From d69bc23894806b2ccd8ee79d0e939b11d9b62f6a Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Tue, 22 May 2012 17:38:33 -0700 Subject: [PATCH 001/257] Initial version of CCBReader reading ccbi format. (Only reads and checks the header so far). --- .../extensions/CCBReader/CCBCustomClass.cpp | 78 -- .../extensions/CCBReader/CCBCustomClass.h | 97 --- cocos2dx/extensions/CCBReader/CCBReader.cpp | 141 ++++ cocos2dx/extensions/CCBReader/CCBReader.h | 111 +-- .../extensions/CCBReader/CCBReader_v1.cpp | 707 ---------------- .../extensions/CCBReader/CCBReader_v2.cpp | 768 ------------------ 6 files changed, 167 insertions(+), 1735 deletions(-) delete mode 100644 cocos2dx/extensions/CCBReader/CCBCustomClass.cpp delete mode 100644 cocos2dx/extensions/CCBReader/CCBCustomClass.h create mode 100644 cocos2dx/extensions/CCBReader/CCBReader.cpp delete mode 100644 cocos2dx/extensions/CCBReader/CCBReader_v1.cpp delete mode 100644 cocos2dx/extensions/CCBReader/CCBReader_v2.cpp diff --git a/cocos2dx/extensions/CCBReader/CCBCustomClass.cpp b/cocos2dx/extensions/CCBReader/CCBCustomClass.cpp deleted file mode 100644 index 59d299d4e2..0000000000 --- a/cocos2dx/extensions/CCBReader/CCBCustomClass.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** - Copyright (c) 2012 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCBCustomClass.h" - -USING_NS_CC_EXT; - -static CCBCustomClassFactory g_FactoryInstance; - -// CCBCustomClassFactory -CCBCustomClassFactory::CCBCustomClassFactory() -{ - m_pCustomCreatorsMap = new CUSTOM_CLASS_MAP; -} - -CCBCustomClassFactory::~CCBCustomClassFactory() -{ - CC_SAFE_DELETE(m_pCustomCreatorsMap); -} - -CCBCustomClassFactory* CCBCustomClassFactory::sharedFactory() -{ - // TBD: don't use static global variable, so ugly - return &g_FactoryInstance; -} - -bool CCBCustomClassFactory::registCustomClass(const char* name, FUNC_CUSTON_CLASS_CREATOR pfnCreator) -{ - bool bRetVal = false; - - if (! (*m_pCustomCreatorsMap)[name] ) - { - (*m_pCustomCreatorsMap)[name] = pfnCreator; - bRetVal = true; - } - else - { - CCLOG("CCB: key = [%s] in m_pCustomCreatorsMap is already registed", name); - } - - return bRetVal; -} - -CCBCustomClassProtocol* CCBCustomClassFactory::createCustomClassWithName(const char* name) -{ - CCBCustomClassProtocol* pRetVal = NULL; - FUNC_CUSTON_CLASS_CREATOR pfnCreator = (*m_pCustomCreatorsMap)[name]; - - if (pfnCreator) - { - CCLOG("CCB: creating [%s] object", name); - pRetVal = pfnCreator(); - } - - return pRetVal; -} - diff --git a/cocos2dx/extensions/CCBReader/CCBCustomClass.h b/cocos2dx/extensions/CCBReader/CCBCustomClass.h deleted file mode 100644 index 4c5dba18db..0000000000 --- a/cocos2dx/extensions/CCBReader/CCBCustomClass.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** - Copyright (c) 2012 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef _CC_CUSTOM_CLASS_H_ -#define _CC_CUSTOM_CLASS_H_ - -#include "cocos2d.h" -#include - -NS_CC_EXT_BEGIN - -/** - @brief This is a simple reflection implement for custom classes in CocosBuilder - - You should declare your custom class like: - class MyCustomLayer : public CCBCustomClass, public CCLayer - CCBCustomClass is a pure virtual class. It doesn't inherit CCObject to prevent dead-diamond. -*/ -class CCBCustomClassProtocol -{ -public: - /** You should implement this static function in your custom class, and return a valid object */ - static CCBCustomClassProtocol* createInstance() { return NULL; }; // cannot create virual class here - - CCBCustomClassProtocol() {}; - virtual ~CCBCustomClassProtocol() {}; - - /** This pure virtual methods should be implemented in your custom class - please refer to tests/ExtensionsTest/CocosBuilderTest as a sample */ - virtual bool callbackSetChildren(const char* name, cocos2d::CCObject* node) = 0; - - /** This pure virtual methods should be implemented in your custom class - please refer to tests/ExtensionsTest/CocosBuilderTest as a sample */ - virtual cocos2d::SEL_MenuHandler callbackGetSelectors(const char* selectorName) = 0; - - /** This pure virtual methods should be implemented in your custom class - please refer to tests/ExtensionsTest/CocosBuilderTest as a sample */ - virtual void callbackAfterCCBLoaded() = 0; -}; - -/** - @brief CCBCustomClass should be registed into this factory, then CCBReader can create your custom class via its name string. - - See tests/Extensionstest/CocosBuilderTest/CocosBuilderTest.cpp as the reference - */ -class CC_DLL CCBCustomClassFactory -{ -private: - /// a function pointer for CCCustomClassProtocol::createInstance - typedef CCBCustomClassProtocol* (*FUNC_CUSTON_CLASS_CREATOR)(); - typedef std::map CUSTOM_CLASS_MAP; - CUSTOM_CLASS_MAP* m_pCustomCreatorsMap; - -public: - CCBCustomClassFactory(); - virtual ~CCBCustomClassFactory(); - - /** get the singleton */ - static CCBCustomClassFactory* sharedFactory(); - - /** Note that you should regist custom class before invoke CCBReader::nodeGraphFromFile - For example: - CCBCustomClassFactory::sharedFactory()->registCustomClass("HelloCocosBuilder", - HelloCocosBuilder::createInstance); - */ - bool registCustomClass(const char* name, FUNC_CUSTON_CLASS_CREATOR pfnCreator); - - /** This function is only used in CCBReader. Developers don't need to know it */ - CCBCustomClassProtocol* createCustomClassWithName(const char* name); - - -}; - -NS_CC_EXT_END; - -#endif // _CC_CUSTOM_CLASS_H_ diff --git a/cocos2dx/extensions/CCBReader/CCBReader.cpp b/cocos2dx/extensions/CCBReader/CCBReader.cpp new file mode 100644 index 0000000000..9a63184ad0 --- /dev/null +++ b/cocos2dx/extensions/CCBReader/CCBReader.cpp @@ -0,0 +1,141 @@ +#include "CCBReader.h" + +using namespace cocos2d; +using namespace cocos2d::extension; + +CCBReader::CCBReader() { + +} + +CCBReader::~CCBReader() { + if(this->mBytes) { + delete this->mBytes; + this->mBytes = NULL; + } + + if(this->mStringCache) { + delete this->mStringCache; + this->mStringCache = NULL; + } +} + +CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBFileName, CCNode * pOwner) { + const char * path = CCFileUtils::fullPathFromRelativePath(pCCBFileName); + + CCFileUtils::ccLoadFileIntoMemory(path, &this->mBytes); + + this->mCurrentByte = 0; + this->mCurrentBit = 0; + + if(!this->readHeader()) { + return NULL; + } + + if(!this->readStringCache()) { + return NULL; + } + + return this->readNodeGraph(); +} + +bool CCBReader::readHeader() { + /* If no bytes loaded, don't crash about it. */ + if(this->mBytes == NULL) { + return false; + } + + /* Read magic bytes */ + int magicBytes = *((int*)(this->mBytes + this->mCurrentByte)); + this->mCurrentByte += 4; + + if(magicBytes != 'ccbi') { + return false; + } + + /* Read version. */ + int version = this->readInt(false); + if(version != kCCBVersion) { + CCLog("WARNING! Incompatible ccbi file version (file: %d reader: %d)", version, kCCBVersion); + return false; + } + + return true; +} + +bool CCBReader::readStringCache() { + return true; +} + +int CCBReader::readInt(bool pSign) { + int numBits = 0; + while(!this->getBit()) { + numBits++; + } + + long long current = 0; + for(int a = numBits - 1; a >= 0; a--) { + if(this->getBit()) { + current |= 1 << a; + } + } + current |= 1 << numBits; + + int num; + if(pSign) { + int s = current % 2; + if(s) { + num = (int)(current / 2); + } else { + num = (int)(-current / 2); + } + } else { + num = current-1; + } + + this->alignBits(); + + return num; +} + +bool CCBReader::getBit() { + bool bit; + unsigned char byte = *(this->mBytes + this->mCurrentByte); + if(byte & (1 << this->mCurrentBit)) { + bit = true; + } else { + bit = false; + } + + this->mCurrentBit++; + + if(this->mCurrentBit >= 8) { + this->mCurrentBit = 0; + this->mCurrentBit++; + } + + return bit; +} + +void CCBReader::alignBits() { + if(this->mCurrentBit) { + this->mCurrentBit = 0; + this->mCurrentByte++; + } +} + +CCNode * CCBReader::readNodeGraph() { + CCLayerColor * ccLayerColor = CCLayerColor::node(); + + CCSize size; + size.setSize(100, 100); + ccLayerColor->setContentSize(size); + + ccColor3B color; + color.r = 255; + color.g = 0; + color.b = 0; + ccLayerColor->setColor(color); + ccLayerColor->setOpacity(255); + + return ccLayerColor; +} \ No newline at end of file diff --git a/cocos2dx/extensions/CCBReader/CCBReader.h b/cocos2dx/extensions/CCBReader/CCBReader.h index fd7560bf19..ddd8800925 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader.h +++ b/cocos2dx/extensions/CCBReader/CCBReader.h @@ -28,98 +28,39 @@ #define __CCB_READER_H__ #include "cocos2d.h" -#include "CCBCustomClass.h" + +#define kCCBVersion 2 NS_CC_EXT_BEGIN /** - @brief Parse CCB file which is generated by CocosBuilder - @warning support CocosBuilder v1 currently. I will update this to v3 when CCB format is stable + * @brief Parse CCBI file which is generated by CocosBuilder */ -class CC_DLL CCBReader : public CCObject -{ -public: - static CCNode* nodeGraphFromFile(const char* ccbFileName, CCNode* owner = NULL); +class CC_DLL CCBReader : public CCObject { + private: + unsigned char * mBytes; + int mCurrentByte; + int mCurrentBit; + + std::vector * mStringCache; + + public: + /* Constructor. */ + CCBReader(); + /* Destructor. */ + ~CCBReader(); + + CCNode * readNodeGraphFromFile(const char* ccbFileName, CCNode* owner = NULL); -private: - static CCNode* nodeGraphFromDictionary(CCDictionary* dict, - CCDictionary* extraProps, - const char* ccbFilePath, - CCNode* owner); - static CCNode* createCustomClassWithName(CCString* className); + private: + bool readHeader(); + bool readStringCache(); + CCNode * readNodeGraph(); - static CCNode* ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extraProps, - const char* assetsDir, CCNode* owner, CCNode* root); - - // read different types of values from dict - - static int intValFromDict(CCDictionary* dict, const std::string key); - - static float floatValFromDict(CCDictionary* dict, const std::string key); - - static bool boolValFromDict(CCDictionary* dict, const std::string key); - - static CCPoint pointValFromDict(CCDictionary* dict, const std::string key); - - static CCSize sizeValFromDict(CCDictionary* dict, const std::string key); - - static ccColor3B ccColor3ValFromDict(CCDictionary* dict, - const std::string key); - - static ccColor4F ccColor4fValFromDict(CCDictionary* dict, - const std::string key); - - static ccBlendFunc blendFuncValFromDict(CCDictionary* dict, - const std::string key); - -private: - // set properties - - static void setExtraProp(CCObject* prop, const char* key, int tag, CCDictionary* dict); - - static void setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* extraProps); - - static void setPropsForSprite(CCSprite* node, CCDictionary* props, - CCDictionary* extraProps); - - static void setPropsForLabelBMFont(CCLabelBMFont* node, CCDictionary* props, - CCDictionary* extraProps); - - static void setPropsForParticleSystem(CCParticleSystem* node, CCDictionary* props, CCDictionary* extraProps); - - static void setPropsForMenu(CCMenu* node, CCDictionary* props, CCDictionary* extraProps); - - static void setPropsForMenuItem(CCMenuItem* node, CCDictionary* props, CCDictionary* extraProps); - - static void setPropsForMenuItemImage(CCMenuItemImage* node, CCDictionary* props, CCDictionary* extraProps); - - static void setPropsForLayer(CCLayer* node, CCDictionary* props, CCDictionary* extraProps); - - static void setPropsForLayerColor(CCLayerColor* node, CCDictionary* props, CCDictionary* extraProps); - - static void setPropsForLayerGradient(CCLayerGradient* node, CCDictionary* props, CCDictionary* extraProps); - -private: - enum - { - kCCBMemberVarAssignmentTypeNone = 0, - kCCBMemberVarAssignmentTypeDocumentRoot = 1, - kCCBMemberVarAssignmentTypeOwner = 2, - }; - - enum { - kInvalidRelativePosition = 0, - kBottomLeft = 1, - kBottom = 2, - kBottomRight = 3, - kCenterLeft = 4, - kCenter = 5, - kCenterRight = 6, - kTopLeft = 7, - kTop = 8, - kTopRight = 9, - }; -}; // end of class CCBReader + bool getBit(); + void alignBits(); + int readInt(bool pSign); +}; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp b/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp deleted file mode 100644 index 0cea9e4a3c..0000000000 --- a/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp +++ /dev/null @@ -1,707 +0,0 @@ -/**************************************************************************** - Copyright (c) 2012 cocos2d-x.org - Copyright (c) 2012 XiaoLong Zhang, Chukong Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCBReader.h" -#include "CCBCustomClass.h" - -USING_NS_CC; -USING_NS_CC_EXT; - -// Read value from dictionary - -int CCBReader::intValFromDict(CCDictionary* dict, const std::string key) -{ - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); - return valueString->intValue(); -} - -float CCBReader::floatValFromDict(CCDictionary* dict, const std::string key) -{ - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); - return valueString->floatValue(); -} - -bool CCBReader::boolValFromDict(CCDictionary* dict, const std::string key) -{ - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); - return (bool) valueString->intValue(); -} - -CCPoint CCBReader::pointValFromDict(CCDictionary* dict, const std::string key) -{ - CCArray* arr = (CCArray*)dict->objectForKey(key.c_str()); - - if (!arr) - { - return ccp(0,0); - } - - float x = ((CCString*)arr->objectAtIndex(0))->floatValue(); - float y = ((CCString*)arr->objectAtIndex(1))->floatValue(); - return ccp(x, y); -} - -CCSize CCBReader::sizeValFromDict(CCDictionary* dict, const std::string key) -{ - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - - if (!arr) - { - return CCSize(0, 0); - } - - float w = ((CCString*)arr->objectAtIndex(0))->floatValue(); - float h = ((CCString*)arr->objectAtIndex(1))->floatValue(); - return CCSize(w, h); -} - -ccColor3B CCBReader::ccColor3ValFromDict(CCDictionary* dict, const std::string key) -{ - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - - int r = ((CCString*)arr->objectAtIndex(0))->intValue(); - int g = ((CCString*)arr->objectAtIndex(1))->intValue(); - int b = ((CCString*)arr->objectAtIndex(2))->intValue(); - - return ccc3(r, g, b); -} - -ccColor4F CCBReader::ccColor4fValFromDict(CCDictionary* dict, const std::string key) -{ - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - - ccColor4F color; - color.r = ((CCString*)arr->objectAtIndex(0))->floatValue(); - color.g = ((CCString*)arr->objectAtIndex(1))->floatValue(); - color.b = ((CCString*)arr->objectAtIndex(2))->floatValue(); - color.a = ((CCString*)arr->objectAtIndex(3))->floatValue(); - - return color; -} - -ccBlendFunc CCBReader::blendFuncValFromDict(CCDictionary* dict, const std::string key) -{ - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - - int src = ((CCString*)arr->objectAtIndex(0))->intValue(); - int dst = ((CCString*)arr->objectAtIndex(1))->intValue(); - - ccBlendFunc blendFunc; - blendFunc.src = src; - blendFunc.dst = dst; - - return blendFunc; -} - -// set extra properties - -void CCBReader::setExtraProp(CCObject* prop, const char* key, int tag, CCDictionary* dict) -{ - std::string tagString; - tagString += tag; - CCDictionary* props = (CCDictionary*) dict->objectForKey(tagString.c_str()); - - if (!props) - { - props = new CCDictionary(); - dict->setObject(props, tagString.c_str()); - } - - props->setObject(prop, key); -} - -void CCBReader::setPropsForMenuItem(CCMenuItem* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setIsEnabled(boolValFromDict(props, "isEnabled")); - if (extraProps) - { - setExtraProp((CCDictionary*) props->objectForKey("selector"), "selector", node->getTag(), extraProps); - setExtraProp((CCDictionary*) props->objectForKey("target"), "target", node->getTag(), extraProps); - CCString* spriteFramesFile = (CCString*) props->objectForKey("spriteFramesFile"); - - if (spriteFramesFile) - { - setExtraProp(spriteFramesFile, "spriteSheetFile", node->getTag(), extraProps); - } - } -} - -void CCBReader::setPropsForMenuItemImage(CCMenuItemImage* node, CCDictionary* props, CCDictionary* extraProps) -{ - if (extraProps) - { - setExtraProp(props->objectForKey("spriteFileNormal"), "spriteFileNormal", node->getTag(), extraProps); - setExtraProp(props->objectForKey("spriteFileSelected"), "spriteFileSelected", node->getTag(), extraProps); - setExtraProp(props->objectForKey("spriteFileDisabled"), "spriteFileDisabled", node->getTag(), extraProps); - } -} - -void CCBReader::setPropsForLayerColor(CCLayerColor* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setColor(ccColor3ValFromDict(props, "color")); - node->setOpacity(intValFromDict(props, "opacity")); - node->setBlendFunc(blendFuncValFromDict(props, "blendFunc")); -} - -void CCBReader::setPropsForLayer(CCLayer* node, CCDictionary* props, CCDictionary* extraProps) -{ - if (extraProps) - { - setExtraProp(props->objectForKey("touchEnabled"), "touchEnabled", node->getTag(), extraProps); - setExtraProp(props->objectForKey("accelerometerEnabled"), "accelerometerEnabled", node->getTag(), extraProps); - setExtraProp(props->objectForKey("mouseEnabled"), "mouseEnabled", node->getTag() ,extraProps); - setExtraProp(props->objectForKey("keyboardEnabled"), "keyboardEnabled", node->getTag(), extraProps); - } - else - { - node->setIsTouchEnabled(boolValFromDict(props, "touchEnabled")); - node->setIsAccelerometerEnabled(boolValFromDict(props, "accelerometerEnabled")); - } -} - -void CCBReader::setPropsForMenu(CCMenu* node, CCDictionary* props, CCDictionary* extraProps) -{ - if (extraProps) - { - - } -} - -void CCBReader::setPropsForLabelBMFont(CCLabelBMFont* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setOpacity(intValFromDict(props, "opacity")); - node->setColor(ccColor3ValFromDict(props, "color")); - - if (extraProps) - { - setExtraProp(props->objectForKey("fontFile"), "fontFile", node->getTag(), extraProps); - } -} - -void CCBReader::setPropsForParticleSystem(CCParticleSystem* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setEmitterMode(intValFromDict(props, "emitterMode")); - node->setEmissionRate(floatValFromDict(props, "emissionRate")); - node->setDuration(floatValFromDict(props, "duration")); - node->setPosVar(pointValFromDict(props, "posVar")); - node->setTotalParticles(intValFromDict(props, "totalParticles")); - node->setLife(floatValFromDict(props, "life")); - node->setLifeVar(floatValFromDict(props, "lifeVar")); - node->setStartSize(intValFromDict(props, "startSize")); - node->setStartSizeVar(intValFromDict(props, "startSizeVar")); - node->setEndSize(intValFromDict(props, "endSize")); - node->setEndSizeVar(intValFromDict(props, "endSizeVar")); - - if (dynamic_cast(node)) - { - node->setStartSpin(intValFromDict(props, "startSpin")); - node->setStartSpinVar(intValFromDict(props, "startSpinVar")); - node->setEndSpin(intValFromDict(props, "endSpin")); - node->setEndSpinVar(intValFromDict(props, "endSpinVar")); - } - - node->setStartColor(ccColor4fValFromDict(props, "startColor")); - node->setStartColorVar(ccColor4fValFromDict(props, "startColorVar")); - node->setEndColor(ccColor4fValFromDict(props, "endColor")); - node->setEndColorVar(ccColor4fValFromDict(props, "endColorVar")); - node->setBlendFunc(blendFuncValFromDict(props, "blendFunc")); - - if (node->getEmitterMode() == kCCParticleModeGravity) - { - node->setGravity(pointValFromDict(props, "gravity")); - node->setAngle(intValFromDict(props, "angle")); - node->setAngleVar(intValFromDict(props, "angleVar")); - node->setSpeed(intValFromDict(props, "speed")); - node->setSpeedVar(intValFromDict(props, "speedVar")); - node->setTangentialAccel(intValFromDict(props, "tangentialAccel")); - node->setTangentialAccelVar(intValFromDict(props, "tangentialAccelVar")); - node->setRadialAccel(intValFromDict(props, "radialAccel")); - node->setRadialAccelVar(intValFromDict(props, "radialAccelVar")); - } - else - { - node->setStartRadius(intValFromDict(props, "startRadius")); - node->setStartRadiusVar(intValFromDict(props, "startRadiusVar")); - node->setEndRadius(intValFromDict(props, "endRadius")); - node->setEndRadiusVar(intValFromDict(props, "endRadiusVar")); - node->setRotatePerSecond(intValFromDict(props, "rotatePerSecond")); - node->setRotatePerSecondVar(intValFromDict(props, "rotatePerSecondVar")); - } - - if (extraProps) - { - setExtraProp(props->objectForKey("spriteFile"), "spriteFile", node->getTag(), extraProps); - } - node->setPositionType(kCCPositionTypeGrouped); -} - -void CCBReader::setPropsForLayerGradient(CCLayerGradient* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setStartColor(ccColor3ValFromDict(props, "color")); - node->setStartOpacity(intValFromDict(props, "opacity")); - node->setEndColor(ccColor3ValFromDict(props, "endColor")); - node->setEndOpacity(intValFromDict(props, "endOpacity")); - node->setVector(pointValFromDict(props, "vector")); -} - -CCNode* CCBReader::createCustomClassWithName(CCString* className) -{ - CCNode* pRetVal = NULL; - - if (className && className->length()) - { - CCBCustomClassProtocol* pNewClass = CCBCustomClassFactory::sharedFactory()->createCustomClassWithName(className->getCString()); - pRetVal = dynamic_cast(pNewClass); - } - - return pRetVal; -} - -void CCBReader::setPropsForSprite(CCSprite* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setOpacity(intValFromDict(props, "opacity")); - node->setColor(ccColor3ValFromDict(props, "color")); - node->setFlipX(boolValFromDict(props, "flipX")); - node->setFlipY(boolValFromDict(props, "flipY")); - node->setBlendFunc(blendFuncValFromDict(props, "blendFunc")); - - if (extraProps) - { - setExtraProp(props->objectForKey("spriteFile"), "spriteFile", node->getTag(), extraProps); - CCString* spriteFramesFile = (CCString*) props->objectForKey("spriteFramesFile"); - - if (spriteFramesFile) - { - setExtraProp(spriteFramesFile, "spriteSheetFile", node->getTag(), extraProps); - } - } -} - -void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* extraProps) -{ - CCPoint position = pointValFromDict(props, "position"); - node->setPosition(position); - - if (dynamic_cast(node) == NULL && - dynamic_cast(node) == NULL && - dynamic_cast(node) == NULL) - { - CCSize size = sizeValFromDict(props, "contentSize"); - //node->setContentSize(size); - } - - node->setScaleX(floatValFromDict(props, "scaleX")); - node->setScaleY(floatValFromDict(props, "scaleY")); - node->setAnchorPoint(pointValFromDict(props, "anchorPoint")); - node->setRotation(floatValFromDict(props, "rotation")); - node->setIsRelativeAnchorPoint(boolValFromDict(props, "isRelativeAnchorPoint")); - node->setIsVisible(boolValFromDict(props, "visible")); - - if (extraProps) - { - if (node->getTag() == -1) - { - node->setTag(extraProps->count() + 1); - } - - setExtraProp(props->objectForKey("tag"), "tag", node->getTag(), extraProps); - - setExtraProp((CCDictionary*) props->objectForKey("customClass"), "customClass", node->getTag(), extraProps); - setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentType"), "memberVarAssignmentType", node->getTag(), extraProps); - setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentName"), "memberVarAssignmentName", node->getTag(), extraProps); - setExtraProp((CCDictionary*) props->objectForKey("lockedScaleRatio"), "lockedScaleRatio", node->getTag(), extraProps); - - // Expanded nodes - bool isExpanded; - CCString* isExpandedObj = (CCString*) props->objectForKey("isExpanded"); - - if (isExpandedObj) { - isExpanded = !isExpandedObj->m_sString.empty(); - } else { - isExpanded = true; - } - - setExtraProp(isExpandedObj, "isExpanded", node->getTag(), extraProps); - } - else - { - node->setTag(intValFromDict(props, "tag")); - } -} - - -CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extraProps, - const char* assetsDir, CCNode* owner, CCNode* root) -{ - CCString* className = (CCString*) dict->objectForKey("class"); - CCDictionary* props = (CCDictionary*) dict->objectForKey("properties"); - CCArray* children = (CCArray*) dict->objectForKey("children"); - - CCString* customClass = (CCString*)props->objectForKey("customClass"); - - if (extraProps) customClass = NULL; - - CCNode* node = NULL; - - if (className->m_sString.compare("CCParticleSystem") == 0) - { - CCString* spriteFile = new CCString(assetsDir); - spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; - - CCParticleSystem* sys = new CCParticleSystemQuad(); - sys->initWithTotalParticles(2048); - sys->setTexture(CCTextureCache::sharedTextureCache()->addImage(spriteFile->m_sString.c_str())); - delete spriteFile; - node = (CCNode*)sys; - - setPropsForNode((CCNode*)node, (CCDictionary*) props, extraProps); - setPropsForParticleSystem((CCParticleSystem*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCMenuItemImage") == 0) - { - CCString* spriteFileNormal = new CCString(assetsDir); - spriteFileNormal->m_sString += ((CCString*)props->objectForKey("spriteFileNormal"))->getCString(); - CCString* spriteFileSelected = new CCString(assetsDir); - spriteFileSelected->m_sString += ((CCString*)props->objectForKey("spriteFileSelected"))->getCString(); - CCString* spriteFileDisabled = new CCString(assetsDir); - spriteFileDisabled->m_sString += ((CCString*)props->objectForKey("spriteFileDisabled"))->getCString(); - - CCSprite* spriteNormal = NULL; - CCSprite* spriteSelected = NULL; - CCSprite* spriteDisabled = NULL; - - CCString* spriteSheetFile = (CCString*)props->objectForKey("spriteFramesFile"); - if (spriteSheetFile && !spriteSheetFile->length()) { - spriteSheetFile->m_sString.insert(0, assetsDir); - } - - if (spriteSheetFile && !spriteSheetFile->length()) - { - CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(spriteSheetFile->m_sString.c_str()); - - spriteNormal = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileNormal"))->getCString()); - spriteSelected = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileSelected"))->getCString()); - spriteDisabled = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileDisabled"))->getCString()); - // TBD: how to defense if exception raise here? - } - else - { - spriteNormal = CCSprite::spriteWithFile(spriteFileNormal->m_sString.c_str()); - spriteSelected = CCSprite::spriteWithFile(spriteFileSelected->m_sString.c_str()); - spriteDisabled = CCSprite::spriteWithFile(spriteFileDisabled->m_sString.c_str()); - } - - //deallocate - CC_SAFE_DELETE(spriteFileNormal); - CC_SAFE_DELETE(spriteFileSelected); - CC_SAFE_DELETE(spriteFileDisabled); - - if (!spriteNormal) spriteNormal = CCSprite::spriteWithFile("missing-texture.png"); - if (!spriteSelected) spriteSelected = CCSprite::spriteWithFile("missing-texture.png"); - if (!spriteDisabled) spriteDisabled = CCSprite::spriteWithFile("missing-texture.png"); - - CCNode *target = NULL ; - if ( extraProps == NULL ) - { - int targetType = ((CCString*)(props->objectForKey("target")))->intValue() ; - if ( targetType == kCCBMemberVarAssignmentTypeDocumentRoot ) - target = (CCNode*)root ; - else if ( targetType == kCCBMemberVarAssignmentTypeOwner ) - target = (CCNode*)owner ; - - } - - CCString *selectorName = (CCString*)props->objectForKey("selector") ; - SEL_MenuHandler sel = NULL; - - if ( selectorName->length() ) - { - sel = dynamic_cast(target)->callbackGetSelectors(selectorName->getCString()); - } - else - { - CCLOG("WARNING! CCMenuItemImage target doesn't respond to selector %@",selectorName) ; - target = NULL ; - } - - node = (CCNode*)CCMenuItemImage::itemWithNormalSprite((CCNode*) spriteNormal, (CCNode*) spriteSelected, (CCNode*) spriteDisabled, target, sel); - - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForMenuItem((CCMenuItem*) node, (CCDictionary*) props, extraProps); - setPropsForMenuItemImage((CCMenuItemImage*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCMenu") == 0) - { - node = (CCNode*)CCMenu::menuWithItems(NULL); - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps); - setPropsForMenu((CCMenu*)node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCLabelBMFont") == 0) - { - CCString* fontFile = new CCString(assetsDir); - fontFile->m_sString += ((CCString*)props->objectForKey("fontFile"))->m_sString; - CCString* stringText = ((CCString*)props->objectForKey("string")); - - node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), - fontFile->m_sString.c_str() ); - - - delete fontFile; - fontFile = 0; - - if (!node) node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), "missing-font.fnt"); - - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLabelBMFont((CCLabelBMFont*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCSprite") == 0) - { - CCString* spriteFile = new CCString(assetsDir); - spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; - CCString* spriteSheetFile = (CCString*)props->objectForKey("spriteFramesFile"); - - if (spriteSheetFile && !spriteSheetFile->length()) - { - spriteSheetFile->m_sString.insert(0, assetsDir); - } - - if (spriteSheetFile && !spriteSheetFile->length()) - { - CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(spriteSheetFile->m_sString.c_str()); - node = (CCNode*)CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFile"))->m_sString.c_str()); - // TBD: how to defense if exception raise here? - } - else - { - printf("spriteFile->m_string.cstr is %s\n", spriteFile->m_sString.c_str()) ; - node = (CCNode*)CCSprite::spriteWithFile(spriteFile->m_sString.c_str()); - } - - CC_SAFE_RELEASE_NULL(spriteFile); - - if (!node) node = (CCNode*)CCSprite::spriteWithFile("missing-texture.png"); - - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForSprite((CCSprite*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCLayerGradient") == 0) - { - node = (CCNode*)createCustomClassWithName(customClass) ; - if (node) - { - if (dynamic_cast(node) == NULL) - { - CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; - node = NULL; - } - } - else - { - node = (CCNode*)CCLayerGradient::node(); - } - - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps); - setPropsForLayerColor((CCLayerColor*) node, (CCDictionary*) props, extraProps); - setPropsForLayerGradient((CCLayerGradient*) node, (CCDictionary*) props, extraProps); - - } - else if (className->m_sString.compare("CCLayerColor") == 0) - { - node = (CCNode*)createCustomClassWithName(customClass) ; - if (node) - { - if (dynamic_cast(node) == NULL) - { - CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; - node = NULL; - } - } - else - { - node = (CCNode*)CCLayerColor::node(); - } - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps); - setPropsForLayerColor((CCLayerColor*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCLayer") == 0) - { - node = (CCNode*)createCustomClassWithName(customClass) ; - if (node) - { - if (dynamic_cast(node) == NULL) - { - CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; - node = NULL; - } - } - else - { - node = (CCNode*)CCLayer::node(); - } - - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCNode") == 0) - { - node = (CCNode*)createCustomClassWithName(customClass) ; - - if (node) - { - if (dynamic_cast(node) == NULL) - { - CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; - node = NULL; - } - } - else - { - node = (CCNode*)CCNode::node(); - } - - setPropsForNode(node, (CCDictionary*) props, extraProps); - } - else - { - CCLOG("WARNING! Class of type %@ couldn't be found", className); - return NULL; - } - - if (!root) root = node; - - // Add children - for (unsigned int i = 0; i < children->count(); i++) - { - CCDictionary* childDict = (CCDictionary*) children->objectAtIndex(i); - CCNode* child = ccObjectFromDictionary(childDict, extraProps, assetsDir, owner, root); - int zOrder = intValFromDict((CCDictionary*) childDict->objectForKey("properties"), "zOrder"); - - if (child && node) - { - node->addChild(child, zOrder); - } - else - { - CCLOG("WARNING! Failed to add child to node"); - } - } - - if ( !extraProps ) - { - CCString* assignmentName = (CCString*)props->objectForKey("memberVarAssignmentName"); - CCLOG("assignmentName is %s", assignmentName->getCString()) ; - int assignmentType = ((CCString*)(props->objectForKey("memberVarAssignmentType")))->intValue() ; - - if ( !assignmentName->m_sString.empty() && - assignmentType) - { - CCBCustomClassProtocol* assignTo = NULL ; - if ( assignmentType == kCCBMemberVarAssignmentTypeOwner ) - { - assignTo = dynamic_cast(owner); - } - else if ( assignmentType == kCCBMemberVarAssignmentTypeDocumentRoot ) - { - assignTo = dynamic_cast(root); - } - - if ( assignTo != NULL ) - { - CCLOG("assign [%s]", assignmentName->getCString()); - assignTo->callbackSetChildren(assignmentName->getCString(), node); - } - } - if (customClass->length()) - { - CCBCustomClassProtocol* pCustom = dynamic_cast(node); - if (pCustom) - { - pCustom->callbackAfterCCBLoaded(); - } - } - - } - return node; -} - -// initialize ccbreader - -CCNode* CCBReader::nodeGraphFromDictionary(CCDictionary* dict, - CCDictionary* extraProps, - const char* assetsDir, - CCNode* owner) -{ - if (!dict) - { - CCLOG("WARNING! Trying to load invalid file type"); - return NULL; - } - - CCString* fileType = (CCString*) dict->objectForKey("fileType"); - int fileVersion = ((CCString*) dict->objectForKey("fileVersion"))->intValue(); - - if (!fileType || fileType->m_sString.compare("CocosBuilder") != 0) - { - CCLOG("WARNING! Trying to load invalid file type"); - } - - if (fileVersion > 1) - { - CCLOG("WARNING! Trying to load file made with a newer version of CocosBuilder, please update the CCBReader class"); - return NULL; - } - - CCDictionary* nodeGraph = (CCDictionary*) dict->objectForKey("nodeGraph"); - return ccObjectFromDictionary(nodeGraph, extraProps, assetsDir, owner, NULL); -} - -CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner) -{ - CCLOG("CCBReader path is: %s", file); - std::string ccbFilePath(file); - std::string ccbFileDir; - - // find ccbFileDir before "/" or "\" - // for example, if ccbFilePath = "CocosBuilder/example.ccb", - // then we should make ccbFileDir = "CocosBuilder/" - size_t lastSlash = ccbFilePath.find_last_of("/"); - if (lastSlash != std::string::npos) - { - ccbFileDir = ccbFilePath.substr(0, lastSlash) + "/"; - } - - CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(ccbFilePath.c_str()); - CCAssert(dict != NULL, "CCBReader: file not found"); - - return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner); -} - diff --git a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp deleted file mode 100644 index f82b7dbbd9..0000000000 --- a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp +++ /dev/null @@ -1,768 +0,0 @@ -/**************************************************************************** - Copyright (c) 2012 cocos2d-x.org - Copyright (c) 2012 XiaoLong Zhang, Chukong Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCBReader.h" -#include "CCBCustomClass.h" - -USING_NS_CC; -USING_NS_CC_EXT; - -// Read value from dictionary - -int CCBReader::intValFromDict(CCDictionary* dict, const std::string key) -{ - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); - return valueString? valueString->intValue() : 0; -} - -float CCBReader::floatValFromDict(CCDictionary* dict, const std::string key) -{ - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); - return valueString? valueString->floatValue() : 0; -} - -bool CCBReader::boolValFromDict(CCDictionary* dict, const std::string key) -{ - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); - return valueString? ((bool)(valueString->intValue())) : false; -} - -CCPoint CCBReader::pointValFromDict(CCDictionary* dict, const std::string key) -{ - CCArray* arr = (CCArray*)dict->objectForKey(key.c_str()); - - if (!arr) - { - return ccp(0,0); - } - - float x = ((CCString*)arr->objectAtIndex(0))->floatValue(); - float y = ((CCString*)arr->objectAtIndex(1))->floatValue(); - return ccp(x, y); -} - -CCSize CCBReader::sizeValFromDict(CCDictionary* dict, const std::string key) -{ - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - - if (!arr) - { - return CCSize(0, 0); - } - - float w = ((CCString*)arr->objectAtIndex(0))->floatValue(); - float h = ((CCString*)arr->objectAtIndex(1))->floatValue(); - return CCSize(w, h); -} - -ccColor3B CCBReader::ccColor3ValFromDict(CCDictionary* dict, const std::string key) -{ - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - - int r = ((CCString*)arr->objectAtIndex(0))->intValue(); - int g = ((CCString*)arr->objectAtIndex(1))->intValue(); - int b = ((CCString*)arr->objectAtIndex(2))->intValue(); - - return ccc3(r, g, b); -} - -ccColor4F CCBReader::ccColor4fValFromDict(CCDictionary* dict, const std::string key) -{ - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - - ccColor4F color; - color.r = ((CCString*)arr->objectAtIndex(0))->floatValue(); - color.g = ((CCString*)arr->objectAtIndex(1))->floatValue(); - color.b = ((CCString*)arr->objectAtIndex(2))->floatValue(); - color.a = ((CCString*)arr->objectAtIndex(3))->floatValue(); - - return color; -} - -ccBlendFunc CCBReader::blendFuncValFromDict(CCDictionary* dict, const std::string key) -{ - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - - int src = ((CCString*)arr->objectAtIndex(0))->intValue(); - int dst = ((CCString*)arr->objectAtIndex(1))->intValue(); - - ccBlendFunc blendFunc; - blendFunc.src = src; - blendFunc.dst = dst; - - return blendFunc; -} - -// set extra properties - -void CCBReader::setExtraProp(CCObject* prop, const char* key, int tag, CCDictionary* dict) -{ - std::string tagString; - tagString += tag; - CCDictionary* props = (CCDictionary*) dict->objectForKey(tagString.c_str()); - - if (!props) - { - props = new CCDictionary(); - dict->setObject(props, tagString.c_str()); - } - - props->setObject(prop, key); -} - -void CCBReader::setPropsForMenuItem(CCMenuItem* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setIsEnabled(boolValFromDict(props, "isEnabled")); - if (extraProps) - { - setExtraProp((CCDictionary*) props->objectForKey("selector"), "selector", node->getTag(), extraProps); - setExtraProp((CCDictionary*) props->objectForKey("target"), "target", node->getTag(), extraProps); - CCString* spriteFramesFile = (CCString*) props->objectForKey("spriteFramesFile"); - - if (spriteFramesFile) - { - setExtraProp(spriteFramesFile, "spriteSheetFile", node->getTag(), extraProps); - } - } -} - -void CCBReader::setPropsForMenuItemImage(CCMenuItemImage* node, CCDictionary* props, CCDictionary* extraProps) -{ - if (extraProps) - { - setExtraProp(props->objectForKey("spriteFileNormal"), "spriteFileNormal", node->getTag(), extraProps); - setExtraProp(props->objectForKey("spriteFileSelected"), "spriteFileSelected", node->getTag(), extraProps); - setExtraProp(props->objectForKey("spriteFileDisabled"), "spriteFileDisabled", node->getTag(), extraProps); - } -} - -void CCBReader::setPropsForLayerColor(CCLayerColor* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setColor(ccColor3ValFromDict(props, "color")); - node->setOpacity(intValFromDict(props, "opacity")); - node->setBlendFunc(blendFuncValFromDict(props, "blendFunc")); -} - -void CCBReader::setPropsForLayer(CCLayer* node, CCDictionary* props, CCDictionary* extraProps) -{ - if (extraProps) - { - setExtraProp(props->objectForKey("touchEnabled"), "touchEnabled", node->getTag(), extraProps); - setExtraProp(props->objectForKey("accelerometerEnabled"), "accelerometerEnabled", node->getTag(), extraProps); - setExtraProp(props->objectForKey("mouseEnabled"), "mouseEnabled", node->getTag() ,extraProps); - setExtraProp(props->objectForKey("keyboardEnabled"), "keyboardEnabled", node->getTag(), extraProps); - } - else - { - node->setIsTouchEnabled(boolValFromDict(props, "touchEnabled")); - node->setIsAccelerometerEnabled(boolValFromDict(props, "accelerometerEnabled")); - } -} - -void CCBReader::setPropsForMenu(CCMenu* node, CCDictionary* props, CCDictionary* extraProps) -{ - if (extraProps) - { - - } -} - -void CCBReader::setPropsForLabelBMFont(CCLabelBMFont* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setOpacity(intValFromDict(props, "opacity")); - node->setColor(ccColor3ValFromDict(props, "color")); - - if (extraProps) - { - setExtraProp(props->objectForKey("fontFile"), "fontFile", node->getTag(), extraProps); - } -} - -void CCBReader::setPropsForParticleSystem(CCParticleSystem* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setEmitterMode(intValFromDict(props, "emitterMode")); - node->setEmissionRate(floatValFromDict(props, "emissionRate")); - node->setDuration(floatValFromDict(props, "duration")); - node->setPosVar(pointValFromDict(props, "posVar")); - node->setTotalParticles(intValFromDict(props, "totalParticles")); - node->setLife(floatValFromDict(props, "life")); - node->setLifeVar(floatValFromDict(props, "lifeVar")); - node->setStartSize(intValFromDict(props, "startSize")); - node->setStartSizeVar(intValFromDict(props, "startSizeVar")); - node->setEndSize(intValFromDict(props, "endSize")); - node->setEndSizeVar(intValFromDict(props, "endSizeVar")); - - if (dynamic_cast(node)) - { - node->setStartSpin(intValFromDict(props, "startSpin")); - node->setStartSpinVar(intValFromDict(props, "startSpinVar")); - node->setEndSpin(intValFromDict(props, "endSpin")); - node->setEndSpinVar(intValFromDict(props, "endSpinVar")); - } - - node->setStartColor(ccColor4fValFromDict(props, "startColor")); - node->setStartColorVar(ccColor4fValFromDict(props, "startColorVar")); - node->setEndColor(ccColor4fValFromDict(props, "endColor")); - node->setEndColorVar(ccColor4fValFromDict(props, "endColorVar")); - node->setBlendFunc(blendFuncValFromDict(props, "blendFunc")); - - if (node->getEmitterMode() == kCCParticleModeGravity) - { - node->setGravity(pointValFromDict(props, "gravity")); - node->setAngle(intValFromDict(props, "angle")); - node->setAngleVar(intValFromDict(props, "angleVar")); - node->setSpeed(intValFromDict(props, "speed")); - node->setSpeedVar(intValFromDict(props, "speedVar")); - node->setTangentialAccel(intValFromDict(props, "tangentialAccel")); - node->setTangentialAccelVar(intValFromDict(props, "tangentialAccelVar")); - node->setRadialAccel(intValFromDict(props, "radialAccel")); - node->setRadialAccelVar(intValFromDict(props, "radialAccelVar")); - } - else - { - node->setStartRadius(intValFromDict(props, "startRadius")); - node->setStartRadiusVar(intValFromDict(props, "startRadiusVar")); - node->setEndRadius(intValFromDict(props, "endRadius")); - node->setEndRadiusVar(intValFromDict(props, "endRadiusVar")); - node->setRotatePerSecond(intValFromDict(props, "rotatePerSecond")); - node->setRotatePerSecondVar(intValFromDict(props, "rotatePerSecondVar")); - } - - if (extraProps) - { - setExtraProp(props->objectForKey("spriteFile"), "spriteFile", node->getTag(), extraProps); - } - node->setPositionType(kCCPositionTypeGrouped); -} - -void CCBReader::setPropsForLayerGradient(CCLayerGradient* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setStartColor(ccColor3ValFromDict(props, "color")); - node->setStartOpacity(intValFromDict(props, "opacity")); - node->setEndColor(ccColor3ValFromDict(props, "endColor")); - node->setEndOpacity(intValFromDict(props, "endOpacity")); - node->setVector(pointValFromDict(props, "vector")); -} - -CCNode* CCBReader::createCustomClassWithName(CCString* className) -{ - CCNode* pRetVal = NULL; - - if (className && className->length()) - { - CCBCustomClassProtocol* pNewClass = CCBCustomClassFactory::sharedFactory()->createCustomClassWithName(className->getCString()); - pRetVal = dynamic_cast(pNewClass); - } - - return pRetVal; -} - -void CCBReader::setPropsForSprite(CCSprite* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setOpacity(intValFromDict(props, "opacity")); - node->setColor(ccColor3ValFromDict(props, "color")); - node->setFlipX(boolValFromDict(props, "flipX")); - node->setFlipY(boolValFromDict(props, "flipY")); - node->setBlendFunc(blendFuncValFromDict(props, "blendFunc")); - - if (extraProps) - { - setExtraProp(props->objectForKey("spriteFile"), "spriteFile", node->getTag(), extraProps); - CCString* spriteFramesFile = (CCString*) props->objectForKey("spriteFramesFile"); - - if (spriteFramesFile) - { - setExtraProp(spriteFramesFile, "spriteSheetFile", node->getTag(), extraProps); - } - } -} - -void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* extraProps) -{ - CCPoint position = pointValFromDict(props, "position"); - int refPointType = intValFromDict(props, "refPointType"); - - if (refPointType == kInvalidRelativePosition) - { - // normal process. - node->setPosition(position); - } - else - { - // support walzer's relative position - CCPoint positionRelative = pointValFromDict(props, "positionRelative"); - CCPoint refPoint(0,0); - CCSize screenSize = CCDirector::sharedDirector()->getWinSize(); - - switch (refPointType) - { - case kInvalidRelativePosition: - - case kBottomLeft: - refPoint.x = 0; - refPoint.y = 0; - break; - case kBottom: - refPoint.x = screenSize.width / 2; - refPoint.y = 0; - break; - case kBottomRight: - refPoint.x = screenSize.width; - refPoint.y = 0; - break; - case kCenterLeft: - refPoint.x = 0; - refPoint.y = screenSize.height / 2; - break; - case kCenter: - refPoint.x = screenSize.width / 2; - refPoint.y = screenSize.height / 2; - break; - case kCenterRight: - refPoint.x = screenSize.width; - refPoint.y = screenSize.height / 2; - break; - case kTopLeft: - refPoint.x = 0; - refPoint.y = screenSize.height; - break; - case kTop: - refPoint.x = screenSize.width / 2; - refPoint.y = screenSize.height; - break; - case kTopRight: - refPoint.x = screenSize.width; - refPoint.y = screenSize.height; - break; - default: - CCLOG("CCReader::setPropsForNode, unexcpeted refPointType"); - } - - position.x = positionRelative.x + refPoint.x; - position.y = positionRelative.y + refPoint.y; - node->setPosition(position); - } - - if (dynamic_cast(node) == NULL && - dynamic_cast(node) == NULL && - dynamic_cast(node) == NULL) - { - CCSize size = sizeValFromDict(props, "contentSize"); - //node->setContentSize(size); - } - - node->setScaleX(floatValFromDict(props, "scaleX")); - node->setScaleY(floatValFromDict(props, "scaleY")); - node->setAnchorPoint(pointValFromDict(props, "anchorPoint")); - node->setRotation(floatValFromDict(props, "rotation")); - node->setIsRelativeAnchorPoint(boolValFromDict(props, "isRelativeAnchorPoint")); - node->setIsVisible(boolValFromDict(props, "visible")); - - if (extraProps) - { - if (node->getTag() == -1) - { - node->setTag(extraProps->count() + 1); - } - - setExtraProp(props->objectForKey("tag"), "tag", node->getTag(), extraProps); - - setExtraProp((CCDictionary*) props->objectForKey("customClass"), "customClass", node->getTag(), extraProps); - setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentType"), "memberVarAssignmentType", node->getTag(), extraProps); - setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentName"), "memberVarAssignmentName", node->getTag(), extraProps); - setExtraProp((CCDictionary*) props->objectForKey("lockedScaleRatio"), "lockedScaleRatio", node->getTag(), extraProps); - - // Expanded nodes - bool isExpanded; - CCString* isExpandedObj = (CCString*) props->objectForKey("isExpanded"); - - if (isExpandedObj) { - isExpanded = !isExpandedObj->m_sString.empty(); - } else { - isExpanded = true; - } - - setExtraProp(isExpandedObj, "isExpanded", node->getTag(), extraProps); - } - else - { - node->setTag(intValFromDict(props, "tag")); - } -} - - -CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extraProps, - const char* assetsDir, CCNode* owner, CCNode* root) -{ - CCString* className = (CCString*) dict->objectForKey("class"); - CCDictionary* props = (CCDictionary*) dict->objectForKey("properties"); - CCArray* children = (CCArray*) dict->objectForKey("children"); - - CCString* customClass = (CCString*)props->objectForKey("customClass"); - - if (extraProps) customClass = NULL; - - CCNode* node = NULL; - - if (className->m_sString.compare("CCParticleSystem") == 0) - { - CCString* spriteFile = new CCString(assetsDir); - spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; - - CCParticleSystem* sys = new CCParticleSystemQuad(); - sys->initWithTotalParticles(2048); - sys->setTexture(CCTextureCache::sharedTextureCache()->addImage(spriteFile->m_sString.c_str())); - delete spriteFile; - node = (CCNode*)sys; - - setPropsForNode((CCNode*)node, (CCDictionary*) props, extraProps); - setPropsForParticleSystem((CCParticleSystem*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCMenuItemImage") == 0) - { - CCString* spriteFileNormal = new CCString(assetsDir); - spriteFileNormal->m_sString += ((CCString*)props->objectForKey("spriteFileNormal"))->getCString(); - CCString* spriteFileSelected = new CCString(assetsDir); - spriteFileSelected->m_sString += ((CCString*)props->objectForKey("spriteFileSelected"))->getCString(); - CCString* spriteFileDisabled = new CCString(assetsDir); - spriteFileDisabled->m_sString += ((CCString*)props->objectForKey("spriteFileDisabled"))->getCString(); - - CCSprite* spriteNormal = NULL; - CCSprite* spriteSelected = NULL; - CCSprite* spriteDisabled = NULL; - - CCString* spriteSheetFile = (CCString*)props->objectForKey("spriteFramesFile"); - if (spriteSheetFile && !spriteSheetFile->length()) { - spriteSheetFile->m_sString.insert(0, assetsDir); - } - - if (spriteSheetFile && !spriteSheetFile->length()) - { - CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(spriteSheetFile->m_sString.c_str()); - - spriteNormal = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileNormal"))->getCString()); - spriteSelected = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileSelected"))->getCString()); - spriteDisabled = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileDisabled"))->getCString()); - // TBD: how to defense if exception raise here? - } - else - { - spriteNormal = CCSprite::spriteWithFile(spriteFileNormal->m_sString.c_str()); - spriteSelected = CCSprite::spriteWithFile(spriteFileSelected->m_sString.c_str()); - spriteDisabled = CCSprite::spriteWithFile(spriteFileDisabled->m_sString.c_str()); - } - - //deallocate - CC_SAFE_DELETE(spriteFileNormal); - CC_SAFE_DELETE(spriteFileSelected); - CC_SAFE_DELETE(spriteFileDisabled); - - if (!spriteNormal) spriteNormal = CCSprite::spriteWithFile("missing-texture.png"); - if (!spriteSelected) spriteSelected = CCSprite::spriteWithFile("missing-texture.png"); - if (!spriteDisabled) spriteDisabled = CCSprite::spriteWithFile("missing-texture.png"); - - CCNode *target = NULL ; - if ( extraProps == NULL ) - { - int targetType = ((CCString*)(props->objectForKey("target")))->intValue() ; - if ( targetType == kCCBMemberVarAssignmentTypeDocumentRoot ) - target = (CCNode*)root ; - else if ( targetType == kCCBMemberVarAssignmentTypeOwner ) - target = (CCNode*)owner ; - - } - - CCString *selectorName = (CCString*)props->objectForKey("selector") ; - SEL_MenuHandler sel = NULL; - - if ( selectorName->length() ) - { - sel = dynamic_cast(target)->callbackGetSelectors(selectorName->getCString()); - } - else - { - CCLOG("WARNING! CCMenuItemImage target doesn't respond to selector %@",selectorName) ; - target = NULL ; - } - - node = (CCNode*)CCMenuItemImage::itemWithNormalSprite((CCNode*) spriteNormal, (CCNode*) spriteSelected, (CCNode*) spriteDisabled, target, sel); - - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForMenuItem((CCMenuItem*) node, (CCDictionary*) props, extraProps); - setPropsForMenuItemImage((CCMenuItemImage*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCMenu") == 0) - { - node = (CCNode*)CCMenu::menuWithItems(NULL); - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps); - setPropsForMenu((CCMenu*)node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCLabelBMFont") == 0) - { - CCString* fontFile = new CCString(assetsDir); - fontFile->m_sString += ((CCString*)props->objectForKey("fontFile"))->m_sString; - CCString* stringText = ((CCString*)props->objectForKey("string")); - - node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), - fontFile->m_sString.c_str() ); - - - delete fontFile; - fontFile = 0; - - if (!node) node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), "missing-font.fnt"); - - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLabelBMFont((CCLabelBMFont*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCSprite") == 0) - { - CCString* spriteFile = new CCString(assetsDir); - spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; - CCString* spriteSheetFile = (CCString*)props->objectForKey("spriteFramesFile"); - - if (spriteSheetFile && !spriteSheetFile->length()) - { - spriteSheetFile->m_sString.insert(0, assetsDir); - } - - if (spriteSheetFile && !spriteSheetFile->length()) - { - CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(spriteSheetFile->m_sString.c_str()); - node = (CCNode*)CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFile"))->m_sString.c_str()); - // TBD: how to defense if exception raise here? - } - else - { - printf("spriteFile->m_string.cstr is %s\n", spriteFile->m_sString.c_str()) ; - node = (CCNode*)CCSprite::spriteWithFile(spriteFile->m_sString.c_str()); - } - - CC_SAFE_RELEASE_NULL(spriteFile); - - if (!node) node = (CCNode*)CCSprite::spriteWithFile("missing-texture.png"); - - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForSprite((CCSprite*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCLayerGradient") == 0) - { - node = (CCNode*)createCustomClassWithName(customClass) ; - if (node) - { - if (dynamic_cast(node) == NULL) - { - CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; - node = NULL; - } - } - else - { - node = (CCNode*)CCLayerGradient::node(); - } - - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps); - setPropsForLayerColor((CCLayerColor*) node, (CCDictionary*) props, extraProps); - setPropsForLayerGradient((CCLayerGradient*) node, (CCDictionary*) props, extraProps); - - } - else if (className->m_sString.compare("CCLayerColor") == 0) - { - node = (CCNode*)createCustomClassWithName(customClass) ; - if (node) - { - if (dynamic_cast(node) == NULL) - { - CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; - node = NULL; - } - } - else - { - node = (CCNode*)CCLayerColor::node(); - } - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps); - setPropsForLayerColor((CCLayerColor*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCLayer") == 0) - { - node = (CCNode*)createCustomClassWithName(customClass) ; - if (node) - { - if (dynamic_cast(node) == NULL) - { - CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; - node = NULL; - } - } - else - { - node = (CCNode*)CCLayer::node(); - } - - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCNode") == 0) - { - node = (CCNode*)createCustomClassWithName(customClass) ; - - if (node) - { - if (dynamic_cast(node) == NULL) - { - CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; - node = NULL; - } - } - else - { - node = (CCNode*)CCNode::node(); - } - - setPropsForNode(node, (CCDictionary*) props, extraProps); - } - else - { - CCLOG("WARNING! Class of type %@ couldn't be found", className); - return NULL; - } - - if (!root) root = node; - - // Add children - for (unsigned int i = 0; i < children->count(); i++) - { - CCDictionary* childDict = (CCDictionary*) children->objectAtIndex(i); - CCNode* child = ccObjectFromDictionary(childDict, extraProps, assetsDir, owner, root); - int zOrder = intValFromDict((CCDictionary*) childDict->objectForKey("properties"), "zOrder"); - - if (child && node) - { - node->addChild(child, zOrder); - } - else - { - CCLOG("WARNING! Failed to add child to node"); - } - } - - if ( !extraProps ) - { - CCString* assignmentName = (CCString*)props->objectForKey("memberVarAssignmentName"); - CCLOG("assignmentName is %s", assignmentName->getCString()) ; - int assignmentType = ((CCString*)(props->objectForKey("memberVarAssignmentType")))->intValue() ; - - if ( !assignmentName->m_sString.empty() && - assignmentType) - { - CCBCustomClassProtocol* assignTo = NULL ; - if ( assignmentType == kCCBMemberVarAssignmentTypeOwner ) - { - assignTo = dynamic_cast(owner); - } - else if ( assignmentType == kCCBMemberVarAssignmentTypeDocumentRoot ) - { - assignTo = dynamic_cast(root); - } - - if ( assignTo != NULL ) - { - CCLOG("assign [%s]", assignmentName->getCString()); - assignTo->callbackSetChildren(assignmentName->getCString(), node); - } - } - if (customClass->length()) - { - CCBCustomClassProtocol* pCustom = dynamic_cast(node); - if (pCustom) - { - pCustom->callbackAfterCCBLoaded(); - } - } - - } - return node; -} - -// initialize ccbreader - -CCNode* CCBReader::nodeGraphFromDictionary(CCDictionary* dict, - CCDictionary* extraProps, - const char* assetsDir, - CCNode* owner) -{ - if (!dict) - { - CCLOG("WARNING! Trying to load invalid file type"); - return NULL; - } - - CCString* fileType = (CCString*) dict->objectForKey("fileType"); - int fileVersion = ((CCString*) dict->objectForKey("fileVersion"))->intValue(); - - if (!fileType || fileType->m_sString.compare("CocosBuilder") != 0) - { - CCLOG("WARNING! Trying to load invalid file type"); - } - - if (fileVersion > 2) - { - CCLOG("WARNING! Trying to load file made with a newer version of CocosBuilder, please update the CCBReader class"); - return NULL; - } - - CCDictionary* nodeGraph = (CCDictionary*) dict->objectForKey("nodeGraph"); - return ccObjectFromDictionary(nodeGraph, extraProps, assetsDir, owner, NULL); -} - -CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner) -{ - CCLOG("CCBReader path is: %s", file); - std::string ccbFilePath(file); - std::string ccbFileDir; - - // find ccbFileDir before "/" or "\" - // for example, if ccbFilePath = "CocosBuilder/example.ccb", - // then we should make ccbFileDir = "CocosBuilder/" - size_t lastSlash = ccbFilePath.find_last_of("/"); - if (lastSlash != std::string::npos) - { - ccbFileDir = ccbFilePath.substr(0, lastSlash) + "/"; - } - - CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(ccbFilePath.c_str()); - CCAssert(dict != NULL, "CCBReader: file not found"); - - return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner); -} - From 19c96632b556461d0e3ef90bad55307b5839bb35 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 29 May 2012 16:21:23 +0800 Subject: [PATCH 002/257] fixed #1176: Changed linebreak symbol to UNIX format ('\n'),replaced 'tab' with four spaces. --- Box2D/Android.mk | 120 ++-- CocosDenshion/android/Android.mk | 38 +- HelloLua/Classes/AppDelegate.cpp | 12 +- HelloLua/proj.android/jni/Android.mk | 46 +- HelloLua/proj.android/jni/Application.mk | 4 +- HelloLua/proj.android/jni/helloworld/main.cpp | 4 +- HelloWorld/proj.android/jni/Android.mk | 40 +- HelloWorld/proj.android/jni/Application.mk | 2 +- chipmunk/Android.mk | 90 +-- cocos2dx/Android.mk | 438 ++++++------ cocos2dx/extensions/CCBReader/CCBReader.h | 4 +- .../extensions/CCBReader/CCBReader_v1.cpp | 192 +++--- .../extensions/CCBReader/CCBReader_v2.cpp | 190 +++--- cocos2dx/platform/CCImageCommon_cpp.h | 118 ++-- js/JSBindings/ScriptingCore.cpp | 456 ++++++------- js/JSBindings/ScriptingCore.h | 222 +++--- js/JSBindings/cocos2d_manual_bindings.cpp | 646 +++++++++--------- .../LuaCocos2d.cpp.REMOVED.git-id | 2 +- lua/proj.android/jni/Android.mk | 74 +- .../Templates/1033/Classes/AppDelegate.cpp | 174 ++--- .../Templates/1033/Classes/AppDelegate.h | 76 +-- .../1033/Classes/HelloWorldScene.cpp | 194 +++--- .../Templates/1033/Classes/HelloWorldScene.h | 66 +- .../Templates/1033/proj.win32/main.cpp | 80 +-- .../Templates/1033/proj.win32/main.h | 26 +- .../Templates/1033/proj.win32/resource.h | 44 +- .../Classes/AppDelegate.cpp | 12 +- testjs/Classes/AppDelegate.cpp | 170 ++--- testjs/Classes/AppDelegate.h | 94 +-- testjs/Classes/simple_class.cpp | 28 +- testjs/Classes/simple_class.h | 74 +- testjs/proj.android/jni/Android.mk | 38 +- testjs/proj.android/jni/Application.mk | 2 +- testjs/proj.ios/AppController.h | 2 +- testjs/proj.ios/AppController.mm | 4 +- testjs/proj.ios/RootViewController.mm | 4 +- testjs/proj.win32/main.cpp | 80 +-- testjs/proj.win32/main.h | 26 +- testjs/proj.win32/resource.h | 40 +- tests/proj.android/jni/Android.mk | 52 +- tests/proj.android/jni/Application.mk | 4 +- .../CocosBuilderTest/CocosBuilderTest.cpp | 2 +- .../template/android/jni/Android.mk | 22 +- .../template/android/jni/Application.mk | 4 +- .../android/jni/LuaProjectTemplate/Android.mk | 62 +- .../android/jni/LuaProjectTemplate/main.cpp | 2 +- 46 files changed, 2040 insertions(+), 2040 deletions(-) diff --git a/Box2D/Android.mk b/Box2D/Android.mk index fe3faa08bf..e289b24bee 100644 --- a/Box2D/Android.mk +++ b/Box2D/Android.mk @@ -1,60 +1,60 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := box2d_static - -LOCAL_MODULE_FILENAME := libbox2d - -LOCAL_SRC_FILES := \ -Collision/Shapes/b2ChainShape.cpp \ -Collision/Shapes/b2CircleShape.cpp \ -Collision/Shapes/b2EdgeShape.cpp \ -Collision/Shapes/b2PolygonShape.cpp \ -Collision/b2BroadPhase.cpp \ -Collision/b2CollideCircle.cpp \ -Collision/b2CollideEdge.cpp \ -Collision/b2CollidePolygon.cpp \ -Collision/b2Collision.cpp \ -Collision/b2Distance.cpp \ -Collision/b2DynamicTree.cpp \ -Collision/b2TimeOfImpact.cpp \ -Common/b2BlockAllocator.cpp \ -Common/b2Draw.cpp \ -Common/b2Math.cpp \ -Common/b2Settings.cpp \ -Common/b2StackAllocator.cpp \ -Common/b2Timer.cpp \ -Dynamics/Contacts/b2ChainAndCircleContact.cpp \ -Dynamics/Contacts/b2ChainAndPolygonContact.cpp \ -Dynamics/Contacts/b2CircleContact.cpp \ -Dynamics/Contacts/b2Contact.cpp \ -Dynamics/Contacts/b2ContactSolver.cpp \ -Dynamics/Contacts/b2EdgeAndCircleContact.cpp \ -Dynamics/Contacts/b2EdgeAndPolygonContact.cpp \ -Dynamics/Contacts/b2PolygonAndCircleContact.cpp \ -Dynamics/Contacts/b2PolygonContact.cpp \ -Dynamics/Joints/b2DistanceJoint.cpp \ -Dynamics/Joints/b2FrictionJoint.cpp \ -Dynamics/Joints/b2GearJoint.cpp \ -Dynamics/Joints/b2Joint.cpp \ -Dynamics/Joints/b2MouseJoint.cpp \ -Dynamics/Joints/b2PrismaticJoint.cpp \ -Dynamics/Joints/b2PulleyJoint.cpp \ -Dynamics/Joints/b2RevoluteJoint.cpp \ -Dynamics/Joints/b2RopeJoint.cpp \ -Dynamics/Joints/b2WeldJoint.cpp \ -Dynamics/Joints/b2WheelJoint.cpp \ -Dynamics/b2Body.cpp \ -Dynamics/b2ContactManager.cpp \ -Dynamics/b2Fixture.cpp \ -Dynamics/b2Island.cpp \ -Dynamics/b2World.cpp \ -Dynamics/b2WorldCallbacks.cpp \ -Rope/b2Rope.cpp - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/.. - -include $(BUILD_STATIC_LIBRARY) +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := box2d_static + +LOCAL_MODULE_FILENAME := libbox2d + +LOCAL_SRC_FILES := \ +Collision/Shapes/b2ChainShape.cpp \ +Collision/Shapes/b2CircleShape.cpp \ +Collision/Shapes/b2EdgeShape.cpp \ +Collision/Shapes/b2PolygonShape.cpp \ +Collision/b2BroadPhase.cpp \ +Collision/b2CollideCircle.cpp \ +Collision/b2CollideEdge.cpp \ +Collision/b2CollidePolygon.cpp \ +Collision/b2Collision.cpp \ +Collision/b2Distance.cpp \ +Collision/b2DynamicTree.cpp \ +Collision/b2TimeOfImpact.cpp \ +Common/b2BlockAllocator.cpp \ +Common/b2Draw.cpp \ +Common/b2Math.cpp \ +Common/b2Settings.cpp \ +Common/b2StackAllocator.cpp \ +Common/b2Timer.cpp \ +Dynamics/Contacts/b2ChainAndCircleContact.cpp \ +Dynamics/Contacts/b2ChainAndPolygonContact.cpp \ +Dynamics/Contacts/b2CircleContact.cpp \ +Dynamics/Contacts/b2Contact.cpp \ +Dynamics/Contacts/b2ContactSolver.cpp \ +Dynamics/Contacts/b2EdgeAndCircleContact.cpp \ +Dynamics/Contacts/b2EdgeAndPolygonContact.cpp \ +Dynamics/Contacts/b2PolygonAndCircleContact.cpp \ +Dynamics/Contacts/b2PolygonContact.cpp \ +Dynamics/Joints/b2DistanceJoint.cpp \ +Dynamics/Joints/b2FrictionJoint.cpp \ +Dynamics/Joints/b2GearJoint.cpp \ +Dynamics/Joints/b2Joint.cpp \ +Dynamics/Joints/b2MouseJoint.cpp \ +Dynamics/Joints/b2PrismaticJoint.cpp \ +Dynamics/Joints/b2PulleyJoint.cpp \ +Dynamics/Joints/b2RevoluteJoint.cpp \ +Dynamics/Joints/b2RopeJoint.cpp \ +Dynamics/Joints/b2WeldJoint.cpp \ +Dynamics/Joints/b2WheelJoint.cpp \ +Dynamics/b2Body.cpp \ +Dynamics/b2ContactManager.cpp \ +Dynamics/b2Fixture.cpp \ +Dynamics/b2Island.cpp \ +Dynamics/b2World.cpp \ +Dynamics/b2WorldCallbacks.cpp \ +Rope/b2Rope.cpp + +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/.. + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/.. + +include $(BUILD_STATIC_LIBRARY) diff --git a/CocosDenshion/android/Android.mk b/CocosDenshion/android/Android.mk index 0b6649e1e7..7e0c5b48f1 100644 --- a/CocosDenshion/android/Android.mk +++ b/CocosDenshion/android/Android.mk @@ -1,21 +1,21 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_MODULE := cocosdenshion_static - -LOCAL_MODULE_FILENAME := libcocosdenshion - -LOCAL_SRC_FILES := SimpleAudioEngine.cpp \ -jni/SimpleAudioEngineJni.cpp - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../include - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include \ - $(LOCAL_PATH)/../../cocos2dx/include \ +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +LOCAL_MODULE := cocosdenshion_static + +LOCAL_MODULE_FILENAME := libcocosdenshion + +LOCAL_SRC_FILES := SimpleAudioEngine.cpp \ +jni/SimpleAudioEngineJni.cpp + +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../include + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include \ + $(LOCAL_PATH)/../../cocos2dx/include \ $(LOCAL_PATH)/../../cocos2dx/platform \ - $(LOCAL_PATH)/../../cocos2dx/platform/android \ - $(LOCAL_PATH)/../../cocos2dx/platform/android/jni - -LOCAL_LDLIBS := -llog - + $(LOCAL_PATH)/../../cocos2dx/platform/android \ + $(LOCAL_PATH)/../../cocos2dx/platform/android/jni + +LOCAL_LDLIBS := -llog + include $(BUILD_STATIC_LIBRARY) diff --git a/HelloLua/Classes/AppDelegate.cpp b/HelloLua/Classes/AppDelegate.cpp index 3fa9228bd9..6201bf0da8 100644 --- a/HelloLua/Classes/AppDelegate.cpp +++ b/HelloLua/Classes/AppDelegate.cpp @@ -41,12 +41,12 @@ bool AppDelegate::applicationDidFinishLaunching() CCScriptEngineProtocol* pEngine = CCLuaEngine::engine(); CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua"); - if (pstrFileContent) - { - pEngine->executeString(pstrFileContent->getCString()); - } +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua"); + if (pstrFileContent) + { + pEngine->executeString(pstrFileContent->getCString()); + } #else std::string path = CCFileUtils::fullPathFromRelativePath("hello.lua"); pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str()); diff --git a/HelloLua/proj.android/jni/Android.mk b/HelloLua/proj.android/jni/Android.mk index 7144854a1b..a8417a9224 100644 --- a/HelloLua/proj.android/jni/Android.mk +++ b/HelloLua/proj.android/jni/Android.mk @@ -1,26 +1,26 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := game_shared - -LOCAL_MODULE_FILENAME := libgame - -LOCAL_SRC_FILES := helloworld/main.cpp \ - ../../Classes/AppDelegate.cpp \ - ../../../lua/cocos2dx_support/CCLuaEngine.cpp \ - ../../../lua/cocos2dx_support/Cocos2dxLuaLoader.cpp \ - ../../../lua/cocos2dx_support/LuaCocos2d.cpp \ - ../../../lua/cocos2dx_support/tolua_fix.c - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes - +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := game_shared + +LOCAL_MODULE_FILENAME := libgame + +LOCAL_SRC_FILES := helloworld/main.cpp \ + ../../Classes/AppDelegate.cpp \ + ../../../lua/cocos2dx_support/CCLuaEngine.cpp \ + ../../../lua/cocos2dx_support/Cocos2dxLuaLoader.cpp \ + ../../../lua/cocos2dx_support/LuaCocos2d.cpp \ + ../../../lua/cocos2dx_support/tolua_fix.c + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes + LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_lua_static - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,cocos2dx) -$(call import-module,CocosDenshion/android) -$(call import-module,lua/proj.android/jni) + +include $(BUILD_SHARED_LIBRARY) + +$(call import-module,cocos2dx) +$(call import-module,CocosDenshion/android) +$(call import-module,lua/proj.android/jni) diff --git a/HelloLua/proj.android/jni/Application.mk b/HelloLua/proj.android/jni/Application.mk index cb24aada5f..f5e25d70ef 100644 --- a/HelloLua/proj.android/jni/Application.mk +++ b/HelloLua/proj.android/jni/Application.mk @@ -1,3 +1,3 @@ APP_STL := gnustl_static -APP_CPPFLAGS := -frtti -APP_CPPFLAGS += -fexceptions +APP_CPPFLAGS := -frtti +APP_CPPFLAGS += -fexceptions diff --git a/HelloLua/proj.android/jni/helloworld/main.cpp b/HelloLua/proj.android/jni/helloworld/main.cpp index 39957ab36c..e4d222db90 100644 --- a/HelloLua/proj.android/jni/helloworld/main.cpp +++ b/HelloLua/proj.android/jni/helloworld/main.cpp @@ -34,8 +34,8 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccDrawInit(); - ccGLInvalidateStateCache(); + ccDrawInit(); + ccGLInvalidateStateCache(); CCShaderCache::sharedShaderCache()->reloadDefaultShaders(); CCTextureCache::reloadAllTextures(); diff --git a/HelloWorld/proj.android/jni/Android.mk b/HelloWorld/proj.android/jni/Android.mk index aedf61112c..a14b4fa135 100644 --- a/HelloWorld/proj.android/jni/Android.mk +++ b/HelloWorld/proj.android/jni/Android.mk @@ -1,20 +1,20 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := helloworld_shared - -LOCAL_MODULE_FILENAME := libhelloworld - -LOCAL_SRC_FILES := helloworld/main.cpp \ - ../../Classes/AppDelegate.cpp \ - ../../Classes/HelloWorldScene.cpp - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes - -LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,cocos2dx) - +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := helloworld_shared + +LOCAL_MODULE_FILENAME := libhelloworld + +LOCAL_SRC_FILES := helloworld/main.cpp \ + ../../Classes/AppDelegate.cpp \ + ../../Classes/HelloWorldScene.cpp + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes + +LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static + +include $(BUILD_SHARED_LIBRARY) + +$(call import-module,cocos2dx) + diff --git a/HelloWorld/proj.android/jni/Application.mk b/HelloWorld/proj.android/jni/Application.mk index 0ba4ae3a9c..22d424dab7 100644 --- a/HelloWorld/proj.android/jni/Application.mk +++ b/HelloWorld/proj.android/jni/Application.mk @@ -1,2 +1,2 @@ -APP_STL := gnustl_static +APP_STL := gnustl_static APP_CPPFLAGS := -frtti \ No newline at end of file diff --git a/chipmunk/Android.mk b/chipmunk/Android.mk index 771d02dfc5..bf22594183 100644 --- a/chipmunk/Android.mk +++ b/chipmunk/Android.mk @@ -1,45 +1,45 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := chipmunk_static - -LOCAL_MODULE_FILENAME := libchipmunk - -LOCAL_SRC_FILES := \ -src/chipmunk.c \ -src/constraints/cpConstraint.c \ -src/constraints/cpDampedRotarySpring.c \ -src/constraints/cpDampedSpring.c \ -src/constraints/cpGearJoint.c \ -src/constraints/cpGrooveJoint.c \ -src/constraints/cpPinJoint.c \ -src/constraints/cpPivotJoint.c \ -src/constraints/cpRatchetJoint.c \ -src/constraints/cpRotaryLimitJoint.c \ -src/constraints/cpSimpleMotor.c \ -src/constraints/cpSlideJoint.c \ -src/cpArbiter.c \ -src/cpArray.c \ -src/cpBB.c \ -src/cpBBTree.c \ -src/cpBody.c \ -src/cpCollision.c \ -src/cpHashSet.c \ -src/cpPolyShape.c \ -src/cpShape.c \ -src/cpSpace.c \ -src/cpSpaceComponent.c \ -src/cpSpaceHash.c \ -src/cpSpaceQuery.c \ -src/cpSpaceStep.c \ -src/cpSpatialIndex.c \ -src/cpSweep1D.c \ -src/cpVect.c - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include/chipmunk - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/chipmunk -LOCAL_CFLAGS := -std=c99 - -include $(BUILD_STATIC_LIBRARY) +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := chipmunk_static + +LOCAL_MODULE_FILENAME := libchipmunk + +LOCAL_SRC_FILES := \ +src/chipmunk.c \ +src/constraints/cpConstraint.c \ +src/constraints/cpDampedRotarySpring.c \ +src/constraints/cpDampedSpring.c \ +src/constraints/cpGearJoint.c \ +src/constraints/cpGrooveJoint.c \ +src/constraints/cpPinJoint.c \ +src/constraints/cpPivotJoint.c \ +src/constraints/cpRatchetJoint.c \ +src/constraints/cpRotaryLimitJoint.c \ +src/constraints/cpSimpleMotor.c \ +src/constraints/cpSlideJoint.c \ +src/cpArbiter.c \ +src/cpArray.c \ +src/cpBB.c \ +src/cpBBTree.c \ +src/cpBody.c \ +src/cpCollision.c \ +src/cpHashSet.c \ +src/cpPolyShape.c \ +src/cpShape.c \ +src/cpSpace.c \ +src/cpSpaceComponent.c \ +src/cpSpaceHash.c \ +src/cpSpaceQuery.c \ +src/cpSpaceStep.c \ +src/cpSpatialIndex.c \ +src/cpSweep1D.c \ +src/cpVect.c + +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include/chipmunk + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/include/chipmunk +LOCAL_CFLAGS := -std=c99 + +include $(BUILD_STATIC_LIBRARY) diff --git a/cocos2dx/Android.mk b/cocos2dx/Android.mk index 5c8db2a0ba..f73df4fca2 100644 --- a/cocos2dx/Android.mk +++ b/cocos2dx/Android.mk @@ -1,222 +1,222 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := cocos2dx_static - -LOCAL_MODULE_FILENAME := libcocos2d - -LOCAL_SRC_FILES := \ -CCConfiguration.cpp \ -CCDrawingPrimitives.cpp \ -CCScheduler.cpp \ -CCCamera.cpp \ -actions/CCAction.cpp \ -actions/CCActionCamera.cpp \ -actions/CCActionEase.cpp \ -actions/CCActionGrid.cpp \ -actions/CCActionGrid3D.cpp \ -actions/CCActionInstant.cpp \ -actions/CCActionInterval.cpp \ -actions/CCActionManager.cpp \ -actions/CCActionPageTurn3D.cpp \ -actions/CCActionProgressTimer.cpp \ -actions/CCActionTiledGrid.cpp \ -actions/CCActionTween.cpp \ -base_nodes/CCAtlasNode.cpp \ -base_nodes/CCNode.cpp \ -cocoa/CCAffineTransform.cpp \ -cocoa/CCGeometry.cpp \ -cocoa/CCAutoreleasePool.cpp \ -cocoa/CCData.cpp \ -cocoa/CCDictionary.cpp \ -cocoa/CCNS.cpp \ -cocoa/CCObject.cpp \ -cocoa/CCSet.cpp \ -cocoa/CCString.cpp \ -cocoa/CCZone.cpp \ -cocoa/CCArray.cpp \ -cocos2d.cpp \ -CCDirector.cpp \ -effects/CCGrabber.cpp \ -effects/CCGrid.cpp \ -extensions/CCNotificationCenter/CCNotificationCenter.cpp \ -extensions/CCControlExtension/CCControl.cpp \ -extensions/CCControlExtension/CCControlButton.cpp \ -extensions/CCControlExtension/CCControlColourPicker.cpp \ -extensions/CCControlExtension/CCControlHuePicker.cpp \ -extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp \ -extensions/CCControlExtension/CCControlSlider.cpp \ -extensions/CCControlExtension/CCControlSwitch.cpp \ -extensions/CCControlExtension/CCControlUtils.cpp \ -extensions/CCControlExtension/CCInvocation.cpp \ -extensions/CCControlExtension/CCMenuPassive.cpp \ -extensions/CCControlExtension/CCScale9Sprite.cpp \ -extensions/CCControlExtension/CCSpacer.cpp \ -extensions/CCListView/CCListView.cpp \ -extensions/CCListView/CCListViewCell.cpp \ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := cocos2dx_static + +LOCAL_MODULE_FILENAME := libcocos2d + +LOCAL_SRC_FILES := \ +CCConfiguration.cpp \ +CCDrawingPrimitives.cpp \ +CCScheduler.cpp \ +CCCamera.cpp \ +actions/CCAction.cpp \ +actions/CCActionCamera.cpp \ +actions/CCActionEase.cpp \ +actions/CCActionGrid.cpp \ +actions/CCActionGrid3D.cpp \ +actions/CCActionInstant.cpp \ +actions/CCActionInterval.cpp \ +actions/CCActionManager.cpp \ +actions/CCActionPageTurn3D.cpp \ +actions/CCActionProgressTimer.cpp \ +actions/CCActionTiledGrid.cpp \ +actions/CCActionTween.cpp \ +base_nodes/CCAtlasNode.cpp \ +base_nodes/CCNode.cpp \ +cocoa/CCAffineTransform.cpp \ +cocoa/CCGeometry.cpp \ +cocoa/CCAutoreleasePool.cpp \ +cocoa/CCData.cpp \ +cocoa/CCDictionary.cpp \ +cocoa/CCNS.cpp \ +cocoa/CCObject.cpp \ +cocoa/CCSet.cpp \ +cocoa/CCString.cpp \ +cocoa/CCZone.cpp \ +cocoa/CCArray.cpp \ +cocos2d.cpp \ +CCDirector.cpp \ +effects/CCGrabber.cpp \ +effects/CCGrid.cpp \ +extensions/CCNotificationCenter/CCNotificationCenter.cpp \ +extensions/CCControlExtension/CCControl.cpp \ +extensions/CCControlExtension/CCControlButton.cpp \ +extensions/CCControlExtension/CCControlColourPicker.cpp \ +extensions/CCControlExtension/CCControlHuePicker.cpp \ +extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp \ +extensions/CCControlExtension/CCControlSlider.cpp \ +extensions/CCControlExtension/CCControlSwitch.cpp \ +extensions/CCControlExtension/CCControlUtils.cpp \ +extensions/CCControlExtension/CCInvocation.cpp \ +extensions/CCControlExtension/CCMenuPassive.cpp \ +extensions/CCControlExtension/CCScale9Sprite.cpp \ +extensions/CCControlExtension/CCSpacer.cpp \ +extensions/CCListView/CCListView.cpp \ +extensions/CCListView/CCListViewCell.cpp \ extensions/CCTextureWatcher/CCTextureWatcher.cpp \ extensions/CCBReader/CCBCustomClass.cpp \ -extensions/CCBReader/CCBReader_v2.cpp \ -kazmath/src/aabb.c \ -kazmath/src/mat3.c \ -kazmath/src/mat4.c \ -kazmath/src/neon_matrix_impl.c \ -kazmath/src/plane.c \ -kazmath/src/quaternion.c \ -kazmath/src/ray2.c \ -kazmath/src/utility.c \ -kazmath/src/vec2.c \ -kazmath/src/vec3.c \ -kazmath/src/vec4.c \ -kazmath/src/GL/mat4stack.c \ -kazmath/src/GL/matrix.c \ -keypad_dispatcher/CCKeypadDelegate.cpp \ -keypad_dispatcher/CCKeypadDispatcher.cpp \ -label_nodes/CCLabelAtlas.cpp \ -label_nodes/CCLabelBMFont.cpp \ -label_nodes/CCLabelTTF.cpp \ -layers_scenes_transitions_nodes/CCLayer.cpp \ -layers_scenes_transitions_nodes/CCScene.cpp \ -layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp \ -layers_scenes_transitions_nodes/CCTransition.cpp \ -layers_scenes_transitions_nodes/CCTransitionProgress.cpp \ -menu_nodes/CCMenu.cpp \ -menu_nodes/CCMenuItem.cpp \ -misc_nodes/CCMotionStreak.cpp \ -misc_nodes/CCProgressTimer.cpp \ -misc_nodes/CCRenderTexture.cpp \ -particle_nodes/CCParticleExamples.cpp \ -particle_nodes/CCParticleSystem.cpp \ -particle_nodes/CCParticleBatchNode.cpp \ -particle_nodes/CCParticleSystemQuad.cpp \ -platform/CCSAXParser.cpp \ -platform/CCThread.cpp \ -platform/platform.cpp \ -platform/CCEGLViewProtocol.cpp \ -platform/android/CCEGLView.cpp \ -platform/android/CCAccelerometer.cpp \ -platform/android/CCApplication.cpp \ -platform/android/CCCommon.cpp \ -platform/android/CCFileUtils.cpp \ -platform/android/CCImage.cpp \ -platform/android/jni/JniHelper.cpp \ -platform/android/jni/IMEJni.cpp \ -platform/android/jni/MessageJni.cpp \ -platform/android/jni/SensorJni.cpp \ -platform/android/jni/SystemInfoJni.cpp \ -platform/android/jni/TouchesJni.cpp \ -script_support/CCScriptSupport.cpp \ -shaders/ccShaders.cpp \ -shaders/CCGLProgram.cpp \ -shaders/ccGLStateCache.cpp \ -shaders/CCShaderCache.cpp \ -sprite_nodes/CCAnimation.cpp \ -sprite_nodes/CCAnimationCache.cpp \ -sprite_nodes/CCSprite.cpp \ -sprite_nodes/CCSpriteBatchNode.cpp \ -sprite_nodes/CCSpriteFrame.cpp \ -sprite_nodes/CCSpriteFrameCache.cpp \ -support/CCProfiling.cpp \ -support/CCPointExtension.cpp \ -support/TransformUtils.cpp \ -support/CCUserDefault.cpp \ -support/base64.cpp \ -support/ccUtils.cpp \ -support/CCVertex.cpp \ -support/image_support/TGAlib.cpp \ -support/zip_support/ZipUtils.cpp \ -support/zip_support/ioapi.cpp \ -support/zip_support/unzip.cpp \ -text_input_node/CCIMEDispatcher.cpp \ -text_input_node/CCTextFieldTTF.cpp \ -textures/CCTexture2D.cpp \ -textures/CCTextureAtlas.cpp \ -textures/CCTextureCache.cpp \ -textures/CCTexturePVR.cpp \ -tileMap_parallax_nodes/CCParallaxNode.cpp \ -tileMap_parallax_nodes/CCTMXLayer.cpp \ -tileMap_parallax_nodes/CCTMXObjectGroup.cpp \ -tileMap_parallax_nodes/CCTMXTiledMap.cpp \ -tileMap_parallax_nodes/CCTMXXMLParser.cpp \ -tileMap_parallax_nodes/CCTileMapAtlas.cpp \ -touch_dispatcher/CCTouchDispatcher.cpp \ -touch_dispatcher/CCTouchHandler.cpp - -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/ \ - $(LOCAL_PATH)/actions \ - $(LOCAL_PATH)/base_nodes \ - $(LOCAL_PATH)/cocoa \ - $(LOCAL_PATH)/effects \ - $(LOCAL_PATH)/extensions \ - $(LOCAL_PATH)/include \ - $(LOCAL_PATH)/kazmath/include \ - $(LOCAL_PATH)/keypad_dispatcher \ - $(LOCAL_PATH)/label_nodes \ - $(LOCAL_PATH)/layers_scenes_transitions_nodes \ - $(LOCAL_PATH)/menu_nodes \ - $(LOCAL_PATH)/misc_nodes \ - $(LOCAL_PATH)/particle_nodes \ - $(LOCAL_PATH)/platform \ - $(LOCAL_PATH)/platform/android \ - $(LOCAL_PATH)/script_support \ - $(LOCAL_PATH)/shaders \ - $(LOCAL_PATH)/sprite_nodes \ - $(LOCAL_PATH)/support \ - $(LOCAL_PATH)/text_input_node \ - $(LOCAL_PATH)/textures \ - $(LOCAL_PATH)/tileMap_parallax_nodes \ - $(LOCAL_PATH)/touch_dispatcher - - -LOCAL_EXPORT_LDLIBS := -llog\ - -lz \ - -lGLESv2 - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ \ - $(LOCAL_PATH)/actions \ - $(LOCAL_PATH)/base_nodes \ - $(LOCAL_PATH)/cocoa \ - $(LOCAL_PATH)/effects \ - $(LOCAL_PATH)/extensions \ - $(LOCAL_PATH)/include \ - $(LOCAL_PATH)/kazmath/include \ - $(LOCAL_PATH)/keypad_dispatcher \ - $(LOCAL_PATH)/label_nodes \ - $(LOCAL_PATH)/layers_scenes_transitions_nodes \ - $(LOCAL_PATH)/menu_nodes \ - $(LOCAL_PATH)/misc_nodes \ - $(LOCAL_PATH)/particle_nodes \ - $(LOCAL_PATH)/platform \ - $(LOCAL_PATH)/platform/android \ - $(LOCAL_PATH)/script_support \ - $(LOCAL_PATH)/shaders \ - $(LOCAL_PATH)/sprite_nodes \ - $(LOCAL_PATH)/support \ - $(LOCAL_PATH)/text_input_node \ - $(LOCAL_PATH)/textures \ - $(LOCAL_PATH)/tileMap_parallax_nodes \ - $(LOCAL_PATH)/touch_dispatcher - - -LOCAL_LDLIBS := -lGLESv2 \ - -lEGL \ - -llog \ - -lz - -LOCAL_WHOLE_STATIC_LIBRARIES := cocos_libpng_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_jpeg_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libxml2_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libtiff_static +extensions/CCBReader/CCBReader_v2.cpp \ +kazmath/src/aabb.c \ +kazmath/src/mat3.c \ +kazmath/src/mat4.c \ +kazmath/src/neon_matrix_impl.c \ +kazmath/src/plane.c \ +kazmath/src/quaternion.c \ +kazmath/src/ray2.c \ +kazmath/src/utility.c \ +kazmath/src/vec2.c \ +kazmath/src/vec3.c \ +kazmath/src/vec4.c \ +kazmath/src/GL/mat4stack.c \ +kazmath/src/GL/matrix.c \ +keypad_dispatcher/CCKeypadDelegate.cpp \ +keypad_dispatcher/CCKeypadDispatcher.cpp \ +label_nodes/CCLabelAtlas.cpp \ +label_nodes/CCLabelBMFont.cpp \ +label_nodes/CCLabelTTF.cpp \ +layers_scenes_transitions_nodes/CCLayer.cpp \ +layers_scenes_transitions_nodes/CCScene.cpp \ +layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp \ +layers_scenes_transitions_nodes/CCTransition.cpp \ +layers_scenes_transitions_nodes/CCTransitionProgress.cpp \ +menu_nodes/CCMenu.cpp \ +menu_nodes/CCMenuItem.cpp \ +misc_nodes/CCMotionStreak.cpp \ +misc_nodes/CCProgressTimer.cpp \ +misc_nodes/CCRenderTexture.cpp \ +particle_nodes/CCParticleExamples.cpp \ +particle_nodes/CCParticleSystem.cpp \ +particle_nodes/CCParticleBatchNode.cpp \ +particle_nodes/CCParticleSystemQuad.cpp \ +platform/CCSAXParser.cpp \ +platform/CCThread.cpp \ +platform/platform.cpp \ +platform/CCEGLViewProtocol.cpp \ +platform/android/CCEGLView.cpp \ +platform/android/CCAccelerometer.cpp \ +platform/android/CCApplication.cpp \ +platform/android/CCCommon.cpp \ +platform/android/CCFileUtils.cpp \ +platform/android/CCImage.cpp \ +platform/android/jni/JniHelper.cpp \ +platform/android/jni/IMEJni.cpp \ +platform/android/jni/MessageJni.cpp \ +platform/android/jni/SensorJni.cpp \ +platform/android/jni/SystemInfoJni.cpp \ +platform/android/jni/TouchesJni.cpp \ +script_support/CCScriptSupport.cpp \ +shaders/ccShaders.cpp \ +shaders/CCGLProgram.cpp \ +shaders/ccGLStateCache.cpp \ +shaders/CCShaderCache.cpp \ +sprite_nodes/CCAnimation.cpp \ +sprite_nodes/CCAnimationCache.cpp \ +sprite_nodes/CCSprite.cpp \ +sprite_nodes/CCSpriteBatchNode.cpp \ +sprite_nodes/CCSpriteFrame.cpp \ +sprite_nodes/CCSpriteFrameCache.cpp \ +support/CCProfiling.cpp \ +support/CCPointExtension.cpp \ +support/TransformUtils.cpp \ +support/CCUserDefault.cpp \ +support/base64.cpp \ +support/ccUtils.cpp \ +support/CCVertex.cpp \ +support/image_support/TGAlib.cpp \ +support/zip_support/ZipUtils.cpp \ +support/zip_support/ioapi.cpp \ +support/zip_support/unzip.cpp \ +text_input_node/CCIMEDispatcher.cpp \ +text_input_node/CCTextFieldTTF.cpp \ +textures/CCTexture2D.cpp \ +textures/CCTextureAtlas.cpp \ +textures/CCTextureCache.cpp \ +textures/CCTexturePVR.cpp \ +tileMap_parallax_nodes/CCParallaxNode.cpp \ +tileMap_parallax_nodes/CCTMXLayer.cpp \ +tileMap_parallax_nodes/CCTMXObjectGroup.cpp \ +tileMap_parallax_nodes/CCTMXTiledMap.cpp \ +tileMap_parallax_nodes/CCTMXXMLParser.cpp \ +tileMap_parallax_nodes/CCTileMapAtlas.cpp \ +touch_dispatcher/CCTouchDispatcher.cpp \ +touch_dispatcher/CCTouchHandler.cpp + +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/ \ + $(LOCAL_PATH)/actions \ + $(LOCAL_PATH)/base_nodes \ + $(LOCAL_PATH)/cocoa \ + $(LOCAL_PATH)/effects \ + $(LOCAL_PATH)/extensions \ + $(LOCAL_PATH)/include \ + $(LOCAL_PATH)/kazmath/include \ + $(LOCAL_PATH)/keypad_dispatcher \ + $(LOCAL_PATH)/label_nodes \ + $(LOCAL_PATH)/layers_scenes_transitions_nodes \ + $(LOCAL_PATH)/menu_nodes \ + $(LOCAL_PATH)/misc_nodes \ + $(LOCAL_PATH)/particle_nodes \ + $(LOCAL_PATH)/platform \ + $(LOCAL_PATH)/platform/android \ + $(LOCAL_PATH)/script_support \ + $(LOCAL_PATH)/shaders \ + $(LOCAL_PATH)/sprite_nodes \ + $(LOCAL_PATH)/support \ + $(LOCAL_PATH)/text_input_node \ + $(LOCAL_PATH)/textures \ + $(LOCAL_PATH)/tileMap_parallax_nodes \ + $(LOCAL_PATH)/touch_dispatcher + + +LOCAL_EXPORT_LDLIBS := -llog\ + -lz \ + -lGLESv2 + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/ \ + $(LOCAL_PATH)/actions \ + $(LOCAL_PATH)/base_nodes \ + $(LOCAL_PATH)/cocoa \ + $(LOCAL_PATH)/effects \ + $(LOCAL_PATH)/extensions \ + $(LOCAL_PATH)/include \ + $(LOCAL_PATH)/kazmath/include \ + $(LOCAL_PATH)/keypad_dispatcher \ + $(LOCAL_PATH)/label_nodes \ + $(LOCAL_PATH)/layers_scenes_transitions_nodes \ + $(LOCAL_PATH)/menu_nodes \ + $(LOCAL_PATH)/misc_nodes \ + $(LOCAL_PATH)/particle_nodes \ + $(LOCAL_PATH)/platform \ + $(LOCAL_PATH)/platform/android \ + $(LOCAL_PATH)/script_support \ + $(LOCAL_PATH)/shaders \ + $(LOCAL_PATH)/sprite_nodes \ + $(LOCAL_PATH)/support \ + $(LOCAL_PATH)/text_input_node \ + $(LOCAL_PATH)/textures \ + $(LOCAL_PATH)/tileMap_parallax_nodes \ + $(LOCAL_PATH)/touch_dispatcher + + +LOCAL_LDLIBS := -lGLESv2 \ + -lEGL \ + -llog \ + -lz + +LOCAL_WHOLE_STATIC_LIBRARIES := cocos_libpng_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocos_jpeg_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libxml2_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocos_libtiff_static + + +# define the macro to compile through support/zip_support/ioapi.c +LOCAL_CFLAGS := -DUSE_FILE32API + +include $(BUILD_STATIC_LIBRARY) + +$(call import-module,libjpeg) +$(call import-module,libpng) +$(call import-module,libxml2) +$(call import-module,libtiff) - -# define the macro to compile through support/zip_support/ioapi.c -LOCAL_CFLAGS := -DUSE_FILE32API - -include $(BUILD_STATIC_LIBRARY) - -$(call import-module,libjpeg) -$(call import-module,libpng) -$(call import-module,libxml2) -$(call import-module,libtiff) - diff --git a/cocos2dx/extensions/CCBReader/CCBReader.h b/cocos2dx/extensions/CCBReader/CCBReader.h index fd7560bf19..19a804b4d3 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader.h +++ b/cocos2dx/extensions/CCBReader/CCBReader.h @@ -51,7 +51,7 @@ private: static CCNode* ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extraProps, const char* assetsDir, CCNode* owner, CCNode* root); - // read different types of values from dict + // read different types of values from dict static int intValFromDict(CCDictionary* dict, const std::string key); @@ -73,7 +73,7 @@ private: const std::string key); private: - // set properties + // set properties static void setExtraProp(CCObject* prop, const char* key, int tag, CCDictionary* dict); diff --git a/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp b/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp index 0cea9e4a3c..daaca0b9c4 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp @@ -33,31 +33,31 @@ USING_NS_CC_EXT; int CCBReader::intValFromDict(CCDictionary* dict, const std::string key) { - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); - return valueString->intValue(); + CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); + return valueString->intValue(); } float CCBReader::floatValFromDict(CCDictionary* dict, const std::string key) { - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); + CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); return valueString->floatValue(); } bool CCBReader::boolValFromDict(CCDictionary* dict, const std::string key) { - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); + CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); return (bool) valueString->intValue(); } CCPoint CCBReader::pointValFromDict(CCDictionary* dict, const std::string key) { - CCArray* arr = (CCArray*)dict->objectForKey(key.c_str()); - + CCArray* arr = (CCArray*)dict->objectForKey(key.c_str()); + if (!arr) - { - return ccp(0,0); - } - + { + return ccp(0,0); + } + float x = ((CCString*)arr->objectAtIndex(0))->floatValue(); float y = ((CCString*)arr->objectAtIndex(1))->floatValue(); return ccp(x, y); @@ -65,13 +65,13 @@ CCPoint CCBReader::pointValFromDict(CCDictionary* dict, const std::string key) CCSize CCBReader::sizeValFromDict(CCDictionary* dict, const std::string key) { - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - + CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); + if (!arr) - { - return CCSize(0, 0); - } - + { + return CCSize(0, 0); + } + float w = ((CCString*)arr->objectAtIndex(0))->floatValue(); float h = ((CCString*)arr->objectAtIndex(1))->floatValue(); return CCSize(w, h); @@ -79,39 +79,39 @@ CCSize CCBReader::sizeValFromDict(CCDictionary* dict, const std::string key) ccColor3B CCBReader::ccColor3ValFromDict(CCDictionary* dict, const std::string key) { - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - + CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); + int r = ((CCString*)arr->objectAtIndex(0))->intValue(); int g = ((CCString*)arr->objectAtIndex(1))->intValue(); int b = ((CCString*)arr->objectAtIndex(2))->intValue(); - + return ccc3(r, g, b); } ccColor4F CCBReader::ccColor4fValFromDict(CCDictionary* dict, const std::string key) { - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - + CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); + ccColor4F color; color.r = ((CCString*)arr->objectAtIndex(0))->floatValue(); color.g = ((CCString*)arr->objectAtIndex(1))->floatValue(); color.b = ((CCString*)arr->objectAtIndex(2))->floatValue(); color.a = ((CCString*)arr->objectAtIndex(3))->floatValue(); - + return color; } ccBlendFunc CCBReader::blendFuncValFromDict(CCDictionary* dict, const std::string key) { - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - + CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); + int src = ((CCString*)arr->objectAtIndex(0))->intValue(); int dst = ((CCString*)arr->objectAtIndex(1))->intValue(); - + ccBlendFunc blendFunc; blendFunc.src = src; blendFunc.dst = dst; - + return blendFunc; } @@ -119,10 +119,10 @@ ccBlendFunc CCBReader::blendFuncValFromDict(CCDictionary* dict, const std::strin void CCBReader::setExtraProp(CCObject* prop, const char* key, int tag, CCDictionary* dict) { - std::string tagString; - tagString += tag; + std::string tagString; + tagString += tag; CCDictionary* props = (CCDictionary*) dict->objectForKey(tagString.c_str()); - + if (!props) { props = new CCDictionary(); @@ -140,7 +140,7 @@ void CCBReader::setPropsForMenuItem(CCMenuItem* node, CCDictionary* props, CCDic setExtraProp((CCDictionary*) props->objectForKey("selector"), "selector", node->getTag(), extraProps); setExtraProp((CCDictionary*) props->objectForKey("target"), "target", node->getTag(), extraProps); CCString* spriteFramesFile = (CCString*) props->objectForKey("spriteFramesFile"); - + if (spriteFramesFile) { setExtraProp(spriteFramesFile, "spriteSheetFile", node->getTag(), extraProps); @@ -193,7 +193,7 @@ void CCBReader::setPropsForLabelBMFont(CCLabelBMFont* node, CCDictionary* props, { node->setOpacity(intValFromDict(props, "opacity")); node->setColor(ccColor3ValFromDict(props, "color")); - + if (extraProps) { setExtraProp(props->objectForKey("fontFile"), "fontFile", node->getTag(), extraProps); @@ -221,7 +221,7 @@ void CCBReader::setPropsForParticleSystem(CCParticleSystem* node, CCDictionary* node->setEndSpin(intValFromDict(props, "endSpin")); node->setEndSpinVar(intValFromDict(props, "endSpinVar")); } - + node->setStartColor(ccColor4fValFromDict(props, "startColor")); node->setStartColorVar(ccColor4fValFromDict(props, "startColorVar")); node->setEndColor(ccColor4fValFromDict(props, "endColor")); @@ -286,12 +286,12 @@ void CCBReader::setPropsForSprite(CCSprite* node, CCDictionary* props, CCDiction node->setFlipX(boolValFromDict(props, "flipX")); node->setFlipY(boolValFromDict(props, "flipY")); node->setBlendFunc(blendFuncValFromDict(props, "blendFunc")); - + if (extraProps) { setExtraProp(props->objectForKey("spriteFile"), "spriteFile", node->getTag(), extraProps); CCString* spriteFramesFile = (CCString*) props->objectForKey("spriteFramesFile"); - + if (spriteFramesFile) { setExtraProp(spriteFramesFile, "spriteSheetFile", node->getTag(), extraProps); @@ -301,17 +301,17 @@ void CCBReader::setPropsForSprite(CCSprite* node, CCDictionary* props, CCDiction void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* extraProps) { - CCPoint position = pointValFromDict(props, "position"); - node->setPosition(position); + CCPoint position = pointValFromDict(props, "position"); + node->setPosition(position); if (dynamic_cast(node) == NULL && dynamic_cast(node) == NULL && dynamic_cast(node) == NULL) { - CCSize size = sizeValFromDict(props, "contentSize"); - //node->setContentSize(size); + CCSize size = sizeValFromDict(props, "contentSize"); + //node->setContentSize(size); } - + node->setScaleX(floatValFromDict(props, "scaleX")); node->setScaleY(floatValFromDict(props, "scaleY")); node->setAnchorPoint(pointValFromDict(props, "anchorPoint")); @@ -330,20 +330,20 @@ void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* setExtraProp((CCDictionary*) props->objectForKey("customClass"), "customClass", node->getTag(), extraProps); setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentType"), "memberVarAssignmentType", node->getTag(), extraProps); - setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentName"), "memberVarAssignmentName", node->getTag(), extraProps); + setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentName"), "memberVarAssignmentName", node->getTag(), extraProps); setExtraProp((CCDictionary*) props->objectForKey("lockedScaleRatio"), "lockedScaleRatio", node->getTag(), extraProps); // Expanded nodes bool isExpanded; CCString* isExpandedObj = (CCString*) props->objectForKey("isExpanded"); - + if (isExpandedObj) { - isExpanded = !isExpandedObj->m_sString.empty(); - } else { - isExpanded = true; - } - - setExtraProp(isExpandedObj, "isExpanded", node->getTag(), extraProps); + isExpanded = !isExpandedObj->m_sString.empty(); + } else { + isExpanded = true; + } + + setExtraProp(isExpandedObj, "isExpanded", node->getTag(), extraProps); } else { @@ -355,38 +355,38 @@ void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extraProps, const char* assetsDir, CCNode* owner, CCNode* root) { - CCString* className = (CCString*) dict->objectForKey("class"); + CCString* className = (CCString*) dict->objectForKey("class"); CCDictionary* props = (CCDictionary*) dict->objectForKey("properties"); CCArray* children = (CCArray*) dict->objectForKey("children"); CCString* customClass = (CCString*)props->objectForKey("customClass"); - + if (extraProps) customClass = NULL; CCNode* node = NULL; - if (className->m_sString.compare("CCParticleSystem") == 0) + if (className->m_sString.compare("CCParticleSystem") == 0) { CCString* spriteFile = new CCString(assetsDir); - spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; - + spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; + CCParticleSystem* sys = new CCParticleSystemQuad(); - sys->initWithTotalParticles(2048); + sys->initWithTotalParticles(2048); sys->setTexture(CCTextureCache::sharedTextureCache()->addImage(spriteFile->m_sString.c_str())); - delete spriteFile; + delete spriteFile; node = (CCNode*)sys; - + setPropsForNode((CCNode*)node, (CCDictionary*) props, extraProps); setPropsForParticleSystem((CCParticleSystem*) node, (CCDictionary*) props, extraProps); } else if (className->m_sString.compare("CCMenuItemImage") == 0) { CCString* spriteFileNormal = new CCString(assetsDir); - spriteFileNormal->m_sString += ((CCString*)props->objectForKey("spriteFileNormal"))->getCString(); + spriteFileNormal->m_sString += ((CCString*)props->objectForKey("spriteFileNormal"))->getCString(); CCString* spriteFileSelected = new CCString(assetsDir); - spriteFileSelected->m_sString += ((CCString*)props->objectForKey("spriteFileSelected"))->getCString(); + spriteFileSelected->m_sString += ((CCString*)props->objectForKey("spriteFileSelected"))->getCString(); CCString* spriteFileDisabled = new CCString(assetsDir); - spriteFileDisabled->m_sString += ((CCString*)props->objectForKey("spriteFileDisabled"))->getCString(); + spriteFileDisabled->m_sString += ((CCString*)props->objectForKey("spriteFileDisabled"))->getCString(); CCSprite* spriteNormal = NULL; CCSprite* spriteSelected = NULL; @@ -394,12 +394,12 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr CCString* spriteSheetFile = (CCString*)props->objectForKey("spriteFramesFile"); if (spriteSheetFile && !spriteSheetFile->length()) { - spriteSheetFile->m_sString.insert(0, assetsDir); - } + spriteSheetFile->m_sString.insert(0, assetsDir); + } if (spriteSheetFile && !spriteSheetFile->length()) { - CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(spriteSheetFile->m_sString.c_str()); + CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(spriteSheetFile->m_sString.c_str()); spriteNormal = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileNormal"))->getCString()); spriteSelected = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileSelected"))->getCString()); @@ -412,16 +412,16 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr spriteSelected = CCSprite::spriteWithFile(spriteFileSelected->m_sString.c_str()); spriteDisabled = CCSprite::spriteWithFile(spriteFileDisabled->m_sString.c_str()); } - - //deallocate + + //deallocate CC_SAFE_DELETE(spriteFileNormal); CC_SAFE_DELETE(spriteFileSelected); CC_SAFE_DELETE(spriteFileDisabled); if (!spriteNormal) spriteNormal = CCSprite::spriteWithFile("missing-texture.png"); if (!spriteSelected) spriteSelected = CCSprite::spriteWithFile("missing-texture.png"); - if (!spriteDisabled) spriteDisabled = CCSprite::spriteWithFile("missing-texture.png"); - + if (!spriteDisabled) spriteDisabled = CCSprite::spriteWithFile("missing-texture.png"); + CCNode *target = NULL ; if ( extraProps == NULL ) { @@ -446,7 +446,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr target = NULL ; } - node = (CCNode*)CCMenuItemImage::itemWithNormalSprite((CCNode*) spriteNormal, (CCNode*) spriteSelected, (CCNode*) spriteDisabled, target, sel); + node = (CCNode*)CCMenuItemImage::itemWithNormalSprite((CCNode*) spriteNormal, (CCNode*) spriteSelected, (CCNode*) spriteDisabled, target, sel); setPropsForNode(node, (CCDictionary*) props, extraProps); setPropsForMenuItem((CCMenuItem*) node, (CCDictionary*) props, extraProps); @@ -455,38 +455,38 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr else if (className->m_sString.compare("CCMenu") == 0) { node = (CCNode*)CCMenu::menuWithItems(NULL); - setPropsForNode(node, (CCDictionary*) props, extraProps); + setPropsForNode(node, (CCDictionary*) props, extraProps); setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps); setPropsForMenu((CCMenu*)node, (CCDictionary*) props, extraProps); } - else if (className->m_sString.compare("CCLabelBMFont") == 0) + else if (className->m_sString.compare("CCLabelBMFont") == 0) { CCString* fontFile = new CCString(assetsDir); - fontFile->m_sString += ((CCString*)props->objectForKey("fontFile"))->m_sString; + fontFile->m_sString += ((CCString*)props->objectForKey("fontFile"))->m_sString; CCString* stringText = ((CCString*)props->objectForKey("string")); - + node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), fontFile->m_sString.c_str() ); - - delete fontFile; - fontFile = 0; - + + delete fontFile; + fontFile = 0; + if (!node) node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), "missing-font.fnt"); setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLabelBMFont((CCLabelBMFont*) node, (CCDictionary*) props, extraProps); + setPropsForLabelBMFont((CCLabelBMFont*) node, (CCDictionary*) props, extraProps); } - else if (className->m_sString.compare("CCSprite") == 0) + else if (className->m_sString.compare("CCSprite") == 0) { CCString* spriteFile = new CCString(assetsDir); - spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; + spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; CCString* spriteSheetFile = (CCString*)props->objectForKey("spriteFramesFile"); - + if (spriteSheetFile && !spriteSheetFile->length()) - { - spriteSheetFile->m_sString.insert(0, assetsDir); - } + { + spriteSheetFile->m_sString.insert(0, assetsDir); + } if (spriteSheetFile && !spriteSheetFile->length()) { @@ -499,7 +499,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr printf("spriteFile->m_string.cstr is %s\n", spriteFile->m_sString.c_str()) ; node = (CCNode*)CCSprite::spriteWithFile(spriteFile->m_sString.c_str()); } - + CC_SAFE_RELEASE_NULL(spriteFile); if (!node) node = (CCNode*)CCSprite::spriteWithFile("missing-texture.png"); @@ -515,7 +515,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr if (dynamic_cast(node) == NULL) { CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; + delete node; node = NULL; } } @@ -538,7 +538,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr if (dynamic_cast(node) == NULL) { CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; + delete node; node = NULL; } } @@ -558,7 +558,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr if (dynamic_cast(node) == NULL) { CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; + delete node; node = NULL; } } @@ -579,7 +579,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr if (dynamic_cast(node) == NULL) { CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; + delete node; node = NULL; } } @@ -587,12 +587,12 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr { node = (CCNode*)CCNode::node(); } - + setPropsForNode(node, (CCDictionary*) props, extraProps); } else { - CCLOG("WARNING! Class of type %@ couldn't be found", className); + CCLOG("WARNING! Class of type %@ couldn't be found", className); return NULL; } @@ -604,14 +604,14 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr CCDictionary* childDict = (CCDictionary*) children->objectAtIndex(i); CCNode* child = ccObjectFromDictionary(childDict, extraProps, assetsDir, owner, root); int zOrder = intValFromDict((CCDictionary*) childDict->objectForKey("properties"), "zOrder"); - + if (child && node) { node->addChild(child, zOrder); } else { - CCLOG("WARNING! Failed to add child to node"); + CCLOG("WARNING! Failed to add child to node"); } } @@ -660,12 +660,12 @@ CCNode* CCBReader::nodeGraphFromDictionary(CCDictionary* dict, const char* assetsDir, CCNode* owner) { - if (!dict) + if (!dict) { CCLOG("WARNING! Trying to load invalid file type"); return NULL; } - + CCString* fileType = (CCString*) dict->objectForKey("fileType"); int fileVersion = ((CCString*) dict->objectForKey("fileVersion"))->intValue(); @@ -686,8 +686,8 @@ CCNode* CCBReader::nodeGraphFromDictionary(CCDictionary* dict, CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner) { - CCLOG("CCBReader path is: %s", file); - std::string ccbFilePath(file); + CCLOG("CCBReader path is: %s", file); + std::string ccbFilePath(file); std::string ccbFileDir; // find ccbFileDir before "/" or "\" @@ -700,8 +700,8 @@ CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner) } CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(ccbFilePath.c_str()); - CCAssert(dict != NULL, "CCBReader: file not found"); + CCAssert(dict != NULL, "CCBReader: file not found"); - return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner); + return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner); } diff --git a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp index f82b7dbbd9..e04be27088 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp @@ -33,31 +33,31 @@ USING_NS_CC_EXT; int CCBReader::intValFromDict(CCDictionary* dict, const std::string key) { - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); - return valueString? valueString->intValue() : 0; + CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); + return valueString? valueString->intValue() : 0; } float CCBReader::floatValFromDict(CCDictionary* dict, const std::string key) { - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); + CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); return valueString? valueString->floatValue() : 0; } bool CCBReader::boolValFromDict(CCDictionary* dict, const std::string key) { - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); + CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); return valueString? ((bool)(valueString->intValue())) : false; } CCPoint CCBReader::pointValFromDict(CCDictionary* dict, const std::string key) { - CCArray* arr = (CCArray*)dict->objectForKey(key.c_str()); - + CCArray* arr = (CCArray*)dict->objectForKey(key.c_str()); + if (!arr) - { - return ccp(0,0); - } - + { + return ccp(0,0); + } + float x = ((CCString*)arr->objectAtIndex(0))->floatValue(); float y = ((CCString*)arr->objectAtIndex(1))->floatValue(); return ccp(x, y); @@ -65,13 +65,13 @@ CCPoint CCBReader::pointValFromDict(CCDictionary* dict, const std::string key) CCSize CCBReader::sizeValFromDict(CCDictionary* dict, const std::string key) { - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - + CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); + if (!arr) - { - return CCSize(0, 0); - } - + { + return CCSize(0, 0); + } + float w = ((CCString*)arr->objectAtIndex(0))->floatValue(); float h = ((CCString*)arr->objectAtIndex(1))->floatValue(); return CCSize(w, h); @@ -79,39 +79,39 @@ CCSize CCBReader::sizeValFromDict(CCDictionary* dict, const std::string key) ccColor3B CCBReader::ccColor3ValFromDict(CCDictionary* dict, const std::string key) { - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - + CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); + int r = ((CCString*)arr->objectAtIndex(0))->intValue(); int g = ((CCString*)arr->objectAtIndex(1))->intValue(); int b = ((CCString*)arr->objectAtIndex(2))->intValue(); - + return ccc3(r, g, b); } ccColor4F CCBReader::ccColor4fValFromDict(CCDictionary* dict, const std::string key) { - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - + CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); + ccColor4F color; color.r = ((CCString*)arr->objectAtIndex(0))->floatValue(); color.g = ((CCString*)arr->objectAtIndex(1))->floatValue(); color.b = ((CCString*)arr->objectAtIndex(2))->floatValue(); color.a = ((CCString*)arr->objectAtIndex(3))->floatValue(); - + return color; } ccBlendFunc CCBReader::blendFuncValFromDict(CCDictionary* dict, const std::string key) { - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - + CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); + int src = ((CCString*)arr->objectAtIndex(0))->intValue(); int dst = ((CCString*)arr->objectAtIndex(1))->intValue(); - + ccBlendFunc blendFunc; blendFunc.src = src; blendFunc.dst = dst; - + return blendFunc; } @@ -119,10 +119,10 @@ ccBlendFunc CCBReader::blendFuncValFromDict(CCDictionary* dict, const std::strin void CCBReader::setExtraProp(CCObject* prop, const char* key, int tag, CCDictionary* dict) { - std::string tagString; - tagString += tag; + std::string tagString; + tagString += tag; CCDictionary* props = (CCDictionary*) dict->objectForKey(tagString.c_str()); - + if (!props) { props = new CCDictionary(); @@ -140,7 +140,7 @@ void CCBReader::setPropsForMenuItem(CCMenuItem* node, CCDictionary* props, CCDic setExtraProp((CCDictionary*) props->objectForKey("selector"), "selector", node->getTag(), extraProps); setExtraProp((CCDictionary*) props->objectForKey("target"), "target", node->getTag(), extraProps); CCString* spriteFramesFile = (CCString*) props->objectForKey("spriteFramesFile"); - + if (spriteFramesFile) { setExtraProp(spriteFramesFile, "spriteSheetFile", node->getTag(), extraProps); @@ -193,7 +193,7 @@ void CCBReader::setPropsForLabelBMFont(CCLabelBMFont* node, CCDictionary* props, { node->setOpacity(intValFromDict(props, "opacity")); node->setColor(ccColor3ValFromDict(props, "color")); - + if (extraProps) { setExtraProp(props->objectForKey("fontFile"), "fontFile", node->getTag(), extraProps); @@ -221,7 +221,7 @@ void CCBReader::setPropsForParticleSystem(CCParticleSystem* node, CCDictionary* node->setEndSpin(intValFromDict(props, "endSpin")); node->setEndSpinVar(intValFromDict(props, "endSpinVar")); } - + node->setStartColor(ccColor4fValFromDict(props, "startColor")); node->setStartColorVar(ccColor4fValFromDict(props, "startColorVar")); node->setEndColor(ccColor4fValFromDict(props, "endColor")); @@ -286,12 +286,12 @@ void CCBReader::setPropsForSprite(CCSprite* node, CCDictionary* props, CCDiction node->setFlipX(boolValFromDict(props, "flipX")); node->setFlipY(boolValFromDict(props, "flipY")); node->setBlendFunc(blendFuncValFromDict(props, "blendFunc")); - + if (extraProps) { setExtraProp(props->objectForKey("spriteFile"), "spriteFile", node->getTag(), extraProps); CCString* spriteFramesFile = (CCString*) props->objectForKey("spriteFramesFile"); - + if (spriteFramesFile) { setExtraProp(spriteFramesFile, "spriteSheetFile", node->getTag(), extraProps); @@ -301,7 +301,7 @@ void CCBReader::setPropsForSprite(CCSprite* node, CCDictionary* props, CCDiction void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* extraProps) { - CCPoint position = pointValFromDict(props, "position"); + CCPoint position = pointValFromDict(props, "position"); int refPointType = intValFromDict(props, "refPointType"); if (refPointType == kInvalidRelativePosition) @@ -369,10 +369,10 @@ void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* dynamic_cast(node) == NULL && dynamic_cast(node) == NULL) { - CCSize size = sizeValFromDict(props, "contentSize"); - //node->setContentSize(size); + CCSize size = sizeValFromDict(props, "contentSize"); + //node->setContentSize(size); } - + node->setScaleX(floatValFromDict(props, "scaleX")); node->setScaleY(floatValFromDict(props, "scaleY")); node->setAnchorPoint(pointValFromDict(props, "anchorPoint")); @@ -391,20 +391,20 @@ void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* setExtraProp((CCDictionary*) props->objectForKey("customClass"), "customClass", node->getTag(), extraProps); setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentType"), "memberVarAssignmentType", node->getTag(), extraProps); - setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentName"), "memberVarAssignmentName", node->getTag(), extraProps); + setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentName"), "memberVarAssignmentName", node->getTag(), extraProps); setExtraProp((CCDictionary*) props->objectForKey("lockedScaleRatio"), "lockedScaleRatio", node->getTag(), extraProps); // Expanded nodes bool isExpanded; CCString* isExpandedObj = (CCString*) props->objectForKey("isExpanded"); - + if (isExpandedObj) { - isExpanded = !isExpandedObj->m_sString.empty(); - } else { - isExpanded = true; - } - - setExtraProp(isExpandedObj, "isExpanded", node->getTag(), extraProps); + isExpanded = !isExpandedObj->m_sString.empty(); + } else { + isExpanded = true; + } + + setExtraProp(isExpandedObj, "isExpanded", node->getTag(), extraProps); } else { @@ -416,38 +416,38 @@ void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extraProps, const char* assetsDir, CCNode* owner, CCNode* root) { - CCString* className = (CCString*) dict->objectForKey("class"); + CCString* className = (CCString*) dict->objectForKey("class"); CCDictionary* props = (CCDictionary*) dict->objectForKey("properties"); CCArray* children = (CCArray*) dict->objectForKey("children"); CCString* customClass = (CCString*)props->objectForKey("customClass"); - + if (extraProps) customClass = NULL; CCNode* node = NULL; - if (className->m_sString.compare("CCParticleSystem") == 0) + if (className->m_sString.compare("CCParticleSystem") == 0) { CCString* spriteFile = new CCString(assetsDir); - spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; - + spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; + CCParticleSystem* sys = new CCParticleSystemQuad(); - sys->initWithTotalParticles(2048); + sys->initWithTotalParticles(2048); sys->setTexture(CCTextureCache::sharedTextureCache()->addImage(spriteFile->m_sString.c_str())); - delete spriteFile; + delete spriteFile; node = (CCNode*)sys; - + setPropsForNode((CCNode*)node, (CCDictionary*) props, extraProps); setPropsForParticleSystem((CCParticleSystem*) node, (CCDictionary*) props, extraProps); } else if (className->m_sString.compare("CCMenuItemImage") == 0) { CCString* spriteFileNormal = new CCString(assetsDir); - spriteFileNormal->m_sString += ((CCString*)props->objectForKey("spriteFileNormal"))->getCString(); + spriteFileNormal->m_sString += ((CCString*)props->objectForKey("spriteFileNormal"))->getCString(); CCString* spriteFileSelected = new CCString(assetsDir); - spriteFileSelected->m_sString += ((CCString*)props->objectForKey("spriteFileSelected"))->getCString(); + spriteFileSelected->m_sString += ((CCString*)props->objectForKey("spriteFileSelected"))->getCString(); CCString* spriteFileDisabled = new CCString(assetsDir); - spriteFileDisabled->m_sString += ((CCString*)props->objectForKey("spriteFileDisabled"))->getCString(); + spriteFileDisabled->m_sString += ((CCString*)props->objectForKey("spriteFileDisabled"))->getCString(); CCSprite* spriteNormal = NULL; CCSprite* spriteSelected = NULL; @@ -455,12 +455,12 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr CCString* spriteSheetFile = (CCString*)props->objectForKey("spriteFramesFile"); if (spriteSheetFile && !spriteSheetFile->length()) { - spriteSheetFile->m_sString.insert(0, assetsDir); - } + spriteSheetFile->m_sString.insert(0, assetsDir); + } if (spriteSheetFile && !spriteSheetFile->length()) { - CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(spriteSheetFile->m_sString.c_str()); + CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(spriteSheetFile->m_sString.c_str()); spriteNormal = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileNormal"))->getCString()); spriteSelected = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileSelected"))->getCString()); @@ -473,16 +473,16 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr spriteSelected = CCSprite::spriteWithFile(spriteFileSelected->m_sString.c_str()); spriteDisabled = CCSprite::spriteWithFile(spriteFileDisabled->m_sString.c_str()); } - - //deallocate + + //deallocate CC_SAFE_DELETE(spriteFileNormal); CC_SAFE_DELETE(spriteFileSelected); CC_SAFE_DELETE(spriteFileDisabled); if (!spriteNormal) spriteNormal = CCSprite::spriteWithFile("missing-texture.png"); if (!spriteSelected) spriteSelected = CCSprite::spriteWithFile("missing-texture.png"); - if (!spriteDisabled) spriteDisabled = CCSprite::spriteWithFile("missing-texture.png"); - + if (!spriteDisabled) spriteDisabled = CCSprite::spriteWithFile("missing-texture.png"); + CCNode *target = NULL ; if ( extraProps == NULL ) { @@ -507,7 +507,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr target = NULL ; } - node = (CCNode*)CCMenuItemImage::itemWithNormalSprite((CCNode*) spriteNormal, (CCNode*) spriteSelected, (CCNode*) spriteDisabled, target, sel); + node = (CCNode*)CCMenuItemImage::itemWithNormalSprite((CCNode*) spriteNormal, (CCNode*) spriteSelected, (CCNode*) spriteDisabled, target, sel); setPropsForNode(node, (CCDictionary*) props, extraProps); setPropsForMenuItem((CCMenuItem*) node, (CCDictionary*) props, extraProps); @@ -516,38 +516,38 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr else if (className->m_sString.compare("CCMenu") == 0) { node = (CCNode*)CCMenu::menuWithItems(NULL); - setPropsForNode(node, (CCDictionary*) props, extraProps); + setPropsForNode(node, (CCDictionary*) props, extraProps); setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps); setPropsForMenu((CCMenu*)node, (CCDictionary*) props, extraProps); } - else if (className->m_sString.compare("CCLabelBMFont") == 0) + else if (className->m_sString.compare("CCLabelBMFont") == 0) { CCString* fontFile = new CCString(assetsDir); - fontFile->m_sString += ((CCString*)props->objectForKey("fontFile"))->m_sString; + fontFile->m_sString += ((CCString*)props->objectForKey("fontFile"))->m_sString; CCString* stringText = ((CCString*)props->objectForKey("string")); - + node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), fontFile->m_sString.c_str() ); - - delete fontFile; - fontFile = 0; - + + delete fontFile; + fontFile = 0; + if (!node) node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), "missing-font.fnt"); setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLabelBMFont((CCLabelBMFont*) node, (CCDictionary*) props, extraProps); + setPropsForLabelBMFont((CCLabelBMFont*) node, (CCDictionary*) props, extraProps); } - else if (className->m_sString.compare("CCSprite") == 0) + else if (className->m_sString.compare("CCSprite") == 0) { CCString* spriteFile = new CCString(assetsDir); - spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; + spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; CCString* spriteSheetFile = (CCString*)props->objectForKey("spriteFramesFile"); - + if (spriteSheetFile && !spriteSheetFile->length()) - { - spriteSheetFile->m_sString.insert(0, assetsDir); - } + { + spriteSheetFile->m_sString.insert(0, assetsDir); + } if (spriteSheetFile && !spriteSheetFile->length()) { @@ -560,7 +560,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr printf("spriteFile->m_string.cstr is %s\n", spriteFile->m_sString.c_str()) ; node = (CCNode*)CCSprite::spriteWithFile(spriteFile->m_sString.c_str()); } - + CC_SAFE_RELEASE_NULL(spriteFile); if (!node) node = (CCNode*)CCSprite::spriteWithFile("missing-texture.png"); @@ -576,7 +576,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr if (dynamic_cast(node) == NULL) { CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; + delete node; node = NULL; } } @@ -599,7 +599,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr if (dynamic_cast(node) == NULL) { CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; + delete node; node = NULL; } } @@ -619,7 +619,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr if (dynamic_cast(node) == NULL) { CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; + delete node; node = NULL; } } @@ -640,7 +640,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr if (dynamic_cast(node) == NULL) { CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; + delete node; node = NULL; } } @@ -648,12 +648,12 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr { node = (CCNode*)CCNode::node(); } - + setPropsForNode(node, (CCDictionary*) props, extraProps); } else { - CCLOG("WARNING! Class of type %@ couldn't be found", className); + CCLOG("WARNING! Class of type %@ couldn't be found", className); return NULL; } @@ -665,14 +665,14 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr CCDictionary* childDict = (CCDictionary*) children->objectAtIndex(i); CCNode* child = ccObjectFromDictionary(childDict, extraProps, assetsDir, owner, root); int zOrder = intValFromDict((CCDictionary*) childDict->objectForKey("properties"), "zOrder"); - + if (child && node) { node->addChild(child, zOrder); } else { - CCLOG("WARNING! Failed to add child to node"); + CCLOG("WARNING! Failed to add child to node"); } } @@ -721,12 +721,12 @@ CCNode* CCBReader::nodeGraphFromDictionary(CCDictionary* dict, const char* assetsDir, CCNode* owner) { - if (!dict) + if (!dict) { CCLOG("WARNING! Trying to load invalid file type"); return NULL; } - + CCString* fileType = (CCString*) dict->objectForKey("fileType"); int fileVersion = ((CCString*) dict->objectForKey("fileVersion"))->intValue(); @@ -747,8 +747,8 @@ CCNode* CCBReader::nodeGraphFromDictionary(CCDictionary* dict, CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner) { - CCLOG("CCBReader path is: %s", file); - std::string ccbFilePath(file); + CCLOG("CCBReader path is: %s", file); + std::string ccbFilePath(file); std::string ccbFileDir; // find ccbFileDir before "/" or "\" @@ -761,8 +761,8 @@ CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner) } CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(ccbFilePath.c_str()); - CCAssert(dict != NULL, "CCBReader: file not found"); + CCAssert(dict != NULL, "CCBReader: file not found"); - return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner); + return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner); } diff --git a/cocos2dx/platform/CCImageCommon_cpp.h b/cocos2dx/platform/CCImageCommon_cpp.h index df1255c3d2..3ebd41c6a4 100644 --- a/cocos2dx/platform/CCImageCommon_cpp.h +++ b/cocos2dx/platform/CCImageCommon_cpp.h @@ -392,19 +392,19 @@ out: static tmsize_t _tiffReadProc(thandle_t fd, void* buf, tmsize_t size) { tImageSource* isource = (tImageSource*)fd; - uint8* ma; - uint64 mb; - unsigned long n; - unsigned long o; - tmsize_t p; - ma=(uint8*)buf; - mb=size; - p=0; - while (mb>0) - { - n=0x80000000UL; - if ((uint64)n>mb) - n=(unsigned long)mb; + uint8* ma; + uint64 mb; + unsigned long n; + unsigned long o; + tmsize_t p; + ma=(uint8*)buf; + mb=size; + p=0; + while (mb>0) + { + n=0x80000000UL; + if ((uint64)n>mb) + n=(unsigned long)mb; if((int)(isource->offset + n) <= isource->size) @@ -418,15 +418,15 @@ static tmsize_t _tiffReadProc(thandle_t fd, void* buf, tmsize_t size) return 0; } - ma+=o; - mb-=o; - p+=o; - if (o!=n) + ma+=o; + mb-=o; + p+=o; + if (o!=n) { - break; + break; } - } - return p; + } + return p; } static tmsize_t _tiffWriteProc(thandle_t fd, void* buf, tmsize_t size) @@ -434,7 +434,7 @@ static tmsize_t _tiffWriteProc(thandle_t fd, void* buf, tmsize_t size) CC_UNUSED_PARAM(fd); CC_UNUSED_PARAM(buf); CC_UNUSED_PARAM(size); - return 0; + return 0; } @@ -444,7 +444,7 @@ static uint64 _tiffSeekProc(thandle_t fd, uint64 off, int whence) uint64 ret = -1; do { - if (whence == SEEK_SET) + if (whence == SEEK_SET) { CC_BREAK_IF(off > isource->size-1); ret = isource->offset = (uint32)off; @@ -481,19 +481,19 @@ static int _tiffCloseProc(thandle_t fd) return 0; } -static int _tiffMapProc(thandle_t fd, void** pbase, toff_t* psize) -{ - CC_UNUSED_PARAM(fd); - CC_UNUSED_PARAM(pbase); - CC_UNUSED_PARAM(psize); - return 0; -} - -static void _tiffUnmapProc(thandle_t fd, void* base, toff_t size) -{ - CC_UNUSED_PARAM(fd); - CC_UNUSED_PARAM(base); - CC_UNUSED_PARAM(size); +static int _tiffMapProc(thandle_t fd, void** pbase, toff_t* psize) +{ + CC_UNUSED_PARAM(fd); + CC_UNUSED_PARAM(pbase); + CC_UNUSED_PARAM(psize); + return 0; +} + +static void _tiffUnmapProc(thandle_t fd, void* base, toff_t size) +{ + CC_UNUSED_PARAM(fd); + CC_UNUSED_PARAM(base); + CC_UNUSED_PARAM(size); } bool CCImage::_initWithTiffData(void* pData, int nDataLen) @@ -515,25 +515,25 @@ bool CCImage::_initWithTiffData(void* pData, int nDataLen) CC_BREAK_IF(NULL == tif); - uint32 w, h; - uint16 bitsPerSample, samplePerPixel, planarConfig, extraSample; - size_t npixels; - - TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); - TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); - TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bitsPerSample); - TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplePerPixel); - TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &planarConfig); - - npixels = w * h; - - m_bHasAlpha = true; - m_nWidth = w; - m_nHeight = h; - m_nBitsPerComponent = 8; - - m_pData = new unsigned char[npixels * sizeof (uint32)]; - + uint32 w, h; + uint16 bitsPerSample, samplePerPixel, planarConfig, extraSample; + size_t npixels; + + TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); + TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); + TIFFGetField(tif, TIFFTAG_BITSPERSAMPLE, &bitsPerSample); + TIFFGetField(tif, TIFFTAG_SAMPLESPERPIXEL, &samplePerPixel); + TIFFGetField(tif, TIFFTAG_PLANARCONFIG, &planarConfig); + + npixels = w * h; + + m_bHasAlpha = true; + m_nWidth = w; + m_nHeight = h; + m_nBitsPerComponent = 8; + + m_pData = new unsigned char[npixels * sizeof (uint32)]; + uint32* raster = (uint32*) _TIFFmalloc(npixels * sizeof (uint32)); if (raster != NULL) { @@ -550,15 +550,15 @@ bool CCImage::_initWithTiffData(void* pData, int nDataLen) src[j + 2], src[j + 3] ); } */ - m_bPreMulti = true; - + m_bPreMulti = true; + memcpy(m_pData, raster, npixels*sizeof (uint32)); } _TIFFfree(raster); - } - - + } + + TIFFClose(tif); bRet = true; diff --git a/js/JSBindings/ScriptingCore.cpp b/js/JSBindings/ScriptingCore.cpp index 3dbd714c86..33a78b4e72 100644 --- a/js/JSBindings/ScriptingCore.cpp +++ b/js/JSBindings/ScriptingCore.cpp @@ -16,254 +16,254 @@ using namespace cocos2d; static JSClass global_class = { - "global", JSCLASS_GLOBAL_FLAGS, - JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, - JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub, - JSCLASS_NO_OPTIONAL_MEMBERS + "global", JSCLASS_GLOBAL_FLAGS, + JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_StrictPropertyStub, + JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub, + JSCLASS_NO_OPTIONAL_MEMBERS }; ScriptingCore::ScriptingCore() { - this->rt = JS_NewRuntime(8 * 1024 * 1024); - this->cx = JS_NewContext(rt, 8192); - JS_SetOptions(this->cx, JSOPTION_VAROBJFIX); - JS_SetVersion(this->cx, JSVERSION_LATEST); - JS_SetErrorReporter(this->cx, ScriptingCore::reportError); - global = JS_NewCompartmentAndGlobalObject(cx, &global_class, NULL); - if (!JS_InitStandardClasses(cx, global)) { - CCLog("js error"); - } - // create the cocos namespace - JSObject *cocos = JS_NewObject(cx, NULL, NULL, NULL); - jsval cocosVal = OBJECT_TO_JSVAL(cocos); - JS_SetProperty(cx, global, "cocos", &cocosVal); + this->rt = JS_NewRuntime(8 * 1024 * 1024); + this->cx = JS_NewContext(rt, 8192); + JS_SetOptions(this->cx, JSOPTION_VAROBJFIX); + JS_SetVersion(this->cx, JSVERSION_LATEST); + JS_SetErrorReporter(this->cx, ScriptingCore::reportError); + global = JS_NewCompartmentAndGlobalObject(cx, &global_class, NULL); + if (!JS_InitStandardClasses(cx, global)) { + CCLog("js error"); + } + // create the cocos namespace + JSObject *cocos = JS_NewObject(cx, NULL, NULL, NULL); + jsval cocosVal = OBJECT_TO_JSVAL(cocos); + JS_SetProperty(cx, global, "cocos", &cocosVal); - // register the internal classes - S_CCPoint::jsCreateClass(this->cx, cocos, "Point"); - S_CCSize::jsCreateClass(this->cx, cocos, "Size"); - S_CCRect::jsCreateClass(this->cx, cocos, "Rect"); - S__ccGridSize::jsCreateClass(this->cx, cocos, "GridSize"); - S_CCSet::jsCreateClass(this->cx, cocos, "Set"); - S_CCTouch::jsCreateClass(this->cx, cocos, "Touch"); - S_CCDirector::jsCreateClass(this->cx, cocos, "Director"); - S_CCNode::jsCreateClass(this->cx, cocos, "Node"); - S_CCTextureAtlas::jsCreateClass(this->cx, cocos, "TextureAtlas"); - S_CCSpriteBatchNode::jsCreateClass(this->cx, cocos, "SpriteBatchNode"); - S_CCScene::jsCreateClass(this->cx, cocos, "Scene"); - S_CCLayer::jsCreateClass(this->cx, cocos, "Layer"); - S_CCSprite::jsCreateClass(this->cx, cocos, "Sprite"); - S_CCRenderTexture::jsCreateClass(this->cx, cocos, "RenderTexture"); - S_CCMenu::jsCreateClass(this->cx, cocos, "Menu"); - S_CCMenuItem::jsCreateClass(this->cx, cocos, "MenuItem"); - S_CCMenuItemLabel::jsCreateClass(this->cx, cocos, "MenuItemLabel"); - S_CCMenuItemSprite::jsCreateClass(this->cx, cocos, "MenuItemSprite"); - S_CCMenuItemImage::jsCreateClass(this->cx, cocos, "MenuItemImage"); - S_CCSpriteFrame::jsCreateClass(this->cx, cocos, "SpriteFrame"); - S_CCSpriteFrameCache::jsCreateClass(this->cx, cocos, "SpriteFrameCache"); - S_CCAnimation::jsCreateClass(this->cx, cocos, "Animation"); - S_CCAction::jsCreateClass(this->cx, cocos, "Action"); - S_CCActionInterval::jsCreateClass(this->cx, cocos, "ActionInterval"); - S_CCFiniteTimeAction::jsCreateClass(this->cx, cocos, "FiniteTimeAction"); - S_CCActionInstant::jsCreateClass(this->cx, cocos, "ActionInstant"); - S_CCDelayTime::jsCreateClass(this->cx, cocos, "DelayTime"); - S_CCAnimate::jsCreateClass(this->cx, cocos, "Animate"); - S_CCMoveTo::jsCreateClass(this->cx, cocos, "MoveTo"); - S_CCMoveBy::jsCreateClass(this->cx, cocos, "MoveBy"); - S_CCRotateBy::jsCreateClass(this->cx, cocos, "RotateBy"); - S_CCRotateTo::jsCreateClass(this->cx, cocos, "RotateTo"); - S_CCActionEase::jsCreateClass(this->cx, cocos, "ActionEase"); - S_CCEaseRateAction::jsCreateClass(this->cx, cocos, "EaseRateAction"); - S_CCEaseIn::jsCreateClass(this->cx, cocos, "EaseIn"); - S_CCEaseOut::jsCreateClass(this->cx, cocos, "EaseOut"); - S_CCEaseInOut::jsCreateClass(this->cx, cocos, "EaseInOut"); - S_CCEaseBackInOut::jsCreateClass(this->cx, cocos, "EaseBackInOut"); - S_CCEaseBackOut::jsCreateClass(this->cx, cocos, "EaseBackOut"); - S_CCEaseElasticIn::jsCreateClass(this->cx, cocos, "EaseElasticIn"); - S_CCEaseElastic::jsCreateClass(this->cx, cocos, "EaseElastic"); - S_CCEaseElasticOut::jsCreateClass(this->cx, cocos, "EaseElasticOut"); - S_CCEaseElasticInOut::jsCreateClass(this->cx, cocos, "EaseElasticInOut"); - S_CCEaseBounce::jsCreateClass(this->cx, cocos, "EaseBounce"); - S_CCEaseBounceIn::jsCreateClass(this->cx, cocos, "EaseBounceIn"); - S_CCEaseBounceInOut::jsCreateClass(this->cx, cocos, "EaseBounceInOut"); - S_CCEaseBackIn::jsCreateClass(this->cx, cocos, "EaseBackIn"); - S_CCEaseBounceOut::jsCreateClass(this->cx, cocos, "EaseBounceOut"); - S_CCEaseExponentialIn::jsCreateClass(this->cx, cocos, "EaseExponentialIn"); - S_CCEaseExponentialOut::jsCreateClass(this->cx, cocos, "EaseExponentialOut"); - S_CCEaseExponentialInOut::jsCreateClass(this->cx, cocos, "EaseExponentialInOut"); - S_CCEaseSineIn::jsCreateClass(this->cx, cocos, "EaseSineIn"); - S_CCEaseSineOut::jsCreateClass(this->cx, cocos, "EaseSineOut"); - S_CCEaseSineInOut::jsCreateClass(this->cx, cocos, "EaseSineInOut"); - S_CCRepeatForever::jsCreateClass(this->cx, cocos, "RepeatForever"); - S_CCSequence::jsCreateClass(this->cx, cocos, "Sequence"); - S_CCLabelTTF::jsCreateClass(this->cx, cocos, "LabelTTF"); - S_CCParticleSystem::jsCreateClass(this->cx, cocos, "ParticleSystem"); - S_CCFileUtils::jsCreateClass(this->cx, cocos, "FileUtils"); - S_CCTexture2D::jsCreateClass(this->cx, cocos, "Texture2D"); - S_CCTextureCache::jsCreateClass(this->cx, cocos, "TextureCache"); - S_CCParallaxNode::jsCreateClass(this->cx, cocos, "ParallaxNode"); - S_CCTintBy::jsCreateClass(this->cx, cocos, "TintBy"); - S_CCTintTo::jsCreateClass(this->cx, cocos, "TintTo"); - S_CCLayerColor::jsCreateClass(this->cx, cocos, "LayerColor"); - S_CCBlink::jsCreateClass(this->cx, cocos, "Blink"); - S_CCSpeed::jsCreateClass(this->cx, cocos, "Speed"); - S_CCGridAction::jsCreateClass(this->cx, cocos, "GridAction"); - S_CCGrid3DAction::jsCreateClass(this->cx, cocos, "Grid3DAction"); - S_CCWaves3D::jsCreateClass(this->cx, cocos, "Waves3D"); - S_CCTransitionScene::jsCreateClass(this->cx, cocos, "TransitionScene"); - S_CCTransitionSceneOriented::jsCreateClass(this->cx, cocos, "TransitionSceneOriented"); - S_CCTransitionRotoZoom::jsCreateClass(this->cx, cocos, "TransitionRotoZoom"); - S_CCTransitionFadeDown::jsCreateClass(this->cx, cocos, "TransitionFadeDown"); - S_CCTransitionJumpZoom::jsCreateClass(this->cx, cocos, "TransitionJumpZoom"); - S_CCTransitionMoveInL::jsCreateClass(this->cx, cocos, "TransitionMoveInL"); - S_CCTransitionMoveInR::jsCreateClass(this->cx, cocos, "TransitionMoveInR"); - S_CCTransitionMoveInT::jsCreateClass(this->cx, cocos, "TransitionMoveInT"); - S_CCTransitionMoveInB::jsCreateClass(this->cx, cocos, "TransitionMoveInB"); - S_CCTransitionSlideInL::jsCreateClass(this->cx, cocos, "TransitionSlideInL"); - S_CCTransitionSlideInR::jsCreateClass(this->cx, cocos, "TransitionSlideInR"); - S_CCTransitionSlideInB::jsCreateClass(this->cx, cocos, "TransitionSlideInB"); - S_CCTransitionSlideInT::jsCreateClass(this->cx, cocos, "TransitionSlideInT"); - S_CCTransitionShrinkGrow::jsCreateClass(this->cx, cocos, "TransitionShrinkGrow"); - S_CCTransitionFlipX::jsCreateClass(this->cx, cocos, "TransitionFlipX"); - S_CCTransitionFlipY::jsCreateClass(this->cx, cocos, "TransitionFlipY"); - S_CCTransitionFlipAngular::jsCreateClass(this->cx, cocos, "TransitionFlipAngular"); - S_CCTransitionZoomFlipX::jsCreateClass(this->cx, cocos, "TransitionZoomFlipX"); - S_CCTransitionZoomFlipY::jsCreateClass(this->cx, cocos, "TransitionZoomFlipY"); - S_CCTransitionZoomFlipAngular::jsCreateClass(this->cx, cocos, "TransitionZoomFlipAngular"); - S_CCTransitionFade::jsCreateClass(this->cx, cocos, "TransitionFade"); - S_CCTransitionCrossFade::jsCreateClass(this->cx, cocos, "TransitionCrossFade"); - S_CCTransitionTurnOffTiles::jsCreateClass(this->cx, cocos, "TransitionTurnOffTiles"); - S_CCTransitionSplitCols::jsCreateClass(this->cx, cocos, "TransitionSplitCols"); - S_CCTransitionSplitRows::jsCreateClass(this->cx, cocos, "TransitionSplitRows"); - S_CCTransitionFadeTR::jsCreateClass(this->cx, cocos, "TransitionFadeTR"); - S_CCTransitionFadeBL::jsCreateClass(this->cx, cocos, "TransitionFadeBL"); - S_CCTransitionFadeUp::jsCreateClass(this->cx, cocos, "TransitionFadeUp"); - S_CCFadeOutBLTiles::jsCreateClass(this->cx, cocos, "FadeOutBLTiles"); - S_CCProgressFromTo::jsCreateClass(this->cx, cocos, "ProgressFromTo"); - S_CCFadeOutUpTiles::jsCreateClass(this->cx, cocos, "FadeOutUpTiles"); - S_CCAnimationCache::jsCreateClass(this->cx, cocos, "AnimationCache"); - S_CCPlace::jsCreateClass(this->cx, cocos, "Place"); - S_CCLabelBMFont::jsCreateClass(this->cx, cocos, "LabelBMFont"); - S_CCReverseTime::jsCreateClass(this->cx, cocos, "ReverseTime"); - S_CCFadeOutTRTiles::jsCreateClass(this->cx, cocos, "FadeOutTRTiles"); - S_CCCamera::jsCreateClass(this->cx, cocos, "Camera"); - S_CCProgressTo::jsCreateClass(this->cx, cocos, "ProgressTo"); - S_CCWavesTiles3D::jsCreateClass(this->cx, cocos, "WavesTiles3D"); - S_CCMotionStreak::jsCreateClass(this->cx, cocos, "MotionStreak"); - S_CCTransitionProgressRadialCCW::jsCreateClass(this->cx, cocos, "TransitionRadialProgressCCW"); - S_CCFadeOutDownTiles::jsCreateClass(this->cx, cocos, "FadeOutDownTiles"); - S_CCTurnOffTiles::jsCreateClass(this->cx, cocos, "TurnOffTiles"); - S_CCDeccelAmplitude::jsCreateClass(this->cx, cocos, "DeccelAmplitude"); - S_CCProgressTimer::jsCreateClass(this->cx, cocos, "ProgressTimer"); - S_CCReuseGrid::jsCreateClass(this->cx, cocos, "ReuseGrid"); - S_CCStopGrid::jsCreateClass(this->cx, cocos, "StopGrid"); - S_CCTwirl::jsCreateClass(this->cx, cocos, "Twirl"); - S_CCShakyTiles3D::jsCreateClass(this->cx, cocos, "ShakyTiles3D"); - S_CCTransitionProgressRadialCW::jsCreateClass(this->cx, cocos, "TransitionProgressRadialCW"); - S_CCAtlasNode::jsCreateClass(this->cx, cocos, "AtlasNode"); - S_CCWaves::jsCreateClass(this->cx, cocos, "Waves"); - S_CCShow::jsCreateClass(this->cx, cocos, "Show"); - S_CCOrbitCamera::jsCreateClass(this->cx, cocos, "OrbitCamera"); - S_CCShatteredTiles3D::jsCreateClass(this->cx, cocos, "ShatteredTiles3D"); - S_CCHide::jsCreateClass(this->cx, cocos, "Hide"); - S_CCToggleVisibility::jsCreateClass(this->cx, cocos, "ToggleVisibility"); - S_CCActionCamera::jsCreateClass(this->cx, cocos, "ActionCamera"); - S_CCShuffleTiles::jsCreateClass(this->cx, cocos, "ShuffleTiles"); - S_CCLayerGradient::jsCreateClass(this->cx, cocos, "LayerGradient"); - S_CCFlipX::jsCreateClass(this->cx, cocos, "FlipX"); - S_CCRepeat::jsCreateClass(this->cx, cocos, "Repeat"); - S_CCFlipY::jsCreateClass(this->cx, cocos, "FlipY"); - S_CCBezierBy::jsCreateClass(this->cx, cocos, "BezierBy"); - S_CCPageTurn3D::jsCreateClass(this->cx, cocos, "PageTurn3D"); - S_CCLens3D::jsCreateClass(this->cx, cocos, "Lens3D"); - S_CCRipple3D::jsCreateClass(this->cx, cocos, "Ripple3D"); - S_CCApplication::jsCreateClass(this->cx, cocos, "Application"); - S_CCFlipX3D::jsCreateClass(this->cx, cocos, "FlipX3D"); - S_CCJumpTo::jsCreateClass(this->cx, cocos, "JumpTo"); - S_CCTransitionPageTurn::jsCreateClass(this->cx, cocos, "TransitionPageTurn"); - S_CCFlipY3D::jsCreateClass(this->cx, cocos, "FlipY3D"); - S_CCLiquid::jsCreateClass(this->cx, cocos, "Liquid"); - S_CCTiledGrid3DAction::jsCreateClass(this->cx, cocos, "TiledGrid3DAction"); - S_CCJumpBy::jsCreateClass(this->cx, cocos, "JumpBy"); - S_CCFollow::jsCreateClass(this->cx, cocos, "Follow"); - S_CCSkewBy::jsCreateClass(this->cx, cocos, "SkewBy"); - S_CCAccelDeccelAmplitude::jsCreateClass(this->cx, cocos, "AccelDeccelAmplitude"); - S_CCLabelAtlas::jsCreateClass(this->cx, cocos, "LabelAtlas"); - S_CCAccelAmplitude::jsCreateClass(this->cx, cocos, "AccelAmplitude"); - S_CCSkewTo::jsCreateClass(this->cx, cocos, "SkewTo"); - S_CCShaky3D::jsCreateClass(this->cx, cocos, "Shaky3D"); - S_CCSplitCols::jsCreateClass(this->cx, cocos, "SplitCols"); - S_CCFadeOut::jsCreateClass(this->cx, cocos, "FadeOut"); - S_CCTileMapAtlas::jsCreateClass(this->cx, cocos, "TileMapAtlas"); - S_CCFadeTo::jsCreateClass(this->cx, cocos, "FadeTo"); - S_CCJumpTiles3D::jsCreateClass(this->cx, cocos, "JumpTiles3D"); - S_CCFadeIn::jsCreateClass(this->cx, cocos, "FadeIn"); - S_CCSplitRows::jsCreateClass(this->cx, cocos, "SplitRows"); - S_CCScaleBy::jsCreateClass(this->cx, cocos, "ScaleBy"); - S_CCScaleTo::jsCreateClass(this->cx, cocos, "ScaleTo"); - S_CCBezierTo::jsCreateClass(this->cx, cocos, "BezierTo"); - S_CCTMXTiledMap::jsCreateClass(this->cx, cocos, "TMXTiledMap"); - S_CCTMXLayer::jsCreateClass(this->cx, cocos, "TMXLayer"); + // register the internal classes + S_CCPoint::jsCreateClass(this->cx, cocos, "Point"); + S_CCSize::jsCreateClass(this->cx, cocos, "Size"); + S_CCRect::jsCreateClass(this->cx, cocos, "Rect"); + S__ccGridSize::jsCreateClass(this->cx, cocos, "GridSize"); + S_CCSet::jsCreateClass(this->cx, cocos, "Set"); + S_CCTouch::jsCreateClass(this->cx, cocos, "Touch"); + S_CCDirector::jsCreateClass(this->cx, cocos, "Director"); + S_CCNode::jsCreateClass(this->cx, cocos, "Node"); + S_CCTextureAtlas::jsCreateClass(this->cx, cocos, "TextureAtlas"); + S_CCSpriteBatchNode::jsCreateClass(this->cx, cocos, "SpriteBatchNode"); + S_CCScene::jsCreateClass(this->cx, cocos, "Scene"); + S_CCLayer::jsCreateClass(this->cx, cocos, "Layer"); + S_CCSprite::jsCreateClass(this->cx, cocos, "Sprite"); + S_CCRenderTexture::jsCreateClass(this->cx, cocos, "RenderTexture"); + S_CCMenu::jsCreateClass(this->cx, cocos, "Menu"); + S_CCMenuItem::jsCreateClass(this->cx, cocos, "MenuItem"); + S_CCMenuItemLabel::jsCreateClass(this->cx, cocos, "MenuItemLabel"); + S_CCMenuItemSprite::jsCreateClass(this->cx, cocos, "MenuItemSprite"); + S_CCMenuItemImage::jsCreateClass(this->cx, cocos, "MenuItemImage"); + S_CCSpriteFrame::jsCreateClass(this->cx, cocos, "SpriteFrame"); + S_CCSpriteFrameCache::jsCreateClass(this->cx, cocos, "SpriteFrameCache"); + S_CCAnimation::jsCreateClass(this->cx, cocos, "Animation"); + S_CCAction::jsCreateClass(this->cx, cocos, "Action"); + S_CCActionInterval::jsCreateClass(this->cx, cocos, "ActionInterval"); + S_CCFiniteTimeAction::jsCreateClass(this->cx, cocos, "FiniteTimeAction"); + S_CCActionInstant::jsCreateClass(this->cx, cocos, "ActionInstant"); + S_CCDelayTime::jsCreateClass(this->cx, cocos, "DelayTime"); + S_CCAnimate::jsCreateClass(this->cx, cocos, "Animate"); + S_CCMoveTo::jsCreateClass(this->cx, cocos, "MoveTo"); + S_CCMoveBy::jsCreateClass(this->cx, cocos, "MoveBy"); + S_CCRotateBy::jsCreateClass(this->cx, cocos, "RotateBy"); + S_CCRotateTo::jsCreateClass(this->cx, cocos, "RotateTo"); + S_CCActionEase::jsCreateClass(this->cx, cocos, "ActionEase"); + S_CCEaseRateAction::jsCreateClass(this->cx, cocos, "EaseRateAction"); + S_CCEaseIn::jsCreateClass(this->cx, cocos, "EaseIn"); + S_CCEaseOut::jsCreateClass(this->cx, cocos, "EaseOut"); + S_CCEaseInOut::jsCreateClass(this->cx, cocos, "EaseInOut"); + S_CCEaseBackInOut::jsCreateClass(this->cx, cocos, "EaseBackInOut"); + S_CCEaseBackOut::jsCreateClass(this->cx, cocos, "EaseBackOut"); + S_CCEaseElasticIn::jsCreateClass(this->cx, cocos, "EaseElasticIn"); + S_CCEaseElastic::jsCreateClass(this->cx, cocos, "EaseElastic"); + S_CCEaseElasticOut::jsCreateClass(this->cx, cocos, "EaseElasticOut"); + S_CCEaseElasticInOut::jsCreateClass(this->cx, cocos, "EaseElasticInOut"); + S_CCEaseBounce::jsCreateClass(this->cx, cocos, "EaseBounce"); + S_CCEaseBounceIn::jsCreateClass(this->cx, cocos, "EaseBounceIn"); + S_CCEaseBounceInOut::jsCreateClass(this->cx, cocos, "EaseBounceInOut"); + S_CCEaseBackIn::jsCreateClass(this->cx, cocos, "EaseBackIn"); + S_CCEaseBounceOut::jsCreateClass(this->cx, cocos, "EaseBounceOut"); + S_CCEaseExponentialIn::jsCreateClass(this->cx, cocos, "EaseExponentialIn"); + S_CCEaseExponentialOut::jsCreateClass(this->cx, cocos, "EaseExponentialOut"); + S_CCEaseExponentialInOut::jsCreateClass(this->cx, cocos, "EaseExponentialInOut"); + S_CCEaseSineIn::jsCreateClass(this->cx, cocos, "EaseSineIn"); + S_CCEaseSineOut::jsCreateClass(this->cx, cocos, "EaseSineOut"); + S_CCEaseSineInOut::jsCreateClass(this->cx, cocos, "EaseSineInOut"); + S_CCRepeatForever::jsCreateClass(this->cx, cocos, "RepeatForever"); + S_CCSequence::jsCreateClass(this->cx, cocos, "Sequence"); + S_CCLabelTTF::jsCreateClass(this->cx, cocos, "LabelTTF"); + S_CCParticleSystem::jsCreateClass(this->cx, cocos, "ParticleSystem"); + S_CCFileUtils::jsCreateClass(this->cx, cocos, "FileUtils"); + S_CCTexture2D::jsCreateClass(this->cx, cocos, "Texture2D"); + S_CCTextureCache::jsCreateClass(this->cx, cocos, "TextureCache"); + S_CCParallaxNode::jsCreateClass(this->cx, cocos, "ParallaxNode"); + S_CCTintBy::jsCreateClass(this->cx, cocos, "TintBy"); + S_CCTintTo::jsCreateClass(this->cx, cocos, "TintTo"); + S_CCLayerColor::jsCreateClass(this->cx, cocos, "LayerColor"); + S_CCBlink::jsCreateClass(this->cx, cocos, "Blink"); + S_CCSpeed::jsCreateClass(this->cx, cocos, "Speed"); + S_CCGridAction::jsCreateClass(this->cx, cocos, "GridAction"); + S_CCGrid3DAction::jsCreateClass(this->cx, cocos, "Grid3DAction"); + S_CCWaves3D::jsCreateClass(this->cx, cocos, "Waves3D"); + S_CCTransitionScene::jsCreateClass(this->cx, cocos, "TransitionScene"); + S_CCTransitionSceneOriented::jsCreateClass(this->cx, cocos, "TransitionSceneOriented"); + S_CCTransitionRotoZoom::jsCreateClass(this->cx, cocos, "TransitionRotoZoom"); + S_CCTransitionFadeDown::jsCreateClass(this->cx, cocos, "TransitionFadeDown"); + S_CCTransitionJumpZoom::jsCreateClass(this->cx, cocos, "TransitionJumpZoom"); + S_CCTransitionMoveInL::jsCreateClass(this->cx, cocos, "TransitionMoveInL"); + S_CCTransitionMoveInR::jsCreateClass(this->cx, cocos, "TransitionMoveInR"); + S_CCTransitionMoveInT::jsCreateClass(this->cx, cocos, "TransitionMoveInT"); + S_CCTransitionMoveInB::jsCreateClass(this->cx, cocos, "TransitionMoveInB"); + S_CCTransitionSlideInL::jsCreateClass(this->cx, cocos, "TransitionSlideInL"); + S_CCTransitionSlideInR::jsCreateClass(this->cx, cocos, "TransitionSlideInR"); + S_CCTransitionSlideInB::jsCreateClass(this->cx, cocos, "TransitionSlideInB"); + S_CCTransitionSlideInT::jsCreateClass(this->cx, cocos, "TransitionSlideInT"); + S_CCTransitionShrinkGrow::jsCreateClass(this->cx, cocos, "TransitionShrinkGrow"); + S_CCTransitionFlipX::jsCreateClass(this->cx, cocos, "TransitionFlipX"); + S_CCTransitionFlipY::jsCreateClass(this->cx, cocos, "TransitionFlipY"); + S_CCTransitionFlipAngular::jsCreateClass(this->cx, cocos, "TransitionFlipAngular"); + S_CCTransitionZoomFlipX::jsCreateClass(this->cx, cocos, "TransitionZoomFlipX"); + S_CCTransitionZoomFlipY::jsCreateClass(this->cx, cocos, "TransitionZoomFlipY"); + S_CCTransitionZoomFlipAngular::jsCreateClass(this->cx, cocos, "TransitionZoomFlipAngular"); + S_CCTransitionFade::jsCreateClass(this->cx, cocos, "TransitionFade"); + S_CCTransitionCrossFade::jsCreateClass(this->cx, cocos, "TransitionCrossFade"); + S_CCTransitionTurnOffTiles::jsCreateClass(this->cx, cocos, "TransitionTurnOffTiles"); + S_CCTransitionSplitCols::jsCreateClass(this->cx, cocos, "TransitionSplitCols"); + S_CCTransitionSplitRows::jsCreateClass(this->cx, cocos, "TransitionSplitRows"); + S_CCTransitionFadeTR::jsCreateClass(this->cx, cocos, "TransitionFadeTR"); + S_CCTransitionFadeBL::jsCreateClass(this->cx, cocos, "TransitionFadeBL"); + S_CCTransitionFadeUp::jsCreateClass(this->cx, cocos, "TransitionFadeUp"); + S_CCFadeOutBLTiles::jsCreateClass(this->cx, cocos, "FadeOutBLTiles"); + S_CCProgressFromTo::jsCreateClass(this->cx, cocos, "ProgressFromTo"); + S_CCFadeOutUpTiles::jsCreateClass(this->cx, cocos, "FadeOutUpTiles"); + S_CCAnimationCache::jsCreateClass(this->cx, cocos, "AnimationCache"); + S_CCPlace::jsCreateClass(this->cx, cocos, "Place"); + S_CCLabelBMFont::jsCreateClass(this->cx, cocos, "LabelBMFont"); + S_CCReverseTime::jsCreateClass(this->cx, cocos, "ReverseTime"); + S_CCFadeOutTRTiles::jsCreateClass(this->cx, cocos, "FadeOutTRTiles"); + S_CCCamera::jsCreateClass(this->cx, cocos, "Camera"); + S_CCProgressTo::jsCreateClass(this->cx, cocos, "ProgressTo"); + S_CCWavesTiles3D::jsCreateClass(this->cx, cocos, "WavesTiles3D"); + S_CCMotionStreak::jsCreateClass(this->cx, cocos, "MotionStreak"); + S_CCTransitionProgressRadialCCW::jsCreateClass(this->cx, cocos, "TransitionRadialProgressCCW"); + S_CCFadeOutDownTiles::jsCreateClass(this->cx, cocos, "FadeOutDownTiles"); + S_CCTurnOffTiles::jsCreateClass(this->cx, cocos, "TurnOffTiles"); + S_CCDeccelAmplitude::jsCreateClass(this->cx, cocos, "DeccelAmplitude"); + S_CCProgressTimer::jsCreateClass(this->cx, cocos, "ProgressTimer"); + S_CCReuseGrid::jsCreateClass(this->cx, cocos, "ReuseGrid"); + S_CCStopGrid::jsCreateClass(this->cx, cocos, "StopGrid"); + S_CCTwirl::jsCreateClass(this->cx, cocos, "Twirl"); + S_CCShakyTiles3D::jsCreateClass(this->cx, cocos, "ShakyTiles3D"); + S_CCTransitionProgressRadialCW::jsCreateClass(this->cx, cocos, "TransitionProgressRadialCW"); + S_CCAtlasNode::jsCreateClass(this->cx, cocos, "AtlasNode"); + S_CCWaves::jsCreateClass(this->cx, cocos, "Waves"); + S_CCShow::jsCreateClass(this->cx, cocos, "Show"); + S_CCOrbitCamera::jsCreateClass(this->cx, cocos, "OrbitCamera"); + S_CCShatteredTiles3D::jsCreateClass(this->cx, cocos, "ShatteredTiles3D"); + S_CCHide::jsCreateClass(this->cx, cocos, "Hide"); + S_CCToggleVisibility::jsCreateClass(this->cx, cocos, "ToggleVisibility"); + S_CCActionCamera::jsCreateClass(this->cx, cocos, "ActionCamera"); + S_CCShuffleTiles::jsCreateClass(this->cx, cocos, "ShuffleTiles"); + S_CCLayerGradient::jsCreateClass(this->cx, cocos, "LayerGradient"); + S_CCFlipX::jsCreateClass(this->cx, cocos, "FlipX"); + S_CCRepeat::jsCreateClass(this->cx, cocos, "Repeat"); + S_CCFlipY::jsCreateClass(this->cx, cocos, "FlipY"); + S_CCBezierBy::jsCreateClass(this->cx, cocos, "BezierBy"); + S_CCPageTurn3D::jsCreateClass(this->cx, cocos, "PageTurn3D"); + S_CCLens3D::jsCreateClass(this->cx, cocos, "Lens3D"); + S_CCRipple3D::jsCreateClass(this->cx, cocos, "Ripple3D"); + S_CCApplication::jsCreateClass(this->cx, cocos, "Application"); + S_CCFlipX3D::jsCreateClass(this->cx, cocos, "FlipX3D"); + S_CCJumpTo::jsCreateClass(this->cx, cocos, "JumpTo"); + S_CCTransitionPageTurn::jsCreateClass(this->cx, cocos, "TransitionPageTurn"); + S_CCFlipY3D::jsCreateClass(this->cx, cocos, "FlipY3D"); + S_CCLiquid::jsCreateClass(this->cx, cocos, "Liquid"); + S_CCTiledGrid3DAction::jsCreateClass(this->cx, cocos, "TiledGrid3DAction"); + S_CCJumpBy::jsCreateClass(this->cx, cocos, "JumpBy"); + S_CCFollow::jsCreateClass(this->cx, cocos, "Follow"); + S_CCSkewBy::jsCreateClass(this->cx, cocos, "SkewBy"); + S_CCAccelDeccelAmplitude::jsCreateClass(this->cx, cocos, "AccelDeccelAmplitude"); + S_CCLabelAtlas::jsCreateClass(this->cx, cocos, "LabelAtlas"); + S_CCAccelAmplitude::jsCreateClass(this->cx, cocos, "AccelAmplitude"); + S_CCSkewTo::jsCreateClass(this->cx, cocos, "SkewTo"); + S_CCShaky3D::jsCreateClass(this->cx, cocos, "Shaky3D"); + S_CCSplitCols::jsCreateClass(this->cx, cocos, "SplitCols"); + S_CCFadeOut::jsCreateClass(this->cx, cocos, "FadeOut"); + S_CCTileMapAtlas::jsCreateClass(this->cx, cocos, "TileMapAtlas"); + S_CCFadeTo::jsCreateClass(this->cx, cocos, "FadeTo"); + S_CCJumpTiles3D::jsCreateClass(this->cx, cocos, "JumpTiles3D"); + S_CCFadeIn::jsCreateClass(this->cx, cocos, "FadeIn"); + S_CCSplitRows::jsCreateClass(this->cx, cocos, "SplitRows"); + S_CCScaleBy::jsCreateClass(this->cx, cocos, "ScaleBy"); + S_CCScaleTo::jsCreateClass(this->cx, cocos, "ScaleTo"); + S_CCBezierTo::jsCreateClass(this->cx, cocos, "BezierTo"); + S_CCTMXTiledMap::jsCreateClass(this->cx, cocos, "TMXTiledMap"); + S_CCTMXLayer::jsCreateClass(this->cx, cocos, "TMXLayer"); - S_SimpleAudioEngine::jsCreateClass(this->cx, cocos, "SimpleAudioEngine"); + S_SimpleAudioEngine::jsCreateClass(this->cx, cocos, "SimpleAudioEngine"); - // register some global functions - JS_DefineFunction(this->cx, global, "require", ScriptingCore::executeScript, 0, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(this->cx, cocos, "log", ScriptingCore::log, 0, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(this->cx, cocos, "executeScript", ScriptingCore::executeScript, 1, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(this->cx, cocos, "addGCRootObject", ScriptingCore::addRootJS, 1, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(this->cx, cocos, "removeGCRootObject", ScriptingCore::removeRootJS, 1, JSPROP_READONLY | JSPROP_PERMANENT); - JS_DefineFunction(this->cx, cocos, "forceGC", ScriptingCore::forceGC, 0, JSPROP_READONLY | JSPROP_PERMANENT); + // register some global functions + JS_DefineFunction(this->cx, global, "require", ScriptingCore::executeScript, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(this->cx, cocos, "log", ScriptingCore::log, 0, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(this->cx, cocos, "executeScript", ScriptingCore::executeScript, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(this->cx, cocos, "addGCRootObject", ScriptingCore::addRootJS, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(this->cx, cocos, "removeGCRootObject", ScriptingCore::removeRootJS, 1, JSPROP_READONLY | JSPROP_PERMANENT); + JS_DefineFunction(this->cx, cocos, "forceGC", ScriptingCore::forceGC, 0, JSPROP_READONLY | JSPROP_PERMANENT); } bool ScriptingCore::evalString(const char *string, jsval *outVal) { - jsval rval; - JSString *str; - JSBool ok; - const char *filename = "noname"; - uint32_t lineno = 0; - if (outVal == NULL) { - outVal = &rval; - } - ok = JS_EvaluateScript(cx, global, string, strlen(string), filename, lineno, outVal); - if (ok == JS_FALSE) { - CCLog("error evaluating script:\n%s", string); - } - str = JS_ValueToString(cx, rval); - return ok; + jsval rval; + JSString *str; + JSBool ok; + const char *filename = "noname"; + uint32_t lineno = 0; + if (outVal == NULL) { + outVal = &rval; + } + ok = JS_EvaluateScript(cx, global, string, strlen(string), filename, lineno, outVal); + if (ok == JS_FALSE) { + CCLog("error evaluating script:\n%s", string); + } + str = JS_ValueToString(cx, rval); + return ok; } void ScriptingCore::runScript(const char *path) { #ifdef DEBUG - /** - * dpath should point to the parent directory of the "JS" folder. If this is - * set to "" (as it is now) then it will take the scripts from the app bundle. - * By setting the absolute path you can iterate the development only by - * modifying those scripts and reloading from the simulator (no recompiling/ - * relaunching) - */ -// std::string dpath("/Users/rabarca/Desktop/testjs/testjs/"); - std::string dpath(""); - dpath += path; - const char *realPath = CCFileUtils::fullPathFromRelativePath(dpath.c_str()); + /** + * dpath should point to the parent directory of the "JS" folder. If this is + * set to "" (as it is now) then it will take the scripts from the app bundle. + * By setting the absolute path you can iterate the development only by + * modifying those scripts and reloading from the simulator (no recompiling/ + * relaunching) + */ +// std::string dpath("/Users/rabarca/Desktop/testjs/testjs/"); + std::string dpath(""); + dpath += path; + const char *realPath = CCFileUtils::fullPathFromRelativePath(dpath.c_str()); #else - const char *realPath = CCFileUtils::fullPathFromRelativePath(path); + const char *realPath = CCFileUtils::fullPathFromRelativePath(path); #endif - const char* content = CCString::stringWithContentsOfFile(realPath)->getCString(); - if (content && strlen(content) > 0) { - JSBool ok; - jsval rval; - ok = JS_EvaluateScript(this->cx, this->global, (char *)content, strlen(content), path, 1, &rval); - if (ok == JS_FALSE) { - CCLog("error evaluating script:\n%s", content); - } - } + const char* content = CCString::stringWithContentsOfFile(realPath)->getCString(); + if (content && strlen(content) > 0) { + JSBool ok; + jsval rval; + ok = JS_EvaluateScript(this->cx, this->global, (char *)content, strlen(content), path, 1, &rval); + if (ok == JS_FALSE) { + CCLog("error evaluating script:\n%s", content); + } + } } ScriptingCore::~ScriptingCore() { - JS_DestroyContext(cx); - JS_DestroyRuntime(rt); - JS_ShutDown(); + JS_DestroyContext(cx); + JS_DestroyRuntime(rt); + JS_ShutDown(); } diff --git a/js/JSBindings/ScriptingCore.h b/js/JSBindings/ScriptingCore.h index 1aa5a5155c..8a58ac5681 100644 --- a/js/JSBindings/ScriptingCore.h +++ b/js/JSBindings/ScriptingCore.h @@ -14,129 +14,129 @@ class ScriptingCore { - JSRuntime *rt; - JSContext *cx; - JSObject *global; + JSRuntime *rt; + JSContext *cx; + JSObject *global; - ScriptingCore(); + ScriptingCore(); public: - ~ScriptingCore(); + ~ScriptingCore(); - static ScriptingCore & getInstance() { - static ScriptingCore instance; - return instance; - }; + static ScriptingCore & getInstance() { + static ScriptingCore instance; + return instance; + }; - /** - * will eval the specified string - * @param string The string with the javascript code to be evaluated - * @param outVal The jsval that will hold the return value of the evaluation. - * Can be NULL. - */ - bool evalString(const char *string, jsval *outVal); + /** + * will eval the specified string + * @param string The string with the javascript code to be evaluated + * @param outVal The jsval that will hold the return value of the evaluation. + * Can be NULL. + */ + bool evalString(const char *string, jsval *outVal); - /** - * will run the specified string - * @param string The path of the script to be run - */ - void runScript(const char *path); + /** + * will run the specified string + * @param string The path of the script to be run + */ + void runScript(const char *path); - /** - * @return the global context - */ - JSContext* getGlobalContext() { - return cx; - }; + /** + * @return the global context + */ + JSContext* getGlobalContext() { + return cx; + }; - /** - * @param cx - * @param message - * @param report - */ - static void reportError(JSContext *cx, const char *message, JSErrorReport *report) - { - fprintf(stderr, "%s:%u:%s\n", - report->filename ? report->filename : "", - (unsigned int) report->lineno, - message); - }; + /** + * @param cx + * @param message + * @param report + */ + static void reportError(JSContext *cx, const char *message, JSErrorReport *report) + { + fprintf(stderr, "%s:%u:%s\n", + report->filename ? report->filename : "", + (unsigned int) report->lineno, + message); + }; - /** - * Log something using CCLog - * @param cx - * @param argc - * @param vp - */ - static JSBool log(JSContext *cx, uint32_t argc, jsval *vp) - { - if (argc > 0) { - JSString *string = NULL; - JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &string); - if (string) { - char *cstr = JS_EncodeString(cx, string); - cocos2d::CCLog(cstr); - } - } - return JS_TRUE; - }; + /** + * Log something using CCLog + * @param cx + * @param argc + * @param vp + */ + static JSBool log(JSContext *cx, uint32_t argc, jsval *vp) + { + if (argc > 0) { + JSString *string = NULL; + JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &string); + if (string) { + char *cstr = JS_EncodeString(cx, string); + cocos2d::CCLog(cstr); + } + } + return JS_TRUE; + }; - /** - * run a script from script :) - */ - static JSBool executeScript(JSContext *cx, uint32_t argc, jsval *vp) - { - if (argc == 1) { - JSString *string; - if (JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &string) == JS_TRUE) { - ScriptingCore::getInstance().runScript(JS_EncodeString(cx, string)); - } - } - return JS_TRUE; - }; + /** + * run a script from script :) + */ + static JSBool executeScript(JSContext *cx, uint32_t argc, jsval *vp) + { + if (argc == 1) { + JSString *string; + if (JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "S", &string) == JS_TRUE) { + ScriptingCore::getInstance().runScript(JS_EncodeString(cx, string)); + } + } + return JS_TRUE; + }; - /** - * Register an object as a member of the GC's root set, preventing - * them from being GC'ed - */ - static JSBool addRootJS(JSContext *cx, uint32_t argc, jsval *vp) - { - if (argc == 1) { - JSObject *o = NULL; - if (JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "o", &o) == JS_TRUE) { - if (JS_AddObjectRoot(cx, &o) == JS_FALSE) { - cocos2d::CCLog("something went wrong when setting an object to the root"); - } - } - } - return JS_TRUE; - }; + /** + * Register an object as a member of the GC's root set, preventing + * them from being GC'ed + */ + static JSBool addRootJS(JSContext *cx, uint32_t argc, jsval *vp) + { + if (argc == 1) { + JSObject *o = NULL; + if (JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "o", &o) == JS_TRUE) { + if (JS_AddObjectRoot(cx, &o) == JS_FALSE) { + cocos2d::CCLog("something went wrong when setting an object to the root"); + } + } + } + return JS_TRUE; + }; - /** - * removes an object from the GC's root, allowing them to be GC'ed if no - * longer referenced. - */ - static JSBool removeRootJS(JSContext *cx, uint32_t argc, jsval *vp) - { - if (argc == 1) { - JSObject *o = NULL; - if (JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "o", &o) == JS_TRUE) { - JS_RemoveObjectRoot(cx, &o); - } - } - return JS_TRUE; - }; + /** + * removes an object from the GC's root, allowing them to be GC'ed if no + * longer referenced. + */ + static JSBool removeRootJS(JSContext *cx, uint32_t argc, jsval *vp) + { + if (argc == 1) { + JSObject *o = NULL; + if (JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "o", &o) == JS_TRUE) { + JS_RemoveObjectRoot(cx, &o); + } + } + return JS_TRUE; + }; - /** - * Force a cycle of GC - * @param cx - * @param argc - * @param vp - */ - static JSBool forceGC(JSContext *cx, uint32_t argc, jsval *vp) - { - JS_GC(cx); - return JS_TRUE; - }; + /** + * Force a cycle of GC + * @param cx + * @param argc + * @param vp + */ + static JSBool forceGC(JSContext *cx, uint32_t argc, jsval *vp) + { + JS_GC(cx); + return JS_TRUE; + }; }; #endif diff --git a/js/JSBindings/cocos2d_manual_bindings.cpp b/js/JSBindings/cocos2d_manual_bindings.cpp index b0318ad5c7..e8a4ca5877 100644 --- a/js/JSBindings/cocos2d_manual_bindings.cpp +++ b/js/JSBindings/cocos2d_manual_bindings.cpp @@ -1,379 +1,379 @@ #include "cocos2d_generated.hpp" JSBool S_CCNode::jsaddChild(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); - S_CCNode* self = NULL; JSGET_PTRSHELL(S_CCNode, self, obj); - if (self == NULL) return JS_FALSE; - if (argc >= 1) { - JSObject *arg0; - int zorder = 0; - int tag = 0; - JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "o/ii", &arg0, &zorder, &tag); - CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0); - // call the proper method - if (argc == 1) { - self->addChild(narg0); - } else if (argc == 2) { - self->addChild(narg0, zorder); - } else { - self->addChild(narg0, zorder, tag); - } + JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); + S_CCNode* self = NULL; JSGET_PTRSHELL(S_CCNode, self, obj); + if (self == NULL) return JS_FALSE; + if (argc >= 1) { + JSObject *arg0; + int zorder = 0; + int tag = 0; + JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "o/ii", &arg0, &zorder, &tag); + CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0); + // call the proper method + if (argc == 1) { + self->addChild(narg0); + } else if (argc == 2) { + self->addChild(narg0, zorder); + } else { + self->addChild(narg0, zorder, tag); + } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCMenuItemSprite::jsinitWithNormalSprite(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); - S_CCMenuItemSprite* self = NULL; JSGET_PTRSHELL(S_CCMenuItemSprite, self, obj); - if (self == NULL) return JS_FALSE; - if (argc >= 2) { - JSObject *arg0; - JSObject *arg1; - JSObject *arg2 = NULL; - JS_ConvertArguments(cx, 5, JS_ARGV(cx, vp), "oo/o", &arg0, &arg1, &arg2); - CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0); - CCNode* narg1; JSGET_PTRSHELL(CCNode, narg1, arg1); - CCNode* narg2 = NULL; if (argc == 3) JSGET_PTRSHELL(CCNode, narg2, arg2); - bool ret = self->initWithNormalSprite(narg0, narg1, narg2, self, menu_selector(S_CCMenuItemSprite::menuAction)); - JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); - - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); + S_CCMenuItemSprite* self = NULL; JSGET_PTRSHELL(S_CCMenuItemSprite, self, obj); + if (self == NULL) return JS_FALSE; + if (argc >= 2) { + JSObject *arg0; + JSObject *arg1; + JSObject *arg2 = NULL; + JS_ConvertArguments(cx, 5, JS_ARGV(cx, vp), "oo/o", &arg0, &arg1, &arg2); + CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0); + CCNode* narg1; JSGET_PTRSHELL(CCNode, narg1, arg1); + CCNode* narg2 = NULL; if (argc == 3) JSGET_PTRSHELL(CCNode, narg2, arg2); + bool ret = self->initWithNormalSprite(narg0, narg1, narg2, self, menu_selector(S_CCMenuItemSprite::menuAction)); + JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); + + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCMenuItemImage::jsinitWithNormalImage(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); - S_CCMenuItemImage* self = NULL; JSGET_PTRSHELL(S_CCMenuItemImage, self, obj); - if (self == NULL) return JS_FALSE; - if (argc >= 2) { - JSString *arg0; - JSString *arg1; - JSString *arg2 = NULL; - JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "SS/S", &arg0, &arg1, &arg2); - char *narg0 = JS_EncodeString(cx, arg0); - char *narg1 = JS_EncodeString(cx, arg1); - char *narg2 = (arg2) ? JS_EncodeString(cx, arg2) : NULL; - bool ret = self->initWithNormalImage(narg0, narg1, narg2, self, menu_selector(S_CCMenuItemImage::menuAction)); - JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); - - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); + S_CCMenuItemImage* self = NULL; JSGET_PTRSHELL(S_CCMenuItemImage, self, obj); + if (self == NULL) return JS_FALSE; + if (argc >= 2) { + JSString *arg0; + JSString *arg1; + JSString *arg2 = NULL; + JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "SS/S", &arg0, &arg1, &arg2); + char *narg0 = JS_EncodeString(cx, arg0); + char *narg1 = JS_EncodeString(cx, arg1); + char *narg2 = (arg2) ? JS_EncodeString(cx, arg2) : NULL; + bool ret = self->initWithNormalImage(narg0, narg1, narg2, self, menu_selector(S_CCMenuItemImage::menuAction)); + JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); + + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCSequence::jsactions(JSContext *cx, uint32_t argc, jsval *vp) { - // just like CCSequence::actions - if (argc > 0) { - jsval* argv = JS_ARGV(cx, vp); - // get first element - S_CCSequence* prev; - JSGET_PTRSHELL(S_CCSequence, prev, JSVAL_TO_OBJECT(argv[0])); - for (int i=1; i < argc; i++) { - CCFiniteTimeAction *next; JSGET_PTRSHELL(CCFiniteTimeAction, next, JSVAL_TO_OBJECT(argv[i])); - prev = (S_CCSequence *)CCSequence::actionOneTwo(prev, next); - } - // wrap prev in an action - // temporary because it's just a wrapper for an autoreleased object - // or worst case, it's an already binded object (if it's just one item in the array) - pointerShell_t* pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t)); - pt->flags = kPointerTemporary; - pt->data = prev; - JSObject* out = JS_NewObject(cx, S_CCSequence::jsClass, S_CCSequence::jsObject, NULL); - prev->jsObject = out; - JS_SetPrivate(out, pt); - JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(out)); - return JS_TRUE; - } - JS_ReportError(cx, "must call with at least one element"); - return JS_FALSE; + // just like CCSequence::actions + if (argc > 0) { + jsval* argv = JS_ARGV(cx, vp); + // get first element + S_CCSequence* prev; + JSGET_PTRSHELL(S_CCSequence, prev, JSVAL_TO_OBJECT(argv[0])); + for (int i=1; i < argc; i++) { + CCFiniteTimeAction *next; JSGET_PTRSHELL(CCFiniteTimeAction, next, JSVAL_TO_OBJECT(argv[i])); + prev = (S_CCSequence *)CCSequence::actionOneTwo(prev, next); + } + // wrap prev in an action + // temporary because it's just a wrapper for an autoreleased object + // or worst case, it's an already binded object (if it's just one item in the array) + pointerShell_t* pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t)); + pt->flags = kPointerTemporary; + pt->data = prev; + JSObject* out = JS_NewObject(cx, S_CCSequence::jsClass, S_CCSequence::jsObject, NULL); + prev->jsObject = out; + JS_SetPrivate(out, pt); + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(out)); + return JS_TRUE; + } + JS_ReportError(cx, "must call with at least one element"); + return JS_FALSE; } JSBool S_CCParticleSystem::jsparticleWithFile(JSContext *cx, uint32_t argc, jsval *vp) { - if (argc == 1) { - JSString *arg0; - JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "S", &arg0); - char *narg0 = JS_EncodeString(cx, arg0); - CCParticleSystem* ret = CCParticleSystemQuad::particleWithFile(narg0); - if (ret == NULL) { - JS_SET_RVAL(cx, vp, JSVAL_NULL); - return JS_TRUE; - } - do { - JSObject *tmp = JS_NewObject(cx, S_CCParticleSystem::jsClass, S_CCParticleSystem::jsObject, NULL); - pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t)); - pt->flags = kPointerTemporary; - pt->data = (void *)ret; - JS_SetPrivate(tmp, pt); - JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp)); - } while (0); - - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + if (argc == 1) { + JSString *arg0; + JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "S", &arg0); + char *narg0 = JS_EncodeString(cx, arg0); + CCParticleSystem* ret = CCParticleSystemQuad::particleWithFile(narg0); + if (ret == NULL) { + JS_SET_RVAL(cx, vp, JSVAL_NULL); + return JS_TRUE; + } + do { + JSObject *tmp = JS_NewObject(cx, S_CCParticleSystem::jsClass, S_CCParticleSystem::jsObject, NULL); + pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t)); + pt->flags = kPointerTemporary; + pt->data = (void *)ret; + JS_SetPrivate(tmp, pt); + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp)); + } while (0); + + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCFileUtils::jsgetFileData(JSContext *cx, uint32_t argc, jsval *vp) { - if (argc == 2) { - JSString *arg0; - JSString *arg1; - unsigned long len; - JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1); - char *narg0 = JS_EncodeString(cx, arg0); - char *narg1 = JS_EncodeString(cx, arg1); - unsigned char *ret = CCFileUtils::getFileData(narg0, narg1, &len); - if (ret == NULL) { - JS_SET_RVAL(cx, vp, JSVAL_NULL); - return JS_TRUE; - } - JSString *str = JS_NewStringCopyN(cx, (const char *)ret, len); - JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(str)); - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + if (argc == 2) { + JSString *arg0; + JSString *arg1; + unsigned long len; + JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1); + char *narg0 = JS_EncodeString(cx, arg0); + char *narg1 = JS_EncodeString(cx, arg1); + unsigned char *ret = CCFileUtils::getFileData(narg0, narg1, &len); + if (ret == NULL) { + JS_SET_RVAL(cx, vp, JSVAL_NULL); + return JS_TRUE; + } + JSString *str = JS_NewStringCopyN(cx, (const char *)ret, len); + JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(str)); + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCFileUtils::jsfullPathFromRelativePath(JSContext *cx, uint32_t argc, jsval *vp) { - if (argc == 1) { - JSString *arg0; - JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "S", &arg0); - char *narg0 = JS_EncodeString(cx, arg0); - const char *ret = CCFileUtils::fullPathFromRelativePath(narg0); - if (ret == NULL) { - JS_SET_RVAL(cx, vp, JSVAL_NULL); - return JS_TRUE; - } - JSString *str = JS_NewStringCopyN(cx, ret, strlen(ret)); - JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(str)); - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + if (argc == 1) { + JSString *arg0; + JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "S", &arg0); + char *narg0 = JS_EncodeString(cx, arg0); + const char *ret = CCFileUtils::fullPathFromRelativePath(narg0); + if (ret == NULL) { + JS_SET_RVAL(cx, vp, JSVAL_NULL); + return JS_TRUE; + } + JSString *str = JS_NewStringCopyN(cx, ret, strlen(ret)); + JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(str)); + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCFileUtils::jsfullPathFromRelativeFile(JSContext *cx, uint32_t argc, jsval *vp) { - if (argc == 2) { - JSString *arg0; - JSString *arg1; - JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1); - char *narg0 = JS_EncodeString(cx, arg0); - char *narg1 = JS_EncodeString(cx, arg1); - const char *ret = CCFileUtils::fullPathFromRelativeFile(narg0, narg1); - if (ret == NULL) { - JS_SET_RVAL(cx, vp, JSVAL_NULL); - return JS_TRUE; - } - JSString *str = JS_NewStringCopyN(cx, ret, strlen(ret)); - JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(str)); - return JS_TRUE; - - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + if (argc == 2) { + JSString *arg0; + JSString *arg1; + JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1); + char *narg0 = JS_EncodeString(cx, arg0); + char *narg1 = JS_EncodeString(cx, arg1); + const char *ret = CCFileUtils::fullPathFromRelativeFile(narg0, narg1); + if (ret == NULL) { + JS_SET_RVAL(cx, vp, JSVAL_NULL); + return JS_TRUE; + } + JSString *str = JS_NewStringCopyN(cx, ret, strlen(ret)); + JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(str)); + return JS_TRUE; + + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCLabelTTF::jslabelWithString(JSContext *cx, uint32_t argc, jsval *vp) { - if (argc == 5) { - JSString *arg0; - JSObject *arg1; - int arg2; - JSString *arg3; - double arg4; - JS_ConvertArguments(cx, 5, JS_ARGV(cx, vp), "SoiSd", &arg0, &arg1, &arg2, &arg3, &arg4); - char *narg0 = JS_EncodeString(cx, arg0); - CCSize* narg1; JSGET_PTRSHELL(CCSize, narg1, arg1); - char *narg3 = JS_EncodeString(cx, arg3); - CCLabelTTF *ret = CCLabelTTF::labelWithString(narg0, *narg1, (CCTextAlignment)arg2, narg3, arg4); - if (ret == NULL) { - JS_SET_RVAL(cx, vp, JSVAL_NULL); - return JS_TRUE; - } - do { - JSObject *tmp = JS_NewObject(cx, S_CCLabelTTF::jsClass, S_CCLabelTTF::jsObject, NULL); - pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t)); - pt->flags = kPointerTemporary; - pt->data = (void *)ret; - JS_SetPrivate(tmp, pt); - JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp)); - } while (0); - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + if (argc == 5) { + JSString *arg0; + JSObject *arg1; + int arg2; + JSString *arg3; + double arg4; + JS_ConvertArguments(cx, 5, JS_ARGV(cx, vp), "SoiSd", &arg0, &arg1, &arg2, &arg3, &arg4); + char *narg0 = JS_EncodeString(cx, arg0); + CCSize* narg1; JSGET_PTRSHELL(CCSize, narg1, arg1); + char *narg3 = JS_EncodeString(cx, arg3); + CCLabelTTF *ret = CCLabelTTF::labelWithString(narg0, *narg1, (CCTextAlignment)arg2, narg3, arg4); + if (ret == NULL) { + JS_SET_RVAL(cx, vp, JSVAL_NULL); + return JS_TRUE; + } + do { + JSObject *tmp = JS_NewObject(cx, S_CCLabelTTF::jsClass, S_CCLabelTTF::jsObject, NULL); + pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t)); + pt->flags = kPointerTemporary; + pt->data = (void *)ret; + JS_SetPrivate(tmp, pt); + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp)); + } while (0); + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCLabelTTF::jsinitWithString(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); - S_CCLabelTTF* self = NULL; JSGET_PTRSHELL(S_CCLabelTTF, self, obj); - if (self == NULL) return JS_FALSE; - if (argc == 5) { - JSString *arg0; - JSObject *arg1; - int arg2; - JSString *arg3; - double arg4; - JS_ConvertArguments(cx, 5, JS_ARGV(cx, vp), "SoiSd", &arg0, &arg1, &arg2, &arg3, &arg4); - char *narg0 = JS_EncodeString(cx, arg0); - CCSize* narg1; JSGET_PTRSHELL(CCSize, narg1, arg1); - char *narg3 = JS_EncodeString(cx, arg3); - bool ret = self->initWithString(narg0, *narg1, (CCTextAlignment)arg2, narg3, arg4); - JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); - - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); + S_CCLabelTTF* self = NULL; JSGET_PTRSHELL(S_CCLabelTTF, self, obj); + if (self == NULL) return JS_FALSE; + if (argc == 5) { + JSString *arg0; + JSObject *arg1; + int arg2; + JSString *arg3; + double arg4; + JS_ConvertArguments(cx, 5, JS_ARGV(cx, vp), "SoiSd", &arg0, &arg1, &arg2, &arg3, &arg4); + char *narg0 = JS_EncodeString(cx, arg0); + CCSize* narg1; JSGET_PTRSHELL(CCSize, narg1, arg1); + char *narg3 = JS_EncodeString(cx, arg3); + bool ret = self->initWithString(narg0, *narg1, (CCTextAlignment)arg2, narg3, arg4); + JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); + + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCMenuItem::jsinit(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); - S_CCMenuItem* self = NULL; JSGET_PTRSHELL(S_CCMenuItem, self, obj); - if (self == NULL) return JS_FALSE; - if (argc == 0) { - bool ret = self->initWithTarget(self, menu_selector(S_CCMenuItem::menuAction)); - JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); - - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); + S_CCMenuItem* self = NULL; JSGET_PTRSHELL(S_CCMenuItem, self, obj); + if (self == NULL) return JS_FALSE; + if (argc == 0) { + bool ret = self->initWithTarget(self, menu_selector(S_CCMenuItem::menuAction)); + JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); + + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCRenderTexture::jsrenderTextureWithWidthAndHeight(JSContext *cx, uint32_t argc, jsval *vp) { - if (argc == 2) { - int arg0; - int arg1; - JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "ii", &arg0, &arg1); - CCRenderTexture* ret = CCRenderTexture::renderTextureWithWidthAndHeight(arg0, arg1); - do { - JSObject *tmp = JS_NewObject(cx, S_CCRenderTexture::jsClass, S_CCRenderTexture::jsObject, NULL); - pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t)); - pt->flags = kPointerTemporary; - pt->data = (void *)ret; - JS_SetPrivate(tmp, pt); - JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp)); - } while (0); - - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + if (argc == 2) { + int arg0; + int arg1; + JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "ii", &arg0, &arg1); + CCRenderTexture* ret = CCRenderTexture::renderTextureWithWidthAndHeight(arg0, arg1); + do { + JSObject *tmp = JS_NewObject(cx, S_CCRenderTexture::jsClass, S_CCRenderTexture::jsObject, NULL); + pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t)); + pt->flags = kPointerTemporary; + pt->data = (void *)ret; + JS_SetPrivate(tmp, pt); + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp)); + } while (0); + + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCRenderTexture::jsinitWithWidthAndHeight(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); - S_CCRenderTexture* self = NULL; JSGET_PTRSHELL(S_CCRenderTexture, self, obj); - if (self == NULL) return JS_FALSE; - if (argc == 2) { - int arg0; - int arg1; - JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "ii", &arg0, &arg1); - bool ret = self->initWithWidthAndHeight(arg0, arg1, kCCTexture2DPixelFormat_RGBA8888); - JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); - - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); + S_CCRenderTexture* self = NULL; JSGET_PTRSHELL(S_CCRenderTexture, self, obj); + if (self == NULL) return JS_FALSE; + if (argc == 2) { + int arg0; + int arg1; + JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "ii", &arg0, &arg1); + bool ret = self->initWithWidthAndHeight(arg0, arg1, kCCTexture2DPixelFormat_RGBA8888); + JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); + + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCMenuItemLabel::jsitemWithLabel(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); - S_CCRenderTexture* self = NULL; JSGET_PTRSHELL(S_CCRenderTexture, self, obj); - if (self == NULL) return JS_FALSE; - if (argc == 1) { - JSObject *arg0; - JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "o", &arg0); - CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0); - CCMenuItemLabel *ret = CCMenuItemLabel::itemWithLabel(narg0, self, menu_selector(S_CCMenuItemLabel::menuAction)); - if (ret == NULL) { - JS_SET_RVAL(cx, vp, JSVAL_NULL); - return JS_TRUE; - } - do { - JSObject *tmp = JS_NewObject(cx, S_CCMenuItemLabel::jsClass, S_CCMenuItemLabel::jsObject, NULL); - pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t)); - pt->flags = kPointerTemporary; - pt->data = (void *)ret; - JS_SetPrivate(tmp, pt); - JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp)); - } while(0); - - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); + S_CCRenderTexture* self = NULL; JSGET_PTRSHELL(S_CCRenderTexture, self, obj); + if (self == NULL) return JS_FALSE; + if (argc == 1) { + JSObject *arg0; + JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "o", &arg0); + CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0); + CCMenuItemLabel *ret = CCMenuItemLabel::itemWithLabel(narg0, self, menu_selector(S_CCMenuItemLabel::menuAction)); + if (ret == NULL) { + JS_SET_RVAL(cx, vp, JSVAL_NULL); + return JS_TRUE; + } + do { + JSObject *tmp = JS_NewObject(cx, S_CCMenuItemLabel::jsClass, S_CCMenuItemLabel::jsObject, NULL); + pointerShell_t *pt = (pointerShell_t *)JS_malloc(cx, sizeof(pointerShell_t)); + pt->flags = kPointerTemporary; + pt->data = (void *)ret; + JS_SetPrivate(tmp, pt); + JS_SET_RVAL(cx, vp, OBJECT_TO_JSVAL(tmp)); + } while(0); + + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCMenuItemLabel::jsinitWithLabel(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); - S_CCMenuItemLabel* self = NULL; JSGET_PTRSHELL(S_CCMenuItemLabel, self, obj); - if (self == NULL) return JS_FALSE; - if (argc == 1) { - JSObject *arg0; - JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "o", &arg0); - CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0); - bool ret = self->initWithLabel(narg0, self, menu_selector(S_CCMenuItemLabel::menuAction)); - JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); - - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); + S_CCMenuItemLabel* self = NULL; JSGET_PTRSHELL(S_CCMenuItemLabel, self, obj); + if (self == NULL) return JS_FALSE; + if (argc == 1) { + JSObject *arg0; + JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "o", &arg0); + CCNode* narg0; JSGET_PTRSHELL(CCNode, narg0, arg0); + bool ret = self->initWithLabel(narg0, self, menu_selector(S_CCMenuItemLabel::menuAction)); + JS_SET_RVAL(cx, vp, BOOLEAN_TO_JSVAL(ret)); + + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCApplication::jsgetCurrentLanguage(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); - CCApplication* self = NULL; JSGET_PTRSHELL(CCApplication, self, obj); - if (self == NULL) return JS_FALSE; - jsval result; JS_NewNumberValue(cx, self->getCurrentLanguage(), &result); - JS_SET_RVAL(cx, vp, result); - return JS_TRUE; + JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); + CCApplication* self = NULL; JSGET_PTRSHELL(CCApplication, self, obj); + if (self == NULL) return JS_FALSE; + jsval result; JS_NewNumberValue(cx, self->getCurrentLanguage(), &result); + JS_SET_RVAL(cx, vp, result); + return JS_TRUE; } JSBool S_CCUserDefault::jsgetStringForKey(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); - S_CCUserDefault* self = NULL; JSGET_PTRSHELL(S_CCUserDefault, self, obj); - if (self == NULL) return JS_FALSE; - if (argc == 2) { - JSString *arg0; - JSString *arg1; - JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1); - char *narg0 = JS_EncodeString(cx, arg0); - std::string narg1(JS_EncodeString(cx, arg1)); - std::string ret = self->getStringForKey(narg0, narg1); - JSString *jsret = JS_NewStringCopyZ(cx, ret.c_str()); - JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(jsret)); - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); + S_CCUserDefault* self = NULL; JSGET_PTRSHELL(S_CCUserDefault, self, obj); + if (self == NULL) return JS_FALSE; + if (argc == 2) { + JSString *arg0; + JSString *arg1; + JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1); + char *narg0 = JS_EncodeString(cx, arg0); + std::string narg1(JS_EncodeString(cx, arg1)); + std::string ret = self->getStringForKey(narg0, narg1); + JSString *jsret = JS_NewStringCopyZ(cx, ret.c_str()); + JS_SET_RVAL(cx, vp, STRING_TO_JSVAL(jsret)); + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } JSBool S_CCUserDefault::jssetStringForKey(JSContext *cx, uint32_t argc, jsval *vp) { - JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); - S_CCUserDefault* self = NULL; JSGET_PTRSHELL(S_CCUserDefault, self, obj); - if (self == NULL) return JS_FALSE; - if (argc == 2) { - JSString *arg0; - JSString *arg1; - JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1); - char *narg0 = JS_EncodeString(cx, arg0); - std::string narg1(JS_EncodeString(cx, arg1)); - self->setStringForKey(narg0, narg1); - - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; - } - JS_SET_RVAL(cx, vp, JSVAL_TRUE); - return JS_TRUE; + JSObject* obj = (JSObject *)JS_THIS_OBJECT(cx, vp); + S_CCUserDefault* self = NULL; JSGET_PTRSHELL(S_CCUserDefault, self, obj); + if (self == NULL) return JS_FALSE; + if (argc == 2) { + JSString *arg0; + JSString *arg1; + JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1); + char *narg0 = JS_EncodeString(cx, arg0); + std::string narg1(JS_EncodeString(cx, arg1)); + self->setStringForKey(narg0, narg1); + + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; + } + JS_SET_RVAL(cx, vp, JSVAL_TRUE); + return JS_TRUE; } diff --git a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index 071a7526ac..2d1624912e 100644 --- a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -215941887bb3ecde65ca64e6e1b5ddaacded6a7c \ No newline at end of file +5a1155c9dcd8585864efa8080d8fd42059f9ea52 \ No newline at end of file diff --git a/lua/proj.android/jni/Android.mk b/lua/proj.android/jni/Android.mk index 34739f5758..2d249968c6 100644 --- a/lua/proj.android/jni/Android.mk +++ b/lua/proj.android/jni/Android.mk @@ -7,46 +7,46 @@ LOCAL_MODULE_FILENAME := liblua LOCAL_SRC_FILES :=../../lua/lapi.c \ ../../lua/lauxlib.c \ - ../../lua/lbaselib.c \ - ../../lua/lcode.c \ - ../../lua/ldblib.c \ - ../../lua/ldebug.c \ - ../../lua/ldo.c \ - ../../lua/ldump.c \ - ../../lua/lfunc.c \ - ../../lua/lgc.c \ - ../../lua/linit.c \ - ../../lua/liolib.c \ - ../../lua/llex.c \ - ../../lua/lmathlib.c \ - ../../lua/lmem.c \ - ../../lua/loadlib.c \ - ../../lua/lobject.c \ - ../../lua/lopcodes.c \ - ../../lua/loslib.c \ - ../../lua/lparser.c \ - ../../lua/lstate.c \ - ../../lua/lstring.c \ - ../../lua/lstrlib.c \ - ../../lua/ltable.c \ - ../../lua/ltablib.c \ - ../../lua/ltm.c \ - ../../lua/lua.c \ - ../../lua/lundump.c \ - ../../lua/lvm.c \ - ../../lua/lzio.c \ - ../../lua/print.c \ - ../../tolua/tolua_event.c \ - ../../tolua/tolua_is.c \ - ../../tolua/tolua_map.c \ - ../../tolua/tolua_push.c \ - ../../tolua/tolua_to.c - + ../../lua/lbaselib.c \ + ../../lua/lcode.c \ + ../../lua/ldblib.c \ + ../../lua/ldebug.c \ + ../../lua/ldo.c \ + ../../lua/ldump.c \ + ../../lua/lfunc.c \ + ../../lua/lgc.c \ + ../../lua/linit.c \ + ../../lua/liolib.c \ + ../../lua/llex.c \ + ../../lua/lmathlib.c \ + ../../lua/lmem.c \ + ../../lua/loadlib.c \ + ../../lua/lobject.c \ + ../../lua/lopcodes.c \ + ../../lua/loslib.c \ + ../../lua/lparser.c \ + ../../lua/lstate.c \ + ../../lua/lstring.c \ + ../../lua/lstrlib.c \ + ../../lua/ltable.c \ + ../../lua/ltablib.c \ + ../../lua/ltm.c \ + ../../lua/lua.c \ + ../../lua/lundump.c \ + ../../lua/lvm.c \ + ../../lua/lzio.c \ + ../../lua/print.c \ + ../../tolua/tolua_event.c \ + ../../tolua/tolua_is.c \ + ../../tolua/tolua_map.c \ + ../../tolua/tolua_push.c \ + ../../tolua/tolua_to.c + LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../../lua \ $(LOCAL_PATH)/../../tolua \ $(LOCAL_PATH)/../../cocos2dx_support - - + + LOCAL_C_INCLUDES := $(LOCAL_PATH)/ \ $(LOCAL_PATH)/../../lua diff --git a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.cpp b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.cpp index 3c29270c50..2d57ea041f 100644 --- a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.cpp +++ b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.cpp @@ -1,87 +1,87 @@ -#include "cocos2d.h" -#include "CCEGLView.h" -#include "AppDelegate.h" -[! if CC_USE_LUA] -#include "CCLuaEngine.h" -[! else] -#include "HelloWorldScene.h" -[! endif] -[! if CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] -#include "SimpleAudioEngine.h" - -using namespace CocosDenshion; -[! endif] - -USING_NS_CC; - -AppDelegate::AppDelegate() -{ -} - -AppDelegate::~AppDelegate() -{ -[! if CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] - SimpleAudioEngine::end(); -[! endif] -} - -bool AppDelegate::applicationDidFinishLaunching() -{ - // initialize director - CCDirector *pDirector = CCDirector::sharedDirector(); - pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView()); - - // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. -// pDirector->enableRetinaDisplay(true); - - // turn on display FPS - pDirector->setDisplayStats(true); - - // set FPS. the default value is 1.0/60 if you don't call this - pDirector->setAnimationInterval(1.0 / 60); - -[! if CC_USE_LUA] - // register lua engine - CCScriptEngineProtocol* pEngine = CCLuaEngine::engine(); - CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua"); - if (pstrFileContent) - { - pEngine->executeString(pstrFileContent->getCString()); - } -#else - std::string path = CCFileUtils::fullPathFromRelativePath("hello.lua"); - pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str()); - pEngine->executeScriptFile(path.c_str()); -#endif -[! else] - // create a scene. it's an autorelease object - CCScene *pScene = HelloWorld::scene(); - - // run - pDirector->runWithScene(pScene); -[! endif] - return true; -} - -// This function will be called when the app is inactive. When comes a phone call,it's be invoked too -void AppDelegate::applicationDidEnterBackground() -{ - CCDirector::sharedDirector()->pause(); -[! if CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] - - SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); -[! endif] -} - -// this function will be called when the app is active again -void AppDelegate::applicationWillEnterForeground() -{ - CCDirector::sharedDirector()->resume(); -[! if CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] - - SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); -[! endif] -} +#include "cocos2d.h" +#include "CCEGLView.h" +#include "AppDelegate.h" +[! if CC_USE_LUA] +#include "CCLuaEngine.h" +[! else] +#include "HelloWorldScene.h" +[! endif] +[! if CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] +#include "SimpleAudioEngine.h" + +using namespace CocosDenshion; +[! endif] + +USING_NS_CC; + +AppDelegate::AppDelegate() +{ +} + +AppDelegate::~AppDelegate() +{ +[! if CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] + SimpleAudioEngine::end(); +[! endif] +} + +bool AppDelegate::applicationDidFinishLaunching() +{ + // initialize director + CCDirector *pDirector = CCDirector::sharedDirector(); + pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView()); + + // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. +// pDirector->enableRetinaDisplay(true); + + // turn on display FPS + pDirector->setDisplayStats(true); + + // set FPS. the default value is 1.0/60 if you don't call this + pDirector->setAnimationInterval(1.0 / 60); + +[! if CC_USE_LUA] + // register lua engine + CCScriptEngineProtocol* pEngine = CCLuaEngine::engine(); + CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua"); + if (pstrFileContent) + { + pEngine->executeString(pstrFileContent->getCString()); + } +#else + std::string path = CCFileUtils::fullPathFromRelativePath("hello.lua"); + pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str()); + pEngine->executeScriptFile(path.c_str()); +#endif +[! else] + // create a scene. it's an autorelease object + CCScene *pScene = HelloWorld::scene(); + + // run + pDirector->runWithScene(pScene); +[! endif] + return true; +} + +// This function will be called when the app is inactive. When comes a phone call,it's be invoked too +void AppDelegate::applicationDidEnterBackground() +{ + CCDirector::sharedDirector()->pause(); +[! if CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] + + SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); +[! endif] +} + +// this function will be called when the app is active again +void AppDelegate::applicationWillEnterForeground() +{ + CCDirector::sharedDirector()->resume(); +[! if CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] + + SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); +[! endif] +} diff --git a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.h b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.h index f2d35bace9..65dfe75bfe 100644 --- a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.h +++ b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.h @@ -1,38 +1,38 @@ -#ifndef __APP_DELEGATE_H__ -#define __APP_DELEGATE_H__ - -#include "CCApplication.h" - -/** -@brief The cocos2d Application. - -The reason for implement as private inheritance is to hide some interface call by CCDirector. -*/ -class AppDelegate : private cocos2d::CCApplication -{ -public: - AppDelegate(); - virtual ~AppDelegate(); - - /** - @brief Implement CCDirector and CCScene init code here. - @return true Initialize success, app continue. - @return false Initialize failed, app terminate. - */ - virtual bool applicationDidFinishLaunching(); - - /** - @brief The function be called when the application enter background - @param the pointer of the application - */ - virtual void applicationDidEnterBackground(); - - /** - @brief The function be called when the application enter foreground - @param the pointer of the application - */ - virtual void applicationWillEnterForeground(); -}; - -#endif // __APP_DELEGATE_H__ - +#ifndef __APP_DELEGATE_H__ +#define __APP_DELEGATE_H__ + +#include "CCApplication.h" + +/** +@brief The cocos2d Application. + +The reason for implement as private inheritance is to hide some interface call by CCDirector. +*/ +class AppDelegate : private cocos2d::CCApplication +{ +public: + AppDelegate(); + virtual ~AppDelegate(); + + /** + @brief Implement CCDirector and CCScene init code here. + @return true Initialize success, app continue. + @return false Initialize failed, app terminate. + */ + virtual bool applicationDidFinishLaunching(); + + /** + @brief The function be called when the application enter background + @param the pointer of the application + */ + virtual void applicationDidEnterBackground(); + + /** + @brief The function be called when the application enter foreground + @param the pointer of the application + */ + virtual void applicationWillEnterForeground(); +}; + +#endif // __APP_DELEGATE_H__ + diff --git a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.cpp b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.cpp index f789b7bb1a..e85e95e66a 100644 --- a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.cpp +++ b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.cpp @@ -1,97 +1,97 @@ -#include "HelloWorldScene.h" - -using namespace cocos2d; - -CCScene* HelloWorld::scene() -{ - CCScene * scene = NULL; - do - { - // 'scene' is an autorelease object - scene = CCScene::node(); - CC_BREAK_IF(! scene); - - // 'layer' is an autorelease object - HelloWorld *layer = HelloWorld::node(); - CC_BREAK_IF(! layer); - - // add layer as a child to scene - scene->addChild(layer); - } while (0); - - // return the scene - return scene; -} - -// on "init" you need to initialize your instance -bool HelloWorld::init() -{ - bool bRet = false; - do - { - ////////////////////////////////////////////////////////////////////////// - // super init first - ////////////////////////////////////////////////////////////////////////// - - CC_BREAK_IF(! CCLayer::init()); - - ////////////////////////////////////////////////////////////////////////// - // add your codes below... - ////////////////////////////////////////////////////////////////////////// - - // 1. Add a menu item with "X" image, which is clicked to quit the program. - - // Create a "close" menu item with close icon, it's an auto release object. - CCMenuItemImage *pCloseItem = CCMenuItemImage::itemWithNormalImage( - "CloseNormal.png", - "CloseSelected.png", - this, - menu_selector(HelloWorld::menuCloseCallback)); - CC_BREAK_IF(! pCloseItem); - - // Place the menu item bottom-right conner. - pCloseItem->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20)); - - // Create a menu with the "close" menu item, it's an auto release object. - CCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, NULL); - pMenu->setPosition(CCPointZero); - CC_BREAK_IF(! pMenu); - - // Add the menu to HelloWorld layer as a child layer. - this->addChild(pMenu, 1); - - // 2. Add a label shows "Hello World". - - // Create a label and initialize with string "Hello World". - CCLabelTTF* pLabel = CCLabelTTF::labelWithString("Hello World", "Arial", 24); - CC_BREAK_IF(! pLabel); - - // Get window size and place the label upper. - CCSize size = CCDirector::sharedDirector()->getWinSize(); - pLabel->setPosition(ccp(size.width / 2, size.height - 50)); - - // Add the label to HelloWorld layer as a child layer. - this->addChild(pLabel, 1); - - // 3. Add add a splash screen, show the cocos2d splash image. - CCSprite* pSprite = CCSprite::spriteWithFile("HelloWorld.png"); - CC_BREAK_IF(! pSprite); - - // Place the sprite on the center of the screen - pSprite->setPosition(ccp(size.width/2, size.height/2)); - - // Add the sprite to HelloWorld layer as a child layer. - this->addChild(pSprite, 0); - - bRet = true; - } while (0); - - return bRet; -} - -void HelloWorld::menuCloseCallback(CCObject* pSender) -{ - // "close" menu item clicked - CCDirector::sharedDirector()->end(); -} - +#include "HelloWorldScene.h" + +using namespace cocos2d; + +CCScene* HelloWorld::scene() +{ + CCScene * scene = NULL; + do + { + // 'scene' is an autorelease object + scene = CCScene::node(); + CC_BREAK_IF(! scene); + + // 'layer' is an autorelease object + HelloWorld *layer = HelloWorld::node(); + CC_BREAK_IF(! layer); + + // add layer as a child to scene + scene->addChild(layer); + } while (0); + + // return the scene + return scene; +} + +// on "init" you need to initialize your instance +bool HelloWorld::init() +{ + bool bRet = false; + do + { + ////////////////////////////////////////////////////////////////////////// + // super init first + ////////////////////////////////////////////////////////////////////////// + + CC_BREAK_IF(! CCLayer::init()); + + ////////////////////////////////////////////////////////////////////////// + // add your codes below... + ////////////////////////////////////////////////////////////////////////// + + // 1. Add a menu item with "X" image, which is clicked to quit the program. + + // Create a "close" menu item with close icon, it's an auto release object. + CCMenuItemImage *pCloseItem = CCMenuItemImage::itemWithNormalImage( + "CloseNormal.png", + "CloseSelected.png", + this, + menu_selector(HelloWorld::menuCloseCallback)); + CC_BREAK_IF(! pCloseItem); + + // Place the menu item bottom-right conner. + pCloseItem->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20)); + + // Create a menu with the "close" menu item, it's an auto release object. + CCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, NULL); + pMenu->setPosition(CCPointZero); + CC_BREAK_IF(! pMenu); + + // Add the menu to HelloWorld layer as a child layer. + this->addChild(pMenu, 1); + + // 2. Add a label shows "Hello World". + + // Create a label and initialize with string "Hello World". + CCLabelTTF* pLabel = CCLabelTTF::labelWithString("Hello World", "Arial", 24); + CC_BREAK_IF(! pLabel); + + // Get window size and place the label upper. + CCSize size = CCDirector::sharedDirector()->getWinSize(); + pLabel->setPosition(ccp(size.width / 2, size.height - 50)); + + // Add the label to HelloWorld layer as a child layer. + this->addChild(pLabel, 1); + + // 3. Add add a splash screen, show the cocos2d splash image. + CCSprite* pSprite = CCSprite::spriteWithFile("HelloWorld.png"); + CC_BREAK_IF(! pSprite); + + // Place the sprite on the center of the screen + pSprite->setPosition(ccp(size.width/2, size.height/2)); + + // Add the sprite to HelloWorld layer as a child layer. + this->addChild(pSprite, 0); + + bRet = true; + } while (0); + + return bRet; +} + +void HelloWorld::menuCloseCallback(CCObject* pSender) +{ + // "close" menu item clicked + CCDirector::sharedDirector()->end(); +} + diff --git a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.h b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.h index 0f45161148..aebea7b637 100644 --- a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.h +++ b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.h @@ -1,34 +1,34 @@ -#ifndef __HELLOWORLD_SCENE_H__ -#define __HELLOWORLD_SCENE_H__ - -#include "cocos2d.h" -[! if CC_USE_BOX2D] - -#include "Box2D/Box2D.h" -[! endif] -[! if CC_USE_CHIPMUNK] - -#include "chipmunk.h" -[! endif] -[! if CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] - -#include "SimpleAudioEngine.h" -[! endif] - -class HelloWorld : public cocos2d::CCLayer -{ -public: - // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone - virtual bool init(); - - // there's no 'id' in cpp, so we recommand to return the exactly class pointer - static cocos2d::CCScene* scene(); - - // a selector callback - virtual void menuCloseCallback(CCObject* pSender); - - // implement the "static node()" method manually - LAYER_NODE_FUNC(HelloWorld); -}; - +#ifndef __HELLOWORLD_SCENE_H__ +#define __HELLOWORLD_SCENE_H__ + +#include "cocos2d.h" +[! if CC_USE_BOX2D] + +#include "Box2D/Box2D.h" +[! endif] +[! if CC_USE_CHIPMUNK] + +#include "chipmunk.h" +[! endif] +[! if CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] + +#include "SimpleAudioEngine.h" +[! endif] + +class HelloWorld : public cocos2d::CCLayer +{ +public: + // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone + virtual bool init(); + + // there's no 'id' in cpp, so we recommand to return the exactly class pointer + static cocos2d::CCScene* scene(); + + // a selector callback + virtual void menuCloseCallback(CCObject* pSender); + + // implement the "static node()" method manually + LAYER_NODE_FUNC(HelloWorld); +}; + #endif // __HELLOWORLD_SCENE_H__ \ No newline at end of file diff --git a/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/main.cpp b/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/main.cpp index 9f97c90f99..f284ee7201 100644 --- a/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/main.cpp +++ b/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/main.cpp @@ -1,40 +1,40 @@ -#include "main.h" -#include "AppDelegate.h" -#include "CCEGLView.h" - -USING_NS_CC; - -// uncomment below line, open debug console -// #define USE_WIN32_CONSOLE - -int APIENTRY _tWinMain(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPTSTR lpCmdLine, - int nCmdShow) -{ - UNREFERENCED_PARAMETER(hPrevInstance); - UNREFERENCED_PARAMETER(lpCmdLine); - -#ifdef USE_WIN32_CONSOLE - AllocConsole(); - freopen("CONIN$", "r", stdin); - freopen("CONOUT$", "w", stdout); - freopen("CONOUT$", "w", stderr); -#endif - - // create the application instance - AppDelegate app; - CCEGLView& eglView = CCEGLView::sharedOpenGLView(); - eglView.setViewName("Hello World"); - eglView.setFrameSize(480, 320); - // set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line. - // eglView.setDesignResolutionSize(480, 320); - - int ret = CCApplication::sharedApplication().run(); - -#ifdef USE_WIN32_CONSOLE - FreeConsole(); -#endif - - return ret; -} +#include "main.h" +#include "AppDelegate.h" +#include "CCEGLView.h" + +USING_NS_CC; + +// uncomment below line, open debug console +// #define USE_WIN32_CONSOLE + +int APIENTRY _tWinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPTSTR lpCmdLine, + int nCmdShow) +{ + UNREFERENCED_PARAMETER(hPrevInstance); + UNREFERENCED_PARAMETER(lpCmdLine); + +#ifdef USE_WIN32_CONSOLE + AllocConsole(); + freopen("CONIN$", "r", stdin); + freopen("CONOUT$", "w", stdout); + freopen("CONOUT$", "w", stderr); +#endif + + // create the application instance + AppDelegate app; + CCEGLView& eglView = CCEGLView::sharedOpenGLView(); + eglView.setViewName("Hello World"); + eglView.setFrameSize(480, 320); + // set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line. + // eglView.setDesignResolutionSize(480, 320); + + int ret = CCApplication::sharedApplication().run(); + +#ifdef USE_WIN32_CONSOLE + FreeConsole(); +#endif + + return ret; +} diff --git a/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/main.h b/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/main.h index 45b862cc00..abe1c3a007 100644 --- a/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/main.h +++ b/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/main.h @@ -1,13 +1,13 @@ -#ifndef __MAIN_H__ -#define __MAIN_H__ - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - -// Windows Header Files: -#include -#include - -// C RunTime Header Files -#include "CCStdC.h" - -#endif // __WINMAIN_H__ +#ifndef __MAIN_H__ +#define __MAIN_H__ + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +// Windows Header Files: +#include +#include + +// C RunTime Header Files +#include "CCStdC.h" + +#endif // __WINMAIN_H__ diff --git a/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/resource.h b/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/resource.h index 4132eda4e2..58684d7c8a 100644 --- a/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/resource.h +++ b/template/msvc/CCAppWiz.win32/Templates/1033/proj.win32/resource.h @@ -1,22 +1,22 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by [!output PROJECT_NAME].RC -// - -[!if WTL_COM_SERVER] -#define IDS_PROJNAME 100 -#define IDR_[!output UPPERCASE_SAFE_PROJECT_NAME] 100 -[!endif] - -#define ID_FILE_NEW_WINDOW 32771 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 201 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 32775 -#endif -#endif +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by [!output PROJECT_NAME].RC +// + +[!if WTL_COM_SERVER] +#define IDS_PROJNAME 100 +#define IDR_[!output UPPERCASE_SAFE_PROJECT_NAME] 100 +[!endif] + +#define ID_FILE_NEW_WINDOW 32771 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 201 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 32775 +#endif +#endif diff --git a/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp index 7649a5ff8e..fa0a03eff9 100644 --- a/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp +++ b/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp @@ -42,12 +42,12 @@ bool AppDelegate::applicationDidFinishLaunching() CCScriptEngineProtocol* pEngine = CCLuaEngine::engine(); CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua"); - if (pstrFileContent) - { - pEngine->executeString(pstrFileContent->getCString()); - } +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua"); + if (pstrFileContent) + { + pEngine->executeString(pstrFileContent->getCString()); + } #else string path = CCFileUtils::fullPathFromRelativePath("hello.lua"); pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str()); diff --git a/testjs/Classes/AppDelegate.cpp b/testjs/Classes/AppDelegate.cpp index c7be9078bf..38dc2e91c1 100644 --- a/testjs/Classes/AppDelegate.cpp +++ b/testjs/Classes/AppDelegate.cpp @@ -1,85 +1,85 @@ -// -// testjsAppDelegate.cpp -// testjs -// -// Created by Rolando Abarca on 3/19/12. -// Copyright __MyCompanyName__ 2012. All rights reserved. -// - -#include "AppDelegate.h" - -#include "cocos2d.h" -#include "simple_native_generated.hpp" - -USING_NS_CC; - -AppDelegate::AppDelegate() -{ - -} - -AppDelegate::~AppDelegate() -{ - -} - -bool AppDelegate::applicationDidFinishLaunching() -{ - // initialize director - CCDirector *pDirector = CCDirector::sharedDirector(); - pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView()); - - // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. - // pDirector->enableRetinaDisplay(true); - - // sets landscape mode - // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); - - // turn on display FPS - pDirector->setDisplayStats(true); - - // set FPS. the default value is 1.0/60 if you don't call this - pDirector->setAnimationInterval(1.0 / 60); - - // add our generated bindings - /* - JSContext *cx = ScriptingCore::getInstance().getGlobalContext(); - JSObject *obj = JS_GetGlobalObject(cx); - // since we pass the global object as the second argument, so these classes - // will also be "global" much like properties added to "window" or "document" - // in a browser - S_SimpleNativeClass::jsCreateClass(cx, obj, "SimpleNativeClass"); - S_AnotherClass::jsCreateClass(cx, obj, "AnotherClass"); - register_enums_simple_native_generated(obj); - ScriptingCore::getInstance().runScript("Javascript/1to1/test_bindings.js"); - */ - - // run the main script - ScriptingCore::getInstance().runScript("JS/1to1/test_actions.js"); -// ScriptingCore::getInstance().runScript("JS/1to1/test_ease_actions.js"); -// ScriptingCore::getInstance().runScript("JS/1to1/test_particles.js"); -// ScriptingCore::getInstance().runScript("JS/1to1/test_layer.js"); -// ScriptingCore::getInstance().runScript("JS/1to1/test_sound.js"); -// ScriptingCore::getInstance().runScript("JS/1to1/test_transitions.js"); -// ScriptingCore::getInstance().runScript("JS/1to1/test_require.js"); - - return true; -} - -// This function will be called when the app is inactive. When comes a phone call,it's be invoked too -void AppDelegate::applicationDidEnterBackground() -{ - CCDirector::sharedDirector()->pause(); - - // if you use SimpleAudioEngine, it must be pause - // SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); -} - -// this function will be called when the app is active again -void AppDelegate::applicationWillEnterForeground() -{ - CCDirector::sharedDirector()->resume(); - - // if you use SimpleAudioEngine, it must resume here - // SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); -} +// +// testjsAppDelegate.cpp +// testjs +// +// Created by Rolando Abarca on 3/19/12. +// Copyright __MyCompanyName__ 2012. All rights reserved. +// + +#include "AppDelegate.h" + +#include "cocos2d.h" +#include "simple_native_generated.hpp" + +USING_NS_CC; + +AppDelegate::AppDelegate() +{ + +} + +AppDelegate::~AppDelegate() +{ + +} + +bool AppDelegate::applicationDidFinishLaunching() +{ + // initialize director + CCDirector *pDirector = CCDirector::sharedDirector(); + pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView()); + + // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. + // pDirector->enableRetinaDisplay(true); + + // sets landscape mode + // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); + + // turn on display FPS + pDirector->setDisplayStats(true); + + // set FPS. the default value is 1.0/60 if you don't call this + pDirector->setAnimationInterval(1.0 / 60); + + // add our generated bindings + /* + JSContext *cx = ScriptingCore::getInstance().getGlobalContext(); + JSObject *obj = JS_GetGlobalObject(cx); + // since we pass the global object as the second argument, so these classes + // will also be "global" much like properties added to "window" or "document" + // in a browser + S_SimpleNativeClass::jsCreateClass(cx, obj, "SimpleNativeClass"); + S_AnotherClass::jsCreateClass(cx, obj, "AnotherClass"); + register_enums_simple_native_generated(obj); + ScriptingCore::getInstance().runScript("Javascript/1to1/test_bindings.js"); + */ + + // run the main script + ScriptingCore::getInstance().runScript("JS/1to1/test_actions.js"); +// ScriptingCore::getInstance().runScript("JS/1to1/test_ease_actions.js"); +// ScriptingCore::getInstance().runScript("JS/1to1/test_particles.js"); +// ScriptingCore::getInstance().runScript("JS/1to1/test_layer.js"); +// ScriptingCore::getInstance().runScript("JS/1to1/test_sound.js"); +// ScriptingCore::getInstance().runScript("JS/1to1/test_transitions.js"); +// ScriptingCore::getInstance().runScript("JS/1to1/test_require.js"); + + return true; +} + +// This function will be called when the app is inactive. When comes a phone call,it's be invoked too +void AppDelegate::applicationDidEnterBackground() +{ + CCDirector::sharedDirector()->pause(); + + // if you use SimpleAudioEngine, it must be pause + // SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); +} + +// this function will be called when the app is active again +void AppDelegate::applicationWillEnterForeground() +{ + CCDirector::sharedDirector()->resume(); + + // if you use SimpleAudioEngine, it must resume here + // SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); +} diff --git a/testjs/Classes/AppDelegate.h b/testjs/Classes/AppDelegate.h index 2f481f8165..e6047ffe91 100644 --- a/testjs/Classes/AppDelegate.h +++ b/testjs/Classes/AppDelegate.h @@ -1,47 +1,47 @@ -// -// testjsAppDelegate.h -// testjs -// -// Created by Rolando Abarca on 3/19/12. -// Copyright __MyCompanyName__ 2012. All rights reserved. -// - -#ifndef _APP_DELEGATE_H_ -#define _APP_DELEGATE_H_ - -#include "CCApplication.h" -#include "ScriptingCore.h" - -/** -@brief The cocos2d Application. - -The reason for implement as private inheritance is to hide some interface call by CCDirector. -*/ -class AppDelegate : private cocos2d::CCApplication -{ -public: - AppDelegate(); - virtual ~AppDelegate(); - - /** - @brief Implement CCDirector and CCScene init code here. - @return true Initialize success, app continue. - @return false Initialize failed, app terminate. - */ - virtual bool applicationDidFinishLaunching(); - - /** - @brief The function be called when the application enter background - @param the pointer of the application - */ - virtual void applicationDidEnterBackground(); - - /** - @brief The function be called when the application enter foreground - @param the pointer of the application - */ - virtual void applicationWillEnterForeground(); -}; - -#endif // _APP_DELEGATE_H_ - +// +// testjsAppDelegate.h +// testjs +// +// Created by Rolando Abarca on 3/19/12. +// Copyright __MyCompanyName__ 2012. All rights reserved. +// + +#ifndef _APP_DELEGATE_H_ +#define _APP_DELEGATE_H_ + +#include "CCApplication.h" +#include "ScriptingCore.h" + +/** +@brief The cocos2d Application. + +The reason for implement as private inheritance is to hide some interface call by CCDirector. +*/ +class AppDelegate : private cocos2d::CCApplication +{ +public: + AppDelegate(); + virtual ~AppDelegate(); + + /** + @brief Implement CCDirector and CCScene init code here. + @return true Initialize success, app continue. + @return false Initialize failed, app terminate. + */ + virtual bool applicationDidFinishLaunching(); + + /** + @brief The function be called when the application enter background + @param the pointer of the application + */ + virtual void applicationDidEnterBackground(); + + /** + @brief The function be called when the application enter foreground + @param the pointer of the application + */ + virtual void applicationWillEnterForeground(); +}; + +#endif // _APP_DELEGATE_H_ + diff --git a/testjs/Classes/simple_class.cpp b/testjs/Classes/simple_class.cpp index 3bf0f1c9ef..e4308bd910 100644 --- a/testjs/Classes/simple_class.cpp +++ b/testjs/Classes/simple_class.cpp @@ -7,10 +7,10 @@ SimpleNativeClass::SimpleNativeClass() { - // just set some fields - m_someField = 0; - m_someOtherField = 10; - m_anotherMoreComplexField = NULL; + // just set some fields + m_someField = 0; + m_someOtherField = 10; + m_anotherMoreComplexField = NULL; } // empty destructor @@ -21,25 +21,25 @@ SimpleNativeClass::~SimpleNativeClass() // just a very simple function :) int SimpleNativeClass::doSomeProcessing(std::string arg1, std::string arg2) { - return arg1.length() + arg2.length(); + return arg1.length() + arg2.length(); } void SimpleNativeClass::setAnotherMoreComplexField(const char *str) { - if (m_anotherMoreComplexField) { - free(m_anotherMoreComplexField); - } - size_t len = strlen(str); - m_anotherMoreComplexField = (char *)malloc(len); - memcpy(m_anotherMoreComplexField, str, len); + if (m_anotherMoreComplexField) { + free(m_anotherMoreComplexField); + } + size_t len = strlen(str); + m_anotherMoreComplexField = (char *)malloc(len); + memcpy(m_anotherMoreComplexField, str, len); } namespace SomeNamespace { AnotherClass::AnotherClass() { - justOneField = 1313; - aPublicField = 1337; + justOneField = 1313; + aPublicField = 1337; } // empty destructor AnotherClass::~AnotherClass() @@ -47,6 +47,6 @@ AnotherClass::~AnotherClass() } void AnotherClass::doSomethingSimple() { - fprintf(stderr, "just doing something simple\n"); + fprintf(stderr, "just doing something simple\n"); } }; diff --git a/testjs/Classes/simple_class.h b/testjs/Classes/simple_class.h index 62214ac9f4..8f33b5ad7e 100644 --- a/testjs/Classes/simple_class.h +++ b/testjs/Classes/simple_class.h @@ -6,57 +6,57 @@ class SimpleNativeClass { protected: - int m_someField; - int m_someOtherField; - char* m_anotherMoreComplexField; + int m_someField; + int m_someOtherField; + char* m_anotherMoreComplexField; public: - SimpleNativeClass(); - ~SimpleNativeClass(); + SimpleNativeClass(); + ~SimpleNativeClass(); - // these methods are simple, can be defined inline - int getSomeField() { - return m_someField; - }; - int getSomeOtherField() { - return m_someOtherField; - }; - char *getAnotherMoreComplexField() { - return m_anotherMoreComplexField; - } - void setSomeField(int f) { - m_someField = f; - } - void setSomeOtherField(int f) { - m_someOtherField = f; - } - void setAnotherMoreComplexField(const char *str); + // these methods are simple, can be defined inline + int getSomeField() { + return m_someField; + }; + int getSomeOtherField() { + return m_someOtherField; + }; + char *getAnotherMoreComplexField() { + return m_anotherMoreComplexField; + } + void setSomeField(int f) { + m_someField = f; + } + void setSomeOtherField(int f) { + m_someOtherField = f; + } + void setAnotherMoreComplexField(const char *str); - // std::string not working yet! - int doSomeProcessing(std::string arg1, std::string arg2); + // std::string not working yet! + int doSomeProcessing(std::string arg1, std::string arg2); }; namespace SomeNamespace { class AnotherClass { protected: - int justOneField; + int justOneField; public: - int aPublicField; + int aPublicField; - AnotherClass(); - ~AnotherClass(); + AnotherClass(); + ~AnotherClass(); - // also simple methods, can be defined inline - int getJustOneField() { - return justOneField; - } - // wrong setter - won't work (needs ONLY one parameter in order to work) - void setJustOneField() { - justOneField = 999; - } + // also simple methods, can be defined inline + int getJustOneField() { + return justOneField; + } + // wrong setter - won't work (needs ONLY one parameter in order to work) + void setJustOneField() { + justOneField = 999; + } - void doSomethingSimple(); + void doSomethingSimple(); }; }; diff --git a/testjs/proj.android/jni/Android.mk b/testjs/proj.android/jni/Android.mk index d9cdbb6303..8c5afa3441 100644 --- a/testjs/proj.android/jni/Android.mk +++ b/testjs/proj.android/jni/Android.mk @@ -1,29 +1,29 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := test_js_shared - -LOCAL_MODULE_FILENAME := libtestjs - -LOCAL_SRC_FILES := helloworld/main.cpp \ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := test_js_shared + +LOCAL_MODULE_FILENAME := libtestjs + +LOCAL_SRC_FILES := helloworld/main.cpp \ ../../Classes/AppDelegate.cpp \ ../../Classes/simple_class.cpp \ ../../Classes/simple_native_generated.cpp \ ../../../js/JSBindings/cocos_denshion_generated.cpp \ ../../../js/JSBindings/cocos2d_generated.cpp \ ../../../js/JSBindings/cocos2d_manual_bindings.cpp \ - ../../../js/JSBindings/ScriptingCore.cpp - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes - + ../../../js/JSBindings/ScriptingCore.cpp + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes + LOCAL_WHOLE_STATIC_LIBRARIES := cocos2dx_static LOCAL_WHOLE_STATIC_LIBRARIES += cocos_spidermonkey_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static - -include $(BUILD_SHARED_LIBRARY) - +LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static + +include $(BUILD_SHARED_LIBRARY) + $(call import-module,cocos2dx) $(call import-module,CocosDenshion/android) -$(call import-module,spidermonkey-android) - +$(call import-module,spidermonkey-android) + diff --git a/testjs/proj.android/jni/Application.mk b/testjs/proj.android/jni/Application.mk index 0ba4ae3a9c..22d424dab7 100644 --- a/testjs/proj.android/jni/Application.mk +++ b/testjs/proj.android/jni/Application.mk @@ -1,2 +1,2 @@ -APP_STL := gnustl_static +APP_STL := gnustl_static APP_CPPFLAGS := -frtti \ No newline at end of file diff --git a/testjs/proj.ios/AppController.h b/testjs/proj.ios/AppController.h index e301334d85..10287bd13f 100644 --- a/testjs/proj.ios/AppController.h +++ b/testjs/proj.ios/AppController.h @@ -10,7 +10,7 @@ @interface AppController : NSObject { UIWindow *window; - RootViewController *viewController; + RootViewController *viewController; } @end diff --git a/testjs/proj.ios/AppController.mm b/testjs/proj.ios/AppController.mm index 0f397bf831..187e55ed48 100644 --- a/testjs/proj.ios/AppController.mm +++ b/testjs/proj.ios/AppController.mm @@ -56,14 +56,14 @@ static AppDelegate s_sharedApplication; Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. */ - cocos2d::CCDirector::sharedDirector()->pause(); + cocos2d::CCDirector::sharedDirector()->pause(); } - (void)applicationDidBecomeActive:(UIApplication *)application { /* Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. */ - cocos2d::CCDirector::sharedDirector()->resume(); + cocos2d::CCDirector::sharedDirector()->resume(); } - (void)applicationDidEnterBackground:(UIApplication *)application { diff --git a/testjs/proj.ios/RootViewController.mm b/testjs/proj.ios/RootViewController.mm index 2bfb6f241c..9dda5a1846 100644 --- a/testjs/proj.ios/RootViewController.mm +++ b/testjs/proj.ios/RootViewController.mm @@ -36,10 +36,10 @@ */ // Override to allow orientations other than the default landscape orientation. - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { - return UIInterfaceOrientationIsLandscape( interfaceOrientation ); + return UIInterfaceOrientationIsLandscape( interfaceOrientation ); // switch to this line if you want to set portrait view -// return UIInterfaceOrientationIsPortrait( interfaceOrientation ); +// return UIInterfaceOrientationIsPortrait( interfaceOrientation ); } - (void)didReceiveMemoryWarning { diff --git a/testjs/proj.win32/main.cpp b/testjs/proj.win32/main.cpp index 9f97c90f99..f284ee7201 100644 --- a/testjs/proj.win32/main.cpp +++ b/testjs/proj.win32/main.cpp @@ -1,40 +1,40 @@ -#include "main.h" -#include "AppDelegate.h" -#include "CCEGLView.h" - -USING_NS_CC; - -// uncomment below line, open debug console -// #define USE_WIN32_CONSOLE - -int APIENTRY _tWinMain(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPTSTR lpCmdLine, - int nCmdShow) -{ - UNREFERENCED_PARAMETER(hPrevInstance); - UNREFERENCED_PARAMETER(lpCmdLine); - -#ifdef USE_WIN32_CONSOLE - AllocConsole(); - freopen("CONIN$", "r", stdin); - freopen("CONOUT$", "w", stdout); - freopen("CONOUT$", "w", stderr); -#endif - - // create the application instance - AppDelegate app; - CCEGLView& eglView = CCEGLView::sharedOpenGLView(); - eglView.setViewName("Hello World"); - eglView.setFrameSize(480, 320); - // set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line. - // eglView.setDesignResolutionSize(480, 320); - - int ret = CCApplication::sharedApplication().run(); - -#ifdef USE_WIN32_CONSOLE - FreeConsole(); -#endif - - return ret; -} +#include "main.h" +#include "AppDelegate.h" +#include "CCEGLView.h" + +USING_NS_CC; + +// uncomment below line, open debug console +// #define USE_WIN32_CONSOLE + +int APIENTRY _tWinMain(HINSTANCE hInstance, + HINSTANCE hPrevInstance, + LPTSTR lpCmdLine, + int nCmdShow) +{ + UNREFERENCED_PARAMETER(hPrevInstance); + UNREFERENCED_PARAMETER(lpCmdLine); + +#ifdef USE_WIN32_CONSOLE + AllocConsole(); + freopen("CONIN$", "r", stdin); + freopen("CONOUT$", "w", stdout); + freopen("CONOUT$", "w", stderr); +#endif + + // create the application instance + AppDelegate app; + CCEGLView& eglView = CCEGLView::sharedOpenGLView(); + eglView.setViewName("Hello World"); + eglView.setFrameSize(480, 320); + // set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line. + // eglView.setDesignResolutionSize(480, 320); + + int ret = CCApplication::sharedApplication().run(); + +#ifdef USE_WIN32_CONSOLE + FreeConsole(); +#endif + + return ret; +} diff --git a/testjs/proj.win32/main.h b/testjs/proj.win32/main.h index 45b862cc00..abe1c3a007 100644 --- a/testjs/proj.win32/main.h +++ b/testjs/proj.win32/main.h @@ -1,13 +1,13 @@ -#ifndef __MAIN_H__ -#define __MAIN_H__ - -#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers - -// Windows Header Files: -#include -#include - -// C RunTime Header Files -#include "CCStdC.h" - -#endif // __WINMAIN_H__ +#ifndef __MAIN_H__ +#define __MAIN_H__ + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers + +// Windows Header Files: +#include +#include + +// C RunTime Header Files +#include "CCStdC.h" + +#endif // __WINMAIN_H__ diff --git a/testjs/proj.win32/resource.h b/testjs/proj.win32/resource.h index 04067c8f95..a4cfa38af8 100644 --- a/testjs/proj.win32/resource.h +++ b/testjs/proj.win32/resource.h @@ -1,20 +1,20 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by testjs.RC -// - -#define IDS_PROJNAME 100 -#define IDR_TESTJS 100 - -#define ID_FILE_NEW_WINDOW 32771 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 201 -#define _APS_NEXT_CONTROL_VALUE 1000 -#define _APS_NEXT_SYMED_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 32775 -#endif -#endif +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by testjs.RC +// + +#define IDS_PROJNAME 100 +#define IDR_TESTJS 100 + +#define ID_FILE_NEW_WINDOW 32771 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 201 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 32775 +#endif +#endif diff --git a/tests/proj.android/jni/Android.mk b/tests/proj.android/jni/Android.mk index af5fbb2e97..ee1baa0f98 100644 --- a/tests/proj.android/jni/Android.mk +++ b/tests/proj.android/jni/Android.mk @@ -1,26 +1,26 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := cocos_tests_android - -LOCAL_MODULE_FILENAME := libtests - -LOCAL_SRC_FILES := tests/main.cpp - -LOCAL_STATIC_LIBRARIES := curl_static_prebuilt - -LOCAL_WHOLE_STATIC_LIBRARIES := cocos_tests_common -LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static -LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static -LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static -LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,tests) -$(call import-module,cocos2dx) -$(call import-module,cocos2dx/platform/third_party/android/prebuilt/libcurl) -$(call import-module,CocosDenshion/android) -$(call import-module,Box2D) -$(call import-module,chipmunk) +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := cocos_tests_android + +LOCAL_MODULE_FILENAME := libtests + +LOCAL_SRC_FILES := tests/main.cpp + +LOCAL_STATIC_LIBRARIES := curl_static_prebuilt + +LOCAL_WHOLE_STATIC_LIBRARIES := cocos_tests_common +LOCAL_WHOLE_STATIC_LIBRARIES += cocos2dx_static +LOCAL_WHOLE_STATIC_LIBRARIES += cocosdenshion_static +LOCAL_WHOLE_STATIC_LIBRARIES += box2d_static +LOCAL_WHOLE_STATIC_LIBRARIES += chipmunk_static + +include $(BUILD_SHARED_LIBRARY) + +$(call import-module,tests) +$(call import-module,cocos2dx) +$(call import-module,cocos2dx/platform/third_party/android/prebuilt/libcurl) +$(call import-module,CocosDenshion/android) +$(call import-module,Box2D) +$(call import-module,chipmunk) diff --git a/tests/proj.android/jni/Application.mk b/tests/proj.android/jni/Application.mk index 8787d5227b..cf42fcc70e 100644 --- a/tests/proj.android/jni/Application.mk +++ b/tests/proj.android/jni/Application.mk @@ -1,2 +1,2 @@ -APP_STL := gnustl_static -APP_CPPFLAGS := -frtti +APP_STL := gnustl_static +APP_CPPFLAGS := -frtti diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp index 2e7bab8b24..0469bbbb03 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp @@ -36,7 +36,7 @@ void CocosBuilderTestScene::runThisTest() HelloCocosBuilder::createInstance); CCNode* node = CCBReader::nodeGraphFromFile("CocosBuilder_v2/example_relativeposition.ccb"); - this->addChild(node) ; + this->addChild(node) ; CCDirector::sharedDirector()->replaceScene(this); } diff --git a/tools/lua_project_generator/template/android/jni/Android.mk b/tools/lua_project_generator/template/android/jni/Android.mk index 8df30f893b..910cd6be86 100644 --- a/tools/lua_project_generator/template/android/jni/Android.mk +++ b/tools/lua_project_generator/template/android/jni/Android.mk @@ -1,11 +1,11 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) - -subdirs := $(addprefix $(LOCAL_PATH)/../../../,$(addsuffix /Android.mk, \ - cocos2dx \ - CocosDenshion/android \ - lua/proj.android/jni \ - )) -subdirs += $(LOCAL_PATH)/LuaProjectTemplate/Android.mk - -include $(subdirs) +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) + +subdirs := $(addprefix $(LOCAL_PATH)/../../../,$(addsuffix /Android.mk, \ + cocos2dx \ + CocosDenshion/android \ + lua/proj.android/jni \ + )) +subdirs += $(LOCAL_PATH)/LuaProjectTemplate/Android.mk + +include $(subdirs) diff --git a/tools/lua_project_generator/template/android/jni/Application.mk b/tools/lua_project_generator/template/android/jni/Application.mk index ffaaa6b6e3..a79179b9fb 100644 --- a/tools/lua_project_generator/template/android/jni/Application.mk +++ b/tools/lua_project_generator/template/android/jni/Application.mk @@ -1,3 +1,3 @@ -# it is needed for ndk-r5 -APP_STL := stlport_static +# it is needed for ndk-r5 +APP_STL := stlport_static APP_MODULES := cocos2d cocosdenshion lua game \ No newline at end of file diff --git a/tools/lua_project_generator/template/android/jni/LuaProjectTemplate/Android.mk b/tools/lua_project_generator/template/android/jni/LuaProjectTemplate/Android.mk index eacc52e456..bf354ba8a9 100644 --- a/tools/lua_project_generator/template/android/jni/LuaProjectTemplate/Android.mk +++ b/tools/lua_project_generator/template/android/jni/LuaProjectTemplate/Android.mk @@ -1,33 +1,33 @@ -LOCAL_PATH := $(call my-dir) -include $(CLEAR_VARS) -LOCAL_MODULE := game - -LOCAL_SRC_FILES := main.cpp \ -../../../Classes/AppDelegate.cpp \ -../../../../lua/cocos2dx_support/LuaEngineImpl.cpp \ -../../../../lua/cocos2dx_support/Cocos2dxLuaLoader.cpp \ -../../../../lua/cocos2dx_support/LuaCocos2d.cpp \ -../../../../lua/cocos2dx_support/LuaEngine.cpp \ -../../../../lua/CocosDenshion_support/LuaSimpleAudioEngine.cpp - -LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../cocos2dx \ - $(LOCAL_PATH)/../../../../cocos2dx/platform \ - $(LOCAL_PATH)/../../../../cocos2dx/include \ - $(LOCAL_PATH)/../../../../cocos2dx/lua_support \ - $(LOCAL_PATH)/../../../../CocosDenshion/include \ - $(LOCAL_PATH)/../../../Classes \ - $(LOCAL_PATH)/../../../../lua/lua \ - $(LOCAL_PATH)/../../../../lua/tolua \ - $(LOCAL_PATH)/../../../../lua/cocos2dx_support \ - $(LOCAL_PATH)/../../../../lua/CocosDenshion_support -# it is used for ndk-r5 -# if you build with ndk-r4, comment it -# because the new Windows toolchain doesn't support Cygwin's drive -# mapping (i.e /cygdrive/c/ instead of C:/) +LOCAL_PATH := $(call my-dir) +include $(CLEAR_VARS) +LOCAL_MODULE := game + +LOCAL_SRC_FILES := main.cpp \ +../../../Classes/AppDelegate.cpp \ +../../../../lua/cocos2dx_support/LuaEngineImpl.cpp \ +../../../../lua/cocos2dx_support/Cocos2dxLuaLoader.cpp \ +../../../../lua/cocos2dx_support/LuaCocos2d.cpp \ +../../../../lua/cocos2dx_support/LuaEngine.cpp \ +../../../../lua/CocosDenshion_support/LuaSimpleAudioEngine.cpp + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../../cocos2dx \ + $(LOCAL_PATH)/../../../../cocos2dx/platform \ + $(LOCAL_PATH)/../../../../cocos2dx/include \ + $(LOCAL_PATH)/../../../../cocos2dx/lua_support \ + $(LOCAL_PATH)/../../../../CocosDenshion/include \ + $(LOCAL_PATH)/../../../Classes \ + $(LOCAL_PATH)/../../../../lua/lua \ + $(LOCAL_PATH)/../../../../lua/tolua \ + $(LOCAL_PATH)/../../../../lua/cocos2dx_support \ + $(LOCAL_PATH)/../../../../lua/CocosDenshion_support +# it is used for ndk-r5 +# if you build with ndk-r4, comment it +# because the new Windows toolchain doesn't support Cygwin's drive +# mapping (i.e /cygdrive/c/ instead of C:/) LOCAL_LDLIBS := -L$(call host-path, $(LOCAL_PATH)/../../libs/armeabi) \ - -L$(call host-path, $(LOCAL_PATH)/../../../../cocos2dx/platform/third_party/android/libraries) -lcurl \ - -lcocos2d \ - -lcocosdenshion \ - -llua - + -L$(call host-path, $(LOCAL_PATH)/../../../../cocos2dx/platform/third_party/android/libraries) -lcurl \ + -lcocos2d \ + -lcocosdenshion \ + -llua + include $(BUILD_SHARED_LIBRARY) \ No newline at end of file diff --git a/tools/lua_project_generator/template/android/jni/LuaProjectTemplate/main.cpp b/tools/lua_project_generator/template/android/jni/LuaProjectTemplate/main.cpp index e1d0daff5f..8246e103a2 100644 --- a/tools/lua_project_generator/template/android/jni/LuaProjectTemplate/main.cpp +++ b/tools/lua_project_generator/template/android/jni/LuaProjectTemplate/main.cpp @@ -26,7 +26,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi } else { - ccDrawInit(); + ccDrawInit(); ccGLInvalidateStateCache(); CCShaderCache::sharedShaderCache()->reloadDefaultShaders(); From ad50d6ee57c94d95400eb3618e946dea9b5db747 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 29 May 2012 17:11:33 +0800 Subject: [PATCH 003/257] fixed #1270: Fixed some warning on win32. --- cocos2dx/CCDrawingPrimitives.cpp | 6 ++--- cocos2dx/CCDrawingPrimitives.h | 6 ++--- .../extensions/CCBReader/CCBReader_v2.cpp | 4 +-- .../CCControlSaturationBrightnessPicker.cpp | 12 ++++----- .../CCControlExtension/CCControlSwitch.cpp | 4 +-- cocos2dx/extensions/CCListView/CCListView.cpp | 7 +++-- .../CCTextureWatcher/CCTextureWatcher.cpp | 26 +++++++++---------- cocos2dx/kazmath/src/mat3.c | 2 +- cocos2dx/label_nodes/CCLabelBMFont.cpp | 12 +++++---- .../CCLayer.cpp | 2 +- .../CCTransitionProgress.cpp | 2 +- cocos2dx/particle_nodes/CCParticleSystem.cpp | 4 +-- .../particle_nodes/CCParticleSystemQuad.cpp | 2 +- cocos2dx/platform/CCEGLViewProtocol.cpp | 12 ++++----- cocos2dx/platform/CCImage.h | 4 +-- cocos2dx/platform/CCImageCommon_cpp.h | 12 ++++----- cocos2dx/platform/win32/CCEGLView.cpp | 2 +- cocos2dx/shaders/ccGLStateCache.cpp | 4 +-- cocos2dx/textures/CCTextureAtlas.cpp | 2 +- cocos2dx/textures/CCTexturePVR.cpp | 2 +- 20 files changed, 66 insertions(+), 61 deletions(-) diff --git a/cocos2dx/CCDrawingPrimitives.cpp b/cocos2dx/CCDrawingPrimitives.cpp index 5a122765af..d8032cfc29 100644 --- a/cocos2dx/CCDrawingPrimitives.cpp +++ b/cocos2dx/CCDrawingPrimitives.cpp @@ -226,7 +226,7 @@ void ccDrawFilledPoly( const CCPoint *poli, unsigned int numberOfPoints, ccColor CC_INCREMENT_GL_DRAWS(1); } -void ccDrawCircle( const CCPoint& center, float radius, float angle, int segments, bool drawLineToCenter) +void ccDrawCircle( const CCPoint& center, float radius, float angle, unsigned int segments, bool drawLineToCenter) { lazy_init(); @@ -265,7 +265,7 @@ void ccDrawCircle( const CCPoint& center, float radius, float angle, int segment CC_INCREMENT_GL_DRAWS(1); } -void ccDrawQuadBezier(const CCPoint& origin, const CCPoint& control, const CCPoint& destination, int segments) +void ccDrawQuadBezier(const CCPoint& origin, const CCPoint& control, const CCPoint& destination, unsigned int segments) { lazy_init(); @@ -294,7 +294,7 @@ void ccDrawQuadBezier(const CCPoint& origin, const CCPoint& control, const CCPoi CC_INCREMENT_GL_DRAWS(1); } -void ccDrawCubicBezier(const CCPoint& origin, const CCPoint& control1, const CCPoint& control2, const CCPoint& destination, int segments) +void ccDrawCubicBezier(const CCPoint& origin, const CCPoint& control1, const CCPoint& control2, const CCPoint& destination, unsigned int segments) { lazy_init(); diff --git a/cocos2dx/CCDrawingPrimitives.h b/cocos2dx/CCDrawingPrimitives.h index 77297585e5..4b65fe690c 100644 --- a/cocos2dx/CCDrawingPrimitives.h +++ b/cocos2dx/CCDrawingPrimitives.h @@ -73,17 +73,17 @@ void CC_DLL ccDrawPoly( const CCPoint *vertices, unsigned int numOfVertices, boo void CC_DLL ccDrawFilledPoly( const CCPoint *poli, unsigned int numberOfPoints, ccColor4F color ); /** draws a circle given the center, radius and number of segments. */ -void CC_DLL ccDrawCircle( const CCPoint& center, float radius, float angle, int segments, bool drawLineToCenter); +void CC_DLL ccDrawCircle( const CCPoint& center, float radius, float angle, unsigned int segments, bool drawLineToCenter); /** draws a quad bezier path @since v0.8 */ -void CC_DLL ccDrawQuadBezier(const CCPoint& origin, const CCPoint& control, const CCPoint& destination, int segments); +void CC_DLL ccDrawQuadBezier(const CCPoint& origin, const CCPoint& control, const CCPoint& destination, unsigned int segments); /** draws a cubic bezier path @since v0.8 */ -void CC_DLL ccDrawCubicBezier(const CCPoint& origin, const CCPoint& control1, const CCPoint& control2, const CCPoint& destination, int segments); +void CC_DLL ccDrawCubicBezier(const CCPoint& origin, const CCPoint& control1, const CCPoint& control2, const CCPoint& destination, unsigned int segments); /** set the drawing color with 4 unsigned bytes @since v2.0 diff --git a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp index e04be27088..9f72761d9e 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp @@ -40,13 +40,13 @@ int CCBReader::intValFromDict(CCDictionary* dict, const std::string key) float CCBReader::floatValFromDict(CCDictionary* dict, const std::string key) { CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); - return valueString? valueString->floatValue() : 0; + return valueString? valueString->floatValue() : 0.0f; } bool CCBReader::boolValFromDict(CCDictionary* dict, const std::string key) { CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); - return valueString? ((bool)(valueString->intValue())) : false; + return (valueString && valueString->intValue()) ? true : false; } CCPoint CCBReader::pointValFromDict(CCDictionary* dict, const std::string key) diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp b/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp index 5686dd072d..96a1d3ec5a 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp @@ -94,8 +94,8 @@ void CCControlSaturationBrightnessPicker::updateSliderPosition(CCPoint sliderPos // Clamp the position of the icon within the circle // Get the center point of the bkgd image - float centerX = m_startPos.x + m_background->boundingBox().size.width*.5; - float centerY = m_startPos.y + m_background->boundingBox().size.height*.5; + float centerX = m_startPos.x + m_background->boundingBox().size.width*0.5f; + float centerY = m_startPos.y + m_background->boundingBox().size.height*0.5f; // Work out the distance difference between the location and center float dx = sliderPosition.x - centerX; @@ -106,7 +106,7 @@ void CCControlSaturationBrightnessPicker::updateSliderPosition(CCPoint sliderPos float angle = atan2f(dy, dx); // Set the limit to the slider movement within the colour picker - float limit = m_background->boundingBox().size.width*.5; + float limit = m_background->boundingBox().size.width*0.5f; // Check distance doesn't exceed the bounds of the circle if (dist > limit) @@ -126,7 +126,7 @@ void CCControlSaturationBrightnessPicker::updateSliderPosition(CCPoint sliderPos else if (sliderPosition.y > m_startPos.y + boxPos + boxSize) sliderPosition.y = m_startPos.y + boxPos + boxSize; // Use the position / slider width to determin the percentage the dragger is at - m_saturation = 1.0 - fabs((m_startPos.x + (float)boxPos - sliderPosition.x)/(float)boxSize); + m_saturation = 1.0f - fabs((m_startPos.x + (float)boxPos - sliderPosition.x)/(float)boxSize); m_brightness = fabs((m_startPos.y + (float)boxPos - sliderPosition.y)/(float)boxSize); } @@ -135,8 +135,8 @@ bool CCControlSaturationBrightnessPicker::checkSliderPosition(CCPoint location) // Clamp the position of the icon within the circle // get the center point of the bkgd image - float centerX = m_startPos.x + m_background->boundingBox().size.width*.5; - float centerY = m_startPos.y + m_background->boundingBox().size.height*.5; + float centerX = m_startPos.x + m_background->boundingBox().size.width*0.5f; + float centerY = m_startPos.y + m_background->boundingBox().size.height*0.5f; // work out the distance difference between the location and center float dx = location.x - centerX; diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp index dff0484dc2..824d27dd0d 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp @@ -206,7 +206,7 @@ void CCControlSwitchSprite::needsLayout() m_pOffSprite->getContentSize().height / 2)); } - CCRenderTexture *rt = CCRenderTexture::renderTextureWithWidthAndHeight(m_pMaskTexture->getContentSize().width, m_pMaskTexture->getContentSize().height); + CCRenderTexture *rt = CCRenderTexture::renderTextureWithWidthAndHeight((int)m_pMaskTexture->getContentSize().width, (int)m_pMaskTexture->getContentSize().height); rt->begin(); m_pOnSprite->visit(); @@ -358,7 +358,7 @@ void CCControlSwitch::setIsEnabled(bool enabled) { m_bEnabled = enabled; - m_pSwitchSprite->setOpacity((enabled) ? 255.0f : 128.0f); + m_pSwitchSprite->setOpacity((enabled) ? 255 : 128); } CCPoint CCControlSwitch::locationFromTouch(CCTouch* pTouch) diff --git a/cocos2dx/extensions/CCListView/CCListView.cpp b/cocos2dx/extensions/CCListView/CCListView.cpp index 4a91352afe..dd71dee560 100644 --- a/cocos2dx/extensions/CCListView/CCListView.cpp +++ b/cocos2dx/extensions/CCListView/CCListView.cpp @@ -31,7 +31,7 @@ using namespace std; NS_CC_EXT_BEGIN -#define ND_LISTVIEW_ACTION_INTERVAL 0.6666 +#define ND_LISTVIEW_ACTION_INTERVAL 0.6666f /****************************************** **************Public Functions************* *******************************************/ @@ -1142,6 +1142,9 @@ unsigned int CCListView::triggerNumberOfCells(void) { unsigned int nRow = 0; CCListViewProtrolData data; + data.nNumberOfRows = 0; + data.nRow = 0; + data.cell = NULL; if (m_strDeletegate.size() > 0) { @@ -2151,7 +2154,7 @@ bool CCListView::isMenuTouch(CCTouch *touch, CCNode *parent) CCArray *pChildrens = parent->getChildren(); if (pChildrens && pChildrens->count() > 0) { - for (int i = 0; i < pChildrens->count(); i++) + for (unsigned int i = 0; i < pChildrens->count(); i++) { CCNode *pChildren = (CCNode*)pChildrens->objectAtIndex(i); if (this->isMenuTouch(touch, pChildren)) diff --git a/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp b/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp index efa08d7188..ca3185d906 100644 --- a/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp +++ b/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp @@ -45,7 +45,7 @@ CCTextureWatcher::CCTextureWatcher() // layer CCSize size = CCDirector::sharedDirector()->getWinSize(); - size.height *= 0.6; + size.height *= 0.6f; m_pLayer->setContentSize(size); // the menu of disabling touch event @@ -256,12 +256,12 @@ void CCTextureWatcher::CCListView_cellForRow(CCListView *listView, CCListViewPro CCSize listItemSize = CCSize(m_pList->getContentSize().width / NUM_PER_PAGE, m_pList->getContentSize().height); - CCSize size = CCSize(listItemSize.width * 0.9, listItemSize.height * 0.6); + CCSize size = CCSize(listItemSize.width * 0.9f, listItemSize.height * 0.6f); sprintf(m_pszString, "%d/%d", m_nCurrnetPage, m_nTotalPage); m_labelPage->setString(m_pszString); - float offX = 0, offY = 0, offsetX = 0, offsetY = 0; + float offX = 0.0f, offY = 0.0f, offsetX = 0.0f, offsetY = 0.0f; CC_UNUSED_PARAM(offsetY); int nCount = 0; int nStart = (m_nCurrnetPage - 1) * NUM_PER_PAGE; @@ -288,8 +288,8 @@ void CCTextureWatcher::CCListView_cellForRow(CCListView *listView, CCListViewPro { labelCount->setColor(ccc3(255, 0, 0)); } - offX = offsetX + listItemSize.width * 0.5 - labelCount->getContentSize().width * 0.5; - offY = (listItemSize.height - size.height) * 0.5 - labelCount->getContentSize().height; + offX = offsetX + listItemSize.width * 0.5f - labelCount->getContentSize().width * 0.5f; + offY = (listItemSize.height - size.height) * 0.5f - labelCount->getContentSize().height; labelCount->setPosition(ccp(offX, offY)); labelCount->setAnchorPoint(ccp(0, 0)); cell->addChild(labelCount); @@ -297,10 +297,10 @@ void CCTextureWatcher::CCListView_cellForRow(CCListView *listView, CCListViewPro // texture size sprintf(m_pszString, "%.0f*%.0f", textrue->getContentSize().width, textrue->getContentSize().height); CCLabelTTF *labelSize = CCLabelTTF::labelWithString(m_pszString, "Arial", 16); - offX = offsetX + listItemSize.width * 0.5; - offY = (listItemSize.height - size.height) * 0.5 + size.height; + offX = offsetX + listItemSize.width * 0.5f; + offY = (listItemSize.height - size.height) * 0.5f + size.height; labelSize->setPosition(ccp(offX, offY)); - labelSize->setAnchorPoint(ccp(0.5, 0)); + labelSize->setAnchorPoint(ccp(0.5f, 0)); cell->addChild(labelSize); // texture name @@ -313,12 +313,12 @@ void CCTextureWatcher::CCListView_cellForRow(CCListView *listView, CCListViewPro string name = key.substr(pos, len - pos); sprintf(m_pszString, "%s", name.c_str()); - CCSize dimensions = CCSizeMake(listItemSize.width * 0.9, labelSize->getContentSize().height); + CCSize dimensions = CCSizeMake(listItemSize.width * 0.9f, labelSize->getContentSize().height); CCLabelTTF *labelName = CCLabelTTF::labelWithString(m_pszString, dimensions, CCTextAlignmentCenter, "Arial", 16); - offX = offsetX + listItemSize.width * 0.5; + offX = offsetX + listItemSize.width * 0.5f; offY = offY + labelName->getContentSize().height; labelName->setPosition(ccp(offX, offY)); - labelName->setAnchorPoint(ccp(0.5, 0)); + labelName->setAnchorPoint(ccp(0.5f, 0)); cell->addChild(labelName); CCSprite *sprite = CCSprite::spriteWithTexture(textrue); @@ -341,8 +341,8 @@ void CCTextureWatcher::CCListView_cellForRow(CCListView *listView, CCListViewPro sprite->setScale(scale); spriteSize.width *= scale; spriteSize.height *= scale; - offX = offsetX + (listItemSize.width - spriteSize.width) * 0.5; - offY = (listItemSize.height - spriteSize.height) * 0.5; + offX = offsetX + (listItemSize.width - spriteSize.width) * 0.5f; + offY = (listItemSize.height - spriteSize.height) * 0.5f; sprite->setPosition(ccp(offX, offY)); cell->addChild(sprite); offsetX += listItemSize.width; diff --git a/cocos2dx/kazmath/src/mat3.c b/cocos2dx/kazmath/src/mat3.c index 0b047e06f4..d5549a7792 100644 --- a/cocos2dx/kazmath/src/mat3.c +++ b/cocos2dx/kazmath/src/mat3.c @@ -92,7 +92,7 @@ kmMat3* const kmMat3Inverse(kmMat3* pOut, const kmScalar pDeterminate, const kmM return NULL; } - detInv = 1.0 / pDeterminate; + detInv = 1.0f / pDeterminate; kmMat3Adjugate(&adjugate, pM); kmMat3ScalarMultiply(pOut, &adjugate, detInv); diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index d202028fca..357e6590e4 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -864,7 +864,7 @@ void CCLabelBMFont::createFontChars() } totalHeight = m_pConfiguration->m_uCommonHeight * quantityOfLines; - nextFontPositionY = -(m_pConfiguration->m_uCommonHeight - m_pConfiguration->m_uCommonHeight * quantityOfLines); + nextFontPositionY = 0-(m_pConfiguration->m_uCommonHeight - m_pConfiguration->m_uCommonHeight * quantityOfLines); for (unsigned int i= 0; i < stringLen; i++) { @@ -1086,7 +1086,7 @@ void CCLabelBMFont::updateLabel() vector last_word; last_word.reserve( stringLength ); - int line = 1, i = 0; + unsigned int line = 1, i = 0; bool start_line = false, start_word = false; float startOfLine = -1, startOfWord = -1; int skip = 0; @@ -1101,7 +1101,7 @@ void CCLabelBMFont::updateLabel() if (!characterSprite->getIsVisible()) continue; - if (i >= stringLength || i < 0) + if (i >= stringLength) break; unsigned short character = str_whole[i]; @@ -1132,7 +1132,7 @@ void CCLabelBMFont::updateLabel() i++; line++; - if (i >= stringLength || i < 0) + if (i >= stringLength) break; character = str_whole[i]; @@ -1195,7 +1195,7 @@ void CCLabelBMFont::updateLabel() startOfLine = -1; line++; - if (i >= stringLength || i < 0) + if (i >= stringLength) break; if (!startOfWord) @@ -1229,7 +1229,9 @@ void CCLabelBMFont::updateLabel() unsigned short* str_new = new unsigned short[size + 1]; for (int i = 0; i < size; ++i) + { str_new[i] = multiline_string[i]; + } str_new[size] = 0; diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index 6b640ceb16..4caf9aef7a 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -285,7 +285,7 @@ bool CCLayer::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent) { if (m_pScriptHandlerEntry) { - return excuteScriptTouchHandler(CCTOUCHBEGAN, pTouch); + return excuteScriptTouchHandler(CCTOUCHBEGAN, pTouch) == 0 ? false : true; } CC_UNUSED_PARAM(pTouch); CC_UNUSED_PARAM(pEvent); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp index f15398e80c..32096364f9 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp @@ -62,7 +62,7 @@ void CCTransitionProgress::onEnter() CCSize size = CCDirector::sharedDirector()->getWinSize(); // create the second render texture for outScene - CCRenderTexture *texture = CCRenderTexture::renderTextureWithWidthAndHeight(size.width, size.height); + CCRenderTexture *texture = CCRenderTexture::renderTextureWithWidthAndHeight((int)size.width, (int)size.height); texture->getSprite()->setAnchorPoint(ccp(0.5f,0.5f)); texture->setPosition(ccp(size.width/2, size.height/2)); texture->setAnchorPoint(ccp(0.5f,0.5f)); diff --git a/cocos2dx/particle_nodes/CCParticleSystem.cpp b/cocos2dx/particle_nodes/CCParticleSystem.cpp index 0ae5a07d90..b764005d4b 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystem.cpp @@ -347,7 +347,7 @@ bool CCParticleSystem::initWithTotalParticles(unsigned int numberOfParticles) if (m_pBatchNode) { - for (int i = 0; i < m_uTotalParticles; i++) + for (unsigned int i = 0; i < m_uTotalParticles; i++) { m_pParticles[i].atlasIndex=i; } @@ -1203,7 +1203,7 @@ void CCParticleSystem::setBatchNode(CCParticleBatchNode* batchNode) if( batchNode ) { //each particle needs a unique index - for (int i = 0; i < m_uTotalParticles; i++) + for (unsigned int i = 0; i < m_uTotalParticles; i++) { m_pParticles[i].atlasIndex=i; } diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp index eaba6348f8..ce5220fb5c 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp @@ -416,7 +416,7 @@ void CCParticleSystemQuad::setTotalParticles(unsigned int tp) // Init particles if (m_pBatchNode) { - for (int i = 0; i < m_uTotalParticles; i++) + for (unsigned int i = 0; i < m_uTotalParticles; i++) { m_pParticles[i].atlasIndex=i; } diff --git a/cocos2dx/platform/CCEGLViewProtocol.cpp b/cocos2dx/platform/CCEGLViewProtocol.cpp index dfaffb2395..ccf65b5a57 100644 --- a/cocos2dx/platform/CCEGLViewProtocol.cpp +++ b/cocos2dx/platform/CCEGLViewProtocol.cpp @@ -83,8 +83,8 @@ void CCEGLViewProtocol::setDesignResolutionSize(float width, float height) // calculate the factor and the rect of viewport m_fScreenScaleFactor = MIN((float)m_sSizeInPixel.width / m_sSizeInPoint.width, (float)m_sSizeInPixel.height / m_sSizeInPoint.height); - int viewPortW = (int)(m_sSizeInPoint.width * m_fScreenScaleFactor); - int viewPortH = (int)(m_sSizeInPoint.height * m_fScreenScaleFactor); + float viewPortW = m_sSizeInPoint.width * m_fScreenScaleFactor; + float viewPortH = m_sSizeInPoint.height * m_fScreenScaleFactor; m_rcViewPort.setRect((m_sSizeInPixel.width - viewPortW) / 2, (m_sSizeInPixel.height - viewPortH) / 2, viewPortW, viewPortH); @@ -136,8 +136,8 @@ void CCEGLViewProtocol::setViewPortInPoints(float x , float y , float w , float if (m_bNeedScale) { float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR(); - glViewport((GLint)(x * factor) + m_rcViewPort.origin.x, - (GLint)(y * factor) + m_rcViewPort.origin.y, + glViewport((GLint)(x * factor + m_rcViewPort.origin.x), + (GLint)(y * factor + m_rcViewPort.origin.y), (GLsizei)(w * factor), (GLsizei)(h * factor)); } @@ -155,8 +155,8 @@ void CCEGLViewProtocol::setScissorInPoints(float x , float y , float w , float h if (m_bNeedScale) { float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR(); - glScissor((GLint)(x * factor) + m_rcViewPort.origin.x, - (GLint)(y * factor) + m_rcViewPort.origin.y, + glScissor((GLint)(x * factor + m_rcViewPort.origin.x), + (GLint)(y * factor + m_rcViewPort.origin.y), (GLsizei)(w * factor), (GLsizei)(h * factor)); } diff --git a/cocos2dx/platform/CCImage.h b/cocos2dx/platform/CCImage.h index 34d8513e77..f7322740c9 100644 --- a/cocos2dx/platform/CCImage.h +++ b/cocos2dx/platform/CCImage.h @@ -120,8 +120,8 @@ public: */ bool saveToFile(const char *pszFilePath, bool bIsToRGB = true); - CC_SYNTHESIZE_READONLY(short, m_nWidth, Width); - CC_SYNTHESIZE_READONLY(short, m_nHeight, Height); + CC_SYNTHESIZE_READONLY(unsigned short, m_nWidth, Width); + CC_SYNTHESIZE_READONLY(unsigned short, m_nHeight, Height); CC_SYNTHESIZE_READONLY(int, m_nBitsPerComponent, BitsPerComponent); protected: diff --git a/cocos2dx/platform/CCImageCommon_cpp.h b/cocos2dx/platform/CCImageCommon_cpp.h index 3ebd41c6a4..1b42085847 100644 --- a/cocos2dx/platform/CCImageCommon_cpp.h +++ b/cocos2dx/platform/CCImageCommon_cpp.h @@ -354,7 +354,7 @@ bool CCImage::_initWithPngData(void * pData, int nDatalen) if (row_pointers) { const unsigned int stride = m_nWidth * channels; - for (size_t i = 0; i < m_nHeight; ++i) + for (unsigned short i = 0; i < m_nHeight; ++i) { png_uint_32 q = i * stride; row_pointers[i] = (png_bytep)m_pData + q; @@ -364,9 +364,9 @@ bool CCImage::_initWithPngData(void * pData, int nDatalen) if (m_bHasAlpha) { unsigned int *tmp = (unsigned int *)m_pData; - for(unsigned int i = 0; i < m_nHeight; i++) + for(unsigned short i = 0; i < m_nHeight; i++) { - for(int j = 0; j < m_nWidth * channels; j += 4) + for(unsigned int j = 0; j < m_nWidth * channels; j += 4) { *tmp++ = CC_RGB_PREMULTIPLY_APLHA( row_pointers[i][j], row_pointers[i][j + 1], row_pointers[i][j + 2], row_pointers[i][j + 3] ); @@ -515,9 +515,9 @@ bool CCImage::_initWithTiffData(void* pData, int nDataLen) CC_BREAK_IF(NULL == tif); - uint32 w, h; - uint16 bitsPerSample, samplePerPixel, planarConfig, extraSample; - size_t npixels; + uint32 w = 0, h = 0; + uint16 bitsPerSample = 0, samplePerPixel = 0, planarConfig = 0; + size_t npixels = 0; TIFFGetField(tif, TIFFTAG_IMAGEWIDTH, &w); TIFFGetField(tif, TIFFTAG_IMAGELENGTH, &h); diff --git a/cocos2dx/platform/win32/CCEGLView.cpp b/cocos2dx/platform/win32/CCEGLView.cpp index 3e8c916ea5..f58d480936 100644 --- a/cocos2dx/platform/win32/CCEGLView.cpp +++ b/cocos2dx/platform/win32/CCEGLView.cpp @@ -461,7 +461,7 @@ void CCEGLView::resize(int width, int height) void CCEGLView::setFrameSize(float width, float height) { - Create((LPCTSTR)m_szViewName, width, height); + Create((LPCTSTR)m_szViewName, (int)width, (int)height); CCEGLViewProtocol::setFrameSize(width, height); } diff --git a/cocos2dx/shaders/ccGLStateCache.cpp b/cocos2dx/shaders/ccGLStateCache.cpp index 3f2100d0fa..828124880e 100644 --- a/cocos2dx/shaders/ccGLStateCache.cpp +++ b/cocos2dx/shaders/ccGLStateCache.cpp @@ -163,10 +163,10 @@ void ccGLEnable( ccGLServerState flags ) { #if CC_ENABLE_GL_STATE_CACHE - bool enabled = false; + int enabled = 0; /* GL_BLEND */ - if( (enabled=(flags & CC_GL_BLEND)) != (s_eGLServerState & CC_GL_BLEND) ) { + if( (enabled = (flags & CC_GL_BLEND)) != (s_eGLServerState & CC_GL_BLEND) ) { if( enabled ) { glEnable( GL_BLEND ); s_eGLServerState |= CC_GL_BLEND; diff --git a/cocos2dx/textures/CCTextureAtlas.cpp b/cocos2dx/textures/CCTextureAtlas.cpp index f4fa712e2c..8ce755d087 100644 --- a/cocos2dx/textures/CCTextureAtlas.cpp +++ b/cocos2dx/textures/CCTextureAtlas.cpp @@ -563,7 +563,7 @@ void CCTextureAtlas::fillWithEmptyQuadsFromIndex(unsigned int index, unsigned in memset(&quad, 0, sizeof(quad)); unsigned int to = index + amount; - for (int i = index ; i < to ; i++) + for (unsigned int i = index ; i < to ; i++) { m_pQuads[i] = quad; } diff --git a/cocos2dx/textures/CCTexturePVR.cpp b/cocos2dx/textures/CCTexturePVR.cpp index c1c83879cd..ad3edf450e 100755 --- a/cocos2dx/textures/CCTexturePVR.cpp +++ b/cocos2dx/textures/CCTexturePVR.cpp @@ -244,7 +244,7 @@ bool CCTexturePVR::unpackPVRData(unsigned char* data, unsigned int len) It means that image is compressed as flipped. We don't support automatic flipping. */ - bool flipped = (bool)(flags & kPVRTextureFlagVerticalFlip); + bool flipped = (flags & kPVRTextureFlagVerticalFlip) ? true : false; if ( flipped ) { CCLOG("cocos2d: WARNING: Image is flipped. Regenerate it using PVRTexTool"); From 48646408160c4b49c5293c5c443a667d4891d05e Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 29 May 2012 17:25:18 +0800 Subject: [PATCH 004/257] fixed #1270: Re-generated LuaCocos2d.cpp. --- lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id | 2 +- tools/tolua++/CCDrawingPrimitives.pkg | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index 2d1624912e..3cb6d0e67e 100644 --- a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -5a1155c9dcd8585864efa8080d8fd42059f9ea52 \ No newline at end of file +b44166abef4b62f6277ccfa7730bde51123f4295 \ No newline at end of file diff --git a/tools/tolua++/CCDrawingPrimitives.pkg b/tools/tolua++/CCDrawingPrimitives.pkg index 4e9be97ee8..af6e0e9514 100644 --- a/tools/tolua++/CCDrawingPrimitives.pkg +++ b/tools/tolua++/CCDrawingPrimitives.pkg @@ -3,6 +3,6 @@ void ccDrawPoint(CCPoint point); void ccDrawPoints(const CCPoint *points, unsigned int numberOfPoints); void ccDrawLine(CCPoint origin, CCPoint destination); void ccDrawPoly(const CCPoint *vertices, int numOfVertices, bool closePolygon); -void ccDrawCircle(CCPoint center, float radius, float angle, int segments, bool drawLineToCenter); -void ccDrawQuadBezier(CCPoint origin, CCPoint control, CCPoint destination, int segments); -void ccDrawCubicBezier(CCPoint origin, CCPoint control1, CCPoint control2, CCPoint destination, int segments); +void ccDrawCircle(CCPoint center, float radius, float angle, unsigned int segments, bool drawLineToCenter); +void ccDrawQuadBezier(CCPoint origin, CCPoint control, CCPoint destination, unsigned int segments); +void ccDrawCubicBezier(CCPoint origin, CCPoint control1, CCPoint control2, CCPoint destination, unsigned int segments); From 228bc1e044fcd8ef76b95bc3eb1ad7207650e85a Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 29 May 2012 17:50:27 +0800 Subject: [PATCH 005/257] fixed #1240: Updated vs2010 project setting. --- cocos2d-win32.vc2010.sln | 16 +- cocos2dx/proj.win32/cocos2d-win32.vcxproj | 21 ++- .../proj.win32/cocos2d-win32.vcxproj.filters | 12 +- testjs/proj.win32/testjs.win32.vcxproj | 165 ++++++++++++++++++ .../proj.win32/testjs.win32.vcxproj.filters | 89 ++++++++++ testjs/proj.win32/testjs.win32.vcxproj.user | 7 + 6 files changed, 292 insertions(+), 18 deletions(-) create mode 100644 testjs/proj.win32/testjs.win32.vcxproj create mode 100644 testjs/proj.win32/testjs.win32.vcxproj.filters create mode 100644 testjs/proj.win32/testjs.win32.vcxproj.user diff --git a/cocos2d-win32.vc2010.sln b/cocos2d-win32.vc2010.sln index 787447af2b..9528235217 100644 --- a/cocos2d-win32.vc2010.sln +++ b/cocos2d-win32.vc2010.sln @@ -17,7 +17,16 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloLua", "HelloLua\proj.w EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloWorld", "HelloWorld\proj.win32\HelloWorld.win32.vcxproj", "{B8BF9E81-35FD-4582-BA1C-B85FA365BABB}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testjs", "testjs\proj.win32\testjs.win32.vcxproj", "{D0F06A44-A245-4D13-A498-0120C203B539}" + ProjectSection(ProjectDependencies) = postProject + {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} + {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} = {F8EDD7FA-9A51-4E80-BAEB-860825D2EAC6} + EndProjectSection +EndProject Global + GlobalSection(DPCodeReviewSolutionGUID) = preSolution + DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} + EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 @@ -55,11 +64,12 @@ Global {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Debug|Win32.Build.0 = Debug|Win32 {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Release|Win32.ActiveCfg = Release|Win32 {B8BF9E81-35FD-4582-BA1C-B85FA365BABB}.Release|Win32.Build.0 = Release|Win32 + {D0F06A44-A245-4D13-A498-0120C203B539}.Debug|Win32.ActiveCfg = Debug|Win32 + {D0F06A44-A245-4D13-A498-0120C203B539}.Debug|Win32.Build.0 = Debug|Win32 + {D0F06A44-A245-4D13-A498-0120C203B539}.Release|Win32.ActiveCfg = Release|Win32 + {D0F06A44-A245-4D13-A498-0120C203B539}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(DPCodeReviewSolutionGUID) = preSolution - DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} - EndGlobalSection EndGlobal diff --git a/cocos2dx/proj.win32/cocos2d-win32.vcxproj b/cocos2dx/proj.win32/cocos2d-win32.vcxproj index f81dfd595c..447046e014 100755 --- a/cocos2dx/proj.win32/cocos2d-win32.vcxproj +++ b/cocos2dx/proj.win32/cocos2d-win32.vcxproj @@ -57,7 +57,7 @@ Disabled - ..;..\platform;..\platform\win32;..\platform\third_party\win32\iconv;..\platform\third_party\win32\zlib;..\platform\third_party\win32\libpng;..\platform\third_party\win32\libjpeg;..\platform\third_party\win32\libxml2;..\platform\third_party\win32\pthread;..\platform\third_party\win32\OGLES;..\include;..\kazmath\include;..\actions;..\base_nodes;..\cocoa;..\effects;..\extensions;..\keypad_dispatcher;..\label_nodes;..\layers_scenes_transitions_nodes;..\menu_nodes;..\misc_nodes;..\particle_nodes;..\script_support;..\shaders;..\sprite_nodes;..\text_input_node;..\textures;..\tileMap_parallax_nodes;..\touch_dispatcher;..\support;%(AdditionalIncludeDirectories) + ..;..\platform;..\platform\win32;..\platform\third_party\win32\iconv;..\platform\third_party\win32\zlib;..\platform\third_party\win32\libpng;..\platform\third_party\win32\libtiff;..\platform\third_party\win32\libjpeg;..\platform\third_party\win32\libxml2;..\platform\third_party\win32\pthread;..\platform\third_party\win32\OGLES;..\include;..\kazmath\include;..\actions;..\base_nodes;..\cocoa;..\effects;..\extensions;..\keypad_dispatcher;..\label_nodes;..\layers_scenes_transitions_nodes;..\menu_nodes;..\misc_nodes;..\particle_nodes;..\script_support;..\shaders;..\sprite_nodes;..\text_input_node;..\textures;..\tileMap_parallax_nodes;..\touch_dispatcher;..\support;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) true EnableFastChecks @@ -74,11 +74,13 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ - libEGL.lib;libGLESv2.lib;libxml2.lib;libzlib.lib;libpng.lib;libjpeg.lib;libiconv.lib;pthreadVCE2.lib;%(AdditionalDependencies) + libEGL.lib;libGLESv2.lib;libxml2.lib;libzlib.lib;libpng.lib;libtiff.lib;libjpeg.lib;libiconv.lib;pthreadVCE2.lib;%(AdditionalDependencies);%(AdditionalDependencies) $(OutDir)$(ProjectName).dll $(OutDir);%(AdditionalLibraryDirectories) - false - ;%(IgnoreSpecificDefaultLibraries) + + + + true Windows $(TargetDir)$(TargetName).lib @@ -95,7 +97,7 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ - ..;..\platform;..\platform\win32;..\platform\third_party\win32\iconv;..\platform\third_party\win32\zlib;..\platform\third_party\win32\libpng;..\platform\third_party\win32\libjpeg;..\platform\third_party\win32\libxml2;..\platform\third_party\win32\pthread;..\platform\third_party\win32\OGLES;..\include;..\kazmath\include;..\actions;..\base_nodes;..\cocoa;..\effects;..\extensions;..\keypad_dispatcher;..\label_nodes;..\layers_scenes_transitions_nodes;..\menu_nodes;..\misc_nodes;..\particle_nodes;..\script_support;..\shaders;..\sprite_nodes;..\text_input_node;..\textures;..\tileMap_parallax_nodes;..\touch_dispatcher;..\support;%(AdditionalIncludeDirectories) + ..;..\platform;..\platform\win32;..\platform\third_party\win32\iconv;..\platform\third_party\win32\zlib;..\platform\third_party\win32\libpng;..\platform\third_party\win32\libtiff;..\platform\third_party\win32\libjpeg;..\platform\third_party\win32\libxml2;..\platform\third_party\win32\pthread;..\platform\third_party\win32\OGLES;..\include;..\kazmath\include;..\actions;..\base_nodes;..\cocoa;..\effects;..\extensions;..\keypad_dispatcher;..\label_nodes;..\layers_scenes_transitions_nodes;..\menu_nodes;..\misc_nodes;..\particle_nodes;..\script_support;..\shaders;..\sprite_nodes;..\text_input_node;..\textures;..\tileMap_parallax_nodes;..\touch_dispatcher;..\support;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) MultiThreadedDLL @@ -110,10 +112,11 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ - libEGL.lib;libglesv2.lib;libxml2.lib;libzlib.lib;libpng.lib;libjpeg.lib;libiconv.lib;pthreadVCE2.lib;%(AdditionalDependencies) + libEGL.lib;libGLESv2.lib;libxml2.lib;libzlib.lib;libpng.lib;libtiff.lib;libjpeg.lib;libiconv.lib;pthreadVCE2.lib;;%(AdditionalDependencies) $(OutDir)$(ProjectName).dll $(OutDir);%(AdditionalLibraryDirectories) - ;%(IgnoreSpecificDefaultLibraries) + + true Windows true @@ -212,7 +215,6 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ - @@ -221,6 +223,7 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ + @@ -363,7 +366,6 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ - @@ -371,6 +373,7 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ + diff --git a/cocos2dx/proj.win32/cocos2d-win32.vcxproj.filters b/cocos2dx/proj.win32/cocos2d-win32.vcxproj.filters index 4b8b744c77..b815d74410 100755 --- a/cocos2dx/proj.win32/cocos2d-win32.vcxproj.filters +++ b/cocos2dx/proj.win32/cocos2d-win32.vcxproj.filters @@ -345,9 +345,6 @@ platform - - platform - platform @@ -489,6 +486,9 @@ extensions\CCBReader + + platform\win32 + @@ -791,9 +791,6 @@ platform - - platform - platform @@ -985,5 +982,8 @@ extensions\CCBReader + + platform\win32 + \ No newline at end of file diff --git a/testjs/proj.win32/testjs.win32.vcxproj b/testjs/proj.win32/testjs.win32.vcxproj new file mode 100644 index 0000000000..678cb01865 --- /dev/null +++ b/testjs/proj.win32/testjs.win32.vcxproj @@ -0,0 +1,165 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + + testjs + {D0F06A44-A245-4D13-A498-0120C203B539} + + + + Application + Unicode + + + Application + Unicode + + + + + + + + + + + + + <_ProjectFileVersion>10.0.40219.1 + $(SolutionDir)$(Configuration).win32\ + $(Configuration).win32\ + true + $(SolutionDir)$(Configuration).win32\ + $(Configuration).win32\ + false + AllRules.ruleset + + + AllRules.ruleset + + + + + + _DEBUG;%(PreprocessorDefinitions) + false + Win32 + true + $(IntDir)testjs.tlb + testjs.h + + + testjs_i.c + testjs_p.c + + + Disabled + .;..\Classes;..\..\js\spidermonkey-win32\include;..\..\js\JSBindings;..\..\js\BindingsExample;..\..\cocos2dx;..\..\cocos2dx\actions;..\..\cocos2dx\base_nodes;..\..\cocos2dx\cocoa;..\..\cocos2dx\effects;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\keypad_dispatcher;..\..\cocos2dx\label_nodes;..\..\cocos2dx\layers_scenes_transitions_nodes;..\..\cocos2dx\menu_nodes;..\..\cocos2dx\misc_nodes;..\..\cocos2dx\particle_nodes;..\..\cocos2dx\script_support;..\..\cocos2dx\shaders;..\..\cocos2dx\sprite_nodes;..\..\cocos2dx\support;..\..\cocos2dx\text_input_node;..\..\cocos2dx\textures;..\..\cocos2dx\tileMap_parallax_nodes;..\..\cocos2dx\touch_dispatcher;..\..\cocos2dx\platform;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;STRICT;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + true + EnableFastChecks + MultiThreadedDebugDLL + + + Level3 + EditAndContinue + 4251;4800;4244;4390;4065;4996;%(DisableSpecificWarnings) + + + _DEBUG;%(PreprocessorDefinitions) + 0x0409 + $(IntDir);%(AdditionalIncludeDirectories) + + + if not exist "$(OutDir)" mkdir "$(OutDir)" +xcopy /Y /Q "$(SolutionDir)js\spidermonkey-win32\lib\*.*" "$(OutDir)" + + + + libcocos2d.lib;libGLESv2.lib;libCocosDenshion.lib;js.lib;%(AdditionalDependencies) + $(OutDir);%(AdditionalLibraryDirectories) + true + Windows + MachineX86 + + + + + NDEBUG;%(PreprocessorDefinitions) + false + Win32 + true + $(IntDir)testjs.tlb + testjs.h + + + testjs_i.c + testjs_p.c + + + .;..\Classes;..\..\cocos2dx;..\..\cocos2dx\actions;..\..\cocos2dx\base_nodes;..\..\cocos2dx\cocoa;..\..\cocos2dx\effects;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\keypad_dispatcher;..\..\cocos2dx\label_nodes;..\..\cocos2dx\layers_scenes_transitions_nodes;..\..\cocos2dx\menu_nodes;..\..\cocos2dx\misc_nodes;..\..\cocos2dx\particle_nodes;..\..\cocos2dx\script_support;..\..\cocos2dx\shaders;..\..\cocos2dx\sprite_nodes;..\..\cocos2dx\support;..\..\cocos2dx\text_input_node;..\..\cocos2dx\textures;..\..\cocos2dx\tileMap_parallax_nodes;..\..\cocos2dx\touch_dispatcher;..\..\cocos2dx\platform;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories) + WIN32;_WINDOWS;STRICT;NDEBUG;%(PreprocessorDefinitions) + + + MultiThreadedDLL + + + Level3 + + + 4251;%(DisableSpecificWarnings) + + + NDEBUG;%(PreprocessorDefinitions) + 0x0409 + $(IntDir);%(AdditionalIncludeDirectories) + + + libcocos2d.lib;libGLESv2.lib;libCocosDenshion.lib;%(AdditionalDependencies) + $(OutDir);%(AdditionalLibraryDirectories) + Windows + MachineX86 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/testjs/proj.win32/testjs.win32.vcxproj.filters b/testjs/proj.win32/testjs.win32.vcxproj.filters new file mode 100644 index 0000000000..aea2cc42db --- /dev/null +++ b/testjs/proj.win32/testjs.win32.vcxproj.filters @@ -0,0 +1,89 @@ + + + + + {e3cf2382-1ff3-40f9-8b7e-18b61a7c2c65} + + + {21e3383e-1ce0-44c9-a5f6-9583e571c46c} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;jpg;jpeg;jpe;png;manifest + + + {42d8c7a8-ec45-498f-a33a-5805aab82fee} + + + {3b086d97-dbd9-4069-810a-ea7b36ffc165} + + + + + JSBindings + + + JSBindings + + + JSBindings + + + JSBindings + + + win32 + + + Classes + + + Classes + + + Classes + + + + + JSBindings + + + JSBindings + + + JSBindings + + + win32 + + + win32 + + + Classes + + + Classes + + + Classes + + + + + resource + + + resource + + + resource + + + resource + + + + + resource + + + \ No newline at end of file diff --git a/testjs/proj.win32/testjs.win32.vcxproj.user b/testjs/proj.win32/testjs.win32.vcxproj.user new file mode 100644 index 0000000000..3ba81af9e4 --- /dev/null +++ b/testjs/proj.win32/testjs.win32.vcxproj.user @@ -0,0 +1,7 @@ + + + + $(ProjectDir)..\Resources + WindowsLocalDebugger + + \ No newline at end of file From b4fad0bb2b2982c54ee0a884c4abf15dab9bbe3f Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 29 May 2012 18:06:52 +0800 Subject: [PATCH 006/257] fixed #1240: Updated vs2010 project setting (release target). --- HelloLua/proj.win32/HelloLua.win32.vcxproj | 2 +- testjs/proj.win32/testjs.win32.vcxproj | 8 ++++++-- testjs/proj.win32/testjs.win32.vcxproj.user | 4 ++++ tests/proj.win32/test.win32.vcxproj | 4 ++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/HelloLua/proj.win32/HelloLua.win32.vcxproj b/HelloLua/proj.win32/HelloLua.win32.vcxproj index d8a0bd5b27..2ba2c0c63c 100644 --- a/HelloLua/proj.win32/HelloLua.win32.vcxproj +++ b/HelloLua/proj.win32/HelloLua.win32.vcxproj @@ -120,7 +120,7 @@ $(IntDir);%(AdditionalIncludeDirectories) - libcocos2d.lib;libCocosDenshion.lib;libgles_cm.lib;liblua.lib;%(AdditionalDependencies) + libcocos2d.lib;libCocosDenshion.lib;liblua.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) Windows MachineX86 diff --git a/testjs/proj.win32/testjs.win32.vcxproj b/testjs/proj.win32/testjs.win32.vcxproj index 678cb01865..7f4da46eca 100644 --- a/testjs/proj.win32/testjs.win32.vcxproj +++ b/testjs/proj.win32/testjs.win32.vcxproj @@ -106,7 +106,7 @@ xcopy /Y /Q "$(SolutionDir)js\spidermonkey-win32\lib\*.*" "$(OutDir)" testjs_p.c - .;..\Classes;..\..\cocos2dx;..\..\cocos2dx\actions;..\..\cocos2dx\base_nodes;..\..\cocos2dx\cocoa;..\..\cocos2dx\effects;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\keypad_dispatcher;..\..\cocos2dx\label_nodes;..\..\cocos2dx\layers_scenes_transitions_nodes;..\..\cocos2dx\menu_nodes;..\..\cocos2dx\misc_nodes;..\..\cocos2dx\particle_nodes;..\..\cocos2dx\script_support;..\..\cocos2dx\shaders;..\..\cocos2dx\sprite_nodes;..\..\cocos2dx\support;..\..\cocos2dx\text_input_node;..\..\cocos2dx\textures;..\..\cocos2dx\tileMap_parallax_nodes;..\..\cocos2dx\touch_dispatcher;..\..\cocos2dx\platform;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories) + .;..\Classes;..\..\js\spidermonkey-win32\include;..\..\js\JSBindings;..\..\js\BindingsExample;..\..\cocos2dx;..\..\cocos2dx\actions;..\..\cocos2dx\base_nodes;..\..\cocos2dx\cocoa;..\..\cocos2dx\effects;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\keypad_dispatcher;..\..\cocos2dx\label_nodes;..\..\cocos2dx\layers_scenes_transitions_nodes;..\..\cocos2dx\menu_nodes;..\..\cocos2dx\misc_nodes;..\..\cocos2dx\particle_nodes;..\..\cocos2dx\script_support;..\..\cocos2dx\shaders;..\..\cocos2dx\sprite_nodes;..\..\cocos2dx\support;..\..\cocos2dx\text_input_node;..\..\cocos2dx\textures;..\..\cocos2dx\tileMap_parallax_nodes;..\..\cocos2dx\touch_dispatcher;..\..\cocos2dx\platform;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;%(PreprocessorDefinitions) @@ -124,11 +124,15 @@ xcopy /Y /Q "$(SolutionDir)js\spidermonkey-win32\lib\*.*" "$(OutDir)" $(IntDir);%(AdditionalIncludeDirectories) - libcocos2d.lib;libGLESv2.lib;libCocosDenshion.lib;%(AdditionalDependencies) + libcocos2d.lib;libGLESv2.lib;libCocosDenshion.lib;js.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) Windows MachineX86 + + if not exist "$(OutDir)" mkdir "$(OutDir)" +xcopy /Y /Q "$(SolutionDir)js\spidermonkey-win32\lib\*.*" "$(OutDir)" + diff --git a/testjs/proj.win32/testjs.win32.vcxproj.user b/testjs/proj.win32/testjs.win32.vcxproj.user index 3ba81af9e4..314a27ae4d 100644 --- a/testjs/proj.win32/testjs.win32.vcxproj.user +++ b/testjs/proj.win32/testjs.win32.vcxproj.user @@ -4,4 +4,8 @@ $(ProjectDir)..\Resources WindowsLocalDebugger + + $(ProjectDir)..\Resources + WindowsLocalDebugger + \ No newline at end of file diff --git a/tests/proj.win32/test.win32.vcxproj b/tests/proj.win32/test.win32.vcxproj index 026c51d793..ca6f8ccc0c 100644 --- a/tests/proj.win32/test.win32.vcxproj +++ b/tests/proj.win32/test.win32.vcxproj @@ -91,10 +91,10 @@ Level3 ProgramDatabase - 4244;4996;%(DisableSpecificWarnings) + 4251;4244;4996;%(DisableSpecificWarnings) - libcocos2d.lib;libgles_cm.lib;libBox2d.lib;libchipmunk.lib;libcurl_imp.lib;libCocosDenshion.lib;%(AdditionalDependencies) + libGLESv2.lib;libcocos2d.lib;libBox2d.lib;libchipmunk.lib;libcurl_imp.lib;libCocosDenshion.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).exe $(OutDir);%(AdditionalLibraryDirectories) true From ff0dde984c11dace37b558d09632086abddf5f83 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 29 May 2012 18:29:56 +0800 Subject: [PATCH 007/257] fixed #1240: Updated vs2008 project setting (release target). --- HelloLua/proj.win32/HelloLua.win32.vcproj | 4 ++-- testjs/proj.win32/testjs.win32.vcproj | 7 ++++--- tests/proj.win32/test.win32.vcproj | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/HelloLua/proj.win32/HelloLua.win32.vcproj b/HelloLua/proj.win32/HelloLua.win32.vcproj index f5455bac3f..7d9805f419 100644 --- a/HelloLua/proj.win32/HelloLua.win32.vcproj +++ b/HelloLua/proj.win32/HelloLua.win32.vcproj @@ -135,7 +135,7 @@ /> Date: Wed, 30 May 2012 11:21:36 +0800 Subject: [PATCH 008/257] fixed #1266: use flag O_CREAT when creating named semaphore --- cocos2dx/textures/CCTextureCache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index 786b6f7c24..3df0890836 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -275,7 +275,7 @@ void CCTextureCache::addImageAsync(const char *path, CCObject *target, SEL_CallF if (s_pSem == NULL) { #if CC_ASYNC_TEXTURE_CACHE_USE_NAMED_SEMAPHORE - s_pSem = sem_open(CC_ASYNC_TEXTURE_CACHE_SEMAPHORE, O_CREAT | O_EXCL, 0644, 0); + s_pSem = sem_open(CC_ASYNC_TEXTURE_CACHE_SEMAPHORE, O_CREAT, 0644, 0); if( s_pSem == SEM_FAILED ) { CCLOG( "CCTextureCache async thread semaphore init error: %s\n", strerror( errno ) ); From 8203cf00bae28f699cadbb63d51db11d6ba4a4af Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 30 May 2012 13:37:36 +0800 Subject: [PATCH 009/257] use fonts/fps_images.png --- tests/tests/PerformanceTest/PerformanceParticleTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests/PerformanceTest/PerformanceParticleTest.cpp b/tests/tests/PerformanceTest/PerformanceParticleTest.cpp index f0ff2bacf3..343556470c 100644 --- a/tests/tests/PerformanceTest/PerformanceParticleTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceParticleTest.cpp @@ -95,7 +95,7 @@ void ParticleMainScene::initWithSubTest(int asubtest, int particles) addChild(infoLabel, 1, kTagInfoLayer); // particles on stage - CCLabelAtlas *labelAtlas = CCLabelAtlas::labelWithString("0000", "Images/fps_images.png", 16, 24, '.'); + CCLabelAtlas *labelAtlas = CCLabelAtlas::labelWithString("0000", "fonts/fps_images.png", 16, 24, '.'); addChild(labelAtlas, 0, kTagLabelAtlas); labelAtlas->setPosition(ccp(s.width-66,50)); From 895de701ba985d3895341ee858146e91b4a9b4f3 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 30 May 2012 14:24:59 +0800 Subject: [PATCH 010/257] fixed #1273: Crash appears after clicking closed button in TextureCacheTest. Also fixed a bug about memory leak in CCEGLView.cpp(win32). And updated build-win32.bat. --- build-win32.bat | 5 ++- cocos2dx/platform/win32/CCEGLView.cpp | 1 + cocos2dx/textures/CCTextureCache.cpp | 45 ++++++++++++++++----------- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/build-win32.bat b/build-win32.bat index 02f0052f04..ac57b491bd 100644 --- a/build-win32.bat +++ b/build-win32.bat @@ -46,6 +46,7 @@ set CC_TEST_BIN=tests.exe set CC_TEST_RES=..\tests\Resources\*.* set CC_HELLOWORLD_RES=..\HelloWorld\Resources\*.* set CC_HELLOLUA_RES=..\HelloLua\Resources\*.* +set CC_TESTJS_RES=..\testjs\Resources\*.* if not exist "%CC_TEST_BIN%" ( echo Can't find the binary "tests.exe", is there build error? @@ -59,6 +60,8 @@ echo. xcopy /E /Y /Q "%CC_TEST_RES%" . xcopy /E /Y /Q "%CC_HELLOWORLD_RES%" . xcopy /E /Y /Q "%CC_HELLOLUA_RES%" . +xcopy /E /Y /Q "%CC_TESTJS_RES%" . + call "%CC_TEST_BIN%" start http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Cocos2d-x_Application_Wizard_for_Visual_Studio_User_Guide goto EOF @@ -66,4 +69,4 @@ goto EOF :ERROR pause -:EOF \ No newline at end of file +:EOF diff --git a/cocos2dx/platform/win32/CCEGLView.cpp b/cocos2dx/platform/win32/CCEGLView.cpp index f58d480936..4ff9e89fb9 100644 --- a/cocos2dx/platform/win32/CCEGLView.cpp +++ b/cocos2dx/platform/win32/CCEGLView.cpp @@ -191,6 +191,7 @@ CCEGLView::CCEGLView() CCEGLView::~CCEGLView() { + CC_SAFE_DELETE(m_pEGL); } bool CCEGLView::Create(LPCTSTR pTitle, int w, int h) diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index 786b6f7c24..bd447244d8 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -65,10 +65,11 @@ typedef struct _ImageInfo static pthread_t s_loadingThread; -static pthread_mutex_t s_asyncStructQueueMutex; +static pthread_mutex_t s_asyncStructQueueMutex; static pthread_mutex_t s_ImageInfoMutex; static sem_t* s_pSem = NULL; +static unsigned long s_nAsyncRefCount = 0; #if CC_TARGET_PLATFORM == CC_PLATFORM_IOS #define CC_ASYNC_TEXTURE_CACHE_USE_NAMED_SEMAPHORE 1 @@ -84,10 +85,10 @@ static sem_t* s_pSem = NULL; #endif -static bool need_quit; +static bool need_quit = false; -static std::queue *s_pAsyncStructQueue; -static std::queue *s_pImageQueue; +static std::queue* s_pAsyncStructQueue = NULL; +static std::queue* s_pImageQueue = NULL; static CCImage::EImageFormat computeImageFormatType(string& filename) { @@ -187,6 +188,8 @@ static void* loadImage(void* data) sem_destroy(s_pSem); #endif s_pSem = NULL; + delete s_pAsyncStructQueue; + delete s_pImageQueue; } return 0; @@ -195,13 +198,14 @@ static void* loadImage(void* data) // implementation CCTextureCache // TextureCache - Alloc, Init & Dealloc -static CCTextureCache *g_sharedTextureCache; +static CCTextureCache *g_sharedTextureCache = NULL; CCTextureCache * CCTextureCache::sharedTextureCache() { if (!g_sharedTextureCache) + { g_sharedTextureCache = new CCTextureCache(); - + } return g_sharedTextureCache; } @@ -229,7 +233,6 @@ void CCTextureCache::purgeSharedTextureCache() CC_SAFE_RELEASE_NULL(g_sharedTextureCache); } - const char* CCTextureCache::description() { return CCString::stringWithFormat("", m_pTextures->count())->getCString(); @@ -298,11 +301,16 @@ void CCTextureCache::addImageAsync(const char *path, CCObject *target, SEL_CallF pthread_mutex_init(&s_ImageInfoMutex, NULL); pthread_create(&s_loadingThread, NULL, loadImage, NULL); - CCDirector::sharedDirector()->getScheduler()->scheduleSelector(schedule_selector(CCTextureCache::addImageAsyncCallBack), this, 0, false); - need_quit = false; } + if (0 == s_nAsyncRefCount) + { + CCDirector::sharedDirector()->getScheduler()->scheduleSelector(schedule_selector(CCTextureCache::addImageAsyncCallBack), this, 0, false); + } + + ++s_nAsyncRefCount; + if (target) { target->retain(); @@ -354,15 +362,8 @@ void CCTextureCache::addImageAsyncCallBack(ccTime dt) #endif #if CC_ENABLE_CACHE_TEXTTURE_DATA - // cache the texture file name - if (pImageInfo->imageType == CCImage::kFmtJpg) - { - VolatileTexture::addImageTexture(texture, filename, CCImage::kFmtJpg); - } - else - { - VolatileTexture::addImageTexture(texture, filename, CCImage::kFmtPng); - } + // cache the texture file name + VolatileTexture::addImageTexture(texture, filename, pImageInfo->imageType); #endif // cache the texture @@ -375,9 +376,15 @@ void CCTextureCache::addImageAsyncCallBack(ccTime dt) target->release(); } - delete pImage; + pImage->release(); delete pAsyncStruct; delete pImageInfo; + + --s_nAsyncRefCount; + if (0 == s_nAsyncRefCount) + { + CCDirector::sharedDirector()->getScheduler()->unscheduleSelector(schedule_selector(CCTextureCache::addImageAsyncCallBack), g_sharedTextureCache); + } } } From 265cb135ad524688aff47f9005fd163812896337 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 30 May 2012 14:27:30 +0800 Subject: [PATCH 011/257] fixed #1273: Passed 'this' to unscheduleSelector rather than 'g_sharedTextureCache'. --- cocos2dx/textures/CCTextureCache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index bd447244d8..288c8c4144 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -383,7 +383,7 @@ void CCTextureCache::addImageAsyncCallBack(ccTime dt) --s_nAsyncRefCount; if (0 == s_nAsyncRefCount) { - CCDirector::sharedDirector()->getScheduler()->unscheduleSelector(schedule_selector(CCTextureCache::addImageAsyncCallBack), g_sharedTextureCache); + CCDirector::sharedDirector()->getScheduler()->unscheduleSelector(schedule_selector(CCTextureCache::addImageAsyncCallBack), this); } } } From 4428810fd5147dac9f10d95d37d80c1976fba25e Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 30 May 2012 15:42:29 +0800 Subject: [PATCH 012/257] fixed some bugs --- cocos2dx/platform/ios/CCPlatformDefine.h | 10 +++------- cocos2dx/textures/CCTexture2D.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/cocos2dx/platform/ios/CCPlatformDefine.h b/cocos2dx/platform/ios/CCPlatformDefine.h index ab19688f60..789ea77e08 100644 --- a/cocos2dx/platform/ios/CCPlatformDefine.h +++ b/cocos2dx/platform/ios/CCPlatformDefine.h @@ -1,15 +1,11 @@ #ifndef __CCPLATFORMDEFINE_H__ #define __CCPLATFORMDEFINE_H__ +#include + #define CC_DLL -#define CC_ASSERT(cond) \ -if (! (cond)) \ -{ \ - char content[100]; \ - sprintf(content, "%s function:%s line:%d", __FILE__, __FUNCTION__, __LINE__ - 3); \ - CCMessageBox(content, "Assert error"); \ -} +#define CC_ASSERT(cond) assert(cond) #define CC_UNUSED_PARAM(unusedparam) (void)unusedparam diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index 9bbc5feeaf..3e7189f2e9 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -576,16 +576,16 @@ void CCTexture2D::PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied) void CCTexture2D::generateMipmap() { - CCAssert( m_uPixelsWide == ccNextPOT(m_uPixelsWide) && m_uPixelsHigh == ccNextPOT(m_uPixelsHigh), "Mimpap texture only works in POT textures"); + //CCAssert( m_uPixelsWide == ccNextPOT(m_uPixelsWide) && m_uPixelsHigh == ccNextPOT(m_uPixelsHigh), "Mimpap texture only works in POT textures"); ccGLBindTexture2D( m_uName ); glGenerateMipmap(GL_TEXTURE_2D); } void CCTexture2D::setTexParameters(ccTexParams *texParams) { - CCAssert( (m_uPixelsWide == ccNextPOT(m_uPixelsWide) && m_uPixelsHigh == ccNextPOT(m_uPixelsHigh)) || - (texParams->wrapS == GL_CLAMP_TO_EDGE && texParams->wrapT == GL_CLAMP_TO_EDGE), - "GL_CLAMP_TO_EDGE should be used in NPOT textures"); + //CCAssert( (m_uPixelsWide == ccNextPOT(m_uPixelsWide) && m_uPixelsHigh == ccNextPOT(m_uPixelsHigh)) || + //(texParams->wrapS == GL_CLAMP_TO_EDGE && texParams->wrapT == GL_CLAMP_TO_EDGE), + //"GL_CLAMP_TO_EDGE should be used in NPOT textures"); ccGLBindTexture2D( m_uName ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texParams->minFilter ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texParams->magFilter ); From 7115a7f3c93ad56dd52b06539ad682046b268fce Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 30 May 2012 16:09:19 +0800 Subject: [PATCH 013/257] issue #1275: Memory leaks in CCBReader and ActionsTest. --- cocos2dx/CCDirector.cpp | 2 ++ .../extensions/CCBReader/CCBCustomClass.cpp | 14 +++++++--- .../extensions/CCBReader/CCBCustomClass.h | 3 +++ .../extensions/CCBReader/CCBReader_v1.cpp | 26 +++++++++---------- .../extensions/CCBReader/CCBReader_v2.cpp | 20 +++++++------- tests/tests/ActionsTest/ActionsTest.cpp | 1 + 6 files changed, 40 insertions(+), 26 deletions(-) diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 9858066e95..4140a4d2db 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -54,6 +54,7 @@ THE SOFTWARE. #include "CCEGLView.h" #include "extensions/CCNotificationCenter/CCNotificationCenter.h" #include "extensions/CCTextureWatcher/CCTextureWatcher.h" +#include "extensions/CCBReader/CCBCustomClass.h" #include using namespace std; @@ -591,6 +592,7 @@ void CCDirector::purgeDirector() CCUserDefault::purgeSharedUserDefault(); extension::CCNotificationCenter::purgeNotificationCenter(); extension::CCTextureWatcher::purgeTextureWatcher(); + extension::CCBCustomClassFactory::purgeFactory(); ccGLInvalidateStateCache(); diff --git a/cocos2dx/extensions/CCBReader/CCBCustomClass.cpp b/cocos2dx/extensions/CCBReader/CCBCustomClass.cpp index 59d299d4e2..9d886fd8ba 100644 --- a/cocos2dx/extensions/CCBReader/CCBCustomClass.cpp +++ b/cocos2dx/extensions/CCBReader/CCBCustomClass.cpp @@ -26,7 +26,7 @@ USING_NS_CC_EXT; -static CCBCustomClassFactory g_FactoryInstance; +static CCBCustomClassFactory* g_pFactoryInstance = NULL; // CCBCustomClassFactory CCBCustomClassFactory::CCBCustomClassFactory() @@ -41,8 +41,16 @@ CCBCustomClassFactory::~CCBCustomClassFactory() CCBCustomClassFactory* CCBCustomClassFactory::sharedFactory() { - // TBD: don't use static global variable, so ugly - return &g_FactoryInstance; + if (g_pFactoryInstance == NULL) + { + g_pFactoryInstance = new CCBCustomClassFactory(); + } + return g_pFactoryInstance; +} + +void CCBCustomClassFactory::purgeFactory() +{ + CC_SAFE_DELETE(g_pFactoryInstance); } bool CCBCustomClassFactory::registCustomClass(const char* name, FUNC_CUSTON_CLASS_CREATOR pfnCreator) diff --git a/cocos2dx/extensions/CCBReader/CCBCustomClass.h b/cocos2dx/extensions/CCBReader/CCBCustomClass.h index 4c5dba18db..7f87d7574c 100644 --- a/cocos2dx/extensions/CCBReader/CCBCustomClass.h +++ b/cocos2dx/extensions/CCBReader/CCBCustomClass.h @@ -79,6 +79,9 @@ public: /** get the singleton */ static CCBCustomClassFactory* sharedFactory(); + /** purge the singleton */ + static void purgeFactory(); + /** Note that you should regist custom class before invoke CCBReader::nodeGraphFromFile For example: CCBCustomClassFactory::sharedFactory()->registCustomClass("HelloCocosBuilder", diff --git a/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp b/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp index daaca0b9c4..0b0a5e5d14 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp @@ -34,19 +34,19 @@ USING_NS_CC_EXT; int CCBReader::intValFromDict(CCDictionary* dict, const std::string key) { CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); - return valueString->intValue(); + return valueString? valueString->intValue() : 0; } float CCBReader::floatValFromDict(CCDictionary* dict, const std::string key) { CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); - return valueString->floatValue(); + return valueString? valueString->floatValue() : 0.0f; } bool CCBReader::boolValFromDict(CCDictionary* dict, const std::string key) { CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); - return (bool) valueString->intValue(); + return (valueString && valueString->intValue()) ? true : false; } CCPoint CCBReader::pointValFromDict(CCDictionary* dict, const std::string key) @@ -274,6 +274,7 @@ CCNode* CCBReader::createCustomClassWithName(CCString* className) { CCBCustomClassProtocol* pNewClass = CCBCustomClassFactory::sharedFactory()->createCustomClassWithName(className->getCString()); pRetVal = dynamic_cast(pNewClass); + pRetVal->autorelease(); } return pRetVal; @@ -371,9 +372,11 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; CCParticleSystem* sys = new CCParticleSystemQuad(); + sys->autorelease(); sys->initWithTotalParticles(2048); sys->setTexture(CCTextureCache::sharedTextureCache()->addImage(spriteFile->m_sString.c_str())); - delete spriteFile; + CC_SAFE_RELEASE_NULL(spriteFile); + node = (CCNode*)sys; setPropsForNode((CCNode*)node, (CCDictionary*) props, extraProps); @@ -414,9 +417,9 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr } //deallocate - CC_SAFE_DELETE(spriteFileNormal); - CC_SAFE_DELETE(spriteFileSelected); - CC_SAFE_DELETE(spriteFileDisabled); + CC_SAFE_RELEASE_NULL(spriteFileNormal); + CC_SAFE_RELEASE_NULL(spriteFileSelected); + CC_SAFE_RELEASE_NULL(spriteFileDisabled); if (!spriteNormal) spriteNormal = CCSprite::spriteWithFile("missing-texture.png"); if (!spriteSelected) spriteSelected = CCSprite::spriteWithFile("missing-texture.png"); @@ -468,9 +471,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), fontFile->m_sString.c_str() ); - - delete fontFile; - fontFile = 0; + CC_SAFE_RELEASE_NULL(fontFile); if (!node) node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), "missing-font.fnt"); @@ -496,7 +497,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr } else { - printf("spriteFile->m_string.cstr is %s\n", spriteFile->m_sString.c_str()) ; + CCLOG("spriteFile->m_string.cstr is %s\n", spriteFile->m_sString.c_str()) ; node = (CCNode*)CCSprite::spriteWithFile(spriteFile->m_sString.c_str()); } @@ -699,9 +700,8 @@ CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner) ccbFileDir = ccbFilePath.substr(0, lastSlash) + "/"; } - CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(ccbFilePath.c_str()); + CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFile(ccbFilePath.c_str()); CCAssert(dict != NULL, "CCBReader: file not found"); - return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner); } diff --git a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp index 9f72761d9e..64e1ae0692 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp @@ -274,6 +274,7 @@ CCNode* CCBReader::createCustomClassWithName(CCString* className) { CCBCustomClassProtocol* pNewClass = CCBCustomClassFactory::sharedFactory()->createCustomClassWithName(className->getCString()); pRetVal = dynamic_cast(pNewClass); + pRetVal->autorelease(); } return pRetVal; @@ -432,9 +433,11 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; CCParticleSystem* sys = new CCParticleSystemQuad(); + sys->autorelease(); sys->initWithTotalParticles(2048); sys->setTexture(CCTextureCache::sharedTextureCache()->addImage(spriteFile->m_sString.c_str())); - delete spriteFile; + CC_SAFE_RELEASE_NULL(spriteFile); + node = (CCNode*)sys; setPropsForNode((CCNode*)node, (CCDictionary*) props, extraProps); @@ -475,9 +478,9 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr } //deallocate - CC_SAFE_DELETE(spriteFileNormal); - CC_SAFE_DELETE(spriteFileSelected); - CC_SAFE_DELETE(spriteFileDisabled); + CC_SAFE_RELEASE_NULL(spriteFileNormal); + CC_SAFE_RELEASE_NULL(spriteFileSelected); + CC_SAFE_RELEASE_NULL(spriteFileDisabled); if (!spriteNormal) spriteNormal = CCSprite::spriteWithFile("missing-texture.png"); if (!spriteSelected) spriteSelected = CCSprite::spriteWithFile("missing-texture.png"); @@ -529,9 +532,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), fontFile->m_sString.c_str() ); - - delete fontFile; - fontFile = 0; + CC_SAFE_RELEASE_NULL(fontFile); if (!node) node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), "missing-font.fnt"); @@ -557,7 +558,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr } else { - printf("spriteFile->m_string.cstr is %s\n", spriteFile->m_sString.c_str()) ; + CCLOG("spriteFile->m_string.cstr is %s\n", spriteFile->m_sString.c_str()) ; node = (CCNode*)CCSprite::spriteWithFile(spriteFile->m_sString.c_str()); } @@ -760,9 +761,8 @@ CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner) ccbFileDir = ccbFilePath.substr(0, lastSlash) + "/"; } - CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(ccbFilePath.c_str()); + CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFile(ccbFilePath.c_str()); CCAssert(dict != NULL, "CCBReader: file not found"); - return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner); } diff --git a/tests/tests/ActionsTest/ActionsTest.cpp b/tests/tests/ActionsTest/ActionsTest.cpp index 1043762c3c..90e58efb8a 100644 --- a/tests/tests/ActionsTest/ActionsTest.cpp +++ b/tests/tests/ActionsTest/ActionsTest.cpp @@ -1260,6 +1260,7 @@ void Issue1305::log(CCNode* pSender) void Issue1305::onExit() { m_pSpriteTmp->release(); + ActionsDemo::onExit(); } void Issue1305::addSprite(ccTime dt) From 5b4495d982ab77a4b9ba028fbd7dc2db9882f01d Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 30 May 2012 16:26:47 +0800 Subject: [PATCH 014/257] Opened assert for CCTexture2D::setTexParameters and generateMipmap. --- cocos2dx/textures/CCTexture2D.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index 3e7189f2e9..9bbc5feeaf 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -576,16 +576,16 @@ void CCTexture2D::PVRImagesHavePremultipliedAlpha(bool haveAlphaPremultiplied) void CCTexture2D::generateMipmap() { - //CCAssert( m_uPixelsWide == ccNextPOT(m_uPixelsWide) && m_uPixelsHigh == ccNextPOT(m_uPixelsHigh), "Mimpap texture only works in POT textures"); + CCAssert( m_uPixelsWide == ccNextPOT(m_uPixelsWide) && m_uPixelsHigh == ccNextPOT(m_uPixelsHigh), "Mimpap texture only works in POT textures"); ccGLBindTexture2D( m_uName ); glGenerateMipmap(GL_TEXTURE_2D); } void CCTexture2D::setTexParameters(ccTexParams *texParams) { - //CCAssert( (m_uPixelsWide == ccNextPOT(m_uPixelsWide) && m_uPixelsHigh == ccNextPOT(m_uPixelsHigh)) || - //(texParams->wrapS == GL_CLAMP_TO_EDGE && texParams->wrapT == GL_CLAMP_TO_EDGE), - //"GL_CLAMP_TO_EDGE should be used in NPOT textures"); + CCAssert( (m_uPixelsWide == ccNextPOT(m_uPixelsWide) && m_uPixelsHigh == ccNextPOT(m_uPixelsHigh)) || + (texParams->wrapS == GL_CLAMP_TO_EDGE && texParams->wrapT == GL_CLAMP_TO_EDGE), + "GL_CLAMP_TO_EDGE should be used in NPOT textures"); ccGLBindTexture2D( m_uName ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texParams->minFilter ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texParams->magFilter ); From 93d1879a566b7dcf272755c2573da2f5d97247ad Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 30 May 2012 16:34:42 +0800 Subject: [PATCH 015/257] fixed #1277: CCToggleVisibility should implement copyWithZone. --- cocos2dx/actions/CCActionInstant.cpp | 30 +++++++++++++++++++++++----- cocos2dx/actions/CCActionInstant.h | 1 + 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/cocos2dx/actions/CCActionInstant.cpp b/cocos2dx/actions/CCActionInstant.cpp index 0136d493e2..2782314e4f 100644 --- a/cocos2dx/actions/CCActionInstant.cpp +++ b/cocos2dx/actions/CCActionInstant.cpp @@ -103,7 +103,7 @@ CCObject* CCShow::copyWithZone(CCZone *pZone) { pZone = pNewZone = new CCZone(pRet); } - CCFiniteTimeAction::copyWithZone(pZone); + CCActionInstant::copyWithZone(pZone); CC_SAFE_DELETE(pNewZone); return pRet; } @@ -141,7 +141,7 @@ CCObject* CCHide::copyWithZone(CCZone *pZone) { pZone = pNewZone = new CCZone(pRet); } - CCFiniteTimeAction::copyWithZone(pZone); + CCActionInstant::copyWithZone(pZone); CC_SAFE_DELETE(pNewZone); return pRet; } @@ -149,21 +149,41 @@ CCObject* CCHide::copyWithZone(CCZone *pZone) { // // ToggleVisibility // -CCToggleVisibility * CCToggleVisibility::action() { +CCToggleVisibility * CCToggleVisibility::action() +{ CCToggleVisibility *pRet = new CCToggleVisibility(); - if (pRet) { + if (pRet) + { pRet->autorelease(); } return pRet; } -void CCToggleVisibility::update(ccTime time) { +void CCToggleVisibility::update(ccTime time) +{ CC_UNUSED_PARAM(time); m_pTarget->setIsVisible(!m_pTarget->getIsVisible()); } +CCObject* CCToggleVisibility::copyWithZone(CCZone *pZone) +{ + CCZone *pNewZone = NULL; + CCToggleVisibility *pRet = NULL; + + if (pZone && pZone->m_pCopyObject) { + pRet = (CCToggleVisibility*) (pZone->m_pCopyObject); + } else { + pRet = new CCToggleVisibility(); + pZone = pNewZone = new CCZone(pRet); + } + + CCActionInstant::copyWithZone(pZone); + CC_SAFE_DELETE(pNewZone); + return pRet; +} + // // FlipX // diff --git a/cocos2dx/actions/CCActionInstant.h b/cocos2dx/actions/CCActionInstant.h index dc19e79823..87b0885965 100644 --- a/cocos2dx/actions/CCActionInstant.h +++ b/cocos2dx/actions/CCActionInstant.h @@ -96,6 +96,7 @@ public: virtual ~CCToggleVisibility(){} //super method virtual void update(ccTime time); + virtual CCObject* copyWithZone(CCZone *pZone); public: //override static method /** Allocates and initializes the action */ From 922f7544ad4685977eea06062993b7ff4cb15d25 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 30 May 2012 16:55:46 +0800 Subject: [PATCH 016/257] Updated TouchesTest. --- tests/tests/TouchesTest/TouchesTest.cpp | 18 ++++++++++-------- tests/tests/TouchesTest/TouchesTest.h | 6 ++++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/tests/tests/TouchesTest/TouchesTest.cpp b/tests/tests/TouchesTest/TouchesTest.cpp index 282823e720..d91acdcc45 100644 --- a/tests/tests/TouchesTest/TouchesTest.cpp +++ b/tests/tests/TouchesTest/TouchesTest.cpp @@ -9,7 +9,7 @@ enum tagPlayer kLowPlayer } PlayerTouches; -#define kStatusBarHeight 20.0f +#define kStatusBarHeight 0.0f //20.0f //#define k1UpperLimit (480.0f - kStatusBarHeight) enum @@ -42,10 +42,12 @@ void PongScene::MainMenuCallback(CCObject* pSender) //------------------------------------------------------------------ PongLayer::PongLayer() { + m_tWinSize = CCDirector::sharedDirector()->getWinSize(); + m_ballStartingVelocity = CCPointMake(20.0f, -100.0f); m_ball = Ball::ballWithTexture( CCTextureCache::sharedTextureCache()->addImage(s_Ball) ); - m_ball->setPosition( CCPointMake(160.0f, 240.0f) ); + m_ball->setPosition( CCPointMake(m_tWinSize.width/2, m_tWinSize.height/2) ); m_ball->setVelocity( m_ballStartingVelocity ); addChild( m_ball ); m_ball->retain(); @@ -55,19 +57,19 @@ PongLayer::PongLayer() CCArray *paddlesM = CCArray::arrayWithCapacity(4); Paddle* paddle = Paddle::paddleWithTexture(paddleTexture); - paddle->setPosition( CCPointMake(160, 15) ); + paddle->setPosition( CCPointMake(m_tWinSize.width/2, 15) ); paddlesM->addObject( paddle ); paddle = Paddle::paddleWithTexture( paddleTexture ); - paddle->setPosition( CCPointMake(160, 480 - kStatusBarHeight - 15) ); + paddle->setPosition( CCPointMake(m_tWinSize.width/2, m_tWinSize.height - kStatusBarHeight - 15) ); paddlesM->addObject( paddle ); paddle = Paddle::paddleWithTexture( paddleTexture ); - paddle->setPosition( CCPointMake(160, 100) ); + paddle->setPosition( CCPointMake(m_tWinSize.width/2, 100) ); paddlesM->addObject( paddle ); paddle = Paddle::paddleWithTexture( paddleTexture ); - paddle->setPosition( CCPointMake(160, 480 - kStatusBarHeight - 100) ); + paddle->setPosition( CCPointMake(m_tWinSize.width/2, m_tWinSize.height - kStatusBarHeight - 100) ); paddlesM->addObject( paddle ); m_paddles = (CCArray*)paddlesM->copy(); @@ -96,7 +98,7 @@ void PongLayer::resetAndScoreBallForPlayer(int player) { m_ballStartingVelocity = ccpMult(m_ballStartingVelocity, -1.1f); m_ball->setVelocity( m_ballStartingVelocity ); - m_ball->setPosition( CCPointMake(160.0f, 240.0f) ); + m_ball->setPosition( CCPointMake(m_tWinSize.width/2, m_tWinSize.height/2) ); // TODO -- scoring } @@ -117,7 +119,7 @@ void PongLayer::doStep(ccTime delta) m_ball->collideWithPaddle( paddle ); } - if (m_ball->getPosition().y > 480 - kStatusBarHeight + m_ball->radius()) + if (m_ball->getPosition().y > m_tWinSize.height - kStatusBarHeight + m_ball->radius()) resetAndScoreBallForPlayer( kLowPlayer ); else if (m_ball->getPosition().y < -m_ball->radius()) resetAndScoreBallForPlayer( kHighPlayer ); diff --git a/tests/tests/TouchesTest/TouchesTest.h b/tests/tests/TouchesTest/TouchesTest.h index 41c6338dd2..571a50f625 100644 --- a/tests/tests/TouchesTest/TouchesTest.h +++ b/tests/tests/TouchesTest/TouchesTest.h @@ -19,9 +19,11 @@ public: class Ball; class PongLayer : public CCLayer { - Ball* m_ball; +private: + CCSize m_tWinSize; + Ball* m_ball; CCArray* m_paddles; - CCPoint m_ballStartingVelocity; + CCPoint m_ballStartingVelocity; public: PongLayer(); ~PongLayer(); From 6be44ad7b0f9671906247e4ef4e5dc80e3a751c4 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 30 May 2012 18:30:11 +0800 Subject: [PATCH 017/257] fixed #1279: NodeNonOpaqueTest can't be shown correctly. --- cocos2dx/platform/CCImageCommon_cpp.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cocos2dx/platform/CCImageCommon_cpp.h b/cocos2dx/platform/CCImageCommon_cpp.h index 1b42085847..cdc9272109 100644 --- a/cocos2dx/platform/CCImageCommon_cpp.h +++ b/cocos2dx/platform/CCImageCommon_cpp.h @@ -244,8 +244,10 @@ bool CCImage::_initWithJpgData(void * data, int nSize) while( cinfo.output_scanline < cinfo.image_height ) { jpeg_read_scanlines( &cinfo, row_pointer, 1 ); - for( i=0; i Date: Wed, 30 May 2012 18:31:20 +0800 Subject: [PATCH 018/257] fix some bug --- .../gen/org/cocos2dx/hellolua/R.java | 26 ------------------- HelloLua/proj.android/jni/helloworld/main.cpp | 2 +- HelloLua/proj.android/project.properties | 2 +- .../gen/org/cocos2dx/application/R.java | 26 ------------------- HelloWorld/proj.android/project.properties | 2 +- cocos2dx/platform/ios/CCEGLView.h | 1 + cocos2dx/platform/ios/CCEGLView.mm | 4 +++ cocos2dx/touch_dispatcher/CCTouchHandler.cpp | 2 -- .../gen/org/cocos2dx/tests/R.java | 26 ------------------- .../project.pbxproj.REMOVED.git-id | 2 +- 10 files changed, 9 insertions(+), 84 deletions(-) delete mode 100644 HelloLua/proj.android/gen/org/cocos2dx/hellolua/R.java delete mode 100644 HelloWorld/proj.android/gen/org/cocos2dx/application/R.java delete mode 100644 tests/proj.android/gen/org/cocos2dx/tests/R.java diff --git a/HelloLua/proj.android/gen/org/cocos2dx/hellolua/R.java b/HelloLua/proj.android/gen/org/cocos2dx/hellolua/R.java deleted file mode 100644 index ba4eac96cd..0000000000 --- a/HelloLua/proj.android/gen/org/cocos2dx/hellolua/R.java +++ /dev/null @@ -1,26 +0,0 @@ -/* AUTO-GENERATED FILE. DO NOT MODIFY. - * - * This class was automatically generated by the - * aapt tool from the resource data it found. It - * should not be modified by hand. - */ - -package org.cocos2dx.hellolua; - -public final class R { - public static final class attr { - } - public static final class drawable { - public static final int icon=0x7f020000; - } - public static final class id { - public static final int test_demo_gl_surfaceview=0x7f050001; - public static final int textField=0x7f050000; - } - public static final class layout { - public static final int game_demo=0x7f030000; - } - public static final class string { - public static final int app_name=0x7f040000; - } -} diff --git a/HelloLua/proj.android/jni/helloworld/main.cpp b/HelloLua/proj.android/jni/helloworld/main.cpp index e4d222db90..c51cd9e0db 100644 --- a/HelloLua/proj.android/jni/helloworld/main.cpp +++ b/HelloLua/proj.android/jni/helloworld/main.cpp @@ -27,7 +27,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi CCEGLView *view = &CCEGLView::sharedOpenGLView(); view->setFrameSize(w, h); // set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line. - // view.setDesignResolutionSize(480, 320); + view->setDesignResolutionSize(480, 320); AppDelegate *pAppDelegate = new AppDelegate(); CCApplication::sharedApplication().run(); diff --git a/HelloLua/proj.android/project.properties b/HelloLua/proj.android/project.properties index f049142c17..ea89160e01 100644 --- a/HelloLua/proj.android/project.properties +++ b/HelloLua/proj.android/project.properties @@ -8,4 +8,4 @@ # project structure. # Project target. -target=android-10 +target=android-8 diff --git a/HelloWorld/proj.android/gen/org/cocos2dx/application/R.java b/HelloWorld/proj.android/gen/org/cocos2dx/application/R.java deleted file mode 100644 index 979d1ae7fc..0000000000 --- a/HelloWorld/proj.android/gen/org/cocos2dx/application/R.java +++ /dev/null @@ -1,26 +0,0 @@ -/* AUTO-GENERATED FILE. DO NOT MODIFY. - * - * This class was automatically generated by the - * aapt tool from the resource data it found. It - * should not be modified by hand. - */ - -package org.cocos2dx.application; - -public final class R { - public static final class attr { - } - public static final class drawable { - public static final int icon=0x7f020000; - } - public static final class id { - public static final int helloworld_gl_surfaceview=0x7f050001; - public static final int textField=0x7f050000; - } - public static final class layout { - public static final int helloworld_demo=0x7f030000; - } - public static final class string { - public static final int app_name=0x7f040000; - } -} diff --git a/HelloWorld/proj.android/project.properties b/HelloWorld/proj.android/project.properties index f049142c17..ea89160e01 100644 --- a/HelloWorld/proj.android/project.properties +++ b/HelloWorld/proj.android/project.properties @@ -8,4 +8,4 @@ # project structure. # Project target. -target=android-10 +target=android-8 diff --git a/cocos2dx/platform/ios/CCEGLView.h b/cocos2dx/platform/ios/CCEGLView.h index fa89874119..e1aaf1bc9d 100644 --- a/cocos2dx/platform/ios/CCEGLView.h +++ b/cocos2dx/platform/ios/CCEGLView.h @@ -43,6 +43,7 @@ public: bool canSetContentScaleFactor(); bool isIpad(); void setContentScaleFactor(float contentScaleFactor); + virtual CCSize getFrameSize(); // keep compatible void end(); diff --git a/cocos2dx/platform/ios/CCEGLView.mm b/cocos2dx/platform/ios/CCEGLView.mm index 7a4fd16bed..4e62451c56 100644 --- a/cocos2dx/platform/ios/CCEGLView.mm +++ b/cocos2dx/platform/ios/CCEGLView.mm @@ -83,6 +83,10 @@ void CCEGLView::swapBuffers() [[EAGLView sharedEGLView] swapBuffers]; } +CCSize CCEGLView::getFrameSize() +{ + assert(false); +} void CCEGLView::setIMEKeyboardState(bool bOpen) { diff --git a/cocos2dx/touch_dispatcher/CCTouchHandler.cpp b/cocos2dx/touch_dispatcher/CCTouchHandler.cpp index 7796dee877..224b1c1003 100644 --- a/cocos2dx/touch_dispatcher/CCTouchHandler.cpp +++ b/cocos2dx/touch_dispatcher/CCTouchHandler.cpp @@ -40,8 +40,6 @@ void CCTouchHandler::setDelegate(CCTouchDelegate *pDelegate) dynamic_cast(pDelegate)->retain(); } - dynamic_cast(pDelegate)->retain(); - if (m_pDelegate) { dynamic_cast(m_pDelegate)->release(); diff --git a/tests/proj.android/gen/org/cocos2dx/tests/R.java b/tests/proj.android/gen/org/cocos2dx/tests/R.java deleted file mode 100644 index 298ffe08a6..0000000000 --- a/tests/proj.android/gen/org/cocos2dx/tests/R.java +++ /dev/null @@ -1,26 +0,0 @@ -/* AUTO-GENERATED FILE. DO NOT MODIFY. - * - * This class was automatically generated by the - * aapt tool from the resource data it found. It - * should not be modified by hand. - */ - -package org.cocos2dx.tests; - -public final class R { - public static final class attr { - } - public static final class drawable { - public static final int icon=0x7f020000; - } - public static final class id { - public static final int test_demo_gl_surfaceview=0x7f050001; - public static final int textField=0x7f050000; - } - public static final class layout { - public static final int test_demo=0x7f030000; - } - public static final class string { - public static final int app_name=0x7f040000; - } -} diff --git a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id index 6ecbb29baf..6fb416ba08 100644 --- a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -6a7a307611b24e912fd48f6075ceab240a16305a \ No newline at end of file +14a32fb3ba86f267841b87b9a63e906ce7a64969 \ No newline at end of file From 56ea340314b5351b6b3b0b778f0616280ce1c1e7 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 30 May 2012 11:28:50 -0700 Subject: [PATCH 019/257] Current state of the CCB(I)Reader (dysfunctional due to CCLabelBMFont problems). --- cocos2dx/extensions/CCBIReader/CCBReader.cpp | 327 ++++++++ cocos2dx/extensions/CCBIReader/CCBReader.h | 128 +++ .../CCBIReader/CCLabelBMFontLoader.cpp | 41 + .../CCBIReader/CCLabelBMFontLoader.h | 22 + .../CCBIReader/CCLayerColorLoader.cpp | 36 + .../CCBIReader/CCLayerColorLoader.h | 22 + .../CCBIReader/CCLayerGradientLoader.cpp | 55 ++ .../CCBIReader/CCLayerGradientLoader.h | 23 + .../extensions/CCBIReader/CCLayerLoader.cpp | 30 + .../extensions/CCBIReader/CCLayerLoader.h | 20 + .../extensions/CCBIReader/CCNodeLoader.cpp | 791 ++++++++++++++++++ cocos2dx/extensions/CCBIReader/CCNodeLoader.h | 80 ++ .../extensions/CCBIReader/CCSpriteLoader.cpp | 55 ++ .../extensions/CCBIReader/CCSpriteLoader.h | 24 + 14 files changed, 1654 insertions(+) create mode 100644 cocos2dx/extensions/CCBIReader/CCBReader.cpp create mode 100644 cocos2dx/extensions/CCBIReader/CCBReader.h create mode 100644 cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.cpp create mode 100644 cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h create mode 100644 cocos2dx/extensions/CCBIReader/CCLayerColorLoader.cpp create mode 100644 cocos2dx/extensions/CCBIReader/CCLayerColorLoader.h create mode 100644 cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.cpp create mode 100644 cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.h create mode 100644 cocos2dx/extensions/CCBIReader/CCLayerLoader.cpp create mode 100644 cocos2dx/extensions/CCBIReader/CCLayerLoader.h create mode 100644 cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp create mode 100644 cocos2dx/extensions/CCBIReader/CCNodeLoader.h create mode 100644 cocos2dx/extensions/CCBIReader/CCSpriteLoader.cpp create mode 100644 cocos2dx/extensions/CCBIReader/CCSpriteLoader.h diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.cpp b/cocos2dx/extensions/CCBIReader/CCBReader.cpp new file mode 100644 index 0000000000..1db1d0a3ad --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCBReader.cpp @@ -0,0 +1,327 @@ +#include "CCNodeLoader.h" +#include "CCLayerLoader.h" +#include "CCLayerColorLoader.h" +#include "CCLayerGradientLoader.h" +#include "CCLabelBMFontLoader.h" +#include "CCSpriteLoader.h" +#include "CCBReader.h" +#include + +using namespace cocos2d; +using namespace cocos2d::extension; + +CCBReader::CCBReader() { + this->registerCCNodeLoader("CCNode", new CCNodeLoader()); + this->registerCCNodeLoader("CCLayer", new CCLayerLoader()); + this->registerCCNodeLoader("CCLayerColor", new CCLayerColorLoader()); + this->registerCCNodeLoader("CCLayerGradient", new CCLayerGradientLoader()); + this->registerCCNodeLoader("CCSprite", new CCSpriteLoader()); + this->registerCCNodeLoader("CCLabelBMFont", new CCLabelBMFontLoader()); +} + +void CCBReader::registerCCNodeLoader(std::string pClassName, CCNodeLoader * pCCNodeLoader) { + this->mCCNodeLoaders.insert(std::pair(pClassName, pCCNodeLoader)); +} + +CCNodeLoader * CCBReader::getCCNodeLoader(std::string pClassName) { + std::map::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName); + assert(ccNodeLoadersIterator != this->mCCNodeLoaders.end()); + return ccNodeLoadersIterator->second; +} + +CCBReader::~CCBReader() { + if(this->mBytes) { + delete this->mBytes; + this->mBytes = NULL; + } +} + +CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBFileName, CCNode * pOwner) { + return this->readNodeGraphFromFile(pCCBFileName, pOwner, CCDirector::sharedDirector()->getWinSize()); +} + +CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBFileName, CCNode * pOwner, CCSize pParentSize) { + const char * path = CCFileUtils::fullPathFromRelativePath(pCCBFileName); + + CCFileUtils::ccLoadFileIntoMemory(path, &this->mBytes); + + this->mCurrentByte = 0; + this->mCurrentBit = 0; + this->mOwner = pOwner; + this->mRootContainerSize = pParentSize; + + if(!this->readHeader()) { + return NULL; + } + + if(!this->readStringCache()) { + return NULL; + } + + return this->readNodeGraph(); +} + +bool CCBReader::readHeader() { + /* If no bytes loaded, don't crash about it. */ + if(this->mBytes == NULL) { + return false; + } + + /* Read magic bytes */ + int magicBytes = *((int*)(this->mBytes + this->mCurrentByte)); + this->mCurrentByte += 4; + + if(magicBytes != 'ccbi') { + return false; + } + + /* Read version. */ + int version = this->readInt(false); + if(version != kCCBVersion) { + CCLog("WARNING! Incompatible ccbi file version (file: %d reader: %d)", version, kCCBVersion); + return false; + } + + return true; +} + +bool CCBReader::readStringCache() { + int numStrings = this->readInt(false); + + for(int i = 0; i < numStrings; i++) { + std::string string = this->readUTF8(); + this->mStringCache.push_back(string); + } + + return true; +} + +std::string CCBReader::readUTF8() { + int b0 = this->readByte(); + int b1 = this->readByte(); + + int numBytes = b0 << 8 | b1; + + const char * ptr = (const char*) (this->mBytes + this->mCurrentByte); + std::string str(ptr, numBytes); + + this->mCurrentByte += numBytes; + + return str; +} + +unsigned char CCBReader::readByte() { + unsigned char byte = this->mBytes[this->mCurrentByte]; + this->mCurrentByte++; + return byte; +} + +bool CCBReader::readBool() { + return this->readByte(); +} + +int CCBReader::readInt(bool pSign) { + int numBits = 0; + while(!this->getBit()) { + numBits++; + } + + long long current = 0; + for(int a = numBits - 1; a >= 0; a--) { + if(this->getBit()) { + current |= 1 << a; + } + } + current |= 1 << numBits; + + int num; + if(pSign) { + int s = current % 2; + if(s) { + num = (int)(current / 2); + } else { + num = (int)(-current / 2); + } + } else { + num = current - 1; + } + + this->alignBits(); + + return num; +} + + +float CCBReader::readFloat() { + unsigned char type = this->readByte(); + + switch (type) { + case kCCBFloat0: + return 0; + case kCCBFloat1: + return 1; + case kCCBFloatMinus1: + return -1; + case kCCBFloat05: + return 0.5f; + case kCCBFloatInteger: + return this->readInt(true); + default: + /* using a memcpy since the compiler isn't + * doing the float ptr math correctly on device. + * TODO still applies in C++ ? */ + float * pF = (float*)(this->mBytes + this->mCurrentByte); + float f = 0; + memcpy(&f, pF, sizeof(float)); + this->mCurrentByte += 4; + return f; + } +} + + +bool CCBReader::getBit() { + bool bit; + unsigned char byte = *(this->mBytes + this->mCurrentByte); + if(byte & (1 << this->mCurrentBit)) { + bit = true; + } else { + bit = false; + } + + this->mCurrentBit++; + + if(this->mCurrentBit >= 8) { + this->mCurrentBit = 0; + this->mCurrentByte++; + } + + return bit; +} + +void CCBReader::alignBits() { + if(this->mCurrentBit) { + this->mCurrentBit = 0; + this->mCurrentByte++; + } +} + +std::string CCBReader::readCachedString() { + int i = this->readInt(false); + return this->mStringCache[i]; +} + +CCNode * CCBReader::readNodeGraph(CCNode * pParent) { + // Read class name + std::string className = this->readCachedString(); + + int memberVarAssignmentType = this->readInt(false); + std::string memberVarAssignmentName; + if(memberVarAssignmentType) { + memberVarAssignmentName = this->readCachedString(); + } + + CCNodeLoader * ccNodeLoader = this->getCCNodeLoader(className); + CCNode * node = ccNodeLoader->loadCCNode(pParent, this); + + // Set root node + if(!this->mRootNode) { + this->mRootNode = node; // TODO retain? + } + + // TODO + /* + // Assign to variable (if applicable) + if (memberVarAssignmentType) + { + id target = NULL; + if (memberVarAssignmentType == kCCBTargetTypeDocumentRoot) target = rootNode; + else if (memberVarAssignmentType == kCCBTargetTypeOwner) target = owner; + + if (target) + { + Ivar ivar = class_getInstanceVariable([target class],[memberVarAssignmentName UTF8String]); + if (ivar) + { + object_setIvar(target,ivar,node); + } + else + { + NSLog(@"CCBReader: Couldn't find member variable: %@", memberVarAssignmentName); + } + } + } + */ + + // Read and add children + int numChildren = this->readInt(false); + for(int i = 0; i < numChildren; i++) { + CCNode * child = this->readNodeGraph(node); + node->addChild(child); + } + + + // TODO + /* + // Call didLoadFromCCB + if ([node respondsToSelector:@selector(didLoadFromCCB)]) + { + [node performSelector:@selector(didLoadFromCCB)]; + } + */ + + return node; +} + +CCNode * CCBReader::readNodeGraph() { + return this->readNodeGraph(NULL); +} + +CCNode * CCBReader::getOwner() { + return this->mOwner; +} + +CCSize CCBReader::getContainerSize(CCNode * pNode) { + if(pNode) { + return pNode->getContentSize(); + } else { + return this->mRootContainerSize; + } +} + +std::string CCBReader::lastPathComponent(std::string pPath) { + int slashPos = pPath.find_last_of("/"); + if (slashPos != std::string::npos) { + return pPath.substr(slashPos + 1, pPath.length() - slashPos); + } + return pPath; +} + +std::string CCBReader::deletePathExtension(std::string pPath) { + int dotPos = pPath.find_last_of("."); + if (dotPos != std::string::npos) { + return pPath.substr(0, dotPos); + } + return pPath; +} + +bool CCBReader::isSpriteSheetLoaded(std::string pSpriteSheet) { + return this->mLoadedSpriteSheets.find(pSpriteSheet) != this->mLoadedSpriteSheets.end(); +} + +void CCBReader::addLoadedSpriteSheet(std::string pSpriteSheet) { + this->mLoadedSpriteSheets.insert(pSpriteSheet); +} + +std::string CCBReader::toLowerCase(std::string pString) { + std::string copy(pString); + std::transform(copy.begin(), copy.end(), copy.begin(), ::tolower); + return copy; +} + +bool CCBReader::endsWith(std::string pString, std::string pEnding) { + if (pString.length() >= pEnding.length()) { + return (pString.compare(pString.length() - pEnding.length(), pEnding.length(), pEnding) == 0); + } else { + return false; + } +} diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.h b/cocos2dx/extensions/CCBIReader/CCBReader.h new file mode 100644 index 0000000000..bba76d3ff6 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCBReader.h @@ -0,0 +1,128 @@ +#ifndef _CCB_READER_H_ +#define _CCB_READER_H_ + +#include "cocos2d.h" + +#define kCCBVersion 2 + +#define kCCBPropTypePosition 0 +#define kCCBPropTypeSize 1 +#define kCCBPropTypePoint 2 +#define kCCBPropTypePointLock 3 +#define kCCBPropTypeScaleLock 4 +#define kCCBPropTypeDegrees 5 +#define kCCBPropTypeInteger 6 +#define kCCBPropTypeFloat 7 +#define kCCBPropTypeFloatVar 8 +#define kCCBPropTypeCheck 9 +#define kCCBPropTypeSpriteFrame 10 +#define kCCBPropTypeTexture 11 +#define kCCBPropTypeByte 12 +#define kCCBPropTypeColor3 13 +#define kCCBPropTypeColor4FVar 14 +#define kCCBPropTypeFlip 15 +#define kCCBPropTypeBlendFunc 16 +#define kCCBPropTypeFntFile 17 +#define kCCBPropTypeText 18 +#define kCCBPropTypeFontTTF 19 +#define kCCBPropTypeIntegerLabeled 20 +#define kCCBPropTypeBlock 21 +#define kCCBPropTypeAnimation 22 +#define kCCBPropTypeCCBFile 23 +#define kCCBPropTypeString 24 +#define kCCBPropTypeBlockCCControl 25 +#define kCCBPropTypeFloatScale 26 + +#define kCCBFloat0 0 +#define kCCBFloat1 1 +#define kCCBFloatMinus1 2 +#define kCCBFloat05 3 +#define kCCBFloatInteger 4 +#define kCCBFloatFull 5 + +#define kCCBPlatformAll 0 +#define kCCBPlatformIOS 1 +#define kCCBPlatformMac 2 + +#define kCCBTargetTypeNone 0 +#define kCCBTargetTypeDocumentRoot 1 +#define kCCBTargetTypeOwner 2 + +#define kCCBPositionTypeRelativeBottomLeft 0 +#define kCCBPositionTypeRelativeTopLeft 1 +#define kCCBPositionTypeRelativeTopRight 2 +#define kCCBPositionTypeRelativeBottomRight 3 +#define kCCBPositionTypePercent 4 + +#define kCCBSizeTypeAbsolute 0 +#define kCCBSizeTypePercent 1 +#define kCCBSizeTypeRelativeContainer 2 +#define kCCBSizeTypeHorizontalPercent 3 +#define kCCBSzieTypeVerticalPercent 4 + + +#define kCCBScaleTypeAbsolute 0 +#define kCCBScaleTypeMultiplyResolution 1 + +NS_CC_EXT_BEGIN + +/* Forward declaration. */ +class CCNodeLoader; + +/** + * @brief Parse CCBI file which is generated by CocosBuilder + */ +class CC_DLL CCBReader : public cocos2d::CCObject { // TODO Why extend CCObject? -> Also all Loaders should extend from CCObject? + private: + unsigned char * mBytes; + int mCurrentByte; + int mCurrentBit; + cocos2d::CCNode * mOwner; /* TODO Should that be any 'Object'? */ + cocos2d::CCNode * mRootNode; + cocos2d::CCSize mRootContainerSize; + + std::vector mStringCache; + std::map mCCNodeLoaders; + std::set mLoadedSpriteSheets; + + public: + /* Constructor. */ + CCBReader(); + /* Destructor. */ + ~CCBReader(); + + CCNode * readNodeGraphFromFile(const char *, cocos2d::CCNode * = NULL); + CCNode * readNodeGraphFromFile(const char *, cocos2d::CCNode *, CCSize); + void registerCCNodeLoader(std::string, CCNodeLoader *); + CCNodeLoader * getCCNodeLoader(std::string); + + cocos2d::CCNode * getOwner(); + cocos2d::CCSize getContainerSize(cocos2d::CCNode *); + std::string lastPathComponent(std::string); + std::string deletePathExtension(std::string); + std::string toLowerCase(std::string); + bool endsWith(std::string, std::string); + bool isSpriteSheetLoaded(std::string); + void addLoadedSpriteSheet(std::string); + + /* Parse methods */ + int readInt(bool pSign); + unsigned char readByte(); + bool readBool(); + float readFloat(); + std::string readCachedString(); + + private: + bool readHeader(); + bool readStringCache(); + cocos2d::CCNode * readNodeGraph(); + cocos2d::CCNode * readNodeGraph(cocos2d::CCNode *); + + bool getBit(); + void alignBits(); + std::string readUTF8(); +}; + +NS_CC_EXT_END + +#endif \ No newline at end of file diff --git a/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.cpp b/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.cpp new file mode 100644 index 0000000000..575d23c107 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.cpp @@ -0,0 +1,41 @@ +#import "CCLabelBMFontLoader.h" + +using namespace cocos2d; +using namespace cocos2d::extension; + +#define PROPERTY_COLOR "color" +#define PROPERTY_OPACITY "opacity" +#define PROPERTY_BLENDFUNC "blendFunc" + +CCLabelBMFont * CCLabelBMFontLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { + if(pRet && pRet->initWithString(str, fntFile)) { + pRet->autorelease(); + return pRet; + } + CC_SAFE_DELETE(pRet); + return new CCLabelBMFont(); // TODO Is this problematic? +} + +void CCLabelBMFontLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_COLOR) == 0) { + ((CCLabelBMFont *)pNode)->setColor(pCCColor3B); + } else { + CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); + } +} + +void CCLabelBMFontLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, std::string pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_OPACITY) == 0) { + ((CCLabelBMFont *)pNode)->setOpacity(pByte); + } else { + CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); + } +} + +void CCLabelBMFontLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_BLENDFUNC) == 0) { + ((CCLabelBMFont *)pNode)->setBlendFunc(pCCBlendFunc); + } else { + CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); + } +} \ No newline at end of file diff --git a/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h b/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h new file mode 100644 index 0000000000..d91cc4c07f --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h @@ -0,0 +1,22 @@ +#ifndef _CCLABELBMFONT_LOADER_H_ +#define _CCLABELBMFONT_LOADER_H_ + +#include "CCNodeLoader.h" + +NS_CC_EXT_BEGIN + +/* Forward declaration. */ +class CCBReader; + +class CCLabelBMFontLoader : public CCNodeLoader { + protected: + virtual cocos2d::CCLabelBMFont * createCCNode(cocos2d::CCNode *, CCBReader *); + + virtual void onHandlePropTypeColor3(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::ccColor3B, CCBReader *); + virtual void onHandlePropTypeByte(CCNode *, CCNode *, std::string, unsigned char, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *); +}; + +NS_CC_EXT_END + +#endif diff --git a/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.cpp b/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.cpp new file mode 100644 index 0000000000..2102a6c7bb --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.cpp @@ -0,0 +1,36 @@ +#import "CCLayerColorLoader.h" + +using namespace cocos2d; +using namespace cocos2d::extension; + +#define PROPERTY_COLOR "color" +#define PROPERTY_OPACITY "opacity" +#define PROPERTY_BLENDFUNC "blendFunc" + +CCLayerColor * CCLayerColorLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { + return CCLayerColor::node(); +} + +void CCLayerColorLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_COLOR) == 0) { + ((CCLayerColor *)pNode)->setColor(pCCColor3B); + } else { + CCLayerLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); + } +} + +void CCLayerColorLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, std::string pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_OPACITY) == 0) { + ((CCLayerColor *)pNode)->setOpacity(pByte); + } else { + CCLayerLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); + } +} + +void CCLayerColorLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_BLENDFUNC) == 0) { + ((CCLayerColor *)pNode)->setBlendFunc(pCCBlendFunc); + } else { + CCLayerLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); + } +} \ No newline at end of file diff --git a/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.h b/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.h new file mode 100644 index 0000000000..758b2bd841 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.h @@ -0,0 +1,22 @@ +#ifndef _CCLAYERCOLOR_LOADER_H_ +#define _CCLAYERCOLOR_LOADER_H_ + +#include "CCLayerLoader.h" + +NS_CC_EXT_BEGIN + +/* Forward declaration. */ +class CCBReader; + +class CCLayerColorLoader : public CCLayerLoader { + protected: + virtual cocos2d::CCLayerColor * createCCNode(cocos2d::CCNode *, CCBReader *); + + virtual void onHandlePropTypeColor3(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::ccColor3B, CCBReader *); + virtual void onHandlePropTypeByte(CCNode *, CCNode *, std::string, unsigned char, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *); +}; + +NS_CC_EXT_END + +#endif diff --git a/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.cpp b/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.cpp new file mode 100644 index 0000000000..747e871b00 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.cpp @@ -0,0 +1,55 @@ +#import "CCLayerGradientLoader.h" + +using namespace cocos2d; +using namespace cocos2d::extension; + +#define PROPERTY_STARTCOLOR "startColor" +#define PROPERTY_ENDCOLOR "endColor" +#define PROPERTY_STARTOPACITY "startOpacity" +#define PROPERTY_ENDOPACITY "endOpacity" +#define PROPERTY_VECTOR "vector" +#define PROPERTY_BLENDFUNC "blendFunc" + +CCLayerGradient * CCLayerGradientLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { + return CCLayerGradient::node(); +} + +void CCLayerGradientLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_STARTCOLOR) == 0) { + ((CCLayerGradient *)pNode)->setStartColor(pCCColor3B); + } else if(pPropertyName.compare(PROPERTY_ENDCOLOR) == 0) { + ((CCLayerGradient *)pNode)->setEndColor(pCCColor3B); + } else { + CCLayerLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); + } +} + +void CCLayerGradientLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, std::string pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_STARTOPACITY) == 0) { + ((CCLayerGradient *)pNode)->setStartOpacity(pByte); + } else if(pPropertyName.compare(PROPERTY_ENDOPACITY) == 0) { + ((CCLayerGradient *)pNode)->setEndOpacity(pByte); + } else { + CCLayerLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); + } +} + +void CCLayerGradientLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_BLENDFUNC) == 0) { + ((CCLayerGradient *)pNode)->setBlendFunc(pCCBlendFunc); + } else { + CCLayerLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); + } +} + + +void CCLayerGradientLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_VECTOR) == 0) { + ((CCLayerGradient *)pNode)->setVector(pPoint); + + // TODO Not passed along the ccbi file. + // ((CCLayerGradient *)pNode)->setIsCompressedInterpolation(true); + } else { + CCLayerLoader::onHandlePropTypePoint(pNode, pParent, pPropertyName, pPoint, pCCBReader); + } +} \ No newline at end of file diff --git a/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.h b/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.h new file mode 100644 index 0000000000..83ca562838 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.h @@ -0,0 +1,23 @@ +#ifndef _CCLAYERGRADIENT_LOADER_H_ +#define _CCLAYERGRADIENT_LOADER_H_ + +#include "CCLayerLoader.h" + +NS_CC_EXT_BEGIN + +/* Forward declaration. */ +class CCBReader; + +class CCLayerGradientLoader : public CCLayerLoader { + protected: + virtual cocos2d::CCLayerGradient * createCCNode(cocos2d::CCNode *, CCBReader *); + + virtual void onHandlePropTypeColor3(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::ccColor3B, CCBReader *); + virtual void onHandlePropTypeByte(CCNode *, CCNode *, std::string, unsigned char, CCBReader *); + virtual void onHandlePropTypePoint(CCNode *, CCNode *, std::string, CCPoint, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *); +}; + +NS_CC_EXT_END + +#endif diff --git a/cocos2dx/extensions/CCBIReader/CCLayerLoader.cpp b/cocos2dx/extensions/CCBIReader/CCLayerLoader.cpp new file mode 100644 index 0000000000..739e023a9e --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCLayerLoader.cpp @@ -0,0 +1,30 @@ +#import "CCLayerLoader.h" + +using namespace cocos2d; +using namespace cocos2d::extension; + +#define PROPERTY_TOUCH_ENABLED "isTouchEnabled" +#define PROPERTY_ACCELEROMETER_ENABLED "isAccelerometerEnabled" +#define PROPERTY_MOUSE_ENABLED "isMouseEnabled" +#define PROPERTY_KEYBOARD_ENABLED "isKeyboardEnabled" + +CCLayer * CCLayerLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { + return CCLayer::node(); +} + +void CCLayerLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, std::string pPropertyName, bool pCheck, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_TOUCH_ENABLED) == 0) { + ((CCLayer *)pNode)->setIsTouchEnabled(pCheck); + } else if(pPropertyName.compare(PROPERTY_ACCELEROMETER_ENABLED) == 0) { + ((CCLayer *)pNode)->setIsAccelerometerEnabled(pCheck); + } else if(pPropertyName.compare(PROPERTY_MOUSE_ENABLED) == 0) { + // TODO XXX + CCLOG("The property '%s' is not supported!", PROPERTY_MOUSE_ENABLED); + } else if(pPropertyName.compare(PROPERTY_KEYBOARD_ENABLED) == 0) { + // TODO XXX + CCLOG("The property '%s' is not supported!", PROPERTY_KEYBOARD_ENABLED); + // This comes closest: ((CCLayer *)pNode)->setIsKeypadEnabled(pCheck); + } else { + CCNodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader); + } +} diff --git a/cocos2dx/extensions/CCBIReader/CCLayerLoader.h b/cocos2dx/extensions/CCBIReader/CCLayerLoader.h new file mode 100644 index 0000000000..497ba3496d --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCLayerLoader.h @@ -0,0 +1,20 @@ +#ifndef _CCLAYER_LOADER_H_ +#define _CCLAYER_LOADER_H_ + +#include "CCNodeLoader.h" + +NS_CC_EXT_BEGIN + +/* Forward declaration. */ +class CCBReader; + +class CCLayerLoader : public CCNodeLoader { + protected: + virtual cocos2d::CCLayer * createCCNode(cocos2d::CCNode *, CCBReader *); + + virtual void onHandlePropTypeCheck(CCNode *, CCNode *, std::string, bool, CCBReader *); +}; + +NS_CC_EXT_END + +#endif diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp new file mode 100644 index 0000000000..37b2bcabd8 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp @@ -0,0 +1,791 @@ +#import "CCNodeLoader.h" + +#define PROPERTY_POSITION "position" +#define PROPERTY_CONTENTSIZE "contentSize" +#define PROPERTY_ANCHORPOINT "anchorPoint" +#define PROPERTY_SCALE "scale" +#define PROPERTY_ROTATION "rotation" +#define PROPERTY_TAG "tag" +#define PROPERTY_IGNOREANCHORPOINTFORPOSITION "ignoreAnchorPointForPosition" +#define PROPERTY_VISIBLE "visible" + +#define ASSERT_UNEXPECTED_PROPERTY(PROPERTY) printf("Unexpected property type: '%s'!\n", PROPERTY.c_str()); assert(false) +#define ASSERT_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) printf("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false) + +using namespace cocos2d; +using namespace cocos2d::extension; + +CCNode * CCNodeLoader::loadCCNode(CCNode * pParent, CCBReader * pCCBReader) { + CCNode * ccNode = this->createCCNode(pParent, pCCBReader); + + this->parseProperties(ccNode, pParent, pCCBReader); + + return ccNode; +} + +CCNode * CCNodeLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { + return CCNode::node(); +} + +void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + int propertyCount = pCCBReader->readInt(false); + for(int i = 0; i < propertyCount; i++) { + int type = pCCBReader->readInt(false); + std::string propertyName = pCCBReader->readCachedString(); + + // Check if the property can be set for this platform + bool setProp = false; + + int platform = pCCBReader->readByte(); + if(platform == kCCBPlatformAll) { + setProp = true; + } +#ifdef __CC_PLATFORM_IOS + if(platform == kCCBPlatformIOS) { + setProp = true; + } +#elif defined(__CC_PLATFORM_MAC) + if(platform == kCCBPlatformMac) { + setProp = true; + } +#endif + + switch(type) { + case kCCBPropTypePosition: { + CCPoint position = this->parsePropTypePosition(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypePosition(pNode, pParent, propertyName, position, pCCBReader); + } + break; + } + case kCCBPropTypePoint: { + CCPoint point = this->parsePropTypePoint(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypePoint(pNode, pParent, propertyName, point, pCCBReader); + } + break; + } + case kCCBPropTypePointLock: { + CCPoint pointLock = this->parsePropTypePointLock(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypePointLock(pNode, pParent, propertyName, pointLock, pCCBReader); + } + break; + } + case kCCBPropTypeSize: { + CCSize size = this->parsePropTypeSize(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypeSize(pNode, pParent, propertyName, size, pCCBReader); + } + break; + } + case kCCBPropTypeScaleLock: { + float * scaleLock = this->parsePropTypeScaleLock(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypeScaleLock(pNode, pParent, propertyName, scaleLock, pCCBReader); + } + delete scaleLock; // TODO Can this just be deleted? + break; + } + case kCCBPropTypeFloat: { + float f = this->parsePropTypeFloat(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypeFloat(pNode, pParent, propertyName, f, pCCBReader); + } + break; + } + case kCCBPropTypeDegrees: { + float degrees = this->parsePropTypeDegrees(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypeDegrees(pNode, pParent, propertyName, degrees, pCCBReader); + } + break; + } + case kCCBPropTypeFloatScale: { + float floatScale = this->parsePropTypeFloatScale(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypeFloatScale(pNode, pParent, propertyName, floatScale, pCCBReader); + } + break; + } + case kCCBPropTypeInteger: { + int integer = this->parsePropTypeInteger(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypeInteger(pNode, pParent, propertyName, integer, pCCBReader); + } + break; + } + case kCCBPropTypeIntegerLabeled: { + int integerLabeled = this->parsePropTypeIntegerLabeled(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypeIntegerLabeled(pNode, pParent, propertyName, integerLabeled, pCCBReader); + } + break; + } + case kCCBPropTypeFloatVar: { + float * floatVar = this->parsePropTypeFloatVar(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypeFloatVar(pNode, pParent, propertyName, floatVar, pCCBReader); + } + delete floatVar; // TODO Can this just be deleted? + break; + } + case kCCBPropTypeCheck: { + bool check = this->parsePropTypeCheck(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypeCheck(pNode, pParent, propertyName, check, pCCBReader); + } + break; + } + case kCCBPropTypeSpriteFrame: { + if(setProp) { + this->onHandlePropTypeSpriteFrame(pNode, pParent, propertyName, this->parsePropTypeSpriteFrame(pNode, pParent, pCCBReader), pCCBReader); + } + break; + } + case kCCBPropTypeAnimation: { + CCAnimation * ccAnimation = this->parsePropTypeAnimation(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypeAnimation(pNode, pParent, propertyName, ccAnimation, pCCBReader); + } + // TODO delete ccAnimation; ??? + break; + } + case kCCBPropTypeTexture: { + CCTexture2D * ccTexture2D = this->parsePropTypeTexture(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypeTexture(pNode, pParent, propertyName, ccTexture2D, pCCBReader); + } + + break; + } + case kCCBPropTypeByte: { + unsigned char byte = this->parsePropTypeByte(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypeByte(pNode, pParent, propertyName, byte, pCCBReader); + } + break; + } + case kCCBPropTypeColor3: { + ccColor3B color3B = this->parsePropTypeColor3(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypeColor3(pNode, pParent, propertyName, color3B, pCCBReader); + } + break; + } + case kCCBPropTypeColor4FVar: { + ccColor4F * color4FVar = this->parsePropTypeColor4FVar(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypeColor4FVar(pNode, pParent, propertyName, color4FVar, pCCBReader); + } + delete color4FVar; // TODO Can this just be deleted? + break; + } + case kCCBPropTypeFlip: { + bool * flip = this->parsePropTypeFlip(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypeFlip(pNode, pParent, propertyName, flip, pCCBReader); + } + delete flip; // TODO Can this just be deleted? + break; + } + case kCCBPropTypeBlendFunc: { + ccBlendFunc blendFunc = this->parsePropTypeBlendFunc(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypeBlendFunc(pNode, pParent, propertyName, blendFunc, pCCBReader); + } + break; + } + case kCCBPropTypeFntFile: { + std::string fntFile = this->parsePropTypeFntFile(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypeFntFile(pNode, pParent, propertyName, fntFile, pCCBReader); + } + break; + } + case kCCBPropTypeString: { + std::string string = this->parsePropTypeString(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypeString(pNode, pParent, propertyName, string, pCCBReader); + } + break; + } + case kCCBPropTypeText: { + std::string text = this->parsePropTypeText(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypeText(pNode, pParent, propertyName, text, pCCBReader); + } + break; + } + case kCCBPropTypeBlock: { + void * block = this->parsePropTypeBlock(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypeBlock(pNode, pParent, propertyName, block, pCCBReader); + } + // TODO delete block; ??? + break; + } + case kCCBPropTypeBlockCCControl: { + void * blockCCControl = this->parsePropTypeBlockCCControl(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypeBlockCCControl(pNode, pParent, propertyName, blockCCControl, pCCBReader); + } + // TODO delete blockCCControl; ??? + break; + } + case kCCBPropTypeCCBFile: { + std::string ccbFile = this->parsePropTypeCCBFile(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypeCCBFile(pNode, pParent, propertyName, ccbFile, pCCBReader); + } + break; + } + default: + ASSERT_UNEXPECTED_PROPERTYTYPE(type); + break; + } + } +} + +CCPoint CCNodeLoader::parsePropTypePosition(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + float x = pCCBReader->readFloat(); + float y = pCCBReader->readFloat(); + + int type = pCCBReader->readInt(false); + + CCSize containerSize = pCCBReader->getContainerSize(pParent); + + switch (type) { + case kCCBPositionTypeRelativeBottomLeft: { + /* Nothing. */ + break; + } + case kCCBPositionTypeRelativeTopLeft: { + y = containerSize.height - y; + break; + } + case kCCBPositionTypeRelativeTopRight: { + x = containerSize.width - x; + y = containerSize.height - y; + break; + } + case kCCBPositionTypeRelativeBottomRight: { + x = containerSize.width - x; + break; + } + case kCCBPositionTypePercent: { + x = (int)(containerSize.width * x / 100.0f); + y = (int)(containerSize.height * y / 100.0f); + break; + } + } + + return CCPoint(x, y); +} + +CCPoint CCNodeLoader::parsePropTypePoint(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + float x = pCCBReader->readFloat(); + float y = pCCBReader->readFloat(); + + return CCPoint(x, y); +} + +CCPoint CCNodeLoader::parsePropTypePointLock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + float x = pCCBReader->readFloat(); + float y = pCCBReader->readFloat(); + + return CCPoint(x, y); +} + +CCSize CCNodeLoader::parsePropTypeSize(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + float width = pCCBReader->readFloat(); + float height = pCCBReader->readFloat(); + + int type = pCCBReader->readInt(false); + + CCSize containerSize = pCCBReader->getContainerSize(pParent); + + switch (type) { + case kCCBSizeTypeAbsolute: { + /* Nothing. */ + break; + } + case kCCBSizeTypeRelativeContainer: { + width = containerSize.width - width; + height = containerSize.height - height; + break; + } + case kCCBSizeTypePercent: { + width = (int)(containerSize.width * width / 100.0f); + height = (int)(containerSize.height * height / 100.0f); + break; + } + case kCCBSizeTypeHorizontalPercent: { + width = (int)(containerSize.width * width / 100.0f); + break; + } + case kCCBSzieTypeVerticalPercent: { + height = (int)(containerSize.height * height / 100.0f); + break; + } + default: + break; + } + + return CCSize(width, height); +} + +float * CCNodeLoader::parsePropTypeScaleLock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + float x = pCCBReader->readFloat(); + float y = pCCBReader->readFloat(); + + int type = pCCBReader->readInt(false); + + // TODO + /* + if (type == kCCBScaleTypeMultiplyResolution) { + x *= resolutionScale; + y *= resolutionScale; + } + */ + + float * scaleLock = new float[2]; + scaleLock[0] = x; + scaleLock[1] = y; + + return scaleLock; +} + +float CCNodeLoader::parsePropTypeFloat(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + return pCCBReader->readFloat(); +} + +float CCNodeLoader::parsePropTypeDegrees(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + return pCCBReader->readFloat(); +} + +float CCNodeLoader::parsePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + float f = pCCBReader->readFloat(); + + int type = pCCBReader->readInt(false); + + // TODO + /* + if (type == kCCBScaleTypeMultiplyResolution) { + x *= resolutionScale; + y *= resolutionScale; + } + */ + return f; +} + +int CCNodeLoader::parsePropTypeInteger(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + return pCCBReader->readInt(true); +} + +int CCNodeLoader::parsePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + return pCCBReader->readInt(true); +} + +float * CCNodeLoader::parsePropTypeFloatVar(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + float f = pCCBReader->readFloat(); + float fVar = pCCBReader->readFloat(); + + float * arr = new float[2]; + arr[0] = f; + arr[1] = fVar; + + return arr; +} + +bool CCNodeLoader::parsePropTypeCheck(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + return pCCBReader->readBool(); +} + + +CCSpriteFrame * CCNodeLoader::parsePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + std::string spriteSheet = pCCBReader->readCachedString(); + std::string spriteFile = pCCBReader->readCachedString(); + + CCSpriteFrame * spriteFrame; + if (spriteSheet.compare("") == 0) { + CCTexture2D * texture = CCTextureCache::sharedTextureCache()->addImage(spriteFile.c_str()); + CCRect bounds = CCRect::CCRect(0, 0, texture->getContentSize().width, texture->getContentSize().height); + spriteFrame = CCSpriteFrame::frameWithTexture(texture, bounds); + } else { + CCSpriteFrameCache * frameCache = CCSpriteFrameCache::sharedSpriteFrameCache(); + + /* Load the sprite sheet only if it is not loaded. */ + if (!pCCBReader->isSpriteSheetLoaded(spriteSheet)) { + frameCache->addSpriteFramesWithFile(spriteSheet.c_str()); + pCCBReader->addLoadedSpriteSheet(spriteSheet); + } + + spriteFrame = frameCache->spriteFrameByName(spriteFile.c_str()); + } + return spriteFrame; +} + +CCAnimation * CCNodeLoader::parsePropTypeAnimation(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + std::string animationFile = pCCBReader->readCachedString(); + std::string animation = pCCBReader->readCachedString(); + + CCAnimation * ccAnimation = NULL; + + // Support for stripping relative file paths, since ios doesn't currently + // know what to do with them, since its pulling from bundle. + // Eventually this should be handled by a client side asset manager + // interface which figured out what resources to load. + // TODO Does this problem exist in C++? + animation = pCCBReader->lastPathComponent(animation); + animationFile = pCCBReader->lastPathComponent(animationFile); + + if (animation.compare("") != 0) { + CCAnimationCache * animationCache = CCAnimationCache::sharedAnimationCache(); + animationCache->addAnimationsWithFile(animationFile.c_str()); + + ccAnimation = animationCache->animationByName(animation.c_str()); + } + return ccAnimation; +} + +CCTexture2D * CCNodeLoader::parsePropTypeTexture(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + std::string spriteFile = pCCBReader->readCachedString(); + + return CCTextureCache::sharedTextureCache()->addImage(spriteFile.c_str()); +} + +unsigned char CCNodeLoader::parsePropTypeByte(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + return pCCBReader->readByte(); +} + +ccColor3B CCNodeLoader::parsePropTypeColor3(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + unsigned char red = pCCBReader->readByte(); + unsigned char green = pCCBReader->readByte(); + unsigned char blue = pCCBReader->readByte(); + + ccColor3B color = { red, green, blue }; + return color; +} + +ccColor4F * CCNodeLoader::parsePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + float red = pCCBReader->readFloat(); + float green = pCCBReader->readFloat(); + float blue = pCCBReader->readFloat(); + float alpha = pCCBReader->readFloat(); + float redVar = pCCBReader->readFloat(); + float greenVar = pCCBReader->readFloat(); + float blueVar = pCCBReader->readFloat(); + float alphaVar = pCCBReader->readFloat(); + + ccColor4F * colors = new ccColor4F[2]; + colors[0].r = red; + colors[0].g = green; + colors[0].b = blue; + colors[0].a = alpha; + + colors[1].r = redVar; + colors[1].g = greenVar; + colors[1].b = blueVar; + colors[1].a = alphaVar; + + return colors; +} + +bool * CCNodeLoader::parsePropTypeFlip(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + bool flipX = pCCBReader->readBool(); + bool flipY = pCCBReader->readBool(); + + bool * arr = new bool[2]; + arr[0] = flipX; + arr[1] = flipY; + + return arr; +} + +ccBlendFunc CCNodeLoader::parsePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + int source = pCCBReader->readInt(false); + int destination = pCCBReader->readInt(false); + + ccBlendFunc blendFunc; + blendFunc.src = source; + blendFunc.dst = destination; + + return blendFunc; +} + +std::string CCNodeLoader::parsePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + return pCCBReader->readCachedString(); +} + +std::string CCNodeLoader::parsePropTypeString(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + return pCCBReader->readCachedString(); +} + +std::string CCNodeLoader::parsePropTypeText(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + return pCCBReader->readCachedString(); +} + +std::string CCNodeLoader::parsePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + std::string fnt = pCCBReader->readCachedString(); + + std::string ttfEnding("ttf"); + + if (pCCBReader->endsWith(pCCBReader->toLowerCase(fnt), ttfEnding)){ + fnt = pCCBReader->deletePathExtension(pCCBReader->lastPathComponent(fnt)); + } + + return fnt; +} + +void * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + std::string selectorName = pCCBReader->readCachedString(); + int selectorTarget = pCCBReader->readInt(false); + + // TODO Selectors? + /* +#ifdef CCB_ENABLE_JAVASCRIPT + if (selectorTarget && selectorName && ![selectorName isEqualToString:@""]) + { + void (^block)(id sender); + block = ^(id sender) { + [[JSCocoa sharedController] eval:[NSString stringWithFormat:@"%@();",selectorName]]; + }; + + NSString* setSelectorName = [NSString stringWithFormat:@"set%@:",[name capitalizedString]]; + SEL setSelector = NSSelectorFromString(setSelectorName); + + if ([node respondsToSelector:setSelector]) + { + [node performSelector:setSelector withObject:block]; + } + else + { + NSLog(@"CCBReader: Failed to set selector/target block for %@",selectorName); + } + } +#else + if (selectorTarget) + { + id target = NULL; + if (selectorTarget == kCCBTargetTypeDocumentRoot) target = rootNode; + else if (selectorTarget == kCCBTargetTypeOwner) target = owner; + + if (target) + { + SEL selector = NSSelectorFromString(selectorName); + __block id t = target; + + void (^block)(id sender); + block = ^(id sender) { + [t performSelector:selector withObject:sender]; + }; + + NSString* setSelectorName = [NSString stringWithFormat:@"set%@:",[name capitalizedString]]; + SEL setSelector = NSSelectorFromString(setSelectorName); + + if ([node respondsToSelector:setSelector]) + { + [node performSelector:setSelector withObject:block]; + } + else + { + NSLog(@"CCBReader: Failed to set selector/target block for %@",selectorName); + } + } + else + { + NSLog(@"CCBReader: Failed to find target for block"); + } + } +#endif + */ + return NULL; +} + +void * CCNodeLoader::parsePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + std::string selectorName = pCCBReader->readCachedString(); + int selectorTarget = pCCBReader->readInt(false); + int ctrlEvts = pCCBReader->readInt(false); + + // TODO + /* + // Since we do not know for sure that CCControl is available, use + // NSInvocation to call it's addTarget:action:forControlEvents: method + NSMethodSignature* sig = [node methodSignatureForSelector:@selector(addTarget:action:forControlEvents:)]; + if (sig) + { + SEL selector = NSSelectorFromString(selectorName); + id target = NULL; + if (selectorTarget == kCCBTargetTypeDocumentRoot) target = rootNode; + else if (selectorTarget == kCCBTargetTypeOwner) target = owner; + + if (selector && target) + { + NSInvocation* invocation = [NSInvocation invocationWithMethodSignature:sig]; + [invocation setTarget:node]; + [invocation setSelector:@selector(addTarget:action:forControlEvents:)]; + [invocation setArgument:&target atIndex:2]; + [invocation setArgument:&selector atIndex:3]; + [invocation setArgument:&ctrlEvts atIndex:4]; + + [invocation invoke]; + } + } + else + { + NSLog(@"CCBReader: Failed to add selector/target block for CCControl"); + } + */ + return NULL; +} + +std::string CCNodeLoader::parsePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + std::string ccbFileName = pCCBReader->readCachedString(); + + /* Change path extension to .ccbi. */ + return pCCBReader->deletePathExtension(ccbFileName) + std::string(".ccbi"); +} + + + +void CCNodeLoader::onHandlePropTypePosition(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCPoint pPosition, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_POSITION) == 0) { + pNode->setPosition(pPosition); + } else { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + } +} + +void CCNodeLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_ANCHORPOINT) == 0) { + pNode->setAnchorPoint(pPoint); + } else { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + } +} + +void CCNodeLoader::onHandlePropTypePointLock(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCPoint pPointLock, CCBReader * pCCBReader) { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); +} + +void CCNodeLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSize pSize, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_CONTENTSIZE) == 0) { + pNode->setContentSize(pSize); + } +} + +void CCNodeLoader::onHandlePropTypeScaleLock(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float * pScaleLock, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_SCALE) == 0) { + pNode->setScaleX(pScaleLock[0]); + pNode->setScaleX(pScaleLock[1]); + } else { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + } +} + +void CCNodeLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float pFloat, CCBReader * pCCBReader) { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); +} + +void CCNodeLoader::onHandlePropTypeDegrees(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float pDegrees, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_ROTATION) == 0) { + pNode->setRotation(pDegrees); + } else { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + } +} + +void CCNodeLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float pFloatScale, CCBReader * pCCBReader) { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); +} + +void CCNodeLoader::onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, std::string pPropertyName, int pInteger, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_TAG) == 0) { + pNode->setTag(pInteger); + } else { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + } +} + +void CCNodeLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, std::string pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); +} + +void CCNodeLoader::onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float * pFloatVar, CCBReader * pCCBReader) { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); +} + +void CCNodeLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, std::string pPropertyName, bool pCheck, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_VISIBLE) == 0) { + pNode->setIsVisible(pCheck); + } else if(pPropertyName.compare(PROPERTY_IGNOREANCHORPOINTFORPOSITION) == 0) { + pNode->setIsRelativeAnchorPoint(!pCheck); + } else { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + } +} + +void CCNodeLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); +} + +void CCNodeLoader::onHandlePropTypeAnimation(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCAnimation * pCCAnimation, CCBReader * pCCBReader) { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); +} + +void CCNodeLoader::onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader) { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); +} + +void CCNodeLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, std::string pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); +} + +void CCNodeLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); +} + +void CCNodeLoader::onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader) { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); +} + +void CCNodeLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, std::string pPropertyName, bool * pFlip, CCBReader * pCCBReader) { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); +} + +void CCNodeLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); +} + +void CCNodeLoader::onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pFntFile, CCBReader * pCCBReader) { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); +} + +void CCNodeLoader::onHandlePropTypeString(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pString, CCBReader * pCCBReader) { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); +} + +void CCNodeLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pString, CCBReader * pCCBReader) { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); +} + +void CCNodeLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pFontTTF, CCBReader * pCCBReader) { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); +} + +void CCNodeLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, std::string pPropertyName, void * pBlock, CCBReader * pCCBReader) { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); +} + +void CCNodeLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, std::string pPropertyName, void * pBlock, CCBReader * pCCBReader) { + ASSERT_UNEXPECTED_PROPERTY(pPropertyName); +} + +void CCNodeLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pCCBFileName, CCBReader * pCCBReader) { + // TODO check pPropertyName? + CCBReader * ccbReader = new CCBReader(); + CCNode * ccNode = ccbReader->readNodeGraphFromFile(pCCBFileName.c_str(), pCCBReader->getOwner(), pParent->getContentSize()); + + pNode->addChild(ccNode); // TODO will this work in all cases? +} \ No newline at end of file diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.h b/cocos2dx/extensions/CCBIReader/CCNodeLoader.h new file mode 100644 index 0000000000..4538639f5a --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.h @@ -0,0 +1,80 @@ +#ifndef _CCNODE_LOADER_H_ +#define _CCNODE_LOADER_H_ + +#include "cocos2d.h" +#include "CCBReader.h" + +NS_CC_EXT_BEGIN + +/* Forward declaration. */ +class CCBReader; + +class CC_DLL CCNodeLoader { + public: + virtual cocos2d::CCNode * loadCCNode(cocos2d::CCNode *, CCBReader *); + virtual void parseProperties(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + + protected: + virtual cocos2d::CCNode * createCCNode(cocos2d::CCNode *, CCBReader *); + + virtual cocos2d::CCPoint parsePropTypePosition(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual cocos2d::CCPoint parsePropTypePoint(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual cocos2d::CCPoint parsePropTypePointLock(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual cocos2d::CCSize parsePropTypeSize(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual float * parsePropTypeScaleLock(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual float parsePropTypeFloat(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual float parsePropTypeDegrees(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual float parsePropTypeFloatScale(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual int parsePropTypeInteger(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual int parsePropTypeIntegerLabeled(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual float * parsePropTypeFloatVar(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual bool parsePropTypeCheck(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual cocos2d::CCSpriteFrame * parsePropTypeSpriteFrame(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual cocos2d::CCAnimation * parsePropTypeAnimation(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual cocos2d::CCTexture2D * parsePropTypeTexture(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual unsigned char parsePropTypeByte(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual cocos2d::ccColor3B parsePropTypeColor3(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual cocos2d::ccColor4F * parsePropTypeColor4FVar(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual bool * parsePropTypeFlip(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual cocos2d::ccBlendFunc parsePropTypeBlendFunc(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual std::string parsePropTypeFntFile(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual std::string parsePropTypeString(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual std::string parsePropTypeText(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual std::string parsePropTypeFontTTF(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual void * parsePropTypeBlock(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual void * parsePropTypeBlockCCControl(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual std::string parsePropTypeCCBFile(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + + + virtual void onHandlePropTypePosition(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::CCPoint, CCBReader *); + virtual void onHandlePropTypePoint(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::CCPoint, CCBReader *); + virtual void onHandlePropTypePointLock(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::CCPoint, CCBReader *); + virtual void onHandlePropTypeSize(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::CCSize, CCBReader *); + virtual void onHandlePropTypeScaleLock(cocos2d::CCNode *, cocos2d::CCNode *, std::string, float *, CCBReader *); + virtual void onHandlePropTypeFloat(cocos2d::CCNode *, cocos2d::CCNode *, std::string, float, CCBReader *); + virtual void onHandlePropTypeDegrees(cocos2d::CCNode *, cocos2d::CCNode *, std::string, float, CCBReader *); + virtual void onHandlePropTypeFloatScale(cocos2d::CCNode *, cocos2d::CCNode *, std::string, float, CCBReader *); + virtual void onHandlePropTypeInteger(cocos2d::CCNode *, cocos2d::CCNode *, std::string, int, CCBReader *); + virtual void onHandlePropTypeIntegerLabeled(cocos2d::CCNode *, cocos2d::CCNode *, std::string, int, CCBReader *); + virtual void onHandlePropTypeFloatVar(cocos2d::CCNode *, cocos2d::CCNode *, std::string, float *, CCBReader *); + virtual void onHandlePropTypeCheck(cocos2d::CCNode *, cocos2d::CCNode *, std::string, bool, CCBReader *); + virtual void onHandlePropTypeSpriteFrame(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::CCSpriteFrame *, CCBReader *); + virtual void onHandlePropTypeAnimation(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::CCAnimation *, CCBReader *); + virtual void onHandlePropTypeTexture(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::CCTexture2D *, CCBReader *); + virtual void onHandlePropTypeByte(cocos2d::CCNode *, cocos2d::CCNode *, std::string, unsigned char, CCBReader *); + virtual void onHandlePropTypeColor3(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::ccColor3B, CCBReader *); + virtual void onHandlePropTypeColor4FVar(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::ccColor4F *, CCBReader *); + virtual void onHandlePropTypeFlip(cocos2d::CCNode *, cocos2d::CCNode *, std::string, bool *, CCBReader *); + virtual void onHandlePropTypeBlendFunc(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeFntFile(cocos2d::CCNode *, cocos2d::CCNode *, std::string, std::string, CCBReader *); + virtual void onHandlePropTypeString(cocos2d::CCNode *, cocos2d::CCNode *, std::string, std::string, CCBReader *); + virtual void onHandlePropTypeText(cocos2d::CCNode *, cocos2d::CCNode *, std::string, std::string, CCBReader *); + virtual void onHandlePropTypeFontTTF(cocos2d::CCNode *, cocos2d::CCNode *, std::string, std::string, CCBReader *); + virtual void onHandlePropTypeBlock(cocos2d::CCNode *, cocos2d::CCNode *, std::string, void *, CCBReader *); + virtual void onHandlePropTypeBlockCCControl(cocos2d::CCNode *, cocos2d::CCNode *, std::string, void *, CCBReader *); + virtual void onHandlePropTypeCCBFile(cocos2d::CCNode *, cocos2d::CCNode *, std::string, std::string, CCBReader *); +}; + +NS_CC_EXT_END + +#endif diff --git a/cocos2dx/extensions/CCBIReader/CCSpriteLoader.cpp b/cocos2dx/extensions/CCBIReader/CCSpriteLoader.cpp new file mode 100644 index 0000000000..7b040b21eb --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCSpriteLoader.cpp @@ -0,0 +1,55 @@ +#import "CCSpriteLoader.h" + +using namespace cocos2d; +using namespace cocos2d::extension; + +#define PROPERTY_FLIP "flip" +#define PROPERTY_DISPLAYFRAME "displayFrame" +#define PROPERTY_COLOR "color" +#define PROPERTY_OPACITY "opacity" +#define PROPERTY_BLENDFUNC "blendFunc" + +CCSprite * CCSpriteLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { + return CCSprite::node(); +} + +void CCSpriteLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_DISPLAYFRAME) == 0) { + ((CCSprite *)pNode)->setDisplayFrame(pCCSpriteFrame); + } else { + CCNodeLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pCCSpriteFrame, pCCBReader); + } +} + +void CCSpriteLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, std::string pPropertyName, bool * pFlip, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_FLIP) == 0) { + ((CCSprite *)pNode)->setFlipX(pFlip[0]); + ((CCSprite *)pNode)->setFlipX(pFlip[1]); + } else { + CCNodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pFlip, pCCBReader); + } +} + +void CCSpriteLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_COLOR) == 0) { + ((CCSprite *)pNode)->setColor(pCCColor3B); + } else { + CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); + } +} + +void CCSpriteLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, std::string pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_OPACITY) == 0) { + ((CCSprite *)pNode)->setOpacity(pByte); + } else { + CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); + } +} + +void CCSpriteLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_BLENDFUNC) == 0) { + ((CCSprite *)pNode)->setBlendFunc(pCCBlendFunc); + } else { + CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); + } +} \ No newline at end of file diff --git a/cocos2dx/extensions/CCBIReader/CCSpriteLoader.h b/cocos2dx/extensions/CCBIReader/CCSpriteLoader.h new file mode 100644 index 0000000000..ec8cd6e8e5 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCSpriteLoader.h @@ -0,0 +1,24 @@ +#ifndef _CCSPRITE_LOADER_H_ +#define _CCSPRITE_LOADER_H_ + +#include "CCNodeLoader.h" + +NS_CC_EXT_BEGIN + +/* Forward declaration. */ +class CCBReader; + +class CCSpriteLoader : public CCNodeLoader { + protected: + virtual cocos2d::CCSprite * createCCNode(cocos2d::CCNode *, CCBReader *); + + virtual void onHandlePropTypeColor3(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::ccColor3B, CCBReader *); + virtual void onHandlePropTypeByte(CCNode *, CCNode *, std::string, unsigned char, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeSpriteFrame(CCNode *, CCNode *, std::string, CCSpriteFrame *, CCBReader *); + virtual void onHandlePropTypeFlip(CCNode *, CCNode *, std::string, bool *, CCBReader *); +}; + +NS_CC_EXT_END + +#endif From a7d4fa619d8dd25b819753bbf6517c5275290730 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 30 May 2012 11:30:53 -0700 Subject: [PATCH 020/257] Removed CCBReader to avoid conflicts. --- cocos2dx/extensions/CCBReader/CCBReader.cpp | 141 -------------------- cocos2dx/extensions/CCBReader/CCBReader.h | 67 ---------- 2 files changed, 208 deletions(-) delete mode 100644 cocos2dx/extensions/CCBReader/CCBReader.cpp delete mode 100644 cocos2dx/extensions/CCBReader/CCBReader.h diff --git a/cocos2dx/extensions/CCBReader/CCBReader.cpp b/cocos2dx/extensions/CCBReader/CCBReader.cpp deleted file mode 100644 index 9a63184ad0..0000000000 --- a/cocos2dx/extensions/CCBReader/CCBReader.cpp +++ /dev/null @@ -1,141 +0,0 @@ -#include "CCBReader.h" - -using namespace cocos2d; -using namespace cocos2d::extension; - -CCBReader::CCBReader() { - -} - -CCBReader::~CCBReader() { - if(this->mBytes) { - delete this->mBytes; - this->mBytes = NULL; - } - - if(this->mStringCache) { - delete this->mStringCache; - this->mStringCache = NULL; - } -} - -CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBFileName, CCNode * pOwner) { - const char * path = CCFileUtils::fullPathFromRelativePath(pCCBFileName); - - CCFileUtils::ccLoadFileIntoMemory(path, &this->mBytes); - - this->mCurrentByte = 0; - this->mCurrentBit = 0; - - if(!this->readHeader()) { - return NULL; - } - - if(!this->readStringCache()) { - return NULL; - } - - return this->readNodeGraph(); -} - -bool CCBReader::readHeader() { - /* If no bytes loaded, don't crash about it. */ - if(this->mBytes == NULL) { - return false; - } - - /* Read magic bytes */ - int magicBytes = *((int*)(this->mBytes + this->mCurrentByte)); - this->mCurrentByte += 4; - - if(magicBytes != 'ccbi') { - return false; - } - - /* Read version. */ - int version = this->readInt(false); - if(version != kCCBVersion) { - CCLog("WARNING! Incompatible ccbi file version (file: %d reader: %d)", version, kCCBVersion); - return false; - } - - return true; -} - -bool CCBReader::readStringCache() { - return true; -} - -int CCBReader::readInt(bool pSign) { - int numBits = 0; - while(!this->getBit()) { - numBits++; - } - - long long current = 0; - for(int a = numBits - 1; a >= 0; a--) { - if(this->getBit()) { - current |= 1 << a; - } - } - current |= 1 << numBits; - - int num; - if(pSign) { - int s = current % 2; - if(s) { - num = (int)(current / 2); - } else { - num = (int)(-current / 2); - } - } else { - num = current-1; - } - - this->alignBits(); - - return num; -} - -bool CCBReader::getBit() { - bool bit; - unsigned char byte = *(this->mBytes + this->mCurrentByte); - if(byte & (1 << this->mCurrentBit)) { - bit = true; - } else { - bit = false; - } - - this->mCurrentBit++; - - if(this->mCurrentBit >= 8) { - this->mCurrentBit = 0; - this->mCurrentBit++; - } - - return bit; -} - -void CCBReader::alignBits() { - if(this->mCurrentBit) { - this->mCurrentBit = 0; - this->mCurrentByte++; - } -} - -CCNode * CCBReader::readNodeGraph() { - CCLayerColor * ccLayerColor = CCLayerColor::node(); - - CCSize size; - size.setSize(100, 100); - ccLayerColor->setContentSize(size); - - ccColor3B color; - color.r = 255; - color.g = 0; - color.b = 0; - ccLayerColor->setColor(color); - ccLayerColor->setOpacity(255); - - return ccLayerColor; -} \ No newline at end of file diff --git a/cocos2dx/extensions/CCBReader/CCBReader.h b/cocos2dx/extensions/CCBReader/CCBReader.h deleted file mode 100644 index ddd8800925..0000000000 --- a/cocos2dx/extensions/CCBReader/CCBReader.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** - Copyright (c) 2012 cocos2d-x.org - Copyright (c) 2012 XiaoLong Zhang, Chukong Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - - -#ifndef __CCB_READER_H__ -#define __CCB_READER_H__ - -#include "cocos2d.h" - -#define kCCBVersion 2 - -NS_CC_EXT_BEGIN - -/** - * @brief Parse CCBI file which is generated by CocosBuilder - */ -class CC_DLL CCBReader : public CCObject { - private: - unsigned char * mBytes; - int mCurrentByte; - int mCurrentBit; - - std::vector * mStringCache; - - public: - /* Constructor. */ - CCBReader(); - /* Destructor. */ - ~CCBReader(); - - CCNode * readNodeGraphFromFile(const char* ccbFileName, CCNode* owner = NULL); - - private: - bool readHeader(); - bool readStringCache(); - CCNode * readNodeGraph(); - - bool getBit(); - void alignBits(); - int readInt(bool pSign); -}; - -NS_CC_EXT_END - -#endif // __CCB_READER_H__ \ No newline at end of file From 827ee160b5a5c73c0c6e2ecf07eff16fd1deb467 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 30 May 2012 15:31:08 -0700 Subject: [PATCH 021/257] Added support for initializing a CCLabelBMFont without a fntfile and a string. (See: ffbdb60a5908f5baef227bb0365a0b2653a3a59a, a6749b38f8085ba81921063328bc50cb7a989613, e6e3917c0c3f2e95e13c3be29584cb9e3781d3a7). --- cocos2dx/label_nodes/CCLabelBMFont.cpp | 74 ++++++++++++++++++--- cocos2dx/label_nodes/CCLabelBMFont.h | 6 ++ cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp | 7 ++ cocos2dx/sprite_nodes/CCSpriteBatchNode.h | 1 + 4 files changed, 77 insertions(+), 11 deletions(-) diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index d202028fca..e493a0fd0f 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -35,6 +35,7 @@ http://www.angelcode.com/products/bmfont/ (Free, Windows only) #include "platform/platform.h" #include "CCDictionary.h" #include "CCConfiguration.h" +#include "CCTextureCache.h" #include "CCDrawingPrimitives.h" #include "CCSprite.h" #include "CCPointExtension.h" @@ -727,6 +728,20 @@ void CCLabelBMFont::purgeCachedData() FNTConfigRemoveCache(); } +CCLabelBMFont * CCLabelBMFont::node() +{ + CCLabelBMFont * pRet = new CCLabelBMFont(); + if (pRet && pRet->init()) + { + pRet->autorelease(); + } + else + { + CC_SAFE_DELETE(pRet); + } + return pRet; +} + //LabelBMFont - Creation & Init CCLabelBMFont *CCLabelBMFont::labelWithString(const char *str, const char *fntFile) { @@ -766,6 +781,11 @@ CCLabelBMFont *CCLabelBMFont::labelWithString(const char *str, const char *fntFi return NULL; } +bool CCLabelBMFont::init() +{ + return initWithString(NULL, NULL, kCCLabelAutomaticWidth, CCTextAlignmentLeft, CCPointZero); +} + bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile) { return initWithString(theString, fntFile, kCCLabelAutomaticWidth, CCTextAlignmentLeft, CCPointZero); @@ -778,25 +798,45 @@ bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile, f bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile, float width, CCTextAlignment alignment, CCPoint imageOffset) { - CCAssert(theString != NULL, ""); - CC_SAFE_RELEASE(m_pConfiguration);// allow re-init - m_pConfiguration = FNTConfigLoadFile(fntFile); - m_pConfiguration->retain(); - CCAssert( m_pConfiguration, "Error creating config for LabelBMFont"); + CCAssert(!this->m_pConfiguration, "re-init is no longer supported"); + + CCAssert((theString != NULL && fntFile != NULL) || (theString == NULL && fntFile == NULL), "Invalid params for CCLabelBMFont"); - if (CCSpriteBatchNode::initWithFile(m_pConfiguration->m_sAtlasName.c_str(), strlen(theString))) + CCTexture2D * texture; + + if(fntFile != NULL) + { + m_pConfiguration = FNTConfigLoadFile(fntFile); + m_pConfiguration->retain(); + CCAssert( m_pConfiguration, "Error creating config for LabelBMFont"); + + texture = CCTextureCache::sharedTextureCache()->addImage(this->m_pConfiguration->m_sAtlasName.c_str()); + } + else + { + texture = new CCTexture2D(); + texture->autorelease(); + } + + + if (CCSpriteBatchNode::initWithTexture(texture, (theString == NULL) ? 0 : strlen(theString))) { - m_pAlignment = alignment; - m_tImageOffset = imageOffset; m_fWidth = width; - CC_SAFE_DELETE_ARRAY(m_sString); - m_sString = cc_utf8_from_cstr(theString); + m_pAlignment = alignment; + m_cOpacity = 255; m_tColor = ccWHITE; + m_tContentSize = CCSizeZero; + m_bIsOpacityModifyRGB = m_pobTextureAtlas->getTexture()->getHasPremultipliedAlpha(); - this->setString(theString); + setAnchorPoint(ccp(0.5f, 0.5f)); + + m_tImageOffset = imageOffset; + + this->setString((theString == NULL) ? "" : theString); + return true; } return false; @@ -1310,6 +1350,18 @@ void CCLabelBMFont::setWidth(float width) updateLabel(); } +void CCLabelBMFont::setFntFile(const char *fntFile) +{ + CCBMFontConfiguration * newConfiguration = FNTConfigLoadFile(fntFile); + + CCAssert(newConfiguration, printf("CCLabelBMFont: Impossible to create font. Please check file: '%@'", fntFile) ); + CC_SAFE_RELEASE(this->m_pConfiguration); + this->m_pConfiguration = newConfiguration; + this->m_pConfiguration->retain(); + this->setTexture(CCTextureCache::sharedTextureCache()->addImage(this->m_pConfiguration->m_sAtlasName.c_str())); + this->createFontChars(); +} + void CCLabelBMFont::setLineBreakWithoutSpace( bool breakWithoutSpace ) { m_bLineBreakWithoutSpaces = breakWithoutSpace; diff --git a/cocos2dx/label_nodes/CCLabelBMFont.h b/cocos2dx/label_nodes/CCLabelBMFont.h index 42fc6abcaa..0d47868a2b 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.h +++ b/cocos2dx/label_nodes/CCLabelBMFont.h @@ -181,7 +181,12 @@ public: static CCLabelBMFont * labelWithString(const char *str, const char *fntFile, float width, CCTextAlignment alignment); static CCLabelBMFont * labelWithString(const char *str, const char *fntFile, float width, CCTextAlignment alignment, CCPoint imageOffset); + /** Creates an label. + */ + static CCLabelBMFont * node(); + /** init a bitmap font altas with an initial string and the FNT file */ + bool init(); bool initWithString(const char *str, const char *fntFile, float width, CCTextAlignment alignment, CCPoint imageOffset); bool initWithString(const char *str, const char *fntFile, float width, CCTextAlignment alignment); bool initWithString(const char *str, const char *fntFile); @@ -197,6 +202,7 @@ public: virtual void updateLabel(); virtual void setAlignment(CCTextAlignment alignment); virtual void setWidth(float width); + virtual void setFntFile(const char *fntFile); virtual void setLineBreakWithoutSpace(bool breakWithoutSpace); virtual void setScale(float scale); virtual void setScaleX(float scaleX); diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp index fdb5164daf..875f087cbc 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp @@ -108,6 +108,13 @@ bool CCSpriteBatchNode::initWithTexture(CCTexture2D *tex, unsigned int capacity) return true; } +bool CCSpriteBatchNode::init() +{ + CCTexture2D * texture = new CCTexture2D(); + texture->autorelease(); + return this->initWithTexture(texture, 0); +} + /* * init with FileImage */ diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.h b/cocos2dx/sprite_nodes/CCSpriteBatchNode.h index 037bddfaaa..54924d6c07 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.h +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.h @@ -105,6 +105,7 @@ public: The file will be loaded using the TextureMgr. */ bool initWithFile(const char* fileImage, unsigned int capacity); + bool init(); void increaseAtlasCapacity(); From 9ca7fa468ad675cb678af7e282e7866476ca1c99 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 30 May 2012 15:34:50 -0700 Subject: [PATCH 022/257] Added default init method for CCLabelTTF (See: 24125b93aad2d4fc7ebf1bc6e4ef6b8b83ff770d). --- cocos2dx/label_nodes/CCLabelTTF.cpp | 42 +++++++++++++++++++++++++++++ cocos2dx/label_nodes/CCLabelTTF.h | 7 +++++ 2 files changed, 49 insertions(+) diff --git a/cocos2dx/label_nodes/CCLabelTTF.cpp b/cocos2dx/label_nodes/CCLabelTTF.cpp index fece124454..7ecf00f5f9 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.cpp +++ b/cocos2dx/label_nodes/CCLabelTTF.cpp @@ -52,6 +52,20 @@ CCLabelTTF::~CCLabelTTF() CC_SAFE_DELETE(m_pString); } +CCLabelTTF * CCLabelTTF::node() +{ + CCLabelTTF * pRet = new CCLabelTTF(); + if (pRet && pRet->init()) + { + pRet->autorelease(); + } + else + { + CC_SAFE_DELETE(pRet); + } + return pRet; +} + CCLabelTTF * CCLabelTTF::labelWithString(const char *label, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize) { CCLabelTTF *pRet = new CCLabelTTF(); @@ -119,6 +133,34 @@ bool CCLabelTTF::initWithString(const char *label, const char *fontName, float f } return false; } +void CCLabelTTF::setFontName(const char *fontName) +{ + if(this->m_pFontName == NULL || strcmp(this->m_pFontName->c_str(), fontName)) + { + CC_SAFE_DELETE(m_pFontName); + this->m_pFontName = new std::string(fontName); + + this->setString(this->m_pString->c_str()); + } +} +void CCLabelTTF::setFontSize(float fontSize) +{ + if(this->m_fFontSize != fontSize) + { + this->m_fFontSize = fontSize; + + this->setString(this->m_pString->c_str()); + } +} +void CCLabelTTF::setHorizontalAlignment(CCTextAlignment pCCTextAlignment) +{ + if(this->m_eAlignment != pCCTextAlignment) + { + this->m_eAlignment = pCCTextAlignment; + + this->setString(this->m_pString->c_str()); + } +} void CCLabelTTF::setString(const char *label) { if (m_pString) diff --git a/cocos2dx/label_nodes/CCLabelTTF.h b/cocos2dx/label_nodes/CCLabelTTF.h index ee2ecaaa6b..0ed619db18 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.h +++ b/cocos2dx/label_nodes/CCLabelTTF.h @@ -52,11 +52,18 @@ public: bool initWithString(const char *label, const char *fontName, float fontSize); /** initializes the CCLabelTTF */ bool init(); + /** Creates an label. + */ + static CCLabelTTF * node(); /** changes the string to render * @warning Changing the string is as expensive as creating a new CCLabelTTF. To obtain better performance use CCLabelAtlas */ virtual void setString(const char *label); virtual const char* getString(void); + virtual void setFontName(const char *fontName); + virtual void setFontSize(float fontSize); + virtual void setHorizontalAlignment(CCTextAlignment); +// virtual void setVerticalAlignment(...); // ( See: 63d9724ac4d81a05c6ec7feea0c01bcd27c8fc6b ) virtual CCLabelProtocol* convertToLabelProtocol() { return (CCLabelProtocol*)this; } protected: From c754dac31bda9d859fd4aa97ebddb462fcf13e7a Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 30 May 2012 15:36:00 -0700 Subject: [PATCH 023/257] Added missing case kCCBPropTypeFontTTF in CCNodeLoader::parseProperties. --- cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp index 37b2bcabd8..11f330af49 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp @@ -203,6 +203,13 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * } break; } + case kCCBPropTypeFontTTF: { + std::string fontTTF = this->parsePropTypeFontTTF(pNode, pParent, pCCBReader); + if(setProp) { + this->onHandlePropTypeFontTTF(pNode, pParent, propertyName, fontTTF, pCCBReader); + } + break; + } case kCCBPropTypeString: { std::string string = this->parsePropTypeString(pNode, pParent, pCCBReader); if(setProp) { @@ -766,7 +773,7 @@ void CCNodeLoader::onHandlePropTypeString(CCNode * pNode, CCNode * pParent, std: ASSERT_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pString, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pText, CCBReader * pCCBReader) { ASSERT_UNEXPECTED_PROPERTY(pPropertyName); } From 5578521a691c305bb9a1284c27e509790db88615 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 30 May 2012 15:37:36 -0700 Subject: [PATCH 024/257] Fixed CCLabelBMFontLoader (according to changes in: 827ee160b5a5c73c0c6e2ecf07eff16fd1deb467). --- .../CCBIReader/CCLabelBMFontLoader.cpp | 25 ++++++++++++++----- .../CCBIReader/CCLabelBMFontLoader.h | 2 ++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.cpp b/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.cpp index 575d23c107..4922eb424b 100644 --- a/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.cpp @@ -6,14 +6,11 @@ using namespace cocos2d::extension; #define PROPERTY_COLOR "color" #define PROPERTY_OPACITY "opacity" #define PROPERTY_BLENDFUNC "blendFunc" +#define PROPERTY_FNTFILE "fntFile" +#define PROPERTY_STRING "string" CCLabelBMFont * CCLabelBMFontLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { - if(pRet && pRet->initWithString(str, fntFile)) { - pRet->autorelease(); - return pRet; - } - CC_SAFE_DELETE(pRet); - return new CCLabelBMFont(); // TODO Is this problematic? + return CCLabelBMFont::node(); } void CCLabelBMFontLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { @@ -38,4 +35,20 @@ void CCLabelBMFontLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pPa } else { CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); } +} + +void CCLabelBMFontLoader::onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pFntFile, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_FNTFILE) == 0) { + ((CCLabelBMFont *)pNode)->setFntFile(pFntFile.c_str()); + } else { + CCNodeLoader::onHandlePropTypeFntFile(pNode, pParent, pPropertyName, pFntFile, pCCBReader); + } +} + +void CCLabelBMFontLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pText, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_STRING) == 0) { + ((CCLabelBMFont *)pNode)->setString(pText.c_str()); + } else { + CCNodeLoader::onHandlePropTypeText(pNode, pParent, pPropertyName, pText, pCCBReader); + } } \ No newline at end of file diff --git a/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h b/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h index d91cc4c07f..342cf5d616 100644 --- a/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h @@ -15,6 +15,8 @@ class CCLabelBMFontLoader : public CCNodeLoader { virtual void onHandlePropTypeColor3(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::ccColor3B, CCBReader *); virtual void onHandlePropTypeByte(CCNode *, CCNode *, std::string, unsigned char, CCBReader *); virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeFntFile(CCNode *, CCNode *, std::string, std::string, CCBReader *); + virtual void onHandlePropTypeText(CCNode *, CCNode *, std::string, std::string, CCBReader *); }; NS_CC_EXT_END From 6b3fa4abb6c60579aab980dc67ec9f75e8e9c1c1 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 30 May 2012 15:38:20 -0700 Subject: [PATCH 025/257] Added CCLabelTTFLoader. --- cocos2dx/extensions/CCBIReader/CCBReader.cpp | 2 + .../CCBIReader/CCLabelTTFLoader.cpp | 76 +++++++++++++++++++ .../extensions/CCBIReader/CCLabelTTFLoader.h | 26 +++++++ 3 files changed, 104 insertions(+) create mode 100644 cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp create mode 100644 cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.h diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.cpp b/cocos2dx/extensions/CCBIReader/CCBReader.cpp index 1db1d0a3ad..a7c5a469aa 100644 --- a/cocos2dx/extensions/CCBIReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCBReader.cpp @@ -3,6 +3,7 @@ #include "CCLayerColorLoader.h" #include "CCLayerGradientLoader.h" #include "CCLabelBMFontLoader.h" +#include "CCLabelTTFLoader.h" #include "CCSpriteLoader.h" #include "CCBReader.h" #include @@ -17,6 +18,7 @@ CCBReader::CCBReader() { this->registerCCNodeLoader("CCLayerGradient", new CCLayerGradientLoader()); this->registerCCNodeLoader("CCSprite", new CCSpriteLoader()); this->registerCCNodeLoader("CCLabelBMFont", new CCLabelBMFontLoader()); + this->registerCCNodeLoader("CCLabelTTF", new CCLabelTTFLoader()); } void CCBReader::registerCCNodeLoader(std::string pClassName, CCNodeLoader * pCCNodeLoader) { diff --git a/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp b/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp new file mode 100644 index 0000000000..de92809547 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp @@ -0,0 +1,76 @@ +#import "CCLabelTTFLoader.h" + +using namespace cocos2d; +using namespace cocos2d::extension; + +#define PROPERTY_COLOR "color" +#define PROPERTY_OPACITY "opacity" +#define PROPERTY_BLENDFUNC "blendFunc" +#define PROPERTY_FONTNAME "fontName" +#define PROPERTY_FONTSIZE "fontSize" +#define PROPERTY_HORIZONTALALIGNMENT "horizontalAlignment" +#define PROPERTY_VERTICALALIGNMENT "verticalAlignment" +#define PROPERTY_STRING "string" + +CCLabelTTF * CCLabelTTFLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { + return CCLabelTTF::node(); +} + +void CCLabelTTFLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_COLOR) == 0) { + ((CCLabelTTF *)pNode)->setColor(pCCColor3B); + } else { + CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); + } +} + +void CCLabelTTFLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, std::string pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_OPACITY) == 0) { + ((CCLabelTTF *)pNode)->setOpacity(pByte); + } else { + CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); + } +} + +void CCLabelTTFLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_BLENDFUNC) == 0) { + ((CCLabelTTF *)pNode)->setBlendFunc(pCCBlendFunc); + } else { + CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); + } +} + +void CCLabelTTFLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pFontTTF, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_FONTNAME) == 0) { + ((CCLabelTTF *)pNode)->setFontName(pFontTTF.c_str()); + } else { + CCNodeLoader::onHandlePropTypeFontTTF(pNode, pParent, pPropertyName, pFontTTF, pCCBReader); + } +} + +void CCLabelTTFLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pText, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_STRING) == 0) { + ((CCLabelTTF *)pNode)->setString(pText.c_str()); + } else { + CCNodeLoader::onHandlePropTypeText(pNode, pParent, pPropertyName, pText, pCCBReader); + } +} + +void CCLabelTTFLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float pFloatScale, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_FONTSIZE) == 0) { + ((CCLabelTTF *)pNode)->setFontSize(pFloatScale); + } else { + CCNodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pFloatScale, pCCBReader); + } +} + +void CCLabelTTFLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, std::string pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_HORIZONTALALIGNMENT) == 0) { + ((CCLabelTTF *)pNode)->setHorizontalAlignment(CCTextAlignment(pIntegerLabeled)); + } else if(pPropertyName.compare(PROPERTY_VERTICALALIGNMENT) == 0) { + // TODO Add support when CCLabelTTF supports it. ( See: 63d9724ac4d81a05c6ec7feea0c01bcd27c8fc6b ) + // ((CCLabelTTF *)pNode)->setVerticalAlignment(pIntegerLabeled); + } else { + CCNodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader); + } +} \ No newline at end of file diff --git a/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.h b/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.h new file mode 100644 index 0000000000..5df3dc4259 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.h @@ -0,0 +1,26 @@ +#ifndef _CCLABELTTF_LOADER_H_ +#define _CCLABELTTF_LOADER_H_ + +#include "CCNodeLoader.h" + +NS_CC_EXT_BEGIN + +/* Forward declaration. */ +class CCBReader; + +class CCLabelTTFLoader : public CCNodeLoader { + protected: + virtual cocos2d::CCLabelTTF * createCCNode(cocos2d::CCNode *, CCBReader *); + + virtual void onHandlePropTypeColor3(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::ccColor3B, CCBReader *); + virtual void onHandlePropTypeByte(CCNode *, CCNode *, std::string, unsigned char, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeFontTTF(CCNode *, CCNode *, std::string, std::string, CCBReader *); + virtual void onHandlePropTypeText(CCNode *, CCNode *, std::string, std::string, CCBReader *); + virtual void onHandlePropTypeFloatScale(CCNode *, CCNode *, std::string, float, CCBReader *); + virtual void onHandlePropTypeIntegerLabeled(CCNode *, CCNode *, std::string, int, CCBReader *); +}; + +NS_CC_EXT_END + +#endif From d0f101b82016fc49f3db197bc2814e166827ae3b Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 30 May 2012 16:14:02 -0700 Subject: [PATCH 026/257] Added missing ASSERT_FAIL_UNEXPECTED_PROPERTY in CCNOdeLoader::onHandlePropTypeSize. --- .../extensions/CCBIReader/CCNodeLoader.cpp | 58 ++++++++++--------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp index 11f330af49..3cb8290a7a 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp @@ -9,8 +9,8 @@ #define PROPERTY_IGNOREANCHORPOINTFORPOSITION "ignoreAnchorPointForPosition" #define PROPERTY_VISIBLE "visible" -#define ASSERT_UNEXPECTED_PROPERTY(PROPERTY) printf("Unexpected property type: '%s'!\n", PROPERTY.c_str()); assert(false) -#define ASSERT_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) printf("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false) +#define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) printf("Unexpected property type: '%s'!\n", PROPERTY.c_str()); assert(false) +#define ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) printf("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false) using namespace cocos2d; using namespace cocos2d::extension; @@ -248,7 +248,7 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * break; } default: - ASSERT_UNEXPECTED_PROPERTYTYPE(type); + ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(type); break; } } @@ -660,7 +660,7 @@ void CCNodeLoader::onHandlePropTypePosition(CCNode * pNode, CCNode * pParent, st if(pPropertyName.compare(PROPERTY_POSITION) == 0) { pNode->setPosition(pPosition); } else { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } @@ -668,17 +668,19 @@ void CCNodeLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, std:: if(pPropertyName.compare(PROPERTY_ANCHORPOINT) == 0) { pNode->setAnchorPoint(pPoint); } else { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } void CCNodeLoader::onHandlePropTypePointLock(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCPoint pPointLock, CCBReader * pCCBReader) { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void CCNodeLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSize pSize, CCBReader * pCCBReader) { if(pPropertyName.compare(PROPERTY_CONTENTSIZE) == 0) { pNode->setContentSize(pSize); + } else { + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } @@ -687,40 +689,40 @@ void CCNodeLoader::onHandlePropTypeScaleLock(CCNode * pNode, CCNode * pParent, s pNode->setScaleX(pScaleLock[0]); pNode->setScaleX(pScaleLock[1]); } else { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } void CCNodeLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float pFloat, CCBReader * pCCBReader) { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void CCNodeLoader::onHandlePropTypeDegrees(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float pDegrees, CCBReader * pCCBReader) { if(pPropertyName.compare(PROPERTY_ROTATION) == 0) { pNode->setRotation(pDegrees); } else { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } void CCNodeLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float pFloatScale, CCBReader * pCCBReader) { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void CCNodeLoader::onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, std::string pPropertyName, int pInteger, CCBReader * pCCBReader) { if(pPropertyName.compare(PROPERTY_TAG) == 0) { pNode->setTag(pInteger); } else { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } void CCNodeLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, std::string pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void CCNodeLoader::onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float * pFloatVar, CCBReader * pCCBReader) { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void CCNodeLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, std::string pPropertyName, bool pCheck, CCBReader * pCCBReader) { @@ -729,64 +731,64 @@ void CCNodeLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, std:: } else if(pPropertyName.compare(PROPERTY_IGNOREANCHORPOINTFORPOSITION) == 0) { pNode->setIsRelativeAnchorPoint(!pCheck); } else { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } void CCNodeLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void CCNodeLoader::onHandlePropTypeAnimation(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCAnimation * pCCAnimation, CCBReader * pCCBReader) { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void CCNodeLoader::onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader) { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void CCNodeLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, std::string pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void CCNodeLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void CCNodeLoader::onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader) { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void CCNodeLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, std::string pPropertyName, bool * pFlip, CCBReader * pCCBReader) { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void CCNodeLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void CCNodeLoader::onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pFntFile, CCBReader * pCCBReader) { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void CCNodeLoader::onHandlePropTypeString(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pString, CCBReader * pCCBReader) { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void CCNodeLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pText, CCBReader * pCCBReader) { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void CCNodeLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pFontTTF, CCBReader * pCCBReader) { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void CCNodeLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, std::string pPropertyName, void * pBlock, CCBReader * pCCBReader) { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void CCNodeLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, std::string pPropertyName, void * pBlock, CCBReader * pCCBReader) { - ASSERT_UNEXPECTED_PROPERTY(pPropertyName); + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } void CCNodeLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pCCBFileName, CCBReader * pCCBReader) { From 36e6d94d46dd5580273a228739907a23eb1cbcf2 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 30 May 2012 16:49:51 -0700 Subject: [PATCH 027/257] Added setter for dimensions of CCLabelTTF (According to: 302dd76b4f87ddb18cc571ebec3be0811ea534ca). --- cocos2dx/label_nodes/CCLabelTTF.cpp | 9 +++++++++ cocos2dx/label_nodes/CCLabelTTF.h | 1 + 2 files changed, 10 insertions(+) diff --git a/cocos2dx/label_nodes/CCLabelTTF.cpp b/cocos2dx/label_nodes/CCLabelTTF.cpp index 7ecf00f5f9..7ddcf9632d 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.cpp +++ b/cocos2dx/label_nodes/CCLabelTTF.cpp @@ -152,6 +152,15 @@ void CCLabelTTF::setFontSize(float fontSize) this->setString(this->m_pString->c_str()); } } +void CCLabelTTF::setDimensions(CCSize dimensions) +{ + if(this->m_tDimensions.width != dimensions.width || this->m_tDimensions.height != dimensions.height) + { + this->m_tDimensions = dimensions; + + this->setString(this->m_pString->c_str()); + } +} void CCLabelTTF::setHorizontalAlignment(CCTextAlignment pCCTextAlignment) { if(this->m_eAlignment != pCCTextAlignment) diff --git a/cocos2dx/label_nodes/CCLabelTTF.h b/cocos2dx/label_nodes/CCLabelTTF.h index 0ed619db18..6c15587528 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.h +++ b/cocos2dx/label_nodes/CCLabelTTF.h @@ -62,6 +62,7 @@ public: virtual const char* getString(void); virtual void setFontName(const char *fontName); virtual void setFontSize(float fontSize); + virtual void setDimensions(CCSize dim); virtual void setHorizontalAlignment(CCTextAlignment); // virtual void setVerticalAlignment(...); // ( See: 63d9724ac4d81a05c6ec7feea0c01bcd27c8fc6b ) From 6e9fac0a58b5ef63782747b3884de125ac2b1f47 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 30 May 2012 16:51:33 -0700 Subject: [PATCH 028/257] Cleanup. --- cocos2dx/extensions/CCBIReader/CCBReader.cpp | 6 +- cocos2dx/extensions/CCBIReader/CCBReader.h | 20 +-- .../CCBIReader/CCLabelBMFontLoader.h | 4 +- .../CCBIReader/CCLabelTTFLoader.cpp | 9 ++ .../extensions/CCBIReader/CCLabelTTFLoader.h | 5 +- .../CCBIReader/CCLayerColorLoader.h | 4 +- .../CCBIReader/CCLayerGradientLoader.h | 4 +- .../extensions/CCBIReader/CCLayerLoader.h | 2 +- cocos2dx/extensions/CCBIReader/CCNodeLoader.h | 114 +++++++++--------- .../extensions/CCBIReader/CCSpriteLoader.h | 4 +- 10 files changed, 92 insertions(+), 80 deletions(-) diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.cpp b/cocos2dx/extensions/CCBIReader/CCBReader.cpp index a7c5a469aa..9b8ea9d664 100644 --- a/cocos2dx/extensions/CCBIReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCBReader.cpp @@ -1,3 +1,5 @@ +#include "CCBReader.h" + #include "CCNodeLoader.h" #include "CCLayerLoader.h" #include "CCLayerColorLoader.h" @@ -5,8 +7,7 @@ #include "CCLabelBMFontLoader.h" #include "CCLabelTTFLoader.h" #include "CCSpriteLoader.h" -#include "CCBReader.h" -#include +#include "CCScale9SpriteLoader.h" using namespace cocos2d; using namespace cocos2d::extension; @@ -19,6 +20,7 @@ CCBReader::CCBReader() { this->registerCCNodeLoader("CCSprite", new CCSpriteLoader()); this->registerCCNodeLoader("CCLabelBMFont", new CCLabelBMFontLoader()); this->registerCCNodeLoader("CCLabelTTF", new CCLabelTTFLoader()); + this->registerCCNodeLoader("CCScale9Sprite", new CCScale9SpriteLoader()); } void CCBReader::registerCCNodeLoader(std::string pClassName, CCNodeLoader * pCCNodeLoader) { diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.h b/cocos2dx/extensions/CCBIReader/CCBReader.h index bba76d3ff6..fae89937a0 100644 --- a/cocos2dx/extensions/CCBIReader/CCBReader.h +++ b/cocos2dx/extensions/CCBIReader/CCBReader.h @@ -72,14 +72,14 @@ class CCNodeLoader; /** * @brief Parse CCBI file which is generated by CocosBuilder */ -class CC_DLL CCBReader : public cocos2d::CCObject { // TODO Why extend CCObject? -> Also all Loaders should extend from CCObject? +class CC_DLL CCBReader : public CCObject { // TODO Why extend CCObject? -> Also all Loaders should extend from CCObject? private: unsigned char * mBytes; int mCurrentByte; int mCurrentBit; - cocos2d::CCNode * mOwner; /* TODO Should that be any 'Object'? */ - cocos2d::CCNode * mRootNode; - cocos2d::CCSize mRootContainerSize; + CCNode * mOwner; /* TODO Should that be any 'Object'? */ + CCNode * mRootNode; + CCSize mRootContainerSize; std::vector mStringCache; std::map mCCNodeLoaders; @@ -91,13 +91,13 @@ class CC_DLL CCBReader : public cocos2d::CCObject { // TODO Why extend CCObject? /* Destructor. */ ~CCBReader(); - CCNode * readNodeGraphFromFile(const char *, cocos2d::CCNode * = NULL); - CCNode * readNodeGraphFromFile(const char *, cocos2d::CCNode *, CCSize); + CCNode * readNodeGraphFromFile(const char *, CCNode * = NULL); + CCNode * readNodeGraphFromFile(const char *, CCNode *, CCSize); void registerCCNodeLoader(std::string, CCNodeLoader *); CCNodeLoader * getCCNodeLoader(std::string); - cocos2d::CCNode * getOwner(); - cocos2d::CCSize getContainerSize(cocos2d::CCNode *); + CCNode * getOwner(); + CCSize getContainerSize(CCNode *); std::string lastPathComponent(std::string); std::string deletePathExtension(std::string); std::string toLowerCase(std::string); @@ -115,8 +115,8 @@ class CC_DLL CCBReader : public cocos2d::CCObject { // TODO Why extend CCObject? private: bool readHeader(); bool readStringCache(); - cocos2d::CCNode * readNodeGraph(); - cocos2d::CCNode * readNodeGraph(cocos2d::CCNode *); + CCNode * readNodeGraph(); + CCNode * readNodeGraph(CCNode *); bool getBit(); void alignBits(); diff --git a/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h b/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h index 342cf5d616..c78603451e 100644 --- a/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h @@ -10,9 +10,9 @@ class CCBReader; class CCLabelBMFontLoader : public CCNodeLoader { protected: - virtual cocos2d::CCLabelBMFont * createCCNode(cocos2d::CCNode *, CCBReader *); + virtual CCLabelBMFont * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeColor3(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::ccColor3B, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode *, CCNode *, std::string, ccColor3B, CCBReader *); virtual void onHandlePropTypeByte(CCNode *, CCNode *, std::string, unsigned char, CCBReader *); virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *); virtual void onHandlePropTypeFntFile(CCNode *, CCNode *, std::string, std::string, CCBReader *); diff --git a/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp b/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp index de92809547..cc7e88b174 100644 --- a/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp @@ -11,6 +11,7 @@ using namespace cocos2d::extension; #define PROPERTY_HORIZONTALALIGNMENT "horizontalAlignment" #define PROPERTY_VERTICALALIGNMENT "verticalAlignment" #define PROPERTY_STRING "string" +#define PROPERTY_DIMENSIONS "dimensions" CCLabelTTF * CCLabelTTFLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { return CCLabelTTF::node(); @@ -73,4 +74,12 @@ void CCLabelTTFLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * p } else { CCNodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader); } +} + +void CCLabelTTFLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSize pSize, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_DIMENSIONS) == 0) { + ((CCLabelTTF *)pNode)->setDimensions(pSize); + } else { + CCNodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, pCCBReader); + } } \ No newline at end of file diff --git a/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.h b/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.h index 5df3dc4259..4d89c3a1e5 100644 --- a/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.h @@ -10,15 +10,16 @@ class CCBReader; class CCLabelTTFLoader : public CCNodeLoader { protected: - virtual cocos2d::CCLabelTTF * createCCNode(cocos2d::CCNode *, CCBReader *); + virtual CCLabelTTF * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeColor3(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::ccColor3B, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode *, CCNode *, std::string, ccColor3B, CCBReader *); virtual void onHandlePropTypeByte(CCNode *, CCNode *, std::string, unsigned char, CCBReader *); virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *); virtual void onHandlePropTypeFontTTF(CCNode *, CCNode *, std::string, std::string, CCBReader *); virtual void onHandlePropTypeText(CCNode *, CCNode *, std::string, std::string, CCBReader *); virtual void onHandlePropTypeFloatScale(CCNode *, CCNode *, std::string, float, CCBReader *); virtual void onHandlePropTypeIntegerLabeled(CCNode *, CCNode *, std::string, int, CCBReader *); + virtual void onHandlePropTypeSize(CCNode *, CCNode *, std::string, CCSize, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.h b/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.h index 758b2bd841..0d86a46a75 100644 --- a/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.h @@ -10,9 +10,9 @@ class CCBReader; class CCLayerColorLoader : public CCLayerLoader { protected: - virtual cocos2d::CCLayerColor * createCCNode(cocos2d::CCNode *, CCBReader *); + virtual CCLayerColor * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeColor3(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::ccColor3B, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode *, CCNode *, std::string, ccColor3B, CCBReader *); virtual void onHandlePropTypeByte(CCNode *, CCNode *, std::string, unsigned char, CCBReader *); virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *); }; diff --git a/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.h b/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.h index 83ca562838..6565fdc02f 100644 --- a/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.h @@ -10,9 +10,9 @@ class CCBReader; class CCLayerGradientLoader : public CCLayerLoader { protected: - virtual cocos2d::CCLayerGradient * createCCNode(cocos2d::CCNode *, CCBReader *); + virtual CCLayerGradient * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeColor3(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::ccColor3B, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode *, CCNode *, std::string, ccColor3B, CCBReader *); virtual void onHandlePropTypeByte(CCNode *, CCNode *, std::string, unsigned char, CCBReader *); virtual void onHandlePropTypePoint(CCNode *, CCNode *, std::string, CCPoint, CCBReader *); virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *); diff --git a/cocos2dx/extensions/CCBIReader/CCLayerLoader.h b/cocos2dx/extensions/CCBIReader/CCLayerLoader.h index 497ba3496d..dec385f247 100644 --- a/cocos2dx/extensions/CCBIReader/CCLayerLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCLayerLoader.h @@ -10,7 +10,7 @@ class CCBReader; class CCLayerLoader : public CCNodeLoader { protected: - virtual cocos2d::CCLayer * createCCNode(cocos2d::CCNode *, CCBReader *); + virtual CCLayer * createCCNode(CCNode *, CCBReader *); virtual void onHandlePropTypeCheck(CCNode *, CCNode *, std::string, bool, CCBReader *); }; diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.h b/cocos2dx/extensions/CCBIReader/CCNodeLoader.h index 4538639f5a..ae463b3537 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.h @@ -11,68 +11,68 @@ class CCBReader; class CC_DLL CCNodeLoader { public: - virtual cocos2d::CCNode * loadCCNode(cocos2d::CCNode *, CCBReader *); - virtual void parseProperties(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual CCNode * loadCCNode(CCNode *, CCBReader *); + virtual void parseProperties(CCNode *, CCNode *, CCBReader *); protected: - virtual cocos2d::CCNode * createCCNode(cocos2d::CCNode *, CCBReader *); + virtual CCNode * createCCNode(CCNode *, CCBReader *); - virtual cocos2d::CCPoint parsePropTypePosition(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual cocos2d::CCPoint parsePropTypePoint(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual cocos2d::CCPoint parsePropTypePointLock(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual cocos2d::CCSize parsePropTypeSize(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual float * parsePropTypeScaleLock(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual float parsePropTypeFloat(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual float parsePropTypeDegrees(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual float parsePropTypeFloatScale(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual int parsePropTypeInteger(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual int parsePropTypeIntegerLabeled(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual float * parsePropTypeFloatVar(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual bool parsePropTypeCheck(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual cocos2d::CCSpriteFrame * parsePropTypeSpriteFrame(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual cocos2d::CCAnimation * parsePropTypeAnimation(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual cocos2d::CCTexture2D * parsePropTypeTexture(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual unsigned char parsePropTypeByte(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual cocos2d::ccColor3B parsePropTypeColor3(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual cocos2d::ccColor4F * parsePropTypeColor4FVar(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual bool * parsePropTypeFlip(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual cocos2d::ccBlendFunc parsePropTypeBlendFunc(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual std::string parsePropTypeFntFile(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual std::string parsePropTypeString(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual std::string parsePropTypeText(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual std::string parsePropTypeFontTTF(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual void * parsePropTypeBlock(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual void * parsePropTypeBlockCCControl(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); - virtual std::string parsePropTypeCCBFile(cocos2d::CCNode *, cocos2d::CCNode *, CCBReader *); + virtual CCPoint parsePropTypePosition(CCNode *, CCNode *, CCBReader *); + virtual CCPoint parsePropTypePoint(CCNode *, CCNode *, CCBReader *); + virtual CCPoint parsePropTypePointLock(CCNode *, CCNode *, CCBReader *); + virtual CCSize parsePropTypeSize(CCNode *, CCNode *, CCBReader *); + virtual float * parsePropTypeScaleLock(CCNode *, CCNode *, CCBReader *); + virtual float parsePropTypeFloat(CCNode *, CCNode *, CCBReader *); + virtual float parsePropTypeDegrees(CCNode *, CCNode *, CCBReader *); + virtual float parsePropTypeFloatScale(CCNode *, CCNode *, CCBReader *); + virtual int parsePropTypeInteger(CCNode *, CCNode *, CCBReader *); + virtual int parsePropTypeIntegerLabeled(CCNode *, CCNode *, CCBReader *); + virtual float * parsePropTypeFloatVar(CCNode *, CCNode *, CCBReader *); + virtual bool parsePropTypeCheck(CCNode *, CCNode *, CCBReader *); + virtual CCSpriteFrame * parsePropTypeSpriteFrame(CCNode *, CCNode *, CCBReader *); + virtual CCAnimation * parsePropTypeAnimation(CCNode *, CCNode *, CCBReader *); + virtual CCTexture2D * parsePropTypeTexture(CCNode *, CCNode *, CCBReader *); + virtual unsigned char parsePropTypeByte(CCNode *, CCNode *, CCBReader *); + virtual ccColor3B parsePropTypeColor3(CCNode *, CCNode *, CCBReader *); + virtual ccColor4F * parsePropTypeColor4FVar(CCNode *, CCNode *, CCBReader *); + virtual bool * parsePropTypeFlip(CCNode *, CCNode *, CCBReader *); + virtual ccBlendFunc parsePropTypeBlendFunc(CCNode *, CCNode *, CCBReader *); + virtual std::string parsePropTypeFntFile(CCNode *, CCNode *, CCBReader *); + virtual std::string parsePropTypeString(CCNode *, CCNode *, CCBReader *); + virtual std::string parsePropTypeText(CCNode *, CCNode *, CCBReader *); + virtual std::string parsePropTypeFontTTF(CCNode *, CCNode *, CCBReader *); + virtual void * parsePropTypeBlock(CCNode *, CCNode *, CCBReader *); + virtual void * parsePropTypeBlockCCControl(CCNode *, CCNode *, CCBReader *); + virtual std::string parsePropTypeCCBFile(CCNode *, CCNode *, CCBReader *); - virtual void onHandlePropTypePosition(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::CCPoint, CCBReader *); - virtual void onHandlePropTypePoint(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::CCPoint, CCBReader *); - virtual void onHandlePropTypePointLock(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::CCPoint, CCBReader *); - virtual void onHandlePropTypeSize(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::CCSize, CCBReader *); - virtual void onHandlePropTypeScaleLock(cocos2d::CCNode *, cocos2d::CCNode *, std::string, float *, CCBReader *); - virtual void onHandlePropTypeFloat(cocos2d::CCNode *, cocos2d::CCNode *, std::string, float, CCBReader *); - virtual void onHandlePropTypeDegrees(cocos2d::CCNode *, cocos2d::CCNode *, std::string, float, CCBReader *); - virtual void onHandlePropTypeFloatScale(cocos2d::CCNode *, cocos2d::CCNode *, std::string, float, CCBReader *); - virtual void onHandlePropTypeInteger(cocos2d::CCNode *, cocos2d::CCNode *, std::string, int, CCBReader *); - virtual void onHandlePropTypeIntegerLabeled(cocos2d::CCNode *, cocos2d::CCNode *, std::string, int, CCBReader *); - virtual void onHandlePropTypeFloatVar(cocos2d::CCNode *, cocos2d::CCNode *, std::string, float *, CCBReader *); - virtual void onHandlePropTypeCheck(cocos2d::CCNode *, cocos2d::CCNode *, std::string, bool, CCBReader *); - virtual void onHandlePropTypeSpriteFrame(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::CCSpriteFrame *, CCBReader *); - virtual void onHandlePropTypeAnimation(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::CCAnimation *, CCBReader *); - virtual void onHandlePropTypeTexture(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::CCTexture2D *, CCBReader *); - virtual void onHandlePropTypeByte(cocos2d::CCNode *, cocos2d::CCNode *, std::string, unsigned char, CCBReader *); - virtual void onHandlePropTypeColor3(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::ccColor3B, CCBReader *); - virtual void onHandlePropTypeColor4FVar(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::ccColor4F *, CCBReader *); - virtual void onHandlePropTypeFlip(cocos2d::CCNode *, cocos2d::CCNode *, std::string, bool *, CCBReader *); - virtual void onHandlePropTypeBlendFunc(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::ccBlendFunc, CCBReader *); - virtual void onHandlePropTypeFntFile(cocos2d::CCNode *, cocos2d::CCNode *, std::string, std::string, CCBReader *); - virtual void onHandlePropTypeString(cocos2d::CCNode *, cocos2d::CCNode *, std::string, std::string, CCBReader *); - virtual void onHandlePropTypeText(cocos2d::CCNode *, cocos2d::CCNode *, std::string, std::string, CCBReader *); - virtual void onHandlePropTypeFontTTF(cocos2d::CCNode *, cocos2d::CCNode *, std::string, std::string, CCBReader *); - virtual void onHandlePropTypeBlock(cocos2d::CCNode *, cocos2d::CCNode *, std::string, void *, CCBReader *); - virtual void onHandlePropTypeBlockCCControl(cocos2d::CCNode *, cocos2d::CCNode *, std::string, void *, CCBReader *); - virtual void onHandlePropTypeCCBFile(cocos2d::CCNode *, cocos2d::CCNode *, std::string, std::string, CCBReader *); + virtual void onHandlePropTypePosition(CCNode *, CCNode *, std::string, CCPoint, CCBReader *); + virtual void onHandlePropTypePoint(CCNode *, CCNode *, std::string, CCPoint, CCBReader *); + virtual void onHandlePropTypePointLock(CCNode *, CCNode *, std::string, CCPoint, CCBReader *); + virtual void onHandlePropTypeSize(CCNode *, CCNode *, std::string, CCSize, CCBReader *); + virtual void onHandlePropTypeScaleLock(CCNode *, CCNode *, std::string, float *, CCBReader *); + virtual void onHandlePropTypeFloat(CCNode *, CCNode *, std::string, float, CCBReader *); + virtual void onHandlePropTypeDegrees(CCNode *, CCNode *, std::string, float, CCBReader *); + virtual void onHandlePropTypeFloatScale(CCNode *, CCNode *, std::string, float, CCBReader *); + virtual void onHandlePropTypeInteger(CCNode *, CCNode *, std::string, int, CCBReader *); + virtual void onHandlePropTypeIntegerLabeled(CCNode *, CCNode *, std::string, int, CCBReader *); + virtual void onHandlePropTypeFloatVar(CCNode *, CCNode *, std::string, float *, CCBReader *); + virtual void onHandlePropTypeCheck(CCNode *, CCNode *, std::string, bool, CCBReader *); + virtual void onHandlePropTypeSpriteFrame(CCNode *, CCNode *, std::string, CCSpriteFrame *, CCBReader *); + virtual void onHandlePropTypeAnimation(CCNode *, CCNode *, std::string, CCAnimation *, CCBReader *); + virtual void onHandlePropTypeTexture(CCNode *, CCNode *, std::string, CCTexture2D *, CCBReader *); + virtual void onHandlePropTypeByte(CCNode *, CCNode *, std::string, unsigned char, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode *, CCNode *, std::string, ccColor3B, CCBReader *); + virtual void onHandlePropTypeColor4FVar(CCNode *, CCNode *, std::string, ccColor4F *, CCBReader *); + virtual void onHandlePropTypeFlip(CCNode *, CCNode *, std::string, bool *, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeFntFile(CCNode *, CCNode *, std::string, std::string, CCBReader *); + virtual void onHandlePropTypeString(CCNode *, CCNode *, std::string, std::string, CCBReader *); + virtual void onHandlePropTypeText(CCNode *, CCNode *, std::string, std::string, CCBReader *); + virtual void onHandlePropTypeFontTTF(CCNode *, CCNode *, std::string, std::string, CCBReader *); + virtual void onHandlePropTypeBlock(CCNode *, CCNode *, std::string, void *, CCBReader *); + virtual void onHandlePropTypeBlockCCControl(CCNode *, CCNode *, std::string, void *, CCBReader *); + virtual void onHandlePropTypeCCBFile(CCNode *, CCNode *, std::string, std::string, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBIReader/CCSpriteLoader.h b/cocos2dx/extensions/CCBIReader/CCSpriteLoader.h index ec8cd6e8e5..04b0782649 100644 --- a/cocos2dx/extensions/CCBIReader/CCSpriteLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCSpriteLoader.h @@ -10,9 +10,9 @@ class CCBReader; class CCSpriteLoader : public CCNodeLoader { protected: - virtual cocos2d::CCSprite * createCCNode(cocos2d::CCNode *, CCBReader *); + virtual CCSprite * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeColor3(cocos2d::CCNode *, cocos2d::CCNode *, std::string, cocos2d::ccColor3B, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode *, CCNode *, std::string, ccColor3B, CCBReader *); virtual void onHandlePropTypeByte(CCNode *, CCNode *, std::string, unsigned char, CCBReader *); virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *); virtual void onHandlePropTypeSpriteFrame(CCNode *, CCNode *, std::string, CCSpriteFrame *, CCBReader *); From b7130c3d6342edd0a89cfc330b14bb5035d9fa1b Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 30 May 2012 16:52:02 -0700 Subject: [PATCH 029/257] Added (dysfunctional) CCScale9SpriteLoader. --- .../CCBIReader/CCScale9SpriteLoader.cpp | 58 +++++++++++++++++++ .../CCBIReader/CCScale9SpriteLoader.h | 24 ++++++++ 2 files changed, 82 insertions(+) create mode 100644 cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.cpp create mode 100644 cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.h diff --git a/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.cpp b/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.cpp new file mode 100644 index 0000000000..929417b437 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.cpp @@ -0,0 +1,58 @@ +#import "CCScale9SpriteLoader.h" + +using namespace cocos2d; +using namespace cocos2d::extension; + +#define PROPERTY_CONTENTSIZE "contentSize" +#define PROPERTY_DISPLAYFRAME "displayFrame" +#define PROPERTY_COLOR "color" +#define PROPERTY_OPACITY "opacity" +#define PROPERTY_BLENDFUNC "blendFunc" +#define PROPERTY_DIMENSIONS "dimensions" + +CCScale9Sprite * CCScale9SpriteLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { + return CCScale9Sprite::node(); +} + +void CCScale9SpriteLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_DISPLAYFRAME) == 0) { + ((CCSprite *)pNode)->setDisplayFrame(pCCSpriteFrame); + } else { + CCNodeLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pCCSpriteFrame, pCCBReader); + } +} + +void CCScale9SpriteLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_COLOR) == 0) { + ((CCScale9Sprite *)pNode)->setColor(pCCColor3B); + } else { + CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); + } +} + +void CCScale9SpriteLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, std::string pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_OPACITY) == 0) { + ((CCScale9Sprite *)pNode)->setOpacity(pByte); + } else { + CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); + } +} + +void CCScale9SpriteLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_BLENDFUNC) == 0) { + // TODO Not exported by CocosBuilder yet! + // ((CCScale9Sprite *)pNode)->setBlendFunc(pCCBlendFunc); + } else { + CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); + } +} + +void CCScale9SpriteLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSize pSize, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_CONTENTSIZE) == 0) { + ((CCScale9Sprite *)pNode)->setContentSize(pSize); + } else if(pPropertyName.compare(PROPERTY_DIMENSIONS) == 0) { + ((CCScale9Sprite *)pNode)->setContentSize(pSize); + } else { + CCNodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, pCCBReader); + } +} \ No newline at end of file diff --git a/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.h b/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.h new file mode 100644 index 0000000000..d7ad30747e --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.h @@ -0,0 +1,24 @@ +#ifndef _CCSCALE9SPRITE_LOADER_H_ +#define _CCSCALE9SPRITE_LOADER_H_ + +#include "CCNodeLoader.h" + +NS_CC_EXT_BEGIN + +/* Forward declaration. */ +class CCBReader; + +class CCScale9SpriteLoader : public CCNodeLoader { + protected: + virtual CCScale9Sprite * createCCNode(CCNode *, CCBReader *); + + virtual void onHandlePropTypeColor3(CCNode *, CCNode *, std::string, ccColor3B, CCBReader *); + virtual void onHandlePropTypeByte(CCNode *, CCNode *, std::string, unsigned char, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeSpriteFrame(CCNode *, CCNode *, std::string, CCSpriteFrame *, CCBReader *); + virtual void onHandlePropTypeSize(CCNode *, CCNode *, std::string, CCSize, CCBReader *); +}; + +NS_CC_EXT_END + +#endif From a283bfed4f1194d41e8cf43d85b969f190601726 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 31 May 2012 09:52:39 +0800 Subject: [PATCH 030/257] fixed #1191: update xcode template --- .../lib_cocos2dx.xctemplate/TemplateInfo.plist.REMOVED.git-id | 2 +- tools/xcode4_template_generator/run_generator.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist.REMOVED.git-id b/template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist.REMOVED.git-id index 7f4ba3bbc4..280b63ea85 100644 --- a/template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist.REMOVED.git-id +++ b/template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist.REMOVED.git-id @@ -1 +1 @@ -a0108c887c7176801731f3e9503263b79a9eeb62 \ No newline at end of file +44156c1d13cbc3821278cc9d51e878adfd5ea603 \ No newline at end of file diff --git a/tools/xcode4_template_generator/run_generator.sh b/tools/xcode4_template_generator/run_generator.sh index 9805277fcf..410ef5428f 100755 --- a/tools/xcode4_template_generator/run_generator.sh +++ b/tools/xcode4_template_generator/run_generator.sh @@ -2,7 +2,7 @@ pushd ../../ echo "generating libcocos2dx" mkdir -p template/xcode4/lib_cocos2dx.xctemplate -python ./tools/xcode4_template_generator/template_generator.py --directory cocos2dx --identifier libcocos2dx --prefix libs --exclude "android win32 airplay wophone bada third_party CCImage.cpp CCThread.cpp proj.ios CCFileUtilsCommon_cpp.h CCImageCommon_cpp.h CCFileUtils.cpp Android.mk Linux linux qnx marmalade" > ./template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist +python ./tools/xcode4_template_generator/template_generator.py --directory cocos2dx --identifier libcocos2dx --prefix libs --exclude "android win32 airplay wophone bada third_party CCImage.cpp CCThread.cpp proj.ios CCFileUtilsCommon_cpp.h CCImageCommon_cpp.h CCFileUtils.cpp Android.mk Linux linux qnx marmalade CCBReader_v1.cpp" > ./template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist echo "generating libcocosdenshion" mkdir -p template/xcode4/lib_cocosdenshion.xctemplate From 97fbcf6b6a3568b903a991ff19a474b42355ee58 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 31 May 2012 10:11:24 +0800 Subject: [PATCH 031/257] fixed #1191: modify comment --- create-android-project.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/create-android-project.sh b/create-android-project.sh index c0ce7b5b68..4c52767cad 100755 --- a/create-android-project.sh +++ b/create-android-project.sh @@ -99,8 +99,7 @@ check_path(){ create_android_project(){ echo "Input package path. For example: org.cocos2dx.example" read PACKAGE_PATH - echo "Now cocos2d-x supports Android 2.1-update1, 2.2, 2.3 & 3.0" - echo "Other versions have not tested." + echo "Now cocos2d-x supports Android 2.2 or upper version" $ANDROID_SDK_ROOT_LOCAL/tools/android list targets echo "input target id:" read TARGET_ID From 9be586e4ec94e89f6c72ccfc764208f06a8011bc Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 31 May 2012 10:13:05 +0800 Subject: [PATCH 032/257] Updated main.cpp for each project of android. --- HelloWorld/proj.android/jni/helloworld/main.cpp | 2 +- testjs/proj.android/jni/helloworld/main.cpp | 2 +- tests/proj.android/jni/tests/main.cpp | 2 +- .../template/android/jni/LuaProjectTemplate/main.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/HelloWorld/proj.android/jni/helloworld/main.cpp b/HelloWorld/proj.android/jni/helloworld/main.cpp index dce5fa5213..4da6f3544f 100644 --- a/HelloWorld/proj.android/jni/helloworld/main.cpp +++ b/HelloWorld/proj.android/jni/helloworld/main.cpp @@ -30,7 +30,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi CCEGLView *view = &CCEGLView::sharedOpenGLView(); view->setFrameSize(w, h); // set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line. - // view.setDesignResolutionSize(480, 320); + // view->setDesignResolutionSize(480, 320); AppDelegate *pAppDelegate = new AppDelegate(); CCApplication::sharedApplication().run(); diff --git a/testjs/proj.android/jni/helloworld/main.cpp b/testjs/proj.android/jni/helloworld/main.cpp index 735dcf6539..355326d2be 100644 --- a/testjs/proj.android/jni/helloworld/main.cpp +++ b/testjs/proj.android/jni/helloworld/main.cpp @@ -28,7 +28,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi CCEGLView *view = &CCEGLView::sharedOpenGLView(); view->setFrameSize(w, h); // set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line. - // view.setDesignResolutionSize(480, 320); + // view->setDesignResolutionSize(480, 320); AppDelegate *pAppDelegate = new AppDelegate(); CCApplication::sharedApplication().run(); diff --git a/tests/proj.android/jni/tests/main.cpp b/tests/proj.android/jni/tests/main.cpp index e2ce2ef055..9eb857591e 100644 --- a/tests/proj.android/jni/tests/main.cpp +++ b/tests/proj.android/jni/tests/main.cpp @@ -28,7 +28,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi CCEGLView *view = &CCEGLView::sharedOpenGLView(); view->setFrameSize(w, h); // set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line. - // view.setDesignResolutionSize(480, 320); + // view->setDesignResolutionSize(480, 320); AppDelegate *pAppDelegate = new AppDelegate(); CCApplication::sharedApplication().run(); diff --git a/tools/lua_project_generator/template/android/jni/LuaProjectTemplate/main.cpp b/tools/lua_project_generator/template/android/jni/LuaProjectTemplate/main.cpp index 8246e103a2..38a963b47a 100644 --- a/tools/lua_project_generator/template/android/jni/LuaProjectTemplate/main.cpp +++ b/tools/lua_project_generator/template/android/jni/LuaProjectTemplate/main.cpp @@ -19,7 +19,7 @@ void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(JNIEnv* env, jobject thi CCEGLView *view = &CCEGLView::sharedOpenGLView(); view->setFrameSize(w, h); // set the design resolution screen size, if you want to use Design Resoulution scaled to current screen, please uncomment next line. - // view.setDesignResolutionSize(480, 320); + // view->setDesignResolutionSize(480, 320); AppDelegate *pAppDelegate = new AppDelegate(); CCApplication::sharedApplication().run(); From 9237804b29b95140205dad961066e1cc2c49786f Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 31 May 2012 10:14:00 +0800 Subject: [PATCH 033/257] modify engine version --- cocos2dx/cocos2d.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/cocos2d.cpp b/cocos2dx/cocos2d.cpp index 374ac000d3..993aec7f80 100644 --- a/cocos2dx/cocos2d.cpp +++ b/cocos2dx/cocos2d.cpp @@ -30,7 +30,7 @@ NS_CC_BEGIN const char* cocos2dVersion() { - return "cocos2d-2.0-rc0a-x-0.1.0"; + return "cocos2d-2.0-rc0a-x-2.0"; } NS_CC_END From 30fedb78d53c28a2a35e2be19b0eb046e66ff813 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 31 May 2012 11:07:08 +0800 Subject: [PATCH 034/257] update changelog --- CHANGELOG | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 7d4bbf6bef..3881d9f06e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,90 @@ +cocos2d-2.0-rc0a-x-2.0 @May.31 2012 + [all platforms] + Bug #1094: fix a bug that nothing will be shown when using CCParticleBatchNode + Bug #1115: fix a bug that CCFileUtils::fullPathFromRelativePath() with resolution parameter return error value with empty string + Bug #1137: fix a memory leak in CCLabelBMFont and sync the implementation of CCLabelBMFont to gles20 branch + Bug #1138: fix a memory leak in CCTextureCache::addPVRImage. + Bug #1155: revert CCDirector singleton to original implementation + Bug #1157: fix a bug that nothing is shown in TMX Orthogonal Test + Bug #1158: fix a bug in CCParticleSystemQuad + Bug #1159: update "CallFuncND + auto remove" test demo + Bug #1160: rename 'CGFloat' to 'CCFloat' + Bug #1164: add the render mode which uses VBO without VAO in CCParticleSystemQuad + Bug #1165: merge pull request #842 + Bug #1187: fix a bug that spanish(Buen día) cannot be shown completely in CCLabelBMFont unicode test + Bug #1189: CCLabelBMFont updateLabel() optimizations and fixes + Bug #1212: fix a bug that TMXBug787Test crash. + Bug #1217: fix a bug that EaseActions reverse broken + Bug #1232: fix a bug that CCLayerGradient::updateColor() assign wrong value to m_pSquareColors + Bug #1244: fix memory leak in CCParticleSystem::initWithDictionary() + Bug #1273: fix a bug that app will crash after clicking closed button in TextureCacheTest + Bug #1275: fix memory leaks in tests project + Bug #1277: implement CCToggleVisibility::copyWithZone() + Feature #1114: integrate CCControlExtension and implement corresponding tests + Feature #1180: synchronize CCConfiguration + Feature #1194: merge texturewatcher contributed by NetGragon + Feature #1205: add ccbreader and test case for CocosBuilder + Feature #1240: support TIFF format picture + Feature #1258: merge Rolando's testjs into gles20 branch + Refactor #1156: synchronize CCDirector + Refactor #1166: improve CCString and CCArray, optimize CCDictionary + Refactor #1176: change linebreak symbol to UNIX format ('\n'), replace 'tab' with four spaces + Refactor #1177: refactor platform + Refactor #1178: use macro NS_CC_BEGIN instead of "namespace cocos2d {", NS_CC_END instead of "}" + Refactor #1188: refactor directory structure + Refactor #1191: update templates for all platforms + Refactor #1198: optimize CCTextureCache::removeUnusedTextures() + Refactor #1203: remove CCFileUtils::setResource(const char* pszZipFileName) and SimpleAudioEngine::setResource + Refactor #1204: refactor AppDelegate::initInstance() + Refactor #1206: remove some unused files, only supports iOS, win32 and android + Refactor #1211: translate Chinese comments to English for CCTextureWatcher and CCListView + Refactor #1246: fix CCDirector using CCLabelBMFont instead of CCLabelTTF + Refactor #1252: add CCEGLViewProtocol::getFrameSize() method for getting the real screen size of device + Refactor #1253: add static method "purgeConfiguration" for CCConfiguration to avoid memory leak + [iOS] + Bug #1109: add parentheses to remove Xcode warnings + Bug #1230: fix a bug that Calculation of string width may be wrong on iOS + Bug #1266: fix a bug that CCTextureCahce::addImageAsync() don't work correctly on iOS + Feature #1095: IOS screen resolution support + [android] + Bug #1139: fix a bug that screen becomes black when backing from background + Bug #1140: fix a bug that ParticleTest crashed + Bug #1141: fix a bug that NodeTest crashed in StressTest1 and StressTest2 + Bug #1142: fix a bug that TouchesTest crashed + Bug #1143: fix a bug that MenuTest crashed + Bug #1144: fix a bug that ParallaxTest crashed + Bug #1145: fix a bug that TileMap crashed + Bug #1146: fix a bug that IntervalTest crashed + Bug #1147: fix a bug that ChipmunkAccelTouchTest crashed + Bug #1148: fix a bug that LabelTest crashed + Bug #1149: fix a bug that SpriteTest crashed when go to second test case + Bug #1150: fix a bug that RenderTextureTest crashed at second test case + Bug #1151: fix a bug that Box2DTest crashed + Bug #1152: fix a bug that PerformanceTest crashed at 1, 2, 5 test cases + Bug #1185: fix a bug that when backing to foreground, will lost texture if it uses sprite batch node + Bug #1216: fix JNI memory leaks + Bug #1229: fix a bug that android port can not be compiled on ndk android-8 level + Bug #1236: fix a bug that JniHelper::jstring2string may crash when parameter is null + Bug #1237: fix a bug that line number message printed by CCAssert is wrong + Bug #1279: fix a bug that NodeNonOpaqueTest can't be shown correctly + Feature #1247: add profiler support for android + Feature #1265: build dynamic library of spidermonkey for Android, and implement testjs for android + Refactor #1179: popup a message box when invoking CCAssert() on Android + Refactor #1201: simplify the usage of writing Android.mk + [windows] + Bug #1215: fix a bug that Win32 retina cannot work + Bug #1251: add CocosBuilderTest to the test project for VS2008 + Bug #1264: fix wrong string alignment when using utf-8 encoded text with CCLabelTTF + Bug #1268: fix a bug that Testjs will crash after clicking the close button on win32 + Bug #1270: fix some warning on win32 + Feature #1186: add console window for Win32 application, all debug message output to this console window + Feature #1263: build dynamic library of spidermonkey for win32, and add testjs project to solution + Refactor #1170: remove win32 template of wophone + [lua] + Refactor #1190: update lua binding to 2.0 + Refactor #1220: using CCString::stringWithContentsOfFile to get string from lua script files + + cocos2d-1.0.1-x-0.12.0 @ Mar.5 2012 [all platforms] Bug #925: rename HelloWorld/Resource to HelloWorld/Resources From cec50ae2d852043cec63cbd3fe3067de9baf8b59 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 31 May 2012 13:07:25 +0800 Subject: [PATCH 035/257] fixed #1280: BitmapFontMultiLineAlignment test can't work correctly. We should invoke 'this->setString(m_sString_initial.c_str(), true);' in the 'CCLabelBMFont::updateLabel'. --- cocos2dx/label_nodes/CCLabelBMFont.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index 357e6590e4..b5bf2ac9f1 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -1076,6 +1076,7 @@ void CCLabelBMFont::setAnchorPoint(const CCPoint& point) // LabelBMFont - Alignment void CCLabelBMFont::updateLabel() { + this->setString(m_sString_initial.c_str(), true); if (m_fWidth > 0) { // Step 1: Make multiline From 63a6b97bc5c57138ae38952c5f23173b02a00142 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 31 May 2012 15:32:18 +0800 Subject: [PATCH 036/257] fixed #1280: Renamed some functions. --- cocos2dx/label_nodes/CCLabelBMFont.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index b5bf2ac9f1..6d710f19cc 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -216,7 +216,6 @@ static bool isspace_unicode(unsigned short ch) static void cc_utf8_trim_ws(std::vector* str) { - using namespace std; int len = str->size(); if ( len <= 0 ) @@ -321,14 +320,14 @@ cc_utf8_get_char (const char * p) } /* - * cc_utf8_from_cstr: + * cc_utf16_from_utf8: * @str_old: pointer to the start of a C string. * * Creates a utf8 string from a cstring. * * Return value: the newly created utf8 string. * */ -static unsigned short* cc_utf8_from_cstr(const char* str_old) +static unsigned short* cc_utf16_from_utf8(const char* str_old) { int len = cc_utf8_strlen(str_old, -1); @@ -344,14 +343,15 @@ static unsigned short* cc_utf8_from_cstr(const char* str_old) return str_new; } -static std::vector cc_utf8_vec_from_cstr(const unsigned short* str) +static std::vector cc_utf16_vec_from_utf16_str(const unsigned short* str) { int len = cc_wcslen(str); std::vector str_new; for (int i = 0; i < len; ++i) + { str_new.push_back(str[i]); - + } return str_new; } @@ -790,7 +790,7 @@ bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile, f m_tImageOffset = imageOffset; m_fWidth = width; CC_SAFE_DELETE_ARRAY(m_sString); - m_sString = cc_utf8_from_cstr(theString); + m_sString = cc_utf16_from_utf8(theString); m_cOpacity = 255; m_tColor = ccWHITE; m_tContentSize = CCSizeZero; @@ -943,7 +943,7 @@ void CCLabelBMFont::createFontChars() tmpSize.height = (float) totalHeight; this->setContentSize(CC_SIZE_PIXELS_TO_POINTS(tmpSize)); - + } //LabelBMFont - CCLabelProtocol protocol @@ -955,7 +955,7 @@ void CCLabelBMFont::setString(const char *newString) void CCLabelBMFont::setString(const char *newString, bool fromUpdate) { CC_SAFE_DELETE_ARRAY(m_sString); - m_sString = cc_utf8_from_cstr(newString); + m_sString = cc_utf16_from_utf8(newString); m_sString_initial = newString; updateString(fromUpdate); @@ -963,7 +963,6 @@ void CCLabelBMFont::setString(const char *newString, bool fromUpdate) void CCLabelBMFont::updateString(bool fromUpdate) { - if (m_pChildren && m_pChildren->count() != 0) { CCObject* child; @@ -1076,11 +1075,12 @@ void CCLabelBMFont::setAnchorPoint(const CCPoint& point) // LabelBMFont - Alignment void CCLabelBMFont::updateLabel() { - this->setString(m_sString_initial.c_str(), true); + this->setString(m_sString_initial.c_str(), true); + if (m_fWidth > 0) { // Step 1: Make multiline - vector str_whole = cc_utf8_vec_from_cstr(m_sString); + vector str_whole = cc_utf16_vec_from_utf16_str(m_sString); unsigned int stringLength = str_whole.size(); vector multiline_string; multiline_string.reserve( stringLength ); From fe9fb347aa2e4431169ef600414c50cd8b6d8dba Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Thu, 31 May 2012 11:47:16 -0700 Subject: [PATCH 037/257] CCScale9Sprite: Added support for insets by floats and CCRect. Fixed bug for positioning for uneven insets. Changing texture no longer affects the anchor point. Made it possible to set the SpriteFrame. (Changes according to https://github.com/YannickL/CCControlExtension/commits/gles20: d00c4f90ab53d5295bce03123ddbccc4fa0acf58, ed56cb1558c755748437d152f2f7a4bb5a1455ba, c4bbcb9beb2febfb4b55323709e30082af902c90, 5da062de92d39d91b014f87809fc30ba501538fc) --- .../CCControlExtension/CCScale9Sprite.cpp | 270 ++++++++++++++---- .../CCControlExtension/CCScale9Sprite.h | 24 +- 2 files changed, 228 insertions(+), 66 deletions(-) diff --git a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp index 220a198119..e8fc1358e0 100644 --- a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp @@ -25,12 +25,50 @@ CCScale9Sprite::~CCScale9Sprite() } +bool CCScale9Sprite::init() +{ + return this->initWithBatchNode(NULL, CCRectZero, CCRectZero); +} + bool CCScale9Sprite::initWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect, CCRect capInsets) { + if(batchnode) + { + this->updateWithBatchNode(batchnode, rect, capInsets); + this->setAnchorPoint(ccp(0.5f,0.5f)); + } + this->m_positionsAreDirty = true; - CCAssert(batchnode != NULL, "The batchnode must be not nil."); + return this; +} + +bool CCScale9Sprite::updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect, CCRect capInsets) +{ + // Release old sprites + this->removeAllChildrenWithCleanup(true); + + if(this->topLeft) + { + CC_SAFE_RELEASE(this->topLeft); + CC_SAFE_RELEASE(this->top); + CC_SAFE_RELEASE(this->topRight); + CC_SAFE_RELEASE(this->left); + CC_SAFE_RELEASE(this->centre); + CC_SAFE_RELEASE(this->right); + CC_SAFE_RELEASE(this->bottomLeft); + CC_SAFE_RELEASE(this->bottom); + CC_SAFE_RELEASE(this->bottomRight); + } - scale9Image = batchnode; + if(this->scale9Image != batchnode) + { + CC_SAFE_RELEASE(this->scale9Image); + scale9Image = batchnode; // TODO No retain on purpose? + } + + scale9Image->removeAllChildrenWithCleanup(true); + + m_capInsets = capInsets; // If there is no given rect if ( CCRect::CCRectEqualToRect(rect, CCRectZero) ) @@ -45,14 +83,14 @@ bool CCScale9Sprite::initWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect m_spriteRect = rect; m_originalSize = rect.size; m_preferredSize = m_originalSize; - m_capInsets = capInsets; + m_capInsetsInternal = capInsets; this->setAnchorPoint(ccp(0.5f, 0.5f)); // If there is no specified center region - if ( CCRect::CCRectEqualToRect(m_capInsets, CCRectZero) ) + if ( CCRect::CCRectEqualToRect(m_capInsetsInternal, CCRectZero) ) { // Apply the 3x3 grid format - m_capInsets = CCRectMake( + m_capInsetsInternal = CCRectMake( rect.origin.x + m_originalSize.width / 3, rect.origin.y + m_originalSize.height / 3, m_originalSize.width / 3, @@ -70,71 +108,71 @@ bool CCScale9Sprite::initWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect // // Centre - centre = CCSprite::spriteWithTexture(scale9Image->getTexture(), m_capInsets); + centre = CCSprite::spriteWithTexture(scale9Image->getTexture(), m_capInsetsInternal); scale9Image->addChild(centre ,0 ,pCentre); // Top - top = CCSprite::spriteWithTexture(scale9Image->getTexture(), CCRectMake(m_capInsets.origin.x, + top = CCSprite::spriteWithTexture(scale9Image->getTexture(), CCRectMake(m_capInsetsInternal.origin.x, t, - m_capInsets.size.width, - m_capInsets.origin.y - t)); + m_capInsetsInternal.size.width, + m_capInsetsInternal.origin.y - t)); scale9Image->addChild(top, 1, pTop); // Bottom - bottom = CCSprite::spriteWithTexture(scale9Image->getTexture(), CCRectMake( m_capInsets.origin.x, - m_capInsets.origin.y + m_capInsets.size.height, - m_capInsets.size.width, - h - (m_capInsets.origin.y - t + m_capInsets.size.height) )); + bottom = CCSprite::spriteWithTexture(scale9Image->getTexture(), CCRectMake( m_capInsetsInternal.origin.x, + m_capInsetsInternal.origin.y + m_capInsetsInternal.size.height, + m_capInsetsInternal.size.width, + h - (m_capInsetsInternal.origin.y - t + m_capInsetsInternal.size.height) )); scale9Image->addChild(bottom, 1, pBottom); // Left left = CCSprite::spriteWithTexture(scale9Image->getTexture(), CCRectMake( l, - m_capInsets.origin.y, - m_capInsets.origin.x - l, - m_capInsets.size.height) ); + m_capInsetsInternal.origin.y, + m_capInsetsInternal.origin.x - l, + m_capInsetsInternal.size.height) ); scale9Image->addChild(left, 1, pLeft); // Right right = CCSprite::spriteWithTexture(scale9Image->getTexture(), CCRectMake( - m_capInsets.origin.x + m_capInsets.size.width, - m_capInsets.origin.y, - w - (m_capInsets.origin.x - l + m_capInsets.size.width), - m_capInsets.size.height)); + m_capInsetsInternal.origin.x + m_capInsetsInternal.size.width, + m_capInsetsInternal.origin.y, + w - (m_capInsetsInternal.origin.x - l + m_capInsetsInternal.size.width), + m_capInsetsInternal.size.height)); scale9Image->addChild(right, 1, pRight); // Top left topLeft = CCSprite::spriteWithTexture(scale9Image->getTexture(), CCRectMake( l, t, - m_capInsets.origin.x - l, - m_capInsets.origin.y - t)); + m_capInsetsInternal.origin.x - l, + m_capInsetsInternal.origin.y - t)); scale9Image->addChild(topLeft, 2, pTopLeft); // Top right topRight = CCSprite::spriteWithTexture(scale9Image->getTexture(), CCRectMake( - m_capInsets.origin.x + m_capInsets.size.width, + m_capInsetsInternal.origin.x + m_capInsetsInternal.size.width, t, - w - (m_capInsets.origin.x - l + m_capInsets.size.width), - m_capInsets.origin.y - t)); + w - (m_capInsetsInternal.origin.x - l + m_capInsetsInternal.size.width), + m_capInsetsInternal.origin.y - t)); scale9Image->addChild(topRight, 2, pTopRight); // Bottom left bottomLeft = CCSprite::spriteWithTexture(scale9Image->getTexture(), CCRectMake( l, - m_capInsets.origin.y + m_capInsets.size.height, - m_capInsets.origin.x - l, - h - (m_capInsets.origin.y - t + m_capInsets.size.height)) ); + m_capInsetsInternal.origin.y + m_capInsetsInternal.size.height, + m_capInsetsInternal.origin.x - l, + h - (m_capInsetsInternal.origin.y - t + m_capInsetsInternal.size.height)) ); scale9Image->addChild(bottomLeft, 2, pBottomLeft); // Bottom right bottomRight = CCSprite::spriteWithTexture(scale9Image->getTexture(), CCRectMake( - m_capInsets.origin.x + m_capInsets.size.width, - m_capInsets.origin.y + m_capInsets.size.height, - w - (m_capInsets.origin.x - l + m_capInsets.size.width), - h - (m_capInsets.origin.y - t + m_capInsets.size.height)) ); + m_capInsetsInternal.origin.x + m_capInsetsInternal.size.width, + m_capInsetsInternal.origin.y + m_capInsetsInternal.size.height, + w - (m_capInsetsInternal.origin.x - l + m_capInsetsInternal.size.width), + h - (m_capInsetsInternal.origin.y - t + m_capInsetsInternal.size.height)) ); scale9Image->addChild(bottomRight, 2, pBottomRight); @@ -146,13 +184,17 @@ bool CCScale9Sprite::initWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect void CCScale9Sprite::setContentSize(const CCSize &size) { - CCNode::setContentSize(size); - setAnchorPoint(ccp(0.5f,0.5f)); - + this->m_positionsAreDirty = true; +} + +void CCScale9Sprite::updatePositions() +{ + CCSize size = this->m_tContentSize; + CCLOG("scale9 set content size %0.2f %0.2f",size.width,size.height); CCLOG("leftCap %0.2f rightCap %0.2f",topLeft->getContentSize().width,topRight->getContentSize().width); - + float sizableWidth = size.width - topLeft->getContentSize().width - topRight->getContentSize().width; float sizableHeight = size.height - topLeft->getContentSize().height - bottomRight->getContentSize().height; float horizontalScale = sizableWidth/centre->getContentSize().width; @@ -161,27 +203,39 @@ void CCScale9Sprite::setContentSize(const CCSize &size) centre->setScaleY(verticalScale); float rescaledWidth = centre->getContentSize().width * horizontalScale; float rescaledHeight = centre->getContentSize().height * verticalScale; - - float despx = size.width*0.5f; - float despy = size.height*0.5f; - - //Position corners - topLeft->setPosition(ccp(-rescaledWidth/2 - topLeft->getContentSize().width/2 +despx, rescaledHeight/2 + topLeft->getContentSize().height*0.5f +despy) ); - topRight->setPosition(ccp(rescaledWidth/2 + topRight->getContentSize().width/2 +despx, rescaledHeight/2 + topRight->getContentSize().height*0.5f +despy)); - bottomLeft->setPosition(ccp(-rescaledWidth/2 - bottomLeft->getContentSize().width/2 +despx, -rescaledHeight/2 - bottomLeft->getContentSize().height*0.5f +despy)); - bottomRight->setPosition(ccp(rescaledWidth/2 + bottomRight->getContentSize().width/2 +despx, -rescaledHeight/2 + -bottomRight->getContentSize().height*0.5f +despy)); - + + float leftWidth = bottomLeft->getContentSize().width; + float bottomHeight = bottomLeft->getContentSize().height; + + bottomLeft->setAnchorPoint(ccp(0,0)); + bottomRight->setAnchorPoint(ccp(0,0)); + topLeft->setAnchorPoint(ccp(0,0)); + topRight->setAnchorPoint(ccp(0,0)); + left->setAnchorPoint(ccp(0,0)); + right->setAnchorPoint(ccp(0,0)); + top->setAnchorPoint(ccp(0,0)); + bottom->setAnchorPoint(ccp(0,0)); + centre->setAnchorPoint(ccp(0,0)); + + // Position corners + bottomLeft->setPosition(ccp(0,0)); + bottomRight->setPosition(ccp(leftWidth+rescaledWidth,0)); + topLeft->setPosition(ccp(0, bottomHeight+rescaledHeight)); + topRight->setPosition(ccp(leftWidth+rescaledWidth, bottomHeight+rescaledHeight)); + + // Scale and position borders + left->setPosition(ccp(0, bottomHeight)); + left->setScaleY(verticalScale); + right->setPosition(ccp(leftWidth+rescaledWidth,bottomHeight)); + right->setScaleY(verticalScale); + bottom->setPosition(ccp(leftWidth,0)); + bottom->setScaleX(horizontalScale); + top->setPosition(ccp(leftWidth,bottomHeight+rescaledHeight)); top->setScaleX(horizontalScale); - top->setPosition(ccp(0+despx,rescaledHeight/2 + topLeft->getContentSize().height*0.5f +despy)); - bottom->setScaleX (horizontalScale); - bottom->setPosition(ccp(0+despx,-rescaledHeight/2 - bottomLeft->getContentSize().height*0.5f +despy)); - left->setScaleY (verticalScale); - left->setPosition(ccp(-rescaledWidth/2 - topLeft->getContentSize().width/2 +despx, 0+despy)); - right->setScaleY (verticalScale); - right->setPosition(ccp(rescaledWidth/2 + topRight->getContentSize().width/2 +despx, 0+despy)); - - centre->setPosition(ccp(despx, despy)); - + + // Position centre + centre->setPosition(ccp(leftWidth, bottomHeight)); + CCLOG("Scale9 setContentSize %02.f x %02.f <%0.2f x %0.2f>",sizableWidth,sizableHeight,horizontalScale,verticalScale); } @@ -263,7 +317,7 @@ CCScale9Sprite* CCScale9Sprite::spriteWithFile(const char* file) bool CCScale9Sprite::initWithSpriteFrame(CCSpriteFrame* spriteFrame, CCRect capInsets) { CCAssert(spriteFrame != NULL, "Sprite frame must be not nil"); - + CCSpriteBatchNode *batchnode = CCSpriteBatchNode::batchNodeWithTexture(spriteFrame->getTexture(), 9); bool pReturn = this->initWithBatchNode(batchnode, spriteFrame->getRect(), capInsets); return pReturn; @@ -301,7 +355,7 @@ CCScale9Sprite* CCScale9Sprite::spriteWithSpriteFrame(CCSpriteFrame* spriteFrame bool CCScale9Sprite::initWithSpriteFrameName(const char* spriteFrameName, CCRect capInsets) { CCAssert(spriteFrameName != NULL, "Invalid spriteFrameName for sprite"); - + CCSpriteFrame *frame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(spriteFrameName); bool pReturn = this->initWithSpriteFrame(frame, capInsets); return pReturn; @@ -317,7 +371,6 @@ CCScale9Sprite* CCScale9Sprite::spriteWithSpriteFrameName(const char* spriteFram } CC_SAFE_DELETE(pReturn); return NULL; - } bool CCScale9Sprite::initWithSpriteFrameName(const char* spriteFrameName) @@ -387,7 +440,7 @@ const ccColor3B& CCScale9Sprite::getColor(void) void CCScale9Sprite::setOpacity(GLubyte var) { m_cOpacity = var; - + if (scale9Image->getChildren() && scale9Image->getChildren()->count() != 0) { CCObject* child; @@ -420,10 +473,22 @@ GLubyte CCScale9Sprite::getOpacity() return m_cOpacity; } +void CCScale9Sprite::setPreferredSize(CCSize preferedSize) +{ + this->setContentSize(preferedSize); + this->m_preferredSize = preferedSize; +} + +CCSize CCScale9Sprite::getPreferredSize() +{ + return this->m_preferredSize; +} void CCScale9Sprite::setCapInsets(CCRect capInsets) { - m_capInsets = capInsets; + CCSize contentSize = this->m_tContentSize; + this->updateWithBatchNode(this->scale9Image, this->m_spriteRect, capInsets); + this->setContentSize(contentSize); } CCRect CCScale9Sprite::getCapInsets() @@ -431,6 +496,23 @@ CCRect CCScale9Sprite::getCapInsets() return m_capInsets; } +void CCScale9Sprite::updateCapInset() +{ + CCRect insets; + if (this->m_insetLeft == 0 && this->m_insetTop == 0 && this->m_insetRight == 0 && this->m_insetBottom == 0) + { + insets = CCRectZero; + } + else + { + insets = CCRectMake(this->m_insetLeft, + this->m_insetTop, + this->m_spriteRect.size.width-this->m_insetLeft-this->m_insetRight, + this->m_spriteRect.size.height-this->m_insetTop-this->m_insetBottom); + } + this->setCapInsets(insets); +} + void CCScale9Sprite::setIsOpacityModifyRGB(bool var) { m_bIsOpacityModifyRGB = var; @@ -461,4 +543,70 @@ bool CCScale9Sprite::getIsOpacityModifyRGB() return m_bIsOpacityModifyRGB; } +void CCScale9Sprite::setSpriteFrame(CCSpriteFrame * spriteFrame) +{ + CCSpriteBatchNode * batchnode = CCSpriteBatchNode::batchNodeWithTexture(spriteFrame->getTexture(), 9); + this->updateWithBatchNode(batchnode, spriteFrame->getRect(), CCRectZero); + + // Reset insets + this->m_insetLeft = 0; + this->m_insetTop = 0; + this->m_insetRight = 0; + this->m_insetBottom = 0; +} + +float CCScale9Sprite::getInsetLeft() +{ + return this->m_insetLeft; +} + +float CCScale9Sprite::getInsetTop() +{ + return this->m_insetTop; +} + +float CCScale9Sprite::getInsetRight() +{ + return this->m_insetRight; +} + +float CCScale9Sprite::getInsetBottom() +{ + return this->m_insetBottom; +} + +void CCScale9Sprite::setInsetLeft(float insetLeft) +{ + this->m_insetLeft = insetLeft; + this->updateCapInset(); +} + +void CCScale9Sprite::setInsetTop(float insetTop) +{ + this->m_insetTop = insetTop; + this->updateCapInset(); +} + +void CCScale9Sprite::setInsetRight(float insetRight) +{ + this->m_insetRight = insetRight; + this->updateCapInset(); +} + +void CCScale9Sprite::setInsetBottom(float insetBottom) +{ + this->m_insetBottom = insetBottom; + this->updateCapInset(); +} + +void CCScale9Sprite::visit() +{ + if(this->m_positionsAreDirty) + { + this->updatePositions(); + this->m_positionsAreDirty = false; + } + CCNode::visit(); +} + NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h index 7b912463f1..6c5938e3d6 100644 --- a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h +++ b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h @@ -44,7 +44,7 @@ public: /** Prefered sprite's size. By default the prefered size is the original size. */ //if the preferredSize component is given as -1, it is ignored - CC_SYNTHESIZE(CCSize, m_preferredSize, PreferredSize); + CC_PROPERTY(CCSize, m_preferredSize, PreferredSize); /** * The end-cap insets. * On a non-resizeable sprite, this property is set to CGRectZero; the sprite @@ -56,10 +56,15 @@ public: /** Color: conforms to CCRGBAProtocol protocol */ CC_PROPERTY_PASS_BY_REF(ccColor3B, m_tColor, Color) CC_PROPERTY(CCRect, m_capInsets, CapInsets); - + CC_PROPERTY(float, m_insetLeft, InsetLeft); + CC_PROPERTY(float, m_insetTop, InsetTop); + CC_PROPERTY(float, m_insetRight, InsetRight); + CC_PROPERTY(float, m_insetBottom, InsetBottom); protected: CCRect m_spriteRect; + CCRect m_capInsetsInternal; + bool m_positionsAreDirty; CCSpriteBatchNode* scale9Image; CCSprite* topLeft; @@ -75,11 +80,17 @@ protected: /** Conforms to CocosNodeRGBA protocol. */ ccColor3B m_sColorUnmodified; bool m_bIsOpacityModifyRGB; - + + void updateCapInset(); + void updatePositions(); + public: - void virtual setContentSize(const CCSize &size); + virtual void setContentSize(const CCSize &size); + virtual void visit(); + virtual bool init(); + virtual bool initWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect, CCRect capInsets); /** * Initializes a 9-slice sprite with a texture file, a delimitation zone and @@ -273,7 +284,10 @@ public: @since v0.8 */ virtual bool getIsOpacityModifyRGB(void); - + + virtual bool updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect, CCRect capInsets); + + virtual void setSpriteFrame(CCSpriteFrame * spriteFrame); }; NS_CC_EXT_END From 8678a14b6e95532ff093fef387759193f9d2b5eb Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Thu, 31 May 2012 12:03:33 -0700 Subject: [PATCH 038/257] CCScale9Sprite: Added initialization of insets. Moved setting the default anchorpoint to its constructor. --- .../CCControlExtension/CCScale9Sprite.cpp | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp index e8fc1358e0..d2d0073a39 100644 --- a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp @@ -16,8 +16,12 @@ NS_CC_EXT_BEGIN CCScale9Sprite::CCScale9Sprite() +: m_insetLeft(0) +, m_insetTop(0) +, m_insetRight(0) +, m_insetBottom(0) { - + this->setAnchorPoint(ccp(0.5f, 0.5f)); } CCScale9Sprite::~CCScale9Sprite() @@ -35,7 +39,6 @@ bool CCScale9Sprite::initWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect if(batchnode) { this->updateWithBatchNode(batchnode, rect, capInsets); - this->setAnchorPoint(ccp(0.5f,0.5f)); } this->m_positionsAreDirty = true; @@ -47,7 +50,9 @@ bool CCScale9Sprite::updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect re // Release old sprites this->removeAllChildrenWithCleanup(true); - if(this->topLeft) + // TODO Is this needed? + /* + if(this->topLeft != NULL) { CC_SAFE_RELEASE(this->topLeft); CC_SAFE_RELEASE(this->top); @@ -59,10 +64,17 @@ bool CCScale9Sprite::updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect re CC_SAFE_RELEASE(this->bottom); CC_SAFE_RELEASE(this->bottomRight); } + */ if(this->scale9Image != batchnode) { - CC_SAFE_RELEASE(this->scale9Image); + // TODO Is this needed? + /* + if(this->scale9Image != NULL) + { + CC_SAFE_RELEASE(this->scale9Image); + } + */ scale9Image = batchnode; // TODO No retain on purpose? } @@ -109,7 +121,7 @@ bool CCScale9Sprite::updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect re // Centre centre = CCSprite::spriteWithTexture(scale9Image->getTexture(), m_capInsetsInternal); - scale9Image->addChild(centre ,0 ,pCentre); + scale9Image->addChild(centre, 0, pCentre); // Top top = CCSprite::spriteWithTexture(scale9Image->getTexture(), CCRectMake(m_capInsetsInternal.origin.x, From 948fcc3d07611e0b2dcf2cbb7aab4fb1d1ec5e5a Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Thu, 31 May 2012 12:37:28 -0700 Subject: [PATCH 039/257] CCScale9Sprite: Moved anchorpoint initialization back to updateWithBatchNode, since this is probably the intended location, but causes problems due to the order properties appear in the CCBI file format. --- cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp | 4 ++-- cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp index d2d0073a39..2e2a24fb4c 100644 --- a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp @@ -21,7 +21,7 @@ CCScale9Sprite::CCScale9Sprite() , m_insetRight(0) , m_insetBottom(0) { - this->setAnchorPoint(ccp(0.5f, 0.5f)); + } CCScale9Sprite::~CCScale9Sprite() @@ -39,6 +39,7 @@ bool CCScale9Sprite::initWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect if(batchnode) { this->updateWithBatchNode(batchnode, rect, capInsets); + this->setAnchorPoint(ccp(0.5f, 0.5f)); } this->m_positionsAreDirty = true; @@ -96,7 +97,6 @@ bool CCScale9Sprite::updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect re m_originalSize = rect.size; m_preferredSize = m_originalSize; m_capInsetsInternal = capInsets; - this->setAnchorPoint(ccp(0.5f, 0.5f)); // If there is no specified center region if ( CCRect::CCRectEqualToRect(m_capInsetsInternal, CCRectZero) ) diff --git a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h index 6c5938e3d6..0f7e38bfaf 100644 --- a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h +++ b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h @@ -86,7 +86,7 @@ protected: public: - virtual void setContentSize(const CCSize &size); + virtual void setContentSize(const CCSize & size); virtual void visit(); virtual bool init(); From 8a01e33491a4969b3e2696466d9df4bd215b77e5 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Thu, 31 May 2012 12:38:00 -0700 Subject: [PATCH 040/257] Added CCScale9SpriteLoader. --- .../extensions/CCBIReader/CCNodeLoader.cpp | 6 ++-- .../CCBIReader/CCScale9SpriteLoader.cpp | 32 +++++++++++++++---- .../CCBIReader/CCScale9SpriteLoader.h | 1 + 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp index 3cb8290a7a..a7be2fa8a3 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp @@ -138,9 +138,11 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * break; } case kCCBPropTypeSpriteFrame: { + CCSpriteFrame * ccSpriteFrame = this->parsePropTypeSpriteFrame(pNode, pParent, pCCBReader); if(setProp) { - this->onHandlePropTypeSpriteFrame(pNode, pParent, propertyName, this->parsePropTypeSpriteFrame(pNode, pParent, pCCBReader), pCCBReader); + this->onHandlePropTypeSpriteFrame(pNode, pParent, propertyName, ccSpriteFrame, pCCBReader); } + // TODO delete ccSpriteFrame; ??? break; } case kCCBPropTypeAnimation: { @@ -156,7 +158,7 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * if(setProp) { this->onHandlePropTypeTexture(pNode, pParent, propertyName, ccTexture2D, pCCBReader); } - + // TODO delete ccTexture2D; ??? break; } case kCCBPropTypeByte: { diff --git a/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.cpp b/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.cpp index 929417b437..077bdf490e 100644 --- a/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.cpp @@ -4,19 +4,23 @@ using namespace cocos2d; using namespace cocos2d::extension; #define PROPERTY_CONTENTSIZE "contentSize" -#define PROPERTY_DISPLAYFRAME "displayFrame" +#define PROPERTY_SPRITEFRAME "spriteFrame" #define PROPERTY_COLOR "color" #define PROPERTY_OPACITY "opacity" #define PROPERTY_BLENDFUNC "blendFunc" -#define PROPERTY_DIMENSIONS "dimensions" +#define PROPERTY_PREFEREDSIZE "preferedSize" // TODO Should be "preferredSize". This is a typo in cocos2d-iphone, cocos2d-x and CocosBuilder! +#define PROPERTY_INSETLEFT "insetLeft" +#define PROPERTY_INSETTOP "insetTop" +#define PROPERTY_INSETRIGHT "insetRight" +#define PROPERTY_INSETBOTTOM "insetBottom" CCScale9Sprite * CCScale9SpriteLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { return CCScale9Sprite::node(); } void CCScale9SpriteLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_DISPLAYFRAME) == 0) { - ((CCSprite *)pNode)->setDisplayFrame(pCCSpriteFrame); + if(pPropertyName.compare(PROPERTY_SPRITEFRAME) == 0) { + ((CCScale9Sprite *)pNode)->initWithSpriteFrame(pCCSpriteFrame); } else { CCNodeLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pCCSpriteFrame, pCCBReader); } @@ -49,10 +53,24 @@ void CCScale9SpriteLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pP void CCScale9SpriteLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSize pSize, CCBReader * pCCBReader) { if(pPropertyName.compare(PROPERTY_CONTENTSIZE) == 0) { - ((CCScale9Sprite *)pNode)->setContentSize(pSize); - } else if(pPropertyName.compare(PROPERTY_DIMENSIONS) == 0) { - ((CCScale9Sprite *)pNode)->setContentSize(pSize); + //((CCScale9Sprite *)pNode)->setContentSize(pSize); + } else if(pPropertyName.compare(PROPERTY_PREFEREDSIZE) == 0) { + ((CCScale9Sprite *)pNode)->setPreferredSize(pSize); } else { CCNodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, pCCBReader); } +} + +void CCScale9SpriteLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float pFloat, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_INSETLEFT) == 0) { + ((CCScale9Sprite *)pNode)->setInsetLeft(pFloat); + } else if(pPropertyName.compare(PROPERTY_INSETTOP) == 0) { + ((CCScale9Sprite *)pNode)->setInsetTop(pFloat); + } else if(pPropertyName.compare(PROPERTY_INSETRIGHT) == 0) { + ((CCScale9Sprite *)pNode)->setInsetRight(pFloat); + } else if(pPropertyName.compare(PROPERTY_INSETBOTTOM) == 0) { + ((CCScale9Sprite *)pNode)->setInsetBottom(pFloat); + } else { + CCNodeLoader::onHandlePropTypeFloat(pNode, pParent, pPropertyName, pFloat, pCCBReader); + } } \ No newline at end of file diff --git a/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.h b/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.h index d7ad30747e..accf7a8495 100644 --- a/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.h @@ -17,6 +17,7 @@ class CCScale9SpriteLoader : public CCNodeLoader { virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *); virtual void onHandlePropTypeSpriteFrame(CCNode *, CCNode *, std::string, CCSpriteFrame *, CCBReader *); virtual void onHandlePropTypeSize(CCNode *, CCNode *, std::string, CCSize, CCBReader *); + virtual void onHandlePropTypeFloat(CCNode *, CCNode *, std::string, float, CCBReader *); }; NS_CC_EXT_END From b63559d86dfa72c8cb4b67dba05785804a69fb7e Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Thu, 31 May 2012 14:57:13 -0700 Subject: [PATCH 041/257] Added CCBFileLoader.cpp. Fixed a bug in CCNodeLoader::onHandlePropTypeSize. --- .../extensions/CCBIReader/CCBFileLoader.cpp | 18 ++++++++++++ .../extensions/CCBIReader/CCBFileLoader.h | 20 +++++++++++++ cocos2dx/extensions/CCBIReader/CCBReader.cpp | 27 ++++++++++++------ cocos2dx/extensions/CCBIReader/CCBReader.h | 1 + .../extensions/CCBIReader/CCNodeLoader.cpp | 28 +++++++++++-------- cocos2dx/extensions/CCBIReader/CCNodeLoader.h | 4 +-- 6 files changed, 76 insertions(+), 22 deletions(-) create mode 100644 cocos2dx/extensions/CCBIReader/CCBFileLoader.cpp create mode 100644 cocos2dx/extensions/CCBIReader/CCBFileLoader.h diff --git a/cocos2dx/extensions/CCBIReader/CCBFileLoader.cpp b/cocos2dx/extensions/CCBIReader/CCBFileLoader.cpp new file mode 100644 index 0000000000..7e04218f9e --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCBFileLoader.cpp @@ -0,0 +1,18 @@ +#import "CCBFileLoader.h" + +using namespace cocos2d; +using namespace cocos2d::extension; + +#define PROPERTY_CCBFILE "ccbFile" + +CCNode * CCBFileLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { + return CCNode::node(); +} + +void CCBFileLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_CCBFILE) == 0) { + pNode->addChild(pCCBFileNode); + } else { + CCNodeLoader::onHandlePropTypeCCBFile(pNode, pParent, pPropertyName, pCCBFileNode, pCCBReader); + } +} diff --git a/cocos2dx/extensions/CCBIReader/CCBFileLoader.h b/cocos2dx/extensions/CCBIReader/CCBFileLoader.h new file mode 100644 index 0000000000..9875a78e6e --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCBFileLoader.h @@ -0,0 +1,20 @@ +#ifndef _CCBFILE_LOADER_H_ +#define _CCBFILE_LOADER_H_ + +#include "CCNodeLoader.h" + +NS_CC_EXT_BEGIN + +/* Forward declaration. */ +class CCBReader; + +class CCBFileLoader : public CCNodeLoader { + protected: + virtual CCNode * createCCNode(CCNode *, CCBReader *); + + virtual void onHandlePropTypeCCBFile(CCNode *, CCNode *, std::string, CCNode *, CCBReader *); +}; + +NS_CC_EXT_END + +#endif diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.cpp b/cocos2dx/extensions/CCBIReader/CCBReader.cpp index 9b8ea9d664..ddffcc98ff 100644 --- a/cocos2dx/extensions/CCBIReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCBReader.cpp @@ -8,6 +8,7 @@ #include "CCLabelTTFLoader.h" #include "CCSpriteLoader.h" #include "CCScale9SpriteLoader.h" +#include "CCBFileLoader.h" using namespace cocos2d; using namespace cocos2d::extension; @@ -21,6 +22,22 @@ CCBReader::CCBReader() { this->registerCCNodeLoader("CCLabelBMFont", new CCLabelBMFontLoader()); this->registerCCNodeLoader("CCLabelTTF", new CCLabelTTFLoader()); this->registerCCNodeLoader("CCScale9Sprite", new CCScale9SpriteLoader()); + this->registerCCNodeLoader("CCBFile", new CCBFileLoader()); +} + +CCBReader::~CCBReader() { + if(this->mBytes) { + delete this->mBytes; + this->mBytes = NULL; + } + + // TODO Also delete mCCNodeLoaders, mLoadedSpritesheets, etc... ? (Keep in mind they might be copied/inherited from another CCBReader through the copy constructor!) +} + +CCBReader::CCBReader(CCBReader * pCCBReader) { + /* Borrow CCNodeLoaders and LoadedSpriteSheets. */ + this->mLoadedSpriteSheets = pCCBReader->mLoadedSpriteSheets; + this->mCCNodeLoaders = pCCBReader->mCCNodeLoaders; } void CCBReader::registerCCNodeLoader(std::string pClassName, CCNodeLoader * pCCNodeLoader) { @@ -33,13 +50,6 @@ CCNodeLoader * CCBReader::getCCNodeLoader(std::string pClassName) { return ccNodeLoadersIterator->second; } -CCBReader::~CCBReader() { - if(this->mBytes) { - delete this->mBytes; - this->mBytes = NULL; - } -} - CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBFileName, CCNode * pOwner) { return this->readNodeGraphFromFile(pCCBFileName, pOwner, CCDirector::sharedDirector()->getWinSize()); } @@ -47,7 +57,8 @@ CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBFileName, CCNode * pO CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBFileName, CCNode * pOwner, CCSize pParentSize) { const char * path = CCFileUtils::fullPathFromRelativePath(pCCBFileName); - CCFileUtils::ccLoadFileIntoMemory(path, &this->mBytes); + unsigned long size = 0; + this->mBytes = CCFileUtils::getFileData(path, "r", &size); this->mCurrentByte = 0; this->mCurrentBit = 0; diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.h b/cocos2dx/extensions/CCBIReader/CCBReader.h index fae89937a0..f0e350e88d 100644 --- a/cocos2dx/extensions/CCBIReader/CCBReader.h +++ b/cocos2dx/extensions/CCBIReader/CCBReader.h @@ -88,6 +88,7 @@ class CC_DLL CCBReader : public CCObject { // TODO Why extend CCObject? -> Also public: /* Constructor. */ CCBReader(); + CCBReader(CCBReader *); /* Destructor. */ ~CCBReader(); diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp index a7be2fa8a3..bc07d19997 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp @@ -243,9 +243,9 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * break; } case kCCBPropTypeCCBFile: { - std::string ccbFile = this->parsePropTypeCCBFile(pNode, pParent, pCCBReader); + CCNode * ccbFileNode = this->parsePropTypeCCBFile(pNode, pParent, pCCBReader); if(setProp) { - this->onHandlePropTypeCCBFile(pNode, pParent, propertyName, ccbFile, pCCBReader); + this->onHandlePropTypeCCBFile(pNode, pParent, propertyName, ccbFileNode, pCCBReader); } break; } @@ -649,11 +649,19 @@ void * CCNodeLoader::parsePropTypeBlockCCControl(CCNode * pNode, CCNode * pParen return NULL; } -std::string CCNodeLoader::parsePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { +CCNode * CCNodeLoader::parsePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { std::string ccbFileName = pCCBReader->readCachedString(); - + /* Change path extension to .ccbi. */ - return pCCBReader->deletePathExtension(ccbFileName) + std::string(".ccbi"); + std::string ccbiFileName = pCCBReader->deletePathExtension(ccbFileName) + std::string(".ccbi"); + + CCBReader * ccbReader = new CCBReader(pCCBReader); + + CCNode * ccbFileNode = ccbReader->readNodeGraphFromFile(ccbiFileName.c_str(), pCCBReader->getOwner(), pParent->getContentSize()); + + delete ccbReader; + + return ccbFileNode; } @@ -689,7 +697,7 @@ void CCNodeLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, std::s void CCNodeLoader::onHandlePropTypeScaleLock(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float * pScaleLock, CCBReader * pCCBReader) { if(pPropertyName.compare(PROPERTY_SCALE) == 0) { pNode->setScaleX(pScaleLock[0]); - pNode->setScaleX(pScaleLock[1]); + pNode->setScaleY(pScaleLock[1]); } else { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } @@ -793,10 +801,6 @@ void CCNodeLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pPare ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pCCBFileName, CCBReader * pCCBReader) { - // TODO check pPropertyName? - CCBReader * ccbReader = new CCBReader(); - CCNode * ccNode = ccbReader->readNodeGraphFromFile(pCCBFileName.c_str(), pCCBReader->getOwner(), pParent->getContentSize()); - - pNode->addChild(ccNode); // TODO will this work in all cases? +void CCNodeLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader) { + ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } \ No newline at end of file diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.h b/cocos2dx/extensions/CCBIReader/CCNodeLoader.h index ae463b3537..a7bbb6c7ff 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.h @@ -43,7 +43,7 @@ class CC_DLL CCNodeLoader { virtual std::string parsePropTypeFontTTF(CCNode *, CCNode *, CCBReader *); virtual void * parsePropTypeBlock(CCNode *, CCNode *, CCBReader *); virtual void * parsePropTypeBlockCCControl(CCNode *, CCNode *, CCBReader *); - virtual std::string parsePropTypeCCBFile(CCNode *, CCNode *, CCBReader *); + virtual CCNode * parsePropTypeCCBFile(CCNode *, CCNode *, CCBReader *); virtual void onHandlePropTypePosition(CCNode *, CCNode *, std::string, CCPoint, CCBReader *); @@ -72,7 +72,7 @@ class CC_DLL CCNodeLoader { virtual void onHandlePropTypeFontTTF(CCNode *, CCNode *, std::string, std::string, CCBReader *); virtual void onHandlePropTypeBlock(CCNode *, CCNode *, std::string, void *, CCBReader *); virtual void onHandlePropTypeBlockCCControl(CCNode *, CCNode *, std::string, void *, CCBReader *); - virtual void onHandlePropTypeCCBFile(CCNode *, CCNode *, std::string, std::string, CCBReader *); + virtual void onHandlePropTypeCCBFile(CCNode *, CCNode *, std::string, CCNode *, CCBReader *); }; NS_CC_EXT_END From 7cb3be205744c79b72f454f9ff47d113b6e8be9b Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Thu, 31 May 2012 17:01:01 -0700 Subject: [PATCH 042/257] Minor change. --- cocos2dx/label_nodes/CCLabelBMFont.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index 7fcb4a4961..a6b4b7ae61 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -734,12 +734,10 @@ CCLabelBMFont * CCLabelBMFont::node() if (pRet && pRet->init()) { pRet->autorelease(); + return pRet; } - else - { - CC_SAFE_DELETE(pRet); - } - return pRet; + CC_SAFE_DELETE(pRet); + return NULL; } //LabelBMFont - Creation & Init From 40f1ffe5fb1269c0a24f2558bd3eb953ba3b75f9 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Thu, 31 May 2012 17:04:53 -0700 Subject: [PATCH 043/257] CCMenuItem(Image): Added possibility to init without any image. (Changes according to: 5e8518eaed78a6c589bf73dadf85e2056f834f36, 013b4cec0a9250268b131105795e87d37cba4d52) --- cocos2dx/menu_nodes/CCMenuItem.cpp | 177 ++++++++++++++++++----------- cocos2dx/menu_nodes/CCMenuItem.h | 6 + 2 files changed, 116 insertions(+), 67 deletions(-) diff --git a/cocos2dx/menu_nodes/CCMenuItem.cpp b/cocos2dx/menu_nodes/CCMenuItem.cpp index 6cfdc6342f..320433415e 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.cpp +++ b/cocos2dx/menu_nodes/CCMenuItem.cpp @@ -401,7 +401,6 @@ void CCMenuItemSprite::setNormalImage(CCNode* var) { addChild(var, 0, kNormalTag); var->setAnchorPoint(ccp(0, 0)); - var->setIsVisible(true); } if (m_pNormalImage) @@ -410,7 +409,12 @@ void CCMenuItemSprite::setNormalImage(CCNode* var) } m_pNormalImage = var; - this->setContentSize(m_pNormalImage->getContentSize()); + if(m_pNormalImage) + { + this->setContentSize(m_pNormalImage->getContentSize()); + } + + this->updateImagesVisibility(); } CCNode * CCMenuItemSprite::getSelectedImage() { @@ -422,7 +426,6 @@ void CCMenuItemSprite::setSelectedImage(CCNode* var) { addChild(var, 0, kSelectedTag); var->setAnchorPoint(ccp(0, 0)); - var->setIsVisible(false); } if (m_pSelectedImage) @@ -431,6 +434,8 @@ void CCMenuItemSprite::setSelectedImage(CCNode* var) } m_pSelectedImage = var; + + this->updateImagesVisibility(); } CCNode * CCMenuItemSprite::getDisabledImage() { @@ -451,6 +456,8 @@ void CCMenuItemSprite::setDisabledImage(CCNode* var) } m_pDisabledImage = var; + + this->updateImagesVisibility(); } // //CCMenuItemSprite - CCRGBAProtocol protocol @@ -508,13 +515,11 @@ CCMenuItemSprite * CCMenuItemSprite::itemWithNormalSprite(CCNode *normalSprite, } bool CCMenuItemSprite::initWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, CCObject* target, SEL_MenuHandler selector) { - CCAssert(normalSprite != NULL, ""); CCMenuItem::initWithTarget(target, selector); setNormalImage(normalSprite); setSelectedImage(selectedSprite); setDisabledImage(disabledSprite); - - this->setContentSize(m_pNormalImage->getContentSize()); + return true; } @@ -524,64 +529,17 @@ bool CCMenuItemSprite::initWithNormalSprite(CCNode* normalSprite, CCNode* select void CCMenuItemSprite::selected() { CCMenuItem::selected(); - - if (m_pDisabledImage) + if (m_pNormalImage) { - m_pDisabledImage->setIsVisible(false); - } - - if (m_pSelectedImage) - { - m_pNormalImage->setIsVisible(false); - m_pSelectedImage->setIsVisible(true); - } - else - { - m_pNormalImage->setIsVisible(true); - } -} - -void CCMenuItemSprite::unselected() -{ - CCMenuItem::unselected(); - - m_pNormalImage->setIsVisible(true); - - if (m_pSelectedImage) - { - m_pSelectedImage->setIsVisible(false); - } - - if (m_pDisabledImage) - { - m_pDisabledImage->setIsVisible(false); - } -} - -void CCMenuItemSprite::setIsEnabled(bool bEnabled) -{ - CCMenuItem::setIsEnabled(bEnabled); - - if (m_pSelectedImage) - { - m_pSelectedImage->setIsVisible(false); - } - - if (bEnabled) - { - m_pNormalImage->setIsVisible(true); - if (m_pDisabledImage) { m_pDisabledImage->setIsVisible(false); } - } - else - { - if (m_pDisabledImage) + + if (m_pSelectedImage) { - m_pDisabledImage->setIsVisible(true); m_pNormalImage->setIsVisible(false); + m_pSelectedImage->setIsVisible(true); } else { @@ -590,6 +548,84 @@ void CCMenuItemSprite::setIsEnabled(bool bEnabled) } } +void CCMenuItemSprite::unselected() +{ + CCMenuItem::unselected(); + if (m_pNormalImage) + { + m_pNormalImage->setIsVisible(true); + + if (m_pSelectedImage) + { + m_pSelectedImage->setIsVisible(false); + } + + if (m_pDisabledImage) + { + m_pDisabledImage->setIsVisible(false); + } + } +} + +void CCMenuItemSprite::setIsEnabled(bool bEnabled) +{ + if(bEnabled != this->m_bIsEnabled) + { + CCMenuItem::setIsEnabled(bEnabled); + this->updateImagesVisibility(); + } +} + +void CCMenuItemSprite::updateImagesVisibility() +{ + if (m_pNormalImage) + { + if (m_pSelectedImage) + { + m_pSelectedImage->setIsVisible(false); + } + + if (this->m_bIsEnabled) + { + m_pNormalImage->setIsVisible(true); + + if (m_pDisabledImage) + { + m_pDisabledImage->setIsVisible(false); + } + } + else + { + if (m_pDisabledImage) + { + m_pDisabledImage->setIsVisible(true); + m_pNormalImage->setIsVisible(false); + } + else + { + m_pNormalImage->setIsVisible(true); + } + } + } +} + + +CCMenuItemImage* CCMenuItemImage::node() +{ + CCMenuItemImage *pRet = new CCMenuItemImage(); + if (pRet && pRet->init()) + { + pRet->autorelease(); + return pRet; + } + CC_SAFE_DELETE(pRet); + return NULL; +} + +bool CCMenuItemImage::init(void) +{ + return initWithNormalImage(NULL, NULL, NULL, NULL, NULL); +} CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, const char *selectedImage) { return CCMenuItemImage::itemWithNormalImage(normalImage, selectedImage, NULL, NULL, NULL); @@ -622,10 +658,15 @@ CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, } bool CCMenuItemImage::initWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector) { - CCNode *normalSprite = CCSprite::spriteWithFile(normalImage); + CCNode *normalSprite = NULL; CCNode *selectedSprite = NULL; CCNode *disabledSprite = NULL; - + + if (normalImage) + { + normalSprite = CCSprite::spriteWithFile(normalImage); + } + if (selectedImage) { selectedSprite = CCSprite::spriteWithFile(selectedImage); @@ -654,7 +695,6 @@ void CCMenuItemImage::setDisabledSpriteFrame(CCSpriteFrame * frame) { setDisabledImage(CCSprite::spriteWithSpriteFrame(frame)); } - // // MenuItemToggle // @@ -770,15 +810,18 @@ void CCMenuItemToggle::activate() } void CCMenuItemToggle::setIsEnabled(bool enabled) { - CCMenuItem::setIsEnabled(enabled); - - if(m_pSubItems && m_pSubItems->count() > 0) + if(enabled != this->m_bIsEnabled) { - CCObject* pObj = NULL; - CCARRAY_FOREACH(m_pSubItems, pObj) + CCMenuItem::setIsEnabled(enabled); + + if(m_pSubItems && m_pSubItems->count() > 0) { - CCMenuItem* pItem = (CCMenuItem*)pObj; - pItem->setIsEnabled(enabled); + CCObject* pObj = NULL; + CCARRAY_FOREACH(m_pSubItems, pObj) + { + CCMenuItem* pItem = (CCMenuItem*)pObj; + pItem->setIsEnabled(enabled); + } } } } diff --git a/cocos2dx/menu_nodes/CCMenuItem.h b/cocos2dx/menu_nodes/CCMenuItem.h index 0c5362dcc5..0a3cdfa181 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.h +++ b/cocos2dx/menu_nodes/CCMenuItem.h @@ -239,6 +239,8 @@ public: virtual void setIsOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} virtual bool getIsOpacityModifyRGB(void) { return false;} + + virtual void updateImagesVisibility(); }; /** @brief CCMenuItemImage accepts images as items. @@ -262,6 +264,7 @@ public: static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage, CCObject* target, SEL_MenuHandler selector); /** creates a menu item with a normal,selected and disabled image with target/selector */ static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector); + bool init(); /** initializes a menu item with a normal, selected and disabled image with target/selector */ bool initWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector); /** sets the sprite frame for the normal image */ @@ -270,6 +273,9 @@ public: void setSelectedSpriteFrame(CCSpriteFrame* frame); /** sets the sprite frame for the disabled image */ void setDisabledSpriteFrame(CCSpriteFrame* frame); + /** Creates an CCMenuItemImage. + */ + static CCMenuItemImage* node(); }; /** @brief A CCMenuItemToggle From 62e0c1cda096fcc55f13e53b702881d5dc2e40cd Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Thu, 31 May 2012 17:07:02 -0700 Subject: [PATCH 044/257] Added CCMenuLoader, CCMenuItemLoader and CCMenuItemImageLoader. --- cocos2dx/extensions/CCBIReader/CCBReader.cpp | 5 ++++ .../CCBIReader/CCMenuItemImageLoader .cpp | 24 +++++++++++++++++++ .../CCBIReader/CCMenuItemImageLoader.h | 20 ++++++++++++++++ .../CCBIReader/CCMenuItemLoader.cpp | 23 ++++++++++++++++++ .../extensions/CCBIReader/CCMenuItemLoader.h | 21 ++++++++++++++++ .../extensions/CCBIReader/CCMenuLoader.cpp | 9 +++++++ cocos2dx/extensions/CCBIReader/CCMenuLoader.h | 18 ++++++++++++++ 7 files changed, 120 insertions(+) create mode 100644 cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader .cpp create mode 100644 cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader.h create mode 100644 cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp create mode 100644 cocos2dx/extensions/CCBIReader/CCMenuItemLoader.h create mode 100644 cocos2dx/extensions/CCBIReader/CCMenuLoader.cpp create mode 100644 cocos2dx/extensions/CCBIReader/CCMenuLoader.h diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.cpp b/cocos2dx/extensions/CCBIReader/CCBReader.cpp index ddffcc98ff..87d06f7409 100644 --- a/cocos2dx/extensions/CCBIReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCBReader.cpp @@ -9,6 +9,9 @@ #include "CCSpriteLoader.h" #include "CCScale9SpriteLoader.h" #include "CCBFileLoader.h" +#include "CCMenuLoader.h" +#include "CCMenuItemLoader.h" +#include "CCMenuItemImageLoader.h" using namespace cocos2d; using namespace cocos2d::extension; @@ -23,6 +26,8 @@ CCBReader::CCBReader() { this->registerCCNodeLoader("CCLabelTTF", new CCLabelTTFLoader()); this->registerCCNodeLoader("CCScale9Sprite", new CCScale9SpriteLoader()); this->registerCCNodeLoader("CCBFile", new CCBFileLoader()); + this->registerCCNodeLoader("CCMenu", new CCMenuLoader()); + this->registerCCNodeLoader("CCMenuItemImage", new CCMenuItemImageLoader()); } CCBReader::~CCBReader() { diff --git a/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader .cpp b/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader .cpp new file mode 100644 index 0000000000..3e9ad01216 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader .cpp @@ -0,0 +1,24 @@ +#import "CCMenuItemImageLoader.h" + +using namespace cocos2d; +using namespace cocos2d::extension; + +#define PROPERTY_NORMALDISPLAYFRAME "normalSpriteFrame" +#define PROPERTY_SELECTEDDISPLAYFRAME "selectedSpriteFrame" +#define PROPERTY_DISABLEDDISPLAYFRAME "disabledSpriteFrame" + +CCMenuItemImage * CCMenuItemImageLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { + return CCMenuItemImage::node(); +} + +void CCMenuItemImageLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_NORMALDISPLAYFRAME) == 0) { + ((CCMenuItemImage *)pNode)->setNormalSpriteFrame(pCCSpriteFrame); + } else if(pPropertyName.compare(PROPERTY_SELECTEDDISPLAYFRAME) == 0) { + ((CCMenuItemImage *)pNode)->setSelectedSpriteFrame(pCCSpriteFrame); + } else if(pPropertyName.compare(PROPERTY_DISABLEDDISPLAYFRAME) == 0) { + ((CCMenuItemImage *)pNode)->setDisabledSpriteFrame(pCCSpriteFrame); + } else { + CCMenuItemLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pCCSpriteFrame, pCCBReader); + } +} \ No newline at end of file diff --git a/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader.h b/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader.h new file mode 100644 index 0000000000..ab79908e4d --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader.h @@ -0,0 +1,20 @@ +#ifndef _CCMENUITEMIMAGE_LOADER_H_ +#define _CCMENUITEMIMAGE_LOADER_H_ + +#include "CCMenuItemLoader.h" + +NS_CC_EXT_BEGIN + +/* Forward declaration. */ +class CCBReader; + +class CCMenuItemImageLoader : public CCMenuItemLoader { + protected: + virtual CCMenuItemImage * createCCNode(CCNode *, CCBReader *); + + virtual void onHandlePropTypeSpriteFrame(CCNode *, CCNode *, std::string, CCSpriteFrame *, CCBReader *); +}; + +NS_CC_EXT_END + +#endif diff --git a/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp b/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp new file mode 100644 index 0000000000..9ddd481882 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp @@ -0,0 +1,23 @@ +#import "CCMenuItemLoader.h" + +using namespace cocos2d; +using namespace cocos2d::extension; + +#define PROPERTY_BLOCK "block" +#define PROPERTY_ISENABLED "isEnabled" + +void CCMenuItemLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, std::string pPropertyName, void * pBlock, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_BLOCK) == 0) { + // ((CCMenuItem *)pNode)->setTarget(???, ???); + } else { + CCNodeLoader::onHandlePropTypeBlock(pNode, pParent, pPropertyName, pBlock, pCCBReader); + } +} + +void CCMenuItemLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, std::string pPropertyName, bool pCheck, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_ISENABLED) == 0) { + ((CCMenuItem *)pNode)->setIsEnabled(pCheck); + } else { + CCNodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader); + } +} \ No newline at end of file diff --git a/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.h b/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.h new file mode 100644 index 0000000000..cde6bbb776 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.h @@ -0,0 +1,21 @@ +#ifndef _CCMENUITEM_LOADER_H_ +#define _CCMENUITEM_LOADER_H_ + +#include "CCLayerLoader.h" + +NS_CC_EXT_BEGIN + +/* Forward declaration. */ +class CCBReader; + +class CCMenuItemLoader : public CCNodeLoader { + protected: + virtual CCMenuItem * createCCNode(CCNode *, CCBReader *) = 0; + + virtual void onHandlePropTypeBlock(CCNode *, CCNode *, std::string, void *, CCBReader *); + virtual void onHandlePropTypeCheck(CCNode *, CCNode *, std::string, bool, CCBReader *); +}; + +NS_CC_EXT_END + +#endif diff --git a/cocos2dx/extensions/CCBIReader/CCMenuLoader.cpp b/cocos2dx/extensions/CCBIReader/CCMenuLoader.cpp new file mode 100644 index 0000000000..0006481b92 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCMenuLoader.cpp @@ -0,0 +1,9 @@ +#import "CCMenuLoader.h" + +using namespace cocos2d; +using namespace cocos2d::extension; + + +CCMenu * CCMenuLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { + return CCMenu::node(); +} \ No newline at end of file diff --git a/cocos2dx/extensions/CCBIReader/CCMenuLoader.h b/cocos2dx/extensions/CCBIReader/CCMenuLoader.h new file mode 100644 index 0000000000..37bce71745 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCMenuLoader.h @@ -0,0 +1,18 @@ +#ifndef _CCMENU_LOADER_H_ +#define _CCMENU_LOADER_H_ + +#include "CCLayerLoader.h" + +NS_CC_EXT_BEGIN + +/* Forward declaration. */ +class CCBReader; + +class CCMenuLoader : public CCLayerLoader { + protected: + virtual CCMenu * createCCNode(CCNode *, CCBReader *); +}; + +NS_CC_EXT_END + +#endif From dfa1216ba914ac1525d93d9892485f82655771f3 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 1 Jun 2012 11:01:09 +0800 Subject: [PATCH 045/257] add CCBReader into project --- .../proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- .../HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id b/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id index a42ba6f236..a719cf6fd3 100644 --- a/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -842462907b895bea8fcf8fc4a567560e546e440f \ No newline at end of file +054e166ed7b342f0cd56308efb308551f9488951 \ No newline at end of file diff --git a/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id b/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id index 4d57dadf2d..58cbc28d2d 100644 --- a/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -c7a3fbb2c6d8e698889720796681db135c37b25b \ No newline at end of file +5e8bc2ebea93cf60f4c5992e1175c43fffffb7e8 \ No newline at end of file diff --git a/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id b/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id index 364ae308d1..17c493db58 100644 --- a/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -a330c09f123bd8de33522f7dedde5def5ea256a6 \ No newline at end of file +59d857c1050d96d698c58eaf20c0c3cd1a808cbf \ No newline at end of file From 93b5fc37c7857018dbc10fceefcda3ddb884492d Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 1 Jun 2012 12:04:04 +0800 Subject: [PATCH 046/257] typo fix --- tests/Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Android.mk b/tests/Android.mk index a777abaad7..1589dd0532 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -12,7 +12,7 @@ tests/ActionManagerTest/ActionManagerTest.cpp \ tests/ActionsTest/ActionsTest.cpp \ tests/ActionsEaseTest/ActionsEaseTest.cpp \ tests/ActionsProgressTest/ActionsProgressTest.cpp \ -tests/Box2dTest/Box2dTest.cpp \ +tests/Box2DTest/Box2dTest.cpp \ tests/Box2DTestBed/Box2dView.cpp \ tests/Box2DTestBed/GLES-Render.cpp \ tests/Box2DTestBed/Test.cpp \ From ebcc78497fe2da893b6c4f39d6eee4e2b99374ed Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 1 Jun 2012 13:44:28 +0800 Subject: [PATCH 047/257] fixed #1282: Can not run samples on windows if the display card is ATI. Use opengl directly. Reverted all project configurations to Unicode characterset to avoid textinput error. --- Box2D/proj.win32/Box2D.win32.vcproj | 4 +- Box2D/proj.win32/Box2D.win32.vcxproj | 4 +- CocosDenshion/win32/MciPlayer.cpp | 6 +- HelloLua/proj.win32/HelloLua.win32.vcproj | 8 +- HelloLua/proj.win32/HelloLua.win32.vcxproj | 4 +- HelloWorld/proj.win32/HelloWorld.win32.vcproj | 6 +- .../proj.win32/HelloWorld.win32.vcxproj | 4 +- chipmunk/proj.win32/chipmunk.win32.vcproj | 4 +- chipmunk/proj.win32/chipmunk.win32.vcxproj | 4 +- cocos2d-win32.vc2008.sln | 6 +- .../third_party/win32/OGLES/EGL/egl.h | 329 ---- .../third_party/win32/OGLES/EGL/eglext.h | 175 -- .../third_party/win32/OGLES/EGL/eglplatform.h | 124 -- .../win32/OGLES/GL/glew.h.REMOVED.git-id | 1 + .../third_party/win32/OGLES/GL/glxew.h | 1587 +++++++++++++++++ .../third_party/win32/OGLES/GL/wglew.h | 1363 ++++++++++++++ .../third_party/win32/OGLES/GLES2/gl2.h | 619 ------- .../third_party/win32/OGLES/GLES2/gl2ext.h | 971 ---------- .../third_party/win32/OGLES/GLES2/gl2extimg.h | 47 - .../win32/OGLES/GLES2/gl2platform.h | 28 - .../third_party/win32/OGLES/KHR/khrplatform.h | 302 ---- .../win32/libraries/glew32.dll.REMOVED.git-id | 1 + .../win32/libraries/glew32.lib.REMOVED.git-id | 1 + .../libraries/libGLESv2.dll.REMOVED.git-id | 1 - cocos2dx/platform/win32/CCApplication.cpp | 16 +- cocos2dx/platform/win32/CCEGLView.cpp | 237 +-- cocos2dx/platform/win32/CCEGLView.h | 11 +- cocos2dx/platform/win32/CCGL.h | 9 +- cocos2dx/platform/win32/CCImage.cpp | 90 +- cocos2dx/proj.win32/cocos2d-win32.vcproj | 8 +- cocos2dx/proj.win32/cocos2d-win32.vcxproj | 8 +- lua/proj.win32/liblua.vcproj | 4 +- lua/proj.win32/liblua.vcxproj | 4 +- .../CCAppWiz.win32/Scripts/1033/default.js | 2 +- testjs/proj.win32/testjs.win32.vcproj | 6 +- testjs/proj.win32/testjs.win32.vcxproj | 4 +- tests/proj.win32/test.win32.vcproj | 8 +- tests/proj.win32/test.win32.vcxproj | 8 +- 38 files changed, 3173 insertions(+), 2841 deletions(-) delete mode 100644 cocos2dx/platform/third_party/win32/OGLES/EGL/egl.h delete mode 100644 cocos2dx/platform/third_party/win32/OGLES/EGL/eglext.h delete mode 100644 cocos2dx/platform/third_party/win32/OGLES/EGL/eglplatform.h create mode 100644 cocos2dx/platform/third_party/win32/OGLES/GL/glew.h.REMOVED.git-id create mode 100644 cocos2dx/platform/third_party/win32/OGLES/GL/glxew.h create mode 100644 cocos2dx/platform/third_party/win32/OGLES/GL/wglew.h delete mode 100644 cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2.h delete mode 100644 cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2ext.h delete mode 100644 cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2extimg.h delete mode 100644 cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2platform.h delete mode 100644 cocos2dx/platform/third_party/win32/OGLES/KHR/khrplatform.h create mode 100644 cocos2dx/platform/third_party/win32/libraries/glew32.dll.REMOVED.git-id create mode 100644 cocos2dx/platform/third_party/win32/libraries/glew32.lib.REMOVED.git-id delete mode 100644 cocos2dx/platform/third_party/win32/libraries/libGLESv2.dll.REMOVED.git-id diff --git a/Box2D/proj.win32/Box2D.win32.vcproj b/Box2D/proj.win32/Box2D.win32.vcproj index c5e04f29e8..dc04b76b82 100644 --- a/Box2D/proj.win32/Box2D.win32.vcproj +++ b/Box2D/proj.win32/Box2D.win32.vcproj @@ -21,7 +21,7 @@ OutputDirectory="$(SolutionDir)$(ConfigurationName).win32" IntermediateDirectory="$(ConfigurationName).win32" ConfigurationType="4" - CharacterSet="2" + CharacterSet="1" > StaticLibrary - MultiByte + Unicode StaticLibrary - MultiByte + Unicode diff --git a/CocosDenshion/win32/MciPlayer.cpp b/CocosDenshion/win32/MciPlayer.cpp index da403a616e..753edc1f8d 100644 --- a/CocosDenshion/win32/MciPlayer.cpp +++ b/CocosDenshion/win32/MciPlayer.cpp @@ -19,7 +19,7 @@ MciPlayer::MciPlayer() { if (! s_hInstance) { - s_hInstance = GetModuleHandle( NULL ); // Grab An Instance For Our Window + s_hInstance = GetModuleHandle( NULL ); // Grab An Instance For Our Window WNDCLASS wc; // Windows Class Structure @@ -35,8 +35,8 @@ MciPlayer::MciPlayer() wc.lpszMenuName = NULL; // We Don't Want A Menu wc.lpszClassName = WIN_CLASS_NAME; // Set The Class Name - if (! RegisterClass(&wc) // ×¢²á ´°¿ÚÀà ʧ°Ü - && 1410 != GetLastError()) // ²¢ÇÒʧ°ÜµÄÔ­Òò²»ÊÇ´°¿ÚÀàÒÑ×¢²á + if (! RegisterClass(&wc) + && 1410 != GetLastError()) { return; } diff --git a/HelloLua/proj.win32/HelloLua.win32.vcproj b/HelloLua/proj.win32/HelloLua.win32.vcproj index 7d9805f419..e4efafcfb0 100644 --- a/HelloLua/proj.win32/HelloLua.win32.vcproj +++ b/HelloLua/proj.win32/HelloLua.win32.vcproj @@ -20,7 +20,7 @@ OutputDirectory="$(SolutionDir)$(ConfigurationName).win32" IntermediateDirectory="$(ConfigurationName).win32" ConfigurationType="1" - CharacterSet="2" + CharacterSet="1" > Application - MultiByte + Unicode Application - MultiByte + Unicode diff --git a/HelloWorld/proj.win32/HelloWorld.win32.vcproj b/HelloWorld/proj.win32/HelloWorld.win32.vcproj index 06d237790b..a691858006 100644 --- a/HelloWorld/proj.win32/HelloWorld.win32.vcproj +++ b/HelloWorld/proj.win32/HelloWorld.win32.vcproj @@ -21,7 +21,7 @@ OutputDirectory="$(SolutionDir)$(ConfigurationName).win32" IntermediateDirectory="$(ConfigurationName).win32" ConfigurationType="1" - CharacterSet="2" + CharacterSet="1" > Application - MultiByte + Unicode true Application - MultiByte + Unicode diff --git a/chipmunk/proj.win32/chipmunk.win32.vcproj b/chipmunk/proj.win32/chipmunk.win32.vcproj index bb89c267c1..86932ed886 100644 --- a/chipmunk/proj.win32/chipmunk.win32.vcproj +++ b/chipmunk/proj.win32/chipmunk.win32.vcproj @@ -20,7 +20,7 @@ OutputDirectory="$(SolutionDir)$(ConfigurationName).win32" IntermediateDirectory="$(ConfigurationName).win32" ConfigurationType="4" - CharacterSet="2" + CharacterSet="1" > StaticLibrary - MultiByte + Unicode StaticLibrary - MultiByte + Unicode diff --git a/cocos2d-win32.vc2008.sln b/cocos2d-win32.vc2008.sln index 937a2e7fd8..c145c07176 100644 --- a/cocos2d-win32.vc2008.sln +++ b/cocos2d-win32.vc2008.sln @@ -39,6 +39,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testjs", "testjs\proj.win32 EndProjectSection EndProject Global + GlobalSection(DPCodeReviewSolutionGUID) = preSolution + DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} + EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 @@ -84,7 +87,4 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(DPCodeReviewSolutionGUID) = preSolution - DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} - EndGlobalSection EndGlobal diff --git a/cocos2dx/platform/third_party/win32/OGLES/EGL/egl.h b/cocos2dx/platform/third_party/win32/OGLES/EGL/egl.h deleted file mode 100644 index 1c65660d42..0000000000 --- a/cocos2dx/platform/third_party/win32/OGLES/EGL/egl.h +++ /dev/null @@ -1,329 +0,0 @@ -/* -*- mode: c; tab-width: 8; -*- */ -/* vi: set sw=4 ts=8: */ -/* Reference version of egl.h for EGL 1.4. - */ - -/* -** Copyright (c) 2007-2009 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -#ifndef __egl_h_ -#define __egl_h_ - -/* All platform-dependent types and macro boilerplate (such as EGLAPI - * and EGLAPIENTRY) should go in eglplatform.h. - */ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* EGL Types */ -/* EGLint is defined in eglplatform.h */ -typedef unsigned int EGLBoolean; -typedef unsigned int EGLenum; -typedef void *EGLConfig; -typedef void *EGLContext; -typedef void *EGLDisplay; -typedef void *EGLSurface; -typedef void *EGLClientBuffer; - -/* EGL Versioning */ -#define EGL_VERSION_1_0 1 -#define EGL_VERSION_1_1 1 -#define EGL_VERSION_1_2 1 -#define EGL_VERSION_1_3 1 -#define EGL_VERSION_1_4 1 - -/* EGL Enumerants. Bitmasks and other exceptional cases aside, most - * enums are assigned unique values starting at 0x3000. - */ - -/* EGL aliases */ -#define EGL_FALSE 0 -#define EGL_TRUE 1 - -/* Out-of-band handle values */ -#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0) -#define EGL_NO_CONTEXT ((EGLContext)0) -#define EGL_NO_DISPLAY ((EGLDisplay)0) -#define EGL_NO_SURFACE ((EGLSurface)0) - -/* Out-of-band attribute value */ -#define EGL_DONT_CARE ((EGLint)-1) - -/* Errors / GetError return values */ -#define EGL_SUCCESS 0x3000 -#define EGL_NOT_INITIALIZED 0x3001 -#define EGL_BAD_ACCESS 0x3002 -#define EGL_BAD_ALLOC 0x3003 -#define EGL_BAD_ATTRIBUTE 0x3004 -#define EGL_BAD_CONFIG 0x3005 -#define EGL_BAD_CONTEXT 0x3006 -#define EGL_BAD_CURRENT_SURFACE 0x3007 -#define EGL_BAD_DISPLAY 0x3008 -#define EGL_BAD_MATCH 0x3009 -#define EGL_BAD_NATIVE_PIXMAP 0x300A -#define EGL_BAD_NATIVE_WINDOW 0x300B -#define EGL_BAD_PARAMETER 0x300C -#define EGL_BAD_SURFACE 0x300D -#define EGL_CONTEXT_LOST 0x300E /* EGL 1.1 - IMG_power_management */ - -/* Reserved 0x300F-0x301F for additional errors */ - -/* Config attributes */ -#define EGL_BUFFER_SIZE 0x3020 -#define EGL_ALPHA_SIZE 0x3021 -#define EGL_BLUE_SIZE 0x3022 -#define EGL_GREEN_SIZE 0x3023 -#define EGL_RED_SIZE 0x3024 -#define EGL_DEPTH_SIZE 0x3025 -#define EGL_STENCIL_SIZE 0x3026 -#define EGL_CONFIG_CAVEAT 0x3027 -#define EGL_CONFIG_ID 0x3028 -#define EGL_LEVEL 0x3029 -#define EGL_MAX_PBUFFER_HEIGHT 0x302A -#define EGL_MAX_PBUFFER_PIXELS 0x302B -#define EGL_MAX_PBUFFER_WIDTH 0x302C -#define EGL_NATIVE_RENDERABLE 0x302D -#define EGL_NATIVE_VISUAL_ID 0x302E -#define EGL_NATIVE_VISUAL_TYPE 0x302F -#define EGL_PRESERVED_RESOURCES 0x3030 -#define EGL_SAMPLES 0x3031 -#define EGL_SAMPLE_BUFFERS 0x3032 -#define EGL_SURFACE_TYPE 0x3033 -#define EGL_TRANSPARENT_TYPE 0x3034 -#define EGL_TRANSPARENT_BLUE_VALUE 0x3035 -#define EGL_TRANSPARENT_GREEN_VALUE 0x3036 -#define EGL_TRANSPARENT_RED_VALUE 0x3037 -#define EGL_NONE 0x3038 /* Attrib list terminator */ -#define EGL_BIND_TO_TEXTURE_RGB 0x3039 -#define EGL_BIND_TO_TEXTURE_RGBA 0x303A -#define EGL_MIN_SWAP_INTERVAL 0x303B -#define EGL_MAX_SWAP_INTERVAL 0x303C -#define EGL_LUMINANCE_SIZE 0x303D -#define EGL_ALPHA_MASK_SIZE 0x303E -#define EGL_COLOR_BUFFER_TYPE 0x303F -#define EGL_RENDERABLE_TYPE 0x3040 -#define EGL_MATCH_NATIVE_PIXMAP 0x3041 /* Pseudo-attribute (not queryable) */ -#define EGL_CONFORMANT 0x3042 - -/* Reserved 0x3041-0x304F for additional config attributes */ - -/* Config attribute values */ -#define EGL_SLOW_CONFIG 0x3050 /* EGL_CONFIG_CAVEAT value */ -#define EGL_NON_CONFORMANT_CONFIG 0x3051 /* EGL_CONFIG_CAVEAT value */ -#define EGL_TRANSPARENT_RGB 0x3052 /* EGL_TRANSPARENT_TYPE value */ -#define EGL_RGB_BUFFER 0x308E /* EGL_COLOR_BUFFER_TYPE value */ -#define EGL_LUMINANCE_BUFFER 0x308F /* EGL_COLOR_BUFFER_TYPE value */ - -/* More config attribute values, for EGL_TEXTURE_FORMAT */ -#define EGL_NO_TEXTURE 0x305C -#define EGL_TEXTURE_RGB 0x305D -#define EGL_TEXTURE_RGBA 0x305E -#define EGL_TEXTURE_2D 0x305F - -/* Config attribute mask bits */ -#define EGL_PBUFFER_BIT 0x0001 /* EGL_SURFACE_TYPE mask bits */ -#define EGL_PIXMAP_BIT 0x0002 /* EGL_SURFACE_TYPE mask bits */ -#define EGL_WINDOW_BIT 0x0004 /* EGL_SURFACE_TYPE mask bits */ -#define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020 /* EGL_SURFACE_TYPE mask bits */ -#define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040 /* EGL_SURFACE_TYPE mask bits */ -#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 /* EGL_SURFACE_TYPE mask bits */ -#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 /* EGL_SURFACE_TYPE mask bits */ - -#define EGL_OPENGL_ES_BIT 0x0001 /* EGL_RENDERABLE_TYPE mask bits */ -#define EGL_OPENVG_BIT 0x0002 /* EGL_RENDERABLE_TYPE mask bits */ -#define EGL_OPENGL_ES2_BIT 0x0004 /* EGL_RENDERABLE_TYPE mask bits */ -#define EGL_OPENGL_BIT 0x0008 /* EGL_RENDERABLE_TYPE mask bits */ - -/* QueryString targets */ -#define EGL_VENDOR 0x3053 -#define EGL_VERSION 0x3054 -#define EGL_EXTENSIONS 0x3055 -#define EGL_CLIENT_APIS 0x308D - -/* QuerySurface / SurfaceAttrib / CreatePbufferSurface targets */ -#define EGL_HEIGHT 0x3056 -#define EGL_WIDTH 0x3057 -#define EGL_LARGEST_PBUFFER 0x3058 -#define EGL_TEXTURE_FORMAT 0x3080 -#define EGL_TEXTURE_TARGET 0x3081 -#define EGL_MIPMAP_TEXTURE 0x3082 -#define EGL_MIPMAP_LEVEL 0x3083 -#define EGL_RENDER_BUFFER 0x3086 -#define EGL_VG_COLORSPACE 0x3087 -#define EGL_VG_ALPHA_FORMAT 0x3088 -#define EGL_HORIZONTAL_RESOLUTION 0x3090 -#define EGL_VERTICAL_RESOLUTION 0x3091 -#define EGL_PIXEL_ASPECT_RATIO 0x3092 -#define EGL_SWAP_BEHAVIOR 0x3093 -#define EGL_MULTISAMPLE_RESOLVE 0x3099 - -/* EGL_RENDER_BUFFER values / BindTexImage / ReleaseTexImage buffer targets */ -#define EGL_BACK_BUFFER 0x3084 -#define EGL_SINGLE_BUFFER 0x3085 - -/* OpenVG color spaces */ -#define EGL_VG_COLORSPACE_sRGB 0x3089 /* EGL_VG_COLORSPACE value */ -#define EGL_VG_COLORSPACE_LINEAR 0x308A /* EGL_VG_COLORSPACE value */ - -/* OpenVG alpha formats */ -#define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B /* EGL_ALPHA_FORMAT value */ -#define EGL_VG_ALPHA_FORMAT_PRE 0x308C /* EGL_ALPHA_FORMAT value */ - -/* Constant scale factor by which fractional display resolutions & - * aspect ratio are scaled when queried as integer values. - */ -#define EGL_DISPLAY_SCALING 10000 - -/* Unknown display resolution/aspect ratio */ -#define EGL_UNKNOWN ((EGLint)-1) - -/* Back buffer swap behaviors */ -#define EGL_BUFFER_PRESERVED 0x3094 /* EGL_SWAP_BEHAVIOR value */ -#define EGL_BUFFER_DESTROYED 0x3095 /* EGL_SWAP_BEHAVIOR value */ - -/* CreatePbufferFromClientBuffer buffer types */ -#define EGL_OPENVG_IMAGE 0x3096 - -/* QueryContext targets */ -#define EGL_CONTEXT_CLIENT_TYPE 0x3097 - -/* CreateContext attributes */ -#define EGL_CONTEXT_CLIENT_VERSION 0x3098 - -/* Multisample resolution behaviors */ -#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A /* EGL_MULTISAMPLE_RESOLVE value */ -#define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B /* EGL_MULTISAMPLE_RESOLVE value */ - -/* BindAPI/QueryAPI targets */ -#define EGL_OPENGL_ES_API 0x30A0 -#define EGL_OPENVG_API 0x30A1 -#define EGL_OPENGL_API 0x30A2 - -/* GetCurrentSurface targets */ -#define EGL_DRAW 0x3059 -#define EGL_READ 0x305A - -/* WaitNative engines */ -#define EGL_CORE_NATIVE_ENGINE 0x305B - -/* EGL 1.2 tokens renamed for consistency in EGL 1.3 */ -#define EGL_COLORSPACE EGL_VG_COLORSPACE -#define EGL_ALPHA_FORMAT EGL_VG_ALPHA_FORMAT -#define EGL_COLORSPACE_sRGB EGL_VG_COLORSPACE_sRGB -#define EGL_COLORSPACE_LINEAR EGL_VG_COLORSPACE_LINEAR -#define EGL_ALPHA_FORMAT_NONPRE EGL_VG_ALPHA_FORMAT_NONPRE -#define EGL_ALPHA_FORMAT_PRE EGL_VG_ALPHA_FORMAT_PRE - -/* EGL extensions must request enum blocks from the Khronos - * API Registrar, who maintains the enumerant registry. Submit - * a bug in Khronos Bugzilla against task "Registry". - */ - - - -/* EGL Functions */ - -EGLAPI EGLint EGLAPIENTRY eglGetError(void); - -EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id); -EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor); -EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy); - -EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name); - -EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, - EGLint config_size, EGLint *num_config); -EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, - EGLConfig *configs, EGLint config_size, - EGLint *num_config); -EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, - EGLint attribute, EGLint *value); - -EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, - EGLNativeWindowType win, - const EGLint *attrib_list); -EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, - const EGLint *attrib_list); -EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, - EGLNativePixmapType pixmap, - const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface); -EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface, - EGLint attribute, EGLint *value); - -EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api); -EGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void); - -EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void); - -EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void); - -EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer( - EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, - EGLConfig config, const EGLint *attrib_list); - -EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, - EGLint attribute, EGLint value); -EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer); -EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer); - - -EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval); - - -EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config, - EGLContext share_context, - const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx); -EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, - EGLSurface read, EGLContext ctx); - -EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void); -EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw); -EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx, - EGLint attribute, EGLint *value); - -EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void); -EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine); -EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface); -EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, - EGLNativePixmapType target); - -/* This is a generic function pointer type, whose name indicates it must - * be cast to the proper type *and calling convention* before use. - */ -typedef void (*__eglMustCastToProperFunctionPointerType)(void); - -/* Now, define eglGetProcAddress using the generic function ptr. type */ -EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY - eglGetProcAddress(const char *procname); - -#ifdef __cplusplus -} -#endif - -#endif /* __egl_h_ */ diff --git a/cocos2dx/platform/third_party/win32/OGLES/EGL/eglext.h b/cocos2dx/platform/third_party/win32/OGLES/EGL/eglext.h deleted file mode 100644 index 87beb21d24..0000000000 --- a/cocos2dx/platform/third_party/win32/OGLES/EGL/eglext.h +++ /dev/null @@ -1,175 +0,0 @@ -#ifndef __eglext_h_ -#define __eglext_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2007-2009 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -#include - -/*************************************************************/ - -/* Header file version number */ -/* Current version at http://www.khronos.org/registry/egl/ */ -#define EGL_EGLEXT_VERSION 4 - -#ifndef EGL_KHR_config_attribs -#define EGL_KHR_config_attribs 1 -#define EGL_CONFORMANT_KHR 0x3042 /* EGLConfig attribute */ -#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR 0x0020 /* EGL_SURFACE_TYPE bitfield */ -#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040 /* EGL_SURFACE_TYPE bitfield */ -#endif - -#ifndef EGL_KHR_lock_surface -#define EGL_KHR_lock_surface 1 -#define EGL_READ_SURFACE_BIT_KHR 0x0001 /* EGL_LOCK_USAGE_HINT_KHR bitfield */ -#define EGL_WRITE_SURFACE_BIT_KHR 0x0002 /* EGL_LOCK_USAGE_HINT_KHR bitfield */ -#define EGL_LOCK_SURFACE_BIT_KHR 0x0080 /* EGL_SURFACE_TYPE bitfield */ -#define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100 /* EGL_SURFACE_TYPE bitfield */ -#define EGL_MATCH_FORMAT_KHR 0x3043 /* EGLConfig attribute */ -#define EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0 /* EGL_MATCH_FORMAT_KHR value */ -#define EGL_FORMAT_RGB_565_KHR 0x30C1 /* EGL_MATCH_FORMAT_KHR value */ -#define EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2 /* EGL_MATCH_FORMAT_KHR value */ -#define EGL_FORMAT_RGBA_8888_KHR 0x30C3 /* EGL_MATCH_FORMAT_KHR value */ -#define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 /* eglLockSurfaceKHR attribute */ -#define EGL_LOCK_USAGE_HINT_KHR 0x30C5 /* eglLockSurfaceKHR attribute */ -#define EGL_BITMAP_POINTER_KHR 0x30C6 /* eglQuerySurface attribute */ -#define EGL_BITMAP_PITCH_KHR 0x30C7 /* eglQuerySurface attribute */ -#define EGL_BITMAP_ORIGIN_KHR 0x30C8 /* eglQuerySurface attribute */ -#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9 /* eglQuerySurface attribute */ -#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA /* eglQuerySurface attribute */ -#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB /* eglQuerySurface attribute */ -#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC /* eglQuerySurface attribute */ -#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD /* eglQuerySurface attribute */ -#define EGL_LOWER_LEFT_KHR 0x30CE /* EGL_BITMAP_ORIGIN_KHR value */ -#define EGL_UPPER_LEFT_KHR 0x30CF /* EGL_BITMAP_ORIGIN_KHR value */ -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay display, EGLSurface surface); -#endif /* EGL_EGLEXT_PROTOTYPES */ -typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface); -#endif - -#ifndef EGL_KHR_image -#define EGL_KHR_image 1 -#define EGL_NATIVE_PIXMAP_KHR 0x30B0 /* eglCreateImageKHR target */ -typedef void *EGLImageKHR; -#define EGL_NO_IMAGE_KHR ((EGLImageKHR)0) -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image); -#endif /* EGL_EGLEXT_PROTOTYPES */ -typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image); -#endif - -#ifndef EGL_KHR_vg_parent_image -#define EGL_KHR_vg_parent_image 1 -#define EGL_VG_PARENT_IMAGE_KHR 0x30BA /* eglCreateImageKHR target */ -#endif - -#ifndef EGL_KHR_gl_texture_2D_image -#define EGL_KHR_gl_texture_2D_image 1 -#define EGL_GL_TEXTURE_2D_KHR 0x30B1 /* eglCreateImageKHR target */ -#define EGL_GL_TEXTURE_LEVEL_KHR 0x30BC /* eglCreateImageKHR attribute */ -#endif - -#ifndef EGL_KHR_gl_texture_cubemap_image -#define EGL_KHR_gl_texture_cubemap_image 1 -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3 /* eglCreateImageKHR target */ -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4 /* eglCreateImageKHR target */ -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5 /* eglCreateImageKHR target */ -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6 /* eglCreateImageKHR target */ -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7 /* eglCreateImageKHR target */ -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8 /* eglCreateImageKHR target */ -#endif - -#ifndef EGL_KHR_gl_texture_3D_image -#define EGL_KHR_gl_texture_3D_image 1 -#define EGL_GL_TEXTURE_3D_KHR 0x30B2 /* eglCreateImageKHR target */ -#define EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD /* eglCreateImageKHR attribute */ -#endif - -#ifndef EGL_KHR_gl_renderbuffer_image -#define EGL_KHR_gl_renderbuffer_image 1 -#define EGL_GL_RENDERBUFFER_KHR 0x30B9 /* eglCreateImageKHR target */ -#endif - -#ifndef EGL_KHR_reusable_sync -#define EGL_KHR_reusable_sync 1 - -typedef void* EGLSyncKHR; -typedef khronos_utime_nanoseconds_t EGLTimeKHR; - -#define EGL_SYNC_STATUS_KHR 0x30F1 -#define EGL_SIGNALED_KHR 0x30F2 -#define EGL_UNSIGNALED_KHR 0x30F3 -#define EGL_TIMEOUT_EXPIRED_KHR 0x30F5 -#define EGL_CONDITION_SATISFIED_KHR 0x30F6 -#define EGL_SYNC_TYPE_KHR 0x30F7 -#define EGL_SYNC_REUSABLE_KHR 0x30FA -#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 /* eglClientWaitSyncKHR bitfield */ -#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull -#define EGL_NO_SYNC_KHR ((EGLSyncKHR)0) -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync); -EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); -EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); -EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); -#endif /* EGL_EGLEXT_PROTOTYPES */ -typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHR) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHR) (EGLDisplay dpy, EGLSyncKHR sync); -typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHR) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHR) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHR) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); -#endif - -#ifndef EGL_KHR_image_base -#define EGL_KHR_image_base 1 -/* Most interfaces defined by EGL_KHR_image_pixmap above */ -#define EGL_IMAGE_PRESERVED_KHR 0x30D2 /* eglCreateImageKHR attribute */ -#endif - -#ifndef EGL_KHR_image_pixmap -#define EGL_KHR_image_pixmap 1 -/* Interfaces defined by EGL_KHR_image above */ -#endif - -#ifndef EGL_IMG_context_priority -#define EGL_IMG_context_priority 1 -#define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100 -#define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101 -#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102 -#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103 -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cocos2dx/platform/third_party/win32/OGLES/EGL/eglplatform.h b/cocos2dx/platform/third_party/win32/OGLES/EGL/eglplatform.h deleted file mode 100644 index e8a18f25a3..0000000000 --- a/cocos2dx/platform/third_party/win32/OGLES/EGL/eglplatform.h +++ /dev/null @@ -1,124 +0,0 @@ -#ifndef __eglplatform_h_ -#define __eglplatform_h_ - -/* -** Copyright (c) 2007-2009 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -/* Platform-specific types and definitions for egl.h - * - * Adopters may modify khrplatform.h and this file to suit their platform. - * You are encouraged to submit all modifications to the Khronos group so that - * they can be included in future versions of this file. Please submit changes - * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) - * by filing a bug against product "EGL" component "Registry". - */ - -#include - -/* Macros used in EGL function prototype declarations. - * - * EGL functions should be prototyped as: - * - * EGLAPI return-type EGLAPIENTRY eglFunction(arguments); - * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments); - * - * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h - */ - -#ifndef EGLAPI -#define EGLAPI KHRONOS_APICALL -#endif - -#define EGLAPIENTRY KHRONOS_APIENTRY -#define EGLAPIENTRYP KHRONOS_APIENTRY* - -/* The types NativeDisplayType, NativeWindowType, and NativePixmapType - * are aliases of window-system-dependent types, such as X Display * or - * Windows Device Context. They must be defined in platform-specific - * code below. The EGL-prefixed versions of Native*Type are the same - * types, renamed in EGL 1.3 so all types in the API start with "EGL". - */ - -#if defined(_WIN32) && !defined(__WINSCW__) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */ -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN 1 -#endif -#include - -typedef HDC EGLNativeDisplayType; -typedef HBITMAP EGLNativePixmapType; -typedef HWND EGLNativeWindowType; - -#elif defined(SUPPORT_X11) - -/* X11 (tentative) */ -#include -#include - -typedef Display *EGLNativeDisplayType; -typedef Pixmap EGLNativePixmapType; -typedef Window EGLNativeWindowType; - - -#elif defined(ANDROID) - -struct android_native_window_t; -struct egl_native_pixmap_t; - -typedef struct android_native_window_t* EGLNativeWindowType; -typedef struct egl_native_pixmap_t* EGLNativePixmapType; -typedef void* EGLNativeDisplayType; - -#else - -#if defined(_WIN64) || __WORDSIZE == 64 -typedef khronos_int64_t EGLNativeDisplayType; -#else -typedef int EGLNativeDisplayType; -#endif - -typedef void *EGLNativeWindowType; -typedef void *EGLNativePixmapType; - -#endif - -/* EGL 1.2 types, renamed for consistency in EGL 1.3 */ -typedef EGLNativeDisplayType NativeDisplayType; -typedef EGLNativePixmapType NativePixmapType; -typedef EGLNativeWindowType NativeWindowType; - - -/* Define EGLint. This must be a signed integral type large enough to contain - * all legal attribute names and values passed into and out of EGL, whether - * their type is boolean, bitmask, enumerant (symbolic constant), integer, - * handle, or other. While in general a 32-bit integer will suffice, if - * handles are 64 bit types, then EGLint should be defined as a signed 64-bit - * integer type. - */ -#if defined(_WIN64) || __WORDSIZE == 64 -typedef khronos_int64_t EGLint; -#else -typedef khronos_int32_t EGLint; -#endif - -#endif /* __eglplatform_h */ diff --git a/cocos2dx/platform/third_party/win32/OGLES/GL/glew.h.REMOVED.git-id b/cocos2dx/platform/third_party/win32/OGLES/GL/glew.h.REMOVED.git-id new file mode 100644 index 0000000000..3e2934f9e6 --- /dev/null +++ b/cocos2dx/platform/third_party/win32/OGLES/GL/glew.h.REMOVED.git-id @@ -0,0 +1 @@ +ecd17c38e19265c7777dcd20993d744992f163a7 \ No newline at end of file diff --git a/cocos2dx/platform/third_party/win32/OGLES/GL/glxew.h b/cocos2dx/platform/third_party/win32/OGLES/GL/glxew.h new file mode 100644 index 0000000000..83c4bc6f8c --- /dev/null +++ b/cocos2dx/platform/third_party/win32/OGLES/GL/glxew.h @@ -0,0 +1,1587 @@ +/* +** The OpenGL Extension Wrangler Library +** Copyright (C) 2002-2008, Milan Ikits +** Copyright (C) 2002-2008, Marcelo E. Magallon +** Copyright (C) 2002, Lev Povalahev +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** +** * Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** * The name of the author may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +** THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * Mesa 3-D graphics library + * Version: 7.0 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* +** Copyright (c) 2007 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +#ifndef __glxew_h__ +#define __glxew_h__ +#define __GLXEW_H__ + +#ifdef __glxext_h_ +#error glxext.h included before glxew.h +#endif + +#if defined(GLX_H) || defined(__GLX_glx_h__) || defined(__glx_h__) +#error glx.h included before glxew.h +#endif + +#define __glxext_h_ + +#define GLX_H +#define __GLX_glx_h__ +#define __glx_h__ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* ---------------------------- GLX_VERSION_1_0 --------------------------- */ + +#ifndef GLX_VERSION_1_0 +#define GLX_VERSION_1_0 1 + +#define GLX_USE_GL 1 +#define GLX_BUFFER_SIZE 2 +#define GLX_LEVEL 3 +#define GLX_RGBA 4 +#define GLX_DOUBLEBUFFER 5 +#define GLX_STEREO 6 +#define GLX_AUX_BUFFERS 7 +#define GLX_RED_SIZE 8 +#define GLX_GREEN_SIZE 9 +#define GLX_BLUE_SIZE 10 +#define GLX_ALPHA_SIZE 11 +#define GLX_DEPTH_SIZE 12 +#define GLX_STENCIL_SIZE 13 +#define GLX_ACCUM_RED_SIZE 14 +#define GLX_ACCUM_GREEN_SIZE 15 +#define GLX_ACCUM_BLUE_SIZE 16 +#define GLX_ACCUM_ALPHA_SIZE 17 +#define GLX_BAD_SCREEN 1 +#define GLX_BAD_ATTRIBUTE 2 +#define GLX_NO_EXTENSION 3 +#define GLX_BAD_VISUAL 4 +#define GLX_BAD_CONTEXT 5 +#define GLX_BAD_VALUE 6 +#define GLX_BAD_ENUM 7 + +typedef XID GLXDrawable; +typedef XID GLXPixmap; +#ifdef __sun +typedef struct __glXContextRec *GLXContext; +#else +typedef struct __GLXcontextRec *GLXContext; +#endif + +typedef unsigned int GLXVideoDeviceNV; + +extern Bool glXQueryExtension (Display *dpy, int *errorBase, int *eventBase); +extern Bool glXQueryVersion (Display *dpy, int *major, int *minor); +extern int glXGetConfig (Display *dpy, XVisualInfo *vis, int attrib, int *value); +extern XVisualInfo* glXChooseVisual (Display *dpy, int screen, int *attribList); +extern GLXPixmap glXCreateGLXPixmap (Display *dpy, XVisualInfo *vis, Pixmap pixmap); +extern void glXDestroyGLXPixmap (Display *dpy, GLXPixmap pix); +extern GLXContext glXCreateContext (Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct); +extern void glXDestroyContext (Display *dpy, GLXContext ctx); +extern Bool glXIsDirect (Display *dpy, GLXContext ctx); +extern void glXCopyContext (Display *dpy, GLXContext src, GLXContext dst, GLulong mask); +extern Bool glXMakeCurrent (Display *dpy, GLXDrawable drawable, GLXContext ctx); +extern GLXContext glXGetCurrentContext (void); +extern GLXDrawable glXGetCurrentDrawable (void); +extern void glXWaitGL (void); +extern void glXWaitX (void); +extern void glXSwapBuffers (Display *dpy, GLXDrawable drawable); +extern void glXUseXFont (Font font, int first, int count, int listBase); + +#define GLXEW_VERSION_1_0 GLXEW_GET_VAR(__GLXEW_VERSION_1_0) + +#endif /* GLX_VERSION_1_0 */ + +/* ---------------------------- GLX_VERSION_1_1 --------------------------- */ + +#ifndef GLX_VERSION_1_1 +#define GLX_VERSION_1_1 + +#define GLX_VENDOR 0x1 +#define GLX_VERSION 0x2 +#define GLX_EXTENSIONS 0x3 + +extern const char* glXQueryExtensionsString (Display *dpy, int screen); +extern const char* glXGetClientString (Display *dpy, int name); +extern const char* glXQueryServerString (Display *dpy, int screen, int name); + +#define GLXEW_VERSION_1_1 GLXEW_GET_VAR(__GLXEW_VERSION_1_1) + +#endif /* GLX_VERSION_1_1 */ + +/* ---------------------------- GLX_VERSION_1_2 ---------------------------- */ + +#ifndef GLX_VERSION_1_2 +#define GLX_VERSION_1_2 1 + +typedef Display* ( * PFNGLXGETCURRENTDISPLAYPROC) (void); + +#define glXGetCurrentDisplay GLXEW_GET_FUN(__glewXGetCurrentDisplay) + +#define GLXEW_VERSION_1_2 GLXEW_GET_VAR(__GLXEW_VERSION_1_2) + +#endif /* GLX_VERSION_1_2 */ + +/* ---------------------------- GLX_VERSION_1_3 ---------------------------- */ + +#ifndef GLX_VERSION_1_3 +#define GLX_VERSION_1_3 1 + +#define GLX_RGBA_BIT 0x00000001 +#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001 +#define GLX_WINDOW_BIT 0x00000001 +#define GLX_COLOR_INDEX_BIT 0x00000002 +#define GLX_PIXMAP_BIT 0x00000002 +#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002 +#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004 +#define GLX_PBUFFER_BIT 0x00000004 +#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008 +#define GLX_AUX_BUFFERS_BIT 0x00000010 +#define GLX_CONFIG_CAVEAT 0x20 +#define GLX_DEPTH_BUFFER_BIT 0x00000020 +#define GLX_X_VISUAL_TYPE 0x22 +#define GLX_TRANSPARENT_TYPE 0x23 +#define GLX_TRANSPARENT_INDEX_VALUE 0x24 +#define GLX_TRANSPARENT_RED_VALUE 0x25 +#define GLX_TRANSPARENT_GREEN_VALUE 0x26 +#define GLX_TRANSPARENT_BLUE_VALUE 0x27 +#define GLX_TRANSPARENT_ALPHA_VALUE 0x28 +#define GLX_STENCIL_BUFFER_BIT 0x00000040 +#define GLX_ACCUM_BUFFER_BIT 0x00000080 +#define GLX_NONE 0x8000 +#define GLX_SLOW_CONFIG 0x8001 +#define GLX_TRUE_COLOR 0x8002 +#define GLX_DIRECT_COLOR 0x8003 +#define GLX_PSEUDO_COLOR 0x8004 +#define GLX_STATIC_COLOR 0x8005 +#define GLX_GRAY_SCALE 0x8006 +#define GLX_STATIC_GRAY 0x8007 +#define GLX_TRANSPARENT_RGB 0x8008 +#define GLX_TRANSPARENT_INDEX 0x8009 +#define GLX_VISUAL_ID 0x800B +#define GLX_SCREEN 0x800C +#define GLX_NON_CONFORMANT_CONFIG 0x800D +#define GLX_DRAWABLE_TYPE 0x8010 +#define GLX_RENDER_TYPE 0x8011 +#define GLX_X_RENDERABLE 0x8012 +#define GLX_FBCONFIG_ID 0x8013 +#define GLX_RGBA_TYPE 0x8014 +#define GLX_COLOR_INDEX_TYPE 0x8015 +#define GLX_MAX_PBUFFER_WIDTH 0x8016 +#define GLX_MAX_PBUFFER_HEIGHT 0x8017 +#define GLX_MAX_PBUFFER_PIXELS 0x8018 +#define GLX_PRESERVED_CONTENTS 0x801B +#define GLX_LARGEST_PBUFFER 0x801C +#define GLX_WIDTH 0x801D +#define GLX_HEIGHT 0x801E +#define GLX_EVENT_MASK 0x801F +#define GLX_DAMAGED 0x8020 +#define GLX_SAVED 0x8021 +#define GLX_WINDOW 0x8022 +#define GLX_PBUFFER 0x8023 +#define GLX_PBUFFER_HEIGHT 0x8040 +#define GLX_PBUFFER_WIDTH 0x8041 +#define GLX_PBUFFER_CLOBBER_MASK 0x08000000 +#define GLX_DONT_CARE 0xFFFFFFFF + +typedef XID GLXFBConfigID; +typedef XID GLXPbuffer; +typedef XID GLXWindow; +typedef struct __GLXFBConfigRec *GLXFBConfig; + +typedef struct { + int event_type; + int draw_type; + unsigned long serial; + Bool send_event; + Display *display; + GLXDrawable drawable; + unsigned int buffer_mask; + unsigned int aux_buffer; + int x, y; + int width, height; + int count; +} GLXPbufferClobberEvent; +typedef union __GLXEvent { + GLXPbufferClobberEvent glxpbufferclobber; + long pad[24]; +} GLXEvent; + +typedef GLXFBConfig* ( * PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements); +typedef GLXContext ( * PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); +typedef GLXPbuffer ( * PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list); +typedef GLXPixmap ( * PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list); +typedef GLXWindow ( * PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list); +typedef void ( * PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf); +typedef void ( * PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap); +typedef void ( * PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win); +typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLEPROC) (void); +typedef int ( * PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value); +typedef GLXFBConfig* ( * PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements); +typedef void ( * PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask); +typedef XVisualInfo* ( * PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config); +typedef Bool ( * PFNGLXMAKECONTEXTCURRENTPROC) (Display *display, GLXDrawable draw, GLXDrawable read, GLXContext ctx); +typedef int ( * PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value); +typedef void ( * PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value); +typedef void ( * PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask); + +#define glXChooseFBConfig GLXEW_GET_FUN(__glewXChooseFBConfig) +#define glXCreateNewContext GLXEW_GET_FUN(__glewXCreateNewContext) +#define glXCreatePbuffer GLXEW_GET_FUN(__glewXCreatePbuffer) +#define glXCreatePixmap GLXEW_GET_FUN(__glewXCreatePixmap) +#define glXCreateWindow GLXEW_GET_FUN(__glewXCreateWindow) +#define glXDestroyPbuffer GLXEW_GET_FUN(__glewXDestroyPbuffer) +#define glXDestroyPixmap GLXEW_GET_FUN(__glewXDestroyPixmap) +#define glXDestroyWindow GLXEW_GET_FUN(__glewXDestroyWindow) +#define glXGetCurrentReadDrawable GLXEW_GET_FUN(__glewXGetCurrentReadDrawable) +#define glXGetFBConfigAttrib GLXEW_GET_FUN(__glewXGetFBConfigAttrib) +#define glXGetFBConfigs GLXEW_GET_FUN(__glewXGetFBConfigs) +#define glXGetSelectedEvent GLXEW_GET_FUN(__glewXGetSelectedEvent) +#define glXGetVisualFromFBConfig GLXEW_GET_FUN(__glewXGetVisualFromFBConfig) +#define glXMakeContextCurrent GLXEW_GET_FUN(__glewXMakeContextCurrent) +#define glXQueryContext GLXEW_GET_FUN(__glewXQueryContext) +#define glXQueryDrawable GLXEW_GET_FUN(__glewXQueryDrawable) +#define glXSelectEvent GLXEW_GET_FUN(__glewXSelectEvent) + +#define GLXEW_VERSION_1_3 GLXEW_GET_VAR(__GLXEW_VERSION_1_3) + +#endif /* GLX_VERSION_1_3 */ + +/* ---------------------------- GLX_VERSION_1_4 ---------------------------- */ + +#ifndef GLX_VERSION_1_4 +#define GLX_VERSION_1_4 1 + +#define GLX_SAMPLE_BUFFERS 100000 +#define GLX_SAMPLES 100001 + +extern void ( * glXGetProcAddress (const GLubyte *procName)) (void); + +#define GLXEW_VERSION_1_4 GLXEW_GET_VAR(__GLXEW_VERSION_1_4) + +#endif /* GLX_VERSION_1_4 */ + +/* -------------------------- GLX_3DFX_multisample ------------------------- */ + +#ifndef GLX_3DFX_multisample +#define GLX_3DFX_multisample 1 + +#define GLX_SAMPLE_BUFFERS_3DFX 0x8050 +#define GLX_SAMPLES_3DFX 0x8051 + +#define GLXEW_3DFX_multisample GLXEW_GET_VAR(__GLXEW_3DFX_multisample) + +#endif /* GLX_3DFX_multisample */ + +/* ------------------------ GLX_AMD_gpu_association ------------------------ */ + +#ifndef GLX_AMD_gpu_association +#define GLX_AMD_gpu_association 1 + +#define GLX_GPU_VENDOR_AMD 0x1F00 +#define GLX_GPU_RENDERER_STRING_AMD 0x1F01 +#define GLX_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 +#define GLX_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 +#define GLX_GPU_RAM_AMD 0x21A3 +#define GLX_GPU_CLOCK_AMD 0x21A4 +#define GLX_GPU_NUM_PIPES_AMD 0x21A5 +#define GLX_GPU_NUM_SIMD_AMD 0x21A6 +#define GLX_GPU_NUM_RB_AMD 0x21A7 +#define GLX_GPU_NUM_SPI_AMD 0x21A8 + +#define GLXEW_AMD_gpu_association GLXEW_GET_VAR(__GLXEW_AMD_gpu_association) + +#endif /* GLX_AMD_gpu_association */ + +/* ------------------------- GLX_ARB_create_context ------------------------ */ + +#ifndef GLX_ARB_create_context +#define GLX_ARB_create_context 1 + +#define GLX_CONTEXT_DEBUG_BIT_ARB 0x0001 +#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 +#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define GLX_CONTEXT_FLAGS_ARB 0x2094 + +typedef GLXContext ( * PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display* dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); + +#define glXCreateContextAttribsARB GLXEW_GET_FUN(__glewXCreateContextAttribsARB) + +#define GLXEW_ARB_create_context GLXEW_GET_VAR(__GLXEW_ARB_create_context) + +#endif /* GLX_ARB_create_context */ + +/* --------------------- GLX_ARB_create_context_profile -------------------- */ + +#ifndef GLX_ARB_create_context_profile +#define GLX_ARB_create_context_profile 1 + +#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 +#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 + +#define GLXEW_ARB_create_context_profile GLXEW_GET_VAR(__GLXEW_ARB_create_context_profile) + +#endif /* GLX_ARB_create_context_profile */ + +/* ------------------- GLX_ARB_create_context_robustness ------------------- */ + +#ifndef GLX_ARB_create_context_robustness +#define GLX_ARB_create_context_robustness 1 + +#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GLX_NO_RESET_NOTIFICATION_ARB 0x8261 + +#define GLXEW_ARB_create_context_robustness GLXEW_GET_VAR(__GLXEW_ARB_create_context_robustness) + +#endif /* GLX_ARB_create_context_robustness */ + +/* ------------------------- GLX_ARB_fbconfig_float ------------------------ */ + +#ifndef GLX_ARB_fbconfig_float +#define GLX_ARB_fbconfig_float 1 + +#define GLX_RGBA_FLOAT_BIT 0x00000004 +#define GLX_RGBA_FLOAT_TYPE 0x20B9 + +#define GLXEW_ARB_fbconfig_float GLXEW_GET_VAR(__GLXEW_ARB_fbconfig_float) + +#endif /* GLX_ARB_fbconfig_float */ + +/* ------------------------ GLX_ARB_framebuffer_sRGB ----------------------- */ + +#ifndef GLX_ARB_framebuffer_sRGB +#define GLX_ARB_framebuffer_sRGB 1 + +#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2 + +#define GLXEW_ARB_framebuffer_sRGB GLXEW_GET_VAR(__GLXEW_ARB_framebuffer_sRGB) + +#endif /* GLX_ARB_framebuffer_sRGB */ + +/* ------------------------ GLX_ARB_get_proc_address ----------------------- */ + +#ifndef GLX_ARB_get_proc_address +#define GLX_ARB_get_proc_address 1 + +extern void ( * glXGetProcAddressARB (const GLubyte *procName)) (void); + +#define GLXEW_ARB_get_proc_address GLXEW_GET_VAR(__GLXEW_ARB_get_proc_address) + +#endif /* GLX_ARB_get_proc_address */ + +/* -------------------------- GLX_ARB_multisample -------------------------- */ + +#ifndef GLX_ARB_multisample +#define GLX_ARB_multisample 1 + +#define GLX_SAMPLE_BUFFERS_ARB 100000 +#define GLX_SAMPLES_ARB 100001 + +#define GLXEW_ARB_multisample GLXEW_GET_VAR(__GLXEW_ARB_multisample) + +#endif /* GLX_ARB_multisample */ + +/* ---------------------- GLX_ARB_vertex_buffer_object --------------------- */ + +#ifndef GLX_ARB_vertex_buffer_object +#define GLX_ARB_vertex_buffer_object 1 + +#define GLX_CONTEXT_ALLOW_BUFFER_BYTE_ORDER_MISMATCH_ARB 0x2095 + +#define GLXEW_ARB_vertex_buffer_object GLXEW_GET_VAR(__GLXEW_ARB_vertex_buffer_object) + +#endif /* GLX_ARB_vertex_buffer_object */ + +/* ----------------------- GLX_ATI_pixel_format_float ---------------------- */ + +#ifndef GLX_ATI_pixel_format_float +#define GLX_ATI_pixel_format_float 1 + +#define GLX_RGBA_FLOAT_ATI_BIT 0x00000100 + +#define GLXEW_ATI_pixel_format_float GLXEW_GET_VAR(__GLXEW_ATI_pixel_format_float) + +#endif /* GLX_ATI_pixel_format_float */ + +/* ------------------------- GLX_ATI_render_texture ------------------------ */ + +#ifndef GLX_ATI_render_texture +#define GLX_ATI_render_texture 1 + +#define GLX_BIND_TO_TEXTURE_RGB_ATI 0x9800 +#define GLX_BIND_TO_TEXTURE_RGBA_ATI 0x9801 +#define GLX_TEXTURE_FORMAT_ATI 0x9802 +#define GLX_TEXTURE_TARGET_ATI 0x9803 +#define GLX_MIPMAP_TEXTURE_ATI 0x9804 +#define GLX_TEXTURE_RGB_ATI 0x9805 +#define GLX_TEXTURE_RGBA_ATI 0x9806 +#define GLX_NO_TEXTURE_ATI 0x9807 +#define GLX_TEXTURE_CUBE_MAP_ATI 0x9808 +#define GLX_TEXTURE_1D_ATI 0x9809 +#define GLX_TEXTURE_2D_ATI 0x980A +#define GLX_MIPMAP_LEVEL_ATI 0x980B +#define GLX_CUBE_MAP_FACE_ATI 0x980C +#define GLX_TEXTURE_CUBE_MAP_POSITIVE_X_ATI 0x980D +#define GLX_TEXTURE_CUBE_MAP_NEGATIVE_X_ATI 0x980E +#define GLX_TEXTURE_CUBE_MAP_POSITIVE_Y_ATI 0x980F +#define GLX_TEXTURE_CUBE_MAP_NEGATIVE_Y_ATI 0x9810 +#define GLX_TEXTURE_CUBE_MAP_POSITIVE_Z_ATI 0x9811 +#define GLX_TEXTURE_CUBE_MAP_NEGATIVE_Z_ATI 0x9812 +#define GLX_FRONT_LEFT_ATI 0x9813 +#define GLX_FRONT_RIGHT_ATI 0x9814 +#define GLX_BACK_LEFT_ATI 0x9815 +#define GLX_BACK_RIGHT_ATI 0x9816 +#define GLX_AUX0_ATI 0x9817 +#define GLX_AUX1_ATI 0x9818 +#define GLX_AUX2_ATI 0x9819 +#define GLX_AUX3_ATI 0x981A +#define GLX_AUX4_ATI 0x981B +#define GLX_AUX5_ATI 0x981C +#define GLX_AUX6_ATI 0x981D +#define GLX_AUX7_ATI 0x981E +#define GLX_AUX8_ATI 0x981F +#define GLX_AUX9_ATI 0x9820 +#define GLX_BIND_TO_TEXTURE_LUMINANCE_ATI 0x9821 +#define GLX_BIND_TO_TEXTURE_INTENSITY_ATI 0x9822 + +typedef void ( * PFNGLXBINDTEXIMAGEATIPROC) (Display *dpy, GLXPbuffer pbuf, int buffer); +typedef void ( * PFNGLXDRAWABLEATTRIBATIPROC) (Display *dpy, GLXDrawable draw, const int *attrib_list); +typedef void ( * PFNGLXRELEASETEXIMAGEATIPROC) (Display *dpy, GLXPbuffer pbuf, int buffer); + +#define glXBindTexImageATI GLXEW_GET_FUN(__glewXBindTexImageATI) +#define glXDrawableAttribATI GLXEW_GET_FUN(__glewXDrawableAttribATI) +#define glXReleaseTexImageATI GLXEW_GET_FUN(__glewXReleaseTexImageATI) + +#define GLXEW_ATI_render_texture GLXEW_GET_VAR(__GLXEW_ATI_render_texture) + +#endif /* GLX_ATI_render_texture */ + +/* ------------------- GLX_EXT_create_context_es2_profile ------------------ */ + +#ifndef GLX_EXT_create_context_es2_profile +#define GLX_EXT_create_context_es2_profile 1 + +#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 + +#define GLXEW_EXT_create_context_es2_profile GLXEW_GET_VAR(__GLXEW_EXT_create_context_es2_profile) + +#endif /* GLX_EXT_create_context_es2_profile */ + +/* --------------------- GLX_EXT_fbconfig_packed_float --------------------- */ + +#ifndef GLX_EXT_fbconfig_packed_float +#define GLX_EXT_fbconfig_packed_float 1 + +#define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT 0x00000008 +#define GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT 0x20B1 + +#define GLXEW_EXT_fbconfig_packed_float GLXEW_GET_VAR(__GLXEW_EXT_fbconfig_packed_float) + +#endif /* GLX_EXT_fbconfig_packed_float */ + +/* ------------------------ GLX_EXT_framebuffer_sRGB ----------------------- */ + +#ifndef GLX_EXT_framebuffer_sRGB +#define GLX_EXT_framebuffer_sRGB 1 + +#define GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20B2 + +#define GLXEW_EXT_framebuffer_sRGB GLXEW_GET_VAR(__GLXEW_EXT_framebuffer_sRGB) + +#endif /* GLX_EXT_framebuffer_sRGB */ + +/* ------------------------- GLX_EXT_import_context ------------------------ */ + +#ifndef GLX_EXT_import_context +#define GLX_EXT_import_context 1 + +#define GLX_SHARE_CONTEXT_EXT 0x800A +#define GLX_VISUAL_ID_EXT 0x800B +#define GLX_SCREEN_EXT 0x800C + +typedef XID GLXContextID; + +typedef void ( * PFNGLXFREECONTEXTEXTPROC) (Display* dpy, GLXContext context); +typedef GLXContextID ( * PFNGLXGETCONTEXTIDEXTPROC) (const GLXContext context); +typedef GLXContext ( * PFNGLXIMPORTCONTEXTEXTPROC) (Display* dpy, GLXContextID contextID); +typedef int ( * PFNGLXQUERYCONTEXTINFOEXTPROC) (Display* dpy, GLXContext context, int attribute,int *value); + +#define glXFreeContextEXT GLXEW_GET_FUN(__glewXFreeContextEXT) +#define glXGetContextIDEXT GLXEW_GET_FUN(__glewXGetContextIDEXT) +#define glXImportContextEXT GLXEW_GET_FUN(__glewXImportContextEXT) +#define glXQueryContextInfoEXT GLXEW_GET_FUN(__glewXQueryContextInfoEXT) + +#define GLXEW_EXT_import_context GLXEW_GET_VAR(__GLXEW_EXT_import_context) + +#endif /* GLX_EXT_import_context */ + +/* -------------------------- GLX_EXT_scene_marker ------------------------- */ + +#ifndef GLX_EXT_scene_marker +#define GLX_EXT_scene_marker 1 + +#define GLXEW_EXT_scene_marker GLXEW_GET_VAR(__GLXEW_EXT_scene_marker) + +#endif /* GLX_EXT_scene_marker */ + +/* -------------------------- GLX_EXT_swap_control ------------------------- */ + +#ifndef GLX_EXT_swap_control +#define GLX_EXT_swap_control 1 + +#define GLX_SWAP_INTERVAL_EXT 0x20F1 +#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2 + +typedef void ( * PFNGLXSWAPINTERVALEXTPROC) (Display* dpy, GLXDrawable drawable, int interval); + +#define glXSwapIntervalEXT GLXEW_GET_FUN(__glewXSwapIntervalEXT) + +#define GLXEW_EXT_swap_control GLXEW_GET_VAR(__GLXEW_EXT_swap_control) + +#endif /* GLX_EXT_swap_control */ + +/* ---------------------- GLX_EXT_texture_from_pixmap ---------------------- */ + +#ifndef GLX_EXT_texture_from_pixmap +#define GLX_EXT_texture_from_pixmap 1 + +#define GLX_TEXTURE_1D_BIT_EXT 0x00000001 +#define GLX_TEXTURE_2D_BIT_EXT 0x00000002 +#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004 +#define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0 +#define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1 +#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2 +#define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3 +#define GLX_Y_INVERTED_EXT 0x20D4 +#define GLX_TEXTURE_FORMAT_EXT 0x20D5 +#define GLX_TEXTURE_TARGET_EXT 0x20D6 +#define GLX_MIPMAP_TEXTURE_EXT 0x20D7 +#define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8 +#define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9 +#define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA +#define GLX_TEXTURE_1D_EXT 0x20DB +#define GLX_TEXTURE_2D_EXT 0x20DC +#define GLX_TEXTURE_RECTANGLE_EXT 0x20DD +#define GLX_FRONT_LEFT_EXT 0x20DE +#define GLX_FRONT_RIGHT_EXT 0x20DF +#define GLX_BACK_LEFT_EXT 0x20E0 +#define GLX_BACK_RIGHT_EXT 0x20E1 +#define GLX_AUX0_EXT 0x20E2 +#define GLX_AUX1_EXT 0x20E3 +#define GLX_AUX2_EXT 0x20E4 +#define GLX_AUX3_EXT 0x20E5 +#define GLX_AUX4_EXT 0x20E6 +#define GLX_AUX5_EXT 0x20E7 +#define GLX_AUX6_EXT 0x20E8 +#define GLX_AUX7_EXT 0x20E9 +#define GLX_AUX8_EXT 0x20EA +#define GLX_AUX9_EXT 0x20EB + +typedef void ( * PFNGLXBINDTEXIMAGEEXTPROC) (Display* display, GLXDrawable drawable, int buffer, const int *attrib_list); +typedef void ( * PFNGLXRELEASETEXIMAGEEXTPROC) (Display* display, GLXDrawable drawable, int buffer); + +#define glXBindTexImageEXT GLXEW_GET_FUN(__glewXBindTexImageEXT) +#define glXReleaseTexImageEXT GLXEW_GET_FUN(__glewXReleaseTexImageEXT) + +#define GLXEW_EXT_texture_from_pixmap GLXEW_GET_VAR(__GLXEW_EXT_texture_from_pixmap) + +#endif /* GLX_EXT_texture_from_pixmap */ + +/* -------------------------- GLX_EXT_visual_info -------------------------- */ + +#ifndef GLX_EXT_visual_info +#define GLX_EXT_visual_info 1 + +#define GLX_X_VISUAL_TYPE_EXT 0x22 +#define GLX_TRANSPARENT_TYPE_EXT 0x23 +#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24 +#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25 +#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26 +#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27 +#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28 +#define GLX_NONE_EXT 0x8000 +#define GLX_TRUE_COLOR_EXT 0x8002 +#define GLX_DIRECT_COLOR_EXT 0x8003 +#define GLX_PSEUDO_COLOR_EXT 0x8004 +#define GLX_STATIC_COLOR_EXT 0x8005 +#define GLX_GRAY_SCALE_EXT 0x8006 +#define GLX_STATIC_GRAY_EXT 0x8007 +#define GLX_TRANSPARENT_RGB_EXT 0x8008 +#define GLX_TRANSPARENT_INDEX_EXT 0x8009 + +#define GLXEW_EXT_visual_info GLXEW_GET_VAR(__GLXEW_EXT_visual_info) + +#endif /* GLX_EXT_visual_info */ + +/* ------------------------- GLX_EXT_visual_rating ------------------------- */ + +#ifndef GLX_EXT_visual_rating +#define GLX_EXT_visual_rating 1 + +#define GLX_VISUAL_CAVEAT_EXT 0x20 +#define GLX_SLOW_VISUAL_EXT 0x8001 +#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D + +#define GLXEW_EXT_visual_rating GLXEW_GET_VAR(__GLXEW_EXT_visual_rating) + +#endif /* GLX_EXT_visual_rating */ + +/* -------------------------- GLX_INTEL_swap_event ------------------------- */ + +#ifndef GLX_INTEL_swap_event +#define GLX_INTEL_swap_event 1 + +#define GLX_EXCHANGE_COMPLETE_INTEL 0x8180 +#define GLX_COPY_COMPLETE_INTEL 0x8181 +#define GLX_FLIP_COMPLETE_INTEL 0x8182 +#define GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK 0x04000000 + +#define GLXEW_INTEL_swap_event GLXEW_GET_VAR(__GLXEW_INTEL_swap_event) + +#endif /* GLX_INTEL_swap_event */ + +/* -------------------------- GLX_MESA_agp_offset -------------------------- */ + +#ifndef GLX_MESA_agp_offset +#define GLX_MESA_agp_offset 1 + +typedef unsigned int ( * PFNGLXGETAGPOFFSETMESAPROC) (const void* pointer); + +#define glXGetAGPOffsetMESA GLXEW_GET_FUN(__glewXGetAGPOffsetMESA) + +#define GLXEW_MESA_agp_offset GLXEW_GET_VAR(__GLXEW_MESA_agp_offset) + +#endif /* GLX_MESA_agp_offset */ + +/* ------------------------ GLX_MESA_copy_sub_buffer ----------------------- */ + +#ifndef GLX_MESA_copy_sub_buffer +#define GLX_MESA_copy_sub_buffer 1 + +typedef void ( * PFNGLXCOPYSUBBUFFERMESAPROC) (Display* dpy, GLXDrawable drawable, int x, int y, int width, int height); + +#define glXCopySubBufferMESA GLXEW_GET_FUN(__glewXCopySubBufferMESA) + +#define GLXEW_MESA_copy_sub_buffer GLXEW_GET_VAR(__GLXEW_MESA_copy_sub_buffer) + +#endif /* GLX_MESA_copy_sub_buffer */ + +/* ------------------------ GLX_MESA_pixmap_colormap ----------------------- */ + +#ifndef GLX_MESA_pixmap_colormap +#define GLX_MESA_pixmap_colormap 1 + +typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPMESAPROC) (Display* dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap); + +#define glXCreateGLXPixmapMESA GLXEW_GET_FUN(__glewXCreateGLXPixmapMESA) + +#define GLXEW_MESA_pixmap_colormap GLXEW_GET_VAR(__GLXEW_MESA_pixmap_colormap) + +#endif /* GLX_MESA_pixmap_colormap */ + +/* ------------------------ GLX_MESA_release_buffers ----------------------- */ + +#ifndef GLX_MESA_release_buffers +#define GLX_MESA_release_buffers 1 + +typedef Bool ( * PFNGLXRELEASEBUFFERSMESAPROC) (Display* dpy, GLXDrawable d); + +#define glXReleaseBuffersMESA GLXEW_GET_FUN(__glewXReleaseBuffersMESA) + +#define GLXEW_MESA_release_buffers GLXEW_GET_VAR(__GLXEW_MESA_release_buffers) + +#endif /* GLX_MESA_release_buffers */ + +/* ------------------------- GLX_MESA_set_3dfx_mode ------------------------ */ + +#ifndef GLX_MESA_set_3dfx_mode +#define GLX_MESA_set_3dfx_mode 1 + +#define GLX_3DFX_WINDOW_MODE_MESA 0x1 +#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2 + +typedef GLboolean ( * PFNGLXSET3DFXMODEMESAPROC) (GLint mode); + +#define glXSet3DfxModeMESA GLXEW_GET_FUN(__glewXSet3DfxModeMESA) + +#define GLXEW_MESA_set_3dfx_mode GLXEW_GET_VAR(__GLXEW_MESA_set_3dfx_mode) + +#endif /* GLX_MESA_set_3dfx_mode */ + +/* ------------------------- GLX_MESA_swap_control ------------------------- */ + +#ifndef GLX_MESA_swap_control +#define GLX_MESA_swap_control 1 + +typedef int ( * PFNGLXGETSWAPINTERVALMESAPROC) (void); +typedef int ( * PFNGLXSWAPINTERVALMESAPROC) (unsigned int interval); + +#define glXGetSwapIntervalMESA GLXEW_GET_FUN(__glewXGetSwapIntervalMESA) +#define glXSwapIntervalMESA GLXEW_GET_FUN(__glewXSwapIntervalMESA) + +#define GLXEW_MESA_swap_control GLXEW_GET_VAR(__GLXEW_MESA_swap_control) + +#endif /* GLX_MESA_swap_control */ + +/* --------------------------- GLX_NV_copy_image --------------------------- */ + +#ifndef GLX_NV_copy_image +#define GLX_NV_copy_image 1 + +typedef void ( * PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); + +#define glXCopyImageSubDataNV GLXEW_GET_FUN(__glewXCopyImageSubDataNV) + +#define GLXEW_NV_copy_image GLXEW_GET_VAR(__GLXEW_NV_copy_image) + +#endif /* GLX_NV_copy_image */ + +/* -------------------------- GLX_NV_float_buffer -------------------------- */ + +#ifndef GLX_NV_float_buffer +#define GLX_NV_float_buffer 1 + +#define GLX_FLOAT_COMPONENTS_NV 0x20B0 + +#define GLXEW_NV_float_buffer GLXEW_GET_VAR(__GLXEW_NV_float_buffer) + +#endif /* GLX_NV_float_buffer */ + +/* ---------------------- GLX_NV_multisample_coverage ---------------------- */ + +#ifndef GLX_NV_multisample_coverage +#define GLX_NV_multisample_coverage 1 + +#define GLX_COLOR_SAMPLES_NV 0x20B3 +#define GLX_COVERAGE_SAMPLES_NV 100001 + +#define GLXEW_NV_multisample_coverage GLXEW_GET_VAR(__GLXEW_NV_multisample_coverage) + +#endif /* GLX_NV_multisample_coverage */ + +/* -------------------------- GLX_NV_present_video ------------------------- */ + +#ifndef GLX_NV_present_video +#define GLX_NV_present_video 1 + +#define GLX_NUM_VIDEO_SLOTS_NV 0x20F0 + +typedef int ( * PFNGLXBINDVIDEODEVICENVPROC) (Display* dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list); +typedef unsigned int* ( * PFNGLXENUMERATEVIDEODEVICESNVPROC) (Display *dpy, int screen, int *nelements); + +#define glXBindVideoDeviceNV GLXEW_GET_FUN(__glewXBindVideoDeviceNV) +#define glXEnumerateVideoDevicesNV GLXEW_GET_FUN(__glewXEnumerateVideoDevicesNV) + +#define GLXEW_NV_present_video GLXEW_GET_VAR(__GLXEW_NV_present_video) + +#endif /* GLX_NV_present_video */ + +/* --------------------------- GLX_NV_swap_group --------------------------- */ + +#ifndef GLX_NV_swap_group +#define GLX_NV_swap_group 1 + +typedef Bool ( * PFNGLXBINDSWAPBARRIERNVPROC) (Display* dpy, GLuint group, GLuint barrier); +typedef Bool ( * PFNGLXJOINSWAPGROUPNVPROC) (Display* dpy, GLXDrawable drawable, GLuint group); +typedef Bool ( * PFNGLXQUERYFRAMECOUNTNVPROC) (Display* dpy, int screen, GLuint *count); +typedef Bool ( * PFNGLXQUERYMAXSWAPGROUPSNVPROC) (Display* dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers); +typedef Bool ( * PFNGLXQUERYSWAPGROUPNVPROC) (Display* dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier); +typedef Bool ( * PFNGLXRESETFRAMECOUNTNVPROC) (Display* dpy, int screen); + +#define glXBindSwapBarrierNV GLXEW_GET_FUN(__glewXBindSwapBarrierNV) +#define glXJoinSwapGroupNV GLXEW_GET_FUN(__glewXJoinSwapGroupNV) +#define glXQueryFrameCountNV GLXEW_GET_FUN(__glewXQueryFrameCountNV) +#define glXQueryMaxSwapGroupsNV GLXEW_GET_FUN(__glewXQueryMaxSwapGroupsNV) +#define glXQuerySwapGroupNV GLXEW_GET_FUN(__glewXQuerySwapGroupNV) +#define glXResetFrameCountNV GLXEW_GET_FUN(__glewXResetFrameCountNV) + +#define GLXEW_NV_swap_group GLXEW_GET_VAR(__GLXEW_NV_swap_group) + +#endif /* GLX_NV_swap_group */ + +/* ----------------------- GLX_NV_vertex_array_range ----------------------- */ + +#ifndef GLX_NV_vertex_array_range +#define GLX_NV_vertex_array_range 1 + +typedef void * ( * PFNGLXALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readFrequency, GLfloat writeFrequency, GLfloat priority); +typedef void ( * PFNGLXFREEMEMORYNVPROC) (void *pointer); + +#define glXAllocateMemoryNV GLXEW_GET_FUN(__glewXAllocateMemoryNV) +#define glXFreeMemoryNV GLXEW_GET_FUN(__glewXFreeMemoryNV) + +#define GLXEW_NV_vertex_array_range GLXEW_GET_VAR(__GLXEW_NV_vertex_array_range) + +#endif /* GLX_NV_vertex_array_range */ + +/* -------------------------- GLX_NV_video_capture ------------------------- */ + +#ifndef GLX_NV_video_capture +#define GLX_NV_video_capture 1 + +#define GLX_DEVICE_ID_NV 0x20CD +#define GLX_UNIQUE_ID_NV 0x20CE +#define GLX_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF + +typedef XID GLXVideoCaptureDeviceNV; + +typedef int ( * PFNGLXBINDVIDEOCAPTUREDEVICENVPROC) (Display* dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device); +typedef GLXVideoCaptureDeviceNV * ( * PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC) (Display* dpy, int screen, int *nelements); +typedef void ( * PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC) (Display* dpy, GLXVideoCaptureDeviceNV device); +typedef int ( * PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC) (Display* dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value); +typedef void ( * PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC) (Display* dpy, GLXVideoCaptureDeviceNV device); + +#define glXBindVideoCaptureDeviceNV GLXEW_GET_FUN(__glewXBindVideoCaptureDeviceNV) +#define glXEnumerateVideoCaptureDevicesNV GLXEW_GET_FUN(__glewXEnumerateVideoCaptureDevicesNV) +#define glXLockVideoCaptureDeviceNV GLXEW_GET_FUN(__glewXLockVideoCaptureDeviceNV) +#define glXQueryVideoCaptureDeviceNV GLXEW_GET_FUN(__glewXQueryVideoCaptureDeviceNV) +#define glXReleaseVideoCaptureDeviceNV GLXEW_GET_FUN(__glewXReleaseVideoCaptureDeviceNV) + +#define GLXEW_NV_video_capture GLXEW_GET_VAR(__GLXEW_NV_video_capture) + +#endif /* GLX_NV_video_capture */ + +/* -------------------------- GLX_NV_video_output -------------------------- */ + +#ifndef GLX_NV_video_output +#define GLX_NV_video_output 1 + +#define GLX_VIDEO_OUT_COLOR_NV 0x20C3 +#define GLX_VIDEO_OUT_ALPHA_NV 0x20C4 +#define GLX_VIDEO_OUT_DEPTH_NV 0x20C5 +#define GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 +#define GLX_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 +#define GLX_VIDEO_OUT_FRAME_NV 0x20C8 +#define GLX_VIDEO_OUT_FIELD_1_NV 0x20C9 +#define GLX_VIDEO_OUT_FIELD_2_NV 0x20CA +#define GLX_VIDEO_OUT_STACKED_FIELDS_1_2_NV 0x20CB +#define GLX_VIDEO_OUT_STACKED_FIELDS_2_1_NV 0x20CC + +typedef int ( * PFNGLXBINDVIDEOIMAGENVPROC) (Display* dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer); +typedef int ( * PFNGLXGETVIDEODEVICENVPROC) (Display* dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice); +typedef int ( * PFNGLXGETVIDEOINFONVPROC) (Display* dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +typedef int ( * PFNGLXRELEASEVIDEODEVICENVPROC) (Display* dpy, int screen, GLXVideoDeviceNV VideoDevice); +typedef int ( * PFNGLXRELEASEVIDEOIMAGENVPROC) (Display* dpy, GLXPbuffer pbuf); +typedef int ( * PFNGLXSENDPBUFFERTOVIDEONVPROC) (Display* dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock); + +#define glXBindVideoImageNV GLXEW_GET_FUN(__glewXBindVideoImageNV) +#define glXGetVideoDeviceNV GLXEW_GET_FUN(__glewXGetVideoDeviceNV) +#define glXGetVideoInfoNV GLXEW_GET_FUN(__glewXGetVideoInfoNV) +#define glXReleaseVideoDeviceNV GLXEW_GET_FUN(__glewXReleaseVideoDeviceNV) +#define glXReleaseVideoImageNV GLXEW_GET_FUN(__glewXReleaseVideoImageNV) +#define glXSendPbufferToVideoNV GLXEW_GET_FUN(__glewXSendPbufferToVideoNV) + +#define GLXEW_NV_video_output GLXEW_GET_VAR(__GLXEW_NV_video_output) + +#endif /* GLX_NV_video_output */ + +/* -------------------------- GLX_OML_swap_method -------------------------- */ + +#ifndef GLX_OML_swap_method +#define GLX_OML_swap_method 1 + +#define GLX_SWAP_METHOD_OML 0x8060 +#define GLX_SWAP_EXCHANGE_OML 0x8061 +#define GLX_SWAP_COPY_OML 0x8062 +#define GLX_SWAP_UNDEFINED_OML 0x8063 + +#define GLXEW_OML_swap_method GLXEW_GET_VAR(__GLXEW_OML_swap_method) + +#endif /* GLX_OML_swap_method */ + +/* -------------------------- GLX_OML_sync_control ------------------------- */ + +#ifndef GLX_OML_sync_control +#define GLX_OML_sync_control 1 + +typedef Bool ( * PFNGLXGETMSCRATEOMLPROC) (Display* dpy, GLXDrawable drawable, int32_t* numerator, int32_t* denominator); +typedef Bool ( * PFNGLXGETSYNCVALUESOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t* ust, int64_t* msc, int64_t* sbc); +typedef int64_t ( * PFNGLXSWAPBUFFERSMSCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder); +typedef Bool ( * PFNGLXWAITFORMSCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t* ust, int64_t* msc, int64_t* sbc); +typedef Bool ( * PFNGLXWAITFORSBCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_sbc, int64_t* ust, int64_t* msc, int64_t* sbc); + +#define glXGetMscRateOML GLXEW_GET_FUN(__glewXGetMscRateOML) +#define glXGetSyncValuesOML GLXEW_GET_FUN(__glewXGetSyncValuesOML) +#define glXSwapBuffersMscOML GLXEW_GET_FUN(__glewXSwapBuffersMscOML) +#define glXWaitForMscOML GLXEW_GET_FUN(__glewXWaitForMscOML) +#define glXWaitForSbcOML GLXEW_GET_FUN(__glewXWaitForSbcOML) + +#define GLXEW_OML_sync_control GLXEW_GET_VAR(__GLXEW_OML_sync_control) + +#endif /* GLX_OML_sync_control */ + +/* ------------------------ GLX_SGIS_blended_overlay ----------------------- */ + +#ifndef GLX_SGIS_blended_overlay +#define GLX_SGIS_blended_overlay 1 + +#define GLX_BLENDED_RGBA_SGIS 0x8025 + +#define GLXEW_SGIS_blended_overlay GLXEW_GET_VAR(__GLXEW_SGIS_blended_overlay) + +#endif /* GLX_SGIS_blended_overlay */ + +/* -------------------------- GLX_SGIS_color_range ------------------------- */ + +#ifndef GLX_SGIS_color_range +#define GLX_SGIS_color_range 1 + +#define GLX_MIN_RED_SGIS 0 +#define GLX_MAX_GREEN_SGIS 0 +#define GLX_MIN_BLUE_SGIS 0 +#define GLX_MAX_ALPHA_SGIS 0 +#define GLX_MIN_GREEN_SGIS 0 +#define GLX_MIN_ALPHA_SGIS 0 +#define GLX_MAX_RED_SGIS 0 +#define GLX_EXTENDED_RANGE_SGIS 0 +#define GLX_MAX_BLUE_SGIS 0 + +#define GLXEW_SGIS_color_range GLXEW_GET_VAR(__GLXEW_SGIS_color_range) + +#endif /* GLX_SGIS_color_range */ + +/* -------------------------- GLX_SGIS_multisample ------------------------- */ + +#ifndef GLX_SGIS_multisample +#define GLX_SGIS_multisample 1 + +#define GLX_SAMPLE_BUFFERS_SGIS 100000 +#define GLX_SAMPLES_SGIS 100001 + +#define GLXEW_SGIS_multisample GLXEW_GET_VAR(__GLXEW_SGIS_multisample) + +#endif /* GLX_SGIS_multisample */ + +/* ---------------------- GLX_SGIS_shared_multisample ---------------------- */ + +#ifndef GLX_SGIS_shared_multisample +#define GLX_SGIS_shared_multisample 1 + +#define GLX_MULTISAMPLE_SUB_RECT_WIDTH_SGIS 0x8026 +#define GLX_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS 0x8027 + +#define GLXEW_SGIS_shared_multisample GLXEW_GET_VAR(__GLXEW_SGIS_shared_multisample) + +#endif /* GLX_SGIS_shared_multisample */ + +/* --------------------------- GLX_SGIX_fbconfig --------------------------- */ + +#ifndef GLX_SGIX_fbconfig +#define GLX_SGIX_fbconfig 1 + +#define GLX_WINDOW_BIT_SGIX 0x00000001 +#define GLX_RGBA_BIT_SGIX 0x00000001 +#define GLX_PIXMAP_BIT_SGIX 0x00000002 +#define GLX_COLOR_INDEX_BIT_SGIX 0x00000002 +#define GLX_SCREEN_EXT 0x800C +#define GLX_DRAWABLE_TYPE_SGIX 0x8010 +#define GLX_RENDER_TYPE_SGIX 0x8011 +#define GLX_X_RENDERABLE_SGIX 0x8012 +#define GLX_FBCONFIG_ID_SGIX 0x8013 +#define GLX_RGBA_TYPE_SGIX 0x8014 +#define GLX_COLOR_INDEX_TYPE_SGIX 0x8015 + +typedef XID GLXFBConfigIDSGIX; +typedef struct __GLXFBConfigRec *GLXFBConfigSGIX; + +typedef GLXFBConfigSGIX* ( * PFNGLXCHOOSEFBCONFIGSGIXPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements); +typedef GLXContext ( * PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) (Display* dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); +typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC) (Display* dpy, GLXFBConfig config, Pixmap pixmap); +typedef int ( * PFNGLXGETFBCONFIGATTRIBSGIXPROC) (Display* dpy, GLXFBConfigSGIX config, int attribute, int *value); +typedef GLXFBConfigSGIX ( * PFNGLXGETFBCONFIGFROMVISUALSGIXPROC) (Display* dpy, XVisualInfo *vis); +typedef XVisualInfo* ( * PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLXFBConfig config); + +#define glXChooseFBConfigSGIX GLXEW_GET_FUN(__glewXChooseFBConfigSGIX) +#define glXCreateContextWithConfigSGIX GLXEW_GET_FUN(__glewXCreateContextWithConfigSGIX) +#define glXCreateGLXPixmapWithConfigSGIX GLXEW_GET_FUN(__glewXCreateGLXPixmapWithConfigSGIX) +#define glXGetFBConfigAttribSGIX GLXEW_GET_FUN(__glewXGetFBConfigAttribSGIX) +#define glXGetFBConfigFromVisualSGIX GLXEW_GET_FUN(__glewXGetFBConfigFromVisualSGIX) +#define glXGetVisualFromFBConfigSGIX GLXEW_GET_FUN(__glewXGetVisualFromFBConfigSGIX) + +#define GLXEW_SGIX_fbconfig GLXEW_GET_VAR(__GLXEW_SGIX_fbconfig) + +#endif /* GLX_SGIX_fbconfig */ + +/* --------------------------- GLX_SGIX_hyperpipe -------------------------- */ + +#ifndef GLX_SGIX_hyperpipe +#define GLX_SGIX_hyperpipe 1 + +#define GLX_HYPERPIPE_DISPLAY_PIPE_SGIX 0x00000001 +#define GLX_PIPE_RECT_SGIX 0x00000001 +#define GLX_PIPE_RECT_LIMITS_SGIX 0x00000002 +#define GLX_HYPERPIPE_RENDER_PIPE_SGIX 0x00000002 +#define GLX_HYPERPIPE_STEREO_SGIX 0x00000003 +#define GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX 0x00000004 +#define GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80 +#define GLX_BAD_HYPERPIPE_CONFIG_SGIX 91 +#define GLX_BAD_HYPERPIPE_SGIX 92 +#define GLX_HYPERPIPE_ID_SGIX 0x8030 + +typedef struct { + char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; + int networkId; +} GLXHyperpipeNetworkSGIX; +typedef struct { + char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; + int XOrigin; + int YOrigin; + int maxHeight; + int maxWidth; +} GLXPipeRectLimits; +typedef struct { + char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; + int channel; + unsigned int participationType; + int timeSlice; +} GLXHyperpipeConfigSGIX; +typedef struct { + char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; + int srcXOrigin; + int srcYOrigin; + int srcWidth; + int srcHeight; + int destXOrigin; + int destYOrigin; + int destWidth; + int destHeight; +} GLXPipeRect; + +typedef int ( * PFNGLXBINDHYPERPIPESGIXPROC) (Display *dpy, int hpId); +typedef int ( * PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId); +typedef int ( * PFNGLXHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList); +typedef int ( * PFNGLXHYPERPIPECONFIGSGIXPROC) (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId); +typedef int ( * PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList); +typedef int ( * PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList); +typedef GLXHyperpipeConfigSGIX * ( * PFNGLXQUERYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId, int *npipes); +typedef GLXHyperpipeNetworkSGIX * ( * PFNGLXQUERYHYPERPIPENETWORKSGIXPROC) (Display *dpy, int *npipes); + +#define glXBindHyperpipeSGIX GLXEW_GET_FUN(__glewXBindHyperpipeSGIX) +#define glXDestroyHyperpipeConfigSGIX GLXEW_GET_FUN(__glewXDestroyHyperpipeConfigSGIX) +#define glXHyperpipeAttribSGIX GLXEW_GET_FUN(__glewXHyperpipeAttribSGIX) +#define glXHyperpipeConfigSGIX GLXEW_GET_FUN(__glewXHyperpipeConfigSGIX) +#define glXQueryHyperpipeAttribSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeAttribSGIX) +#define glXQueryHyperpipeBestAttribSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeBestAttribSGIX) +#define glXQueryHyperpipeConfigSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeConfigSGIX) +#define glXQueryHyperpipeNetworkSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeNetworkSGIX) + +#define GLXEW_SGIX_hyperpipe GLXEW_GET_VAR(__GLXEW_SGIX_hyperpipe) + +#endif /* GLX_SGIX_hyperpipe */ + +/* ---------------------------- GLX_SGIX_pbuffer --------------------------- */ + +#ifndef GLX_SGIX_pbuffer +#define GLX_SGIX_pbuffer 1 + +#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001 +#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002 +#define GLX_PBUFFER_BIT_SGIX 0x00000004 +#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004 +#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008 +#define GLX_AUX_BUFFERS_BIT_SGIX 0x00000010 +#define GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020 +#define GLX_STENCIL_BUFFER_BIT_SGIX 0x00000040 +#define GLX_ACCUM_BUFFER_BIT_SGIX 0x00000080 +#define GLX_SAMPLE_BUFFERS_BIT_SGIX 0x00000100 +#define GLX_MAX_PBUFFER_WIDTH_SGIX 0x8016 +#define GLX_MAX_PBUFFER_HEIGHT_SGIX 0x8017 +#define GLX_MAX_PBUFFER_PIXELS_SGIX 0x8018 +#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019 +#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A +#define GLX_PRESERVED_CONTENTS_SGIX 0x801B +#define GLX_LARGEST_PBUFFER_SGIX 0x801C +#define GLX_WIDTH_SGIX 0x801D +#define GLX_HEIGHT_SGIX 0x801E +#define GLX_EVENT_MASK_SGIX 0x801F +#define GLX_DAMAGED_SGIX 0x8020 +#define GLX_SAVED_SGIX 0x8021 +#define GLX_WINDOW_SGIX 0x8022 +#define GLX_PBUFFER_SGIX 0x8023 +#define GLX_BUFFER_CLOBBER_MASK_SGIX 0x08000000 + +typedef XID GLXPbufferSGIX; +typedef struct { int type; unsigned long serial; Bool send_event; Display *display; GLXDrawable drawable; int event_type; int draw_type; unsigned int mask; int x, y; int width, height; int count; } GLXBufferClobberEventSGIX; + +typedef GLXPbuffer ( * PFNGLXCREATEGLXPBUFFERSGIXPROC) (Display* dpy, GLXFBConfig config, unsigned int width, unsigned int height, int *attrib_list); +typedef void ( * PFNGLXDESTROYGLXPBUFFERSGIXPROC) (Display* dpy, GLXPbuffer pbuf); +typedef void ( * PFNGLXGETSELECTEDEVENTSGIXPROC) (Display* dpy, GLXDrawable drawable, unsigned long *mask); +typedef void ( * PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display* dpy, GLXPbuffer pbuf, int attribute, unsigned int *value); +typedef void ( * PFNGLXSELECTEVENTSGIXPROC) (Display* dpy, GLXDrawable drawable, unsigned long mask); + +#define glXCreateGLXPbufferSGIX GLXEW_GET_FUN(__glewXCreateGLXPbufferSGIX) +#define glXDestroyGLXPbufferSGIX GLXEW_GET_FUN(__glewXDestroyGLXPbufferSGIX) +#define glXGetSelectedEventSGIX GLXEW_GET_FUN(__glewXGetSelectedEventSGIX) +#define glXQueryGLXPbufferSGIX GLXEW_GET_FUN(__glewXQueryGLXPbufferSGIX) +#define glXSelectEventSGIX GLXEW_GET_FUN(__glewXSelectEventSGIX) + +#define GLXEW_SGIX_pbuffer GLXEW_GET_VAR(__GLXEW_SGIX_pbuffer) + +#endif /* GLX_SGIX_pbuffer */ + +/* ------------------------- GLX_SGIX_swap_barrier ------------------------- */ + +#ifndef GLX_SGIX_swap_barrier +#define GLX_SGIX_swap_barrier 1 + +typedef void ( * PFNGLXBINDSWAPBARRIERSGIXPROC) (Display *dpy, GLXDrawable drawable, int barrier); +typedef Bool ( * PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC) (Display *dpy, int screen, int *max); + +#define glXBindSwapBarrierSGIX GLXEW_GET_FUN(__glewXBindSwapBarrierSGIX) +#define glXQueryMaxSwapBarriersSGIX GLXEW_GET_FUN(__glewXQueryMaxSwapBarriersSGIX) + +#define GLXEW_SGIX_swap_barrier GLXEW_GET_VAR(__GLXEW_SGIX_swap_barrier) + +#endif /* GLX_SGIX_swap_barrier */ + +/* -------------------------- GLX_SGIX_swap_group -------------------------- */ + +#ifndef GLX_SGIX_swap_group +#define GLX_SGIX_swap_group 1 + +typedef void ( * PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawable, GLXDrawable member); + +#define glXJoinSwapGroupSGIX GLXEW_GET_FUN(__glewXJoinSwapGroupSGIX) + +#define GLXEW_SGIX_swap_group GLXEW_GET_VAR(__GLXEW_SGIX_swap_group) + +#endif /* GLX_SGIX_swap_group */ + +/* ------------------------- GLX_SGIX_video_resize ------------------------- */ + +#ifndef GLX_SGIX_video_resize +#define GLX_SGIX_video_resize 1 + +#define GLX_SYNC_FRAME_SGIX 0x00000000 +#define GLX_SYNC_SWAP_SGIX 0x00000001 + +typedef int ( * PFNGLXBINDCHANNELTOWINDOWSGIXPROC) (Display* display, int screen, int channel, Window window); +typedef int ( * PFNGLXCHANNELRECTSGIXPROC) (Display* display, int screen, int channel, int x, int y, int w, int h); +typedef int ( * PFNGLXCHANNELRECTSYNCSGIXPROC) (Display* display, int screen, int channel, GLenum synctype); +typedef int ( * PFNGLXQUERYCHANNELDELTASSGIXPROC) (Display* display, int screen, int channel, int *x, int *y, int *w, int *h); +typedef int ( * PFNGLXQUERYCHANNELRECTSGIXPROC) (Display* display, int screen, int channel, int *dx, int *dy, int *dw, int *dh); + +#define glXBindChannelToWindowSGIX GLXEW_GET_FUN(__glewXBindChannelToWindowSGIX) +#define glXChannelRectSGIX GLXEW_GET_FUN(__glewXChannelRectSGIX) +#define glXChannelRectSyncSGIX GLXEW_GET_FUN(__glewXChannelRectSyncSGIX) +#define glXQueryChannelDeltasSGIX GLXEW_GET_FUN(__glewXQueryChannelDeltasSGIX) +#define glXQueryChannelRectSGIX GLXEW_GET_FUN(__glewXQueryChannelRectSGIX) + +#define GLXEW_SGIX_video_resize GLXEW_GET_VAR(__GLXEW_SGIX_video_resize) + +#endif /* GLX_SGIX_video_resize */ + +/* ---------------------- GLX_SGIX_visual_select_group --------------------- */ + +#ifndef GLX_SGIX_visual_select_group +#define GLX_SGIX_visual_select_group 1 + +#define GLX_VISUAL_SELECT_GROUP_SGIX 0x8028 + +#define GLXEW_SGIX_visual_select_group GLXEW_GET_VAR(__GLXEW_SGIX_visual_select_group) + +#endif /* GLX_SGIX_visual_select_group */ + +/* ---------------------------- GLX_SGI_cushion ---------------------------- */ + +#ifndef GLX_SGI_cushion +#define GLX_SGI_cushion 1 + +typedef void ( * PFNGLXCUSHIONSGIPROC) (Display* dpy, Window window, float cushion); + +#define glXCushionSGI GLXEW_GET_FUN(__glewXCushionSGI) + +#define GLXEW_SGI_cushion GLXEW_GET_VAR(__GLXEW_SGI_cushion) + +#endif /* GLX_SGI_cushion */ + +/* ----------------------- GLX_SGI_make_current_read ----------------------- */ + +#ifndef GLX_SGI_make_current_read +#define GLX_SGI_make_current_read 1 + +typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLESGIPROC) (void); +typedef Bool ( * PFNGLXMAKECURRENTREADSGIPROC) (Display* dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); + +#define glXGetCurrentReadDrawableSGI GLXEW_GET_FUN(__glewXGetCurrentReadDrawableSGI) +#define glXMakeCurrentReadSGI GLXEW_GET_FUN(__glewXMakeCurrentReadSGI) + +#define GLXEW_SGI_make_current_read GLXEW_GET_VAR(__GLXEW_SGI_make_current_read) + +#endif /* GLX_SGI_make_current_read */ + +/* -------------------------- GLX_SGI_swap_control ------------------------- */ + +#ifndef GLX_SGI_swap_control +#define GLX_SGI_swap_control 1 + +typedef int ( * PFNGLXSWAPINTERVALSGIPROC) (int interval); + +#define glXSwapIntervalSGI GLXEW_GET_FUN(__glewXSwapIntervalSGI) + +#define GLXEW_SGI_swap_control GLXEW_GET_VAR(__GLXEW_SGI_swap_control) + +#endif /* GLX_SGI_swap_control */ + +/* --------------------------- GLX_SGI_video_sync -------------------------- */ + +#ifndef GLX_SGI_video_sync +#define GLX_SGI_video_sync 1 + +typedef int ( * PFNGLXGETVIDEOSYNCSGIPROC) (unsigned int* count); +typedef int ( * PFNGLXWAITVIDEOSYNCSGIPROC) (int divisor, int remainder, unsigned int* count); + +#define glXGetVideoSyncSGI GLXEW_GET_FUN(__glewXGetVideoSyncSGI) +#define glXWaitVideoSyncSGI GLXEW_GET_FUN(__glewXWaitVideoSyncSGI) + +#define GLXEW_SGI_video_sync GLXEW_GET_VAR(__GLXEW_SGI_video_sync) + +#endif /* GLX_SGI_video_sync */ + +/* --------------------- GLX_SUN_get_transparent_index --------------------- */ + +#ifndef GLX_SUN_get_transparent_index +#define GLX_SUN_get_transparent_index 1 + +typedef Status ( * PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display* dpy, Window overlay, Window underlay, unsigned long *pTransparentIndex); + +#define glXGetTransparentIndexSUN GLXEW_GET_FUN(__glewXGetTransparentIndexSUN) + +#define GLXEW_SUN_get_transparent_index GLXEW_GET_VAR(__GLXEW_SUN_get_transparent_index) + +#endif /* GLX_SUN_get_transparent_index */ + +/* -------------------------- GLX_SUN_video_resize ------------------------- */ + +#ifndef GLX_SUN_video_resize +#define GLX_SUN_video_resize 1 + +#define GLX_VIDEO_RESIZE_SUN 0x8171 +#define GL_VIDEO_RESIZE_COMPENSATION_SUN 0x85CD + +typedef int ( * PFNGLXGETVIDEORESIZESUNPROC) (Display* display, GLXDrawable window, float* factor); +typedef int ( * PFNGLXVIDEORESIZESUNPROC) (Display* display, GLXDrawable window, float factor); + +#define glXGetVideoResizeSUN GLXEW_GET_FUN(__glewXGetVideoResizeSUN) +#define glXVideoResizeSUN GLXEW_GET_FUN(__glewXVideoResizeSUN) + +#define GLXEW_SUN_video_resize GLXEW_GET_VAR(__GLXEW_SUN_video_resize) + +#endif /* GLX_SUN_video_resize */ + +/* ------------------------------------------------------------------------- */ + +#ifdef GLEW_MX +#define GLXEW_EXPORT +#else +#define GLXEW_EXPORT extern +#endif /* GLEW_MX */ + +extern PFNGLXGETCURRENTDISPLAYPROC __glewXGetCurrentDisplay; + +extern PFNGLXCHOOSEFBCONFIGPROC __glewXChooseFBConfig; +extern PFNGLXCREATENEWCONTEXTPROC __glewXCreateNewContext; +extern PFNGLXCREATEPBUFFERPROC __glewXCreatePbuffer; +extern PFNGLXCREATEPIXMAPPROC __glewXCreatePixmap; +extern PFNGLXCREATEWINDOWPROC __glewXCreateWindow; +extern PFNGLXDESTROYPBUFFERPROC __glewXDestroyPbuffer; +extern PFNGLXDESTROYPIXMAPPROC __glewXDestroyPixmap; +extern PFNGLXDESTROYWINDOWPROC __glewXDestroyWindow; +extern PFNGLXGETCURRENTREADDRAWABLEPROC __glewXGetCurrentReadDrawable; +extern PFNGLXGETFBCONFIGATTRIBPROC __glewXGetFBConfigAttrib; +extern PFNGLXGETFBCONFIGSPROC __glewXGetFBConfigs; +extern PFNGLXGETSELECTEDEVENTPROC __glewXGetSelectedEvent; +extern PFNGLXGETVISUALFROMFBCONFIGPROC __glewXGetVisualFromFBConfig; +extern PFNGLXMAKECONTEXTCURRENTPROC __glewXMakeContextCurrent; +extern PFNGLXQUERYCONTEXTPROC __glewXQueryContext; +extern PFNGLXQUERYDRAWABLEPROC __glewXQueryDrawable; +extern PFNGLXSELECTEVENTPROC __glewXSelectEvent; + +extern PFNGLXCREATECONTEXTATTRIBSARBPROC __glewXCreateContextAttribsARB; + +extern PFNGLXBINDTEXIMAGEATIPROC __glewXBindTexImageATI; +extern PFNGLXDRAWABLEATTRIBATIPROC __glewXDrawableAttribATI; +extern PFNGLXRELEASETEXIMAGEATIPROC __glewXReleaseTexImageATI; + +extern PFNGLXFREECONTEXTEXTPROC __glewXFreeContextEXT; +extern PFNGLXGETCONTEXTIDEXTPROC __glewXGetContextIDEXT; +extern PFNGLXIMPORTCONTEXTEXTPROC __glewXImportContextEXT; +extern PFNGLXQUERYCONTEXTINFOEXTPROC __glewXQueryContextInfoEXT; + +extern PFNGLXSWAPINTERVALEXTPROC __glewXSwapIntervalEXT; + +extern PFNGLXBINDTEXIMAGEEXTPROC __glewXBindTexImageEXT; +extern PFNGLXRELEASETEXIMAGEEXTPROC __glewXReleaseTexImageEXT; + +extern PFNGLXGETAGPOFFSETMESAPROC __glewXGetAGPOffsetMESA; + +extern PFNGLXCOPYSUBBUFFERMESAPROC __glewXCopySubBufferMESA; + +extern PFNGLXCREATEGLXPIXMAPMESAPROC __glewXCreateGLXPixmapMESA; + +extern PFNGLXRELEASEBUFFERSMESAPROC __glewXReleaseBuffersMESA; + +extern PFNGLXSET3DFXMODEMESAPROC __glewXSet3DfxModeMESA; + +extern PFNGLXGETSWAPINTERVALMESAPROC __glewXGetSwapIntervalMESA; +extern PFNGLXSWAPINTERVALMESAPROC __glewXSwapIntervalMESA; + +extern PFNGLXCOPYIMAGESUBDATANVPROC __glewXCopyImageSubDataNV; + +extern PFNGLXBINDVIDEODEVICENVPROC __glewXBindVideoDeviceNV; +extern PFNGLXENUMERATEVIDEODEVICESNVPROC __glewXEnumerateVideoDevicesNV; + +extern PFNGLXBINDSWAPBARRIERNVPROC __glewXBindSwapBarrierNV; +extern PFNGLXJOINSWAPGROUPNVPROC __glewXJoinSwapGroupNV; +extern PFNGLXQUERYFRAMECOUNTNVPROC __glewXQueryFrameCountNV; +extern PFNGLXQUERYMAXSWAPGROUPSNVPROC __glewXQueryMaxSwapGroupsNV; +extern PFNGLXQUERYSWAPGROUPNVPROC __glewXQuerySwapGroupNV; +extern PFNGLXRESETFRAMECOUNTNVPROC __glewXResetFrameCountNV; + +extern PFNGLXALLOCATEMEMORYNVPROC __glewXAllocateMemoryNV; +extern PFNGLXFREEMEMORYNVPROC __glewXFreeMemoryNV; + +extern PFNGLXBINDVIDEOCAPTUREDEVICENVPROC __glewXBindVideoCaptureDeviceNV; +extern PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC __glewXEnumerateVideoCaptureDevicesNV; +extern PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC __glewXLockVideoCaptureDeviceNV; +extern PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC __glewXQueryVideoCaptureDeviceNV; +extern PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC __glewXReleaseVideoCaptureDeviceNV; + +extern PFNGLXBINDVIDEOIMAGENVPROC __glewXBindVideoImageNV; +extern PFNGLXGETVIDEODEVICENVPROC __glewXGetVideoDeviceNV; +extern PFNGLXGETVIDEOINFONVPROC __glewXGetVideoInfoNV; +extern PFNGLXRELEASEVIDEODEVICENVPROC __glewXReleaseVideoDeviceNV; +extern PFNGLXRELEASEVIDEOIMAGENVPROC __glewXReleaseVideoImageNV; +extern PFNGLXSENDPBUFFERTOVIDEONVPROC __glewXSendPbufferToVideoNV; + +extern PFNGLXGETMSCRATEOMLPROC __glewXGetMscRateOML; +extern PFNGLXGETSYNCVALUESOMLPROC __glewXGetSyncValuesOML; +extern PFNGLXSWAPBUFFERSMSCOMLPROC __glewXSwapBuffersMscOML; +extern PFNGLXWAITFORMSCOMLPROC __glewXWaitForMscOML; +extern PFNGLXWAITFORSBCOMLPROC __glewXWaitForSbcOML; + +extern PFNGLXCHOOSEFBCONFIGSGIXPROC __glewXChooseFBConfigSGIX; +extern PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC __glewXCreateContextWithConfigSGIX; +extern PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC __glewXCreateGLXPixmapWithConfigSGIX; +extern PFNGLXGETFBCONFIGATTRIBSGIXPROC __glewXGetFBConfigAttribSGIX; +extern PFNGLXGETFBCONFIGFROMVISUALSGIXPROC __glewXGetFBConfigFromVisualSGIX; +extern PFNGLXGETVISUALFROMFBCONFIGSGIXPROC __glewXGetVisualFromFBConfigSGIX; + +extern PFNGLXBINDHYPERPIPESGIXPROC __glewXBindHyperpipeSGIX; +extern PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC __glewXDestroyHyperpipeConfigSGIX; +extern PFNGLXHYPERPIPEATTRIBSGIXPROC __glewXHyperpipeAttribSGIX; +extern PFNGLXHYPERPIPECONFIGSGIXPROC __glewXHyperpipeConfigSGIX; +extern PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC __glewXQueryHyperpipeAttribSGIX; +extern PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC __glewXQueryHyperpipeBestAttribSGIX; +extern PFNGLXQUERYHYPERPIPECONFIGSGIXPROC __glewXQueryHyperpipeConfigSGIX; +extern PFNGLXQUERYHYPERPIPENETWORKSGIXPROC __glewXQueryHyperpipeNetworkSGIX; + +extern PFNGLXCREATEGLXPBUFFERSGIXPROC __glewXCreateGLXPbufferSGIX; +extern PFNGLXDESTROYGLXPBUFFERSGIXPROC __glewXDestroyGLXPbufferSGIX; +extern PFNGLXGETSELECTEDEVENTSGIXPROC __glewXGetSelectedEventSGIX; +extern PFNGLXQUERYGLXPBUFFERSGIXPROC __glewXQueryGLXPbufferSGIX; +extern PFNGLXSELECTEVENTSGIXPROC __glewXSelectEventSGIX; + +extern PFNGLXBINDSWAPBARRIERSGIXPROC __glewXBindSwapBarrierSGIX; +extern PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC __glewXQueryMaxSwapBarriersSGIX; + +extern PFNGLXJOINSWAPGROUPSGIXPROC __glewXJoinSwapGroupSGIX; + +extern PFNGLXBINDCHANNELTOWINDOWSGIXPROC __glewXBindChannelToWindowSGIX; +extern PFNGLXCHANNELRECTSGIXPROC __glewXChannelRectSGIX; +extern PFNGLXCHANNELRECTSYNCSGIXPROC __glewXChannelRectSyncSGIX; +extern PFNGLXQUERYCHANNELDELTASSGIXPROC __glewXQueryChannelDeltasSGIX; +extern PFNGLXQUERYCHANNELRECTSGIXPROC __glewXQueryChannelRectSGIX; + +extern PFNGLXCUSHIONSGIPROC __glewXCushionSGI; + +extern PFNGLXGETCURRENTREADDRAWABLESGIPROC __glewXGetCurrentReadDrawableSGI; +extern PFNGLXMAKECURRENTREADSGIPROC __glewXMakeCurrentReadSGI; + +extern PFNGLXSWAPINTERVALSGIPROC __glewXSwapIntervalSGI; + +extern PFNGLXGETVIDEOSYNCSGIPROC __glewXGetVideoSyncSGI; +extern PFNGLXWAITVIDEOSYNCSGIPROC __glewXWaitVideoSyncSGI; + +extern PFNGLXGETTRANSPARENTINDEXSUNPROC __glewXGetTransparentIndexSUN; + +extern PFNGLXGETVIDEORESIZESUNPROC __glewXGetVideoResizeSUN; +extern PFNGLXVIDEORESIZESUNPROC __glewXVideoResizeSUN; + +#if defined(GLEW_MX) +struct GLXEWContextStruct +{ +#endif /* GLEW_MX */ + +GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_0; +GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_1; +GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_2; +GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_3; +GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_4; +GLXEW_EXPORT GLboolean __GLXEW_3DFX_multisample; +GLXEW_EXPORT GLboolean __GLXEW_AMD_gpu_association; +GLXEW_EXPORT GLboolean __GLXEW_ARB_create_context; +GLXEW_EXPORT GLboolean __GLXEW_ARB_create_context_profile; +GLXEW_EXPORT GLboolean __GLXEW_ARB_create_context_robustness; +GLXEW_EXPORT GLboolean __GLXEW_ARB_fbconfig_float; +GLXEW_EXPORT GLboolean __GLXEW_ARB_framebuffer_sRGB; +GLXEW_EXPORT GLboolean __GLXEW_ARB_get_proc_address; +GLXEW_EXPORT GLboolean __GLXEW_ARB_multisample; +GLXEW_EXPORT GLboolean __GLXEW_ARB_vertex_buffer_object; +GLXEW_EXPORT GLboolean __GLXEW_ATI_pixel_format_float; +GLXEW_EXPORT GLboolean __GLXEW_ATI_render_texture; +GLXEW_EXPORT GLboolean __GLXEW_EXT_create_context_es2_profile; +GLXEW_EXPORT GLboolean __GLXEW_EXT_fbconfig_packed_float; +GLXEW_EXPORT GLboolean __GLXEW_EXT_framebuffer_sRGB; +GLXEW_EXPORT GLboolean __GLXEW_EXT_import_context; +GLXEW_EXPORT GLboolean __GLXEW_EXT_scene_marker; +GLXEW_EXPORT GLboolean __GLXEW_EXT_swap_control; +GLXEW_EXPORT GLboolean __GLXEW_EXT_texture_from_pixmap; +GLXEW_EXPORT GLboolean __GLXEW_EXT_visual_info; +GLXEW_EXPORT GLboolean __GLXEW_EXT_visual_rating; +GLXEW_EXPORT GLboolean __GLXEW_INTEL_swap_event; +GLXEW_EXPORT GLboolean __GLXEW_MESA_agp_offset; +GLXEW_EXPORT GLboolean __GLXEW_MESA_copy_sub_buffer; +GLXEW_EXPORT GLboolean __GLXEW_MESA_pixmap_colormap; +GLXEW_EXPORT GLboolean __GLXEW_MESA_release_buffers; +GLXEW_EXPORT GLboolean __GLXEW_MESA_set_3dfx_mode; +GLXEW_EXPORT GLboolean __GLXEW_MESA_swap_control; +GLXEW_EXPORT GLboolean __GLXEW_NV_copy_image; +GLXEW_EXPORT GLboolean __GLXEW_NV_float_buffer; +GLXEW_EXPORT GLboolean __GLXEW_NV_multisample_coverage; +GLXEW_EXPORT GLboolean __GLXEW_NV_present_video; +GLXEW_EXPORT GLboolean __GLXEW_NV_swap_group; +GLXEW_EXPORT GLboolean __GLXEW_NV_vertex_array_range; +GLXEW_EXPORT GLboolean __GLXEW_NV_video_capture; +GLXEW_EXPORT GLboolean __GLXEW_NV_video_output; +GLXEW_EXPORT GLboolean __GLXEW_OML_swap_method; +GLXEW_EXPORT GLboolean __GLXEW_OML_sync_control; +GLXEW_EXPORT GLboolean __GLXEW_SGIS_blended_overlay; +GLXEW_EXPORT GLboolean __GLXEW_SGIS_color_range; +GLXEW_EXPORT GLboolean __GLXEW_SGIS_multisample; +GLXEW_EXPORT GLboolean __GLXEW_SGIS_shared_multisample; +GLXEW_EXPORT GLboolean __GLXEW_SGIX_fbconfig; +GLXEW_EXPORT GLboolean __GLXEW_SGIX_hyperpipe; +GLXEW_EXPORT GLboolean __GLXEW_SGIX_pbuffer; +GLXEW_EXPORT GLboolean __GLXEW_SGIX_swap_barrier; +GLXEW_EXPORT GLboolean __GLXEW_SGIX_swap_group; +GLXEW_EXPORT GLboolean __GLXEW_SGIX_video_resize; +GLXEW_EXPORT GLboolean __GLXEW_SGIX_visual_select_group; +GLXEW_EXPORT GLboolean __GLXEW_SGI_cushion; +GLXEW_EXPORT GLboolean __GLXEW_SGI_make_current_read; +GLXEW_EXPORT GLboolean __GLXEW_SGI_swap_control; +GLXEW_EXPORT GLboolean __GLXEW_SGI_video_sync; +GLXEW_EXPORT GLboolean __GLXEW_SUN_get_transparent_index; +GLXEW_EXPORT GLboolean __GLXEW_SUN_video_resize; + +#ifdef GLEW_MX +}; /* GLXEWContextStruct */ +#endif /* GLEW_MX */ + +/* ------------------------------------------------------------------------ */ + +#ifdef GLEW_MX + +typedef struct GLXEWContextStruct GLXEWContext; +extern GLenum glxewContextInit (GLXEWContext* ctx); +extern GLboolean glxewContextIsSupported (const GLXEWContext* ctx, const char* name); + +#define glxewInit() glxewContextInit(glxewGetContext()) +#define glxewIsSupported(x) glxewContextIsSupported(glxewGetContext(), x) + +#define GLXEW_GET_VAR(x) (*(const GLboolean*)&(glxewGetContext()->x)) +#define GLXEW_GET_FUN(x) x + +#else /* GLEW_MX */ + +#define GLXEW_GET_VAR(x) (*(const GLboolean*)&x) +#define GLXEW_GET_FUN(x) x + +extern GLboolean glxewIsSupported (const char* name); + +#endif /* GLEW_MX */ + +extern GLboolean glxewGetExtension (const char* name); + +#ifdef __cplusplus +} +#endif + +#endif /* __glxew_h__ */ diff --git a/cocos2dx/platform/third_party/win32/OGLES/GL/wglew.h b/cocos2dx/platform/third_party/win32/OGLES/GL/wglew.h new file mode 100644 index 0000000000..a32e11c6c6 --- /dev/null +++ b/cocos2dx/platform/third_party/win32/OGLES/GL/wglew.h @@ -0,0 +1,1363 @@ +/* +** The OpenGL Extension Wrangler Library +** Copyright (C) 2002-2008, Milan Ikits +** Copyright (C) 2002-2008, Marcelo E. Magallon +** Copyright (C) 2002, Lev Povalahev +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** +** * Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** * The name of the author may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +** THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +** Copyright (c) 2007 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +#ifndef __wglew_h__ +#define __wglew_h__ +#define __WGLEW_H__ + +#ifdef __wglext_h_ +#error wglext.h included before wglew.h +#endif + +#define __wglext_h_ + +#if !defined(WINAPI) +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN 1 +# endif +#include +# undef WIN32_LEAN_AND_MEAN +#endif + +/* + * GLEW_STATIC needs to be set when using the static version. + * GLEW_BUILD is set when building the DLL version. + */ +#ifdef GLEW_STATIC +# define GLEWAPI extern +#else +# ifdef GLEW_BUILD +# define GLEWAPI extern __declspec(dllexport) +# else +# define GLEWAPI extern __declspec(dllimport) +# endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* -------------------------- WGL_3DFX_multisample ------------------------- */ + +#ifndef WGL_3DFX_multisample +#define WGL_3DFX_multisample 1 + +#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 +#define WGL_SAMPLES_3DFX 0x2061 + +#define WGLEW_3DFX_multisample WGLEW_GET_VAR(__WGLEW_3DFX_multisample) + +#endif /* WGL_3DFX_multisample */ + +/* ------------------------- WGL_3DL_stereo_control ------------------------ */ + +#ifndef WGL_3DL_stereo_control +#define WGL_3DL_stereo_control 1 + +#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 +#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 +#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 +#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 + +typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); + +#define wglSetStereoEmitterState3DL WGLEW_GET_FUN(__wglewSetStereoEmitterState3DL) + +#define WGLEW_3DL_stereo_control WGLEW_GET_VAR(__WGLEW_3DL_stereo_control) + +#endif /* WGL_3DL_stereo_control */ + +/* ------------------------ WGL_AMD_gpu_association ------------------------ */ + +#ifndef WGL_AMD_gpu_association +#define WGL_AMD_gpu_association 1 + +#define WGL_GPU_VENDOR_AMD 0x1F00 +#define WGL_GPU_RENDERER_STRING_AMD 0x1F01 +#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 +#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 +#define WGL_GPU_RAM_AMD 0x21A3 +#define WGL_GPU_CLOCK_AMD 0x21A4 +#define WGL_GPU_NUM_PIPES_AMD 0x21A5 +#define WGL_GPU_NUM_SIMD_AMD 0x21A6 +#define WGL_GPU_NUM_RB_AMD 0x21A7 +#define WGL_GPU_NUM_SPI_AMD 0x21A8 + +typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); +typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int* attribList); +typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc); +typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); +typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); +typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT* ids); +typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, INT property, GLenum dataType, UINT size, void* data); +typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc); + +#define wglBlitContextFramebufferAMD WGLEW_GET_FUN(__wglewBlitContextFramebufferAMD) +#define wglCreateAssociatedContextAMD WGLEW_GET_FUN(__wglewCreateAssociatedContextAMD) +#define wglCreateAssociatedContextAttribsAMD WGLEW_GET_FUN(__wglewCreateAssociatedContextAttribsAMD) +#define wglDeleteAssociatedContextAMD WGLEW_GET_FUN(__wglewDeleteAssociatedContextAMD) +#define wglGetContextGPUIDAMD WGLEW_GET_FUN(__wglewGetContextGPUIDAMD) +#define wglGetCurrentAssociatedContextAMD WGLEW_GET_FUN(__wglewGetCurrentAssociatedContextAMD) +#define wglGetGPUIDsAMD WGLEW_GET_FUN(__wglewGetGPUIDsAMD) +#define wglGetGPUInfoAMD WGLEW_GET_FUN(__wglewGetGPUInfoAMD) +#define wglMakeAssociatedContextCurrentAMD WGLEW_GET_FUN(__wglewMakeAssociatedContextCurrentAMD) + +#define WGLEW_AMD_gpu_association WGLEW_GET_VAR(__WGLEW_AMD_gpu_association) + +#endif /* WGL_AMD_gpu_association */ + +/* ------------------------- WGL_ARB_buffer_region ------------------------- */ + +#ifndef WGL_ARB_buffer_region +#define WGL_ARB_buffer_region 1 + +#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 +#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 +#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 +#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 + +typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); +typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); +typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); +typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); + +#define wglCreateBufferRegionARB WGLEW_GET_FUN(__wglewCreateBufferRegionARB) +#define wglDeleteBufferRegionARB WGLEW_GET_FUN(__wglewDeleteBufferRegionARB) +#define wglRestoreBufferRegionARB WGLEW_GET_FUN(__wglewRestoreBufferRegionARB) +#define wglSaveBufferRegionARB WGLEW_GET_FUN(__wglewSaveBufferRegionARB) + +#define WGLEW_ARB_buffer_region WGLEW_GET_VAR(__WGLEW_ARB_buffer_region) + +#endif /* WGL_ARB_buffer_region */ + +/* ------------------------- WGL_ARB_create_context ------------------------ */ + +#ifndef WGL_ARB_create_context +#define WGL_ARB_create_context 1 + +#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 +#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 +#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 +#define WGL_CONTEXT_FLAGS_ARB 0x2094 +#define ERROR_INVALID_VERSION_ARB 0x2095 +#define ERROR_INVALID_PROFILE_ARB 0x2096 + +typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int* attribList); + +#define wglCreateContextAttribsARB WGLEW_GET_FUN(__wglewCreateContextAttribsARB) + +#define WGLEW_ARB_create_context WGLEW_GET_VAR(__WGLEW_ARB_create_context) + +#endif /* WGL_ARB_create_context */ + +/* --------------------- WGL_ARB_create_context_profile -------------------- */ + +#ifndef WGL_ARB_create_context_profile +#define WGL_ARB_create_context_profile 1 + +#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 +#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 + +#define WGLEW_ARB_create_context_profile WGLEW_GET_VAR(__WGLEW_ARB_create_context_profile) + +#endif /* WGL_ARB_create_context_profile */ + +/* ------------------- WGL_ARB_create_context_robustness ------------------- */ + +#ifndef WGL_ARB_create_context_robustness +#define WGL_ARB_create_context_robustness 1 + +#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 + +#define WGLEW_ARB_create_context_robustness WGLEW_GET_VAR(__WGLEW_ARB_create_context_robustness) + +#endif /* WGL_ARB_create_context_robustness */ + +/* ----------------------- WGL_ARB_extensions_string ----------------------- */ + +#ifndef WGL_ARB_extensions_string +#define WGL_ARB_extensions_string 1 + +typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); + +#define wglGetExtensionsStringARB WGLEW_GET_FUN(__wglewGetExtensionsStringARB) + +#define WGLEW_ARB_extensions_string WGLEW_GET_VAR(__WGLEW_ARB_extensions_string) + +#endif /* WGL_ARB_extensions_string */ + +/* ------------------------ WGL_ARB_framebuffer_sRGB ----------------------- */ + +#ifndef WGL_ARB_framebuffer_sRGB +#define WGL_ARB_framebuffer_sRGB 1 + +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 + +#define WGLEW_ARB_framebuffer_sRGB WGLEW_GET_VAR(__WGLEW_ARB_framebuffer_sRGB) + +#endif /* WGL_ARB_framebuffer_sRGB */ + +/* ----------------------- WGL_ARB_make_current_read ----------------------- */ + +#ifndef WGL_ARB_make_current_read +#define WGL_ARB_make_current_read 1 + +#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 +#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 + +typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (VOID); +typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); + +#define wglGetCurrentReadDCARB WGLEW_GET_FUN(__wglewGetCurrentReadDCARB) +#define wglMakeContextCurrentARB WGLEW_GET_FUN(__wglewMakeContextCurrentARB) + +#define WGLEW_ARB_make_current_read WGLEW_GET_VAR(__WGLEW_ARB_make_current_read) + +#endif /* WGL_ARB_make_current_read */ + +/* -------------------------- WGL_ARB_multisample -------------------------- */ + +#ifndef WGL_ARB_multisample +#define WGL_ARB_multisample 1 + +#define WGL_SAMPLE_BUFFERS_ARB 0x2041 +#define WGL_SAMPLES_ARB 0x2042 + +#define WGLEW_ARB_multisample WGLEW_GET_VAR(__WGLEW_ARB_multisample) + +#endif /* WGL_ARB_multisample */ + +/* ---------------------------- WGL_ARB_pbuffer ---------------------------- */ + +#ifndef WGL_ARB_pbuffer +#define WGL_ARB_pbuffer 1 + +#define WGL_DRAW_TO_PBUFFER_ARB 0x202D +#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E +#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 +#define WGL_PBUFFER_LARGEST_ARB 0x2033 +#define WGL_PBUFFER_WIDTH_ARB 0x2034 +#define WGL_PBUFFER_HEIGHT_ARB 0x2035 +#define WGL_PBUFFER_LOST_ARB 0x2036 + +DECLARE_HANDLE(HPBUFFERARB); + +typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList); +typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); +typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); +typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int* piValue); +typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); + +#define wglCreatePbufferARB WGLEW_GET_FUN(__wglewCreatePbufferARB) +#define wglDestroyPbufferARB WGLEW_GET_FUN(__wglewDestroyPbufferARB) +#define wglGetPbufferDCARB WGLEW_GET_FUN(__wglewGetPbufferDCARB) +#define wglQueryPbufferARB WGLEW_GET_FUN(__wglewQueryPbufferARB) +#define wglReleasePbufferDCARB WGLEW_GET_FUN(__wglewReleasePbufferDCARB) + +#define WGLEW_ARB_pbuffer WGLEW_GET_VAR(__WGLEW_ARB_pbuffer) + +#endif /* WGL_ARB_pbuffer */ + +/* -------------------------- WGL_ARB_pixel_format ------------------------- */ + +#ifndef WGL_ARB_pixel_format +#define WGL_ARB_pixel_format 1 + +#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 +#define WGL_DRAW_TO_WINDOW_ARB 0x2001 +#define WGL_DRAW_TO_BITMAP_ARB 0x2002 +#define WGL_ACCELERATION_ARB 0x2003 +#define WGL_NEED_PALETTE_ARB 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 +#define WGL_SWAP_METHOD_ARB 0x2007 +#define WGL_NUMBER_OVERLAYS_ARB 0x2008 +#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 +#define WGL_TRANSPARENT_ARB 0x200A +#define WGL_SHARE_DEPTH_ARB 0x200C +#define WGL_SHARE_STENCIL_ARB 0x200D +#define WGL_SHARE_ACCUM_ARB 0x200E +#define WGL_SUPPORT_GDI_ARB 0x200F +#define WGL_SUPPORT_OPENGL_ARB 0x2010 +#define WGL_DOUBLE_BUFFER_ARB 0x2011 +#define WGL_STEREO_ARB 0x2012 +#define WGL_PIXEL_TYPE_ARB 0x2013 +#define WGL_COLOR_BITS_ARB 0x2014 +#define WGL_RED_BITS_ARB 0x2015 +#define WGL_RED_SHIFT_ARB 0x2016 +#define WGL_GREEN_BITS_ARB 0x2017 +#define WGL_GREEN_SHIFT_ARB 0x2018 +#define WGL_BLUE_BITS_ARB 0x2019 +#define WGL_BLUE_SHIFT_ARB 0x201A +#define WGL_ALPHA_BITS_ARB 0x201B +#define WGL_ALPHA_SHIFT_ARB 0x201C +#define WGL_ACCUM_BITS_ARB 0x201D +#define WGL_ACCUM_RED_BITS_ARB 0x201E +#define WGL_ACCUM_GREEN_BITS_ARB 0x201F +#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 +#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 +#define WGL_DEPTH_BITS_ARB 0x2022 +#define WGL_STENCIL_BITS_ARB 0x2023 +#define WGL_AUX_BUFFERS_ARB 0x2024 +#define WGL_NO_ACCELERATION_ARB 0x2025 +#define WGL_GENERIC_ACCELERATION_ARB 0x2026 +#define WGL_FULL_ACCELERATION_ARB 0x2027 +#define WGL_SWAP_EXCHANGE_ARB 0x2028 +#define WGL_SWAP_COPY_ARB 0x2029 +#define WGL_SWAP_UNDEFINED_ARB 0x202A +#define WGL_TYPE_RGBA_ARB 0x202B +#define WGL_TYPE_COLORINDEX_ARB 0x202C +#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 +#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 +#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 +#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A +#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B + +typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int* piAttributes, FLOAT *pfValues); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int* piAttributes, int *piValues); + +#define wglChoosePixelFormatARB WGLEW_GET_FUN(__wglewChoosePixelFormatARB) +#define wglGetPixelFormatAttribfvARB WGLEW_GET_FUN(__wglewGetPixelFormatAttribfvARB) +#define wglGetPixelFormatAttribivARB WGLEW_GET_FUN(__wglewGetPixelFormatAttribivARB) + +#define WGLEW_ARB_pixel_format WGLEW_GET_VAR(__WGLEW_ARB_pixel_format) + +#endif /* WGL_ARB_pixel_format */ + +/* ----------------------- WGL_ARB_pixel_format_float ---------------------- */ + +#ifndef WGL_ARB_pixel_format_float +#define WGL_ARB_pixel_format_float 1 + +#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 + +#define WGLEW_ARB_pixel_format_float WGLEW_GET_VAR(__WGLEW_ARB_pixel_format_float) + +#endif /* WGL_ARB_pixel_format_float */ + +/* ------------------------- WGL_ARB_render_texture ------------------------ */ + +#ifndef WGL_ARB_render_texture +#define WGL_ARB_render_texture 1 + +#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 +#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 +#define WGL_TEXTURE_FORMAT_ARB 0x2072 +#define WGL_TEXTURE_TARGET_ARB 0x2073 +#define WGL_MIPMAP_TEXTURE_ARB 0x2074 +#define WGL_TEXTURE_RGB_ARB 0x2075 +#define WGL_TEXTURE_RGBA_ARB 0x2076 +#define WGL_NO_TEXTURE_ARB 0x2077 +#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 +#define WGL_TEXTURE_1D_ARB 0x2079 +#define WGL_TEXTURE_2D_ARB 0x207A +#define WGL_MIPMAP_LEVEL_ARB 0x207B +#define WGL_CUBE_MAP_FACE_ARB 0x207C +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 +#define WGL_FRONT_LEFT_ARB 0x2083 +#define WGL_FRONT_RIGHT_ARB 0x2084 +#define WGL_BACK_LEFT_ARB 0x2085 +#define WGL_BACK_RIGHT_ARB 0x2086 +#define WGL_AUX0_ARB 0x2087 +#define WGL_AUX1_ARB 0x2088 +#define WGL_AUX2_ARB 0x2089 +#define WGL_AUX3_ARB 0x208A +#define WGL_AUX4_ARB 0x208B +#define WGL_AUX5_ARB 0x208C +#define WGL_AUX6_ARB 0x208D +#define WGL_AUX7_ARB 0x208E +#define WGL_AUX8_ARB 0x208F +#define WGL_AUX9_ARB 0x2090 + +typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); +typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); +typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int* piAttribList); + +#define wglBindTexImageARB WGLEW_GET_FUN(__wglewBindTexImageARB) +#define wglReleaseTexImageARB WGLEW_GET_FUN(__wglewReleaseTexImageARB) +#define wglSetPbufferAttribARB WGLEW_GET_FUN(__wglewSetPbufferAttribARB) + +#define WGLEW_ARB_render_texture WGLEW_GET_VAR(__WGLEW_ARB_render_texture) + +#endif /* WGL_ARB_render_texture */ + +/* ----------------------- WGL_ATI_pixel_format_float ---------------------- */ + +#ifndef WGL_ATI_pixel_format_float +#define WGL_ATI_pixel_format_float 1 + +#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 +#define GL_RGBA_FLOAT_MODE_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 + +#define WGLEW_ATI_pixel_format_float WGLEW_GET_VAR(__WGLEW_ATI_pixel_format_float) + +#endif /* WGL_ATI_pixel_format_float */ + +/* -------------------- WGL_ATI_render_texture_rectangle ------------------- */ + +#ifndef WGL_ATI_render_texture_rectangle +#define WGL_ATI_render_texture_rectangle 1 + +#define WGL_TEXTURE_RECTANGLE_ATI 0x21A5 + +#define WGLEW_ATI_render_texture_rectangle WGLEW_GET_VAR(__WGLEW_ATI_render_texture_rectangle) + +#endif /* WGL_ATI_render_texture_rectangle */ + +/* ------------------- WGL_EXT_create_context_es2_profile ------------------ */ + +#ifndef WGL_EXT_create_context_es2_profile +#define WGL_EXT_create_context_es2_profile 1 + +#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 + +#define WGLEW_EXT_create_context_es2_profile WGLEW_GET_VAR(__WGLEW_EXT_create_context_es2_profile) + +#endif /* WGL_EXT_create_context_es2_profile */ + +/* -------------------------- WGL_EXT_depth_float -------------------------- */ + +#ifndef WGL_EXT_depth_float +#define WGL_EXT_depth_float 1 + +#define WGL_DEPTH_FLOAT_EXT 0x2040 + +#define WGLEW_EXT_depth_float WGLEW_GET_VAR(__WGLEW_EXT_depth_float) + +#endif /* WGL_EXT_depth_float */ + +/* ---------------------- WGL_EXT_display_color_table ---------------------- */ + +#ifndef WGL_EXT_display_color_table +#define WGL_EXT_display_color_table 1 + +typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); +typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); +typedef void (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); +typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (GLushort* table, GLuint length); + +#define wglBindDisplayColorTableEXT WGLEW_GET_FUN(__wglewBindDisplayColorTableEXT) +#define wglCreateDisplayColorTableEXT WGLEW_GET_FUN(__wglewCreateDisplayColorTableEXT) +#define wglDestroyDisplayColorTableEXT WGLEW_GET_FUN(__wglewDestroyDisplayColorTableEXT) +#define wglLoadDisplayColorTableEXT WGLEW_GET_FUN(__wglewLoadDisplayColorTableEXT) + +#define WGLEW_EXT_display_color_table WGLEW_GET_VAR(__WGLEW_EXT_display_color_table) + +#endif /* WGL_EXT_display_color_table */ + +/* ----------------------- WGL_EXT_extensions_string ----------------------- */ + +#ifndef WGL_EXT_extensions_string +#define WGL_EXT_extensions_string 1 + +typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); + +#define wglGetExtensionsStringEXT WGLEW_GET_FUN(__wglewGetExtensionsStringEXT) + +#define WGLEW_EXT_extensions_string WGLEW_GET_VAR(__WGLEW_EXT_extensions_string) + +#endif /* WGL_EXT_extensions_string */ + +/* ------------------------ WGL_EXT_framebuffer_sRGB ----------------------- */ + +#ifndef WGL_EXT_framebuffer_sRGB +#define WGL_EXT_framebuffer_sRGB 1 + +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 + +#define WGLEW_EXT_framebuffer_sRGB WGLEW_GET_VAR(__WGLEW_EXT_framebuffer_sRGB) + +#endif /* WGL_EXT_framebuffer_sRGB */ + +/* ----------------------- WGL_EXT_make_current_read ----------------------- */ + +#ifndef WGL_EXT_make_current_read +#define WGL_EXT_make_current_read 1 + +#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 + +typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (VOID); +typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); + +#define wglGetCurrentReadDCEXT WGLEW_GET_FUN(__wglewGetCurrentReadDCEXT) +#define wglMakeContextCurrentEXT WGLEW_GET_FUN(__wglewMakeContextCurrentEXT) + +#define WGLEW_EXT_make_current_read WGLEW_GET_VAR(__WGLEW_EXT_make_current_read) + +#endif /* WGL_EXT_make_current_read */ + +/* -------------------------- WGL_EXT_multisample -------------------------- */ + +#ifndef WGL_EXT_multisample +#define WGL_EXT_multisample 1 + +#define WGL_SAMPLE_BUFFERS_EXT 0x2041 +#define WGL_SAMPLES_EXT 0x2042 + +#define WGLEW_EXT_multisample WGLEW_GET_VAR(__WGLEW_EXT_multisample) + +#endif /* WGL_EXT_multisample */ + +/* ---------------------------- WGL_EXT_pbuffer ---------------------------- */ + +#ifndef WGL_EXT_pbuffer +#define WGL_EXT_pbuffer 1 + +#define WGL_DRAW_TO_PBUFFER_EXT 0x202D +#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E +#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 +#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 +#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 +#define WGL_PBUFFER_LARGEST_EXT 0x2033 +#define WGL_PBUFFER_WIDTH_EXT 0x2034 +#define WGL_PBUFFER_HEIGHT_EXT 0x2035 + +DECLARE_HANDLE(HPBUFFEREXT); + +typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList); +typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); +typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); +typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int* piValue); +typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); + +#define wglCreatePbufferEXT WGLEW_GET_FUN(__wglewCreatePbufferEXT) +#define wglDestroyPbufferEXT WGLEW_GET_FUN(__wglewDestroyPbufferEXT) +#define wglGetPbufferDCEXT WGLEW_GET_FUN(__wglewGetPbufferDCEXT) +#define wglQueryPbufferEXT WGLEW_GET_FUN(__wglewQueryPbufferEXT) +#define wglReleasePbufferDCEXT WGLEW_GET_FUN(__wglewReleasePbufferDCEXT) + +#define WGLEW_EXT_pbuffer WGLEW_GET_VAR(__WGLEW_EXT_pbuffer) + +#endif /* WGL_EXT_pbuffer */ + +/* -------------------------- WGL_EXT_pixel_format ------------------------- */ + +#ifndef WGL_EXT_pixel_format +#define WGL_EXT_pixel_format 1 + +#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 +#define WGL_DRAW_TO_WINDOW_EXT 0x2001 +#define WGL_DRAW_TO_BITMAP_EXT 0x2002 +#define WGL_ACCELERATION_EXT 0x2003 +#define WGL_NEED_PALETTE_EXT 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 +#define WGL_SWAP_METHOD_EXT 0x2007 +#define WGL_NUMBER_OVERLAYS_EXT 0x2008 +#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 +#define WGL_TRANSPARENT_EXT 0x200A +#define WGL_TRANSPARENT_VALUE_EXT 0x200B +#define WGL_SHARE_DEPTH_EXT 0x200C +#define WGL_SHARE_STENCIL_EXT 0x200D +#define WGL_SHARE_ACCUM_EXT 0x200E +#define WGL_SUPPORT_GDI_EXT 0x200F +#define WGL_SUPPORT_OPENGL_EXT 0x2010 +#define WGL_DOUBLE_BUFFER_EXT 0x2011 +#define WGL_STEREO_EXT 0x2012 +#define WGL_PIXEL_TYPE_EXT 0x2013 +#define WGL_COLOR_BITS_EXT 0x2014 +#define WGL_RED_BITS_EXT 0x2015 +#define WGL_RED_SHIFT_EXT 0x2016 +#define WGL_GREEN_BITS_EXT 0x2017 +#define WGL_GREEN_SHIFT_EXT 0x2018 +#define WGL_BLUE_BITS_EXT 0x2019 +#define WGL_BLUE_SHIFT_EXT 0x201A +#define WGL_ALPHA_BITS_EXT 0x201B +#define WGL_ALPHA_SHIFT_EXT 0x201C +#define WGL_ACCUM_BITS_EXT 0x201D +#define WGL_ACCUM_RED_BITS_EXT 0x201E +#define WGL_ACCUM_GREEN_BITS_EXT 0x201F +#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 +#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 +#define WGL_DEPTH_BITS_EXT 0x2022 +#define WGL_STENCIL_BITS_EXT 0x2023 +#define WGL_AUX_BUFFERS_EXT 0x2024 +#define WGL_NO_ACCELERATION_EXT 0x2025 +#define WGL_GENERIC_ACCELERATION_EXT 0x2026 +#define WGL_FULL_ACCELERATION_EXT 0x2027 +#define WGL_SWAP_EXCHANGE_EXT 0x2028 +#define WGL_SWAP_COPY_EXT 0x2029 +#define WGL_SWAP_UNDEFINED_EXT 0x202A +#define WGL_TYPE_RGBA_EXT 0x202B +#define WGL_TYPE_COLORINDEX_EXT 0x202C + +typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, FLOAT *pfValues); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, int *piValues); + +#define wglChoosePixelFormatEXT WGLEW_GET_FUN(__wglewChoosePixelFormatEXT) +#define wglGetPixelFormatAttribfvEXT WGLEW_GET_FUN(__wglewGetPixelFormatAttribfvEXT) +#define wglGetPixelFormatAttribivEXT WGLEW_GET_FUN(__wglewGetPixelFormatAttribivEXT) + +#define WGLEW_EXT_pixel_format WGLEW_GET_VAR(__WGLEW_EXT_pixel_format) + +#endif /* WGL_EXT_pixel_format */ + +/* ------------------- WGL_EXT_pixel_format_packed_float ------------------- */ + +#ifndef WGL_EXT_pixel_format_packed_float +#define WGL_EXT_pixel_format_packed_float 1 + +#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 + +#define WGLEW_EXT_pixel_format_packed_float WGLEW_GET_VAR(__WGLEW_EXT_pixel_format_packed_float) + +#endif /* WGL_EXT_pixel_format_packed_float */ + +/* -------------------------- WGL_EXT_swap_control ------------------------- */ + +#ifndef WGL_EXT_swap_control +#define WGL_EXT_swap_control 1 + +typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); +typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); + +#define wglGetSwapIntervalEXT WGLEW_GET_FUN(__wglewGetSwapIntervalEXT) +#define wglSwapIntervalEXT WGLEW_GET_FUN(__wglewSwapIntervalEXT) + +#define WGLEW_EXT_swap_control WGLEW_GET_VAR(__WGLEW_EXT_swap_control) + +#endif /* WGL_EXT_swap_control */ + +/* --------------------- WGL_I3D_digital_video_control --------------------- */ + +#ifndef WGL_I3D_digital_video_control +#define WGL_I3D_digital_video_control 1 + +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 +#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 +#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 + +typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int* piValue); +typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int* piValue); + +#define wglGetDigitalVideoParametersI3D WGLEW_GET_FUN(__wglewGetDigitalVideoParametersI3D) +#define wglSetDigitalVideoParametersI3D WGLEW_GET_FUN(__wglewSetDigitalVideoParametersI3D) + +#define WGLEW_I3D_digital_video_control WGLEW_GET_VAR(__WGLEW_I3D_digital_video_control) + +#endif /* WGL_I3D_digital_video_control */ + +/* ----------------------------- WGL_I3D_gamma ----------------------------- */ + +#ifndef WGL_I3D_gamma +#define WGL_I3D_gamma 1 + +#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E +#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F + +typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT* puRed, USHORT *puGreen, USHORT *puBlue); +typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int* piValue); +typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT* puRed, const USHORT *puGreen, const USHORT *puBlue); +typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int* piValue); + +#define wglGetGammaTableI3D WGLEW_GET_FUN(__wglewGetGammaTableI3D) +#define wglGetGammaTableParametersI3D WGLEW_GET_FUN(__wglewGetGammaTableParametersI3D) +#define wglSetGammaTableI3D WGLEW_GET_FUN(__wglewSetGammaTableI3D) +#define wglSetGammaTableParametersI3D WGLEW_GET_FUN(__wglewSetGammaTableParametersI3D) + +#define WGLEW_I3D_gamma WGLEW_GET_VAR(__WGLEW_I3D_gamma) + +#endif /* WGL_I3D_gamma */ + +/* ---------------------------- WGL_I3D_genlock ---------------------------- */ + +#ifndef WGL_I3D_genlock +#define WGL_I3D_genlock 1 + +#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 +#define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045 +#define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046 +#define WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047 +#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 +#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 +#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A +#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B +#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C + +typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); +typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); +typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT* uRate); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT* uDelay); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT* uEdge); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT* uSource); +typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL* pFlag); +typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT* uMaxLineDelay, UINT *uMaxPixelDelay); + +#define wglDisableGenlockI3D WGLEW_GET_FUN(__wglewDisableGenlockI3D) +#define wglEnableGenlockI3D WGLEW_GET_FUN(__wglewEnableGenlockI3D) +#define wglGenlockSampleRateI3D WGLEW_GET_FUN(__wglewGenlockSampleRateI3D) +#define wglGenlockSourceDelayI3D WGLEW_GET_FUN(__wglewGenlockSourceDelayI3D) +#define wglGenlockSourceEdgeI3D WGLEW_GET_FUN(__wglewGenlockSourceEdgeI3D) +#define wglGenlockSourceI3D WGLEW_GET_FUN(__wglewGenlockSourceI3D) +#define wglGetGenlockSampleRateI3D WGLEW_GET_FUN(__wglewGetGenlockSampleRateI3D) +#define wglGetGenlockSourceDelayI3D WGLEW_GET_FUN(__wglewGetGenlockSourceDelayI3D) +#define wglGetGenlockSourceEdgeI3D WGLEW_GET_FUN(__wglewGetGenlockSourceEdgeI3D) +#define wglGetGenlockSourceI3D WGLEW_GET_FUN(__wglewGetGenlockSourceI3D) +#define wglIsEnabledGenlockI3D WGLEW_GET_FUN(__wglewIsEnabledGenlockI3D) +#define wglQueryGenlockMaxSourceDelayI3D WGLEW_GET_FUN(__wglewQueryGenlockMaxSourceDelayI3D) + +#define WGLEW_I3D_genlock WGLEW_GET_VAR(__WGLEW_I3D_genlock) + +#endif /* WGL_I3D_genlock */ + +/* -------------------------- WGL_I3D_image_buffer ------------------------- */ + +#ifndef WGL_I3D_image_buffer +#define WGL_I3D_image_buffer 1 + +#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 +#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 + +typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hdc, HANDLE* pEvent, LPVOID *pAddress, DWORD *pSize, UINT count); +typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); +typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); +typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hdc, LPVOID* pAddress, UINT count); + +#define wglAssociateImageBufferEventsI3D WGLEW_GET_FUN(__wglewAssociateImageBufferEventsI3D) +#define wglCreateImageBufferI3D WGLEW_GET_FUN(__wglewCreateImageBufferI3D) +#define wglDestroyImageBufferI3D WGLEW_GET_FUN(__wglewDestroyImageBufferI3D) +#define wglReleaseImageBufferEventsI3D WGLEW_GET_FUN(__wglewReleaseImageBufferEventsI3D) + +#define WGLEW_I3D_image_buffer WGLEW_GET_VAR(__WGLEW_I3D_image_buffer) + +#endif /* WGL_I3D_image_buffer */ + +/* ------------------------ WGL_I3D_swap_frame_lock ------------------------ */ + +#ifndef WGL_I3D_swap_frame_lock +#define WGL_I3D_swap_frame_lock 1 + +typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (VOID); +typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (VOID); +typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL* pFlag); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL* pFlag); + +#define wglDisableFrameLockI3D WGLEW_GET_FUN(__wglewDisableFrameLockI3D) +#define wglEnableFrameLockI3D WGLEW_GET_FUN(__wglewEnableFrameLockI3D) +#define wglIsEnabledFrameLockI3D WGLEW_GET_FUN(__wglewIsEnabledFrameLockI3D) +#define wglQueryFrameLockMasterI3D WGLEW_GET_FUN(__wglewQueryFrameLockMasterI3D) + +#define WGLEW_I3D_swap_frame_lock WGLEW_GET_VAR(__WGLEW_I3D_swap_frame_lock) + +#endif /* WGL_I3D_swap_frame_lock */ + +/* ------------------------ WGL_I3D_swap_frame_usage ----------------------- */ + +#ifndef WGL_I3D_swap_frame_usage +#define WGL_I3D_swap_frame_usage 1 + +typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float* pUsage); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD* pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); + +#define wglBeginFrameTrackingI3D WGLEW_GET_FUN(__wglewBeginFrameTrackingI3D) +#define wglEndFrameTrackingI3D WGLEW_GET_FUN(__wglewEndFrameTrackingI3D) +#define wglGetFrameUsageI3D WGLEW_GET_FUN(__wglewGetFrameUsageI3D) +#define wglQueryFrameTrackingI3D WGLEW_GET_FUN(__wglewQueryFrameTrackingI3D) + +#define WGLEW_I3D_swap_frame_usage WGLEW_GET_VAR(__WGLEW_I3D_swap_frame_usage) + +#endif /* WGL_I3D_swap_frame_usage */ + +/* --------------------------- WGL_NV_DX_interop --------------------------- */ + +#ifndef WGL_NV_DX_interop +#define WGL_NV_DX_interop 1 + +#define WGL_ACCESS_READ_ONLY_NV 0x0000 +#define WGL_ACCESS_READ_WRITE_NV 0x0001 +#define WGL_ACCESS_WRITE_DISCARD_NV 0x0002 + +typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice); +typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects); +typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access); +typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void* dxDevice); +typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void* dxObject, GLuint name, GLenum type, GLenum access); +typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void* dxObject, HANDLE shareHandle); +typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects); +typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject); + +#define wglDXCloseDeviceNV WGLEW_GET_FUN(__wglewDXCloseDeviceNV) +#define wglDXLockObjectsNV WGLEW_GET_FUN(__wglewDXLockObjectsNV) +#define wglDXObjectAccessNV WGLEW_GET_FUN(__wglewDXObjectAccessNV) +#define wglDXOpenDeviceNV WGLEW_GET_FUN(__wglewDXOpenDeviceNV) +#define wglDXRegisterObjectNV WGLEW_GET_FUN(__wglewDXRegisterObjectNV) +#define wglDXSetResourceShareHandleNV WGLEW_GET_FUN(__wglewDXSetResourceShareHandleNV) +#define wglDXUnlockObjectsNV WGLEW_GET_FUN(__wglewDXUnlockObjectsNV) +#define wglDXUnregisterObjectNV WGLEW_GET_FUN(__wglewDXUnregisterObjectNV) + +#define WGLEW_NV_DX_interop WGLEW_GET_VAR(__WGLEW_NV_DX_interop) + +#endif /* WGL_NV_DX_interop */ + +/* --------------------------- WGL_NV_copy_image --------------------------- */ + +#ifndef WGL_NV_copy_image +#define WGL_NV_copy_image 1 + +typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); + +#define wglCopyImageSubDataNV WGLEW_GET_FUN(__wglewCopyImageSubDataNV) + +#define WGLEW_NV_copy_image WGLEW_GET_VAR(__WGLEW_NV_copy_image) + +#endif /* WGL_NV_copy_image */ + +/* -------------------------- WGL_NV_float_buffer -------------------------- */ + +#ifndef WGL_NV_float_buffer +#define WGL_NV_float_buffer 1 + +#define WGL_FLOAT_COMPONENTS_NV 0x20B0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 +#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 +#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 +#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 +#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 + +#define WGLEW_NV_float_buffer WGLEW_GET_VAR(__WGLEW_NV_float_buffer) + +#endif /* WGL_NV_float_buffer */ + +/* -------------------------- WGL_NV_gpu_affinity -------------------------- */ + +#ifndef WGL_NV_gpu_affinity +#define WGL_NV_gpu_affinity 1 + +#define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 +#define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 + +DECLARE_HANDLE(HGPUNV); +typedef struct _GPU_DEVICE { + DWORD cb; + CHAR DeviceName[32]; + CHAR DeviceString[128]; + DWORD Flags; + RECT rcVirtualScreen; +} GPU_DEVICE, *PGPU_DEVICE; + +typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); +typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); +typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); +typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); +typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); + +#define wglCreateAffinityDCNV WGLEW_GET_FUN(__wglewCreateAffinityDCNV) +#define wglDeleteDCNV WGLEW_GET_FUN(__wglewDeleteDCNV) +#define wglEnumGpuDevicesNV WGLEW_GET_FUN(__wglewEnumGpuDevicesNV) +#define wglEnumGpusFromAffinityDCNV WGLEW_GET_FUN(__wglewEnumGpusFromAffinityDCNV) +#define wglEnumGpusNV WGLEW_GET_FUN(__wglewEnumGpusNV) + +#define WGLEW_NV_gpu_affinity WGLEW_GET_VAR(__WGLEW_NV_gpu_affinity) + +#endif /* WGL_NV_gpu_affinity */ + +/* ---------------------- WGL_NV_multisample_coverage ---------------------- */ + +#ifndef WGL_NV_multisample_coverage +#define WGL_NV_multisample_coverage 1 + +#define WGL_COVERAGE_SAMPLES_NV 0x2042 +#define WGL_COLOR_SAMPLES_NV 0x20B9 + +#define WGLEW_NV_multisample_coverage WGLEW_GET_VAR(__WGLEW_NV_multisample_coverage) + +#endif /* WGL_NV_multisample_coverage */ + +/* -------------------------- WGL_NV_present_video ------------------------- */ + +#ifndef WGL_NV_present_video +#define WGL_NV_present_video 1 + +#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 + +DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); + +typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int* piAttribList); +typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDc, HVIDEOOUTPUTDEVICENV* phDeviceList); +typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int* piValue); + +#define wglBindVideoDeviceNV WGLEW_GET_FUN(__wglewBindVideoDeviceNV) +#define wglEnumerateVideoDevicesNV WGLEW_GET_FUN(__wglewEnumerateVideoDevicesNV) +#define wglQueryCurrentContextNV WGLEW_GET_FUN(__wglewQueryCurrentContextNV) + +#define WGLEW_NV_present_video WGLEW_GET_VAR(__WGLEW_NV_present_video) + +#endif /* WGL_NV_present_video */ + +/* ---------------------- WGL_NV_render_depth_texture ---------------------- */ + +#ifndef WGL_NV_render_depth_texture +#define WGL_NV_render_depth_texture 1 + +#define WGL_NO_TEXTURE_ARB 0x2077 +#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 +#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 +#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 +#define WGL_DEPTH_COMPONENT_NV 0x20A7 + +#define WGLEW_NV_render_depth_texture WGLEW_GET_VAR(__WGLEW_NV_render_depth_texture) + +#endif /* WGL_NV_render_depth_texture */ + +/* -------------------- WGL_NV_render_texture_rectangle -------------------- */ + +#ifndef WGL_NV_render_texture_rectangle +#define WGL_NV_render_texture_rectangle 1 + +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 +#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 + +#define WGLEW_NV_render_texture_rectangle WGLEW_GET_VAR(__WGLEW_NV_render_texture_rectangle) + +#endif /* WGL_NV_render_texture_rectangle */ + +/* --------------------------- WGL_NV_swap_group --------------------------- */ + +#ifndef WGL_NV_swap_group +#define WGL_NV_swap_group 1 + +typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); +typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint* count); +typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint* maxGroups, GLuint *maxBarriers); +typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint* group, GLuint *barrier); +typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); + +#define wglBindSwapBarrierNV WGLEW_GET_FUN(__wglewBindSwapBarrierNV) +#define wglJoinSwapGroupNV WGLEW_GET_FUN(__wglewJoinSwapGroupNV) +#define wglQueryFrameCountNV WGLEW_GET_FUN(__wglewQueryFrameCountNV) +#define wglQueryMaxSwapGroupsNV WGLEW_GET_FUN(__wglewQueryMaxSwapGroupsNV) +#define wglQuerySwapGroupNV WGLEW_GET_FUN(__wglewQuerySwapGroupNV) +#define wglResetFrameCountNV WGLEW_GET_FUN(__wglewResetFrameCountNV) + +#define WGLEW_NV_swap_group WGLEW_GET_VAR(__WGLEW_NV_swap_group) + +#endif /* WGL_NV_swap_group */ + +/* ----------------------- WGL_NV_vertex_array_range ----------------------- */ + +#ifndef WGL_NV_vertex_array_range +#define WGL_NV_vertex_array_range 1 + +typedef void * (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readFrequency, GLfloat writeFrequency, GLfloat priority); +typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); + +#define wglAllocateMemoryNV WGLEW_GET_FUN(__wglewAllocateMemoryNV) +#define wglFreeMemoryNV WGLEW_GET_FUN(__wglewFreeMemoryNV) + +#define WGLEW_NV_vertex_array_range WGLEW_GET_VAR(__WGLEW_NV_vertex_array_range) + +#endif /* WGL_NV_vertex_array_range */ + +/* -------------------------- WGL_NV_video_capture ------------------------- */ + +#ifndef WGL_NV_video_capture +#define WGL_NV_video_capture 1 + +#define WGL_UNIQUE_ID_NV 0x20CE +#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF + +DECLARE_HANDLE(HVIDEOINPUTDEVICENV); + +typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); +typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV* phDeviceList); +typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int* piValue); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); + +#define wglBindVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewBindVideoCaptureDeviceNV) +#define wglEnumerateVideoCaptureDevicesNV WGLEW_GET_FUN(__wglewEnumerateVideoCaptureDevicesNV) +#define wglLockVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewLockVideoCaptureDeviceNV) +#define wglQueryVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewQueryVideoCaptureDeviceNV) +#define wglReleaseVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewReleaseVideoCaptureDeviceNV) + +#define WGLEW_NV_video_capture WGLEW_GET_VAR(__WGLEW_NV_video_capture) + +#endif /* WGL_NV_video_capture */ + +/* -------------------------- WGL_NV_video_output -------------------------- */ + +#ifndef WGL_NV_video_output +#define WGL_NV_video_output 1 + +#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 +#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 +#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 +#define WGL_VIDEO_OUT_COLOR_NV 0x20C3 +#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 +#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 +#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 +#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 +#define WGL_VIDEO_OUT_FRAME 0x20C8 +#define WGL_VIDEO_OUT_FIELD_1 0x20C9 +#define WGL_VIDEO_OUT_FIELD_2 0x20CA +#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB +#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC + +DECLARE_HANDLE(HPVIDEODEV); + +typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); +typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV* hVideoDevice); +typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long* pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); +typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long* pulCounterPbuffer, BOOL bBlock); + +#define wglBindVideoImageNV WGLEW_GET_FUN(__wglewBindVideoImageNV) +#define wglGetVideoDeviceNV WGLEW_GET_FUN(__wglewGetVideoDeviceNV) +#define wglGetVideoInfoNV WGLEW_GET_FUN(__wglewGetVideoInfoNV) +#define wglReleaseVideoDeviceNV WGLEW_GET_FUN(__wglewReleaseVideoDeviceNV) +#define wglReleaseVideoImageNV WGLEW_GET_FUN(__wglewReleaseVideoImageNV) +#define wglSendPbufferToVideoNV WGLEW_GET_FUN(__wglewSendPbufferToVideoNV) + +#define WGLEW_NV_video_output WGLEW_GET_VAR(__WGLEW_NV_video_output) + +#endif /* WGL_NV_video_output */ + +/* -------------------------- WGL_OML_sync_control ------------------------- */ + +#ifndef WGL_OML_sync_control +#define WGL_OML_sync_control 1 + +typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32* numerator, INT32 *denominator); +typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64* ust, INT64 *msc, INT64 *sbc); +typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, INT fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64* ust, INT64 *msc, INT64 *sbc); +typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64* ust, INT64 *msc, INT64 *sbc); + +#define wglGetMscRateOML WGLEW_GET_FUN(__wglewGetMscRateOML) +#define wglGetSyncValuesOML WGLEW_GET_FUN(__wglewGetSyncValuesOML) +#define wglSwapBuffersMscOML WGLEW_GET_FUN(__wglewSwapBuffersMscOML) +#define wglSwapLayerBuffersMscOML WGLEW_GET_FUN(__wglewSwapLayerBuffersMscOML) +#define wglWaitForMscOML WGLEW_GET_FUN(__wglewWaitForMscOML) +#define wglWaitForSbcOML WGLEW_GET_FUN(__wglewWaitForSbcOML) + +#define WGLEW_OML_sync_control WGLEW_GET_VAR(__WGLEW_OML_sync_control) + +#endif /* WGL_OML_sync_control */ + +/* ------------------------------------------------------------------------- */ + +#ifdef GLEW_MX +#define WGLEW_EXPORT +#else +#define WGLEW_EXPORT GLEWAPI +#endif /* GLEW_MX */ + +#ifdef GLEW_MX +struct WGLEWContextStruct +{ +#endif /* GLEW_MX */ + +WGLEW_EXPORT PFNWGLSETSTEREOEMITTERSTATE3DLPROC __wglewSetStereoEmitterState3DL; + +WGLEW_EXPORT PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC __wglewBlitContextFramebufferAMD; +WGLEW_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC __wglewCreateAssociatedContextAMD; +WGLEW_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC __wglewCreateAssociatedContextAttribsAMD; +WGLEW_EXPORT PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC __wglewDeleteAssociatedContextAMD; +WGLEW_EXPORT PFNWGLGETCONTEXTGPUIDAMDPROC __wglewGetContextGPUIDAMD; +WGLEW_EXPORT PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC __wglewGetCurrentAssociatedContextAMD; +WGLEW_EXPORT PFNWGLGETGPUIDSAMDPROC __wglewGetGPUIDsAMD; +WGLEW_EXPORT PFNWGLGETGPUINFOAMDPROC __wglewGetGPUInfoAMD; +WGLEW_EXPORT PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC __wglewMakeAssociatedContextCurrentAMD; + +WGLEW_EXPORT PFNWGLCREATEBUFFERREGIONARBPROC __wglewCreateBufferRegionARB; +WGLEW_EXPORT PFNWGLDELETEBUFFERREGIONARBPROC __wglewDeleteBufferRegionARB; +WGLEW_EXPORT PFNWGLRESTOREBUFFERREGIONARBPROC __wglewRestoreBufferRegionARB; +WGLEW_EXPORT PFNWGLSAVEBUFFERREGIONARBPROC __wglewSaveBufferRegionARB; + +WGLEW_EXPORT PFNWGLCREATECONTEXTATTRIBSARBPROC __wglewCreateContextAttribsARB; + +WGLEW_EXPORT PFNWGLGETEXTENSIONSSTRINGARBPROC __wglewGetExtensionsStringARB; + +WGLEW_EXPORT PFNWGLGETCURRENTREADDCARBPROC __wglewGetCurrentReadDCARB; +WGLEW_EXPORT PFNWGLMAKECONTEXTCURRENTARBPROC __wglewMakeContextCurrentARB; + +WGLEW_EXPORT PFNWGLCREATEPBUFFERARBPROC __wglewCreatePbufferARB; +WGLEW_EXPORT PFNWGLDESTROYPBUFFERARBPROC __wglewDestroyPbufferARB; +WGLEW_EXPORT PFNWGLGETPBUFFERDCARBPROC __wglewGetPbufferDCARB; +WGLEW_EXPORT PFNWGLQUERYPBUFFERARBPROC __wglewQueryPbufferARB; +WGLEW_EXPORT PFNWGLRELEASEPBUFFERDCARBPROC __wglewReleasePbufferDCARB; + +WGLEW_EXPORT PFNWGLCHOOSEPIXELFORMATARBPROC __wglewChoosePixelFormatARB; +WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBFVARBPROC __wglewGetPixelFormatAttribfvARB; +WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBIVARBPROC __wglewGetPixelFormatAttribivARB; + +WGLEW_EXPORT PFNWGLBINDTEXIMAGEARBPROC __wglewBindTexImageARB; +WGLEW_EXPORT PFNWGLRELEASETEXIMAGEARBPROC __wglewReleaseTexImageARB; +WGLEW_EXPORT PFNWGLSETPBUFFERATTRIBARBPROC __wglewSetPbufferAttribARB; + +WGLEW_EXPORT PFNWGLBINDDISPLAYCOLORTABLEEXTPROC __wglewBindDisplayColorTableEXT; +WGLEW_EXPORT PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC __wglewCreateDisplayColorTableEXT; +WGLEW_EXPORT PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC __wglewDestroyDisplayColorTableEXT; +WGLEW_EXPORT PFNWGLLOADDISPLAYCOLORTABLEEXTPROC __wglewLoadDisplayColorTableEXT; + +WGLEW_EXPORT PFNWGLGETEXTENSIONSSTRINGEXTPROC __wglewGetExtensionsStringEXT; + +WGLEW_EXPORT PFNWGLGETCURRENTREADDCEXTPROC __wglewGetCurrentReadDCEXT; +WGLEW_EXPORT PFNWGLMAKECONTEXTCURRENTEXTPROC __wglewMakeContextCurrentEXT; + +WGLEW_EXPORT PFNWGLCREATEPBUFFEREXTPROC __wglewCreatePbufferEXT; +WGLEW_EXPORT PFNWGLDESTROYPBUFFEREXTPROC __wglewDestroyPbufferEXT; +WGLEW_EXPORT PFNWGLGETPBUFFERDCEXTPROC __wglewGetPbufferDCEXT; +WGLEW_EXPORT PFNWGLQUERYPBUFFEREXTPROC __wglewQueryPbufferEXT; +WGLEW_EXPORT PFNWGLRELEASEPBUFFERDCEXTPROC __wglewReleasePbufferDCEXT; + +WGLEW_EXPORT PFNWGLCHOOSEPIXELFORMATEXTPROC __wglewChoosePixelFormatEXT; +WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBFVEXTPROC __wglewGetPixelFormatAttribfvEXT; +WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBIVEXTPROC __wglewGetPixelFormatAttribivEXT; + +WGLEW_EXPORT PFNWGLGETSWAPINTERVALEXTPROC __wglewGetSwapIntervalEXT; +WGLEW_EXPORT PFNWGLSWAPINTERVALEXTPROC __wglewSwapIntervalEXT; + +WGLEW_EXPORT PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC __wglewGetDigitalVideoParametersI3D; +WGLEW_EXPORT PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC __wglewSetDigitalVideoParametersI3D; + +WGLEW_EXPORT PFNWGLGETGAMMATABLEI3DPROC __wglewGetGammaTableI3D; +WGLEW_EXPORT PFNWGLGETGAMMATABLEPARAMETERSI3DPROC __wglewGetGammaTableParametersI3D; +WGLEW_EXPORT PFNWGLSETGAMMATABLEI3DPROC __wglewSetGammaTableI3D; +WGLEW_EXPORT PFNWGLSETGAMMATABLEPARAMETERSI3DPROC __wglewSetGammaTableParametersI3D; + +WGLEW_EXPORT PFNWGLDISABLEGENLOCKI3DPROC __wglewDisableGenlockI3D; +WGLEW_EXPORT PFNWGLENABLEGENLOCKI3DPROC __wglewEnableGenlockI3D; +WGLEW_EXPORT PFNWGLGENLOCKSAMPLERATEI3DPROC __wglewGenlockSampleRateI3D; +WGLEW_EXPORT PFNWGLGENLOCKSOURCEDELAYI3DPROC __wglewGenlockSourceDelayI3D; +WGLEW_EXPORT PFNWGLGENLOCKSOURCEEDGEI3DPROC __wglewGenlockSourceEdgeI3D; +WGLEW_EXPORT PFNWGLGENLOCKSOURCEI3DPROC __wglewGenlockSourceI3D; +WGLEW_EXPORT PFNWGLGETGENLOCKSAMPLERATEI3DPROC __wglewGetGenlockSampleRateI3D; +WGLEW_EXPORT PFNWGLGETGENLOCKSOURCEDELAYI3DPROC __wglewGetGenlockSourceDelayI3D; +WGLEW_EXPORT PFNWGLGETGENLOCKSOURCEEDGEI3DPROC __wglewGetGenlockSourceEdgeI3D; +WGLEW_EXPORT PFNWGLGETGENLOCKSOURCEI3DPROC __wglewGetGenlockSourceI3D; +WGLEW_EXPORT PFNWGLISENABLEDGENLOCKI3DPROC __wglewIsEnabledGenlockI3D; +WGLEW_EXPORT PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC __wglewQueryGenlockMaxSourceDelayI3D; + +WGLEW_EXPORT PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC __wglewAssociateImageBufferEventsI3D; +WGLEW_EXPORT PFNWGLCREATEIMAGEBUFFERI3DPROC __wglewCreateImageBufferI3D; +WGLEW_EXPORT PFNWGLDESTROYIMAGEBUFFERI3DPROC __wglewDestroyImageBufferI3D; +WGLEW_EXPORT PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC __wglewReleaseImageBufferEventsI3D; + +WGLEW_EXPORT PFNWGLDISABLEFRAMELOCKI3DPROC __wglewDisableFrameLockI3D; +WGLEW_EXPORT PFNWGLENABLEFRAMELOCKI3DPROC __wglewEnableFrameLockI3D; +WGLEW_EXPORT PFNWGLISENABLEDFRAMELOCKI3DPROC __wglewIsEnabledFrameLockI3D; +WGLEW_EXPORT PFNWGLQUERYFRAMELOCKMASTERI3DPROC __wglewQueryFrameLockMasterI3D; + +WGLEW_EXPORT PFNWGLBEGINFRAMETRACKINGI3DPROC __wglewBeginFrameTrackingI3D; +WGLEW_EXPORT PFNWGLENDFRAMETRACKINGI3DPROC __wglewEndFrameTrackingI3D; +WGLEW_EXPORT PFNWGLGETFRAMEUSAGEI3DPROC __wglewGetFrameUsageI3D; +WGLEW_EXPORT PFNWGLQUERYFRAMETRACKINGI3DPROC __wglewQueryFrameTrackingI3D; + +WGLEW_EXPORT PFNWGLDXCLOSEDEVICENVPROC __wglewDXCloseDeviceNV; +WGLEW_EXPORT PFNWGLDXLOCKOBJECTSNVPROC __wglewDXLockObjectsNV; +WGLEW_EXPORT PFNWGLDXOBJECTACCESSNVPROC __wglewDXObjectAccessNV; +WGLEW_EXPORT PFNWGLDXOPENDEVICENVPROC __wglewDXOpenDeviceNV; +WGLEW_EXPORT PFNWGLDXREGISTEROBJECTNVPROC __wglewDXRegisterObjectNV; +WGLEW_EXPORT PFNWGLDXSETRESOURCESHAREHANDLENVPROC __wglewDXSetResourceShareHandleNV; +WGLEW_EXPORT PFNWGLDXUNLOCKOBJECTSNVPROC __wglewDXUnlockObjectsNV; +WGLEW_EXPORT PFNWGLDXUNREGISTEROBJECTNVPROC __wglewDXUnregisterObjectNV; + +WGLEW_EXPORT PFNWGLCOPYIMAGESUBDATANVPROC __wglewCopyImageSubDataNV; + +WGLEW_EXPORT PFNWGLCREATEAFFINITYDCNVPROC __wglewCreateAffinityDCNV; +WGLEW_EXPORT PFNWGLDELETEDCNVPROC __wglewDeleteDCNV; +WGLEW_EXPORT PFNWGLENUMGPUDEVICESNVPROC __wglewEnumGpuDevicesNV; +WGLEW_EXPORT PFNWGLENUMGPUSFROMAFFINITYDCNVPROC __wglewEnumGpusFromAffinityDCNV; +WGLEW_EXPORT PFNWGLENUMGPUSNVPROC __wglewEnumGpusNV; + +WGLEW_EXPORT PFNWGLBINDVIDEODEVICENVPROC __wglewBindVideoDeviceNV; +WGLEW_EXPORT PFNWGLENUMERATEVIDEODEVICESNVPROC __wglewEnumerateVideoDevicesNV; +WGLEW_EXPORT PFNWGLQUERYCURRENTCONTEXTNVPROC __wglewQueryCurrentContextNV; + +WGLEW_EXPORT PFNWGLBINDSWAPBARRIERNVPROC __wglewBindSwapBarrierNV; +WGLEW_EXPORT PFNWGLJOINSWAPGROUPNVPROC __wglewJoinSwapGroupNV; +WGLEW_EXPORT PFNWGLQUERYFRAMECOUNTNVPROC __wglewQueryFrameCountNV; +WGLEW_EXPORT PFNWGLQUERYMAXSWAPGROUPSNVPROC __wglewQueryMaxSwapGroupsNV; +WGLEW_EXPORT PFNWGLQUERYSWAPGROUPNVPROC __wglewQuerySwapGroupNV; +WGLEW_EXPORT PFNWGLRESETFRAMECOUNTNVPROC __wglewResetFrameCountNV; + +WGLEW_EXPORT PFNWGLALLOCATEMEMORYNVPROC __wglewAllocateMemoryNV; +WGLEW_EXPORT PFNWGLFREEMEMORYNVPROC __wglewFreeMemoryNV; + +WGLEW_EXPORT PFNWGLBINDVIDEOCAPTUREDEVICENVPROC __wglewBindVideoCaptureDeviceNV; +WGLEW_EXPORT PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC __wglewEnumerateVideoCaptureDevicesNV; +WGLEW_EXPORT PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC __wglewLockVideoCaptureDeviceNV; +WGLEW_EXPORT PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC __wglewQueryVideoCaptureDeviceNV; +WGLEW_EXPORT PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC __wglewReleaseVideoCaptureDeviceNV; + +WGLEW_EXPORT PFNWGLBINDVIDEOIMAGENVPROC __wglewBindVideoImageNV; +WGLEW_EXPORT PFNWGLGETVIDEODEVICENVPROC __wglewGetVideoDeviceNV; +WGLEW_EXPORT PFNWGLGETVIDEOINFONVPROC __wglewGetVideoInfoNV; +WGLEW_EXPORT PFNWGLRELEASEVIDEODEVICENVPROC __wglewReleaseVideoDeviceNV; +WGLEW_EXPORT PFNWGLRELEASEVIDEOIMAGENVPROC __wglewReleaseVideoImageNV; +WGLEW_EXPORT PFNWGLSENDPBUFFERTOVIDEONVPROC __wglewSendPbufferToVideoNV; + +WGLEW_EXPORT PFNWGLGETMSCRATEOMLPROC __wglewGetMscRateOML; +WGLEW_EXPORT PFNWGLGETSYNCVALUESOMLPROC __wglewGetSyncValuesOML; +WGLEW_EXPORT PFNWGLSWAPBUFFERSMSCOMLPROC __wglewSwapBuffersMscOML; +WGLEW_EXPORT PFNWGLSWAPLAYERBUFFERSMSCOMLPROC __wglewSwapLayerBuffersMscOML; +WGLEW_EXPORT PFNWGLWAITFORMSCOMLPROC __wglewWaitForMscOML; +WGLEW_EXPORT PFNWGLWAITFORSBCOMLPROC __wglewWaitForSbcOML; +WGLEW_EXPORT GLboolean __WGLEW_3DFX_multisample; +WGLEW_EXPORT GLboolean __WGLEW_3DL_stereo_control; +WGLEW_EXPORT GLboolean __WGLEW_AMD_gpu_association; +WGLEW_EXPORT GLboolean __WGLEW_ARB_buffer_region; +WGLEW_EXPORT GLboolean __WGLEW_ARB_create_context; +WGLEW_EXPORT GLboolean __WGLEW_ARB_create_context_profile; +WGLEW_EXPORT GLboolean __WGLEW_ARB_create_context_robustness; +WGLEW_EXPORT GLboolean __WGLEW_ARB_extensions_string; +WGLEW_EXPORT GLboolean __WGLEW_ARB_framebuffer_sRGB; +WGLEW_EXPORT GLboolean __WGLEW_ARB_make_current_read; +WGLEW_EXPORT GLboolean __WGLEW_ARB_multisample; +WGLEW_EXPORT GLboolean __WGLEW_ARB_pbuffer; +WGLEW_EXPORT GLboolean __WGLEW_ARB_pixel_format; +WGLEW_EXPORT GLboolean __WGLEW_ARB_pixel_format_float; +WGLEW_EXPORT GLboolean __WGLEW_ARB_render_texture; +WGLEW_EXPORT GLboolean __WGLEW_ATI_pixel_format_float; +WGLEW_EXPORT GLboolean __WGLEW_ATI_render_texture_rectangle; +WGLEW_EXPORT GLboolean __WGLEW_EXT_create_context_es2_profile; +WGLEW_EXPORT GLboolean __WGLEW_EXT_depth_float; +WGLEW_EXPORT GLboolean __WGLEW_EXT_display_color_table; +WGLEW_EXPORT GLboolean __WGLEW_EXT_extensions_string; +WGLEW_EXPORT GLboolean __WGLEW_EXT_framebuffer_sRGB; +WGLEW_EXPORT GLboolean __WGLEW_EXT_make_current_read; +WGLEW_EXPORT GLboolean __WGLEW_EXT_multisample; +WGLEW_EXPORT GLboolean __WGLEW_EXT_pbuffer; +WGLEW_EXPORT GLboolean __WGLEW_EXT_pixel_format; +WGLEW_EXPORT GLboolean __WGLEW_EXT_pixel_format_packed_float; +WGLEW_EXPORT GLboolean __WGLEW_EXT_swap_control; +WGLEW_EXPORT GLboolean __WGLEW_I3D_digital_video_control; +WGLEW_EXPORT GLboolean __WGLEW_I3D_gamma; +WGLEW_EXPORT GLboolean __WGLEW_I3D_genlock; +WGLEW_EXPORT GLboolean __WGLEW_I3D_image_buffer; +WGLEW_EXPORT GLboolean __WGLEW_I3D_swap_frame_lock; +WGLEW_EXPORT GLboolean __WGLEW_I3D_swap_frame_usage; +WGLEW_EXPORT GLboolean __WGLEW_NV_DX_interop; +WGLEW_EXPORT GLboolean __WGLEW_NV_copy_image; +WGLEW_EXPORT GLboolean __WGLEW_NV_float_buffer; +WGLEW_EXPORT GLboolean __WGLEW_NV_gpu_affinity; +WGLEW_EXPORT GLboolean __WGLEW_NV_multisample_coverage; +WGLEW_EXPORT GLboolean __WGLEW_NV_present_video; +WGLEW_EXPORT GLboolean __WGLEW_NV_render_depth_texture; +WGLEW_EXPORT GLboolean __WGLEW_NV_render_texture_rectangle; +WGLEW_EXPORT GLboolean __WGLEW_NV_swap_group; +WGLEW_EXPORT GLboolean __WGLEW_NV_vertex_array_range; +WGLEW_EXPORT GLboolean __WGLEW_NV_video_capture; +WGLEW_EXPORT GLboolean __WGLEW_NV_video_output; +WGLEW_EXPORT GLboolean __WGLEW_OML_sync_control; + +#ifdef GLEW_MX +}; /* WGLEWContextStruct */ +#endif /* GLEW_MX */ + +/* ------------------------------------------------------------------------- */ + +#ifdef GLEW_MX + +typedef struct WGLEWContextStruct WGLEWContext; +GLEWAPI GLenum wglewContextInit (WGLEWContext* ctx); +GLEWAPI GLboolean wglewContextIsSupported (const WGLEWContext* ctx, const char* name); + +#define wglewInit() wglewContextInit(wglewGetContext()) +#define wglewIsSupported(x) wglewContextIsSupported(wglewGetContext(), x) + +#define WGLEW_GET_VAR(x) (*(const GLboolean*)&(wglewGetContext()->x)) +#define WGLEW_GET_FUN(x) wglewGetContext()->x + +#else /* GLEW_MX */ + +#define WGLEW_GET_VAR(x) (*(const GLboolean*)&x) +#define WGLEW_GET_FUN(x) x + +GLEWAPI GLboolean wglewIsSupported (const char* name); + +#endif /* GLEW_MX */ + +GLEWAPI GLboolean wglewGetExtension (const char* name); + +#ifdef __cplusplus +} +#endif + +#undef GLEWAPI + +#endif /* __wglew_h__ */ diff --git a/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2.h b/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2.h deleted file mode 100644 index 4040ac6a11..0000000000 --- a/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2.h +++ /dev/null @@ -1,619 +0,0 @@ -#ifndef __gl2_h_ -#define __gl2_h_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This document is licensed under the SGI Free Software B License Version - * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . - */ - -/*------------------------------------------------------------------------- - * Data type definitions - *-----------------------------------------------------------------------*/ - -typedef void GLvoid; -typedef char GLchar; -typedef unsigned int GLenum; -typedef unsigned char GLboolean; -typedef unsigned int GLbitfield; -typedef khronos_int8_t GLbyte; -typedef short GLshort; -typedef int GLint; -typedef int GLsizei; -typedef khronos_uint8_t GLubyte; -typedef unsigned short GLushort; -typedef unsigned int GLuint; -typedef khronos_float_t GLfloat; -typedef khronos_float_t GLclampf; -typedef khronos_int32_t GLfixed; - -/* GL types for handling large vertex buffer objects */ -typedef khronos_intptr_t GLintptr; -typedef khronos_ssize_t GLsizeiptr; - -/* OpenGL ES core versions */ -#define GL_ES_VERSION_2_0 1 - -/* ClearBufferMask */ -#define GL_DEPTH_BUFFER_BIT 0x00000100 -#define GL_STENCIL_BUFFER_BIT 0x00000400 -#define GL_COLOR_BUFFER_BIT 0x00004000 - -/* Boolean */ -#define GL_FALSE 0 -#define GL_TRUE 1 - -/* BeginMode */ -#define GL_POINTS 0x0000 -#define GL_LINES 0x0001 -#define GL_LINE_LOOP 0x0002 -#define GL_LINE_STRIP 0x0003 -#define GL_TRIANGLES 0x0004 -#define GL_TRIANGLE_STRIP 0x0005 -#define GL_TRIANGLE_FAN 0x0006 - -/* AlphaFunction (not supported in ES20) */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* BlendingFactorDest */ -#define GL_ZERO 0 -#define GL_ONE 1 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 - -/* BlendingFactorSrc */ -/* GL_ZERO */ -/* GL_ONE */ -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#define GL_SRC_ALPHA_SATURATE 0x0308 -/* GL_SRC_ALPHA */ -/* GL_ONE_MINUS_SRC_ALPHA */ -/* GL_DST_ALPHA */ -/* GL_ONE_MINUS_DST_ALPHA */ - -/* BlendEquationSeparate */ -#define GL_FUNC_ADD 0x8006 -#define GL_BLEND_EQUATION 0x8009 -#define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */ -#define GL_BLEND_EQUATION_ALPHA 0x883D - -/* BlendSubtract */ -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B - -/* Separate Blend Functions */ -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 - -/* Buffer Objects */ -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 - -#define GL_STREAM_DRAW 0x88E0 -#define GL_STATIC_DRAW 0x88E4 -#define GL_DYNAMIC_DRAW 0x88E8 - -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 - -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 - -/* CullFaceMode */ -#define GL_FRONT 0x0404 -#define GL_BACK 0x0405 -#define GL_FRONT_AND_BACK 0x0408 - -/* DepthFunction */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* EnableCap */ -#define GL_TEXTURE_2D 0x0DE1 -#define GL_CULL_FACE 0x0B44 -#define GL_BLEND 0x0BE2 -#define GL_DITHER 0x0BD0 -#define GL_STENCIL_TEST 0x0B90 -#define GL_DEPTH_TEST 0x0B71 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_COVERAGE 0x80A0 - -/* ErrorCode */ -#define GL_NO_ERROR 0 -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_OUT_OF_MEMORY 0x0505 - -/* FrontFaceDirection */ -#define GL_CW 0x0900 -#define GL_CCW 0x0901 - -/* GetPName */ -#define GL_LINE_WIDTH 0x0B21 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#define GL_CULL_FACE_MODE 0x0B45 -#define GL_FRONT_FACE 0x0B46 -#define GL_DEPTH_RANGE 0x0B70 -#define GL_DEPTH_WRITEMASK 0x0B72 -#define GL_DEPTH_CLEAR_VALUE 0x0B73 -#define GL_DEPTH_FUNC 0x0B74 -#define GL_STENCIL_CLEAR_VALUE 0x0B91 -#define GL_STENCIL_FUNC 0x0B92 -#define GL_STENCIL_FAIL 0x0B94 -#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#define GL_STENCIL_REF 0x0B97 -#define GL_STENCIL_VALUE_MASK 0x0B93 -#define GL_STENCIL_WRITEMASK 0x0B98 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#define GL_VIEWPORT 0x0BA2 -#define GL_SCISSOR_BOX 0x0C10 -/* GL_SCISSOR_TEST */ -#define GL_COLOR_CLEAR_VALUE 0x0C22 -#define GL_COLOR_WRITEMASK 0x0C23 -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_ALIGNMENT 0x0D05 -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#define GL_MAX_VIEWPORT_DIMS 0x0D3A -#define GL_SUBPIXEL_BITS 0x0D50 -#define GL_RED_BITS 0x0D52 -#define GL_GREEN_BITS 0x0D53 -#define GL_BLUE_BITS 0x0D54 -#define GL_ALPHA_BITS 0x0D55 -#define GL_DEPTH_BITS 0x0D56 -#define GL_STENCIL_BITS 0x0D57 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -/* GL_POLYGON_OFFSET_FILL */ -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_TEXTURE_BINDING_2D 0x8069 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB - -/* GetTextureParameter */ -/* GL_TEXTURE_MAG_FILTER */ -/* GL_TEXTURE_MIN_FILTER */ -/* GL_TEXTURE_WRAP_S */ -/* GL_TEXTURE_WRAP_T */ - -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 - -/* HintMode */ -#define GL_DONT_CARE 0x1100 -#define GL_FASTEST 0x1101 -#define GL_NICEST 0x1102 - -/* HintTarget */ -#define GL_GENERATE_MIPMAP_HINT 0x8192 - -/* DataType */ -#define GL_BYTE 0x1400 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_SHORT 0x1402 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_INT 0x1404 -#define GL_UNSIGNED_INT 0x1405 -#define GL_FLOAT 0x1406 -#define GL_FIXED 0x140C - -/* PixelFormat */ -#define GL_DEPTH_COMPONENT 0x1902 -#define GL_ALPHA 0x1906 -#define GL_RGB 0x1907 -#define GL_RGBA 0x1908 -#define GL_LUMINANCE 0x1909 -#define GL_LUMINANCE_ALPHA 0x190A - -/* PixelType */ -/* GL_UNSIGNED_BYTE */ -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 - -/* Shaders */ -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#define GL_SHADER_TYPE 0x8B4F -#define GL_DELETE_STATUS 0x8B80 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D - -/* StencilFunction */ -#define GL_NEVER 0x0200 -#define GL_LESS 0x0201 -#define GL_EQUAL 0x0202 -#define GL_LEQUAL 0x0203 -#define GL_GREATER 0x0204 -#define GL_NOTEQUAL 0x0205 -#define GL_GEQUAL 0x0206 -#define GL_ALWAYS 0x0207 - -/* StencilOp */ -/* GL_ZERO */ -#define GL_KEEP 0x1E00 -#define GL_REPLACE 0x1E01 -#define GL_INCR 0x1E02 -#define GL_DECR 0x1E03 -#define GL_INVERT 0x150A -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 - -/* StringName */ -#define GL_VENDOR 0x1F00 -#define GL_RENDERER 0x1F01 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 - -/* TextureMagFilter */ -#define GL_NEAREST 0x2600 -#define GL_LINEAR 0x2601 - -/* TextureMinFilter */ -/* GL_NEAREST */ -/* GL_LINEAR */ -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 - -/* TextureParameterName */ -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_TEXTURE_WRAP_S 0x2802 -#define GL_TEXTURE_WRAP_T 0x2803 - -/* TextureTarget */ -/* GL_TEXTURE_2D */ -#define GL_TEXTURE 0x1702 - -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C - -/* TextureUnit */ -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 - -/* TextureWrapMode */ -#define GL_REPEAT 0x2901 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_MIRRORED_REPEAT 0x8370 - -/* Uniform Types */ -#define GL_FLOAT_VEC2 0x8B50 -#define GL_FLOAT_VEC3 0x8B51 -#define GL_FLOAT_VEC4 0x8B52 -#define GL_INT_VEC2 0x8B53 -#define GL_INT_VEC3 0x8B54 -#define GL_INT_VEC4 0x8B55 -#define GL_BOOL 0x8B56 -#define GL_BOOL_VEC2 0x8B57 -#define GL_BOOL_VEC3 0x8B58 -#define GL_BOOL_VEC4 0x8B59 -#define GL_FLOAT_MAT2 0x8B5A -#define GL_FLOAT_MAT3 0x8B5B -#define GL_FLOAT_MAT4 0x8B5C -#define GL_SAMPLER_2D 0x8B5E -#define GL_SAMPLER_CUBE 0x8B60 - -/* Vertex Arrays */ -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F - -/* Read Format */ -#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B - -/* Shader Source */ -#define GL_COMPILE_STATUS 0x8B81 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_SHADER_COMPILER 0x8DFA - -/* Shader Binary */ -#define GL_SHADER_BINARY_FORMATS 0x8DF8 -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 - -/* Shader Precision-Specified Types */ -#define GL_LOW_FLOAT 0x8DF0 -#define GL_MEDIUM_FLOAT 0x8DF1 -#define GL_HIGH_FLOAT 0x8DF2 -#define GL_LOW_INT 0x8DF3 -#define GL_MEDIUM_INT 0x8DF4 -#define GL_HIGH_INT 0x8DF5 - -/* Framebuffer Object. */ -#define GL_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 - -#define GL_RGBA4 0x8056 -#define GL_RGB5_A1 0x8057 -#define GL_RGB565 0x8D62 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_STENCIL_INDEX 0x1901 -#define GL_STENCIL_INDEX8 0x8D48 - -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#define GL_RENDERBUFFER_RED_SIZE 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 - -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 - -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 - -#define GL_NONE 0 - -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD - -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 - -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 - -/*------------------------------------------------------------------------- - * GL core functions. - *-----------------------------------------------------------------------*/ - -GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture); -GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader); -GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar* name); -GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer); -GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); -GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); -GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture); -GL_APICALL void GL_APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -GL_APICALL void GL_APIENTRY glBlendEquation ( GLenum mode ); -GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); -GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); -GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); -GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); -GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target); -GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); -GL_APICALL void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -GL_APICALL void GL_APIENTRY glClearDepthf (GLclampf depth); -GL_APICALL void GL_APIENTRY glClearStencil (GLint s); -GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader); -GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data); -GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data); -GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GL_APICALL GLuint GL_APIENTRY glCreateProgram (void); -GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type); -GL_APICALL void GL_APIENTRY glCullFace (GLenum mode); -GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers); -GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers); -GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program); -GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers); -GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader); -GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures); -GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func); -GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag); -GL_APICALL void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar); -GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader); -GL_APICALL void GL_APIENTRY glDisable (GLenum cap); -GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index); -GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); -GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices); -GL_APICALL void GL_APIENTRY glEnable (GLenum cap); -GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index); -GL_APICALL void GL_APIENTRY glFinish (void); -GL_APICALL void GL_APIENTRY glFlush (void); -GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode); -GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers); -GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target); -GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers); -GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers); -GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures); -GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); -GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); -GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); -GL_APICALL int GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name); -GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params); -GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params); -GL_APICALL GLenum GL_APIENTRY glGetError (void); -GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params); -GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog); -GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog); -GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); -GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source); -GL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenum name); -GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params); -GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params); -GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params); -GL_APICALL int GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name); -GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params); -GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer); -GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode); -GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer); -GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap); -GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer); -GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program); -GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer); -GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader); -GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture); -GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); -GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program); -GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param); -GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); -GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); -GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); -GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -GL_APICALL void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert); -GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); -GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length); -GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar** string, const GLint* length); -GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); -GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); -GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask); -GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); -GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); -GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass); -GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels); -GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); -GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params); -GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); -GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint* params); -GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels); -GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat x); -GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v); -GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint x); -GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* v); -GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat x, GLfloat y); -GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat* v); -GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint x, GLint y); -GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint* v); -GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z); -GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat* v); -GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint x, GLint y, GLint z); -GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint* v); -GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* v); -GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w); -GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* v); -GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -GL_APICALL void GL_APIENTRY glUseProgram (GLuint program); -GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program); -GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x); -GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values); -GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y); -GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint indx, const GLfloat* values); -GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z); -GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint indx, const GLfloat* values); -GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint indx, const GLfloat* values); -GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr); -GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); - -#ifdef __cplusplus -} -#endif - -#endif /* __gl2_h_ */ diff --git a/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2ext.h b/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2ext.h deleted file mode 100644 index 9eeddcfc97..0000000000 --- a/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2ext.h +++ /dev/null @@ -1,971 +0,0 @@ -#ifndef __gl2ext_h_ -#define __gl2ext_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This document is licensed under the SGI Free Software B License Version - * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . - */ - -#ifndef GL_APIENTRYP -# define GL_APIENTRYP GL_APIENTRY* -#endif - -/*------------------------------------------------------------------------* - * OES extension tokens - *------------------------------------------------------------------------*/ - -/* GL_OES_compressed_ETC1_RGB8_texture */ -#ifndef GL_OES_compressed_ETC1_RGB8_texture -#define GL_ETC1_RGB8_OES 0x8D64 -#endif - -/* GL_OES_compressed_paletted_texture */ -#ifndef GL_OES_compressed_paletted_texture -#define GL_PALETTE4_RGB8_OES 0x8B90 -#define GL_PALETTE4_RGBA8_OES 0x8B91 -#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 -#define GL_PALETTE4_RGBA4_OES 0x8B93 -#define GL_PALETTE4_RGB5_A1_OES 0x8B94 -#define GL_PALETTE8_RGB8_OES 0x8B95 -#define GL_PALETTE8_RGBA8_OES 0x8B96 -#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 -#define GL_PALETTE8_RGBA4_OES 0x8B98 -#define GL_PALETTE8_RGB5_A1_OES 0x8B99 -#endif - -/* GL_OES_depth24 */ -#ifndef GL_OES_depth24 -#define GL_DEPTH_COMPONENT24_OES 0x81A6 -#endif - -/* GL_OES_depth32 */ -#ifndef GL_OES_depth32 -#define GL_DEPTH_COMPONENT32_OES 0x81A7 -#endif - -/* GL_OES_depth_texture */ -/* No new tokens introduced by this extension. */ - -/* GL_OES_EGL_image */ -#ifndef GL_OES_EGL_image -typedef void* GLeglImageOES; -#endif - -/* GL_OES_EGL_image_external */ -#ifndef GL_OES_EGL_image_external -/* GLeglImageOES defined in GL_OES_EGL_image already. */ -#define GL_TEXTURE_EXTERNAL_OES 0x8D65 -#define GL_SAMPLER_EXTERNAL_OES 0x8D66 -#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67 -#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68 -#endif - -/* GL_OES_element_index_uint */ -#ifndef GL_OES_element_index_uint -#define GL_UNSIGNED_INT 0x1405 -#endif - -/* GL_OES_get_program_binary */ -#ifndef GL_OES_get_program_binary -#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 -#define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE -#define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF -#endif - -/* GL_OES_mapbuffer */ -#ifndef GL_OES_mapbuffer -#define GL_WRITE_ONLY_OES 0x88B9 -#define GL_BUFFER_ACCESS_OES 0x88BB -#define GL_BUFFER_MAPPED_OES 0x88BC -#define GL_BUFFER_MAP_POINTER_OES 0x88BD -#endif - -/* GL_OES_packed_depth_stencil */ -#ifndef GL_OES_packed_depth_stencil -#define GL_DEPTH_STENCIL_OES 0x84F9 -#define GL_UNSIGNED_INT_24_8_OES 0x84FA -#define GL_DEPTH24_STENCIL8_OES 0x88F0 -#endif - -/* GL_OES_rgb8_rgba8 */ -#ifndef GL_OES_rgb8_rgba8 -#define GL_RGB8_OES 0x8051 -#define GL_RGBA8_OES 0x8058 -#endif - -/* GL_OES_standard_derivatives */ -#ifndef GL_OES_standard_derivatives -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B -#endif - -/* GL_OES_stencil1 */ -#ifndef GL_OES_stencil1 -#define GL_STENCIL_INDEX1_OES 0x8D46 -#endif - -/* GL_OES_stencil4 */ -#ifndef GL_OES_stencil4 -#define GL_STENCIL_INDEX4_OES 0x8D47 -#endif - -/* GL_OES_texture_3D */ -#ifndef GL_OES_texture_3D -#define GL_TEXTURE_WRAP_R_OES 0x8072 -#define GL_TEXTURE_3D_OES 0x806F -#define GL_TEXTURE_BINDING_3D_OES 0x806A -#define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073 -#define GL_SAMPLER_3D_OES 0x8B5F -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4 -#endif - -/* GL_OES_texture_float */ -/* No new tokens introduced by this extension. */ - -/* GL_OES_texture_float_linear */ -/* No new tokens introduced by this extension. */ - -/* GL_OES_texture_half_float */ -#ifndef GL_OES_texture_half_float -#define GL_HALF_FLOAT_OES 0x8D61 -#endif - -/* GL_OES_texture_half_float_linear */ -/* No new tokens introduced by this extension. */ - -/* GL_OES_texture_npot */ -/* No new tokens introduced by this extension. */ - -/* GL_OES_vertex_array_object */ -#ifndef GL_OES_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5 -#endif - -/* GL_OES_vertex_half_float */ -/* GL_HALF_FLOAT_OES defined in GL_OES_texture_half_float already. */ - -/* GL_OES_vertex_type_10_10_10_2 */ -#ifndef GL_OES_vertex_type_10_10_10_2 -#define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6 -#define GL_INT_10_10_10_2_OES 0x8DF7 -#endif - -/*------------------------------------------------------------------------* - * AMD extension tokens - *------------------------------------------------------------------------*/ - -/* GL_AMD_compressed_3DC_texture */ -#ifndef GL_AMD_compressed_3DC_texture -#define GL_3DC_X_AMD 0x87F9 -#define GL_3DC_XY_AMD 0x87FA -#endif - -/* GL_AMD_compressed_ATC_texture */ -#ifndef GL_AMD_compressed_ATC_texture -#define GL_ATC_RGB_AMD 0x8C92 -#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 -#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE -#endif - -/* GL_AMD_performance_monitor */ -#ifndef GL_AMD_performance_monitor -#define GL_COUNTER_TYPE_AMD 0x8BC0 -#define GL_COUNTER_RANGE_AMD 0x8BC1 -#define GL_UNSIGNED_INT64_AMD 0x8BC2 -#define GL_PERCENTAGE_AMD 0x8BC3 -#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 -#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 -#define GL_PERFMON_RESULT_AMD 0x8BC6 -#endif - -/* GL_AMD_program_binary_Z400 */ -#ifndef GL_AMD_program_binary_Z400 -#define GL_Z400_BINARY_AMD 0x8740 -#endif - -/*------------------------------------------------------------------------* - * ANGLE extension tokens - *------------------------------------------------------------------------*/ - -/* GL_ANGLE_framebuffer_blit */ -#ifndef GL_ANGLE_framebuffer_blit -#define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6 -#define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA -#endif - -/* GL_ANGLE_framebuffer_multisample */ -#ifndef GL_ANGLE_framebuffer_multisample -#define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56 -#define GL_MAX_SAMPLES_ANGLE 0x8D57 -#endif - -/*------------------------------------------------------------------------* - * APPLE extension tokens - *------------------------------------------------------------------------*/ - -/* GL_APPLE_rgb_422 */ -#ifndef GL_APPLE_rgb_422 -#define GL_RGB_422_APPLE 0x8A1F -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#endif - -/* GL_APPLE_framebuffer_multisample */ -#ifndef GL_APPLE_framebuffer_multisample -#define GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE 0x8D56 -#define GL_MAX_SAMPLES_APPLE 0x8D57 -#define GL_READ_FRAMEBUFFER_APPLE 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_APPLE 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE 0x8CA6 -#define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA -#endif - -/* GL_APPLE_texture_format_BGRA8888 */ -#ifndef GL_APPLE_texture_format_BGRA8888 -#define GL_BGRA_EXT 0x80E1 -#endif - -/* GL_APPLE_texture_max_level */ -#ifndef GL_APPLE_texture_max_level -#define GL_TEXTURE_MAX_LEVEL_APPLE 0x813D -#endif - -/*------------------------------------------------------------------------* - * ARM extension tokens - *------------------------------------------------------------------------*/ - -/* GL_ARM_mali_shader_binary */ -#ifndef GL_ARM_mali_shader_binary -#define GL_MALI_SHADER_BINARY_ARM 0x8F60 -#endif - -/* GL_ARM_rgba8 */ -/* No new tokens introduced by this extension. */ - -/*------------------------------------------------------------------------* - * EXT extension tokens - *------------------------------------------------------------------------*/ - -/* GL_EXT_blend_minmax */ -#ifndef GL_EXT_blend_minmax -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#endif - -/* GL_EXT_discard_framebuffer */ -#ifndef GL_EXT_discard_framebuffer -#define GL_COLOR_EXT 0x1800 -#define GL_DEPTH_EXT 0x1801 -#define GL_STENCIL_EXT 0x1802 -#endif - -/* GL_EXT_multi_draw_arrays */ -/* No new tokens introduced by this extension. */ - -/* GL_EXT_read_format_bgra */ -#ifndef GL_EXT_read_format_bgra -#define GL_BGRA_EXT 0x80E1 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366 -#endif - -/* GL_EXT_texture_filter_anisotropic */ -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif - -/* GL_EXT_texture_format_BGRA8888 */ -#ifndef GL_EXT_texture_format_BGRA8888 -#define GL_BGRA_EXT 0x80E1 -#endif - -/* GL_EXT_texture_type_2_10_10_10_REV */ -#ifndef GL_EXT_texture_type_2_10_10_10_REV -#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368 -#endif - -/* GL_EXT_texture_compression_dxt1 */ -#ifndef GL_EXT_texture_compression_dxt1 -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#endif - -/* GL_EXT_shader_texture_lod */ -/* No new tokens introduced by this extension. */ - -/*------------------------------------------------------------------------* - * IMG extension tokens - *------------------------------------------------------------------------*/ - -/* GL_IMG_program_binary */ -#ifndef GL_IMG_program_binary -#define GL_SGX_PROGRAM_BINARY_IMG 0x9130 -#endif - -/* GL_IMG_read_format */ -#ifndef GL_IMG_read_format -#define GL_BGRA_IMG 0x80E1 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG 0x8365 -#endif - -/* GL_IMG_shader_binary */ -#ifndef GL_IMG_shader_binary -#define GL_SGX_BINARY_IMG 0x8C0A -#endif - -/* GL_IMG_texture_compression_pvrtc */ -#ifndef GL_IMG_texture_compression_pvrtc -#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 -#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 -#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 -#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 -#endif - -/* GL_IMG_multisampled_render_to_texture */ -#ifndef GL_IMG_multisampled_render_to_texture -#define GL_RENDERBUFFER_SAMPLES_IMG 0x9133 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134 -#define GL_MAX_SAMPLES_IMG 0x9135 -#define GL_TEXTURE_SAMPLES_IMG 0x9136 -#endif - -/*------------------------------------------------------------------------* - * NV extension tokens - *------------------------------------------------------------------------*/ - -/* GL_NV_fence */ -#ifndef GL_NV_fence -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 -#endif - -/* GL_NV_coverage_sample */ -#ifndef GL_NV_coverage_sample -#define GL_COVERAGE_COMPONENT_NV 0x8ED0 -#define GL_COVERAGE_COMPONENT4_NV 0x8ED1 -#define GL_COVERAGE_ATTACHMENT_NV 0x8ED2 -#define GL_COVERAGE_BUFFERS_NV 0x8ED3 -#define GL_COVERAGE_SAMPLES_NV 0x8ED4 -#define GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5 -#define GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6 -#define GL_COVERAGE_AUTOMATIC_NV 0x8ED7 -#define GL_COVERAGE_BUFFER_BIT_NV 0x8000 -#endif - -/* GL_NV_depth_nonlinear */ -#ifndef GL_NV_depth_nonlinear -#define GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C -#endif - -/*------------------------------------------------------------------------* - * QCOM extension tokens - *------------------------------------------------------------------------*/ - -/* GL_QCOM_driver_control */ -/* No new tokens introduced by this extension. */ - -/* GL_QCOM_extended_get */ -#ifndef GL_QCOM_extended_get -#define GL_TEXTURE_WIDTH_QCOM 0x8BD2 -#define GL_TEXTURE_HEIGHT_QCOM 0x8BD3 -#define GL_TEXTURE_DEPTH_QCOM 0x8BD4 -#define GL_TEXTURE_INTERNAL_FORMAT_QCOM 0x8BD5 -#define GL_TEXTURE_FORMAT_QCOM 0x8BD6 -#define GL_TEXTURE_TYPE_QCOM 0x8BD7 -#define GL_TEXTURE_IMAGE_VALID_QCOM 0x8BD8 -#define GL_TEXTURE_NUM_LEVELS_QCOM 0x8BD9 -#define GL_TEXTURE_TARGET_QCOM 0x8BDA -#define GL_TEXTURE_OBJECT_VALID_QCOM 0x8BDB -#define GL_STATE_RESTORE 0x8BDC -#endif - -/* GL_QCOM_extended_get2 */ -/* No new tokens introduced by this extension. */ - -/* GL_QCOM_perfmon_global_mode */ -#ifndef GL_QCOM_perfmon_global_mode -#define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0 -#endif - -/* GL_QCOM_writeonly_rendering */ -#ifndef GL_QCOM_writeonly_rendering -#define GL_WRITEONLY_RENDERING_QCOM 0x8823 -#endif - -/* GL_QCOM_tiled_rendering */ -#ifndef GL_QCOM_tiled_rendering -#define GL_COLOR_BUFFER_BIT0_QCOM 0x00000001 -#define GL_COLOR_BUFFER_BIT1_QCOM 0x00000002 -#define GL_COLOR_BUFFER_BIT2_QCOM 0x00000004 -#define GL_COLOR_BUFFER_BIT3_QCOM 0x00000008 -#define GL_COLOR_BUFFER_BIT4_QCOM 0x00000010 -#define GL_COLOR_BUFFER_BIT5_QCOM 0x00000020 -#define GL_COLOR_BUFFER_BIT6_QCOM 0x00000040 -#define GL_COLOR_BUFFER_BIT7_QCOM 0x00000080 -#define GL_DEPTH_BUFFER_BIT0_QCOM 0x00000100 -#define GL_DEPTH_BUFFER_BIT1_QCOM 0x00000200 -#define GL_DEPTH_BUFFER_BIT2_QCOM 0x00000400 -#define GL_DEPTH_BUFFER_BIT3_QCOM 0x00000800 -#define GL_DEPTH_BUFFER_BIT4_QCOM 0x00001000 -#define GL_DEPTH_BUFFER_BIT5_QCOM 0x00002000 -#define GL_DEPTH_BUFFER_BIT6_QCOM 0x00004000 -#define GL_DEPTH_BUFFER_BIT7_QCOM 0x00008000 -#define GL_STENCIL_BUFFER_BIT0_QCOM 0x00010000 -#define GL_STENCIL_BUFFER_BIT1_QCOM 0x00020000 -#define GL_STENCIL_BUFFER_BIT2_QCOM 0x00040000 -#define GL_STENCIL_BUFFER_BIT3_QCOM 0x00080000 -#define GL_STENCIL_BUFFER_BIT4_QCOM 0x00100000 -#define GL_STENCIL_BUFFER_BIT5_QCOM 0x00200000 -#define GL_STENCIL_BUFFER_BIT6_QCOM 0x00400000 -#define GL_STENCIL_BUFFER_BIT7_QCOM 0x00800000 -#define GL_MULTISAMPLE_BUFFER_BIT0_QCOM 0x01000000 -#define GL_MULTISAMPLE_BUFFER_BIT1_QCOM 0x02000000 -#define GL_MULTISAMPLE_BUFFER_BIT2_QCOM 0x04000000 -#define GL_MULTISAMPLE_BUFFER_BIT3_QCOM 0x08000000 -#define GL_MULTISAMPLE_BUFFER_BIT4_QCOM 0x10000000 -#define GL_MULTISAMPLE_BUFFER_BIT5_QCOM 0x20000000 -#define GL_MULTISAMPLE_BUFFER_BIT6_QCOM 0x40000000 -#define GL_MULTISAMPLE_BUFFER_BIT7_QCOM 0x80000000 -#endif - -/*------------------------------------------------------------------------* - * VIV extension tokens - *------------------------------------------------------------------------*/ - -/* GL_VIV_shader_binary */ -#ifndef GL_VIV_shader_binary -#define GL_SHADER_BINARY_VIV 0x8FC4 -#endif - -/*------------------------------------------------------------------------* - * End of extension tokens, start of corresponding extension functions - *------------------------------------------------------------------------*/ - -/*------------------------------------------------------------------------* - * OES extension functions - *------------------------------------------------------------------------*/ - -/* GL_OES_compressed_ETC1_RGB8_texture */ -#ifndef GL_OES_compressed_ETC1_RGB8_texture -#define GL_OES_compressed_ETC1_RGB8_texture 1 -#endif - -/* GL_OES_compressed_paletted_texture */ -#ifndef GL_OES_compressed_paletted_texture -#define GL_OES_compressed_paletted_texture 1 -#endif - -/* GL_OES_depth24 */ -#ifndef GL_OES_depth24 -#define GL_OES_depth24 1 -#endif - -/* GL_OES_depth32 */ -#ifndef GL_OES_depth32 -#define GL_OES_depth32 1 -#endif - -/* GL_OES_depth_texture */ -#ifndef GL_OES_depth_texture -#define GL_OES_depth_texture 1 -#endif - -/* GL_OES_EGL_image */ -#ifndef GL_OES_EGL_image -#define GL_OES_EGL_image 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); -GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image); -#endif -typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); -typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); -#endif - -/* GL_OES_EGL_image_external */ -#ifndef GL_OES_EGL_image_external -#define GL_OES_EGL_image_external 1 -/* glEGLImageTargetTexture2DOES defined in GL_OES_EGL_image already. */ -#endif - -/* GL_OES_element_index_uint */ -#ifndef GL_OES_element_index_uint -#define GL_OES_element_index_uint 1 -#endif - -/* GL_OES_fbo_render_mipmap */ -#ifndef GL_OES_fbo_render_mipmap -#define GL_OES_fbo_render_mipmap 1 -#endif - -/* GL_OES_fragment_precision_high */ -#ifndef GL_OES_fragment_precision_high -#define GL_OES_fragment_precision_high 1 -#endif - -/* GL_OES_get_program_binary */ -#ifndef GL_OES_get_program_binary -#define GL_OES_get_program_binary 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glGetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); -GL_APICALL void GL_APIENTRY glProgramBinaryOES (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length); -#endif -typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); -typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length); -#endif - -/* GL_OES_mapbuffer */ -#ifndef GL_OES_mapbuffer -#define GL_OES_mapbuffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void* GL_APIENTRY glMapBufferOES (GLenum target, GLenum access); -GL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target); -GL_APICALL void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, GLvoid** params); -#endif -typedef void* (GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access); -typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target); -typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, GLvoid** params); -#endif - -/* GL_OES_packed_depth_stencil */ -#ifndef GL_OES_packed_depth_stencil -#define GL_OES_packed_depth_stencil 1 -#endif - -/* GL_OES_rgb8_rgba8 */ -#ifndef GL_OES_rgb8_rgba8 -#define GL_OES_rgb8_rgba8 1 -#endif - -/* GL_OES_standard_derivatives */ -#ifndef GL_OES_standard_derivatives -#define GL_OES_standard_derivatives 1 -#endif - -/* GL_OES_stencil1 */ -#ifndef GL_OES_stencil1 -#define GL_OES_stencil1 1 -#endif - -/* GL_OES_stencil4 */ -#ifndef GL_OES_stencil4 -#define GL_OES_stencil4 1 -#endif - -/* GL_OES_texture_3D */ -#ifndef GL_OES_texture_3D -#define GL_OES_texture_3D 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); -GL_APICALL void GL_APIENTRY glTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); -GL_APICALL void GL_APIENTRY glCopyTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); -GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data); -GL_APICALL void GL_APIENTRY glFramebufferTexture3DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -#endif -typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); -typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); -typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); -typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data); -typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOES) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -#endif - -/* GL_OES_texture_float */ -#ifndef GL_OES_texture_float -#define GL_OES_texture_float 1 -#endif - -/* GL_OES_texture_float_linear */ -#ifndef GL_OES_texture_float_linear -#define GL_OES_texture_float_linear 1 -#endif - -/* GL_OES_texture_half_float */ -#ifndef GL_OES_texture_half_float -#define GL_OES_texture_half_float 1 -#endif - -/* GL_OES_texture_half_float_linear */ -#ifndef GL_OES_texture_half_float_linear -#define GL_OES_texture_half_float_linear 1 -#endif - -/* GL_OES_texture_npot */ -#ifndef GL_OES_texture_npot -#define GL_OES_texture_npot 1 -#endif - -/* GL_OES_vertex_array_object */ -#ifndef GL_OES_vertex_array_object -#define GL_OES_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glBindVertexArrayOES (GLuint array); -GL_APICALL void GL_APIENTRY glDeleteVertexArraysOES (GLsizei n, const GLuint *arrays); -GL_APICALL void GL_APIENTRY glGenVertexArraysOES (GLsizei n, GLuint *arrays); -GL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES (GLuint array); -#endif -typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array); -typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays); -typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array); -#endif - -/* GL_OES_vertex_half_float */ -#ifndef GL_OES_vertex_half_float -#define GL_OES_vertex_half_float 1 -#endif - -/* GL_OES_vertex_type_10_10_10_2 */ -#ifndef GL_OES_vertex_type_10_10_10_2 -#define GL_OES_vertex_type_10_10_10_2 1 -#endif - -/*------------------------------------------------------------------------* - * AMD extension functions - *------------------------------------------------------------------------*/ - -/* GL_AMD_compressed_3DC_texture */ -#ifndef GL_AMD_compressed_3DC_texture -#define GL_AMD_compressed_3DC_texture 1 -#endif - -/* GL_AMD_compressed_ATC_texture */ -#ifndef GL_AMD_compressed_ATC_texture -#define GL_AMD_compressed_ATC_texture 1 -#endif - -/* AMD_performance_monitor */ -#ifndef GL_AMD_performance_monitor -#define GL_AMD_performance_monitor 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); -GL_APICALL void GL_APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); -GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, char *groupString); -GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, char *counterString); -GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data); -GL_APICALL void GL_APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); -GL_APICALL void GL_APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); -GL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList); -GL_APICALL void GL_APIENTRY glBeginPerfMonitorAMD (GLuint monitor); -GL_APICALL void GL_APIENTRY glEndPerfMonitorAMD (GLuint monitor); -GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); -#endif -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, char *groupString); -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, char *counterString); -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data); -typedef void (GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList); -typedef void (GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); -typedef void (GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); -#endif - -/* GL_AMD_program_binary_Z400 */ -#ifndef GL_AMD_program_binary_Z400 -#define GL_AMD_program_binary_Z400 1 -#endif - -/*------------------------------------------------------------------------* - * ANGLE extension functions - *------------------------------------------------------------------------*/ - -/* GL_ANGLE_framebuffer_blit */ -#ifndef GL_ANGLE_framebuffer_blit -#define GL_ANGLE_framebuffer_blit 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif -typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif - -/* GL_ANGLE_framebuffer_multisample */ -#ifndef GL_ANGLE_framebuffer_multisample -#define GL_ANGLE_framebuffer_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif -typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif - -/*------------------------------------------------------------------------* - * APPLE extension functions - *------------------------------------------------------------------------*/ - -/* GL_APPLE_rgb_422 */ -#ifndef GL_APPLE_rgb_422 -#define GL_APPLE_rgb_422 1 -#endif - -/* GL_APPLE_framebuffer_multisample */ -#ifndef GL_APPLE_framebuffer_multisample -#define GL_APPLE_framebuffer_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum, GLsizei, GLenum, GLsizei, GLsizei); -GL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void); -#endif - -/* GL_APPLE_texture_format_BGRA8888 */ -#ifndef GL_APPLE_texture_format_BGRA8888 -#define GL_APPLE_texture_format_BGRA8888 1 -#endif - -/* GL_APPLE_texture_max_level */ -#ifndef GL_APPLE_texture_max_level -#define GL_APPLE_texture_max_level 1 -#endif - -/*------------------------------------------------------------------------* - * ARM extension functions - *------------------------------------------------------------------------*/ - -/* GL_ARM_mali_shader_binary */ -#ifndef GL_ARM_mali_shader_binary -#define GL_ARM_mali_shader_binary 1 -#endif - -/* GL_ARM_rgba8 */ -#ifndef GL_ARM_rgba8 -#define GL_ARM_rgba8 1 -#endif - -/*------------------------------------------------------------------------* - * EXT extension functions - *------------------------------------------------------------------------*/ - -/* GL_EXT_blend_minmax */ -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 -#endif - -/* GL_EXT_discard_framebuffer */ -#ifndef GL_EXT_discard_framebuffer -#define GL_EXT_discard_framebuffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments); -#endif -typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); -#endif - -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); -GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -#endif - -/* GL_EXT_read_format_bgra */ -#ifndef GL_EXT_read_format_bgra -#define GL_EXT_read_format_bgra 1 -#endif - -/* GL_EXT_texture_filter_anisotropic */ -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 -#endif - -/* GL_EXT_texture_format_BGRA8888 */ -#ifndef GL_EXT_texture_format_BGRA8888 -#define GL_EXT_texture_format_BGRA8888 1 -#endif - -/* GL_EXT_texture_type_2_10_10_10_REV */ -#ifndef GL_EXT_texture_type_2_10_10_10_REV -#define GL_EXT_texture_type_2_10_10_10_REV 1 -#endif - -/* GL_EXT_texture_compression_dxt1 */ -#ifndef GL_EXT_texture_compression_dxt1 -#define GL_EXT_texture_compression_dxt1 1 -#endif - -/* GL_EXT_shader_texture_lod */ -#ifndef GL_EXT_shader_texture_lod -#define GL_EXT_shader_texture_lod 1 -#endif - -/*------------------------------------------------------------------------* - * IMG extension functions - *------------------------------------------------------------------------*/ - -/* GL_IMG_program_binary */ -#ifndef GL_IMG_program_binary -#define GL_IMG_program_binary 1 -#endif - -/* GL_IMG_read_format */ -#ifndef GL_IMG_read_format -#define GL_IMG_read_format 1 -#endif - -/* GL_IMG_shader_binary */ -#ifndef GL_IMG_shader_binary -#define GL_IMG_shader_binary 1 -#endif - -/* GL_IMG_texture_compression_pvrtc */ -#ifndef GL_IMG_texture_compression_pvrtc -#define GL_IMG_texture_compression_pvrtc 1 -#endif - -/* GL_IMG_multisampled_render_to_texture */ -#ifndef GL_IMG_multisampled_render_to_texture -#define GL_IMG_multisampled_render_to_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei); -GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei); -#endif -typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); -#endif - -/*------------------------------------------------------------------------* - * NV extension functions - *------------------------------------------------------------------------*/ - -/* GL_NV_fence */ -#ifndef GL_NV_fence -#define GL_NV_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); -GL_APICALL void GL_APIENTRY glGenFencesNV (GLsizei, GLuint *); -GL_APICALL GLboolean GL_APIENTRY glIsFenceNV (GLuint); -GL_APICALL GLboolean GL_APIENTRY glTestFenceNV (GLuint); -GL_APICALL void GL_APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); -GL_APICALL void GL_APIENTRY glFinishFenceNV (GLuint); -GL_APICALL void GL_APIENTRY glSetFenceNV (GLuint, GLenum); -#endif -typedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); -typedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); -typedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); -typedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); -typedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); -typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); -typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); -#endif - -/* GL_NV_coverage_sample */ -#ifndef GL_NV_coverage_sample -#define GL_NV_coverage_sample 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glCoverageMaskNV (GLboolean mask); -GL_APICALL void GL_APIENTRY glCoverageOperationNV (GLenum operation); -#endif -typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask); -typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation); -#endif - -/* GL_NV_depth_nonlinear */ -#ifndef GL_NV_depth_nonlinear -#define GL_NV_depth_nonlinear 1 -#endif - -/*------------------------------------------------------------------------* - * QCOM extension functions - *------------------------------------------------------------------------*/ - -/* GL_QCOM_driver_control */ -#ifndef GL_QCOM_driver_control -#define GL_QCOM_driver_control 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glGetDriverControlsQCOM (GLint *num, GLsizei size, GLuint *driverControls); -GL_APICALL void GL_APIENTRY glGetDriverControlStringQCOM (GLuint driverControl, GLsizei bufSize, GLsizei *length, char *driverControlString); -GL_APICALL void GL_APIENTRY glEnableDriverControlQCOM (GLuint driverControl); -GL_APICALL void GL_APIENTRY glDisableDriverControlQCOM (GLuint driverControl); -#endif -typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls); -typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, char *driverControlString); -typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); -typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); -#endif - -/* GL_QCOM_extended_get */ -#ifndef GL_QCOM_extended_get -#define GL_QCOM_extended_get 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glExtGetTexturesQCOM (GLuint *textures, GLint maxTextures, GLint *numTextures); -GL_APICALL void GL_APIENTRY glExtGetBuffersQCOM (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); -GL_APICALL void GL_APIENTRY glExtGetRenderbuffersQCOM (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); -GL_APICALL void GL_APIENTRY glExtGetFramebuffersQCOM (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); -GL_APICALL void GL_APIENTRY glExtGetTexLevelParameterivQCOM (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); -GL_APICALL void GL_APIENTRY glExtTexObjectStateOverrideiQCOM (GLenum target, GLenum pname, GLint param); -GL_APICALL void GL_APIENTRY glExtGetTexSubImageQCOM (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels); -GL_APICALL void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, GLvoid **params); -#endif -typedef void (GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC) (GLuint *textures, GLint maxTextures, GLint *numTextures); -typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC) (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); -typedef void (GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC) (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); -typedef void (GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC) (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); -typedef void (GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); -typedef void (GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC) (GLenum target, GLenum pname, GLint param); -typedef void (GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels); -typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, GLvoid **params); -#endif - -/* GL_QCOM_extended_get2 */ -#ifndef GL_QCOM_extended_get2 -#define GL_QCOM_extended_get2 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glExtGetShadersQCOM (GLuint *shaders, GLint maxShaders, GLint *numShaders); -GL_APICALL void GL_APIENTRY glExtGetProgramsQCOM (GLuint *programs, GLint maxPrograms, GLint *numPrograms); -GL_APICALL GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM (GLuint program); -GL_APICALL void GL_APIENTRY glExtGetProgramBinarySourceQCOM (GLuint program, GLenum shadertype, char *source, GLint *length); -#endif -typedef void (GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC) (GLuint *shaders, GLint maxShaders, GLint *numShaders); -typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC) (GLuint *programs, GLint maxPrograms, GLint *numPrograms); -typedef GLboolean (GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC) (GLuint program); -typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC) (GLuint program, GLenum shadertype, char *source, GLint *length); -#endif - -/* GL_QCOM_perfmon_global_mode */ -#ifndef GL_QCOM_perfmon_global_mode -#define GL_QCOM_perfmon_global_mode 1 -#endif - -/* GL_QCOM_writeonly_rendering */ -#ifndef GL_QCOM_writeonly_rendering -#define GL_QCOM_writeonly_rendering 1 -#endif - -/* GL_QCOM_tiled_rendering */ -#ifndef GL_QCOM_tiled_rendering -#define GL_QCOM_tiled_rendering 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glStartTilingQCOM (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); -GL_APICALL void GL_APIENTRY glEndTilingQCOM (GLbitfield preserveMask); -#endif -typedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); -typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask); -#endif - -/*------------------------------------------------------------------------* - * VIV extension tokens - *------------------------------------------------------------------------*/ - -/* GL_VIV_shader_binary */ -#ifndef GL_VIV_shader_binary -#define GL_VIV_shader_binary 1 -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* __gl2ext_h_ */ diff --git a/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2extimg.h b/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2extimg.h deleted file mode 100644 index 9d90955e24..0000000000 --- a/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2extimg.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef __gl2extimg_h_ -#define __gl2extimg_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/*------------------------------------------------------------------------* - * IMG extension tokens - *------------------------------------------------------------------------*/ - -/* GL_IMG_binary_shader */ -#ifndef GL_IMG_binary_shader -#define GL_SGX_BINARY_IMG 0x8C0A -#endif - -/* GL_IMG_texture_compression_pvrtc */ -#ifndef GL_IMG_texture_compression_pvrtc -#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 -#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 -#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 -#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 -#endif - - -/* GL_IMG_texture_format_BGRA8888 */ -#define GL_BGRA 0x80E1 - -/*------------------------------------------------------------------------* - * IMG extension functions - *------------------------------------------------------------------------*/ - -/* GL_IMG_binary_shader */ -#ifndef GL_IMG_binary_shader -#define GL_IMG_binary_shader 1 -#endif - -/* GL_IMG_texture_compression_pvrtc */ -#ifndef GL_IMG_texture_compression_pvrtc -#define GL_IMG_texture_compression_pvrtc 1 -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* __gl2extimg_h_ */ diff --git a/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2platform.h b/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2platform.h deleted file mode 100644 index eeb8e59ecd..0000000000 --- a/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2platform.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __gl2platform_h_ -#define __gl2platform_h_ - -/* - * This document is licensed under the SGI Free Software B License Version - * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . - */ - -/* Platform-specific types and definitions for OpenGL ES 2.X gl2.h - * - * Adopters may modify khrplatform.h and this file to suit their platform. - * You are encouraged to submit all modifications to the Khronos group so that - * they can be included in future versions of this file. Please submit changes - * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) - * by filing a bug against product "OpenGL-ES" component "Registry". - */ - -#include - -#ifndef GL_APICALL -#define GL_APICALL KHRONOS_APICALL -#endif - -#ifndef GL_APIENTRY -#define GL_APIENTRY KHRONOS_APIENTRY -#endif - -#endif /* __gl2platform_h_ */ diff --git a/cocos2dx/platform/third_party/win32/OGLES/KHR/khrplatform.h b/cocos2dx/platform/third_party/win32/OGLES/KHR/khrplatform.h deleted file mode 100644 index a8067e9a55..0000000000 --- a/cocos2dx/platform/third_party/win32/OGLES/KHR/khrplatform.h +++ /dev/null @@ -1,302 +0,0 @@ -#ifndef __khrplatform_h_ -#define __khrplatform_h_ - -/* -** Copyright (c) 2008-2009 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -/* Khronos platform-specific types and definitions. - * - * $Revision: 1.5 $ on $Date: 2010/06/03 16:51:55 $ - * - * Adopters may modify this file to suit their platform. Adopters are - * encouraged to submit platform specific modifications to the Khronos - * group so that they can be included in future versions of this file. - * Please submit changes by sending them to the public Khronos Bugzilla - * (http://khronos.org/bugzilla) by filing a bug against product - * "Khronos (general)" component "Registry". - * - * A predefined template which fills in some of the bug fields can be - * reached using http://tinyurl.com/khrplatform-h-bugreport, but you - * must create a Bugzilla login first. - * - * - * See the Implementer's Guidelines for information about where this file - * should be located on your system and for more details of its use: - * http://www.khronos.org/registry/implementers_guide.pdf - * - * This file should be included as - * #include - * by Khronos client API header files that use its types and defines. - * - * The types in khrplatform.h should only be used to define API-specific types. - * - * Types defined in khrplatform.h: - * khronos_int8_t signed 8 bit - * khronos_uint8_t unsigned 8 bit - * khronos_int16_t signed 16 bit - * khronos_uint16_t unsigned 16 bit - * khronos_int32_t signed 32 bit - * khronos_uint32_t unsigned 32 bit - * khronos_int64_t signed 64 bit - * khronos_uint64_t unsigned 64 bit - * khronos_intptr_t signed same number of bits as a pointer - * khronos_uintptr_t unsigned same number of bits as a pointer - * khronos_ssize_t signed size - * khronos_usize_t unsigned size - * khronos_float_t signed 32 bit floating point - * khronos_time_ns_t unsigned 64 bit time in nanoseconds - * khronos_utime_nanoseconds_t unsigned time interval or absolute time in - * nanoseconds - * khronos_stime_nanoseconds_t signed time interval in nanoseconds - * khronos_boolean_enum_t enumerated boolean type. This should - * only be used as a base type when a client API's boolean type is - * an enum. Client APIs which use an integer or other type for - * booleans cannot use this as the base type for their boolean. - * - * Tokens defined in khrplatform.h: - * - * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. - * - * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. - * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. - * - * Calling convention macros defined in this file: - * KHRONOS_APICALL - * KHRONOS_APIENTRY - * KHRONOS_APIATTRIBUTES - * - * These may be used in function prototypes as: - * - * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( - * int arg1, - * int arg2) KHRONOS_APIATTRIBUTES; - */ - -/*------------------------------------------------------------------------- - * Definition of KHRONOS_APICALL - *------------------------------------------------------------------------- - * This precedes the return type of the function in the function prototype. - */ - -#if (defined(_WIN32) || defined(__VC32__)) && !defined(__SCITECH_SNAP__) && !defined(__WINSCW__) -# if defined (_DLL_EXPORTS) -# define KHRONOS_APICALL __declspec(dllexport) -# else -# define KHRONOS_APICALL __declspec(dllimport) -# endif -#elif defined (__SYMBIAN32__) -# if defined (__GCC32__) -# define KHRONOS_APICALL __declspec(dllexport) -# else -# define KHRONOS_APICALL IMPORT_C -# endif -#else -# define KHRONOS_APICALL -#endif - -/*------------------------------------------------------------------------- - * Definition of KHRONOS_APIENTRY - *------------------------------------------------------------------------- - * This follows the return type of the function and precedes the function - * name in the function prototype. - */ -#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) && !defined(__WINSCW__) - /* Win32 but not WinCE */ -# define KHRONOS_APIENTRY __stdcall -#else -# define KHRONOS_APIENTRY -#endif - -/*------------------------------------------------------------------------- - * Definition of KHRONOS_APIATTRIBUTES - *------------------------------------------------------------------------- - * This follows the closing parenthesis of the function prototype arguments. - */ -#if defined (__ARMCC_2__) -#define KHRONOS_APIATTRIBUTES __softfp -#else -#define KHRONOS_APIATTRIBUTES -#endif - -/*------------------------------------------------------------------------- - * basic type definitions - *-----------------------------------------------------------------------*/ -#if defined(__SYMBIAN32__) - -#include - -typedef TInt32 khronos_int32_t; -typedef TUint32 khronos_uint32_t; -typedef TInt64 khronos_int64_t; -typedef TUint64 khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) - - -/* - * Using - */ -#include -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif defined(__VMS ) || defined(__sgi) - -/* - * Using - */ -#include -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) - -/* - * Win32 - */ -typedef __int32 khronos_int32_t; -typedef unsigned __int32 khronos_uint32_t; -typedef __int64 khronos_int64_t; -typedef unsigned __int64 khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif defined(__sun__) || defined(__digital__) - -/* - * Sun or Digital - */ -typedef int khronos_int32_t; -typedef unsigned int khronos_uint32_t; -#if defined(__arch64__) || defined(_LP64) -typedef long int khronos_int64_t; -typedef unsigned long int khronos_uint64_t; -#else -typedef long long int khronos_int64_t; -typedef unsigned long long int khronos_uint64_t; -#endif /* __arch64__ */ -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif defined(_UITRON_) - -/* - * uITRON - */ -typedef signed int khronos_int32_t; -typedef unsigned int khronos_uint32_t; -typedef long long khronos_int64_t; -typedef unsigned long long khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - - -#elif 0 - -/* - * Hypothetical platform with no float or int64 support - */ -typedef int khronos_int32_t; -typedef unsigned int khronos_uint32_t; -#define KHRONOS_SUPPORT_INT64 0 -#define KHRONOS_SUPPORT_FLOAT 0 - -#else - -/* - * Generic fallback - */ -#include -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#endif - - -/* - * Types that are (so far) the same on all platforms - */ -typedef signed char khronos_int8_t; -typedef unsigned char khronos_uint8_t; -typedef signed short int khronos_int16_t; -typedef unsigned short int khronos_uint16_t; -typedef signed long int khronos_intptr_t; -typedef unsigned long int khronos_uintptr_t; -typedef signed long int khronos_ssize_t; -typedef unsigned long int khronos_usize_t; - -#if KHRONOS_SUPPORT_FLOAT -/* - * Float type - */ -typedef float khronos_float_t; -#endif - -#if KHRONOS_SUPPORT_INT64 -/* Time types - * - * These types can be used to represent a time interval in nanoseconds or - * an absolute Unadjusted System Time. Unadjusted System Time is the number - * of nanoseconds since some arbitrary system event (e.g. since the last - * time the system booted). The Unadjusted System Time is an unsigned - * 64 bit value that wraps back to 0 every 584 years. Time intervals - * may be either signed or unsigned. - */ -typedef khronos_uint64_t khronos_utime_nanoseconds_t; -typedef khronos_int64_t khronos_stime_nanoseconds_t; -#endif - -/* - * Dummy value used to pad enum types to 32 bits. - */ -#ifndef KHRONOS_MAX_ENUM -#define KHRONOS_MAX_ENUM 0x7FFFFFFF -#endif - -/* - * Enumerated boolean type - * - * Values other than zero should be considered to be true. Therefore - * comparisons should not be made against KHRONOS_TRUE. - */ -typedef enum { - KHRONOS_FALSE = 0, - KHRONOS_TRUE = 1, - KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM -} khronos_boolean_enum_t; - -#endif /* __khrplatform_h_ */ diff --git a/cocos2dx/platform/third_party/win32/libraries/glew32.dll.REMOVED.git-id b/cocos2dx/platform/third_party/win32/libraries/glew32.dll.REMOVED.git-id new file mode 100644 index 0000000000..2df0a76454 --- /dev/null +++ b/cocos2dx/platform/third_party/win32/libraries/glew32.dll.REMOVED.git-id @@ -0,0 +1 @@ +cbce7da7692ddd7eb16880ec7b05e0faa8139c1a \ No newline at end of file diff --git a/cocos2dx/platform/third_party/win32/libraries/glew32.lib.REMOVED.git-id b/cocos2dx/platform/third_party/win32/libraries/glew32.lib.REMOVED.git-id new file mode 100644 index 0000000000..cd7b41948f --- /dev/null +++ b/cocos2dx/platform/third_party/win32/libraries/glew32.lib.REMOVED.git-id @@ -0,0 +1 @@ +03be6ad746e36147d633ec0e6a55e6bdb30a3a9d \ No newline at end of file diff --git a/cocos2dx/platform/third_party/win32/libraries/libGLESv2.dll.REMOVED.git-id b/cocos2dx/platform/third_party/win32/libraries/libGLESv2.dll.REMOVED.git-id deleted file mode 100644 index de5f0feefc..0000000000 --- a/cocos2dx/platform/third_party/win32/libraries/libGLESv2.dll.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -ebda058de3bf9518d8a4381f87b6796169f38538 \ No newline at end of file diff --git a/cocos2dx/platform/win32/CCApplication.cpp b/cocos2dx/platform/win32/CCApplication.cpp index a4f2ec87a0..a2c05ab7f9 100644 --- a/cocos2dx/platform/win32/CCApplication.cpp +++ b/cocos2dx/platform/win32/CCApplication.cpp @@ -160,17 +160,17 @@ static void PVRFrameEnableControlWindow(bool bEnable) return; } - const char * szValue = "hide_gui"; - const char * szNewData = (bEnable) ? "NO" : "YES"; - char szOldData[256] = {0}; - DWORD dwSize = sizeof(szOldData); - LSTATUS status = RegQueryValueEx(hKey, szValue, 0, NULL, (LPBYTE)szOldData, &dwSize); + const WCHAR* wszValue = L"hide_gui"; + const WCHAR* wszNewData = (bEnable) ? L"NO" : L"YES"; + WCHAR wszOldData[256] = {0}; + DWORD dwSize = sizeof(wszOldData); + LSTATUS status = RegQueryValueExW(hKey, wszValue, 0, NULL, (LPBYTE)wszOldData, &dwSize); if (ERROR_FILE_NOT_FOUND == status // the key not exist || (ERROR_SUCCESS == status // or the hide_gui value is exist - && 0 != strcmp(szNewData, szOldData))) // but new data and old data not equal + && 0 != wcscmp(wszNewData, wszOldData))) // but new data and old data not equal { - dwSize = sizeof(wchar_t) * (strlen(szNewData) + 1); - RegSetValueEx(hKey, szValue, 0, REG_SZ, (const BYTE *)szNewData, dwSize); + dwSize = sizeof(WCHAR) * (wcslen(wszNewData) + 1); + RegSetValueEx(hKey, wszValue, 0, REG_SZ, (const BYTE *)wszNewData, dwSize); } RegCloseKey(hKey); diff --git a/cocos2dx/platform/win32/CCEGLView.cpp b/cocos2dx/platform/win32/CCEGLView.cpp index 4ff9e89fb9..976b75289a 100644 --- a/cocos2dx/platform/win32/CCEGLView.cpp +++ b/cocos2dx/platform/win32/CCEGLView.cpp @@ -32,141 +32,43 @@ THE SOFTWARE. #include "CCKeypadDispatcher.h" #include "CCApplication.h" -#include "EGL/egl.h" - NS_CC_BEGIN -////////////////////////////////////////////////////////////////////////// -// impliment CCEGL -////////////////////////////////////////////////////////////////////////// - -class CCEGL +static void SetupPixelFormat(HDC hDC) { -public: - ~CCEGL() - { - if (EGL_NO_SURFACE != m_eglSurface) - { - eglDestroySurface(m_eglDisplay, m_eglSurface); - } - if (EGL_NO_CONTEXT != m_eglContext) - { - eglDestroyContext(m_eglDisplay, m_eglContext); - } - eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - eglTerminate(m_eglDisplay); - if (m_eglNativeDisplay) - { - ReleaseDC(m_eglNativeWindow, m_eglNativeDisplay); - } - } + int pixelFormat; - static CCEGL * create(CCEGLView * pWindow) - { - CCEGL * pEGL = new CCEGL; - BOOL bSuccess = FALSE; - do - { - CC_BREAK_IF(! pEGL); + PIXELFORMATDESCRIPTOR pfd = + { + sizeof(PIXELFORMATDESCRIPTOR), // size + 1, // version + PFD_SUPPORT_OPENGL | // OpenGL window + PFD_DRAW_TO_WINDOW | // render to window + PFD_DOUBLEBUFFER, // support double-buffering + PFD_TYPE_RGBA, // color type + 32, // prefered color depth + 0, 0, 0, 0, 0, 0, // color bits (ignored) + 0, // no alpha buffer + 0, // alpha bits (ignored) + 0, // no accumulation buffer + 0, 0, 0, 0, // accum bits (ignored) + 16, // depth buffer + 0, // no stencil buffer + 0, // no auxiliary buffers + PFD_MAIN_PLANE, // main layer + 0, // reserved + 0, 0, 0, // no layer, visible, damage masks + }; - pEGL->m_eglNativeWindow = pWindow->getHWnd(); - - pEGL->m_eglNativeDisplay = GetDC(pEGL->m_eglNativeWindow); - - EGLDisplay eglDisplay; - CC_BREAK_IF(EGL_NO_DISPLAY == (eglDisplay = eglGetDisplay(pEGL->m_eglNativeDisplay))); - - EGLint nMajor, nMinor; - CC_BREAK_IF(EGL_FALSE == eglInitialize(eglDisplay, &nMajor, &nMinor) || 1 != nMajor); - - const EGLint aConfigAttribs[] = - { - EGL_LEVEL, 0, - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL_NATIVE_RENDERABLE, EGL_FALSE, - EGL_DEPTH_SIZE, 16, - EGL_NONE, - }; - EGLint iConfigs; - EGLConfig eglConfig; - CC_BREAK_IF(EGL_FALSE == eglChooseConfig(eglDisplay, aConfigAttribs, &eglConfig, 1, &iConfigs) - || (iConfigs != 1)); - - EGLContext eglContext; - eglContext = eglCreateContext(eglDisplay, eglConfig, NULL, NULL); - CC_BREAK_IF(EGL_NO_CONTEXT == eglContext); - - EGLSurface eglSurface; - eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, pEGL->m_eglNativeWindow, NULL); - CC_BREAK_IF(EGL_NO_SURFACE == eglSurface); - - CC_BREAK_IF(EGL_FALSE == eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)); - - pEGL->m_eglDisplay = eglDisplay; - pEGL->m_eglConfig = eglConfig; - pEGL->m_eglContext = eglContext; - pEGL->m_eglSurface = eglSurface; - bSuccess = TRUE; - } while (0); - - if (! bSuccess) - { - CC_SAFE_DELETE(pEGL); - } - - return pEGL; - } - - void resizeSurface() - { -// if (! m_eglNativeWindow || EGL_NO_DISPLAY == m_eglDisplay) -// { -// return; -// } -// -// // release old surface -// if (EGL_NO_SURFACE != m_eglSurface) -// { -// eglDestroySurface(m_eglDisplay, m_eglSurface); -// m_eglSurface = EGL_NO_SURFACE; -// } -// -// // create new surface and make current -// m_eglSurface = eglCreateWindowSurface(m_eglDisplay, m_eglConfig, m_eglNativeWindow, NULL); -// eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext); - } - - void swapBuffers() - { - if (EGL_NO_DISPLAY != m_eglDisplay) - { - eglSwapBuffers(m_eglDisplay, m_eglSurface); - } - } -private: - CCEGL() - : m_eglNativeWindow(NULL) - , m_eglNativeDisplay(EGL_DEFAULT_DISPLAY) - , m_eglDisplay(EGL_NO_DISPLAY) - , m_eglConfig(0) - , m_eglSurface(EGL_NO_SURFACE) - , m_eglContext(EGL_NO_CONTEXT) - {} - - EGLNativeWindowType m_eglNativeWindow; - EGLNativeDisplayType m_eglNativeDisplay; - EGLDisplay m_eglDisplay; - EGLConfig m_eglConfig; - EGLSurface m_eglSurface; - EGLContext m_eglContext; -}; + pixelFormat = ChoosePixelFormat(hDC, &pfd); + SetPixelFormat(hDC, pixelFormat, &pfd); +} ////////////////////////////////////////////////////////////////////////// // impliment CCEGLView ////////////////////////////////////////////////////////////////////////// static CCEGLView* s_pMainWindow = NULL; -static const char* kWindowClassName = "Cocos2dxWin32"; +static const WCHAR* kWindowClassName = L"Cocos2dxWin32"; static LRESULT CALLBACK _WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { @@ -182,8 +84,9 @@ static LRESULT CALLBACK _WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM CCEGLView::CCEGLView() : m_bCaptured(false) -, m_pEGL(NULL) , m_hWnd(NULL) +, m_hDC(NULL) +, m_hRC(NULL) , m_lpfnAccelerometerKeyHook(NULL) { @@ -191,7 +94,52 @@ CCEGLView::CCEGLView() CCEGLView::~CCEGLView() { - CC_SAFE_DELETE(m_pEGL); + +} + +bool CCEGLView::initGL() +{ + m_hDC = GetDC(m_hWnd); + SetupPixelFormat(m_hDC); + //SetupPalette(); + m_hRC = wglCreateContext(m_hDC); + wglMakeCurrent(m_hDC, m_hRC); + + GLenum GlewInitResult = glewInit(); + if (GLEW_OK != GlewInitResult) + { + fprintf(stderr,"ERROR: %s\n",glewGetErrorString(GlewInitResult)); + return false; + } + + if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader) + { + CCLog("Ready for GLSL\n"); + } + else + { + CCLog("Not totally ready :( \n"); + } + + if (glewIsSupported("GL_VERSION_2_0")) + { + CCLog("Ready for OpenGL 2.0\n"); + } + else + { + CCLog("OpenGL 2.0 not supported\n"); + } + return true; +} + +void CCEGLView::destroyGL() +{ + if (m_hDC != NULL && m_hRC != NULL) + { + // deselect rendering context and delete it + wglMakeCurrent(m_hDC, NULL); + wglDeleteContext(m_hRC); + } } bool CCEGLView::Create(LPCTSTR pTitle, int w, int h) @@ -222,11 +170,14 @@ bool CCEGLView::Create(LPCTSTR pTitle, int w, int h) RECT rcDesktop; GetWindowRect(GetDesktopWindow(), &rcDesktop); + WCHAR wszBuf[50] = {0}; + MultiByteToWideChar(CP_UTF8, 0, m_szViewName, -1, wszBuf, sizeof(wszBuf)); + // create window m_hWnd = CreateWindowEx( WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, // Extended Style For The Window kWindowClassName, // Class Name - m_szViewName, // Window Title + wszBuf, // Window Title WS_CAPTION | WS_POPUPWINDOW | WS_MINIMIZEBOX, // Defined Window Style 0, 0, // Window Position 0, // Window Width @@ -240,16 +191,9 @@ bool CCEGLView::Create(LPCTSTR pTitle, int w, int h) resize(w, h); - // init egl - m_pEGL = CCEGL::create(this); - - if (! m_pEGL) - { - DestroyWindow(m_hWnd); - m_hWnd = NULL; - break; - } - + bRet = initGL(); + CC_BREAK_IF(!bRet); + s_pMainWindow = this; bRet = true; } while (0); @@ -259,8 +203,6 @@ bool CCEGLView::Create(LPCTSTR pTitle, int w, int h) LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { - PAINTSTRUCT ps; - switch (message) { case WM_LBUTTONDOWN: @@ -360,7 +302,6 @@ LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { char szUtf8[8] = {0}; int nLen = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)&wParam, 1, szUtf8, sizeof(szUtf8), NULL, NULL); - CCIMEDispatcher::sharedDispatcher()->dispatchInsertText(szUtf8, nLen); } if ( m_lpfnAccelerometerKeyHook!=NULL ) @@ -369,8 +310,8 @@ LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) } } break; - case WM_PAINT: + PAINTSTRUCT ps; BeginPaint(m_hWnd, &ps); EndPaint(m_hWnd, &ps); break; @@ -380,6 +321,7 @@ LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) break; case WM_DESTROY: + destroyGL(); PostQuitMessage(0); break; @@ -397,7 +339,7 @@ void CCEGLView::setAccelerometerKeyHook( LPFN_ACCELEROMETER_KEYHOOK lpfnAccelero bool CCEGLView::isOpenGLReady() { - return (NULL != m_pEGL); + return (m_hDC != NULL && m_hRC != NULL); } void CCEGLView::end() @@ -414,9 +356,9 @@ void CCEGLView::end() void CCEGLView::swapBuffers() { - if (m_pEGL) + if (m_hDC != NULL) { - m_pEGL->swapBuffers(); + ::SwapBuffers(m_hDC); } } @@ -453,11 +395,6 @@ void CCEGLView::resize(int width, int height) // change width and height SetWindowPos(m_hWnd, 0, 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER); - - if (m_pEGL) - { - m_pEGL->resizeSurface(); - } } void CCEGLView::setFrameSize(float width, float height) diff --git a/cocos2dx/platform/win32/CCEGLView.h b/cocos2dx/platform/win32/CCEGLView.h index a6ede92c5a..017db9b38c 100644 --- a/cocos2dx/platform/win32/CCEGLView.h +++ b/cocos2dx/platform/win32/CCEGLView.h @@ -51,6 +51,8 @@ public: private: virtual bool Create(LPCTSTR pTitle, int w, int h); + bool initGL(); + void destroyGL(); public: virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); @@ -71,10 +73,11 @@ public: protected: private: - bool m_bCaptured; - CCEGL * m_pEGL; - HWND m_hWnd; - LPFN_ACCELEROMETER_KEYHOOK m_lpfnAccelerometerKeyHook; + bool m_bCaptured; + HWND m_hWnd; + HDC m_hDC; + HGLRC m_hRC; + LPFN_ACCELEROMETER_KEYHOOK m_lpfnAccelerometerKeyHook; }; NS_CC_END diff --git a/cocos2dx/platform/win32/CCGL.h b/cocos2dx/platform/win32/CCGL.h index c872d3461b..f58864ebd2 100644 --- a/cocos2dx/platform/win32/CCGL.h +++ b/cocos2dx/platform/win32/CCGL.h @@ -25,13 +25,6 @@ THE SOFTWARE. #ifndef __CCGL_H__ #define __CCGL_H__ -#define glClearDepth glClearDepthf -#define glDeleteVertexArrays glDeleteVertexArraysOES -#define glGenVertexArrays glGenVertexArraysOES -#define glBindVertexArray glBindVertexArrayOES - -#include "GLES2/gl2.h" -#include "GLES2/gl2ext.h" - +#include "GL/glew.h" #endif // __PLATFOMR_CCGL_H__ diff --git a/cocos2dx/platform/win32/CCImage.cpp b/cocos2dx/platform/win32/CCImage.cpp index e03c549470..fe503a8387 100644 --- a/cocos2dx/platform/win32/CCImage.cpp +++ b/cocos2dx/platform/win32/CCImage.cpp @@ -57,14 +57,42 @@ public: DeleteObject(m_hFont); m_hFont = hDefFont; } - // release temp font resource - if (m_curFontPath.size() > 0) - { - RemoveFontResource(m_curFontPath.c_str()); - SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0); - } + // release temp font resource + if (m_curFontPath.size() > 0) + { + wchar_t * pwszBuffer = utf8ToUtf16(m_curFontPath); + if (pwszBuffer) + { + RemoveFontResource(pwszBuffer); + SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0); + delete [] pwszBuffer; + pwszBuffer = NULL; + } + } } + wchar_t * utf8ToUtf16(std::string nString) + { + wchar_t * pwszBuffer = NULL; + do + { + if (nString.size() < 0) + { + break; + } + // utf-8 to utf-16 + int nLen = nString.size(); + int nBufLen = nLen + 1; + pwszBuffer = new wchar_t[nBufLen]; + CC_BREAK_IF(! pwszBuffer); + memset(pwszBuffer,0,nBufLen); + nLen = MultiByteToWideChar(CP_UTF8, 0, nString.c_str(), nLen, pwszBuffer, nBufLen); + pwszBuffer[nLen] = '\0'; + } while (0); + return pwszBuffer; + + } + bool setFont(const char * pFontName = NULL, int nSize = 0) { bool bRet = false; @@ -110,27 +138,41 @@ public: if (m_hFont != hDefFont) { DeleteObject(m_hFont); - // release old font register - if (m_curFontPath.size() > 0) - { - if(RemoveFontResource(m_curFontPath.c_str())) - { - SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0); - } - } - - fontPath.size()>0?(m_curFontPath = fontPath):(m_curFontPath.clear()); - // register temp font - if (m_curFontPath.size() > 0) - { - if(AddFontResource(m_curFontPath.c_str())) - { - SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0); - } - } + // release old font register + if (m_curFontPath.size() > 0) + { + wchar_t * pwszBuffer = utf8ToUtf16(m_curFontPath); + if (pwszBuffer) + { + if(RemoveFontResource(pwszBuffer)) + { + SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0); + } + delete [] pwszBuffer; + pwszBuffer = NULL; + } + } + fontPath.size()>0?(m_curFontPath = fontPath):(m_curFontPath.clear()); + // register temp font + if (m_curFontPath.size() > 0) + { + wchar_t * pwszBuffer = utf8ToUtf16(m_curFontPath); + if (pwszBuffer) + { + if(AddFontResource(pwszBuffer)) + { + SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0); + } + delete [] pwszBuffer; + pwszBuffer = NULL; + } + } } m_hFont = NULL; + // disable Cleartype + tNewFont.lfQuality = ANTIALIASED_QUALITY; + // create new font m_hFont = CreateFontIndirectA(&tNewFont); if (! m_hFont) diff --git a/cocos2dx/proj.win32/cocos2d-win32.vcproj b/cocos2dx/proj.win32/cocos2d-win32.vcproj index b325206771..be918e894e 100755 --- a/cocos2dx/proj.win32/cocos2d-win32.vcproj +++ b/cocos2dx/proj.win32/cocos2d-win32.vcproj @@ -21,7 +21,7 @@ OutputDirectory="$(SolutionDir)$(ConfigurationName).win32" IntermediateDirectory="$(ConfigurationName).win32" ConfigurationType="2" - CharacterSet="2" + CharacterSet="1" > DynamicLibrary - MultiByte + Unicode DynamicLibrary - MultiByte + Unicode @@ -74,7 +74,7 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ - libEGL.lib;libGLESv2.lib;libxml2.lib;libzlib.lib;libpng.lib;libtiff.lib;libjpeg.lib;libiconv.lib;pthreadVCE2.lib;%(AdditionalDependencies);%(AdditionalDependencies) + opengl32.lib;glew32.lib;libxml2.lib;libzlib.lib;libpng.lib;libtiff.lib;libjpeg.lib;libiconv.lib;pthreadVCE2.lib;%(AdditionalDependencies);%(AdditionalDependencies) $(OutDir)$(ProjectName).dll $(OutDir);%(AdditionalLibraryDirectories) @@ -112,7 +112,7 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ - libEGL.lib;libGLESv2.lib;libxml2.lib;libzlib.lib;libpng.lib;libtiff.lib;libjpeg.lib;libiconv.lib;pthreadVCE2.lib;;%(AdditionalDependencies) + opengl32.lib;glew32.lib;libxml2.lib;libzlib.lib;libpng.lib;libtiff.lib;libjpeg.lib;libiconv.lib;pthreadVCE2.lib;;%(AdditionalDependencies) $(OutDir)$(ProjectName).dll $(OutDir);%(AdditionalLibraryDirectories) diff --git a/lua/proj.win32/liblua.vcproj b/lua/proj.win32/liblua.vcproj index b6313e9e57..08898e3c93 100644 --- a/lua/proj.win32/liblua.vcproj +++ b/lua/proj.win32/liblua.vcproj @@ -21,7 +21,7 @@ OutputDirectory="$(SolutionDir)$(ConfigurationName).win32" IntermediateDirectory="$(ConfigurationName).win32" ConfigurationType="4" - CharacterSet="2" + CharacterSet="1" > StaticLibrary - MultiByte + Unicode true StaticLibrary - MultiByte + Unicode diff --git a/template/msvc/CCAppWiz.win32/Scripts/1033/default.js b/template/msvc/CCAppWiz.win32/Scripts/1033/default.js index d5929b5525..9aabd73bfd 100644 --- a/template/msvc/CCAppWiz.win32/Scripts/1033/default.js +++ b/template/msvc/CCAppWiz.win32/Scripts/1033/default.js @@ -306,7 +306,7 @@ function AddConfigurations(proj, strProjectName) { } // Additional Library Directories - var strAddDepends = 'libcocos2d.lib libGLESv2.lib'; + var strAddDepends = 'libcocos2d.lib opengl32.lib glew32.lib'; if (wizard.FindSymbol('CC_USE_BOX2D')) { strAddDepends += ' libBox2d.lib'; } diff --git a/testjs/proj.win32/testjs.win32.vcproj b/testjs/proj.win32/testjs.win32.vcproj index 659ea5ad21..712f215622 100644 --- a/testjs/proj.win32/testjs.win32.vcproj +++ b/testjs/proj.win32/testjs.win32.vcproj @@ -73,7 +73,7 @@ /> - libcocos2d.lib;libGLESv2.lib;libCocosDenshion.lib;js.lib;%(AdditionalDependencies) + libcocos2d.lib;opengl32.lib;glew32.lib;libCocosDenshion.lib;js.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) true Windows @@ -124,7 +124,7 @@ xcopy /Y /Q "$(SolutionDir)js\spidermonkey-win32\lib\*.*" "$(OutDir)" $(IntDir);%(AdditionalIncludeDirectories) - libcocos2d.lib;libGLESv2.lib;libCocosDenshion.lib;js.lib;%(AdditionalDependencies) + libcocos2d.lib;opengl32.lib;glew32.lib;libCocosDenshion.lib;js.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) Windows MachineX86 diff --git a/tests/proj.win32/test.win32.vcproj b/tests/proj.win32/test.win32.vcproj index c19bee53bc..501f7bdc80 100644 --- a/tests/proj.win32/test.win32.vcproj +++ b/tests/proj.win32/test.win32.vcproj @@ -21,7 +21,7 @@ OutputDirectory="$(SolutionDir)$(ConfigurationName).win32" IntermediateDirectory="$(ConfigurationName).win32" ConfigurationType="1" - CharacterSet="2" + CharacterSet="1" > Application - MultiByte + Unicode true Application - MultiByte + Unicode @@ -67,7 +67,7 @@ 4251;4244;4996;%(DisableSpecificWarnings) - libGLESv2.lib;libcocos2d.lib;libBox2d.lib;libchipmunk.lib;libcurl_imp.lib;libCocosDenshion.lib;%(AdditionalDependencies) + opengl32.lib;glew32.lib;libcocos2d.lib;libBox2d.lib;libchipmunk.lib;libcurl_imp.lib;libCocosDenshion.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).exe $(OutDir);%(AdditionalLibraryDirectories) true @@ -94,7 +94,7 @@ 4251;4244;4996;%(DisableSpecificWarnings) - libGLESv2.lib;libcocos2d.lib;libBox2d.lib;libchipmunk.lib;libcurl_imp.lib;libCocosDenshion.lib;%(AdditionalDependencies) + opengl32.lib;glew32.lib;libcocos2d.lib;libBox2d.lib;libchipmunk.lib;libcurl_imp.lib;libCocosDenshion.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).exe $(OutDir);%(AdditionalLibraryDirectories) true From 2b235fd7057416a660ac04f3d7fce347be7ebed5 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 1 Jun 2012 13:56:22 +0800 Subject: [PATCH 048/257] Delete libEGL.dll(.lib). --- .../third_party/win32/libraries/libEGL.dll.REMOVED.git-id | 1 - 1 file changed, 1 deletion(-) delete mode 100644 cocos2dx/platform/third_party/win32/libraries/libEGL.dll.REMOVED.git-id diff --git a/cocos2dx/platform/third_party/win32/libraries/libEGL.dll.REMOVED.git-id b/cocos2dx/platform/third_party/win32/libraries/libEGL.dll.REMOVED.git-id deleted file mode 100644 index b1e0c80d1a..0000000000 --- a/cocos2dx/platform/third_party/win32/libraries/libEGL.dll.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -94cfb991773a35b467f19af4bde43d039ad534e7 \ No newline at end of file From 472c98b65293e9efc47da5ef8a3bc24c6eaf081f Mon Sep 17 00:00:00 2001 From: Nat Weiss Date: Thu, 31 May 2012 23:20:56 -0700 Subject: [PATCH 049/257] Fixes the declaration of tgaLoadRLEImageData() to match it's implementation. This causes an android build to be successful. --- cocos2dx/support/image_support/TGAlib.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/support/image_support/TGAlib.cpp b/cocos2dx/support/image_support/TGAlib.cpp index 2892a420b9..8de460c73d 100644 --- a/cocos2dx/support/image_support/TGAlib.cpp +++ b/cocos2dx/support/image_support/TGAlib.cpp @@ -30,7 +30,7 @@ THE SOFTWARE. namespace cocos2d { -void tgaLoadRLEImageData(FILE *file, tImageTGA *info); +static bool tgaLoadRLEImageData(unsigned char* Buffer, unsigned long bufSize, tImageTGA *psInfo); void tgaFlipImage( tImageTGA *info ); // load the image header field from stream From 987374c76b415ad82a8de97649dd4b63b34d6b4d Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 1 Jun 2012 14:48:13 +0800 Subject: [PATCH 050/257] Update AUTHORS --- AUTHORS | 3 +++ 1 file changed, 3 insertions(+) diff --git a/AUTHORS b/AUTHORS index 592b839874..bfc594d765 100644 --- a/AUTHORS +++ b/AUTHORS @@ -86,6 +86,9 @@ Developers: jreitman fix the bug of asynchronous loading resources for iOS + Nat Weiss + Fixes the declaration of tgaLoadRLEImageData() + Retired Core Developers: WenSheng Yang Author of windows port, CCTextField, From 3959fe8f4d4fc611d492675c74027a7c13ccd16d Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 1 Jun 2012 14:48:45 +0800 Subject: [PATCH 051/257] typo fixed in CCGL.h --- cocos2dx/platform/android/CCGL.h | 2 +- cocos2dx/platform/ios/CCGL.h | 2 +- cocos2dx/platform/win32/CCGL.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2dx/platform/android/CCGL.h b/cocos2dx/platform/android/CCGL.h index cdd9794032..f2701dab0a 100644 --- a/cocos2dx/platform/android/CCGL.h +++ b/cocos2dx/platform/android/CCGL.h @@ -53,4 +53,4 @@ extern PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArraysOESEXT; #define glDeleteVertexArraysOES glDeleteVertexArraysOESEXT -#endif // __PLATFOMR_CCGL_H__ +#endif // __CCGL_H__ diff --git a/cocos2dx/platform/ios/CCGL.h b/cocos2dx/platform/ios/CCGL.h index 5dc4f76483..faad8e010d 100644 --- a/cocos2dx/platform/ios/CCGL.h +++ b/cocos2dx/platform/ios/CCGL.h @@ -34,4 +34,4 @@ THE SOFTWARE. #include -#endif // __PLATFOMR_CCGL_H__ +#endif // __CCGL_H__ diff --git a/cocos2dx/platform/win32/CCGL.h b/cocos2dx/platform/win32/CCGL.h index f58864ebd2..2a45c87796 100644 --- a/cocos2dx/platform/win32/CCGL.h +++ b/cocos2dx/platform/win32/CCGL.h @@ -27,4 +27,4 @@ THE SOFTWARE. #include "GL/glew.h" -#endif // __PLATFOMR_CCGL_H__ +#endif // __CCGL_H__ From 8b6026f932ef6d0f284b8d73ac5657b79eec10ea Mon Sep 17 00:00:00 2001 From: Nat Weiss Date: Fri, 1 Jun 2012 00:36:16 -0700 Subject: [PATCH 052/257] Android template's build_native.sh automatically copies new icons from your assets directory. --- template/android/build_native.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/template/android/build_native.sh b/template/android/build_native.sh index 9c6d50ada5..32345d4bd9 100644 --- a/template/android/build_native.sh +++ b/template/android/build_native.sh @@ -50,6 +50,21 @@ do fi done +# copy icons (if they exist) +file=$GAME_ANDROID_ROOT/assets/Icon-72.png +if [ -f "$file" ]; then + cp $file $GAME_ANDROID_ROOT/res/drawable-hdpi/icon.png +fi +file=$GAME_ANDROID_ROOT/assets/Icon-48.png +if [ -f "$file" ]; then + cp $file $GAME_ANDROID_ROOT/res/drawable-mdpi/icon.png +fi +file=$GAME_ANDROID_ROOT/assets/Icon-32.png +if [ -f "$file" ]; then + cp $file $GAME_ANDROID_ROOT/res/drawable-ldpi/icon.png +fi + + if [[ $buildexternalsfromsource ]]; then echo "Building external dependencies from source" $NDK_ROOT/ndk-build -C $GAME_ANDROID_ROOT \ From 0fedc8a84a051717a6e360593a6bdf3387602084 Mon Sep 17 00:00:00 2001 From: Nat Weiss Date: Fri, 1 Jun 2012 00:54:17 -0700 Subject: [PATCH 053/257] Enhances CCTransitionScene to work even if there is no running scene. --- cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp index 1305eaf663..98916eac98 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp @@ -75,6 +75,11 @@ bool CCTransitionScene::initWithDuration(ccTime t, CCScene *scene) m_pInScene = scene; m_pInScene->retain(); m_pOutScene = CCDirector::sharedDirector()->getRunningScene(); + if (m_pOutScene == NULL) + { + m_pOutScene = CCScene::node(); + m_pOutScene->init(); + } m_pOutScene->retain(); CCAssert( m_pInScene != m_pOutScene, "Incoming scene must be different from the outgoing scene" ); From ac268896f1303389a64e9a230385f1bddc0d5fe8 Mon Sep 17 00:00:00 2001 From: icewind Date: Fri, 1 Jun 2012 14:07:45 +0400 Subject: [PATCH 054/257] CCControlButton update. Added zoomOnTouchDown property and setPreferredSize Ported some functions from original CCControlExtensions repository. Added feature to set the preferred size of the background sprite and toggle zooming on TouchDown event --- .../CCControlExtension/CCControlButton.cpp | 52 +++++++++++++++++-- .../CCControlExtension/CCControlButton.h | 5 ++ 2 files changed, 52 insertions(+), 5 deletions(-) diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp index d84cd089bf..24c00f96ed 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp @@ -70,6 +70,9 @@ bool CCControlButton::initWithLabelAndBackgroundSprite(CCNode* node, CCScale9Spr // Adjust the background image by default m_adjustBackgroundImage=true; + // Zooming button by default + m_zoomOnTouchDown = true; + // Set the default anchor point setIsRelativeAnchorPoint(true); setAnchorPoint(ccp(0.5f, 0.5f)); @@ -185,12 +188,51 @@ void CCControlButton::setIsHighlighted(bool enabled) stopAction(action); } needsLayout(); - - float scaleValue = (getIsHighlighted() && getIsEnabled() && !getIsSelected()) ? 1.1f : 1.0f; - CCAction *zoomAction =CCScaleTo::actionWithDuration(0.05f, scaleValue); - zoomAction->setTag(kZoomActionTag); - runAction(zoomAction); + if( m_zoomOnTouchDown ) + { + float scaleValue = (getIsHighlighted() && getIsEnabled() && !getIsSelected()) ? 1.1f : 1.0f; + CCAction *zoomAction =CCScaleTo::actionWithDuration(0.05f, scaleValue); + zoomAction->setTag(kZoomActionTag); + runAction(zoomAction); + } } + +void CCControlButton::setZoomOnTouchDown(bool zoomOnTouchDown) +{ + m_zoomOnTouchDown = zoomOnTouchDown; +} + +bool CCControlButton::getZoomOnTouchDown() +{ + return m_zoomOnTouchDown; +} + +void CCControlButton::setPreferredSize(CCSize size) +{ + if(size.width == 0 && size.height == 0) + { + m_adjustBackgroundImage = true; + } + else + { + m_adjustBackgroundImage = false; + CCDictElement * item = NULL; + CCDICT_FOREACH(m_backgroundSpriteDispatchTable, item) + { + CCScale9Sprite* sprite = (CCScale9Sprite*)item->getObject(); + sprite->setPreferredSize(size); + } + + m_preferredSize = size; + } + needsLayout(); +} + +CCSize CCControlButton::getPreferredSize() +{ + return m_preferredSize; +} + void CCControlButton::setAdjustBackgroundImage(bool adjustBackgroundImage) { m_adjustBackgroundImage=adjustBackgroundImage; diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.h b/cocos2dx/extensions/CCControlExtension/CCControlButton.h index 056e9a89cc..75abd743d0 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.h @@ -53,6 +53,11 @@ protected: background will use the prefered size of the background image. */ CC_PROPERTY(bool, m_adjustBackgroundImage, AdjustBackgroundImage); + /** Adjust the button zooming on touchdown. Default value is YES. */ + CC_PROPERTY(bool, m_zoomOnTouchDown, ZoomOnTouchDown); + + /** The prefered size of the button, if label is larger it will be expanded. */ + CC_PROPERTY(CCSize, m_preferredSize, PreferredSize); /** The current title that is displayed on the button. */ CC_SYNTHESIZE_READONLY(CCString*, m_currentTitle, CurrentTitle); From 8dbe897755d952ae3338eebac520a8012f2b9afb Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Fri, 1 Jun 2012 11:59:10 -0700 Subject: [PATCH 055/257] CCLabelBMFont: Made fntFile a property. (According to: ffbdb60a5908f5baef227bb0365a0b2653a3a59a) --- cocos2dx/label_nodes/CCLabelBMFont.cpp | 13 +++++++++++-- cocos2dx/label_nodes/CCLabelBMFont.h | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index a6b4b7ae61..b29828f664 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -806,6 +806,8 @@ bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile, f { m_pConfiguration = FNTConfigLoadFile(fntFile); m_pConfiguration->retain(); + + m_pFntFile = fntFile; CCAssert( m_pConfiguration, "Error creating config for LabelBMFont"); texture = CCTextureCache::sharedTextureCache()->addImage(this->m_pConfiguration->m_sAtlasName.c_str()); @@ -852,8 +854,9 @@ CCLabelBMFont::CCLabelBMFont() CCLabelBMFont::~CCLabelBMFont() { - CC_SAFE_DELETE(m_sString); - CC_SAFE_RELEASE(m_pConfiguration); + CC_SAFE_DELETE(this->m_sString); + CC_SAFE_RELEASE(this->m_pConfiguration); + CC_SAFE_DELETE(this->m_pFntFile); } // LabelBMFont - Atlas generation @@ -1352,6 +1355,8 @@ void CCLabelBMFont::setWidth(float width) void CCLabelBMFont::setFntFile(const char *fntFile) { + CC_SAFE_DELETE(m_pFntFile); + this->m_pFntFile = fntFile; CCBMFontConfiguration * newConfiguration = FNTConfigLoadFile(fntFile); CCAssert(newConfiguration, printf("CCLabelBMFont: Impossible to create font. Please check file: '%@'", fntFile) ); @@ -1395,6 +1400,10 @@ float CCLabelBMFont::getLetterPosXRight( CCSprite* sp ) { return sp->getPosition().x * m_fScaleX + (sp->getContentSize().width * m_fScaleX * sp->getAnchorPoint().x); } +const char * CCLabelBMFont::getFntFile() +{ + return this->m_pFntFile; +} //LabelBMFont - Debug draw #if CC_LABELBMFONT_DEBUG_DRAW void CCLabelBMFont::draw() diff --git a/cocos2dx/label_nodes/CCLabelBMFont.h b/cocos2dx/label_nodes/CCLabelBMFont.h index 0d47868a2b..596eca535d 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.h +++ b/cocos2dx/label_nodes/CCLabelBMFont.h @@ -167,6 +167,7 @@ protected: bool m_bLineBreakWithoutSpaces; // offset of the texture atlas CCPoint m_tImageOffset; + const char * m_pFntFile; public: CCLabelBMFont(); @@ -208,6 +209,8 @@ public: virtual void setScaleX(float scaleX); virtual void setScaleY(float scaleY); + virtual const char * getFntFile(); + #if CC_LABELBMFONT_DEBUG_DRAW virtual void draw(); #endif // CC_LABELBMFONT_DEBUG_DRAW From 18fba1664de4806b59a8ab35b4974d7cc639f4df Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Fri, 1 Jun 2012 12:29:48 -0700 Subject: [PATCH 056/257] CCControlButton: Added getters and setters for backgroundspriteframe, titlettf, titlettfsize, titleBMGont. Added ZoomOnTouchDown property. (According to: https://github.com/YannickL/CCControlExtension/ : 9dfb9d97a5fe729115b461d9a52ebc36aba51c72, b31256ad6b26e7f645719f203f0e72d717e68c75, 7a79cd702d4ccb958281bcec5d8a7658723f7c2a, c4bbcb9beb2febfb4b55323709e30082af902c90, d4a88349e1f60100225d49e43af587dc10def66f) --- .../CCControlExtension/CCControlButton.cpp | 143 +++++++++++++++++- .../CCControlExtension/CCControlButton.h | 33 +++- 2 files changed, 169 insertions(+), 7 deletions(-) diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp index d84cd089bf..0cd8b80aca 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp @@ -28,6 +28,7 @@ #include "CCScale9Sprite.h" #include "CCPointExtension.h" #include "CCLabelTTF.h" +#include "CCLabelBMFont.h" #include "CCAction.h" #include "CCActionInterval.h" @@ -50,6 +51,11 @@ CCControlButton::~CCControlButton() //initialisers +bool CCControlButton::init() +{ + return this->initWithLabelAndBackgroundSprite(CCLabelTTF::labelWithString("", "Helvetica", 12), CCScale9Sprite::node()); +} + bool CCControlButton::initWithLabelAndBackgroundSprite(CCNode* node, CCScale9Sprite* backgroundSprite) { @@ -62,6 +68,7 @@ bool CCControlButton::initWithLabelAndBackgroundSprite(CCNode* node, CCScale9Spr setIsTouchEnabled(true); pushed=false; + m_zoomOnTouchDown = true; m_nState=CCControlStateInitial; m_currentTitle=NULL; m_backgroundSprite=NULL; @@ -186,10 +193,13 @@ void CCControlButton::setIsHighlighted(bool enabled) } needsLayout(); - float scaleValue = (getIsHighlighted() && getIsEnabled() && !getIsSelected()) ? 1.1f : 1.0f; - CCAction *zoomAction =CCScaleTo::actionWithDuration(0.05f, scaleValue); - zoomAction->setTag(kZoomActionTag); - runAction(zoomAction); + if(m_zoomOnTouchDown) + { + float scaleValue = (getIsHighlighted() && getIsEnabled() && !getIsSelected()) ? 1.1f : 1.0f; + CCAction *zoomAction =CCScaleTo::actionWithDuration(0.05f, scaleValue); + zoomAction->setTag(kZoomActionTag); + runAction(zoomAction); + } } void CCControlButton::setAdjustBackgroundImage(bool adjustBackgroundImage) { @@ -202,6 +212,36 @@ bool CCControlButton::getAdjustBackgroundImage() return m_adjustBackgroundImage; } +CCSize CCControlButton::getPreferredSize() +{ + return this->m_preferredSize; +} + +void CCControlButton::setPreferredSize(CCSize preferredSize) +{ + if (preferredSize.width == 0 && preferredSize.height == 0) + { + this->m_adjustBackgroundImage = true; + } + else + { + this->m_adjustBackgroundImage = false; + + // TODO Was: "for (id key in backgroundSpriteDispatchTable_)" + CCDictElement * key = NULL; + CCDICT_FOREACH(m_backgroundSpriteDispatchTable, key) + { + int i = 0; // TODO + //CCScale9Sprite * sprite = m_backgroundSpriteDispatchTable->objectForKey(key); + //sprite->setPreferredSize(preferredSize); + } + } + + this->m_preferredSize = preferredSize; + + this->needsLayout(); +} + CCString* CCControlButton::getTitleForState(CCControlState state) { CCString* title=(CCString*)m_titleDispatchTable->objectForKey(state); @@ -289,6 +329,75 @@ void CCControlButton::setTitleLabelForState(CCNode* titleLabel, CCControlState s } } +void CCControlButton::setTitleTTFForState(const char * fntFile, CCControlState state) +{ + CCString * title = this->getTitleForState(state); + if (!title) title = new CCString(""); + this->setTitleLabelForState(CCLabelTTF::labelWithString(title->getCString(), fntFile, 12), state); +} + +const char * CCControlButton::getTitleTTFForState(CCControlState state) +{ + CCLabelProtocol* label = dynamic_cast(this->getTitleLabelForState(state)); + CCLabelTTF* labelTTF = dynamic_cast(label); + if(labelTTF != 0) + { + return labelTTF->getFontName(); + } + else + { + return ""; + } +} + +void CCControlButton::setTitleTTFSizeForState(float size, CCControlState state) +{ + CCLabelProtocol* label = dynamic_cast(this->getTitleLabelForState(state)); + if(label) + { + CCLabelTTF* labelTTF = dynamic_cast(label); + if(labelTTF != 0) + { + return labelTTF->setFontSize(size); + } + } +} + +float CCControlButton::getTitleTTFSizeForState(CCControlState state) +{ + CCLabelProtocol* label = dynamic_cast(this->getTitleLabelForState(state)); + CCLabelTTF* labelTTF = dynamic_cast(label); + if(labelTTF != 0) + { + return labelTTF->getFontSize(); + } + else + { + return 0; + } +} + +void CCControlButton::setTitleBMFontForState(const char * fntFile, CCControlState state) +{ + CCString * title = this->getTitleForState(state); + if (!title) title = new CCString(""); + this->setTitleLabelForState(CCLabelBMFont::labelWithString(title->getCString(), fntFile), state); +} + +const char * CCControlButton::getTitleBMFontForState(CCControlState state) +{ + CCLabelProtocol* label = dynamic_cast(this->getTitleLabelForState(state)); + CCLabelBMFont* labelBMFont = dynamic_cast(label); + if(labelBMFont != 0) + { + return labelBMFont->getFntFile(); + } + else + { + return ""; + } +} + CCScale9Sprite* CCControlButton::getBackgroundSpriteForState(CCControlState state) { @@ -307,7 +416,7 @@ void CCControlButton::setBackgroundSpriteForState(CCScale9Sprite* sprite, CCCont if (previousSprite) { removeChild(previousSprite, true); - m_backgroundSpriteDispatchTable->removeObjectForKey(state); + m_backgroundSpriteDispatchTable->removeObjectForKey(state); } m_backgroundSpriteDispatchTable->setObject(sprite, state); @@ -315,6 +424,11 @@ void CCControlButton::setBackgroundSpriteForState(CCScale9Sprite* sprite, CCCont sprite->setAnchorPoint(ccp(0.5f, 0.5f)); addChild(sprite); + if (this->m_preferredSize.width != 0 || this->m_preferredSize.height != 0) + { + sprite->setPreferredSize(this->m_preferredSize); + } + // If the current state if equal to the given state we update the layout if (getState() == state) { @@ -322,6 +436,13 @@ void CCControlButton::setBackgroundSpriteForState(CCScale9Sprite* sprite, CCCont } } +void CCControlButton::setBackgroundSpriteFrameForState(CCSpriteFrame * spriteFrame, CCControlState state) +{ + CCScale9Sprite * sprite = CCScale9Sprite::spriteWithSpriteFrame(spriteFrame); + this->setBackgroundSpriteForState(sprite, state); +} + + void CCControlButton::needsLayout() { // Hide the background and the label @@ -462,4 +583,16 @@ void CCControlButton::ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent) sendActionsForControlEvents(CCControlEventTouchCancel); } +CCControlButton * CCControlButton::node() +{ + CCControlButton *pControlButton = new CCControlButton(); + if (pControlButton && pControlButton->init()) + { + pControlButton->autorelease(); + return pControlButton; + } + CC_SAFE_DELETE(pControlButton); + return NULL; +} + NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.h b/cocos2dx/extensions/CCControlExtension/CCControlButton.h index 056e9a89cc..ecc62e3bd5 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.h @@ -51,9 +51,12 @@ protected: /** Adjust the background image. YES by default. If the property is set to NO, the background will use the prefered size of the background image. */ - CC_PROPERTY(bool, m_adjustBackgroundImage, AdjustBackgroundImage); + CC_PROPERTY(bool, m_adjustBackgroundImage, AdjustBackgroundImage); + + CC_PROPERTY(CCSize, m_preferredSize, PreferredSize); + + CC_SYNTHESIZE(bool, m_zoomOnTouchDown, ZoomOnTouchDown); - /** The current title that is displayed on the button. */ CC_SYNTHESIZE_READONLY(CCString*, m_currentTitle, CurrentTitle); /** The current color used to display the title. */ @@ -85,6 +88,7 @@ protected: public: + virtual bool init(); virtual bool initWithLabelAndBackgroundSprite(CCNode* label, CCScale9Sprite* backgroundSprite); static CCControlButton* buttonWithLabelAndBackgroundSprite(CCNode* label, CCScale9Sprite* backgroundSprite); @@ -162,6 +166,21 @@ public: */ virtual void setTitleLabelForState(CCNode* label, CCControlState state); + virtual void setTitleTTFForState(const char * fntFile, CCControlState state); + virtual const char * getTitleTTFForState(CCControlState state); + + virtual void setTitleTTFSizeForState(float size, CCControlState state); + virtual float getTitleTTFSizeForState(CCControlState state); + + /** + * Sets the font of the label, changes the label to a CCLabelBMFont if neccessary. + * @param fntFile The name of the font to change to + * @param state The state that uses the specified fntFile. The values are described + * in "CCControlState". + */ + virtual void setTitleBMFontForState(const char * fntFile, CCControlState state); + virtual const char * getTitleBMFontForState(CCControlState state); + /** * Returns the background sprite used for a state. * @@ -179,6 +198,16 @@ public: */ virtual void setBackgroundSpriteForState(CCScale9Sprite* sprite, CCControlState state); + /** + * Sets the background spriteFrame to use for the specified button state. + * + * @param spriteFrame The background spriteFrame to use for the specified state. + * @param state The state that uses the specified image. The values are described + * in "CCControlState". + */ + virtual void setBackgroundSpriteFrameForState(CCSpriteFrame * spriteFrame, CCControlState state); + + static CCControlButton * node(); }; NS_CC_EXT_END From 9576db1e2807a60b07b8b7514a2d38f88436f601 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Fri, 1 Jun 2012 15:10:20 -0700 Subject: [PATCH 057/257] CCControlButton: Added LabelAnchorPoint property. (According to: https://github.com/YannickL/CCControlExtension/ : 623f10433a088140adbb1e1d7d6c97e1ae05adf9) --- .../CCControlExtension/CCControlButton.cpp | 26 +++++++++++++++---- .../CCControlExtension/CCControlButton.h | 1 + 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp index 0cd8b80aca..a8d52028b2 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp @@ -116,6 +116,8 @@ bool CCControlButton::initWithLabelAndBackgroundSprite(CCNode* node, CCScale9Spr m_marginH=24; m_marginV=12; + this->m_labelAnchorPoint = CCPoint(0.5f, 0.5f); + // Layout update needsLayout(); @@ -228,12 +230,11 @@ void CCControlButton::setPreferredSize(CCSize preferredSize) this->m_adjustBackgroundImage = false; // TODO Was: "for (id key in backgroundSpriteDispatchTable_)" - CCDictElement * key = NULL; - CCDICT_FOREACH(m_backgroundSpriteDispatchTable, key) + CCDictElement * element = NULL; + CCDICT_FOREACH(m_backgroundSpriteDispatchTable, element) { - int i = 0; // TODO - //CCScale9Sprite * sprite = m_backgroundSpriteDispatchTable->objectForKey(key); - //sprite->setPreferredSize(preferredSize); + CCScale9Sprite * sprite = dynamic_cast(m_backgroundSpriteDispatchTable->objectForKey(element->getIntKey())); + sprite->setPreferredSize(preferredSize); } } @@ -242,6 +243,18 @@ void CCControlButton::setPreferredSize(CCSize preferredSize) this->needsLayout(); } +CCPoint CCControlButton::getLabelAnchorPoint() +{ + return this->m_labelAnchorPoint; +} + +void CCControlButton::setLabelAnchorPoint(CCPoint labelAnchorPoint) +{ + this->m_labelAnchorPoint = labelAnchorPoint; + + this->m_titleLabel->setAnchorPoint(labelAnchorPoint); +} + CCString* CCControlButton::getTitleForState(CCControlState state) { CCString* title=(CCString*)m_titleDispatchTable->objectForKey(state); @@ -448,6 +461,9 @@ void CCControlButton::needsLayout() // Hide the background and the label m_titleLabel->setIsVisible(false); m_backgroundSprite->setIsVisible(false); + + // Update anchor of all labels + this->setLabelAnchorPoint(this->m_labelAnchorPoint); // Update the label to match with the current state //CC_SAFE_RELEASE(m_currentTitle) diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.h b/cocos2dx/extensions/CCControlExtension/CCControlButton.h index ecc62e3bd5..22af8ef30c 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.h @@ -54,6 +54,7 @@ protected: CC_PROPERTY(bool, m_adjustBackgroundImage, AdjustBackgroundImage); CC_PROPERTY(CCSize, m_preferredSize, PreferredSize); + CC_PROPERTY(CCPoint, m_labelAnchorPoint, LabelAnchorPoint); CC_SYNTHESIZE(bool, m_zoomOnTouchDown, ZoomOnTouchDown); From eee8ba758616840a4eba12ee95f8c6fd11213441 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Fri, 1 Jun 2012 15:11:16 -0700 Subject: [PATCH 058/257] CCLabelTTF: Added getters for fontName and fontSize. --- cocos2dx/label_nodes/CCLabelTTF.cpp | 8 ++++++++ cocos2dx/label_nodes/CCLabelTTF.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/cocos2dx/label_nodes/CCLabelTTF.cpp b/cocos2dx/label_nodes/CCLabelTTF.cpp index 7ddcf9632d..20b03b5b1e 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.cpp +++ b/cocos2dx/label_nodes/CCLabelTTF.cpp @@ -133,6 +133,10 @@ bool CCLabelTTF::initWithString(const char *label, const char *fontName, float f } return false; } +const char * CCLabelTTF::getFontName() +{ + return this->m_pFontName->c_str(); +} void CCLabelTTF::setFontName(const char *fontName) { if(this->m_pFontName == NULL || strcmp(this->m_pFontName->c_str(), fontName)) @@ -143,6 +147,10 @@ void CCLabelTTF::setFontName(const char *fontName) this->setString(this->m_pString->c_str()); } } +float CCLabelTTF::getFontSize() +{ + return this->m_fFontSize; +} void CCLabelTTF::setFontSize(float fontSize) { if(this->m_fFontSize != fontSize) diff --git a/cocos2dx/label_nodes/CCLabelTTF.h b/cocos2dx/label_nodes/CCLabelTTF.h index 6c15587528..65bea47cea 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.h +++ b/cocos2dx/label_nodes/CCLabelTTF.h @@ -60,7 +60,9 @@ public: */ virtual void setString(const char *label); virtual const char* getString(void); + virtual const char* getFontName(); virtual void setFontName(const char *fontName); + virtual float getFontSize(); virtual void setFontSize(float fontSize); virtual void setDimensions(CCSize dim); virtual void setHorizontalAlignment(CCTextAlignment); From 67d9b8ea25b2079ad18c77666a9cf1fede81423d Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Fri, 1 Jun 2012 15:11:42 -0700 Subject: [PATCH 059/257] Minor changes. --- cocos2dx/sprite_nodes/CCSprite.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index bf9bfe13cd..19ada1c3d3 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -144,12 +144,10 @@ CCSprite* CCSprite::node() if (pSprite && pSprite->init()) { pSprite->autorelease(); + return pSprite; } - else - { - CC_SAFE_DELETE(pSprite); - } - return pSprite; + CC_SAFE_DELETE(pSprite); + return NULL; } bool CCSprite::init(void) From 9951ba8ad21b9273886416e2c59cc2d48a08d999 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Fri, 1 Jun 2012 15:12:07 -0700 Subject: [PATCH 060/257] Minor changes. --- cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp b/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp index 9ddd481882..559f357361 100644 --- a/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp @@ -8,6 +8,7 @@ using namespace cocos2d::extension; void CCMenuItemLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, std::string pPropertyName, void * pBlock, CCBReader * pCCBReader) { if(pPropertyName.compare(PROPERTY_BLOCK) == 0) { + // TODO selector thingy... // ((CCMenuItem *)pNode)->setTarget(???, ???); } else { CCNodeLoader::onHandlePropTypeBlock(pNode, pParent, pPropertyName, pBlock, pCCBReader); From 2340c93c17e970c137beabc4c31b98ccfdb0031e Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Fri, 1 Jun 2012 15:13:16 -0700 Subject: [PATCH 061/257] Fixed CCNodeLoader::parsePropTypeSpriteFrame not trying to load 'null' sprites/spritesheets. Also minor renaming. --- cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp index bc07d19997..918fea0be7 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp @@ -418,6 +418,9 @@ CCSpriteFrame * CCNodeLoader::parsePropTypeSpriteFrame(CCNode * pNode, CCNode * CCSpriteFrame * spriteFrame; if (spriteSheet.compare("") == 0) { + if (spriteFile.compare("") == 0) { + return NULL; + } CCTexture2D * texture = CCTextureCache::sharedTextureCache()->addImage(spriteFile.c_str()); CCRect bounds = CCRect::CCRect(0, 0, texture->getContentSize().width, texture->getContentSize().height); spriteFrame = CCSpriteFrame::frameWithTexture(texture, bounds); @@ -797,7 +800,7 @@ void CCNodeLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, std:: ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, std::string pPropertyName, void * pBlock, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, std::string pPropertyName, void * pBlockCCControl, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } From 43682e68578be5a2fc1a34e5628c7d6458bbe610 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Fri, 1 Jun 2012 15:14:18 -0700 Subject: [PATCH 062/257] Added CControlLoader and CCControlButtonLoader. --- cocos2dx/extensions/CCBIReader/CCBReader.cpp | 2 + .../CCBIReader/CCControlButtonLoader.cpp | 117 ++++++++++++++++++ .../CCBIReader/CCControlButtonLoader.h | 27 ++++ .../extensions/CCBIReader/CCControlLoader.cpp | 27 ++++ .../extensions/CCBIReader/CCControlLoader.h | 21 ++++ 5 files changed, 194 insertions(+) create mode 100644 cocos2dx/extensions/CCBIReader/CCControlButtonLoader.cpp create mode 100644 cocos2dx/extensions/CCBIReader/CCControlButtonLoader.h create mode 100644 cocos2dx/extensions/CCBIReader/CCControlLoader.cpp create mode 100644 cocos2dx/extensions/CCBIReader/CCControlLoader.h diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.cpp b/cocos2dx/extensions/CCBIReader/CCBReader.cpp index 87d06f7409..b04e1f6cc5 100644 --- a/cocos2dx/extensions/CCBIReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCBReader.cpp @@ -12,6 +12,7 @@ #include "CCMenuLoader.h" #include "CCMenuItemLoader.h" #include "CCMenuItemImageLoader.h" +#include "CCControlButtonLoader.h" using namespace cocos2d; using namespace cocos2d::extension; @@ -28,6 +29,7 @@ CCBReader::CCBReader() { this->registerCCNodeLoader("CCBFile", new CCBFileLoader()); this->registerCCNodeLoader("CCMenu", new CCMenuLoader()); this->registerCCNodeLoader("CCMenuItemImage", new CCMenuItemImageLoader()); + this->registerCCNodeLoader("CCControlButton", new CCControlButtonLoader()); } CCBReader::~CCBReader() { diff --git a/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.cpp b/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.cpp new file mode 100644 index 0000000000..cf22f7d542 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.cpp @@ -0,0 +1,117 @@ +#import "CCControlButtonLoader.h" + +using namespace cocos2d; +using namespace cocos2d::extension; + +#define PROPERTY_ZOOMONTOUCHDOWN "zoomOnTouchDown" +#define PROPERTY_TITLE_NORMAL "title|1" +#define PROPERTY_TITLE_HIGHLIGHTED "title|2" +#define PROPERTY_TITLE_DISABLED "title|3" +#define PROPERTY_TITLECOLOR_NORMAL "titleColor|1" +#define PROPERTY_TITLECOLOR_HIGHLIGHTED "titleColor|2" +#define PROPERTY_TITLECOLOR_DISABLED "titleColor|3" +#define PROPERTY_TITLETTF_NORMAL "titleTTF|1" +#define PROPERTY_TITLETTF_HIGHLIGHTED "titleTTF|2" +#define PROPERTY_TITLETTF_DISABLED "titleTTF|3" +#define PROPERTY_TITLETTFSIZE_NORMAL "titleTTFSize|1" +#define PROPERTY_TITLETTFSIZE_HIGHLIGHTED "titleTTFSize|2" +#define PROPERTY_TITLETTFSIZE_DISABLED "titleTTFSize|3" +#define PROPERTY_LABELANCHORPOINT "labelAnchorPoint" +#define PROPERTY_PREFEREDSIZE "preferedSize" // TODO Should be "preferredSize". This is a typo in cocos2d-iphone, cocos2d-x and CocosBuilder! +#define PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL "backgroundSpriteFrame|1" +#define PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED "backgroundSpriteFrame|2" +#define PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED "backgroundSpriteFrame|3" + +CCControl * CCControlButtonLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { + return CCControlButton::node(); +} + +void CCControlButtonLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, std::string pPropertyName, bool pCheck, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_ZOOMONTOUCHDOWN) == 0) { + ((CCControlButton *)pNode)->setZoomOnTouchDown(pCheck); + } else { + CCControlLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader); + } +} + +void CCControlButtonLoader::onHandlePropTypeString(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pString, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_TITLE_NORMAL) == 0) { + ((CCControlButton *)pNode)->setTitleForState(new CCString(pString), CCControlStateNormal); // TODO Leak? + } else if(pPropertyName.compare(PROPERTY_TITLE_HIGHLIGHTED) == 0) { + ((CCControlButton *)pNode)->setTitleForState(new CCString(pString), CCControlStateHighlighted); // TODO Leak? + } else if(pPropertyName.compare(PROPERTY_TITLE_DISABLED) == 0) { + ((CCControlButton *)pNode)->setTitleForState(new CCString(pString), CCControlStateDisabled); // TODO Leak? + } else { + CCControlLoader::onHandlePropTypeString(pNode, pParent, pPropertyName, pString, pCCBReader); + } +} + +void CCControlButtonLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pFontTTF, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_TITLETTF_NORMAL) == 0) { + ((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF.c_str(), CCControlStateNormal); + } else if(pPropertyName.compare(PROPERTY_TITLETTF_HIGHLIGHTED) == 0) { + ((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF.c_str(), CCControlStateHighlighted); + } else if(pPropertyName.compare(PROPERTY_TITLETTF_DISABLED) == 0) { + ((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF.c_str(), CCControlStateDisabled); + } else { + CCControlLoader::onHandlePropTypeFontTTF(pNode, pParent, pPropertyName, pFontTTF, pCCBReader); + } +} + +void CCControlButtonLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float pFloatScale, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_TITLETTFSIZE_NORMAL) == 0) { + ((CCControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, CCControlStateNormal); + } else if(pPropertyName.compare(PROPERTY_TITLETTFSIZE_HIGHLIGHTED) == 0) { + ((CCControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, CCControlStateHighlighted); + } else if(pPropertyName.compare(PROPERTY_TITLETTFSIZE_DISABLED) == 0) { + ((CCControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, CCControlStateDisabled); + } else { + CCControlLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pFloatScale, pCCBReader); + } +} + +void CCControlButtonLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_LABELANCHORPOINT) == 0) { + ((CCControlButton *)pNode)->setLabelAnchorPoint(pPoint); + } else { + CCControlLoader::onHandlePropTypePoint(pNode, pParent, pPropertyName, pPoint, pCCBReader); + } +} + +void CCControlButtonLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSize pSize, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_PREFEREDSIZE) == 0) { + ((CCControlButton *)pNode)->setPreferredSize(pSize); + } else { + CCControlLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, pCCBReader); + } +} + +void CCControlButtonLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL) == 0) { + if(pCCSpriteFrame != NULL) { + ((CCControlButton *)pNode)->setBackgroundSpriteFrameForState(pCCSpriteFrame, CCControlStateNormal); + } + } else if(pPropertyName.compare(PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED) == 0) { + if(pCCSpriteFrame != NULL) { + ((CCControlButton *)pNode)->setBackgroundSpriteFrameForState(pCCSpriteFrame, CCControlStateHighlighted); + } + } else if(pPropertyName.compare(PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED) == 0) { + if(pCCSpriteFrame != NULL) { + ((CCControlButton *)pNode)->setBackgroundSpriteFrameForState(pCCSpriteFrame, CCControlStateDisabled); + } + } else { + CCControlLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pCCSpriteFrame, pCCBReader); + } +} + +void CCControlButtonLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_TITLECOLOR_NORMAL) == 0) { + ((CCControlButton *)pNode)->setTitleColorForState(pCCColor3B, CCControlStateNormal); + } else if(pPropertyName.compare(PROPERTY_TITLECOLOR_HIGHLIGHTED) == 0) { + ((CCControlButton *)pNode)->setTitleColorForState(pCCColor3B, CCControlStateHighlighted); + } else if(pPropertyName.compare(PROPERTY_TITLECOLOR_DISABLED) == 0) { + ((CCControlButton *)pNode)->setTitleColorForState(pCCColor3B, CCControlStateDisabled); + } else { + CCControlLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); + } +} \ No newline at end of file diff --git a/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.h b/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.h new file mode 100644 index 0000000000..b98f99a39e --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.h @@ -0,0 +1,27 @@ +#ifndef _CCCONTROLBUTTON_LOADER_H_ +#define _CCCONTROLBUTTON_LOADER_H_ + +#include "CCControlLoader.h" + +NS_CC_EXT_BEGIN + +/* Forward declaration. */ +class CCBReader; + +class CCControlButtonLoader : public CCControlLoader { + protected: + virtual CCControl * createCCNode(CCNode *, CCBReader *); + + virtual void onHandlePropTypeCheck(CCNode *, CCNode *, std::string, bool, CCBReader *); + virtual void onHandlePropTypeString(CCNode *, CCNode *, std::string, std::string, CCBReader *); + virtual void onHandlePropTypeFontTTF(CCNode *, CCNode *, std::string, std::string, CCBReader *); + virtual void onHandlePropTypeFloatScale(CCNode *, CCNode *, std::string, float, CCBReader *); + virtual void onHandlePropTypePoint(CCNode *, CCNode *, std::string, CCPoint, CCBReader *); + virtual void onHandlePropTypeSize(CCNode *, CCNode *, std::string, CCSize, CCBReader *); + virtual void onHandlePropTypeSpriteFrame(CCNode *, CCNode *, std::string, CCSpriteFrame *, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode *, CCNode *, std::string, ccColor3B, CCBReader *); +}; + +NS_CC_EXT_END + +#endif diff --git a/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp b/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp new file mode 100644 index 0000000000..ef022533d3 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp @@ -0,0 +1,27 @@ +#import "CCControlLoader.h" + +using namespace cocos2d; +using namespace cocos2d::extension; + +#define PROPERTY_ENABLED "enabled" +#define PROPERTY_SELECTED "selected" +#define PROPERTY_CCCONTROL "ccControl" + +void CCControlLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, std::string pPropertyName, bool pCheck, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_ENABLED) == 0) { + ((CCControl *)pNode)->setIsEnabled(pCheck); + } else if(pPropertyName.compare(PROPERTY_SELECTED) == 0) { + ((CCControl *)pNode)->setIsSelected(pCheck); + } else { + CCNodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader); + } +} + +void CCControlLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, std::string pPropertyName, void * pBlockCCControl, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_CCCONTROL) == 0) { + // TODO selector thingy... + // ((CCControl *)pNode)->setTarget(???, ???); + } else { + CCNodeLoader::onHandlePropTypeBlockCCControl(pNode, pParent, pPropertyName, pBlockCCControl, pCCBReader); + } +} \ No newline at end of file diff --git a/cocos2dx/extensions/CCBIReader/CCControlLoader.h b/cocos2dx/extensions/CCBIReader/CCControlLoader.h new file mode 100644 index 0000000000..b7e292e944 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCControlLoader.h @@ -0,0 +1,21 @@ +#ifndef _CCCONTROL_LOADER_H_ +#define _CCCONTROL_LOADER_H_ + +#include "CCNodeLoader.h" + +NS_CC_EXT_BEGIN + +/* Forward declaration. */ +class CCBReader; + +class CCControlLoader : public CCNodeLoader { + protected: + virtual CCControl * createCCNode(CCNode *, CCBReader *) = 0; + + virtual void onHandlePropTypeBlockCCControl(CCNode *, CCNode *, std::string, void *, CCBReader *); + virtual void onHandlePropTypeCheck(CCNode *, CCNode *, std::string, bool, CCBReader *); +}; + +NS_CC_EXT_END + +#endif From 8576837e5e5d1fbd40c355c8d29b96bc2d371102 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Fri, 1 Jun 2012 16:38:43 -0700 Subject: [PATCH 063/257] CCParticleSystemQuad: Added CCParticleSystemQuad::node(). --- cocos2dx/particle_nodes/CCParticleSystemQuad.cpp | 11 +++++++++++ cocos2dx/particle_nodes/CCParticleSystemQuad.h | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp index ce5220fb5c..cfa563ccac 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp @@ -562,4 +562,15 @@ void CCParticleSystemQuad::setBatchNode(CCParticleBatchNode * batchNode) } } +CCParticleSystemQuad * CCParticleSystemQuad::node() { + CCParticleSystemQuad *pParticleSystemQuad = new CCParticleSystemQuad(); + if (pParticleSystemQuad && pParticleSystemQuad->init()) + { + pParticleSystemQuad->autorelease(); + return pParticleSystemQuad; + } + CC_SAFE_DELETE(pParticleSystemQuad); + return NULL; +} + NS_CC_END diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.h b/cocos2dx/particle_nodes/CCParticleSystemQuad.h index 9e1a2c8b29..01ac720754 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.h +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.h @@ -2,7 +2,7 @@ Copyright (c) 2010-2011 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Leonardo KasperaviÄius -Copyright (c) 2011 ynga Inc. +Copyright (c) 2011 Zynga Inc. http://www.cocos2d-x.org @@ -96,6 +96,8 @@ public: /** listen the event that coming to foreground on Android */ void listenBackToForeground(CCObject *obj); + + static CCParticleSystemQuad * node(); private: #if CC_TEXTURE_ATLAS_USE_VAO void setupVBOandVAO(); From bb49eaebe9f24809076f745b834085955cbe0787 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Fri, 1 Jun 2012 16:45:30 -0700 Subject: [PATCH 064/257] Added CCParticleSystemQuadLoader. --- cocos2dx/extensions/CCBIReader/CCBReader.cpp | 2 + .../extensions/CCBIReader/CCNodeLoader.cpp | 4 +- .../CCBIReader/CCParticleSystemQuadLoader.cpp | 137 ++++++++++++++++++ .../CCBIReader/CCParticleSystemQuadLoader.h | 27 ++++ 4 files changed, 168 insertions(+), 2 deletions(-) create mode 100644 cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.cpp create mode 100644 cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.h diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.cpp b/cocos2dx/extensions/CCBIReader/CCBReader.cpp index b04e1f6cc5..22bcd32352 100644 --- a/cocos2dx/extensions/CCBIReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCBReader.cpp @@ -13,6 +13,7 @@ #include "CCMenuItemLoader.h" #include "CCMenuItemImageLoader.h" #include "CCControlButtonLoader.h" +#include "CCParticleSystemQuadLoader.h" using namespace cocos2d; using namespace cocos2d::extension; @@ -30,6 +31,7 @@ CCBReader::CCBReader() { this->registerCCNodeLoader("CCMenu", new CCMenuLoader()); this->registerCCNodeLoader("CCMenuItemImage", new CCMenuItemImageLoader()); this->registerCCNodeLoader("CCControlButton", new CCControlButtonLoader()); + this->registerCCNodeLoader("CCParticleSystemQuad", new CCParticleSystemQuadLoader()); } CCBReader::~CCBReader() { diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp index 918fea0be7..f4a623f091 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp @@ -9,7 +9,7 @@ #define PROPERTY_IGNOREANCHORPOINTFORPOSITION "ignoreAnchorPointForPosition" #define PROPERTY_VISIBLE "visible" -#define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) printf("Unexpected property type: '%s'!\n", PROPERTY.c_str()); assert(false) +#define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) printf("Unexpected property: '%s'!\n", PROPERTY.c_str()); assert(false) #define ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) printf("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false) using namespace cocos2d; @@ -463,7 +463,7 @@ CCAnimation * CCNodeLoader::parsePropTypeAnimation(CCNode * pNode, CCNode * pPar CCTexture2D * CCNodeLoader::parsePropTypeTexture(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { std::string spriteFile = pCCBReader->readCachedString(); - + return CCTextureCache::sharedTextureCache()->addImage(spriteFile.c_str()); } diff --git a/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.cpp b/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.cpp new file mode 100644 index 0000000000..fd37bcce37 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.cpp @@ -0,0 +1,137 @@ +#import "CCParticleSystemQuadLoader.h" + +using namespace cocos2d; +using namespace cocos2d::extension; + +#define PROPERTY_EMITERMODE "emitterMode" +#define PROPERTY_POSVAR "posVar" +#define PROPERTY_EMISSIONRATE "emissionRate" +#define PROPERTY_DURATION "duration" +#define PROPERTY_TOTALPARTICLES "totalParticles" +#define PROPERTY_LIFE "life" +#define PROPERTY_STARTSIZE "startSize" +#define PROPERTY_ENDSIZE "endSize" +#define PROPERTY_STARTSPIN "startSpin" +#define PROPERTY_ENDSPIN "endSpin" +#define PROPERTY_ANGLE "angle" +#define PROPERTY_STARTCOLOR "startColor" +#define PROPERTY_ENDCOLOR "endColor" +#define PROPERTY_BLENDFUNC "blendFunc" +#define PROPERTY_GRAVITY "gravity" +#define PROPERTY_SPEED "speed" +#define PROPERTY_TANGENTIALACCEL "tangentialAccel" +#define PROPERTY_RADIALACCEL "radialAccel" +#define PROPERTY_TEXTURE "texture" +#define PROPERTY_STARTRADIUS "startRadius" +#define PROPERTY_ENDRADIUS "endRadius" +#define PROPERTY_ROTATEPERSECOND "rotatePerSecond" + +CCParticleSystemQuad * CCParticleSystemQuadLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { + return CCParticleSystemQuad::node(); +} + +void CCParticleSystemQuadLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, std::string pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_EMITERMODE) == 0) { + ((CCParticleSystemQuad *)pNode)->setEmitterMode(pIntegerLabeled); + } else { + CCNodeLoader::onHandlePropTypeIntegerLabeled(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader); + } +} + +void CCParticleSystemQuadLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_POSVAR) == 0) { + ((CCParticleSystemQuad *)pNode)->setPosVar(pPoint); + } else if(pPropertyName.compare(PROPERTY_GRAVITY) == 0) { + ((CCParticleSystemQuad *)pNode)->setGravity(pPoint); + } else { + CCNodeLoader::onHandlePropTypePoint(pNode, pParent, pPropertyName, pPoint, pCCBReader); + } +} + +void CCParticleSystemQuadLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float pFloat, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_EMISSIONRATE) == 0) { + ((CCParticleSystemQuad *)pNode)->setEmissionRate(pFloat); + } else if(pPropertyName.compare(PROPERTY_DURATION) == 0) { + ((CCParticleSystemQuad *)pNode)->setDuration(pFloat); + } else { + CCNodeLoader::onHandlePropTypeFloat(pNode, pParent, pPropertyName, pFloat, pCCBReader); + } +} + +void CCParticleSystemQuadLoader::onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, std::string pPropertyName, int pInteger, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_TOTALPARTICLES) == 0) { + ((CCParticleSystemQuad *)pNode)->setTotalParticles(pInteger); + } else { + CCNodeLoader::onHandlePropTypeInteger(pNode, pParent, pPropertyName, pInteger, pCCBReader); + } +} + +void CCParticleSystemQuadLoader::onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float * pFloatVar, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_LIFE) == 0) { + ((CCParticleSystemQuad *)pNode)->setLife(pFloatVar[0]); + ((CCParticleSystemQuad *)pNode)->setLifeVar(pFloatVar[1]); + } else if(pPropertyName.compare(PROPERTY_STARTSIZE) == 0) { + ((CCParticleSystemQuad *)pNode)->setStartSize(pFloatVar[0]); + ((CCParticleSystemQuad *)pNode)->setStartSizeVar(pFloatVar[1]); + } else if(pPropertyName.compare(PROPERTY_ENDSIZE) == 0) { + ((CCParticleSystemQuad *)pNode)->setEndSize(pFloatVar[0]); + ((CCParticleSystemQuad *)pNode)->setEndSizeVar(pFloatVar[1]); + } else if(pPropertyName.compare(PROPERTY_STARTSPIN) == 0) { + ((CCParticleSystemQuad *)pNode)->setStartSpin(pFloatVar[0]); + ((CCParticleSystemQuad *)pNode)->setStartSpinVar(pFloatVar[1]); + } else if(pPropertyName.compare(PROPERTY_ENDSPIN) == 0) { + ((CCParticleSystemQuad *)pNode)->setEndSpin(pFloatVar[0]); + ((CCParticleSystemQuad *)pNode)->setEndSpinVar(pFloatVar[1]); + } else if(pPropertyName.compare(PROPERTY_ANGLE) == 0) { + ((CCParticleSystemQuad *)pNode)->setAngle(pFloatVar[0]); + ((CCParticleSystemQuad *)pNode)->setAngleVar(pFloatVar[1]); + } else if(pPropertyName.compare(PROPERTY_SPEED) == 0) { + ((CCParticleSystemQuad *)pNode)->setSpeed(pFloatVar[0]); + ((CCParticleSystemQuad *)pNode)->setSpeedVar(pFloatVar[1]); + } else if(pPropertyName.compare(PROPERTY_TANGENTIALACCEL) == 0) { + ((CCParticleSystemQuad *)pNode)->setTangentialAccel(pFloatVar[0]); + ((CCParticleSystemQuad *)pNode)->setTangentialAccelVar(pFloatVar[1]); + } else if(pPropertyName.compare(PROPERTY_RADIALACCEL) == 0) { + ((CCParticleSystemQuad *)pNode)->setRadialAccel(pFloatVar[0]); + ((CCParticleSystemQuad *)pNode)->setRadialAccelVar(pFloatVar[1]); + } else if(pPropertyName.compare(PROPERTY_STARTRADIUS) == 0) { + ((CCParticleSystemQuad *)pNode)->setStartRadius(pFloatVar[0]); + ((CCParticleSystemQuad *)pNode)->setStartRadiusVar(pFloatVar[1]); + } else if(pPropertyName.compare(PROPERTY_ENDRADIUS) == 0) { + ((CCParticleSystemQuad *)pNode)->setEndRadius(pFloatVar[0]); + ((CCParticleSystemQuad *)pNode)->setEndRadiusVar(pFloatVar[1]); + } else if(pPropertyName.compare(PROPERTY_ROTATEPERSECOND) == 0) { + ((CCParticleSystemQuad *)pNode)->setRotatePerSecond(pFloatVar[0]); + ((CCParticleSystemQuad *)pNode)->setRotatePerSecondVar(pFloatVar[1]); + } else { + CCNodeLoader::onHandlePropTypeFloatVar(pNode, pParent, pPropertyName, pFloatVar, pCCBReader); + } +} + +void CCParticleSystemQuadLoader::onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_STARTCOLOR) == 0) { + ((CCParticleSystemQuad *)pNode)->setStartColor(pCCColor4FVar[0]); + ((CCParticleSystemQuad *)pNode)->setStartColorVar(pCCColor4FVar[1]); + } else if(pPropertyName.compare(PROPERTY_ENDCOLOR) == 0) { + ((CCParticleSystemQuad *)pNode)->setEndColor(pCCColor4FVar[0]); + ((CCParticleSystemQuad *)pNode)->setEndColorVar(pCCColor4FVar[1]); + } else { + CCNodeLoader::onHandlePropTypeColor4FVar(pNode, pParent, pPropertyName, pCCColor4FVar, pCCBReader); + } +} + +void CCParticleSystemQuadLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_BLENDFUNC) == 0) { + ((CCParticleSystemQuad *)pNode)->setBlendFunc(pCCBlendFunc); + } else { + CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); + } +} + +void CCParticleSystemQuadLoader::onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader) { + if(pPropertyName.compare(PROPERTY_TEXTURE) == 0) { + ((CCParticleSystemQuad *)pNode)->setTexture(pCCTexture2D); + } else { + CCNodeLoader::onHandlePropTypeTexture(pNode, pParent, pPropertyName, pCCTexture2D, pCCBReader); + } +} \ No newline at end of file diff --git a/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.h b/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.h new file mode 100644 index 0000000000..8e46562ef0 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.h @@ -0,0 +1,27 @@ +#ifndef _CCPARTICLESYSTEMQUAD_LOADER_H_ +#define _CCPARTICLESYSTEMQUAD_LOADER_H_ + +#include "CCNodeLoader.h" + +NS_CC_EXT_BEGIN + +/* Forward declaration. */ +class CCBReader; + +class CCParticleSystemQuadLoader : public CCNodeLoader { + protected: + virtual CCParticleSystemQuad * createCCNode(CCNode *, CCBReader *); + + virtual void onHandlePropTypeIntegerLabeled(CCNode *, CCNode *, std::string, int, CCBReader *); + virtual void onHandlePropTypePoint(CCNode *, CCNode *, std::string, CCPoint, CCBReader *); + virtual void onHandlePropTypeFloat(CCNode *, CCNode *, std::string, float, CCBReader *); + virtual void onHandlePropTypeInteger(CCNode *, CCNode *, std::string, int, CCBReader *); + virtual void onHandlePropTypeFloatVar(CCNode *, CCNode *, std::string, float *, CCBReader *); + virtual void onHandlePropTypeColor4FVar(CCNode *, CCNode *, std::string, ccColor4F *, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeTexture(CCNode *, CCNode *, std::string, CCTexture2D *, CCBReader *); +}; + +NS_CC_EXT_END + +#endif From b17eeb4cb7b3c6be16f699daf0df898c5c400562 Mon Sep 17 00:00:00 2001 From: NatWeiss Date: Fri, 1 Jun 2012 17:53:47 -0700 Subject: [PATCH 065/257] Update AUTHORS --- AUTHORS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index bfc594d765..ef1ad64da1 100644 --- a/AUTHORS +++ b/AUTHORS @@ -87,7 +87,7 @@ Developers: fix the bug of asynchronous loading resources for iOS Nat Weiss - Fixes the declaration of tgaLoadRLEImageData() + Minor enhancements to the Cocos2D-X codebase and Android build scripts Retired Core Developers: WenSheng Yang From 1d59f0ced612ef01d786fe1a9ccbfcf6cc34dd9c Mon Sep 17 00:00:00 2001 From: minggo Date: Sun, 3 Jun 2012 09:45:51 +0800 Subject: [PATCH 066/257] Update AUTHORS --- AUTHORS | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS b/AUTHORS index bfc594d765..b0a638f300 100644 --- a/AUTHORS +++ b/AUTHORS @@ -88,6 +88,7 @@ Developers: Nat Weiss Fixes the declaration of tgaLoadRLEImageData() + make Android template's build_native.sh automatically copies new icons Retired Core Developers: WenSheng Yang From ddcd69c4534356c7c08200f1e36a7b658a848bf2 Mon Sep 17 00:00:00 2001 From: minggo Date: Sun, 3 Jun 2012 09:47:07 +0800 Subject: [PATCH 067/257] Update AUTHORS --- AUTHORS | 1 - 1 file changed, 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index b0a638f300..bfc594d765 100644 --- a/AUTHORS +++ b/AUTHORS @@ -88,7 +88,6 @@ Developers: Nat Weiss Fixes the declaration of tgaLoadRLEImageData() - make Android template's build_native.sh automatically copies new icons Retired Core Developers: WenSheng Yang From dc24094b5f7c54dca69beec06ba1fa8db006f7f6 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 4 Jun 2012 11:41:03 +0800 Subject: [PATCH 068/257] fixed #1290:use Shaders folder in correct way --- tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id index 6fb416ba08..4d6dee11db 100644 --- a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -14a32fb3ba86f267841b87b9a63e906ce7a64969 \ No newline at end of file +10a5824d2ea7fd21b1d844f95393c267a2c9f61e \ No newline at end of file From 6c5be5e56e97e0b6e04a08aed0f43acd35821fda Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Mon, 4 Jun 2012 15:30:03 -0700 Subject: [PATCH 069/257] CCScale9Sprite: Removed debug logging. --- cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp index 2e2a24fb4c..e702f3e2f6 100644 --- a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp @@ -204,9 +204,6 @@ void CCScale9Sprite::updatePositions() { CCSize size = this->m_tContentSize; - CCLOG("scale9 set content size %0.2f %0.2f",size.width,size.height); - CCLOG("leftCap %0.2f rightCap %0.2f",topLeft->getContentSize().width,topRight->getContentSize().width); - float sizableWidth = size.width - topLeft->getContentSize().width - topRight->getContentSize().width; float sizableHeight = size.height - topLeft->getContentSize().height - bottomRight->getContentSize().height; float horizontalScale = sizableWidth/centre->getContentSize().width; @@ -247,8 +244,6 @@ void CCScale9Sprite::updatePositions() // Position centre centre->setPosition(ccp(leftWidth, bottomHeight)); - - CCLOG("Scale9 setContentSize %02.f x %02.f <%0.2f x %0.2f>",sizableWidth,sizableHeight,horizontalScale,verticalScale); } bool CCScale9Sprite::initWithFile(const char* file, CCRect rect, CCRect capInsets) From 5c38dd7193751d7a9f258587e6a049f8f01d6ee4 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Mon, 4 Jun 2012 15:52:49 -0700 Subject: [PATCH 070/257] Added CCBMemberVariableAssigner and CCBSelectorResolver. --- .../CCBIReader/CCBMemberVariableAssigner.cpp | 9 + .../CCBIReader/CCBMemberVariableAssigner.h | 15 ++ cocos2dx/extensions/CCBIReader/CCBReader.cpp | 79 +++++---- cocos2dx/extensions/CCBIReader/CCBReader.h | 24 ++- .../CCBIReader/CCBSelectorResolver.h | 15 ++ .../extensions/CCBIReader/CCControlLoader.cpp | 6 +- .../extensions/CCBIReader/CCControlLoader.h | 2 +- .../CCBIReader/CCMenuItemLoader.cpp | 7 +- .../extensions/CCBIReader/CCMenuItemLoader.h | 2 +- .../extensions/CCBIReader/CCNodeLoader.cpp | 162 ++++++++---------- cocos2dx/extensions/CCBIReader/CCNodeLoader.h | 19 +- 11 files changed, 187 insertions(+), 153 deletions(-) create mode 100644 cocos2dx/extensions/CCBIReader/CCBMemberVariableAssigner.cpp create mode 100644 cocos2dx/extensions/CCBIReader/CCBMemberVariableAssigner.h create mode 100644 cocos2dx/extensions/CCBIReader/CCBSelectorResolver.h diff --git a/cocos2dx/extensions/CCBIReader/CCBMemberVariableAssigner.cpp b/cocos2dx/extensions/CCBIReader/CCBMemberVariableAssigner.cpp new file mode 100644 index 0000000000..0d268089a4 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCBMemberVariableAssigner.cpp @@ -0,0 +1,9 @@ +// +// CCBMemberVariableAssigner.cpp +// CCBIReaderTest +// +// Created by Nicolas Fabian Gramlich on 6/4/12. +// Copyright (c) 2012 __MyCompanyName__. All rights reserved. +// + +#include diff --git a/cocos2dx/extensions/CCBIReader/CCBMemberVariableAssigner.h b/cocos2dx/extensions/CCBIReader/CCBMemberVariableAssigner.h new file mode 100644 index 0000000000..b42fc76722 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCBMemberVariableAssigner.h @@ -0,0 +1,15 @@ +#ifndef _CCB_MEMBERVARIABLEASSIGNER_H_ +#define _CCB_MEMBERVARIABLEASSIGNER_H_ + +#include "cocos2d.h" + +NS_CC_EXT_BEGIN + +class CCBMemberVariableAssigner { + public: + virtual bool onAssignCCBMemberVariable(CCObject * pTarget, std::string pMemberVariableName, CCNode * pNode) = 0; +}; + +NS_CC_EXT_END + +#endif diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.cpp b/cocos2dx/extensions/CCBIReader/CCBReader.cpp index 22bcd32352..b2b2249a6a 100644 --- a/cocos2dx/extensions/CCBIReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCBReader.cpp @@ -18,7 +18,10 @@ using namespace cocos2d; using namespace cocos2d::extension; -CCBReader::CCBReader() { +CCBReader::CCBReader(CCBMemberVariableAssigner * pCCBMemberVariableAssigner, CCBSelectorResolver * pCCBSelectorResolver) { + this->mCCBMemberVariableAssigner = pCCBMemberVariableAssigner; + this->mCCBSelectorResolver = pCCBSelectorResolver; + this->registerCCNodeLoader("CCNode", new CCNodeLoader()); this->registerCCNodeLoader("CCLayer", new CCLayerLoader()); this->registerCCNodeLoader("CCLayerColor", new CCLayerColorLoader()); @@ -47,23 +50,33 @@ CCBReader::CCBReader(CCBReader * pCCBReader) { /* Borrow CCNodeLoaders and LoadedSpriteSheets. */ this->mLoadedSpriteSheets = pCCBReader->mLoadedSpriteSheets; this->mCCNodeLoaders = pCCBReader->mCCNodeLoaders; + this->mCCBMemberVariableAssigner = pCCBReader->mCCBMemberVariableAssigner; + this->mCCBSelectorResolver = pCCBReader->mCCBSelectorResolver; } void CCBReader::registerCCNodeLoader(std::string pClassName, CCNodeLoader * pCCNodeLoader) { this->mCCNodeLoaders.insert(std::pair(pClassName, pCCNodeLoader)); } +CCBMemberVariableAssigner * CCBReader::getCCBMemberVariableAssigner() { + return this->mCCBMemberVariableAssigner; +} + +CCBSelectorResolver * CCBReader::getCCBSelectorResolver() { + return this->mCCBSelectorResolver; +} + CCNodeLoader * CCBReader::getCCNodeLoader(std::string pClassName) { std::map::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName); assert(ccNodeLoadersIterator != this->mCCNodeLoaders.end()); return ccNodeLoadersIterator->second; } -CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBFileName, CCNode * pOwner) { +CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBFileName, CCObject * pOwner) { return this->readNodeGraphFromFile(pCCBFileName, pOwner, CCDirector::sharedDirector()->getWinSize()); } -CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBFileName, CCNode * pOwner, CCSize pParentSize) { +CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize) { const char * path = CCFileUtils::fullPathFromRelativePath(pCCBFileName); unsigned long size = 0; @@ -72,7 +85,7 @@ CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBFileName, CCNode * pO this->mCurrentByte = 0; this->mCurrentBit = 0; this->mOwner = pOwner; - this->mRootContainerSize = pParentSize; + this->mRootContainerSize = pRootContainerSize; if(!this->readHeader()) { return NULL; @@ -235,60 +248,48 @@ std::string CCBReader::readCachedString() { } CCNode * CCBReader::readNodeGraph(CCNode * pParent) { - // Read class name + /* Read class name. */ std::string className = this->readCachedString(); int memberVarAssignmentType = this->readInt(false); std::string memberVarAssignmentName; - if(memberVarAssignmentType) { + if(memberVarAssignmentType != kCCBTargetTypeNone) { memberVarAssignmentName = this->readCachedString(); } - + CCNodeLoader * ccNodeLoader = this->getCCNodeLoader(className); CCNode * node = ccNodeLoader->loadCCNode(pParent, this); - - // Set root node - if(!this->mRootNode) { + + /* Set root node, if not set yet. */ + if(this->mRootNode == NULL) { this->mRootNode = node; // TODO retain? } - // TODO - /* - // Assign to variable (if applicable) - if (memberVarAssignmentType) - { - id target = NULL; - if (memberVarAssignmentType == kCCBTargetTypeDocumentRoot) target = rootNode; - else if (memberVarAssignmentType == kCCBTargetTypeOwner) target = owner; - - if (target) - { - Ivar ivar = class_getInstanceVariable([target class],[memberVarAssignmentName UTF8String]); - if (ivar) - { - object_setIvar(target,ivar,node); - } - else - { - NSLog(@"CCBReader: Couldn't find member variable: %@", memberVarAssignmentName); + if(memberVarAssignmentType != kCCBTargetTypeNone) { + CCObject * target = NULL; + if(memberVarAssignmentType == kCCBTargetTypeDocumentRoot) { + target = this->getRootNode(); + } else if (memberVarAssignmentType == kCCBTargetTypeOwner) { + target = this->getOwner(); + } + + if (target != NULL) { + if(this->mCCBMemberVariableAssigner != NULL) { + this->mCCBMemberVariableAssigner->onAssignCCBMemberVariable(target, memberVarAssignmentName, node); } } } - */ - - // Read and add children + + /* Read and add children. */ int numChildren = this->readInt(false); for(int i = 0; i < numChildren; i++) { CCNode * child = this->readNodeGraph(node); node->addChild(child); } - // TODO /* - // Call didLoadFromCCB - if ([node respondsToSelector:@selector(didLoadFromCCB)]) - { + if([node respondsToSelector:@selector(didLoadFromCCB)]) { [node performSelector:@selector(didLoadFromCCB)]; } */ @@ -300,10 +301,14 @@ CCNode * CCBReader::readNodeGraph() { return this->readNodeGraph(NULL); } -CCNode * CCBReader::getOwner() { +CCObject * CCBReader::getOwner() { return this->mOwner; } +CCNode * CCBReader::getRootNode() { + return this->mRootNode; +} + CCSize CCBReader::getContainerSize(CCNode * pNode) { if(pNode) { return pNode->getContentSize(); diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.h b/cocos2dx/extensions/CCBIReader/CCBReader.h index f0e350e88d..64214003ee 100644 --- a/cocos2dx/extensions/CCBIReader/CCBReader.h +++ b/cocos2dx/extensions/CCBIReader/CCBReader.h @@ -2,6 +2,8 @@ #define _CCB_READER_H_ #include "cocos2d.h" +#include "CCBMemberVariableAssigner.h" +#include "CCBSelectorResolver.h" #define kCCBVersion 2 @@ -77,27 +79,33 @@ class CC_DLL CCBReader : public CCObject { // TODO Why extend CCObject? -> Also unsigned char * mBytes; int mCurrentByte; int mCurrentBit; - CCNode * mOwner; /* TODO Should that be any 'Object'? */ + CCObject * mOwner; CCNode * mRootNode; CCSize mRootContainerSize; - + + CCBMemberVariableAssigner * mCCBMemberVariableAssigner; + CCBSelectorResolver * mCCBSelectorResolver; + std::vector mStringCache; std::map mCCNodeLoaders; std::set mLoadedSpriteSheets; public: /* Constructor. */ - CCBReader(); + CCBReader(CCBMemberVariableAssigner * = NULL, CCBSelectorResolver * = NULL); CCBReader(CCBReader *); /* Destructor. */ ~CCBReader(); - CCNode * readNodeGraphFromFile(const char *, CCNode * = NULL); - CCNode * readNodeGraphFromFile(const char *, CCNode *, CCSize); - void registerCCNodeLoader(std::string, CCNodeLoader *); - CCNodeLoader * getCCNodeLoader(std::string); + CCNode * readNodeGraphFromFile(const char * pCCBFileName, CCObject * pOwner = NULL); + CCNode * readNodeGraphFromFile(const char * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize); + void registerCCNodeLoader(std::string pClassName, CCNodeLoader * pCCNodeLoader); + CCNodeLoader * getCCNodeLoader(std::string pClassName); + CCBMemberVariableAssigner * getCCBMemberVariableAssigner(); + CCBSelectorResolver * getCCBSelectorResolver(); - CCNode * getOwner(); + CCObject * getOwner(); + CCNode * getRootNode(); CCSize getContainerSize(CCNode *); std::string lastPathComponent(std::string); std::string deletePathExtension(std::string); diff --git a/cocos2dx/extensions/CCBIReader/CCBSelectorResolver.h b/cocos2dx/extensions/CCBIReader/CCBSelectorResolver.h new file mode 100644 index 0000000000..8c425e66ec --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCBSelectorResolver.h @@ -0,0 +1,15 @@ +#ifndef _CCB_SELECTORRESOLVER_H_ +#define _CCB_SELECTORRESOLVER_H_ + +#include "cocos2d.h" + +NS_CC_EXT_BEGIN + +class CCBSelectorResolver { + public: + virtual cocos2d::SEL_MenuHandler onResolveCCBSelector(CCObject * pTarget, std::string pSelectorName) = 0; +}; + +NS_CC_EXT_END + +#endif diff --git a/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp b/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp index ef022533d3..ca6afa99cf 100644 --- a/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp @@ -17,11 +17,11 @@ void CCControlLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, st } } -void CCControlLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, std::string pPropertyName, void * pBlockCCControl, CCBReader * pCCBReader) { +void CCControlLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, std::string pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader) { if(pPropertyName.compare(PROPERTY_CCCONTROL) == 0) { // TODO selector thingy... - // ((CCControl *)pNode)->setTarget(???, ???); + ((CCControl *)pNode)->addTargetWithActionForControlEvents(pBlockCCControlData->mTarget, pBlockCCControlData->mSELMenuHandler, pBlockCCControlData->mControlEvents); // TODO First paramater is wrong! } else { - CCNodeLoader::onHandlePropTypeBlockCCControl(pNode, pParent, pPropertyName, pBlockCCControl, pCCBReader); + CCNodeLoader::onHandlePropTypeBlockCCControl(pNode, pParent, pPropertyName, pBlockCCControlData, pCCBReader); } } \ No newline at end of file diff --git a/cocos2dx/extensions/CCBIReader/CCControlLoader.h b/cocos2dx/extensions/CCBIReader/CCControlLoader.h index b7e292e944..eebfb54e43 100644 --- a/cocos2dx/extensions/CCBIReader/CCControlLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCControlLoader.h @@ -12,7 +12,7 @@ class CCControlLoader : public CCNodeLoader { protected: virtual CCControl * createCCNode(CCNode *, CCBReader *) = 0; - virtual void onHandlePropTypeBlockCCControl(CCNode *, CCNode *, std::string, void *, CCBReader *); + virtual void onHandlePropTypeBlockCCControl(CCNode *, CCNode *, std::string, BlockCCControlData *, CCBReader *); virtual void onHandlePropTypeCheck(CCNode *, CCNode *, std::string, bool, CCBReader *); }; diff --git a/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp b/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp index 559f357361..5bf69cf070 100644 --- a/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp @@ -6,12 +6,11 @@ using namespace cocos2d::extension; #define PROPERTY_BLOCK "block" #define PROPERTY_ISENABLED "isEnabled" -void CCMenuItemLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, std::string pPropertyName, void * pBlock, CCBReader * pCCBReader) { +void CCMenuItemLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, std::string pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader) { if(pPropertyName.compare(PROPERTY_BLOCK) == 0) { - // TODO selector thingy... - // ((CCMenuItem *)pNode)->setTarget(???, ???); + ((CCMenuItem *)pNode)->setTarget(pBlockData->mTarget, pBlockData->mSELMenuHandler); } else { - CCNodeLoader::onHandlePropTypeBlock(pNode, pParent, pPropertyName, pBlock, pCCBReader); + CCNodeLoader::onHandlePropTypeBlock(pNode, pParent, pPropertyName, pBlockData, pCCBReader); } } diff --git a/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.h b/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.h index cde6bbb776..d8c5c9c9eb 100644 --- a/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.h @@ -12,7 +12,7 @@ class CCMenuItemLoader : public CCNodeLoader { protected: virtual CCMenuItem * createCCNode(CCNode *, CCBReader *) = 0; - virtual void onHandlePropTypeBlock(CCNode *, CCNode *, std::string, void *, CCBReader *); + virtual void onHandlePropTypeBlock(CCNode *, CCNode *, std::string, BlockData *, CCBReader *); virtual void onHandlePropTypeCheck(CCNode *, CCNode *, std::string, bool, CCBReader *); }; diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp index f4a623f091..f83594a79d 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp @@ -188,7 +188,7 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * if(setProp) { this->onHandlePropTypeFlip(pNode, pParent, propertyName, flip, pCCBReader); } - delete flip; // TODO Can this just be deleted? + delete flip; break; } case kCCBPropTypeBlendFunc: { @@ -227,19 +227,19 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * break; } case kCCBPropTypeBlock: { - void * block = this->parsePropTypeBlock(pNode, pParent, pCCBReader); + BlockData * blockData = this->parsePropTypeBlock(pNode, pParent, pCCBReader); if(setProp) { - this->onHandlePropTypeBlock(pNode, pParent, propertyName, block, pCCBReader); + this->onHandlePropTypeBlock(pNode, pParent, propertyName, blockData, pCCBReader); } // TODO delete block; ??? break; } case kCCBPropTypeBlockCCControl: { - void * blockCCControl = this->parsePropTypeBlockCCControl(pNode, pParent, pCCBReader); - if(setProp) { - this->onHandlePropTypeBlockCCControl(pNode, pParent, propertyName, blockCCControl, pCCBReader); + BlockCCControlData * blockCCControlData = this->parsePropTypeBlockCCControl(pNode, pParent, pCCBReader); + if(setProp && blockCCControlData != NULL) { + this->onHandlePropTypeBlockCCControl(pNode, pParent, propertyName, blockCCControlData, pCCBReader); } - // TODO delete blockCCControl; ??? + delete blockCCControlData; break; } case kCCBPropTypeCCBFile: { @@ -550,105 +550,77 @@ std::string CCNodeLoader::parsePropTypeFontTTF(CCNode * pNode, CCNode * pParent, return fnt; } -void * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { +BlockData * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { std::string selectorName = pCCBReader->readCachedString(); int selectorTarget = pCCBReader->readInt(false); - // TODO Selectors? - /* -#ifdef CCB_ENABLE_JAVASCRIPT - if (selectorTarget && selectorName && ![selectorName isEqualToString:@""]) - { - void (^block)(id sender); - block = ^(id sender) { - [[JSCocoa sharedController] eval:[NSString stringWithFormat:@"%@();",selectorName]]; - }; - - NSString* setSelectorName = [NSString stringWithFormat:@"set%@:",[name capitalizedString]]; - SEL setSelector = NSSelectorFromString(setSelectorName); - - if ([node respondsToSelector:setSelector]) - { - [node performSelector:setSelector withObject:block]; + if(selectorTarget != kCCBTargetTypeNone) { + CCObject * target = NULL; + if(selectorTarget == kCCBTargetTypeDocumentRoot) { + target = pCCBReader->getRootNode(); + } else if (selectorTarget == kCCBTargetTypeOwner) { + target = pCCBReader->getOwner(); } - else - { - NSLog(@"CCBReader: Failed to set selector/target block for %@",selectorName); + + if(target != NULL) { + if(selectorName.length() > 0) { + CCBSelectorResolver * ccbSelectorResolver = pCCBReader->getCCBSelectorResolver(); + if(ccbSelectorResolver != NULL) { + BlockData * blockData = new BlockData(); + blockData->mSELMenuHandler = ccbSelectorResolver->onResolveCCBSelector(target, selectorName); + + blockData->mTarget = target; + + return blockData; + } else { + CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName.c_str()); + } + } else { + CCLOG("Unexpected empty selector."); + } + } else { + CCLOG("Unexpected NULL target for selector."); } } -#else - if (selectorTarget) - { - id target = NULL; - if (selectorTarget == kCCBTargetTypeDocumentRoot) target = rootNode; - else if (selectorTarget == kCCBTargetTypeOwner) target = owner; - - if (target) - { - SEL selector = NSSelectorFromString(selectorName); - __block id t = target; - - void (^block)(id sender); - block = ^(id sender) { - [t performSelector:selector withObject:sender]; - }; - - NSString* setSelectorName = [NSString stringWithFormat:@"set%@:",[name capitalizedString]]; - SEL setSelector = NSSelectorFromString(setSelectorName); - - if ([node respondsToSelector:setSelector]) - { - [node performSelector:setSelector withObject:block]; - } - else - { - NSLog(@"CCBReader: Failed to set selector/target block for %@",selectorName); - } - } - else - { - NSLog(@"CCBReader: Failed to find target for block"); - } - } -#endif - */ + return NULL; } -void * CCNodeLoader::parsePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { +BlockCCControlData * CCNodeLoader::parsePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { std::string selectorName = pCCBReader->readCachedString(); int selectorTarget = pCCBReader->readInt(false); - int ctrlEvts = pCCBReader->readInt(false); - - // TODO - /* - // Since we do not know for sure that CCControl is available, use - // NSInvocation to call it's addTarget:action:forControlEvents: method - NSMethodSignature* sig = [node methodSignatureForSelector:@selector(addTarget:action:forControlEvents:)]; - if (sig) - { - SEL selector = NSSelectorFromString(selectorName); - id target = NULL; - if (selectorTarget == kCCBTargetTypeDocumentRoot) target = rootNode; - else if (selectorTarget == kCCBTargetTypeOwner) target = owner; - - if (selector && target) - { - NSInvocation* invocation = [NSInvocation invocationWithMethodSignature:sig]; - [invocation setTarget:node]; - [invocation setSelector:@selector(addTarget:action:forControlEvents:)]; - [invocation setArgument:&target atIndex:2]; - [invocation setArgument:&selector atIndex:3]; - [invocation setArgument:&ctrlEvts atIndex:4]; - - [invocation invoke]; + int controlEvents = pCCBReader->readInt(false); + + if(selectorTarget != kCCBTargetTypeNone) { + CCObject * target = NULL; + if(selectorTarget == kCCBTargetTypeDocumentRoot) { + target = pCCBReader->getRootNode(); + } else if (selectorTarget == kCCBTargetTypeOwner) { + target = pCCBReader->getOwner(); + } + + if(target != NULL) { + if(selectorName.length() > 0) { + CCBSelectorResolver * ccbSelectorResolver = pCCBReader->getCCBSelectorResolver(); + if(ccbSelectorResolver != NULL) { + BlockCCControlData * blockCCControlData = new BlockCCControlData(); + blockCCControlData->mSELMenuHandler = ccbSelectorResolver->onResolveCCBSelector(target, selectorName); + + blockCCControlData->mTarget = target; + blockCCControlData->mControlEvents = controlEvents; + + return blockCCControlData; + } else { + CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName.c_str()); + } + } else { + CCLOG("Unexpected empty selector."); + } + } else { + CCLOG("Unexpected NULL target for selector."); } } - else - { - NSLog(@"CCBReader: Failed to add selector/target block for CCControl"); - } - */ + return NULL; } @@ -796,11 +768,11 @@ void CCNodeLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, std ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, std::string pPropertyName, void * pBlock, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, std::string pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, std::string pPropertyName, void * pBlockCCControl, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, std::string pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.h b/cocos2dx/extensions/CCBIReader/CCNodeLoader.h index a7bbb6c7ff..df5838ec4e 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.h @@ -6,6 +6,17 @@ NS_CC_EXT_BEGIN +struct BlockData { + SEL_MenuHandler mSELMenuHandler; + CCObject * mTarget; +}; + +struct BlockCCControlData { + SEL_MenuHandler mSELMenuHandler; + CCObject * mTarget; + int mControlEvents; +}; + /* Forward declaration. */ class CCBReader; @@ -41,8 +52,8 @@ class CC_DLL CCNodeLoader { virtual std::string parsePropTypeString(CCNode *, CCNode *, CCBReader *); virtual std::string parsePropTypeText(CCNode *, CCNode *, CCBReader *); virtual std::string parsePropTypeFontTTF(CCNode *, CCNode *, CCBReader *); - virtual void * parsePropTypeBlock(CCNode *, CCNode *, CCBReader *); - virtual void * parsePropTypeBlockCCControl(CCNode *, CCNode *, CCBReader *); + virtual BlockData * parsePropTypeBlock(CCNode *, CCNode *, CCBReader *); + virtual BlockCCControlData * parsePropTypeBlockCCControl(CCNode *, CCNode *, CCBReader *); virtual CCNode * parsePropTypeCCBFile(CCNode *, CCNode *, CCBReader *); @@ -70,8 +81,8 @@ class CC_DLL CCNodeLoader { virtual void onHandlePropTypeString(CCNode *, CCNode *, std::string, std::string, CCBReader *); virtual void onHandlePropTypeText(CCNode *, CCNode *, std::string, std::string, CCBReader *); virtual void onHandlePropTypeFontTTF(CCNode *, CCNode *, std::string, std::string, CCBReader *); - virtual void onHandlePropTypeBlock(CCNode *, CCNode *, std::string, void *, CCBReader *); - virtual void onHandlePropTypeBlockCCControl(CCNode *, CCNode *, std::string, void *, CCBReader *); + virtual void onHandlePropTypeBlock(CCNode *, CCNode *, std::string, BlockData *, CCBReader *); + virtual void onHandlePropTypeBlockCCControl(CCNode *, CCNode *, std::string, BlockCCControlData *, CCBReader *); virtual void onHandlePropTypeCCBFile(CCNode *, CCNode *, std::string, CCNode *, CCBReader *); }; From 28862c30cf49492464d0c5beb83268479c477152 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Mon, 4 Jun 2012 16:03:45 -0700 Subject: [PATCH 071/257] CCNodeLoader: Fixed small memory leak. --- cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp index f83594a79d..a09d74ffac 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp @@ -231,7 +231,7 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * if(setProp) { this->onHandlePropTypeBlock(pNode, pParent, propertyName, blockData, pCCBReader); } - // TODO delete block; ??? + delete blockData; break; } case kCCBPropTypeBlockCCControl: { From d3e0f8dc92b92e98faca8130a615ae260a2cfca9 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Mon, 4 Jun 2012 16:16:42 -0700 Subject: [PATCH 072/257] Added support for resolutionScale. --- cocos2dx/extensions/CCBIReader/CCBReader.cpp | 20 ++++++++++++++++++- cocos2dx/extensions/CCBIReader/CCBReader.h | 11 +++++++--- .../extensions/CCBIReader/CCNodeLoader.cpp | 14 ++++--------- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.cpp b/cocos2dx/extensions/CCBIReader/CCBReader.cpp index b2b2249a6a..1e9d0709ef 100644 --- a/cocos2dx/extensions/CCBIReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCBReader.cpp @@ -15,6 +15,10 @@ #include "CCControlButtonLoader.h" #include "CCParticleSystemQuadLoader.h" +#ifdef __CC_PLATFORM_IOS +#import +#endif + using namespace cocos2d; using namespace cocos2d::extension; @@ -22,6 +26,15 @@ CCBReader::CCBReader(CCBMemberVariableAssigner * pCCBMemberVariableAssigner, CCB this->mCCBMemberVariableAssigner = pCCBMemberVariableAssigner; this->mCCBSelectorResolver = pCCBSelectorResolver; + this->mResolutionScale = 1; + +#ifdef __CC_PLATFORM_IOS + /* iPad */ + if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + this->mResolutionScale = 2; + } +#endif + this->registerCCNodeLoader("CCNode", new CCNodeLoader()); this->registerCCNodeLoader("CCLayer", new CCLayerLoader()); this->registerCCNodeLoader("CCLayerColor", new CCLayerColorLoader()); @@ -47,7 +60,8 @@ CCBReader::~CCBReader() { } CCBReader::CCBReader(CCBReader * pCCBReader) { - /* Borrow CCNodeLoaders and LoadedSpriteSheets. */ + /* Borrow data from the 'parent' CCBLoader. */ + this->mResolutionScale = pCCBReader->mResolutionScale; this->mLoadedSpriteSheets = pCCBReader->mLoadedSpriteSheets; this->mCCNodeLoaders = pCCBReader->mCCNodeLoaders; this->mCCBMemberVariableAssigner = pCCBReader->mCCBMemberVariableAssigner; @@ -66,6 +80,10 @@ CCBSelectorResolver * CCBReader::getCCBSelectorResolver() { return this->mCCBSelectorResolver; } +float CCBReader::getResolutionScale() { + return this->mResolutionScale; +} + CCNodeLoader * CCBReader::getCCNodeLoader(std::string pClassName) { std::map::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName); assert(ccNodeLoadersIterator != this->mCCNodeLoaders.end()); diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.h b/cocos2dx/extensions/CCBIReader/CCBReader.h index 64214003ee..de16874295 100644 --- a/cocos2dx/extensions/CCBIReader/CCBReader.h +++ b/cocos2dx/extensions/CCBIReader/CCBReader.h @@ -82,6 +82,7 @@ class CC_DLL CCBReader : public CCObject { // TODO Why extend CCObject? -> Also CCObject * mOwner; CCNode * mRootNode; CCSize mRootContainerSize; + float mResolutionScale; CCBMemberVariableAssigner * mCCBMemberVariableAssigner; CCBSelectorResolver * mCCBSelectorResolver; @@ -107,14 +108,18 @@ class CC_DLL CCBReader : public CCObject { // TODO Why extend CCObject? -> Also CCObject * getOwner(); CCNode * getRootNode(); CCSize getContainerSize(CCNode *); + float getResolutionScale(); + + bool isSpriteSheetLoaded(std::string); + void addLoadedSpriteSheet(std::string); + + /* Utility methods. */ std::string lastPathComponent(std::string); std::string deletePathExtension(std::string); std::string toLowerCase(std::string); bool endsWith(std::string, std::string); - bool isSpriteSheetLoaded(std::string); - void addLoadedSpriteSheet(std::string); - /* Parse methods */ + /* Parse methods. */ int readInt(bool pSign); unsigned char readByte(); bool readBool(); diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp index a09d74ffac..f134fe4c8d 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp @@ -350,13 +350,10 @@ float * CCNodeLoader::parsePropTypeScaleLock(CCNode * pNode, CCNode * pParent, C int type = pCCBReader->readInt(false); - // TODO - /* if (type == kCCBScaleTypeMultiplyResolution) { - x *= resolutionScale; - y *= resolutionScale; + x *= pCCBReader->getResolutionScale(); + y *= pCCBReader->getResolutionScale(); } - */ float * scaleLock = new float[2]; scaleLock[0] = x; @@ -378,13 +375,10 @@ float CCNodeLoader::parsePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CC int type = pCCBReader->readInt(false); - // TODO - /* if (type == kCCBScaleTypeMultiplyResolution) { - x *= resolutionScale; - y *= resolutionScale; + f *= pCCBReader->getResolutionScale(); } - */ + return f; } From 420a73113829ab56695a80458eabe8c0eb293004 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Mon, 4 Jun 2012 17:45:25 -0700 Subject: [PATCH 073/257] Switched from std::string to const char *. --- .../extensions/CCBIReader/CCBFileLoader.cpp | 4 +- .../extensions/CCBIReader/CCBFileLoader.h | 2 +- cocos2dx/extensions/CCBIReader/CCBReader.cpp | 85 +++++----- cocos2dx/extensions/CCBIReader/CCBReader.h | 33 ++-- .../CCBIReader/CCControlButtonLoader.cpp | 58 +++---- .../CCBIReader/CCControlButtonLoader.h | 16 +- .../extensions/CCBIReader/CCControlLoader.cpp | 10 +- .../extensions/CCBIReader/CCControlLoader.h | 4 +- .../CCBIReader/CCLabelBMFontLoader.cpp | 24 +-- .../CCBIReader/CCLabelBMFontLoader.h | 10 +- .../CCBIReader/CCLabelTTFLoader.cpp | 38 ++--- .../extensions/CCBIReader/CCLabelTTFLoader.h | 16 +- .../CCBIReader/CCLayerColorLoader.cpp | 12 +- .../CCBIReader/CCLayerColorLoader.h | 6 +- .../CCBIReader/CCLayerGradientLoader.cpp | 20 +-- .../CCBIReader/CCLayerGradientLoader.h | 8 +- .../extensions/CCBIReader/CCLayerLoader.cpp | 10 +- .../extensions/CCBIReader/CCLayerLoader.h | 2 +- .../CCBIReader/CCMenuItemImageLoader .cpp | 8 +- .../CCBIReader/CCMenuItemImageLoader.h | 2 +- .../CCBIReader/CCMenuItemLoader.cpp | 8 +- .../extensions/CCBIReader/CCMenuItemLoader.h | 4 +- .../extensions/CCBIReader/CCNodeLoader.cpp | 157 +++++++++--------- cocos2dx/extensions/CCBIReader/CCNodeLoader.h | 62 +++---- .../CCBIReader/CCParticleSystemQuadLoader.cpp | 60 +++---- .../CCBIReader/CCParticleSystemQuadLoader.h | 16 +- .../CCBIReader/CCScale9SpriteLoader.cpp | 32 ++-- .../CCBIReader/CCScale9SpriteLoader.h | 12 +- .../extensions/CCBIReader/CCSpriteLoader.cpp | 20 +-- .../extensions/CCBIReader/CCSpriteLoader.h | 10 +- 30 files changed, 385 insertions(+), 364 deletions(-) diff --git a/cocos2dx/extensions/CCBIReader/CCBFileLoader.cpp b/cocos2dx/extensions/CCBIReader/CCBFileLoader.cpp index 7e04218f9e..292278626b 100644 --- a/cocos2dx/extensions/CCBIReader/CCBFileLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCBFileLoader.cpp @@ -9,8 +9,8 @@ CCNode * CCBFileLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { return CCNode::node(); } -void CCBFileLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_CCBFILE) == 0) { +void CCBFileLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_CCBFILE) == 0) { pNode->addChild(pCCBFileNode); } else { CCNodeLoader::onHandlePropTypeCCBFile(pNode, pParent, pPropertyName, pCCBFileNode, pCCBReader); diff --git a/cocos2dx/extensions/CCBIReader/CCBFileLoader.h b/cocos2dx/extensions/CCBIReader/CCBFileLoader.h index 9875a78e6e..ad44cd1d00 100644 --- a/cocos2dx/extensions/CCBIReader/CCBFileLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCBFileLoader.h @@ -12,7 +12,7 @@ class CCBFileLoader : public CCNodeLoader { protected: virtual CCNode * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeCCBFile(CCNode *, CCNode *, std::string, CCNode *, CCBReader *); + virtual void onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCNode *, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.cpp b/cocos2dx/extensions/CCBIReader/CCBReader.cpp index 1e9d0709ef..7db6e5c551 100644 --- a/cocos2dx/extensions/CCBIReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCBReader.cpp @@ -68,8 +68,8 @@ CCBReader::CCBReader(CCBReader * pCCBReader) { this->mCCBSelectorResolver = pCCBReader->mCCBSelectorResolver; } -void CCBReader::registerCCNodeLoader(std::string pClassName, CCNodeLoader * pCCNodeLoader) { - this->mCCNodeLoaders.insert(std::pair(pClassName, pCCNodeLoader)); +void CCBReader::registerCCNodeLoader(const char * pClassName, CCNodeLoader * pCCNodeLoader) { + this->mCCNodeLoaders.insert(std::pair(pClassName, pCCNodeLoader)); } CCBMemberVariableAssigner * CCBReader::getCCBMemberVariableAssigner() { @@ -84,8 +84,8 @@ float CCBReader::getResolutionScale() { return this->mResolutionScale; } -CCNodeLoader * CCBReader::getCCNodeLoader(std::string pClassName) { - std::map::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName); +CCNodeLoader * CCBReader::getCCNodeLoader(const char * pClassName) { + std::map::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName); assert(ccNodeLoadersIterator != this->mCCNodeLoaders.end()); return ccNodeLoadersIterator->second; } @@ -144,25 +144,26 @@ bool CCBReader::readStringCache() { int numStrings = this->readInt(false); for(int i = 0; i < numStrings; i++) { - std::string string = this->readUTF8(); - this->mStringCache.push_back(string); + this->readStringCacheEntry(); } return true; } -std::string CCBReader::readUTF8() { +void CCBReader::readStringCacheEntry() { int b0 = this->readByte(); int b1 = this->readByte(); int numBytes = b0 << 8 | b1; - const char * ptr = (const char*) (this->mBytes + this->mCurrentByte); - std::string str(ptr, numBytes); + const char * src = (const char *) (this->mBytes + this->mCurrentByte); + char * ptr = new char[numBytes + 1]; // TODO I'm most likely leaking memory here. Unfortunately I'm not sure if I can safely delete the items in the mStringCache in ~CCBReader. =( + strncpy(ptr, src, numBytes); + ptr[numBytes] = '\0'; this->mCurrentByte += numBytes; - return str; + this->mStringCache.push_back(ptr); } unsigned char CCBReader::readByte() { @@ -260,17 +261,17 @@ void CCBReader::alignBits() { } } -std::string CCBReader::readCachedString() { +const char * CCBReader::readCachedString() { int i = this->readInt(false); return this->mStringCache[i]; } CCNode * CCBReader::readNodeGraph(CCNode * pParent) { /* Read class name. */ - std::string className = this->readCachedString(); + const char * className = this->readCachedString(); int memberVarAssignmentType = this->readInt(false); - std::string memberVarAssignmentName; + const char * memberVarAssignmentName; if(memberVarAssignmentType != kCCBTargetTypeNone) { memberVarAssignmentName = this->readCachedString(); } @@ -335,39 +336,47 @@ CCSize CCBReader::getContainerSize(CCNode * pNode) { } } -std::string CCBReader::lastPathComponent(std::string pPath) { - int slashPos = pPath.find_last_of("/"); - if (slashPos != std::string::npos) { - return pPath.substr(slashPos + 1, pPath.length() - slashPos); - } - return pPath; -} - -std::string CCBReader::deletePathExtension(std::string pPath) { - int dotPos = pPath.find_last_of("."); - if (dotPos != std::string::npos) { - return pPath.substr(0, dotPos); - } - return pPath; -} - -bool CCBReader::isSpriteSheetLoaded(std::string pSpriteSheet) { +bool CCBReader::isSpriteSheetLoaded(const char * pSpriteSheet) { return this->mLoadedSpriteSheets.find(pSpriteSheet) != this->mLoadedSpriteSheets.end(); } -void CCBReader::addLoadedSpriteSheet(std::string pSpriteSheet) { +void CCBReader::addLoadedSpriteSheet(const char * pSpriteSheet) { this->mLoadedSpriteSheets.insert(pSpriteSheet); } -std::string CCBReader::toLowerCase(std::string pString) { - std::string copy(pString); - std::transform(copy.begin(), copy.end(), copy.begin(), ::tolower); - return copy; +const char * CCBReader::lastPathComponent(const char * pPath) { + // TODO Memory leaks? + std::string path(pPath); + int slashPos = path.find_last_of("/"); + if (slashPos != std::string::npos) { + return path.substr(slashPos + 1, path.length() - slashPos).c_str(); + } + return pPath; } -bool CCBReader::endsWith(std::string pString, std::string pEnding) { - if (pString.length() >= pEnding.length()) { - return (pString.compare(pString.length() - pEnding.length(), pEnding.length(), pEnding) == 0); +const char * CCBReader::deletePathExtension(const char * pPath) { + // TODO Memory leaks? + std::string path(pPath); + int dotPos = path.find_last_of("."); + if (dotPos != std::string::npos) { + return path.substr(0, dotPos).c_str(); + } + return pPath; +} + +const char * CCBReader::toLowerCase(const char * pString) { + // TODO Memory leaks? + std::string copy(pString); + std::transform(copy.begin(), copy.end(), copy.begin(), ::tolower); + return copy.c_str(); +} + +bool CCBReader::endsWith(const char * pString, const char * pEnding) { + // TODO Memory leaks? + std::string string(pString); + std::string ending(pEnding); + if (string.length() >= ending.length()) { + return (string.compare(string.length() - ending.length(), ending.length(), ending) == 0); } else { return false; } diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.h b/cocos2dx/extensions/CCBIReader/CCBReader.h index de16874295..22d010a655 100644 --- a/cocos2dx/extensions/CCBIReader/CCBReader.h +++ b/cocos2dx/extensions/CCBIReader/CCBReader.h @@ -68,6 +68,12 @@ NS_CC_EXT_BEGIN +struct cmp_str { + bool operator() (char const *a, char const *b) { + return std::strcmp(a, b) < 0; + } +}; + /* Forward declaration. */ class CCNodeLoader; @@ -87,9 +93,9 @@ class CC_DLL CCBReader : public CCObject { // TODO Why extend CCObject? -> Also CCBMemberVariableAssigner * mCCBMemberVariableAssigner; CCBSelectorResolver * mCCBSelectorResolver; - std::vector mStringCache; - std::map mCCNodeLoaders; - std::set mLoadedSpriteSheets; + std::vector mStringCache; + std::map mCCNodeLoaders; + std::set mLoadedSpriteSheets; public: /* Constructor. */ @@ -100,8 +106,8 @@ class CC_DLL CCBReader : public CCObject { // TODO Why extend CCObject? -> Also CCNode * readNodeGraphFromFile(const char * pCCBFileName, CCObject * pOwner = NULL); CCNode * readNodeGraphFromFile(const char * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize); - void registerCCNodeLoader(std::string pClassName, CCNodeLoader * pCCNodeLoader); - CCNodeLoader * getCCNodeLoader(std::string pClassName); + void registerCCNodeLoader(const char * pClassName, CCNodeLoader * pCCNodeLoader); + CCNodeLoader * getCCNodeLoader(const char * pClassName); CCBMemberVariableAssigner * getCCBMemberVariableAssigner(); CCBSelectorResolver * getCCBSelectorResolver(); @@ -110,31 +116,32 @@ class CC_DLL CCBReader : public CCObject { // TODO Why extend CCObject? -> Also CCSize getContainerSize(CCNode *); float getResolutionScale(); - bool isSpriteSheetLoaded(std::string); - void addLoadedSpriteSheet(std::string); + bool isSpriteSheetLoaded(const char *); + void addLoadedSpriteSheet(const char *); /* Utility methods. */ - std::string lastPathComponent(std::string); - std::string deletePathExtension(std::string); - std::string toLowerCase(std::string); - bool endsWith(std::string, std::string); + const char * lastPathComponent(const char *); + const char * deletePathExtension(const char *); + const char * toLowerCase(const char *); + bool endsWith(const char *, const char *); /* Parse methods. */ int readInt(bool pSign); unsigned char readByte(); bool readBool(); float readFloat(); - std::string readCachedString(); + const char * readCachedString(); private: bool readHeader(); bool readStringCache(); + void readStringCacheEntry(); CCNode * readNodeGraph(); CCNode * readNodeGraph(CCNode *); bool getBit(); void alignBits(); - std::string readUTF8(); + const char * readUTF8(); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.cpp b/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.cpp index cf22f7d542..af70c85c5c 100644 --- a/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.cpp @@ -26,76 +26,76 @@ CCControl * CCControlButtonLoader::createCCNode(CCNode * pParent, CCBReader * pC return CCControlButton::node(); } -void CCControlButtonLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, std::string pPropertyName, bool pCheck, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_ZOOMONTOUCHDOWN) == 0) { +void CCControlButtonLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_ZOOMONTOUCHDOWN) == 0) { ((CCControlButton *)pNode)->setZoomOnTouchDown(pCheck); } else { CCControlLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader); } } -void CCControlButtonLoader::onHandlePropTypeString(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pString, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_TITLE_NORMAL) == 0) { +void CCControlButtonLoader::onHandlePropTypeString(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pString, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_TITLE_NORMAL) == 0) { ((CCControlButton *)pNode)->setTitleForState(new CCString(pString), CCControlStateNormal); // TODO Leak? - } else if(pPropertyName.compare(PROPERTY_TITLE_HIGHLIGHTED) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_TITLE_HIGHLIGHTED) == 0) { ((CCControlButton *)pNode)->setTitleForState(new CCString(pString), CCControlStateHighlighted); // TODO Leak? - } else if(pPropertyName.compare(PROPERTY_TITLE_DISABLED) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_TITLE_DISABLED) == 0) { ((CCControlButton *)pNode)->setTitleForState(new CCString(pString), CCControlStateDisabled); // TODO Leak? } else { CCControlLoader::onHandlePropTypeString(pNode, pParent, pPropertyName, pString, pCCBReader); } } -void CCControlButtonLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pFontTTF, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_TITLETTF_NORMAL) == 0) { - ((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF.c_str(), CCControlStateNormal); - } else if(pPropertyName.compare(PROPERTY_TITLETTF_HIGHLIGHTED) == 0) { - ((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF.c_str(), CCControlStateHighlighted); - } else if(pPropertyName.compare(PROPERTY_TITLETTF_DISABLED) == 0) { - ((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF.c_str(), CCControlStateDisabled); +void CCControlButtonLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_TITLETTF_NORMAL) == 0) { + ((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF, CCControlStateNormal); + } else if(strcmp(pPropertyName, PROPERTY_TITLETTF_HIGHLIGHTED) == 0) { + ((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF, CCControlStateHighlighted); + } else if(strcmp(pPropertyName, PROPERTY_TITLETTF_DISABLED) == 0) { + ((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF, CCControlStateDisabled); } else { CCControlLoader::onHandlePropTypeFontTTF(pNode, pParent, pPropertyName, pFontTTF, pCCBReader); } } -void CCControlButtonLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float pFloatScale, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_TITLETTFSIZE_NORMAL) == 0) { +void CCControlButtonLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloatScale, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_TITLETTFSIZE_NORMAL) == 0) { ((CCControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, CCControlStateNormal); - } else if(pPropertyName.compare(PROPERTY_TITLETTFSIZE_HIGHLIGHTED) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_TITLETTFSIZE_HIGHLIGHTED) == 0) { ((CCControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, CCControlStateHighlighted); - } else if(pPropertyName.compare(PROPERTY_TITLETTFSIZE_DISABLED) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_TITLETTFSIZE_DISABLED) == 0) { ((CCControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, CCControlStateDisabled); } else { CCControlLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pFloatScale, pCCBReader); } } -void CCControlButtonLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_LABELANCHORPOINT) == 0) { +void CCControlButtonLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_LABELANCHORPOINT) == 0) { ((CCControlButton *)pNode)->setLabelAnchorPoint(pPoint); } else { CCControlLoader::onHandlePropTypePoint(pNode, pParent, pPropertyName, pPoint, pCCBReader); } } -void CCControlButtonLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSize pSize, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_PREFEREDSIZE) == 0) { +void CCControlButtonLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize pSize, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_PREFEREDSIZE) == 0) { ((CCControlButton *)pNode)->setPreferredSize(pSize); } else { CCControlLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, pCCBReader); } } -void CCControlButtonLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL) == 0) { +void CCControlButtonLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL) == 0) { if(pCCSpriteFrame != NULL) { ((CCControlButton *)pNode)->setBackgroundSpriteFrameForState(pCCSpriteFrame, CCControlStateNormal); } - } else if(pPropertyName.compare(PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED) == 0) { if(pCCSpriteFrame != NULL) { ((CCControlButton *)pNode)->setBackgroundSpriteFrameForState(pCCSpriteFrame, CCControlStateHighlighted); } - } else if(pPropertyName.compare(PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED) == 0) { if(pCCSpriteFrame != NULL) { ((CCControlButton *)pNode)->setBackgroundSpriteFrameForState(pCCSpriteFrame, CCControlStateDisabled); } @@ -104,12 +104,12 @@ void CCControlButtonLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * } } -void CCControlButtonLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_TITLECOLOR_NORMAL) == 0) { +void CCControlButtonLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_NORMAL) == 0) { ((CCControlButton *)pNode)->setTitleColorForState(pCCColor3B, CCControlStateNormal); - } else if(pPropertyName.compare(PROPERTY_TITLECOLOR_HIGHLIGHTED) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_HIGHLIGHTED) == 0) { ((CCControlButton *)pNode)->setTitleColorForState(pCCColor3B, CCControlStateHighlighted); - } else if(pPropertyName.compare(PROPERTY_TITLECOLOR_DISABLED) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_DISABLED) == 0) { ((CCControlButton *)pNode)->setTitleColorForState(pCCColor3B, CCControlStateDisabled); } else { CCControlLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); diff --git a/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.h b/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.h index b98f99a39e..95f1889cca 100644 --- a/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.h @@ -12,14 +12,14 @@ class CCControlButtonLoader : public CCControlLoader { protected: virtual CCControl * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeCheck(CCNode *, CCNode *, std::string, bool, CCBReader *); - virtual void onHandlePropTypeString(CCNode *, CCNode *, std::string, std::string, CCBReader *); - virtual void onHandlePropTypeFontTTF(CCNode *, CCNode *, std::string, std::string, CCBReader *); - virtual void onHandlePropTypeFloatScale(CCNode *, CCNode *, std::string, float, CCBReader *); - virtual void onHandlePropTypePoint(CCNode *, CCNode *, std::string, CCPoint, CCBReader *); - virtual void onHandlePropTypeSize(CCNode *, CCNode *, std::string, CCSize, CCBReader *); - virtual void onHandlePropTypeSpriteFrame(CCNode *, CCNode *, std::string, CCSpriteFrame *, CCBReader *); - virtual void onHandlePropTypeColor3(CCNode *, CCNode *, std::string, ccColor3B, CCBReader *); + virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool, CCBReader *); + virtual void onHandlePropTypeString(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char *, CCBReader *); + virtual void onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char *, CCBReader *); + virtual void onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float, CCBReader *); + virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint, CCBReader *); + virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize, CCBReader *); + virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame *, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp b/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp index ca6afa99cf..3a36d7409f 100644 --- a/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp @@ -7,18 +7,18 @@ using namespace cocos2d::extension; #define PROPERTY_SELECTED "selected" #define PROPERTY_CCCONTROL "ccControl" -void CCControlLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, std::string pPropertyName, bool pCheck, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_ENABLED) == 0) { +void CCControlLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_ENABLED) == 0) { ((CCControl *)pNode)->setIsEnabled(pCheck); - } else if(pPropertyName.compare(PROPERTY_SELECTED) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_SELECTED) == 0) { ((CCControl *)pNode)->setIsSelected(pCheck); } else { CCNodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader); } } -void CCControlLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, std::string pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_CCCONTROL) == 0) { +void CCControlLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_CCCONTROL) == 0) { // TODO selector thingy... ((CCControl *)pNode)->addTargetWithActionForControlEvents(pBlockCCControlData->mTarget, pBlockCCControlData->mSELMenuHandler, pBlockCCControlData->mControlEvents); // TODO First paramater is wrong! } else { diff --git a/cocos2dx/extensions/CCBIReader/CCControlLoader.h b/cocos2dx/extensions/CCBIReader/CCControlLoader.h index eebfb54e43..a018602001 100644 --- a/cocos2dx/extensions/CCBIReader/CCControlLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCControlLoader.h @@ -12,8 +12,8 @@ class CCControlLoader : public CCNodeLoader { protected: virtual CCControl * createCCNode(CCNode *, CCBReader *) = 0; - virtual void onHandlePropTypeBlockCCControl(CCNode *, CCNode *, std::string, BlockCCControlData *, CCBReader *); - virtual void onHandlePropTypeCheck(CCNode *, CCNode *, std::string, bool, CCBReader *); + virtual void onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockCCControlData *, CCBReader *); + virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.cpp b/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.cpp index 4922eb424b..d75121e296 100644 --- a/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.cpp @@ -13,41 +13,41 @@ CCLabelBMFont * CCLabelBMFontLoader::createCCNode(CCNode * pParent, CCBReader * return CCLabelBMFont::node(); } -void CCLabelBMFontLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_COLOR) == 0) { +void CCLabelBMFontLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) { ((CCLabelBMFont *)pNode)->setColor(pCCColor3B); } else { CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); } } -void CCLabelBMFontLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, std::string pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_OPACITY) == 0) { +void CCLabelBMFontLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) { ((CCLabelBMFont *)pNode)->setOpacity(pByte); } else { CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); } } -void CCLabelBMFontLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_BLENDFUNC) == 0) { +void CCLabelBMFontLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { ((CCLabelBMFont *)pNode)->setBlendFunc(pCCBlendFunc); } else { CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); } } -void CCLabelBMFontLoader::onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pFntFile, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_FNTFILE) == 0) { - ((CCLabelBMFont *)pNode)->setFntFile(pFntFile.c_str()); +void CCLabelBMFontLoader::onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pFntFile, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_FNTFILE) == 0) { + ((CCLabelBMFont *)pNode)->setFntFile(pFntFile); } else { CCNodeLoader::onHandlePropTypeFntFile(pNode, pParent, pPropertyName, pFntFile, pCCBReader); } } -void CCLabelBMFontLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pText, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_STRING) == 0) { - ((CCLabelBMFont *)pNode)->setString(pText.c_str()); +void CCLabelBMFontLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pText, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_STRING) == 0) { + ((CCLabelBMFont *)pNode)->setString(pText); } else { CCNodeLoader::onHandlePropTypeText(pNode, pParent, pPropertyName, pText, pCCBReader); } diff --git a/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h b/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h index c78603451e..decb69f364 100644 --- a/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h @@ -12,11 +12,11 @@ class CCLabelBMFontLoader : public CCNodeLoader { protected: virtual CCLabelBMFont * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeColor3(CCNode *, CCNode *, std::string, ccColor3B, CCBReader *); - virtual void onHandlePropTypeByte(CCNode *, CCNode *, std::string, unsigned char, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *); - virtual void onHandlePropTypeFntFile(CCNode *, CCNode *, std::string, std::string, CCBReader *); - virtual void onHandlePropTypeText(CCNode *, CCNode *, std::string, std::string, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B, CCBReader *); + virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char *, CCBReader *); + virtual void onHandlePropTypeText(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char *, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp b/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp index cc7e88b174..3e845d21b3 100644 --- a/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp @@ -17,58 +17,58 @@ CCLabelTTF * CCLabelTTFLoader::createCCNode(CCNode * pParent, CCBReader * pCCBRe return CCLabelTTF::node(); } -void CCLabelTTFLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_COLOR) == 0) { +void CCLabelTTFLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) { ((CCLabelTTF *)pNode)->setColor(pCCColor3B); } else { CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); } } -void CCLabelTTFLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, std::string pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_OPACITY) == 0) { +void CCLabelTTFLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) { ((CCLabelTTF *)pNode)->setOpacity(pByte); } else { CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); } } -void CCLabelTTFLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_BLENDFUNC) == 0) { +void CCLabelTTFLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { ((CCLabelTTF *)pNode)->setBlendFunc(pCCBlendFunc); } else { CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); } } -void CCLabelTTFLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pFontTTF, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_FONTNAME) == 0) { - ((CCLabelTTF *)pNode)->setFontName(pFontTTF.c_str()); +void CCLabelTTFLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_FONTNAME) == 0) { + ((CCLabelTTF *)pNode)->setFontName(pFontTTF); } else { CCNodeLoader::onHandlePropTypeFontTTF(pNode, pParent, pPropertyName, pFontTTF, pCCBReader); } } -void CCLabelTTFLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pText, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_STRING) == 0) { - ((CCLabelTTF *)pNode)->setString(pText.c_str()); +void CCLabelTTFLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pText, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_STRING) == 0) { + ((CCLabelTTF *)pNode)->setString(pText); } else { CCNodeLoader::onHandlePropTypeText(pNode, pParent, pPropertyName, pText, pCCBReader); } } -void CCLabelTTFLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float pFloatScale, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_FONTSIZE) == 0) { +void CCLabelTTFLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloatScale, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_FONTSIZE) == 0) { ((CCLabelTTF *)pNode)->setFontSize(pFloatScale); } else { CCNodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pFloatScale, pCCBReader); } } -void CCLabelTTFLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, std::string pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_HORIZONTALALIGNMENT) == 0) { +void CCLabelTTFLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_HORIZONTALALIGNMENT) == 0) { ((CCLabelTTF *)pNode)->setHorizontalAlignment(CCTextAlignment(pIntegerLabeled)); - } else if(pPropertyName.compare(PROPERTY_VERTICALALIGNMENT) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_VERTICALALIGNMENT) == 0) { // TODO Add support when CCLabelTTF supports it. ( See: 63d9724ac4d81a05c6ec7feea0c01bcd27c8fc6b ) // ((CCLabelTTF *)pNode)->setVerticalAlignment(pIntegerLabeled); } else { @@ -76,8 +76,8 @@ void CCLabelTTFLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * p } } -void CCLabelTTFLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSize pSize, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_DIMENSIONS) == 0) { +void CCLabelTTFLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize pSize, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_DIMENSIONS) == 0) { ((CCLabelTTF *)pNode)->setDimensions(pSize); } else { CCNodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, pCCBReader); diff --git a/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.h b/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.h index 4d89c3a1e5..5bd2fdac34 100644 --- a/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.h @@ -12,14 +12,14 @@ class CCLabelTTFLoader : public CCNodeLoader { protected: virtual CCLabelTTF * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeColor3(CCNode *, CCNode *, std::string, ccColor3B, CCBReader *); - virtual void onHandlePropTypeByte(CCNode *, CCNode *, std::string, unsigned char, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *); - virtual void onHandlePropTypeFontTTF(CCNode *, CCNode *, std::string, std::string, CCBReader *); - virtual void onHandlePropTypeText(CCNode *, CCNode *, std::string, std::string, CCBReader *); - virtual void onHandlePropTypeFloatScale(CCNode *, CCNode *, std::string, float, CCBReader *); - virtual void onHandlePropTypeIntegerLabeled(CCNode *, CCNode *, std::string, int, CCBReader *); - virtual void onHandlePropTypeSize(CCNode *, CCNode *, std::string, CCSize, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B, CCBReader *); + virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char *, CCBReader *); + virtual void onHandlePropTypeText(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char *, CCBReader *); + virtual void onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float, CCBReader *); + virtual void onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int, CCBReader *); + virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.cpp b/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.cpp index 2102a6c7bb..07cc6e644b 100644 --- a/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.cpp @@ -11,24 +11,24 @@ CCLayerColor * CCLayerColorLoader::createCCNode(CCNode * pParent, CCBReader * pC return CCLayerColor::node(); } -void CCLayerColorLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_COLOR) == 0) { +void CCLayerColorLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) { ((CCLayerColor *)pNode)->setColor(pCCColor3B); } else { CCLayerLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); } } -void CCLayerColorLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, std::string pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_OPACITY) == 0) { +void CCLayerColorLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) { ((CCLayerColor *)pNode)->setOpacity(pByte); } else { CCLayerLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); } } -void CCLayerColorLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_BLENDFUNC) == 0) { +void CCLayerColorLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { ((CCLayerColor *)pNode)->setBlendFunc(pCCBlendFunc); } else { CCLayerLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); diff --git a/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.h b/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.h index 0d86a46a75..535d971d85 100644 --- a/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.h @@ -12,9 +12,9 @@ class CCLayerColorLoader : public CCLayerLoader { protected: virtual CCLayerColor * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeColor3(CCNode *, CCNode *, std::string, ccColor3B, CCBReader *); - virtual void onHandlePropTypeByte(CCNode *, CCNode *, std::string, unsigned char, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B, CCBReader *); + virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.cpp b/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.cpp index 747e871b00..f1e4cca492 100644 --- a/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.cpp @@ -14,28 +14,28 @@ CCLayerGradient * CCLayerGradientLoader::createCCNode(CCNode * pParent, CCBReade return CCLayerGradient::node(); } -void CCLayerGradientLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_STARTCOLOR) == 0) { +void CCLayerGradientLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_STARTCOLOR) == 0) { ((CCLayerGradient *)pNode)->setStartColor(pCCColor3B); - } else if(pPropertyName.compare(PROPERTY_ENDCOLOR) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_ENDCOLOR) == 0) { ((CCLayerGradient *)pNode)->setEndColor(pCCColor3B); } else { CCLayerLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); } } -void CCLayerGradientLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, std::string pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_STARTOPACITY) == 0) { +void CCLayerGradientLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_STARTOPACITY) == 0) { ((CCLayerGradient *)pNode)->setStartOpacity(pByte); - } else if(pPropertyName.compare(PROPERTY_ENDOPACITY) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_ENDOPACITY) == 0) { ((CCLayerGradient *)pNode)->setEndOpacity(pByte); } else { CCLayerLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); } } -void CCLayerGradientLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_BLENDFUNC) == 0) { +void CCLayerGradientLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { ((CCLayerGradient *)pNode)->setBlendFunc(pCCBlendFunc); } else { CCLayerLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); @@ -43,8 +43,8 @@ void CCLayerGradientLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * p } -void CCLayerGradientLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_VECTOR) == 0) { +void CCLayerGradientLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_VECTOR) == 0) { ((CCLayerGradient *)pNode)->setVector(pPoint); // TODO Not passed along the ccbi file. diff --git a/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.h b/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.h index 6565fdc02f..e149b6ae54 100644 --- a/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.h @@ -12,10 +12,10 @@ class CCLayerGradientLoader : public CCLayerLoader { protected: virtual CCLayerGradient * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeColor3(CCNode *, CCNode *, std::string, ccColor3B, CCBReader *); - virtual void onHandlePropTypeByte(CCNode *, CCNode *, std::string, unsigned char, CCBReader *); - virtual void onHandlePropTypePoint(CCNode *, CCNode *, std::string, CCPoint, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B, CCBReader *); + virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char, CCBReader *); + virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBIReader/CCLayerLoader.cpp b/cocos2dx/extensions/CCBIReader/CCLayerLoader.cpp index 739e023a9e..e8326df324 100644 --- a/cocos2dx/extensions/CCBIReader/CCLayerLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCLayerLoader.cpp @@ -12,15 +12,15 @@ CCLayer * CCLayerLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) return CCLayer::node(); } -void CCLayerLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, std::string pPropertyName, bool pCheck, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_TOUCH_ENABLED) == 0) { +void CCLayerLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_TOUCH_ENABLED) == 0) { ((CCLayer *)pNode)->setIsTouchEnabled(pCheck); - } else if(pPropertyName.compare(PROPERTY_ACCELEROMETER_ENABLED) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_ACCELEROMETER_ENABLED) == 0) { ((CCLayer *)pNode)->setIsAccelerometerEnabled(pCheck); - } else if(pPropertyName.compare(PROPERTY_MOUSE_ENABLED) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_MOUSE_ENABLED) == 0) { // TODO XXX CCLOG("The property '%s' is not supported!", PROPERTY_MOUSE_ENABLED); - } else if(pPropertyName.compare(PROPERTY_KEYBOARD_ENABLED) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_KEYBOARD_ENABLED) == 0) { // TODO XXX CCLOG("The property '%s' is not supported!", PROPERTY_KEYBOARD_ENABLED); // This comes closest: ((CCLayer *)pNode)->setIsKeypadEnabled(pCheck); diff --git a/cocos2dx/extensions/CCBIReader/CCLayerLoader.h b/cocos2dx/extensions/CCBIReader/CCLayerLoader.h index dec385f247..34f43ea4e4 100644 --- a/cocos2dx/extensions/CCBIReader/CCLayerLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCLayerLoader.h @@ -12,7 +12,7 @@ class CCLayerLoader : public CCNodeLoader { protected: virtual CCLayer * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeCheck(CCNode *, CCNode *, std::string, bool, CCBReader *); + virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader .cpp b/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader .cpp index 3e9ad01216..2a27499629 100644 --- a/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader .cpp +++ b/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader .cpp @@ -11,12 +11,12 @@ CCMenuItemImage * CCMenuItemImageLoader::createCCNode(CCNode * pParent, CCBReade return CCMenuItemImage::node(); } -void CCMenuItemImageLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_NORMALDISPLAYFRAME) == 0) { +void CCMenuItemImageLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_NORMALDISPLAYFRAME) == 0) { ((CCMenuItemImage *)pNode)->setNormalSpriteFrame(pCCSpriteFrame); - } else if(pPropertyName.compare(PROPERTY_SELECTEDDISPLAYFRAME) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_SELECTEDDISPLAYFRAME) == 0) { ((CCMenuItemImage *)pNode)->setSelectedSpriteFrame(pCCSpriteFrame); - } else if(pPropertyName.compare(PROPERTY_DISABLEDDISPLAYFRAME) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_DISABLEDDISPLAYFRAME) == 0) { ((CCMenuItemImage *)pNode)->setDisabledSpriteFrame(pCCSpriteFrame); } else { CCMenuItemLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pCCSpriteFrame, pCCBReader); diff --git a/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader.h b/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader.h index ab79908e4d..4cd4f2ece0 100644 --- a/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader.h @@ -12,7 +12,7 @@ class CCMenuItemImageLoader : public CCMenuItemLoader { protected: virtual CCMenuItemImage * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeSpriteFrame(CCNode *, CCNode *, std::string, CCSpriteFrame *, CCBReader *); + virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame *, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp b/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp index 5bf69cf070..0bc3fc4514 100644 --- a/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp @@ -6,16 +6,16 @@ using namespace cocos2d::extension; #define PROPERTY_BLOCK "block" #define PROPERTY_ISENABLED "isEnabled" -void CCMenuItemLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, std::string pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_BLOCK) == 0) { +void CCMenuItemLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_BLOCK) == 0) { ((CCMenuItem *)pNode)->setTarget(pBlockData->mTarget, pBlockData->mSELMenuHandler); } else { CCNodeLoader::onHandlePropTypeBlock(pNode, pParent, pPropertyName, pBlockData, pCCBReader); } } -void CCMenuItemLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, std::string pPropertyName, bool pCheck, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_ISENABLED) == 0) { +void CCMenuItemLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_ISENABLED) == 0) { ((CCMenuItem *)pNode)->setIsEnabled(pCheck); } else { CCNodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader); diff --git a/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.h b/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.h index d8c5c9c9eb..44643df6ee 100644 --- a/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.h @@ -12,8 +12,8 @@ class CCMenuItemLoader : public CCNodeLoader { protected: virtual CCMenuItem * createCCNode(CCNode *, CCBReader *) = 0; - virtual void onHandlePropTypeBlock(CCNode *, CCNode *, std::string, BlockData *, CCBReader *); - virtual void onHandlePropTypeCheck(CCNode *, CCNode *, std::string, bool, CCBReader *); + virtual void onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockData *, CCBReader *); + virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp index f134fe4c8d..d70275763f 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp @@ -9,7 +9,7 @@ #define PROPERTY_IGNOREANCHORPOINTFORPOSITION "ignoreAnchorPointForPosition" #define PROPERTY_VISIBLE "visible" -#define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) printf("Unexpected property: '%s'!\n", PROPERTY.c_str()); assert(false) +#define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) printf("Unexpected property: '%s'!\n", PROPERTY); assert(false) #define ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) printf("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false) using namespace cocos2d; @@ -31,7 +31,7 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * int propertyCount = pCCBReader->readInt(false); for(int i = 0; i < propertyCount; i++) { int type = pCCBReader->readInt(false); - std::string propertyName = pCCBReader->readCachedString(); + const char * propertyName = pCCBReader->readCachedString(); // Check if the property can be set for this platform bool setProp = false; @@ -199,28 +199,28 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * break; } case kCCBPropTypeFntFile: { - std::string fntFile = this->parsePropTypeFntFile(pNode, pParent, pCCBReader); + const char * fntFile = this->parsePropTypeFntFile(pNode, pParent, pCCBReader); if(setProp) { this->onHandlePropTypeFntFile(pNode, pParent, propertyName, fntFile, pCCBReader); } break; } case kCCBPropTypeFontTTF: { - std::string fontTTF = this->parsePropTypeFontTTF(pNode, pParent, pCCBReader); + const char * fontTTF = this->parsePropTypeFontTTF(pNode, pParent, pCCBReader); if(setProp) { this->onHandlePropTypeFontTTF(pNode, pParent, propertyName, fontTTF, pCCBReader); } break; } case kCCBPropTypeString: { - std::string string = this->parsePropTypeString(pNode, pParent, pCCBReader); + const char * string = this->parsePropTypeString(pNode, pParent, pCCBReader); if(setProp) { this->onHandlePropTypeString(pNode, pParent, propertyName, string, pCCBReader); } break; } case kCCBPropTypeText: { - std::string text = this->parsePropTypeText(pNode, pParent, pCCBReader); + const char * text = this->parsePropTypeText(pNode, pParent, pCCBReader); if(setProp) { this->onHandlePropTypeText(pNode, pParent, propertyName, text, pCCBReader); } @@ -350,7 +350,7 @@ float * CCNodeLoader::parsePropTypeScaleLock(CCNode * pNode, CCNode * pParent, C int type = pCCBReader->readInt(false); - if (type == kCCBScaleTypeMultiplyResolution) { + if(type == kCCBScaleTypeMultiplyResolution) { x *= pCCBReader->getResolutionScale(); y *= pCCBReader->getResolutionScale(); } @@ -375,7 +375,7 @@ float CCNodeLoader::parsePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CC int type = pCCBReader->readInt(false); - if (type == kCCBScaleTypeMultiplyResolution) { + if(type == kCCBScaleTypeMultiplyResolution) { f *= pCCBReader->getResolutionScale(); } @@ -407,34 +407,34 @@ bool CCNodeLoader::parsePropTypeCheck(CCNode * pNode, CCNode * pParent, CCBReade CCSpriteFrame * CCNodeLoader::parsePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - std::string spriteSheet = pCCBReader->readCachedString(); - std::string spriteFile = pCCBReader->readCachedString(); + const char * spriteSheet = pCCBReader->readCachedString(); + const char * spriteFile = pCCBReader->readCachedString(); CCSpriteFrame * spriteFrame; - if (spriteSheet.compare("") == 0) { - if (spriteFile.compare("") == 0) { + if(strcmp(spriteSheet, "") == 0) { + if(strcmp(spriteFile, "") == 0) { return NULL; } - CCTexture2D * texture = CCTextureCache::sharedTextureCache()->addImage(spriteFile.c_str()); + CCTexture2D * texture = CCTextureCache::sharedTextureCache()->addImage(spriteFile); CCRect bounds = CCRect::CCRect(0, 0, texture->getContentSize().width, texture->getContentSize().height); spriteFrame = CCSpriteFrame::frameWithTexture(texture, bounds); } else { CCSpriteFrameCache * frameCache = CCSpriteFrameCache::sharedSpriteFrameCache(); /* Load the sprite sheet only if it is not loaded. */ - if (!pCCBReader->isSpriteSheetLoaded(spriteSheet)) { - frameCache->addSpriteFramesWithFile(spriteSheet.c_str()); + if(!pCCBReader->isSpriteSheetLoaded(spriteSheet)) { + frameCache->addSpriteFramesWithFile(spriteSheet); pCCBReader->addLoadedSpriteSheet(spriteSheet); } - spriteFrame = frameCache->spriteFrameByName(spriteFile.c_str()); + spriteFrame = frameCache->spriteFrameByName(spriteFile); } return spriteFrame; } CCAnimation * CCNodeLoader::parsePropTypeAnimation(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - std::string animationFile = pCCBReader->readCachedString(); - std::string animation = pCCBReader->readCachedString(); + const char * animationFile = pCCBReader->readCachedString(); + const char * animation = pCCBReader->readCachedString(); CCAnimation * ccAnimation = NULL; @@ -446,19 +446,19 @@ CCAnimation * CCNodeLoader::parsePropTypeAnimation(CCNode * pNode, CCNode * pPar animation = pCCBReader->lastPathComponent(animation); animationFile = pCCBReader->lastPathComponent(animationFile); - if (animation.compare("") != 0) { + if(strcmp(animation, "") != 0) { CCAnimationCache * animationCache = CCAnimationCache::sharedAnimationCache(); - animationCache->addAnimationsWithFile(animationFile.c_str()); + animationCache->addAnimationsWithFile(animationFile); - ccAnimation = animationCache->animationByName(animation.c_str()); + ccAnimation = animationCache->animationByName(animation); } return ccAnimation; } CCTexture2D * CCNodeLoader::parsePropTypeTexture(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - std::string spriteFile = pCCBReader->readCachedString(); + const char * spriteFile = pCCBReader->readCachedString(); - return CCTextureCache::sharedTextureCache()->addImage(spriteFile.c_str()); + return CCTextureCache::sharedTextureCache()->addImage(spriteFile); } unsigned char CCNodeLoader::parsePropTypeByte(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { @@ -520,24 +520,24 @@ ccBlendFunc CCNodeLoader::parsePropTypeBlendFunc(CCNode * pNode, CCNode * pParen return blendFunc; } -std::string CCNodeLoader::parsePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { +const char * CCNodeLoader::parsePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { return pCCBReader->readCachedString(); } -std::string CCNodeLoader::parsePropTypeString(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { +const char * CCNodeLoader::parsePropTypeString(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { return pCCBReader->readCachedString(); } -std::string CCNodeLoader::parsePropTypeText(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { +const char * CCNodeLoader::parsePropTypeText(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { return pCCBReader->readCachedString(); } -std::string CCNodeLoader::parsePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - std::string fnt = pCCBReader->readCachedString(); +const char * CCNodeLoader::parsePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + const char * fnt = pCCBReader->readCachedString(); - std::string ttfEnding("ttf"); + const char * ttfEnding("ttf"); - if (pCCBReader->endsWith(pCCBReader->toLowerCase(fnt), ttfEnding)){ + if(pCCBReader->endsWith(pCCBReader->toLowerCase(fnt), ttfEnding)){ fnt = pCCBReader->deletePathExtension(pCCBReader->lastPathComponent(fnt)); } @@ -545,19 +545,19 @@ std::string CCNodeLoader::parsePropTypeFontTTF(CCNode * pNode, CCNode * pParent, } BlockData * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - std::string selectorName = pCCBReader->readCachedString(); + const char * selectorName = pCCBReader->readCachedString(); int selectorTarget = pCCBReader->readInt(false); if(selectorTarget != kCCBTargetTypeNone) { CCObject * target = NULL; if(selectorTarget == kCCBTargetTypeDocumentRoot) { target = pCCBReader->getRootNode(); - } else if (selectorTarget == kCCBTargetTypeOwner) { + } else if(selectorTarget == kCCBTargetTypeOwner) { target = pCCBReader->getOwner(); } if(target != NULL) { - if(selectorName.length() > 0) { + if(strlen(selectorName) > 0) { CCBSelectorResolver * ccbSelectorResolver = pCCBReader->getCCBSelectorResolver(); if(ccbSelectorResolver != NULL) { BlockData * blockData = new BlockData(); @@ -567,7 +567,7 @@ BlockData * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, C return blockData; } else { - CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName.c_str()); + CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName); } } else { CCLOG("Unexpected empty selector."); @@ -581,7 +581,7 @@ BlockData * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, C } BlockCCControlData * CCNodeLoader::parsePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - std::string selectorName = pCCBReader->readCachedString(); + const char * selectorName = pCCBReader->readCachedString(); int selectorTarget = pCCBReader->readInt(false); int controlEvents = pCCBReader->readInt(false); @@ -589,12 +589,12 @@ BlockCCControlData * CCNodeLoader::parsePropTypeBlockCCControl(CCNode * pNode, C CCObject * target = NULL; if(selectorTarget == kCCBTargetTypeDocumentRoot) { target = pCCBReader->getRootNode(); - } else if (selectorTarget == kCCBTargetTypeOwner) { + } else if(selectorTarget == kCCBTargetTypeOwner) { target = pCCBReader->getOwner(); } if(target != NULL) { - if(selectorName.length() > 0) { + if(strlen(selectorName) > 0) { CCBSelectorResolver * ccbSelectorResolver = pCCBReader->getCCBSelectorResolver(); if(ccbSelectorResolver != NULL) { BlockCCControlData * blockCCControlData = new BlockCCControlData(); @@ -605,7 +605,7 @@ BlockCCControlData * CCNodeLoader::parsePropTypeBlockCCControl(CCNode * pNode, C return blockCCControlData; } else { - CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName.c_str()); + CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName); } } else { CCLOG("Unexpected empty selector."); @@ -619,14 +619,19 @@ BlockCCControlData * CCNodeLoader::parsePropTypeBlockCCControl(CCNode * pNode, C } CCNode * CCNodeLoader::parsePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - std::string ccbFileName = pCCBReader->readCachedString(); + const char * ccbFileName = pCCBReader->readCachedString(); /* Change path extension to .ccbi. */ - std::string ccbiFileName = pCCBReader->deletePathExtension(ccbFileName) + std::string(".ccbi"); + const char * ccbFileWithoutPathExtension = pCCBReader->deletePathExtension(ccbFileName); + int ccbiFileNameLenght = strlen(ccbFileWithoutPathExtension) + strlen(".ccbi"); + char * ccbiFileName = new char[ccbiFileNameLenght + 1]; // TODO Memory leak? + strcpy(ccbiFileName, ccbFileWithoutPathExtension); + strcat(ccbiFileName, ".ccbi"); + ccbiFileName[ccbiFileNameLenght] = '\0'; CCBReader * ccbReader = new CCBReader(pCCBReader); - CCNode * ccbFileNode = ccbReader->readNodeGraphFromFile(ccbiFileName.c_str(), pCCBReader->getOwner(), pParent->getContentSize()); + CCNode * ccbFileNode = ccbReader->readNodeGraphFromFile(ccbiFileName, pCCBReader->getOwner(), pParent->getContentSize()); delete ccbReader; @@ -635,36 +640,36 @@ CCNode * CCNodeLoader::parsePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CC -void CCNodeLoader::onHandlePropTypePosition(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCPoint pPosition, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_POSITION) == 0) { +void CCNodeLoader::onHandlePropTypePosition(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPosition, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_POSITION) == 0) { pNode->setPosition(pPosition); } else { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } -void CCNodeLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_ANCHORPOINT) == 0) { +void CCNodeLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_ANCHORPOINT) == 0) { pNode->setAnchorPoint(pPoint); } else { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } -void CCNodeLoader::onHandlePropTypePointLock(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCPoint pPointLock, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypePointLock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPointLock, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSize pSize, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_CONTENTSIZE) == 0) { +void CCNodeLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize pSize, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_CONTENTSIZE) == 0) { pNode->setContentSize(pSize); } else { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } -void CCNodeLoader::onHandlePropTypeScaleLock(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float * pScaleLock, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_SCALE) == 0) { +void CCNodeLoader::onHandlePropTypeScaleLock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float * pScaleLock, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_SCALE) == 0) { pNode->setScaleX(pScaleLock[0]); pNode->setScaleY(pScaleLock[1]); } else { @@ -672,104 +677,104 @@ void CCNodeLoader::onHandlePropTypeScaleLock(CCNode * pNode, CCNode * pParent, s } } -void CCNodeLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float pFloat, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloat, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeDegrees(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float pDegrees, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_ROTATION) == 0) { +void CCNodeLoader::onHandlePropTypeDegrees(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pDegrees, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_ROTATION) == 0) { pNode->setRotation(pDegrees); } else { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } -void CCNodeLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float pFloatScale, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloatScale, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, std::string pPropertyName, int pInteger, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_TAG) == 0) { +void CCNodeLoader::onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pInteger, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_TAG) == 0) { pNode->setTag(pInteger); } else { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } -void CCNodeLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, std::string pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float * pFloatVar, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float * pFloatVar, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, std::string pPropertyName, bool pCheck, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_VISIBLE) == 0) { +void CCNodeLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_VISIBLE) == 0) { pNode->setIsVisible(pCheck); - } else if(pPropertyName.compare(PROPERTY_IGNOREANCHORPOINTFORPOSITION) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_IGNOREANCHORPOINTFORPOSITION) == 0) { pNode->setIsRelativeAnchorPoint(!pCheck); } else { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } -void CCNodeLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeAnimation(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCAnimation * pCCAnimation, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeAnimation(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCAnimation * pCCAnimation, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, std::string pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, std::string pPropertyName, bool * pFlip, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool * pFlip, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pFntFile, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pFntFile, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeString(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pString, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeString(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pString, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pText, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pText, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, std::string pPropertyName, std::string pFontTTF, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, std::string pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, std::string pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } \ No newline at end of file diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.h b/cocos2dx/extensions/CCBIReader/CCNodeLoader.h index df5838ec4e..86ab5eaa78 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.h @@ -48,42 +48,42 @@ class CC_DLL CCNodeLoader { virtual ccColor4F * parsePropTypeColor4FVar(CCNode *, CCNode *, CCBReader *); virtual bool * parsePropTypeFlip(CCNode *, CCNode *, CCBReader *); virtual ccBlendFunc parsePropTypeBlendFunc(CCNode *, CCNode *, CCBReader *); - virtual std::string parsePropTypeFntFile(CCNode *, CCNode *, CCBReader *); - virtual std::string parsePropTypeString(CCNode *, CCNode *, CCBReader *); - virtual std::string parsePropTypeText(CCNode *, CCNode *, CCBReader *); - virtual std::string parsePropTypeFontTTF(CCNode *, CCNode *, CCBReader *); + virtual const char * parsePropTypeFntFile(CCNode *, CCNode *, CCBReader *); + virtual const char * parsePropTypeString(CCNode *, CCNode *, CCBReader *); + virtual const char * parsePropTypeText(CCNode *, CCNode *, CCBReader *); + virtual const char * parsePropTypeFontTTF(CCNode *, CCNode *, CCBReader *); virtual BlockData * parsePropTypeBlock(CCNode *, CCNode *, CCBReader *); virtual BlockCCControlData * parsePropTypeBlockCCControl(CCNode *, CCNode *, CCBReader *); virtual CCNode * parsePropTypeCCBFile(CCNode *, CCNode *, CCBReader *); - virtual void onHandlePropTypePosition(CCNode *, CCNode *, std::string, CCPoint, CCBReader *); - virtual void onHandlePropTypePoint(CCNode *, CCNode *, std::string, CCPoint, CCBReader *); - virtual void onHandlePropTypePointLock(CCNode *, CCNode *, std::string, CCPoint, CCBReader *); - virtual void onHandlePropTypeSize(CCNode *, CCNode *, std::string, CCSize, CCBReader *); - virtual void onHandlePropTypeScaleLock(CCNode *, CCNode *, std::string, float *, CCBReader *); - virtual void onHandlePropTypeFloat(CCNode *, CCNode *, std::string, float, CCBReader *); - virtual void onHandlePropTypeDegrees(CCNode *, CCNode *, std::string, float, CCBReader *); - virtual void onHandlePropTypeFloatScale(CCNode *, CCNode *, std::string, float, CCBReader *); - virtual void onHandlePropTypeInteger(CCNode *, CCNode *, std::string, int, CCBReader *); - virtual void onHandlePropTypeIntegerLabeled(CCNode *, CCNode *, std::string, int, CCBReader *); - virtual void onHandlePropTypeFloatVar(CCNode *, CCNode *, std::string, float *, CCBReader *); - virtual void onHandlePropTypeCheck(CCNode *, CCNode *, std::string, bool, CCBReader *); - virtual void onHandlePropTypeSpriteFrame(CCNode *, CCNode *, std::string, CCSpriteFrame *, CCBReader *); - virtual void onHandlePropTypeAnimation(CCNode *, CCNode *, std::string, CCAnimation *, CCBReader *); - virtual void onHandlePropTypeTexture(CCNode *, CCNode *, std::string, CCTexture2D *, CCBReader *); - virtual void onHandlePropTypeByte(CCNode *, CCNode *, std::string, unsigned char, CCBReader *); - virtual void onHandlePropTypeColor3(CCNode *, CCNode *, std::string, ccColor3B, CCBReader *); - virtual void onHandlePropTypeColor4FVar(CCNode *, CCNode *, std::string, ccColor4F *, CCBReader *); - virtual void onHandlePropTypeFlip(CCNode *, CCNode *, std::string, bool *, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *); - virtual void onHandlePropTypeFntFile(CCNode *, CCNode *, std::string, std::string, CCBReader *); - virtual void onHandlePropTypeString(CCNode *, CCNode *, std::string, std::string, CCBReader *); - virtual void onHandlePropTypeText(CCNode *, CCNode *, std::string, std::string, CCBReader *); - virtual void onHandlePropTypeFontTTF(CCNode *, CCNode *, std::string, std::string, CCBReader *); - virtual void onHandlePropTypeBlock(CCNode *, CCNode *, std::string, BlockData *, CCBReader *); - virtual void onHandlePropTypeBlockCCControl(CCNode *, CCNode *, std::string, BlockCCControlData *, CCBReader *); - virtual void onHandlePropTypeCCBFile(CCNode *, CCNode *, std::string, CCNode *, CCBReader *); + virtual void onHandlePropTypePosition(CCNode *, CCNode *, const char *, CCPoint, CCBReader *); + virtual void onHandlePropTypePoint(CCNode *, CCNode *, const char *, CCPoint, CCBReader *); + virtual void onHandlePropTypePointLock(CCNode *, CCNode *, const char *, CCPoint, CCBReader *); + virtual void onHandlePropTypeSize(CCNode *, CCNode *, const char *, CCSize, CCBReader *); + virtual void onHandlePropTypeScaleLock(CCNode *, CCNode *, const char *, float *, CCBReader *); + virtual void onHandlePropTypeFloat(CCNode *, CCNode *, const char *, float, CCBReader *); + virtual void onHandlePropTypeDegrees(CCNode *, CCNode *, const char *, float, CCBReader *); + virtual void onHandlePropTypeFloatScale(CCNode *, CCNode *, const char *, float, CCBReader *); + virtual void onHandlePropTypeInteger(CCNode *, CCNode *, const char *, int, CCBReader *); + virtual void onHandlePropTypeIntegerLabeled(CCNode *, CCNode *, const char *, int, CCBReader *); + virtual void onHandlePropTypeFloatVar(CCNode *, CCNode *, const char *, float *, CCBReader *); + virtual void onHandlePropTypeCheck(CCNode *, CCNode *, const char *, bool, CCBReader *); + virtual void onHandlePropTypeSpriteFrame(CCNode *, CCNode *, const char *, CCSpriteFrame *, CCBReader *); + virtual void onHandlePropTypeAnimation(CCNode *, CCNode *, const char *, CCAnimation *, CCBReader *); + virtual void onHandlePropTypeTexture(CCNode *, CCNode *, const char *, CCTexture2D *, CCBReader *); + virtual void onHandlePropTypeByte(CCNode *, CCNode *, const char *, unsigned char, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode *, CCNode *, const char *, ccColor3B, CCBReader *); + virtual void onHandlePropTypeColor4FVar(CCNode *, CCNode *, const char *, ccColor4F *, CCBReader *); + virtual void onHandlePropTypeFlip(CCNode *, CCNode *, const char *, bool *, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, const char *, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeFntFile(CCNode *, CCNode *, const char *, const char *, CCBReader *); + virtual void onHandlePropTypeString(CCNode *, CCNode *, const char *, const char *, CCBReader *); + virtual void onHandlePropTypeText(CCNode *, CCNode *, const char *, const char *, CCBReader *); + virtual void onHandlePropTypeFontTTF(CCNode *, CCNode *, const char *, const char *, CCBReader *); + virtual void onHandlePropTypeBlock(CCNode *, CCNode *, const char *, BlockData *, CCBReader *); + virtual void onHandlePropTypeBlockCCControl(CCNode *, CCNode *, const char *, BlockCCControlData *, CCBReader *); + virtual void onHandlePropTypeCCBFile(CCNode *, CCNode *, const char *, CCNode *, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.cpp b/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.cpp index fd37bcce37..490bb29417 100644 --- a/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.cpp @@ -30,77 +30,77 @@ CCParticleSystemQuad * CCParticleSystemQuadLoader::createCCNode(CCNode * pParent return CCParticleSystemQuad::node(); } -void CCParticleSystemQuadLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, std::string pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_EMITERMODE) == 0) { +void CCParticleSystemQuadLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_EMITERMODE) == 0) { ((CCParticleSystemQuad *)pNode)->setEmitterMode(pIntegerLabeled); } else { CCNodeLoader::onHandlePropTypeIntegerLabeled(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader); } } -void CCParticleSystemQuadLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_POSVAR) == 0) { +void CCParticleSystemQuadLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_POSVAR) == 0) { ((CCParticleSystemQuad *)pNode)->setPosVar(pPoint); - } else if(pPropertyName.compare(PROPERTY_GRAVITY) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_GRAVITY) == 0) { ((CCParticleSystemQuad *)pNode)->setGravity(pPoint); } else { CCNodeLoader::onHandlePropTypePoint(pNode, pParent, pPropertyName, pPoint, pCCBReader); } } -void CCParticleSystemQuadLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float pFloat, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_EMISSIONRATE) == 0) { +void CCParticleSystemQuadLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloat, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_EMISSIONRATE) == 0) { ((CCParticleSystemQuad *)pNode)->setEmissionRate(pFloat); - } else if(pPropertyName.compare(PROPERTY_DURATION) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_DURATION) == 0) { ((CCParticleSystemQuad *)pNode)->setDuration(pFloat); } else { CCNodeLoader::onHandlePropTypeFloat(pNode, pParent, pPropertyName, pFloat, pCCBReader); } } -void CCParticleSystemQuadLoader::onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, std::string pPropertyName, int pInteger, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_TOTALPARTICLES) == 0) { +void CCParticleSystemQuadLoader::onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pInteger, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_TOTALPARTICLES) == 0) { ((CCParticleSystemQuad *)pNode)->setTotalParticles(pInteger); } else { CCNodeLoader::onHandlePropTypeInteger(pNode, pParent, pPropertyName, pInteger, pCCBReader); } } -void CCParticleSystemQuadLoader::onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float * pFloatVar, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_LIFE) == 0) { +void CCParticleSystemQuadLoader::onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float * pFloatVar, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_LIFE) == 0) { ((CCParticleSystemQuad *)pNode)->setLife(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setLifeVar(pFloatVar[1]); - } else if(pPropertyName.compare(PROPERTY_STARTSIZE) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_STARTSIZE) == 0) { ((CCParticleSystemQuad *)pNode)->setStartSize(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setStartSizeVar(pFloatVar[1]); - } else if(pPropertyName.compare(PROPERTY_ENDSIZE) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_ENDSIZE) == 0) { ((CCParticleSystemQuad *)pNode)->setEndSize(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setEndSizeVar(pFloatVar[1]); - } else if(pPropertyName.compare(PROPERTY_STARTSPIN) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_STARTSPIN) == 0) { ((CCParticleSystemQuad *)pNode)->setStartSpin(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setStartSpinVar(pFloatVar[1]); - } else if(pPropertyName.compare(PROPERTY_ENDSPIN) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_ENDSPIN) == 0) { ((CCParticleSystemQuad *)pNode)->setEndSpin(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setEndSpinVar(pFloatVar[1]); - } else if(pPropertyName.compare(PROPERTY_ANGLE) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_ANGLE) == 0) { ((CCParticleSystemQuad *)pNode)->setAngle(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setAngleVar(pFloatVar[1]); - } else if(pPropertyName.compare(PROPERTY_SPEED) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_SPEED) == 0) { ((CCParticleSystemQuad *)pNode)->setSpeed(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setSpeedVar(pFloatVar[1]); - } else if(pPropertyName.compare(PROPERTY_TANGENTIALACCEL) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_TANGENTIALACCEL) == 0) { ((CCParticleSystemQuad *)pNode)->setTangentialAccel(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setTangentialAccelVar(pFloatVar[1]); - } else if(pPropertyName.compare(PROPERTY_RADIALACCEL) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_RADIALACCEL) == 0) { ((CCParticleSystemQuad *)pNode)->setRadialAccel(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setRadialAccelVar(pFloatVar[1]); - } else if(pPropertyName.compare(PROPERTY_STARTRADIUS) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_STARTRADIUS) == 0) { ((CCParticleSystemQuad *)pNode)->setStartRadius(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setStartRadiusVar(pFloatVar[1]); - } else if(pPropertyName.compare(PROPERTY_ENDRADIUS) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_ENDRADIUS) == 0) { ((CCParticleSystemQuad *)pNode)->setEndRadius(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setEndRadiusVar(pFloatVar[1]); - } else if(pPropertyName.compare(PROPERTY_ROTATEPERSECOND) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_ROTATEPERSECOND) == 0) { ((CCParticleSystemQuad *)pNode)->setRotatePerSecond(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setRotatePerSecondVar(pFloatVar[1]); } else { @@ -108,11 +108,11 @@ void CCParticleSystemQuadLoader::onHandlePropTypeFloatVar(CCNode * pNode, CCNode } } -void CCParticleSystemQuadLoader::onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_STARTCOLOR) == 0) { +void CCParticleSystemQuadLoader::onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_STARTCOLOR) == 0) { ((CCParticleSystemQuad *)pNode)->setStartColor(pCCColor4FVar[0]); ((CCParticleSystemQuad *)pNode)->setStartColorVar(pCCColor4FVar[1]); - } else if(pPropertyName.compare(PROPERTY_ENDCOLOR) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_ENDCOLOR) == 0) { ((CCParticleSystemQuad *)pNode)->setEndColor(pCCColor4FVar[0]); ((CCParticleSystemQuad *)pNode)->setEndColorVar(pCCColor4FVar[1]); } else { @@ -120,16 +120,16 @@ void CCParticleSystemQuadLoader::onHandlePropTypeColor4FVar(CCNode * pNode, CCNo } } -void CCParticleSystemQuadLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_BLENDFUNC) == 0) { +void CCParticleSystemQuadLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { ((CCParticleSystemQuad *)pNode)->setBlendFunc(pCCBlendFunc); } else { CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); } } -void CCParticleSystemQuadLoader::onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_TEXTURE) == 0) { +void CCParticleSystemQuadLoader::onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_TEXTURE) == 0) { ((CCParticleSystemQuad *)pNode)->setTexture(pCCTexture2D); } else { CCNodeLoader::onHandlePropTypeTexture(pNode, pParent, pPropertyName, pCCTexture2D, pCCBReader); diff --git a/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.h b/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.h index 8e46562ef0..8250af8142 100644 --- a/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.h @@ -12,14 +12,14 @@ class CCParticleSystemQuadLoader : public CCNodeLoader { protected: virtual CCParticleSystemQuad * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeIntegerLabeled(CCNode *, CCNode *, std::string, int, CCBReader *); - virtual void onHandlePropTypePoint(CCNode *, CCNode *, std::string, CCPoint, CCBReader *); - virtual void onHandlePropTypeFloat(CCNode *, CCNode *, std::string, float, CCBReader *); - virtual void onHandlePropTypeInteger(CCNode *, CCNode *, std::string, int, CCBReader *); - virtual void onHandlePropTypeFloatVar(CCNode *, CCNode *, std::string, float *, CCBReader *); - virtual void onHandlePropTypeColor4FVar(CCNode *, CCNode *, std::string, ccColor4F *, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *); - virtual void onHandlePropTypeTexture(CCNode *, CCNode *, std::string, CCTexture2D *, CCBReader *); + virtual void onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int, CCBReader *); + virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint, CCBReader *); + virtual void onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float, CCBReader *); + virtual void onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int, CCBReader *); + virtual void onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float *, CCBReader *); + virtual void onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor4F *, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCTexture2D *, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.cpp b/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.cpp index 077bdf490e..5259f00f13 100644 --- a/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.cpp @@ -18,32 +18,32 @@ CCScale9Sprite * CCScale9SpriteLoader::createCCNode(CCNode * pParent, CCBReader return CCScale9Sprite::node(); } -void CCScale9SpriteLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_SPRITEFRAME) == 0) { +void CCScale9SpriteLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_SPRITEFRAME) == 0) { ((CCScale9Sprite *)pNode)->initWithSpriteFrame(pCCSpriteFrame); } else { CCNodeLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pCCSpriteFrame, pCCBReader); } } -void CCScale9SpriteLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_COLOR) == 0) { +void CCScale9SpriteLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) { ((CCScale9Sprite *)pNode)->setColor(pCCColor3B); } else { CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); } } -void CCScale9SpriteLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, std::string pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_OPACITY) == 0) { +void CCScale9SpriteLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) { ((CCScale9Sprite *)pNode)->setOpacity(pByte); } else { CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); } } -void CCScale9SpriteLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_BLENDFUNC) == 0) { +void CCScale9SpriteLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { // TODO Not exported by CocosBuilder yet! // ((CCScale9Sprite *)pNode)->setBlendFunc(pCCBlendFunc); } else { @@ -51,24 +51,24 @@ void CCScale9SpriteLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pP } } -void CCScale9SpriteLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSize pSize, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_CONTENTSIZE) == 0) { +void CCScale9SpriteLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize pSize, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_CONTENTSIZE) == 0) { //((CCScale9Sprite *)pNode)->setContentSize(pSize); - } else if(pPropertyName.compare(PROPERTY_PREFEREDSIZE) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_PREFEREDSIZE) == 0) { ((CCScale9Sprite *)pNode)->setPreferredSize(pSize); } else { CCNodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, pCCBReader); } } -void CCScale9SpriteLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, std::string pPropertyName, float pFloat, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_INSETLEFT) == 0) { +void CCScale9SpriteLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloat, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_INSETLEFT) == 0) { ((CCScale9Sprite *)pNode)->setInsetLeft(pFloat); - } else if(pPropertyName.compare(PROPERTY_INSETTOP) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_INSETTOP) == 0) { ((CCScale9Sprite *)pNode)->setInsetTop(pFloat); - } else if(pPropertyName.compare(PROPERTY_INSETRIGHT) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_INSETRIGHT) == 0) { ((CCScale9Sprite *)pNode)->setInsetRight(pFloat); - } else if(pPropertyName.compare(PROPERTY_INSETBOTTOM) == 0) { + } else if(strcmp(pPropertyName, PROPERTY_INSETBOTTOM) == 0) { ((CCScale9Sprite *)pNode)->setInsetBottom(pFloat); } else { CCNodeLoader::onHandlePropTypeFloat(pNode, pParent, pPropertyName, pFloat, pCCBReader); diff --git a/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.h b/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.h index accf7a8495..7c14c0f465 100644 --- a/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.h @@ -12,12 +12,12 @@ class CCScale9SpriteLoader : public CCNodeLoader { protected: virtual CCScale9Sprite * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeColor3(CCNode *, CCNode *, std::string, ccColor3B, CCBReader *); - virtual void onHandlePropTypeByte(CCNode *, CCNode *, std::string, unsigned char, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *); - virtual void onHandlePropTypeSpriteFrame(CCNode *, CCNode *, std::string, CCSpriteFrame *, CCBReader *); - virtual void onHandlePropTypeSize(CCNode *, CCNode *, std::string, CCSize, CCBReader *); - virtual void onHandlePropTypeFloat(CCNode *, CCNode *, std::string, float, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B, CCBReader *); + virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame *, CCBReader *); + virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize, CCBReader *); + virtual void onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBIReader/CCSpriteLoader.cpp b/cocos2dx/extensions/CCBIReader/CCSpriteLoader.cpp index 7b040b21eb..9d660c3edd 100644 --- a/cocos2dx/extensions/CCBIReader/CCSpriteLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCSpriteLoader.cpp @@ -13,16 +13,16 @@ CCSprite * CCSpriteLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader return CCSprite::node(); } -void CCSpriteLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, std::string pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_DISPLAYFRAME) == 0) { +void CCSpriteLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_DISPLAYFRAME) == 0) { ((CCSprite *)pNode)->setDisplayFrame(pCCSpriteFrame); } else { CCNodeLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pCCSpriteFrame, pCCBReader); } } -void CCSpriteLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, std::string pPropertyName, bool * pFlip, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_FLIP) == 0) { +void CCSpriteLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool * pFlip, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_FLIP) == 0) { ((CCSprite *)pNode)->setFlipX(pFlip[0]); ((CCSprite *)pNode)->setFlipX(pFlip[1]); } else { @@ -30,24 +30,24 @@ void CCSpriteLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, std: } } -void CCSpriteLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_COLOR) == 0) { +void CCSpriteLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) { ((CCSprite *)pNode)->setColor(pCCColor3B); } else { CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); } } -void CCSpriteLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, std::string pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_OPACITY) == 0) { +void CCSpriteLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) { ((CCSprite *)pNode)->setOpacity(pByte); } else { CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); } } -void CCSpriteLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, std::string pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { - if(pPropertyName.compare(PROPERTY_BLENDFUNC) == 0) { +void CCSpriteLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { + if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { ((CCSprite *)pNode)->setBlendFunc(pCCBlendFunc); } else { CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); diff --git a/cocos2dx/extensions/CCBIReader/CCSpriteLoader.h b/cocos2dx/extensions/CCBIReader/CCSpriteLoader.h index 04b0782649..84ac7fd6f4 100644 --- a/cocos2dx/extensions/CCBIReader/CCSpriteLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCSpriteLoader.h @@ -12,11 +12,11 @@ class CCSpriteLoader : public CCNodeLoader { protected: virtual CCSprite * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeColor3(CCNode *, CCNode *, std::string, ccColor3B, CCBReader *); - virtual void onHandlePropTypeByte(CCNode *, CCNode *, std::string, unsigned char, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, std::string, ccBlendFunc, CCBReader *); - virtual void onHandlePropTypeSpriteFrame(CCNode *, CCNode *, std::string, CCSpriteFrame *, CCBReader *); - virtual void onHandlePropTypeFlip(CCNode *, CCNode *, std::string, bool *, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B, CCBReader *); + virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame *, CCBReader *); + virtual void onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool *, CCBReader *); }; NS_CC_EXT_END From 7733607fe213b0ee62b06b5feed7f4833df2b08e Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 5 Jun 2012 10:51:53 +0800 Subject: [PATCH 074/257] fixed #1296: fix logical error of CCTMXTileMap::tilesetForLayer() --- cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp index 29ee6d50e5..d4fd318ced 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp @@ -146,7 +146,7 @@ CCTMXTilesetInfo * CCTMXTiledMap::tilesetForLayer(CCTMXLayerInfo *layerInfo, CCT { CCTMXTilesetInfo* tileset = NULL; CCObject* pObj = NULL; - CCARRAY_FOREACH_REVERSE(tilesets, pObj); + CCARRAY_FOREACH_REVERSE(tilesets, pObj) { tileset = (CCTMXTilesetInfo*)pObj; if (tileset) From 56817244ed5eeed8dd8a739f19bc800427ea333c Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 5 Jun 2012 15:27:46 +0800 Subject: [PATCH 075/257] fixed #1297: Retina mode can't work in 'Projection2D' mode. --- cocos2dx/CCDirector.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 4140a4d2db..b4c2d7d58f 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -349,7 +349,7 @@ void CCDirector::setProjection(ccDirectorProjection kProjection) kmGLMatrixMode(KM_GL_PROJECTION); kmGLLoadIdentity(); kmMat4 orthoMatrix; - kmMat4OrthographicProjection(&orthoMatrix, 0, size.width, 0, size.height, -1024, 1024 ); + kmMat4OrthographicProjection(&orthoMatrix, 0, size.width / CC_CONTENT_SCALE_FACTOR(), 0, size.height / CC_CONTENT_SCALE_FACTOR(), -1024, 1024 ); kmGLMultMatrix(&orthoMatrix); kmGLMatrixMode(KM_GL_MODELVIEW); kmGLLoadIdentity(); From 0702becaf5a93cd2e2356b2d262bf1d05905c964 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Tue, 5 Jun 2012 16:22:42 -0700 Subject: [PATCH 076/257] CCAutoreleasepool: Fixed typo. --- cocos2dx/cocoa/CCAutoreleasePool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/cocoa/CCAutoreleasePool.cpp b/cocos2dx/cocoa/CCAutoreleasePool.cpp index 82c8c5b45e..fae7b822fc 100644 --- a/cocos2dx/cocoa/CCAutoreleasePool.cpp +++ b/cocos2dx/cocoa/CCAutoreleasePool.cpp @@ -43,7 +43,7 @@ void CCAutoreleasePool::addObject(CCObject* pObject) { m_pManagedObjectArray->addObject(pObject); - CCAssert(pObject->m_uReference > 1, "reference count should greager than 1"); + CCAssert(pObject->m_uReference > 1, "reference count should be greater than 1"); pObject->release(); // no ref count, in this case autorelease pool added. } From 2d86a4089c4428ca1b25d23c09249569ab72ac90 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Tue, 5 Jun 2012 17:11:50 -0700 Subject: [PATCH 077/257] CCLabelBMFont: Now using std::string to store internal data instead of just storing a 'foreign' const char *. --- cocos2dx/label_nodes/CCLabelBMFont.cpp | 8 +++----- cocos2dx/label_nodes/CCLabelBMFont.h | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index b29828f664..c02407477f 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -807,7 +807,7 @@ bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile, f m_pConfiguration = FNTConfigLoadFile(fntFile); m_pConfiguration->retain(); - m_pFntFile = fntFile; + m_sFntFile = fntFile; CCAssert( m_pConfiguration, "Error creating config for LabelBMFont"); texture = CCTextureCache::sharedTextureCache()->addImage(this->m_pConfiguration->m_sAtlasName.c_str()); @@ -856,7 +856,6 @@ CCLabelBMFont::~CCLabelBMFont() { CC_SAFE_DELETE(this->m_sString); CC_SAFE_RELEASE(this->m_pConfiguration); - CC_SAFE_DELETE(this->m_pFntFile); } // LabelBMFont - Atlas generation @@ -1355,8 +1354,7 @@ void CCLabelBMFont::setWidth(float width) void CCLabelBMFont::setFntFile(const char *fntFile) { - CC_SAFE_DELETE(m_pFntFile); - this->m_pFntFile = fntFile; + this->m_sFntFile = fntFile; CCBMFontConfiguration * newConfiguration = FNTConfigLoadFile(fntFile); CCAssert(newConfiguration, printf("CCLabelBMFont: Impossible to create font. Please check file: '%@'", fntFile) ); @@ -1402,7 +1400,7 @@ float CCLabelBMFont::getLetterPosXRight( CCSprite* sp ) } const char * CCLabelBMFont::getFntFile() { - return this->m_pFntFile; + return this->m_sFntFile.c_str(); } //LabelBMFont - Debug draw #if CC_LABELBMFONT_DEBUG_DRAW diff --git a/cocos2dx/label_nodes/CCLabelBMFont.h b/cocos2dx/label_nodes/CCLabelBMFont.h index 596eca535d..0f6bf57654 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.h +++ b/cocos2dx/label_nodes/CCLabelBMFont.h @@ -167,7 +167,7 @@ protected: bool m_bLineBreakWithoutSpaces; // offset of the texture atlas CCPoint m_tImageOffset; - const char * m_pFntFile; + std::string m_sFntFile; public: CCLabelBMFont(); From c9db868d93cabefc716bfba4941316c82c278a51 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Tue, 5 Jun 2012 17:12:41 -0700 Subject: [PATCH 078/257] CCLabelTTF: Now internally using std::string instead of std::string *. --- cocos2dx/label_nodes/CCLabelTTF.cpp | 41 +++++++++++------------------ cocos2dx/label_nodes/CCLabelTTF.h | 7 ++--- 2 files changed, 19 insertions(+), 29 deletions(-) diff --git a/cocos2dx/label_nodes/CCLabelTTF.cpp b/cocos2dx/label_nodes/CCLabelTTF.cpp index 20b03b5b1e..ae75392954 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.cpp +++ b/cocos2dx/label_nodes/CCLabelTTF.cpp @@ -40,16 +40,13 @@ NS_CC_BEGIN // CCLabelTTF::CCLabelTTF() : m_eAlignment(CCTextAlignmentCenter) - , m_pFontName(NULL) , m_fFontSize(0.0) - , m_pString(NULL) { } CCLabelTTF::~CCLabelTTF() { - CC_SAFE_DELETE(m_pFontName); - CC_SAFE_DELETE(m_pString); + } CCLabelTTF * CCLabelTTF::node() @@ -105,8 +102,7 @@ bool CCLabelTTF::initWithString(const char *label, const CCSize& dimensions, CCT m_tDimensions = CCSizeMake( dimensions.width * CC_CONTENT_SCALE_FACTOR(), dimensions.height * CC_CONTENT_SCALE_FACTOR() ); m_eAlignment = alignment; - CC_SAFE_DELETE(m_pFontName); - m_pFontName = new std::string(fontName); + m_sFontName = fontName; m_fFontSize = fontSize * CC_CONTENT_SCALE_FACTOR(); this->setString(label); @@ -124,8 +120,7 @@ bool CCLabelTTF::initWithString(const char *label, const char *fontName, float f m_tDimensions = CCSizeZero; - CC_SAFE_DELETE(m_pFontName); - m_pFontName = new std::string(fontName); + m_sFontName = fontName; m_fFontSize = fontSize * CC_CONTENT_SCALE_FACTOR(); this->setString(label); @@ -135,16 +130,15 @@ bool CCLabelTTF::initWithString(const char *label, const char *fontName, float f } const char * CCLabelTTF::getFontName() { - return this->m_pFontName->c_str(); + return this->m_sFontName.c_str(); } void CCLabelTTF::setFontName(const char *fontName) { - if(this->m_pFontName == NULL || strcmp(this->m_pFontName->c_str(), fontName)) + if(strcmp(this->m_sFontName.c_str(), fontName) != 0) { - CC_SAFE_DELETE(m_pFontName); - this->m_pFontName = new std::string(fontName); + this->m_sFontName = fontName; - this->setString(this->m_pString->c_str()); + this->setString(this->m_sString.c_str()); } } float CCLabelTTF::getFontSize() @@ -157,7 +151,7 @@ void CCLabelTTF::setFontSize(float fontSize) { this->m_fFontSize = fontSize; - this->setString(this->m_pString->c_str()); + this->setString(this->m_sString.c_str()); } } void CCLabelTTF::setDimensions(CCSize dimensions) @@ -166,7 +160,7 @@ void CCLabelTTF::setDimensions(CCSize dimensions) { this->m_tDimensions = dimensions; - this->setString(this->m_pString->c_str()); + this->setString(this->m_sString.c_str()); } } void CCLabelTTF::setHorizontalAlignment(CCTextAlignment pCCTextAlignment) @@ -175,28 +169,23 @@ void CCLabelTTF::setHorizontalAlignment(CCTextAlignment pCCTextAlignment) { this->m_eAlignment = pCCTextAlignment; - this->setString(this->m_pString->c_str()); + this->setString(this->m_sString.c_str()); } } void CCLabelTTF::setString(const char *label) { - if (m_pString) - { - delete m_pString; - m_pString = NULL; - } - m_pString = new std::string(label); + m_sString = label; CCTexture2D *texture; if( CCSize::CCSizeEqualToSize( m_tDimensions, CCSizeZero ) ) { texture = new CCTexture2D(); - texture->initWithString(label, m_pFontName->c_str(), m_fFontSize); + texture->initWithString(label, m_sFontName.c_str(), m_fFontSize); } else { texture = new CCTexture2D(); - texture->initWithString(label, m_tDimensions, m_eAlignment, m_pFontName->c_str(), m_fFontSize); + texture->initWithString(label, m_tDimensions, m_eAlignment, m_sFontName.c_str(), m_fFontSize); } // TODO @@ -227,12 +216,12 @@ void CCLabelTTF::setString(const char *label) const char* CCLabelTTF::getString(void) { - return m_pString->c_str(); + return m_sString.c_str(); } const char* CCLabelTTF::description() { - return CCString::stringWithFormat("", m_pFontName->c_str(), m_fFontSize)->getCString(); + return CCString::stringWithFormat("", m_sFontName.c_str(), m_fFontSize)->getCString(); } NS_CC_END diff --git a/cocos2dx/label_nodes/CCLabelTTF.h b/cocos2dx/label_nodes/CCLabelTTF.h index 65bea47cea..9a6ba56ccf 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.h +++ b/cocos2dx/label_nodes/CCLabelTTF.h @@ -55,11 +55,12 @@ public: /** Creates an label. */ static CCLabelTTF * node(); + + virtual const char* getString(); /** changes the string to render * @warning Changing the string is as expensive as creating a new CCLabelTTF. To obtain better performance use CCLabelAtlas */ virtual void setString(const char *label); - virtual const char* getString(void); virtual const char* getFontName(); virtual void setFontName(const char *fontName); virtual float getFontSize(); @@ -74,10 +75,10 @@ protected: CCSize m_tDimensions; CCTextAlignment m_eAlignment; /** Font name used in the label */ - std::string * m_pFontName; + std::string m_sFontName; /** Font size of the label */ float m_fFontSize; - std::string * m_pString; + std::string m_sString; }; NS_CC_END From bcf53f1453cee7db914f7901931ce6fb5624ce73 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Tue, 5 Jun 2012 17:15:28 -0700 Subject: [PATCH 079/257] Added CCNodeLoaderLibrary (more of a factory pattern, compared to adding the CCNodeLoaders directly to the CCBReader. Fixed all TODOs regarding (potential) memory leaks (Thanks to Ricardo Quesada). CCNodeLoaders are now autorelease objects (having a static 'loader()' method to be used). --- .../extensions/CCBIReader/CCBFileLoader.h | 3 + cocos2dx/extensions/CCBIReader/CCBReader.cpp | 108 +++++++----------- cocos2dx/extensions/CCBIReader/CCBReader.h | 37 +++--- .../CCBIReader/CCControlButtonLoader.cpp | 12 +- .../CCBIReader/CCControlButtonLoader.h | 3 + .../extensions/CCBIReader/CCControlLoader.cpp | 3 +- .../CCBIReader/CCLabelBMFontLoader.h | 3 + .../extensions/CCBIReader/CCLabelTTFLoader.h | 3 + .../CCBIReader/CCLayerColorLoader.h | 2 + .../CCBIReader/CCLayerGradientLoader.h | 3 + .../extensions/CCBIReader/CCLayerLoader.h | 3 + .../CCBIReader/CCMenuItemImageLoader.h | 3 + cocos2dx/extensions/CCBIReader/CCMenuLoader.h | 3 + .../extensions/CCBIReader/CCNodeLoader.cpp | 14 +-- cocos2dx/extensions/CCBIReader/CCNodeLoader.h | 4 +- .../CCBIReader/CCNodeLoaderLibrary.cpp | 89 +++++++++++++++ .../CCBIReader/CCNodeLoaderLibrary.h | 32 ++++++ .../CCBIReader/CCParticleSystemQuadLoader.h | 3 + .../CCBIReader/CCScale9SpriteLoader.h | 3 + .../extensions/CCBIReader/CCSpriteLoader.h | 3 + 20 files changed, 235 insertions(+), 99 deletions(-) create mode 100644 cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.cpp create mode 100644 cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.h diff --git a/cocos2dx/extensions/CCBIReader/CCBFileLoader.h b/cocos2dx/extensions/CCBIReader/CCBFileLoader.h index ad44cd1d00..0a33589d79 100644 --- a/cocos2dx/extensions/CCBIReader/CCBFileLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCBFileLoader.h @@ -9,6 +9,9 @@ NS_CC_EXT_BEGIN class CCBReader; class CCBFileLoader : public CCNodeLoader { + public: + STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCBFileLoader, loader); + protected: virtual CCNode * createCCNode(CCNode *, CCBReader *); diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.cpp b/cocos2dx/extensions/CCBIReader/CCBReader.cpp index 7db6e5c551..f5108ac668 100644 --- a/cocos2dx/extensions/CCBIReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCBReader.cpp @@ -1,19 +1,7 @@ #include "CCBReader.h" #include "CCNodeLoader.h" -#include "CCLayerLoader.h" -#include "CCLayerColorLoader.h" -#include "CCLayerGradientLoader.h" -#include "CCLabelBMFontLoader.h" -#include "CCLabelTTFLoader.h" -#include "CCSpriteLoader.h" -#include "CCScale9SpriteLoader.h" -#include "CCBFileLoader.h" -#include "CCMenuLoader.h" -#include "CCMenuItemLoader.h" -#include "CCMenuItemImageLoader.h" -#include "CCControlButtonLoader.h" -#include "CCParticleSystemQuadLoader.h" +#include "CCNodeLoaderLibrary.h" #ifdef __CC_PLATFORM_IOS #import @@ -22,56 +10,55 @@ using namespace cocos2d; using namespace cocos2d::extension; -CCBReader::CCBReader(CCBMemberVariableAssigner * pCCBMemberVariableAssigner, CCBSelectorResolver * pCCBSelectorResolver) { +CCBReader::CCBReader(CCNodeLoaderLibrary * pCCNodeLoaderLibrary, CCBMemberVariableAssigner * pCCBMemberVariableAssigner, CCBSelectorResolver * pCCBSelectorResolver) { + this->mRootNode = NULL; + this->mRootCCBReader = true; + + this->mCCNodeLoaderLibrary = pCCNodeLoaderLibrary; this->mCCBMemberVariableAssigner = pCCBMemberVariableAssigner; this->mCCBSelectorResolver = pCCBSelectorResolver; this->mResolutionScale = 1; - + #ifdef __CC_PLATFORM_IOS /* iPad */ if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { this->mResolutionScale = 2; } #endif - - this->registerCCNodeLoader("CCNode", new CCNodeLoader()); - this->registerCCNodeLoader("CCLayer", new CCLayerLoader()); - this->registerCCNodeLoader("CCLayerColor", new CCLayerColorLoader()); - this->registerCCNodeLoader("CCLayerGradient", new CCLayerGradientLoader()); - this->registerCCNodeLoader("CCSprite", new CCSpriteLoader()); - this->registerCCNodeLoader("CCLabelBMFont", new CCLabelBMFontLoader()); - this->registerCCNodeLoader("CCLabelTTF", new CCLabelTTFLoader()); - this->registerCCNodeLoader("CCScale9Sprite", new CCScale9SpriteLoader()); - this->registerCCNodeLoader("CCBFile", new CCBFileLoader()); - this->registerCCNodeLoader("CCMenu", new CCMenuLoader()); - this->registerCCNodeLoader("CCMenuItemImage", new CCMenuItemImageLoader()); - this->registerCCNodeLoader("CCControlButton", new CCControlButtonLoader()); - this->registerCCNodeLoader("CCParticleSystemQuad", new CCParticleSystemQuadLoader()); } CCBReader::~CCBReader() { - if(this->mBytes) { + if(this->mBytes != NULL) { delete this->mBytes; this->mBytes = NULL; } - // TODO Also delete mCCNodeLoaders, mLoadedSpritesheets, etc... ? (Keep in mind they might be copied/inherited from another CCBReader through the copy constructor!) + /* Clear string cache. */ + this->mStringCache.clear(); + + if(this->mRootCCBReader) { + /* Clear loaded spritesheets. */ + this->mLoadedSpriteSheets.clear(); + } + + if(this->mRootNode != NULL) { + this->mRootNode->release(); + } } CCBReader::CCBReader(CCBReader * pCCBReader) { - /* Borrow data from the 'parent' CCBLoader. */ + this->mRootNode = NULL; + this->mRootCCBReader = false; + + /* Borrow data from the 'parent' CCBReader. */ this->mResolutionScale = pCCBReader->mResolutionScale; this->mLoadedSpriteSheets = pCCBReader->mLoadedSpriteSheets; - this->mCCNodeLoaders = pCCBReader->mCCNodeLoaders; + this->mCCNodeLoaderLibrary = pCCBReader->mCCNodeLoaderLibrary; this->mCCBMemberVariableAssigner = pCCBReader->mCCBMemberVariableAssigner; this->mCCBSelectorResolver = pCCBReader->mCCBSelectorResolver; } -void CCBReader::registerCCNodeLoader(const char * pClassName, CCNodeLoader * pCCNodeLoader) { - this->mCCNodeLoaders.insert(std::pair(pClassName, pCCNodeLoader)); -} - CCBMemberVariableAssigner * CCBReader::getCCBMemberVariableAssigner() { return this->mCCBMemberVariableAssigner; } @@ -84,19 +71,13 @@ float CCBReader::getResolutionScale() { return this->mResolutionScale; } -CCNodeLoader * CCBReader::getCCNodeLoader(const char * pClassName) { - std::map::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName); - assert(ccNodeLoadersIterator != this->mCCNodeLoaders.end()); - return ccNodeLoadersIterator->second; -} - CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBFileName, CCObject * pOwner) { return this->readNodeGraphFromFile(pCCBFileName, pOwner, CCDirector::sharedDirector()->getWinSize()); } CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize) { const char * path = CCFileUtils::fullPathFromRelativePath(pCCBFileName); - + unsigned long size = 0; this->mBytes = CCFileUtils::getFileData(path, "r", &size); @@ -104,15 +85,15 @@ CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBFileName, CCObject * this->mCurrentBit = 0; this->mOwner = pOwner; this->mRootContainerSize = pRootContainerSize; - + if(!this->readHeader()) { return NULL; } - + if(!this->readStringCache()) { return NULL; } - + return this->readNodeGraph(); } @@ -157,13 +138,11 @@ void CCBReader::readStringCacheEntry() { int numBytes = b0 << 8 | b1; const char * src = (const char *) (this->mBytes + this->mCurrentByte); - char * ptr = new char[numBytes + 1]; // TODO I'm most likely leaking memory here. Unfortunately I'm not sure if I can safely delete the items in the mStringCache in ~CCBReader. =( - strncpy(ptr, src, numBytes); - ptr[numBytes] = '\0'; + std::string string(src, numBytes); this->mCurrentByte += numBytes; - this->mStringCache.push_back(ptr); + this->mStringCache.push_back(string); } unsigned char CCBReader::readByte() { @@ -263,7 +242,7 @@ void CCBReader::alignBits() { const char * CCBReader::readCachedString() { int i = this->readInt(false); - return this->mStringCache[i]; + return this->mStringCache[i].c_str(); } CCNode * CCBReader::readNodeGraph(CCNode * pParent) { @@ -276,23 +255,24 @@ CCNode * CCBReader::readNodeGraph(CCNode * pParent) { memberVarAssignmentName = this->readCachedString(); } - CCNodeLoader * ccNodeLoader = this->getCCNodeLoader(className); + CCNodeLoader * ccNodeLoader = this->mCCNodeLoaderLibrary->getCCNodeLoader(className); CCNode * node = ccNodeLoader->loadCCNode(pParent, this); /* Set root node, if not set yet. */ if(this->mRootNode == NULL) { - this->mRootNode = node; // TODO retain? + this->mRootNode = node; + this->mRootNode->retain(); } if(memberVarAssignmentType != kCCBTargetTypeNone) { CCObject * target = NULL; if(memberVarAssignmentType == kCCBTargetTypeDocumentRoot) { - target = this->getRootNode(); - } else if (memberVarAssignmentType == kCCBTargetTypeOwner) { - target = this->getOwner(); + target = this->mRootNode; + } else if(memberVarAssignmentType == kCCBTargetTypeOwner) { + target = this->mOwner; } - if (target != NULL) { + if(target != NULL) { if(this->mCCBMemberVariableAssigner != NULL) { this->mCCBMemberVariableAssigner->onAssignCCBMemberVariable(target, memberVarAssignmentName, node); } @@ -305,7 +285,7 @@ CCNode * CCBReader::readNodeGraph(CCNode * pParent) { CCNode * child = this->readNodeGraph(node); node->addChild(child); } - + // TODO /* if([node respondsToSelector:@selector(didLoadFromCCB)]) { @@ -345,37 +325,33 @@ void CCBReader::addLoadedSpriteSheet(const char * pSpriteSheet) { } const char * CCBReader::lastPathComponent(const char * pPath) { - // TODO Memory leaks? std::string path(pPath); int slashPos = path.find_last_of("/"); - if (slashPos != std::string::npos) { + if(slashPos != std::string::npos) { return path.substr(slashPos + 1, path.length() - slashPos).c_str(); } return pPath; } const char * CCBReader::deletePathExtension(const char * pPath) { - // TODO Memory leaks? std::string path(pPath); int dotPos = path.find_last_of("."); - if (dotPos != std::string::npos) { + if(dotPos != std::string::npos) { return path.substr(0, dotPos).c_str(); } return pPath; } const char * CCBReader::toLowerCase(const char * pString) { - // TODO Memory leaks? std::string copy(pString); std::transform(copy.begin(), copy.end(), copy.begin(), ::tolower); return copy.c_str(); } bool CCBReader::endsWith(const char * pString, const char * pEnding) { - // TODO Memory leaks? std::string string(pString); std::string ending(pEnding); - if (string.length() >= ending.length()) { + if(string.length() >= ending.length()) { return (string.compare(string.length() - ending.length(), ending.length(), ending) == 0); } else { return false; diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.h b/cocos2dx/extensions/CCBIReader/CCBReader.h index 22d010a655..5e370c804c 100644 --- a/cocos2dx/extensions/CCBIReader/CCBReader.h +++ b/cocos2dx/extensions/CCBIReader/CCBReader.h @@ -5,6 +5,12 @@ #include "CCBMemberVariableAssigner.h" #include "CCBSelectorResolver.h" +#define STATIC_NEW_AUTORELEASE_OBJECT_METHOD(T, METHOD) static T * METHOD() { \ +T * t = new T(); \ +t->autorelease(); \ +return t; \ +} + #define kCCBVersion 2 #define kCCBPropTypePosition 0 @@ -68,20 +74,17 @@ NS_CC_EXT_BEGIN -struct cmp_str { - bool operator() (char const *a, char const *b) { - return std::strcmp(a, b) < 0; - } -}; - /* Forward declaration. */ class CCNodeLoader; +class CCNodeLoaderLibrary; /** * @brief Parse CCBI file which is generated by CocosBuilder */ -class CC_DLL CCBReader : public CCObject { // TODO Why extend CCObject? -> Also all Loaders should extend from CCObject? - private: +class CC_DLL CCBReader : public CCObject { + private: + bool mRootCCBReader; + unsigned char * mBytes; int mCurrentByte; int mCurrentBit; @@ -90,24 +93,22 @@ class CC_DLL CCBReader : public CCObject { // TODO Why extend CCObject? -> Also CCSize mRootContainerSize; float mResolutionScale; + CCNodeLoaderLibrary * mCCNodeLoaderLibrary; CCBMemberVariableAssigner * mCCBMemberVariableAssigner; CCBSelectorResolver * mCCBSelectorResolver; - std::vector mStringCache; - std::map mCCNodeLoaders; - std::set mLoadedSpriteSheets; + std::vector mStringCache; + std::set mLoadedSpriteSheets; - public: + public: /* Constructor. */ - CCBReader(CCBMemberVariableAssigner * = NULL, CCBSelectorResolver * = NULL); + CCBReader(CCNodeLoaderLibrary *, CCBMemberVariableAssigner * = NULL, CCBSelectorResolver * = NULL); CCBReader(CCBReader *); /* Destructor. */ ~CCBReader(); CCNode * readNodeGraphFromFile(const char * pCCBFileName, CCObject * pOwner = NULL); CCNode * readNodeGraphFromFile(const char * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize); - void registerCCNodeLoader(const char * pClassName, CCNodeLoader * pCCNodeLoader); - CCNodeLoader * getCCNodeLoader(const char * pClassName); CCBMemberVariableAssigner * getCCBMemberVariableAssigner(); CCBSelectorResolver * getCCBSelectorResolver(); @@ -118,7 +119,7 @@ class CC_DLL CCBReader : public CCObject { // TODO Why extend CCObject? -> Also bool isSpriteSheetLoaded(const char *); void addLoadedSpriteSheet(const char *); - + /* Utility methods. */ const char * lastPathComponent(const char *); const char * deletePathExtension(const char *); @@ -131,14 +132,14 @@ class CC_DLL CCBReader : public CCObject { // TODO Why extend CCObject? -> Also bool readBool(); float readFloat(); const char * readCachedString(); - + private: bool readHeader(); bool readStringCache(); void readStringCacheEntry(); CCNode * readNodeGraph(); CCNode * readNodeGraph(CCNode *); - + bool getBit(); void alignBits(); const char * readUTF8(); diff --git a/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.cpp b/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.cpp index af70c85c5c..25381324fd 100644 --- a/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.cpp @@ -36,11 +36,17 @@ void CCControlButtonLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pPare void CCControlButtonLoader::onHandlePropTypeString(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pString, CCBReader * pCCBReader) { if(strcmp(pPropertyName, PROPERTY_TITLE_NORMAL) == 0) { - ((CCControlButton *)pNode)->setTitleForState(new CCString(pString), CCControlStateNormal); // TODO Leak? + CCString * ccString = new CCString(pString); + ccString->autorelease(); + ((CCControlButton *)pNode)->setTitleForState(ccString, CCControlStateNormal); } else if(strcmp(pPropertyName, PROPERTY_TITLE_HIGHLIGHTED) == 0) { - ((CCControlButton *)pNode)->setTitleForState(new CCString(pString), CCControlStateHighlighted); // TODO Leak? + CCString * ccString = new CCString(pString); + ccString->autorelease(); + ((CCControlButton *)pNode)->setTitleForState(ccString, CCControlStateHighlighted); } else if(strcmp(pPropertyName, PROPERTY_TITLE_DISABLED) == 0) { - ((CCControlButton *)pNode)->setTitleForState(new CCString(pString), CCControlStateDisabled); // TODO Leak? + CCString * ccString = new CCString(pString); + ccString->autorelease(); + ((CCControlButton *)pNode)->setTitleForState(ccString, CCControlStateDisabled); } else { CCControlLoader::onHandlePropTypeString(pNode, pParent, pPropertyName, pString, pCCBReader); } diff --git a/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.h b/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.h index 95f1889cca..6651bb0bd7 100644 --- a/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.h @@ -9,6 +9,9 @@ NS_CC_EXT_BEGIN class CCBReader; class CCControlButtonLoader : public CCControlLoader { + public: + STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCControlButtonLoader, loader); + protected: virtual CCControl * createCCNode(CCNode *, CCBReader *); diff --git a/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp b/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp index 3a36d7409f..304b4d0c21 100644 --- a/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp @@ -19,8 +19,7 @@ void CCControlLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, co void CCControlLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader) { if(strcmp(pPropertyName, PROPERTY_CCCONTROL) == 0) { - // TODO selector thingy... - ((CCControl *)pNode)->addTargetWithActionForControlEvents(pBlockCCControlData->mTarget, pBlockCCControlData->mSELMenuHandler, pBlockCCControlData->mControlEvents); // TODO First paramater is wrong! + ((CCControl *)pNode)->addTargetWithActionForControlEvents(pBlockCCControlData->mTarget, pBlockCCControlData->mSELMenuHandler, pBlockCCControlData->mControlEvents); } else { CCNodeLoader::onHandlePropTypeBlockCCControl(pNode, pParent, pPropertyName, pBlockCCControlData, pCCBReader); } diff --git a/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h b/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h index decb69f364..4731e818f8 100644 --- a/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h @@ -9,6 +9,9 @@ NS_CC_EXT_BEGIN class CCBReader; class CCLabelBMFontLoader : public CCNodeLoader { + public: + STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLabelBMFontLoader, loader); + protected: virtual CCLabelBMFont * createCCNode(CCNode *, CCBReader *); diff --git a/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.h b/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.h index 5bd2fdac34..224f62302b 100644 --- a/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.h @@ -9,6 +9,9 @@ NS_CC_EXT_BEGIN class CCBReader; class CCLabelTTFLoader : public CCNodeLoader { + public: + STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLabelTTFLoader, loader); + protected: virtual CCLabelTTF * createCCNode(CCNode *, CCBReader *); diff --git a/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.h b/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.h index 535d971d85..88a297e1a4 100644 --- a/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.h @@ -9,6 +9,8 @@ NS_CC_EXT_BEGIN class CCBReader; class CCLayerColorLoader : public CCLayerLoader { + public: + STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerColorLoader, loader); protected: virtual CCLayerColor * createCCNode(CCNode *, CCBReader *); diff --git a/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.h b/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.h index e149b6ae54..9f207269cb 100644 --- a/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.h @@ -9,6 +9,9 @@ NS_CC_EXT_BEGIN class CCBReader; class CCLayerGradientLoader : public CCLayerLoader { + public: + STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerGradientLoader, loader); + protected: virtual CCLayerGradient * createCCNode(CCNode *, CCBReader *); diff --git a/cocos2dx/extensions/CCBIReader/CCLayerLoader.h b/cocos2dx/extensions/CCBIReader/CCLayerLoader.h index 34f43ea4e4..162e79cb44 100644 --- a/cocos2dx/extensions/CCBIReader/CCLayerLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCLayerLoader.h @@ -9,6 +9,9 @@ NS_CC_EXT_BEGIN class CCBReader; class CCLayerLoader : public CCNodeLoader { + public: + STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerLoader, loader); + protected: virtual CCLayer * createCCNode(CCNode *, CCBReader *); diff --git a/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader.h b/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader.h index 4cd4f2ece0..09b2a760c1 100644 --- a/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader.h @@ -9,6 +9,9 @@ NS_CC_EXT_BEGIN class CCBReader; class CCMenuItemImageLoader : public CCMenuItemLoader { + public: + STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCMenuItemImageLoader, loader); + protected: virtual CCMenuItemImage * createCCNode(CCNode *, CCBReader *); diff --git a/cocos2dx/extensions/CCBIReader/CCMenuLoader.h b/cocos2dx/extensions/CCBIReader/CCMenuLoader.h index 37bce71745..59fbfc58cf 100644 --- a/cocos2dx/extensions/CCBIReader/CCMenuLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCMenuLoader.h @@ -9,6 +9,9 @@ NS_CC_EXT_BEGIN class CCBReader; class CCMenuLoader : public CCLayerLoader { + public: + STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCMenuLoader, loader); + protected: virtual CCMenu * createCCNode(CCNode *, CCBReader *); }; diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp index d70275763f..bdd09cbf10 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp @@ -84,7 +84,7 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * if(setProp) { this->onHandlePropTypeScaleLock(pNode, pParent, propertyName, scaleLock, pCCBReader); } - delete scaleLock; // TODO Can this just be deleted? + delete scaleLock; break; } case kCCBPropTypeFloat: { @@ -127,7 +127,7 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * if(setProp) { this->onHandlePropTypeFloatVar(pNode, pParent, propertyName, floatVar, pCCBReader); } - delete floatVar; // TODO Can this just be deleted? + delete floatVar; break; } case kCCBPropTypeCheck: { @@ -142,7 +142,6 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * if(setProp) { this->onHandlePropTypeSpriteFrame(pNode, pParent, propertyName, ccSpriteFrame, pCCBReader); } - // TODO delete ccSpriteFrame; ??? break; } case kCCBPropTypeAnimation: { @@ -150,7 +149,6 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * if(setProp) { this->onHandlePropTypeAnimation(pNode, pParent, propertyName, ccAnimation, pCCBReader); } - // TODO delete ccAnimation; ??? break; } case kCCBPropTypeTexture: { @@ -158,7 +156,6 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * if(setProp) { this->onHandlePropTypeTexture(pNode, pParent, propertyName, ccTexture2D, pCCBReader); } - // TODO delete ccTexture2D; ??? break; } case kCCBPropTypeByte: { @@ -180,7 +177,7 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * if(setProp) { this->onHandlePropTypeColor4FVar(pNode, pParent, propertyName, color4FVar, pCCBReader); } - delete color4FVar; // TODO Can this just be deleted? + delete color4FVar; break; } case kCCBPropTypeFlip: { @@ -624,17 +621,16 @@ CCNode * CCNodeLoader::parsePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CC /* Change path extension to .ccbi. */ const char * ccbFileWithoutPathExtension = pCCBReader->deletePathExtension(ccbFileName); int ccbiFileNameLenght = strlen(ccbFileWithoutPathExtension) + strlen(".ccbi"); - char * ccbiFileName = new char[ccbiFileNameLenght + 1]; // TODO Memory leak? + char ccbiFileName[ccbiFileNameLenght + 1]; strcpy(ccbiFileName, ccbFileWithoutPathExtension); strcat(ccbiFileName, ".ccbi"); ccbiFileName[ccbiFileNameLenght] = '\0'; CCBReader * ccbReader = new CCBReader(pCCBReader); + ccbReader->autorelease(); CCNode * ccbFileNode = ccbReader->readNodeGraphFromFile(ccbiFileName, pCCBReader->getOwner(), pParent->getContentSize()); - delete ccbReader; - return ccbFileNode; } diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.h b/cocos2dx/extensions/CCBIReader/CCNodeLoader.h index 86ab5eaa78..d0f88bbb5c 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.h @@ -20,8 +20,10 @@ struct BlockCCControlData { /* Forward declaration. */ class CCBReader; -class CC_DLL CCNodeLoader { +class CC_DLL CCNodeLoader : public CCObject { public: + STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCNodeLoader, loader); + virtual CCNode * loadCCNode(CCNode *, CCBReader *); virtual void parseProperties(CCNode *, CCNode *, CCBReader *); diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.cpp b/cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.cpp new file mode 100644 index 0000000000..5f9a05ca97 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.cpp @@ -0,0 +1,89 @@ +#include "CCNodeLoaderLibrary.h" + +#include "CCLayerLoader.h" +#include "CCLayerColorLoader.h" +#include "CCLayerGradientLoader.h" +#include "CCLabelBMFontLoader.h" +#include "CCLabelTTFLoader.h" +#include "CCSpriteLoader.h" +#include "CCScale9SpriteLoader.h" +#include "CCBFileLoader.h" +#include "CCMenuLoader.h" +#include "CCMenuItemLoader.h" +#include "CCMenuItemImageLoader.h" +#include "CCControlButtonLoader.h" +#include "CCParticleSystemQuadLoader.h" + +using namespace cocos2d; +using namespace cocos2d::extension; + +CCNodeLoaderLibrary::CCNodeLoaderLibrary() { + +} + +CCNodeLoaderLibrary::~CCNodeLoaderLibrary() { + this->purge(true); +} + +void CCNodeLoaderLibrary::registerDefaultCCNodeLoaders() { + this->registerCCNodeLoader("CCNode", CCNodeLoader::loader()); + this->registerCCNodeLoader("CCLayer", CCLayerLoader::loader()); + this->registerCCNodeLoader("CCLayerColor", CCLayerColorLoader::loader()); + this->registerCCNodeLoader("CCLayerGradient", CCLayerGradientLoader::loader()); + this->registerCCNodeLoader("CCSprite", CCSpriteLoader::loader()); + this->registerCCNodeLoader("CCLabelBMFont", CCLabelBMFontLoader::loader()); + this->registerCCNodeLoader("CCLabelTTF", CCLabelTTFLoader::loader()); + this->registerCCNodeLoader("CCScale9Sprite", CCScale9SpriteLoader::loader()); + this->registerCCNodeLoader("CCBFile", CCBFileLoader::loader()); + this->registerCCNodeLoader("CCMenu", CCMenuLoader::loader()); + this->registerCCNodeLoader("CCMenuItemImage", CCMenuItemImageLoader::loader()); + this->registerCCNodeLoader("CCControlButton", CCControlButtonLoader::loader()); + this->registerCCNodeLoader("CCParticleSystemQuad", CCParticleSystemQuadLoader::loader()); +} + +void CCNodeLoaderLibrary::registerCCNodeLoader(const char * pClassName, CCNodeLoader * pCCNodeLoader) { + this->mCCNodeLoaders.insert(std::pair(pClassName, pCCNodeLoader)); + pCCNodeLoader->retain(); +} + +void CCNodeLoaderLibrary::unregisterCCNodeLoader(const char * pClassName) { + std::map::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName); + assert(ccNodeLoadersIterator != this->mCCNodeLoaders.end()); + ccNodeLoadersIterator->second->release(); +} + +CCNodeLoader * CCNodeLoaderLibrary::getCCNodeLoader(const char * pClassName) { + std::map::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName); + assert(ccNodeLoadersIterator != this->mCCNodeLoaders.end()); + return ccNodeLoadersIterator->second; +} + +void CCNodeLoaderLibrary::purge(bool pDelete) { + if(pDelete) { + for(std::map::iterator it = this->mCCNodeLoaders.begin(); it != this->mCCNodeLoaders.end(); it++) { + it->second->release(); + } + } + this->mCCNodeLoaders.clear(); +} + + + +static CCNodeLoaderLibrary * sSharedCCNodeLoaderLibrary = NULL; + +CCNodeLoaderLibrary * CCNodeLoaderLibrary::sharedCCNodeLoaderLibrary() { + if(sSharedCCNodeLoaderLibrary == NULL) { + sSharedCCNodeLoaderLibrary = new CCNodeLoaderLibrary(); + + sSharedCCNodeLoaderLibrary->registerDefaultCCNodeLoaders(); + } + return sSharedCCNodeLoaderLibrary; +} + +CCNodeLoaderLibrary * CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary() { + CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::library(); + + ccNodeLoaderLibrary->registerDefaultCCNodeLoaders(); + + return ccNodeLoaderLibrary; +} \ No newline at end of file diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.h b/cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.h new file mode 100644 index 0000000000..de4d908bd5 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.h @@ -0,0 +1,32 @@ +#ifndef _CCNODE_LOADER_LIBRARY_H_ +#define _CCNODE_LOADER_LIBRARY_H_ + +#include "cocos2d.h" +#include "CCBReader.h" + +NS_CC_EXT_BEGIN + +class CC_DLL CCNodeLoaderLibrary : public CCObject { + private: + std::map mCCNodeLoaders; + + public: + STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCNodeLoaderLibrary, library); + + CCNodeLoaderLibrary(); + ~CCNodeLoaderLibrary(); + + void registerDefaultCCNodeLoaders(); + void registerCCNodeLoader(const char * pClassName, CCNodeLoader * pCCNodeLoader); + void unregisterCCNodeLoader(const char * pClassName); + CCNodeLoader * getCCNodeLoader(const char * pClassName); + void purge(bool pDelete); + + public: + static CCNodeLoaderLibrary * sharedCCNodeLoaderLibrary(); + static CCNodeLoaderLibrary * newDefaultCCNodeLoaderLibrary(); +}; + +NS_CC_EXT_END + +#endif diff --git a/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.h b/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.h index 8250af8142..9d75980758 100644 --- a/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.h @@ -9,6 +9,9 @@ NS_CC_EXT_BEGIN class CCBReader; class CCParticleSystemQuadLoader : public CCNodeLoader { + public: + STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCParticleSystemQuadLoader, loader); + protected: virtual CCParticleSystemQuad * createCCNode(CCNode *, CCBReader *); diff --git a/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.h b/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.h index 7c14c0f465..08f396f6bb 100644 --- a/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.h @@ -9,6 +9,9 @@ NS_CC_EXT_BEGIN class CCBReader; class CCScale9SpriteLoader : public CCNodeLoader { + public: + STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCScale9SpriteLoader, loader); + protected: virtual CCScale9Sprite * createCCNode(CCNode *, CCBReader *); diff --git a/cocos2dx/extensions/CCBIReader/CCSpriteLoader.h b/cocos2dx/extensions/CCBIReader/CCSpriteLoader.h index 84ac7fd6f4..cf98c92180 100644 --- a/cocos2dx/extensions/CCBIReader/CCSpriteLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCSpriteLoader.h @@ -9,6 +9,9 @@ NS_CC_EXT_BEGIN class CCBReader; class CCSpriteLoader : public CCNodeLoader { + public: + STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCSpriteLoader, loader); + protected: virtual CCSprite * createCCNode(CCNode *, CCBReader *); From 6bb2941ec98a225263eea7f17dcbfca8508d7e0b Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 6 Jun 2012 10:06:51 +0800 Subject: [PATCH 080/257] fixed #1300: Typo: CC_ENABLE_CACHE_TEXTTURE_DATA -> CC_ENABLE_CACHE_TEXTURE_DATA --- cocos2dx/misc_nodes/CCRenderTexture.cpp | 2 +- cocos2dx/platform/CCPlatformMacros.h | 6 +++--- cocos2dx/textures/CCTexture2D.cpp | 6 +++--- cocos2dx/textures/CCTextureCache.cpp | 14 +++++++------- cocos2dx/textures/CCTextureCache.h | 6 +++--- .../tests/RenderTextureTest/RenderTextureTest.cpp | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/cocos2dx/misc_nodes/CCRenderTexture.cpp b/cocos2dx/misc_nodes/CCRenderTexture.cpp index c4eb592e00..7c144aee43 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.cpp +++ b/cocos2dx/misc_nodes/CCRenderTexture.cpp @@ -224,7 +224,7 @@ void CCRenderTexture::end(bool bIsTOCacheTexture) director->setProjection(director->getProjection()); -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA if (bIsTOCacheTexture) { CC_SAFE_DELETE(m_pUITextureImage); diff --git a/cocos2dx/platform/CCPlatformMacros.h b/cocos2dx/platform/CCPlatformMacros.h index e3fda7014c..ce752969d2 100644 --- a/cocos2dx/platform/CCPlatformMacros.h +++ b/cocos2dx/platform/CCPlatformMacros.h @@ -31,16 +31,16 @@ #include "CCPlatformConfig.h" #include "CCPlatformDefine.h" -/** @def CC_ENABLE_CACHE_TEXTTURE_DATA +/** @def CC_ENABLE_CACHE_TEXTURE_DATA Enable it if you want to cache the texture data. Basically,it's only enabled in android It's new in cocos2d-x since v0.99.5 */ #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - #define CC_ENABLE_CACHE_TEXTTURE_DATA 1 + #define CC_ENABLE_CACHE_TEXTURE_DATA 1 #else - #define CC_ENABLE_CACHE_TEXTTURE_DATA 0 + #define CC_ENABLE_CACHE_TEXTURE_DATA 0 #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index 9bbc5feeaf..596fbaec37 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -45,7 +45,7 @@ THE SOFTWARE. #include "ccGLStateCache.h" #include "CCShaderCache.h" -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA #include "CCTextureCache.h" #endif @@ -78,7 +78,7 @@ CCTexture2D::CCTexture2D() CCTexture2D::~CCTexture2D() { -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA VolatileTexture::removeTexture(this); #endif @@ -417,7 +417,7 @@ bool CCTexture2D::initWithString(const char *text, const char *fontName, float f } bool CCTexture2D::initWithString(const char *text, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize) { -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA // cache the texture data VolatileTexture::addStringTexture(this, text, dimensions, alignment, fontName, fontSize); #endif diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index 5fc57f22c7..c691a65f2d 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -361,7 +361,7 @@ void CCTextureCache::addImageAsyncCallBack(ccTime dt) texture->initWithImage(pImage); #endif -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA // cache the texture file name VolatileTexture::addImageTexture(texture, filename, pImageInfo->imageType); #endif @@ -449,7 +449,7 @@ CCTexture2D * CCTextureCache::addImage(const char * path) if( texture ) { -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA // cache the texture file name VolatileTexture::addImageTexture(texture, fullpath.c_str(), eImageFormat); #endif @@ -527,7 +527,7 @@ CCTexture2D * CCTextureCache::addPVRImage(const char* path) tex = new CCTexture2D(); if(tex != NULL && tex->initWithPVRFile(fullpath.c_str()) ) { -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA // cache the texture file name VolatileTexture::addImageTexture(tex, fullpath.c_str(), CCImage::kFmtRawData); #endif @@ -582,7 +582,7 @@ CCTexture2D* CCTextureCache::addUIImage(CCImage *image, const char *key) } while (0); -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA VolatileTexture::addCCImage(texture, image); #endif @@ -667,7 +667,7 @@ CCTexture2D* CCTextureCache::textureForKey(const char* key) void CCTextureCache::reloadAllTextures() { -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA VolatileTexture::reloadAllTextures(); #endif } @@ -699,7 +699,7 @@ void CCTextureCache::dumpCachedTextureInfo() CCLOG("cocos2d: CCTextureCache dumpDebugInfo: %ld textures, for %lu KB (%.2f MB)", (long)count, (long)totalBytes / 1024, totalBytes / (1024.0f*1024.0f)); } -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA std::list VolatileTexture::textures; bool VolatileTexture::isReloading = false; @@ -897,7 +897,7 @@ void VolatileTexture::reloadAllTextures() isReloading = false; } -#endif // CC_ENABLE_CACHE_TEXTTURE_DATA +#endif // CC_ENABLE_CACHE_TEXTURE_DATA NS_CC_END diff --git a/cocos2dx/textures/CCTextureCache.h b/cocos2dx/textures/CCTextureCache.h index 1ed542a5ed..8a98477b41 100644 --- a/cocos2dx/textures/CCTextureCache.h +++ b/cocos2dx/textures/CCTextureCache.h @@ -33,7 +33,7 @@ THE SOFTWARE. #include "CCTexture2D.h" -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA #include "CCImage.h" #include #endif @@ -163,12 +163,12 @@ public: CCTexture2D* addPVRImage(const char* filename); /** Reload all textures - It's only useful when the value of CC_ENABLE_CACHE_TEXTTURE_DATA is 1 + It's only useful when the value of CC_ENABLE_CACHE_TEXTURE_DATA is 1 */ static void reloadAllTextures(); }; -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA class VolatileTexture { diff --git a/tests/tests/RenderTextureTest/RenderTextureTest.cpp b/tests/tests/RenderTextureTest/RenderTextureTest.cpp index 821fbcf970..b4f42d3410 100644 --- a/tests/tests/RenderTextureTest/RenderTextureTest.cpp +++ b/tests/tests/RenderTextureTest/RenderTextureTest.cpp @@ -195,7 +195,7 @@ void RenderTextureTest::ccTouchesMoved(CCSet* touches, CCEvent* event) void RenderTextureTest::ccTouchesEnded(CCSet* touches, CCEvent* event) { -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA CCSetIterator it; CCTouch* touch; From 2238db301bf3332dd9fc9e5d376183ee5a94b2e8 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 6 Jun 2012 14:13:40 +0800 Subject: [PATCH 081/257] fixed #1301: CCEGLView::sharedOpenGLView().setScissorInPoints() should apply scissor in points. --- HelloWorld/proj.win32/HelloWorld.win32.vcproj | 4 ++-- cocos2dx/CCDirector.cpp | 3 +-- cocos2dx/platform/CCEGLViewProtocol.cpp | 22 ++++++++++++------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/HelloWorld/proj.win32/HelloWorld.win32.vcproj b/HelloWorld/proj.win32/HelloWorld.win32.vcproj index a691858006..9dc1b267d0 100644 --- a/HelloWorld/proj.win32/HelloWorld.win32.vcproj +++ b/HelloWorld/proj.win32/HelloWorld.win32.vcproj @@ -61,7 +61,7 @@ /> setViewPortInPoints(0, 0, size.width, size.height); + m_pobOpenGLView->setViewPortInPoints(0, 0, sizePoint.width, sizePoint.height); } switch (kProjection) diff --git a/cocos2dx/platform/CCEGLViewProtocol.cpp b/cocos2dx/platform/CCEGLViewProtocol.cpp index ccf65b5a57..9b0607e532 100644 --- a/cocos2dx/platform/CCEGLViewProtocol.cpp +++ b/cocos2dx/platform/CCEGLViewProtocol.cpp @@ -97,6 +97,8 @@ CCSize CCEGLViewProtocol::getSize() CCSize size; if (m_bNeedScale) { + // retina and scale mode can't be opened at the same time + CCAssert(CC_CONTENT_SCALE_FACTOR() == 1.0f, "retina and scale mode can't be opened at the same time!"); size.setSize(m_sSizeInPoint.width, m_sSizeInPoint.height); } else @@ -135,6 +137,7 @@ void CCEGLViewProtocol::setViewPortInPoints(float x , float y , float w , float { if (m_bNeedScale) { + CCAssert(CC_CONTENT_SCALE_FACTOR() == 1.0f, "retina and scale mode can't be opened at the same time!"); float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR(); glViewport((GLint)(x * factor + m_rcViewPort.origin.x), (GLint)(y * factor + m_rcViewPort.origin.y), @@ -143,10 +146,11 @@ void CCEGLViewProtocol::setViewPortInPoints(float x , float y , float w , float } else { - glViewport((GLint)x, - (GLint)y, - (GLsizei)w, - (GLsizei)h); + glViewport( + (GLint)(x*CC_CONTENT_SCALE_FACTOR()), + (GLint)(y*CC_CONTENT_SCALE_FACTOR()), + (GLsizei)(w*CC_CONTENT_SCALE_FACTOR()), + (GLsizei)(h*CC_CONTENT_SCALE_FACTOR())); } } @@ -154,6 +158,7 @@ void CCEGLViewProtocol::setScissorInPoints(float x , float y , float w , float h { if (m_bNeedScale) { + CCAssert(CC_CONTENT_SCALE_FACTOR() == 1.0f, "retina and scale mode can't be opened at the same time!"); float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR(); glScissor((GLint)(x * factor + m_rcViewPort.origin.x), (GLint)(y * factor + m_rcViewPort.origin.y), @@ -162,10 +167,11 @@ void CCEGLViewProtocol::setScissorInPoints(float x , float y , float w , float h } else { - glScissor((GLint)x, - (GLint)y, - (GLsizei)w, - (GLsizei)h); + glScissor( + (GLint)(x * CC_CONTENT_SCALE_FACTOR()), + (GLint)(y * CC_CONTENT_SCALE_FACTOR()), + (GLsizei)(w * CC_CONTENT_SCALE_FACTOR()), + (GLsizei)(h * CC_CONTENT_SCALE_FACTOR())); } } From 37aa196c73999cc4c8d5016370bfa75fedaf8227 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 6 Jun 2012 14:31:49 +0800 Subject: [PATCH 082/257] Removed some unused codes. --- HelloLua/Classes/AppDelegate.cpp | 2 - HelloWorld/Classes/AppDelegate.cpp | 2 - .../Classes/AppDelegate.cpp | 3 - .../Classes/AppDelegate.cpp | 3 - .../Classes/AppDelegate.cpp | 3 - .../Classes/AppDelegate.cpp | 2 - testjs/Classes/AppDelegate.cpp | 3 - tests/AppDelegate.cpp | 4 - .../template/Classes/AppDelegate.cpp | 83 +++---------------- .../template/Classes/AppDelegate.h | 8 -- 10 files changed, 11 insertions(+), 102 deletions(-) diff --git a/HelloLua/Classes/AppDelegate.cpp b/HelloLua/Classes/AppDelegate.cpp index 6201bf0da8..0fcf6dbe98 100644 --- a/HelloLua/Classes/AppDelegate.cpp +++ b/HelloLua/Classes/AppDelegate.cpp @@ -32,8 +32,6 @@ bool AppDelegate::applicationDidFinishLaunching() // turn on display FPS pDirector->setDisplayStats(true); - // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); - // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); diff --git a/HelloWorld/Classes/AppDelegate.cpp b/HelloWorld/Classes/AppDelegate.cpp index e9642c568d..875c3da4e4 100644 --- a/HelloWorld/Classes/AppDelegate.cpp +++ b/HelloWorld/Classes/AppDelegate.cpp @@ -27,8 +27,6 @@ bool AppDelegate::applicationDidFinishLaunching() { // turn on display FPS pDirector->setDisplayStats(true); - // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); - // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); diff --git a/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.cpp index 339020ed9b..07ffb55c1e 100644 --- a/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.cpp +++ b/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.cpp @@ -31,9 +31,6 @@ bool AppDelegate::applicationDidFinishLaunching() // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. // pDirector->enableRetinaDisplay(true); - // sets landscape mode - // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); - // turn on display FPS pDirector->setDisplayStats(true); diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.cpp index 339020ed9b..07ffb55c1e 100644 --- a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.cpp +++ b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.cpp @@ -31,9 +31,6 @@ bool AppDelegate::applicationDidFinishLaunching() // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. // pDirector->enableRetinaDisplay(true); - // sets landscape mode - // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); - // turn on display FPS pDirector->setDisplayStats(true); diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/AppDelegate.cpp index 339020ed9b..07ffb55c1e 100644 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/AppDelegate.cpp +++ b/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/AppDelegate.cpp @@ -31,9 +31,6 @@ bool AppDelegate::applicationDidFinishLaunching() // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. // pDirector->enableRetinaDisplay(true); - // sets landscape mode - // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); - // turn on display FPS pDirector->setDisplayStats(true); diff --git a/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp index fa0a03eff9..984bba4348 100644 --- a/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp +++ b/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp @@ -33,8 +33,6 @@ bool AppDelegate::applicationDidFinishLaunching() // turn on display FPS pDirector->setDisplayStats(true); - // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); - // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); diff --git a/testjs/Classes/AppDelegate.cpp b/testjs/Classes/AppDelegate.cpp index 38dc2e91c1..696ee5aea2 100644 --- a/testjs/Classes/AppDelegate.cpp +++ b/testjs/Classes/AppDelegate.cpp @@ -32,9 +32,6 @@ bool AppDelegate::applicationDidFinishLaunching() // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. // pDirector->enableRetinaDisplay(true); - // sets landscape mode - // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); - // turn on display FPS pDirector->setDisplayStats(true); diff --git a/tests/AppDelegate.cpp b/tests/AppDelegate.cpp index d6c50ebf4b..2a58f05895 100644 --- a/tests/AppDelegate.cpp +++ b/tests/AppDelegate.cpp @@ -25,10 +25,6 @@ bool AppDelegate::applicationDidFinishLaunching() // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. // pDirector->enableRetinaDisplay(true); - // sets opengl landscape mode - // tests set device orientation in RootViewController.mm - // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); - // turn on display FPS pDirector->setDisplayStats(true); diff --git a/tools/lua_project_generator/template/Classes/AppDelegate.cpp b/tools/lua_project_generator/template/Classes/AppDelegate.cpp index 3ee661ec67..e341801473 100644 --- a/tools/lua_project_generator/template/Classes/AppDelegate.cpp +++ b/tools/lua_project_generator/template/Classes/AppDelegate.cpp @@ -7,7 +7,6 @@ USING_NS_CC; using namespace CocosDenshion; AppDelegate::AppDelegate() -:m_pLuaEngine(NULL) { } @@ -15,99 +14,39 @@ AppDelegate::~AppDelegate() { // end simple audio engine here, or it may crashed on win32 SimpleAudioEngine::sharedEngine()->end(); - CCScriptEngineManager::sharedScriptEngineManager()->removeScriptEngine(); + //CCScriptEngineManager::purgeSharedManager(); CC_SAFE_DELETE(m_pLuaEngine); } -bool AppDelegate::initInstance() -{ - bool bRet = false; - do - { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) - - // Initialize OpenGLView instance, that release by CCDirector when application terminate. - // The HelloWorld is designed as HVGA. - CCEGLView * pMainWnd = new CCEGLView(); - CC_BREAK_IF(! pMainWnd - || ! pMainWnd->Create(TEXT("cocos2d: LuaProjectTemplate"), 480, 320)); - -#endif // CC_PLATFORM_WIN32 - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - - // OpenGLView initialized in testsAppDelegate.mm on ios platform, nothing need to do here. - -#endif // CC_PLATFORM_IOS - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - - // OpenGLView initialized in HelloWorld/android/jni/helloworld/main.cpp - // the default setting is to create a fullscreen view - // if you want to use auto-scale, please enable view->create(320,480) in main.cpp - -#endif // CC_PLATFORM_ANDROID - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE) - // MaxAksenov said it's NOT a very elegant solution. I agree, haha - CCDirector::sharedDirector()->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); -#endif - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_BADA) - CCEGLView * pMainWnd = new CCEGLView(); - CC_BREAK_IF(! pMainWnd|| ! pMainWnd->Create(this)); - CCFileUtils::setResourcePath("/Res/"); -#endif - bRet = true; - } while (0); - return bRet; -} - bool AppDelegate::applicationDidFinishLaunching() { // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView()); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_BADA) - CCDirector::sharedDirector()->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); -#endif // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. // pDirector->enableRetinaDisplay(true); // turn on display FPS - pDirector->setDisplayFPS(true); - - // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); + pDirector->setDisplayStats(true); // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); // register lua engine - m_pLuaEngine = new LuaEngine; - CCScriptEngineManager::sharedScriptEngineManager()->setScriptEngine(m_pLuaEngine); + CCScriptEngineProtocol* pEngine = CCLuaEngine::engine(); + CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - unsigned long size; - char *pFileContent = (char*)CCFileUtils::getFileData("main.lua", "r", &size); - - if (pFileContent) + CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua"); + if (pstrFileContent) { - // copy the file contents and add '\0' at the end, or the lua parser can not parse it - char *pCodes = new char[size + 1]; - pCodes[size] = '\0'; - memcpy(pCodes, pFileContent, size); - delete[] pFileContent; - - CCScriptEngineManager::sharedScriptEngineManager()->getScriptEngine()->executeString(pCodes); - delete []pCodes; + pEngine->executeString(pstrFileContent->getCString()); } -#endif - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - string path = CCFileUtils::fullPathFromRelativePath("main.lua"); - CCScriptEngineManager::sharedScriptEngineManager()->getScriptEngine()->addSearchPath(path.substr(0, path.find_last_of("/")).c_str()); - CCScriptEngineManager::sharedScriptEngineManager()->getScriptEngine()->executeScriptFile(path.c_str()); +#else + std::string path = CCFileUtils::fullPathFromRelativePath("hello.lua"); + pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str()); + pEngine->executeScriptFile(path.c_str()); #endif return true; diff --git a/tools/lua_project_generator/template/Classes/AppDelegate.h b/tools/lua_project_generator/template/Classes/AppDelegate.h index 05241d3e10..1b7c3f81f2 100644 --- a/tools/lua_project_generator/template/Classes/AppDelegate.h +++ b/tools/lua_project_generator/template/Classes/AppDelegate.h @@ -15,11 +15,6 @@ public: AppDelegate(); virtual ~AppDelegate(); - /** - @brief Implement for initialize OpenGL instance, set source path, etc... - */ - virtual bool initInstance(); - /** @brief Implement CCDirector and CCScene init code here. @return true Initialize success, app continue. @@ -38,9 +33,6 @@ public: @param the pointer of the application */ virtual void applicationWillEnterForeground(); - -private: - LuaEngine* m_pLuaEngine; }; #endif // _APP_DELEGATE_H_ From 734ea54abab7eac77bb905cbd26d01c15bba9977 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 6 Jun 2012 15:16:02 +0800 Subject: [PATCH 083/257] fixed #1302: The parameter of CCMenu::setHandlerPriority should be signed int. --- cocos2dx/menu_nodes/CCMenu.cpp | 2 +- cocos2dx/menu_nodes/CCMenu.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2dx/menu_nodes/CCMenu.cpp b/cocos2dx/menu_nodes/CCMenu.cpp index e2436c53f3..ec4670ea6e 100644 --- a/cocos2dx/menu_nodes/CCMenu.cpp +++ b/cocos2dx/menu_nodes/CCMenu.cpp @@ -178,7 +178,7 @@ void CCMenu::onExit() //Menu - Events -void CCMenu::setHandlerPriority(unsigned int newPriority) +void CCMenu::setHandlerPriority(int newPriority) { CCTouchDispatcher* pDispatcher = CCDirector::sharedDirector()->getTouchDispatcher(); pDispatcher->setPriority(newPriority, this); diff --git a/cocos2dx/menu_nodes/CCMenu.h b/cocos2dx/menu_nodes/CCMenu.h index 79a5cc1d0c..8dc7f71e0e 100644 --- a/cocos2dx/menu_nodes/CCMenu.h +++ b/cocos2dx/menu_nodes/CCMenu.h @@ -109,7 +109,7 @@ public: void alignItemsInRows(unsigned int rows, va_list args); /** set event handler priority. By default it is: kCCMenuTouchPriority */ - void setHandlerPriority(unsigned int newPriority); + void setHandlerPriority(int newPriority); //super methods virtual void addChild(CCNode * child); From 1ff04700b54a5478ebc4c3bf88f531bfb57fa662 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 6 Jun 2012 15:38:25 +0800 Subject: [PATCH 084/257] fixed #1278: stop effect when unloading effect --- .../src/org/cocos2dx/lib/Cocos2dxSound.java | 169 ++++++++---------- .../src/org/cocos2dx/lib/Cocos2dxSound.java | 169 ++++++++---------- .../src/org/cocos2dx/lib/Cocos2dxSound.java | 169 ++++++++---------- .../src/org/cocos2dx/lib/Cocos2dxSound.java | 169 ++++++++---------- 4 files changed, 312 insertions(+), 364 deletions(-) diff --git a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java b/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java index ca646cb545..e7061f74de 100644 --- a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java +++ b/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java @@ -23,6 +23,7 @@ THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.lib; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -44,10 +45,12 @@ public class Cocos2dxSound { private float mLeftVolume; private float mRightVolume; - // sound id and stream id map - private HashMap mSoundIdStreamIdMap; - // sound path and sound id map - private HashMap mPathSoundIDMap; + // sound path and stream ids map + // a file may be played many times at the same time + // so there is an array map to a file path + private HashMap> mPathStreamIDsMap; + + private HashMap mPathSoundIdMap; private static final String TAG = "Cocos2dxSound"; private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 5; @@ -55,8 +58,8 @@ public class Cocos2dxSound { private static final int SOUND_PRIORITY = 1; private static final int SOUND_QUALITY = 5; - private final int INVALID_SOUND_ID = -1; - private final int INVALID_STREAM_ID = -1; + private final static int INVALID_SOUND_ID = -1; + private final static int INVALID_STREAM_ID = -1; public Cocos2dxSound(Context context){ this.mContext = context; @@ -64,53 +67,48 @@ public class Cocos2dxSound { } public int preloadEffect(String path){ - int soundId = INVALID_SOUND_ID; + Integer soundID = this.mPathSoundIdMap.get(path); - // if the sound is preloaded, pass it - if (this.mPathSoundIDMap.get(path) != null){ - soundId = this.mPathSoundIDMap.get(path).intValue(); - } else { - soundId = createSoundIdFromAsset(path); - - if (soundId != INVALID_SOUND_ID){ - // the sound is loaded but has not been played - this.mSoundIdStreamIdMap.put(soundId, INVALID_STREAM_ID); - - // record path and sound id map - this.mPathSoundIDMap.put(path, soundId); - } + if (soundID == null) { + soundID = createSoundIdFromAsset(path); + this.mPathSoundIdMap.put(path, soundID); } - return soundId; + return soundID; } public void unloadEffect(String path){ - // get sound id and remove from mPathSoundIDMap - Integer soundId = this.mPathSoundIDMap.remove(path); + // stop effects + ArrayList streamIDs = this.mPathStreamIDsMap.get(path); + if (streamIDs != null) { + for (Integer streamID : streamIDs) { + this.mSoundPool.stop(streamID); + } + } + this.mPathStreamIDsMap.remove(path); - if (soundId != null){ - // unload effect - this.mSoundPool.unload(soundId.intValue()); - - // remove record from mSoundIdStreamIdMap - this.mSoundIdStreamIdMap.remove(soundId); - } + // unload effect + Integer soundID = this.mPathSoundIdMap.get(path); + this.mSoundPool.unload(soundID); + this.mPathSoundIdMap.remove(path); } public int playEffect(String path, boolean isLoop){ - Integer soundId = this.mPathSoundIDMap.get(path); + Integer soundId = this.mPathSoundIdMap.get(path); + int streamId = INVALID_STREAM_ID; - if (soundId != null){ - // the sound is preloaded, stop it first - - this.mSoundPool.stop(soundId); - + if (soundId != null){ // play sound - int streamId = this.mSoundPool.play(soundId.intValue(), this.mLeftVolume, + streamId = this.mSoundPool.play(soundId.intValue(), this.mLeftVolume, this.mRightVolume, SOUND_PRIORITY, isLoop ? -1 : 0, SOUND_RATE); - // record sound id and stream id map - this.mSoundIdStreamIdMap.put(soundId, streamId); + // record stream id + ArrayList streamIds = this.mPathStreamIDsMap.get(path); + if (streamIds == null) { + streamIds = new ArrayList(); + this.mPathStreamIDsMap.put(path, streamIds); + } + streamIds.add(streamId); } else { // the effect is not prepared soundId = preloadEffect(path); @@ -133,54 +131,53 @@ public class Cocos2dxSound { playEffect(path, isLoop); } - return soundId.intValue(); + return streamId; } - public void stopEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); + public void stopEffect(int streamID){ + this.mSoundPool.stop(streamID); - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.stop(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); + // remove record + for (String path : this.mPathStreamIDsMap.keySet()) { + if (this.mPathStreamIDsMap.get(path).contains(streamID)) { + this.mPathStreamIDsMap.get(path).remove(this.mPathStreamIDsMap.get(path).indexOf(streamID)); + break; + } } } - public void pauseEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); - - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.pause(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); - } + public void pauseEffect(int streamID){ + this.mSoundPool.pause(streamID); } - public void resumeEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); - - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.resume(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); - } + public void resumeEffect(int streamID){ + this.mSoundPool.resume(streamID); } public void pauseAllEffects(){ - // autoResume is available since level 8 - pauseOrResumeAllEffects(true); + this.mSoundPool.autoPause(); } public void resumeAllEffects(){ // autoPause() is available since level 8 - pauseOrResumeAllEffects(false); + this.mSoundPool.autoResume(); } @SuppressWarnings("unchecked") public void stopAllEffects(){ - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - int soundId = entry.getKey(); - this.stopEffect(soundId); - } + // stop effects + if (! this.mPathStreamIDsMap.isEmpty()) { + Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); + while (iter.hasNext()){ + Map.Entry> entry = (Map.Entry>)iter.next(); + for (int streamID : entry.getValue()) { + this.mSoundPool.stop(streamID); + } + } + } + + // remove records + this.mPathStreamIDsMap.clear(); } public float getEffectsVolume(){ @@ -200,17 +197,21 @@ public class Cocos2dxSound { this.mLeftVolume = this.mRightVolume = volume; // change the volume of playing sounds - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - this.mSoundPool.setVolume(entry.getValue(), mLeftVolume, mRightVolume); - } + if (! this.mPathStreamIDsMap.isEmpty()) { + Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); + while (iter.hasNext()){ + Map.Entry> entry = (Map.Entry>)iter.next(); + for (int streamID : entry.getValue()) { + this.mSoundPool.setVolume(streamID, mLeftVolume, mRightVolume); + } + } + } } public void end(){ this.mSoundPool.release(); - this.mPathSoundIDMap.clear(); - this.mSoundIdStreamIdMap.clear(); + this.mPathStreamIDsMap.clear(); + this.mPathSoundIdMap.clear(); initData(); } @@ -234,25 +235,11 @@ public class Cocos2dxSound { } private void initData(){ - this.mSoundIdStreamIdMap = new HashMap(); + this.mPathStreamIDsMap = new HashMap>(); + this.mPathSoundIdMap = new HashMap(); mSoundPool = new SoundPool(MAX_SIMULTANEOUS_STREAMS_DEFAULT, AudioManager.STREAM_MUSIC, SOUND_QUALITY); - mPathSoundIDMap = new HashMap(); this.mLeftVolume = 0.5f; this.mRightVolume = 0.5f; } - - @SuppressWarnings("unchecked") - private void pauseOrResumeAllEffects(boolean isPause){ - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - int soundId = entry.getKey(); - if (isPause) { - this.pauseEffect(soundId); - } else { - this.resumeEffect(soundId); - } - } - } } diff --git a/HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java b/HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java index ca646cb545..e7061f74de 100644 --- a/HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java +++ b/HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java @@ -23,6 +23,7 @@ THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.lib; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -44,10 +45,12 @@ public class Cocos2dxSound { private float mLeftVolume; private float mRightVolume; - // sound id and stream id map - private HashMap mSoundIdStreamIdMap; - // sound path and sound id map - private HashMap mPathSoundIDMap; + // sound path and stream ids map + // a file may be played many times at the same time + // so there is an array map to a file path + private HashMap> mPathStreamIDsMap; + + private HashMap mPathSoundIdMap; private static final String TAG = "Cocos2dxSound"; private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 5; @@ -55,8 +58,8 @@ public class Cocos2dxSound { private static final int SOUND_PRIORITY = 1; private static final int SOUND_QUALITY = 5; - private final int INVALID_SOUND_ID = -1; - private final int INVALID_STREAM_ID = -1; + private final static int INVALID_SOUND_ID = -1; + private final static int INVALID_STREAM_ID = -1; public Cocos2dxSound(Context context){ this.mContext = context; @@ -64,53 +67,48 @@ public class Cocos2dxSound { } public int preloadEffect(String path){ - int soundId = INVALID_SOUND_ID; + Integer soundID = this.mPathSoundIdMap.get(path); - // if the sound is preloaded, pass it - if (this.mPathSoundIDMap.get(path) != null){ - soundId = this.mPathSoundIDMap.get(path).intValue(); - } else { - soundId = createSoundIdFromAsset(path); - - if (soundId != INVALID_SOUND_ID){ - // the sound is loaded but has not been played - this.mSoundIdStreamIdMap.put(soundId, INVALID_STREAM_ID); - - // record path and sound id map - this.mPathSoundIDMap.put(path, soundId); - } + if (soundID == null) { + soundID = createSoundIdFromAsset(path); + this.mPathSoundIdMap.put(path, soundID); } - return soundId; + return soundID; } public void unloadEffect(String path){ - // get sound id and remove from mPathSoundIDMap - Integer soundId = this.mPathSoundIDMap.remove(path); + // stop effects + ArrayList streamIDs = this.mPathStreamIDsMap.get(path); + if (streamIDs != null) { + for (Integer streamID : streamIDs) { + this.mSoundPool.stop(streamID); + } + } + this.mPathStreamIDsMap.remove(path); - if (soundId != null){ - // unload effect - this.mSoundPool.unload(soundId.intValue()); - - // remove record from mSoundIdStreamIdMap - this.mSoundIdStreamIdMap.remove(soundId); - } + // unload effect + Integer soundID = this.mPathSoundIdMap.get(path); + this.mSoundPool.unload(soundID); + this.mPathSoundIdMap.remove(path); } public int playEffect(String path, boolean isLoop){ - Integer soundId = this.mPathSoundIDMap.get(path); + Integer soundId = this.mPathSoundIdMap.get(path); + int streamId = INVALID_STREAM_ID; - if (soundId != null){ - // the sound is preloaded, stop it first - - this.mSoundPool.stop(soundId); - + if (soundId != null){ // play sound - int streamId = this.mSoundPool.play(soundId.intValue(), this.mLeftVolume, + streamId = this.mSoundPool.play(soundId.intValue(), this.mLeftVolume, this.mRightVolume, SOUND_PRIORITY, isLoop ? -1 : 0, SOUND_RATE); - // record sound id and stream id map - this.mSoundIdStreamIdMap.put(soundId, streamId); + // record stream id + ArrayList streamIds = this.mPathStreamIDsMap.get(path); + if (streamIds == null) { + streamIds = new ArrayList(); + this.mPathStreamIDsMap.put(path, streamIds); + } + streamIds.add(streamId); } else { // the effect is not prepared soundId = preloadEffect(path); @@ -133,54 +131,53 @@ public class Cocos2dxSound { playEffect(path, isLoop); } - return soundId.intValue(); + return streamId; } - public void stopEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); + public void stopEffect(int streamID){ + this.mSoundPool.stop(streamID); - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.stop(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); + // remove record + for (String path : this.mPathStreamIDsMap.keySet()) { + if (this.mPathStreamIDsMap.get(path).contains(streamID)) { + this.mPathStreamIDsMap.get(path).remove(this.mPathStreamIDsMap.get(path).indexOf(streamID)); + break; + } } } - public void pauseEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); - - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.pause(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); - } + public void pauseEffect(int streamID){ + this.mSoundPool.pause(streamID); } - public void resumeEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); - - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.resume(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); - } + public void resumeEffect(int streamID){ + this.mSoundPool.resume(streamID); } public void pauseAllEffects(){ - // autoResume is available since level 8 - pauseOrResumeAllEffects(true); + this.mSoundPool.autoPause(); } public void resumeAllEffects(){ // autoPause() is available since level 8 - pauseOrResumeAllEffects(false); + this.mSoundPool.autoResume(); } @SuppressWarnings("unchecked") public void stopAllEffects(){ - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - int soundId = entry.getKey(); - this.stopEffect(soundId); - } + // stop effects + if (! this.mPathStreamIDsMap.isEmpty()) { + Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); + while (iter.hasNext()){ + Map.Entry> entry = (Map.Entry>)iter.next(); + for (int streamID : entry.getValue()) { + this.mSoundPool.stop(streamID); + } + } + } + + // remove records + this.mPathStreamIDsMap.clear(); } public float getEffectsVolume(){ @@ -200,17 +197,21 @@ public class Cocos2dxSound { this.mLeftVolume = this.mRightVolume = volume; // change the volume of playing sounds - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - this.mSoundPool.setVolume(entry.getValue(), mLeftVolume, mRightVolume); - } + if (! this.mPathStreamIDsMap.isEmpty()) { + Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); + while (iter.hasNext()){ + Map.Entry> entry = (Map.Entry>)iter.next(); + for (int streamID : entry.getValue()) { + this.mSoundPool.setVolume(streamID, mLeftVolume, mRightVolume); + } + } + } } public void end(){ this.mSoundPool.release(); - this.mPathSoundIDMap.clear(); - this.mSoundIdStreamIdMap.clear(); + this.mPathStreamIDsMap.clear(); + this.mPathSoundIdMap.clear(); initData(); } @@ -234,25 +235,11 @@ public class Cocos2dxSound { } private void initData(){ - this.mSoundIdStreamIdMap = new HashMap(); + this.mPathStreamIDsMap = new HashMap>(); + this.mPathSoundIdMap = new HashMap(); mSoundPool = new SoundPool(MAX_SIMULTANEOUS_STREAMS_DEFAULT, AudioManager.STREAM_MUSIC, SOUND_QUALITY); - mPathSoundIDMap = new HashMap(); this.mLeftVolume = 0.5f; this.mRightVolume = 0.5f; } - - @SuppressWarnings("unchecked") - private void pauseOrResumeAllEffects(boolean isPause){ - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - int soundId = entry.getKey(); - if (isPause) { - this.pauseEffect(soundId); - } else { - this.resumeEffect(soundId); - } - } - } } diff --git a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java b/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java index ca646cb545..e7061f74de 100644 --- a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java +++ b/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java @@ -23,6 +23,7 @@ THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.lib; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -44,10 +45,12 @@ public class Cocos2dxSound { private float mLeftVolume; private float mRightVolume; - // sound id and stream id map - private HashMap mSoundIdStreamIdMap; - // sound path and sound id map - private HashMap mPathSoundIDMap; + // sound path and stream ids map + // a file may be played many times at the same time + // so there is an array map to a file path + private HashMap> mPathStreamIDsMap; + + private HashMap mPathSoundIdMap; private static final String TAG = "Cocos2dxSound"; private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 5; @@ -55,8 +58,8 @@ public class Cocos2dxSound { private static final int SOUND_PRIORITY = 1; private static final int SOUND_QUALITY = 5; - private final int INVALID_SOUND_ID = -1; - private final int INVALID_STREAM_ID = -1; + private final static int INVALID_SOUND_ID = -1; + private final static int INVALID_STREAM_ID = -1; public Cocos2dxSound(Context context){ this.mContext = context; @@ -64,53 +67,48 @@ public class Cocos2dxSound { } public int preloadEffect(String path){ - int soundId = INVALID_SOUND_ID; + Integer soundID = this.mPathSoundIdMap.get(path); - // if the sound is preloaded, pass it - if (this.mPathSoundIDMap.get(path) != null){ - soundId = this.mPathSoundIDMap.get(path).intValue(); - } else { - soundId = createSoundIdFromAsset(path); - - if (soundId != INVALID_SOUND_ID){ - // the sound is loaded but has not been played - this.mSoundIdStreamIdMap.put(soundId, INVALID_STREAM_ID); - - // record path and sound id map - this.mPathSoundIDMap.put(path, soundId); - } + if (soundID == null) { + soundID = createSoundIdFromAsset(path); + this.mPathSoundIdMap.put(path, soundID); } - return soundId; + return soundID; } public void unloadEffect(String path){ - // get sound id and remove from mPathSoundIDMap - Integer soundId = this.mPathSoundIDMap.remove(path); + // stop effects + ArrayList streamIDs = this.mPathStreamIDsMap.get(path); + if (streamIDs != null) { + for (Integer streamID : streamIDs) { + this.mSoundPool.stop(streamID); + } + } + this.mPathStreamIDsMap.remove(path); - if (soundId != null){ - // unload effect - this.mSoundPool.unload(soundId.intValue()); - - // remove record from mSoundIdStreamIdMap - this.mSoundIdStreamIdMap.remove(soundId); - } + // unload effect + Integer soundID = this.mPathSoundIdMap.get(path); + this.mSoundPool.unload(soundID); + this.mPathSoundIdMap.remove(path); } public int playEffect(String path, boolean isLoop){ - Integer soundId = this.mPathSoundIDMap.get(path); + Integer soundId = this.mPathSoundIdMap.get(path); + int streamId = INVALID_STREAM_ID; - if (soundId != null){ - // the sound is preloaded, stop it first - - this.mSoundPool.stop(soundId); - + if (soundId != null){ // play sound - int streamId = this.mSoundPool.play(soundId.intValue(), this.mLeftVolume, + streamId = this.mSoundPool.play(soundId.intValue(), this.mLeftVolume, this.mRightVolume, SOUND_PRIORITY, isLoop ? -1 : 0, SOUND_RATE); - // record sound id and stream id map - this.mSoundIdStreamIdMap.put(soundId, streamId); + // record stream id + ArrayList streamIds = this.mPathStreamIDsMap.get(path); + if (streamIds == null) { + streamIds = new ArrayList(); + this.mPathStreamIDsMap.put(path, streamIds); + } + streamIds.add(streamId); } else { // the effect is not prepared soundId = preloadEffect(path); @@ -133,54 +131,53 @@ public class Cocos2dxSound { playEffect(path, isLoop); } - return soundId.intValue(); + return streamId; } - public void stopEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); + public void stopEffect(int streamID){ + this.mSoundPool.stop(streamID); - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.stop(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); + // remove record + for (String path : this.mPathStreamIDsMap.keySet()) { + if (this.mPathStreamIDsMap.get(path).contains(streamID)) { + this.mPathStreamIDsMap.get(path).remove(this.mPathStreamIDsMap.get(path).indexOf(streamID)); + break; + } } } - public void pauseEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); - - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.pause(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); - } + public void pauseEffect(int streamID){ + this.mSoundPool.pause(streamID); } - public void resumeEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); - - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.resume(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); - } + public void resumeEffect(int streamID){ + this.mSoundPool.resume(streamID); } public void pauseAllEffects(){ - // autoResume is available since level 8 - pauseOrResumeAllEffects(true); + this.mSoundPool.autoPause(); } public void resumeAllEffects(){ // autoPause() is available since level 8 - pauseOrResumeAllEffects(false); + this.mSoundPool.autoResume(); } @SuppressWarnings("unchecked") public void stopAllEffects(){ - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - int soundId = entry.getKey(); - this.stopEffect(soundId); - } + // stop effects + if (! this.mPathStreamIDsMap.isEmpty()) { + Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); + while (iter.hasNext()){ + Map.Entry> entry = (Map.Entry>)iter.next(); + for (int streamID : entry.getValue()) { + this.mSoundPool.stop(streamID); + } + } + } + + // remove records + this.mPathStreamIDsMap.clear(); } public float getEffectsVolume(){ @@ -200,17 +197,21 @@ public class Cocos2dxSound { this.mLeftVolume = this.mRightVolume = volume; // change the volume of playing sounds - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - this.mSoundPool.setVolume(entry.getValue(), mLeftVolume, mRightVolume); - } + if (! this.mPathStreamIDsMap.isEmpty()) { + Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); + while (iter.hasNext()){ + Map.Entry> entry = (Map.Entry>)iter.next(); + for (int streamID : entry.getValue()) { + this.mSoundPool.setVolume(streamID, mLeftVolume, mRightVolume); + } + } + } } public void end(){ this.mSoundPool.release(); - this.mPathSoundIDMap.clear(); - this.mSoundIdStreamIdMap.clear(); + this.mPathStreamIDsMap.clear(); + this.mPathSoundIdMap.clear(); initData(); } @@ -234,25 +235,11 @@ public class Cocos2dxSound { } private void initData(){ - this.mSoundIdStreamIdMap = new HashMap(); + this.mPathStreamIDsMap = new HashMap>(); + this.mPathSoundIdMap = new HashMap(); mSoundPool = new SoundPool(MAX_SIMULTANEOUS_STREAMS_DEFAULT, AudioManager.STREAM_MUSIC, SOUND_QUALITY); - mPathSoundIDMap = new HashMap(); this.mLeftVolume = 0.5f; this.mRightVolume = 0.5f; } - - @SuppressWarnings("unchecked") - private void pauseOrResumeAllEffects(boolean isPause){ - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - int soundId = entry.getKey(); - if (isPause) { - this.pauseEffect(soundId); - } else { - this.resumeEffect(soundId); - } - } - } } diff --git a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java b/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java index ca646cb545..e7061f74de 100644 --- a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java +++ b/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java @@ -23,6 +23,7 @@ THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.lib; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -44,10 +45,12 @@ public class Cocos2dxSound { private float mLeftVolume; private float mRightVolume; - // sound id and stream id map - private HashMap mSoundIdStreamIdMap; - // sound path and sound id map - private HashMap mPathSoundIDMap; + // sound path and stream ids map + // a file may be played many times at the same time + // so there is an array map to a file path + private HashMap> mPathStreamIDsMap; + + private HashMap mPathSoundIdMap; private static final String TAG = "Cocos2dxSound"; private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 5; @@ -55,8 +58,8 @@ public class Cocos2dxSound { private static final int SOUND_PRIORITY = 1; private static final int SOUND_QUALITY = 5; - private final int INVALID_SOUND_ID = -1; - private final int INVALID_STREAM_ID = -1; + private final static int INVALID_SOUND_ID = -1; + private final static int INVALID_STREAM_ID = -1; public Cocos2dxSound(Context context){ this.mContext = context; @@ -64,53 +67,48 @@ public class Cocos2dxSound { } public int preloadEffect(String path){ - int soundId = INVALID_SOUND_ID; + Integer soundID = this.mPathSoundIdMap.get(path); - // if the sound is preloaded, pass it - if (this.mPathSoundIDMap.get(path) != null){ - soundId = this.mPathSoundIDMap.get(path).intValue(); - } else { - soundId = createSoundIdFromAsset(path); - - if (soundId != INVALID_SOUND_ID){ - // the sound is loaded but has not been played - this.mSoundIdStreamIdMap.put(soundId, INVALID_STREAM_ID); - - // record path and sound id map - this.mPathSoundIDMap.put(path, soundId); - } + if (soundID == null) { + soundID = createSoundIdFromAsset(path); + this.mPathSoundIdMap.put(path, soundID); } - return soundId; + return soundID; } public void unloadEffect(String path){ - // get sound id and remove from mPathSoundIDMap - Integer soundId = this.mPathSoundIDMap.remove(path); + // stop effects + ArrayList streamIDs = this.mPathStreamIDsMap.get(path); + if (streamIDs != null) { + for (Integer streamID : streamIDs) { + this.mSoundPool.stop(streamID); + } + } + this.mPathStreamIDsMap.remove(path); - if (soundId != null){ - // unload effect - this.mSoundPool.unload(soundId.intValue()); - - // remove record from mSoundIdStreamIdMap - this.mSoundIdStreamIdMap.remove(soundId); - } + // unload effect + Integer soundID = this.mPathSoundIdMap.get(path); + this.mSoundPool.unload(soundID); + this.mPathSoundIdMap.remove(path); } public int playEffect(String path, boolean isLoop){ - Integer soundId = this.mPathSoundIDMap.get(path); + Integer soundId = this.mPathSoundIdMap.get(path); + int streamId = INVALID_STREAM_ID; - if (soundId != null){ - // the sound is preloaded, stop it first - - this.mSoundPool.stop(soundId); - + if (soundId != null){ // play sound - int streamId = this.mSoundPool.play(soundId.intValue(), this.mLeftVolume, + streamId = this.mSoundPool.play(soundId.intValue(), this.mLeftVolume, this.mRightVolume, SOUND_PRIORITY, isLoop ? -1 : 0, SOUND_RATE); - // record sound id and stream id map - this.mSoundIdStreamIdMap.put(soundId, streamId); + // record stream id + ArrayList streamIds = this.mPathStreamIDsMap.get(path); + if (streamIds == null) { + streamIds = new ArrayList(); + this.mPathStreamIDsMap.put(path, streamIds); + } + streamIds.add(streamId); } else { // the effect is not prepared soundId = preloadEffect(path); @@ -133,54 +131,53 @@ public class Cocos2dxSound { playEffect(path, isLoop); } - return soundId.intValue(); + return streamId; } - public void stopEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); + public void stopEffect(int streamID){ + this.mSoundPool.stop(streamID); - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.stop(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); + // remove record + for (String path : this.mPathStreamIDsMap.keySet()) { + if (this.mPathStreamIDsMap.get(path).contains(streamID)) { + this.mPathStreamIDsMap.get(path).remove(this.mPathStreamIDsMap.get(path).indexOf(streamID)); + break; + } } } - public void pauseEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); - - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.pause(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); - } + public void pauseEffect(int streamID){ + this.mSoundPool.pause(streamID); } - public void resumeEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); - - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.resume(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); - } + public void resumeEffect(int streamID){ + this.mSoundPool.resume(streamID); } public void pauseAllEffects(){ - // autoResume is available since level 8 - pauseOrResumeAllEffects(true); + this.mSoundPool.autoPause(); } public void resumeAllEffects(){ // autoPause() is available since level 8 - pauseOrResumeAllEffects(false); + this.mSoundPool.autoResume(); } @SuppressWarnings("unchecked") public void stopAllEffects(){ - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - int soundId = entry.getKey(); - this.stopEffect(soundId); - } + // stop effects + if (! this.mPathStreamIDsMap.isEmpty()) { + Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); + while (iter.hasNext()){ + Map.Entry> entry = (Map.Entry>)iter.next(); + for (int streamID : entry.getValue()) { + this.mSoundPool.stop(streamID); + } + } + } + + // remove records + this.mPathStreamIDsMap.clear(); } public float getEffectsVolume(){ @@ -200,17 +197,21 @@ public class Cocos2dxSound { this.mLeftVolume = this.mRightVolume = volume; // change the volume of playing sounds - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - this.mSoundPool.setVolume(entry.getValue(), mLeftVolume, mRightVolume); - } + if (! this.mPathStreamIDsMap.isEmpty()) { + Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); + while (iter.hasNext()){ + Map.Entry> entry = (Map.Entry>)iter.next(); + for (int streamID : entry.getValue()) { + this.mSoundPool.setVolume(streamID, mLeftVolume, mRightVolume); + } + } + } } public void end(){ this.mSoundPool.release(); - this.mPathSoundIDMap.clear(); - this.mSoundIdStreamIdMap.clear(); + this.mPathStreamIDsMap.clear(); + this.mPathSoundIdMap.clear(); initData(); } @@ -234,25 +235,11 @@ public class Cocos2dxSound { } private void initData(){ - this.mSoundIdStreamIdMap = new HashMap(); + this.mPathStreamIDsMap = new HashMap>(); + this.mPathSoundIdMap = new HashMap(); mSoundPool = new SoundPool(MAX_SIMULTANEOUS_STREAMS_DEFAULT, AudioManager.STREAM_MUSIC, SOUND_QUALITY); - mPathSoundIDMap = new HashMap(); this.mLeftVolume = 0.5f; this.mRightVolume = 0.5f; } - - @SuppressWarnings("unchecked") - private void pauseOrResumeAllEffects(boolean isPause){ - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - int soundId = entry.getKey(); - if (isPause) { - this.pauseEffect(soundId); - } else { - this.resumeEffect(soundId); - } - } - } } From 4b7f9f582f91aa4c855b88ab8f9c30cfa86bac9c Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 6 Jun 2012 15:56:55 +0800 Subject: [PATCH 085/257] fixed #1297: fixed a bug in CCRenderTexture::begin. The parameters of glViewPort should not multiply CC_CONTENT_SCALE_FACTOR(). --- cocos2dx/misc_nodes/CCRenderTexture.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2dx/misc_nodes/CCRenderTexture.cpp b/cocos2dx/misc_nodes/CCRenderTexture.cpp index 7c144aee43..978406a9eb 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.cpp +++ b/cocos2dx/misc_nodes/CCRenderTexture.cpp @@ -172,10 +172,10 @@ void CCRenderTexture::begin() float heightRatio = size.height / texSize.height; // Adjust the orthographic projection and viewport - glViewport(0, 0, (GLsizei)(texSize.width * CC_CONTENT_SCALE_FACTOR()), (GLsizei)(texSize.height * CC_CONTENT_SCALE_FACTOR())); + glViewport(0, 0, (GLsizei)texSize.width, (GLsizei)texSize.height); // special viewport for 3d projection + retina display - if ( director->getProjection() == kCCDirectorProjection3D && CC_CONTENT_SCALE_FACTOR() != 1 ) + if ( director->getProjection() == kCCDirectorProjection3D && CC_CONTENT_SCALE_FACTOR() != 1.0f ) { glViewport((GLsizei)(-texSize.width/2), (GLsizei)(-texSize.height/2), (GLsizei)(texSize.width * CC_CONTENT_SCALE_FACTOR()), (GLsizei)(texSize.height * CC_CONTENT_SCALE_FACTOR())); } From c64c4a74bf5db788d5abb18039686ea1b00c6ee3 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 6 Jun 2012 22:49:28 +0800 Subject: [PATCH 086/257] fixed #1308: Strange TouchDispatcher behavior. --- cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp index f5a03f915c..8c0f08fcd1 100644 --- a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp +++ b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp @@ -40,7 +40,7 @@ NS_CC_BEGIN */ static int less(const void* p1, const void* p2) { - return ((cocos2d::CCTouchHandler*)p1)->getPriority() < ((cocos2d::CCTouchHandler*)p2)->getPriority() ? 1 : -1; + return (*((CCTouchHandler**)p1))->getPriority() - (*((CCTouchHandler**)p2))->getPriority(); } From 671a0ef5b44b6dd1fba8e7bfa135677143b22735 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 6 Jun 2012 11:06:28 -0700 Subject: [PATCH 087/257] Removed zombie file: CCBMemberVariableAssigner.cpp. --- .../extensions/CCBIReader/CCBMemberVariableAssigner.cpp | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 cocos2dx/extensions/CCBIReader/CCBMemberVariableAssigner.cpp diff --git a/cocos2dx/extensions/CCBIReader/CCBMemberVariableAssigner.cpp b/cocos2dx/extensions/CCBIReader/CCBMemberVariableAssigner.cpp deleted file mode 100644 index 0d268089a4..0000000000 --- a/cocos2dx/extensions/CCBIReader/CCBMemberVariableAssigner.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// -// CCBMemberVariableAssigner.cpp -// CCBIReaderTest -// -// Created by Nicolas Fabian Gramlich on 6/4/12. -// Copyright (c) 2012 __MyCompanyName__. All rights reserved. -// - -#include From aefc1e13705f9a0249e7edf1ca037c6865fe8dce Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 6 Jun 2012 11:43:33 -0700 Subject: [PATCH 088/257] CCBMemberVariableAssigner and CCBSelectorResolver: now using const char * instead of std::string. --- cocos2dx/extensions/CCBIReader/CCBMemberVariableAssigner.h | 2 +- cocos2dx/extensions/CCBIReader/CCBSelectorResolver.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2dx/extensions/CCBIReader/CCBMemberVariableAssigner.h b/cocos2dx/extensions/CCBIReader/CCBMemberVariableAssigner.h index b42fc76722..d992c1acf1 100644 --- a/cocos2dx/extensions/CCBIReader/CCBMemberVariableAssigner.h +++ b/cocos2dx/extensions/CCBIReader/CCBMemberVariableAssigner.h @@ -7,7 +7,7 @@ NS_CC_EXT_BEGIN class CCBMemberVariableAssigner { public: - virtual bool onAssignCCBMemberVariable(CCObject * pTarget, std::string pMemberVariableName, CCNode * pNode) = 0; + virtual bool onAssignCCBMemberVariable(CCObject * pTarget, const char * pMemberVariableName, CCNode * pNode) = 0; }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBIReader/CCBSelectorResolver.h b/cocos2dx/extensions/CCBIReader/CCBSelectorResolver.h index 8c425e66ec..01a323168e 100644 --- a/cocos2dx/extensions/CCBIReader/CCBSelectorResolver.h +++ b/cocos2dx/extensions/CCBIReader/CCBSelectorResolver.h @@ -7,7 +7,7 @@ NS_CC_EXT_BEGIN class CCBSelectorResolver { public: - virtual cocos2d::SEL_MenuHandler onResolveCCBSelector(CCObject * pTarget, std::string pSelectorName) = 0; + virtual cocos2d::SEL_MenuHandler onResolveCCBSelector(CCObject * pTarget, const char * pSelectorName) = 0; }; NS_CC_EXT_END From df571e9cbb6961587c6bbfdfd161d727511807d7 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 6 Jun 2012 14:31:14 -0700 Subject: [PATCH 089/257] CCControlExtension: Added support for SEL_CCControlHandler (as opposed to SEL_MenuHandler), which also passes the CCControlEvent parameter. --- cocos2dx/extensions/CCControlExtension/CCControl.cpp | 8 ++++---- cocos2dx/extensions/CCControlExtension/CCControl.h | 10 +++++----- .../CCControlExtension/CCControlColourPicker.cpp | 4 ++-- .../extensions/CCControlExtension/CCInvocation.cpp | 4 ++-- cocos2dx/extensions/CCControlExtension/CCInvocation.h | 8 ++++++-- 5 files changed, 19 insertions(+), 15 deletions(-) diff --git a/cocos2dx/extensions/CCControlExtension/CCControl.cpp b/cocos2dx/extensions/CCControlExtension/CCControl.cpp index 3af099067a..e921c63457 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControl.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControl.cpp @@ -107,7 +107,7 @@ void CCControl::sendActionsForControlEvents(CCControlEvent controlEvents) } } } -void CCControl::addTargetWithActionForControlEvents(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvents) +void CCControl::addTargetWithActionForControlEvents(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvents) { // For each control events for (int i = 0; i < CONTROL_EVENT_TOTAL_NUMBER; i++) @@ -135,7 +135,7 @@ void CCControl::addTargetWithActionForControlEvents(CCObject* target, SEL_MenuHa * @param controlEvent A control event for which the action message is sent. * See "CCControlEvent" for constants. */ -void CCControl::addTargetWithActionForControlEvent(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvent) +void CCControl::addTargetWithActionForControlEvent(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent) { // Create the invocation object CCInvocation *invocation=new CCInvocation(target, action, controlEvent); @@ -145,7 +145,7 @@ void CCControl::addTargetWithActionForControlEvent(CCObject* target, SEL_MenuHan eventInvocationList->addObject(invocation); } -void CCControl::removeTargetWithActionForControlEvents(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvents) +void CCControl::removeTargetWithActionForControlEvents(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvents) { // For each control events for (int i = 0; i < CONTROL_EVENT_TOTAL_NUMBER; i++) @@ -170,7 +170,7 @@ void CCControl::removeTargetWithActionForControlEvents(CCObject* target, SEL_Men * @param controlEvent A control event for which the action message is sent. * See "CCControlEvent" for constants. */ -void CCControl::removeTargetWithActionForControlEvent(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvent) +void CCControl::removeTargetWithActionForControlEvent(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent) { // Retrieve all invocations for the given control event // diff --git a/cocos2dx/extensions/CCControlExtension/CCControl.h b/cocos2dx/extensions/CCControlExtension/CCControl.h index a73f15d959..c5921be7fa 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControl.h +++ b/cocos2dx/extensions/CCControlExtension/CCControl.h @@ -134,7 +134,7 @@ public: * @param controlEvents A bitmask specifying the control events for which the * action message is sent. See "CCControlEvent" for bitmask constants. */ - virtual void addTargetWithActionForControlEvents(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvents); + virtual void addTargetWithActionForControlEvents(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvents); /** * Removes a target and action for a particular event (or events) from an @@ -148,7 +148,7 @@ public: * @param controlEvents A bitmask specifying the control events associated with * target and action. See "CCControlEvent" for bitmask constants. */ - virtual void removeTargetWithActionForControlEvents(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvents); + virtual void removeTargetWithActionForControlEvents(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvents); /** * Returns a point corresponding to the touh location converted into the @@ -183,7 +183,7 @@ protected: * @return an CCInvocation object able to construct messages using a given * target-action pair. */ - CCInvocation* invocationWithTargetAndActionForControlEvent(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvent); + CCInvocation* invocationWithTargetAndActionForControlEvent(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent); @@ -199,8 +199,8 @@ protected: // CCArray* dispatchListforControlEvent(CCControlEvent controlEvent); public: - void addTargetWithActionForControlEvent(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvent); - void removeTargetWithActionForControlEvent(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvent); + void addTargetWithActionForControlEvent(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent); + void removeTargetWithActionForControlEvent(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent); LAYER_NODE_FUNC(CCControl); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp b/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp index cb10c38759..cd18b94ab3 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp @@ -71,8 +71,8 @@ bool CCControlColourPicker::init() m_colourPicker=CCControlSaturationBrightnessPicker::pickerWithTargetAndPos(spriteSheet, ccp(backgroundPointZero.x + colourShift, backgroundPointZero.y + colourShift)); // Setup events - m_huePicker->addTargetWithActionForControlEvents(this, menu_selector(CCControlColourPicker::hueSliderValueChanged), CCControlEventValueChanged); - m_colourPicker->addTargetWithActionForControlEvents(this, menu_selector(CCControlColourPicker::colourSliderValueChanged), CCControlEventValueChanged); + m_huePicker->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlColourPicker::hueSliderValueChanged), CCControlEventValueChanged); + m_colourPicker->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlColourPicker::colourSliderValueChanged), CCControlEventValueChanged); // Set defaults updateHueAndControlPicker(); diff --git a/cocos2dx/extensions/CCControlExtension/CCInvocation.cpp b/cocos2dx/extensions/CCControlExtension/CCInvocation.cpp index 1ac51fc575..96ee02bc79 100644 --- a/cocos2dx/extensions/CCControlExtension/CCInvocation.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCInvocation.cpp @@ -2,7 +2,7 @@ NS_CC_EXT_BEGIN -CCInvocation::CCInvocation(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvent) +CCInvocation::CCInvocation(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent) { m_target=target; m_action=action; @@ -13,7 +13,7 @@ void CCInvocation::invoke(CCObject* sender) { if (m_target && m_action) { - (m_target->*m_action)(sender); + (m_target->*m_action)(sender, m_controlEvent); } } diff --git a/cocos2dx/extensions/CCControlExtension/CCInvocation.h b/cocos2dx/extensions/CCControlExtension/CCInvocation.h index b33b35f022..8c9c7482b8 100644 --- a/cocos2dx/extensions/CCControlExtension/CCInvocation.h +++ b/cocos2dx/extensions/CCControlExtension/CCInvocation.h @@ -11,14 +11,18 @@ NS_CC_EXT_BEGIN typedef unsigned int CCControlEvent; +typedef void (CCObject::*SEL_CCControlHandler)(CCObject*, CCControlEvent); + +#define cccontrol_selector(_SELECTOR) (SEL_CCControlHandler)(&_SELECTOR) + class CC_DLL CCInvocation : public CCObject { - CC_SYNTHESIZE_READONLY(SEL_MenuHandler, m_action, Action); + CC_SYNTHESIZE_READONLY(SEL_CCControlHandler, m_action, Action); CC_SYNTHESIZE_READONLY(CCObject*, m_target, Target); CC_SYNTHESIZE_READONLY(CCControlEvent, m_controlEvent, ControlEvent); public: - CCInvocation(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvent); + CCInvocation(CCObject* target, SEL_CCControlHandler action, CCControlEvent controlEvent); void invoke(CCObject* sender); }; From 45d9fc9686559b4c9e79b42b273bad0f31fcbc8d Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 6 Jun 2012 14:32:15 -0700 Subject: [PATCH 090/257] Making use of the new SEL_CCControlHandler in the CCControlExtension. --- cocos2dx/extensions/CCBIReader/CCBSelectorResolver.h | 3 ++- cocos2dx/extensions/CCBIReader/CCControlLoader.cpp | 2 +- cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp | 4 ++-- cocos2dx/extensions/CCBIReader/CCNodeLoader.h | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cocos2dx/extensions/CCBIReader/CCBSelectorResolver.h b/cocos2dx/extensions/CCBIReader/CCBSelectorResolver.h index 01a323168e..dccf75df52 100644 --- a/cocos2dx/extensions/CCBIReader/CCBSelectorResolver.h +++ b/cocos2dx/extensions/CCBIReader/CCBSelectorResolver.h @@ -7,7 +7,8 @@ NS_CC_EXT_BEGIN class CCBSelectorResolver { public: - virtual cocos2d::SEL_MenuHandler onResolveCCBSelector(CCObject * pTarget, const char * pSelectorName) = 0; + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(CCObject * pTarget, const char * pSelectorName) = 0; + virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(CCObject * pTarget, const char * pSelectorName) = 0; }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp b/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp index 304b4d0c21..606ea29541 100644 --- a/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp @@ -19,7 +19,7 @@ void CCControlLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, co void CCControlLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader) { if(strcmp(pPropertyName, PROPERTY_CCCONTROL) == 0) { - ((CCControl *)pNode)->addTargetWithActionForControlEvents(pBlockCCControlData->mTarget, pBlockCCControlData->mSELMenuHandler, pBlockCCControlData->mControlEvents); + ((CCControl *)pNode)->addTargetWithActionForControlEvents(pBlockCCControlData->mTarget, pBlockCCControlData->mSELCCControlHandler, pBlockCCControlData->mControlEvents); } else { CCNodeLoader::onHandlePropTypeBlockCCControl(pNode, pParent, pPropertyName, pBlockCCControlData, pCCBReader); } diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp index bdd09cbf10..c3ffd0b7ce 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp @@ -558,7 +558,7 @@ BlockData * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, C CCBSelectorResolver * ccbSelectorResolver = pCCBReader->getCCBSelectorResolver(); if(ccbSelectorResolver != NULL) { BlockData * blockData = new BlockData(); - blockData->mSELMenuHandler = ccbSelectorResolver->onResolveCCBSelector(target, selectorName); + blockData->mSELMenuHandler = ccbSelectorResolver->onResolveCCBCCMenuSelector(target, selectorName); blockData->mTarget = target; @@ -595,7 +595,7 @@ BlockCCControlData * CCNodeLoader::parsePropTypeBlockCCControl(CCNode * pNode, C CCBSelectorResolver * ccbSelectorResolver = pCCBReader->getCCBSelectorResolver(); if(ccbSelectorResolver != NULL) { BlockCCControlData * blockCCControlData = new BlockCCControlData(); - blockCCControlData->mSELMenuHandler = ccbSelectorResolver->onResolveCCBSelector(target, selectorName); + blockCCControlData->mSELCCControlHandler = ccbSelectorResolver->onResolveCCBCCControlSelector(target, selectorName); blockCCControlData->mTarget = target; blockCCControlData->mControlEvents = controlEvents; diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.h b/cocos2dx/extensions/CCBIReader/CCNodeLoader.h index d0f88bbb5c..265d010c77 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.h @@ -12,7 +12,7 @@ struct BlockData { }; struct BlockCCControlData { - SEL_MenuHandler mSELMenuHandler; + SEL_CCControlHandler mSELCCControlHandler; CCObject * mTarget; int mControlEvents; }; From f466b081c9d70786bbe24a8f5610220e6c1a7a97 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 7 Jun 2012 11:38:59 +0800 Subject: [PATCH 091/257] fixed #1308: Used std::sort to sort the touchHandler array. --- .../touch_dispatcher/CCTouchDispatcher.cpp | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp index 8c0f08fcd1..544276241c 100644 --- a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp +++ b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp @@ -38,12 +38,11 @@ NS_CC_BEGIN /** * Used for sort */ -static int less(const void* p1, const void* p2) +static int less(const CCObject* p1, const CCObject* p2) { - return (*((CCTouchHandler**)p1))->getPriority() - (*((CCTouchHandler**)p2))->getPriority(); + return ((CCTouchHandler*)p1)->getPriority() < ((CCTouchHandler*)p2)->getPriority(); } - bool CCTouchDispatcher::isDispatchEvents(void) { return m_bDispatchEvents; @@ -293,8 +292,7 @@ CCTouchHandler* CCTouchDispatcher::findHandler(CCArray* pArray, CCTouchDelegate void CCTouchDispatcher::rearrangeHandlers(CCArray *pArray) { - // FIXME: qsort is not supported in bada1.0, so we must implement it ourselves. - qsort(pArray->data->arr, pArray->data->num, sizeof(pArray->data->arr[0]), less); + std::sort(pArray->data->arr, pArray->data->arr + pArray->data->num, less); } void CCTouchDispatcher::setPriority(int nPriority, CCTouchDelegate *pDelegate) @@ -306,11 +304,13 @@ void CCTouchDispatcher::setPriority(int nPriority, CCTouchDelegate *pDelegate) handler = this->findHandler(pDelegate); CCAssert(handler != NULL, ""); - - handler->setPriority(nPriority); - - this->rearrangeHandlers(m_pTargetedHandlers); - this->rearrangeHandlers(m_pStandardHandlers); + + if (handler->getPriority() != nPriority) + { + handler->setPriority(nPriority); + this->rearrangeHandlers(m_pTargetedHandlers); + this->rearrangeHandlers(m_pStandardHandlers); + } } // From 49d8ac72f658a166f0690026fe2d30c509a2ee36 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 7 Jun 2012 14:13:44 +0800 Subject: [PATCH 092/257] fixed #1202:remove CCFileData --- cocos2dx/cocoa/CCData.cpp | 5 ++--- cocos2dx/label_nodes/CCLabelBMFont.cpp | 7 +++--- cocos2dx/platform/CCFileUtils.h | 26 ----------------------- cocos2dx/platform/CCImageCommon_cpp.h | 14 ++++++++---- cocos2dx/platform/CCSAXParser.cpp | 5 ++--- cocos2dx/platform/ios/CCImage.mm | 14 +++++++----- cocos2dx/support/image_support/TGAlib.cpp | 6 +++--- cocos2dx/textures/CCTextureCache.cpp | 13 ++++++------ 8 files changed, 35 insertions(+), 55 deletions(-) diff --git a/cocos2dx/cocoa/CCData.cpp b/cocos2dx/cocoa/CCData.cpp index 43cc1a94d6..fea7f5cf02 100644 --- a/cocos2dx/cocoa/CCData.cpp +++ b/cocos2dx/cocoa/CCData.cpp @@ -44,9 +44,8 @@ CCData::~CCData(void) CCData* CCData::dataWithContentsOfFile(const string &strPath) { - CCFileData data(strPath.c_str(), "rb"); - unsigned long nSize = data.getSize(); - unsigned char* pBuffer = data.getBuffer(); + unsigned long nSize; + unsigned char *pBuffer = CCFileUtils::getFileData(strPath.c_str(), "rb", &nSize); if (! pBuffer) { diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index 6d710f19cc..77f37a6702 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -473,10 +473,9 @@ void CCBMFontConfiguration::purgeFontDefDictionary() void CCBMFontConfiguration::parseConfigFile(const char *controlFile) { std::string fullpath = CCFileUtils::fullPathFromRelativePath(controlFile); - - CCFileData data(fullpath.c_str(), "rb"); - unsigned long nBufSize = data.getSize(); - char* pBuffer = (char*) data.getBuffer(); + + unsigned long nBufSize; + char *pBuffer = (char*)CCFileUtils::getFileData(fullpath.c_str(), "rb", &nBufSize); CCAssert(pBuffer, "CCBMFontConfiguration::parseConfigFile | Open file error."); diff --git a/cocos2dx/platform/CCFileUtils.h b/cocos2dx/platform/CCFileUtils.h index 9d604088aa..7c91d41783 100644 --- a/cocos2dx/platform/CCFileUtils.h +++ b/cocos2dx/platform/CCFileUtils.h @@ -163,32 +163,6 @@ public: static int ccLoadFileIntoMemory(const char *filename, unsigned char **out); }; -class CCFileData -{ -public: - CCFileData(const char* pszFileName, const char* pszMode) - : m_pBuffer(0) - , m_uSize(0) - { - m_pBuffer = CCFileUtils::getFileData(pszFileName, pszMode, &m_uSize); - } - ~CCFileData() - { - CC_SAFE_DELETE_ARRAY(m_pBuffer); - } - - bool reset(const char* pszFileName, const char* pszMode) - { - CC_SAFE_DELETE_ARRAY(m_pBuffer); - m_uSize = 0; - m_pBuffer = CCFileUtils::getFileData(pszFileName, pszMode, &m_uSize); - return (m_pBuffer) ? true : false; - } - - CC_SYNTHESIZE_READONLY(unsigned char *, m_pBuffer, Buffer); - CC_SYNTHESIZE_READONLY(unsigned long , m_uSize, Size); -}; - NS_CC_END #endif // __CC_FILEUTILS_PLATFORM_H__ diff --git a/cocos2dx/platform/CCImageCommon_cpp.h b/cocos2dx/platform/CCImageCommon_cpp.h index cdc9272109..e393a31fea 100644 --- a/cocos2dx/platform/CCImageCommon_cpp.h +++ b/cocos2dx/platform/CCImageCommon_cpp.h @@ -95,15 +95,21 @@ CCImage::~CCImage() bool CCImage::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFmtPng*/) { CC_UNUSED_PARAM(eImgFmt); - CCFileData data(CCFileUtils::fullPathFromRelativePath(strPath), "rb"); - return initWithImageData(data.getBuffer(), data.getSize(), eImgFmt); + + unsigned long nSize; + unsigned char *pBuffer = CCFileUtils::getFileData(CCFileUtils::fullPathFromRelativePath(strPath), "rb", &nSize); + + return initWithImageData(pBuffer, nSize, eImgFmt); } bool CCImage::initWithImageFileThreadSafe(const char *fullpath, EImageFormat imageType) { CC_UNUSED_PARAM(imageType); - CCFileData data(fullpath, "rb"); - return initWithImageData(data.getBuffer(), data.getSize(), imageType); + + unsigned long nSize; + unsigned char *pBuffer = CCFileUtils::getFileData(fullpath, "rb", &nSize); + + return initWithImageData(pBuffer, nSize, imageType); } bool CCImage::initWithImageData(void * pData, diff --git a/cocos2dx/platform/CCSAXParser.cpp b/cocos2dx/platform/CCSAXParser.cpp index e44d55aba7..2e5b4423fe 100644 --- a/cocos2dx/platform/CCSAXParser.cpp +++ b/cocos2dx/platform/CCSAXParser.cpp @@ -83,9 +83,8 @@ bool CCSAXParser::parse(const char* pXMLData, unsigned int uDataLength) bool CCSAXParser::parse(const char *pszFile) { - CCFileData data(pszFile, "rt"); - unsigned long size = data.getSize(); - char *pBuffer = (char*) data.getBuffer(); + unsigned long size; + char *pBuffer = (char*)CCFileUtils::getFileData(pszFile, "rt", &size); if (!pBuffer) { diff --git a/cocos2dx/platform/ios/CCImage.mm b/cocos2dx/platform/ios/CCImage.mm index e9b53d7305..9828f30ccc 100644 --- a/cocos2dx/platform/ios/CCImage.mm +++ b/cocos2dx/platform/ios/CCImage.mm @@ -347,8 +347,10 @@ CCImage::~CCImage() bool CCImage::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFmtPng*/) { - CCFileData data(CCFileUtils::fullPathFromRelativePath(strPath), "rb"); - return initWithImageData(data.getBuffer(), data.getSize(), eImgFmt); + unsigned long nSize; + unsigned char *pBuffer = CCFileUtils::getFileData(CCFileUtils::fullPathFromRelativePath(strPath), "rb", &nSize); + + return initWithImageData(pBuffer, nSize, eImgFmt); } bool CCImage::initWithImageFileThreadSafe(const char *fullpath, EImageFormat imageType) @@ -356,9 +358,11 @@ bool CCImage::initWithImageFileThreadSafe(const char *fullpath, EImageFormat ima CC_UNUSED_PARAM(imageType); /* * CCFileUtils::fullPathFromRelativePath() is not thread-safe, it use autorelease(). - */ - CCFileData data(fullpath, "rb"); - return initWithImageData(data.getBuffer(), data.getSize(), imageType); + */ + unsigned long nSize; + unsigned char *pBuffer = CCFileUtils::getFileData(fullpath, "rb", &nSize); + + return initWithImageData(pBuffer, nSize, imageType); } bool CCImage::initWithImageData(void * pData, diff --git a/cocos2dx/support/image_support/TGAlib.cpp b/cocos2dx/support/image_support/TGAlib.cpp index 8de460c73d..22545ba13d 100644 --- a/cocos2dx/support/image_support/TGAlib.cpp +++ b/cocos2dx/support/image_support/TGAlib.cpp @@ -197,9 +197,9 @@ tImageTGA * tgaLoad(const char *pszFilename) { int mode,total; tImageTGA *info = NULL; - CCFileData data(pszFilename, "rb"); - unsigned long nSize = data.getSize(); - unsigned char* pBuffer = data.getBuffer(); + + unsigned long nSize; + unsigned char *pBuffer = CCFileUtils::getFileData(pszFilename, "rb", &nSize); do { diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index c691a65f2d..289a0ffbce 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -438,10 +438,9 @@ CCTexture2D * CCTextureCache::addImage(const char * path) eImageFormat = CCImage::kFmtTiff; } - CCImage image; - CCFileData data(fullpath.c_str(), "rb"); - unsigned long nSize = data.getSize(); - unsigned char* pBuffer = data.getBuffer(); + CCImage image; + unsigned long nSize; + unsigned char *pBuffer = CCFileUtils::getFileData(fullpath.c_str(), "rb", &nSize); CC_BREAK_IF(! image.initWithImageData((void*)pBuffer, nSize, eImageFormat)); texture = new CCTexture2D(); @@ -851,9 +850,9 @@ void VolatileTexture::reloadAllTextures() } else { - CCFileData data(vt->m_strFileName.c_str(), "rb"); - unsigned long nSize = data.getSize(); - unsigned char* pBuffer = data.getBuffer(); + unsigned long nSize; + unsigned char *pBuffer = CCFileUtils::getFileData(vt->m_strFileName.c_str(), "rb", &nSize); + if (image.initWithImageData((void*)pBuffer, nSize, vt->m_FmtImage)) { From b87e932b9ff2093ee9bc7351f9d36ba5ebbbc0f3 Mon Sep 17 00:00:00 2001 From: icewind Date: Thu, 7 Jun 2012 13:20:30 +0400 Subject: [PATCH 093/257] Override setOpacity to affect a background sprites Calling button->setOpacity was affecting only to label. Now opacity value applies also to a background sprites --- .../CCControlExtension/CCControlButton.cpp | 27 +++++++++++++++++++ .../CCControlExtension/CCControlButton.h | 5 ++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp index 24c00f96ed..12f767f1a9 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp @@ -496,6 +496,33 @@ void CCControlButton::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent) } } +void CCControlButton::setOpacity(GLubyte opacity) +{ + m_cOpacity = opacity; + + CCObject* child; + CCArray* children=getChildren(); + CCARRAY_FOREACH(children, child) + { + CCRGBAProtocol* pNode = dynamic_cast(child); + if (pNode) + { + pNode->setOpacity(opacity); + } + } + CCDictElement * item = NULL; + CCDICT_FOREACH(m_backgroundSpriteDispatchTable, item) + { + CCScale9Sprite* sprite = (CCScale9Sprite*)item->getObject(); + sprite->setOpacity(opacity); + } +} + +GLubyte CCControlButton::getOpacity() +{ + return m_cOpacity; +} + void CCControlButton::ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent) { m_nState = CCControlStateNormal; diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.h b/cocos2dx/extensions/CCControlExtension/CCControlButton.h index 75abd743d0..8f993d6fe6 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.h @@ -70,6 +70,9 @@ protected: //CC_PROPERTY(CCScale9Sprite*, m_backgroundSprite, BackgroundSprite); CCScale9Sprite* m_backgroundSprite; + /* Override setter to affect a background sprite too */ + CC_PROPERTY(GLubyte, m_cOpacity, Opacity); + /** Flag to know if the button is currently pushed. */ CC_SYNTHESIZE_READONLY(bool, pushed, IsPushed); // @@ -105,8 +108,6 @@ public: virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent); virtual void ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent); - - /** * Returns the title used for a state. * From ed43e6a90bf8e55a145df89d57e576dcb58221e3 Mon Sep 17 00:00:00 2001 From: Nat Weiss Date: Thu, 7 Jun 2012 21:16:24 -0700 Subject: [PATCH 094/257] Allows Cocos2D-X to be built for iOS including all cpp files. --- cocos2dx/extensions/CCBReader/CCBReader.h | 2 ++ cocos2dx/extensions/CCBReader/CCBReader_v1.cpp | 3 +++ cocos2dx/extensions/CCBReader/CCBReader_v2.cpp | 3 +++ cocos2dx/platform/CCThread.cpp | 5 +++++ 4 files changed, 13 insertions(+) diff --git a/cocos2dx/extensions/CCBReader/CCBReader.h b/cocos2dx/extensions/CCBReader/CCBReader.h index 19a804b4d3..365da70896 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader.h +++ b/cocos2dx/extensions/CCBReader/CCBReader.h @@ -30,6 +30,8 @@ #include "cocos2d.h" #include "CCBCustomClass.h" +#define CCB_READER_VERSION 2 + NS_CC_EXT_BEGIN /** diff --git a/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp b/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp index 0b0a5e5d14..7b0421042a 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp @@ -23,6 +23,8 @@ THE SOFTWARE. ****************************************************************************/ +#if CCB_READER_VERSION == 1 + #include "CCBReader.h" #include "CCBCustomClass.h" @@ -705,3 +707,4 @@ CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner) return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner); } +#endif diff --git a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp index 64e1ae0692..5162221347 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp @@ -23,6 +23,8 @@ THE SOFTWARE. ****************************************************************************/ +#if CCB_READER_VERSION == 2 + #include "CCBReader.h" #include "CCBCustomClass.h" @@ -766,3 +768,4 @@ CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner) return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner); } +#endif diff --git a/cocos2dx/platform/CCThread.cpp b/cocos2dx/platform/CCThread.cpp index 0ba2c38cc2..b0dde32bf1 100644 --- a/cocos2dx/platform/CCThread.cpp +++ b/cocos2dx/platform/CCThread.cpp @@ -22,6 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ +// iOS already has a CCThread.mm +#if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) + #include "CCThread.h" NS_CC_BEGIN @@ -37,3 +40,5 @@ void CCThread::createAutoreleasePool() } NS_CC_END + +#endif \ No newline at end of file From cc163204450cbad7d2ceab9151350eac264b1f7d Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 8 Jun 2012 13:55:28 +0800 Subject: [PATCH 095/257] issue #1310: syncronize actions --- cocos2dx/CCDirector.cpp | 2 +- cocos2dx/CCDirector.h | 8 +- cocos2dx/CCScheduler.cpp | 40 +- cocos2dx/CCScheduler.h | 48 +- cocos2dx/actions/CCAction.cpp | 8 +- cocos2dx/actions/CCAction.h | 19 +- cocos2dx/actions/CCActionCamera.cpp | 2 +- cocos2dx/actions/CCActionCamera.h | 2 +- cocos2dx/actions/CCActionCatmullRom.cpp | 415 ++++++++++++++++++ cocos2dx/actions/CCActionCatmullRom.h | 188 ++++++++ cocos2dx/actions/CCActionEase.cpp | 60 +-- cocos2dx/actions/CCActionEase.h | 40 +- cocos2dx/actions/CCActionGrid.cpp | 22 +- cocos2dx/actions/CCActionGrid.h | 26 +- cocos2dx/actions/CCActionGrid3D.cpp | 54 +-- cocos2dx/actions/CCActionGrid3D.h | 54 +-- cocos2dx/actions/CCActionInstant.cpp | 18 +- cocos2dx/actions/CCActionInstant.h | 18 +- cocos2dx/actions/CCActionInterval.cpp | 146 +++--- cocos2dx/actions/CCActionInterval.h | 132 +++--- cocos2dx/actions/CCActionManager.cpp | 29 +- cocos2dx/actions/CCActionManager.h | 12 +- cocos2dx/actions/CCActionPageTurn3D.cpp | 4 +- cocos2dx/actions/CCActionPageTurn3D.h | 4 +- cocos2dx/actions/CCActionProgressTimer.cpp | 12 +- cocos2dx/actions/CCActionProgressTimer.h | 12 +- cocos2dx/actions/CCActionTiledGrid.cpp | 68 +-- cocos2dx/actions/CCActionTiledGrid.h | 68 +-- cocos2dx/actions/CCActionTween.cpp | 6 +- cocos2dx/actions/CCActionTween.h | 6 +- cocos2dx/base_nodes/CCNode.cpp | 6 +- cocos2dx/base_nodes/CCNode.h | 6 +- cocos2dx/cocoa/CCGeometry.h | 7 +- cocos2dx/cocoa/CCObject.h | 5 +- cocos2dx/include/ccTypes.h | 7 +- .../CCTransition.cpp | 30 +- .../CCTransition.h | 35 +- .../CCTransitionPageTurn.cpp | 4 +- .../CCTransitionPageTurn.h | 4 +- cocos2dx/misc_nodes/CCMotionStreak.cpp | 2 +- cocos2dx/misc_nodes/CCMotionStreak.h | 2 +- cocos2dx/particle_nodes/CCParticleSystem.cpp | 2 +- cocos2dx/particle_nodes/CCParticleSystem.h | 4 +- cocos2dx/script_support/CCScriptSupport.cpp | 6 +- cocos2dx/script_support/CCScriptSupport.h | 12 +- cocos2dx/shaders/CCGLProgram.h | 2 + cocos2dx/textures/CCTextureCache.cpp | 2 +- cocos2dx/textures/CCTextureCache.h | 2 +- .../project.pbxproj.REMOVED.git-id | 2 +- .../ActionManagerTest/ActionManagerTest.cpp | 4 +- .../ActionManagerTest/ActionManagerTest.h | 4 +- .../tests/ActionsEaseTest/ActionsEaseTest.cpp | 4 +- tests/tests/ActionsEaseTest/ActionsEaseTest.h | 4 +- tests/tests/ActionsTest/ActionsTest.cpp | 2 +- tests/tests/ActionsTest/ActionsTest.h | 2 +- tests/tests/Box2DTest/Box2dTest.cpp | 2 +- tests/tests/Box2DTest/Box2dTest.h | 2 +- tests/tests/Box2DTestBed/Box2dView.cpp | 2 +- tests/tests/Box2DTestBed/Box2dView.h | 2 +- tests/tests/BugsTest/Bug-624.cpp | 4 +- tests/tests/BugsTest/Bug-624.h | 4 +- .../ChipmunkAccelTouchTest.cpp | 2 +- .../ChipmunkAccelTouchTest.h | 2 +- tests/tests/EffectsTest/EffectsTest.cpp | 48 +- tests/tests/EffectsTest/EffectsTest.h | 2 +- tests/tests/IntervalTest/IntervalTest.cpp | 10 +- tests/tests/IntervalTest/IntervalTest.h | 12 +- tests/tests/LabelTest/LabelTest.cpp | 10 +- tests/tests/LabelTest/LabelTest.h | 18 +- tests/tests/LayerTest/LayerTest.cpp | 2 +- tests/tests/LayerTest/LayerTest.h | 2 +- tests/tests/MenuTest/MenuTest.cpp | 2 +- tests/tests/MenuTest/MenuTest.h | 2 +- .../MotionStreakTest/MotionStreakTest.cpp | 2 +- .../tests/MotionStreakTest/MotionStreakTest.h | 2 +- tests/tests/NodeTest/NodeTest.cpp | 18 +- tests/tests/NodeTest/NodeTest.h | 16 +- tests/tests/ParticleTest/ParticleTest.cpp | 24 +- tests/tests/ParticleTest/ParticleTest.h | 20 +- .../PerformanceNodeChildrenTest.cpp | 10 +- .../PerformanceNodeChildrenTest.h | 14 +- .../PerformanceParticleTest.cpp | 2 +- .../PerformanceTest/PerformanceParticleTest.h | 2 +- .../PerformanceTouchesTest.cpp | 2 +- .../PerformanceTest/PerformanceTouchesTest.h | 4 +- tests/tests/SceneTest/SceneTest.cpp | 6 +- tests/tests/SceneTest/SceneTest.h | 6 +- tests/tests/SchedulerTest/SchedulerTest.cpp | 62 +-- tests/tests/SchedulerTest/SchedulerTest.h | 60 +-- tests/tests/ShaderTest/ShaderTest.cpp | 4 +- tests/tests/ShaderTest/ShaderTest.h | 6 +- .../SpriteTest/SpriteTest.cpp.REMOVED.git-id | 2 +- tests/tests/SpriteTest/SpriteTest.h | 28 +- tests/tests/TextInputTest/TextInputTest.cpp | 6 +- tests/tests/Texture2dTest/Texture2dTest.cpp | 2 +- tests/tests/Texture2dTest/Texture2dTest.h | 2 +- tests/tests/TileMapTest/TileMapTest.cpp | 20 +- tests/tests/TileMapTest/TileMapTest.h | 20 +- tests/tests/TouchesTest/Ball.cpp | 2 +- tests/tests/TouchesTest/Ball.h | 2 +- tests/tests/TouchesTest/TouchesTest.cpp | 2 +- tests/tests/TouchesTest/TouchesTest.h | 2 +- .../tests/TransitionsTest/TransitionsTest.cpp | 36 +- tests/tests/TransitionsTest/TransitionsTest.h | 4 +- tests/tests/ZwoptexTest/ZwoptexTest.cpp | 4 +- tests/tests/ZwoptexTest/ZwoptexTest.h | 4 +- 106 files changed, 1423 insertions(+), 784 deletions(-) create mode 100644 cocos2dx/actions/CCActionCatmullRom.cpp create mode 100644 cocos2dx/actions/CCActionCatmullRom.h diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 8ac31f5911..ebd9ad173a 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -138,7 +138,7 @@ bool CCDirector::init(void) m_pScheduler = new CCScheduler(); // action manager m_pActionManager = new CCActionManager(); - m_pScheduler->scheduleUpdateForTarget(m_pActionManager, kCCActionManagerPriority, false); + m_pScheduler->scheduleUpdateForTarget(m_pActionManager, kCCPrioritySystem, false); // touchDispatcher m_pTouchDispatcher = new CCTouchDispatcher(); m_pTouchDispatcher->init(); diff --git a/cocos2dx/CCDirector.h b/cocos2dx/CCDirector.h index 5ccd4eed4d..9b63a63aea 100644 --- a/cocos2dx/CCDirector.h +++ b/cocos2dx/CCDirector.h @@ -329,8 +329,8 @@ protected: bool m_bLandscape; bool m_bDisplayStats; - ccTime m_fAccumDt; - ccTime m_fFrameRate; + float m_fAccumDt; + float m_fFrameRate; CCLabelBMFont *m_pFPSLabel; CCLabelBMFont *m_pSPFLabel; @@ -342,7 +342,7 @@ protected: /* How many frames were called since the director started */ unsigned int m_uTotalFrames; unsigned int m_uFrames; - ccTime m_fSecondsPerFrame; + float m_fSecondsPerFrame; /* The running scene */ CCScene *m_pRunningScene; @@ -361,7 +361,7 @@ protected: struct cc_timeval *m_pLastUpdate; /* delta time since last tick to main loop */ - ccTime m_fDeltaTime; + float m_fDeltaTime; /* whether or not the next delta time will be zero */ bool m_bNextDeltaTimeZero; diff --git a/cocos2dx/CCScheduler.cpp b/cocos2dx/CCScheduler.cpp index ebe3de1ba9..81818c4ecb 100644 --- a/cocos2dx/CCScheduler.cpp +++ b/cocos2dx/CCScheduler.cpp @@ -63,15 +63,15 @@ typedef struct _hashSelectorEntry ccArray *timers; CCObject *target; // hash key (retained) unsigned int timerIndex; - CCTimer *currentTimer; + floatr *currentTimer; bool currentTimerSalvaged; bool paused; UT_hash_handle hh; } tHashSelectorEntry; -// implementation CCTimer +// implementation floatr -CCTimer::CCTimer() +floatr::floatr() : m_pfnSelector(NULL) , m_fInterval(0.0f) , m_pTarget(NULL) @@ -86,9 +86,9 @@ CCTimer::CCTimer() } -CCTimer* CCTimer::timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector) +floatr* floatr::timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector) { - CCTimer *pTimer = new CCTimer(); + floatr *pTimer = new floatr(); pTimer->initWithTarget(pTarget, pfnSelector, 0.0f, kCCRepeatForever, 0.0f); pTimer->autorelease(); @@ -96,9 +96,9 @@ CCTimer* CCTimer::timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector) return pTimer; } -CCTimer* CCTimer::timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, ccTime fSeconds) +floatr* floatr::timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, float fSeconds) { - CCTimer *pTimer = new CCTimer(); + floatr *pTimer = new floatr(); pTimer->initWithTarget(pTarget, pfnSelector, fSeconds, kCCRepeatForever, 0.0f); pTimer->autorelease(); @@ -106,9 +106,9 @@ CCTimer* CCTimer::timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, c return pTimer; } -CCTimer* CCTimer::timerWithScriptHandler(int nHandler, ccTime fSeconds) +floatr* floatr::timerWithScriptHandler(int nHandler, float fSeconds) { - CCTimer *pTimer = new CCTimer(); + floatr *pTimer = new floatr(); pTimer->initWithScriptHandler(nHandler, fSeconds); pTimer->autorelease(); @@ -116,7 +116,7 @@ CCTimer* CCTimer::timerWithScriptHandler(int nHandler, ccTime fSeconds) return pTimer; } -bool CCTimer::initWithScriptHandler(int nHandler, ccTime fSeconds) +bool floatr::initWithScriptHandler(int nHandler, float fSeconds) { m_nScriptHandler = nHandler; m_fElapsed = -1; @@ -125,12 +125,12 @@ bool CCTimer::initWithScriptHandler(int nHandler, ccTime fSeconds) return true; } -bool CCTimer::initWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector) +bool floatr::initWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector) { return initWithTarget(pTarget, pfnSelector, 0, kCCRepeatForever, 0.0f); } -bool CCTimer::initWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, ccTime fSeconds, unsigned int nRepeat, ccTime fDelay) +bool floatr::initWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, float fSeconds, unsigned int nRepeat, float fDelay) { m_pTarget = pTarget; m_pfnSelector = pfnSelector; @@ -143,7 +143,7 @@ bool CCTimer::initWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, ccTime return true; } -void CCTimer::update(ccTime dt) +void floatr::update(float dt) { if (m_fElapsed == -1) { @@ -254,7 +254,7 @@ void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, this->scheduleSelector(pfnSelector, pTarget, fInterval, bPaused, kCCRepeatForever, 0.0f); } -void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, ccTime fInterval, bool bPaused, unsigned int repeat, ccTime delay) +void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, float fInterval, bool bPaused, unsigned int repeat, float delay) { CCAssert(pfnSelector, ""); CCAssert(pTarget, ""); @@ -288,7 +288,7 @@ void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, { for (unsigned int i = 0; i < pElement->timers->num; ++i) { - CCTimer *timer = (CCTimer*)pElement->timers->arr[i]; + floatr *timer = (floatr*)pElement->timers->arr[i]; if (pfnSelector == timer->m_pfnSelector) { @@ -300,7 +300,7 @@ void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, ccArrayEnsureExtraCapacity(pElement->timers, 1); } - CCTimer *pTimer = new CCTimer(); + floatr *pTimer = new floatr(); pTimer->initWithTarget(pTarget, pfnSelector, fInterval, repeat, delay); ccArrayAppendObject(pElement->timers, pTimer); pTimer->release(); @@ -324,7 +324,7 @@ void CCScheduler::unscheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget { for (unsigned int i = 0; i < pElement->timers->num; ++i) { - CCTimer *pTimer = (CCTimer*)(pElement->timers->arr[i]); + floatr *pTimer = (floatr*)(pElement->timers->arr[i]); if (pfnSelector == pTimer->m_pfnSelector) { @@ -580,7 +580,7 @@ void CCScheduler::unscheduleAllSelectorsForTarget(CCObject *pTarget) unscheduleUpdateForTarget(pTarget); } -unsigned int CCScheduler::scheduleScriptFunc(unsigned int nHandler, ccTime fInterval, bool bPaused) +unsigned int CCScheduler::scheduleScriptFunc(unsigned int nHandler, float fInterval, bool bPaused) { CCSchedulerScriptHandlerEntry* pEntry = CCSchedulerScriptHandlerEntry::entryWithHandler(nHandler, fInterval, bPaused); if (!m_pScriptHandlerEntries) @@ -664,7 +664,7 @@ bool CCScheduler::isTargetPaused(CCObject *pTarget) } // main loop -void CCScheduler::update(ccTime dt) +void CCScheduler::update(float dt) { m_bUpdateHashLocked = true; @@ -714,7 +714,7 @@ void CCScheduler::update(ccTime dt) // The 'timers' array may change while inside this loop for (elt->timerIndex = 0; elt->timerIndex < elt->timers->num; ++(elt->timerIndex)) { - elt->currentTimer = (CCTimer*)(elt->timers->arr[elt->timerIndex]); + elt->currentTimer = (floatr*)(elt->timers->arr[elt->timerIndex]); elt->currentTimerSalvaged = false; elt->currentTimer->update(dt); diff --git a/cocos2dx/CCScheduler.h b/cocos2dx/CCScheduler.h index ed2e0d6d67..c9e79295fb 100644 --- a/cocos2dx/CCScheduler.h +++ b/cocos2dx/CCScheduler.h @@ -32,54 +32,60 @@ THE SOFTWARE. NS_CC_BEGIN +// Priority level reserved for system services. +#define kCCPrioritySystem INT_MIN + +// Minimum priority level for user scheduling. +#define kCCPriorityNonSystemMin (kCCPrioritySystem+1) + // -// CCTimer +// floatr // /** @brief Light weight timer */ -class CC_DLL CCTimer : public CCObject +class CC_DLL floatr : public CCObject { public: - CCTimer(void); + floatr(void); /** get interval in seconds */ - inline ccTime getInterval(void) { return m_fInterval; } + inline float getInterval(void) { return m_fInterval; } /** set interval in seconds */ - inline void setInterval(ccTime fInterval){ m_fInterval = fInterval; } + inline void setInterval(float fInterval){ m_fInterval = fInterval; } /** Initializes a timer with a target and a selector. */ bool initWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector); /** Initializes a timer with a target, a selector and an interval in seconds, repeat in number of times to repeat, delay in seconds. */ - bool initWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, ccTime fSeconds, unsigned int nRepeat, ccTime fDelay); + bool initWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, float fSeconds, unsigned int nRepeat, float fDelay); /** Initializes a timer with a script callback function and an interval in seconds. */ - bool initWithScriptHandler(int nHandler, ccTime fSeconds); + bool initWithScriptHandler(int nHandler, float fSeconds); /** triggers the timer */ - void update(ccTime dt); + void update(float dt); public: /** Allocates a timer with a target and a selector. */ - static CCTimer* timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector); + static floatr* timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector); /** Allocates a timer with a target, a selector and an interval in seconds. */ - static CCTimer* timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, ccTime fSeconds); + static floatr* timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, float fSeconds); /** Allocates a timer with a script callback function and an interval in seconds. */ - static CCTimer* timerWithScriptHandler(int nHandler, ccTime fSeconds); + static floatr* timerWithScriptHandler(int nHandler, float fSeconds); public: SEL_SCHEDULE m_pfnSelector; - ccTime m_fInterval; + float m_fInterval; protected: CCObject *m_pTarget; - ccTime m_fElapsed; + float m_fElapsed; bool m_bRunForever; bool m_bUseDelay; unsigned int m_nTimesExecuted; unsigned int m_nRepeat; //0 = once, 1 is 2 x executed - ccTime m_fDelay; + float m_fDelay; int m_nScriptHandler; }; @@ -110,7 +116,7 @@ public: CCScheduler(); ~CCScheduler(void); - inline ccTime getTimeScale(void) { return m_fTimeScale; } + inline float getTimeScale(void) { return m_fTimeScale; } /** Modifies the time of all scheduled callbacks. You can use this property to create a 'slow motion' or 'fast forward' effect. Default is 1.0. To create a 'slow motion' effect, use values below 1.0. @@ -118,12 +124,12 @@ public: @since v0.8 @warning It will affect EVERY scheduled selector / action. */ - inline void setTimeScale(ccTime fTimeScale) { m_fTimeScale = fTimeScale; } + inline void setTimeScale(float fTimeScale) { m_fTimeScale = fTimeScale; } /** 'update' the scheduler. You should NEVER call this method, unless you know what you are doing. */ - void update(ccTime dt); + void update(float dt); /** The scheduled method will be called every 'interval' seconds. If paused is YES, then it won't be called until it is resumed. @@ -134,10 +140,10 @@ public: @since v0.99.3, repeat and delay added in v1.1 */ - void scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, ccTime fInterval, bool bPaused, unsigned int repeat, ccTime delay); + void scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, float fInterval, bool bPaused, unsigned int repeat, float delay); /** calls scheduleSelector with kCCRepeatForever and a 0 delay */ - void scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, ccTime fInterval, bool bPaused); + void scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, float fInterval, bool bPaused); /** Schedules the 'update' selector for a given target with a given priority. The 'update' selector will be called every frame. The lower the priority, the earlier it is called. @@ -174,7 +180,7 @@ public: If 'interval' is 0, it will be called every frame. return schedule script entry ID, used for unscheduleScriptFunc(). */ - unsigned int scheduleScriptFunc(unsigned int nHandler, ccTime fInterval, bool bPaused); + unsigned int scheduleScriptFunc(unsigned int nHandler, float fInterval, bool bPaused); /** Unschedule a script entry. */ void unscheduleScriptEntry(unsigned int uScheduleScriptEntryID); @@ -208,7 +214,7 @@ private: void appendIn(struct _listEntry **ppList, CCObject *pTarget, bool bPaused); protected: - ccTime m_fTimeScale; + float m_fTimeScale; // // "updates with priority" stuff diff --git a/cocos2dx/actions/CCAction.cpp b/cocos2dx/actions/CCAction.cpp index 03c046a684..f63b3d3214 100644 --- a/cocos2dx/actions/CCAction.cpp +++ b/cocos2dx/actions/CCAction.cpp @@ -94,13 +94,13 @@ bool CCAction::isDone() return true; } -void CCAction::step(ccTime dt) +void CCAction::step(float dt) { CC_UNUSED_PARAM(dt); CCLOG("[Action step]. override me"); } -void CCAction::update(ccTime time) +void CCAction::update(float time) { CC_UNUSED_PARAM(time); CCLOG("[Action update]. override me"); @@ -178,7 +178,7 @@ void CCSpeed::stop() CCAction::stop(); } -void CCSpeed::step(ccTime dt) +void CCSpeed::step(float dt) { m_pInnerAction->step(dt * m_fSpeed); } @@ -303,7 +303,7 @@ CCObject *CCFollow::copyWithZone(CCZone *pZone) CC_SAFE_DELETE(pNewZone); return pRet; } -void CCFollow::step(ccTime dt) +void CCFollow::step(float dt) { CC_UNUSED_PARAM(dt); diff --git a/cocos2dx/actions/CCAction.h b/cocos2dx/actions/CCAction.h index 76c4162d58..62cd64f3b5 100644 --- a/cocos2dx/actions/CCAction.h +++ b/cocos2dx/actions/CCAction.h @@ -28,6 +28,7 @@ THE SOFTWARE. #define __ACTIONS_CCACTION_H__ #include "CCObject.h" +#include "CCGeometry.h" NS_CC_BEGIN @@ -62,7 +63,7 @@ public: virtual void stop(void); //! called every frame with it's delta time. DON'T override unless you know what you are doing. - virtual void step(ccTime dt); + virtual void step(float dt); /** called once per frame. time a value between 0 and 1 @@ -72,7 +73,7 @@ public: - 0.5 means that the action is in the middle - 1 means that the action is over */ - virtual void update(ccTime time); + virtual void update(float time); inline CCNode* getTarget(void) { return m_pTarget; } /** The action will modify the target properties. */ @@ -122,15 +123,15 @@ public: {} virtual ~CCFiniteTimeAction(){} //! get duration in seconds of the action - inline ccTime getDuration(void) { return m_fDuration; } + inline float getDuration(void) { return m_fDuration; } //! set duration in seconds of the action - inline void setDuration(ccTime duration) { m_fDuration = duration; } + inline void setDuration(float duration) { m_fDuration = duration; } /** returns a reversed action */ virtual CCFiniteTimeAction* reverse(void); protected: //! duration in seconds - ccTime m_fDuration; + float m_fDuration; }; class CCActionInterval; @@ -161,7 +162,7 @@ public: virtual CCObject* copyWithZone(CCZone *pZone); virtual void startWithTarget(CCNode* pTarget); virtual void stop(); - virtual void step(ccTime dt); + virtual void step(float dt); virtual bool isDone(void); virtual CCActionInterval* reverse(void); @@ -181,10 +182,6 @@ protected: CCActionInterval *m_pInnerAction; }; - -class CCNode; -class CCPoint; -class CCRect; /** @brief CCFollow is an action that "follows" a node. @@ -219,7 +216,7 @@ public: bool initWithTarget(CCNode *pFollowedNode, const CCRect& rect); virtual CCObject* copyWithZone(CCZone *pZone); - virtual void step(ccTime dt); + virtual void step(float dt); virtual bool isDone(void); virtual void stop(void); diff --git a/cocos2dx/actions/CCActionCamera.cpp b/cocos2dx/actions/CCActionCamera.cpp index aabc9e065d..2f279cc689 100644 --- a/cocos2dx/actions/CCActionCamera.cpp +++ b/cocos2dx/actions/CCActionCamera.cpp @@ -116,7 +116,7 @@ void CCOrbitCamera::startWithTarget(CCNode *pTarget) m_fRadX = (CCFloat)CC_DEGREES_TO_RADIANS(m_fAngleX); } -void CCOrbitCamera::update(ccTime dt) +void CCOrbitCamera::update(float dt) { float r = (m_fRadius + m_fDeltaRadius * dt) * CCCamera::getZEye(); float za = m_fRadZ + m_fRadDeltaZ * dt; diff --git a/cocos2dx/actions/CCActionCamera.h b/cocos2dx/actions/CCActionCamera.h index b4be84de88..fc4d6459d2 100644 --- a/cocos2dx/actions/CCActionCamera.h +++ b/cocos2dx/actions/CCActionCamera.h @@ -96,7 +96,7 @@ public: // super methods virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); protected: float m_fRadius; diff --git a/cocos2dx/actions/CCActionCatmullRom.cpp b/cocos2dx/actions/CCActionCatmullRom.cpp new file mode 100644 index 0000000000..7a4d3339dd --- /dev/null +++ b/cocos2dx/actions/CCActionCatmullRom.cpp @@ -0,0 +1,415 @@ +/* + * Copyright (c) 2010-2012 cocos2d-x.org + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2008 Radu Gruian + * + * Copyright (c) 2011 Vit Valentin + * + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * + * Orignal code by Radu Gruian: http://www.codeproject.com/Articles/30838/Overhauser-Catmull-Rom-Splines-for-Camera-Animatio.So + * + * Adapted to cocos2d-x by Vit Valentin + * + * Adapted from cocos2d-x to cocos2d-iphone by Ricardo Quesada + */ +#include "ccMacros.h" +#include "support/CCPointExtension.h" +#include "CCActionCatmullRom.h" + +NS_CC_BEGIN; + +/* + * Implementation of CCPointArray + */ +CCPointArray* CCPointArray::arrayWithCapacity(unsigned int capacity) +{ + CCPointArray* ret = new CCPointArray(); + if (ret) + { + if (ret->initWithCapacity(capacity)) + { + ret->autorelease(); + } + else + { + delete ret; + ret = NULL; + } + } + + return ret; +} + +bool CCPointArray::initWithCapacity(unsigned int capacity) +{ + m_pControlPoints = new CCArray(capacity); + + return true; +} + +CCObject* CCPointArray::copyWithZone(cocos2d::CCZone *zone) +{ + CCArray *newArray = new CCArray(); + + CCObject* pObj = NULL; + CCARRAY_FOREACH(m_pControlPoints, pObj) + { + newArray->addObject(pObj); + } + + CCPointArray *points = CCPointArray::arrayWithCapacity(10); + points->setControlPoints(newArray); + newArray->release(); + + return points; +} + +CCPointArray::~CCPointArray() +{ + CC_SAFE_RELEASE_NULL(m_pControlPoints); +} + +CCPointArray::CCPointArray() :m_pControlPoints(NULL){} + +void CCPointArray::addControlPoint(CCPoint &controlPoint) +{ + m_pControlPoints->addObject(&controlPoint); +} + +void CCPointArray::insertControlPoint(CCPoint &controlPoint, unsigned int index) +{ + m_pControlPoints->insertObject(&controlPoint, index); +} + +CCPoint CCPointArray::getControlPointAtIndex(unsigned int index) +{ + index = MIN(m_pControlPoints->count()-1, MAX(index, 0)); + CCPoint point = *((CCPoint*)m_pControlPoints->objectAtIndex(index)); + + return point; +} + +void CCPointArray::replaceControlPoint(cocos2d::CCPoint &controlPoint, unsigned int index) +{ + m_pControlPoints->replaceObjectAtIndex(index, &controlPoint); +} + +void CCPointArray::removeControlPointAtIndex(unsigned int index) +{ + m_pControlPoints->removeObjectAtIndex(index); +} + +unsigned int CCPointArray::count() +{ + return m_pControlPoints->count(); +} + +CCPointArray* CCPointArray::reverse() +{ + CCArray *newArray = new CCArray(m_pControlPoints->count()); + for (int i = m_pControlPoints->count()-1; i >= 0; --i) + { + newArray->addObject(m_pControlPoints->objectAtIndex(i)); + } + CCPointArray *config = CCPointArray::arrayWithCapacity(0); + config->setControlPoints(newArray); + + newArray->release(); + + config->autorelease(); + return config; +} + +void CCPointArray::reverseInline() +{ + unsigned int l = m_pControlPoints->count(); + for (unsigned int i = 0; i < l/2; ++i) + { + m_pControlPoints->exchangeObjectAtIndex(i, l-i-1); + } +} + +// CatmullRom Spline formula: +inline CCPoint ccCardinalSplineAt(CCPoint &p0, CCPoint &p1, CCPoint &p2, CCPoint &p3, CCFloat tension, float t) +{ + float t2 = t * t; + float t3 = t2 * t; + + /* + * Formula: s(-ttt + 2tt – t)P1 + s(-ttt + tt)P2 + (2ttt – 3tt + 1)P2 + s(ttt – 2tt + t)P3 + (-2ttt + 3tt)P3 + s(ttt – tt)P4 + */ + float s = (1 - tension) / 2; + + float b1 = s * ((-t3 + (2 * t2)) - t); // s(-t3 + 2 t2 – t)P1 + float b2 = s * (-t3 + t2) + (2 * t3 - 3 * t2 + 1); // s(-t3 + t2)P2 + (2 t3 – 3 t2 + 1)P2 + float b3 = s * (t3 - 2 * t2 + t) + (-2 * t3 + 3 * t2); // s(t3 – 2 t2 + t)P3 + (-2 t3 + 3 t2)P3 + float b4 = s * (t3 - t2); // s(t3 – t2)P4 + + float x = (p0.x*b1 + p1.x*b2 + p2.x*b3 + p3.x*b4); + float y = (p0.y*b1 + p1.y*b2 + p2.y*b3 + p3.y*b4); + + return ccp(x,y); +} + +/* Implementation of CCCardinalSplineTo + */ +CCCardinalSplineTo* CCCardinalSplineTo::actionWithDuration(float duration, cocos2d::CCPointArray *points, float tension) +{ + CCCardinalSplineTo *ret = new CCCardinalSplineTo(); + if (ret) + { + if (ret->initWithDuration(duration, points, tension)) + { + ret->autorelease(); + } + else + { + CC_SAFE_RELEASE_NULL(ret); + } + } + + return ret; +} + +bool CCCardinalSplineTo::initWithDuration(float duration, cocos2d::CCPointArray *points, float tension) +{ + CCAssert(points->count() > 0, "Invalid configuration. It must at least have one control point"); + + if (CCActionInterval::initWithDuration(duration)) + { + this->setPoints(points); + this->m_fTension = tension; + + return true; + } + + return false; +} + +CCCardinalSplineTo::~CCCardinalSplineTo() +{ + CC_SAFE_RELEASE_NULL(m_pPoints); +} + +CCCardinalSplineTo::CCCardinalSplineTo() +: m_pPoints(NULL) +, m_fTension(0.f) +, m_fDeltaT(0.f) +{ +} + +void CCCardinalSplineTo::startWithTarget(cocos2d::CCNode *pTarget) +{ + CCActionInterval::startWithTarget(pTarget); + + m_fDeltaT = (float) 1 / m_pPoints->count(); +} + +CCCardinalSplineTo* CCCardinalSplineTo::copyWithZone(cocos2d::CCZone *pZone) +{ + CCCardinalSplineTo *copy = CCCardinalSplineTo::actionWithDuration(this->getDuration(), this->m_pPoints, this->m_fTension); + return copy; +} + +void CCCardinalSplineTo::update(float time) +{ + unsigned int p; + float lt; + + // border + if (time == 1) + { + p = m_pPoints->count() - 1; + lt = 1; + } + else + { + p = time / m_fDeltaT; + lt = (time - m_fDeltaT * (float)p) / m_fDeltaT; + } + + // Interpolate + CCPoint pp0 = m_pPoints->getControlPointAtIndex(p-1); + CCPoint pp1 = m_pPoints->getControlPointAtIndex(p+0); + CCPoint pp2 = m_pPoints->getControlPointAtIndex(p+1); + CCPoint pp3 = m_pPoints->getControlPointAtIndex(p+2); + + CCPoint newPos = ccCardinalSplineAt(pp0, pp1, pp2, pp3, m_fTension, lt); + + this->updatePosition(newPos); +} + +void CCCardinalSplineTo::updatePosition(cocos2d::CCPoint &newPos) +{ + m_pTarget->setPosition(newPos); +} + +CCActionInterval* CCCardinalSplineTo::reverse() +{ + CCPointArray *reverse = m_pPoints->reverse(); + + return CCCardinalSplineTo::actionWithDuration(m_fDuration, reverse, m_fTension); +} + +/* CCCardinalSplineBy + */ + +CCCardinalSplineBy* CCCardinalSplineBy::actionWithDuration(float duration, cocos2d::CCPointArray *points, float tension) +{ + CCCardinalSplineBy *ret = new CCCardinalSplineBy(); + if (ret) + { + if (ret->initWithDuration(duration, points, tension)) + { + ret->autorelease(); + } + else + { + CC_SAFE_RELEASE_NULL(ret); + } + } + + return ret; +} + +CCCardinalSplineBy::CCCardinalSplineBy() : m_startPosition(0,0) +{ +} + +void CCCardinalSplineBy::updatePosition(cocos2d::CCPoint &newPos) +{ + m_pTarget->setPosition(ccpAdd(newPos, m_startPosition)); +} + +CCActionInterval* CCCardinalSplineBy::reverse() +{ + CCPointArray *copyConfig = (CCPointArray*)m_pPoints->copy(); + + // + // convert "absolutes" to "diffs" + // + CCPoint p = copyConfig->getControlPointAtIndex(0); + for (unsigned int i = 1; i < copyConfig->count(); ++i) + { + CCPoint current = copyConfig->getControlPointAtIndex(i); + CCPoint diff = ccpSub(current, p); + copyConfig->replaceControlPoint(diff, i); + + p = current; + } + + + // convert to "diffs" to "reverse absolute" + + CCPointArray *reverse = copyConfig->reverse(); + copyConfig->release(); + + // 1st element (which should be 0,0) should be here too + + p = reverse->getControlPointAtIndex(reverse->count()-1); + reverse->removeControlPointAtIndex(reverse->count()-1); + + p = ccpNeg(p); + reverse->insertControlPoint(p, 0); + + for (unsigned int i = 1; i < reverse->count(); ++i) + { + CCPoint current = reverse->getControlPointAtIndex(i); + current = ccpNeg(current); + CCPoint abs = ccpAdd(current, p); + reverse->replaceControlPoint(abs, i); + + p = abs; + } + + return CCCardinalSplineBy::actionWithDuration(m_fDuration, reverse, m_fTension); +} + +void CCCardinalSplineBy::startWithTarget(cocos2d::CCNode *pTarget) +{ + CCCardinalSplineTo::startWithTarget(pTarget); + m_startPosition = pTarget->getPosition(); +} + +/* CCCatmullRomTo + */ +CCCatmullRomTo* CCCatmullRomTo::actionWithDuration(float dt, cocos2d::CCPointArray *points) +{ + CCCatmullRomTo *ret = new CCCatmullRomTo(); + if (ret) + { + if (ret->initWithDuration(dt, points)) + { + ret->autorelease(); + } + else + { + CC_SAFE_RELEASE_NULL(ret); + } + } + + return ret; +} + +bool CCCatmullRomTo::initWithDuration(float dt, cocos2d::CCPointArray *points) +{ + if (CCCardinalSplineTo::initWithDuration(dt, points, 0.5f)) + { + return true; + } + + return false; +} + +/* CCCatmullRomBy + */ +CCCatmullRomBy* CCCatmullRomBy::actionWithDuration(float dt, cocos2d::CCPointArray *points) +{ + CCCatmullRomBy *ret = new CCCatmullRomBy(); + if (ret) + { + if (ret->initWithDuration(dt, points)) + { + ret->autorelease(); + } + else + { + CC_SAFE_RELEASE_NULL(ret); + } + } + + return ret; +} + +bool CCCatmullRomBy::initWithDuration(float dt, cocos2d::CCPointArray *points) +{ + if (CCCardinalSplineTo::initWithDuration(dt, points, 0.5f)) + { + return true; + } + + return false; +} + +NS_CC_END; + diff --git a/cocos2dx/actions/CCActionCatmullRom.h b/cocos2dx/actions/CCActionCatmullRom.h new file mode 100644 index 0000000000..984f63db78 --- /dev/null +++ b/cocos2dx/actions/CCActionCatmullRom.h @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2012 cocos2d-x.org + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2008 Radu Gruian + * + * Copyright (c) 2011 Vit Valentin + * + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * + * Orignal code by Radu Gruian: http://www.codeproject.com/Articles/30838/Overhauser-Catmull-Rom-Splines-for-Camera-Animatio.So + * + * Adapted to cocos2d-x by Vit Valentin + * + * Adapted from cocos2d-x to cocos2d-iphone by Ricardo Quesada + */ + + +#ifndef __CCACTION_CATMULLROM_H__ +#define __CCACTION_CATMULLROM_H__ + +#include "CCActionInterval.h" +#include "CCNode.h" +#include "CCGeometry.h" + +NS_CC_BEGIN; + +/** An Array that contain control points. + Used by CCCardinalSplineTo and (By) and CCCatmullRomTo (and By) actions. + */ +class CC_DLL CCPointArray : public CCNode +{ +public: + /** creates and initializes a Points array with capacity */ + static CCPointArray* arrayWithCapacity(unsigned int capacity); + + virtual ~CCPointArray(); + CCPointArray(); + + /** initializes a Catmull Rom config with a capacity hint */ + bool initWithCapacity(unsigned int capacity); + + /** appends a control point */ + void addControlPoint(CCPoint &controlPoint); + + /** inserts a controlPoint at index */ + void insertControlPoint(CCPoint &controlPoint, unsigned int index); + + /** replaces an existing controlPoint at index */ + void replaceControlPoint(CCPoint &controlPoint, unsigned int index); + + /** get the value of a controlPoint at a given index */ + CCPoint getControlPointAtIndex(unsigned int index); + + /** deletes a control point at a given index */ + void removeControlPointAtIndex(unsigned int index); + + /** returns the number of objects of the control point array */ + unsigned int count(); + + /** returns a new copy of the array reversed. User is responsible for releasing this copy */ + CCPointArray* reverse(); + + /** reverse the current control point array inline, without generating a new one */ + void reverseInline(); + + virtual CCObject* copyWithZone(CCZone *zone); + + inline CCArray* getControlPoints(){ return m_pControlPoints; } + inline void setControlPoints(CCArray *controlPoints) + { + CC_SAFE_RETAIN(controlPoints); + CC_SAFE_RELEASE(m_pControlPoints); + m_pControlPoints = controlPoints; + } +private: + /** Array that contains the control points */ + CCArray *m_pControlPoints; +}; + +/** Cardinal Spline path. + http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline + */ +class CC_DLL CCCardinalSplineTo : public CCActionInterval +{ +public: + /** creates an action with a Cardinal Spline array of points and tension */ + static CCCardinalSplineTo* actionWithDuration(float duration, CCPointArray* points, float tension); + + virtual ~CCCardinalSplineTo(); + CCCardinalSplineTo(); + + /** initializes the action with a duration and an array of points */ + bool initWithDuration(float duration, CCPointArray* points, float tension); + + // super virtual functions + virtual CCCardinalSplineTo* copyWithZone(CCZone* pZone); + virtual void startWithTarget(CCNode *pTarget); + virtual void update(float time); + virtual CCActionInterval* reverse(); + + virtual void updatePosition(CCPoint &newPos); + + inline CCPointArray* getPoints() { return m_pPoints; } + inline void setPoints(CCPointArray* points) + { + CC_SAFE_RETAIN(points); + CC_SAFE_RELEASE(m_pPoints); + m_pPoints = points; + } + +protected: + /** Array of control points */ + CCPointArray *m_pPoints; + float m_fDeltaT; + float m_fTension; +}; + +/** Cardinal Spline path. + http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline + */ +class CC_DLL CCCardinalSplineBy : public CCCardinalSplineTo +{ +public: + /** creates an action with a Cardinal Spline array of points and tension */ + static CCCardinalSplineBy* actionWithDuration(float duration, CCPointArray* points, float tension); + + CCCardinalSplineBy(); + + virtual void startWithTarget(CCNode *pTarget); + virtual CCActionInterval* reverse(); + virtual void updatePosition(CCPoint &newPos); +protected: + CCPoint m_startPosition; +}; + +/** An action that moves the target with a CatmullRom curve to a destination point. + A Catmull Rom is a Cardinal Spline with a tension of 0.5. + http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline + */ +class CCCatmullRomTo : public CCCardinalSplineTo +{ +public: + /** creates an action with a Cardinal Spline array of points and tension */ + static CCCatmullRomTo* actionWithDuration(float dt, CCPointArray* points); + + /** initializes the action with a duration and an array of points */ + bool initWithDuration(float dt, CCPointArray* points); +}; + +/** An action that moves the target with a CatmullRom curve by a certain distance. + A Catmull Rom is a Cardinal Spline with a tension of 0.5. + http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline + */ +class CC_DLL CCCatmullRomBy : public CCCardinalSplineBy +{ +public: + /** creates an action with a Cardinal Spline array of points and tension */ + static CCCatmullRomBy* actionWithDuration(float dt, CCPointArray* points); + + /** initializes the action with a duration and an array of points */ + bool initWithDuration(float dt, CCPointArray* points); +}; + +/** Returns the Cardinal Spline position for a given set of control points, tension and time */ +extern CCPoint ccCardinalSplineAt(CCPoint &p0, CCPoint &p1, CCPoint &p2, CCPoint &p3, CCFloat tension, float t); + +NS_CC_END; + +#endif // __CCACTION_CATMULLROM_H__ diff --git a/cocos2dx/actions/CCActionEase.cpp b/cocos2dx/actions/CCActionEase.cpp index 4f4bf7a7c7..aebdbfae13 100644 --- a/cocos2dx/actions/CCActionEase.cpp +++ b/cocos2dx/actions/CCActionEase.cpp @@ -115,7 +115,7 @@ void CCActionEase::stop(void) CCActionInterval::stop(); } -void CCActionEase::update(ccTime time) +void CCActionEase::update(float time) { m_pOther->update(time); } @@ -229,7 +229,7 @@ CCObject* CCEaseIn::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseIn::update(ccTime time) +void CCEaseIn::update(float time) { m_pOther->update(powf(time, m_fRate)); } @@ -281,7 +281,7 @@ CCObject* CCEaseOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseOut::update(ccTime time) +void CCEaseOut::update(float time) { m_pOther->update(powf(time, 1 / m_fRate)); } @@ -333,7 +333,7 @@ CCObject* CCEaseInOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseInOut::update(ccTime time) +void CCEaseInOut::update(float time) { time *= 2; if (time < 1) @@ -394,7 +394,7 @@ CCObject* CCEaseExponentialIn::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseExponentialIn::update(ccTime time) +void CCEaseExponentialIn::update(float time) { m_pOther->update(time == 0 ? 0 : powf(2, 10 * (time/1 - 1)) - 1 * 0.001f); } @@ -446,7 +446,7 @@ CCObject* CCEaseExponentialOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseExponentialOut::update(ccTime time) +void CCEaseExponentialOut::update(float time) { m_pOther->update(time == 1 ? 1 : (-powf(2, -10 * time / 1) + 1)); } @@ -498,7 +498,7 @@ CCObject* CCEaseExponentialInOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseExponentialInOut::update(ccTime time) +void CCEaseExponentialInOut::update(float time) { time /= 0.5f; if (time < 1) @@ -560,7 +560,7 @@ CCObject* CCEaseSineIn::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseSineIn::update(ccTime time) +void CCEaseSineIn::update(float time) { m_pOther->update(-1 * cosf(time * (float)M_PI_2) + 1); } @@ -612,7 +612,7 @@ CCObject* CCEaseSineOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseSineOut::update(ccTime time) +void CCEaseSineOut::update(float time) { m_pOther->update(sinf(time * (float)M_PI_2)); } @@ -664,7 +664,7 @@ CCObject* CCEaseSineInOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseSineInOut::update(ccTime time) +void CCEaseSineInOut::update(float time) { m_pOther->update(-0.5f * (cosf((float)M_PI * time) - 1)); } @@ -817,9 +817,9 @@ CCObject* CCEaseElasticIn::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseElasticIn::update(ccTime time) +void CCEaseElasticIn::update(float time) { - ccTime newT = 0; + float newT = 0; if (time == 0 || time == 1) { newT = time; @@ -899,9 +899,9 @@ CCObject *CCEaseElasticOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseElasticOut::update(ccTime time) +void CCEaseElasticOut::update(float time) { - ccTime newT = 0; + float newT = 0; if (time == 0 || time == 1) { newT = time; @@ -981,9 +981,9 @@ CCObject* CCEaseElasticInOut::copyWithZone(CCZone *pZone) } -void CCEaseElasticInOut::update(ccTime time) +void CCEaseElasticInOut::update(float time) { - ccTime newT = 0; + float newT = 0; if (time == 0 || time == 1) { newT = time; @@ -996,7 +996,7 @@ void CCEaseElasticInOut::update(ccTime time) m_fPeriod = 0.3f * 1.5f; } - ccTime s = m_fPeriod / 4; + float s = m_fPeriod / 4; time = time - 1; if (time < 0) @@ -1059,7 +1059,7 @@ CCObject* CCEaseBounce::copyWithZone(CCZone *pZone) return pCopy; } -ccTime CCEaseBounce::bounceTime(ccTime time) +float CCEaseBounce::bounceTime(float time) { if (time < 1 / 2.75) { @@ -1127,9 +1127,9 @@ CCObject* CCEaseBounceIn::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseBounceIn::update(ccTime time) +void CCEaseBounceIn::update(float time) { - ccTime newT = 1 - bounceTime(1 - time); + float newT = 1 - bounceTime(1 - time); m_pOther->update(newT); } @@ -1180,9 +1180,9 @@ CCObject* CCEaseBounceOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseBounceOut::update(ccTime time) +void CCEaseBounceOut::update(float time) { - ccTime newT = bounceTime(time); + float newT = bounceTime(time); m_pOther->update(newT); } @@ -1233,9 +1233,9 @@ CCObject* CCEaseBounceInOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseBounceInOut::update(ccTime time) +void CCEaseBounceInOut::update(float time) { - ccTime newT = 0; + float newT = 0; if (time < 0.5f) { time = time * 2; @@ -1296,9 +1296,9 @@ CCObject* CCEaseBackIn::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseBackIn::update(ccTime time) +void CCEaseBackIn::update(float time) { - ccTime overshoot = 1.70158f; + float overshoot = 1.70158f; m_pOther->update(time * time * ((overshoot + 1) * time - overshoot)); } @@ -1349,9 +1349,9 @@ CCObject* CCEaseBackOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseBackOut::update(ccTime time) +void CCEaseBackOut::update(float time) { - ccTime overshoot = 1.70158f; + float overshoot = 1.70158f; time = time - 1; m_pOther->update(time * time * ((overshoot + 1) * time + overshoot) + 1); @@ -1404,9 +1404,9 @@ CCObject* CCEaseBackInOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseBackInOut::update(ccTime time) +void CCEaseBackInOut::update(float time) { - ccTime overshoot = 1.70158f * 1.525f; + float overshoot = 1.70158f * 1.525f; time = time * 2; if (time < 1) diff --git a/cocos2dx/actions/CCActionEase.h b/cocos2dx/actions/CCActionEase.h index ea2ab39621..05117c8691 100644 --- a/cocos2dx/actions/CCActionEase.h +++ b/cocos2dx/actions/CCActionEase.h @@ -47,7 +47,7 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); virtual void stop(void); - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); public: @@ -91,7 +91,7 @@ protected: class CC_DLL CCEaseIn : public CCEaseRateAction { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); public: @@ -105,7 +105,7 @@ public: class CC_DLL CCEaseOut : public CCEaseRateAction { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(); virtual CCObject* copyWithZone(CCZone* pZone); @@ -120,7 +120,7 @@ public: class CC_DLL CCEaseInOut : public CCEaseRateAction { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCObject* copyWithZone(CCZone* pZone); virtual CCActionInterval* reverse(void); @@ -135,7 +135,7 @@ public: class CC_DLL CCEaseExponentialIn : public CCActionEase { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); @@ -150,7 +150,7 @@ public: class CC_DLL CCEaseExponentialOut : public CCActionEase { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); @@ -166,7 +166,7 @@ public: class CC_DLL CCEaseExponentialInOut : public CCActionEase { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCObject* copyWithZone(CCZone* pZone); virtual CCActionInterval* reverse(); @@ -182,7 +182,7 @@ public: class CC_DLL CCEaseSineIn : public CCActionEase { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); @@ -197,7 +197,7 @@ public: class CC_DLL CCEaseSineOut : public CCActionEase { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); @@ -212,7 +212,7 @@ public: class CC_DLL CCEaseSineInOut : public CCActionEase { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCObject* copyWithZone(CCZone* pZone); virtual CCActionInterval* reverse(); @@ -259,7 +259,7 @@ protected: class CC_DLL CCEaseElasticIn : public CCEaseElastic { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); @@ -278,7 +278,7 @@ public: class CC_DLL CCEaseElasticOut : public CCEaseElastic { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); @@ -297,7 +297,7 @@ public: class CC_DLL CCEaseElasticInOut : public CCEaseElastic { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); @@ -315,7 +315,7 @@ public: class CC_DLL CCEaseBounce : public CCActionEase { public: - ccTime bounceTime(ccTime time); + float bounceTime(float time); virtual CCObject* copyWithZone(CCZone* pZone); virtual CCActionInterval* reverse(); @@ -332,7 +332,7 @@ public: class CC_DLL CCEaseBounceIn : public CCEaseBounce { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); @@ -349,7 +349,7 @@ public: class CC_DLL CCEaseBounceOut : public CCEaseBounce { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); @@ -366,7 +366,7 @@ public: class CC_DLL CCEaseBounceInOut : public CCEaseBounce { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCObject* copyWithZone(CCZone* pZone); virtual CCActionInterval* reverse(); @@ -383,7 +383,7 @@ public: class CC_DLL CCEaseBackIn : public CCActionEase { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); @@ -400,7 +400,7 @@ public: class CC_DLL CCEaseBackOut : public CCActionEase { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); @@ -417,7 +417,7 @@ public: class CC_DLL CCEaseBackInOut : public CCActionEase { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCObject* copyWithZone(CCZone* pZone); virtual CCActionInterval* reverse(); diff --git a/cocos2dx/actions/CCActionGrid.cpp b/cocos2dx/actions/CCActionGrid.cpp index 7ac4ba43b5..f70ff3050f 100644 --- a/cocos2dx/actions/CCActionGrid.cpp +++ b/cocos2dx/actions/CCActionGrid.cpp @@ -30,7 +30,7 @@ THE SOFTWARE. NS_CC_BEGIN // implementation of CCGridAction -CCGridAction* CCGridAction::actionWithSize(const ccGridSize& gridSize, ccTime duration) +CCGridAction* CCGridAction::actionWithSize(const ccGridSize& gridSize, float duration) { CCGridAction *pAction = new CCGridAction(); if (pAction) @@ -48,7 +48,7 @@ CCGridAction* CCGridAction::actionWithSize(const ccGridSize& gridSize, ccTime du return pAction; } -bool CCGridAction::initWithSize(const ccGridSize& gridSize, ccTime duration) +bool CCGridAction::initWithSize(const ccGridSize& gridSize, float duration) { if (CCActionInterval::initWithDuration(duration)) { @@ -181,7 +181,7 @@ void CCTiledGrid3DAction::setTile(const ccGridSize& pos, const ccQuad3& coords) // implementation CCAccelDeccelAmplitude -CCAccelDeccelAmplitude* CCAccelDeccelAmplitude::actionWithAction(CCAction *pAction, ccTime duration) +CCAccelDeccelAmplitude* CCAccelDeccelAmplitude::actionWithAction(CCAction *pAction, float duration) { CCAccelDeccelAmplitude *pRet = new CCAccelDeccelAmplitude(); if (pRet) @@ -199,7 +199,7 @@ CCAccelDeccelAmplitude* CCAccelDeccelAmplitude::actionWithAction(CCAction *pActi return pRet; } -bool CCAccelDeccelAmplitude::initWithAction(CCAction *pAction, ccTime duration) +bool CCAccelDeccelAmplitude::initWithAction(CCAction *pAction, float duration) { if (CCActionInterval::initWithDuration(duration)) { @@ -224,7 +224,7 @@ void CCAccelDeccelAmplitude::startWithTarget(CCNode *pTarget) m_pOther->startWithTarget(pTarget); } -void CCAccelDeccelAmplitude::update(ccTime time) +void CCAccelDeccelAmplitude::update(float time) { float f = time * 2; @@ -244,7 +244,7 @@ CCActionInterval* CCAccelDeccelAmplitude::reverse(void) // implementation of AccelAmplitude -CCAccelAmplitude* CCAccelAmplitude::actionWithAction(CCAction *pAction, ccTime duration) +CCAccelAmplitude* CCAccelAmplitude::actionWithAction(CCAction *pAction, float duration) { CCAccelAmplitude *pRet = new CCAccelAmplitude(); if (pRet) @@ -262,7 +262,7 @@ CCAccelAmplitude* CCAccelAmplitude::actionWithAction(CCAction *pAction, ccTime d return pRet; } -bool CCAccelAmplitude::initWithAction(CCAction *pAction, ccTime duration) +bool CCAccelAmplitude::initWithAction(CCAction *pAction, float duration) { if (CCActionInterval::initWithDuration(duration)) { @@ -287,7 +287,7 @@ void CCAccelAmplitude::startWithTarget(CCNode *pTarget) m_pOther->startWithTarget(pTarget); } -void CCAccelAmplitude::update(ccTime time) +void CCAccelAmplitude::update(float time) { ((CCAccelAmplitude*)(m_pOther))->setAmplitudeRate(powf(time, m_fRate)); m_pOther->update(time); @@ -300,7 +300,7 @@ CCActionInterval* CCAccelAmplitude::reverse(void) // DeccelAmplitude -CCDeccelAmplitude* CCDeccelAmplitude::actionWithAction(CCAction *pAction, ccTime duration) +CCDeccelAmplitude* CCDeccelAmplitude::actionWithAction(CCAction *pAction, float duration) { CCDeccelAmplitude *pRet = new CCDeccelAmplitude(); if (pRet) @@ -318,7 +318,7 @@ CCDeccelAmplitude* CCDeccelAmplitude::actionWithAction(CCAction *pAction, ccTime return pRet; } -bool CCDeccelAmplitude::initWithAction(CCAction *pAction, ccTime duration) +bool CCDeccelAmplitude::initWithAction(CCAction *pAction, float duration) { if (CCActionInterval::initWithDuration(duration)) { @@ -343,7 +343,7 @@ void CCDeccelAmplitude::startWithTarget(CCNode *pTarget) m_pOther->startWithTarget(pTarget); } -void CCDeccelAmplitude::update(ccTime time) +void CCDeccelAmplitude::update(float time) { ((CCDeccelAmplitude*)(m_pOther))->setAmplitudeRate(powf((1 - time), m_fRate)); m_pOther->update(time); diff --git a/cocos2dx/actions/CCActionGrid.h b/cocos2dx/actions/CCActionGrid.h index 3b6850d5ae..bf115c3a6f 100644 --- a/cocos2dx/actions/CCActionGrid.h +++ b/cocos2dx/actions/CCActionGrid.h @@ -41,13 +41,13 @@ public: virtual CCActionInterval* reverse(void); /** initializes the action with size and duration */ - virtual bool initWithSize(const ccGridSize& gridSize, ccTime duration); + virtual bool initWithSize(const ccGridSize& gridSize, float duration); /** returns the grid */ virtual CCGridBase* getGrid(void); public: /** creates the action with size and duration */ - static CCGridAction* actionWithSize(const ccGridSize& gridSize, ccTime duration); + static CCGridAction* actionWithSize(const ccGridSize& gridSize, float duration); protected: ccGridSize m_sGridSize; @@ -71,7 +71,7 @@ public: public: /** creates the action with size and duration */ - static CCGrid3DAction* actionWithSize(const ccGridSize& gridSize, ccTime duration); + static CCGrid3DAction* actionWithSize(const ccGridSize& gridSize, float duration); }; /** @brief Base class for CCTiledGrid3D actions */ @@ -90,7 +90,7 @@ public: public: /** creates the action with size and duration */ - static CCTiledGrid3DAction* actionWithSize(const ccGridSize& gridSize, ccTime duration); + static CCTiledGrid3DAction* actionWithSize(const ccGridSize& gridSize, float duration); }; /** @brief CCAccelDeccelAmplitude action */ @@ -99,10 +99,10 @@ class CC_DLL CCAccelDeccelAmplitude : public CCActionInterval public: virtual ~CCAccelDeccelAmplitude(void); /** initializes the action with an inner action that has the amplitude property, and a duration time */ - bool initWithAction(CCAction *pAction, ccTime duration); + bool initWithAction(CCAction *pAction, float duration); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); /** get amplitude rate */ @@ -112,7 +112,7 @@ public: public: /** creates the action with an inner action that has the amplitude property, and a duration time */ - static CCAccelDeccelAmplitude* actionWithAction(CCAction *pAction, ccTime duration); + static CCAccelDeccelAmplitude* actionWithAction(CCAction *pAction, float duration); protected: float m_fRate; @@ -125,7 +125,7 @@ class CC_DLL CCAccelAmplitude : public CCActionInterval public: ~CCAccelAmplitude(void); /** initializes the action with an inner action that has the amplitude property, and a duration time */ - bool initWithAction(CCAction *pAction, ccTime duration); + bool initWithAction(CCAction *pAction, float duration); /** get amplitude rate */ inline float getRate(void) { return m_fRate; } @@ -133,12 +133,12 @@ public: inline void setRate(float fRate) { m_fRate = fRate; } virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); public: /** creates the action with an inner action that has the amplitude property, and a duration time */ - static CCAccelAmplitude* actionWithAction(CCAction *pAction, ccTime duration); + static CCAccelAmplitude* actionWithAction(CCAction *pAction, float duration); protected: float m_fRate; @@ -151,7 +151,7 @@ class CC_DLL CCDeccelAmplitude : public CCActionInterval public: ~CCDeccelAmplitude(void); /** initializes the action with an inner action that has the amplitude property, and a duration time */ - bool initWithAction(CCAction *pAction, ccTime duration); + bool initWithAction(CCAction *pAction, float duration); /** get amplitude rate */ inline float getRate(void) { return m_fRate; } @@ -159,12 +159,12 @@ public: inline void setRate(float fRate) { m_fRate = fRate; } virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); public: /** creates the action with an inner action that has the amplitude property, and a duration time */ - static CCDeccelAmplitude* actionWithAction(CCAction *pAction, ccTime duration); + static CCDeccelAmplitude* actionWithAction(CCAction *pAction, float duration); protected: float m_fRate; diff --git a/cocos2dx/actions/CCActionGrid3D.cpp b/cocos2dx/actions/CCActionGrid3D.cpp index 578a712aef..1ba7efb92f 100644 --- a/cocos2dx/actions/CCActionGrid3D.cpp +++ b/cocos2dx/actions/CCActionGrid3D.cpp @@ -31,7 +31,7 @@ THE SOFTWARE. NS_CC_BEGIN // implementation of CCWaves3D -CCWaves3D* CCWaves3D::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration) +CCWaves3D* CCWaves3D::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) { CCWaves3D *pAction = new CCWaves3D(); @@ -50,7 +50,7 @@ CCWaves3D* CCWaves3D::actionWithWaves(int wav, float amp, const ccGridSize& grid return pAction; } -bool CCWaves3D::initWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration) +bool CCWaves3D::initWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) { if (CCGrid3DAction::initWithSize(gridSize, duration)) { @@ -88,7 +88,7 @@ CCObject* CCWaves3D::copyWithZone(CCZone *pZone) return pCopy; } -void CCWaves3D::update(ccTime time) +void CCWaves3D::update(float time) { int i, j; for (i = 0; i < m_sGridSize.x + 1; ++i) @@ -105,7 +105,7 @@ void CCWaves3D::update(ccTime time) // implementation of CCFlipX3D -CCFlipX3D* CCFlipX3D::actionWithDuration(ccTime duration) +CCFlipX3D* CCFlipX3D::actionWithDuration(float duration) { CCFlipX3D *pAction = new CCFlipX3D(); @@ -124,12 +124,12 @@ CCFlipX3D* CCFlipX3D::actionWithDuration(ccTime duration) return pAction; } -bool CCFlipX3D::initWithDuration(ccTime duration) +bool CCFlipX3D::initWithDuration(float duration) { return CCGrid3DAction::initWithSize(ccg(1, 1), duration); } -bool CCFlipX3D::initWithSize(const ccGridSize& gridSize, ccTime duration) +bool CCFlipX3D::initWithSize(const ccGridSize& gridSize, float duration) { if (gridSize.x != 1 || gridSize.y != 1) { @@ -165,7 +165,7 @@ CCObject* CCFlipX3D::copyWithZone(CCZone *pZone) return pCopy; } -void CCFlipX3D::update(ccTime time) +void CCFlipX3D::update(float time) { CCFloat angle = (CCFloat)M_PI * time; // 180 degrees CCFloat mz = sinf(angle); @@ -231,7 +231,7 @@ void CCFlipX3D::update(ccTime time) // implementation of FlipY3D -CCFlipY3D* CCFlipY3D::actionWithDuration(ccTime duration) +CCFlipY3D* CCFlipY3D::actionWithDuration(float duration) { CCFlipY3D *pAction = new CCFlipY3D(); @@ -273,7 +273,7 @@ CCObject* CCFlipY3D::copyWithZone(CCZone* pZone) return pCopy; } -void CCFlipY3D::update(ccTime time) +void CCFlipY3D::update(float time) { CCFloat angle = (CCFloat)M_PI * time; // 180 degrees CCFloat mz = sinf( angle ); @@ -340,7 +340,7 @@ void CCFlipY3D::update(ccTime time) // implementation of Lens3D -CCLens3D* CCLens3D::actionWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, ccTime duration) +CCLens3D* CCLens3D::actionWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration) { CCLens3D *pAction = new CCLens3D(); @@ -359,7 +359,7 @@ CCLens3D* CCLens3D::actionWithPosition(const CCPoint& pos, float r, const ccGrid return pAction; } -bool CCLens3D::initWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, ccTime duration) +bool CCLens3D::initWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration) { if (CCGrid3DAction::initWithSize(gridSize, duration)) { @@ -409,7 +409,7 @@ void CCLens3D::setPosition(const CCPoint& pos) } } -void CCLens3D::update(ccTime time) +void CCLens3D::update(float time) { CC_UNUSED_PARAM(time); if (m_bDirty) @@ -454,7 +454,7 @@ void CCLens3D::update(ccTime time) // implementation of Ripple3D -CCRipple3D* CCRipple3D::actionWithPosition(const CCPoint& pos, float r, int wav, float amp, const ccGridSize& gridSize, ccTime duration) +CCRipple3D* CCRipple3D::actionWithPosition(const CCPoint& pos, float r, int wav, float amp, const ccGridSize& gridSize, float duration) { CCRipple3D *pAction = new CCRipple3D(); @@ -473,7 +473,7 @@ CCRipple3D* CCRipple3D::actionWithPosition(const CCPoint& pos, float r, int wav, return pAction; } -bool CCRipple3D::initWithPosition(const CCPoint& pos, float r, int wav, float amp, const ccGridSize& gridSize, ccTime duration) +bool CCRipple3D::initWithPosition(const CCPoint& pos, float r, int wav, float amp, const ccGridSize& gridSize, float duration) { if (CCGrid3DAction::initWithSize(gridSize, duration)) { @@ -519,7 +519,7 @@ CCObject* CCRipple3D::copyWithZone(CCZone *pZone) return pCopy; } -void CCRipple3D::update(ccTime time) +void CCRipple3D::update(float time) { int i, j; @@ -545,7 +545,7 @@ void CCRipple3D::update(ccTime time) // implementation of Shaky3D -CCShaky3D* CCShaky3D::actionWithRange(int range, bool shakeZ, const ccGridSize& gridSize, ccTime duration) +CCShaky3D* CCShaky3D::actionWithRange(int range, bool shakeZ, const ccGridSize& gridSize, float duration) { CCShaky3D *pAction = new CCShaky3D(); @@ -564,7 +564,7 @@ CCShaky3D* CCShaky3D::actionWithRange(int range, bool shakeZ, const ccGridSize& return pAction; } -bool CCShaky3D::initWithRange(int range, bool shakeZ, const ccGridSize& gridSize, ccTime duration) +bool CCShaky3D::initWithRange(int range, bool shakeZ, const ccGridSize& gridSize, float duration) { if (CCGrid3DAction::initWithSize(gridSize, duration)) { @@ -600,7 +600,7 @@ CCObject* CCShaky3D::copyWithZone(CCZone *pZone) return pCopy; } -void CCShaky3D::update(ccTime time) +void CCShaky3D::update(float time) { CC_UNUSED_PARAM(time); int i, j; @@ -624,7 +624,7 @@ void CCShaky3D::update(ccTime time) // implementation of Liquid -CCLiquid* CCLiquid::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration) +CCLiquid* CCLiquid::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) { CCLiquid *pAction = new CCLiquid(); @@ -643,7 +643,7 @@ CCLiquid* CCLiquid::actionWithWaves(int wav, float amp, const ccGridSize& gridSi return pAction; } -bool CCLiquid::initWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration) +bool CCLiquid::initWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) { if (CCGrid3DAction::initWithSize(gridSize, duration)) { @@ -680,7 +680,7 @@ CCObject* CCLiquid::copyWithZone(CCZone *pZone) return pCopy; } -void CCLiquid::update(ccTime time) +void CCLiquid::update(float time) { int i, j; @@ -698,7 +698,7 @@ void CCLiquid::update(ccTime time) // implementation of Waves -CCWaves* CCWaves::actionWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, ccTime duration) +CCWaves* CCWaves::actionWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, float duration) { CCWaves *pAction = new CCWaves(); @@ -717,7 +717,7 @@ CCWaves* CCWaves::actionWithWaves(int wav, float amp, bool h, bool v, const ccGr return pAction; } -bool CCWaves::initWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, ccTime duration) +bool CCWaves::initWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, float duration) { if (CCGrid3DAction::initWithSize(gridSize, duration)) { @@ -756,7 +756,7 @@ CCObject* CCWaves::copyWithZone(CCZone *pZone) return pCopy; } -void CCWaves::update(ccTime time) +void CCWaves::update(float time) { int i, j; @@ -783,7 +783,7 @@ void CCWaves::update(ccTime time) // implementation of Twirl -CCTwirl* CCTwirl::actionWithPosition(CCPoint pos, int t, float amp, const ccGridSize& gridSize, ccTime duration) +CCTwirl* CCTwirl::actionWithPosition(CCPoint pos, int t, float amp, const ccGridSize& gridSize, float duration) { CCTwirl *pAction = new CCTwirl(); @@ -802,7 +802,7 @@ CCTwirl* CCTwirl::actionWithPosition(CCPoint pos, int t, float amp, const ccGrid return pAction; } -bool CCTwirl::initWithPosition(const CCPoint& pos, int t, float amp, const ccGridSize& gridSize, ccTime duration) +bool CCTwirl::initWithPosition(const CCPoint& pos, int t, float amp, const ccGridSize& gridSize, float duration) { if (CCGrid3DAction::initWithSize(gridSize, duration)) { @@ -848,7 +848,7 @@ CCObject* CCTwirl::copyWithZone(CCZone *pZone) return pCopy; } -void CCTwirl::update(ccTime time) +void CCTwirl::update(float time) { int i, j; CCPoint c = m_positionInPixels; diff --git a/cocos2dx/actions/CCActionGrid3D.h b/cocos2dx/actions/CCActionGrid3D.h index a3ac81f0f3..e96f72efbc 100644 --- a/cocos2dx/actions/CCActionGrid3D.h +++ b/cocos2dx/actions/CCActionGrid3D.h @@ -41,14 +41,14 @@ public: inline void setAmplitudeRate(float fAmplitudeRate) { m_fAmplitudeRate = fAmplitudeRate; } /** init the action */ - bool initWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration); + bool initWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** create the action */ - static CCWaves3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration); + static CCWaves3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); protected: int m_nWaves; @@ -61,26 +61,26 @@ class CC_DLL CCFlipX3D : public CCGrid3DAction { public: /** initializes the action with duration */ - bool initWithDuration(ccTime duration); - virtual bool initWithSize(const ccGridSize& gridSize, ccTime duration); + bool initWithDuration(float duration); + virtual bool initWithSize(const ccGridSize& gridSize, float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with duration */ - static CCFlipX3D* actionWithDuration(ccTime duration); + static CCFlipX3D* actionWithDuration(float duration); }; /** @brief CCFlipY3D action */ class CC_DLL CCFlipY3D : public CCFlipX3D { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCObject* copyWithZone(CCZone* pZone); public: /** creates the action with duration */ - static CCFlipY3D* actionWithDuration(ccTime duration); + static CCFlipY3D* actionWithDuration(float duration); }; /** @brief CCLens3D action */ @@ -96,13 +96,13 @@ public: void setPosition(const CCPoint& position); /** initializes the action with center position, radius, a grid size and duration */ - bool initWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, ccTime duration); + bool initWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with center position, radius, a grid size and duration */ - static CCLens3D* actionWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, ccTime duration); + static CCLens3D* actionWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration); protected: /* lens center position */ CCPoint m_position; @@ -133,14 +133,14 @@ public: /** initializes the action with radius, number of waves, amplitude, a grid size and duration */ bool initWithPosition(const CCPoint& pos, float r, int wav, float amp, - const ccGridSize& gridSize, ccTime duration); + const ccGridSize& gridSize, float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with radius, number of waves, amplitude, a grid size and duration */ static CCRipple3D* actionWithPosition(const CCPoint& pos, float r, int wav, float amp, - const ccGridSize& gridSize, ccTime duration); + const ccGridSize& gridSize, float duration); protected: /* center position */ CCPoint m_position; @@ -158,13 +158,13 @@ class CC_DLL CCShaky3D : public CCGrid3DAction { public: /** initializes the action with a range, shake Z vertices, a grid and duration */ - bool initWithRange(int range, bool shakeZ, const ccGridSize& gridSize, ccTime duration); + bool initWithRange(int range, bool shakeZ, const ccGridSize& gridSize, float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with a range, shake Z vertices, a grid and duration */ - static CCShaky3D* actionWithRange(int range, bool shakeZ, const ccGridSize& gridSize, ccTime duration); + static CCShaky3D* actionWithRange(int range, bool shakeZ, const ccGridSize& gridSize, float duration); protected: int m_nRandrange; @@ -182,13 +182,13 @@ public: inline void setAmplitudeRate(float fAmplitudeRate) { m_fAmplitudeRate = fAmplitudeRate; } /** initializes the action with amplitude, a grid and duration */ - bool initWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration); + bool initWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with amplitude, a grid and duration */ - static CCLiquid* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration); + static CCLiquid* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); protected: int m_nWaves; @@ -208,14 +208,14 @@ public: /** initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration */ bool initWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, - ccTime duration); + float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration */ static CCWaves* actionWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, - ccTime duration); + float duration); protected: int m_nWaves; float m_fAmplitude; @@ -241,14 +241,14 @@ public: /** initializes the action with center position, number of twirls, amplitude, a grid size and duration */ bool initWithPosition(const CCPoint& pos, int t, float amp, const ccGridSize& gridSize, - ccTime duration); + float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with center position, number of twirls, amplitude, a grid size and duration */ static CCTwirl* actionWithPosition(CCPoint pos, int t, float amp, const ccGridSize& gridSize, - ccTime duration); + float duration); protected: /* twirl center */ CCPoint m_position; diff --git a/cocos2dx/actions/CCActionInstant.cpp b/cocos2dx/actions/CCActionInstant.cpp index 2782314e4f..d003c0f10c 100644 --- a/cocos2dx/actions/CCActionInstant.cpp +++ b/cocos2dx/actions/CCActionInstant.cpp @@ -56,12 +56,12 @@ bool CCActionInstant::isDone() { return true; } -void CCActionInstant::step(ccTime dt) { +void CCActionInstant::step(float dt) { CC_UNUSED_PARAM(dt); update(1); } -void CCActionInstant::update(ccTime time) { +void CCActionInstant::update(float time) { CC_UNUSED_PARAM(time); // nothing } @@ -83,7 +83,7 @@ CCShow* CCShow::action() { return pRet; } -void CCShow::update(ccTime time) { +void CCShow::update(float time) { CC_UNUSED_PARAM(time); m_pTarget->setIsVisible(true); } @@ -121,7 +121,7 @@ CCHide * CCHide::action() { return pRet; } -void CCHide::update(ccTime time) { +void CCHide::update(float time) { CC_UNUSED_PARAM(time); m_pTarget->setIsVisible(false); } @@ -161,7 +161,7 @@ CCToggleVisibility * CCToggleVisibility::action() return pRet; } -void CCToggleVisibility::update(ccTime time) +void CCToggleVisibility::update(float time) { CC_UNUSED_PARAM(time); m_pTarget->setIsVisible(!m_pTarget->getIsVisible()); @@ -204,7 +204,7 @@ bool CCFlipX::initWithFlipX(bool x) { return true; } -void CCFlipX::update(ccTime time) { +void CCFlipX::update(float time) { CC_UNUSED_PARAM(time); ((CCSprite*) (m_pTarget))->setFlipX(m_bFlipX); } @@ -250,7 +250,7 @@ bool CCFlipY::initWithFlipY(bool y) { return true; } -void CCFlipY::update(ccTime time) { +void CCFlipY::update(float time) { CC_UNUSED_PARAM(time); ((CCSprite*) (m_pTarget))->setFlipY(m_bFlipY); } @@ -313,7 +313,7 @@ CCObject * CCPlace::copyWithZone(CCZone *pZone) { return pRet; } -void CCPlace::update(ccTime time) { +void CCPlace::update(float time) { CC_UNUSED_PARAM(time); m_pTarget->setPosition(m_tPosition); } @@ -370,7 +370,7 @@ CCObject * CCCallFunc::copyWithZone(CCZone *pZone) { return pRet; } -void CCCallFunc::update(ccTime time) { +void CCCallFunc::update(float time) { CC_UNUSED_PARAM(time); this->execute(); } diff --git a/cocos2dx/actions/CCActionInstant.h b/cocos2dx/actions/CCActionInstant.h index 87b0885965..1359e36ee7 100644 --- a/cocos2dx/actions/CCActionInstant.h +++ b/cocos2dx/actions/CCActionInstant.h @@ -44,8 +44,8 @@ public: // CCAction methods virtual CCObject* copyWithZone(CCZone *pZone); virtual bool isDone(void); - virtual void step(ccTime dt); - virtual void update(ccTime time); + virtual void step(float dt); + virtual void update(float time); //CCFiniteTimeAction method virtual CCFiniteTimeAction * reverse(void); }; @@ -58,7 +58,7 @@ public: CCShow(){} virtual ~CCShow(){} //super methods - virtual void update(ccTime time); + virtual void update(float time); virtual CCFiniteTimeAction * reverse(void); virtual CCObject* copyWithZone(CCZone *pZone); public: @@ -78,7 +78,7 @@ public: CCHide(){} virtual ~CCHide(){} //super methods - virtual void update(ccTime time); + virtual void update(float time); virtual CCFiniteTimeAction * reverse(void); virtual CCObject* copyWithZone(CCZone *pZone); public: @@ -95,7 +95,7 @@ public: CCToggleVisibility(){} virtual ~CCToggleVisibility(){} //super method - virtual void update(ccTime time); + virtual void update(float time); virtual CCObject* copyWithZone(CCZone *pZone); public: //override static method @@ -120,7 +120,7 @@ public: /** init the action */ bool initWithFlipX(bool x); //super methods - virtual void update(ccTime time); + virtual void update(float time); virtual CCFiniteTimeAction * reverse(void); virtual CCObject* copyWithZone(CCZone *pZone); @@ -145,7 +145,7 @@ public: /** init the action */ bool initWithFlipY(bool y); //super methods - virtual void update(ccTime time); + virtual void update(float time); virtual CCFiniteTimeAction * reverse(void); virtual CCObject* copyWithZone(CCZone *pZone); @@ -165,7 +165,7 @@ public: /** Initializes a Place action with a position */ bool initWithPosition(const CCPoint& pos); //super methods - virtual void update(ccTime time); + virtual void update(float time); virtual CCObject* copyWithZone(CCZone *pZone); protected: CCPoint m_tPosition; @@ -202,7 +202,7 @@ public: /** executes the callback */ virtual void execute(); //super methods - virtual void update(ccTime time); + virtual void update(float time); CCObject * copyWithZone(CCZone *pZone); inline CCObject* getTargetCallback() diff --git a/cocos2dx/actions/CCActionInterval.cpp b/cocos2dx/actions/CCActionInterval.cpp index 6c6861eda9..347b57e0ae 100644 --- a/cocos2dx/actions/CCActionInterval.cpp +++ b/cocos2dx/actions/CCActionInterval.cpp @@ -38,7 +38,7 @@ NS_CC_BEGIN // // IntervalAction // -CCActionInterval* CCActionInterval::actionWithDuration(ccTime d) +CCActionInterval* CCActionInterval::actionWithDuration(float d) { CCActionInterval *pAction = new CCActionInterval(); pAction->initWithDuration(d); @@ -47,7 +47,7 @@ CCActionInterval* CCActionInterval::actionWithDuration(ccTime d) return pAction; } -bool CCActionInterval::initWithDuration(ccTime d) +bool CCActionInterval::initWithDuration(float d) { m_fDuration = d; @@ -95,7 +95,7 @@ bool CCActionInterval::isDone(void) return m_elapsed >= m_fDuration; } -void CCActionInterval::step(ccTime dt) +void CCActionInterval::step(float dt) { if (m_bFirstTick) { @@ -180,7 +180,7 @@ CCFiniteTimeAction* CCSequence::actions(CCFiniteTimeAction *pAction1, ...) return pPrev; } -CCFiniteTimeAction* CCSequence::actionsWithArray(CCArray *actions) +CCFiniteTimeAction* CCSequence::actionWithArray(CCArray *actions) { CCFiniteTimeAction* prev = (CCFiniteTimeAction*)actions->objectAtIndex(0); @@ -197,7 +197,7 @@ bool CCSequence::initOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction * CCAssert(pActionOne != NULL, ""); CCAssert(pActionTwo != NULL, ""); - ccTime d = pActionOne->getDuration() + pActionTwo->getDuration(); + float d = pActionOne->getDuration() + pActionTwo->getDuration(); CCActionInterval::initWithDuration(d); m_pActions[0] = pActionOne; @@ -257,10 +257,10 @@ void CCSequence::stop(void) CCActionInterval::stop(); } -void CCSequence::update(ccTime t) +void CCSequence::update(float t) { int found = 0; - ccTime new_t = 0.0f; + float new_t = 0.0f; if( t < m_split ) { // action[0] @@ -324,7 +324,7 @@ CCRepeat* CCRepeat::actionWithAction(CCFiniteTimeAction *pAction, unsigned int t bool CCRepeat::initWithAction(CCFiniteTimeAction *pAction, unsigned int times) { - ccTime d = pAction->getDuration() * times; + float d = pAction->getDuration() * times; if (CCActionInterval::initWithDuration(d)) { @@ -391,7 +391,7 @@ void CCRepeat::stop(void) // issue #80. Instead of hooking step:, hook update: since it can be called by any // container action like CCRepeat, CCSequence, CCEase, etc.. -void CCRepeat::update(ccTime dt) +void CCRepeat::update(float dt) { if (dt >= m_fNextDt) { @@ -495,12 +495,12 @@ void CCRepeatForever::startWithTarget(CCNode* pTarget) m_pInnerAction->startWithTarget(pTarget); } -void CCRepeatForever::step(ccTime dt) +void CCRepeatForever::step(float dt) { m_pInnerAction->step(dt); if (m_pInnerAction->isDone()) { - ccTime diff = m_pInnerAction->getElapsed() - m_pInnerAction->getDuration(); + float diff = m_pInnerAction->getElapsed() - m_pInnerAction->getDuration(); m_pInnerAction->startWithTarget(m_pTarget); // to prevent jerk. issue #390, 1247 m_pInnerAction->step(0.0f); @@ -546,7 +546,7 @@ CCFiniteTimeAction* CCSpawn::actions(CCFiniteTimeAction *pAction1, ...) return pPrev; } -CCFiniteTimeAction* CCSpawn::actionsWithArray(CCArray *actions) +CCFiniteTimeAction* CCSpawn::actionWithArray(CCArray *actions) { CCFiniteTimeAction* prev = (CCFiniteTimeAction*)actions->objectAtIndex(0); @@ -574,8 +574,8 @@ bool CCSpawn:: initOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAct bool bRet = false; - ccTime d1 = pAction1->getDuration(); - ccTime d2 = pAction2->getDuration(); + float d1 = pAction1->getDuration(); + float d2 = pAction2->getDuration(); if (CCActionInterval::initWithDuration(MAX(d1, d2))) { @@ -646,7 +646,7 @@ void CCSpawn::stop(void) CCActionInterval::stop(); } -void CCSpawn::update(ccTime time) +void CCSpawn::update(float time) { if (m_pOne) { @@ -666,7 +666,7 @@ CCActionInterval* CCSpawn::reverse(void) // // RotateTo // -CCRotateTo* CCRotateTo::actionWithDuration(ccTime duration, float fDeltaAngle) +CCRotateTo* CCRotateTo::actionWithDuration(float duration, float fDeltaAngle) { CCRotateTo* pRotateTo = new CCRotateTo(); pRotateTo->initWithDuration(duration, fDeltaAngle); @@ -675,7 +675,7 @@ CCRotateTo* CCRotateTo::actionWithDuration(ccTime duration, float fDeltaAngle) return pRotateTo; } -bool CCRotateTo::initWithDuration(ccTime duration, float fDeltaAngle) +bool CCRotateTo::initWithDuration(float duration, float fDeltaAngle) { if (CCActionInterval::initWithDuration(duration)) { @@ -737,7 +737,7 @@ void CCRotateTo::startWithTarget(CCNode *pTarget) } } -void CCRotateTo::update(ccTime time) +void CCRotateTo::update(float time) { if (m_pTarget) { @@ -748,7 +748,7 @@ void CCRotateTo::update(ccTime time) // // RotateBy // -CCRotateBy* CCRotateBy::actionWithDuration(ccTime duration, float fDeltaAngle) +CCRotateBy* CCRotateBy::actionWithDuration(float duration, float fDeltaAngle) { CCRotateBy *pRotateBy = new CCRotateBy(); pRotateBy->initWithDuration(duration, fDeltaAngle); @@ -757,7 +757,7 @@ CCRotateBy* CCRotateBy::actionWithDuration(ccTime duration, float fDeltaAngle) return pRotateBy; } -bool CCRotateBy::initWithDuration(ccTime duration, float fDeltaAngle) +bool CCRotateBy::initWithDuration(float duration, float fDeltaAngle) { if (CCActionInterval::initWithDuration(duration)) { @@ -797,7 +797,7 @@ void CCRotateBy::startWithTarget(CCNode *pTarget) m_fStartAngle = pTarget->getRotation(); } -void CCRotateBy::update(ccTime time) +void CCRotateBy::update(float time) { // XXX: shall I add % 360 if (m_pTarget) @@ -814,7 +814,7 @@ CCActionInterval* CCRotateBy::reverse(void) // // MoveTo // -CCMoveTo* CCMoveTo::actionWithDuration(ccTime duration, const CCPoint& position) +CCMoveTo* CCMoveTo::actionWithDuration(float duration, const CCPoint& position) { CCMoveTo *pMoveTo = new CCMoveTo(); pMoveTo->initWithDuration(duration, position); @@ -823,7 +823,7 @@ CCMoveTo* CCMoveTo::actionWithDuration(ccTime duration, const CCPoint& position) return pMoveTo; } -bool CCMoveTo::initWithDuration(ccTime duration, const CCPoint& position) +bool CCMoveTo::initWithDuration(float duration, const CCPoint& position) { if (CCActionInterval::initWithDuration(duration)) { @@ -864,7 +864,7 @@ void CCMoveTo::startWithTarget(CCNode *pTarget) m_delta = ccpSub(m_endPosition, m_startPosition); } -void CCMoveTo::update(ccTime time) +void CCMoveTo::update(float time) { if (m_pTarget) { @@ -876,7 +876,7 @@ void CCMoveTo::update(ccTime time) // // MoveBy // -CCMoveBy* CCMoveBy::actionWithDuration(ccTime duration, const CCPoint& position) +CCMoveBy* CCMoveBy::actionWithDuration(float duration, const CCPoint& position) { CCMoveBy *pMoveBy = new CCMoveBy(); pMoveBy->initWithDuration(duration, position); @@ -885,7 +885,7 @@ CCMoveBy* CCMoveBy::actionWithDuration(ccTime duration, const CCPoint& position) return pMoveBy; } -bool CCMoveBy::initWithDuration(ccTime duration, const CCPoint& position) +bool CCMoveBy::initWithDuration(float duration, const CCPoint& position) { if (CCActionInterval::initWithDuration(duration)) { @@ -934,7 +934,7 @@ CCActionInterval* CCMoveBy::reverse(void) // // CCSkewTo // -CCSkewTo* CCSkewTo::actionWithDuration(ccTime t, float sx, float sy) +CCSkewTo* CCSkewTo::actionWithDuration(float t, float sx, float sy) { CCSkewTo *pSkewTo = new CCSkewTo(); if (pSkewTo) @@ -952,7 +952,7 @@ CCSkewTo* CCSkewTo::actionWithDuration(ccTime t, float sx, float sy) return pSkewTo; } -bool CCSkewTo::initWithDuration(ccTime t, float sx, float sy) +bool CCSkewTo::initWithDuration(float t, float sx, float sy) { bool bRet = false; @@ -1039,7 +1039,7 @@ void CCSkewTo::startWithTarget(CCNode *pTarget) } } -void CCSkewTo::update(ccTime t) +void CCSkewTo::update(float t) { m_pTarget->setSkewX(m_fStartSkewX + m_fDeltaX * t); m_pTarget->setSkewY(m_fStartSkewY + m_fDeltaY * t); @@ -1060,7 +1060,7 @@ CCSkewTo::CCSkewTo() // // CCSkewBy // -CCSkewBy* CCSkewBy::actionWithDuration(ccTime t, float sx, float sy) +CCSkewBy* CCSkewBy::actionWithDuration(float t, float sx, float sy) { CCSkewBy *pSkewBy = new CCSkewBy(); if (pSkewBy) @@ -1078,7 +1078,7 @@ CCSkewBy* CCSkewBy::actionWithDuration(ccTime t, float sx, float sy) return pSkewBy; } -bool CCSkewBy::initWithDuration(ccTime t, float deltaSkewX, float deltaSkewY) +bool CCSkewBy::initWithDuration(float t, float deltaSkewX, float deltaSkewY) { bool bRet = false; @@ -1110,7 +1110,7 @@ CCActionInterval* CCSkewBy::reverse() // // JumpBy // -CCJumpBy* CCJumpBy::actionWithDuration(ccTime duration, const CCPoint& position, ccTime height, unsigned int jumps) +CCJumpBy* CCJumpBy::actionWithDuration(float duration, const CCPoint& position, float height, unsigned int jumps) { CCJumpBy *pJumpBy = new CCJumpBy(); pJumpBy->initWithDuration(duration, position, height, jumps); @@ -1119,7 +1119,7 @@ CCJumpBy* CCJumpBy::actionWithDuration(ccTime duration, const CCPoint& position, return pJumpBy; } -bool CCJumpBy::initWithDuration(ccTime duration, const CCPoint& position, ccTime height, unsigned int jumps) +bool CCJumpBy::initWithDuration(float duration, const CCPoint& position, float height, unsigned int jumps) { if (CCActionInterval::initWithDuration(duration)) { @@ -1162,15 +1162,15 @@ void CCJumpBy::startWithTarget(CCNode *pTarget) m_startPosition = pTarget->getPosition(); } -void CCJumpBy::update(ccTime time) +void CCJumpBy::update(float time) { // parabolic jump (since v0.8.2) if (m_pTarget) { - ccTime frac = fmodf(time * m_nJumps, 1.0f); - ccTime y = m_height * 4 * frac * (1 - frac); + float frac = fmodf(time * m_nJumps, 1.0f); + float y = m_height * 4 * frac * (1 - frac); y += m_delta.y * time; - ccTime x = m_delta.x * time; + float x = m_delta.x * time; m_pTarget->setPosition(ccp(m_startPosition.x + x, m_startPosition.y + y)); } } @@ -1184,7 +1184,7 @@ CCActionInterval* CCJumpBy::reverse(void) // // JumpTo // -CCJumpTo* CCJumpTo::actionWithDuration(ccTime duration, const CCPoint& position, ccTime height, int jumps) +CCJumpTo* CCJumpTo::actionWithDuration(float duration, const CCPoint& position, float height, int jumps) { CCJumpTo *pJumpTo = new CCJumpTo(); pJumpTo->initWithDuration(duration, position, height, jumps); @@ -1226,7 +1226,7 @@ void CCJumpTo::startWithTarget(CCNode *pTarget) // ((1 - t) + t)3 = 1 // Expands to¡­ // (1 - t)3 + 3t(1-t)2 + 3t2(1 - t) + t3 = 1 -static inline float bezierat( float a, float b, float c, float d, ccTime t ) +static inline float bezierat( float a, float b, float c, float d, float t ) { return (powf(1-t,3) * a + 3*t*(powf(1-t,2))*b + @@ -1237,7 +1237,7 @@ static inline float bezierat( float a, float b, float c, float d, ccTime t ) // // BezierBy // -CCBezierBy* CCBezierBy::actionWithDuration(ccTime t, const ccBezierConfig& c) +CCBezierBy* CCBezierBy::actionWithDuration(float t, const ccBezierConfig& c) { CCBezierBy *pBezierBy = new CCBezierBy(); pBezierBy->initWithDuration(t, c); @@ -1246,7 +1246,7 @@ CCBezierBy* CCBezierBy::actionWithDuration(ccTime t, const ccBezierConfig& c) return pBezierBy; } -bool CCBezierBy::initWithDuration(ccTime t, const ccBezierConfig& c) +bool CCBezierBy::initWithDuration(float t, const ccBezierConfig& c) { if (CCActionInterval::initWithDuration(t)) { @@ -1286,7 +1286,7 @@ CCObject* CCBezierBy::copyWithZone(CCZone *pZone) return pCopy; } -void CCBezierBy::update(ccTime time) +void CCBezierBy::update(float time) { if (m_pTarget) { @@ -1321,7 +1321,7 @@ CCActionInterval* CCBezierBy::reverse(void) // // BezierTo // -CCBezierTo* CCBezierTo::actionWithDuration(ccTime t, const ccBezierConfig& c) +CCBezierTo* CCBezierTo::actionWithDuration(float t, const ccBezierConfig& c) { CCBezierTo *pBezierTo = new CCBezierTo(); pBezierTo->initWithDuration(t, c); @@ -1364,7 +1364,7 @@ void CCBezierTo::startWithTarget(CCNode *pTarget) // // ScaleTo // -CCScaleTo* CCScaleTo::actionWithDuration(ccTime duration, float s) +CCScaleTo* CCScaleTo::actionWithDuration(float duration, float s) { CCScaleTo *pScaleTo = new CCScaleTo(); pScaleTo->initWithDuration(duration, s); @@ -1373,7 +1373,7 @@ CCScaleTo* CCScaleTo::actionWithDuration(ccTime duration, float s) return pScaleTo; } -bool CCScaleTo::initWithDuration(ccTime duration, float s) +bool CCScaleTo::initWithDuration(float duration, float s) { if (CCActionInterval::initWithDuration(duration)) { @@ -1386,7 +1386,7 @@ bool CCScaleTo::initWithDuration(ccTime duration, float s) return false; } -CCScaleTo* CCScaleTo::actionWithDuration(ccTime duration, float sx, float sy) +CCScaleTo* CCScaleTo::actionWithDuration(float duration, float sx, float sy) { CCScaleTo *pScaleTo = new CCScaleTo(); pScaleTo->initWithDuration(duration, sx, sy); @@ -1395,7 +1395,7 @@ CCScaleTo* CCScaleTo::actionWithDuration(ccTime duration, float sx, float sy) return pScaleTo; } -bool CCScaleTo::initWithDuration(ccTime duration, float sx, float sy) +bool CCScaleTo::initWithDuration(float duration, float sx, float sy) { if (CCActionInterval::initWithDuration(duration)) { @@ -1441,7 +1441,7 @@ void CCScaleTo::startWithTarget(CCNode *pTarget) m_fDeltaY = m_fEndScaleY - m_fStartScaleY; } -void CCScaleTo::update(ccTime time) +void CCScaleTo::update(float time) { if (m_pTarget) { @@ -1453,7 +1453,7 @@ void CCScaleTo::update(ccTime time) // // ScaleBy // -CCScaleBy* CCScaleBy::actionWithDuration(ccTime duration, float s) +CCScaleBy* CCScaleBy::actionWithDuration(float duration, float s) { CCScaleBy *pScaleBy = new CCScaleBy(); pScaleBy->initWithDuration(duration, s); @@ -1462,7 +1462,7 @@ CCScaleBy* CCScaleBy::actionWithDuration(ccTime duration, float s) return pScaleBy; } -CCScaleBy* CCScaleBy::actionWithDuration(ccTime duration, float sx, float sy) +CCScaleBy* CCScaleBy::actionWithDuration(float duration, float sx, float sy) { CCScaleBy *pScaleBy = new CCScaleBy(); pScaleBy->initWithDuration(duration, sx, sy); @@ -1510,7 +1510,7 @@ CCActionInterval* CCScaleBy::reverse(void) // // Blink // -CCBlink* CCBlink::actionWithDuration(ccTime duration, unsigned int uBlinks) +CCBlink* CCBlink::actionWithDuration(float duration, unsigned int uBlinks) { CCBlink *pBlink = new CCBlink(); pBlink->initWithDuration(duration, uBlinks); @@ -1519,7 +1519,7 @@ CCBlink* CCBlink::actionWithDuration(ccTime duration, unsigned int uBlinks) return pBlink; } -bool CCBlink::initWithDuration(ccTime duration, unsigned int uBlinks) +bool CCBlink::initWithDuration(float duration, unsigned int uBlinks) { if (CCActionInterval::initWithDuration(duration)) { @@ -1554,12 +1554,12 @@ CCObject* CCBlink::copyWithZone(CCZone *pZone) return pCopy; } -void CCBlink::update(ccTime time) +void CCBlink::update(float time) { if (m_pTarget && ! isDone()) { - ccTime slice = 1.0f / m_nTimes; - ccTime m = fmodf(time, slice); + float slice = 1.0f / m_nTimes; + float m = fmodf(time, slice); m_pTarget->setIsVisible(m > slice / 2 ? true : false); } } @@ -1573,7 +1573,7 @@ CCActionInterval* CCBlink::reverse(void) // // FadeIn // -CCFadeIn* CCFadeIn::actionWithDuration(ccTime d) +CCFadeIn* CCFadeIn::actionWithDuration(float d) { CCFadeIn* pAction = new CCFadeIn(); @@ -1605,7 +1605,7 @@ CCObject* CCFadeIn::copyWithZone(CCZone *pZone) return pCopy; } -void CCFadeIn::update(ccTime time) +void CCFadeIn::update(float time) { CCRGBAProtocol *pRGBAProtocol = dynamic_cast(m_pTarget); if (pRGBAProtocol) @@ -1623,7 +1623,7 @@ CCActionInterval* CCFadeIn::reverse(void) // // FadeOut // -CCFadeOut* CCFadeOut::actionWithDuration(ccTime d) +CCFadeOut* CCFadeOut::actionWithDuration(float d) { CCFadeOut* pAction = new CCFadeOut(); @@ -1655,7 +1655,7 @@ CCObject* CCFadeOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCFadeOut::update(ccTime time) +void CCFadeOut::update(float time) { CCRGBAProtocol *pRGBAProtocol = dynamic_cast(m_pTarget); if (pRGBAProtocol) @@ -1673,7 +1673,7 @@ CCActionInterval* CCFadeOut::reverse(void) // // FadeTo // -CCFadeTo* CCFadeTo::actionWithDuration(ccTime duration, GLubyte opacity) +CCFadeTo* CCFadeTo::actionWithDuration(float duration, GLubyte opacity) { CCFadeTo *pFadeTo = new CCFadeTo(); pFadeTo->initWithDuration(duration, opacity); @@ -1682,7 +1682,7 @@ CCFadeTo* CCFadeTo::actionWithDuration(ccTime duration, GLubyte opacity) return pFadeTo; } -bool CCFadeTo::initWithDuration(ccTime duration, GLubyte opacity) +bool CCFadeTo::initWithDuration(float duration, GLubyte opacity) { if (CCActionInterval::initWithDuration(duration)) { @@ -1728,7 +1728,7 @@ void CCFadeTo::startWithTarget(CCNode *pTarget) /*m_fromOpacity = pTarget->getOpacity();*/ } -void CCFadeTo::update(ccTime time) +void CCFadeTo::update(float time) { CCRGBAProtocol *pRGBAProtocol = dynamic_cast(m_pTarget); if (pRGBAProtocol) @@ -1741,7 +1741,7 @@ void CCFadeTo::update(ccTime time) // // TintTo // -CCTintTo* CCTintTo::actionWithDuration(ccTime duration, GLubyte red, GLubyte green, GLubyte blue) +CCTintTo* CCTintTo::actionWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue) { CCTintTo *pTintTo = new CCTintTo(); pTintTo->initWithDuration(duration, red, green, blue); @@ -1750,7 +1750,7 @@ CCTintTo* CCTintTo::actionWithDuration(ccTime duration, GLubyte red, GLubyte gre return pTintTo; } -bool CCTintTo::initWithDuration(ccTime duration, GLubyte red, GLubyte green, GLubyte blue) +bool CCTintTo::initWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue) { if (CCActionInterval::initWithDuration(duration)) { @@ -1795,7 +1795,7 @@ void CCTintTo::startWithTarget(CCNode *pTarget) /*m_from = pTarget->getColor();*/ } -void CCTintTo::update(ccTime time) +void CCTintTo::update(float time) { CCRGBAProtocol *pRGBAProtocol = dynamic_cast(m_pTarget); if (pRGBAProtocol) @@ -1809,7 +1809,7 @@ void CCTintTo::update(ccTime time) // // TintBy // -CCTintBy* CCTintBy::actionWithDuration(ccTime duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue) +CCTintBy* CCTintBy::actionWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue) { CCTintBy *pTintBy = new CCTintBy(); pTintBy->initWithDuration(duration, deltaRed, deltaGreen, deltaBlue); @@ -1818,7 +1818,7 @@ CCTintBy* CCTintBy::actionWithDuration(ccTime duration, GLshort deltaRed, GLshor return pTintBy; } -bool CCTintBy::initWithDuration(ccTime duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue) +bool CCTintBy::initWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue) { if (CCActionInterval::initWithDuration(duration)) { @@ -1869,7 +1869,7 @@ void CCTintBy::startWithTarget(CCNode *pTarget) } } -void CCTintBy::update(ccTime time) +void CCTintBy::update(float time) { CCRGBAProtocol *pRGBAProtocol = dynamic_cast(m_pTarget); if (pRGBAProtocol) @@ -1888,7 +1888,7 @@ CCActionInterval* CCTintBy::reverse(void) // // DelayTime // -CCDelayTime* CCDelayTime::actionWithDuration(ccTime d) +CCDelayTime* CCDelayTime::actionWithDuration(float d) { CCDelayTime* pAction = new CCDelayTime(); @@ -1921,7 +1921,7 @@ CCObject* CCDelayTime::copyWithZone(CCZone *pZone) return pCopy; } -void CCDelayTime::update(ccTime time) +void CCDelayTime::update(float time) { CC_UNUSED_PARAM(time); return; @@ -2009,7 +2009,7 @@ void CCReverseTime::stop(void) CCActionInterval::stop(); } -void CCReverseTime::update(ccTime time) +void CCReverseTime::update(float time) { if (m_pOther) { @@ -2134,7 +2134,7 @@ void CCAnimate::stop(void) CCActionInterval::stop(); } -void CCAnimate::update(ccTime t) +void CCAnimate::update(float t) { // if t==1, ignore. Animation should finish with t==1 if( t < 1.0f ) { @@ -2269,7 +2269,7 @@ void CCTargetedAction::stop(void) m_pAction->stop(); } -void CCTargetedAction::update(ccTime time) +void CCTargetedAction::update(float time) { m_pAction->update(time); } diff --git a/cocos2dx/actions/CCActionInterval.h b/cocos2dx/actions/CCActionInterval.h index 9dff69f463..6107ca4c12 100644 --- a/cocos2dx/actions/CCActionInterval.h +++ b/cocos2dx/actions/CCActionInterval.h @@ -57,23 +57,23 @@ class CC_DLL CCActionInterval : public CCFiniteTimeAction { public: /** how many seconds had elapsed since the actions started to run. */ - inline ccTime getElapsed(void) { return m_elapsed; } + inline float getElapsed(void) { return m_elapsed; } /** initializes the action */ - bool initWithDuration(ccTime d); + bool initWithDuration(float d); /** returns true if the action has finished */ virtual bool isDone(void); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void step(ccTime dt); + virtual void step(float dt); virtual void startWithTarget(CCNode *pTarget); /** returns a reversed action */ virtual CCActionInterval* reverse(void); public: /** creates the action */ - static CCActionInterval* actionWithDuration(ccTime d); + static CCActionInterval* actionWithDuration(float d); public: //extension in CCGridAction @@ -81,7 +81,7 @@ public: CCFloat getAmplitudeRate(void); protected: - ccTime m_elapsed; + float m_elapsed; bool m_bFirstTick; }; @@ -98,20 +98,20 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); virtual void stop(void); - virtual void update(ccTime t); + virtual void update(float t); virtual CCActionInterval* reverse(void); public: /** helper constructor to create an array of sequenceable actions */ static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...); /** helper contructor to create an array of sequenceable actions given an array */ - static CCFiniteTimeAction* actionsWithArray(CCArray *actions); + static CCFiniteTimeAction* actionWithArray(CCArray *arrayOfActions); /** creates the action */ static CCSequence* actionOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo); protected: CCFiniteTimeAction *m_pActions[2]; - ccTime m_split; + float m_split; int m_last; }; @@ -129,7 +129,7 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); virtual void stop(void); - virtual void update(ccTime dt); + virtual void update(float dt); virtual bool isDone(void); virtual CCActionInterval* reverse(void); @@ -155,7 +155,7 @@ public: protected: unsigned int m_uTimes; unsigned int m_uTotal; - ccTime m_fNextDt; + float m_fNextDt; bool m_bActionInstant; /** Inner action */ CCFiniteTimeAction *m_pInnerAction; @@ -177,7 +177,7 @@ public: bool initWithAction(CCActionInterval *pAction); virtual CCObject* copyWithZone(CCZone *pZone); virtual void startWithTarget(CCNode* pTarget); - virtual void step(ccTime dt); + virtual void step(float dt); virtual bool isDone(void); virtual CCActionInterval* reverse(void); @@ -218,7 +218,7 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); virtual void stop(void); - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); public: @@ -226,7 +226,7 @@ public: static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...); /** helper contructor to create an array of spawned actions given an array */ - static CCFiniteTimeAction* actionsWithArray(CCArray *actions); + static CCFiniteTimeAction* actionWithArray(CCArray *arrayOfActions); /** creates the Spawn action */ static CCSpawn* actionOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2); @@ -244,15 +244,15 @@ class CC_DLL CCRotateTo : public CCActionInterval { public: /** initializes the action */ - bool initWithDuration(ccTime duration, float fDeltaAngle); + bool initWithDuration(float duration, float fDeltaAngle); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action */ - static CCRotateTo* actionWithDuration(ccTime duration, float fDeltaAngle); + static CCRotateTo* actionWithDuration(float duration, float fDeltaAngle); protected: float m_fDstAngle; @@ -266,16 +266,16 @@ class CC_DLL CCRotateBy : public CCActionInterval { public: /** initializes the action */ - bool initWithDuration(ccTime duration, float fDeltaAngle); + bool initWithDuration(float duration, float fDeltaAngle); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); public: /** creates the action */ - static CCRotateBy* actionWithDuration(ccTime duration, float fDeltaAngle); + static CCRotateBy* actionWithDuration(float duration, float fDeltaAngle); protected: float m_fAngle; @@ -288,15 +288,15 @@ class CC_DLL CCMoveTo : public CCActionInterval { public: /** initializes the action */ - bool initWithDuration(ccTime duration, const CCPoint& position); + bool initWithDuration(float duration, const CCPoint& position); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action */ - static CCMoveTo* actionWithDuration(ccTime duration, const CCPoint& position); + static CCMoveTo* actionWithDuration(float duration, const CCPoint& position); protected: CCPoint m_endPosition; @@ -312,7 +312,7 @@ class CC_DLL CCMoveBy : public CCMoveTo { public: /** initializes the action */ - bool initWithDuration(ccTime duration, const CCPoint& position); + bool initWithDuration(float duration, const CCPoint& position); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); @@ -320,7 +320,7 @@ public: public: /** creates the action */ - static CCMoveBy* actionWithDuration(ccTime duration, const CCPoint& position); + static CCMoveBy* actionWithDuration(float duration, const CCPoint& position); }; /** Skews a CCNode object to given angles by modifying it's skewX and skewY attributes @@ -330,13 +330,13 @@ class CC_DLL CCSkewTo : public CCActionInterval { public: CCSkewTo(); - virtual bool initWithDuration(ccTime t, float sx, float sy); + virtual bool initWithDuration(float t, float sx, float sy); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); public: - static CCSkewTo* actionWithDuration(ccTime t, float sx, float sy); + static CCSkewTo* actionWithDuration(float t, float sx, float sy); protected: float m_fSkewX; @@ -355,12 +355,12 @@ protected: class CC_DLL CCSkewBy : public CCSkewTo { public: - virtual bool initWithDuration(ccTime t, float sx, float sy); + virtual bool initWithDuration(float t, float sx, float sy); virtual void startWithTarget(CCNode *pTarget); virtual CCActionInterval* reverse(void); public: - static CCSkewBy* actionWithDuration(ccTime t, float deltaSkewX, float deltaSkewY); + static CCSkewBy* actionWithDuration(float t, float deltaSkewX, float deltaSkewY); }; /** @brief Moves a CCNode object simulating a parabolic jump movement by modifying it's position attribute. @@ -369,21 +369,21 @@ class CC_DLL CCJumpBy : public CCActionInterval { public: /** initializes the action */ - bool initWithDuration(ccTime duration, const CCPoint& position, ccTime height, unsigned int jumps); + bool initWithDuration(float duration, const CCPoint& position, float height, unsigned int jumps); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); public: /** creates the action */ - static CCJumpBy* actionWithDuration(ccTime duration, const CCPoint& position, ccTime height, unsigned int jumps); + static CCJumpBy* actionWithDuration(float duration, const CCPoint& position, float height, unsigned int jumps); protected: CCPoint m_startPosition; CCPoint m_delta; - ccTime m_height; + float m_height; unsigned int m_nJumps; }; @@ -397,7 +397,7 @@ public: public: /** creates the action */ - static CCJumpTo* actionWithDuration(ccTime duration, const CCPoint& position, ccTime height, int jumps); + static CCJumpTo* actionWithDuration(float duration, const CCPoint& position, float height, int jumps); }; /** @typedef bezier configuration structure @@ -417,16 +417,16 @@ class CC_DLL CCBezierBy : public CCActionInterval { public: /** initializes the action with a duration and a bezier configuration */ - bool initWithDuration(ccTime t, const ccBezierConfig& c); + bool initWithDuration(float t, const ccBezierConfig& c); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); public: /** creates the action with a duration and a bezier configuration */ - static CCBezierBy* actionWithDuration(ccTime t, const ccBezierConfig& c); + static CCBezierBy* actionWithDuration(float t, const ccBezierConfig& c); protected: ccBezierConfig m_sConfig; @@ -444,7 +444,7 @@ public: public: /** creates the action with a duration and a bezier configuration */ - static CCBezierTo* actionWithDuration(ccTime t, const ccBezierConfig& c); + static CCBezierTo* actionWithDuration(float t, const ccBezierConfig& c); }; /** @brief Scales a CCNode object to a zoom factor by modifying it's scale attribute. @@ -454,21 +454,21 @@ class CC_DLL CCScaleTo : public CCActionInterval { public: /** initializes the action with the same scale factor for X and Y */ - bool initWithDuration(ccTime duration, float s); + bool initWithDuration(float duration, float s); /** initializes the action with and X factor and a Y factor */ - bool initWithDuration(ccTime duration, float sx, float sy); + bool initWithDuration(float duration, float sx, float sy); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with the same scale factor for X and Y */ - static CCScaleTo* actionWithDuration(ccTime duration, float s); + static CCScaleTo* actionWithDuration(float duration, float s); /** creates the action with and X factor and a Y factor */ - static CCScaleTo* actionWithDuration(ccTime duration, float sx, float sy); + static CCScaleTo* actionWithDuration(float duration, float sx, float sy); protected: float m_fScaleX; float m_fScaleY; @@ -491,10 +491,10 @@ public: public: /** creates the action with the same scale factor for X and Y */ - static CCScaleBy* actionWithDuration(ccTime duration, float s); + static CCScaleBy* actionWithDuration(float duration, float s); /** creates the action with and X factor and a Y factor */ - static CCScaleBy* actionWithDuration(ccTime duration, float sx, float sy); + static CCScaleBy* actionWithDuration(float duration, float sx, float sy); }; /** @brief Blinks a CCNode object by modifying it's visible attribute @@ -503,15 +503,15 @@ class CC_DLL CCBlink : public CCActionInterval { public: /** initializes the action */ - bool initWithDuration(ccTime duration, unsigned int uBlinks); + bool initWithDuration(float duration, unsigned int uBlinks); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); public: /** creates the action */ - static CCBlink* actionWithDuration(ccTime duration, unsigned int uBlinks); + static CCBlink* actionWithDuration(float duration, unsigned int uBlinks); protected: unsigned int m_nTimes; }; @@ -522,13 +522,13 @@ protected: class CC_DLL CCFadeIn : public CCActionInterval { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); public: /** creates the action */ - static CCFadeIn* actionWithDuration(ccTime d); + static CCFadeIn* actionWithDuration(float d); }; /** @brief Fades Out an object that implements the CCRGBAProtocol protocol. It modifies the opacity from 255 to 0. @@ -537,13 +537,13 @@ public: class CC_DLL CCFadeOut : public CCActionInterval { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); public: /** creates the action */ - static CCFadeOut* actionWithDuration(ccTime d); + static CCFadeOut* actionWithDuration(float d); }; /** @brief Fades an object that implements the CCRGBAProtocol protocol. It modifies the opacity from the current value to a custom one. @@ -553,15 +553,15 @@ class CC_DLL CCFadeTo : public CCActionInterval { public: /** initializes the action with duration and opacity */ - bool initWithDuration(ccTime duration, GLubyte opacity); + bool initWithDuration(float duration, GLubyte opacity); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates an action with duration and opacity */ - static CCFadeTo* actionWithDuration(ccTime duration, GLubyte opacity); + static CCFadeTo* actionWithDuration(float duration, GLubyte opacity); protected: GLubyte m_toOpacity; @@ -576,15 +576,15 @@ class CC_DLL CCTintTo : public CCActionInterval { public: /** initializes the action with duration and color */ - bool initWithDuration(ccTime duration, GLubyte red, GLubyte green, GLubyte blue); + bool initWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates an action with duration and color */ - static CCTintTo* actionWithDuration(ccTime duration, GLubyte red, GLubyte green, GLubyte blue); + static CCTintTo* actionWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue); protected: ccColor3B m_to; @@ -598,16 +598,16 @@ class CC_DLL CCTintBy : public CCActionInterval { public: /** initializes the action with duration and color */ - bool initWithDuration(ccTime duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); + bool initWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); public: /** creates an action with duration and color */ - static CCTintBy* actionWithDuration(ccTime duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); + static CCTintBy* actionWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); protected: GLshort m_deltaR; @@ -624,13 +624,13 @@ protected: class CC_DLL CCDelayTime : public CCActionInterval { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); public: /** creates the action */ - static CCDelayTime* actionWithDuration(ccTime d); + static CCDelayTime* actionWithDuration(float d); }; /** @brief Executes an action in reverse order, from time=duration to time=0 @@ -652,7 +652,7 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); virtual void stop(void); - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); public: @@ -678,7 +678,7 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); virtual void stop(void); - virtual void update(ccTime t); + virtual void update(float t); virtual CCActionInterval* reverse(void); public: @@ -710,7 +710,7 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); virtual void stop(void); - virtual void update(ccTime time); + virtual void update(float time); /** This is the target that the action will be forced to run with */ CC_SYNTHESIZE_RETAIN(CCNode*, m_pForcedTarget, ForcedTarget); diff --git a/cocos2dx/actions/CCActionManager.cpp b/cocos2dx/actions/CCActionManager.cpp index 5c8b1c477d..f9d0f1b8ff 100644 --- a/cocos2dx/actions/CCActionManager.cpp +++ b/cocos2dx/actions/CCActionManager.cpp @@ -31,6 +31,7 @@ THE SOFTWARE. #include "ccMacros.h" #include "support/data_support/ccCArray.h" #include "support/data_support/uthash.h" +#include "CCSet.h" NS_CC_BEGIN // @@ -139,6 +140,32 @@ void CCActionManager::resumeTarget(CCObject *pTarget) } } +CCSet* CCActionManager::pauseAlllRunningActions() +{ + CCSet *idsWithActions = new CCSet(); + idsWithActions->autorelease(); + + for (tHashElement *element=m_pTargets; element != NULL; element = (tHashElement *)element->hh.next) + { + if (! element->paused) + { + element->paused = true; + idsWithActions->addObject(element->target); + } + } + + return idsWithActions; +} + +void CCActionManager::resumeTargets(cocos2d::CCSet *targetsToResume) +{ + CCSetIterator iter; + for (iter = targetsToResume->begin(); iter != targetsToResume->end(); ++iter) + { + resumeTarget(*iter); + } +} + // run void CCActionManager::addAction(CCAction *pAction, CCNode *pTarget, bool paused) @@ -309,7 +336,7 @@ unsigned int CCActionManager::numberOfRunningActionsInTarget(CCObject *pTarget) } // main loop -void CCActionManager::update(ccTime dt) +void CCActionManager::update(float dt) { for (tHashElement *elt = m_pTargets; elt != NULL; ) { diff --git a/cocos2dx/actions/CCActionManager.h b/cocos2dx/actions/CCActionManager.h index 24b9bcc3e9..1dbd038632 100644 --- a/cocos2dx/actions/CCActionManager.h +++ b/cocos2dx/actions/CCActionManager.h @@ -34,7 +34,7 @@ THE SOFTWARE. NS_CC_BEGIN -#define kCCActionManagerPriority 0 +class CCSet; struct _hashElement; /** @@ -98,6 +98,14 @@ public: /** Resumes the target. All queued actions will be resumed. */ void resumeTarget(CCObject *pTarget); + + /** Pauses all running actions, returning a list of targets whose actions were paused. + */ + CCSet* pauseAlllRunningActions(); + + /** Resume a set of targets (convenience function to reverse a pauseAllRunningActions call) + */ + void resumeTargets(CCSet *targetsToResume); protected: // declared in CCActionManager.m @@ -105,7 +113,7 @@ protected: void removeActionAtIndex(unsigned int uIndex, struct _hashElement *pElement); void deleteHashElement(struct _hashElement *pElement); void actionAllocWithHashElement(struct _hashElement *pElement); - void update(ccTime dt); + void update(float dt); protected: struct _hashElement *m_pTargets; diff --git a/cocos2dx/actions/CCActionPageTurn3D.cpp b/cocos2dx/actions/CCActionPageTurn3D.cpp index 4581153626..064f3cdf00 100644 --- a/cocos2dx/actions/CCActionPageTurn3D.cpp +++ b/cocos2dx/actions/CCActionPageTurn3D.cpp @@ -27,7 +27,7 @@ THE SOFTWARE. NS_CC_BEGIN -CCPageTurn3D* CCPageTurn3D::actionWithSize(const ccGridSize& gridSize, ccTime time) +CCPageTurn3D* CCPageTurn3D::actionWithSize(const ccGridSize& gridSize, float time) { CCPageTurn3D *pAction = new CCPageTurn3D(); @@ -50,7 +50,7 @@ CCPageTurn3D* CCPageTurn3D::actionWithSize(const ccGridSize& gridSize, ccTime ti * Update each tick * Time is the percentage of the way through the duration */ -void CCPageTurn3D::update(ccTime time) +void CCPageTurn3D::update(float time) { float tt = MAX(0, time - 0.25f); float deltaAy = (tt * tt * 500); diff --git a/cocos2dx/actions/CCActionPageTurn3D.h b/cocos2dx/actions/CCActionPageTurn3D.h index 2d00ce92df..7bdb78e9c7 100644 --- a/cocos2dx/actions/CCActionPageTurn3D.h +++ b/cocos2dx/actions/CCActionPageTurn3D.h @@ -40,11 +40,11 @@ NS_CC_BEGIN class CC_DLL CCPageTurn3D : public CCGrid3DAction { public: - virtual void update(ccTime time); + virtual void update(float time); public: /** create the action */ - static CCPageTurn3D* actionWithSize(const ccGridSize& gridSize, ccTime time); + static CCPageTurn3D* actionWithSize(const ccGridSize& gridSize, float time); }; NS_CC_END diff --git a/cocos2dx/actions/CCActionProgressTimer.cpp b/cocos2dx/actions/CCActionProgressTimer.cpp index fcdd62e527..6738ccceb9 100644 --- a/cocos2dx/actions/CCActionProgressTimer.cpp +++ b/cocos2dx/actions/CCActionProgressTimer.cpp @@ -32,7 +32,7 @@ NS_CC_BEGIN // implementation of CCProgressTo -CCProgressTo* CCProgressTo::actionWithDuration(ccTime duration, float fPercent) +CCProgressTo* CCProgressTo::actionWithDuration(float duration, float fPercent) { CCProgressTo *pProgressTo = new CCProgressTo(); pProgressTo->initWithDuration(duration, fPercent); @@ -41,7 +41,7 @@ CCProgressTo* CCProgressTo::actionWithDuration(ccTime duration, float fPercent) return pProgressTo; } -bool CCProgressTo::initWithDuration(ccTime duration, float fPercent) +bool CCProgressTo::initWithDuration(float duration, float fPercent) { if (CCActionInterval::initWithDuration(duration)) { @@ -89,14 +89,14 @@ void CCProgressTo::startWithTarget(CCNode *pTarget) } } -void CCProgressTo::update(ccTime time) +void CCProgressTo::update(float time) { ((kProgressTimerCast)(m_pTarget))->setPercentage(m_fFrom + (m_fTo - m_fFrom) * time); } // implementation of CCProgressFromTo -CCProgressFromTo* CCProgressFromTo::actionWithDuration(ccTime duration, float fFromPercentage, float fToPercentage) +CCProgressFromTo* CCProgressFromTo::actionWithDuration(float duration, float fFromPercentage, float fToPercentage) { CCProgressFromTo *pProgressFromTo = new CCProgressFromTo(); pProgressFromTo->initWithDuration(duration, fFromPercentage, fToPercentage); @@ -105,7 +105,7 @@ CCProgressFromTo* CCProgressFromTo::actionWithDuration(ccTime duration, float fF return pProgressFromTo; } -bool CCProgressFromTo::initWithDuration(ccTime duration, float fFromPercentage, float fToPercentage) +bool CCProgressFromTo::initWithDuration(float duration, float fFromPercentage, float fToPercentage) { if (CCActionInterval::initWithDuration(duration)) { @@ -151,7 +151,7 @@ void CCProgressFromTo::startWithTarget(CCNode *pTarget) CCActionInterval::startWithTarget(pTarget); } -void CCProgressFromTo::update(ccTime time) +void CCProgressFromTo::update(float time) { ((kProgressTimerCast)(m_pTarget))->setPercentage(m_fFrom + (m_fTo - m_fFrom) * time); } diff --git a/cocos2dx/actions/CCActionProgressTimer.h b/cocos2dx/actions/CCActionProgressTimer.h index e2aa1c6779..3ac86890c0 100644 --- a/cocos2dx/actions/CCActionProgressTimer.h +++ b/cocos2dx/actions/CCActionProgressTimer.h @@ -37,15 +37,15 @@ class CC_DLL CCProgressTo : public CCActionInterval { public: /** Initializes with a duration and a percent */ - bool initWithDuration(ccTime duration, float fPercent); + bool initWithDuration(float duration, float fPercent); virtual CCObject* copyWithZone(CCZone *pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); public: /** Creates and initializes with a duration and a percent */ - static CCProgressTo* actionWithDuration(ccTime duration, float fPercent); + static CCProgressTo* actionWithDuration(float duration, float fPercent); protected: float m_fTo; @@ -60,16 +60,16 @@ class CC_DLL CCProgressFromTo : public CCActionInterval { public: /** Initializes the action with a duration, a "from" percentage and a "to" percentage */ - bool initWithDuration(ccTime duration, float fFromPercentage, float fToPercentage); + bool initWithDuration(float duration, float fFromPercentage, float fToPercentage); virtual CCObject* copyWithZone(CCZone *pZone); virtual CCActionInterval* reverse(void); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); public: /** Creates and initializes the action with a duration, a "from" percentage and a "to" percentage */ - static CCProgressFromTo* actionWithDuration(ccTime duration, float fFromPercentage, float fToPercentage); + static CCProgressFromTo* actionWithDuration(float duration, float fFromPercentage, float fToPercentage); protected: float m_fTo; diff --git a/cocos2dx/actions/CCActionTiledGrid.cpp b/cocos2dx/actions/CCActionTiledGrid.cpp index 82060c0f7f..be2d7a2d98 100644 --- a/cocos2dx/actions/CCActionTiledGrid.cpp +++ b/cocos2dx/actions/CCActionTiledGrid.cpp @@ -41,7 +41,7 @@ struct Tile // implementation of ShakyTiles3D -CCShakyTiles3D* CCShakyTiles3D::actionWithRange(int nRange, bool bShakeZ,const ccGridSize& gridSize, ccTime duration) +CCShakyTiles3D* CCShakyTiles3D::actionWithRange(int nRange, bool bShakeZ,const ccGridSize& gridSize, float duration) { CCShakyTiles3D *pAction = new CCShakyTiles3D(); @@ -60,7 +60,7 @@ CCShakyTiles3D* CCShakyTiles3D::actionWithRange(int nRange, bool bShakeZ,const c return pAction; } -bool CCShakyTiles3D::initWithRange(int nRange, bool bShakeZ, const ccGridSize& gridSize, ccTime duration) +bool CCShakyTiles3D::initWithRange(int nRange, bool bShakeZ, const ccGridSize& gridSize, float duration) { if (CCTiledGrid3DAction::initWithSize(gridSize, duration)) { @@ -96,7 +96,7 @@ CCObject* CCShakyTiles3D::copyWithZone(CCZone *pZone) return pCopy; } -void CCShakyTiles3D::update(ccTime time) +void CCShakyTiles3D::update(float time) { CC_UNUSED_PARAM(time); int i, j; @@ -134,7 +134,7 @@ void CCShakyTiles3D::update(ccTime time) // implementation of CCShatteredTiles3D -CCShatteredTiles3D* CCShatteredTiles3D::actionWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize, ccTime duration) +CCShatteredTiles3D* CCShatteredTiles3D::actionWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize, float duration) { CCShatteredTiles3D *pAction = new CCShatteredTiles3D(); @@ -153,7 +153,7 @@ CCShatteredTiles3D* CCShatteredTiles3D::actionWithRange(int nRange, bool bShatte return pAction; } -bool CCShatteredTiles3D::initWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize, ccTime duration) +bool CCShatteredTiles3D::initWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize, float duration) { if (CCTiledGrid3DAction::initWithSize(gridSize, duration)) { @@ -190,7 +190,7 @@ CCObject* CCShatteredTiles3D::copyWithZone(CCZone *pZone) return pCopy; } -void CCShatteredTiles3D::update(ccTime time) +void CCShatteredTiles3D::update(float time) { CC_UNUSED_PARAM(time); int i, j; @@ -233,7 +233,7 @@ void CCShatteredTiles3D::update(ccTime time) // implementation of CCShuffleTiles -CCShuffleTiles* CCShuffleTiles::actionWithSeed(int s, const ccGridSize& gridSize, ccTime duration) +CCShuffleTiles* CCShuffleTiles::actionWithSeed(int s, const ccGridSize& gridSize, float duration) { CCShuffleTiles *pAction = new CCShuffleTiles(); @@ -252,7 +252,7 @@ CCShuffleTiles* CCShuffleTiles::actionWithSeed(int s, const ccGridSize& gridSize return pAction; } -bool CCShuffleTiles::initWithSeed(int s, const ccGridSize& gridSize, ccTime duration) +bool CCShuffleTiles::initWithSeed(int s, const ccGridSize& gridSize, float duration) { if (CCTiledGrid3DAction::initWithSize(gridSize, duration)) { @@ -378,7 +378,7 @@ void CCShuffleTiles::startWithTarget(CCNode *pTarget) } } -void CCShuffleTiles::update(ccTime time) +void CCShuffleTiles::update(float time) { int i, j; @@ -397,7 +397,7 @@ void CCShuffleTiles::update(ccTime time) // implementation of CCFadeOutTRTiles -CCFadeOutTRTiles* CCFadeOutTRTiles::actionWithSize(const ccGridSize& gridSize, ccTime time) +CCFadeOutTRTiles* CCFadeOutTRTiles::actionWithSize(const ccGridSize& gridSize, float time) { CCFadeOutTRTiles *pAction = new CCFadeOutTRTiles(); @@ -416,7 +416,7 @@ CCFadeOutTRTiles* CCFadeOutTRTiles::actionWithSize(const ccGridSize& gridSize, c return pAction; } -float CCFadeOutTRTiles::testFunc(const ccGridSize& pos, ccTime time) +float CCFadeOutTRTiles::testFunc(const ccGridSize& pos, float time) { CCPoint n = ccpMult(ccp((float)m_sGridSize.x, (float)m_sGridSize.y), time); if ((n.x + n.y) == 0.0f) @@ -459,7 +459,7 @@ void CCFadeOutTRTiles::transformTile(const ccGridSize& pos, float distance) setTile(pos, coords); } -void CCFadeOutTRTiles::update(ccTime time) +void CCFadeOutTRTiles::update(float time) { int i, j; @@ -485,7 +485,7 @@ void CCFadeOutTRTiles::update(ccTime time) } // implementation of CCFadeOutBLTiles -CCFadeOutBLTiles* CCFadeOutBLTiles::actionWithSize(const ccGridSize& gridSize, ccTime time) +CCFadeOutBLTiles* CCFadeOutBLTiles::actionWithSize(const ccGridSize& gridSize, float time) { CCFadeOutBLTiles *pAction = new CCFadeOutBLTiles(); @@ -504,7 +504,7 @@ CCFadeOutBLTiles* CCFadeOutBLTiles::actionWithSize(const ccGridSize& gridSize, c return pAction; } -float CCFadeOutBLTiles::testFunc(const ccGridSize& pos, ccTime time) +float CCFadeOutBLTiles::testFunc(const ccGridSize& pos, float time) { CCPoint n = ccpMult(ccp((float)m_sGridSize.x, (float)m_sGridSize.y), (1.0f - time)); if ((pos.x + pos.y) == 0) @@ -517,7 +517,7 @@ float CCFadeOutBLTiles::testFunc(const ccGridSize& pos, ccTime time) // implementation of CCFadeOutUpTiles -CCFadeOutUpTiles* CCFadeOutUpTiles::actionWithSize(const ccGridSize& gridSize, ccTime time) +CCFadeOutUpTiles* CCFadeOutUpTiles::actionWithSize(const ccGridSize& gridSize, float time) { CCFadeOutUpTiles *pAction = new CCFadeOutUpTiles(); @@ -536,7 +536,7 @@ CCFadeOutUpTiles* CCFadeOutUpTiles::actionWithSize(const ccGridSize& gridSize, c return pAction; } -float CCFadeOutUpTiles::testFunc(const ccGridSize& pos, ccTime time) +float CCFadeOutUpTiles::testFunc(const ccGridSize& pos, float time) { CCPoint n = ccpMult(ccp((float)m_sGridSize.x, (float)m_sGridSize.y), time); if (n.y == 0.0f) @@ -561,7 +561,7 @@ void CCFadeOutUpTiles::transformTile(const ccGridSize& pos, float distance) } // implementation of CCFadeOutDownTiles -CCFadeOutDownTiles* CCFadeOutDownTiles::actionWithSize(const ccGridSize& gridSize, ccTime time) +CCFadeOutDownTiles* CCFadeOutDownTiles::actionWithSize(const ccGridSize& gridSize, float time) { CCFadeOutDownTiles *pAction = new CCFadeOutDownTiles(); @@ -580,7 +580,7 @@ CCFadeOutDownTiles* CCFadeOutDownTiles::actionWithSize(const ccGridSize& gridSiz return pAction; } -float CCFadeOutDownTiles::testFunc(const ccGridSize& pos, ccTime time) +float CCFadeOutDownTiles::testFunc(const ccGridSize& pos, float time) { CCPoint n = ccpMult(ccp((float)m_sGridSize.x, (float)m_sGridSize.y), (1.0f - time)); if (pos.y == 0) @@ -592,7 +592,7 @@ float CCFadeOutDownTiles::testFunc(const ccGridSize& pos, ccTime time) } // implementation of TurnOffTiles -CCTurnOffTiles* CCTurnOffTiles::actionWithSize(const ccGridSize& size, ccTime d) +CCTurnOffTiles* CCTurnOffTiles::actionWithSize(const ccGridSize& size, float d) { CCTurnOffTiles* pAction = new CCTurnOffTiles(); if (pAction->initWithSize(size, d)) @@ -606,7 +606,7 @@ CCTurnOffTiles* CCTurnOffTiles::actionWithSize(const ccGridSize& size, ccTime d) return pAction; } -CCTurnOffTiles* CCTurnOffTiles::actionWithSeed(int s, const ccGridSize& gridSize, ccTime duration) +CCTurnOffTiles* CCTurnOffTiles::actionWithSeed(int s, const ccGridSize& gridSize, float duration) { CCTurnOffTiles *pAction = new CCTurnOffTiles(); @@ -625,7 +625,7 @@ CCTurnOffTiles* CCTurnOffTiles::actionWithSeed(int s, const ccGridSize& gridSize return pAction; } -bool CCTurnOffTiles::initWithSeed(int s, const ccGridSize& gridSize, ccTime duration) +bool CCTurnOffTiles::initWithSeed(int s, const ccGridSize& gridSize, float duration) { if (CCTiledGrid3DAction::initWithSize(gridSize, duration)) { @@ -712,7 +712,7 @@ void CCTurnOffTiles::startWithTarget(CCNode *pTarget) shuffle(m_pTilesOrder, m_nTilesCount); } -void CCTurnOffTiles::update(ccTime time) +void CCTurnOffTiles::update(float time) { unsigned int i, l, t; @@ -736,7 +736,7 @@ void CCTurnOffTiles::update(ccTime time) // implementation of CCWavesTiles3D -CCWavesTiles3D* CCWavesTiles3D::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration) +CCWavesTiles3D* CCWavesTiles3D::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) { CCWavesTiles3D *pAction = new CCWavesTiles3D(); @@ -755,7 +755,7 @@ CCWavesTiles3D* CCWavesTiles3D::actionWithWaves(int wav, float amp, const ccGrid return pAction; } -bool CCWavesTiles3D::initWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration) +bool CCWavesTiles3D::initWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) { if (CCTiledGrid3DAction::initWithSize(gridSize, duration)) { @@ -791,7 +791,7 @@ CCObject* CCWavesTiles3D::copyWithZone(CCZone *pZone) return pCopy; } -void CCWavesTiles3D::update(ccTime time) +void CCWavesTiles3D::update(float time) { int i, j; @@ -814,7 +814,7 @@ void CCWavesTiles3D::update(ccTime time) // implementation of CCJumpTiles3D -CCJumpTiles3D* CCJumpTiles3D::actionWithJumps(int j, float amp, const ccGridSize& gridSize, ccTime duration) +CCJumpTiles3D* CCJumpTiles3D::actionWithJumps(int j, float amp, const ccGridSize& gridSize, float duration) { CCJumpTiles3D *pAction = new CCJumpTiles3D(); @@ -833,7 +833,7 @@ CCJumpTiles3D* CCJumpTiles3D::actionWithJumps(int j, float amp, const ccGridSize return pAction; } -bool CCJumpTiles3D::initWithJumps(int j, float amp, const ccGridSize& gridSize, ccTime duration) +bool CCJumpTiles3D::initWithJumps(int j, float amp, const ccGridSize& gridSize, float duration) { if (CCTiledGrid3DAction::initWithSize(gridSize, duration)) { @@ -868,7 +868,7 @@ CCObject* CCJumpTiles3D::copyWithZone(CCZone *pZone) return pCopy; } -void CCJumpTiles3D::update(ccTime time) +void CCJumpTiles3D::update(float time) { int i, j; @@ -903,7 +903,7 @@ void CCJumpTiles3D::update(ccTime time) // implementation of CCSplitRows -CCSplitRows* CCSplitRows::actionWithRows(int nRows, ccTime duration) +CCSplitRows* CCSplitRows::actionWithRows(int nRows, float duration) { CCSplitRows *pAction = new CCSplitRows(); @@ -922,7 +922,7 @@ CCSplitRows* CCSplitRows::actionWithRows(int nRows, ccTime duration) return pAction; } -bool CCSplitRows::initWithRows(int nRows, ccTime duration) +bool CCSplitRows::initWithRows(int nRows, float duration) { m_nRows = nRows; @@ -957,7 +957,7 @@ void CCSplitRows::startWithTarget(CCNode *pTarget) m_winSize = CCDirector::sharedDirector()->getWinSizeInPixels(); } -void CCSplitRows::update(ccTime time) +void CCSplitRows::update(float time) { int j; @@ -982,7 +982,7 @@ void CCSplitRows::update(ccTime time) // implementation of CCSplitCols -CCSplitCols* CCSplitCols::actionWithCols(int nCols, ccTime duration) +CCSplitCols* CCSplitCols::actionWithCols(int nCols, float duration) { CCSplitCols *pAction = new CCSplitCols(); @@ -1001,7 +1001,7 @@ CCSplitCols* CCSplitCols::actionWithCols(int nCols, ccTime duration) return pAction; } -bool CCSplitCols::initWithCols(int nCols, ccTime duration) +bool CCSplitCols::initWithCols(int nCols, float duration) { m_nCols = nCols; return CCTiledGrid3DAction::initWithSize(ccg(nCols, 1), duration); @@ -1034,7 +1034,7 @@ void CCSplitCols::startWithTarget(CCNode *pTarget) m_winSize = CCDirector::sharedDirector()->getWinSizeInPixels(); } -void CCSplitCols::update(ccTime time) +void CCSplitCols::update(float time) { int i; diff --git a/cocos2dx/actions/CCActionTiledGrid.h b/cocos2dx/actions/CCActionTiledGrid.h index ebe5943f2d..93635638c6 100644 --- a/cocos2dx/actions/CCActionTiledGrid.h +++ b/cocos2dx/actions/CCActionTiledGrid.h @@ -34,15 +34,15 @@ class CC_DLL CCShakyTiles3D : public CCTiledGrid3DAction public: /** initializes the action with a range, whether or not to shake Z vertices, a grid size, and duration */ bool initWithRange(int nRange, bool bShakeZ, const ccGridSize& gridSize, - ccTime duration); + float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with a range, whether or not to shake Z vertices, a grid size, and duration */ static CCShakyTiles3D* actionWithRange(int nRange, bool bShakeZ, const ccGridSize& gridSize, - ccTime duration); + float duration); protected: int m_nRandrange; @@ -55,15 +55,15 @@ class CC_DLL CCShatteredTiles3D : public CCTiledGrid3DAction public: /** initializes the action with a range, whether or not to shatter Z vertices, a grid size and duration */ bool initWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize, - ccTime duration); + float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with a range, whether of not to shatter Z vertices, a grid size and duration */ static CCShatteredTiles3D* actionWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize, - ccTime duration); + float duration); protected: int m_nRandrange; @@ -80,18 +80,18 @@ class CC_DLL CCShuffleTiles : public CCTiledGrid3DAction public: ~CCShuffleTiles(void); /** initializes the action with a random seed, the grid size and the duration */ - bool initWithSeed(int s, const ccGridSize& gridSize, ccTime duration); + bool initWithSeed(int s, const ccGridSize& gridSize, float duration); void shuffle(int *pArray, unsigned int nLen); ccGridSize getDelta(const ccGridSize& pos); void placeTile(const ccGridSize& pos, Tile *t); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); virtual CCObject* copyWithZone(CCZone* pZone); public: /** creates the action with a random seed, the grid size and the duration */ - static CCShuffleTiles* actionWithSeed(int s, const ccGridSize& gridSize, ccTime duration); + static CCShuffleTiles* actionWithSeed(int s, const ccGridSize& gridSize, float duration); protected: int m_nSeed; @@ -106,15 +106,15 @@ protected: class CC_DLL CCFadeOutTRTiles : public CCTiledGrid3DAction { public: - virtual float testFunc(const ccGridSize& pos, ccTime time); + virtual float testFunc(const ccGridSize& pos, float time); void turnOnTile(const ccGridSize& pos); void turnOffTile(const ccGridSize& pos); virtual void transformTile(const ccGridSize& pos, float distance); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with the grid size and the duration */ - static CCFadeOutTRTiles* actionWithSize(const ccGridSize& gridSize, ccTime time); + static CCFadeOutTRTiles* actionWithSize(const ccGridSize& gridSize, float time); }; /** @brief CCFadeOutBLTiles action. @@ -123,11 +123,11 @@ public: class CC_DLL CCFadeOutBLTiles : public CCFadeOutTRTiles { public: - virtual float testFunc(const ccGridSize& pos, ccTime time); + virtual float testFunc(const ccGridSize& pos, float time); public: /** creates the action with the grid size and the duration */ - static CCFadeOutBLTiles* actionWithSize(const ccGridSize& gridSize, ccTime time); + static CCFadeOutBLTiles* actionWithSize(const ccGridSize& gridSize, float time); }; /** @brief CCFadeOutUpTiles action. @@ -136,12 +136,12 @@ public: class CC_DLL CCFadeOutUpTiles : public CCFadeOutTRTiles { public: - virtual float testFunc(const ccGridSize& pos, ccTime time); + virtual float testFunc(const ccGridSize& pos, float time); virtual void transformTile(const ccGridSize& pos, float distance); public: /** creates the action with the grid size and the duration */ - static CCFadeOutUpTiles* actionWithSize(const ccGridSize& gridSize, ccTime time); + static CCFadeOutUpTiles* actionWithSize(const ccGridSize& gridSize, float time); }; /** @brief CCFadeOutDownTiles action. @@ -150,11 +150,11 @@ public: class CC_DLL CCFadeOutDownTiles : public CCFadeOutUpTiles { public: - virtual float testFunc(const ccGridSize& pos, ccTime time); + virtual float testFunc(const ccGridSize& pos, float time); public: /** creates the action with the grid size and the duration */ - static CCFadeOutDownTiles* actionWithSize(const ccGridSize& gridSize, ccTime time); + static CCFadeOutDownTiles* actionWithSize(const ccGridSize& gridSize, float time); }; /** @brief CCTurnOffTiles action. @@ -165,20 +165,20 @@ class CC_DLL CCTurnOffTiles : public CCTiledGrid3DAction public: ~CCTurnOffTiles(void); /** initializes the action with a random seed, the grid size and the duration */ - bool initWithSeed(int s, const ccGridSize& gridSize, ccTime duration); + bool initWithSeed(int s, const ccGridSize& gridSize, float duration); void shuffle(int *pArray, unsigned int nLen); void turnOnTile(const ccGridSize& pos); void turnOffTile(const ccGridSize& pos); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with the grid size and the duration */ - static CCTurnOffTiles* actionWithSize(const ccGridSize& size, ccTime d); + static CCTurnOffTiles* actionWithSize(const ccGridSize& size, float d); /** creates the action with a random seed, the grid size and the duration */ - static CCTurnOffTiles* actionWithSeed(int s, const ccGridSize& gridSize, ccTime duration); + static CCTurnOffTiles* actionWithSeed(int s, const ccGridSize& gridSize, float duration); protected: int m_nSeed; @@ -199,14 +199,14 @@ public: inline void setAmplitudeRate(float fAmplitudeRate) { m_fAmplitudeRate = fAmplitudeRate; } /** initializes the action with a number of waves, the waves amplitude, the grid size and the duration */ - bool initWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration); + bool initWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with a number of waves, the waves amplitude, the grid size and the duration */ - static CCWavesTiles3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration); + static CCWavesTiles3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); protected: int m_nWaves; @@ -229,13 +229,13 @@ public: inline void setAmplitudeRate(float fAmplitudeRate) { m_fAmplitudeRate = fAmplitudeRate; } /** initializes the action with the number of jumps, the sin amplitude, the grid size and the duration */ - bool initWithJumps(int j, float amp, const ccGridSize& gridSize, ccTime duration); + bool initWithJumps(int j, float amp, const ccGridSize& gridSize, float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with the number of jumps, the sin amplitude, the grid size and the duration */ - static CCJumpTiles3D* actionWithJumps(int j, float amp, const ccGridSize& gridSize, ccTime duration); + static CCJumpTiles3D* actionWithJumps(int j, float amp, const ccGridSize& gridSize, float duration); protected: int m_nJumps; @@ -248,15 +248,15 @@ class CC_DLL CCSplitRows : public CCTiledGrid3DAction { public : /** initializes the action with the number of rows to split and the duration */ - bool initWithRows(int nRows, ccTime duration); + bool initWithRows(int nRows, float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); virtual void startWithTarget(CCNode *pTarget); public: /** creates the action with the number of rows to split and the duration */ - static CCSplitRows* actionWithRows(int nRows, ccTime duration); + static CCSplitRows* actionWithRows(int nRows, float duration); protected: int m_nRows; @@ -268,15 +268,15 @@ class CC_DLL CCSplitCols : public CCTiledGrid3DAction { public: /** initializes the action with the number of columns to split and the duration */ - bool initWithCols(int nCols, ccTime duration); + bool initWithCols(int nCols, float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); virtual void startWithTarget(CCNode *pTarget); public: /** creates the action with the number of columns to split and the duration */ - static CCSplitCols* actionWithCols(int nCols, ccTime duration); + static CCSplitCols* actionWithCols(int nCols, float duration); protected: int m_nCols; diff --git a/cocos2dx/actions/CCActionTween.cpp b/cocos2dx/actions/CCActionTween.cpp index b0c297569f..b5d57102fa 100644 --- a/cocos2dx/actions/CCActionTween.cpp +++ b/cocos2dx/actions/CCActionTween.cpp @@ -27,7 +27,7 @@ THE SOFTWARE. NS_CC_BEGIN -CCActionTween* CCActionTween::actionWithDuration(ccTime aDuration, const char* key, float from, float to) +CCActionTween* CCActionTween::actionWithDuration(float aDuration, const char* key, float from, float to) { CCActionTween* pRet = new CCActionTween(); if (pRet && pRet->initWithDuration(aDuration, key, from, to)) @@ -41,7 +41,7 @@ CCActionTween* CCActionTween::actionWithDuration(ccTime aDuration, const char* k return pRet; } -bool CCActionTween::initWithDuration(ccTime aDuration, const char* key, float from, float to) +bool CCActionTween::initWithDuration(float aDuration, const char* key, float from, float to) { if (CCActionInterval::initWithDuration(aDuration)) { @@ -61,7 +61,7 @@ void CCActionTween::startWithTarget(CCNode *pTarget) m_fDelta = m_fTo - m_fFrom; } -void CCActionTween::update(ccTime dt) +void CCActionTween::update(float dt) { dynamic_cast(m_pTarget)->updateTweenAction(m_fTo - m_fDelta * (1 - dt), m_strKey.c_str()); } diff --git a/cocos2dx/actions/CCActionTween.h b/cocos2dx/actions/CCActionTween.h index 36a58c63b1..77c85dcf63 100644 --- a/cocos2dx/actions/CCActionTween.h +++ b/cocos2dx/actions/CCActionTween.h @@ -58,13 +58,13 @@ class CCActionTween : public CCActionInterval { public: /** creates an initializes the action with the property name (key), and the from and to parameters. */ - static CCActionTween* actionWithDuration(ccTime aDuration, const char* key, float from, float to); + static CCActionTween* actionWithDuration(float aDuration, const char* key, float from, float to); /** initializes the action with the property name (key), and the from and to parameters. */ - bool initWithDuration(ccTime aDuration, const char* key, float from, float to); + bool initWithDuration(float aDuration, const char* key, float from, float to); void startWithTarget(CCNode *pTarget); - void update(ccTime dt); + void update(float dt); CCActionInterval* reverse(); std::string m_strKey; diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 870dd56578..40a6aa5886 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -923,12 +923,12 @@ void CCNode::schedule(SEL_SCHEDULE selector) this->schedule(selector, 0.0f, kCCRepeatForever, 0.0f); } -void CCNode::schedule(SEL_SCHEDULE selector, ccTime interval) +void CCNode::schedule(SEL_SCHEDULE selector, float interval) { this->schedule(selector, interval, kCCRepeatForever, 0.0f); } -void CCNode::schedule(SEL_SCHEDULE selector, ccTime interval, unsigned int repeat, ccTime delay) +void CCNode::schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay) { CCAssert( selector, "Argument must be non-nil"); CCAssert( interval >=0, "Argument must be positive"); @@ -936,7 +936,7 @@ void CCNode::schedule(SEL_SCHEDULE selector, ccTime interval, unsigned int repea m_pScheduler->scheduleSelector(selector, this, interval, !m_bIsRunning, repeat, delay); } -void CCNode::scheduleOnce(SEL_SCHEDULE selector, ccTime delay) +void CCNode::scheduleOnce(SEL_SCHEDULE selector, float delay) { this->schedule(selector, 0.0f, 0, delay); } diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index c83d3d01f3..7acf9a47b1 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -544,18 +544,18 @@ public: If the selector is already scheduled, then the interval parameter will be updated without scheduling it again. */ - void schedule(SEL_SCHEDULE selector, ccTime interval); + void schedule(SEL_SCHEDULE selector, float interval); /** repeat will execute the action repeat + 1 times, for a continues action use kCCRepeatForever delay is the amount of time the action will wait before execution */ - void schedule(SEL_SCHEDULE selector, ccTime interval, unsigned int repeat, ccTime delay); + void schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay); /** Schedules a selector that runs only once, with a delay of 0 or larger */ - void scheduleOnce(SEL_SCHEDULE selector, ccTime delay); + void scheduleOnce(SEL_SCHEDULE selector, float delay); /** unschedules a custom selector.*/ void unschedule(SEL_SCHEDULE selector); diff --git a/cocos2dx/cocoa/CCGeometry.h b/cocos2dx/cocoa/CCGeometry.h index efc227472a..e6eb7c9740 100644 --- a/cocos2dx/cocoa/CCGeometry.h +++ b/cocos2dx/cocoa/CCGeometry.h @@ -26,12 +26,13 @@ THE SOFTWARE. #define __CCGEMETRY_H__ #include "CCPlatformMacros.h" +#include "CCObject.h" NS_CC_BEGIN typedef float CCFloat; -class CC_DLL CCPoint +class CC_DLL CCPoint : public CCObject { public: float x; @@ -47,7 +48,7 @@ public: static bool CCPointEqualToPoint(const CCPoint& point1, const CCPoint& point2); }; -class CC_DLL CCSize +class CC_DLL CCSize : public CCObject { public: float width; @@ -63,7 +64,7 @@ public: static bool CCSizeEqualToSize(const CCSize& size1, const CCSize& size2); }; -class CC_DLL CCRect +class CC_DLL CCRect : public CCObject { public: CCPoint origin; diff --git a/cocos2dx/cocoa/CCObject.h b/cocos2dx/cocoa/CCObject.h index 47477c5d9f..d835652378 100644 --- a/cocos2dx/cocoa/CCObject.h +++ b/cocos2dx/cocoa/CCObject.h @@ -25,7 +25,6 @@ THE SOFTWARE. #ifndef __CCOBJECT_H__ #define __CCOBJECT_H__ -#include "ccTypes.h" #include "CCCommon.h" NS_CC_BEGIN @@ -66,13 +65,13 @@ public: unsigned int retainCount(void); virtual bool isEqual(const CCObject* pObject); - virtual void update(ccTime dt) {CC_UNUSED_PARAM(dt);}; + virtual void update(float dt) {CC_UNUSED_PARAM(dt);}; friend class CCAutoreleasePool; }; -typedef void (CCObject::*SEL_SCHEDULE)(ccTime); +typedef void (CCObject::*SEL_SCHEDULE)(float); typedef void (CCObject::*SEL_CallFunc)(); typedef void (CCObject::*SEL_CallFuncN)(CCNode*); typedef void (CCObject::*SEL_CallFuncND)(CCNode*, void*); diff --git a/cocos2dx/include/ccTypes.h b/cocos2dx/include/ccTypes.h index 952a87fd63..47a25fa9fd 100755 --- a/cocos2dx/include/ccTypes.h +++ b/cocos2dx/include/ccTypes.h @@ -321,11 +321,6 @@ typedef enum } ccResolutionType; -//! delta time type -//! if you want more resolution redefine it as a double -typedef float ccTime; -//typedef double ccTime; - typedef enum { CCTextAlignmentLeft, @@ -352,7 +347,7 @@ typedef struct _ccT2F_Quad typedef struct { ccT2F_Quad texCoords; - ccTime delay; + float delay; CCSize size; } ccAnimationFrameData; diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp index 98916eac98..3c1e527ef2 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp @@ -51,7 +51,7 @@ CCTransitionScene::~CCTransitionScene() m_pOutScene->release(); } -CCTransitionScene * CCTransitionScene::transitionWithDuration(ccTime t, CCScene *scene) +CCTransitionScene * CCTransitionScene::transitionWithDuration(float t, CCScene *scene) { CCTransitionScene * pScene = new CCTransitionScene(); if(pScene && pScene->initWithDuration(t,scene)) @@ -63,7 +63,7 @@ CCTransitionScene * CCTransitionScene::transitionWithDuration(ccTime t, CCScene return NULL; } -bool CCTransitionScene::initWithDuration(ccTime t, CCScene *scene) +bool CCTransitionScene::initWithDuration(float t, CCScene *scene) { CCAssert( scene != NULL, "Argument scene must be non-nil"); @@ -135,7 +135,7 @@ void CCTransitionScene::finish() } -void CCTransitionScene::setNewScene(ccTime dt) +void CCTransitionScene::setNewScene(float dt) { CC_UNUSED_PARAM(dt); // [self unschedule:_cmd]; @@ -197,7 +197,7 @@ CCTransitionSceneOriented::~CCTransitionSceneOriented() { } -CCTransitionSceneOriented * CCTransitionSceneOriented::transitionWithDuration(ccTime t, CCScene *scene, tOrientation orientation) +CCTransitionSceneOriented * CCTransitionSceneOriented::transitionWithDuration(float t, CCScene *scene, tOrientation orientation) { CCTransitionSceneOriented * pScene = new CCTransitionSceneOriented(); pScene->initWithDuration(t,scene,orientation); @@ -205,7 +205,7 @@ CCTransitionSceneOriented * CCTransitionSceneOriented::transitionWithDuration(cc return pScene; } -bool CCTransitionSceneOriented::initWithDuration(ccTime t, CCScene *scene, tOrientation orientation) +bool CCTransitionSceneOriented::initWithDuration(float t, CCScene *scene, tOrientation orientation) { if ( CCTransitionScene::initWithDuration(t, scene) ) { @@ -657,7 +657,7 @@ void CCTransitionFlipX::onEnter() m_pOutScene->runAction(outA); } -CCTransitionFlipX* CCTransitionFlipX::transitionWithDuration(ccTime t, CCScene* s, tOrientation o) +CCTransitionFlipX* CCTransitionFlipX::transitionWithDuration(float t, CCScene* s, tOrientation o) { CCTransitionFlipX* pScene = new CCTransitionFlipX(); pScene->initWithDuration(t, s, o); @@ -722,7 +722,7 @@ void CCTransitionFlipY::onEnter() } -CCTransitionFlipY* CCTransitionFlipY::transitionWithDuration(ccTime t, CCScene* s, tOrientation o) +CCTransitionFlipY* CCTransitionFlipY::transitionWithDuration(float t, CCScene* s, tOrientation o) { CCTransitionFlipY* pScene = new CCTransitionFlipY(); pScene->initWithDuration(t, s, o); @@ -786,7 +786,7 @@ void CCTransitionFlipAngular::onEnter() m_pOutScene->runAction(outA); } -CCTransitionFlipAngular* CCTransitionFlipAngular::transitionWithDuration(ccTime t, CCScene* s, tOrientation o) +CCTransitionFlipAngular* CCTransitionFlipAngular::transitionWithDuration(float t, CCScene* s, tOrientation o) { CCTransitionFlipAngular* pScene = new CCTransitionFlipAngular(); pScene->initWithDuration(t, s, o); @@ -859,7 +859,7 @@ void CCTransitionZoomFlipX::onEnter() m_pOutScene->runAction(outA); } -CCTransitionZoomFlipX* CCTransitionZoomFlipX::transitionWithDuration(ccTime t, CCScene* s, tOrientation o) +CCTransitionZoomFlipX* CCTransitionZoomFlipX::transitionWithDuration(float t, CCScene* s, tOrientation o) { CCTransitionZoomFlipX* pScene = new CCTransitionZoomFlipX(); pScene->initWithDuration(t, s, o); @@ -932,7 +932,7 @@ void CCTransitionZoomFlipY::onEnter() m_pOutScene->runAction(outA); } -CCTransitionZoomFlipY* CCTransitionZoomFlipY::transitionWithDuration(ccTime t, CCScene* s, tOrientation o) +CCTransitionZoomFlipY* CCTransitionZoomFlipY::transitionWithDuration(float t, CCScene* s, tOrientation o) { CCTransitionZoomFlipY* pScene = new CCTransitionZoomFlipY(); pScene->initWithDuration(t, s, o); @@ -1008,7 +1008,7 @@ void CCTransitionZoomFlipAngular::onEnter() m_pOutScene->runAction(outA); } -CCTransitionZoomFlipAngular* CCTransitionZoomFlipAngular::transitionWithDuration(ccTime t, CCScene* s, tOrientation o) +CCTransitionZoomFlipAngular* CCTransitionZoomFlipAngular::transitionWithDuration(float t, CCScene* s, tOrientation o) { CCTransitionZoomFlipAngular* pScene = new CCTransitionZoomFlipAngular(); pScene->initWithDuration(t, s, o); @@ -1028,7 +1028,7 @@ CCTransitionFade::~CCTransitionFade() } -CCTransitionFade * CCTransitionFade::transitionWithDuration(ccTime duration, CCScene *scene, const ccColor3B& color) +CCTransitionFade * CCTransitionFade::transitionWithDuration(float duration, CCScene *scene, const ccColor3B& color) { CCTransitionFade * pTransition = new CCTransitionFade(); pTransition->initWithDuration(duration, scene, color); @@ -1036,7 +1036,7 @@ CCTransitionFade * CCTransitionFade::transitionWithDuration(ccTime duration, CCS return pTransition; } -bool CCTransitionFade::initWithDuration(ccTime duration, CCScene *scene, const ccColor3B& color) +bool CCTransitionFade::initWithDuration(float duration, CCScene *scene, const ccColor3B& color) { if (CCTransitionScene::initWithDuration(duration, scene)) { @@ -1048,7 +1048,7 @@ bool CCTransitionFade::initWithDuration(ccTime duration, CCScene *scene, const c return true; } -bool CCTransitionFade::initWithDuration(ccTime t, CCScene *scene) +bool CCTransitionFade::initWithDuration(float t, CCScene *scene) { this->initWithDuration(t, scene, ccBLACK); return true; @@ -1177,7 +1177,7 @@ void CCTransitionCrossFade::onExit() CCTransitionScene::onExit(); } -CCTransitionCrossFade* CCTransitionCrossFade::transitionWithDuration(ccTime d, CCScene* s) +CCTransitionCrossFade* CCTransitionCrossFade::transitionWithDuration(float d, CCScene* s) { CCTransitionCrossFade* Transition = new CCTransitionCrossFade(); Transition->initWithDuration(d, s); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h index 7e5b84be5d..14fb22b473 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h @@ -28,6 +28,7 @@ THE SOFTWARE. #define __CCTRANSITION_H__ #include "CCScene.h" +#include "ccTypes.h" NS_CC_BEGIN @@ -35,10 +36,10 @@ NS_CC_BEGIN //c/c++ don't support object creation of using class name //so, all classes need creation method. #define DECLEAR_TRANSITIONWITHDURATION(_Type)\ - static _Type* transitionWithDuration(ccTime t, CCScene* scene); + static _Type* transitionWithDuration(float t, CCScene* scene); #define IMPLEMENT_TRANSITIONWITHDURATION(_Type)\ - _Type* _Type::transitionWithDuration(ccTime t, CCScene* scene)\ + _Type* _Type::transitionWithDuration(float t, CCScene* scene)\ {\ _Type* pScene = new _Type();\ if(pScene && pScene->initWithDuration(t, scene)){\ @@ -85,7 +86,7 @@ class CC_DLL CCTransitionScene : public CCScene protected: CCScene * m_pInScene; CCScene * m_pOutScene; - ccTime m_fDuration; + float m_fDuration; bool m_bIsInSceneOnTop; bool m_bIsSendCleanupToScene; @@ -99,10 +100,10 @@ public: virtual void cleanup(); /** creates a base transition with duration and incoming scene */ - static CCTransitionScene * transitionWithDuration(ccTime t, CCScene *scene); + static CCTransitionScene * transitionWithDuration(float t, CCScene *scene); /** initializes a transition with duration and incoming scene */ - virtual bool initWithDuration(ccTime t,CCScene* scene); + virtual bool initWithDuration(float t,CCScene* scene); /** called after the transition finishes */ void finish(void); @@ -113,7 +114,7 @@ public: protected: virtual void sceneOrder(); private: - void setNewScene(ccTime dt); + void setNewScene(float dt); }; @@ -130,9 +131,9 @@ public: virtual ~CCTransitionSceneOriented(); /** creates a base transition with duration and incoming scene */ - static CCTransitionSceneOriented * transitionWithDuration(ccTime t,CCScene* scene, tOrientation orientation); + static CCTransitionSceneOriented * transitionWithDuration(float t,CCScene* scene, tOrientation orientation); /** initializes a transition with duration and incoming scene */ - virtual bool initWithDuration(ccTime t,CCScene* scene,tOrientation orientation); + virtual bool initWithDuration(float t,CCScene* scene,tOrientation orientation); }; /** @brief CCTransitionRotoZoom: @@ -327,7 +328,7 @@ public: virtual void onEnter(); - static CCTransitionFlipX* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionFlipX* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; /** @brief CCTransitionFlipY: @@ -342,7 +343,7 @@ public: virtual void onEnter(); - static CCTransitionFlipY* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationUpOver); + static CCTransitionFlipY* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationUpOver); }; /** @brief CCTransitionFlipAngular: @@ -357,7 +358,7 @@ public: virtual void onEnter(); - static CCTransitionFlipAngular* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionFlipAngular* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; /** @brief CCTransitionZoomFlipX: @@ -372,7 +373,7 @@ public: virtual void onEnter(); - static CCTransitionZoomFlipX* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionZoomFlipX* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; /** @brief CCTransitionZoomFlipY: @@ -387,7 +388,7 @@ public: virtual void onEnter(); - static CCTransitionZoomFlipY* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationUpOver); + static CCTransitionZoomFlipY* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationUpOver); }; /** @brief CCTransitionZoomFlipAngular: @@ -402,7 +403,7 @@ public: virtual void onEnter(); - static CCTransitionZoomFlipAngular* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionZoomFlipAngular* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; /** @brief CCTransitionFade: @@ -421,11 +422,11 @@ public: /** creates the transition with a duration and with an RGB color * Example: FadeTransition::transitionWithDuration(2, scene, ccc3(255,0,0); // red color */ - static CCTransitionFade* transitionWithDuration(ccTime duration,CCScene* scene, const ccColor3B& color = ccBLACK); + static CCTransitionFade* transitionWithDuration(float duration,CCScene* scene, const ccColor3B& color = ccBLACK); /** initializes the transition with a duration and with an RGB color */ - virtual bool initWithDuration(ccTime t, CCScene*scene ,const ccColor3B& color); + virtual bool initWithDuration(float t, CCScene*scene ,const ccColor3B& color); - virtual bool initWithDuration(ccTime t,CCScene* scene); + virtual bool initWithDuration(float t,CCScene* scene); virtual void onEnter(); virtual void onExit(); }; diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp index ef83273d91..ef1f5f6d8f 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp @@ -41,7 +41,7 @@ CCTransitionPageTurn::~CCTransitionPageTurn() } /** creates a base transition with duration and incoming scene */ -CCTransitionPageTurn * CCTransitionPageTurn::transitionWithDuration(ccTime t, CCScene *scene, bool backwards) +CCTransitionPageTurn * CCTransitionPageTurn::transitionWithDuration(float t, CCScene *scene, bool backwards) { CCTransitionPageTurn * pTransition = new CCTransitionPageTurn(); pTransition->initWithDuration(t,scene,backwards); @@ -50,7 +50,7 @@ CCTransitionPageTurn * CCTransitionPageTurn::transitionWithDuration(ccTime t, CC } /** initializes a transition with duration and incoming scene */ -bool CCTransitionPageTurn::initWithDuration(ccTime t, CCScene *scene, bool backwards) +bool CCTransitionPageTurn::initWithDuration(float t, CCScene *scene, bool backwards) { // XXX: needed before [super init] m_bBack = backwards; diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h index d9088e4f6d..02fd2c19f2 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h @@ -55,14 +55,14 @@ public: * If back is true then the effect is reversed to appear as if the incoming * scene is being turned from left over the outgoing scene. */ - static CCTransitionPageTurn* transitionWithDuration(ccTime t,CCScene* scene,bool backwards); + static CCTransitionPageTurn* transitionWithDuration(float t,CCScene* scene,bool backwards); /** * Creates a base transition with duration and incoming scene. * If back is true then the effect is reversed to appear as if the incoming * scene is being turned from left over the outgoing scene. */ - virtual bool initWithDuration(ccTime t,CCScene* scene,bool backwards); + virtual bool initWithDuration(float t,CCScene* scene,bool backwards); CCActionInterval* actionWithSize(const ccGridSize& vector); diff --git a/cocos2dx/misc_nodes/CCMotionStreak.cpp b/cocos2dx/misc_nodes/CCMotionStreak.cpp index b07cf806bd..b626031362 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.cpp +++ b/cocos2dx/misc_nodes/CCMotionStreak.cpp @@ -207,7 +207,7 @@ bool CCMotionStreak::getIsOpacityModifyRGB(void) return false; } -void CCMotionStreak::update(ccTime delta) +void CCMotionStreak::update(float delta) { delta *= m_fFadeDelta; diff --git a/cocos2dx/misc_nodes/CCMotionStreak.h b/cocos2dx/misc_nodes/CCMotionStreak.h index 98d956d669..836a14b53a 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.h +++ b/cocos2dx/misc_nodes/CCMotionStreak.h @@ -60,7 +60,7 @@ public: /** Override super methods */ virtual void setPosition(const CCPoint& position); virtual void draw(); - virtual void update(ccTime delta); + virtual void update(float delta); /* Implement interfaces */ virtual CCTexture2D* getTexture(void); diff --git a/cocos2dx/particle_nodes/CCParticleSystem.cpp b/cocos2dx/particle_nodes/CCParticleSystem.cpp index b764005d4b..f237626751 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystem.cpp @@ -534,7 +534,7 @@ bool CCParticleSystem::isFull() } // ParticleSystem - MainLoop -void CCParticleSystem::update(ccTime dt) +void CCParticleSystem::update(float dt) { CC_PROFILER_START_CATEGORY(kCCProfilerCategoryParticles , "CCParticleSystem - update"); diff --git a/cocos2dx/particle_nodes/CCParticleSystem.h b/cocos2dx/particle_nodes/CCParticleSystem.h index 04bbd5dcc8..11d1f63c16 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.h +++ b/cocos2dx/particle_nodes/CCParticleSystem.h @@ -99,7 +99,7 @@ typedef struct sCCParticle { float rotation; float deltaRotation; - ccTime timeToLive; + float timeToLive; unsigned int atlasIndex; @@ -389,7 +389,7 @@ public: //! should be overriden by subclasses virtual void postStep(); - virtual void update(ccTime dt); + virtual void update(float dt); virtual void updateWithNoTime(void); }; diff --git a/cocos2dx/script_support/CCScriptSupport.cpp b/cocos2dx/script_support/CCScriptSupport.cpp index 040f40e162..957c380de3 100644 --- a/cocos2dx/script_support/CCScriptSupport.cpp +++ b/cocos2dx/script_support/CCScriptSupport.cpp @@ -27,7 +27,7 @@ THE SOFTWARE. NS_CC_BEGIN -CCSchedulerScriptHandlerEntry* CCSchedulerScriptHandlerEntry::entryWithHandler(int nHandler, ccTime fInterval, bool bPaused) +CCSchedulerScriptHandlerEntry* CCSchedulerScriptHandlerEntry::entryWithHandler(int nHandler, float fInterval, bool bPaused) { CCSchedulerScriptHandlerEntry* pEntry = new CCSchedulerScriptHandlerEntry(); pEntry->initWithHandler(nHandler, fInterval, bPaused); @@ -35,9 +35,9 @@ CCSchedulerScriptHandlerEntry* CCSchedulerScriptHandlerEntry::entryWithHandler(i return pEntry; } -bool CCSchedulerScriptHandlerEntry::initWithHandler(int nHandler, ccTime fInterval, bool bPaused) +bool CCSchedulerScriptHandlerEntry::initWithHandler(int nHandler, float fInterval, bool bPaused) { - m_pTimer = new CCTimer(); + m_pTimer = new floatr(); m_pTimer->initWithScriptHandler(nHandler, fInterval); m_pTimer->autorelease(); m_pTimer->retain(); diff --git a/cocos2dx/script_support/CCScriptSupport.h b/cocos2dx/script_support/CCScriptSupport.h index 4679b9f216..213e527ef2 100644 --- a/cocos2dx/script_support/CCScriptSupport.h +++ b/cocos2dx/script_support/CCScriptSupport.h @@ -33,17 +33,17 @@ typedef struct lua_State lua_State; NS_CC_BEGIN -class CCTimer; +class floatr; // Lua support for CCScheduler class CCSchedulerScriptHandlerEntry : public CCObject { public: // nHandler return by tolua_ref_function(), called from LuaCocos2d.cpp - static CCSchedulerScriptHandlerEntry* entryWithHandler(int nHandler, ccTime fInterval, bool bPaused); + static CCSchedulerScriptHandlerEntry* entryWithHandler(int nHandler, float fInterval, bool bPaused); ~CCSchedulerScriptHandlerEntry(void); - inline cocos2d::CCTimer* getTimer(void) { + inline cocos2d::floatr* getTimer(void) { return m_pTimer; } @@ -65,9 +65,9 @@ public: private: CCSchedulerScriptHandlerEntry(void); - bool initWithHandler(int nHandler, ccTime fInterval, bool bPaused); + bool initWithHandler(int nHandler, float fInterval, bool bPaused); - cocos2d::CCTimer* m_pTimer; + cocos2d::floatr* m_pTimer; bool m_bPaused; bool m_bMarkedForDeletion; int m_nHandler; @@ -178,7 +178,7 @@ public: virtual int executeTouchesEvent(int nHandler, int eventType, CCSet *pTouches) = 0; // execute a schedule function - virtual int executeSchedule(int nHandler, ccTime dt) = 0; + virtual int executeSchedule(int nHandler, float dt) = 0; }; /** diff --git a/cocos2dx/shaders/CCGLProgram.h b/cocos2dx/shaders/CCGLProgram.h index 03f8e0ee9a..fd5f480dff 100644 --- a/cocos2dx/shaders/CCGLProgram.h +++ b/cocos2dx/shaders/CCGLProgram.h @@ -31,6 +31,8 @@ THE SOFTWARE. #include "ccMacros.h" #include "CCObject.h" +#include "CCGL.h" + NS_CC_BEGIN enum { diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index 289a0ffbce..b3017a95a5 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -330,7 +330,7 @@ void CCTextureCache::addImageAsync(const char *path, CCObject *target, SEL_CallF sem_post(s_pSem); } -void CCTextureCache::addImageAsyncCallBack(ccTime dt) +void CCTextureCache::addImageAsyncCallBack(float dt) { // the image is generated in loading thread std::queue *imagesQueue = s_pImageQueue; diff --git a/cocos2dx/textures/CCTextureCache.h b/cocos2dx/textures/CCTextureCache.h index 8a98477b41..def606d5ef 100644 --- a/cocos2dx/textures/CCTextureCache.h +++ b/cocos2dx/textures/CCTextureCache.h @@ -56,7 +56,7 @@ protected: private: // @todo void addImageWithAsyncObject(CCAsyncObject* async); - void addImageAsyncCallBack(ccTime dt); + void addImageAsyncCallBack(float dt); public: diff --git a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id index 4d6dee11db..3a2f28fb74 100644 --- a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -10a5824d2ea7fd21b1d844f95393c267a2c9f61e \ No newline at end of file +277bc57b726290085c72db62cf656b66594440dc \ No newline at end of file diff --git a/tests/tests/ActionManagerTest/ActionManagerTest.cpp b/tests/tests/ActionManagerTest/ActionManagerTest.cpp index c1403d45b2..91ade71d38 100644 --- a/tests/tests/ActionManagerTest/ActionManagerTest.cpp +++ b/tests/tests/ActionManagerTest/ActionManagerTest.cpp @@ -240,7 +240,7 @@ void PauseTest::onEnter() schedule( schedule_selector(PauseTest::unpause), 3); } -void PauseTest::unpause(ccTime dt) +void PauseTest::unpause(float dt) { unschedule( schedule_selector(PauseTest::unpause) ); CCNode* node = getChildByTag( kTagGrossini ); @@ -324,7 +324,7 @@ void ResumeTest::onEnter() this->schedule(schedule_selector(ResumeTest::resumeGrossini), 3.0f); } -void ResumeTest::resumeGrossini(ccTime time) +void ResumeTest::resumeGrossini(float time) { this->unschedule(schedule_selector(ResumeTest::resumeGrossini)); diff --git a/tests/tests/ActionManagerTest/ActionManagerTest.h b/tests/tests/ActionManagerTest/ActionManagerTest.h index f2214f58d4..35afb921d1 100644 --- a/tests/tests/ActionManagerTest/ActionManagerTest.h +++ b/tests/tests/ActionManagerTest/ActionManagerTest.h @@ -43,7 +43,7 @@ class PauseTest : public ActionManagerTest public: virtual std::string title(); virtual void onEnter(); - void unpause(ccTime dt); + void unpause(float dt); }; class RemoveTest : public ActionManagerTest @@ -59,7 +59,7 @@ class ResumeTest : public ActionManagerTest public: virtual std::string title(); virtual void onEnter(); - void resumeGrossini(ccTime time); + void resumeGrossini(float time); }; class ActionManagerTestScene : public TestScene diff --git a/tests/tests/ActionsEaseTest/ActionsEaseTest.cpp b/tests/tests/ActionsEaseTest/ActionsEaseTest.cpp index cb4aa3b83c..4186a47b0b 100644 --- a/tests/tests/ActionsEaseTest/ActionsEaseTest.cpp +++ b/tests/tests/ActionsEaseTest/ActionsEaseTest.cpp @@ -51,7 +51,7 @@ void SpriteEase::onEnter() schedule(schedule_selector(SpriteEase::testStopAction), 6.25f); } -void SpriteEase::testStopAction(ccTime dt) +void SpriteEase::testStopAction(float dt) { unschedule(schedule_selector(SpriteEase::testStopAction)); m_tamara->stopActionByTag(1); @@ -515,7 +515,7 @@ void SpeedTest::onEnter() this->schedule(schedule_selector(SpeedTest::altertime), 1.0f);//:@selector(altertime:) interval:1.0f]; } -void SpeedTest::altertime(ccTime dt) +void SpeedTest::altertime(float dt) { CCSpeed* action1 = (CCSpeed*)(m_grossini->getActionByTag(kTagAction1)); CCSpeed* action2 = (CCSpeed*)(m_tamara->getActionByTag(kTagAction1)); diff --git a/tests/tests/ActionsEaseTest/ActionsEaseTest.h b/tests/tests/ActionsEaseTest/ActionsEaseTest.h index adc8fb1c81..04a5769af1 100644 --- a/tests/tests/ActionsEaseTest/ActionsEaseTest.h +++ b/tests/tests/ActionsEaseTest/ActionsEaseTest.h @@ -35,7 +35,7 @@ public: void onEnter(); virtual std::string title(); - void testStopAction(ccTime dt); + void testStopAction(float dt); }; class SpriteEaseInOut : public EaseSpriteDemo @@ -121,7 +121,7 @@ public: void onEnter(); virtual std::string title(); - void altertime(ccTime dt); + void altertime(float dt); }; class ActionsEaseTestScene : public TestScene diff --git a/tests/tests/ActionsTest/ActionsTest.cpp b/tests/tests/ActionsTest/ActionsTest.cpp index 90e58efb8a..217d432c97 100644 --- a/tests/tests/ActionsTest/ActionsTest.cpp +++ b/tests/tests/ActionsTest/ActionsTest.cpp @@ -1263,7 +1263,7 @@ void Issue1305::onExit() ActionsDemo::onExit(); } -void Issue1305::addSprite(ccTime dt) +void Issue1305::addSprite(float dt) { m_pSpriteTmp->setPosition(ccp(250,250)); addChild(m_pSpriteTmp); diff --git a/tests/tests/ActionsTest/ActionsTest.h b/tests/tests/ActionsTest/ActionsTest.h index f4eb8c852e..46da2c604f 100644 --- a/tests/tests/ActionsTest/ActionsTest.h +++ b/tests/tests/ActionsTest/ActionsTest.h @@ -290,7 +290,7 @@ public: virtual void onEnter(); virtual void onExit(); void log(CCNode* pSender); - void addSprite(ccTime dt); + void addSprite(float dt); virtual std::string title(); virtual std::string subtitle(); private: diff --git a/tests/tests/Box2DTest/Box2dTest.cpp b/tests/tests/Box2DTest/Box2dTest.cpp index d319b43aad..7a64603062 100644 --- a/tests/tests/Box2DTest/Box2dTest.cpp +++ b/tests/tests/Box2DTest/Box2dTest.cpp @@ -237,7 +237,7 @@ void Box2DTestLayer::addNewSpriteAtPosition(CCPoint p) } -void Box2DTestLayer::update(ccTime dt) +void Box2DTestLayer::update(float dt) { //It is recommended that a fixed time step is used with Box2D for stability //of the simulation, however, we are using a variable time step here. diff --git a/tests/tests/Box2DTest/Box2dTest.h b/tests/tests/Box2DTest/Box2dTest.h index 4f0b45d6fb..0697f513a1 100644 --- a/tests/tests/Box2DTest/Box2dTest.h +++ b/tests/tests/Box2DTest/Box2dTest.h @@ -32,7 +32,7 @@ public: virtual void draw(); void addNewSpriteAtPosition(CCPoint p); - void update(ccTime dt); + void update(float dt); virtual void ccTouchesEnded(CCSet* touches, CCEvent* event); //CREATE_NODE(Box2DTestLayer); diff --git a/tests/tests/Box2DTestBed/Box2dView.cpp b/tests/tests/Box2DTestBed/Box2dView.cpp index b8f254ac54..0ac3284864 100644 --- a/tests/tests/Box2DTestBed/Box2dView.cpp +++ b/tests/tests/Box2DTestBed/Box2dView.cpp @@ -187,7 +187,7 @@ std::string Box2DView::title() return std::string(m_entry->name); } -void Box2DView::tick(ccTime dt) +void Box2DView::tick(float dt) { m_test->Step(&settings); } diff --git a/tests/tests/Box2DTestBed/Box2dView.h b/tests/tests/Box2DTestBed/Box2dView.h index a9bba025a3..d731d91fab 100644 --- a/tests/tests/Box2DTestBed/Box2dView.h +++ b/tests/tests/Box2DTestBed/Box2dView.h @@ -40,7 +40,7 @@ public: bool initWithEntryID(int entryId); std::string title(); - void tick(ccTime dt); + void tick(float dt); void draw(); virtual void registerWithTouchDispatcher(); diff --git a/tests/tests/BugsTest/Bug-624.cpp b/tests/tests/BugsTest/Bug-624.cpp index f788631f42..08419cb1ed 100644 --- a/tests/tests/BugsTest/Bug-624.cpp +++ b/tests/tests/BugsTest/Bug-624.cpp @@ -28,7 +28,7 @@ bool Bug624Layer::init() return false; } -void Bug624Layer::switchLayer(ccTime dt) +void Bug624Layer::switchLayer(float dt) { unschedule(schedule_selector(Bug624Layer::switchLayer)); @@ -65,7 +65,7 @@ bool Bug624Layer2::init() return false; } -void Bug624Layer2::switchLayer(ccTime dt) +void Bug624Layer2::switchLayer(float dt) { unschedule(schedule_selector(Bug624Layer::switchLayer)); diff --git a/tests/tests/BugsTest/Bug-624.h b/tests/tests/BugsTest/Bug-624.h index 7d9a735d43..d407fb4d31 100644 --- a/tests/tests/BugsTest/Bug-624.h +++ b/tests/tests/BugsTest/Bug-624.h @@ -7,7 +7,7 @@ class Bug624Layer : public BugsTestBaseLayer { public: virtual bool init(); - void switchLayer(ccTime dt); + void switchLayer(float dt); virtual void didAccelerate(CCAcceleration* pAccelerationValue); LAYER_NODE_FUNC(Bug624Layer); @@ -17,7 +17,7 @@ class Bug624Layer2 : public BugsTestBaseLayer { public: virtual bool init(); - void switchLayer(ccTime dt); + void switchLayer(float dt); virtual void didAccelerate(CCAcceleration* pAccelerationValue); LAYER_NODE_FUNC(Bug624Layer2); diff --git a/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp b/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp index f25ce5b0c9..f45c455ba6 100644 --- a/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp +++ b/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp @@ -148,7 +148,7 @@ void ChipmunkAccelTouchTestLayer::initPhysics() } } -void ChipmunkAccelTouchTestLayer::update(ccTime delta) +void ChipmunkAccelTouchTestLayer::update(float delta) { // Should use a fixed size step based on the animation interval. int steps = 2; diff --git a/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.h b/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.h index 51a24c2a28..72a53afa9e 100644 --- a/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.h +++ b/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.h @@ -19,7 +19,7 @@ public: void reset(CCObject* sender); void addNewSpriteAtPosition(CCPoint p); - void update(ccTime dt); + void update(float dt); virtual void ccTouchesEnded(CCSet* touches, CCEvent* event); virtual void didAccelerate(CCAcceleration* pAccelerationValue); diff --git a/tests/tests/EffectsTest/EffectsTest.cpp b/tests/tests/EffectsTest/EffectsTest.cpp index b2719abcae..2d067b22fe 100644 --- a/tests/tests/EffectsTest/EffectsTest.cpp +++ b/tests/tests/EffectsTest/EffectsTest.cpp @@ -39,7 +39,7 @@ static std::string effectsList[] = class Shaky3DDemo : public CCShaky3D { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { return CCShaky3D::actionWithRange(5, false, ccg(15,10), t); } @@ -48,7 +48,7 @@ public: class Waves3DDemo : public CCWaves3D { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { return CCWaves3D::actionWithWaves(5, 40, ccg(15,10), t); } @@ -57,7 +57,7 @@ public: class FlipX3DDemo : public CCFlipX3D { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCFlipX3D* flipx = CCFlipX3D::actionWithDuration(t); CCActionInterval* flipx_back = flipx->reverse(); @@ -70,7 +70,7 @@ public: class FlipY3DDemo : public CCFlipY3D { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCFlipY3D* flipy = CCFlipY3D::actionWithDuration(t); CCActionInterval* flipy_back = flipy->reverse(); @@ -83,7 +83,7 @@ public: class Lens3DDemo : public CCLens3D { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCSize size = CCDirector::sharedDirector()->getWinSize(); return CCLens3D::actionWithPosition(CCPointMake(size.width/2,size.height/2), 240, ccg(15,10), t); @@ -94,7 +94,7 @@ public: class Ripple3DDemo : public CCRipple3D { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCSize size = CCDirector::sharedDirector()->getWinSize(); return CCRipple3D::actionWithPosition(CCPointMake(size.width/2,size.height/2), 240, 4, 160, ccg(32,24), t); @@ -105,7 +105,7 @@ public: class LiquidDemo : public CCLiquid { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { return CCLiquid::actionWithWaves(4, 20, ccg(16,12), t); } @@ -115,7 +115,7 @@ public: class WavesDemo : public CCWaves { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { return CCWaves::actionWithWaves(4, 20, true, true, ccg(16,12), t); } @@ -125,7 +125,7 @@ public: class TwirlDemo : public CCTwirl { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCSize size = CCDirector::sharedDirector()->getWinSize(); return CCTwirl::actionWithPosition(CCPointMake(size.width/2, size.height/2), 1, 2.5f, ccg(12,8), t); @@ -136,7 +136,7 @@ public: class ShakyTiles3DDemo : public CCShakyTiles3D { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { return CCShakyTiles3D::actionWithRange(5, false, ccg(16,12), t) ; } @@ -146,7 +146,7 @@ public: class ShatteredTiles3DDemo : public CCShatteredTiles3D { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { return CCShatteredTiles3D::actionWithRange(5, false, ccg(16,12), t); } @@ -156,7 +156,7 @@ public: class ShuffleTilesDemo : public CCShuffleTiles { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCShuffleTiles* shuffle = CCShuffleTiles::actionWithSeed(25, ccg(16,12), t); CCActionInterval* shuffle_back = shuffle->reverse(); @@ -170,7 +170,7 @@ public: class FadeOutTRTilesDemo : public CCFadeOutTRTiles { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCFadeOutTRTiles* fadeout = CCFadeOutTRTiles::actionWithSize(ccg(16,12), t); CCActionInterval* back = fadeout->reverse(); @@ -184,7 +184,7 @@ public: class FadeOutBLTilesDemo : public CCFadeOutBLTiles { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCFadeOutBLTiles* fadeout = CCFadeOutBLTiles::actionWithSize(ccg(16,12), t); CCActionInterval* back = fadeout->reverse(); @@ -198,7 +198,7 @@ public: class FadeOutUpTilesDemo : public CCFadeOutUpTiles { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCFadeOutUpTiles* fadeout = CCFadeOutUpTiles::actionWithSize(ccg(16,12), t); CCActionInterval* back = fadeout->reverse(); @@ -211,7 +211,7 @@ public: class FadeOutDownTilesDemo : public CCFadeOutDownTiles { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCFadeOutDownTiles* fadeout = CCFadeOutDownTiles::actionWithSize(ccg(16,12), t); CCActionInterval* back = fadeout->reverse(); @@ -224,7 +224,7 @@ public: class TurnOffTilesDemo : public CCTurnOffTiles { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCTurnOffTiles* fadeout = CCTurnOffTiles::actionWithSeed(25, ccg(48,32) , t); CCActionInterval* back = fadeout->reverse(); @@ -237,7 +237,7 @@ public: class WavesTiles3DDemo : public CCWavesTiles3D { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { return CCWavesTiles3D::actionWithWaves(4, 120, ccg(15,10), t); } @@ -246,7 +246,7 @@ public: class JumpTiles3DDemo : public CCJumpTiles3D { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCSize size = CCDirector::sharedDirector()->getWinSize(); return CCJumpTiles3D::actionWithJumps(2, 30, ccg(15,10), t); @@ -256,7 +256,7 @@ public: class SplitRowsDemo : public CCSplitRows { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { return CCSplitRows::actionWithRows(9, t); } @@ -265,7 +265,7 @@ public: class SplitColsDemo : public CCSplitCols { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { return CCSplitCols::actionWithCols(9, t); } @@ -274,7 +274,7 @@ public: class PageTurn3DDemo : public CCPageTurn3D { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCDirector::sharedDirector()->setDepthTest(true); return CCPageTurn3D::actionWithSize(ccg(15,10), t); @@ -288,7 +288,7 @@ public: //------------------------------------------------------------------ #define MAX_LAYER 22 -CCActionInterval* createEffect(int nIndex, ccTime t) +CCActionInterval* createEffect(int nIndex, float t) { CCDirector::sharedDirector()->setDepthTest(false); @@ -393,7 +393,7 @@ TextLayer::TextLayer(void) schedule( schedule_selector(TextLayer::checkAnim) ); } -void TextLayer::checkAnim(ccTime dt) +void TextLayer::checkAnim(float dt) { CCNode* s2 = getChildByTag(kTagBackground); if ( s2->numberOfRunningActions() == 0 && s2->getGrid() != NULL) diff --git a/tests/tests/EffectsTest/EffectsTest.h b/tests/tests/EffectsTest/EffectsTest.h index bbd7288131..022d0e8306 100644 --- a/tests/tests/EffectsTest/EffectsTest.h +++ b/tests/tests/EffectsTest/EffectsTest.h @@ -18,7 +18,7 @@ public: TextLayer(void); ~TextLayer(void); - void checkAnim(ccTime dt); + void checkAnim(float dt); virtual void onEnter(); diff --git a/tests/tests/IntervalTest/IntervalTest.cpp b/tests/tests/IntervalTest/IntervalTest.cpp index 68e6f270f1..f471b45049 100644 --- a/tests/tests/IntervalTest/IntervalTest.cpp +++ b/tests/tests/IntervalTest/IntervalTest.cpp @@ -75,7 +75,7 @@ IntervalLayer::~IntervalLayer() } } -void IntervalLayer::update(ccTime dt) +void IntervalLayer::update(float dt) { m_time0 +=dt; char time[10] = {0}; @@ -92,7 +92,7 @@ void IntervalLayer::onPause(CCObject* pSender) } -void IntervalLayer::step1(ccTime dt) +void IntervalLayer::step1(float dt) { m_time1 +=dt; @@ -101,7 +101,7 @@ void IntervalLayer::step1(ccTime dt) m_label1->setString( str ); } -void IntervalLayer::step2(ccTime dt) +void IntervalLayer::step2(float dt) { m_time2 +=dt; @@ -110,7 +110,7 @@ void IntervalLayer::step2(ccTime dt) m_label2->setString( str ); } -void IntervalLayer::step3(ccTime dt) +void IntervalLayer::step3(float dt) { m_time3 +=dt; @@ -119,7 +119,7 @@ void IntervalLayer::step3(ccTime dt) m_label3->setString( str ); } -void IntervalLayer::step4(ccTime dt) +void IntervalLayer::step4(float dt) { m_time4 +=dt; diff --git a/tests/tests/IntervalTest/IntervalTest.h b/tests/tests/IntervalTest/IntervalTest.h index f78bfcfec6..2cc6952eaf 100644 --- a/tests/tests/IntervalTest/IntervalTest.h +++ b/tests/tests/IntervalTest/IntervalTest.h @@ -12,7 +12,7 @@ protected: CCLabelBMFont* m_label3; CCLabelBMFont* m_label4; - ccTime m_time0, m_time1, m_time2, m_time3, m_time4; + float m_time0, m_time1, m_time2, m_time3, m_time4; public: IntervalLayer(void); @@ -20,11 +20,11 @@ public: public: void onPause(CCObject* pSender); - void step1(ccTime dt); - void step2(ccTime dt); - void step3(ccTime dt); - void step4(ccTime dt); - void update(ccTime dt); + void step1(float dt); + void step2(float dt); + void step3(float dt); + void step4(float dt); + void update(float dt); //CREATE_NODE(IntervalLayer); }; diff --git a/tests/tests/LabelTest/LabelTest.cpp b/tests/tests/LabelTest/LabelTest.cpp index a54a4bf8ca..d62dd37365 100644 --- a/tests/tests/LabelTest/LabelTest.cpp +++ b/tests/tests/LabelTest/LabelTest.cpp @@ -279,7 +279,7 @@ LabelAtlasTest::LabelAtlasTest() } -void LabelAtlasTest::step(ccTime dt) +void LabelAtlasTest::step(float dt) { m_time += dt; char string[12] = {0}; @@ -333,7 +333,7 @@ LabelAtlasColorTest::LabelAtlasColorTest() schedule( schedule_selector(LabelAtlasColorTest::step) ); //:@selector(step:)]; } -void LabelAtlasColorTest::step(ccTime dt) +void LabelAtlasColorTest::step(float dt) { m_time += dt; char string[12] = {0}; @@ -413,7 +413,7 @@ Atlas3::Atlas3() schedule( schedule_selector(Atlas3::step) );//:@selector(step:)]; } -void Atlas3::step(ccTime dt) +void Atlas3::step(float dt) { m_time += dt; //std::string string; @@ -512,7 +512,7 @@ void Atlas4::draw() ccDrawLine( ccp(s.width/2, 0), ccp(s.width/2, s.height) ); } -void Atlas4::step(ccTime dt) +void Atlas4::step(float dt) { m_time += dt; char string[10] = {0}; @@ -780,7 +780,7 @@ LabelsEmpty::LabelsEmpty() setEmpty = false; } -void LabelsEmpty::updateStrings(ccTime dt) +void LabelsEmpty::updateStrings(float dt) { CCLabelBMFont* label1 = (CCLabelBMFont*) getChildByTag(kTagBitmapAtlas1); CCLabelTTF* label2 = (CCLabelTTF*) getChildByTag(kTagBitmapAtlas2); diff --git a/tests/tests/LabelTest/LabelTest.h b/tests/tests/LabelTest/LabelTest.h index d2634fb0f9..0df0c68e6a 100644 --- a/tests/tests/LabelTest/LabelTest.h +++ b/tests/tests/LabelTest/LabelTest.h @@ -34,11 +34,11 @@ public: class LabelAtlasTest : public AtlasDemo { - ccTime m_time; + float m_time; public: LabelAtlasTest(); - virtual void step(ccTime dt); + virtual void step(float dt); virtual std::string title(); virtual std::string subtitle(); @@ -46,21 +46,21 @@ public: class LabelAtlasColorTest : public AtlasDemo { - ccTime m_time; + float m_time; public: LabelAtlasColorTest(); - virtual void step(ccTime dt); + virtual void step(float dt); virtual std::string title(); virtual std::string subtitle(); }; class Atlas3 : public AtlasDemo { - ccTime m_time; + float m_time; public: Atlas3(); - virtual void step(ccTime dt); + virtual void step(float dt); virtual std::string title(); virtual std::string subtitle(); @@ -68,10 +68,10 @@ public: class Atlas4 : public AtlasDemo { - ccTime m_time; + float m_time; public: Atlas4(); - virtual void step(ccTime dt); + virtual void step(float dt); virtual void draw(); virtual std::string title(); @@ -124,7 +124,7 @@ class LabelsEmpty : public AtlasDemo { public: LabelsEmpty(); - void updateStrings(ccTime dt); + void updateStrings(float dt); virtual std::string title(); virtual std::string subtitle(); diff --git a/tests/tests/LayerTest/LayerTest.cpp b/tests/tests/LayerTest/LayerTest.cpp index 66c40e29b7..85e49eec5b 100644 --- a/tests/tests/LayerTest/LayerTest.cpp +++ b/tests/tests/LayerTest/LayerTest.cpp @@ -267,7 +267,7 @@ LayerTestBlend::LayerTestBlend() schedule( schedule_selector(LayerTestBlend::newBlend), 1.0f); } -void LayerTestBlend::newBlend(ccTime dt) +void LayerTestBlend::newBlend(float dt) { CCLayerColor *layer = (CCLayerColor*)getChildByTag(kTagLayer); diff --git a/tests/tests/LayerTest/LayerTest.h b/tests/tests/LayerTest/LayerTest.h index e5a2f3bba1..d23223b835 100644 --- a/tests/tests/LayerTest/LayerTest.h +++ b/tests/tests/LayerTest/LayerTest.h @@ -48,7 +48,7 @@ class LayerTestBlend : public LayerTest { public: LayerTestBlend(); - void newBlend(ccTime dt); + void newBlend(float dt); virtual std::string title(); }; diff --git a/tests/tests/MenuTest/MenuTest.cpp b/tests/tests/MenuTest/MenuTest.cpp index 250b1d696e..bbea03ed64 100644 --- a/tests/tests/MenuTest/MenuTest.cpp +++ b/tests/tests/MenuTest/MenuTest.cpp @@ -151,7 +151,7 @@ void MenuLayerMainMenu::menuCallbackConfig(CCObject* sender) ((CCLayerMultiplex*)m_pParent)->switchTo(3); } -void MenuLayerMainMenu::allowTouches(ccTime dt) +void MenuLayerMainMenu::allowTouches(float dt) { CCDirector* pDirector = CCDirector::sharedDirector(); pDirector->getTouchDispatcher()->setPriority(kCCMenuHandlerPriority+1, this); diff --git a/tests/tests/MenuTest/MenuTest.h b/tests/tests/MenuTest/MenuTest.h index 5f2dc575ba..4f9393514d 100644 --- a/tests/tests/MenuTest/MenuTest.h +++ b/tests/tests/MenuTest/MenuTest.h @@ -20,7 +20,7 @@ public: virtual void ccTouchCancelled(CCTouch *touch, CCEvent * pEvent); virtual void ccTouchMoved(CCTouch *touch, CCEvent * pEvent); - void allowTouches(ccTime dt); + void allowTouches(float dt); void menuCallback(CCObject* pSender); void menuCallbackConfig(CCObject* pSender); void menuCallbackDisabled(CCObject* pSender); diff --git a/tests/tests/MotionStreakTest/MotionStreakTest.cpp b/tests/tests/MotionStreakTest/MotionStreakTest.cpp index 2dbc1deb5d..013bb30b97 100644 --- a/tests/tests/MotionStreakTest/MotionStreakTest.cpp +++ b/tests/tests/MotionStreakTest/MotionStreakTest.cpp @@ -56,7 +56,7 @@ void MotionStreakTest1::onEnter() streak = m_streak; } -void MotionStreakTest1::onUpdate(ccTime delta) +void MotionStreakTest1::onUpdate(float delta) { m_streak->setPosition( m_target->convertToWorldSpace(CCPointZero) ); } diff --git a/tests/tests/MotionStreakTest/MotionStreakTest.h b/tests/tests/MotionStreakTest/MotionStreakTest.h index 45dd68996e..0925f46a96 100644 --- a/tests/tests/MotionStreakTest/MotionStreakTest.h +++ b/tests/tests/MotionStreakTest/MotionStreakTest.h @@ -32,7 +32,7 @@ protected: public: virtual void onEnter(); - void onUpdate(ccTime delta); + void onUpdate(float delta); virtual std::string title(); }; diff --git a/tests/tests/NodeTest/NodeTest.cpp b/tests/tests/NodeTest/NodeTest.cpp index bb8ce6314d..e62589dc5d 100644 --- a/tests/tests/NodeTest/NodeTest.cpp +++ b/tests/tests/NodeTest/NodeTest.cpp @@ -232,14 +232,14 @@ Test4::Test4() schedule( schedule_selector(Test4::delay4), 4.0f); } -void Test4::delay2(ccTime dt) +void Test4::delay2(float dt) { CCSprite* node = (CCSprite*)(getChildByTag(2)); CCAction* action1 = CCRotateBy::actionWithDuration(1, 360); node->runAction(action1); } -void Test4::delay4(ccTime dt) +void Test4::delay4(float dt) { unschedule(schedule_selector(Test4::delay4)); removeChildByTag(3, false); @@ -282,7 +282,7 @@ Test5::Test5() schedule( schedule_selector(Test5::addAndRemove), 2.0f); } -void Test5::addAndRemove(ccTime dt) +void Test5::addAndRemove(float dt) { CCNode* sp1 = getChildByTag(kTagSprite1); CCNode* sp2 = getChildByTag(kTagSprite2); @@ -343,7 +343,7 @@ Test6::Test6() schedule( schedule_selector(Test6::addAndRemove), 2.0f); } -void Test6::addAndRemove(ccTime dt) +void Test6::addAndRemove(float dt) { CCNode* sp1 = getChildByTag(kTagSprite1); CCNode* sp2 = getChildByTag(kTagSprite2); @@ -384,7 +384,7 @@ StressTest1::StressTest1() schedule( schedule_selector(StressTest1::shouldNotCrash), 1.0f); } -void StressTest1::shouldNotCrash(ccTime dt) +void StressTest1::shouldNotCrash(float dt) { unschedule(schedule_selector(StressTest1::shouldNotCrash)); @@ -455,7 +455,7 @@ StressTest2::StressTest2() addChild(sublayer, 0, kTagSprite1); } -void StressTest2::shouldNotLeak(ccTime dt) +void StressTest2::shouldNotLeak(float dt) { unschedule( schedule_selector(StressTest2::shouldNotLeak) ); CCLayer* sublayer = (CCLayer*)getChildByTag(kTagSprite1); @@ -482,13 +482,13 @@ SchedulerTest1::SchedulerTest1() //UXLOG("retain count after addChild is %d", layer->retainCount()); // 2 layer->schedule( schedule_selector(SchedulerTest1::doSomething) ); - //UXLOG("retain count after schedule is %d", layer->retainCount()); // 3 : (object-c viersion), but win32 version is still 2, because CCTimer class don't save target. + //UXLOG("retain count after schedule is %d", layer->retainCount()); // 3 : (object-c viersion), but win32 version is still 2, because floatr class don't save target. layer->unschedule(schedule_selector(SchedulerTest1::doSomething)); //UXLOG("retain count after unschedule is %d", layer->retainCount()); // STILL 3! (win32 is '2') } -void SchedulerTest1::doSomething(ccTime dt) +void SchedulerTest1::doSomething(float dt) { } @@ -657,7 +657,7 @@ CameraZoomTest::CameraZoomTest() scheduleUpdate(); } -void CameraZoomTest::update(ccTime dt) +void CameraZoomTest::update(float dt) { CCNode *sprite; CCCamera *cam; diff --git a/tests/tests/NodeTest/NodeTest.h b/tests/tests/NodeTest/NodeTest.h index 1a999c2ee5..277625325a 100644 --- a/tests/tests/NodeTest/NodeTest.h +++ b/tests/tests/NodeTest/NodeTest.h @@ -30,8 +30,8 @@ class Test4 : public TestCocosNodeDemo { public: Test4(); - void delay2(ccTime dt); - void delay4(ccTime dt); + void delay2(float dt); + void delay4(float dt); virtual std::string title(); }; @@ -40,7 +40,7 @@ class Test5 : public TestCocosNodeDemo { public: Test5(); - void addAndRemove(ccTime dt); + void addAndRemove(float dt); virtual std::string title(); }; @@ -49,14 +49,14 @@ class Test6 : public TestCocosNodeDemo { public: Test6(); - void addAndRemove(ccTime dt); + void addAndRemove(float dt); virtual std::string title(); }; class StressTest1 : public TestCocosNodeDemo { - void shouldNotCrash(ccTime dt); + void shouldNotCrash(float dt); void removeMe(CCNode* node); public: StressTest1(); @@ -66,7 +66,7 @@ public: class StressTest2 : public TestCocosNodeDemo { - void shouldNotLeak(ccTime dt); + void shouldNotLeak(float dt); public: StressTest2(); @@ -77,7 +77,7 @@ class SchedulerTest1 : public TestCocosNodeDemo { public: SchedulerTest1(); - void doSomething(ccTime dt); + void doSomething(float dt); virtual std::string title(); }; @@ -104,7 +104,7 @@ class CameraZoomTest : public TestCocosNodeDemo float m_z; public: CameraZoomTest(); - void update(ccTime dt); + void update(float dt); virtual void onEnter(); virtual void onExit(); diff --git a/tests/tests/ParticleTest/ParticleTest.cpp b/tests/tests/ParticleTest/ParticleTest.cpp index e4bcf31988..cc2d44a15b 100644 --- a/tests/tests/ParticleTest/ParticleTest.cpp +++ b/tests/tests/ParticleTest/ParticleTest.cpp @@ -914,7 +914,7 @@ void Issue870::onEnter() schedule(schedule_selector(Issue870::updateQuads), 2.0f); } -void Issue870::updateQuads(ccTime dt) +void Issue870::updateQuads(float dt) { m_nIndex = (m_nIndex + 1) % 4; CCRect rect = CCRectMake(m_nIndex * 32, 0, 32, 32); @@ -1168,7 +1168,7 @@ void ParticleDemo::ccTouchEnded(CCTouch* touch, CCEvent* event) } } -void ParticleDemo::update(ccTime dt) +void ParticleDemo::update(float dt) { if (m_emitter) { @@ -1252,7 +1252,7 @@ void ParticleBatchHybrid::onEnter() m_pParent2 = node; } -void ParticleBatchHybrid::switchRender(ccTime dt) +void ParticleBatchHybrid::switchRender(float dt) { bool usingBatch = ( m_emitter->getBatchNode() != NULL ); m_emitter->removeFromParentAndCleanup(false); @@ -1373,7 +1373,7 @@ std::string ParticleReorder::subtitle() return "Reordering particles with and without batches batches"; } -void ParticleReorder::reorderParticles(ccTime dt) +void ParticleReorder::reorderParticles(float dt) { for( int i=0; i<2;i++) { CCNode *parent = getChildByTag(1000+i); @@ -1407,7 +1407,7 @@ class RainbowEffect : public CCParticleSystemQuad public: bool init(); virtual bool initWithTotalParticles(unsigned int numberOfParticles); - virtual void update(ccTime dt); + virtual void update(float dt); }; bool RainbowEffect::init() @@ -1481,7 +1481,7 @@ bool RainbowEffect::initWithTotalParticles(unsigned int numberOfParticles) return false; } -void RainbowEffect::update(ccTime dt) +void RainbowEffect::update(float dt) { m_fEmitCounter = 0; CCParticleSystemQuad::update(dt); @@ -1551,7 +1551,7 @@ std::string MultipleParticleSystems::subtitle() return "v1.1 test: FPS should be lower than next test"; } -void MultipleParticleSystems::update(ccTime dt) +void MultipleParticleSystems::update(float dt) { CCLabelAtlas *atlas = (CCLabelAtlas*) getChildByTag(kTagParticleCount); @@ -1602,7 +1602,7 @@ void MultipleParticleSystemsBatched::onEnter() m_emitter = NULL; } -void MultipleParticleSystemsBatched::update(ccTime dt) +void MultipleParticleSystemsBatched::update(float dt) { CCLabelAtlas *atlas = (CCLabelAtlas*) getChildByTag(kTagParticleCount); @@ -1668,7 +1668,7 @@ void AddAndDeleteParticleSystems::onEnter() } -void AddAndDeleteParticleSystems::removeSystem(ccTime dt) +void AddAndDeleteParticleSystems::removeSystem(float dt) { int nChildrenCount = m_pBatchNode->getChildren()->count(); if (nChildrenCount > 0) @@ -1691,7 +1691,7 @@ void AddAndDeleteParticleSystems::removeSystem(ccTime dt) } } -void AddAndDeleteParticleSystems::update(ccTime dt) +void AddAndDeleteParticleSystems::update(float dt) { CCLabelAtlas *atlas = (CCLabelAtlas*) getChildByTag(kTagParticleCount); @@ -1820,14 +1820,14 @@ void ReorderParticleSystems::onEnter() } -void ReorderParticleSystems::reorderSystem(ccTime time) +void ReorderParticleSystems::reorderSystem(float time) { CCParticleSystem* system = (CCParticleSystem*)m_pBatchNode->getChildren()->objectAtIndex(1); m_pBatchNode->reorderChild(system, system->getZOrder() - 1); } -void ReorderParticleSystems::update(ccTime dt) +void ReorderParticleSystems::update(float dt) { CCLabelAtlas *atlas = (CCLabelAtlas*) getChildByTag(kTagParticleCount); diff --git a/tests/tests/ParticleTest/ParticleTest.h b/tests/tests/ParticleTest/ParticleTest.h index 7965d67aee..0156127607 100644 --- a/tests/tests/ParticleTest/ParticleTest.h +++ b/tests/tests/ParticleTest/ParticleTest.h @@ -36,7 +36,7 @@ public: virtual void ccTouchMoved(CCTouch* touch, CCEvent* event); virtual void ccTouchEnded(CCTouch* touch, CCEvent* event); - virtual void update(ccTime dt); + virtual void update(float dt); void setEmitterPosition(); }; @@ -195,7 +195,7 @@ public: virtual void onEnter(); virtual std::string title(); virtual std::string subtitle(); - void updateQuads(ccTime dt); + void updateQuads(float dt); private: int m_nIndex; @@ -213,7 +213,7 @@ class ParticleBatchHybrid : public ParticleDemo { public: virtual void onEnter(); - void switchRender(ccTime dt); + void switchRender(float dt); virtual std::string title(); virtual std::string subtitle(); private: @@ -233,7 +233,7 @@ class ParticleReorder : public ParticleDemo { public: virtual void onEnter(); - void reorderParticles(ccTime dt); + void reorderParticles(float dt); virtual std::string title(); virtual std::string subtitle(); private: @@ -246,14 +246,14 @@ public: virtual void onEnter(); virtual std::string title(); virtual std::string subtitle(); - virtual void update(ccTime dt); + virtual void update(float dt); }; class MultipleParticleSystemsBatched : public ParticleDemo { public: virtual void onEnter(); - virtual void update(ccTime dt); + virtual void update(float dt); virtual std::string title(); virtual std::string subtitle(); private: @@ -264,8 +264,8 @@ class AddAndDeleteParticleSystems : public ParticleDemo { public: virtual void onEnter(); - virtual void update(ccTime dt); - void removeSystem(ccTime dt); + virtual void update(float dt); + void removeSystem(float dt); virtual std::string title(); virtual std::string subtitle(); private: @@ -276,8 +276,8 @@ class ReorderParticleSystems : public ParticleDemo { public: virtual void onEnter(); - void reorderSystem(ccTime time); - virtual void update(ccTime dt); + void reorderSystem(float time); + virtual void update(float dt); virtual std::string title(); virtual std::string subtitle(); private: diff --git a/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp b/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp index e1a1636f9f..676cf01904 100644 --- a/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -223,7 +223,7 @@ std::string IterateSpriteSheet::profilerName() // IterateSpriteSheetFastEnum // //////////////////////////////////////////////////////// -void IterateSpriteSheetFastEnum::update(ccTime dt) +void IterateSpriteSheetFastEnum::update(float dt) { // iterate using fast enumeration protocol CCArray* pChildren = batchNode->getChildren(); @@ -264,7 +264,7 @@ std::string IterateSpriteSheetFastEnum::profilerName() // IterateSpriteSheetCArray // //////////////////////////////////////////////////////// -void IterateSpriteSheetCArray::update(ccTime dt) +void IterateSpriteSheetCArray::update(float dt) { // iterate using fast enumeration protocol CCArray* pChildren = batchNode->getChildren(); @@ -366,7 +366,7 @@ std::string AddRemoveSpriteSheet::profilerName() // AddSpriteSheet // //////////////////////////////////////////////////////// -void AddSpriteSheet::update(ccTime dt) +void AddSpriteSheet::update(float dt) { // reset seed //srandom(0); @@ -431,7 +431,7 @@ std::string AddSpriteSheet::profilerName() // RemoveSpriteSheet // //////////////////////////////////////////////////////// -void RemoveSpriteSheet::update(ccTime dt) +void RemoveSpriteSheet::update(float dt) { //srandom(0); @@ -491,7 +491,7 @@ std::string RemoveSpriteSheet::profilerName() // ReorderSpriteSheet // //////////////////////////////////////////////////////// -void ReorderSpriteSheet::update(ccTime dt) +void ReorderSpriteSheet::update(float dt) { //srandom(0); diff --git a/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.h b/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.h index a0ccb29d57..448659c7b1 100644 --- a/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.h +++ b/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.h @@ -37,7 +37,7 @@ public: ~IterateSpriteSheet(); virtual void updateQuantityOfNodes(); virtual void initWithQuantityOfNodes(unsigned int nNodes); - virtual void update(ccTime dt) = 0; + virtual void update(float dt) = 0; virtual std::string profilerName(); protected: @@ -51,7 +51,7 @@ protected: class IterateSpriteSheetFastEnum : public IterateSpriteSheet { public: - virtual void update(ccTime dt); + virtual void update(float dt); virtual std::string title(); virtual std::string subtitle(); @@ -61,7 +61,7 @@ public: class IterateSpriteSheetCArray : public IterateSpriteSheet { public: - virtual void update(ccTime dt); + virtual void update(float dt); virtual std::string title(); virtual std::string subtitle(); @@ -74,7 +74,7 @@ public: ~AddRemoveSpriteSheet(); virtual void updateQuantityOfNodes(); virtual void initWithQuantityOfNodes(unsigned int nNodes); - virtual void update(ccTime dt) = 0; + virtual void update(float dt) = 0; virtual std::string profilerName(); protected: @@ -88,7 +88,7 @@ protected: class AddSpriteSheet : public AddRemoveSpriteSheet { public: - virtual void update(ccTime dt); + virtual void update(float dt); virtual std::string title(); virtual std::string subtitle(); @@ -98,7 +98,7 @@ public: class RemoveSpriteSheet : public AddRemoveSpriteSheet { public: - virtual void update(ccTime dt); + virtual void update(float dt); virtual std::string title(); virtual std::string subtitle(); @@ -108,7 +108,7 @@ public: class ReorderSpriteSheet : public AddRemoveSpriteSheet { public: - virtual void update(ccTime dt); + virtual void update(float dt); virtual std::string title(); virtual std::string subtitle(); diff --git a/tests/tests/PerformanceTest/PerformanceParticleTest.cpp b/tests/tests/PerformanceTest/PerformanceParticleTest.cpp index 343556470c..0701cb82a5 100644 --- a/tests/tests/PerformanceTest/PerformanceParticleTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceParticleTest.cpp @@ -144,7 +144,7 @@ std::string ParticleMainScene::title() return "No title"; } -void ParticleMainScene::step(ccTime dt) +void ParticleMainScene::step(float dt) { CCLabelAtlas *atlas = (CCLabelAtlas*) getChildByTag(kTagLabelAtlas); CCParticleSystem *emitter = (CCParticleSystem*) getChildByTag(kTagParticleSystem); diff --git a/tests/tests/PerformanceTest/PerformanceParticleTest.h b/tests/tests/PerformanceTest/PerformanceParticleTest.h index 03cce4ae89..636689a9cc 100644 --- a/tests/tests/PerformanceTest/PerformanceParticleTest.h +++ b/tests/tests/PerformanceTest/PerformanceParticleTest.h @@ -16,7 +16,7 @@ public: virtual void initWithSubTest(int subtest, int particles); virtual std::string title(); - void step(ccTime dt); + void step(float dt); void createParticleSystem(); void onDecrease(CCObject* pSender); void onIncrease(CCObject* pSender); diff --git a/tests/tests/PerformanceTest/PerformanceTouchesTest.cpp b/tests/tests/PerformanceTest/PerformanceTouchesTest.cpp index 33ff66f18b..e4e0b5782b 100644 --- a/tests/tests/PerformanceTest/PerformanceTouchesTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceTouchesTest.cpp @@ -57,7 +57,7 @@ void TouchesMainScene::onEnter() numberOfTouchesB = numberOfTouchesM = numberOfTouchesE = numberOfTouchesC = 0; } -void TouchesMainScene::update(ccTime dt) +void TouchesMainScene::update(float dt) { elapsedTime += dt; diff --git a/tests/tests/PerformanceTest/PerformanceTouchesTest.h b/tests/tests/PerformanceTest/PerformanceTouchesTest.h index 2cfbce6ae9..573d22470a 100644 --- a/tests/tests/PerformanceTest/PerformanceTouchesTest.h +++ b/tests/tests/PerformanceTest/PerformanceTouchesTest.h @@ -14,7 +14,7 @@ public: virtual void showCurrentTest(); virtual void onEnter(); virtual std::string title(); - virtual void update(ccTime dt); + virtual void update(float dt); protected: CCLabelBMFont * m_plabel; @@ -22,7 +22,7 @@ protected: int numberOfTouchesM; int numberOfTouchesE; int numberOfTouchesC; - ccTime elapsedTime; + float elapsedTime; }; class TouchesPerformTest1 : public TouchesMainScene diff --git a/tests/tests/SceneTest/SceneTest.cpp b/tests/tests/SceneTest/SceneTest.cpp index 22fb630065..d325d0a5b8 100644 --- a/tests/tests/SceneTest/SceneTest.cpp +++ b/tests/tests/SceneTest/SceneTest.cpp @@ -38,7 +38,7 @@ SceneTestLayer1::SceneTestLayer1() schedule( schedule_selector(SceneTestLayer1::testDealloc) ); } -void SceneTestLayer1::testDealloc(ccTime dt) +void SceneTestLayer1::testDealloc(float dt) { //UXLOG("SceneTestLayer1:testDealloc"); } @@ -123,7 +123,7 @@ SceneTestLayer2::SceneTestLayer2() schedule( schedule_selector(SceneTestLayer2::testDealloc) ); } -void SceneTestLayer2::testDealloc(ccTime dt) +void SceneTestLayer2::testDealloc(float dt) { //m_timeCounter += dt; //if( m_timeCounter > 10 ) @@ -180,7 +180,7 @@ SceneTestLayer3::SceneTestLayer3() //schedule(); } -void SceneTestLayer3::testDealloc(ccTime dt) +void SceneTestLayer3::testDealloc(float dt) { } diff --git a/tests/tests/SceneTest/SceneTest.h b/tests/tests/SceneTest/SceneTest.h index 586788fede..c4bfb75a5d 100644 --- a/tests/tests/SceneTest/SceneTest.h +++ b/tests/tests/SceneTest/SceneTest.h @@ -13,7 +13,7 @@ public: virtual void onEnter(); virtual void onEnterTransitionDidFinish(); - void testDealloc(ccTime dt); + void testDealloc(float dt); void onPushScene(CCObject* pSender); void onPushSceneTran(CCObject* pSender); void onQuit(CCObject* pSender); @@ -27,7 +27,7 @@ class SceneTestLayer2 : public CCLayer public: SceneTestLayer2(); - void testDealloc(ccTime dt); + void testDealloc(float dt); void onGoBack(CCObject* pSender); void onReplaceScene(CCObject* pSender); void onReplaceSceneTran(CCObject* pSender); @@ -40,7 +40,7 @@ class SceneTestLayer3 : public CCLayerColor public: SceneTestLayer3(); - virtual void testDealloc(ccTime dt); + virtual void testDealloc(float dt); virtual void ccTouchesEnded(CCSet* touches, CCEvent* event); diff --git a/tests/tests/SchedulerTest/SchedulerTest.cpp b/tests/tests/SchedulerTest/SchedulerTest.cpp index 14180c1a6b..0a8163dba8 100644 --- a/tests/tests/SchedulerTest/SchedulerTest.cpp +++ b/tests/tests/SchedulerTest/SchedulerTest.cpp @@ -161,7 +161,7 @@ void SchedulerAutoremove::onEnter() accum = 0; } -void SchedulerAutoremove::autoremove(ccTime dt) +void SchedulerAutoremove::autoremove(float dt) { accum += dt; CCLOG("Time: %f", accum); @@ -173,7 +173,7 @@ void SchedulerAutoremove::autoremove(ccTime dt) } } -void SchedulerAutoremove::tick(ccTime dt) +void SchedulerAutoremove::tick(float dt) { CCLOG("This scheduler should not be removed"); } @@ -202,17 +202,17 @@ void SchedulerPauseResume::onEnter() schedule(schedule_selector(SchedulerPauseResume::pause), 0.5f); } -void SchedulerPauseResume::tick1(ccTime dt) +void SchedulerPauseResume::tick1(float dt) { CCLOG("tick1"); } -void SchedulerPauseResume::tick2(ccTime dt) +void SchedulerPauseResume::tick2(float dt) { CCLOG("tick2"); } -void SchedulerPauseResume::pause(ccTime dt) +void SchedulerPauseResume::pause(float dt) { CCDirector::sharedDirector()->getScheduler()->pauseTarget(this); } @@ -243,27 +243,27 @@ void SchedulerUnscheduleAll::onEnter() schedule(schedule_selector(SchedulerUnscheduleAll::unscheduleAll), 4); } -void SchedulerUnscheduleAll::tick1(ccTime dt) +void SchedulerUnscheduleAll::tick1(float dt) { CCLOG("tick1"); } -void SchedulerUnscheduleAll::tick2(ccTime dt) +void SchedulerUnscheduleAll::tick2(float dt) { CCLOG("tick2"); } -void SchedulerUnscheduleAll::tick3(ccTime dt) +void SchedulerUnscheduleAll::tick3(float dt) { CCLOG("tick3"); } -void SchedulerUnscheduleAll::tick4(ccTime dt) +void SchedulerUnscheduleAll::tick4(float dt) { CCLOG("tick4"); } -void SchedulerUnscheduleAll::unscheduleAll(ccTime dt) +void SchedulerUnscheduleAll::unscheduleAll(float dt) { unscheduleAllSelectors(); } @@ -294,27 +294,27 @@ void SchedulerUnscheduleAllHard::onEnter() schedule(schedule_selector(SchedulerUnscheduleAllHard::unscheduleAll), 4); } -void SchedulerUnscheduleAllHard::tick1(ccTime dt) +void SchedulerUnscheduleAllHard::tick1(float dt) { CCLOG("tick1"); } -void SchedulerUnscheduleAllHard::tick2(ccTime dt) +void SchedulerUnscheduleAllHard::tick2(float dt) { CCLOG("tick2"); } -void SchedulerUnscheduleAllHard::tick3(ccTime dt) +void SchedulerUnscheduleAllHard::tick3(float dt) { CCLOG("tick3"); } -void SchedulerUnscheduleAllHard::tick4(ccTime dt) +void SchedulerUnscheduleAllHard::tick4(float dt) { CCLOG("tick4"); } -void SchedulerUnscheduleAllHard::unscheduleAll(ccTime dt) +void SchedulerUnscheduleAllHard::unscheduleAll(float dt) { CCDirector::sharedDirector()->getScheduler()->unscheduleAllSelectors(); } @@ -343,22 +343,22 @@ void SchedulerSchedulesAndRemove::onEnter() schedule(schedule_selector(SchedulerSchedulesAndRemove::scheduleAndUnschedule), 4.0f); } -void SchedulerSchedulesAndRemove::tick1(ccTime dt) +void SchedulerSchedulesAndRemove::tick1(float dt) { CCLOG("tick1"); } -void SchedulerSchedulesAndRemove::tick2(ccTime dt) +void SchedulerSchedulesAndRemove::tick2(float dt) { CCLOG("tick2"); } -void SchedulerSchedulesAndRemove::tick3(ccTime dt) +void SchedulerSchedulesAndRemove::tick3(float dt) { CCLOG("tick3"); } -void SchedulerSchedulesAndRemove::tick4(ccTime dt) +void SchedulerSchedulesAndRemove::tick4(float dt) { CCLOG("tick4"); } @@ -373,7 +373,7 @@ std::string SchedulerSchedulesAndRemove::subtitle() return "Will unschedule and schedule selectors in 4s. See console"; } -void SchedulerSchedulesAndRemove::scheduleAndUnschedule(ccTime dt) +void SchedulerSchedulesAndRemove::scheduleAndUnschedule(float dt) { unschedule(schedule_selector(SchedulerSchedulesAndRemove::tick1)); unschedule(schedule_selector(SchedulerSchedulesAndRemove::tick2)); @@ -454,7 +454,7 @@ void SchedulerUpdate::onEnter() schedule(schedule_selector(SchedulerUpdate::removeUpdates), 4.0f); } -void SchedulerUpdate::removeUpdates(ccTime dt) +void SchedulerUpdate::removeUpdates(float dt) { CCArray* children = getChildren(); CCNode* pNode; @@ -495,17 +495,17 @@ void SchedulerUpdateAndCustom::onEnter() schedule(schedule_selector(SchedulerUpdateAndCustom::stopSelectors), 0.4f); } -void SchedulerUpdateAndCustom::update(ccTime dt) +void SchedulerUpdateAndCustom::update(float dt) { CCLOG("update called:%f", dt); } -void SchedulerUpdateAndCustom::tick(ccTime dt) +void SchedulerUpdateAndCustom::tick(float dt) { CCLOG("custom selector called:%f",dt); } -void SchedulerUpdateAndCustom::stopSelectors(ccTime dt) +void SchedulerUpdateAndCustom::stopSelectors(float dt) { unscheduleAllSelectors(); } @@ -532,19 +532,19 @@ void SchedulerUpdateFromCustom::onEnter() schedule(schedule_selector(SchedulerUpdateFromCustom::schedUpdate), 2.0f); } -void SchedulerUpdateFromCustom::update(ccTime dt) +void SchedulerUpdateFromCustom::update(float dt) { CCLOG("update called:%f", dt); } -void SchedulerUpdateFromCustom::schedUpdate(ccTime dt) +void SchedulerUpdateFromCustom::schedUpdate(float dt) { unschedule(schedule_selector(SchedulerUpdateFromCustom::schedUpdate)); scheduleUpdate(); schedule(schedule_selector(SchedulerUpdateFromCustom::stopUpdate), 2.0f); } -void SchedulerUpdateFromCustom::stopUpdate(ccTime dt) +void SchedulerUpdateFromCustom::stopUpdate(float dt) { unscheduleUpdate(); unschedule(schedule_selector(SchedulerUpdateFromCustom::stopUpdate)); @@ -584,7 +584,7 @@ std::string RescheduleSelector::subtitle() return "Interval is 1 second, then 2, then 3..."; } -void RescheduleSelector::schedUpdate(ccTime dt) +void RescheduleSelector::schedUpdate(float dt) { m_nTicks++; @@ -616,7 +616,7 @@ std::string SchedulerDelayAndRepeat::subtitle() return "After 5 x executed, method unscheduled. See console"; } -void SchedulerDelayAndRepeat::update(ccTime dt) +void SchedulerDelayAndRepeat::update(float dt) { CCLog("update called:%f", dt); } @@ -639,7 +639,7 @@ CCControlSlider* SchedulerTimeScale::sliderCtl() void SchedulerTimeScale::sliderAction(CCObject* pSender) { CCControlSlider* pSliderCtl = (CCControlSlider*)pSender; - ccTime scale; + float scale; scale = pSliderCtl->getValue(); CCDirector::sharedDirector()->getScheduler()->setTimeScale(scale); @@ -730,7 +730,7 @@ CCControlSlider *TwoSchedulers::sliderCtl() void TwoSchedulers::sliderAction(CCObject* sender) { - ccTime scale; + float scale; CCControlSlider *slider = (CCControlSlider*) sender; scale = slider->getValue(); diff --git a/tests/tests/SchedulerTest/SchedulerTest.h b/tests/tests/SchedulerTest/SchedulerTest.h index 514105328f..f84899375f 100644 --- a/tests/tests/SchedulerTest/SchedulerTest.h +++ b/tests/tests/SchedulerTest/SchedulerTest.h @@ -36,10 +36,10 @@ public: virtual std::string title(); virtual std::string subtitle(); - void autoremove(ccTime dt); - void tick(ccTime dt); + void autoremove(float dt); + void tick(float dt); private: - ccTime accum; + float accum; }; class SchedulerPauseResume : public SchedulerTestLayer @@ -49,9 +49,9 @@ public: virtual std::string title(); virtual std::string subtitle(); - void tick1(ccTime dt); - void tick2(ccTime dt); - void pause(ccTime dt); + void tick1(float dt); + void tick2(float dt); + void pause(float dt); }; class SchedulerUnscheduleAll : public SchedulerTestLayer @@ -61,11 +61,11 @@ public: virtual std::string title(); virtual std::string subtitle(); - void tick1(ccTime dt); - void tick2(ccTime dt); - void tick3(ccTime dt); - void tick4(ccTime dt); - void unscheduleAll(ccTime dt); + void tick1(float dt); + void tick2(float dt); + void tick3(float dt); + void tick4(float dt); + void unscheduleAll(float dt); }; class SchedulerUnscheduleAllHard : public SchedulerTestLayer @@ -75,11 +75,11 @@ public: virtual std::string title(); virtual std::string subtitle(); - void tick1(ccTime dt); - void tick2(ccTime dt); - void tick3(ccTime dt); - void tick4(ccTime dt); - void unscheduleAll(ccTime dt); + void tick1(float dt); + void tick2(float dt); + void tick3(float dt); + void tick4(float dt); + void unscheduleAll(float dt); }; class SchedulerSchedulesAndRemove : public SchedulerTestLayer @@ -89,11 +89,11 @@ public: virtual std::string title(); virtual std::string subtitle(); - void tick1(ccTime dt); - void tick2(ccTime dt); - void tick3(ccTime dt); - void tick4(ccTime dt); - void scheduleAndUnschedule(ccTime dt); + void tick1(float dt); + void tick2(float dt); + void tick3(float dt); + void tick4(float dt); + void scheduleAndUnschedule(float dt); }; class SchedulerUpdate : public SchedulerTestLayer @@ -103,7 +103,7 @@ public: virtual std::string title(); virtual std::string subtitle(); - void removeUpdates(ccTime dt); + void removeUpdates(float dt); }; class SchedulerUpdateAndCustom : public SchedulerTestLayer @@ -113,9 +113,9 @@ public: virtual std::string title(); virtual std::string subtitle(); - void update(ccTime dt); - void tick(ccTime dt); - void stopSelectors(ccTime dt); + void update(float dt); + void tick(float dt); + void stopSelectors(float dt); }; class SchedulerUpdateFromCustom : public SchedulerTestLayer @@ -125,9 +125,9 @@ public: virtual std::string title(); virtual std::string subtitle(); - void update(ccTime dt); - void schedUpdate(ccTime dt); - void stopUpdate(ccTime dt); + void update(float dt); + void schedUpdate(float dt); + void stopUpdate(float dt); }; class TestNode : public CCNode @@ -147,7 +147,7 @@ public: virtual std::string title(); virtual std::string subtitle(); - void schedUpdate(ccTime dt); + void schedUpdate(float dt); private: float m_fInterval; int m_nTicks; @@ -159,7 +159,7 @@ public: virtual void onEnter(); virtual std::string title(); virtual std::string subtitle(); - void update(ccTime dt); + void update(float dt); }; class SchedulerTimeScale : public SchedulerTestLayer diff --git a/tests/tests/ShaderTest/ShaderTest.cpp b/tests/tests/ShaderTest/ShaderTest.cpp index 77df392079..c9709cdd59 100644 --- a/tests/tests/ShaderTest/ShaderTest.cpp +++ b/tests/tests/ShaderTest/ShaderTest.cpp @@ -194,7 +194,7 @@ void ShaderNode::loadShaderVertex(const char *vert, const char *frag) shader->release(); } -void ShaderNode::update(ccTime dt) +void ShaderNode::update(float dt) { m_time += dt; } @@ -662,7 +662,7 @@ bool ShaderRetroEffect::init() return false; } -void ShaderRetroEffect::update(ccTime dt) +void ShaderRetroEffect::update(float dt) { m_fAccum += dt; diff --git a/tests/tests/ShaderTest/ShaderTest.h b/tests/tests/ShaderTest/ShaderTest.h index 8912fd555f..99250a659c 100644 --- a/tests/tests/ShaderTest/ShaderTest.h +++ b/tests/tests/ShaderTest/ShaderTest.h @@ -102,10 +102,10 @@ public: virtual std::string title(); virtual std::string subtitle(); bool init(); - void update(ccTime dt); + void update(float dt); protected: CCLabelBMFont* m_pLabel; - ccTime m_fAccum; + float m_fAccum; }; class ShaderNode : public CCNode @@ -116,7 +116,7 @@ public: bool initWithVertex(const char *vert, const char *frag); void loadShaderVertex(const char *vert, const char *frag); - virtual void update(ccTime dt); + virtual void update(float dt); virtual void setPosition(const CCPoint &newPosition); virtual void draw(); diff --git a/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id b/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id index 648614cd0d..51d5c99134 100644 --- a/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id +++ b/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id @@ -1 +1 @@ -2e6b4ecbc083689855217489786150bb669823ed \ No newline at end of file +32985150da64bb4070f46022a1fb52ec24c22451 \ No newline at end of file diff --git a/tests/tests/SpriteTest/SpriteTest.h b/tests/tests/SpriteTest/SpriteTest.h index 2081ee3bad..e94da4971f 100644 --- a/tests/tests/SpriteTest/SpriteTest.h +++ b/tests/tests/SpriteTest/SpriteTest.h @@ -46,7 +46,7 @@ class SpriteColorOpacity : public SpriteTestDemo { public: SpriteColorOpacity(); - void removeAndAddSprite(ccTime dt); + void removeAndAddSprite(float dt); virtual std::string title(); }; @@ -54,7 +54,7 @@ class SpriteBatchNodeColorOpacity : public SpriteTestDemo { public: SpriteBatchNodeColorOpacity(); - void removeAndAddSprite(ccTime dt); + void removeAndAddSprite(float dt); virtual std::string title(); }; @@ -63,7 +63,7 @@ class SpriteZOrder : public SpriteTestDemo int m_dir; public: SpriteZOrder(); - void reorderSprite(ccTime dt); + void reorderSprite(float dt); virtual std::string title(); }; @@ -72,7 +72,7 @@ class SpriteBatchNodeZOrder: public SpriteTestDemo int m_dir; public: SpriteBatchNodeZOrder(); - void reorderSprite(ccTime dt); + void reorderSprite(float dt); virtual std::string title(); }; @@ -98,7 +98,7 @@ public: SpriteBatchNodeReorderIssue766(); virtual std::string title(); virtual std::string subtitle(); - void reorderSprite(ccTime dt); + void reorderSprite(float dt); CCSprite* makeSpriteZ(int aZ); private: @@ -114,7 +114,7 @@ public: SpriteBatchNodeReorderIssue767(); virtual std::string title(); virtual std::string subtitle(); - void reorderSprites(ccTime dt); + void reorderSprites(float dt); }; class SpriteZVertex: public SpriteTestDemo @@ -164,7 +164,7 @@ class SpriteFlip : public SpriteTestDemo { public: SpriteFlip(); - void flipSprites(ccTime dt); + void flipSprites(float dt); virtual std::string title(); }; @@ -172,7 +172,7 @@ class SpriteBatchNodeFlip : public SpriteTestDemo { public: SpriteBatchNodeFlip(); - void flipSprites(ccTime dt); + void flipSprites(float dt); virtual std::string title(); }; @@ -229,8 +229,8 @@ public: virtual std::string title(); virtual std::string subtitle(); - void startIn05Secs(ccTime dt); - void flipSprites(ccTime dt); + void startIn05Secs(float dt); + void flipSprites(float dt); private: CCSprite *m_pSprite1; CCSprite *m_pSprite2; @@ -341,7 +341,7 @@ class SpriteHybrid: public SpriteTestDemo bool m_usingSpriteBatchNode; public: SpriteHybrid(); - void reparentSprite(ccTime dt); + void reparentSprite(float dt); virtual std::string title(); virtual void onExit(); }; @@ -448,7 +448,7 @@ public: virtual std::string title(); virtual std::string subtitle(); - void reorderSprite(ccTime dt); + void reorderSprite(float dt); private: CCNode *m_pNode; @@ -466,7 +466,7 @@ public: virtual std::string title(); virtual std::string subtitle(); - void reorderSprite(ccTime dt); + void reorderSprite(float dt); private: CCSpriteBatchNode *m_pBatchNode; @@ -481,7 +481,7 @@ class SpriteBatchNodeReorderOneChild : public SpriteTestDemo { public: SpriteBatchNodeReorderOneChild(); - void reorderSprite(ccTime dt); + void reorderSprite(float dt); virtual std::string title(); private: CCSpriteBatchNode *m_pBatchNode; diff --git a/tests/tests/TextInputTest/TextInputTest.cpp b/tests/tests/TextInputTest/TextInputTest.cpp index 773a789553..d870c6447a 100644 --- a/tests/tests/TextInputTest/TextInputTest.cpp +++ b/tests/tests/TextInputTest/TextInputTest.cpp @@ -409,7 +409,7 @@ bool TextFieldTTFActionTest::onTextFieldInsertText(CCTextFieldTTF * pSender, con CCSize inputTextSize = label->getContentSize(); CCPoint beginPos(endPos.x, CCDirector::sharedDirector()->getWinSize().height - inputTextSize.height * 2); - ccTime duration = 0.5; + float duration = 0.5; label->setPosition(beginPos); label->setScale(8); @@ -440,8 +440,8 @@ bool TextFieldTTFActionTest::onTextFieldDeleteBackward(CCTextFieldTTF * pSender, CCSize winSize = CCDirector::sharedDirector()->getWinSize(); CCPoint endPos(- winSize.width / 4.0f, winSize.height * (0.5 + (float)rand() / (2.0f * RAND_MAX))); - ccTime duration = 1; - ccTime rotateDuration = 0.2f; + float duration = 1; + float rotateDuration = 0.2f; int repeatTime = 5; label->setPosition(beginPos); diff --git a/tests/tests/Texture2dTest/Texture2dTest.cpp b/tests/tests/Texture2dTest/Texture2dTest.cpp index a26be88810..545d686269 100644 --- a/tests/tests/Texture2dTest/Texture2dTest.cpp +++ b/tests/tests/Texture2dTest/Texture2dTest.cpp @@ -1133,7 +1133,7 @@ TextureAsync::~TextureAsync() CCTextureCache::sharedTextureCache()->removeAllTextures(); } -void TextureAsync::loadImages(ccTime dt) +void TextureAsync::loadImages(float dt) { for( int i=0;i < 8;i++) { for( int j=0;j < 8; j++) { diff --git a/tests/tests/Texture2dTest/Texture2dTest.h b/tests/tests/Texture2dTest/Texture2dTest.h index 3e30455cd5..ad0c837a19 100644 --- a/tests/tests/Texture2dTest/Texture2dTest.h +++ b/tests/tests/Texture2dTest/Texture2dTest.h @@ -234,7 +234,7 @@ class TextureAsync : public TextureDemo { public: virtual ~TextureAsync(); - void loadImages(ccTime dt); + void loadImages(float dt); void imageLoaded(CCObject* pObj); virtual std::string title(); virtual std::string subtitle(); diff --git a/tests/tests/TileMapTest/TileMapTest.cpp b/tests/tests/TileMapTest/TileMapTest.cpp index 7a9a7d918b..41cdc6812c 100644 --- a/tests/tests/TileMapTest/TileMapTest.cpp +++ b/tests/tests/TileMapTest/TileMapTest.cpp @@ -70,7 +70,7 @@ TileMapEditTest::TileMapEditTest() map->setPosition( ccp(-20,-200) ); } -void TileMapEditTest::updateMap(ccTime dt) +void TileMapEditTest::updateMap(float dt) { // IMPORTANT // The only limitation is that you cannot change an empty, or assign an empty tile to a tile @@ -278,7 +278,7 @@ TMXOrthoTest4::TMXOrthoTest4() } -void TMXOrthoTest4::removeSprite(ccTime dt) +void TMXOrthoTest4::removeSprite(float dt) { unschedule(schedule_selector(TMXOrthoTest4::removeSprite)); @@ -376,7 +376,7 @@ void TMXReadWriteTest::removeSprite(CCNode* sender) //////----UXLOG("atlas quantity: %d", p->textureAtlas()->totalQuads()); } -void TMXReadWriteTest::updateCol(ccTime dt) +void TMXReadWriteTest::updateCol(float dt) { CCTMXTiledMap* map = (CCTMXTiledMap*)getChildByTag(kTagTileMap); CCTMXLayer *layer = (CCTMXLayer*)map->getChildByTag(0); @@ -395,7 +395,7 @@ void TMXReadWriteTest::updateCol(ccTime dt) m_gid2 = (m_gid2 + 1) % 80; } -void TMXReadWriteTest::repaintWithGID(ccTime dt) +void TMXReadWriteTest::repaintWithGID(float dt) { // unschedule:_cmd); @@ -411,7 +411,7 @@ void TMXReadWriteTest::repaintWithGID(ccTime dt) } } -void TMXReadWriteTest::removeTiles(ccTime dt) +void TMXReadWriteTest::removeTiles(float dt) { unschedule(schedule_selector(TMXReadWriteTest::removeTiles)); @@ -835,7 +835,7 @@ void TMXIsoZorder::onExit() TileDemo::onExit(); } -void TMXIsoZorder::repositionSprite(ccTime dt) +void TMXIsoZorder::repositionSprite(float dt) { CCPoint p = m_tamara->getPosition(); p = CC_POINT_POINTS_TO_PIXELS(p); @@ -895,7 +895,7 @@ TMXOrthoZorder::~TMXOrthoZorder() m_tamara->release(); } -void TMXOrthoZorder::repositionSprite(ccTime dt) +void TMXOrthoZorder::repositionSprite(float dt) { CCPoint p = m_tamara->getPosition(); p = CC_POINT_POINTS_TO_PIXELS(p); @@ -958,7 +958,7 @@ TMXIsoVertexZ::~TMXIsoVertexZ() m_tamara->release(); } -void TMXIsoVertexZ::repositionSprite(ccTime dt) +void TMXIsoVertexZ::repositionSprite(float dt) { // tile height is 64x32 // map size: 30x30 @@ -1028,7 +1028,7 @@ TMXOrthoVertexZ::~TMXOrthoVertexZ() m_tamara->release(); } -void TMXOrthoVertexZ::repositionSprite(ccTime dt) +void TMXOrthoVertexZ::repositionSprite(float dt) { // tile height is 101x81 // map size: 12x12 @@ -1207,7 +1207,7 @@ std::string TMXOrthoFlipRunTimeTest::subtitle() return "in 2 sec bottom left tiles will flip"; } -void TMXOrthoFlipRunTimeTest::flipIt(ccTime dt) +void TMXOrthoFlipRunTimeTest::flipIt(float dt) { CCTMXTiledMap *map = (CCTMXTiledMap*) getChildByTag(kTagTileMap); CCTMXLayer *layer = map->layerNamed("Layer 0"); diff --git a/tests/tests/TileMapTest/TileMapTest.h b/tests/tests/TileMapTest/TileMapTest.h index 1c3ae4109b..e903dd9adb 100644 --- a/tests/tests/TileMapTest/TileMapTest.h +++ b/tests/tests/TileMapTest/TileMapTest.h @@ -41,7 +41,7 @@ public: TileMapEditTest (void); virtual std::string title(); - void updateMap(ccTime dt); + void updateMap(float dt); }; class TMXOrthoTest : public TileDemo @@ -72,7 +72,7 @@ class TMXOrthoTest4 : public TileDemo { public: TMXOrthoTest4(void); - void removeSprite(ccTime dt); + void removeSprite(float dt); virtual std::string title(); }; @@ -85,9 +85,9 @@ public: virtual std::string title(); void removeSprite(CCNode* sender); - void updateCol(ccTime dt); - void repaintWithGID(ccTime dt); - void removeTiles(ccTime dt); + void updateCol(float dt); + void repaintWithGID(float dt); + void removeTiles(float dt); }; class TMXHexTest : public TileDemo @@ -173,7 +173,7 @@ public: virtual void onExit(void); ~TMXIsoZorder(); - void repositionSprite(ccTime dt); + void repositionSprite(float dt); }; class TMXOrthoZorder : public TileDemo @@ -185,7 +185,7 @@ public: virtual std::string subtitle(); virtual ~TMXOrthoZorder(); - void repositionSprite(ccTime dt); + void repositionSprite(float dt); }; class TMXIsoVertexZ : public TileDemo @@ -197,7 +197,7 @@ public: virtual std::string subtitle(); ~TMXIsoVertexZ(); - void repositionSprite(ccTime dt); + void repositionSprite(float dt); virtual void onEnter(); virtual void onExit(); }; @@ -211,7 +211,7 @@ public: virtual std::string subtitle(); ~TMXOrthoVertexZ(); - void repositionSprite(ccTime dt); + void repositionSprite(float dt); virtual void onEnter(); virtual void onExit(); }; @@ -253,7 +253,7 @@ public: TMXOrthoFlipRunTimeTest(); virtual std::string title(); virtual std::string subtitle(); - void flipIt(ccTime dt); + void flipIt(float dt); }; class TMXOrthoFromXMLTest : public TileDemo diff --git a/tests/tests/TouchesTest/Ball.cpp b/tests/tests/TouchesTest/Ball.cpp index df68e7d8e5..a070367bbd 100644 --- a/tests/tests/TouchesTest/Ball.cpp +++ b/tests/tests/TouchesTest/Ball.cpp @@ -23,7 +23,7 @@ Ball* Ball::ballWithTexture(CCTexture2D* aTexture) return pBall; } -void Ball::move(ccTime delta) +void Ball::move(float delta) { this->setPosition( ccpAdd(getPosition(), ccpMult(m_velocity, delta)) ); diff --git a/tests/tests/TouchesTest/Ball.h b/tests/tests/TouchesTest/Ball.h index fa10d416a8..e3ed1def0f 100644 --- a/tests/tests/TouchesTest/Ball.h +++ b/tests/tests/TouchesTest/Ball.h @@ -17,7 +17,7 @@ public: float radius(); //BOOL initWithTexture(CCTexture2D* aTexture); //virtual void setTexture(CCTexture2D* newTexture); - void move(ccTime delta); + void move(float delta); void collideWithPaddle(Paddle* paddle); diff --git a/tests/tests/TouchesTest/TouchesTest.cpp b/tests/tests/TouchesTest/TouchesTest.cpp index d91acdcc45..ad97c1d64d 100644 --- a/tests/tests/TouchesTest/TouchesTest.cpp +++ b/tests/tests/TouchesTest/TouchesTest.cpp @@ -103,7 +103,7 @@ void PongLayer::resetAndScoreBallForPlayer(int player) // TODO -- scoring } -void PongLayer::doStep(ccTime delta) +void PongLayer::doStep(float delta) { m_ball->move(delta); diff --git a/tests/tests/TouchesTest/TouchesTest.h b/tests/tests/TouchesTest/TouchesTest.h index 571a50f625..b3ff280a75 100644 --- a/tests/tests/TouchesTest/TouchesTest.h +++ b/tests/tests/TouchesTest/TouchesTest.h @@ -29,7 +29,7 @@ public: ~PongLayer(); void resetAndScoreBallForPlayer(int player); - void doStep(ccTime delta); + void doStep(float delta); }; #endif diff --git a/tests/tests/TransitionsTest/TransitionsTest.cpp b/tests/tests/TransitionsTest/TransitionsTest.cpp index 1ecb7266f4..079eae62b9 100644 --- a/tests/tests/TransitionsTest/TransitionsTest.cpp +++ b/tests/tests/TransitionsTest/TransitionsTest.cpp @@ -7,7 +7,7 @@ class FadeWhiteTransition : public CCTransitionFade { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionFade::transitionWithDuration(t, s, ccWHITE); } @@ -16,7 +16,7 @@ public: class FlipXLeftOver : public CCTransitionFlipX { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionFlipX::transitionWithDuration(t, s, kOrientationLeftOver); } @@ -25,7 +25,7 @@ public: class FlipXRightOver : public CCTransitionFlipX { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionFlipX::transitionWithDuration(t, s, kOrientationRightOver); } @@ -34,7 +34,7 @@ public: class FlipYUpOver : public CCTransitionFlipY { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionFlipY::transitionWithDuration(t, s, kOrientationUpOver); } @@ -43,7 +43,7 @@ public: class FlipYDownOver : public CCTransitionFlipY { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionFlipY::transitionWithDuration(t, s, kOrientationDownOver); } @@ -52,7 +52,7 @@ public: class FlipAngularLeftOver : public CCTransitionFlipAngular { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionFlipAngular::transitionWithDuration(t, s, kOrientationLeftOver); } @@ -61,7 +61,7 @@ public: class FlipAngularRightOver : public CCTransitionFlipAngular { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionFlipAngular::transitionWithDuration(t, s, kOrientationRightOver); } @@ -70,7 +70,7 @@ public: class ZoomFlipXLeftOver : public CCTransitionZoomFlipX { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionZoomFlipX::transitionWithDuration(t, s, kOrientationLeftOver); } @@ -79,7 +79,7 @@ public: class ZoomFlipXRightOver : public CCTransitionZoomFlipX { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionZoomFlipX::transitionWithDuration(t, s, kOrientationRightOver); } @@ -88,7 +88,7 @@ public: class ZoomFlipYUpOver : public CCTransitionZoomFlipY { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionZoomFlipY::transitionWithDuration(t, s, kOrientationUpOver); @@ -98,7 +98,7 @@ public: class ZoomFlipYDownOver : public CCTransitionZoomFlipY { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionZoomFlipY::transitionWithDuration(t, s, kOrientationDownOver); } @@ -107,7 +107,7 @@ public: class ZoomFlipAngularLeftOver : public CCTransitionZoomFlipAngular { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionZoomFlipAngular::transitionWithDuration(t, s, kOrientationLeftOver); } @@ -116,7 +116,7 @@ public: class ZoomFlipAngularRightOver : public CCTransitionZoomFlipAngular { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionZoomFlipAngular::transitionWithDuration(t, s, kOrientationRightOver); } @@ -125,7 +125,7 @@ public: class PageTransitionForward : public CCTransitionPageTurn { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { CCDirector::sharedDirector()->setDepthTest(true); return CCTransitionPageTurn::transitionWithDuration(t, s, false); @@ -135,7 +135,7 @@ public: class PageTransitionBackward : public CCTransitionPageTurn { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { CCDirector::sharedDirector()->setDepthTest(true); return CCTransitionPageTurn::transitionWithDuration(t, s, true); @@ -198,7 +198,7 @@ static std::string transitions[MAX_LAYER] = { }; static int s_nSceneIdx = 0; -CCTransitionScene* createTransition(int nIndex, ccTime t, CCScene* s) +CCTransitionScene* createTransition(int nIndex, float t, CCScene* s) { // fix bug #486, without setDepthTest(false), FlipX,Y will flickers CCDirector::sharedDirector()->setDepthTest(false); @@ -374,7 +374,7 @@ void TestLayer1::backCallback(CCObject* pSender) } } -void TestLayer1::step(ccTime dt) +void TestLayer1::step(float dt) { } @@ -503,7 +503,7 @@ void TestLayer2::backCallback(CCObject* pSender) } } -void TestLayer2::step(ccTime dt) +void TestLayer2::step(float dt) { } diff --git a/tests/tests/TransitionsTest/TransitionsTest.h b/tests/tests/TransitionsTest/TransitionsTest.h index 80c5085998..993aab241d 100644 --- a/tests/tests/TransitionsTest/TransitionsTest.h +++ b/tests/tests/TransitionsTest/TransitionsTest.h @@ -21,7 +21,7 @@ public: void nextCallback(CCObject* pSender); void backCallback(CCObject* pSender); - void step(ccTime dt); + void step(float dt); virtual void onEnter(); virtual void onEnterTransitionDidFinish(); @@ -39,7 +39,7 @@ public: void nextCallback(CCObject* pSender); void backCallback(CCObject* pSender); - void step(ccTime dt); + void step(float dt); virtual void onEnter(); virtual void onEnterTransitionDidFinish(); diff --git a/tests/tests/ZwoptexTest/ZwoptexTest.cpp b/tests/tests/ZwoptexTest/ZwoptexTest.cpp index 95182c4fef..77e23098a8 100644 --- a/tests/tests/ZwoptexTest/ZwoptexTest.cpp +++ b/tests/tests/ZwoptexTest/ZwoptexTest.cpp @@ -162,14 +162,14 @@ void ZwoptexGenericTest::onEnter() counter = 0; } -void ZwoptexGenericTest::startIn05Secs(ccTime dt) +void ZwoptexGenericTest::startIn05Secs(float dt) { unschedule(schedule_selector(ZwoptexGenericTest::startIn05Secs)); schedule(schedule_selector(ZwoptexGenericTest::flipSprites), 0.5f); } static int spriteFrameIndex = 0; -void ZwoptexGenericTest::flipSprites(ccTime dt) +void ZwoptexGenericTest::flipSprites(float dt) { counter++; diff --git a/tests/tests/ZwoptexTest/ZwoptexTest.h b/tests/tests/ZwoptexTest/ZwoptexTest.h index 24bae86da2..85fc9074c8 100644 --- a/tests/tests/ZwoptexTest/ZwoptexTest.h +++ b/tests/tests/ZwoptexTest/ZwoptexTest.h @@ -21,8 +21,8 @@ class ZwoptexGenericTest : public ZwoptexTest public: ~ZwoptexGenericTest(); virtual void onEnter(); - void flipSprites(ccTime dt); - void startIn05Secs(ccTime dt); + void flipSprites(float dt); + void startIn05Secs(float dt); virtual std::string title(); virtual std::string subtitle(); From c5cf23c8594f35b7c696abc2cd958d450467b61f Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 8 Jun 2012 14:11:48 +0800 Subject: [PATCH 096/257] issue #1310: First commit since sync to rc2. --- cocos2dx/CCConfiguration.cpp | 6 +- cocos2dx/CCConfiguration.h | 11 +- cocos2dx/CCDirector.cpp | 31 +- cocos2dx/CCDrawingPrimitives.cpp | 74 ++- cocos2dx/CCDrawingPrimitives.h | 30 +- cocos2dx/CCScheduler.cpp | 97 ++- cocos2dx/CCScheduler.h | 31 + cocos2dx/cocoa/CCArray.cpp | 179 +++++- cocos2dx/cocoa/CCArray.h | 23 +- cocos2dx/cocoa/CCObject.h | 4 +- cocos2dx/cocos2d.cpp | 2 +- cocos2dx/include/ccTypes.h | 30 +- cocos2dx/misc_nodes/CCMotionStreak.cpp | 38 +- cocos2dx/misc_nodes/CCMotionStreak.h | 3 + .../particle_nodes/CCParticleBatchNode.cpp | 2 +- cocos2dx/particle_nodes/CCParticleSystem.cpp | 50 +- cocos2dx/particle_nodes/CCParticleSystem.h | 8 +- .../particle_nodes/CCParticleSystemQuad.cpp | 10 +- .../particle_nodes/CCParticleSystemQuad.h | 8 +- cocos2dx/proj.win32/cocos2d-win32.vcproj | 4 + cocos2dx/sprite_nodes/CCSprite.cpp | 21 +- cocos2dx/sprite_nodes/CCSprite.h | 2 +- cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp | 2 +- cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp | 117 ++-- cocos2dx/sprite_nodes/CCSpriteFrameCache.h | 13 +- cocos2dx/support/CCVertex.cpp | 7 +- cocos2dx/support/CCVertex.h | 4 +- cocos2dx/support/data_support/ccCArray.cpp | 584 ++++++++++++++++++ cocos2dx/support/data_support/ccCArray.h | 498 ++++----------- cocos2dx/textures/CCTexture2D.cpp | 99 ++- cocos2dx/textures/CCTexture2D.h | 33 +- cocos2dx/textures/CCTexturePVR.cpp | 2 +- cocos2dx/textures/CCTexturePVR.h | 2 +- .../tileMap_parallax_nodes/CCTMXLayer.cpp | 67 +- .../tileMap_parallax_nodes/CCTMXXMLParser.cpp | 1 + .../tileMap_parallax_nodes/CCTileMapAtlas.cpp | 4 +- 36 files changed, 1517 insertions(+), 580 deletions(-) create mode 100644 cocos2dx/support/data_support/ccCArray.cpp diff --git a/cocos2dx/CCConfiguration.cpp b/cocos2dx/CCConfiguration.cpp index 8eba9c1b69..50bdd35109 100644 --- a/cocos2dx/CCConfiguration.cpp +++ b/cocos2dx/CCConfiguration.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2010 Ricardo Quesada http://www.cocos2d-x.org @@ -41,6 +41,7 @@ CCConfiguration::CCConfiguration(void) , m_bSupportsPVRTC(false) , m_bSupportsNPOT(false) , m_bSupportsBGRA8888(false) +, m_bSupportsShareableVAO(false) , m_bSupportsDiscardFramebuffer(false) , m_nMaxSamplesAllowed(0) , m_pGlExtensions(NULL) @@ -66,12 +67,15 @@ bool CCConfiguration::init(void) m_bSupportsBGRA8888 = checkForGLExtension("GL_IMG_texture_format_BGRA888"); m_bSupportsDiscardFramebuffer = checkForGLExtension("GL_EXT_discard_framebuffer"); + m_bSupportsShareableVAO = checkForGLExtension("vertex_array_object"); + CCLOG("cocos2d: GL_MAX_TEXTURE_SIZE: %d", m_nMaxTextureSize); CCLOG("cocos2d: GL_MAX_TEXTURE_UNITS: %d",m_nMaxTextureUnits); CCLOG("cocos2d: GL supports PVRTC: %s", (m_bSupportsPVRTC ? "YES" : "NO")); CCLOG("cocos2d: GL supports BGRA8888 textures: %s", (m_bSupportsBGRA8888 ? "YES" : "NO")); CCLOG("cocos2d: GL supports NPOT textures: %s", (m_bSupportsNPOT ? "YES" : "NO")); CCLOG("cocos2d: GL supports discard_framebuffer: %s", (m_bSupportsDiscardFramebuffer ? "YES" : "NO")); + CCLOG("cocos2d: GL supports shareable VAO: %s", (m_bSupportsShareableVAO ? "YES" : "NO") ); bool bEnableProfilers = false; diff --git a/cocos2dx/CCConfiguration.h b/cocos2dx/CCConfiguration.h index 13a0f2274c..299aef6772 100644 --- a/cocos2dx/CCConfiguration.h +++ b/cocos2dx/CCConfiguration.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2010 Ricardo Quesada http://www.cocos2d-x.org @@ -97,6 +97,14 @@ public: return m_bSupportsDiscardFramebuffer; } + /** Whether or not shareable VAOs are supported. + @since v2.0.0 + */ + inline bool isSupportsShareableVAO(void) + { + return m_bSupportsShareableVAO; + } + /** returns whether or not an OpenGL is supported */ bool checkForGLExtension(const std::string &searchName); @@ -113,6 +121,7 @@ protected: bool m_bSupportsNPOT; bool m_bSupportsBGRA8888; bool m_bSupportsDiscardFramebuffer; + bool m_bSupportsShareableVAO; GLint m_nMaxSamplesAllowed; GLint m_nMaxTextureUnits; char * m_pGlExtensions; diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 8ac31f5911..32fdeeee2f 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. @@ -357,11 +357,11 @@ void CCDirector::setProjection(ccDirectorProjection kProjection) case kCCDirectorProjection3D: { - // reset the viewport if 3d proj & retina display - if( CC_CONTENT_SCALE_FACTOR() != 1.0f ) - { - glViewport((GLint)-size.width/2, (GLint)-size.height/2, (GLsizei)(size.width * CC_CONTENT_SCALE_FACTOR()), (GLsizei)(size.height * CC_CONTENT_SCALE_FACTOR()) ); - } +//cjh // reset the viewport if 3d proj & retina display +// if( CC_CONTENT_SCALE_FACTOR() != 1.0f ) +// { +// glViewport((GLint)-size.width/2, (GLint)-size.height/2, (GLsizei)(size.width * CC_CONTENT_SCALE_FACTOR()), (GLsizei)(size.height * CC_CONTENT_SCALE_FACTOR()) ); +// } float zeye = this->getZEye(); @@ -371,14 +371,17 @@ void CCDirector::setProjection(ccDirectorProjection kProjection) kmGLLoadIdentity(); // issue #1334 - if (m_pobOpenGLView && m_pobOpenGLView->isIpad() && m_pobOpenGLView->getMainScreenScale() > 1.0f) - { - kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, zeye-size.height/2, zeye+size.height/2); - } - else - { - kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.5f, 1500); - } + kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, zeye*2); + // kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, 1500); + +//cjh if (m_pobOpenGLView && m_pobOpenGLView->isIpad() && m_pobOpenGLView->getMainScreenScale() > 1.0f) +// { +// kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, zeye-size.height/2, zeye+size.height/2); +// } +// else +// { +// kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.5f, 1500); +// } // kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, 1500); kmGLMultMatrix(&matrixPerspective); diff --git a/cocos2dx/CCDrawingPrimitives.cpp b/cocos2dx/CCDrawingPrimitives.cpp index d8032cfc29..8a54460889 100644 --- a/cocos2dx/CCDrawingPrimitives.cpp +++ b/cocos2dx/CCDrawingPrimitives.cpp @@ -32,6 +32,7 @@ THE SOFTWARE. #include "ccGLStateCache.h" #include "CCShaderCache.h" #include "CCGLProgram.h" +#include "CCActionCatmullRom.h" #include #include @@ -154,6 +155,25 @@ void ccDrawLine( const CCPoint& origin, const CCPoint& destination ) CC_INCREMENT_GL_DRAWS(1); } +void ccDrawRect( CCPoint origin, CCPoint destination ) +{ + ccDrawLine(CCPointMake(origin.x, origin.y), CCPointMake(destination.x, origin.y)); + ccDrawLine(CCPointMake(destination.x, origin.y), CCPointMake(destination.x, destination.y)); + ccDrawLine(CCPointMake(destination.x, destination.y), CCPointMake(origin.x, destination.y)); + ccDrawLine(CCPointMake(origin.x, destination.y), CCPointMake(origin.x, origin.y)); +} + +void ccDrawSolidRect( CCPoint origin, CCPoint destination, ccColor4F color ) +{ + CCPoint vertices[] = { + origin, + {destination.x, origin.y}, + destination, + {origin.x, destination.y}, + }; + + ccDrawSolidPoly(vertices, 4, color ); +} void ccDrawPoly( const CCPoint *poli, unsigned int numberOfPoints, bool closePolygon ) { @@ -192,7 +212,7 @@ void ccDrawPoly( const CCPoint *poli, unsigned int numberOfPoints, bool closePol CC_INCREMENT_GL_DRAWS(1); } -void ccDrawFilledPoly( const CCPoint *poli, unsigned int numberOfPoints, ccColor4F color ) +void ccDrawSolidPoly( const CCPoint *poli, unsigned int numberOfPoints, ccColor4F color ) { lazy_init(); @@ -294,6 +314,58 @@ void ccDrawQuadBezier(const CCPoint& origin, const CCPoint& control, const CCPoi CC_INCREMENT_GL_DRAWS(1); } +void ccDrawCatmullRom( CCPointArray *points, unsigned int segments ) +{ + ccDrawCardinalSpline( points, 0.5f, segments ); +} + +void ccDrawCardinalSpline( CCPointArray *config, CCFloat tension, unsigned int segments ) +{ + lazy_init(); + + ccVertex2F* vertices = new ccVertex2F[segments + 1]; + + unsigned int p; + CCFloat lt; + CCFloat deltaT = 1.0f / config->count(); + + for( unsigned int i=0; i < segments+1;i++) { + + CCFloat dt = (CCFloat)i / segments; + + // border + if( dt == 1 ) { + p = config->count() - 1; + lt = 1; + } else { + p = dt / deltaT; + lt = (dt - deltaT * (CCFloat)p) / deltaT; + } + + // Interpolate + CCPoint pp0 = config->getControlPointAtIndex(p-1); + CCPoint pp1 = config->getControlPointAtIndex(p+0); + CCPoint pp2 = config->getControlPointAtIndex(p+1); + CCPoint pp3 = config->getControlPointAtIndex(p+2); + + CCPoint newPos = ccCardinalSplineAt( pp0, pp1, pp2, pp3, tension, lt); + vertices[i].x = newPos.x; + vertices[i].y = newPos.y; + } + + shader_->use(); + shader_->setUniformForModelViewProjectionMatrix(); + shader_->setUniformLocationWith4fv(colorLocation_, (GLfloat*)&color_.r, 1); + + ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); + + glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); + glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments + 1); + + CC_SAFE_DELETE_ARRAY(vertices); + CC_INCREMENT_GL_DRAWS(1); +} + void ccDrawCubicBezier(const CCPoint& origin, const CCPoint& control1, const CCPoint& control2, const CCPoint& destination, unsigned int segments) { lazy_init(); diff --git a/cocos2dx/CCDrawingPrimitives.h b/cocos2dx/CCDrawingPrimitives.h index 4b65fe690c..a57b503ef1 100644 --- a/cocos2dx/CCDrawingPrimitives.h +++ b/cocos2dx/CCDrawingPrimitives.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. @@ -49,6 +49,8 @@ THE SOFTWARE. NS_CC_BEGIN +class CCPointArray; + /** initlialize context */ void CC_DLL ccDrawInit(); @@ -63,28 +65,50 @@ void CC_DLL ccDrawPoints( const CCPoint *points, unsigned int numberOfPoints ); /** draws a line given the origin and destination point measured in points */ void CC_DLL ccDrawLine( const CCPoint& origin, const CCPoint& destination ); +/** draws a rectangle given the origin and destination point measured in points. */ +void CC_DLL ccDrawRect( CCPoint origin, CCPoint destination ); + +/** draws a solid rectangle given the origin and destination point measured in points. + @since 1.1 + */ +void CC_DLL ccDrawSolidRect( CCPoint origin, CCPoint destination, ccColor4F color ); + /** draws a poligon given a pointer to CCPoint coordiantes and the number of vertices measured in points. The polygon can be closed or open */ void CC_DLL ccDrawPoly( const CCPoint *vertices, unsigned int numOfVertices, bool closePolygon ); -/** draws a filled polygon given a pointer to CGPoint coordiantes, the number of vertices measured in points, and a color. +/** draws a solid polygon given a pointer to CGPoint coordiantes, the number of vertices measured in points, and a color. */ -void CC_DLL ccDrawFilledPoly( const CCPoint *poli, unsigned int numberOfPoints, ccColor4F color ); +void CC_DLL ccDrawSolidPoly( const CCPoint *poli, unsigned int numberOfPoints, ccColor4F color ); /** draws a circle given the center, radius and number of segments. */ void CC_DLL ccDrawCircle( const CCPoint& center, float radius, float angle, unsigned int segments, bool drawLineToCenter); /** draws a quad bezier path + @warning This function could be pretty slow. Use it only for debugging purposes. @since v0.8 */ void CC_DLL ccDrawQuadBezier(const CCPoint& origin, const CCPoint& control, const CCPoint& destination, unsigned int segments); /** draws a cubic bezier path + @warning This function could be pretty slow. Use it only for debugging purposes. @since v0.8 */ void CC_DLL ccDrawCubicBezier(const CCPoint& origin, const CCPoint& control1, const CCPoint& control2, const CCPoint& destination, unsigned int segments); +/** draws a Catmull Rom path. + @warning This function could be pretty slow. Use it only for debugging purposes. + @since v2.0 + */ +void CC_DLL ccDrawCatmullRom( CCPointArray *arrayOfControlPoints, unsigned int segments ); + +/** draws a Cardinal Spline path. + @warning This function could be pretty slow. Use it only for debugging purposes. + @since v2.0 + */ +void CC_DLL ccDrawCardinalSpline( CCPointArray *config, CCFloat tension, unsigned int segments ); + /** set the drawing color with 4 unsigned bytes @since v2.0 */ diff --git a/cocos2dx/CCScheduler.cpp b/cocos2dx/CCScheduler.cpp index ebe3de1ba9..b882d7dd05 100644 --- a/cocos2dx/CCScheduler.cpp +++ b/cocos2dx/CCScheduler.cpp @@ -256,8 +256,8 @@ void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, ccTime fInterval, bool bPaused, unsigned int repeat, ccTime delay) { - CCAssert(pfnSelector, ""); - CCAssert(pTarget, ""); + CCAssert(pfnSelector, "Argument selector must be non-NULL"); + CCAssert(pTarget, "Argument target must be non-NULL"); tHashSelectorEntry *pElement = NULL; HASH_FIND_INT(m_pHashForSelectors, &pTarget, pElement); @@ -292,7 +292,7 @@ void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, if (pfnSelector == timer->m_pfnSelector) { - CCLOG("CCSheduler#scheduleSelector. Selector already scheduled."); + CCLOG("CCScheduler#scheduleSelector. Selector already scheduled. Updating interval from: %.4f to %.4f", timer->getInterval(), fInterval); timer->m_fInterval = fInterval; return; } @@ -510,6 +510,11 @@ void CCScheduler::unscheduleUpdateForTarget(const CCObject *pTarget) } void CCScheduler::unscheduleAllSelectors(void) +{ + unscheduleAllSelectorsWithMinPriority(kCCPrioritySystem); +} + +void CCScheduler::unscheduleAllSelectorsWithMinPriority(int nMinPriority) { // Custom Selectors tHashSelectorEntry *pElement = NULL; @@ -525,17 +530,31 @@ void CCScheduler::unscheduleAllSelectors(void) // Updates selectors tListEntry *pEntry, *pTmp; - DL_FOREACH_SAFE(m_pUpdates0List, pEntry, pTmp) + if(nMinPriority < 0) { - unscheduleUpdateForTarget(pEntry->target); + DL_FOREACH_SAFE(m_pUpdatesNegList, pEntry, pTmp) + { + if(pEntry->priority >= nMinPriority) + { + unscheduleUpdateForTarget(pEntry->target); + } + } } - DL_FOREACH_SAFE(m_pUpdatesNegList, pEntry, pTmp) + + if(nMinPriority <= 0) { - unscheduleUpdateForTarget(pEntry->target); + DL_FOREACH_SAFE(m_pUpdates0List, pEntry, pTmp) + { + unscheduleUpdateForTarget(pEntry->target); + } } + DL_FOREACH_SAFE(m_pUpdatesPosList, pEntry, pTmp) { - unscheduleUpdateForTarget(pEntry->target); + if(pEntry->priority >= nMinPriority) + { + unscheduleUpdateForTarget(pEntry->target); + } } if (m_pScriptHandlerEntries) @@ -663,6 +682,68 @@ bool CCScheduler::isTargetPaused(CCObject *pTarget) return false; // should never get here } +CCSet* CCScheduler::pauseAllTargets() +{ + return pauseAllTargetsWithMinPriority(kCCPrioritySystem); +} + +CCSet* CCScheduler::pauseAllTargetsWithMinPriority(int nMinPriority) +{ + CCSet* idsWithSelectors = new CCSet();// setWithCapacity:50]; + idsWithSelectors->autorelease(); + + // Custom Selectors + for(tHashSelectorEntry *element = m_pHashForSelectors; element != NULL; + element = (tHashSelectorEntry*)element->hh.next) + { + element->paused = true; + idsWithSelectors->addObject(element->target); + } + + // Updates selectors + tListEntry *entry, *tmp; + if(nMinPriority < 0) + { + DL_FOREACH_SAFE( m_pUpdatesNegList, entry, tmp ) + { + if(entry->priority >= nMinPriority) + { + entry->paused = true; + idsWithSelectors->addObject(entry->target); + } + } + } + + if(nMinPriority <= 0) + { + DL_FOREACH_SAFE( m_pUpdates0List, entry, tmp ) + { + entry->paused = true; + idsWithSelectors->addObject(entry->target); + } + } + + DL_FOREACH_SAFE( m_pUpdatesPosList, entry, tmp ) + { + if(entry->priority >= nMinPriority) + { + entry->paused = true; + idsWithSelectors->addObject(entry->target); + } + } + + return idsWithSelectors; +} + +void CCScheduler::resumeTargets(CCSet* pTargetsToResume) +{ + CCSetIterator iter; + for (iter = pTargetsToResume->begin(); iter != pTargetsToResume->end(); ++iter) + { + resumeTarget(*iter); + } +} + // main loop void CCScheduler::update(ccTime dt) { diff --git a/cocos2dx/CCScheduler.h b/cocos2dx/CCScheduler.h index ed2e0d6d67..8fbe6be0cb 100644 --- a/cocos2dx/CCScheduler.h +++ b/cocos2dx/CCScheduler.h @@ -32,6 +32,13 @@ THE SOFTWARE. NS_CC_BEGIN +// Priority level reserved for system services. +#define kCCPrioritySystem INT_MIN + +// Minimum priority level for user scheduling. +#define kCCPriorityNonSystemMin (kCCPrioritySystem+1) + +class CCSet; // // CCTimer // @@ -169,6 +176,12 @@ public: */ void unscheduleAllSelectors(void); + /** Unschedules all selectors from all targets with a minimum priority. + You should only call this with kCCPriorityNonSystemMin or higher. + @since v2.0.0 + */ + void unscheduleAllSelectorsWithMinPriority(int nMinPriority); + /** The scheduled script callback will be called every 'interval' seconds. If paused is YES, then it won't be called until it is resumed. If 'interval' is 0, it will be called every frame. @@ -198,6 +211,24 @@ public: */ bool isTargetPaused(CCObject *pTarget); + /** Pause all selectors from all targets. + You should NEVER call this method, unless you know what you are doing. + @since v2.0.0 + */ + CCSet* pauseAllTargets(); + + /** Pause all selectors from all targets with a minimum priority. + You should only call this with kCCPriorityNonSystemMin or higher. + @since v2.0.0 + */ + CCSet* pauseAllTargetsWithMinPriority(int nMinPriority); + + /** Resume selectors on a set of targets. + This can be useful for undoing a call to pauseAllSelectors. + @since v2.0.0 + */ + void resumeTargets(CCSet* targetsToResume); + private: void removeHashElement(struct _hashSelectorEntry *pElement); void removeUpdateFromHash(struct _listEntry *entry); diff --git a/cocos2dx/cocoa/CCArray.cpp b/cocos2dx/cocoa/CCArray.cpp index 27c0f40dc4..135e210ae2 100644 --- a/cocos2dx/cocoa/CCArray.cpp +++ b/cocos2dx/cocoa/CCArray.cpp @@ -145,7 +145,7 @@ bool CCArray::init() bool CCArray::initWithObject(CCObject* pObject) { - ccArrayFree(data); + ccArrayFree(&data); bool bRet = initWithCapacity(1); if (bRet) { @@ -157,7 +157,7 @@ bool CCArray::initWithObject(CCObject* pObject) /** Initializes an array with some objects */ bool CCArray::initWithObjects(CCObject* pObject, ...) { - ccArrayFree(data); + ccArrayFree(&data); bool bRet = false; do { @@ -191,14 +191,14 @@ bool CCArray::initWithObjects(CCObject* pObject, ...) bool CCArray::initWithCapacity(unsigned int capacity) { - ccArrayFree(data); + ccArrayFree(&data); data = ccArrayNew(capacity); return true; } bool CCArray::initWithArray(CCArray* otherArray) { - ccArrayFree(data); + ccArrayFree(&data); bool bRet = false; do { @@ -253,6 +253,18 @@ bool CCArray::containsObject(CCObject* object) return ccArrayContainsObject(data, object); } +bool CCArray::isEqualToArray(CCArray* otherArray) +{ + for (int i = 0; i< this->count(); i++) + { + if (!this->objectAtIndex(i)->isEqual(otherArray->objectAtIndex(i))) + { + return false; + } + } + return true; +} + void CCArray::addObject(CCObject* object) { ccArrayAppendObjectWithResize(data, object); @@ -326,6 +338,12 @@ void CCArray::exchangeObjectAtIndex(unsigned int index1, unsigned int index2) ccArraySwapObjectsAtIndexes(data, index1, index2); } +void CCArray::replaceObjectAtIndex(unsigned int index, CCObject* pObject, bool bReleaseObject/* = true*/) +{ + ccArrayInsertObjectAtIndex(data, pObject, index); + ccArrayRemoveObjectAtIndex(data, index+1); +} + void CCArray::reverseObjects() { if (data->num > 1) @@ -349,24 +367,10 @@ void CCArray::reduceMemoryFootprint() CCArray::~CCArray() { - ccArrayFree(data); + ccArrayFree(&data); } -void CCArray::replaceObjectAtIndex(unsigned int uIndex, CCObject* pObject, bool bReleaseObject/* = true*/) -{ - if (bReleaseObject && uIndex < data->num && data->arr[uIndex] != NULL) - { - data->arr[uIndex]->release(); - } - data->arr[uIndex] = pObject; - - // add the ref - if (pObject) - { - pObject->retain(); - } -} CCObject* CCArray::copyWithZone(CCZone* pZone) { @@ -382,4 +386,141 @@ CCObject* CCArray::copyWithZone(CCZone* pZone) return pArray; } +//#pragma mark CCArray - sorting + +/** @since 1.1 */ +//#pragma mark - +//#pragma mark CCArray insertionSortUsingCFuncComparator + +void CCArray::insertionSortUsingCFuncComparator(cc_comparator comparator) +{ + cc_insertionSort(data, comparator); +} + +//#pragma mark CCArray qsortUsingCFuncComparator + +void CCArray::qsortUsingCFuncComparator(cc_comparator comparator) +{ + // stable c qsort is used - cost of sorting: best n*log(n), average n*log(n) + // qsort(void *, size_t, size_t, int (*)(const void *arg1, const void *arg2)); + + qsort(data->arr, data->num, sizeof (CCObject*), comparator); +} + +//#pragma mark CCArray mergesortLUsingCFuncComparator + +void CCArray::mergesortLUsingCFuncComparator(cc_comparator comparator) +{ + cc_mergesortL(data, sizeof (CCObject*), comparator); +} + +//#pragma mark CCArray insertionSort with (SEL)selector + +void CCArray::insertionSort(SEL_Compare selector) // It sorts source array in ascending order +{ + int i,j,length = data->num; + + CCObject* * x = data->arr; + CCObject* temp; + + // insertion sort + for(i=1; i0 && (x[j-1]->*selector)(x[j]) == CCOrderedDescending ) + { + temp = x[j]; + x[j] = x[j-1]; + x[j-1] = temp; + j--; + } + } +} + +static inline int selectorCompare(CCObject* object1,CCObject* object2,SEL_Compare selector) +{ + return (int) (object1->*selector)(object2); +} + +void CCArray::sortUsingSelector(SEL_Compare selector) +{ + this->sortUsingFunction(selectorCompare, selector); +} + +//#pragma mark CCArray sortUsingFunction + +// using a comparison function +void CCArray::sortUsingFunction(int (*compare)(CCObject*, CCObject*, SEL_Compare) , SEL_Compare context) +{ + int h, i, j, k, l, m, n = this->count(); + CCObject* A, **B = (CCObject**)malloc( (n/2 + 1) * sizeof(CCObject*)); + + // to prevent retain counts from temporarily hitting zero. + for( i=0;iarr[i]->retain(); + } + + for (h = 1; h < n; h += h) + { + for (m = n - 1 - h; m >= 0; m -= h + h) + { + l = m - h + 1; + if (l < 0) + { + l = 0; + } + + for (i = 0, j = l; j <= m; i++, j++) + { + B[i] = this->objectAtIndex(j); + } + + for (i = 0, k = l; k < j && j <= m + h; k++) + { + A = this->objectAtIndex(j); + if (compare(A, B[i], context) == CCOrderedDescending) + { + this->replaceObjectAtIndex(k, B[i++]); + } + else + { + this->replaceObjectAtIndex(k, A); + j++; + } + } + + while (k < j) + { + this->replaceObjectAtIndex(k++, B[i++]); + } + } + } + + for(i=0;iarr[i]->release(); + } + + free(B); +} + +void CCArray::makeObjectsPerformSelector(SEL_CallFunc aSelector) +{ + ccArrayMakeObjectsPerformSelector(data, aSelector); +} + +void CCArray::makeObjectsPerformSelectorWithObject(SEL_CallFuncO aSelector, CCObject* object) +{ + ccArrayMakeObjectsPerformSelectorWithObject(data, aSelector, object); +} + +void CCArray::makeObjectPerformSelectorWithArrayObjects(CCObject* object, SEL_CallFuncO aSelector) +{ + ccArrayMakeObjectPerformSelectorWithArrayObjects(data, aSelector, object); +} + NS_CC_END diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index 50951cbd87..00d8467c3c 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -126,7 +126,8 @@ public: CCObject* randomObject(); /** Returns a Boolean value that indicates whether object is present in array. */ bool containsObject(CCObject* object); - + /** @since 1.1 */ + bool isEqualToArray(CCArray* pOtherArray); // Adding Objects /** Add a certain object */ @@ -159,12 +160,30 @@ public: void exchangeObject(CCObject* object1, CCObject* object2); /** Swap two elements with certain indexes */ void exchangeObjectAtIndex(unsigned int index1, unsigned int index2); + + /** Replace object at index with another object. */ + void replaceObjectAtIndex(unsigned int uIndex, CCObject* pObject, bool bReleaseObject = true); + /** Revers the array */ void reverseObjects(); /* Shrinks the array so the memory footprint corresponds with the number of items */ void reduceMemoryFootprint(); - void replaceObjectAtIndex(unsigned int uIndex, CCObject* pObject, bool bReleaseObject = true); + // Sorting Array + /** all since @1.1 */ + void qsortUsingCFuncComparator(cc_comparator comparator); // c qsort is used for sorting + void insertionSortUsingCFuncComparator(cc_comparator comparator); // insertion sort + void mergesortLUsingCFuncComparator(cc_comparator comparator); // mergesort + void insertionSort(SEL_Compare selector); // It sorts source array in ascending order + void sortUsingFunction(int (*compare)(CCObject*, CCObject*, SEL_Compare) , SEL_Compare context); + void sortUsingSelector(SEL_Compare selector); + + // Sending Messages to Elements + + void makeObjectsPerformSelector(SEL_CallFunc aSelector); + void makeObjectsPerformSelectorWithObject(SEL_CallFuncO aSelector, CCObject* object); + /** @since 1.1 */ + void makeObjectPerformSelectorWithArrayObjects(CCObject* object, SEL_CallFuncO aSelector); /* override functions */ virtual CCObject* copyWithZone(CCZone* pZone); diff --git a/cocos2dx/cocoa/CCObject.h b/cocos2dx/cocoa/CCObject.h index 47477c5d9f..5d24307523 100644 --- a/cocos2dx/cocoa/CCObject.h +++ b/cocos2dx/cocoa/CCObject.h @@ -79,7 +79,8 @@ typedef void (CCObject::*SEL_CallFuncND)(CCNode*, void*); typedef void (CCObject::*SEL_CallFuncO)(CCObject*); typedef void (CCObject::*SEL_MenuHandler)(CCObject*); typedef void (CCObject::*SEL_EventHandler)(CCEvent*); - +typedef int (CCObject::*SEL_Compare)(CCObject*); + #define schedule_selector(_SELECTOR) (SEL_SCHEDULE)(&_SELECTOR) #define callfunc_selector(_SELECTOR) (SEL_CallFunc)(&_SELECTOR) #define callfuncN_selector(_SELECTOR) (SEL_CallFuncN)(&_SELECTOR) @@ -87,6 +88,7 @@ typedef void (CCObject::*SEL_EventHandler)(CCEvent*); #define callfuncO_selector(_SELECTOR) (SEL_CallFuncO)(&_SELECTOR) #define menu_selector(_SELECTOR) (SEL_MenuHandler)(&_SELECTOR) #define event_selector(_SELECTOR) (SEL_EventHandler)(&_SELECTOR) +#define compare_selector(_SELECTOR) (SEL_Compare)(&_SELECTOR) NS_CC_END diff --git a/cocos2dx/cocos2d.cpp b/cocos2dx/cocos2d.cpp index 993aec7f80..58f6c1d432 100644 --- a/cocos2dx/cocos2d.cpp +++ b/cocos2dx/cocos2d.cpp @@ -30,7 +30,7 @@ NS_CC_BEGIN const char* cocos2dVersion() { - return "cocos2d-2.0-rc0a-x-2.0"; + return "cocos2d-2.0-rc2-x-2.0"; } NS_CC_END diff --git a/cocos2dx/include/ccTypes.h b/cocos2dx/include/ccTypes.h index 952a87fd63..21f26e374b 100755 --- a/cocos2dx/include/ccTypes.h +++ b/cocos2dx/include/ccTypes.h @@ -326,13 +326,35 @@ typedef enum typedef float ccTime; //typedef double ccTime; -typedef enum +// XXX: If any of these enums are edited and/or reordered, udpate CCTexture2D.m +//! Vertical text alignment type +typedef enum { - CCTextAlignmentLeft, - CCTextAlignmentCenter, - CCTextAlignmentRight, + kCCVerticalTextAlignmentTop, + kCCVerticalTextAlignmentCenter, + kCCVerticalTextAlignmentBottom, +} CCVerticalTextAlignment; + +// XXX: If any of these enums are edited and/or reordered, udpate CCTexture2D.m +//! Horizontal text alignment type +typedef enum +{ + kCCTextAlignmentLeft, + kCCTextAlignmentCenter, + kCCTextAlignmentRight, } CCTextAlignment; +// XXX: If any of these enums are edited and/or reordered, udpate CCTexture2D.m +//! Line break modes +typedef enum { + kCCLineBreakModeWordWrap, + kCCLineBreakModeCharacterWrap, + kCCLineBreakModeClip, + kCCLineBreakModeHeadTruncation, + kCCLineBreakModeTailTruncation, + kCCLineBreakModeMiddleTruncation +} CCLineBreakMode; + // types for animation in particle systems // texture coordinates for a quad diff --git a/cocos2dx/misc_nodes/CCMotionStreak.cpp b/cocos2dx/misc_nodes/CCMotionStreak.cpp index b07cf806bd..d77c1d2435 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.cpp +++ b/cocos2dx/misc_nodes/CCMotionStreak.cpp @@ -44,11 +44,13 @@ CCMotionStreak::CCMotionStreak() , m_fMinSeg(0.0f) , m_uMaxPoints(0) , m_uNuPoints(0) +, m_uPreviousNuPoints(0) , m_pPointVertexes(NULL) , m_pPointState(NULL) , m_pVertices(NULL) , m_pColorPointer(NULL) , m_pTexCoords(NULL) +, m_bStartingPositionInitialized(false) { m_tBlendFunc.src = GL_SRC_ALPHA; m_tBlendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; @@ -102,7 +104,8 @@ bool CCMotionStreak::initWithFade(float fade, float minSeg, float stroke, ccColo { CCNode::setPosition(CCPointZero); setAnchorPoint(CCPointZero); - setIsRelativeAnchorPoint(false); + setIgnoreAnchorPointForPosition(true); + m_bStartingPositionInitialized = false; m_tPositionR = CCPointZero; m_bFastMode = true; @@ -137,6 +140,7 @@ bool CCMotionStreak::initWithFade(float fade, float minSeg, float stroke, ccColo void CCMotionStreak::setPosition(const CCPoint& position) { + m_bStartingPositionInitialized = true; m_tPositionR = position; } @@ -209,6 +213,11 @@ bool CCMotionStreak::getIsOpacityModifyRGB(void) void CCMotionStreak::update(ccTime delta) { + if (!m_bStartingPositionInitialized) + { + return; + } + delta *= m_fFadeDelta; unsigned int newIdx, newIdx2, i, i2; @@ -261,14 +270,18 @@ void CCMotionStreak::update(ccTime delta) // Append new point bool appendNewPoint = true; if(m_uNuPoints >= m_uMaxPoints) + { appendNewPoint = false; + } else if(m_uNuPoints>0) { bool a1 = ccpDistanceSQ(m_pPointVertexes[m_uNuPoints-1], m_tPositionR) < m_fMinSeg; bool a2 = (m_uNuPoints == 1) ? false : (ccpDistanceSQ(m_pPointVertexes[m_uNuPoints-2], m_tPositionR) < (m_fMinSeg * 2.0f)); if(a1 || a2) + { appendNewPoint = false; + } } if(appendNewPoint) @@ -289,16 +302,33 @@ void CCMotionStreak::update(ccTime delta) if(m_uNuPoints > 0 && m_bFastMode ) { if(m_uNuPoints > 1) - ccVertexLineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, m_pTexCoords, m_uNuPoints, 1); + { + ccVertexLineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, m_uNuPoints, 1); + } else - ccVertexLineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, m_pTexCoords, 0, 2); + { + ccVertexLineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, 0, 2); + } } m_uNuPoints ++; } if( ! m_bFastMode ) - ccVertexLineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, m_pTexCoords, 0, m_uNuPoints); + { + ccVertexLineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, 0, m_uNuPoints); + } + + // Updated Tex Coords only if they are different than previous step + if( m_uNuPoints && m_uPreviousNuPoints != m_uNuPoints ) { + float texDelta = 1.0f / m_uNuPoints; + for( i=0; i < m_uNuPoints; i++ ) { + m_pTexCoords[i*2] = tex2(0, texDelta*i); + m_pTexCoords[i*2+1] = tex2(1, texDelta*i); + } + + m_uPreviousNuPoints = m_uNuPoints; + } } void CCMotionStreak::reset() diff --git a/cocos2dx/misc_nodes/CCMotionStreak.h b/cocos2dx/misc_nodes/CCMotionStreak.h index 98d956d669..7294d6276a 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.h +++ b/cocos2dx/misc_nodes/CCMotionStreak.h @@ -76,6 +76,8 @@ public: /** When fast mode is enbled, new points are added faster but with lower precision */ CC_SYNTHESIZE(bool, m_bFastMode, IsFastMode); + + CC_SYNTHESIZE(bool, m_bStartingPositionInitialized, StartingPositionInitialized); private: /** texture used for the motion streak */ CCTexture2D* m_pTexture; @@ -89,6 +91,7 @@ private: unsigned int m_uMaxPoints; unsigned int m_uNuPoints; + unsigned int m_uPreviousNuPoints; /** Pointers */ CCPoint* m_pPointVertexes; diff --git a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp index d6b8e0f4c7..ee560604ab 100644 --- a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp +++ b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp @@ -452,7 +452,7 @@ void CCParticleBatchNode::increaseAtlasCapacityTo(unsigned int quantity) if( ! m_pTextureAtlas->resizeCapacity(quantity) ) { // serious problems - CCLOG("cocos2d: WARNING: Not enough memory to resize the atlas"); + CCLOGWARN("cocos2d: WARNING: Not enough memory to resize the atlas"); CCAssert(false,"XXX: CCParticleBatchNode #increaseAtlasCapacity SHALL handle this assert"); } } diff --git a/cocos2dx/particle_nodes/CCParticleSystem.cpp b/cocos2dx/particle_nodes/CCParticleSystem.cpp index b764005d4b..235ac5d802 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystem.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. @@ -103,6 +103,7 @@ CCParticleSystem::CCParticleSystem() ,m_fEmissionRate(0) ,m_uTotalParticles(0) ,m_pTexture(NULL) + ,m_bOpacityModifyRGB(false) ,m_bIsBlendAdditive(false) ,m_ePositionType(kCCPositionTypeFree) ,m_bIsAutoRemoveOnFinish(false) @@ -269,6 +270,9 @@ bool CCParticleSystem::initWithDictionary(CCDictionary *dictionary) //don't get the internal texture if a batchNode is used if (!m_pBatchNode) { + // Set a compatible default for the alpha transfer + m_bOpacityModifyRGB = false; + // texture // Try to get the texture from the cache const char* textureName = dictionary->valueForKey("textureFileName")->getCString(); @@ -384,6 +388,7 @@ bool CCParticleSystem::initWithTotalParticles(unsigned int numberOfParticles) CCParticleSystem::~CCParticleSystem() { + unscheduleUpdate(); CC_SAFE_FREE(m_pParticles); CC_SAFE_RELEASE(m_pTexture); } @@ -723,16 +728,34 @@ void CCParticleSystem::postStep() // ParticleSystem - CCTexture protocol void CCParticleSystem::setTexture(CCTexture2D* var) { - CC_SAFE_RETAIN(var); - CC_SAFE_RELEASE(m_pTexture); - m_pTexture = var; - - // If the new texture has No premultiplied alpha, AND the blendFunc hasn't been changed, then update it - if( m_pTexture && ! m_pTexture->getHasPremultipliedAlpha() && - ( m_tBlendFunc.src == CC_BLEND_SRC && m_tBlendFunc.dst == CC_BLEND_DST ) ) + if (m_pTexture != var) { - m_tBlendFunc.src = GL_SRC_ALPHA; - m_tBlendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; + CC_SAFE_RETAIN(var); + CC_SAFE_RELEASE(m_pTexture); + m_pTexture = var; + updateBlendFunc(); + } +} + +void CCParticleSystem::updateBlendFunc() +{ + CCAssert(! m_pBatchNode, "Can't change blending functions when the particle is being batched"); + + bool premultiplied = m_pTexture->getHasPremultipliedAlpha(); + + m_bOpacityModifyRGB = false; + + if( m_pTexture && ( m_tBlendFunc.src == CC_BLEND_SRC && m_tBlendFunc.dst == CC_BLEND_DST ) ) + { + if( premultiplied ) + { + m_bOpacityModifyRGB = true; + } + else + { + m_tBlendFunc.src = GL_SRC_ALPHA; + m_tBlendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; + } } } @@ -1152,9 +1175,12 @@ ccBlendFunc CCParticleSystem::getBlendFunc() return m_tBlendFunc; } -void CCParticleSystem::setBlendFunc(ccBlendFunc var) +void CCParticleSystem::setBlendFunc(ccBlendFunc blendFunc) { - m_tBlendFunc = var; + if( m_tBlendFunc.src != blendFunc.src || m_tBlendFunc.dst != blendFunc.dst ) { + m_tBlendFunc = blendFunc; + this->updateBlendFunc(); + } } tCCPositionType CCParticleSystem::getPositionType() diff --git a/cocos2dx/particle_nodes/CCParticleSystem.h b/cocos2dx/particle_nodes/CCParticleSystem.h index 04bbd5dcc8..57f052c697 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.h +++ b/cocos2dx/particle_nodes/CCParticleSystem.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. @@ -324,6 +324,9 @@ public: CC_PROPERTY(CCTexture2D*, m_pTexture, Texture) /** conforms to CocosNodeTexture protocol */ CC_PROPERTY(ccBlendFunc, m_tBlendFunc, BlendFunc) + /** does the alpha value modify color */ + CC_PROPERTY(bool, m_bOpacityModifyRGB, OpacityModifyRGB) + /** whether or not the particles are using blend additive. If enabled, the following blending function will be used. @code @@ -391,6 +394,9 @@ public: virtual void update(ccTime dt); virtual void updateWithNoTime(void); + +protected: + virtual void updateBlendFunc(); }; NS_CC_END diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp index ce5220fb5c..53c1f3ffa4 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp @@ -1,7 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada -Copyright (c) 2009 Leonardo KasperaviÄius +Copyright (c) 2009 Leonardo KasperaviÄius Copyright (c) 2011 Zynga Inc. http://www.cocos2d-x.org @@ -236,8 +236,10 @@ void CCParticleSystemQuad::updateQuadWithParticle(tCCParticle* particle, const C { quad = &(m_pQuads[m_uParticleIdx]); } - ccColor4B color = {(GLubyte)(particle->color.r * 255), (GLubyte)(particle->color.g * 255), (GLubyte)(particle->color.b * 255), - (GLubyte)(particle->color.a * 255)}; + ccColor4B color = (m_bOpacityModifyRGB) + ? (ccColor4B){ particle->color.r*particle->color.a*255, particle->color.g*particle->color.a*255, particle->color.b*particle->color.a*255, particle->color.a*255} + : (ccColor4B){ particle->color.r*255, particle->color.g*255, particle->color.b*255, particle->color.a*255}; + quad->bl.colors = color; quad->br.colors = color; quad->tl.colors = color; diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.h b/cocos2dx/particle_nodes/CCParticleSystemQuad.h index 9e1a2c8b29..c170d619c6 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.h +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.h @@ -1,8 +1,8 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Leonardo KasperaviÄius -Copyright (c) 2011 ynga Inc. +Copyright (c) 2011 Zynga Inc. http://www.cocos2d-x.org @@ -41,10 +41,8 @@ Special features and Limitations: - Particle size can be any float number. - The system can be scaled - The particles can be rotated -- On 1st and 2nd gen iPhones: It is only a bit slower that CCParticleSystemPoint -- On 3rd gen iPhone and iPads: It is MUCH faster than CCParticleSystemPoint -- It consumes more RAM and more GPU memory than CCParticleSystemPoint - It supports subrects +- It supports batched rendering since 1.1 @since v0.8 */ class CC_DLL CCParticleSystemQuad : public CCParticleSystem diff --git a/cocos2dx/proj.win32/cocos2d-win32.vcproj b/cocos2dx/proj.win32/cocos2d-win32.vcproj index be918e894e..8ebe77b8b1 100755 --- a/cocos2dx/proj.win32/cocos2d-win32.vcproj +++ b/cocos2dx/proj.win32/cocos2d-win32.vcproj @@ -850,6 +850,10 @@ + + diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index bf9bfe13cd..c4be00ab7f 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. @@ -392,9 +392,9 @@ void CCSprite::setTextureCoords(CCRect rect) bottom = top+(rect.size.width*2-2)/(2*atlasHeight); #else left = rect.origin.x/atlasWidth; - right = left+(rect.size.height/atlasWidth); + right = (rect.origin.x+rect.size.height) / atlasWidth; top = rect.origin.y/atlasHeight; - bottom = top+(rect.size.width/atlasHeight); + bottom = (rect.origin.y+rect.size.width) / atlasHeight; #endif // CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL if (m_bFlipX) @@ -425,9 +425,9 @@ void CCSprite::setTextureCoords(CCRect rect) bottom = top + (rect.size.height*2-2)/(2*atlasHeight); #else left = rect.origin.x/atlasWidth; - right = left + rect.size.width/atlasWidth; + right = (rect.origin.x + rect.size.width) / atlasWidth; top = rect.origin.y/atlasHeight; - bottom = top + rect.size.height/atlasHeight; + bottom = (rect.origin.y + rect.size.height) / atlasHeight; #endif // ! CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL if(m_bFlipX) @@ -829,10 +829,10 @@ void CCSprite::setAnchorPoint(const CCPoint& anchor) SET_DIRTY_RECURSIVELY(); } -void CCSprite::setIsRelativeAnchorPoint(bool bRelative) +void CCSprite::setIgnoreAnchorPointForPosition(bool value) { - CCAssert(! m_pobBatchNode, "relativeTransformAnchor is invalid in CCSprite"); - CCNode::setIsRelativeAnchorPoint(bRelative); + CCAssert(! m_pobBatchNode, "ignoreAnchorPointForPosition is invalid in CCSprite"); + CCNode::setIgnoreAnchorPointForPosition(value); } void CCSprite::setIsVisible(bool bVisible) @@ -1063,11 +1063,12 @@ void CCSprite::updateBlendFunc(void) void CCSprite::setTexture(CCTexture2D *texture) { - CCAssert(! m_pobBatchNode, "setTexture doesn't work when the sprite is rendered using a CCSpriteBatchNode"); + // If batchnode, then texture id should be the same + CCAssert(! m_pobBatchNode || texture.name == m_pobBatchNode->getTexture()->getName(), "CCSprite: Batched sprites should use the same texture as the batchnode"); // accept texture==nil as argument CCAssert( !texture || dynamic_cast(texture), "setTexture expects a CCTexture2D. Invalid argument"); - if (m_pobTexture != texture) + if (!m_pobBatchNode && m_pobTexture != texture) { CC_SAFE_RETAIN(texture); CC_SAFE_RELEASE(m_pobTexture); diff --git a/cocos2dx/sprite_nodes/CCSprite.h b/cocos2dx/sprite_nodes/CCSprite.h index 28d031c002..f66830adfe 100644 --- a/cocos2dx/sprite_nodes/CCSprite.h +++ b/cocos2dx/sprite_nodes/CCSprite.h @@ -181,7 +181,7 @@ public: virtual void setScale(float fScale); virtual void setVertexZ(float fVertexZ); virtual void setAnchorPoint(const CCPoint& anchor); - virtual void setIsRelativeAnchorPoint(bool bRelative); + virtual void setIgnoreAnchorPointForPosition(bool value); virtual void setIsVisible(bool bVisible); void setFlipX(bool bFlipX); void setFlipY(bool bFlipY); diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp index fdb5164daf..e25ee087ca 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp @@ -418,7 +418,7 @@ void CCSpriteBatchNode::increaseAtlasCapacity(void) if (! m_pobTextureAtlas->resizeCapacity(quantity)) { // serious problems - CCLOG("cocos2d: WARNING: Not enough memory to resize the atlas"); + CCLOGWARN("cocos2d: WARNING: Not enough memory to resize the atlas"); CCAssert(false, "Not enough memory to resize the atla"); } } diff --git a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp index f3fde8f3d9..d9d30c765e 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Jason Booth Copyright (c) 2009 Robert J Payne @@ -36,6 +36,7 @@ THE SOFTWARE. #include "CCFileUtils.h" #include "CCString.h" #include "CCArray.h" +#include "CCDictionary.h" #include using namespace std; @@ -64,6 +65,7 @@ bool CCSpriteFrameCache::init(void) { m_pSpriteFrames= new CCDictionary(); m_pSpriteFramesAliases = new CCDictionary(); + m_pLoadedFileNames = new std::set(); return true; } @@ -71,6 +73,7 @@ CCSpriteFrameCache::~CCSpriteFrameCache(void) { CC_SAFE_RELEASE(m_pSpriteFrames); CC_SAFE_RELEASE(m_pSpriteFramesAliases); + CC_SAFE_DELETE(m_pLoadedFileNames); } void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary* dictionary, CCTexture2D *pobTexture) @@ -95,7 +98,7 @@ void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary* dictionary, } // check the format - CCAssert(format >=0 && format <= 3, ""); + CCAssert(format >=0 && format <= 3, "format is not supported for CCSpriteFrameCache addSpriteFramesWithDictionary:textureFilename:"); CCDictElement* pElement = NULL; CCDICT_FOREACH(framesDict, pElement) @@ -120,7 +123,7 @@ void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary* dictionary, // check ow/oh if(!ow || !oh) { - CCLOG("cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenrate the .plist"); + CCLOGWARN("cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenrate the .plist"); } // abs ow/oh ow = abs(ow); @@ -176,7 +179,7 @@ void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary* dictionary, std::string oneAlias = ((CCString*)pObj)->getCString(); if (m_pSpriteFramesAliases->objectForKey(oneAlias.c_str())) { - CCLOG("cocos2d: WARNING: an alias with name %s already exists", oneAlias.c_str()); + CCLOGWARN("cocos2d: WARNING: an alias with name %s already exists", oneAlias.c_str()); } m_pSpriteFramesAliases->setObject(frameKey, oneAlias.c_str()); @@ -224,50 +227,57 @@ void CCSpriteFrameCache::addSpriteFramesWithFile(const char* plist, const char* void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist) { - const char *pszPath = CCFileUtils::fullPathFromRelativePath(pszPlist); - CCDictionary *dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(pszPath); - - string texturePath(""); + CCAssert(pszPlist, "plist filename should not be NULL"); - CCDictionary* metadataDict = (CCDictionary*)dict->objectForKey("metadata"); - if (metadataDict) + if (m_pLoadedFileNames->find(pszPlist) != m_pLoadedFileNames->end()) { - // try to read texture file name from meta data - texturePath = metadataDict->valueForKey("textureFileName")->getCString(); + const char *pszPath = CCFileUtils::fullPathFromRelativePath(pszPlist); + CCDictionary *dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(pszPath); + + string texturePath(""); + + CCDictionary* metadataDict = (CCDictionary*)dict->objectForKey("metadata"); + if (metadataDict) + { + // try to read texture file name from meta data + texturePath = metadataDict->valueForKey("textureFileName")->getCString(); + } + + if (! texturePath.empty()) + { + // build texture path relative to plist file + texturePath = CCFileUtils::fullPathFromRelativeFile(texturePath.c_str(), pszPath); + } + else + { + // build texture path by replacing file extension + texturePath = pszPath; + + // remove .xxx + size_t startPos = texturePath.find_last_of("."); + texturePath = texturePath.erase(startPos); + + // append .png + texturePath = texturePath.append(".png"); + + CCLOG("cocos2d: CCSpriteFrameCache: Trying to use file %s as texture", texturePath.c_str()); + } + + CCTexture2D *pTexture = CCTextureCache::sharedTextureCache()->addImage(texturePath.c_str()); + + if (pTexture) + { + addSpriteFramesWithDictionary(dict, pTexture); + m_pLoadedFileNames->insert(pszPlist); + } + else + { + CCLOG("cocos2d: CCSpriteFrameCache: Couldn't load texture"); + } + + dict->release(); } - if (! texturePath.empty()) - { - // build texture path relative to plist file - texturePath = CCFileUtils::fullPathFromRelativeFile(texturePath.c_str(), pszPath); - } - else - { - // build texture path by replacing file extension - texturePath = pszPath; - - // remove .xxx - size_t startPos = texturePath.find_last_of("."); - texturePath = texturePath.erase(startPos); - - // append .png - texturePath = texturePath.append(".png"); - - CCLOG("cocos2d: CCSpriteFrameCache: Trying to use file %s as texture", texturePath.c_str()); - } - - CCTexture2D *pTexture = CCTextureCache::sharedTextureCache()->addImage(texturePath.c_str()); - - if (pTexture) - { - addSpriteFramesWithDictionary(dict, pTexture); - } - else - { - CCLOG("cocos2d: CCSpriteFrameCache: Couldn't load texture"); - } - - dict->release(); } void CCSpriteFrameCache::addSpriteFrame(CCSpriteFrame *pobFrame, const char *pszFrameName) @@ -279,10 +289,12 @@ void CCSpriteFrameCache::removeSpriteFrames(void) { m_pSpriteFrames->removeAllObjects(); m_pSpriteFramesAliases->removeAllObjects(); + m_pLoadedFileNames->clear(); } void CCSpriteFrameCache::removeUnusedSpriteFrames(void) { + bool bRemoved = false; CCDictElement* pElement = NULL; CCDICT_FOREACH(m_pSpriteFrames, pElement) { @@ -291,8 +303,15 @@ void CCSpriteFrameCache::removeUnusedSpriteFrames(void) { CCLOG("cocos2d: CCSpriteFrameCache: removing unused frame: %s", pElement->getStrKey()); m_pSpriteFrames->removeObjectForElememt(pElement); + bRemoved = true; } } + + // XXX. Since we don't know the .plist file that originated the frame, we must remove all .plist from the cache + if( bRemoved ) + { + m_pLoadedFileNames->clear(); + } } @@ -316,6 +335,9 @@ void CCSpriteFrameCache::removeSpriteFrameByName(const char *pszName) { m_pSpriteFrames->removeObjectForKey(pszName); } + + // XXX. Since we don't know the .plist file that originated the frame, we must remove all .plist from the cache + m_pLoadedFileNames->clear(); } void CCSpriteFrameCache::removeSpriteFramesFromFile(const char* plist) @@ -325,6 +347,13 @@ void CCSpriteFrameCache::removeSpriteFramesFromFile(const char* plist) removeSpriteFramesFromDictionary((CCDictionary*)dict); + // remove it from the cache + set::iterator ret = m_pLoadedFileNames->find(plist); + if (ret != m_pLoadedFileNames->end()) + { + m_pLoadedFileNames->erase(ret); + } + dict->release(); } diff --git a/cocos2dx/sprite_nodes/CCSpriteFrameCache.h b/cocos2dx/sprite_nodes/CCSpriteFrameCache.h index 306ea7e66e..c0439e6893 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrameCache.h +++ b/cocos2dx/sprite_nodes/CCSpriteFrameCache.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Jason Booth Copyright (c) 2009 Robert J Payne @@ -38,10 +38,12 @@ THE SOFTWARE. #include "CCSpriteFrame.h" #include "CCTexture2D.h" #include "CCObject.h" -#include "CCDictionary.h" +#include NS_CC_BEGIN +class CCDictionary; +class CCArray; class CCSprite; /** @brief Singleton that handles the loading of the sprite frames. @@ -54,10 +56,11 @@ public: bool init(void); ~CCSpriteFrameCache(void); +private: /*Adds multiple Sprite Frames with a dictionary. The texture will be associated with the created sprite frames. */ void addSpriteFramesWithDictionary(CCDictionary* pobDictionary, CCTexture2D *pobTexture); - +public: /** Adds multiple Sprite Frames from a plist file. * A texture will be loaded automatically. The texture name will composed by replacing the .plist suffix with .png * If you want to use another texture, you should use the addSpriteFramesWithFile:texture method. @@ -101,11 +104,12 @@ public: */ void removeSpriteFramesFromFile(const char* plist); +private: /** Removes multiple Sprite Frames from CCDictionary. * @since v0.99.5 */ void removeSpriteFramesFromDictionary(CCDictionary* dictionary); - +public: /** Removes all Sprite Frames associated with the specified textures. * It is convinient to call this method when a specific texture needs to be removed. * @since v0.995. @@ -130,6 +134,7 @@ private: protected: CCDictionary* m_pSpriteFrames; CCDictionary* m_pSpriteFramesAliases; + std::set* m_pLoadedFileNames; }; NS_CC_END diff --git a/cocos2dx/support/CCVertex.cpp b/cocos2dx/support/CCVertex.cpp index c0d26679bc..9f55d765ca 100644 --- a/cocos2dx/support/CCVertex.cpp +++ b/cocos2dx/support/CCVertex.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org + Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 ForzeField Studios S.L http://www.cocos2d-x.org @@ -29,7 +29,7 @@ NS_CC_BEGIN -void ccVertexLineToPolygon(CCPoint *points, float stroke, ccVertex2F *vertices, ccTex2F *texCoords, unsigned int offset, unsigned int nuPoints) +void ccVertexLineToPolygon(CCPoint *points, float stroke, ccVertex2F *vertices, unsigned int offset, unsigned int nuPoints) { nuPoints += offset; if(nuPoints<=1) return; @@ -38,7 +38,6 @@ void ccVertexLineToPolygon(CCPoint *points, float stroke, ccVertex2F *vertices, unsigned int idx; unsigned int nuPointsMinus = nuPoints-1; - float texDelta = 1.0f/(float)nuPointsMinus; for(unsigned int i = offset; inum = 0; + arr->arr = (CCARRAY_ID *)calloc(capacity, sizeof(CCObject*)); + arr->max = capacity; + + return arr; +} + +/** Frees array after removing all remaining objects. Silently ignores NULL arr. */ +void ccArrayFree(ccArray **arr) +{ + if( arr == NULL || *arr == NULL) return; + + ccArrayRemoveAllObjects(*arr); + + free((*arr)->arr); + free(*arr); + + *arr = NULL; +} + +void ccArrayDoubleCapacity(ccArray *arr) +{ + arr->max *= 2; + CCARRAY_ID *newArr = (CCARRAY_ID *)realloc( arr->arr, arr->max * sizeof(CCObject*) ); + // will fail when there's not enough memory + CCAssert(newArr != NULL, "ccArrayDoubleCapacity failed. Not enough memory"); + arr->arr = newArr; +} + +void ccArrayEnsureExtraCapacity(ccArray *arr, unsigned int extra) +{ + while (arr->max < arr->num + extra) + ccArrayDoubleCapacity(arr); +} + +void ccArrayShrink(ccArray *arr) +{ + unsigned int newSize; + + //only resize when necessary + if (arr->max > arr->num && !(arr->num==0 && arr->max==1)) + { + if (arr->num!=0) + { + newSize=arr->num; + arr->max=arr->num; + } + else + {//minimum capacity of 1, with 0 elements the array would be free'd by realloc + newSize=1; + arr->max=1; + } + + arr->arr = (CCARRAY_ID *) realloc(arr->arr,newSize * sizeof(CCObject*) ); + CCAssert(arr->arr!=NULL,"could not reallocate the memory"); + } +} + +/** Returns index of first occurence of object, CC_INVALID_INDEX if object not found. */ +unsigned int ccArrayGetIndexOfObject(ccArray *arr, CCObject* object) +{ + unsigned int i; + + for( i = 0; i < arr->num; i++) + if( arr->arr[i] == object ) return i; + + return CC_INVALID_INDEX; +} + +/** Returns a Boolean value that indicates whether object is present in array. */ +bool ccArrayContainsObject(ccArray *arr, CCObject* object) +{ + return ccArrayGetIndexOfObject(arr, object) != CC_INVALID_INDEX; +} + +/** Appends an object. Bahaviour undefined if array doesn't have enough capacity. */ +void ccArrayAppendObject(ccArray *arr, CCObject* object) +{ + CCAssert(object != NULL, "Invalid parameter!"); + object->retain(); + arr->arr[arr->num] = object; + arr->num++; +} + +/** Appends an object. Capacity of arr is increased if needed. */ +void ccArrayAppendObjectWithResize(ccArray *arr, CCObject* object) +{ + ccArrayEnsureExtraCapacity(arr, 1); + ccArrayAppendObject(arr, object); +} + +/** Appends objects from plusArr to arr. Behaviour undefined if arr doesn't have + enough capacity. */ +void ccArrayAppendArray(ccArray *arr, ccArray *plusArr) +{ + unsigned int i; + + for( i = 0; i < plusArr->num; i++) + ccArrayAppendObject(arr, plusArr->arr[i]); +} + +/** Appends objects from plusArr to arr. Capacity of arr is increased if needed. */ +void ccArrayAppendArrayWithResize(ccArray *arr, ccArray *plusArr) +{ + ccArrayEnsureExtraCapacity(arr, plusArr->num); + ccArrayAppendArray(arr, plusArr); +} + +/** Inserts an object at index */ +void ccArrayInsertObjectAtIndex(ccArray *arr, CCObject* object, unsigned int index) +{ + CCAssert(index<=arr->num, "Invalid index. Out of bounds"); + CCAssert(object != NULL, "Invalid parameter!"); + + ccArrayEnsureExtraCapacity(arr, 1); + + unsigned int remaining = arr->num - index; + if( remaining > 0) + { + memmove((void *)&arr->arr[index+1], (void *)&arr->arr[index], sizeof(CCObject*) * remaining ); + } + + object->retain(); + arr->arr[index] = object; + arr->num++; +} + +/** Swaps two objects */ +void ccArraySwapObjectsAtIndexes(ccArray *arr, unsigned int index1, unsigned int index2) +{ + CCAssert(index1 < arr->num, "(1) Invalid index. Out of bounds"); + CCAssert(index2 < arr->num, "(2) Invalid index. Out of bounds"); + + CCObject* object1 = arr->arr[index1]; + + arr->arr[index1] = arr->arr[index2]; + arr->arr[index2] = object1; +} + +/** Removes all objects from arr */ +void ccArrayRemoveAllObjects(ccArray *arr) +{ + while( arr->num > 0 ) + { + (arr->arr[--arr->num])->release(); + } +} + +/** Removes object at specified index and pushes back all subsequent objects. + Behaviour undefined if index outside [0, num-1]. */ +void ccArrayRemoveObjectAtIndex(ccArray *arr, unsigned int index, bool bReleaseObj/* = true*/) +{ + if (bReleaseObj) + { + CC_SAFE_RELEASE(arr->arr[index]); + } + + arr->num--; + + unsigned int remaining = arr->num - index; + if(remaining>0) + { + memmove((void *)&arr->arr[index], (void *)&arr->arr[index+1], remaining * sizeof(CCObject*)); + } +} + +/** Removes object at specified index and fills the gap with the last object, + thereby avoiding the need to push back subsequent objects. + Behaviour undefined if index outside [0, num-1]. */ +void ccArrayFastRemoveObjectAtIndex(ccArray *arr, unsigned int index) +{ + CC_SAFE_RELEASE(arr->arr[index]); + unsigned int last = --arr->num; + arr->arr[index] = arr->arr[last]; +} + +void ccArrayFastRemoveObject(ccArray *arr, CCObject* object) +{ + unsigned int index = ccArrayGetIndexOfObject(arr, object); + if (index != CC_INVALID_INDEX) + ccArrayFastRemoveObjectAtIndex(arr, index); +} + +/** Searches for the first occurance of object and removes it. If object is not + found the function has no effect. */ +void ccArrayRemoveObject(ccArray *arr, CCObject* object, bool bReleaseObj/* = true*/) +{ + unsigned int index = ccArrayGetIndexOfObject(arr, object); + if (index != CC_INVALID_INDEX) + { + ccArrayRemoveObjectAtIndex(arr, index, bReleaseObj); + } +} + +/** Removes from arr all objects in minusArr. For each object in minusArr, the + first matching instance in arr will be removed. */ +void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr) +{ + unsigned int i; + + for( i = 0; i < minusArr->num; i++) + ccArrayRemoveObject(arr, minusArr->arr[i]); +} + +/** Removes from arr all objects in minusArr. For each object in minusArr, all + matching instances in arr will be removed. */ +void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr) +{ + unsigned int back = 0; + unsigned int i; + + for( i = 0; i < arr->num; i++) { + if( ccArrayContainsObject(minusArr, arr->arr[i]) ) { + CC_SAFE_RELEASE(arr->arr[i]); + back++; + } else + arr->arr[i - back] = arr->arr[i]; + } + + arr->num -= back; +} + +/** Sends to each object in arr the message identified by given selector. */ +void ccArrayMakeObjectsPerformSelector(ccArray *arr, SEL_CallFunc sel) +{ + unsigned int i; + + for( i = 0; i < arr->num; i++) + { + // #pragma clang diagnostic push + // #if defined(__has_feature) && __has_feature(objc_arc) + // #pragma clang diagnostic ignored "-Warc-performSelector-leaks" + // #endif + (arr->arr[i]->*sel)(); + //[arr->arr[i] performSelector:sel]; + //#pragma clang diagnostic pop + } + +} + +void ccArrayMakeObjectsPerformSelectorWithObject(ccArray *arr, SEL_CallFuncO sel, CCObject* object) +{ + unsigned int i; + + for( i = 0; i < arr->num; i++) + { + // #pragma clang diagnostic push + // + // #if defined(__has_feature) && __has_feature(objc_arc) + // #pragma clang diagnostic ignored "-Warc-performSelector-leaks" + // #endif + (arr->arr[i]->*sel)(object); + //[arr->arr[i] performSelector:sel withObject:object]; + //#pragma clang diagnostic pop + } + +} + +void ccArrayMakeObjectPerformSelectorWithArrayObjects(ccArray *arr, SEL_CallFuncO sel, CCObject* object) +{ + unsigned int i; + + for( i = 0; i < arr->num; i++) + { +// #pragma clang diagnostic push +// +// #if defined(__has_feature) && __has_feature(objc_arc) +// #pragma clang diagnostic ignored "-Warc-performSelector-leaks" +// #endif +// [object performSelector:sel withObject:arr->arr[i]]; + (object->*sel)(arr->arr[i]); +//#pragma clang diagnostic pop + } +} + + +// #pragma mark - +// #pragma mark ccCArray for Values (c structures) + +/** Allocates and initializes a new C array with specified capacity */ +ccCArray* ccCArrayNew(unsigned int capacity) +{ + if (capacity == 0) + capacity = 1; + + ccCArray *arr = (ccCArray*)malloc( sizeof(ccCArray) ); + arr->num = 0; + arr->arr = (CCARRAY_ID *) malloc( capacity * sizeof(CCObject*) ); + arr->max = capacity; + + return arr; +} + +/** Frees C array after removing all remaining values. Silently ignores NULL arr. */ +void ccCArrayFree(ccCArray *arr) +{ + if( arr == NULL ) return; + + ccCArrayRemoveAllValues(arr); + + free(arr->arr); + free(arr); +} + +/** Doubles C array capacity */ +void ccCArrayDoubleCapacity(ccCArray *arr) +{ + ccArrayDoubleCapacity(arr); +} + +/** Increases array capacity such that max >= num + extra. */ +void ccCArrayEnsureExtraCapacity(ccCArray *arr, unsigned int extra) +{ + ccArrayEnsureExtraCapacity(arr,extra); +} + +/** Returns index of first occurence of value, CC_INVALID_INDEX if value not found. */ +unsigned int ccCArrayGetIndexOfValue(ccCArray *arr, CCARRAY_ID value) +{ + unsigned int i; + + for( i = 0; i < arr->num; i++) + { + if( arr->arr[i]->isEqual(value) ) return i; + } + return CC_INVALID_INDEX; +} + +/** Returns a Boolean value that indicates whether value is present in the C array. */ +bool ccCArrayContainsValue(ccCArray *arr, CCARRAY_ID value) +{ + return ccCArrayGetIndexOfValue(arr, value) != CC_INVALID_INDEX; +} + +/** Inserts a value at a certain position. Behaviour undefined if aray doesn't have enough capacity */ +void ccCArrayInsertValueAtIndex( ccCArray *arr, CCARRAY_ID value, unsigned int index) +{ + CCAssert( index < arr->max, "ccCArrayInsertValueAtIndex: invalid index"); + + unsigned int remaining = arr->num - index; + + // last Value doesn't need to be moved + if( remaining > 0) { + // tex coordinates + memmove((void *)&arr->arr[index+1], (void *)&arr->arr[index], sizeof(void*) * remaining ); + } + + arr->num++; + arr->arr[index] = value; +} + +/** Appends an value. Bahaviour undefined if array doesn't have enough capacity. */ +void ccCArrayAppendValue(ccCArray *arr, CCARRAY_ID value) +{ + arr->arr[arr->num] = (CCObject*) value; + arr->num++; +} + +/** Appends an value. Capacity of arr is increased if needed. */ +void ccCArrayAppendValueWithResize(ccCArray *arr, CCARRAY_ID value) +{ + ccCArrayEnsureExtraCapacity(arr, 1); + ccCArrayAppendValue(arr, value); +} + + +/** Appends values from plusArr to arr. Behaviour undefined if arr doesn't have + enough capacity. */ +void ccCArrayAppendArray(ccCArray *arr, ccCArray *plusArr) +{ + unsigned int i; + + for( i = 0; i < plusArr->num; i++) + { + ccCArrayAppendValue(arr, plusArr->arr[i]); + } +} + +/** Appends values from plusArr to arr. Capacity of arr is increased if needed. */ +void ccCArrayAppendArrayWithResize(ccCArray *arr, ccCArray *plusArr) +{ + ccCArrayEnsureExtraCapacity(arr, plusArr->num); + ccCArrayAppendArray(arr, plusArr); +} + +/** Removes all values from arr */ +void ccCArrayRemoveAllValues(ccCArray *arr) +{ + arr->num = 0; +} + +/** Removes value at specified index and pushes back all subsequent values. + Behaviour undefined if index outside [0, num-1]. + @since v0.99.4 + */ +void ccCArrayRemoveValueAtIndex(ccCArray *arr, unsigned int index) +{ + unsigned int last; + + for( last = --arr->num; index < last; index++) + arr->arr[index] = arr->arr[index + 1]; +} + +/** Removes value at specified index and fills the gap with the last value, + thereby avoiding the need to push back subsequent values. + Behaviour undefined if index outside [0, num-1]. + @since v0.99.4 + */ +void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, unsigned int index) +{ + unsigned int last = --arr->num; + arr->arr[index] = arr->arr[last]; +} + +/** Searches for the first occurance of value and removes it. If value is not found the function has no effect. + @since v0.99.4 + */ +void ccCArrayRemoveValue(ccCArray *arr, CCARRAY_ID value) +{ + unsigned int index = ccCArrayGetIndexOfValue(arr, value); + if (index != CC_INVALID_INDEX) + ccCArrayRemoveValueAtIndex(arr, index); +} + +/** Removes from arr all values in minusArr. For each Value in minusArr, the first matching instance in arr will be removed. + @since v0.99.4 + */ +void ccCArrayRemoveArray(ccCArray *arr, ccCArray *minusArr) +{ + unsigned int i; + + for( i = 0; i < minusArr->num; i++) + ccCArrayRemoveValue(arr, minusArr->arr[i]); +} + +/** Removes from arr all values in minusArr. For each value in minusArr, all matching instances in arr will be removed. + @since v0.99.4 + */ +void ccCArrayFullRemoveArray(ccCArray *arr, ccCArray *minusArr) +{ + unsigned int i; + unsigned int back = 0; + + for( i = 0; i < arr->num; i++) { + if( ccCArrayContainsValue(minusArr, arr->arr[i]) ) { + back++; + } else + arr->arr[i - back] = arr->arr[i]; + } + + arr->num -= back; +} + +//used by mergesortL +void cc_pointerswap(void* a, void* b, size_t width) +{ + void* tmp; + tmp = *(void**)a; + *(void**)a = *(void**)b; + *(void**)b = tmp; +} + +// iterative mergesort arrd on +// http://www.inf.fh-flensburg.de/lang/algorithmen/sortieren/merge/mergiter.htm +int cc_mergesortL(ccCArray* array, size_t width, cc_comparator comparator) +{ + CCARRAY_ID *arr = array->arr; + int i,j,k,s,m,n= array->num; + + CCARRAY_ID *B = (CCARRAY_ID*) malloc((n/2 + 1) * width); + for (s = 1; s < n; s += s) + { + for (m = n-1-s; m >= 0; m -= s+s) + { + int lo = MAX(m-(s+1),0); + int hi = m+s; + + j = lo; + + if (m-j > 0) + { + //triggers a warning when compiled with ARC, B needs to be strong typed, for compiling for obj-c++ + //memcpy aritmetics aren't allowed on void* types + //explicitely casting didn't work +// #pragma clang diagnostic push +// #if defined(__has_feature) && __has_feature(objc_arc) +// #pragma clang diagnostic ignored "-Warc-non-pod-memaccess" +// #endif + + memcpy(B, &arr[j], (m-j) * width); +//#pragma clang diagnostic pop + } + + i = 0; + j = m; + k = lo; + + while (knum; + + CCARRAY_ID *x = arr->arr; + CCObject* temp; + + // insertion sort + for(i=1; i0 && ( comparator( &x[j-1], &x[j] ) == CCOrderedDescending) ) + { + temp = x[j]; + x[j] = x[j-1]; + x[j-1] = temp; + j--; + } + } +} + +NS_CC_END diff --git a/cocos2dx/support/data_support/ccCArray.h b/cocos2dx/support/data_support/ccCArray.h index 341a67e446..932e218fb8 100644 --- a/cocos2dx/support/data_support/ccCArray.h +++ b/cocos2dx/support/data_support/ccCArray.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2007 Scott Lembcke http://www.cocos2d-x.org @@ -23,16 +23,20 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -/** +/** @file - Based on Chipmunk cpArray. - ccArray is a faster alternative to CCMutableArray, it does pretty much the - same thing (stores CCObjects and retains/releases them appropriately). It's + based on Chipmunk cpArray. + ccArray is a faster alternative to NSMutableArray, it does pretty much the + same thing (stores NSObjects and retains/releases them appropriately). It's faster because: - - it uses a plain C interface so it doesn't incur Objective-c messaging overhead + - it uses a plain C interface so it doesn't incur Objective-c messaging overhead - it assumes you know what you're doing, so it doesn't spend time on safety checks - (index out of bounds, required capacity etc.) + (index out of bounds, required capacity etc.) - comparisons are done using pointer equality instead of isEqual + + There are 2 kind of functions: + - ccArray functions that manipulates objective-c objects (retain and release are performanced) + - ccCArray functions that manipulates values like if they were standard C structures (no retain/release is performed) */ #ifndef CC_ARRAY_H @@ -43,465 +47,191 @@ THE SOFTWARE. #include #include "ccMacros.h" #include "CCObject.h" -#include "ccMacros.h" NS_CC_BEGIN - // Easy integration -#define CCARRAYDATA_FOREACH(__array__, __object__) \ - __object__=__array__->arr[0]; for(unsigned int i=0, num=__array__->num; iarr[i]) \ +#define CC_INVALID_INDEX 0xffffffff -typedef struct _ccArray -{ - unsigned int num, max; - CCObject** arr; //equals CCObject** arr; + +// #pragma mark - +// #pragma mark ccArray for Objects + +// Easy integration +#define CCARRAYDATA_FOREACH(__array__, __object__) \ +__object__=__array__->arr[0]; for(unsigned int i=0, num=__array__->num; iarr[i]) \ + +// #if defined(__has_feature) && __has_feature(objc_arc) +// typedef __strong CCObject* CCARRAY_ID; +// #else + typedef CCObject* CCARRAY_ID; +//#endif + +typedef struct ccArray { + unsigned int num, max; + CCARRAY_ID *arr; } ccArray; -/** Allocates and initializes a new array with specified capacity */ -static inline ccArray* ccArrayNew(unsigned int capacity) +enum CCComparisonResult { - if (capacity == 0) - { - capacity = 1; - } - - ccArray *arr = (ccArray*)malloc( sizeof(ccArray) ); - arr->num = 0; - - arr->arr = (CCObject**)malloc( capacity * sizeof(CCObject*) ); - arr->max = capacity; - - return arr; -} + CCOrderedDescending = 1, + CCOrderedAscending = -1, + CCOrderedSame = 0 +}; -static inline void ccArrayRemoveAllObjects(ccArray *arr); +typedef int (*cc_comparator)(const void *, const void *); + +/** Allocates and initializes a new array with specified capacity */ +ccArray* ccArrayNew(unsigned int capacity); /** Frees array after removing all remaining objects. Silently ignores nil arr. */ -static inline void ccArrayFree(ccArray*& arr) -{ - if( arr == NULL ) - { - return; - } - - ccArrayRemoveAllObjects(arr); - - free(arr->arr); - free(arr); - arr = NULL; -} +void ccArrayFree(ccArray **arr); /** Doubles array capacity */ -static inline void ccArrayDoubleCapacity(ccArray *arr) -{ - arr->max *= 2; - CCObject** newArr = (CCObject**)realloc( arr->arr, arr->max * sizeof(CCObject*) ); - // will fail when there's not enough memory - CCAssert(newArr != 0, "ccArrayDoubleCapacity failed. Not enough memory"); - arr->arr = newArr; -} +void ccArrayDoubleCapacity(ccArray *arr); /** Increases array capacity such that max >= num + extra. */ -static inline void ccArrayEnsureExtraCapacity(ccArray *arr, unsigned int extra) -{ - while (arr->max < arr->num + extra) - { - ccArrayDoubleCapacity(arr); - } -} +void ccArrayEnsureExtraCapacity(ccArray *arr, unsigned int extra); /** shrinks the array so the memory footprint corresponds with the number of items */ -static inline void ccArrayShrink(ccArray *arr) -{ - unsigned int newSize; +void ccArrayShrink(ccArray *arr); - //only resize when necessary - if (arr->max > arr->num && !(arr->num==0 && arr->max==1)) - { - if (arr->num!=0) - { - newSize=arr->num; - arr->max=arr->num; - } - else - {//minimum capacity of 1, with 0 elements the array would be free'd by realloc - newSize=1; - arr->max=1; - } - - arr->arr = (CCObject**) realloc(arr->arr,newSize * sizeof(CCObject*) ); - CCAssert(arr->arr != NULL, "could not reallocate the memory"); - } -} - -/** Returns index of first occurence of object, UXNotFound if object not found. */ -static inline unsigned int ccArrayGetIndexOfObject(ccArray *arr, CCObject* object) -{ - for ( unsigned int i = 0; i < arr->num; i++) - { - if (arr->arr[i] == object) - { - return i; - } - } - - return UINT_MAX; -} +/** Returns index of first occurence of object, NSNotFound if object not found. */ +unsigned int ccArrayGetIndexOfObject(ccArray *arr, CCObject* object); /** Returns a Boolean value that indicates whether object is present in array. */ -static inline bool ccArrayContainsObject(ccArray *arr, CCObject* object) -{ - return ccArrayGetIndexOfObject(arr, object) != UINT_MAX; -} +bool ccArrayContainsObject(ccArray *arr, CCObject* object); /** Appends an object. Bahaviour undefined if array doesn't have enough capacity. */ -static inline void ccArrayAppendObject(ccArray *arr, CCObject* object) -{ - arr->arr[arr->num] = object; object->retain(); - arr->num++; -} +void ccArrayAppendObject(ccArray *arr, CCObject* object); /** Appends an object. Capacity of arr is increased if needed. */ -static inline void ccArrayAppendObjectWithResize(ccArray *arr, CCObject* object) -{ - ccArrayEnsureExtraCapacity(arr, 1); - ccArrayAppendObject(arr, object); -} +void ccArrayAppendObjectWithResize(ccArray *arr, CCObject* object); -/** Appends objects from plusArr to arr. Behaviour undefined if arr doesn't have - enough capacity. */ -static inline void ccArrayAppendArray(ccArray *arr, ccArray *plusArr) -{ - for( unsigned int i = 0; i < plusArr->num; i++) - { - ccArrayAppendObject(arr, plusArr->arr[i]); - } -} +/** Appends objects from plusArr to arr. + Behaviour undefined if arr doesn't have enough capacity. */ +void ccArrayAppendArray(ccArray *arr, ccArray *plusArr); /** Appends objects from plusArr to arr. Capacity of arr is increased if needed. */ -static inline void ccArrayAppendArrayWithResize(ccArray *arr, ccArray *plusArr) -{ - ccArrayEnsureExtraCapacity(arr, plusArr->num); - ccArrayAppendArray(arr, plusArr); -} +void ccArrayAppendArrayWithResize(ccArray *arr, ccArray *plusArr); /** Inserts an object at index */ -static inline void ccArrayInsertObjectAtIndex(ccArray *arr, CCObject* object, unsigned int index) -{ - CCAssert(index<=arr->num, "Invalid index. Out of bounds"); - - ccArrayEnsureExtraCapacity(arr, 1); - - unsigned int remaining = arr->num - index; - if( remaining > 0) - memmove(&arr->arr[index+1], &arr->arr[index], sizeof(CCObject*) * remaining ); - - object->retain(); - arr->arr[index] = object; - arr->num++; -} +void ccArrayInsertObjectAtIndex(ccArray *arr, CCObject* object, unsigned int index); /** Swaps two objects */ -static inline void ccArraySwapObjectsAtIndexes(ccArray *arr, unsigned int index1, unsigned int index2) -{ - CCAssert(index1 < arr->num, "(1) Invalid index. Out of bounds"); - CCAssert(index2 < arr->num, "(2) Invalid index. Out of bounds"); - - CCObject* object1 = arr->arr[index1]; - - arr->arr[index1] = arr->arr[index2]; - arr->arr[index2] = object1; -} +void ccArraySwapObjectsAtIndexes(ccArray *arr, unsigned int index1, unsigned int index2); /** Removes all objects from arr */ -static inline void ccArrayRemoveAllObjects(ccArray *arr) -{ - while(arr->num > 0) - { - arr->arr[--arr->num]->release(); - } -} +void ccArrayRemoveAllObjects(ccArray *arr); /** Removes object at specified index and pushes back all subsequent objects. Behaviour undefined if index outside [0, num-1]. */ -static inline void ccArrayRemoveObjectAtIndex(ccArray *arr, unsigned int index, bool bReleaseObj) -{ - CCAssert(arr && arr->num > 0 && index < arr->num, "Invalid index. Out of bounds"); - if (bReleaseObj) - { - arr->arr[index]->release(); - } - - arr->num--; - - unsigned int remaining = arr->num - index; - if (remaining > 0) - { - memmove(&arr->arr[index], &arr->arr[index+1], remaining * sizeof(void*)); - } -} +void ccArrayRemoveObjectAtIndex(ccArray *arr, unsigned int index, bool bReleaseObj = true); /** Removes object at specified index and fills the gap with the last object, thereby avoiding the need to push back subsequent objects. Behaviour undefined if index outside [0, num-1]. */ -static inline void ccArrayFastRemoveObjectAtIndex(ccArray *arr, unsigned int index) -{ - arr->arr[index]->release(); +void ccArrayFastRemoveObjectAtIndex(ccArray *arr, unsigned int index); - unsigned int last = --arr->num; - arr->arr[index] = arr->arr[last]; -} - -static inline void ccArrayFastRemoveObject(ccArray *arr, CCObject* object) -{ - unsigned int index = ccArrayGetIndexOfObject(arr, object); - if (index != UINT_MAX) - { - ccArrayFastRemoveObjectAtIndex(arr, index); - } -} +void ccArrayFastRemoveObject(ccArray *arr, CCObject* object); /** Searches for the first occurance of object and removes it. If object is not found the function has no effect. */ -static inline void ccArrayRemoveObject(ccArray *arr, CCObject* object, bool bReleaseObj) -{ - unsigned int index = ccArrayGetIndexOfObject(arr, object); - - if (index != UINT_MAX) - { - ccArrayRemoveObjectAtIndex(arr, index, bReleaseObj); - } -} +void ccArrayRemoveObject(ccArray *arr, CCObject* object, bool bReleaseObj = true); /** Removes from arr all objects in minusArr. For each object in minusArr, the first matching instance in arr will be removed. */ -static inline void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr) -{ - for( unsigned int i = 0; i < minusArr->num; i++) - { - ccArrayRemoveObject(arr, minusArr->arr[i], true); - } -} +void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr); /** Removes from arr all objects in minusArr. For each object in minusArr, all matching instances in arr will be removed. */ -static inline void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr) -{ - unsigned int back = 0; - - for( unsigned int i = 0; i < arr->num; i++) - { - if( ccArrayContainsObject(minusArr, arr->arr[i]) ) - { - arr->arr[i]->release(); - back++; - } - else - { - arr->arr[i - back] = arr->arr[i]; - } - } - - arr->num -= back; -} +void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr); -typedef struct _ccCArray -{ - unsigned int num, max; - void** arr; //equals CCObject** arr; -} ccCArray; +/** Sends to each object in arr the message identified by given selector. */ +void ccArrayMakeObjectsPerformSelector(ccArray *arr, SEL_CallFunc sel); -static inline void ccCArrayRemoveAllValues(ccCArray *arr); +void ccArrayMakeObjectsPerformSelectorWithObject(ccArray *arr, SEL_CallFuncO sel, CCObject* object); + +void ccArrayMakeObjectPerformSelectorWithArrayObjects(ccArray *arr, SEL_CallFuncO sel, CCObject* object); + + +// #pragma mark - +// #pragma mark ccCArray for Values (c structures) + +typedef ccArray ccCArray; /** Allocates and initializes a new C array with specified capacity */ -static inline ccCArray* ccCArrayNew(unsigned int capacity) -{ - if (capacity == 0) - { - capacity = 1; - } - - ccCArray *arr = (ccCArray*)malloc( sizeof(ccCArray) ); - arr->num = 0; - arr->arr = (void**) malloc( capacity * sizeof(void*) ); - arr->max = capacity; - - return arr; -} +ccCArray* ccCArrayNew(unsigned int capacity); /** Frees C array after removing all remaining values. Silently ignores nil arr. */ -static inline void ccCArrayFree(ccCArray *arr) -{ - if( arr == NULL ) - { - return; - } - - ccCArrayRemoveAllValues(arr); - - free(arr->arr); - free(arr); -} +void ccCArrayFree(ccCArray *arr); /** Doubles C array capacity */ -static inline void ccCArrayDoubleCapacity(ccCArray *arr) -{ - ccArrayDoubleCapacity((ccArray*)arr); -} +void ccCArrayDoubleCapacity(ccCArray *arr); /** Increases array capacity such that max >= num + extra. */ -static inline void ccCArrayEnsureExtraCapacity(ccCArray *arr, unsigned int extra) -{ - ccArrayEnsureExtraCapacity((ccArray*)arr,extra); -} +void ccCArrayEnsureExtraCapacity(ccCArray *arr, unsigned int extra); /** Returns index of first occurence of value, NSNotFound if value not found. */ -static inline int ccCArrayGetIndexOfValue(ccCArray *arr, void* value) -{ - for (unsigned int i = 0; i < arr->num; i++) - { - if (arr->arr[i] == value) - { - return i; - } - } - - return -1; -} +unsigned int ccCArrayGetIndexOfValue(ccCArray *arr, CCARRAY_ID value); /** Returns a Boolean value that indicates whether value is present in the C array. */ -static inline bool ccCArrayContainsValue(ccCArray *arr, void* value) -{ - return ccCArrayGetIndexOfValue(arr, value) != -1; -} +bool ccCArrayContainsValue(ccCArray *arr, CCARRAY_ID value); -/** Inserts a value at a certain position. The valid index is [0, num] */ -static inline void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, unsigned int index) -{ - CCAssert( index < arr->max, "ccCArrayInsertValueAtIndex: invalid index"); - unsigned int remaining = arr->num - index; +/** Inserts a value at a certain position. Behaviour undefined if aray doesn't have enough capacity */ +void ccCArrayInsertValueAtIndex( ccCArray *arr, CCARRAY_ID value, unsigned int index); - // make sure it has enough capacity - if (arr->num + 1 == arr->max) - { - ccCArrayDoubleCapacity(arr); - } - - // last Value doesn't need to be moved - if( remaining > 0) - { - // tex coordinates - memmove( &arr->arr[index+1],&arr->arr[index], sizeof(void*) * remaining ); - } - - arr->num++; - arr->arr[index] = value; -} - -/** Appends an value */ -static inline void ccCArrayAppendValue(ccCArray *arr, void* value) -{ - arr->arr[arr->num] = value; - arr->num++; - - // double the capacity for the next append action - // if the num >= max - if (arr->num >= arr->max) - { - ccCArrayDoubleCapacity(arr); - } -} +/** Appends an value. Bahaviour undefined if array doesn't have enough capacity. */ +void ccCArrayAppendValue(ccCArray *arr, CCARRAY_ID value); /** Appends an value. Capacity of arr is increased if needed. */ -static inline void ccCArrayAppendValueWithResize(ccCArray *arr, void* value) -{ - ccCArrayEnsureExtraCapacity(arr, 1); - ccCArrayAppendValue(arr, value); -} +void ccCArrayAppendValueWithResize(ccCArray *arr, CCARRAY_ID value); /** Appends values from plusArr to arr. Behaviour undefined if arr doesn't have enough capacity. */ -static inline void ccCArrayAppendArray(ccCArray *arr, ccCArray *plusArr) -{ - for (unsigned int i = 0; i < plusArr->num; i++) - { - ccCArrayAppendValue(arr, plusArr->arr[i]); - } -} +void ccCArrayAppendArray(ccCArray *arr, ccCArray *plusArr); /** Appends values from plusArr to arr. Capacity of arr is increased if needed. */ -static inline void ccCArrayAppendArrayWithResize(ccCArray *arr, ccCArray *plusArr) -{ - ccCArrayEnsureExtraCapacity(arr, plusArr->num); - ccCArrayAppendArray(arr, plusArr); -} +void ccCArrayAppendArrayWithResize(ccCArray *arr, ccCArray *plusArr); /** Removes all values from arr */ -static inline void ccCArrayRemoveAllValues(ccCArray *arr) -{ - arr->num = 0; -} +void ccCArrayRemoveAllValues(ccCArray *arr); /** Removes value at specified index and pushes back all subsequent values. - Behaviour undefined if index outside [0, num-1]. */ -static inline void ccCArrayRemoveValueAtIndex(ccCArray *arr, unsigned int index) -{ - for (unsigned int last = --arr->num; index < last; index++) - { - arr->arr[index] = arr->arr[index + 1]; - } -} + Behaviour undefined if index outside [0, num-1]. + @since v0.99.4 + */ +void ccCArrayRemoveValueAtIndex(ccCArray *arr, unsigned int index); /** Removes value at specified index and fills the gap with the last value, thereby avoiding the need to push back subsequent values. - Behaviour undefined if index outside [0, num-1]. */ -static inline void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, unsigned int index) -{ - unsigned int last = --arr->num; - arr->arr[index] = arr->arr[last]; -} + Behaviour undefined if index outside [0, num-1]. + @since v0.99.4 + */ +void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, unsigned int index); -/** Searches for the first occurance of value and removes it. If value is not - found the function has no effect. */ -static inline void ccCArrayRemoveValue(ccCArray *arr, void* value) -{ - unsigned int index = ccCArrayGetIndexOfValue(arr, value); - if (index != UINT_MAX) - { - ccCArrayRemoveValueAtIndex(arr, index); - } -} +/** Searches for the first occurance of value and removes it. If value is not found the function has no effect. + @since v0.99.4 + */ +void ccCArrayRemoveValue(ccCArray *arr, CCARRAY_ID value); -/** Removes from arr all values in minusArr. For each Value in minusArr, the - first matching instance in arr will be removed. */ -static inline void ccCArrayRemoveArray(ccCArray *arr, ccCArray *minusArr) -{ - for( unsigned int i = 0; i < minusArr->num; i++) - { - ccCArrayRemoveValue(arr, minusArr->arr[i]); - } -} +/** Removes from arr all values in minusArr. For each Value in minusArr, the first matching instance in arr will be removed. + @since v0.99.4 + */ +void ccCArrayRemoveArray(ccCArray *arr, ccCArray *minusArr); -/** Removes from arr all values in minusArr. For each value in minusArr, all - matching instances in arr will be removed. */ -static inline void ccCArrayFullRemoveArray(ccCArray *arr, ccCArray *minusArr) -{ - unsigned int back = 0; - - for (unsigned int i = 0; i < arr->num; i++) - { - if( ccCArrayContainsValue(minusArr, arr->arr[i]) ) - { - back++; - } else - { - arr->arr[i - back] = arr->arr[i]; - } - } - - arr->num -= back; -} +/** Removes from arr all values in minusArr. For each value in minusArr, all matching instances in arr will be removed. + @since v0.99.4 + */ +void ccCArrayFullRemoveArray(ccCArray *arr, ccCArray *minusArr); + +// iterative mergesort arrd on +// http://www.inf.fh-flensburg.de/lang/algorithmen/sortieren/merge/mergiter.htm +int cc_mergesortL(ccCArray* array, size_t width, cc_comparator comparator); + +void cc_insertionSort(ccCArray* arr, cc_comparator comparator); + +void cc_pointerswap(void* a, void* b, size_t width); NS_CC_END - + #endif // CC_ARRAY_H diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index 596fbaec37..38c90cddde 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008 Apple Inc. All Rights Reserved. http://www.cocos2d-x.org @@ -71,6 +71,7 @@ CCTexture2D::CCTexture2D() , m_fMaxS(0.0) , m_fMaxT(0.0) , m_bHasPremultipliedAlpha(false) +, m_bHasMipmaps(false) , m_bPVRHaveAlphaPremultiplied(true) , m_pShaderProgram(NULL) { @@ -177,11 +178,23 @@ bool CCTexture2D::getHasPremultipliedAlpha() bool CCTexture2D::initWithData(const void *data, CCTexture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const CCSize& contentSize) { - glPixelStorei(GL_UNPACK_ALIGNMENT,1); + // XXX: 32 bits or POT textures uses UNPACK of 4 (is this correct ??? ) + if( pixelFormat == kCCTexture2DPixelFormat_RGBA8888 || ( ccNextPOT(pixelsWide)==pixelsWide && ccNextPOT(pixelsHigh)==pixelsHigh) ) + { + glPixelStorei(GL_UNPACK_ALIGNMENT,4); + } + else + { + glPixelStorei(GL_UNPACK_ALIGNMENT,1); + } + glGenTextures(1, &m_uName); ccGLBindTexture2D(m_uName); - this->setAntiAliasTexParameters(); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); // Specify OpenGL texture image @@ -224,6 +237,7 @@ bool CCTexture2D::initWithData(const void *data, CCTexture2DPixelFormat pixelFor m_fMaxT = contentSize.height / (float)(pixelsHigh); m_bHasPremultipliedAlpha = false; + m_bHasMipmaps = false; m_eResolutionType = kCCResolutionUnknown; setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTexture)); @@ -413,9 +427,15 @@ bool CCTexture2D::initPremultipliedATextureWithImage(CCImage *image, unsigned in // implementation CCTexture2D (Text) bool CCTexture2D::initWithString(const char *text, const char *fontName, float fontSize) { - return initWithString(text, CCSizeMake(0,0), CCTextAlignmentCenter, fontName, fontSize); + return initWithString(text, CCSizeMake(0,0), kCCTextAlignmentCenter, kCCVerticalTextAlignmentTop, kCCLineBreakModeWordWrap, fontName, fontSize); } -bool CCTexture2D::initWithString(const char *text, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize) + +bool CCTexture2D::initWithString(const char *text, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize) +{ + return initWithString(text, dimensions, hAlignment, vAlignment, kCCLineBreakModeWordWrap, fontName, fontSize); +} + +bool CCTexture2D::initWithString(const char *text, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, CCLineBreakMode lineBreakMode, const char *fontName, float fontSize) { #if CC_ENABLE_CACHE_TEXTURE_DATA // cache the texture data @@ -423,10 +443,30 @@ bool CCTexture2D::initWithString(const char *text, const CCSize& dimensions, CCT #endif CCImage image; - CCImage::ETextAlign eAlign = (CCTextAlignmentCenter == alignment) ? CCImage::kAlignCenter - : (CCTextAlignmentLeft == alignment) ? CCImage::kAlignLeft : CCImage::kAlignRight; + + CCImage::ETextAlign eAlign; + + if (kCCVerticalTextAlignmentTop == vAlignment) + { + eAlign = (kCCTextAlignmentCenter == hAlignment) ? CCImage::kAlignTop + : (kCCTextAlignmentLeft == hAlignment) ? CCImage::kAlignTopLeft : CCImage::kAlignTopRight; + } + else if (kCCVerticalTextAlignmentCenter == vAlignment) + { + eAlign = (kCCTextAlignmentCenter == hAlignment) ? CCImage::kAlignCenter + : (kCCTextAlignmentLeft == hAlignment) ? CCImage::kAlignLeft : CCImage::kAlignRight; + } + else if (kCCVerticalTextAlignmentBottom == vAlignment) + { + eAlign = (kCCTextAlignmentCenter == hAlignment) ? CCImage::kAlignBottom + : (kCCTextAlignmentLeft == hAlignment) ? CCImage::kAlignBottomLeft : CCImage::kAlignBottomRight; + } + else + { + CCAssert(false, "Not supported alignment format!"); + } - if (! image.initWithString(text, (int)dimensions.width, (int)dimensions.height, eAlign, fontName, (int)fontSize)) + if (!image.initWithString(text, (int)dimensions.width, (int)dimensions.height, eAlign, fontName, (int)fontSize)) { return false; } @@ -551,8 +591,8 @@ bool CCTexture2D::initWithPVRFile(const char* file) m_tContentSize = CCSizeMake((float)m_uPixelsWide, (float)m_uPixelsHigh); m_bHasPremultipliedAlpha = PVRHaveAlphaPremultiplied_; m_ePixelFormat = pvr->getFormat(); - - this->setAntiAliasTexParameters(); + m_bHasMipmaps = pvr->getNumberOfMipmaps() > 1; + pvr->release(); } else @@ -579,13 +619,15 @@ void CCTexture2D::generateMipmap() CCAssert( m_uPixelsWide == ccNextPOT(m_uPixelsWide) && m_uPixelsHigh == ccNextPOT(m_uPixelsHigh), "Mimpap texture only works in POT textures"); ccGLBindTexture2D( m_uName ); glGenerateMipmap(GL_TEXTURE_2D); + m_bHasMipmaps = true; } void CCTexture2D::setTexParameters(ccTexParams *texParams) { - CCAssert( (m_uPixelsWide == ccNextPOT(m_uPixelsWide) && m_uPixelsHigh == ccNextPOT(m_uPixelsHigh)) || - (texParams->wrapS == GL_CLAMP_TO_EDGE && texParams->wrapT == GL_CLAMP_TO_EDGE), - "GL_CLAMP_TO_EDGE should be used in NPOT textures"); + CCAssert( (m_uPixelsWide == ccNextPOT(m_uPixelsWide) || texParams->wrapS == GL_CLAMP_TO_EDGE) && + (m_uPixelsHigh == ccNextPOT(m_uPixelsHigh) || texParams->wrapT == GL_CLAMP_TO_EDGE), + "GL_CLAMP_TO_EDGE should be used in NPOT dimensions"); + ccGLBindTexture2D( m_uName ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texParams->minFilter ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texParams->magFilter ); @@ -595,14 +637,34 @@ void CCTexture2D::setTexParameters(ccTexParams *texParams) void CCTexture2D::setAliasTexParameters() { - ccTexParams texParams = { GL_NEAREST, GL_NEAREST, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE }; - this->setTexParameters(&texParams); + ccGLBindTexture2D( m_uName ); + + if( ! m_bHasMipmaps ) + { + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + } + else + { + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST ); + } + + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); } void CCTexture2D::setAntiAliasTexParameters() { - ccTexParams texParams = { GL_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE }; - this->setTexParameters(&texParams); + ccGLBindTexture2D( m_uName ); + + if( ! m_bHasMipmaps ) + { + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + } + else + { + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST ); + } + + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); } // @@ -655,7 +717,8 @@ unsigned int CCTexture2D::bitsPerPixelForFormat() ret = 16; break; case kCCTexture2DPixelFormat_RGB888: - ret = 24; + // It is 32 and not 24, since its internal representation uses 32 bits. + ret = 32; break; default: ret = -1; diff --git a/cocos2dx/textures/CCTexture2D.h b/cocos2dx/textures/CCTexture2D.h index 08e08ed0f1..caefdc9825 100644 --- a/cocos2dx/textures/CCTexture2D.h +++ b/cocos2dx/textures/CCTexture2D.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (C) 2008 Apple Inc. All Rights Reserved. http://www.cocos2d-x.org @@ -41,7 +41,7 @@ class CCImage; Possible texture pixel formats */ typedef enum { - kCCTexture2DPixelFormat_Automatic = 0, + //! 32-bit texture: RGBA8888 kCCTexture2DPixelFormat_RGBA8888, //! 24-bit texture: RGBA888 @@ -67,7 +67,6 @@ typedef enum { kCCTexture2DPixelFormat_Default = kCCTexture2DPixelFormat_RGBA8888, // backward compatibility stuff - kTexture2DPixelFormat_Automatic = kCCTexture2DPixelFormat_Automatic, kTexture2DPixelFormat_RGBA8888 = kCCTexture2DPixelFormat_RGBA8888, kTexture2DPixelFormat_RGB888 = kCCTexture2DPixelFormat_RGB888, kTexture2DPixelFormat_RGB565 = kCCTexture2DPixelFormat_RGB565, @@ -136,8 +135,10 @@ public: Extensions to make it easy to create a CCTexture2D object from a string of text. Note that the generated textures are of type A8 - use the blending mode (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA). */ + + bool initWithString(const char *text, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, CCLineBreakMode lineBreakMode, const char *fontName, float fontSize); /** Initializes a texture from a string with dimensions, alignment, font name and font size */ - bool initWithString(const char *text, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize); + bool initWithString(const char *text, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize); /** Initializes a texture from a string with font name and font size */ bool initWithString(const char *text, const char *fontName, float fontSize); @@ -155,6 +156,9 @@ public: /** sets the min filter, mag filter, wrap s and wrap t texture parameters. If the texture size is NPOT (non power of 2), then in can only use GL_CLAMP_TO_EDGE in GL_TEXTURE_WRAP_{S,T}. + + @warning Calling this method could allocate additional texture memory. + @since v0.8 */ void setTexParameters(ccTexParams* texParams); @@ -163,6 +167,8 @@ public: - GL_TEXTURE_MIN_FILTER = GL_LINEAR - GL_TEXTURE_MAG_FILTER = GL_LINEAR + @warning Calling this method could allocate additional texture memory. + @since v0.8 */ void setAntiAliasTexParameters(); @@ -171,6 +177,8 @@ public: - GL_TEXTURE_MIN_FILTER = GL_NEAREST - GL_TEXTURE_MAG_FILTER = GL_NEAREST + @warning Calling this method could allocate additional texture memory. + @since v0.8 */ void setAliasTexParameters(); @@ -187,6 +195,17 @@ public: */ unsigned int bitsPerPixelForFormat(); + /** returns the pixel format in a NSString. + @since v2.0 + */ + CCString* stringForFormat(); + + + /** Helper functions that returns bits per pixels for a given format. + @since v2.0 + */ + unsigned int bitsPerPixelForFormat(CCTexture2DPixelFormat format); + /** sets the default pixel format for UIImagescontains alpha channel. If the UIImage contains alpha channel, then the options are: - generate 32-bit textures: kCCTexture2DPixelFormat_RGBA8888 (default one) @@ -198,7 +217,9 @@ public: How does it work ? - If the image is an RGBA (with Alpha) then the default pixel format will be used (it can be a 8-bit, 16-bit or 32-bit texture) - - If the image is an RGB (without Alpha) then an RGB565 or RGB888 texture will be used (16-bit texture) + - If the image is an RGB (without Alpha) then: If the default pixel format is RGBA8888 then a RGBA8888 (32-bit) will be used. Otherwise a RGB565 (16-bit texture) will be used. + + This parameter is not valid for PVR / PVR.CCZ images. @since v0.8 */ @@ -247,6 +268,8 @@ private: /** whether or not the texture has their Alpha premultiplied */ CC_PROPERTY_READONLY(bool, m_bHasPremultipliedAlpha, HasPremultipliedAlpha); + CC_PROPERTY_READONLY(bool, m_bHasMipmaps, HasMipmaps); + /** shader program used by drawAtPoint and drawInRect */ CC_PROPERTY(CCGLProgram*, m_pShaderProgram, ShaderProgram); diff --git a/cocos2dx/textures/CCTexturePVR.cpp b/cocos2dx/textures/CCTexturePVR.cpp index ad3edf450e..d578b88c0c 100755 --- a/cocos2dx/textures/CCTexturePVR.cpp +++ b/cocos2dx/textures/CCTexturePVR.cpp @@ -371,7 +371,7 @@ bool CCTexturePVR::createGLTexture() { if (m_uName != 0) { - glDeleteTextures(1, &m_uName); + ccGLDeleteTexture(m_uName); } glGenTextures(1, &m_uName); diff --git a/cocos2dx/textures/CCTexturePVR.h b/cocos2dx/textures/CCTexturePVR.h index cc66451f20..91ff0d6f07 100644 --- a/cocos2dx/textures/CCTexturePVR.h +++ b/cocos2dx/textures/CCTexturePVR.h @@ -123,7 +123,7 @@ protected: How many mipmaps do we have. It must be at least one when proper initialization finishes */ - unsigned int m_uNumberOfMipmaps; + CC_PROPERTY_READONLY(unsigned int, m_uNumberOfMipmaps, NumberOfMipmaps); /* Makrs for mipmaps. Each entry contains position in file diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp index c419aa541a..62b5b67a0a 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp @@ -238,27 +238,52 @@ void CCTMXLayer::setupTileSprite(CCSprite* sprite, CCPoint pos, unsigned int gid sprite->setOpacity(m_cOpacity); //issue 1264, flip can be undone as well - if (gid & kCCTMXTileHorizontalFlag) - { - sprite->setFlipX(true); - } - else - { - sprite->setFlipX(false); - } - - if (gid & kCCTMXTileVerticalFlag) - { - sprite->setFlipY(true); - } - else - { - sprite->setFlipY(false); - } - - if( gid & kCCTMXTileDiagonalFlag) - { - CCAssert(false, "Tiled Anti-Diagonally Flip not supported yet"); + sprite->setFlipX(false); + sprite->setFlipX(false); + sprite->setRotation(0.0f); + sprite->setAnchorPoint(ccp(0,0)); + + // Rotation in tiled is achieved using 3 flipped states, flipping across the horizontal, vertical, and diagonal axes of the tiles. + if (gid & kCCTMXTileDiagonalFlag) + { + // put the anchor in the middle for ease of rotation. + sprite->setAnchorPoint(ccp(0.5f,0.5f)); + sprite->setPosition(ccp(positionAt(pos).x + sprite->getContentSize().height/2, + positionAt(pos).y + sprite->getContentSize().width/2 ) ); + + unsigned int flag = gid & (kCCTMXTileHorizontalFlag | kCCTMXTileVerticalFlag ); + + // handle the 4 diagonally flipped states. + if (flag == kCCTMXTileHorizontalFlag) + { + sprite->setRotation(90.0f); + } + else if (flag == kCCTMXTileVerticalFlag) + { + sprite->setRotation(270.0f); + } + else if (flag == (kCCTMXTileVerticalFlag | kCCTMXTileHorizontalFlag) ) + { + sprite->setRotation(90.0f); + sprite->setFlipX(true); + } + else + { + sprite->setRotation(270.0f); + sprite->setFlipX(true); + } + } + else + { + if (gid & kCCTMXTileHorizontalFlag) + { + sprite->setFlipX(true); + } + + if (gid & kCCTMXTileVerticalFlag) + { + sprite->setFlipY(true); + } } } diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp index 633a6a7fb7..320f8e308f 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp @@ -287,6 +287,7 @@ bool CCTMXMapInfo::parseXMLString(const char *xmlString) bool CCTMXMapInfo::parseXMLData(const CCData* data) { //TODO: implementation. + CCAssert(false, "not implement!"); return false; } diff --git a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp index 295f650c06..0e811e3928 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp @@ -115,12 +115,14 @@ void CCTileMapAtlas::loadTGAfile(const char *file) { CCAssert( file != NULL, "file must be non-nil"); + const char* pPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(file) + // //Find the path of the file // NSBundle *mainBndl = [CCDirector sharedDirector].loadingBundle; // CCString *resourcePath = [mainBndl resourcePath]; // CCString * path = [resourcePath stringByAppendingPathComponent:file]; - m_pTGAInfo = tgaLoad( CCFileUtils::fullPathFromRelativePath(file) ); + m_pTGAInfo = tgaLoad( pPath ); #if 1 if( m_pTGAInfo->status != TGA_OK ) { From 9a600c62212cb83f1a335c6b9f15ead7aa8166e1 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 8 Jun 2012 14:17:39 +0800 Subject: [PATCH 097/257] issue #1310: syncronize base_nodes --- cocos2dx/base_nodes/CCNode.cpp | 34 ++++++++++++++++++++++------------ cocos2dx/base_nodes/CCNode.h | 8 +++----- 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 40a6aa5886..4722c90f4f 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -72,7 +72,7 @@ CCNode::CCNode(void) , m_bIsRunning(false) , m_pParent(NULL) // "whole screen" objects. like Scenes and Layers, should set isRelativeAnchorPoint to false -, m_bIsRelativeAnchorPoint(true) +, m_bIgnoreAnchorPointForPosition(false) , m_nTag(kCCNodeTagInvalid) // userData is always inited as nil , m_pUserData(NULL) @@ -392,15 +392,18 @@ void CCNode::setParent(CCNode * var) } /// isRelativeAnchorPoint getter -bool CCNode::getIsRelativeAnchorPoint() +bool CCNode::getIgnoreAnchorPointForPosition() { - return m_bIsRelativeAnchorPoint; + return m_bIgnoreAnchorPointForPosition; } /// isRelativeAnchorPoint setter -void CCNode::setIsRelativeAnchorPoint(bool newValue) +void CCNode::setIgnoreAnchorPointForPosition(bool newValue) { - m_bIsRelativeAnchorPoint = newValue; - m_bIsTransformDirty = m_bIsInverseDirty = true; + if (newValue != m_bIgnoreAnchorPointForPosition) + { + m_bIgnoreAnchorPointForPosition = newValue; + m_bIsTransformDirty = m_bIsInverseDirty = true; + } } /// tag getter @@ -969,20 +972,23 @@ void CCNode::pauseSchedulerAndActions() CCAffineTransform CCNode::nodeToParentTransform(void) { - if ( m_bIsTransformDirty ) { + if (m_bIsTransformDirty) + { // Translate values float x = m_tPosition.x; float y = m_tPosition.y; - if ( !m_bIsRelativeAnchorPoint ) { + if (m_bIgnoreAnchorPointForPosition) + { x += m_tAnchorPointInPoints.x; y += m_tAnchorPointInPoints.y; } // Rotation values float c = 1, s = 0; - if( m_fRotation ) { + if (m_fRotation) + { float radians = -CC_DEGREES_TO_RADIANS(m_fRotation); c = cosf(radians); s = sinf(radians); @@ -993,7 +999,8 @@ CCAffineTransform CCNode::nodeToParentTransform(void) // optimization: // inline anchor point calculation if skew is not needed - if( !needsSkewMatrix && !CCPoint::CCPointEqualToPoint(m_tAnchorPointInPoints, CCPointZero) ) { + if (! needsSkewMatrix && !CCPoint::CCPointEqualToPoint(m_tAnchorPointInPoints, CCPointZero)) + { x += c * -m_tAnchorPointInPoints.x * m_fScaleX + -s * -m_tAnchorPointInPoints.y * m_fScaleY; y += s * -m_tAnchorPointInPoints.x * m_fScaleX + c * -m_tAnchorPointInPoints.y * m_fScaleY; } @@ -1006,15 +1013,18 @@ CCAffineTransform CCNode::nodeToParentTransform(void) // XXX: Try to inline skew // If skew is needed, apply skew and then anchor point - if( needsSkewMatrix ) { + if (needsSkewMatrix) + { CCAffineTransform skewMatrix = CCAffineTransformMake(1.0f, tanf(CC_DEGREES_TO_RADIANS(m_fSkewY)), tanf(CC_DEGREES_TO_RADIANS(m_fSkewX)), 1.0f, 0.0f, 0.0f ); m_tTransform = CCAffineTransformConcat(skewMatrix, m_tTransform); // adjust anchor point - if( ! CCPoint::CCPointEqualToPoint(m_tAnchorPointInPoints, CCPointZero) ) + if (! CCPoint::CCPointEqualToPoint(m_tAnchorPointInPoints, CCPointZero)) + { m_tTransform = CCAffineTransformTranslate(m_tTransform, -m_tAnchorPointInPoints.x, -m_tAnchorPointInPoints.y); + } } m_bIsTransformDirty = false; diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index 7acf9a47b1..55c2e58e9d 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -259,11 +259,9 @@ class CC_DLL CCNode : public CCObject /** A weak reference to the parent */ CC_PROPERTY(CCNode *, m_pParent, Parent) - /** If true the transformtions will be relative to it's anchor point. - * Sprites, Labels and any other sizeble object use it have it enabled by default. - * Scenes, Layers and other "whole screen" object don't use it, have it disabled by default. - */ - CC_PROPERTY(bool, m_bIsRelativeAnchorPoint, IsRelativeAnchorPoint) + // If ture, the Anchor Point will be (0,0) when you position the CCNode. + // Used by CCLayer and CCScene + CC_PROPERTY(bool, m_bIgnoreAnchorPointForPosition, IgnoreAnchorPointForPosition); /** A tag used to identify the node easily */ CC_PROPERTY(int, m_nTag, Tag) From c8dfe7f92bb428648760f4b030cc27e01684ea1b Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 8 Jun 2012 14:30:55 +0800 Subject: [PATCH 098/257] issue #1310: Finished CCRenderTexture.h(.cpp). --- cocos2dx/misc_nodes/CCRenderTexture.cpp | 121 ++++++++++++++++++++++-- cocos2dx/misc_nodes/CCRenderTexture.h | 34 +++++-- 2 files changed, 138 insertions(+), 17 deletions(-) diff --git a/cocos2dx/misc_nodes/CCRenderTexture.cpp b/cocos2dx/misc_nodes/CCRenderTexture.cpp index 978406a9eb..e74abbb211 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.cpp +++ b/cocos2dx/misc_nodes/CCRenderTexture.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Jason Booth http://www.cocos2d-x.org @@ -44,6 +44,7 @@ NS_CC_BEGIN CCRenderTexture::CCRenderTexture() : m_pSprite(NULL) , m_uFBO(0) +, m_uDepthRenderBufffer(0) , m_nOldFBO(0) , m_pTexture(0) , m_pUITextureImage(NULL) @@ -55,7 +56,10 @@ CCRenderTexture::~CCRenderTexture() { //TODO: 2.0 remove this line. removeAllChildrenWithCleanup(true); glDeleteFramebuffers(1, &m_uFBO); - + if (m_uDepthRenderBufffer) + { + glDeleteRenderbuffers(1, &m_uDepthRenderBufffer); + } CC_SAFE_DELETE(m_pUITextureImage); } @@ -81,11 +85,11 @@ CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w, int h, return NULL; } -CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w, int h) +CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat) { CCRenderTexture *pRet = new CCRenderTexture(); - if(pRet && pRet->initWithWidthAndHeight(w, h, kCCTexture2DPixelFormat_RGBA8888)) + if(pRet && pRet->initWithWidthAndHeight(w, h, eFormat, uDepthStencilFormat)) { pRet->autorelease(); return pRet; @@ -94,7 +98,20 @@ CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w, int h) return NULL; } -bool CCRenderTexture::initWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat) +CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w, int h) +{ + CCRenderTexture *pRet = new CCRenderTexture(); + + if(pRet && pRet->initWithWidthAndHeight(w, h, kCCTexture2DPixelFormat_RGBA8888, 0)) + { + pRet->autorelease(); + return pRet; + } + CC_SAFE_DELETE(pRet); + return NULL; +} + +bool CCRenderTexture::initWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat) { CCAssert(m_ePixelFormat != kCCTexture2DPixelFormat_A8, "only RGB and RGBA formats are valid for a render texture"); @@ -130,6 +147,9 @@ bool CCRenderTexture::initWithWidthAndHeight(int w, int h, CCTexture2DPixelForma m_pTexture->initWithData(data, (CCTexture2DPixelFormat)m_ePixelFormat, powW, powH, CCSizeMake((float)w, (float)h)); free( data ); + GLint oldRBO; + glGetIntegerv(GL_RENDERBUFFER_BINDING, &oldRBO); + // generate FBO glGenFramebuffers(1, &m_uFBO); glBindFramebuffer(GL_FRAMEBUFFER, m_uFBO); @@ -137,6 +157,20 @@ bool CCRenderTexture::initWithWidthAndHeight(int w, int h, CCTexture2DPixelForma // associate texture with FBO glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_pTexture->getName(), 0); + if (m_uDepthRenderBufffer != 0) + { + //create and attach depth buffer + glGenRenderbuffers(1, &m_uDepthRenderBufffer); + glBindRenderbuffer(GL_RENDERBUFFER, m_uDepthRenderBufffer); + glRenderbufferStorage(GL_RENDERBUFFER, uDepthStencilFormat, powW, powH); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_uDepthRenderBufffer); + + // if depth format is the one with stencil part, bind same render buffer as stencil attachment + if (uDepthStencilFormat == CC_GL_DEPTH24_STENCIL8) + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_uDepthRenderBufffer); + } + + // check if it worked (probably worth doing :) ) CCAssert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE, "Could not attach texture to framebuffer"); @@ -151,6 +185,7 @@ bool CCRenderTexture::initWithWidthAndHeight(int w, int h, CCTexture2DPixelForma ccBlendFunc tBlendFunc = {GL_ONE, GL_ONE_MINUS_SRC_ALPHA }; m_pSprite->setBlendFunc(tBlendFunc); + glBindRenderbuffer(GL_RENDERBUFFER, oldRBO); glBindFramebuffer(GL_FRAMEBUFFER, m_nOldFBO); bRet = true; } while (0); @@ -174,11 +209,6 @@ void CCRenderTexture::begin() // Adjust the orthographic projection and viewport glViewport(0, 0, (GLsizei)texSize.width, (GLsizei)texSize.height); - // special viewport for 3d projection + retina display - if ( director->getProjection() == kCCDirectorProjection3D && CC_CONTENT_SCALE_FACTOR() != 1.0f ) - { - glViewport((GLsizei)(-texSize.width/2), (GLsizei)(-texSize.height/2), (GLsizei)(texSize.width * CC_CONTENT_SCALE_FACTOR()), (GLsizei)(texSize.height * CC_CONTENT_SCALE_FACTOR())); - } kmMat4 orthoMatrix; kmMat4OrthographicProjection(&orthoMatrix, (float)-1.0 / widthRatio, (float)1.0 / widthRatio, @@ -204,6 +234,48 @@ void CCRenderTexture::beginWithClear(float r, float g, float b, float a) glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); } +void CCRenderTexture::beginWithClear(float r, float g, float b, float a, float depthValue) +{ + this->begin(); + + // save clear color + GLfloat clearColor[4]; + GLfloat depthClearValue; + glGetFloatv(GL_COLOR_CLEAR_VALUE,clearColor); + glGetFloatv(GL_DEPTH_CLEAR_VALUE, &depthClearValue); + + glClearColor(r, g, b, a); + glClearDepth(depthValue); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + // restore clear color + glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); + glClearDepth(depthClearValue); +} + +void CCRenderTexture::beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue) +{ + this->begin(); + + // save clear color + GLfloat clearColor[4]; + GLfloat depthClearValue; + int stencilClearValue; + glGetFloatv(GL_COLOR_CLEAR_VALUE,clearColor); + glGetFloatv(GL_DEPTH_CLEAR_VALUE, &depthClearValue); + glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &stencilClearValue); + + glClearColor(r, g, b, a); + glClearDepth(depthValue); + glClearStencil(stencilValue); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + + // restore clear color + glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); + glClearDepth(depthClearValue); + glClearStencil(stencilClearValue); +} + void CCRenderTexture::end(bool bIsTOCacheTexture) { glBindFramebuffer(GL_FRAMEBUFFER, m_nOldFBO); @@ -251,6 +323,35 @@ void CCRenderTexture::clear(float r, float g, float b, float a) this->end(); } +void CCRenderTexture::clearDepth(float depthValue) +{ + this->begin(); + //! save old depth value + GLfloat depthClearValue; + glGetFloatv(GL_DEPTH_CLEAR_VALUE, &depthClearValue); + + glClearDepth(depthValue); + glClear(GL_DEPTH_BUFFER_BIT); + + // restore clear color + glClearDepth(depthClearValue); + this->end(); +} + +void CCRenderTexture::clearStencil(int stencilValue) +{ + // save old stencil value + int stencilClearValue; + glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &stencilClearValue); + + glClearStencil(stencilValue); + glClear(GL_STENCIL_BUFFER_BIT); + + // restore clear color + glClearStencil(stencilClearValue); +} + + bool CCRenderTexture::saveToFile(const char *szFilePath) { bool bRet = false; diff --git a/cocos2dx/misc_nodes/CCRenderTexture.h b/cocos2dx/misc_nodes/CCRenderTexture.h index d135326f3e..b04b0832b1 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.h +++ b/cocos2dx/misc_nodes/CCRenderTexture.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Jason Booth http://www.cocos2d-x.org @@ -58,6 +58,10 @@ class CC_DLL CCRenderTexture : public CCNode public: CCRenderTexture(); virtual ~CCRenderTexture(); + + /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format*/ + static CCRenderTexture * renderTextureWithWidthAndHeight(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat); + /** creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid */ static CCRenderTexture * renderTextureWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat); @@ -67,6 +71,9 @@ public: /** initializes a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid */ bool initWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat); + /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format*/ + bool initWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat); + /** starts grabbing */ void begin(); @@ -74,7 +81,14 @@ public: This is more efficient then calling -clear first and then -begin */ void beginWithClear(float r, float g, float b, float a); - + /** starts rendering to the texture while clearing the texture first. + This is more efficient then calling -clear first and then -begin */ + void beginWithClear(float r, float g, float b, float a, float depthValue); + + /** starts rendering to the texture while clearing the texture first. + This is more efficient then calling -clear first and then -begin */ + void beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue); + /** end is key word of lua, use other name to export to lua. */ inline void endToLua(){ end();}; @@ -85,6 +99,11 @@ public: /** clears the texture with a color */ void clear(float r, float g, float b, float a); + /** clears the texture with a specified depth value */ + void clearDepth(float depthValue); + + /** clears the texture with a specified stencil value */ + void clearStencil(int stencilValue); /* creates a new CCImage from with the texture's data. Caller is responsible for releasing it by calling delete. */ @@ -101,11 +120,12 @@ public: bool saveToFile(const char *name, tCCImageFormat format); protected: - GLuint m_uFBO; - GLint m_nOldFBO; - CCTexture2D *m_pTexture; - CCImage *m_pUITextureImage; - GLenum m_ePixelFormat; + GLuint m_uFBO; + GLuint m_uDepthRenderBufffer; + GLint m_nOldFBO; + CCTexture2D* m_pTexture; + CCImage* m_pUITextureImage; + GLenum m_ePixelFormat; }; NS_CC_END From fd2d9a8aa6674f5457d5b380f303bc59ace284ef Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 8 Jun 2012 14:50:41 +0800 Subject: [PATCH 099/257] issue #1310: Finished 'menu_nodes' and 'layers_scenes_transitions_nodes'. --- .../CCLayer.cpp | 4 +- .../layers_scenes_transitions_nodes/CCLayer.h | 2 +- .../CCScene.cpp | 4 +- cocos2dx/menu_nodes/CCMenu.cpp | 2 +- cocos2dx/menu_nodes/CCMenuItem.cpp | 142 ++++++++++-------- cocos2dx/menu_nodes/CCMenuItem.h | 2 + 6 files changed, 90 insertions(+), 66 deletions(-) diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index 4caf9aef7a..3e160e7808 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. @@ -49,7 +49,7 @@ CCLayer::CCLayer() ,m_pScriptHandlerEntry(NULL) { setAnchorPoint(ccp(0.5f, 0.5f)); - m_bIsRelativeAnchorPoint = false; + m_bIgnoreAnchorPointForPosition = true; } CCLayer::~CCLayer() diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h index 579a8165cf..d42b3eae98 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp index 4bc1e88318..fa684792e2 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. @@ -32,7 +32,7 @@ NS_CC_BEGIN CCScene::CCScene() { - m_bIsRelativeAnchorPoint = false; + m_bIgnoreAnchorPointForPosition = true; setAnchorPoint(ccp(0.5f, 0.5f)); } diff --git a/cocos2dx/menu_nodes/CCMenu.cpp b/cocos2dx/menu_nodes/CCMenu.cpp index ec4670ea6e..32f5e562a5 100644 --- a/cocos2dx/menu_nodes/CCMenu.cpp +++ b/cocos2dx/menu_nodes/CCMenu.cpp @@ -119,7 +119,7 @@ bool CCMenu::initWithArray(CCArray* pArrayOfItems) // menu in the center of the screen CCSize s = CCDirector::sharedDirector()->getWinSize(); - this->m_bIsRelativeAnchorPoint = false; + this->ignoreAnchorPointForPosition = true; setAnchorPoint(ccp(0.5f, 0.5f)); this->setContentSize(s); diff --git a/cocos2dx/menu_nodes/CCMenuItem.cpp b/cocos2dx/menu_nodes/CCMenuItem.cpp index 6cfdc6342f..dadc273c80 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.cpp +++ b/cocos2dx/menu_nodes/CCMenuItem.cpp @@ -395,62 +395,74 @@ CCNode * CCMenuItemSprite::getNormalImage() { return m_pNormalImage; } -void CCMenuItemSprite::setNormalImage(CCNode* var) +void CCMenuItemSprite::setNormalImage(CCNode* pImage) { - if (var) + if (pImage != m_pNormalImage) { - addChild(var, 0, kNormalTag); - var->setAnchorPoint(ccp(0, 0)); - var->setIsVisible(true); + if (pImage) + { + addChild(pImage, 0, kNormalTag); + pImage->setAnchorPoint(ccp(0, 0)); + } + + if (m_pNormalImage) + { + removeChild(m_pNormalImage, true); + } + + m_pNormalImage = pImage; + this->setContentSize(m_pNormalImage->getContentSize()); + this->updateImagesVisibility(); } - - if (m_pNormalImage) - { - removeChild(m_pNormalImage, true); - } - - m_pNormalImage = var; - this->setContentSize(m_pNormalImage->getContentSize()); } CCNode * CCMenuItemSprite::getSelectedImage() { return m_pSelectedImage; } -void CCMenuItemSprite::setSelectedImage(CCNode* var) +void CCMenuItemSprite::setSelectedImage(CCNode* pImage) { - if (var) + if (pImage != m_pNormalImage) { - addChild(var, 0, kSelectedTag); - var->setAnchorPoint(ccp(0, 0)); - var->setIsVisible(false); + if (pImage) + { + addChild(pImage, 0, kSelectedTag); + pImage->setAnchorPoint(ccp(0, 0)); + } + + if (m_pSelectedImage) + { + removeChild(m_pSelectedImage, true); + } + + m_pSelectedImage = pImage; + this->updateImagesVisibility(); } - - if (m_pSelectedImage) - { - removeChild(m_pSelectedImage, true); - } - - m_pSelectedImage = var; + } + CCNode * CCMenuItemSprite::getDisabledImage() { return m_pDisabledImage; } -void CCMenuItemSprite::setDisabledImage(CCNode* var) + +void CCMenuItemSprite::setDisabledImage(CCNode* pImage) { - if (var) + if (pImage != m_pNormalImage) { - addChild(var, 0, kDisableTag); - var->setAnchorPoint(ccp(0, 0)); - var->setIsVisible(false); + if (pImage) + { + addChild(pImage, 0, kDisableTag); + pImage->setAnchorPoint(ccp(0, 0)); + } + + if (m_pDisabledImage) + { + removeChild(m_pDisabledImage, true); + } + + m_pDisabledImage = pImage; + this->updateImagesVisibility(); } - - if (m_pDisabledImage) - { - removeChild(m_pDisabledImage, true); - } - - m_pDisabledImage = var; } // //CCMenuItemSprite - CCRGBAProtocol protocol @@ -560,32 +572,35 @@ void CCMenuItemSprite::unselected() void CCMenuItemSprite::setIsEnabled(bool bEnabled) { - CCMenuItem::setIsEnabled(bEnabled); - - if (m_pSelectedImage) - { - m_pSelectedImage->setIsVisible(false); + if( m_bIsEnabled != bEnabled ) + { + CCMenuItem::setIsEnabled(bEnabled); + this->updateImagesVisibility(); } - - if (bEnabled) +} + +// Helper +void CCMenuItemSprite::updateImagesVisibility() +{ + if (m_bIsEnabled) { - m_pNormalImage->setIsVisible(true); - - if (m_pDisabledImage) - { - m_pDisabledImage->setIsVisible(false); - } + if (m_pNormalImage) m_pNormalImage->setIsVisible(true); + if (m_pSelectedImage) m_pSelectedImage->setIsVisible(false); + if (m_pDisabledImage) m_pDisabledImage->setIsVisible(false); } else { if (m_pDisabledImage) { - m_pDisabledImage->setIsVisible(true); - m_pNormalImage->setIsVisible(false); + if (m_pNormalImage) m_pNormalImage->setIsVisible(false); + if (m_pSelectedImage) m_pSelectedImage->setIsVisible(false); + if (m_pDisabledImage) m_pDisabledImage->setIsVisible(true); } else { - m_pNormalImage->setIsVisible(true); + if (m_pNormalImage) m_pNormalImage->setIsVisible(true); + if (m_pSelectedImage) m_pSelectedImage->setIsVisible(false); + if (m_pDisabledImage) m_pDisabledImage->setIsVisible(false); } } } @@ -594,10 +609,12 @@ CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, { return CCMenuItemImage::itemWithNormalImage(normalImage, selectedImage, NULL, NULL, NULL); } + CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, const char *selectedImage, CCObject* target, SEL_MenuHandler selector) { return CCMenuItemImage::itemWithNormalImage(normalImage, selectedImage, NULL, target, selector); } + CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector) { CCMenuItemImage *pRet = new CCMenuItemImage(); @@ -609,6 +626,7 @@ CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, CC_SAFE_DELETE(pRet); return NULL; } + CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage) { CCMenuItemImage *pRet = new CCMenuItemImage(); @@ -620,6 +638,7 @@ CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, CC_SAFE_DELETE(pRet); return NULL; } + bool CCMenuItemImage::initWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector) { CCNode *normalSprite = CCSprite::spriteWithFile(normalImage); @@ -770,15 +789,18 @@ void CCMenuItemToggle::activate() } void CCMenuItemToggle::setIsEnabled(bool enabled) { - CCMenuItem::setIsEnabled(enabled); - - if(m_pSubItems && m_pSubItems->count() > 0) + if (m_bIsEnabled != enabled) { - CCObject* pObj = NULL; - CCARRAY_FOREACH(m_pSubItems, pObj) + CCMenuItem::setIsEnabled(enabled); + + if(m_pSubItems && m_pSubItems->count() > 0) { - CCMenuItem* pItem = (CCMenuItem*)pObj; - pItem->setIsEnabled(enabled); + CCObject* pObj = NULL; + CCARRAY_FOREACH(m_pSubItems, pObj) + { + CCMenuItem* pItem = (CCMenuItem*)pObj; + pItem->setIsEnabled(enabled); + } } } } diff --git a/cocos2dx/menu_nodes/CCMenuItem.h b/cocos2dx/menu_nodes/CCMenuItem.h index 0c5362dcc5..d650d3d042 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.h +++ b/cocos2dx/menu_nodes/CCMenuItem.h @@ -239,6 +239,8 @@ public: virtual void setIsOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} virtual bool getIsOpacityModifyRGB(void) { return false;} +protected: + virtual void updateImagesVisibility(); }; /** @brief CCMenuItemImage accepts images as items. From 6ee3db827ce306e7463b14f7c8b020a2e329a180 Mon Sep 17 00:00:00 2001 From: Nat Weiss Date: Thu, 7 Jun 2012 23:52:15 -0700 Subject: [PATCH 100/257] Allows Cocos2D-X to be built for iOS including all cpp files. --- cocos2dx/platform/CCThread.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2dx/platform/CCThread.cpp b/cocos2dx/platform/CCThread.cpp index b0dde32bf1..7271c76ec3 100644 --- a/cocos2dx/platform/CCThread.cpp +++ b/cocos2dx/platform/CCThread.cpp @@ -22,11 +22,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ +#include "CCThread.h" + // iOS already has a CCThread.mm #if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) -#include "CCThread.h" - NS_CC_BEGIN CCThread::~CCThread() From 4a887ac5980d648aa5442dcef7791e332777fcaa Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 8 Jun 2012 15:03:18 +0800 Subject: [PATCH 101/257] issue #1310: Updated CCScene.h. --- cocos2dx/layers_scenes_transitions_nodes/CCScene.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCScene.h b/cocos2dx/layers_scenes_transitions_nodes/CCScene.h index 7c6f8b2646..72d5cead50 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCScene.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCScene.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. From 6cf608effd486337a1113393d66d94a207169f21 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 8 Jun 2012 15:17:15 +0800 Subject: [PATCH 102/257] issue #1310: deleted some functions which can't be implemented in C++. Moved arrayMakeObjectsPerformSelector to CCArray.h. --- cocos2dx/base_nodes/CCNode.h | 34 -------------- cocos2dx/cocoa/CCArray.h | 34 ++++++++++++++ cocos2dx/support/data_support/ccCArray.cpp | 54 ---------------------- cocos2dx/support/data_support/ccCArray.h | 8 ---- 4 files changed, 34 insertions(+), 96 deletions(-) diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index 7acf9a47b1..70d19eceb0 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -57,40 +57,6 @@ enum { kCCNodeOnExit }; -#define arrayMakeObjectsPerformSelector(pArray, func, elementType) \ -do { \ - if(pArray && pArray->count() > 0) \ - { \ - CCObject* child; \ - CCARRAY_FOREACH(pArray, child) \ - { \ - elementType pNode = (elementType) child; \ - if(pNode) \ - { \ - pNode->func(); \ - } \ - } \ - } \ -} \ -while(false) - -#define arrayMakeObjectsPerformSelectorWithObject(pArray, func, pObject, elementType) \ -do { \ - if(pArray && pArray->count() > 0) \ - { \ - CCObject* child = NULL; \ - CCARRAY_FOREACH(pArray, child) \ - { \ - elementType pNode = (elementType) child; \ - if(pNode) \ - { \ - pNode->func(pObject); \ - } \ - } \ - } \ -} \ -while(false) - /** @brief CCNode is the main element. Anything thats gets drawn or contains things that get drawn is a CCNode. The most popular CCNodes are: CCScene, CCLayer, CCSprite, CCMenu. diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index 00d8467c3c..dad04d5942 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -67,6 +67,40 @@ I found that it's not work in C++. So it keep what it's look like in version 1.0 #define CCARRAY_VERIFY_TYPE(__array__, __type__) void(0) #endif +#define arrayMakeObjectsPerformSelector(pArray, func, elementType) \ +do { \ + if(pArray && pArray->count() > 0) \ + { \ + CCObject* child; \ + CCARRAY_FOREACH(pArray, child) \ + { \ + elementType pNode = (elementType) child; \ + if(pNode) \ + { \ + pNode->func(); \ + } \ + } \ + } \ +} \ +while(false) + +#define arrayMakeObjectsPerformSelectorWithObject(pArray, func, pObject, elementType) \ +do { \ + if(pArray && pArray->count() > 0) \ + { \ + CCObject* child = NULL; \ + CCARRAY_FOREACH(pArray, child) \ + { \ + elementType pNode = (elementType) child; \ + if(pNode) \ + { \ + pNode->func(pObject); \ + } \ + } \ + } \ +} \ +while(false) + NS_CC_BEGIN diff --git a/cocos2dx/support/data_support/ccCArray.cpp b/cocos2dx/support/data_support/ccCArray.cpp index e1609a6d12..26128aa163 100644 --- a/cocos2dx/support/data_support/ccCArray.cpp +++ b/cocos2dx/support/data_support/ccCArray.cpp @@ -256,60 +256,6 @@ void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr) arr->num -= back; } -/** Sends to each object in arr the message identified by given selector. */ -void ccArrayMakeObjectsPerformSelector(ccArray *arr, SEL_CallFunc sel) -{ - unsigned int i; - - for( i = 0; i < arr->num; i++) - { - // #pragma clang diagnostic push - // #if defined(__has_feature) && __has_feature(objc_arc) - // #pragma clang diagnostic ignored "-Warc-performSelector-leaks" - // #endif - (arr->arr[i]->*sel)(); - //[arr->arr[i] performSelector:sel]; - //#pragma clang diagnostic pop - } - -} - -void ccArrayMakeObjectsPerformSelectorWithObject(ccArray *arr, SEL_CallFuncO sel, CCObject* object) -{ - unsigned int i; - - for( i = 0; i < arr->num; i++) - { - // #pragma clang diagnostic push - // - // #if defined(__has_feature) && __has_feature(objc_arc) - // #pragma clang diagnostic ignored "-Warc-performSelector-leaks" - // #endif - (arr->arr[i]->*sel)(object); - //[arr->arr[i] performSelector:sel withObject:object]; - //#pragma clang diagnostic pop - } - -} - -void ccArrayMakeObjectPerformSelectorWithArrayObjects(ccArray *arr, SEL_CallFuncO sel, CCObject* object) -{ - unsigned int i; - - for( i = 0; i < arr->num; i++) - { -// #pragma clang diagnostic push -// -// #if defined(__has_feature) && __has_feature(objc_arc) -// #pragma clang diagnostic ignored "-Warc-performSelector-leaks" -// #endif -// [object performSelector:sel withObject:arr->arr[i]]; - (object->*sel)(arr->arr[i]); -//#pragma clang diagnostic pop - } -} - - // #pragma mark - // #pragma mark ccCArray for Values (c structures) diff --git a/cocos2dx/support/data_support/ccCArray.h b/cocos2dx/support/data_support/ccCArray.h index 932e218fb8..2832066e5e 100644 --- a/cocos2dx/support/data_support/ccCArray.h +++ b/cocos2dx/support/data_support/ccCArray.h @@ -146,14 +146,6 @@ void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr); matching instances in arr will be removed. */ void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr); -/** Sends to each object in arr the message identified by given selector. */ -void ccArrayMakeObjectsPerformSelector(ccArray *arr, SEL_CallFunc sel); - -void ccArrayMakeObjectsPerformSelectorWithObject(ccArray *arr, SEL_CallFuncO sel, CCObject* object); - -void ccArrayMakeObjectPerformSelectorWithArrayObjects(ccArray *arr, SEL_CallFuncO sel, CCObject* object); - - // #pragma mark - // #pragma mark ccCArray for Values (c structures) From 6b7a59f00745a1b4d60f1416713fe3e1fccd6ef0 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 8 Jun 2012 15:29:47 +0800 Subject: [PATCH 103/257] issue #1310:synchronize CCLableAtlas and CCLabelBMFont --- cocos2dx/label_nodes/CCLabelAtlas.cpp | 45 +++++++++- cocos2dx/label_nodes/CCLabelAtlas.h | 16 +++- cocos2dx/label_nodes/CCLabelBMFont.cpp | 110 +++++++++++++------------ cocos2dx/label_nodes/CCLabelBMFont.h | 23 ++++-- 4 files changed, 129 insertions(+), 65 deletions(-) diff --git a/cocos2dx/label_nodes/CCLabelAtlas.cpp b/cocos2dx/label_nodes/CCLabelAtlas.cpp index 76aab24f99..55ee293a99 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.cpp +++ b/cocos2dx/label_nodes/CCLabelAtlas.cpp @@ -33,13 +33,15 @@ THE SOFTWARE. #include "ccGLStateCache.h" #include "CCDirector.h" #include "support/TransformUtils.h" +#include "CCInteger.h" +#include "CCFileUtils.h" // external #include "kazmath/GL/matrix.h" NS_CC_BEGIN //CCLabelAtlas - Creation & Init -CCLabelAtlas * CCLabelAtlas::labelWithString(const char *label, const char *charMapFile, unsigned int itemWidth, int unsigned itemHeight, unsigned char startCharMap) +CCLabelAtlas* CCLabelAtlas::labelWithString(const char *label, const char *charMapFile, unsigned int itemWidth, int unsigned itemHeight, unsigned int startCharMap) { CCLabelAtlas *pRet = new CCLabelAtlas(); if(pRet && pRet->initWithString(label, charMapFile, itemWidth, itemHeight, startCharMap)) @@ -51,18 +53,53 @@ CCLabelAtlas * CCLabelAtlas::labelWithString(const char *label, const char *char return NULL; } -bool CCLabelAtlas::initWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned char startCharMap) +bool CCLabelAtlas::initWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap) { CCAssert(label != NULL, ""); if (CCAtlasNode::initWithTileFile(charMapFile, itemWidth, itemHeight, strlen(label))) { - m_cMapStartChar = startCharMap; + m_uMapStartChar = startCharMap; this->setString(label); return true; } return false; } +CCLabelAtlas* CCLabelAtlas::labelWithString(const char *string, const char *fntFile) +{ + CCLabelAtlas *ret = new CCLabelAtlas(); + if (ret) + { + if (ret->initWithString(string, fntFile)) + { + ret->autorelease(); + } + else + { + CC_SAFE_RELEASE_NULL(ret); + } + } + + return ret; +} + +bool CCLabelAtlas::initWithString(const char *theString, const char *fntFile) +{ + CCDictionary *dict = CCDictionary::dictionaryWithContentsOfFile(CCFileUtils::fullPathFromRelativePath(fntFile)); + + CCAssert(((CCInteger*)dict->objectForKey("version"))->getValue() == 1, "Unsupported version. Upgrade cocos2d version"); + + CCString *textureFilename = (CCString*)dict->objectForKey("textureFilename"); + unsigned int width = ((CCInteger*)dict->objectForKey("itemWidth"))->getValue() / CC_CONTENT_SCALE_FACTOR(); + unsigned int height = ((CCInteger*)dict->objectForKey("itemHeight"))->getValue() / CC_CONTENT_SCALE_FACTOR(); + unsigned int startChar = ((CCInteger*)dict->objectForKey("firstChar"))->getValue(); + + + this->initWithString(theString, textureFilename->getCString(), width, height, startChar); + + return true; +} + //CCLabelAtlas - Atlas generation void CCLabelAtlas::updateAtlasValues() { @@ -79,7 +116,7 @@ void CCLabelAtlas::updateAtlasValues() float itemHeightInPixels = m_uItemHeight * CC_CONTENT_SCALE_FACTOR(); for(unsigned int i = 0; i < n; i++) { - unsigned char a = s[i] - m_cMapStartChar; + unsigned char a = s[i] - m_uMapStartChar; float row = (float) (a % m_uItemsPerRow); float col = (float) (a / m_uItemsPerRow); diff --git a/cocos2dx/label_nodes/CCLabelAtlas.h b/cocos2dx/label_nodes/CCLabelAtlas.h index d5445517c8..343c15b2d2 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.h +++ b/cocos2dx/label_nodes/CCLabelAtlas.h @@ -52,10 +52,20 @@ public: m_sString.clear(); } /** creates the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */ - static CCLabelAtlas * labelWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned char startCharMap); + static CCLabelAtlas * labelWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); + + /** creates the CCLabelAtlas with a string and a configuration file + @since v2.0 + */ + static CCLabelAtlas* labelWithString(const char *sring, const char *fntFile); /** initializes the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */ - bool initWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned char startCharMap); + bool initWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); + + /** initializes the CCLabelAtlas with a string and a configuration file + @since v2.0 + */ + bool initWithString(const char *string, const char *fntFile); // super methods virtual void updateAtlasValues(); virtual void setString(const char *label); @@ -69,7 +79,7 @@ protected: // string to render std::string m_sString; // the first char in the charmap - unsigned char m_cMapStartChar; + unsigned int m_uMapStartChar; }; NS_CC_END diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index 77f37a6702..89c6847a9a 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -41,6 +41,7 @@ http://www.angelcode.com/products/bmfont/ (Free, Windows only) #include "CCFileUtils.h" #include "support/data_support/uthash.h" #include "CCDirector.h" +#include "CCTextureCache.h" using namespace std; @@ -372,7 +373,10 @@ CCBMFontConfiguration* FNTConfigLoadFile( const char *fntFile) if( pRet == NULL ) { pRet = CCBMFontConfiguration::configurationWithFNTFile(fntFile); - configurations->setObject(pRet, fntFile); + if (pRet) + { + configurations->setObject(pRet, fntFile); + } } return pRet; @@ -415,15 +419,19 @@ CCBMFontConfiguration * CCBMFontConfiguration::configurationWithFNTFile(const ch bool CCBMFontConfiguration::initWithFNTfile(const char *FNTfile) { - CCAssert(FNTfile != NULL && strlen(FNTfile)!=0, ""); m_pKerningDictionary = NULL; - this->parseConfigFile(FNTfile); + m_pFontDefDictionary = NULL; + if (! this->parseConfigFile(FNTfile)) + { + return false; + } + return true; } CCBMFontConfiguration::CCBMFontConfiguration() : m_pFontDefDictionary(NULL) - , m_uCommonHeight(0) + , m_nCommonHeight(0) , m_pKerningDictionary(NULL) { @@ -470,23 +478,22 @@ void CCBMFontConfiguration::purgeFontDefDictionary() } -void CCBMFontConfiguration::parseConfigFile(const char *controlFile) +bool CCBMFontConfiguration::parseConfigFile(const char *controlFile) { std::string fullpath = CCFileUtils::fullPathFromRelativePath(controlFile); - - unsigned long nBufSize; - char *pBuffer = (char*)CCFileUtils::getFileData(fullpath.c_str(), "rb", &nBufSize); + CCString *contents = CCString::stringWithContentsOfFile(fullpath.c_str()); - CCAssert(pBuffer, "CCBMFontConfiguration::parseConfigFile | Open file error."); + CCAssert(contents, "CCBMFontConfiguration::parseConfigFile | Open file error."); - if (!pBuffer) + if (!contents) { - return; + CCLOG("cocos2d: Error parsing FNTfile %s", controlFile); + return false; } // parse spacing / padding std::string line; - std::string strLeft(pBuffer, nBufSize); + std::string strLeft = contents->getCString(); while (strLeft.length() > 0) { int pos = strLeft.find('\n'); @@ -533,15 +540,17 @@ void CCBMFontConfiguration::parseConfigFile(const char *controlFile) element->key = element->fontDef.charID; HASH_ADD_INT(m_pFontDefDictionary, key, element); } - else if(line.substr(0,strlen("kernings count")) == "kernings count") - { - this->parseKerningCapacity(line); - } +// else if(line.substr(0,strlen("kernings count")) == "kernings count") +// { +// this->parseKerningCapacity(line); +// } else if(line.substr(0,strlen("kerning first")) == "kerning first") { this->parseKerningEntry(line); } } + + return true; } void CCBMFontConfiguration::parseImageFileName(std::string line, const char *fntFile) @@ -591,7 +600,7 @@ void CCBMFontConfiguration::parseCommonArguments(std::string line) int index = line.find("lineHeight="); int index2 = line.find(' ', index); std::string value = line.substr(index, index2-index); - sscanf(value.c_str(), "lineHeight=%u", &m_uCommonHeight); + sscanf(value.c_str(), "lineHeight=%d", &m_nCommonHeight); // scaleW. sanity check index = line.find("scaleW=") + strlen("scaleW="); index2 = line.find(' ', index); @@ -661,28 +670,6 @@ void CCBMFontConfiguration::parseCharacterDefinition(std::string line, ccBMFontD sscanf(value.c_str(), "xadvance=%d", &characterDefinition->xAdvance); } -void CCBMFontConfiguration::parseKerningCapacity(std::string line) -{ - // When using uthash there is not need to parse the capacity. - - // CCAssert(!kerningDictionary, @"dictionary already initialized"); - // - // // Break the values for this line up using = - // CCMutableArray *values = [line componentsSeparatedByString:@"="]; - // NSEnumerator *nse = [values objectEnumerator]; - // CCString *propertyValue; - // - // // We need to move past the first entry in the array before we start assigning values - // [nse nextObject]; - // - // // count - // propertyValue = [nse nextObject]; - // int capacity = [propertyValue intValue]; - // - // if( capacity != -1 ) - // kerningDictionary = ccHashSetNew(capacity, targetSetEql); -} - void CCBMFontConfiguration::parseKerningEntry(std::string line) { ////////////////////////////////////////////////////////////////////////// @@ -777,13 +764,31 @@ bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile, f bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile, float width, CCTextAlignment alignment, CCPoint imageOffset) { - CCAssert(theString != NULL, ""); - CC_SAFE_RELEASE(m_pConfiguration);// allow re-init - m_pConfiguration = FNTConfigLoadFile(fntFile); - m_pConfiguration->retain(); - CCAssert( m_pConfiguration, "Error creating config for LabelBMFont"); + CCAssert(!m_pConfiguration, "re-init is no longer supported"); + CCAssert( (theString && fntFile) || (theString==NULL && fntFile==NULL), "Invalid params for CCLabelBMFont"); + + CCTexture2D *texture = NULL; + + if (fntFile) + { + CCBMFontConfiguration *newConf = FNTConfigLoadFile(fntFile); + CCAssert(newConf, "CCLabelBMFont: Impossible to create font. Please check file"); + + newConf->retain(); + CC_SAFE_RELEASE(m_pConfiguration); + m_pConfiguration = newConf; + + m_sFntFile = fntFile; + + texture = CCTextureCache::sharedTextureCache()->addImage(m_pConfiguration->getAtlasName()); + } + else + { + texture = new CCTexture2D(); + texture->autorelease(); + } - if (CCSpriteBatchNode::initWithFile(m_pConfiguration->m_sAtlasName.c_str(), strlen(theString))) + if (CCSpriteBatchNode::initWithTexture(texture, strlen(theString))) { m_pAlignment = alignment; m_tImageOffset = imageOffset; @@ -862,8 +867,8 @@ void CCLabelBMFont::createFontChars() } } - totalHeight = m_pConfiguration->m_uCommonHeight * quantityOfLines; - nextFontPositionY = 0-(m_pConfiguration->m_uCommonHeight - m_pConfiguration->m_uCommonHeight * quantityOfLines); + totalHeight = m_pConfiguration->m_nCommonHeight * quantityOfLines; + nextFontPositionY = 0-(m_pConfiguration->m_nCommonHeight - m_pConfiguration->m_nCommonHeight * quantityOfLines); for (unsigned int i= 0; i < stringLen; i++) { @@ -872,7 +877,7 @@ void CCLabelBMFont::createFontChars() if (c == '\n') { nextFontPositionX = 0; - nextFontPositionY -= m_pConfiguration->m_uCommonHeight; + nextFontPositionY -= m_pConfiguration->m_nCommonHeight; continue; } @@ -911,7 +916,8 @@ void CCLabelBMFont::createFontChars() fontChar->setOpacity(255); } - float yOffset = (float)(m_pConfiguration->m_uCommonHeight) - fontDef.yOffset; + // See issue 1343. cast( signed short + unsigned integer ) == unsigned integer (sign is lost!) + int yOffset = m_pConfiguration->m_nCommonHeight - fontDef.yOffset; CCPoint fontPos = ccp( (float)nextFontPositionX + fontDef.xOffset + fontDef.rect.size.width*0.5f + kerningAmount, (float)nextFontPositionY + yOffset - rect.size.height*0.5f * CC_CONTENT_SCALE_FACTOR() ); fontChar->setPosition(CC_POINT_PIXELS_TO_POINTS(fontPos)); @@ -955,7 +961,7 @@ void CCLabelBMFont::setString(const char *newString, bool fromUpdate) { CC_SAFE_DELETE_ARRAY(m_sString); m_sString = cc_utf16_from_utf8(newString); - m_sString_initial = newString; + m_sInitialString = newString; updateString(fromUpdate); } @@ -982,7 +988,7 @@ void CCLabelBMFont::updateString(bool fromUpdate) const char* CCLabelBMFont::getString(void) { - return m_sString_initial.c_str(); + return m_sInitialString.c_str(); } void CCLabelBMFont::setCString(const char *label) @@ -1074,7 +1080,7 @@ void CCLabelBMFont::setAnchorPoint(const CCPoint& point) // LabelBMFont - Alignment void CCLabelBMFont::updateLabel() { - this->setString(m_sString_initial.c_str(), true); + this->setString(m_sInitialString.c_str(), true); if (m_fWidth > 0) { diff --git a/cocos2dx/label_nodes/CCLabelBMFont.h b/cocos2dx/label_nodes/CCLabelBMFont.h index 42fc6abcaa..a5a62d33f5 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.h +++ b/cocos2dx/label_nodes/CCLabelBMFont.h @@ -91,8 +91,8 @@ public://@public // BMFont definitions struct _FontDefHashElement* m_pFontDefDictionary; - //! FNTConfig: Common Height - unsigned int m_uCommonHeight; + //! FNTConfig: Common Height Should be signed (issue #1343) + int m_nCommonHeight; //! Padding ccBMFontPadding m_tPadding; //! atlas name @@ -107,13 +107,15 @@ public: static CCBMFontConfiguration * configurationWithFNTFile(const char *FNTfile); /** initializes a BitmapFontConfiguration with a FNT file */ bool initWithFNTfile(const char *FNTfile); + + inline const char* getAtlasName(){ return m_sAtlasName.c_str(); } + inline void setAtlasName(const char* atlasName) { m_sAtlasName = atlasName; } private: - void parseConfigFile(const char *controlFile); + bool parseConfigFile(const char *controlFile); void parseCharacterDefinition(std::string line, ccBMFontDef *characterDefinition); void parseInfoArguments(std::string line); void parseCommonArguments(std::string line); void parseImageFileName(std::string line, const char *fntFile); - void parseKerningCapacity(std::string line); void parseKerningEntry(std::string line); void purgeKerningDictionary(); void purgeFontDefDictionary(); @@ -160,10 +162,19 @@ class CC_DLL CCLabelBMFont : public CCSpriteBatchNode, public CCLabelProtocol, p protected: // string to render unsigned short* m_sString; - std::string m_sString_initial; - CCBMFontConfiguration *m_pConfiguration; + + // name of fntFile + std::string m_sFntFile; + + // initial string without line breaks + std::string m_sInitialString; + // alignment of all lines CCTextAlignment m_pAlignment; + // max width until a line break is added float m_fWidth; + + CCBMFontConfiguration *m_pConfiguration; + bool m_bLineBreakWithoutSpaces; // offset of the texture atlas CCPoint m_tImageOffset; From 76a560a4744afe127c271e0508064c2019471a9c Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 8 Jun 2012 16:22:57 +0800 Subject: [PATCH 104/257] issue #1310: Made CCFileUtils as a singleton. --- cocos2dx/CCDrawingPrimitives.cpp | 5 +- cocos2dx/cocoa/CCArray.cpp | 31 +--- cocos2dx/cocoa/CCArray.h | 9 +- cocos2dx/cocoa/CCData.cpp | 2 +- cocos2dx/cocoa/CCString.cpp | 2 +- .../CCControlExtension/CCControlButton.cpp | 2 +- .../CCControlExtension/CCControlSlider.cpp | 2 +- .../CCControlExtension/CCControlSwitch.cpp | 2 +- .../CCControlExtension/CCMenuPassive.cpp | 2 +- .../CCTextureWatcher/CCTextureWatcher.cpp | 6 +- cocos2dx/label_nodes/CCLabelAtlas.cpp | 2 +- cocos2dx/label_nodes/CCLabelBMFont.cpp | 13 +- cocos2dx/label_nodes/CCLabelTTF.cpp | 4 +- cocos2dx/menu_nodes/CCMenu.cpp | 2 +- cocos2dx/misc_nodes/CCRenderTexture.cpp | 2 +- cocos2dx/particle_nodes/CCParticleSystem.cpp | 10 +- .../particle_nodes/CCParticleSystemQuad.cpp | 4 +- cocos2dx/platform/CCFileUtils.h | 40 +++-- cocos2dx/platform/CCImageCommon_cpp.h | 4 +- cocos2dx/platform/CCPlatformMacros.h | 11 +- cocos2dx/platform/CCSAXParser.cpp | 2 +- cocos2dx/platform/win32/CCFileUtils.cpp | 16 ++ cocos2dx/platform/win32/CCGL.h | 2 + cocos2dx/platform/win32/CCImage.cpp | 2 +- cocos2dx/shaders/CCGLProgram.cpp | 4 +- cocos2dx/sprite_nodes/CCAnimationCache.cpp | 2 +- cocos2dx/sprite_nodes/CCSprite.cpp | 2 +- cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp | 8 +- cocos2dx/support/CCUserDefault.cpp | 2 +- cocos2dx/support/data_support/ccCArray.cpp | 139 +++++++++--------- cocos2dx/support/data_support/ccCArray.h | 21 +-- cocos2dx/support/image_support/TGAlib.cpp | 2 +- cocos2dx/support/zip_support/ZipUtils.cpp | 4 +- cocos2dx/textures/CCTextureCache.cpp | 28 ++-- cocos2dx/textures/CCTexturePVR.cpp | 4 +- cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h | 2 +- .../tileMap_parallax_nodes/CCTMXXMLParser.cpp | 14 +- .../tileMap_parallax_nodes/CCTileMapAtlas.cpp | 2 +- 38 files changed, 209 insertions(+), 202 deletions(-) diff --git a/cocos2dx/CCDrawingPrimitives.cpp b/cocos2dx/CCDrawingPrimitives.cpp index 8a54460889..f1e4161e3c 100644 --- a/cocos2dx/CCDrawingPrimitives.cpp +++ b/cocos2dx/CCDrawingPrimitives.cpp @@ -33,6 +33,7 @@ THE SOFTWARE. #include "CCShaderCache.h" #include "CCGLProgram.h" #include "CCActionCatmullRom.h" +#include "CCPointExtension.h" #include #include @@ -167,9 +168,9 @@ void ccDrawSolidRect( CCPoint origin, CCPoint destination, ccColor4F color ) { CCPoint vertices[] = { origin, - {destination.x, origin.y}, + ccp(destination.x, origin.y), destination, - {origin.x, destination.y}, + ccp(origin.x, destination.y) }; ccDrawSolidPoly(vertices, 4, color ); diff --git a/cocos2dx/cocoa/CCArray.cpp b/cocos2dx/cocoa/CCArray.cpp index 135e210ae2..0ee2b94b5e 100644 --- a/cocos2dx/cocoa/CCArray.cpp +++ b/cocos2dx/cocoa/CCArray.cpp @@ -145,7 +145,7 @@ bool CCArray::init() bool CCArray::initWithObject(CCObject* pObject) { - ccArrayFree(&data); + ccArrayFree(data); bool bRet = initWithCapacity(1); if (bRet) { @@ -157,7 +157,7 @@ bool CCArray::initWithObject(CCObject* pObject) /** Initializes an array with some objects */ bool CCArray::initWithObjects(CCObject* pObject, ...) { - ccArrayFree(&data); + ccArrayFree(data); bool bRet = false; do { @@ -191,14 +191,14 @@ bool CCArray::initWithObjects(CCObject* pObject, ...) bool CCArray::initWithCapacity(unsigned int capacity) { - ccArrayFree(&data); + ccArrayFree(data); data = ccArrayNew(capacity); return true; } bool CCArray::initWithArray(CCArray* otherArray) { - ccArrayFree(&data); + ccArrayFree(data); bool bRet = false; do { @@ -255,7 +255,7 @@ bool CCArray::containsObject(CCObject* object) bool CCArray::isEqualToArray(CCArray* otherArray) { - for (int i = 0; i< this->count(); i++) + for (unsigned int i = 0; i< this->count(); i++) { if (!this->objectAtIndex(i)->isEqual(otherArray->objectAtIndex(i))) { @@ -367,7 +367,7 @@ void CCArray::reduceMemoryFootprint() CCArray::~CCArray() { - ccArrayFree(&data); + ccArrayFree(data); } @@ -394,7 +394,7 @@ CCObject* CCArray::copyWithZone(CCZone* pZone) void CCArray::insertionSortUsingCFuncComparator(cc_comparator comparator) { - cc_insertionSort(data, comparator); +//TODO: cc_insertionSort(data, comparator); } //#pragma mark CCArray qsortUsingCFuncComparator @@ -411,7 +411,7 @@ void CCArray::qsortUsingCFuncComparator(cc_comparator comparator) void CCArray::mergesortLUsingCFuncComparator(cc_comparator comparator) { - cc_mergesortL(data, sizeof (CCObject*), comparator); +//TODO: cc_mergesortL(data, sizeof (CCObject*), comparator); } //#pragma mark CCArray insertionSort with (SEL)selector @@ -508,19 +508,4 @@ void CCArray::sortUsingFunction(int (*compare)(CCObject*, CCObject*, SEL_Compare free(B); } -void CCArray::makeObjectsPerformSelector(SEL_CallFunc aSelector) -{ - ccArrayMakeObjectsPerformSelector(data, aSelector); -} - -void CCArray::makeObjectsPerformSelectorWithObject(SEL_CallFuncO aSelector, CCObject* object) -{ - ccArrayMakeObjectsPerformSelectorWithObject(data, aSelector, object); -} - -void CCArray::makeObjectPerformSelectorWithArrayObjects(CCObject* object, SEL_CallFuncO aSelector) -{ - ccArrayMakeObjectPerformSelectorWithArrayObjects(data, aSelector, object); -} - NS_CC_END diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index dad04d5942..a8fd9deafa 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -211,14 +211,7 @@ public: void insertionSort(SEL_Compare selector); // It sorts source array in ascending order void sortUsingFunction(int (*compare)(CCObject*, CCObject*, SEL_Compare) , SEL_Compare context); void sortUsingSelector(SEL_Compare selector); - - // Sending Messages to Elements - - void makeObjectsPerformSelector(SEL_CallFunc aSelector); - void makeObjectsPerformSelectorWithObject(SEL_CallFuncO aSelector, CCObject* object); - /** @since 1.1 */ - void makeObjectPerformSelectorWithArrayObjects(CCObject* object, SEL_CallFuncO aSelector); - + /* override functions */ virtual CCObject* copyWithZone(CCZone* pZone); diff --git a/cocos2dx/cocoa/CCData.cpp b/cocos2dx/cocoa/CCData.cpp index fea7f5cf02..89b390ce1d 100644 --- a/cocos2dx/cocoa/CCData.cpp +++ b/cocos2dx/cocoa/CCData.cpp @@ -45,7 +45,7 @@ CCData::~CCData(void) CCData* CCData::dataWithContentsOfFile(const string &strPath) { unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::getFileData(strPath.c_str(), "rb", &nSize); + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(strPath.c_str(), "rb", &nSize); if (! pBuffer) { diff --git a/cocos2dx/cocoa/CCString.cpp b/cocos2dx/cocoa/CCString.cpp index 16cd420eef..bc3747c21b 100644 --- a/cocos2dx/cocoa/CCString.cpp +++ b/cocos2dx/cocoa/CCString.cpp @@ -185,7 +185,7 @@ CCString* CCString::stringWithContentsOfFile(const char* pszFileName) unsigned long size = 0; unsigned char* pData = 0; CCString* pRet = NULL; - pData = CCFileUtils::getFileData(pszFileName, "rb", &size); + pData = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(pszFileName, "rb", &size); pRet = stringWithData(pData, size); CC_SAFE_DELETE_ARRAY(pData); return pRet; diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp index 24c00f96ed..69bbdbfd15 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp @@ -74,7 +74,7 @@ bool CCControlButton::initWithLabelAndBackgroundSprite(CCNode* node, CCScale9Spr m_zoomOnTouchDown = true; // Set the default anchor point - setIsRelativeAnchorPoint(true); + setIgnoreAnchorPointForPosition(false); setAnchorPoint(ccp(0.5f, 0.5f)); // Set the nodes diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp b/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp index 771054cf4a..a3c8672215 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp @@ -68,7 +68,7 @@ CCControlSlider* CCControlSlider::sliderWithSprites(CCSprite * backgroundSprite, { if (CCControl::init()) { - setIsRelativeAnchorPoint(true); + setIgnoreAnchorPointForPosition(false); setIsTouchEnabled(true); m_backgroundSprite=backgroundSprite; diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp index 824d27dd0d..8bae8159e7 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp @@ -309,7 +309,7 @@ bool CCControlSwitch::initWithMaskSprite(CCSprite *maskSprite, CCSprite * onSpri m_pSwitchSprite->setPosition(ccp (m_pSwitchSprite->getContentSize().width / 2, m_pSwitchSprite->getContentSize().height / 2)); addChild(m_pSwitchSprite); - setIsRelativeAnchorPoint(true); + setIgnoreAnchorPointForPosition(false); setAnchorPoint(ccp (0.5f, 0.5f)); setContentSize(m_pSwitchSprite->getContentSize()); return true; diff --git a/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp b/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp index cb6536fcee..b641ac732e 100644 --- a/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp @@ -53,7 +53,7 @@ bool CCMenuPassive::initWithItems(CCNode* item, va_list args) CCSize s = CCDirector::sharedDirector()->getWinSize(); // Set the default anchor point - setIsRelativeAnchorPoint(false); + setIgnoreAnchorPointForPosition(true); setAnchorPoint(ccp(0.5f, 0.5f)); this->setContentSize(s); diff --git a/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp b/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp index ca3185d906..b3b3b47437 100644 --- a/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp +++ b/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp @@ -50,7 +50,7 @@ CCTextureWatcher::CCTextureWatcher() // the menu of disabling touch event //* - CCLabelTTF *label = CCLabelTTF::labelWithString(" ", size, CCTextAlignmentLeft, "Arial", 12); + CCLabelTTF *label = CCLabelTTF::labelWithString(" ", size, kCCTextAlignmentLeft, kCCVerticalTextAlignmentTop, "Arial", 12); CCMenuItemLabel *menuItem = CCMenuItemLabel::itemWithLabel(label); menuItem->setAnchorPoint(ccp(0, 0)); menuItem->setPosition(ccp(0, 0)); @@ -98,7 +98,7 @@ CCTextureWatcher::CCTextureWatcher() m_pLayer->addChild(menu1); // label page - m_labelPage = CCLabelTTF::labelWithString(" ", CCSizeMake(size.width * 0.1, labelFresh->getContentSize().height), CCTextAlignmentCenter, "Arial", 16); + m_labelPage = CCLabelTTF::labelWithString(" ", CCSizeMake(size.width * 0.1, labelFresh->getContentSize().height), kCCTextAlignmentCenter, kCCVerticalTextAlignmentTop, "Arial", 16); m_labelPage->setAnchorPoint(ccp(0.5, 0)); m_labelPage->setPosition(ccp(size.width/2.0, 0)); m_pLayer->addChild(m_labelPage, 0); @@ -314,7 +314,7 @@ void CCTextureWatcher::CCListView_cellForRow(CCListView *listView, CCListViewPro string name = key.substr(pos, len - pos); sprintf(m_pszString, "%s", name.c_str()); CCSize dimensions = CCSizeMake(listItemSize.width * 0.9f, labelSize->getContentSize().height); - CCLabelTTF *labelName = CCLabelTTF::labelWithString(m_pszString, dimensions, CCTextAlignmentCenter, "Arial", 16); + CCLabelTTF *labelName = CCLabelTTF::labelWithString(m_pszString, dimensions, kCCTextAlignmentCenter, kCCVerticalTextAlignmentTop, "Arial", 16); offX = offsetX + listItemSize.width * 0.5f; offY = offY + labelName->getContentSize().height; labelName->setPosition(ccp(offX, offY)); diff --git a/cocos2dx/label_nodes/CCLabelAtlas.cpp b/cocos2dx/label_nodes/CCLabelAtlas.cpp index 55ee293a99..f2ae74627b 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.cpp +++ b/cocos2dx/label_nodes/CCLabelAtlas.cpp @@ -85,7 +85,7 @@ CCLabelAtlas* CCLabelAtlas::labelWithString(const char *string, const char *fntF bool CCLabelAtlas::initWithString(const char *theString, const char *fntFile) { - CCDictionary *dict = CCDictionary::dictionaryWithContentsOfFile(CCFileUtils::fullPathFromRelativePath(fntFile)); + CCDictionary *dict = CCDictionary::dictionaryWithContentsOfFile(CCFileUtils::sharedFileUtils()->sharedFileUtils()->fullPathFromRelativePath(fntFile)); CCAssert(((CCInteger*)dict->objectForKey("version"))->getValue() == 1, "Unsupported version. Upgrade cocos2d version"); diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index 89c6847a9a..296cbd1520 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -480,7 +480,7 @@ void CCBMFontConfiguration::purgeFontDefDictionary() bool CCBMFontConfiguration::parseConfigFile(const char *controlFile) { - std::string fullpath = CCFileUtils::fullPathFromRelativePath(controlFile); + std::string fullpath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(controlFile); CCString *contents = CCString::stringWithContentsOfFile(fullpath.c_str()); CCAssert(contents, "CCBMFontConfiguration::parseConfigFile | Open file error."); @@ -570,7 +570,7 @@ void CCBMFontConfiguration::parseImageFileName(std::string line, const char *fnt index2 = line.find('"', index); value = line.substr(index, index2-index); - m_sAtlasName = CCFileUtils::fullPathFromRelativeFile(value.c_str(), fntFile); + m_sAtlasName = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(value.c_str(), fntFile); } void CCBMFontConfiguration::parseInfoArguments(std::string line) @@ -754,7 +754,7 @@ CCLabelBMFont *CCLabelBMFont::labelWithString(const char *str, const char *fntFi bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile) { - return initWithString(theString, fntFile, kCCLabelAutomaticWidth, CCTextAlignmentLeft, CCPointZero); + return initWithString(theString, fntFile, kCCLabelAutomaticWidth, kCCTextAlignmentLeft, CCPointZero); } bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile, float width, CCTextAlignment alignment) @@ -1247,7 +1247,7 @@ void CCLabelBMFont::updateLabel() } // Step 2: Make alignment - if (m_pAlignment != CCTextAlignmentLeft) + if (m_pAlignment != kCCTextAlignmentLeft) { int i = 0; @@ -1272,11 +1272,12 @@ void CCLabelBMFont::updateLabel() float shift = 0; switch (m_pAlignment) { - case CCTextAlignmentCenter: + case kCCTextAlignmentCenter: shift = getContentSize().width/2.0f - lineWidth/2.0f; break; - case CCTextAlignmentRight: + case kCCTextAlignmentRight: shift = getContentSize().width - lineWidth; + break; default: break; } diff --git a/cocos2dx/label_nodes/CCLabelTTF.cpp b/cocos2dx/label_nodes/CCLabelTTF.cpp index fece124454..cb04d43ed1 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.cpp +++ b/cocos2dx/label_nodes/CCLabelTTF.cpp @@ -39,7 +39,7 @@ NS_CC_BEGIN //CCLabelTTF // CCLabelTTF::CCLabelTTF() - : m_eAlignment(CCTextAlignmentCenter) + : m_eAlignment(kCCTextAlignmentCenter) , m_pFontName(NULL) , m_fFontSize(0.0) , m_pString(NULL) @@ -137,7 +137,7 @@ void CCLabelTTF::setString(const char *label) else { texture = new CCTexture2D(); - texture->initWithString(label, m_tDimensions, m_eAlignment, m_pFontName->c_str(), m_fFontSize); +//cjh texture->initWithString(label, m_tDimensions, m_eAlignment, kCCVerticalTextAlignmentTop, m_pFontName->c_str(), m_fFontSize); } // TODO diff --git a/cocos2dx/menu_nodes/CCMenu.cpp b/cocos2dx/menu_nodes/CCMenu.cpp index 32f5e562a5..9d07aced9e 100644 --- a/cocos2dx/menu_nodes/CCMenu.cpp +++ b/cocos2dx/menu_nodes/CCMenu.cpp @@ -119,7 +119,7 @@ bool CCMenu::initWithArray(CCArray* pArrayOfItems) // menu in the center of the screen CCSize s = CCDirector::sharedDirector()->getWinSize(); - this->ignoreAnchorPointForPosition = true; + this->setIgnoreAnchorPointForPosition(true); setAnchorPoint(ccp(0.5f, 0.5f)); this->setContentSize(s); diff --git a/cocos2dx/misc_nodes/CCRenderTexture.cpp b/cocos2dx/misc_nodes/CCRenderTexture.cpp index e74abbb211..1a758c8acc 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.cpp +++ b/cocos2dx/misc_nodes/CCRenderTexture.cpp @@ -374,7 +374,7 @@ bool CCRenderTexture::saveToFile(const char *fileName, tCCImageFormat format) CCImage *pImage = newCCImage(); if (pImage) { - std::string fullpath = CCFileUtils::getWriteablePath() + fileName; + std::string fullpath = CCFileUtils::sharedFileUtils()->getWriteablePath() + fileName; bRet = pImage->saveToFile(fullpath.c_str(), true); } diff --git a/cocos2dx/particle_nodes/CCParticleSystem.cpp b/cocos2dx/particle_nodes/CCParticleSystem.cpp index 2a9b80a788..b6d57a9569 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystem.cpp @@ -150,7 +150,7 @@ bool CCParticleSystem::init() bool CCParticleSystem::initWithFile(const char *plistFile) { bool bRet = false; - m_sPlistFile = CCFileUtils::fullPathFromRelativePath(plistFile); + m_sPlistFile = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(plistFile); CCDictionary *dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(m_sPlistFile.c_str()); CCAssert( dict != NULL, "Particles: file not found"); @@ -276,19 +276,19 @@ bool CCParticleSystem::initWithDictionary(CCDictionary *dictionary) // texture // Try to get the texture from the cache const char* textureName = dictionary->valueForKey("textureFileName")->getCString(); - std::string fullpath = CCFileUtils::fullPathFromRelativeFile(textureName, m_sPlistFile.c_str()); + std::string fullpath = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(textureName, m_sPlistFile.c_str()); CCTexture2D *tex = NULL; if (strlen(textureName) > 0) { // set not pop-up message box when load image failed - bool bNotify = CCFileUtils::getIsPopupNotify(); - CCFileUtils::setIsPopupNotify(false); + bool bNotify = CCFileUtils::sharedFileUtils()->getIsPopupNotify(); + CCFileUtils::sharedFileUtils()->setIsPopupNotify(false); tex = CCTextureCache::sharedTextureCache()->addImage(fullpath.c_str()); // reset the value of UIImage notify - CCFileUtils::setIsPopupNotify(bNotify); + CCFileUtils::sharedFileUtils()->setIsPopupNotify(bNotify); } if (tex) diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp index 53c1f3ffa4..306f1c336d 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp @@ -237,8 +237,8 @@ void CCParticleSystemQuad::updateQuadWithParticle(tCCParticle* particle, const C quad = &(m_pQuads[m_uParticleIdx]); } ccColor4B color = (m_bOpacityModifyRGB) - ? (ccColor4B){ particle->color.r*particle->color.a*255, particle->color.g*particle->color.a*255, particle->color.b*particle->color.a*255, particle->color.a*255} - : (ccColor4B){ particle->color.r*255, particle->color.g*255, particle->color.b*255, particle->color.a*255}; + ? ccc4( particle->color.r*particle->color.a*255, particle->color.g*particle->color.a*255, particle->color.b*particle->color.a*255, particle->color.a*255) + : ccc4( particle->color.r*255, particle->color.g*255, particle->color.b*255, particle->color.a*255); quad->bl.colors = color; quad->br.colors = color; diff --git a/cocos2dx/platform/CCFileUtils.h b/cocos2dx/platform/CCFileUtils.h index 7c91d41783..b4e83fde1d 100644 --- a/cocos2dx/platform/CCFileUtils.h +++ b/cocos2dx/platform/CCFileUtils.h @@ -34,7 +34,8 @@ NS_CC_BEGIN class CC_DLL CCFileUtils { public: - + static CCFileUtils* sharedFileUtils(); + static void purgeFileUtils(); /** @brief Get resource file data @param[in] pszFileName The resource file name which contain the path @@ -43,7 +44,7 @@ public: @return if success,the pointer of data will be returned,or NULL is returned @warning If you get the file data succeed,you must delete it after used. */ - static unsigned char* getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize); + unsigned char* getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize); /** @brief Get resource file data from zip file @@ -52,7 +53,7 @@ public: @return if success,the pointer of data will be returned,or NULL is returned @warning If you get the file data succeed,you must delete it after used. */ - static unsigned char* getFileDataFromZip(const char* pszZipFilePath, const char* pszFileName, unsigned long * pSize); + unsigned char* getFileDataFromZip(const char* pszZipFilePath, const char* pszFileName, unsigned long * pSize); /** removes the suffix from a path * On RetinaDisplay it will remove the -hd suffix @@ -62,7 +63,7 @@ public: @since v0.99.5 */ - static std::string& removeSuffixFromFile(std::string& path); + std::string& removeSuffixFromFile(std::string& path); /** @brief Generate the absolute path of the file. @@ -72,7 +73,7 @@ public: If you have not set the ResourcePath,the function add "/NEWPLUS/TDA_DATA/UserData/" as default. You can set ResourcePath by function void setResourcePath(const char *pszResourcePath); */ - static const char* fullPathFromRelativePath(const char *pszRelativePath); + const char* fullPathFromRelativePath(const char *pszRelativePath); /** Returns the fullpath of an filename including the resolution of the image. @@ -88,10 +89,10 @@ public: If a RetinaDisplay file is found, it will set resolution type to kCCResolutionRetinaDisplay */ - static const char* fullPathFromRelativePath(const char *pszRelativePath, ccResolutionType *pResolutionType); + const char* fullPathFromRelativePath(const char *pszRelativePath, ccResolutionType *pResolutionType); /// @cond - static const char* fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile); + const char* fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile); /// @endcond /** Sets the iPhone RetinaDisplay suffix to load resources. @@ -100,7 +101,7 @@ public: @since v1.1 */ - static void setiPhoneRetinaDisplaySuffix(const char *suffix); + void setiPhoneRetinaDisplaySuffix(const char *suffix); /** Sets the iPad suffix to load resources. By default it is "". @@ -108,7 +109,7 @@ public: */ - static void setiPadSuffix(const char *suffix); + void setiPadSuffix(const char *suffix); /** Sets the iPad Retina Display suffix to load resources. By default it is "-ipadhd". @@ -116,7 +117,7 @@ public: @since v1.1 */ - static void setiPadRetinaDisplaySuffix(const char *suffix); + void setiPadRetinaDisplaySuffix(const char *suffix); /** Returns whether or not a given filename exists with the iPad suffix. Only available on iOS. Not supported on OS X. @@ -124,9 +125,9 @@ public: */ bool iPadFileExistsAtPath(const char *filename); - /** Returns whether or not a given filename exists with the iPad RetinaDisplay suffix. - Only available on iOS. Not supported on OS X. - + /** Returns whether or not a given filename exists with the iPad RetinaDisplay suffix. + Only available on iOS. Not supported on OS X. + @since v2.0 */ bool iPadRetinaDisplayFileExistsAtPath(const char *filename); @@ -143,24 +144,19 @@ public: In android, if you want to read file other than apk, you shoud use invoke getFileData(), and pass the absolute path. */ - static void setResourcePath(const char *pszResourcePath); + void setResourcePath(const char *pszResourcePath); /** @brief Get the writeable path @return The path that can write/read file */ - static std::string getWriteablePath(); + std::string getWriteablePath(); /** @brief Set/Get whether pop-up a message box when the image load failed */ - static void setIsPopupNotify(bool bNotify); - static bool getIsPopupNotify(); - - /////////////////////////////////////////////////// - // interfaces on ios - /////////////////////////////////////////////////// - static int ccLoadFileIntoMemory(const char *filename, unsigned char **out); + void setIsPopupNotify(bool bNotify); + bool getIsPopupNotify(); }; NS_CC_END diff --git a/cocos2dx/platform/CCImageCommon_cpp.h b/cocos2dx/platform/CCImageCommon_cpp.h index e393a31fea..80e7788683 100644 --- a/cocos2dx/platform/CCImageCommon_cpp.h +++ b/cocos2dx/platform/CCImageCommon_cpp.h @@ -97,7 +97,7 @@ bool CCImage::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = e CC_UNUSED_PARAM(eImgFmt); unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::getFileData(CCFileUtils::fullPathFromRelativePath(strPath), "rb", &nSize); + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(strPath), "rb", &nSize); return initWithImageData(pBuffer, nSize, eImgFmt); } @@ -107,7 +107,7 @@ bool CCImage::initWithImageFileThreadSafe(const char *fullpath, EImageFormat ima CC_UNUSED_PARAM(imageType); unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::getFileData(fullpath, "rb", &nSize); + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(fullpath, "rb", &nSize); return initWithImageData(pBuffer, nSize, imageType); } diff --git a/cocos2dx/platform/CCPlatformMacros.h b/cocos2dx/platform/CCPlatformMacros.h index ce752969d2..b1d5a458c8 100644 --- a/cocos2dx/platform/CCPlatformMacros.h +++ b/cocos2dx/platform/CCPlatformMacros.h @@ -166,22 +166,27 @@ public: virtual void set##funName(varType var) \ #define CC_SAFE_RETAIN(p) do { if(p) { (p)->retain(); } } while(0) #define CC_BREAK_IF(cond) if(cond) break +#define __CCLOGWITHFUNCTION(s, ...) \ + CCLog("%s : %s",__FUNCTION__, CCString::stringWithFormat(s, ##__VA_ARGS__)->getCString()) // cocos2d debug #if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0 -#define CCLOG(...) -#define CCLOGINFO(...) -#define CCLOGERROR(...) +#define CCLOG(...) do {} while (0) +#define CCLOGINFO(...) do {} while (0) +#define CCLOGERROR(...) do {} while (0) +#define CCLOGWARN(...) do {} while (0) #elif COCOS2D_DEBUG == 1 #define CCLOG(format, ...) cocos2d::CCLog(format, ##__VA_ARGS__) #define CCLOGERROR(format,...) cocos2d::CCLog(format, ##__VA_ARGS__) #define CCLOGINFO(format,...) do {} while (0) +#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__) #elif COCOS2D_DEBUG > 1 #define CCLOG(format, ...) cocos2d::CCLog(format, ##__VA_ARGS__) #define CCLOGERROR(format,...) cocos2d::CCLog(format, ##__VA_ARGS__) #define CCLOGINFO(format,...) cocos2d::CCLog(format, ##__VA_ARGS__) +#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__) #endif // COCOS2D_DEBUG // Lua engine debug diff --git a/cocos2dx/platform/CCSAXParser.cpp b/cocos2dx/platform/CCSAXParser.cpp index 2e5b4423fe..3c7c9cbd3d 100644 --- a/cocos2dx/platform/CCSAXParser.cpp +++ b/cocos2dx/platform/CCSAXParser.cpp @@ -84,7 +84,7 @@ bool CCSAXParser::parse(const char* pXMLData, unsigned int uDataLength) bool CCSAXParser::parse(const char *pszFile) { unsigned long size; - char *pBuffer = (char*)CCFileUtils::getFileData(pszFile, "rt", &size); + char *pBuffer = (char*)CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(pszFile, "rt", &size); if (!pBuffer) { diff --git a/cocos2dx/platform/win32/CCFileUtils.cpp b/cocos2dx/platform/win32/CCFileUtils.cpp index 33a140424c..33887eb046 100644 --- a/cocos2dx/platform/win32/CCFileUtils.cpp +++ b/cocos2dx/platform/win32/CCFileUtils.cpp @@ -49,6 +49,22 @@ static void _CheckPath() } } +static CCFileUtils* s_pFileUtils = NULL; + +CCFileUtils* CCFileUtils::sharedFileUtils() +{ + if (s_pFileUtils == NULL) + { + s_pFileUtils = new CCFileUtils(); + } + return s_pFileUtils; +} + +void CCFileUtils::purgeFileUtils() +{ + CC_SAFE_DELETE(s_pFileUtils); +} + void CCFileUtils::setResourcePath(const char *pszResourcePath) { CCAssert(pszResourcePath != NULL, "[FileUtils setResourcePath] -- wrong resource path"); diff --git a/cocos2dx/platform/win32/CCGL.h b/cocos2dx/platform/win32/CCGL.h index 2a45c87796..63b4b91b4a 100644 --- a/cocos2dx/platform/win32/CCGL.h +++ b/cocos2dx/platform/win32/CCGL.h @@ -27,4 +27,6 @@ THE SOFTWARE. #include "GL/glew.h" +#define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8 + #endif // __CCGL_H__ diff --git a/cocos2dx/platform/win32/CCImage.cpp b/cocos2dx/platform/win32/CCImage.cpp index fe503a8387..5ddd5fa0c8 100644 --- a/cocos2dx/platform/win32/CCImage.cpp +++ b/cocos2dx/platform/win32/CCImage.cpp @@ -111,7 +111,7 @@ public: int nFindTTF = fontName.find(".TTF"); if (nFindttf >= 0 || nFindTTF >= 0) { - fontPath = CCFileUtils::fullPathFromRelativePath(fontName.c_str()); + fontPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(fontName.c_str()); int nFindPos = fontName.rfind("/"); fontName = &fontName[nFindPos+1]; nFindPos = fontName.rfind("."); diff --git a/cocos2dx/shaders/CCGLProgram.cpp b/cocos2dx/shaders/CCGLProgram.cpp index caf9401488..7c32c832a8 100644 --- a/cocos2dx/shaders/CCGLProgram.cpp +++ b/cocos2dx/shaders/CCGLProgram.cpp @@ -116,8 +116,8 @@ bool CCGLProgram::initWithVertexShaderByteArray(const GLchar* vShaderByteArray, bool CCGLProgram::initWithVertexShaderFilename(const char* vShaderFilename, const char* fShaderFilename) { - const GLchar * vertexSource = (GLchar*) CCString::stringWithContentsOfFile(CCFileUtils::fullPathFromRelativePath(vShaderFilename))->getCString(); - const GLchar * fragmentSource = (GLchar*) CCString::stringWithContentsOfFile(CCFileUtils::fullPathFromRelativePath(fShaderFilename))->getCString(); + const GLchar * vertexSource = (GLchar*) CCString::stringWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(vShaderFilename))->getCString(); + const GLchar * fragmentSource = (GLchar*) CCString::stringWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(fShaderFilename))->getCString(); return initWithVertexShaderByteArray(vertexSource, fragmentSource); } diff --git a/cocos2dx/sprite_nodes/CCAnimationCache.cpp b/cocos2dx/sprite_nodes/CCAnimationCache.cpp index 849decebb6..3428ee8f80 100644 --- a/cocos2dx/sprite_nodes/CCAnimationCache.cpp +++ b/cocos2dx/sprite_nodes/CCAnimationCache.cpp @@ -244,7 +244,7 @@ void CCAnimationCache::addAnimationsWithFile(const char* plist) { CCAssert( plist, "Invalid texture file name"); - const char* path = CCFileUtils::fullPathFromRelativePath(plist); + const char* path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(plist); CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFile(path); CCAssert( dict, "CCAnimationCache: File could not be found"); diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index c4be00ab7f..a1c27ee50e 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -1064,7 +1064,7 @@ void CCSprite::updateBlendFunc(void) void CCSprite::setTexture(CCTexture2D *texture) { // If batchnode, then texture id should be the same - CCAssert(! m_pobBatchNode || texture.name == m_pobBatchNode->getTexture()->getName(), "CCSprite: Batched sprites should use the same texture as the batchnode"); + CCAssert(! m_pobBatchNode || texture->getName() == m_pobBatchNode->getTexture()->getName(), "CCSprite: Batched sprites should use the same texture as the batchnode"); // accept texture==nil as argument CCAssert( !texture || dynamic_cast(texture), "setTexture expects a CCTexture2D. Invalid argument"); diff --git a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp index d9d30c765e..5ba469a81e 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp @@ -202,7 +202,7 @@ void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary* dictionary, void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist, CCTexture2D *pobTexture) { - const char *pszPath = CCFileUtils::fullPathFromRelativePath(pszPlist); + const char *pszPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pszPlist); CCDictionary *dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(pszPath); addSpriteFramesWithDictionary(dict, pobTexture); @@ -231,7 +231,7 @@ void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist) if (m_pLoadedFileNames->find(pszPlist) != m_pLoadedFileNames->end()) { - const char *pszPath = CCFileUtils::fullPathFromRelativePath(pszPlist); + const char *pszPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pszPlist); CCDictionary *dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(pszPath); string texturePath(""); @@ -246,7 +246,7 @@ void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist) if (! texturePath.empty()) { // build texture path relative to plist file - texturePath = CCFileUtils::fullPathFromRelativeFile(texturePath.c_str(), pszPath); + texturePath = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(texturePath.c_str(), pszPath); } else { @@ -342,7 +342,7 @@ void CCSpriteFrameCache::removeSpriteFrameByName(const char *pszName) void CCSpriteFrameCache::removeSpriteFramesFromFile(const char* plist) { - const char* path = CCFileUtils::fullPathFromRelativePath(plist); + const char* path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(plist); CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(path); removeSpriteFramesFromDictionary((CCDictionary*)dict); diff --git a/cocos2dx/support/CCUserDefault.cpp b/cocos2dx/support/CCUserDefault.cpp index 927a4371e0..030ef9c26b 100644 --- a/cocos2dx/support/CCUserDefault.cpp +++ b/cocos2dx/support/CCUserDefault.cpp @@ -324,7 +324,7 @@ void CCUserDefault::initXMLFilePath() { if (! m_sbIsFilePathInitialized) { - m_sFilePath += CCFileUtils::getWriteablePath() + XML_FILE_NAME; + m_sFilePath += CCFileUtils::sharedFileUtils()->getWriteablePath() + XML_FILE_NAME; m_sbIsFilePathInitialized = true; } } diff --git a/cocos2dx/support/data_support/ccCArray.cpp b/cocos2dx/support/data_support/ccCArray.cpp index 26128aa163..72e8b17fa4 100644 --- a/cocos2dx/support/data_support/ccCArray.cpp +++ b/cocos2dx/support/data_support/ccCArray.cpp @@ -42,16 +42,16 @@ ccArray* ccArrayNew(unsigned int capacity) { } /** Frees array after removing all remaining objects. Silently ignores NULL arr. */ -void ccArrayFree(ccArray **arr) +void ccArrayFree(ccArray*& arr) { - if( arr == NULL || *arr == NULL) return; + if( arr == NULL) return; - ccArrayRemoveAllObjects(*arr); + ccArrayRemoveAllObjects(arr); - free((*arr)->arr); - free(*arr); + free(arr->arr); + free(arr); - *arr = NULL; + arr = NULL; } void ccArrayDoubleCapacity(ccArray *arr) @@ -267,7 +267,7 @@ ccCArray* ccCArrayNew(unsigned int capacity) ccCArray *arr = (ccCArray*)malloc( sizeof(ccCArray) ); arr->num = 0; - arr->arr = (CCARRAY_ID *) malloc( capacity * sizeof(CCObject*) ); + arr->arr = (void**)malloc( capacity * sizeof(void*) ); arr->max = capacity; return arr; @@ -287,35 +287,40 @@ void ccCArrayFree(ccCArray *arr) /** Doubles C array capacity */ void ccCArrayDoubleCapacity(ccCArray *arr) { - ccArrayDoubleCapacity(arr); + arr->max *= 2; + void** newArr = (void**)realloc( arr->arr, arr->max * sizeof(void*) ); + // will fail when there's not enough memory + CCAssert(newArr != NULL, "ccCArrayDoubleCapacity failed. Not enough memory"); + arr->arr = newArr; } /** Increases array capacity such that max >= num + extra. */ void ccCArrayEnsureExtraCapacity(ccCArray *arr, unsigned int extra) { - ccArrayEnsureExtraCapacity(arr,extra); + while (arr->max < arr->num + extra) + ccCArrayDoubleCapacity(arr); } /** Returns index of first occurence of value, CC_INVALID_INDEX if value not found. */ -unsigned int ccCArrayGetIndexOfValue(ccCArray *arr, CCARRAY_ID value) +unsigned int ccCArrayGetIndexOfValue(ccCArray *arr, void* value) { unsigned int i; for( i = 0; i < arr->num; i++) { - if( arr->arr[i]->isEqual(value) ) return i; + if( arr->arr[i] == value ) return i; } return CC_INVALID_INDEX; } /** Returns a Boolean value that indicates whether value is present in the C array. */ -bool ccCArrayContainsValue(ccCArray *arr, CCARRAY_ID value) +bool ccCArrayContainsValue(ccCArray *arr, void* value) { return ccCArrayGetIndexOfValue(arr, value) != CC_INVALID_INDEX; } /** Inserts a value at a certain position. Behaviour undefined if aray doesn't have enough capacity */ -void ccCArrayInsertValueAtIndex( ccCArray *arr, CCARRAY_ID value, unsigned int index) +void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, unsigned int index) { CCAssert( index < arr->max, "ccCArrayInsertValueAtIndex: invalid index"); @@ -332,14 +337,14 @@ void ccCArrayInsertValueAtIndex( ccCArray *arr, CCARRAY_ID value, unsigned int i } /** Appends an value. Bahaviour undefined if array doesn't have enough capacity. */ -void ccCArrayAppendValue(ccCArray *arr, CCARRAY_ID value) +void ccCArrayAppendValue(ccCArray *arr, void* value) { arr->arr[arr->num] = (CCObject*) value; arr->num++; } /** Appends an value. Capacity of arr is increased if needed. */ -void ccCArrayAppendValueWithResize(ccCArray *arr, CCARRAY_ID value) +void ccCArrayAppendValueWithResize(ccCArray *arr, void* value) { ccCArrayEnsureExtraCapacity(arr, 1); ccCArrayAppendValue(arr, value); @@ -397,7 +402,7 @@ void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, unsigned int index) /** Searches for the first occurance of value and removes it. If value is not found the function has no effect. @since v0.99.4 */ -void ccCArrayRemoveValue(ccCArray *arr, CCARRAY_ID value) +void ccCArrayRemoveValue(ccCArray *arr, void* value) { unsigned int index = ccCArrayGetIndexOfValue(arr, value); if (index != CC_INVALID_INDEX) @@ -446,55 +451,55 @@ void cc_pointerswap(void* a, void* b, size_t width) // http://www.inf.fh-flensburg.de/lang/algorithmen/sortieren/merge/mergiter.htm int cc_mergesortL(ccCArray* array, size_t width, cc_comparator comparator) { - CCARRAY_ID *arr = array->arr; - int i,j,k,s,m,n= array->num; - - CCARRAY_ID *B = (CCARRAY_ID*) malloc((n/2 + 1) * width); - for (s = 1; s < n; s += s) - { - for (m = n-1-s; m >= 0; m -= s+s) - { - int lo = MAX(m-(s+1),0); - int hi = m+s; - - j = lo; - - if (m-j > 0) - { - //triggers a warning when compiled with ARC, B needs to be strong typed, for compiling for obj-c++ - //memcpy aritmetics aren't allowed on void* types - //explicitely casting didn't work -// #pragma clang diagnostic push -// #if defined(__has_feature) && __has_feature(objc_arc) -// #pragma clang diagnostic ignored "-Warc-non-pod-memaccess" -// #endif - - memcpy(B, &arr[j], (m-j) * width); -//#pragma clang diagnostic pop - } - - i = 0; - j = m; - k = lo; - - while (karr; +// int i,j,k,s,m,n= array->num; +// +// void *B = malloc((n/2 + 1) * width); +// for (s = 1; s < n; s += s) +// { +// for (m = n-1-s; m >= 0; m -= s+s) +// { +// int lo = MAX(m-(s+1),0); +// int hi = m+s; +// +// j = lo; +// +// if (m-j > 0) +// { +// //triggers a warning when compiled with ARC, B needs to be strong typed, for compiling for obj-c++ +// //memcpy aritmetics aren't allowed on void* types +// //explicitely casting didn't work +// // #pragma clang diagnostic push +// // #if defined(__has_feature) && __has_feature(objc_arc) +// // #pragma clang diagnostic ignored "-Warc-non-pod-memaccess" +// // #endif +// +// memcpy(B, &arr[j], (m-j) * width); +// //#pragma clang diagnostic pop +// } +// +// i = 0; +// j = m; +// k = lo; +// +// while (knum; - CCARRAY_ID *x = arr->arr; - CCObject* temp; + void** x = arr->arr; + void* temp; // insertion sort for(i=1; iarr[0]; for(unsigned int i=0, num=__array__->num; isharedFileUtils()->getFileData(pszFilename, "rb", &nSize); do { diff --git a/cocos2dx/support/zip_support/ZipUtils.cpp b/cocos2dx/support/zip_support/ZipUtils.cpp index 44666378df..f8217f7639 100644 --- a/cocos2dx/support/zip_support/ZipUtils.cpp +++ b/cocos2dx/support/zip_support/ZipUtils.cpp @@ -217,8 +217,8 @@ namespace cocos2d unsigned char *compressed = NULL; int fileLen = 0; - compressed = CCFileUtils::getFileData(path, "rb", (unsigned long *)(&fileLen)); - // int fileLen = CCFileUtils::ccLoadFileIntoMemory( path, &compressed ); + compressed = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(path, "rb", (unsigned long *)(&fileLen)); + // int fileLen = CCFileUtils::sharedFileUtils()->ccLoadFileIntoMemory( path, &compressed ); if( fileLen < 0 ) { diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index b3017a95a5..8bb6cf5fe1 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -258,9 +258,9 @@ void CCTextureCache::addImageAsync(const char *path, CCObject *target, SEL_CallF // optimization std::string pathKey = path; - CCFileUtils::removeSuffixFromFile(pathKey); + CCFileUtils::sharedFileUtils()->removeSuffixFromFile(pathKey); - pathKey = CCFileUtils::fullPathFromRelativePath(pathKey.c_str()); + pathKey = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pathKey.c_str()); texture = (CCTexture2D*)m_pTextures->objectForKey(pathKey.c_str()); std::string fullpath = pathKey; @@ -402,12 +402,12 @@ CCTexture2D * CCTextureCache::addImage(const char * path) // remove possible -HD suffix to prevent caching the same image twice (issue #1040) std::string pathKey = path; ccResolutionType resolution = kCCResolutionUnknown; - CCFileUtils::removeSuffixFromFile(pathKey); + CCFileUtils::sharedFileUtils()->removeSuffixFromFile(pathKey); - pathKey = CCFileUtils::fullPathFromRelativePath(pathKey.c_str()); + pathKey = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pathKey.c_str()); texture = (CCTexture2D*)m_pTextures->objectForKey(pathKey.c_str()); - std::string fullpath = pathKey; // (CCFileUtils::fullPathFromRelativePath(path)); + std::string fullpath = pathKey; // (CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(path)); if( ! texture ) { std::string lowerCase(path); @@ -440,7 +440,7 @@ CCTexture2D * CCTextureCache::addImage(const char * path) CCImage image; unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::getFileData(fullpath.c_str(), "rb", &nSize); + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(fullpath.c_str(), "rb", &nSize); CC_BREAK_IF(! image.initWithImageData((void*)pBuffer, nSize, eImageFormat)); texture = new CCTexture2D(); @@ -478,7 +478,7 @@ CCTexture2D* CCTextureCache::addPVRTCImage(const char* path, int bpp, bool hasAl CCTexture2D * texture; std::string temp(path); - CCFileUtils::removeSuffixFromFile(temp); + CCFileUtils::sharedFileUtils()->removeSuffixFromFile(temp); if ( (texture = (CCTexture2D*)m_pTextures->objectForKey(temp.c_str())) ) { @@ -486,7 +486,7 @@ CCTexture2D* CCTextureCache::addPVRTCImage(const char* path, int bpp, bool hasAl } // Split up directory and filename - std::string fullpath( CCFileUtils::fullPathFromRelativePath(path) ); + std::string fullpath( CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(path) ); CCData * data = CCData::dataWithContentsOfFile(fullpath); texture = new CCTexture2D(); @@ -514,7 +514,7 @@ CCTexture2D * CCTextureCache::addPVRImage(const char* path) CCTexture2D* tex = NULL; std::string key(path); // remove possible -HD suffix to prevent caching the same image twice (issue #1040) - CCFileUtils::removeSuffixFromFile(key); + CCFileUtils::sharedFileUtils()->removeSuffixFromFile(key); if( (tex = (CCTexture2D*)m_pTextures->objectForKey(key.c_str())) ) { @@ -522,7 +522,7 @@ CCTexture2D * CCTextureCache::addPVRImage(const char* path) } // Split up directory and filename - std::string fullpath = CCFileUtils::fullPathFromRelativePath(key.c_str()); + std::string fullpath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(key.c_str()); tex = new CCTexture2D(); if(tex != NULL && tex->initWithPVRFile(fullpath.c_str()) ) { @@ -551,7 +551,7 @@ CCTexture2D* CCTextureCache::addUIImage(CCImage *image, const char *key) std::string forKey; if (key) { - forKey = CCFileUtils::fullPathFromRelativePath(key); + forKey = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(key); } // Don't have to lock here, because addImageAsync() will not @@ -655,13 +655,13 @@ void CCTextureCache::removeTextureForKey(const char *textureKeyName) return; } - string fullPath = CCFileUtils::fullPathFromRelativePath(textureKeyName); + string fullPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(textureKeyName); m_pTextures->removeObjectForKey(fullPath.c_str()); } CCTexture2D* CCTextureCache::textureForKey(const char* key) { - return (CCTexture2D*)m_pTextures->objectForKey(CCFileUtils::fullPathFromRelativePath(key)); + return (CCTexture2D*)m_pTextures->objectForKey(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(key)); } void CCTextureCache::reloadAllTextures() @@ -851,7 +851,7 @@ void VolatileTexture::reloadAllTextures() else { unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::getFileData(vt->m_strFileName.c_str(), "rb", &nSize); + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(vt->m_strFileName.c_str(), "rb", &nSize); if (image.initWithImageData((void*)pBuffer, nSize, vt->m_FmtImage)) diff --git a/cocos2dx/textures/CCTexturePVR.cpp b/cocos2dx/textures/CCTexturePVR.cpp index d578b88c0c..c330117d4e 100755 --- a/cocos2dx/textures/CCTexturePVR.cpp +++ b/cocos2dx/textures/CCTexturePVR.cpp @@ -33,7 +33,7 @@ THE SOFTWARE. #include "CCStdC.h" #include "CCFileUtils.h" #include "support/zip_support/ZipUtils.h" - +#include "ccGLStateCache.h" #include NS_CC_BEGIN @@ -446,7 +446,7 @@ bool CCTexturePVR::initWithContentsOfFile(const char* path) } else { - pvrdata = CCFileUtils::getFileData(path, "rb", (unsigned long *)(&pvrlen)); + pvrdata = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(path, "rb", (unsigned long *)(&pvrlen)); } if (pvrlen < 0) diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h index e831c12cf4..86d2331bd8 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h @@ -186,7 +186,7 @@ protected: //! used for optimization CCSprite *m_pReusedTile; - _ccCArray *m_pAtlasIndexArray; + ccCArray *m_pAtlasIndexArray; // used for retina display float m_fContentScaleFactor; diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp index 320f8e308f..b32a1011d1 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp @@ -158,7 +158,7 @@ void CCTMXMapInfo::internalInit(const char* tmxFileName, const char* resourcePat if (tmxFileName != NULL) { - m_sTMXFileName = CCFileUtils::fullPathFromRelativePath(tmxFileName); + m_sTMXFileName = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(tmxFileName); } if (resourcePath != NULL) @@ -359,17 +359,17 @@ void CCTMXMapInfo::startElement(void *ctx, const char *name, const char **atts) { if (m_sTMXFileName.length() == 0) { - string pszFullPath = CCFileUtils::fullPathFromRelativePath(m_sResources.c_str()); + string pszFullPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(m_sResources.c_str()); if (pszFullPath.find_last_of("/\\") != pszFullPath.length()-1) { pszFullPath.append("/"); } - externalTilesetFilename = CCFileUtils::fullPathFromRelativeFile(externalTilesetFilename.c_str(), pszFullPath.c_str() ); + externalTilesetFilename = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(externalTilesetFilename.c_str(), pszFullPath.c_str() ); } else { - externalTilesetFilename = CCFileUtils::fullPathFromRelativeFile(externalTilesetFilename.c_str(), pTMXMapInfo->getTMXFileName()); + externalTilesetFilename = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(externalTilesetFilename.c_str(), pTMXMapInfo->getTMXFileName()); } pTMXMapInfo->parseXMLFile(externalTilesetFilename.c_str()); } @@ -458,17 +458,17 @@ void CCTMXMapInfo::startElement(void *ctx, const char *name, const char **atts) std::string imagename = valueForKey("source", attributeDict); if (m_sTMXFileName.length() == 0) { - string pszFullPath = CCFileUtils::fullPathFromRelativePath(m_sResources.c_str()); + string pszFullPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(m_sResources.c_str()); if (pszFullPath.find_last_of("/\\") != pszFullPath.length()-1) { pszFullPath.append("/"); } - tileset->m_sSourceImage = CCFileUtils::fullPathFromRelativeFile(imagename.c_str(), pszFullPath.c_str() ); + tileset->m_sSourceImage = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(imagename.c_str(), pszFullPath.c_str() ); } else { - tileset->m_sSourceImage = CCFileUtils::fullPathFromRelativeFile(imagename.c_str(), pTMXMapInfo->getTMXFileName()); + tileset->m_sSourceImage = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(imagename.c_str(), pTMXMapInfo->getTMXFileName()); } } else if(elementName == "data") diff --git a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp index 0e811e3928..29e6085e4f 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp @@ -115,7 +115,7 @@ void CCTileMapAtlas::loadTGAfile(const char *file) { CCAssert( file != NULL, "file must be non-nil"); - const char* pPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(file) + const char* pPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(file); // //Find the path of the file // NSBundle *mainBndl = [CCDirector sharedDirector].loadingBundle; From 12a9d134431e4918bb4b248abc10dfaebd2a4db8 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 8 Jun 2012 16:54:38 +0800 Subject: [PATCH 105/257] issue #1310: Synchronize to RC2, HelloWorld works ok on win32. --- cocos2dx/extensions/CCBReader/CCBReader_v2.cpp | 2 +- .../extensions/CCTextureWatcher/CCTextureWatcher.cpp | 6 +++--- cocos2dx/misc_nodes/CCRenderTexture.cpp | 5 +++++ cocos2dx/particle_nodes/CCParticleSystem.cpp | 10 ++++++++++ cocos2dx/proj.win32/cocos2d-win32.vcproj | 8 ++++++++ cocos2dx/textures/CCTexture2D.h | 2 +- cocos2dx/textures/CCTexturePVR.h | 2 +- 7 files changed, 29 insertions(+), 6 deletions(-) diff --git a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp index 64e1ae0692..5cbcf8001e 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp @@ -378,7 +378,7 @@ void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* node->setScaleY(floatValFromDict(props, "scaleY")); node->setAnchorPoint(pointValFromDict(props, "anchorPoint")); node->setRotation(floatValFromDict(props, "rotation")); - node->setIsRelativeAnchorPoint(boolValFromDict(props, "isRelativeAnchorPoint")); + node->setIgnoreAnchorPointForPosition(!boolValFromDict(props, "isRelativeAnchorPoint")); node->setIsVisible(boolValFromDict(props, "visible")); if (extraProps) diff --git a/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp b/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp index b3b3b47437..780e52fc1e 100644 --- a/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp +++ b/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp @@ -50,7 +50,7 @@ CCTextureWatcher::CCTextureWatcher() // the menu of disabling touch event //* - CCLabelTTF *label = CCLabelTTF::labelWithString(" ", size, kCCTextAlignmentLeft, kCCVerticalTextAlignmentTop, "Arial", 12); + CCLabelTTF *label = CCLabelTTF::labelWithString(" ", size, kCCTextAlignmentLeft, "Arial", 12); CCMenuItemLabel *menuItem = CCMenuItemLabel::itemWithLabel(label); menuItem->setAnchorPoint(ccp(0, 0)); menuItem->setPosition(ccp(0, 0)); @@ -98,7 +98,7 @@ CCTextureWatcher::CCTextureWatcher() m_pLayer->addChild(menu1); // label page - m_labelPage = CCLabelTTF::labelWithString(" ", CCSizeMake(size.width * 0.1, labelFresh->getContentSize().height), kCCTextAlignmentCenter, kCCVerticalTextAlignmentTop, "Arial", 16); + m_labelPage = CCLabelTTF::labelWithString(" ", CCSizeMake(size.width * 0.1, labelFresh->getContentSize().height), kCCTextAlignmentCenter, "Arial", 16); m_labelPage->setAnchorPoint(ccp(0.5, 0)); m_labelPage->setPosition(ccp(size.width/2.0, 0)); m_pLayer->addChild(m_labelPage, 0); @@ -314,7 +314,7 @@ void CCTextureWatcher::CCListView_cellForRow(CCListView *listView, CCListViewPro string name = key.substr(pos, len - pos); sprintf(m_pszString, "%s", name.c_str()); CCSize dimensions = CCSizeMake(listItemSize.width * 0.9f, labelSize->getContentSize().height); - CCLabelTTF *labelName = CCLabelTTF::labelWithString(m_pszString, dimensions, kCCTextAlignmentCenter, kCCVerticalTextAlignmentTop, "Arial", 16); + CCLabelTTF *labelName = CCLabelTTF::labelWithString(m_pszString, dimensions, kCCTextAlignmentCenter, "Arial", 16); offX = offsetX + listItemSize.width * 0.5f; offY = offY + labelName->getContentSize().height; labelName->setPosition(ccp(offX, offY)); diff --git a/cocos2dx/misc_nodes/CCRenderTexture.cpp b/cocos2dx/misc_nodes/CCRenderTexture.cpp index 1a758c8acc..01e57622ae 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.cpp +++ b/cocos2dx/misc_nodes/CCRenderTexture.cpp @@ -111,6 +111,11 @@ CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w, int h) return NULL; } +bool CCRenderTexture::initWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat) +{ + return initWithWidthAndHeight(w, h, eFormat, 0); +} + bool CCRenderTexture::initWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat) { CCAssert(m_ePixelFormat != kCCTexture2DPixelFormat_A8, "only RGB and RGBA formats are valid for a render texture"); diff --git a/cocos2dx/particle_nodes/CCParticleSystem.cpp b/cocos2dx/particle_nodes/CCParticleSystem.cpp index b6d57a9569..b307d02596 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystem.cpp @@ -1183,6 +1183,16 @@ void CCParticleSystem::setBlendFunc(ccBlendFunc blendFunc) } } +bool CCParticleSystem::getOpacityModifyRGB() +{ + return m_bOpacityModifyRGB; +} + +void CCParticleSystem::setOpacityModifyRGB(bool bOpacityModifyRGB) +{ + m_bOpacityModifyRGB = bOpacityModifyRGB; +} + tCCPositionType CCParticleSystem::getPositionType() { return m_ePositionType; diff --git a/cocos2dx/proj.win32/cocos2d-win32.vcproj b/cocos2dx/proj.win32/cocos2d-win32.vcproj index 8ebe77b8b1..fb354843a5 100755 --- a/cocos2dx/proj.win32/cocos2d-win32.vcproj +++ b/cocos2dx/proj.win32/cocos2d-win32.vcproj @@ -339,6 +339,14 @@ RelativePath="..\actions\CCActionCamera.h" > + + + + diff --git a/cocos2dx/textures/CCTexture2D.h b/cocos2dx/textures/CCTexture2D.h index caefdc9825..1e5aea7c62 100644 --- a/cocos2dx/textures/CCTexture2D.h +++ b/cocos2dx/textures/CCTexture2D.h @@ -268,7 +268,7 @@ private: /** whether or not the texture has their Alpha premultiplied */ CC_PROPERTY_READONLY(bool, m_bHasPremultipliedAlpha, HasPremultipliedAlpha); - CC_PROPERTY_READONLY(bool, m_bHasMipmaps, HasMipmaps); + CC_SYNTHESIZE_READONLY(bool, m_bHasMipmaps, HasMipmaps); /** shader program used by drawAtPoint and drawInRect */ CC_PROPERTY(CCGLProgram*, m_pShaderProgram, ShaderProgram); diff --git a/cocos2dx/textures/CCTexturePVR.h b/cocos2dx/textures/CCTexturePVR.h index 91ff0d6f07..c56ccd1f9b 100644 --- a/cocos2dx/textures/CCTexturePVR.h +++ b/cocos2dx/textures/CCTexturePVR.h @@ -123,7 +123,7 @@ protected: How many mipmaps do we have. It must be at least one when proper initialization finishes */ - CC_PROPERTY_READONLY(unsigned int, m_uNumberOfMipmaps, NumberOfMipmaps); + CC_SYNTHESIZE_READONLY(unsigned int, m_uNumberOfMipmaps, NumberOfMipmaps); /* Makrs for mipmaps. Each entry contains position in file From 9ff7dcd96d790eeea8cada7cd67664075b572a9b Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 8 Jun 2012 17:15:00 +0800 Subject: [PATCH 106/257] issue #1310: Removed some functions. --- cocos2dx/cocoa/CCArray.cpp | 124 ------------- cocos2dx/cocoa/CCArray.h | 9 - cocos2dx/support/data_support/ccCArray.cpp | 204 +++++++-------------- cocos2dx/support/data_support/ccCArray.h | 30 +-- 4 files changed, 72 insertions(+), 295 deletions(-) diff --git a/cocos2dx/cocoa/CCArray.cpp b/cocos2dx/cocoa/CCArray.cpp index 0ee2b94b5e..63ffff4f86 100644 --- a/cocos2dx/cocoa/CCArray.cpp +++ b/cocos2dx/cocoa/CCArray.cpp @@ -370,8 +370,6 @@ CCArray::~CCArray() ccArrayFree(data); } - - CCObject* CCArray::copyWithZone(CCZone* pZone) { CCAssert(pZone == NULL, "CCArray should not be inherited."); @@ -386,126 +384,4 @@ CCObject* CCArray::copyWithZone(CCZone* pZone) return pArray; } -//#pragma mark CCArray - sorting - -/** @since 1.1 */ -//#pragma mark - -//#pragma mark CCArray insertionSortUsingCFuncComparator - -void CCArray::insertionSortUsingCFuncComparator(cc_comparator comparator) -{ -//TODO: cc_insertionSort(data, comparator); -} - -//#pragma mark CCArray qsortUsingCFuncComparator - -void CCArray::qsortUsingCFuncComparator(cc_comparator comparator) -{ - // stable c qsort is used - cost of sorting: best n*log(n), average n*log(n) - // qsort(void *, size_t, size_t, int (*)(const void *arg1, const void *arg2)); - - qsort(data->arr, data->num, sizeof (CCObject*), comparator); -} - -//#pragma mark CCArray mergesortLUsingCFuncComparator - -void CCArray::mergesortLUsingCFuncComparator(cc_comparator comparator) -{ -//TODO: cc_mergesortL(data, sizeof (CCObject*), comparator); -} - -//#pragma mark CCArray insertionSort with (SEL)selector - -void CCArray::insertionSort(SEL_Compare selector) // It sorts source array in ascending order -{ - int i,j,length = data->num; - - CCObject* * x = data->arr; - CCObject* temp; - - // insertion sort - for(i=1; i0 && (x[j-1]->*selector)(x[j]) == CCOrderedDescending ) - { - temp = x[j]; - x[j] = x[j-1]; - x[j-1] = temp; - j--; - } - } -} - -static inline int selectorCompare(CCObject* object1,CCObject* object2,SEL_Compare selector) -{ - return (int) (object1->*selector)(object2); -} - -void CCArray::sortUsingSelector(SEL_Compare selector) -{ - this->sortUsingFunction(selectorCompare, selector); -} - -//#pragma mark CCArray sortUsingFunction - -// using a comparison function -void CCArray::sortUsingFunction(int (*compare)(CCObject*, CCObject*, SEL_Compare) , SEL_Compare context) -{ - int h, i, j, k, l, m, n = this->count(); - CCObject* A, **B = (CCObject**)malloc( (n/2 + 1) * sizeof(CCObject*)); - - // to prevent retain counts from temporarily hitting zero. - for( i=0;iarr[i]->retain(); - } - - for (h = 1; h < n; h += h) - { - for (m = n - 1 - h; m >= 0; m -= h + h) - { - l = m - h + 1; - if (l < 0) - { - l = 0; - } - - for (i = 0, j = l; j <= m; i++, j++) - { - B[i] = this->objectAtIndex(j); - } - - for (i = 0, k = l; k < j && j <= m + h; k++) - { - A = this->objectAtIndex(j); - if (compare(A, B[i], context) == CCOrderedDescending) - { - this->replaceObjectAtIndex(k, B[i++]); - } - else - { - this->replaceObjectAtIndex(k, A); - j++; - } - } - - while (k < j) - { - this->replaceObjectAtIndex(k++, B[i++]); - } - } - } - - for(i=0;iarr[i]->release(); - } - - free(B); -} - NS_CC_END diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index a8fd9deafa..500cd82585 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -202,15 +202,6 @@ public: void reverseObjects(); /* Shrinks the array so the memory footprint corresponds with the number of items */ void reduceMemoryFootprint(); - - // Sorting Array - /** all since @1.1 */ - void qsortUsingCFuncComparator(cc_comparator comparator); // c qsort is used for sorting - void insertionSortUsingCFuncComparator(cc_comparator comparator); // insertion sort - void mergesortLUsingCFuncComparator(cc_comparator comparator); // mergesort - void insertionSort(SEL_Compare selector); // It sorts source array in ascending order - void sortUsingFunction(int (*compare)(CCObject*, CCObject*, SEL_Compare) , SEL_Compare context); - void sortUsingSelector(SEL_Compare selector); /* override functions */ virtual CCObject* copyWithZone(CCZone* pZone); diff --git a/cocos2dx/support/data_support/ccCArray.cpp b/cocos2dx/support/data_support/ccCArray.cpp index 72e8b17fa4..dd7966e873 100644 --- a/cocos2dx/support/data_support/ccCArray.cpp +++ b/cocos2dx/support/data_support/ccCArray.cpp @@ -29,13 +29,14 @@ THE SOFTWARE. NS_CC_BEGIN /** Allocates and initializes a new array with specified capacity */ -ccArray* ccArrayNew(unsigned int capacity) { +ccArray* ccArrayNew(unsigned int capacity) +{ if (capacity == 0) capacity = 1; ccArray *arr = (ccArray*)malloc( sizeof(ccArray) ); arr->num = 0; - arr->arr = (CCARRAY_ID *)calloc(capacity, sizeof(CCObject*)); + arr->arr = (CCObject**)calloc(capacity, sizeof(CCObject*)); arr->max = capacity; return arr; @@ -44,8 +45,10 @@ ccArray* ccArrayNew(unsigned int capacity) { /** Frees array after removing all remaining objects. Silently ignores NULL arr. */ void ccArrayFree(ccArray*& arr) { - if( arr == NULL) return; - + if( arr == NULL ) + { + return; + } ccArrayRemoveAllObjects(arr); free(arr->arr); @@ -57,21 +60,23 @@ void ccArrayFree(ccArray*& arr) void ccArrayDoubleCapacity(ccArray *arr) { arr->max *= 2; - CCARRAY_ID *newArr = (CCARRAY_ID *)realloc( arr->arr, arr->max * sizeof(CCObject*) ); + CCObject** newArr = (CCObject**)realloc( arr->arr, arr->max * sizeof(CCObject*) ); // will fail when there's not enough memory - CCAssert(newArr != NULL, "ccArrayDoubleCapacity failed. Not enough memory"); + CCAssert(newArr != 0, "ccArrayDoubleCapacity failed. Not enough memory"); arr->arr = newArr; } void ccArrayEnsureExtraCapacity(ccArray *arr, unsigned int extra) { while (arr->max < arr->num + extra) + { ccArrayDoubleCapacity(arr); + } } void ccArrayShrink(ccArray *arr) { - unsigned int newSize; + unsigned int newSize = 0; //only resize when necessary if (arr->max > arr->num && !(arr->num==0 && arr->max==1)) @@ -87,7 +92,7 @@ void ccArrayShrink(ccArray *arr) arr->max=1; } - arr->arr = (CCARRAY_ID *) realloc(arr->arr,newSize * sizeof(CCObject*) ); + arr->arr = (CCObject**)realloc(arr->arr,newSize * sizeof(CCObject*) ); CCAssert(arr->arr!=NULL,"could not reallocate the memory"); } } @@ -95,10 +100,10 @@ void ccArrayShrink(ccArray *arr) /** Returns index of first occurence of object, CC_INVALID_INDEX if object not found. */ unsigned int ccArrayGetIndexOfObject(ccArray *arr, CCObject* object) { - unsigned int i; - - for( i = 0; i < arr->num; i++) + for(unsigned int i = 0; i < arr->num; i++) + { if( arr->arr[i] == object ) return i; + } return CC_INVALID_INDEX; } @@ -129,10 +134,10 @@ void ccArrayAppendObjectWithResize(ccArray *arr, CCObject* object) enough capacity. */ void ccArrayAppendArray(ccArray *arr, ccArray *plusArr) { - unsigned int i; - - for( i = 0; i < plusArr->num; i++) + for(unsigned int i = 0; i < plusArr->num; i++) + { ccArrayAppendObject(arr, plusArr->arr[i]); + } } /** Appends objects from plusArr to arr. Capacity of arr is increased if needed. */ @@ -186,6 +191,7 @@ void ccArrayRemoveAllObjects(ccArray *arr) Behaviour undefined if index outside [0, num-1]. */ void ccArrayRemoveObjectAtIndex(ccArray *arr, unsigned int index, bool bReleaseObj/* = true*/) { + CCAssert(arr && arr->num > 0 && index < arr->num, "Invalid index. Out of bounds"); if (bReleaseObj) { CC_SAFE_RELEASE(arr->arr[index]); @@ -214,7 +220,9 @@ void ccArrayFastRemoveObject(ccArray *arr, CCObject* object) { unsigned int index = ccArrayGetIndexOfObject(arr, object); if (index != CC_INVALID_INDEX) + { ccArrayFastRemoveObjectAtIndex(arr, index); + } } /** Searches for the first occurance of object and removes it. If object is not @@ -232,10 +240,10 @@ void ccArrayRemoveObject(ccArray *arr, CCObject* object, bool bReleaseObj/* = tr first matching instance in arr will be removed. */ void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr) { - unsigned int i; - - for( i = 0; i < minusArr->num; i++) + for(unsigned int i = 0; i < minusArr->num; i++) + { ccArrayRemoveObject(arr, minusArr->arr[i]); + } } /** Removes from arr all objects in minusArr. For each object in minusArr, all @@ -243,14 +251,19 @@ void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr) void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr) { unsigned int back = 0; - unsigned int i; + unsigned int i = 0; - for( i = 0; i < arr->num; i++) { - if( ccArrayContainsObject(minusArr, arr->arr[i]) ) { + for( i = 0; i < arr->num; i++) + { + if( ccArrayContainsObject(minusArr, arr->arr[i]) ) + { CC_SAFE_RELEASE(arr->arr[i]); back++; - } else + } + else + { arr->arr[i - back] = arr->arr[i]; + } } arr->num -= back; @@ -263,8 +276,10 @@ void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr) ccCArray* ccCArrayNew(unsigned int capacity) { if (capacity == 0) + { capacity = 1; - + } + ccCArray *arr = (ccCArray*)malloc( sizeof(ccCArray) ); arr->num = 0; arr->arr = (void**)malloc( capacity * sizeof(void*) ); @@ -276,8 +291,10 @@ ccCArray* ccCArrayNew(unsigned int capacity) /** Frees C array after removing all remaining values. Silently ignores NULL arr. */ void ccCArrayFree(ccCArray *arr) { - if( arr == NULL ) return; - + if( arr == NULL ) + { + return; + } ccCArrayRemoveAllValues(arr); free(arr->arr); @@ -287,18 +304,13 @@ void ccCArrayFree(ccCArray *arr) /** Doubles C array capacity */ void ccCArrayDoubleCapacity(ccCArray *arr) { - arr->max *= 2; - void** newArr = (void**)realloc( arr->arr, arr->max * sizeof(void*) ); - // will fail when there's not enough memory - CCAssert(newArr != NULL, "ccCArrayDoubleCapacity failed. Not enough memory"); - arr->arr = newArr; + ccArrayDoubleCapacity((ccArray*)arr); } /** Increases array capacity such that max >= num + extra. */ void ccCArrayEnsureExtraCapacity(ccCArray *arr, unsigned int extra) { - while (arr->max < arr->num + extra) - ccCArrayDoubleCapacity(arr); + ccArrayEnsureExtraCapacity((ccArray*)arr,extra); } /** Returns index of first occurence of value, CC_INVALID_INDEX if value not found. */ @@ -325,7 +337,11 @@ void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, unsigned int index) CCAssert( index < arr->max, "ccCArrayInsertValueAtIndex: invalid index"); unsigned int remaining = arr->num - index; - + // make sure it has enough capacity + if (arr->num + 1 == arr->max) + { + ccCArrayDoubleCapacity(arr); + } // last Value doesn't need to be moved if( remaining > 0) { // tex coordinates @@ -339,8 +355,14 @@ void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, unsigned int index) /** Appends an value. Bahaviour undefined if array doesn't have enough capacity. */ void ccCArrayAppendValue(ccCArray *arr, void* value) { - arr->arr[arr->num] = (CCObject*) value; + arr->arr[arr->num] = value; arr->num++; + // double the capacity for the next append action + // if the num >= max + if (arr->num >= arr->max) + { + ccCArrayDoubleCapacity(arr); + } } /** Appends an value. Capacity of arr is increased if needed. */ @@ -385,7 +407,9 @@ void ccCArrayRemoveValueAtIndex(ccCArray *arr, unsigned int index) unsigned int last; for( last = --arr->num; index < last; index++) + { arr->arr[index] = arr->arr[index + 1]; + } } /** Removes value at specified index and fills the gap with the last value, @@ -406,7 +430,9 @@ void ccCArrayRemoveValue(ccCArray *arr, void* value) { unsigned int index = ccCArrayGetIndexOfValue(arr, value); if (index != CC_INVALID_INDEX) + { ccCArrayRemoveValueAtIndex(arr, index); + } } /** Removes from arr all values in minusArr. For each Value in minusArr, the first matching instance in arr will be removed. @@ -414,10 +440,10 @@ void ccCArrayRemoveValue(ccCArray *arr, void* value) */ void ccCArrayRemoveArray(ccCArray *arr, ccCArray *minusArr) { - unsigned int i; - - for( i = 0; i < minusArr->num; i++) + for(unsigned int i = 0; i < minusArr->num; i++) + { ccCArrayRemoveValue(arr, minusArr->arr[i]); + } } /** Removes from arr all values in minusArr. For each value in minusArr, all matching instances in arr will be removed. @@ -425,111 +451,21 @@ void ccCArrayRemoveArray(ccCArray *arr, ccCArray *minusArr) */ void ccCArrayFullRemoveArray(ccCArray *arr, ccCArray *minusArr) { - unsigned int i; unsigned int back = 0; - for( i = 0; i < arr->num; i++) { - if( ccCArrayContainsValue(minusArr, arr->arr[i]) ) { + for(unsigned int i = 0; i < arr->num; i++) + { + if( ccCArrayContainsValue(minusArr, arr->arr[i]) ) + { back++; - } else + } + else + { arr->arr[i - back] = arr->arr[i]; + } } arr->num -= back; } -//used by mergesortL -void cc_pointerswap(void* a, void* b, size_t width) -{ - void* tmp; - tmp = *(void**)a; - *(void**)a = *(void**)b; - *(void**)b = tmp; -} - -// iterative mergesort arrd on -// http://www.inf.fh-flensburg.de/lang/algorithmen/sortieren/merge/mergiter.htm -int cc_mergesortL(ccCArray* array, size_t width, cc_comparator comparator) -{ -// void** arr = array->arr; -// int i,j,k,s,m,n= array->num; -// -// void *B = malloc((n/2 + 1) * width); -// for (s = 1; s < n; s += s) -// { -// for (m = n-1-s; m >= 0; m -= s+s) -// { -// int lo = MAX(m-(s+1),0); -// int hi = m+s; -// -// j = lo; -// -// if (m-j > 0) -// { -// //triggers a warning when compiled with ARC, B needs to be strong typed, for compiling for obj-c++ -// //memcpy aritmetics aren't allowed on void* types -// //explicitely casting didn't work -// // #pragma clang diagnostic push -// // #if defined(__has_feature) && __has_feature(objc_arc) -// // #pragma clang diagnostic ignored "-Warc-non-pod-memaccess" -// // #endif -// -// memcpy(B, &arr[j], (m-j) * width); -// //#pragma clang diagnostic pop -// } -// -// i = 0; -// j = m; -// k = lo; -// -// while (knum; - - void** x = arr->arr; - void* temp; - - // insertion sort - for(i=1; i0 && ( comparator( &x[j-1], &x[j] ) == CCOrderedDescending) ) - { - temp = x[j]; - x[j] = x[j-1]; - x[j-1] = temp; - j--; - } - } -} - NS_CC_END diff --git a/cocos2dx/support/data_support/ccCArray.h b/cocos2dx/support/data_support/ccCArray.h index 73b17fe26c..1ceba49aca 100644 --- a/cocos2dx/support/data_support/ccCArray.h +++ b/cocos2dx/support/data_support/ccCArray.h @@ -52,34 +52,16 @@ NS_CC_BEGIN #define CC_INVALID_INDEX 0xffffffff - -// #pragma mark - -// #pragma mark ccArray for Objects - // Easy integration #define CCARRAYDATA_FOREACH(__array__, __object__) \ __object__=__array__->arr[0]; for(unsigned int i=0, num=__array__->num; iarr[i]) \ -// #if defined(__has_feature) && __has_feature(objc_arc) -// typedef __strong CCObject* CCARRAY_ID; -// #else - typedef CCObject* CCARRAY_ID; -//#endif typedef struct _ccArray { unsigned int num, max; - CCARRAY_ID *arr; + CCObject** arr; } ccArray; -enum CCComparisonResult -{ - CCOrderedDescending = 1, - CCOrderedAscending = -1, - CCOrderedSame = 0 -}; - -typedef int (*cc_comparator)(const void *, const void *); - /** Allocates and initializes a new array with specified capacity */ ccArray* ccArrayNew(unsigned int capacity); @@ -151,7 +133,7 @@ void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr); typedef struct _ccCArray { unsigned int num, max; - void **arr; + void** arr; } ccCArray; /** Allocates and initializes a new C array with specified capacity */ @@ -219,14 +201,6 @@ void ccCArrayRemoveArray(ccCArray *arr, ccCArray *minusArr); */ void ccCArrayFullRemoveArray(ccCArray *arr, ccCArray *minusArr); -// iterative mergesort arrd on -// http://www.inf.fh-flensburg.de/lang/algorithmen/sortieren/merge/mergiter.htm -int cc_mergesortL(ccCArray* array, size_t width, cc_comparator comparator); - -void cc_insertionSort(ccCArray* arr, cc_comparator comparator); - -void cc_pointerswap(void* a, void* b, size_t width); - NS_CC_END #endif // CC_ARRAY_H From 371b3f9938cd143b4e29f258729dae99dddb375f Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 8 Jun 2012 17:34:15 +0800 Subject: [PATCH 107/257] issue #1310: Tests project updated!. --- cocos2dx/CCDirector.cpp | 4 ++-- .../extensions/CCBReader/CCBReader_v1.cpp | 4 ++-- .../extensions/CCBReader/CCBReader_v2.cpp | 4 ++-- tests/AppDelegate.cpp | 2 +- tests/tests/Box2DTest/Box2dTest.cpp | 2 +- tests/tests/BugsTest/Bug-1159.cpp | 4 ++-- tests/tests/BugsTest/Bug-914.cpp | 2 +- .../ChipmunkAccelTouchTest.cpp | 2 +- .../CocosDenshionTest/CocosDenshionTest.cpp | 12 +++++----- tests/tests/FontTest/FontTest.cpp | 6 ++--- tests/tests/LabelTest/LabelTest.cpp | 22 +++++++++---------- tests/tests/LayerTest/LayerTest.cpp | 6 ++--- tests/tests/ShaderTest/ShaderTest.cpp | 4 ++-- .../SpriteTest/SpriteTest.cpp.REMOVED.git-id | 2 +- tests/tests/Texture2dTest/Texture2dTest.cpp | 4 ++-- tests/tests/TileMapTest/TileMapTest.cpp | 2 +- 16 files changed, 41 insertions(+), 41 deletions(-) diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index dd8c549266..5c840fded0 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -357,7 +357,7 @@ void CCDirector::setProjection(ccDirectorProjection kProjection) case kCCDirectorProjection3D: { -//cjh // reset the viewport if 3d proj & retina display +//TODO: // reset the viewport if 3d proj & retina display // if( CC_CONTENT_SCALE_FACTOR() != 1.0f ) // { // glViewport((GLint)-size.width/2, (GLint)-size.height/2, (GLsizei)(size.width * CC_CONTENT_SCALE_FACTOR()), (GLsizei)(size.height * CC_CONTENT_SCALE_FACTOR()) ); @@ -374,7 +374,7 @@ void CCDirector::setProjection(ccDirectorProjection kProjection) kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, zeye*2); // kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, 1500); -//cjh if (m_pobOpenGLView && m_pobOpenGLView->isIpad() && m_pobOpenGLView->getMainScreenScale() > 1.0f) +//TODO: if (m_pobOpenGLView && m_pobOpenGLView->isIpad() && m_pobOpenGLView->getMainScreenScale() > 1.0f) // { // kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, zeye-size.height/2, zeye+size.height/2); // } diff --git a/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp b/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp index 7b0421042a..717ce8c8d8 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp @@ -23,11 +23,11 @@ THE SOFTWARE. ****************************************************************************/ -#if CCB_READER_VERSION == 1 - #include "CCBReader.h" #include "CCBCustomClass.h" +#if CCB_READER_VERSION == 1 + USING_NS_CC; USING_NS_CC_EXT; diff --git a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp index 0c3a84843d..eed24d56e2 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp @@ -23,11 +23,11 @@ THE SOFTWARE. ****************************************************************************/ -#if CCB_READER_VERSION == 2 - #include "CCBReader.h" #include "CCBCustomClass.h" +#if CCB_READER_VERSION == 2 + USING_NS_CC; USING_NS_CC_EXT; diff --git a/tests/AppDelegate.cpp b/tests/AppDelegate.cpp index 2a58f05895..a52503fc57 100644 --- a/tests/AppDelegate.cpp +++ b/tests/AppDelegate.cpp @@ -23,7 +23,7 @@ bool AppDelegate::applicationDidFinishLaunching() pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView()); // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. - // pDirector->enableRetinaDisplay(true); + pDirector->enableRetinaDisplay(true); // turn on display FPS pDirector->setDisplayStats(true); diff --git a/tests/tests/Box2DTest/Box2dTest.cpp b/tests/tests/Box2DTest/Box2dTest.cpp index 7a64603062..1211366201 100644 --- a/tests/tests/Box2DTest/Box2dTest.cpp +++ b/tests/tests/Box2DTest/Box2dTest.cpp @@ -34,7 +34,7 @@ CCAffineTransform PhysicsSprite::nodeToParentTransform(void) float x = pos.x * PTM_RATIO; float y = pos.y * PTM_RATIO; - if ( !getIsRelativeAnchorPoint() ) { + if ( getIgnoreAnchorPointForPosition() ) { x += m_tAnchorPointInPoints.x; y += m_tAnchorPointInPoints.y; } diff --git a/tests/tests/BugsTest/Bug-1159.cpp b/tests/tests/BugsTest/Bug-1159.cpp index 962ba4e743..8805514228 100644 --- a/tests/tests/BugsTest/Bug-1159.cpp +++ b/tests/tests/BugsTest/Bug-1159.cpp @@ -29,7 +29,7 @@ bool Bug1159Layer::init() CCLayerColor *sprite_a = CCLayerColor::layerWithColor(ccc4(255, 0, 0, 255), 700, 700); sprite_a->setAnchorPoint(ccp(0.5f, 0.5f)); - sprite_a->setIsRelativeAnchorPoint(true); + sprite_a->setIgnoreAnchorPointForPosition(false); sprite_a->setPosition(ccp(0.0f, s.height/2)); addChild(sprite_a); @@ -40,7 +40,7 @@ bool Bug1159Layer::init() CCLayerColor *sprite_b = CCLayerColor::layerWithColor(ccc4(0, 0, 255, 255), 400, 400); sprite_b->setAnchorPoint(ccp(0.5f, 0.5f)); - sprite_b->setIsRelativeAnchorPoint(true); + sprite_b->setIgnoreAnchorPointForPosition(false); sprite_b->setPosition(ccp(s.width/2, s.height/2)); addChild(sprite_b); diff --git a/tests/tests/BugsTest/Bug-914.cpp b/tests/tests/BugsTest/Bug-914.cpp index 699d923488..05187d07d8 100644 --- a/tests/tests/BugsTest/Bug-914.cpp +++ b/tests/tests/BugsTest/Bug-914.cpp @@ -40,7 +40,7 @@ bool Bug914Layer::init() layer->setContentSize(CCSizeMake(i*100, i*100)); layer->setPosition(ccp(size.width/2, size.height/2)); layer->setAnchorPoint(ccp(0.5f, 0.5f)); - layer->setIsRelativeAnchorPoint(true); + layer->setIgnoreAnchorPointForPosition(false); addChild(layer, -1-i); } diff --git a/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp b/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp index f45c455ba6..b61104d6d8 100644 --- a/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp +++ b/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp @@ -46,7 +46,7 @@ CCAffineTransform ChipmunkPhysicsSprite::nodeToParentTransform(void) CCFloat x = m_pBody->p.x; CCFloat y = m_pBody->p.y; - if ( !getIsRelativeAnchorPoint() ) { + if ( getIgnoreAnchorPointForPosition() ) { x += m_tAnchorPointInPoints.x; y += m_tAnchorPointInPoints.y; } diff --git a/tests/tests/CocosDenshionTest/CocosDenshionTest.cpp b/tests/tests/CocosDenshionTest/CocosDenshionTest.cpp index 55858da22e..4bad47c84b 100644 --- a/tests/tests/CocosDenshionTest/CocosDenshionTest.cpp +++ b/tests/tests/CocosDenshionTest/CocosDenshionTest.cpp @@ -76,8 +76,8 @@ m_nSoundId(0) setIsTouchEnabled(true); // preload background music and effect - SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic( CCFileUtils::fullPathFromRelativePath(MUSIC_FILE) ); - SimpleAudioEngine::sharedEngine()->preloadEffect( CCFileUtils::fullPathFromRelativePath(EFFECT_FILE) ); + SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic( CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(MUSIC_FILE) ); + SimpleAudioEngine::sharedEngine()->preloadEffect( CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(EFFECT_FILE) ); // set default volume SimpleAudioEngine::sharedEngine()->setEffectsVolume(0.5); @@ -106,7 +106,7 @@ void CocosDenshionTest::menuCallback(CCObject * pSender) // play background music case 0: - SimpleAudioEngine::sharedEngine()->playBackgroundMusic(std::string(CCFileUtils::fullPathFromRelativePath(MUSIC_FILE)).c_str(), true); + SimpleAudioEngine::sharedEngine()->playBackgroundMusic(std::string(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(MUSIC_FILE)).c_str(), true); break; // stop background music case 1: @@ -137,11 +137,11 @@ void CocosDenshionTest::menuCallback(CCObject * pSender) break; // play effect case 6: - m_nSoundId = SimpleAudioEngine::sharedEngine()->playEffect(std::string(CCFileUtils::fullPathFromRelativePath(EFFECT_FILE)).c_str()); + m_nSoundId = SimpleAudioEngine::sharedEngine()->playEffect(std::string(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(EFFECT_FILE)).c_str()); break; // play effect case 7: - m_nSoundId = SimpleAudioEngine::sharedEngine()->playEffect(std::string(CCFileUtils::fullPathFromRelativePath(EFFECT_FILE)).c_str(), true); + m_nSoundId = SimpleAudioEngine::sharedEngine()->playEffect(std::string(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(EFFECT_FILE)).c_str(), true); break; // stop effect case 8: @@ -149,7 +149,7 @@ void CocosDenshionTest::menuCallback(CCObject * pSender) break; // unload effect case 9: - SimpleAudioEngine::sharedEngine()->unloadEffect(std::string(CCFileUtils::fullPathFromRelativePath(EFFECT_FILE)).c_str()); + SimpleAudioEngine::sharedEngine()->unloadEffect(std::string(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(EFFECT_FILE)).c_str()); break; // add bakcground music volume case 10: diff --git a/tests/tests/FontTest/FontTest.cpp b/tests/tests/FontTest/FontTest.cpp index cdd4ae8b50..ef4ebe8989 100644 --- a/tests/tests/FontTest/FontTest.cpp +++ b/tests/tests/FontTest/FontTest.cpp @@ -75,9 +75,9 @@ void FontTest::showFont(const char *pFont) CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLabelTTF *top = CCLabelTTF::labelWithString(pFont, pFont, 24); - CCLabelTTF *left = CCLabelTTF::labelWithString("alignment left", CCSizeMake(s.width, 50), CCTextAlignmentLeft, pFont, 32); - CCLabelTTF *center = CCLabelTTF::labelWithString("alignment center", CCSizeMake(s.width, 50), CCTextAlignmentCenter, pFont, 32); - CCLabelTTF *right = CCLabelTTF::labelWithString("alignment right", CCSizeMake(s.width, 50), CCTextAlignmentRight, pFont, 32); + CCLabelTTF *left = CCLabelTTF::labelWithString("alignment left", CCSizeMake(s.width, 50), kCCTextAlignmentLeft, pFont, 32); + CCLabelTTF *center = CCLabelTTF::labelWithString("alignment center", CCSizeMake(s.width, 50), kCCTextAlignmentCenter, pFont, 32); + CCLabelTTF *right = CCLabelTTF::labelWithString("alignment right", CCSizeMake(s.width, 50), kCCTextAlignmentRight, pFont, 32); top->setPosition(ccp(s.width/2, 250)); left->setPosition(ccp(s.width/2, 200)); diff --git a/tests/tests/LabelTest/LabelTest.cpp b/tests/tests/LabelTest/LabelTest.cpp index d62dd37365..35ae63bd9f 100644 --- a/tests/tests/LabelTest/LabelTest.cpp +++ b/tests/tests/LabelTest/LabelTest.cpp @@ -912,9 +912,9 @@ LabelTTFTest::LabelTTFTest() CCSize s = CCDirector::sharedDirector()->getWinSize(); // CCLabelBMFont - CCLabelTTF *left = CCLabelTTF::labelWithString("align left", CCSizeMake(s.width, 50), CCTextAlignmentLeft, "Marker Felt", 32); - CCLabelTTF *center = CCLabelTTF::labelWithString("align center", CCSizeMake(s.width, 50), CCTextAlignmentCenter, "Marker Felt", 32); - CCLabelTTF *right = CCLabelTTF::labelWithString("align right", CCSizeMake(s.width, 50), CCTextAlignmentRight, "Marker Felt", 32); + CCLabelTTF *left = CCLabelTTF::labelWithString("align left", CCSizeMake(s.width, 50), kCCTextAlignmentLeft, "Marker Felt", 32); + CCLabelTTF *center = CCLabelTTF::labelWithString("align center", CCSizeMake(s.width, 50), kCCTextAlignmentCenter, "Marker Felt", 32); + CCLabelTTF *right = CCLabelTTF::labelWithString("align right", CCSizeMake(s.width, 50), kCCTextAlignmentRight, "Marker Felt", 32); left->setPosition(ccp(s.width / 2, 200)); center->setPosition(ccp(s.width / 2, 150)); @@ -941,7 +941,7 @@ LabelTTFMultiline::LabelTTFMultiline() // CCLabelBMFont CCLabelTTF *center = CCLabelTTF::labelWithString("word wrap \"testing\" (bla0) bla1 'bla2' [bla3] (bla4) {bla5} {bla6} [bla7] (bla8) [bla9] 'bla0' \"bla1\"", - CCSizeMake(s.width / 2, 200), CCTextAlignmentCenter, "MarkerFelt.ttc", 32); + CCSizeMake(s.width / 2, 200), kCCTextAlignmentCenter, "MarkerFelt.ttc", 32); center->setPosition(ccp(s.width / 2, 150)); addChild(center); @@ -1010,7 +1010,7 @@ BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment() CCSize size = CCDirector::sharedDirector()->getWinSize(); // create and initialize a Label - this->m_pLabelShouldRetain = CCLabelBMFont::labelWithString(LongSentencesExample, "fonts/markerFelt.fnt", size.width/1.5, CCTextAlignmentCenter); + this->m_pLabelShouldRetain = CCLabelBMFont::labelWithString(LongSentencesExample, "fonts/markerFelt.fnt", size.width/1.5, kCCTextAlignmentCenter); this->m_pLabelShouldRetain->retain(); this->m_pArrowsBarShouldRetain = CCSprite::spriteWithFile("Images/arrowsBar.png"); @@ -1119,13 +1119,13 @@ void BitmapFontMultiLineAlignment::alignmentChanged(cocos2d::CCObject *sender) switch(item->getTag()) { case LeftAlign: - this->m_pLabelShouldRetain->setAlignment(CCTextAlignmentLeft); + this->m_pLabelShouldRetain->setAlignment(kCCTextAlignmentLeft); break; case CenterAlign: - this->m_pLabelShouldRetain->setAlignment(CCTextAlignmentCenter); + this->m_pLabelShouldRetain->setAlignment(kCCTextAlignmentCenter); break; case RightAlign: - this->m_pLabelShouldRetain->setAlignment(CCTextAlignmentRight); + this->m_pLabelShouldRetain->setAlignment(kCCTextAlignmentRight); break; default: @@ -1217,11 +1217,11 @@ BMFontOneAtlas::BMFontOneAtlas() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelBMFont *label1 = CCLabelBMFont::labelWithString("This is Helvetica", "fonts/helvetica-32.fnt", kCCLabelAutomaticWidth, CCTextAlignmentLeft, CCPointZero); + CCLabelBMFont *label1 = CCLabelBMFont::labelWithString("This is Helvetica", "fonts/helvetica-32.fnt", kCCLabelAutomaticWidth, kCCTextAlignmentLeft, CCPointZero); addChild(label1); label1->setPosition(ccp(s.width/2, s.height/3*2)); - CCLabelBMFont *label2 = CCLabelBMFont::labelWithString("And this is Geneva", "fonts/geneva-32.fnt", kCCLabelAutomaticWidth, CCTextAlignmentLeft, ccp(0, 128)); + CCLabelBMFont *label2 = CCLabelBMFont::labelWithString("And this is Geneva", "fonts/geneva-32.fnt", kCCLabelAutomaticWidth, kCCTextAlignmentLeft, ccp(0, 128)); addChild(label2); label2->setPosition(ccp(s.width/2, s.height/3*1)); } @@ -1247,7 +1247,7 @@ BMFontUnicode::BMFontUnicode() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelBMFont *label1 = CCLabelBMFont::labelWithString(spanish, "fonts/arial-unicode-26.fnt", 200, CCTextAlignmentLeft); + CCLabelBMFont *label1 = CCLabelBMFont::labelWithString(spanish, "fonts/arial-unicode-26.fnt", 200, kCCTextAlignmentLeft); addChild(label1); label1->setPosition(ccp(s.width/2, s.height/4*3)); diff --git a/tests/tests/LayerTest/LayerTest.cpp b/tests/tests/LayerTest/LayerTest.cpp index 85e49eec5b..79daedbf4a 100644 --- a/tests/tests/LayerTest/LayerTest.cpp +++ b/tests/tests/LayerTest/LayerTest.cpp @@ -154,7 +154,7 @@ void LayerTest1::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLayerColor* layer = CCLayerColor::layerWithColor( ccc4(0xFF, 0x00, 0x00, 0x80), 200, 200); - layer->setIsRelativeAnchorPoint(true); + layer->setIgnoreAnchorPointForPosition(false); layer->setPosition( CCPointMake(s.width/2, s.height/2) ); addChild(layer, 1, kTagLayer); } @@ -219,12 +219,12 @@ void LayerTest2::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLayerColor* layer1 = CCLayerColor::layerWithColor( ccc4(255, 255, 0, 80), 100, 300); layer1->setPosition(CCPointMake(s.width/3, s.height/2)); - layer1->setIsRelativeAnchorPoint(true); + layer1->setIgnoreAnchorPointForPosition(false); addChild(layer1, 1); CCLayerColor* layer2 = CCLayerColor::layerWithColor( ccc4(0, 0, 255, 255), 100, 300); layer2->setPosition(CCPointMake((s.width/3)*2, s.height/2)); - layer2->setIsRelativeAnchorPoint(true); + layer2->setIgnoreAnchorPointForPosition(false); addChild(layer2, 1); CCActionInterval* actionTint = CCTintBy::actionWithDuration(2, -255, -127, 0); diff --git a/tests/tests/ShaderTest/ShaderTest.cpp b/tests/tests/ShaderTest/ShaderTest.cpp index c9709cdd59..3232d8b54d 100644 --- a/tests/tests/ShaderTest/ShaderTest.cpp +++ b/tests/tests/ShaderTest/ShaderTest.cpp @@ -476,7 +476,7 @@ bool SpriteBlur::initWithTexture(CCTexture2D* texture, const CCRect& rect) sub_[0] = sub_[1] = sub_[2] = sub_[3] = 0; GLchar * fragSource = (GLchar*) CCString::stringWithContentsOfFile( - CCFileUtils::fullPathFromRelativePath("Shaders/example_Blur.fsh"))->getCString(); + CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("Shaders/example_Blur.fsh"))->getCString(); CCGLProgram* pProgram = new CCGLProgram(); pProgram->initWithVertexShaderByteArray(ccPositionTextureColor_vert, fragSource); setShaderProgram(pProgram); @@ -630,7 +630,7 @@ bool ShaderRetroEffect::init() { if( ShaderTestDemo::init() ) { - GLchar * fragSource = (GLchar*) CCString::stringWithContentsOfFile(CCFileUtils::fullPathFromRelativePath("Shaders/example_HorizontalColor.fsh"))->getCString(); + GLchar * fragSource = (GLchar*) CCString::stringWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("Shaders/example_HorizontalColor.fsh"))->getCString(); CCGLProgram *p = new CCGLProgram(); p->initWithVertexShaderByteArray(ccPositionTexture_vert, fragSource); diff --git a/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id b/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id index 51d5c99134..de1fc1f12a 100644 --- a/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id +++ b/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id @@ -1 +1 @@ -32985150da64bb4070f46022a1fb52ec24c22451 \ No newline at end of file +30f90defc4364cbcd8e686f75010ac83a50fb386 \ No newline at end of file diff --git a/tests/tests/Texture2dTest/Texture2dTest.cpp b/tests/tests/Texture2dTest/Texture2dTest.cpp index 545d686269..89b671e5b3 100644 --- a/tests/tests/Texture2dTest/Texture2dTest.cpp +++ b/tests/tests/Texture2dTest/Texture2dTest.cpp @@ -1478,14 +1478,14 @@ void FileUtilsTest::onEnter() #if 0 // TODO:(CC_TARGET_PLATFORM == CC_PLATFORM_IOS) // Testint CCFileUtils API bool ret = false; - ret = CCFileUtils::iPhoneRetinaDisplayFileExistsAtPath("Images/bugs/test_issue_1179.png"); + ret = CCFileUtils::sharedFileUtils()->iPhoneRetinaDisplayFileExistsAtPath("Images/bugs/test_issue_1179.png"); if( ret ) CCLog("Test #3: retinaDisplayFileExistsAtPath: OK"); else CCLog("Test #3: retinaDisplayFileExistsAtPath: FAILED"); - ret = CCFileUtils::iPhoneRetinaDisplayFileExistsAtPath("grossini-does_no_exist.png"); + ret = CCFileUtils::sharedFileUtils()->iPhoneRetinaDisplayFileExistsAtPath("grossini-does_no_exist.png"); if( !ret ) CCLog("Test #4: retinaDisplayFileExistsAtPath: OK"); else diff --git a/tests/tests/TileMapTest/TileMapTest.cpp b/tests/tests/TileMapTest/TileMapTest.cpp index 41cdc6812c..524fee7bc0 100644 --- a/tests/tests/TileMapTest/TileMapTest.cpp +++ b/tests/tests/TileMapTest/TileMapTest.cpp @@ -1254,7 +1254,7 @@ TMXOrthoFromXMLTest::TMXOrthoFromXMLTest() string resources = "TileMaps"; // partial paths are OK as resource paths. string file = resources + "/orthogonal-test1.tmx"; - CCString* str = CCString::stringWithContentsOfFile(CCFileUtils::fullPathFromRelativePath(file.c_str())); + CCString* str = CCString::stringWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(file.c_str())); CCAssert(str != NULL, "Unable to open file"); CCTMXTiledMap *map = CCTMXTiledMap::tiledMapWithXML(str->getCString() ,resources.c_str()); From c9dc60b0f7d416042e4c761bab0ef64e18df7f1f Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 8 Jun 2012 17:58:21 +0800 Subject: [PATCH 108/257] issue #1310: fixed a bug in CCSpriteFrameCache.cpp. Disable retina mode for tests project. --- cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp | 2 +- tests/AppDelegate.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp index 5ba469a81e..97a3695446 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp @@ -229,7 +229,7 @@ void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist) { CCAssert(pszPlist, "plist filename should not be NULL"); - if (m_pLoadedFileNames->find(pszPlist) != m_pLoadedFileNames->end()) + if (m_pLoadedFileNames->find(pszPlist) == m_pLoadedFileNames->end()) { const char *pszPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pszPlist); CCDictionary *dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(pszPath); diff --git a/tests/AppDelegate.cpp b/tests/AppDelegate.cpp index a52503fc57..2a58f05895 100644 --- a/tests/AppDelegate.cpp +++ b/tests/AppDelegate.cpp @@ -23,7 +23,7 @@ bool AppDelegate::applicationDidFinishLaunching() pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView()); // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. - pDirector->enableRetinaDisplay(true); + // pDirector->enableRetinaDisplay(true); // turn on display FPS pDirector->setDisplayStats(true); From 70fa2ec3cba4b432ba78f0cfc7527b8b4b2a9b78 Mon Sep 17 00:00:00 2001 From: Nat Weiss Date: Fri, 8 Jun 2012 13:52:40 -0700 Subject: [PATCH 109/257] Fixed a few release-mode Xcode warnings about unused parameters. --- cocos2dx/CCConfiguration.cpp | 2 ++ cocos2dx/platform/ios/CCEGLView.mm | 1 + cocos2dx/platform/ios/CCImage.mm | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/cocos2dx/CCConfiguration.cpp b/cocos2dx/CCConfiguration.cpp index 8eba9c1b69..b56f332efe 100644 --- a/cocos2dx/CCConfiguration.cpp +++ b/cocos2dx/CCConfiguration.cpp @@ -77,6 +77,8 @@ bool CCConfiguration::init(void) #if CC_ENABLE_PROFILERS bEnableProfilers = true; +#else + bEnableProfilers = false; #endif CCLOG("cocos2d: compiled with Profiling Support: %s", diff --git a/cocos2dx/platform/ios/CCEGLView.mm b/cocos2dx/platform/ios/CCEGLView.mm index 4e62451c56..cec7168830 100644 --- a/cocos2dx/platform/ios/CCEGLView.mm +++ b/cocos2dx/platform/ios/CCEGLView.mm @@ -86,6 +86,7 @@ void CCEGLView::swapBuffers() CCSize CCEGLView::getFrameSize() { assert(false); + return CCSizeMake(0, 0); } void CCEGLView::setIMEKeyboardState(bool bOpen) diff --git a/cocos2dx/platform/ios/CCImage.mm b/cocos2dx/platform/ios/CCImage.mm index 9828f30ccc..8ab0bf4c83 100644 --- a/cocos2dx/platform/ios/CCImage.mm +++ b/cocos2dx/platform/ios/CCImage.mm @@ -426,21 +426,25 @@ bool CCImage::_initWithRawData(void *pData, int nDatalen, int nWidth, int nHeigh bool CCImage::_initWithJpgData(void *pData, int nDatalen) { assert(0); + return false; } bool CCImage::_initWithPngData(void *pData, int nDatalen) { assert(0); + return false; } bool CCImage::_saveImageToPNG(const char *pszFilePath, bool bIsToRGB) { assert(0); + return false; } bool CCImage::_saveImageToJPG(const char *pszFilePath) { assert(0); + return false; } bool CCImage::initWithString( From 94235d3602559d12b61c971a50de4f622e48394b Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 11 Jun 2012 10:41:52 +0800 Subject: [PATCH 110/257] issue #1310: make tests and HelloWorld work ok --- .../project.pbxproj.REMOVED.git-id | 2 +- cocos2dx/CCDirector.cpp | 2 +- cocos2dx/actions/CCActionCatmullRom.cpp | 2 +- cocos2dx/actions/CCActionCatmullRom.h | 2 +- cocos2dx/platform/ios/CCFileUtils.mm | 13 ++++++++++++- cocos2dx/platform/ios/CCGL.h | 1 + cocos2dx/platform/ios/CCImage.mm | 5 +++-- js/JSBindings/cocos2d_generated.cpp.REMOVED.git-id | 2 +- js/JSBindings/cocos2d_generated.hpp.REMOVED.git-id | 2 +- .../testjs.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- .../test.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- 11 files changed, 24 insertions(+), 11 deletions(-) diff --git a/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id b/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id index 58cbc28d2d..43f6702dd0 100644 --- a/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -5e8bc2ebea93cf60f4c5992e1175c43fffffb7e8 \ No newline at end of file +e725a16819b832fcdbd8496ae63d0b24c76af31a \ No newline at end of file diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 5c840fded0..e17278a8c0 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -371,7 +371,7 @@ void CCDirector::setProjection(ccDirectorProjection kProjection) kmGLLoadIdentity(); // issue #1334 - kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, zeye*2); + kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, zeye*2); // kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, 1500); //TODO: if (m_pobOpenGLView && m_pobOpenGLView->isIpad() && m_pobOpenGLView->getMainScreenScale() > 1.0f) diff --git a/cocos2dx/actions/CCActionCatmullRom.cpp b/cocos2dx/actions/CCActionCatmullRom.cpp index 7a4d3339dd..50ea1d1bc7 100644 --- a/cocos2dx/actions/CCActionCatmullRom.cpp +++ b/cocos2dx/actions/CCActionCatmullRom.cpp @@ -150,7 +150,7 @@ void CCPointArray::reverseInline() } // CatmullRom Spline formula: -inline CCPoint ccCardinalSplineAt(CCPoint &p0, CCPoint &p1, CCPoint &p2, CCPoint &p3, CCFloat tension, float t) +CCPoint ccCardinalSplineAt(CCPoint &p0, CCPoint &p1, CCPoint &p2, CCPoint &p3, float tension, float t) { float t2 = t * t; float t3 = t2 * t; diff --git a/cocos2dx/actions/CCActionCatmullRom.h b/cocos2dx/actions/CCActionCatmullRom.h index 984f63db78..62a0c2576b 100644 --- a/cocos2dx/actions/CCActionCatmullRom.h +++ b/cocos2dx/actions/CCActionCatmullRom.h @@ -181,7 +181,7 @@ public: }; /** Returns the Cardinal Spline position for a given set of control points, tension and time */ -extern CCPoint ccCardinalSplineAt(CCPoint &p0, CCPoint &p1, CCPoint &p2, CCPoint &p3, CCFloat tension, float t); +extern CCPoint ccCardinalSplineAt(CCPoint &p0, CCPoint &p1, CCPoint &p2, CCPoint &p3, float tension, float t); NS_CC_END; diff --git a/cocos2dx/platform/ios/CCFileUtils.mm b/cocos2dx/platform/ios/CCFileUtils.mm index 2cc27f59af..3f87b9f0e0 100644 --- a/cocos2dx/platform/ios/CCFileUtils.mm +++ b/cocos2dx/platform/ios/CCFileUtils.mm @@ -212,6 +212,17 @@ static void static_addValueToCCDict(id key, id value, CCDictionary* pDict) NS_CC_BEGIN +CCFileUtils* CCFileUtils::sharedFileUtils() +{ + static CCFileUtils *fileUtils = NULL; + if (fileUtils == NULL) + { + fileUtils = new CCFileUtils(); + } + + return fileUtils; +} + void CCFileUtils::setResourcePath(const char *pszResourcePath) { assert(0); @@ -389,7 +400,7 @@ const char *CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const CCDictionary* ccFileUtils_dictionaryWithContentsOfFileThreadSafe(const char *pFileName) { - const char* pszFullPath = CCFileUtils::fullPathFromRelativePath(pFileName); + const char* pszFullPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pFileName); NSString* pPath = [NSString stringWithUTF8String:pszFullPath]; NSDictionary* pDict = [NSDictionary dictionaryWithContentsOfFile:pPath]; diff --git a/cocos2dx/platform/ios/CCGL.h b/cocos2dx/platform/ios/CCGL.h index faad8e010d..e1b95d5104 100644 --- a/cocos2dx/platform/ios/CCGL.h +++ b/cocos2dx/platform/ios/CCGL.h @@ -29,6 +29,7 @@ THE SOFTWARE. #define glDeleteVertexArrays glDeleteVertexArraysOES #define glGenVertexArrays glGenVertexArraysOES #define glBindVertexArray glBindVertexArrayOES +#define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES #include #include diff --git a/cocos2dx/platform/ios/CCImage.mm b/cocos2dx/platform/ios/CCImage.mm index 8ab0bf4c83..5cf6edc95a 100644 --- a/cocos2dx/platform/ios/CCImage.mm +++ b/cocos2dx/platform/ios/CCImage.mm @@ -348,7 +348,8 @@ CCImage::~CCImage() bool CCImage::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFmtPng*/) { unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::getFileData(CCFileUtils::fullPathFromRelativePath(strPath), "rb", &nSize); + CCFileUtils *fileUtils = CCFileUtils::sharedFileUtils(); + unsigned char *pBuffer = fileUtils->getFileData(fileUtils->fullPathFromRelativePath(strPath), "rb", &nSize); return initWithImageData(pBuffer, nSize, eImgFmt); } @@ -360,7 +361,7 @@ bool CCImage::initWithImageFileThreadSafe(const char *fullpath, EImageFormat ima * CCFileUtils::fullPathFromRelativePath() is not thread-safe, it use autorelease(). */ unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::getFileData(fullpath, "rb", &nSize); + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->getFileData(fullpath, "rb", &nSize); return initWithImageData(pBuffer, nSize, imageType); } diff --git a/js/JSBindings/cocos2d_generated.cpp.REMOVED.git-id b/js/JSBindings/cocos2d_generated.cpp.REMOVED.git-id index 3d85d029c4..05cd982ee9 100644 --- a/js/JSBindings/cocos2d_generated.cpp.REMOVED.git-id +++ b/js/JSBindings/cocos2d_generated.cpp.REMOVED.git-id @@ -1 +1 @@ -2d4adf9bb3276c7884f16637eb15bd5090ad7ca2 \ No newline at end of file +2ef6f502d16098ac1a18aee1ab7a64815c241af6 \ No newline at end of file diff --git a/js/JSBindings/cocos2d_generated.hpp.REMOVED.git-id b/js/JSBindings/cocos2d_generated.hpp.REMOVED.git-id index 4a62df2fde..650571e3ce 100644 --- a/js/JSBindings/cocos2d_generated.hpp.REMOVED.git-id +++ b/js/JSBindings/cocos2d_generated.hpp.REMOVED.git-id @@ -1 +1 @@ -f15b1b846b94b2d2b69438899124884963fd9f09 \ No newline at end of file +27f42f585ea7195531f863d34fff314117000630 \ No newline at end of file diff --git a/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id b/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id index 17c493db58..2997ec0aac 100644 --- a/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -59d857c1050d96d698c58eaf20c0c3cd1a808cbf \ No newline at end of file +594b0f9fe97d6f6dd1d56c71ccd7e1c61b5522b3 \ No newline at end of file diff --git a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id index 3a2f28fb74..1b9507a40b 100644 --- a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -277bc57b726290085c72db62cf656b66594440dc \ No newline at end of file +b77ecad7976dbe21bb61300c73e06ddbad3a4bd8 \ No newline at end of file From c95cbb1774c1af55336780bb5ffca95da985d0b4 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 11 Jun 2012 10:59:57 +0800 Subject: [PATCH 111/257] issue #1310: Used CCLabelAtlas instead of CCLabelBMFont to display FPS,SPF status. Updated CCFileUtils, added some method, such as sharedFileUtils/purgeFileUtils/purgeCachedEntries. Fixed a bug in CCDirector, made retina mode work correctly. --- cocos2dx/CCDirector.cpp | 78 ++++++++++++++----- cocos2dx/CCDirector.h | 21 +++-- cocos2dx/platform/CCFileUtils.h | 2 + cocos2dx/platform/android/CCFileUtils.cpp | 30 ++++++- cocos2dx/platform/ios/CCFileUtils.mm | 26 +++++++ cocos2dx/platform/win32/CCFileUtils.cpp | 10 +++ .../DrawPrimitivesTest/DrawPrimitivesTest.cpp | 3 + tests/tests/ParticleTest/ParticleTest.cpp | 2 +- .../PerformanceParticleTest.cpp | 2 +- 9 files changed, 145 insertions(+), 29 deletions(-) diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 5c840fded0..1c7c589d1f 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -120,7 +120,7 @@ bool CCDirector::init(void) // paused ? m_bPaused = false; - + // purge ? m_bPurgeDirecotorInNextLoop = false; @@ -267,7 +267,7 @@ void CCDirector::calculateDeltaTime(void) return; } - // new delta time + // new delta time. Re-fixed issue #1277 if (m_bNextDeltaTimeZero) { m_fDeltaTime = 0; @@ -417,11 +417,12 @@ void CCDirector::purgeCachedData(void) { CCLabelBMFont::purgeCachedData(); CCTextureCache::sharedTextureCache()->removeUnusedTextures(); + CCFileUtils::sharedFileUtils()->purgeCachedEntries(); } float CCDirector::getZEye(void) { - return (m_obWinSizeInPixels.height / 1.1566f); + return (m_obWinSizeInPixels.height / 1.1566f / CC_CONTENT_SCALE_FACTOR()); } void CCDirector::setAlphaBlending(bool bOn) @@ -546,6 +547,35 @@ void CCDirector::popScene(void) } } +void CCDirector::popToRootScene(void) +{ + CCAssert(m_pRunningScene != NULL, "A running Scene is needed"); + unsigned int c = m_pobScenesStack->count(); + + if (c == 1) + { + m_pobScenesStack->removeLastObject(); + this->end(); + } + else + { + while (c > 1) + { + CCScene *current = (CCScene*)m_pobScenesStack->lastObject(); + if( current->getIsRunning() ) + { + current->onExit(); + } + current->cleanup(); + + m_pobScenesStack->removeLastObject(); + c--; + } + m_pNextScene = (CCScene*)m_pobScenesStack->lastObject(); + m_bSendCleanupToScene = false; + } +} + void CCDirector::end() { m_bPurgeDirecotorInNextLoop = true; @@ -588,6 +618,7 @@ void CCDirector::purgeDirector() CCSpriteFrameCache::purgeSharedSpriteFrameCache(); CCTextureCache::purgeSharedTextureCache(); CCShaderCache::purgeSharedShaderCache(); + CCFileUtils::purgeFileUtils(); CCConfiguration::purgeConfiguration(); // cocos2d-x specific data structures @@ -719,21 +750,32 @@ void CCDirector::calculateMPF() void CCDirector::createStatsLabel() { - CC_SAFE_RELEASE_NULL(m_pFPSLabel); - CC_SAFE_RELEASE_NULL(m_pSPFLabel); - CC_SAFE_RELEASE_NULL(m_pDrawsLabel); - - m_pFPSLabel = CCLabelBMFont::labelWithString("00.0", "fps_images.fnt"); - m_pSPFLabel = CCLabelBMFont::labelWithString("0.000", "fps_images.fnt"); - m_pDrawsLabel = CCLabelBMFont::labelWithString("000", "fps_images.fnt"); - - m_pFPSLabel->retain(); - m_pSPFLabel->retain(); - m_pDrawsLabel->retain(); - - m_pDrawsLabel->setPosition(ccp(20, 50)); - m_pSPFLabel->setPosition(ccp(25, 30)); - m_pFPSLabel->setPosition(ccp(20, 10)); + if( m_pFPSLabel && m_pSPFLabel ) + { + CCTexture2D *texture = m_pFPSLabel->getTexture(); + + CC_SAFE_RELEASE_NULL(m_pFPSLabel); + CC_SAFE_RELEASE_NULL(m_pSPFLabel); + CC_SAFE_RELEASE_NULL(m_pDrawsLabel); + CCTextureCache::sharedTextureCache()->removeTexture(texture); + + CCFileUtils::sharedFileUtils()->purgeCachedEntries(); + } + + CCTexture2DPixelFormat currentFormat = CCTexture2D::defaultAlphaPixelFormat(); + CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444); + m_pFPSLabel = new CCLabelAtlas(); + m_pFPSLabel->initWithString("00.0", "fps_images.png", 12, 32, '.'); + m_pSPFLabel = new CCLabelAtlas(); + m_pSPFLabel->initWithString("0.000", "fps_images.png", 12, 32, '.'); + m_pDrawsLabel = new CCLabelAtlas(); + m_pDrawsLabel->initWithString("000", "fps_images.png", 12, 32, '.'); + + CCTexture2D::setDefaultAlphaPixelFormat(currentFormat); + + m_pDrawsLabel->setPosition( ccpAdd( ccp(0,34), CC_DIRECTOR_STATS_POSITION ) ); + m_pSPFLabel->setPosition( ccpAdd( ccp(0,17), CC_DIRECTOR_STATS_POSITION ) ); + m_pFPSLabel->setPosition( CC_DIRECTOR_STATS_POSITION ); } diff --git a/cocos2dx/CCDirector.h b/cocos2dx/CCDirector.h index 9b63a63aea..ff53a42da1 100644 --- a/cocos2dx/CCDirector.h +++ b/cocos2dx/CCDirector.h @@ -55,7 +55,7 @@ typedef enum { } ccDirectorProjection; /* Forward declarations. */ -class CCLabelBMFont; +class CCLabelAtlas; class CCScene; class CCEGLView; class CCDirectorDelegate; @@ -120,7 +120,7 @@ public: /** Whether or not the Director is paused */ inline bool isPaused(void) { return m_bPaused; } - + /** How many frames were called since the director started */ inline unsigned int getFrames(void) { return m_uFrames; } @@ -200,6 +200,13 @@ public: */ void popScene(void); + /**Pops out all scenes from the queue until the root scene in the queue. + * This scene will replace the running one. + * The running scene will be deleted. If there are no more scenes in the stack the execution is terminated. + * ONLY call it if there is a running scene. + */ + void popToRootScene(void); + /** Replaces the running scene with a new one. The running scene is terminated. * ONLY call it if there is a running scene. */ @@ -332,13 +339,13 @@ protected: float m_fAccumDt; float m_fFrameRate; - CCLabelBMFont *m_pFPSLabel; - CCLabelBMFont *m_pSPFLabel; - CCLabelBMFont *m_pDrawsLabel; + CCLabelAtlas *m_pFPSLabel; + CCLabelAtlas *m_pSPFLabel; + CCLabelAtlas *m_pDrawsLabel; - /* is the running scene paused */ + /** Whether or not the Director is paused */ bool m_bPaused; - + /* How many frames were called since the director started */ unsigned int m_uTotalFrames; unsigned int m_uFrames; diff --git a/cocos2dx/platform/CCFileUtils.h b/cocos2dx/platform/CCFileUtils.h index b4e83fde1d..9bf5931574 100644 --- a/cocos2dx/platform/CCFileUtils.h +++ b/cocos2dx/platform/CCFileUtils.h @@ -36,6 +36,8 @@ class CC_DLL CCFileUtils public: static CCFileUtils* sharedFileUtils(); static void purgeFileUtils(); + + void purgeCachedEntries(); /** @brief Get resource file data @param[in] pszFileName The resource file name which contain the path diff --git a/cocos2dx/platform/android/CCFileUtils.cpp b/cocos2dx/platform/android/CCFileUtils.cpp index 4d2d437e9b..60c6df25b2 100644 --- a/cocos2dx/platform/android/CCFileUtils.cpp +++ b/cocos2dx/platform/android/CCFileUtils.cpp @@ -25,16 +25,42 @@ THE SOFTWARE. #define __CC_PLATFORM_FILEUTILS_CPP__ #include "CCFileUtilsCommon_cpp.h" +using namespace std; + NS_CC_BEGIN #include "CCCommon.h" #include "jni/SystemInfoJni.h" -using namespace std; - // record the resource path static string s_strResourcePath = ""; +static CCFileUtils* s_pFileUtils = NULL; + +CCFileUtils* CCFileUtils::sharedFileUtils() +{ + if (s_pFileUtils == NULL) + { + s_pFileUtils = new CCFileUtils(); + } + return s_pFileUtils; +} + +void CCFileUtils::purgeFileUtils() +{ + if (s_pFileUtils != NULL) + { + s_pFileUtils->purgeCachedEntries(); + } + + CC_SAFE_DELETE(s_pFileUtils); +} + +void CCFileUtils::purgeCachedEntries() +{ + +} + /* * This function is implemented for jni to set apk path. */ diff --git a/cocos2dx/platform/ios/CCFileUtils.mm b/cocos2dx/platform/ios/CCFileUtils.mm index 2cc27f59af..a738994dbf 100644 --- a/cocos2dx/platform/ios/CCFileUtils.mm +++ b/cocos2dx/platform/ios/CCFileUtils.mm @@ -212,6 +212,32 @@ static void static_addValueToCCDict(id key, id value, CCDictionary* pDict) NS_CC_BEGIN +static CCFileUtils* s_pFileUtils = NULL; + +CCFileUtils* CCFileUtils::sharedFileUtils() +{ + if (s_pFileUtils == NULL) + { + s_pFileUtils = new CCFileUtils(); + } + return s_pFileUtils; +} + +void CCFileUtils::purgeFileUtils() +{ + if (s_pFileUtils != NULL) + { + s_pFileUtils->purgeCachedEntries(); + } + + CC_SAFE_DELETE(s_pFileUtils); +} + +void CCFileUtils::purgeCachedEntries() +{ + +} + void CCFileUtils::setResourcePath(const char *pszResourcePath) { assert(0); diff --git a/cocos2dx/platform/win32/CCFileUtils.cpp b/cocos2dx/platform/win32/CCFileUtils.cpp index 33887eb046..73105bc103 100644 --- a/cocos2dx/platform/win32/CCFileUtils.cpp +++ b/cocos2dx/platform/win32/CCFileUtils.cpp @@ -62,9 +62,19 @@ CCFileUtils* CCFileUtils::sharedFileUtils() void CCFileUtils::purgeFileUtils() { + if (s_pFileUtils != NULL) + { + s_pFileUtils->purgeCachedEntries(); + } + CC_SAFE_DELETE(s_pFileUtils); } +void CCFileUtils::purgeCachedEntries() +{ + +} + void CCFileUtils::setResourcePath(const char *pszResourcePath) { CCAssert(pszResourcePath != NULL, "[FileUtils setResourcePath] -- wrong resource path"); diff --git a/tests/tests/DrawPrimitivesTest/DrawPrimitivesTest.cpp b/tests/tests/DrawPrimitivesTest/DrawPrimitivesTest.cpp index 33bbedb155..67d30e156f 100644 --- a/tests/tests/DrawPrimitivesTest/DrawPrimitivesTest.cpp +++ b/tests/tests/DrawPrimitivesTest/DrawPrimitivesTest.cpp @@ -90,6 +90,9 @@ void DrawPrimitivesTest::draw() ccDrawCubicBezier(ccp(s.width/2, s.height/2), ccp(s.width/2+30,s.height/2+50), ccp(s.width/2+60,s.height/2-50),ccp(s.width, s.height/2),100); CHECK_GL_ERROR_DEBUG(); + //draw a solid polygon + CCPoint vertices3[] = {ccp(60,160), ccp(70,190), ccp(100,190), ccp(90,160)}; + ccDrawSolidPoly( vertices3, 4, ccc4f(1,1,0,1) ); // restore original values glLineWidth(1); diff --git a/tests/tests/ParticleTest/ParticleTest.cpp b/tests/tests/ParticleTest/ParticleTest.cpp index cc2d44a15b..aa63850ac8 100644 --- a/tests/tests/ParticleTest/ParticleTest.cpp +++ b/tests/tests/ParticleTest/ParticleTest.cpp @@ -1104,7 +1104,7 @@ void ParticleDemo::onEnter(void) addChild( menu, 100 ); - CCLabelAtlas* labelAtlas = CCLabelAtlas::labelWithString("0000", "fonts/fps_images.png", 16, 24, '.'); + CCLabelAtlas* labelAtlas = CCLabelAtlas::labelWithString("0000", "fps_images.png", 12, 32, '.'); addChild(labelAtlas, 100, kTagParticleCount); labelAtlas->setPosition(CCPointMake(s.width-66,50)); diff --git a/tests/tests/PerformanceTest/PerformanceParticleTest.cpp b/tests/tests/PerformanceTest/PerformanceParticleTest.cpp index 0701cb82a5..fec426fcf6 100644 --- a/tests/tests/PerformanceTest/PerformanceParticleTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceParticleTest.cpp @@ -95,7 +95,7 @@ void ParticleMainScene::initWithSubTest(int asubtest, int particles) addChild(infoLabel, 1, kTagInfoLayer); // particles on stage - CCLabelAtlas *labelAtlas = CCLabelAtlas::labelWithString("0000", "fonts/fps_images.png", 16, 24, '.'); + CCLabelAtlas *labelAtlas = CCLabelAtlas::labelWithString("0000", "fps_images.png", 12, 32, '.'); addChild(labelAtlas, 0, kTagLabelAtlas); labelAtlas->setPosition(ccp(s.width-66,50)); From bd535c3c1ca72f8210a59a445e86928cfe6a8375 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 11 Jun 2012 11:53:17 +0800 Subject: [PATCH 112/257] issue #1310: Fixed a bug that 3d effect can't be displayed correctly in retina mode. --- cocos2dx/CCDirector.cpp | 16 ---------------- cocos2dx/actions/CCActionGrid3D.cpp | 22 +++++++--------------- cocos2dx/actions/CCActionGrid3D.h | 9 --------- cocos2dx/effects/CCGrid.cpp | 2 +- 4 files changed, 8 insertions(+), 41 deletions(-) diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 3676702630..c47f0b6706 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -357,12 +357,6 @@ void CCDirector::setProjection(ccDirectorProjection kProjection) case kCCDirectorProjection3D: { -//TODO: // reset the viewport if 3d proj & retina display -// if( CC_CONTENT_SCALE_FACTOR() != 1.0f ) -// { -// glViewport((GLint)-size.width/2, (GLint)-size.height/2, (GLsizei)(size.width * CC_CONTENT_SCALE_FACTOR()), (GLsizei)(size.height * CC_CONTENT_SCALE_FACTOR()) ); -// } - float zeye = this->getZEye(); kmMat4 matrixPerspective, matrixLookup; @@ -374,16 +368,6 @@ void CCDirector::setProjection(ccDirectorProjection kProjection) kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, zeye*2); // kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, 1500); -//TODO: if (m_pobOpenGLView && m_pobOpenGLView->isIpad() && m_pobOpenGLView->getMainScreenScale() > 1.0f) -// { -// kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, zeye-size.height/2, zeye+size.height/2); -// } -// else -// { -// kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.5f, 1500); -// } - -// kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, 1500); kmGLMultMatrix(&matrixPerspective); kmGLMatrixMode(KM_GL_MODELVIEW); diff --git a/cocos2dx/actions/CCActionGrid3D.cpp b/cocos2dx/actions/CCActionGrid3D.cpp index 1ba7efb92f..52b4a49861 100644 --- a/cocos2dx/actions/CCActionGrid3D.cpp +++ b/cocos2dx/actions/CCActionGrid3D.cpp @@ -134,7 +134,7 @@ bool CCFlipX3D::initWithSize(const ccGridSize& gridSize, float duration) if (gridSize.x != 1 || gridSize.y != 1) { // Grid size must be (1,1) - CCAssert(0, ""); + CCAssert(0, "Grid size must be (1,1)"); return false; } @@ -402,9 +402,6 @@ void CCLens3D::setPosition(const CCPoint& pos) { if( ! CCPoint::CCPointEqualToPoint(pos, m_position) ) { m_position = pos; - m_positionInPixels.x = pos.x * CC_CONTENT_SCALE_FACTOR(); - m_positionInPixels.y = pos.y * CC_CONTENT_SCALE_FACTOR(); - m_bDirty = true; } } @@ -421,7 +418,7 @@ void CCLens3D::update(float time) for (j = 0; j < m_sGridSize.y + 1; ++j) { ccVertex3F v = originalVertex(ccg(i, j)); - CCPoint vect = ccpSub(m_positionInPixels, ccp(v.x, v.y)); + CCPoint vect = ccpSub(m_position, ccp(v.x, v.y)); CCFloat r = ccpLength(vect); if (r < m_fRadius) @@ -492,8 +489,6 @@ bool CCRipple3D::initWithPosition(const CCPoint& pos, float r, int wav, float am void CCRipple3D::setPosition(const CCPoint& position) { m_position = position; - m_positionInPixels.x = position.x * CC_CONTENT_SCALE_FACTOR(); - m_positionInPixels.y = position.y * CC_CONTENT_SCALE_FACTOR(); } CCObject* CCRipple3D::copyWithZone(CCZone *pZone) @@ -528,7 +523,7 @@ void CCRipple3D::update(float time) for (j = 0; j < (m_sGridSize.y+1); ++j) { ccVertex3F v = originalVertex(ccg(i, j)); - CCPoint vect = ccpSub(m_positionInPixels, ccp(v.x,v.y)); + CCPoint vect = ccpSub(m_position, ccp(v.x,v.y)); CCFloat r = ccpLength(vect); if (r < m_fRadius) @@ -820,8 +815,6 @@ bool CCTwirl::initWithPosition(const CCPoint& pos, int t, float amp, const ccGri void CCTwirl::setPosition(const CCPoint& position) { m_position = position; - m_positionInPixels.x = position.x * CC_CONTENT_SCALE_FACTOR(); - m_positionInPixels.y = position.y * CC_CONTENT_SCALE_FACTOR(); } CCObject* CCTwirl::copyWithZone(CCZone *pZone) @@ -851,7 +844,7 @@ CCObject* CCTwirl::copyWithZone(CCZone *pZone) void CCTwirl::update(float time) { int i, j; - CCPoint c = m_positionInPixels; + CCPoint c = m_position; for (i = 0; i < (m_sGridSize.x+1); ++i) { @@ -865,10 +858,9 @@ void CCTwirl::update(float time) CCFloat amp = 0.1f * m_fAmplitude * m_fAmplitudeRate; CCFloat a = r * cosf( (CCFloat)M_PI/2.0f + time * (CCFloat)M_PI * m_nTwirls * 2 ) * amp; - CCPoint d; - - d.x = sinf(a) * (v.y-c.y) + cosf(a) * (v.x-c.x); - d.y = cosf(a) * (v.y-c.y) - sinf(a) * (v.x-c.x); + CCPoint d = ccp( + sinf(a) * (v.y-c.y) + cosf(a) * (v.x-c.x), + cosf(a) * (v.y-c.y) - sinf(a) * (v.x-c.x)); v.x = c.x + d.x; v.y = c.y + d.y; diff --git a/cocos2dx/actions/CCActionGrid3D.h b/cocos2dx/actions/CCActionGrid3D.h index e96f72efbc..83489274a5 100644 --- a/cocos2dx/actions/CCActionGrid3D.h +++ b/cocos2dx/actions/CCActionGrid3D.h @@ -110,9 +110,6 @@ protected: /** lens effect. Defaults to 0.7 - 0 means no effect, 1 is very strong effect */ float m_fLensEffect; - /* @since v0.99.5 */ - // CCPoint m_lastPosition; - CCPoint m_positionInPixels; bool m_bDirty; }; @@ -148,9 +145,6 @@ protected: int m_nWaves; float m_fAmplitude; float m_fAmplitudeRate; - - /*@since v0.99.5*/ - CCPoint m_positionInPixels; }; /** @brief CCShaky3D action */ @@ -255,9 +249,6 @@ protected: int m_nTwirls; float m_fAmplitude; float m_fAmplitudeRate; - - /*@since v0.99.5 */ - CCPoint m_positionInPixels; }; NS_CC_END diff --git a/cocos2dx/effects/CCGrid.cpp b/cocos2dx/effects/CCGrid.cpp index 78018b50dc..a2f7d6742f 100644 --- a/cocos2dx/effects/CCGrid.cpp +++ b/cocos2dx/effects/CCGrid.cpp @@ -89,7 +89,7 @@ bool CCGridBase::initWithSize(const ccGridSize& gridSize, CCTexture2D *pTexture, CC_SAFE_RETAIN(m_pTexture); m_bIsTextureFlipped = bFlipped; - const CCSize& texSize = m_pTexture->getContentSizeInPixels(); + const CCSize& texSize = m_pTexture->getContentSize(); m_obStep.x = texSize.width / m_sGridSize.x; m_obStep.y = texSize.height / m_sGridSize.y; From b4899ae46d64029dd08fa3af3ba57ea007caa990 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 11 Jun 2012 14:36:25 +0800 Subject: [PATCH 113/257] issue #1310: synchronize CCLabelTTF --- cocos2dx/label_nodes/CCLabelTTF.cpp | 275 +++++++++++++++------- cocos2dx/label_nodes/CCLabelTTF.h | 57 ++++- cocos2dx/platform/CCApplicationProtocol.h | 2 + cocos2dx/platform/CCEGLViewProtocol.cpp | 5 - cocos2dx/platform/CCEGLViewProtocol.h | 1 - cocos2dx/platform/ios/CCApplication.h | 78 +++--- cocos2dx/platform/ios/CCApplication.mm | 10 + 7 files changed, 289 insertions(+), 139 deletions(-) diff --git a/cocos2dx/label_nodes/CCLabelTTF.cpp b/cocos2dx/label_nodes/CCLabelTTF.cpp index cb04d43ed1..2e48263ec0 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.cpp +++ b/cocos2dx/label_nodes/CCLabelTTF.cpp @@ -26,6 +26,7 @@ THE SOFTWARE. #include "CCDirector.h" #include "CCGLProgram.h" #include "CCShaderCache.h" +#include "CCApplication.h" NS_CC_BEGIN @@ -39,34 +40,33 @@ NS_CC_BEGIN //CCLabelTTF // CCLabelTTF::CCLabelTTF() - : m_eAlignment(kCCTextAlignmentCenter) - , m_pFontName(NULL) - , m_fFontSize(0.0) - , m_pString(NULL) +: m_hAlignment(kCCTextAlignmentCenter) +, m_vAlignment(kCCVerticalTextAlignmentTop) +, m_pFontName(NULL) +, m_fFontSize(0.0) +, m_string("") { } CCLabelTTF::~CCLabelTTF() { - CC_SAFE_DELETE(m_pFontName); - CC_SAFE_DELETE(m_pString); + CC_SAFE_DELETE(m_pFontName); } -CCLabelTTF * CCLabelTTF::labelWithString(const char *label, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize) +CCLabelTTF * CCLabelTTF::labelWithString(const char *string, const char *fontName, float fontSize) { - CCLabelTTF *pRet = new CCLabelTTF(); - if(pRet && pRet->initWithString(label, dimensions, alignment, fontName, fontSize)) - { - pRet->autorelease(); - return pRet; - } - CC_SAFE_DELETE(pRet); - return NULL; + return labelWithString(string, CCSizeZero, kCCTextAlignmentCenter, kCCVerticalTextAlignmentTop, fontName, fontSize); } -CCLabelTTF * CCLabelTTF::labelWithString(const char *label, const char *fontName, float fontSize) + +CCLabelTTF * CCLabelTTF::labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, const char *fontName, float fontSize) +{ + return labelWithString(string, dimensions, hAlignment, kCCVerticalTextAlignmentTop, fontName, fontSize); +} + +CCLabelTTF* CCLabelTTF::labelWithString(const char *string, const cocos2d::CCSize &dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize) { CCLabelTTF *pRet = new CCLabelTTF(); - if(pRet && pRet->initWithString(label, fontName, fontSize)) + if(pRet && pRet->initWithString(string, dimensions, hAlignment, vAlignment, fontName, fontSize)) { pRet->autorelease(); return pRet; @@ -82,93 +82,50 @@ bool CCLabelTTF::init() bool CCLabelTTF::initWithString(const char *label, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize) { - CCAssert(label != NULL, ""); - if (CCSprite::init()) - { - // shader program - setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(SHADER_PROGRAM)); - - m_tDimensions = CCSizeMake( dimensions.width * CC_CONTENT_SCALE_FACTOR(), dimensions.height * CC_CONTENT_SCALE_FACTOR() ); - m_eAlignment = alignment; - - CC_SAFE_DELETE(m_pFontName); - m_pFontName = new std::string(fontName); - - m_fFontSize = fontSize * CC_CONTENT_SCALE_FACTOR(); - this->setString(label); - return true; - } - return false; + return this->initWithString(label, dimensions, alignment, kCCVerticalTextAlignmentTop, fontName, fontSize); } + bool CCLabelTTF::initWithString(const char *label, const char *fontName, float fontSize) { - CCAssert(label != NULL, ""); + return this->initWithString(label, CCSizeZero, kCCTextAlignmentLeft, kCCVerticalTextAlignmentTop, fontName, fontSize); +} + +bool CCLabelTTF::initWithString(const char *string, const cocos2d::CCSize &dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize) +{ if (CCSprite::init()) { // shader program - setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(SHADER_PROGRAM)); - - m_tDimensions = CCSizeZero; - - CC_SAFE_DELETE(m_pFontName); + this->setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(SHADER_PROGRAM)); + + m_tDimensions = CCSizeMake(dimensions.width, dimensions.height); + m_hAlignment = hAlignment; + m_vAlignment = vAlignment; m_pFontName = new std::string(fontName); - - m_fFontSize = fontSize * CC_CONTENT_SCALE_FACTOR(); - this->setString(label); + m_fFontSize = fontSize; + + this->setString(string); + return true; } + return false; } -void CCLabelTTF::setString(const char *label) + +void CCLabelTTF::setString(const char *string) { - if (m_pString) - { - delete m_pString; - m_pString = NULL; - } - m_pString = new std::string(label); + CCAssert(string != NULL, "Invalid string"); - CCTexture2D *texture; - if( CCSize::CCSizeEqualToSize( m_tDimensions, CCSizeZero ) ) + if (m_string.compare(string)) { - texture = new CCTexture2D(); - texture->initWithString(label, m_pFontName->c_str(), m_fFontSize); + m_string = string; + + this->updateTexture(); } - else - { - texture = new CCTexture2D(); -//cjh texture->initWithString(label, m_tDimensions, m_eAlignment, kCCVerticalTextAlignmentTop, m_pFontName->c_str(), m_fFontSize); - } - -// TODO -// #ifdef __CC_PLATFORM_IOS -// // iPad ? -// if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) { -// if( CC_CONTENT_SCALE_FACTOR() == 2 ) -// [tex setResolutionType:kCCResolutioniPadRetinaDisplay]; -// else -// [tex setResolutionType:kCCResolutioniPad]; -// } -// // iPhone ? -// else -// { -// if( CC_CONTENT_SCALE_FACTOR() == 2 ) -// [tex setResolutionType:kCCResolutioniPhoneRetinaDisplay]; -// else -// [tex setResolutionType:kCCResolutioniPhone]; -// } -// #end - this->setTexture(texture); - texture->release(); - - CCRect rect = CCRectZero; - rect.size = m_pobTexture->getContentSize(); - this->setTextureRect(rect); } const char* CCLabelTTF::getString(void) { - return m_pString->c_str(); + return m_string.c_str(); } const char* CCLabelTTF::description() @@ -176,4 +133,152 @@ const char* CCLabelTTF::description() return CCString::stringWithFormat("", m_pFontName->c_str(), m_fFontSize)->getCString(); } +CCTextAlignment CCLabelTTF::getHorizontalAlignment() +{ + return m_hAlignment; +} + +void CCLabelTTF::setHorizontalAlignment(CCTextAlignment alignment) +{ + if (alignment != m_hAlignment) + { + m_hAlignment = alignment; + + // Force update + if (m_string.size() > 0) + { + this->updateTexture(); + } + } +} + +CCVerticalTextAlignment CCLabelTTF::getVerticalAlignment() +{ + return m_vAlignment; +} + +void CCLabelTTF::setVerticalAlignment(CCVerticalTextAlignment verticalAlignment) +{ + if (verticalAlignment != m_vAlignment) + { + m_vAlignment = verticalAlignment; + + // Force update + if (m_string.size() > 0) + { + this->updateTexture(); + } + } +} + +CCSize CCLabelTTF::getDimensions() +{ + return m_tDimensions; +} + +void CCLabelTTF::setDimensions(CCSize &dim) +{ + if (dim.width != m_tDimensions.width || dim.height != m_tDimensions.height) + { + m_tDimensions = dim; + + // Force udpate + if (m_string.size() > 0) + { + this->updateTexture(); + } + } +} + +float CCLabelTTF::getFontSize() +{ + return m_fFontSize; +} + +void CCLabelTTF::setFontSize(float fontSize) +{ + if (m_fFontSize != fontSize) + { + // Force update + if (m_string.size() > 0) + { + this->updateTexture(); + } + } +} + +const char* CCLabelTTF::getFontName() +{ + return m_pFontName->c_str(); +} + +void CCLabelTTF::setFontName(const char *fontName) +{ + if (m_pFontName->compare(fontName)) + { + delete m_pFontName; + m_pFontName = new std::string(fontName); + + // Force update + if (m_string.size() > 0) + { + this->updateTexture(); + } + } +} + +// Helper +void CCLabelTTF::updateTexture() +{ + CCTexture2D *tex; + if (m_tDimensions.width == 0 || m_tDimensions.height == 0) + { + tex = new CCTexture2D(); + tex->initWithString(m_string.c_str(), m_pFontName->c_str(), m_fFontSize * CC_CONTENT_SCALE_FACTOR()) ; + } + else + { + tex = new CCTexture2D(); + tex->initWithString(m_string.c_str(), + CC_SIZE_POINTS_TO_PIXELS(m_tDimensions), + m_hAlignment, + m_vAlignment, + m_pFontName->c_str(), + m_fFontSize * CC_CONTENT_SCALE_FACTOR()); + } + + // iPad ? + //if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) { + if (CCApplication::sharedApplication().isIpad()) + { + if (CC_CONTENT_SCALE_FACTOR() == 2) + { + tex->setResolutionType(kCCResolutioniPadRetinaDisplay); + } + else + { + tex->setResolutionType(kCCResolutioniPad); + } + } + // iPhone ? + else + { + if (CC_CONTENT_SCALE_FACTOR() == 2) + { + tex->setResolutionType(kCCResolutioniPhoneRetinaDisplay); + } + else + { + tex->setResolutionType(kCCResolutioniPhone); + } + } + + this->setTexture(tex); + tex->release(); + + CCRect rect = CCRectZero; + rect.size = m_pobTexture->getContentSize(); + this->setTextureRect(rect); +} + NS_CC_END diff --git a/cocos2dx/label_nodes/CCLabelTTF.h b/cocos2dx/label_nodes/CCLabelTTF.h index ee2ecaaa6b..78dd76b999 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.h +++ b/cocos2dx/label_nodes/CCLabelTTF.h @@ -41,33 +41,70 @@ class CC_DLL CCLabelTTF : public CCSprite, public CCLabelProtocol public: CCLabelTTF(); virtual ~CCLabelTTF(); - const char* description(); - /** creates a CCLabelTTF from a fontname, alignment, dimension and font size */ - static CCLabelTTF * labelWithString(const char *label, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize); - /** creates a CCLabelTTF from a fontname and font size */ - static CCLabelTTF * labelWithString(const char *label, const char *fontName, float fontSize); + const char* description(); + + /** creates a CCLabelTTF with a font name and font size in points*/ + static CCLabelTTF * labelWithString(const char *string, const char *fontName, float fontSize); + + /** creates a CCLabelTTF from a fontname, horizontal alignment, dimension in points, and font size in points. + @since v1.0 + */ + static CCLabelTTF * labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, + const char *fontName, float fontSize); + + /** creates a CCLabel from a fontname, alignment, dimension in points and font size in points*/ + static CCLabelTTF * labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, + CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize); + /** initializes the CCLabelTTF with a font name, alignment, dimension and font size */ - bool initWithString(const char *label, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize); + bool initWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, const char *fontName, float fontSize); + + /** initializes the CCLabelTTF with a font name, alignment, dimension and font size */ + bool initWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, + CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize); + /** initializes the CCLabelTTF with a font name and font size */ - bool initWithString(const char *label, const char *fontName, float fontSize); + bool initWithString(const char *string, const char *fontName, float fontSize); + /** initializes the CCLabelTTF */ bool init(); + /** changes the string to render * @warning Changing the string is as expensive as creating a new CCLabelTTF. To obtain better performance use CCLabelAtlas */ virtual void setString(const char *label); virtual const char* getString(void); + + CCTextAlignment getHorizontalAlignment(); + void setHorizontalAlignment(CCTextAlignment alignment); + + CCVerticalTextAlignment getVerticalAlignment(); + void setVerticalAlignment(CCVerticalTextAlignment verticalAlignment); + + CCSize getDimensions(); + void setDimensions(CCSize &dim); + + float getFontSize(); + void setFontSize(float fontSize); + + const char* getFontName(); + void setFontName(const char *fontName); - virtual CCLabelProtocol* convertToLabelProtocol() { return (CCLabelProtocol*)this; } +private: + void updateTexture(); protected: /** Dimensions of the label in Points */ CCSize m_tDimensions; - CCTextAlignment m_eAlignment; + /** The alignment of the label */ + CCTextAlignment m_hAlignment; + /** The vertical alignment of the label */ + CCVerticalTextAlignment m_vAlignment; /** Font name used in the label */ std::string * m_pFontName; /** Font size of the label */ float m_fFontSize; - std::string * m_pString; + + std::string m_string; }; NS_CC_END diff --git a/cocos2dx/platform/CCApplicationProtocol.h b/cocos2dx/platform/CCApplicationProtocol.h index 4da7a785cc..86b597209a 100644 --- a/cocos2dx/platform/CCApplicationProtocol.h +++ b/cocos2dx/platform/CCApplicationProtocol.h @@ -43,6 +43,8 @@ public: @return Current language config */ virtual ccLanguageType getCurrentLanguage() = 0; + + virtual bool isIpad() { return false; } }; diff --git a/cocos2dx/platform/CCEGLViewProtocol.cpp b/cocos2dx/platform/CCEGLViewProtocol.cpp index 9b0607e532..d3de801602 100644 --- a/cocos2dx/platform/CCEGLViewProtocol.cpp +++ b/cocos2dx/platform/CCEGLViewProtocol.cpp @@ -55,11 +55,6 @@ CCEGLViewProtocol::~CCEGLViewProtocol() } -bool CCEGLViewProtocol::isIpad() -{ - return false; -} - void CCEGLViewProtocol::setFrameSize(float width, float height) { m_sSizeInPixel.setSize(width, height); diff --git a/cocos2dx/platform/CCEGLViewProtocol.h b/cocos2dx/platform/CCEGLViewProtocol.h index 5ddf181f86..b2bc1283a8 100644 --- a/cocos2dx/platform/CCEGLViewProtocol.h +++ b/cocos2dx/platform/CCEGLViewProtocol.h @@ -21,7 +21,6 @@ public: virtual void swapBuffers() = 0; virtual void setIMEKeyboardState(bool bOpen) = 0; - virtual bool isIpad(); virtual CCRect getViewPort(); virtual CCSize getSize(); virtual void setFrameSize(float width, float height); diff --git a/cocos2dx/platform/ios/CCApplication.h b/cocos2dx/platform/ios/CCApplication.h index e151755698..c35f8f627a 100644 --- a/cocos2dx/platform/ios/CCApplication.h +++ b/cocos2dx/platform/ios/CCApplication.h @@ -35,53 +35,55 @@ class CCRect; class CC_DLL CCApplication : public CCApplicationProtocol { public: - CCApplication(); - virtual ~CCApplication(); + CCApplication(); + virtual ~CCApplication(); - /** - @brief Callback by CCDirector for limit FPS. - @interval The time, which expressed in second in second, between current frame and next. - */ - void setAnimationInterval(double interval); + /** + @brief Callback by CCDirector for limit FPS. + @interval The time, which expressed in second in second, between current frame and next. + */ + void setAnimationInterval(double interval); - typedef enum - { - /// Device oriented vertically, home button on the bottom - kOrientationPortrait = 0, + typedef enum + { + /// Device oriented vertically, home button on the bottom + kOrientationPortrait = 0, /// Device oriented vertically, home button on the top - kOrientationPortraitUpsideDown = 1, - /// Device oriented horizontally, home button on the right - kOrientationLandscapeLeft = 2, - /// Device oriented horizontally, home button on the left - kOrientationLandscapeRight = 3, - } Orientation; + kOrientationPortraitUpsideDown = 1, + /// Device oriented horizontally, home button on the right + kOrientationLandscapeLeft = 2, + /// Device oriented horizontally, home button on the left + kOrientationLandscapeRight = 3, + } Orientation; - /** - @brief Callback by CCDirector for change device orientation. - @orientation The defination of orientation which CCDirector want change to. - @return The actual orientation of the application. - */ - Orientation setOrientation(Orientation orientation); + /** + @brief Callback by CCDirector for change device orientation. + @orientation The defination of orientation which CCDirector want change to. + @return The actual orientation of the application. + */ + Orientation setOrientation(Orientation orientation); - /** - @brief Run the message loop. - */ - int run(); + /** + @brief Run the message loop. + */ + int run(); - /** - @brief Get current applicaiton instance. - @return Current application instance pointer. - */ - static CCApplication& sharedApplication(); + /** + @brief Get current applicaiton instance. + @return Current application instance pointer. + */ + static CCApplication& sharedApplication(); - /** - @brief Get current language config - @return Current language config - */ - virtual ccLanguageType getCurrentLanguage(); + /** + @brief Get current language config + @return Current language config + */ + virtual ccLanguageType getCurrentLanguage(); + + virtual bool isIpad(); protected: - static CCApplication * sm_pSharedApplication; + static CCApplication * sm_pSharedApplication; }; NS_CC_END diff --git a/cocos2dx/platform/ios/CCApplication.mm b/cocos2dx/platform/ios/CCApplication.mm index 80aa8225c9..9c21bc89f4 100644 --- a/cocos2dx/platform/ios/CCApplication.mm +++ b/cocos2dx/platform/ios/CCApplication.mm @@ -145,4 +145,14 @@ ccLanguageType CCApplication::getCurrentLanguage() return ret; } +bool CCApplication::isIpad() +{ + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) + { + return true; + } + + return false; +} + NS_CC_END From 2ce7c86c50a24e0006e6f069499a84f201162c38 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 11 Jun 2012 14:44:32 +0800 Subject: [PATCH 114/257] fixed #1315: TileMapTest can't be shown correctly in retina mode. --- cocos2dx/base_nodes/CCAtlasNode.cpp | 1 - cocos2dx/include/ccMacros.h | 2 +- .../tileMap_parallax_nodes/CCTMXLayer.cpp | 2 - .../tileMap_parallax_nodes/CCTileMapAtlas.cpp | 92 +++++++++---------- .../tileMap_parallax_nodes/CCTileMapAtlas.h | 11 +-- tests/tests/TileMapTest/TileMapTest.cpp | 8 +- tests/tests/TouchesTest/Ball.cpp | 6 +- 7 files changed, 58 insertions(+), 64 deletions(-) diff --git a/cocos2dx/base_nodes/CCAtlasNode.cpp b/cocos2dx/base_nodes/CCAtlasNode.cpp index 5bbf832153..f73b965429 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.cpp +++ b/cocos2dx/base_nodes/CCAtlasNode.cpp @@ -126,7 +126,6 @@ void CCAtlasNode::calculateMaxItems() void CCAtlasNode::updateAtlasValues() { CCAssert(false, "CCAtlasNode:Abstract updateAtlasValue not overriden"); - //[NSException raise:@"CCAtlasNode:Abstract" format:@"updateAtlasValue not overriden"]; } // CCAtlasNode - draw diff --git a/cocos2dx/include/ccMacros.h b/cocos2dx/include/ccMacros.h index 9784249c31..d958faa6ed 100644 --- a/cocos2dx/include/ccMacros.h +++ b/cocos2dx/include/ccMacros.h @@ -85,7 +85,7 @@ default gl blend src function. Compatible with premultiplied alpha images. #define CC_NODE_DRAW_SETUP() \ do { \ ccGLEnable( m_glServerState ); \ - if (getShaderProgram() != NULL) \ + CCAssert(getShaderProgram(), "No shader program set for node: %p", this); \ { \ getShaderProgram()->use(); \ getShaderProgram()->setUniformForModelViewProjectionMatrix(); \ diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp index 62b5b67a0a..3482411195 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp @@ -88,8 +88,6 @@ bool CCTMXLayer::initWithTilesetInfo(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerIn m_pAtlasIndexArray = ccCArrayNew((unsigned int)totalNumberOfTiles); this->setContentSize(CC_SIZE_PIXELS_TO_POINTS(CCSizeMake(m_tLayerSize.width * m_tMapTileSize.width, m_tLayerSize.height * m_tMapTileSize.height))); - m_tMapTileSize.width /= m_fContentScaleFactor; - m_tMapTileSize.height /= m_fContentScaleFactor; m_bUseAutomaticVertexZ = false; m_nVertexZvalue = 0; diff --git a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp index 29e6085e4f..c8ae96e89f 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp @@ -28,10 +28,12 @@ THE SOFTWARE. #include "CCTextureAtlas.h" #include "support/image_support/TGAlib.h" #include "ccConfig.h" +#include "CCDictionary.h" +#include "CCInteger.h" +#include "CCDirector.h" NS_CC_BEGIN - // implementation CCTileMapAtlas CCTileMapAtlas * CCTileMapAtlas::tileMapAtlasWithTileFile(const char *tile, const char *mapFile, int tileWidth, int tileHeight) @@ -45,13 +47,16 @@ CCTileMapAtlas * CCTileMapAtlas::tileMapAtlasWithTileFile(const char *tile, cons CC_SAFE_DELETE(pRet); return NULL; } + bool CCTileMapAtlas::initWithTileFile(const char *tile, const char *mapFile, int tileWidth, int tileHeight) { this->loadTGAfile(mapFile); this->calculateItemsToRender(); + if( CCAtlasNode::initWithTileFile(tile, tileWidth, tileHeight, m_nItemsToRender) ) { - m_pPosToAtlasIndex = new StringToIntegerDictionary(); + m_tColor = ccWHITE; + m_pPosToAtlasIndex = new CCDictionary(); this->updateAtlasValues(); this->setContentSize(CCSizeMake((float)(m_pTGAInfo->width*m_uItemWidth), (float)(m_pTGAInfo->height*m_uItemHeight))); @@ -59,25 +64,23 @@ bool CCTileMapAtlas::initWithTileFile(const char *tile, const char *mapFile, int } return false; } + CCTileMapAtlas::CCTileMapAtlas() :m_pTGAInfo(NULL) ,m_pPosToAtlasIndex(NULL) ,m_nItemsToRender(0) { } + CCTileMapAtlas::~CCTileMapAtlas() { if (m_pTGAInfo) { tgaDestroy(m_pTGAInfo); } - if (m_pPosToAtlasIndex) - { - m_pPosToAtlasIndex->clear(); - delete m_pPosToAtlasIndex; - m_pPosToAtlasIndex = NULL; - } + CC_SAFE_RELEASE(m_pPosToAtlasIndex); } + void CCTileMapAtlas::releaseMap() { if (m_pTGAInfo) @@ -86,13 +89,9 @@ void CCTileMapAtlas::releaseMap() } m_pTGAInfo = NULL; - if (m_pPosToAtlasIndex) - { - m_pPosToAtlasIndex->clear(); - delete m_pPosToAtlasIndex; - m_pPosToAtlasIndex = NULL; - } + CC_SAFE_RELEASE_NULL(m_pPosToAtlasIndex); } + void CCTileMapAtlas::calculateItemsToRender() { CCAssert( m_pTGAInfo != NULL, "tgaInfo must be non-nil"); @@ -111,6 +110,7 @@ void CCTileMapAtlas::calculateItemsToRender() } } } + void CCTileMapAtlas::loadTGAfile(const char *file) { CCAssert( file != NULL, "file must be non-nil"); @@ -150,22 +150,13 @@ void CCTileMapAtlas::setTile(const ccColor3B& tile, const ccGridSize& position) { ptr[position.x + position.y * m_pTGAInfo->width] = tile; - // XXX: this method consumes a lot of memory - // XXX: a tree of something like that shall be impolemented - char buffer[32]; - /*std::string key = itoa(position.x, buffer, 10);*/ - sprintf(buffer, "%d", position.x); - std::string key = buffer; - - key += ","; - /*key += itoa(position.y, buffer, 10);*/ - sprintf(buffer, "%d", position.y); - key += buffer; - - int num = m_pPosToAtlasIndex->find(key)->second; - this->updateAtlasValueAt(position, tile, num); + // XXX: this method consumes a lot of memory + // XXX: a tree of something like that shall be impolemented + CCInteger *num = (CCInteger*)m_pPosToAtlasIndex->objectForKey(CCString::stringWithFormat("%d,%d", position.x, position.y)->getCString()); + this->updateAtlasValueAt(position, tile, num->getValue()); } } + ccColor3B CCTileMapAtlas::tileAt(const ccGridSize& position) { CCAssert( m_pTGAInfo != NULL, "tgaInfo must not be nil"); @@ -177,6 +168,7 @@ ccColor3B CCTileMapAtlas::tileAt(const ccGridSize& position) return value; } + void CCTileMapAtlas::updateAtlasValueAt(const ccGridSize& pos, const ccColor3B& value, unsigned int index) { ccV3F_C4B_T2F_Quad quad; @@ -189,16 +181,19 @@ void CCTileMapAtlas::updateAtlasValueAt(const ccGridSize& pos, const ccColor3B& float textureWide = (float) (m_pTextureAtlas->getTexture()->getPixelsWide()); float textureHigh = (float) (m_pTextureAtlas->getTexture()->getPixelsHigh()); + float itemWidthInPixels = m_uItemWidth * CC_CONTENT_SCALE_FACTOR(); + float itemHeightInPixels = m_uItemHeight * CC_CONTENT_SCALE_FACTOR(); + #if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL - float left = (2 * row * m_uItemWidth + 1) / (2 * textureWide); - float right = left + (m_uItemWidth * 2 - 2) / (2 * textureWide); - float top = (2 * col * m_uItemHeight + 1) / (2 * textureHigh); - float bottom = top + (m_uItemHeight * 2 - 2) / (2 * textureHigh); + float left = (2 * row * itemWidthInPixels + 1) / (2 * textureWide); + float right = left + (itemWidthInPixels * 2 - 2) / (2 * textureWide); + float top = (2 * col * itemHeightInPixels + 1) / (2 * textureHigh); + float bottom = top + (itemHeightInPixels * 2 - 2) / (2 * textureHigh); #else - float left = (row * m_uItemWidth) / textureWide; - float right = left + m_uItemWidth / textureWide; - float top = (col * m_uItemHeight) / textureHigh; - float bottom = top + m_uItemHeight / textureHigh; + float left = (row * itemWidthInPixels) / textureWide; + float right = left + itemWidthInPixels / textureWide; + float top = (col * itemHeightInPixels) / textureHigh; + float bottom = top + itemHeightInPixels / textureHigh; #endif quad.tl.texCoords.u = left; @@ -223,8 +218,15 @@ void CCTileMapAtlas::updateAtlasValueAt(const ccGridSize& pos, const ccColor3B& quad.tr.vertices.y = (float)(y * m_uItemHeight + m_uItemHeight); quad.tr.vertices.z = 0.0f; + ccColor4B color = { m_tColor.r, m_tColor.g, m_tColor.b, m_cOpacity }; + quad.tr.colors = color; + quad.tl.colors = color; + quad.br.colors = color; + quad.bl.colors = color; + m_pTextureAtlas->updateQuad(&quad, index); } + void CCTileMapAtlas::updateAtlasValues() { CCAssert( m_pTGAInfo != NULL, "tgaInfo must be non-nil"); @@ -244,28 +246,22 @@ void CCTileMapAtlas::updateAtlasValues() { this->updateAtlasValueAt(ccg(x,y), value, total); - char buffer[32]; - /*std::string key = itoa(x, buffer, 10);*/ - sprintf(buffer, "%d", x); - std::string key = buffer; - - key += ","; - /*key += itoa(y, buffer, 10);*/ - sprintf(buffer, "%d", y); - key += buffer; - - m_pPosToAtlasIndex->insert(StringToIntegerPair(key, total)); - + CCString *key = CCString::stringWithFormat("%d,%d", x,y); + CCInteger *num = CCInteger::integerWithInt(total); + m_pPosToAtlasIndex->setObject(num, key->getCString()); + total++; } } } } } + void CCTileMapAtlas::setTGAInfo(struct sImageTGA* var) { m_pTGAInfo = var; } + struct sImageTGA * CCTileMapAtlas::getTGAInfo() { return m_pTGAInfo; diff --git a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h index 8bfe6bd7c7..eb68b7ef48 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h @@ -25,15 +25,14 @@ THE SOFTWARE. ****************************************************************************/ #ifndef __CCTILE_MAP_ATLAS__ #define __CCTILE_MAP_ATLAS__ -#include -#include + + #include "CCAtlasNode.h" NS_CC_BEGIN -typedef std::map StringToIntegerDictionary; -typedef std::pair StringToIntegerPair; struct sImageTGA; +class CCDictionary; /** @brief CCTileMapAtlas is a subclass of CCAtlasNode. It knows how to render a map based of tiles. @@ -82,9 +81,9 @@ private: protected: //! x,y to altas dicctionary - StringToIntegerDictionary *m_pPosToAtlasIndex; + CCDictionary* m_pPosToAtlasIndex; //! numbers of tiles to render - int m_nItemsToRender; + int m_nItemsToRender; }; NS_CC_END diff --git a/tests/tests/TileMapTest/TileMapTest.cpp b/tests/tests/TileMapTest/TileMapTest.cpp index 524fee7bc0..799b0bda2e 100644 --- a/tests/tests/TileMapTest/TileMapTest.cpp +++ b/tests/tests/TileMapTest/TileMapTest.cpp @@ -22,7 +22,7 @@ TileMapTest::TileMapTest() map->getTexture()->setAntiAliasTexParameters(); CCSize s = map->getContentSize(); - ////----UXLOG("ContentSize: %f, %f", s.width,s.height); + CCLOG("ContentSize: %f, %f", s.width,s.height); // If you are not going to use the Map, you can free it now // NEW since v0.7 @@ -57,12 +57,12 @@ TileMapEditTest::TileMapEditTest() map->getTexture()->setAliasTexParameters(); CCSize s = map->getContentSize(); - ////----UXLOG("ContentSize: %f, %f", s.width,s.height); + CCLOG("ContentSize: %f, %f", s.width,s.height); // If you are not going to use the Map, you can free it now // [tilemap releaseMap); // And if you are going to use, it you can access the data with: - schedule(schedule_selector(TileMapEditTest::updateMap), 0.2f);//:@selector(updateMap:) interval:0.2f); + schedule(schedule_selector(TileMapEditTest::updateMap), 0.2f); addChild(map, 0, kTagTileMap); @@ -126,7 +126,7 @@ TMXOrthoTest::TMXOrthoTest() addChild(map, 0, kTagTileMap); CCSize s = map->getContentSize(); - ////----UXLOG("ContentSize: %f, %f", s.width,s.height); + CCLOG("ContentSize: %f, %f", s.width,s.height); CCArray * pChildrenArray = map->getChildren(); CCSpriteBatchNode* child = NULL; diff --git a/tests/tests/TouchesTest/Ball.cpp b/tests/tests/TouchesTest/Ball.cpp index a070367bbd..a7238e83da 100644 --- a/tests/tests/TouchesTest/Ball.cpp +++ b/tests/tests/TouchesTest/Ball.cpp @@ -25,11 +25,13 @@ Ball* Ball::ballWithTexture(CCTexture2D* aTexture) void Ball::move(float delta) { + CCSize size = CCDirector::sharedDirector()->getWinSize(); + this->setPosition( ccpAdd(getPosition(), ccpMult(m_velocity, delta)) ); - if (getPosition().x > 320 - radius()) + if (getPosition().x > size.width - radius()) { - setPosition( ccp( 320 - radius(), getPosition().y) ); + setPosition( ccp( size.width - radius(), getPosition().y) ); m_velocity.x *= -1; } else if (getPosition().x < radius()) From 77f51b5c489b13fb5cada098e42cb82b821f9d7f Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 11 Jun 2012 15:01:23 +0800 Subject: [PATCH 115/257] issue #1310:synchronize CocosDenshion --- CocosDenshion/ios/CocosDenshion.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CocosDenshion/ios/CocosDenshion.m b/CocosDenshion/ios/CocosDenshion.m index f5695aa1ba..fe980938a7 100644 --- a/CocosDenshion/ios/CocosDenshion.m +++ b/CocosDenshion/ios/CocosDenshion.m @@ -521,7 +521,7 @@ static BOOL _mixerRateSet = NO; if (soundId >= bufferTotal) { //Need to resize the buffers int requiredIncrement = CD_BUFFERS_INCREMENT; - while (bufferTotal + requiredIncrement < soundId) { + while (bufferTotal + requiredIncrement <= soundId) { requiredIncrement += CD_BUFFERS_INCREMENT; } CDLOGINFO(@"Denshion::CDSoundEngine - attempting to resize buffers by %i for sound %i",requiredIncrement,soundId); From ccbfd24c217a5c936682be20d6f364757f583596 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 11 Jun 2012 18:25:57 +0800 Subject: [PATCH 116/257] issue #1310: synchronize ActionManagerTest ActionEaseTest ActionsProgressTest ActionsTest --- cocos2dx/actions/CCActionCatmullRom.cpp | 36 +- cocos2dx/actions/CCActionCatmullRom.h | 2 +- cocos2dx/include/ccMacros.h | 2 +- .../project.pbxproj.REMOVED.git-id | 2 +- .../ActionManagerTest/ActionManagerTest.cpp | 10 +- .../tests/ActionsEaseTest/ActionsEaseTest.cpp | 22 +- .../ActionsProgressTest.cpp | 8 +- tests/tests/ActionsTest/ActionsTest.cpp | 370 ++++++++++++++---- tests/tests/ActionsTest/ActionsTest.h | 43 ++ 9 files changed, 395 insertions(+), 100 deletions(-) diff --git a/cocos2dx/actions/CCActionCatmullRom.cpp b/cocos2dx/actions/CCActionCatmullRom.cpp index 50ea1d1bc7..e7f54cce4e 100644 --- a/cocos2dx/actions/CCActionCatmullRom.cpp +++ b/cocos2dx/actions/CCActionCatmullRom.cpp @@ -36,6 +36,8 @@ #include "support/CCPointExtension.h" #include "CCActionCatmullRom.h" +using namespace std; + NS_CC_BEGIN; /* @@ -78,6 +80,7 @@ CCObject* CCPointArray::copyWithZone(cocos2d::CCZone *zone) } CCPointArray *points = CCPointArray::arrayWithCapacity(10); + points->retain(); points->setControlPoints(newArray); newArray->release(); @@ -91,14 +94,30 @@ CCPointArray::~CCPointArray() CCPointArray::CCPointArray() :m_pControlPoints(NULL){} -void CCPointArray::addControlPoint(CCPoint &controlPoint) +void CCPointArray::addControlPoint(CCPoint controlPoint) { - m_pControlPoints->addObject(&controlPoint); + // should create a new object of CCPoint + // because developer always use this function like this + // addControlPoint(ccp(x, y)) + // passing controlPoint is a temple object + // and CCArray::addObject() will retain the passing object, so it + // should be an object created in heap + CCPoint *temp = new CCPoint(controlPoint.x, controlPoint.y); + m_pControlPoints->addObject(temp); + temp->release(); } void CCPointArray::insertControlPoint(CCPoint &controlPoint, unsigned int index) { - m_pControlPoints->insertObject(&controlPoint, index); + // should create a new object of CCPoint + // because developer always use this function like this + // insertControlPoint(ccp(x, y)) + // passing controlPoint is a temple object + // and CCArray::insertObject() will retain the passing object, so it + // should be an object created in heap + CCPoint *temp = new CCPoint(controlPoint.x, controlPoint.y); + m_pControlPoints->insertObject(temp, index); + temp->release(); } CCPoint CCPointArray::getControlPointAtIndex(unsigned int index) @@ -111,7 +130,15 @@ CCPoint CCPointArray::getControlPointAtIndex(unsigned int index) void CCPointArray::replaceControlPoint(cocos2d::CCPoint &controlPoint, unsigned int index) { - m_pControlPoints->replaceObjectAtIndex(index, &controlPoint); + // should create a new object of CCPoint + // because developer always use this function like this + // replaceControlPoint(ccp(x, y)) + // passing controlPoint is a temple object + // and CCArray::insertObject() will retain the passing object, so it + // should be an object created in heap + CCPoint *temp = new CCPoint(controlPoint.x, controlPoint.y); + m_pControlPoints->replaceObjectAtIndex(index, temp); + temp->release(); } void CCPointArray::removeControlPointAtIndex(unsigned int index) @@ -136,7 +163,6 @@ CCPointArray* CCPointArray::reverse() newArray->release(); - config->autorelease(); return config; } diff --git a/cocos2dx/actions/CCActionCatmullRom.h b/cocos2dx/actions/CCActionCatmullRom.h index 62a0c2576b..55636cea8b 100644 --- a/cocos2dx/actions/CCActionCatmullRom.h +++ b/cocos2dx/actions/CCActionCatmullRom.h @@ -59,7 +59,7 @@ public: bool initWithCapacity(unsigned int capacity); /** appends a control point */ - void addControlPoint(CCPoint &controlPoint); + void addControlPoint(CCPoint controlPoint); /** inserts a controlPoint at index */ void insertControlPoint(CCPoint &controlPoint, unsigned int index); diff --git a/cocos2dx/include/ccMacros.h b/cocos2dx/include/ccMacros.h index d958faa6ed..46245f6592 100644 --- a/cocos2dx/include/ccMacros.h +++ b/cocos2dx/include/ccMacros.h @@ -85,7 +85,7 @@ default gl blend src function. Compatible with premultiplied alpha images. #define CC_NODE_DRAW_SETUP() \ do { \ ccGLEnable( m_glServerState ); \ - CCAssert(getShaderProgram(), "No shader program set for node: %p", this); \ + CCAssert(getShaderProgram(), "No shader program set for this node"); \ { \ getShaderProgram()->use(); \ getShaderProgram()->setUniformForModelViewProjectionMatrix(); \ diff --git a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id index 1b9507a40b..8f63248979 100644 --- a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -b77ecad7976dbe21bb61300c73e06ddbad3a4bd8 \ No newline at end of file +c16d1dddb12b5a7e7e715f234dfd031657369f96 \ No newline at end of file diff --git a/tests/tests/ActionManagerTest/ActionManagerTest.cpp b/tests/tests/ActionManagerTest/ActionManagerTest.cpp index 91ade71d38..4bbac03725 100644 --- a/tests/tests/ActionManagerTest/ActionManagerTest.cpp +++ b/tests/tests/ActionManagerTest/ActionManagerTest.cpp @@ -90,7 +90,7 @@ void ActionManagerTest::onEnter() CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32); addChild(label, 1); - label->setPosition( CCPointMake(s.width/2, s.height-50) ); + label->setPosition(CCPointMake(s.width/2, s.height-50)); CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(ActionManagerTest::backCallback) ); CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(ActionManagerTest::restartCallback) ); @@ -98,10 +98,10 @@ void ActionManagerTest::onEnter() CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); - menu->setPosition( CCPointZero ); - item1->setPosition( CCPointMake( s.width/2 - 100,30) ); - item2->setPosition( CCPointMake( s.width/2, 30) ); - item3->setPosition( CCPointMake( s.width/2 + 100,30) ); + menu->setPosition(CCPointZero); + item1->setPosition(CCPointMake(s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2)); + item2->setPosition(CCPointMake(s.width/2, item2->getContentSize().height/2)); + item3->setPosition(CCPointMake(s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2)); addChild(menu, 1); } diff --git a/tests/tests/ActionsEaseTest/ActionsEaseTest.cpp b/tests/tests/ActionsEaseTest/ActionsEaseTest.cpp index 4186a47b0b..412f171309 100644 --- a/tests/tests/ActionsEaseTest/ActionsEaseTest.cpp +++ b/tests/tests/ActionsEaseTest/ActionsEaseTest.cpp @@ -617,8 +617,10 @@ EaseSpriteDemo::~EaseSpriteDemo(void) void EaseSpriteDemo::positionForTwo() { - m_grossini->setPosition( CCPointMake( 60, 120 ) ); - m_tamara->setPosition( CCPointMake( 60, 220) ); + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + m_grossini->setPosition(CCPointMake(60, s.height*1/5)); + m_tamara->setPosition(CCPointMake( 60, s.height*4/5)); m_kathia->setIsVisible(false); } @@ -643,13 +645,13 @@ void EaseSpriteDemo::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - m_grossini->setPosition( CCPointMake(60, 50) ); - m_kathia->setPosition( CCPointMake(60, 150) ); - m_tamara->setPosition( CCPointMake(60, 250) ); + m_grossini->setPosition(CCPointMake(60, s.height*1/5)); + m_kathia->setPosition(CCPointMake(60, s.height*2.5f/5)); + m_tamara->setPosition(CCPointMake(60, s.height*4/5)); CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32); addChild(label); - label->setPosition( CCPointMake(s.width/2, s.height-50) ); + label->setPosition(CCPointMake(s.width/2, s.height-50)); CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(EaseSpriteDemo::backCallback) ); CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(EaseSpriteDemo::restartCallback) ); @@ -657,10 +659,10 @@ void EaseSpriteDemo::onEnter() CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); - menu->setPosition( CCPointZero ); - item1->setPosition( CCPointMake( s.width/2 - 100,30) ); - item2->setPosition( CCPointMake( s.width/2, 30) ); - item3->setPosition( CCPointMake( s.width/2 + 100,30) ); + menu->setPosition(CCPointZero); + item1->setPosition(CCPointMake(s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2)); + item2->setPosition(CCPointMake( s.width/2, item2->getContentSize().height/2)); + item3->setPosition(CCPointMake( s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2)); addChild(menu, 1); } diff --git a/tests/tests/ActionsProgressTest/ActionsProgressTest.cpp b/tests/tests/ActionsProgressTest/ActionsProgressTest.cpp index 07b704c5b7..aecd192f42 100644 --- a/tests/tests/ActionsProgressTest/ActionsProgressTest.cpp +++ b/tests/tests/ActionsProgressTest/ActionsProgressTest.cpp @@ -111,10 +111,10 @@ void SpriteDemo::onEnter() CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(SpriteDemo::nextCallback) ); CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); - menu->setPosition( CCPointZero ); - item1->setPosition( CCPointMake( s.width/2 - 100,30) ); - item2->setPosition( CCPointMake( s.width/2, 30) ); - item3->setPosition( CCPointMake( s.width/2 + 100,30) ); + menu->setPosition(CCPointZero); + item1->setPosition(CCPointMake( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2)); + item2->setPosition(CCPointMake( s.width/2, item2->getContentSize().height/2)); + item3->setPosition(CCPointMake( s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2)); addChild(menu, 1); CCLayerColor *background = CCLayerColor::layerWithColor(ccc4(255,0,0,255)); diff --git a/tests/tests/ActionsTest/ActionsTest.cpp b/tests/tests/ActionsTest/ActionsTest.cpp index 217d432c97..1719327645 100644 --- a/tests/tests/ActionsTest/ActionsTest.cpp +++ b/tests/tests/ActionsTest/ActionsTest.cpp @@ -1,5 +1,6 @@ #include "ActionsTest.h" #include "../testResource.h" +#include "CCActionCatmullRom.h" CCLayer* NextAction(); CCLayer* BackAction(); @@ -13,72 +14,79 @@ CCLayer* CreateLayer(int nIndex) switch (nIndex) { - case ACTION_MANUAL_LAYER: - pLayer = new ActionManual(); break; - case ACTION_MOVE_LAYER: - pLayer = new ActionMove(); break; - case ACTION_SCALE_LAYER: - pLayer = new ActionScale(); break; - case ACTION_ROTATE_LAYER: - pLayer = new ActionRotate(); break; - case ACTION_SKEW_LAYER: - pLayer = new ActionSkew(); break; - case ACTION_SKEWROTATE_LAYER: - pLayer = new ActionSkewRotateScale(); break; - case ACTION_JUMP_LAYER: - pLayer = new ActionJump(); break; - case ACTION_BEZIER_LAYER: - pLayer = new ActionBezier(); break; - case ACTION_BLINK_LAYER: - pLayer = new ActionBlink(); break; - case ACTION_FADE_LAYER: - pLayer = new ActionFade(); break; - case ACTION_TINT_LAYER: - pLayer = new ActionTint(); break; - case ACTION_ANIMATE_LAYER: - pLayer = new ActionAnimate(); break; - case ACTION_SEQUENCE_LAYER: - pLayer = new ActionSequence(); break; - case ACTION_SEQUENCE2_LAYER: - pLayer = new ActionSequence2(); break; - case ACTION_SPAWN_LAYER: - pLayer = new ActionSpawn(); break; - case ACTION_REVERSE: - pLayer = new ActionReverse(); break; - case ACTION_DELAYTIME_LAYER: - pLayer = new ActionDelayTime(); break; - case ACTION_REPEAT_LAYER: - pLayer = new ActionRepeat(); break; - case ACTION_REPEATEFOREVER_LAYER: - pLayer = new ActionRepeatForever(); break; - case ACTION_ROTATETOREPEATE_LAYER: - pLayer = new ActionRotateToRepeat(); break; - case ACTION_ROTATEJERK_LAYER: - pLayer = new ActionRotateJerk(); break; - case ACTION_CALLFUNC_LAYER: - pLayer = new ActionCallFunc(); break; - case ACTION_CALLFUNCND_LAYER: - pLayer = new ActionCallFuncND(); break; - case ACTION_REVERSESEQUENCE_LAYER: - pLayer = new ActionReverseSequence(); break; - case ACTION_REVERSESEQUENCE2_LAYER: - pLayer = new ActionReverseSequence2(); break; - case ACTION_ORBIT_LAYER: - pLayer = new ActionOrbit(); break; - case ACTION_FLLOW_LAYER: - pLayer = new ActionFollow(); break; - case ACTION_TARGETED_LAYER: - pLayer = new ActionTargeted(); break; - case ACTION_ISSUE1305_LAYER: - pLayer = new Issue1305(); break; - case ACTION_ISSUE1305_2_LAYER: - pLayer = new Issue1305_2(); break; - case ACTION_ISSUE1288_LAYER: - pLayer = new Issue1288(); break; - case ACTION_ISSUE1288_2_LAYER: - pLayer = new Issue1288_2(); break; - case ACTION_ISSUE1327_LAYER: - pLayer = new Issue1327(); break; + case ACTION_MANUAL_LAYER: + pLayer = new ActionManual(); break; + case ACTION_MOVE_LAYER: + pLayer = new ActionMove(); break; + case ACTION_SCALE_LAYER: + pLayer = new ActionScale(); break; + case ACTION_ROTATE_LAYER: + pLayer = new ActionRotate(); break; + case ACTION_SKEW_LAYER: + pLayer = new ActionSkew(); break; + case ACTION_SKEWROTATE_LAYER: + pLayer = new ActionSkewRotateScale(); break; + case ACTION_JUMP_LAYER: + pLayer = new ActionJump(); break; + case ACTION_BEZIER_LAYER: + pLayer = new ActionBezier(); break; + case ACTION_BLINK_LAYER: + pLayer = new ActionBlink(); break; + case ACTION_FADE_LAYER: + pLayer = new ActionFade(); break; + case ACTION_TINT_LAYER: + pLayer = new ActionTint(); break; + case ACTION_ANIMATE_LAYER: + pLayer = new ActionAnimate(); break; + case ACTION_SEQUENCE_LAYER: + pLayer = new ActionSequence(); break; + case ACTION_SEQUENCE2_LAYER: + pLayer = new ActionSequence2(); break; + case ACTION_SPAWN_LAYER: + pLayer = new ActionSpawn(); break; + case ACTION_REVERSE: + pLayer = new ActionReverse(); break; + case ACTION_DELAYTIME_LAYER: + pLayer = new ActionDelayTime(); break; + case ACTION_REPEAT_LAYER: + pLayer = new ActionRepeat(); break; + case ACTION_REPEATEFOREVER_LAYER: + pLayer = new ActionRepeatForever(); break; + case ACTION_ROTATETOREPEATE_LAYER: + pLayer = new ActionRotateToRepeat(); break; + case ACTION_ROTATEJERK_LAYER: + pLayer = new ActionRotateJerk(); break; + case ACTION_CALLFUNC_LAYER: + pLayer = new ActionCallFunc(); break; + case ACTION_CALLFUNCND_LAYER: + pLayer = new ActionCallFuncND(); break; + case ACTION_REVERSESEQUENCE_LAYER: + pLayer = new ActionReverseSequence(); break; + case ACTION_REVERSESEQUENCE2_LAYER: + pLayer = new ActionReverseSequence2(); break; + case ACTION_ORBIT_LAYER: + pLayer = new ActionOrbit(); break; + case ACTION_FLLOW_LAYER: + pLayer = new ActionFollow(); break; + case ACTION_TARGETED_LAYER: + pLayer = new ActionTargeted(); break; + case ACTION_ISSUE1305_LAYER: + pLayer = new Issue1305(); break; + case ACTION_ISSUE1305_2_LAYER: + pLayer = new Issue1305_2(); break; + case ACTION_ISSUE1288_LAYER: + pLayer = new Issue1288(); break; + case ACTION_ISSUE1288_2_LAYER: + pLayer = new Issue1288_2(); break; + case ACTION_ISSUE1327_LAYER: + pLayer = new Issue1327(); break; + case ACTION_CARDINALSPLINE_LAYER: + pLayer = new ActionCardinalSpline(); break; + case ACTION_CATMULLROM_LAYER: + pLayer = new ActionCatmullRom(); break; + case PAUSERESUMEACTIONS_LAYER: + pLayer = new PauseResumeActions(); break; + default: break; } @@ -157,9 +165,9 @@ void ActionsDemo::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - m_grossini->setPosition( CCPointMake(s.width/2, s.height/3)); - m_tamara->setPosition( CCPointMake(s.width/2, 2*s.height/3)); - m_kathia->setPosition( CCPointMake(s.width/2, s.height/2)); + m_grossini->setPosition(CCPointMake(s.width/2, s.height/3)); + m_tamara->setPosition(CCPointMake(s.width/2, 2*s.height/3)); + m_kathia->setPosition(CCPointMake(s.width/2, s.height/2)); // add title and subtitle std::string str = title(); @@ -183,10 +191,10 @@ void ActionsDemo::onEnter() CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); - menu->setPosition( CCPointZero ); - item1->setPosition( CCPointMake( s.width/2 - 100,30) ); - item2->setPosition( CCPointMake( s.width/2, 30) ); - item3->setPosition( CCPointMake( s.width/2 + 100,30) ); + menu->setPosition(CCPointZero); + item1->setPosition(CCPointMake(s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2)); + item2->setPosition(CCPointMake(s.width/2, item2->getContentSize().height/2)); + item3->setPosition(CCPointMake(s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2)); addChild(menu, 1); } @@ -1441,3 +1449,219 @@ void Issue1327::logSprRotation(CCNode* pSender) CCLog("%f", ((CCSprite*)pSender)->getRotation()); } +/** ActionCatmullRom + */ +void ActionCatmullRom::onEnter() +{ + ActionsDemo::onEnter(); + + this->centerSprites(2); + + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + // + // sprite 1 (By) + // + // startPosition can be any coordinate, but since the movement + // is relative to the Catmull Rom curve, it is better to start with (0,0). + // + + m_tamara->setPosition(ccp(50, 50)); + + CCPointArray *array = CCPointArray::arrayWithCapacity(20); + + array->addControlPoint(ccp(0, 0)); + array->addControlPoint(ccp(80, 80)); + array->addControlPoint(ccp(s.width - 80, 80)); + array->addControlPoint(ccp(s.width - 80, s.height - 80)); + array->addControlPoint(ccp(80, s.height - 80)); + array->addControlPoint(ccp(80, 80)); + array->addControlPoint(ccp(s.width / 2, s.height / 2)); + + CCCatmullRomBy *action = CCCatmullRomBy::actionWithDuration(3, array); + CCFiniteTimeAction *reverse = action->reverse(); + + CCFiniteTimeAction *seq = CCSequence::actions(action, reverse, NULL); + + m_tamara->runAction(seq); + + + // + // sprite 2 (To) + // + // The startPosition is not important here, because it uses a "To" action. + // The initial position will be the 1st point of the Catmull Rom path + // + + CCPointArray *array2 = CCPointArray::arrayWithCapacity(20); + + array2->addControlPoint(ccp(s.width / 2, 30)); + array2->addControlPoint(ccp(s.width -80, 30)); + array2->addControlPoint(ccp(s.width - 80, s.height - 80)); + array2->addControlPoint(ccp(s.width / 2, s.height - 80)); + array2->addControlPoint(ccp(s.width / 2, 30)); + + CCCatmullRomTo *action2 = CCCatmullRomTo::actionWithDuration(3, array2); + CCFiniteTimeAction *reverse2 = action2->reverse(); + + CCFiniteTimeAction *seq2 = CCSequence::actions(action2, reverse2, NULL); + + m_kathia->runAction(seq2); + + m_pArray1 = array; + m_pArray1->retain(); + m_pArray2 = array2; + m_pArray2->retain(); +} + +ActionCatmullRom::~ActionCatmullRom() +{ + m_pArray1->release(); + m_pArray2->release(); +} + +void ActionCatmullRom::draw() +{ + ActionsDemo::draw(); + + // move to 50,50 since the "by" path will start at 50,50 + kmGLPushMatrix(); + kmGLTranslatef(50, 50, 0); + ccDrawCatmullRom(m_pArray1, 50); + kmGLPopMatrix(); + + ccDrawCatmullRom(m_pArray2,50); +} + +string ActionCatmullRom::title() +{ + return "CatmullRomBy / CatmullRomTo"; +} + +string ActionCatmullRom::subtitle() +{ + return "Catmull Rom spline paths. Testing reverse too"; +} + +/** ActionCardinalSpline + */ +void ActionCardinalSpline::onEnter() +{ + ActionsDemo::onEnter(); + + this->centerSprites(2); + + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCPointArray *array = CCPointArray::arrayWithCapacity(20); + + array->addControlPoint(ccp(0, 0)); + array->addControlPoint(ccp(s.width/2-30, 0)); + array->addControlPoint(ccp(s.width/2-30, s.height-80)); + array->addControlPoint(ccp(0, s.height-80)); + array->addControlPoint(ccp(0, 0)); + + // + // sprite 1 (By) + // + // Spline with no tension (tension==0) + // + + CCCardinalSplineBy *action = CCCardinalSplineBy::actionWithDuration(3, array, 0); + CCActionInterval *reverse = action->reverse(); + + CCFiniteTimeAction *seq = CCSequence::actions(action, reverse, NULL); + + m_tamara->setPosition(ccp(50, 50)); + m_tamara->runAction(seq); + + // + // sprite 2 (By) + // + // Spline with high tension (tension==1) + // + + CCCardinalSplineBy *action2 = CCCardinalSplineBy::actionWithDuration(3, array, 1); + CCActionInterval *reverse2 = action2->reverse(); + + CCFiniteTimeAction *seq2 = CCSequence::actions(action2, reverse2, NULL); + + m_kathia->setPosition(ccp(s.width/2, 50)); + m_kathia->runAction(seq2); + + m_pArray = array; + array->retain(); +} + +ActionCardinalSpline::~ActionCardinalSpline() +{ + m_pArray->release(); +} + +void ActionCardinalSpline::draw() +{ + ActionsDemo::draw(); + + // move to 50,50 since the "by" path will start at 50,50 + kmGLPushMatrix(); + kmGLTranslatef(50, 50, 0); + ccDrawCardinalSpline(m_pArray, 0, 100); + kmGLPopMatrix(); + + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + kmGLPushMatrix(); + kmGLTranslatef(s.width/2, 50, 0); + ccDrawCardinalSpline(m_pArray, 1, 100); + kmGLPopMatrix(); +} + +string ActionCardinalSpline::title() +{ + return "CardinalSplineBy / CardinalSplineAt"; +} + +string ActionCardinalSpline::subtitle() +{ + return "Cardinal Spline paths. Testing different tensions for one array"; +} + +/** PauseResumeActions + */ +void PauseResumeActions::onEnter() +{ + ActionsDemo::onEnter(); + + this->centerSprites(2); + + m_tamara->runAction(CCRepeatForever::actionWithAction(CCRotateBy::actionWithDuration(3, 360))); + m_grossini->runAction(CCRepeatForever::actionWithAction(CCRotateBy::actionWithDuration(3, -360))); + m_kathia->runAction(CCRepeatForever::actionWithAction(CCRotateBy::actionWithDuration(3, 360))); + + this->schedule(schedule_selector(PauseResumeActions::pause), 3, false, 0); + this->schedule(schedule_selector(PauseResumeActions::resume), 5, false, 0); +} + +string PauseResumeActions::title() +{ + return "PauseResumeActions"; +} + +string PauseResumeActions::subtitle() +{ + return "All actions pause at 3s and resume at 5s"; +} + +void PauseResumeActions::pause(float dt) +{ + CCLog("Pausing"); + CCDirector *director = CCDirector::sharedDirector(); + this->m_pPausedTargets = director->getActionManager()->pauseAlllRunningActions(); +} + +void PauseResumeActions::resume(float dt) +{ + CCLog("Resuming"); + CCDirector *director = CCDirector::sharedDirector(); + director->getActionManager()->resumeTargets(this->m_pPausedTargets); +} \ No newline at end of file diff --git a/tests/tests/ActionsTest/ActionsTest.h b/tests/tests/ActionsTest/ActionsTest.h index 46da2c604f..d93a9b88cb 100644 --- a/tests/tests/ActionsTest/ActionsTest.h +++ b/tests/tests/ActionsTest/ActionsTest.h @@ -16,6 +16,8 @@ enum ACTION_SKEW_LAYER, ACTION_SKEWROTATE_LAYER, ACTION_JUMP_LAYER, + ACTION_CARDINALSPLINE_LAYER, + ACTION_CATMULLROM_LAYER, ACTION_BEZIER_LAYER, ACTION_BLINK_LAYER, ACTION_FADE_LAYER, @@ -37,6 +39,7 @@ enum ACTION_ORBIT_LAYER, ACTION_FLLOW_LAYER, ACTION_TARGETED_LAYER, + PAUSERESUMEACTIONS_LAYER, ACTION_ISSUE1305_LAYER, ACTION_ISSUE1305_2_LAYER, ACTION_ISSUE1288_LAYER, @@ -334,4 +337,44 @@ public: void logSprRotation(CCNode* pSender); }; +class ActionCatmullRom : public ActionsDemo +{ +public: + ~ActionCatmullRom(); + + virtual void onEnter(); + virtual void draw(); + virtual std::string subtitle(); + virtual std::string title(); +private: + CCPointArray *m_pArray1; + CCPointArray *m_pArray2; +}; + +class ActionCardinalSpline : public ActionsDemo +{ +public: + ~ActionCardinalSpline(); + + virtual void onEnter(); + virtual void draw(); + virtual std::string subtitle(); + virtual std::string title(); +private: + CCPointArray *m_pArray; +}; + +class PauseResumeActions : public ActionsDemo +{ +public: + virtual void onEnter(); + virtual std::string subtitle(); + virtual std::string title(); + + void pause(float dt); + void resume(float dt); +private: + CCSet *m_pPausedTargets; +}; + #endif From 62f87c18a2d1d7f2e4cbbd01a9bc2f3e157426ff Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 11 Jun 2012 20:02:40 +0800 Subject: [PATCH 117/257] issue #1310: Exported CCCatmullRomTo class and ccCardinalSplineAt function. --- cocos2dx/actions/CCActionCatmullRom.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2dx/actions/CCActionCatmullRom.h b/cocos2dx/actions/CCActionCatmullRom.h index 55636cea8b..fbb793965b 100644 --- a/cocos2dx/actions/CCActionCatmullRom.h +++ b/cocos2dx/actions/CCActionCatmullRom.h @@ -156,7 +156,7 @@ protected: A Catmull Rom is a Cardinal Spline with a tension of 0.5. http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline */ -class CCCatmullRomTo : public CCCardinalSplineTo +class CC_DLL CCCatmullRomTo : public CCCardinalSplineTo { public: /** creates an action with a Cardinal Spline array of points and tension */ @@ -181,7 +181,7 @@ public: }; /** Returns the Cardinal Spline position for a given set of control points, tension and time */ -extern CCPoint ccCardinalSplineAt(CCPoint &p0, CCPoint &p1, CCPoint &p2, CCPoint &p3, float tension, float t); +extern CC_DLL CCPoint ccCardinalSplineAt(CCPoint &p0, CCPoint &p1, CCPoint &p2, CCPoint &p3, float tension, float t); NS_CC_END; From be362bef9bd2e075cbe6500cb2b8146155fdeb90 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 11 Jun 2012 21:58:04 +0800 Subject: [PATCH 118/257] issue #1310: Some typo fixes. Updated CCTexture2D.h/.cpp. --- cocos2dx/actions/CCActionManager.cpp | 2 +- cocos2dx/actions/CCActionManager.h | 2 +- cocos2dx/cocoa/CCObject.h | 5 +- cocos2dx/cocoa/CCSet.h | 8 +- cocos2dx/textures/CCTexture2D.cpp | 137 ++++++++++++++++++--------- cocos2dx/textures/CCTexture2D.h | 13 ++- 6 files changed, 107 insertions(+), 60 deletions(-) diff --git a/cocos2dx/actions/CCActionManager.cpp b/cocos2dx/actions/CCActionManager.cpp index f9d0f1b8ff..f4a2e153d7 100644 --- a/cocos2dx/actions/CCActionManager.cpp +++ b/cocos2dx/actions/CCActionManager.cpp @@ -140,7 +140,7 @@ void CCActionManager::resumeTarget(CCObject *pTarget) } } -CCSet* CCActionManager::pauseAlllRunningActions() +CCSet* CCActionManager::pauseAllRunningActions() { CCSet *idsWithActions = new CCSet(); idsWithActions->autorelease(); diff --git a/cocos2dx/actions/CCActionManager.h b/cocos2dx/actions/CCActionManager.h index 1dbd038632..60cddaaaf1 100644 --- a/cocos2dx/actions/CCActionManager.h +++ b/cocos2dx/actions/CCActionManager.h @@ -101,7 +101,7 @@ public: /** Pauses all running actions, returning a list of targets whose actions were paused. */ - CCSet* pauseAlllRunningActions(); + CCSet* pauseAllRunningActions(); /** Resume a set of targets (convenience function to reverse a pauseAllRunningActions call) */ diff --git a/cocos2dx/cocoa/CCObject.h b/cocos2dx/cocoa/CCObject.h index 62fe578710..ef3c2d45e9 100644 --- a/cocos2dx/cocoa/CCObject.h +++ b/cocos2dx/cocoa/CCObject.h @@ -25,13 +25,12 @@ THE SOFTWARE. #ifndef __CCOBJECT_H__ #define __CCOBJECT_H__ -#include "CCCommon.h" +#include "CCPlatformMacros.h" NS_CC_BEGIN class CCZone; class CCObject; -class CCString; class CCNode; class CCEvent; @@ -64,7 +63,7 @@ public: bool isSingleRefrence(void); unsigned int retainCount(void); virtual bool isEqual(const CCObject* pObject); - + virtual void update(float dt) {CC_UNUSED_PARAM(dt);}; friend class CCAutoreleasePool; diff --git a/cocos2dx/cocoa/CCSet.h b/cocos2dx/cocoa/CCSet.h index 1fad47f6ed..f6684a2391 100644 --- a/cocos2dx/cocoa/CCSet.h +++ b/cocos2dx/cocoa/CCSet.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org http://www.cocos2d-x.org @@ -22,8 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#ifndef __NS_SET_H__ -#define __NS_SET_H__ +#ifndef __CC_SET_H__ +#define __CC_SET_H__ #include #include "CCObject.h" @@ -82,5 +82,5 @@ private: NS_CC_END -#endif // __NS_SET_H__ +#endif // __CC_SET_H__ diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index 38c90cddde..d16a409a46 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -667,6 +667,50 @@ void CCTexture2D::setAntiAliasTexParameters() glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); } +const char* CCTexture2D::stringForFormat() +{ + switch (m_ePixelFormat) + { + case kCCTexture2DPixelFormat_RGBA8888: + return "RGBA8888"; + + case kCCTexture2DPixelFormat_RGB888: + return "RGB888"; + + case kCCTexture2DPixelFormat_RGB565: + return "RGB565"; + + case kCCTexture2DPixelFormat_RGBA4444: + return "RGBA4444"; + + case kCCTexture2DPixelFormat_RGB5A1: + return "RGB5A1"; + + case kCCTexture2DPixelFormat_AI88: + return "AI88"; + + case kCCTexture2DPixelFormat_A8: + return "A8"; + + case kCCTexture2DPixelFormat_I8: + return "I8"; + + case kCCTexture2DPixelFormat_PVRTC4: + return "PVRTC4"; + + case kCCTexture2DPixelFormat_PVRTC2: + return "PVRTC2"; + + default: + CCAssert(false , "unrecognised pixel format"); + CCLOG("stringForFormat: %ld, cannot give useful result", (long)m_ePixelFormat); + break; + } + + return NULL; +} + + // // Texture options for images that contains alpha // @@ -683,50 +727,55 @@ CCTexture2DPixelFormat CCTexture2D::defaultAlphaPixelFormat() return g_defaultAlphaPixelFormat; } -unsigned int CCTexture2D::bitsPerPixelForFormat() -{ - unsigned int ret = 0; +unsigned int CCTexture2D::bitsPerPixelForFormat(CCTexture2DPixelFormat format) +{ + unsigned int ret=0; + + switch (format) { + case kCCTexture2DPixelFormat_RGBA8888: + ret = 32; + break; + case kCCTexture2DPixelFormat_RGB888: + // It is 32 and not 24, since its internal representation uses 32 bits. + ret = 32; + break; + case kCCTexture2DPixelFormat_RGB565: + ret = 16; + break; + case kCCTexture2DPixelFormat_RGBA4444: + ret = 16; + break; + case kCCTexture2DPixelFormat_RGB5A1: + ret = 16; + break; + case kCCTexture2DPixelFormat_AI88: + ret = 16; + break; + case kCCTexture2DPixelFormat_A8: + ret = 8; + break; + case kCCTexture2DPixelFormat_I8: + ret = 8; + break; + case kCCTexture2DPixelFormat_PVRTC4: + ret = 4; + break; + case kCCTexture2DPixelFormat_PVRTC2: + ret = 2; + break; + default: + ret = -1; + CCAssert(false , "unrecognised pixel format"); + CCLOG("bitsPerPixelForFormat: %ld, cannot give useful result", (long)format); + break; + } + return ret; +} + +unsigned int CCTexture2D::bitsPerPixelForFormat() +{ + return this->bitsPerPixelForFormat(m_ePixelFormat); +} - switch (m_ePixelFormat) - { - case kCCTexture2DPixelFormat_RGBA8888: - ret = 32; - break; - case kCCTexture2DPixelFormat_RGB565: - ret = 16; - break; - case kCCTexture2DPixelFormat_A8: - ret = 8; - break; - case kCCTexture2DPixelFormat_RGBA4444: - ret = 16; - break; - case kCCTexture2DPixelFormat_RGB5A1: - ret = 16; - break; - case kCCTexture2DPixelFormat_PVRTC4: - ret = 4; - break; - case kCCTexture2DPixelFormat_PVRTC2: - ret = 2; - break; - case kCCTexture2DPixelFormat_I8: - ret = 8; - break; - case kCCTexture2DPixelFormat_AI88: - ret = 16; - break; - case kCCTexture2DPixelFormat_RGB888: - // It is 32 and not 24, since its internal representation uses 32 bits. - ret = 32; - break; - default: - ret = -1; - CCAssert(false, "illegal pixel format"); - CCLOG("bitsPerPixelForFormat: %d, cannot give useful result", m_ePixelFormat); - break; - } - return ret; -} NS_CC_END diff --git a/cocos2dx/textures/CCTexture2D.h b/cocos2dx/textures/CCTexture2D.h index 1e5aea7c62..9a8a1414c4 100644 --- a/cocos2dx/textures/CCTexture2D.h +++ b/cocos2dx/textures/CCTexture2D.h @@ -190,16 +190,15 @@ public: */ void generateMipmap(); + /** returns the pixel format. + @since v2.0 + */ + const char* stringForFormat(); + /** returns the bits-per-pixel of the in-memory OpenGL texture @since v1.0 */ - unsigned int bitsPerPixelForFormat(); - - /** returns the pixel format in a NSString. - @since v2.0 - */ - CCString* stringForFormat(); - + unsigned int bitsPerPixelForFormat(); /** Helper functions that returns bits per pixels for a given format. @since v2.0 From 43787314183f0fac08660f3631bb517ca633ab9d Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Mon, 11 Jun 2012 10:43:07 -0700 Subject: [PATCH 119/257] Merge with gles20. --- AUTHORS | 4 + Box2D/proj.win32/Box2D.win32.vcproj | 4 +- Box2D/proj.win32/Box2D.win32.vcxproj | 4 +- CocosDenshion/win32/MciPlayer.cpp | 6 +- HelloLua/Classes/AppDelegate.cpp | 2 - .../src/org/cocos2dx/lib/Cocos2dxSound.java | 169 +- .../project.pbxproj.REMOVED.git-id | 2 +- HelloLua/proj.win32/HelloLua.win32.vcproj | 8 +- HelloLua/proj.win32/HelloLua.win32.vcxproj | 4 +- HelloWorld/Classes/AppDelegate.cpp | 2 - .../src/org/cocos2dx/lib/Cocos2dxSound.java | 169 +- .../project.pbxproj.REMOVED.git-id | 2 +- HelloWorld/proj.win32/HelloWorld.win32.vcproj | 8 +- .../proj.win32/HelloWorld.win32.vcxproj | 4 +- chipmunk/proj.win32/chipmunk.win32.vcproj | 4 +- chipmunk/proj.win32/chipmunk.win32.vcxproj | 4 +- cocos2d-win32.vc2008.sln | 6 +- cocos2dx/CCConfiguration.cpp | 6 +- cocos2dx/CCConfiguration.h | 11 +- cocos2dx/CCDirector.cpp | 40 +- cocos2dx/CCDirector.h | 8 +- cocos2dx/CCDrawingPrimitives.cpp | 75 +- cocos2dx/CCDrawingPrimitives.h | 30 +- cocos2dx/CCScheduler.cpp | 137 +- cocos2dx/CCScheduler.h | 73 +- cocos2dx/actions/CCAction.cpp | 8 +- cocos2dx/actions/CCAction.h | 19 +- cocos2dx/actions/CCActionCamera.cpp | 2 +- cocos2dx/actions/CCActionCamera.h | 2 +- cocos2dx/actions/CCActionCatmullRom.cpp | 415 +++++ cocos2dx/actions/CCActionCatmullRom.h | 188 ++ cocos2dx/actions/CCActionEase.cpp | 60 +- cocos2dx/actions/CCActionEase.h | 40 +- cocos2dx/actions/CCActionGrid.cpp | 22 +- cocos2dx/actions/CCActionGrid.h | 26 +- cocos2dx/actions/CCActionGrid3D.cpp | 54 +- cocos2dx/actions/CCActionGrid3D.h | 54 +- cocos2dx/actions/CCActionInstant.cpp | 18 +- cocos2dx/actions/CCActionInstant.h | 18 +- cocos2dx/actions/CCActionInterval.cpp | 146 +- cocos2dx/actions/CCActionInterval.h | 132 +- cocos2dx/actions/CCActionManager.cpp | 29 +- cocos2dx/actions/CCActionManager.h | 12 +- cocos2dx/actions/CCActionPageTurn3D.cpp | 4 +- cocos2dx/actions/CCActionPageTurn3D.h | 4 +- cocos2dx/actions/CCActionProgressTimer.cpp | 12 +- cocos2dx/actions/CCActionProgressTimer.h | 12 +- cocos2dx/actions/CCActionTiledGrid.cpp | 68 +- cocos2dx/actions/CCActionTiledGrid.h | 68 +- cocos2dx/actions/CCActionTween.cpp | 6 +- cocos2dx/actions/CCActionTween.h | 6 +- cocos2dx/base_nodes/CCNode.cpp | 40 +- cocos2dx/base_nodes/CCNode.h | 48 +- cocos2dx/cocoa/CCArray.cpp | 34 +- cocos2dx/cocoa/CCArray.h | 45 +- cocos2dx/cocoa/CCData.cpp | 5 +- cocos2dx/cocoa/CCGeometry.h | 7 +- cocos2dx/cocoa/CCObject.h | 9 +- cocos2dx/cocoa/CCString.cpp | 2 +- cocos2dx/cocos2d.cpp | 2 +- cocos2dx/extensions/CCBIReader/CCBReader.cpp | 4 +- .../extensions/CCBIReader/CCNodeLoader.cpp | 2 +- .../CCBIReader/CCNodeLoaderLibrary.cpp | 4 + .../CCBIReader/CCNodeLoaderLibrary.h | 2 + cocos2dx/extensions/CCBReader/CCBReader.h | 2 + .../extensions/CCBReader/CCBReader_v1.cpp | 3 + .../extensions/CCBReader/CCBReader_v2.cpp | 5 +- .../CCControlExtension/CCControlButton.cpp | 64 +- .../CCControlExtension/CCControlButton.h | 8 +- .../CCControlExtension/CCControlSlider.cpp | 2 +- .../CCControlExtension/CCControlSwitch.cpp | 2 +- .../CCControlExtension/CCMenuPassive.cpp | 2 +- .../CCTextureWatcher/CCTextureWatcher.cpp | 6 +- cocos2dx/include/ccTypes.h | 37 +- cocos2dx/label_nodes/CCLabelAtlas.cpp | 45 +- cocos2dx/label_nodes/CCLabelAtlas.h | 16 +- cocos2dx/label_nodes/CCLabelBMFont.cpp | 123 +- cocos2dx/label_nodes/CCLabelBMFont.h | 24 +- cocos2dx/label_nodes/CCLabelTTF.cpp | 4 +- .../CCLayer.cpp | 4 +- .../layers_scenes_transitions_nodes/CCLayer.h | 2 +- .../CCScene.cpp | 4 +- .../layers_scenes_transitions_nodes/CCScene.h | 2 +- .../CCTransition.cpp | 35 +- .../CCTransition.h | 35 +- .../CCTransitionPageTurn.cpp | 4 +- .../CCTransitionPageTurn.h | 4 +- cocos2dx/menu_nodes/CCMenu.cpp | 4 +- cocos2dx/menu_nodes/CCMenu.h | 2 +- cocos2dx/menu_nodes/CCMenuItem.cpp | 141 +- cocos2dx/menu_nodes/CCMenuItem.h | 1 + cocos2dx/misc_nodes/CCMotionStreak.cpp | 40 +- cocos2dx/misc_nodes/CCMotionStreak.h | 5 +- cocos2dx/misc_nodes/CCRenderTexture.cpp | 128 +- cocos2dx/misc_nodes/CCRenderTexture.h | 34 +- .../particle_nodes/CCParticleBatchNode.cpp | 2 +- cocos2dx/particle_nodes/CCParticleSystem.cpp | 75 +- cocos2dx/particle_nodes/CCParticleSystem.h | 12 +- .../particle_nodes/CCParticleSystemQuad.cpp | 10 +- .../particle_nodes/CCParticleSystemQuad.h | 6 +- cocos2dx/platform/CCEGLViewProtocol.cpp | 22 +- cocos2dx/platform/CCFileUtils.h | 66 +- cocos2dx/platform/CCImageCommon_cpp.h | 14 +- cocos2dx/platform/CCPlatformMacros.h | 19 +- cocos2dx/platform/CCSAXParser.cpp | 5 +- cocos2dx/platform/CCThread.cpp | 5 + cocos2dx/platform/android/CCGL.h | 2 +- cocos2dx/platform/ios/CCFileUtils.mm | 13 +- cocos2dx/platform/ios/CCGL.h | 2 +- cocos2dx/platform/ios/CCImage.mm | 14 +- .../third_party/win32/OGLES/EGL/egl.h | 329 ---- .../third_party/win32/OGLES/EGL/eglext.h | 175 -- .../third_party/win32/OGLES/EGL/eglplatform.h | 124 -- .../win32/OGLES/GL/glew.h.REMOVED.git-id | 1 + .../third_party/win32/OGLES/GL/glxew.h | 1587 +++++++++++++++++ .../third_party/win32/OGLES/GL/wglew.h | 1363 ++++++++++++++ .../third_party/win32/OGLES/GLES2/gl2.h | 619 ------- .../third_party/win32/OGLES/GLES2/gl2ext.h | 971 ---------- .../third_party/win32/OGLES/GLES2/gl2extimg.h | 47 - .../win32/OGLES/GLES2/gl2platform.h | 28 - .../third_party/win32/OGLES/KHR/khrplatform.h | 302 ---- .../win32/libraries/glew32.dll.REMOVED.git-id | 1 + .../win32/libraries/glew32.lib.REMOVED.git-id | 1 + .../win32/libraries/libEGL.dll.REMOVED.git-id | 1 - .../libraries/libGLESv2.dll.REMOVED.git-id | 1 - cocos2dx/platform/win32/CCApplication.cpp | 16 +- cocos2dx/platform/win32/CCEGLView.cpp | 237 +-- cocos2dx/platform/win32/CCEGLView.h | 11 +- cocos2dx/platform/win32/CCFileUtils.cpp | 16 + cocos2dx/platform/win32/CCGL.h | 11 +- cocos2dx/platform/win32/CCImage.cpp | 92 +- cocos2dx/proj.win32/cocos2d-win32.vcproj | 20 +- cocos2dx/proj.win32/cocos2d-win32.vcxproj | 8 +- cocos2dx/script_support/CCScriptSupport.cpp | 6 +- cocos2dx/script_support/CCScriptSupport.h | 12 +- cocos2dx/shaders/CCGLProgram.cpp | 4 +- cocos2dx/shaders/CCGLProgram.h | 2 + cocos2dx/sprite_nodes/CCAnimationCache.cpp | 2 +- cocos2dx/sprite_nodes/CCSprite.cpp | 21 +- cocos2dx/sprite_nodes/CCSprite.h | 2 +- cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp | 2 +- cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp | 121 +- cocos2dx/sprite_nodes/CCSpriteFrameCache.h | 13 +- cocos2dx/support/CCUserDefault.cpp | 2 +- cocos2dx/support/CCVertex.cpp | 7 +- cocos2dx/support/CCVertex.h | 4 +- cocos2dx/support/data_support/ccCArray.cpp | 471 +++++ cocos2dx/support/data_support/ccCArray.h | 467 +---- cocos2dx/support/image_support/TGAlib.cpp | 8 +- cocos2dx/support/zip_support/ZipUtils.cpp | 4 +- cocos2dx/textures/CCTexture2D.cpp | 105 +- cocos2dx/textures/CCTexture2D.h | 33 +- cocos2dx/textures/CCTextureCache.cpp | 53 +- cocos2dx/textures/CCTextureCache.h | 8 +- cocos2dx/textures/CCTexturePVR.cpp | 6 +- cocos2dx/textures/CCTexturePVR.h | 2 +- .../tileMap_parallax_nodes/CCTMXLayer.cpp | 67 +- cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h | 2 +- .../tileMap_parallax_nodes/CCTMXTiledMap.cpp | 2 +- .../tileMap_parallax_nodes/CCTMXXMLParser.cpp | 15 +- .../tileMap_parallax_nodes/CCTileMapAtlas.cpp | 4 +- .../touch_dispatcher/CCTouchDispatcher.cpp | 20 +- lua/proj.win32/liblua.vcproj | 4 +- lua/proj.win32/liblua.vcxproj | 4 +- template/android/build_native.sh | 15 + .../CCAppWiz.win32/Scripts/1033/default.js | 2 +- .../Classes/AppDelegate.cpp | 3 - .../Classes/AppDelegate.cpp | 3 - .../Classes/AppDelegate.cpp | 3 - .../Classes/AppDelegate.cpp | 2 - testjs/Classes/AppDelegate.cpp | 3 - .../src/org/cocos2dx/lib/Cocos2dxSound.java | 169 +- .../project.pbxproj.REMOVED.git-id | 2 +- testjs/proj.win32/testjs.win32.vcproj | 6 +- testjs/proj.win32/testjs.win32.vcxproj | 4 +- tests/Android.mk | 2 +- tests/AppDelegate.cpp | 4 - .../src/org/cocos2dx/lib/Cocos2dxSound.java | 169 +- .../project.pbxproj.REMOVED.git-id | 2 +- tests/proj.win32/test.win32.vcproj | 8 +- tests/proj.win32/test.win32.vcxproj | 8 +- .../ActionManagerTest/ActionManagerTest.cpp | 4 +- .../ActionManagerTest/ActionManagerTest.h | 4 +- .../tests/ActionsEaseTest/ActionsEaseTest.cpp | 4 +- tests/tests/ActionsEaseTest/ActionsEaseTest.h | 4 +- tests/tests/ActionsTest/ActionsTest.cpp | 2 +- tests/tests/ActionsTest/ActionsTest.h | 2 +- tests/tests/Box2DTest/Box2dTest.cpp | 4 +- tests/tests/Box2DTest/Box2dTest.h | 2 +- tests/tests/Box2DTestBed/Box2dView.cpp | 2 +- tests/tests/Box2DTestBed/Box2dView.h | 2 +- tests/tests/BugsTest/Bug-1159.cpp | 4 +- tests/tests/BugsTest/Bug-624.cpp | 4 +- tests/tests/BugsTest/Bug-624.h | 4 +- tests/tests/BugsTest/Bug-914.cpp | 2 +- .../ChipmunkAccelTouchTest.cpp | 4 +- .../ChipmunkAccelTouchTest.h | 2 +- .../CocosDenshionTest/CocosDenshionTest.cpp | 12 +- tests/tests/EffectsTest/EffectsTest.cpp | 48 +- tests/tests/EffectsTest/EffectsTest.h | 2 +- tests/tests/FontTest/FontTest.cpp | 6 +- tests/tests/IntervalTest/IntervalTest.cpp | 10 +- tests/tests/IntervalTest/IntervalTest.h | 12 +- tests/tests/LabelTest/LabelTest.cpp | 32 +- tests/tests/LabelTest/LabelTest.h | 18 +- tests/tests/LayerTest/LayerTest.cpp | 8 +- tests/tests/LayerTest/LayerTest.h | 2 +- tests/tests/MenuTest/MenuTest.cpp | 2 +- tests/tests/MenuTest/MenuTest.h | 2 +- .../MotionStreakTest/MotionStreakTest.cpp | 2 +- .../tests/MotionStreakTest/MotionStreakTest.h | 2 +- tests/tests/NodeTest/NodeTest.cpp | 18 +- tests/tests/NodeTest/NodeTest.h | 16 +- tests/tests/ParticleTest/ParticleTest.cpp | 24 +- tests/tests/ParticleTest/ParticleTest.h | 20 +- .../PerformanceNodeChildrenTest.cpp | 10 +- .../PerformanceNodeChildrenTest.h | 14 +- .../PerformanceParticleTest.cpp | 2 +- .../PerformanceTest/PerformanceParticleTest.h | 2 +- .../PerformanceTouchesTest.cpp | 2 +- .../PerformanceTest/PerformanceTouchesTest.h | 4 +- .../RenderTextureTest/RenderTextureTest.cpp | 2 +- tests/tests/SceneTest/SceneTest.cpp | 6 +- tests/tests/SceneTest/SceneTest.h | 6 +- tests/tests/SchedulerTest/SchedulerTest.cpp | 62 +- tests/tests/SchedulerTest/SchedulerTest.h | 60 +- tests/tests/ShaderTest/ShaderTest.cpp | 8 +- tests/tests/ShaderTest/ShaderTest.h | 6 +- .../SpriteTest/SpriteTest.cpp.REMOVED.git-id | 2 +- tests/tests/SpriteTest/SpriteTest.h | 28 +- tests/tests/TextInputTest/TextInputTest.cpp | 6 +- tests/tests/Texture2dTest/Texture2dTest.cpp | 6 +- tests/tests/Texture2dTest/Texture2dTest.h | 2 +- tests/tests/TileMapTest/TileMapTest.cpp | 22 +- tests/tests/TileMapTest/TileMapTest.h | 20 +- tests/tests/TouchesTest/Ball.cpp | 2 +- tests/tests/TouchesTest/Ball.h | 2 +- tests/tests/TouchesTest/TouchesTest.cpp | 2 +- tests/tests/TouchesTest/TouchesTest.h | 2 +- .../tests/TransitionsTest/TransitionsTest.cpp | 36 +- tests/tests/TransitionsTest/TransitionsTest.h | 4 +- tests/tests/ZwoptexTest/ZwoptexTest.cpp | 4 +- tests/tests/ZwoptexTest/ZwoptexTest.h | 4 +- .../template/Classes/AppDelegate.cpp | 83 +- .../template/Classes/AppDelegate.h | 8 - 245 files changed, 6873 insertions(+), 5135 deletions(-) create mode 100644 cocos2dx/actions/CCActionCatmullRom.cpp create mode 100644 cocos2dx/actions/CCActionCatmullRom.h delete mode 100644 cocos2dx/platform/third_party/win32/OGLES/EGL/egl.h delete mode 100644 cocos2dx/platform/third_party/win32/OGLES/EGL/eglext.h delete mode 100644 cocos2dx/platform/third_party/win32/OGLES/EGL/eglplatform.h create mode 100644 cocos2dx/platform/third_party/win32/OGLES/GL/glew.h.REMOVED.git-id create mode 100644 cocos2dx/platform/third_party/win32/OGLES/GL/glxew.h create mode 100644 cocos2dx/platform/third_party/win32/OGLES/GL/wglew.h delete mode 100644 cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2.h delete mode 100644 cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2ext.h delete mode 100644 cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2extimg.h delete mode 100644 cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2platform.h delete mode 100644 cocos2dx/platform/third_party/win32/OGLES/KHR/khrplatform.h create mode 100644 cocos2dx/platform/third_party/win32/libraries/glew32.dll.REMOVED.git-id create mode 100644 cocos2dx/platform/third_party/win32/libraries/glew32.lib.REMOVED.git-id delete mode 100644 cocos2dx/platform/third_party/win32/libraries/libEGL.dll.REMOVED.git-id delete mode 100644 cocos2dx/platform/third_party/win32/libraries/libGLESv2.dll.REMOVED.git-id create mode 100644 cocos2dx/support/data_support/ccCArray.cpp diff --git a/AUTHORS b/AUTHORS index 592b839874..8fa2248941 100644 --- a/AUTHORS +++ b/AUTHORS @@ -28,6 +28,7 @@ Developers: Nicolas Gramlich (nicolasgramlich, Zynga) fixed CCDirector to use CCLabelBMFont instead of CCLabelTTF + added CCBReader (CCBI format) Jianfeng Zhou (NetGragon Inc) contributes CCListView and CCTextureWatcher. @@ -86,6 +87,9 @@ Developers: jreitman fix the bug of asynchronous loading resources for iOS + Nat Weiss + Minor enhancements to the Cocos2D-X codebase and Android build scripts + Retired Core Developers: WenSheng Yang Author of windows port, CCTextField, diff --git a/Box2D/proj.win32/Box2D.win32.vcproj b/Box2D/proj.win32/Box2D.win32.vcproj index c5e04f29e8..dc04b76b82 100644 --- a/Box2D/proj.win32/Box2D.win32.vcproj +++ b/Box2D/proj.win32/Box2D.win32.vcproj @@ -21,7 +21,7 @@ OutputDirectory="$(SolutionDir)$(ConfigurationName).win32" IntermediateDirectory="$(ConfigurationName).win32" ConfigurationType="4" - CharacterSet="2" + CharacterSet="1" > StaticLibrary - MultiByte + Unicode StaticLibrary - MultiByte + Unicode diff --git a/CocosDenshion/win32/MciPlayer.cpp b/CocosDenshion/win32/MciPlayer.cpp index da403a616e..753edc1f8d 100644 --- a/CocosDenshion/win32/MciPlayer.cpp +++ b/CocosDenshion/win32/MciPlayer.cpp @@ -19,7 +19,7 @@ MciPlayer::MciPlayer() { if (! s_hInstance) { - s_hInstance = GetModuleHandle( NULL ); // Grab An Instance For Our Window + s_hInstance = GetModuleHandle( NULL ); // Grab An Instance For Our Window WNDCLASS wc; // Windows Class Structure @@ -35,8 +35,8 @@ MciPlayer::MciPlayer() wc.lpszMenuName = NULL; // We Don't Want A Menu wc.lpszClassName = WIN_CLASS_NAME; // Set The Class Name - if (! RegisterClass(&wc) // ×¢²á ´°¿ÚÀà ʧ°Ü - && 1410 != GetLastError()) // ²¢ÇÒʧ°ÜµÄÔ­Òò²»ÊÇ´°¿ÚÀàÒÑ×¢²á + if (! RegisterClass(&wc) + && 1410 != GetLastError()) { return; } diff --git a/HelloLua/Classes/AppDelegate.cpp b/HelloLua/Classes/AppDelegate.cpp index 6201bf0da8..0fcf6dbe98 100644 --- a/HelloLua/Classes/AppDelegate.cpp +++ b/HelloLua/Classes/AppDelegate.cpp @@ -32,8 +32,6 @@ bool AppDelegate::applicationDidFinishLaunching() // turn on display FPS pDirector->setDisplayStats(true); - // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); - // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); diff --git a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java b/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java index ca646cb545..e7061f74de 100644 --- a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java +++ b/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java @@ -23,6 +23,7 @@ THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.lib; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -44,10 +45,12 @@ public class Cocos2dxSound { private float mLeftVolume; private float mRightVolume; - // sound id and stream id map - private HashMap mSoundIdStreamIdMap; - // sound path and sound id map - private HashMap mPathSoundIDMap; + // sound path and stream ids map + // a file may be played many times at the same time + // so there is an array map to a file path + private HashMap> mPathStreamIDsMap; + + private HashMap mPathSoundIdMap; private static final String TAG = "Cocos2dxSound"; private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 5; @@ -55,8 +58,8 @@ public class Cocos2dxSound { private static final int SOUND_PRIORITY = 1; private static final int SOUND_QUALITY = 5; - private final int INVALID_SOUND_ID = -1; - private final int INVALID_STREAM_ID = -1; + private final static int INVALID_SOUND_ID = -1; + private final static int INVALID_STREAM_ID = -1; public Cocos2dxSound(Context context){ this.mContext = context; @@ -64,53 +67,48 @@ public class Cocos2dxSound { } public int preloadEffect(String path){ - int soundId = INVALID_SOUND_ID; + Integer soundID = this.mPathSoundIdMap.get(path); - // if the sound is preloaded, pass it - if (this.mPathSoundIDMap.get(path) != null){ - soundId = this.mPathSoundIDMap.get(path).intValue(); - } else { - soundId = createSoundIdFromAsset(path); - - if (soundId != INVALID_SOUND_ID){ - // the sound is loaded but has not been played - this.mSoundIdStreamIdMap.put(soundId, INVALID_STREAM_ID); - - // record path and sound id map - this.mPathSoundIDMap.put(path, soundId); - } + if (soundID == null) { + soundID = createSoundIdFromAsset(path); + this.mPathSoundIdMap.put(path, soundID); } - return soundId; + return soundID; } public void unloadEffect(String path){ - // get sound id and remove from mPathSoundIDMap - Integer soundId = this.mPathSoundIDMap.remove(path); + // stop effects + ArrayList streamIDs = this.mPathStreamIDsMap.get(path); + if (streamIDs != null) { + for (Integer streamID : streamIDs) { + this.mSoundPool.stop(streamID); + } + } + this.mPathStreamIDsMap.remove(path); - if (soundId != null){ - // unload effect - this.mSoundPool.unload(soundId.intValue()); - - // remove record from mSoundIdStreamIdMap - this.mSoundIdStreamIdMap.remove(soundId); - } + // unload effect + Integer soundID = this.mPathSoundIdMap.get(path); + this.mSoundPool.unload(soundID); + this.mPathSoundIdMap.remove(path); } public int playEffect(String path, boolean isLoop){ - Integer soundId = this.mPathSoundIDMap.get(path); + Integer soundId = this.mPathSoundIdMap.get(path); + int streamId = INVALID_STREAM_ID; - if (soundId != null){ - // the sound is preloaded, stop it first - - this.mSoundPool.stop(soundId); - + if (soundId != null){ // play sound - int streamId = this.mSoundPool.play(soundId.intValue(), this.mLeftVolume, + streamId = this.mSoundPool.play(soundId.intValue(), this.mLeftVolume, this.mRightVolume, SOUND_PRIORITY, isLoop ? -1 : 0, SOUND_RATE); - // record sound id and stream id map - this.mSoundIdStreamIdMap.put(soundId, streamId); + // record stream id + ArrayList streamIds = this.mPathStreamIDsMap.get(path); + if (streamIds == null) { + streamIds = new ArrayList(); + this.mPathStreamIDsMap.put(path, streamIds); + } + streamIds.add(streamId); } else { // the effect is not prepared soundId = preloadEffect(path); @@ -133,54 +131,53 @@ public class Cocos2dxSound { playEffect(path, isLoop); } - return soundId.intValue(); + return streamId; } - public void stopEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); + public void stopEffect(int streamID){ + this.mSoundPool.stop(streamID); - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.stop(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); + // remove record + for (String path : this.mPathStreamIDsMap.keySet()) { + if (this.mPathStreamIDsMap.get(path).contains(streamID)) { + this.mPathStreamIDsMap.get(path).remove(this.mPathStreamIDsMap.get(path).indexOf(streamID)); + break; + } } } - public void pauseEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); - - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.pause(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); - } + public void pauseEffect(int streamID){ + this.mSoundPool.pause(streamID); } - public void resumeEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); - - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.resume(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); - } + public void resumeEffect(int streamID){ + this.mSoundPool.resume(streamID); } public void pauseAllEffects(){ - // autoResume is available since level 8 - pauseOrResumeAllEffects(true); + this.mSoundPool.autoPause(); } public void resumeAllEffects(){ // autoPause() is available since level 8 - pauseOrResumeAllEffects(false); + this.mSoundPool.autoResume(); } @SuppressWarnings("unchecked") public void stopAllEffects(){ - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - int soundId = entry.getKey(); - this.stopEffect(soundId); - } + // stop effects + if (! this.mPathStreamIDsMap.isEmpty()) { + Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); + while (iter.hasNext()){ + Map.Entry> entry = (Map.Entry>)iter.next(); + for (int streamID : entry.getValue()) { + this.mSoundPool.stop(streamID); + } + } + } + + // remove records + this.mPathStreamIDsMap.clear(); } public float getEffectsVolume(){ @@ -200,17 +197,21 @@ public class Cocos2dxSound { this.mLeftVolume = this.mRightVolume = volume; // change the volume of playing sounds - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - this.mSoundPool.setVolume(entry.getValue(), mLeftVolume, mRightVolume); - } + if (! this.mPathStreamIDsMap.isEmpty()) { + Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); + while (iter.hasNext()){ + Map.Entry> entry = (Map.Entry>)iter.next(); + for (int streamID : entry.getValue()) { + this.mSoundPool.setVolume(streamID, mLeftVolume, mRightVolume); + } + } + } } public void end(){ this.mSoundPool.release(); - this.mPathSoundIDMap.clear(); - this.mSoundIdStreamIdMap.clear(); + this.mPathStreamIDsMap.clear(); + this.mPathSoundIdMap.clear(); initData(); } @@ -234,25 +235,11 @@ public class Cocos2dxSound { } private void initData(){ - this.mSoundIdStreamIdMap = new HashMap(); + this.mPathStreamIDsMap = new HashMap>(); + this.mPathSoundIdMap = new HashMap(); mSoundPool = new SoundPool(MAX_SIMULTANEOUS_STREAMS_DEFAULT, AudioManager.STREAM_MUSIC, SOUND_QUALITY); - mPathSoundIDMap = new HashMap(); this.mLeftVolume = 0.5f; this.mRightVolume = 0.5f; } - - @SuppressWarnings("unchecked") - private void pauseOrResumeAllEffects(boolean isPause){ - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - int soundId = entry.getKey(); - if (isPause) { - this.pauseEffect(soundId); - } else { - this.resumeEffect(soundId); - } - } - } } diff --git a/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id b/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id index a42ba6f236..a719cf6fd3 100644 --- a/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -842462907b895bea8fcf8fc4a567560e546e440f \ No newline at end of file +054e166ed7b342f0cd56308efb308551f9488951 \ No newline at end of file diff --git a/HelloLua/proj.win32/HelloLua.win32.vcproj b/HelloLua/proj.win32/HelloLua.win32.vcproj index 7d9805f419..e4efafcfb0 100644 --- a/HelloLua/proj.win32/HelloLua.win32.vcproj +++ b/HelloLua/proj.win32/HelloLua.win32.vcproj @@ -20,7 +20,7 @@ OutputDirectory="$(SolutionDir)$(ConfigurationName).win32" IntermediateDirectory="$(ConfigurationName).win32" ConfigurationType="1" - CharacterSet="2" + CharacterSet="1" > Application - MultiByte + Unicode Application - MultiByte + Unicode diff --git a/HelloWorld/Classes/AppDelegate.cpp b/HelloWorld/Classes/AppDelegate.cpp index e9642c568d..875c3da4e4 100644 --- a/HelloWorld/Classes/AppDelegate.cpp +++ b/HelloWorld/Classes/AppDelegate.cpp @@ -27,8 +27,6 @@ bool AppDelegate::applicationDidFinishLaunching() { // turn on display FPS pDirector->setDisplayStats(true); - // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); - // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); diff --git a/HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java b/HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java index ca646cb545..e7061f74de 100644 --- a/HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java +++ b/HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java @@ -23,6 +23,7 @@ THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.lib; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -44,10 +45,12 @@ public class Cocos2dxSound { private float mLeftVolume; private float mRightVolume; - // sound id and stream id map - private HashMap mSoundIdStreamIdMap; - // sound path and sound id map - private HashMap mPathSoundIDMap; + // sound path and stream ids map + // a file may be played many times at the same time + // so there is an array map to a file path + private HashMap> mPathStreamIDsMap; + + private HashMap mPathSoundIdMap; private static final String TAG = "Cocos2dxSound"; private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 5; @@ -55,8 +58,8 @@ public class Cocos2dxSound { private static final int SOUND_PRIORITY = 1; private static final int SOUND_QUALITY = 5; - private final int INVALID_SOUND_ID = -1; - private final int INVALID_STREAM_ID = -1; + private final static int INVALID_SOUND_ID = -1; + private final static int INVALID_STREAM_ID = -1; public Cocos2dxSound(Context context){ this.mContext = context; @@ -64,53 +67,48 @@ public class Cocos2dxSound { } public int preloadEffect(String path){ - int soundId = INVALID_SOUND_ID; + Integer soundID = this.mPathSoundIdMap.get(path); - // if the sound is preloaded, pass it - if (this.mPathSoundIDMap.get(path) != null){ - soundId = this.mPathSoundIDMap.get(path).intValue(); - } else { - soundId = createSoundIdFromAsset(path); - - if (soundId != INVALID_SOUND_ID){ - // the sound is loaded but has not been played - this.mSoundIdStreamIdMap.put(soundId, INVALID_STREAM_ID); - - // record path and sound id map - this.mPathSoundIDMap.put(path, soundId); - } + if (soundID == null) { + soundID = createSoundIdFromAsset(path); + this.mPathSoundIdMap.put(path, soundID); } - return soundId; + return soundID; } public void unloadEffect(String path){ - // get sound id and remove from mPathSoundIDMap - Integer soundId = this.mPathSoundIDMap.remove(path); + // stop effects + ArrayList streamIDs = this.mPathStreamIDsMap.get(path); + if (streamIDs != null) { + for (Integer streamID : streamIDs) { + this.mSoundPool.stop(streamID); + } + } + this.mPathStreamIDsMap.remove(path); - if (soundId != null){ - // unload effect - this.mSoundPool.unload(soundId.intValue()); - - // remove record from mSoundIdStreamIdMap - this.mSoundIdStreamIdMap.remove(soundId); - } + // unload effect + Integer soundID = this.mPathSoundIdMap.get(path); + this.mSoundPool.unload(soundID); + this.mPathSoundIdMap.remove(path); } public int playEffect(String path, boolean isLoop){ - Integer soundId = this.mPathSoundIDMap.get(path); + Integer soundId = this.mPathSoundIdMap.get(path); + int streamId = INVALID_STREAM_ID; - if (soundId != null){ - // the sound is preloaded, stop it first - - this.mSoundPool.stop(soundId); - + if (soundId != null){ // play sound - int streamId = this.mSoundPool.play(soundId.intValue(), this.mLeftVolume, + streamId = this.mSoundPool.play(soundId.intValue(), this.mLeftVolume, this.mRightVolume, SOUND_PRIORITY, isLoop ? -1 : 0, SOUND_RATE); - // record sound id and stream id map - this.mSoundIdStreamIdMap.put(soundId, streamId); + // record stream id + ArrayList streamIds = this.mPathStreamIDsMap.get(path); + if (streamIds == null) { + streamIds = new ArrayList(); + this.mPathStreamIDsMap.put(path, streamIds); + } + streamIds.add(streamId); } else { // the effect is not prepared soundId = preloadEffect(path); @@ -133,54 +131,53 @@ public class Cocos2dxSound { playEffect(path, isLoop); } - return soundId.intValue(); + return streamId; } - public void stopEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); + public void stopEffect(int streamID){ + this.mSoundPool.stop(streamID); - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.stop(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); + // remove record + for (String path : this.mPathStreamIDsMap.keySet()) { + if (this.mPathStreamIDsMap.get(path).contains(streamID)) { + this.mPathStreamIDsMap.get(path).remove(this.mPathStreamIDsMap.get(path).indexOf(streamID)); + break; + } } } - public void pauseEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); - - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.pause(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); - } + public void pauseEffect(int streamID){ + this.mSoundPool.pause(streamID); } - public void resumeEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); - - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.resume(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); - } + public void resumeEffect(int streamID){ + this.mSoundPool.resume(streamID); } public void pauseAllEffects(){ - // autoResume is available since level 8 - pauseOrResumeAllEffects(true); + this.mSoundPool.autoPause(); } public void resumeAllEffects(){ // autoPause() is available since level 8 - pauseOrResumeAllEffects(false); + this.mSoundPool.autoResume(); } @SuppressWarnings("unchecked") public void stopAllEffects(){ - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - int soundId = entry.getKey(); - this.stopEffect(soundId); - } + // stop effects + if (! this.mPathStreamIDsMap.isEmpty()) { + Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); + while (iter.hasNext()){ + Map.Entry> entry = (Map.Entry>)iter.next(); + for (int streamID : entry.getValue()) { + this.mSoundPool.stop(streamID); + } + } + } + + // remove records + this.mPathStreamIDsMap.clear(); } public float getEffectsVolume(){ @@ -200,17 +197,21 @@ public class Cocos2dxSound { this.mLeftVolume = this.mRightVolume = volume; // change the volume of playing sounds - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - this.mSoundPool.setVolume(entry.getValue(), mLeftVolume, mRightVolume); - } + if (! this.mPathStreamIDsMap.isEmpty()) { + Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); + while (iter.hasNext()){ + Map.Entry> entry = (Map.Entry>)iter.next(); + for (int streamID : entry.getValue()) { + this.mSoundPool.setVolume(streamID, mLeftVolume, mRightVolume); + } + } + } } public void end(){ this.mSoundPool.release(); - this.mPathSoundIDMap.clear(); - this.mSoundIdStreamIdMap.clear(); + this.mPathStreamIDsMap.clear(); + this.mPathSoundIdMap.clear(); initData(); } @@ -234,25 +235,11 @@ public class Cocos2dxSound { } private void initData(){ - this.mSoundIdStreamIdMap = new HashMap(); + this.mPathStreamIDsMap = new HashMap>(); + this.mPathSoundIdMap = new HashMap(); mSoundPool = new SoundPool(MAX_SIMULTANEOUS_STREAMS_DEFAULT, AudioManager.STREAM_MUSIC, SOUND_QUALITY); - mPathSoundIDMap = new HashMap(); this.mLeftVolume = 0.5f; this.mRightVolume = 0.5f; } - - @SuppressWarnings("unchecked") - private void pauseOrResumeAllEffects(boolean isPause){ - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - int soundId = entry.getKey(); - if (isPause) { - this.pauseEffect(soundId); - } else { - this.resumeEffect(soundId); - } - } - } } diff --git a/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id b/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id index 4d57dadf2d..58cbc28d2d 100644 --- a/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -c7a3fbb2c6d8e698889720796681db135c37b25b \ No newline at end of file +5e8bc2ebea93cf60f4c5992e1175c43fffffb7e8 \ No newline at end of file diff --git a/HelloWorld/proj.win32/HelloWorld.win32.vcproj b/HelloWorld/proj.win32/HelloWorld.win32.vcproj index 06d237790b..9dc1b267d0 100644 --- a/HelloWorld/proj.win32/HelloWorld.win32.vcproj +++ b/HelloWorld/proj.win32/HelloWorld.win32.vcproj @@ -21,7 +21,7 @@ OutputDirectory="$(SolutionDir)$(ConfigurationName).win32" IntermediateDirectory="$(ConfigurationName).win32" ConfigurationType="1" - CharacterSet="2" + CharacterSet="1" > Application - MultiByte + Unicode true Application - MultiByte + Unicode diff --git a/chipmunk/proj.win32/chipmunk.win32.vcproj b/chipmunk/proj.win32/chipmunk.win32.vcproj index bb89c267c1..86932ed886 100644 --- a/chipmunk/proj.win32/chipmunk.win32.vcproj +++ b/chipmunk/proj.win32/chipmunk.win32.vcproj @@ -20,7 +20,7 @@ OutputDirectory="$(SolutionDir)$(ConfigurationName).win32" IntermediateDirectory="$(ConfigurationName).win32" ConfigurationType="4" - CharacterSet="2" + CharacterSet="1" > StaticLibrary - MultiByte + Unicode StaticLibrary - MultiByte + Unicode diff --git a/cocos2d-win32.vc2008.sln b/cocos2d-win32.vc2008.sln index 937a2e7fd8..c145c07176 100644 --- a/cocos2d-win32.vc2008.sln +++ b/cocos2d-win32.vc2008.sln @@ -39,6 +39,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "testjs", "testjs\proj.win32 EndProjectSection EndProject Global + GlobalSection(DPCodeReviewSolutionGUID) = preSolution + DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} + EndGlobalSection GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 @@ -84,7 +87,4 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(DPCodeReviewSolutionGUID) = preSolution - DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} - EndGlobalSection EndGlobal diff --git a/cocos2dx/CCConfiguration.cpp b/cocos2dx/CCConfiguration.cpp index 8eba9c1b69..50bdd35109 100644 --- a/cocos2dx/CCConfiguration.cpp +++ b/cocos2dx/CCConfiguration.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2010 Ricardo Quesada http://www.cocos2d-x.org @@ -41,6 +41,7 @@ CCConfiguration::CCConfiguration(void) , m_bSupportsPVRTC(false) , m_bSupportsNPOT(false) , m_bSupportsBGRA8888(false) +, m_bSupportsShareableVAO(false) , m_bSupportsDiscardFramebuffer(false) , m_nMaxSamplesAllowed(0) , m_pGlExtensions(NULL) @@ -66,12 +67,15 @@ bool CCConfiguration::init(void) m_bSupportsBGRA8888 = checkForGLExtension("GL_IMG_texture_format_BGRA888"); m_bSupportsDiscardFramebuffer = checkForGLExtension("GL_EXT_discard_framebuffer"); + m_bSupportsShareableVAO = checkForGLExtension("vertex_array_object"); + CCLOG("cocos2d: GL_MAX_TEXTURE_SIZE: %d", m_nMaxTextureSize); CCLOG("cocos2d: GL_MAX_TEXTURE_UNITS: %d",m_nMaxTextureUnits); CCLOG("cocos2d: GL supports PVRTC: %s", (m_bSupportsPVRTC ? "YES" : "NO")); CCLOG("cocos2d: GL supports BGRA8888 textures: %s", (m_bSupportsBGRA8888 ? "YES" : "NO")); CCLOG("cocos2d: GL supports NPOT textures: %s", (m_bSupportsNPOT ? "YES" : "NO")); CCLOG("cocos2d: GL supports discard_framebuffer: %s", (m_bSupportsDiscardFramebuffer ? "YES" : "NO")); + CCLOG("cocos2d: GL supports shareable VAO: %s", (m_bSupportsShareableVAO ? "YES" : "NO") ); bool bEnableProfilers = false; diff --git a/cocos2dx/CCConfiguration.h b/cocos2dx/CCConfiguration.h index 13a0f2274c..299aef6772 100644 --- a/cocos2dx/CCConfiguration.h +++ b/cocos2dx/CCConfiguration.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2010 Ricardo Quesada http://www.cocos2d-x.org @@ -97,6 +97,14 @@ public: return m_bSupportsDiscardFramebuffer; } + /** Whether or not shareable VAOs are supported. + @since v2.0.0 + */ + inline bool isSupportsShareableVAO(void) + { + return m_bSupportsShareableVAO; + } + /** returns whether or not an OpenGL is supported */ bool checkForGLExtension(const std::string &searchName); @@ -113,6 +121,7 @@ protected: bool m_bSupportsNPOT; bool m_bSupportsBGRA8888; bool m_bSupportsDiscardFramebuffer; + bool m_bSupportsShareableVAO; GLint m_nMaxSamplesAllowed; GLint m_nMaxTextureUnits; char * m_pGlExtensions; diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 4140a4d2db..4dbe64bfb6 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. @@ -55,6 +55,7 @@ THE SOFTWARE. #include "extensions/CCNotificationCenter/CCNotificationCenter.h" #include "extensions/CCTextureWatcher/CCTextureWatcher.h" #include "extensions/CCBReader/CCBCustomClass.h" +#include "extensions/CCBIReader/CCNodeLoaderLibrary.h" #include using namespace std; @@ -138,7 +139,7 @@ bool CCDirector::init(void) m_pScheduler = new CCScheduler(); // action manager m_pActionManager = new CCActionManager(); - m_pScheduler->scheduleUpdateForTarget(m_pActionManager, kCCActionManagerPriority, false); + m_pScheduler->scheduleUpdateForTarget(m_pActionManager, kCCPrioritySystem, false); // touchDispatcher m_pTouchDispatcher = new CCTouchDispatcher(); m_pTouchDispatcher->init(); @@ -336,10 +337,9 @@ void CCDirector::setProjection(ccDirectorProjection kProjection) CCSize size = m_obWinSizeInPixels; CCSize sizePoint = m_obWinSizeInPoints; - //glViewport(0, 0, size.width * CC_CONTENT_SCALE_FACTOR(), size.height * CC_CONTENT_SCALE_FACTOR() ); if (m_pobOpenGLView) { - m_pobOpenGLView->setViewPortInPoints(0, 0, size.width, size.height); + m_pobOpenGLView->setViewPortInPoints(0, 0, sizePoint.width, sizePoint.height); } switch (kProjection) @@ -349,7 +349,7 @@ void CCDirector::setProjection(ccDirectorProjection kProjection) kmGLMatrixMode(KM_GL_PROJECTION); kmGLLoadIdentity(); kmMat4 orthoMatrix; - kmMat4OrthographicProjection(&orthoMatrix, 0, size.width, 0, size.height, -1024, 1024 ); + kmMat4OrthographicProjection(&orthoMatrix, 0, size.width / CC_CONTENT_SCALE_FACTOR(), 0, size.height / CC_CONTENT_SCALE_FACTOR(), -1024, 1024 ); kmGLMultMatrix(&orthoMatrix); kmGLMatrixMode(KM_GL_MODELVIEW); kmGLLoadIdentity(); @@ -358,11 +358,11 @@ void CCDirector::setProjection(ccDirectorProjection kProjection) case kCCDirectorProjection3D: { - // reset the viewport if 3d proj & retina display - if( CC_CONTENT_SCALE_FACTOR() != 1.0f ) - { - glViewport((GLint)-size.width/2, (GLint)-size.height/2, (GLsizei)(size.width * CC_CONTENT_SCALE_FACTOR()), (GLsizei)(size.height * CC_CONTENT_SCALE_FACTOR()) ); - } +//TODO: // reset the viewport if 3d proj & retina display +// if( CC_CONTENT_SCALE_FACTOR() != 1.0f ) +// { +// glViewport((GLint)-size.width/2, (GLint)-size.height/2, (GLsizei)(size.width * CC_CONTENT_SCALE_FACTOR()), (GLsizei)(size.height * CC_CONTENT_SCALE_FACTOR()) ); +// } float zeye = this->getZEye(); @@ -372,14 +372,17 @@ void CCDirector::setProjection(ccDirectorProjection kProjection) kmGLLoadIdentity(); // issue #1334 - if (m_pobOpenGLView && m_pobOpenGLView->isIpad() && m_pobOpenGLView->getMainScreenScale() > 1.0f) - { - kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, zeye-size.height/2, zeye+size.height/2); - } - else - { - kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.5f, 1500); - } + kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, zeye*2); + // kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, 1500); + +//TODO: if (m_pobOpenGLView && m_pobOpenGLView->isIpad() && m_pobOpenGLView->getMainScreenScale() > 1.0f) +// { +// kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, zeye-size.height/2, zeye+size.height/2); +// } +// else +// { +// kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.5f, 1500); +// } // kmMat4PerspectiveProjection( &matrixPerspective, 60, (GLfloat)size.width/size.height, 0.1f, 1500); kmGLMultMatrix(&matrixPerspective); @@ -593,6 +596,7 @@ void CCDirector::purgeDirector() extension::CCNotificationCenter::purgeNotificationCenter(); extension::CCTextureWatcher::purgeTextureWatcher(); extension::CCBCustomClassFactory::purgeFactory(); + extension::CCNodeLoaderLibrary::purgeSharedCCNodeLoaderLibrary(); ccGLInvalidateStateCache(); diff --git a/cocos2dx/CCDirector.h b/cocos2dx/CCDirector.h index 5ccd4eed4d..9b63a63aea 100644 --- a/cocos2dx/CCDirector.h +++ b/cocos2dx/CCDirector.h @@ -329,8 +329,8 @@ protected: bool m_bLandscape; bool m_bDisplayStats; - ccTime m_fAccumDt; - ccTime m_fFrameRate; + float m_fAccumDt; + float m_fFrameRate; CCLabelBMFont *m_pFPSLabel; CCLabelBMFont *m_pSPFLabel; @@ -342,7 +342,7 @@ protected: /* How many frames were called since the director started */ unsigned int m_uTotalFrames; unsigned int m_uFrames; - ccTime m_fSecondsPerFrame; + float m_fSecondsPerFrame; /* The running scene */ CCScene *m_pRunningScene; @@ -361,7 +361,7 @@ protected: struct cc_timeval *m_pLastUpdate; /* delta time since last tick to main loop */ - ccTime m_fDeltaTime; + float m_fDeltaTime; /* whether or not the next delta time will be zero */ bool m_bNextDeltaTimeZero; diff --git a/cocos2dx/CCDrawingPrimitives.cpp b/cocos2dx/CCDrawingPrimitives.cpp index d8032cfc29..2c7d4e0193 100644 --- a/cocos2dx/CCDrawingPrimitives.cpp +++ b/cocos2dx/CCDrawingPrimitives.cpp @@ -32,6 +32,8 @@ THE SOFTWARE. #include "ccGLStateCache.h" #include "CCShaderCache.h" #include "CCGLProgram.h" +#include "CCActionCatmullRom.h" +#include "CCPointExtension.h" #include #include @@ -154,6 +156,25 @@ void ccDrawLine( const CCPoint& origin, const CCPoint& destination ) CC_INCREMENT_GL_DRAWS(1); } +void ccDrawRect( CCPoint origin, CCPoint destination ) +{ + ccDrawLine(CCPointMake(origin.x, origin.y), CCPointMake(destination.x, origin.y)); + ccDrawLine(CCPointMake(destination.x, origin.y), CCPointMake(destination.x, destination.y)); + ccDrawLine(CCPointMake(destination.x, destination.y), CCPointMake(origin.x, destination.y)); + ccDrawLine(CCPointMake(origin.x, destination.y), CCPointMake(origin.x, origin.y)); +} + +void ccDrawSolidRect( CCPoint origin, CCPoint destination, ccColor4F color ) +{ + CCPoint vertices[] = { + origin, + ccp(destination.x, origin.y), + destination, + ccp(origin.x, destination.y) + }; + + ccDrawSolidPoly(vertices, 4, color ); +} void ccDrawPoly( const CCPoint *poli, unsigned int numberOfPoints, bool closePolygon ) { @@ -192,7 +213,7 @@ void ccDrawPoly( const CCPoint *poli, unsigned int numberOfPoints, bool closePol CC_INCREMENT_GL_DRAWS(1); } -void ccDrawFilledPoly( const CCPoint *poli, unsigned int numberOfPoints, ccColor4F color ) +void ccDrawSolidPoly( const CCPoint *poli, unsigned int numberOfPoints, ccColor4F color ) { lazy_init(); @@ -294,6 +315,58 @@ void ccDrawQuadBezier(const CCPoint& origin, const CCPoint& control, const CCPoi CC_INCREMENT_GL_DRAWS(1); } +void ccDrawCatmullRom( CCPointArray *points, unsigned int segments ) +{ + ccDrawCardinalSpline( points, 0.5f, segments ); +} + +void ccDrawCardinalSpline( CCPointArray *config, CCFloat tension, unsigned int segments ) +{ + lazy_init(); + + ccVertex2F* vertices = new ccVertex2F[segments + 1]; + + unsigned int p; + CCFloat lt; + CCFloat deltaT = 1.0f / config->count(); + + for( unsigned int i=0; i < segments+1;i++) { + + CCFloat dt = (CCFloat)i / segments; + + // border + if( dt == 1 ) { + p = config->count() - 1; + lt = 1; + } else { + p = dt / deltaT; + lt = (dt - deltaT * (CCFloat)p) / deltaT; + } + + // Interpolate + CCPoint pp0 = config->getControlPointAtIndex(p-1); + CCPoint pp1 = config->getControlPointAtIndex(p+0); + CCPoint pp2 = config->getControlPointAtIndex(p+1); + CCPoint pp3 = config->getControlPointAtIndex(p+2); + + CCPoint newPos = ccCardinalSplineAt( pp0, pp1, pp2, pp3, tension, lt); + vertices[i].x = newPos.x; + vertices[i].y = newPos.y; + } + + shader_->use(); + shader_->setUniformForModelViewProjectionMatrix(); + shader_->setUniformLocationWith4fv(colorLocation_, (GLfloat*)&color_.r, 1); + + ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); + + glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, vertices); + glDrawArrays(GL_LINE_STRIP, 0, (GLsizei) segments + 1); + + CC_SAFE_DELETE_ARRAY(vertices); + CC_INCREMENT_GL_DRAWS(1); +} + void ccDrawCubicBezier(const CCPoint& origin, const CCPoint& control1, const CCPoint& control2, const CCPoint& destination, unsigned int segments) { lazy_init(); diff --git a/cocos2dx/CCDrawingPrimitives.h b/cocos2dx/CCDrawingPrimitives.h index 4b65fe690c..a57b503ef1 100644 --- a/cocos2dx/CCDrawingPrimitives.h +++ b/cocos2dx/CCDrawingPrimitives.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. @@ -49,6 +49,8 @@ THE SOFTWARE. NS_CC_BEGIN +class CCPointArray; + /** initlialize context */ void CC_DLL ccDrawInit(); @@ -63,28 +65,50 @@ void CC_DLL ccDrawPoints( const CCPoint *points, unsigned int numberOfPoints ); /** draws a line given the origin and destination point measured in points */ void CC_DLL ccDrawLine( const CCPoint& origin, const CCPoint& destination ); +/** draws a rectangle given the origin and destination point measured in points. */ +void CC_DLL ccDrawRect( CCPoint origin, CCPoint destination ); + +/** draws a solid rectangle given the origin and destination point measured in points. + @since 1.1 + */ +void CC_DLL ccDrawSolidRect( CCPoint origin, CCPoint destination, ccColor4F color ); + /** draws a poligon given a pointer to CCPoint coordiantes and the number of vertices measured in points. The polygon can be closed or open */ void CC_DLL ccDrawPoly( const CCPoint *vertices, unsigned int numOfVertices, bool closePolygon ); -/** draws a filled polygon given a pointer to CGPoint coordiantes, the number of vertices measured in points, and a color. +/** draws a solid polygon given a pointer to CGPoint coordiantes, the number of vertices measured in points, and a color. */ -void CC_DLL ccDrawFilledPoly( const CCPoint *poli, unsigned int numberOfPoints, ccColor4F color ); +void CC_DLL ccDrawSolidPoly( const CCPoint *poli, unsigned int numberOfPoints, ccColor4F color ); /** draws a circle given the center, radius and number of segments. */ void CC_DLL ccDrawCircle( const CCPoint& center, float radius, float angle, unsigned int segments, bool drawLineToCenter); /** draws a quad bezier path + @warning This function could be pretty slow. Use it only for debugging purposes. @since v0.8 */ void CC_DLL ccDrawQuadBezier(const CCPoint& origin, const CCPoint& control, const CCPoint& destination, unsigned int segments); /** draws a cubic bezier path + @warning This function could be pretty slow. Use it only for debugging purposes. @since v0.8 */ void CC_DLL ccDrawCubicBezier(const CCPoint& origin, const CCPoint& control1, const CCPoint& control2, const CCPoint& destination, unsigned int segments); +/** draws a Catmull Rom path. + @warning This function could be pretty slow. Use it only for debugging purposes. + @since v2.0 + */ +void CC_DLL ccDrawCatmullRom( CCPointArray *arrayOfControlPoints, unsigned int segments ); + +/** draws a Cardinal Spline path. + @warning This function could be pretty slow. Use it only for debugging purposes. + @since v2.0 + */ +void CC_DLL ccDrawCardinalSpline( CCPointArray *config, CCFloat tension, unsigned int segments ); + /** set the drawing color with 4 unsigned bytes @since v2.0 */ diff --git a/cocos2dx/CCScheduler.cpp b/cocos2dx/CCScheduler.cpp index ebe3de1ba9..1f486f6e89 100644 --- a/cocos2dx/CCScheduler.cpp +++ b/cocos2dx/CCScheduler.cpp @@ -63,15 +63,15 @@ typedef struct _hashSelectorEntry ccArray *timers; CCObject *target; // hash key (retained) unsigned int timerIndex; - CCTimer *currentTimer; + floatr *currentTimer; bool currentTimerSalvaged; bool paused; UT_hash_handle hh; } tHashSelectorEntry; -// implementation CCTimer +// implementation floatr -CCTimer::CCTimer() +floatr::floatr() : m_pfnSelector(NULL) , m_fInterval(0.0f) , m_pTarget(NULL) @@ -86,9 +86,9 @@ CCTimer::CCTimer() } -CCTimer* CCTimer::timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector) +floatr* floatr::timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector) { - CCTimer *pTimer = new CCTimer(); + floatr *pTimer = new floatr(); pTimer->initWithTarget(pTarget, pfnSelector, 0.0f, kCCRepeatForever, 0.0f); pTimer->autorelease(); @@ -96,9 +96,9 @@ CCTimer* CCTimer::timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector) return pTimer; } -CCTimer* CCTimer::timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, ccTime fSeconds) +floatr* floatr::timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, float fSeconds) { - CCTimer *pTimer = new CCTimer(); + floatr *pTimer = new floatr(); pTimer->initWithTarget(pTarget, pfnSelector, fSeconds, kCCRepeatForever, 0.0f); pTimer->autorelease(); @@ -106,9 +106,9 @@ CCTimer* CCTimer::timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, c return pTimer; } -CCTimer* CCTimer::timerWithScriptHandler(int nHandler, ccTime fSeconds) +floatr* floatr::timerWithScriptHandler(int nHandler, float fSeconds) { - CCTimer *pTimer = new CCTimer(); + floatr *pTimer = new floatr(); pTimer->initWithScriptHandler(nHandler, fSeconds); pTimer->autorelease(); @@ -116,7 +116,7 @@ CCTimer* CCTimer::timerWithScriptHandler(int nHandler, ccTime fSeconds) return pTimer; } -bool CCTimer::initWithScriptHandler(int nHandler, ccTime fSeconds) +bool floatr::initWithScriptHandler(int nHandler, float fSeconds) { m_nScriptHandler = nHandler; m_fElapsed = -1; @@ -125,12 +125,12 @@ bool CCTimer::initWithScriptHandler(int nHandler, ccTime fSeconds) return true; } -bool CCTimer::initWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector) +bool floatr::initWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector) { return initWithTarget(pTarget, pfnSelector, 0, kCCRepeatForever, 0.0f); } -bool CCTimer::initWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, ccTime fSeconds, unsigned int nRepeat, ccTime fDelay) +bool floatr::initWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, float fSeconds, unsigned int nRepeat, float fDelay) { m_pTarget = pTarget; m_pfnSelector = pfnSelector; @@ -143,7 +143,7 @@ bool CCTimer::initWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, ccTime return true; } -void CCTimer::update(ccTime dt) +void floatr::update(float dt) { if (m_fElapsed == -1) { @@ -254,10 +254,10 @@ void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, this->scheduleSelector(pfnSelector, pTarget, fInterval, bPaused, kCCRepeatForever, 0.0f); } -void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, ccTime fInterval, bool bPaused, unsigned int repeat, ccTime delay) +void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, float fInterval, bool bPaused, unsigned int repeat, float delay) { - CCAssert(pfnSelector, ""); - CCAssert(pTarget, ""); + CCAssert(pfnSelector, "Argument selector must be non-NULL"); + CCAssert(pTarget, "Argument target must be non-NULL"); tHashSelectorEntry *pElement = NULL; HASH_FIND_INT(m_pHashForSelectors, &pTarget, pElement); @@ -288,11 +288,11 @@ void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, { for (unsigned int i = 0; i < pElement->timers->num; ++i) { - CCTimer *timer = (CCTimer*)pElement->timers->arr[i]; + floatr *timer = (floatr*)pElement->timers->arr[i]; if (pfnSelector == timer->m_pfnSelector) { - CCLOG("CCSheduler#scheduleSelector. Selector already scheduled."); + CCLOG("CCScheduler#scheduleSelector. Selector already scheduled. Updating interval from: %.4f to %.4f", timer->getInterval(), fInterval); timer->m_fInterval = fInterval; return; } @@ -300,7 +300,7 @@ void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, ccArrayEnsureExtraCapacity(pElement->timers, 1); } - CCTimer *pTimer = new CCTimer(); + floatr *pTimer = new floatr(); pTimer->initWithTarget(pTarget, pfnSelector, fInterval, repeat, delay); ccArrayAppendObject(pElement->timers, pTimer); pTimer->release(); @@ -324,7 +324,7 @@ void CCScheduler::unscheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget { for (unsigned int i = 0; i < pElement->timers->num; ++i) { - CCTimer *pTimer = (CCTimer*)(pElement->timers->arr[i]); + floatr *pTimer = (floatr*)(pElement->timers->arr[i]); if (pfnSelector == pTimer->m_pfnSelector) { @@ -510,6 +510,11 @@ void CCScheduler::unscheduleUpdateForTarget(const CCObject *pTarget) } void CCScheduler::unscheduleAllSelectors(void) +{ + unscheduleAllSelectorsWithMinPriority(kCCPrioritySystem); +} + +void CCScheduler::unscheduleAllSelectorsWithMinPriority(int nMinPriority) { // Custom Selectors tHashSelectorEntry *pElement = NULL; @@ -525,17 +530,31 @@ void CCScheduler::unscheduleAllSelectors(void) // Updates selectors tListEntry *pEntry, *pTmp; - DL_FOREACH_SAFE(m_pUpdates0List, pEntry, pTmp) + if(nMinPriority < 0) { - unscheduleUpdateForTarget(pEntry->target); + DL_FOREACH_SAFE(m_pUpdatesNegList, pEntry, pTmp) + { + if(pEntry->priority >= nMinPriority) + { + unscheduleUpdateForTarget(pEntry->target); + } + } } - DL_FOREACH_SAFE(m_pUpdatesNegList, pEntry, pTmp) + + if(nMinPriority <= 0) { - unscheduleUpdateForTarget(pEntry->target); + DL_FOREACH_SAFE(m_pUpdates0List, pEntry, pTmp) + { + unscheduleUpdateForTarget(pEntry->target); + } } + DL_FOREACH_SAFE(m_pUpdatesPosList, pEntry, pTmp) { - unscheduleUpdateForTarget(pEntry->target); + if(pEntry->priority >= nMinPriority) + { + unscheduleUpdateForTarget(pEntry->target); + } } if (m_pScriptHandlerEntries) @@ -580,7 +599,7 @@ void CCScheduler::unscheduleAllSelectorsForTarget(CCObject *pTarget) unscheduleUpdateForTarget(pTarget); } -unsigned int CCScheduler::scheduleScriptFunc(unsigned int nHandler, ccTime fInterval, bool bPaused) +unsigned int CCScheduler::scheduleScriptFunc(unsigned int nHandler, float fInterval, bool bPaused) { CCSchedulerScriptHandlerEntry* pEntry = CCSchedulerScriptHandlerEntry::entryWithHandler(nHandler, fInterval, bPaused); if (!m_pScriptHandlerEntries) @@ -663,8 +682,70 @@ bool CCScheduler::isTargetPaused(CCObject *pTarget) return false; // should never get here } +CCSet* CCScheduler::pauseAllTargets() +{ + return pauseAllTargetsWithMinPriority(kCCPrioritySystem); +} + +CCSet* CCScheduler::pauseAllTargetsWithMinPriority(int nMinPriority) +{ + CCSet* idsWithSelectors = new CCSet();// setWithCapacity:50]; + idsWithSelectors->autorelease(); + + // Custom Selectors + for(tHashSelectorEntry *element = m_pHashForSelectors; element != NULL; + element = (tHashSelectorEntry*)element->hh.next) + { + element->paused = true; + idsWithSelectors->addObject(element->target); + } + + // Updates selectors + tListEntry *entry, *tmp; + if(nMinPriority < 0) + { + DL_FOREACH_SAFE( m_pUpdatesNegList, entry, tmp ) + { + if(entry->priority >= nMinPriority) + { + entry->paused = true; + idsWithSelectors->addObject(entry->target); + } + } + } + + if(nMinPriority <= 0) + { + DL_FOREACH_SAFE( m_pUpdates0List, entry, tmp ) + { + entry->paused = true; + idsWithSelectors->addObject(entry->target); + } + } + + DL_FOREACH_SAFE( m_pUpdatesPosList, entry, tmp ) + { + if(entry->priority >= nMinPriority) + { + entry->paused = true; + idsWithSelectors->addObject(entry->target); + } + } + + return idsWithSelectors; +} + +void CCScheduler::resumeTargets(CCSet* pTargetsToResume) +{ + CCSetIterator iter; + for (iter = pTargetsToResume->begin(); iter != pTargetsToResume->end(); ++iter) + { + resumeTarget(*iter); + } +} + // main loop -void CCScheduler::update(ccTime dt) +void CCScheduler::update(float dt) { m_bUpdateHashLocked = true; @@ -714,7 +795,7 @@ void CCScheduler::update(ccTime dt) // The 'timers' array may change while inside this loop for (elt->timerIndex = 0; elt->timerIndex < elt->timers->num; ++(elt->timerIndex)) { - elt->currentTimer = (CCTimer*)(elt->timers->arr[elt->timerIndex]); + elt->currentTimer = (floatr*)(elt->timers->arr[elt->timerIndex]); elt->currentTimerSalvaged = false; elt->currentTimer->update(dt); diff --git a/cocos2dx/CCScheduler.h b/cocos2dx/CCScheduler.h index ed2e0d6d67..5ae548f980 100644 --- a/cocos2dx/CCScheduler.h +++ b/cocos2dx/CCScheduler.h @@ -32,54 +32,61 @@ THE SOFTWARE. NS_CC_BEGIN +// Priority level reserved for system services. +#define kCCPrioritySystem INT_MIN + +// Minimum priority level for user scheduling. +#define kCCPriorityNonSystemMin (kCCPrioritySystem+1) + +class CCSet; // -// CCTimer +// floatr // /** @brief Light weight timer */ -class CC_DLL CCTimer : public CCObject +class CC_DLL floatr : public CCObject { public: - CCTimer(void); + floatr(void); /** get interval in seconds */ - inline ccTime getInterval(void) { return m_fInterval; } + inline float getInterval(void) { return m_fInterval; } /** set interval in seconds */ - inline void setInterval(ccTime fInterval){ m_fInterval = fInterval; } + inline void setInterval(float fInterval){ m_fInterval = fInterval; } /** Initializes a timer with a target and a selector. */ bool initWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector); /** Initializes a timer with a target, a selector and an interval in seconds, repeat in number of times to repeat, delay in seconds. */ - bool initWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, ccTime fSeconds, unsigned int nRepeat, ccTime fDelay); + bool initWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, float fSeconds, unsigned int nRepeat, float fDelay); /** Initializes a timer with a script callback function and an interval in seconds. */ - bool initWithScriptHandler(int nHandler, ccTime fSeconds); + bool initWithScriptHandler(int nHandler, float fSeconds); /** triggers the timer */ - void update(ccTime dt); + void update(float dt); public: /** Allocates a timer with a target and a selector. */ - static CCTimer* timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector); + static floatr* timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector); /** Allocates a timer with a target, a selector and an interval in seconds. */ - static CCTimer* timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, ccTime fSeconds); + static floatr* timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, float fSeconds); /** Allocates a timer with a script callback function and an interval in seconds. */ - static CCTimer* timerWithScriptHandler(int nHandler, ccTime fSeconds); + static floatr* timerWithScriptHandler(int nHandler, float fSeconds); public: SEL_SCHEDULE m_pfnSelector; - ccTime m_fInterval; + float m_fInterval; protected: CCObject *m_pTarget; - ccTime m_fElapsed; + float m_fElapsed; bool m_bRunForever; bool m_bUseDelay; unsigned int m_nTimesExecuted; unsigned int m_nRepeat; //0 = once, 1 is 2 x executed - ccTime m_fDelay; + float m_fDelay; int m_nScriptHandler; }; @@ -110,7 +117,7 @@ public: CCScheduler(); ~CCScheduler(void); - inline ccTime getTimeScale(void) { return m_fTimeScale; } + inline float getTimeScale(void) { return m_fTimeScale; } /** Modifies the time of all scheduled callbacks. You can use this property to create a 'slow motion' or 'fast forward' effect. Default is 1.0. To create a 'slow motion' effect, use values below 1.0. @@ -118,12 +125,12 @@ public: @since v0.8 @warning It will affect EVERY scheduled selector / action. */ - inline void setTimeScale(ccTime fTimeScale) { m_fTimeScale = fTimeScale; } + inline void setTimeScale(float fTimeScale) { m_fTimeScale = fTimeScale; } /** 'update' the scheduler. You should NEVER call this method, unless you know what you are doing. */ - void update(ccTime dt); + void update(float dt); /** The scheduled method will be called every 'interval' seconds. If paused is YES, then it won't be called until it is resumed. @@ -134,10 +141,10 @@ public: @since v0.99.3, repeat and delay added in v1.1 */ - void scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, ccTime fInterval, bool bPaused, unsigned int repeat, ccTime delay); + void scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, float fInterval, bool bPaused, unsigned int repeat, float delay); /** calls scheduleSelector with kCCRepeatForever and a 0 delay */ - void scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, ccTime fInterval, bool bPaused); + void scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, float fInterval, bool bPaused); /** Schedules the 'update' selector for a given target with a given priority. The 'update' selector will be called every frame. The lower the priority, the earlier it is called. @@ -169,12 +176,18 @@ public: */ void unscheduleAllSelectors(void); + /** Unschedules all selectors from all targets with a minimum priority. + You should only call this with kCCPriorityNonSystemMin or higher. + @since v2.0.0 + */ + void unscheduleAllSelectorsWithMinPriority(int nMinPriority); + /** The scheduled script callback will be called every 'interval' seconds. If paused is YES, then it won't be called until it is resumed. If 'interval' is 0, it will be called every frame. return schedule script entry ID, used for unscheduleScriptFunc(). */ - unsigned int scheduleScriptFunc(unsigned int nHandler, ccTime fInterval, bool bPaused); + unsigned int scheduleScriptFunc(unsigned int nHandler, float fInterval, bool bPaused); /** Unschedule a script entry. */ void unscheduleScriptEntry(unsigned int uScheduleScriptEntryID); @@ -198,6 +211,24 @@ public: */ bool isTargetPaused(CCObject *pTarget); + /** Pause all selectors from all targets. + You should NEVER call this method, unless you know what you are doing. + @since v2.0.0 + */ + CCSet* pauseAllTargets(); + + /** Pause all selectors from all targets with a minimum priority. + You should only call this with kCCPriorityNonSystemMin or higher. + @since v2.0.0 + */ + CCSet* pauseAllTargetsWithMinPriority(int nMinPriority); + + /** Resume selectors on a set of targets. + This can be useful for undoing a call to pauseAllSelectors. + @since v2.0.0 + */ + void resumeTargets(CCSet* targetsToResume); + private: void removeHashElement(struct _hashSelectorEntry *pElement); void removeUpdateFromHash(struct _listEntry *entry); @@ -208,7 +239,7 @@ private: void appendIn(struct _listEntry **ppList, CCObject *pTarget, bool bPaused); protected: - ccTime m_fTimeScale; + float m_fTimeScale; // // "updates with priority" stuff diff --git a/cocos2dx/actions/CCAction.cpp b/cocos2dx/actions/CCAction.cpp index 03c046a684..f63b3d3214 100644 --- a/cocos2dx/actions/CCAction.cpp +++ b/cocos2dx/actions/CCAction.cpp @@ -94,13 +94,13 @@ bool CCAction::isDone() return true; } -void CCAction::step(ccTime dt) +void CCAction::step(float dt) { CC_UNUSED_PARAM(dt); CCLOG("[Action step]. override me"); } -void CCAction::update(ccTime time) +void CCAction::update(float time) { CC_UNUSED_PARAM(time); CCLOG("[Action update]. override me"); @@ -178,7 +178,7 @@ void CCSpeed::stop() CCAction::stop(); } -void CCSpeed::step(ccTime dt) +void CCSpeed::step(float dt) { m_pInnerAction->step(dt * m_fSpeed); } @@ -303,7 +303,7 @@ CCObject *CCFollow::copyWithZone(CCZone *pZone) CC_SAFE_DELETE(pNewZone); return pRet; } -void CCFollow::step(ccTime dt) +void CCFollow::step(float dt) { CC_UNUSED_PARAM(dt); diff --git a/cocos2dx/actions/CCAction.h b/cocos2dx/actions/CCAction.h index 76c4162d58..62cd64f3b5 100644 --- a/cocos2dx/actions/CCAction.h +++ b/cocos2dx/actions/CCAction.h @@ -28,6 +28,7 @@ THE SOFTWARE. #define __ACTIONS_CCACTION_H__ #include "CCObject.h" +#include "CCGeometry.h" NS_CC_BEGIN @@ -62,7 +63,7 @@ public: virtual void stop(void); //! called every frame with it's delta time. DON'T override unless you know what you are doing. - virtual void step(ccTime dt); + virtual void step(float dt); /** called once per frame. time a value between 0 and 1 @@ -72,7 +73,7 @@ public: - 0.5 means that the action is in the middle - 1 means that the action is over */ - virtual void update(ccTime time); + virtual void update(float time); inline CCNode* getTarget(void) { return m_pTarget; } /** The action will modify the target properties. */ @@ -122,15 +123,15 @@ public: {} virtual ~CCFiniteTimeAction(){} //! get duration in seconds of the action - inline ccTime getDuration(void) { return m_fDuration; } + inline float getDuration(void) { return m_fDuration; } //! set duration in seconds of the action - inline void setDuration(ccTime duration) { m_fDuration = duration; } + inline void setDuration(float duration) { m_fDuration = duration; } /** returns a reversed action */ virtual CCFiniteTimeAction* reverse(void); protected: //! duration in seconds - ccTime m_fDuration; + float m_fDuration; }; class CCActionInterval; @@ -161,7 +162,7 @@ public: virtual CCObject* copyWithZone(CCZone *pZone); virtual void startWithTarget(CCNode* pTarget); virtual void stop(); - virtual void step(ccTime dt); + virtual void step(float dt); virtual bool isDone(void); virtual CCActionInterval* reverse(void); @@ -181,10 +182,6 @@ protected: CCActionInterval *m_pInnerAction; }; - -class CCNode; -class CCPoint; -class CCRect; /** @brief CCFollow is an action that "follows" a node. @@ -219,7 +216,7 @@ public: bool initWithTarget(CCNode *pFollowedNode, const CCRect& rect); virtual CCObject* copyWithZone(CCZone *pZone); - virtual void step(ccTime dt); + virtual void step(float dt); virtual bool isDone(void); virtual void stop(void); diff --git a/cocos2dx/actions/CCActionCamera.cpp b/cocos2dx/actions/CCActionCamera.cpp index aabc9e065d..2f279cc689 100644 --- a/cocos2dx/actions/CCActionCamera.cpp +++ b/cocos2dx/actions/CCActionCamera.cpp @@ -116,7 +116,7 @@ void CCOrbitCamera::startWithTarget(CCNode *pTarget) m_fRadX = (CCFloat)CC_DEGREES_TO_RADIANS(m_fAngleX); } -void CCOrbitCamera::update(ccTime dt) +void CCOrbitCamera::update(float dt) { float r = (m_fRadius + m_fDeltaRadius * dt) * CCCamera::getZEye(); float za = m_fRadZ + m_fRadDeltaZ * dt; diff --git a/cocos2dx/actions/CCActionCamera.h b/cocos2dx/actions/CCActionCamera.h index b4be84de88..fc4d6459d2 100644 --- a/cocos2dx/actions/CCActionCamera.h +++ b/cocos2dx/actions/CCActionCamera.h @@ -96,7 +96,7 @@ public: // super methods virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); protected: float m_fRadius; diff --git a/cocos2dx/actions/CCActionCatmullRom.cpp b/cocos2dx/actions/CCActionCatmullRom.cpp new file mode 100644 index 0000000000..7a4d3339dd --- /dev/null +++ b/cocos2dx/actions/CCActionCatmullRom.cpp @@ -0,0 +1,415 @@ +/* + * Copyright (c) 2010-2012 cocos2d-x.org + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2008 Radu Gruian + * + * Copyright (c) 2011 Vit Valentin + * + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * + * Orignal code by Radu Gruian: http://www.codeproject.com/Articles/30838/Overhauser-Catmull-Rom-Splines-for-Camera-Animatio.So + * + * Adapted to cocos2d-x by Vit Valentin + * + * Adapted from cocos2d-x to cocos2d-iphone by Ricardo Quesada + */ +#include "ccMacros.h" +#include "support/CCPointExtension.h" +#include "CCActionCatmullRom.h" + +NS_CC_BEGIN; + +/* + * Implementation of CCPointArray + */ +CCPointArray* CCPointArray::arrayWithCapacity(unsigned int capacity) +{ + CCPointArray* ret = new CCPointArray(); + if (ret) + { + if (ret->initWithCapacity(capacity)) + { + ret->autorelease(); + } + else + { + delete ret; + ret = NULL; + } + } + + return ret; +} + +bool CCPointArray::initWithCapacity(unsigned int capacity) +{ + m_pControlPoints = new CCArray(capacity); + + return true; +} + +CCObject* CCPointArray::copyWithZone(cocos2d::CCZone *zone) +{ + CCArray *newArray = new CCArray(); + + CCObject* pObj = NULL; + CCARRAY_FOREACH(m_pControlPoints, pObj) + { + newArray->addObject(pObj); + } + + CCPointArray *points = CCPointArray::arrayWithCapacity(10); + points->setControlPoints(newArray); + newArray->release(); + + return points; +} + +CCPointArray::~CCPointArray() +{ + CC_SAFE_RELEASE_NULL(m_pControlPoints); +} + +CCPointArray::CCPointArray() :m_pControlPoints(NULL){} + +void CCPointArray::addControlPoint(CCPoint &controlPoint) +{ + m_pControlPoints->addObject(&controlPoint); +} + +void CCPointArray::insertControlPoint(CCPoint &controlPoint, unsigned int index) +{ + m_pControlPoints->insertObject(&controlPoint, index); +} + +CCPoint CCPointArray::getControlPointAtIndex(unsigned int index) +{ + index = MIN(m_pControlPoints->count()-1, MAX(index, 0)); + CCPoint point = *((CCPoint*)m_pControlPoints->objectAtIndex(index)); + + return point; +} + +void CCPointArray::replaceControlPoint(cocos2d::CCPoint &controlPoint, unsigned int index) +{ + m_pControlPoints->replaceObjectAtIndex(index, &controlPoint); +} + +void CCPointArray::removeControlPointAtIndex(unsigned int index) +{ + m_pControlPoints->removeObjectAtIndex(index); +} + +unsigned int CCPointArray::count() +{ + return m_pControlPoints->count(); +} + +CCPointArray* CCPointArray::reverse() +{ + CCArray *newArray = new CCArray(m_pControlPoints->count()); + for (int i = m_pControlPoints->count()-1; i >= 0; --i) + { + newArray->addObject(m_pControlPoints->objectAtIndex(i)); + } + CCPointArray *config = CCPointArray::arrayWithCapacity(0); + config->setControlPoints(newArray); + + newArray->release(); + + config->autorelease(); + return config; +} + +void CCPointArray::reverseInline() +{ + unsigned int l = m_pControlPoints->count(); + for (unsigned int i = 0; i < l/2; ++i) + { + m_pControlPoints->exchangeObjectAtIndex(i, l-i-1); + } +} + +// CatmullRom Spline formula: +inline CCPoint ccCardinalSplineAt(CCPoint &p0, CCPoint &p1, CCPoint &p2, CCPoint &p3, CCFloat tension, float t) +{ + float t2 = t * t; + float t3 = t2 * t; + + /* + * Formula: s(-ttt + 2tt – t)P1 + s(-ttt + tt)P2 + (2ttt – 3tt + 1)P2 + s(ttt – 2tt + t)P3 + (-2ttt + 3tt)P3 + s(ttt – tt)P4 + */ + float s = (1 - tension) / 2; + + float b1 = s * ((-t3 + (2 * t2)) - t); // s(-t3 + 2 t2 – t)P1 + float b2 = s * (-t3 + t2) + (2 * t3 - 3 * t2 + 1); // s(-t3 + t2)P2 + (2 t3 – 3 t2 + 1)P2 + float b3 = s * (t3 - 2 * t2 + t) + (-2 * t3 + 3 * t2); // s(t3 – 2 t2 + t)P3 + (-2 t3 + 3 t2)P3 + float b4 = s * (t3 - t2); // s(t3 – t2)P4 + + float x = (p0.x*b1 + p1.x*b2 + p2.x*b3 + p3.x*b4); + float y = (p0.y*b1 + p1.y*b2 + p2.y*b3 + p3.y*b4); + + return ccp(x,y); +} + +/* Implementation of CCCardinalSplineTo + */ +CCCardinalSplineTo* CCCardinalSplineTo::actionWithDuration(float duration, cocos2d::CCPointArray *points, float tension) +{ + CCCardinalSplineTo *ret = new CCCardinalSplineTo(); + if (ret) + { + if (ret->initWithDuration(duration, points, tension)) + { + ret->autorelease(); + } + else + { + CC_SAFE_RELEASE_NULL(ret); + } + } + + return ret; +} + +bool CCCardinalSplineTo::initWithDuration(float duration, cocos2d::CCPointArray *points, float tension) +{ + CCAssert(points->count() > 0, "Invalid configuration. It must at least have one control point"); + + if (CCActionInterval::initWithDuration(duration)) + { + this->setPoints(points); + this->m_fTension = tension; + + return true; + } + + return false; +} + +CCCardinalSplineTo::~CCCardinalSplineTo() +{ + CC_SAFE_RELEASE_NULL(m_pPoints); +} + +CCCardinalSplineTo::CCCardinalSplineTo() +: m_pPoints(NULL) +, m_fTension(0.f) +, m_fDeltaT(0.f) +{ +} + +void CCCardinalSplineTo::startWithTarget(cocos2d::CCNode *pTarget) +{ + CCActionInterval::startWithTarget(pTarget); + + m_fDeltaT = (float) 1 / m_pPoints->count(); +} + +CCCardinalSplineTo* CCCardinalSplineTo::copyWithZone(cocos2d::CCZone *pZone) +{ + CCCardinalSplineTo *copy = CCCardinalSplineTo::actionWithDuration(this->getDuration(), this->m_pPoints, this->m_fTension); + return copy; +} + +void CCCardinalSplineTo::update(float time) +{ + unsigned int p; + float lt; + + // border + if (time == 1) + { + p = m_pPoints->count() - 1; + lt = 1; + } + else + { + p = time / m_fDeltaT; + lt = (time - m_fDeltaT * (float)p) / m_fDeltaT; + } + + // Interpolate + CCPoint pp0 = m_pPoints->getControlPointAtIndex(p-1); + CCPoint pp1 = m_pPoints->getControlPointAtIndex(p+0); + CCPoint pp2 = m_pPoints->getControlPointAtIndex(p+1); + CCPoint pp3 = m_pPoints->getControlPointAtIndex(p+2); + + CCPoint newPos = ccCardinalSplineAt(pp0, pp1, pp2, pp3, m_fTension, lt); + + this->updatePosition(newPos); +} + +void CCCardinalSplineTo::updatePosition(cocos2d::CCPoint &newPos) +{ + m_pTarget->setPosition(newPos); +} + +CCActionInterval* CCCardinalSplineTo::reverse() +{ + CCPointArray *reverse = m_pPoints->reverse(); + + return CCCardinalSplineTo::actionWithDuration(m_fDuration, reverse, m_fTension); +} + +/* CCCardinalSplineBy + */ + +CCCardinalSplineBy* CCCardinalSplineBy::actionWithDuration(float duration, cocos2d::CCPointArray *points, float tension) +{ + CCCardinalSplineBy *ret = new CCCardinalSplineBy(); + if (ret) + { + if (ret->initWithDuration(duration, points, tension)) + { + ret->autorelease(); + } + else + { + CC_SAFE_RELEASE_NULL(ret); + } + } + + return ret; +} + +CCCardinalSplineBy::CCCardinalSplineBy() : m_startPosition(0,0) +{ +} + +void CCCardinalSplineBy::updatePosition(cocos2d::CCPoint &newPos) +{ + m_pTarget->setPosition(ccpAdd(newPos, m_startPosition)); +} + +CCActionInterval* CCCardinalSplineBy::reverse() +{ + CCPointArray *copyConfig = (CCPointArray*)m_pPoints->copy(); + + // + // convert "absolutes" to "diffs" + // + CCPoint p = copyConfig->getControlPointAtIndex(0); + for (unsigned int i = 1; i < copyConfig->count(); ++i) + { + CCPoint current = copyConfig->getControlPointAtIndex(i); + CCPoint diff = ccpSub(current, p); + copyConfig->replaceControlPoint(diff, i); + + p = current; + } + + + // convert to "diffs" to "reverse absolute" + + CCPointArray *reverse = copyConfig->reverse(); + copyConfig->release(); + + // 1st element (which should be 0,0) should be here too + + p = reverse->getControlPointAtIndex(reverse->count()-1); + reverse->removeControlPointAtIndex(reverse->count()-1); + + p = ccpNeg(p); + reverse->insertControlPoint(p, 0); + + for (unsigned int i = 1; i < reverse->count(); ++i) + { + CCPoint current = reverse->getControlPointAtIndex(i); + current = ccpNeg(current); + CCPoint abs = ccpAdd(current, p); + reverse->replaceControlPoint(abs, i); + + p = abs; + } + + return CCCardinalSplineBy::actionWithDuration(m_fDuration, reverse, m_fTension); +} + +void CCCardinalSplineBy::startWithTarget(cocos2d::CCNode *pTarget) +{ + CCCardinalSplineTo::startWithTarget(pTarget); + m_startPosition = pTarget->getPosition(); +} + +/* CCCatmullRomTo + */ +CCCatmullRomTo* CCCatmullRomTo::actionWithDuration(float dt, cocos2d::CCPointArray *points) +{ + CCCatmullRomTo *ret = new CCCatmullRomTo(); + if (ret) + { + if (ret->initWithDuration(dt, points)) + { + ret->autorelease(); + } + else + { + CC_SAFE_RELEASE_NULL(ret); + } + } + + return ret; +} + +bool CCCatmullRomTo::initWithDuration(float dt, cocos2d::CCPointArray *points) +{ + if (CCCardinalSplineTo::initWithDuration(dt, points, 0.5f)) + { + return true; + } + + return false; +} + +/* CCCatmullRomBy + */ +CCCatmullRomBy* CCCatmullRomBy::actionWithDuration(float dt, cocos2d::CCPointArray *points) +{ + CCCatmullRomBy *ret = new CCCatmullRomBy(); + if (ret) + { + if (ret->initWithDuration(dt, points)) + { + ret->autorelease(); + } + else + { + CC_SAFE_RELEASE_NULL(ret); + } + } + + return ret; +} + +bool CCCatmullRomBy::initWithDuration(float dt, cocos2d::CCPointArray *points) +{ + if (CCCardinalSplineTo::initWithDuration(dt, points, 0.5f)) + { + return true; + } + + return false; +} + +NS_CC_END; + diff --git a/cocos2dx/actions/CCActionCatmullRom.h b/cocos2dx/actions/CCActionCatmullRom.h new file mode 100644 index 0000000000..984f63db78 --- /dev/null +++ b/cocos2dx/actions/CCActionCatmullRom.h @@ -0,0 +1,188 @@ +/* + * Copyright (c) 2012 cocos2d-x.org + * cocos2d for iPhone: http://www.cocos2d-iphone.org + * + * Copyright (c) 2008 Radu Gruian + * + * Copyright (c) 2011 Vit Valentin + * + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + * + * Orignal code by Radu Gruian: http://www.codeproject.com/Articles/30838/Overhauser-Catmull-Rom-Splines-for-Camera-Animatio.So + * + * Adapted to cocos2d-x by Vit Valentin + * + * Adapted from cocos2d-x to cocos2d-iphone by Ricardo Quesada + */ + + +#ifndef __CCACTION_CATMULLROM_H__ +#define __CCACTION_CATMULLROM_H__ + +#include "CCActionInterval.h" +#include "CCNode.h" +#include "CCGeometry.h" + +NS_CC_BEGIN; + +/** An Array that contain control points. + Used by CCCardinalSplineTo and (By) and CCCatmullRomTo (and By) actions. + */ +class CC_DLL CCPointArray : public CCNode +{ +public: + /** creates and initializes a Points array with capacity */ + static CCPointArray* arrayWithCapacity(unsigned int capacity); + + virtual ~CCPointArray(); + CCPointArray(); + + /** initializes a Catmull Rom config with a capacity hint */ + bool initWithCapacity(unsigned int capacity); + + /** appends a control point */ + void addControlPoint(CCPoint &controlPoint); + + /** inserts a controlPoint at index */ + void insertControlPoint(CCPoint &controlPoint, unsigned int index); + + /** replaces an existing controlPoint at index */ + void replaceControlPoint(CCPoint &controlPoint, unsigned int index); + + /** get the value of a controlPoint at a given index */ + CCPoint getControlPointAtIndex(unsigned int index); + + /** deletes a control point at a given index */ + void removeControlPointAtIndex(unsigned int index); + + /** returns the number of objects of the control point array */ + unsigned int count(); + + /** returns a new copy of the array reversed. User is responsible for releasing this copy */ + CCPointArray* reverse(); + + /** reverse the current control point array inline, without generating a new one */ + void reverseInline(); + + virtual CCObject* copyWithZone(CCZone *zone); + + inline CCArray* getControlPoints(){ return m_pControlPoints; } + inline void setControlPoints(CCArray *controlPoints) + { + CC_SAFE_RETAIN(controlPoints); + CC_SAFE_RELEASE(m_pControlPoints); + m_pControlPoints = controlPoints; + } +private: + /** Array that contains the control points */ + CCArray *m_pControlPoints; +}; + +/** Cardinal Spline path. + http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline + */ +class CC_DLL CCCardinalSplineTo : public CCActionInterval +{ +public: + /** creates an action with a Cardinal Spline array of points and tension */ + static CCCardinalSplineTo* actionWithDuration(float duration, CCPointArray* points, float tension); + + virtual ~CCCardinalSplineTo(); + CCCardinalSplineTo(); + + /** initializes the action with a duration and an array of points */ + bool initWithDuration(float duration, CCPointArray* points, float tension); + + // super virtual functions + virtual CCCardinalSplineTo* copyWithZone(CCZone* pZone); + virtual void startWithTarget(CCNode *pTarget); + virtual void update(float time); + virtual CCActionInterval* reverse(); + + virtual void updatePosition(CCPoint &newPos); + + inline CCPointArray* getPoints() { return m_pPoints; } + inline void setPoints(CCPointArray* points) + { + CC_SAFE_RETAIN(points); + CC_SAFE_RELEASE(m_pPoints); + m_pPoints = points; + } + +protected: + /** Array of control points */ + CCPointArray *m_pPoints; + float m_fDeltaT; + float m_fTension; +}; + +/** Cardinal Spline path. + http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline + */ +class CC_DLL CCCardinalSplineBy : public CCCardinalSplineTo +{ +public: + /** creates an action with a Cardinal Spline array of points and tension */ + static CCCardinalSplineBy* actionWithDuration(float duration, CCPointArray* points, float tension); + + CCCardinalSplineBy(); + + virtual void startWithTarget(CCNode *pTarget); + virtual CCActionInterval* reverse(); + virtual void updatePosition(CCPoint &newPos); +protected: + CCPoint m_startPosition; +}; + +/** An action that moves the target with a CatmullRom curve to a destination point. + A Catmull Rom is a Cardinal Spline with a tension of 0.5. + http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline + */ +class CCCatmullRomTo : public CCCardinalSplineTo +{ +public: + /** creates an action with a Cardinal Spline array of points and tension */ + static CCCatmullRomTo* actionWithDuration(float dt, CCPointArray* points); + + /** initializes the action with a duration and an array of points */ + bool initWithDuration(float dt, CCPointArray* points); +}; + +/** An action that moves the target with a CatmullRom curve by a certain distance. + A Catmull Rom is a Cardinal Spline with a tension of 0.5. + http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline + */ +class CC_DLL CCCatmullRomBy : public CCCardinalSplineBy +{ +public: + /** creates an action with a Cardinal Spline array of points and tension */ + static CCCatmullRomBy* actionWithDuration(float dt, CCPointArray* points); + + /** initializes the action with a duration and an array of points */ + bool initWithDuration(float dt, CCPointArray* points); +}; + +/** Returns the Cardinal Spline position for a given set of control points, tension and time */ +extern CCPoint ccCardinalSplineAt(CCPoint &p0, CCPoint &p1, CCPoint &p2, CCPoint &p3, CCFloat tension, float t); + +NS_CC_END; + +#endif // __CCACTION_CATMULLROM_H__ diff --git a/cocos2dx/actions/CCActionEase.cpp b/cocos2dx/actions/CCActionEase.cpp index 4f4bf7a7c7..aebdbfae13 100644 --- a/cocos2dx/actions/CCActionEase.cpp +++ b/cocos2dx/actions/CCActionEase.cpp @@ -115,7 +115,7 @@ void CCActionEase::stop(void) CCActionInterval::stop(); } -void CCActionEase::update(ccTime time) +void CCActionEase::update(float time) { m_pOther->update(time); } @@ -229,7 +229,7 @@ CCObject* CCEaseIn::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseIn::update(ccTime time) +void CCEaseIn::update(float time) { m_pOther->update(powf(time, m_fRate)); } @@ -281,7 +281,7 @@ CCObject* CCEaseOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseOut::update(ccTime time) +void CCEaseOut::update(float time) { m_pOther->update(powf(time, 1 / m_fRate)); } @@ -333,7 +333,7 @@ CCObject* CCEaseInOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseInOut::update(ccTime time) +void CCEaseInOut::update(float time) { time *= 2; if (time < 1) @@ -394,7 +394,7 @@ CCObject* CCEaseExponentialIn::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseExponentialIn::update(ccTime time) +void CCEaseExponentialIn::update(float time) { m_pOther->update(time == 0 ? 0 : powf(2, 10 * (time/1 - 1)) - 1 * 0.001f); } @@ -446,7 +446,7 @@ CCObject* CCEaseExponentialOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseExponentialOut::update(ccTime time) +void CCEaseExponentialOut::update(float time) { m_pOther->update(time == 1 ? 1 : (-powf(2, -10 * time / 1) + 1)); } @@ -498,7 +498,7 @@ CCObject* CCEaseExponentialInOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseExponentialInOut::update(ccTime time) +void CCEaseExponentialInOut::update(float time) { time /= 0.5f; if (time < 1) @@ -560,7 +560,7 @@ CCObject* CCEaseSineIn::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseSineIn::update(ccTime time) +void CCEaseSineIn::update(float time) { m_pOther->update(-1 * cosf(time * (float)M_PI_2) + 1); } @@ -612,7 +612,7 @@ CCObject* CCEaseSineOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseSineOut::update(ccTime time) +void CCEaseSineOut::update(float time) { m_pOther->update(sinf(time * (float)M_PI_2)); } @@ -664,7 +664,7 @@ CCObject* CCEaseSineInOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseSineInOut::update(ccTime time) +void CCEaseSineInOut::update(float time) { m_pOther->update(-0.5f * (cosf((float)M_PI * time) - 1)); } @@ -817,9 +817,9 @@ CCObject* CCEaseElasticIn::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseElasticIn::update(ccTime time) +void CCEaseElasticIn::update(float time) { - ccTime newT = 0; + float newT = 0; if (time == 0 || time == 1) { newT = time; @@ -899,9 +899,9 @@ CCObject *CCEaseElasticOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseElasticOut::update(ccTime time) +void CCEaseElasticOut::update(float time) { - ccTime newT = 0; + float newT = 0; if (time == 0 || time == 1) { newT = time; @@ -981,9 +981,9 @@ CCObject* CCEaseElasticInOut::copyWithZone(CCZone *pZone) } -void CCEaseElasticInOut::update(ccTime time) +void CCEaseElasticInOut::update(float time) { - ccTime newT = 0; + float newT = 0; if (time == 0 || time == 1) { newT = time; @@ -996,7 +996,7 @@ void CCEaseElasticInOut::update(ccTime time) m_fPeriod = 0.3f * 1.5f; } - ccTime s = m_fPeriod / 4; + float s = m_fPeriod / 4; time = time - 1; if (time < 0) @@ -1059,7 +1059,7 @@ CCObject* CCEaseBounce::copyWithZone(CCZone *pZone) return pCopy; } -ccTime CCEaseBounce::bounceTime(ccTime time) +float CCEaseBounce::bounceTime(float time) { if (time < 1 / 2.75) { @@ -1127,9 +1127,9 @@ CCObject* CCEaseBounceIn::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseBounceIn::update(ccTime time) +void CCEaseBounceIn::update(float time) { - ccTime newT = 1 - bounceTime(1 - time); + float newT = 1 - bounceTime(1 - time); m_pOther->update(newT); } @@ -1180,9 +1180,9 @@ CCObject* CCEaseBounceOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseBounceOut::update(ccTime time) +void CCEaseBounceOut::update(float time) { - ccTime newT = bounceTime(time); + float newT = bounceTime(time); m_pOther->update(newT); } @@ -1233,9 +1233,9 @@ CCObject* CCEaseBounceInOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseBounceInOut::update(ccTime time) +void CCEaseBounceInOut::update(float time) { - ccTime newT = 0; + float newT = 0; if (time < 0.5f) { time = time * 2; @@ -1296,9 +1296,9 @@ CCObject* CCEaseBackIn::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseBackIn::update(ccTime time) +void CCEaseBackIn::update(float time) { - ccTime overshoot = 1.70158f; + float overshoot = 1.70158f; m_pOther->update(time * time * ((overshoot + 1) * time - overshoot)); } @@ -1349,9 +1349,9 @@ CCObject* CCEaseBackOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseBackOut::update(ccTime time) +void CCEaseBackOut::update(float time) { - ccTime overshoot = 1.70158f; + float overshoot = 1.70158f; time = time - 1; m_pOther->update(time * time * ((overshoot + 1) * time + overshoot) + 1); @@ -1404,9 +1404,9 @@ CCObject* CCEaseBackInOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCEaseBackInOut::update(ccTime time) +void CCEaseBackInOut::update(float time) { - ccTime overshoot = 1.70158f * 1.525f; + float overshoot = 1.70158f * 1.525f; time = time * 2; if (time < 1) diff --git a/cocos2dx/actions/CCActionEase.h b/cocos2dx/actions/CCActionEase.h index ea2ab39621..05117c8691 100644 --- a/cocos2dx/actions/CCActionEase.h +++ b/cocos2dx/actions/CCActionEase.h @@ -47,7 +47,7 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); virtual void stop(void); - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); public: @@ -91,7 +91,7 @@ protected: class CC_DLL CCEaseIn : public CCEaseRateAction { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); public: @@ -105,7 +105,7 @@ public: class CC_DLL CCEaseOut : public CCEaseRateAction { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(); virtual CCObject* copyWithZone(CCZone* pZone); @@ -120,7 +120,7 @@ public: class CC_DLL CCEaseInOut : public CCEaseRateAction { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCObject* copyWithZone(CCZone* pZone); virtual CCActionInterval* reverse(void); @@ -135,7 +135,7 @@ public: class CC_DLL CCEaseExponentialIn : public CCActionEase { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); @@ -150,7 +150,7 @@ public: class CC_DLL CCEaseExponentialOut : public CCActionEase { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); @@ -166,7 +166,7 @@ public: class CC_DLL CCEaseExponentialInOut : public CCActionEase { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCObject* copyWithZone(CCZone* pZone); virtual CCActionInterval* reverse(); @@ -182,7 +182,7 @@ public: class CC_DLL CCEaseSineIn : public CCActionEase { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); @@ -197,7 +197,7 @@ public: class CC_DLL CCEaseSineOut : public CCActionEase { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); @@ -212,7 +212,7 @@ public: class CC_DLL CCEaseSineInOut : public CCActionEase { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCObject* copyWithZone(CCZone* pZone); virtual CCActionInterval* reverse(); @@ -259,7 +259,7 @@ protected: class CC_DLL CCEaseElasticIn : public CCEaseElastic { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); @@ -278,7 +278,7 @@ public: class CC_DLL CCEaseElasticOut : public CCEaseElastic { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); @@ -297,7 +297,7 @@ public: class CC_DLL CCEaseElasticInOut : public CCEaseElastic { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); @@ -315,7 +315,7 @@ public: class CC_DLL CCEaseBounce : public CCActionEase { public: - ccTime bounceTime(ccTime time); + float bounceTime(float time); virtual CCObject* copyWithZone(CCZone* pZone); virtual CCActionInterval* reverse(); @@ -332,7 +332,7 @@ public: class CC_DLL CCEaseBounceIn : public CCEaseBounce { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); @@ -349,7 +349,7 @@ public: class CC_DLL CCEaseBounceOut : public CCEaseBounce { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); @@ -366,7 +366,7 @@ public: class CC_DLL CCEaseBounceInOut : public CCEaseBounce { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCObject* copyWithZone(CCZone* pZone); virtual CCActionInterval* reverse(); @@ -383,7 +383,7 @@ public: class CC_DLL CCEaseBackIn : public CCActionEase { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); @@ -400,7 +400,7 @@ public: class CC_DLL CCEaseBackOut : public CCActionEase { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); @@ -417,7 +417,7 @@ public: class CC_DLL CCEaseBackInOut : public CCActionEase { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCObject* copyWithZone(CCZone* pZone); virtual CCActionInterval* reverse(); diff --git a/cocos2dx/actions/CCActionGrid.cpp b/cocos2dx/actions/CCActionGrid.cpp index 7ac4ba43b5..f70ff3050f 100644 --- a/cocos2dx/actions/CCActionGrid.cpp +++ b/cocos2dx/actions/CCActionGrid.cpp @@ -30,7 +30,7 @@ THE SOFTWARE. NS_CC_BEGIN // implementation of CCGridAction -CCGridAction* CCGridAction::actionWithSize(const ccGridSize& gridSize, ccTime duration) +CCGridAction* CCGridAction::actionWithSize(const ccGridSize& gridSize, float duration) { CCGridAction *pAction = new CCGridAction(); if (pAction) @@ -48,7 +48,7 @@ CCGridAction* CCGridAction::actionWithSize(const ccGridSize& gridSize, ccTime du return pAction; } -bool CCGridAction::initWithSize(const ccGridSize& gridSize, ccTime duration) +bool CCGridAction::initWithSize(const ccGridSize& gridSize, float duration) { if (CCActionInterval::initWithDuration(duration)) { @@ -181,7 +181,7 @@ void CCTiledGrid3DAction::setTile(const ccGridSize& pos, const ccQuad3& coords) // implementation CCAccelDeccelAmplitude -CCAccelDeccelAmplitude* CCAccelDeccelAmplitude::actionWithAction(CCAction *pAction, ccTime duration) +CCAccelDeccelAmplitude* CCAccelDeccelAmplitude::actionWithAction(CCAction *pAction, float duration) { CCAccelDeccelAmplitude *pRet = new CCAccelDeccelAmplitude(); if (pRet) @@ -199,7 +199,7 @@ CCAccelDeccelAmplitude* CCAccelDeccelAmplitude::actionWithAction(CCAction *pActi return pRet; } -bool CCAccelDeccelAmplitude::initWithAction(CCAction *pAction, ccTime duration) +bool CCAccelDeccelAmplitude::initWithAction(CCAction *pAction, float duration) { if (CCActionInterval::initWithDuration(duration)) { @@ -224,7 +224,7 @@ void CCAccelDeccelAmplitude::startWithTarget(CCNode *pTarget) m_pOther->startWithTarget(pTarget); } -void CCAccelDeccelAmplitude::update(ccTime time) +void CCAccelDeccelAmplitude::update(float time) { float f = time * 2; @@ -244,7 +244,7 @@ CCActionInterval* CCAccelDeccelAmplitude::reverse(void) // implementation of AccelAmplitude -CCAccelAmplitude* CCAccelAmplitude::actionWithAction(CCAction *pAction, ccTime duration) +CCAccelAmplitude* CCAccelAmplitude::actionWithAction(CCAction *pAction, float duration) { CCAccelAmplitude *pRet = new CCAccelAmplitude(); if (pRet) @@ -262,7 +262,7 @@ CCAccelAmplitude* CCAccelAmplitude::actionWithAction(CCAction *pAction, ccTime d return pRet; } -bool CCAccelAmplitude::initWithAction(CCAction *pAction, ccTime duration) +bool CCAccelAmplitude::initWithAction(CCAction *pAction, float duration) { if (CCActionInterval::initWithDuration(duration)) { @@ -287,7 +287,7 @@ void CCAccelAmplitude::startWithTarget(CCNode *pTarget) m_pOther->startWithTarget(pTarget); } -void CCAccelAmplitude::update(ccTime time) +void CCAccelAmplitude::update(float time) { ((CCAccelAmplitude*)(m_pOther))->setAmplitudeRate(powf(time, m_fRate)); m_pOther->update(time); @@ -300,7 +300,7 @@ CCActionInterval* CCAccelAmplitude::reverse(void) // DeccelAmplitude -CCDeccelAmplitude* CCDeccelAmplitude::actionWithAction(CCAction *pAction, ccTime duration) +CCDeccelAmplitude* CCDeccelAmplitude::actionWithAction(CCAction *pAction, float duration) { CCDeccelAmplitude *pRet = new CCDeccelAmplitude(); if (pRet) @@ -318,7 +318,7 @@ CCDeccelAmplitude* CCDeccelAmplitude::actionWithAction(CCAction *pAction, ccTime return pRet; } -bool CCDeccelAmplitude::initWithAction(CCAction *pAction, ccTime duration) +bool CCDeccelAmplitude::initWithAction(CCAction *pAction, float duration) { if (CCActionInterval::initWithDuration(duration)) { @@ -343,7 +343,7 @@ void CCDeccelAmplitude::startWithTarget(CCNode *pTarget) m_pOther->startWithTarget(pTarget); } -void CCDeccelAmplitude::update(ccTime time) +void CCDeccelAmplitude::update(float time) { ((CCDeccelAmplitude*)(m_pOther))->setAmplitudeRate(powf((1 - time), m_fRate)); m_pOther->update(time); diff --git a/cocos2dx/actions/CCActionGrid.h b/cocos2dx/actions/CCActionGrid.h index 3b6850d5ae..bf115c3a6f 100644 --- a/cocos2dx/actions/CCActionGrid.h +++ b/cocos2dx/actions/CCActionGrid.h @@ -41,13 +41,13 @@ public: virtual CCActionInterval* reverse(void); /** initializes the action with size and duration */ - virtual bool initWithSize(const ccGridSize& gridSize, ccTime duration); + virtual bool initWithSize(const ccGridSize& gridSize, float duration); /** returns the grid */ virtual CCGridBase* getGrid(void); public: /** creates the action with size and duration */ - static CCGridAction* actionWithSize(const ccGridSize& gridSize, ccTime duration); + static CCGridAction* actionWithSize(const ccGridSize& gridSize, float duration); protected: ccGridSize m_sGridSize; @@ -71,7 +71,7 @@ public: public: /** creates the action with size and duration */ - static CCGrid3DAction* actionWithSize(const ccGridSize& gridSize, ccTime duration); + static CCGrid3DAction* actionWithSize(const ccGridSize& gridSize, float duration); }; /** @brief Base class for CCTiledGrid3D actions */ @@ -90,7 +90,7 @@ public: public: /** creates the action with size and duration */ - static CCTiledGrid3DAction* actionWithSize(const ccGridSize& gridSize, ccTime duration); + static CCTiledGrid3DAction* actionWithSize(const ccGridSize& gridSize, float duration); }; /** @brief CCAccelDeccelAmplitude action */ @@ -99,10 +99,10 @@ class CC_DLL CCAccelDeccelAmplitude : public CCActionInterval public: virtual ~CCAccelDeccelAmplitude(void); /** initializes the action with an inner action that has the amplitude property, and a duration time */ - bool initWithAction(CCAction *pAction, ccTime duration); + bool initWithAction(CCAction *pAction, float duration); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); /** get amplitude rate */ @@ -112,7 +112,7 @@ public: public: /** creates the action with an inner action that has the amplitude property, and a duration time */ - static CCAccelDeccelAmplitude* actionWithAction(CCAction *pAction, ccTime duration); + static CCAccelDeccelAmplitude* actionWithAction(CCAction *pAction, float duration); protected: float m_fRate; @@ -125,7 +125,7 @@ class CC_DLL CCAccelAmplitude : public CCActionInterval public: ~CCAccelAmplitude(void); /** initializes the action with an inner action that has the amplitude property, and a duration time */ - bool initWithAction(CCAction *pAction, ccTime duration); + bool initWithAction(CCAction *pAction, float duration); /** get amplitude rate */ inline float getRate(void) { return m_fRate; } @@ -133,12 +133,12 @@ public: inline void setRate(float fRate) { m_fRate = fRate; } virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); public: /** creates the action with an inner action that has the amplitude property, and a duration time */ - static CCAccelAmplitude* actionWithAction(CCAction *pAction, ccTime duration); + static CCAccelAmplitude* actionWithAction(CCAction *pAction, float duration); protected: float m_fRate; @@ -151,7 +151,7 @@ class CC_DLL CCDeccelAmplitude : public CCActionInterval public: ~CCDeccelAmplitude(void); /** initializes the action with an inner action that has the amplitude property, and a duration time */ - bool initWithAction(CCAction *pAction, ccTime duration); + bool initWithAction(CCAction *pAction, float duration); /** get amplitude rate */ inline float getRate(void) { return m_fRate; } @@ -159,12 +159,12 @@ public: inline void setRate(float fRate) { m_fRate = fRate; } virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); public: /** creates the action with an inner action that has the amplitude property, and a duration time */ - static CCDeccelAmplitude* actionWithAction(CCAction *pAction, ccTime duration); + static CCDeccelAmplitude* actionWithAction(CCAction *pAction, float duration); protected: float m_fRate; diff --git a/cocos2dx/actions/CCActionGrid3D.cpp b/cocos2dx/actions/CCActionGrid3D.cpp index 578a712aef..1ba7efb92f 100644 --- a/cocos2dx/actions/CCActionGrid3D.cpp +++ b/cocos2dx/actions/CCActionGrid3D.cpp @@ -31,7 +31,7 @@ THE SOFTWARE. NS_CC_BEGIN // implementation of CCWaves3D -CCWaves3D* CCWaves3D::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration) +CCWaves3D* CCWaves3D::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) { CCWaves3D *pAction = new CCWaves3D(); @@ -50,7 +50,7 @@ CCWaves3D* CCWaves3D::actionWithWaves(int wav, float amp, const ccGridSize& grid return pAction; } -bool CCWaves3D::initWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration) +bool CCWaves3D::initWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) { if (CCGrid3DAction::initWithSize(gridSize, duration)) { @@ -88,7 +88,7 @@ CCObject* CCWaves3D::copyWithZone(CCZone *pZone) return pCopy; } -void CCWaves3D::update(ccTime time) +void CCWaves3D::update(float time) { int i, j; for (i = 0; i < m_sGridSize.x + 1; ++i) @@ -105,7 +105,7 @@ void CCWaves3D::update(ccTime time) // implementation of CCFlipX3D -CCFlipX3D* CCFlipX3D::actionWithDuration(ccTime duration) +CCFlipX3D* CCFlipX3D::actionWithDuration(float duration) { CCFlipX3D *pAction = new CCFlipX3D(); @@ -124,12 +124,12 @@ CCFlipX3D* CCFlipX3D::actionWithDuration(ccTime duration) return pAction; } -bool CCFlipX3D::initWithDuration(ccTime duration) +bool CCFlipX3D::initWithDuration(float duration) { return CCGrid3DAction::initWithSize(ccg(1, 1), duration); } -bool CCFlipX3D::initWithSize(const ccGridSize& gridSize, ccTime duration) +bool CCFlipX3D::initWithSize(const ccGridSize& gridSize, float duration) { if (gridSize.x != 1 || gridSize.y != 1) { @@ -165,7 +165,7 @@ CCObject* CCFlipX3D::copyWithZone(CCZone *pZone) return pCopy; } -void CCFlipX3D::update(ccTime time) +void CCFlipX3D::update(float time) { CCFloat angle = (CCFloat)M_PI * time; // 180 degrees CCFloat mz = sinf(angle); @@ -231,7 +231,7 @@ void CCFlipX3D::update(ccTime time) // implementation of FlipY3D -CCFlipY3D* CCFlipY3D::actionWithDuration(ccTime duration) +CCFlipY3D* CCFlipY3D::actionWithDuration(float duration) { CCFlipY3D *pAction = new CCFlipY3D(); @@ -273,7 +273,7 @@ CCObject* CCFlipY3D::copyWithZone(CCZone* pZone) return pCopy; } -void CCFlipY3D::update(ccTime time) +void CCFlipY3D::update(float time) { CCFloat angle = (CCFloat)M_PI * time; // 180 degrees CCFloat mz = sinf( angle ); @@ -340,7 +340,7 @@ void CCFlipY3D::update(ccTime time) // implementation of Lens3D -CCLens3D* CCLens3D::actionWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, ccTime duration) +CCLens3D* CCLens3D::actionWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration) { CCLens3D *pAction = new CCLens3D(); @@ -359,7 +359,7 @@ CCLens3D* CCLens3D::actionWithPosition(const CCPoint& pos, float r, const ccGrid return pAction; } -bool CCLens3D::initWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, ccTime duration) +bool CCLens3D::initWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration) { if (CCGrid3DAction::initWithSize(gridSize, duration)) { @@ -409,7 +409,7 @@ void CCLens3D::setPosition(const CCPoint& pos) } } -void CCLens3D::update(ccTime time) +void CCLens3D::update(float time) { CC_UNUSED_PARAM(time); if (m_bDirty) @@ -454,7 +454,7 @@ void CCLens3D::update(ccTime time) // implementation of Ripple3D -CCRipple3D* CCRipple3D::actionWithPosition(const CCPoint& pos, float r, int wav, float amp, const ccGridSize& gridSize, ccTime duration) +CCRipple3D* CCRipple3D::actionWithPosition(const CCPoint& pos, float r, int wav, float amp, const ccGridSize& gridSize, float duration) { CCRipple3D *pAction = new CCRipple3D(); @@ -473,7 +473,7 @@ CCRipple3D* CCRipple3D::actionWithPosition(const CCPoint& pos, float r, int wav, return pAction; } -bool CCRipple3D::initWithPosition(const CCPoint& pos, float r, int wav, float amp, const ccGridSize& gridSize, ccTime duration) +bool CCRipple3D::initWithPosition(const CCPoint& pos, float r, int wav, float amp, const ccGridSize& gridSize, float duration) { if (CCGrid3DAction::initWithSize(gridSize, duration)) { @@ -519,7 +519,7 @@ CCObject* CCRipple3D::copyWithZone(CCZone *pZone) return pCopy; } -void CCRipple3D::update(ccTime time) +void CCRipple3D::update(float time) { int i, j; @@ -545,7 +545,7 @@ void CCRipple3D::update(ccTime time) // implementation of Shaky3D -CCShaky3D* CCShaky3D::actionWithRange(int range, bool shakeZ, const ccGridSize& gridSize, ccTime duration) +CCShaky3D* CCShaky3D::actionWithRange(int range, bool shakeZ, const ccGridSize& gridSize, float duration) { CCShaky3D *pAction = new CCShaky3D(); @@ -564,7 +564,7 @@ CCShaky3D* CCShaky3D::actionWithRange(int range, bool shakeZ, const ccGridSize& return pAction; } -bool CCShaky3D::initWithRange(int range, bool shakeZ, const ccGridSize& gridSize, ccTime duration) +bool CCShaky3D::initWithRange(int range, bool shakeZ, const ccGridSize& gridSize, float duration) { if (CCGrid3DAction::initWithSize(gridSize, duration)) { @@ -600,7 +600,7 @@ CCObject* CCShaky3D::copyWithZone(CCZone *pZone) return pCopy; } -void CCShaky3D::update(ccTime time) +void CCShaky3D::update(float time) { CC_UNUSED_PARAM(time); int i, j; @@ -624,7 +624,7 @@ void CCShaky3D::update(ccTime time) // implementation of Liquid -CCLiquid* CCLiquid::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration) +CCLiquid* CCLiquid::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) { CCLiquid *pAction = new CCLiquid(); @@ -643,7 +643,7 @@ CCLiquid* CCLiquid::actionWithWaves(int wav, float amp, const ccGridSize& gridSi return pAction; } -bool CCLiquid::initWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration) +bool CCLiquid::initWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) { if (CCGrid3DAction::initWithSize(gridSize, duration)) { @@ -680,7 +680,7 @@ CCObject* CCLiquid::copyWithZone(CCZone *pZone) return pCopy; } -void CCLiquid::update(ccTime time) +void CCLiquid::update(float time) { int i, j; @@ -698,7 +698,7 @@ void CCLiquid::update(ccTime time) // implementation of Waves -CCWaves* CCWaves::actionWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, ccTime duration) +CCWaves* CCWaves::actionWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, float duration) { CCWaves *pAction = new CCWaves(); @@ -717,7 +717,7 @@ CCWaves* CCWaves::actionWithWaves(int wav, float amp, bool h, bool v, const ccGr return pAction; } -bool CCWaves::initWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, ccTime duration) +bool CCWaves::initWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, float duration) { if (CCGrid3DAction::initWithSize(gridSize, duration)) { @@ -756,7 +756,7 @@ CCObject* CCWaves::copyWithZone(CCZone *pZone) return pCopy; } -void CCWaves::update(ccTime time) +void CCWaves::update(float time) { int i, j; @@ -783,7 +783,7 @@ void CCWaves::update(ccTime time) // implementation of Twirl -CCTwirl* CCTwirl::actionWithPosition(CCPoint pos, int t, float amp, const ccGridSize& gridSize, ccTime duration) +CCTwirl* CCTwirl::actionWithPosition(CCPoint pos, int t, float amp, const ccGridSize& gridSize, float duration) { CCTwirl *pAction = new CCTwirl(); @@ -802,7 +802,7 @@ CCTwirl* CCTwirl::actionWithPosition(CCPoint pos, int t, float amp, const ccGrid return pAction; } -bool CCTwirl::initWithPosition(const CCPoint& pos, int t, float amp, const ccGridSize& gridSize, ccTime duration) +bool CCTwirl::initWithPosition(const CCPoint& pos, int t, float amp, const ccGridSize& gridSize, float duration) { if (CCGrid3DAction::initWithSize(gridSize, duration)) { @@ -848,7 +848,7 @@ CCObject* CCTwirl::copyWithZone(CCZone *pZone) return pCopy; } -void CCTwirl::update(ccTime time) +void CCTwirl::update(float time) { int i, j; CCPoint c = m_positionInPixels; diff --git a/cocos2dx/actions/CCActionGrid3D.h b/cocos2dx/actions/CCActionGrid3D.h index a3ac81f0f3..e96f72efbc 100644 --- a/cocos2dx/actions/CCActionGrid3D.h +++ b/cocos2dx/actions/CCActionGrid3D.h @@ -41,14 +41,14 @@ public: inline void setAmplitudeRate(float fAmplitudeRate) { m_fAmplitudeRate = fAmplitudeRate; } /** init the action */ - bool initWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration); + bool initWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** create the action */ - static CCWaves3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration); + static CCWaves3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); protected: int m_nWaves; @@ -61,26 +61,26 @@ class CC_DLL CCFlipX3D : public CCGrid3DAction { public: /** initializes the action with duration */ - bool initWithDuration(ccTime duration); - virtual bool initWithSize(const ccGridSize& gridSize, ccTime duration); + bool initWithDuration(float duration); + virtual bool initWithSize(const ccGridSize& gridSize, float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with duration */ - static CCFlipX3D* actionWithDuration(ccTime duration); + static CCFlipX3D* actionWithDuration(float duration); }; /** @brief CCFlipY3D action */ class CC_DLL CCFlipY3D : public CCFlipX3D { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCObject* copyWithZone(CCZone* pZone); public: /** creates the action with duration */ - static CCFlipY3D* actionWithDuration(ccTime duration); + static CCFlipY3D* actionWithDuration(float duration); }; /** @brief CCLens3D action */ @@ -96,13 +96,13 @@ public: void setPosition(const CCPoint& position); /** initializes the action with center position, radius, a grid size and duration */ - bool initWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, ccTime duration); + bool initWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with center position, radius, a grid size and duration */ - static CCLens3D* actionWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, ccTime duration); + static CCLens3D* actionWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration); protected: /* lens center position */ CCPoint m_position; @@ -133,14 +133,14 @@ public: /** initializes the action with radius, number of waves, amplitude, a grid size and duration */ bool initWithPosition(const CCPoint& pos, float r, int wav, float amp, - const ccGridSize& gridSize, ccTime duration); + const ccGridSize& gridSize, float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with radius, number of waves, amplitude, a grid size and duration */ static CCRipple3D* actionWithPosition(const CCPoint& pos, float r, int wav, float amp, - const ccGridSize& gridSize, ccTime duration); + const ccGridSize& gridSize, float duration); protected: /* center position */ CCPoint m_position; @@ -158,13 +158,13 @@ class CC_DLL CCShaky3D : public CCGrid3DAction { public: /** initializes the action with a range, shake Z vertices, a grid and duration */ - bool initWithRange(int range, bool shakeZ, const ccGridSize& gridSize, ccTime duration); + bool initWithRange(int range, bool shakeZ, const ccGridSize& gridSize, float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with a range, shake Z vertices, a grid and duration */ - static CCShaky3D* actionWithRange(int range, bool shakeZ, const ccGridSize& gridSize, ccTime duration); + static CCShaky3D* actionWithRange(int range, bool shakeZ, const ccGridSize& gridSize, float duration); protected: int m_nRandrange; @@ -182,13 +182,13 @@ public: inline void setAmplitudeRate(float fAmplitudeRate) { m_fAmplitudeRate = fAmplitudeRate; } /** initializes the action with amplitude, a grid and duration */ - bool initWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration); + bool initWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with amplitude, a grid and duration */ - static CCLiquid* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration); + static CCLiquid* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); protected: int m_nWaves; @@ -208,14 +208,14 @@ public: /** initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration */ bool initWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, - ccTime duration); + float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration */ static CCWaves* actionWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, - ccTime duration); + float duration); protected: int m_nWaves; float m_fAmplitude; @@ -241,14 +241,14 @@ public: /** initializes the action with center position, number of twirls, amplitude, a grid size and duration */ bool initWithPosition(const CCPoint& pos, int t, float amp, const ccGridSize& gridSize, - ccTime duration); + float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with center position, number of twirls, amplitude, a grid size and duration */ static CCTwirl* actionWithPosition(CCPoint pos, int t, float amp, const ccGridSize& gridSize, - ccTime duration); + float duration); protected: /* twirl center */ CCPoint m_position; diff --git a/cocos2dx/actions/CCActionInstant.cpp b/cocos2dx/actions/CCActionInstant.cpp index 2782314e4f..d003c0f10c 100644 --- a/cocos2dx/actions/CCActionInstant.cpp +++ b/cocos2dx/actions/CCActionInstant.cpp @@ -56,12 +56,12 @@ bool CCActionInstant::isDone() { return true; } -void CCActionInstant::step(ccTime dt) { +void CCActionInstant::step(float dt) { CC_UNUSED_PARAM(dt); update(1); } -void CCActionInstant::update(ccTime time) { +void CCActionInstant::update(float time) { CC_UNUSED_PARAM(time); // nothing } @@ -83,7 +83,7 @@ CCShow* CCShow::action() { return pRet; } -void CCShow::update(ccTime time) { +void CCShow::update(float time) { CC_UNUSED_PARAM(time); m_pTarget->setIsVisible(true); } @@ -121,7 +121,7 @@ CCHide * CCHide::action() { return pRet; } -void CCHide::update(ccTime time) { +void CCHide::update(float time) { CC_UNUSED_PARAM(time); m_pTarget->setIsVisible(false); } @@ -161,7 +161,7 @@ CCToggleVisibility * CCToggleVisibility::action() return pRet; } -void CCToggleVisibility::update(ccTime time) +void CCToggleVisibility::update(float time) { CC_UNUSED_PARAM(time); m_pTarget->setIsVisible(!m_pTarget->getIsVisible()); @@ -204,7 +204,7 @@ bool CCFlipX::initWithFlipX(bool x) { return true; } -void CCFlipX::update(ccTime time) { +void CCFlipX::update(float time) { CC_UNUSED_PARAM(time); ((CCSprite*) (m_pTarget))->setFlipX(m_bFlipX); } @@ -250,7 +250,7 @@ bool CCFlipY::initWithFlipY(bool y) { return true; } -void CCFlipY::update(ccTime time) { +void CCFlipY::update(float time) { CC_UNUSED_PARAM(time); ((CCSprite*) (m_pTarget))->setFlipY(m_bFlipY); } @@ -313,7 +313,7 @@ CCObject * CCPlace::copyWithZone(CCZone *pZone) { return pRet; } -void CCPlace::update(ccTime time) { +void CCPlace::update(float time) { CC_UNUSED_PARAM(time); m_pTarget->setPosition(m_tPosition); } @@ -370,7 +370,7 @@ CCObject * CCCallFunc::copyWithZone(CCZone *pZone) { return pRet; } -void CCCallFunc::update(ccTime time) { +void CCCallFunc::update(float time) { CC_UNUSED_PARAM(time); this->execute(); } diff --git a/cocos2dx/actions/CCActionInstant.h b/cocos2dx/actions/CCActionInstant.h index 87b0885965..1359e36ee7 100644 --- a/cocos2dx/actions/CCActionInstant.h +++ b/cocos2dx/actions/CCActionInstant.h @@ -44,8 +44,8 @@ public: // CCAction methods virtual CCObject* copyWithZone(CCZone *pZone); virtual bool isDone(void); - virtual void step(ccTime dt); - virtual void update(ccTime time); + virtual void step(float dt); + virtual void update(float time); //CCFiniteTimeAction method virtual CCFiniteTimeAction * reverse(void); }; @@ -58,7 +58,7 @@ public: CCShow(){} virtual ~CCShow(){} //super methods - virtual void update(ccTime time); + virtual void update(float time); virtual CCFiniteTimeAction * reverse(void); virtual CCObject* copyWithZone(CCZone *pZone); public: @@ -78,7 +78,7 @@ public: CCHide(){} virtual ~CCHide(){} //super methods - virtual void update(ccTime time); + virtual void update(float time); virtual CCFiniteTimeAction * reverse(void); virtual CCObject* copyWithZone(CCZone *pZone); public: @@ -95,7 +95,7 @@ public: CCToggleVisibility(){} virtual ~CCToggleVisibility(){} //super method - virtual void update(ccTime time); + virtual void update(float time); virtual CCObject* copyWithZone(CCZone *pZone); public: //override static method @@ -120,7 +120,7 @@ public: /** init the action */ bool initWithFlipX(bool x); //super methods - virtual void update(ccTime time); + virtual void update(float time); virtual CCFiniteTimeAction * reverse(void); virtual CCObject* copyWithZone(CCZone *pZone); @@ -145,7 +145,7 @@ public: /** init the action */ bool initWithFlipY(bool y); //super methods - virtual void update(ccTime time); + virtual void update(float time); virtual CCFiniteTimeAction * reverse(void); virtual CCObject* copyWithZone(CCZone *pZone); @@ -165,7 +165,7 @@ public: /** Initializes a Place action with a position */ bool initWithPosition(const CCPoint& pos); //super methods - virtual void update(ccTime time); + virtual void update(float time); virtual CCObject* copyWithZone(CCZone *pZone); protected: CCPoint m_tPosition; @@ -202,7 +202,7 @@ public: /** executes the callback */ virtual void execute(); //super methods - virtual void update(ccTime time); + virtual void update(float time); CCObject * copyWithZone(CCZone *pZone); inline CCObject* getTargetCallback() diff --git a/cocos2dx/actions/CCActionInterval.cpp b/cocos2dx/actions/CCActionInterval.cpp index 6c6861eda9..347b57e0ae 100644 --- a/cocos2dx/actions/CCActionInterval.cpp +++ b/cocos2dx/actions/CCActionInterval.cpp @@ -38,7 +38,7 @@ NS_CC_BEGIN // // IntervalAction // -CCActionInterval* CCActionInterval::actionWithDuration(ccTime d) +CCActionInterval* CCActionInterval::actionWithDuration(float d) { CCActionInterval *pAction = new CCActionInterval(); pAction->initWithDuration(d); @@ -47,7 +47,7 @@ CCActionInterval* CCActionInterval::actionWithDuration(ccTime d) return pAction; } -bool CCActionInterval::initWithDuration(ccTime d) +bool CCActionInterval::initWithDuration(float d) { m_fDuration = d; @@ -95,7 +95,7 @@ bool CCActionInterval::isDone(void) return m_elapsed >= m_fDuration; } -void CCActionInterval::step(ccTime dt) +void CCActionInterval::step(float dt) { if (m_bFirstTick) { @@ -180,7 +180,7 @@ CCFiniteTimeAction* CCSequence::actions(CCFiniteTimeAction *pAction1, ...) return pPrev; } -CCFiniteTimeAction* CCSequence::actionsWithArray(CCArray *actions) +CCFiniteTimeAction* CCSequence::actionWithArray(CCArray *actions) { CCFiniteTimeAction* prev = (CCFiniteTimeAction*)actions->objectAtIndex(0); @@ -197,7 +197,7 @@ bool CCSequence::initOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction * CCAssert(pActionOne != NULL, ""); CCAssert(pActionTwo != NULL, ""); - ccTime d = pActionOne->getDuration() + pActionTwo->getDuration(); + float d = pActionOne->getDuration() + pActionTwo->getDuration(); CCActionInterval::initWithDuration(d); m_pActions[0] = pActionOne; @@ -257,10 +257,10 @@ void CCSequence::stop(void) CCActionInterval::stop(); } -void CCSequence::update(ccTime t) +void CCSequence::update(float t) { int found = 0; - ccTime new_t = 0.0f; + float new_t = 0.0f; if( t < m_split ) { // action[0] @@ -324,7 +324,7 @@ CCRepeat* CCRepeat::actionWithAction(CCFiniteTimeAction *pAction, unsigned int t bool CCRepeat::initWithAction(CCFiniteTimeAction *pAction, unsigned int times) { - ccTime d = pAction->getDuration() * times; + float d = pAction->getDuration() * times; if (CCActionInterval::initWithDuration(d)) { @@ -391,7 +391,7 @@ void CCRepeat::stop(void) // issue #80. Instead of hooking step:, hook update: since it can be called by any // container action like CCRepeat, CCSequence, CCEase, etc.. -void CCRepeat::update(ccTime dt) +void CCRepeat::update(float dt) { if (dt >= m_fNextDt) { @@ -495,12 +495,12 @@ void CCRepeatForever::startWithTarget(CCNode* pTarget) m_pInnerAction->startWithTarget(pTarget); } -void CCRepeatForever::step(ccTime dt) +void CCRepeatForever::step(float dt) { m_pInnerAction->step(dt); if (m_pInnerAction->isDone()) { - ccTime diff = m_pInnerAction->getElapsed() - m_pInnerAction->getDuration(); + float diff = m_pInnerAction->getElapsed() - m_pInnerAction->getDuration(); m_pInnerAction->startWithTarget(m_pTarget); // to prevent jerk. issue #390, 1247 m_pInnerAction->step(0.0f); @@ -546,7 +546,7 @@ CCFiniteTimeAction* CCSpawn::actions(CCFiniteTimeAction *pAction1, ...) return pPrev; } -CCFiniteTimeAction* CCSpawn::actionsWithArray(CCArray *actions) +CCFiniteTimeAction* CCSpawn::actionWithArray(CCArray *actions) { CCFiniteTimeAction* prev = (CCFiniteTimeAction*)actions->objectAtIndex(0); @@ -574,8 +574,8 @@ bool CCSpawn:: initOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAct bool bRet = false; - ccTime d1 = pAction1->getDuration(); - ccTime d2 = pAction2->getDuration(); + float d1 = pAction1->getDuration(); + float d2 = pAction2->getDuration(); if (CCActionInterval::initWithDuration(MAX(d1, d2))) { @@ -646,7 +646,7 @@ void CCSpawn::stop(void) CCActionInterval::stop(); } -void CCSpawn::update(ccTime time) +void CCSpawn::update(float time) { if (m_pOne) { @@ -666,7 +666,7 @@ CCActionInterval* CCSpawn::reverse(void) // // RotateTo // -CCRotateTo* CCRotateTo::actionWithDuration(ccTime duration, float fDeltaAngle) +CCRotateTo* CCRotateTo::actionWithDuration(float duration, float fDeltaAngle) { CCRotateTo* pRotateTo = new CCRotateTo(); pRotateTo->initWithDuration(duration, fDeltaAngle); @@ -675,7 +675,7 @@ CCRotateTo* CCRotateTo::actionWithDuration(ccTime duration, float fDeltaAngle) return pRotateTo; } -bool CCRotateTo::initWithDuration(ccTime duration, float fDeltaAngle) +bool CCRotateTo::initWithDuration(float duration, float fDeltaAngle) { if (CCActionInterval::initWithDuration(duration)) { @@ -737,7 +737,7 @@ void CCRotateTo::startWithTarget(CCNode *pTarget) } } -void CCRotateTo::update(ccTime time) +void CCRotateTo::update(float time) { if (m_pTarget) { @@ -748,7 +748,7 @@ void CCRotateTo::update(ccTime time) // // RotateBy // -CCRotateBy* CCRotateBy::actionWithDuration(ccTime duration, float fDeltaAngle) +CCRotateBy* CCRotateBy::actionWithDuration(float duration, float fDeltaAngle) { CCRotateBy *pRotateBy = new CCRotateBy(); pRotateBy->initWithDuration(duration, fDeltaAngle); @@ -757,7 +757,7 @@ CCRotateBy* CCRotateBy::actionWithDuration(ccTime duration, float fDeltaAngle) return pRotateBy; } -bool CCRotateBy::initWithDuration(ccTime duration, float fDeltaAngle) +bool CCRotateBy::initWithDuration(float duration, float fDeltaAngle) { if (CCActionInterval::initWithDuration(duration)) { @@ -797,7 +797,7 @@ void CCRotateBy::startWithTarget(CCNode *pTarget) m_fStartAngle = pTarget->getRotation(); } -void CCRotateBy::update(ccTime time) +void CCRotateBy::update(float time) { // XXX: shall I add % 360 if (m_pTarget) @@ -814,7 +814,7 @@ CCActionInterval* CCRotateBy::reverse(void) // // MoveTo // -CCMoveTo* CCMoveTo::actionWithDuration(ccTime duration, const CCPoint& position) +CCMoveTo* CCMoveTo::actionWithDuration(float duration, const CCPoint& position) { CCMoveTo *pMoveTo = new CCMoveTo(); pMoveTo->initWithDuration(duration, position); @@ -823,7 +823,7 @@ CCMoveTo* CCMoveTo::actionWithDuration(ccTime duration, const CCPoint& position) return pMoveTo; } -bool CCMoveTo::initWithDuration(ccTime duration, const CCPoint& position) +bool CCMoveTo::initWithDuration(float duration, const CCPoint& position) { if (CCActionInterval::initWithDuration(duration)) { @@ -864,7 +864,7 @@ void CCMoveTo::startWithTarget(CCNode *pTarget) m_delta = ccpSub(m_endPosition, m_startPosition); } -void CCMoveTo::update(ccTime time) +void CCMoveTo::update(float time) { if (m_pTarget) { @@ -876,7 +876,7 @@ void CCMoveTo::update(ccTime time) // // MoveBy // -CCMoveBy* CCMoveBy::actionWithDuration(ccTime duration, const CCPoint& position) +CCMoveBy* CCMoveBy::actionWithDuration(float duration, const CCPoint& position) { CCMoveBy *pMoveBy = new CCMoveBy(); pMoveBy->initWithDuration(duration, position); @@ -885,7 +885,7 @@ CCMoveBy* CCMoveBy::actionWithDuration(ccTime duration, const CCPoint& position) return pMoveBy; } -bool CCMoveBy::initWithDuration(ccTime duration, const CCPoint& position) +bool CCMoveBy::initWithDuration(float duration, const CCPoint& position) { if (CCActionInterval::initWithDuration(duration)) { @@ -934,7 +934,7 @@ CCActionInterval* CCMoveBy::reverse(void) // // CCSkewTo // -CCSkewTo* CCSkewTo::actionWithDuration(ccTime t, float sx, float sy) +CCSkewTo* CCSkewTo::actionWithDuration(float t, float sx, float sy) { CCSkewTo *pSkewTo = new CCSkewTo(); if (pSkewTo) @@ -952,7 +952,7 @@ CCSkewTo* CCSkewTo::actionWithDuration(ccTime t, float sx, float sy) return pSkewTo; } -bool CCSkewTo::initWithDuration(ccTime t, float sx, float sy) +bool CCSkewTo::initWithDuration(float t, float sx, float sy) { bool bRet = false; @@ -1039,7 +1039,7 @@ void CCSkewTo::startWithTarget(CCNode *pTarget) } } -void CCSkewTo::update(ccTime t) +void CCSkewTo::update(float t) { m_pTarget->setSkewX(m_fStartSkewX + m_fDeltaX * t); m_pTarget->setSkewY(m_fStartSkewY + m_fDeltaY * t); @@ -1060,7 +1060,7 @@ CCSkewTo::CCSkewTo() // // CCSkewBy // -CCSkewBy* CCSkewBy::actionWithDuration(ccTime t, float sx, float sy) +CCSkewBy* CCSkewBy::actionWithDuration(float t, float sx, float sy) { CCSkewBy *pSkewBy = new CCSkewBy(); if (pSkewBy) @@ -1078,7 +1078,7 @@ CCSkewBy* CCSkewBy::actionWithDuration(ccTime t, float sx, float sy) return pSkewBy; } -bool CCSkewBy::initWithDuration(ccTime t, float deltaSkewX, float deltaSkewY) +bool CCSkewBy::initWithDuration(float t, float deltaSkewX, float deltaSkewY) { bool bRet = false; @@ -1110,7 +1110,7 @@ CCActionInterval* CCSkewBy::reverse() // // JumpBy // -CCJumpBy* CCJumpBy::actionWithDuration(ccTime duration, const CCPoint& position, ccTime height, unsigned int jumps) +CCJumpBy* CCJumpBy::actionWithDuration(float duration, const CCPoint& position, float height, unsigned int jumps) { CCJumpBy *pJumpBy = new CCJumpBy(); pJumpBy->initWithDuration(duration, position, height, jumps); @@ -1119,7 +1119,7 @@ CCJumpBy* CCJumpBy::actionWithDuration(ccTime duration, const CCPoint& position, return pJumpBy; } -bool CCJumpBy::initWithDuration(ccTime duration, const CCPoint& position, ccTime height, unsigned int jumps) +bool CCJumpBy::initWithDuration(float duration, const CCPoint& position, float height, unsigned int jumps) { if (CCActionInterval::initWithDuration(duration)) { @@ -1162,15 +1162,15 @@ void CCJumpBy::startWithTarget(CCNode *pTarget) m_startPosition = pTarget->getPosition(); } -void CCJumpBy::update(ccTime time) +void CCJumpBy::update(float time) { // parabolic jump (since v0.8.2) if (m_pTarget) { - ccTime frac = fmodf(time * m_nJumps, 1.0f); - ccTime y = m_height * 4 * frac * (1 - frac); + float frac = fmodf(time * m_nJumps, 1.0f); + float y = m_height * 4 * frac * (1 - frac); y += m_delta.y * time; - ccTime x = m_delta.x * time; + float x = m_delta.x * time; m_pTarget->setPosition(ccp(m_startPosition.x + x, m_startPosition.y + y)); } } @@ -1184,7 +1184,7 @@ CCActionInterval* CCJumpBy::reverse(void) // // JumpTo // -CCJumpTo* CCJumpTo::actionWithDuration(ccTime duration, const CCPoint& position, ccTime height, int jumps) +CCJumpTo* CCJumpTo::actionWithDuration(float duration, const CCPoint& position, float height, int jumps) { CCJumpTo *pJumpTo = new CCJumpTo(); pJumpTo->initWithDuration(duration, position, height, jumps); @@ -1226,7 +1226,7 @@ void CCJumpTo::startWithTarget(CCNode *pTarget) // ((1 - t) + t)3 = 1 // Expands to¡­ // (1 - t)3 + 3t(1-t)2 + 3t2(1 - t) + t3 = 1 -static inline float bezierat( float a, float b, float c, float d, ccTime t ) +static inline float bezierat( float a, float b, float c, float d, float t ) { return (powf(1-t,3) * a + 3*t*(powf(1-t,2))*b + @@ -1237,7 +1237,7 @@ static inline float bezierat( float a, float b, float c, float d, ccTime t ) // // BezierBy // -CCBezierBy* CCBezierBy::actionWithDuration(ccTime t, const ccBezierConfig& c) +CCBezierBy* CCBezierBy::actionWithDuration(float t, const ccBezierConfig& c) { CCBezierBy *pBezierBy = new CCBezierBy(); pBezierBy->initWithDuration(t, c); @@ -1246,7 +1246,7 @@ CCBezierBy* CCBezierBy::actionWithDuration(ccTime t, const ccBezierConfig& c) return pBezierBy; } -bool CCBezierBy::initWithDuration(ccTime t, const ccBezierConfig& c) +bool CCBezierBy::initWithDuration(float t, const ccBezierConfig& c) { if (CCActionInterval::initWithDuration(t)) { @@ -1286,7 +1286,7 @@ CCObject* CCBezierBy::copyWithZone(CCZone *pZone) return pCopy; } -void CCBezierBy::update(ccTime time) +void CCBezierBy::update(float time) { if (m_pTarget) { @@ -1321,7 +1321,7 @@ CCActionInterval* CCBezierBy::reverse(void) // // BezierTo // -CCBezierTo* CCBezierTo::actionWithDuration(ccTime t, const ccBezierConfig& c) +CCBezierTo* CCBezierTo::actionWithDuration(float t, const ccBezierConfig& c) { CCBezierTo *pBezierTo = new CCBezierTo(); pBezierTo->initWithDuration(t, c); @@ -1364,7 +1364,7 @@ void CCBezierTo::startWithTarget(CCNode *pTarget) // // ScaleTo // -CCScaleTo* CCScaleTo::actionWithDuration(ccTime duration, float s) +CCScaleTo* CCScaleTo::actionWithDuration(float duration, float s) { CCScaleTo *pScaleTo = new CCScaleTo(); pScaleTo->initWithDuration(duration, s); @@ -1373,7 +1373,7 @@ CCScaleTo* CCScaleTo::actionWithDuration(ccTime duration, float s) return pScaleTo; } -bool CCScaleTo::initWithDuration(ccTime duration, float s) +bool CCScaleTo::initWithDuration(float duration, float s) { if (CCActionInterval::initWithDuration(duration)) { @@ -1386,7 +1386,7 @@ bool CCScaleTo::initWithDuration(ccTime duration, float s) return false; } -CCScaleTo* CCScaleTo::actionWithDuration(ccTime duration, float sx, float sy) +CCScaleTo* CCScaleTo::actionWithDuration(float duration, float sx, float sy) { CCScaleTo *pScaleTo = new CCScaleTo(); pScaleTo->initWithDuration(duration, sx, sy); @@ -1395,7 +1395,7 @@ CCScaleTo* CCScaleTo::actionWithDuration(ccTime duration, float sx, float sy) return pScaleTo; } -bool CCScaleTo::initWithDuration(ccTime duration, float sx, float sy) +bool CCScaleTo::initWithDuration(float duration, float sx, float sy) { if (CCActionInterval::initWithDuration(duration)) { @@ -1441,7 +1441,7 @@ void CCScaleTo::startWithTarget(CCNode *pTarget) m_fDeltaY = m_fEndScaleY - m_fStartScaleY; } -void CCScaleTo::update(ccTime time) +void CCScaleTo::update(float time) { if (m_pTarget) { @@ -1453,7 +1453,7 @@ void CCScaleTo::update(ccTime time) // // ScaleBy // -CCScaleBy* CCScaleBy::actionWithDuration(ccTime duration, float s) +CCScaleBy* CCScaleBy::actionWithDuration(float duration, float s) { CCScaleBy *pScaleBy = new CCScaleBy(); pScaleBy->initWithDuration(duration, s); @@ -1462,7 +1462,7 @@ CCScaleBy* CCScaleBy::actionWithDuration(ccTime duration, float s) return pScaleBy; } -CCScaleBy* CCScaleBy::actionWithDuration(ccTime duration, float sx, float sy) +CCScaleBy* CCScaleBy::actionWithDuration(float duration, float sx, float sy) { CCScaleBy *pScaleBy = new CCScaleBy(); pScaleBy->initWithDuration(duration, sx, sy); @@ -1510,7 +1510,7 @@ CCActionInterval* CCScaleBy::reverse(void) // // Blink // -CCBlink* CCBlink::actionWithDuration(ccTime duration, unsigned int uBlinks) +CCBlink* CCBlink::actionWithDuration(float duration, unsigned int uBlinks) { CCBlink *pBlink = new CCBlink(); pBlink->initWithDuration(duration, uBlinks); @@ -1519,7 +1519,7 @@ CCBlink* CCBlink::actionWithDuration(ccTime duration, unsigned int uBlinks) return pBlink; } -bool CCBlink::initWithDuration(ccTime duration, unsigned int uBlinks) +bool CCBlink::initWithDuration(float duration, unsigned int uBlinks) { if (CCActionInterval::initWithDuration(duration)) { @@ -1554,12 +1554,12 @@ CCObject* CCBlink::copyWithZone(CCZone *pZone) return pCopy; } -void CCBlink::update(ccTime time) +void CCBlink::update(float time) { if (m_pTarget && ! isDone()) { - ccTime slice = 1.0f / m_nTimes; - ccTime m = fmodf(time, slice); + float slice = 1.0f / m_nTimes; + float m = fmodf(time, slice); m_pTarget->setIsVisible(m > slice / 2 ? true : false); } } @@ -1573,7 +1573,7 @@ CCActionInterval* CCBlink::reverse(void) // // FadeIn // -CCFadeIn* CCFadeIn::actionWithDuration(ccTime d) +CCFadeIn* CCFadeIn::actionWithDuration(float d) { CCFadeIn* pAction = new CCFadeIn(); @@ -1605,7 +1605,7 @@ CCObject* CCFadeIn::copyWithZone(CCZone *pZone) return pCopy; } -void CCFadeIn::update(ccTime time) +void CCFadeIn::update(float time) { CCRGBAProtocol *pRGBAProtocol = dynamic_cast(m_pTarget); if (pRGBAProtocol) @@ -1623,7 +1623,7 @@ CCActionInterval* CCFadeIn::reverse(void) // // FadeOut // -CCFadeOut* CCFadeOut::actionWithDuration(ccTime d) +CCFadeOut* CCFadeOut::actionWithDuration(float d) { CCFadeOut* pAction = new CCFadeOut(); @@ -1655,7 +1655,7 @@ CCObject* CCFadeOut::copyWithZone(CCZone *pZone) return pCopy; } -void CCFadeOut::update(ccTime time) +void CCFadeOut::update(float time) { CCRGBAProtocol *pRGBAProtocol = dynamic_cast(m_pTarget); if (pRGBAProtocol) @@ -1673,7 +1673,7 @@ CCActionInterval* CCFadeOut::reverse(void) // // FadeTo // -CCFadeTo* CCFadeTo::actionWithDuration(ccTime duration, GLubyte opacity) +CCFadeTo* CCFadeTo::actionWithDuration(float duration, GLubyte opacity) { CCFadeTo *pFadeTo = new CCFadeTo(); pFadeTo->initWithDuration(duration, opacity); @@ -1682,7 +1682,7 @@ CCFadeTo* CCFadeTo::actionWithDuration(ccTime duration, GLubyte opacity) return pFadeTo; } -bool CCFadeTo::initWithDuration(ccTime duration, GLubyte opacity) +bool CCFadeTo::initWithDuration(float duration, GLubyte opacity) { if (CCActionInterval::initWithDuration(duration)) { @@ -1728,7 +1728,7 @@ void CCFadeTo::startWithTarget(CCNode *pTarget) /*m_fromOpacity = pTarget->getOpacity();*/ } -void CCFadeTo::update(ccTime time) +void CCFadeTo::update(float time) { CCRGBAProtocol *pRGBAProtocol = dynamic_cast(m_pTarget); if (pRGBAProtocol) @@ -1741,7 +1741,7 @@ void CCFadeTo::update(ccTime time) // // TintTo // -CCTintTo* CCTintTo::actionWithDuration(ccTime duration, GLubyte red, GLubyte green, GLubyte blue) +CCTintTo* CCTintTo::actionWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue) { CCTintTo *pTintTo = new CCTintTo(); pTintTo->initWithDuration(duration, red, green, blue); @@ -1750,7 +1750,7 @@ CCTintTo* CCTintTo::actionWithDuration(ccTime duration, GLubyte red, GLubyte gre return pTintTo; } -bool CCTintTo::initWithDuration(ccTime duration, GLubyte red, GLubyte green, GLubyte blue) +bool CCTintTo::initWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue) { if (CCActionInterval::initWithDuration(duration)) { @@ -1795,7 +1795,7 @@ void CCTintTo::startWithTarget(CCNode *pTarget) /*m_from = pTarget->getColor();*/ } -void CCTintTo::update(ccTime time) +void CCTintTo::update(float time) { CCRGBAProtocol *pRGBAProtocol = dynamic_cast(m_pTarget); if (pRGBAProtocol) @@ -1809,7 +1809,7 @@ void CCTintTo::update(ccTime time) // // TintBy // -CCTintBy* CCTintBy::actionWithDuration(ccTime duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue) +CCTintBy* CCTintBy::actionWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue) { CCTintBy *pTintBy = new CCTintBy(); pTintBy->initWithDuration(duration, deltaRed, deltaGreen, deltaBlue); @@ -1818,7 +1818,7 @@ CCTintBy* CCTintBy::actionWithDuration(ccTime duration, GLshort deltaRed, GLshor return pTintBy; } -bool CCTintBy::initWithDuration(ccTime duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue) +bool CCTintBy::initWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue) { if (CCActionInterval::initWithDuration(duration)) { @@ -1869,7 +1869,7 @@ void CCTintBy::startWithTarget(CCNode *pTarget) } } -void CCTintBy::update(ccTime time) +void CCTintBy::update(float time) { CCRGBAProtocol *pRGBAProtocol = dynamic_cast(m_pTarget); if (pRGBAProtocol) @@ -1888,7 +1888,7 @@ CCActionInterval* CCTintBy::reverse(void) // // DelayTime // -CCDelayTime* CCDelayTime::actionWithDuration(ccTime d) +CCDelayTime* CCDelayTime::actionWithDuration(float d) { CCDelayTime* pAction = new CCDelayTime(); @@ -1921,7 +1921,7 @@ CCObject* CCDelayTime::copyWithZone(CCZone *pZone) return pCopy; } -void CCDelayTime::update(ccTime time) +void CCDelayTime::update(float time) { CC_UNUSED_PARAM(time); return; @@ -2009,7 +2009,7 @@ void CCReverseTime::stop(void) CCActionInterval::stop(); } -void CCReverseTime::update(ccTime time) +void CCReverseTime::update(float time) { if (m_pOther) { @@ -2134,7 +2134,7 @@ void CCAnimate::stop(void) CCActionInterval::stop(); } -void CCAnimate::update(ccTime t) +void CCAnimate::update(float t) { // if t==1, ignore. Animation should finish with t==1 if( t < 1.0f ) { @@ -2269,7 +2269,7 @@ void CCTargetedAction::stop(void) m_pAction->stop(); } -void CCTargetedAction::update(ccTime time) +void CCTargetedAction::update(float time) { m_pAction->update(time); } diff --git a/cocos2dx/actions/CCActionInterval.h b/cocos2dx/actions/CCActionInterval.h index 9dff69f463..6107ca4c12 100644 --- a/cocos2dx/actions/CCActionInterval.h +++ b/cocos2dx/actions/CCActionInterval.h @@ -57,23 +57,23 @@ class CC_DLL CCActionInterval : public CCFiniteTimeAction { public: /** how many seconds had elapsed since the actions started to run. */ - inline ccTime getElapsed(void) { return m_elapsed; } + inline float getElapsed(void) { return m_elapsed; } /** initializes the action */ - bool initWithDuration(ccTime d); + bool initWithDuration(float d); /** returns true if the action has finished */ virtual bool isDone(void); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void step(ccTime dt); + virtual void step(float dt); virtual void startWithTarget(CCNode *pTarget); /** returns a reversed action */ virtual CCActionInterval* reverse(void); public: /** creates the action */ - static CCActionInterval* actionWithDuration(ccTime d); + static CCActionInterval* actionWithDuration(float d); public: //extension in CCGridAction @@ -81,7 +81,7 @@ public: CCFloat getAmplitudeRate(void); protected: - ccTime m_elapsed; + float m_elapsed; bool m_bFirstTick; }; @@ -98,20 +98,20 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); virtual void stop(void); - virtual void update(ccTime t); + virtual void update(float t); virtual CCActionInterval* reverse(void); public: /** helper constructor to create an array of sequenceable actions */ static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...); /** helper contructor to create an array of sequenceable actions given an array */ - static CCFiniteTimeAction* actionsWithArray(CCArray *actions); + static CCFiniteTimeAction* actionWithArray(CCArray *arrayOfActions); /** creates the action */ static CCSequence* actionOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo); protected: CCFiniteTimeAction *m_pActions[2]; - ccTime m_split; + float m_split; int m_last; }; @@ -129,7 +129,7 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); virtual void stop(void); - virtual void update(ccTime dt); + virtual void update(float dt); virtual bool isDone(void); virtual CCActionInterval* reverse(void); @@ -155,7 +155,7 @@ public: protected: unsigned int m_uTimes; unsigned int m_uTotal; - ccTime m_fNextDt; + float m_fNextDt; bool m_bActionInstant; /** Inner action */ CCFiniteTimeAction *m_pInnerAction; @@ -177,7 +177,7 @@ public: bool initWithAction(CCActionInterval *pAction); virtual CCObject* copyWithZone(CCZone *pZone); virtual void startWithTarget(CCNode* pTarget); - virtual void step(ccTime dt); + virtual void step(float dt); virtual bool isDone(void); virtual CCActionInterval* reverse(void); @@ -218,7 +218,7 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); virtual void stop(void); - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); public: @@ -226,7 +226,7 @@ public: static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...); /** helper contructor to create an array of spawned actions given an array */ - static CCFiniteTimeAction* actionsWithArray(CCArray *actions); + static CCFiniteTimeAction* actionWithArray(CCArray *arrayOfActions); /** creates the Spawn action */ static CCSpawn* actionOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2); @@ -244,15 +244,15 @@ class CC_DLL CCRotateTo : public CCActionInterval { public: /** initializes the action */ - bool initWithDuration(ccTime duration, float fDeltaAngle); + bool initWithDuration(float duration, float fDeltaAngle); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action */ - static CCRotateTo* actionWithDuration(ccTime duration, float fDeltaAngle); + static CCRotateTo* actionWithDuration(float duration, float fDeltaAngle); protected: float m_fDstAngle; @@ -266,16 +266,16 @@ class CC_DLL CCRotateBy : public CCActionInterval { public: /** initializes the action */ - bool initWithDuration(ccTime duration, float fDeltaAngle); + bool initWithDuration(float duration, float fDeltaAngle); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); public: /** creates the action */ - static CCRotateBy* actionWithDuration(ccTime duration, float fDeltaAngle); + static CCRotateBy* actionWithDuration(float duration, float fDeltaAngle); protected: float m_fAngle; @@ -288,15 +288,15 @@ class CC_DLL CCMoveTo : public CCActionInterval { public: /** initializes the action */ - bool initWithDuration(ccTime duration, const CCPoint& position); + bool initWithDuration(float duration, const CCPoint& position); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action */ - static CCMoveTo* actionWithDuration(ccTime duration, const CCPoint& position); + static CCMoveTo* actionWithDuration(float duration, const CCPoint& position); protected: CCPoint m_endPosition; @@ -312,7 +312,7 @@ class CC_DLL CCMoveBy : public CCMoveTo { public: /** initializes the action */ - bool initWithDuration(ccTime duration, const CCPoint& position); + bool initWithDuration(float duration, const CCPoint& position); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); @@ -320,7 +320,7 @@ public: public: /** creates the action */ - static CCMoveBy* actionWithDuration(ccTime duration, const CCPoint& position); + static CCMoveBy* actionWithDuration(float duration, const CCPoint& position); }; /** Skews a CCNode object to given angles by modifying it's skewX and skewY attributes @@ -330,13 +330,13 @@ class CC_DLL CCSkewTo : public CCActionInterval { public: CCSkewTo(); - virtual bool initWithDuration(ccTime t, float sx, float sy); + virtual bool initWithDuration(float t, float sx, float sy); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); public: - static CCSkewTo* actionWithDuration(ccTime t, float sx, float sy); + static CCSkewTo* actionWithDuration(float t, float sx, float sy); protected: float m_fSkewX; @@ -355,12 +355,12 @@ protected: class CC_DLL CCSkewBy : public CCSkewTo { public: - virtual bool initWithDuration(ccTime t, float sx, float sy); + virtual bool initWithDuration(float t, float sx, float sy); virtual void startWithTarget(CCNode *pTarget); virtual CCActionInterval* reverse(void); public: - static CCSkewBy* actionWithDuration(ccTime t, float deltaSkewX, float deltaSkewY); + static CCSkewBy* actionWithDuration(float t, float deltaSkewX, float deltaSkewY); }; /** @brief Moves a CCNode object simulating a parabolic jump movement by modifying it's position attribute. @@ -369,21 +369,21 @@ class CC_DLL CCJumpBy : public CCActionInterval { public: /** initializes the action */ - bool initWithDuration(ccTime duration, const CCPoint& position, ccTime height, unsigned int jumps); + bool initWithDuration(float duration, const CCPoint& position, float height, unsigned int jumps); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); public: /** creates the action */ - static CCJumpBy* actionWithDuration(ccTime duration, const CCPoint& position, ccTime height, unsigned int jumps); + static CCJumpBy* actionWithDuration(float duration, const CCPoint& position, float height, unsigned int jumps); protected: CCPoint m_startPosition; CCPoint m_delta; - ccTime m_height; + float m_height; unsigned int m_nJumps; }; @@ -397,7 +397,7 @@ public: public: /** creates the action */ - static CCJumpTo* actionWithDuration(ccTime duration, const CCPoint& position, ccTime height, int jumps); + static CCJumpTo* actionWithDuration(float duration, const CCPoint& position, float height, int jumps); }; /** @typedef bezier configuration structure @@ -417,16 +417,16 @@ class CC_DLL CCBezierBy : public CCActionInterval { public: /** initializes the action with a duration and a bezier configuration */ - bool initWithDuration(ccTime t, const ccBezierConfig& c); + bool initWithDuration(float t, const ccBezierConfig& c); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); public: /** creates the action with a duration and a bezier configuration */ - static CCBezierBy* actionWithDuration(ccTime t, const ccBezierConfig& c); + static CCBezierBy* actionWithDuration(float t, const ccBezierConfig& c); protected: ccBezierConfig m_sConfig; @@ -444,7 +444,7 @@ public: public: /** creates the action with a duration and a bezier configuration */ - static CCBezierTo* actionWithDuration(ccTime t, const ccBezierConfig& c); + static CCBezierTo* actionWithDuration(float t, const ccBezierConfig& c); }; /** @brief Scales a CCNode object to a zoom factor by modifying it's scale attribute. @@ -454,21 +454,21 @@ class CC_DLL CCScaleTo : public CCActionInterval { public: /** initializes the action with the same scale factor for X and Y */ - bool initWithDuration(ccTime duration, float s); + bool initWithDuration(float duration, float s); /** initializes the action with and X factor and a Y factor */ - bool initWithDuration(ccTime duration, float sx, float sy); + bool initWithDuration(float duration, float sx, float sy); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with the same scale factor for X and Y */ - static CCScaleTo* actionWithDuration(ccTime duration, float s); + static CCScaleTo* actionWithDuration(float duration, float s); /** creates the action with and X factor and a Y factor */ - static CCScaleTo* actionWithDuration(ccTime duration, float sx, float sy); + static CCScaleTo* actionWithDuration(float duration, float sx, float sy); protected: float m_fScaleX; float m_fScaleY; @@ -491,10 +491,10 @@ public: public: /** creates the action with the same scale factor for X and Y */ - static CCScaleBy* actionWithDuration(ccTime duration, float s); + static CCScaleBy* actionWithDuration(float duration, float s); /** creates the action with and X factor and a Y factor */ - static CCScaleBy* actionWithDuration(ccTime duration, float sx, float sy); + static CCScaleBy* actionWithDuration(float duration, float sx, float sy); }; /** @brief Blinks a CCNode object by modifying it's visible attribute @@ -503,15 +503,15 @@ class CC_DLL CCBlink : public CCActionInterval { public: /** initializes the action */ - bool initWithDuration(ccTime duration, unsigned int uBlinks); + bool initWithDuration(float duration, unsigned int uBlinks); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); public: /** creates the action */ - static CCBlink* actionWithDuration(ccTime duration, unsigned int uBlinks); + static CCBlink* actionWithDuration(float duration, unsigned int uBlinks); protected: unsigned int m_nTimes; }; @@ -522,13 +522,13 @@ protected: class CC_DLL CCFadeIn : public CCActionInterval { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); public: /** creates the action */ - static CCFadeIn* actionWithDuration(ccTime d); + static CCFadeIn* actionWithDuration(float d); }; /** @brief Fades Out an object that implements the CCRGBAProtocol protocol. It modifies the opacity from 255 to 0. @@ -537,13 +537,13 @@ public: class CC_DLL CCFadeOut : public CCActionInterval { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); public: /** creates the action */ - static CCFadeOut* actionWithDuration(ccTime d); + static CCFadeOut* actionWithDuration(float d); }; /** @brief Fades an object that implements the CCRGBAProtocol protocol. It modifies the opacity from the current value to a custom one. @@ -553,15 +553,15 @@ class CC_DLL CCFadeTo : public CCActionInterval { public: /** initializes the action with duration and opacity */ - bool initWithDuration(ccTime duration, GLubyte opacity); + bool initWithDuration(float duration, GLubyte opacity); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates an action with duration and opacity */ - static CCFadeTo* actionWithDuration(ccTime duration, GLubyte opacity); + static CCFadeTo* actionWithDuration(float duration, GLubyte opacity); protected: GLubyte m_toOpacity; @@ -576,15 +576,15 @@ class CC_DLL CCTintTo : public CCActionInterval { public: /** initializes the action with duration and color */ - bool initWithDuration(ccTime duration, GLubyte red, GLubyte green, GLubyte blue); + bool initWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates an action with duration and color */ - static CCTintTo* actionWithDuration(ccTime duration, GLubyte red, GLubyte green, GLubyte blue); + static CCTintTo* actionWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue); protected: ccColor3B m_to; @@ -598,16 +598,16 @@ class CC_DLL CCTintBy : public CCActionInterval { public: /** initializes the action with duration and color */ - bool initWithDuration(ccTime duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); + bool initWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); public: /** creates an action with duration and color */ - static CCTintBy* actionWithDuration(ccTime duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); + static CCTintBy* actionWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); protected: GLshort m_deltaR; @@ -624,13 +624,13 @@ protected: class CC_DLL CCDelayTime : public CCActionInterval { public: - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); public: /** creates the action */ - static CCDelayTime* actionWithDuration(ccTime d); + static CCDelayTime* actionWithDuration(float d); }; /** @brief Executes an action in reverse order, from time=duration to time=0 @@ -652,7 +652,7 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); virtual void stop(void); - virtual void update(ccTime time); + virtual void update(float time); virtual CCActionInterval* reverse(void); public: @@ -678,7 +678,7 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); virtual void stop(void); - virtual void update(ccTime t); + virtual void update(float t); virtual CCActionInterval* reverse(void); public: @@ -710,7 +710,7 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); virtual void stop(void); - virtual void update(ccTime time); + virtual void update(float time); /** This is the target that the action will be forced to run with */ CC_SYNTHESIZE_RETAIN(CCNode*, m_pForcedTarget, ForcedTarget); diff --git a/cocos2dx/actions/CCActionManager.cpp b/cocos2dx/actions/CCActionManager.cpp index 5c8b1c477d..f9d0f1b8ff 100644 --- a/cocos2dx/actions/CCActionManager.cpp +++ b/cocos2dx/actions/CCActionManager.cpp @@ -31,6 +31,7 @@ THE SOFTWARE. #include "ccMacros.h" #include "support/data_support/ccCArray.h" #include "support/data_support/uthash.h" +#include "CCSet.h" NS_CC_BEGIN // @@ -139,6 +140,32 @@ void CCActionManager::resumeTarget(CCObject *pTarget) } } +CCSet* CCActionManager::pauseAlllRunningActions() +{ + CCSet *idsWithActions = new CCSet(); + idsWithActions->autorelease(); + + for (tHashElement *element=m_pTargets; element != NULL; element = (tHashElement *)element->hh.next) + { + if (! element->paused) + { + element->paused = true; + idsWithActions->addObject(element->target); + } + } + + return idsWithActions; +} + +void CCActionManager::resumeTargets(cocos2d::CCSet *targetsToResume) +{ + CCSetIterator iter; + for (iter = targetsToResume->begin(); iter != targetsToResume->end(); ++iter) + { + resumeTarget(*iter); + } +} + // run void CCActionManager::addAction(CCAction *pAction, CCNode *pTarget, bool paused) @@ -309,7 +336,7 @@ unsigned int CCActionManager::numberOfRunningActionsInTarget(CCObject *pTarget) } // main loop -void CCActionManager::update(ccTime dt) +void CCActionManager::update(float dt) { for (tHashElement *elt = m_pTargets; elt != NULL; ) { diff --git a/cocos2dx/actions/CCActionManager.h b/cocos2dx/actions/CCActionManager.h index 24b9bcc3e9..1dbd038632 100644 --- a/cocos2dx/actions/CCActionManager.h +++ b/cocos2dx/actions/CCActionManager.h @@ -34,7 +34,7 @@ THE SOFTWARE. NS_CC_BEGIN -#define kCCActionManagerPriority 0 +class CCSet; struct _hashElement; /** @@ -98,6 +98,14 @@ public: /** Resumes the target. All queued actions will be resumed. */ void resumeTarget(CCObject *pTarget); + + /** Pauses all running actions, returning a list of targets whose actions were paused. + */ + CCSet* pauseAlllRunningActions(); + + /** Resume a set of targets (convenience function to reverse a pauseAllRunningActions call) + */ + void resumeTargets(CCSet *targetsToResume); protected: // declared in CCActionManager.m @@ -105,7 +113,7 @@ protected: void removeActionAtIndex(unsigned int uIndex, struct _hashElement *pElement); void deleteHashElement(struct _hashElement *pElement); void actionAllocWithHashElement(struct _hashElement *pElement); - void update(ccTime dt); + void update(float dt); protected: struct _hashElement *m_pTargets; diff --git a/cocos2dx/actions/CCActionPageTurn3D.cpp b/cocos2dx/actions/CCActionPageTurn3D.cpp index 4581153626..064f3cdf00 100644 --- a/cocos2dx/actions/CCActionPageTurn3D.cpp +++ b/cocos2dx/actions/CCActionPageTurn3D.cpp @@ -27,7 +27,7 @@ THE SOFTWARE. NS_CC_BEGIN -CCPageTurn3D* CCPageTurn3D::actionWithSize(const ccGridSize& gridSize, ccTime time) +CCPageTurn3D* CCPageTurn3D::actionWithSize(const ccGridSize& gridSize, float time) { CCPageTurn3D *pAction = new CCPageTurn3D(); @@ -50,7 +50,7 @@ CCPageTurn3D* CCPageTurn3D::actionWithSize(const ccGridSize& gridSize, ccTime ti * Update each tick * Time is the percentage of the way through the duration */ -void CCPageTurn3D::update(ccTime time) +void CCPageTurn3D::update(float time) { float tt = MAX(0, time - 0.25f); float deltaAy = (tt * tt * 500); diff --git a/cocos2dx/actions/CCActionPageTurn3D.h b/cocos2dx/actions/CCActionPageTurn3D.h index 2d00ce92df..7bdb78e9c7 100644 --- a/cocos2dx/actions/CCActionPageTurn3D.h +++ b/cocos2dx/actions/CCActionPageTurn3D.h @@ -40,11 +40,11 @@ NS_CC_BEGIN class CC_DLL CCPageTurn3D : public CCGrid3DAction { public: - virtual void update(ccTime time); + virtual void update(float time); public: /** create the action */ - static CCPageTurn3D* actionWithSize(const ccGridSize& gridSize, ccTime time); + static CCPageTurn3D* actionWithSize(const ccGridSize& gridSize, float time); }; NS_CC_END diff --git a/cocos2dx/actions/CCActionProgressTimer.cpp b/cocos2dx/actions/CCActionProgressTimer.cpp index fcdd62e527..6738ccceb9 100644 --- a/cocos2dx/actions/CCActionProgressTimer.cpp +++ b/cocos2dx/actions/CCActionProgressTimer.cpp @@ -32,7 +32,7 @@ NS_CC_BEGIN // implementation of CCProgressTo -CCProgressTo* CCProgressTo::actionWithDuration(ccTime duration, float fPercent) +CCProgressTo* CCProgressTo::actionWithDuration(float duration, float fPercent) { CCProgressTo *pProgressTo = new CCProgressTo(); pProgressTo->initWithDuration(duration, fPercent); @@ -41,7 +41,7 @@ CCProgressTo* CCProgressTo::actionWithDuration(ccTime duration, float fPercent) return pProgressTo; } -bool CCProgressTo::initWithDuration(ccTime duration, float fPercent) +bool CCProgressTo::initWithDuration(float duration, float fPercent) { if (CCActionInterval::initWithDuration(duration)) { @@ -89,14 +89,14 @@ void CCProgressTo::startWithTarget(CCNode *pTarget) } } -void CCProgressTo::update(ccTime time) +void CCProgressTo::update(float time) { ((kProgressTimerCast)(m_pTarget))->setPercentage(m_fFrom + (m_fTo - m_fFrom) * time); } // implementation of CCProgressFromTo -CCProgressFromTo* CCProgressFromTo::actionWithDuration(ccTime duration, float fFromPercentage, float fToPercentage) +CCProgressFromTo* CCProgressFromTo::actionWithDuration(float duration, float fFromPercentage, float fToPercentage) { CCProgressFromTo *pProgressFromTo = new CCProgressFromTo(); pProgressFromTo->initWithDuration(duration, fFromPercentage, fToPercentage); @@ -105,7 +105,7 @@ CCProgressFromTo* CCProgressFromTo::actionWithDuration(ccTime duration, float fF return pProgressFromTo; } -bool CCProgressFromTo::initWithDuration(ccTime duration, float fFromPercentage, float fToPercentage) +bool CCProgressFromTo::initWithDuration(float duration, float fFromPercentage, float fToPercentage) { if (CCActionInterval::initWithDuration(duration)) { @@ -151,7 +151,7 @@ void CCProgressFromTo::startWithTarget(CCNode *pTarget) CCActionInterval::startWithTarget(pTarget); } -void CCProgressFromTo::update(ccTime time) +void CCProgressFromTo::update(float time) { ((kProgressTimerCast)(m_pTarget))->setPercentage(m_fFrom + (m_fTo - m_fFrom) * time); } diff --git a/cocos2dx/actions/CCActionProgressTimer.h b/cocos2dx/actions/CCActionProgressTimer.h index e2aa1c6779..3ac86890c0 100644 --- a/cocos2dx/actions/CCActionProgressTimer.h +++ b/cocos2dx/actions/CCActionProgressTimer.h @@ -37,15 +37,15 @@ class CC_DLL CCProgressTo : public CCActionInterval { public: /** Initializes with a duration and a percent */ - bool initWithDuration(ccTime duration, float fPercent); + bool initWithDuration(float duration, float fPercent); virtual CCObject* copyWithZone(CCZone *pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); public: /** Creates and initializes with a duration and a percent */ - static CCProgressTo* actionWithDuration(ccTime duration, float fPercent); + static CCProgressTo* actionWithDuration(float duration, float fPercent); protected: float m_fTo; @@ -60,16 +60,16 @@ class CC_DLL CCProgressFromTo : public CCActionInterval { public: /** Initializes the action with a duration, a "from" percentage and a "to" percentage */ - bool initWithDuration(ccTime duration, float fFromPercentage, float fToPercentage); + bool initWithDuration(float duration, float fFromPercentage, float fToPercentage); virtual CCObject* copyWithZone(CCZone *pZone); virtual CCActionInterval* reverse(void); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); public: /** Creates and initializes the action with a duration, a "from" percentage and a "to" percentage */ - static CCProgressFromTo* actionWithDuration(ccTime duration, float fFromPercentage, float fToPercentage); + static CCProgressFromTo* actionWithDuration(float duration, float fFromPercentage, float fToPercentage); protected: float m_fTo; diff --git a/cocos2dx/actions/CCActionTiledGrid.cpp b/cocos2dx/actions/CCActionTiledGrid.cpp index 82060c0f7f..be2d7a2d98 100644 --- a/cocos2dx/actions/CCActionTiledGrid.cpp +++ b/cocos2dx/actions/CCActionTiledGrid.cpp @@ -41,7 +41,7 @@ struct Tile // implementation of ShakyTiles3D -CCShakyTiles3D* CCShakyTiles3D::actionWithRange(int nRange, bool bShakeZ,const ccGridSize& gridSize, ccTime duration) +CCShakyTiles3D* CCShakyTiles3D::actionWithRange(int nRange, bool bShakeZ,const ccGridSize& gridSize, float duration) { CCShakyTiles3D *pAction = new CCShakyTiles3D(); @@ -60,7 +60,7 @@ CCShakyTiles3D* CCShakyTiles3D::actionWithRange(int nRange, bool bShakeZ,const c return pAction; } -bool CCShakyTiles3D::initWithRange(int nRange, bool bShakeZ, const ccGridSize& gridSize, ccTime duration) +bool CCShakyTiles3D::initWithRange(int nRange, bool bShakeZ, const ccGridSize& gridSize, float duration) { if (CCTiledGrid3DAction::initWithSize(gridSize, duration)) { @@ -96,7 +96,7 @@ CCObject* CCShakyTiles3D::copyWithZone(CCZone *pZone) return pCopy; } -void CCShakyTiles3D::update(ccTime time) +void CCShakyTiles3D::update(float time) { CC_UNUSED_PARAM(time); int i, j; @@ -134,7 +134,7 @@ void CCShakyTiles3D::update(ccTime time) // implementation of CCShatteredTiles3D -CCShatteredTiles3D* CCShatteredTiles3D::actionWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize, ccTime duration) +CCShatteredTiles3D* CCShatteredTiles3D::actionWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize, float duration) { CCShatteredTiles3D *pAction = new CCShatteredTiles3D(); @@ -153,7 +153,7 @@ CCShatteredTiles3D* CCShatteredTiles3D::actionWithRange(int nRange, bool bShatte return pAction; } -bool CCShatteredTiles3D::initWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize, ccTime duration) +bool CCShatteredTiles3D::initWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize, float duration) { if (CCTiledGrid3DAction::initWithSize(gridSize, duration)) { @@ -190,7 +190,7 @@ CCObject* CCShatteredTiles3D::copyWithZone(CCZone *pZone) return pCopy; } -void CCShatteredTiles3D::update(ccTime time) +void CCShatteredTiles3D::update(float time) { CC_UNUSED_PARAM(time); int i, j; @@ -233,7 +233,7 @@ void CCShatteredTiles3D::update(ccTime time) // implementation of CCShuffleTiles -CCShuffleTiles* CCShuffleTiles::actionWithSeed(int s, const ccGridSize& gridSize, ccTime duration) +CCShuffleTiles* CCShuffleTiles::actionWithSeed(int s, const ccGridSize& gridSize, float duration) { CCShuffleTiles *pAction = new CCShuffleTiles(); @@ -252,7 +252,7 @@ CCShuffleTiles* CCShuffleTiles::actionWithSeed(int s, const ccGridSize& gridSize return pAction; } -bool CCShuffleTiles::initWithSeed(int s, const ccGridSize& gridSize, ccTime duration) +bool CCShuffleTiles::initWithSeed(int s, const ccGridSize& gridSize, float duration) { if (CCTiledGrid3DAction::initWithSize(gridSize, duration)) { @@ -378,7 +378,7 @@ void CCShuffleTiles::startWithTarget(CCNode *pTarget) } } -void CCShuffleTiles::update(ccTime time) +void CCShuffleTiles::update(float time) { int i, j; @@ -397,7 +397,7 @@ void CCShuffleTiles::update(ccTime time) // implementation of CCFadeOutTRTiles -CCFadeOutTRTiles* CCFadeOutTRTiles::actionWithSize(const ccGridSize& gridSize, ccTime time) +CCFadeOutTRTiles* CCFadeOutTRTiles::actionWithSize(const ccGridSize& gridSize, float time) { CCFadeOutTRTiles *pAction = new CCFadeOutTRTiles(); @@ -416,7 +416,7 @@ CCFadeOutTRTiles* CCFadeOutTRTiles::actionWithSize(const ccGridSize& gridSize, c return pAction; } -float CCFadeOutTRTiles::testFunc(const ccGridSize& pos, ccTime time) +float CCFadeOutTRTiles::testFunc(const ccGridSize& pos, float time) { CCPoint n = ccpMult(ccp((float)m_sGridSize.x, (float)m_sGridSize.y), time); if ((n.x + n.y) == 0.0f) @@ -459,7 +459,7 @@ void CCFadeOutTRTiles::transformTile(const ccGridSize& pos, float distance) setTile(pos, coords); } -void CCFadeOutTRTiles::update(ccTime time) +void CCFadeOutTRTiles::update(float time) { int i, j; @@ -485,7 +485,7 @@ void CCFadeOutTRTiles::update(ccTime time) } // implementation of CCFadeOutBLTiles -CCFadeOutBLTiles* CCFadeOutBLTiles::actionWithSize(const ccGridSize& gridSize, ccTime time) +CCFadeOutBLTiles* CCFadeOutBLTiles::actionWithSize(const ccGridSize& gridSize, float time) { CCFadeOutBLTiles *pAction = new CCFadeOutBLTiles(); @@ -504,7 +504,7 @@ CCFadeOutBLTiles* CCFadeOutBLTiles::actionWithSize(const ccGridSize& gridSize, c return pAction; } -float CCFadeOutBLTiles::testFunc(const ccGridSize& pos, ccTime time) +float CCFadeOutBLTiles::testFunc(const ccGridSize& pos, float time) { CCPoint n = ccpMult(ccp((float)m_sGridSize.x, (float)m_sGridSize.y), (1.0f - time)); if ((pos.x + pos.y) == 0) @@ -517,7 +517,7 @@ float CCFadeOutBLTiles::testFunc(const ccGridSize& pos, ccTime time) // implementation of CCFadeOutUpTiles -CCFadeOutUpTiles* CCFadeOutUpTiles::actionWithSize(const ccGridSize& gridSize, ccTime time) +CCFadeOutUpTiles* CCFadeOutUpTiles::actionWithSize(const ccGridSize& gridSize, float time) { CCFadeOutUpTiles *pAction = new CCFadeOutUpTiles(); @@ -536,7 +536,7 @@ CCFadeOutUpTiles* CCFadeOutUpTiles::actionWithSize(const ccGridSize& gridSize, c return pAction; } -float CCFadeOutUpTiles::testFunc(const ccGridSize& pos, ccTime time) +float CCFadeOutUpTiles::testFunc(const ccGridSize& pos, float time) { CCPoint n = ccpMult(ccp((float)m_sGridSize.x, (float)m_sGridSize.y), time); if (n.y == 0.0f) @@ -561,7 +561,7 @@ void CCFadeOutUpTiles::transformTile(const ccGridSize& pos, float distance) } // implementation of CCFadeOutDownTiles -CCFadeOutDownTiles* CCFadeOutDownTiles::actionWithSize(const ccGridSize& gridSize, ccTime time) +CCFadeOutDownTiles* CCFadeOutDownTiles::actionWithSize(const ccGridSize& gridSize, float time) { CCFadeOutDownTiles *pAction = new CCFadeOutDownTiles(); @@ -580,7 +580,7 @@ CCFadeOutDownTiles* CCFadeOutDownTiles::actionWithSize(const ccGridSize& gridSiz return pAction; } -float CCFadeOutDownTiles::testFunc(const ccGridSize& pos, ccTime time) +float CCFadeOutDownTiles::testFunc(const ccGridSize& pos, float time) { CCPoint n = ccpMult(ccp((float)m_sGridSize.x, (float)m_sGridSize.y), (1.0f - time)); if (pos.y == 0) @@ -592,7 +592,7 @@ float CCFadeOutDownTiles::testFunc(const ccGridSize& pos, ccTime time) } // implementation of TurnOffTiles -CCTurnOffTiles* CCTurnOffTiles::actionWithSize(const ccGridSize& size, ccTime d) +CCTurnOffTiles* CCTurnOffTiles::actionWithSize(const ccGridSize& size, float d) { CCTurnOffTiles* pAction = new CCTurnOffTiles(); if (pAction->initWithSize(size, d)) @@ -606,7 +606,7 @@ CCTurnOffTiles* CCTurnOffTiles::actionWithSize(const ccGridSize& size, ccTime d) return pAction; } -CCTurnOffTiles* CCTurnOffTiles::actionWithSeed(int s, const ccGridSize& gridSize, ccTime duration) +CCTurnOffTiles* CCTurnOffTiles::actionWithSeed(int s, const ccGridSize& gridSize, float duration) { CCTurnOffTiles *pAction = new CCTurnOffTiles(); @@ -625,7 +625,7 @@ CCTurnOffTiles* CCTurnOffTiles::actionWithSeed(int s, const ccGridSize& gridSize return pAction; } -bool CCTurnOffTiles::initWithSeed(int s, const ccGridSize& gridSize, ccTime duration) +bool CCTurnOffTiles::initWithSeed(int s, const ccGridSize& gridSize, float duration) { if (CCTiledGrid3DAction::initWithSize(gridSize, duration)) { @@ -712,7 +712,7 @@ void CCTurnOffTiles::startWithTarget(CCNode *pTarget) shuffle(m_pTilesOrder, m_nTilesCount); } -void CCTurnOffTiles::update(ccTime time) +void CCTurnOffTiles::update(float time) { unsigned int i, l, t; @@ -736,7 +736,7 @@ void CCTurnOffTiles::update(ccTime time) // implementation of CCWavesTiles3D -CCWavesTiles3D* CCWavesTiles3D::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration) +CCWavesTiles3D* CCWavesTiles3D::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) { CCWavesTiles3D *pAction = new CCWavesTiles3D(); @@ -755,7 +755,7 @@ CCWavesTiles3D* CCWavesTiles3D::actionWithWaves(int wav, float amp, const ccGrid return pAction; } -bool CCWavesTiles3D::initWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration) +bool CCWavesTiles3D::initWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) { if (CCTiledGrid3DAction::initWithSize(gridSize, duration)) { @@ -791,7 +791,7 @@ CCObject* CCWavesTiles3D::copyWithZone(CCZone *pZone) return pCopy; } -void CCWavesTiles3D::update(ccTime time) +void CCWavesTiles3D::update(float time) { int i, j; @@ -814,7 +814,7 @@ void CCWavesTiles3D::update(ccTime time) // implementation of CCJumpTiles3D -CCJumpTiles3D* CCJumpTiles3D::actionWithJumps(int j, float amp, const ccGridSize& gridSize, ccTime duration) +CCJumpTiles3D* CCJumpTiles3D::actionWithJumps(int j, float amp, const ccGridSize& gridSize, float duration) { CCJumpTiles3D *pAction = new CCJumpTiles3D(); @@ -833,7 +833,7 @@ CCJumpTiles3D* CCJumpTiles3D::actionWithJumps(int j, float amp, const ccGridSize return pAction; } -bool CCJumpTiles3D::initWithJumps(int j, float amp, const ccGridSize& gridSize, ccTime duration) +bool CCJumpTiles3D::initWithJumps(int j, float amp, const ccGridSize& gridSize, float duration) { if (CCTiledGrid3DAction::initWithSize(gridSize, duration)) { @@ -868,7 +868,7 @@ CCObject* CCJumpTiles3D::copyWithZone(CCZone *pZone) return pCopy; } -void CCJumpTiles3D::update(ccTime time) +void CCJumpTiles3D::update(float time) { int i, j; @@ -903,7 +903,7 @@ void CCJumpTiles3D::update(ccTime time) // implementation of CCSplitRows -CCSplitRows* CCSplitRows::actionWithRows(int nRows, ccTime duration) +CCSplitRows* CCSplitRows::actionWithRows(int nRows, float duration) { CCSplitRows *pAction = new CCSplitRows(); @@ -922,7 +922,7 @@ CCSplitRows* CCSplitRows::actionWithRows(int nRows, ccTime duration) return pAction; } -bool CCSplitRows::initWithRows(int nRows, ccTime duration) +bool CCSplitRows::initWithRows(int nRows, float duration) { m_nRows = nRows; @@ -957,7 +957,7 @@ void CCSplitRows::startWithTarget(CCNode *pTarget) m_winSize = CCDirector::sharedDirector()->getWinSizeInPixels(); } -void CCSplitRows::update(ccTime time) +void CCSplitRows::update(float time) { int j; @@ -982,7 +982,7 @@ void CCSplitRows::update(ccTime time) // implementation of CCSplitCols -CCSplitCols* CCSplitCols::actionWithCols(int nCols, ccTime duration) +CCSplitCols* CCSplitCols::actionWithCols(int nCols, float duration) { CCSplitCols *pAction = new CCSplitCols(); @@ -1001,7 +1001,7 @@ CCSplitCols* CCSplitCols::actionWithCols(int nCols, ccTime duration) return pAction; } -bool CCSplitCols::initWithCols(int nCols, ccTime duration) +bool CCSplitCols::initWithCols(int nCols, float duration) { m_nCols = nCols; return CCTiledGrid3DAction::initWithSize(ccg(nCols, 1), duration); @@ -1034,7 +1034,7 @@ void CCSplitCols::startWithTarget(CCNode *pTarget) m_winSize = CCDirector::sharedDirector()->getWinSizeInPixels(); } -void CCSplitCols::update(ccTime time) +void CCSplitCols::update(float time) { int i; diff --git a/cocos2dx/actions/CCActionTiledGrid.h b/cocos2dx/actions/CCActionTiledGrid.h index ebe5943f2d..93635638c6 100644 --- a/cocos2dx/actions/CCActionTiledGrid.h +++ b/cocos2dx/actions/CCActionTiledGrid.h @@ -34,15 +34,15 @@ class CC_DLL CCShakyTiles3D : public CCTiledGrid3DAction public: /** initializes the action with a range, whether or not to shake Z vertices, a grid size, and duration */ bool initWithRange(int nRange, bool bShakeZ, const ccGridSize& gridSize, - ccTime duration); + float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with a range, whether or not to shake Z vertices, a grid size, and duration */ static CCShakyTiles3D* actionWithRange(int nRange, bool bShakeZ, const ccGridSize& gridSize, - ccTime duration); + float duration); protected: int m_nRandrange; @@ -55,15 +55,15 @@ class CC_DLL CCShatteredTiles3D : public CCTiledGrid3DAction public: /** initializes the action with a range, whether or not to shatter Z vertices, a grid size and duration */ bool initWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize, - ccTime duration); + float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with a range, whether of not to shatter Z vertices, a grid size and duration */ static CCShatteredTiles3D* actionWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize, - ccTime duration); + float duration); protected: int m_nRandrange; @@ -80,18 +80,18 @@ class CC_DLL CCShuffleTiles : public CCTiledGrid3DAction public: ~CCShuffleTiles(void); /** initializes the action with a random seed, the grid size and the duration */ - bool initWithSeed(int s, const ccGridSize& gridSize, ccTime duration); + bool initWithSeed(int s, const ccGridSize& gridSize, float duration); void shuffle(int *pArray, unsigned int nLen); ccGridSize getDelta(const ccGridSize& pos); void placeTile(const ccGridSize& pos, Tile *t); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); virtual CCObject* copyWithZone(CCZone* pZone); public: /** creates the action with a random seed, the grid size and the duration */ - static CCShuffleTiles* actionWithSeed(int s, const ccGridSize& gridSize, ccTime duration); + static CCShuffleTiles* actionWithSeed(int s, const ccGridSize& gridSize, float duration); protected: int m_nSeed; @@ -106,15 +106,15 @@ protected: class CC_DLL CCFadeOutTRTiles : public CCTiledGrid3DAction { public: - virtual float testFunc(const ccGridSize& pos, ccTime time); + virtual float testFunc(const ccGridSize& pos, float time); void turnOnTile(const ccGridSize& pos); void turnOffTile(const ccGridSize& pos); virtual void transformTile(const ccGridSize& pos, float distance); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with the grid size and the duration */ - static CCFadeOutTRTiles* actionWithSize(const ccGridSize& gridSize, ccTime time); + static CCFadeOutTRTiles* actionWithSize(const ccGridSize& gridSize, float time); }; /** @brief CCFadeOutBLTiles action. @@ -123,11 +123,11 @@ public: class CC_DLL CCFadeOutBLTiles : public CCFadeOutTRTiles { public: - virtual float testFunc(const ccGridSize& pos, ccTime time); + virtual float testFunc(const ccGridSize& pos, float time); public: /** creates the action with the grid size and the duration */ - static CCFadeOutBLTiles* actionWithSize(const ccGridSize& gridSize, ccTime time); + static CCFadeOutBLTiles* actionWithSize(const ccGridSize& gridSize, float time); }; /** @brief CCFadeOutUpTiles action. @@ -136,12 +136,12 @@ public: class CC_DLL CCFadeOutUpTiles : public CCFadeOutTRTiles { public: - virtual float testFunc(const ccGridSize& pos, ccTime time); + virtual float testFunc(const ccGridSize& pos, float time); virtual void transformTile(const ccGridSize& pos, float distance); public: /** creates the action with the grid size and the duration */ - static CCFadeOutUpTiles* actionWithSize(const ccGridSize& gridSize, ccTime time); + static CCFadeOutUpTiles* actionWithSize(const ccGridSize& gridSize, float time); }; /** @brief CCFadeOutDownTiles action. @@ -150,11 +150,11 @@ public: class CC_DLL CCFadeOutDownTiles : public CCFadeOutUpTiles { public: - virtual float testFunc(const ccGridSize& pos, ccTime time); + virtual float testFunc(const ccGridSize& pos, float time); public: /** creates the action with the grid size and the duration */ - static CCFadeOutDownTiles* actionWithSize(const ccGridSize& gridSize, ccTime time); + static CCFadeOutDownTiles* actionWithSize(const ccGridSize& gridSize, float time); }; /** @brief CCTurnOffTiles action. @@ -165,20 +165,20 @@ class CC_DLL CCTurnOffTiles : public CCTiledGrid3DAction public: ~CCTurnOffTiles(void); /** initializes the action with a random seed, the grid size and the duration */ - bool initWithSeed(int s, const ccGridSize& gridSize, ccTime duration); + bool initWithSeed(int s, const ccGridSize& gridSize, float duration); void shuffle(int *pArray, unsigned int nLen); void turnOnTile(const ccGridSize& pos); void turnOffTile(const ccGridSize& pos); virtual CCObject* copyWithZone(CCZone* pZone); virtual void startWithTarget(CCNode *pTarget); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with the grid size and the duration */ - static CCTurnOffTiles* actionWithSize(const ccGridSize& size, ccTime d); + static CCTurnOffTiles* actionWithSize(const ccGridSize& size, float d); /** creates the action with a random seed, the grid size and the duration */ - static CCTurnOffTiles* actionWithSeed(int s, const ccGridSize& gridSize, ccTime duration); + static CCTurnOffTiles* actionWithSeed(int s, const ccGridSize& gridSize, float duration); protected: int m_nSeed; @@ -199,14 +199,14 @@ public: inline void setAmplitudeRate(float fAmplitudeRate) { m_fAmplitudeRate = fAmplitudeRate; } /** initializes the action with a number of waves, the waves amplitude, the grid size and the duration */ - bool initWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration); + bool initWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with a number of waves, the waves amplitude, the grid size and the duration */ - static CCWavesTiles3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, ccTime duration); + static CCWavesTiles3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); protected: int m_nWaves; @@ -229,13 +229,13 @@ public: inline void setAmplitudeRate(float fAmplitudeRate) { m_fAmplitudeRate = fAmplitudeRate; } /** initializes the action with the number of jumps, the sin amplitude, the grid size and the duration */ - bool initWithJumps(int j, float amp, const ccGridSize& gridSize, ccTime duration); + bool initWithJumps(int j, float amp, const ccGridSize& gridSize, float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); public: /** creates the action with the number of jumps, the sin amplitude, the grid size and the duration */ - static CCJumpTiles3D* actionWithJumps(int j, float amp, const ccGridSize& gridSize, ccTime duration); + static CCJumpTiles3D* actionWithJumps(int j, float amp, const ccGridSize& gridSize, float duration); protected: int m_nJumps; @@ -248,15 +248,15 @@ class CC_DLL CCSplitRows : public CCTiledGrid3DAction { public : /** initializes the action with the number of rows to split and the duration */ - bool initWithRows(int nRows, ccTime duration); + bool initWithRows(int nRows, float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); virtual void startWithTarget(CCNode *pTarget); public: /** creates the action with the number of rows to split and the duration */ - static CCSplitRows* actionWithRows(int nRows, ccTime duration); + static CCSplitRows* actionWithRows(int nRows, float duration); protected: int m_nRows; @@ -268,15 +268,15 @@ class CC_DLL CCSplitCols : public CCTiledGrid3DAction { public: /** initializes the action with the number of columns to split and the duration */ - bool initWithCols(int nCols, ccTime duration); + bool initWithCols(int nCols, float duration); virtual CCObject* copyWithZone(CCZone* pZone); - virtual void update(ccTime time); + virtual void update(float time); virtual void startWithTarget(CCNode *pTarget); public: /** creates the action with the number of columns to split and the duration */ - static CCSplitCols* actionWithCols(int nCols, ccTime duration); + static CCSplitCols* actionWithCols(int nCols, float duration); protected: int m_nCols; diff --git a/cocos2dx/actions/CCActionTween.cpp b/cocos2dx/actions/CCActionTween.cpp index b0c297569f..b5d57102fa 100644 --- a/cocos2dx/actions/CCActionTween.cpp +++ b/cocos2dx/actions/CCActionTween.cpp @@ -27,7 +27,7 @@ THE SOFTWARE. NS_CC_BEGIN -CCActionTween* CCActionTween::actionWithDuration(ccTime aDuration, const char* key, float from, float to) +CCActionTween* CCActionTween::actionWithDuration(float aDuration, const char* key, float from, float to) { CCActionTween* pRet = new CCActionTween(); if (pRet && pRet->initWithDuration(aDuration, key, from, to)) @@ -41,7 +41,7 @@ CCActionTween* CCActionTween::actionWithDuration(ccTime aDuration, const char* k return pRet; } -bool CCActionTween::initWithDuration(ccTime aDuration, const char* key, float from, float to) +bool CCActionTween::initWithDuration(float aDuration, const char* key, float from, float to) { if (CCActionInterval::initWithDuration(aDuration)) { @@ -61,7 +61,7 @@ void CCActionTween::startWithTarget(CCNode *pTarget) m_fDelta = m_fTo - m_fFrom; } -void CCActionTween::update(ccTime dt) +void CCActionTween::update(float dt) { dynamic_cast(m_pTarget)->updateTweenAction(m_fTo - m_fDelta * (1 - dt), m_strKey.c_str()); } diff --git a/cocos2dx/actions/CCActionTween.h b/cocos2dx/actions/CCActionTween.h index 36a58c63b1..77c85dcf63 100644 --- a/cocos2dx/actions/CCActionTween.h +++ b/cocos2dx/actions/CCActionTween.h @@ -58,13 +58,13 @@ class CCActionTween : public CCActionInterval { public: /** creates an initializes the action with the property name (key), and the from and to parameters. */ - static CCActionTween* actionWithDuration(ccTime aDuration, const char* key, float from, float to); + static CCActionTween* actionWithDuration(float aDuration, const char* key, float from, float to); /** initializes the action with the property name (key), and the from and to parameters. */ - bool initWithDuration(ccTime aDuration, const char* key, float from, float to); + bool initWithDuration(float aDuration, const char* key, float from, float to); void startWithTarget(CCNode *pTarget); - void update(ccTime dt); + void update(float dt); CCActionInterval* reverse(); std::string m_strKey; diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 870dd56578..4722c90f4f 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -72,7 +72,7 @@ CCNode::CCNode(void) , m_bIsRunning(false) , m_pParent(NULL) // "whole screen" objects. like Scenes and Layers, should set isRelativeAnchorPoint to false -, m_bIsRelativeAnchorPoint(true) +, m_bIgnoreAnchorPointForPosition(false) , m_nTag(kCCNodeTagInvalid) // userData is always inited as nil , m_pUserData(NULL) @@ -392,15 +392,18 @@ void CCNode::setParent(CCNode * var) } /// isRelativeAnchorPoint getter -bool CCNode::getIsRelativeAnchorPoint() +bool CCNode::getIgnoreAnchorPointForPosition() { - return m_bIsRelativeAnchorPoint; + return m_bIgnoreAnchorPointForPosition; } /// isRelativeAnchorPoint setter -void CCNode::setIsRelativeAnchorPoint(bool newValue) +void CCNode::setIgnoreAnchorPointForPosition(bool newValue) { - m_bIsRelativeAnchorPoint = newValue; - m_bIsTransformDirty = m_bIsInverseDirty = true; + if (newValue != m_bIgnoreAnchorPointForPosition) + { + m_bIgnoreAnchorPointForPosition = newValue; + m_bIsTransformDirty = m_bIsInverseDirty = true; + } } /// tag getter @@ -923,12 +926,12 @@ void CCNode::schedule(SEL_SCHEDULE selector) this->schedule(selector, 0.0f, kCCRepeatForever, 0.0f); } -void CCNode::schedule(SEL_SCHEDULE selector, ccTime interval) +void CCNode::schedule(SEL_SCHEDULE selector, float interval) { this->schedule(selector, interval, kCCRepeatForever, 0.0f); } -void CCNode::schedule(SEL_SCHEDULE selector, ccTime interval, unsigned int repeat, ccTime delay) +void CCNode::schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay) { CCAssert( selector, "Argument must be non-nil"); CCAssert( interval >=0, "Argument must be positive"); @@ -936,7 +939,7 @@ void CCNode::schedule(SEL_SCHEDULE selector, ccTime interval, unsigned int repea m_pScheduler->scheduleSelector(selector, this, interval, !m_bIsRunning, repeat, delay); } -void CCNode::scheduleOnce(SEL_SCHEDULE selector, ccTime delay) +void CCNode::scheduleOnce(SEL_SCHEDULE selector, float delay) { this->schedule(selector, 0.0f, 0, delay); } @@ -969,20 +972,23 @@ void CCNode::pauseSchedulerAndActions() CCAffineTransform CCNode::nodeToParentTransform(void) { - if ( m_bIsTransformDirty ) { + if (m_bIsTransformDirty) + { // Translate values float x = m_tPosition.x; float y = m_tPosition.y; - if ( !m_bIsRelativeAnchorPoint ) { + if (m_bIgnoreAnchorPointForPosition) + { x += m_tAnchorPointInPoints.x; y += m_tAnchorPointInPoints.y; } // Rotation values float c = 1, s = 0; - if( m_fRotation ) { + if (m_fRotation) + { float radians = -CC_DEGREES_TO_RADIANS(m_fRotation); c = cosf(radians); s = sinf(radians); @@ -993,7 +999,8 @@ CCAffineTransform CCNode::nodeToParentTransform(void) // optimization: // inline anchor point calculation if skew is not needed - if( !needsSkewMatrix && !CCPoint::CCPointEqualToPoint(m_tAnchorPointInPoints, CCPointZero) ) { + if (! needsSkewMatrix && !CCPoint::CCPointEqualToPoint(m_tAnchorPointInPoints, CCPointZero)) + { x += c * -m_tAnchorPointInPoints.x * m_fScaleX + -s * -m_tAnchorPointInPoints.y * m_fScaleY; y += s * -m_tAnchorPointInPoints.x * m_fScaleX + c * -m_tAnchorPointInPoints.y * m_fScaleY; } @@ -1006,15 +1013,18 @@ CCAffineTransform CCNode::nodeToParentTransform(void) // XXX: Try to inline skew // If skew is needed, apply skew and then anchor point - if( needsSkewMatrix ) { + if (needsSkewMatrix) + { CCAffineTransform skewMatrix = CCAffineTransformMake(1.0f, tanf(CC_DEGREES_TO_RADIANS(m_fSkewY)), tanf(CC_DEGREES_TO_RADIANS(m_fSkewX)), 1.0f, 0.0f, 0.0f ); m_tTransform = CCAffineTransformConcat(skewMatrix, m_tTransform); // adjust anchor point - if( ! CCPoint::CCPointEqualToPoint(m_tAnchorPointInPoints, CCPointZero) ) + if (! CCPoint::CCPointEqualToPoint(m_tAnchorPointInPoints, CCPointZero)) + { m_tTransform = CCAffineTransformTranslate(m_tTransform, -m_tAnchorPointInPoints.x, -m_tAnchorPointInPoints.y); + } } m_bIsTransformDirty = false; diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index c83d3d01f3..b4bd9bc09f 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -57,40 +57,6 @@ enum { kCCNodeOnExit }; -#define arrayMakeObjectsPerformSelector(pArray, func, elementType) \ -do { \ - if(pArray && pArray->count() > 0) \ - { \ - CCObject* child; \ - CCARRAY_FOREACH(pArray, child) \ - { \ - elementType pNode = (elementType) child; \ - if(pNode) \ - { \ - pNode->func(); \ - } \ - } \ - } \ -} \ -while(false) - -#define arrayMakeObjectsPerformSelectorWithObject(pArray, func, pObject, elementType) \ -do { \ - if(pArray && pArray->count() > 0) \ - { \ - CCObject* child = NULL; \ - CCARRAY_FOREACH(pArray, child) \ - { \ - elementType pNode = (elementType) child; \ - if(pNode) \ - { \ - pNode->func(pObject); \ - } \ - } \ - } \ -} \ -while(false) - /** @brief CCNode is the main element. Anything thats gets drawn or contains things that get drawn is a CCNode. The most popular CCNodes are: CCScene, CCLayer, CCSprite, CCMenu. @@ -259,11 +225,9 @@ class CC_DLL CCNode : public CCObject /** A weak reference to the parent */ CC_PROPERTY(CCNode *, m_pParent, Parent) - /** If true the transformtions will be relative to it's anchor point. - * Sprites, Labels and any other sizeble object use it have it enabled by default. - * Scenes, Layers and other "whole screen" object don't use it, have it disabled by default. - */ - CC_PROPERTY(bool, m_bIsRelativeAnchorPoint, IsRelativeAnchorPoint) + // If ture, the Anchor Point will be (0,0) when you position the CCNode. + // Used by CCLayer and CCScene + CC_PROPERTY(bool, m_bIgnoreAnchorPointForPosition, IgnoreAnchorPointForPosition); /** A tag used to identify the node easily */ CC_PROPERTY(int, m_nTag, Tag) @@ -544,18 +508,18 @@ public: If the selector is already scheduled, then the interval parameter will be updated without scheduling it again. */ - void schedule(SEL_SCHEDULE selector, ccTime interval); + void schedule(SEL_SCHEDULE selector, float interval); /** repeat will execute the action repeat + 1 times, for a continues action use kCCRepeatForever delay is the amount of time the action will wait before execution */ - void schedule(SEL_SCHEDULE selector, ccTime interval, unsigned int repeat, ccTime delay); + void schedule(SEL_SCHEDULE selector, float interval, unsigned int repeat, float delay); /** Schedules a selector that runs only once, with a delay of 0 or larger */ - void scheduleOnce(SEL_SCHEDULE selector, ccTime delay); + void scheduleOnce(SEL_SCHEDULE selector, float delay); /** unschedules a custom selector.*/ void unschedule(SEL_SCHEDULE selector); diff --git a/cocos2dx/cocoa/CCArray.cpp b/cocos2dx/cocoa/CCArray.cpp index 27c0f40dc4..63ffff4f86 100644 --- a/cocos2dx/cocoa/CCArray.cpp +++ b/cocos2dx/cocoa/CCArray.cpp @@ -253,6 +253,18 @@ bool CCArray::containsObject(CCObject* object) return ccArrayContainsObject(data, object); } +bool CCArray::isEqualToArray(CCArray* otherArray) +{ + for (unsigned int i = 0; i< this->count(); i++) + { + if (!this->objectAtIndex(i)->isEqual(otherArray->objectAtIndex(i))) + { + return false; + } + } + return true; +} + void CCArray::addObject(CCObject* object) { ccArrayAppendObjectWithResize(data, object); @@ -326,6 +338,12 @@ void CCArray::exchangeObjectAtIndex(unsigned int index1, unsigned int index2) ccArraySwapObjectsAtIndexes(data, index1, index2); } +void CCArray::replaceObjectAtIndex(unsigned int index, CCObject* pObject, bool bReleaseObject/* = true*/) +{ + ccArrayInsertObjectAtIndex(data, pObject, index); + ccArrayRemoveObjectAtIndex(data, index+1); +} + void CCArray::reverseObjects() { if (data->num > 1) @@ -352,22 +370,6 @@ CCArray::~CCArray() ccArrayFree(data); } -void CCArray::replaceObjectAtIndex(unsigned int uIndex, CCObject* pObject, bool bReleaseObject/* = true*/) -{ - if (bReleaseObject && uIndex < data->num && data->arr[uIndex] != NULL) - { - data->arr[uIndex]->release(); - } - - data->arr[uIndex] = pObject; - - // add the ref - if (pObject) - { - pObject->retain(); - } -} - CCObject* CCArray::copyWithZone(CCZone* pZone) { CCAssert(pZone == NULL, "CCArray should not be inherited."); diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index 50951cbd87..500cd82585 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -67,6 +67,40 @@ I found that it's not work in C++. So it keep what it's look like in version 1.0 #define CCARRAY_VERIFY_TYPE(__array__, __type__) void(0) #endif +#define arrayMakeObjectsPerformSelector(pArray, func, elementType) \ +do { \ + if(pArray && pArray->count() > 0) \ + { \ + CCObject* child; \ + CCARRAY_FOREACH(pArray, child) \ + { \ + elementType pNode = (elementType) child; \ + if(pNode) \ + { \ + pNode->func(); \ + } \ + } \ + } \ +} \ +while(false) + +#define arrayMakeObjectsPerformSelectorWithObject(pArray, func, pObject, elementType) \ +do { \ + if(pArray && pArray->count() > 0) \ + { \ + CCObject* child = NULL; \ + CCARRAY_FOREACH(pArray, child) \ + { \ + elementType pNode = (elementType) child; \ + if(pNode) \ + { \ + pNode->func(pObject); \ + } \ + } \ + } \ +} \ +while(false) + NS_CC_BEGIN @@ -126,7 +160,8 @@ public: CCObject* randomObject(); /** Returns a Boolean value that indicates whether object is present in array. */ bool containsObject(CCObject* object); - + /** @since 1.1 */ + bool isEqualToArray(CCArray* pOtherArray); // Adding Objects /** Add a certain object */ @@ -159,13 +194,15 @@ public: void exchangeObject(CCObject* object1, CCObject* object2); /** Swap two elements with certain indexes */ void exchangeObjectAtIndex(unsigned int index1, unsigned int index2); + + /** Replace object at index with another object. */ + void replaceObjectAtIndex(unsigned int uIndex, CCObject* pObject, bool bReleaseObject = true); + /** Revers the array */ void reverseObjects(); /* Shrinks the array so the memory footprint corresponds with the number of items */ void reduceMemoryFootprint(); - - void replaceObjectAtIndex(unsigned int uIndex, CCObject* pObject, bool bReleaseObject = true); - + /* override functions */ virtual CCObject* copyWithZone(CCZone* pZone); diff --git a/cocos2dx/cocoa/CCData.cpp b/cocos2dx/cocoa/CCData.cpp index 43cc1a94d6..89b390ce1d 100644 --- a/cocos2dx/cocoa/CCData.cpp +++ b/cocos2dx/cocoa/CCData.cpp @@ -44,9 +44,8 @@ CCData::~CCData(void) CCData* CCData::dataWithContentsOfFile(const string &strPath) { - CCFileData data(strPath.c_str(), "rb"); - unsigned long nSize = data.getSize(); - unsigned char* pBuffer = data.getBuffer(); + unsigned long nSize; + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(strPath.c_str(), "rb", &nSize); if (! pBuffer) { diff --git a/cocos2dx/cocoa/CCGeometry.h b/cocos2dx/cocoa/CCGeometry.h index efc227472a..e6eb7c9740 100644 --- a/cocos2dx/cocoa/CCGeometry.h +++ b/cocos2dx/cocoa/CCGeometry.h @@ -26,12 +26,13 @@ THE SOFTWARE. #define __CCGEMETRY_H__ #include "CCPlatformMacros.h" +#include "CCObject.h" NS_CC_BEGIN typedef float CCFloat; -class CC_DLL CCPoint +class CC_DLL CCPoint : public CCObject { public: float x; @@ -47,7 +48,7 @@ public: static bool CCPointEqualToPoint(const CCPoint& point1, const CCPoint& point2); }; -class CC_DLL CCSize +class CC_DLL CCSize : public CCObject { public: float width; @@ -63,7 +64,7 @@ public: static bool CCSizeEqualToSize(const CCSize& size1, const CCSize& size2); }; -class CC_DLL CCRect +class CC_DLL CCRect : public CCObject { public: CCPoint origin; diff --git a/cocos2dx/cocoa/CCObject.h b/cocos2dx/cocoa/CCObject.h index 47477c5d9f..62fe578710 100644 --- a/cocos2dx/cocoa/CCObject.h +++ b/cocos2dx/cocoa/CCObject.h @@ -25,7 +25,6 @@ THE SOFTWARE. #ifndef __CCOBJECT_H__ #define __CCOBJECT_H__ -#include "ccTypes.h" #include "CCCommon.h" NS_CC_BEGIN @@ -66,20 +65,21 @@ public: unsigned int retainCount(void); virtual bool isEqual(const CCObject* pObject); - virtual void update(ccTime dt) {CC_UNUSED_PARAM(dt);}; + virtual void update(float dt) {CC_UNUSED_PARAM(dt);}; friend class CCAutoreleasePool; }; -typedef void (CCObject::*SEL_SCHEDULE)(ccTime); +typedef void (CCObject::*SEL_SCHEDULE)(float); typedef void (CCObject::*SEL_CallFunc)(); typedef void (CCObject::*SEL_CallFuncN)(CCNode*); typedef void (CCObject::*SEL_CallFuncND)(CCNode*, void*); typedef void (CCObject::*SEL_CallFuncO)(CCObject*); typedef void (CCObject::*SEL_MenuHandler)(CCObject*); typedef void (CCObject::*SEL_EventHandler)(CCEvent*); - +typedef int (CCObject::*SEL_Compare)(CCObject*); + #define schedule_selector(_SELECTOR) (SEL_SCHEDULE)(&_SELECTOR) #define callfunc_selector(_SELECTOR) (SEL_CallFunc)(&_SELECTOR) #define callfuncN_selector(_SELECTOR) (SEL_CallFuncN)(&_SELECTOR) @@ -87,6 +87,7 @@ typedef void (CCObject::*SEL_EventHandler)(CCEvent*); #define callfuncO_selector(_SELECTOR) (SEL_CallFuncO)(&_SELECTOR) #define menu_selector(_SELECTOR) (SEL_MenuHandler)(&_SELECTOR) #define event_selector(_SELECTOR) (SEL_EventHandler)(&_SELECTOR) +#define compare_selector(_SELECTOR) (SEL_Compare)(&_SELECTOR) NS_CC_END diff --git a/cocos2dx/cocoa/CCString.cpp b/cocos2dx/cocoa/CCString.cpp index 16cd420eef..bc3747c21b 100644 --- a/cocos2dx/cocoa/CCString.cpp +++ b/cocos2dx/cocoa/CCString.cpp @@ -185,7 +185,7 @@ CCString* CCString::stringWithContentsOfFile(const char* pszFileName) unsigned long size = 0; unsigned char* pData = 0; CCString* pRet = NULL; - pData = CCFileUtils::getFileData(pszFileName, "rb", &size); + pData = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(pszFileName, "rb", &size); pRet = stringWithData(pData, size); CC_SAFE_DELETE_ARRAY(pData); return pRet; diff --git a/cocos2dx/cocos2d.cpp b/cocos2dx/cocos2d.cpp index 993aec7f80..58f6c1d432 100644 --- a/cocos2dx/cocos2d.cpp +++ b/cocos2dx/cocos2d.cpp @@ -30,7 +30,7 @@ NS_CC_BEGIN const char* cocos2dVersion() { - return "cocos2d-2.0-rc0a-x-2.0"; + return "cocos2d-2.0-rc2-x-2.0"; } NS_CC_END diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.cpp b/cocos2dx/extensions/CCBIReader/CCBReader.cpp index f5108ac668..5da717dd19 100644 --- a/cocos2dx/extensions/CCBIReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCBReader.cpp @@ -76,10 +76,10 @@ CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBFileName, CCObject * } CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize) { - const char * path = CCFileUtils::fullPathFromRelativePath(pCCBFileName); + const char * path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pCCBFileName); unsigned long size = 0; - this->mBytes = CCFileUtils::getFileData(path, "r", &size); + this->mBytes = CCFileUtils::sharedFileUtils()->getFileData(path, "r", &size); this->mCurrentByte = 0; this->mCurrentBit = 0; diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp index c3ffd0b7ce..c830ebe6ae 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp @@ -709,7 +709,7 @@ void CCNodeLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const if(strcmp(pPropertyName, PROPERTY_VISIBLE) == 0) { pNode->setIsVisible(pCheck); } else if(strcmp(pPropertyName, PROPERTY_IGNOREANCHORPOINTFORPOSITION) == 0) { - pNode->setIsRelativeAnchorPoint(!pCheck); + pNode->setIgnoreAnchorPointForPosition(pCheck); } else { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.cpp b/cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.cpp index 5f9a05ca97..ae2ed8364a 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.cpp +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.cpp @@ -80,6 +80,10 @@ CCNodeLoaderLibrary * CCNodeLoaderLibrary::sharedCCNodeLoaderLibrary() { return sSharedCCNodeLoaderLibrary; } +void CCNodeLoaderLibrary::purgeSharedCCNodeLoaderLibrary() { + CC_SAFE_DELETE(sSharedCCNodeLoaderLibrary); +} + CCNodeLoaderLibrary * CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary() { CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::library(); diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.h b/cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.h index de4d908bd5..818e7ae9f0 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.h +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.h @@ -24,6 +24,8 @@ class CC_DLL CCNodeLoaderLibrary : public CCObject { public: static CCNodeLoaderLibrary * sharedCCNodeLoaderLibrary(); + static void purgeSharedCCNodeLoaderLibrary(); + static CCNodeLoaderLibrary * newDefaultCCNodeLoaderLibrary(); }; diff --git a/cocos2dx/extensions/CCBReader/CCBReader.h b/cocos2dx/extensions/CCBReader/CCBReader.h index 19a804b4d3..365da70896 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader.h +++ b/cocos2dx/extensions/CCBReader/CCBReader.h @@ -30,6 +30,8 @@ #include "cocos2d.h" #include "CCBCustomClass.h" +#define CCB_READER_VERSION 2 + NS_CC_EXT_BEGIN /** diff --git a/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp b/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp index 0b0a5e5d14..717ce8c8d8 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp @@ -26,6 +26,8 @@ #include "CCBReader.h" #include "CCBCustomClass.h" +#if CCB_READER_VERSION == 1 + USING_NS_CC; USING_NS_CC_EXT; @@ -705,3 +707,4 @@ CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner) return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner); } +#endif diff --git a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp index 64e1ae0692..eed24d56e2 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp @@ -26,6 +26,8 @@ #include "CCBReader.h" #include "CCBCustomClass.h" +#if CCB_READER_VERSION == 2 + USING_NS_CC; USING_NS_CC_EXT; @@ -378,7 +380,7 @@ void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* node->setScaleY(floatValFromDict(props, "scaleY")); node->setAnchorPoint(pointValFromDict(props, "anchorPoint")); node->setRotation(floatValFromDict(props, "rotation")); - node->setIsRelativeAnchorPoint(boolValFromDict(props, "isRelativeAnchorPoint")); + node->setIgnoreAnchorPointForPosition(!boolValFromDict(props, "isRelativeAnchorPoint")); node->setIsVisible(boolValFromDict(props, "visible")); if (extraProps) @@ -766,3 +768,4 @@ CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner) return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner); } +#endif diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp index a8d52028b2..ab61e0fa05 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp @@ -77,8 +77,11 @@ bool CCControlButton::initWithLabelAndBackgroundSprite(CCNode* node, CCScale9Spr // Adjust the background image by default m_adjustBackgroundImage=true; + // Zooming button by default + m_zoomOnTouchDown = true; + // Set the default anchor point - setIsRelativeAnchorPoint(true); + setIgnoreAnchorPointForPosition(false); setAnchorPoint(ccp(0.5f, 0.5f)); // Set the nodes @@ -194,8 +197,7 @@ void CCControlButton::setIsHighlighted(bool enabled) stopAction(action); } needsLayout(); - - if(m_zoomOnTouchDown) + if( m_zoomOnTouchDown ) { float scaleValue = (getIsHighlighted() && getIsEnabled() && !getIsSelected()) ? 1.1f : 1.0f; CCAction *zoomAction =CCScaleTo::actionWithDuration(0.05f, scaleValue); @@ -203,6 +205,38 @@ void CCControlButton::setIsHighlighted(bool enabled) runAction(zoomAction); } } + +void CCControlButton::setZoomOnTouchDown(bool zoomOnTouchDown) +{ + m_zoomOnTouchDown = zoomOnTouchDown; +} + +bool CCControlButton::getZoomOnTouchDown() +{ + return m_zoomOnTouchDown; +} + +void CCControlButton::setPreferredSize(CCSize size) +{ + if(size.width == 0 && size.height == 0) + { + m_adjustBackgroundImage = true; + } + else + { + m_adjustBackgroundImage = false; + CCDictElement * item = NULL; + CCDICT_FOREACH(m_backgroundSpriteDispatchTable, item) + { + CCScale9Sprite* sprite = (CCScale9Sprite*)item->getObject(); + sprite->setPreferredSize(size); + } + + m_preferredSize = size; + } + needsLayout(); +} + void CCControlButton::setAdjustBackgroundImage(bool adjustBackgroundImage) { m_adjustBackgroundImage=adjustBackgroundImage; @@ -219,30 +253,6 @@ CCSize CCControlButton::getPreferredSize() return this->m_preferredSize; } -void CCControlButton::setPreferredSize(CCSize preferredSize) -{ - if (preferredSize.width == 0 && preferredSize.height == 0) - { - this->m_adjustBackgroundImage = true; - } - else - { - this->m_adjustBackgroundImage = false; - - // TODO Was: "for (id key in backgroundSpriteDispatchTable_)" - CCDictElement * element = NULL; - CCDICT_FOREACH(m_backgroundSpriteDispatchTable, element) - { - CCScale9Sprite * sprite = dynamic_cast(m_backgroundSpriteDispatchTable->objectForKey(element->getIntKey())); - sprite->setPreferredSize(preferredSize); - } - } - - this->m_preferredSize = preferredSize; - - this->needsLayout(); -} - CCPoint CCControlButton::getLabelAnchorPoint() { return this->m_labelAnchorPoint; diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.h b/cocos2dx/extensions/CCControlExtension/CCControlButton.h index 22af8ef30c..addc0e8289 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.h @@ -53,10 +53,14 @@ protected: background will use the prefered size of the background image. */ CC_PROPERTY(bool, m_adjustBackgroundImage, AdjustBackgroundImage); - CC_PROPERTY(CCSize, m_preferredSize, PreferredSize); + /** Default value is (0.5f, 0.5f). */ CC_PROPERTY(CCPoint, m_labelAnchorPoint, LabelAnchorPoint); - CC_SYNTHESIZE(bool, m_zoomOnTouchDown, ZoomOnTouchDown); + /** Adjust the button zooming on touchdown. Default value is YES. */ + CC_PROPERTY(bool, m_zoomOnTouchDown, ZoomOnTouchDown); + + /** The prefered size of the button, if label is larger it will be expanded. */ + CC_PROPERTY(CCSize, m_preferredSize, PreferredSize); /** The current title that is displayed on the button. */ CC_SYNTHESIZE_READONLY(CCString*, m_currentTitle, CurrentTitle); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp b/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp index 771054cf4a..a3c8672215 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp @@ -68,7 +68,7 @@ CCControlSlider* CCControlSlider::sliderWithSprites(CCSprite * backgroundSprite, { if (CCControl::init()) { - setIsRelativeAnchorPoint(true); + setIgnoreAnchorPointForPosition(false); setIsTouchEnabled(true); m_backgroundSprite=backgroundSprite; diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp index 824d27dd0d..8bae8159e7 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp @@ -309,7 +309,7 @@ bool CCControlSwitch::initWithMaskSprite(CCSprite *maskSprite, CCSprite * onSpri m_pSwitchSprite->setPosition(ccp (m_pSwitchSprite->getContentSize().width / 2, m_pSwitchSprite->getContentSize().height / 2)); addChild(m_pSwitchSprite); - setIsRelativeAnchorPoint(true); + setIgnoreAnchorPointForPosition(false); setAnchorPoint(ccp (0.5f, 0.5f)); setContentSize(m_pSwitchSprite->getContentSize()); return true; diff --git a/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp b/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp index cb6536fcee..b641ac732e 100644 --- a/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp @@ -53,7 +53,7 @@ bool CCMenuPassive::initWithItems(CCNode* item, va_list args) CCSize s = CCDirector::sharedDirector()->getWinSize(); // Set the default anchor point - setIsRelativeAnchorPoint(false); + setIgnoreAnchorPointForPosition(true); setAnchorPoint(ccp(0.5f, 0.5f)); this->setContentSize(s); diff --git a/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp b/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp index ca3185d906..780e52fc1e 100644 --- a/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp +++ b/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp @@ -50,7 +50,7 @@ CCTextureWatcher::CCTextureWatcher() // the menu of disabling touch event //* - CCLabelTTF *label = CCLabelTTF::labelWithString(" ", size, CCTextAlignmentLeft, "Arial", 12); + CCLabelTTF *label = CCLabelTTF::labelWithString(" ", size, kCCTextAlignmentLeft, "Arial", 12); CCMenuItemLabel *menuItem = CCMenuItemLabel::itemWithLabel(label); menuItem->setAnchorPoint(ccp(0, 0)); menuItem->setPosition(ccp(0, 0)); @@ -98,7 +98,7 @@ CCTextureWatcher::CCTextureWatcher() m_pLayer->addChild(menu1); // label page - m_labelPage = CCLabelTTF::labelWithString(" ", CCSizeMake(size.width * 0.1, labelFresh->getContentSize().height), CCTextAlignmentCenter, "Arial", 16); + m_labelPage = CCLabelTTF::labelWithString(" ", CCSizeMake(size.width * 0.1, labelFresh->getContentSize().height), kCCTextAlignmentCenter, "Arial", 16); m_labelPage->setAnchorPoint(ccp(0.5, 0)); m_labelPage->setPosition(ccp(size.width/2.0, 0)); m_pLayer->addChild(m_labelPage, 0); @@ -314,7 +314,7 @@ void CCTextureWatcher::CCListView_cellForRow(CCListView *listView, CCListViewPro string name = key.substr(pos, len - pos); sprintf(m_pszString, "%s", name.c_str()); CCSize dimensions = CCSizeMake(listItemSize.width * 0.9f, labelSize->getContentSize().height); - CCLabelTTF *labelName = CCLabelTTF::labelWithString(m_pszString, dimensions, CCTextAlignmentCenter, "Arial", 16); + CCLabelTTF *labelName = CCLabelTTF::labelWithString(m_pszString, dimensions, kCCTextAlignmentCenter, "Arial", 16); offX = offsetX + listItemSize.width * 0.5f; offY = offY + labelName->getContentSize().height; labelName->setPosition(ccp(offX, offY)); diff --git a/cocos2dx/include/ccTypes.h b/cocos2dx/include/ccTypes.h index 952a87fd63..2071787d79 100755 --- a/cocos2dx/include/ccTypes.h +++ b/cocos2dx/include/ccTypes.h @@ -321,18 +321,35 @@ typedef enum } ccResolutionType; -//! delta time type -//! if you want more resolution redefine it as a double -typedef float ccTime; -//typedef double ccTime; - -typedef enum +// XXX: If any of these enums are edited and/or reordered, udpate CCTexture2D.m +//! Vertical text alignment type +typedef enum { - CCTextAlignmentLeft, - CCTextAlignmentCenter, - CCTextAlignmentRight, + kCCVerticalTextAlignmentTop, + kCCVerticalTextAlignmentCenter, + kCCVerticalTextAlignmentBottom, +} CCVerticalTextAlignment; + +// XXX: If any of these enums are edited and/or reordered, udpate CCTexture2D.m +//! Horizontal text alignment type +typedef enum +{ + kCCTextAlignmentLeft, + kCCTextAlignmentCenter, + kCCTextAlignmentRight, } CCTextAlignment; +// XXX: If any of these enums are edited and/or reordered, udpate CCTexture2D.m +//! Line break modes +typedef enum { + kCCLineBreakModeWordWrap, + kCCLineBreakModeCharacterWrap, + kCCLineBreakModeClip, + kCCLineBreakModeHeadTruncation, + kCCLineBreakModeTailTruncation, + kCCLineBreakModeMiddleTruncation +} CCLineBreakMode; + // types for animation in particle systems // texture coordinates for a quad @@ -352,7 +369,7 @@ typedef struct _ccT2F_Quad typedef struct { ccT2F_Quad texCoords; - ccTime delay; + float delay; CCSize size; } ccAnimationFrameData; diff --git a/cocos2dx/label_nodes/CCLabelAtlas.cpp b/cocos2dx/label_nodes/CCLabelAtlas.cpp index 76aab24f99..f2ae74627b 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.cpp +++ b/cocos2dx/label_nodes/CCLabelAtlas.cpp @@ -33,13 +33,15 @@ THE SOFTWARE. #include "ccGLStateCache.h" #include "CCDirector.h" #include "support/TransformUtils.h" +#include "CCInteger.h" +#include "CCFileUtils.h" // external #include "kazmath/GL/matrix.h" NS_CC_BEGIN //CCLabelAtlas - Creation & Init -CCLabelAtlas * CCLabelAtlas::labelWithString(const char *label, const char *charMapFile, unsigned int itemWidth, int unsigned itemHeight, unsigned char startCharMap) +CCLabelAtlas* CCLabelAtlas::labelWithString(const char *label, const char *charMapFile, unsigned int itemWidth, int unsigned itemHeight, unsigned int startCharMap) { CCLabelAtlas *pRet = new CCLabelAtlas(); if(pRet && pRet->initWithString(label, charMapFile, itemWidth, itemHeight, startCharMap)) @@ -51,18 +53,53 @@ CCLabelAtlas * CCLabelAtlas::labelWithString(const char *label, const char *char return NULL; } -bool CCLabelAtlas::initWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned char startCharMap) +bool CCLabelAtlas::initWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap) { CCAssert(label != NULL, ""); if (CCAtlasNode::initWithTileFile(charMapFile, itemWidth, itemHeight, strlen(label))) { - m_cMapStartChar = startCharMap; + m_uMapStartChar = startCharMap; this->setString(label); return true; } return false; } +CCLabelAtlas* CCLabelAtlas::labelWithString(const char *string, const char *fntFile) +{ + CCLabelAtlas *ret = new CCLabelAtlas(); + if (ret) + { + if (ret->initWithString(string, fntFile)) + { + ret->autorelease(); + } + else + { + CC_SAFE_RELEASE_NULL(ret); + } + } + + return ret; +} + +bool CCLabelAtlas::initWithString(const char *theString, const char *fntFile) +{ + CCDictionary *dict = CCDictionary::dictionaryWithContentsOfFile(CCFileUtils::sharedFileUtils()->sharedFileUtils()->fullPathFromRelativePath(fntFile)); + + CCAssert(((CCInteger*)dict->objectForKey("version"))->getValue() == 1, "Unsupported version. Upgrade cocos2d version"); + + CCString *textureFilename = (CCString*)dict->objectForKey("textureFilename"); + unsigned int width = ((CCInteger*)dict->objectForKey("itemWidth"))->getValue() / CC_CONTENT_SCALE_FACTOR(); + unsigned int height = ((CCInteger*)dict->objectForKey("itemHeight"))->getValue() / CC_CONTENT_SCALE_FACTOR(); + unsigned int startChar = ((CCInteger*)dict->objectForKey("firstChar"))->getValue(); + + + this->initWithString(theString, textureFilename->getCString(), width, height, startChar); + + return true; +} + //CCLabelAtlas - Atlas generation void CCLabelAtlas::updateAtlasValues() { @@ -79,7 +116,7 @@ void CCLabelAtlas::updateAtlasValues() float itemHeightInPixels = m_uItemHeight * CC_CONTENT_SCALE_FACTOR(); for(unsigned int i = 0; i < n; i++) { - unsigned char a = s[i] - m_cMapStartChar; + unsigned char a = s[i] - m_uMapStartChar; float row = (float) (a % m_uItemsPerRow); float col = (float) (a / m_uItemsPerRow); diff --git a/cocos2dx/label_nodes/CCLabelAtlas.h b/cocos2dx/label_nodes/CCLabelAtlas.h index d5445517c8..343c15b2d2 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.h +++ b/cocos2dx/label_nodes/CCLabelAtlas.h @@ -52,10 +52,20 @@ public: m_sString.clear(); } /** creates the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */ - static CCLabelAtlas * labelWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned char startCharMap); + static CCLabelAtlas * labelWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); + + /** creates the CCLabelAtlas with a string and a configuration file + @since v2.0 + */ + static CCLabelAtlas* labelWithString(const char *sring, const char *fntFile); /** initializes the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */ - bool initWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned char startCharMap); + bool initWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); + + /** initializes the CCLabelAtlas with a string and a configuration file + @since v2.0 + */ + bool initWithString(const char *string, const char *fntFile); // super methods virtual void updateAtlasValues(); virtual void setString(const char *label); @@ -69,7 +79,7 @@ protected: // string to render std::string m_sString; // the first char in the charmap - unsigned char m_cMapStartChar; + unsigned int m_uMapStartChar; }; NS_CC_END diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index c02407477f..bd145da3c7 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -42,6 +42,7 @@ http://www.angelcode.com/products/bmfont/ (Free, Windows only) #include "CCFileUtils.h" #include "support/data_support/uthash.h" #include "CCDirector.h" +#include "CCTextureCache.h" using namespace std; @@ -373,7 +374,10 @@ CCBMFontConfiguration* FNTConfigLoadFile( const char *fntFile) if( pRet == NULL ) { pRet = CCBMFontConfiguration::configurationWithFNTFile(fntFile); - configurations->setObject(pRet, fntFile); + if (pRet) + { + configurations->setObject(pRet, fntFile); + } } return pRet; @@ -416,15 +420,19 @@ CCBMFontConfiguration * CCBMFontConfiguration::configurationWithFNTFile(const ch bool CCBMFontConfiguration::initWithFNTfile(const char *FNTfile) { - CCAssert(FNTfile != NULL && strlen(FNTfile)!=0, ""); m_pKerningDictionary = NULL; - this->parseConfigFile(FNTfile); + m_pFontDefDictionary = NULL; + if (! this->parseConfigFile(FNTfile)) + { + return false; + } + return true; } CCBMFontConfiguration::CCBMFontConfiguration() : m_pFontDefDictionary(NULL) - , m_uCommonHeight(0) + , m_nCommonHeight(0) , m_pKerningDictionary(NULL) { @@ -471,24 +479,22 @@ void CCBMFontConfiguration::purgeFontDefDictionary() } -void CCBMFontConfiguration::parseConfigFile(const char *controlFile) +bool CCBMFontConfiguration::parseConfigFile(const char *controlFile) { - std::string fullpath = CCFileUtils::fullPathFromRelativePath(controlFile); + std::string fullpath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(controlFile); + CCString *contents = CCString::stringWithContentsOfFile(fullpath.c_str()); - CCFileData data(fullpath.c_str(), "rb"); - unsigned long nBufSize = data.getSize(); - char* pBuffer = (char*) data.getBuffer(); + CCAssert(contents, "CCBMFontConfiguration::parseConfigFile | Open file error."); - CCAssert(pBuffer, "CCBMFontConfiguration::parseConfigFile | Open file error."); - - if (!pBuffer) + if (!contents) { - return; + CCLOG("cocos2d: Error parsing FNTfile %s", controlFile); + return false; } // parse spacing / padding std::string line; - std::string strLeft(pBuffer, nBufSize); + std::string strLeft = contents->getCString(); while (strLeft.length() > 0) { int pos = strLeft.find('\n'); @@ -535,15 +541,17 @@ void CCBMFontConfiguration::parseConfigFile(const char *controlFile) element->key = element->fontDef.charID; HASH_ADD_INT(m_pFontDefDictionary, key, element); } - else if(line.substr(0,strlen("kernings count")) == "kernings count") - { - this->parseKerningCapacity(line); - } +// else if(line.substr(0,strlen("kernings count")) == "kernings count") +// { +// this->parseKerningCapacity(line); +// } else if(line.substr(0,strlen("kerning first")) == "kerning first") { this->parseKerningEntry(line); } } + + return true; } void CCBMFontConfiguration::parseImageFileName(std::string line, const char *fntFile) @@ -563,7 +571,7 @@ void CCBMFontConfiguration::parseImageFileName(std::string line, const char *fnt index2 = line.find('"', index); value = line.substr(index, index2-index); - m_sAtlasName = CCFileUtils::fullPathFromRelativeFile(value.c_str(), fntFile); + m_sAtlasName = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(value.c_str(), fntFile); } void CCBMFontConfiguration::parseInfoArguments(std::string line) @@ -593,7 +601,7 @@ void CCBMFontConfiguration::parseCommonArguments(std::string line) int index = line.find("lineHeight="); int index2 = line.find(' ', index); std::string value = line.substr(index, index2-index); - sscanf(value.c_str(), "lineHeight=%u", &m_uCommonHeight); + sscanf(value.c_str(), "lineHeight=%d", &m_nCommonHeight); // scaleW. sanity check index = line.find("scaleW=") + strlen("scaleW="); index2 = line.find(' ', index); @@ -663,28 +671,6 @@ void CCBMFontConfiguration::parseCharacterDefinition(std::string line, ccBMFontD sscanf(value.c_str(), "xadvance=%d", &characterDefinition->xAdvance); } -void CCBMFontConfiguration::parseKerningCapacity(std::string line) -{ - // When using uthash there is not need to parse the capacity. - - // CCAssert(!kerningDictionary, @"dictionary already initialized"); - // - // // Break the values for this line up using = - // CCMutableArray *values = [line componentsSeparatedByString:@"="]; - // NSEnumerator *nse = [values objectEnumerator]; - // CCString *propertyValue; - // - // // We need to move past the first entry in the array before we start assigning values - // [nse nextObject]; - // - // // count - // propertyValue = [nse nextObject]; - // int capacity = [propertyValue intValue]; - // - // if( capacity != -1 ) - // kerningDictionary = ccHashSetNew(capacity, targetSetEql); -} - void CCBMFontConfiguration::parseKerningEntry(std::string line) { ////////////////////////////////////////////////////////////////////////// @@ -781,12 +767,12 @@ CCLabelBMFont *CCLabelBMFont::labelWithString(const char *str, const char *fntFi bool CCLabelBMFont::init() { - return initWithString(NULL, NULL, kCCLabelAutomaticWidth, CCTextAlignmentLeft, CCPointZero); + return initWithString(NULL, NULL, kCCLabelAutomaticWidth, kCCTextAlignmentLeft, CCPointZero); } bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile) { - return initWithString(theString, fntFile, kCCLabelAutomaticWidth, CCTextAlignmentLeft, CCPointZero); + return initWithString(theString, fntFile, kCCLabelAutomaticWidth, kCCTextAlignmentLeft, CCPointZero); } bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile, float width, CCTextAlignment alignment) @@ -797,27 +783,28 @@ bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile, f bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile, float width, CCTextAlignment alignment, CCPoint imageOffset) { CCAssert(!this->m_pConfiguration, "re-init is no longer supported"); - CCAssert((theString != NULL && fntFile != NULL) || (theString == NULL && fntFile == NULL), "Invalid params for CCLabelBMFont"); - - CCTexture2D * texture; - - if(fntFile != NULL) + + CCTexture2D *texture = NULL; + + if (fntFile != NULL) { - m_pConfiguration = FNTConfigLoadFile(fntFile); - m_pConfiguration->retain(); - + CCBMFontConfiguration *newConf = FNTConfigLoadFile(fntFile); + CCAssert(newConf, "CCLabelBMFont: Impossible to create font. Please check file"); + + newConf->retain(); + CC_SAFE_RELEASE(m_pConfiguration); + m_pConfiguration = newConf; + m_sFntFile = fntFile; - CCAssert( m_pConfiguration, "Error creating config for LabelBMFont"); - - texture = CCTextureCache::sharedTextureCache()->addImage(this->m_pConfiguration->m_sAtlasName.c_str()); + + texture = CCTextureCache::sharedTextureCache()->addImage(m_pConfiguration->getAtlasName()); } - else + else { texture = new CCTexture2D(); texture->autorelease(); } - if (CCSpriteBatchNode::initWithTexture(texture, (theString == NULL) ? 0 : strlen(theString))) { @@ -902,8 +889,8 @@ void CCLabelBMFont::createFontChars() } } - totalHeight = m_pConfiguration->m_uCommonHeight * quantityOfLines; - nextFontPositionY = 0-(m_pConfiguration->m_uCommonHeight - m_pConfiguration->m_uCommonHeight * quantityOfLines); + totalHeight = m_pConfiguration->m_nCommonHeight * quantityOfLines; + nextFontPositionY = 0-(m_pConfiguration->m_nCommonHeight - m_pConfiguration->m_nCommonHeight * quantityOfLines); for (unsigned int i= 0; i < stringLen; i++) { @@ -912,7 +899,7 @@ void CCLabelBMFont::createFontChars() if (c == '\n') { nextFontPositionX = 0; - nextFontPositionY -= m_pConfiguration->m_uCommonHeight; + nextFontPositionY -= m_pConfiguration->m_nCommonHeight; continue; } @@ -951,7 +938,8 @@ void CCLabelBMFont::createFontChars() fontChar->setOpacity(255); } - float yOffset = (float)(m_pConfiguration->m_uCommonHeight) - fontDef.yOffset; + // See issue 1343. cast( signed short + unsigned integer ) == unsigned integer (sign is lost!) + int yOffset = m_pConfiguration->m_nCommonHeight - fontDef.yOffset; CCPoint fontPos = ccp( (float)nextFontPositionX + fontDef.xOffset + fontDef.rect.size.width*0.5f + kerningAmount, (float)nextFontPositionY + yOffset - rect.size.height*0.5f * CC_CONTENT_SCALE_FACTOR() ); fontChar->setPosition(CC_POINT_PIXELS_TO_POINTS(fontPos)); @@ -995,7 +983,7 @@ void CCLabelBMFont::setString(const char *newString, bool fromUpdate) { CC_SAFE_DELETE_ARRAY(m_sString); m_sString = cc_utf16_from_utf8(newString); - m_sString_initial = newString; + m_sInitialString = newString; updateString(fromUpdate); } @@ -1022,7 +1010,7 @@ void CCLabelBMFont::updateString(bool fromUpdate) const char* CCLabelBMFont::getString(void) { - return m_sString_initial.c_str(); + return m_sInitialString.c_str(); } void CCLabelBMFont::setCString(const char *label) @@ -1114,7 +1102,7 @@ void CCLabelBMFont::setAnchorPoint(const CCPoint& point) // LabelBMFont - Alignment void CCLabelBMFont::updateLabel() { - this->setString(m_sString_initial.c_str(), true); + this->setString(m_sInitialString.c_str(), true); if (m_fWidth > 0) { @@ -1281,7 +1269,7 @@ void CCLabelBMFont::updateLabel() } // Step 2: Make alignment - if (m_pAlignment != CCTextAlignmentLeft) + if (m_pAlignment != kCCTextAlignmentLeft) { int i = 0; @@ -1306,11 +1294,12 @@ void CCLabelBMFont::updateLabel() float shift = 0; switch (m_pAlignment) { - case CCTextAlignmentCenter: + case kCCTextAlignmentCenter: shift = getContentSize().width/2.0f - lineWidth/2.0f; break; - case CCTextAlignmentRight: + case kCCTextAlignmentRight: shift = getContentSize().width - lineWidth; + break; default: break; } diff --git a/cocos2dx/label_nodes/CCLabelBMFont.h b/cocos2dx/label_nodes/CCLabelBMFont.h index 0f6bf57654..97a7b1261c 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.h +++ b/cocos2dx/label_nodes/CCLabelBMFont.h @@ -91,8 +91,8 @@ public://@public // BMFont definitions struct _FontDefHashElement* m_pFontDefDictionary; - //! FNTConfig: Common Height - unsigned int m_uCommonHeight; + //! FNTConfig: Common Height Should be signed (issue #1343) + int m_nCommonHeight; //! Padding ccBMFontPadding m_tPadding; //! atlas name @@ -107,13 +107,15 @@ public: static CCBMFontConfiguration * configurationWithFNTFile(const char *FNTfile); /** initializes a BitmapFontConfiguration with a FNT file */ bool initWithFNTfile(const char *FNTfile); + + inline const char* getAtlasName(){ return m_sAtlasName.c_str(); } + inline void setAtlasName(const char* atlasName) { m_sAtlasName = atlasName; } private: - void parseConfigFile(const char *controlFile); + bool parseConfigFile(const char *controlFile); void parseCharacterDefinition(std::string line, ccBMFontDef *characterDefinition); void parseInfoArguments(std::string line); void parseCommonArguments(std::string line); void parseImageFileName(std::string line, const char *fntFile); - void parseKerningCapacity(std::string line); void parseKerningEntry(std::string line); void purgeKerningDictionary(); void purgeFontDefDictionary(); @@ -160,14 +162,22 @@ class CC_DLL CCLabelBMFont : public CCSpriteBatchNode, public CCLabelProtocol, p protected: // string to render unsigned short* m_sString; - std::string m_sString_initial; - CCBMFontConfiguration *m_pConfiguration; + + // name of fntFile + std::string m_sFntFile; + + // initial string without line breaks + std::string m_sInitialString; + // alignment of all lines CCTextAlignment m_pAlignment; + // max width until a line break is added float m_fWidth; + + CCBMFontConfiguration *m_pConfiguration; + bool m_bLineBreakWithoutSpaces; // offset of the texture atlas CCPoint m_tImageOffset; - std::string m_sFntFile; public: CCLabelBMFont(); diff --git a/cocos2dx/label_nodes/CCLabelTTF.cpp b/cocos2dx/label_nodes/CCLabelTTF.cpp index ae75392954..967f16919d 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.cpp +++ b/cocos2dx/label_nodes/CCLabelTTF.cpp @@ -39,7 +39,7 @@ NS_CC_BEGIN //CCLabelTTF // CCLabelTTF::CCLabelTTF() - : m_eAlignment(CCTextAlignmentCenter) + : m_eAlignment(kCCTextAlignmentCenter) , m_fFontSize(0.0) { } @@ -185,7 +185,7 @@ void CCLabelTTF::setString(const char *label) else { texture = new CCTexture2D(); - texture->initWithString(label, m_tDimensions, m_eAlignment, m_sFontName.c_str(), m_fFontSize); +//cjh texture->initWithString(label, m_tDimensions, m_eAlignment, kCCVerticalTextAlignmentTop, m_pFontName->c_str(), m_fFontSize); } // TODO diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index 4caf9aef7a..3e160e7808 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. @@ -49,7 +49,7 @@ CCLayer::CCLayer() ,m_pScriptHandlerEntry(NULL) { setAnchorPoint(ccp(0.5f, 0.5f)); - m_bIsRelativeAnchorPoint = false; + m_bIgnoreAnchorPointForPosition = true; } CCLayer::~CCLayer() diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h index 579a8165cf..d42b3eae98 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp index 4bc1e88318..fa684792e2 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. @@ -32,7 +32,7 @@ NS_CC_BEGIN CCScene::CCScene() { - m_bIsRelativeAnchorPoint = false; + m_bIgnoreAnchorPointForPosition = true; setAnchorPoint(ccp(0.5f, 0.5f)); } diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCScene.h b/cocos2dx/layers_scenes_transitions_nodes/CCScene.h index 7c6f8b2646..72d5cead50 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCScene.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCScene.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp index 1305eaf663..3c1e527ef2 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp @@ -51,7 +51,7 @@ CCTransitionScene::~CCTransitionScene() m_pOutScene->release(); } -CCTransitionScene * CCTransitionScene::transitionWithDuration(ccTime t, CCScene *scene) +CCTransitionScene * CCTransitionScene::transitionWithDuration(float t, CCScene *scene) { CCTransitionScene * pScene = new CCTransitionScene(); if(pScene && pScene->initWithDuration(t,scene)) @@ -63,7 +63,7 @@ CCTransitionScene * CCTransitionScene::transitionWithDuration(ccTime t, CCScene return NULL; } -bool CCTransitionScene::initWithDuration(ccTime t, CCScene *scene) +bool CCTransitionScene::initWithDuration(float t, CCScene *scene) { CCAssert( scene != NULL, "Argument scene must be non-nil"); @@ -75,6 +75,11 @@ bool CCTransitionScene::initWithDuration(ccTime t, CCScene *scene) m_pInScene = scene; m_pInScene->retain(); m_pOutScene = CCDirector::sharedDirector()->getRunningScene(); + if (m_pOutScene == NULL) + { + m_pOutScene = CCScene::node(); + m_pOutScene->init(); + } m_pOutScene->retain(); CCAssert( m_pInScene != m_pOutScene, "Incoming scene must be different from the outgoing scene" ); @@ -130,7 +135,7 @@ void CCTransitionScene::finish() } -void CCTransitionScene::setNewScene(ccTime dt) +void CCTransitionScene::setNewScene(float dt) { CC_UNUSED_PARAM(dt); // [self unschedule:_cmd]; @@ -192,7 +197,7 @@ CCTransitionSceneOriented::~CCTransitionSceneOriented() { } -CCTransitionSceneOriented * CCTransitionSceneOriented::transitionWithDuration(ccTime t, CCScene *scene, tOrientation orientation) +CCTransitionSceneOriented * CCTransitionSceneOriented::transitionWithDuration(float t, CCScene *scene, tOrientation orientation) { CCTransitionSceneOriented * pScene = new CCTransitionSceneOriented(); pScene->initWithDuration(t,scene,orientation); @@ -200,7 +205,7 @@ CCTransitionSceneOriented * CCTransitionSceneOriented::transitionWithDuration(cc return pScene; } -bool CCTransitionSceneOriented::initWithDuration(ccTime t, CCScene *scene, tOrientation orientation) +bool CCTransitionSceneOriented::initWithDuration(float t, CCScene *scene, tOrientation orientation) { if ( CCTransitionScene::initWithDuration(t, scene) ) { @@ -652,7 +657,7 @@ void CCTransitionFlipX::onEnter() m_pOutScene->runAction(outA); } -CCTransitionFlipX* CCTransitionFlipX::transitionWithDuration(ccTime t, CCScene* s, tOrientation o) +CCTransitionFlipX* CCTransitionFlipX::transitionWithDuration(float t, CCScene* s, tOrientation o) { CCTransitionFlipX* pScene = new CCTransitionFlipX(); pScene->initWithDuration(t, s, o); @@ -717,7 +722,7 @@ void CCTransitionFlipY::onEnter() } -CCTransitionFlipY* CCTransitionFlipY::transitionWithDuration(ccTime t, CCScene* s, tOrientation o) +CCTransitionFlipY* CCTransitionFlipY::transitionWithDuration(float t, CCScene* s, tOrientation o) { CCTransitionFlipY* pScene = new CCTransitionFlipY(); pScene->initWithDuration(t, s, o); @@ -781,7 +786,7 @@ void CCTransitionFlipAngular::onEnter() m_pOutScene->runAction(outA); } -CCTransitionFlipAngular* CCTransitionFlipAngular::transitionWithDuration(ccTime t, CCScene* s, tOrientation o) +CCTransitionFlipAngular* CCTransitionFlipAngular::transitionWithDuration(float t, CCScene* s, tOrientation o) { CCTransitionFlipAngular* pScene = new CCTransitionFlipAngular(); pScene->initWithDuration(t, s, o); @@ -854,7 +859,7 @@ void CCTransitionZoomFlipX::onEnter() m_pOutScene->runAction(outA); } -CCTransitionZoomFlipX* CCTransitionZoomFlipX::transitionWithDuration(ccTime t, CCScene* s, tOrientation o) +CCTransitionZoomFlipX* CCTransitionZoomFlipX::transitionWithDuration(float t, CCScene* s, tOrientation o) { CCTransitionZoomFlipX* pScene = new CCTransitionZoomFlipX(); pScene->initWithDuration(t, s, o); @@ -927,7 +932,7 @@ void CCTransitionZoomFlipY::onEnter() m_pOutScene->runAction(outA); } -CCTransitionZoomFlipY* CCTransitionZoomFlipY::transitionWithDuration(ccTime t, CCScene* s, tOrientation o) +CCTransitionZoomFlipY* CCTransitionZoomFlipY::transitionWithDuration(float t, CCScene* s, tOrientation o) { CCTransitionZoomFlipY* pScene = new CCTransitionZoomFlipY(); pScene->initWithDuration(t, s, o); @@ -1003,7 +1008,7 @@ void CCTransitionZoomFlipAngular::onEnter() m_pOutScene->runAction(outA); } -CCTransitionZoomFlipAngular* CCTransitionZoomFlipAngular::transitionWithDuration(ccTime t, CCScene* s, tOrientation o) +CCTransitionZoomFlipAngular* CCTransitionZoomFlipAngular::transitionWithDuration(float t, CCScene* s, tOrientation o) { CCTransitionZoomFlipAngular* pScene = new CCTransitionZoomFlipAngular(); pScene->initWithDuration(t, s, o); @@ -1023,7 +1028,7 @@ CCTransitionFade::~CCTransitionFade() } -CCTransitionFade * CCTransitionFade::transitionWithDuration(ccTime duration, CCScene *scene, const ccColor3B& color) +CCTransitionFade * CCTransitionFade::transitionWithDuration(float duration, CCScene *scene, const ccColor3B& color) { CCTransitionFade * pTransition = new CCTransitionFade(); pTransition->initWithDuration(duration, scene, color); @@ -1031,7 +1036,7 @@ CCTransitionFade * CCTransitionFade::transitionWithDuration(ccTime duration, CCS return pTransition; } -bool CCTransitionFade::initWithDuration(ccTime duration, CCScene *scene, const ccColor3B& color) +bool CCTransitionFade::initWithDuration(float duration, CCScene *scene, const ccColor3B& color) { if (CCTransitionScene::initWithDuration(duration, scene)) { @@ -1043,7 +1048,7 @@ bool CCTransitionFade::initWithDuration(ccTime duration, CCScene *scene, const c return true; } -bool CCTransitionFade::initWithDuration(ccTime t, CCScene *scene) +bool CCTransitionFade::initWithDuration(float t, CCScene *scene) { this->initWithDuration(t, scene, ccBLACK); return true; @@ -1172,7 +1177,7 @@ void CCTransitionCrossFade::onExit() CCTransitionScene::onExit(); } -CCTransitionCrossFade* CCTransitionCrossFade::transitionWithDuration(ccTime d, CCScene* s) +CCTransitionCrossFade* CCTransitionCrossFade::transitionWithDuration(float d, CCScene* s) { CCTransitionCrossFade* Transition = new CCTransitionCrossFade(); Transition->initWithDuration(d, s); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h index 7e5b84be5d..14fb22b473 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h @@ -28,6 +28,7 @@ THE SOFTWARE. #define __CCTRANSITION_H__ #include "CCScene.h" +#include "ccTypes.h" NS_CC_BEGIN @@ -35,10 +36,10 @@ NS_CC_BEGIN //c/c++ don't support object creation of using class name //so, all classes need creation method. #define DECLEAR_TRANSITIONWITHDURATION(_Type)\ - static _Type* transitionWithDuration(ccTime t, CCScene* scene); + static _Type* transitionWithDuration(float t, CCScene* scene); #define IMPLEMENT_TRANSITIONWITHDURATION(_Type)\ - _Type* _Type::transitionWithDuration(ccTime t, CCScene* scene)\ + _Type* _Type::transitionWithDuration(float t, CCScene* scene)\ {\ _Type* pScene = new _Type();\ if(pScene && pScene->initWithDuration(t, scene)){\ @@ -85,7 +86,7 @@ class CC_DLL CCTransitionScene : public CCScene protected: CCScene * m_pInScene; CCScene * m_pOutScene; - ccTime m_fDuration; + float m_fDuration; bool m_bIsInSceneOnTop; bool m_bIsSendCleanupToScene; @@ -99,10 +100,10 @@ public: virtual void cleanup(); /** creates a base transition with duration and incoming scene */ - static CCTransitionScene * transitionWithDuration(ccTime t, CCScene *scene); + static CCTransitionScene * transitionWithDuration(float t, CCScene *scene); /** initializes a transition with duration and incoming scene */ - virtual bool initWithDuration(ccTime t,CCScene* scene); + virtual bool initWithDuration(float t,CCScene* scene); /** called after the transition finishes */ void finish(void); @@ -113,7 +114,7 @@ public: protected: virtual void sceneOrder(); private: - void setNewScene(ccTime dt); + void setNewScene(float dt); }; @@ -130,9 +131,9 @@ public: virtual ~CCTransitionSceneOriented(); /** creates a base transition with duration and incoming scene */ - static CCTransitionSceneOriented * transitionWithDuration(ccTime t,CCScene* scene, tOrientation orientation); + static CCTransitionSceneOriented * transitionWithDuration(float t,CCScene* scene, tOrientation orientation); /** initializes a transition with duration and incoming scene */ - virtual bool initWithDuration(ccTime t,CCScene* scene,tOrientation orientation); + virtual bool initWithDuration(float t,CCScene* scene,tOrientation orientation); }; /** @brief CCTransitionRotoZoom: @@ -327,7 +328,7 @@ public: virtual void onEnter(); - static CCTransitionFlipX* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionFlipX* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; /** @brief CCTransitionFlipY: @@ -342,7 +343,7 @@ public: virtual void onEnter(); - static CCTransitionFlipY* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationUpOver); + static CCTransitionFlipY* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationUpOver); }; /** @brief CCTransitionFlipAngular: @@ -357,7 +358,7 @@ public: virtual void onEnter(); - static CCTransitionFlipAngular* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionFlipAngular* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; /** @brief CCTransitionZoomFlipX: @@ -372,7 +373,7 @@ public: virtual void onEnter(); - static CCTransitionZoomFlipX* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionZoomFlipX* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; /** @brief CCTransitionZoomFlipY: @@ -387,7 +388,7 @@ public: virtual void onEnter(); - static CCTransitionZoomFlipY* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationUpOver); + static CCTransitionZoomFlipY* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationUpOver); }; /** @brief CCTransitionZoomFlipAngular: @@ -402,7 +403,7 @@ public: virtual void onEnter(); - static CCTransitionZoomFlipAngular* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionZoomFlipAngular* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; /** @brief CCTransitionFade: @@ -421,11 +422,11 @@ public: /** creates the transition with a duration and with an RGB color * Example: FadeTransition::transitionWithDuration(2, scene, ccc3(255,0,0); // red color */ - static CCTransitionFade* transitionWithDuration(ccTime duration,CCScene* scene, const ccColor3B& color = ccBLACK); + static CCTransitionFade* transitionWithDuration(float duration,CCScene* scene, const ccColor3B& color = ccBLACK); /** initializes the transition with a duration and with an RGB color */ - virtual bool initWithDuration(ccTime t, CCScene*scene ,const ccColor3B& color); + virtual bool initWithDuration(float t, CCScene*scene ,const ccColor3B& color); - virtual bool initWithDuration(ccTime t,CCScene* scene); + virtual bool initWithDuration(float t,CCScene* scene); virtual void onEnter(); virtual void onExit(); }; diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp index ef83273d91..ef1f5f6d8f 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp @@ -41,7 +41,7 @@ CCTransitionPageTurn::~CCTransitionPageTurn() } /** creates a base transition with duration and incoming scene */ -CCTransitionPageTurn * CCTransitionPageTurn::transitionWithDuration(ccTime t, CCScene *scene, bool backwards) +CCTransitionPageTurn * CCTransitionPageTurn::transitionWithDuration(float t, CCScene *scene, bool backwards) { CCTransitionPageTurn * pTransition = new CCTransitionPageTurn(); pTransition->initWithDuration(t,scene,backwards); @@ -50,7 +50,7 @@ CCTransitionPageTurn * CCTransitionPageTurn::transitionWithDuration(ccTime t, CC } /** initializes a transition with duration and incoming scene */ -bool CCTransitionPageTurn::initWithDuration(ccTime t, CCScene *scene, bool backwards) +bool CCTransitionPageTurn::initWithDuration(float t, CCScene *scene, bool backwards) { // XXX: needed before [super init] m_bBack = backwards; diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h index d9088e4f6d..02fd2c19f2 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h @@ -55,14 +55,14 @@ public: * If back is true then the effect is reversed to appear as if the incoming * scene is being turned from left over the outgoing scene. */ - static CCTransitionPageTurn* transitionWithDuration(ccTime t,CCScene* scene,bool backwards); + static CCTransitionPageTurn* transitionWithDuration(float t,CCScene* scene,bool backwards); /** * Creates a base transition with duration and incoming scene. * If back is true then the effect is reversed to appear as if the incoming * scene is being turned from left over the outgoing scene. */ - virtual bool initWithDuration(ccTime t,CCScene* scene,bool backwards); + virtual bool initWithDuration(float t,CCScene* scene,bool backwards); CCActionInterval* actionWithSize(const ccGridSize& vector); diff --git a/cocos2dx/menu_nodes/CCMenu.cpp b/cocos2dx/menu_nodes/CCMenu.cpp index e2436c53f3..9d07aced9e 100644 --- a/cocos2dx/menu_nodes/CCMenu.cpp +++ b/cocos2dx/menu_nodes/CCMenu.cpp @@ -119,7 +119,7 @@ bool CCMenu::initWithArray(CCArray* pArrayOfItems) // menu in the center of the screen CCSize s = CCDirector::sharedDirector()->getWinSize(); - this->m_bIsRelativeAnchorPoint = false; + this->setIgnoreAnchorPointForPosition(true); setAnchorPoint(ccp(0.5f, 0.5f)); this->setContentSize(s); @@ -178,7 +178,7 @@ void CCMenu::onExit() //Menu - Events -void CCMenu::setHandlerPriority(unsigned int newPriority) +void CCMenu::setHandlerPriority(int newPriority) { CCTouchDispatcher* pDispatcher = CCDirector::sharedDirector()->getTouchDispatcher(); pDispatcher->setPriority(newPriority, this); diff --git a/cocos2dx/menu_nodes/CCMenu.h b/cocos2dx/menu_nodes/CCMenu.h index 79a5cc1d0c..8dc7f71e0e 100644 --- a/cocos2dx/menu_nodes/CCMenu.h +++ b/cocos2dx/menu_nodes/CCMenu.h @@ -109,7 +109,7 @@ public: void alignItemsInRows(unsigned int rows, va_list args); /** set event handler priority. By default it is: kCCMenuTouchPriority */ - void setHandlerPriority(unsigned int newPriority); + void setHandlerPriority(int newPriority); //super methods virtual void addChild(CCNode * child); diff --git a/cocos2dx/menu_nodes/CCMenuItem.cpp b/cocos2dx/menu_nodes/CCMenuItem.cpp index 320433415e..c4b1ac2916 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.cpp +++ b/cocos2dx/menu_nodes/CCMenuItem.cpp @@ -395,69 +395,73 @@ CCNode * CCMenuItemSprite::getNormalImage() { return m_pNormalImage; } -void CCMenuItemSprite::setNormalImage(CCNode* var) +void CCMenuItemSprite::setNormalImage(CCNode* pImage) { - if (var) + if (pImage != m_pNormalImage) { - addChild(var, 0, kNormalTag); - var->setAnchorPoint(ccp(0, 0)); - } - - if (m_pNormalImage) - { - removeChild(m_pNormalImage, true); - } - - m_pNormalImage = var; - if(m_pNormalImage) - { - this->setContentSize(m_pNormalImage->getContentSize()); - } + if (pImage) + { + addChild(pImage, 0, kNormalTag); + pImage->setAnchorPoint(ccp(0, 0)); + } - this->updateImagesVisibility(); + if (m_pNormalImage) + { + removeChild(m_pNormalImage, true); + } + + m_pNormalImage = pImage; + this->setContentSize(m_pNormalImage->getContentSize()); + this->updateImagesVisibility(); + } } CCNode * CCMenuItemSprite::getSelectedImage() { return m_pSelectedImage; } -void CCMenuItemSprite::setSelectedImage(CCNode* var) +void CCMenuItemSprite::setSelectedImage(CCNode* pImage) { - if (var) + if (pImage != m_pNormalImage) { - addChild(var, 0, kSelectedTag); - var->setAnchorPoint(ccp(0, 0)); - } - - if (m_pSelectedImage) - { - removeChild(m_pSelectedImage, true); - } - - m_pSelectedImage = var; + if (pImage) + { + addChild(pImage, 0, kSelectedTag); + pImage->setAnchorPoint(ccp(0, 0)); + } - this->updateImagesVisibility(); + if (m_pSelectedImage) + { + removeChild(m_pSelectedImage, true); + } + + m_pSelectedImage = pImage; + this->updateImagesVisibility(); + } } + CCNode * CCMenuItemSprite::getDisabledImage() { return m_pDisabledImage; } -void CCMenuItemSprite::setDisabledImage(CCNode* var) -{ - if (var) - { - addChild(var, 0, kDisableTag); - var->setAnchorPoint(ccp(0, 0)); - var->setIsVisible(false); - } - - if (m_pDisabledImage) - { - removeChild(m_pDisabledImage, true); - } - - m_pDisabledImage = var; - this->updateImagesVisibility(); +void CCMenuItemSprite::setDisabledImage(CCNode* pImage) +{ + if (pImage != m_pNormalImage) + { + if (pImage) + { + addChild(pImage, 0, kDisableTag); + pImage->setAnchorPoint(ccp(0, 0)); + } + + if (m_pDisabledImage) + { + removeChild(m_pDisabledImage, true); + } + + m_pDisabledImage = pImage; + this->updateImagesVisibility(); + } } // //CCMenuItemSprite - CCRGBAProtocol protocol @@ -569,42 +573,35 @@ void CCMenuItemSprite::unselected() void CCMenuItemSprite::setIsEnabled(bool bEnabled) { - if(bEnabled != this->m_bIsEnabled) + if( m_bIsEnabled != bEnabled ) { CCMenuItem::setIsEnabled(bEnabled); this->updateImagesVisibility(); } } +// Helper void CCMenuItemSprite::updateImagesVisibility() { - if (m_pNormalImage) + if (m_bIsEnabled) { - if (m_pSelectedImage) + if (m_pNormalImage) m_pNormalImage->setIsVisible(true); + if (m_pSelectedImage) m_pSelectedImage->setIsVisible(false); + if (m_pDisabledImage) m_pDisabledImage->setIsVisible(false); + } + else + { + if (m_pDisabledImage) { - m_pSelectedImage->setIsVisible(false); - } - - if (this->m_bIsEnabled) - { - m_pNormalImage->setIsVisible(true); - - if (m_pDisabledImage) - { - m_pDisabledImage->setIsVisible(false); - } + if (m_pNormalImage) m_pNormalImage->setIsVisible(false); + if (m_pSelectedImage) m_pSelectedImage->setIsVisible(false); + if (m_pDisabledImage) m_pDisabledImage->setIsVisible(true); } else { - if (m_pDisabledImage) - { - m_pDisabledImage->setIsVisible(true); - m_pNormalImage->setIsVisible(false); - } - else - { - m_pNormalImage->setIsVisible(true); - } + if (m_pNormalImage) m_pNormalImage->setIsVisible(true); + if (m_pSelectedImage) m_pSelectedImage->setIsVisible(false); + if (m_pDisabledImage) m_pDisabledImage->setIsVisible(false); } } } @@ -630,10 +627,12 @@ CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, { return CCMenuItemImage::itemWithNormalImage(normalImage, selectedImage, NULL, NULL, NULL); } + CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, const char *selectedImage, CCObject* target, SEL_MenuHandler selector) { return CCMenuItemImage::itemWithNormalImage(normalImage, selectedImage, NULL, target, selector); } + CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector) { CCMenuItemImage *pRet = new CCMenuItemImage(); @@ -645,6 +644,7 @@ CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, CC_SAFE_DELETE(pRet); return NULL; } + CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage) { CCMenuItemImage *pRet = new CCMenuItemImage(); @@ -656,6 +656,7 @@ CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, CC_SAFE_DELETE(pRet); return NULL; } + bool CCMenuItemImage::initWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector) { CCNode *normalSprite = NULL; @@ -810,7 +811,7 @@ void CCMenuItemToggle::activate() } void CCMenuItemToggle::setIsEnabled(bool enabled) { - if(enabled != this->m_bIsEnabled) + if (m_bIsEnabled != enabled) { CCMenuItem::setIsEnabled(enabled); diff --git a/cocos2dx/menu_nodes/CCMenuItem.h b/cocos2dx/menu_nodes/CCMenuItem.h index 0a3cdfa181..f246f29572 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.h +++ b/cocos2dx/menu_nodes/CCMenuItem.h @@ -240,6 +240,7 @@ public: virtual void setIsOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} virtual bool getIsOpacityModifyRGB(void) { return false;} +protected: virtual void updateImagesVisibility(); }; diff --git a/cocos2dx/misc_nodes/CCMotionStreak.cpp b/cocos2dx/misc_nodes/CCMotionStreak.cpp index b07cf806bd..94c5b9ae27 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.cpp +++ b/cocos2dx/misc_nodes/CCMotionStreak.cpp @@ -44,11 +44,13 @@ CCMotionStreak::CCMotionStreak() , m_fMinSeg(0.0f) , m_uMaxPoints(0) , m_uNuPoints(0) +, m_uPreviousNuPoints(0) , m_pPointVertexes(NULL) , m_pPointState(NULL) , m_pVertices(NULL) , m_pColorPointer(NULL) , m_pTexCoords(NULL) +, m_bStartingPositionInitialized(false) { m_tBlendFunc.src = GL_SRC_ALPHA; m_tBlendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; @@ -102,7 +104,8 @@ bool CCMotionStreak::initWithFade(float fade, float minSeg, float stroke, ccColo { CCNode::setPosition(CCPointZero); setAnchorPoint(CCPointZero); - setIsRelativeAnchorPoint(false); + setIgnoreAnchorPointForPosition(true); + m_bStartingPositionInitialized = false; m_tPositionR = CCPointZero; m_bFastMode = true; @@ -137,6 +140,7 @@ bool CCMotionStreak::initWithFade(float fade, float minSeg, float stroke, ccColo void CCMotionStreak::setPosition(const CCPoint& position) { + m_bStartingPositionInitialized = true; m_tPositionR = position; } @@ -207,8 +211,13 @@ bool CCMotionStreak::getIsOpacityModifyRGB(void) return false; } -void CCMotionStreak::update(ccTime delta) +void CCMotionStreak::update(float delta) { + if (!m_bStartingPositionInitialized) + { + return; + } + delta *= m_fFadeDelta; unsigned int newIdx, newIdx2, i, i2; @@ -261,14 +270,18 @@ void CCMotionStreak::update(ccTime delta) // Append new point bool appendNewPoint = true; if(m_uNuPoints >= m_uMaxPoints) + { appendNewPoint = false; + } else if(m_uNuPoints>0) { bool a1 = ccpDistanceSQ(m_pPointVertexes[m_uNuPoints-1], m_tPositionR) < m_fMinSeg; bool a2 = (m_uNuPoints == 1) ? false : (ccpDistanceSQ(m_pPointVertexes[m_uNuPoints-2], m_tPositionR) < (m_fMinSeg * 2.0f)); if(a1 || a2) + { appendNewPoint = false; + } } if(appendNewPoint) @@ -289,16 +302,33 @@ void CCMotionStreak::update(ccTime delta) if(m_uNuPoints > 0 && m_bFastMode ) { if(m_uNuPoints > 1) - ccVertexLineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, m_pTexCoords, m_uNuPoints, 1); + { + ccVertexLineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, m_uNuPoints, 1); + } else - ccVertexLineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, m_pTexCoords, 0, 2); + { + ccVertexLineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, 0, 2); + } } m_uNuPoints ++; } if( ! m_bFastMode ) - ccVertexLineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, m_pTexCoords, 0, m_uNuPoints); + { + ccVertexLineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, 0, m_uNuPoints); + } + + // Updated Tex Coords only if they are different than previous step + if( m_uNuPoints && m_uPreviousNuPoints != m_uNuPoints ) { + float texDelta = 1.0f / m_uNuPoints; + for( i=0; i < m_uNuPoints; i++ ) { + m_pTexCoords[i*2] = tex2(0, texDelta*i); + m_pTexCoords[i*2+1] = tex2(1, texDelta*i); + } + + m_uPreviousNuPoints = m_uNuPoints; + } } void CCMotionStreak::reset() diff --git a/cocos2dx/misc_nodes/CCMotionStreak.h b/cocos2dx/misc_nodes/CCMotionStreak.h index 98d956d669..68ce88435d 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.h +++ b/cocos2dx/misc_nodes/CCMotionStreak.h @@ -60,7 +60,7 @@ public: /** Override super methods */ virtual void setPosition(const CCPoint& position); virtual void draw(); - virtual void update(ccTime delta); + virtual void update(float delta); /* Implement interfaces */ virtual CCTexture2D* getTexture(void); @@ -76,6 +76,8 @@ public: /** When fast mode is enbled, new points are added faster but with lower precision */ CC_SYNTHESIZE(bool, m_bFastMode, IsFastMode); + + CC_SYNTHESIZE(bool, m_bStartingPositionInitialized, StartingPositionInitialized); private: /** texture used for the motion streak */ CCTexture2D* m_pTexture; @@ -89,6 +91,7 @@ private: unsigned int m_uMaxPoints; unsigned int m_uNuPoints; + unsigned int m_uPreviousNuPoints; /** Pointers */ CCPoint* m_pPointVertexes; diff --git a/cocos2dx/misc_nodes/CCRenderTexture.cpp b/cocos2dx/misc_nodes/CCRenderTexture.cpp index c4eb592e00..0f6a5fb3c8 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.cpp +++ b/cocos2dx/misc_nodes/CCRenderTexture.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Jason Booth http://www.cocos2d-x.org @@ -44,6 +44,7 @@ NS_CC_BEGIN CCRenderTexture::CCRenderTexture() : m_pSprite(NULL) , m_uFBO(0) +, m_uDepthRenderBufffer(0) , m_nOldFBO(0) , m_pTexture(0) , m_pUITextureImage(NULL) @@ -55,7 +56,10 @@ CCRenderTexture::~CCRenderTexture() { //TODO: 2.0 remove this line. removeAllChildrenWithCleanup(true); glDeleteFramebuffers(1, &m_uFBO); - + if (m_uDepthRenderBufffer) + { + glDeleteRenderbuffers(1, &m_uDepthRenderBufffer); + } CC_SAFE_DELETE(m_pUITextureImage); } @@ -81,11 +85,24 @@ CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w, int h, return NULL; } +CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat) +{ + CCRenderTexture *pRet = new CCRenderTexture(); + + if(pRet && pRet->initWithWidthAndHeight(w, h, eFormat, uDepthStencilFormat)) + { + pRet->autorelease(); + return pRet; + } + CC_SAFE_DELETE(pRet); + return NULL; +} + CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w, int h) { CCRenderTexture *pRet = new CCRenderTexture(); - if(pRet && pRet->initWithWidthAndHeight(w, h, kCCTexture2DPixelFormat_RGBA8888)) + if(pRet && pRet->initWithWidthAndHeight(w, h, kCCTexture2DPixelFormat_RGBA8888, 0)) { pRet->autorelease(); return pRet; @@ -95,6 +112,11 @@ CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w, int h) } bool CCRenderTexture::initWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat) +{ + return initWithWidthAndHeight(w, h, eFormat, 0); +} + +bool CCRenderTexture::initWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat) { CCAssert(m_ePixelFormat != kCCTexture2DPixelFormat_A8, "only RGB and RGBA formats are valid for a render texture"); @@ -130,6 +152,9 @@ bool CCRenderTexture::initWithWidthAndHeight(int w, int h, CCTexture2DPixelForma m_pTexture->initWithData(data, (CCTexture2DPixelFormat)m_ePixelFormat, powW, powH, CCSizeMake((float)w, (float)h)); free( data ); + GLint oldRBO; + glGetIntegerv(GL_RENDERBUFFER_BINDING, &oldRBO); + // generate FBO glGenFramebuffers(1, &m_uFBO); glBindFramebuffer(GL_FRAMEBUFFER, m_uFBO); @@ -137,6 +162,20 @@ bool CCRenderTexture::initWithWidthAndHeight(int w, int h, CCTexture2DPixelForma // associate texture with FBO glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_pTexture->getName(), 0); + if (m_uDepthRenderBufffer != 0) + { + //create and attach depth buffer + glGenRenderbuffers(1, &m_uDepthRenderBufffer); + glBindRenderbuffer(GL_RENDERBUFFER, m_uDepthRenderBufffer); + glRenderbufferStorage(GL_RENDERBUFFER, uDepthStencilFormat, powW, powH); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_uDepthRenderBufffer); + + // if depth format is the one with stencil part, bind same render buffer as stencil attachment + //if (uDepthStencilFormat == CC_GL_DEPTH24_STENCIL8) + // glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_uDepthRenderBufffer); + } + + // check if it worked (probably worth doing :) ) CCAssert(glCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE, "Could not attach texture to framebuffer"); @@ -151,6 +190,7 @@ bool CCRenderTexture::initWithWidthAndHeight(int w, int h, CCTexture2DPixelForma ccBlendFunc tBlendFunc = {GL_ONE, GL_ONE_MINUS_SRC_ALPHA }; m_pSprite->setBlendFunc(tBlendFunc); + glBindRenderbuffer(GL_RENDERBUFFER, oldRBO); glBindFramebuffer(GL_FRAMEBUFFER, m_nOldFBO); bRet = true; } while (0); @@ -172,13 +212,8 @@ void CCRenderTexture::begin() float heightRatio = size.height / texSize.height; // Adjust the orthographic projection and viewport - glViewport(0, 0, (GLsizei)(texSize.width * CC_CONTENT_SCALE_FACTOR()), (GLsizei)(texSize.height * CC_CONTENT_SCALE_FACTOR())); + glViewport(0, 0, (GLsizei)texSize.width, (GLsizei)texSize.height); - // special viewport for 3d projection + retina display - if ( director->getProjection() == kCCDirectorProjection3D && CC_CONTENT_SCALE_FACTOR() != 1 ) - { - glViewport((GLsizei)(-texSize.width/2), (GLsizei)(-texSize.height/2), (GLsizei)(texSize.width * CC_CONTENT_SCALE_FACTOR()), (GLsizei)(texSize.height * CC_CONTENT_SCALE_FACTOR())); - } kmMat4 orthoMatrix; kmMat4OrthographicProjection(&orthoMatrix, (float)-1.0 / widthRatio, (float)1.0 / widthRatio, @@ -204,6 +239,48 @@ void CCRenderTexture::beginWithClear(float r, float g, float b, float a) glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); } +void CCRenderTexture::beginWithClear(float r, float g, float b, float a, float depthValue) +{ + this->begin(); + + // save clear color + GLfloat clearColor[4]; + GLfloat depthClearValue; + glGetFloatv(GL_COLOR_CLEAR_VALUE,clearColor); + glGetFloatv(GL_DEPTH_CLEAR_VALUE, &depthClearValue); + + glClearColor(r, g, b, a); + glClearDepth(depthValue); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + + // restore clear color + glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); + glClearDepth(depthClearValue); +} + +void CCRenderTexture::beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue) +{ + this->begin(); + + // save clear color + GLfloat clearColor[4]; + GLfloat depthClearValue; + int stencilClearValue; + glGetFloatv(GL_COLOR_CLEAR_VALUE,clearColor); + glGetFloatv(GL_DEPTH_CLEAR_VALUE, &depthClearValue); + glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &stencilClearValue); + + glClearColor(r, g, b, a); + glClearDepth(depthValue); + glClearStencil(stencilValue); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); + + // restore clear color + glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); + glClearDepth(depthClearValue); + glClearStencil(stencilClearValue); +} + void CCRenderTexture::end(bool bIsTOCacheTexture) { glBindFramebuffer(GL_FRAMEBUFFER, m_nOldFBO); @@ -224,7 +301,7 @@ void CCRenderTexture::end(bool bIsTOCacheTexture) director->setProjection(director->getProjection()); -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA if (bIsTOCacheTexture) { CC_SAFE_DELETE(m_pUITextureImage); @@ -251,6 +328,35 @@ void CCRenderTexture::clear(float r, float g, float b, float a) this->end(); } +void CCRenderTexture::clearDepth(float depthValue) +{ + this->begin(); + //! save old depth value + GLfloat depthClearValue; + glGetFloatv(GL_DEPTH_CLEAR_VALUE, &depthClearValue); + + glClearDepth(depthValue); + glClear(GL_DEPTH_BUFFER_BIT); + + // restore clear color + glClearDepth(depthClearValue); + this->end(); +} + +void CCRenderTexture::clearStencil(int stencilValue) +{ + // save old stencil value + int stencilClearValue; + glGetIntegerv(GL_STENCIL_CLEAR_VALUE, &stencilClearValue); + + glClearStencil(stencilValue); + glClear(GL_STENCIL_BUFFER_BIT); + + // restore clear color + glClearStencil(stencilClearValue); +} + + bool CCRenderTexture::saveToFile(const char *szFilePath) { bool bRet = false; @@ -273,7 +379,7 @@ bool CCRenderTexture::saveToFile(const char *fileName, tCCImageFormat format) CCImage *pImage = newCCImage(); if (pImage) { - std::string fullpath = CCFileUtils::getWriteablePath() + fileName; + std::string fullpath = CCFileUtils::sharedFileUtils()->getWriteablePath() + fileName; bRet = pImage->saveToFile(fullpath.c_str(), true); } diff --git a/cocos2dx/misc_nodes/CCRenderTexture.h b/cocos2dx/misc_nodes/CCRenderTexture.h index d135326f3e..b04b0832b1 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.h +++ b/cocos2dx/misc_nodes/CCRenderTexture.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 Jason Booth http://www.cocos2d-x.org @@ -58,6 +58,10 @@ class CC_DLL CCRenderTexture : public CCNode public: CCRenderTexture(); virtual ~CCRenderTexture(); + + /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format*/ + static CCRenderTexture * renderTextureWithWidthAndHeight(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat); + /** creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid */ static CCRenderTexture * renderTextureWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat); @@ -67,6 +71,9 @@ public: /** initializes a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid */ bool initWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat); + /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format*/ + bool initWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat); + /** starts grabbing */ void begin(); @@ -74,7 +81,14 @@ public: This is more efficient then calling -clear first and then -begin */ void beginWithClear(float r, float g, float b, float a); - + /** starts rendering to the texture while clearing the texture first. + This is more efficient then calling -clear first and then -begin */ + void beginWithClear(float r, float g, float b, float a, float depthValue); + + /** starts rendering to the texture while clearing the texture first. + This is more efficient then calling -clear first and then -begin */ + void beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue); + /** end is key word of lua, use other name to export to lua. */ inline void endToLua(){ end();}; @@ -85,6 +99,11 @@ public: /** clears the texture with a color */ void clear(float r, float g, float b, float a); + /** clears the texture with a specified depth value */ + void clearDepth(float depthValue); + + /** clears the texture with a specified stencil value */ + void clearStencil(int stencilValue); /* creates a new CCImage from with the texture's data. Caller is responsible for releasing it by calling delete. */ @@ -101,11 +120,12 @@ public: bool saveToFile(const char *name, tCCImageFormat format); protected: - GLuint m_uFBO; - GLint m_nOldFBO; - CCTexture2D *m_pTexture; - CCImage *m_pUITextureImage; - GLenum m_ePixelFormat; + GLuint m_uFBO; + GLuint m_uDepthRenderBufffer; + GLint m_nOldFBO; + CCTexture2D* m_pTexture; + CCImage* m_pUITextureImage; + GLenum m_ePixelFormat; }; NS_CC_END diff --git a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp index d6b8e0f4c7..ee560604ab 100644 --- a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp +++ b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp @@ -452,7 +452,7 @@ void CCParticleBatchNode::increaseAtlasCapacityTo(unsigned int quantity) if( ! m_pTextureAtlas->resizeCapacity(quantity) ) { // serious problems - CCLOG("cocos2d: WARNING: Not enough memory to resize the atlas"); + CCLOGWARN("cocos2d: WARNING: Not enough memory to resize the atlas"); CCAssert(false,"XXX: CCParticleBatchNode #increaseAtlasCapacity SHALL handle this assert"); } } diff --git a/cocos2dx/particle_nodes/CCParticleSystem.cpp b/cocos2dx/particle_nodes/CCParticleSystem.cpp index b764005d4b..1009a7fb63 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystem.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. @@ -103,6 +103,7 @@ CCParticleSystem::CCParticleSystem() ,m_fEmissionRate(0) ,m_uTotalParticles(0) ,m_pTexture(NULL) + ,m_bOpacityModifyRGB(false) ,m_bIsBlendAdditive(false) ,m_ePositionType(kCCPositionTypeFree) ,m_bIsAutoRemoveOnFinish(false) @@ -149,7 +150,7 @@ bool CCParticleSystem::init() bool CCParticleSystem::initWithFile(const char *plistFile) { bool bRet = false; - m_sPlistFile = CCFileUtils::fullPathFromRelativePath(plistFile); + m_sPlistFile = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(plistFile); CCDictionary *dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(m_sPlistFile.c_str()); CCAssert( dict != NULL, "Particles: file not found"); @@ -269,22 +270,25 @@ bool CCParticleSystem::initWithDictionary(CCDictionary *dictionary) //don't get the internal texture if a batchNode is used if (!m_pBatchNode) { + // Set a compatible default for the alpha transfer + m_bOpacityModifyRGB = false; + // texture // Try to get the texture from the cache const char* textureName = dictionary->valueForKey("textureFileName")->getCString(); - std::string fullpath = CCFileUtils::fullPathFromRelativeFile(textureName, m_sPlistFile.c_str()); + std::string fullpath = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(textureName, m_sPlistFile.c_str()); CCTexture2D *tex = NULL; if (strlen(textureName) > 0) { // set not pop-up message box when load image failed - bool bNotify = CCFileUtils::getIsPopupNotify(); - CCFileUtils::setIsPopupNotify(false); + bool bNotify = CCFileUtils::sharedFileUtils()->getIsPopupNotify(); + CCFileUtils::sharedFileUtils()->setIsPopupNotify(false); tex = CCTextureCache::sharedTextureCache()->addImage(fullpath.c_str()); // reset the value of UIImage notify - CCFileUtils::setIsPopupNotify(bNotify); + CCFileUtils::sharedFileUtils()->setIsPopupNotify(bNotify); } if (tex) @@ -384,6 +388,7 @@ bool CCParticleSystem::initWithTotalParticles(unsigned int numberOfParticles) CCParticleSystem::~CCParticleSystem() { + unscheduleUpdate(); CC_SAFE_FREE(m_pParticles); CC_SAFE_RELEASE(m_pTexture); } @@ -534,7 +539,7 @@ bool CCParticleSystem::isFull() } // ParticleSystem - MainLoop -void CCParticleSystem::update(ccTime dt) +void CCParticleSystem::update(float dt) { CC_PROFILER_START_CATEGORY(kCCProfilerCategoryParticles , "CCParticleSystem - update"); @@ -723,16 +728,37 @@ void CCParticleSystem::postStep() // ParticleSystem - CCTexture protocol void CCParticleSystem::setTexture(CCTexture2D* var) { - CC_SAFE_RETAIN(var); - CC_SAFE_RELEASE(m_pTexture); - m_pTexture = var; - - // If the new texture has No premultiplied alpha, AND the blendFunc hasn't been changed, then update it - if( m_pTexture && ! m_pTexture->getHasPremultipliedAlpha() && - ( m_tBlendFunc.src == CC_BLEND_SRC && m_tBlendFunc.dst == CC_BLEND_DST ) ) + if (m_pTexture != var) { - m_tBlendFunc.src = GL_SRC_ALPHA; - m_tBlendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; + CC_SAFE_RETAIN(var); + CC_SAFE_RELEASE(m_pTexture); + m_pTexture = var; + updateBlendFunc(); + } +} + +void CCParticleSystem::updateBlendFunc() +{ + CCAssert(! m_pBatchNode, "Can't change blending functions when the particle is being batched"); + + if(m_pTexture) + { + bool premultiplied = m_pTexture->getHasPremultipliedAlpha(); + + m_bOpacityModifyRGB = false; + + if( m_pTexture && ( m_tBlendFunc.src == CC_BLEND_SRC && m_tBlendFunc.dst == CC_BLEND_DST ) ) + { + if( premultiplied ) + { + m_bOpacityModifyRGB = true; + } + else + { + m_tBlendFunc.src = GL_SRC_ALPHA; + m_tBlendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; + } + } } } @@ -1152,9 +1178,22 @@ ccBlendFunc CCParticleSystem::getBlendFunc() return m_tBlendFunc; } -void CCParticleSystem::setBlendFunc(ccBlendFunc var) +void CCParticleSystem::setBlendFunc(ccBlendFunc blendFunc) { - m_tBlendFunc = var; + if( m_tBlendFunc.src != blendFunc.src || m_tBlendFunc.dst != blendFunc.dst ) { + m_tBlendFunc = blendFunc; + this->updateBlendFunc(); + } +} + +bool CCParticleSystem::getOpacityModifyRGB() +{ + return m_bOpacityModifyRGB; +} + +void CCParticleSystem::setOpacityModifyRGB(bool bOpacityModifyRGB) +{ + m_bOpacityModifyRGB = bOpacityModifyRGB; } tCCPositionType CCParticleSystem::getPositionType() diff --git a/cocos2dx/particle_nodes/CCParticleSystem.h b/cocos2dx/particle_nodes/CCParticleSystem.h index 04bbd5dcc8..60073ffafa 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.h +++ b/cocos2dx/particle_nodes/CCParticleSystem.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. @@ -99,7 +99,7 @@ typedef struct sCCParticle { float rotation; float deltaRotation; - ccTime timeToLive; + float timeToLive; unsigned int atlasIndex; @@ -324,6 +324,9 @@ public: CC_PROPERTY(CCTexture2D*, m_pTexture, Texture) /** conforms to CocosNodeTexture protocol */ CC_PROPERTY(ccBlendFunc, m_tBlendFunc, BlendFunc) + /** does the alpha value modify color */ + CC_PROPERTY(bool, m_bOpacityModifyRGB, OpacityModifyRGB) + /** whether or not the particles are using blend additive. If enabled, the following blending function will be used. @code @@ -389,8 +392,11 @@ public: //! should be overriden by subclasses virtual void postStep(); - virtual void update(ccTime dt); + virtual void update(float dt); virtual void updateWithNoTime(void); + +protected: + virtual void updateBlendFunc(); }; NS_CC_END diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp index cfa563ccac..62c31058b4 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp @@ -1,7 +1,7 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada -Copyright (c) 2009 Leonardo KasperaviÄius +Copyright (c) 2009 Leonardo KasperaviÄius Copyright (c) 2011 Zynga Inc. http://www.cocos2d-x.org @@ -236,8 +236,10 @@ void CCParticleSystemQuad::updateQuadWithParticle(tCCParticle* particle, const C { quad = &(m_pQuads[m_uParticleIdx]); } - ccColor4B color = {(GLubyte)(particle->color.r * 255), (GLubyte)(particle->color.g * 255), (GLubyte)(particle->color.b * 255), - (GLubyte)(particle->color.a * 255)}; + ccColor4B color = (m_bOpacityModifyRGB) + ? ccc4( particle->color.r*particle->color.a*255, particle->color.g*particle->color.a*255, particle->color.b*particle->color.a*255, particle->color.a*255) + : ccc4( particle->color.r*255, particle->color.g*255, particle->color.b*255, particle->color.a*255); + quad->bl.colors = color; quad->br.colors = color; quad->tl.colors = color; diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.h b/cocos2dx/particle_nodes/CCParticleSystemQuad.h index 01ac720754..4ca7ac0cad 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.h +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Leonardo KasperaviÄius Copyright (c) 2011 Zynga Inc. @@ -41,10 +41,8 @@ Special features and Limitations: - Particle size can be any float number. - The system can be scaled - The particles can be rotated -- On 1st and 2nd gen iPhones: It is only a bit slower that CCParticleSystemPoint -- On 3rd gen iPhone and iPads: It is MUCH faster than CCParticleSystemPoint -- It consumes more RAM and more GPU memory than CCParticleSystemPoint - It supports subrects +- It supports batched rendering since 1.1 @since v0.8 */ class CC_DLL CCParticleSystemQuad : public CCParticleSystem diff --git a/cocos2dx/platform/CCEGLViewProtocol.cpp b/cocos2dx/platform/CCEGLViewProtocol.cpp index ccf65b5a57..9b0607e532 100644 --- a/cocos2dx/platform/CCEGLViewProtocol.cpp +++ b/cocos2dx/platform/CCEGLViewProtocol.cpp @@ -97,6 +97,8 @@ CCSize CCEGLViewProtocol::getSize() CCSize size; if (m_bNeedScale) { + // retina and scale mode can't be opened at the same time + CCAssert(CC_CONTENT_SCALE_FACTOR() == 1.0f, "retina and scale mode can't be opened at the same time!"); size.setSize(m_sSizeInPoint.width, m_sSizeInPoint.height); } else @@ -135,6 +137,7 @@ void CCEGLViewProtocol::setViewPortInPoints(float x , float y , float w , float { if (m_bNeedScale) { + CCAssert(CC_CONTENT_SCALE_FACTOR() == 1.0f, "retina and scale mode can't be opened at the same time!"); float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR(); glViewport((GLint)(x * factor + m_rcViewPort.origin.x), (GLint)(y * factor + m_rcViewPort.origin.y), @@ -143,10 +146,11 @@ void CCEGLViewProtocol::setViewPortInPoints(float x , float y , float w , float } else { - glViewport((GLint)x, - (GLint)y, - (GLsizei)w, - (GLsizei)h); + glViewport( + (GLint)(x*CC_CONTENT_SCALE_FACTOR()), + (GLint)(y*CC_CONTENT_SCALE_FACTOR()), + (GLsizei)(w*CC_CONTENT_SCALE_FACTOR()), + (GLsizei)(h*CC_CONTENT_SCALE_FACTOR())); } } @@ -154,6 +158,7 @@ void CCEGLViewProtocol::setScissorInPoints(float x , float y , float w , float h { if (m_bNeedScale) { + CCAssert(CC_CONTENT_SCALE_FACTOR() == 1.0f, "retina and scale mode can't be opened at the same time!"); float factor = m_fScreenScaleFactor / CC_CONTENT_SCALE_FACTOR(); glScissor((GLint)(x * factor + m_rcViewPort.origin.x), (GLint)(y * factor + m_rcViewPort.origin.y), @@ -162,10 +167,11 @@ void CCEGLViewProtocol::setScissorInPoints(float x , float y , float w , float h } else { - glScissor((GLint)x, - (GLint)y, - (GLsizei)w, - (GLsizei)h); + glScissor( + (GLint)(x * CC_CONTENT_SCALE_FACTOR()), + (GLint)(y * CC_CONTENT_SCALE_FACTOR()), + (GLsizei)(w * CC_CONTENT_SCALE_FACTOR()), + (GLsizei)(h * CC_CONTENT_SCALE_FACTOR())); } } diff --git a/cocos2dx/platform/CCFileUtils.h b/cocos2dx/platform/CCFileUtils.h index 9d604088aa..b4e83fde1d 100644 --- a/cocos2dx/platform/CCFileUtils.h +++ b/cocos2dx/platform/CCFileUtils.h @@ -34,7 +34,8 @@ NS_CC_BEGIN class CC_DLL CCFileUtils { public: - + static CCFileUtils* sharedFileUtils(); + static void purgeFileUtils(); /** @brief Get resource file data @param[in] pszFileName The resource file name which contain the path @@ -43,7 +44,7 @@ public: @return if success,the pointer of data will be returned,or NULL is returned @warning If you get the file data succeed,you must delete it after used. */ - static unsigned char* getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize); + unsigned char* getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize); /** @brief Get resource file data from zip file @@ -52,7 +53,7 @@ public: @return if success,the pointer of data will be returned,or NULL is returned @warning If you get the file data succeed,you must delete it after used. */ - static unsigned char* getFileDataFromZip(const char* pszZipFilePath, const char* pszFileName, unsigned long * pSize); + unsigned char* getFileDataFromZip(const char* pszZipFilePath, const char* pszFileName, unsigned long * pSize); /** removes the suffix from a path * On RetinaDisplay it will remove the -hd suffix @@ -62,7 +63,7 @@ public: @since v0.99.5 */ - static std::string& removeSuffixFromFile(std::string& path); + std::string& removeSuffixFromFile(std::string& path); /** @brief Generate the absolute path of the file. @@ -72,7 +73,7 @@ public: If you have not set the ResourcePath,the function add "/NEWPLUS/TDA_DATA/UserData/" as default. You can set ResourcePath by function void setResourcePath(const char *pszResourcePath); */ - static const char* fullPathFromRelativePath(const char *pszRelativePath); + const char* fullPathFromRelativePath(const char *pszRelativePath); /** Returns the fullpath of an filename including the resolution of the image. @@ -88,10 +89,10 @@ public: If a RetinaDisplay file is found, it will set resolution type to kCCResolutionRetinaDisplay */ - static const char* fullPathFromRelativePath(const char *pszRelativePath, ccResolutionType *pResolutionType); + const char* fullPathFromRelativePath(const char *pszRelativePath, ccResolutionType *pResolutionType); /// @cond - static const char* fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile); + const char* fullPathFromRelativeFile(const char *pszFilename, const char *pszRelativeFile); /// @endcond /** Sets the iPhone RetinaDisplay suffix to load resources. @@ -100,7 +101,7 @@ public: @since v1.1 */ - static void setiPhoneRetinaDisplaySuffix(const char *suffix); + void setiPhoneRetinaDisplaySuffix(const char *suffix); /** Sets the iPad suffix to load resources. By default it is "". @@ -108,7 +109,7 @@ public: */ - static void setiPadSuffix(const char *suffix); + void setiPadSuffix(const char *suffix); /** Sets the iPad Retina Display suffix to load resources. By default it is "-ipadhd". @@ -116,7 +117,7 @@ public: @since v1.1 */ - static void setiPadRetinaDisplaySuffix(const char *suffix); + void setiPadRetinaDisplaySuffix(const char *suffix); /** Returns whether or not a given filename exists with the iPad suffix. Only available on iOS. Not supported on OS X. @@ -124,9 +125,9 @@ public: */ bool iPadFileExistsAtPath(const char *filename); - /** Returns whether or not a given filename exists with the iPad RetinaDisplay suffix. - Only available on iOS. Not supported on OS X. - + /** Returns whether or not a given filename exists with the iPad RetinaDisplay suffix. + Only available on iOS. Not supported on OS X. + @since v2.0 */ bool iPadRetinaDisplayFileExistsAtPath(const char *filename); @@ -143,50 +144,19 @@ public: In android, if you want to read file other than apk, you shoud use invoke getFileData(), and pass the absolute path. */ - static void setResourcePath(const char *pszResourcePath); + void setResourcePath(const char *pszResourcePath); /** @brief Get the writeable path @return The path that can write/read file */ - static std::string getWriteablePath(); + std::string getWriteablePath(); /** @brief Set/Get whether pop-up a message box when the image load failed */ - static void setIsPopupNotify(bool bNotify); - static bool getIsPopupNotify(); - - /////////////////////////////////////////////////// - // interfaces on ios - /////////////////////////////////////////////////// - static int ccLoadFileIntoMemory(const char *filename, unsigned char **out); -}; - -class CCFileData -{ -public: - CCFileData(const char* pszFileName, const char* pszMode) - : m_pBuffer(0) - , m_uSize(0) - { - m_pBuffer = CCFileUtils::getFileData(pszFileName, pszMode, &m_uSize); - } - ~CCFileData() - { - CC_SAFE_DELETE_ARRAY(m_pBuffer); - } - - bool reset(const char* pszFileName, const char* pszMode) - { - CC_SAFE_DELETE_ARRAY(m_pBuffer); - m_uSize = 0; - m_pBuffer = CCFileUtils::getFileData(pszFileName, pszMode, &m_uSize); - return (m_pBuffer) ? true : false; - } - - CC_SYNTHESIZE_READONLY(unsigned char *, m_pBuffer, Buffer); - CC_SYNTHESIZE_READONLY(unsigned long , m_uSize, Size); + void setIsPopupNotify(bool bNotify); + bool getIsPopupNotify(); }; NS_CC_END diff --git a/cocos2dx/platform/CCImageCommon_cpp.h b/cocos2dx/platform/CCImageCommon_cpp.h index cdc9272109..80e7788683 100644 --- a/cocos2dx/platform/CCImageCommon_cpp.h +++ b/cocos2dx/platform/CCImageCommon_cpp.h @@ -95,15 +95,21 @@ CCImage::~CCImage() bool CCImage::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFmtPng*/) { CC_UNUSED_PARAM(eImgFmt); - CCFileData data(CCFileUtils::fullPathFromRelativePath(strPath), "rb"); - return initWithImageData(data.getBuffer(), data.getSize(), eImgFmt); + + unsigned long nSize; + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(strPath), "rb", &nSize); + + return initWithImageData(pBuffer, nSize, eImgFmt); } bool CCImage::initWithImageFileThreadSafe(const char *fullpath, EImageFormat imageType) { CC_UNUSED_PARAM(imageType); - CCFileData data(fullpath, "rb"); - return initWithImageData(data.getBuffer(), data.getSize(), imageType); + + unsigned long nSize; + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(fullpath, "rb", &nSize); + + return initWithImageData(pBuffer, nSize, imageType); } bool CCImage::initWithImageData(void * pData, diff --git a/cocos2dx/platform/CCPlatformMacros.h b/cocos2dx/platform/CCPlatformMacros.h index e3fda7014c..5fca4d1fae 100644 --- a/cocos2dx/platform/CCPlatformMacros.h +++ b/cocos2dx/platform/CCPlatformMacros.h @@ -31,16 +31,16 @@ #include "CCPlatformConfig.h" #include "CCPlatformDefine.h" -/** @def CC_ENABLE_CACHE_TEXTTURE_DATA +/** @def CC_ENABLE_CACHE_TEXTURE_DATA Enable it if you want to cache the texture data. Basically,it's only enabled in android It's new in cocos2d-x since v0.99.5 */ #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - #define CC_ENABLE_CACHE_TEXTTURE_DATA 1 + #define CC_ENABLE_CACHE_TEXTURE_DATA 1 #else - #define CC_ENABLE_CACHE_TEXTTURE_DATA 0 + #define CC_ENABLE_CACHE_TEXTURE_DATA 0 #endif #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) || (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) @@ -166,22 +166,27 @@ public: virtual void set##funName(varType var) \ #define CC_SAFE_RETAIN(p) do { if(p) { (p)->retain(); } } while(0) #define CC_BREAK_IF(cond) if(cond) break +#define __CCLOGWITHFUNCTION(s, ...) \ + CCLog("%s : %s",__FUNCTION__, CCString::stringWithFormat(s, ##__VA_ARGS__)->getCString()) // cocos2d debug #if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0 -#define CCLOG(...) -#define CCLOGINFO(...) -#define CCLOGERROR(...) +#define CCLOG(...) do {} while (0) +#define CCLOGINFO(...) do {} while (0) +#define CCLOGERROR(...) do {} while (0) +#define CCLOGWARN(...) do {} while (0) #elif COCOS2D_DEBUG == 1 #define CCLOG(format, ...) cocos2d::CCLog(format, ##__VA_ARGS__) #define CCLOGERROR(format,...) cocos2d::CCLog(format, ##__VA_ARGS__) -#define CCLOGINFO(format,...) do {} while (0) +#define CCLOGINFO(format,...) cocos2d::CCLog(format, ##__VA_ARGS__) +#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__) #elif COCOS2D_DEBUG > 1 #define CCLOG(format, ...) cocos2d::CCLog(format, ##__VA_ARGS__) #define CCLOGERROR(format,...) cocos2d::CCLog(format, ##__VA_ARGS__) #define CCLOGINFO(format,...) cocos2d::CCLog(format, ##__VA_ARGS__) +#define CCLOGWARN(...) __CCLOGWITHFUNCTION(__VA_ARGS__) #endif // COCOS2D_DEBUG // Lua engine debug diff --git a/cocos2dx/platform/CCSAXParser.cpp b/cocos2dx/platform/CCSAXParser.cpp index e44d55aba7..3c7c9cbd3d 100644 --- a/cocos2dx/platform/CCSAXParser.cpp +++ b/cocos2dx/platform/CCSAXParser.cpp @@ -83,9 +83,8 @@ bool CCSAXParser::parse(const char* pXMLData, unsigned int uDataLength) bool CCSAXParser::parse(const char *pszFile) { - CCFileData data(pszFile, "rt"); - unsigned long size = data.getSize(); - char *pBuffer = (char*) data.getBuffer(); + unsigned long size; + char *pBuffer = (char*)CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(pszFile, "rt", &size); if (!pBuffer) { diff --git a/cocos2dx/platform/CCThread.cpp b/cocos2dx/platform/CCThread.cpp index 0ba2c38cc2..7271c76ec3 100644 --- a/cocos2dx/platform/CCThread.cpp +++ b/cocos2dx/platform/CCThread.cpp @@ -24,6 +24,9 @@ THE SOFTWARE. #include "CCThread.h" +// iOS already has a CCThread.mm +#if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) + NS_CC_BEGIN CCThread::~CCThread() @@ -37,3 +40,5 @@ void CCThread::createAutoreleasePool() } NS_CC_END + +#endif \ No newline at end of file diff --git a/cocos2dx/platform/android/CCGL.h b/cocos2dx/platform/android/CCGL.h index cdd9794032..f2701dab0a 100644 --- a/cocos2dx/platform/android/CCGL.h +++ b/cocos2dx/platform/android/CCGL.h @@ -53,4 +53,4 @@ extern PFNGLDELETEVERTEXARRAYSOESPROC glDeleteVertexArraysOESEXT; #define glDeleteVertexArraysOES glDeleteVertexArraysOESEXT -#endif // __PLATFOMR_CCGL_H__ +#endif // __CCGL_H__ diff --git a/cocos2dx/platform/ios/CCFileUtils.mm b/cocos2dx/platform/ios/CCFileUtils.mm index 2cc27f59af..6c6aa2b79a 100644 --- a/cocos2dx/platform/ios/CCFileUtils.mm +++ b/cocos2dx/platform/ios/CCFileUtils.mm @@ -49,6 +49,17 @@ static NSString *__suffixiPad =@"-ipad"; static NSString *__suffixiPadRetinaDisplay =@"-ipadhd"; static NSFileManager *__localFileManager= [[NSFileManager alloc] init]; +static CCFileUtils* s_pFileUtils = NULL; + +CCFileUtils* CCFileUtils::sharedFileUtils() +{ + if (s_pFileUtils == NULL) + { + s_pFileUtils = new CCFileUtils(); + } + return s_pFileUtils; +} + static NSString* removeSuffixFromPath(NSString *suffix, NSString *path) { // quick return @@ -389,7 +400,7 @@ const char *CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const CCDictionary* ccFileUtils_dictionaryWithContentsOfFileThreadSafe(const char *pFileName) { - const char* pszFullPath = CCFileUtils::fullPathFromRelativePath(pFileName); + const char* pszFullPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pFileName); NSString* pPath = [NSString stringWithUTF8String:pszFullPath]; NSDictionary* pDict = [NSDictionary dictionaryWithContentsOfFile:pPath]; diff --git a/cocos2dx/platform/ios/CCGL.h b/cocos2dx/platform/ios/CCGL.h index 5dc4f76483..faad8e010d 100644 --- a/cocos2dx/platform/ios/CCGL.h +++ b/cocos2dx/platform/ios/CCGL.h @@ -34,4 +34,4 @@ THE SOFTWARE. #include -#endif // __PLATFOMR_CCGL_H__ +#endif // __CCGL_H__ diff --git a/cocos2dx/platform/ios/CCImage.mm b/cocos2dx/platform/ios/CCImage.mm index e9b53d7305..98e31306a2 100644 --- a/cocos2dx/platform/ios/CCImage.mm +++ b/cocos2dx/platform/ios/CCImage.mm @@ -347,8 +347,10 @@ CCImage::~CCImage() bool CCImage::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFmtPng*/) { - CCFileData data(CCFileUtils::fullPathFromRelativePath(strPath), "rb"); - return initWithImageData(data.getBuffer(), data.getSize(), eImgFmt); + unsigned long nSize; + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->getFileData(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(strPath), "rb", &nSize); + + return initWithImageData(pBuffer, nSize, eImgFmt); } bool CCImage::initWithImageFileThreadSafe(const char *fullpath, EImageFormat imageType) @@ -356,9 +358,11 @@ bool CCImage::initWithImageFileThreadSafe(const char *fullpath, EImageFormat ima CC_UNUSED_PARAM(imageType); /* * CCFileUtils::fullPathFromRelativePath() is not thread-safe, it use autorelease(). - */ - CCFileData data(fullpath, "rb"); - return initWithImageData(data.getBuffer(), data.getSize(), imageType); + */ + unsigned long nSize; + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->getFileData(fullpath, "rb", &nSize); + + return initWithImageData(pBuffer, nSize, imageType); } bool CCImage::initWithImageData(void * pData, diff --git a/cocos2dx/platform/third_party/win32/OGLES/EGL/egl.h b/cocos2dx/platform/third_party/win32/OGLES/EGL/egl.h deleted file mode 100644 index 1c65660d42..0000000000 --- a/cocos2dx/platform/third_party/win32/OGLES/EGL/egl.h +++ /dev/null @@ -1,329 +0,0 @@ -/* -*- mode: c; tab-width: 8; -*- */ -/* vi: set sw=4 ts=8: */ -/* Reference version of egl.h for EGL 1.4. - */ - -/* -** Copyright (c) 2007-2009 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -#ifndef __egl_h_ -#define __egl_h_ - -/* All platform-dependent types and macro boilerplate (such as EGLAPI - * and EGLAPIENTRY) should go in eglplatform.h. - */ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* EGL Types */ -/* EGLint is defined in eglplatform.h */ -typedef unsigned int EGLBoolean; -typedef unsigned int EGLenum; -typedef void *EGLConfig; -typedef void *EGLContext; -typedef void *EGLDisplay; -typedef void *EGLSurface; -typedef void *EGLClientBuffer; - -/* EGL Versioning */ -#define EGL_VERSION_1_0 1 -#define EGL_VERSION_1_1 1 -#define EGL_VERSION_1_2 1 -#define EGL_VERSION_1_3 1 -#define EGL_VERSION_1_4 1 - -/* EGL Enumerants. Bitmasks and other exceptional cases aside, most - * enums are assigned unique values starting at 0x3000. - */ - -/* EGL aliases */ -#define EGL_FALSE 0 -#define EGL_TRUE 1 - -/* Out-of-band handle values */ -#define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType)0) -#define EGL_NO_CONTEXT ((EGLContext)0) -#define EGL_NO_DISPLAY ((EGLDisplay)0) -#define EGL_NO_SURFACE ((EGLSurface)0) - -/* Out-of-band attribute value */ -#define EGL_DONT_CARE ((EGLint)-1) - -/* Errors / GetError return values */ -#define EGL_SUCCESS 0x3000 -#define EGL_NOT_INITIALIZED 0x3001 -#define EGL_BAD_ACCESS 0x3002 -#define EGL_BAD_ALLOC 0x3003 -#define EGL_BAD_ATTRIBUTE 0x3004 -#define EGL_BAD_CONFIG 0x3005 -#define EGL_BAD_CONTEXT 0x3006 -#define EGL_BAD_CURRENT_SURFACE 0x3007 -#define EGL_BAD_DISPLAY 0x3008 -#define EGL_BAD_MATCH 0x3009 -#define EGL_BAD_NATIVE_PIXMAP 0x300A -#define EGL_BAD_NATIVE_WINDOW 0x300B -#define EGL_BAD_PARAMETER 0x300C -#define EGL_BAD_SURFACE 0x300D -#define EGL_CONTEXT_LOST 0x300E /* EGL 1.1 - IMG_power_management */ - -/* Reserved 0x300F-0x301F for additional errors */ - -/* Config attributes */ -#define EGL_BUFFER_SIZE 0x3020 -#define EGL_ALPHA_SIZE 0x3021 -#define EGL_BLUE_SIZE 0x3022 -#define EGL_GREEN_SIZE 0x3023 -#define EGL_RED_SIZE 0x3024 -#define EGL_DEPTH_SIZE 0x3025 -#define EGL_STENCIL_SIZE 0x3026 -#define EGL_CONFIG_CAVEAT 0x3027 -#define EGL_CONFIG_ID 0x3028 -#define EGL_LEVEL 0x3029 -#define EGL_MAX_PBUFFER_HEIGHT 0x302A -#define EGL_MAX_PBUFFER_PIXELS 0x302B -#define EGL_MAX_PBUFFER_WIDTH 0x302C -#define EGL_NATIVE_RENDERABLE 0x302D -#define EGL_NATIVE_VISUAL_ID 0x302E -#define EGL_NATIVE_VISUAL_TYPE 0x302F -#define EGL_PRESERVED_RESOURCES 0x3030 -#define EGL_SAMPLES 0x3031 -#define EGL_SAMPLE_BUFFERS 0x3032 -#define EGL_SURFACE_TYPE 0x3033 -#define EGL_TRANSPARENT_TYPE 0x3034 -#define EGL_TRANSPARENT_BLUE_VALUE 0x3035 -#define EGL_TRANSPARENT_GREEN_VALUE 0x3036 -#define EGL_TRANSPARENT_RED_VALUE 0x3037 -#define EGL_NONE 0x3038 /* Attrib list terminator */ -#define EGL_BIND_TO_TEXTURE_RGB 0x3039 -#define EGL_BIND_TO_TEXTURE_RGBA 0x303A -#define EGL_MIN_SWAP_INTERVAL 0x303B -#define EGL_MAX_SWAP_INTERVAL 0x303C -#define EGL_LUMINANCE_SIZE 0x303D -#define EGL_ALPHA_MASK_SIZE 0x303E -#define EGL_COLOR_BUFFER_TYPE 0x303F -#define EGL_RENDERABLE_TYPE 0x3040 -#define EGL_MATCH_NATIVE_PIXMAP 0x3041 /* Pseudo-attribute (not queryable) */ -#define EGL_CONFORMANT 0x3042 - -/* Reserved 0x3041-0x304F for additional config attributes */ - -/* Config attribute values */ -#define EGL_SLOW_CONFIG 0x3050 /* EGL_CONFIG_CAVEAT value */ -#define EGL_NON_CONFORMANT_CONFIG 0x3051 /* EGL_CONFIG_CAVEAT value */ -#define EGL_TRANSPARENT_RGB 0x3052 /* EGL_TRANSPARENT_TYPE value */ -#define EGL_RGB_BUFFER 0x308E /* EGL_COLOR_BUFFER_TYPE value */ -#define EGL_LUMINANCE_BUFFER 0x308F /* EGL_COLOR_BUFFER_TYPE value */ - -/* More config attribute values, for EGL_TEXTURE_FORMAT */ -#define EGL_NO_TEXTURE 0x305C -#define EGL_TEXTURE_RGB 0x305D -#define EGL_TEXTURE_RGBA 0x305E -#define EGL_TEXTURE_2D 0x305F - -/* Config attribute mask bits */ -#define EGL_PBUFFER_BIT 0x0001 /* EGL_SURFACE_TYPE mask bits */ -#define EGL_PIXMAP_BIT 0x0002 /* EGL_SURFACE_TYPE mask bits */ -#define EGL_WINDOW_BIT 0x0004 /* EGL_SURFACE_TYPE mask bits */ -#define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020 /* EGL_SURFACE_TYPE mask bits */ -#define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040 /* EGL_SURFACE_TYPE mask bits */ -#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200 /* EGL_SURFACE_TYPE mask bits */ -#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400 /* EGL_SURFACE_TYPE mask bits */ - -#define EGL_OPENGL_ES_BIT 0x0001 /* EGL_RENDERABLE_TYPE mask bits */ -#define EGL_OPENVG_BIT 0x0002 /* EGL_RENDERABLE_TYPE mask bits */ -#define EGL_OPENGL_ES2_BIT 0x0004 /* EGL_RENDERABLE_TYPE mask bits */ -#define EGL_OPENGL_BIT 0x0008 /* EGL_RENDERABLE_TYPE mask bits */ - -/* QueryString targets */ -#define EGL_VENDOR 0x3053 -#define EGL_VERSION 0x3054 -#define EGL_EXTENSIONS 0x3055 -#define EGL_CLIENT_APIS 0x308D - -/* QuerySurface / SurfaceAttrib / CreatePbufferSurface targets */ -#define EGL_HEIGHT 0x3056 -#define EGL_WIDTH 0x3057 -#define EGL_LARGEST_PBUFFER 0x3058 -#define EGL_TEXTURE_FORMAT 0x3080 -#define EGL_TEXTURE_TARGET 0x3081 -#define EGL_MIPMAP_TEXTURE 0x3082 -#define EGL_MIPMAP_LEVEL 0x3083 -#define EGL_RENDER_BUFFER 0x3086 -#define EGL_VG_COLORSPACE 0x3087 -#define EGL_VG_ALPHA_FORMAT 0x3088 -#define EGL_HORIZONTAL_RESOLUTION 0x3090 -#define EGL_VERTICAL_RESOLUTION 0x3091 -#define EGL_PIXEL_ASPECT_RATIO 0x3092 -#define EGL_SWAP_BEHAVIOR 0x3093 -#define EGL_MULTISAMPLE_RESOLVE 0x3099 - -/* EGL_RENDER_BUFFER values / BindTexImage / ReleaseTexImage buffer targets */ -#define EGL_BACK_BUFFER 0x3084 -#define EGL_SINGLE_BUFFER 0x3085 - -/* OpenVG color spaces */ -#define EGL_VG_COLORSPACE_sRGB 0x3089 /* EGL_VG_COLORSPACE value */ -#define EGL_VG_COLORSPACE_LINEAR 0x308A /* EGL_VG_COLORSPACE value */ - -/* OpenVG alpha formats */ -#define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B /* EGL_ALPHA_FORMAT value */ -#define EGL_VG_ALPHA_FORMAT_PRE 0x308C /* EGL_ALPHA_FORMAT value */ - -/* Constant scale factor by which fractional display resolutions & - * aspect ratio are scaled when queried as integer values. - */ -#define EGL_DISPLAY_SCALING 10000 - -/* Unknown display resolution/aspect ratio */ -#define EGL_UNKNOWN ((EGLint)-1) - -/* Back buffer swap behaviors */ -#define EGL_BUFFER_PRESERVED 0x3094 /* EGL_SWAP_BEHAVIOR value */ -#define EGL_BUFFER_DESTROYED 0x3095 /* EGL_SWAP_BEHAVIOR value */ - -/* CreatePbufferFromClientBuffer buffer types */ -#define EGL_OPENVG_IMAGE 0x3096 - -/* QueryContext targets */ -#define EGL_CONTEXT_CLIENT_TYPE 0x3097 - -/* CreateContext attributes */ -#define EGL_CONTEXT_CLIENT_VERSION 0x3098 - -/* Multisample resolution behaviors */ -#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A /* EGL_MULTISAMPLE_RESOLVE value */ -#define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B /* EGL_MULTISAMPLE_RESOLVE value */ - -/* BindAPI/QueryAPI targets */ -#define EGL_OPENGL_ES_API 0x30A0 -#define EGL_OPENVG_API 0x30A1 -#define EGL_OPENGL_API 0x30A2 - -/* GetCurrentSurface targets */ -#define EGL_DRAW 0x3059 -#define EGL_READ 0x305A - -/* WaitNative engines */ -#define EGL_CORE_NATIVE_ENGINE 0x305B - -/* EGL 1.2 tokens renamed for consistency in EGL 1.3 */ -#define EGL_COLORSPACE EGL_VG_COLORSPACE -#define EGL_ALPHA_FORMAT EGL_VG_ALPHA_FORMAT -#define EGL_COLORSPACE_sRGB EGL_VG_COLORSPACE_sRGB -#define EGL_COLORSPACE_LINEAR EGL_VG_COLORSPACE_LINEAR -#define EGL_ALPHA_FORMAT_NONPRE EGL_VG_ALPHA_FORMAT_NONPRE -#define EGL_ALPHA_FORMAT_PRE EGL_VG_ALPHA_FORMAT_PRE - -/* EGL extensions must request enum blocks from the Khronos - * API Registrar, who maintains the enumerant registry. Submit - * a bug in Khronos Bugzilla against task "Registry". - */ - - - -/* EGL Functions */ - -EGLAPI EGLint EGLAPIENTRY eglGetError(void); - -EGLAPI EGLDisplay EGLAPIENTRY eglGetDisplay(EGLNativeDisplayType display_id); -EGLAPI EGLBoolean EGLAPIENTRY eglInitialize(EGLDisplay dpy, EGLint *major, EGLint *minor); -EGLAPI EGLBoolean EGLAPIENTRY eglTerminate(EGLDisplay dpy); - -EGLAPI const char * EGLAPIENTRY eglQueryString(EGLDisplay dpy, EGLint name); - -EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigs(EGLDisplay dpy, EGLConfig *configs, - EGLint config_size, EGLint *num_config); -EGLAPI EGLBoolean EGLAPIENTRY eglChooseConfig(EGLDisplay dpy, const EGLint *attrib_list, - EGLConfig *configs, EGLint config_size, - EGLint *num_config); -EGLAPI EGLBoolean EGLAPIENTRY eglGetConfigAttrib(EGLDisplay dpy, EGLConfig config, - EGLint attribute, EGLint *value); - -EGLAPI EGLSurface EGLAPIENTRY eglCreateWindowSurface(EGLDisplay dpy, EGLConfig config, - EGLNativeWindowType win, - const EGLint *attrib_list); -EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferSurface(EGLDisplay dpy, EGLConfig config, - const EGLint *attrib_list); -EGLAPI EGLSurface EGLAPIENTRY eglCreatePixmapSurface(EGLDisplay dpy, EGLConfig config, - EGLNativePixmapType pixmap, - const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroySurface(EGLDisplay dpy, EGLSurface surface); -EGLAPI EGLBoolean EGLAPIENTRY eglQuerySurface(EGLDisplay dpy, EGLSurface surface, - EGLint attribute, EGLint *value); - -EGLAPI EGLBoolean EGLAPIENTRY eglBindAPI(EGLenum api); -EGLAPI EGLenum EGLAPIENTRY eglQueryAPI(void); - -EGLAPI EGLBoolean EGLAPIENTRY eglWaitClient(void); - -EGLAPI EGLBoolean EGLAPIENTRY eglReleaseThread(void); - -EGLAPI EGLSurface EGLAPIENTRY eglCreatePbufferFromClientBuffer( - EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, - EGLConfig config, const EGLint *attrib_list); - -EGLAPI EGLBoolean EGLAPIENTRY eglSurfaceAttrib(EGLDisplay dpy, EGLSurface surface, - EGLint attribute, EGLint value); -EGLAPI EGLBoolean EGLAPIENTRY eglBindTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer); -EGLAPI EGLBoolean EGLAPIENTRY eglReleaseTexImage(EGLDisplay dpy, EGLSurface surface, EGLint buffer); - - -EGLAPI EGLBoolean EGLAPIENTRY eglSwapInterval(EGLDisplay dpy, EGLint interval); - - -EGLAPI EGLContext EGLAPIENTRY eglCreateContext(EGLDisplay dpy, EGLConfig config, - EGLContext share_context, - const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroyContext(EGLDisplay dpy, EGLContext ctx); -EGLAPI EGLBoolean EGLAPIENTRY eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, - EGLSurface read, EGLContext ctx); - -EGLAPI EGLContext EGLAPIENTRY eglGetCurrentContext(void); -EGLAPI EGLSurface EGLAPIENTRY eglGetCurrentSurface(EGLint readdraw); -EGLAPI EGLDisplay EGLAPIENTRY eglGetCurrentDisplay(void); -EGLAPI EGLBoolean EGLAPIENTRY eglQueryContext(EGLDisplay dpy, EGLContext ctx, - EGLint attribute, EGLint *value); - -EGLAPI EGLBoolean EGLAPIENTRY eglWaitGL(void); -EGLAPI EGLBoolean EGLAPIENTRY eglWaitNative(EGLint engine); -EGLAPI EGLBoolean EGLAPIENTRY eglSwapBuffers(EGLDisplay dpy, EGLSurface surface); -EGLAPI EGLBoolean EGLAPIENTRY eglCopyBuffers(EGLDisplay dpy, EGLSurface surface, - EGLNativePixmapType target); - -/* This is a generic function pointer type, whose name indicates it must - * be cast to the proper type *and calling convention* before use. - */ -typedef void (*__eglMustCastToProperFunctionPointerType)(void); - -/* Now, define eglGetProcAddress using the generic function ptr. type */ -EGLAPI __eglMustCastToProperFunctionPointerType EGLAPIENTRY - eglGetProcAddress(const char *procname); - -#ifdef __cplusplus -} -#endif - -#endif /* __egl_h_ */ diff --git a/cocos2dx/platform/third_party/win32/OGLES/EGL/eglext.h b/cocos2dx/platform/third_party/win32/OGLES/EGL/eglext.h deleted file mode 100644 index 87beb21d24..0000000000 --- a/cocos2dx/platform/third_party/win32/OGLES/EGL/eglext.h +++ /dev/null @@ -1,175 +0,0 @@ -#ifndef __eglext_h_ -#define __eglext_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* -** Copyright (c) 2007-2009 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -#include - -/*************************************************************/ - -/* Header file version number */ -/* Current version at http://www.khronos.org/registry/egl/ */ -#define EGL_EGLEXT_VERSION 4 - -#ifndef EGL_KHR_config_attribs -#define EGL_KHR_config_attribs 1 -#define EGL_CONFORMANT_KHR 0x3042 /* EGLConfig attribute */ -#define EGL_VG_COLORSPACE_LINEAR_BIT_KHR 0x0020 /* EGL_SURFACE_TYPE bitfield */ -#define EGL_VG_ALPHA_FORMAT_PRE_BIT_KHR 0x0040 /* EGL_SURFACE_TYPE bitfield */ -#endif - -#ifndef EGL_KHR_lock_surface -#define EGL_KHR_lock_surface 1 -#define EGL_READ_SURFACE_BIT_KHR 0x0001 /* EGL_LOCK_USAGE_HINT_KHR bitfield */ -#define EGL_WRITE_SURFACE_BIT_KHR 0x0002 /* EGL_LOCK_USAGE_HINT_KHR bitfield */ -#define EGL_LOCK_SURFACE_BIT_KHR 0x0080 /* EGL_SURFACE_TYPE bitfield */ -#define EGL_OPTIMAL_FORMAT_BIT_KHR 0x0100 /* EGL_SURFACE_TYPE bitfield */ -#define EGL_MATCH_FORMAT_KHR 0x3043 /* EGLConfig attribute */ -#define EGL_FORMAT_RGB_565_EXACT_KHR 0x30C0 /* EGL_MATCH_FORMAT_KHR value */ -#define EGL_FORMAT_RGB_565_KHR 0x30C1 /* EGL_MATCH_FORMAT_KHR value */ -#define EGL_FORMAT_RGBA_8888_EXACT_KHR 0x30C2 /* EGL_MATCH_FORMAT_KHR value */ -#define EGL_FORMAT_RGBA_8888_KHR 0x30C3 /* EGL_MATCH_FORMAT_KHR value */ -#define EGL_MAP_PRESERVE_PIXELS_KHR 0x30C4 /* eglLockSurfaceKHR attribute */ -#define EGL_LOCK_USAGE_HINT_KHR 0x30C5 /* eglLockSurfaceKHR attribute */ -#define EGL_BITMAP_POINTER_KHR 0x30C6 /* eglQuerySurface attribute */ -#define EGL_BITMAP_PITCH_KHR 0x30C7 /* eglQuerySurface attribute */ -#define EGL_BITMAP_ORIGIN_KHR 0x30C8 /* eglQuerySurface attribute */ -#define EGL_BITMAP_PIXEL_RED_OFFSET_KHR 0x30C9 /* eglQuerySurface attribute */ -#define EGL_BITMAP_PIXEL_GREEN_OFFSET_KHR 0x30CA /* eglQuerySurface attribute */ -#define EGL_BITMAP_PIXEL_BLUE_OFFSET_KHR 0x30CB /* eglQuerySurface attribute */ -#define EGL_BITMAP_PIXEL_ALPHA_OFFSET_KHR 0x30CC /* eglQuerySurface attribute */ -#define EGL_BITMAP_PIXEL_LUMINANCE_OFFSET_KHR 0x30CD /* eglQuerySurface attribute */ -#define EGL_LOWER_LEFT_KHR 0x30CE /* EGL_BITMAP_ORIGIN_KHR value */ -#define EGL_UPPER_LEFT_KHR 0x30CF /* EGL_BITMAP_ORIGIN_KHR value */ -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLBoolean EGLAPIENTRY eglLockSurfaceKHR (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglUnlockSurfaceKHR (EGLDisplay display, EGLSurface surface); -#endif /* EGL_EGLEXT_PROTOTYPES */ -typedef EGLBoolean (EGLAPIENTRYP PFNEGLLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface, const EGLint *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLUNLOCKSURFACEKHRPROC) (EGLDisplay display, EGLSurface surface); -#endif - -#ifndef EGL_KHR_image -#define EGL_KHR_image 1 -#define EGL_NATIVE_PIXMAP_KHR 0x30B0 /* eglCreateImageKHR target */ -typedef void *EGLImageKHR; -#define EGL_NO_IMAGE_KHR ((EGLImageKHR)0) -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLImageKHR EGLAPIENTRY eglCreateImageKHR (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroyImageKHR (EGLDisplay dpy, EGLImageKHR image); -#endif /* EGL_EGLEXT_PROTOTYPES */ -typedef EGLImageKHR (EGLAPIENTRYP PFNEGLCREATEIMAGEKHRPROC) (EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLint *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGLImageKHR image); -#endif - -#ifndef EGL_KHR_vg_parent_image -#define EGL_KHR_vg_parent_image 1 -#define EGL_VG_PARENT_IMAGE_KHR 0x30BA /* eglCreateImageKHR target */ -#endif - -#ifndef EGL_KHR_gl_texture_2D_image -#define EGL_KHR_gl_texture_2D_image 1 -#define EGL_GL_TEXTURE_2D_KHR 0x30B1 /* eglCreateImageKHR target */ -#define EGL_GL_TEXTURE_LEVEL_KHR 0x30BC /* eglCreateImageKHR attribute */ -#endif - -#ifndef EGL_KHR_gl_texture_cubemap_image -#define EGL_KHR_gl_texture_cubemap_image 1 -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X_KHR 0x30B3 /* eglCreateImageKHR target */ -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X_KHR 0x30B4 /* eglCreateImageKHR target */ -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y_KHR 0x30B5 /* eglCreateImageKHR target */ -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_KHR 0x30B6 /* eglCreateImageKHR target */ -#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z_KHR 0x30B7 /* eglCreateImageKHR target */ -#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_KHR 0x30B8 /* eglCreateImageKHR target */ -#endif - -#ifndef EGL_KHR_gl_texture_3D_image -#define EGL_KHR_gl_texture_3D_image 1 -#define EGL_GL_TEXTURE_3D_KHR 0x30B2 /* eglCreateImageKHR target */ -#define EGL_GL_TEXTURE_ZOFFSET_KHR 0x30BD /* eglCreateImageKHR attribute */ -#endif - -#ifndef EGL_KHR_gl_renderbuffer_image -#define EGL_KHR_gl_renderbuffer_image 1 -#define EGL_GL_RENDERBUFFER_KHR 0x30B9 /* eglCreateImageKHR target */ -#endif - -#ifndef EGL_KHR_reusable_sync -#define EGL_KHR_reusable_sync 1 - -typedef void* EGLSyncKHR; -typedef khronos_utime_nanoseconds_t EGLTimeKHR; - -#define EGL_SYNC_STATUS_KHR 0x30F1 -#define EGL_SIGNALED_KHR 0x30F2 -#define EGL_UNSIGNALED_KHR 0x30F3 -#define EGL_TIMEOUT_EXPIRED_KHR 0x30F5 -#define EGL_CONDITION_SATISFIED_KHR 0x30F6 -#define EGL_SYNC_TYPE_KHR 0x30F7 -#define EGL_SYNC_REUSABLE_KHR 0x30FA -#define EGL_SYNC_FLUSH_COMMANDS_BIT_KHR 0x0001 /* eglClientWaitSyncKHR bitfield */ -#define EGL_FOREVER_KHR 0xFFFFFFFFFFFFFFFFull -#define EGL_NO_SYNC_KHR ((EGLSyncKHR)0) -#ifdef EGL_EGLEXT_PROTOTYPES -EGLAPI EGLSyncKHR EGLAPIENTRY eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); -EGLAPI EGLBoolean EGLAPIENTRY eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync); -EGLAPI EGLint EGLAPIENTRY eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); -EGLAPI EGLBoolean EGLAPIENTRY eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); -EGLAPI EGLBoolean EGLAPIENTRY eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); -#endif /* EGL_EGLEXT_PROTOTYPES */ -typedef EGLSyncKHR (EGLAPIENTRYP PFNEGLCREATESYNCKHR) (EGLDisplay dpy, EGLenum type, const EGLint *attrib_list); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYSYNCKHR) (EGLDisplay dpy, EGLSyncKHR sync); -typedef EGLint (EGLAPIENTRYP PFNEGLCLIENTWAITSYNCKHR) (EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLSIGNALSYNCKHR) (EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode); -typedef EGLBoolean (EGLAPIENTRYP PFNEGLGETSYNCATTRIBKHR) (EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value); -#endif - -#ifndef EGL_KHR_image_base -#define EGL_KHR_image_base 1 -/* Most interfaces defined by EGL_KHR_image_pixmap above */ -#define EGL_IMAGE_PRESERVED_KHR 0x30D2 /* eglCreateImageKHR attribute */ -#endif - -#ifndef EGL_KHR_image_pixmap -#define EGL_KHR_image_pixmap 1 -/* Interfaces defined by EGL_KHR_image above */ -#endif - -#ifndef EGL_IMG_context_priority -#define EGL_IMG_context_priority 1 -#define EGL_CONTEXT_PRIORITY_LEVEL_IMG 0x3100 -#define EGL_CONTEXT_PRIORITY_HIGH_IMG 0x3101 -#define EGL_CONTEXT_PRIORITY_MEDIUM_IMG 0x3102 -#define EGL_CONTEXT_PRIORITY_LOW_IMG 0x3103 -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/cocos2dx/platform/third_party/win32/OGLES/EGL/eglplatform.h b/cocos2dx/platform/third_party/win32/OGLES/EGL/eglplatform.h deleted file mode 100644 index e8a18f25a3..0000000000 --- a/cocos2dx/platform/third_party/win32/OGLES/EGL/eglplatform.h +++ /dev/null @@ -1,124 +0,0 @@ -#ifndef __eglplatform_h_ -#define __eglplatform_h_ - -/* -** Copyright (c) 2007-2009 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -/* Platform-specific types and definitions for egl.h - * - * Adopters may modify khrplatform.h and this file to suit their platform. - * You are encouraged to submit all modifications to the Khronos group so that - * they can be included in future versions of this file. Please submit changes - * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) - * by filing a bug against product "EGL" component "Registry". - */ - -#include - -/* Macros used in EGL function prototype declarations. - * - * EGL functions should be prototyped as: - * - * EGLAPI return-type EGLAPIENTRY eglFunction(arguments); - * typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments); - * - * KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h - */ - -#ifndef EGLAPI -#define EGLAPI KHRONOS_APICALL -#endif - -#define EGLAPIENTRY KHRONOS_APIENTRY -#define EGLAPIENTRYP KHRONOS_APIENTRY* - -/* The types NativeDisplayType, NativeWindowType, and NativePixmapType - * are aliases of window-system-dependent types, such as X Display * or - * Windows Device Context. They must be defined in platform-specific - * code below. The EGL-prefixed versions of Native*Type are the same - * types, renamed in EGL 1.3 so all types in the API start with "EGL". - */ - -#if defined(_WIN32) && !defined(__WINSCW__) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */ -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN 1 -#endif -#include - -typedef HDC EGLNativeDisplayType; -typedef HBITMAP EGLNativePixmapType; -typedef HWND EGLNativeWindowType; - -#elif defined(SUPPORT_X11) - -/* X11 (tentative) */ -#include -#include - -typedef Display *EGLNativeDisplayType; -typedef Pixmap EGLNativePixmapType; -typedef Window EGLNativeWindowType; - - -#elif defined(ANDROID) - -struct android_native_window_t; -struct egl_native_pixmap_t; - -typedef struct android_native_window_t* EGLNativeWindowType; -typedef struct egl_native_pixmap_t* EGLNativePixmapType; -typedef void* EGLNativeDisplayType; - -#else - -#if defined(_WIN64) || __WORDSIZE == 64 -typedef khronos_int64_t EGLNativeDisplayType; -#else -typedef int EGLNativeDisplayType; -#endif - -typedef void *EGLNativeWindowType; -typedef void *EGLNativePixmapType; - -#endif - -/* EGL 1.2 types, renamed for consistency in EGL 1.3 */ -typedef EGLNativeDisplayType NativeDisplayType; -typedef EGLNativePixmapType NativePixmapType; -typedef EGLNativeWindowType NativeWindowType; - - -/* Define EGLint. This must be a signed integral type large enough to contain - * all legal attribute names and values passed into and out of EGL, whether - * their type is boolean, bitmask, enumerant (symbolic constant), integer, - * handle, or other. While in general a 32-bit integer will suffice, if - * handles are 64 bit types, then EGLint should be defined as a signed 64-bit - * integer type. - */ -#if defined(_WIN64) || __WORDSIZE == 64 -typedef khronos_int64_t EGLint; -#else -typedef khronos_int32_t EGLint; -#endif - -#endif /* __eglplatform_h */ diff --git a/cocos2dx/platform/third_party/win32/OGLES/GL/glew.h.REMOVED.git-id b/cocos2dx/platform/third_party/win32/OGLES/GL/glew.h.REMOVED.git-id new file mode 100644 index 0000000000..3e2934f9e6 --- /dev/null +++ b/cocos2dx/platform/third_party/win32/OGLES/GL/glew.h.REMOVED.git-id @@ -0,0 +1 @@ +ecd17c38e19265c7777dcd20993d744992f163a7 \ No newline at end of file diff --git a/cocos2dx/platform/third_party/win32/OGLES/GL/glxew.h b/cocos2dx/platform/third_party/win32/OGLES/GL/glxew.h new file mode 100644 index 0000000000..83c4bc6f8c --- /dev/null +++ b/cocos2dx/platform/third_party/win32/OGLES/GL/glxew.h @@ -0,0 +1,1587 @@ +/* +** The OpenGL Extension Wrangler Library +** Copyright (C) 2002-2008, Milan Ikits +** Copyright (C) 2002-2008, Marcelo E. Magallon +** Copyright (C) 2002, Lev Povalahev +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** +** * Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** * The name of the author may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +** THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* + * Mesa 3-D graphics library + * Version: 7.0 + * + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/* +** Copyright (c) 2007 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +#ifndef __glxew_h__ +#define __glxew_h__ +#define __GLXEW_H__ + +#ifdef __glxext_h_ +#error glxext.h included before glxew.h +#endif + +#if defined(GLX_H) || defined(__GLX_glx_h__) || defined(__glx_h__) +#error glx.h included before glxew.h +#endif + +#define __glxext_h_ + +#define GLX_H +#define __GLX_glx_h__ +#define __glx_h__ + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* ---------------------------- GLX_VERSION_1_0 --------------------------- */ + +#ifndef GLX_VERSION_1_0 +#define GLX_VERSION_1_0 1 + +#define GLX_USE_GL 1 +#define GLX_BUFFER_SIZE 2 +#define GLX_LEVEL 3 +#define GLX_RGBA 4 +#define GLX_DOUBLEBUFFER 5 +#define GLX_STEREO 6 +#define GLX_AUX_BUFFERS 7 +#define GLX_RED_SIZE 8 +#define GLX_GREEN_SIZE 9 +#define GLX_BLUE_SIZE 10 +#define GLX_ALPHA_SIZE 11 +#define GLX_DEPTH_SIZE 12 +#define GLX_STENCIL_SIZE 13 +#define GLX_ACCUM_RED_SIZE 14 +#define GLX_ACCUM_GREEN_SIZE 15 +#define GLX_ACCUM_BLUE_SIZE 16 +#define GLX_ACCUM_ALPHA_SIZE 17 +#define GLX_BAD_SCREEN 1 +#define GLX_BAD_ATTRIBUTE 2 +#define GLX_NO_EXTENSION 3 +#define GLX_BAD_VISUAL 4 +#define GLX_BAD_CONTEXT 5 +#define GLX_BAD_VALUE 6 +#define GLX_BAD_ENUM 7 + +typedef XID GLXDrawable; +typedef XID GLXPixmap; +#ifdef __sun +typedef struct __glXContextRec *GLXContext; +#else +typedef struct __GLXcontextRec *GLXContext; +#endif + +typedef unsigned int GLXVideoDeviceNV; + +extern Bool glXQueryExtension (Display *dpy, int *errorBase, int *eventBase); +extern Bool glXQueryVersion (Display *dpy, int *major, int *minor); +extern int glXGetConfig (Display *dpy, XVisualInfo *vis, int attrib, int *value); +extern XVisualInfo* glXChooseVisual (Display *dpy, int screen, int *attribList); +extern GLXPixmap glXCreateGLXPixmap (Display *dpy, XVisualInfo *vis, Pixmap pixmap); +extern void glXDestroyGLXPixmap (Display *dpy, GLXPixmap pix); +extern GLXContext glXCreateContext (Display *dpy, XVisualInfo *vis, GLXContext shareList, Bool direct); +extern void glXDestroyContext (Display *dpy, GLXContext ctx); +extern Bool glXIsDirect (Display *dpy, GLXContext ctx); +extern void glXCopyContext (Display *dpy, GLXContext src, GLXContext dst, GLulong mask); +extern Bool glXMakeCurrent (Display *dpy, GLXDrawable drawable, GLXContext ctx); +extern GLXContext glXGetCurrentContext (void); +extern GLXDrawable glXGetCurrentDrawable (void); +extern void glXWaitGL (void); +extern void glXWaitX (void); +extern void glXSwapBuffers (Display *dpy, GLXDrawable drawable); +extern void glXUseXFont (Font font, int first, int count, int listBase); + +#define GLXEW_VERSION_1_0 GLXEW_GET_VAR(__GLXEW_VERSION_1_0) + +#endif /* GLX_VERSION_1_0 */ + +/* ---------------------------- GLX_VERSION_1_1 --------------------------- */ + +#ifndef GLX_VERSION_1_1 +#define GLX_VERSION_1_1 + +#define GLX_VENDOR 0x1 +#define GLX_VERSION 0x2 +#define GLX_EXTENSIONS 0x3 + +extern const char* glXQueryExtensionsString (Display *dpy, int screen); +extern const char* glXGetClientString (Display *dpy, int name); +extern const char* glXQueryServerString (Display *dpy, int screen, int name); + +#define GLXEW_VERSION_1_1 GLXEW_GET_VAR(__GLXEW_VERSION_1_1) + +#endif /* GLX_VERSION_1_1 */ + +/* ---------------------------- GLX_VERSION_1_2 ---------------------------- */ + +#ifndef GLX_VERSION_1_2 +#define GLX_VERSION_1_2 1 + +typedef Display* ( * PFNGLXGETCURRENTDISPLAYPROC) (void); + +#define glXGetCurrentDisplay GLXEW_GET_FUN(__glewXGetCurrentDisplay) + +#define GLXEW_VERSION_1_2 GLXEW_GET_VAR(__GLXEW_VERSION_1_2) + +#endif /* GLX_VERSION_1_2 */ + +/* ---------------------------- GLX_VERSION_1_3 ---------------------------- */ + +#ifndef GLX_VERSION_1_3 +#define GLX_VERSION_1_3 1 + +#define GLX_RGBA_BIT 0x00000001 +#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001 +#define GLX_WINDOW_BIT 0x00000001 +#define GLX_COLOR_INDEX_BIT 0x00000002 +#define GLX_PIXMAP_BIT 0x00000002 +#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002 +#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004 +#define GLX_PBUFFER_BIT 0x00000004 +#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008 +#define GLX_AUX_BUFFERS_BIT 0x00000010 +#define GLX_CONFIG_CAVEAT 0x20 +#define GLX_DEPTH_BUFFER_BIT 0x00000020 +#define GLX_X_VISUAL_TYPE 0x22 +#define GLX_TRANSPARENT_TYPE 0x23 +#define GLX_TRANSPARENT_INDEX_VALUE 0x24 +#define GLX_TRANSPARENT_RED_VALUE 0x25 +#define GLX_TRANSPARENT_GREEN_VALUE 0x26 +#define GLX_TRANSPARENT_BLUE_VALUE 0x27 +#define GLX_TRANSPARENT_ALPHA_VALUE 0x28 +#define GLX_STENCIL_BUFFER_BIT 0x00000040 +#define GLX_ACCUM_BUFFER_BIT 0x00000080 +#define GLX_NONE 0x8000 +#define GLX_SLOW_CONFIG 0x8001 +#define GLX_TRUE_COLOR 0x8002 +#define GLX_DIRECT_COLOR 0x8003 +#define GLX_PSEUDO_COLOR 0x8004 +#define GLX_STATIC_COLOR 0x8005 +#define GLX_GRAY_SCALE 0x8006 +#define GLX_STATIC_GRAY 0x8007 +#define GLX_TRANSPARENT_RGB 0x8008 +#define GLX_TRANSPARENT_INDEX 0x8009 +#define GLX_VISUAL_ID 0x800B +#define GLX_SCREEN 0x800C +#define GLX_NON_CONFORMANT_CONFIG 0x800D +#define GLX_DRAWABLE_TYPE 0x8010 +#define GLX_RENDER_TYPE 0x8011 +#define GLX_X_RENDERABLE 0x8012 +#define GLX_FBCONFIG_ID 0x8013 +#define GLX_RGBA_TYPE 0x8014 +#define GLX_COLOR_INDEX_TYPE 0x8015 +#define GLX_MAX_PBUFFER_WIDTH 0x8016 +#define GLX_MAX_PBUFFER_HEIGHT 0x8017 +#define GLX_MAX_PBUFFER_PIXELS 0x8018 +#define GLX_PRESERVED_CONTENTS 0x801B +#define GLX_LARGEST_PBUFFER 0x801C +#define GLX_WIDTH 0x801D +#define GLX_HEIGHT 0x801E +#define GLX_EVENT_MASK 0x801F +#define GLX_DAMAGED 0x8020 +#define GLX_SAVED 0x8021 +#define GLX_WINDOW 0x8022 +#define GLX_PBUFFER 0x8023 +#define GLX_PBUFFER_HEIGHT 0x8040 +#define GLX_PBUFFER_WIDTH 0x8041 +#define GLX_PBUFFER_CLOBBER_MASK 0x08000000 +#define GLX_DONT_CARE 0xFFFFFFFF + +typedef XID GLXFBConfigID; +typedef XID GLXPbuffer; +typedef XID GLXWindow; +typedef struct __GLXFBConfigRec *GLXFBConfig; + +typedef struct { + int event_type; + int draw_type; + unsigned long serial; + Bool send_event; + Display *display; + GLXDrawable drawable; + unsigned int buffer_mask; + unsigned int aux_buffer; + int x, y; + int width, height; + int count; +} GLXPbufferClobberEvent; +typedef union __GLXEvent { + GLXPbufferClobberEvent glxpbufferclobber; + long pad[24]; +} GLXEvent; + +typedef GLXFBConfig* ( * PFNGLXCHOOSEFBCONFIGPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements); +typedef GLXContext ( * PFNGLXCREATENEWCONTEXTPROC) (Display *dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); +typedef GLXPbuffer ( * PFNGLXCREATEPBUFFERPROC) (Display *dpy, GLXFBConfig config, const int *attrib_list); +typedef GLXPixmap ( * PFNGLXCREATEPIXMAPPROC) (Display *dpy, GLXFBConfig config, Pixmap pixmap, const int *attrib_list); +typedef GLXWindow ( * PFNGLXCREATEWINDOWPROC) (Display *dpy, GLXFBConfig config, Window win, const int *attrib_list); +typedef void ( * PFNGLXDESTROYPBUFFERPROC) (Display *dpy, GLXPbuffer pbuf); +typedef void ( * PFNGLXDESTROYPIXMAPPROC) (Display *dpy, GLXPixmap pixmap); +typedef void ( * PFNGLXDESTROYWINDOWPROC) (Display *dpy, GLXWindow win); +typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLEPROC) (void); +typedef int ( * PFNGLXGETFBCONFIGATTRIBPROC) (Display *dpy, GLXFBConfig config, int attribute, int *value); +typedef GLXFBConfig* ( * PFNGLXGETFBCONFIGSPROC) (Display *dpy, int screen, int *nelements); +typedef void ( * PFNGLXGETSELECTEDEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long *event_mask); +typedef XVisualInfo* ( * PFNGLXGETVISUALFROMFBCONFIGPROC) (Display *dpy, GLXFBConfig config); +typedef Bool ( * PFNGLXMAKECONTEXTCURRENTPROC) (Display *display, GLXDrawable draw, GLXDrawable read, GLXContext ctx); +typedef int ( * PFNGLXQUERYCONTEXTPROC) (Display *dpy, GLXContext ctx, int attribute, int *value); +typedef void ( * PFNGLXQUERYDRAWABLEPROC) (Display *dpy, GLXDrawable draw, int attribute, unsigned int *value); +typedef void ( * PFNGLXSELECTEVENTPROC) (Display *dpy, GLXDrawable draw, unsigned long event_mask); + +#define glXChooseFBConfig GLXEW_GET_FUN(__glewXChooseFBConfig) +#define glXCreateNewContext GLXEW_GET_FUN(__glewXCreateNewContext) +#define glXCreatePbuffer GLXEW_GET_FUN(__glewXCreatePbuffer) +#define glXCreatePixmap GLXEW_GET_FUN(__glewXCreatePixmap) +#define glXCreateWindow GLXEW_GET_FUN(__glewXCreateWindow) +#define glXDestroyPbuffer GLXEW_GET_FUN(__glewXDestroyPbuffer) +#define glXDestroyPixmap GLXEW_GET_FUN(__glewXDestroyPixmap) +#define glXDestroyWindow GLXEW_GET_FUN(__glewXDestroyWindow) +#define glXGetCurrentReadDrawable GLXEW_GET_FUN(__glewXGetCurrentReadDrawable) +#define glXGetFBConfigAttrib GLXEW_GET_FUN(__glewXGetFBConfigAttrib) +#define glXGetFBConfigs GLXEW_GET_FUN(__glewXGetFBConfigs) +#define glXGetSelectedEvent GLXEW_GET_FUN(__glewXGetSelectedEvent) +#define glXGetVisualFromFBConfig GLXEW_GET_FUN(__glewXGetVisualFromFBConfig) +#define glXMakeContextCurrent GLXEW_GET_FUN(__glewXMakeContextCurrent) +#define glXQueryContext GLXEW_GET_FUN(__glewXQueryContext) +#define glXQueryDrawable GLXEW_GET_FUN(__glewXQueryDrawable) +#define glXSelectEvent GLXEW_GET_FUN(__glewXSelectEvent) + +#define GLXEW_VERSION_1_3 GLXEW_GET_VAR(__GLXEW_VERSION_1_3) + +#endif /* GLX_VERSION_1_3 */ + +/* ---------------------------- GLX_VERSION_1_4 ---------------------------- */ + +#ifndef GLX_VERSION_1_4 +#define GLX_VERSION_1_4 1 + +#define GLX_SAMPLE_BUFFERS 100000 +#define GLX_SAMPLES 100001 + +extern void ( * glXGetProcAddress (const GLubyte *procName)) (void); + +#define GLXEW_VERSION_1_4 GLXEW_GET_VAR(__GLXEW_VERSION_1_4) + +#endif /* GLX_VERSION_1_4 */ + +/* -------------------------- GLX_3DFX_multisample ------------------------- */ + +#ifndef GLX_3DFX_multisample +#define GLX_3DFX_multisample 1 + +#define GLX_SAMPLE_BUFFERS_3DFX 0x8050 +#define GLX_SAMPLES_3DFX 0x8051 + +#define GLXEW_3DFX_multisample GLXEW_GET_VAR(__GLXEW_3DFX_multisample) + +#endif /* GLX_3DFX_multisample */ + +/* ------------------------ GLX_AMD_gpu_association ------------------------ */ + +#ifndef GLX_AMD_gpu_association +#define GLX_AMD_gpu_association 1 + +#define GLX_GPU_VENDOR_AMD 0x1F00 +#define GLX_GPU_RENDERER_STRING_AMD 0x1F01 +#define GLX_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 +#define GLX_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 +#define GLX_GPU_RAM_AMD 0x21A3 +#define GLX_GPU_CLOCK_AMD 0x21A4 +#define GLX_GPU_NUM_PIPES_AMD 0x21A5 +#define GLX_GPU_NUM_SIMD_AMD 0x21A6 +#define GLX_GPU_NUM_RB_AMD 0x21A7 +#define GLX_GPU_NUM_SPI_AMD 0x21A8 + +#define GLXEW_AMD_gpu_association GLXEW_GET_VAR(__GLXEW_AMD_gpu_association) + +#endif /* GLX_AMD_gpu_association */ + +/* ------------------------- GLX_ARB_create_context ------------------------ */ + +#ifndef GLX_ARB_create_context +#define GLX_ARB_create_context 1 + +#define GLX_CONTEXT_DEBUG_BIT_ARB 0x0001 +#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 +#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define GLX_CONTEXT_FLAGS_ARB 0x2094 + +typedef GLXContext ( * PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display* dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list); + +#define glXCreateContextAttribsARB GLXEW_GET_FUN(__glewXCreateContextAttribsARB) + +#define GLXEW_ARB_create_context GLXEW_GET_VAR(__GLXEW_ARB_create_context) + +#endif /* GLX_ARB_create_context */ + +/* --------------------- GLX_ARB_create_context_profile -------------------- */ + +#ifndef GLX_ARB_create_context_profile +#define GLX_ARB_create_context_profile 1 + +#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 +#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126 + +#define GLXEW_ARB_create_context_profile GLXEW_GET_VAR(__GLXEW_ARB_create_context_profile) + +#endif /* GLX_ARB_create_context_profile */ + +/* ------------------- GLX_ARB_create_context_robustness ------------------- */ + +#ifndef GLX_ARB_create_context_robustness +#define GLX_ARB_create_context_robustness 1 + +#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define GLX_NO_RESET_NOTIFICATION_ARB 0x8261 + +#define GLXEW_ARB_create_context_robustness GLXEW_GET_VAR(__GLXEW_ARB_create_context_robustness) + +#endif /* GLX_ARB_create_context_robustness */ + +/* ------------------------- GLX_ARB_fbconfig_float ------------------------ */ + +#ifndef GLX_ARB_fbconfig_float +#define GLX_ARB_fbconfig_float 1 + +#define GLX_RGBA_FLOAT_BIT 0x00000004 +#define GLX_RGBA_FLOAT_TYPE 0x20B9 + +#define GLXEW_ARB_fbconfig_float GLXEW_GET_VAR(__GLXEW_ARB_fbconfig_float) + +#endif /* GLX_ARB_fbconfig_float */ + +/* ------------------------ GLX_ARB_framebuffer_sRGB ----------------------- */ + +#ifndef GLX_ARB_framebuffer_sRGB +#define GLX_ARB_framebuffer_sRGB 1 + +#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20B2 + +#define GLXEW_ARB_framebuffer_sRGB GLXEW_GET_VAR(__GLXEW_ARB_framebuffer_sRGB) + +#endif /* GLX_ARB_framebuffer_sRGB */ + +/* ------------------------ GLX_ARB_get_proc_address ----------------------- */ + +#ifndef GLX_ARB_get_proc_address +#define GLX_ARB_get_proc_address 1 + +extern void ( * glXGetProcAddressARB (const GLubyte *procName)) (void); + +#define GLXEW_ARB_get_proc_address GLXEW_GET_VAR(__GLXEW_ARB_get_proc_address) + +#endif /* GLX_ARB_get_proc_address */ + +/* -------------------------- GLX_ARB_multisample -------------------------- */ + +#ifndef GLX_ARB_multisample +#define GLX_ARB_multisample 1 + +#define GLX_SAMPLE_BUFFERS_ARB 100000 +#define GLX_SAMPLES_ARB 100001 + +#define GLXEW_ARB_multisample GLXEW_GET_VAR(__GLXEW_ARB_multisample) + +#endif /* GLX_ARB_multisample */ + +/* ---------------------- GLX_ARB_vertex_buffer_object --------------------- */ + +#ifndef GLX_ARB_vertex_buffer_object +#define GLX_ARB_vertex_buffer_object 1 + +#define GLX_CONTEXT_ALLOW_BUFFER_BYTE_ORDER_MISMATCH_ARB 0x2095 + +#define GLXEW_ARB_vertex_buffer_object GLXEW_GET_VAR(__GLXEW_ARB_vertex_buffer_object) + +#endif /* GLX_ARB_vertex_buffer_object */ + +/* ----------------------- GLX_ATI_pixel_format_float ---------------------- */ + +#ifndef GLX_ATI_pixel_format_float +#define GLX_ATI_pixel_format_float 1 + +#define GLX_RGBA_FLOAT_ATI_BIT 0x00000100 + +#define GLXEW_ATI_pixel_format_float GLXEW_GET_VAR(__GLXEW_ATI_pixel_format_float) + +#endif /* GLX_ATI_pixel_format_float */ + +/* ------------------------- GLX_ATI_render_texture ------------------------ */ + +#ifndef GLX_ATI_render_texture +#define GLX_ATI_render_texture 1 + +#define GLX_BIND_TO_TEXTURE_RGB_ATI 0x9800 +#define GLX_BIND_TO_TEXTURE_RGBA_ATI 0x9801 +#define GLX_TEXTURE_FORMAT_ATI 0x9802 +#define GLX_TEXTURE_TARGET_ATI 0x9803 +#define GLX_MIPMAP_TEXTURE_ATI 0x9804 +#define GLX_TEXTURE_RGB_ATI 0x9805 +#define GLX_TEXTURE_RGBA_ATI 0x9806 +#define GLX_NO_TEXTURE_ATI 0x9807 +#define GLX_TEXTURE_CUBE_MAP_ATI 0x9808 +#define GLX_TEXTURE_1D_ATI 0x9809 +#define GLX_TEXTURE_2D_ATI 0x980A +#define GLX_MIPMAP_LEVEL_ATI 0x980B +#define GLX_CUBE_MAP_FACE_ATI 0x980C +#define GLX_TEXTURE_CUBE_MAP_POSITIVE_X_ATI 0x980D +#define GLX_TEXTURE_CUBE_MAP_NEGATIVE_X_ATI 0x980E +#define GLX_TEXTURE_CUBE_MAP_POSITIVE_Y_ATI 0x980F +#define GLX_TEXTURE_CUBE_MAP_NEGATIVE_Y_ATI 0x9810 +#define GLX_TEXTURE_CUBE_MAP_POSITIVE_Z_ATI 0x9811 +#define GLX_TEXTURE_CUBE_MAP_NEGATIVE_Z_ATI 0x9812 +#define GLX_FRONT_LEFT_ATI 0x9813 +#define GLX_FRONT_RIGHT_ATI 0x9814 +#define GLX_BACK_LEFT_ATI 0x9815 +#define GLX_BACK_RIGHT_ATI 0x9816 +#define GLX_AUX0_ATI 0x9817 +#define GLX_AUX1_ATI 0x9818 +#define GLX_AUX2_ATI 0x9819 +#define GLX_AUX3_ATI 0x981A +#define GLX_AUX4_ATI 0x981B +#define GLX_AUX5_ATI 0x981C +#define GLX_AUX6_ATI 0x981D +#define GLX_AUX7_ATI 0x981E +#define GLX_AUX8_ATI 0x981F +#define GLX_AUX9_ATI 0x9820 +#define GLX_BIND_TO_TEXTURE_LUMINANCE_ATI 0x9821 +#define GLX_BIND_TO_TEXTURE_INTENSITY_ATI 0x9822 + +typedef void ( * PFNGLXBINDTEXIMAGEATIPROC) (Display *dpy, GLXPbuffer pbuf, int buffer); +typedef void ( * PFNGLXDRAWABLEATTRIBATIPROC) (Display *dpy, GLXDrawable draw, const int *attrib_list); +typedef void ( * PFNGLXRELEASETEXIMAGEATIPROC) (Display *dpy, GLXPbuffer pbuf, int buffer); + +#define glXBindTexImageATI GLXEW_GET_FUN(__glewXBindTexImageATI) +#define glXDrawableAttribATI GLXEW_GET_FUN(__glewXDrawableAttribATI) +#define glXReleaseTexImageATI GLXEW_GET_FUN(__glewXReleaseTexImageATI) + +#define GLXEW_ATI_render_texture GLXEW_GET_VAR(__GLXEW_ATI_render_texture) + +#endif /* GLX_ATI_render_texture */ + +/* ------------------- GLX_EXT_create_context_es2_profile ------------------ */ + +#ifndef GLX_EXT_create_context_es2_profile +#define GLX_EXT_create_context_es2_profile 1 + +#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 + +#define GLXEW_EXT_create_context_es2_profile GLXEW_GET_VAR(__GLXEW_EXT_create_context_es2_profile) + +#endif /* GLX_EXT_create_context_es2_profile */ + +/* --------------------- GLX_EXT_fbconfig_packed_float --------------------- */ + +#ifndef GLX_EXT_fbconfig_packed_float +#define GLX_EXT_fbconfig_packed_float 1 + +#define GLX_RGBA_UNSIGNED_FLOAT_BIT_EXT 0x00000008 +#define GLX_RGBA_UNSIGNED_FLOAT_TYPE_EXT 0x20B1 + +#define GLXEW_EXT_fbconfig_packed_float GLXEW_GET_VAR(__GLXEW_EXT_fbconfig_packed_float) + +#endif /* GLX_EXT_fbconfig_packed_float */ + +/* ------------------------ GLX_EXT_framebuffer_sRGB ----------------------- */ + +#ifndef GLX_EXT_framebuffer_sRGB +#define GLX_EXT_framebuffer_sRGB 1 + +#define GLX_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20B2 + +#define GLXEW_EXT_framebuffer_sRGB GLXEW_GET_VAR(__GLXEW_EXT_framebuffer_sRGB) + +#endif /* GLX_EXT_framebuffer_sRGB */ + +/* ------------------------- GLX_EXT_import_context ------------------------ */ + +#ifndef GLX_EXT_import_context +#define GLX_EXT_import_context 1 + +#define GLX_SHARE_CONTEXT_EXT 0x800A +#define GLX_VISUAL_ID_EXT 0x800B +#define GLX_SCREEN_EXT 0x800C + +typedef XID GLXContextID; + +typedef void ( * PFNGLXFREECONTEXTEXTPROC) (Display* dpy, GLXContext context); +typedef GLXContextID ( * PFNGLXGETCONTEXTIDEXTPROC) (const GLXContext context); +typedef GLXContext ( * PFNGLXIMPORTCONTEXTEXTPROC) (Display* dpy, GLXContextID contextID); +typedef int ( * PFNGLXQUERYCONTEXTINFOEXTPROC) (Display* dpy, GLXContext context, int attribute,int *value); + +#define glXFreeContextEXT GLXEW_GET_FUN(__glewXFreeContextEXT) +#define glXGetContextIDEXT GLXEW_GET_FUN(__glewXGetContextIDEXT) +#define glXImportContextEXT GLXEW_GET_FUN(__glewXImportContextEXT) +#define glXQueryContextInfoEXT GLXEW_GET_FUN(__glewXQueryContextInfoEXT) + +#define GLXEW_EXT_import_context GLXEW_GET_VAR(__GLXEW_EXT_import_context) + +#endif /* GLX_EXT_import_context */ + +/* -------------------------- GLX_EXT_scene_marker ------------------------- */ + +#ifndef GLX_EXT_scene_marker +#define GLX_EXT_scene_marker 1 + +#define GLXEW_EXT_scene_marker GLXEW_GET_VAR(__GLXEW_EXT_scene_marker) + +#endif /* GLX_EXT_scene_marker */ + +/* -------------------------- GLX_EXT_swap_control ------------------------- */ + +#ifndef GLX_EXT_swap_control +#define GLX_EXT_swap_control 1 + +#define GLX_SWAP_INTERVAL_EXT 0x20F1 +#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2 + +typedef void ( * PFNGLXSWAPINTERVALEXTPROC) (Display* dpy, GLXDrawable drawable, int interval); + +#define glXSwapIntervalEXT GLXEW_GET_FUN(__glewXSwapIntervalEXT) + +#define GLXEW_EXT_swap_control GLXEW_GET_VAR(__GLXEW_EXT_swap_control) + +#endif /* GLX_EXT_swap_control */ + +/* ---------------------- GLX_EXT_texture_from_pixmap ---------------------- */ + +#ifndef GLX_EXT_texture_from_pixmap +#define GLX_EXT_texture_from_pixmap 1 + +#define GLX_TEXTURE_1D_BIT_EXT 0x00000001 +#define GLX_TEXTURE_2D_BIT_EXT 0x00000002 +#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004 +#define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0 +#define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1 +#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2 +#define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3 +#define GLX_Y_INVERTED_EXT 0x20D4 +#define GLX_TEXTURE_FORMAT_EXT 0x20D5 +#define GLX_TEXTURE_TARGET_EXT 0x20D6 +#define GLX_MIPMAP_TEXTURE_EXT 0x20D7 +#define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8 +#define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9 +#define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA +#define GLX_TEXTURE_1D_EXT 0x20DB +#define GLX_TEXTURE_2D_EXT 0x20DC +#define GLX_TEXTURE_RECTANGLE_EXT 0x20DD +#define GLX_FRONT_LEFT_EXT 0x20DE +#define GLX_FRONT_RIGHT_EXT 0x20DF +#define GLX_BACK_LEFT_EXT 0x20E0 +#define GLX_BACK_RIGHT_EXT 0x20E1 +#define GLX_AUX0_EXT 0x20E2 +#define GLX_AUX1_EXT 0x20E3 +#define GLX_AUX2_EXT 0x20E4 +#define GLX_AUX3_EXT 0x20E5 +#define GLX_AUX4_EXT 0x20E6 +#define GLX_AUX5_EXT 0x20E7 +#define GLX_AUX6_EXT 0x20E8 +#define GLX_AUX7_EXT 0x20E9 +#define GLX_AUX8_EXT 0x20EA +#define GLX_AUX9_EXT 0x20EB + +typedef void ( * PFNGLXBINDTEXIMAGEEXTPROC) (Display* display, GLXDrawable drawable, int buffer, const int *attrib_list); +typedef void ( * PFNGLXRELEASETEXIMAGEEXTPROC) (Display* display, GLXDrawable drawable, int buffer); + +#define glXBindTexImageEXT GLXEW_GET_FUN(__glewXBindTexImageEXT) +#define glXReleaseTexImageEXT GLXEW_GET_FUN(__glewXReleaseTexImageEXT) + +#define GLXEW_EXT_texture_from_pixmap GLXEW_GET_VAR(__GLXEW_EXT_texture_from_pixmap) + +#endif /* GLX_EXT_texture_from_pixmap */ + +/* -------------------------- GLX_EXT_visual_info -------------------------- */ + +#ifndef GLX_EXT_visual_info +#define GLX_EXT_visual_info 1 + +#define GLX_X_VISUAL_TYPE_EXT 0x22 +#define GLX_TRANSPARENT_TYPE_EXT 0x23 +#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24 +#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25 +#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26 +#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27 +#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28 +#define GLX_NONE_EXT 0x8000 +#define GLX_TRUE_COLOR_EXT 0x8002 +#define GLX_DIRECT_COLOR_EXT 0x8003 +#define GLX_PSEUDO_COLOR_EXT 0x8004 +#define GLX_STATIC_COLOR_EXT 0x8005 +#define GLX_GRAY_SCALE_EXT 0x8006 +#define GLX_STATIC_GRAY_EXT 0x8007 +#define GLX_TRANSPARENT_RGB_EXT 0x8008 +#define GLX_TRANSPARENT_INDEX_EXT 0x8009 + +#define GLXEW_EXT_visual_info GLXEW_GET_VAR(__GLXEW_EXT_visual_info) + +#endif /* GLX_EXT_visual_info */ + +/* ------------------------- GLX_EXT_visual_rating ------------------------- */ + +#ifndef GLX_EXT_visual_rating +#define GLX_EXT_visual_rating 1 + +#define GLX_VISUAL_CAVEAT_EXT 0x20 +#define GLX_SLOW_VISUAL_EXT 0x8001 +#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D + +#define GLXEW_EXT_visual_rating GLXEW_GET_VAR(__GLXEW_EXT_visual_rating) + +#endif /* GLX_EXT_visual_rating */ + +/* -------------------------- GLX_INTEL_swap_event ------------------------- */ + +#ifndef GLX_INTEL_swap_event +#define GLX_INTEL_swap_event 1 + +#define GLX_EXCHANGE_COMPLETE_INTEL 0x8180 +#define GLX_COPY_COMPLETE_INTEL 0x8181 +#define GLX_FLIP_COMPLETE_INTEL 0x8182 +#define GLX_BUFFER_SWAP_COMPLETE_INTEL_MASK 0x04000000 + +#define GLXEW_INTEL_swap_event GLXEW_GET_VAR(__GLXEW_INTEL_swap_event) + +#endif /* GLX_INTEL_swap_event */ + +/* -------------------------- GLX_MESA_agp_offset -------------------------- */ + +#ifndef GLX_MESA_agp_offset +#define GLX_MESA_agp_offset 1 + +typedef unsigned int ( * PFNGLXGETAGPOFFSETMESAPROC) (const void* pointer); + +#define glXGetAGPOffsetMESA GLXEW_GET_FUN(__glewXGetAGPOffsetMESA) + +#define GLXEW_MESA_agp_offset GLXEW_GET_VAR(__GLXEW_MESA_agp_offset) + +#endif /* GLX_MESA_agp_offset */ + +/* ------------------------ GLX_MESA_copy_sub_buffer ----------------------- */ + +#ifndef GLX_MESA_copy_sub_buffer +#define GLX_MESA_copy_sub_buffer 1 + +typedef void ( * PFNGLXCOPYSUBBUFFERMESAPROC) (Display* dpy, GLXDrawable drawable, int x, int y, int width, int height); + +#define glXCopySubBufferMESA GLXEW_GET_FUN(__glewXCopySubBufferMESA) + +#define GLXEW_MESA_copy_sub_buffer GLXEW_GET_VAR(__GLXEW_MESA_copy_sub_buffer) + +#endif /* GLX_MESA_copy_sub_buffer */ + +/* ------------------------ GLX_MESA_pixmap_colormap ----------------------- */ + +#ifndef GLX_MESA_pixmap_colormap +#define GLX_MESA_pixmap_colormap 1 + +typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPMESAPROC) (Display* dpy, XVisualInfo *visual, Pixmap pixmap, Colormap cmap); + +#define glXCreateGLXPixmapMESA GLXEW_GET_FUN(__glewXCreateGLXPixmapMESA) + +#define GLXEW_MESA_pixmap_colormap GLXEW_GET_VAR(__GLXEW_MESA_pixmap_colormap) + +#endif /* GLX_MESA_pixmap_colormap */ + +/* ------------------------ GLX_MESA_release_buffers ----------------------- */ + +#ifndef GLX_MESA_release_buffers +#define GLX_MESA_release_buffers 1 + +typedef Bool ( * PFNGLXRELEASEBUFFERSMESAPROC) (Display* dpy, GLXDrawable d); + +#define glXReleaseBuffersMESA GLXEW_GET_FUN(__glewXReleaseBuffersMESA) + +#define GLXEW_MESA_release_buffers GLXEW_GET_VAR(__GLXEW_MESA_release_buffers) + +#endif /* GLX_MESA_release_buffers */ + +/* ------------------------- GLX_MESA_set_3dfx_mode ------------------------ */ + +#ifndef GLX_MESA_set_3dfx_mode +#define GLX_MESA_set_3dfx_mode 1 + +#define GLX_3DFX_WINDOW_MODE_MESA 0x1 +#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2 + +typedef GLboolean ( * PFNGLXSET3DFXMODEMESAPROC) (GLint mode); + +#define glXSet3DfxModeMESA GLXEW_GET_FUN(__glewXSet3DfxModeMESA) + +#define GLXEW_MESA_set_3dfx_mode GLXEW_GET_VAR(__GLXEW_MESA_set_3dfx_mode) + +#endif /* GLX_MESA_set_3dfx_mode */ + +/* ------------------------- GLX_MESA_swap_control ------------------------- */ + +#ifndef GLX_MESA_swap_control +#define GLX_MESA_swap_control 1 + +typedef int ( * PFNGLXGETSWAPINTERVALMESAPROC) (void); +typedef int ( * PFNGLXSWAPINTERVALMESAPROC) (unsigned int interval); + +#define glXGetSwapIntervalMESA GLXEW_GET_FUN(__glewXGetSwapIntervalMESA) +#define glXSwapIntervalMESA GLXEW_GET_FUN(__glewXSwapIntervalMESA) + +#define GLXEW_MESA_swap_control GLXEW_GET_VAR(__GLXEW_MESA_swap_control) + +#endif /* GLX_MESA_swap_control */ + +/* --------------------------- GLX_NV_copy_image --------------------------- */ + +#ifndef GLX_NV_copy_image +#define GLX_NV_copy_image 1 + +typedef void ( * PFNGLXCOPYIMAGESUBDATANVPROC) (Display *dpy, GLXContext srcCtx, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, GLXContext dstCtx, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); + +#define glXCopyImageSubDataNV GLXEW_GET_FUN(__glewXCopyImageSubDataNV) + +#define GLXEW_NV_copy_image GLXEW_GET_VAR(__GLXEW_NV_copy_image) + +#endif /* GLX_NV_copy_image */ + +/* -------------------------- GLX_NV_float_buffer -------------------------- */ + +#ifndef GLX_NV_float_buffer +#define GLX_NV_float_buffer 1 + +#define GLX_FLOAT_COMPONENTS_NV 0x20B0 + +#define GLXEW_NV_float_buffer GLXEW_GET_VAR(__GLXEW_NV_float_buffer) + +#endif /* GLX_NV_float_buffer */ + +/* ---------------------- GLX_NV_multisample_coverage ---------------------- */ + +#ifndef GLX_NV_multisample_coverage +#define GLX_NV_multisample_coverage 1 + +#define GLX_COLOR_SAMPLES_NV 0x20B3 +#define GLX_COVERAGE_SAMPLES_NV 100001 + +#define GLXEW_NV_multisample_coverage GLXEW_GET_VAR(__GLXEW_NV_multisample_coverage) + +#endif /* GLX_NV_multisample_coverage */ + +/* -------------------------- GLX_NV_present_video ------------------------- */ + +#ifndef GLX_NV_present_video +#define GLX_NV_present_video 1 + +#define GLX_NUM_VIDEO_SLOTS_NV 0x20F0 + +typedef int ( * PFNGLXBINDVIDEODEVICENVPROC) (Display* dpy, unsigned int video_slot, unsigned int video_device, const int *attrib_list); +typedef unsigned int* ( * PFNGLXENUMERATEVIDEODEVICESNVPROC) (Display *dpy, int screen, int *nelements); + +#define glXBindVideoDeviceNV GLXEW_GET_FUN(__glewXBindVideoDeviceNV) +#define glXEnumerateVideoDevicesNV GLXEW_GET_FUN(__glewXEnumerateVideoDevicesNV) + +#define GLXEW_NV_present_video GLXEW_GET_VAR(__GLXEW_NV_present_video) + +#endif /* GLX_NV_present_video */ + +/* --------------------------- GLX_NV_swap_group --------------------------- */ + +#ifndef GLX_NV_swap_group +#define GLX_NV_swap_group 1 + +typedef Bool ( * PFNGLXBINDSWAPBARRIERNVPROC) (Display* dpy, GLuint group, GLuint barrier); +typedef Bool ( * PFNGLXJOINSWAPGROUPNVPROC) (Display* dpy, GLXDrawable drawable, GLuint group); +typedef Bool ( * PFNGLXQUERYFRAMECOUNTNVPROC) (Display* dpy, int screen, GLuint *count); +typedef Bool ( * PFNGLXQUERYMAXSWAPGROUPSNVPROC) (Display* dpy, int screen, GLuint *maxGroups, GLuint *maxBarriers); +typedef Bool ( * PFNGLXQUERYSWAPGROUPNVPROC) (Display* dpy, GLXDrawable drawable, GLuint *group, GLuint *barrier); +typedef Bool ( * PFNGLXRESETFRAMECOUNTNVPROC) (Display* dpy, int screen); + +#define glXBindSwapBarrierNV GLXEW_GET_FUN(__glewXBindSwapBarrierNV) +#define glXJoinSwapGroupNV GLXEW_GET_FUN(__glewXJoinSwapGroupNV) +#define glXQueryFrameCountNV GLXEW_GET_FUN(__glewXQueryFrameCountNV) +#define glXQueryMaxSwapGroupsNV GLXEW_GET_FUN(__glewXQueryMaxSwapGroupsNV) +#define glXQuerySwapGroupNV GLXEW_GET_FUN(__glewXQuerySwapGroupNV) +#define glXResetFrameCountNV GLXEW_GET_FUN(__glewXResetFrameCountNV) + +#define GLXEW_NV_swap_group GLXEW_GET_VAR(__GLXEW_NV_swap_group) + +#endif /* GLX_NV_swap_group */ + +/* ----------------------- GLX_NV_vertex_array_range ----------------------- */ + +#ifndef GLX_NV_vertex_array_range +#define GLX_NV_vertex_array_range 1 + +typedef void * ( * PFNGLXALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readFrequency, GLfloat writeFrequency, GLfloat priority); +typedef void ( * PFNGLXFREEMEMORYNVPROC) (void *pointer); + +#define glXAllocateMemoryNV GLXEW_GET_FUN(__glewXAllocateMemoryNV) +#define glXFreeMemoryNV GLXEW_GET_FUN(__glewXFreeMemoryNV) + +#define GLXEW_NV_vertex_array_range GLXEW_GET_VAR(__GLXEW_NV_vertex_array_range) + +#endif /* GLX_NV_vertex_array_range */ + +/* -------------------------- GLX_NV_video_capture ------------------------- */ + +#ifndef GLX_NV_video_capture +#define GLX_NV_video_capture 1 + +#define GLX_DEVICE_ID_NV 0x20CD +#define GLX_UNIQUE_ID_NV 0x20CE +#define GLX_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF + +typedef XID GLXVideoCaptureDeviceNV; + +typedef int ( * PFNGLXBINDVIDEOCAPTUREDEVICENVPROC) (Display* dpy, unsigned int video_capture_slot, GLXVideoCaptureDeviceNV device); +typedef GLXVideoCaptureDeviceNV * ( * PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC) (Display* dpy, int screen, int *nelements); +typedef void ( * PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC) (Display* dpy, GLXVideoCaptureDeviceNV device); +typedef int ( * PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC) (Display* dpy, GLXVideoCaptureDeviceNV device, int attribute, int *value); +typedef void ( * PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC) (Display* dpy, GLXVideoCaptureDeviceNV device); + +#define glXBindVideoCaptureDeviceNV GLXEW_GET_FUN(__glewXBindVideoCaptureDeviceNV) +#define glXEnumerateVideoCaptureDevicesNV GLXEW_GET_FUN(__glewXEnumerateVideoCaptureDevicesNV) +#define glXLockVideoCaptureDeviceNV GLXEW_GET_FUN(__glewXLockVideoCaptureDeviceNV) +#define glXQueryVideoCaptureDeviceNV GLXEW_GET_FUN(__glewXQueryVideoCaptureDeviceNV) +#define glXReleaseVideoCaptureDeviceNV GLXEW_GET_FUN(__glewXReleaseVideoCaptureDeviceNV) + +#define GLXEW_NV_video_capture GLXEW_GET_VAR(__GLXEW_NV_video_capture) + +#endif /* GLX_NV_video_capture */ + +/* -------------------------- GLX_NV_video_output -------------------------- */ + +#ifndef GLX_NV_video_output +#define GLX_NV_video_output 1 + +#define GLX_VIDEO_OUT_COLOR_NV 0x20C3 +#define GLX_VIDEO_OUT_ALPHA_NV 0x20C4 +#define GLX_VIDEO_OUT_DEPTH_NV 0x20C5 +#define GLX_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 +#define GLX_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 +#define GLX_VIDEO_OUT_FRAME_NV 0x20C8 +#define GLX_VIDEO_OUT_FIELD_1_NV 0x20C9 +#define GLX_VIDEO_OUT_FIELD_2_NV 0x20CA +#define GLX_VIDEO_OUT_STACKED_FIELDS_1_2_NV 0x20CB +#define GLX_VIDEO_OUT_STACKED_FIELDS_2_1_NV 0x20CC + +typedef int ( * PFNGLXBINDVIDEOIMAGENVPROC) (Display* dpy, GLXVideoDeviceNV VideoDevice, GLXPbuffer pbuf, int iVideoBuffer); +typedef int ( * PFNGLXGETVIDEODEVICENVPROC) (Display* dpy, int screen, int numVideoDevices, GLXVideoDeviceNV *pVideoDevice); +typedef int ( * PFNGLXGETVIDEOINFONVPROC) (Display* dpy, int screen, GLXVideoDeviceNV VideoDevice, unsigned long *pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +typedef int ( * PFNGLXRELEASEVIDEODEVICENVPROC) (Display* dpy, int screen, GLXVideoDeviceNV VideoDevice); +typedef int ( * PFNGLXRELEASEVIDEOIMAGENVPROC) (Display* dpy, GLXPbuffer pbuf); +typedef int ( * PFNGLXSENDPBUFFERTOVIDEONVPROC) (Display* dpy, GLXPbuffer pbuf, int iBufferType, unsigned long *pulCounterPbuffer, GLboolean bBlock); + +#define glXBindVideoImageNV GLXEW_GET_FUN(__glewXBindVideoImageNV) +#define glXGetVideoDeviceNV GLXEW_GET_FUN(__glewXGetVideoDeviceNV) +#define glXGetVideoInfoNV GLXEW_GET_FUN(__glewXGetVideoInfoNV) +#define glXReleaseVideoDeviceNV GLXEW_GET_FUN(__glewXReleaseVideoDeviceNV) +#define glXReleaseVideoImageNV GLXEW_GET_FUN(__glewXReleaseVideoImageNV) +#define glXSendPbufferToVideoNV GLXEW_GET_FUN(__glewXSendPbufferToVideoNV) + +#define GLXEW_NV_video_output GLXEW_GET_VAR(__GLXEW_NV_video_output) + +#endif /* GLX_NV_video_output */ + +/* -------------------------- GLX_OML_swap_method -------------------------- */ + +#ifndef GLX_OML_swap_method +#define GLX_OML_swap_method 1 + +#define GLX_SWAP_METHOD_OML 0x8060 +#define GLX_SWAP_EXCHANGE_OML 0x8061 +#define GLX_SWAP_COPY_OML 0x8062 +#define GLX_SWAP_UNDEFINED_OML 0x8063 + +#define GLXEW_OML_swap_method GLXEW_GET_VAR(__GLXEW_OML_swap_method) + +#endif /* GLX_OML_swap_method */ + +/* -------------------------- GLX_OML_sync_control ------------------------- */ + +#ifndef GLX_OML_sync_control +#define GLX_OML_sync_control 1 + +typedef Bool ( * PFNGLXGETMSCRATEOMLPROC) (Display* dpy, GLXDrawable drawable, int32_t* numerator, int32_t* denominator); +typedef Bool ( * PFNGLXGETSYNCVALUESOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t* ust, int64_t* msc, int64_t* sbc); +typedef int64_t ( * PFNGLXSWAPBUFFERSMSCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder); +typedef Bool ( * PFNGLXWAITFORMSCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_msc, int64_t divisor, int64_t remainder, int64_t* ust, int64_t* msc, int64_t* sbc); +typedef Bool ( * PFNGLXWAITFORSBCOMLPROC) (Display* dpy, GLXDrawable drawable, int64_t target_sbc, int64_t* ust, int64_t* msc, int64_t* sbc); + +#define glXGetMscRateOML GLXEW_GET_FUN(__glewXGetMscRateOML) +#define glXGetSyncValuesOML GLXEW_GET_FUN(__glewXGetSyncValuesOML) +#define glXSwapBuffersMscOML GLXEW_GET_FUN(__glewXSwapBuffersMscOML) +#define glXWaitForMscOML GLXEW_GET_FUN(__glewXWaitForMscOML) +#define glXWaitForSbcOML GLXEW_GET_FUN(__glewXWaitForSbcOML) + +#define GLXEW_OML_sync_control GLXEW_GET_VAR(__GLXEW_OML_sync_control) + +#endif /* GLX_OML_sync_control */ + +/* ------------------------ GLX_SGIS_blended_overlay ----------------------- */ + +#ifndef GLX_SGIS_blended_overlay +#define GLX_SGIS_blended_overlay 1 + +#define GLX_BLENDED_RGBA_SGIS 0x8025 + +#define GLXEW_SGIS_blended_overlay GLXEW_GET_VAR(__GLXEW_SGIS_blended_overlay) + +#endif /* GLX_SGIS_blended_overlay */ + +/* -------------------------- GLX_SGIS_color_range ------------------------- */ + +#ifndef GLX_SGIS_color_range +#define GLX_SGIS_color_range 1 + +#define GLX_MIN_RED_SGIS 0 +#define GLX_MAX_GREEN_SGIS 0 +#define GLX_MIN_BLUE_SGIS 0 +#define GLX_MAX_ALPHA_SGIS 0 +#define GLX_MIN_GREEN_SGIS 0 +#define GLX_MIN_ALPHA_SGIS 0 +#define GLX_MAX_RED_SGIS 0 +#define GLX_EXTENDED_RANGE_SGIS 0 +#define GLX_MAX_BLUE_SGIS 0 + +#define GLXEW_SGIS_color_range GLXEW_GET_VAR(__GLXEW_SGIS_color_range) + +#endif /* GLX_SGIS_color_range */ + +/* -------------------------- GLX_SGIS_multisample ------------------------- */ + +#ifndef GLX_SGIS_multisample +#define GLX_SGIS_multisample 1 + +#define GLX_SAMPLE_BUFFERS_SGIS 100000 +#define GLX_SAMPLES_SGIS 100001 + +#define GLXEW_SGIS_multisample GLXEW_GET_VAR(__GLXEW_SGIS_multisample) + +#endif /* GLX_SGIS_multisample */ + +/* ---------------------- GLX_SGIS_shared_multisample ---------------------- */ + +#ifndef GLX_SGIS_shared_multisample +#define GLX_SGIS_shared_multisample 1 + +#define GLX_MULTISAMPLE_SUB_RECT_WIDTH_SGIS 0x8026 +#define GLX_MULTISAMPLE_SUB_RECT_HEIGHT_SGIS 0x8027 + +#define GLXEW_SGIS_shared_multisample GLXEW_GET_VAR(__GLXEW_SGIS_shared_multisample) + +#endif /* GLX_SGIS_shared_multisample */ + +/* --------------------------- GLX_SGIX_fbconfig --------------------------- */ + +#ifndef GLX_SGIX_fbconfig +#define GLX_SGIX_fbconfig 1 + +#define GLX_WINDOW_BIT_SGIX 0x00000001 +#define GLX_RGBA_BIT_SGIX 0x00000001 +#define GLX_PIXMAP_BIT_SGIX 0x00000002 +#define GLX_COLOR_INDEX_BIT_SGIX 0x00000002 +#define GLX_SCREEN_EXT 0x800C +#define GLX_DRAWABLE_TYPE_SGIX 0x8010 +#define GLX_RENDER_TYPE_SGIX 0x8011 +#define GLX_X_RENDERABLE_SGIX 0x8012 +#define GLX_FBCONFIG_ID_SGIX 0x8013 +#define GLX_RGBA_TYPE_SGIX 0x8014 +#define GLX_COLOR_INDEX_TYPE_SGIX 0x8015 + +typedef XID GLXFBConfigIDSGIX; +typedef struct __GLXFBConfigRec *GLXFBConfigSGIX; + +typedef GLXFBConfigSGIX* ( * PFNGLXCHOOSEFBCONFIGSGIXPROC) (Display *dpy, int screen, const int *attrib_list, int *nelements); +typedef GLXContext ( * PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) (Display* dpy, GLXFBConfig config, int render_type, GLXContext share_list, Bool direct); +typedef GLXPixmap ( * PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC) (Display* dpy, GLXFBConfig config, Pixmap pixmap); +typedef int ( * PFNGLXGETFBCONFIGATTRIBSGIXPROC) (Display* dpy, GLXFBConfigSGIX config, int attribute, int *value); +typedef GLXFBConfigSGIX ( * PFNGLXGETFBCONFIGFROMVISUALSGIXPROC) (Display* dpy, XVisualInfo *vis); +typedef XVisualInfo* ( * PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) (Display *dpy, GLXFBConfig config); + +#define glXChooseFBConfigSGIX GLXEW_GET_FUN(__glewXChooseFBConfigSGIX) +#define glXCreateContextWithConfigSGIX GLXEW_GET_FUN(__glewXCreateContextWithConfigSGIX) +#define glXCreateGLXPixmapWithConfigSGIX GLXEW_GET_FUN(__glewXCreateGLXPixmapWithConfigSGIX) +#define glXGetFBConfigAttribSGIX GLXEW_GET_FUN(__glewXGetFBConfigAttribSGIX) +#define glXGetFBConfigFromVisualSGIX GLXEW_GET_FUN(__glewXGetFBConfigFromVisualSGIX) +#define glXGetVisualFromFBConfigSGIX GLXEW_GET_FUN(__glewXGetVisualFromFBConfigSGIX) + +#define GLXEW_SGIX_fbconfig GLXEW_GET_VAR(__GLXEW_SGIX_fbconfig) + +#endif /* GLX_SGIX_fbconfig */ + +/* --------------------------- GLX_SGIX_hyperpipe -------------------------- */ + +#ifndef GLX_SGIX_hyperpipe +#define GLX_SGIX_hyperpipe 1 + +#define GLX_HYPERPIPE_DISPLAY_PIPE_SGIX 0x00000001 +#define GLX_PIPE_RECT_SGIX 0x00000001 +#define GLX_PIPE_RECT_LIMITS_SGIX 0x00000002 +#define GLX_HYPERPIPE_RENDER_PIPE_SGIX 0x00000002 +#define GLX_HYPERPIPE_STEREO_SGIX 0x00000003 +#define GLX_HYPERPIPE_PIXEL_AVERAGE_SGIX 0x00000004 +#define GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX 80 +#define GLX_BAD_HYPERPIPE_CONFIG_SGIX 91 +#define GLX_BAD_HYPERPIPE_SGIX 92 +#define GLX_HYPERPIPE_ID_SGIX 0x8030 + +typedef struct { + char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; + int networkId; +} GLXHyperpipeNetworkSGIX; +typedef struct { + char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; + int XOrigin; + int YOrigin; + int maxHeight; + int maxWidth; +} GLXPipeRectLimits; +typedef struct { + char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; + int channel; + unsigned int participationType; + int timeSlice; +} GLXHyperpipeConfigSGIX; +typedef struct { + char pipeName[GLX_HYPERPIPE_PIPE_NAME_LENGTH_SGIX]; + int srcXOrigin; + int srcYOrigin; + int srcWidth; + int srcHeight; + int destXOrigin; + int destYOrigin; + int destWidth; + int destHeight; +} GLXPipeRect; + +typedef int ( * PFNGLXBINDHYPERPIPESGIXPROC) (Display *dpy, int hpId); +typedef int ( * PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId); +typedef int ( * PFNGLXHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList); +typedef int ( * PFNGLXHYPERPIPECONFIGSGIXPROC) (Display *dpy, int networkId, int npipes, GLXHyperpipeConfigSGIX *cfg, int *hpId); +typedef int ( * PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *returnAttribList); +typedef int ( * PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC) (Display *dpy, int timeSlice, int attrib, int size, void *attribList, void *returnAttribList); +typedef GLXHyperpipeConfigSGIX * ( * PFNGLXQUERYHYPERPIPECONFIGSGIXPROC) (Display *dpy, int hpId, int *npipes); +typedef GLXHyperpipeNetworkSGIX * ( * PFNGLXQUERYHYPERPIPENETWORKSGIXPROC) (Display *dpy, int *npipes); + +#define glXBindHyperpipeSGIX GLXEW_GET_FUN(__glewXBindHyperpipeSGIX) +#define glXDestroyHyperpipeConfigSGIX GLXEW_GET_FUN(__glewXDestroyHyperpipeConfigSGIX) +#define glXHyperpipeAttribSGIX GLXEW_GET_FUN(__glewXHyperpipeAttribSGIX) +#define glXHyperpipeConfigSGIX GLXEW_GET_FUN(__glewXHyperpipeConfigSGIX) +#define glXQueryHyperpipeAttribSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeAttribSGIX) +#define glXQueryHyperpipeBestAttribSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeBestAttribSGIX) +#define glXQueryHyperpipeConfigSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeConfigSGIX) +#define glXQueryHyperpipeNetworkSGIX GLXEW_GET_FUN(__glewXQueryHyperpipeNetworkSGIX) + +#define GLXEW_SGIX_hyperpipe GLXEW_GET_VAR(__GLXEW_SGIX_hyperpipe) + +#endif /* GLX_SGIX_hyperpipe */ + +/* ---------------------------- GLX_SGIX_pbuffer --------------------------- */ + +#ifndef GLX_SGIX_pbuffer +#define GLX_SGIX_pbuffer 1 + +#define GLX_FRONT_LEFT_BUFFER_BIT_SGIX 0x00000001 +#define GLX_FRONT_RIGHT_BUFFER_BIT_SGIX 0x00000002 +#define GLX_PBUFFER_BIT_SGIX 0x00000004 +#define GLX_BACK_LEFT_BUFFER_BIT_SGIX 0x00000004 +#define GLX_BACK_RIGHT_BUFFER_BIT_SGIX 0x00000008 +#define GLX_AUX_BUFFERS_BIT_SGIX 0x00000010 +#define GLX_DEPTH_BUFFER_BIT_SGIX 0x00000020 +#define GLX_STENCIL_BUFFER_BIT_SGIX 0x00000040 +#define GLX_ACCUM_BUFFER_BIT_SGIX 0x00000080 +#define GLX_SAMPLE_BUFFERS_BIT_SGIX 0x00000100 +#define GLX_MAX_PBUFFER_WIDTH_SGIX 0x8016 +#define GLX_MAX_PBUFFER_HEIGHT_SGIX 0x8017 +#define GLX_MAX_PBUFFER_PIXELS_SGIX 0x8018 +#define GLX_OPTIMAL_PBUFFER_WIDTH_SGIX 0x8019 +#define GLX_OPTIMAL_PBUFFER_HEIGHT_SGIX 0x801A +#define GLX_PRESERVED_CONTENTS_SGIX 0x801B +#define GLX_LARGEST_PBUFFER_SGIX 0x801C +#define GLX_WIDTH_SGIX 0x801D +#define GLX_HEIGHT_SGIX 0x801E +#define GLX_EVENT_MASK_SGIX 0x801F +#define GLX_DAMAGED_SGIX 0x8020 +#define GLX_SAVED_SGIX 0x8021 +#define GLX_WINDOW_SGIX 0x8022 +#define GLX_PBUFFER_SGIX 0x8023 +#define GLX_BUFFER_CLOBBER_MASK_SGIX 0x08000000 + +typedef XID GLXPbufferSGIX; +typedef struct { int type; unsigned long serial; Bool send_event; Display *display; GLXDrawable drawable; int event_type; int draw_type; unsigned int mask; int x, y; int width, height; int count; } GLXBufferClobberEventSGIX; + +typedef GLXPbuffer ( * PFNGLXCREATEGLXPBUFFERSGIXPROC) (Display* dpy, GLXFBConfig config, unsigned int width, unsigned int height, int *attrib_list); +typedef void ( * PFNGLXDESTROYGLXPBUFFERSGIXPROC) (Display* dpy, GLXPbuffer pbuf); +typedef void ( * PFNGLXGETSELECTEDEVENTSGIXPROC) (Display* dpy, GLXDrawable drawable, unsigned long *mask); +typedef void ( * PFNGLXQUERYGLXPBUFFERSGIXPROC) (Display* dpy, GLXPbuffer pbuf, int attribute, unsigned int *value); +typedef void ( * PFNGLXSELECTEVENTSGIXPROC) (Display* dpy, GLXDrawable drawable, unsigned long mask); + +#define glXCreateGLXPbufferSGIX GLXEW_GET_FUN(__glewXCreateGLXPbufferSGIX) +#define glXDestroyGLXPbufferSGIX GLXEW_GET_FUN(__glewXDestroyGLXPbufferSGIX) +#define glXGetSelectedEventSGIX GLXEW_GET_FUN(__glewXGetSelectedEventSGIX) +#define glXQueryGLXPbufferSGIX GLXEW_GET_FUN(__glewXQueryGLXPbufferSGIX) +#define glXSelectEventSGIX GLXEW_GET_FUN(__glewXSelectEventSGIX) + +#define GLXEW_SGIX_pbuffer GLXEW_GET_VAR(__GLXEW_SGIX_pbuffer) + +#endif /* GLX_SGIX_pbuffer */ + +/* ------------------------- GLX_SGIX_swap_barrier ------------------------- */ + +#ifndef GLX_SGIX_swap_barrier +#define GLX_SGIX_swap_barrier 1 + +typedef void ( * PFNGLXBINDSWAPBARRIERSGIXPROC) (Display *dpy, GLXDrawable drawable, int barrier); +typedef Bool ( * PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC) (Display *dpy, int screen, int *max); + +#define glXBindSwapBarrierSGIX GLXEW_GET_FUN(__glewXBindSwapBarrierSGIX) +#define glXQueryMaxSwapBarriersSGIX GLXEW_GET_FUN(__glewXQueryMaxSwapBarriersSGIX) + +#define GLXEW_SGIX_swap_barrier GLXEW_GET_VAR(__GLXEW_SGIX_swap_barrier) + +#endif /* GLX_SGIX_swap_barrier */ + +/* -------------------------- GLX_SGIX_swap_group -------------------------- */ + +#ifndef GLX_SGIX_swap_group +#define GLX_SGIX_swap_group 1 + +typedef void ( * PFNGLXJOINSWAPGROUPSGIXPROC) (Display *dpy, GLXDrawable drawable, GLXDrawable member); + +#define glXJoinSwapGroupSGIX GLXEW_GET_FUN(__glewXJoinSwapGroupSGIX) + +#define GLXEW_SGIX_swap_group GLXEW_GET_VAR(__GLXEW_SGIX_swap_group) + +#endif /* GLX_SGIX_swap_group */ + +/* ------------------------- GLX_SGIX_video_resize ------------------------- */ + +#ifndef GLX_SGIX_video_resize +#define GLX_SGIX_video_resize 1 + +#define GLX_SYNC_FRAME_SGIX 0x00000000 +#define GLX_SYNC_SWAP_SGIX 0x00000001 + +typedef int ( * PFNGLXBINDCHANNELTOWINDOWSGIXPROC) (Display* display, int screen, int channel, Window window); +typedef int ( * PFNGLXCHANNELRECTSGIXPROC) (Display* display, int screen, int channel, int x, int y, int w, int h); +typedef int ( * PFNGLXCHANNELRECTSYNCSGIXPROC) (Display* display, int screen, int channel, GLenum synctype); +typedef int ( * PFNGLXQUERYCHANNELDELTASSGIXPROC) (Display* display, int screen, int channel, int *x, int *y, int *w, int *h); +typedef int ( * PFNGLXQUERYCHANNELRECTSGIXPROC) (Display* display, int screen, int channel, int *dx, int *dy, int *dw, int *dh); + +#define glXBindChannelToWindowSGIX GLXEW_GET_FUN(__glewXBindChannelToWindowSGIX) +#define glXChannelRectSGIX GLXEW_GET_FUN(__glewXChannelRectSGIX) +#define glXChannelRectSyncSGIX GLXEW_GET_FUN(__glewXChannelRectSyncSGIX) +#define glXQueryChannelDeltasSGIX GLXEW_GET_FUN(__glewXQueryChannelDeltasSGIX) +#define glXQueryChannelRectSGIX GLXEW_GET_FUN(__glewXQueryChannelRectSGIX) + +#define GLXEW_SGIX_video_resize GLXEW_GET_VAR(__GLXEW_SGIX_video_resize) + +#endif /* GLX_SGIX_video_resize */ + +/* ---------------------- GLX_SGIX_visual_select_group --------------------- */ + +#ifndef GLX_SGIX_visual_select_group +#define GLX_SGIX_visual_select_group 1 + +#define GLX_VISUAL_SELECT_GROUP_SGIX 0x8028 + +#define GLXEW_SGIX_visual_select_group GLXEW_GET_VAR(__GLXEW_SGIX_visual_select_group) + +#endif /* GLX_SGIX_visual_select_group */ + +/* ---------------------------- GLX_SGI_cushion ---------------------------- */ + +#ifndef GLX_SGI_cushion +#define GLX_SGI_cushion 1 + +typedef void ( * PFNGLXCUSHIONSGIPROC) (Display* dpy, Window window, float cushion); + +#define glXCushionSGI GLXEW_GET_FUN(__glewXCushionSGI) + +#define GLXEW_SGI_cushion GLXEW_GET_VAR(__GLXEW_SGI_cushion) + +#endif /* GLX_SGI_cushion */ + +/* ----------------------- GLX_SGI_make_current_read ----------------------- */ + +#ifndef GLX_SGI_make_current_read +#define GLX_SGI_make_current_read 1 + +typedef GLXDrawable ( * PFNGLXGETCURRENTREADDRAWABLESGIPROC) (void); +typedef Bool ( * PFNGLXMAKECURRENTREADSGIPROC) (Display* dpy, GLXDrawable draw, GLXDrawable read, GLXContext ctx); + +#define glXGetCurrentReadDrawableSGI GLXEW_GET_FUN(__glewXGetCurrentReadDrawableSGI) +#define glXMakeCurrentReadSGI GLXEW_GET_FUN(__glewXMakeCurrentReadSGI) + +#define GLXEW_SGI_make_current_read GLXEW_GET_VAR(__GLXEW_SGI_make_current_read) + +#endif /* GLX_SGI_make_current_read */ + +/* -------------------------- GLX_SGI_swap_control ------------------------- */ + +#ifndef GLX_SGI_swap_control +#define GLX_SGI_swap_control 1 + +typedef int ( * PFNGLXSWAPINTERVALSGIPROC) (int interval); + +#define glXSwapIntervalSGI GLXEW_GET_FUN(__glewXSwapIntervalSGI) + +#define GLXEW_SGI_swap_control GLXEW_GET_VAR(__GLXEW_SGI_swap_control) + +#endif /* GLX_SGI_swap_control */ + +/* --------------------------- GLX_SGI_video_sync -------------------------- */ + +#ifndef GLX_SGI_video_sync +#define GLX_SGI_video_sync 1 + +typedef int ( * PFNGLXGETVIDEOSYNCSGIPROC) (unsigned int* count); +typedef int ( * PFNGLXWAITVIDEOSYNCSGIPROC) (int divisor, int remainder, unsigned int* count); + +#define glXGetVideoSyncSGI GLXEW_GET_FUN(__glewXGetVideoSyncSGI) +#define glXWaitVideoSyncSGI GLXEW_GET_FUN(__glewXWaitVideoSyncSGI) + +#define GLXEW_SGI_video_sync GLXEW_GET_VAR(__GLXEW_SGI_video_sync) + +#endif /* GLX_SGI_video_sync */ + +/* --------------------- GLX_SUN_get_transparent_index --------------------- */ + +#ifndef GLX_SUN_get_transparent_index +#define GLX_SUN_get_transparent_index 1 + +typedef Status ( * PFNGLXGETTRANSPARENTINDEXSUNPROC) (Display* dpy, Window overlay, Window underlay, unsigned long *pTransparentIndex); + +#define glXGetTransparentIndexSUN GLXEW_GET_FUN(__glewXGetTransparentIndexSUN) + +#define GLXEW_SUN_get_transparent_index GLXEW_GET_VAR(__GLXEW_SUN_get_transparent_index) + +#endif /* GLX_SUN_get_transparent_index */ + +/* -------------------------- GLX_SUN_video_resize ------------------------- */ + +#ifndef GLX_SUN_video_resize +#define GLX_SUN_video_resize 1 + +#define GLX_VIDEO_RESIZE_SUN 0x8171 +#define GL_VIDEO_RESIZE_COMPENSATION_SUN 0x85CD + +typedef int ( * PFNGLXGETVIDEORESIZESUNPROC) (Display* display, GLXDrawable window, float* factor); +typedef int ( * PFNGLXVIDEORESIZESUNPROC) (Display* display, GLXDrawable window, float factor); + +#define glXGetVideoResizeSUN GLXEW_GET_FUN(__glewXGetVideoResizeSUN) +#define glXVideoResizeSUN GLXEW_GET_FUN(__glewXVideoResizeSUN) + +#define GLXEW_SUN_video_resize GLXEW_GET_VAR(__GLXEW_SUN_video_resize) + +#endif /* GLX_SUN_video_resize */ + +/* ------------------------------------------------------------------------- */ + +#ifdef GLEW_MX +#define GLXEW_EXPORT +#else +#define GLXEW_EXPORT extern +#endif /* GLEW_MX */ + +extern PFNGLXGETCURRENTDISPLAYPROC __glewXGetCurrentDisplay; + +extern PFNGLXCHOOSEFBCONFIGPROC __glewXChooseFBConfig; +extern PFNGLXCREATENEWCONTEXTPROC __glewXCreateNewContext; +extern PFNGLXCREATEPBUFFERPROC __glewXCreatePbuffer; +extern PFNGLXCREATEPIXMAPPROC __glewXCreatePixmap; +extern PFNGLXCREATEWINDOWPROC __glewXCreateWindow; +extern PFNGLXDESTROYPBUFFERPROC __glewXDestroyPbuffer; +extern PFNGLXDESTROYPIXMAPPROC __glewXDestroyPixmap; +extern PFNGLXDESTROYWINDOWPROC __glewXDestroyWindow; +extern PFNGLXGETCURRENTREADDRAWABLEPROC __glewXGetCurrentReadDrawable; +extern PFNGLXGETFBCONFIGATTRIBPROC __glewXGetFBConfigAttrib; +extern PFNGLXGETFBCONFIGSPROC __glewXGetFBConfigs; +extern PFNGLXGETSELECTEDEVENTPROC __glewXGetSelectedEvent; +extern PFNGLXGETVISUALFROMFBCONFIGPROC __glewXGetVisualFromFBConfig; +extern PFNGLXMAKECONTEXTCURRENTPROC __glewXMakeContextCurrent; +extern PFNGLXQUERYCONTEXTPROC __glewXQueryContext; +extern PFNGLXQUERYDRAWABLEPROC __glewXQueryDrawable; +extern PFNGLXSELECTEVENTPROC __glewXSelectEvent; + +extern PFNGLXCREATECONTEXTATTRIBSARBPROC __glewXCreateContextAttribsARB; + +extern PFNGLXBINDTEXIMAGEATIPROC __glewXBindTexImageATI; +extern PFNGLXDRAWABLEATTRIBATIPROC __glewXDrawableAttribATI; +extern PFNGLXRELEASETEXIMAGEATIPROC __glewXReleaseTexImageATI; + +extern PFNGLXFREECONTEXTEXTPROC __glewXFreeContextEXT; +extern PFNGLXGETCONTEXTIDEXTPROC __glewXGetContextIDEXT; +extern PFNGLXIMPORTCONTEXTEXTPROC __glewXImportContextEXT; +extern PFNGLXQUERYCONTEXTINFOEXTPROC __glewXQueryContextInfoEXT; + +extern PFNGLXSWAPINTERVALEXTPROC __glewXSwapIntervalEXT; + +extern PFNGLXBINDTEXIMAGEEXTPROC __glewXBindTexImageEXT; +extern PFNGLXRELEASETEXIMAGEEXTPROC __glewXReleaseTexImageEXT; + +extern PFNGLXGETAGPOFFSETMESAPROC __glewXGetAGPOffsetMESA; + +extern PFNGLXCOPYSUBBUFFERMESAPROC __glewXCopySubBufferMESA; + +extern PFNGLXCREATEGLXPIXMAPMESAPROC __glewXCreateGLXPixmapMESA; + +extern PFNGLXRELEASEBUFFERSMESAPROC __glewXReleaseBuffersMESA; + +extern PFNGLXSET3DFXMODEMESAPROC __glewXSet3DfxModeMESA; + +extern PFNGLXGETSWAPINTERVALMESAPROC __glewXGetSwapIntervalMESA; +extern PFNGLXSWAPINTERVALMESAPROC __glewXSwapIntervalMESA; + +extern PFNGLXCOPYIMAGESUBDATANVPROC __glewXCopyImageSubDataNV; + +extern PFNGLXBINDVIDEODEVICENVPROC __glewXBindVideoDeviceNV; +extern PFNGLXENUMERATEVIDEODEVICESNVPROC __glewXEnumerateVideoDevicesNV; + +extern PFNGLXBINDSWAPBARRIERNVPROC __glewXBindSwapBarrierNV; +extern PFNGLXJOINSWAPGROUPNVPROC __glewXJoinSwapGroupNV; +extern PFNGLXQUERYFRAMECOUNTNVPROC __glewXQueryFrameCountNV; +extern PFNGLXQUERYMAXSWAPGROUPSNVPROC __glewXQueryMaxSwapGroupsNV; +extern PFNGLXQUERYSWAPGROUPNVPROC __glewXQuerySwapGroupNV; +extern PFNGLXRESETFRAMECOUNTNVPROC __glewXResetFrameCountNV; + +extern PFNGLXALLOCATEMEMORYNVPROC __glewXAllocateMemoryNV; +extern PFNGLXFREEMEMORYNVPROC __glewXFreeMemoryNV; + +extern PFNGLXBINDVIDEOCAPTUREDEVICENVPROC __glewXBindVideoCaptureDeviceNV; +extern PFNGLXENUMERATEVIDEOCAPTUREDEVICESNVPROC __glewXEnumerateVideoCaptureDevicesNV; +extern PFNGLXLOCKVIDEOCAPTUREDEVICENVPROC __glewXLockVideoCaptureDeviceNV; +extern PFNGLXQUERYVIDEOCAPTUREDEVICENVPROC __glewXQueryVideoCaptureDeviceNV; +extern PFNGLXRELEASEVIDEOCAPTUREDEVICENVPROC __glewXReleaseVideoCaptureDeviceNV; + +extern PFNGLXBINDVIDEOIMAGENVPROC __glewXBindVideoImageNV; +extern PFNGLXGETVIDEODEVICENVPROC __glewXGetVideoDeviceNV; +extern PFNGLXGETVIDEOINFONVPROC __glewXGetVideoInfoNV; +extern PFNGLXRELEASEVIDEODEVICENVPROC __glewXReleaseVideoDeviceNV; +extern PFNGLXRELEASEVIDEOIMAGENVPROC __glewXReleaseVideoImageNV; +extern PFNGLXSENDPBUFFERTOVIDEONVPROC __glewXSendPbufferToVideoNV; + +extern PFNGLXGETMSCRATEOMLPROC __glewXGetMscRateOML; +extern PFNGLXGETSYNCVALUESOMLPROC __glewXGetSyncValuesOML; +extern PFNGLXSWAPBUFFERSMSCOMLPROC __glewXSwapBuffersMscOML; +extern PFNGLXWAITFORMSCOMLPROC __glewXWaitForMscOML; +extern PFNGLXWAITFORSBCOMLPROC __glewXWaitForSbcOML; + +extern PFNGLXCHOOSEFBCONFIGSGIXPROC __glewXChooseFBConfigSGIX; +extern PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC __glewXCreateContextWithConfigSGIX; +extern PFNGLXCREATEGLXPIXMAPWITHCONFIGSGIXPROC __glewXCreateGLXPixmapWithConfigSGIX; +extern PFNGLXGETFBCONFIGATTRIBSGIXPROC __glewXGetFBConfigAttribSGIX; +extern PFNGLXGETFBCONFIGFROMVISUALSGIXPROC __glewXGetFBConfigFromVisualSGIX; +extern PFNGLXGETVISUALFROMFBCONFIGSGIXPROC __glewXGetVisualFromFBConfigSGIX; + +extern PFNGLXBINDHYPERPIPESGIXPROC __glewXBindHyperpipeSGIX; +extern PFNGLXDESTROYHYPERPIPECONFIGSGIXPROC __glewXDestroyHyperpipeConfigSGIX; +extern PFNGLXHYPERPIPEATTRIBSGIXPROC __glewXHyperpipeAttribSGIX; +extern PFNGLXHYPERPIPECONFIGSGIXPROC __glewXHyperpipeConfigSGIX; +extern PFNGLXQUERYHYPERPIPEATTRIBSGIXPROC __glewXQueryHyperpipeAttribSGIX; +extern PFNGLXQUERYHYPERPIPEBESTATTRIBSGIXPROC __glewXQueryHyperpipeBestAttribSGIX; +extern PFNGLXQUERYHYPERPIPECONFIGSGIXPROC __glewXQueryHyperpipeConfigSGIX; +extern PFNGLXQUERYHYPERPIPENETWORKSGIXPROC __glewXQueryHyperpipeNetworkSGIX; + +extern PFNGLXCREATEGLXPBUFFERSGIXPROC __glewXCreateGLXPbufferSGIX; +extern PFNGLXDESTROYGLXPBUFFERSGIXPROC __glewXDestroyGLXPbufferSGIX; +extern PFNGLXGETSELECTEDEVENTSGIXPROC __glewXGetSelectedEventSGIX; +extern PFNGLXQUERYGLXPBUFFERSGIXPROC __glewXQueryGLXPbufferSGIX; +extern PFNGLXSELECTEVENTSGIXPROC __glewXSelectEventSGIX; + +extern PFNGLXBINDSWAPBARRIERSGIXPROC __glewXBindSwapBarrierSGIX; +extern PFNGLXQUERYMAXSWAPBARRIERSSGIXPROC __glewXQueryMaxSwapBarriersSGIX; + +extern PFNGLXJOINSWAPGROUPSGIXPROC __glewXJoinSwapGroupSGIX; + +extern PFNGLXBINDCHANNELTOWINDOWSGIXPROC __glewXBindChannelToWindowSGIX; +extern PFNGLXCHANNELRECTSGIXPROC __glewXChannelRectSGIX; +extern PFNGLXCHANNELRECTSYNCSGIXPROC __glewXChannelRectSyncSGIX; +extern PFNGLXQUERYCHANNELDELTASSGIXPROC __glewXQueryChannelDeltasSGIX; +extern PFNGLXQUERYCHANNELRECTSGIXPROC __glewXQueryChannelRectSGIX; + +extern PFNGLXCUSHIONSGIPROC __glewXCushionSGI; + +extern PFNGLXGETCURRENTREADDRAWABLESGIPROC __glewXGetCurrentReadDrawableSGI; +extern PFNGLXMAKECURRENTREADSGIPROC __glewXMakeCurrentReadSGI; + +extern PFNGLXSWAPINTERVALSGIPROC __glewXSwapIntervalSGI; + +extern PFNGLXGETVIDEOSYNCSGIPROC __glewXGetVideoSyncSGI; +extern PFNGLXWAITVIDEOSYNCSGIPROC __glewXWaitVideoSyncSGI; + +extern PFNGLXGETTRANSPARENTINDEXSUNPROC __glewXGetTransparentIndexSUN; + +extern PFNGLXGETVIDEORESIZESUNPROC __glewXGetVideoResizeSUN; +extern PFNGLXVIDEORESIZESUNPROC __glewXVideoResizeSUN; + +#if defined(GLEW_MX) +struct GLXEWContextStruct +{ +#endif /* GLEW_MX */ + +GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_0; +GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_1; +GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_2; +GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_3; +GLXEW_EXPORT GLboolean __GLXEW_VERSION_1_4; +GLXEW_EXPORT GLboolean __GLXEW_3DFX_multisample; +GLXEW_EXPORT GLboolean __GLXEW_AMD_gpu_association; +GLXEW_EXPORT GLboolean __GLXEW_ARB_create_context; +GLXEW_EXPORT GLboolean __GLXEW_ARB_create_context_profile; +GLXEW_EXPORT GLboolean __GLXEW_ARB_create_context_robustness; +GLXEW_EXPORT GLboolean __GLXEW_ARB_fbconfig_float; +GLXEW_EXPORT GLboolean __GLXEW_ARB_framebuffer_sRGB; +GLXEW_EXPORT GLboolean __GLXEW_ARB_get_proc_address; +GLXEW_EXPORT GLboolean __GLXEW_ARB_multisample; +GLXEW_EXPORT GLboolean __GLXEW_ARB_vertex_buffer_object; +GLXEW_EXPORT GLboolean __GLXEW_ATI_pixel_format_float; +GLXEW_EXPORT GLboolean __GLXEW_ATI_render_texture; +GLXEW_EXPORT GLboolean __GLXEW_EXT_create_context_es2_profile; +GLXEW_EXPORT GLboolean __GLXEW_EXT_fbconfig_packed_float; +GLXEW_EXPORT GLboolean __GLXEW_EXT_framebuffer_sRGB; +GLXEW_EXPORT GLboolean __GLXEW_EXT_import_context; +GLXEW_EXPORT GLboolean __GLXEW_EXT_scene_marker; +GLXEW_EXPORT GLboolean __GLXEW_EXT_swap_control; +GLXEW_EXPORT GLboolean __GLXEW_EXT_texture_from_pixmap; +GLXEW_EXPORT GLboolean __GLXEW_EXT_visual_info; +GLXEW_EXPORT GLboolean __GLXEW_EXT_visual_rating; +GLXEW_EXPORT GLboolean __GLXEW_INTEL_swap_event; +GLXEW_EXPORT GLboolean __GLXEW_MESA_agp_offset; +GLXEW_EXPORT GLboolean __GLXEW_MESA_copy_sub_buffer; +GLXEW_EXPORT GLboolean __GLXEW_MESA_pixmap_colormap; +GLXEW_EXPORT GLboolean __GLXEW_MESA_release_buffers; +GLXEW_EXPORT GLboolean __GLXEW_MESA_set_3dfx_mode; +GLXEW_EXPORT GLboolean __GLXEW_MESA_swap_control; +GLXEW_EXPORT GLboolean __GLXEW_NV_copy_image; +GLXEW_EXPORT GLboolean __GLXEW_NV_float_buffer; +GLXEW_EXPORT GLboolean __GLXEW_NV_multisample_coverage; +GLXEW_EXPORT GLboolean __GLXEW_NV_present_video; +GLXEW_EXPORT GLboolean __GLXEW_NV_swap_group; +GLXEW_EXPORT GLboolean __GLXEW_NV_vertex_array_range; +GLXEW_EXPORT GLboolean __GLXEW_NV_video_capture; +GLXEW_EXPORT GLboolean __GLXEW_NV_video_output; +GLXEW_EXPORT GLboolean __GLXEW_OML_swap_method; +GLXEW_EXPORT GLboolean __GLXEW_OML_sync_control; +GLXEW_EXPORT GLboolean __GLXEW_SGIS_blended_overlay; +GLXEW_EXPORT GLboolean __GLXEW_SGIS_color_range; +GLXEW_EXPORT GLboolean __GLXEW_SGIS_multisample; +GLXEW_EXPORT GLboolean __GLXEW_SGIS_shared_multisample; +GLXEW_EXPORT GLboolean __GLXEW_SGIX_fbconfig; +GLXEW_EXPORT GLboolean __GLXEW_SGIX_hyperpipe; +GLXEW_EXPORT GLboolean __GLXEW_SGIX_pbuffer; +GLXEW_EXPORT GLboolean __GLXEW_SGIX_swap_barrier; +GLXEW_EXPORT GLboolean __GLXEW_SGIX_swap_group; +GLXEW_EXPORT GLboolean __GLXEW_SGIX_video_resize; +GLXEW_EXPORT GLboolean __GLXEW_SGIX_visual_select_group; +GLXEW_EXPORT GLboolean __GLXEW_SGI_cushion; +GLXEW_EXPORT GLboolean __GLXEW_SGI_make_current_read; +GLXEW_EXPORT GLboolean __GLXEW_SGI_swap_control; +GLXEW_EXPORT GLboolean __GLXEW_SGI_video_sync; +GLXEW_EXPORT GLboolean __GLXEW_SUN_get_transparent_index; +GLXEW_EXPORT GLboolean __GLXEW_SUN_video_resize; + +#ifdef GLEW_MX +}; /* GLXEWContextStruct */ +#endif /* GLEW_MX */ + +/* ------------------------------------------------------------------------ */ + +#ifdef GLEW_MX + +typedef struct GLXEWContextStruct GLXEWContext; +extern GLenum glxewContextInit (GLXEWContext* ctx); +extern GLboolean glxewContextIsSupported (const GLXEWContext* ctx, const char* name); + +#define glxewInit() glxewContextInit(glxewGetContext()) +#define glxewIsSupported(x) glxewContextIsSupported(glxewGetContext(), x) + +#define GLXEW_GET_VAR(x) (*(const GLboolean*)&(glxewGetContext()->x)) +#define GLXEW_GET_FUN(x) x + +#else /* GLEW_MX */ + +#define GLXEW_GET_VAR(x) (*(const GLboolean*)&x) +#define GLXEW_GET_FUN(x) x + +extern GLboolean glxewIsSupported (const char* name); + +#endif /* GLEW_MX */ + +extern GLboolean glxewGetExtension (const char* name); + +#ifdef __cplusplus +} +#endif + +#endif /* __glxew_h__ */ diff --git a/cocos2dx/platform/third_party/win32/OGLES/GL/wglew.h b/cocos2dx/platform/third_party/win32/OGLES/GL/wglew.h new file mode 100644 index 0000000000..a32e11c6c6 --- /dev/null +++ b/cocos2dx/platform/third_party/win32/OGLES/GL/wglew.h @@ -0,0 +1,1363 @@ +/* +** The OpenGL Extension Wrangler Library +** Copyright (C) 2002-2008, Milan Ikits +** Copyright (C) 2002-2008, Marcelo E. Magallon +** Copyright (C) 2002, Lev Povalahev +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions are met: +** +** * Redistributions of source code must retain the above copyright notice, +** this list of conditions and the following disclaimer. +** * Redistributions in binary form must reproduce the above copyright notice, +** this list of conditions and the following disclaimer in the documentation +** and/or other materials provided with the distribution. +** * The name of the author may be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +** AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +** IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +** ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +** LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +** CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +** SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +** INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +** CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +** ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +** THE POSSIBILITY OF SUCH DAMAGE. +*/ + +/* +** Copyright (c) 2007 The Khronos Group Inc. +** +** Permission is hereby granted, free of charge, to any person obtaining a +** copy of this software and/or associated documentation files (the +** "Materials"), to deal in the Materials without restriction, including +** without limitation the rights to use, copy, modify, merge, publish, +** distribute, sublicense, and/or sell copies of the Materials, and to +** permit persons to whom the Materials are furnished to do so, subject to +** the following conditions: +** +** The above copyright notice and this permission notice shall be included +** in all copies or substantial portions of the Materials. +** +** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, +** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE +** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. +*/ + +#ifndef __wglew_h__ +#define __wglew_h__ +#define __WGLEW_H__ + +#ifdef __wglext_h_ +#error wglext.h included before wglew.h +#endif + +#define __wglext_h_ + +#if !defined(WINAPI) +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN 1 +# endif +#include +# undef WIN32_LEAN_AND_MEAN +#endif + +/* + * GLEW_STATIC needs to be set when using the static version. + * GLEW_BUILD is set when building the DLL version. + */ +#ifdef GLEW_STATIC +# define GLEWAPI extern +#else +# ifdef GLEW_BUILD +# define GLEWAPI extern __declspec(dllexport) +# else +# define GLEWAPI extern __declspec(dllimport) +# endif +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* -------------------------- WGL_3DFX_multisample ------------------------- */ + +#ifndef WGL_3DFX_multisample +#define WGL_3DFX_multisample 1 + +#define WGL_SAMPLE_BUFFERS_3DFX 0x2060 +#define WGL_SAMPLES_3DFX 0x2061 + +#define WGLEW_3DFX_multisample WGLEW_GET_VAR(__WGLEW_3DFX_multisample) + +#endif /* WGL_3DFX_multisample */ + +/* ------------------------- WGL_3DL_stereo_control ------------------------ */ + +#ifndef WGL_3DL_stereo_control +#define WGL_3DL_stereo_control 1 + +#define WGL_STEREO_EMITTER_ENABLE_3DL 0x2055 +#define WGL_STEREO_EMITTER_DISABLE_3DL 0x2056 +#define WGL_STEREO_POLARITY_NORMAL_3DL 0x2057 +#define WGL_STEREO_POLARITY_INVERT_3DL 0x2058 + +typedef BOOL (WINAPI * PFNWGLSETSTEREOEMITTERSTATE3DLPROC) (HDC hDC, UINT uState); + +#define wglSetStereoEmitterState3DL WGLEW_GET_FUN(__wglewSetStereoEmitterState3DL) + +#define WGLEW_3DL_stereo_control WGLEW_GET_VAR(__WGLEW_3DL_stereo_control) + +#endif /* WGL_3DL_stereo_control */ + +/* ------------------------ WGL_AMD_gpu_association ------------------------ */ + +#ifndef WGL_AMD_gpu_association +#define WGL_AMD_gpu_association 1 + +#define WGL_GPU_VENDOR_AMD 0x1F00 +#define WGL_GPU_RENDERER_STRING_AMD 0x1F01 +#define WGL_GPU_OPENGL_VERSION_STRING_AMD 0x1F02 +#define WGL_GPU_FASTEST_TARGET_GPUS_AMD 0x21A2 +#define WGL_GPU_RAM_AMD 0x21A3 +#define WGL_GPU_CLOCK_AMD 0x21A4 +#define WGL_GPU_NUM_PIPES_AMD 0x21A5 +#define WGL_GPU_NUM_SIMD_AMD 0x21A6 +#define WGL_GPU_NUM_RB_AMD 0x21A7 +#define WGL_GPU_NUM_SPI_AMD 0x21A8 + +typedef VOID (WINAPI * PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC) (HGLRC dstCtx, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); +typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC) (UINT id); +typedef HGLRC (WINAPI * PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC) (UINT id, HGLRC hShareContext, const int* attribList); +typedef BOOL (WINAPI * PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC) (HGLRC hglrc); +typedef UINT (WINAPI * PFNWGLGETCONTEXTGPUIDAMDPROC) (HGLRC hglrc); +typedef HGLRC (WINAPI * PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC) (void); +typedef UINT (WINAPI * PFNWGLGETGPUIDSAMDPROC) (UINT maxCount, UINT* ids); +typedef INT (WINAPI * PFNWGLGETGPUINFOAMDPROC) (UINT id, INT property, GLenum dataType, UINT size, void* data); +typedef BOOL (WINAPI * PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC) (HGLRC hglrc); + +#define wglBlitContextFramebufferAMD WGLEW_GET_FUN(__wglewBlitContextFramebufferAMD) +#define wglCreateAssociatedContextAMD WGLEW_GET_FUN(__wglewCreateAssociatedContextAMD) +#define wglCreateAssociatedContextAttribsAMD WGLEW_GET_FUN(__wglewCreateAssociatedContextAttribsAMD) +#define wglDeleteAssociatedContextAMD WGLEW_GET_FUN(__wglewDeleteAssociatedContextAMD) +#define wglGetContextGPUIDAMD WGLEW_GET_FUN(__wglewGetContextGPUIDAMD) +#define wglGetCurrentAssociatedContextAMD WGLEW_GET_FUN(__wglewGetCurrentAssociatedContextAMD) +#define wglGetGPUIDsAMD WGLEW_GET_FUN(__wglewGetGPUIDsAMD) +#define wglGetGPUInfoAMD WGLEW_GET_FUN(__wglewGetGPUInfoAMD) +#define wglMakeAssociatedContextCurrentAMD WGLEW_GET_FUN(__wglewMakeAssociatedContextCurrentAMD) + +#define WGLEW_AMD_gpu_association WGLEW_GET_VAR(__WGLEW_AMD_gpu_association) + +#endif /* WGL_AMD_gpu_association */ + +/* ------------------------- WGL_ARB_buffer_region ------------------------- */ + +#ifndef WGL_ARB_buffer_region +#define WGL_ARB_buffer_region 1 + +#define WGL_FRONT_COLOR_BUFFER_BIT_ARB 0x00000001 +#define WGL_BACK_COLOR_BUFFER_BIT_ARB 0x00000002 +#define WGL_DEPTH_BUFFER_BIT_ARB 0x00000004 +#define WGL_STENCIL_BUFFER_BIT_ARB 0x00000008 + +typedef HANDLE (WINAPI * PFNWGLCREATEBUFFERREGIONARBPROC) (HDC hDC, int iLayerPlane, UINT uType); +typedef VOID (WINAPI * PFNWGLDELETEBUFFERREGIONARBPROC) (HANDLE hRegion); +typedef BOOL (WINAPI * PFNWGLRESTOREBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height, int xSrc, int ySrc); +typedef BOOL (WINAPI * PFNWGLSAVEBUFFERREGIONARBPROC) (HANDLE hRegion, int x, int y, int width, int height); + +#define wglCreateBufferRegionARB WGLEW_GET_FUN(__wglewCreateBufferRegionARB) +#define wglDeleteBufferRegionARB WGLEW_GET_FUN(__wglewDeleteBufferRegionARB) +#define wglRestoreBufferRegionARB WGLEW_GET_FUN(__wglewRestoreBufferRegionARB) +#define wglSaveBufferRegionARB WGLEW_GET_FUN(__wglewSaveBufferRegionARB) + +#define WGLEW_ARB_buffer_region WGLEW_GET_VAR(__WGLEW_ARB_buffer_region) + +#endif /* WGL_ARB_buffer_region */ + +/* ------------------------- WGL_ARB_create_context ------------------------ */ + +#ifndef WGL_ARB_create_context +#define WGL_ARB_create_context 1 + +#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 +#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 +#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091 +#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 +#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 +#define WGL_CONTEXT_FLAGS_ARB 0x2094 +#define ERROR_INVALID_VERSION_ARB 0x2095 +#define ERROR_INVALID_PROFILE_ARB 0x2096 + +typedef HGLRC (WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC) (HDC hDC, HGLRC hShareContext, const int* attribList); + +#define wglCreateContextAttribsARB WGLEW_GET_FUN(__wglewCreateContextAttribsARB) + +#define WGLEW_ARB_create_context WGLEW_GET_VAR(__WGLEW_ARB_create_context) + +#endif /* WGL_ARB_create_context */ + +/* --------------------- WGL_ARB_create_context_profile -------------------- */ + +#ifndef WGL_ARB_create_context_profile +#define WGL_ARB_create_context_profile 1 + +#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 +#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 + +#define WGLEW_ARB_create_context_profile WGLEW_GET_VAR(__WGLEW_ARB_create_context_profile) + +#endif /* WGL_ARB_create_context_profile */ + +/* ------------------- WGL_ARB_create_context_robustness ------------------- */ + +#ifndef WGL_ARB_create_context_robustness +#define WGL_ARB_create_context_robustness 1 + +#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004 +#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 +#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 +#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261 + +#define WGLEW_ARB_create_context_robustness WGLEW_GET_VAR(__WGLEW_ARB_create_context_robustness) + +#endif /* WGL_ARB_create_context_robustness */ + +/* ----------------------- WGL_ARB_extensions_string ----------------------- */ + +#ifndef WGL_ARB_extensions_string +#define WGL_ARB_extensions_string 1 + +typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGARBPROC) (HDC hdc); + +#define wglGetExtensionsStringARB WGLEW_GET_FUN(__wglewGetExtensionsStringARB) + +#define WGLEW_ARB_extensions_string WGLEW_GET_VAR(__WGLEW_ARB_extensions_string) + +#endif /* WGL_ARB_extensions_string */ + +/* ------------------------ WGL_ARB_framebuffer_sRGB ----------------------- */ + +#ifndef WGL_ARB_framebuffer_sRGB +#define WGL_ARB_framebuffer_sRGB 1 + +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9 + +#define WGLEW_ARB_framebuffer_sRGB WGLEW_GET_VAR(__WGLEW_ARB_framebuffer_sRGB) + +#endif /* WGL_ARB_framebuffer_sRGB */ + +/* ----------------------- WGL_ARB_make_current_read ----------------------- */ + +#ifndef WGL_ARB_make_current_read +#define WGL_ARB_make_current_read 1 + +#define ERROR_INVALID_PIXEL_TYPE_ARB 0x2043 +#define ERROR_INCOMPATIBLE_DEVICE_CONTEXTS_ARB 0x2054 + +typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCARBPROC) (VOID); +typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTARBPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); + +#define wglGetCurrentReadDCARB WGLEW_GET_FUN(__wglewGetCurrentReadDCARB) +#define wglMakeContextCurrentARB WGLEW_GET_FUN(__wglewMakeContextCurrentARB) + +#define WGLEW_ARB_make_current_read WGLEW_GET_VAR(__WGLEW_ARB_make_current_read) + +#endif /* WGL_ARB_make_current_read */ + +/* -------------------------- WGL_ARB_multisample -------------------------- */ + +#ifndef WGL_ARB_multisample +#define WGL_ARB_multisample 1 + +#define WGL_SAMPLE_BUFFERS_ARB 0x2041 +#define WGL_SAMPLES_ARB 0x2042 + +#define WGLEW_ARB_multisample WGLEW_GET_VAR(__WGLEW_ARB_multisample) + +#endif /* WGL_ARB_multisample */ + +/* ---------------------------- WGL_ARB_pbuffer ---------------------------- */ + +#ifndef WGL_ARB_pbuffer +#define WGL_ARB_pbuffer 1 + +#define WGL_DRAW_TO_PBUFFER_ARB 0x202D +#define WGL_MAX_PBUFFER_PIXELS_ARB 0x202E +#define WGL_MAX_PBUFFER_WIDTH_ARB 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_ARB 0x2030 +#define WGL_PBUFFER_LARGEST_ARB 0x2033 +#define WGL_PBUFFER_WIDTH_ARB 0x2034 +#define WGL_PBUFFER_HEIGHT_ARB 0x2035 +#define WGL_PBUFFER_LOST_ARB 0x2036 + +DECLARE_HANDLE(HPBUFFERARB); + +typedef HPBUFFERARB (WINAPI * PFNWGLCREATEPBUFFERARBPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList); +typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFERARBPROC) (HPBUFFERARB hPbuffer); +typedef HDC (WINAPI * PFNWGLGETPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer); +typedef BOOL (WINAPI * PFNWGLQUERYPBUFFERARBPROC) (HPBUFFERARB hPbuffer, int iAttribute, int* piValue); +typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCARBPROC) (HPBUFFERARB hPbuffer, HDC hDC); + +#define wglCreatePbufferARB WGLEW_GET_FUN(__wglewCreatePbufferARB) +#define wglDestroyPbufferARB WGLEW_GET_FUN(__wglewDestroyPbufferARB) +#define wglGetPbufferDCARB WGLEW_GET_FUN(__wglewGetPbufferDCARB) +#define wglQueryPbufferARB WGLEW_GET_FUN(__wglewQueryPbufferARB) +#define wglReleasePbufferDCARB WGLEW_GET_FUN(__wglewReleasePbufferDCARB) + +#define WGLEW_ARB_pbuffer WGLEW_GET_VAR(__WGLEW_ARB_pbuffer) + +#endif /* WGL_ARB_pbuffer */ + +/* -------------------------- WGL_ARB_pixel_format ------------------------- */ + +#ifndef WGL_ARB_pixel_format +#define WGL_ARB_pixel_format 1 + +#define WGL_NUMBER_PIXEL_FORMATS_ARB 0x2000 +#define WGL_DRAW_TO_WINDOW_ARB 0x2001 +#define WGL_DRAW_TO_BITMAP_ARB 0x2002 +#define WGL_ACCELERATION_ARB 0x2003 +#define WGL_NEED_PALETTE_ARB 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_ARB 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_ARB 0x2006 +#define WGL_SWAP_METHOD_ARB 0x2007 +#define WGL_NUMBER_OVERLAYS_ARB 0x2008 +#define WGL_NUMBER_UNDERLAYS_ARB 0x2009 +#define WGL_TRANSPARENT_ARB 0x200A +#define WGL_SHARE_DEPTH_ARB 0x200C +#define WGL_SHARE_STENCIL_ARB 0x200D +#define WGL_SHARE_ACCUM_ARB 0x200E +#define WGL_SUPPORT_GDI_ARB 0x200F +#define WGL_SUPPORT_OPENGL_ARB 0x2010 +#define WGL_DOUBLE_BUFFER_ARB 0x2011 +#define WGL_STEREO_ARB 0x2012 +#define WGL_PIXEL_TYPE_ARB 0x2013 +#define WGL_COLOR_BITS_ARB 0x2014 +#define WGL_RED_BITS_ARB 0x2015 +#define WGL_RED_SHIFT_ARB 0x2016 +#define WGL_GREEN_BITS_ARB 0x2017 +#define WGL_GREEN_SHIFT_ARB 0x2018 +#define WGL_BLUE_BITS_ARB 0x2019 +#define WGL_BLUE_SHIFT_ARB 0x201A +#define WGL_ALPHA_BITS_ARB 0x201B +#define WGL_ALPHA_SHIFT_ARB 0x201C +#define WGL_ACCUM_BITS_ARB 0x201D +#define WGL_ACCUM_RED_BITS_ARB 0x201E +#define WGL_ACCUM_GREEN_BITS_ARB 0x201F +#define WGL_ACCUM_BLUE_BITS_ARB 0x2020 +#define WGL_ACCUM_ALPHA_BITS_ARB 0x2021 +#define WGL_DEPTH_BITS_ARB 0x2022 +#define WGL_STENCIL_BITS_ARB 0x2023 +#define WGL_AUX_BUFFERS_ARB 0x2024 +#define WGL_NO_ACCELERATION_ARB 0x2025 +#define WGL_GENERIC_ACCELERATION_ARB 0x2026 +#define WGL_FULL_ACCELERATION_ARB 0x2027 +#define WGL_SWAP_EXCHANGE_ARB 0x2028 +#define WGL_SWAP_COPY_ARB 0x2029 +#define WGL_SWAP_UNDEFINED_ARB 0x202A +#define WGL_TYPE_RGBA_ARB 0x202B +#define WGL_TYPE_COLORINDEX_ARB 0x202C +#define WGL_TRANSPARENT_RED_VALUE_ARB 0x2037 +#define WGL_TRANSPARENT_GREEN_VALUE_ARB 0x2038 +#define WGL_TRANSPARENT_BLUE_VALUE_ARB 0x2039 +#define WGL_TRANSPARENT_ALPHA_VALUE_ARB 0x203A +#define WGL_TRANSPARENT_INDEX_VALUE_ARB 0x203B + +typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATARBPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int* piAttributes, FLOAT *pfValues); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVARBPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int* piAttributes, int *piValues); + +#define wglChoosePixelFormatARB WGLEW_GET_FUN(__wglewChoosePixelFormatARB) +#define wglGetPixelFormatAttribfvARB WGLEW_GET_FUN(__wglewGetPixelFormatAttribfvARB) +#define wglGetPixelFormatAttribivARB WGLEW_GET_FUN(__wglewGetPixelFormatAttribivARB) + +#define WGLEW_ARB_pixel_format WGLEW_GET_VAR(__WGLEW_ARB_pixel_format) + +#endif /* WGL_ARB_pixel_format */ + +/* ----------------------- WGL_ARB_pixel_format_float ---------------------- */ + +#ifndef WGL_ARB_pixel_format_float +#define WGL_ARB_pixel_format_float 1 + +#define WGL_TYPE_RGBA_FLOAT_ARB 0x21A0 + +#define WGLEW_ARB_pixel_format_float WGLEW_GET_VAR(__WGLEW_ARB_pixel_format_float) + +#endif /* WGL_ARB_pixel_format_float */ + +/* ------------------------- WGL_ARB_render_texture ------------------------ */ + +#ifndef WGL_ARB_render_texture +#define WGL_ARB_render_texture 1 + +#define WGL_BIND_TO_TEXTURE_RGB_ARB 0x2070 +#define WGL_BIND_TO_TEXTURE_RGBA_ARB 0x2071 +#define WGL_TEXTURE_FORMAT_ARB 0x2072 +#define WGL_TEXTURE_TARGET_ARB 0x2073 +#define WGL_MIPMAP_TEXTURE_ARB 0x2074 +#define WGL_TEXTURE_RGB_ARB 0x2075 +#define WGL_TEXTURE_RGBA_ARB 0x2076 +#define WGL_NO_TEXTURE_ARB 0x2077 +#define WGL_TEXTURE_CUBE_MAP_ARB 0x2078 +#define WGL_TEXTURE_1D_ARB 0x2079 +#define WGL_TEXTURE_2D_ARB 0x207A +#define WGL_MIPMAP_LEVEL_ARB 0x207B +#define WGL_CUBE_MAP_FACE_ARB 0x207C +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x207D +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x207E +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x207F +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x2080 +#define WGL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x2081 +#define WGL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x2082 +#define WGL_FRONT_LEFT_ARB 0x2083 +#define WGL_FRONT_RIGHT_ARB 0x2084 +#define WGL_BACK_LEFT_ARB 0x2085 +#define WGL_BACK_RIGHT_ARB 0x2086 +#define WGL_AUX0_ARB 0x2087 +#define WGL_AUX1_ARB 0x2088 +#define WGL_AUX2_ARB 0x2089 +#define WGL_AUX3_ARB 0x208A +#define WGL_AUX4_ARB 0x208B +#define WGL_AUX5_ARB 0x208C +#define WGL_AUX6_ARB 0x208D +#define WGL_AUX7_ARB 0x208E +#define WGL_AUX8_ARB 0x208F +#define WGL_AUX9_ARB 0x2090 + +typedef BOOL (WINAPI * PFNWGLBINDTEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); +typedef BOOL (WINAPI * PFNWGLRELEASETEXIMAGEARBPROC) (HPBUFFERARB hPbuffer, int iBuffer); +typedef BOOL (WINAPI * PFNWGLSETPBUFFERATTRIBARBPROC) (HPBUFFERARB hPbuffer, const int* piAttribList); + +#define wglBindTexImageARB WGLEW_GET_FUN(__wglewBindTexImageARB) +#define wglReleaseTexImageARB WGLEW_GET_FUN(__wglewReleaseTexImageARB) +#define wglSetPbufferAttribARB WGLEW_GET_FUN(__wglewSetPbufferAttribARB) + +#define WGLEW_ARB_render_texture WGLEW_GET_VAR(__WGLEW_ARB_render_texture) + +#endif /* WGL_ARB_render_texture */ + +/* ----------------------- WGL_ATI_pixel_format_float ---------------------- */ + +#ifndef WGL_ATI_pixel_format_float +#define WGL_ATI_pixel_format_float 1 + +#define WGL_TYPE_RGBA_FLOAT_ATI 0x21A0 +#define GL_RGBA_FLOAT_MODE_ATI 0x8820 +#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835 + +#define WGLEW_ATI_pixel_format_float WGLEW_GET_VAR(__WGLEW_ATI_pixel_format_float) + +#endif /* WGL_ATI_pixel_format_float */ + +/* -------------------- WGL_ATI_render_texture_rectangle ------------------- */ + +#ifndef WGL_ATI_render_texture_rectangle +#define WGL_ATI_render_texture_rectangle 1 + +#define WGL_TEXTURE_RECTANGLE_ATI 0x21A5 + +#define WGLEW_ATI_render_texture_rectangle WGLEW_GET_VAR(__WGLEW_ATI_render_texture_rectangle) + +#endif /* WGL_ATI_render_texture_rectangle */ + +/* ------------------- WGL_EXT_create_context_es2_profile ------------------ */ + +#ifndef WGL_EXT_create_context_es2_profile +#define WGL_EXT_create_context_es2_profile 1 + +#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 + +#define WGLEW_EXT_create_context_es2_profile WGLEW_GET_VAR(__WGLEW_EXT_create_context_es2_profile) + +#endif /* WGL_EXT_create_context_es2_profile */ + +/* -------------------------- WGL_EXT_depth_float -------------------------- */ + +#ifndef WGL_EXT_depth_float +#define WGL_EXT_depth_float 1 + +#define WGL_DEPTH_FLOAT_EXT 0x2040 + +#define WGLEW_EXT_depth_float WGLEW_GET_VAR(__WGLEW_EXT_depth_float) + +#endif /* WGL_EXT_depth_float */ + +/* ---------------------- WGL_EXT_display_color_table ---------------------- */ + +#ifndef WGL_EXT_display_color_table +#define WGL_EXT_display_color_table 1 + +typedef GLboolean (WINAPI * PFNWGLBINDDISPLAYCOLORTABLEEXTPROC) (GLushort id); +typedef GLboolean (WINAPI * PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC) (GLushort id); +typedef void (WINAPI * PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC) (GLushort id); +typedef GLboolean (WINAPI * PFNWGLLOADDISPLAYCOLORTABLEEXTPROC) (GLushort* table, GLuint length); + +#define wglBindDisplayColorTableEXT WGLEW_GET_FUN(__wglewBindDisplayColorTableEXT) +#define wglCreateDisplayColorTableEXT WGLEW_GET_FUN(__wglewCreateDisplayColorTableEXT) +#define wglDestroyDisplayColorTableEXT WGLEW_GET_FUN(__wglewDestroyDisplayColorTableEXT) +#define wglLoadDisplayColorTableEXT WGLEW_GET_FUN(__wglewLoadDisplayColorTableEXT) + +#define WGLEW_EXT_display_color_table WGLEW_GET_VAR(__WGLEW_EXT_display_color_table) + +#endif /* WGL_EXT_display_color_table */ + +/* ----------------------- WGL_EXT_extensions_string ----------------------- */ + +#ifndef WGL_EXT_extensions_string +#define WGL_EXT_extensions_string 1 + +typedef const char* (WINAPI * PFNWGLGETEXTENSIONSSTRINGEXTPROC) (void); + +#define wglGetExtensionsStringEXT WGLEW_GET_FUN(__wglewGetExtensionsStringEXT) + +#define WGLEW_EXT_extensions_string WGLEW_GET_VAR(__WGLEW_EXT_extensions_string) + +#endif /* WGL_EXT_extensions_string */ + +/* ------------------------ WGL_EXT_framebuffer_sRGB ----------------------- */ + +#ifndef WGL_EXT_framebuffer_sRGB +#define WGL_EXT_framebuffer_sRGB 1 + +#define WGL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x20A9 + +#define WGLEW_EXT_framebuffer_sRGB WGLEW_GET_VAR(__WGLEW_EXT_framebuffer_sRGB) + +#endif /* WGL_EXT_framebuffer_sRGB */ + +/* ----------------------- WGL_EXT_make_current_read ----------------------- */ + +#ifndef WGL_EXT_make_current_read +#define WGL_EXT_make_current_read 1 + +#define ERROR_INVALID_PIXEL_TYPE_EXT 0x2043 + +typedef HDC (WINAPI * PFNWGLGETCURRENTREADDCEXTPROC) (VOID); +typedef BOOL (WINAPI * PFNWGLMAKECONTEXTCURRENTEXTPROC) (HDC hDrawDC, HDC hReadDC, HGLRC hglrc); + +#define wglGetCurrentReadDCEXT WGLEW_GET_FUN(__wglewGetCurrentReadDCEXT) +#define wglMakeContextCurrentEXT WGLEW_GET_FUN(__wglewMakeContextCurrentEXT) + +#define WGLEW_EXT_make_current_read WGLEW_GET_VAR(__WGLEW_EXT_make_current_read) + +#endif /* WGL_EXT_make_current_read */ + +/* -------------------------- WGL_EXT_multisample -------------------------- */ + +#ifndef WGL_EXT_multisample +#define WGL_EXT_multisample 1 + +#define WGL_SAMPLE_BUFFERS_EXT 0x2041 +#define WGL_SAMPLES_EXT 0x2042 + +#define WGLEW_EXT_multisample WGLEW_GET_VAR(__WGLEW_EXT_multisample) + +#endif /* WGL_EXT_multisample */ + +/* ---------------------------- WGL_EXT_pbuffer ---------------------------- */ + +#ifndef WGL_EXT_pbuffer +#define WGL_EXT_pbuffer 1 + +#define WGL_DRAW_TO_PBUFFER_EXT 0x202D +#define WGL_MAX_PBUFFER_PIXELS_EXT 0x202E +#define WGL_MAX_PBUFFER_WIDTH_EXT 0x202F +#define WGL_MAX_PBUFFER_HEIGHT_EXT 0x2030 +#define WGL_OPTIMAL_PBUFFER_WIDTH_EXT 0x2031 +#define WGL_OPTIMAL_PBUFFER_HEIGHT_EXT 0x2032 +#define WGL_PBUFFER_LARGEST_EXT 0x2033 +#define WGL_PBUFFER_WIDTH_EXT 0x2034 +#define WGL_PBUFFER_HEIGHT_EXT 0x2035 + +DECLARE_HANDLE(HPBUFFEREXT); + +typedef HPBUFFEREXT (WINAPI * PFNWGLCREATEPBUFFEREXTPROC) (HDC hDC, int iPixelFormat, int iWidth, int iHeight, const int* piAttribList); +typedef BOOL (WINAPI * PFNWGLDESTROYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer); +typedef HDC (WINAPI * PFNWGLGETPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer); +typedef BOOL (WINAPI * PFNWGLQUERYPBUFFEREXTPROC) (HPBUFFEREXT hPbuffer, int iAttribute, int* piValue); +typedef int (WINAPI * PFNWGLRELEASEPBUFFERDCEXTPROC) (HPBUFFEREXT hPbuffer, HDC hDC); + +#define wglCreatePbufferEXT WGLEW_GET_FUN(__wglewCreatePbufferEXT) +#define wglDestroyPbufferEXT WGLEW_GET_FUN(__wglewDestroyPbufferEXT) +#define wglGetPbufferDCEXT WGLEW_GET_FUN(__wglewGetPbufferDCEXT) +#define wglQueryPbufferEXT WGLEW_GET_FUN(__wglewQueryPbufferEXT) +#define wglReleasePbufferDCEXT WGLEW_GET_FUN(__wglewReleasePbufferDCEXT) + +#define WGLEW_EXT_pbuffer WGLEW_GET_VAR(__WGLEW_EXT_pbuffer) + +#endif /* WGL_EXT_pbuffer */ + +/* -------------------------- WGL_EXT_pixel_format ------------------------- */ + +#ifndef WGL_EXT_pixel_format +#define WGL_EXT_pixel_format 1 + +#define WGL_NUMBER_PIXEL_FORMATS_EXT 0x2000 +#define WGL_DRAW_TO_WINDOW_EXT 0x2001 +#define WGL_DRAW_TO_BITMAP_EXT 0x2002 +#define WGL_ACCELERATION_EXT 0x2003 +#define WGL_NEED_PALETTE_EXT 0x2004 +#define WGL_NEED_SYSTEM_PALETTE_EXT 0x2005 +#define WGL_SWAP_LAYER_BUFFERS_EXT 0x2006 +#define WGL_SWAP_METHOD_EXT 0x2007 +#define WGL_NUMBER_OVERLAYS_EXT 0x2008 +#define WGL_NUMBER_UNDERLAYS_EXT 0x2009 +#define WGL_TRANSPARENT_EXT 0x200A +#define WGL_TRANSPARENT_VALUE_EXT 0x200B +#define WGL_SHARE_DEPTH_EXT 0x200C +#define WGL_SHARE_STENCIL_EXT 0x200D +#define WGL_SHARE_ACCUM_EXT 0x200E +#define WGL_SUPPORT_GDI_EXT 0x200F +#define WGL_SUPPORT_OPENGL_EXT 0x2010 +#define WGL_DOUBLE_BUFFER_EXT 0x2011 +#define WGL_STEREO_EXT 0x2012 +#define WGL_PIXEL_TYPE_EXT 0x2013 +#define WGL_COLOR_BITS_EXT 0x2014 +#define WGL_RED_BITS_EXT 0x2015 +#define WGL_RED_SHIFT_EXT 0x2016 +#define WGL_GREEN_BITS_EXT 0x2017 +#define WGL_GREEN_SHIFT_EXT 0x2018 +#define WGL_BLUE_BITS_EXT 0x2019 +#define WGL_BLUE_SHIFT_EXT 0x201A +#define WGL_ALPHA_BITS_EXT 0x201B +#define WGL_ALPHA_SHIFT_EXT 0x201C +#define WGL_ACCUM_BITS_EXT 0x201D +#define WGL_ACCUM_RED_BITS_EXT 0x201E +#define WGL_ACCUM_GREEN_BITS_EXT 0x201F +#define WGL_ACCUM_BLUE_BITS_EXT 0x2020 +#define WGL_ACCUM_ALPHA_BITS_EXT 0x2021 +#define WGL_DEPTH_BITS_EXT 0x2022 +#define WGL_STENCIL_BITS_EXT 0x2023 +#define WGL_AUX_BUFFERS_EXT 0x2024 +#define WGL_NO_ACCELERATION_EXT 0x2025 +#define WGL_GENERIC_ACCELERATION_EXT 0x2026 +#define WGL_FULL_ACCELERATION_EXT 0x2027 +#define WGL_SWAP_EXCHANGE_EXT 0x2028 +#define WGL_SWAP_COPY_EXT 0x2029 +#define WGL_SWAP_UNDEFINED_EXT 0x202A +#define WGL_TYPE_RGBA_EXT 0x202B +#define WGL_TYPE_COLORINDEX_EXT 0x202C + +typedef BOOL (WINAPI * PFNWGLCHOOSEPIXELFORMATEXTPROC) (HDC hdc, const int* piAttribIList, const FLOAT *pfAttribFList, UINT nMaxFormats, int *piFormats, UINT *nNumFormats); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBFVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, FLOAT *pfValues); +typedef BOOL (WINAPI * PFNWGLGETPIXELFORMATATTRIBIVEXTPROC) (HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, int* piAttributes, int *piValues); + +#define wglChoosePixelFormatEXT WGLEW_GET_FUN(__wglewChoosePixelFormatEXT) +#define wglGetPixelFormatAttribfvEXT WGLEW_GET_FUN(__wglewGetPixelFormatAttribfvEXT) +#define wglGetPixelFormatAttribivEXT WGLEW_GET_FUN(__wglewGetPixelFormatAttribivEXT) + +#define WGLEW_EXT_pixel_format WGLEW_GET_VAR(__WGLEW_EXT_pixel_format) + +#endif /* WGL_EXT_pixel_format */ + +/* ------------------- WGL_EXT_pixel_format_packed_float ------------------- */ + +#ifndef WGL_EXT_pixel_format_packed_float +#define WGL_EXT_pixel_format_packed_float 1 + +#define WGL_TYPE_RGBA_UNSIGNED_FLOAT_EXT 0x20A8 + +#define WGLEW_EXT_pixel_format_packed_float WGLEW_GET_VAR(__WGLEW_EXT_pixel_format_packed_float) + +#endif /* WGL_EXT_pixel_format_packed_float */ + +/* -------------------------- WGL_EXT_swap_control ------------------------- */ + +#ifndef WGL_EXT_swap_control +#define WGL_EXT_swap_control 1 + +typedef int (WINAPI * PFNWGLGETSWAPINTERVALEXTPROC) (void); +typedef BOOL (WINAPI * PFNWGLSWAPINTERVALEXTPROC) (int interval); + +#define wglGetSwapIntervalEXT WGLEW_GET_FUN(__wglewGetSwapIntervalEXT) +#define wglSwapIntervalEXT WGLEW_GET_FUN(__wglewSwapIntervalEXT) + +#define WGLEW_EXT_swap_control WGLEW_GET_VAR(__WGLEW_EXT_swap_control) + +#endif /* WGL_EXT_swap_control */ + +/* --------------------- WGL_I3D_digital_video_control --------------------- */ + +#ifndef WGL_I3D_digital_video_control +#define WGL_I3D_digital_video_control 1 + +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_FRAMEBUFFER_I3D 0x2050 +#define WGL_DIGITAL_VIDEO_CURSOR_ALPHA_VALUE_I3D 0x2051 +#define WGL_DIGITAL_VIDEO_CURSOR_INCLUDED_I3D 0x2052 +#define WGL_DIGITAL_VIDEO_GAMMA_CORRECTED_I3D 0x2053 + +typedef BOOL (WINAPI * PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int* piValue); +typedef BOOL (WINAPI * PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int* piValue); + +#define wglGetDigitalVideoParametersI3D WGLEW_GET_FUN(__wglewGetDigitalVideoParametersI3D) +#define wglSetDigitalVideoParametersI3D WGLEW_GET_FUN(__wglewSetDigitalVideoParametersI3D) + +#define WGLEW_I3D_digital_video_control WGLEW_GET_VAR(__WGLEW_I3D_digital_video_control) + +#endif /* WGL_I3D_digital_video_control */ + +/* ----------------------------- WGL_I3D_gamma ----------------------------- */ + +#ifndef WGL_I3D_gamma +#define WGL_I3D_gamma 1 + +#define WGL_GAMMA_TABLE_SIZE_I3D 0x204E +#define WGL_GAMMA_EXCLUDE_DESKTOP_I3D 0x204F + +typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, USHORT* puRed, USHORT *puGreen, USHORT *puBlue); +typedef BOOL (WINAPI * PFNWGLGETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, int* piValue); +typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEI3DPROC) (HDC hDC, int iEntries, const USHORT* puRed, const USHORT *puGreen, const USHORT *puBlue); +typedef BOOL (WINAPI * PFNWGLSETGAMMATABLEPARAMETERSI3DPROC) (HDC hDC, int iAttribute, const int* piValue); + +#define wglGetGammaTableI3D WGLEW_GET_FUN(__wglewGetGammaTableI3D) +#define wglGetGammaTableParametersI3D WGLEW_GET_FUN(__wglewGetGammaTableParametersI3D) +#define wglSetGammaTableI3D WGLEW_GET_FUN(__wglewSetGammaTableI3D) +#define wglSetGammaTableParametersI3D WGLEW_GET_FUN(__wglewSetGammaTableParametersI3D) + +#define WGLEW_I3D_gamma WGLEW_GET_VAR(__WGLEW_I3D_gamma) + +#endif /* WGL_I3D_gamma */ + +/* ---------------------------- WGL_I3D_genlock ---------------------------- */ + +#ifndef WGL_I3D_genlock +#define WGL_I3D_genlock 1 + +#define WGL_GENLOCK_SOURCE_MULTIVIEW_I3D 0x2044 +#define WGL_GENLOCK_SOURCE_EXTERNAL_SYNC_I3D 0x2045 +#define WGL_GENLOCK_SOURCE_EXTERNAL_FIELD_I3D 0x2046 +#define WGL_GENLOCK_SOURCE_EXTERNAL_TTL_I3D 0x2047 +#define WGL_GENLOCK_SOURCE_DIGITAL_SYNC_I3D 0x2048 +#define WGL_GENLOCK_SOURCE_DIGITAL_FIELD_I3D 0x2049 +#define WGL_GENLOCK_SOURCE_EDGE_FALLING_I3D 0x204A +#define WGL_GENLOCK_SOURCE_EDGE_RISING_I3D 0x204B +#define WGL_GENLOCK_SOURCE_EDGE_BOTH_I3D 0x204C + +typedef BOOL (WINAPI * PFNWGLDISABLEGENLOCKI3DPROC) (HDC hDC); +typedef BOOL (WINAPI * PFNWGLENABLEGENLOCKI3DPROC) (HDC hDC); +typedef BOOL (WINAPI * PFNWGLGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT uRate); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT uDelay); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT uEdge); +typedef BOOL (WINAPI * PFNWGLGENLOCKSOURCEI3DPROC) (HDC hDC, UINT uSource); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSAMPLERATEI3DPROC) (HDC hDC, UINT* uRate); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEDELAYI3DPROC) (HDC hDC, UINT* uDelay); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEEDGEI3DPROC) (HDC hDC, UINT* uEdge); +typedef BOOL (WINAPI * PFNWGLGETGENLOCKSOURCEI3DPROC) (HDC hDC, UINT* uSource); +typedef BOOL (WINAPI * PFNWGLISENABLEDGENLOCKI3DPROC) (HDC hDC, BOOL* pFlag); +typedef BOOL (WINAPI * PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC) (HDC hDC, UINT* uMaxLineDelay, UINT *uMaxPixelDelay); + +#define wglDisableGenlockI3D WGLEW_GET_FUN(__wglewDisableGenlockI3D) +#define wglEnableGenlockI3D WGLEW_GET_FUN(__wglewEnableGenlockI3D) +#define wglGenlockSampleRateI3D WGLEW_GET_FUN(__wglewGenlockSampleRateI3D) +#define wglGenlockSourceDelayI3D WGLEW_GET_FUN(__wglewGenlockSourceDelayI3D) +#define wglGenlockSourceEdgeI3D WGLEW_GET_FUN(__wglewGenlockSourceEdgeI3D) +#define wglGenlockSourceI3D WGLEW_GET_FUN(__wglewGenlockSourceI3D) +#define wglGetGenlockSampleRateI3D WGLEW_GET_FUN(__wglewGetGenlockSampleRateI3D) +#define wglGetGenlockSourceDelayI3D WGLEW_GET_FUN(__wglewGetGenlockSourceDelayI3D) +#define wglGetGenlockSourceEdgeI3D WGLEW_GET_FUN(__wglewGetGenlockSourceEdgeI3D) +#define wglGetGenlockSourceI3D WGLEW_GET_FUN(__wglewGetGenlockSourceI3D) +#define wglIsEnabledGenlockI3D WGLEW_GET_FUN(__wglewIsEnabledGenlockI3D) +#define wglQueryGenlockMaxSourceDelayI3D WGLEW_GET_FUN(__wglewQueryGenlockMaxSourceDelayI3D) + +#define WGLEW_I3D_genlock WGLEW_GET_VAR(__WGLEW_I3D_genlock) + +#endif /* WGL_I3D_genlock */ + +/* -------------------------- WGL_I3D_image_buffer ------------------------- */ + +#ifndef WGL_I3D_image_buffer +#define WGL_I3D_image_buffer 1 + +#define WGL_IMAGE_BUFFER_MIN_ACCESS_I3D 0x00000001 +#define WGL_IMAGE_BUFFER_LOCK_I3D 0x00000002 + +typedef BOOL (WINAPI * PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC) (HDC hdc, HANDLE* pEvent, LPVOID *pAddress, DWORD *pSize, UINT count); +typedef LPVOID (WINAPI * PFNWGLCREATEIMAGEBUFFERI3DPROC) (HDC hDC, DWORD dwSize, UINT uFlags); +typedef BOOL (WINAPI * PFNWGLDESTROYIMAGEBUFFERI3DPROC) (HDC hDC, LPVOID pAddress); +typedef BOOL (WINAPI * PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC) (HDC hdc, LPVOID* pAddress, UINT count); + +#define wglAssociateImageBufferEventsI3D WGLEW_GET_FUN(__wglewAssociateImageBufferEventsI3D) +#define wglCreateImageBufferI3D WGLEW_GET_FUN(__wglewCreateImageBufferI3D) +#define wglDestroyImageBufferI3D WGLEW_GET_FUN(__wglewDestroyImageBufferI3D) +#define wglReleaseImageBufferEventsI3D WGLEW_GET_FUN(__wglewReleaseImageBufferEventsI3D) + +#define WGLEW_I3D_image_buffer WGLEW_GET_VAR(__WGLEW_I3D_image_buffer) + +#endif /* WGL_I3D_image_buffer */ + +/* ------------------------ WGL_I3D_swap_frame_lock ------------------------ */ + +#ifndef WGL_I3D_swap_frame_lock +#define WGL_I3D_swap_frame_lock 1 + +typedef BOOL (WINAPI * PFNWGLDISABLEFRAMELOCKI3DPROC) (VOID); +typedef BOOL (WINAPI * PFNWGLENABLEFRAMELOCKI3DPROC) (VOID); +typedef BOOL (WINAPI * PFNWGLISENABLEDFRAMELOCKI3DPROC) (BOOL* pFlag); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMELOCKMASTERI3DPROC) (BOOL* pFlag); + +#define wglDisableFrameLockI3D WGLEW_GET_FUN(__wglewDisableFrameLockI3D) +#define wglEnableFrameLockI3D WGLEW_GET_FUN(__wglewEnableFrameLockI3D) +#define wglIsEnabledFrameLockI3D WGLEW_GET_FUN(__wglewIsEnabledFrameLockI3D) +#define wglQueryFrameLockMasterI3D WGLEW_GET_FUN(__wglewQueryFrameLockMasterI3D) + +#define WGLEW_I3D_swap_frame_lock WGLEW_GET_VAR(__WGLEW_I3D_swap_frame_lock) + +#endif /* WGL_I3D_swap_frame_lock */ + +/* ------------------------ WGL_I3D_swap_frame_usage ----------------------- */ + +#ifndef WGL_I3D_swap_frame_usage +#define WGL_I3D_swap_frame_usage 1 + +typedef BOOL (WINAPI * PFNWGLBEGINFRAMETRACKINGI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLENDFRAMETRACKINGI3DPROC) (void); +typedef BOOL (WINAPI * PFNWGLGETFRAMEUSAGEI3DPROC) (float* pUsage); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMETRACKINGI3DPROC) (DWORD* pFrameCount, DWORD *pMissedFrames, float *pLastMissedUsage); + +#define wglBeginFrameTrackingI3D WGLEW_GET_FUN(__wglewBeginFrameTrackingI3D) +#define wglEndFrameTrackingI3D WGLEW_GET_FUN(__wglewEndFrameTrackingI3D) +#define wglGetFrameUsageI3D WGLEW_GET_FUN(__wglewGetFrameUsageI3D) +#define wglQueryFrameTrackingI3D WGLEW_GET_FUN(__wglewQueryFrameTrackingI3D) + +#define WGLEW_I3D_swap_frame_usage WGLEW_GET_VAR(__WGLEW_I3D_swap_frame_usage) + +#endif /* WGL_I3D_swap_frame_usage */ + +/* --------------------------- WGL_NV_DX_interop --------------------------- */ + +#ifndef WGL_NV_DX_interop +#define WGL_NV_DX_interop 1 + +#define WGL_ACCESS_READ_ONLY_NV 0x0000 +#define WGL_ACCESS_READ_WRITE_NV 0x0001 +#define WGL_ACCESS_WRITE_DISCARD_NV 0x0002 + +typedef BOOL (WINAPI * PFNWGLDXCLOSEDEVICENVPROC) (HANDLE hDevice); +typedef BOOL (WINAPI * PFNWGLDXLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects); +typedef BOOL (WINAPI * PFNWGLDXOBJECTACCESSNVPROC) (HANDLE hObject, GLenum access); +typedef HANDLE (WINAPI * PFNWGLDXOPENDEVICENVPROC) (void* dxDevice); +typedef HANDLE (WINAPI * PFNWGLDXREGISTEROBJECTNVPROC) (HANDLE hDevice, void* dxObject, GLuint name, GLenum type, GLenum access); +typedef BOOL (WINAPI * PFNWGLDXSETRESOURCESHAREHANDLENVPROC) (void* dxObject, HANDLE shareHandle); +typedef BOOL (WINAPI * PFNWGLDXUNLOCKOBJECTSNVPROC) (HANDLE hDevice, GLint count, HANDLE* hObjects); +typedef BOOL (WINAPI * PFNWGLDXUNREGISTEROBJECTNVPROC) (HANDLE hDevice, HANDLE hObject); + +#define wglDXCloseDeviceNV WGLEW_GET_FUN(__wglewDXCloseDeviceNV) +#define wglDXLockObjectsNV WGLEW_GET_FUN(__wglewDXLockObjectsNV) +#define wglDXObjectAccessNV WGLEW_GET_FUN(__wglewDXObjectAccessNV) +#define wglDXOpenDeviceNV WGLEW_GET_FUN(__wglewDXOpenDeviceNV) +#define wglDXRegisterObjectNV WGLEW_GET_FUN(__wglewDXRegisterObjectNV) +#define wglDXSetResourceShareHandleNV WGLEW_GET_FUN(__wglewDXSetResourceShareHandleNV) +#define wglDXUnlockObjectsNV WGLEW_GET_FUN(__wglewDXUnlockObjectsNV) +#define wglDXUnregisterObjectNV WGLEW_GET_FUN(__wglewDXUnregisterObjectNV) + +#define WGLEW_NV_DX_interop WGLEW_GET_VAR(__WGLEW_NV_DX_interop) + +#endif /* WGL_NV_DX_interop */ + +/* --------------------------- WGL_NV_copy_image --------------------------- */ + +#ifndef WGL_NV_copy_image +#define WGL_NV_copy_image 1 + +typedef BOOL (WINAPI * PFNWGLCOPYIMAGESUBDATANVPROC) (HGLRC hSrcRC, GLuint srcName, GLenum srcTarget, GLint srcLevel, GLint srcX, GLint srcY, GLint srcZ, HGLRC hDstRC, GLuint dstName, GLenum dstTarget, GLint dstLevel, GLint dstX, GLint dstY, GLint dstZ, GLsizei width, GLsizei height, GLsizei depth); + +#define wglCopyImageSubDataNV WGLEW_GET_FUN(__wglewCopyImageSubDataNV) + +#define WGLEW_NV_copy_image WGLEW_GET_VAR(__WGLEW_NV_copy_image) + +#endif /* WGL_NV_copy_image */ + +/* -------------------------- WGL_NV_float_buffer -------------------------- */ + +#ifndef WGL_NV_float_buffer +#define WGL_NV_float_buffer 1 + +#define WGL_FLOAT_COMPONENTS_NV 0x20B0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_R_NV 0x20B1 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RG_NV 0x20B2 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGB_NV 0x20B3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_FLOAT_RGBA_NV 0x20B4 +#define WGL_TEXTURE_FLOAT_R_NV 0x20B5 +#define WGL_TEXTURE_FLOAT_RG_NV 0x20B6 +#define WGL_TEXTURE_FLOAT_RGB_NV 0x20B7 +#define WGL_TEXTURE_FLOAT_RGBA_NV 0x20B8 + +#define WGLEW_NV_float_buffer WGLEW_GET_VAR(__WGLEW_NV_float_buffer) + +#endif /* WGL_NV_float_buffer */ + +/* -------------------------- WGL_NV_gpu_affinity -------------------------- */ + +#ifndef WGL_NV_gpu_affinity +#define WGL_NV_gpu_affinity 1 + +#define WGL_ERROR_INCOMPATIBLE_AFFINITY_MASKS_NV 0x20D0 +#define WGL_ERROR_MISSING_AFFINITY_MASK_NV 0x20D1 + +DECLARE_HANDLE(HGPUNV); +typedef struct _GPU_DEVICE { + DWORD cb; + CHAR DeviceName[32]; + CHAR DeviceString[128]; + DWORD Flags; + RECT rcVirtualScreen; +} GPU_DEVICE, *PGPU_DEVICE; + +typedef HDC (WINAPI * PFNWGLCREATEAFFINITYDCNVPROC) (const HGPUNV *phGpuList); +typedef BOOL (WINAPI * PFNWGLDELETEDCNVPROC) (HDC hdc); +typedef BOOL (WINAPI * PFNWGLENUMGPUDEVICESNVPROC) (HGPUNV hGpu, UINT iDeviceIndex, PGPU_DEVICE lpGpuDevice); +typedef BOOL (WINAPI * PFNWGLENUMGPUSFROMAFFINITYDCNVPROC) (HDC hAffinityDC, UINT iGpuIndex, HGPUNV *hGpu); +typedef BOOL (WINAPI * PFNWGLENUMGPUSNVPROC) (UINT iGpuIndex, HGPUNV *phGpu); + +#define wglCreateAffinityDCNV WGLEW_GET_FUN(__wglewCreateAffinityDCNV) +#define wglDeleteDCNV WGLEW_GET_FUN(__wglewDeleteDCNV) +#define wglEnumGpuDevicesNV WGLEW_GET_FUN(__wglewEnumGpuDevicesNV) +#define wglEnumGpusFromAffinityDCNV WGLEW_GET_FUN(__wglewEnumGpusFromAffinityDCNV) +#define wglEnumGpusNV WGLEW_GET_FUN(__wglewEnumGpusNV) + +#define WGLEW_NV_gpu_affinity WGLEW_GET_VAR(__WGLEW_NV_gpu_affinity) + +#endif /* WGL_NV_gpu_affinity */ + +/* ---------------------- WGL_NV_multisample_coverage ---------------------- */ + +#ifndef WGL_NV_multisample_coverage +#define WGL_NV_multisample_coverage 1 + +#define WGL_COVERAGE_SAMPLES_NV 0x2042 +#define WGL_COLOR_SAMPLES_NV 0x20B9 + +#define WGLEW_NV_multisample_coverage WGLEW_GET_VAR(__WGLEW_NV_multisample_coverage) + +#endif /* WGL_NV_multisample_coverage */ + +/* -------------------------- WGL_NV_present_video ------------------------- */ + +#ifndef WGL_NV_present_video +#define WGL_NV_present_video 1 + +#define WGL_NUM_VIDEO_SLOTS_NV 0x20F0 + +DECLARE_HANDLE(HVIDEOOUTPUTDEVICENV); + +typedef BOOL (WINAPI * PFNWGLBINDVIDEODEVICENVPROC) (HDC hDc, unsigned int uVideoSlot, HVIDEOOUTPUTDEVICENV hVideoDevice, const int* piAttribList); +typedef int (WINAPI * PFNWGLENUMERATEVIDEODEVICESNVPROC) (HDC hDc, HVIDEOOUTPUTDEVICENV* phDeviceList); +typedef BOOL (WINAPI * PFNWGLQUERYCURRENTCONTEXTNVPROC) (int iAttribute, int* piValue); + +#define wglBindVideoDeviceNV WGLEW_GET_FUN(__wglewBindVideoDeviceNV) +#define wglEnumerateVideoDevicesNV WGLEW_GET_FUN(__wglewEnumerateVideoDevicesNV) +#define wglQueryCurrentContextNV WGLEW_GET_FUN(__wglewQueryCurrentContextNV) + +#define WGLEW_NV_present_video WGLEW_GET_VAR(__WGLEW_NV_present_video) + +#endif /* WGL_NV_present_video */ + +/* ---------------------- WGL_NV_render_depth_texture ---------------------- */ + +#ifndef WGL_NV_render_depth_texture +#define WGL_NV_render_depth_texture 1 + +#define WGL_NO_TEXTURE_ARB 0x2077 +#define WGL_BIND_TO_TEXTURE_DEPTH_NV 0x20A3 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_DEPTH_NV 0x20A4 +#define WGL_DEPTH_TEXTURE_FORMAT_NV 0x20A5 +#define WGL_TEXTURE_DEPTH_COMPONENT_NV 0x20A6 +#define WGL_DEPTH_COMPONENT_NV 0x20A7 + +#define WGLEW_NV_render_depth_texture WGLEW_GET_VAR(__WGLEW_NV_render_depth_texture) + +#endif /* WGL_NV_render_depth_texture */ + +/* -------------------- WGL_NV_render_texture_rectangle -------------------- */ + +#ifndef WGL_NV_render_texture_rectangle +#define WGL_NV_render_texture_rectangle 1 + +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGB_NV 0x20A0 +#define WGL_BIND_TO_TEXTURE_RECTANGLE_RGBA_NV 0x20A1 +#define WGL_TEXTURE_RECTANGLE_NV 0x20A2 + +#define WGLEW_NV_render_texture_rectangle WGLEW_GET_VAR(__WGLEW_NV_render_texture_rectangle) + +#endif /* WGL_NV_render_texture_rectangle */ + +/* --------------------------- WGL_NV_swap_group --------------------------- */ + +#ifndef WGL_NV_swap_group +#define WGL_NV_swap_group 1 + +typedef BOOL (WINAPI * PFNWGLBINDSWAPBARRIERNVPROC) (GLuint group, GLuint barrier); +typedef BOOL (WINAPI * PFNWGLJOINSWAPGROUPNVPROC) (HDC hDC, GLuint group); +typedef BOOL (WINAPI * PFNWGLQUERYFRAMECOUNTNVPROC) (HDC hDC, GLuint* count); +typedef BOOL (WINAPI * PFNWGLQUERYMAXSWAPGROUPSNVPROC) (HDC hDC, GLuint* maxGroups, GLuint *maxBarriers); +typedef BOOL (WINAPI * PFNWGLQUERYSWAPGROUPNVPROC) (HDC hDC, GLuint* group, GLuint *barrier); +typedef BOOL (WINAPI * PFNWGLRESETFRAMECOUNTNVPROC) (HDC hDC); + +#define wglBindSwapBarrierNV WGLEW_GET_FUN(__wglewBindSwapBarrierNV) +#define wglJoinSwapGroupNV WGLEW_GET_FUN(__wglewJoinSwapGroupNV) +#define wglQueryFrameCountNV WGLEW_GET_FUN(__wglewQueryFrameCountNV) +#define wglQueryMaxSwapGroupsNV WGLEW_GET_FUN(__wglewQueryMaxSwapGroupsNV) +#define wglQuerySwapGroupNV WGLEW_GET_FUN(__wglewQuerySwapGroupNV) +#define wglResetFrameCountNV WGLEW_GET_FUN(__wglewResetFrameCountNV) + +#define WGLEW_NV_swap_group WGLEW_GET_VAR(__WGLEW_NV_swap_group) + +#endif /* WGL_NV_swap_group */ + +/* ----------------------- WGL_NV_vertex_array_range ----------------------- */ + +#ifndef WGL_NV_vertex_array_range +#define WGL_NV_vertex_array_range 1 + +typedef void * (WINAPI * PFNWGLALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readFrequency, GLfloat writeFrequency, GLfloat priority); +typedef void (WINAPI * PFNWGLFREEMEMORYNVPROC) (void *pointer); + +#define wglAllocateMemoryNV WGLEW_GET_FUN(__wglewAllocateMemoryNV) +#define wglFreeMemoryNV WGLEW_GET_FUN(__wglewFreeMemoryNV) + +#define WGLEW_NV_vertex_array_range WGLEW_GET_VAR(__WGLEW_NV_vertex_array_range) + +#endif /* WGL_NV_vertex_array_range */ + +/* -------------------------- WGL_NV_video_capture ------------------------- */ + +#ifndef WGL_NV_video_capture +#define WGL_NV_video_capture 1 + +#define WGL_UNIQUE_ID_NV 0x20CE +#define WGL_NUM_VIDEO_CAPTURE_SLOTS_NV 0x20CF + +DECLARE_HANDLE(HVIDEOINPUTDEVICENV); + +typedef BOOL (WINAPI * PFNWGLBINDVIDEOCAPTUREDEVICENVPROC) (UINT uVideoSlot, HVIDEOINPUTDEVICENV hDevice); +typedef UINT (WINAPI * PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC) (HDC hDc, HVIDEOINPUTDEVICENV* phDeviceList); +typedef BOOL (WINAPI * PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); +typedef BOOL (WINAPI * PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice, int iAttribute, int* piValue); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC) (HDC hDc, HVIDEOINPUTDEVICENV hDevice); + +#define wglBindVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewBindVideoCaptureDeviceNV) +#define wglEnumerateVideoCaptureDevicesNV WGLEW_GET_FUN(__wglewEnumerateVideoCaptureDevicesNV) +#define wglLockVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewLockVideoCaptureDeviceNV) +#define wglQueryVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewQueryVideoCaptureDeviceNV) +#define wglReleaseVideoCaptureDeviceNV WGLEW_GET_FUN(__wglewReleaseVideoCaptureDeviceNV) + +#define WGLEW_NV_video_capture WGLEW_GET_VAR(__WGLEW_NV_video_capture) + +#endif /* WGL_NV_video_capture */ + +/* -------------------------- WGL_NV_video_output -------------------------- */ + +#ifndef WGL_NV_video_output +#define WGL_NV_video_output 1 + +#define WGL_BIND_TO_VIDEO_RGB_NV 0x20C0 +#define WGL_BIND_TO_VIDEO_RGBA_NV 0x20C1 +#define WGL_BIND_TO_VIDEO_RGB_AND_DEPTH_NV 0x20C2 +#define WGL_VIDEO_OUT_COLOR_NV 0x20C3 +#define WGL_VIDEO_OUT_ALPHA_NV 0x20C4 +#define WGL_VIDEO_OUT_DEPTH_NV 0x20C5 +#define WGL_VIDEO_OUT_COLOR_AND_ALPHA_NV 0x20C6 +#define WGL_VIDEO_OUT_COLOR_AND_DEPTH_NV 0x20C7 +#define WGL_VIDEO_OUT_FRAME 0x20C8 +#define WGL_VIDEO_OUT_FIELD_1 0x20C9 +#define WGL_VIDEO_OUT_FIELD_2 0x20CA +#define WGL_VIDEO_OUT_STACKED_FIELDS_1_2 0x20CB +#define WGL_VIDEO_OUT_STACKED_FIELDS_2_1 0x20CC + +DECLARE_HANDLE(HPVIDEODEV); + +typedef BOOL (WINAPI * PFNWGLBINDVIDEOIMAGENVPROC) (HPVIDEODEV hVideoDevice, HPBUFFERARB hPbuffer, int iVideoBuffer); +typedef BOOL (WINAPI * PFNWGLGETVIDEODEVICENVPROC) (HDC hDC, int numDevices, HPVIDEODEV* hVideoDevice); +typedef BOOL (WINAPI * PFNWGLGETVIDEOINFONVPROC) (HPVIDEODEV hpVideoDevice, unsigned long* pulCounterOutputPbuffer, unsigned long *pulCounterOutputVideo); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEODEVICENVPROC) (HPVIDEODEV hVideoDevice); +typedef BOOL (WINAPI * PFNWGLRELEASEVIDEOIMAGENVPROC) (HPBUFFERARB hPbuffer, int iVideoBuffer); +typedef BOOL (WINAPI * PFNWGLSENDPBUFFERTOVIDEONVPROC) (HPBUFFERARB hPbuffer, int iBufferType, unsigned long* pulCounterPbuffer, BOOL bBlock); + +#define wglBindVideoImageNV WGLEW_GET_FUN(__wglewBindVideoImageNV) +#define wglGetVideoDeviceNV WGLEW_GET_FUN(__wglewGetVideoDeviceNV) +#define wglGetVideoInfoNV WGLEW_GET_FUN(__wglewGetVideoInfoNV) +#define wglReleaseVideoDeviceNV WGLEW_GET_FUN(__wglewReleaseVideoDeviceNV) +#define wglReleaseVideoImageNV WGLEW_GET_FUN(__wglewReleaseVideoImageNV) +#define wglSendPbufferToVideoNV WGLEW_GET_FUN(__wglewSendPbufferToVideoNV) + +#define WGLEW_NV_video_output WGLEW_GET_VAR(__WGLEW_NV_video_output) + +#endif /* WGL_NV_video_output */ + +/* -------------------------- WGL_OML_sync_control ------------------------- */ + +#ifndef WGL_OML_sync_control +#define WGL_OML_sync_control 1 + +typedef BOOL (WINAPI * PFNWGLGETMSCRATEOMLPROC) (HDC hdc, INT32* numerator, INT32 *denominator); +typedef BOOL (WINAPI * PFNWGLGETSYNCVALUESOMLPROC) (HDC hdc, INT64* ust, INT64 *msc, INT64 *sbc); +typedef INT64 (WINAPI * PFNWGLSWAPBUFFERSMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef INT64 (WINAPI * PFNWGLSWAPLAYERBUFFERSMSCOMLPROC) (HDC hdc, INT fuPlanes, INT64 target_msc, INT64 divisor, INT64 remainder); +typedef BOOL (WINAPI * PFNWGLWAITFORMSCOMLPROC) (HDC hdc, INT64 target_msc, INT64 divisor, INT64 remainder, INT64* ust, INT64 *msc, INT64 *sbc); +typedef BOOL (WINAPI * PFNWGLWAITFORSBCOMLPROC) (HDC hdc, INT64 target_sbc, INT64* ust, INT64 *msc, INT64 *sbc); + +#define wglGetMscRateOML WGLEW_GET_FUN(__wglewGetMscRateOML) +#define wglGetSyncValuesOML WGLEW_GET_FUN(__wglewGetSyncValuesOML) +#define wglSwapBuffersMscOML WGLEW_GET_FUN(__wglewSwapBuffersMscOML) +#define wglSwapLayerBuffersMscOML WGLEW_GET_FUN(__wglewSwapLayerBuffersMscOML) +#define wglWaitForMscOML WGLEW_GET_FUN(__wglewWaitForMscOML) +#define wglWaitForSbcOML WGLEW_GET_FUN(__wglewWaitForSbcOML) + +#define WGLEW_OML_sync_control WGLEW_GET_VAR(__WGLEW_OML_sync_control) + +#endif /* WGL_OML_sync_control */ + +/* ------------------------------------------------------------------------- */ + +#ifdef GLEW_MX +#define WGLEW_EXPORT +#else +#define WGLEW_EXPORT GLEWAPI +#endif /* GLEW_MX */ + +#ifdef GLEW_MX +struct WGLEWContextStruct +{ +#endif /* GLEW_MX */ + +WGLEW_EXPORT PFNWGLSETSTEREOEMITTERSTATE3DLPROC __wglewSetStereoEmitterState3DL; + +WGLEW_EXPORT PFNWGLBLITCONTEXTFRAMEBUFFERAMDPROC __wglewBlitContextFramebufferAMD; +WGLEW_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTAMDPROC __wglewCreateAssociatedContextAMD; +WGLEW_EXPORT PFNWGLCREATEASSOCIATEDCONTEXTATTRIBSAMDPROC __wglewCreateAssociatedContextAttribsAMD; +WGLEW_EXPORT PFNWGLDELETEASSOCIATEDCONTEXTAMDPROC __wglewDeleteAssociatedContextAMD; +WGLEW_EXPORT PFNWGLGETCONTEXTGPUIDAMDPROC __wglewGetContextGPUIDAMD; +WGLEW_EXPORT PFNWGLGETCURRENTASSOCIATEDCONTEXTAMDPROC __wglewGetCurrentAssociatedContextAMD; +WGLEW_EXPORT PFNWGLGETGPUIDSAMDPROC __wglewGetGPUIDsAMD; +WGLEW_EXPORT PFNWGLGETGPUINFOAMDPROC __wglewGetGPUInfoAMD; +WGLEW_EXPORT PFNWGLMAKEASSOCIATEDCONTEXTCURRENTAMDPROC __wglewMakeAssociatedContextCurrentAMD; + +WGLEW_EXPORT PFNWGLCREATEBUFFERREGIONARBPROC __wglewCreateBufferRegionARB; +WGLEW_EXPORT PFNWGLDELETEBUFFERREGIONARBPROC __wglewDeleteBufferRegionARB; +WGLEW_EXPORT PFNWGLRESTOREBUFFERREGIONARBPROC __wglewRestoreBufferRegionARB; +WGLEW_EXPORT PFNWGLSAVEBUFFERREGIONARBPROC __wglewSaveBufferRegionARB; + +WGLEW_EXPORT PFNWGLCREATECONTEXTATTRIBSARBPROC __wglewCreateContextAttribsARB; + +WGLEW_EXPORT PFNWGLGETEXTENSIONSSTRINGARBPROC __wglewGetExtensionsStringARB; + +WGLEW_EXPORT PFNWGLGETCURRENTREADDCARBPROC __wglewGetCurrentReadDCARB; +WGLEW_EXPORT PFNWGLMAKECONTEXTCURRENTARBPROC __wglewMakeContextCurrentARB; + +WGLEW_EXPORT PFNWGLCREATEPBUFFERARBPROC __wglewCreatePbufferARB; +WGLEW_EXPORT PFNWGLDESTROYPBUFFERARBPROC __wglewDestroyPbufferARB; +WGLEW_EXPORT PFNWGLGETPBUFFERDCARBPROC __wglewGetPbufferDCARB; +WGLEW_EXPORT PFNWGLQUERYPBUFFERARBPROC __wglewQueryPbufferARB; +WGLEW_EXPORT PFNWGLRELEASEPBUFFERDCARBPROC __wglewReleasePbufferDCARB; + +WGLEW_EXPORT PFNWGLCHOOSEPIXELFORMATARBPROC __wglewChoosePixelFormatARB; +WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBFVARBPROC __wglewGetPixelFormatAttribfvARB; +WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBIVARBPROC __wglewGetPixelFormatAttribivARB; + +WGLEW_EXPORT PFNWGLBINDTEXIMAGEARBPROC __wglewBindTexImageARB; +WGLEW_EXPORT PFNWGLRELEASETEXIMAGEARBPROC __wglewReleaseTexImageARB; +WGLEW_EXPORT PFNWGLSETPBUFFERATTRIBARBPROC __wglewSetPbufferAttribARB; + +WGLEW_EXPORT PFNWGLBINDDISPLAYCOLORTABLEEXTPROC __wglewBindDisplayColorTableEXT; +WGLEW_EXPORT PFNWGLCREATEDISPLAYCOLORTABLEEXTPROC __wglewCreateDisplayColorTableEXT; +WGLEW_EXPORT PFNWGLDESTROYDISPLAYCOLORTABLEEXTPROC __wglewDestroyDisplayColorTableEXT; +WGLEW_EXPORT PFNWGLLOADDISPLAYCOLORTABLEEXTPROC __wglewLoadDisplayColorTableEXT; + +WGLEW_EXPORT PFNWGLGETEXTENSIONSSTRINGEXTPROC __wglewGetExtensionsStringEXT; + +WGLEW_EXPORT PFNWGLGETCURRENTREADDCEXTPROC __wglewGetCurrentReadDCEXT; +WGLEW_EXPORT PFNWGLMAKECONTEXTCURRENTEXTPROC __wglewMakeContextCurrentEXT; + +WGLEW_EXPORT PFNWGLCREATEPBUFFEREXTPROC __wglewCreatePbufferEXT; +WGLEW_EXPORT PFNWGLDESTROYPBUFFEREXTPROC __wglewDestroyPbufferEXT; +WGLEW_EXPORT PFNWGLGETPBUFFERDCEXTPROC __wglewGetPbufferDCEXT; +WGLEW_EXPORT PFNWGLQUERYPBUFFEREXTPROC __wglewQueryPbufferEXT; +WGLEW_EXPORT PFNWGLRELEASEPBUFFERDCEXTPROC __wglewReleasePbufferDCEXT; + +WGLEW_EXPORT PFNWGLCHOOSEPIXELFORMATEXTPROC __wglewChoosePixelFormatEXT; +WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBFVEXTPROC __wglewGetPixelFormatAttribfvEXT; +WGLEW_EXPORT PFNWGLGETPIXELFORMATATTRIBIVEXTPROC __wglewGetPixelFormatAttribivEXT; + +WGLEW_EXPORT PFNWGLGETSWAPINTERVALEXTPROC __wglewGetSwapIntervalEXT; +WGLEW_EXPORT PFNWGLSWAPINTERVALEXTPROC __wglewSwapIntervalEXT; + +WGLEW_EXPORT PFNWGLGETDIGITALVIDEOPARAMETERSI3DPROC __wglewGetDigitalVideoParametersI3D; +WGLEW_EXPORT PFNWGLSETDIGITALVIDEOPARAMETERSI3DPROC __wglewSetDigitalVideoParametersI3D; + +WGLEW_EXPORT PFNWGLGETGAMMATABLEI3DPROC __wglewGetGammaTableI3D; +WGLEW_EXPORT PFNWGLGETGAMMATABLEPARAMETERSI3DPROC __wglewGetGammaTableParametersI3D; +WGLEW_EXPORT PFNWGLSETGAMMATABLEI3DPROC __wglewSetGammaTableI3D; +WGLEW_EXPORT PFNWGLSETGAMMATABLEPARAMETERSI3DPROC __wglewSetGammaTableParametersI3D; + +WGLEW_EXPORT PFNWGLDISABLEGENLOCKI3DPROC __wglewDisableGenlockI3D; +WGLEW_EXPORT PFNWGLENABLEGENLOCKI3DPROC __wglewEnableGenlockI3D; +WGLEW_EXPORT PFNWGLGENLOCKSAMPLERATEI3DPROC __wglewGenlockSampleRateI3D; +WGLEW_EXPORT PFNWGLGENLOCKSOURCEDELAYI3DPROC __wglewGenlockSourceDelayI3D; +WGLEW_EXPORT PFNWGLGENLOCKSOURCEEDGEI3DPROC __wglewGenlockSourceEdgeI3D; +WGLEW_EXPORT PFNWGLGENLOCKSOURCEI3DPROC __wglewGenlockSourceI3D; +WGLEW_EXPORT PFNWGLGETGENLOCKSAMPLERATEI3DPROC __wglewGetGenlockSampleRateI3D; +WGLEW_EXPORT PFNWGLGETGENLOCKSOURCEDELAYI3DPROC __wglewGetGenlockSourceDelayI3D; +WGLEW_EXPORT PFNWGLGETGENLOCKSOURCEEDGEI3DPROC __wglewGetGenlockSourceEdgeI3D; +WGLEW_EXPORT PFNWGLGETGENLOCKSOURCEI3DPROC __wglewGetGenlockSourceI3D; +WGLEW_EXPORT PFNWGLISENABLEDGENLOCKI3DPROC __wglewIsEnabledGenlockI3D; +WGLEW_EXPORT PFNWGLQUERYGENLOCKMAXSOURCEDELAYI3DPROC __wglewQueryGenlockMaxSourceDelayI3D; + +WGLEW_EXPORT PFNWGLASSOCIATEIMAGEBUFFEREVENTSI3DPROC __wglewAssociateImageBufferEventsI3D; +WGLEW_EXPORT PFNWGLCREATEIMAGEBUFFERI3DPROC __wglewCreateImageBufferI3D; +WGLEW_EXPORT PFNWGLDESTROYIMAGEBUFFERI3DPROC __wglewDestroyImageBufferI3D; +WGLEW_EXPORT PFNWGLRELEASEIMAGEBUFFEREVENTSI3DPROC __wglewReleaseImageBufferEventsI3D; + +WGLEW_EXPORT PFNWGLDISABLEFRAMELOCKI3DPROC __wglewDisableFrameLockI3D; +WGLEW_EXPORT PFNWGLENABLEFRAMELOCKI3DPROC __wglewEnableFrameLockI3D; +WGLEW_EXPORT PFNWGLISENABLEDFRAMELOCKI3DPROC __wglewIsEnabledFrameLockI3D; +WGLEW_EXPORT PFNWGLQUERYFRAMELOCKMASTERI3DPROC __wglewQueryFrameLockMasterI3D; + +WGLEW_EXPORT PFNWGLBEGINFRAMETRACKINGI3DPROC __wglewBeginFrameTrackingI3D; +WGLEW_EXPORT PFNWGLENDFRAMETRACKINGI3DPROC __wglewEndFrameTrackingI3D; +WGLEW_EXPORT PFNWGLGETFRAMEUSAGEI3DPROC __wglewGetFrameUsageI3D; +WGLEW_EXPORT PFNWGLQUERYFRAMETRACKINGI3DPROC __wglewQueryFrameTrackingI3D; + +WGLEW_EXPORT PFNWGLDXCLOSEDEVICENVPROC __wglewDXCloseDeviceNV; +WGLEW_EXPORT PFNWGLDXLOCKOBJECTSNVPROC __wglewDXLockObjectsNV; +WGLEW_EXPORT PFNWGLDXOBJECTACCESSNVPROC __wglewDXObjectAccessNV; +WGLEW_EXPORT PFNWGLDXOPENDEVICENVPROC __wglewDXOpenDeviceNV; +WGLEW_EXPORT PFNWGLDXREGISTEROBJECTNVPROC __wglewDXRegisterObjectNV; +WGLEW_EXPORT PFNWGLDXSETRESOURCESHAREHANDLENVPROC __wglewDXSetResourceShareHandleNV; +WGLEW_EXPORT PFNWGLDXUNLOCKOBJECTSNVPROC __wglewDXUnlockObjectsNV; +WGLEW_EXPORT PFNWGLDXUNREGISTEROBJECTNVPROC __wglewDXUnregisterObjectNV; + +WGLEW_EXPORT PFNWGLCOPYIMAGESUBDATANVPROC __wglewCopyImageSubDataNV; + +WGLEW_EXPORT PFNWGLCREATEAFFINITYDCNVPROC __wglewCreateAffinityDCNV; +WGLEW_EXPORT PFNWGLDELETEDCNVPROC __wglewDeleteDCNV; +WGLEW_EXPORT PFNWGLENUMGPUDEVICESNVPROC __wglewEnumGpuDevicesNV; +WGLEW_EXPORT PFNWGLENUMGPUSFROMAFFINITYDCNVPROC __wglewEnumGpusFromAffinityDCNV; +WGLEW_EXPORT PFNWGLENUMGPUSNVPROC __wglewEnumGpusNV; + +WGLEW_EXPORT PFNWGLBINDVIDEODEVICENVPROC __wglewBindVideoDeviceNV; +WGLEW_EXPORT PFNWGLENUMERATEVIDEODEVICESNVPROC __wglewEnumerateVideoDevicesNV; +WGLEW_EXPORT PFNWGLQUERYCURRENTCONTEXTNVPROC __wglewQueryCurrentContextNV; + +WGLEW_EXPORT PFNWGLBINDSWAPBARRIERNVPROC __wglewBindSwapBarrierNV; +WGLEW_EXPORT PFNWGLJOINSWAPGROUPNVPROC __wglewJoinSwapGroupNV; +WGLEW_EXPORT PFNWGLQUERYFRAMECOUNTNVPROC __wglewQueryFrameCountNV; +WGLEW_EXPORT PFNWGLQUERYMAXSWAPGROUPSNVPROC __wglewQueryMaxSwapGroupsNV; +WGLEW_EXPORT PFNWGLQUERYSWAPGROUPNVPROC __wglewQuerySwapGroupNV; +WGLEW_EXPORT PFNWGLRESETFRAMECOUNTNVPROC __wglewResetFrameCountNV; + +WGLEW_EXPORT PFNWGLALLOCATEMEMORYNVPROC __wglewAllocateMemoryNV; +WGLEW_EXPORT PFNWGLFREEMEMORYNVPROC __wglewFreeMemoryNV; + +WGLEW_EXPORT PFNWGLBINDVIDEOCAPTUREDEVICENVPROC __wglewBindVideoCaptureDeviceNV; +WGLEW_EXPORT PFNWGLENUMERATEVIDEOCAPTUREDEVICESNVPROC __wglewEnumerateVideoCaptureDevicesNV; +WGLEW_EXPORT PFNWGLLOCKVIDEOCAPTUREDEVICENVPROC __wglewLockVideoCaptureDeviceNV; +WGLEW_EXPORT PFNWGLQUERYVIDEOCAPTUREDEVICENVPROC __wglewQueryVideoCaptureDeviceNV; +WGLEW_EXPORT PFNWGLRELEASEVIDEOCAPTUREDEVICENVPROC __wglewReleaseVideoCaptureDeviceNV; + +WGLEW_EXPORT PFNWGLBINDVIDEOIMAGENVPROC __wglewBindVideoImageNV; +WGLEW_EXPORT PFNWGLGETVIDEODEVICENVPROC __wglewGetVideoDeviceNV; +WGLEW_EXPORT PFNWGLGETVIDEOINFONVPROC __wglewGetVideoInfoNV; +WGLEW_EXPORT PFNWGLRELEASEVIDEODEVICENVPROC __wglewReleaseVideoDeviceNV; +WGLEW_EXPORT PFNWGLRELEASEVIDEOIMAGENVPROC __wglewReleaseVideoImageNV; +WGLEW_EXPORT PFNWGLSENDPBUFFERTOVIDEONVPROC __wglewSendPbufferToVideoNV; + +WGLEW_EXPORT PFNWGLGETMSCRATEOMLPROC __wglewGetMscRateOML; +WGLEW_EXPORT PFNWGLGETSYNCVALUESOMLPROC __wglewGetSyncValuesOML; +WGLEW_EXPORT PFNWGLSWAPBUFFERSMSCOMLPROC __wglewSwapBuffersMscOML; +WGLEW_EXPORT PFNWGLSWAPLAYERBUFFERSMSCOMLPROC __wglewSwapLayerBuffersMscOML; +WGLEW_EXPORT PFNWGLWAITFORMSCOMLPROC __wglewWaitForMscOML; +WGLEW_EXPORT PFNWGLWAITFORSBCOMLPROC __wglewWaitForSbcOML; +WGLEW_EXPORT GLboolean __WGLEW_3DFX_multisample; +WGLEW_EXPORT GLboolean __WGLEW_3DL_stereo_control; +WGLEW_EXPORT GLboolean __WGLEW_AMD_gpu_association; +WGLEW_EXPORT GLboolean __WGLEW_ARB_buffer_region; +WGLEW_EXPORT GLboolean __WGLEW_ARB_create_context; +WGLEW_EXPORT GLboolean __WGLEW_ARB_create_context_profile; +WGLEW_EXPORT GLboolean __WGLEW_ARB_create_context_robustness; +WGLEW_EXPORT GLboolean __WGLEW_ARB_extensions_string; +WGLEW_EXPORT GLboolean __WGLEW_ARB_framebuffer_sRGB; +WGLEW_EXPORT GLboolean __WGLEW_ARB_make_current_read; +WGLEW_EXPORT GLboolean __WGLEW_ARB_multisample; +WGLEW_EXPORT GLboolean __WGLEW_ARB_pbuffer; +WGLEW_EXPORT GLboolean __WGLEW_ARB_pixel_format; +WGLEW_EXPORT GLboolean __WGLEW_ARB_pixel_format_float; +WGLEW_EXPORT GLboolean __WGLEW_ARB_render_texture; +WGLEW_EXPORT GLboolean __WGLEW_ATI_pixel_format_float; +WGLEW_EXPORT GLboolean __WGLEW_ATI_render_texture_rectangle; +WGLEW_EXPORT GLboolean __WGLEW_EXT_create_context_es2_profile; +WGLEW_EXPORT GLboolean __WGLEW_EXT_depth_float; +WGLEW_EXPORT GLboolean __WGLEW_EXT_display_color_table; +WGLEW_EXPORT GLboolean __WGLEW_EXT_extensions_string; +WGLEW_EXPORT GLboolean __WGLEW_EXT_framebuffer_sRGB; +WGLEW_EXPORT GLboolean __WGLEW_EXT_make_current_read; +WGLEW_EXPORT GLboolean __WGLEW_EXT_multisample; +WGLEW_EXPORT GLboolean __WGLEW_EXT_pbuffer; +WGLEW_EXPORT GLboolean __WGLEW_EXT_pixel_format; +WGLEW_EXPORT GLboolean __WGLEW_EXT_pixel_format_packed_float; +WGLEW_EXPORT GLboolean __WGLEW_EXT_swap_control; +WGLEW_EXPORT GLboolean __WGLEW_I3D_digital_video_control; +WGLEW_EXPORT GLboolean __WGLEW_I3D_gamma; +WGLEW_EXPORT GLboolean __WGLEW_I3D_genlock; +WGLEW_EXPORT GLboolean __WGLEW_I3D_image_buffer; +WGLEW_EXPORT GLboolean __WGLEW_I3D_swap_frame_lock; +WGLEW_EXPORT GLboolean __WGLEW_I3D_swap_frame_usage; +WGLEW_EXPORT GLboolean __WGLEW_NV_DX_interop; +WGLEW_EXPORT GLboolean __WGLEW_NV_copy_image; +WGLEW_EXPORT GLboolean __WGLEW_NV_float_buffer; +WGLEW_EXPORT GLboolean __WGLEW_NV_gpu_affinity; +WGLEW_EXPORT GLboolean __WGLEW_NV_multisample_coverage; +WGLEW_EXPORT GLboolean __WGLEW_NV_present_video; +WGLEW_EXPORT GLboolean __WGLEW_NV_render_depth_texture; +WGLEW_EXPORT GLboolean __WGLEW_NV_render_texture_rectangle; +WGLEW_EXPORT GLboolean __WGLEW_NV_swap_group; +WGLEW_EXPORT GLboolean __WGLEW_NV_vertex_array_range; +WGLEW_EXPORT GLboolean __WGLEW_NV_video_capture; +WGLEW_EXPORT GLboolean __WGLEW_NV_video_output; +WGLEW_EXPORT GLboolean __WGLEW_OML_sync_control; + +#ifdef GLEW_MX +}; /* WGLEWContextStruct */ +#endif /* GLEW_MX */ + +/* ------------------------------------------------------------------------- */ + +#ifdef GLEW_MX + +typedef struct WGLEWContextStruct WGLEWContext; +GLEWAPI GLenum wglewContextInit (WGLEWContext* ctx); +GLEWAPI GLboolean wglewContextIsSupported (const WGLEWContext* ctx, const char* name); + +#define wglewInit() wglewContextInit(wglewGetContext()) +#define wglewIsSupported(x) wglewContextIsSupported(wglewGetContext(), x) + +#define WGLEW_GET_VAR(x) (*(const GLboolean*)&(wglewGetContext()->x)) +#define WGLEW_GET_FUN(x) wglewGetContext()->x + +#else /* GLEW_MX */ + +#define WGLEW_GET_VAR(x) (*(const GLboolean*)&x) +#define WGLEW_GET_FUN(x) x + +GLEWAPI GLboolean wglewIsSupported (const char* name); + +#endif /* GLEW_MX */ + +GLEWAPI GLboolean wglewGetExtension (const char* name); + +#ifdef __cplusplus +} +#endif + +#undef GLEWAPI + +#endif /* __wglew_h__ */ diff --git a/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2.h b/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2.h deleted file mode 100644 index 4040ac6a11..0000000000 --- a/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2.h +++ /dev/null @@ -1,619 +0,0 @@ -#ifndef __gl2_h_ -#define __gl2_h_ - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This document is licensed under the SGI Free Software B License Version - * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . - */ - -/*------------------------------------------------------------------------- - * Data type definitions - *-----------------------------------------------------------------------*/ - -typedef void GLvoid; -typedef char GLchar; -typedef unsigned int GLenum; -typedef unsigned char GLboolean; -typedef unsigned int GLbitfield; -typedef khronos_int8_t GLbyte; -typedef short GLshort; -typedef int GLint; -typedef int GLsizei; -typedef khronos_uint8_t GLubyte; -typedef unsigned short GLushort; -typedef unsigned int GLuint; -typedef khronos_float_t GLfloat; -typedef khronos_float_t GLclampf; -typedef khronos_int32_t GLfixed; - -/* GL types for handling large vertex buffer objects */ -typedef khronos_intptr_t GLintptr; -typedef khronos_ssize_t GLsizeiptr; - -/* OpenGL ES core versions */ -#define GL_ES_VERSION_2_0 1 - -/* ClearBufferMask */ -#define GL_DEPTH_BUFFER_BIT 0x00000100 -#define GL_STENCIL_BUFFER_BIT 0x00000400 -#define GL_COLOR_BUFFER_BIT 0x00004000 - -/* Boolean */ -#define GL_FALSE 0 -#define GL_TRUE 1 - -/* BeginMode */ -#define GL_POINTS 0x0000 -#define GL_LINES 0x0001 -#define GL_LINE_LOOP 0x0002 -#define GL_LINE_STRIP 0x0003 -#define GL_TRIANGLES 0x0004 -#define GL_TRIANGLE_STRIP 0x0005 -#define GL_TRIANGLE_FAN 0x0006 - -/* AlphaFunction (not supported in ES20) */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* BlendingFactorDest */ -#define GL_ZERO 0 -#define GL_ONE 1 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 - -/* BlendingFactorSrc */ -/* GL_ZERO */ -/* GL_ONE */ -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#define GL_SRC_ALPHA_SATURATE 0x0308 -/* GL_SRC_ALPHA */ -/* GL_ONE_MINUS_SRC_ALPHA */ -/* GL_DST_ALPHA */ -/* GL_ONE_MINUS_DST_ALPHA */ - -/* BlendEquationSeparate */ -#define GL_FUNC_ADD 0x8006 -#define GL_BLEND_EQUATION 0x8009 -#define GL_BLEND_EQUATION_RGB 0x8009 /* same as BLEND_EQUATION */ -#define GL_BLEND_EQUATION_ALPHA 0x883D - -/* BlendSubtract */ -#define GL_FUNC_SUBTRACT 0x800A -#define GL_FUNC_REVERSE_SUBTRACT 0x800B - -/* Separate Blend Functions */ -#define GL_BLEND_DST_RGB 0x80C8 -#define GL_BLEND_SRC_RGB 0x80C9 -#define GL_BLEND_DST_ALPHA 0x80CA -#define GL_BLEND_SRC_ALPHA 0x80CB -#define GL_CONSTANT_COLOR 0x8001 -#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002 -#define GL_CONSTANT_ALPHA 0x8003 -#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004 -#define GL_BLEND_COLOR 0x8005 - -/* Buffer Objects */ -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 - -#define GL_STREAM_DRAW 0x88E0 -#define GL_STATIC_DRAW 0x88E4 -#define GL_DYNAMIC_DRAW 0x88E8 - -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 - -#define GL_CURRENT_VERTEX_ATTRIB 0x8626 - -/* CullFaceMode */ -#define GL_FRONT 0x0404 -#define GL_BACK 0x0405 -#define GL_FRONT_AND_BACK 0x0408 - -/* DepthFunction */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* EnableCap */ -#define GL_TEXTURE_2D 0x0DE1 -#define GL_CULL_FACE 0x0B44 -#define GL_BLEND 0x0BE2 -#define GL_DITHER 0x0BD0 -#define GL_STENCIL_TEST 0x0B90 -#define GL_DEPTH_TEST 0x0B71 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_COVERAGE 0x80A0 - -/* ErrorCode */ -#define GL_NO_ERROR 0 -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_OUT_OF_MEMORY 0x0505 - -/* FrontFaceDirection */ -#define GL_CW 0x0900 -#define GL_CCW 0x0901 - -/* GetPName */ -#define GL_LINE_WIDTH 0x0B21 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#define GL_CULL_FACE_MODE 0x0B45 -#define GL_FRONT_FACE 0x0B46 -#define GL_DEPTH_RANGE 0x0B70 -#define GL_DEPTH_WRITEMASK 0x0B72 -#define GL_DEPTH_CLEAR_VALUE 0x0B73 -#define GL_DEPTH_FUNC 0x0B74 -#define GL_STENCIL_CLEAR_VALUE 0x0B91 -#define GL_STENCIL_FUNC 0x0B92 -#define GL_STENCIL_FAIL 0x0B94 -#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#define GL_STENCIL_REF 0x0B97 -#define GL_STENCIL_VALUE_MASK 0x0B93 -#define GL_STENCIL_WRITEMASK 0x0B98 -#define GL_STENCIL_BACK_FUNC 0x8800 -#define GL_STENCIL_BACK_FAIL 0x8801 -#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802 -#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803 -#define GL_STENCIL_BACK_REF 0x8CA3 -#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4 -#define GL_STENCIL_BACK_WRITEMASK 0x8CA5 -#define GL_VIEWPORT 0x0BA2 -#define GL_SCISSOR_BOX 0x0C10 -/* GL_SCISSOR_TEST */ -#define GL_COLOR_CLEAR_VALUE 0x0C22 -#define GL_COLOR_WRITEMASK 0x0C23 -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_ALIGNMENT 0x0D05 -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#define GL_MAX_VIEWPORT_DIMS 0x0D3A -#define GL_SUBPIXEL_BITS 0x0D50 -#define GL_RED_BITS 0x0D52 -#define GL_GREEN_BITS 0x0D53 -#define GL_BLUE_BITS 0x0D54 -#define GL_ALPHA_BITS 0x0D55 -#define GL_DEPTH_BITS 0x0D56 -#define GL_STENCIL_BITS 0x0D57 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -/* GL_POLYGON_OFFSET_FILL */ -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_TEXTURE_BINDING_2D 0x8069 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB - -/* GetTextureParameter */ -/* GL_TEXTURE_MAG_FILTER */ -/* GL_TEXTURE_MIN_FILTER */ -/* GL_TEXTURE_WRAP_S */ -/* GL_TEXTURE_WRAP_T */ - -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 - -/* HintMode */ -#define GL_DONT_CARE 0x1100 -#define GL_FASTEST 0x1101 -#define GL_NICEST 0x1102 - -/* HintTarget */ -#define GL_GENERATE_MIPMAP_HINT 0x8192 - -/* DataType */ -#define GL_BYTE 0x1400 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_SHORT 0x1402 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_INT 0x1404 -#define GL_UNSIGNED_INT 0x1405 -#define GL_FLOAT 0x1406 -#define GL_FIXED 0x140C - -/* PixelFormat */ -#define GL_DEPTH_COMPONENT 0x1902 -#define GL_ALPHA 0x1906 -#define GL_RGB 0x1907 -#define GL_RGBA 0x1908 -#define GL_LUMINANCE 0x1909 -#define GL_LUMINANCE_ALPHA 0x190A - -/* PixelType */ -/* GL_UNSIGNED_BYTE */ -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 - -/* Shaders */ -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 -#define GL_MAX_VERTEX_ATTRIBS 0x8869 -#define GL_MAX_VERTEX_UNIFORM_VECTORS 0x8DFB -#define GL_MAX_VARYING_VECTORS 0x8DFC -#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D -#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C -#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872 -#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD -#define GL_SHADER_TYPE 0x8B4F -#define GL_DELETE_STATUS 0x8B80 -#define GL_LINK_STATUS 0x8B82 -#define GL_VALIDATE_STATUS 0x8B83 -#define GL_ATTACHED_SHADERS 0x8B85 -#define GL_ACTIVE_UNIFORMS 0x8B86 -#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87 -#define GL_ACTIVE_ATTRIBUTES 0x8B89 -#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A -#define GL_SHADING_LANGUAGE_VERSION 0x8B8C -#define GL_CURRENT_PROGRAM 0x8B8D - -/* StencilFunction */ -#define GL_NEVER 0x0200 -#define GL_LESS 0x0201 -#define GL_EQUAL 0x0202 -#define GL_LEQUAL 0x0203 -#define GL_GREATER 0x0204 -#define GL_NOTEQUAL 0x0205 -#define GL_GEQUAL 0x0206 -#define GL_ALWAYS 0x0207 - -/* StencilOp */ -/* GL_ZERO */ -#define GL_KEEP 0x1E00 -#define GL_REPLACE 0x1E01 -#define GL_INCR 0x1E02 -#define GL_DECR 0x1E03 -#define GL_INVERT 0x150A -#define GL_INCR_WRAP 0x8507 -#define GL_DECR_WRAP 0x8508 - -/* StringName */ -#define GL_VENDOR 0x1F00 -#define GL_RENDERER 0x1F01 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 - -/* TextureMagFilter */ -#define GL_NEAREST 0x2600 -#define GL_LINEAR 0x2601 - -/* TextureMinFilter */ -/* GL_NEAREST */ -/* GL_LINEAR */ -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 - -/* TextureParameterName */ -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_TEXTURE_WRAP_S 0x2802 -#define GL_TEXTURE_WRAP_T 0x2803 - -/* TextureTarget */ -/* GL_TEXTURE_2D */ -#define GL_TEXTURE 0x1702 - -#define GL_TEXTURE_CUBE_MAP 0x8513 -#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518 -#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519 -#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A -#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C - -/* TextureUnit */ -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 - -/* TextureWrapMode */ -#define GL_REPEAT 0x2901 -#define GL_CLAMP_TO_EDGE 0x812F -#define GL_MIRRORED_REPEAT 0x8370 - -/* Uniform Types */ -#define GL_FLOAT_VEC2 0x8B50 -#define GL_FLOAT_VEC3 0x8B51 -#define GL_FLOAT_VEC4 0x8B52 -#define GL_INT_VEC2 0x8B53 -#define GL_INT_VEC3 0x8B54 -#define GL_INT_VEC4 0x8B55 -#define GL_BOOL 0x8B56 -#define GL_BOOL_VEC2 0x8B57 -#define GL_BOOL_VEC3 0x8B58 -#define GL_BOOL_VEC4 0x8B59 -#define GL_FLOAT_MAT2 0x8B5A -#define GL_FLOAT_MAT3 0x8B5B -#define GL_FLOAT_MAT4 0x8B5C -#define GL_SAMPLER_2D 0x8B5E -#define GL_SAMPLER_CUBE 0x8B60 - -/* Vertex Arrays */ -#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622 -#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623 -#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624 -#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625 -#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A -#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645 -#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F - -/* Read Format */ -#define GL_IMPLEMENTATION_COLOR_READ_TYPE 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT 0x8B9B - -/* Shader Source */ -#define GL_COMPILE_STATUS 0x8B81 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_SHADER_SOURCE_LENGTH 0x8B88 -#define GL_SHADER_COMPILER 0x8DFA - -/* Shader Binary */ -#define GL_SHADER_BINARY_FORMATS 0x8DF8 -#define GL_NUM_SHADER_BINARY_FORMATS 0x8DF9 - -/* Shader Precision-Specified Types */ -#define GL_LOW_FLOAT 0x8DF0 -#define GL_MEDIUM_FLOAT 0x8DF1 -#define GL_HIGH_FLOAT 0x8DF2 -#define GL_LOW_INT 0x8DF3 -#define GL_MEDIUM_INT 0x8DF4 -#define GL_HIGH_INT 0x8DF5 - -/* Framebuffer Object. */ -#define GL_FRAMEBUFFER 0x8D40 -#define GL_RENDERBUFFER 0x8D41 - -#define GL_RGBA4 0x8056 -#define GL_RGB5_A1 0x8057 -#define GL_RGB565 0x8D62 -#define GL_DEPTH_COMPONENT16 0x81A5 -#define GL_STENCIL_INDEX 0x1901 -#define GL_STENCIL_INDEX8 0x8D48 - -#define GL_RENDERBUFFER_WIDTH 0x8D42 -#define GL_RENDERBUFFER_HEIGHT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44 -#define GL_RENDERBUFFER_RED_SIZE 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55 - -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3 - -#define GL_COLOR_ATTACHMENT0 0x8CE0 -#define GL_DEPTH_ATTACHMENT 0x8D00 -#define GL_STENCIL_ATTACHMENT 0x8D20 - -#define GL_NONE 0 - -#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS 0x8CD9 -#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD - -#define GL_FRAMEBUFFER_BINDING 0x8CA6 -#define GL_RENDERBUFFER_BINDING 0x8CA7 -#define GL_MAX_RENDERBUFFER_SIZE 0x84E8 - -#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506 - -/*------------------------------------------------------------------------- - * GL core functions. - *-----------------------------------------------------------------------*/ - -GL_APICALL void GL_APIENTRY glActiveTexture (GLenum texture); -GL_APICALL void GL_APIENTRY glAttachShader (GLuint program, GLuint shader); -GL_APICALL void GL_APIENTRY glBindAttribLocation (GLuint program, GLuint index, const GLchar* name); -GL_APICALL void GL_APIENTRY glBindBuffer (GLenum target, GLuint buffer); -GL_APICALL void GL_APIENTRY glBindFramebuffer (GLenum target, GLuint framebuffer); -GL_APICALL void GL_APIENTRY glBindRenderbuffer (GLenum target, GLuint renderbuffer); -GL_APICALL void GL_APIENTRY glBindTexture (GLenum target, GLuint texture); -GL_APICALL void GL_APIENTRY glBlendColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -GL_APICALL void GL_APIENTRY glBlendEquation ( GLenum mode ); -GL_APICALL void GL_APIENTRY glBlendEquationSeparate (GLenum modeRGB, GLenum modeAlpha); -GL_APICALL void GL_APIENTRY glBlendFunc (GLenum sfactor, GLenum dfactor); -GL_APICALL void GL_APIENTRY glBlendFuncSeparate (GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, GLenum dstAlpha); -GL_APICALL void GL_APIENTRY glBufferData (GLenum target, GLsizeiptr size, const GLvoid* data, GLenum usage); -GL_APICALL void GL_APIENTRY glBufferSubData (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid* data); -GL_APICALL GLenum GL_APIENTRY glCheckFramebufferStatus (GLenum target); -GL_APICALL void GL_APIENTRY glClear (GLbitfield mask); -GL_APICALL void GL_APIENTRY glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -GL_APICALL void GL_APIENTRY glClearDepthf (GLclampf depth); -GL_APICALL void GL_APIENTRY glClearStencil (GLint s); -GL_APICALL void GL_APIENTRY glColorMask (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -GL_APICALL void GL_APIENTRY glCompileShader (GLuint shader); -GL_APICALL void GL_APIENTRY glCompressedTexImage2D (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid* data); -GL_APICALL void GL_APIENTRY glCompressedTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid* data); -GL_APICALL void GL_APIENTRY glCopyTexImage2D (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border); -GL_APICALL void GL_APIENTRY glCopyTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GL_APICALL GLuint GL_APIENTRY glCreateProgram (void); -GL_APICALL GLuint GL_APIENTRY glCreateShader (GLenum type); -GL_APICALL void GL_APIENTRY glCullFace (GLenum mode); -GL_APICALL void GL_APIENTRY glDeleteBuffers (GLsizei n, const GLuint* buffers); -GL_APICALL void GL_APIENTRY glDeleteFramebuffers (GLsizei n, const GLuint* framebuffers); -GL_APICALL void GL_APIENTRY glDeleteProgram (GLuint program); -GL_APICALL void GL_APIENTRY glDeleteRenderbuffers (GLsizei n, const GLuint* renderbuffers); -GL_APICALL void GL_APIENTRY glDeleteShader (GLuint shader); -GL_APICALL void GL_APIENTRY glDeleteTextures (GLsizei n, const GLuint* textures); -GL_APICALL void GL_APIENTRY glDepthFunc (GLenum func); -GL_APICALL void GL_APIENTRY glDepthMask (GLboolean flag); -GL_APICALL void GL_APIENTRY glDepthRangef (GLclampf zNear, GLclampf zFar); -GL_APICALL void GL_APIENTRY glDetachShader (GLuint program, GLuint shader); -GL_APICALL void GL_APIENTRY glDisable (GLenum cap); -GL_APICALL void GL_APIENTRY glDisableVertexAttribArray (GLuint index); -GL_APICALL void GL_APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count); -GL_APICALL void GL_APIENTRY glDrawElements (GLenum mode, GLsizei count, GLenum type, const GLvoid* indices); -GL_APICALL void GL_APIENTRY glEnable (GLenum cap); -GL_APICALL void GL_APIENTRY glEnableVertexAttribArray (GLuint index); -GL_APICALL void GL_APIENTRY glFinish (void); -GL_APICALL void GL_APIENTRY glFlush (void); -GL_APICALL void GL_APIENTRY glFramebufferRenderbuffer (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -GL_APICALL void GL_APIENTRY glFramebufferTexture2D (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -GL_APICALL void GL_APIENTRY glFrontFace (GLenum mode); -GL_APICALL void GL_APIENTRY glGenBuffers (GLsizei n, GLuint* buffers); -GL_APICALL void GL_APIENTRY glGenerateMipmap (GLenum target); -GL_APICALL void GL_APIENTRY glGenFramebuffers (GLsizei n, GLuint* framebuffers); -GL_APICALL void GL_APIENTRY glGenRenderbuffers (GLsizei n, GLuint* renderbuffers); -GL_APICALL void GL_APIENTRY glGenTextures (GLsizei n, GLuint* textures); -GL_APICALL void GL_APIENTRY glGetActiveAttrib (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); -GL_APICALL void GL_APIENTRY glGetActiveUniform (GLuint program, GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, GLchar* name); -GL_APICALL void GL_APIENTRY glGetAttachedShaders (GLuint program, GLsizei maxcount, GLsizei* count, GLuint* shaders); -GL_APICALL int GL_APIENTRY glGetAttribLocation (GLuint program, const GLchar* name); -GL_APICALL void GL_APIENTRY glGetBooleanv (GLenum pname, GLboolean* params); -GL_APICALL void GL_APIENTRY glGetBufferParameteriv (GLenum target, GLenum pname, GLint* params); -GL_APICALL GLenum GL_APIENTRY glGetError (void); -GL_APICALL void GL_APIENTRY glGetFloatv (GLenum pname, GLfloat* params); -GL_APICALL void GL_APIENTRY glGetFramebufferAttachmentParameteriv (GLenum target, GLenum attachment, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetIntegerv (GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetProgramiv (GLuint program, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetProgramInfoLog (GLuint program, GLsizei bufsize, GLsizei* length, GLchar* infolog); -GL_APICALL void GL_APIENTRY glGetRenderbufferParameteriv (GLenum target, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetShaderiv (GLuint shader, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetShaderInfoLog (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* infolog); -GL_APICALL void GL_APIENTRY glGetShaderPrecisionFormat (GLenum shadertype, GLenum precisiontype, GLint* range, GLint* precision); -GL_APICALL void GL_APIENTRY glGetShaderSource (GLuint shader, GLsizei bufsize, GLsizei* length, GLchar* source); -GL_APICALL const GLubyte* GL_APIENTRY glGetString (GLenum name); -GL_APICALL void GL_APIENTRY glGetTexParameterfv (GLenum target, GLenum pname, GLfloat* params); -GL_APICALL void GL_APIENTRY glGetTexParameteriv (GLenum target, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetUniformfv (GLuint program, GLint location, GLfloat* params); -GL_APICALL void GL_APIENTRY glGetUniformiv (GLuint program, GLint location, GLint* params); -GL_APICALL int GL_APIENTRY glGetUniformLocation (GLuint program, const GLchar* name); -GL_APICALL void GL_APIENTRY glGetVertexAttribfv (GLuint index, GLenum pname, GLfloat* params); -GL_APICALL void GL_APIENTRY glGetVertexAttribiv (GLuint index, GLenum pname, GLint* params); -GL_APICALL void GL_APIENTRY glGetVertexAttribPointerv (GLuint index, GLenum pname, GLvoid** pointer); -GL_APICALL void GL_APIENTRY glHint (GLenum target, GLenum mode); -GL_APICALL GLboolean GL_APIENTRY glIsBuffer (GLuint buffer); -GL_APICALL GLboolean GL_APIENTRY glIsEnabled (GLenum cap); -GL_APICALL GLboolean GL_APIENTRY glIsFramebuffer (GLuint framebuffer); -GL_APICALL GLboolean GL_APIENTRY glIsProgram (GLuint program); -GL_APICALL GLboolean GL_APIENTRY glIsRenderbuffer (GLuint renderbuffer); -GL_APICALL GLboolean GL_APIENTRY glIsShader (GLuint shader); -GL_APICALL GLboolean GL_APIENTRY glIsTexture (GLuint texture); -GL_APICALL void GL_APIENTRY glLineWidth (GLfloat width); -GL_APICALL void GL_APIENTRY glLinkProgram (GLuint program); -GL_APICALL void GL_APIENTRY glPixelStorei (GLenum pname, GLint param); -GL_APICALL void GL_APIENTRY glPolygonOffset (GLfloat factor, GLfloat units); -GL_APICALL void GL_APIENTRY glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels); -GL_APICALL void GL_APIENTRY glReleaseShaderCompiler (void); -GL_APICALL void GL_APIENTRY glRenderbufferStorage (GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -GL_APICALL void GL_APIENTRY glSampleCoverage (GLclampf value, GLboolean invert); -GL_APICALL void GL_APIENTRY glScissor (GLint x, GLint y, GLsizei width, GLsizei height); -GL_APICALL void GL_APIENTRY glShaderBinary (GLsizei n, const GLuint* shaders, GLenum binaryformat, const GLvoid* binary, GLsizei length); -GL_APICALL void GL_APIENTRY glShaderSource (GLuint shader, GLsizei count, const GLchar** string, const GLint* length); -GL_APICALL void GL_APIENTRY glStencilFunc (GLenum func, GLint ref, GLuint mask); -GL_APICALL void GL_APIENTRY glStencilFuncSeparate (GLenum face, GLenum func, GLint ref, GLuint mask); -GL_APICALL void GL_APIENTRY glStencilMask (GLuint mask); -GL_APICALL void GL_APIENTRY glStencilMaskSeparate (GLenum face, GLuint mask); -GL_APICALL void GL_APIENTRY glStencilOp (GLenum fail, GLenum zfail, GLenum zpass); -GL_APICALL void GL_APIENTRY glStencilOpSeparate (GLenum face, GLenum fail, GLenum zfail, GLenum zpass); -GL_APICALL void GL_APIENTRY glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid* pixels); -GL_APICALL void GL_APIENTRY glTexParameterf (GLenum target, GLenum pname, GLfloat param); -GL_APICALL void GL_APIENTRY glTexParameterfv (GLenum target, GLenum pname, const GLfloat* params); -GL_APICALL void GL_APIENTRY glTexParameteri (GLenum target, GLenum pname, GLint param); -GL_APICALL void GL_APIENTRY glTexParameteriv (GLenum target, GLenum pname, const GLint* params); -GL_APICALL void GL_APIENTRY glTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid* pixels); -GL_APICALL void GL_APIENTRY glUniform1f (GLint location, GLfloat x); -GL_APICALL void GL_APIENTRY glUniform1fv (GLint location, GLsizei count, const GLfloat* v); -GL_APICALL void GL_APIENTRY glUniform1i (GLint location, GLint x); -GL_APICALL void GL_APIENTRY glUniform1iv (GLint location, GLsizei count, const GLint* v); -GL_APICALL void GL_APIENTRY glUniform2f (GLint location, GLfloat x, GLfloat y); -GL_APICALL void GL_APIENTRY glUniform2fv (GLint location, GLsizei count, const GLfloat* v); -GL_APICALL void GL_APIENTRY glUniform2i (GLint location, GLint x, GLint y); -GL_APICALL void GL_APIENTRY glUniform2iv (GLint location, GLsizei count, const GLint* v); -GL_APICALL void GL_APIENTRY glUniform3f (GLint location, GLfloat x, GLfloat y, GLfloat z); -GL_APICALL void GL_APIENTRY glUniform3fv (GLint location, GLsizei count, const GLfloat* v); -GL_APICALL void GL_APIENTRY glUniform3i (GLint location, GLint x, GLint y, GLint z); -GL_APICALL void GL_APIENTRY glUniform3iv (GLint location, GLsizei count, const GLint* v); -GL_APICALL void GL_APIENTRY glUniform4f (GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GL_APICALL void GL_APIENTRY glUniform4fv (GLint location, GLsizei count, const GLfloat* v); -GL_APICALL void GL_APIENTRY glUniform4i (GLint location, GLint x, GLint y, GLint z, GLint w); -GL_APICALL void GL_APIENTRY glUniform4iv (GLint location, GLsizei count, const GLint* v); -GL_APICALL void GL_APIENTRY glUniformMatrix2fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix3fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -GL_APICALL void GL_APIENTRY glUniformMatrix4fv (GLint location, GLsizei count, GLboolean transpose, const GLfloat* value); -GL_APICALL void GL_APIENTRY glUseProgram (GLuint program); -GL_APICALL void GL_APIENTRY glValidateProgram (GLuint program); -GL_APICALL void GL_APIENTRY glVertexAttrib1f (GLuint indx, GLfloat x); -GL_APICALL void GL_APIENTRY glVertexAttrib1fv (GLuint indx, const GLfloat* values); -GL_APICALL void GL_APIENTRY glVertexAttrib2f (GLuint indx, GLfloat x, GLfloat y); -GL_APICALL void GL_APIENTRY glVertexAttrib2fv (GLuint indx, const GLfloat* values); -GL_APICALL void GL_APIENTRY glVertexAttrib3f (GLuint indx, GLfloat x, GLfloat y, GLfloat z); -GL_APICALL void GL_APIENTRY glVertexAttrib3fv (GLuint indx, const GLfloat* values); -GL_APICALL void GL_APIENTRY glVertexAttrib4f (GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w); -GL_APICALL void GL_APIENTRY glVertexAttrib4fv (GLuint indx, const GLfloat* values); -GL_APICALL void GL_APIENTRY glVertexAttribPointer (GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr); -GL_APICALL void GL_APIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei height); - -#ifdef __cplusplus -} -#endif - -#endif /* __gl2_h_ */ diff --git a/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2ext.h b/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2ext.h deleted file mode 100644 index 9eeddcfc97..0000000000 --- a/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2ext.h +++ /dev/null @@ -1,971 +0,0 @@ -#ifndef __gl2ext_h_ -#define __gl2ext_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * This document is licensed under the SGI Free Software B License Version - * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . - */ - -#ifndef GL_APIENTRYP -# define GL_APIENTRYP GL_APIENTRY* -#endif - -/*------------------------------------------------------------------------* - * OES extension tokens - *------------------------------------------------------------------------*/ - -/* GL_OES_compressed_ETC1_RGB8_texture */ -#ifndef GL_OES_compressed_ETC1_RGB8_texture -#define GL_ETC1_RGB8_OES 0x8D64 -#endif - -/* GL_OES_compressed_paletted_texture */ -#ifndef GL_OES_compressed_paletted_texture -#define GL_PALETTE4_RGB8_OES 0x8B90 -#define GL_PALETTE4_RGBA8_OES 0x8B91 -#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 -#define GL_PALETTE4_RGBA4_OES 0x8B93 -#define GL_PALETTE4_RGB5_A1_OES 0x8B94 -#define GL_PALETTE8_RGB8_OES 0x8B95 -#define GL_PALETTE8_RGBA8_OES 0x8B96 -#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 -#define GL_PALETTE8_RGBA4_OES 0x8B98 -#define GL_PALETTE8_RGB5_A1_OES 0x8B99 -#endif - -/* GL_OES_depth24 */ -#ifndef GL_OES_depth24 -#define GL_DEPTH_COMPONENT24_OES 0x81A6 -#endif - -/* GL_OES_depth32 */ -#ifndef GL_OES_depth32 -#define GL_DEPTH_COMPONENT32_OES 0x81A7 -#endif - -/* GL_OES_depth_texture */ -/* No new tokens introduced by this extension. */ - -/* GL_OES_EGL_image */ -#ifndef GL_OES_EGL_image -typedef void* GLeglImageOES; -#endif - -/* GL_OES_EGL_image_external */ -#ifndef GL_OES_EGL_image_external -/* GLeglImageOES defined in GL_OES_EGL_image already. */ -#define GL_TEXTURE_EXTERNAL_OES 0x8D65 -#define GL_SAMPLER_EXTERNAL_OES 0x8D66 -#define GL_TEXTURE_BINDING_EXTERNAL_OES 0x8D67 -#define GL_REQUIRED_TEXTURE_IMAGE_UNITS_OES 0x8D68 -#endif - -/* GL_OES_element_index_uint */ -#ifndef GL_OES_element_index_uint -#define GL_UNSIGNED_INT 0x1405 -#endif - -/* GL_OES_get_program_binary */ -#ifndef GL_OES_get_program_binary -#define GL_PROGRAM_BINARY_LENGTH_OES 0x8741 -#define GL_NUM_PROGRAM_BINARY_FORMATS_OES 0x87FE -#define GL_PROGRAM_BINARY_FORMATS_OES 0x87FF -#endif - -/* GL_OES_mapbuffer */ -#ifndef GL_OES_mapbuffer -#define GL_WRITE_ONLY_OES 0x88B9 -#define GL_BUFFER_ACCESS_OES 0x88BB -#define GL_BUFFER_MAPPED_OES 0x88BC -#define GL_BUFFER_MAP_POINTER_OES 0x88BD -#endif - -/* GL_OES_packed_depth_stencil */ -#ifndef GL_OES_packed_depth_stencil -#define GL_DEPTH_STENCIL_OES 0x84F9 -#define GL_UNSIGNED_INT_24_8_OES 0x84FA -#define GL_DEPTH24_STENCIL8_OES 0x88F0 -#endif - -/* GL_OES_rgb8_rgba8 */ -#ifndef GL_OES_rgb8_rgba8 -#define GL_RGB8_OES 0x8051 -#define GL_RGBA8_OES 0x8058 -#endif - -/* GL_OES_standard_derivatives */ -#ifndef GL_OES_standard_derivatives -#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_OES 0x8B8B -#endif - -/* GL_OES_stencil1 */ -#ifndef GL_OES_stencil1 -#define GL_STENCIL_INDEX1_OES 0x8D46 -#endif - -/* GL_OES_stencil4 */ -#ifndef GL_OES_stencil4 -#define GL_STENCIL_INDEX4_OES 0x8D47 -#endif - -/* GL_OES_texture_3D */ -#ifndef GL_OES_texture_3D -#define GL_TEXTURE_WRAP_R_OES 0x8072 -#define GL_TEXTURE_3D_OES 0x806F -#define GL_TEXTURE_BINDING_3D_OES 0x806A -#define GL_MAX_3D_TEXTURE_SIZE_OES 0x8073 -#define GL_SAMPLER_3D_OES 0x8B5F -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_OES 0x8CD4 -#endif - -/* GL_OES_texture_float */ -/* No new tokens introduced by this extension. */ - -/* GL_OES_texture_float_linear */ -/* No new tokens introduced by this extension. */ - -/* GL_OES_texture_half_float */ -#ifndef GL_OES_texture_half_float -#define GL_HALF_FLOAT_OES 0x8D61 -#endif - -/* GL_OES_texture_half_float_linear */ -/* No new tokens introduced by this extension. */ - -/* GL_OES_texture_npot */ -/* No new tokens introduced by this extension. */ - -/* GL_OES_vertex_array_object */ -#ifndef GL_OES_vertex_array_object -#define GL_VERTEX_ARRAY_BINDING_OES 0x85B5 -#endif - -/* GL_OES_vertex_half_float */ -/* GL_HALF_FLOAT_OES defined in GL_OES_texture_half_float already. */ - -/* GL_OES_vertex_type_10_10_10_2 */ -#ifndef GL_OES_vertex_type_10_10_10_2 -#define GL_UNSIGNED_INT_10_10_10_2_OES 0x8DF6 -#define GL_INT_10_10_10_2_OES 0x8DF7 -#endif - -/*------------------------------------------------------------------------* - * AMD extension tokens - *------------------------------------------------------------------------*/ - -/* GL_AMD_compressed_3DC_texture */ -#ifndef GL_AMD_compressed_3DC_texture -#define GL_3DC_X_AMD 0x87F9 -#define GL_3DC_XY_AMD 0x87FA -#endif - -/* GL_AMD_compressed_ATC_texture */ -#ifndef GL_AMD_compressed_ATC_texture -#define GL_ATC_RGB_AMD 0x8C92 -#define GL_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 -#define GL_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE -#endif - -/* GL_AMD_performance_monitor */ -#ifndef GL_AMD_performance_monitor -#define GL_COUNTER_TYPE_AMD 0x8BC0 -#define GL_COUNTER_RANGE_AMD 0x8BC1 -#define GL_UNSIGNED_INT64_AMD 0x8BC2 -#define GL_PERCENTAGE_AMD 0x8BC3 -#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4 -#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5 -#define GL_PERFMON_RESULT_AMD 0x8BC6 -#endif - -/* GL_AMD_program_binary_Z400 */ -#ifndef GL_AMD_program_binary_Z400 -#define GL_Z400_BINARY_AMD 0x8740 -#endif - -/*------------------------------------------------------------------------* - * ANGLE extension tokens - *------------------------------------------------------------------------*/ - -/* GL_ANGLE_framebuffer_blit */ -#ifndef GL_ANGLE_framebuffer_blit -#define GL_READ_FRAMEBUFFER_ANGLE 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_ANGLE 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_ANGLE 0x8CA6 -#define GL_READ_FRAMEBUFFER_BINDING_ANGLE 0x8CAA -#endif - -/* GL_ANGLE_framebuffer_multisample */ -#ifndef GL_ANGLE_framebuffer_multisample -#define GL_RENDERBUFFER_SAMPLES_ANGLE 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_ANGLE 0x8D56 -#define GL_MAX_SAMPLES_ANGLE 0x8D57 -#endif - -/*------------------------------------------------------------------------* - * APPLE extension tokens - *------------------------------------------------------------------------*/ - -/* GL_APPLE_rgb_422 */ -#ifndef GL_APPLE_rgb_422 -#define GL_RGB_422_APPLE 0x8A1F -#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA -#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB -#endif - -/* GL_APPLE_framebuffer_multisample */ -#ifndef GL_APPLE_framebuffer_multisample -#define GL_RENDERBUFFER_SAMPLES_APPLE 0x8CAB -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_APPLE 0x8D56 -#define GL_MAX_SAMPLES_APPLE 0x8D57 -#define GL_READ_FRAMEBUFFER_APPLE 0x8CA8 -#define GL_DRAW_FRAMEBUFFER_APPLE 0x8CA9 -#define GL_DRAW_FRAMEBUFFER_BINDING_APPLE 0x8CA6 -#define GL_READ_FRAMEBUFFER_BINDING_APPLE 0x8CAA -#endif - -/* GL_APPLE_texture_format_BGRA8888 */ -#ifndef GL_APPLE_texture_format_BGRA8888 -#define GL_BGRA_EXT 0x80E1 -#endif - -/* GL_APPLE_texture_max_level */ -#ifndef GL_APPLE_texture_max_level -#define GL_TEXTURE_MAX_LEVEL_APPLE 0x813D -#endif - -/*------------------------------------------------------------------------* - * ARM extension tokens - *------------------------------------------------------------------------*/ - -/* GL_ARM_mali_shader_binary */ -#ifndef GL_ARM_mali_shader_binary -#define GL_MALI_SHADER_BINARY_ARM 0x8F60 -#endif - -/* GL_ARM_rgba8 */ -/* No new tokens introduced by this extension. */ - -/*------------------------------------------------------------------------* - * EXT extension tokens - *------------------------------------------------------------------------*/ - -/* GL_EXT_blend_minmax */ -#ifndef GL_EXT_blend_minmax -#define GL_MIN_EXT 0x8007 -#define GL_MAX_EXT 0x8008 -#endif - -/* GL_EXT_discard_framebuffer */ -#ifndef GL_EXT_discard_framebuffer -#define GL_COLOR_EXT 0x1800 -#define GL_DEPTH_EXT 0x1801 -#define GL_STENCIL_EXT 0x1802 -#endif - -/* GL_EXT_multi_draw_arrays */ -/* No new tokens introduced by this extension. */ - -/* GL_EXT_read_format_bgra */ -#ifndef GL_EXT_read_format_bgra -#define GL_BGRA_EXT 0x80E1 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV_EXT 0x8365 -#define GL_UNSIGNED_SHORT_1_5_5_5_REV_EXT 0x8366 -#endif - -/* GL_EXT_texture_filter_anisotropic */ -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE -#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF -#endif - -/* GL_EXT_texture_format_BGRA8888 */ -#ifndef GL_EXT_texture_format_BGRA8888 -#define GL_BGRA_EXT 0x80E1 -#endif - -/* GL_EXT_texture_type_2_10_10_10_REV */ -#ifndef GL_EXT_texture_type_2_10_10_10_REV -#define GL_UNSIGNED_INT_2_10_10_10_REV_EXT 0x8368 -#endif - -/* GL_EXT_texture_compression_dxt1 */ -#ifndef GL_EXT_texture_compression_dxt1 -#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0 -#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1 -#endif - -/* GL_EXT_shader_texture_lod */ -/* No new tokens introduced by this extension. */ - -/*------------------------------------------------------------------------* - * IMG extension tokens - *------------------------------------------------------------------------*/ - -/* GL_IMG_program_binary */ -#ifndef GL_IMG_program_binary -#define GL_SGX_PROGRAM_BINARY_IMG 0x9130 -#endif - -/* GL_IMG_read_format */ -#ifndef GL_IMG_read_format -#define GL_BGRA_IMG 0x80E1 -#define GL_UNSIGNED_SHORT_4_4_4_4_REV_IMG 0x8365 -#endif - -/* GL_IMG_shader_binary */ -#ifndef GL_IMG_shader_binary -#define GL_SGX_BINARY_IMG 0x8C0A -#endif - -/* GL_IMG_texture_compression_pvrtc */ -#ifndef GL_IMG_texture_compression_pvrtc -#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 -#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 -#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 -#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 -#endif - -/* GL_IMG_multisampled_render_to_texture */ -#ifndef GL_IMG_multisampled_render_to_texture -#define GL_RENDERBUFFER_SAMPLES_IMG 0x9133 -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG 0x9134 -#define GL_MAX_SAMPLES_IMG 0x9135 -#define GL_TEXTURE_SAMPLES_IMG 0x9136 -#endif - -/*------------------------------------------------------------------------* - * NV extension tokens - *------------------------------------------------------------------------*/ - -/* GL_NV_fence */ -#ifndef GL_NV_fence -#define GL_ALL_COMPLETED_NV 0x84F2 -#define GL_FENCE_STATUS_NV 0x84F3 -#define GL_FENCE_CONDITION_NV 0x84F4 -#endif - -/* GL_NV_coverage_sample */ -#ifndef GL_NV_coverage_sample -#define GL_COVERAGE_COMPONENT_NV 0x8ED0 -#define GL_COVERAGE_COMPONENT4_NV 0x8ED1 -#define GL_COVERAGE_ATTACHMENT_NV 0x8ED2 -#define GL_COVERAGE_BUFFERS_NV 0x8ED3 -#define GL_COVERAGE_SAMPLES_NV 0x8ED4 -#define GL_COVERAGE_ALL_FRAGMENTS_NV 0x8ED5 -#define GL_COVERAGE_EDGE_FRAGMENTS_NV 0x8ED6 -#define GL_COVERAGE_AUTOMATIC_NV 0x8ED7 -#define GL_COVERAGE_BUFFER_BIT_NV 0x8000 -#endif - -/* GL_NV_depth_nonlinear */ -#ifndef GL_NV_depth_nonlinear -#define GL_DEPTH_COMPONENT16_NONLINEAR_NV 0x8E2C -#endif - -/*------------------------------------------------------------------------* - * QCOM extension tokens - *------------------------------------------------------------------------*/ - -/* GL_QCOM_driver_control */ -/* No new tokens introduced by this extension. */ - -/* GL_QCOM_extended_get */ -#ifndef GL_QCOM_extended_get -#define GL_TEXTURE_WIDTH_QCOM 0x8BD2 -#define GL_TEXTURE_HEIGHT_QCOM 0x8BD3 -#define GL_TEXTURE_DEPTH_QCOM 0x8BD4 -#define GL_TEXTURE_INTERNAL_FORMAT_QCOM 0x8BD5 -#define GL_TEXTURE_FORMAT_QCOM 0x8BD6 -#define GL_TEXTURE_TYPE_QCOM 0x8BD7 -#define GL_TEXTURE_IMAGE_VALID_QCOM 0x8BD8 -#define GL_TEXTURE_NUM_LEVELS_QCOM 0x8BD9 -#define GL_TEXTURE_TARGET_QCOM 0x8BDA -#define GL_TEXTURE_OBJECT_VALID_QCOM 0x8BDB -#define GL_STATE_RESTORE 0x8BDC -#endif - -/* GL_QCOM_extended_get2 */ -/* No new tokens introduced by this extension. */ - -/* GL_QCOM_perfmon_global_mode */ -#ifndef GL_QCOM_perfmon_global_mode -#define GL_PERFMON_GLOBAL_MODE_QCOM 0x8FA0 -#endif - -/* GL_QCOM_writeonly_rendering */ -#ifndef GL_QCOM_writeonly_rendering -#define GL_WRITEONLY_RENDERING_QCOM 0x8823 -#endif - -/* GL_QCOM_tiled_rendering */ -#ifndef GL_QCOM_tiled_rendering -#define GL_COLOR_BUFFER_BIT0_QCOM 0x00000001 -#define GL_COLOR_BUFFER_BIT1_QCOM 0x00000002 -#define GL_COLOR_BUFFER_BIT2_QCOM 0x00000004 -#define GL_COLOR_BUFFER_BIT3_QCOM 0x00000008 -#define GL_COLOR_BUFFER_BIT4_QCOM 0x00000010 -#define GL_COLOR_BUFFER_BIT5_QCOM 0x00000020 -#define GL_COLOR_BUFFER_BIT6_QCOM 0x00000040 -#define GL_COLOR_BUFFER_BIT7_QCOM 0x00000080 -#define GL_DEPTH_BUFFER_BIT0_QCOM 0x00000100 -#define GL_DEPTH_BUFFER_BIT1_QCOM 0x00000200 -#define GL_DEPTH_BUFFER_BIT2_QCOM 0x00000400 -#define GL_DEPTH_BUFFER_BIT3_QCOM 0x00000800 -#define GL_DEPTH_BUFFER_BIT4_QCOM 0x00001000 -#define GL_DEPTH_BUFFER_BIT5_QCOM 0x00002000 -#define GL_DEPTH_BUFFER_BIT6_QCOM 0x00004000 -#define GL_DEPTH_BUFFER_BIT7_QCOM 0x00008000 -#define GL_STENCIL_BUFFER_BIT0_QCOM 0x00010000 -#define GL_STENCIL_BUFFER_BIT1_QCOM 0x00020000 -#define GL_STENCIL_BUFFER_BIT2_QCOM 0x00040000 -#define GL_STENCIL_BUFFER_BIT3_QCOM 0x00080000 -#define GL_STENCIL_BUFFER_BIT4_QCOM 0x00100000 -#define GL_STENCIL_BUFFER_BIT5_QCOM 0x00200000 -#define GL_STENCIL_BUFFER_BIT6_QCOM 0x00400000 -#define GL_STENCIL_BUFFER_BIT7_QCOM 0x00800000 -#define GL_MULTISAMPLE_BUFFER_BIT0_QCOM 0x01000000 -#define GL_MULTISAMPLE_BUFFER_BIT1_QCOM 0x02000000 -#define GL_MULTISAMPLE_BUFFER_BIT2_QCOM 0x04000000 -#define GL_MULTISAMPLE_BUFFER_BIT3_QCOM 0x08000000 -#define GL_MULTISAMPLE_BUFFER_BIT4_QCOM 0x10000000 -#define GL_MULTISAMPLE_BUFFER_BIT5_QCOM 0x20000000 -#define GL_MULTISAMPLE_BUFFER_BIT6_QCOM 0x40000000 -#define GL_MULTISAMPLE_BUFFER_BIT7_QCOM 0x80000000 -#endif - -/*------------------------------------------------------------------------* - * VIV extension tokens - *------------------------------------------------------------------------*/ - -/* GL_VIV_shader_binary */ -#ifndef GL_VIV_shader_binary -#define GL_SHADER_BINARY_VIV 0x8FC4 -#endif - -/*------------------------------------------------------------------------* - * End of extension tokens, start of corresponding extension functions - *------------------------------------------------------------------------*/ - -/*------------------------------------------------------------------------* - * OES extension functions - *------------------------------------------------------------------------*/ - -/* GL_OES_compressed_ETC1_RGB8_texture */ -#ifndef GL_OES_compressed_ETC1_RGB8_texture -#define GL_OES_compressed_ETC1_RGB8_texture 1 -#endif - -/* GL_OES_compressed_paletted_texture */ -#ifndef GL_OES_compressed_paletted_texture -#define GL_OES_compressed_paletted_texture 1 -#endif - -/* GL_OES_depth24 */ -#ifndef GL_OES_depth24 -#define GL_OES_depth24 1 -#endif - -/* GL_OES_depth32 */ -#ifndef GL_OES_depth32 -#define GL_OES_depth32 1 -#endif - -/* GL_OES_depth_texture */ -#ifndef GL_OES_depth_texture -#define GL_OES_depth_texture 1 -#endif - -/* GL_OES_EGL_image */ -#ifndef GL_OES_EGL_image -#define GL_OES_EGL_image 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glEGLImageTargetTexture2DOES (GLenum target, GLeglImageOES image); -GL_APICALL void GL_APIENTRY glEGLImageTargetRenderbufferStorageOES (GLenum target, GLeglImageOES image); -#endif -typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC) (GLenum target, GLeglImageOES image); -typedef void (GL_APIENTRYP PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC) (GLenum target, GLeglImageOES image); -#endif - -/* GL_OES_EGL_image_external */ -#ifndef GL_OES_EGL_image_external -#define GL_OES_EGL_image_external 1 -/* glEGLImageTargetTexture2DOES defined in GL_OES_EGL_image already. */ -#endif - -/* GL_OES_element_index_uint */ -#ifndef GL_OES_element_index_uint -#define GL_OES_element_index_uint 1 -#endif - -/* GL_OES_fbo_render_mipmap */ -#ifndef GL_OES_fbo_render_mipmap -#define GL_OES_fbo_render_mipmap 1 -#endif - -/* GL_OES_fragment_precision_high */ -#ifndef GL_OES_fragment_precision_high -#define GL_OES_fragment_precision_high 1 -#endif - -/* GL_OES_get_program_binary */ -#ifndef GL_OES_get_program_binary -#define GL_OES_get_program_binary 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glGetProgramBinaryOES (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); -GL_APICALL void GL_APIENTRY glProgramBinaryOES (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length); -#endif -typedef void (GL_APIENTRYP PFNGLGETPROGRAMBINARYOESPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLenum *binaryFormat, GLvoid *binary); -typedef void (GL_APIENTRYP PFNGLPROGRAMBINARYOESPROC) (GLuint program, GLenum binaryFormat, const GLvoid *binary, GLint length); -#endif - -/* GL_OES_mapbuffer */ -#ifndef GL_OES_mapbuffer -#define GL_OES_mapbuffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void* GL_APIENTRY glMapBufferOES (GLenum target, GLenum access); -GL_APICALL GLboolean GL_APIENTRY glUnmapBufferOES (GLenum target); -GL_APICALL void GL_APIENTRY glGetBufferPointervOES (GLenum target, GLenum pname, GLvoid** params); -#endif -typedef void* (GL_APIENTRYP PFNGLMAPBUFFEROESPROC) (GLenum target, GLenum access); -typedef GLboolean (GL_APIENTRYP PFNGLUNMAPBUFFEROESPROC) (GLenum target); -typedef void (GL_APIENTRYP PFNGLGETBUFFERPOINTERVOESPROC) (GLenum target, GLenum pname, GLvoid** params); -#endif - -/* GL_OES_packed_depth_stencil */ -#ifndef GL_OES_packed_depth_stencil -#define GL_OES_packed_depth_stencil 1 -#endif - -/* GL_OES_rgb8_rgba8 */ -#ifndef GL_OES_rgb8_rgba8 -#define GL_OES_rgb8_rgba8 1 -#endif - -/* GL_OES_standard_derivatives */ -#ifndef GL_OES_standard_derivatives -#define GL_OES_standard_derivatives 1 -#endif - -/* GL_OES_stencil1 */ -#ifndef GL_OES_stencil1 -#define GL_OES_stencil1 1 -#endif - -/* GL_OES_stencil4 */ -#ifndef GL_OES_stencil4 -#define GL_OES_stencil4 1 -#endif - -/* GL_OES_texture_3D */ -#ifndef GL_OES_texture_3D -#define GL_OES_texture_3D 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); -GL_APICALL void GL_APIENTRY glTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); -GL_APICALL void GL_APIENTRY glCopyTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -GL_APICALL void GL_APIENTRY glCompressedTexImage3DOES (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); -GL_APICALL void GL_APIENTRY glCompressedTexSubImage3DOES (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data); -GL_APICALL void GL_APIENTRY glFramebufferTexture3DOES (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -#endif -typedef void (GL_APIENTRYP PFNGLTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid* pixels); -typedef void (GL_APIENTRYP PFNGLTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid* pixels); -typedef void (GL_APIENTRYP PFNGLCOPYTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height); -typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DOESPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid* data); -typedef void (GL_APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DOESPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid* data); -typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DOES) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -#endif - -/* GL_OES_texture_float */ -#ifndef GL_OES_texture_float -#define GL_OES_texture_float 1 -#endif - -/* GL_OES_texture_float_linear */ -#ifndef GL_OES_texture_float_linear -#define GL_OES_texture_float_linear 1 -#endif - -/* GL_OES_texture_half_float */ -#ifndef GL_OES_texture_half_float -#define GL_OES_texture_half_float 1 -#endif - -/* GL_OES_texture_half_float_linear */ -#ifndef GL_OES_texture_half_float_linear -#define GL_OES_texture_half_float_linear 1 -#endif - -/* GL_OES_texture_npot */ -#ifndef GL_OES_texture_npot -#define GL_OES_texture_npot 1 -#endif - -/* GL_OES_vertex_array_object */ -#ifndef GL_OES_vertex_array_object -#define GL_OES_vertex_array_object 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glBindVertexArrayOES (GLuint array); -GL_APICALL void GL_APIENTRY glDeleteVertexArraysOES (GLsizei n, const GLuint *arrays); -GL_APICALL void GL_APIENTRY glGenVertexArraysOES (GLsizei n, GLuint *arrays); -GL_APICALL GLboolean GL_APIENTRY glIsVertexArrayOES (GLuint array); -#endif -typedef void (GL_APIENTRYP PFNGLBINDVERTEXARRAYOESPROC) (GLuint array); -typedef void (GL_APIENTRYP PFNGLDELETEVERTEXARRAYSOESPROC) (GLsizei n, const GLuint *arrays); -typedef void (GL_APIENTRYP PFNGLGENVERTEXARRAYSOESPROC) (GLsizei n, GLuint *arrays); -typedef GLboolean (GL_APIENTRYP PFNGLISVERTEXARRAYOESPROC) (GLuint array); -#endif - -/* GL_OES_vertex_half_float */ -#ifndef GL_OES_vertex_half_float -#define GL_OES_vertex_half_float 1 -#endif - -/* GL_OES_vertex_type_10_10_10_2 */ -#ifndef GL_OES_vertex_type_10_10_10_2 -#define GL_OES_vertex_type_10_10_10_2 1 -#endif - -/*------------------------------------------------------------------------* - * AMD extension functions - *------------------------------------------------------------------------*/ - -/* GL_AMD_compressed_3DC_texture */ -#ifndef GL_AMD_compressed_3DC_texture -#define GL_AMD_compressed_3DC_texture 1 -#endif - -/* GL_AMD_compressed_ATC_texture */ -#ifndef GL_AMD_compressed_ATC_texture -#define GL_AMD_compressed_ATC_texture 1 -#endif - -/* AMD_performance_monitor */ -#ifndef GL_AMD_performance_monitor -#define GL_AMD_performance_monitor 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupsAMD (GLint *numGroups, GLsizei groupsSize, GLuint *groups); -GL_APICALL void GL_APIENTRY glGetPerfMonitorCountersAMD (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); -GL_APICALL void GL_APIENTRY glGetPerfMonitorGroupStringAMD (GLuint group, GLsizei bufSize, GLsizei *length, char *groupString); -GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterStringAMD (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, char *counterString); -GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint group, GLuint counter, GLenum pname, GLvoid *data); -GL_APICALL void GL_APIENTRY glGenPerfMonitorsAMD (GLsizei n, GLuint *monitors); -GL_APICALL void GL_APIENTRY glDeletePerfMonitorsAMD (GLsizei n, GLuint *monitors); -GL_APICALL void GL_APIENTRY glSelectPerfMonitorCountersAMD (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList); -GL_APICALL void GL_APIENTRY glBeginPerfMonitorAMD (GLuint monitor); -GL_APICALL void GL_APIENTRY glEndPerfMonitorAMD (GLuint monitor); -GL_APICALL void GL_APIENTRY glGetPerfMonitorCounterDataAMD (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); -#endif -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups); -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters); -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, char *groupString); -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, char *counterString); -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, GLvoid *data); -typedef void (GL_APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (GL_APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors); -typedef void (GL_APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *countersList); -typedef void (GL_APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor); -typedef void (GL_APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor); -typedef void (GL_APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten); -#endif - -/* GL_AMD_program_binary_Z400 */ -#ifndef GL_AMD_program_binary_Z400 -#define GL_AMD_program_binary_Z400 1 -#endif - -/*------------------------------------------------------------------------* - * ANGLE extension functions - *------------------------------------------------------------------------*/ - -/* GL_ANGLE_framebuffer_blit */ -#ifndef GL_ANGLE_framebuffer_blit -#define GL_ANGLE_framebuffer_blit 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glBlitFramebufferANGLE (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif -typedef void (GL_APIENTRYP PFNGLBLITFRAMEBUFFERANGLEPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -#endif - -/* GL_ANGLE_framebuffer_multisample */ -#ifndef GL_ANGLE_framebuffer_multisample -#define GL_ANGLE_framebuffer_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleANGLE (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif -typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEANGLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -#endif - -/*------------------------------------------------------------------------* - * APPLE extension functions - *------------------------------------------------------------------------*/ - -/* GL_APPLE_rgb_422 */ -#ifndef GL_APPLE_rgb_422 -#define GL_APPLE_rgb_422 1 -#endif - -/* GL_APPLE_framebuffer_multisample */ -#ifndef GL_APPLE_framebuffer_multisample -#define GL_APPLE_framebuffer_multisample 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleAPPLE (GLenum, GLsizei, GLenum, GLsizei, GLsizei); -GL_APICALL void GL_APIENTRY glResolveMultisampleFramebufferAPPLE (void); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEAPPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GL_APIENTRYP PFNGLRESOLVEMULTISAMPLEFRAMEBUFFERAPPLEPROC) (void); -#endif - -/* GL_APPLE_texture_format_BGRA8888 */ -#ifndef GL_APPLE_texture_format_BGRA8888 -#define GL_APPLE_texture_format_BGRA8888 1 -#endif - -/* GL_APPLE_texture_max_level */ -#ifndef GL_APPLE_texture_max_level -#define GL_APPLE_texture_max_level 1 -#endif - -/*------------------------------------------------------------------------* - * ARM extension functions - *------------------------------------------------------------------------*/ - -/* GL_ARM_mali_shader_binary */ -#ifndef GL_ARM_mali_shader_binary -#define GL_ARM_mali_shader_binary 1 -#endif - -/* GL_ARM_rgba8 */ -#ifndef GL_ARM_rgba8 -#define GL_ARM_rgba8 1 -#endif - -/*------------------------------------------------------------------------* - * EXT extension functions - *------------------------------------------------------------------------*/ - -/* GL_EXT_blend_minmax */ -#ifndef GL_EXT_blend_minmax -#define GL_EXT_blend_minmax 1 -#endif - -/* GL_EXT_discard_framebuffer */ -#ifndef GL_EXT_discard_framebuffer -#define GL_EXT_discard_framebuffer 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments); -#endif -typedef void (GL_APIENTRYP PFNGLDISCARDFRAMEBUFFEREXTPROC) (GLenum target, GLsizei numAttachments, const GLenum *attachments); -#endif - -#ifndef GL_EXT_multi_draw_arrays -#define GL_EXT_multi_draw_arrays 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei); -GL_APICALL void GL_APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei); -#endif /* GL_GLEXT_PROTOTYPES */ -typedef void (GL_APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount); -typedef void (GL_APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount); -#endif - -/* GL_EXT_read_format_bgra */ -#ifndef GL_EXT_read_format_bgra -#define GL_EXT_read_format_bgra 1 -#endif - -/* GL_EXT_texture_filter_anisotropic */ -#ifndef GL_EXT_texture_filter_anisotropic -#define GL_EXT_texture_filter_anisotropic 1 -#endif - -/* GL_EXT_texture_format_BGRA8888 */ -#ifndef GL_EXT_texture_format_BGRA8888 -#define GL_EXT_texture_format_BGRA8888 1 -#endif - -/* GL_EXT_texture_type_2_10_10_10_REV */ -#ifndef GL_EXT_texture_type_2_10_10_10_REV -#define GL_EXT_texture_type_2_10_10_10_REV 1 -#endif - -/* GL_EXT_texture_compression_dxt1 */ -#ifndef GL_EXT_texture_compression_dxt1 -#define GL_EXT_texture_compression_dxt1 1 -#endif - -/* GL_EXT_shader_texture_lod */ -#ifndef GL_EXT_shader_texture_lod -#define GL_EXT_shader_texture_lod 1 -#endif - -/*------------------------------------------------------------------------* - * IMG extension functions - *------------------------------------------------------------------------*/ - -/* GL_IMG_program_binary */ -#ifndef GL_IMG_program_binary -#define GL_IMG_program_binary 1 -#endif - -/* GL_IMG_read_format */ -#ifndef GL_IMG_read_format -#define GL_IMG_read_format 1 -#endif - -/* GL_IMG_shader_binary */ -#ifndef GL_IMG_shader_binary -#define GL_IMG_shader_binary 1 -#endif - -/* GL_IMG_texture_compression_pvrtc */ -#ifndef GL_IMG_texture_compression_pvrtc -#define GL_IMG_texture_compression_pvrtc 1 -#endif - -/* GL_IMG_multisampled_render_to_texture */ -#ifndef GL_IMG_multisampled_render_to_texture -#define GL_IMG_multisampled_render_to_texture 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glRenderbufferStorageMultisampleIMG (GLenum, GLsizei, GLenum, GLsizei, GLsizei); -GL_APICALL void GL_APIENTRY glFramebufferTexture2DMultisampleIMG (GLenum, GLenum, GLenum, GLuint, GLint, GLsizei); -#endif -typedef void (GL_APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (GL_APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLsizei samples); -#endif - -/*------------------------------------------------------------------------* - * NV extension functions - *------------------------------------------------------------------------*/ - -/* GL_NV_fence */ -#ifndef GL_NV_fence -#define GL_NV_fence 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glDeleteFencesNV (GLsizei, const GLuint *); -GL_APICALL void GL_APIENTRY glGenFencesNV (GLsizei, GLuint *); -GL_APICALL GLboolean GL_APIENTRY glIsFenceNV (GLuint); -GL_APICALL GLboolean GL_APIENTRY glTestFenceNV (GLuint); -GL_APICALL void GL_APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *); -GL_APICALL void GL_APIENTRY glFinishFenceNV (GLuint); -GL_APICALL void GL_APIENTRY glSetFenceNV (GLuint, GLenum); -#endif -typedef void (GL_APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences); -typedef void (GL_APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences); -typedef GLboolean (GL_APIENTRYP PFNGLISFENCENVPROC) (GLuint fence); -typedef GLboolean (GL_APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence); -typedef void (GL_APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params); -typedef void (GL_APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence); -typedef void (GL_APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition); -#endif - -/* GL_NV_coverage_sample */ -#ifndef GL_NV_coverage_sample -#define GL_NV_coverage_sample 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glCoverageMaskNV (GLboolean mask); -GL_APICALL void GL_APIENTRY glCoverageOperationNV (GLenum operation); -#endif -typedef void (GL_APIENTRYP PFNGLCOVERAGEMASKNVPROC) (GLboolean mask); -typedef void (GL_APIENTRYP PFNGLCOVERAGEOPERATIONNVPROC) (GLenum operation); -#endif - -/* GL_NV_depth_nonlinear */ -#ifndef GL_NV_depth_nonlinear -#define GL_NV_depth_nonlinear 1 -#endif - -/*------------------------------------------------------------------------* - * QCOM extension functions - *------------------------------------------------------------------------*/ - -/* GL_QCOM_driver_control */ -#ifndef GL_QCOM_driver_control -#define GL_QCOM_driver_control 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glGetDriverControlsQCOM (GLint *num, GLsizei size, GLuint *driverControls); -GL_APICALL void GL_APIENTRY glGetDriverControlStringQCOM (GLuint driverControl, GLsizei bufSize, GLsizei *length, char *driverControlString); -GL_APICALL void GL_APIENTRY glEnableDriverControlQCOM (GLuint driverControl); -GL_APICALL void GL_APIENTRY glDisableDriverControlQCOM (GLuint driverControl); -#endif -typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSQCOMPROC) (GLint *num, GLsizei size, GLuint *driverControls); -typedef void (GL_APIENTRYP PFNGLGETDRIVERCONTROLSTRINGQCOMPROC) (GLuint driverControl, GLsizei bufSize, GLsizei *length, char *driverControlString); -typedef void (GL_APIENTRYP PFNGLENABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); -typedef void (GL_APIENTRYP PFNGLDISABLEDRIVERCONTROLQCOMPROC) (GLuint driverControl); -#endif - -/* GL_QCOM_extended_get */ -#ifndef GL_QCOM_extended_get -#define GL_QCOM_extended_get 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glExtGetTexturesQCOM (GLuint *textures, GLint maxTextures, GLint *numTextures); -GL_APICALL void GL_APIENTRY glExtGetBuffersQCOM (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); -GL_APICALL void GL_APIENTRY glExtGetRenderbuffersQCOM (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); -GL_APICALL void GL_APIENTRY glExtGetFramebuffersQCOM (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); -GL_APICALL void GL_APIENTRY glExtGetTexLevelParameterivQCOM (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); -GL_APICALL void GL_APIENTRY glExtTexObjectStateOverrideiQCOM (GLenum target, GLenum pname, GLint param); -GL_APICALL void GL_APIENTRY glExtGetTexSubImageQCOM (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels); -GL_APICALL void GL_APIENTRY glExtGetBufferPointervQCOM (GLenum target, GLvoid **params); -#endif -typedef void (GL_APIENTRYP PFNGLEXTGETTEXTURESQCOMPROC) (GLuint *textures, GLint maxTextures, GLint *numTextures); -typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERSQCOMPROC) (GLuint *buffers, GLint maxBuffers, GLint *numBuffers); -typedef void (GL_APIENTRYP PFNGLEXTGETRENDERBUFFERSQCOMPROC) (GLuint *renderbuffers, GLint maxRenderbuffers, GLint *numRenderbuffers); -typedef void (GL_APIENTRYP PFNGLEXTGETFRAMEBUFFERSQCOMPROC) (GLuint *framebuffers, GLint maxFramebuffers, GLint *numFramebuffers); -typedef void (GL_APIENTRYP PFNGLEXTGETTEXLEVELPARAMETERIVQCOMPROC) (GLuint texture, GLenum face, GLint level, GLenum pname, GLint *params); -typedef void (GL_APIENTRYP PFNGLEXTTEXOBJECTSTATEOVERRIDEIQCOMPROC) (GLenum target, GLenum pname, GLint param); -typedef void (GL_APIENTRYP PFNGLEXTGETTEXSUBIMAGEQCOMPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels); -typedef void (GL_APIENTRYP PFNGLEXTGETBUFFERPOINTERVQCOMPROC) (GLenum target, GLvoid **params); -#endif - -/* GL_QCOM_extended_get2 */ -#ifndef GL_QCOM_extended_get2 -#define GL_QCOM_extended_get2 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glExtGetShadersQCOM (GLuint *shaders, GLint maxShaders, GLint *numShaders); -GL_APICALL void GL_APIENTRY glExtGetProgramsQCOM (GLuint *programs, GLint maxPrograms, GLint *numPrograms); -GL_APICALL GLboolean GL_APIENTRY glExtIsProgramBinaryQCOM (GLuint program); -GL_APICALL void GL_APIENTRY glExtGetProgramBinarySourceQCOM (GLuint program, GLenum shadertype, char *source, GLint *length); -#endif -typedef void (GL_APIENTRYP PFNGLEXTGETSHADERSQCOMPROC) (GLuint *shaders, GLint maxShaders, GLint *numShaders); -typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMSQCOMPROC) (GLuint *programs, GLint maxPrograms, GLint *numPrograms); -typedef GLboolean (GL_APIENTRYP PFNGLEXTISPROGRAMBINARYQCOMPROC) (GLuint program); -typedef void (GL_APIENTRYP PFNGLEXTGETPROGRAMBINARYSOURCEQCOMPROC) (GLuint program, GLenum shadertype, char *source, GLint *length); -#endif - -/* GL_QCOM_perfmon_global_mode */ -#ifndef GL_QCOM_perfmon_global_mode -#define GL_QCOM_perfmon_global_mode 1 -#endif - -/* GL_QCOM_writeonly_rendering */ -#ifndef GL_QCOM_writeonly_rendering -#define GL_QCOM_writeonly_rendering 1 -#endif - -/* GL_QCOM_tiled_rendering */ -#ifndef GL_QCOM_tiled_rendering -#define GL_QCOM_tiled_rendering 1 -#ifdef GL_GLEXT_PROTOTYPES -GL_APICALL void GL_APIENTRY glStartTilingQCOM (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); -GL_APICALL void GL_APIENTRY glEndTilingQCOM (GLbitfield preserveMask); -#endif -typedef void (GL_APIENTRYP PFNGLSTARTTILINGQCOMPROC) (GLuint x, GLuint y, GLuint width, GLuint height, GLbitfield preserveMask); -typedef void (GL_APIENTRYP PFNGLENDTILINGQCOMPROC) (GLbitfield preserveMask); -#endif - -/*------------------------------------------------------------------------* - * VIV extension tokens - *------------------------------------------------------------------------*/ - -/* GL_VIV_shader_binary */ -#ifndef GL_VIV_shader_binary -#define GL_VIV_shader_binary 1 -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* __gl2ext_h_ */ diff --git a/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2extimg.h b/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2extimg.h deleted file mode 100644 index 9d90955e24..0000000000 --- a/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2extimg.h +++ /dev/null @@ -1,47 +0,0 @@ -#ifndef __gl2extimg_h_ -#define __gl2extimg_h_ - -#ifdef __cplusplus -extern "C" { -#endif - -/*------------------------------------------------------------------------* - * IMG extension tokens - *------------------------------------------------------------------------*/ - -/* GL_IMG_binary_shader */ -#ifndef GL_IMG_binary_shader -#define GL_SGX_BINARY_IMG 0x8C0A -#endif - -/* GL_IMG_texture_compression_pvrtc */ -#ifndef GL_IMG_texture_compression_pvrtc -#define GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG 0x8C00 -#define GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG 0x8C01 -#define GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG 0x8C02 -#define GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG 0x8C03 -#endif - - -/* GL_IMG_texture_format_BGRA8888 */ -#define GL_BGRA 0x80E1 - -/*------------------------------------------------------------------------* - * IMG extension functions - *------------------------------------------------------------------------*/ - -/* GL_IMG_binary_shader */ -#ifndef GL_IMG_binary_shader -#define GL_IMG_binary_shader 1 -#endif - -/* GL_IMG_texture_compression_pvrtc */ -#ifndef GL_IMG_texture_compression_pvrtc -#define GL_IMG_texture_compression_pvrtc 1 -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* __gl2extimg_h_ */ diff --git a/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2platform.h b/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2platform.h deleted file mode 100644 index eeb8e59ecd..0000000000 --- a/cocos2dx/platform/third_party/win32/OGLES/GLES2/gl2platform.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef __gl2platform_h_ -#define __gl2platform_h_ - -/* - * This document is licensed under the SGI Free Software B License Version - * 2.0. For details, see http://oss.sgi.com/projects/FreeB/ . - */ - -/* Platform-specific types and definitions for OpenGL ES 2.X gl2.h - * - * Adopters may modify khrplatform.h and this file to suit their platform. - * You are encouraged to submit all modifications to the Khronos group so that - * they can be included in future versions of this file. Please submit changes - * by sending them to the public Khronos Bugzilla (http://khronos.org/bugzilla) - * by filing a bug against product "OpenGL-ES" component "Registry". - */ - -#include - -#ifndef GL_APICALL -#define GL_APICALL KHRONOS_APICALL -#endif - -#ifndef GL_APIENTRY -#define GL_APIENTRY KHRONOS_APIENTRY -#endif - -#endif /* __gl2platform_h_ */ diff --git a/cocos2dx/platform/third_party/win32/OGLES/KHR/khrplatform.h b/cocos2dx/platform/third_party/win32/OGLES/KHR/khrplatform.h deleted file mode 100644 index a8067e9a55..0000000000 --- a/cocos2dx/platform/third_party/win32/OGLES/KHR/khrplatform.h +++ /dev/null @@ -1,302 +0,0 @@ -#ifndef __khrplatform_h_ -#define __khrplatform_h_ - -/* -** Copyright (c) 2008-2009 The Khronos Group Inc. -** -** Permission is hereby granted, free of charge, to any person obtaining a -** copy of this software and/or associated documentation files (the -** "Materials"), to deal in the Materials without restriction, including -** without limitation the rights to use, copy, modify, merge, publish, -** distribute, sublicense, and/or sell copies of the Materials, and to -** permit persons to whom the Materials are furnished to do so, subject to -** the following conditions: -** -** The above copyright notice and this permission notice shall be included -** in all copies or substantial portions of the Materials. -** -** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS. -*/ - -/* Khronos platform-specific types and definitions. - * - * $Revision: 1.5 $ on $Date: 2010/06/03 16:51:55 $ - * - * Adopters may modify this file to suit their platform. Adopters are - * encouraged to submit platform specific modifications to the Khronos - * group so that they can be included in future versions of this file. - * Please submit changes by sending them to the public Khronos Bugzilla - * (http://khronos.org/bugzilla) by filing a bug against product - * "Khronos (general)" component "Registry". - * - * A predefined template which fills in some of the bug fields can be - * reached using http://tinyurl.com/khrplatform-h-bugreport, but you - * must create a Bugzilla login first. - * - * - * See the Implementer's Guidelines for information about where this file - * should be located on your system and for more details of its use: - * http://www.khronos.org/registry/implementers_guide.pdf - * - * This file should be included as - * #include - * by Khronos client API header files that use its types and defines. - * - * The types in khrplatform.h should only be used to define API-specific types. - * - * Types defined in khrplatform.h: - * khronos_int8_t signed 8 bit - * khronos_uint8_t unsigned 8 bit - * khronos_int16_t signed 16 bit - * khronos_uint16_t unsigned 16 bit - * khronos_int32_t signed 32 bit - * khronos_uint32_t unsigned 32 bit - * khronos_int64_t signed 64 bit - * khronos_uint64_t unsigned 64 bit - * khronos_intptr_t signed same number of bits as a pointer - * khronos_uintptr_t unsigned same number of bits as a pointer - * khronos_ssize_t signed size - * khronos_usize_t unsigned size - * khronos_float_t signed 32 bit floating point - * khronos_time_ns_t unsigned 64 bit time in nanoseconds - * khronos_utime_nanoseconds_t unsigned time interval or absolute time in - * nanoseconds - * khronos_stime_nanoseconds_t signed time interval in nanoseconds - * khronos_boolean_enum_t enumerated boolean type. This should - * only be used as a base type when a client API's boolean type is - * an enum. Client APIs which use an integer or other type for - * booleans cannot use this as the base type for their boolean. - * - * Tokens defined in khrplatform.h: - * - * KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values. - * - * KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0. - * KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0. - * - * Calling convention macros defined in this file: - * KHRONOS_APICALL - * KHRONOS_APIENTRY - * KHRONOS_APIATTRIBUTES - * - * These may be used in function prototypes as: - * - * KHRONOS_APICALL void KHRONOS_APIENTRY funcname( - * int arg1, - * int arg2) KHRONOS_APIATTRIBUTES; - */ - -/*------------------------------------------------------------------------- - * Definition of KHRONOS_APICALL - *------------------------------------------------------------------------- - * This precedes the return type of the function in the function prototype. - */ - -#if (defined(_WIN32) || defined(__VC32__)) && !defined(__SCITECH_SNAP__) && !defined(__WINSCW__) -# if defined (_DLL_EXPORTS) -# define KHRONOS_APICALL __declspec(dllexport) -# else -# define KHRONOS_APICALL __declspec(dllimport) -# endif -#elif defined (__SYMBIAN32__) -# if defined (__GCC32__) -# define KHRONOS_APICALL __declspec(dllexport) -# else -# define KHRONOS_APICALL IMPORT_C -# endif -#else -# define KHRONOS_APICALL -#endif - -/*------------------------------------------------------------------------- - * Definition of KHRONOS_APIENTRY - *------------------------------------------------------------------------- - * This follows the return type of the function and precedes the function - * name in the function prototype. - */ -#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__) && !defined(__WINSCW__) - /* Win32 but not WinCE */ -# define KHRONOS_APIENTRY __stdcall -#else -# define KHRONOS_APIENTRY -#endif - -/*------------------------------------------------------------------------- - * Definition of KHRONOS_APIATTRIBUTES - *------------------------------------------------------------------------- - * This follows the closing parenthesis of the function prototype arguments. - */ -#if defined (__ARMCC_2__) -#define KHRONOS_APIATTRIBUTES __softfp -#else -#define KHRONOS_APIATTRIBUTES -#endif - -/*------------------------------------------------------------------------- - * basic type definitions - *-----------------------------------------------------------------------*/ -#if defined(__SYMBIAN32__) - -#include - -typedef TInt32 khronos_int32_t; -typedef TUint32 khronos_uint32_t; -typedef TInt64 khronos_int64_t; -typedef TUint64 khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__) - - -/* - * Using - */ -#include -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif defined(__VMS ) || defined(__sgi) - -/* - * Using - */ -#include -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif defined(_WIN32) && !defined(__SCITECH_SNAP__) - -/* - * Win32 - */ -typedef __int32 khronos_int32_t; -typedef unsigned __int32 khronos_uint32_t; -typedef __int64 khronos_int64_t; -typedef unsigned __int64 khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif defined(__sun__) || defined(__digital__) - -/* - * Sun or Digital - */ -typedef int khronos_int32_t; -typedef unsigned int khronos_uint32_t; -#if defined(__arch64__) || defined(_LP64) -typedef long int khronos_int64_t; -typedef unsigned long int khronos_uint64_t; -#else -typedef long long int khronos_int64_t; -typedef unsigned long long int khronos_uint64_t; -#endif /* __arch64__ */ -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#elif defined(_UITRON_) - -/* - * uITRON - */ -typedef signed int khronos_int32_t; -typedef unsigned int khronos_uint32_t; -typedef long long khronos_int64_t; -typedef unsigned long long khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - - -#elif 0 - -/* - * Hypothetical platform with no float or int64 support - */ -typedef int khronos_int32_t; -typedef unsigned int khronos_uint32_t; -#define KHRONOS_SUPPORT_INT64 0 -#define KHRONOS_SUPPORT_FLOAT 0 - -#else - -/* - * Generic fallback - */ -#include -typedef int32_t khronos_int32_t; -typedef uint32_t khronos_uint32_t; -typedef int64_t khronos_int64_t; -typedef uint64_t khronos_uint64_t; -#define KHRONOS_SUPPORT_INT64 1 -#define KHRONOS_SUPPORT_FLOAT 1 - -#endif - - -/* - * Types that are (so far) the same on all platforms - */ -typedef signed char khronos_int8_t; -typedef unsigned char khronos_uint8_t; -typedef signed short int khronos_int16_t; -typedef unsigned short int khronos_uint16_t; -typedef signed long int khronos_intptr_t; -typedef unsigned long int khronos_uintptr_t; -typedef signed long int khronos_ssize_t; -typedef unsigned long int khronos_usize_t; - -#if KHRONOS_SUPPORT_FLOAT -/* - * Float type - */ -typedef float khronos_float_t; -#endif - -#if KHRONOS_SUPPORT_INT64 -/* Time types - * - * These types can be used to represent a time interval in nanoseconds or - * an absolute Unadjusted System Time. Unadjusted System Time is the number - * of nanoseconds since some arbitrary system event (e.g. since the last - * time the system booted). The Unadjusted System Time is an unsigned - * 64 bit value that wraps back to 0 every 584 years. Time intervals - * may be either signed or unsigned. - */ -typedef khronos_uint64_t khronos_utime_nanoseconds_t; -typedef khronos_int64_t khronos_stime_nanoseconds_t; -#endif - -/* - * Dummy value used to pad enum types to 32 bits. - */ -#ifndef KHRONOS_MAX_ENUM -#define KHRONOS_MAX_ENUM 0x7FFFFFFF -#endif - -/* - * Enumerated boolean type - * - * Values other than zero should be considered to be true. Therefore - * comparisons should not be made against KHRONOS_TRUE. - */ -typedef enum { - KHRONOS_FALSE = 0, - KHRONOS_TRUE = 1, - KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM -} khronos_boolean_enum_t; - -#endif /* __khrplatform_h_ */ diff --git a/cocos2dx/platform/third_party/win32/libraries/glew32.dll.REMOVED.git-id b/cocos2dx/platform/third_party/win32/libraries/glew32.dll.REMOVED.git-id new file mode 100644 index 0000000000..2df0a76454 --- /dev/null +++ b/cocos2dx/platform/third_party/win32/libraries/glew32.dll.REMOVED.git-id @@ -0,0 +1 @@ +cbce7da7692ddd7eb16880ec7b05e0faa8139c1a \ No newline at end of file diff --git a/cocos2dx/platform/third_party/win32/libraries/glew32.lib.REMOVED.git-id b/cocos2dx/platform/third_party/win32/libraries/glew32.lib.REMOVED.git-id new file mode 100644 index 0000000000..cd7b41948f --- /dev/null +++ b/cocos2dx/platform/third_party/win32/libraries/glew32.lib.REMOVED.git-id @@ -0,0 +1 @@ +03be6ad746e36147d633ec0e6a55e6bdb30a3a9d \ No newline at end of file diff --git a/cocos2dx/platform/third_party/win32/libraries/libEGL.dll.REMOVED.git-id b/cocos2dx/platform/third_party/win32/libraries/libEGL.dll.REMOVED.git-id deleted file mode 100644 index b1e0c80d1a..0000000000 --- a/cocos2dx/platform/third_party/win32/libraries/libEGL.dll.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -94cfb991773a35b467f19af4bde43d039ad534e7 \ No newline at end of file diff --git a/cocos2dx/platform/third_party/win32/libraries/libGLESv2.dll.REMOVED.git-id b/cocos2dx/platform/third_party/win32/libraries/libGLESv2.dll.REMOVED.git-id deleted file mode 100644 index de5f0feefc..0000000000 --- a/cocos2dx/platform/third_party/win32/libraries/libGLESv2.dll.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -ebda058de3bf9518d8a4381f87b6796169f38538 \ No newline at end of file diff --git a/cocos2dx/platform/win32/CCApplication.cpp b/cocos2dx/platform/win32/CCApplication.cpp index a4f2ec87a0..a2c05ab7f9 100644 --- a/cocos2dx/platform/win32/CCApplication.cpp +++ b/cocos2dx/platform/win32/CCApplication.cpp @@ -160,17 +160,17 @@ static void PVRFrameEnableControlWindow(bool bEnable) return; } - const char * szValue = "hide_gui"; - const char * szNewData = (bEnable) ? "NO" : "YES"; - char szOldData[256] = {0}; - DWORD dwSize = sizeof(szOldData); - LSTATUS status = RegQueryValueEx(hKey, szValue, 0, NULL, (LPBYTE)szOldData, &dwSize); + const WCHAR* wszValue = L"hide_gui"; + const WCHAR* wszNewData = (bEnable) ? L"NO" : L"YES"; + WCHAR wszOldData[256] = {0}; + DWORD dwSize = sizeof(wszOldData); + LSTATUS status = RegQueryValueExW(hKey, wszValue, 0, NULL, (LPBYTE)wszOldData, &dwSize); if (ERROR_FILE_NOT_FOUND == status // the key not exist || (ERROR_SUCCESS == status // or the hide_gui value is exist - && 0 != strcmp(szNewData, szOldData))) // but new data and old data not equal + && 0 != wcscmp(wszNewData, wszOldData))) // but new data and old data not equal { - dwSize = sizeof(wchar_t) * (strlen(szNewData) + 1); - RegSetValueEx(hKey, szValue, 0, REG_SZ, (const BYTE *)szNewData, dwSize); + dwSize = sizeof(WCHAR) * (wcslen(wszNewData) + 1); + RegSetValueEx(hKey, wszValue, 0, REG_SZ, (const BYTE *)wszNewData, dwSize); } RegCloseKey(hKey); diff --git a/cocos2dx/platform/win32/CCEGLView.cpp b/cocos2dx/platform/win32/CCEGLView.cpp index 4ff9e89fb9..976b75289a 100644 --- a/cocos2dx/platform/win32/CCEGLView.cpp +++ b/cocos2dx/platform/win32/CCEGLView.cpp @@ -32,141 +32,43 @@ THE SOFTWARE. #include "CCKeypadDispatcher.h" #include "CCApplication.h" -#include "EGL/egl.h" - NS_CC_BEGIN -////////////////////////////////////////////////////////////////////////// -// impliment CCEGL -////////////////////////////////////////////////////////////////////////// - -class CCEGL +static void SetupPixelFormat(HDC hDC) { -public: - ~CCEGL() - { - if (EGL_NO_SURFACE != m_eglSurface) - { - eglDestroySurface(m_eglDisplay, m_eglSurface); - } - if (EGL_NO_CONTEXT != m_eglContext) - { - eglDestroyContext(m_eglDisplay, m_eglContext); - } - eglMakeCurrent(m_eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - eglTerminate(m_eglDisplay); - if (m_eglNativeDisplay) - { - ReleaseDC(m_eglNativeWindow, m_eglNativeDisplay); - } - } + int pixelFormat; - static CCEGL * create(CCEGLView * pWindow) - { - CCEGL * pEGL = new CCEGL; - BOOL bSuccess = FALSE; - do - { - CC_BREAK_IF(! pEGL); + PIXELFORMATDESCRIPTOR pfd = + { + sizeof(PIXELFORMATDESCRIPTOR), // size + 1, // version + PFD_SUPPORT_OPENGL | // OpenGL window + PFD_DRAW_TO_WINDOW | // render to window + PFD_DOUBLEBUFFER, // support double-buffering + PFD_TYPE_RGBA, // color type + 32, // prefered color depth + 0, 0, 0, 0, 0, 0, // color bits (ignored) + 0, // no alpha buffer + 0, // alpha bits (ignored) + 0, // no accumulation buffer + 0, 0, 0, 0, // accum bits (ignored) + 16, // depth buffer + 0, // no stencil buffer + 0, // no auxiliary buffers + PFD_MAIN_PLANE, // main layer + 0, // reserved + 0, 0, 0, // no layer, visible, damage masks + }; - pEGL->m_eglNativeWindow = pWindow->getHWnd(); - - pEGL->m_eglNativeDisplay = GetDC(pEGL->m_eglNativeWindow); - - EGLDisplay eglDisplay; - CC_BREAK_IF(EGL_NO_DISPLAY == (eglDisplay = eglGetDisplay(pEGL->m_eglNativeDisplay))); - - EGLint nMajor, nMinor; - CC_BREAK_IF(EGL_FALSE == eglInitialize(eglDisplay, &nMajor, &nMinor) || 1 != nMajor); - - const EGLint aConfigAttribs[] = - { - EGL_LEVEL, 0, - EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - EGL_NATIVE_RENDERABLE, EGL_FALSE, - EGL_DEPTH_SIZE, 16, - EGL_NONE, - }; - EGLint iConfigs; - EGLConfig eglConfig; - CC_BREAK_IF(EGL_FALSE == eglChooseConfig(eglDisplay, aConfigAttribs, &eglConfig, 1, &iConfigs) - || (iConfigs != 1)); - - EGLContext eglContext; - eglContext = eglCreateContext(eglDisplay, eglConfig, NULL, NULL); - CC_BREAK_IF(EGL_NO_CONTEXT == eglContext); - - EGLSurface eglSurface; - eglSurface = eglCreateWindowSurface(eglDisplay, eglConfig, pEGL->m_eglNativeWindow, NULL); - CC_BREAK_IF(EGL_NO_SURFACE == eglSurface); - - CC_BREAK_IF(EGL_FALSE == eglMakeCurrent(eglDisplay, eglSurface, eglSurface, eglContext)); - - pEGL->m_eglDisplay = eglDisplay; - pEGL->m_eglConfig = eglConfig; - pEGL->m_eglContext = eglContext; - pEGL->m_eglSurface = eglSurface; - bSuccess = TRUE; - } while (0); - - if (! bSuccess) - { - CC_SAFE_DELETE(pEGL); - } - - return pEGL; - } - - void resizeSurface() - { -// if (! m_eglNativeWindow || EGL_NO_DISPLAY == m_eglDisplay) -// { -// return; -// } -// -// // release old surface -// if (EGL_NO_SURFACE != m_eglSurface) -// { -// eglDestroySurface(m_eglDisplay, m_eglSurface); -// m_eglSurface = EGL_NO_SURFACE; -// } -// -// // create new surface and make current -// m_eglSurface = eglCreateWindowSurface(m_eglDisplay, m_eglConfig, m_eglNativeWindow, NULL); -// eglMakeCurrent(m_eglDisplay, m_eglSurface, m_eglSurface, m_eglContext); - } - - void swapBuffers() - { - if (EGL_NO_DISPLAY != m_eglDisplay) - { - eglSwapBuffers(m_eglDisplay, m_eglSurface); - } - } -private: - CCEGL() - : m_eglNativeWindow(NULL) - , m_eglNativeDisplay(EGL_DEFAULT_DISPLAY) - , m_eglDisplay(EGL_NO_DISPLAY) - , m_eglConfig(0) - , m_eglSurface(EGL_NO_SURFACE) - , m_eglContext(EGL_NO_CONTEXT) - {} - - EGLNativeWindowType m_eglNativeWindow; - EGLNativeDisplayType m_eglNativeDisplay; - EGLDisplay m_eglDisplay; - EGLConfig m_eglConfig; - EGLSurface m_eglSurface; - EGLContext m_eglContext; -}; + pixelFormat = ChoosePixelFormat(hDC, &pfd); + SetPixelFormat(hDC, pixelFormat, &pfd); +} ////////////////////////////////////////////////////////////////////////// // impliment CCEGLView ////////////////////////////////////////////////////////////////////////// static CCEGLView* s_pMainWindow = NULL; -static const char* kWindowClassName = "Cocos2dxWin32"; +static const WCHAR* kWindowClassName = L"Cocos2dxWin32"; static LRESULT CALLBACK _WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { @@ -182,8 +84,9 @@ static LRESULT CALLBACK _WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM CCEGLView::CCEGLView() : m_bCaptured(false) -, m_pEGL(NULL) , m_hWnd(NULL) +, m_hDC(NULL) +, m_hRC(NULL) , m_lpfnAccelerometerKeyHook(NULL) { @@ -191,7 +94,52 @@ CCEGLView::CCEGLView() CCEGLView::~CCEGLView() { - CC_SAFE_DELETE(m_pEGL); + +} + +bool CCEGLView::initGL() +{ + m_hDC = GetDC(m_hWnd); + SetupPixelFormat(m_hDC); + //SetupPalette(); + m_hRC = wglCreateContext(m_hDC); + wglMakeCurrent(m_hDC, m_hRC); + + GLenum GlewInitResult = glewInit(); + if (GLEW_OK != GlewInitResult) + { + fprintf(stderr,"ERROR: %s\n",glewGetErrorString(GlewInitResult)); + return false; + } + + if (GLEW_ARB_vertex_shader && GLEW_ARB_fragment_shader) + { + CCLog("Ready for GLSL\n"); + } + else + { + CCLog("Not totally ready :( \n"); + } + + if (glewIsSupported("GL_VERSION_2_0")) + { + CCLog("Ready for OpenGL 2.0\n"); + } + else + { + CCLog("OpenGL 2.0 not supported\n"); + } + return true; +} + +void CCEGLView::destroyGL() +{ + if (m_hDC != NULL && m_hRC != NULL) + { + // deselect rendering context and delete it + wglMakeCurrent(m_hDC, NULL); + wglDeleteContext(m_hRC); + } } bool CCEGLView::Create(LPCTSTR pTitle, int w, int h) @@ -222,11 +170,14 @@ bool CCEGLView::Create(LPCTSTR pTitle, int w, int h) RECT rcDesktop; GetWindowRect(GetDesktopWindow(), &rcDesktop); + WCHAR wszBuf[50] = {0}; + MultiByteToWideChar(CP_UTF8, 0, m_szViewName, -1, wszBuf, sizeof(wszBuf)); + // create window m_hWnd = CreateWindowEx( WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, // Extended Style For The Window kWindowClassName, // Class Name - m_szViewName, // Window Title + wszBuf, // Window Title WS_CAPTION | WS_POPUPWINDOW | WS_MINIMIZEBOX, // Defined Window Style 0, 0, // Window Position 0, // Window Width @@ -240,16 +191,9 @@ bool CCEGLView::Create(LPCTSTR pTitle, int w, int h) resize(w, h); - // init egl - m_pEGL = CCEGL::create(this); - - if (! m_pEGL) - { - DestroyWindow(m_hWnd); - m_hWnd = NULL; - break; - } - + bRet = initGL(); + CC_BREAK_IF(!bRet); + s_pMainWindow = this; bRet = true; } while (0); @@ -259,8 +203,6 @@ bool CCEGLView::Create(LPCTSTR pTitle, int w, int h) LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { - PAINTSTRUCT ps; - switch (message) { case WM_LBUTTONDOWN: @@ -360,7 +302,6 @@ LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) { char szUtf8[8] = {0}; int nLen = WideCharToMultiByte(CP_UTF8, 0, (LPCWSTR)&wParam, 1, szUtf8, sizeof(szUtf8), NULL, NULL); - CCIMEDispatcher::sharedDispatcher()->dispatchInsertText(szUtf8, nLen); } if ( m_lpfnAccelerometerKeyHook!=NULL ) @@ -369,8 +310,8 @@ LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) } } break; - case WM_PAINT: + PAINTSTRUCT ps; BeginPaint(m_hWnd, &ps); EndPaint(m_hWnd, &ps); break; @@ -380,6 +321,7 @@ LRESULT CCEGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) break; case WM_DESTROY: + destroyGL(); PostQuitMessage(0); break; @@ -397,7 +339,7 @@ void CCEGLView::setAccelerometerKeyHook( LPFN_ACCELEROMETER_KEYHOOK lpfnAccelero bool CCEGLView::isOpenGLReady() { - return (NULL != m_pEGL); + return (m_hDC != NULL && m_hRC != NULL); } void CCEGLView::end() @@ -414,9 +356,9 @@ void CCEGLView::end() void CCEGLView::swapBuffers() { - if (m_pEGL) + if (m_hDC != NULL) { - m_pEGL->swapBuffers(); + ::SwapBuffers(m_hDC); } } @@ -453,11 +395,6 @@ void CCEGLView::resize(int width, int height) // change width and height SetWindowPos(m_hWnd, 0, 0, 0, rcClient.right - rcClient.left, rcClient.bottom - rcClient.top, SWP_NOCOPYBITS | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER); - - if (m_pEGL) - { - m_pEGL->resizeSurface(); - } } void CCEGLView::setFrameSize(float width, float height) diff --git a/cocos2dx/platform/win32/CCEGLView.h b/cocos2dx/platform/win32/CCEGLView.h index a6ede92c5a..017db9b38c 100644 --- a/cocos2dx/platform/win32/CCEGLView.h +++ b/cocos2dx/platform/win32/CCEGLView.h @@ -51,6 +51,8 @@ public: private: virtual bool Create(LPCTSTR pTitle, int w, int h); + bool initGL(); + void destroyGL(); public: virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam); @@ -71,10 +73,11 @@ public: protected: private: - bool m_bCaptured; - CCEGL * m_pEGL; - HWND m_hWnd; - LPFN_ACCELEROMETER_KEYHOOK m_lpfnAccelerometerKeyHook; + bool m_bCaptured; + HWND m_hWnd; + HDC m_hDC; + HGLRC m_hRC; + LPFN_ACCELEROMETER_KEYHOOK m_lpfnAccelerometerKeyHook; }; NS_CC_END diff --git a/cocos2dx/platform/win32/CCFileUtils.cpp b/cocos2dx/platform/win32/CCFileUtils.cpp index 33a140424c..33887eb046 100644 --- a/cocos2dx/platform/win32/CCFileUtils.cpp +++ b/cocos2dx/platform/win32/CCFileUtils.cpp @@ -49,6 +49,22 @@ static void _CheckPath() } } +static CCFileUtils* s_pFileUtils = NULL; + +CCFileUtils* CCFileUtils::sharedFileUtils() +{ + if (s_pFileUtils == NULL) + { + s_pFileUtils = new CCFileUtils(); + } + return s_pFileUtils; +} + +void CCFileUtils::purgeFileUtils() +{ + CC_SAFE_DELETE(s_pFileUtils); +} + void CCFileUtils::setResourcePath(const char *pszResourcePath) { CCAssert(pszResourcePath != NULL, "[FileUtils setResourcePath] -- wrong resource path"); diff --git a/cocos2dx/platform/win32/CCGL.h b/cocos2dx/platform/win32/CCGL.h index c872d3461b..63b4b91b4a 100644 --- a/cocos2dx/platform/win32/CCGL.h +++ b/cocos2dx/platform/win32/CCGL.h @@ -25,13 +25,8 @@ THE SOFTWARE. #ifndef __CCGL_H__ #define __CCGL_H__ -#define glClearDepth glClearDepthf -#define glDeleteVertexArrays glDeleteVertexArraysOES -#define glGenVertexArrays glGenVertexArraysOES -#define glBindVertexArray glBindVertexArrayOES +#include "GL/glew.h" -#include "GLES2/gl2.h" -#include "GLES2/gl2ext.h" +#define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8 - -#endif // __PLATFOMR_CCGL_H__ +#endif // __CCGL_H__ diff --git a/cocos2dx/platform/win32/CCImage.cpp b/cocos2dx/platform/win32/CCImage.cpp index e03c549470..5ddd5fa0c8 100644 --- a/cocos2dx/platform/win32/CCImage.cpp +++ b/cocos2dx/platform/win32/CCImage.cpp @@ -57,14 +57,42 @@ public: DeleteObject(m_hFont); m_hFont = hDefFont; } - // release temp font resource - if (m_curFontPath.size() > 0) - { - RemoveFontResource(m_curFontPath.c_str()); - SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0); - } + // release temp font resource + if (m_curFontPath.size() > 0) + { + wchar_t * pwszBuffer = utf8ToUtf16(m_curFontPath); + if (pwszBuffer) + { + RemoveFontResource(pwszBuffer); + SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0); + delete [] pwszBuffer; + pwszBuffer = NULL; + } + } } + wchar_t * utf8ToUtf16(std::string nString) + { + wchar_t * pwszBuffer = NULL; + do + { + if (nString.size() < 0) + { + break; + } + // utf-8 to utf-16 + int nLen = nString.size(); + int nBufLen = nLen + 1; + pwszBuffer = new wchar_t[nBufLen]; + CC_BREAK_IF(! pwszBuffer); + memset(pwszBuffer,0,nBufLen); + nLen = MultiByteToWideChar(CP_UTF8, 0, nString.c_str(), nLen, pwszBuffer, nBufLen); + pwszBuffer[nLen] = '\0'; + } while (0); + return pwszBuffer; + + } + bool setFont(const char * pFontName = NULL, int nSize = 0) { bool bRet = false; @@ -83,7 +111,7 @@ public: int nFindTTF = fontName.find(".TTF"); if (nFindttf >= 0 || nFindTTF >= 0) { - fontPath = CCFileUtils::fullPathFromRelativePath(fontName.c_str()); + fontPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(fontName.c_str()); int nFindPos = fontName.rfind("/"); fontName = &fontName[nFindPos+1]; nFindPos = fontName.rfind("."); @@ -110,27 +138,41 @@ public: if (m_hFont != hDefFont) { DeleteObject(m_hFont); - // release old font register - if (m_curFontPath.size() > 0) - { - if(RemoveFontResource(m_curFontPath.c_str())) - { - SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0); - } - } - - fontPath.size()>0?(m_curFontPath = fontPath):(m_curFontPath.clear()); - // register temp font - if (m_curFontPath.size() > 0) - { - if(AddFontResource(m_curFontPath.c_str())) - { - SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0); - } - } + // release old font register + if (m_curFontPath.size() > 0) + { + wchar_t * pwszBuffer = utf8ToUtf16(m_curFontPath); + if (pwszBuffer) + { + if(RemoveFontResource(pwszBuffer)) + { + SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0); + } + delete [] pwszBuffer; + pwszBuffer = NULL; + } + } + fontPath.size()>0?(m_curFontPath = fontPath):(m_curFontPath.clear()); + // register temp font + if (m_curFontPath.size() > 0) + { + wchar_t * pwszBuffer = utf8ToUtf16(m_curFontPath); + if (pwszBuffer) + { + if(AddFontResource(pwszBuffer)) + { + SendMessage( m_hWnd, WM_FONTCHANGE, 0, 0); + } + delete [] pwszBuffer; + pwszBuffer = NULL; + } + } } m_hFont = NULL; + // disable Cleartype + tNewFont.lfQuality = ANTIALIASED_QUALITY; + // create new font m_hFont = CreateFontIndirectA(&tNewFont); if (! m_hFont) diff --git a/cocos2dx/proj.win32/cocos2d-win32.vcproj b/cocos2dx/proj.win32/cocos2d-win32.vcproj index b325206771..fb354843a5 100755 --- a/cocos2dx/proj.win32/cocos2d-win32.vcproj +++ b/cocos2dx/proj.win32/cocos2d-win32.vcproj @@ -21,7 +21,7 @@ OutputDirectory="$(SolutionDir)$(ConfigurationName).win32" IntermediateDirectory="$(ConfigurationName).win32" ConfigurationType="2" - CharacterSet="2" + CharacterSet="1" > + + + + @@ -850,6 +858,10 @@ + + diff --git a/cocos2dx/proj.win32/cocos2d-win32.vcxproj b/cocos2dx/proj.win32/cocos2d-win32.vcxproj index 447046e014..d15885d496 100755 --- a/cocos2dx/proj.win32/cocos2d-win32.vcxproj +++ b/cocos2dx/proj.win32/cocos2d-win32.vcxproj @@ -19,11 +19,11 @@ DynamicLibrary - MultiByte + Unicode DynamicLibrary - MultiByte + Unicode @@ -74,7 +74,7 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ - libEGL.lib;libGLESv2.lib;libxml2.lib;libzlib.lib;libpng.lib;libtiff.lib;libjpeg.lib;libiconv.lib;pthreadVCE2.lib;%(AdditionalDependencies);%(AdditionalDependencies) + opengl32.lib;glew32.lib;libxml2.lib;libzlib.lib;libpng.lib;libtiff.lib;libjpeg.lib;libiconv.lib;pthreadVCE2.lib;%(AdditionalDependencies);%(AdditionalDependencies) $(OutDir)$(ProjectName).dll $(OutDir);%(AdditionalLibraryDirectories) @@ -112,7 +112,7 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ - libEGL.lib;libGLESv2.lib;libxml2.lib;libzlib.lib;libpng.lib;libtiff.lib;libjpeg.lib;libiconv.lib;pthreadVCE2.lib;;%(AdditionalDependencies) + opengl32.lib;glew32.lib;libxml2.lib;libzlib.lib;libpng.lib;libtiff.lib;libjpeg.lib;libiconv.lib;pthreadVCE2.lib;;%(AdditionalDependencies) $(OutDir)$(ProjectName).dll $(OutDir);%(AdditionalLibraryDirectories) diff --git a/cocos2dx/script_support/CCScriptSupport.cpp b/cocos2dx/script_support/CCScriptSupport.cpp index 040f40e162..957c380de3 100644 --- a/cocos2dx/script_support/CCScriptSupport.cpp +++ b/cocos2dx/script_support/CCScriptSupport.cpp @@ -27,7 +27,7 @@ THE SOFTWARE. NS_CC_BEGIN -CCSchedulerScriptHandlerEntry* CCSchedulerScriptHandlerEntry::entryWithHandler(int nHandler, ccTime fInterval, bool bPaused) +CCSchedulerScriptHandlerEntry* CCSchedulerScriptHandlerEntry::entryWithHandler(int nHandler, float fInterval, bool bPaused) { CCSchedulerScriptHandlerEntry* pEntry = new CCSchedulerScriptHandlerEntry(); pEntry->initWithHandler(nHandler, fInterval, bPaused); @@ -35,9 +35,9 @@ CCSchedulerScriptHandlerEntry* CCSchedulerScriptHandlerEntry::entryWithHandler(i return pEntry; } -bool CCSchedulerScriptHandlerEntry::initWithHandler(int nHandler, ccTime fInterval, bool bPaused) +bool CCSchedulerScriptHandlerEntry::initWithHandler(int nHandler, float fInterval, bool bPaused) { - m_pTimer = new CCTimer(); + m_pTimer = new floatr(); m_pTimer->initWithScriptHandler(nHandler, fInterval); m_pTimer->autorelease(); m_pTimer->retain(); diff --git a/cocos2dx/script_support/CCScriptSupport.h b/cocos2dx/script_support/CCScriptSupport.h index 4679b9f216..213e527ef2 100644 --- a/cocos2dx/script_support/CCScriptSupport.h +++ b/cocos2dx/script_support/CCScriptSupport.h @@ -33,17 +33,17 @@ typedef struct lua_State lua_State; NS_CC_BEGIN -class CCTimer; +class floatr; // Lua support for CCScheduler class CCSchedulerScriptHandlerEntry : public CCObject { public: // nHandler return by tolua_ref_function(), called from LuaCocos2d.cpp - static CCSchedulerScriptHandlerEntry* entryWithHandler(int nHandler, ccTime fInterval, bool bPaused); + static CCSchedulerScriptHandlerEntry* entryWithHandler(int nHandler, float fInterval, bool bPaused); ~CCSchedulerScriptHandlerEntry(void); - inline cocos2d::CCTimer* getTimer(void) { + inline cocos2d::floatr* getTimer(void) { return m_pTimer; } @@ -65,9 +65,9 @@ public: private: CCSchedulerScriptHandlerEntry(void); - bool initWithHandler(int nHandler, ccTime fInterval, bool bPaused); + bool initWithHandler(int nHandler, float fInterval, bool bPaused); - cocos2d::CCTimer* m_pTimer; + cocos2d::floatr* m_pTimer; bool m_bPaused; bool m_bMarkedForDeletion; int m_nHandler; @@ -178,7 +178,7 @@ public: virtual int executeTouchesEvent(int nHandler, int eventType, CCSet *pTouches) = 0; // execute a schedule function - virtual int executeSchedule(int nHandler, ccTime dt) = 0; + virtual int executeSchedule(int nHandler, float dt) = 0; }; /** diff --git a/cocos2dx/shaders/CCGLProgram.cpp b/cocos2dx/shaders/CCGLProgram.cpp index caf9401488..7c32c832a8 100644 --- a/cocos2dx/shaders/CCGLProgram.cpp +++ b/cocos2dx/shaders/CCGLProgram.cpp @@ -116,8 +116,8 @@ bool CCGLProgram::initWithVertexShaderByteArray(const GLchar* vShaderByteArray, bool CCGLProgram::initWithVertexShaderFilename(const char* vShaderFilename, const char* fShaderFilename) { - const GLchar * vertexSource = (GLchar*) CCString::stringWithContentsOfFile(CCFileUtils::fullPathFromRelativePath(vShaderFilename))->getCString(); - const GLchar * fragmentSource = (GLchar*) CCString::stringWithContentsOfFile(CCFileUtils::fullPathFromRelativePath(fShaderFilename))->getCString(); + const GLchar * vertexSource = (GLchar*) CCString::stringWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(vShaderFilename))->getCString(); + const GLchar * fragmentSource = (GLchar*) CCString::stringWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(fShaderFilename))->getCString(); return initWithVertexShaderByteArray(vertexSource, fragmentSource); } diff --git a/cocos2dx/shaders/CCGLProgram.h b/cocos2dx/shaders/CCGLProgram.h index 03f8e0ee9a..fd5f480dff 100644 --- a/cocos2dx/shaders/CCGLProgram.h +++ b/cocos2dx/shaders/CCGLProgram.h @@ -31,6 +31,8 @@ THE SOFTWARE. #include "ccMacros.h" #include "CCObject.h" +#include "CCGL.h" + NS_CC_BEGIN enum { diff --git a/cocos2dx/sprite_nodes/CCAnimationCache.cpp b/cocos2dx/sprite_nodes/CCAnimationCache.cpp index 849decebb6..3428ee8f80 100644 --- a/cocos2dx/sprite_nodes/CCAnimationCache.cpp +++ b/cocos2dx/sprite_nodes/CCAnimationCache.cpp @@ -244,7 +244,7 @@ void CCAnimationCache::addAnimationsWithFile(const char* plist) { CCAssert( plist, "Invalid texture file name"); - const char* path = CCFileUtils::fullPathFromRelativePath(plist); + const char* path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(plist); CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFile(path); CCAssert( dict, "CCAnimationCache: File could not be found"); diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index 19ada1c3d3..9389a792d3 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. @@ -390,9 +390,9 @@ void CCSprite::setTextureCoords(CCRect rect) bottom = top+(rect.size.width*2-2)/(2*atlasHeight); #else left = rect.origin.x/atlasWidth; - right = left+(rect.size.height/atlasWidth); + right = (rect.origin.x+rect.size.height) / atlasWidth; top = rect.origin.y/atlasHeight; - bottom = top+(rect.size.width/atlasHeight); + bottom = (rect.origin.y+rect.size.width) / atlasHeight; #endif // CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL if (m_bFlipX) @@ -423,9 +423,9 @@ void CCSprite::setTextureCoords(CCRect rect) bottom = top + (rect.size.height*2-2)/(2*atlasHeight); #else left = rect.origin.x/atlasWidth; - right = left + rect.size.width/atlasWidth; + right = (rect.origin.x + rect.size.width) / atlasWidth; top = rect.origin.y/atlasHeight; - bottom = top + rect.size.height/atlasHeight; + bottom = (rect.origin.y + rect.size.height) / atlasHeight; #endif // ! CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL if(m_bFlipX) @@ -827,10 +827,10 @@ void CCSprite::setAnchorPoint(const CCPoint& anchor) SET_DIRTY_RECURSIVELY(); } -void CCSprite::setIsRelativeAnchorPoint(bool bRelative) +void CCSprite::setIgnoreAnchorPointForPosition(bool value) { - CCAssert(! m_pobBatchNode, "relativeTransformAnchor is invalid in CCSprite"); - CCNode::setIsRelativeAnchorPoint(bRelative); + CCAssert(! m_pobBatchNode, "ignoreAnchorPointForPosition is invalid in CCSprite"); + CCNode::setIgnoreAnchorPointForPosition(value); } void CCSprite::setIsVisible(bool bVisible) @@ -1061,11 +1061,12 @@ void CCSprite::updateBlendFunc(void) void CCSprite::setTexture(CCTexture2D *texture) { - CCAssert(! m_pobBatchNode, "setTexture doesn't work when the sprite is rendered using a CCSpriteBatchNode"); + // If batchnode, then texture id should be the same + CCAssert(! m_pobBatchNode || texture->getName() == m_pobBatchNode->getTexture()->getName(), "CCSprite: Batched sprites should use the same texture as the batchnode"); // accept texture==nil as argument CCAssert( !texture || dynamic_cast(texture), "setTexture expects a CCTexture2D. Invalid argument"); - if (m_pobTexture != texture) + if (!m_pobBatchNode && m_pobTexture != texture) { CC_SAFE_RETAIN(texture); CC_SAFE_RELEASE(m_pobTexture); diff --git a/cocos2dx/sprite_nodes/CCSprite.h b/cocos2dx/sprite_nodes/CCSprite.h index 28d031c002..f66830adfe 100644 --- a/cocos2dx/sprite_nodes/CCSprite.h +++ b/cocos2dx/sprite_nodes/CCSprite.h @@ -181,7 +181,7 @@ public: virtual void setScale(float fScale); virtual void setVertexZ(float fVertexZ); virtual void setAnchorPoint(const CCPoint& anchor); - virtual void setIsRelativeAnchorPoint(bool bRelative); + virtual void setIgnoreAnchorPointForPosition(bool value); virtual void setIsVisible(bool bVisible); void setFlipX(bool bFlipX); void setFlipY(bool bFlipY); diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp index 875f087cbc..94cfc3e5b5 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp @@ -425,7 +425,7 @@ void CCSpriteBatchNode::increaseAtlasCapacity(void) if (! m_pobTextureAtlas->resizeCapacity(quantity)) { // serious problems - CCLOG("cocos2d: WARNING: Not enough memory to resize the atlas"); + CCLOGWARN("cocos2d: WARNING: Not enough memory to resize the atlas"); CCAssert(false, "Not enough memory to resize the atla"); } } diff --git a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp index f3fde8f3d9..b4b3c2802f 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Jason Booth Copyright (c) 2009 Robert J Payne @@ -36,6 +36,7 @@ THE SOFTWARE. #include "CCFileUtils.h" #include "CCString.h" #include "CCArray.h" +#include "CCDictionary.h" #include using namespace std; @@ -64,6 +65,7 @@ bool CCSpriteFrameCache::init(void) { m_pSpriteFrames= new CCDictionary(); m_pSpriteFramesAliases = new CCDictionary(); + m_pLoadedFileNames = new std::set(); return true; } @@ -71,6 +73,7 @@ CCSpriteFrameCache::~CCSpriteFrameCache(void) { CC_SAFE_RELEASE(m_pSpriteFrames); CC_SAFE_RELEASE(m_pSpriteFramesAliases); + CC_SAFE_DELETE(m_pLoadedFileNames); } void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary* dictionary, CCTexture2D *pobTexture) @@ -95,7 +98,7 @@ void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary* dictionary, } // check the format - CCAssert(format >=0 && format <= 3, ""); + CCAssert(format >=0 && format <= 3, "format is not supported for CCSpriteFrameCache addSpriteFramesWithDictionary:textureFilename:"); CCDictElement* pElement = NULL; CCDICT_FOREACH(framesDict, pElement) @@ -120,7 +123,7 @@ void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary* dictionary, // check ow/oh if(!ow || !oh) { - CCLOG("cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenrate the .plist"); + CCLOGWARN("cocos2d: WARNING: originalWidth/Height not found on the CCSpriteFrame. AnchorPoint won't work as expected. Regenrate the .plist"); } // abs ow/oh ow = abs(ow); @@ -176,7 +179,7 @@ void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary* dictionary, std::string oneAlias = ((CCString*)pObj)->getCString(); if (m_pSpriteFramesAliases->objectForKey(oneAlias.c_str())) { - CCLOG("cocos2d: WARNING: an alias with name %s already exists", oneAlias.c_str()); + CCLOGWARN("cocos2d: WARNING: an alias with name %s already exists", oneAlias.c_str()); } m_pSpriteFramesAliases->setObject(frameKey, oneAlias.c_str()); @@ -199,7 +202,7 @@ void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary* dictionary, void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist, CCTexture2D *pobTexture) { - const char *pszPath = CCFileUtils::fullPathFromRelativePath(pszPlist); + const char *pszPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pszPlist); CCDictionary *dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(pszPath); addSpriteFramesWithDictionary(dict, pobTexture); @@ -224,50 +227,57 @@ void CCSpriteFrameCache::addSpriteFramesWithFile(const char* plist, const char* void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist) { - const char *pszPath = CCFileUtils::fullPathFromRelativePath(pszPlist); - CCDictionary *dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(pszPath); - - string texturePath(""); + CCAssert(pszPlist, "plist filename should not be NULL"); - CCDictionary* metadataDict = (CCDictionary*)dict->objectForKey("metadata"); - if (metadataDict) + if (m_pLoadedFileNames->find(pszPlist) == m_pLoadedFileNames->end()) { - // try to read texture file name from meta data - texturePath = metadataDict->valueForKey("textureFileName")->getCString(); + const char *pszPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pszPlist); + CCDictionary *dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(pszPath); + + string texturePath(""); + + CCDictionary* metadataDict = (CCDictionary*)dict->objectForKey("metadata"); + if (metadataDict) + { + // try to read texture file name from meta data + texturePath = metadataDict->valueForKey("textureFileName")->getCString(); + } + + if (! texturePath.empty()) + { + // build texture path relative to plist file + texturePath = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(texturePath.c_str(), pszPath); + } + else + { + // build texture path by replacing file extension + texturePath = pszPath; + + // remove .xxx + size_t startPos = texturePath.find_last_of("."); + texturePath = texturePath.erase(startPos); + + // append .png + texturePath = texturePath.append(".png"); + + CCLOG("cocos2d: CCSpriteFrameCache: Trying to use file %s as texture", texturePath.c_str()); + } + + CCTexture2D *pTexture = CCTextureCache::sharedTextureCache()->addImage(texturePath.c_str()); + + if (pTexture) + { + addSpriteFramesWithDictionary(dict, pTexture); + m_pLoadedFileNames->insert(pszPlist); + } + else + { + CCLOG("cocos2d: CCSpriteFrameCache: Couldn't load texture"); + } + + dict->release(); } - if (! texturePath.empty()) - { - // build texture path relative to plist file - texturePath = CCFileUtils::fullPathFromRelativeFile(texturePath.c_str(), pszPath); - } - else - { - // build texture path by replacing file extension - texturePath = pszPath; - - // remove .xxx - size_t startPos = texturePath.find_last_of("."); - texturePath = texturePath.erase(startPos); - - // append .png - texturePath = texturePath.append(".png"); - - CCLOG("cocos2d: CCSpriteFrameCache: Trying to use file %s as texture", texturePath.c_str()); - } - - CCTexture2D *pTexture = CCTextureCache::sharedTextureCache()->addImage(texturePath.c_str()); - - if (pTexture) - { - addSpriteFramesWithDictionary(dict, pTexture); - } - else - { - CCLOG("cocos2d: CCSpriteFrameCache: Couldn't load texture"); - } - - dict->release(); } void CCSpriteFrameCache::addSpriteFrame(CCSpriteFrame *pobFrame, const char *pszFrameName) @@ -279,10 +289,12 @@ void CCSpriteFrameCache::removeSpriteFrames(void) { m_pSpriteFrames->removeAllObjects(); m_pSpriteFramesAliases->removeAllObjects(); + m_pLoadedFileNames->clear(); } void CCSpriteFrameCache::removeUnusedSpriteFrames(void) { + bool bRemoved = false; CCDictElement* pElement = NULL; CCDICT_FOREACH(m_pSpriteFrames, pElement) { @@ -291,8 +303,15 @@ void CCSpriteFrameCache::removeUnusedSpriteFrames(void) { CCLOG("cocos2d: CCSpriteFrameCache: removing unused frame: %s", pElement->getStrKey()); m_pSpriteFrames->removeObjectForElememt(pElement); + bRemoved = true; } } + + // XXX. Since we don't know the .plist file that originated the frame, we must remove all .plist from the cache + if( bRemoved ) + { + m_pLoadedFileNames->clear(); + } } @@ -316,15 +335,25 @@ void CCSpriteFrameCache::removeSpriteFrameByName(const char *pszName) { m_pSpriteFrames->removeObjectForKey(pszName); } + + // XXX. Since we don't know the .plist file that originated the frame, we must remove all .plist from the cache + m_pLoadedFileNames->clear(); } void CCSpriteFrameCache::removeSpriteFramesFromFile(const char* plist) { - const char* path = CCFileUtils::fullPathFromRelativePath(plist); + const char* path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(plist); CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(path); removeSpriteFramesFromDictionary((CCDictionary*)dict); + // remove it from the cache + set::iterator ret = m_pLoadedFileNames->find(plist); + if (ret != m_pLoadedFileNames->end()) + { + m_pLoadedFileNames->erase(ret); + } + dict->release(); } diff --git a/cocos2dx/sprite_nodes/CCSpriteFrameCache.h b/cocos2dx/sprite_nodes/CCSpriteFrameCache.h index 306ea7e66e..c0439e6893 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrameCache.h +++ b/cocos2dx/sprite_nodes/CCSpriteFrameCache.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Jason Booth Copyright (c) 2009 Robert J Payne @@ -38,10 +38,12 @@ THE SOFTWARE. #include "CCSpriteFrame.h" #include "CCTexture2D.h" #include "CCObject.h" -#include "CCDictionary.h" +#include NS_CC_BEGIN +class CCDictionary; +class CCArray; class CCSprite; /** @brief Singleton that handles the loading of the sprite frames. @@ -54,10 +56,11 @@ public: bool init(void); ~CCSpriteFrameCache(void); +private: /*Adds multiple Sprite Frames with a dictionary. The texture will be associated with the created sprite frames. */ void addSpriteFramesWithDictionary(CCDictionary* pobDictionary, CCTexture2D *pobTexture); - +public: /** Adds multiple Sprite Frames from a plist file. * A texture will be loaded automatically. The texture name will composed by replacing the .plist suffix with .png * If you want to use another texture, you should use the addSpriteFramesWithFile:texture method. @@ -101,11 +104,12 @@ public: */ void removeSpriteFramesFromFile(const char* plist); +private: /** Removes multiple Sprite Frames from CCDictionary. * @since v0.99.5 */ void removeSpriteFramesFromDictionary(CCDictionary* dictionary); - +public: /** Removes all Sprite Frames associated with the specified textures. * It is convinient to call this method when a specific texture needs to be removed. * @since v0.995. @@ -130,6 +134,7 @@ private: protected: CCDictionary* m_pSpriteFrames; CCDictionary* m_pSpriteFramesAliases; + std::set* m_pLoadedFileNames; }; NS_CC_END diff --git a/cocos2dx/support/CCUserDefault.cpp b/cocos2dx/support/CCUserDefault.cpp index 927a4371e0..030ef9c26b 100644 --- a/cocos2dx/support/CCUserDefault.cpp +++ b/cocos2dx/support/CCUserDefault.cpp @@ -324,7 +324,7 @@ void CCUserDefault::initXMLFilePath() { if (! m_sbIsFilePathInitialized) { - m_sFilePath += CCFileUtils::getWriteablePath() + XML_FILE_NAME; + m_sFilePath += CCFileUtils::sharedFileUtils()->getWriteablePath() + XML_FILE_NAME; m_sbIsFilePathInitialized = true; } } diff --git a/cocos2dx/support/CCVertex.cpp b/cocos2dx/support/CCVertex.cpp index c0d26679bc..9f55d765ca 100644 --- a/cocos2dx/support/CCVertex.cpp +++ b/cocos2dx/support/CCVertex.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2010 cocos2d-x.org + Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 ForzeField Studios S.L http://www.cocos2d-x.org @@ -29,7 +29,7 @@ NS_CC_BEGIN -void ccVertexLineToPolygon(CCPoint *points, float stroke, ccVertex2F *vertices, ccTex2F *texCoords, unsigned int offset, unsigned int nuPoints) +void ccVertexLineToPolygon(CCPoint *points, float stroke, ccVertex2F *vertices, unsigned int offset, unsigned int nuPoints) { nuPoints += offset; if(nuPoints<=1) return; @@ -38,7 +38,6 @@ void ccVertexLineToPolygon(CCPoint *points, float stroke, ccVertex2F *vertices, unsigned int idx; unsigned int nuPointsMinus = nuPoints-1; - float texDelta = 1.0f/(float)nuPointsMinus; for(unsigned int i = offset; inum = 0; + arr->arr = (CCObject**)calloc(capacity, sizeof(CCObject*)); + arr->max = capacity; + + return arr; +} + +/** Frees array after removing all remaining objects. Silently ignores NULL arr. */ +void ccArrayFree(ccArray*& arr) +{ + if( arr == NULL ) + { + return; + } + ccArrayRemoveAllObjects(arr); + + free(arr->arr); + free(arr); + + arr = NULL; +} + +void ccArrayDoubleCapacity(ccArray *arr) +{ + arr->max *= 2; + CCObject** newArr = (CCObject**)realloc( arr->arr, arr->max * sizeof(CCObject*) ); + // will fail when there's not enough memory + CCAssert(newArr != 0, "ccArrayDoubleCapacity failed. Not enough memory"); + arr->arr = newArr; +} + +void ccArrayEnsureExtraCapacity(ccArray *arr, unsigned int extra) +{ + while (arr->max < arr->num + extra) + { + ccArrayDoubleCapacity(arr); + } +} + +void ccArrayShrink(ccArray *arr) +{ + unsigned int newSize = 0; + + //only resize when necessary + if (arr->max > arr->num && !(arr->num==0 && arr->max==1)) + { + if (arr->num!=0) + { + newSize=arr->num; + arr->max=arr->num; + } + else + {//minimum capacity of 1, with 0 elements the array would be free'd by realloc + newSize=1; + arr->max=1; + } + + arr->arr = (CCObject**)realloc(arr->arr,newSize * sizeof(CCObject*) ); + CCAssert(arr->arr!=NULL,"could not reallocate the memory"); + } +} + +/** Returns index of first occurence of object, CC_INVALID_INDEX if object not found. */ +unsigned int ccArrayGetIndexOfObject(ccArray *arr, CCObject* object) +{ + for(unsigned int i = 0; i < arr->num; i++) + { + if( arr->arr[i] == object ) return i; + } + + return CC_INVALID_INDEX; +} + +/** Returns a Boolean value that indicates whether object is present in array. */ +bool ccArrayContainsObject(ccArray *arr, CCObject* object) +{ + return ccArrayGetIndexOfObject(arr, object) != CC_INVALID_INDEX; +} + +/** Appends an object. Bahaviour undefined if array doesn't have enough capacity. */ +void ccArrayAppendObject(ccArray *arr, CCObject* object) +{ + CCAssert(object != NULL, "Invalid parameter!"); + object->retain(); + arr->arr[arr->num] = object; + arr->num++; +} + +/** Appends an object. Capacity of arr is increased if needed. */ +void ccArrayAppendObjectWithResize(ccArray *arr, CCObject* object) +{ + ccArrayEnsureExtraCapacity(arr, 1); + ccArrayAppendObject(arr, object); +} + +/** Appends objects from plusArr to arr. Behaviour undefined if arr doesn't have + enough capacity. */ +void ccArrayAppendArray(ccArray *arr, ccArray *plusArr) +{ + for(unsigned int i = 0; i < plusArr->num; i++) + { + ccArrayAppendObject(arr, plusArr->arr[i]); + } +} + +/** Appends objects from plusArr to arr. Capacity of arr is increased if needed. */ +void ccArrayAppendArrayWithResize(ccArray *arr, ccArray *plusArr) +{ + ccArrayEnsureExtraCapacity(arr, plusArr->num); + ccArrayAppendArray(arr, plusArr); +} + +/** Inserts an object at index */ +void ccArrayInsertObjectAtIndex(ccArray *arr, CCObject* object, unsigned int index) +{ + CCAssert(index<=arr->num, "Invalid index. Out of bounds"); + CCAssert(object != NULL, "Invalid parameter!"); + + ccArrayEnsureExtraCapacity(arr, 1); + + unsigned int remaining = arr->num - index; + if( remaining > 0) + { + memmove((void *)&arr->arr[index+1], (void *)&arr->arr[index], sizeof(CCObject*) * remaining ); + } + + object->retain(); + arr->arr[index] = object; + arr->num++; +} + +/** Swaps two objects */ +void ccArraySwapObjectsAtIndexes(ccArray *arr, unsigned int index1, unsigned int index2) +{ + CCAssert(index1 < arr->num, "(1) Invalid index. Out of bounds"); + CCAssert(index2 < arr->num, "(2) Invalid index. Out of bounds"); + + CCObject* object1 = arr->arr[index1]; + + arr->arr[index1] = arr->arr[index2]; + arr->arr[index2] = object1; +} + +/** Removes all objects from arr */ +void ccArrayRemoveAllObjects(ccArray *arr) +{ + while( arr->num > 0 ) + { + (arr->arr[--arr->num])->release(); + } +} + +/** Removes object at specified index and pushes back all subsequent objects. + Behaviour undefined if index outside [0, num-1]. */ +void ccArrayRemoveObjectAtIndex(ccArray *arr, unsigned int index, bool bReleaseObj/* = true*/) +{ + CCAssert(arr && arr->num > 0 && index < arr->num, "Invalid index. Out of bounds"); + if (bReleaseObj) + { + CC_SAFE_RELEASE(arr->arr[index]); + } + + arr->num--; + + unsigned int remaining = arr->num - index; + if(remaining>0) + { + memmove((void *)&arr->arr[index], (void *)&arr->arr[index+1], remaining * sizeof(CCObject*)); + } +} + +/** Removes object at specified index and fills the gap with the last object, + thereby avoiding the need to push back subsequent objects. + Behaviour undefined if index outside [0, num-1]. */ +void ccArrayFastRemoveObjectAtIndex(ccArray *arr, unsigned int index) +{ + CC_SAFE_RELEASE(arr->arr[index]); + unsigned int last = --arr->num; + arr->arr[index] = arr->arr[last]; +} + +void ccArrayFastRemoveObject(ccArray *arr, CCObject* object) +{ + unsigned int index = ccArrayGetIndexOfObject(arr, object); + if (index != CC_INVALID_INDEX) + { + ccArrayFastRemoveObjectAtIndex(arr, index); + } +} + +/** Searches for the first occurance of object and removes it. If object is not + found the function has no effect. */ +void ccArrayRemoveObject(ccArray *arr, CCObject* object, bool bReleaseObj/* = true*/) +{ + unsigned int index = ccArrayGetIndexOfObject(arr, object); + if (index != CC_INVALID_INDEX) + { + ccArrayRemoveObjectAtIndex(arr, index, bReleaseObj); + } +} + +/** Removes from arr all objects in minusArr. For each object in minusArr, the + first matching instance in arr will be removed. */ +void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr) +{ + for(unsigned int i = 0; i < minusArr->num; i++) + { + ccArrayRemoveObject(arr, minusArr->arr[i]); + } +} + +/** Removes from arr all objects in minusArr. For each object in minusArr, all + matching instances in arr will be removed. */ +void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr) +{ + unsigned int back = 0; + unsigned int i = 0; + + for( i = 0; i < arr->num; i++) + { + if( ccArrayContainsObject(minusArr, arr->arr[i]) ) + { + CC_SAFE_RELEASE(arr->arr[i]); + back++; + } + else + { + arr->arr[i - back] = arr->arr[i]; + } + } + + arr->num -= back; +} + +// #pragma mark - +// #pragma mark ccCArray for Values (c structures) + +/** Allocates and initializes a new C array with specified capacity */ +ccCArray* ccCArrayNew(unsigned int capacity) +{ + if (capacity == 0) + { + capacity = 1; + } + + ccCArray *arr = (ccCArray*)malloc( sizeof(ccCArray) ); + arr->num = 0; + arr->arr = (void**)malloc( capacity * sizeof(void*) ); + arr->max = capacity; + + return arr; +} + +/** Frees C array after removing all remaining values. Silently ignores NULL arr. */ +void ccCArrayFree(ccCArray *arr) +{ + if( arr == NULL ) + { + return; + } + ccCArrayRemoveAllValues(arr); + + free(arr->arr); + free(arr); +} + +/** Doubles C array capacity */ +void ccCArrayDoubleCapacity(ccCArray *arr) +{ + ccArrayDoubleCapacity((ccArray*)arr); +} + +/** Increases array capacity such that max >= num + extra. */ +void ccCArrayEnsureExtraCapacity(ccCArray *arr, unsigned int extra) +{ + ccArrayEnsureExtraCapacity((ccArray*)arr,extra); +} + +/** Returns index of first occurence of value, CC_INVALID_INDEX if value not found. */ +unsigned int ccCArrayGetIndexOfValue(ccCArray *arr, void* value) +{ + unsigned int i; + + for( i = 0; i < arr->num; i++) + { + if( arr->arr[i] == value ) return i; + } + return CC_INVALID_INDEX; +} + +/** Returns a Boolean value that indicates whether value is present in the C array. */ +bool ccCArrayContainsValue(ccCArray *arr, void* value) +{ + return ccCArrayGetIndexOfValue(arr, value) != CC_INVALID_INDEX; +} + +/** Inserts a value at a certain position. Behaviour undefined if aray doesn't have enough capacity */ +void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, unsigned int index) +{ + CCAssert( index < arr->max, "ccCArrayInsertValueAtIndex: invalid index"); + + unsigned int remaining = arr->num - index; + // make sure it has enough capacity + if (arr->num + 1 == arr->max) + { + ccCArrayDoubleCapacity(arr); + } + // last Value doesn't need to be moved + if( remaining > 0) { + // tex coordinates + memmove((void *)&arr->arr[index+1], (void *)&arr->arr[index], sizeof(void*) * remaining ); + } + + arr->num++; + arr->arr[index] = value; +} + +/** Appends an value. Bahaviour undefined if array doesn't have enough capacity. */ +void ccCArrayAppendValue(ccCArray *arr, void* value) +{ + arr->arr[arr->num] = value; + arr->num++; + // double the capacity for the next append action + // if the num >= max + if (arr->num >= arr->max) + { + ccCArrayDoubleCapacity(arr); + } +} + +/** Appends an value. Capacity of arr is increased if needed. */ +void ccCArrayAppendValueWithResize(ccCArray *arr, void* value) +{ + ccCArrayEnsureExtraCapacity(arr, 1); + ccCArrayAppendValue(arr, value); +} + + +/** Appends values from plusArr to arr. Behaviour undefined if arr doesn't have + enough capacity. */ +void ccCArrayAppendArray(ccCArray *arr, ccCArray *plusArr) +{ + unsigned int i; + + for( i = 0; i < plusArr->num; i++) + { + ccCArrayAppendValue(arr, plusArr->arr[i]); + } +} + +/** Appends values from plusArr to arr. Capacity of arr is increased if needed. */ +void ccCArrayAppendArrayWithResize(ccCArray *arr, ccCArray *plusArr) +{ + ccCArrayEnsureExtraCapacity(arr, plusArr->num); + ccCArrayAppendArray(arr, plusArr); +} + +/** Removes all values from arr */ +void ccCArrayRemoveAllValues(ccCArray *arr) +{ + arr->num = 0; +} + +/** Removes value at specified index and pushes back all subsequent values. + Behaviour undefined if index outside [0, num-1]. + @since v0.99.4 + */ +void ccCArrayRemoveValueAtIndex(ccCArray *arr, unsigned int index) +{ + unsigned int last; + + for( last = --arr->num; index < last; index++) + { + arr->arr[index] = arr->arr[index + 1]; + } +} + +/** Removes value at specified index and fills the gap with the last value, + thereby avoiding the need to push back subsequent values. + Behaviour undefined if index outside [0, num-1]. + @since v0.99.4 + */ +void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, unsigned int index) +{ + unsigned int last = --arr->num; + arr->arr[index] = arr->arr[last]; +} + +/** Searches for the first occurance of value and removes it. If value is not found the function has no effect. + @since v0.99.4 + */ +void ccCArrayRemoveValue(ccCArray *arr, void* value) +{ + unsigned int index = ccCArrayGetIndexOfValue(arr, value); + if (index != CC_INVALID_INDEX) + { + ccCArrayRemoveValueAtIndex(arr, index); + } +} + +/** Removes from arr all values in minusArr. For each Value in minusArr, the first matching instance in arr will be removed. + @since v0.99.4 + */ +void ccCArrayRemoveArray(ccCArray *arr, ccCArray *minusArr) +{ + for(unsigned int i = 0; i < minusArr->num; i++) + { + ccCArrayRemoveValue(arr, minusArr->arr[i]); + } +} + +/** Removes from arr all values in minusArr. For each value in minusArr, all matching instances in arr will be removed. + @since v0.99.4 + */ +void ccCArrayFullRemoveArray(ccCArray *arr, ccCArray *minusArr) +{ + unsigned int back = 0; + + for(unsigned int i = 0; i < arr->num; i++) + { + if( ccCArrayContainsValue(minusArr, arr->arr[i]) ) + { + back++; + } + else + { + arr->arr[i - back] = arr->arr[i]; + } + } + + arr->num -= back; +} + +NS_CC_END diff --git a/cocos2dx/support/data_support/ccCArray.h b/cocos2dx/support/data_support/ccCArray.h index 341a67e446..1ceba49aca 100644 --- a/cocos2dx/support/data_support/ccCArray.h +++ b/cocos2dx/support/data_support/ccCArray.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2007 Scott Lembcke http://www.cocos2d-x.org @@ -23,16 +23,20 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -/** +/** @file - Based on Chipmunk cpArray. - ccArray is a faster alternative to CCMutableArray, it does pretty much the - same thing (stores CCObjects and retains/releases them appropriately). It's + based on Chipmunk cpArray. + ccArray is a faster alternative to NSMutableArray, it does pretty much the + same thing (stores NSObjects and retains/releases them appropriately). It's faster because: - - it uses a plain C interface so it doesn't incur Objective-c messaging overhead + - it uses a plain C interface so it doesn't incur Objective-c messaging overhead - it assumes you know what you're doing, so it doesn't spend time on safety checks - (index out of bounds, required capacity etc.) + (index out of bounds, required capacity etc.) - comparisons are done using pointer equality instead of isEqual + + There are 2 kind of functions: + - ccArray functions that manipulates objective-c objects (retain and release are performanced) + - ccCArray functions that manipulates values like if they were standard C structures (no retain/release is performed) */ #ifndef CC_ARRAY_H @@ -43,465 +47,160 @@ THE SOFTWARE. #include #include "ccMacros.h" #include "CCObject.h" -#include "ccMacros.h" NS_CC_BEGIN - // Easy integration -#define CCARRAYDATA_FOREACH(__array__, __object__) \ - __object__=__array__->arr[0]; for(unsigned int i=0, num=__array__->num; iarr[i]) \ +#define CC_INVALID_INDEX 0xffffffff -typedef struct _ccArray -{ - unsigned int num, max; - CCObject** arr; //equals CCObject** arr; +// Easy integration +#define CCARRAYDATA_FOREACH(__array__, __object__) \ +__object__=__array__->arr[0]; for(unsigned int i=0, num=__array__->num; iarr[i]) \ + + +typedef struct _ccArray { + unsigned int num, max; + CCObject** arr; } ccArray; /** Allocates and initializes a new array with specified capacity */ -static inline ccArray* ccArrayNew(unsigned int capacity) -{ - if (capacity == 0) - { - capacity = 1; - } - - ccArray *arr = (ccArray*)malloc( sizeof(ccArray) ); - arr->num = 0; - - arr->arr = (CCObject**)malloc( capacity * sizeof(CCObject*) ); - arr->max = capacity; - - return arr; -} - -static inline void ccArrayRemoveAllObjects(ccArray *arr); +ccArray* ccArrayNew(unsigned int capacity); /** Frees array after removing all remaining objects. Silently ignores nil arr. */ -static inline void ccArrayFree(ccArray*& arr) -{ - if( arr == NULL ) - { - return; - } - - ccArrayRemoveAllObjects(arr); - - free(arr->arr); - free(arr); - arr = NULL; -} +void ccArrayFree(ccArray*& arr); /** Doubles array capacity */ -static inline void ccArrayDoubleCapacity(ccArray *arr) -{ - arr->max *= 2; - CCObject** newArr = (CCObject**)realloc( arr->arr, arr->max * sizeof(CCObject*) ); - // will fail when there's not enough memory - CCAssert(newArr != 0, "ccArrayDoubleCapacity failed. Not enough memory"); - arr->arr = newArr; -} +void ccArrayDoubleCapacity(ccArray *arr); /** Increases array capacity such that max >= num + extra. */ -static inline void ccArrayEnsureExtraCapacity(ccArray *arr, unsigned int extra) -{ - while (arr->max < arr->num + extra) - { - ccArrayDoubleCapacity(arr); - } -} +void ccArrayEnsureExtraCapacity(ccArray *arr, unsigned int extra); /** shrinks the array so the memory footprint corresponds with the number of items */ -static inline void ccArrayShrink(ccArray *arr) -{ - unsigned int newSize; +void ccArrayShrink(ccArray *arr); - //only resize when necessary - if (arr->max > arr->num && !(arr->num==0 && arr->max==1)) - { - if (arr->num!=0) - { - newSize=arr->num; - arr->max=arr->num; - } - else - {//minimum capacity of 1, with 0 elements the array would be free'd by realloc - newSize=1; - arr->max=1; - } - - arr->arr = (CCObject**) realloc(arr->arr,newSize * sizeof(CCObject*) ); - CCAssert(arr->arr != NULL, "could not reallocate the memory"); - } -} - -/** Returns index of first occurence of object, UXNotFound if object not found. */ -static inline unsigned int ccArrayGetIndexOfObject(ccArray *arr, CCObject* object) -{ - for ( unsigned int i = 0; i < arr->num; i++) - { - if (arr->arr[i] == object) - { - return i; - } - } - - return UINT_MAX; -} +/** Returns index of first occurence of object, NSNotFound if object not found. */ +unsigned int ccArrayGetIndexOfObject(ccArray *arr, CCObject* object); /** Returns a Boolean value that indicates whether object is present in array. */ -static inline bool ccArrayContainsObject(ccArray *arr, CCObject* object) -{ - return ccArrayGetIndexOfObject(arr, object) != UINT_MAX; -} +bool ccArrayContainsObject(ccArray *arr, CCObject* object); /** Appends an object. Bahaviour undefined if array doesn't have enough capacity. */ -static inline void ccArrayAppendObject(ccArray *arr, CCObject* object) -{ - arr->arr[arr->num] = object; object->retain(); - arr->num++; -} +void ccArrayAppendObject(ccArray *arr, CCObject* object); /** Appends an object. Capacity of arr is increased if needed. */ -static inline void ccArrayAppendObjectWithResize(ccArray *arr, CCObject* object) -{ - ccArrayEnsureExtraCapacity(arr, 1); - ccArrayAppendObject(arr, object); -} +void ccArrayAppendObjectWithResize(ccArray *arr, CCObject* object); -/** Appends objects from plusArr to arr. Behaviour undefined if arr doesn't have - enough capacity. */ -static inline void ccArrayAppendArray(ccArray *arr, ccArray *plusArr) -{ - for( unsigned int i = 0; i < plusArr->num; i++) - { - ccArrayAppendObject(arr, plusArr->arr[i]); - } -} +/** Appends objects from plusArr to arr. + Behaviour undefined if arr doesn't have enough capacity. */ +void ccArrayAppendArray(ccArray *arr, ccArray *plusArr); /** Appends objects from plusArr to arr. Capacity of arr is increased if needed. */ -static inline void ccArrayAppendArrayWithResize(ccArray *arr, ccArray *plusArr) -{ - ccArrayEnsureExtraCapacity(arr, plusArr->num); - ccArrayAppendArray(arr, plusArr); -} +void ccArrayAppendArrayWithResize(ccArray *arr, ccArray *plusArr); /** Inserts an object at index */ -static inline void ccArrayInsertObjectAtIndex(ccArray *arr, CCObject* object, unsigned int index) -{ - CCAssert(index<=arr->num, "Invalid index. Out of bounds"); - - ccArrayEnsureExtraCapacity(arr, 1); - - unsigned int remaining = arr->num - index; - if( remaining > 0) - memmove(&arr->arr[index+1], &arr->arr[index], sizeof(CCObject*) * remaining ); - - object->retain(); - arr->arr[index] = object; - arr->num++; -} +void ccArrayInsertObjectAtIndex(ccArray *arr, CCObject* object, unsigned int index); /** Swaps two objects */ -static inline void ccArraySwapObjectsAtIndexes(ccArray *arr, unsigned int index1, unsigned int index2) -{ - CCAssert(index1 < arr->num, "(1) Invalid index. Out of bounds"); - CCAssert(index2 < arr->num, "(2) Invalid index. Out of bounds"); - - CCObject* object1 = arr->arr[index1]; - - arr->arr[index1] = arr->arr[index2]; - arr->arr[index2] = object1; -} +void ccArraySwapObjectsAtIndexes(ccArray *arr, unsigned int index1, unsigned int index2); /** Removes all objects from arr */ -static inline void ccArrayRemoveAllObjects(ccArray *arr) -{ - while(arr->num > 0) - { - arr->arr[--arr->num]->release(); - } -} +void ccArrayRemoveAllObjects(ccArray *arr); /** Removes object at specified index and pushes back all subsequent objects. Behaviour undefined if index outside [0, num-1]. */ -static inline void ccArrayRemoveObjectAtIndex(ccArray *arr, unsigned int index, bool bReleaseObj) -{ - CCAssert(arr && arr->num > 0 && index < arr->num, "Invalid index. Out of bounds"); - if (bReleaseObj) - { - arr->arr[index]->release(); - } - - arr->num--; - - unsigned int remaining = arr->num - index; - if (remaining > 0) - { - memmove(&arr->arr[index], &arr->arr[index+1], remaining * sizeof(void*)); - } -} +void ccArrayRemoveObjectAtIndex(ccArray *arr, unsigned int index, bool bReleaseObj = true); /** Removes object at specified index and fills the gap with the last object, thereby avoiding the need to push back subsequent objects. Behaviour undefined if index outside [0, num-1]. */ -static inline void ccArrayFastRemoveObjectAtIndex(ccArray *arr, unsigned int index) -{ - arr->arr[index]->release(); +void ccArrayFastRemoveObjectAtIndex(ccArray *arr, unsigned int index); - unsigned int last = --arr->num; - arr->arr[index] = arr->arr[last]; -} - -static inline void ccArrayFastRemoveObject(ccArray *arr, CCObject* object) -{ - unsigned int index = ccArrayGetIndexOfObject(arr, object); - if (index != UINT_MAX) - { - ccArrayFastRemoveObjectAtIndex(arr, index); - } -} +void ccArrayFastRemoveObject(ccArray *arr, CCObject* object); /** Searches for the first occurance of object and removes it. If object is not found the function has no effect. */ -static inline void ccArrayRemoveObject(ccArray *arr, CCObject* object, bool bReleaseObj) -{ - unsigned int index = ccArrayGetIndexOfObject(arr, object); - - if (index != UINT_MAX) - { - ccArrayRemoveObjectAtIndex(arr, index, bReleaseObj); - } -} +void ccArrayRemoveObject(ccArray *arr, CCObject* object, bool bReleaseObj = true); /** Removes from arr all objects in minusArr. For each object in minusArr, the first matching instance in arr will be removed. */ -static inline void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr) -{ - for( unsigned int i = 0; i < minusArr->num; i++) - { - ccArrayRemoveObject(arr, minusArr->arr[i], true); - } -} +void ccArrayRemoveArray(ccArray *arr, ccArray *minusArr); /** Removes from arr all objects in minusArr. For each object in minusArr, all matching instances in arr will be removed. */ -static inline void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr) -{ - unsigned int back = 0; - - for( unsigned int i = 0; i < arr->num; i++) - { - if( ccArrayContainsObject(minusArr, arr->arr[i]) ) - { - arr->arr[i]->release(); - back++; - } - else - { - arr->arr[i - back] = arr->arr[i]; - } - } - - arr->num -= back; -} +void ccArrayFullRemoveArray(ccArray *arr, ccArray *minusArr); -typedef struct _ccCArray -{ +// #pragma mark - +// #pragma mark ccCArray for Values (c structures) + +typedef struct _ccCArray { unsigned int num, max; - void** arr; //equals CCObject** arr; + void** arr; } ccCArray; -static inline void ccCArrayRemoveAllValues(ccCArray *arr); - /** Allocates and initializes a new C array with specified capacity */ -static inline ccCArray* ccCArrayNew(unsigned int capacity) -{ - if (capacity == 0) - { - capacity = 1; - } - - ccCArray *arr = (ccCArray*)malloc( sizeof(ccCArray) ); - arr->num = 0; - arr->arr = (void**) malloc( capacity * sizeof(void*) ); - arr->max = capacity; - - return arr; -} +ccCArray* ccCArrayNew(unsigned int capacity); /** Frees C array after removing all remaining values. Silently ignores nil arr. */ -static inline void ccCArrayFree(ccCArray *arr) -{ - if( arr == NULL ) - { - return; - } - - ccCArrayRemoveAllValues(arr); - - free(arr->arr); - free(arr); -} +void ccCArrayFree(ccCArray *arr); /** Doubles C array capacity */ -static inline void ccCArrayDoubleCapacity(ccCArray *arr) -{ - ccArrayDoubleCapacity((ccArray*)arr); -} +void ccCArrayDoubleCapacity(ccCArray *arr); /** Increases array capacity such that max >= num + extra. */ -static inline void ccCArrayEnsureExtraCapacity(ccCArray *arr, unsigned int extra) -{ - ccArrayEnsureExtraCapacity((ccArray*)arr,extra); -} +void ccCArrayEnsureExtraCapacity(ccCArray *arr, unsigned int extra); /** Returns index of first occurence of value, NSNotFound if value not found. */ -static inline int ccCArrayGetIndexOfValue(ccCArray *arr, void* value) -{ - for (unsigned int i = 0; i < arr->num; i++) - { - if (arr->arr[i] == value) - { - return i; - } - } - - return -1; -} +unsigned int ccCArrayGetIndexOfValue(ccCArray *arr, void* value); /** Returns a Boolean value that indicates whether value is present in the C array. */ -static inline bool ccCArrayContainsValue(ccCArray *arr, void* value) -{ - return ccCArrayGetIndexOfValue(arr, value) != -1; -} +bool ccCArrayContainsValue(ccCArray *arr, void* value); -/** Inserts a value at a certain position. The valid index is [0, num] */ -static inline void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, unsigned int index) -{ - CCAssert( index < arr->max, "ccCArrayInsertValueAtIndex: invalid index"); - unsigned int remaining = arr->num - index; +/** Inserts a value at a certain position. Behaviour undefined if aray doesn't have enough capacity */ +void ccCArrayInsertValueAtIndex( ccCArray *arr, void* value, unsigned int index); - // make sure it has enough capacity - if (arr->num + 1 == arr->max) - { - ccCArrayDoubleCapacity(arr); - } - - // last Value doesn't need to be moved - if( remaining > 0) - { - // tex coordinates - memmove( &arr->arr[index+1],&arr->arr[index], sizeof(void*) * remaining ); - } - - arr->num++; - arr->arr[index] = value; -} - -/** Appends an value */ -static inline void ccCArrayAppendValue(ccCArray *arr, void* value) -{ - arr->arr[arr->num] = value; - arr->num++; - - // double the capacity for the next append action - // if the num >= max - if (arr->num >= arr->max) - { - ccCArrayDoubleCapacity(arr); - } -} +/** Appends an value. Bahaviour undefined if array doesn't have enough capacity. */ +void ccCArrayAppendValue(ccCArray *arr, void* value); /** Appends an value. Capacity of arr is increased if needed. */ -static inline void ccCArrayAppendValueWithResize(ccCArray *arr, void* value) -{ - ccCArrayEnsureExtraCapacity(arr, 1); - ccCArrayAppendValue(arr, value); -} +void ccCArrayAppendValueWithResize(ccCArray *arr, void* value); /** Appends values from plusArr to arr. Behaviour undefined if arr doesn't have enough capacity. */ -static inline void ccCArrayAppendArray(ccCArray *arr, ccCArray *plusArr) -{ - for (unsigned int i = 0; i < plusArr->num; i++) - { - ccCArrayAppendValue(arr, plusArr->arr[i]); - } -} +void ccCArrayAppendArray(ccCArray *arr, ccCArray *plusArr); /** Appends values from plusArr to arr. Capacity of arr is increased if needed. */ -static inline void ccCArrayAppendArrayWithResize(ccCArray *arr, ccCArray *plusArr) -{ - ccCArrayEnsureExtraCapacity(arr, plusArr->num); - ccCArrayAppendArray(arr, plusArr); -} +void ccCArrayAppendArrayWithResize(ccCArray *arr, ccCArray *plusArr); /** Removes all values from arr */ -static inline void ccCArrayRemoveAllValues(ccCArray *arr) -{ - arr->num = 0; -} +void ccCArrayRemoveAllValues(ccCArray *arr); /** Removes value at specified index and pushes back all subsequent values. - Behaviour undefined if index outside [0, num-1]. */ -static inline void ccCArrayRemoveValueAtIndex(ccCArray *arr, unsigned int index) -{ - for (unsigned int last = --arr->num; index < last; index++) - { - arr->arr[index] = arr->arr[index + 1]; - } -} + Behaviour undefined if index outside [0, num-1]. + @since v0.99.4 + */ +void ccCArrayRemoveValueAtIndex(ccCArray *arr, unsigned int index); /** Removes value at specified index and fills the gap with the last value, thereby avoiding the need to push back subsequent values. - Behaviour undefined if index outside [0, num-1]. */ -static inline void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, unsigned int index) -{ - unsigned int last = --arr->num; - arr->arr[index] = arr->arr[last]; -} + Behaviour undefined if index outside [0, num-1]. + @since v0.99.4 + */ +void ccCArrayFastRemoveValueAtIndex(ccCArray *arr, unsigned int index); -/** Searches for the first occurance of value and removes it. If value is not - found the function has no effect. */ -static inline void ccCArrayRemoveValue(ccCArray *arr, void* value) -{ - unsigned int index = ccCArrayGetIndexOfValue(arr, value); - if (index != UINT_MAX) - { - ccCArrayRemoveValueAtIndex(arr, index); - } -} +/** Searches for the first occurance of value and removes it. If value is not found the function has no effect. + @since v0.99.4 + */ +void ccCArrayRemoveValue(ccCArray *arr, void* value); -/** Removes from arr all values in minusArr. For each Value in minusArr, the - first matching instance in arr will be removed. */ -static inline void ccCArrayRemoveArray(ccCArray *arr, ccCArray *minusArr) -{ - for( unsigned int i = 0; i < minusArr->num; i++) - { - ccCArrayRemoveValue(arr, minusArr->arr[i]); - } -} +/** Removes from arr all values in minusArr. For each Value in minusArr, the first matching instance in arr will be removed. + @since v0.99.4 + */ +void ccCArrayRemoveArray(ccCArray *arr, ccCArray *minusArr); -/** Removes from arr all values in minusArr. For each value in minusArr, all - matching instances in arr will be removed. */ -static inline void ccCArrayFullRemoveArray(ccCArray *arr, ccCArray *minusArr) -{ - unsigned int back = 0; - - for (unsigned int i = 0; i < arr->num; i++) - { - if( ccCArrayContainsValue(minusArr, arr->arr[i]) ) - { - back++; - } else - { - arr->arr[i - back] = arr->arr[i]; - } - } - - arr->num -= back; -} +/** Removes from arr all values in minusArr. For each value in minusArr, all matching instances in arr will be removed. + @since v0.99.4 + */ +void ccCArrayFullRemoveArray(ccCArray *arr, ccCArray *minusArr); NS_CC_END - + #endif // CC_ARRAY_H diff --git a/cocos2dx/support/image_support/TGAlib.cpp b/cocos2dx/support/image_support/TGAlib.cpp index 2892a420b9..9cfce7ffe6 100644 --- a/cocos2dx/support/image_support/TGAlib.cpp +++ b/cocos2dx/support/image_support/TGAlib.cpp @@ -30,7 +30,7 @@ THE SOFTWARE. namespace cocos2d { -void tgaLoadRLEImageData(FILE *file, tImageTGA *info); +static bool tgaLoadRLEImageData(unsigned char* Buffer, unsigned long bufSize, tImageTGA *psInfo); void tgaFlipImage( tImageTGA *info ); // load the image header field from stream @@ -197,9 +197,9 @@ tImageTGA * tgaLoad(const char *pszFilename) { int mode,total; tImageTGA *info = NULL; - CCFileData data(pszFilename, "rb"); - unsigned long nSize = data.getSize(); - unsigned char* pBuffer = data.getBuffer(); + + unsigned long nSize; + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(pszFilename, "rb", &nSize); do { diff --git a/cocos2dx/support/zip_support/ZipUtils.cpp b/cocos2dx/support/zip_support/ZipUtils.cpp index 44666378df..f8217f7639 100644 --- a/cocos2dx/support/zip_support/ZipUtils.cpp +++ b/cocos2dx/support/zip_support/ZipUtils.cpp @@ -217,8 +217,8 @@ namespace cocos2d unsigned char *compressed = NULL; int fileLen = 0; - compressed = CCFileUtils::getFileData(path, "rb", (unsigned long *)(&fileLen)); - // int fileLen = CCFileUtils::ccLoadFileIntoMemory( path, &compressed ); + compressed = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(path, "rb", (unsigned long *)(&fileLen)); + // int fileLen = CCFileUtils::sharedFileUtils()->ccLoadFileIntoMemory( path, &compressed ); if( fileLen < 0 ) { diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index 9bbc5feeaf..907c83e470 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008 Apple Inc. All Rights Reserved. http://www.cocos2d-x.org @@ -45,7 +45,7 @@ THE SOFTWARE. #include "ccGLStateCache.h" #include "CCShaderCache.h" -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA #include "CCTextureCache.h" #endif @@ -71,6 +71,7 @@ CCTexture2D::CCTexture2D() , m_fMaxS(0.0) , m_fMaxT(0.0) , m_bHasPremultipliedAlpha(false) +, m_bHasMipmaps(false) , m_bPVRHaveAlphaPremultiplied(true) , m_pShaderProgram(NULL) { @@ -78,7 +79,7 @@ CCTexture2D::CCTexture2D() CCTexture2D::~CCTexture2D() { -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA VolatileTexture::removeTexture(this); #endif @@ -177,11 +178,23 @@ bool CCTexture2D::getHasPremultipliedAlpha() bool CCTexture2D::initWithData(const void *data, CCTexture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const CCSize& contentSize) { - glPixelStorei(GL_UNPACK_ALIGNMENT,1); + // XXX: 32 bits or POT textures uses UNPACK of 4 (is this correct ??? ) + if( pixelFormat == kCCTexture2DPixelFormat_RGBA8888 || ( ccNextPOT(pixelsWide)==pixelsWide && ccNextPOT(pixelsHigh)==pixelsHigh) ) + { + glPixelStorei(GL_UNPACK_ALIGNMENT,4); + } + else + { + glPixelStorei(GL_UNPACK_ALIGNMENT,1); + } + glGenTextures(1, &m_uName); ccGLBindTexture2D(m_uName); - this->setAntiAliasTexParameters(); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); // Specify OpenGL texture image @@ -224,6 +237,7 @@ bool CCTexture2D::initWithData(const void *data, CCTexture2DPixelFormat pixelFor m_fMaxT = contentSize.height / (float)(pixelsHigh); m_bHasPremultipliedAlpha = false; + m_bHasMipmaps = false; m_eResolutionType = kCCResolutionUnknown; setShaderProgram(CCShaderCache::sharedShaderCache()->programForKey(kCCShader_PositionTexture)); @@ -413,20 +427,46 @@ bool CCTexture2D::initPremultipliedATextureWithImage(CCImage *image, unsigned in // implementation CCTexture2D (Text) bool CCTexture2D::initWithString(const char *text, const char *fontName, float fontSize) { - return initWithString(text, CCSizeMake(0,0), CCTextAlignmentCenter, fontName, fontSize); + return initWithString(text, CCSizeMake(0,0), kCCTextAlignmentCenter, kCCVerticalTextAlignmentTop, kCCLineBreakModeWordWrap, fontName, fontSize); } -bool CCTexture2D::initWithString(const char *text, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize) + +bool CCTexture2D::initWithString(const char *text, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize) { -#if CC_ENABLE_CACHE_TEXTTURE_DATA + return initWithString(text, dimensions, hAlignment, vAlignment, kCCLineBreakModeWordWrap, fontName, fontSize); +} + +bool CCTexture2D::initWithString(const char *text, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, CCLineBreakMode lineBreakMode, const char *fontName, float fontSize) +{ +#if CC_ENABLE_CACHE_TEXTURE_DATA // cache the texture data VolatileTexture::addStringTexture(this, text, dimensions, alignment, fontName, fontSize); #endif CCImage image; - CCImage::ETextAlign eAlign = (CCTextAlignmentCenter == alignment) ? CCImage::kAlignCenter - : (CCTextAlignmentLeft == alignment) ? CCImage::kAlignLeft : CCImage::kAlignRight; + + CCImage::ETextAlign eAlign; + + if (kCCVerticalTextAlignmentTop == vAlignment) + { + eAlign = (kCCTextAlignmentCenter == hAlignment) ? CCImage::kAlignTop + : (kCCTextAlignmentLeft == hAlignment) ? CCImage::kAlignTopLeft : CCImage::kAlignTopRight; + } + else if (kCCVerticalTextAlignmentCenter == vAlignment) + { + eAlign = (kCCTextAlignmentCenter == hAlignment) ? CCImage::kAlignCenter + : (kCCTextAlignmentLeft == hAlignment) ? CCImage::kAlignLeft : CCImage::kAlignRight; + } + else if (kCCVerticalTextAlignmentBottom == vAlignment) + { + eAlign = (kCCTextAlignmentCenter == hAlignment) ? CCImage::kAlignBottom + : (kCCTextAlignmentLeft == hAlignment) ? CCImage::kAlignBottomLeft : CCImage::kAlignBottomRight; + } + else + { + CCAssert(false, "Not supported alignment format!"); + } - if (! image.initWithString(text, (int)dimensions.width, (int)dimensions.height, eAlign, fontName, (int)fontSize)) + if (!image.initWithString(text, (int)dimensions.width, (int)dimensions.height, eAlign, fontName, (int)fontSize)) { return false; } @@ -551,8 +591,8 @@ bool CCTexture2D::initWithPVRFile(const char* file) m_tContentSize = CCSizeMake((float)m_uPixelsWide, (float)m_uPixelsHigh); m_bHasPremultipliedAlpha = PVRHaveAlphaPremultiplied_; m_ePixelFormat = pvr->getFormat(); - - this->setAntiAliasTexParameters(); + m_bHasMipmaps = pvr->getNumberOfMipmaps() > 1; + pvr->release(); } else @@ -579,13 +619,15 @@ void CCTexture2D::generateMipmap() CCAssert( m_uPixelsWide == ccNextPOT(m_uPixelsWide) && m_uPixelsHigh == ccNextPOT(m_uPixelsHigh), "Mimpap texture only works in POT textures"); ccGLBindTexture2D( m_uName ); glGenerateMipmap(GL_TEXTURE_2D); + m_bHasMipmaps = true; } void CCTexture2D::setTexParameters(ccTexParams *texParams) { - CCAssert( (m_uPixelsWide == ccNextPOT(m_uPixelsWide) && m_uPixelsHigh == ccNextPOT(m_uPixelsHigh)) || - (texParams->wrapS == GL_CLAMP_TO_EDGE && texParams->wrapT == GL_CLAMP_TO_EDGE), - "GL_CLAMP_TO_EDGE should be used in NPOT textures"); + CCAssert( (m_uPixelsWide == ccNextPOT(m_uPixelsWide) || texParams->wrapS == GL_CLAMP_TO_EDGE) && + (m_uPixelsHigh == ccNextPOT(m_uPixelsHigh) || texParams->wrapT == GL_CLAMP_TO_EDGE), + "GL_CLAMP_TO_EDGE should be used in NPOT dimensions"); + ccGLBindTexture2D( m_uName ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texParams->minFilter ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texParams->magFilter ); @@ -595,14 +637,34 @@ void CCTexture2D::setTexParameters(ccTexParams *texParams) void CCTexture2D::setAliasTexParameters() { - ccTexParams texParams = { GL_NEAREST, GL_NEAREST, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE }; - this->setTexParameters(&texParams); + ccGLBindTexture2D( m_uName ); + + if( ! m_bHasMipmaps ) + { + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + } + else + { + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST ); + } + + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); } void CCTexture2D::setAntiAliasTexParameters() { - ccTexParams texParams = { GL_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE }; - this->setTexParameters(&texParams); + ccGLBindTexture2D( m_uName ); + + if( ! m_bHasMipmaps ) + { + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + } + else + { + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST ); + } + + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); } // @@ -655,7 +717,8 @@ unsigned int CCTexture2D::bitsPerPixelForFormat() ret = 16; break; case kCCTexture2DPixelFormat_RGB888: - ret = 24; + // It is 32 and not 24, since its internal representation uses 32 bits. + ret = 32; break; default: ret = -1; diff --git a/cocos2dx/textures/CCTexture2D.h b/cocos2dx/textures/CCTexture2D.h index 08e08ed0f1..1e5aea7c62 100644 --- a/cocos2dx/textures/CCTexture2D.h +++ b/cocos2dx/textures/CCTexture2D.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (C) 2008 Apple Inc. All Rights Reserved. http://www.cocos2d-x.org @@ -41,7 +41,7 @@ class CCImage; Possible texture pixel formats */ typedef enum { - kCCTexture2DPixelFormat_Automatic = 0, + //! 32-bit texture: RGBA8888 kCCTexture2DPixelFormat_RGBA8888, //! 24-bit texture: RGBA888 @@ -67,7 +67,6 @@ typedef enum { kCCTexture2DPixelFormat_Default = kCCTexture2DPixelFormat_RGBA8888, // backward compatibility stuff - kTexture2DPixelFormat_Automatic = kCCTexture2DPixelFormat_Automatic, kTexture2DPixelFormat_RGBA8888 = kCCTexture2DPixelFormat_RGBA8888, kTexture2DPixelFormat_RGB888 = kCCTexture2DPixelFormat_RGB888, kTexture2DPixelFormat_RGB565 = kCCTexture2DPixelFormat_RGB565, @@ -136,8 +135,10 @@ public: Extensions to make it easy to create a CCTexture2D object from a string of text. Note that the generated textures are of type A8 - use the blending mode (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA). */ + + bool initWithString(const char *text, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, CCLineBreakMode lineBreakMode, const char *fontName, float fontSize); /** Initializes a texture from a string with dimensions, alignment, font name and font size */ - bool initWithString(const char *text, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize); + bool initWithString(const char *text, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize); /** Initializes a texture from a string with font name and font size */ bool initWithString(const char *text, const char *fontName, float fontSize); @@ -155,6 +156,9 @@ public: /** sets the min filter, mag filter, wrap s and wrap t texture parameters. If the texture size is NPOT (non power of 2), then in can only use GL_CLAMP_TO_EDGE in GL_TEXTURE_WRAP_{S,T}. + + @warning Calling this method could allocate additional texture memory. + @since v0.8 */ void setTexParameters(ccTexParams* texParams); @@ -163,6 +167,8 @@ public: - GL_TEXTURE_MIN_FILTER = GL_LINEAR - GL_TEXTURE_MAG_FILTER = GL_LINEAR + @warning Calling this method could allocate additional texture memory. + @since v0.8 */ void setAntiAliasTexParameters(); @@ -171,6 +177,8 @@ public: - GL_TEXTURE_MIN_FILTER = GL_NEAREST - GL_TEXTURE_MAG_FILTER = GL_NEAREST + @warning Calling this method could allocate additional texture memory. + @since v0.8 */ void setAliasTexParameters(); @@ -187,6 +195,17 @@ public: */ unsigned int bitsPerPixelForFormat(); + /** returns the pixel format in a NSString. + @since v2.0 + */ + CCString* stringForFormat(); + + + /** Helper functions that returns bits per pixels for a given format. + @since v2.0 + */ + unsigned int bitsPerPixelForFormat(CCTexture2DPixelFormat format); + /** sets the default pixel format for UIImagescontains alpha channel. If the UIImage contains alpha channel, then the options are: - generate 32-bit textures: kCCTexture2DPixelFormat_RGBA8888 (default one) @@ -198,7 +217,9 @@ public: How does it work ? - If the image is an RGBA (with Alpha) then the default pixel format will be used (it can be a 8-bit, 16-bit or 32-bit texture) - - If the image is an RGB (without Alpha) then an RGB565 or RGB888 texture will be used (16-bit texture) + - If the image is an RGB (without Alpha) then: If the default pixel format is RGBA8888 then a RGBA8888 (32-bit) will be used. Otherwise a RGB565 (16-bit texture) will be used. + + This parameter is not valid for PVR / PVR.CCZ images. @since v0.8 */ @@ -247,6 +268,8 @@ private: /** whether or not the texture has their Alpha premultiplied */ CC_PROPERTY_READONLY(bool, m_bHasPremultipliedAlpha, HasPremultipliedAlpha); + CC_SYNTHESIZE_READONLY(bool, m_bHasMipmaps, HasMipmaps); + /** shader program used by drawAtPoint and drawInRect */ CC_PROPERTY(CCGLProgram*, m_pShaderProgram, ShaderProgram); diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index 5fc57f22c7..8bb6cf5fe1 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -258,9 +258,9 @@ void CCTextureCache::addImageAsync(const char *path, CCObject *target, SEL_CallF // optimization std::string pathKey = path; - CCFileUtils::removeSuffixFromFile(pathKey); + CCFileUtils::sharedFileUtils()->removeSuffixFromFile(pathKey); - pathKey = CCFileUtils::fullPathFromRelativePath(pathKey.c_str()); + pathKey = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pathKey.c_str()); texture = (CCTexture2D*)m_pTextures->objectForKey(pathKey.c_str()); std::string fullpath = pathKey; @@ -330,7 +330,7 @@ void CCTextureCache::addImageAsync(const char *path, CCObject *target, SEL_CallF sem_post(s_pSem); } -void CCTextureCache::addImageAsyncCallBack(ccTime dt) +void CCTextureCache::addImageAsyncCallBack(float dt) { // the image is generated in loading thread std::queue *imagesQueue = s_pImageQueue; @@ -361,7 +361,7 @@ void CCTextureCache::addImageAsyncCallBack(ccTime dt) texture->initWithImage(pImage); #endif -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA // cache the texture file name VolatileTexture::addImageTexture(texture, filename, pImageInfo->imageType); #endif @@ -402,12 +402,12 @@ CCTexture2D * CCTextureCache::addImage(const char * path) // remove possible -HD suffix to prevent caching the same image twice (issue #1040) std::string pathKey = path; ccResolutionType resolution = kCCResolutionUnknown; - CCFileUtils::removeSuffixFromFile(pathKey); + CCFileUtils::sharedFileUtils()->removeSuffixFromFile(pathKey); - pathKey = CCFileUtils::fullPathFromRelativePath(pathKey.c_str()); + pathKey = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pathKey.c_str()); texture = (CCTexture2D*)m_pTextures->objectForKey(pathKey.c_str()); - std::string fullpath = pathKey; // (CCFileUtils::fullPathFromRelativePath(path)); + std::string fullpath = pathKey; // (CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(path)); if( ! texture ) { std::string lowerCase(path); @@ -438,10 +438,9 @@ CCTexture2D * CCTextureCache::addImage(const char * path) eImageFormat = CCImage::kFmtTiff; } - CCImage image; - CCFileData data(fullpath.c_str(), "rb"); - unsigned long nSize = data.getSize(); - unsigned char* pBuffer = data.getBuffer(); + CCImage image; + unsigned long nSize; + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(fullpath.c_str(), "rb", &nSize); CC_BREAK_IF(! image.initWithImageData((void*)pBuffer, nSize, eImageFormat)); texture = new CCTexture2D(); @@ -449,7 +448,7 @@ CCTexture2D * CCTextureCache::addImage(const char * path) if( texture ) { -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA // cache the texture file name VolatileTexture::addImageTexture(texture, fullpath.c_str(), eImageFormat); #endif @@ -479,7 +478,7 @@ CCTexture2D* CCTextureCache::addPVRTCImage(const char* path, int bpp, bool hasAl CCTexture2D * texture; std::string temp(path); - CCFileUtils::removeSuffixFromFile(temp); + CCFileUtils::sharedFileUtils()->removeSuffixFromFile(temp); if ( (texture = (CCTexture2D*)m_pTextures->objectForKey(temp.c_str())) ) { @@ -487,7 +486,7 @@ CCTexture2D* CCTextureCache::addPVRTCImage(const char* path, int bpp, bool hasAl } // Split up directory and filename - std::string fullpath( CCFileUtils::fullPathFromRelativePath(path) ); + std::string fullpath( CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(path) ); CCData * data = CCData::dataWithContentsOfFile(fullpath); texture = new CCTexture2D(); @@ -515,7 +514,7 @@ CCTexture2D * CCTextureCache::addPVRImage(const char* path) CCTexture2D* tex = NULL; std::string key(path); // remove possible -HD suffix to prevent caching the same image twice (issue #1040) - CCFileUtils::removeSuffixFromFile(key); + CCFileUtils::sharedFileUtils()->removeSuffixFromFile(key); if( (tex = (CCTexture2D*)m_pTextures->objectForKey(key.c_str())) ) { @@ -523,11 +522,11 @@ CCTexture2D * CCTextureCache::addPVRImage(const char* path) } // Split up directory and filename - std::string fullpath = CCFileUtils::fullPathFromRelativePath(key.c_str()); + std::string fullpath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(key.c_str()); tex = new CCTexture2D(); if(tex != NULL && tex->initWithPVRFile(fullpath.c_str()) ) { -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA // cache the texture file name VolatileTexture::addImageTexture(tex, fullpath.c_str(), CCImage::kFmtRawData); #endif @@ -552,7 +551,7 @@ CCTexture2D* CCTextureCache::addUIImage(CCImage *image, const char *key) std::string forKey; if (key) { - forKey = CCFileUtils::fullPathFromRelativePath(key); + forKey = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(key); } // Don't have to lock here, because addImageAsync() will not @@ -582,7 +581,7 @@ CCTexture2D* CCTextureCache::addUIImage(CCImage *image, const char *key) } while (0); -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA VolatileTexture::addCCImage(texture, image); #endif @@ -656,18 +655,18 @@ void CCTextureCache::removeTextureForKey(const char *textureKeyName) return; } - string fullPath = CCFileUtils::fullPathFromRelativePath(textureKeyName); + string fullPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(textureKeyName); m_pTextures->removeObjectForKey(fullPath.c_str()); } CCTexture2D* CCTextureCache::textureForKey(const char* key) { - return (CCTexture2D*)m_pTextures->objectForKey(CCFileUtils::fullPathFromRelativePath(key)); + return (CCTexture2D*)m_pTextures->objectForKey(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(key)); } void CCTextureCache::reloadAllTextures() { -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA VolatileTexture::reloadAllTextures(); #endif } @@ -699,7 +698,7 @@ void CCTextureCache::dumpCachedTextureInfo() CCLOG("cocos2d: CCTextureCache dumpDebugInfo: %ld textures, for %lu KB (%.2f MB)", (long)count, (long)totalBytes / 1024, totalBytes / (1024.0f*1024.0f)); } -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA std::list VolatileTexture::textures; bool VolatileTexture::isReloading = false; @@ -851,9 +850,9 @@ void VolatileTexture::reloadAllTextures() } else { - CCFileData data(vt->m_strFileName.c_str(), "rb"); - unsigned long nSize = data.getSize(); - unsigned char* pBuffer = data.getBuffer(); + unsigned long nSize; + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(vt->m_strFileName.c_str(), "rb", &nSize); + if (image.initWithImageData((void*)pBuffer, nSize, vt->m_FmtImage)) { @@ -897,7 +896,7 @@ void VolatileTexture::reloadAllTextures() isReloading = false; } -#endif // CC_ENABLE_CACHE_TEXTTURE_DATA +#endif // CC_ENABLE_CACHE_TEXTURE_DATA NS_CC_END diff --git a/cocos2dx/textures/CCTextureCache.h b/cocos2dx/textures/CCTextureCache.h index 1ed542a5ed..def606d5ef 100644 --- a/cocos2dx/textures/CCTextureCache.h +++ b/cocos2dx/textures/CCTextureCache.h @@ -33,7 +33,7 @@ THE SOFTWARE. #include "CCTexture2D.h" -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA #include "CCImage.h" #include #endif @@ -56,7 +56,7 @@ protected: private: // @todo void addImageWithAsyncObject(CCAsyncObject* async); - void addImageAsyncCallBack(ccTime dt); + void addImageAsyncCallBack(float dt); public: @@ -163,12 +163,12 @@ public: CCTexture2D* addPVRImage(const char* filename); /** Reload all textures - It's only useful when the value of CC_ENABLE_CACHE_TEXTTURE_DATA is 1 + It's only useful when the value of CC_ENABLE_CACHE_TEXTURE_DATA is 1 */ static void reloadAllTextures(); }; -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA class VolatileTexture { diff --git a/cocos2dx/textures/CCTexturePVR.cpp b/cocos2dx/textures/CCTexturePVR.cpp index ad3edf450e..c330117d4e 100755 --- a/cocos2dx/textures/CCTexturePVR.cpp +++ b/cocos2dx/textures/CCTexturePVR.cpp @@ -33,7 +33,7 @@ THE SOFTWARE. #include "CCStdC.h" #include "CCFileUtils.h" #include "support/zip_support/ZipUtils.h" - +#include "ccGLStateCache.h" #include NS_CC_BEGIN @@ -371,7 +371,7 @@ bool CCTexturePVR::createGLTexture() { if (m_uName != 0) { - glDeleteTextures(1, &m_uName); + ccGLDeleteTexture(m_uName); } glGenTextures(1, &m_uName); @@ -446,7 +446,7 @@ bool CCTexturePVR::initWithContentsOfFile(const char* path) } else { - pvrdata = CCFileUtils::getFileData(path, "rb", (unsigned long *)(&pvrlen)); + pvrdata = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(path, "rb", (unsigned long *)(&pvrlen)); } if (pvrlen < 0) diff --git a/cocos2dx/textures/CCTexturePVR.h b/cocos2dx/textures/CCTexturePVR.h index cc66451f20..c56ccd1f9b 100644 --- a/cocos2dx/textures/CCTexturePVR.h +++ b/cocos2dx/textures/CCTexturePVR.h @@ -123,7 +123,7 @@ protected: How many mipmaps do we have. It must be at least one when proper initialization finishes */ - unsigned int m_uNumberOfMipmaps; + CC_SYNTHESIZE_READONLY(unsigned int, m_uNumberOfMipmaps, NumberOfMipmaps); /* Makrs for mipmaps. Each entry contains position in file diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp index c419aa541a..62b5b67a0a 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp @@ -238,27 +238,52 @@ void CCTMXLayer::setupTileSprite(CCSprite* sprite, CCPoint pos, unsigned int gid sprite->setOpacity(m_cOpacity); //issue 1264, flip can be undone as well - if (gid & kCCTMXTileHorizontalFlag) - { - sprite->setFlipX(true); - } - else - { - sprite->setFlipX(false); - } - - if (gid & kCCTMXTileVerticalFlag) - { - sprite->setFlipY(true); - } - else - { - sprite->setFlipY(false); - } - - if( gid & kCCTMXTileDiagonalFlag) - { - CCAssert(false, "Tiled Anti-Diagonally Flip not supported yet"); + sprite->setFlipX(false); + sprite->setFlipX(false); + sprite->setRotation(0.0f); + sprite->setAnchorPoint(ccp(0,0)); + + // Rotation in tiled is achieved using 3 flipped states, flipping across the horizontal, vertical, and diagonal axes of the tiles. + if (gid & kCCTMXTileDiagonalFlag) + { + // put the anchor in the middle for ease of rotation. + sprite->setAnchorPoint(ccp(0.5f,0.5f)); + sprite->setPosition(ccp(positionAt(pos).x + sprite->getContentSize().height/2, + positionAt(pos).y + sprite->getContentSize().width/2 ) ); + + unsigned int flag = gid & (kCCTMXTileHorizontalFlag | kCCTMXTileVerticalFlag ); + + // handle the 4 diagonally flipped states. + if (flag == kCCTMXTileHorizontalFlag) + { + sprite->setRotation(90.0f); + } + else if (flag == kCCTMXTileVerticalFlag) + { + sprite->setRotation(270.0f); + } + else if (flag == (kCCTMXTileVerticalFlag | kCCTMXTileHorizontalFlag) ) + { + sprite->setRotation(90.0f); + sprite->setFlipX(true); + } + else + { + sprite->setRotation(270.0f); + sprite->setFlipX(true); + } + } + else + { + if (gid & kCCTMXTileHorizontalFlag) + { + sprite->setFlipX(true); + } + + if (gid & kCCTMXTileVerticalFlag) + { + sprite->setFlipY(true); + } } } diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h index e831c12cf4..86d2331bd8 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h @@ -186,7 +186,7 @@ protected: //! used for optimization CCSprite *m_pReusedTile; - _ccCArray *m_pAtlasIndexArray; + ccCArray *m_pAtlasIndexArray; // used for retina display float m_fContentScaleFactor; diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp index 29ee6d50e5..d4fd318ced 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp @@ -146,7 +146,7 @@ CCTMXTilesetInfo * CCTMXTiledMap::tilesetForLayer(CCTMXLayerInfo *layerInfo, CCT { CCTMXTilesetInfo* tileset = NULL; CCObject* pObj = NULL; - CCARRAY_FOREACH_REVERSE(tilesets, pObj); + CCARRAY_FOREACH_REVERSE(tilesets, pObj) { tileset = (CCTMXTilesetInfo*)pObj; if (tileset) diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp index 633a6a7fb7..b32a1011d1 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp @@ -158,7 +158,7 @@ void CCTMXMapInfo::internalInit(const char* tmxFileName, const char* resourcePat if (tmxFileName != NULL) { - m_sTMXFileName = CCFileUtils::fullPathFromRelativePath(tmxFileName); + m_sTMXFileName = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(tmxFileName); } if (resourcePath != NULL) @@ -287,6 +287,7 @@ bool CCTMXMapInfo::parseXMLString(const char *xmlString) bool CCTMXMapInfo::parseXMLData(const CCData* data) { //TODO: implementation. + CCAssert(false, "not implement!"); return false; } @@ -358,17 +359,17 @@ void CCTMXMapInfo::startElement(void *ctx, const char *name, const char **atts) { if (m_sTMXFileName.length() == 0) { - string pszFullPath = CCFileUtils::fullPathFromRelativePath(m_sResources.c_str()); + string pszFullPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(m_sResources.c_str()); if (pszFullPath.find_last_of("/\\") != pszFullPath.length()-1) { pszFullPath.append("/"); } - externalTilesetFilename = CCFileUtils::fullPathFromRelativeFile(externalTilesetFilename.c_str(), pszFullPath.c_str() ); + externalTilesetFilename = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(externalTilesetFilename.c_str(), pszFullPath.c_str() ); } else { - externalTilesetFilename = CCFileUtils::fullPathFromRelativeFile(externalTilesetFilename.c_str(), pTMXMapInfo->getTMXFileName()); + externalTilesetFilename = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(externalTilesetFilename.c_str(), pTMXMapInfo->getTMXFileName()); } pTMXMapInfo->parseXMLFile(externalTilesetFilename.c_str()); } @@ -457,17 +458,17 @@ void CCTMXMapInfo::startElement(void *ctx, const char *name, const char **atts) std::string imagename = valueForKey("source", attributeDict); if (m_sTMXFileName.length() == 0) { - string pszFullPath = CCFileUtils::fullPathFromRelativePath(m_sResources.c_str()); + string pszFullPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(m_sResources.c_str()); if (pszFullPath.find_last_of("/\\") != pszFullPath.length()-1) { pszFullPath.append("/"); } - tileset->m_sSourceImage = CCFileUtils::fullPathFromRelativeFile(imagename.c_str(), pszFullPath.c_str() ); + tileset->m_sSourceImage = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(imagename.c_str(), pszFullPath.c_str() ); } else { - tileset->m_sSourceImage = CCFileUtils::fullPathFromRelativeFile(imagename.c_str(), pTMXMapInfo->getTMXFileName()); + tileset->m_sSourceImage = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(imagename.c_str(), pTMXMapInfo->getTMXFileName()); } } else if(elementName == "data") diff --git a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp index 295f650c06..29e6085e4f 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp @@ -115,12 +115,14 @@ void CCTileMapAtlas::loadTGAfile(const char *file) { CCAssert( file != NULL, "file must be non-nil"); + const char* pPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(file); + // //Find the path of the file // NSBundle *mainBndl = [CCDirector sharedDirector].loadingBundle; // CCString *resourcePath = [mainBndl resourcePath]; // CCString * path = [resourcePath stringByAppendingPathComponent:file]; - m_pTGAInfo = tgaLoad( CCFileUtils::fullPathFromRelativePath(file) ); + m_pTGAInfo = tgaLoad( pPath ); #if 1 if( m_pTGAInfo->status != TGA_OK ) { diff --git a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp index f5a03f915c..544276241c 100644 --- a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp +++ b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp @@ -38,12 +38,11 @@ NS_CC_BEGIN /** * Used for sort */ -static int less(const void* p1, const void* p2) +static int less(const CCObject* p1, const CCObject* p2) { - return ((cocos2d::CCTouchHandler*)p1)->getPriority() < ((cocos2d::CCTouchHandler*)p2)->getPriority() ? 1 : -1; + return ((CCTouchHandler*)p1)->getPriority() < ((CCTouchHandler*)p2)->getPriority(); } - bool CCTouchDispatcher::isDispatchEvents(void) { return m_bDispatchEvents; @@ -293,8 +292,7 @@ CCTouchHandler* CCTouchDispatcher::findHandler(CCArray* pArray, CCTouchDelegate void CCTouchDispatcher::rearrangeHandlers(CCArray *pArray) { - // FIXME: qsort is not supported in bada1.0, so we must implement it ourselves. - qsort(pArray->data->arr, pArray->data->num, sizeof(pArray->data->arr[0]), less); + std::sort(pArray->data->arr, pArray->data->arr + pArray->data->num, less); } void CCTouchDispatcher::setPriority(int nPriority, CCTouchDelegate *pDelegate) @@ -306,11 +304,13 @@ void CCTouchDispatcher::setPriority(int nPriority, CCTouchDelegate *pDelegate) handler = this->findHandler(pDelegate); CCAssert(handler != NULL, ""); - - handler->setPriority(nPriority); - - this->rearrangeHandlers(m_pTargetedHandlers); - this->rearrangeHandlers(m_pStandardHandlers); + + if (handler->getPriority() != nPriority) + { + handler->setPriority(nPriority); + this->rearrangeHandlers(m_pTargetedHandlers); + this->rearrangeHandlers(m_pStandardHandlers); + } } // diff --git a/lua/proj.win32/liblua.vcproj b/lua/proj.win32/liblua.vcproj index b6313e9e57..08898e3c93 100644 --- a/lua/proj.win32/liblua.vcproj +++ b/lua/proj.win32/liblua.vcproj @@ -21,7 +21,7 @@ OutputDirectory="$(SolutionDir)$(ConfigurationName).win32" IntermediateDirectory="$(ConfigurationName).win32" ConfigurationType="4" - CharacterSet="2" + CharacterSet="1" > StaticLibrary - MultiByte + Unicode true StaticLibrary - MultiByte + Unicode diff --git a/template/android/build_native.sh b/template/android/build_native.sh index 9c6d50ada5..32345d4bd9 100644 --- a/template/android/build_native.sh +++ b/template/android/build_native.sh @@ -50,6 +50,21 @@ do fi done +# copy icons (if they exist) +file=$GAME_ANDROID_ROOT/assets/Icon-72.png +if [ -f "$file" ]; then + cp $file $GAME_ANDROID_ROOT/res/drawable-hdpi/icon.png +fi +file=$GAME_ANDROID_ROOT/assets/Icon-48.png +if [ -f "$file" ]; then + cp $file $GAME_ANDROID_ROOT/res/drawable-mdpi/icon.png +fi +file=$GAME_ANDROID_ROOT/assets/Icon-32.png +if [ -f "$file" ]; then + cp $file $GAME_ANDROID_ROOT/res/drawable-ldpi/icon.png +fi + + if [[ $buildexternalsfromsource ]]; then echo "Building external dependencies from source" $NDK_ROOT/ndk-build -C $GAME_ANDROID_ROOT \ diff --git a/template/msvc/CCAppWiz.win32/Scripts/1033/default.js b/template/msvc/CCAppWiz.win32/Scripts/1033/default.js index d5929b5525..9aabd73bfd 100644 --- a/template/msvc/CCAppWiz.win32/Scripts/1033/default.js +++ b/template/msvc/CCAppWiz.win32/Scripts/1033/default.js @@ -306,7 +306,7 @@ function AddConfigurations(proj, strProjectName) { } // Additional Library Directories - var strAddDepends = 'libcocos2d.lib libGLESv2.lib'; + var strAddDepends = 'libcocos2d.lib opengl32.lib glew32.lib'; if (wizard.FindSymbol('CC_USE_BOX2D')) { strAddDepends += ' libBox2d.lib'; } diff --git a/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.cpp index 339020ed9b..07ffb55c1e 100644 --- a/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.cpp +++ b/template/xcode4/cocos2dx.xctemplate/Classes/AppDelegate.cpp @@ -31,9 +31,6 @@ bool AppDelegate::applicationDidFinishLaunching() // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. // pDirector->enableRetinaDisplay(true); - // sets landscape mode - // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); - // turn on display FPS pDirector->setDisplayStats(true); diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.cpp index 339020ed9b..07ffb55c1e 100644 --- a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.cpp +++ b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.cpp @@ -31,9 +31,6 @@ bool AppDelegate::applicationDidFinishLaunching() // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. // pDirector->enableRetinaDisplay(true); - // sets landscape mode - // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); - // turn on display FPS pDirector->setDisplayStats(true); diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/AppDelegate.cpp index 339020ed9b..07ffb55c1e 100644 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/AppDelegate.cpp +++ b/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/AppDelegate.cpp @@ -31,9 +31,6 @@ bool AppDelegate::applicationDidFinishLaunching() // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. // pDirector->enableRetinaDisplay(true); - // sets landscape mode - // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); - // turn on display FPS pDirector->setDisplayStats(true); diff --git a/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp index fa0a03eff9..984bba4348 100644 --- a/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp +++ b/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp @@ -33,8 +33,6 @@ bool AppDelegate::applicationDidFinishLaunching() // turn on display FPS pDirector->setDisplayStats(true); - // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); - // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); diff --git a/testjs/Classes/AppDelegate.cpp b/testjs/Classes/AppDelegate.cpp index 38dc2e91c1..696ee5aea2 100644 --- a/testjs/Classes/AppDelegate.cpp +++ b/testjs/Classes/AppDelegate.cpp @@ -32,9 +32,6 @@ bool AppDelegate::applicationDidFinishLaunching() // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. // pDirector->enableRetinaDisplay(true); - // sets landscape mode - // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); - // turn on display FPS pDirector->setDisplayStats(true); diff --git a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java b/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java index ca646cb545..e7061f74de 100644 --- a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java +++ b/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java @@ -23,6 +23,7 @@ THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.lib; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -44,10 +45,12 @@ public class Cocos2dxSound { private float mLeftVolume; private float mRightVolume; - // sound id and stream id map - private HashMap mSoundIdStreamIdMap; - // sound path and sound id map - private HashMap mPathSoundIDMap; + // sound path and stream ids map + // a file may be played many times at the same time + // so there is an array map to a file path + private HashMap> mPathStreamIDsMap; + + private HashMap mPathSoundIdMap; private static final String TAG = "Cocos2dxSound"; private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 5; @@ -55,8 +58,8 @@ public class Cocos2dxSound { private static final int SOUND_PRIORITY = 1; private static final int SOUND_QUALITY = 5; - private final int INVALID_SOUND_ID = -1; - private final int INVALID_STREAM_ID = -1; + private final static int INVALID_SOUND_ID = -1; + private final static int INVALID_STREAM_ID = -1; public Cocos2dxSound(Context context){ this.mContext = context; @@ -64,53 +67,48 @@ public class Cocos2dxSound { } public int preloadEffect(String path){ - int soundId = INVALID_SOUND_ID; + Integer soundID = this.mPathSoundIdMap.get(path); - // if the sound is preloaded, pass it - if (this.mPathSoundIDMap.get(path) != null){ - soundId = this.mPathSoundIDMap.get(path).intValue(); - } else { - soundId = createSoundIdFromAsset(path); - - if (soundId != INVALID_SOUND_ID){ - // the sound is loaded but has not been played - this.mSoundIdStreamIdMap.put(soundId, INVALID_STREAM_ID); - - // record path and sound id map - this.mPathSoundIDMap.put(path, soundId); - } + if (soundID == null) { + soundID = createSoundIdFromAsset(path); + this.mPathSoundIdMap.put(path, soundID); } - return soundId; + return soundID; } public void unloadEffect(String path){ - // get sound id and remove from mPathSoundIDMap - Integer soundId = this.mPathSoundIDMap.remove(path); + // stop effects + ArrayList streamIDs = this.mPathStreamIDsMap.get(path); + if (streamIDs != null) { + for (Integer streamID : streamIDs) { + this.mSoundPool.stop(streamID); + } + } + this.mPathStreamIDsMap.remove(path); - if (soundId != null){ - // unload effect - this.mSoundPool.unload(soundId.intValue()); - - // remove record from mSoundIdStreamIdMap - this.mSoundIdStreamIdMap.remove(soundId); - } + // unload effect + Integer soundID = this.mPathSoundIdMap.get(path); + this.mSoundPool.unload(soundID); + this.mPathSoundIdMap.remove(path); } public int playEffect(String path, boolean isLoop){ - Integer soundId = this.mPathSoundIDMap.get(path); + Integer soundId = this.mPathSoundIdMap.get(path); + int streamId = INVALID_STREAM_ID; - if (soundId != null){ - // the sound is preloaded, stop it first - - this.mSoundPool.stop(soundId); - + if (soundId != null){ // play sound - int streamId = this.mSoundPool.play(soundId.intValue(), this.mLeftVolume, + streamId = this.mSoundPool.play(soundId.intValue(), this.mLeftVolume, this.mRightVolume, SOUND_PRIORITY, isLoop ? -1 : 0, SOUND_RATE); - // record sound id and stream id map - this.mSoundIdStreamIdMap.put(soundId, streamId); + // record stream id + ArrayList streamIds = this.mPathStreamIDsMap.get(path); + if (streamIds == null) { + streamIds = new ArrayList(); + this.mPathStreamIDsMap.put(path, streamIds); + } + streamIds.add(streamId); } else { // the effect is not prepared soundId = preloadEffect(path); @@ -133,54 +131,53 @@ public class Cocos2dxSound { playEffect(path, isLoop); } - return soundId.intValue(); + return streamId; } - public void stopEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); + public void stopEffect(int streamID){ + this.mSoundPool.stop(streamID); - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.stop(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); + // remove record + for (String path : this.mPathStreamIDsMap.keySet()) { + if (this.mPathStreamIDsMap.get(path).contains(streamID)) { + this.mPathStreamIDsMap.get(path).remove(this.mPathStreamIDsMap.get(path).indexOf(streamID)); + break; + } } } - public void pauseEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); - - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.pause(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); - } + public void pauseEffect(int streamID){ + this.mSoundPool.pause(streamID); } - public void resumeEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); - - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.resume(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); - } + public void resumeEffect(int streamID){ + this.mSoundPool.resume(streamID); } public void pauseAllEffects(){ - // autoResume is available since level 8 - pauseOrResumeAllEffects(true); + this.mSoundPool.autoPause(); } public void resumeAllEffects(){ // autoPause() is available since level 8 - pauseOrResumeAllEffects(false); + this.mSoundPool.autoResume(); } @SuppressWarnings("unchecked") public void stopAllEffects(){ - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - int soundId = entry.getKey(); - this.stopEffect(soundId); - } + // stop effects + if (! this.mPathStreamIDsMap.isEmpty()) { + Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); + while (iter.hasNext()){ + Map.Entry> entry = (Map.Entry>)iter.next(); + for (int streamID : entry.getValue()) { + this.mSoundPool.stop(streamID); + } + } + } + + // remove records + this.mPathStreamIDsMap.clear(); } public float getEffectsVolume(){ @@ -200,17 +197,21 @@ public class Cocos2dxSound { this.mLeftVolume = this.mRightVolume = volume; // change the volume of playing sounds - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - this.mSoundPool.setVolume(entry.getValue(), mLeftVolume, mRightVolume); - } + if (! this.mPathStreamIDsMap.isEmpty()) { + Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); + while (iter.hasNext()){ + Map.Entry> entry = (Map.Entry>)iter.next(); + for (int streamID : entry.getValue()) { + this.mSoundPool.setVolume(streamID, mLeftVolume, mRightVolume); + } + } + } } public void end(){ this.mSoundPool.release(); - this.mPathSoundIDMap.clear(); - this.mSoundIdStreamIdMap.clear(); + this.mPathStreamIDsMap.clear(); + this.mPathSoundIdMap.clear(); initData(); } @@ -234,25 +235,11 @@ public class Cocos2dxSound { } private void initData(){ - this.mSoundIdStreamIdMap = new HashMap(); + this.mPathStreamIDsMap = new HashMap>(); + this.mPathSoundIdMap = new HashMap(); mSoundPool = new SoundPool(MAX_SIMULTANEOUS_STREAMS_DEFAULT, AudioManager.STREAM_MUSIC, SOUND_QUALITY); - mPathSoundIDMap = new HashMap(); this.mLeftVolume = 0.5f; this.mRightVolume = 0.5f; } - - @SuppressWarnings("unchecked") - private void pauseOrResumeAllEffects(boolean isPause){ - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - int soundId = entry.getKey(); - if (isPause) { - this.pauseEffect(soundId); - } else { - this.resumeEffect(soundId); - } - } - } } diff --git a/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id b/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id index 364ae308d1..17c493db58 100644 --- a/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -a330c09f123bd8de33522f7dedde5def5ea256a6 \ No newline at end of file +59d857c1050d96d698c58eaf20c0c3cd1a808cbf \ No newline at end of file diff --git a/testjs/proj.win32/testjs.win32.vcproj b/testjs/proj.win32/testjs.win32.vcproj index 659ea5ad21..712f215622 100644 --- a/testjs/proj.win32/testjs.win32.vcproj +++ b/testjs/proj.win32/testjs.win32.vcproj @@ -73,7 +73,7 @@ /> - libcocos2d.lib;libGLESv2.lib;libCocosDenshion.lib;js.lib;%(AdditionalDependencies) + libcocos2d.lib;opengl32.lib;glew32.lib;libCocosDenshion.lib;js.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) true Windows @@ -124,7 +124,7 @@ xcopy /Y /Q "$(SolutionDir)js\spidermonkey-win32\lib\*.*" "$(OutDir)" $(IntDir);%(AdditionalIncludeDirectories) - libcocos2d.lib;libGLESv2.lib;libCocosDenshion.lib;js.lib;%(AdditionalDependencies) + libcocos2d.lib;opengl32.lib;glew32.lib;libCocosDenshion.lib;js.lib;%(AdditionalDependencies) $(OutDir);%(AdditionalLibraryDirectories) Windows MachineX86 diff --git a/tests/Android.mk b/tests/Android.mk index a777abaad7..1589dd0532 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -12,7 +12,7 @@ tests/ActionManagerTest/ActionManagerTest.cpp \ tests/ActionsTest/ActionsTest.cpp \ tests/ActionsEaseTest/ActionsEaseTest.cpp \ tests/ActionsProgressTest/ActionsProgressTest.cpp \ -tests/Box2dTest/Box2dTest.cpp \ +tests/Box2DTest/Box2dTest.cpp \ tests/Box2DTestBed/Box2dView.cpp \ tests/Box2DTestBed/GLES-Render.cpp \ tests/Box2DTestBed/Test.cpp \ diff --git a/tests/AppDelegate.cpp b/tests/AppDelegate.cpp index d6c50ebf4b..2a58f05895 100644 --- a/tests/AppDelegate.cpp +++ b/tests/AppDelegate.cpp @@ -25,10 +25,6 @@ bool AppDelegate::applicationDidFinishLaunching() // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. // pDirector->enableRetinaDisplay(true); - // sets opengl landscape mode - // tests set device orientation in RootViewController.mm - // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); - // turn on display FPS pDirector->setDisplayStats(true); diff --git a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java b/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java index ca646cb545..e7061f74de 100644 --- a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java +++ b/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java @@ -23,6 +23,7 @@ THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.lib; +import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.Map; @@ -44,10 +45,12 @@ public class Cocos2dxSound { private float mLeftVolume; private float mRightVolume; - // sound id and stream id map - private HashMap mSoundIdStreamIdMap; - // sound path and sound id map - private HashMap mPathSoundIDMap; + // sound path and stream ids map + // a file may be played many times at the same time + // so there is an array map to a file path + private HashMap> mPathStreamIDsMap; + + private HashMap mPathSoundIdMap; private static final String TAG = "Cocos2dxSound"; private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 5; @@ -55,8 +58,8 @@ public class Cocos2dxSound { private static final int SOUND_PRIORITY = 1; private static final int SOUND_QUALITY = 5; - private final int INVALID_SOUND_ID = -1; - private final int INVALID_STREAM_ID = -1; + private final static int INVALID_SOUND_ID = -1; + private final static int INVALID_STREAM_ID = -1; public Cocos2dxSound(Context context){ this.mContext = context; @@ -64,53 +67,48 @@ public class Cocos2dxSound { } public int preloadEffect(String path){ - int soundId = INVALID_SOUND_ID; + Integer soundID = this.mPathSoundIdMap.get(path); - // if the sound is preloaded, pass it - if (this.mPathSoundIDMap.get(path) != null){ - soundId = this.mPathSoundIDMap.get(path).intValue(); - } else { - soundId = createSoundIdFromAsset(path); - - if (soundId != INVALID_SOUND_ID){ - // the sound is loaded but has not been played - this.mSoundIdStreamIdMap.put(soundId, INVALID_STREAM_ID); - - // record path and sound id map - this.mPathSoundIDMap.put(path, soundId); - } + if (soundID == null) { + soundID = createSoundIdFromAsset(path); + this.mPathSoundIdMap.put(path, soundID); } - return soundId; + return soundID; } public void unloadEffect(String path){ - // get sound id and remove from mPathSoundIDMap - Integer soundId = this.mPathSoundIDMap.remove(path); + // stop effects + ArrayList streamIDs = this.mPathStreamIDsMap.get(path); + if (streamIDs != null) { + for (Integer streamID : streamIDs) { + this.mSoundPool.stop(streamID); + } + } + this.mPathStreamIDsMap.remove(path); - if (soundId != null){ - // unload effect - this.mSoundPool.unload(soundId.intValue()); - - // remove record from mSoundIdStreamIdMap - this.mSoundIdStreamIdMap.remove(soundId); - } + // unload effect + Integer soundID = this.mPathSoundIdMap.get(path); + this.mSoundPool.unload(soundID); + this.mPathSoundIdMap.remove(path); } public int playEffect(String path, boolean isLoop){ - Integer soundId = this.mPathSoundIDMap.get(path); + Integer soundId = this.mPathSoundIdMap.get(path); + int streamId = INVALID_STREAM_ID; - if (soundId != null){ - // the sound is preloaded, stop it first - - this.mSoundPool.stop(soundId); - + if (soundId != null){ // play sound - int streamId = this.mSoundPool.play(soundId.intValue(), this.mLeftVolume, + streamId = this.mSoundPool.play(soundId.intValue(), this.mLeftVolume, this.mRightVolume, SOUND_PRIORITY, isLoop ? -1 : 0, SOUND_RATE); - // record sound id and stream id map - this.mSoundIdStreamIdMap.put(soundId, streamId); + // record stream id + ArrayList streamIds = this.mPathStreamIDsMap.get(path); + if (streamIds == null) { + streamIds = new ArrayList(); + this.mPathStreamIDsMap.put(path, streamIds); + } + streamIds.add(streamId); } else { // the effect is not prepared soundId = preloadEffect(path); @@ -133,54 +131,53 @@ public class Cocos2dxSound { playEffect(path, isLoop); } - return soundId.intValue(); + return streamId; } - public void stopEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); + public void stopEffect(int streamID){ + this.mSoundPool.stop(streamID); - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.stop(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); + // remove record + for (String path : this.mPathStreamIDsMap.keySet()) { + if (this.mPathStreamIDsMap.get(path).contains(streamID)) { + this.mPathStreamIDsMap.get(path).remove(this.mPathStreamIDsMap.get(path).indexOf(streamID)); + break; + } } } - public void pauseEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); - - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.pause(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); - } + public void pauseEffect(int streamID){ + this.mSoundPool.pause(streamID); } - public void resumeEffect(int soundId){ - Integer streamId = this.mSoundIdStreamIdMap.get(soundId); - - if (streamId != null && streamId.intValue() != INVALID_STREAM_ID){ - this.mSoundPool.resume(streamId.intValue()); - this.mPathSoundIDMap.remove(soundId); - } + public void resumeEffect(int streamID){ + this.mSoundPool.resume(streamID); } public void pauseAllEffects(){ - // autoResume is available since level 8 - pauseOrResumeAllEffects(true); + this.mSoundPool.autoPause(); } public void resumeAllEffects(){ // autoPause() is available since level 8 - pauseOrResumeAllEffects(false); + this.mSoundPool.autoResume(); } @SuppressWarnings("unchecked") public void stopAllEffects(){ - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - int soundId = entry.getKey(); - this.stopEffect(soundId); - } + // stop effects + if (! this.mPathStreamIDsMap.isEmpty()) { + Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); + while (iter.hasNext()){ + Map.Entry> entry = (Map.Entry>)iter.next(); + for (int streamID : entry.getValue()) { + this.mSoundPool.stop(streamID); + } + } + } + + // remove records + this.mPathStreamIDsMap.clear(); } public float getEffectsVolume(){ @@ -200,17 +197,21 @@ public class Cocos2dxSound { this.mLeftVolume = this.mRightVolume = volume; // change the volume of playing sounds - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - this.mSoundPool.setVolume(entry.getValue(), mLeftVolume, mRightVolume); - } + if (! this.mPathStreamIDsMap.isEmpty()) { + Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); + while (iter.hasNext()){ + Map.Entry> entry = (Map.Entry>)iter.next(); + for (int streamID : entry.getValue()) { + this.mSoundPool.setVolume(streamID, mLeftVolume, mRightVolume); + } + } + } } public void end(){ this.mSoundPool.release(); - this.mPathSoundIDMap.clear(); - this.mSoundIdStreamIdMap.clear(); + this.mPathStreamIDsMap.clear(); + this.mPathSoundIdMap.clear(); initData(); } @@ -234,25 +235,11 @@ public class Cocos2dxSound { } private void initData(){ - this.mSoundIdStreamIdMap = new HashMap(); + this.mPathStreamIDsMap = new HashMap>(); + this.mPathSoundIdMap = new HashMap(); mSoundPool = new SoundPool(MAX_SIMULTANEOUS_STREAMS_DEFAULT, AudioManager.STREAM_MUSIC, SOUND_QUALITY); - mPathSoundIDMap = new HashMap(); this.mLeftVolume = 0.5f; this.mRightVolume = 0.5f; } - - @SuppressWarnings("unchecked") - private void pauseOrResumeAllEffects(boolean isPause){ - Iterator iter = this.mSoundIdStreamIdMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry entry = (Map.Entry)iter.next(); - int soundId = entry.getKey(); - if (isPause) { - this.pauseEffect(soundId); - } else { - this.resumeEffect(soundId); - } - } - } } diff --git a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id index 6fb416ba08..3a2f28fb74 100644 --- a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -14a32fb3ba86f267841b87b9a63e906ce7a64969 \ No newline at end of file +277bc57b726290085c72db62cf656b66594440dc \ No newline at end of file diff --git a/tests/proj.win32/test.win32.vcproj b/tests/proj.win32/test.win32.vcproj index c19bee53bc..501f7bdc80 100644 --- a/tests/proj.win32/test.win32.vcproj +++ b/tests/proj.win32/test.win32.vcproj @@ -21,7 +21,7 @@ OutputDirectory="$(SolutionDir)$(ConfigurationName).win32" IntermediateDirectory="$(ConfigurationName).win32" ConfigurationType="1" - CharacterSet="2" + CharacterSet="1" > Application - MultiByte + Unicode true Application - MultiByte + Unicode @@ -67,7 +67,7 @@ 4251;4244;4996;%(DisableSpecificWarnings) - libGLESv2.lib;libcocos2d.lib;libBox2d.lib;libchipmunk.lib;libcurl_imp.lib;libCocosDenshion.lib;%(AdditionalDependencies) + opengl32.lib;glew32.lib;libcocos2d.lib;libBox2d.lib;libchipmunk.lib;libcurl_imp.lib;libCocosDenshion.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).exe $(OutDir);%(AdditionalLibraryDirectories) true @@ -94,7 +94,7 @@ 4251;4244;4996;%(DisableSpecificWarnings) - libGLESv2.lib;libcocos2d.lib;libBox2d.lib;libchipmunk.lib;libcurl_imp.lib;libCocosDenshion.lib;%(AdditionalDependencies) + opengl32.lib;glew32.lib;libcocos2d.lib;libBox2d.lib;libchipmunk.lib;libcurl_imp.lib;libCocosDenshion.lib;%(AdditionalDependencies) $(OutDir)$(ProjectName).exe $(OutDir);%(AdditionalLibraryDirectories) true diff --git a/tests/tests/ActionManagerTest/ActionManagerTest.cpp b/tests/tests/ActionManagerTest/ActionManagerTest.cpp index c1403d45b2..91ade71d38 100644 --- a/tests/tests/ActionManagerTest/ActionManagerTest.cpp +++ b/tests/tests/ActionManagerTest/ActionManagerTest.cpp @@ -240,7 +240,7 @@ void PauseTest::onEnter() schedule( schedule_selector(PauseTest::unpause), 3); } -void PauseTest::unpause(ccTime dt) +void PauseTest::unpause(float dt) { unschedule( schedule_selector(PauseTest::unpause) ); CCNode* node = getChildByTag( kTagGrossini ); @@ -324,7 +324,7 @@ void ResumeTest::onEnter() this->schedule(schedule_selector(ResumeTest::resumeGrossini), 3.0f); } -void ResumeTest::resumeGrossini(ccTime time) +void ResumeTest::resumeGrossini(float time) { this->unschedule(schedule_selector(ResumeTest::resumeGrossini)); diff --git a/tests/tests/ActionManagerTest/ActionManagerTest.h b/tests/tests/ActionManagerTest/ActionManagerTest.h index f2214f58d4..35afb921d1 100644 --- a/tests/tests/ActionManagerTest/ActionManagerTest.h +++ b/tests/tests/ActionManagerTest/ActionManagerTest.h @@ -43,7 +43,7 @@ class PauseTest : public ActionManagerTest public: virtual std::string title(); virtual void onEnter(); - void unpause(ccTime dt); + void unpause(float dt); }; class RemoveTest : public ActionManagerTest @@ -59,7 +59,7 @@ class ResumeTest : public ActionManagerTest public: virtual std::string title(); virtual void onEnter(); - void resumeGrossini(ccTime time); + void resumeGrossini(float time); }; class ActionManagerTestScene : public TestScene diff --git a/tests/tests/ActionsEaseTest/ActionsEaseTest.cpp b/tests/tests/ActionsEaseTest/ActionsEaseTest.cpp index cb4aa3b83c..4186a47b0b 100644 --- a/tests/tests/ActionsEaseTest/ActionsEaseTest.cpp +++ b/tests/tests/ActionsEaseTest/ActionsEaseTest.cpp @@ -51,7 +51,7 @@ void SpriteEase::onEnter() schedule(schedule_selector(SpriteEase::testStopAction), 6.25f); } -void SpriteEase::testStopAction(ccTime dt) +void SpriteEase::testStopAction(float dt) { unschedule(schedule_selector(SpriteEase::testStopAction)); m_tamara->stopActionByTag(1); @@ -515,7 +515,7 @@ void SpeedTest::onEnter() this->schedule(schedule_selector(SpeedTest::altertime), 1.0f);//:@selector(altertime:) interval:1.0f]; } -void SpeedTest::altertime(ccTime dt) +void SpeedTest::altertime(float dt) { CCSpeed* action1 = (CCSpeed*)(m_grossini->getActionByTag(kTagAction1)); CCSpeed* action2 = (CCSpeed*)(m_tamara->getActionByTag(kTagAction1)); diff --git a/tests/tests/ActionsEaseTest/ActionsEaseTest.h b/tests/tests/ActionsEaseTest/ActionsEaseTest.h index adc8fb1c81..04a5769af1 100644 --- a/tests/tests/ActionsEaseTest/ActionsEaseTest.h +++ b/tests/tests/ActionsEaseTest/ActionsEaseTest.h @@ -35,7 +35,7 @@ public: void onEnter(); virtual std::string title(); - void testStopAction(ccTime dt); + void testStopAction(float dt); }; class SpriteEaseInOut : public EaseSpriteDemo @@ -121,7 +121,7 @@ public: void onEnter(); virtual std::string title(); - void altertime(ccTime dt); + void altertime(float dt); }; class ActionsEaseTestScene : public TestScene diff --git a/tests/tests/ActionsTest/ActionsTest.cpp b/tests/tests/ActionsTest/ActionsTest.cpp index 90e58efb8a..217d432c97 100644 --- a/tests/tests/ActionsTest/ActionsTest.cpp +++ b/tests/tests/ActionsTest/ActionsTest.cpp @@ -1263,7 +1263,7 @@ void Issue1305::onExit() ActionsDemo::onExit(); } -void Issue1305::addSprite(ccTime dt) +void Issue1305::addSprite(float dt) { m_pSpriteTmp->setPosition(ccp(250,250)); addChild(m_pSpriteTmp); diff --git a/tests/tests/ActionsTest/ActionsTest.h b/tests/tests/ActionsTest/ActionsTest.h index f4eb8c852e..46da2c604f 100644 --- a/tests/tests/ActionsTest/ActionsTest.h +++ b/tests/tests/ActionsTest/ActionsTest.h @@ -290,7 +290,7 @@ public: virtual void onEnter(); virtual void onExit(); void log(CCNode* pSender); - void addSprite(ccTime dt); + void addSprite(float dt); virtual std::string title(); virtual std::string subtitle(); private: diff --git a/tests/tests/Box2DTest/Box2dTest.cpp b/tests/tests/Box2DTest/Box2dTest.cpp index d319b43aad..1211366201 100644 --- a/tests/tests/Box2DTest/Box2dTest.cpp +++ b/tests/tests/Box2DTest/Box2dTest.cpp @@ -34,7 +34,7 @@ CCAffineTransform PhysicsSprite::nodeToParentTransform(void) float x = pos.x * PTM_RATIO; float y = pos.y * PTM_RATIO; - if ( !getIsRelativeAnchorPoint() ) { + if ( getIgnoreAnchorPointForPosition() ) { x += m_tAnchorPointInPoints.x; y += m_tAnchorPointInPoints.y; } @@ -237,7 +237,7 @@ void Box2DTestLayer::addNewSpriteAtPosition(CCPoint p) } -void Box2DTestLayer::update(ccTime dt) +void Box2DTestLayer::update(float dt) { //It is recommended that a fixed time step is used with Box2D for stability //of the simulation, however, we are using a variable time step here. diff --git a/tests/tests/Box2DTest/Box2dTest.h b/tests/tests/Box2DTest/Box2dTest.h index 4f0b45d6fb..0697f513a1 100644 --- a/tests/tests/Box2DTest/Box2dTest.h +++ b/tests/tests/Box2DTest/Box2dTest.h @@ -32,7 +32,7 @@ public: virtual void draw(); void addNewSpriteAtPosition(CCPoint p); - void update(ccTime dt); + void update(float dt); virtual void ccTouchesEnded(CCSet* touches, CCEvent* event); //CREATE_NODE(Box2DTestLayer); diff --git a/tests/tests/Box2DTestBed/Box2dView.cpp b/tests/tests/Box2DTestBed/Box2dView.cpp index b8f254ac54..0ac3284864 100644 --- a/tests/tests/Box2DTestBed/Box2dView.cpp +++ b/tests/tests/Box2DTestBed/Box2dView.cpp @@ -187,7 +187,7 @@ std::string Box2DView::title() return std::string(m_entry->name); } -void Box2DView::tick(ccTime dt) +void Box2DView::tick(float dt) { m_test->Step(&settings); } diff --git a/tests/tests/Box2DTestBed/Box2dView.h b/tests/tests/Box2DTestBed/Box2dView.h index a9bba025a3..d731d91fab 100644 --- a/tests/tests/Box2DTestBed/Box2dView.h +++ b/tests/tests/Box2DTestBed/Box2dView.h @@ -40,7 +40,7 @@ public: bool initWithEntryID(int entryId); std::string title(); - void tick(ccTime dt); + void tick(float dt); void draw(); virtual void registerWithTouchDispatcher(); diff --git a/tests/tests/BugsTest/Bug-1159.cpp b/tests/tests/BugsTest/Bug-1159.cpp index 962ba4e743..8805514228 100644 --- a/tests/tests/BugsTest/Bug-1159.cpp +++ b/tests/tests/BugsTest/Bug-1159.cpp @@ -29,7 +29,7 @@ bool Bug1159Layer::init() CCLayerColor *sprite_a = CCLayerColor::layerWithColor(ccc4(255, 0, 0, 255), 700, 700); sprite_a->setAnchorPoint(ccp(0.5f, 0.5f)); - sprite_a->setIsRelativeAnchorPoint(true); + sprite_a->setIgnoreAnchorPointForPosition(false); sprite_a->setPosition(ccp(0.0f, s.height/2)); addChild(sprite_a); @@ -40,7 +40,7 @@ bool Bug1159Layer::init() CCLayerColor *sprite_b = CCLayerColor::layerWithColor(ccc4(0, 0, 255, 255), 400, 400); sprite_b->setAnchorPoint(ccp(0.5f, 0.5f)); - sprite_b->setIsRelativeAnchorPoint(true); + sprite_b->setIgnoreAnchorPointForPosition(false); sprite_b->setPosition(ccp(s.width/2, s.height/2)); addChild(sprite_b); diff --git a/tests/tests/BugsTest/Bug-624.cpp b/tests/tests/BugsTest/Bug-624.cpp index f788631f42..08419cb1ed 100644 --- a/tests/tests/BugsTest/Bug-624.cpp +++ b/tests/tests/BugsTest/Bug-624.cpp @@ -28,7 +28,7 @@ bool Bug624Layer::init() return false; } -void Bug624Layer::switchLayer(ccTime dt) +void Bug624Layer::switchLayer(float dt) { unschedule(schedule_selector(Bug624Layer::switchLayer)); @@ -65,7 +65,7 @@ bool Bug624Layer2::init() return false; } -void Bug624Layer2::switchLayer(ccTime dt) +void Bug624Layer2::switchLayer(float dt) { unschedule(schedule_selector(Bug624Layer::switchLayer)); diff --git a/tests/tests/BugsTest/Bug-624.h b/tests/tests/BugsTest/Bug-624.h index 7d9a735d43..d407fb4d31 100644 --- a/tests/tests/BugsTest/Bug-624.h +++ b/tests/tests/BugsTest/Bug-624.h @@ -7,7 +7,7 @@ class Bug624Layer : public BugsTestBaseLayer { public: virtual bool init(); - void switchLayer(ccTime dt); + void switchLayer(float dt); virtual void didAccelerate(CCAcceleration* pAccelerationValue); LAYER_NODE_FUNC(Bug624Layer); @@ -17,7 +17,7 @@ class Bug624Layer2 : public BugsTestBaseLayer { public: virtual bool init(); - void switchLayer(ccTime dt); + void switchLayer(float dt); virtual void didAccelerate(CCAcceleration* pAccelerationValue); LAYER_NODE_FUNC(Bug624Layer2); diff --git a/tests/tests/BugsTest/Bug-914.cpp b/tests/tests/BugsTest/Bug-914.cpp index 699d923488..05187d07d8 100644 --- a/tests/tests/BugsTest/Bug-914.cpp +++ b/tests/tests/BugsTest/Bug-914.cpp @@ -40,7 +40,7 @@ bool Bug914Layer::init() layer->setContentSize(CCSizeMake(i*100, i*100)); layer->setPosition(ccp(size.width/2, size.height/2)); layer->setAnchorPoint(ccp(0.5f, 0.5f)); - layer->setIsRelativeAnchorPoint(true); + layer->setIgnoreAnchorPointForPosition(false); addChild(layer, -1-i); } diff --git a/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp b/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp index f25ce5b0c9..b61104d6d8 100644 --- a/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp +++ b/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp @@ -46,7 +46,7 @@ CCAffineTransform ChipmunkPhysicsSprite::nodeToParentTransform(void) CCFloat x = m_pBody->p.x; CCFloat y = m_pBody->p.y; - if ( !getIsRelativeAnchorPoint() ) { + if ( getIgnoreAnchorPointForPosition() ) { x += m_tAnchorPointInPoints.x; y += m_tAnchorPointInPoints.y; } @@ -148,7 +148,7 @@ void ChipmunkAccelTouchTestLayer::initPhysics() } } -void ChipmunkAccelTouchTestLayer::update(ccTime delta) +void ChipmunkAccelTouchTestLayer::update(float delta) { // Should use a fixed size step based on the animation interval. int steps = 2; diff --git a/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.h b/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.h index 51a24c2a28..72a53afa9e 100644 --- a/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.h +++ b/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.h @@ -19,7 +19,7 @@ public: void reset(CCObject* sender); void addNewSpriteAtPosition(CCPoint p); - void update(ccTime dt); + void update(float dt); virtual void ccTouchesEnded(CCSet* touches, CCEvent* event); virtual void didAccelerate(CCAcceleration* pAccelerationValue); diff --git a/tests/tests/CocosDenshionTest/CocosDenshionTest.cpp b/tests/tests/CocosDenshionTest/CocosDenshionTest.cpp index 55858da22e..4bad47c84b 100644 --- a/tests/tests/CocosDenshionTest/CocosDenshionTest.cpp +++ b/tests/tests/CocosDenshionTest/CocosDenshionTest.cpp @@ -76,8 +76,8 @@ m_nSoundId(0) setIsTouchEnabled(true); // preload background music and effect - SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic( CCFileUtils::fullPathFromRelativePath(MUSIC_FILE) ); - SimpleAudioEngine::sharedEngine()->preloadEffect( CCFileUtils::fullPathFromRelativePath(EFFECT_FILE) ); + SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic( CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(MUSIC_FILE) ); + SimpleAudioEngine::sharedEngine()->preloadEffect( CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(EFFECT_FILE) ); // set default volume SimpleAudioEngine::sharedEngine()->setEffectsVolume(0.5); @@ -106,7 +106,7 @@ void CocosDenshionTest::menuCallback(CCObject * pSender) // play background music case 0: - SimpleAudioEngine::sharedEngine()->playBackgroundMusic(std::string(CCFileUtils::fullPathFromRelativePath(MUSIC_FILE)).c_str(), true); + SimpleAudioEngine::sharedEngine()->playBackgroundMusic(std::string(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(MUSIC_FILE)).c_str(), true); break; // stop background music case 1: @@ -137,11 +137,11 @@ void CocosDenshionTest::menuCallback(CCObject * pSender) break; // play effect case 6: - m_nSoundId = SimpleAudioEngine::sharedEngine()->playEffect(std::string(CCFileUtils::fullPathFromRelativePath(EFFECT_FILE)).c_str()); + m_nSoundId = SimpleAudioEngine::sharedEngine()->playEffect(std::string(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(EFFECT_FILE)).c_str()); break; // play effect case 7: - m_nSoundId = SimpleAudioEngine::sharedEngine()->playEffect(std::string(CCFileUtils::fullPathFromRelativePath(EFFECT_FILE)).c_str(), true); + m_nSoundId = SimpleAudioEngine::sharedEngine()->playEffect(std::string(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(EFFECT_FILE)).c_str(), true); break; // stop effect case 8: @@ -149,7 +149,7 @@ void CocosDenshionTest::menuCallback(CCObject * pSender) break; // unload effect case 9: - SimpleAudioEngine::sharedEngine()->unloadEffect(std::string(CCFileUtils::fullPathFromRelativePath(EFFECT_FILE)).c_str()); + SimpleAudioEngine::sharedEngine()->unloadEffect(std::string(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(EFFECT_FILE)).c_str()); break; // add bakcground music volume case 10: diff --git a/tests/tests/EffectsTest/EffectsTest.cpp b/tests/tests/EffectsTest/EffectsTest.cpp index b2719abcae..2d067b22fe 100644 --- a/tests/tests/EffectsTest/EffectsTest.cpp +++ b/tests/tests/EffectsTest/EffectsTest.cpp @@ -39,7 +39,7 @@ static std::string effectsList[] = class Shaky3DDemo : public CCShaky3D { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { return CCShaky3D::actionWithRange(5, false, ccg(15,10), t); } @@ -48,7 +48,7 @@ public: class Waves3DDemo : public CCWaves3D { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { return CCWaves3D::actionWithWaves(5, 40, ccg(15,10), t); } @@ -57,7 +57,7 @@ public: class FlipX3DDemo : public CCFlipX3D { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCFlipX3D* flipx = CCFlipX3D::actionWithDuration(t); CCActionInterval* flipx_back = flipx->reverse(); @@ -70,7 +70,7 @@ public: class FlipY3DDemo : public CCFlipY3D { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCFlipY3D* flipy = CCFlipY3D::actionWithDuration(t); CCActionInterval* flipy_back = flipy->reverse(); @@ -83,7 +83,7 @@ public: class Lens3DDemo : public CCLens3D { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCSize size = CCDirector::sharedDirector()->getWinSize(); return CCLens3D::actionWithPosition(CCPointMake(size.width/2,size.height/2), 240, ccg(15,10), t); @@ -94,7 +94,7 @@ public: class Ripple3DDemo : public CCRipple3D { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCSize size = CCDirector::sharedDirector()->getWinSize(); return CCRipple3D::actionWithPosition(CCPointMake(size.width/2,size.height/2), 240, 4, 160, ccg(32,24), t); @@ -105,7 +105,7 @@ public: class LiquidDemo : public CCLiquid { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { return CCLiquid::actionWithWaves(4, 20, ccg(16,12), t); } @@ -115,7 +115,7 @@ public: class WavesDemo : public CCWaves { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { return CCWaves::actionWithWaves(4, 20, true, true, ccg(16,12), t); } @@ -125,7 +125,7 @@ public: class TwirlDemo : public CCTwirl { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCSize size = CCDirector::sharedDirector()->getWinSize(); return CCTwirl::actionWithPosition(CCPointMake(size.width/2, size.height/2), 1, 2.5f, ccg(12,8), t); @@ -136,7 +136,7 @@ public: class ShakyTiles3DDemo : public CCShakyTiles3D { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { return CCShakyTiles3D::actionWithRange(5, false, ccg(16,12), t) ; } @@ -146,7 +146,7 @@ public: class ShatteredTiles3DDemo : public CCShatteredTiles3D { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { return CCShatteredTiles3D::actionWithRange(5, false, ccg(16,12), t); } @@ -156,7 +156,7 @@ public: class ShuffleTilesDemo : public CCShuffleTiles { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCShuffleTiles* shuffle = CCShuffleTiles::actionWithSeed(25, ccg(16,12), t); CCActionInterval* shuffle_back = shuffle->reverse(); @@ -170,7 +170,7 @@ public: class FadeOutTRTilesDemo : public CCFadeOutTRTiles { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCFadeOutTRTiles* fadeout = CCFadeOutTRTiles::actionWithSize(ccg(16,12), t); CCActionInterval* back = fadeout->reverse(); @@ -184,7 +184,7 @@ public: class FadeOutBLTilesDemo : public CCFadeOutBLTiles { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCFadeOutBLTiles* fadeout = CCFadeOutBLTiles::actionWithSize(ccg(16,12), t); CCActionInterval* back = fadeout->reverse(); @@ -198,7 +198,7 @@ public: class FadeOutUpTilesDemo : public CCFadeOutUpTiles { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCFadeOutUpTiles* fadeout = CCFadeOutUpTiles::actionWithSize(ccg(16,12), t); CCActionInterval* back = fadeout->reverse(); @@ -211,7 +211,7 @@ public: class FadeOutDownTilesDemo : public CCFadeOutDownTiles { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCFadeOutDownTiles* fadeout = CCFadeOutDownTiles::actionWithSize(ccg(16,12), t); CCActionInterval* back = fadeout->reverse(); @@ -224,7 +224,7 @@ public: class TurnOffTilesDemo : public CCTurnOffTiles { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCTurnOffTiles* fadeout = CCTurnOffTiles::actionWithSeed(25, ccg(48,32) , t); CCActionInterval* back = fadeout->reverse(); @@ -237,7 +237,7 @@ public: class WavesTiles3DDemo : public CCWavesTiles3D { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { return CCWavesTiles3D::actionWithWaves(4, 120, ccg(15,10), t); } @@ -246,7 +246,7 @@ public: class JumpTiles3DDemo : public CCJumpTiles3D { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCSize size = CCDirector::sharedDirector()->getWinSize(); return CCJumpTiles3D::actionWithJumps(2, 30, ccg(15,10), t); @@ -256,7 +256,7 @@ public: class SplitRowsDemo : public CCSplitRows { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { return CCSplitRows::actionWithRows(9, t); } @@ -265,7 +265,7 @@ public: class SplitColsDemo : public CCSplitCols { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { return CCSplitCols::actionWithCols(9, t); } @@ -274,7 +274,7 @@ public: class PageTurn3DDemo : public CCPageTurn3D { public: - static CCActionInterval* actionWithDuration(ccTime t) + static CCActionInterval* actionWithDuration(float t) { CCDirector::sharedDirector()->setDepthTest(true); return CCPageTurn3D::actionWithSize(ccg(15,10), t); @@ -288,7 +288,7 @@ public: //------------------------------------------------------------------ #define MAX_LAYER 22 -CCActionInterval* createEffect(int nIndex, ccTime t) +CCActionInterval* createEffect(int nIndex, float t) { CCDirector::sharedDirector()->setDepthTest(false); @@ -393,7 +393,7 @@ TextLayer::TextLayer(void) schedule( schedule_selector(TextLayer::checkAnim) ); } -void TextLayer::checkAnim(ccTime dt) +void TextLayer::checkAnim(float dt) { CCNode* s2 = getChildByTag(kTagBackground); if ( s2->numberOfRunningActions() == 0 && s2->getGrid() != NULL) diff --git a/tests/tests/EffectsTest/EffectsTest.h b/tests/tests/EffectsTest/EffectsTest.h index bbd7288131..022d0e8306 100644 --- a/tests/tests/EffectsTest/EffectsTest.h +++ b/tests/tests/EffectsTest/EffectsTest.h @@ -18,7 +18,7 @@ public: TextLayer(void); ~TextLayer(void); - void checkAnim(ccTime dt); + void checkAnim(float dt); virtual void onEnter(); diff --git a/tests/tests/FontTest/FontTest.cpp b/tests/tests/FontTest/FontTest.cpp index cdd4ae8b50..ef4ebe8989 100644 --- a/tests/tests/FontTest/FontTest.cpp +++ b/tests/tests/FontTest/FontTest.cpp @@ -75,9 +75,9 @@ void FontTest::showFont(const char *pFont) CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLabelTTF *top = CCLabelTTF::labelWithString(pFont, pFont, 24); - CCLabelTTF *left = CCLabelTTF::labelWithString("alignment left", CCSizeMake(s.width, 50), CCTextAlignmentLeft, pFont, 32); - CCLabelTTF *center = CCLabelTTF::labelWithString("alignment center", CCSizeMake(s.width, 50), CCTextAlignmentCenter, pFont, 32); - CCLabelTTF *right = CCLabelTTF::labelWithString("alignment right", CCSizeMake(s.width, 50), CCTextAlignmentRight, pFont, 32); + CCLabelTTF *left = CCLabelTTF::labelWithString("alignment left", CCSizeMake(s.width, 50), kCCTextAlignmentLeft, pFont, 32); + CCLabelTTF *center = CCLabelTTF::labelWithString("alignment center", CCSizeMake(s.width, 50), kCCTextAlignmentCenter, pFont, 32); + CCLabelTTF *right = CCLabelTTF::labelWithString("alignment right", CCSizeMake(s.width, 50), kCCTextAlignmentRight, pFont, 32); top->setPosition(ccp(s.width/2, 250)); left->setPosition(ccp(s.width/2, 200)); diff --git a/tests/tests/IntervalTest/IntervalTest.cpp b/tests/tests/IntervalTest/IntervalTest.cpp index 68e6f270f1..f471b45049 100644 --- a/tests/tests/IntervalTest/IntervalTest.cpp +++ b/tests/tests/IntervalTest/IntervalTest.cpp @@ -75,7 +75,7 @@ IntervalLayer::~IntervalLayer() } } -void IntervalLayer::update(ccTime dt) +void IntervalLayer::update(float dt) { m_time0 +=dt; char time[10] = {0}; @@ -92,7 +92,7 @@ void IntervalLayer::onPause(CCObject* pSender) } -void IntervalLayer::step1(ccTime dt) +void IntervalLayer::step1(float dt) { m_time1 +=dt; @@ -101,7 +101,7 @@ void IntervalLayer::step1(ccTime dt) m_label1->setString( str ); } -void IntervalLayer::step2(ccTime dt) +void IntervalLayer::step2(float dt) { m_time2 +=dt; @@ -110,7 +110,7 @@ void IntervalLayer::step2(ccTime dt) m_label2->setString( str ); } -void IntervalLayer::step3(ccTime dt) +void IntervalLayer::step3(float dt) { m_time3 +=dt; @@ -119,7 +119,7 @@ void IntervalLayer::step3(ccTime dt) m_label3->setString( str ); } -void IntervalLayer::step4(ccTime dt) +void IntervalLayer::step4(float dt) { m_time4 +=dt; diff --git a/tests/tests/IntervalTest/IntervalTest.h b/tests/tests/IntervalTest/IntervalTest.h index f78bfcfec6..2cc6952eaf 100644 --- a/tests/tests/IntervalTest/IntervalTest.h +++ b/tests/tests/IntervalTest/IntervalTest.h @@ -12,7 +12,7 @@ protected: CCLabelBMFont* m_label3; CCLabelBMFont* m_label4; - ccTime m_time0, m_time1, m_time2, m_time3, m_time4; + float m_time0, m_time1, m_time2, m_time3, m_time4; public: IntervalLayer(void); @@ -20,11 +20,11 @@ public: public: void onPause(CCObject* pSender); - void step1(ccTime dt); - void step2(ccTime dt); - void step3(ccTime dt); - void step4(ccTime dt); - void update(ccTime dt); + void step1(float dt); + void step2(float dt); + void step3(float dt); + void step4(float dt); + void update(float dt); //CREATE_NODE(IntervalLayer); }; diff --git a/tests/tests/LabelTest/LabelTest.cpp b/tests/tests/LabelTest/LabelTest.cpp index a54a4bf8ca..35ae63bd9f 100644 --- a/tests/tests/LabelTest/LabelTest.cpp +++ b/tests/tests/LabelTest/LabelTest.cpp @@ -279,7 +279,7 @@ LabelAtlasTest::LabelAtlasTest() } -void LabelAtlasTest::step(ccTime dt) +void LabelAtlasTest::step(float dt) { m_time += dt; char string[12] = {0}; @@ -333,7 +333,7 @@ LabelAtlasColorTest::LabelAtlasColorTest() schedule( schedule_selector(LabelAtlasColorTest::step) ); //:@selector(step:)]; } -void LabelAtlasColorTest::step(ccTime dt) +void LabelAtlasColorTest::step(float dt) { m_time += dt; char string[12] = {0}; @@ -413,7 +413,7 @@ Atlas3::Atlas3() schedule( schedule_selector(Atlas3::step) );//:@selector(step:)]; } -void Atlas3::step(ccTime dt) +void Atlas3::step(float dt) { m_time += dt; //std::string string; @@ -512,7 +512,7 @@ void Atlas4::draw() ccDrawLine( ccp(s.width/2, 0), ccp(s.width/2, s.height) ); } -void Atlas4::step(ccTime dt) +void Atlas4::step(float dt) { m_time += dt; char string[10] = {0}; @@ -780,7 +780,7 @@ LabelsEmpty::LabelsEmpty() setEmpty = false; } -void LabelsEmpty::updateStrings(ccTime dt) +void LabelsEmpty::updateStrings(float dt) { CCLabelBMFont* label1 = (CCLabelBMFont*) getChildByTag(kTagBitmapAtlas1); CCLabelTTF* label2 = (CCLabelTTF*) getChildByTag(kTagBitmapAtlas2); @@ -912,9 +912,9 @@ LabelTTFTest::LabelTTFTest() CCSize s = CCDirector::sharedDirector()->getWinSize(); // CCLabelBMFont - CCLabelTTF *left = CCLabelTTF::labelWithString("align left", CCSizeMake(s.width, 50), CCTextAlignmentLeft, "Marker Felt", 32); - CCLabelTTF *center = CCLabelTTF::labelWithString("align center", CCSizeMake(s.width, 50), CCTextAlignmentCenter, "Marker Felt", 32); - CCLabelTTF *right = CCLabelTTF::labelWithString("align right", CCSizeMake(s.width, 50), CCTextAlignmentRight, "Marker Felt", 32); + CCLabelTTF *left = CCLabelTTF::labelWithString("align left", CCSizeMake(s.width, 50), kCCTextAlignmentLeft, "Marker Felt", 32); + CCLabelTTF *center = CCLabelTTF::labelWithString("align center", CCSizeMake(s.width, 50), kCCTextAlignmentCenter, "Marker Felt", 32); + CCLabelTTF *right = CCLabelTTF::labelWithString("align right", CCSizeMake(s.width, 50), kCCTextAlignmentRight, "Marker Felt", 32); left->setPosition(ccp(s.width / 2, 200)); center->setPosition(ccp(s.width / 2, 150)); @@ -941,7 +941,7 @@ LabelTTFMultiline::LabelTTFMultiline() // CCLabelBMFont CCLabelTTF *center = CCLabelTTF::labelWithString("word wrap \"testing\" (bla0) bla1 'bla2' [bla3] (bla4) {bla5} {bla6} [bla7] (bla8) [bla9] 'bla0' \"bla1\"", - CCSizeMake(s.width / 2, 200), CCTextAlignmentCenter, "MarkerFelt.ttc", 32); + CCSizeMake(s.width / 2, 200), kCCTextAlignmentCenter, "MarkerFelt.ttc", 32); center->setPosition(ccp(s.width / 2, 150)); addChild(center); @@ -1010,7 +1010,7 @@ BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment() CCSize size = CCDirector::sharedDirector()->getWinSize(); // create and initialize a Label - this->m_pLabelShouldRetain = CCLabelBMFont::labelWithString(LongSentencesExample, "fonts/markerFelt.fnt", size.width/1.5, CCTextAlignmentCenter); + this->m_pLabelShouldRetain = CCLabelBMFont::labelWithString(LongSentencesExample, "fonts/markerFelt.fnt", size.width/1.5, kCCTextAlignmentCenter); this->m_pLabelShouldRetain->retain(); this->m_pArrowsBarShouldRetain = CCSprite::spriteWithFile("Images/arrowsBar.png"); @@ -1119,13 +1119,13 @@ void BitmapFontMultiLineAlignment::alignmentChanged(cocos2d::CCObject *sender) switch(item->getTag()) { case LeftAlign: - this->m_pLabelShouldRetain->setAlignment(CCTextAlignmentLeft); + this->m_pLabelShouldRetain->setAlignment(kCCTextAlignmentLeft); break; case CenterAlign: - this->m_pLabelShouldRetain->setAlignment(CCTextAlignmentCenter); + this->m_pLabelShouldRetain->setAlignment(kCCTextAlignmentCenter); break; case RightAlign: - this->m_pLabelShouldRetain->setAlignment(CCTextAlignmentRight); + this->m_pLabelShouldRetain->setAlignment(kCCTextAlignmentRight); break; default: @@ -1217,11 +1217,11 @@ BMFontOneAtlas::BMFontOneAtlas() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelBMFont *label1 = CCLabelBMFont::labelWithString("This is Helvetica", "fonts/helvetica-32.fnt", kCCLabelAutomaticWidth, CCTextAlignmentLeft, CCPointZero); + CCLabelBMFont *label1 = CCLabelBMFont::labelWithString("This is Helvetica", "fonts/helvetica-32.fnt", kCCLabelAutomaticWidth, kCCTextAlignmentLeft, CCPointZero); addChild(label1); label1->setPosition(ccp(s.width/2, s.height/3*2)); - CCLabelBMFont *label2 = CCLabelBMFont::labelWithString("And this is Geneva", "fonts/geneva-32.fnt", kCCLabelAutomaticWidth, CCTextAlignmentLeft, ccp(0, 128)); + CCLabelBMFont *label2 = CCLabelBMFont::labelWithString("And this is Geneva", "fonts/geneva-32.fnt", kCCLabelAutomaticWidth, kCCTextAlignmentLeft, ccp(0, 128)); addChild(label2); label2->setPosition(ccp(s.width/2, s.height/3*1)); } @@ -1247,7 +1247,7 @@ BMFontUnicode::BMFontUnicode() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelBMFont *label1 = CCLabelBMFont::labelWithString(spanish, "fonts/arial-unicode-26.fnt", 200, CCTextAlignmentLeft); + CCLabelBMFont *label1 = CCLabelBMFont::labelWithString(spanish, "fonts/arial-unicode-26.fnt", 200, kCCTextAlignmentLeft); addChild(label1); label1->setPosition(ccp(s.width/2, s.height/4*3)); diff --git a/tests/tests/LabelTest/LabelTest.h b/tests/tests/LabelTest/LabelTest.h index d2634fb0f9..0df0c68e6a 100644 --- a/tests/tests/LabelTest/LabelTest.h +++ b/tests/tests/LabelTest/LabelTest.h @@ -34,11 +34,11 @@ public: class LabelAtlasTest : public AtlasDemo { - ccTime m_time; + float m_time; public: LabelAtlasTest(); - virtual void step(ccTime dt); + virtual void step(float dt); virtual std::string title(); virtual std::string subtitle(); @@ -46,21 +46,21 @@ public: class LabelAtlasColorTest : public AtlasDemo { - ccTime m_time; + float m_time; public: LabelAtlasColorTest(); - virtual void step(ccTime dt); + virtual void step(float dt); virtual std::string title(); virtual std::string subtitle(); }; class Atlas3 : public AtlasDemo { - ccTime m_time; + float m_time; public: Atlas3(); - virtual void step(ccTime dt); + virtual void step(float dt); virtual std::string title(); virtual std::string subtitle(); @@ -68,10 +68,10 @@ public: class Atlas4 : public AtlasDemo { - ccTime m_time; + float m_time; public: Atlas4(); - virtual void step(ccTime dt); + virtual void step(float dt); virtual void draw(); virtual std::string title(); @@ -124,7 +124,7 @@ class LabelsEmpty : public AtlasDemo { public: LabelsEmpty(); - void updateStrings(ccTime dt); + void updateStrings(float dt); virtual std::string title(); virtual std::string subtitle(); diff --git a/tests/tests/LayerTest/LayerTest.cpp b/tests/tests/LayerTest/LayerTest.cpp index 66c40e29b7..79daedbf4a 100644 --- a/tests/tests/LayerTest/LayerTest.cpp +++ b/tests/tests/LayerTest/LayerTest.cpp @@ -154,7 +154,7 @@ void LayerTest1::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLayerColor* layer = CCLayerColor::layerWithColor( ccc4(0xFF, 0x00, 0x00, 0x80), 200, 200); - layer->setIsRelativeAnchorPoint(true); + layer->setIgnoreAnchorPointForPosition(false); layer->setPosition( CCPointMake(s.width/2, s.height/2) ); addChild(layer, 1, kTagLayer); } @@ -219,12 +219,12 @@ void LayerTest2::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLayerColor* layer1 = CCLayerColor::layerWithColor( ccc4(255, 255, 0, 80), 100, 300); layer1->setPosition(CCPointMake(s.width/3, s.height/2)); - layer1->setIsRelativeAnchorPoint(true); + layer1->setIgnoreAnchorPointForPosition(false); addChild(layer1, 1); CCLayerColor* layer2 = CCLayerColor::layerWithColor( ccc4(0, 0, 255, 255), 100, 300); layer2->setPosition(CCPointMake((s.width/3)*2, s.height/2)); - layer2->setIsRelativeAnchorPoint(true); + layer2->setIgnoreAnchorPointForPosition(false); addChild(layer2, 1); CCActionInterval* actionTint = CCTintBy::actionWithDuration(2, -255, -127, 0); @@ -267,7 +267,7 @@ LayerTestBlend::LayerTestBlend() schedule( schedule_selector(LayerTestBlend::newBlend), 1.0f); } -void LayerTestBlend::newBlend(ccTime dt) +void LayerTestBlend::newBlend(float dt) { CCLayerColor *layer = (CCLayerColor*)getChildByTag(kTagLayer); diff --git a/tests/tests/LayerTest/LayerTest.h b/tests/tests/LayerTest/LayerTest.h index e5a2f3bba1..d23223b835 100644 --- a/tests/tests/LayerTest/LayerTest.h +++ b/tests/tests/LayerTest/LayerTest.h @@ -48,7 +48,7 @@ class LayerTestBlend : public LayerTest { public: LayerTestBlend(); - void newBlend(ccTime dt); + void newBlend(float dt); virtual std::string title(); }; diff --git a/tests/tests/MenuTest/MenuTest.cpp b/tests/tests/MenuTest/MenuTest.cpp index 250b1d696e..bbea03ed64 100644 --- a/tests/tests/MenuTest/MenuTest.cpp +++ b/tests/tests/MenuTest/MenuTest.cpp @@ -151,7 +151,7 @@ void MenuLayerMainMenu::menuCallbackConfig(CCObject* sender) ((CCLayerMultiplex*)m_pParent)->switchTo(3); } -void MenuLayerMainMenu::allowTouches(ccTime dt) +void MenuLayerMainMenu::allowTouches(float dt) { CCDirector* pDirector = CCDirector::sharedDirector(); pDirector->getTouchDispatcher()->setPriority(kCCMenuHandlerPriority+1, this); diff --git a/tests/tests/MenuTest/MenuTest.h b/tests/tests/MenuTest/MenuTest.h index 5f2dc575ba..4f9393514d 100644 --- a/tests/tests/MenuTest/MenuTest.h +++ b/tests/tests/MenuTest/MenuTest.h @@ -20,7 +20,7 @@ public: virtual void ccTouchCancelled(CCTouch *touch, CCEvent * pEvent); virtual void ccTouchMoved(CCTouch *touch, CCEvent * pEvent); - void allowTouches(ccTime dt); + void allowTouches(float dt); void menuCallback(CCObject* pSender); void menuCallbackConfig(CCObject* pSender); void menuCallbackDisabled(CCObject* pSender); diff --git a/tests/tests/MotionStreakTest/MotionStreakTest.cpp b/tests/tests/MotionStreakTest/MotionStreakTest.cpp index 2dbc1deb5d..013bb30b97 100644 --- a/tests/tests/MotionStreakTest/MotionStreakTest.cpp +++ b/tests/tests/MotionStreakTest/MotionStreakTest.cpp @@ -56,7 +56,7 @@ void MotionStreakTest1::onEnter() streak = m_streak; } -void MotionStreakTest1::onUpdate(ccTime delta) +void MotionStreakTest1::onUpdate(float delta) { m_streak->setPosition( m_target->convertToWorldSpace(CCPointZero) ); } diff --git a/tests/tests/MotionStreakTest/MotionStreakTest.h b/tests/tests/MotionStreakTest/MotionStreakTest.h index 45dd68996e..0925f46a96 100644 --- a/tests/tests/MotionStreakTest/MotionStreakTest.h +++ b/tests/tests/MotionStreakTest/MotionStreakTest.h @@ -32,7 +32,7 @@ protected: public: virtual void onEnter(); - void onUpdate(ccTime delta); + void onUpdate(float delta); virtual std::string title(); }; diff --git a/tests/tests/NodeTest/NodeTest.cpp b/tests/tests/NodeTest/NodeTest.cpp index bb8ce6314d..e62589dc5d 100644 --- a/tests/tests/NodeTest/NodeTest.cpp +++ b/tests/tests/NodeTest/NodeTest.cpp @@ -232,14 +232,14 @@ Test4::Test4() schedule( schedule_selector(Test4::delay4), 4.0f); } -void Test4::delay2(ccTime dt) +void Test4::delay2(float dt) { CCSprite* node = (CCSprite*)(getChildByTag(2)); CCAction* action1 = CCRotateBy::actionWithDuration(1, 360); node->runAction(action1); } -void Test4::delay4(ccTime dt) +void Test4::delay4(float dt) { unschedule(schedule_selector(Test4::delay4)); removeChildByTag(3, false); @@ -282,7 +282,7 @@ Test5::Test5() schedule( schedule_selector(Test5::addAndRemove), 2.0f); } -void Test5::addAndRemove(ccTime dt) +void Test5::addAndRemove(float dt) { CCNode* sp1 = getChildByTag(kTagSprite1); CCNode* sp2 = getChildByTag(kTagSprite2); @@ -343,7 +343,7 @@ Test6::Test6() schedule( schedule_selector(Test6::addAndRemove), 2.0f); } -void Test6::addAndRemove(ccTime dt) +void Test6::addAndRemove(float dt) { CCNode* sp1 = getChildByTag(kTagSprite1); CCNode* sp2 = getChildByTag(kTagSprite2); @@ -384,7 +384,7 @@ StressTest1::StressTest1() schedule( schedule_selector(StressTest1::shouldNotCrash), 1.0f); } -void StressTest1::shouldNotCrash(ccTime dt) +void StressTest1::shouldNotCrash(float dt) { unschedule(schedule_selector(StressTest1::shouldNotCrash)); @@ -455,7 +455,7 @@ StressTest2::StressTest2() addChild(sublayer, 0, kTagSprite1); } -void StressTest2::shouldNotLeak(ccTime dt) +void StressTest2::shouldNotLeak(float dt) { unschedule( schedule_selector(StressTest2::shouldNotLeak) ); CCLayer* sublayer = (CCLayer*)getChildByTag(kTagSprite1); @@ -482,13 +482,13 @@ SchedulerTest1::SchedulerTest1() //UXLOG("retain count after addChild is %d", layer->retainCount()); // 2 layer->schedule( schedule_selector(SchedulerTest1::doSomething) ); - //UXLOG("retain count after schedule is %d", layer->retainCount()); // 3 : (object-c viersion), but win32 version is still 2, because CCTimer class don't save target. + //UXLOG("retain count after schedule is %d", layer->retainCount()); // 3 : (object-c viersion), but win32 version is still 2, because floatr class don't save target. layer->unschedule(schedule_selector(SchedulerTest1::doSomething)); //UXLOG("retain count after unschedule is %d", layer->retainCount()); // STILL 3! (win32 is '2') } -void SchedulerTest1::doSomething(ccTime dt) +void SchedulerTest1::doSomething(float dt) { } @@ -657,7 +657,7 @@ CameraZoomTest::CameraZoomTest() scheduleUpdate(); } -void CameraZoomTest::update(ccTime dt) +void CameraZoomTest::update(float dt) { CCNode *sprite; CCCamera *cam; diff --git a/tests/tests/NodeTest/NodeTest.h b/tests/tests/NodeTest/NodeTest.h index 1a999c2ee5..277625325a 100644 --- a/tests/tests/NodeTest/NodeTest.h +++ b/tests/tests/NodeTest/NodeTest.h @@ -30,8 +30,8 @@ class Test4 : public TestCocosNodeDemo { public: Test4(); - void delay2(ccTime dt); - void delay4(ccTime dt); + void delay2(float dt); + void delay4(float dt); virtual std::string title(); }; @@ -40,7 +40,7 @@ class Test5 : public TestCocosNodeDemo { public: Test5(); - void addAndRemove(ccTime dt); + void addAndRemove(float dt); virtual std::string title(); }; @@ -49,14 +49,14 @@ class Test6 : public TestCocosNodeDemo { public: Test6(); - void addAndRemove(ccTime dt); + void addAndRemove(float dt); virtual std::string title(); }; class StressTest1 : public TestCocosNodeDemo { - void shouldNotCrash(ccTime dt); + void shouldNotCrash(float dt); void removeMe(CCNode* node); public: StressTest1(); @@ -66,7 +66,7 @@ public: class StressTest2 : public TestCocosNodeDemo { - void shouldNotLeak(ccTime dt); + void shouldNotLeak(float dt); public: StressTest2(); @@ -77,7 +77,7 @@ class SchedulerTest1 : public TestCocosNodeDemo { public: SchedulerTest1(); - void doSomething(ccTime dt); + void doSomething(float dt); virtual std::string title(); }; @@ -104,7 +104,7 @@ class CameraZoomTest : public TestCocosNodeDemo float m_z; public: CameraZoomTest(); - void update(ccTime dt); + void update(float dt); virtual void onEnter(); virtual void onExit(); diff --git a/tests/tests/ParticleTest/ParticleTest.cpp b/tests/tests/ParticleTest/ParticleTest.cpp index e4bcf31988..cc2d44a15b 100644 --- a/tests/tests/ParticleTest/ParticleTest.cpp +++ b/tests/tests/ParticleTest/ParticleTest.cpp @@ -914,7 +914,7 @@ void Issue870::onEnter() schedule(schedule_selector(Issue870::updateQuads), 2.0f); } -void Issue870::updateQuads(ccTime dt) +void Issue870::updateQuads(float dt) { m_nIndex = (m_nIndex + 1) % 4; CCRect rect = CCRectMake(m_nIndex * 32, 0, 32, 32); @@ -1168,7 +1168,7 @@ void ParticleDemo::ccTouchEnded(CCTouch* touch, CCEvent* event) } } -void ParticleDemo::update(ccTime dt) +void ParticleDemo::update(float dt) { if (m_emitter) { @@ -1252,7 +1252,7 @@ void ParticleBatchHybrid::onEnter() m_pParent2 = node; } -void ParticleBatchHybrid::switchRender(ccTime dt) +void ParticleBatchHybrid::switchRender(float dt) { bool usingBatch = ( m_emitter->getBatchNode() != NULL ); m_emitter->removeFromParentAndCleanup(false); @@ -1373,7 +1373,7 @@ std::string ParticleReorder::subtitle() return "Reordering particles with and without batches batches"; } -void ParticleReorder::reorderParticles(ccTime dt) +void ParticleReorder::reorderParticles(float dt) { for( int i=0; i<2;i++) { CCNode *parent = getChildByTag(1000+i); @@ -1407,7 +1407,7 @@ class RainbowEffect : public CCParticleSystemQuad public: bool init(); virtual bool initWithTotalParticles(unsigned int numberOfParticles); - virtual void update(ccTime dt); + virtual void update(float dt); }; bool RainbowEffect::init() @@ -1481,7 +1481,7 @@ bool RainbowEffect::initWithTotalParticles(unsigned int numberOfParticles) return false; } -void RainbowEffect::update(ccTime dt) +void RainbowEffect::update(float dt) { m_fEmitCounter = 0; CCParticleSystemQuad::update(dt); @@ -1551,7 +1551,7 @@ std::string MultipleParticleSystems::subtitle() return "v1.1 test: FPS should be lower than next test"; } -void MultipleParticleSystems::update(ccTime dt) +void MultipleParticleSystems::update(float dt) { CCLabelAtlas *atlas = (CCLabelAtlas*) getChildByTag(kTagParticleCount); @@ -1602,7 +1602,7 @@ void MultipleParticleSystemsBatched::onEnter() m_emitter = NULL; } -void MultipleParticleSystemsBatched::update(ccTime dt) +void MultipleParticleSystemsBatched::update(float dt) { CCLabelAtlas *atlas = (CCLabelAtlas*) getChildByTag(kTagParticleCount); @@ -1668,7 +1668,7 @@ void AddAndDeleteParticleSystems::onEnter() } -void AddAndDeleteParticleSystems::removeSystem(ccTime dt) +void AddAndDeleteParticleSystems::removeSystem(float dt) { int nChildrenCount = m_pBatchNode->getChildren()->count(); if (nChildrenCount > 0) @@ -1691,7 +1691,7 @@ void AddAndDeleteParticleSystems::removeSystem(ccTime dt) } } -void AddAndDeleteParticleSystems::update(ccTime dt) +void AddAndDeleteParticleSystems::update(float dt) { CCLabelAtlas *atlas = (CCLabelAtlas*) getChildByTag(kTagParticleCount); @@ -1820,14 +1820,14 @@ void ReorderParticleSystems::onEnter() } -void ReorderParticleSystems::reorderSystem(ccTime time) +void ReorderParticleSystems::reorderSystem(float time) { CCParticleSystem* system = (CCParticleSystem*)m_pBatchNode->getChildren()->objectAtIndex(1); m_pBatchNode->reorderChild(system, system->getZOrder() - 1); } -void ReorderParticleSystems::update(ccTime dt) +void ReorderParticleSystems::update(float dt) { CCLabelAtlas *atlas = (CCLabelAtlas*) getChildByTag(kTagParticleCount); diff --git a/tests/tests/ParticleTest/ParticleTest.h b/tests/tests/ParticleTest/ParticleTest.h index 7965d67aee..0156127607 100644 --- a/tests/tests/ParticleTest/ParticleTest.h +++ b/tests/tests/ParticleTest/ParticleTest.h @@ -36,7 +36,7 @@ public: virtual void ccTouchMoved(CCTouch* touch, CCEvent* event); virtual void ccTouchEnded(CCTouch* touch, CCEvent* event); - virtual void update(ccTime dt); + virtual void update(float dt); void setEmitterPosition(); }; @@ -195,7 +195,7 @@ public: virtual void onEnter(); virtual std::string title(); virtual std::string subtitle(); - void updateQuads(ccTime dt); + void updateQuads(float dt); private: int m_nIndex; @@ -213,7 +213,7 @@ class ParticleBatchHybrid : public ParticleDemo { public: virtual void onEnter(); - void switchRender(ccTime dt); + void switchRender(float dt); virtual std::string title(); virtual std::string subtitle(); private: @@ -233,7 +233,7 @@ class ParticleReorder : public ParticleDemo { public: virtual void onEnter(); - void reorderParticles(ccTime dt); + void reorderParticles(float dt); virtual std::string title(); virtual std::string subtitle(); private: @@ -246,14 +246,14 @@ public: virtual void onEnter(); virtual std::string title(); virtual std::string subtitle(); - virtual void update(ccTime dt); + virtual void update(float dt); }; class MultipleParticleSystemsBatched : public ParticleDemo { public: virtual void onEnter(); - virtual void update(ccTime dt); + virtual void update(float dt); virtual std::string title(); virtual std::string subtitle(); private: @@ -264,8 +264,8 @@ class AddAndDeleteParticleSystems : public ParticleDemo { public: virtual void onEnter(); - virtual void update(ccTime dt); - void removeSystem(ccTime dt); + virtual void update(float dt); + void removeSystem(float dt); virtual std::string title(); virtual std::string subtitle(); private: @@ -276,8 +276,8 @@ class ReorderParticleSystems : public ParticleDemo { public: virtual void onEnter(); - void reorderSystem(ccTime time); - virtual void update(ccTime dt); + void reorderSystem(float time); + virtual void update(float dt); virtual std::string title(); virtual std::string subtitle(); private: diff --git a/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp b/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp index e1a1636f9f..676cf01904 100644 --- a/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -223,7 +223,7 @@ std::string IterateSpriteSheet::profilerName() // IterateSpriteSheetFastEnum // //////////////////////////////////////////////////////// -void IterateSpriteSheetFastEnum::update(ccTime dt) +void IterateSpriteSheetFastEnum::update(float dt) { // iterate using fast enumeration protocol CCArray* pChildren = batchNode->getChildren(); @@ -264,7 +264,7 @@ std::string IterateSpriteSheetFastEnum::profilerName() // IterateSpriteSheetCArray // //////////////////////////////////////////////////////// -void IterateSpriteSheetCArray::update(ccTime dt) +void IterateSpriteSheetCArray::update(float dt) { // iterate using fast enumeration protocol CCArray* pChildren = batchNode->getChildren(); @@ -366,7 +366,7 @@ std::string AddRemoveSpriteSheet::profilerName() // AddSpriteSheet // //////////////////////////////////////////////////////// -void AddSpriteSheet::update(ccTime dt) +void AddSpriteSheet::update(float dt) { // reset seed //srandom(0); @@ -431,7 +431,7 @@ std::string AddSpriteSheet::profilerName() // RemoveSpriteSheet // //////////////////////////////////////////////////////// -void RemoveSpriteSheet::update(ccTime dt) +void RemoveSpriteSheet::update(float dt) { //srandom(0); @@ -491,7 +491,7 @@ std::string RemoveSpriteSheet::profilerName() // ReorderSpriteSheet // //////////////////////////////////////////////////////// -void ReorderSpriteSheet::update(ccTime dt) +void ReorderSpriteSheet::update(float dt) { //srandom(0); diff --git a/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.h b/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.h index a0ccb29d57..448659c7b1 100644 --- a/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.h +++ b/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.h @@ -37,7 +37,7 @@ public: ~IterateSpriteSheet(); virtual void updateQuantityOfNodes(); virtual void initWithQuantityOfNodes(unsigned int nNodes); - virtual void update(ccTime dt) = 0; + virtual void update(float dt) = 0; virtual std::string profilerName(); protected: @@ -51,7 +51,7 @@ protected: class IterateSpriteSheetFastEnum : public IterateSpriteSheet { public: - virtual void update(ccTime dt); + virtual void update(float dt); virtual std::string title(); virtual std::string subtitle(); @@ -61,7 +61,7 @@ public: class IterateSpriteSheetCArray : public IterateSpriteSheet { public: - virtual void update(ccTime dt); + virtual void update(float dt); virtual std::string title(); virtual std::string subtitle(); @@ -74,7 +74,7 @@ public: ~AddRemoveSpriteSheet(); virtual void updateQuantityOfNodes(); virtual void initWithQuantityOfNodes(unsigned int nNodes); - virtual void update(ccTime dt) = 0; + virtual void update(float dt) = 0; virtual std::string profilerName(); protected: @@ -88,7 +88,7 @@ protected: class AddSpriteSheet : public AddRemoveSpriteSheet { public: - virtual void update(ccTime dt); + virtual void update(float dt); virtual std::string title(); virtual std::string subtitle(); @@ -98,7 +98,7 @@ public: class RemoveSpriteSheet : public AddRemoveSpriteSheet { public: - virtual void update(ccTime dt); + virtual void update(float dt); virtual std::string title(); virtual std::string subtitle(); @@ -108,7 +108,7 @@ public: class ReorderSpriteSheet : public AddRemoveSpriteSheet { public: - virtual void update(ccTime dt); + virtual void update(float dt); virtual std::string title(); virtual std::string subtitle(); diff --git a/tests/tests/PerformanceTest/PerformanceParticleTest.cpp b/tests/tests/PerformanceTest/PerformanceParticleTest.cpp index 343556470c..0701cb82a5 100644 --- a/tests/tests/PerformanceTest/PerformanceParticleTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceParticleTest.cpp @@ -144,7 +144,7 @@ std::string ParticleMainScene::title() return "No title"; } -void ParticleMainScene::step(ccTime dt) +void ParticleMainScene::step(float dt) { CCLabelAtlas *atlas = (CCLabelAtlas*) getChildByTag(kTagLabelAtlas); CCParticleSystem *emitter = (CCParticleSystem*) getChildByTag(kTagParticleSystem); diff --git a/tests/tests/PerformanceTest/PerformanceParticleTest.h b/tests/tests/PerformanceTest/PerformanceParticleTest.h index 03cce4ae89..636689a9cc 100644 --- a/tests/tests/PerformanceTest/PerformanceParticleTest.h +++ b/tests/tests/PerformanceTest/PerformanceParticleTest.h @@ -16,7 +16,7 @@ public: virtual void initWithSubTest(int subtest, int particles); virtual std::string title(); - void step(ccTime dt); + void step(float dt); void createParticleSystem(); void onDecrease(CCObject* pSender); void onIncrease(CCObject* pSender); diff --git a/tests/tests/PerformanceTest/PerformanceTouchesTest.cpp b/tests/tests/PerformanceTest/PerformanceTouchesTest.cpp index 33ff66f18b..e4e0b5782b 100644 --- a/tests/tests/PerformanceTest/PerformanceTouchesTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceTouchesTest.cpp @@ -57,7 +57,7 @@ void TouchesMainScene::onEnter() numberOfTouchesB = numberOfTouchesM = numberOfTouchesE = numberOfTouchesC = 0; } -void TouchesMainScene::update(ccTime dt) +void TouchesMainScene::update(float dt) { elapsedTime += dt; diff --git a/tests/tests/PerformanceTest/PerformanceTouchesTest.h b/tests/tests/PerformanceTest/PerformanceTouchesTest.h index 2cfbce6ae9..573d22470a 100644 --- a/tests/tests/PerformanceTest/PerformanceTouchesTest.h +++ b/tests/tests/PerformanceTest/PerformanceTouchesTest.h @@ -14,7 +14,7 @@ public: virtual void showCurrentTest(); virtual void onEnter(); virtual std::string title(); - virtual void update(ccTime dt); + virtual void update(float dt); protected: CCLabelBMFont * m_plabel; @@ -22,7 +22,7 @@ protected: int numberOfTouchesM; int numberOfTouchesE; int numberOfTouchesC; - ccTime elapsedTime; + float elapsedTime; }; class TouchesPerformTest1 : public TouchesMainScene diff --git a/tests/tests/RenderTextureTest/RenderTextureTest.cpp b/tests/tests/RenderTextureTest/RenderTextureTest.cpp index 821fbcf970..b4f42d3410 100644 --- a/tests/tests/RenderTextureTest/RenderTextureTest.cpp +++ b/tests/tests/RenderTextureTest/RenderTextureTest.cpp @@ -195,7 +195,7 @@ void RenderTextureTest::ccTouchesMoved(CCSet* touches, CCEvent* event) void RenderTextureTest::ccTouchesEnded(CCSet* touches, CCEvent* event) { -#if CC_ENABLE_CACHE_TEXTTURE_DATA +#if CC_ENABLE_CACHE_TEXTURE_DATA CCSetIterator it; CCTouch* touch; diff --git a/tests/tests/SceneTest/SceneTest.cpp b/tests/tests/SceneTest/SceneTest.cpp index 22fb630065..d325d0a5b8 100644 --- a/tests/tests/SceneTest/SceneTest.cpp +++ b/tests/tests/SceneTest/SceneTest.cpp @@ -38,7 +38,7 @@ SceneTestLayer1::SceneTestLayer1() schedule( schedule_selector(SceneTestLayer1::testDealloc) ); } -void SceneTestLayer1::testDealloc(ccTime dt) +void SceneTestLayer1::testDealloc(float dt) { //UXLOG("SceneTestLayer1:testDealloc"); } @@ -123,7 +123,7 @@ SceneTestLayer2::SceneTestLayer2() schedule( schedule_selector(SceneTestLayer2::testDealloc) ); } -void SceneTestLayer2::testDealloc(ccTime dt) +void SceneTestLayer2::testDealloc(float dt) { //m_timeCounter += dt; //if( m_timeCounter > 10 ) @@ -180,7 +180,7 @@ SceneTestLayer3::SceneTestLayer3() //schedule(); } -void SceneTestLayer3::testDealloc(ccTime dt) +void SceneTestLayer3::testDealloc(float dt) { } diff --git a/tests/tests/SceneTest/SceneTest.h b/tests/tests/SceneTest/SceneTest.h index 586788fede..c4bfb75a5d 100644 --- a/tests/tests/SceneTest/SceneTest.h +++ b/tests/tests/SceneTest/SceneTest.h @@ -13,7 +13,7 @@ public: virtual void onEnter(); virtual void onEnterTransitionDidFinish(); - void testDealloc(ccTime dt); + void testDealloc(float dt); void onPushScene(CCObject* pSender); void onPushSceneTran(CCObject* pSender); void onQuit(CCObject* pSender); @@ -27,7 +27,7 @@ class SceneTestLayer2 : public CCLayer public: SceneTestLayer2(); - void testDealloc(ccTime dt); + void testDealloc(float dt); void onGoBack(CCObject* pSender); void onReplaceScene(CCObject* pSender); void onReplaceSceneTran(CCObject* pSender); @@ -40,7 +40,7 @@ class SceneTestLayer3 : public CCLayerColor public: SceneTestLayer3(); - virtual void testDealloc(ccTime dt); + virtual void testDealloc(float dt); virtual void ccTouchesEnded(CCSet* touches, CCEvent* event); diff --git a/tests/tests/SchedulerTest/SchedulerTest.cpp b/tests/tests/SchedulerTest/SchedulerTest.cpp index 14180c1a6b..0a8163dba8 100644 --- a/tests/tests/SchedulerTest/SchedulerTest.cpp +++ b/tests/tests/SchedulerTest/SchedulerTest.cpp @@ -161,7 +161,7 @@ void SchedulerAutoremove::onEnter() accum = 0; } -void SchedulerAutoremove::autoremove(ccTime dt) +void SchedulerAutoremove::autoremove(float dt) { accum += dt; CCLOG("Time: %f", accum); @@ -173,7 +173,7 @@ void SchedulerAutoremove::autoremove(ccTime dt) } } -void SchedulerAutoremove::tick(ccTime dt) +void SchedulerAutoremove::tick(float dt) { CCLOG("This scheduler should not be removed"); } @@ -202,17 +202,17 @@ void SchedulerPauseResume::onEnter() schedule(schedule_selector(SchedulerPauseResume::pause), 0.5f); } -void SchedulerPauseResume::tick1(ccTime dt) +void SchedulerPauseResume::tick1(float dt) { CCLOG("tick1"); } -void SchedulerPauseResume::tick2(ccTime dt) +void SchedulerPauseResume::tick2(float dt) { CCLOG("tick2"); } -void SchedulerPauseResume::pause(ccTime dt) +void SchedulerPauseResume::pause(float dt) { CCDirector::sharedDirector()->getScheduler()->pauseTarget(this); } @@ -243,27 +243,27 @@ void SchedulerUnscheduleAll::onEnter() schedule(schedule_selector(SchedulerUnscheduleAll::unscheduleAll), 4); } -void SchedulerUnscheduleAll::tick1(ccTime dt) +void SchedulerUnscheduleAll::tick1(float dt) { CCLOG("tick1"); } -void SchedulerUnscheduleAll::tick2(ccTime dt) +void SchedulerUnscheduleAll::tick2(float dt) { CCLOG("tick2"); } -void SchedulerUnscheduleAll::tick3(ccTime dt) +void SchedulerUnscheduleAll::tick3(float dt) { CCLOG("tick3"); } -void SchedulerUnscheduleAll::tick4(ccTime dt) +void SchedulerUnscheduleAll::tick4(float dt) { CCLOG("tick4"); } -void SchedulerUnscheduleAll::unscheduleAll(ccTime dt) +void SchedulerUnscheduleAll::unscheduleAll(float dt) { unscheduleAllSelectors(); } @@ -294,27 +294,27 @@ void SchedulerUnscheduleAllHard::onEnter() schedule(schedule_selector(SchedulerUnscheduleAllHard::unscheduleAll), 4); } -void SchedulerUnscheduleAllHard::tick1(ccTime dt) +void SchedulerUnscheduleAllHard::tick1(float dt) { CCLOG("tick1"); } -void SchedulerUnscheduleAllHard::tick2(ccTime dt) +void SchedulerUnscheduleAllHard::tick2(float dt) { CCLOG("tick2"); } -void SchedulerUnscheduleAllHard::tick3(ccTime dt) +void SchedulerUnscheduleAllHard::tick3(float dt) { CCLOG("tick3"); } -void SchedulerUnscheduleAllHard::tick4(ccTime dt) +void SchedulerUnscheduleAllHard::tick4(float dt) { CCLOG("tick4"); } -void SchedulerUnscheduleAllHard::unscheduleAll(ccTime dt) +void SchedulerUnscheduleAllHard::unscheduleAll(float dt) { CCDirector::sharedDirector()->getScheduler()->unscheduleAllSelectors(); } @@ -343,22 +343,22 @@ void SchedulerSchedulesAndRemove::onEnter() schedule(schedule_selector(SchedulerSchedulesAndRemove::scheduleAndUnschedule), 4.0f); } -void SchedulerSchedulesAndRemove::tick1(ccTime dt) +void SchedulerSchedulesAndRemove::tick1(float dt) { CCLOG("tick1"); } -void SchedulerSchedulesAndRemove::tick2(ccTime dt) +void SchedulerSchedulesAndRemove::tick2(float dt) { CCLOG("tick2"); } -void SchedulerSchedulesAndRemove::tick3(ccTime dt) +void SchedulerSchedulesAndRemove::tick3(float dt) { CCLOG("tick3"); } -void SchedulerSchedulesAndRemove::tick4(ccTime dt) +void SchedulerSchedulesAndRemove::tick4(float dt) { CCLOG("tick4"); } @@ -373,7 +373,7 @@ std::string SchedulerSchedulesAndRemove::subtitle() return "Will unschedule and schedule selectors in 4s. See console"; } -void SchedulerSchedulesAndRemove::scheduleAndUnschedule(ccTime dt) +void SchedulerSchedulesAndRemove::scheduleAndUnschedule(float dt) { unschedule(schedule_selector(SchedulerSchedulesAndRemove::tick1)); unschedule(schedule_selector(SchedulerSchedulesAndRemove::tick2)); @@ -454,7 +454,7 @@ void SchedulerUpdate::onEnter() schedule(schedule_selector(SchedulerUpdate::removeUpdates), 4.0f); } -void SchedulerUpdate::removeUpdates(ccTime dt) +void SchedulerUpdate::removeUpdates(float dt) { CCArray* children = getChildren(); CCNode* pNode; @@ -495,17 +495,17 @@ void SchedulerUpdateAndCustom::onEnter() schedule(schedule_selector(SchedulerUpdateAndCustom::stopSelectors), 0.4f); } -void SchedulerUpdateAndCustom::update(ccTime dt) +void SchedulerUpdateAndCustom::update(float dt) { CCLOG("update called:%f", dt); } -void SchedulerUpdateAndCustom::tick(ccTime dt) +void SchedulerUpdateAndCustom::tick(float dt) { CCLOG("custom selector called:%f",dt); } -void SchedulerUpdateAndCustom::stopSelectors(ccTime dt) +void SchedulerUpdateAndCustom::stopSelectors(float dt) { unscheduleAllSelectors(); } @@ -532,19 +532,19 @@ void SchedulerUpdateFromCustom::onEnter() schedule(schedule_selector(SchedulerUpdateFromCustom::schedUpdate), 2.0f); } -void SchedulerUpdateFromCustom::update(ccTime dt) +void SchedulerUpdateFromCustom::update(float dt) { CCLOG("update called:%f", dt); } -void SchedulerUpdateFromCustom::schedUpdate(ccTime dt) +void SchedulerUpdateFromCustom::schedUpdate(float dt) { unschedule(schedule_selector(SchedulerUpdateFromCustom::schedUpdate)); scheduleUpdate(); schedule(schedule_selector(SchedulerUpdateFromCustom::stopUpdate), 2.0f); } -void SchedulerUpdateFromCustom::stopUpdate(ccTime dt) +void SchedulerUpdateFromCustom::stopUpdate(float dt) { unscheduleUpdate(); unschedule(schedule_selector(SchedulerUpdateFromCustom::stopUpdate)); @@ -584,7 +584,7 @@ std::string RescheduleSelector::subtitle() return "Interval is 1 second, then 2, then 3..."; } -void RescheduleSelector::schedUpdate(ccTime dt) +void RescheduleSelector::schedUpdate(float dt) { m_nTicks++; @@ -616,7 +616,7 @@ std::string SchedulerDelayAndRepeat::subtitle() return "After 5 x executed, method unscheduled. See console"; } -void SchedulerDelayAndRepeat::update(ccTime dt) +void SchedulerDelayAndRepeat::update(float dt) { CCLog("update called:%f", dt); } @@ -639,7 +639,7 @@ CCControlSlider* SchedulerTimeScale::sliderCtl() void SchedulerTimeScale::sliderAction(CCObject* pSender) { CCControlSlider* pSliderCtl = (CCControlSlider*)pSender; - ccTime scale; + float scale; scale = pSliderCtl->getValue(); CCDirector::sharedDirector()->getScheduler()->setTimeScale(scale); @@ -730,7 +730,7 @@ CCControlSlider *TwoSchedulers::sliderCtl() void TwoSchedulers::sliderAction(CCObject* sender) { - ccTime scale; + float scale; CCControlSlider *slider = (CCControlSlider*) sender; scale = slider->getValue(); diff --git a/tests/tests/SchedulerTest/SchedulerTest.h b/tests/tests/SchedulerTest/SchedulerTest.h index 514105328f..f84899375f 100644 --- a/tests/tests/SchedulerTest/SchedulerTest.h +++ b/tests/tests/SchedulerTest/SchedulerTest.h @@ -36,10 +36,10 @@ public: virtual std::string title(); virtual std::string subtitle(); - void autoremove(ccTime dt); - void tick(ccTime dt); + void autoremove(float dt); + void tick(float dt); private: - ccTime accum; + float accum; }; class SchedulerPauseResume : public SchedulerTestLayer @@ -49,9 +49,9 @@ public: virtual std::string title(); virtual std::string subtitle(); - void tick1(ccTime dt); - void tick2(ccTime dt); - void pause(ccTime dt); + void tick1(float dt); + void tick2(float dt); + void pause(float dt); }; class SchedulerUnscheduleAll : public SchedulerTestLayer @@ -61,11 +61,11 @@ public: virtual std::string title(); virtual std::string subtitle(); - void tick1(ccTime dt); - void tick2(ccTime dt); - void tick3(ccTime dt); - void tick4(ccTime dt); - void unscheduleAll(ccTime dt); + void tick1(float dt); + void tick2(float dt); + void tick3(float dt); + void tick4(float dt); + void unscheduleAll(float dt); }; class SchedulerUnscheduleAllHard : public SchedulerTestLayer @@ -75,11 +75,11 @@ public: virtual std::string title(); virtual std::string subtitle(); - void tick1(ccTime dt); - void tick2(ccTime dt); - void tick3(ccTime dt); - void tick4(ccTime dt); - void unscheduleAll(ccTime dt); + void tick1(float dt); + void tick2(float dt); + void tick3(float dt); + void tick4(float dt); + void unscheduleAll(float dt); }; class SchedulerSchedulesAndRemove : public SchedulerTestLayer @@ -89,11 +89,11 @@ public: virtual std::string title(); virtual std::string subtitle(); - void tick1(ccTime dt); - void tick2(ccTime dt); - void tick3(ccTime dt); - void tick4(ccTime dt); - void scheduleAndUnschedule(ccTime dt); + void tick1(float dt); + void tick2(float dt); + void tick3(float dt); + void tick4(float dt); + void scheduleAndUnschedule(float dt); }; class SchedulerUpdate : public SchedulerTestLayer @@ -103,7 +103,7 @@ public: virtual std::string title(); virtual std::string subtitle(); - void removeUpdates(ccTime dt); + void removeUpdates(float dt); }; class SchedulerUpdateAndCustom : public SchedulerTestLayer @@ -113,9 +113,9 @@ public: virtual std::string title(); virtual std::string subtitle(); - void update(ccTime dt); - void tick(ccTime dt); - void stopSelectors(ccTime dt); + void update(float dt); + void tick(float dt); + void stopSelectors(float dt); }; class SchedulerUpdateFromCustom : public SchedulerTestLayer @@ -125,9 +125,9 @@ public: virtual std::string title(); virtual std::string subtitle(); - void update(ccTime dt); - void schedUpdate(ccTime dt); - void stopUpdate(ccTime dt); + void update(float dt); + void schedUpdate(float dt); + void stopUpdate(float dt); }; class TestNode : public CCNode @@ -147,7 +147,7 @@ public: virtual std::string title(); virtual std::string subtitle(); - void schedUpdate(ccTime dt); + void schedUpdate(float dt); private: float m_fInterval; int m_nTicks; @@ -159,7 +159,7 @@ public: virtual void onEnter(); virtual std::string title(); virtual std::string subtitle(); - void update(ccTime dt); + void update(float dt); }; class SchedulerTimeScale : public SchedulerTestLayer diff --git a/tests/tests/ShaderTest/ShaderTest.cpp b/tests/tests/ShaderTest/ShaderTest.cpp index 77df392079..3232d8b54d 100644 --- a/tests/tests/ShaderTest/ShaderTest.cpp +++ b/tests/tests/ShaderTest/ShaderTest.cpp @@ -194,7 +194,7 @@ void ShaderNode::loadShaderVertex(const char *vert, const char *frag) shader->release(); } -void ShaderNode::update(ccTime dt) +void ShaderNode::update(float dt) { m_time += dt; } @@ -476,7 +476,7 @@ bool SpriteBlur::initWithTexture(CCTexture2D* texture, const CCRect& rect) sub_[0] = sub_[1] = sub_[2] = sub_[3] = 0; GLchar * fragSource = (GLchar*) CCString::stringWithContentsOfFile( - CCFileUtils::fullPathFromRelativePath("Shaders/example_Blur.fsh"))->getCString(); + CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("Shaders/example_Blur.fsh"))->getCString(); CCGLProgram* pProgram = new CCGLProgram(); pProgram->initWithVertexShaderByteArray(ccPositionTextureColor_vert, fragSource); setShaderProgram(pProgram); @@ -630,7 +630,7 @@ bool ShaderRetroEffect::init() { if( ShaderTestDemo::init() ) { - GLchar * fragSource = (GLchar*) CCString::stringWithContentsOfFile(CCFileUtils::fullPathFromRelativePath("Shaders/example_HorizontalColor.fsh"))->getCString(); + GLchar * fragSource = (GLchar*) CCString::stringWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("Shaders/example_HorizontalColor.fsh"))->getCString(); CCGLProgram *p = new CCGLProgram(); p->initWithVertexShaderByteArray(ccPositionTexture_vert, fragSource); @@ -662,7 +662,7 @@ bool ShaderRetroEffect::init() return false; } -void ShaderRetroEffect::update(ccTime dt) +void ShaderRetroEffect::update(float dt) { m_fAccum += dt; diff --git a/tests/tests/ShaderTest/ShaderTest.h b/tests/tests/ShaderTest/ShaderTest.h index 8912fd555f..99250a659c 100644 --- a/tests/tests/ShaderTest/ShaderTest.h +++ b/tests/tests/ShaderTest/ShaderTest.h @@ -102,10 +102,10 @@ public: virtual std::string title(); virtual std::string subtitle(); bool init(); - void update(ccTime dt); + void update(float dt); protected: CCLabelBMFont* m_pLabel; - ccTime m_fAccum; + float m_fAccum; }; class ShaderNode : public CCNode @@ -116,7 +116,7 @@ public: bool initWithVertex(const char *vert, const char *frag); void loadShaderVertex(const char *vert, const char *frag); - virtual void update(ccTime dt); + virtual void update(float dt); virtual void setPosition(const CCPoint &newPosition); virtual void draw(); diff --git a/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id b/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id index 648614cd0d..de1fc1f12a 100644 --- a/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id +++ b/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id @@ -1 +1 @@ -2e6b4ecbc083689855217489786150bb669823ed \ No newline at end of file +30f90defc4364cbcd8e686f75010ac83a50fb386 \ No newline at end of file diff --git a/tests/tests/SpriteTest/SpriteTest.h b/tests/tests/SpriteTest/SpriteTest.h index 2081ee3bad..e94da4971f 100644 --- a/tests/tests/SpriteTest/SpriteTest.h +++ b/tests/tests/SpriteTest/SpriteTest.h @@ -46,7 +46,7 @@ class SpriteColorOpacity : public SpriteTestDemo { public: SpriteColorOpacity(); - void removeAndAddSprite(ccTime dt); + void removeAndAddSprite(float dt); virtual std::string title(); }; @@ -54,7 +54,7 @@ class SpriteBatchNodeColorOpacity : public SpriteTestDemo { public: SpriteBatchNodeColorOpacity(); - void removeAndAddSprite(ccTime dt); + void removeAndAddSprite(float dt); virtual std::string title(); }; @@ -63,7 +63,7 @@ class SpriteZOrder : public SpriteTestDemo int m_dir; public: SpriteZOrder(); - void reorderSprite(ccTime dt); + void reorderSprite(float dt); virtual std::string title(); }; @@ -72,7 +72,7 @@ class SpriteBatchNodeZOrder: public SpriteTestDemo int m_dir; public: SpriteBatchNodeZOrder(); - void reorderSprite(ccTime dt); + void reorderSprite(float dt); virtual std::string title(); }; @@ -98,7 +98,7 @@ public: SpriteBatchNodeReorderIssue766(); virtual std::string title(); virtual std::string subtitle(); - void reorderSprite(ccTime dt); + void reorderSprite(float dt); CCSprite* makeSpriteZ(int aZ); private: @@ -114,7 +114,7 @@ public: SpriteBatchNodeReorderIssue767(); virtual std::string title(); virtual std::string subtitle(); - void reorderSprites(ccTime dt); + void reorderSprites(float dt); }; class SpriteZVertex: public SpriteTestDemo @@ -164,7 +164,7 @@ class SpriteFlip : public SpriteTestDemo { public: SpriteFlip(); - void flipSprites(ccTime dt); + void flipSprites(float dt); virtual std::string title(); }; @@ -172,7 +172,7 @@ class SpriteBatchNodeFlip : public SpriteTestDemo { public: SpriteBatchNodeFlip(); - void flipSprites(ccTime dt); + void flipSprites(float dt); virtual std::string title(); }; @@ -229,8 +229,8 @@ public: virtual std::string title(); virtual std::string subtitle(); - void startIn05Secs(ccTime dt); - void flipSprites(ccTime dt); + void startIn05Secs(float dt); + void flipSprites(float dt); private: CCSprite *m_pSprite1; CCSprite *m_pSprite2; @@ -341,7 +341,7 @@ class SpriteHybrid: public SpriteTestDemo bool m_usingSpriteBatchNode; public: SpriteHybrid(); - void reparentSprite(ccTime dt); + void reparentSprite(float dt); virtual std::string title(); virtual void onExit(); }; @@ -448,7 +448,7 @@ public: virtual std::string title(); virtual std::string subtitle(); - void reorderSprite(ccTime dt); + void reorderSprite(float dt); private: CCNode *m_pNode; @@ -466,7 +466,7 @@ public: virtual std::string title(); virtual std::string subtitle(); - void reorderSprite(ccTime dt); + void reorderSprite(float dt); private: CCSpriteBatchNode *m_pBatchNode; @@ -481,7 +481,7 @@ class SpriteBatchNodeReorderOneChild : public SpriteTestDemo { public: SpriteBatchNodeReorderOneChild(); - void reorderSprite(ccTime dt); + void reorderSprite(float dt); virtual std::string title(); private: CCSpriteBatchNode *m_pBatchNode; diff --git a/tests/tests/TextInputTest/TextInputTest.cpp b/tests/tests/TextInputTest/TextInputTest.cpp index 773a789553..d870c6447a 100644 --- a/tests/tests/TextInputTest/TextInputTest.cpp +++ b/tests/tests/TextInputTest/TextInputTest.cpp @@ -409,7 +409,7 @@ bool TextFieldTTFActionTest::onTextFieldInsertText(CCTextFieldTTF * pSender, con CCSize inputTextSize = label->getContentSize(); CCPoint beginPos(endPos.x, CCDirector::sharedDirector()->getWinSize().height - inputTextSize.height * 2); - ccTime duration = 0.5; + float duration = 0.5; label->setPosition(beginPos); label->setScale(8); @@ -440,8 +440,8 @@ bool TextFieldTTFActionTest::onTextFieldDeleteBackward(CCTextFieldTTF * pSender, CCSize winSize = CCDirector::sharedDirector()->getWinSize(); CCPoint endPos(- winSize.width / 4.0f, winSize.height * (0.5 + (float)rand() / (2.0f * RAND_MAX))); - ccTime duration = 1; - ccTime rotateDuration = 0.2f; + float duration = 1; + float rotateDuration = 0.2f; int repeatTime = 5; label->setPosition(beginPos); diff --git a/tests/tests/Texture2dTest/Texture2dTest.cpp b/tests/tests/Texture2dTest/Texture2dTest.cpp index a26be88810..89b671e5b3 100644 --- a/tests/tests/Texture2dTest/Texture2dTest.cpp +++ b/tests/tests/Texture2dTest/Texture2dTest.cpp @@ -1133,7 +1133,7 @@ TextureAsync::~TextureAsync() CCTextureCache::sharedTextureCache()->removeAllTextures(); } -void TextureAsync::loadImages(ccTime dt) +void TextureAsync::loadImages(float dt) { for( int i=0;i < 8;i++) { for( int j=0;j < 8; j++) { @@ -1478,14 +1478,14 @@ void FileUtilsTest::onEnter() #if 0 // TODO:(CC_TARGET_PLATFORM == CC_PLATFORM_IOS) // Testint CCFileUtils API bool ret = false; - ret = CCFileUtils::iPhoneRetinaDisplayFileExistsAtPath("Images/bugs/test_issue_1179.png"); + ret = CCFileUtils::sharedFileUtils()->iPhoneRetinaDisplayFileExistsAtPath("Images/bugs/test_issue_1179.png"); if( ret ) CCLog("Test #3: retinaDisplayFileExistsAtPath: OK"); else CCLog("Test #3: retinaDisplayFileExistsAtPath: FAILED"); - ret = CCFileUtils::iPhoneRetinaDisplayFileExistsAtPath("grossini-does_no_exist.png"); + ret = CCFileUtils::sharedFileUtils()->iPhoneRetinaDisplayFileExistsAtPath("grossini-does_no_exist.png"); if( !ret ) CCLog("Test #4: retinaDisplayFileExistsAtPath: OK"); else diff --git a/tests/tests/Texture2dTest/Texture2dTest.h b/tests/tests/Texture2dTest/Texture2dTest.h index 3e30455cd5..ad0c837a19 100644 --- a/tests/tests/Texture2dTest/Texture2dTest.h +++ b/tests/tests/Texture2dTest/Texture2dTest.h @@ -234,7 +234,7 @@ class TextureAsync : public TextureDemo { public: virtual ~TextureAsync(); - void loadImages(ccTime dt); + void loadImages(float dt); void imageLoaded(CCObject* pObj); virtual std::string title(); virtual std::string subtitle(); diff --git a/tests/tests/TileMapTest/TileMapTest.cpp b/tests/tests/TileMapTest/TileMapTest.cpp index 7a9a7d918b..524fee7bc0 100644 --- a/tests/tests/TileMapTest/TileMapTest.cpp +++ b/tests/tests/TileMapTest/TileMapTest.cpp @@ -70,7 +70,7 @@ TileMapEditTest::TileMapEditTest() map->setPosition( ccp(-20,-200) ); } -void TileMapEditTest::updateMap(ccTime dt) +void TileMapEditTest::updateMap(float dt) { // IMPORTANT // The only limitation is that you cannot change an empty, or assign an empty tile to a tile @@ -278,7 +278,7 @@ TMXOrthoTest4::TMXOrthoTest4() } -void TMXOrthoTest4::removeSprite(ccTime dt) +void TMXOrthoTest4::removeSprite(float dt) { unschedule(schedule_selector(TMXOrthoTest4::removeSprite)); @@ -376,7 +376,7 @@ void TMXReadWriteTest::removeSprite(CCNode* sender) //////----UXLOG("atlas quantity: %d", p->textureAtlas()->totalQuads()); } -void TMXReadWriteTest::updateCol(ccTime dt) +void TMXReadWriteTest::updateCol(float dt) { CCTMXTiledMap* map = (CCTMXTiledMap*)getChildByTag(kTagTileMap); CCTMXLayer *layer = (CCTMXLayer*)map->getChildByTag(0); @@ -395,7 +395,7 @@ void TMXReadWriteTest::updateCol(ccTime dt) m_gid2 = (m_gid2 + 1) % 80; } -void TMXReadWriteTest::repaintWithGID(ccTime dt) +void TMXReadWriteTest::repaintWithGID(float dt) { // unschedule:_cmd); @@ -411,7 +411,7 @@ void TMXReadWriteTest::repaintWithGID(ccTime dt) } } -void TMXReadWriteTest::removeTiles(ccTime dt) +void TMXReadWriteTest::removeTiles(float dt) { unschedule(schedule_selector(TMXReadWriteTest::removeTiles)); @@ -835,7 +835,7 @@ void TMXIsoZorder::onExit() TileDemo::onExit(); } -void TMXIsoZorder::repositionSprite(ccTime dt) +void TMXIsoZorder::repositionSprite(float dt) { CCPoint p = m_tamara->getPosition(); p = CC_POINT_POINTS_TO_PIXELS(p); @@ -895,7 +895,7 @@ TMXOrthoZorder::~TMXOrthoZorder() m_tamara->release(); } -void TMXOrthoZorder::repositionSprite(ccTime dt) +void TMXOrthoZorder::repositionSprite(float dt) { CCPoint p = m_tamara->getPosition(); p = CC_POINT_POINTS_TO_PIXELS(p); @@ -958,7 +958,7 @@ TMXIsoVertexZ::~TMXIsoVertexZ() m_tamara->release(); } -void TMXIsoVertexZ::repositionSprite(ccTime dt) +void TMXIsoVertexZ::repositionSprite(float dt) { // tile height is 64x32 // map size: 30x30 @@ -1028,7 +1028,7 @@ TMXOrthoVertexZ::~TMXOrthoVertexZ() m_tamara->release(); } -void TMXOrthoVertexZ::repositionSprite(ccTime dt) +void TMXOrthoVertexZ::repositionSprite(float dt) { // tile height is 101x81 // map size: 12x12 @@ -1207,7 +1207,7 @@ std::string TMXOrthoFlipRunTimeTest::subtitle() return "in 2 sec bottom left tiles will flip"; } -void TMXOrthoFlipRunTimeTest::flipIt(ccTime dt) +void TMXOrthoFlipRunTimeTest::flipIt(float dt) { CCTMXTiledMap *map = (CCTMXTiledMap*) getChildByTag(kTagTileMap); CCTMXLayer *layer = map->layerNamed("Layer 0"); @@ -1254,7 +1254,7 @@ TMXOrthoFromXMLTest::TMXOrthoFromXMLTest() string resources = "TileMaps"; // partial paths are OK as resource paths. string file = resources + "/orthogonal-test1.tmx"; - CCString* str = CCString::stringWithContentsOfFile(CCFileUtils::fullPathFromRelativePath(file.c_str())); + CCString* str = CCString::stringWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(file.c_str())); CCAssert(str != NULL, "Unable to open file"); CCTMXTiledMap *map = CCTMXTiledMap::tiledMapWithXML(str->getCString() ,resources.c_str()); diff --git a/tests/tests/TileMapTest/TileMapTest.h b/tests/tests/TileMapTest/TileMapTest.h index 1c3ae4109b..e903dd9adb 100644 --- a/tests/tests/TileMapTest/TileMapTest.h +++ b/tests/tests/TileMapTest/TileMapTest.h @@ -41,7 +41,7 @@ public: TileMapEditTest (void); virtual std::string title(); - void updateMap(ccTime dt); + void updateMap(float dt); }; class TMXOrthoTest : public TileDemo @@ -72,7 +72,7 @@ class TMXOrthoTest4 : public TileDemo { public: TMXOrthoTest4(void); - void removeSprite(ccTime dt); + void removeSprite(float dt); virtual std::string title(); }; @@ -85,9 +85,9 @@ public: virtual std::string title(); void removeSprite(CCNode* sender); - void updateCol(ccTime dt); - void repaintWithGID(ccTime dt); - void removeTiles(ccTime dt); + void updateCol(float dt); + void repaintWithGID(float dt); + void removeTiles(float dt); }; class TMXHexTest : public TileDemo @@ -173,7 +173,7 @@ public: virtual void onExit(void); ~TMXIsoZorder(); - void repositionSprite(ccTime dt); + void repositionSprite(float dt); }; class TMXOrthoZorder : public TileDemo @@ -185,7 +185,7 @@ public: virtual std::string subtitle(); virtual ~TMXOrthoZorder(); - void repositionSprite(ccTime dt); + void repositionSprite(float dt); }; class TMXIsoVertexZ : public TileDemo @@ -197,7 +197,7 @@ public: virtual std::string subtitle(); ~TMXIsoVertexZ(); - void repositionSprite(ccTime dt); + void repositionSprite(float dt); virtual void onEnter(); virtual void onExit(); }; @@ -211,7 +211,7 @@ public: virtual std::string subtitle(); ~TMXOrthoVertexZ(); - void repositionSprite(ccTime dt); + void repositionSprite(float dt); virtual void onEnter(); virtual void onExit(); }; @@ -253,7 +253,7 @@ public: TMXOrthoFlipRunTimeTest(); virtual std::string title(); virtual std::string subtitle(); - void flipIt(ccTime dt); + void flipIt(float dt); }; class TMXOrthoFromXMLTest : public TileDemo diff --git a/tests/tests/TouchesTest/Ball.cpp b/tests/tests/TouchesTest/Ball.cpp index df68e7d8e5..a070367bbd 100644 --- a/tests/tests/TouchesTest/Ball.cpp +++ b/tests/tests/TouchesTest/Ball.cpp @@ -23,7 +23,7 @@ Ball* Ball::ballWithTexture(CCTexture2D* aTexture) return pBall; } -void Ball::move(ccTime delta) +void Ball::move(float delta) { this->setPosition( ccpAdd(getPosition(), ccpMult(m_velocity, delta)) ); diff --git a/tests/tests/TouchesTest/Ball.h b/tests/tests/TouchesTest/Ball.h index fa10d416a8..e3ed1def0f 100644 --- a/tests/tests/TouchesTest/Ball.h +++ b/tests/tests/TouchesTest/Ball.h @@ -17,7 +17,7 @@ public: float radius(); //BOOL initWithTexture(CCTexture2D* aTexture); //virtual void setTexture(CCTexture2D* newTexture); - void move(ccTime delta); + void move(float delta); void collideWithPaddle(Paddle* paddle); diff --git a/tests/tests/TouchesTest/TouchesTest.cpp b/tests/tests/TouchesTest/TouchesTest.cpp index d91acdcc45..ad97c1d64d 100644 --- a/tests/tests/TouchesTest/TouchesTest.cpp +++ b/tests/tests/TouchesTest/TouchesTest.cpp @@ -103,7 +103,7 @@ void PongLayer::resetAndScoreBallForPlayer(int player) // TODO -- scoring } -void PongLayer::doStep(ccTime delta) +void PongLayer::doStep(float delta) { m_ball->move(delta); diff --git a/tests/tests/TouchesTest/TouchesTest.h b/tests/tests/TouchesTest/TouchesTest.h index 571a50f625..b3ff280a75 100644 --- a/tests/tests/TouchesTest/TouchesTest.h +++ b/tests/tests/TouchesTest/TouchesTest.h @@ -29,7 +29,7 @@ public: ~PongLayer(); void resetAndScoreBallForPlayer(int player); - void doStep(ccTime delta); + void doStep(float delta); }; #endif diff --git a/tests/tests/TransitionsTest/TransitionsTest.cpp b/tests/tests/TransitionsTest/TransitionsTest.cpp index 1ecb7266f4..079eae62b9 100644 --- a/tests/tests/TransitionsTest/TransitionsTest.cpp +++ b/tests/tests/TransitionsTest/TransitionsTest.cpp @@ -7,7 +7,7 @@ class FadeWhiteTransition : public CCTransitionFade { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionFade::transitionWithDuration(t, s, ccWHITE); } @@ -16,7 +16,7 @@ public: class FlipXLeftOver : public CCTransitionFlipX { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionFlipX::transitionWithDuration(t, s, kOrientationLeftOver); } @@ -25,7 +25,7 @@ public: class FlipXRightOver : public CCTransitionFlipX { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionFlipX::transitionWithDuration(t, s, kOrientationRightOver); } @@ -34,7 +34,7 @@ public: class FlipYUpOver : public CCTransitionFlipY { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionFlipY::transitionWithDuration(t, s, kOrientationUpOver); } @@ -43,7 +43,7 @@ public: class FlipYDownOver : public CCTransitionFlipY { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionFlipY::transitionWithDuration(t, s, kOrientationDownOver); } @@ -52,7 +52,7 @@ public: class FlipAngularLeftOver : public CCTransitionFlipAngular { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionFlipAngular::transitionWithDuration(t, s, kOrientationLeftOver); } @@ -61,7 +61,7 @@ public: class FlipAngularRightOver : public CCTransitionFlipAngular { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionFlipAngular::transitionWithDuration(t, s, kOrientationRightOver); } @@ -70,7 +70,7 @@ public: class ZoomFlipXLeftOver : public CCTransitionZoomFlipX { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionZoomFlipX::transitionWithDuration(t, s, kOrientationLeftOver); } @@ -79,7 +79,7 @@ public: class ZoomFlipXRightOver : public CCTransitionZoomFlipX { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionZoomFlipX::transitionWithDuration(t, s, kOrientationRightOver); } @@ -88,7 +88,7 @@ public: class ZoomFlipYUpOver : public CCTransitionZoomFlipY { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionZoomFlipY::transitionWithDuration(t, s, kOrientationUpOver); @@ -98,7 +98,7 @@ public: class ZoomFlipYDownOver : public CCTransitionZoomFlipY { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionZoomFlipY::transitionWithDuration(t, s, kOrientationDownOver); } @@ -107,7 +107,7 @@ public: class ZoomFlipAngularLeftOver : public CCTransitionZoomFlipAngular { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionZoomFlipAngular::transitionWithDuration(t, s, kOrientationLeftOver); } @@ -116,7 +116,7 @@ public: class ZoomFlipAngularRightOver : public CCTransitionZoomFlipAngular { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { return CCTransitionZoomFlipAngular::transitionWithDuration(t, s, kOrientationRightOver); } @@ -125,7 +125,7 @@ public: class PageTransitionForward : public CCTransitionPageTurn { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { CCDirector::sharedDirector()->setDepthTest(true); return CCTransitionPageTurn::transitionWithDuration(t, s, false); @@ -135,7 +135,7 @@ public: class PageTransitionBackward : public CCTransitionPageTurn { public: - static CCTransitionScene* transitionWithDuration(ccTime t, CCScene* s) + static CCTransitionScene* transitionWithDuration(float t, CCScene* s) { CCDirector::sharedDirector()->setDepthTest(true); return CCTransitionPageTurn::transitionWithDuration(t, s, true); @@ -198,7 +198,7 @@ static std::string transitions[MAX_LAYER] = { }; static int s_nSceneIdx = 0; -CCTransitionScene* createTransition(int nIndex, ccTime t, CCScene* s) +CCTransitionScene* createTransition(int nIndex, float t, CCScene* s) { // fix bug #486, without setDepthTest(false), FlipX,Y will flickers CCDirector::sharedDirector()->setDepthTest(false); @@ -374,7 +374,7 @@ void TestLayer1::backCallback(CCObject* pSender) } } -void TestLayer1::step(ccTime dt) +void TestLayer1::step(float dt) { } @@ -503,7 +503,7 @@ void TestLayer2::backCallback(CCObject* pSender) } } -void TestLayer2::step(ccTime dt) +void TestLayer2::step(float dt) { } diff --git a/tests/tests/TransitionsTest/TransitionsTest.h b/tests/tests/TransitionsTest/TransitionsTest.h index 80c5085998..993aab241d 100644 --- a/tests/tests/TransitionsTest/TransitionsTest.h +++ b/tests/tests/TransitionsTest/TransitionsTest.h @@ -21,7 +21,7 @@ public: void nextCallback(CCObject* pSender); void backCallback(CCObject* pSender); - void step(ccTime dt); + void step(float dt); virtual void onEnter(); virtual void onEnterTransitionDidFinish(); @@ -39,7 +39,7 @@ public: void nextCallback(CCObject* pSender); void backCallback(CCObject* pSender); - void step(ccTime dt); + void step(float dt); virtual void onEnter(); virtual void onEnterTransitionDidFinish(); diff --git a/tests/tests/ZwoptexTest/ZwoptexTest.cpp b/tests/tests/ZwoptexTest/ZwoptexTest.cpp index 95182c4fef..77e23098a8 100644 --- a/tests/tests/ZwoptexTest/ZwoptexTest.cpp +++ b/tests/tests/ZwoptexTest/ZwoptexTest.cpp @@ -162,14 +162,14 @@ void ZwoptexGenericTest::onEnter() counter = 0; } -void ZwoptexGenericTest::startIn05Secs(ccTime dt) +void ZwoptexGenericTest::startIn05Secs(float dt) { unschedule(schedule_selector(ZwoptexGenericTest::startIn05Secs)); schedule(schedule_selector(ZwoptexGenericTest::flipSprites), 0.5f); } static int spriteFrameIndex = 0; -void ZwoptexGenericTest::flipSprites(ccTime dt) +void ZwoptexGenericTest::flipSprites(float dt) { counter++; diff --git a/tests/tests/ZwoptexTest/ZwoptexTest.h b/tests/tests/ZwoptexTest/ZwoptexTest.h index 24bae86da2..85fc9074c8 100644 --- a/tests/tests/ZwoptexTest/ZwoptexTest.h +++ b/tests/tests/ZwoptexTest/ZwoptexTest.h @@ -21,8 +21,8 @@ class ZwoptexGenericTest : public ZwoptexTest public: ~ZwoptexGenericTest(); virtual void onEnter(); - void flipSprites(ccTime dt); - void startIn05Secs(ccTime dt); + void flipSprites(float dt); + void startIn05Secs(float dt); virtual std::string title(); virtual std::string subtitle(); diff --git a/tools/lua_project_generator/template/Classes/AppDelegate.cpp b/tools/lua_project_generator/template/Classes/AppDelegate.cpp index 3ee661ec67..e341801473 100644 --- a/tools/lua_project_generator/template/Classes/AppDelegate.cpp +++ b/tools/lua_project_generator/template/Classes/AppDelegate.cpp @@ -7,7 +7,6 @@ USING_NS_CC; using namespace CocosDenshion; AppDelegate::AppDelegate() -:m_pLuaEngine(NULL) { } @@ -15,99 +14,39 @@ AppDelegate::~AppDelegate() { // end simple audio engine here, or it may crashed on win32 SimpleAudioEngine::sharedEngine()->end(); - CCScriptEngineManager::sharedScriptEngineManager()->removeScriptEngine(); + //CCScriptEngineManager::purgeSharedManager(); CC_SAFE_DELETE(m_pLuaEngine); } -bool AppDelegate::initInstance() -{ - bool bRet = false; - do - { -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) - - // Initialize OpenGLView instance, that release by CCDirector when application terminate. - // The HelloWorld is designed as HVGA. - CCEGLView * pMainWnd = new CCEGLView(); - CC_BREAK_IF(! pMainWnd - || ! pMainWnd->Create(TEXT("cocos2d: LuaProjectTemplate"), 480, 320)); - -#endif // CC_PLATFORM_WIN32 - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - - // OpenGLView initialized in testsAppDelegate.mm on ios platform, nothing need to do here. - -#endif // CC_PLATFORM_IOS - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - - // OpenGLView initialized in HelloWorld/android/jni/helloworld/main.cpp - // the default setting is to create a fullscreen view - // if you want to use auto-scale, please enable view->create(320,480) in main.cpp - -#endif // CC_PLATFORM_ANDROID - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE) - // MaxAksenov said it's NOT a very elegant solution. I agree, haha - CCDirector::sharedDirector()->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); -#endif - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_BADA) - CCEGLView * pMainWnd = new CCEGLView(); - CC_BREAK_IF(! pMainWnd|| ! pMainWnd->Create(this)); - CCFileUtils::setResourcePath("/Res/"); -#endif - bRet = true; - } while (0); - return bRet; -} - bool AppDelegate::applicationDidFinishLaunching() { // initialize director CCDirector *pDirector = CCDirector::sharedDirector(); pDirector->setOpenGLView(&CCEGLView::sharedOpenGLView()); -#if (CC_TARGET_PLATFORM == CC_PLATFORM_BADA) - CCDirector::sharedDirector()->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); -#endif // enable High Resource Mode(2x, such as iphone4) and maintains low resource on other devices. // pDirector->enableRetinaDisplay(true); // turn on display FPS - pDirector->setDisplayFPS(true); - - // pDirector->setDeviceOrientation(kCCDeviceOrientationLandscapeLeft); + pDirector->setDisplayStats(true); // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); // register lua engine - m_pLuaEngine = new LuaEngine; - CCScriptEngineManager::sharedScriptEngineManager()->setScriptEngine(m_pLuaEngine); + CCScriptEngineProtocol* pEngine = CCLuaEngine::engine(); + CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - unsigned long size; - char *pFileContent = (char*)CCFileUtils::getFileData("main.lua", "r", &size); - - if (pFileContent) + CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua"); + if (pstrFileContent) { - // copy the file contents and add '\0' at the end, or the lua parser can not parse it - char *pCodes = new char[size + 1]; - pCodes[size] = '\0'; - memcpy(pCodes, pFileContent, size); - delete[] pFileContent; - - CCScriptEngineManager::sharedScriptEngineManager()->getScriptEngine()->executeString(pCodes); - delete []pCodes; + pEngine->executeString(pstrFileContent->getCString()); } -#endif - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - string path = CCFileUtils::fullPathFromRelativePath("main.lua"); - CCScriptEngineManager::sharedScriptEngineManager()->getScriptEngine()->addSearchPath(path.substr(0, path.find_last_of("/")).c_str()); - CCScriptEngineManager::sharedScriptEngineManager()->getScriptEngine()->executeScriptFile(path.c_str()); +#else + std::string path = CCFileUtils::fullPathFromRelativePath("hello.lua"); + pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str()); + pEngine->executeScriptFile(path.c_str()); #endif return true; diff --git a/tools/lua_project_generator/template/Classes/AppDelegate.h b/tools/lua_project_generator/template/Classes/AppDelegate.h index 05241d3e10..1b7c3f81f2 100644 --- a/tools/lua_project_generator/template/Classes/AppDelegate.h +++ b/tools/lua_project_generator/template/Classes/AppDelegate.h @@ -15,11 +15,6 @@ public: AppDelegate(); virtual ~AppDelegate(); - /** - @brief Implement for initialize OpenGL instance, set source path, etc... - */ - virtual bool initInstance(); - /** @brief Implement CCDirector and CCScene init code here. @return true Initialize success, app continue. @@ -38,9 +33,6 @@ public: @param the pointer of the application */ virtual void applicationWillEnterForeground(); - -private: - LuaEngine* m_pLuaEngine; }; #endif // _APP_DELEGATE_H_ From 342c65e293cd9a9cbfdc8a5a43430ebe8fb39a05 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Mon, 11 Jun 2012 14:57:30 -0700 Subject: [PATCH 120/257] Added CCBIReaderTest, which doesn't work since XCode sucks big time, not finding a simple file. --- .../cbb/pub/fonts/Droid.ttf.REMOVED.git-id | 1 + .../cbb/src/fonts/Droid.ttf.REMOVED.git-id | 1 + .../project.pbxproj.REMOVED.git-id | 2 +- .../CCBIReaderTest/CCBIReaderLayer.cpp | 83 ++++++++++++++++ .../CCBIReaderTest/CCBIReaderLayer.h | 25 +++++ .../CCBIReaderTest/CCBIReaderTest.cpp | 53 ++++++++++ .../CCBIReaderTest/CCBIReaderTest.h | 35 +++++++ .../CCBIReaderTest/HelloCocosBuilder.cpp | 96 +++++++++++++++++++ .../CCBIReaderTest/HelloCocosBuilder.h | 63 ++++++++++++ .../CCControlButtonTest.cpp | 16 ++-- .../CCControlColourPickerTest.cpp | 2 +- .../CCControlSliderTest.cpp | 2 +- .../CCControlSwitchTest.cpp | 2 +- tests/tests/ExtensionsTest/ExtensionsTest.cpp | 13 +++ tests/tests/SchedulerTest/SchedulerTest.cpp | 4 +- tests/tests/ShaderTest/ShaderTest.cpp | 2 +- 16 files changed, 385 insertions(+), 15 deletions(-) create mode 100644 tests/Resources/cbb/pub/fonts/Droid.ttf.REMOVED.git-id create mode 100644 tests/Resources/cbb/src/fonts/Droid.ttf.REMOVED.git-id create mode 100644 tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.cpp create mode 100644 tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.h create mode 100644 tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderTest.cpp create mode 100644 tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderTest.h create mode 100644 tests/tests/ExtensionsTest/CCBIReaderTest/HelloCocosBuilder.cpp create mode 100644 tests/tests/ExtensionsTest/CCBIReaderTest/HelloCocosBuilder.h diff --git a/tests/Resources/cbb/pub/fonts/Droid.ttf.REMOVED.git-id b/tests/Resources/cbb/pub/fonts/Droid.ttf.REMOVED.git-id new file mode 100644 index 0000000000..8da6cbb3a0 --- /dev/null +++ b/tests/Resources/cbb/pub/fonts/Droid.ttf.REMOVED.git-id @@ -0,0 +1 @@ +197f4c7204f12af28120d3506524f0ac051b624d \ No newline at end of file diff --git a/tests/Resources/cbb/src/fonts/Droid.ttf.REMOVED.git-id b/tests/Resources/cbb/src/fonts/Droid.ttf.REMOVED.git-id new file mode 100644 index 0000000000..8da6cbb3a0 --- /dev/null +++ b/tests/Resources/cbb/src/fonts/Droid.ttf.REMOVED.git-id @@ -0,0 +1 @@ +197f4c7204f12af28120d3506524f0ac051b624d \ No newline at end of file diff --git a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id index 8f63248979..59b21d5854 100644 --- a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -c16d1dddb12b5a7e7e715f234dfd031657369f96 \ No newline at end of file +f42fb181945ec91cdc8569191c5810959798ba15 \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.cpp b/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.cpp new file mode 100644 index 0000000000..41d9297d12 --- /dev/null +++ b/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.cpp @@ -0,0 +1,83 @@ +#include "CCBIReaderLayer.h" +#include "CCBReader.h" +#include "CCNodeLoaderLibrary.h" + +using namespace cocos2d; +using namespace cocos2d::extension; + +void CCBIReaderLayer::menuCloseCallback(CCObject* pSender) { + CCDirector::sharedDirector()->end(); + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + exit(0); +#endif +} + +bool CCBIReaderLayer::onAssignCCBMemberVariable(CCObject * pTarget, const char * pMemberVariableName, CCNode * pNode) { + if(pTarget == this) { + if(strcmp(pMemberVariableName, "mCCControlButton") == 0) { + this->mCCControlButton = dynamic_cast(pNode); + return true; + } else if(strcmp(pMemberVariableName, "mCCMenuItemImage") == 0) { + this->mCCMenuItemImage = dynamic_cast(pNode); + return true; + } + } + return false; +} + +SEL_CCControlHandler CCBIReaderLayer::onResolveCCBCCControlSelector(CCObject * pTarget, const char * pSelectorName) { + if(pTarget == this) { + if(strcmp(pSelectorName, "onCCControlButtonClicked") == 0) { + return cccontrol_selector(CCBIReaderLayer::onCCControlButtonClicked); + } + } + return NULL; +} + +SEL_MenuHandler CCBIReaderLayer::onResolveCCBCCMenuSelector(CCObject * pTarget, const char * pSelectorName) { + if(pTarget == this) { + if(strcmp(pSelectorName, "onCCMenuItemImageClicked") == 0) { + return menu_selector(CCBIReaderLayer::onCCMenuItemImageClicked); + } + } + return NULL; +} + +void CCBIReaderLayer::onCCControlButtonClicked(CCObject * pSender, CCControlEvent pCCControlEvent) { + switch(pCCControlEvent) { + case CCControlEventTouchDown: + CCLOG("onCCControlButtonClicked: Touch Down."); + break; + case CCControlEventTouchDragInside: + CCLOG("onCCControlButtonClicked: Touch Drag Inside."); + break; + case CCControlEventTouchDragOutside: + CCLOG("onCCControlButtonClicked: Touch Drag Outside."); + break; + case CCControlEventTouchDragEnter: + CCLOG("onCCControlButtonClicked: Touch Drag Enter."); + break; + case CCControlEventTouchDragExit: + CCLOG("onCCControlButtonClicked: Touch Drag Exit."); + break; + case CCControlEventTouchUpInside: + CCLOG("onCCControlButtonClicked: Touch Up Inside."); + break; + case CCControlEventTouchUpOutside: + CCLOG("onCCControlButtonClicked: Touch Up Outside."); + break; + case CCControlEventTouchCancel: + CCLOG("onCCControlButtonClicked: Touch Cancel."); + break; + case CCControlEventValueChanged: + CCLOG("onCCControlButtonClicked: Value Changed."); + break; + default: + assert(false); // OH SHIT! + } +} + +void CCBIReaderLayer::onCCMenuItemImageClicked(CCObject * pSender) { + CCLOG("onCCMenuItemImageClicked!"); +} \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.h b/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.h new file mode 100644 index 0000000000..385f952b1f --- /dev/null +++ b/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.h @@ -0,0 +1,25 @@ +#ifndef _CCBIREADER_LAYER_H_ +#define _CCBIREADER_LAYER_H_ + +#include "cocos2d.h" +#include "CCBMemberVariableAssigner.h" +#include "CCBSelectorResolver.h" + +class CCBIReaderLayer : public cocos2d::CCLayer, public cocos2d::extension::CCBMemberVariableAssigner, public cocos2d::extension::CCBSelectorResolver { + public: + virtual bool init(); + + virtual void menuCloseCallback(CCObject * pSender); + + virtual bool onAssignCCBMemberVariable(CCObject * pTarget, const char * pMemberVariableName, CCNode * pNode); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(CCObject * pTarget, const char * pSelectorName); + virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(CCObject * pTarget, const char * pSelectorName); + + virtual void onCCControlButtonClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); + virtual void onCCMenuItemImageClicked(CCObject * pSender); + private: + cocos2d::extension::CCControlButton * mCCControlButton; + cocos2d::CCMenuItemImage * mCCMenuItemImage; +}; + +#endif diff --git a/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderTest.cpp b/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderTest.cpp new file mode 100644 index 0000000000..b3d45d9699 --- /dev/null +++ b/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderTest.cpp @@ -0,0 +1,53 @@ +/**************************************************************************** + Copyright (c) 2012 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "CCBIReaderTest.h" +#include "../../testResource.h" +#include "extensions/CCBIReader/CCBReader.h" +#include "HelloCocosBuilder.h" +#include "extensions/CCBIReader/CCNodeLoaderLibrary.h" +#include "CCBIReaderLayer.h" + +using namespace cocos2d; +using namespace cocos2d::extension; + +void CCBIReaderTestScene::runThisTest() { + CCBIReaderLayer * ccbiReaderLayer = (CCBIReaderLayer *)CCBIReaderLayer::node(); + + /* Create an autorelease CCNodeLoaderLibrary. */ + CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary(); + + /* Create an autorelease CCBReader. */ + CCBReader * ccbReader = new CCBReader(ccNodeLoaderLibrary, ccbiReaderLayer, ccbiReaderLayer); + ccbReader->autorelease(); + + /* Read a ccbi file. */ + CCNode * node = ccbReader->readNodeGraphFromFile("ccb/pub/ccb/test.ccbi", ccbiReaderLayer); + + if(node != NULL) { + this->addChild(node); + } + + CCDirector::sharedDirector()->replaceScene(this); +} diff --git a/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderTest.h b/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderTest.h new file mode 100644 index 0000000000..6b7291d374 --- /dev/null +++ b/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderTest.h @@ -0,0 +1,35 @@ +/**************************************************************************** + Copyright (c) 2012 cocos2d-x.org + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#ifndef _CCBREADER_TEST_H_ +#define _CCBREADER_TEST_H_ + +#include "../../testBasic.h" + +class CCBIReaderTestScene : public TestScene { + public: + virtual void runThisTest(); +}; + +#endif \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CCBIReaderTest/HelloCocosBuilder.cpp b/tests/tests/ExtensionsTest/CCBIReaderTest/HelloCocosBuilder.cpp new file mode 100644 index 0000000000..21329d770d --- /dev/null +++ b/tests/tests/ExtensionsTest/CCBIReaderTest/HelloCocosBuilder.cpp @@ -0,0 +1,96 @@ +/**************************************************************************** + Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2012 XiaoLong Zhang, Chukong Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#include "HelloCocosBuilder.h" + +USING_NS_CC; + +HelloCocosBuilder::HelloCocosBuilder() +:m_pSpriteBurst(NULL) +,m_pSpriteIcon(NULL) +{ +} + +HelloCocosBuilder::~HelloCocosBuilder() +{ + CC_SAFE_RELEASE_NULL(m_pSpriteBurst); + CC_SAFE_RELEASE_NULL(m_pSpriteIcon); +} + +bool HelloCocosBuilder::callbackSetChildren(const char* name, CCObject* node) +{ + bool bRetVal = false; + + if (strcmp(name, "sprtBurst") == 0) + { + m_pSpriteBurst = dynamic_cast(node); + CC_ASSERT(m_pSpriteBurst); + m_pSpriteBurst->retain(); + } + else if (strcmp(name, "sprtIcon") == 0) + { + m_pSpriteIcon = dynamic_cast(node); + CC_ASSERT(m_pSpriteIcon); + m_pSpriteIcon->retain(); + } + + return bRetVal; +}; + +void HelloCocosBuilder::callbackAfterCCBLoaded() +{ + CCLOG("loading.....successed!") ; + void* act = CCRotateBy::actionWithDuration(0.5f, 10) ; + void* act1 = CCRepeatForever::actionWithAction((CCActionInterval*)act) ; + m_pSpriteBurst->runAction((CCAction*)act1) ; +} + +SEL_MenuHandler HelloCocosBuilder::callbackGetSelectors(const char* selectorName) +{ + if (strcmp(selectorName, "pressedButton") == 0) + { + return menu_selector(HelloCocosBuilder::pressedButton); + } + else if (strcmp(selectorName, "pressedButton2") == 0) + { + return menu_selector(HelloCocosBuilder::pressedButton2); + } + else + { + return NULL; + } +} + +void HelloCocosBuilder::pressedButton(CCObject*sender) +{ + m_pSpriteIcon->stopAllActions() ; + void* rotateAction = CCRotateBy::actionWithDuration(1, 360) ; + m_pSpriteIcon->runAction((CCAction*)rotateAction) ; +} + +void HelloCocosBuilder::pressedButton2(CCObject*sender) +{ + CCLOG("pressed successed!") ; +} \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CCBIReaderTest/HelloCocosBuilder.h b/tests/tests/ExtensionsTest/CCBIReaderTest/HelloCocosBuilder.h new file mode 100644 index 0000000000..82c80426a5 --- /dev/null +++ b/tests/tests/ExtensionsTest/CCBIReaderTest/HelloCocosBuilder.h @@ -0,0 +1,63 @@ +/**************************************************************************** + Copyright (c) 2012 cocos2d-x.org + Copyright (c) 2012 XiaoLong Zhang, Chukong Inc. + + http://www.cocos2d-x.org + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. + ****************************************************************************/ + +#ifndef cocos2dXReflection_HelloCocosBuilder_h +#define cocos2dXReflection_HelloCocosBuilder_h + +#include "cocos2d.h" +#include "extensions/CCBReader/CCBCustomClass.h" + +namespace cocos2d{ + + class HelloCocosBuilder : public extension::CCBCustomClassProtocol, public CCLayer + { + public: + HelloCocosBuilder(); + ~HelloCocosBuilder(); + + static extension::CCBCustomClassProtocol* createInstance() + { + return new HelloCocosBuilder() ; + } + + public: + // implement 3 pure virtual methods inherited from CCBCustomClass + virtual bool callbackSetChildren(const char* name, CCObject* node); + virtual SEL_MenuHandler callbackGetSelectors(const char* selectorName); + virtual void callbackAfterCCBLoaded(); + + + void pressedButton(CCObject*sender) ; + void pressedButton2(CCObject*sender) ; + + protected: + CCSprite* m_pSpriteBurst ; + CCSprite* m_pSpriteIcon ; + + } ; +} + + +#endif diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp index eb25a05279..7582e7d0c8 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp @@ -136,14 +136,14 @@ bool CCControlButtonTest_Event::init() addChild(background); // Sets up event handlers - controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchDownAction), CCControlEventTouchDown); - controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchDragInsideAction), CCControlEventTouchDragInside); - controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchDragOutsideAction), CCControlEventTouchDragOutside); - controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchDragEnterAction), CCControlEventTouchDragEnter); - controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchDragExitAction), CCControlEventTouchDragExit); - controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchUpInsideAction), CCControlEventTouchUpInside); - controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchUpOutsideAction), CCControlEventTouchUpOutside); - controlButton->addTargetWithActionForControlEvent(this, menu_selector(CCControlButtonTest_Event::touchCancelAction), CCControlEventTouchCancel); + controlButton->addTargetWithActionForControlEvent(this, cccontrol_selector(CCControlButtonTest_Event::touchDownAction), CCControlEventTouchDown); + controlButton->addTargetWithActionForControlEvent(this, cccontrol_selector(CCControlButtonTest_Event::touchDragInsideAction), CCControlEventTouchDragInside); + controlButton->addTargetWithActionForControlEvent(this, cccontrol_selector(CCControlButtonTest_Event::touchDragOutsideAction), CCControlEventTouchDragOutside); + controlButton->addTargetWithActionForControlEvent(this, cccontrol_selector(CCControlButtonTest_Event::touchDragEnterAction), CCControlEventTouchDragEnter); + controlButton->addTargetWithActionForControlEvent(this, cccontrol_selector(CCControlButtonTest_Event::touchDragExitAction), CCControlEventTouchDragExit); + controlButton->addTargetWithActionForControlEvent(this, cccontrol_selector(CCControlButtonTest_Event::touchUpInsideAction), CCControlEventTouchUpInside); + controlButton->addTargetWithActionForControlEvent(this, cccontrol_selector(CCControlButtonTest_Event::touchUpOutsideAction), CCControlEventTouchUpOutside); + controlButton->addTargetWithActionForControlEvent(this, cccontrol_selector(CCControlButtonTest_Event::touchCancelAction), CCControlEventTouchCancel); return true; } return false; diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp index 0253fe9de0..eafe7812c7 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp @@ -51,7 +51,7 @@ bool CCControlColourPickerTest::init() layer->addChild(colourPicker); // Add the target-action pair - colourPicker->addTargetWithActionForControlEvents(this, menu_selector(CCControlColourPickerTest::colourValueChanged), CCControlEventValueChanged); + colourPicker->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlColourPickerTest::colourValueChanged), CCControlEventValueChanged); layer_width += colourPicker->getContentSize().width; diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp index cd2df363e3..d3264a1878 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp @@ -57,7 +57,7 @@ bool CCControlSliderTest::init() slider->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f)); // When the value of the slider will change, the given selector will be call - slider->addTargetWithActionForControlEvents(this, menu_selector(CCControlSliderTest::valueChanged), CCControlEventValueChanged); + slider->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlSliderTest::valueChanged), CCControlEventValueChanged); addChild(slider); return true; diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp index 2a05144934..00796888b8 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp @@ -71,7 +71,7 @@ bool CCControlSwitchTest::init() switchControl->setPosition(ccp (layer_width + 10 + switchControl->getContentSize().width / 2, 0)); layer->addChild(switchControl); - switchControl->addTargetWithActionForControlEvents(this, menu_selector(CCControlSwitchTest::valueChanged), CCControlEventValueChanged); + switchControl->addTargetWithActionForControlEvents(this, cccontrol_selector(CCControlSwitchTest::valueChanged), CCControlEventValueChanged); // Set the layer size layer->setContentSize(CCSizeMake(layer_width, 0)); diff --git a/tests/tests/ExtensionsTest/ExtensionsTest.cpp b/tests/tests/ExtensionsTest/ExtensionsTest.cpp index b02823dfca..cd9358d69b 100644 --- a/tests/tests/ExtensionsTest/ExtensionsTest.cpp +++ b/tests/tests/ExtensionsTest/ExtensionsTest.cpp @@ -3,6 +3,7 @@ #include "NotificationCenterTest/NotificationCenterTest.h" #include "ControlExtensionTest/CCControlSceneManager.h" #include "CocosBuilderTest/CocosBuilderTest.h" +#include "CCBIReaderTest/CCBIReaderTest.h" enum { @@ -16,6 +17,7 @@ enum TEST_CCCONTROLBUTTON, TEST_TEXTUREWATCHER, TEST_COCOSBUILDER, + TEST_CCBIREADER, TEST_MAX_COUNT, }; @@ -25,6 +27,7 @@ static const std::string testsName[TEST_MAX_COUNT] = "CCControlButtonTest", "TextureWatcherTest", "CocosBuilderTest", + "CCBIReaderTest", }; //////////////////////////////////////////////////////// @@ -89,6 +92,16 @@ void ExtensionsMainLayer::menuCallback(CCObject* pSender) } } break; + case TEST_CCBIREADER: + { + TestScene* pScene = new CCBIReaderTestScene(); + if (pScene) + { + pScene->runThisTest(); + pScene->release(); + } + } + break; default: break; } diff --git a/tests/tests/SchedulerTest/SchedulerTest.cpp b/tests/tests/SchedulerTest/SchedulerTest.cpp index 0a8163dba8..52178b57a1 100644 --- a/tests/tests/SchedulerTest/SchedulerTest.cpp +++ b/tests/tests/SchedulerTest/SchedulerTest.cpp @@ -627,7 +627,7 @@ CCControlSlider* SchedulerTimeScale::sliderCtl() { CCControlSlider * slider = CCControlSlider::sliderWithFiles("extensions/sliderTrack2.png","extensions/sliderProgress2.png" ,"extensions/sliderThumb.png"); - slider->addTargetWithActionForControlEvents(this, menu_selector(SchedulerTimeScale::sliderAction), CCControlEventValueChanged); + slider->addTargetWithActionForControlEvents(this, cccontrol_selector(SchedulerTimeScale::sliderAction), CCControlEventValueChanged); slider->setMinimumValue(-3.0f); slider->setMaximumValue(3.0f); @@ -715,7 +715,7 @@ CCControlSlider *TwoSchedulers::sliderCtl() // CGRect frame = CGRectMake(12.0f, 12.0f, 120.0f, 7.0f); CCControlSlider *slider = CCControlSlider::sliderWithFiles("extensions/sliderTrack2.png","extensions/sliderProgress2.png" ,"extensions/sliderThumb.png"); //[[UISlider alloc] initWithFrame:frame]; - slider->addTargetWithActionForControlEvents(this, menu_selector(TwoSchedulers::sliderAction), CCControlEventValueChanged); + slider->addTargetWithActionForControlEvents(this, cccontrol_selector(TwoSchedulers::sliderAction), CCControlEventValueChanged); // in case the parent view draws with a custom color or gradient, use a transparent color //slider.backgroundColor = [UIColor clearColor]; diff --git a/tests/tests/ShaderTest/ShaderTest.cpp b/tests/tests/ShaderTest/ShaderTest.cpp index 3232d8b54d..720b3ebebe 100644 --- a/tests/tests/ShaderTest/ShaderTest.cpp +++ b/tests/tests/ShaderTest/ShaderTest.cpp @@ -581,7 +581,7 @@ CCControlSlider* ShaderBlur::createSliderCtl() slider->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 3.0f)); // When the value of the slider will change, the given selector will be call - slider->addTargetWithActionForControlEvents(this, menu_selector(ShaderBlur::sliderAction), CCControlEventValueChanged); + slider->addTargetWithActionForControlEvents(this, cccontrol_selector(ShaderBlur::sliderAction), CCControlEventValueChanged); return slider; From 4c8351f304c1c7faabb454db5fe03c081e93ee11 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Mon, 11 Jun 2012 15:00:11 -0700 Subject: [PATCH 121/257] Removed Zombie files. --- .../CCBIReaderTest/HelloCocosBuilder.cpp | 96 ------------------- .../CCBIReaderTest/HelloCocosBuilder.h | 63 ------------ 2 files changed, 159 deletions(-) delete mode 100644 tests/tests/ExtensionsTest/CCBIReaderTest/HelloCocosBuilder.cpp delete mode 100644 tests/tests/ExtensionsTest/CCBIReaderTest/HelloCocosBuilder.h diff --git a/tests/tests/ExtensionsTest/CCBIReaderTest/HelloCocosBuilder.cpp b/tests/tests/ExtensionsTest/CCBIReaderTest/HelloCocosBuilder.cpp deleted file mode 100644 index 21329d770d..0000000000 --- a/tests/tests/ExtensionsTest/CCBIReaderTest/HelloCocosBuilder.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** - Copyright (c) 2012 cocos2d-x.org - Copyright (c) 2012 XiaoLong Zhang, Chukong Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "HelloCocosBuilder.h" - -USING_NS_CC; - -HelloCocosBuilder::HelloCocosBuilder() -:m_pSpriteBurst(NULL) -,m_pSpriteIcon(NULL) -{ -} - -HelloCocosBuilder::~HelloCocosBuilder() -{ - CC_SAFE_RELEASE_NULL(m_pSpriteBurst); - CC_SAFE_RELEASE_NULL(m_pSpriteIcon); -} - -bool HelloCocosBuilder::callbackSetChildren(const char* name, CCObject* node) -{ - bool bRetVal = false; - - if (strcmp(name, "sprtBurst") == 0) - { - m_pSpriteBurst = dynamic_cast(node); - CC_ASSERT(m_pSpriteBurst); - m_pSpriteBurst->retain(); - } - else if (strcmp(name, "sprtIcon") == 0) - { - m_pSpriteIcon = dynamic_cast(node); - CC_ASSERT(m_pSpriteIcon); - m_pSpriteIcon->retain(); - } - - return bRetVal; -}; - -void HelloCocosBuilder::callbackAfterCCBLoaded() -{ - CCLOG("loading.....successed!") ; - void* act = CCRotateBy::actionWithDuration(0.5f, 10) ; - void* act1 = CCRepeatForever::actionWithAction((CCActionInterval*)act) ; - m_pSpriteBurst->runAction((CCAction*)act1) ; -} - -SEL_MenuHandler HelloCocosBuilder::callbackGetSelectors(const char* selectorName) -{ - if (strcmp(selectorName, "pressedButton") == 0) - { - return menu_selector(HelloCocosBuilder::pressedButton); - } - else if (strcmp(selectorName, "pressedButton2") == 0) - { - return menu_selector(HelloCocosBuilder::pressedButton2); - } - else - { - return NULL; - } -} - -void HelloCocosBuilder::pressedButton(CCObject*sender) -{ - m_pSpriteIcon->stopAllActions() ; - void* rotateAction = CCRotateBy::actionWithDuration(1, 360) ; - m_pSpriteIcon->runAction((CCAction*)rotateAction) ; -} - -void HelloCocosBuilder::pressedButton2(CCObject*sender) -{ - CCLOG("pressed successed!") ; -} \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CCBIReaderTest/HelloCocosBuilder.h b/tests/tests/ExtensionsTest/CCBIReaderTest/HelloCocosBuilder.h deleted file mode 100644 index 82c80426a5..0000000000 --- a/tests/tests/ExtensionsTest/CCBIReaderTest/HelloCocosBuilder.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** - Copyright (c) 2012 cocos2d-x.org - Copyright (c) 2012 XiaoLong Zhang, Chukong Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef cocos2dXReflection_HelloCocosBuilder_h -#define cocos2dXReflection_HelloCocosBuilder_h - -#include "cocos2d.h" -#include "extensions/CCBReader/CCBCustomClass.h" - -namespace cocos2d{ - - class HelloCocosBuilder : public extension::CCBCustomClassProtocol, public CCLayer - { - public: - HelloCocosBuilder(); - ~HelloCocosBuilder(); - - static extension::CCBCustomClassProtocol* createInstance() - { - return new HelloCocosBuilder() ; - } - - public: - // implement 3 pure virtual methods inherited from CCBCustomClass - virtual bool callbackSetChildren(const char* name, CCObject* node); - virtual SEL_MenuHandler callbackGetSelectors(const char* selectorName); - virtual void callbackAfterCCBLoaded(); - - - void pressedButton(CCObject*sender) ; - void pressedButton2(CCObject*sender) ; - - protected: - CCSprite* m_pSpriteBurst ; - CCSprite* m_pSpriteIcon ; - - } ; -} - - -#endif From 1f2652a8d7cb4ff784c27024daddd2f12651dc76 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Mon, 11 Jun 2012 18:31:11 -0700 Subject: [PATCH 122/257] Made CCBIReaderTest finally work completely. =) Also added support for having a root path when loading a ccb-file (i.e. when you have the two directories, one for the ccb files, one for the spritesheets. <- With a common ancestor.) --- cocos2dx/extensions/CCBIReader/CCBReader.cpp | 50 +++++++++++----- cocos2dx/extensions/CCBIReader/CCBReader.h | 15 +++-- .../CCBIReader/CCLabelBMFontLoader.cpp | 2 +- .../extensions/CCBIReader/CCNodeLoader.cpp | 59 ++++++++++--------- .../pub/fonts/Droid.ttf.REMOVED.git-id | 0 .../src/fonts/Droid.ttf.REMOVED.git-id | 0 .../project.pbxproj.REMOVED.git-id | 2 +- .../CCBIReaderTest/CCBIReaderLayer.cpp | 15 +++++ .../CCBIReaderTest/CCBIReaderLayer.h | 2 + .../CCBIReaderTest/CCBIReaderTest.cpp | 9 +-- 10 files changed, 97 insertions(+), 57 deletions(-) rename tests/Resources/{cbb => ccb}/pub/fonts/Droid.ttf.REMOVED.git-id (100%) rename tests/Resources/{cbb => ccb}/src/fonts/Droid.ttf.REMOVED.git-id (100%) diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.cpp b/cocos2dx/extensions/CCBIReader/CCBReader.cpp index 5da717dd19..0f880e6017 100644 --- a/cocos2dx/extensions/CCBIReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCBReader.cpp @@ -59,6 +59,10 @@ CCBReader::CCBReader(CCBReader * pCCBReader) { this->mCCBSelectorResolver = pCCBReader->mCCBSelectorResolver; } +std::string CCBReader::getCCBRootPath() { + return this->mCCBRootPath; +} + CCBMemberVariableAssigner * CCBReader::getCCBMemberVariableAssigner() { return this->mCCBMemberVariableAssigner; } @@ -71,12 +75,18 @@ float CCBReader::getResolutionScale() { return this->mResolutionScale; } -CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBFileName, CCObject * pOwner) { - return this->readNodeGraphFromFile(pCCBFileName, pOwner, CCDirector::sharedDirector()->getWinSize()); +CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner) { + return this->readNodeGraphFromFile(pCCBRootPath, pCCBFileName, pOwner, CCDirector::sharedDirector()->getWinSize()); } -CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize) { - const char * path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pCCBFileName); +CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize) { + this->mCCBRootPath = pCCBRootPath; + + char ccbFullFilePath[strlen(pCCBRootPath) + strlen(pCCBFileName) + 1]; + strcpy(ccbFullFilePath, pCCBRootPath); + strcat(ccbFullFilePath, pCCBFileName); + + const char * path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(ccbFullFilePath); unsigned long size = 0; this->mBytes = CCFileUtils::sharedFileUtils()->getFileData(path, "r", &size); @@ -240,19 +250,19 @@ void CCBReader::alignBits() { } } -const char * CCBReader::readCachedString() { +std::string CCBReader::readCachedString() { int i = this->readInt(false); - return this->mStringCache[i].c_str(); + return this->mStringCache[i]; } CCNode * CCBReader::readNodeGraph(CCNode * pParent) { /* Read class name. */ - const char * className = this->readCachedString(); + const char * className = this->readCachedString().c_str(); int memberVarAssignmentType = this->readInt(false); const char * memberVarAssignmentName; if(memberVarAssignmentType != kCCBTargetTypeNone) { - memberVarAssignmentName = this->readCachedString(); + memberVarAssignmentName = this->readCachedString().c_str(); } CCNodeLoader * ccNodeLoader = this->mCCNodeLoaderLibrary->getCCNodeLoader(className); @@ -324,28 +334,36 @@ void CCBReader::addLoadedSpriteSheet(const char * pSpriteSheet) { this->mLoadedSpriteSheets.insert(pSpriteSheet); } -const char * CCBReader::lastPathComponent(const char * pPath) { +std::string CCBReader::lastPathComponent(const char * pPath) { std::string path(pPath); int slashPos = path.find_last_of("/"); if(slashPos != std::string::npos) { - return path.substr(slashPos + 1, path.length() - slashPos).c_str(); + return path.substr(slashPos + 1, path.length() - slashPos); } - return pPath; + return path; } -const char * CCBReader::deletePathExtension(const char * pPath) { +std::string CCBReader::deletePathExtension(const char * pPath) { std::string path(pPath); int dotPos = path.find_last_of("."); if(dotPos != std::string::npos) { - return path.substr(0, dotPos).c_str(); + return path.substr(0, dotPos); } - return pPath; + return path; } -const char * CCBReader::toLowerCase(const char * pString) { +std::string CCBReader::toLowerCase(const char * pString) { std::string copy(pString); std::transform(copy.begin(), copy.end(), copy.begin(), ::tolower); - return copy.c_str(); + return copy; +} + +std::string CCBReader::concat(const char * pStringA, const char * pStringB) { + std::string stringA(pStringA); + std::string stringB(pStringB); + + std::string string = stringA + stringB; + return string; } bool CCBReader::endsWith(const char * pString, const char * pEnding) { diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.h b/cocos2dx/extensions/CCBIReader/CCBReader.h index 5e370c804c..2adb5a00f2 100644 --- a/cocos2dx/extensions/CCBIReader/CCBReader.h +++ b/cocos2dx/extensions/CCBIReader/CCBReader.h @@ -83,6 +83,7 @@ class CCNodeLoaderLibrary; */ class CC_DLL CCBReader : public CCObject { private: + std::string mCCBRootPath; bool mRootCCBReader; unsigned char * mBytes; @@ -107,11 +108,12 @@ class CC_DLL CCBReader : public CCObject { /* Destructor. */ ~CCBReader(); - CCNode * readNodeGraphFromFile(const char * pCCBFileName, CCObject * pOwner = NULL); - CCNode * readNodeGraphFromFile(const char * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize); + CCNode * readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner = NULL); + CCNode * readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize); CCBMemberVariableAssigner * getCCBMemberVariableAssigner(); CCBSelectorResolver * getCCBSelectorResolver(); + std::string getCCBRootPath(); CCObject * getOwner(); CCNode * getRootNode(); CCSize getContainerSize(CCNode *); @@ -121,17 +123,18 @@ class CC_DLL CCBReader : public CCObject { void addLoadedSpriteSheet(const char *); /* Utility methods. */ - const char * lastPathComponent(const char *); - const char * deletePathExtension(const char *); - const char * toLowerCase(const char *); + std::string lastPathComponent(const char *); + std::string deletePathExtension(const char *); + std::string toLowerCase(const char *); bool endsWith(const char *, const char *); + std::string concat(const char *, const char *); /* Parse methods. */ int readInt(bool pSign); unsigned char readByte(); bool readBool(); float readFloat(); - const char * readCachedString(); + std::string readCachedString(); private: bool readHeader(); diff --git a/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.cpp b/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.cpp index d75121e296..3b19d8acab 100644 --- a/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.cpp @@ -39,7 +39,7 @@ void CCLabelBMFontLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pPa void CCLabelBMFontLoader::onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pFntFile, CCBReader * pCCBReader) { if(strcmp(pPropertyName, PROPERTY_FNTFILE) == 0) { - ((CCLabelBMFont *)pNode)->setFntFile(pFntFile); + ((CCLabelBMFont *)pNode)->setFntFile(pCCBReader->concat(pCCBReader->getCCBRootPath().c_str(), pFntFile).c_str()); } else { CCNodeLoader::onHandlePropTypeFntFile(pNode, pParent, pPropertyName, pFntFile, pCCBReader); } diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp index c830ebe6ae..8fc166d0d6 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp @@ -31,7 +31,7 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * int propertyCount = pCCBReader->readInt(false); for(int i = 0; i < propertyCount; i++) { int type = pCCBReader->readInt(false); - const char * propertyName = pCCBReader->readCachedString(); + const char * propertyName = pCCBReader->readCachedString().c_str(); // Check if the property can be set for this platform bool setProp = false; @@ -404,24 +404,29 @@ bool CCNodeLoader::parsePropTypeCheck(CCNode * pNode, CCNode * pParent, CCBReade CCSpriteFrame * CCNodeLoader::parsePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - const char * spriteSheet = pCCBReader->readCachedString(); - const char * spriteFile = pCCBReader->readCachedString(); + const char * spriteSheet = pCCBReader->readCachedString().c_str(); + const char * spriteFile = pCCBReader->readCachedString().c_str(); CCSpriteFrame * spriteFrame; if(strcmp(spriteSheet, "") == 0) { if(strcmp(spriteFile, "") == 0) { return NULL; } - CCTexture2D * texture = CCTextureCache::sharedTextureCache()->addImage(spriteFile); + + const char * spriteFilePath = pCCBReader->concat(pCCBReader->getCCBRootPath().c_str(), spriteFile).c_str(); + + CCTexture2D * texture = CCTextureCache::sharedTextureCache()->addImage(spriteFilePath); CCRect bounds = CCRect::CCRect(0, 0, texture->getContentSize().width, texture->getContentSize().height); spriteFrame = CCSpriteFrame::frameWithTexture(texture, bounds); } else { CCSpriteFrameCache * frameCache = CCSpriteFrameCache::sharedSpriteFrameCache(); - + + const char * spriteSheetPath = pCCBReader->concat(pCCBReader->getCCBRootPath().c_str(), spriteSheet).c_str(); + /* Load the sprite sheet only if it is not loaded. */ - if(!pCCBReader->isSpriteSheetLoaded(spriteSheet)) { - frameCache->addSpriteFramesWithFile(spriteSheet); - pCCBReader->addLoadedSpriteSheet(spriteSheet); + if(!pCCBReader->isSpriteSheetLoaded(spriteSheetPath)) { + frameCache->addSpriteFramesWithFile(spriteSheetPath); + pCCBReader->addLoadedSpriteSheet(spriteSheetPath); } spriteFrame = frameCache->spriteFrameByName(spriteFile); @@ -430,8 +435,8 @@ CCSpriteFrame * CCNodeLoader::parsePropTypeSpriteFrame(CCNode * pNode, CCNode * } CCAnimation * CCNodeLoader::parsePropTypeAnimation(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - const char * animationFile = pCCBReader->readCachedString(); - const char * animation = pCCBReader->readCachedString(); + const char * animationFile = pCCBReader->readCachedString().c_str(); + const char * animation = pCCBReader->readCachedString().c_str(); CCAnimation * ccAnimation = NULL; @@ -440,8 +445,8 @@ CCAnimation * CCNodeLoader::parsePropTypeAnimation(CCNode * pNode, CCNode * pPar // Eventually this should be handled by a client side asset manager // interface which figured out what resources to load. // TODO Does this problem exist in C++? - animation = pCCBReader->lastPathComponent(animation); - animationFile = pCCBReader->lastPathComponent(animationFile); + animation = pCCBReader->lastPathComponent(animation).c_str(); + animationFile = pCCBReader->lastPathComponent(animationFile).c_str(); if(strcmp(animation, "") != 0) { CCAnimationCache * animationCache = CCAnimationCache::sharedAnimationCache(); @@ -453,7 +458,7 @@ CCAnimation * CCNodeLoader::parsePropTypeAnimation(CCNode * pNode, CCNode * pPar } CCTexture2D * CCNodeLoader::parsePropTypeTexture(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - const char * spriteFile = pCCBReader->readCachedString(); + const char * spriteFile = pCCBReader->concat(pCCBReader->getCCBRootPath().c_str(), pCCBReader->readCachedString().c_str()).c_str(); return CCTextureCache::sharedTextureCache()->addImage(spriteFile); } @@ -518,31 +523,31 @@ ccBlendFunc CCNodeLoader::parsePropTypeBlendFunc(CCNode * pNode, CCNode * pParen } const char * CCNodeLoader::parsePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - return pCCBReader->readCachedString(); + return pCCBReader->readCachedString().c_str(); } const char * CCNodeLoader::parsePropTypeString(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - return pCCBReader->readCachedString(); + return pCCBReader->readCachedString().c_str(); } const char * CCNodeLoader::parsePropTypeText(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - return pCCBReader->readCachedString(); + return pCCBReader->readCachedString().c_str(); } const char * CCNodeLoader::parsePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - const char * fnt = pCCBReader->readCachedString(); + const char * fnt = pCCBReader->readCachedString().c_str(); const char * ttfEnding("ttf"); - if(pCCBReader->endsWith(pCCBReader->toLowerCase(fnt), ttfEnding)){ - fnt = pCCBReader->deletePathExtension(pCCBReader->lastPathComponent(fnt)); + if(pCCBReader->endsWith(pCCBReader->toLowerCase(fnt).c_str(), ttfEnding)){ + fnt = pCCBReader->deletePathExtension(pCCBReader->lastPathComponent(fnt).c_str()).c_str(); } return fnt; } BlockData * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - const char * selectorName = pCCBReader->readCachedString(); + const char * selectorName = pCCBReader->readCachedString().c_str(); int selectorTarget = pCCBReader->readInt(false); if(selectorTarget != kCCBTargetTypeNone) { @@ -578,7 +583,7 @@ BlockData * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, C } BlockCCControlData * CCNodeLoader::parsePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - const char * selectorName = pCCBReader->readCachedString(); + const char * selectorName = pCCBReader->readCachedString().c_str(); int selectorTarget = pCCBReader->readInt(false); int controlEvents = pCCBReader->readInt(false); @@ -616,20 +621,16 @@ BlockCCControlData * CCNodeLoader::parsePropTypeBlockCCControl(CCNode * pNode, C } CCNode * CCNodeLoader::parsePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - const char * ccbFileName = pCCBReader->readCachedString(); + const char * ccbFileName = pCCBReader->readCachedString().c_str(); /* Change path extension to .ccbi. */ - const char * ccbFileWithoutPathExtension = pCCBReader->deletePathExtension(ccbFileName); - int ccbiFileNameLenght = strlen(ccbFileWithoutPathExtension) + strlen(".ccbi"); - char ccbiFileName[ccbiFileNameLenght + 1]; - strcpy(ccbiFileName, ccbFileWithoutPathExtension); - strcat(ccbiFileName, ".ccbi"); - ccbiFileName[ccbiFileNameLenght] = '\0'; + const char * ccbFileWithoutPathExtension = pCCBReader->deletePathExtension(ccbFileName).c_str(); + const char * ccbiFileName = pCCBReader->concat(ccbFileWithoutPathExtension, ".ccbi").c_str(); CCBReader * ccbReader = new CCBReader(pCCBReader); ccbReader->autorelease(); - CCNode * ccbFileNode = ccbReader->readNodeGraphFromFile(ccbiFileName, pCCBReader->getOwner(), pParent->getContentSize()); + CCNode * ccbFileNode = ccbReader->readNodeGraphFromFile(pCCBReader->getCCBRootPath().c_str(), ccbiFileName, pCCBReader->getOwner(), pParent->getContentSize()); return ccbFileNode; } diff --git a/tests/Resources/cbb/pub/fonts/Droid.ttf.REMOVED.git-id b/tests/Resources/ccb/pub/fonts/Droid.ttf.REMOVED.git-id similarity index 100% rename from tests/Resources/cbb/pub/fonts/Droid.ttf.REMOVED.git-id rename to tests/Resources/ccb/pub/fonts/Droid.ttf.REMOVED.git-id diff --git a/tests/Resources/cbb/src/fonts/Droid.ttf.REMOVED.git-id b/tests/Resources/ccb/src/fonts/Droid.ttf.REMOVED.git-id similarity index 100% rename from tests/Resources/cbb/src/fonts/Droid.ttf.REMOVED.git-id rename to tests/Resources/ccb/src/fonts/Droid.ttf.REMOVED.git-id diff --git a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id index 59b21d5854..c25c63674f 100644 --- a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -f42fb181945ec91cdc8569191c5810959798ba15 \ No newline at end of file +2183a27683dff4601536660a9a71e35cdfc1ce34 \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.cpp b/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.cpp index 41d9297d12..154d2ce97b 100644 --- a/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.cpp +++ b/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.cpp @@ -5,6 +5,21 @@ using namespace cocos2d; using namespace cocos2d::extension; +CCBIReaderLayer * CCBIReaderLayer::node() { + CCBIReaderLayer *pRet = new CCBIReaderLayer(); + if (pRet && pRet->init()) { + pRet->autorelease(); + return pRet; + } else { + CC_SAFE_DELETE(pRet); + return NULL; + } +} + +bool CCBIReaderLayer::init() { + return CCLayer::init(); +} + void CCBIReaderLayer::menuCloseCallback(CCObject* pSender) { CCDirector::sharedDirector()->end(); diff --git a/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.h b/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.h index 385f952b1f..ace823bfbf 100644 --- a/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.h +++ b/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.h @@ -7,6 +7,8 @@ class CCBIReaderLayer : public cocos2d::CCLayer, public cocos2d::extension::CCBMemberVariableAssigner, public cocos2d::extension::CCBSelectorResolver { public: + static CCBIReaderLayer * node(); + virtual bool init(); virtual void menuCloseCallback(CCObject * pSender); diff --git a/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderTest.cpp b/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderTest.cpp index b3d45d9699..fdeb5d98e3 100644 --- a/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderTest.cpp +++ b/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderTest.cpp @@ -25,7 +25,6 @@ #include "CCBIReaderTest.h" #include "../../testResource.h" #include "extensions/CCBIReader/CCBReader.h" -#include "HelloCocosBuilder.h" #include "extensions/CCBIReader/CCNodeLoaderLibrary.h" #include "CCBIReaderLayer.h" @@ -33,7 +32,7 @@ using namespace cocos2d; using namespace cocos2d::extension; void CCBIReaderTestScene::runThisTest() { - CCBIReaderLayer * ccbiReaderLayer = (CCBIReaderLayer *)CCBIReaderLayer::node(); + CCBIReaderLayer * ccbiReaderLayer = CCBIReaderLayer::node(); /* Create an autorelease CCNodeLoaderLibrary. */ CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary(); @@ -43,11 +42,13 @@ void CCBIReaderTestScene::runThisTest() { ccbReader->autorelease(); /* Read a ccbi file. */ - CCNode * node = ccbReader->readNodeGraphFromFile("ccb/pub/ccb/test.ccbi", ccbiReaderLayer); + CCNode * node = ccbReader->readNodeGraphFromFile("ccb/pub/", "ccb/test.ccbi", ccbiReaderLayer); if(node != NULL) { - this->addChild(node); + ccbiReaderLayer->addChild(node); } + this->addChild(ccbiReaderLayer); + CCDirector::sharedDirector()->replaceScene(this); } From e52d5ae223cd00602db9fa94a75191d61da2b0d9 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Mon, 11 Jun 2012 18:31:36 -0700 Subject: [PATCH 123/257] CCSpriteFrameCache: Minor optimization. --- cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp index b4b3c2802f..4d64d73dcf 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp @@ -104,7 +104,8 @@ void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary* dictionary, CCDICT_FOREACH(framesDict, pElement) { CCDictionary* frameDict = (CCDictionary*)pElement->getObject(); - CCSpriteFrame* spriteFrame = (CCSpriteFrame*)m_pSpriteFrames->objectForKey(pElement->getStrKey()); + std::string spriteFrameName = pElement->getStrKey(); + CCSpriteFrame* spriteFrame = (CCSpriteFrame*)m_pSpriteFrames->objectForKey(spriteFrameName); if (spriteFrame) { continue; @@ -171,7 +172,7 @@ void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary* dictionary, // get aliases CCArray* aliases = (CCArray*) (frameDict->objectForKey("aliases")); - CCString * frameKey = new CCString(pElement->getStrKey()); + CCString * frameKey = new CCString(spriteFrameName); CCObject* pObj = NULL; CCARRAY_FOREACH(aliases, pObj) @@ -195,7 +196,7 @@ void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary* dictionary, } // add sprite frame - m_pSpriteFrames->setObject(spriteFrame, pElement->getStrKey()); + m_pSpriteFrames->setObject(spriteFrame, spriteFrameName); spriteFrame->release(); } } From a8222b9757c3ad8440c92e7a6e8a037b027d5825 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Jun 2012 09:38:38 +0800 Subject: [PATCH 124/257] issue #1310: Sync Chipmunk to v6.1.1 --- chipmunk/include/chipmunk/chipmunk.h | 89 +- chipmunk/include/chipmunk/chipmunk_ffi.h | 3 +- chipmunk/include/chipmunk/chipmunk_private.h | 136 ++- chipmunk/include/chipmunk/chipmunk_types.h | 167 ++- .../chipmunk/constraints/cpConstraint.h | 102 +- .../constraints/cpDampedRotarySpring.h | 20 +- .../chipmunk/constraints/cpDampedSpring.h | 26 +- .../chipmunk/constraints/cpGearJoint.h | 16 +- .../chipmunk/constraints/cpGrooveJoint.h | 24 +- .../include/chipmunk/constraints/cpPinJoint.h | 20 +- .../chipmunk/constraints/cpPivotJoint.h | 18 +- .../chipmunk/constraints/cpRatchetJoint.h | 14 +- .../chipmunk/constraints/cpRotaryLimitJoint.h | 14 +- .../chipmunk/constraints/cpSimpleMotor.h | 12 +- .../chipmunk/constraints/cpSlideJoint.h | 20 +- chipmunk/include/chipmunk/constraints/util.h | 106 +- chipmunk/include/chipmunk/cpArbiter.h | 142 ++- chipmunk/include/chipmunk/cpBB.h | 84 +- chipmunk/include/chipmunk/cpBody.h | 153 +-- chipmunk/include/chipmunk/cpPolyShape.h | 23 +- chipmunk/include/chipmunk/cpShape.h | 176 +-- chipmunk/include/chipmunk/cpSpace.h | 189 +-- chipmunk/include/chipmunk/cpSpatialIndex.h | 113 +- chipmunk/include/chipmunk/cpVect.h | 52 +- chipmunk/src/CMakeLists.txt | 2 +- chipmunk/src/chipmunk.c | 310 +++-- chipmunk/src/constraints/cpConstraint.c | 40 +- .../src/constraints/cpDampedRotarySpring.c | 89 +- chipmunk/src/constraints/cpDampedSpring.c | 107 +- chipmunk/src/constraints/cpGearJoint.c | 109 +- chipmunk/src/constraints/cpGrooveJoint.c | 181 ++- chipmunk/src/constraints/cpPinJoint.c | 121 +- chipmunk/src/constraints/cpPivotJoint.c | 111 +- chipmunk/src/constraints/cpRatchetJoint.c | 139 ++- chipmunk/src/constraints/cpRotaryLimitJoint.c | 129 +- chipmunk/src/constraints/cpSimpleMotor.c | 89 +- chipmunk/src/constraints/cpSlideJoint.c | 146 ++- chipmunk/src/cpArbiter.c | 446 +++---- chipmunk/src/cpArray.c | 109 +- chipmunk/src/cpBB.c | 27 +- chipmunk/src/cpBBTree.c | 1044 ++++++++--------- chipmunk/src/cpBody.c | 280 +++-- chipmunk/src/cpCollision.c | 508 ++++---- chipmunk/src/cpHashSet.c | 321 +++-- chipmunk/src/cpPolyShape.c | 270 +++-- chipmunk/src/cpShape.c | 436 +++---- chipmunk/src/cpSpace.c | 635 +++++----- chipmunk/src/cpSpaceComponent.c | 479 ++++---- chipmunk/src/cpSpaceHash.c | 758 ++++++------ chipmunk/src/cpSpaceQuery.c | 376 +++--- chipmunk/src/cpSpaceStep.c | 637 +++++----- chipmunk/src/cpSpatialIndex.c | 67 +- chipmunk/src/cpSweep1D.c | 220 ++-- chipmunk/src/cpVect.c | 33 +- chipmunk/src/prime.h | 74 +- 55 files changed, 5144 insertions(+), 4868 deletions(-) diff --git a/chipmunk/include/chipmunk/chipmunk.h b/chipmunk/include/chipmunk/chipmunk.h index c47e93ce4c..fc04da8327 100644 --- a/chipmunk/include/chipmunk/chipmunk.h +++ b/chipmunk/include/chipmunk/chipmunk.h @@ -22,31 +22,34 @@ #ifndef CHIPMUNK_HEADER #define CHIPMUNK_HEADER +#include +#include + #ifdef __cplusplus extern "C" { #endif #ifndef CP_ALLOW_PRIVATE_ACCESS - #define CP_ALLOW_PRIVATE_ACCESS 0 + #define CP_ALLOW_PRIVATE_ACCESS 0 #endif #if CP_ALLOW_PRIVATE_ACCESS == 1 - #define CP_PRIVATE(symbol) symbol + #define CP_PRIVATE(symbol) symbol #else - #define CP_PRIVATE(symbol) symbol##_private + #define CP_PRIVATE(symbol) symbol##_private #endif void cpMessage(const char *condition, const char *file, int line, int isError, int isHardError, const char *message, ...); #ifdef NDEBUG - #define cpAssertWarn(condition, ...) + #define cpAssertWarn(condition, ...) #else - #define cpAssertWarn(condition, ...) if(!(condition)) cpMessage(#condition, __FILE__, __LINE__, 0, 0, __VA_ARGS__) + #define cpAssertWarn(condition, ...) if(!(condition)) cpMessage(#condition, __FILE__, __LINE__, 0, 0, __VA_ARGS__) #endif #ifdef NDEBUG - #define cpAssertSoft(condition, ...) + #define cpAssertSoft(condition, ...) #else - #define cpAssertSoft(condition, ...) if(!(condition)) cpMessage(#condition, __FILE__, __LINE__, 1, 0, __VA_ARGS__) + #define cpAssertSoft(condition, ...) if(!(condition)) cpMessage(#condition, __FILE__, __LINE__, 1, 0, __VA_ARGS__) #endif // Hard assertions are important and cheap to execute. They are not disabled by compiling as debug. @@ -54,28 +57,28 @@ void cpMessage(const char *condition, const char *file, int line, int isError, i #include "chipmunk_types.h" - + /// @defgroup misc Misc /// @{ /// Allocated size for various Chipmunk buffers #ifndef CP_BUFFER_BYTES - #define CP_BUFFER_BYTES (32*1024) + #define CP_BUFFER_BYTES (32*1024) #endif #ifndef cpcalloc - /// Chipmunk calloc() alias. - #define cpcalloc calloc + /// Chipmunk calloc() alias. + #define cpcalloc calloc #endif #ifndef cprealloc - /// Chipmunk realloc() alias. - #define cprealloc realloc + /// Chipmunk realloc() alias. + #define cprealloc realloc #endif #ifndef cpfree - /// Chipmunk free() alias. - #define cpfree free + /// Chipmunk free() alias. + #define cpfree free #endif typedef struct cpArray cpArray; @@ -98,15 +101,15 @@ typedef struct cpSpace cpSpace; #include "cpShape.h" #include "cpPolyShape.h" -#include "cpArbiter.h" +#include "cpArbiter.h" #include "constraints/cpConstraint.h" #include "cpSpace.h" -// Chipmunk 6.0.3 +// Chipmunk 6.1.1 #define CP_VERSION_MAJOR 6 -#define CP_VERSION_MINOR 0 -#define CP_VERSION_RELEASE 3 +#define CP_VERSION_MINOR 1 +#define CP_VERSION_RELEASE 1 /// Version string. extern const char *cpVersionString; @@ -148,6 +151,54 @@ cpFloat cpMomentForBox(cpFloat m, cpFloat width, cpFloat height); /// Calculate the moment of inertia for a solid box. cpFloat cpMomentForBox2(cpFloat m, cpBB box); +/// Calculate the convex hull of a given set of points. Returns the count of points in the hull. +/// @c result must be a pointer to a @c cpVect array with at least @c count elements. If @c result is @c NULL, then @c verts will be reduced instead. +/// @c first is an optional pointer to an integer to store where the first vertex in the hull came from (i.e. verts[first] == result[0]) +/// @c tol is the allowed amount to shrink the hull when simplifying it. A tolerance of 0.0 creates an exact hull. +int cpConvexHull(int count, cpVect *verts, cpVect *result, int *first, cpFloat tol); + +#ifdef _MSC_VER +#include "malloc.h" +#endif + +/// Convenience macro to work with cpConvexHull. +/// @c count and @c verts is the input array passed to cpConvexHull(). +/// @c count_var and @c verts_var are the names of the variables the macro creates to store the result. +/// The output vertex array is allocated on the stack using alloca() so it will be freed automatically, but cannot be returned from the current scope. +#define CP_CONVEX_HULL(__count__, __verts__, __count_var__, __verts_var__) \ +cpVect *__verts_var__ = (cpVect *)alloca(__count__*sizeof(cpVect)); \ +int __count_var__ = cpConvexHull(__count__, __verts__, __verts_var__, NULL, 0.0); \ + +#if defined(__has_extension) +#if __has_extension(blocks) +// Define alternate block based alternatives for a few of the callback heavy functions. +// Collision handlers are post-step callbacks are not included to avoid memory management issues. +// If you want to use blocks for those and are aware of how to correctly manage the memory, the implementation is trivial. + +void cpSpaceEachBody_b(cpSpace *space, void (^block)(cpBody *body)); +void cpSpaceEachShape_b(cpSpace *space, void (^block)(cpShape *shape)); +void cpSpaceEachConstraint_b(cpSpace *space, void (^block)(cpConstraint *constraint)); + +void cpBodyEachShape_b(cpBody *body, void (^block)(cpShape *shape)); +void cpBodyEachConstraint_b(cpBody *body, void (^block)(cpConstraint *constraint)); +void cpBodyEachArbiter_b(cpBody *body, void (^block)(cpArbiter *arbiter)); + +typedef void (^cpSpaceNearestPointQueryBlock)(cpShape *shape, cpFloat distance, cpVect point); +void cpSpaceNearestPointQuery_b(cpSpace *space, cpVect point, cpFloat maxDistance, cpLayers layers, cpGroup group, cpSpaceNearestPointQueryBlock block); + +typedef void (^cpSpaceSegmentQueryBlock)(cpShape *shape, cpFloat t, cpVect n); +void cpSpaceSegmentQuery_b(cpSpace *space, cpVect start, cpVect end, cpLayers layers, cpGroup group, cpSpaceSegmentQueryBlock block); + +typedef void (^cpSpaceBBQueryBlock)(cpShape *shape); +void cpSpaceBBQuery_b(cpSpace *space, cpBB bb, cpLayers layers, cpGroup group, cpSpaceBBQueryBlock block); + +typedef void (^cpSpaceShapeQueryBlock)(cpShape *shape, cpContactPointSet *points); +cpBool cpSpaceShapeQuery_b(cpSpace *space, cpShape *shape, cpSpaceShapeQueryBlock block); + +#endif +#endif + + //@} #ifdef __cplusplus diff --git a/chipmunk/include/chipmunk/chipmunk_ffi.h b/chipmunk/include/chipmunk/chipmunk_ffi.h index 41b3834438..bef268fa6d 100644 --- a/chipmunk/include/chipmunk/chipmunk_ffi.h +++ b/chipmunk/include/chipmunk/chipmunk_ffi.h @@ -14,7 +14,7 @@ #endif #define MAKE_PROPERTIES_REF(struct, property) \ - MAKE_REF(struct##Get##property); MAKE_REF(struct##Set##property); + MAKE_REF(struct##Get##property); MAKE_REF(struct##Set##property); MAKE_REF(cpv); // makes a variable named _cpv that contains the function pointer for cpv() MAKE_REF(cpveql); @@ -152,7 +152,6 @@ MAKE_REF(cpSpatialIndexInsert); MAKE_REF(cpSpatialIndexRemove); MAKE_REF(cpSpatialIndexReindex); MAKE_REF(cpSpatialIndexReindexObject); -MAKE_REF(cpSpatialIndexPointQuery); MAKE_REF(cpSpatialIndexSegmentQuery); MAKE_REF(cpSpatialIndexQuery); MAKE_REF(cpSpatialIndexReindexQuery); diff --git a/chipmunk/include/chipmunk/chipmunk_private.h b/chipmunk/include/chipmunk/chipmunk_private.h index 094331042d..31d5ea5988 100644 --- a/chipmunk/include/chipmunk/chipmunk_private.h +++ b/chipmunk/include/chipmunk/chipmunk_private.h @@ -28,8 +28,8 @@ //MARK: cpArray struct cpArray { - int num, max; - void **arr; + int num, max; + void **arr; }; cpArray *cpArrayNew(int size); @@ -48,26 +48,26 @@ void cpArrayFreeEach(cpArray *arr, void (freeFunc)(void*)); static inline cpConstraint * cpConstraintNext(cpConstraint *node, cpBody *body) { - return (node->a == body ? node->next_a : node->next_b); + return (node->a == body ? node->next_a : node->next_b); } #define CP_BODY_FOREACH_CONSTRAINT(bdy, var)\ - for(cpConstraint *var = bdy->constraintList; var; var = cpConstraintNext(var, bdy)) + for(cpConstraint *var = bdy->constraintList; var; var = cpConstraintNext(var, bdy)) static inline cpArbiter * cpArbiterNext(cpArbiter *node, cpBody *body) { - return (node->body_a == body ? node->thread_a.next : node->thread_b.next); + return (node->body_a == body ? node->thread_a.next : node->thread_b.next); } #define CP_BODY_FOREACH_ARBITER(bdy, var)\ - for(cpArbiter *var = bdy->arbiterList; var; var = cpArbiterNext(var, bdy)) + for(cpArbiter *var = bdy->arbiterList; var; var = cpArbiterNext(var, bdy)) #define CP_BODY_FOREACH_SHAPE(body, var)\ - for(cpShape *var = body->shapeList; var; var = var->next) + for(cpShape *var = body->shapeList; var; var = var->next) #define CP_BODY_FOREACH_COMPONENT(root, var)\ - for(cpBody *var = root; var; var = var->node.next) + for(cpBody *var = root; var; var = var->node.next) //MARK: cpHashSet @@ -99,54 +99,80 @@ void cpBodyRemoveConstraint(cpBody *body, cpConstraint *constraint); //MARK: Shape/Collision Functions +// TODO should move this to the cpVect API. It's pretty useful. +static inline cpVect +cpClosetPointOnSegment(const cpVect p, const cpVect a, const cpVect b) +{ + cpVect delta = cpvsub(a, b); + cpFloat t = cpfclamp01(cpvdot(delta, cpvsub(p, b))/cpvlengthsq(delta)); + return cpvadd(b, cpvmult(delta, t)); +} + cpShape* cpShapeInit(cpShape *shape, const cpShapeClass *klass, cpBody *body); static inline cpBool cpShapeActive(cpShape *shape) { - return shape->prev || shape->body->shapeList == shape; + return shape->prev || (shape->body && shape->body->shapeList == shape); } int cpCollideShapes(const cpShape *a, const cpShape *b, cpContact *arr); +// TODO doesn't really need to be inline, but need a better place to put this function +static inline cpSplittingPlane +cpSplittingPlaneNew(cpVect a, cpVect b) +{ + cpVect n = cpvnormalize(cpvperp(cpvsub(b, a))); + cpSplittingPlane plane = {n, cpvdot(n, a)}; + return plane; +} + +static inline cpFloat +cpSplittingPlaneCompare(cpSplittingPlane plane, cpVect v) +{ + return cpvdot(plane.n, v) - plane.d; +} + +void cpLoopIndexes(cpVect *verts, int count, int *start, int *end); + static inline cpFloat cpPolyShapeValueOnAxis(const cpPolyShape *poly, const cpVect n, const cpFloat d) { - cpVect *verts = poly->tVerts; - cpFloat min = cpvdot(n, verts[0]); - - for(int i=1; inumVerts; i++){ - min = cpfmin(min, cpvdot(n, verts[i])); - } - - return min - d; + cpVect *verts = poly->tVerts; + cpFloat min = cpvdot(n, verts[0]); + + for(int i=1; inumVerts; i++){ + min = cpfmin(min, cpvdot(n, verts[i])); + } + + return min - d; } static inline cpBool cpPolyShapeContainsVert(const cpPolyShape *poly, const cpVect v) { - cpPolyShapeAxis *axes = poly->tAxes; - - for(int i=0; inumVerts; i++){ - cpFloat dist = cpvdot(axes[i].n, v) - axes[i].d; - if(dist > 0.0f) return cpFalse; - } - - return cpTrue; + cpSplittingPlane *planes = poly->tPlanes; + + for(int i=0; inumVerts; i++){ + cpFloat dist = cpSplittingPlaneCompare(planes[i], v); + if(dist > 0.0f) return cpFalse; + } + + return cpTrue; } static inline cpBool cpPolyShapeContainsVertPartial(const cpPolyShape *poly, const cpVect v, const cpVect n) { - cpPolyShapeAxis *axes = poly->tAxes; - - for(int i=0; inumVerts; i++){ - if(cpvdot(axes[i].n, n) < 0.0f) continue; - cpFloat dist = cpvdot(axes[i].n, v) - axes[i].d; - if(dist > 0.0f) return cpFalse; - } - - return cpTrue; + cpSplittingPlane *planes = poly->tPlanes; + + for(int i=0; inumVerts; i++){ + if(cpvdot(planes[i].n, n) < 0.0f) continue; + cpFloat dist = cpSplittingPlaneCompare(planes[i], v); + if(dist > 0.0f) return cpFalse; + } + + return cpTrue; } //MARK: Spatial Index Functions @@ -162,7 +188,7 @@ void cpSpacePushFreshContactBuffer(cpSpace *space); cpContact *cpContactBufferGetArray(cpSpace *space); void cpSpacePushContacts(cpSpace *space, int count); -void *cpSpaceGetPostStepData(cpSpace *space, void *obj); +void *cpSpaceGetPostStepData(cpSpace *space, void *key); cpBool cpSpaceArbiterSetFilter(cpArbiter *arb, cpSpace *space); void cpSpaceFilterArbiters(cpSpace *space, cpBody *body, cpShape *filter); @@ -174,18 +200,18 @@ void cpSpaceUnlock(cpSpace *space, cpBool runPostStep); static inline cpCollisionHandler * cpSpaceLookupHandler(cpSpace *space, cpCollisionType a, cpCollisionType b) { - cpCollisionType types[] = {a, b}; - return (cpCollisionHandler *)cpHashSetFind(space->collisionHandlers, CP_HASH_PAIR(a, b), types); + cpCollisionType types[] = {a, b}; + return (cpCollisionHandler *)cpHashSetFind(space->collisionHandlers, CP_HASH_PAIR(a, b), types); } static inline void cpSpaceUncacheArbiter(cpSpace *space, cpArbiter *arb) { - cpShape *a = arb->a, *b = arb->b; - cpShape *shape_pair[] = {a, b}; - cpHashValue arbHashID = CP_HASH_PAIR((cpHashValue)a, (cpHashValue)b); - cpHashSetRemove(space->cachedArbiters, arbHashID, shape_pair); - cpArrayDeleteObj(space->arbiters, arb); + cpShape *a = arb->a, *b = arb->b; + cpShape *shape_pair[] = {a, b}; + cpHashValue arbHashID = CP_HASH_PAIR((cpHashValue)a, (cpHashValue)b); + cpHashSetRemove(space->cachedArbiters, arbHashID, shape_pair); + cpArrayDeleteObj(space->arbiters, arb); } void cpShapeUpdateFunc(cpShape *shape, void *unused); @@ -196,16 +222,16 @@ void cpSpaceCollideShapes(cpShape *a, cpShape *b, cpSpace *space); //MARK: Arbiters struct cpContact { - cpVect p, n; - cpFloat dist; - - cpVect r1, r2; - cpFloat nMass, tMass, bounce; + cpVect p, n; + cpFloat dist; + + cpVect r1, r2; + cpFloat nMass, tMass, bounce; - cpFloat jnAcc, jtAcc, jBias; - cpFloat bias; - - cpHashValue hash; + cpFloat jnAcc, jtAcc, jBias; + cpFloat bias; + + cpHashValue hash; }; cpContact* cpContactInit(cpContact *con, cpVect p, cpVect n, cpFloat dist, cpHashValue hash); @@ -214,15 +240,15 @@ cpArbiter* cpArbiterInit(cpArbiter *arb, cpShape *a, cpShape *b); static inline void cpArbiterCallSeparate(cpArbiter *arb, cpSpace *space) { - // The handler needs to be looked up again as the handler cached on the arbiter may have been deleted since the last step. - cpCollisionHandler *handler = cpSpaceLookupHandler(space, arb->a->collision_type, arb->b->collision_type); - handler->separate(arb, space, handler->data); + // The handler needs to be looked up again as the handler cached on the arbiter may have been deleted since the last step. + cpCollisionHandler *handler = cpSpaceLookupHandler(space, arb->a->collision_type, arb->b->collision_type); + handler->separate(arb, space, handler->data); } static inline struct cpArbiterThread * cpArbiterThreadForBody(cpArbiter *arb, cpBody *body) { - return (arb->body_a == body ? &arb->thread_a : &arb->thread_b); + return (arb->body_a == body ? &arb->thread_a : &arb->thread_b); } void cpArbiterUnthread(cpArbiter *arb); diff --git a/chipmunk/include/chipmunk/chipmunk_types.h b/chipmunk/include/chipmunk/chipmunk_types.h index 0f8faca0b9..fb61f8c73f 100644 --- a/chipmunk/include/chipmunk/chipmunk_types.h +++ b/chipmunk/include/chipmunk/chipmunk_types.h @@ -5,27 +5,27 @@ #import "TargetConditionals.h" #endif -#if (TARGET_OS_IPHONE == 1) && (!defined CP_USE_CGPOINTS) - #define CP_USE_CGPOINTS 1 +#if (TARGET_OS_IPHONE == 1) || (TARGET_OS_MAC == 1) && (!defined CP_USE_CGPOINTS) + #define CP_USE_CGPOINTS 1 #endif -#ifdef CP_USE_CGPOINTS - #if TARGET_OS_IPHONE - #import - #elif TARGET_OS_MAC - #import - #endif - - #if defined(__LP64__) && __LP64__ - #define CP_USE_DOUBLES 1 - #else - #define CP_USE_DOUBLES 0 - #endif +#if CP_USE_CGPOINTS == 1 + #if TARGET_OS_IPHONE + #import + #elif TARGET_OS_MAC + #import + #endif + + #if defined(__LP64__) && __LP64__ + #define CP_USE_DOUBLES 1 + #else + #define CP_USE_DOUBLES 0 + #endif #endif #ifndef CP_USE_DOUBLES - // use doubles by default for higher precision - #define CP_USE_DOUBLES 1 + // use doubles by default for higher precision + #define CP_USE_DOUBLES 1 #endif /// @defgroup basicTypes Basic Types @@ -35,89 +35,88 @@ #if CP_USE_DOUBLES /// Chipmunk's floating point type. /// Can be reconfigured at compile time. - typedef double cpFloat; - #define cpfsqrt sqrt - #define cpfsin sin - #define cpfcos cos - #define cpfacos acos - #define cpfatan2 atan2 - #define cpfmod fmod - #define cpfexp exp - #define cpfpow pow - #define cpffloor floor - #define cpfceil ceil + typedef double cpFloat; + #define cpfsqrt sqrt + #define cpfsin sin + #define cpfcos cos + #define cpfacos acos + #define cpfatan2 atan2 + #define cpfmod fmod + #define cpfexp exp + #define cpfpow pow + #define cpffloor floor + #define cpfceil ceil #else - typedef float cpFloat; - #define cpfsqrt sqrtf - #define cpfsin sinf - #define cpfcos cosf - #define cpfacos acosf - #define cpfatan2 atan2f - #define cpfmod fmodf - #define cpfexp expf - #define cpfpow powf - #define cpffloor floorf - #define cpfceil ceilf + typedef float cpFloat; + #define cpfsqrt sqrtf + #define cpfsin sinf + #define cpfcos cosf + #define cpfacos acosf + #define cpfatan2 atan2f + #define cpfmod fmodf + #define cpfexp expf + #define cpfpow powf + #define cpffloor floorf + #define cpfceil ceilf #endif #ifndef INFINITY - //TODO use C++ infinity - #ifdef _MSC_VER - union MSVC_EVIL_FLOAT_HACK - { - unsigned __int8 Bytes[4]; - float Value; - }; - static union MSVC_EVIL_FLOAT_HACK INFINITY_HACK = {{0x00, 0x00, 0x80, 0x7F}}; - #define INFINITY (INFINITY_HACK.Value) - #endif - - #ifdef __GNUC__ - #define INFINITY (__builtin_inf()) - #endif - - #ifndef INFINITY - #define INFINITY (1e1000) - #endif + #ifdef _MSC_VER + union MSVC_EVIL_FLOAT_HACK + { + unsigned __int8 Bytes[4]; + float Value; + }; + static union MSVC_EVIL_FLOAT_HACK INFINITY_HACK = {{0x00, 0x00, 0x80, 0x7F}}; + #define INFINITY (INFINITY_HACK.Value) + #endif + + #ifdef __GNUC__ + #define INFINITY (__builtin_inf()) + #endif + + #ifndef INFINITY + #define INFINITY (1e1000) + #endif #endif #ifndef M_PI - #define M_PI 3.14159265358979323846264338327950288 + #define M_PI 3.14159265358979323846264338327950288 #endif #ifndef M_E - #define M_E 2.71828182845904523536028747135266250 + #define M_E 2.71828182845904523536028747135266250 #endif /// Return the max of two cpFloats. static inline cpFloat cpfmax(cpFloat a, cpFloat b) { - return (a > b) ? a : b; + return (a > b) ? a : b; } /// Return the min of two cpFloats. static inline cpFloat cpfmin(cpFloat a, cpFloat b) { - return (a < b) ? a : b; + return (a < b) ? a : b; } /// Return the absolute value of a cpFloat. static inline cpFloat cpfabs(cpFloat f) { - return (f < 0) ? -f : f; + return (f < 0) ? -f : f; } /// Clamp @c f to be between @c min and @c max. static inline cpFloat cpfclamp(cpFloat f, cpFloat min, cpFloat max) { - return cpfmin(cpfmax(f, min), max); + return cpfmin(cpfmax(f, min), max); } /// Clamp @c f to be between 0 and 1. static inline cpFloat cpfclamp01(cpFloat f) { - return cpfmax(0.0f, cpfmin(f, 1.0f)); + return cpfmax(0.0f, cpfmin(f, 1.0f)); } @@ -125,13 +124,13 @@ static inline cpFloat cpfclamp01(cpFloat f) /// Linearly interpolate (or extrapolate) between @c f1 and @c f2 by @c t percent. static inline cpFloat cpflerp(cpFloat f1, cpFloat f2, cpFloat t) { - return f1*(1.0f - t) + f2*t; + return f1*(1.0f - t) + f2*t; } /// Linearly interpolate from @c f1 to @c f2 by no more than @c d. static inline cpFloat cpflerpconst(cpFloat f1, cpFloat f2, cpFloat d) { - return f1 + cpfclamp(f2 - f1, -d, d); + return f1 + cpfclamp(f2 - f1, -d, d); } /// Hash value type. @@ -140,75 +139,75 @@ typedef uintptr_t cpHashValue; // Oh C, how we love to define our own boolean types to get compiler compatibility /// Chipmunk's boolean type. #ifdef CP_BOOL_TYPE - typedef CP_BOOL_TYPE cpBool; + typedef CP_BOOL_TYPE cpBool; #else - typedef int cpBool; + typedef int cpBool; #endif #ifndef cpTrue /// true value. - #define cpTrue 1 + #define cpTrue 1 #endif #ifndef cpFalse /// false value. - #define cpFalse 0 + #define cpFalse 0 #endif #ifdef CP_DATA_POINTER_TYPE - typedef CP_DATA_POINTER_TYPE cpDataPointer; + typedef CP_DATA_POINTER_TYPE cpDataPointer; #else /// Type used for user data pointers. - typedef void * cpDataPointer; + typedef void * cpDataPointer; #endif #ifdef CP_COLLISION_TYPE_TYPE - typedef CP_COLLISION_TYPE_TYPE cpCollisionType; + typedef CP_COLLISION_TYPE_TYPE cpCollisionType; #else /// Type used for cpSpace.collision_type. - typedef uintptr_t cpCollisionType; + typedef uintptr_t cpCollisionType; #endif #ifdef CP_GROUP_TYPE - typedef CP_GROUP_TYPE cpGroup; + typedef CP_GROUP_TYPE cpGroup; #else /// Type used for cpShape.group. - typedef uintptr_t cpGroup; + typedef uintptr_t cpGroup; #endif #ifdef CP_LAYERS_TYPE - typedef CP_LAYERS_TYPE cpLayers; + typedef CP_LAYERS_TYPE cpLayers; #else /// Type used for cpShape.layers. - typedef unsigned int cpLayers; + typedef unsigned int cpLayers; #endif #ifdef CP_TIMESTAMP_TYPE - typedef CP_TIMESTAMP_TYPE cpTimestamp; + typedef CP_TIMESTAMP_TYPE cpTimestamp; #else /// Type used for various timestamps in Chipmunk. - typedef unsigned int cpTimestamp; + typedef unsigned int cpTimestamp; #endif #ifndef CP_NO_GROUP /// Value for cpShape.group signifying that a shape is in no group. - #define CP_NO_GROUP ((cpGroup)0) + #define CP_NO_GROUP ((cpGroup)0) #endif #ifndef CP_ALL_LAYERS /// Value for cpShape.layers signifying that a shape is in every layer. - #define CP_ALL_LAYERS (~(cpLayers)0) + #define CP_ALL_LAYERS (~(cpLayers)0) #endif /// @} // CGPoints are structurally the same, and allow // easy interoperability with other Cocoa libraries -#ifdef CP_USE_CGPOINTS - typedef CGPoint cpVect; +#if CP_USE_CGPOINTS + typedef CGPoint cpVect; #else /// Chipmunk's 2D vector type. /// @addtogroup cpVect - typedef struct cpVect{cpFloat x,y;} cpVect; + typedef struct cpVect{cpFloat x,y;} cpVect; #endif diff --git a/chipmunk/include/chipmunk/constraints/cpConstraint.h b/chipmunk/include/chipmunk/constraints/cpConstraint.h index 4859e1f482..0202748fb9 100644 --- a/chipmunk/include/chipmunk/constraints/cpConstraint.h +++ b/chipmunk/include/chipmunk/constraints/cpConstraint.h @@ -31,10 +31,10 @@ typedef cpFloat (*cpConstraintGetImpulseImpl)(cpConstraint *constraint); /// @private struct cpConstraintClass { - cpConstraintPreStepImpl preStep; - cpConstraintApplyCachedImpulseImpl applyCachedImpulse; - cpConstraintApplyImpulseImpl applyImpulse; - cpConstraintGetImpulseImpl getImpulse; + cpConstraintPreStepImpl preStep; + cpConstraintApplyCachedImpulseImpl applyCachedImpulse; + cpConstraintApplyImpulseImpl applyImpulse; + cpConstraintGetImpulseImpl getImpulse; }; /// Callback function type that gets called before solving a joint. @@ -45,41 +45,41 @@ typedef void (*cpConstraintPostSolveFunc)(cpConstraint *constraint, cpSpace *spa /// Opaque cpConstraint struct. struct cpConstraint { - CP_PRIVATE(const cpConstraintClass *klass); - - /// The first body connected to this constraint. - cpBody *a; - /// The second body connected to this constraint. - cpBody *b; - - CP_PRIVATE(cpSpace *space); - - CP_PRIVATE(cpConstraint *next_a); - CP_PRIVATE(cpConstraint *next_b); - - /// The maximum force that this constraint is allowed to use. - /// Defaults to infinity. - cpFloat maxForce; - /// The rate at which joint error is corrected. - /// Defaults to pow(1.0 - 0.1, 60.0) meaning that it will - /// correct 10% of the error every 1/60th of a second. - cpFloat errorBias; - /// The maximum rate at which joint error is corrected. - /// Defaults to infinity. - cpFloat maxBias; - - /// Function called before the solver runs. - /// Animate your joint anchors, update your motor torque, etc. - cpConstraintPreSolveFunc preSolve; - - /// Function called after the solver runs. - /// Use the applied impulse to perform effects like breakable joints. - cpConstraintPostSolveFunc postSolve; - - /// User definable data pointer. - /// Generally this points to your the game object class so you can access it - /// when given a cpConstraint reference in a callback. - cpDataPointer data; + CP_PRIVATE(const cpConstraintClass *klass); + + /// The first body connected to this constraint. + cpBody *a; + /// The second body connected to this constraint. + cpBody *b; + + CP_PRIVATE(cpSpace *space); + + CP_PRIVATE(cpConstraint *next_a); + CP_PRIVATE(cpConstraint *next_b); + + /// The maximum force that this constraint is allowed to use. + /// Defaults to infinity. + cpFloat maxForce; + /// The rate at which joint error is corrected. + /// Defaults to pow(1.0 - 0.1, 60.0) meaning that it will + /// correct 10% of the error every 1/60th of a second. + cpFloat errorBias; + /// The maximum rate at which joint error is corrected. + /// Defaults to infinity. + cpFloat maxBias; + + /// Function called before the solver runs. + /// Animate your joint anchors, update your motor torque, etc. + cpConstraintPreSolveFunc preSolve; + + /// Function called after the solver runs. + /// Use the applied impulse to perform effects like breakable joints. + cpConstraintPostSolveFunc postSolve; + + /// User definable data pointer. + /// Generally this points to your the game object class so you can access it + /// when given a cpConstraint reference in a callback. + cpDataPointer data; }; /// Destroy a constraint. @@ -90,8 +90,8 @@ void cpConstraintFree(cpConstraint *constraint); /// @private static inline void cpConstraintActivateBodies(cpConstraint *constraint) { - cpBody *a = constraint->a; if(a) cpBodyActivate(a); - cpBody *b = constraint->b; if(b) cpBodyActivate(b); + cpBody *a = constraint->a; if(a) cpBodyActivate(a); + cpBody *b = constraint->b; if(b) cpBodyActivate(b); } /// @private @@ -101,8 +101,8 @@ static inline type cpConstraint##Get##name(const cpConstraint *constraint){retur /// @private #define CP_DefineConstraintStructSetter(type, member, name) \ static inline void cpConstraint##Set##name(cpConstraint *constraint, type value){ \ - cpConstraintActivateBodies(constraint); \ - constraint->member = value; \ + cpConstraintActivateBodies(constraint); \ + constraint->member = value; \ } /// @private @@ -110,6 +110,8 @@ static inline void cpConstraint##Set##name(cpConstraint *constraint, type value) CP_DefineConstraintStructGetter(type, member, name) \ CP_DefineConstraintStructSetter(type, member, name) +CP_DefineConstraintStructGetter(cpSpace*, CP_PRIVATE(space), Space); + CP_DefineConstraintStructGetter(cpBody*, a, A); CP_DefineConstraintStructGetter(cpBody*, b, B); CP_DefineConstraintStructProperty(cpFloat, maxForce, MaxForce); @@ -122,25 +124,25 @@ CP_DefineConstraintStructProperty(cpDataPointer, data, UserData); // Get the last impulse applied by this constraint. static inline cpFloat cpConstraintGetImpulse(cpConstraint *constraint) { - return constraint->CP_PRIVATE(klass)->getImpulse(constraint); + return constraint->CP_PRIVATE(klass)->getImpulse(constraint); } /// @} #define cpConstraintCheckCast(constraint, struct) \ - cpAssertHard(constraint->CP_PRIVATE(klass) == struct##GetClass(), "Constraint is not a "#struct) + cpAssertHard(constraint->CP_PRIVATE(klass) == struct##GetClass(), "Constraint is not a "#struct) #define CP_DefineConstraintGetter(struct, type, member, name) \ static inline type struct##Get##name(const cpConstraint *constraint){ \ - cpConstraintCheckCast(constraint, struct); \ - return ((struct *)constraint)->member; \ + cpConstraintCheckCast(constraint, struct); \ + return ((struct *)constraint)->member; \ } #define CP_DefineConstraintSetter(struct, type, member, name) \ static inline void struct##Set##name(cpConstraint *constraint, type value){ \ - cpConstraintCheckCast(constraint, struct); \ - cpConstraintActivateBodies(constraint); \ - ((struct *)constraint)->member = value; \ + cpConstraintCheckCast(constraint, struct); \ + cpConstraintActivateBodies(constraint); \ + ((struct *)constraint)->member = value; \ } #define CP_DefineConstraintProperty(struct, type, member, name) \ diff --git a/chipmunk/include/chipmunk/constraints/cpDampedRotarySpring.h b/chipmunk/include/chipmunk/constraints/cpDampedRotarySpring.h index fb9c21c6da..ac272f8ab7 100644 --- a/chipmunk/include/chipmunk/constraints/cpDampedRotarySpring.h +++ b/chipmunk/include/chipmunk/constraints/cpDampedRotarySpring.h @@ -28,16 +28,16 @@ const cpConstraintClass *cpDampedRotarySpringGetClass(void); /// @private typedef struct cpDampedRotarySpring { - cpConstraint constraint; - cpFloat restAngle; - cpFloat stiffness; - cpFloat damping; - cpDampedRotarySpringTorqueFunc springTorqueFunc; - - cpFloat target_wrn; - cpFloat w_coef; - - cpFloat iSum; + cpConstraint constraint; + cpFloat restAngle; + cpFloat stiffness; + cpFloat damping; + cpDampedRotarySpringTorqueFunc springTorqueFunc; + + cpFloat target_wrn; + cpFloat w_coef; + + cpFloat iSum; } cpDampedRotarySpring; /// Allocate a damped rotary spring. diff --git a/chipmunk/include/chipmunk/constraints/cpDampedSpring.h b/chipmunk/include/chipmunk/constraints/cpDampedSpring.h index 106b56d3c2..249fb247da 100644 --- a/chipmunk/include/chipmunk/constraints/cpDampedSpring.h +++ b/chipmunk/include/chipmunk/constraints/cpDampedSpring.h @@ -30,19 +30,19 @@ const cpConstraintClass *cpDampedSpringGetClass(void); /// @private struct cpDampedSpring { - cpConstraint constraint; - cpVect anchr1, anchr2; - cpFloat restLength; - cpFloat stiffness; - cpFloat damping; - cpDampedSpringForceFunc springForceFunc; - - cpFloat target_vrn; - cpFloat v_coef; - - cpVect r1, r2; - cpFloat nMass; - cpVect n; + cpConstraint constraint; + cpVect anchr1, anchr2; + cpFloat restLength; + cpFloat stiffness; + cpFloat damping; + cpDampedSpringForceFunc springForceFunc; + + cpFloat target_vrn; + cpFloat v_coef; + + cpVect r1, r2; + cpFloat nMass; + cpVect n; }; /// Allocate a damped spring. diff --git a/chipmunk/include/chipmunk/constraints/cpGearJoint.h b/chipmunk/include/chipmunk/constraints/cpGearJoint.h index 4a5801dd44..caa6c12d67 100644 --- a/chipmunk/include/chipmunk/constraints/cpGearJoint.h +++ b/chipmunk/include/chipmunk/constraints/cpGearJoint.h @@ -26,14 +26,14 @@ const cpConstraintClass *cpGearJointGetClass(void); /// @private typedef struct cpGearJoint { - cpConstraint constraint; - cpFloat phase, ratio; - cpFloat ratio_inv; - - cpFloat iSum; - - cpFloat bias; - cpFloat jAcc, jMax; + cpConstraint constraint; + cpFloat phase, ratio; + cpFloat ratio_inv; + + cpFloat iSum; + + cpFloat bias; + cpFloat jAcc, jMax; } cpGearJoint; /// Allocate a gear joint. diff --git a/chipmunk/include/chipmunk/constraints/cpGrooveJoint.h b/chipmunk/include/chipmunk/constraints/cpGrooveJoint.h index 7a2caa1ce1..52c815648b 100644 --- a/chipmunk/include/chipmunk/constraints/cpGrooveJoint.h +++ b/chipmunk/include/chipmunk/constraints/cpGrooveJoint.h @@ -26,18 +26,18 @@ const cpConstraintClass *cpGrooveJointGetClass(void); /// @private typedef struct cpGrooveJoint { - cpConstraint constraint; - cpVect grv_n, grv_a, grv_b; - cpVect anchr2; - - cpVect grv_tn; - cpFloat clamp; - cpVect r1, r2; - cpVect k1, k2; - - cpVect jAcc; - cpFloat jMaxLen; - cpVect bias; + cpConstraint constraint; + cpVect grv_n, grv_a, grv_b; + cpVect anchr2; + + cpVect grv_tn; + cpFloat clamp; + cpVect r1, r2; + cpVect k1, k2; + + cpVect jAcc; + cpFloat jMaxLen; + cpVect bias; } cpGrooveJoint; /// Allocate a groove joint. diff --git a/chipmunk/include/chipmunk/constraints/cpPinJoint.h b/chipmunk/include/chipmunk/constraints/cpPinJoint.h index 103ad11330..32c32852ad 100644 --- a/chipmunk/include/chipmunk/constraints/cpPinJoint.h +++ b/chipmunk/include/chipmunk/constraints/cpPinJoint.h @@ -26,16 +26,16 @@ const cpConstraintClass *cpPinJointGetClass(void); /// @private typedef struct cpPinJoint { - cpConstraint constraint; - cpVect anchr1, anchr2; - cpFloat dist; - - cpVect r1, r2; - cpVect n; - cpFloat nMass; - - cpFloat jnAcc, jnMax; - cpFloat bias; + cpConstraint constraint; + cpVect anchr1, anchr2; + cpFloat dist; + + cpVect r1, r2; + cpVect n; + cpFloat nMass; + + cpFloat jnAcc, jnMax; + cpFloat bias; } cpPinJoint; /// Allocate a pin joint. diff --git a/chipmunk/include/chipmunk/constraints/cpPivotJoint.h b/chipmunk/include/chipmunk/constraints/cpPivotJoint.h index 22c4b4843b..de2473033e 100644 --- a/chipmunk/include/chipmunk/constraints/cpPivotJoint.h +++ b/chipmunk/include/chipmunk/constraints/cpPivotJoint.h @@ -26,15 +26,15 @@ const cpConstraintClass *cpPivotJointGetClass(void); /// @private typedef struct cpPivotJoint { - cpConstraint constraint; - cpVect anchr1, anchr2; - - cpVect r1, r2; - cpVect k1, k2; - - cpVect jAcc; - cpFloat jMaxLen; - cpVect bias; + cpConstraint constraint; + cpVect anchr1, anchr2; + + cpVect r1, r2; + cpVect k1, k2; + + cpVect jAcc; + cpFloat jMaxLen; + cpVect bias; } cpPivotJoint; /// Allocate a pivot joint diff --git a/chipmunk/include/chipmunk/constraints/cpRatchetJoint.h b/chipmunk/include/chipmunk/constraints/cpRatchetJoint.h index 091b6d8950..f604f0c40f 100644 --- a/chipmunk/include/chipmunk/constraints/cpRatchetJoint.h +++ b/chipmunk/include/chipmunk/constraints/cpRatchetJoint.h @@ -26,13 +26,13 @@ const cpConstraintClass *cpRatchetJointGetClass(void); /// @private typedef struct cpRatchetJoint { - cpConstraint constraint; - cpFloat angle, phase, ratchet; - - cpFloat iSum; - - cpFloat bias; - cpFloat jAcc, jMax; + cpConstraint constraint; + cpFloat angle, phase, ratchet; + + cpFloat iSum; + + cpFloat bias; + cpFloat jAcc, jMax; } cpRatchetJoint; /// Allocate a ratchet joint. diff --git a/chipmunk/include/chipmunk/constraints/cpRotaryLimitJoint.h b/chipmunk/include/chipmunk/constraints/cpRotaryLimitJoint.h index 12728f783c..6823d2b195 100644 --- a/chipmunk/include/chipmunk/constraints/cpRotaryLimitJoint.h +++ b/chipmunk/include/chipmunk/constraints/cpRotaryLimitJoint.h @@ -26,13 +26,13 @@ const cpConstraintClass *cpRotaryLimitJointGetClass(void); /// @private typedef struct cpRotaryLimitJoint { - cpConstraint constraint; - cpFloat min, max; - - cpFloat iSum; - - cpFloat bias; - cpFloat jAcc, jMax; + cpConstraint constraint; + cpFloat min, max; + + cpFloat iSum; + + cpFloat bias; + cpFloat jAcc, jMax; } cpRotaryLimitJoint; /// Allocate a damped rotary limit joint. diff --git a/chipmunk/include/chipmunk/constraints/cpSimpleMotor.h b/chipmunk/include/chipmunk/constraints/cpSimpleMotor.h index e5cc9774bc..d954b65246 100644 --- a/chipmunk/include/chipmunk/constraints/cpSimpleMotor.h +++ b/chipmunk/include/chipmunk/constraints/cpSimpleMotor.h @@ -26,12 +26,12 @@ const cpConstraintClass *cpSimpleMotorGetClass(void); /// @private typedef struct cpSimpleMotor { - cpConstraint constraint; - cpFloat rate; - - cpFloat iSum; - - cpFloat jAcc, jMax; + cpConstraint constraint; + cpFloat rate; + + cpFloat iSum; + + cpFloat jAcc, jMax; } cpSimpleMotor; /// Allocate a simple motor. diff --git a/chipmunk/include/chipmunk/constraints/cpSlideJoint.h b/chipmunk/include/chipmunk/constraints/cpSlideJoint.h index b944bf4693..55c1ffd612 100644 --- a/chipmunk/include/chipmunk/constraints/cpSlideJoint.h +++ b/chipmunk/include/chipmunk/constraints/cpSlideJoint.h @@ -26,16 +26,16 @@ const cpConstraintClass *cpSlideJointGetClass(void); /// @private typedef struct cpSlideJoint { - cpConstraint constraint; - cpVect anchr1, anchr2; - cpFloat min, max; - - cpVect r1, r2; - cpVect n; - cpFloat nMass; - - cpFloat jnAcc, jnMax; - cpFloat bias; + cpConstraint constraint; + cpVect anchr1, anchr2; + cpFloat min, max; + + cpVect r1, r2; + cpVect n; + cpFloat nMass; + + cpFloat jnAcc, jnMax; + cpFloat bias; } cpSlideJoint; /// Allocate a slide joint. diff --git a/chipmunk/include/chipmunk/constraints/util.h b/chipmunk/include/chipmunk/constraints/util.h index 091eb3e87c..71c7ccb86c 100644 --- a/chipmunk/include/chipmunk/constraints/util.h +++ b/chipmunk/include/chipmunk/constraints/util.h @@ -31,105 +31,105 @@ void cpConstraintInit(cpConstraint *constraint, const cpConstraintClass *klass, static inline cpVect relative_velocity(cpBody *a, cpBody *b, cpVect r1, cpVect r2){ - cpVect v1_sum = cpvadd(a->v, cpvmult(cpvperp(r1), a->w)); - cpVect v2_sum = cpvadd(b->v, cpvmult(cpvperp(r2), b->w)); - - return cpvsub(v2_sum, v1_sum); + cpVect v1_sum = cpvadd(a->v, cpvmult(cpvperp(r1), a->w)); + cpVect v2_sum = cpvadd(b->v, cpvmult(cpvperp(r2), b->w)); + + return cpvsub(v2_sum, v1_sum); } static inline cpFloat normal_relative_velocity(cpBody *a, cpBody *b, cpVect r1, cpVect r2, cpVect n){ - return cpvdot(relative_velocity(a, b, r1, r2), n); + return cpvdot(relative_velocity(a, b, r1, r2), n); } static inline void apply_impulse(cpBody *body, cpVect j, cpVect r){ - body->v = cpvadd(body->v, cpvmult(j, body->m_inv)); - body->w += body->i_inv*cpvcross(r, j); + body->v = cpvadd(body->v, cpvmult(j, body->m_inv)); + body->w += body->i_inv*cpvcross(r, j); } static inline void apply_impulses(cpBody *a , cpBody *b, cpVect r1, cpVect r2, cpVect j) { - apply_impulse(a, cpvneg(j), r1); - apply_impulse(b, j, r2); + apply_impulse(a, cpvneg(j), r1); + apply_impulse(b, j, r2); } static inline void apply_bias_impulse(cpBody *body, cpVect j, cpVect r) { - body->CP_PRIVATE(v_bias) = cpvadd(body->CP_PRIVATE(v_bias), cpvmult(j, body->m_inv)); - body->CP_PRIVATE(w_bias) += body->i_inv*cpvcross(r, j); + body->CP_PRIVATE(v_bias) = cpvadd(body->CP_PRIVATE(v_bias), cpvmult(j, body->m_inv)); + body->CP_PRIVATE(w_bias) += body->i_inv*cpvcross(r, j); } static inline void apply_bias_impulses(cpBody *a , cpBody *b, cpVect r1, cpVect r2, cpVect j) { - apply_bias_impulse(a, cpvneg(j), r1); - apply_bias_impulse(b, j, r2); + apply_bias_impulse(a, cpvneg(j), r1); + apply_bias_impulse(b, j, r2); } static inline cpFloat k_scalar_body(cpBody *body, cpVect r, cpVect n) { - cpFloat rcn = cpvcross(r, n); - return body->m_inv + body->i_inv*rcn*rcn; + cpFloat rcn = cpvcross(r, n); + return body->m_inv + body->i_inv*rcn*rcn; } static inline cpFloat k_scalar(cpBody *a, cpBody *b, cpVect r1, cpVect r2, cpVect n) { - cpFloat value = k_scalar_body(a, r1, n) + k_scalar_body(b, r2, n); - cpAssertSoft(value != 0.0, "Unsolvable collision or constraint."); - - return value; + cpFloat value = k_scalar_body(a, r1, n) + k_scalar_body(b, r2, n); + cpAssertSoft(value != 0.0, "Unsolvable collision or constraint."); + + return value; } static inline void k_tensor(cpBody *a, cpBody *b, cpVect r1, cpVect r2, cpVect *k1, cpVect *k2) { - // calculate mass matrix - // If I wasn't lazy and wrote a proper matrix class, this wouldn't be so gross... - cpFloat k11, k12, k21, k22; - cpFloat m_sum = a->m_inv + b->m_inv; - - // start with I*m_sum - k11 = m_sum; k12 = 0.0f; - k21 = 0.0f; k22 = m_sum; - - // add the influence from r1 - cpFloat a_i_inv = a->i_inv; - cpFloat r1xsq = r1.x * r1.x * a_i_inv; - cpFloat r1ysq = r1.y * r1.y * a_i_inv; - cpFloat r1nxy = -r1.x * r1.y * a_i_inv; - k11 += r1ysq; k12 += r1nxy; - k21 += r1nxy; k22 += r1xsq; - - // add the influnce from r2 - cpFloat b_i_inv = b->i_inv; - cpFloat r2xsq = r2.x * r2.x * b_i_inv; - cpFloat r2ysq = r2.y * r2.y * b_i_inv; - cpFloat r2nxy = -r2.x * r2.y * b_i_inv; - k11 += r2ysq; k12 += r2nxy; - k21 += r2nxy; k22 += r2xsq; - - // invert - cpFloat determinant = k11*k22 - k12*k21; - cpAssertSoft(determinant != 0.0, "Unsolvable constraint."); - - cpFloat det_inv = 1.0f/determinant; - *k1 = cpv( k22*det_inv, -k12*det_inv); - *k2 = cpv(-k21*det_inv, k11*det_inv); + // calculate mass matrix + // If I wasn't lazy and wrote a proper matrix class, this wouldn't be so gross... + cpFloat k11, k12, k21, k22; + cpFloat m_sum = a->m_inv + b->m_inv; + + // start with I*m_sum + k11 = m_sum; k12 = 0.0f; + k21 = 0.0f; k22 = m_sum; + + // add the influence from r1 + cpFloat a_i_inv = a->i_inv; + cpFloat r1xsq = r1.x * r1.x * a_i_inv; + cpFloat r1ysq = r1.y * r1.y * a_i_inv; + cpFloat r1nxy = -r1.x * r1.y * a_i_inv; + k11 += r1ysq; k12 += r1nxy; + k21 += r1nxy; k22 += r1xsq; + + // add the influnce from r2 + cpFloat b_i_inv = b->i_inv; + cpFloat r2xsq = r2.x * r2.x * b_i_inv; + cpFloat r2ysq = r2.y * r2.y * b_i_inv; + cpFloat r2nxy = -r2.x * r2.y * b_i_inv; + k11 += r2ysq; k12 += r2nxy; + k21 += r2nxy; k22 += r2xsq; + + // invert + cpFloat determinant = k11*k22 - k12*k21; + cpAssertSoft(determinant != 0.0, "Unsolvable constraint."); + + cpFloat det_inv = 1.0f/determinant; + *k1 = cpv( k22*det_inv, -k12*det_inv); + *k2 = cpv(-k21*det_inv, k11*det_inv); } static inline cpVect mult_k(cpVect vr, cpVect k1, cpVect k2) { - return cpv(cpvdot(vr, k1), cpvdot(vr, k2)); + return cpv(cpvdot(vr, k1), cpvdot(vr, k2)); } static inline cpFloat bias_coef(cpFloat errorBias, cpFloat dt) { - return 1.0f - cpfpow(errorBias, dt); + return 1.0f - cpfpow(errorBias, dt); } diff --git a/chipmunk/include/chipmunk/cpArbiter.h b/chipmunk/include/chipmunk/cpArbiter.h index 518660e853..9a4365ee2e 100644 --- a/chipmunk/include/chipmunk/cpArbiter.h +++ b/chipmunk/include/chipmunk/cpArbiter.h @@ -39,13 +39,13 @@ typedef void (*cpCollisionSeparateFunc)(cpArbiter *arb, cpSpace *space, void *da /// @private struct cpCollisionHandler { - cpCollisionType a; - cpCollisionType b; - cpCollisionBeginFunc begin; - cpCollisionPreSolveFunc preSolve; - cpCollisionPostSolveFunc postSolve; - cpCollisionSeparateFunc separate; - void *data; + cpCollisionType a; + cpCollisionType b; + cpCollisionBeginFunc begin; + cpCollisionPreSolveFunc preSolve; + cpCollisionPostSolveFunc postSolve; + cpCollisionSeparateFunc separate; + void *data; }; typedef struct cpContact cpContact; @@ -54,50 +54,50 @@ typedef struct cpContact cpContact; /// @private typedef enum cpArbiterState { - // Arbiter is active and its the first collision. - cpArbiterStateFirstColl, - // Arbiter is active and its not the first collision. - cpArbiterStateNormal, - // Collision has been explicitly ignored. - // Either by returning false from a begin collision handler or calling cpArbiterIgnore(). - cpArbiterStateIgnore, - // Collison is no longer active. A space will cache an arbiter for up to cpSpace.collisionPersistence more steps. - cpArbiterStateCached, + // Arbiter is active and its the first collision. + cpArbiterStateFirstColl, + // Arbiter is active and its not the first collision. + cpArbiterStateNormal, + // Collision has been explicitly ignored. + // Either by returning false from a begin collision handler or calling cpArbiterIgnore(). + cpArbiterStateIgnore, + // Collison is no longer active. A space will cache an arbiter for up to cpSpace.collisionPersistence more steps. + cpArbiterStateCached, } cpArbiterState; /// @private struct cpArbiterThread { - // Links to next and previous arbiters in the contact graph. - struct cpArbiter *next, *prev; + // Links to next and previous arbiters in the contact graph. + struct cpArbiter *next, *prev; }; /// A colliding pair of shapes. struct cpArbiter { - /// Calculated value to use for the elasticity coefficient. - /// Override in a pre-solve collision handler for custom behavior. - cpFloat e; - /// Calculated value to use for the friction coefficient. - /// Override in a pre-solve collision handler for custom behavior. - cpFloat u; - /// Calculated value to use for applying surface velocities. - /// Override in a pre-solve collision handler for custom behavior. - cpVect surface_vr; - - CP_PRIVATE(cpShape *a); - CP_PRIVATE(cpShape *b); - CP_PRIVATE(cpBody *body_a); - CP_PRIVATE(cpBody *body_b); - - CP_PRIVATE(struct cpArbiterThread thread_a); - CP_PRIVATE(struct cpArbiterThread thread_b); - - CP_PRIVATE(int numContacts); - CP_PRIVATE(cpContact *contacts); - - CP_PRIVATE(cpTimestamp stamp); - CP_PRIVATE(cpCollisionHandler *handler); - CP_PRIVATE(cpBool swappedColl); - CP_PRIVATE(cpArbiterState state); + /// Calculated value to use for the elasticity coefficient. + /// Override in a pre-solve collision handler for custom behavior. + cpFloat e; + /// Calculated value to use for the friction coefficient. + /// Override in a pre-solve collision handler for custom behavior. + cpFloat u; + /// Calculated value to use for applying surface velocities. + /// Override in a pre-solve collision handler for custom behavior. + cpVect surface_vr; + + CP_PRIVATE(cpShape *a); + CP_PRIVATE(cpShape *b); + CP_PRIVATE(cpBody *body_a); + CP_PRIVATE(cpBody *body_b); + + CP_PRIVATE(struct cpArbiterThread thread_a); + CP_PRIVATE(struct cpArbiterThread thread_b); + + CP_PRIVATE(int numContacts); + CP_PRIVATE(cpContact *contacts); + + CP_PRIVATE(cpTimestamp stamp); + CP_PRIVATE(cpCollisionHandler *handler); + CP_PRIVATE(cpBool swappedColl); + CP_PRIVATE(cpArbiterState state); }; #define CP_DefineArbiterStructGetter(type, member, name) \ @@ -135,11 +135,11 @@ void cpArbiterIgnore(cpArbiter *arb); /// the order set when the collision handler was registered. static inline void cpArbiterGetShapes(const cpArbiter *arb, cpShape **a, cpShape **b) { - if(arb->CP_PRIVATE(swappedColl)){ - (*a) = arb->CP_PRIVATE(b), (*b) = arb->CP_PRIVATE(a); - } else { - (*a) = arb->CP_PRIVATE(a), (*b) = arb->CP_PRIVATE(b); - } + if(arb->CP_PRIVATE(swappedColl)){ + (*a) = arb->CP_PRIVATE(b), (*b) = arb->CP_PRIVATE(a); + } else { + (*a) = arb->CP_PRIVATE(a), (*b) = arb->CP_PRIVATE(b); + } } /// A macro shortcut for defining and retrieving the shapes from an arbiter. #define CP_ARBITER_GET_SHAPES(arb, a, b) cpShape *a, *b; cpArbiterGetShapes(arb, &a, &b); @@ -149,43 +149,35 @@ static inline void cpArbiterGetShapes(const cpArbiter *arb, cpShape **a, cpShape /// the order set when the collision handler was registered. static inline void cpArbiterGetBodies(const cpArbiter *arb, cpBody **a, cpBody **b) { - CP_ARBITER_GET_SHAPES(arb, shape_a, shape_b); - (*a) = shape_a->body; - (*b) = shape_b->body; + CP_ARBITER_GET_SHAPES(arb, shape_a, shape_b); + (*a) = shape_a->body; + (*b) = shape_b->body; } /// A macro shortcut for defining and retrieving the bodies from an arbiter. #define CP_ARBITER_GET_BODIES(arb, a, b) cpBody *a, *b; cpArbiterGetBodies(arb, &a, &b); -/// Returns true if this is the first step a pair of objects started colliding. -static inline cpBool cpArbiterIsFirstContact(const cpArbiter *arb) -{ - return arb->CP_PRIVATE(state) == cpArbiterStateFirstColl; -} - -/// Get the number of contact points for this arbiter. -static inline int cpArbiterGetCount(const cpArbiter *arb) -{ - return arb->CP_PRIVATE(numContacts); -} - /// A struct that wraps up the important collision data for an arbiter. typedef struct cpContactPointSet { - /// The number of contact points in the set. - int count; - - /// The array of contact points. - struct { - /// The position of the contact point. - cpVect point; - /// The normal of the contact point. - cpVect normal; - /// The depth of the contact point. - cpFloat dist; - } points[CP_MAX_CONTACTS_PER_ARBITER]; + /// The number of contact points in the set. + int count; + + /// The array of contact points. + struct { + /// The position of the contact point. + cpVect point; + /// The normal of the contact point. + cpVect normal; + /// The depth of the contact point. + cpFloat dist; + } points[CP_MAX_CONTACTS_PER_ARBITER]; } cpContactPointSet; /// Return a contact set from an arbiter. cpContactPointSet cpArbiterGetContactPointSet(const cpArbiter *arb); +/// Returns true if this is the first step a pair of objects started colliding. +cpBool cpArbiterIsFirstContact(const cpArbiter *arb); +/// Get the number of contact points for this arbiter. +int cpArbiterGetCount(const cpArbiter *arb); /// Get the normal of the @c ith contact point. cpVect cpArbiterGetNormal(const cpArbiter *arb, int i); /// Get the position of the @c ith contact point. diff --git a/chipmunk/include/chipmunk/cpBB.h b/chipmunk/include/chipmunk/cpBB.h index c5ab62dbf2..7f4a3ec788 100644 --- a/chipmunk/include/chipmunk/cpBB.h +++ b/chipmunk/include/chipmunk/cpBB.h @@ -25,101 +25,101 @@ /// Chipmunk's axis-aligned 2D bounding box type. (left, bottom, right, top) typedef struct cpBB{ - cpFloat l, b, r ,t; + cpFloat l, b, r ,t; } cpBB; /// Convenience constructor for cpBB structs. static inline cpBB cpBBNew(const cpFloat l, const cpFloat b, const cpFloat r, const cpFloat t) { - cpBB bb = {l, b, r, t}; - return bb; + cpBB bb = {l, b, r, t}; + return bb; } /// Constructs a cpBB for a circle with the given position and radius. static inline cpBB cpBBNewForCircle(const cpVect p, const cpFloat r) { - return cpBBNew(p.x - r, p.y - r, p.x + r, p.y + r); + return cpBBNew(p.x - r, p.y - r, p.x + r, p.y + r); } /// Returns true if @c a and @c b intersect. static inline cpBool cpBBIntersects(const cpBB a, const cpBB b) { - return (a.l <= b.r && b.l <= a.r && a.b <= b.t && b.b <= a.t); + return (a.l <= b.r && b.l <= a.r && a.b <= b.t && b.b <= a.t); } /// Returns true if @c other lies completely within @c bb. static inline cpBool cpBBContainsBB(const cpBB bb, const cpBB other) { - return (bb.l <= other.l && bb.r >= other.r && bb.b <= other.b && bb.t >= other.t); + return (bb.l <= other.l && bb.r >= other.r && bb.b <= other.b && bb.t >= other.t); } /// Returns true if @c bb contains @c v. static inline cpBool cpBBContainsVect(const cpBB bb, const cpVect v) { - return (bb.l <= v.x && bb.r >= v.x && bb.b <= v.y && bb.t >= v.y); + return (bb.l <= v.x && bb.r >= v.x && bb.b <= v.y && bb.t >= v.y); } /// Returns a bounding box that holds both bounding boxes. static inline cpBB cpBBMerge(const cpBB a, const cpBB b){ - return cpBBNew( - cpfmin(a.l, b.l), - cpfmin(a.b, b.b), - cpfmax(a.r, b.r), - cpfmax(a.t, b.t) - ); + return cpBBNew( + cpfmin(a.l, b.l), + cpfmin(a.b, b.b), + cpfmax(a.r, b.r), + cpfmax(a.t, b.t) + ); } /// Returns a bounding box that holds both @c bb and @c v. static inline cpBB cpBBExpand(const cpBB bb, const cpVect v){ - return cpBBNew( - cpfmin(bb.l, v.x), - cpfmin(bb.b, v.y), - cpfmax(bb.r, v.x), - cpfmax(bb.t, v.y) - ); + return cpBBNew( + cpfmin(bb.l, v.x), + cpfmin(bb.b, v.y), + cpfmax(bb.r, v.x), + cpfmax(bb.t, v.y) + ); } /// Returns the area of the bounding box. static inline cpFloat cpBBArea(cpBB bb) { - return (bb.r - bb.l)*(bb.t - bb.b); + return (bb.r - bb.l)*(bb.t - bb.b); } /// Merges @c a and @c b and returns the area of the merged bounding box. static inline cpFloat cpBBMergedArea(cpBB a, cpBB b) { - return (cpfmax(a.r, b.r) - cpfmin(a.l, b.l))*(cpfmax(a.t, b.t) - cpfmin(a.b, b.b)); + return (cpfmax(a.r, b.r) - cpfmin(a.l, b.l))*(cpfmax(a.t, b.t) - cpfmin(a.b, b.b)); } /// Returns the fraction along the segment query the cpBB is hit. Returns INFINITY if it doesn't hit. static inline cpFloat cpBBSegmentQuery(cpBB bb, cpVect a, cpVect b) { - cpFloat idx = 1.0f/(b.x - a.x); - cpFloat tx1 = (bb.l == a.x ? -INFINITY : (bb.l - a.x)*idx); - cpFloat tx2 = (bb.r == a.x ? INFINITY : (bb.r - a.x)*idx); - cpFloat txmin = cpfmin(tx1, tx2); - cpFloat txmax = cpfmax(tx1, tx2); - - cpFloat idy = 1.0f/(b.y - a.y); - cpFloat ty1 = (bb.b == a.y ? -INFINITY : (bb.b - a.y)*idy); - cpFloat ty2 = (bb.t == a.y ? INFINITY : (bb.t - a.y)*idy); - cpFloat tymin = cpfmin(ty1, ty2); - cpFloat tymax = cpfmax(ty1, ty2); - - if(tymin <= txmax && txmin <= tymax){ - cpFloat min = cpfmax(txmin, tymin); - cpFloat max = cpfmin(txmax, tymax); - - if(0.0 <= max && min <= 1.0) return cpfmax(min, 0.0); - } - - return INFINITY; + cpFloat idx = 1.0f/(b.x - a.x); + cpFloat tx1 = (bb.l == a.x ? -INFINITY : (bb.l - a.x)*idx); + cpFloat tx2 = (bb.r == a.x ? INFINITY : (bb.r - a.x)*idx); + cpFloat txmin = cpfmin(tx1, tx2); + cpFloat txmax = cpfmax(tx1, tx2); + + cpFloat idy = 1.0f/(b.y - a.y); + cpFloat ty1 = (bb.b == a.y ? -INFINITY : (bb.b - a.y)*idy); + cpFloat ty2 = (bb.t == a.y ? INFINITY : (bb.t - a.y)*idy); + cpFloat tymin = cpfmin(ty1, ty2); + cpFloat tymax = cpfmax(ty1, ty2); + + if(tymin <= txmax && txmin <= tymax){ + cpFloat min = cpfmax(txmin, tymin); + cpFloat max = cpfmin(txmax, tymax); + + if(0.0 <= max && min <= 1.0) return cpfmax(min, 0.0); + } + + return INFINITY; } /// Return true if the bounding box intersects the line segment with ends @c a and @c b. static inline cpBool cpBBIntersectsSegment(cpBB bb, cpVect a, cpVect b) { - return (cpBBSegmentQuery(bb, a, b) != INFINITY); + return (cpBBSegmentQuery(bb, a, b) != INFINITY); } /// Clamp a vector to a bounding box. diff --git a/chipmunk/include/chipmunk/cpBody.h b/chipmunk/include/chipmunk/cpBody.h index dfc214b265..7b57b47886 100644 --- a/chipmunk/include/chipmunk/cpBody.h +++ b/chipmunk/include/chipmunk/cpBody.h @@ -33,70 +33,70 @@ typedef void (*cpBodyPositionFunc)(cpBody *body, cpFloat dt); /// Used internally to track information on the collision graph. /// @private typedef struct cpComponentNode { - cpBody *root; - cpBody *next; - cpFloat idleTime; + cpBody *root; + cpBody *next; + cpFloat idleTime; } cpComponentNode; /// Chipmunk's rigid body struct. struct cpBody { - /// Function that is called to integrate the body's velocity. (Defaults to cpBodyUpdateVelocity) - cpBodyVelocityFunc velocity_func; - - /// Function that is called to integrate the body's position. (Defaults to cpBodyUpdatePosition) - cpBodyPositionFunc position_func; - - /// Mass of the body. - /// Must agree with cpBody.m_inv! Use cpBodySetMass() when changing the mass for this reason. - cpFloat m; - /// Mass inverse. - cpFloat m_inv; - - /// Moment of inertia of the body. - /// Must agree with cpBody.i_inv! Use cpBodySetMoment() when changing the moment for this reason. - cpFloat i; - /// Moment of inertia inverse. - cpFloat i_inv; - - /// Position of the rigid body's center of gravity. - cpVect p; - /// Velocity of the rigid body's center of gravity. - cpVect v; - /// Force acting on the rigid body's center of gravity. - cpVect f; - - /// Rotation of the body around it's center of gravity in radians. - /// Must agree with cpBody.rot! Use cpBodySetAngle() when changing the angle for this reason. - cpFloat a; - /// Angular velocity of the body around it's center of gravity in radians/second. - cpFloat w; - /// Torque applied to the body around it's center of gravity. - cpFloat t; - - /// Cached unit length vector representing the angle of the body. - /// Used for fast rotations using cpvrotate(). - cpVect rot; - - /// User definable data pointer. - /// Generally this points to your the game object class so you can access it - /// when given a cpBody reference in a callback. - cpDataPointer data; - - /// Maximum velocity allowed when updating the velocity. - cpFloat v_limit; - /// Maximum rotational rate (in radians/second) allowed when updating the angular velocity. - cpFloat w_limit; - - CP_PRIVATE(cpVect v_bias); - CP_PRIVATE(cpFloat w_bias); - - CP_PRIVATE(cpSpace *space); - - CP_PRIVATE(cpShape *shapeList); - CP_PRIVATE(cpArbiter *arbiterList); - CP_PRIVATE(cpConstraint *constraintList); - - CP_PRIVATE(cpComponentNode node); + /// Function that is called to integrate the body's velocity. (Defaults to cpBodyUpdateVelocity) + cpBodyVelocityFunc velocity_func; + + /// Function that is called to integrate the body's position. (Defaults to cpBodyUpdatePosition) + cpBodyPositionFunc position_func; + + /// Mass of the body. + /// Must agree with cpBody.m_inv! Use cpBodySetMass() when changing the mass for this reason. + cpFloat m; + /// Mass inverse. + cpFloat m_inv; + + /// Moment of inertia of the body. + /// Must agree with cpBody.i_inv! Use cpBodySetMoment() when changing the moment for this reason. + cpFloat i; + /// Moment of inertia inverse. + cpFloat i_inv; + + /// Position of the rigid body's center of gravity. + cpVect p; + /// Velocity of the rigid body's center of gravity. + cpVect v; + /// Force acting on the rigid body's center of gravity. + cpVect f; + + /// Rotation of the body around it's center of gravity in radians. + /// Must agree with cpBody.rot! Use cpBodySetAngle() when changing the angle for this reason. + cpFloat a; + /// Angular velocity of the body around it's center of gravity in radians/second. + cpFloat w; + /// Torque applied to the body around it's center of gravity. + cpFloat t; + + /// Cached unit length vector representing the angle of the body. + /// Used for fast rotations using cpvrotate(). + cpVect rot; + + /// User definable data pointer. + /// Generally this points to your the game object class so you can access it + /// when given a cpBody reference in a callback. + cpDataPointer data; + + /// Maximum velocity allowed when updating the velocity. + cpFloat v_limit; + /// Maximum rotational rate (in radians/second) allowed when updating the angular velocity. + cpFloat w_limit; + + CP_PRIVATE(cpVect v_bias); + CP_PRIVATE(cpFloat w_bias); + + CP_PRIVATE(cpSpace *space); + + CP_PRIVATE(cpShape *shapeList); + CP_PRIVATE(cpArbiter *arbiterList); + CP_PRIVATE(cpConstraint *constraintList); + + CP_PRIVATE(cpComponentNode node); }; /// Allocate a cpBody. @@ -118,10 +118,10 @@ void cpBodyFree(cpBody *body); /// Check that the properties of a body is sane. (Only in debug mode) #ifdef NDEBUG - #define cpBodyAssertSane(body) + #define cpBodyAssertSane(body) #else - void cpBodySanityCheck(cpBody *body); - #define cpBodyAssertSane(body) cpBodySanityCheck(body) + void cpBodySanityCheck(cpBody *body); + #define cpBodyAssertSane(body) cpBodySanityCheck(body) #endif // Defined in cpSpace.c @@ -138,19 +138,19 @@ void cpBodySleepWithGroup(cpBody *body, cpBody *group); /// Returns true if the body is sleeping. static inline cpBool cpBodyIsSleeping(const cpBody *body) { - return (CP_PRIVATE(body->node).root != ((cpBody*)0)); + return (CP_PRIVATE(body->node).root != ((cpBody*)0)); } /// Returns true if the body is static. static inline cpBool cpBodyIsStatic(const cpBody *body) { - return CP_PRIVATE(body->node).idleTime == INFINITY; + return CP_PRIVATE(body->node).idleTime == INFINITY; } /// Returns true if the body has not been added to a space. static inline cpBool cpBodyIsRogue(const cpBody *body) { - return (body->CP_PRIVATE(space) == ((cpSpace*)0)); + return (body->CP_PRIVATE(space) == ((cpSpace*)0)); } @@ -159,15 +159,18 @@ static inline type cpBodyGet##name(const cpBody *body){return body->member;} #define CP_DefineBodyStructSetter(type, member, name) \ static inline void cpBodySet##name(cpBody *body, const type value){ \ - cpBodyActivate(body); \ - cpBodyAssertSane(body); \ - body->member = value; \ + cpBodyActivate(body); \ + cpBodyAssertSane(body); \ + body->member = value; \ } #define CP_DefineBodyStructProperty(type, member, name) \ CP_DefineBodyStructGetter(type, member, name) \ CP_DefineBodyStructSetter(type, member, name) +// TODO add to docs +CP_DefineBodyStructGetter(cpSpace*, CP_PRIVATE(space), Space); + CP_DefineBodyStructGetter(cpFloat, m, Mass); /// Set the mass of a body. void cpBodySetMass(cpBody *body, cpFloat m); @@ -198,13 +201,13 @@ void cpBodyUpdatePosition(cpBody *body, cpFloat dt); /// Convert body relative/local coordinates to absolute/world coordinates. static inline cpVect cpBodyLocal2World(const cpBody *body, const cpVect v) { - return cpvadd(body->p, cpvrotate(v, body->rot)); + return cpvadd(body->p, cpvrotate(v, body->rot)); } /// Convert body absolute/world coordinates to relative/local coordinates. static inline cpVect cpBodyWorld2Local(const cpBody *body, const cpVect v) { - return cpvunrotate(cpvsub(v, body->p), body->rot); + return cpvunrotate(cpvsub(v, body->p), body->rot); } /// Set the forces and torque or a body to zero. @@ -223,10 +226,10 @@ cpVect cpBodyGetVelAtLocalPoint(cpBody *body, cpVect point); /// Get the kinetic energy of a body. static inline cpFloat cpBodyKineticEnergy(const cpBody *body) { - // Need to do some fudging to avoid NaNs - cpFloat vsq = cpvdot(body->v, body->v); - cpFloat wsq = body->w*body->w; - return (vsq ? vsq*body->m : 0.0f) + (wsq ? wsq*body->i : 0.0f); + // Need to do some fudging to avoid NaNs + cpFloat vsq = cpvdot(body->v, body->v); + cpFloat wsq = body->w*body->w; + return (vsq ? vsq*body->m : 0.0f) + (wsq ? wsq*body->i : 0.0f); } /// Body/shape iterator callback function type. diff --git a/chipmunk/include/chipmunk/cpPolyShape.h b/chipmunk/include/chipmunk/cpPolyShape.h index 34684ddfe4..b62b776af6 100644 --- a/chipmunk/include/chipmunk/cpPolyShape.h +++ b/chipmunk/include/chipmunk/cpPolyShape.h @@ -23,27 +23,27 @@ /// @{ /// @private -typedef struct cpPolyShapeAxis { - cpVect n; - cpFloat d; -} cpPolyShapeAxis; +typedef struct cpSplittingPlane { + cpVect n; + cpFloat d; +} cpSplittingPlane; /// @private typedef struct cpPolyShape { - cpShape shape; - - int numVerts; - cpVect *verts, *tVerts; - cpPolyShapeAxis *axes, *tAxes; + cpShape shape; + + int numVerts; + cpVect *verts, *tVerts; + cpSplittingPlane *planes, *tPlanes; } cpPolyShape; /// Allocate a polygon shape. cpPolyShape* cpPolyShapeAlloc(void); /// Initialize a polygon shape. -/// The vertexes must be convex and have a clockwise winding. +/// A convex hull will be created from the vertexes. cpPolyShape* cpPolyShapeInit(cpPolyShape *poly, cpBody *body, int numVerts, cpVect *verts, cpVect offset); /// Allocate and initialize a polygon shape. -/// The vertexes must be convex and have a clockwise winding. +/// A convex hull will be created from the vertexes. cpShape* cpPolyShapeNew(cpBody *body, int numVerts, cpVect *verts, cpVect offset); /// Initialize a box shaped polygon shape. @@ -56,6 +56,7 @@ cpShape* cpBoxShapeNew(cpBody *body, cpFloat width, cpFloat height); cpShape* cpBoxShapeNew2(cpBody *body, cpBB box); /// Check that a set of vertexes is convex and has a clockwise winding. +/// NOTE: Due to floating point precision issues, hulls created with cpQuickHull() are not guaranteed to validate! cpBool cpPolyValidate(const cpVect *verts, const int numVerts); /// Get the number of verts in a polygon shape. diff --git a/chipmunk/include/chipmunk/cpShape.h b/chipmunk/include/chipmunk/cpShape.h index 1e6fac909a..3d0900b65d 100644 --- a/chipmunk/include/chipmunk/cpShape.h +++ b/chipmunk/include/chipmunk/cpShape.h @@ -25,78 +25,88 @@ typedef struct cpShapeClass cpShapeClass; +/// Nearest point query info struct. +typedef struct cpNearestPointQueryInfo { + /// The nearest shape, NULL if no shape was within range. + cpShape *shape; + /// The closest point on the shape's surface. (in world space coordinates) + cpVect p; + /// The distance to the point. The distance is negative if the point is inside the shape. + cpFloat d; +} cpNearestPointQueryInfo; + /// Segment query info struct. typedef struct cpSegmentQueryInfo { - /// The shape that was hit, NULL if no collision occured. - cpShape *shape; - /// The normalized distance along the query segment in the range [0, 1]. - cpFloat t; - /// The normal of the surface hit. - cpVect n; + /// The shape that was hit, NULL if no collision occured. + cpShape *shape; + /// The normalized distance along the query segment in the range [0, 1]. + cpFloat t; + /// The normal of the surface hit. + cpVect n; } cpSegmentQueryInfo; /// @private typedef enum cpShapeType{ - CP_CIRCLE_SHAPE, - CP_SEGMENT_SHAPE, - CP_POLY_SHAPE, - CP_NUM_SHAPES + CP_CIRCLE_SHAPE, + CP_SEGMENT_SHAPE, + CP_POLY_SHAPE, + CP_NUM_SHAPES } cpShapeType; typedef cpBB (*cpShapeCacheDataImpl)(cpShape *shape, cpVect p, cpVect rot); typedef void (*cpShapeDestroyImpl)(cpShape *shape); -typedef cpBool (*cpShapePointQueryImpl)(cpShape *shape, cpVect p); +typedef void (*cpShapeNearestPointQueryImpl)(cpShape *shape, cpVect p, cpNearestPointQueryInfo *info); typedef void (*cpShapeSegmentQueryImpl)(cpShape *shape, cpVect a, cpVect b, cpSegmentQueryInfo *info); /// @private struct cpShapeClass { - cpShapeType type; - - cpShapeCacheDataImpl cacheData; - cpShapeDestroyImpl destroy; - cpShapePointQueryImpl pointQuery; - cpShapeSegmentQueryImpl segmentQuery; + cpShapeType type; + + cpShapeCacheDataImpl cacheData; + cpShapeDestroyImpl destroy; + cpShapeNearestPointQueryImpl nearestPointQuery; + cpShapeSegmentQueryImpl segmentQuery; }; /// Opaque collision shape struct. struct cpShape { - CP_PRIVATE(const cpShapeClass *klass); - - /// The rigid body this collision shape is attached to. - cpBody *body; + CP_PRIVATE(const cpShapeClass *klass); + + /// The rigid body this collision shape is attached to. + cpBody *body; - /// The current bounding box of the shape. - cpBB bb; - - /// Sensor flag. - /// Sensor shapes call collision callbacks but don't produce collisions. - cpBool sensor; - - /// Coefficient of restitution. (elasticity) - cpFloat e; - /// Coefficient of friction. - cpFloat u; - /// Surface velocity used when solving for friction. - cpVect surface_v; + /// The current bounding box of the shape. + cpBB bb; + + /// Sensor flag. + /// Sensor shapes call collision callbacks but don't produce collisions. + cpBool sensor; + + /// Coefficient of restitution. (elasticity) + cpFloat e; + /// Coefficient of friction. + cpFloat u; + /// Surface velocity used when solving for friction. + cpVect surface_v; - /// User definable data pointer. - /// Generally this points to your the game object class so you can access it - /// when given a cpShape reference in a callback. - cpDataPointer data; - - /// Collision type of this shape used when picking collision handlers. - cpCollisionType collision_type; - /// Group of this shape. Shapes in the same group don't collide. - cpGroup group; - // Layer bitmask for this shape. Shapes only collide if the bitwise and of their layers is non-zero. - cpLayers layers; - - CP_PRIVATE(cpSpace *space); - - CP_PRIVATE(cpShape *next); - CP_PRIVATE(cpShape *prev); - - CP_PRIVATE(cpHashValue hashid); + /// User definable data pointer. + /// Generally this points to your the game object class so you can access it + /// when given a cpShape reference in a callback. + cpDataPointer data; + + /// Collision type of this shape used when picking collision handlers. + cpCollisionType collision_type; + /// Group of this shape. Shapes in the same group don't collide. + cpGroup group; + // Layer bitmask for this shape. Shapes only collide if the bitwise and of their layers is non-zero. + cpLayers layers; + + CP_PRIVATE(cpSpace *space); + + CP_PRIVATE(cpShape *next); + CP_PRIVATE(cpShape *prev); + + CP_PRIVATE(cpHashValue hashid); }; /// Destroy a shape. @@ -112,19 +122,40 @@ cpBB cpShapeUpdate(cpShape *shape, cpVect pos, cpVect rot); /// Test if a point lies within a shape. cpBool cpShapePointQuery(cpShape *shape, cpVect p); +/// Perform a nearest point query. It finds the closest point on the surface of shape to a specific point. +/// The value returned is the distance between the points. A negative distance means the point is inside the shape. +cpFloat cpShapeNearestPointQuery(cpShape *shape, cpVect p, cpNearestPointQueryInfo *out); + +/// Perform a segment query against a shape. @c info must be a pointer to a valid cpSegmentQueryInfo structure. +cpBool cpShapeSegmentQuery(cpShape *shape, cpVect a, cpVect b, cpSegmentQueryInfo *info); + +/// Get the hit point for a segment query. +static inline cpVect cpSegmentQueryHitPoint(const cpVect start, const cpVect end, const cpSegmentQueryInfo info) +{ + return cpvlerp(start, end, info.t); +} + +/// Get the hit distance for a segment query. +static inline cpFloat cpSegmentQueryHitDist(const cpVect start, const cpVect end, const cpSegmentQueryInfo info) +{ + return cpvdist(start, end)*info.t; +} + #define CP_DefineShapeStructGetter(type, member, name) \ static inline type cpShapeGet##name(const cpShape *shape){return shape->member;} #define CP_DefineShapeStructSetter(type, member, name, activates) \ static inline void cpShapeSet##name(cpShape *shape, type value){ \ - if(activates && shape->body) cpBodyActivate(shape->body); \ - shape->member = value; \ + if(activates && shape->body) cpBodyActivate(shape->body); \ + shape->member = value; \ } #define CP_DefineShapeStructProperty(type, member, name, activates) \ CP_DefineShapeStructGetter(type, member, name) \ CP_DefineShapeStructSetter(type, member, name, activates) +CP_DefineShapeStructGetter(cpSpace*, CP_PRIVATE(space), Space); + CP_DefineShapeStructGetter(cpBody*, body, Body); void cpShapeSetBody(cpShape *shape, cpBody *body); @@ -143,21 +174,6 @@ CP_DefineShapeStructProperty(cpLayers, layers, Layers, cpTrue); /// when recreating a space. This will make the simulation be deterministic. void cpResetShapeIdCounter(void); -/// Perform a segment query against a shape. @c info must be a pointer to a valid cpSegmentQueryInfo structure. -cpBool cpShapeSegmentQuery(cpShape *shape, cpVect a, cpVect b, cpSegmentQueryInfo *info); - -/// Get the hit point for a segment query. -static inline cpVect cpSegmentQueryHitPoint(const cpVect start, const cpVect end, const cpSegmentQueryInfo info) -{ - return cpvlerp(start, end, info.t); -} - -/// Get the hit distance for a segment query. -static inline cpFloat cpSegmentQueryHitDist(const cpVect start, const cpVect end, const cpSegmentQueryInfo info) -{ - return cpvdist(start, end)*info.t; -} - #define CP_DeclareShapeGetter(struct, type, name) type struct##Get##name(const cpShape *shape) /// @} @@ -165,10 +181,10 @@ static inline cpFloat cpSegmentQueryHitDist(const cpVect start, const cpVect end /// @private typedef struct cpCircleShape { - cpShape shape; - - cpVect c, tc; - cpFloat r; + cpShape shape; + + cpVect c, tc; + cpFloat r; } cpCircleShape; /// Allocate a circle shape. @@ -186,13 +202,13 @@ CP_DeclareShapeGetter(cpCircleShape, cpFloat, Radius); /// @private typedef struct cpSegmentShape { - cpShape shape; - - cpVect a, b, n; - cpVect ta, tb, tn; - cpFloat r; - - cpVect a_tangent, b_tangent; + cpShape shape; + + cpVect a, b, n; + cpVect ta, tb, tn; + cpFloat r; + + cpVect a_tangent, b_tangent; } cpSegmentShape; /// Allocate a segment shape. diff --git a/chipmunk/include/chipmunk/cpSpace.h b/chipmunk/include/chipmunk/cpSpace.h index b2625aa4f9..ff725ac0a8 100644 --- a/chipmunk/include/chipmunk/cpSpace.h +++ b/chipmunk/include/chipmunk/cpSpace.h @@ -27,82 +27,82 @@ typedef void (*cpSpaceArbiterApplyImpulseFunc)(cpArbiter *arb); /// Basic Unit of Simulation in Chipmunk struct cpSpace { - /// Number of iterations to use in the impulse solver to solve contacts. - int iterations; - - /// Gravity to pass to rigid bodies when integrating velocity. - cpVect gravity; - - /// Damping rate expressed as the fraction of velocity bodies retain each second. - /// A value of 0.9 would mean that each body's velocity will drop 10% per second. - /// The default value is 1.0, meaning no damping is applied. - /// @note This damping value is different than those of cpDampedSpring and cpDampedRotarySpring. - cpFloat damping; - - /// Speed threshold for a body to be considered idle. - /// The default value of 0 means to let the space guess a good threshold based on gravity. - cpFloat idleSpeedThreshold; - - /// Time a group of bodies must remain idle in order to fall asleep. - /// Enabling sleeping also implicitly enables the the contact graph. - /// The default value of INFINITY disables the sleeping algorithm. - cpFloat sleepTimeThreshold; - - /// Amount of encouraged penetration between colliding shapes. - /// Used to reduce oscillating contacts and keep the collision cache warm. - /// Defaults to 0.1. If you have poor simulation quality, - /// increase this number as much as possible without allowing visible amounts of overlap. - cpFloat collisionSlop; - - /// Determines how fast overlapping shapes are pushed apart. - /// Expressed as a fraction of the error remaining after each second. - /// Defaults to pow(1.0 - 0.1, 60.0) meaning that Chipmunk fixes 10% of overlap each frame at 60Hz. - cpFloat collisionBias; - - /// Number of frames that contact information should persist. - /// Defaults to 3. There is probably never a reason to change this value. - cpTimestamp collisionPersistence; - - /// Rebuild the contact graph during each step. Must be enabled to use the cpBodyEachArbiter() function. - /// Disabled by default for a small performance boost. Enabled implicitly when the sleeping feature is enabled. - cpBool enableContactGraph; - - /// User definable data pointer. - /// Generally this points to your game's controller or game state - /// class so you can access it when given a cpSpace reference in a callback. - cpDataPointer data; - - /// The designated static body for this space. - /// You can modify this body, or replace it with your own static body. - /// By default it points to a statically allocated cpBody in the cpSpace struct. - cpBody *staticBody; - - CP_PRIVATE(cpTimestamp stamp); - CP_PRIVATE(cpFloat curr_dt); + /// Number of iterations to use in the impulse solver to solve contacts. + int iterations; + + /// Gravity to pass to rigid bodies when integrating velocity. + cpVect gravity; + + /// Damping rate expressed as the fraction of velocity bodies retain each second. + /// A value of 0.9 would mean that each body's velocity will drop 10% per second. + /// The default value is 1.0, meaning no damping is applied. + /// @note This damping value is different than those of cpDampedSpring and cpDampedRotarySpring. + cpFloat damping; + + /// Speed threshold for a body to be considered idle. + /// The default value of 0 means to let the space guess a good threshold based on gravity. + cpFloat idleSpeedThreshold; + + /// Time a group of bodies must remain idle in order to fall asleep. + /// Enabling sleeping also implicitly enables the the contact graph. + /// The default value of INFINITY disables the sleeping algorithm. + cpFloat sleepTimeThreshold; + + /// Amount of encouraged penetration between colliding shapes. + /// Used to reduce oscillating contacts and keep the collision cache warm. + /// Defaults to 0.1. If you have poor simulation quality, + /// increase this number as much as possible without allowing visible amounts of overlap. + cpFloat collisionSlop; + + /// Determines how fast overlapping shapes are pushed apart. + /// Expressed as a fraction of the error remaining after each second. + /// Defaults to pow(1.0 - 0.1, 60.0) meaning that Chipmunk fixes 10% of overlap each frame at 60Hz. + cpFloat collisionBias; + + /// Number of frames that contact information should persist. + /// Defaults to 3. There is probably never a reason to change this value. + cpTimestamp collisionPersistence; + + /// Rebuild the contact graph during each step. Must be enabled to use the cpBodyEachArbiter() function. + /// Disabled by default for a small performance boost. Enabled implicitly when the sleeping feature is enabled. + cpBool enableContactGraph; + + /// User definable data pointer. + /// Generally this points to your game's controller or game state + /// class so you can access it when given a cpSpace reference in a callback. + cpDataPointer data; + + /// The designated static body for this space. + /// You can modify this body, or replace it with your own static body. + /// By default it points to a statically allocated cpBody in the cpSpace struct. + cpBody *staticBody; + + CP_PRIVATE(cpTimestamp stamp); + CP_PRIVATE(cpFloat curr_dt); - CP_PRIVATE(cpArray *bodies); - CP_PRIVATE(cpArray *rousedBodies); - CP_PRIVATE(cpArray *sleepingComponents); - - CP_PRIVATE(cpSpatialIndex *staticShapes); - CP_PRIVATE(cpSpatialIndex *activeShapes); - - CP_PRIVATE(cpArray *arbiters); - CP_PRIVATE(cpContactBufferHeader *contactBuffersHead); - CP_PRIVATE(cpHashSet *cachedArbiters); - CP_PRIVATE(cpArray *pooledArbiters); - CP_PRIVATE(cpArray *constraints); - - CP_PRIVATE(cpArray *allocatedBuffers); - CP_PRIVATE(int locked); - - CP_PRIVATE(cpHashSet *collisionHandlers); - CP_PRIVATE(cpCollisionHandler defaultHandler); - CP_PRIVATE(cpHashSet *postStepCallbacks); - - CP_PRIVATE(cpSpaceArbiterApplyImpulseFunc arbiterApplyImpulse); - - CP_PRIVATE(cpBody _staticBody); + CP_PRIVATE(cpArray *bodies); + CP_PRIVATE(cpArray *rousedBodies); + CP_PRIVATE(cpArray *sleepingComponents); + + CP_PRIVATE(cpSpatialIndex *staticShapes); + CP_PRIVATE(cpSpatialIndex *activeShapes); + + CP_PRIVATE(cpArray *arbiters); + CP_PRIVATE(cpContactBufferHeader *contactBuffersHead); + CP_PRIVATE(cpHashSet *cachedArbiters); + CP_PRIVATE(cpArray *pooledArbiters); + CP_PRIVATE(cpArray *constraints); + + CP_PRIVATE(cpArray *allocatedBuffers); + CP_PRIVATE(int locked); + + CP_PRIVATE(cpHashSet *collisionHandlers); + CP_PRIVATE(cpCollisionHandler defaultHandler); + + CP_PRIVATE(cpBool skipPostStep); + CP_PRIVATE(cpArray *postStepCallbacks); + + CP_PRIVATE(cpBody _staticBody); }; /// Allocate a cpSpace. @@ -144,7 +144,7 @@ CP_DefineSpaceStructGetter(cpFloat, CP_PRIVATE(curr_dt), CurrentTimeStep); static inline cpBool cpSpaceIsLocked(cpSpace *space) { - return space->CP_PRIVATE(locked); + return space->CP_PRIVATE(locked); } /// Set a default collision handler for this space. @@ -152,24 +152,24 @@ cpSpaceIsLocked(cpSpace *space) /// that isn't explicitly handled by a specific collision handler. /// You can pass NULL for any function you don't want to implement. void cpSpaceSetDefaultCollisionHandler( - cpSpace *space, - cpCollisionBeginFunc begin, - cpCollisionPreSolveFunc preSolve, - cpCollisionPostSolveFunc postSolve, - cpCollisionSeparateFunc separate, - void *data + cpSpace *space, + cpCollisionBeginFunc begin, + cpCollisionPreSolveFunc preSolve, + cpCollisionPostSolveFunc postSolve, + cpCollisionSeparateFunc separate, + void *data ); /// Set a collision handler to be used whenever the two shapes with the given collision types collide. /// You can pass NULL for any function you don't want to implement. void cpSpaceAddCollisionHandler( - cpSpace *space, - cpCollisionType a, cpCollisionType b, - cpCollisionBeginFunc begin, - cpCollisionPreSolveFunc preSolve, - cpCollisionPostSolveFunc postSolve, - cpCollisionSeparateFunc separate, - void *data + cpSpace *space, + cpCollisionType a, cpCollisionType b, + cpCollisionBeginFunc begin, + cpCollisionPreSolveFunc preSolve, + cpCollisionPostSolveFunc postSolve, + cpCollisionSeparateFunc separate, + void *data ); /// Unset a collision handler. @@ -204,8 +204,8 @@ cpBool cpSpaceContainsConstraint(cpSpace *space, cpConstraint *constraint); /// Post Step callback function type. typedef void (*cpPostStepFunc)(cpSpace *space, void *obj, void *data); /// Schedule a post-step callback to be called when cpSpaceStep() finishes. -/// @c obj is used a key, you can only register one callback per unique value for @c obj -void cpSpaceAddPostStepCallback(cpSpace *space, cpPostStepFunc func, void *obj, void *data); +/// You can only register one callback per unique value for @c key. +void cpSpaceAddPostStepCallback(cpSpace *space, cpPostStepFunc func, void *key, void *data); /// Point query callback function type. typedef void (*cpSpacePointQueryFunc)(cpShape *shape, void *data); @@ -214,6 +214,13 @@ void cpSpacePointQuery(cpSpace *space, cpVect point, cpLayers layers, cpGroup gr /// Query the space at a point and return the first shape found. Returns NULL if no shapes were found. cpShape *cpSpacePointQueryFirst(cpSpace *space, cpVect point, cpLayers layers, cpGroup group); +/// Nearest point query callback function type. +typedef void (*cpSpaceNearestPointQueryFunc)(cpShape *shape, cpFloat distance, cpVect point, void *data); +/// Query the space at a point and call @c func for each shape found. +void cpSpaceNearestPointQuery(cpSpace *space, cpVect point, cpFloat maxDistance, cpLayers layers, cpGroup group, cpSpaceNearestPointQueryFunc func, void *data); +/// Query the space at a point and return the nearest shape found. Returns NULL if no shapes were found. +cpShape *cpSpaceNearestPointQueryNearest(cpSpace *space, cpVect point, cpFloat maxDistance, cpLayers layers, cpGroup group, cpNearestPointQueryInfo *out); + /// Segment query callback function type. typedef void (*cpSpaceSegmentQueryFunc)(cpShape *shape, cpFloat t, cpVect n, void *data); /// Perform a directed line segment query (like a raycast) against the space calling @c func for each shape intersected. diff --git a/chipmunk/include/chipmunk/cpSpatialIndex.h b/chipmunk/include/chipmunk/cpSpatialIndex.h index 06f768cde7..bf3d0da397 100644 --- a/chipmunk/include/chipmunk/cpSpatialIndex.h +++ b/chipmunk/include/chipmunk/cpSpatialIndex.h @@ -20,21 +20,21 @@ */ /** - @defgroup cpSpatialIndex cpSpatialIndex - - Spatial indexes are data structures that are used to accelerate collision detection - and spatial queries. Chipmunk provides a number of spatial index algorithms to pick from - and they are programmed in a generic way so that you can use them for holding more than - just cpShape structs. - - It works by using @c void pointers to the objects you add and using a callback to ask your code - for bounding boxes when it needs them. Several types of queries can be performed an index as well - as reindexing and full collision information. All communication to the spatial indexes is performed - through callback functions. - - Spatial indexes should be treated as opaque structs. - This meanns you shouldn't be reading any of the struct fields. - @{ + @defgroup cpSpatialIndex cpSpatialIndex + + Spatial indexes are data structures that are used to accelerate collision detection + and spatial queries. Chipmunk provides a number of spatial index algorithms to pick from + and they are programmed in a generic way so that you can use them for holding more than + just cpShape structs. + + It works by using @c void pointers to the objects you add and using a callback to ask your code + for bounding boxes when it needs them. Several types of queries can be performed an index as well + as reindexing and full collision information. All communication to the spatial indexes is performed + through callback functions. + + Spatial indexes should be treated as opaque structs. + This meanns you shouldn't be reading any of the struct fields. + @{ */ //MARK: Spatial Index @@ -56,11 +56,11 @@ typedef struct cpSpatialIndex cpSpatialIndex; /// @private struct cpSpatialIndex { - cpSpatialIndexClass *klass; - - cpSpatialIndexBBFunc bbfunc; - - cpSpatialIndex *staticIndex, *dynamicIndex; + cpSpatialIndexClass *klass; + + cpSpatialIndexBBFunc bbfunc; + + cpSpatialIndex *staticIndex, *dynamicIndex; }; @@ -127,27 +127,25 @@ typedef void (*cpSpatialIndexReindexImpl)(cpSpatialIndex *index); typedef void (*cpSpatialIndexReindexObjectImpl)(cpSpatialIndex *index, void *obj, cpHashValue hashid); typedef void (*cpSpatialIndexReindexQueryImpl)(cpSpatialIndex *index, cpSpatialIndexQueryFunc func, void *data); -typedef void (*cpSpatialIndexPointQueryImpl)(cpSpatialIndex *index, cpVect point, cpSpatialIndexQueryFunc func, void *data); -typedef void (*cpSpatialIndexSegmentQueryImpl)(cpSpatialIndex *index, void *obj, cpVect a, cpVect b, cpFloat t_exit, cpSpatialIndexSegmentQueryFunc func, void *data); typedef void (*cpSpatialIndexQueryImpl)(cpSpatialIndex *index, void *obj, cpBB bb, cpSpatialIndexQueryFunc func, void *data); +typedef void (*cpSpatialIndexSegmentQueryImpl)(cpSpatialIndex *index, void *obj, cpVect a, cpVect b, cpFloat t_exit, cpSpatialIndexSegmentQueryFunc func, void *data); struct cpSpatialIndexClass { - cpSpatialIndexDestroyImpl destroy; - - cpSpatialIndexCountImpl count; - cpSpatialIndexEachImpl each; - - cpSpatialIndexContainsImpl contains; - cpSpatialIndexInsertImpl insert; - cpSpatialIndexRemoveImpl remove; - - cpSpatialIndexReindexImpl reindex; - cpSpatialIndexReindexObjectImpl reindexObject; - cpSpatialIndexReindexQueryImpl reindexQuery; - - cpSpatialIndexPointQueryImpl pointQuery; - cpSpatialIndexSegmentQueryImpl segmentQuery; - cpSpatialIndexQueryImpl query; + cpSpatialIndexDestroyImpl destroy; + + cpSpatialIndexCountImpl count; + cpSpatialIndexEachImpl each; + + cpSpatialIndexContainsImpl contains; + cpSpatialIndexInsertImpl insert; + cpSpatialIndexRemoveImpl remove; + + cpSpatialIndexReindexImpl reindex; + cpSpatialIndexReindexObjectImpl reindexObject; + cpSpatialIndexReindexQueryImpl reindexQuery; + + cpSpatialIndexQueryImpl query; + cpSpatialIndexSegmentQueryImpl segmentQuery; }; /// Destroy and free a spatial index. @@ -158,71 +156,64 @@ void cpSpatialIndexCollideStatic(cpSpatialIndex *dynamicIndex, cpSpatialIndex *s /// Destroy a spatial index. static inline void cpSpatialIndexDestroy(cpSpatialIndex *index) { - if(index->klass) index->klass->destroy(index); + if(index->klass) index->klass->destroy(index); } /// Get the number of objects in the spatial index. static inline int cpSpatialIndexCount(cpSpatialIndex *index) { - return index->klass->count(index); + return index->klass->count(index); } /// Iterate the objects in the spatial index. @c func will be called once for each object. static inline void cpSpatialIndexEach(cpSpatialIndex *index, cpSpatialIndexIteratorFunc func, void *data) { - index->klass->each(index, func, data); + index->klass->each(index, func, data); } /// Returns true if the spatial index contains the given object. /// Most spatial indexes use hashed storage, so you must provide a hash value too. static inline cpBool cpSpatialIndexContains(cpSpatialIndex *index, void *obj, cpHashValue hashid) { - return index->klass->contains(index, obj, hashid); + return index->klass->contains(index, obj, hashid); } /// Add an object to a spatial index. /// Most spatial indexes use hashed storage, so you must provide a hash value too. static inline void cpSpatialIndexInsert(cpSpatialIndex *index, void *obj, cpHashValue hashid) { - index->klass->insert(index, obj, hashid); + index->klass->insert(index, obj, hashid); } /// Remove an object from a spatial index. /// Most spatial indexes use hashed storage, so you must provide a hash value too. static inline void cpSpatialIndexRemove(cpSpatialIndex *index, void *obj, cpHashValue hashid) { - index->klass->remove(index, obj, hashid); + index->klass->remove(index, obj, hashid); } /// Perform a full reindex of a spatial index. static inline void cpSpatialIndexReindex(cpSpatialIndex *index) { - index->klass->reindex(index); + index->klass->reindex(index); } /// Reindex a single object in the spatial index. static inline void cpSpatialIndexReindexObject(cpSpatialIndex *index, void *obj, cpHashValue hashid) { - index->klass->reindexObject(index, obj, hashid); -} - -/// Perform a point query against the spatial index, calling @c func for each potential match. -/// A pointer to the point will be passed as @c obj1 of @c func. -static inline void cpSpatialIndexPointQuery(cpSpatialIndex *index, cpVect point, cpSpatialIndexQueryFunc func, void *data) -{ - index->klass->pointQuery(index, point, func, data); -} - -/// Perform a segment query against the spatial index, calling @c func for each potential match. -static inline void cpSpatialIndexSegmentQuery(cpSpatialIndex *index, void *obj, cpVect a, cpVect b, cpFloat t_exit, cpSpatialIndexSegmentQueryFunc func, void *data) -{ - index->klass->segmentQuery(index, obj, a, b, t_exit, func, data); + index->klass->reindexObject(index, obj, hashid); } /// Perform a rectangle query against the spatial index, calling @c func for each potential match. static inline void cpSpatialIndexQuery(cpSpatialIndex *index, void *obj, cpBB bb, cpSpatialIndexQueryFunc func, void *data) { - index->klass->query(index, obj, bb, func, data); + index->klass->query(index, obj, bb, func, data); +} + +/// Perform a segment query against the spatial index, calling @c func for each potential match. +static inline void cpSpatialIndexSegmentQuery(cpSpatialIndex *index, void *obj, cpVect a, cpVect b, cpFloat t_exit, cpSpatialIndexSegmentQueryFunc func, void *data) +{ + index->klass->segmentQuery(index, obj, a, b, t_exit, func, data); } /// Simultaneously reindex and find all colliding objects. @@ -230,7 +221,7 @@ static inline void cpSpatialIndexQuery(cpSpatialIndex *index, void *obj, cpBB bb /// If the spatial index was initialized with a static index, it will collide it's objects against that as well. static inline void cpSpatialIndexReindexQuery(cpSpatialIndex *index, cpSpatialIndexQueryFunc func, void *data) { - index->klass->reindexQuery(index, func, data); + index->klass->reindexQuery(index, func, data); } ///@} diff --git a/chipmunk/include/chipmunk/cpVect.h b/chipmunk/include/chipmunk/cpVect.h index 9e8326ba3e..8f866d9097 100644 --- a/chipmunk/include/chipmunk/cpVect.h +++ b/chipmunk/include/chipmunk/cpVect.h @@ -29,8 +29,8 @@ static const cpVect cpvzero = {0.0f,0.0f}; /// Convenience constructor for cpVect structs. static inline cpVect cpv(const cpFloat x, const cpFloat y) { - cpVect v = {x, y}; - return v; + cpVect v = {x, y}; + return v; } /// Returns the length of v. @@ -48,45 +48,45 @@ cpVect cpvforangle(const cpFloat a); /// Returns the angular direction v is pointing in (in radians). cpFloat cpvtoangle(const cpVect v); -/// Returns a string representation of v. Intended mostly for debugging purposes and not production use. -/// @attention The string points to a static local and is reset every time the function is called. -/// If you want to print more than one vector you will have to split up your printing onto separate lines. +/// Returns a string representation of v. Intended mostly for debugging purposes and not production use. +/// @attention The string points to a static local and is reset every time the function is called. +/// If you want to print more than one vector you will have to split up your printing onto separate lines. char* cpvstr(const cpVect v); /// Check if two vectors are equal. (Be careful when comparing floating point numbers!) static inline cpBool cpveql(const cpVect v1, const cpVect v2) { - return (v1.x == v2.x && v1.y == v2.y); + return (v1.x == v2.x && v1.y == v2.y); } /// Add two vectors static inline cpVect cpvadd(const cpVect v1, const cpVect v2) { - return cpv(v1.x + v2.x, v1.y + v2.y); + return cpv(v1.x + v2.x, v1.y + v2.y); } /// Subtract two vectors. static inline cpVect cpvsub(const cpVect v1, const cpVect v2) { - return cpv(v1.x - v2.x, v1.y - v2.y); + return cpv(v1.x - v2.x, v1.y - v2.y); } /// Negate a vector. static inline cpVect cpvneg(const cpVect v) { - return cpv(-v.x, -v.y); + return cpv(-v.x, -v.y); } /// Scalar multiplication. static inline cpVect cpvmult(const cpVect v, const cpFloat s) { - return cpv(v.x*s, v.y*s); + return cpv(v.x*s, v.y*s); } /// Vector dot product. static inline cpFloat cpvdot(const cpVect v1, const cpVect v2) { - return v1.x*v2.x + v1.y*v2.y; + return v1.x*v2.x + v1.y*v2.y; } /// 2D vector cross product analog. @@ -94,90 +94,90 @@ static inline cpFloat cpvdot(const cpVect v1, const cpVect v2) /// This function returns the magnitude of the z value. static inline cpFloat cpvcross(const cpVect v1, const cpVect v2) { - return v1.x*v2.y - v1.y*v2.x; + return v1.x*v2.y - v1.y*v2.x; } /// Returns a perpendicular vector. (90 degree rotation) static inline cpVect cpvperp(const cpVect v) { - return cpv(-v.y, v.x); + return cpv(-v.y, v.x); } /// Returns a perpendicular vector. (-90 degree rotation) static inline cpVect cpvrperp(const cpVect v) { - return cpv(v.y, -v.x); + return cpv(v.y, -v.x); } /// Returns the vector projection of v1 onto v2. static inline cpVect cpvproject(const cpVect v1, const cpVect v2) { - return cpvmult(v2, cpvdot(v1, v2)/cpvdot(v2, v2)); + return cpvmult(v2, cpvdot(v1, v2)/cpvdot(v2, v2)); } /// Uses complex number multiplication to rotate v1 by v2. Scaling will occur if v1 is not a unit vector. static inline cpVect cpvrotate(const cpVect v1, const cpVect v2) { - return cpv(v1.x*v2.x - v1.y*v2.y, v1.x*v2.y + v1.y*v2.x); + return cpv(v1.x*v2.x - v1.y*v2.y, v1.x*v2.y + v1.y*v2.x); } /// Inverse of cpvrotate(). static inline cpVect cpvunrotate(const cpVect v1, const cpVect v2) { - return cpv(v1.x*v2.x + v1.y*v2.y, v1.y*v2.x - v1.x*v2.y); + return cpv(v1.x*v2.x + v1.y*v2.y, v1.y*v2.x - v1.x*v2.y); } /// Returns the squared length of v. Faster than cpvlength() when you only need to compare lengths. static inline cpFloat cpvlengthsq(const cpVect v) { - return cpvdot(v, v); + return cpvdot(v, v); } /// Linearly interpolate between v1 and v2. static inline cpVect cpvlerp(const cpVect v1, const cpVect v2, const cpFloat t) { - return cpvadd(cpvmult(v1, 1.0f - t), cpvmult(v2, t)); + return cpvadd(cpvmult(v1, 1.0f - t), cpvmult(v2, t)); } /// Returns a normalized copy of v. static inline cpVect cpvnormalize(const cpVect v) { - return cpvmult(v, 1.0f/cpvlength(v)); + return cpvmult(v, 1.0f/cpvlength(v)); } /// Returns a normalized copy of v or cpvzero if v was already cpvzero. Protects against divide by zero errors. static inline cpVect cpvnormalize_safe(const cpVect v) { - return (v.x == 0.0f && v.y == 0.0f ? cpvzero : cpvnormalize(v)); + return (v.x == 0.0f && v.y == 0.0f ? cpvzero : cpvnormalize(v)); } /// Clamp v to length len. static inline cpVect cpvclamp(const cpVect v, const cpFloat len) { - return (cpvdot(v,v) > len*len) ? cpvmult(cpvnormalize(v), len) : v; + return (cpvdot(v,v) > len*len) ? cpvmult(cpvnormalize(v), len) : v; } /// Linearly interpolate between v1 towards v2 by distance d. static inline cpVect cpvlerpconst(cpVect v1, cpVect v2, cpFloat d) { - return cpvadd(v1, cpvclamp(cpvsub(v2, v1), d)); + return cpvadd(v1, cpvclamp(cpvsub(v2, v1), d)); } /// Returns the distance between v1 and v2. static inline cpFloat cpvdist(const cpVect v1, const cpVect v2) { - return cpvlength(cpvsub(v1, v2)); + return cpvlength(cpvsub(v1, v2)); } /// Returns the squared distance between v1 and v2. Faster than cpvdist() when you only need to compare distances. static inline cpFloat cpvdistsq(const cpVect v1, const cpVect v2) { - return cpvlengthsq(cpvsub(v1, v2)); + return cpvlengthsq(cpvsub(v1, v2)); } /// Returns true if the distance between v1 and v2 is less than dist. static inline cpBool cpvnear(const cpVect v1, const cpVect v2, const cpFloat dist) { - return cpvdistsq(v1, v2) < dist*dist; + return cpvdistsq(v1, v2) < dist*dist; } /// @} diff --git a/chipmunk/src/CMakeLists.txt b/chipmunk/src/CMakeLists.txt index 4f52ec60d8..c865219e62 100644 --- a/chipmunk/src/CMakeLists.txt +++ b/chipmunk/src/CMakeLists.txt @@ -9,7 +9,7 @@ if(BUILD_SHARED) ${chipmunk_source_files} ) # set the lib's version number - set_target_properties(chipmunk PROPERTIES VERSION 6.0.3) + set_target_properties(chipmunk PROPERTIES VERSION 6.1.1) install(TARGETS chipmunk RUNTIME DESTINATION lib LIBRARY DESTINATION lib) endif(BUILD_SHARED) diff --git a/chipmunk/src/chipmunk.c b/chipmunk/src/chipmunk.c index 67f7e0dcc4..8487dd0b7f 100644 --- a/chipmunk/src/chipmunk.c +++ b/chipmunk/src/chipmunk.c @@ -19,36 +19,27 @@ * SOFTWARE. */ -#include #include -#include +#include #include #include "chipmunk_private.h" -//#ifdef __cplusplus -//extern "C" { -//#endif -// void cpInitCollisionFuncs(void); -//#ifdef __cplusplus -//} -//#endif - void cpMessage(const char *condition, const char *file, int line, cpBool isError, cpBool isHardError, const char *message, ...) { - fprintf(stderr, (isError ? "Aborting due to Chipmunk error: " : "Chipmunk warning: ")); - - va_list vargs; - va_start(vargs, message); { - vfprintf(stderr, message, vargs); - fprintf(stderr, "\n"); - } va_end(vargs); - - fprintf(stderr, "\tFailed condition: %s\n", condition); - fprintf(stderr, "\tSource:%s:%d\n", file, line); - - if(isHardError) abort(); + fprintf(stderr, (isError ? "Aborting due to Chipmunk error: " : "Chipmunk warning: ")); + + va_list vargs; + va_start(vargs, message); { + vfprintf(stderr, message, vargs); + fprintf(stderr, "\n"); + } va_end(vargs); + + fprintf(stderr, "\tFailed condition: %s\n", condition); + fprintf(stderr, "\tSource:%s:%d\n", file, line); + + if(isError) abort(); } #define STR(s) #s @@ -59,112 +50,273 @@ const char *cpVersionString = XSTR(CP_VERSION_MAJOR)"."XSTR(CP_VERSION_MINOR)"." void cpInitChipmunk(void) { -//#ifndef NDEBUG -// printf("Initializing Chipmunk v%s (Debug Enabled)\n", cpVersionString); -// printf("Compile with -DNDEBUG defined to disable debug mode and runtime assertion checks\n"); -//#endif -// -// cpInitCollisionFuncs(); + cpAssertWarn(cpFalse, "cpInitChipmunk is deprecated and no longer required. It will be removed in the future."); } +//MARK: Misc Functions + cpFloat cpMomentForCircle(cpFloat m, cpFloat r1, cpFloat r2, cpVect offset) { - return m*(0.5f*(r1*r1 + r2*r2) + cpvlengthsq(offset)); + return m*(0.5f*(r1*r1 + r2*r2) + cpvlengthsq(offset)); } cpFloat cpAreaForCircle(cpFloat r1, cpFloat r2) { - return (cpFloat)M_PI*cpfabs(r1*r1 - r2*r2); + return (cpFloat)M_PI*cpfabs(r1*r1 - r2*r2); } cpFloat cpMomentForSegment(cpFloat m, cpVect a, cpVect b) { - cpFloat length = cpvlength(cpvsub(b, a)); - cpVect offset = cpvmult(cpvadd(a, b), 1.0f/2.0f); - - return m*(length*length/12.0f + cpvlengthsq(offset)); + cpVect offset = cpvmult(cpvadd(a, b), 0.5f); + return m*(cpvdistsq(b, a)/12.0f + cpvlengthsq(offset)); } cpFloat cpAreaForSegment(cpVect a, cpVect b, cpFloat r) { - return r*((cpFloat)M_PI*r + 2.0f*cpvdist(a, b)); + return r*((cpFloat)M_PI*r + 2.0f*cpvdist(a, b)); } cpFloat cpMomentForPoly(cpFloat m, const int numVerts, const cpVect *verts, cpVect offset) { - cpFloat sum1 = 0.0f; - cpFloat sum2 = 0.0f; - for(int i=0; i max.x || (v.x == max.x && v.y > max.y)){ + max = v; + (*end) = i; + } + } +} + +#define SWAP(__A__, __B__) {cpVect __TMP__ = __A__; __A__ = __B__; __B__ = __TMP__;} + +static int +QHullPartition(cpVect *verts, int count, cpVect a, cpVect b, cpFloat tol) +{ + if(count == 0) return 0; + + cpFloat max = 0; + int pivot = 0; + + cpVect delta = cpvsub(b, a); + cpFloat valueTol = tol*cpvlength(delta); + + int head = 0; + for(int tail = count-1; head <= tail;){ + cpFloat value = cpvcross(delta, cpvsub(verts[head], a)); + if(value > valueTol){ + if(value > max){ + max = value; + pivot = head; + } + + head++; + } else { + SWAP(verts[head], verts[tail]); + tail--; + } + } + + // move the new pivot to the front if it's not already there. + if(pivot != 0) SWAP(verts[0], verts[pivot]); + return head; +} + +static int +QHullReduce(cpFloat tol, cpVect *verts, int count, cpVect a, cpVect pivot, cpVect b, cpVect *result) +{ + if(count < 0){ + return 0; + } else if(count == 0) { + result[0] = pivot; + return 1; + } else { + int left_count = QHullPartition(verts, count, a, pivot, tol); + int index = QHullReduce(tol, verts + 1, left_count - 1, a, verts[0], pivot, result); + + result[index++] = pivot; + + int right_count = QHullPartition(verts + left_count, count - left_count, pivot, b, tol); + return index + QHullReduce(tol, verts + left_count + 1, right_count - 1, pivot, verts[left_count], b, result + index); + } +} + +// QuickHull seemed like a neat algorithm, and efficient-ish for large input sets. +// My implementation performs an in place reduction using the result array as scratch space. +int +cpConvexHull(int count, cpVect *verts, cpVect *result, int *first, cpFloat tol) +{ + if(result){ + // Copy the line vertexes into the empty part of the result polyline to use as a scratch buffer. + memcpy(result, verts, count*sizeof(cpVect)); + } else { + // If a result array was not specified, reduce the input instead. + result = verts; + } + + // Degenerate case, all poins are the same. + int start, end; + cpLoopIndexes(verts, count, &start, &end); + if(start == end){ + if(first) (*first) = 0; + return 1; + } + + SWAP(result[0], result[start]); + SWAP(result[1], result[end == 0 ? start : end]); + + cpVect a = result[0]; + cpVect b = result[1]; + + if(first) (*first) = start; + int resultCount = QHullReduce(tol, result + 2, count - 2, a, b, a, result + 1) + 1; + cpAssertSoft(cpPolyValidate(result, resultCount), + "Internal error: cpConvexHull() and cpPolyValidate() did not agree." + "Please report this error with as much info as you can."); + return resultCount; +} + +//MARK: Alternate Block Iterators + +#if defined(__has_extension) +#if __has_extension(blocks) + +static void IteratorFunc(void *ptr, void (^block)(void *ptr)){block(ptr);} + +void cpSpaceEachBody_b(cpSpace *space, void (^block)(cpBody *body)){ + cpSpaceEachBody(space, (cpSpaceBodyIteratorFunc)IteratorFunc, block); +} + +void cpSpaceEachShape_b(cpSpace *space, void (^block)(cpShape *shape)){ + cpSpaceEachShape(space, (cpSpaceShapeIteratorFunc)IteratorFunc, block); +} + +void cpSpaceEachConstraint_b(cpSpace *space, void (^block)(cpConstraint *constraint)){ + cpSpaceEachConstraint(space, (cpSpaceConstraintIteratorFunc)IteratorFunc, block); +} + +static void BodyIteratorFunc(cpBody *body, void *ptr, void (^block)(void *ptr)){block(ptr);} + +void cpBodyEachShape_b(cpBody *body, void (^block)(cpShape *shape)){ + cpBodyEachShape(body, (cpBodyShapeIteratorFunc)BodyIteratorFunc, block); +} + +void cpBodyEachConstraint_b(cpBody *body, void (^block)(cpConstraint *constraint)){ + cpBodyEachConstraint(body, (cpBodyConstraintIteratorFunc)BodyIteratorFunc, block); +} + +void cpBodyEachArbiter_b(cpBody *body, void (^block)(cpArbiter *arbiter)){ + cpBodyEachArbiter(body, (cpBodyArbiterIteratorFunc)BodyIteratorFunc, block); +} + +static void NearestPointQueryIteratorFunc(cpShape *shape, cpFloat distance, cpVect point, cpSpaceNearestPointQueryBlock block){block(shape, distance, point);} +void cpSpaceNearestPointQuery_b(cpSpace *space, cpVect point, cpFloat maxDistance, cpLayers layers, cpGroup group, cpSpaceNearestPointQueryBlock block){ + cpSpaceNearestPointQuery(space, point, maxDistance, layers, group, (cpSpaceNearestPointQueryFunc)NearestPointQueryIteratorFunc, block); +} + +static void SegmentQueryIteratorFunc(cpShape *shape, cpFloat t, cpVect n, cpSpaceSegmentQueryBlock block){block(shape, t, n);} +void cpSpaceSegmentQuery_b(cpSpace *space, cpVect start, cpVect end, cpLayers layers, cpGroup group, cpSpaceSegmentQueryBlock block){ + cpSpaceSegmentQuery(space, start, end, layers, group, (cpSpaceSegmentQueryFunc)SegmentQueryIteratorFunc, block); +} + +void cpSpaceBBQuery_b(cpSpace *space, cpBB bb, cpLayers layers, cpGroup group, cpSpaceBBQueryBlock block){ + cpSpaceBBQuery(space, bb, layers, group, (cpSpaceBBQueryFunc)IteratorFunc, block); +} + +static void ShapeQueryIteratorFunc(cpShape *shape, cpContactPointSet *points, cpSpaceShapeQueryBlock block){block(shape, points);} +cpBool cpSpaceShapeQuery_b(cpSpace *space, cpShape *shape, cpSpaceShapeQueryBlock block){ + return cpSpaceShapeQuery(space, shape, (cpSpaceShapeQueryFunc)ShapeQueryIteratorFunc, block); +} + +#endif +#endif + #include "chipmunk_ffi.h" diff --git a/chipmunk/src/constraints/cpConstraint.c b/chipmunk/src/constraints/cpConstraint.c index 6b1349c136..d3902f46fe 100644 --- a/chipmunk/src/constraints/cpConstraint.c +++ b/chipmunk/src/constraints/cpConstraint.c @@ -19,9 +19,6 @@ * SOFTWARE. */ -#include -#include - #include "chipmunk_private.h" #include "constraints/util.h" @@ -32,10 +29,10 @@ void cpConstraintDestroy(cpConstraint *constraint){} void cpConstraintFree(cpConstraint *constraint) { - if(constraint){ - cpConstraintDestroy(constraint); - cpfree(constraint); - } + if(constraint){ + cpConstraintDestroy(constraint); + cpfree(constraint); + } } // *** declared in util.h TODO move declaration to chipmunk_private.h @@ -43,18 +40,19 @@ cpConstraintFree(cpConstraint *constraint) void cpConstraintInit(cpConstraint *constraint, const cpConstraintClass *klass, cpBody *a, cpBody *b) { - constraint->klass = klass; - - constraint->a = a; - constraint->b = b; - - constraint->next_a = NULL; - constraint->next_b = NULL; - - constraint->maxForce = (cpFloat)INFINITY; - constraint->errorBias = cpfpow(1.0f - 0.1f, 60.0f); - constraint->maxBias = (cpFloat)INFINITY; - - constraint->preSolve = NULL; - constraint->postSolve = NULL; + constraint->klass = klass; + + constraint->a = a; + constraint->b = b; + constraint->space = NULL; + + constraint->next_a = NULL; + constraint->next_b = NULL; + + constraint->maxForce = (cpFloat)INFINITY; + constraint->errorBias = cpfpow(1.0f - 0.1f, 60.0f); + constraint->maxBias = (cpFloat)INFINITY; + + constraint->preSolve = NULL; + constraint->postSolve = NULL; } diff --git a/chipmunk/src/constraints/cpDampedRotarySpring.c b/chipmunk/src/constraints/cpDampedRotarySpring.c index f970c168c2..f9091aa9c4 100644 --- a/chipmunk/src/constraints/cpDampedRotarySpring.c +++ b/chipmunk/src/constraints/cpDampedRotarySpring.c @@ -19,34 +19,31 @@ * SOFTWARE. */ -#include -#include - #include "chipmunk_private.h" #include "constraints/util.h" static cpFloat defaultSpringTorque(cpDampedRotarySpring *spring, cpFloat relativeAngle){ - return (relativeAngle - spring->restAngle)*spring->stiffness; + return (relativeAngle - spring->restAngle)*spring->stiffness; } static void preStep(cpDampedRotarySpring *spring, cpFloat dt) { - cpBody *a = spring->constraint.a; - cpBody *b = spring->constraint.b; - - cpFloat moment = a->i_inv + b->i_inv; - cpAssertSoft(moment != 0.0, "Unsolvable spring."); - spring->iSum = 1.0f/moment; + cpBody *a = spring->constraint.a; + cpBody *b = spring->constraint.b; + + cpFloat moment = a->i_inv + b->i_inv; + cpAssertSoft(moment != 0.0, "Unsolvable spring."); + spring->iSum = 1.0f/moment; - spring->w_coef = 1.0f - cpfexp(-spring->damping*dt*moment); - spring->target_wrn = 0.0f; + spring->w_coef = 1.0f - cpfexp(-spring->damping*dt*moment); + spring->target_wrn = 0.0f; - // apply spring torque - cpFloat j_spring = spring->springTorqueFunc((cpConstraint *)spring, a->a - b->a)*dt; - a->w -= j_spring*a->i_inv; - b->w += j_spring*b->i_inv; + // apply spring torque + cpFloat j_spring = spring->springTorqueFunc((cpConstraint *)spring, a->a - b->a)*dt; + a->w -= j_spring*a->i_inv; + b->w += j_spring*b->i_inv; } static void applyCachedImpulse(cpDampedRotarySpring *spring, cpFloat dt_coef){} @@ -54,58 +51,58 @@ static void applyCachedImpulse(cpDampedRotarySpring *spring, cpFloat dt_coef){} static void applyImpulse(cpDampedRotarySpring *spring) { - cpBody *a = spring->constraint.a; - cpBody *b = spring->constraint.b; - - // compute relative velocity - cpFloat wrn = a->w - b->w;//normal_relative_velocity(a, b, r1, r2, n) - spring->target_vrn; - - // compute velocity loss from drag - // not 100% certain this is derived correctly, though it makes sense - cpFloat w_damp = (spring->target_wrn - wrn)*spring->w_coef; - spring->target_wrn = wrn + w_damp; - - //apply_impulses(a, b, spring->r1, spring->r2, cpvmult(spring->n, v_damp*spring->nMass)); - cpFloat j_damp = w_damp*spring->iSum; - a->w += j_damp*a->i_inv; - b->w -= j_damp*b->i_inv; + cpBody *a = spring->constraint.a; + cpBody *b = spring->constraint.b; + + // compute relative velocity + cpFloat wrn = a->w - b->w;//normal_relative_velocity(a, b, r1, r2, n) - spring->target_vrn; + + // compute velocity loss from drag + // not 100% certain this is derived correctly, though it makes sense + cpFloat w_damp = (spring->target_wrn - wrn)*spring->w_coef; + spring->target_wrn = wrn + w_damp; + + //apply_impulses(a, b, spring->r1, spring->r2, cpvmult(spring->n, v_damp*spring->nMass)); + cpFloat j_damp = w_damp*spring->iSum; + a->w += j_damp*a->i_inv; + b->w -= j_damp*b->i_inv; } static cpFloat getImpulse(cpConstraint *constraint) { - return 0.0f; + return 0.0f; } static const cpConstraintClass klass = { - (cpConstraintPreStepImpl)preStep, - (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, - (cpConstraintApplyImpulseImpl)applyImpulse, - (cpConstraintGetImpulseImpl)getImpulse, + (cpConstraintPreStepImpl)preStep, + (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, + (cpConstraintApplyImpulseImpl)applyImpulse, + (cpConstraintGetImpulseImpl)getImpulse, }; CP_DefineClassGetter(cpDampedRotarySpring) cpDampedRotarySpring * cpDampedRotarySpringAlloc(void) { - return (cpDampedRotarySpring *)cpcalloc(1, sizeof(cpDampedRotarySpring)); + return (cpDampedRotarySpring *)cpcalloc(1, sizeof(cpDampedRotarySpring)); } cpDampedRotarySpring * cpDampedRotarySpringInit(cpDampedRotarySpring *spring, cpBody *a, cpBody *b, cpFloat restAngle, cpFloat stiffness, cpFloat damping) { - cpConstraintInit((cpConstraint *)spring, &klass, a, b); - - spring->restAngle = restAngle; - spring->stiffness = stiffness; - spring->damping = damping; - spring->springTorqueFunc = (cpDampedRotarySpringTorqueFunc)defaultSpringTorque; - - return spring; + cpConstraintInit((cpConstraint *)spring, &klass, a, b); + + spring->restAngle = restAngle; + spring->stiffness = stiffness; + spring->damping = damping; + spring->springTorqueFunc = (cpDampedRotarySpringTorqueFunc)defaultSpringTorque; + + return spring; } cpConstraint * cpDampedRotarySpringNew(cpBody *a, cpBody *b, cpFloat restAngle, cpFloat stiffness, cpFloat damping) { - return (cpConstraint *)cpDampedRotarySpringInit(cpDampedRotarySpringAlloc(), a, b, restAngle, stiffness, damping); + return (cpConstraint *)cpDampedRotarySpringInit(cpDampedRotarySpringAlloc(), a, b, restAngle, stiffness, damping); } diff --git a/chipmunk/src/constraints/cpDampedSpring.c b/chipmunk/src/constraints/cpDampedSpring.c index 36aa1c5cb8..aec5e37504 100644 --- a/chipmunk/src/constraints/cpDampedSpring.c +++ b/chipmunk/src/constraints/cpDampedSpring.c @@ -19,40 +19,37 @@ * SOFTWARE. */ -#include -#include - #include "chipmunk_private.h" #include "constraints/util.h" static cpFloat defaultSpringForce(cpDampedSpring *spring, cpFloat dist){ - return (spring->restLength - dist)*spring->stiffness; + return (spring->restLength - dist)*spring->stiffness; } static void preStep(cpDampedSpring *spring, cpFloat dt) { - cpBody *a = spring->constraint.a; - cpBody *b = spring->constraint.b; - - spring->r1 = cpvrotate(spring->anchr1, a->rot); - spring->r2 = cpvrotate(spring->anchr2, b->rot); - - cpVect delta = cpvsub(cpvadd(b->p, spring->r2), cpvadd(a->p, spring->r1)); - cpFloat dist = cpvlength(delta); - spring->n = cpvmult(delta, 1.0f/(dist ? dist : INFINITY)); - - cpFloat k = k_scalar(a, b, spring->r1, spring->r2, spring->n); - cpAssertSoft(k != 0.0, "Unsolvable spring."); - spring->nMass = 1.0f/k; - - spring->target_vrn = 0.0f; - spring->v_coef = 1.0f - cpfexp(-spring->damping*dt*k); + cpBody *a = spring->constraint.a; + cpBody *b = spring->constraint.b; + + spring->r1 = cpvrotate(spring->anchr1, a->rot); + spring->r2 = cpvrotate(spring->anchr2, b->rot); + + cpVect delta = cpvsub(cpvadd(b->p, spring->r2), cpvadd(a->p, spring->r1)); + cpFloat dist = cpvlength(delta); + spring->n = cpvmult(delta, 1.0f/(dist ? dist : INFINITY)); + + cpFloat k = k_scalar(a, b, spring->r1, spring->r2, spring->n); + cpAssertSoft(k != 0.0, "Unsolvable spring."); + spring->nMass = 1.0f/k; + + spring->target_vrn = 0.0f; + spring->v_coef = 1.0f - cpfexp(-spring->damping*dt*k); - // apply spring force - cpFloat f_spring = spring->springForceFunc((cpConstraint *)spring, dist); - apply_impulses(a, b, spring->r1, spring->r2, cpvmult(spring->n, f_spring*dt)); + // apply spring force + cpFloat f_spring = spring->springForceFunc((cpConstraint *)spring, dist); + apply_impulses(a, b, spring->r1, spring->r2, cpvmult(spring->n, f_spring*dt)); } static void applyCachedImpulse(cpDampedSpring *spring, cpFloat dt_coef){} @@ -60,61 +57,61 @@ static void applyCachedImpulse(cpDampedSpring *spring, cpFloat dt_coef){} static void applyImpulse(cpDampedSpring *spring) { - cpBody *a = spring->constraint.a; - cpBody *b = spring->constraint.b; - - cpVect n = spring->n; - cpVect r1 = spring->r1; - cpVect r2 = spring->r2; + cpBody *a = spring->constraint.a; + cpBody *b = spring->constraint.b; + + cpVect n = spring->n; + cpVect r1 = spring->r1; + cpVect r2 = spring->r2; - // compute relative velocity - cpFloat vrn = normal_relative_velocity(a, b, r1, r2, n); - - // compute velocity loss from drag - cpFloat v_damp = (spring->target_vrn - vrn)*spring->v_coef; - spring->target_vrn = vrn + v_damp; - - apply_impulses(a, b, spring->r1, spring->r2, cpvmult(spring->n, v_damp*spring->nMass)); + // compute relative velocity + cpFloat vrn = normal_relative_velocity(a, b, r1, r2, n); + + // compute velocity loss from drag + cpFloat v_damp = (spring->target_vrn - vrn)*spring->v_coef; + spring->target_vrn = vrn + v_damp; + + apply_impulses(a, b, spring->r1, spring->r2, cpvmult(spring->n, v_damp*spring->nMass)); } static cpFloat getImpulse(cpConstraint *constraint) { - return 0.0f; + return 0.0f; } static const cpConstraintClass klass = { - (cpConstraintPreStepImpl)preStep, - (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, - (cpConstraintApplyImpulseImpl)applyImpulse, - (cpConstraintGetImpulseImpl)getImpulse, + (cpConstraintPreStepImpl)preStep, + (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, + (cpConstraintApplyImpulseImpl)applyImpulse, + (cpConstraintGetImpulseImpl)getImpulse, }; CP_DefineClassGetter(cpDampedSpring) cpDampedSpring * cpDampedSpringAlloc(void) { - return (cpDampedSpring *)cpcalloc(1, sizeof(cpDampedSpring)); + return (cpDampedSpring *)cpcalloc(1, sizeof(cpDampedSpring)); } cpDampedSpring * cpDampedSpringInit(cpDampedSpring *spring, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat restLength, cpFloat stiffness, cpFloat damping) { - cpConstraintInit((cpConstraint *)spring, cpDampedSpringGetClass(), a, b); - - spring->anchr1 = anchr1; - spring->anchr2 = anchr2; - - spring->restLength = restLength; - spring->stiffness = stiffness; - spring->damping = damping; - spring->springForceFunc = (cpDampedSpringForceFunc)defaultSpringForce; - - return spring; + cpConstraintInit((cpConstraint *)spring, cpDampedSpringGetClass(), a, b); + + spring->anchr1 = anchr1; + spring->anchr2 = anchr2; + + spring->restLength = restLength; + spring->stiffness = stiffness; + spring->damping = damping; + spring->springForceFunc = (cpDampedSpringForceFunc)defaultSpringForce; + + return spring; } cpConstraint * cpDampedSpringNew(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat restLength, cpFloat stiffness, cpFloat damping) { - return (cpConstraint *)cpDampedSpringInit(cpDampedSpringAlloc(), a, b, anchr1, anchr2, restLength, stiffness, damping); + return (cpConstraint *)cpDampedSpringInit(cpDampedSpringAlloc(), a, b, anchr1, anchr2, restLength, stiffness, damping); } diff --git a/chipmunk/src/constraints/cpGearJoint.c b/chipmunk/src/constraints/cpGearJoint.c index cf5e4c1480..9ce9eded81 100644 --- a/chipmunk/src/constraints/cpGearJoint.c +++ b/chipmunk/src/constraints/cpGearJoint.c @@ -19,105 +19,102 @@ * SOFTWARE. */ -#include -#include - #include "chipmunk_private.h" #include "constraints/util.h" static void preStep(cpGearJoint *joint, cpFloat dt) { - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - // calculate moment of inertia coefficient. - joint->iSum = 1.0f/(a->i_inv*joint->ratio_inv + joint->ratio*b->i_inv); - - // calculate bias velocity - cpFloat maxBias = joint->constraint.maxBias; - joint->bias = cpfclamp(-bias_coef(joint->constraint.errorBias, dt)*(b->a*joint->ratio - a->a - joint->phase)/dt, -maxBias, maxBias); - - // compute max impulse - joint->jMax = J_MAX(joint, dt); + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + + // calculate moment of inertia coefficient. + joint->iSum = 1.0f/(a->i_inv*joint->ratio_inv + joint->ratio*b->i_inv); + + // calculate bias velocity + cpFloat maxBias = joint->constraint.maxBias; + joint->bias = cpfclamp(-bias_coef(joint->constraint.errorBias, dt)*(b->a*joint->ratio - a->a - joint->phase)/dt, -maxBias, maxBias); + + // compute max impulse + joint->jMax = J_MAX(joint, dt); } static void applyCachedImpulse(cpGearJoint *joint, cpFloat dt_coef) { - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - cpFloat j = joint->jAcc*dt_coef; - a->w -= j*a->i_inv*joint->ratio_inv; - b->w += j*b->i_inv; + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + + cpFloat j = joint->jAcc*dt_coef; + a->w -= j*a->i_inv*joint->ratio_inv; + b->w += j*b->i_inv; } static void applyImpulse(cpGearJoint *joint) { - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - // compute relative rotational velocity - cpFloat wr = b->w*joint->ratio - a->w; - - // compute normal impulse - cpFloat j = (joint->bias - wr)*joint->iSum; - cpFloat jOld = joint->jAcc; - joint->jAcc = cpfclamp(jOld + j, -joint->jMax, joint->jMax); - j = joint->jAcc - jOld; - - // apply impulse - a->w -= j*a->i_inv*joint->ratio_inv; - b->w += j*b->i_inv; + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + + // compute relative rotational velocity + cpFloat wr = b->w*joint->ratio - a->w; + + // compute normal impulse + cpFloat j = (joint->bias - wr)*joint->iSum; + cpFloat jOld = joint->jAcc; + joint->jAcc = cpfclamp(jOld + j, -joint->jMax, joint->jMax); + j = joint->jAcc - jOld; + + // apply impulse + a->w -= j*a->i_inv*joint->ratio_inv; + b->w += j*b->i_inv; } static cpFloat getImpulse(cpGearJoint *joint) { - return cpfabs(joint->jAcc); + return cpfabs(joint->jAcc); } static const cpConstraintClass klass = { - (cpConstraintPreStepImpl)preStep, - (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, - (cpConstraintApplyImpulseImpl)applyImpulse, - (cpConstraintGetImpulseImpl)getImpulse, + (cpConstraintPreStepImpl)preStep, + (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, + (cpConstraintApplyImpulseImpl)applyImpulse, + (cpConstraintGetImpulseImpl)getImpulse, }; CP_DefineClassGetter(cpGearJoint) cpGearJoint * cpGearJointAlloc(void) { - return (cpGearJoint *)cpcalloc(1, sizeof(cpGearJoint)); + return (cpGearJoint *)cpcalloc(1, sizeof(cpGearJoint)); } cpGearJoint * cpGearJointInit(cpGearJoint *joint, cpBody *a, cpBody *b, cpFloat phase, cpFloat ratio) { - cpConstraintInit((cpConstraint *)joint, &klass, a, b); - - joint->phase = phase; - joint->ratio = ratio; - joint->ratio_inv = 1.0f/ratio; - - joint->jAcc = 0.0f; - - return joint; + cpConstraintInit((cpConstraint *)joint, &klass, a, b); + + joint->phase = phase; + joint->ratio = ratio; + joint->ratio_inv = 1.0f/ratio; + + joint->jAcc = 0.0f; + + return joint; } cpConstraint * cpGearJointNew(cpBody *a, cpBody *b, cpFloat phase, cpFloat ratio) { - return (cpConstraint *)cpGearJointInit(cpGearJointAlloc(), a, b, phase, ratio); + return (cpConstraint *)cpGearJointInit(cpGearJointAlloc(), a, b, phase, ratio); } void cpGearJointSetRatio(cpConstraint *constraint, cpFloat value) { - cpConstraintCheckCast(constraint, cpGearJoint); - ((cpGearJoint *)constraint)->ratio = value; - ((cpGearJoint *)constraint)->ratio_inv = 1.0f/value; - cpConstraintActivateBodies(constraint); + cpConstraintCheckCast(constraint, cpGearJoint); + ((cpGearJoint *)constraint)->ratio = value; + ((cpGearJoint *)constraint)->ratio_inv = 1.0f/value; + cpConstraintActivateBodies(constraint); } diff --git a/chipmunk/src/constraints/cpGrooveJoint.c b/chipmunk/src/constraints/cpGrooveJoint.c index 80c403207e..e61de0fa56 100644 --- a/chipmunk/src/constraints/cpGrooveJoint.c +++ b/chipmunk/src/constraints/cpGrooveJoint.c @@ -19,153 +19,150 @@ * SOFTWARE. */ -#include -#include - #include "chipmunk_private.h" #include "constraints/util.h" static void preStep(cpGrooveJoint *joint, cpFloat dt) { - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - // calculate endpoints in worldspace - cpVect ta = cpBodyLocal2World(a, joint->grv_a); - cpVect tb = cpBodyLocal2World(a, joint->grv_b); + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + + // calculate endpoints in worldspace + cpVect ta = cpBodyLocal2World(a, joint->grv_a); + cpVect tb = cpBodyLocal2World(a, joint->grv_b); - // calculate axis - cpVect n = cpvrotate(joint->grv_n, a->rot); - cpFloat d = cpvdot(ta, n); - - joint->grv_tn = n; - joint->r2 = cpvrotate(joint->anchr2, b->rot); - - // calculate tangential distance along the axis of r2 - cpFloat td = cpvcross(cpvadd(b->p, joint->r2), n); - // calculate clamping factor and r2 - if(td <= cpvcross(ta, n)){ - joint->clamp = 1.0f; - joint->r1 = cpvsub(ta, a->p); - } else if(td >= cpvcross(tb, n)){ - joint->clamp = -1.0f; - joint->r1 = cpvsub(tb, a->p); - } else { - joint->clamp = 0.0f; - joint->r1 = cpvsub(cpvadd(cpvmult(cpvperp(n), -td), cpvmult(n, d)), a->p); - } - - // Calculate mass tensor - k_tensor(a, b, joint->r1, joint->r2, &joint->k1, &joint->k2); - - // compute max impulse - joint->jMaxLen = J_MAX(joint, dt); - - // calculate bias velocity - cpVect delta = cpvsub(cpvadd(b->p, joint->r2), cpvadd(a->p, joint->r1)); - joint->bias = cpvclamp(cpvmult(delta, -bias_coef(joint->constraint.errorBias, dt)/dt), joint->constraint.maxBias); + // calculate axis + cpVect n = cpvrotate(joint->grv_n, a->rot); + cpFloat d = cpvdot(ta, n); + + joint->grv_tn = n; + joint->r2 = cpvrotate(joint->anchr2, b->rot); + + // calculate tangential distance along the axis of r2 + cpFloat td = cpvcross(cpvadd(b->p, joint->r2), n); + // calculate clamping factor and r2 + if(td <= cpvcross(ta, n)){ + joint->clamp = 1.0f; + joint->r1 = cpvsub(ta, a->p); + } else if(td >= cpvcross(tb, n)){ + joint->clamp = -1.0f; + joint->r1 = cpvsub(tb, a->p); + } else { + joint->clamp = 0.0f; + joint->r1 = cpvsub(cpvadd(cpvmult(cpvperp(n), -td), cpvmult(n, d)), a->p); + } + + // Calculate mass tensor + k_tensor(a, b, joint->r1, joint->r2, &joint->k1, &joint->k2); + + // compute max impulse + joint->jMaxLen = J_MAX(joint, dt); + + // calculate bias velocity + cpVect delta = cpvsub(cpvadd(b->p, joint->r2), cpvadd(a->p, joint->r1)); + joint->bias = cpvclamp(cpvmult(delta, -bias_coef(joint->constraint.errorBias, dt)/dt), joint->constraint.maxBias); } static void applyCachedImpulse(cpGrooveJoint *joint, cpFloat dt_coef) { - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - apply_impulses(a, b, joint->r1, joint->r2, cpvmult(joint->jAcc, dt_coef)); + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + + apply_impulses(a, b, joint->r1, joint->r2, cpvmult(joint->jAcc, dt_coef)); } static inline cpVect grooveConstrain(cpGrooveJoint *joint, cpVect j){ - cpVect n = joint->grv_tn; - cpVect jClamp = (joint->clamp*cpvcross(j, n) > 0.0f) ? j : cpvproject(j, n); - return cpvclamp(jClamp, joint->jMaxLen); + cpVect n = joint->grv_tn; + cpVect jClamp = (joint->clamp*cpvcross(j, n) > 0.0f) ? j : cpvproject(j, n); + return cpvclamp(jClamp, joint->jMaxLen); } static void applyImpulse(cpGrooveJoint *joint) { - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - cpVect r1 = joint->r1; - cpVect r2 = joint->r2; - - // compute impulse - cpVect vr = relative_velocity(a, b, r1, r2); + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + + cpVect r1 = joint->r1; + cpVect r2 = joint->r2; + + // compute impulse + cpVect vr = relative_velocity(a, b, r1, r2); - cpVect j = mult_k(cpvsub(joint->bias, vr), joint->k1, joint->k2); - cpVect jOld = joint->jAcc; - joint->jAcc = grooveConstrain(joint, cpvadd(jOld, j)); - j = cpvsub(joint->jAcc, jOld); - - // apply impulse - apply_impulses(a, b, joint->r1, joint->r2, j); + cpVect j = mult_k(cpvsub(joint->bias, vr), joint->k1, joint->k2); + cpVect jOld = joint->jAcc; + joint->jAcc = grooveConstrain(joint, cpvadd(jOld, j)); + j = cpvsub(joint->jAcc, jOld); + + // apply impulse + apply_impulses(a, b, joint->r1, joint->r2, j); } static cpFloat getImpulse(cpGrooveJoint *joint) { - return cpvlength(joint->jAcc); + return cpvlength(joint->jAcc); } static const cpConstraintClass klass = { - (cpConstraintPreStepImpl)preStep, - (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, - (cpConstraintApplyImpulseImpl)applyImpulse, - (cpConstraintGetImpulseImpl)getImpulse, + (cpConstraintPreStepImpl)preStep, + (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, + (cpConstraintApplyImpulseImpl)applyImpulse, + (cpConstraintGetImpulseImpl)getImpulse, }; CP_DefineClassGetter(cpGrooveJoint) cpGrooveJoint * cpGrooveJointAlloc(void) { - return (cpGrooveJoint *)cpcalloc(1, sizeof(cpGrooveJoint)); + return (cpGrooveJoint *)cpcalloc(1, sizeof(cpGrooveJoint)); } cpGrooveJoint * cpGrooveJointInit(cpGrooveJoint *joint, cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchr2) { - cpConstraintInit((cpConstraint *)joint, &klass, a, b); - - joint->grv_a = groove_a; - joint->grv_b = groove_b; - joint->grv_n = cpvperp(cpvnormalize(cpvsub(groove_b, groove_a))); - joint->anchr2 = anchr2; - - joint->jAcc = cpvzero; - - return joint; + cpConstraintInit((cpConstraint *)joint, &klass, a, b); + + joint->grv_a = groove_a; + joint->grv_b = groove_b; + joint->grv_n = cpvperp(cpvnormalize(cpvsub(groove_b, groove_a))); + joint->anchr2 = anchr2; + + joint->jAcc = cpvzero; + + return joint; } cpConstraint * cpGrooveJointNew(cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchr2) { - return (cpConstraint *)cpGrooveJointInit(cpGrooveJointAlloc(), a, b, groove_a, groove_b, anchr2); + return (cpConstraint *)cpGrooveJointInit(cpGrooveJointAlloc(), a, b, groove_a, groove_b, anchr2); } void cpGrooveJointSetGrooveA(cpConstraint *constraint, cpVect value) { - cpGrooveJoint *g = (cpGrooveJoint *)constraint; - cpConstraintCheckCast(constraint, cpGrooveJoint); - - g->grv_a = value; - g->grv_n = cpvperp(cpvnormalize(cpvsub(g->grv_b, value))); - - cpConstraintActivateBodies(constraint); + cpGrooveJoint *g = (cpGrooveJoint *)constraint; + cpConstraintCheckCast(constraint, cpGrooveJoint); + + g->grv_a = value; + g->grv_n = cpvperp(cpvnormalize(cpvsub(g->grv_b, value))); + + cpConstraintActivateBodies(constraint); } void cpGrooveJointSetGrooveB(cpConstraint *constraint, cpVect value) { - cpGrooveJoint *g = (cpGrooveJoint *)constraint; - cpConstraintCheckCast(constraint, cpGrooveJoint); - - g->grv_b = value; - g->grv_n = cpvperp(cpvnormalize(cpvsub(value, g->grv_a))); - - cpConstraintActivateBodies(constraint); + cpGrooveJoint *g = (cpGrooveJoint *)constraint; + cpConstraintCheckCast(constraint, cpGrooveJoint); + + g->grv_b = value; + g->grv_n = cpvperp(cpvnormalize(cpvsub(value, g->grv_a))); + + cpConstraintActivateBodies(constraint); } diff --git a/chipmunk/src/constraints/cpPinJoint.c b/chipmunk/src/constraints/cpPinJoint.c index be20b5df88..f4556dc869 100644 --- a/chipmunk/src/constraints/cpPinJoint.c +++ b/chipmunk/src/constraints/cpPinJoint.c @@ -19,77 +19,74 @@ * SOFTWARE. */ -#include -#include - #include "chipmunk_private.h" #include "constraints/util.h" static void preStep(cpPinJoint *joint, cpFloat dt) { - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - joint->r1 = cpvrotate(joint->anchr1, a->rot); - joint->r2 = cpvrotate(joint->anchr2, b->rot); - - cpVect delta = cpvsub(cpvadd(b->p, joint->r2), cpvadd(a->p, joint->r1)); - cpFloat dist = cpvlength(delta); - joint->n = cpvmult(delta, 1.0f/(dist ? dist : (cpFloat)INFINITY)); - - // calculate mass normal - joint->nMass = 1.0f/k_scalar(a, b, joint->r1, joint->r2, joint->n); - - // calculate bias velocity - cpFloat maxBias = joint->constraint.maxBias; - joint->bias = cpfclamp(-bias_coef(joint->constraint.errorBias, dt)*(dist - joint->dist)/dt, -maxBias, maxBias); - - // compute max impulse - joint->jnMax = J_MAX(joint, dt); + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + + joint->r1 = cpvrotate(joint->anchr1, a->rot); + joint->r2 = cpvrotate(joint->anchr2, b->rot); + + cpVect delta = cpvsub(cpvadd(b->p, joint->r2), cpvadd(a->p, joint->r1)); + cpFloat dist = cpvlength(delta); + joint->n = cpvmult(delta, 1.0f/(dist ? dist : (cpFloat)INFINITY)); + + // calculate mass normal + joint->nMass = 1.0f/k_scalar(a, b, joint->r1, joint->r2, joint->n); + + // calculate bias velocity + cpFloat maxBias = joint->constraint.maxBias; + joint->bias = cpfclamp(-bias_coef(joint->constraint.errorBias, dt)*(dist - joint->dist)/dt, -maxBias, maxBias); + + // compute max impulse + joint->jnMax = J_MAX(joint, dt); } static void applyCachedImpulse(cpPinJoint *joint, cpFloat dt_coef) { - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - cpVect j = cpvmult(joint->n, joint->jnAcc*dt_coef); - apply_impulses(a, b, joint->r1, joint->r2, j); + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + + cpVect j = cpvmult(joint->n, joint->jnAcc*dt_coef); + apply_impulses(a, b, joint->r1, joint->r2, j); } static void applyImpulse(cpPinJoint *joint) { - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - cpVect n = joint->n; + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + cpVect n = joint->n; - // compute relative velocity - cpFloat vrn = normal_relative_velocity(a, b, joint->r1, joint->r2, n); - - // compute normal impulse - cpFloat jn = (joint->bias - vrn)*joint->nMass; - cpFloat jnOld = joint->jnAcc; - joint->jnAcc = cpfclamp(jnOld + jn, -joint->jnMax, joint->jnMax); - jn = joint->jnAcc - jnOld; - - // apply impulse - apply_impulses(a, b, joint->r1, joint->r2, cpvmult(n, jn)); + // compute relative velocity + cpFloat vrn = normal_relative_velocity(a, b, joint->r1, joint->r2, n); + + // compute normal impulse + cpFloat jn = (joint->bias - vrn)*joint->nMass; + cpFloat jnOld = joint->jnAcc; + joint->jnAcc = cpfclamp(jnOld + jn, -joint->jnMax, joint->jnMax); + jn = joint->jnAcc - jnOld; + + // apply impulse + apply_impulses(a, b, joint->r1, joint->r2, cpvmult(n, jn)); } static cpFloat getImpulse(cpPinJoint *joint) { - return cpfabs(joint->jnAcc); + return cpfabs(joint->jnAcc); } static const cpConstraintClass klass = { - (cpConstraintPreStepImpl)preStep, - (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, - (cpConstraintApplyImpulseImpl)applyImpulse, - (cpConstraintGetImpulseImpl)getImpulse, + (cpConstraintPreStepImpl)preStep, + (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, + (cpConstraintApplyImpulseImpl)applyImpulse, + (cpConstraintGetImpulseImpl)getImpulse, }; CP_DefineClassGetter(cpPinJoint); @@ -97,31 +94,31 @@ CP_DefineClassGetter(cpPinJoint); cpPinJoint * cpPinJointAlloc(void) { - return (cpPinJoint *)cpcalloc(1, sizeof(cpPinJoint)); + return (cpPinJoint *)cpcalloc(1, sizeof(cpPinJoint)); } cpPinJoint * cpPinJointInit(cpPinJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2) { - cpConstraintInit((cpConstraint *)joint, &klass, a, b); - - joint->anchr1 = anchr1; - joint->anchr2 = anchr2; - - // STATIC_BODY_CHECK - cpVect p1 = (a ? cpvadd(a->p, cpvrotate(anchr1, a->rot)) : anchr1); - cpVect p2 = (b ? cpvadd(b->p, cpvrotate(anchr2, b->rot)) : anchr2); - joint->dist = cpvlength(cpvsub(p2, p1)); - - cpAssertWarn(joint->dist > 0.0, "You created a 0 length pin joint. A pivot joint will be much more stable."); + cpConstraintInit((cpConstraint *)joint, &klass, a, b); + + joint->anchr1 = anchr1; + joint->anchr2 = anchr2; + + // STATIC_BODY_CHECK + cpVect p1 = (a ? cpvadd(a->p, cpvrotate(anchr1, a->rot)) : anchr1); + cpVect p2 = (b ? cpvadd(b->p, cpvrotate(anchr2, b->rot)) : anchr2); + joint->dist = cpvlength(cpvsub(p2, p1)); + + cpAssertWarn(joint->dist > 0.0, "You created a 0 length pin joint. A pivot joint will be much more stable."); - joint->jnAcc = 0.0f; - - return joint; + joint->jnAcc = 0.0f; + + return joint; } cpConstraint * cpPinJointNew(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2) { - return (cpConstraint *)cpPinJointInit(cpPinJointAlloc(), a, b, anchr1, anchr2); + return (cpConstraint *)cpPinJointInit(cpPinJointAlloc(), a, b, anchr1, anchr2); } diff --git a/chipmunk/src/constraints/cpPivotJoint.c b/chipmunk/src/constraints/cpPivotJoint.c index d0ad6493a7..5191dc18dd 100644 --- a/chipmunk/src/constraints/cpPivotJoint.c +++ b/chipmunk/src/constraints/cpPivotJoint.c @@ -19,106 +19,103 @@ * SOFTWARE. */ -#include -#include - #include "chipmunk_private.h" #include "constraints/util.h" static void preStep(cpPivotJoint *joint, cpFloat dt) { - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - joint->r1 = cpvrotate(joint->anchr1, a->rot); - joint->r2 = cpvrotate(joint->anchr2, b->rot); - - // Calculate mass tensor - k_tensor(a, b, joint->r1, joint->r2, &joint->k1, &joint->k2); - - // compute max impulse - joint->jMaxLen = J_MAX(joint, dt); - - // calculate bias velocity - cpVect delta = cpvsub(cpvadd(b->p, joint->r2), cpvadd(a->p, joint->r1)); - joint->bias = cpvclamp(cpvmult(delta, -bias_coef(joint->constraint.errorBias, dt)/dt), joint->constraint.maxBias); + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + + joint->r1 = cpvrotate(joint->anchr1, a->rot); + joint->r2 = cpvrotate(joint->anchr2, b->rot); + + // Calculate mass tensor + k_tensor(a, b, joint->r1, joint->r2, &joint->k1, &joint->k2); + + // compute max impulse + joint->jMaxLen = J_MAX(joint, dt); + + // calculate bias velocity + cpVect delta = cpvsub(cpvadd(b->p, joint->r2), cpvadd(a->p, joint->r1)); + joint->bias = cpvclamp(cpvmult(delta, -bias_coef(joint->constraint.errorBias, dt)/dt), joint->constraint.maxBias); } static void applyCachedImpulse(cpPivotJoint *joint, cpFloat dt_coef) { - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - apply_impulses(a, b, joint->r1, joint->r2, cpvmult(joint->jAcc, dt_coef)); + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + + apply_impulses(a, b, joint->r1, joint->r2, cpvmult(joint->jAcc, dt_coef)); } static void applyImpulse(cpPivotJoint *joint) { - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - cpVect r1 = joint->r1; - cpVect r2 = joint->r2; - - // compute relative velocity - cpVect vr = relative_velocity(a, b, r1, r2); - - // compute normal impulse - cpVect j = mult_k(cpvsub(joint->bias, vr), joint->k1, joint->k2); - cpVect jOld = joint->jAcc; - joint->jAcc = cpvclamp(cpvadd(joint->jAcc, j), joint->jMaxLen); - j = cpvsub(joint->jAcc, jOld); - - // apply impulse - apply_impulses(a, b, joint->r1, joint->r2, j); + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + + cpVect r1 = joint->r1; + cpVect r2 = joint->r2; + + // compute relative velocity + cpVect vr = relative_velocity(a, b, r1, r2); + + // compute normal impulse + cpVect j = mult_k(cpvsub(joint->bias, vr), joint->k1, joint->k2); + cpVect jOld = joint->jAcc; + joint->jAcc = cpvclamp(cpvadd(joint->jAcc, j), joint->jMaxLen); + j = cpvsub(joint->jAcc, jOld); + + // apply impulse + apply_impulses(a, b, joint->r1, joint->r2, j); } static cpFloat getImpulse(cpConstraint *joint) { - return cpvlength(((cpPivotJoint *)joint)->jAcc); + return cpvlength(((cpPivotJoint *)joint)->jAcc); } static const cpConstraintClass klass = { - (cpConstraintPreStepImpl)preStep, - (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, - (cpConstraintApplyImpulseImpl)applyImpulse, - (cpConstraintGetImpulseImpl)getImpulse, + (cpConstraintPreStepImpl)preStep, + (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, + (cpConstraintApplyImpulseImpl)applyImpulse, + (cpConstraintGetImpulseImpl)getImpulse, }; CP_DefineClassGetter(cpPivotJoint) cpPivotJoint * cpPivotJointAlloc(void) { - return (cpPivotJoint *)cpcalloc(1, sizeof(cpPivotJoint)); + return (cpPivotJoint *)cpcalloc(1, sizeof(cpPivotJoint)); } cpPivotJoint * cpPivotJointInit(cpPivotJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2) { - cpConstraintInit((cpConstraint *)joint, &klass, a, b); - - joint->anchr1 = anchr1; - joint->anchr2 = anchr2; - - joint->jAcc = cpvzero; - - return joint; + cpConstraintInit((cpConstraint *)joint, &klass, a, b); + + joint->anchr1 = anchr1; + joint->anchr2 = anchr2; + + joint->jAcc = cpvzero; + + return joint; } cpConstraint * cpPivotJointNew2(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2) { - return (cpConstraint *)cpPivotJointInit(cpPivotJointAlloc(), a, b, anchr1, anchr2); + return (cpConstraint *)cpPivotJointInit(cpPivotJointAlloc(), a, b, anchr1, anchr2); } cpConstraint * cpPivotJointNew(cpBody *a, cpBody *b, cpVect pivot) { - cpVect anchr1 = (a ? cpBodyWorld2Local(a, pivot) : pivot); - cpVect anchr2 = (b ? cpBodyWorld2Local(b, pivot) : pivot); - return cpPivotJointNew2(a, b, anchr1, anchr2); + cpVect anchr1 = (a ? cpBodyWorld2Local(a, pivot) : pivot); + cpVect anchr2 = (b ? cpBodyWorld2Local(b, pivot) : pivot); + return cpPivotJointNew2(a, b, anchr1, anchr2); } diff --git a/chipmunk/src/constraints/cpRatchetJoint.c b/chipmunk/src/constraints/cpRatchetJoint.c index 4007f93856..c5b5a847bd 100644 --- a/chipmunk/src/constraints/cpRatchetJoint.c +++ b/chipmunk/src/constraints/cpRatchetJoint.c @@ -19,117 +19,114 @@ * SOFTWARE. */ -#include -#include - #include "chipmunk_private.h" #include "constraints/util.h" static void preStep(cpRatchetJoint *joint, cpFloat dt) { - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - cpFloat angle = joint->angle; - cpFloat phase = joint->phase; - cpFloat ratchet = joint->ratchet; - - cpFloat delta = b->a - a->a; - cpFloat diff = angle - delta; - cpFloat pdist = 0.0f; - - if(diff*ratchet > 0.0f){ - pdist = diff; - } else { - joint->angle = cpffloor((delta - phase)/ratchet)*ratchet + phase; - } - - // calculate moment of inertia coefficient. - joint->iSum = 1.0f/(a->i_inv + b->i_inv); - - // calculate bias velocity - cpFloat maxBias = joint->constraint.maxBias; - joint->bias = cpfclamp(-bias_coef(joint->constraint.errorBias, dt)*pdist/dt, -maxBias, maxBias); - - // compute max impulse - joint->jMax = J_MAX(joint, dt); + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + + cpFloat angle = joint->angle; + cpFloat phase = joint->phase; + cpFloat ratchet = joint->ratchet; + + cpFloat delta = b->a - a->a; + cpFloat diff = angle - delta; + cpFloat pdist = 0.0f; + + if(diff*ratchet > 0.0f){ + pdist = diff; + } else { + joint->angle = cpffloor((delta - phase)/ratchet)*ratchet + phase; + } + + // calculate moment of inertia coefficient. + joint->iSum = 1.0f/(a->i_inv + b->i_inv); + + // calculate bias velocity + cpFloat maxBias = joint->constraint.maxBias; + joint->bias = cpfclamp(-bias_coef(joint->constraint.errorBias, dt)*pdist/dt, -maxBias, maxBias); + + // compute max impulse + joint->jMax = J_MAX(joint, dt); - // If the bias is 0, the joint is not at a limit. Reset the impulse. - if(!joint->bias) joint->jAcc = 0.0f; + // If the bias is 0, the joint is not at a limit. Reset the impulse. + if(!joint->bias) joint->jAcc = 0.0f; } static void applyCachedImpulse(cpRatchetJoint *joint, cpFloat dt_coef) { - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - cpFloat j = joint->jAcc*dt_coef; - a->w -= j*a->i_inv; - b->w += j*b->i_inv; + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + + cpFloat j = joint->jAcc*dt_coef; + a->w -= j*a->i_inv; + b->w += j*b->i_inv; } static void applyImpulse(cpRatchetJoint *joint) { - if(!joint->bias) return; // early exit + if(!joint->bias) return; // early exit - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - // compute relative rotational velocity - cpFloat wr = b->w - a->w; - cpFloat ratchet = joint->ratchet; - - // compute normal impulse - cpFloat j = -(joint->bias + wr)*joint->iSum; - cpFloat jOld = joint->jAcc; - joint->jAcc = cpfclamp((jOld + j)*ratchet, 0.0f, joint->jMax*cpfabs(ratchet))/ratchet; - j = joint->jAcc - jOld; - - // apply impulse - a->w -= j*a->i_inv; - b->w += j*b->i_inv; + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + + // compute relative rotational velocity + cpFloat wr = b->w - a->w; + cpFloat ratchet = joint->ratchet; + + // compute normal impulse + cpFloat j = -(joint->bias + wr)*joint->iSum; + cpFloat jOld = joint->jAcc; + joint->jAcc = cpfclamp((jOld + j)*ratchet, 0.0f, joint->jMax*cpfabs(ratchet))/ratchet; + j = joint->jAcc - jOld; + + // apply impulse + a->w -= j*a->i_inv; + b->w += j*b->i_inv; } static cpFloat getImpulse(cpRatchetJoint *joint) { - return cpfabs(joint->jAcc); + return cpfabs(joint->jAcc); } static const cpConstraintClass klass = { - (cpConstraintPreStepImpl)preStep, - (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, - (cpConstraintApplyImpulseImpl)applyImpulse, - (cpConstraintGetImpulseImpl)getImpulse, + (cpConstraintPreStepImpl)preStep, + (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, + (cpConstraintApplyImpulseImpl)applyImpulse, + (cpConstraintGetImpulseImpl)getImpulse, }; CP_DefineClassGetter(cpRatchetJoint) cpRatchetJoint * cpRatchetJointAlloc(void) { - return (cpRatchetJoint *)cpcalloc(1, sizeof(cpRatchetJoint)); + return (cpRatchetJoint *)cpcalloc(1, sizeof(cpRatchetJoint)); } cpRatchetJoint * cpRatchetJointInit(cpRatchetJoint *joint, cpBody *a, cpBody *b, cpFloat phase, cpFloat ratchet) { - cpConstraintInit((cpConstraint *)joint, &klass, a, b); - - joint->angle = 0.0f; - joint->phase = phase; - joint->ratchet = ratchet; - - // STATIC_BODY_CHECK - joint->angle = (b ? b->a : 0.0f) - (a ? a->a : 0.0f); - - return joint; + cpConstraintInit((cpConstraint *)joint, &klass, a, b); + + joint->angle = 0.0f; + joint->phase = phase; + joint->ratchet = ratchet; + + // STATIC_BODY_CHECK + joint->angle = (b ? b->a : 0.0f) - (a ? a->a : 0.0f); + + return joint; } cpConstraint * cpRatchetJointNew(cpBody *a, cpBody *b, cpFloat phase, cpFloat ratchet) { - return (cpConstraint *)cpRatchetJointInit(cpRatchetJointAlloc(), a, b, phase, ratchet); + return (cpConstraint *)cpRatchetJointInit(cpRatchetJointAlloc(), a, b, phase, ratchet); } diff --git a/chipmunk/src/constraints/cpRotaryLimitJoint.c b/chipmunk/src/constraints/cpRotaryLimitJoint.c index cece050dc8..d935489cf2 100644 --- a/chipmunk/src/constraints/cpRotaryLimitJoint.c +++ b/chipmunk/src/constraints/cpRotaryLimitJoint.c @@ -19,112 +19,109 @@ * SOFTWARE. */ -#include -#include - #include "chipmunk_private.h" #include "constraints/util.h" static void preStep(cpRotaryLimitJoint *joint, cpFloat dt) { - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - cpFloat dist = b->a - a->a; - cpFloat pdist = 0.0f; - if(dist > joint->max) { - pdist = joint->max - dist; - } else if(dist < joint->min) { - pdist = joint->min - dist; - } - - // calculate moment of inertia coefficient. - joint->iSum = 1.0f/(1.0f/a->i + 1.0f/b->i); - - // calculate bias velocity - cpFloat maxBias = joint->constraint.maxBias; - joint->bias = cpfclamp(-bias_coef(joint->constraint.errorBias, dt)*pdist/dt, -maxBias, maxBias); - - // compute max impulse - joint->jMax = J_MAX(joint, dt); + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + + cpFloat dist = b->a - a->a; + cpFloat pdist = 0.0f; + if(dist > joint->max) { + pdist = joint->max - dist; + } else if(dist < joint->min) { + pdist = joint->min - dist; + } + + // calculate moment of inertia coefficient. + joint->iSum = 1.0f/(1.0f/a->i + 1.0f/b->i); + + // calculate bias velocity + cpFloat maxBias = joint->constraint.maxBias; + joint->bias = cpfclamp(-bias_coef(joint->constraint.errorBias, dt)*pdist/dt, -maxBias, maxBias); + + // compute max impulse + joint->jMax = J_MAX(joint, dt); - // If the bias is 0, the joint is not at a limit. Reset the impulse. - if(!joint->bias) joint->jAcc = 0.0f; + // If the bias is 0, the joint is not at a limit. Reset the impulse. + if(!joint->bias) joint->jAcc = 0.0f; } static void applyCachedImpulse(cpRotaryLimitJoint *joint, cpFloat dt_coef) { - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - cpFloat j = joint->jAcc*dt_coef; - a->w -= j*a->i_inv; - b->w += j*b->i_inv; + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + + cpFloat j = joint->jAcc*dt_coef; + a->w -= j*a->i_inv; + b->w += j*b->i_inv; } static void applyImpulse(cpRotaryLimitJoint *joint) { - if(!joint->bias) return; // early exit + if(!joint->bias) return; // early exit - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - // compute relative rotational velocity - cpFloat wr = b->w - a->w; - - // compute normal impulse - cpFloat j = -(joint->bias + wr)*joint->iSum; - cpFloat jOld = joint->jAcc; - if(joint->bias < 0.0f){ - joint->jAcc = cpfclamp(jOld + j, 0.0f, joint->jMax); - } else { - joint->jAcc = cpfclamp(jOld + j, -joint->jMax, 0.0f); - } - j = joint->jAcc - jOld; - - // apply impulse - a->w -= j*a->i_inv; - b->w += j*b->i_inv; + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + + // compute relative rotational velocity + cpFloat wr = b->w - a->w; + + // compute normal impulse + cpFloat j = -(joint->bias + wr)*joint->iSum; + cpFloat jOld = joint->jAcc; + if(joint->bias < 0.0f){ + joint->jAcc = cpfclamp(jOld + j, 0.0f, joint->jMax); + } else { + joint->jAcc = cpfclamp(jOld + j, -joint->jMax, 0.0f); + } + j = joint->jAcc - jOld; + + // apply impulse + a->w -= j*a->i_inv; + b->w += j*b->i_inv; } static cpFloat getImpulse(cpRotaryLimitJoint *joint) { - return cpfabs(joint->jAcc); + return cpfabs(joint->jAcc); } static const cpConstraintClass klass = { - (cpConstraintPreStepImpl)preStep, - (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, - (cpConstraintApplyImpulseImpl)applyImpulse, - (cpConstraintGetImpulseImpl)getImpulse, + (cpConstraintPreStepImpl)preStep, + (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, + (cpConstraintApplyImpulseImpl)applyImpulse, + (cpConstraintGetImpulseImpl)getImpulse, }; CP_DefineClassGetter(cpRotaryLimitJoint) cpRotaryLimitJoint * cpRotaryLimitJointAlloc(void) { - return (cpRotaryLimitJoint *)cpcalloc(1, sizeof(cpRotaryLimitJoint)); + return (cpRotaryLimitJoint *)cpcalloc(1, sizeof(cpRotaryLimitJoint)); } cpRotaryLimitJoint * cpRotaryLimitJointInit(cpRotaryLimitJoint *joint, cpBody *a, cpBody *b, cpFloat min, cpFloat max) { - cpConstraintInit((cpConstraint *)joint, &klass, a, b); - - joint->min = min; - joint->max = max; - - joint->jAcc = 0.0f; - - return joint; + cpConstraintInit((cpConstraint *)joint, &klass, a, b); + + joint->min = min; + joint->max = max; + + joint->jAcc = 0.0f; + + return joint; } cpConstraint * cpRotaryLimitJointNew(cpBody *a, cpBody *b, cpFloat min, cpFloat max) { - return (cpConstraint *)cpRotaryLimitJointInit(cpRotaryLimitJointAlloc(), a, b, min, max); + return (cpConstraint *)cpRotaryLimitJointInit(cpRotaryLimitJointAlloc(), a, b, min, max); } diff --git a/chipmunk/src/constraints/cpSimpleMotor.c b/chipmunk/src/constraints/cpSimpleMotor.c index ca32f8fa1c..92cc4cea0a 100644 --- a/chipmunk/src/constraints/cpSimpleMotor.c +++ b/chipmunk/src/constraints/cpSimpleMotor.c @@ -19,90 +19,87 @@ * SOFTWARE. */ -#include -#include - #include "chipmunk_private.h" #include "constraints/util.h" static void preStep(cpSimpleMotor *joint, cpFloat dt) { - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - // calculate moment of inertia coefficient. - joint->iSum = 1.0f/(a->i_inv + b->i_inv); - - // compute max impulse - joint->jMax = J_MAX(joint, dt); + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + + // calculate moment of inertia coefficient. + joint->iSum = 1.0f/(a->i_inv + b->i_inv); + + // compute max impulse + joint->jMax = J_MAX(joint, dt); } static void applyCachedImpulse(cpSimpleMotor *joint, cpFloat dt_coef) { - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - cpFloat j = joint->jAcc*dt_coef; - a->w -= j*a->i_inv; - b->w += j*b->i_inv; + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + + cpFloat j = joint->jAcc*dt_coef; + a->w -= j*a->i_inv; + b->w += j*b->i_inv; } static void applyImpulse(cpSimpleMotor *joint) { - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - // compute relative rotational velocity - cpFloat wr = b->w - a->w + joint->rate; - - // compute normal impulse - cpFloat j = -wr*joint->iSum; - cpFloat jOld = joint->jAcc; - joint->jAcc = cpfclamp(jOld + j, -joint->jMax, joint->jMax); - j = joint->jAcc - jOld; - - // apply impulse - a->w -= j*a->i_inv; - b->w += j*b->i_inv; + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + + // compute relative rotational velocity + cpFloat wr = b->w - a->w + joint->rate; + + // compute normal impulse + cpFloat j = -wr*joint->iSum; + cpFloat jOld = joint->jAcc; + joint->jAcc = cpfclamp(jOld + j, -joint->jMax, joint->jMax); + j = joint->jAcc - jOld; + + // apply impulse + a->w -= j*a->i_inv; + b->w += j*b->i_inv; } static cpFloat getImpulse(cpSimpleMotor *joint) { - return cpfabs(joint->jAcc); + return cpfabs(joint->jAcc); } static const cpConstraintClass klass = { - (cpConstraintPreStepImpl)preStep, - (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, - (cpConstraintApplyImpulseImpl)applyImpulse, - (cpConstraintGetImpulseImpl)getImpulse, + (cpConstraintPreStepImpl)preStep, + (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, + (cpConstraintApplyImpulseImpl)applyImpulse, + (cpConstraintGetImpulseImpl)getImpulse, }; CP_DefineClassGetter(cpSimpleMotor) cpSimpleMotor * cpSimpleMotorAlloc(void) { - return (cpSimpleMotor *)cpcalloc(1, sizeof(cpSimpleMotor)); + return (cpSimpleMotor *)cpcalloc(1, sizeof(cpSimpleMotor)); } cpSimpleMotor * cpSimpleMotorInit(cpSimpleMotor *joint, cpBody *a, cpBody *b, cpFloat rate) { - cpConstraintInit((cpConstraint *)joint, &klass, a, b); - - joint->rate = rate; - - joint->jAcc = 0.0f; - - return joint; + cpConstraintInit((cpConstraint *)joint, &klass, a, b); + + joint->rate = rate; + + joint->jAcc = 0.0f; + + return joint; } cpConstraint * cpSimpleMotorNew(cpBody *a, cpBody *b, cpFloat rate) { - return (cpConstraint *)cpSimpleMotorInit(cpSimpleMotorAlloc(), a, b, rate); + return (cpConstraint *)cpSimpleMotorInit(cpSimpleMotorAlloc(), a, b, rate); } diff --git a/chipmunk/src/constraints/cpSlideJoint.c b/chipmunk/src/constraints/cpSlideJoint.c index e3c9d2cafd..8a03832558 100644 --- a/chipmunk/src/constraints/cpSlideJoint.c +++ b/chipmunk/src/constraints/cpSlideJoint.c @@ -19,120 +19,116 @@ * SOFTWARE. */ -#include -#include - #include "chipmunk_private.h" #include "constraints/util.h" static void preStep(cpSlideJoint *joint, cpFloat dt) { - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - joint->r1 = cpvrotate(joint->anchr1, a->rot); - joint->r2 = cpvrotate(joint->anchr2, b->rot); - - cpVect delta = cpvsub(cpvadd(b->p, joint->r2), cpvadd(a->p, joint->r1)); - cpFloat dist = cpvlength(delta); - cpFloat pdist = 0.0f; - if(dist > joint->max) { - pdist = dist - joint->max; - joint->n = cpvnormalize_safe(delta); - } else if(dist < joint->min) { - pdist = joint->min - dist; - dist = -dist; - joint->n = cpvneg(cpvnormalize_safe(delta)); - } else { - joint->n = cpvzero; - joint->jnAcc = 0.0f; - } - - // calculate mass normal - joint->nMass = 1.0f/k_scalar(a, b, joint->r1, joint->r2, joint->n); - - // calculate bias velocity - cpFloat maxBias = joint->constraint.maxBias; - joint->bias = cpfclamp(-bias_coef(joint->constraint.errorBias, dt)*pdist/dt, -maxBias, maxBias); - - // compute max impulse - joint->jnMax = J_MAX(joint, dt); + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + + joint->r1 = cpvrotate(joint->anchr1, a->rot); + joint->r2 = cpvrotate(joint->anchr2, b->rot); + + cpVect delta = cpvsub(cpvadd(b->p, joint->r2), cpvadd(a->p, joint->r1)); + cpFloat dist = cpvlength(delta); + cpFloat pdist = 0.0f; + if(dist > joint->max) { + pdist = dist - joint->max; + joint->n = cpvnormalize_safe(delta); + } else if(dist < joint->min) { + pdist = joint->min - dist; + joint->n = cpvneg(cpvnormalize_safe(delta)); + } else { + joint->n = cpvzero; + joint->jnAcc = 0.0f; + } + + // calculate mass normal + joint->nMass = 1.0f/k_scalar(a, b, joint->r1, joint->r2, joint->n); + + // calculate bias velocity + cpFloat maxBias = joint->constraint.maxBias; + joint->bias = cpfclamp(-bias_coef(joint->constraint.errorBias, dt)*pdist/dt, -maxBias, maxBias); + + // compute max impulse + joint->jnMax = J_MAX(joint, dt); } static void applyCachedImpulse(cpSlideJoint *joint, cpFloat dt_coef) { - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - cpVect j = cpvmult(joint->n, joint->jnAcc*dt_coef); - apply_impulses(a, b, joint->r1, joint->r2, j); + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + + cpVect j = cpvmult(joint->n, joint->jnAcc*dt_coef); + apply_impulses(a, b, joint->r1, joint->r2, j); } static void applyImpulse(cpSlideJoint *joint) { - if(cpveql(joint->n, cpvzero)) return; // early exit + if(cpveql(joint->n, cpvzero)) return; // early exit - cpBody *a = joint->constraint.a; - cpBody *b = joint->constraint.b; - - cpVect n = joint->n; - cpVect r1 = joint->r1; - cpVect r2 = joint->r2; - - // compute relative velocity - cpVect vr = relative_velocity(a, b, r1, r2); - cpFloat vrn = cpvdot(vr, n); - - // compute normal impulse - cpFloat jn = (joint->bias - vrn)*joint->nMass; - cpFloat jnOld = joint->jnAcc; - joint->jnAcc = cpfclamp(jnOld + jn, -joint->jnMax, 0.0f); - jn = joint->jnAcc - jnOld; - - // apply impulse - apply_impulses(a, b, joint->r1, joint->r2, cpvmult(n, jn)); + cpBody *a = joint->constraint.a; + cpBody *b = joint->constraint.b; + + cpVect n = joint->n; + cpVect r1 = joint->r1; + cpVect r2 = joint->r2; + + // compute relative velocity + cpVect vr = relative_velocity(a, b, r1, r2); + cpFloat vrn = cpvdot(vr, n); + + // compute normal impulse + cpFloat jn = (joint->bias - vrn)*joint->nMass; + cpFloat jnOld = joint->jnAcc; + joint->jnAcc = cpfclamp(jnOld + jn, -joint->jnMax, 0.0f); + jn = joint->jnAcc - jnOld; + + // apply impulse + apply_impulses(a, b, joint->r1, joint->r2, cpvmult(n, jn)); } static cpFloat getImpulse(cpConstraint *joint) { - return cpfabs(((cpSlideJoint *)joint)->jnAcc); + return cpfabs(((cpSlideJoint *)joint)->jnAcc); } static const cpConstraintClass klass = { - (cpConstraintPreStepImpl)preStep, - (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, - (cpConstraintApplyImpulseImpl)applyImpulse, - (cpConstraintGetImpulseImpl)getImpulse, + (cpConstraintPreStepImpl)preStep, + (cpConstraintApplyCachedImpulseImpl)applyCachedImpulse, + (cpConstraintApplyImpulseImpl)applyImpulse, + (cpConstraintGetImpulseImpl)getImpulse, }; CP_DefineClassGetter(cpSlideJoint) cpSlideJoint * cpSlideJointAlloc(void) { - return (cpSlideJoint *)cpcalloc(1, sizeof(cpSlideJoint)); + return (cpSlideJoint *)cpcalloc(1, sizeof(cpSlideJoint)); } cpSlideJoint * cpSlideJointInit(cpSlideJoint *joint, cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat min, cpFloat max) { - cpConstraintInit((cpConstraint *)joint, &klass, a, b); - - joint->anchr1 = anchr1; - joint->anchr2 = anchr2; - joint->min = min; - joint->max = max; - - joint->jnAcc = 0.0f; - - return joint; + cpConstraintInit((cpConstraint *)joint, &klass, a, b); + + joint->anchr1 = anchr1; + joint->anchr2 = anchr2; + joint->min = min; + joint->max = max; + + joint->jnAcc = 0.0f; + + return joint; } cpConstraint * cpSlideJointNew(cpBody *a, cpBody *b, cpVect anchr1, cpVect anchr2, cpFloat min, cpFloat max) { - return (cpConstraint *)cpSlideJointInit(cpSlideJointAlloc(), a, b, anchr1, anchr2, min, max); + return (cpConstraint *)cpSlideJointInit(cpSlideJointAlloc(), a, b, anchr1, anchr2, min, max); } diff --git a/chipmunk/src/cpArbiter.c b/chipmunk/src/cpArbiter.c index 6f72ac6fe1..01fcf3c993 100644 --- a/chipmunk/src/cpArbiter.c +++ b/chipmunk/src/cpArbiter.c @@ -19,273 +19,281 @@ * SOFTWARE. */ -#include -#include - #include "chipmunk_private.h" #include "constraints/util.h" cpContact* cpContactInit(cpContact *con, cpVect p, cpVect n, cpFloat dist, cpHashValue hash) { - con->p = p; - con->n = n; - con->dist = dist; - - con->jnAcc = 0.0f; - con->jtAcc = 0.0f; - con->jBias = 0.0f; - - con->hash = hash; - - return con; + con->p = p; + con->n = n; + con->dist = dist; + + con->jnAcc = 0.0f; + con->jtAcc = 0.0f; + con->jBias = 0.0f; + + con->hash = hash; + + return con; } // TODO make this generic so I can reuse it for constraints also. static inline void unthreadHelper(cpArbiter *arb, cpBody *body) { - struct cpArbiterThread *thread = cpArbiterThreadForBody(arb, body); - cpArbiter *prev = thread->prev; - cpArbiter *next = thread->next; - - if(prev){ - cpArbiterThreadForBody(prev, body)->next = next; - } else { - body->arbiterList = next; - } - - if(next) cpArbiterThreadForBody(next, body)->prev = prev; - - thread->prev = NULL; - thread->next = NULL; + struct cpArbiterThread *thread = cpArbiterThreadForBody(arb, body); + cpArbiter *prev = thread->prev; + cpArbiter *next = thread->next; + + if(prev){ + cpArbiterThreadForBody(prev, body)->next = next; + } else { + body->arbiterList = next; + } + + if(next) cpArbiterThreadForBody(next, body)->prev = prev; + + thread->prev = NULL; + thread->next = NULL; } void cpArbiterUnthread(cpArbiter *arb) { - unthreadHelper(arb, arb->body_a); - unthreadHelper(arb, arb->body_b); + unthreadHelper(arb, arb->body_a); + unthreadHelper(arb, arb->body_b); +} + +cpBool cpArbiterIsFirstContact(const cpArbiter *arb) +{ + return arb->CP_PRIVATE(state) == cpArbiterStateFirstColl; +} + +int cpArbiterGetCount(const cpArbiter *arb) +{ + // Return 0 contacts if we are in a separate callback. + return (arb->CP_PRIVATE(state) != cpArbiterStateCached ? arb->CP_PRIVATE(numContacts) : 0); } cpVect cpArbiterGetNormal(const cpArbiter *arb, int i) { - cpAssertHard(0 <= i && i < arb->numContacts, "Index error: The specified contact index is invalid for this arbiter"); - - cpVect n = arb->contacts[i].n; - return arb->swappedColl ? cpvneg(n) : n; + cpAssertHard(0 <= i && i < cpArbiterGetCount(arb), "Index error: The specified contact index is invalid for this arbiter"); + + cpVect n = arb->contacts[i].n; + return arb->swappedColl ? cpvneg(n) : n; } cpVect cpArbiterGetPoint(const cpArbiter *arb, int i) { - cpAssertHard(0 <= i && i < arb->numContacts, "Index error: The specified contact index is invalid for this arbiter"); - - return arb->CP_PRIVATE(contacts)[i].CP_PRIVATE(p); + cpAssertHard(0 <= i && i < cpArbiterGetCount(arb), "Index error: The specified contact index is invalid for this arbiter"); + + return arb->CP_PRIVATE(contacts)[i].CP_PRIVATE(p); } cpFloat cpArbiterGetDepth(const cpArbiter *arb, int i) { - cpAssertHard(0 <= i && i < arb->numContacts, "Index error: The specified contact index is invalid for this arbiter"); - - return arb->CP_PRIVATE(contacts)[i].CP_PRIVATE(dist); + cpAssertHard(0 <= i && i < cpArbiterGetCount(arb), "Index error: The specified contact index is invalid for this arbiter"); + + return arb->CP_PRIVATE(contacts)[i].CP_PRIVATE(dist); } cpContactPointSet cpArbiterGetContactPointSet(const cpArbiter *arb) { - cpContactPointSet set; - set.count = cpArbiterGetCount(arb); - - int i; - for(i=0; iCP_PRIVATE(contacts)[i].CP_PRIVATE(p); - set.points[i].normal = arb->CP_PRIVATE(contacts)[i].CP_PRIVATE(n); - set.points[i].dist = arb->CP_PRIVATE(contacts)[i].CP_PRIVATE(dist); - } - - return set; + cpContactPointSet set; + set.count = cpArbiterGetCount(arb); + + int i; + for(i=0; iCP_PRIVATE(contacts)[i].CP_PRIVATE(p); + set.points[i].normal = arb->CP_PRIVATE(contacts)[i].CP_PRIVATE(n); + set.points[i].dist = arb->CP_PRIVATE(contacts)[i].CP_PRIVATE(dist); + } + + return set; } cpVect cpArbiterTotalImpulse(const cpArbiter *arb) { - cpContact *contacts = arb->contacts; - cpVect sum = cpvzero; - - for(int i=0, count=arb->numContacts; in, con->jnAcc)); - } - - return (arb->swappedColl ? sum : cpvneg(sum)); + cpContact *contacts = arb->contacts; + cpVect sum = cpvzero; + + for(int i=0, count=cpArbiterGetCount(arb); in, con->jnAcc)); + } + + return (arb->swappedColl ? sum : cpvneg(sum)); } cpVect cpArbiterTotalImpulseWithFriction(const cpArbiter *arb) { - cpContact *contacts = arb->contacts; - cpVect sum = cpvzero; - - for(int i=0, count=arb->numContacts; in, cpv(con->jnAcc, con->jtAcc))); - } - - return (arb->swappedColl ? sum : cpvneg(sum)); + cpContact *contacts = arb->contacts; + cpVect sum = cpvzero; + + for(int i=0, count=cpArbiterGetCount(arb); in, cpv(con->jnAcc, con->jtAcc))); + } + + return (arb->swappedColl ? sum : cpvneg(sum)); } cpFloat cpArbiterTotalKE(const cpArbiter *arb) { - cpFloat eCoef = (1 - arb->e)/(1 + arb->e); - cpFloat sum = 0.0; - - cpContact *contacts = arb->contacts; - for(int i=0, count=arb->numContacts; ijnAcc; - cpFloat jtAcc = con->jtAcc; - - sum += eCoef*jnAcc*jnAcc/con->nMass + jtAcc*jtAcc/con->tMass; - } - - return sum; + cpFloat eCoef = (1 - arb->e)/(1 + arb->e); + cpFloat sum = 0.0; + + cpContact *contacts = arb->contacts; + for(int i=0, count=cpArbiterGetCount(arb); ijnAcc; + cpFloat jtAcc = con->jtAcc; + + sum += eCoef*jnAcc*jnAcc/con->nMass + jtAcc*jtAcc/con->tMass; + } + + return sum; } //cpFloat //cpContactsEstimateCrushingImpulse(cpContact *contacts, int numContacts) //{ -// cpFloat fsum = 0.0f; -// cpVect vsum = cpvzero; -// -// for(int i=0; in, cpv(con->jnAcc, con->jtAcc)); -// -// fsum += cpvlength(j); -// vsum = cpvadd(vsum, j); -// } -// -// cpFloat vmag = cpvlength(vsum); -// return (1.0f - vmag/fsum); +// cpFloat fsum = 0.0f; +// cpVect vsum = cpvzero; +// +// for(int i=0; in, cpv(con->jnAcc, con->jtAcc)); +// +// fsum += cpvlength(j); +// vsum = cpvadd(vsum, j); +// } +// +// cpFloat vmag = cpvlength(vsum); +// return (1.0f - vmag/fsum); //} void cpArbiterIgnore(cpArbiter *arb) { - arb->state = cpArbiterStateIgnore; + arb->state = cpArbiterStateIgnore; } cpArbiter* cpArbiterInit(cpArbiter *arb, cpShape *a, cpShape *b) { - arb->handler = NULL; - arb->swappedColl = cpFalse; - - arb->e = 0.0f; - arb->u = 0.0f; - arb->surface_vr = cpvzero; - - arb->numContacts = 0; - arb->contacts = NULL; - - arb->a = a; arb->body_a = a->body; - arb->b = b; arb->body_b = b->body; - - arb->thread_a.next = NULL; - arb->thread_b.next = NULL; - arb->thread_a.prev = NULL; - arb->thread_b.prev = NULL; - - arb->stamp = 0; - arb->state = cpArbiterStateFirstColl; - - return arb; + arb->handler = NULL; + arb->swappedColl = cpFalse; + + arb->e = 0.0f; + arb->u = 0.0f; + arb->surface_vr = cpvzero; + + arb->numContacts = 0; + arb->contacts = NULL; + + arb->a = a; arb->body_a = a->body; + arb->b = b; arb->body_b = b->body; + + arb->thread_a.next = NULL; + arb->thread_b.next = NULL; + arb->thread_a.prev = NULL; + arb->thread_b.prev = NULL; + + arb->stamp = 0; + arb->state = cpArbiterStateFirstColl; + + return arb; } void cpArbiterUpdate(cpArbiter *arb, cpContact *contacts, int numContacts, cpCollisionHandler *handler, cpShape *a, cpShape *b) { - // Arbiters without contact data may exist if a collision function rejected the collision. - if(arb->contacts){ - // Iterate over the possible pairs to look for hash value matches. - for(int i=0; inumContacts; i++){ - cpContact *old = &arb->contacts[i]; - - for(int j=0; jhash == old->hash){ - // Copy the persistant contact information. - new_contact->jnAcc = old->jnAcc; - new_contact->jtAcc = old->jtAcc; - } - } - } - } - - arb->contacts = contacts; - arb->numContacts = numContacts; - - arb->handler = handler; - arb->swappedColl = (a->collision_type != handler->a); - - arb->e = a->e * b->e; - arb->u = a->u * b->u; - arb->surface_vr = cpvsub(a->surface_v, b->surface_v); - - // For collisions between two similar primitive types, the order could have been swapped. - arb->a = a; arb->body_a = a->body; - arb->b = b; arb->body_b = b->body; - - // mark it as new if it's been cached - if(arb->state == cpArbiterStateCached) arb->state = cpArbiterStateFirstColl; + // Arbiters without contact data may exist if a collision function rejected the collision. + if(arb->contacts){ + // Iterate over the possible pairs to look for hash value matches. + for(int i=0; inumContacts; i++){ + cpContact *old = &arb->contacts[i]; + + for(int j=0; jhash == old->hash){ + // Copy the persistant contact information. + new_contact->jnAcc = old->jnAcc; + new_contact->jtAcc = old->jtAcc; + } + } + } + } + + arb->contacts = contacts; + arb->numContacts = numContacts; + + arb->handler = handler; + arb->swappedColl = (a->collision_type != handler->a); + + arb->e = a->e * b->e; + arb->u = a->u * b->u; + arb->surface_vr = cpvsub(a->surface_v, b->surface_v); + + // For collisions between two similar primitive types, the order could have been swapped. + arb->a = a; arb->body_a = a->body; + arb->b = b; arb->body_b = b->body; + + // mark it as new if it's been cached + if(arb->state == cpArbiterStateCached) arb->state = cpArbiterStateFirstColl; } void cpArbiterPreStep(cpArbiter *arb, cpFloat dt, cpFloat slop, cpFloat bias) { - cpBody *a = arb->body_a; - cpBody *b = arb->body_b; - - for(int i=0; inumContacts; i++){ - cpContact *con = &arb->contacts[i]; - - // Calculate the offsets. - con->r1 = cpvsub(con->p, a->p); - con->r2 = cpvsub(con->p, b->p); - - // Calculate the mass normal and mass tangent. - con->nMass = 1.0f/k_scalar(a, b, con->r1, con->r2, con->n); - con->tMass = 1.0f/k_scalar(a, b, con->r1, con->r2, cpvperp(con->n)); - - // Calculate the target bias velocity. - con->bias = -bias*cpfmin(0.0f, con->dist + slop)/dt; - con->jBias = 0.0f; - - // Calculate the target bounce velocity. - con->bounce = normal_relative_velocity(a, b, con->r1, con->r2, con->n)*arb->e; - } + cpBody *a = arb->body_a; + cpBody *b = arb->body_b; + + for(int i=0; inumContacts; i++){ + cpContact *con = &arb->contacts[i]; + + // Calculate the offsets. + con->r1 = cpvsub(con->p, a->p); + con->r2 = cpvsub(con->p, b->p); + + // Calculate the mass normal and mass tangent. + con->nMass = 1.0f/k_scalar(a, b, con->r1, con->r2, con->n); + con->tMass = 1.0f/k_scalar(a, b, con->r1, con->r2, cpvperp(con->n)); + + // Calculate the target bias velocity. + con->bias = -bias*cpfmin(0.0f, con->dist + slop)/dt; + con->jBias = 0.0f; + + // Calculate the target bounce velocity. + con->bounce = normal_relative_velocity(a, b, con->r1, con->r2, con->n)*arb->e; + } } void cpArbiterApplyCachedImpulse(cpArbiter *arb, cpFloat dt_coef) { - if(cpArbiterIsFirstContact(arb)) return; - - cpBody *a = arb->body_a; - cpBody *b = arb->body_b; - - for(int i=0; inumContacts; i++){ - cpContact *con = &arb->contacts[i]; - cpVect j = cpvrotate(con->n, cpv(con->jnAcc, con->jtAcc)); - apply_impulses(a, b, con->r1, con->r2, cpvmult(j, dt_coef)); - } + if(cpArbiterIsFirstContact(arb)) return; + + cpBody *a = arb->body_a; + cpBody *b = arb->body_b; + + for(int i=0; inumContacts; i++){ + cpContact *con = &arb->contacts[i]; + cpVect j = cpvrotate(con->n, cpv(con->jnAcc, con->jtAcc)); + apply_impulses(a, b, con->r1, con->r2, cpvmult(j, dt_coef)); + } } // TODO is it worth splitting velocity/position correction? @@ -293,40 +301,40 @@ cpArbiterApplyCachedImpulse(cpArbiter *arb, cpFloat dt_coef) void cpArbiterApplyImpulse(cpArbiter *arb) { - cpBody *a = arb->body_a; - cpBody *b = arb->body_b; - cpVect surface_vr = arb->surface_vr; - cpFloat friction = arb->u; + cpBody *a = arb->body_a; + cpBody *b = arb->body_b; + cpVect surface_vr = arb->surface_vr; + cpFloat friction = arb->u; - for(int i=0; inumContacts; i++){ - cpContact *con = &arb->contacts[i]; - cpFloat nMass = con->nMass; - cpVect n = con->n; - cpVect r1 = con->r1; - cpVect r2 = con->r2; - - cpVect vb1 = cpvadd(a->v_bias, cpvmult(cpvperp(r1), a->w_bias)); - cpVect vb2 = cpvadd(b->v_bias, cpvmult(cpvperp(r2), b->w_bias)); - cpVect vr = relative_velocity(a, b, r1, r2); - - cpFloat vbn = cpvdot(cpvsub(vb2, vb1), n); - cpFloat vrn = cpvdot(vr, n); - cpFloat vrt = cpvdot(cpvadd(vr, surface_vr), cpvperp(n)); - - cpFloat jbn = (con->bias - vbn)*nMass; - cpFloat jbnOld = con->jBias; - con->jBias = cpfmax(jbnOld + jbn, 0.0f); - - cpFloat jn = -(con->bounce + vrn)*nMass; - cpFloat jnOld = con->jnAcc; - con->jnAcc = cpfmax(jnOld + jn, 0.0f); - - cpFloat jtMax = friction*con->jnAcc; - cpFloat jt = -vrt*con->tMass; - cpFloat jtOld = con->jtAcc; - con->jtAcc = cpfclamp(jtOld + jt, -jtMax, jtMax); - - apply_bias_impulses(a, b, r1, r2, cpvmult(n, con->jBias - jbnOld)); - apply_impulses(a, b, r1, r2, cpvrotate(n, cpv(con->jnAcc - jnOld, con->jtAcc - jtOld))); - } + for(int i=0; inumContacts; i++){ + cpContact *con = &arb->contacts[i]; + cpFloat nMass = con->nMass; + cpVect n = con->n; + cpVect r1 = con->r1; + cpVect r2 = con->r2; + + cpVect vb1 = cpvadd(a->v_bias, cpvmult(cpvperp(r1), a->w_bias)); + cpVect vb2 = cpvadd(b->v_bias, cpvmult(cpvperp(r2), b->w_bias)); + cpVect vr = relative_velocity(a, b, r1, r2); + + cpFloat vbn = cpvdot(cpvsub(vb2, vb1), n); + cpFloat vrn = cpvdot(vr, n); + cpFloat vrt = cpvdot(cpvadd(vr, surface_vr), cpvperp(n)); + + cpFloat jbn = (con->bias - vbn)*nMass; + cpFloat jbnOld = con->jBias; + con->jBias = cpfmax(jbnOld + jbn, 0.0f); + + cpFloat jn = -(con->bounce + vrn)*nMass; + cpFloat jnOld = con->jnAcc; + con->jnAcc = cpfmax(jnOld + jn, 0.0f); + + cpFloat jtMax = friction*con->jnAcc; + cpFloat jt = -vrt*con->tMass; + cpFloat jtOld = con->jtAcc; + con->jtAcc = cpfclamp(jtOld + jt, -jtMax, jtMax); + + apply_bias_impulses(a, b, r1, r2, cpvmult(n, con->jBias - jbnOld)); + apply_impulses(a, b, r1, r2, cpvrotate(n, cpv(con->jnAcc - jnOld, con->jtAcc - jtOld))); + } } diff --git a/chipmunk/src/cpArray.c b/chipmunk/src/cpArray.c index 1cad553f0f..d944fd1102 100644 --- a/chipmunk/src/cpArray.c +++ b/chipmunk/src/cpArray.c @@ -19,7 +19,6 @@ * SOFTWARE. */ -#include #include #include "chipmunk_private.h" @@ -28,98 +27,98 @@ cpArray * cpArrayNew(int size) { - cpArray *arr = (cpArray *)cpcalloc(1, sizeof(cpArray)); - - arr->num = 0; - arr->max = (size ? size : 4); - arr->arr = (void **)cpcalloc(arr->max, sizeof(void**)); - - return arr; + cpArray *arr = (cpArray *)cpcalloc(1, sizeof(cpArray)); + + arr->num = 0; + arr->max = (size ? size : 4); + arr->arr = (void **)cpcalloc(arr->max, sizeof(void**)); + + return arr; } void cpArrayFree(cpArray *arr) { - if(arr){ - cpfree(arr->arr); - arr->arr = NULL; - - cpfree(arr); - } + if(arr){ + cpfree(arr->arr); + arr->arr = NULL; + + cpfree(arr); + } } void cpArrayPush(cpArray *arr, void *object) { - if(arr->num == arr->max){ - arr->max *= 2; - arr->arr = (void **)cprealloc(arr->arr, arr->max*sizeof(void**)); - } - - arr->arr[arr->num] = object; - arr->num++; + if(arr->num == arr->max){ + arr->max *= 2; + arr->arr = (void **)cprealloc(arr->arr, arr->max*sizeof(void**)); + } + + arr->arr[arr->num] = object; + arr->num++; } void * cpArrayPop(cpArray *arr) { - arr->num--; - - void *value = arr->arr[arr->num]; - arr->arr[arr->num] = NULL; - - return value; + arr->num--; + + void *value = arr->arr[arr->num]; + arr->arr[arr->num] = NULL; + + return value; } //static void //cpArrayDeleteIndex(cpArray *arr, int idx) //{ -// arr->num--; -// -// arr->arr[idx] = arr->arr[arr->num]; -// arr->arr[arr->num] = NULL; +// arr->num--; +// +// arr->arr[idx] = arr->arr[arr->num]; +// arr->arr[arr->num] = NULL; //} void cpArrayDeleteObj(cpArray *arr, void *obj) { - for(int i=0; inum; i++){ - if(arr->arr[i] == obj){ - arr->num--; - - arr->arr[i] = arr->arr[arr->num]; - arr->arr[arr->num] = NULL; - - return; - } - } + for(int i=0; inum; i++){ + if(arr->arr[i] == obj){ + arr->num--; + + arr->arr[i] = arr->arr[arr->num]; + arr->arr[arr->num] = NULL; + + return; + } + } } //void //cpArrayAppend(cpArray *arr, cpArray *other) //{ -// void *tail = &arr->arr[arr->num]; -// -// arr->num += other->num; -// if(arr->num >= arr->max){ -// arr->max = arr->num; -// arr->arr = (void **)cprealloc(arr->arr, arr->max*sizeof(void**)); -// } -// -// memcpy(tail, other->arr, other->num*sizeof(void**)); +// void *tail = &arr->arr[arr->num]; +// +// arr->num += other->num; +// if(arr->num >= arr->max){ +// arr->max = arr->num; +// arr->arr = (void **)cprealloc(arr->arr, arr->max*sizeof(void**)); +// } +// +// memcpy(tail, other->arr, other->num*sizeof(void**)); //} void cpArrayFreeEach(cpArray *arr, void (freeFunc)(void*)) { - for(int i=0; inum; i++) freeFunc(arr->arr[i]); + for(int i=0; inum; i++) freeFunc(arr->arr[i]); } cpBool cpArrayContains(cpArray *arr, void *ptr) { - for(int i=0; inum; i++) - if(arr->arr[i] == ptr) return cpTrue; - - return cpFalse; + for(int i=0; inum; i++) + if(arr->arr[i] == ptr) return cpTrue; + + return cpFalse; } diff --git a/chipmunk/src/cpBB.c b/chipmunk/src/cpBB.c index 2bc9a7b949..ef05e0384b 100644 --- a/chipmunk/src/cpBB.c +++ b/chipmunk/src/cpBB.c @@ -19,29 +19,26 @@ * SOFTWARE. */ -#include -#include - #include "chipmunk_private.h" cpVect cpBBClampVect(const cpBB bb, const cpVect v) { - cpFloat x = cpfmin(cpfmax(bb.l, v.x), bb.r); - cpFloat y = cpfmin(cpfmax(bb.b, v.y), bb.t); - return cpv(x, y); + cpFloat x = cpfmin(cpfmax(bb.l, v.x), bb.r); + cpFloat y = cpfmin(cpfmax(bb.b, v.y), bb.t); + return cpv(x, y); } cpVect cpBBWrapVect(const cpBB bb, const cpVect v) { - cpFloat ix = cpfabs(bb.r - bb.l); - cpFloat modx = cpfmod(v.x - bb.l, ix); - cpFloat x = (modx > 0.0f) ? modx : modx + ix; - - cpFloat iy = cpfabs(bb.t - bb.b); - cpFloat mody = cpfmod(v.y - bb.b, iy); - cpFloat y = (mody > 0.0f) ? mody : mody + iy; - - return cpv(x + bb.l, y + bb.b); + cpFloat ix = cpfabs(bb.r - bb.l); + cpFloat modx = cpfmod(v.x - bb.l, ix); + cpFloat x = (modx > 0.0f) ? modx : modx + ix; + + cpFloat iy = cpfabs(bb.t - bb.b); + cpFloat mody = cpfmod(v.y - bb.b, iy); + cpFloat y = (mody > 0.0f) ? mody : mody + iy; + + return cpv(x + bb.l, y + bb.b); } diff --git a/chipmunk/src/cpBBTree.c b/chipmunk/src/cpBBTree.c index 03e3892149..f379d343bb 100644 --- a/chipmunk/src/cpBBTree.c +++ b/chipmunk/src/cpBBTree.c @@ -30,34 +30,34 @@ typedef struct Node Node; typedef struct Pair Pair; struct cpBBTree { - cpSpatialIndex spatialIndex; - cpBBTreeVelocityFunc velocityFunc; - - cpHashSet *leaves; - Node *root; - - Node *pooledNodes; - Pair *pooledPairs; - cpArray *allocatedBuffers; - - cpTimestamp stamp; + cpSpatialIndex spatialIndex; + cpBBTreeVelocityFunc velocityFunc; + + cpHashSet *leaves; + Node *root; + + Node *pooledNodes; + Pair *pooledPairs; + cpArray *allocatedBuffers; + + cpTimestamp stamp; }; struct Node { - void *obj; - cpBB bb; - Node *parent; - - union { - // Internal nodes - struct { Node *a, *b; } children; - - // Leaves - struct { - cpTimestamp stamp; - Pair *pairs; - } leaf; - } node; + void *obj; + cpBB bb; + Node *parent; + + union { + // Internal nodes + struct { Node *a, *b; } children; + + // Leaves + struct { + cpTimestamp stamp; + Pair *pairs; + } leaf; + } node; }; // Can't use anonymous unions and still get good x-compiler compatability @@ -67,9 +67,9 @@ struct Node { #define PAIRS node.leaf.pairs typedef struct Thread { - Pair *prev; - Node *leaf; - Pair *next; + Pair *prev; + Node *leaf; + Pair *next; } Thread; struct Pair { Thread a, b; }; @@ -79,48 +79,48 @@ struct Pair { Thread a, b; }; static inline cpBB GetBB(cpBBTree *tree, void *obj) { - cpBB bb = tree->spatialIndex.bbfunc(obj); - - cpBBTreeVelocityFunc velocityFunc = tree->velocityFunc; - if(velocityFunc){ - cpFloat coef = 0.1f; - cpFloat x = (bb.r - bb.l)*coef; - cpFloat y = (bb.t - bb.b)*coef; - - cpVect v = cpvmult(velocityFunc(obj), 0.1f); - return cpBBNew(bb.l + cpfmin(-x, v.x), bb.b + cpfmin(-y, v.y), bb.r + cpfmax(x, v.x), bb.t + cpfmax(y, v.y)); - } else { - return bb; - } + cpBB bb = tree->spatialIndex.bbfunc(obj); + + cpBBTreeVelocityFunc velocityFunc = tree->velocityFunc; + if(velocityFunc){ + cpFloat coef = 0.1f; + cpFloat x = (bb.r - bb.l)*coef; + cpFloat y = (bb.t - bb.b)*coef; + + cpVect v = cpvmult(velocityFunc(obj), 0.1f); + return cpBBNew(bb.l + cpfmin(-x, v.x), bb.b + cpfmin(-y, v.y), bb.r + cpfmax(x, v.x), bb.t + cpfmax(y, v.y)); + } else { + return bb; + } } static inline cpBBTree * GetTree(cpSpatialIndex *index) { - return (index && index->klass == Klass() ? (cpBBTree *)index : NULL); + return (index && index->klass == Klass() ? (cpBBTree *)index : NULL); } static inline Node * GetRootIfTree(cpSpatialIndex *index){ - return (index && index->klass == Klass() ? ((cpBBTree *)index)->root : NULL); + return (index && index->klass == Klass() ? ((cpBBTree *)index)->root : NULL); } static inline cpTimestamp GetStamp(cpBBTree *tree) { - cpBBTree *dynamicTree = GetTree(tree->spatialIndex.dynamicIndex); - return (dynamicTree ? dynamicTree->stamp : tree->stamp); + cpBBTree *dynamicTree = GetTree(tree->spatialIndex.dynamicIndex); + return (dynamicTree ? dynamicTree->stamp : tree->stamp); } static inline void IncrementStamp(cpBBTree *tree) { - cpBBTree *dynamicTree = GetTree(tree->spatialIndex.dynamicIndex); - if(dynamicTree){ - dynamicTree->stamp++; - } else { - tree->stamp++; - } + cpBBTree *dynamicTree = GetTree(tree->spatialIndex.dynamicIndex); + if(dynamicTree){ + dynamicTree->stamp++; + } else { + tree->stamp++; + } } //MARK: Pair/Thread Functions @@ -128,87 +128,87 @@ IncrementStamp(cpBBTree *tree) static void PairRecycle(cpBBTree *tree, Pair *pair) { - pair->a.next = tree->pooledPairs; - tree->pooledPairs = pair; + pair->a.next = tree->pooledPairs; + tree->pooledPairs = pair; } static Pair * PairFromPool(cpBBTree *tree) { - Pair *pair = tree->pooledPairs; - - if(pair){ - tree->pooledPairs = pair->a.next; - return pair; - } else { - // Pool is exhausted, make more - int count = CP_BUFFER_BYTES/sizeof(Pair); - cpAssertHard(count, "Internal Error: Buffer size is too small."); - - Pair *buffer = (Pair *)cpcalloc(1, CP_BUFFER_BYTES); - cpArrayPush(tree->allocatedBuffers, buffer); - - // push all but the first one, return the first instead - for(int i=1; ipooledPairs; + + if(pair){ + tree->pooledPairs = pair->a.next; + return pair; + } else { + // Pool is exhausted, make more + int count = CP_BUFFER_BYTES/sizeof(Pair); + cpAssertHard(count, "Internal Error: Buffer size is too small."); + + Pair *buffer = (Pair *)cpcalloc(1, CP_BUFFER_BYTES); + cpArrayPush(tree->allocatedBuffers, buffer); + + // push all but the first one, return the first instead + for(int i=1; ia.leaf == thread.leaf) next->a.prev = prev; else next->b.prev = prev; - } - - if(prev){ - if(prev->a.leaf == thread.leaf) prev->a.next = next; else prev->b.next = next; - } else { - thread.leaf->PAIRS = next; - } + Pair *next = thread.next; + Pair *prev = thread.prev; + + if(next){ + if(next->a.leaf == thread.leaf) next->a.prev = prev; else next->b.prev = prev; + } + + if(prev){ + if(prev->a.leaf == thread.leaf) prev->a.next = next; else prev->b.next = next; + } else { + thread.leaf->PAIRS = next; + } } static void PairsClear(Node *leaf, cpBBTree *tree) { - Pair *pair = leaf->PAIRS; - leaf->PAIRS = NULL; - - while(pair){ - if(pair->a.leaf == leaf){ - Pair *next = pair->a.next; - ThreadUnlink(pair->b); - PairRecycle(tree, pair); - pair = next; - } else { - Pair *next = pair->b.next; - ThreadUnlink(pair->a); - PairRecycle(tree, pair); - pair = next; - } - } + Pair *pair = leaf->PAIRS; + leaf->PAIRS = NULL; + + while(pair){ + if(pair->a.leaf == leaf){ + Pair *next = pair->a.next; + ThreadUnlink(pair->b); + PairRecycle(tree, pair); + pair = next; + } else { + Pair *next = pair->b.next; + ThreadUnlink(pair->a); + PairRecycle(tree, pair); + pair = next; + } + } } static void PairInsert(Node *a, Node *b, cpBBTree *tree) { - Pair *nextA = a->PAIRS, *nextB = b->PAIRS; - Pair *pair = PairFromPool(tree); - Pair temp = {{NULL, a, nextA},{NULL, b, nextB}}; - - a->PAIRS = b->PAIRS = pair; - *pair = temp; - - if(nextA){ - if(nextA->a.leaf == a) nextA->a.prev = pair; else nextA->b.prev = pair; - } - - if(nextB){ - if(nextB->a.leaf == b) nextB->a.prev = pair; else nextB->b.prev = pair; - } + Pair *nextA = a->PAIRS, *nextB = b->PAIRS; + Pair *pair = PairFromPool(tree); + Pair temp = {{NULL, a, nextA},{NULL, b, nextB}}; + + a->PAIRS = b->PAIRS = pair; + *pair = temp; + + if(nextA){ + if(nextA->a.leaf == a) nextA->a.prev = pair; else nextA->b.prev = pair; + } + + if(nextB){ + if(nextB->a.leaf == b) nextB->a.prev = pair; else nextB->b.prev = pair; + } } @@ -217,90 +217,90 @@ PairInsert(Node *a, Node *b, cpBBTree *tree) static void NodeRecycle(cpBBTree *tree, Node *node) { - node->parent = tree->pooledNodes; - tree->pooledNodes = node; + node->parent = tree->pooledNodes; + tree->pooledNodes = node; } static Node * NodeFromPool(cpBBTree *tree) { - Node *node = tree->pooledNodes; - - if(node){ - tree->pooledNodes = node->parent; - return node; - } else { - // Pool is exhausted, make more - int count = CP_BUFFER_BYTES/sizeof(Node); - cpAssertHard(count, "Internal Error: Buffer size is too small."); - - Node *buffer = (Node *)cpcalloc(1, CP_BUFFER_BYTES); - cpArrayPush(tree->allocatedBuffers, buffer); - - // push all but the first one, return the first instead - for(int i=1; ipooledNodes; + + if(node){ + tree->pooledNodes = node->parent; + return node; + } else { + // Pool is exhausted, make more + int count = CP_BUFFER_BYTES/sizeof(Node); + cpAssertHard(count, "Internal Error: Buffer size is too small."); + + Node *buffer = (Node *)cpcalloc(1, CP_BUFFER_BYTES); + cpArrayPush(tree->allocatedBuffers, buffer); + + // push all but the first one, return the first instead + for(int i=1; iA = value; - value->parent = node; + node->A = value; + value->parent = node; } static inline void NodeSetB(Node *node, Node *value) { - node->B = value; - value->parent = node; + node->B = value; + value->parent = node; } static Node * NodeNew(cpBBTree *tree, Node *a, Node *b) { - Node *node = NodeFromPool(tree); - - node->obj = NULL; - node->bb = cpBBMerge(a->bb, b->bb); - node->parent = NULL; - - NodeSetA(node, a); - NodeSetB(node, b); - - return node; + Node *node = NodeFromPool(tree); + + node->obj = NULL; + node->bb = cpBBMerge(a->bb, b->bb); + node->parent = NULL; + + NodeSetA(node, a); + NodeSetB(node, b); + + return node; } static inline cpBool NodeIsLeaf(Node *node) { - return (node->obj != NULL); + return (node->obj != NULL); } static inline Node * NodeOther(Node *node, Node *child) { - return (node->A == child ? node->B : node->A); + return (node->A == child ? node->B : node->A); } static inline void NodeReplaceChild(Node *parent, Node *child, Node *value, cpBBTree *tree) { - cpAssertSoft(!NodeIsLeaf(parent), "Internal Error: Cannot replace child of a leaf."); - cpAssertSoft(child == parent->A || child == parent->B, "Internal Error: Node is not a child of parent."); - - if(parent->A == child){ - NodeRecycle(tree, parent->A); - NodeSetA(parent, value); - } else { - NodeRecycle(tree, parent->B); - NodeSetB(parent, value); - } - - for(Node *node=parent; node; node = node->parent){ - node->bb = cpBBMerge(node->A->bb, node->B->bb); - } + cpAssertSoft(!NodeIsLeaf(parent), "Internal Error: Cannot replace child of a leaf."); + cpAssertSoft(child == parent->A || child == parent->B, "Internal Error: Node is not a child of parent."); + + if(parent->A == child){ + NodeRecycle(tree, parent->A); + NodeSetA(parent, value); + } else { + NodeRecycle(tree, parent->B); + NodeSetB(parent, value); + } + + for(Node *node=parent; node; node = node->parent){ + node->bb = cpBBMerge(node->A->bb, node->B->bb); + } } //MARK: Subtree Functions @@ -308,164 +308,164 @@ NodeReplaceChild(Node *parent, Node *child, Node *value, cpBBTree *tree) static inline cpFloat cpBBProximity(cpBB a, cpBB b) { - return cpfabs(a.l + a.r - b.l - b.r) + cpfabs(a.b + b.t - b.b - b.t); + return cpfabs(a.l + a.r - b.l - b.r) + cpfabs(a.b + a.t - b.b - b.t); } static Node * SubtreeInsert(Node *subtree, Node *leaf, cpBBTree *tree) { - if(subtree == NULL){ - return leaf; - } else if(NodeIsLeaf(subtree)){ - return NodeNew(tree, leaf, subtree); - } else { - cpFloat cost_a = cpBBArea(subtree->B->bb) + cpBBMergedArea(subtree->A->bb, leaf->bb); - cpFloat cost_b = cpBBArea(subtree->A->bb) + cpBBMergedArea(subtree->B->bb, leaf->bb); - - if(cost_a == cost_b){ - cost_a = cpBBProximity(subtree->A->bb, leaf->bb); - cost_b = cpBBProximity(subtree->B->bb, leaf->bb); - } - - if(cost_b < cost_a){ - NodeSetB(subtree, SubtreeInsert(subtree->B, leaf, tree)); - } else { - NodeSetA(subtree, SubtreeInsert(subtree->A, leaf, tree)); - } - - subtree->bb = cpBBMerge(subtree->bb, leaf->bb); - return subtree; - } + if(subtree == NULL){ + return leaf; + } else if(NodeIsLeaf(subtree)){ + return NodeNew(tree, leaf, subtree); + } else { + cpFloat cost_a = cpBBArea(subtree->B->bb) + cpBBMergedArea(subtree->A->bb, leaf->bb); + cpFloat cost_b = cpBBArea(subtree->A->bb) + cpBBMergedArea(subtree->B->bb, leaf->bb); + + if(cost_a == cost_b){ + cost_a = cpBBProximity(subtree->A->bb, leaf->bb); + cost_b = cpBBProximity(subtree->B->bb, leaf->bb); + } + + if(cost_b < cost_a){ + NodeSetB(subtree, SubtreeInsert(subtree->B, leaf, tree)); + } else { + NodeSetA(subtree, SubtreeInsert(subtree->A, leaf, tree)); + } + + subtree->bb = cpBBMerge(subtree->bb, leaf->bb); + return subtree; + } } static void SubtreeQuery(Node *subtree, void *obj, cpBB bb, cpSpatialIndexQueryFunc func, void *data) { - if(cpBBIntersects(subtree->bb, bb)){ - if(NodeIsLeaf(subtree)){ - func(obj, subtree->obj, data); - } else { - SubtreeQuery(subtree->A, obj, bb, func, data); - SubtreeQuery(subtree->B, obj, bb, func, data); - } - } + if(cpBBIntersects(subtree->bb, bb)){ + if(NodeIsLeaf(subtree)){ + func(obj, subtree->obj, data); + } else { + SubtreeQuery(subtree->A, obj, bb, func, data); + SubtreeQuery(subtree->B, obj, bb, func, data); + } + } } static cpFloat SubtreeSegmentQuery(Node *subtree, void *obj, cpVect a, cpVect b, cpFloat t_exit, cpSpatialIndexSegmentQueryFunc func, void *data) { - if(NodeIsLeaf(subtree)){ - return func(obj, subtree->obj, data); - } else { - cpFloat t_a = cpBBSegmentQuery(subtree->A->bb, a, b); - cpFloat t_b = cpBBSegmentQuery(subtree->B->bb, a, b); - - if(t_a < t_b){ - if(t_a < t_exit) t_exit = cpfmin(t_exit, SubtreeSegmentQuery(subtree->A, obj, a, b, t_exit, func, data)); - if(t_b < t_exit) t_exit = cpfmin(t_exit, SubtreeSegmentQuery(subtree->B, obj, a, b, t_exit, func, data)); - } else { - if(t_b < t_exit) t_exit = cpfmin(t_exit, SubtreeSegmentQuery(subtree->B, obj, a, b, t_exit, func, data)); - if(t_a < t_exit) t_exit = cpfmin(t_exit, SubtreeSegmentQuery(subtree->A, obj, a, b, t_exit, func, data)); - } - - return t_exit; - } + if(NodeIsLeaf(subtree)){ + return func(obj, subtree->obj, data); + } else { + cpFloat t_a = cpBBSegmentQuery(subtree->A->bb, a, b); + cpFloat t_b = cpBBSegmentQuery(subtree->B->bb, a, b); + + if(t_a < t_b){ + if(t_a < t_exit) t_exit = cpfmin(t_exit, SubtreeSegmentQuery(subtree->A, obj, a, b, t_exit, func, data)); + if(t_b < t_exit) t_exit = cpfmin(t_exit, SubtreeSegmentQuery(subtree->B, obj, a, b, t_exit, func, data)); + } else { + if(t_b < t_exit) t_exit = cpfmin(t_exit, SubtreeSegmentQuery(subtree->B, obj, a, b, t_exit, func, data)); + if(t_a < t_exit) t_exit = cpfmin(t_exit, SubtreeSegmentQuery(subtree->A, obj, a, b, t_exit, func, data)); + } + + return t_exit; + } } static void SubtreeRecycle(cpBBTree *tree, Node *node) { - if(!NodeIsLeaf(node)){ - SubtreeRecycle(tree, node->A); - SubtreeRecycle(tree, node->B); - NodeRecycle(tree, node); - } + if(!NodeIsLeaf(node)){ + SubtreeRecycle(tree, node->A); + SubtreeRecycle(tree, node->B); + NodeRecycle(tree, node); + } } static inline Node * SubtreeRemove(Node *subtree, Node *leaf, cpBBTree *tree) { - if(leaf == subtree){ - return NULL; - } else { - Node *parent = leaf->parent; - if(parent == subtree){ - Node *other = NodeOther(subtree, leaf); - other->parent = subtree->parent; - NodeRecycle(tree, subtree); - return other; - } else { - NodeReplaceChild(parent->parent, parent, NodeOther(parent, leaf), tree); - return subtree; - } - } + if(leaf == subtree){ + return NULL; + } else { + Node *parent = leaf->parent; + if(parent == subtree){ + Node *other = NodeOther(subtree, leaf); + other->parent = subtree->parent; + NodeRecycle(tree, subtree); + return other; + } else { + NodeReplaceChild(parent->parent, parent, NodeOther(parent, leaf), tree); + return subtree; + } + } } //MARK: Marking Functions typedef struct MarkContext { - cpBBTree *tree; - Node *staticRoot; - cpSpatialIndexQueryFunc func; - void *data; + cpBBTree *tree; + Node *staticRoot; + cpSpatialIndexQueryFunc func; + void *data; } MarkContext; static void MarkLeafQuery(Node *subtree, Node *leaf, cpBool left, MarkContext *context) { - if(cpBBIntersects(leaf->bb, subtree->bb)){ - if(NodeIsLeaf(subtree)){ - if(left){ - PairInsert(leaf, subtree, context->tree); - } else { - if(subtree->STAMP < leaf->STAMP) PairInsert(subtree, leaf, context->tree); - context->func(leaf->obj, subtree->obj, context->data); - } - } else { - MarkLeafQuery(subtree->A, leaf, left, context); - MarkLeafQuery(subtree->B, leaf, left, context); - } - } + if(cpBBIntersects(leaf->bb, subtree->bb)){ + if(NodeIsLeaf(subtree)){ + if(left){ + PairInsert(leaf, subtree, context->tree); + } else { + if(subtree->STAMP < leaf->STAMP) PairInsert(subtree, leaf, context->tree); + context->func(leaf->obj, subtree->obj, context->data); + } + } else { + MarkLeafQuery(subtree->A, leaf, left, context); + MarkLeafQuery(subtree->B, leaf, left, context); + } + } } static void MarkLeaf(Node *leaf, MarkContext *context) { - cpBBTree *tree = context->tree; - if(leaf->STAMP == GetStamp(tree)){ - Node *staticRoot = context->staticRoot; - if(staticRoot) MarkLeafQuery(staticRoot, leaf, cpFalse, context); - - for(Node *node = leaf; node->parent; node = node->parent){ - if(node == node->parent->A){ - MarkLeafQuery(node->parent->B, leaf, cpTrue, context); - } else { - MarkLeafQuery(node->parent->A, leaf, cpFalse, context); - } - } - } else { - Pair *pair = leaf->PAIRS; - while(pair){ - if(leaf == pair->b.leaf){ - context->func(pair->a.leaf->obj, leaf->obj, context->data); - pair = pair->b.next; - } else { - pair = pair->a.next; - } - } - } + cpBBTree *tree = context->tree; + if(leaf->STAMP == GetStamp(tree)){ + Node *staticRoot = context->staticRoot; + if(staticRoot) MarkLeafQuery(staticRoot, leaf, cpFalse, context); + + for(Node *node = leaf; node->parent; node = node->parent){ + if(node == node->parent->A){ + MarkLeafQuery(node->parent->B, leaf, cpTrue, context); + } else { + MarkLeafQuery(node->parent->A, leaf, cpFalse, context); + } + } + } else { + Pair *pair = leaf->PAIRS; + while(pair){ + if(leaf == pair->b.leaf){ + context->func(pair->a.leaf->obj, leaf->obj, context->data); + pair = pair->b.next; + } else { + pair = pair->a.next; + } + } + } } static void MarkSubtree(Node *subtree, MarkContext *context) { - if(NodeIsLeaf(subtree)){ - MarkLeaf(subtree, context); - } else { - MarkSubtree(subtree->A, context); - MarkSubtree(subtree->B, context); - } + if(NodeIsLeaf(subtree)){ + MarkLeaf(subtree, context); + } else { + MarkSubtree(subtree->A, context); + MarkSubtree(subtree->B, context); + } } //MARK: Leaf Functions @@ -473,36 +473,36 @@ MarkSubtree(Node *subtree, MarkContext *context) static Node * LeafNew(cpBBTree *tree, void *obj, cpBB bb) { - Node *node = NodeFromPool(tree); - node->obj = obj; - node->bb = GetBB(tree, obj); - - node->parent = NULL; - node->STAMP = 0; - node->PAIRS = NULL; - - return node; + Node *node = NodeFromPool(tree); + node->obj = obj; + node->bb = GetBB(tree, obj); + + node->parent = NULL; + node->STAMP = 0; + node->PAIRS = NULL; + + return node; } static cpBool LeafUpdate(Node *leaf, cpBBTree *tree) { - Node *root = tree->root; - cpBB bb = tree->spatialIndex.bbfunc(leaf->obj); - - if(!cpBBContainsBB(leaf->bb, bb)){ - leaf->bb = GetBB(tree, leaf->obj); - - root = SubtreeRemove(root, leaf, tree); - tree->root = SubtreeInsert(root, leaf, tree); - - PairsClear(leaf, tree); - leaf->STAMP = GetStamp(tree); - - return cpTrue; - } - - return cpFalse; + Node *root = tree->root; + cpBB bb = tree->spatialIndex.bbfunc(leaf->obj); + + if(!cpBBContainsBB(leaf->bb, bb)){ + leaf->bb = GetBB(tree, leaf->obj); + + root = SubtreeRemove(root, leaf, tree); + tree->root = SubtreeInsert(root, leaf, tree); + + PairsClear(leaf, tree); + leaf->STAMP = GetStamp(tree); + + return cpTrue; + } + + return cpFalse; } static void VoidQueryFunc(void *obj1, void *obj2, void *data){} @@ -510,19 +510,19 @@ static void VoidQueryFunc(void *obj1, void *obj2, void *data){} static void LeafAddPairs(Node *leaf, cpBBTree *tree) { - cpSpatialIndex *dynamicIndex = tree->spatialIndex.dynamicIndex; - if(dynamicIndex){ - Node *dynamicRoot = GetRootIfTree(dynamicIndex); - if(dynamicRoot){ - cpBBTree *dynamicTree = GetTree(dynamicIndex); - MarkContext context = {dynamicTree, NULL, NULL, NULL}; - MarkLeafQuery(dynamicRoot, leaf, cpTrue, &context); - } - } else { - Node *staticRoot = GetRootIfTree(tree->spatialIndex.staticIndex); - MarkContext context = {tree, staticRoot, VoidQueryFunc, NULL}; - MarkLeaf(leaf, &context); - } + cpSpatialIndex *dynamicIndex = tree->spatialIndex.dynamicIndex; + if(dynamicIndex){ + Node *dynamicRoot = GetRootIfTree(dynamicIndex); + if(dynamicRoot){ + cpBBTree *dynamicTree = GetTree(dynamicIndex); + MarkContext context = {dynamicTree, NULL, NULL, NULL}; + MarkLeafQuery(dynamicRoot, leaf, cpTrue, &context); + } + } else { + Node *staticRoot = GetRootIfTree(tree->spatialIndex.staticIndex); + MarkContext context = {tree, staticRoot, VoidQueryFunc, NULL}; + MarkLeaf(leaf, &context); + } } //MARK: Memory Management Functions @@ -530,63 +530,63 @@ LeafAddPairs(Node *leaf, cpBBTree *tree) cpBBTree * cpBBTreeAlloc(void) { - return (cpBBTree *)cpcalloc(1, sizeof(cpBBTree)); + return (cpBBTree *)cpcalloc(1, sizeof(cpBBTree)); } static int leafSetEql(void *obj, Node *node) { - return (obj == node->obj); + return (obj == node->obj); } static void * leafSetTrans(void *obj, cpBBTree *tree) { - return LeafNew(tree, obj, tree->spatialIndex.bbfunc(obj)); + return LeafNew(tree, obj, tree->spatialIndex.bbfunc(obj)); } cpSpatialIndex * cpBBTreeInit(cpBBTree *tree, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex) { - cpSpatialIndexInit((cpSpatialIndex *)tree, Klass(), bbfunc, staticIndex); - - tree->velocityFunc = NULL; - - tree->leaves = cpHashSetNew(0, (cpHashSetEqlFunc)leafSetEql); - tree->root = NULL; - - tree->pooledNodes = NULL; - tree->allocatedBuffers = cpArrayNew(0); - - tree->stamp = 0; - - return (cpSpatialIndex *)tree; + cpSpatialIndexInit((cpSpatialIndex *)tree, Klass(), bbfunc, staticIndex); + + tree->velocityFunc = NULL; + + tree->leaves = cpHashSetNew(0, (cpHashSetEqlFunc)leafSetEql); + tree->root = NULL; + + tree->pooledNodes = NULL; + tree->allocatedBuffers = cpArrayNew(0); + + tree->stamp = 0; + + return (cpSpatialIndex *)tree; } void cpBBTreeSetVelocityFunc(cpSpatialIndex *index, cpBBTreeVelocityFunc func) { - if(index->klass != Klass()){ - cpAssertWarn(cpFalse, "Ignoring cpBBTreeSetVelocityFunc() call to non-tree spatial index."); - return; - } - - ((cpBBTree *)index)->velocityFunc = func; + if(index->klass != Klass()){ + cpAssertWarn(cpFalse, "Ignoring cpBBTreeSetVelocityFunc() call to non-tree spatial index."); + return; + } + + ((cpBBTree *)index)->velocityFunc = func; } cpSpatialIndex * cpBBTreeNew(cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex) { - return cpBBTreeInit(cpBBTreeAlloc(), bbfunc, staticIndex); + return cpBBTreeInit(cpBBTreeAlloc(), bbfunc, staticIndex); } static void cpBBTreeDestroy(cpBBTree *tree) { - cpHashSetFree(tree->leaves); - - if(tree->allocatedBuffers) cpArrayFreeEach(tree->allocatedBuffers, cpfree); - cpArrayFree(tree->allocatedBuffers); + cpHashSetFree(tree->leaves); + + if(tree->allocatedBuffers) cpArrayFreeEach(tree->allocatedBuffers, cpfree); + cpArrayFree(tree->allocatedBuffers); } //MARK: Insert/Remove @@ -594,30 +594,30 @@ cpBBTreeDestroy(cpBBTree *tree) static void cpBBTreeInsert(cpBBTree *tree, void *obj, cpHashValue hashid) { - Node *leaf = (Node *)cpHashSetInsert(tree->leaves, hashid, obj, tree, (cpHashSetTransFunc)leafSetTrans); - - Node *root = tree->root; - tree->root = SubtreeInsert(root, leaf, tree); - - leaf->STAMP = GetStamp(tree); - LeafAddPairs(leaf, tree); - IncrementStamp(tree); + Node *leaf = (Node *)cpHashSetInsert(tree->leaves, hashid, obj, tree, (cpHashSetTransFunc)leafSetTrans); + + Node *root = tree->root; + tree->root = SubtreeInsert(root, leaf, tree); + + leaf->STAMP = GetStamp(tree); + LeafAddPairs(leaf, tree); + IncrementStamp(tree); } static void cpBBTreeRemove(cpBBTree *tree, void *obj, cpHashValue hashid) { - Node *leaf = (Node *)cpHashSetRemove(tree->leaves, hashid, obj); - - tree->root = SubtreeRemove(tree->root, leaf, tree); - PairsClear(leaf, tree); - NodeRecycle(tree, leaf); + Node *leaf = (Node *)cpHashSetRemove(tree->leaves, hashid, obj); + + tree->root = SubtreeRemove(tree->root, leaf, tree); + PairsClear(leaf, tree); + NodeRecycle(tree, leaf); } static cpBool cpBBTreeContains(cpBBTree *tree, void *obj, cpHashValue hashid) { - return (cpHashSetFind(tree->leaves, hashid, obj) != NULL); + return (cpHashSetFind(tree->leaves, hashid, obj) != NULL); } //MARK: Reindex @@ -625,57 +625,50 @@ cpBBTreeContains(cpBBTree *tree, void *obj, cpHashValue hashid) static void cpBBTreeReindexQuery(cpBBTree *tree, cpSpatialIndexQueryFunc func, void *data) { - if(!tree->root) return; - - // LeafUpdate() may modify tree->root. Don't cache it. - cpHashSetEach(tree->leaves, (cpHashSetIteratorFunc)LeafUpdate, tree); - - cpSpatialIndex *staticIndex = tree->spatialIndex.staticIndex; - Node *staticRoot = (staticIndex && staticIndex->klass == Klass() ? ((cpBBTree *)staticIndex)->root : NULL); - - MarkContext context = {tree, staticRoot, func, data}; - MarkSubtree(tree->root, &context); - if(staticIndex && !staticRoot) cpSpatialIndexCollideStatic((cpSpatialIndex *)tree, staticIndex, func, data); - - IncrementStamp(tree); + if(!tree->root) return; + + // LeafUpdate() may modify tree->root. Don't cache it. + cpHashSetEach(tree->leaves, (cpHashSetIteratorFunc)LeafUpdate, tree); + + cpSpatialIndex *staticIndex = tree->spatialIndex.staticIndex; + Node *staticRoot = (staticIndex && staticIndex->klass == Klass() ? ((cpBBTree *)staticIndex)->root : NULL); + + MarkContext context = {tree, staticRoot, func, data}; + MarkSubtree(tree->root, &context); + if(staticIndex && !staticRoot) cpSpatialIndexCollideStatic((cpSpatialIndex *)tree, staticIndex, func, data); + + IncrementStamp(tree); } static void cpBBTreeReindex(cpBBTree *tree) { - cpBBTreeReindexQuery(tree, VoidQueryFunc, NULL); + cpBBTreeReindexQuery(tree, VoidQueryFunc, NULL); } static void cpBBTreeReindexObject(cpBBTree *tree, void *obj, cpHashValue hashid) { - Node *leaf = (Node *)cpHashSetFind(tree->leaves, hashid, obj); - if(leaf){ - if(LeafUpdate(leaf, tree)) LeafAddPairs(leaf, tree); - IncrementStamp(tree); - } + Node *leaf = (Node *)cpHashSetFind(tree->leaves, hashid, obj); + if(leaf){ + if(LeafUpdate(leaf, tree)) LeafAddPairs(leaf, tree); + IncrementStamp(tree); + } } //MARK: Query -static void -cpBBTreePointQuery(cpBBTree *tree, cpVect point, cpSpatialIndexQueryFunc func, void *data) -{ - Node *root = tree->root; - if(root) SubtreeQuery(root, &point, cpBBNew(point.x, point.y, point.x, point.y), func, data); -} - static void cpBBTreeSegmentQuery(cpBBTree *tree, void *obj, cpVect a, cpVect b, cpFloat t_exit, cpSpatialIndexSegmentQueryFunc func, void *data) { - Node *root = tree->root; - if(root) SubtreeSegmentQuery(root, obj, a, b, t_exit, func, data); + Node *root = tree->root; + if(root) SubtreeSegmentQuery(root, obj, a, b, t_exit, func, data); } static void cpBBTreeQuery(cpBBTree *tree, void *obj, cpBB bb, cpSpatialIndexQueryFunc func, void *data) { - if(tree->root) SubtreeQuery(tree->root, obj, bb, func, data); + if(tree->root) SubtreeQuery(tree->root, obj, bb, func, data); } //MARK: Misc @@ -683,12 +676,12 @@ cpBBTreeQuery(cpBBTree *tree, void *obj, cpBB bb, cpSpatialIndexQueryFunc func, static int cpBBTreeCount(cpBBTree *tree) { - return cpHashSetCount(tree->leaves); + return cpHashSetCount(tree->leaves); } typedef struct eachContext { - cpSpatialIndexIteratorFunc func; - void *data; + cpSpatialIndexIteratorFunc func; + void *data; } eachContext; static void each_helper(Node *node, eachContext *context){context->func(node->obj, context->data);} @@ -696,27 +689,26 @@ static void each_helper(Node *node, eachContext *context){context->func(node->ob static void cpBBTreeEach(cpBBTree *tree, cpSpatialIndexIteratorFunc func, void *data) { - eachContext context = {func, data}; - cpHashSetEach(tree->leaves, (cpHashSetIteratorFunc)each_helper, &context); + eachContext context = {func, data}; + cpHashSetEach(tree->leaves, (cpHashSetIteratorFunc)each_helper, &context); } static cpSpatialIndexClass klass = { - (cpSpatialIndexDestroyImpl)cpBBTreeDestroy, - - (cpSpatialIndexCountImpl)cpBBTreeCount, - (cpSpatialIndexEachImpl)cpBBTreeEach, - - (cpSpatialIndexContainsImpl)cpBBTreeContains, - (cpSpatialIndexInsertImpl)cpBBTreeInsert, - (cpSpatialIndexRemoveImpl)cpBBTreeRemove, - - (cpSpatialIndexReindexImpl)cpBBTreeReindex, - (cpSpatialIndexReindexObjectImpl)cpBBTreeReindexObject, - (cpSpatialIndexReindexQueryImpl)cpBBTreeReindexQuery, - - (cpSpatialIndexPointQueryImpl)cpBBTreePointQuery, - (cpSpatialIndexSegmentQueryImpl)cpBBTreeSegmentQuery, - (cpSpatialIndexQueryImpl)cpBBTreeQuery, + (cpSpatialIndexDestroyImpl)cpBBTreeDestroy, + + (cpSpatialIndexCountImpl)cpBBTreeCount, + (cpSpatialIndexEachImpl)cpBBTreeEach, + + (cpSpatialIndexContainsImpl)cpBBTreeContains, + (cpSpatialIndexInsertImpl)cpBBTreeInsert, + (cpSpatialIndexRemoveImpl)cpBBTreeRemove, + + (cpSpatialIndexReindexImpl)cpBBTreeReindex, + (cpSpatialIndexReindexObjectImpl)cpBBTreeReindexObject, + (cpSpatialIndexReindexQueryImpl)cpBBTreeReindexQuery, + + (cpSpatialIndexQueryImpl)cpBBTreeQuery, + (cpSpatialIndexSegmentQueryImpl)cpBBTreeSegmentQuery, }; static inline cpSpatialIndexClass *Klass(){return &klass;} @@ -726,120 +718,120 @@ static inline cpSpatialIndexClass *Klass(){return &klass;} static int cpfcompare(const cpFloat *a, const cpFloat *b){ - return (*a < *b ? -1 : (*b < *a ? 1 : 0)); + return (*a < *b ? -1 : (*b < *a ? 1 : 0)); } static void fillNodeArray(Node *node, Node ***cursor){ - (**cursor) = node; - (*cursor)++; + (**cursor) = node; + (*cursor)++; } static Node * partitionNodes(cpBBTree *tree, Node **nodes, int count) { - if(count == 1){ - return nodes[0]; - } else if(count == 2) { - return NodeNew(tree, nodes[0], nodes[1]); - } - - // Find the AABB for these nodes - cpBB bb = nodes[0]->bb; - for(int i=1; ibb); - - // Split it on it's longest axis - cpBool splitWidth = (bb.r - bb.l > bb.t - bb.b); - - // Sort the bounds and use the median as the splitting point - cpFloat *bounds = (cpFloat *)cpcalloc(count*2, sizeof(cpFloat)); - if(splitWidth){ - for(int i=0; ibb.l; - bounds[2*i + 1] = nodes[i]->bb.r; - } - } else { - for(int i=0; ibb.b; - bounds[2*i + 1] = nodes[i]->bb.t; - } - } - - qsort(bounds, count*2, sizeof(cpFloat), (int (*)(const void *, const void *))cpfcompare); - cpFloat split = (bounds[count - 1] + bounds[count])*0.5f; // use the medain as the split - cpfree(bounds); + if(count == 1){ + return nodes[0]; + } else if(count == 2) { + return NodeNew(tree, nodes[0], nodes[1]); + } + + // Find the AABB for these nodes + cpBB bb = nodes[0]->bb; + for(int i=1; ibb); + + // Split it on it's longest axis + cpBool splitWidth = (bb.r - bb.l > bb.t - bb.b); + + // Sort the bounds and use the median as the splitting point + cpFloat *bounds = (cpFloat *)cpcalloc(count*2, sizeof(cpFloat)); + if(splitWidth){ + for(int i=0; ibb.l; + bounds[2*i + 1] = nodes[i]->bb.r; + } + } else { + for(int i=0; ibb.b; + bounds[2*i + 1] = nodes[i]->bb.t; + } + } + + qsort(bounds, count*2, sizeof(cpFloat), (int (*)(const void *, const void *))cpfcompare); + cpFloat split = (bounds[count - 1] + bounds[count])*0.5f; // use the medain as the split + cpfree(bounds); - // Generate the child BBs - cpBB a = bb, b = bb; - if(splitWidth) a.r = b.l = split; else a.t = b.b = split; - - // Partition the nodes - int right = count; - for(int left=0; left < right;){ - Node *node = nodes[left]; - if(cpBBMergedArea(node->bb, b) < cpBBMergedArea(node->bb, a)){ -// if(cpBBProximity(node->bb, b) < cpBBProximity(node->bb, a)){ - right--; - nodes[left] = nodes[right]; - nodes[right] = node; - } else { - left++; - } - } - - if(right == count){ - Node *node = NULL; - for(int i=0; ibb, b) < cpBBMergedArea(node->bb, a)){ +// if(cpBBProximity(node->bb, b) < cpBBProximity(node->bb, a)){ + right--; + nodes[left] = nodes[right]; + nodes[right] = node; + } else { + left++; + } + } + + if(right == count){ + Node *node = NULL; + for(int i=0; iroot; -// Node *node = root; -// int bit = 0; -// unsigned int path = tree->opath; -// -// while(!NodeIsLeaf(node)){ -// node = (path&(1<a : node->b); -// bit = (bit + 1)&(sizeof(unsigned int)*8 - 1); -// } -// -// root = subtreeRemove(root, node, tree); -// tree->root = subtreeInsert(root, node, tree); -// } +// for(int i=0; iroot; +// Node *node = root; +// int bit = 0; +// unsigned int path = tree->opath; +// +// while(!NodeIsLeaf(node)){ +// node = (path&(1<a : node->b); +// bit = (bit + 1)&(sizeof(unsigned int)*8 - 1); +// } +// +// root = subtreeRemove(root, node, tree); +// tree->root = subtreeInsert(root, node, tree); +// } //} void cpBBTreeOptimize(cpSpatialIndex *index) { - if(index->klass != &klass){ - cpAssertWarn(cpFalse, "Ignoring cpBBTreeOptimize() call to non-tree spatial index."); - return; - } - - cpBBTree *tree = (cpBBTree *)index; - Node *root = tree->root; - if(!root) return; - - int count = cpBBTreeCount(tree); - Node **nodes = (Node **)cpcalloc(count, sizeof(Node *)); - Node **cursor = nodes; - - cpHashSetEach(tree->leaves, (cpHashSetIteratorFunc)fillNodeArray, &cursor); - - SubtreeRecycle(tree, root); - tree->root = partitionNodes(tree, nodes, count); - cpfree(nodes); + if(index->klass != &klass){ + cpAssertWarn(cpFalse, "Ignoring cpBBTreeOptimize() call to non-tree spatial index."); + return; + } + + cpBBTree *tree = (cpBBTree *)index; + Node *root = tree->root; + if(!root) return; + + int count = cpBBTreeCount(tree); + Node **nodes = (Node **)cpcalloc(count, sizeof(Node *)); + Node **cursor = nodes; + + cpHashSetEach(tree->leaves, (cpHashSetIteratorFunc)fillNodeArray, &cursor); + + SubtreeRecycle(tree, root); + tree->root = partitionNodes(tree, nodes, count); + cpfree(nodes); } //MARK: Debug Draw @@ -853,39 +845,39 @@ cpBBTreeOptimize(cpSpatialIndex *index) static void NodeRender(Node *node, int depth) { - if(!NodeIsLeaf(node) && depth <= 10){ - NodeRender(node->a, depth + 1); - NodeRender(node->b, depth + 1); - } - - cpBB bb = node->bb; - -// GLfloat v = depth/2.0f; -// glColor3f(1.0f - v, v, 0.0f); - glLineWidth(cpfmax(5.0f - depth, 1.0f)); - glBegin(GL_LINES); { - glVertex2f(bb.l, bb.b); - glVertex2f(bb.l, bb.t); - - glVertex2f(bb.l, bb.t); - glVertex2f(bb.r, bb.t); - - glVertex2f(bb.r, bb.t); - glVertex2f(bb.r, bb.b); - - glVertex2f(bb.r, bb.b); - glVertex2f(bb.l, bb.b); - }; glEnd(); + if(!NodeIsLeaf(node) && depth <= 10){ + NodeRender(node->a, depth + 1); + NodeRender(node->b, depth + 1); + } + + cpBB bb = node->bb; + +// GLfloat v = depth/2.0f; +// glColor3f(1.0f - v, v, 0.0f); + glLineWidth(cpfmax(5.0f - depth, 1.0f)); + glBegin(GL_LINES); { + glVertex2f(bb.l, bb.b); + glVertex2f(bb.l, bb.t); + + glVertex2f(bb.l, bb.t); + glVertex2f(bb.r, bb.t); + + glVertex2f(bb.r, bb.t); + glVertex2f(bb.r, bb.b); + + glVertex2f(bb.r, bb.b); + glVertex2f(bb.l, bb.b); + }; glEnd(); } void cpBBTreeRenderDebug(cpSpatialIndex *index){ - if(index->klass != &klass){ - cpAssertWarn(cpFalse, "Ignoring cpBBTreeRenderDebug() call to non-tree spatial index."); - return; - } - - cpBBTree *tree = (cpBBTree *)index; - if(tree->root) NodeRender(tree->root, 0); + if(index->klass != &klass){ + cpAssertWarn(cpFalse, "Ignoring cpBBTreeRenderDebug() call to non-tree spatial index."); + return; + } + + cpBBTree *tree = (cpBBTree *)index; + if(tree->root) NodeRender(tree->root, 0); } #endif diff --git a/chipmunk/src/cpBody.c b/chipmunk/src/cpBody.c index 3d2e1a0809..2a2a2c6be9 100644 --- a/chipmunk/src/cpBody.c +++ b/chipmunk/src/cpBody.c @@ -19,9 +19,7 @@ * SOFTWARE. */ -#include #include -#include #include "chipmunk_private.h" #include "constraints/util.h" @@ -32,65 +30,65 @@ cpBody cpStaticBodySingleton; cpBody* cpBodyAlloc(void) { - return (cpBody *)cpcalloc(1, sizeof(cpBody)); + return (cpBody *)cpcalloc(1, sizeof(cpBody)); } cpBody * cpBodyInit(cpBody *body, cpFloat m, cpFloat i) { - body->space = NULL; - body->shapeList = NULL; - body->arbiterList = NULL; - body->constraintList = NULL; - - body->velocity_func = cpBodyUpdateVelocity; - body->position_func = cpBodyUpdatePosition; - - cpComponentNode node = {NULL, NULL, 0.0f}; - body->node = node; - - body->p = cpvzero; - body->v = cpvzero; - body->f = cpvzero; - - body->w = 0.0f; - body->t = 0.0f; - - body->v_bias = cpvzero; - body->w_bias = 0.0f; - - body->v_limit = (cpFloat)INFINITY; - body->w_limit = (cpFloat)INFINITY; - - body->data = NULL; - - // Setters must be called after full initialization so the sanity checks don't assert on garbage data. - cpBodySetMass(body, m); - cpBodySetMoment(body, i); - cpBodySetAngle(body, 0.0f); - - return body; + body->space = NULL; + body->shapeList = NULL; + body->arbiterList = NULL; + body->constraintList = NULL; + + body->velocity_func = cpBodyUpdateVelocity; + body->position_func = cpBodyUpdatePosition; + + cpComponentNode node = {NULL, NULL, 0.0f}; + body->node = node; + + body->p = cpvzero; + body->v = cpvzero; + body->f = cpvzero; + + body->w = 0.0f; + body->t = 0.0f; + + body->v_bias = cpvzero; + body->w_bias = 0.0f; + + body->v_limit = (cpFloat)INFINITY; + body->w_limit = (cpFloat)INFINITY; + + body->data = NULL; + + // Setters must be called after full initialization so the sanity checks don't assert on garbage data. + cpBodySetMass(body, m); + cpBodySetMoment(body, i); + cpBodySetAngle(body, 0.0f); + + return body; } cpBody* cpBodyNew(cpFloat m, cpFloat i) { - return cpBodyInit(cpBodyAlloc(), m, i); + return cpBodyInit(cpBodyAlloc(), m, i); } cpBody * cpBodyInitStatic(cpBody *body) { - cpBodyInit(body, (cpFloat)INFINITY, (cpFloat)INFINITY); - body->node.idleTime = (cpFloat)INFINITY; - - return body; + cpBodyInit(body, (cpFloat)INFINITY, (cpFloat)INFINITY); + body->node.idleTime = (cpFloat)INFINITY; + + return body; } cpBody * cpBodyNewStatic(void) { - return cpBodyInitStatic(cpBodyAlloc()); + return cpBodyInitStatic(cpBodyAlloc()); } void cpBodyDestroy(cpBody *body){} @@ -98,10 +96,10 @@ void cpBodyDestroy(cpBody *body){} void cpBodyFree(cpBody *body) { - if(body){ - cpBodyDestroy(body); - cpfree(body); - } + if(body){ + cpBodyDestroy(body); + cpfree(body); + } } static void cpv_assert_nan(cpVect v, char *message){cpAssertSoft(v.x == v.x && v.y == v.y, message);} @@ -115,21 +113,21 @@ extern "C" { void cpBodySanityCheck(cpBody *body) { - cpAssertSoft(body->m == body->m && body->m_inv == body->m_inv, "Body's mass is invalid."); - cpAssertSoft(body->i == body->i && body->i_inv == body->i_inv, "Body's moment is invalid."); - - cpv_assert_sane(body->p, "Body's position is invalid."); - cpv_assert_sane(body->v, "Body's velocity is invalid."); - cpv_assert_sane(body->f, "Body's force is invalid."); + cpAssertSoft(body->m == body->m && body->m_inv == body->m_inv, "Body's mass is invalid."); + cpAssertSoft(body->i == body->i && body->i_inv == body->i_inv, "Body's moment is invalid."); + + cpv_assert_sane(body->p, "Body's position is invalid."); + cpv_assert_sane(body->v, "Body's velocity is invalid."); + cpv_assert_sane(body->f, "Body's force is invalid."); - cpAssertSoft(body->a == body->a && cpfabs(body->a) != INFINITY, "Body's angle is invalid."); - cpAssertSoft(body->w == body->w && cpfabs(body->w) != INFINITY, "Body's angular velocity is invalid."); - cpAssertSoft(body->t == body->t && cpfabs(body->t) != INFINITY, "Body's torque is invalid."); - - cpv_assert_sane(body->rot, "Internal error: Body's rotation vector is invalid."); - - cpAssertSoft(body->v_limit == body->v_limit, "Body's velocity limit is invalid."); - cpAssertSoft(body->w_limit == body->w_limit, "Body's angular velocity limit is invalid."); + cpAssertSoft(body->a == body->a && cpfabs(body->a) != INFINITY, "Body's angle is invalid."); + cpAssertSoft(body->w == body->w && cpfabs(body->w) != INFINITY, "Body's angular velocity is invalid."); + cpAssertSoft(body->t == body->t && cpfabs(body->t) != INFINITY, "Body's torque is invalid."); + + cpv_assert_sane(body->rot, "Body's rotation vector is invalid."); + + cpAssertSoft(body->v_limit == body->v_limit, "Body's velocity limit is invalid."); + cpAssertSoft(body->w_limit == body->w_limit, "Body's angular velocity limit is invalid."); } #ifdef __cplusplus @@ -139,31 +137,31 @@ cpBodySanityCheck(cpBody *body) void cpBodySetMass(cpBody *body, cpFloat mass) { - cpAssertHard(mass > 0.0f, "Mass must be positive and non-zero."); - - cpBodyActivate(body); - body->m = mass; - body->m_inv = 1.0f/mass; + cpAssertHard(mass > 0.0f, "Mass must be positive and non-zero."); + + cpBodyActivate(body); + body->m = mass; + body->m_inv = 1.0f/mass; } void cpBodySetMoment(cpBody *body, cpFloat moment) { - cpAssertHard(moment > 0.0f, "Moment of Inertia must be positive and non-zero."); - - cpBodyActivate(body); - body->i = moment; - body->i_inv = 1.0f/moment; + cpAssertHard(moment > 0.0f, "Moment of Inertia must be positive and non-zero."); + + cpBodyActivate(body); + body->i = moment; + body->i_inv = 1.0f/moment; } void cpBodyAddShape(cpBody *body, cpShape *shape) { - cpShape *next = body->shapeList; - if(next) next->prev = shape; - - shape->next = next; - body->shapeList = shape; + cpShape *next = body->shapeList; + if(next) next->prev = shape; + + shape->next = next; + body->shapeList = shape; } void @@ -173,14 +171,14 @@ cpBodyRemoveShape(cpBody *body, cpShape *shape) cpShape *next = shape->next; if(prev){ - prev->next = next; + prev->next = next; } else { - body->shapeList = next; + body->shapeList = next; } if(next){ - next->prev = prev; - } + next->prev = prev; + } shape->prev = NULL; shape->next = NULL; @@ -189,142 +187,142 @@ cpBodyRemoveShape(cpBody *body, cpShape *shape) static cpConstraint * filterConstraints(cpConstraint *node, cpBody *body, cpConstraint *filter) { - if(node == filter){ - return cpConstraintNext(node, body); - } else if(node->a == body){ - node->next_a = filterConstraints(node->next_a, body, filter); - } else { - node->next_b = filterConstraints(node->next_b, body, filter); - } - - return node; + if(node == filter){ + return cpConstraintNext(node, body); + } else if(node->a == body){ + node->next_a = filterConstraints(node->next_a, body, filter); + } else { + node->next_b = filterConstraints(node->next_b, body, filter); + } + + return node; } void cpBodyRemoveConstraint(cpBody *body, cpConstraint *constraint) { - body->constraintList = filterConstraints(body->constraintList, body, constraint); + body->constraintList = filterConstraints(body->constraintList, body, constraint); } void cpBodySetPos(cpBody *body, cpVect pos) { - cpBodyActivate(body); - cpBodyAssertSane(body); - body->p = pos; + cpBodyActivate(body); + cpBodyAssertSane(body); + body->p = pos; } static inline void setAngle(cpBody *body, cpFloat angle) { - body->a = angle;//fmod(a, (cpFloat)M_PI*2.0f); - body->rot = cpvforangle(angle); + body->a = angle;//fmod(a, (cpFloat)M_PI*2.0f); + body->rot = cpvforangle(angle); } void cpBodySetAngle(cpBody *body, cpFloat angle) { - cpBodyActivate(body); - cpBodyAssertSane(body); - setAngle(body, angle); + cpBodyActivate(body); + cpBodyAssertSane(body); + setAngle(body, angle); } void cpBodyUpdateVelocity(cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt) { - body->v = cpvclamp(cpvadd(cpvmult(body->v, damping), cpvmult(cpvadd(gravity, cpvmult(body->f, body->m_inv)), dt)), body->v_limit); - - cpFloat w_limit = body->w_limit; - body->w = cpfclamp(body->w*damping + body->t*body->i_inv*dt, -w_limit, w_limit); - - cpBodySanityCheck(body); + body->v = cpvclamp(cpvadd(cpvmult(body->v, damping), cpvmult(cpvadd(gravity, cpvmult(body->f, body->m_inv)), dt)), body->v_limit); + + cpFloat w_limit = body->w_limit; + body->w = cpfclamp(body->w*damping + body->t*body->i_inv*dt, -w_limit, w_limit); + + cpBodySanityCheck(body); } void cpBodyUpdatePosition(cpBody *body, cpFloat dt) { - body->p = cpvadd(body->p, cpvmult(cpvadd(body->v, body->v_bias), dt)); - setAngle(body, body->a + (body->w + body->w_bias)*dt); - - body->v_bias = cpvzero; - body->w_bias = 0.0f; - - cpBodySanityCheck(body); + body->p = cpvadd(body->p, cpvmult(cpvadd(body->v, body->v_bias), dt)); + setAngle(body, body->a + (body->w + body->w_bias)*dt); + + body->v_bias = cpvzero; + body->w_bias = 0.0f; + + cpBodySanityCheck(body); } void cpBodyResetForces(cpBody *body) { - cpBodyActivate(body); - body->f = cpvzero; - body->t = 0.0f; + cpBodyActivate(body); + body->f = cpvzero; + body->t = 0.0f; } void cpBodyApplyForce(cpBody *body, cpVect force, cpVect r) { - cpBodyActivate(body); - body->f = cpvadd(body->f, force); - body->t += cpvcross(r, force); + cpBodyActivate(body); + body->f = cpvadd(body->f, force); + body->t += cpvcross(r, force); } void cpBodyApplyImpulse(cpBody *body, const cpVect j, const cpVect r) { - cpBodyActivate(body); - apply_impulse(body, j, r); + cpBodyActivate(body); + apply_impulse(body, j, r); } static inline cpVect cpBodyGetVelAtPoint(cpBody *body, cpVect r) { - return cpvadd(body->v, cpvmult(cpvperp(r), body->w)); + return cpvadd(body->v, cpvmult(cpvperp(r), body->w)); } cpVect cpBodyGetVelAtWorldPoint(cpBody *body, cpVect point) { - return cpBodyGetVelAtPoint(body, cpvsub(point, body->p)); + return cpBodyGetVelAtPoint(body, cpvsub(point, body->p)); } cpVect cpBodyGetVelAtLocalPoint(cpBody *body, cpVect point) { - return cpBodyGetVelAtPoint(body, cpvrotate(point, body->rot)); + return cpBodyGetVelAtPoint(body, cpvrotate(point, body->rot)); } void cpBodyEachShape(cpBody *body, cpBodyShapeIteratorFunc func, void *data) { - cpShape *shape = body->shapeList; - while(shape){ - cpShape *next = shape->next; - func(body, shape, data); - shape = next; - } + cpShape *shape = body->shapeList; + while(shape){ + cpShape *next = shape->next; + func(body, shape, data); + shape = next; + } } void cpBodyEachConstraint(cpBody *body, cpBodyConstraintIteratorFunc func, void *data) { - cpConstraint *constraint = body->constraintList; - while(constraint){ - cpConstraint *next = cpConstraintNext(constraint, body); - func(body, constraint, data); - constraint = next; - } + cpConstraint *constraint = body->constraintList; + while(constraint){ + cpConstraint *next = cpConstraintNext(constraint, body); + func(body, constraint, data); + constraint = next; + } } void cpBodyEachArbiter(cpBody *body, cpBodyArbiterIteratorFunc func, void *data) { - cpArbiter *arb = body->arbiterList; - while(arb){ - cpArbiter *next = cpArbiterNext(arb, body); - - arb->swappedColl = (body == arb->body_b); - func(body, arb, data); - - arb = next; - } + cpArbiter *arb = body->arbiterList; + while(arb){ + cpArbiter *next = cpArbiterNext(arb, body); + + arb->swappedColl = (body == arb->body_b); + func(body, arb, data); + + arb = next; + } } diff --git a/chipmunk/src/cpCollision.c b/chipmunk/src/cpCollision.c index 3492e558df..75f3bb34bd 100644 --- a/chipmunk/src/cpCollision.c +++ b/chipmunk/src/cpCollision.c @@ -19,10 +19,6 @@ * SOFTWARE. */ -#include -#include -//#include - #include "chipmunk_private.h" typedef int (*collisionFunc)(const cpShape *, const cpShape *, cpContact *); @@ -32,59 +28,59 @@ typedef int (*collisionFunc)(const cpShape *, const cpShape *, cpContact *); static int circle2circleQuery(const cpVect p1, const cpVect p2, const cpFloat r1, const cpFloat r2, cpContact *con) { - cpFloat mindist = r1 + r2; - cpVect delta = cpvsub(p2, p1); - cpFloat distsq = cpvlengthsq(delta); - if(distsq >= mindist*mindist) return 0; - - cpFloat dist = cpfsqrt(distsq); + cpFloat mindist = r1 + r2; + cpVect delta = cpvsub(p2, p1); + cpFloat distsq = cpvlengthsq(delta); + if(distsq >= mindist*mindist) return 0; + + cpFloat dist = cpfsqrt(distsq); - // Allocate and initialize the contact. - cpContactInit( - con, - cpvadd(p1, cpvmult(delta, 0.5f + (r1 - 0.5f*mindist)/(dist ? dist : INFINITY))), - (dist ? cpvmult(delta, 1.0f/dist) : cpv(1.0f, 0.0f)), - dist - mindist, - 0 - ); - - return 1; + // Allocate and initialize the contact. + cpContactInit( + con, + cpvadd(p1, cpvmult(delta, 0.5f + (r1 - 0.5f*mindist)/(dist ? dist : INFINITY))), + (dist ? cpvmult(delta, 1.0f/dist) : cpv(1.0f, 0.0f)), + dist - mindist, + 0 + ); + + return 1; } // Collide circle shapes. static int circle2circle(const cpShape *shape1, const cpShape *shape2, cpContact *arr) { - cpCircleShape *circ1 = (cpCircleShape *)shape1; //TODO - cpCircleShape *circ2 = (cpCircleShape *)shape2; - - return circle2circleQuery(circ1->tc, circ2->tc, circ1->r, circ2->r, arr); + cpCircleShape *circ1 = (cpCircleShape *)shape1; //TODO + cpCircleShape *circ2 = (cpCircleShape *)shape2; + + return circle2circleQuery(circ1->tc, circ2->tc, circ1->r, circ2->r, arr); } static int circle2segment(const cpCircleShape *circleShape, const cpSegmentShape *segmentShape, cpContact *con) { - cpVect seg_a = segmentShape->ta; - cpVect seg_b = segmentShape->tb; - cpVect center = circleShape->tc; - - cpVect seg_delta = cpvsub(seg_b, seg_a); - cpFloat closest_t = cpfclamp01(cpvdot(seg_delta, cpvsub(center, seg_a))/cpvlengthsq(seg_delta)); - cpVect closest = cpvadd(seg_a, cpvmult(seg_delta, closest_t)); - - if(circle2circleQuery(center, closest, circleShape->r, segmentShape->r, con)){ - cpVect n = con[0].n; - - // Reject endcap collisions if tangents are provided. - if( - (closest_t == 0.0f && cpvdot(n, segmentShape->a_tangent) < 0.0) || - (closest_t == 1.0f && cpvdot(n, segmentShape->b_tangent) < 0.0) - ) return 0; - - return 1; - } else { - return 0; - } + cpVect seg_a = segmentShape->ta; + cpVect seg_b = segmentShape->tb; + cpVect center = circleShape->tc; + + cpVect seg_delta = cpvsub(seg_b, seg_a); + cpFloat closest_t = cpfclamp01(cpvdot(seg_delta, cpvsub(center, seg_a))/cpvlengthsq(seg_delta)); + cpVect closest = cpvadd(seg_a, cpvmult(seg_delta, closest_t)); + + if(circle2circleQuery(center, closest, circleShape->r, segmentShape->r, con)){ + cpVect n = con[0].n; + + // Reject endcap collisions if tangents are provided. + if( + (closest_t == 0.0f && cpvdot(n, segmentShape->a_tangent) < 0.0) || + (closest_t == 1.0f && cpvdot(n, segmentShape->b_tangent) < 0.0) + ) return 0; + + return 1; + } else { + return 0; + } } // Helper function for working with contact buffers @@ -92,36 +88,36 @@ circle2segment(const cpCircleShape *circleShape, const cpSegmentShape *segmentSh static cpContact * nextContactPoint(cpContact *arr, int *numPtr) { - int index = *numPtr; - - if(index < CP_MAX_CONTACTS_PER_ARBITER){ - (*numPtr) = index + 1; - return &arr[index]; - } else { - return &arr[CP_MAX_CONTACTS_PER_ARBITER - 1]; - } + int index = *numPtr; + + if(index < CP_MAX_CONTACTS_PER_ARBITER){ + (*numPtr) = index + 1; + return &arr[index]; + } else { + return &arr[CP_MAX_CONTACTS_PER_ARBITER - 1]; + } } // Find the minimum separating axis for the give poly and axis list. static inline int -findMSA(const cpPolyShape *poly, const cpPolyShapeAxis *axes, const int num, cpFloat *min_out) +findMSA(const cpPolyShape *poly, const cpSplittingPlane *planes, const int num, cpFloat *min_out) { - int min_index = 0; - cpFloat min = cpPolyShapeValueOnAxis(poly, axes->n, axes->d); - if(min > 0.0f) return -1; - - for(int i=1; i 0.0f) { - return -1; - } else if(dist > min){ - min = dist; - min_index = i; - } - } - - (*min_out) = min; - return min_index; + int min_index = 0; + cpFloat min = cpPolyShapeValueOnAxis(poly, planes->n, planes->d); + if(min > 0.0f) return -1; + + for(int i=1; i 0.0f) { + return -1; + } else if(dist > min){ + min = dist; + min_index = i; + } + } + + (*min_out) = min; + return min_index; } // Add contacts for probably penetrating vertexes. @@ -130,92 +126,92 @@ findMSA(const cpPolyShape *poly, const cpPolyShapeAxis *axes, const int num, cpF static inline int findVertsFallback(cpContact *arr, const cpPolyShape *poly1, const cpPolyShape *poly2, const cpVect n, const cpFloat dist) { - int num = 0; - - for(int i=0; inumVerts; i++){ - cpVect v = poly1->tVerts[i]; - if(cpPolyShapeContainsVertPartial(poly2, v, cpvneg(n))) - cpContactInit(nextContactPoint(arr, &num), v, n, dist, CP_HASH_PAIR(poly1->shape.hashid, i)); - } - - for(int i=0; inumVerts; i++){ - cpVect v = poly2->tVerts[i]; - if(cpPolyShapeContainsVertPartial(poly1, v, n)) - cpContactInit(nextContactPoint(arr, &num), v, n, dist, CP_HASH_PAIR(poly2->shape.hashid, i)); - } - - return num; + int num = 0; + + for(int i=0; inumVerts; i++){ + cpVect v = poly1->tVerts[i]; + if(cpPolyShapeContainsVertPartial(poly2, v, cpvneg(n))) + cpContactInit(nextContactPoint(arr, &num), v, n, dist, CP_HASH_PAIR(poly1->shape.hashid, i)); + } + + for(int i=0; inumVerts; i++){ + cpVect v = poly2->tVerts[i]; + if(cpPolyShapeContainsVertPartial(poly1, v, n)) + cpContactInit(nextContactPoint(arr, &num), v, n, dist, CP_HASH_PAIR(poly2->shape.hashid, i)); + } + + return num; } // Add contacts for penetrating vertexes. static inline int findVerts(cpContact *arr, const cpPolyShape *poly1, const cpPolyShape *poly2, const cpVect n, const cpFloat dist) { - int num = 0; - - for(int i=0; inumVerts; i++){ - cpVect v = poly1->tVerts[i]; - if(cpPolyShapeContainsVert(poly2, v)) - cpContactInit(nextContactPoint(arr, &num), v, n, dist, CP_HASH_PAIR(poly1->shape.hashid, i)); - } - - for(int i=0; inumVerts; i++){ - cpVect v = poly2->tVerts[i]; - if(cpPolyShapeContainsVert(poly1, v)) - cpContactInit(nextContactPoint(arr, &num), v, n, dist, CP_HASH_PAIR(poly2->shape.hashid, i)); - } - - return (num ? num : findVertsFallback(arr, poly1, poly2, n, dist)); + int num = 0; + + for(int i=0; inumVerts; i++){ + cpVect v = poly1->tVerts[i]; + if(cpPolyShapeContainsVert(poly2, v)) + cpContactInit(nextContactPoint(arr, &num), v, n, dist, CP_HASH_PAIR(poly1->shape.hashid, i)); + } + + for(int i=0; inumVerts; i++){ + cpVect v = poly2->tVerts[i]; + if(cpPolyShapeContainsVert(poly1, v)) + cpContactInit(nextContactPoint(arr, &num), v, n, dist, CP_HASH_PAIR(poly2->shape.hashid, i)); + } + + return (num ? num : findVertsFallback(arr, poly1, poly2, n, dist)); } // Collide poly shapes together. static int poly2poly(const cpShape *shape1, const cpShape *shape2, cpContact *arr) { - cpPolyShape *poly1 = (cpPolyShape *)shape1; - cpPolyShape *poly2 = (cpPolyShape *)shape2; - - cpFloat min1; - int mini1 = findMSA(poly2, poly1->tAxes, poly1->numVerts, &min1); - if(mini1 == -1) return 0; - - cpFloat min2; - int mini2 = findMSA(poly1, poly2->tAxes, poly2->numVerts, &min2); - if(mini2 == -1) return 0; - - // There is overlap, find the penetrating verts - if(min1 > min2) - return findVerts(arr, poly1, poly2, poly1->tAxes[mini1].n, min1); - else - return findVerts(arr, poly1, poly2, cpvneg(poly2->tAxes[mini2].n), min2); + cpPolyShape *poly1 = (cpPolyShape *)shape1; + cpPolyShape *poly2 = (cpPolyShape *)shape2; + + cpFloat min1; + int mini1 = findMSA(poly2, poly1->tPlanes, poly1->numVerts, &min1); + if(mini1 == -1) return 0; + + cpFloat min2; + int mini2 = findMSA(poly1, poly2->tPlanes, poly2->numVerts, &min2); + if(mini2 == -1) return 0; + + // There is overlap, find the penetrating verts + if(min1 > min2) + return findVerts(arr, poly1, poly2, poly1->tPlanes[mini1].n, min1); + else + return findVerts(arr, poly1, poly2, cpvneg(poly2->tPlanes[mini2].n), min2); } // Like cpPolyValueOnAxis(), but for segments. static inline cpFloat segValueOnAxis(const cpSegmentShape *seg, const cpVect n, const cpFloat d) { - cpFloat a = cpvdot(n, seg->ta) - seg->r; - cpFloat b = cpvdot(n, seg->tb) - seg->r; - return cpfmin(a, b) - d; + cpFloat a = cpvdot(n, seg->ta) - seg->r; + cpFloat b = cpvdot(n, seg->tb) - seg->r; + return cpfmin(a, b) - d; } // Identify vertexes that have penetrated the segment. static inline void findPointsBehindSeg(cpContact *arr, int *num, const cpSegmentShape *seg, const cpPolyShape *poly, const cpFloat pDist, const cpFloat coef) { - cpFloat dta = cpvcross(seg->tn, seg->ta); - cpFloat dtb = cpvcross(seg->tn, seg->tb); - cpVect n = cpvmult(seg->tn, coef); - - for(int i=0; inumVerts; i++){ - cpVect v = poly->tVerts[i]; - if(cpvdot(v, n) < cpvdot(seg->tn, seg->ta)*coef + seg->r){ - cpFloat dt = cpvcross(seg->tn, v); - if(dta >= dt && dt >= dtb){ - cpContactInit(nextContactPoint(arr, num), v, n, pDist, CP_HASH_PAIR(poly->shape.hashid, i)); - } - } - } + cpFloat dta = cpvcross(seg->tn, seg->ta); + cpFloat dtb = cpvcross(seg->tn, seg->tb); + cpVect n = cpvmult(seg->tn, coef); + + for(int i=0; inumVerts; i++){ + cpVect v = poly->tVerts[i]; + if(cpvdot(v, n) < cpvdot(seg->tn, seg->ta)*coef + seg->r){ + cpFloat dt = cpvcross(seg->tn, v); + if(dta >= dt && dt >= dtb){ + cpContactInit(nextContactPoint(arr, num), v, n, pDist, CP_HASH_PAIR(poly->shape.hashid, i)); + } + } + } } // This one is complicated and gross. Just don't go there... @@ -223,62 +219,62 @@ findPointsBehindSeg(cpContact *arr, int *num, const cpSegmentShape *seg, const c static int seg2poly(const cpShape *shape1, const cpShape *shape2, cpContact *arr) { - cpSegmentShape *seg = (cpSegmentShape *)shape1; - cpPolyShape *poly = (cpPolyShape *)shape2; - cpPolyShapeAxis *axes = poly->tAxes; - - cpFloat segD = cpvdot(seg->tn, seg->ta); - cpFloat minNorm = cpPolyShapeValueOnAxis(poly, seg->tn, segD) - seg->r; - cpFloat minNeg = cpPolyShapeValueOnAxis(poly, cpvneg(seg->tn), -segD) - seg->r; - if(minNeg > 0.0f || minNorm > 0.0f) return 0; - - int mini = 0; - cpFloat poly_min = segValueOnAxis(seg, axes->n, axes->d); - if(poly_min > 0.0f) return 0; - for(int i=0; inumVerts; i++){ - cpFloat dist = segValueOnAxis(seg, axes[i].n, axes[i].d); - if(dist > 0.0f){ - return 0; - } else if(dist > poly_min){ - poly_min = dist; - mini = i; - } - } - - int num = 0; - - cpVect poly_n = cpvneg(axes[mini].n); - - cpVect va = cpvadd(seg->ta, cpvmult(poly_n, seg->r)); - cpVect vb = cpvadd(seg->tb, cpvmult(poly_n, seg->r)); - if(cpPolyShapeContainsVert(poly, va)) - cpContactInit(nextContactPoint(arr, &num), va, poly_n, poly_min, CP_HASH_PAIR(seg->shape.hashid, 0)); - if(cpPolyShapeContainsVert(poly, vb)) - cpContactInit(nextContactPoint(arr, &num), vb, poly_n, poly_min, CP_HASH_PAIR(seg->shape.hashid, 1)); - - // Floating point precision problems here. - // This will have to do for now. -// poly_min -= cp_collision_slop; // TODO is this needed anymore? - - if(minNorm >= poly_min || minNeg >= poly_min) { - if(minNorm > minNeg) - findPointsBehindSeg(arr, &num, seg, poly, minNorm, 1.0f); - else - findPointsBehindSeg(arr, &num, seg, poly, minNeg, -1.0f); - } - - // If no other collision points are found, try colliding endpoints. - if(num == 0){ - cpVect poly_a = poly->tVerts[mini]; - cpVect poly_b = poly->tVerts[(mini + 1)%poly->numVerts]; - - if(circle2circleQuery(seg->ta, poly_a, seg->r, 0.0f, arr)) return 1; - if(circle2circleQuery(seg->tb, poly_a, seg->r, 0.0f, arr)) return 1; - if(circle2circleQuery(seg->ta, poly_b, seg->r, 0.0f, arr)) return 1; - if(circle2circleQuery(seg->tb, poly_b, seg->r, 0.0f, arr)) return 1; - } + cpSegmentShape *seg = (cpSegmentShape *)shape1; + cpPolyShape *poly = (cpPolyShape *)shape2; + cpSplittingPlane *planes = poly->tPlanes; + + cpFloat segD = cpvdot(seg->tn, seg->ta); + cpFloat minNorm = cpPolyShapeValueOnAxis(poly, seg->tn, segD) - seg->r; + cpFloat minNeg = cpPolyShapeValueOnAxis(poly, cpvneg(seg->tn), -segD) - seg->r; + if(minNeg > 0.0f || minNorm > 0.0f) return 0; + + int mini = 0; + cpFloat poly_min = segValueOnAxis(seg, planes->n, planes->d); + if(poly_min > 0.0f) return 0; + for(int i=0; inumVerts; i++){ + cpFloat dist = segValueOnAxis(seg, planes[i].n, planes[i].d); + if(dist > 0.0f){ + return 0; + } else if(dist > poly_min){ + poly_min = dist; + mini = i; + } + } + + int num = 0; + + cpVect poly_n = cpvneg(planes[mini].n); + + cpVect va = cpvadd(seg->ta, cpvmult(poly_n, seg->r)); + cpVect vb = cpvadd(seg->tb, cpvmult(poly_n, seg->r)); + if(cpPolyShapeContainsVert(poly, va)) + cpContactInit(nextContactPoint(arr, &num), va, poly_n, poly_min, CP_HASH_PAIR(seg->shape.hashid, 0)); + if(cpPolyShapeContainsVert(poly, vb)) + cpContactInit(nextContactPoint(arr, &num), vb, poly_n, poly_min, CP_HASH_PAIR(seg->shape.hashid, 1)); + + // Floating point precision problems here. + // This will have to do for now. +// poly_min -= cp_collision_slop; // TODO is this needed anymore? + + if(minNorm >= poly_min || minNeg >= poly_min) { + if(minNorm > minNeg) + findPointsBehindSeg(arr, &num, seg, poly, minNorm, 1.0f); + else + findPointsBehindSeg(arr, &num, seg, poly, minNeg, -1.0f); + } + + // If no other collision points are found, try colliding endpoints. + if(num == 0){ + cpVect poly_a = poly->tVerts[mini]; + cpVect poly_b = poly->tVerts[(mini + 1)%poly->numVerts]; + + if(circle2circleQuery(seg->ta, poly_a, seg->r, 0.0f, arr)) return 1; + if(circle2circleQuery(seg->tb, poly_a, seg->r, 0.0f, arr)) return 1; + if(circle2circleQuery(seg->ta, poly_b, seg->r, 0.0f, arr)) return 1; + if(circle2circleQuery(seg->tb, poly_b, seg->r, 0.0f, arr)) return 1; + } - return num; + return num; } // This one is less gross, but still gross. @@ -286,56 +282,56 @@ seg2poly(const cpShape *shape1, const cpShape *shape2, cpContact *arr) static int circle2poly(const cpShape *shape1, const cpShape *shape2, cpContact *con) { - cpCircleShape *circ = (cpCircleShape *)shape1; - cpPolyShape *poly = (cpPolyShape *)shape2; - cpPolyShapeAxis *axes = poly->tAxes; - - int mini = 0; - cpFloat min = cpvdot(axes->n, circ->tc) - axes->d - circ->r; - for(int i=0; inumVerts; i++){ - cpFloat dist = cpvdot(axes[i].n, circ->tc) - axes[i].d - circ->r; - if(dist > 0.0f){ - return 0; - } else if(dist > min) { - min = dist; - mini = i; - } - } - - cpVect n = axes[mini].n; - cpVect a = poly->tVerts[mini]; - cpVect b = poly->tVerts[(mini + 1)%poly->numVerts]; - cpFloat dta = cpvcross(n, a); - cpFloat dtb = cpvcross(n, b); - cpFloat dt = cpvcross(n, circ->tc); - - if(dt < dtb){ - return circle2circleQuery(circ->tc, b, circ->r, 0.0f, con); - } else if(dt < dta) { - cpContactInit( - con, - cpvsub(circ->tc, cpvmult(n, circ->r + min/2.0f)), - cpvneg(n), - min, - 0 - ); - - return 1; - } else { - return circle2circleQuery(circ->tc, a, circ->r, 0.0f, con); - } + cpCircleShape *circ = (cpCircleShape *)shape1; + cpPolyShape *poly = (cpPolyShape *)shape2; + cpSplittingPlane *planes = poly->tPlanes; + + int mini = 0; + cpFloat min = cpSplittingPlaneCompare(planes[0], circ->tc) - circ->r; + for(int i=0; inumVerts; i++){ + cpFloat dist = cpSplittingPlaneCompare(planes[i], circ->tc) - circ->r; + if(dist > 0.0f){ + return 0; + } else if(dist > min) { + min = dist; + mini = i; + } + } + + cpVect n = planes[mini].n; + cpVect a = poly->tVerts[mini]; + cpVect b = poly->tVerts[(mini + 1)%poly->numVerts]; + cpFloat dta = cpvcross(n, a); + cpFloat dtb = cpvcross(n, b); + cpFloat dt = cpvcross(n, circ->tc); + + if(dt < dtb){ + return circle2circleQuery(circ->tc, b, circ->r, 0.0f, con); + } else if(dt < dta) { + cpContactInit( + con, + cpvsub(circ->tc, cpvmult(n, circ->r + min/2.0f)), + cpvneg(n), + min, + 0 + ); + + return 1; + } else { + return circle2circleQuery(circ->tc, a, circ->r, 0.0f, con); + } } static const collisionFunc builtinCollisionFuncs[9] = { - circle2circle, - NULL, - NULL, - (collisionFunc)circle2segment, - NULL, - NULL, - circle2poly, - seg2poly, - poly2poly, + circle2circle, + NULL, + NULL, + (collisionFunc)circle2segment, + NULL, + NULL, + circle2poly, + seg2poly, + poly2poly, }; static const collisionFunc *colfuncs = builtinCollisionFuncs; @@ -344,28 +340,28 @@ static const collisionFunc *colfuncs = builtinCollisionFuncs; //static void //addColFunc(const cpShapeType a, const cpShapeType b, const collisionFunc func) //{ -// colfuncs[a + b*CP_NUM_SHAPES] = func; +// colfuncs[a + b*CP_NUM_SHAPES] = func; //} // //#ifdef __cplusplus //extern "C" { //#endif -// void cpInitCollisionFuncs(void); -// -// // Initializes the array of collision functions. -// // Called by cpInitChipmunk(). -// void -// cpInitCollisionFuncs(void) -// { -// if(!colfuncs) -// colfuncs = (collisionFunc *)cpcalloc(CP_NUM_SHAPES*CP_NUM_SHAPES, sizeof(collisionFunc)); -// -// addColFunc(CP_CIRCLE_SHAPE, CP_CIRCLE_SHAPE, circle2circle); -// addColFunc(CP_CIRCLE_SHAPE, CP_SEGMENT_SHAPE, circle2segment); -// addColFunc(CP_SEGMENT_SHAPE, CP_POLY_SHAPE, seg2poly); -// addColFunc(CP_CIRCLE_SHAPE, CP_POLY_SHAPE, circle2poly); -// addColFunc(CP_POLY_SHAPE, CP_POLY_SHAPE, poly2poly); -// } +// void cpInitCollisionFuncs(void); +// +// // Initializes the array of collision functions. +// // Called by cpInitChipmunk(). +// void +// cpInitCollisionFuncs(void) +// { +// if(!colfuncs) +// colfuncs = (collisionFunc *)cpcalloc(CP_NUM_SHAPES*CP_NUM_SHAPES, sizeof(collisionFunc)); +// +// addColFunc(CP_CIRCLE_SHAPE, CP_CIRCLE_SHAPE, circle2circle); +// addColFunc(CP_CIRCLE_SHAPE, CP_SEGMENT_SHAPE, circle2segment); +// addColFunc(CP_SEGMENT_SHAPE, CP_POLY_SHAPE, seg2poly); +// addColFunc(CP_CIRCLE_SHAPE, CP_POLY_SHAPE, circle2poly); +// addColFunc(CP_POLY_SHAPE, CP_POLY_SHAPE, poly2poly); +// } //#ifdef __cplusplus //} //#endif @@ -373,9 +369,9 @@ static const collisionFunc *colfuncs = builtinCollisionFuncs; int cpCollideShapes(const cpShape *a, const cpShape *b, cpContact *arr) { - // Their shape types must be in order. - cpAssertSoft(a->klass->type <= b->klass->type, "Collision shapes passed to cpCollideShapes() are not sorted."); - - collisionFunc cfunc = colfuncs[a->klass->type + b->klass->type*CP_NUM_SHAPES]; - return (cfunc) ? cfunc(a, b, arr) : 0; + // Their shape types must be in order. + cpAssertSoft(a->klass->type <= b->klass->type, "Collision shapes passed to cpCollideShapes() are not sorted."); + + collisionFunc cfunc = colfuncs[a->klass->type + b->klass->type*CP_NUM_SHAPES]; + return (cfunc) ? cfunc(a, b, arr) : 0; } diff --git a/chipmunk/src/cpHashSet.c b/chipmunk/src/cpHashSet.c index dbf5f5b581..0d68a07476 100644 --- a/chipmunk/src/cpHashSet.c +++ b/chipmunk/src/cpHashSet.c @@ -19,238 +19,235 @@ * SOFTWARE. */ -#include -#include - #include "chipmunk_private.h" #include "prime.h" typedef struct cpHashSetBin { - void *elt; - cpHashValue hash; - struct cpHashSetBin *next; + void *elt; + cpHashValue hash; + struct cpHashSetBin *next; } cpHashSetBin; struct cpHashSet { - unsigned int entries, size; - - cpHashSetEqlFunc eql; - void *default_value; - - cpHashSetBin **table; - cpHashSetBin *pooledBins; - - cpArray *allocatedBuffers; + unsigned int entries, size; + + cpHashSetEqlFunc eql; + void *default_value; + + cpHashSetBin **table; + cpHashSetBin *pooledBins; + + cpArray *allocatedBuffers; }; void cpHashSetFree(cpHashSet *set) { - if(set){ - cpfree(set->table); - - cpArrayFreeEach(set->allocatedBuffers, cpfree); - cpArrayFree(set->allocatedBuffers); - - cpfree(set); - } + if(set){ + cpfree(set->table); + + cpArrayFreeEach(set->allocatedBuffers, cpfree); + cpArrayFree(set->allocatedBuffers); + + cpfree(set); + } } cpHashSet * cpHashSetNew(int size, cpHashSetEqlFunc eqlFunc) { - cpHashSet *set = (cpHashSet *)cpcalloc(1, sizeof(cpHashSet)); - - set->size = next_prime(size); - set->entries = 0; - - set->eql = eqlFunc; - set->default_value = NULL; - - set->table = (cpHashSetBin **)cpcalloc(set->size, sizeof(cpHashSetBin *)); - set->pooledBins = NULL; - - set->allocatedBuffers = cpArrayNew(0); - - return set; + cpHashSet *set = (cpHashSet *)cpcalloc(1, sizeof(cpHashSet)); + + set->size = next_prime(size); + set->entries = 0; + + set->eql = eqlFunc; + set->default_value = NULL; + + set->table = (cpHashSetBin **)cpcalloc(set->size, sizeof(cpHashSetBin *)); + set->pooledBins = NULL; + + set->allocatedBuffers = cpArrayNew(0); + + return set; } void cpHashSetSetDefaultValue(cpHashSet *set, void *default_value) { - set->default_value = default_value; + set->default_value = default_value; } static int setIsFull(cpHashSet *set) { - return (set->entries >= set->size); + return (set->entries >= set->size); } static void cpHashSetResize(cpHashSet *set) { - // Get the next approximate doubled prime. - unsigned int newSize = next_prime(set->size + 1); - // Allocate a new table. - cpHashSetBin **newTable = (cpHashSetBin **)cpcalloc(newSize, sizeof(cpHashSetBin *)); - - // Iterate over the chains. - for(unsigned int i=0; isize; i++){ - // Rehash the bins into the new table. - cpHashSetBin *bin = set->table[i]; - while(bin){ - cpHashSetBin *next = bin->next; - - cpHashValue idx = bin->hash%newSize; - bin->next = newTable[idx]; - newTable[idx] = bin; - - bin = next; - } - } - - cpfree(set->table); - - set->table = newTable; - set->size = newSize; + // Get the next approximate doubled prime. + unsigned int newSize = next_prime(set->size + 1); + // Allocate a new table. + cpHashSetBin **newTable = (cpHashSetBin **)cpcalloc(newSize, sizeof(cpHashSetBin *)); + + // Iterate over the chains. + for(unsigned int i=0; isize; i++){ + // Rehash the bins into the new table. + cpHashSetBin *bin = set->table[i]; + while(bin){ + cpHashSetBin *next = bin->next; + + cpHashValue idx = bin->hash%newSize; + bin->next = newTable[idx]; + newTable[idx] = bin; + + bin = next; + } + } + + cpfree(set->table); + + set->table = newTable; + set->size = newSize; } static inline void recycleBin(cpHashSet *set, cpHashSetBin *bin) { - bin->next = set->pooledBins; - set->pooledBins = bin; - bin->elt = NULL; + bin->next = set->pooledBins; + set->pooledBins = bin; + bin->elt = NULL; } static cpHashSetBin * getUnusedBin(cpHashSet *set) { - cpHashSetBin *bin = set->pooledBins; - - if(bin){ - set->pooledBins = bin->next; - return bin; - } else { - // Pool is exhausted, make more - int count = CP_BUFFER_BYTES/sizeof(cpHashSetBin); - cpAssertHard(count, "Internal Error: Buffer size is too small."); - - cpHashSetBin *buffer = (cpHashSetBin *)cpcalloc(1, CP_BUFFER_BYTES); - cpArrayPush(set->allocatedBuffers, buffer); - - // push all but the first one, return it instead - for(int i=1; ipooledBins; + + if(bin){ + set->pooledBins = bin->next; + return bin; + } else { + // Pool is exhausted, make more + int count = CP_BUFFER_BYTES/sizeof(cpHashSetBin); + cpAssertHard(count, "Internal Error: Buffer size is too small."); + + cpHashSetBin *buffer = (cpHashSetBin *)cpcalloc(1, CP_BUFFER_BYTES); + cpArrayPush(set->allocatedBuffers, buffer); + + // push all but the first one, return it instead + for(int i=1; ientries; + return set->entries; } void * cpHashSetInsert(cpHashSet *set, cpHashValue hash, void *ptr, void *data, cpHashSetTransFunc trans) { - cpHashValue idx = hash%set->size; - - // Find the bin with the matching element. - cpHashSetBin *bin = set->table[idx]; - while(bin && !set->eql(ptr, bin->elt)) - bin = bin->next; - - // Create it if necessary. - if(!bin){ - bin = getUnusedBin(set); - bin->hash = hash; - bin->elt = (trans ? trans(ptr, data) : data); - - bin->next = set->table[idx]; - set->table[idx] = bin; - - set->entries++; - if(setIsFull(set)) cpHashSetResize(set); - } - - return bin->elt; + cpHashValue idx = hash%set->size; + + // Find the bin with the matching element. + cpHashSetBin *bin = set->table[idx]; + while(bin && !set->eql(ptr, bin->elt)) + bin = bin->next; + + // Create it if necessary. + if(!bin){ + bin = getUnusedBin(set); + bin->hash = hash; + bin->elt = (trans ? trans(ptr, data) : data); + + bin->next = set->table[idx]; + set->table[idx] = bin; + + set->entries++; + if(setIsFull(set)) cpHashSetResize(set); + } + + return bin->elt; } void * cpHashSetRemove(cpHashSet *set, cpHashValue hash, void *ptr) { - cpHashValue idx = hash%set->size; - - cpHashSetBin **prev_ptr = &set->table[idx]; - cpHashSetBin *bin = set->table[idx]; - - // Find the bin - while(bin && !set->eql(ptr, bin->elt)){ - prev_ptr = &bin->next; - bin = bin->next; - } - - // Remove it if it exists. - if(bin){ - // Update the previous linked list pointer - (*prev_ptr) = bin->next; - set->entries--; - - void *elt = bin->elt; - recycleBin(set, bin); - - return elt; - } - - return NULL; + cpHashValue idx = hash%set->size; + + cpHashSetBin **prev_ptr = &set->table[idx]; + cpHashSetBin *bin = set->table[idx]; + + // Find the bin + while(bin && !set->eql(ptr, bin->elt)){ + prev_ptr = &bin->next; + bin = bin->next; + } + + // Remove it if it exists. + if(bin){ + // Update the previous linked list pointer + (*prev_ptr) = bin->next; + set->entries--; + + void *elt = bin->elt; + recycleBin(set, bin); + + return elt; + } + + return NULL; } void * cpHashSetFind(cpHashSet *set, cpHashValue hash, void *ptr) -{ - cpHashValue idx = hash%set->size; - cpHashSetBin *bin = set->table[idx]; - while(bin && !set->eql(ptr, bin->elt)) - bin = bin->next; - - return (bin ? bin->elt : set->default_value); +{ + cpHashValue idx = hash%set->size; + cpHashSetBin *bin = set->table[idx]; + while(bin && !set->eql(ptr, bin->elt)) + bin = bin->next; + + return (bin ? bin->elt : set->default_value); } void cpHashSetEach(cpHashSet *set, cpHashSetIteratorFunc func, void *data) { - for(unsigned int i=0; isize; i++){ - cpHashSetBin *bin = set->table[i]; - while(bin){ - cpHashSetBin *next = bin->next; - func(bin->elt, data); - bin = next; - } - } + for(unsigned int i=0; isize; i++){ + cpHashSetBin *bin = set->table[i]; + while(bin){ + cpHashSetBin *next = bin->next; + func(bin->elt, data); + bin = next; + } + } } void cpHashSetFilter(cpHashSet *set, cpHashSetFilterFunc func, void *data) { - for(unsigned int i=0; isize; i++){ - // The rest works similarly to cpHashSetRemove() above. - cpHashSetBin **prev_ptr = &set->table[i]; - cpHashSetBin *bin = set->table[i]; - while(bin){ - cpHashSetBin *next = bin->next; - - if(func(bin->elt, data)){ - prev_ptr = &bin->next; - } else { - (*prev_ptr) = next; + for(unsigned int i=0; isize; i++){ + // The rest works similarly to cpHashSetRemove() above. + cpHashSetBin **prev_ptr = &set->table[i]; + cpHashSetBin *bin = set->table[i]; + while(bin){ + cpHashSetBin *next = bin->next; + + if(func(bin->elt, data)){ + prev_ptr = &bin->next; + } else { + (*prev_ptr) = next; - set->entries--; - recycleBin(set, bin); - } - - bin = next; - } - } + set->entries--; + recycleBin(set, bin); + } + + bin = next; + } + } } diff --git a/chipmunk/src/cpPolyShape.c b/chipmunk/src/cpPolyShape.c index 2657a98a16..3f26a8a780 100644 --- a/chipmunk/src/cpPolyShape.c +++ b/chipmunk/src/cpPolyShape.c @@ -19,216 +19,238 @@ * SOFTWARE. */ -#include - #include "chipmunk_private.h" #include "chipmunk_unsafe.h" cpPolyShape * cpPolyShapeAlloc(void) { - return (cpPolyShape *)cpcalloc(1, sizeof(cpPolyShape)); + return (cpPolyShape *)cpcalloc(1, sizeof(cpPolyShape)); } static cpBB cpPolyShapeTransformVerts(cpPolyShape *poly, cpVect p, cpVect rot) { - cpVect *src = poly->verts; - cpVect *dst = poly->tVerts; - - cpFloat l = (cpFloat)INFINITY, r = -(cpFloat)INFINITY; - cpFloat b = (cpFloat)INFINITY, t = -(cpFloat)INFINITY; - - for(int i=0; inumVerts; i++){ - cpVect v = cpvadd(p, cpvrotate(src[i], rot)); - - dst[i] = v; - l = cpfmin(l, v.x); - r = cpfmax(r, v.x); - b = cpfmin(b, v.y); - t = cpfmax(t, v.y); - } - - return cpBBNew(l, b, r, t); + cpVect *src = poly->verts; + cpVect *dst = poly->tVerts; + + cpFloat l = (cpFloat)INFINITY, r = -(cpFloat)INFINITY; + cpFloat b = (cpFloat)INFINITY, t = -(cpFloat)INFINITY; + + for(int i=0; inumVerts; i++){ + cpVect v = cpvadd(p, cpvrotate(src[i], rot)); + + dst[i] = v; + l = cpfmin(l, v.x); + r = cpfmax(r, v.x); + b = cpfmin(b, v.y); + t = cpfmax(t, v.y); + } + + return cpBBNew(l, b, r, t); } static void cpPolyShapeTransformAxes(cpPolyShape *poly, cpVect p, cpVect rot) { - cpPolyShapeAxis *src = poly->axes; - cpPolyShapeAxis *dst = poly->tAxes; - - for(int i=0; inumVerts; i++){ - cpVect n = cpvrotate(src[i].n, rot); - dst[i].n = n; - dst[i].d = cpvdot(p, n) + src[i].d; - } + cpSplittingPlane *src = poly->planes; + cpSplittingPlane *dst = poly->tPlanes; + + for(int i=0; inumVerts; i++){ + cpVect n = cpvrotate(src[i].n, rot); + dst[i].n = n; + dst[i].d = cpvdot(p, n) + src[i].d; + } } static cpBB cpPolyShapeCacheData(cpPolyShape *poly, cpVect p, cpVect rot) { - cpPolyShapeTransformAxes(poly, p, rot); - cpBB bb = poly->shape.bb = cpPolyShapeTransformVerts(poly, p, rot); - - return bb; + cpPolyShapeTransformAxes(poly, p, rot); + cpBB bb = poly->shape.bb = cpPolyShapeTransformVerts(poly, p, rot); + + return bb; } static void cpPolyShapeDestroy(cpPolyShape *poly) { - cpfree(poly->verts); - cpfree(poly->tVerts); - - cpfree(poly->axes); - cpfree(poly->tAxes); + cpfree(poly->verts); + cpfree(poly->planes); } -static cpBool -cpPolyShapePointQuery(cpPolyShape *poly, cpVect p){ - return cpBBContainsVect(poly->shape.bb, p) && cpPolyShapeContainsVert(poly, p); +static void +cpPolyShapeNearestPointQuery(cpPolyShape *poly, cpVect p, cpNearestPointQueryInfo *info){ + int count = poly->numVerts; + cpSplittingPlane *planes = poly->tPlanes; + cpVect *verts = poly->tVerts; + + cpVect v0 = verts[count - 1]; + cpFloat minDist = INFINITY; + cpVect closestPoint = cpvzero; + cpBool outside = cpFalse; + + for(int i=0; i 0.0f) outside = cpTrue; + + cpVect v1 = verts[i]; + cpVect closest = cpClosetPointOnSegment(p, v0, v1); + + cpFloat dist = cpvdist(p, closest); + if(dist < minDist){ + minDist = dist; + closestPoint = closest; + } + + v0 = v1; + } + + info->shape = (cpShape *)poly; + info->p = closestPoint; // TODO div/0 + info->d = (outside ? minDist : -minDist); } static void cpPolyShapeSegmentQuery(cpPolyShape *poly, cpVect a, cpVect b, cpSegmentQueryInfo *info) { - cpPolyShapeAxis *axes = poly->tAxes; - cpVect *verts = poly->tVerts; - int numVerts = poly->numVerts; - - for(int i=0; i an) continue; - - cpFloat bn = cpvdot(b, n); - cpFloat t = (axes[i].d - an)/(bn - an); - if(t < 0.0f || 1.0f < t) continue; - - cpVect point = cpvlerp(a, b, t); - cpFloat dt = -cpvcross(n, point); - cpFloat dtMin = -cpvcross(n, verts[i]); - cpFloat dtMax = -cpvcross(n, verts[(i+1)%numVerts]); - - if(dtMin <= dt && dt <= dtMax){ - info->shape = (cpShape *)poly; - info->t = t; - info->n = n; - } - } + cpSplittingPlane *axes = poly->tPlanes; + cpVect *verts = poly->tVerts; + int numVerts = poly->numVerts; + + for(int i=0; i an) continue; + + cpFloat bn = cpvdot(b, n); + cpFloat t = (axes[i].d - an)/(bn - an); + if(t < 0.0f || 1.0f < t) continue; + + cpVect point = cpvlerp(a, b, t); + cpFloat dt = -cpvcross(n, point); + cpFloat dtMin = -cpvcross(n, verts[i]); + cpFloat dtMax = -cpvcross(n, verts[(i+1)%numVerts]); + + if(dtMin <= dt && dt <= dtMax){ + info->shape = (cpShape *)poly; + info->t = t; + info->n = n; + } + } } static const cpShapeClass polyClass = { - CP_POLY_SHAPE, - (cpShapeCacheDataImpl)cpPolyShapeCacheData, - (cpShapeDestroyImpl)cpPolyShapeDestroy, - (cpShapePointQueryImpl)cpPolyShapePointQuery, - (cpShapeSegmentQueryImpl)cpPolyShapeSegmentQuery, + CP_POLY_SHAPE, + (cpShapeCacheDataImpl)cpPolyShapeCacheData, + (cpShapeDestroyImpl)cpPolyShapeDestroy, + (cpShapeNearestPointQueryImpl)cpPolyShapeNearestPointQuery, + (cpShapeSegmentQueryImpl)cpPolyShapeSegmentQuery, }; cpBool cpPolyValidate(const cpVect *verts, const int numVerts) { - for(int i=0; i 0.0f) - return cpFalse; - } - - return cpTrue; + for(int i=0; i 0.0f){ + return cpFalse; + } + } + + return cpTrue; } int cpPolyShapeGetNumVerts(cpShape *shape) { - cpAssertHard(shape->klass == &polyClass, "Shape is not a poly shape."); - return ((cpPolyShape *)shape)->numVerts; + cpAssertHard(shape->klass == &polyClass, "Shape is not a poly shape."); + return ((cpPolyShape *)shape)->numVerts; } cpVect cpPolyShapeGetVert(cpShape *shape, int idx) { - cpAssertHard(shape->klass == &polyClass, "Shape is not a poly shape."); - cpAssertHard(0 <= idx && idx < cpPolyShapeGetNumVerts(shape), "Index out of range."); - - return ((cpPolyShape *)shape)->verts[idx]; + cpAssertHard(shape->klass == &polyClass, "Shape is not a poly shape."); + cpAssertHard(0 <= idx && idx < cpPolyShapeGetNumVerts(shape), "Index out of range."); + + return ((cpPolyShape *)shape)->verts[idx]; } static void setUpVerts(cpPolyShape *poly, int numVerts, cpVect *verts, cpVect offset) { - poly->numVerts = numVerts; + // Fail if the user attempts to pass a concave poly, or a bad winding. + cpAssertHard(cpPolyValidate(verts, numVerts), "Polygon is concave or has a reversed winding. Consider using cpConvexHull() or CP_CONVEX_HULL()."); + + poly->numVerts = numVerts; + poly->verts = (cpVect *)cpcalloc(2*numVerts, sizeof(cpVect)); + poly->planes = (cpSplittingPlane *)cpcalloc(2*numVerts, sizeof(cpSplittingPlane)); + poly->tVerts = poly->verts + numVerts; + poly->tPlanes = poly->planes + numVerts; + + for(int i=0; iverts = (cpVect *)cpcalloc(numVerts, sizeof(cpVect)); - poly->tVerts = (cpVect *)cpcalloc(numVerts, sizeof(cpVect)); - poly->axes = (cpPolyShapeAxis *)cpcalloc(numVerts, sizeof(cpPolyShapeAxis)); - poly->tAxes = (cpPolyShapeAxis *)cpcalloc(numVerts, sizeof(cpPolyShapeAxis)); - - for(int i=0; iverts[i] = a; - poly->axes[i].n = n; - poly->axes[i].d = cpvdot(n, a); - } + poly->verts[i] = a; + poly->planes[i].n = n; + poly->planes[i].d = cpvdot(n, a); + } + } cpPolyShape * cpPolyShapeInit(cpPolyShape *poly, cpBody *body, int numVerts, cpVect *verts, cpVect offset) { - // Fail if the user attempts to pass a concave poly, or a bad winding. - cpAssertHard(cpPolyValidate(verts, numVerts), "Polygon is concave or has a reversed winding."); - - setUpVerts(poly, numVerts, verts, offset); - cpShapeInit((cpShape *)poly, &polyClass, body); + setUpVerts(poly, numVerts, verts, offset); + cpShapeInit((cpShape *)poly, &polyClass, body); - return poly; + return poly; } cpShape * cpPolyShapeNew(cpBody *body, int numVerts, cpVect *verts, cpVect offset) { - return (cpShape *)cpPolyShapeInit(cpPolyShapeAlloc(), body, numVerts, verts, offset); + return (cpShape *)cpPolyShapeInit(cpPolyShapeAlloc(), body, numVerts, verts, offset); } cpPolyShape * cpBoxShapeInit(cpPolyShape *poly, cpBody *body, cpFloat width, cpFloat height) { - cpFloat hw = width/2.0f; - cpFloat hh = height/2.0f; - - return cpBoxShapeInit2(poly, body, cpBBNew(-hw, -hh, hw, hh)); + cpFloat hw = width/2.0f; + cpFloat hh = height/2.0f; + + return cpBoxShapeInit2(poly, body, cpBBNew(-hw, -hh, hw, hh)); } cpPolyShape * cpBoxShapeInit2(cpPolyShape *poly, cpBody *body, cpBB box) { - cpVect verts[] = { - cpv(box.l, box.b), - cpv(box.l, box.t), - cpv(box.r, box.t), - cpv(box.r, box.b), - }; - - return cpPolyShapeInit(poly, body, 4, verts, cpvzero); + cpVect verts[] = { + cpv(box.l, box.b), + cpv(box.l, box.t), + cpv(box.r, box.t), + cpv(box.r, box.b), + }; + + return cpPolyShapeInit(poly, body, 4, verts, cpvzero); } cpShape * cpBoxShapeNew(cpBody *body, cpFloat width, cpFloat height) { - return (cpShape *)cpBoxShapeInit(cpPolyShapeAlloc(), body, width, height); + return (cpShape *)cpBoxShapeInit(cpPolyShapeAlloc(), body, width, height); } cpShape * cpBoxShapeNew2(cpBody *body, cpBB box) { - return (cpShape *)cpBoxShapeInit2(cpPolyShapeAlloc(), body, box); + return (cpShape *)cpBoxShapeInit2(cpPolyShapeAlloc(), body, box); } // Unsafe API (chipmunk_unsafe.h) @@ -236,7 +258,7 @@ cpBoxShapeNew2(cpBody *body, cpBB box) void cpPolyShapeSetVerts(cpShape *shape, int numVerts, cpVect *verts, cpVect offset) { - cpAssertHard(shape->klass == &polyClass, "Shape is not a poly shape."); - cpPolyShapeDestroy((cpPolyShape *)shape); - setUpVerts((cpPolyShape *)shape, numVerts, verts, offset); + cpAssertHard(shape->klass == &polyClass, "Shape is not a poly shape."); + cpPolyShapeDestroy((cpPolyShape *)shape); + setUpVerts((cpPolyShape *)shape, numVerts, verts, offset); } diff --git a/chipmunk/src/cpShape.c b/chipmunk/src/cpShape.c index 486d9510c7..beb3395def 100644 --- a/chipmunk/src/cpShape.c +++ b/chipmunk/src/cpShape.c @@ -19,17 +19,13 @@ * SOFTWARE. */ -#include -#include -#include - #include "chipmunk_private.h" #include "chipmunk_unsafe.h" #define CP_DefineShapeGetter(struct, type, member, name) \ CP_DeclareShapeGetter(struct, type, name){ \ - cpAssertHard(shape->klass == &struct##Class, "shape is not a "#struct); \ - return ((struct *)shape)->member; \ + cpAssertHard(shape->klass == &struct##Class, "shape is not a "#struct); \ + return ((struct *)shape)->member; \ } static cpHashValue cpShapeIDCounter = 0; @@ -37,155 +33,187 @@ static cpHashValue cpShapeIDCounter = 0; void cpResetShapeIdCounter(void) { - cpShapeIDCounter = 0; + cpShapeIDCounter = 0; } cpShape* cpShapeInit(cpShape *shape, const cpShapeClass *klass, cpBody *body) { - shape->klass = klass; - - shape->hashid = cpShapeIDCounter; - cpShapeIDCounter++; - - shape->body = body; - shape->sensor = 0; - - shape->e = 0.0f; - shape->u = 0.0f; - shape->surface_v = cpvzero; - - shape->collision_type = 0; - shape->group = CP_NO_GROUP; - shape->layers = CP_ALL_LAYERS; - - shape->data = NULL; - shape->next = NULL; - shape->prev = NULL; - - return shape; + shape->klass = klass; + + shape->hashid = cpShapeIDCounter; + cpShapeIDCounter++; + + shape->body = body; + shape->sensor = 0; + + shape->e = 0.0f; + shape->u = 0.0f; + shape->surface_v = cpvzero; + + shape->collision_type = 0; + shape->group = CP_NO_GROUP; + shape->layers = CP_ALL_LAYERS; + + shape->data = NULL; + + shape->space = NULL; + + shape->next = NULL; + shape->prev = NULL; + + return shape; } void cpShapeDestroy(cpShape *shape) { - if(shape->klass && shape->klass->destroy) shape->klass->destroy(shape); + if(shape->klass && shape->klass->destroy) shape->klass->destroy(shape); } void cpShapeFree(cpShape *shape) { - if(shape){ - cpShapeDestroy(shape); - cpfree(shape); - } + if(shape){ + cpShapeDestroy(shape); + cpfree(shape); + } } void cpShapeSetBody(cpShape *shape, cpBody *body) { - cpAssertHard(!cpShapeActive(shape), "You cannot change the body on an active shape. You must remove the shape, then "); - shape->body = body; + cpAssertHard(!cpShapeActive(shape), "You cannot change the body on an active shape. You must remove the shape from the space before changing the body."); + shape->body = body; } cpBB cpShapeCacheBB(cpShape *shape) { - cpBody *body = shape->body; - return cpShapeUpdate(shape, body->p, body->rot); + cpBody *body = shape->body; + return cpShapeUpdate(shape, body->p, body->rot); } cpBB cpShapeUpdate(cpShape *shape, cpVect pos, cpVect rot) { - return (shape->bb = shape->klass->cacheData(shape, pos, rot)); + return (shape->bb = shape->klass->cacheData(shape, pos, rot)); } cpBool cpShapePointQuery(cpShape *shape, cpVect p){ - return shape->klass->pointQuery(shape, p); + cpNearestPointQueryInfo info = {}; + cpShapeNearestPointQuery(shape, p, &info); + + return (info.d < 0.0f); } +cpFloat +cpShapeNearestPointQuery(cpShape *shape, cpVect p, cpNearestPointQueryInfo *info) +{ + cpNearestPointQueryInfo blank = {NULL, cpvzero, INFINITY}; + if(info){ + (*info) = blank; + } else { + info = ␣ + } + + shape->klass->nearestPointQuery(shape, p, info); + return info->d; +} + + cpBool cpShapeSegmentQuery(cpShape *shape, cpVect a, cpVect b, cpSegmentQueryInfo *info){ - cpSegmentQueryInfo blank = {NULL, 0.0f, cpvzero}; - (*info) = blank; - - shape->klass->segmentQuery(shape, a, b, info); - return (info->shape != NULL); + cpSegmentQueryInfo blank = {NULL, 0.0f, cpvzero}; + if(info){ + (*info) = blank; + } else { + info = ␣ + } + + shape->klass->segmentQuery(shape, a, b, info); + return (info->shape != NULL); } cpCircleShape * cpCircleShapeAlloc(void) { - return (cpCircleShape *)cpcalloc(1, sizeof(cpCircleShape)); + return (cpCircleShape *)cpcalloc(1, sizeof(cpCircleShape)); } static cpBB cpCircleShapeCacheData(cpCircleShape *circle, cpVect p, cpVect rot) { - cpVect c = circle->tc = cpvadd(p, cpvrotate(circle->c, rot)); - return cpBBNewForCircle(c, circle->r); + cpVect c = circle->tc = cpvadd(p, cpvrotate(circle->c, rot)); + return cpBBNewForCircle(c, circle->r); } -static cpBool -cpCircleShapePointQuery(cpCircleShape *circle, cpVect p){ - return cpvnear(circle->tc, p, circle->r); +static void +cpCicleShapeNearestPointQuery(cpCircleShape *circle, cpVect p, cpNearestPointQueryInfo *info) +{ + cpVect delta = cpvsub(p, circle->tc); + cpFloat d = cpvlength(delta); + cpFloat r = circle->r; + + info->shape = (cpShape *)circle; + info->p = cpvadd(circle->tc, cpvmult(delta, r/d)); // TODO div/0 + info->d = d - r; } static void circleSegmentQuery(cpShape *shape, cpVect center, cpFloat r, cpVect a, cpVect b, cpSegmentQueryInfo *info) { - // offset the line to be relative to the circle - a = cpvsub(a, center); - b = cpvsub(b, center); - - cpFloat qa = cpvdot(a, a) - 2.0f*cpvdot(a, b) + cpvdot(b, b); - cpFloat qb = -2.0f*cpvdot(a, a) + 2.0f*cpvdot(a, b); - cpFloat qc = cpvdot(a, a) - r*r; - - cpFloat det = qb*qb - 4.0f*qa*qc; - - if(det >= 0.0f){ - cpFloat t = (-qb - cpfsqrt(det))/(2.0f*qa); - if(0.0f<= t && t <= 1.0f){ - info->shape = shape; - info->t = t; - info->n = cpvnormalize(cpvlerp(a, b, t)); - } - } + // offset the line to be relative to the circle + a = cpvsub(a, center); + b = cpvsub(b, center); + + cpFloat qa = cpvdot(a, a) - 2.0f*cpvdot(a, b) + cpvdot(b, b); + cpFloat qb = -2.0f*cpvdot(a, a) + 2.0f*cpvdot(a, b); + cpFloat qc = cpvdot(a, a) - r*r; + + cpFloat det = qb*qb - 4.0f*qa*qc; + + if(det >= 0.0f){ + cpFloat t = (-qb - cpfsqrt(det))/(2.0f*qa); + if(0.0f<= t && t <= 1.0f){ + info->shape = shape; + info->t = t; + info->n = cpvnormalize(cpvlerp(a, b, t)); + } + } } static void cpCircleShapeSegmentQuery(cpCircleShape *circle, cpVect a, cpVect b, cpSegmentQueryInfo *info) { - circleSegmentQuery((cpShape *)circle, circle->tc, circle->r, a, b, info); + circleSegmentQuery((cpShape *)circle, circle->tc, circle->r, a, b, info); } static const cpShapeClass cpCircleShapeClass = { - CP_CIRCLE_SHAPE, - (cpShapeCacheDataImpl)cpCircleShapeCacheData, - NULL, - (cpShapePointQueryImpl)cpCircleShapePointQuery, - (cpShapeSegmentQueryImpl)cpCircleShapeSegmentQuery, + CP_CIRCLE_SHAPE, + (cpShapeCacheDataImpl)cpCircleShapeCacheData, + NULL, + (cpShapeNearestPointQueryImpl)cpCicleShapeNearestPointQuery, + (cpShapeSegmentQueryImpl)cpCircleShapeSegmentQuery, }; cpCircleShape * cpCircleShapeInit(cpCircleShape *circle, cpBody *body, cpFloat radius, cpVect offset) { - circle->c = offset; - circle->r = radius; - - cpShapeInit((cpShape *)circle, &cpCircleShapeClass, body); - - return circle; + circle->c = offset; + circle->r = radius; + + cpShapeInit((cpShape *)circle, &cpCircleShapeClass, body); + + return circle; } cpShape * cpCircleShapeNew(cpBody *body, cpFloat radius, cpVect offset) { - return (cpShape *)cpCircleShapeInit(cpCircleShapeAlloc(), body, radius, offset); + return (cpShape *)cpCircleShapeInit(cpCircleShapeAlloc(), body, radius, offset); } CP_DefineShapeGetter(cpCircleShape, cpVect, c, Offset) @@ -194,142 +222,120 @@ CP_DefineShapeGetter(cpCircleShape, cpFloat, r, Radius) cpSegmentShape * cpSegmentShapeAlloc(void) { - return (cpSegmentShape *)cpcalloc(1, sizeof(cpSegmentShape)); + return (cpSegmentShape *)cpcalloc(1, sizeof(cpSegmentShape)); } static cpBB cpSegmentShapeCacheData(cpSegmentShape *seg, cpVect p, cpVect rot) { - seg->ta = cpvadd(p, cpvrotate(seg->a, rot)); - seg->tb = cpvadd(p, cpvrotate(seg->b, rot)); - seg->tn = cpvrotate(seg->n, rot); - - cpFloat l,r,b,t; - - if(seg->ta.x < seg->tb.x){ - l = seg->ta.x; - r = seg->tb.x; - } else { - l = seg->tb.x; - r = seg->ta.x; - } - - if(seg->ta.y < seg->tb.y){ - b = seg->ta.y; - t = seg->tb.y; - } else { - b = seg->tb.y; - t = seg->ta.y; - } - - cpFloat rad = seg->r; - return cpBBNew(l - rad, b - rad, r + rad, t + rad); + seg->ta = cpvadd(p, cpvrotate(seg->a, rot)); + seg->tb = cpvadd(p, cpvrotate(seg->b, rot)); + seg->tn = cpvrotate(seg->n, rot); + + cpFloat l,r,b,t; + + if(seg->ta.x < seg->tb.x){ + l = seg->ta.x; + r = seg->tb.x; + } else { + l = seg->tb.x; + r = seg->ta.x; + } + + if(seg->ta.y < seg->tb.y){ + b = seg->ta.y; + t = seg->tb.y; + } else { + b = seg->tb.y; + t = seg->ta.y; + } + + cpFloat rad = seg->r; + return cpBBNew(l - rad, b - rad, r + rad, t + rad); } -static cpBool -cpSegmentShapePointQuery(cpSegmentShape *seg, cpVect p){ - if(!cpBBContainsVect(seg->shape.bb, p)) return cpFalse; - - // Calculate normal distance from segment. - cpFloat dn = cpvdot(seg->tn, p) - cpvdot(seg->ta, seg->tn); - cpFloat dist = cpfabs(dn) - seg->r; - if(dist > 0.0f) return cpFalse; - - // Calculate tangential distance along segment. - cpFloat dt = -cpvcross(seg->tn, p); - cpFloat dtMin = -cpvcross(seg->tn, seg->ta); - cpFloat dtMax = -cpvcross(seg->tn, seg->tb); - - // Decision tree to decide which feature of the segment to collide with. - if(dt <= dtMin){ - if(dt < (dtMin - seg->r)){ - return cpFalse; - } else { - return cpvlengthsq(cpvsub(seg->ta, p)) < (seg->r*seg->r); - } - } else { - if(dt < dtMax){ - return cpTrue; - } else { - if(dt < (dtMax + seg->r)) { - return cpvlengthsq(cpvsub(seg->tb, p)) < (seg->r*seg->r); - } else { - return cpFalse; - } - } - } - - return cpTrue; +static void +cpSegmentShapeNearestPointQuery(cpSegmentShape *seg, cpVect p, cpNearestPointQueryInfo *info) +{ + cpVect closest = cpClosetPointOnSegment(p, seg->ta, seg->tb); + + cpVect delta = cpvsub(p, closest); + cpFloat d = cpvlength(delta); + cpFloat r = seg->r; + + info->shape = (cpShape *)seg; + info->p = (d ? cpvadd(closest, cpvmult(delta, r/d)) : closest); + info->d = d - r; } static void cpSegmentShapeSegmentQuery(cpSegmentShape *seg, cpVect a, cpVect b, cpSegmentQueryInfo *info) { - cpVect n = seg->tn; - cpFloat d = cpvdot(cpvsub(seg->ta, a), n); - cpFloat r = seg->r; - - cpVect flipped_n = (d > 0.0f ? cpvneg(n) : n); - cpVect seg_offset = cpvsub(cpvmult(flipped_n, r), a); - - // Make the endpoints relative to 'a' and move them by the thickness of the segment. - cpVect seg_a = cpvadd(seg->ta, seg_offset); - cpVect seg_b = cpvadd(seg->tb, seg_offset); - cpVect delta = cpvsub(b, a); - - if(cpvcross(delta, seg_a)*cpvcross(delta, seg_b) <= 0.0f){ - cpFloat d_offset = d + (d > 0.0f ? -r : r); - cpFloat ad = -d_offset; - cpFloat bd = cpvdot(delta, n) - d_offset; - - if(ad*bd < 0.0f){ - info->shape = (cpShape *)seg; - info->t = ad/(ad - bd); - info->n = flipped_n; - } - } else if(r != 0.0f){ - cpSegmentQueryInfo info1 = {NULL, 1.0f, cpvzero}; - cpSegmentQueryInfo info2 = {NULL, 1.0f, cpvzero}; - circleSegmentQuery((cpShape *)seg, seg->ta, seg->r, a, b, &info1); - circleSegmentQuery((cpShape *)seg, seg->tb, seg->r, a, b, &info2); - - if(info1.t < info2.t){ - (*info) = info1; - } else { - (*info) = info2; - } - } + cpVect n = seg->tn; + cpFloat d = cpvdot(cpvsub(seg->ta, a), n); + cpFloat r = seg->r; + + cpVect flipped_n = (d > 0.0f ? cpvneg(n) : n); + cpVect seg_offset = cpvsub(cpvmult(flipped_n, r), a); + + // Make the endpoints relative to 'a' and move them by the thickness of the segment. + cpVect seg_a = cpvadd(seg->ta, seg_offset); + cpVect seg_b = cpvadd(seg->tb, seg_offset); + cpVect delta = cpvsub(b, a); + + if(cpvcross(delta, seg_a)*cpvcross(delta, seg_b) <= 0.0f){ + cpFloat d_offset = d + (d > 0.0f ? -r : r); + cpFloat ad = -d_offset; + cpFloat bd = cpvdot(delta, n) - d_offset; + + if(ad*bd < 0.0f){ + info->shape = (cpShape *)seg; + info->t = ad/(ad - bd); + info->n = flipped_n; + } + } else if(r != 0.0f){ + cpSegmentQueryInfo info1 = {NULL, 1.0f, cpvzero}; + cpSegmentQueryInfo info2 = {NULL, 1.0f, cpvzero}; + circleSegmentQuery((cpShape *)seg, seg->ta, seg->r, a, b, &info1); + circleSegmentQuery((cpShape *)seg, seg->tb, seg->r, a, b, &info2); + + if(info1.t < info2.t){ + (*info) = info1; + } else { + (*info) = info2; + } + } } static const cpShapeClass cpSegmentShapeClass = { - CP_SEGMENT_SHAPE, - (cpShapeCacheDataImpl)cpSegmentShapeCacheData, - NULL, - (cpShapePointQueryImpl)cpSegmentShapePointQuery, - (cpShapeSegmentQueryImpl)cpSegmentShapeSegmentQuery, + CP_SEGMENT_SHAPE, + (cpShapeCacheDataImpl)cpSegmentShapeCacheData, + NULL, + (cpShapeNearestPointQueryImpl)cpSegmentShapeNearestPointQuery, + (cpShapeSegmentQueryImpl)cpSegmentShapeSegmentQuery, }; cpSegmentShape * cpSegmentShapeInit(cpSegmentShape *seg, cpBody *body, cpVect a, cpVect b, cpFloat r) { - seg->a = a; - seg->b = b; - seg->n = cpvperp(cpvnormalize(cpvsub(b, a))); - - seg->r = r; - - seg->a_tangent = cpvzero; - seg->b_tangent = cpvzero; - - cpShapeInit((cpShape *)seg, &cpSegmentShapeClass, body); - - return seg; + seg->a = a; + seg->b = b; + seg->n = cpvperp(cpvnormalize(cpvsub(b, a))); + + seg->r = r; + + seg->a_tangent = cpvzero; + seg->b_tangent = cpvzero; + + cpShapeInit((cpShape *)seg, &cpSegmentShapeClass, body); + + return seg; } cpShape* cpSegmentShapeNew(cpBody *body, cpVect a, cpVect b, cpFloat r) { - return (cpShape *)cpSegmentShapeInit(cpSegmentShapeAlloc(), body, a, b, r); + return (cpShape *)cpSegmentShapeInit(cpSegmentShapeAlloc(), body, a, b, r); } CP_DefineShapeGetter(cpSegmentShape, cpVect, a, A) @@ -340,11 +346,11 @@ CP_DefineShapeGetter(cpSegmentShape, cpFloat, r, Radius) void cpSegmentShapeSetNeighbors(cpShape *shape, cpVect prev, cpVect next) { - cpAssertHard(shape->klass == &cpSegmentShapeClass, "Shape is not a segment shape."); - cpSegmentShape *seg = (cpSegmentShape *)shape; - - seg->a_tangent = cpvsub(prev, seg->a); - seg->b_tangent = cpvsub(next, seg->b); + cpAssertHard(shape->klass == &cpSegmentShapeClass, "Shape is not a segment shape."); + cpSegmentShape *seg = (cpSegmentShape *)shape; + + seg->a_tangent = cpvsub(prev, seg->a); + seg->b_tangent = cpvsub(next, seg->b); } // Unsafe API (chipmunk_unsafe.h) @@ -352,37 +358,37 @@ cpSegmentShapeSetNeighbors(cpShape *shape, cpVect prev, cpVect next) void cpCircleShapeSetRadius(cpShape *shape, cpFloat radius) { - cpAssertHard(shape->klass == &cpCircleShapeClass, "Shape is not a circle shape."); - cpCircleShape *circle = (cpCircleShape *)shape; - - circle->r = radius; + cpAssertHard(shape->klass == &cpCircleShapeClass, "Shape is not a circle shape."); + cpCircleShape *circle = (cpCircleShape *)shape; + + circle->r = radius; } void cpCircleShapeSetOffset(cpShape *shape, cpVect offset) { - cpAssertHard(shape->klass == &cpCircleShapeClass, "Shape is not a circle shape."); - cpCircleShape *circle = (cpCircleShape *)shape; - - circle->c = offset; + cpAssertHard(shape->klass == &cpCircleShapeClass, "Shape is not a circle shape."); + cpCircleShape *circle = (cpCircleShape *)shape; + + circle->c = offset; } void cpSegmentShapeSetEndpoints(cpShape *shape, cpVect a, cpVect b) { - cpAssertHard(shape->klass == &cpSegmentShapeClass, "Shape is not a segment shape."); - cpSegmentShape *seg = (cpSegmentShape *)shape; - - seg->a = a; - seg->b = b; - seg->n = cpvperp(cpvnormalize(cpvsub(b, a))); + cpAssertHard(shape->klass == &cpSegmentShapeClass, "Shape is not a segment shape."); + cpSegmentShape *seg = (cpSegmentShape *)shape; + + seg->a = a; + seg->b = b; + seg->n = cpvperp(cpvnormalize(cpvsub(b, a))); } void cpSegmentShapeSetRadius(cpShape *shape, cpFloat radius) { - cpAssertHard(shape->klass == &cpSegmentShapeClass, "Shape is not a segment shape."); - cpSegmentShape *seg = (cpSegmentShape *)shape; - - seg->r = radius; + cpAssertHard(shape->klass == &cpSegmentShapeClass, "Shape is not a segment shape."); + cpSegmentShape *seg = (cpSegmentShape *)shape; + + seg->r = radius; } diff --git a/chipmunk/src/cpSpace.c b/chipmunk/src/cpSpace.c index a86f632b3b..6501bca05b 100644 --- a/chipmunk/src/cpSpace.c +++ b/chipmunk/src/cpSpace.c @@ -19,10 +19,8 @@ * SOFTWARE. */ -#include #include #include -#include #include "chipmunk_private.h" @@ -32,10 +30,10 @@ static cpBool arbiterSetEql(cpShape **shapes, cpArbiter *arb) { - cpShape *a = shapes[0]; - cpShape *b = shapes[1]; - - return ((a == arb->a && b == arb->b) || (b == arb->a && a == arb->b)); + cpShape *a = shapes[0]; + cpShape *b = shapes[1]; + + return ((a == arb->a && b == arb->b) || (b == arb->a && a == arb->b)); } //MARK: Collision Handler Set HelperFunctions @@ -44,17 +42,17 @@ arbiterSetEql(cpShape **shapes, cpArbiter *arb) static cpBool handlerSetEql(cpCollisionHandler *check, cpCollisionHandler *pair) { - return ((check->a == pair->a && check->b == pair->b) || (check->b == pair->a && check->a == pair->b)); + return ((check->a == pair->a && check->b == pair->b) || (check->b == pair->a && check->a == pair->b)); } // Transformation function for collisionHandlers. static void * handlerSetTrans(cpCollisionHandler *handler, void *unused) { - cpCollisionHandler *copy = (cpCollisionHandler *)cpcalloc(1, sizeof(cpCollisionHandler)); - (*copy) = (*handler); - - return copy; + cpCollisionHandler *copy = (cpCollisionHandler *)cpcalloc(1, sizeof(cpCollisionHandler)); + (*copy) = (*handler); + + return copy; } //MARK: Misc Helper Funcs @@ -73,7 +71,7 @@ static void freeWrap(void *ptr, void *unused){cpfree(ptr);} cpSpace * cpSpaceAlloc(void) { - return (cpSpace *)cpcalloc(1, sizeof(cpSpace)); + return (cpSpace *)cpcalloc(1, sizeof(cpSpace)); } cpCollisionHandler cpDefaultCollisionHandler = {0, 0, alwaysCollide, alwaysCollide, nothing, nothing, NULL}; @@ -82,352 +80,357 @@ cpSpace* cpSpaceInit(cpSpace *space) { #ifndef NDEBUG - static cpBool done = cpFalse; - if(!done){ - printf("Initializing cpSpace - Chipmunk v%s (Debug Enabled)\n", cpVersionString); - printf("Compile with -DNDEBUG defined to disable debug mode and runtime assertion checks\n"); - done = cpTrue; - } + static cpBool done = cpFalse; + if(!done){ + printf("Initializing cpSpace - Chipmunk v%s (Debug Enabled)\n", cpVersionString); + printf("Compile with -DNDEBUG defined to disable debug mode and runtime assertion checks\n"); + done = cpTrue; + } #endif - space->iterations = 10; - - space->gravity = cpvzero; - space->damping = 1.0f; - - space->collisionSlop = 0.1f; - space->collisionBias = cpfpow(1.0f - 0.1f, 60.0f); - space->collisionPersistence = 3; - - space->locked = 0; - space->stamp = 0; + space->iterations = 10; + + space->gravity = cpvzero; + space->damping = 1.0f; + + space->collisionSlop = 0.1f; + space->collisionBias = cpfpow(1.0f - 0.1f, 60.0f); + space->collisionPersistence = 3; + + space->locked = 0; + space->stamp = 0; - space->staticShapes = cpBBTreeNew((cpSpatialIndexBBFunc)cpShapeGetBB, NULL); - space->activeShapes = cpBBTreeNew((cpSpatialIndexBBFunc)cpShapeGetBB, space->staticShapes); - cpBBTreeSetVelocityFunc(space->activeShapes, (cpBBTreeVelocityFunc)shapeVelocityFunc); - - space->allocatedBuffers = cpArrayNew(0); - - space->bodies = cpArrayNew(0); - space->sleepingComponents = cpArrayNew(0); - space->rousedBodies = cpArrayNew(0); - - space->sleepTimeThreshold = INFINITY; - space->idleSpeedThreshold = 0.0f; - space->enableContactGraph = cpFalse; - - space->arbiters = cpArrayNew(0); - space->pooledArbiters = cpArrayNew(0); - - space->contactBuffersHead = NULL; - space->cachedArbiters = cpHashSetNew(0, (cpHashSetEqlFunc)arbiterSetEql); - - space->constraints = cpArrayNew(0); - - space->defaultHandler = cpDefaultCollisionHandler; - space->collisionHandlers = cpHashSetNew(0, (cpHashSetEqlFunc)handlerSetEql); - cpHashSetSetDefaultValue(space->collisionHandlers, &cpDefaultCollisionHandler); - - space->postStepCallbacks = NULL; - - space->arbiterApplyImpulse = cpArbiterApplyImpulse; - - cpBodyInitStatic(&space->_staticBody); - space->staticBody = &space->_staticBody; - - return space; + space->staticShapes = cpBBTreeNew((cpSpatialIndexBBFunc)cpShapeGetBB, NULL); + space->activeShapes = cpBBTreeNew((cpSpatialIndexBBFunc)cpShapeGetBB, space->staticShapes); + cpBBTreeSetVelocityFunc(space->activeShapes, (cpBBTreeVelocityFunc)shapeVelocityFunc); + + space->allocatedBuffers = cpArrayNew(0); + + space->bodies = cpArrayNew(0); + space->sleepingComponents = cpArrayNew(0); + space->rousedBodies = cpArrayNew(0); + + space->sleepTimeThreshold = INFINITY; + space->idleSpeedThreshold = 0.0f; + space->enableContactGraph = cpFalse; + + space->arbiters = cpArrayNew(0); + space->pooledArbiters = cpArrayNew(0); + + space->contactBuffersHead = NULL; + space->cachedArbiters = cpHashSetNew(0, (cpHashSetEqlFunc)arbiterSetEql); + + space->constraints = cpArrayNew(0); + + space->defaultHandler = cpDefaultCollisionHandler; + space->collisionHandlers = cpHashSetNew(0, (cpHashSetEqlFunc)handlerSetEql); + cpHashSetSetDefaultValue(space->collisionHandlers, &cpDefaultCollisionHandler); + + space->postStepCallbacks = cpArrayNew(0); + space->skipPostStep = cpFalse; + + cpBodyInitStatic(&space->_staticBody); + space->staticBody = &space->_staticBody; + + return space; } cpSpace* cpSpaceNew(void) { - return cpSpaceInit(cpSpaceAlloc()); + return cpSpaceInit(cpSpaceAlloc()); } void cpSpaceDestroy(cpSpace *space) { - cpSpatialIndexFree(space->staticShapes); - cpSpatialIndexFree(space->activeShapes); - - cpArrayFree(space->bodies); - cpArrayFree(space->sleepingComponents); - cpArrayFree(space->rousedBodies); - - cpArrayFree(space->constraints); - - cpHashSetFree(space->cachedArbiters); - - cpArrayFree(space->arbiters); - cpArrayFree(space->pooledArbiters); - - if(space->allocatedBuffers){ - cpArrayFreeEach(space->allocatedBuffers, cpfree); - cpArrayFree(space->allocatedBuffers); - } - - if(space->postStepCallbacks) cpHashSetEach(space->postStepCallbacks, freeWrap, NULL); - cpHashSetFree(space->postStepCallbacks); - - if(space->collisionHandlers) cpHashSetEach(space->collisionHandlers, freeWrap, NULL); - cpHashSetFree(space->collisionHandlers); + cpSpaceEachBody(space, (cpSpaceBodyIteratorFunc)cpBodyActivate, NULL); + + cpSpatialIndexFree(space->staticShapes); + cpSpatialIndexFree(space->activeShapes); + + cpArrayFree(space->bodies); + cpArrayFree(space->sleepingComponents); + cpArrayFree(space->rousedBodies); + + cpArrayFree(space->constraints); + + cpHashSetFree(space->cachedArbiters); + + cpArrayFree(space->arbiters); + cpArrayFree(space->pooledArbiters); + + if(space->allocatedBuffers){ + cpArrayFreeEach(space->allocatedBuffers, cpfree); + cpArrayFree(space->allocatedBuffers); + } + + if(space->postStepCallbacks){ + cpArrayFreeEach(space->postStepCallbacks, cpfree); + cpArrayFree(space->postStepCallbacks); + } + + if(space->collisionHandlers) cpHashSetEach(space->collisionHandlers, freeWrap, NULL); + cpHashSetFree(space->collisionHandlers); } void cpSpaceFree(cpSpace *space) { - if(space){ - cpSpaceDestroy(space); - cpfree(space); - } + if(space){ + cpSpaceDestroy(space); + cpfree(space); + } } #define cpAssertSpaceUnlocked(space) \ - cpAssertHard(!space->locked, \ - "This addition/removal cannot be done safely during a call to cpSpaceStep() or during a query. " \ - "Put these calls into a post-step callback." \ - ); + cpAssertHard(!space->locked, \ + "This addition/removal cannot be done safely during a call to cpSpaceStep() or during a query. " \ + "Put these calls into a post-step callback." \ + ); //MARK: Collision Handler Function Management void cpSpaceAddCollisionHandler( - cpSpace *space, - cpCollisionType a, cpCollisionType b, - cpCollisionBeginFunc begin, - cpCollisionPreSolveFunc preSolve, - cpCollisionPostSolveFunc postSolve, - cpCollisionSeparateFunc separate, - void *data + cpSpace *space, + cpCollisionType a, cpCollisionType b, + cpCollisionBeginFunc begin, + cpCollisionPreSolveFunc preSolve, + cpCollisionPostSolveFunc postSolve, + cpCollisionSeparateFunc separate, + void *data ){ - cpAssertSpaceUnlocked(space); - - // Remove any old function so the new one will get added. - cpSpaceRemoveCollisionHandler(space, a, b); - - cpCollisionHandler handler = { - a, b, - begin ? begin : alwaysCollide, - preSolve ? preSolve : alwaysCollide, - postSolve ? postSolve : nothing, - separate ? separate : nothing, - data - }; - - cpHashSetInsert(space->collisionHandlers, CP_HASH_PAIR(a, b), &handler, NULL, (cpHashSetTransFunc)handlerSetTrans); + cpAssertSpaceUnlocked(space); + + // Remove any old function so the new one will get added. + cpSpaceRemoveCollisionHandler(space, a, b); + + cpCollisionHandler handler = { + a, b, + begin ? begin : alwaysCollide, + preSolve ? preSolve : alwaysCollide, + postSolve ? postSolve : nothing, + separate ? separate : nothing, + data + }; + + cpHashSetInsert(space->collisionHandlers, CP_HASH_PAIR(a, b), &handler, NULL, (cpHashSetTransFunc)handlerSetTrans); } void cpSpaceRemoveCollisionHandler(cpSpace *space, cpCollisionType a, cpCollisionType b) { - cpAssertSpaceUnlocked(space); - - struct { cpCollisionType a, b; } ids = {a, b}; - cpCollisionHandler *old_handler = (cpCollisionHandler *) cpHashSetRemove(space->collisionHandlers, CP_HASH_PAIR(a, b), &ids); - cpfree(old_handler); + cpAssertSpaceUnlocked(space); + + struct { cpCollisionType a, b; } ids = {a, b}; + cpCollisionHandler *old_handler = (cpCollisionHandler *) cpHashSetRemove(space->collisionHandlers, CP_HASH_PAIR(a, b), &ids); + cpfree(old_handler); } void cpSpaceSetDefaultCollisionHandler( - cpSpace *space, - cpCollisionBeginFunc begin, - cpCollisionPreSolveFunc preSolve, - cpCollisionPostSolveFunc postSolve, - cpCollisionSeparateFunc separate, - void *data + cpSpace *space, + cpCollisionBeginFunc begin, + cpCollisionPreSolveFunc preSolve, + cpCollisionPostSolveFunc postSolve, + cpCollisionSeparateFunc separate, + void *data ){ - cpAssertSpaceUnlocked(space); - - cpCollisionHandler handler = { - 0, 0, - begin ? begin : alwaysCollide, - preSolve ? preSolve : alwaysCollide, - postSolve ? postSolve : nothing, - separate ? separate : nothing, - data - }; - - space->defaultHandler = handler; - cpHashSetSetDefaultValue(space->collisionHandlers, &space->defaultHandler); + cpAssertSpaceUnlocked(space); + + cpCollisionHandler handler = { + 0, 0, + begin ? begin : alwaysCollide, + preSolve ? preSolve : alwaysCollide, + postSolve ? postSolve : nothing, + separate ? separate : nothing, + data + }; + + space->defaultHandler = handler; + cpHashSetSetDefaultValue(space->collisionHandlers, &space->defaultHandler); } //MARK: Body, Shape, and Joint Management cpShape * cpSpaceAddShape(cpSpace *space, cpShape *shape) { - cpBody *body = shape->body; - if(cpBodyIsStatic(body)) return cpSpaceAddStaticShape(space, shape); - - cpAssertHard(!shape->space, "This shape is already added to a space and cannot be added to another."); - cpAssertSpaceUnlocked(space); - - cpBodyActivate(body); - cpBodyAddShape(body, shape); - - cpShapeUpdate(shape, body->p, body->rot); - cpSpatialIndexInsert(space->activeShapes, shape, shape->hashid); - shape->space = space; - - return shape; + cpBody *body = shape->body; + if(cpBodyIsStatic(body)) return cpSpaceAddStaticShape(space, shape); + + cpAssertHard(!shape->space, "This shape is already added to a space and cannot be added to another."); + cpAssertSpaceUnlocked(space); + + cpBodyActivate(body); + cpBodyAddShape(body, shape); + + cpShapeUpdate(shape, body->p, body->rot); + cpSpatialIndexInsert(space->activeShapes, shape, shape->hashid); + shape->space = space; + + return shape; } cpShape * cpSpaceAddStaticShape(cpSpace *space, cpShape *shape) { - cpAssertHard(!shape->space, "This shape is already added to a space and cannot be added to another."); - cpAssertSpaceUnlocked(space); - - cpBody *body = shape->body; - cpBodyAddShape(body, shape); - cpShapeUpdate(shape, body->p, body->rot); - cpSpatialIndexInsert(space->staticShapes, shape, shape->hashid); - shape->space = space; - - return shape; + cpAssertHard(!shape->space, "This shape is already added to a space and cannot be added to another."); + cpAssertSpaceUnlocked(space); + + cpBody *body = shape->body; + cpBodyAddShape(body, shape); + cpShapeUpdate(shape, body->p, body->rot); + cpSpatialIndexInsert(space->staticShapes, shape, shape->hashid); + shape->space = space; + + return shape; } cpBody * cpSpaceAddBody(cpSpace *space, cpBody *body) { - cpAssertHard(!cpBodyIsStatic(body), "Static bodies cannot be added to a space as they are not meant to be simulated."); - cpAssertHard(!body->space, "This body is already added to a space and cannot be added to another."); - cpAssertSpaceUnlocked(space); - - cpArrayPush(space->bodies, body); - body->space = space; - - return body; + cpAssertHard(!cpBodyIsStatic(body), "Static bodies cannot be added to a space as they are not meant to be simulated."); + cpAssertHard(!body->space, "This body is already added to a space and cannot be added to another."); + cpAssertSpaceUnlocked(space); + + cpArrayPush(space->bodies, body); + body->space = space; + + return body; } cpConstraint * cpSpaceAddConstraint(cpSpace *space, cpConstraint *constraint) { - cpAssertHard(!constraint->space, "This shape is already added to a space and cannot be added to another."); - cpAssertSpaceUnlocked(space); - - cpBodyActivate(constraint->a); - cpBodyActivate(constraint->b); - cpArrayPush(space->constraints, constraint); - - // Push onto the heads of the bodies' constraint lists - cpBody *a = constraint->a, *b = constraint->b; - constraint->next_a = a->constraintList; a->constraintList = constraint; - constraint->next_b = b->constraintList; b->constraintList = constraint; - constraint->space = space; - - return constraint; + cpAssertHard(!constraint->space, "This shape is already added to a space and cannot be added to another."); + cpAssertSpaceUnlocked(space); + + cpBodyActivate(constraint->a); + cpBodyActivate(constraint->b); + cpArrayPush(space->constraints, constraint); + + // Push onto the heads of the bodies' constraint lists + cpBody *a = constraint->a, *b = constraint->b; + constraint->next_a = a->constraintList; a->constraintList = constraint; + constraint->next_b = b->constraintList; b->constraintList = constraint; + constraint->space = space; + + return constraint; } struct arbiterFilterContext { - cpSpace *space; - cpBody *body; - cpShape *shape; + cpSpace *space; + cpBody *body; + cpShape *shape; }; static cpBool cachedArbitersFilter(cpArbiter *arb, struct arbiterFilterContext *context) { - cpShape *shape = context->shape; - cpBody *body = context->body; - - - // Match on the filter shape, or if it's NULL the filter body - if( - (body == arb->body_a && (shape == arb->a || shape == NULL)) || - (body == arb->body_b && (shape == arb->b || shape == NULL)) - ){ - // Call separate when removing shapes. - if(shape && arb->state != cpArbiterStateCached) cpArbiterCallSeparate(arb, context->space); - - cpArbiterUnthread(arb); - cpArrayDeleteObj(context->space->arbiters, arb); - cpArrayPush(context->space->pooledArbiters, arb); - - return cpFalse; - } - - return cpTrue; + cpShape *shape = context->shape; + cpBody *body = context->body; + + + // Match on the filter shape, or if it's NULL the filter body + if( + (body == arb->body_a && (shape == arb->a || shape == NULL)) || + (body == arb->body_b && (shape == arb->b || shape == NULL)) + ){ + // Call separate when removing shapes. + if(shape && arb->state != cpArbiterStateCached) cpArbiterCallSeparate(arb, context->space); + + cpArbiterUnthread(arb); + cpArrayDeleteObj(context->space->arbiters, arb); + cpArrayPush(context->space->pooledArbiters, arb); + + return cpFalse; + } + + return cpTrue; } void cpSpaceFilterArbiters(cpSpace *space, cpBody *body, cpShape *filter) { - struct arbiterFilterContext context = {space, body, filter}; - cpHashSetFilter(space->cachedArbiters, (cpHashSetFilterFunc)cachedArbitersFilter, &context); + cpSpaceLock(space); { + struct arbiterFilterContext context = {space, body, filter}; + cpHashSetFilter(space->cachedArbiters, (cpHashSetFilterFunc)cachedArbitersFilter, &context); + } cpSpaceUnlock(space, cpTrue); } void cpSpaceRemoveShape(cpSpace *space, cpShape *shape) { - cpBody *body = shape->body; - if(cpBodyIsStatic(body)){ - cpSpaceRemoveStaticShape(space, shape); - } else { - cpAssertHard(cpSpaceContainsShape(space, shape), "Cannot remove a shape that was not added to the space. (Removed twice maybe?)"); - cpAssertSpaceUnlocked(space); - - cpBodyActivate(body); - cpBodyRemoveShape(body, shape); - cpSpaceFilterArbiters(space, body, shape); - cpSpatialIndexRemove(space->activeShapes, shape, shape->hashid); - shape->space = NULL; - } + cpBody *body = shape->body; + if(cpBodyIsStatic(body)){ + cpSpaceRemoveStaticShape(space, shape); + } else { + cpAssertHard(cpSpaceContainsShape(space, shape), "Cannot remove a shape that was not added to the space. (Removed twice maybe?)"); + cpAssertSpaceUnlocked(space); + + cpBodyActivate(body); + cpBodyRemoveShape(body, shape); + cpSpaceFilterArbiters(space, body, shape); + cpSpatialIndexRemove(space->activeShapes, shape, shape->hashid); + shape->space = NULL; + } } void cpSpaceRemoveStaticShape(cpSpace *space, cpShape *shape) { - cpAssertHard(cpSpaceContainsShape(space, shape), "Cannot remove a static or sleeping shape that was not added to the space. (Removed twice maybe?)"); - cpAssertSpaceUnlocked(space); - - cpBody *body = shape->body; - if(cpBodyIsStatic(body)) cpBodyActivateStatic(body, shape); - cpBodyRemoveShape(body, shape); - cpSpaceFilterArbiters(space, body, shape); - cpSpatialIndexRemove(space->staticShapes, shape, shape->hashid); - shape->space = NULL; + cpAssertHard(cpSpaceContainsShape(space, shape), "Cannot remove a static or sleeping shape that was not added to the space. (Removed twice maybe?)"); + cpAssertSpaceUnlocked(space); + + cpBody *body = shape->body; + if(cpBodyIsStatic(body)) cpBodyActivateStatic(body, shape); + cpBodyRemoveShape(body, shape); + cpSpaceFilterArbiters(space, body, shape); + cpSpatialIndexRemove(space->staticShapes, shape, shape->hashid); + shape->space = NULL; } void cpSpaceRemoveBody(cpSpace *space, cpBody *body) { - cpAssertHard(cpSpaceContainsBody(space, body), "Cannot remove a body that was not added to the space. (Removed twice maybe?)"); - cpAssertSpaceUnlocked(space); - - cpBodyActivate(body); -// cpSpaceFilterArbiters(space, body, NULL); - cpArrayDeleteObj(space->bodies, body); - body->space = NULL; + cpAssertHard(cpSpaceContainsBody(space, body), "Cannot remove a body that was not added to the space. (Removed twice maybe?)"); + cpAssertSpaceUnlocked(space); + + cpBodyActivate(body); +// cpSpaceFilterArbiters(space, body, NULL); + cpArrayDeleteObj(space->bodies, body); + body->space = NULL; } void cpSpaceRemoveConstraint(cpSpace *space, cpConstraint *constraint) { - cpAssertHard(cpSpaceContainsConstraint(space, constraint), "Cannot remove a constraint that was not added to the space. (Removed twice maybe?)"); - cpAssertSpaceUnlocked(space); - - cpBodyActivate(constraint->a); - cpBodyActivate(constraint->b); - cpArrayDeleteObj(space->constraints, constraint); - - cpBodyRemoveConstraint(constraint->a, constraint); - cpBodyRemoveConstraint(constraint->b, constraint); - constraint->space = NULL; + cpAssertHard(cpSpaceContainsConstraint(space, constraint), "Cannot remove a constraint that was not added to the space. (Removed twice maybe?)"); + cpAssertSpaceUnlocked(space); + + cpBodyActivate(constraint->a); + cpBodyActivate(constraint->b); + cpArrayDeleteObj(space->constraints, constraint); + + cpBodyRemoveConstraint(constraint->a, constraint); + cpBodyRemoveConstraint(constraint->b, constraint); + constraint->space = NULL; } cpBool cpSpaceContainsShape(cpSpace *space, cpShape *shape) { - return (shape->space == space); + return (shape->space == space); } cpBool cpSpaceContainsBody(cpSpace *space, cpBody *body) { - return (body->space == space); + return (body->space == space); } cpBool cpSpaceContainsConstraint(cpSpace *space, cpConstraint *constraint) { - return (constraint->space == space); + return (constraint->space == space); } @@ -436,58 +439,58 @@ cpBool cpSpaceContainsConstraint(cpSpace *space, cpConstraint *constraint) void cpSpaceEachBody(cpSpace *space, cpSpaceBodyIteratorFunc func, void *data) { - cpSpaceLock(space); { - cpArray *bodies = space->bodies; - - for(int i=0; inum; i++){ - func((cpBody *)bodies->arr[i], data); - } - - cpArray *components = space->sleepingComponents; - for(int i=0; inum; i++){ - cpBody *root = (cpBody *)components->arr[i]; - - cpBody *body = root; - while(body){ - cpBody *next = body->node.next; - func(body, data); - body = next; - } - } - } cpSpaceUnlock(space, cpTrue); + cpSpaceLock(space); { + cpArray *bodies = space->bodies; + + for(int i=0; inum; i++){ + func((cpBody *)bodies->arr[i], data); + } + + cpArray *components = space->sleepingComponents; + for(int i=0; inum; i++){ + cpBody *root = (cpBody *)components->arr[i]; + + cpBody *body = root; + while(body){ + cpBody *next = body->node.next; + func(body, data); + body = next; + } + } + } cpSpaceUnlock(space, cpTrue); } typedef struct spaceShapeContext { - cpSpaceShapeIteratorFunc func; - void *data; + cpSpaceShapeIteratorFunc func; + void *data; } spaceShapeContext; static void spaceEachShapeIterator(cpShape *shape, spaceShapeContext *context) { - context->func(shape, context->data); + context->func(shape, context->data); } void cpSpaceEachShape(cpSpace *space, cpSpaceShapeIteratorFunc func, void *data) { - cpSpaceLock(space); { - spaceShapeContext context = {func, data}; - cpSpatialIndexEach(space->activeShapes, (cpSpatialIndexIteratorFunc)spaceEachShapeIterator, &context); - cpSpatialIndexEach(space->staticShapes, (cpSpatialIndexIteratorFunc)spaceEachShapeIterator, &context); - } cpSpaceUnlock(space, cpTrue); + cpSpaceLock(space); { + spaceShapeContext context = {func, data}; + cpSpatialIndexEach(space->activeShapes, (cpSpatialIndexIteratorFunc)spaceEachShapeIterator, &context); + cpSpatialIndexEach(space->staticShapes, (cpSpatialIndexIteratorFunc)spaceEachShapeIterator, &context); + } cpSpaceUnlock(space, cpTrue); } void cpSpaceEachConstraint(cpSpace *space, cpSpaceConstraintIteratorFunc func, void *data) { - cpSpaceLock(space); { - cpArray *constraints = space->constraints; - - for(int i=0; inum; i++){ - func((cpConstraint *)constraints->arr[i], data); - } - } cpSpaceUnlock(space, cpTrue); + cpSpaceLock(space); { + cpArray *constraints = space->constraints; + + for(int i=0; inum; i++){ + func((cpConstraint *)constraints->arr[i], data); + } + } cpSpaceUnlock(space, cpTrue); } //MARK: Spatial Index Management @@ -495,57 +498,57 @@ cpSpaceEachConstraint(cpSpace *space, cpSpaceConstraintIteratorFunc func, void * static void updateBBCache(cpShape *shape, void *unused) { - cpBody *body = shape->body; - cpShapeUpdate(shape, body->p, body->rot); + cpBody *body = shape->body; + cpShapeUpdate(shape, body->p, body->rot); } void cpSpaceReindexStatic(cpSpace *space) { - cpAssertHard(!space->locked, "You cannot manually reindex objects while the space is locked. Wait until the current query or step is complete."); - - cpSpatialIndexEach(space->staticShapes, (cpSpatialIndexIteratorFunc)&updateBBCache, NULL); - cpSpatialIndexReindex(space->staticShapes); + cpAssertHard(!space->locked, "You cannot manually reindex objects while the space is locked. Wait until the current query or step is complete."); + + cpSpatialIndexEach(space->staticShapes, (cpSpatialIndexIteratorFunc)&updateBBCache, NULL); + cpSpatialIndexReindex(space->staticShapes); } void cpSpaceReindexShape(cpSpace *space, cpShape *shape) { - cpAssertHard(!space->locked, "You cannot manually reindex objects while the space is locked. Wait until the current query or step is complete."); - - cpBody *body = shape->body; - cpShapeUpdate(shape, body->p, body->rot); - - // attempt to rehash the shape in both hashes - cpSpatialIndexReindexObject(space->activeShapes, shape, shape->hashid); - cpSpatialIndexReindexObject(space->staticShapes, shape, shape->hashid); + cpAssertHard(!space->locked, "You cannot manually reindex objects while the space is locked. Wait until the current query or step is complete."); + + cpBody *body = shape->body; + cpShapeUpdate(shape, body->p, body->rot); + + // attempt to rehash the shape in both hashes + cpSpatialIndexReindexObject(space->activeShapes, shape, shape->hashid); + cpSpatialIndexReindexObject(space->staticShapes, shape, shape->hashid); } void cpSpaceReindexShapesForBody(cpSpace *space, cpBody *body) { - CP_BODY_FOREACH_SHAPE(body, shape) cpSpaceReindexShape(space, shape); + CP_BODY_FOREACH_SHAPE(body, shape) cpSpaceReindexShape(space, shape); } static void copyShapes(cpShape *shape, cpSpatialIndex *index) { - cpSpatialIndexInsert(index, shape, shape->hashid); + cpSpatialIndexInsert(index, shape, shape->hashid); } void cpSpaceUseSpatialHash(cpSpace *space, cpFloat dim, int count) { - cpSpatialIndex *staticShapes = cpSpaceHashNew(dim, count, (cpSpatialIndexBBFunc)cpShapeGetBB, NULL); - cpSpatialIndex *activeShapes = cpSpaceHashNew(dim, count, (cpSpatialIndexBBFunc)cpShapeGetBB, staticShapes); - - cpSpatialIndexEach(space->staticShapes, (cpSpatialIndexIteratorFunc)copyShapes, staticShapes); - cpSpatialIndexEach(space->activeShapes, (cpSpatialIndexIteratorFunc)copyShapes, activeShapes); - - cpSpatialIndexFree(space->staticShapes); - cpSpatialIndexFree(space->activeShapes); - - space->staticShapes = staticShapes; - space->activeShapes = activeShapes; + cpSpatialIndex *staticShapes = cpSpaceHashNew(dim, count, (cpSpatialIndexBBFunc)cpShapeGetBB, NULL); + cpSpatialIndex *activeShapes = cpSpaceHashNew(dim, count, (cpSpatialIndexBBFunc)cpShapeGetBB, staticShapes); + + cpSpatialIndexEach(space->staticShapes, (cpSpatialIndexIteratorFunc)copyShapes, staticShapes); + cpSpatialIndexEach(space->activeShapes, (cpSpatialIndexIteratorFunc)copyShapes, activeShapes); + + cpSpatialIndexFree(space->staticShapes); + cpSpatialIndexFree(space->activeShapes); + + space->staticShapes = staticShapes; + space->activeShapes = activeShapes; } diff --git a/chipmunk/src/cpSpaceComponent.c b/chipmunk/src/cpSpaceComponent.c index 539f1dd496..612ada0ce5 100644 --- a/chipmunk/src/cpSpaceComponent.c +++ b/chipmunk/src/cpSpaceComponent.c @@ -19,8 +19,6 @@ * SOFTWARE. */ -#include -#include #include #include "chipmunk_private.h" @@ -30,303 +28,318 @@ void cpSpaceActivateBody(cpSpace *space, cpBody *body) { - cpAssertHard(!cpBodyIsRogue(body), "Internal error: Attempting to activate a rouge body."); - - if(space->locked){ - // cpSpaceActivateBody() is called again once the space is unlocked - if(!cpArrayContains(space->rousedBodies, body)) cpArrayPush(space->rousedBodies, body); - } else { - cpArrayPush(space->bodies, body); + cpAssertHard(!cpBodyIsRogue(body), "Internal error: Attempting to activate a rouge body."); + + if(space->locked){ + // cpSpaceActivateBody() is called again once the space is unlocked + if(!cpArrayContains(space->rousedBodies, body)) cpArrayPush(space->rousedBodies, body); + } else { + cpArrayPush(space->bodies, body); - CP_BODY_FOREACH_SHAPE(body, shape){ - cpSpatialIndexRemove(space->staticShapes, shape, shape->hashid); - cpSpatialIndexInsert(space->activeShapes, shape, shape->hashid); - } - - CP_BODY_FOREACH_ARBITER(body, arb){ - cpBody *bodyA = arb->body_a; - if(body == bodyA || cpBodyIsStatic(bodyA)){ - int numContacts = arb->numContacts; - cpContact *contacts = arb->contacts; - - // Restore contact values back to the space's contact buffer memory - arb->contacts = cpContactBufferGetArray(space); - memcpy(arb->contacts, contacts, numContacts*sizeof(cpContact)); - cpSpacePushContacts(space, numContacts); - - // Reinsert the arbiter into the arbiter cache - cpShape *a = arb->a, *b = arb->b; - cpShape *shape_pair[] = {a, b}; - cpHashValue arbHashID = CP_HASH_PAIR((cpHashValue)a, (cpHashValue)b); - cpHashSetInsert(space->cachedArbiters, arbHashID, shape_pair, arb, NULL); - - // Update the arbiter's state - arb->stamp = space->stamp; - arb->handler = cpSpaceLookupHandler(space, a->collision_type, b->collision_type); - cpArrayPush(space->arbiters, arb); - - cpfree(contacts); - } - } - - CP_BODY_FOREACH_CONSTRAINT(body, constraint){ - cpBody *bodyA = constraint->a; - if(body == bodyA || cpBodyIsStatic(bodyA)) cpArrayPush(space->constraints, constraint); - } - } + CP_BODY_FOREACH_SHAPE(body, shape){ + cpSpatialIndexRemove(space->staticShapes, shape, shape->hashid); + cpSpatialIndexInsert(space->activeShapes, shape, shape->hashid); + } + + CP_BODY_FOREACH_ARBITER(body, arb){ + cpBody *bodyA = arb->body_a; + if(body == bodyA || cpBodyIsStatic(bodyA)){ + int numContacts = arb->numContacts; + cpContact *contacts = arb->contacts; + + // Restore contact values back to the space's contact buffer memory + arb->contacts = cpContactBufferGetArray(space); + memcpy(arb->contacts, contacts, numContacts*sizeof(cpContact)); + cpSpacePushContacts(space, numContacts); + + // Reinsert the arbiter into the arbiter cache + cpShape *a = arb->a, *b = arb->b; + cpShape *shape_pair[] = {a, b}; + cpHashValue arbHashID = CP_HASH_PAIR((cpHashValue)a, (cpHashValue)b); + cpHashSetInsert(space->cachedArbiters, arbHashID, shape_pair, arb, NULL); + + // Update the arbiter's state + arb->stamp = space->stamp; + arb->handler = cpSpaceLookupHandler(space, a->collision_type, b->collision_type); + cpArrayPush(space->arbiters, arb); + + cpfree(contacts); + } + } + + CP_BODY_FOREACH_CONSTRAINT(body, constraint){ + cpBody *bodyA = constraint->a; + if(body == bodyA || cpBodyIsStatic(bodyA)) cpArrayPush(space->constraints, constraint); + } + } } static void cpSpaceDeactivateBody(cpSpace *space, cpBody *body) { - cpAssertHard(!cpBodyIsRogue(body), "Internal error: Attempting to deactivate a rouge body."); - - cpArrayDeleteObj(space->bodies, body); - - CP_BODY_FOREACH_SHAPE(body, shape){ - cpSpatialIndexRemove(space->activeShapes, shape, shape->hashid); - cpSpatialIndexInsert(space->staticShapes, shape, shape->hashid); - } - - CP_BODY_FOREACH_ARBITER(body, arb){ - cpBody *bodyA = arb->body_a; - if(body == bodyA || cpBodyIsStatic(bodyA)){ - cpSpaceUncacheArbiter(space, arb); - - // Save contact values to a new block of memory so they won't time out - size_t bytes = arb->numContacts*sizeof(cpContact); - cpContact *contacts = (cpContact *)cpcalloc(1, bytes); - memcpy(contacts, arb->contacts, bytes); - arb->contacts = contacts; - } - } - - CP_BODY_FOREACH_CONSTRAINT(body, constraint){ - cpBody *bodyA = constraint->a; - if(body == bodyA || cpBodyIsStatic(bodyA)) cpArrayDeleteObj(space->constraints, constraint); - } + cpAssertHard(!cpBodyIsRogue(body), "Internal error: Attempting to deactivate a rouge body."); + + cpArrayDeleteObj(space->bodies, body); + + CP_BODY_FOREACH_SHAPE(body, shape){ + cpSpatialIndexRemove(space->activeShapes, shape, shape->hashid); + cpSpatialIndexInsert(space->staticShapes, shape, shape->hashid); + } + + CP_BODY_FOREACH_ARBITER(body, arb){ + cpBody *bodyA = arb->body_a; + if(body == bodyA || cpBodyIsStatic(bodyA)){ + cpSpaceUncacheArbiter(space, arb); + + // Save contact values to a new block of memory so they won't time out + size_t bytes = arb->numContacts*sizeof(cpContact); + cpContact *contacts = (cpContact *)cpcalloc(1, bytes); + memcpy(contacts, arb->contacts, bytes); + arb->contacts = contacts; + } + } + + CP_BODY_FOREACH_CONSTRAINT(body, constraint){ + cpBody *bodyA = constraint->a; + if(body == bodyA || cpBodyIsStatic(bodyA)) cpArrayDeleteObj(space->constraints, constraint); + } } static inline cpBody * ComponentRoot(cpBody *body) { - return (body ? body->node.root : NULL); + return (body ? body->node.root : NULL); } static inline void ComponentActivate(cpBody *root) { - if(!root || !cpBodyIsSleeping(root)) return; - cpAssertHard(!cpBodyIsRogue(root), "Internal Error: ComponentActivate() called on a rogue body."); - - cpSpace *space = root->space; - cpBody *body = root; - while(body){ - cpBody *next = body->node.next; - - body->node.idleTime = 0.0f; - body->node.root = NULL; - body->node.next = NULL; - cpSpaceActivateBody(space, body); - - body = next; - } - - cpArrayDeleteObj(space->sleepingComponents, root); + if(!root || !cpBodyIsSleeping(root)) return; + cpAssertHard(!cpBodyIsRogue(root), "Internal Error: ComponentActivate() called on a rogue body."); + + cpSpace *space = root->space; + cpBody *body = root; + while(body){ + cpBody *next = body->node.next; + + body->node.idleTime = 0.0f; + body->node.root = NULL; + body->node.next = NULL; + cpSpaceActivateBody(space, body); + + body = next; + } + + cpArrayDeleteObj(space->sleepingComponents, root); } void cpBodyActivate(cpBody *body) { - if(!cpBodyIsRogue(body)){ - body->node.idleTime = 0.0f; - ComponentActivate(ComponentRoot(body)); - } + if(!cpBodyIsRogue(body)){ + body->node.idleTime = 0.0f; + ComponentActivate(ComponentRoot(body)); + } } void cpBodyActivateStatic(cpBody *body, cpShape *filter) { - cpAssertHard(cpBodyIsStatic(body), "cpBodyActivateStatic() called on a non-static body."); - - CP_BODY_FOREACH_ARBITER(body, arb){ - if(!filter || filter == arb->a || filter == arb->b){ - cpBodyActivate(arb->body_a == body ? arb->body_b : arb->body_a); - } - } - - // TODO should also activate joints? + cpAssertHard(cpBodyIsStatic(body), "cpBodyActivateStatic() called on a non-static body."); + + CP_BODY_FOREACH_ARBITER(body, arb){ + if(!filter || filter == arb->a || filter == arb->b){ + cpBodyActivate(arb->body_a == body ? arb->body_b : arb->body_a); + } + } + + // TODO should also activate joints? } static inline void cpBodyPushArbiter(cpBody *body, cpArbiter *arb) { - cpAssertSoft(cpArbiterThreadForBody(arb, body)->next == NULL, "Internal Error: Dangling contact graph pointers detected. (A)"); - cpAssertSoft(cpArbiterThreadForBody(arb, body)->prev == NULL, "Internal Error: Dangling contact graph pointers detected. (B)"); - - cpArbiter *next = body->arbiterList; - cpAssertSoft(next == NULL || cpArbiterThreadForBody(next, body)->prev == NULL, "Internal Error: Dangling contact graph pointers detected. (C)"); - cpArbiterThreadForBody(arb, body)->next = next; - - if(next) cpArbiterThreadForBody(next, body)->prev = arb; - body->arbiterList = arb; + cpAssertSoft(cpArbiterThreadForBody(arb, body)->next == NULL, "Internal Error: Dangling contact graph pointers detected. (A)"); + cpAssertSoft(cpArbiterThreadForBody(arb, body)->prev == NULL, "Internal Error: Dangling contact graph pointers detected. (B)"); + + cpArbiter *next = body->arbiterList; + cpAssertSoft(next == NULL || cpArbiterThreadForBody(next, body)->prev == NULL, "Internal Error: Dangling contact graph pointers detected. (C)"); + cpArbiterThreadForBody(arb, body)->next = next; + + if(next) cpArbiterThreadForBody(next, body)->prev = arb; + body->arbiterList = arb; } static inline void ComponentAdd(cpBody *root, cpBody *body){ - body->node.root = root; + body->node.root = root; - if(body != root){ - body->node.next = root->node.next; - root->node.next = body; - } + if(body != root){ + body->node.next = root->node.next; + root->node.next = body; + } } static inline void FloodFillComponent(cpBody *root, cpBody *body) { - // Rogue bodies cannot be put to sleep and prevent bodies they are touching from sleepining anyway. - // Static bodies (which are a type of rogue body) are effectively sleeping all the time. - if(!cpBodyIsRogue(body)){ - cpBody *other_root = ComponentRoot(body); - if(other_root == NULL){ - ComponentAdd(root, body); - CP_BODY_FOREACH_ARBITER(body, arb) FloodFillComponent(root, (body == arb->body_a ? arb->body_b : arb->body_a)); - CP_BODY_FOREACH_CONSTRAINT(body, constraint) FloodFillComponent(root, (body == constraint->a ? constraint->b : constraint->a)); - } else { - cpAssertSoft(other_root == root, "Internal Error: Inconsistency dectected in the contact graph."); - } - } + // Rogue bodies cannot be put to sleep and prevent bodies they are touching from sleepining anyway. + // Static bodies (which are a type of rogue body) are effectively sleeping all the time. + if(!cpBodyIsRogue(body)){ + cpBody *other_root = ComponentRoot(body); + if(other_root == NULL){ + ComponentAdd(root, body); + CP_BODY_FOREACH_ARBITER(body, arb) FloodFillComponent(root, (body == arb->body_a ? arb->body_b : arb->body_a)); + CP_BODY_FOREACH_CONSTRAINT(body, constraint) FloodFillComponent(root, (body == constraint->a ? constraint->b : constraint->a)); + } else { + cpAssertSoft(other_root == root, "Internal Error: Inconsistency dectected in the contact graph."); + } + } } static inline cpBool ComponentActive(cpBody *root, cpFloat threshold) { - CP_BODY_FOREACH_COMPONENT(root, body){ - if(body->node.idleTime < threshold) return cpTrue; - } - - return cpFalse; + CP_BODY_FOREACH_COMPONENT(root, body){ + if(body->node.idleTime < threshold) return cpTrue; + } + + return cpFalse; } void cpSpaceProcessComponents(cpSpace *space, cpFloat dt) { - cpFloat dv = space->idleSpeedThreshold; - cpFloat dvsq = (dv ? dv*dv : cpvlengthsq(space->gravity)*dt*dt); - - // update idling and reset component nodes - cpArray *bodies = space->bodies; - for(int i=0; inum; i++){ - cpBody *body = (cpBody*)bodies->arr[i]; - - // Need to deal with infinite mass objects - cpFloat keThreshold = (dvsq ? body->m*dvsq : 0.0f); - body->node.idleTime = (cpBodyKineticEnergy(body) > keThreshold ? 0.0f : body->node.idleTime + dt); - - cpAssertSoft(body->node.next == NULL, "Internal Error: Dangling next pointer detected in contact graph."); - cpAssertSoft(body->node.root == NULL, "Internal Error: Dangling root pointer detected in contact graph."); - } - - // Awaken any sleeping bodies found and then push arbiters to the bodies' lists. - cpArray *arbiters = space->arbiters; - for(int i=0, count=arbiters->num; iarr[i]; - cpBody *a = arb->body_a, *b = arb->body_b; - - if((cpBodyIsRogue(b) && !cpBodyIsStatic(b)) || cpBodyIsSleeping(a)) cpBodyActivate(a); - if((cpBodyIsRogue(a) && !cpBodyIsStatic(a)) || cpBodyIsSleeping(b)) cpBodyActivate(b); - - cpBodyPushArbiter(a, arb); - cpBodyPushArbiter(b, arb); - } - - // Bodies should be held active if connected by a joint to a non-static rouge body. - cpArray *constraints = space->constraints; - for(int i=0; inum; i++){ - cpConstraint *constraint = (cpConstraint *)constraints->arr[i]; - cpBody *a = constraint->a, *b = constraint->b; - - if(cpBodyIsRogue(b) && !cpBodyIsStatic(b)) cpBodyActivate(a); - if(cpBodyIsRogue(a) && !cpBodyIsStatic(a)) cpBodyActivate(b); - } - - // Generate components and deactivate sleeping ones - for(int i=0; inum;){ - cpBody *body = (cpBody*)bodies->arr[i]; - - if(ComponentRoot(body) == NULL){ - // Body not in a component yet. Perform a DFS to flood fill mark - // the component in the contact graph using this body as the root. - FloodFillComponent(body, body); - - // Check if the component should be put to sleep. - if(!ComponentActive(body, space->sleepTimeThreshold)){ - cpArrayPush(space->sleepingComponents, body); - CP_BODY_FOREACH_COMPONENT(body, other) cpSpaceDeactivateBody(space, other); - - // cpSpaceDeactivateBody() removed the current body from the list. - // Skip incrementing the index counter. - continue; - } - } - - i++; - - // Only sleeping bodies retain their component node pointers. - body->node.root = NULL; - body->node.next = NULL; - } + cpBool sleep = (space->sleepTimeThreshold != INFINITY); + cpArray *bodies = space->bodies; + +#ifndef NDEBUG + for(int i=0; inum; i++){ + cpBody *body = (cpBody*)bodies->arr[i]; + + cpAssertSoft(body->node.next == NULL, "Internal Error: Dangling next pointer detected in contact graph."); + cpAssertSoft(body->node.root == NULL, "Internal Error: Dangling root pointer detected in contact graph."); + } +#endif + + // Calculate the kinetic energy of all the bodies. + if(sleep){ + cpFloat dv = space->idleSpeedThreshold; + cpFloat dvsq = (dv ? dv*dv : cpvlengthsq(space->gravity)*dt*dt); + + // update idling and reset component nodes + for(int i=0; inum; i++){ + cpBody *body = (cpBody*)bodies->arr[i]; + + // Need to deal with infinite mass objects + cpFloat keThreshold = (dvsq ? body->m*dvsq : 0.0f); + body->node.idleTime = (cpBodyKineticEnergy(body) > keThreshold ? 0.0f : body->node.idleTime + dt); + } + } + + // Awaken any sleeping bodies found and then push arbiters to the bodies' lists. + cpArray *arbiters = space->arbiters; + for(int i=0, count=arbiters->num; iarr[i]; + cpBody *a = arb->body_a, *b = arb->body_b; + + if(sleep){ + if((cpBodyIsRogue(b) && !cpBodyIsStatic(b)) || cpBodyIsSleeping(a)) cpBodyActivate(a); + if((cpBodyIsRogue(a) && !cpBodyIsStatic(a)) || cpBodyIsSleeping(b)) cpBodyActivate(b); + } + + cpBodyPushArbiter(a, arb); + cpBodyPushArbiter(b, arb); + } + + if(sleep){ + // Bodies should be held active if connected by a joint to a non-static rouge body. + cpArray *constraints = space->constraints; + for(int i=0; inum; i++){ + cpConstraint *constraint = (cpConstraint *)constraints->arr[i]; + cpBody *a = constraint->a, *b = constraint->b; + + if(cpBodyIsRogue(b) && !cpBodyIsStatic(b)) cpBodyActivate(a); + if(cpBodyIsRogue(a) && !cpBodyIsStatic(a)) cpBodyActivate(b); + } + + // Generate components and deactivate sleeping ones + for(int i=0; inum;){ + cpBody *body = (cpBody*)bodies->arr[i]; + + if(ComponentRoot(body) == NULL){ + // Body not in a component yet. Perform a DFS to flood fill mark + // the component in the contact graph using this body as the root. + FloodFillComponent(body, body); + + // Check if the component should be put to sleep. + if(!ComponentActive(body, space->sleepTimeThreshold)){ + cpArrayPush(space->sleepingComponents, body); + CP_BODY_FOREACH_COMPONENT(body, other) cpSpaceDeactivateBody(space, other); + + // cpSpaceDeactivateBody() removed the current body from the list. + // Skip incrementing the index counter. + continue; + } + } + + i++; + + // Only sleeping bodies retain their component node pointers. + body->node.root = NULL; + body->node.next = NULL; + } + } } void cpBodySleep(cpBody *body) { - cpBodySleepWithGroup(body, NULL); + cpBodySleepWithGroup(body, NULL); } void cpBodySleepWithGroup(cpBody *body, cpBody *group){ - cpAssertHard(!cpBodyIsStatic(body) && !cpBodyIsRogue(body), "Rogue and static bodies cannot be put to sleep."); - - cpSpace *space = body->space; - cpAssertHard(space, "Cannot put a rogue body to sleep."); - cpAssertHard(!space->locked, "Bodies cannot be put to sleep during a query or a call to cpSpaceStep(). Put these calls into a post-step callback."); - cpAssertHard(group == NULL || cpBodyIsSleeping(group), "Cannot use a non-sleeping body as a group identifier."); - - if(cpBodyIsSleeping(body)){ - cpAssertHard(ComponentRoot(body) == ComponentRoot(group), "The body is already sleeping and it's group cannot be reassigned."); - return; - } - - CP_BODY_FOREACH_SHAPE(body, shape) cpShapeUpdate(shape, body->p, body->rot); - cpSpaceDeactivateBody(space, body); - - if(group){ - cpBody *root = ComponentRoot(group); - - cpComponentNode node = {root, root->node.next, 0.0f}; - body->node = node; - - root->node.next = body; - } else { - cpComponentNode node = {body, NULL, 0.0f}; - body->node = node; - - cpArrayPush(space->sleepingComponents, body); - } - - cpArrayDeleteObj(space->bodies, body); + cpAssertHard(!cpBodyIsStatic(body) && !cpBodyIsRogue(body), "Rogue and static bodies cannot be put to sleep."); + + cpSpace *space = body->space; + cpAssertHard(space, "Cannot put a rogue body to sleep."); + cpAssertHard(!space->locked, "Bodies cannot be put to sleep during a query or a call to cpSpaceStep(). Put these calls into a post-step callback."); + cpAssertHard(group == NULL || cpBodyIsSleeping(group), "Cannot use a non-sleeping body as a group identifier."); + + if(cpBodyIsSleeping(body)){ + cpAssertHard(ComponentRoot(body) == ComponentRoot(group), "The body is already sleeping and it's group cannot be reassigned."); + return; + } + + CP_BODY_FOREACH_SHAPE(body, shape) cpShapeUpdate(shape, body->p, body->rot); + cpSpaceDeactivateBody(space, body); + + if(group){ + cpBody *root = ComponentRoot(group); + + cpComponentNode node = {root, root->node.next, 0.0f}; + body->node = node; + + root->node.next = body; + } else { + cpComponentNode node = {body, NULL, 0.0f}; + body->node = node; + + cpArrayPush(space->sleepingComponents, body); + } + + cpArrayDeleteObj(space->bodies, body); } static void activateTouchingHelper(cpShape *shape, cpContactPointSet *points, cpShape *other){ - cpBodyActivate(shape->body); + cpBodyActivate(shape->body); } void cpSpaceActivateShapesTouchingShape(cpSpace *space, cpShape *shape){ - if(space->sleepTimeThreshold != INFINITY){ - cpSpaceShapeQuery(space, shape, (cpSpaceShapeQueryFunc)activateTouchingHelper, shape); - } + if(space->sleepTimeThreshold != INFINITY){ + cpSpaceShapeQuery(space, shape, (cpSpaceShapeQueryFunc)activateTouchingHelper, shape); + } } diff --git a/chipmunk/src/cpSpaceHash.c b/chipmunk/src/cpSpaceHash.c index e56fb644da..7479e9d3b1 100644 --- a/chipmunk/src/cpSpaceHash.c +++ b/chipmunk/src/cpSpaceHash.c @@ -19,9 +19,6 @@ * SOFTWARE. */ -#include -#include - #include "chipmunk_private.h" #include "prime.h" @@ -29,38 +26,38 @@ typedef struct cpSpaceHashBin cpSpaceHashBin; typedef struct cpHandle cpHandle; struct cpSpaceHash { - cpSpatialIndex spatialIndex; - - int numcells; - cpFloat celldim; - - cpSpaceHashBin **table; - cpHashSet *handleSet; - - cpSpaceHashBin *pooledBins; - cpArray *pooledHandles; - cpArray *allocatedBuffers; - - cpTimestamp stamp; + cpSpatialIndex spatialIndex; + + int numcells; + cpFloat celldim; + + cpSpaceHashBin **table; + cpHashSet *handleSet; + + cpSpaceHashBin *pooledBins; + cpArray *pooledHandles; + cpArray *allocatedBuffers; + + cpTimestamp stamp; }; //MARK: Handle Functions struct cpHandle { - void *obj; - int retain; - cpTimestamp stamp; + void *obj; + int retain; + cpTimestamp stamp; }; static cpHandle* cpHandleInit(cpHandle *hand, void *obj) { - hand->obj = obj; - hand->retain = 0; - hand->stamp = 0; - - return hand; + hand->obj = obj; + hand->retain = 0; + hand->stamp = 0; + + return hand; } static inline void cpHandleRetain(cpHandle *hand){hand->retain++;} @@ -68,8 +65,8 @@ static inline void cpHandleRetain(cpHandle *hand){hand->retain++;} static inline void cpHandleRelease(cpHandle *hand, cpArray *pooledHandles) { - hand->retain--; - if(hand->retain == 0) cpArrayPush(pooledHandles, hand); + hand->retain--; + if(hand->retain == 0) cpArrayPush(pooledHandles, hand); } static int handleSetEql(void *obj, cpHandle *hand){return (obj == hand->obj);} @@ -77,80 +74,80 @@ static int handleSetEql(void *obj, cpHandle *hand){return (obj == hand->obj);} static void * handleSetTrans(void *obj, cpSpaceHash *hash) { - if(hash->pooledHandles->num == 0){ - // handle pool is exhausted, make more - int count = CP_BUFFER_BYTES/sizeof(cpHandle); - cpAssertHard(count, "Internal Error: Buffer size is too small."); - - cpHandle *buffer = (cpHandle *)cpcalloc(1, CP_BUFFER_BYTES); - cpArrayPush(hash->allocatedBuffers, buffer); - - for(int i=0; ipooledHandles, buffer + i); - } - - cpHandle *hand = cpHandleInit((cpHandle *)cpArrayPop(hash->pooledHandles), obj); - cpHandleRetain(hand); - - return hand; + if(hash->pooledHandles->num == 0){ + // handle pool is exhausted, make more + int count = CP_BUFFER_BYTES/sizeof(cpHandle); + cpAssertHard(count, "Internal Error: Buffer size is too small."); + + cpHandle *buffer = (cpHandle *)cpcalloc(1, CP_BUFFER_BYTES); + cpArrayPush(hash->allocatedBuffers, buffer); + + for(int i=0; ipooledHandles, buffer + i); + } + + cpHandle *hand = cpHandleInit((cpHandle *)cpArrayPop(hash->pooledHandles), obj); + cpHandleRetain(hand); + + return hand; } //MARK: Bin Functions struct cpSpaceHashBin { - cpHandle *handle; - cpSpaceHashBin *next; + cpHandle *handle; + cpSpaceHashBin *next; }; static inline void recycleBin(cpSpaceHash *hash, cpSpaceHashBin *bin) { - bin->next = hash->pooledBins; - hash->pooledBins = bin; + bin->next = hash->pooledBins; + hash->pooledBins = bin; } static inline void clearTableCell(cpSpaceHash *hash, int idx) { - cpSpaceHashBin *bin = hash->table[idx]; - while(bin){ - cpSpaceHashBin *next = bin->next; - - cpHandleRelease(bin->handle, hash->pooledHandles); - recycleBin(hash, bin); - - bin = next; - } - - hash->table[idx] = NULL; + cpSpaceHashBin *bin = hash->table[idx]; + while(bin){ + cpSpaceHashBin *next = bin->next; + + cpHandleRelease(bin->handle, hash->pooledHandles); + recycleBin(hash, bin); + + bin = next; + } + + hash->table[idx] = NULL; } static void clearTable(cpSpaceHash *hash) { - for(int i=0; inumcells; i++) clearTableCell(hash, i); + for(int i=0; inumcells; i++) clearTableCell(hash, i); } // Get a recycled or new bin. static inline cpSpaceHashBin * getEmptyBin(cpSpaceHash *hash) { - cpSpaceHashBin *bin = hash->pooledBins; - - if(bin){ - hash->pooledBins = bin->next; - return bin; - } else { - // Pool is exhausted, make more - int count = CP_BUFFER_BYTES/sizeof(cpSpaceHashBin); - cpAssertHard(count, "Internal Error: Buffer size is too small."); - - cpSpaceHashBin *buffer = (cpSpaceHashBin *)cpcalloc(1, CP_BUFFER_BYTES); - cpArrayPush(hash->allocatedBuffers, buffer); - - // push all but the first one, return the first instead - for(int i=1; ipooledBins; + + if(bin){ + hash->pooledBins = bin->next; + return bin; + } else { + // Pool is exhausted, make more + int count = CP_BUFFER_BYTES/sizeof(cpSpaceHashBin); + cpAssertHard(count, "Internal Error: Buffer size is too small."); + + cpSpaceHashBin *buffer = (cpSpaceHashBin *)cpcalloc(1, CP_BUFFER_BYTES); + cpArrayPush(hash->allocatedBuffers, buffer); + + // push all but the first one, return the first instead + for(int i=1; itable); - - hash->numcells = numcells; - hash->table = (cpSpaceHashBin **)cpcalloc(numcells, sizeof(cpSpaceHashBin *)); + cpfree(hash->table); + + hash->numcells = numcells; + hash->table = (cpSpaceHashBin **)cpcalloc(numcells, sizeof(cpSpaceHashBin *)); } static inline cpSpatialIndexClass *Klass(); @@ -176,40 +173,40 @@ static inline cpSpatialIndexClass *Klass(); cpSpatialIndex * cpSpaceHashInit(cpSpaceHash *hash, cpFloat celldim, int numcells, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex) { - cpSpatialIndexInit((cpSpatialIndex *)hash, Klass(), bbfunc, staticIndex); - - cpSpaceHashAllocTable(hash, next_prime(numcells)); - hash->celldim = celldim; - - hash->handleSet = cpHashSetNew(0, (cpHashSetEqlFunc)handleSetEql); - - hash->pooledHandles = cpArrayNew(0); - - hash->pooledBins = NULL; - hash->allocatedBuffers = cpArrayNew(0); - - hash->stamp = 1; - - return (cpSpatialIndex *)hash; + cpSpatialIndexInit((cpSpatialIndex *)hash, Klass(), bbfunc, staticIndex); + + cpSpaceHashAllocTable(hash, next_prime(numcells)); + hash->celldim = celldim; + + hash->handleSet = cpHashSetNew(0, (cpHashSetEqlFunc)handleSetEql); + + hash->pooledHandles = cpArrayNew(0); + + hash->pooledBins = NULL; + hash->allocatedBuffers = cpArrayNew(0); + + hash->stamp = 1; + + return (cpSpatialIndex *)hash; } cpSpatialIndex * cpSpaceHashNew(cpFloat celldim, int cells, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex) { - return cpSpaceHashInit(cpSpaceHashAlloc(), celldim, cells, bbfunc, staticIndex); + return cpSpaceHashInit(cpSpaceHashAlloc(), celldim, cells, bbfunc, staticIndex); } static void cpSpaceHashDestroy(cpSpaceHash *hash) { - if(hash->table) clearTable(hash); - cpfree(hash->table); - - cpHashSetFree(hash->handleSet); - - cpArrayFreeEach(hash->allocatedBuffers, cpfree); - cpArrayFree(hash->allocatedBuffers); - cpArrayFree(hash->pooledHandles); + if(hash->table) clearTable(hash); + cpfree(hash->table); + + cpHashSetFree(hash->handleSet); + + cpArrayFreeEach(hash->allocatedBuffers, cpfree); + cpArrayFree(hash->allocatedBuffers); + cpArrayFree(hash->pooledHandles); } //MARK: Helper Functions @@ -217,19 +214,19 @@ cpSpaceHashDestroy(cpSpaceHash *hash) static inline cpBool containsHandle(cpSpaceHashBin *bin, cpHandle *hand) { - while(bin){ - if(bin->handle == hand) return cpTrue; - bin = bin->next; - } - - return cpFalse; + while(bin){ + if(bin->handle == hand) return cpTrue; + bin = bin->next; + } + + return cpFalse; } // The hash function itself. static inline cpHashValue hash_func(cpHashValue x, cpHashValue y, cpHashValue n) { - return (x*1640531513ul ^ y*2654435789ul) % n; + return (x*1640531513ul ^ y*2654435789ul) % n; } // Much faster than (int)floor(f) @@ -237,37 +234,37 @@ hash_func(cpHashValue x, cpHashValue y, cpHashValue n) static inline int floor_int(cpFloat f) { - int i = (int)f; - return (f < 0.0f && f != i ? i - 1 : i); + int i = (int)f; + return (f < 0.0f && f != i ? i - 1 : i); } static inline void hashHandle(cpSpaceHash *hash, cpHandle *hand, cpBB bb) { - // Find the dimensions in cell coordinates. - cpFloat dim = hash->celldim; - int l = floor_int(bb.l/dim); // Fix by ShiftZ - int r = floor_int(bb.r/dim); - int b = floor_int(bb.b/dim); - int t = floor_int(bb.t/dim); - - int n = hash->numcells; - for(int i=l; i<=r; i++){ - for(int j=b; j<=t; j++){ - cpHashValue idx = hash_func(i,j,n); - cpSpaceHashBin *bin = hash->table[idx]; - - // Don't add an object twice to the same cell. - if(containsHandle(bin, hand)) continue; + // Find the dimensions in cell coordinates. + cpFloat dim = hash->celldim; + int l = floor_int(bb.l/dim); // Fix by ShiftZ + int r = floor_int(bb.r/dim); + int b = floor_int(bb.b/dim); + int t = floor_int(bb.t/dim); + + int n = hash->numcells; + for(int i=l; i<=r; i++){ + for(int j=b; j<=t; j++){ + cpHashValue idx = hash_func(i,j,n); + cpSpaceHashBin *bin = hash->table[idx]; + + // Don't add an object twice to the same cell. + if(containsHandle(bin, hand)) continue; - cpHandleRetain(hand); - // Insert a new bin for the handle in this cell. - cpSpaceHashBin *newBin = getEmptyBin(hash); - newBin->handle = hand; - newBin->next = bin; - hash->table[idx] = newBin; - } - } + cpHandleRetain(hand); + // Insert a new bin for the handle in this cell. + cpSpaceHashBin *newBin = getEmptyBin(hash); + newBin->handle = hand; + newBin->next = bin; + hash->table[idx] = newBin; + } + } } //MARK: Basic Operations @@ -275,50 +272,50 @@ hashHandle(cpSpaceHash *hash, cpHandle *hand, cpBB bb) static void cpSpaceHashInsert(cpSpaceHash *hash, void *obj, cpHashValue hashid) { - cpHandle *hand = (cpHandle *)cpHashSetInsert(hash->handleSet, hashid, obj, hash, (cpHashSetTransFunc)handleSetTrans); - hashHandle(hash, hand, hash->spatialIndex.bbfunc(obj)); + cpHandle *hand = (cpHandle *)cpHashSetInsert(hash->handleSet, hashid, obj, hash, (cpHashSetTransFunc)handleSetTrans); + hashHandle(hash, hand, hash->spatialIndex.bbfunc(obj)); } static void cpSpaceHashRehashObject(cpSpaceHash *hash, void *obj, cpHashValue hashid) { - cpHandle *hand = (cpHandle *)cpHashSetRemove(hash->handleSet, hashid, obj); - - if(hand){ - hand->obj = NULL; - cpHandleRelease(hand, hash->pooledHandles); - - cpSpaceHashInsert(hash, obj, hashid); - } + cpHandle *hand = (cpHandle *)cpHashSetRemove(hash->handleSet, hashid, obj); + + if(hand){ + hand->obj = NULL; + cpHandleRelease(hand, hash->pooledHandles); + + cpSpaceHashInsert(hash, obj, hashid); + } } static void rehash_helper(cpHandle *hand, cpSpaceHash *hash) { - hashHandle(hash, hand, hash->spatialIndex.bbfunc(hand->obj)); + hashHandle(hash, hand, hash->spatialIndex.bbfunc(hand->obj)); } static void cpSpaceHashRehash(cpSpaceHash *hash) { - clearTable(hash); - cpHashSetEach(hash->handleSet, (cpHashSetIteratorFunc)rehash_helper, hash); + clearTable(hash); + cpHashSetEach(hash->handleSet, (cpHashSetIteratorFunc)rehash_helper, hash); } static void cpSpaceHashRemove(cpSpaceHash *hash, void *obj, cpHashValue hashid) { - cpHandle *hand = (cpHandle *)cpHashSetRemove(hash->handleSet, hashid, obj); - - if(hand){ - hand->obj = NULL; - cpHandleRelease(hand, hash->pooledHandles); - } + cpHandle *hand = (cpHandle *)cpHashSetRemove(hash->handleSet, hashid, obj); + + if(hand){ + hand->obj = NULL; + cpHandleRelease(hand, hash->pooledHandles); + } } typedef struct eachContext { - cpSpatialIndexIteratorFunc func; - void *data; + cpSpatialIndexIteratorFunc func; + void *data; } eachContext; static void eachHelper(cpHandle *hand, eachContext *context){context->func(hand->obj, context->data);} @@ -326,30 +323,30 @@ static void eachHelper(cpHandle *hand, eachContext *context){context->func(hand- static void cpSpaceHashEach(cpSpaceHash *hash, cpSpatialIndexIteratorFunc func, void *data) { - eachContext context = {func, data}; - cpHashSetEach(hash->handleSet, (cpHashSetIteratorFunc)eachHelper, &context); + eachContext context = {func, data}; + cpHashSetEach(hash->handleSet, (cpHashSetIteratorFunc)eachHelper, &context); } static void remove_orphaned_handles(cpSpaceHash *hash, cpSpaceHashBin **bin_ptr) { - cpSpaceHashBin *bin = *bin_ptr; - while(bin){ - cpHandle *hand = bin->handle; - cpSpaceHashBin *next = bin->next; - - if(!hand->obj){ - // orphaned handle, unlink and recycle the bin - (*bin_ptr) = bin->next; - recycleBin(hash, bin); - - cpHandleRelease(hand, hash->pooledHandles); - } else { - bin_ptr = &bin->next; - } - - bin = next; - } + cpSpaceHashBin *bin = *bin_ptr; + while(bin){ + cpHandle *hand = bin->handle; + cpSpaceHashBin *next = bin->next; + + if(!hand->obj){ + // orphaned handle, unlink and recycle the bin + (*bin_ptr) = bin->next; + recycleBin(hash, bin); + + cpHandleRelease(hand, hash->pooledHandles); + } else { + bin_ptr = &bin->next; + } + + bin = next; + } } //MARK: Query Functions @@ -357,202 +354,192 @@ remove_orphaned_handles(cpSpaceHash *hash, cpSpaceHashBin **bin_ptr) static inline void query_helper(cpSpaceHash *hash, cpSpaceHashBin **bin_ptr, void *obj, cpSpatialIndexQueryFunc func, void *data) { - restart: - for(cpSpaceHashBin *bin = *bin_ptr; bin; bin = bin->next){ - cpHandle *hand = bin->handle; - void *other = hand->obj; - - if(hand->stamp == hash->stamp || obj == other){ - continue; - } else if(other){ - func(obj, other, data); - hand->stamp = hash->stamp; - } else { - // The object for this handle has been removed - // cleanup this cell and restart the query - remove_orphaned_handles(hash, bin_ptr); - goto restart; // GCC not smart enough/able to tail call an inlined function. - } - } -} - -static void -cpSpaceHashPointQuery(cpSpaceHash *hash, cpVect point, cpSpatialIndexQueryFunc func, void *data) -{ - cpFloat dim = hash->celldim; - cpHashValue idx = hash_func(floor_int(point.x/dim), floor_int(point.y/dim), hash->numcells); // Fix by ShiftZ - - query_helper(hash, &hash->table[idx], &point, func, data); - hash->stamp++; + restart: + for(cpSpaceHashBin *bin = *bin_ptr; bin; bin = bin->next){ + cpHandle *hand = bin->handle; + void *other = hand->obj; + + if(hand->stamp == hash->stamp || obj == other){ + continue; + } else if(other){ + func(obj, other, data); + hand->stamp = hash->stamp; + } else { + // The object for this handle has been removed + // cleanup this cell and restart the query + remove_orphaned_handles(hash, bin_ptr); + goto restart; // GCC not smart enough/able to tail call an inlined function. + } + } } static void cpSpaceHashQuery(cpSpaceHash *hash, void *obj, cpBB bb, cpSpatialIndexQueryFunc func, void *data) { - // Get the dimensions in cell coordinates. - cpFloat dim = hash->celldim; - int l = floor_int(bb.l/dim); // Fix by ShiftZ - int r = floor_int(bb.r/dim); - int b = floor_int(bb.b/dim); - int t = floor_int(bb.t/dim); - - int n = hash->numcells; - cpSpaceHashBin **table = hash->table; - - // Iterate over the cells and query them. - for(int i=l; i<=r; i++){ - for(int j=b; j<=t; j++){ - query_helper(hash, &table[hash_func(i,j,n)], obj, func, data); - } - } - - hash->stamp++; + // Get the dimensions in cell coordinates. + cpFloat dim = hash->celldim; + int l = floor_int(bb.l/dim); // Fix by ShiftZ + int r = floor_int(bb.r/dim); + int b = floor_int(bb.b/dim); + int t = floor_int(bb.t/dim); + + int n = hash->numcells; + cpSpaceHashBin **table = hash->table; + + // Iterate over the cells and query them. + for(int i=l; i<=r; i++){ + for(int j=b; j<=t; j++){ + query_helper(hash, &table[hash_func(i,j,n)], obj, func, data); + } + } + + hash->stamp++; } // Similar to struct eachPair above. typedef struct queryRehashContext { - cpSpaceHash *hash; - cpSpatialIndexQueryFunc func; - void *data; + cpSpaceHash *hash; + cpSpatialIndexQueryFunc func; + void *data; } queryRehashContext; // Hashset iterator func used with cpSpaceHashQueryRehash(). static void queryRehash_helper(cpHandle *hand, queryRehashContext *context) { - cpSpaceHash *hash = context->hash; - cpSpatialIndexQueryFunc func = context->func; - void *data = context->data; + cpSpaceHash *hash = context->hash; + cpSpatialIndexQueryFunc func = context->func; + void *data = context->data; - cpFloat dim = hash->celldim; - int n = hash->numcells; + cpFloat dim = hash->celldim; + int n = hash->numcells; - void *obj = hand->obj; - cpBB bb = hash->spatialIndex.bbfunc(obj); + void *obj = hand->obj; + cpBB bb = hash->spatialIndex.bbfunc(obj); - int l = floor_int(bb.l/dim); - int r = floor_int(bb.r/dim); - int b = floor_int(bb.b/dim); - int t = floor_int(bb.t/dim); - - cpSpaceHashBin **table = hash->table; + int l = floor_int(bb.l/dim); + int r = floor_int(bb.r/dim); + int b = floor_int(bb.b/dim); + int t = floor_int(bb.t/dim); + + cpSpaceHashBin **table = hash->table; - for(int i=l; i<=r; i++){ - for(int j=b; j<=t; j++){ - cpHashValue idx = hash_func(i,j,n); - cpSpaceHashBin *bin = table[idx]; - - if(containsHandle(bin, hand)) continue; - - cpHandleRetain(hand); // this MUST be done first in case the object is removed in func() - query_helper(hash, &bin, obj, func, data); - - cpSpaceHashBin *newBin = getEmptyBin(hash); - newBin->handle = hand; - newBin->next = bin; - table[idx] = newBin; - } - } - - // Increment the stamp for each object hashed. - hash->stamp++; + for(int i=l; i<=r; i++){ + for(int j=b; j<=t; j++){ + cpHashValue idx = hash_func(i,j,n); + cpSpaceHashBin *bin = table[idx]; + + if(containsHandle(bin, hand)) continue; + + cpHandleRetain(hand); // this MUST be done first in case the object is removed in func() + query_helper(hash, &bin, obj, func, data); + + cpSpaceHashBin *newBin = getEmptyBin(hash); + newBin->handle = hand; + newBin->next = bin; + table[idx] = newBin; + } + } + + // Increment the stamp for each object hashed. + hash->stamp++; } static void cpSpaceHashReindexQuery(cpSpaceHash *hash, cpSpatialIndexQueryFunc func, void *data) { - clearTable(hash); - - queryRehashContext context = {hash, func, data}; - cpHashSetEach(hash->handleSet, (cpHashSetIteratorFunc)queryRehash_helper, &context); - - cpSpatialIndexCollideStatic((cpSpatialIndex *)hash, hash->spatialIndex.staticIndex, func, data); + clearTable(hash); + + queryRehashContext context = {hash, func, data}; + cpHashSetEach(hash->handleSet, (cpHashSetIteratorFunc)queryRehash_helper, &context); + + cpSpatialIndexCollideStatic((cpSpatialIndex *)hash, hash->spatialIndex.staticIndex, func, data); } static inline cpFloat segmentQuery_helper(cpSpaceHash *hash, cpSpaceHashBin **bin_ptr, void *obj, cpSpatialIndexSegmentQueryFunc func, void *data) { - cpFloat t = 1.0f; - - restart: - for(cpSpaceHashBin *bin = *bin_ptr; bin; bin = bin->next){ - cpHandle *hand = bin->handle; - void *other = hand->obj; - - // Skip over certain conditions - if(hand->stamp == hash->stamp){ - continue; - } else if(other){ - t = cpfmin(t, func(obj, other, data)); - hand->stamp = hash->stamp; - } else { - // The object for this handle has been removed - // cleanup this cell and restart the query - remove_orphaned_handles(hash, bin_ptr); - goto restart; // GCC not smart enough/able to tail call an inlined function. - } - } - - return t; + cpFloat t = 1.0f; + + restart: + for(cpSpaceHashBin *bin = *bin_ptr; bin; bin = bin->next){ + cpHandle *hand = bin->handle; + void *other = hand->obj; + + // Skip over certain conditions + if(hand->stamp == hash->stamp){ + continue; + } else if(other){ + t = cpfmin(t, func(obj, other, data)); + hand->stamp = hash->stamp; + } else { + // The object for this handle has been removed + // cleanup this cell and restart the query + remove_orphaned_handles(hash, bin_ptr); + goto restart; // GCC not smart enough/able to tail call an inlined function. + } + } + + return t; } // modified from http://playtechs.blogspot.com/2007/03/raytracing-on-grid.html static void cpSpaceHashSegmentQuery(cpSpaceHash *hash, void *obj, cpVect a, cpVect b, cpFloat t_exit, cpSpatialIndexSegmentQueryFunc func, void *data) { - a = cpvmult(a, 1.0f/hash->celldim); - b = cpvmult(b, 1.0f/hash->celldim); - - int cell_x = floor_int(a.x), cell_y = floor_int(a.y); + a = cpvmult(a, 1.0f/hash->celldim); + b = cpvmult(b, 1.0f/hash->celldim); + + int cell_x = floor_int(a.x), cell_y = floor_int(a.y); - cpFloat t = 0; + cpFloat t = 0; - int x_inc, y_inc; - cpFloat temp_v, temp_h; + int x_inc, y_inc; + cpFloat temp_v, temp_h; - if (b.x > a.x){ - x_inc = 1; - temp_h = (cpffloor(a.x + 1.0f) - a.x); - } else { - x_inc = -1; - temp_h = (a.x - cpffloor(a.x)); - } + if (b.x > a.x){ + x_inc = 1; + temp_h = (cpffloor(a.x + 1.0f) - a.x); + } else { + x_inc = -1; + temp_h = (a.x - cpffloor(a.x)); + } - if (b.y > a.y){ - y_inc = 1; - temp_v = (cpffloor(a.y + 1.0f) - a.y); - } else { - y_inc = -1; - temp_v = (a.y - cpffloor(a.y)); - } - - // Division by zero is *very* slow on ARM - cpFloat dx = cpfabs(b.x - a.x), dy = cpfabs(b.y - a.y); - cpFloat dt_dx = (dx ? 1.0f/dx : INFINITY), dt_dy = (dy ? 1.0f/dy : INFINITY); - - // fix NANs in horizontal directions - cpFloat next_h = (temp_h ? temp_h*dt_dx : dt_dx); - cpFloat next_v = (temp_v ? temp_v*dt_dy : dt_dy); - - int n = hash->numcells; - cpSpaceHashBin **table = hash->table; + if (b.y > a.y){ + y_inc = 1; + temp_v = (cpffloor(a.y + 1.0f) - a.y); + } else { + y_inc = -1; + temp_v = (a.y - cpffloor(a.y)); + } + + // Division by zero is *very* slow on ARM + cpFloat dx = cpfabs(b.x - a.x), dy = cpfabs(b.y - a.y); + cpFloat dt_dx = (dx ? 1.0f/dx : INFINITY), dt_dy = (dy ? 1.0f/dy : INFINITY); + + // fix NANs in horizontal directions + cpFloat next_h = (temp_h ? temp_h*dt_dx : dt_dx); + cpFloat next_v = (temp_v ? temp_v*dt_dy : dt_dy); + + int n = hash->numcells; + cpSpaceHashBin **table = hash->table; - while(t < t_exit){ - cpHashValue idx = hash_func(cell_x, cell_y, n); - t_exit = cpfmin(t_exit, segmentQuery_helper(hash, &table[idx], obj, func, data)); + while(t < t_exit){ + cpHashValue idx = hash_func(cell_x, cell_y, n); + t_exit = cpfmin(t_exit, segmentQuery_helper(hash, &table[idx], obj, func, data)); - if (next_v < next_h){ - cell_y += y_inc; - t = next_v; - next_v += dt_dy; - } else { - cell_x += x_inc; - t = next_h; - next_h += dt_dx; - } - } - - hash->stamp++; + if (next_v < next_h){ + cell_y += y_inc; + t = next_v; + next_v += dt_dy; + } else { + cell_x += x_inc; + t = next_h; + next_h += dt_dx; + } + } + + hash->stamp++; } //MARK: Misc @@ -560,46 +547,45 @@ cpSpaceHashSegmentQuery(cpSpaceHash *hash, void *obj, cpVect a, cpVect b, cpFloa void cpSpaceHashResize(cpSpaceHash *hash, cpFloat celldim, int numcells) { - if(hash->spatialIndex.klass != Klass()){ - cpAssertWarn(cpFalse, "Ignoring cpSpaceHashResize() call to non-cpSpaceHash spatial index."); - return; - } - - clearTable(hash); - - hash->celldim = celldim; - cpSpaceHashAllocTable(hash, next_prime(numcells)); + if(hash->spatialIndex.klass != Klass()){ + cpAssertWarn(cpFalse, "Ignoring cpSpaceHashResize() call to non-cpSpaceHash spatial index."); + return; + } + + clearTable(hash); + + hash->celldim = celldim; + cpSpaceHashAllocTable(hash, next_prime(numcells)); } static int cpSpaceHashCount(cpSpaceHash *hash) { - return cpHashSetCount(hash->handleSet); + return cpHashSetCount(hash->handleSet); } static int cpSpaceHashContains(cpSpaceHash *hash, void *obj, cpHashValue hashid) { - return cpHashSetFind(hash->handleSet, hashid, obj) != NULL; + return cpHashSetFind(hash->handleSet, hashid, obj) != NULL; } static cpSpatialIndexClass klass = { - (cpSpatialIndexDestroyImpl)cpSpaceHashDestroy, - - (cpSpatialIndexCountImpl)cpSpaceHashCount, - (cpSpatialIndexEachImpl)cpSpaceHashEach, - (cpSpatialIndexContainsImpl)cpSpaceHashContains, - - (cpSpatialIndexInsertImpl)cpSpaceHashInsert, - (cpSpatialIndexRemoveImpl)cpSpaceHashRemove, - - (cpSpatialIndexReindexImpl)cpSpaceHashRehash, - (cpSpatialIndexReindexObjectImpl)cpSpaceHashRehashObject, - (cpSpatialIndexReindexQueryImpl)cpSpaceHashReindexQuery, - - (cpSpatialIndexPointQueryImpl)cpSpaceHashPointQuery, - (cpSpatialIndexSegmentQueryImpl)cpSpaceHashSegmentQuery, - (cpSpatialIndexQueryImpl)cpSpaceHashQuery, + (cpSpatialIndexDestroyImpl)cpSpaceHashDestroy, + + (cpSpatialIndexCountImpl)cpSpaceHashCount, + (cpSpatialIndexEachImpl)cpSpaceHashEach, + (cpSpatialIndexContainsImpl)cpSpaceHashContains, + + (cpSpatialIndexInsertImpl)cpSpaceHashInsert, + (cpSpatialIndexRemoveImpl)cpSpaceHashRemove, + + (cpSpatialIndexReindexImpl)cpSpaceHashRehash, + (cpSpatialIndexReindexObjectImpl)cpSpaceHashRehashObject, + (cpSpatialIndexReindexQueryImpl)cpSpaceHashReindexQuery, + + (cpSpatialIndexQueryImpl)cpSpaceHashQuery, + (cpSpatialIndexSegmentQueryImpl)cpSpaceHashSegmentQuery, }; static inline cpSpatialIndexClass *Klass(){return &klass;} @@ -615,34 +601,34 @@ static inline cpSpatialIndexClass *Klass(){return &klass;} void cpSpaceHashRenderDebug(cpSpatialIndex *index) { - if(index->klass != &klass){ - cpAssertWarn(cpFalse, "Ignoring cpSpaceHashRenderDebug() call to non-spatial hash spatial index."); - return; - } - - cpSpaceHash *hash = (cpSpaceHash *)index; - cpBB bb = cpBBNew(-320, -240, 320, 240); - - cpFloat dim = hash->celldim; - int n = hash->numcells; - - int l = (int)floor(bb.l/dim); - int r = (int)floor(bb.r/dim); - int b = (int)floor(bb.b/dim); - int t = (int)floor(bb.t/dim); - - for(int i=l; i<=r; i++){ - for(int j=b; j<=t; j++){ - int cell_count = 0; - - int index = hash_func(i,j,n); - for(cpSpaceHashBin *bin = hash->table[index]; bin; bin = bin->next) - cell_count++; - - GLfloat v = 1.0f - (GLfloat)cell_count/10.0f; - glColor3f(v,v,v); - glRectf(i*dim, j*dim, (i + 1)*dim, (j + 1)*dim); - } - } + if(index->klass != &klass){ + cpAssertWarn(cpFalse, "Ignoring cpSpaceHashRenderDebug() call to non-spatial hash spatial index."); + return; + } + + cpSpaceHash *hash = (cpSpaceHash *)index; + cpBB bb = cpBBNew(-320, -240, 320, 240); + + cpFloat dim = hash->celldim; + int n = hash->numcells; + + int l = (int)floor(bb.l/dim); + int r = (int)floor(bb.r/dim); + int b = (int)floor(bb.b/dim); + int t = (int)floor(bb.t/dim); + + for(int i=l; i<=r; i++){ + for(int j=b; j<=t; j++){ + int cell_count = 0; + + int index = hash_func(i,j,n); + for(cpSpaceHashBin *bin = hash->table[index]; bin; bin = bin->next) + cell_count++; + + GLfloat v = 1.0f - (GLfloat)cell_count/10.0f; + glColor3f(v,v,v); + glRectf(i*dim, j*dim, (i + 1)*dim, (j + 1)*dim); + } + } } #endif diff --git a/chipmunk/src/cpSpaceQuery.c b/chipmunk/src/cpSpaceQuery.c index 734b9ad2a2..7d8e46ebf7 100644 --- a/chipmunk/src/cpSpaceQuery.c +++ b/chipmunk/src/cpSpaceQuery.c @@ -19,228 +19,294 @@ * SOFTWARE. */ -#include - #include "chipmunk_private.h" //MARK: Point Query Functions -typedef struct pointQueryContext { - cpLayers layers; - cpGroup group; - cpSpacePointQueryFunc func; - void *data; -} pointQueryContext; +struct PointQueryContext { + cpVect point; + cpLayers layers; + cpGroup group; + cpSpacePointQueryFunc func; + void *data; +}; static void -pointQueryHelper(cpVect *point, cpShape *shape, pointQueryContext *context) +PointQuery(struct PointQueryContext *context, cpShape *shape, void *data) { - if( - !(shape->group && context->group == shape->group) && (context->layers&shape->layers) && - cpShapePointQuery(shape, *point) - ){ - context->func(shape, context->data); - } + if( + !(shape->group && context->group == shape->group) && (context->layers&shape->layers) && + cpShapePointQuery(shape, context->point) + ){ + context->func(shape, context->data); + } } void cpSpacePointQuery(cpSpace *space, cpVect point, cpLayers layers, cpGroup group, cpSpacePointQueryFunc func, void *data) { - pointQueryContext context = {layers, group, func, data}; - - cpSpaceLock(space); { - cpSpatialIndexPointQuery(space->activeShapes, point, (cpSpatialIndexQueryFunc)pointQueryHelper, &context); - cpSpatialIndexPointQuery(space->staticShapes, point, (cpSpatialIndexQueryFunc)pointQueryHelper, &context); - } cpSpaceUnlock(space, cpTrue); + struct PointQueryContext context = {point, layers, group, func, data}; + cpBB bb = cpBBNewForCircle(point, 0.0f); + + cpSpaceLock(space); { + cpSpatialIndexQuery(space->activeShapes, &context, bb, (cpSpatialIndexQueryFunc)PointQuery, data); + cpSpatialIndexQuery(space->staticShapes, &context, bb, (cpSpatialIndexQueryFunc)PointQuery, data); + } cpSpaceUnlock(space, cpTrue); } static void -rememberLastPointQuery(cpShape *shape, cpShape **outShape) +PointQueryFirst(cpShape *shape, cpShape **outShape) { - if(!shape->sensor) *outShape = shape; + if(!shape->sensor) *outShape = shape; } cpShape * cpSpacePointQueryFirst(cpSpace *space, cpVect point, cpLayers layers, cpGroup group) { - cpShape *shape = NULL; - cpSpacePointQuery(space, point, layers, group, (cpSpacePointQueryFunc)rememberLastPointQuery, &shape); - - return shape; + cpShape *shape = NULL; + cpSpacePointQuery(space, point, layers, group, (cpSpacePointQueryFunc)PointQueryFirst, &shape); + + return shape; +} + +//MARK: Nearest Point Query Functions + +struct NearestPointQueryContext { + cpVect point; + cpFloat maxDistance; + cpLayers layers; + cpGroup group; + cpSpaceNearestPointQueryFunc func; +}; + +static void +NearestPointQuery(struct NearestPointQueryContext *context, cpShape *shape, void *data) +{ + if( + !(shape->group && context->group == shape->group) && (context->layers&shape->layers) + ){ + cpNearestPointQueryInfo info; + cpShapeNearestPointQuery(shape, context->point, &info); + + if(info.shape && info.d < context->maxDistance) context->func(shape, info.d, info.p, data); + } +} + +void +cpSpaceNearestPointQuery(cpSpace *space, cpVect point, cpFloat maxDistance, cpLayers layers, cpGroup group, cpSpaceNearestPointQueryFunc func, void *data) +{ + struct NearestPointQueryContext context = {point, maxDistance, layers, group, func}; + cpBB bb = cpBBNewForCircle(point, cpfmax(maxDistance, 0.0f)); + + cpSpaceLock(space); { + cpSpatialIndexQuery(space->activeShapes, &context, bb, (cpSpatialIndexQueryFunc)NearestPointQuery, data); + cpSpatialIndexQuery(space->staticShapes, &context, bb, (cpSpatialIndexQueryFunc)NearestPointQuery, data); + } cpSpaceUnlock(space, cpTrue); +} + +static void +NearestPointQueryNearest(struct NearestPointQueryContext *context, cpShape *shape, cpNearestPointQueryInfo *out) +{ + if( + !(shape->group && context->group == shape->group) && (context->layers&shape->layers) && !shape->sensor + ){ + cpNearestPointQueryInfo info; + cpShapeNearestPointQuery(shape, context->point, &info); + + if(info.d < out->d) (*out) = info; + } +} + +cpShape * +cpSpaceNearestPointQueryNearest(cpSpace *space, cpVect point, cpFloat maxDistance, cpLayers layers, cpGroup group, cpNearestPointQueryInfo *out) +{ + cpNearestPointQueryInfo info = {NULL, cpvzero, maxDistance}; + if(out){ + (*out) = info; + } else { + out = &info; + } + + struct NearestPointQueryContext context = { + point, maxDistance, + layers, group, + NULL + }; + + cpBB bb = cpBBNewForCircle(point, cpfmax(maxDistance, 0.0f)); + cpSpatialIndexQuery(space->activeShapes, &context, bb, (cpSpatialIndexQueryFunc)NearestPointQueryNearest, out); + cpSpatialIndexQuery(space->staticShapes, &context, bb, (cpSpatialIndexQueryFunc)NearestPointQueryNearest, out); + + return out->shape; } //MARK: Segment Query Functions -typedef struct segQueryContext { - cpVect start, end; - cpLayers layers; - cpGroup group; - cpSpaceSegmentQueryFunc func; -} segQueryContext; +struct SegmentQueryContext { + cpVect start, end; + cpLayers layers; + cpGroup group; + cpSpaceSegmentQueryFunc func; +}; static cpFloat -segQueryFunc(segQueryContext *context, cpShape *shape, void *data) +SegmentQuery(struct SegmentQueryContext *context, cpShape *shape, void *data) { - cpSegmentQueryInfo info; - - if( - !(shape->group && context->group == shape->group) && (context->layers&shape->layers) && - cpShapeSegmentQuery(shape, context->start, context->end, &info) - ){ - context->func(shape, info.t, info.n, data); - } - - return 1.0f; + cpSegmentQueryInfo info; + + if( + !(shape->group && context->group == shape->group) && (context->layers&shape->layers) && + cpShapeSegmentQuery(shape, context->start, context->end, &info) + ){ + context->func(shape, info.t, info.n, data); + } + + return 1.0f; } void cpSpaceSegmentQuery(cpSpace *space, cpVect start, cpVect end, cpLayers layers, cpGroup group, cpSpaceSegmentQueryFunc func, void *data) { - segQueryContext context = { - start, end, - layers, group, - func, - }; - - cpSpaceLock(space); { - cpSpatialIndexSegmentQuery(space->staticShapes, &context, start, end, 1.0f, (cpSpatialIndexSegmentQueryFunc)segQueryFunc, data); - cpSpatialIndexSegmentQuery(space->activeShapes, &context, start, end, 1.0f, (cpSpatialIndexSegmentQueryFunc)segQueryFunc, data); - } cpSpaceUnlock(space, cpTrue); + struct SegmentQueryContext context = { + start, end, + layers, group, + func, + }; + + cpSpaceLock(space); { + cpSpatialIndexSegmentQuery(space->staticShapes, &context, start, end, 1.0f, (cpSpatialIndexSegmentQueryFunc)SegmentQuery, data); + cpSpatialIndexSegmentQuery(space->activeShapes, &context, start, end, 1.0f, (cpSpatialIndexSegmentQueryFunc)SegmentQuery, data); + } cpSpaceUnlock(space, cpTrue); } -typedef struct segQueryFirstContext { - cpVect start, end; - cpLayers layers; - cpGroup group; -} segQueryFirstContext; - static cpFloat -segQueryFirst(segQueryFirstContext *context, cpShape *shape, cpSegmentQueryInfo *out) +SegmentQueryFirst(struct SegmentQueryContext *context, cpShape *shape, cpSegmentQueryInfo *out) { - cpSegmentQueryInfo info; - - if( - !(shape->group && context->group == shape->group) && (context->layers&shape->layers) && - !shape->sensor && - cpShapeSegmentQuery(shape, context->start, context->end, &info) && - info.t < out->t - ){ - *out = info; - } - - return out->t; + cpSegmentQueryInfo info; + + if( + !(shape->group && context->group == shape->group) && (context->layers&shape->layers) && + !shape->sensor && + cpShapeSegmentQuery(shape, context->start, context->end, &info) && + info.t < out->t + ){ + (*out) = info; + } + + return out->t; } cpShape * cpSpaceSegmentQueryFirst(cpSpace *space, cpVect start, cpVect end, cpLayers layers, cpGroup group, cpSegmentQueryInfo *out) { - cpSegmentQueryInfo info = {NULL, 1.0f, cpvzero}; - if(out){ - (*out) = info; + cpSegmentQueryInfo info = {NULL, 1.0f, cpvzero}; + if(out){ + (*out) = info; } else { - out = &info; - } - - segQueryFirstContext context = { - start, end, - layers, group - }; - - cpSpatialIndexSegmentQuery(space->staticShapes, &context, start, end, 1.0f, (cpSpatialIndexSegmentQueryFunc)segQueryFirst, out); - cpSpatialIndexSegmentQuery(space->activeShapes, &context, start, end, out->t, (cpSpatialIndexSegmentQueryFunc)segQueryFirst, out); - - return out->shape; + out = &info; + } + + struct SegmentQueryContext context = { + start, end, + layers, group, + NULL + }; + + cpSpatialIndexSegmentQuery(space->staticShapes, &context, start, end, 1.0f, (cpSpatialIndexSegmentQueryFunc)SegmentQueryFirst, out); + cpSpatialIndexSegmentQuery(space->activeShapes, &context, start, end, out->t, (cpSpatialIndexSegmentQueryFunc)SegmentQueryFirst, out); + + return out->shape; } //MARK: BB Query Functions -typedef struct bbQueryContext { - cpLayers layers; - cpGroup group; - cpSpaceBBQueryFunc func; - void *data; -} bbQueryContext; +struct BBQueryContext { + cpBB bb; + cpLayers layers; + cpGroup group; + cpSpaceBBQueryFunc func; +}; static void -bbQueryHelper(cpBB *bb, cpShape *shape, bbQueryContext *context) +BBQuery(struct BBQueryContext *context, cpShape *shape, void *data) { - if( - !(shape->group && context->group == shape->group) && (context->layers&shape->layers) && - cpBBIntersects(*bb, shape->bb) - ){ - context->func(shape, context->data); - } + if( + !(shape->group && context->group == shape->group) && (context->layers&shape->layers) && + cpBBIntersects(context->bb, shape->bb) + ){ + context->func(shape, data); + } } void cpSpaceBBQuery(cpSpace *space, cpBB bb, cpLayers layers, cpGroup group, cpSpaceBBQueryFunc func, void *data) { - bbQueryContext context = {layers, group, func, data}; - - cpSpaceLock(space); { - cpSpatialIndexQuery(space->activeShapes, &bb, bb, (cpSpatialIndexQueryFunc)bbQueryHelper, &context); - cpSpatialIndexQuery(space->staticShapes, &bb, bb, (cpSpatialIndexQueryFunc)bbQueryHelper, &context); - } cpSpaceUnlock(space, cpTrue); + struct BBQueryContext context = {bb, layers, group, func}; + + cpSpaceLock(space); { + cpSpatialIndexQuery(space->activeShapes, &context, bb, (cpSpatialIndexQueryFunc)BBQuery, data); + cpSpatialIndexQuery(space->staticShapes, &context, bb, (cpSpatialIndexQueryFunc)BBQuery, data); + } cpSpaceUnlock(space, cpTrue); } //MARK: Shape Query Functions -typedef struct shapeQueryContext { - cpSpaceShapeQueryFunc func; - void *data; - cpBool anyCollision; -} shapeQueryContext; +struct ShapeQueryContext { + cpSpaceShapeQueryFunc func; + void *data; + cpBool anyCollision; +}; // Callback from the spatial hash. static void -shapeQueryHelper(cpShape *a, cpShape *b, shapeQueryContext *context) +ShapeQuery(cpShape *a, cpShape *b, struct ShapeQueryContext *context) { - // Reject any of the simple cases - if( - (a->group && a->group == b->group) || - !(a->layers & b->layers) || - a == b - ) return; - - cpContact contacts[CP_MAX_CONTACTS_PER_ARBITER]; - int numContacts = 0; - - // Shape 'a' should have the lower shape type. (required by cpCollideShapes() ) - if(a->klass->type <= b->klass->type){ - numContacts = cpCollideShapes(a, b, contacts); - } else { - numContacts = cpCollideShapes(b, a, contacts); - for(int i=0; ianyCollision = !(a->sensor || b->sensor); - - if(context->func){ - cpContactPointSet set = {numContacts, {}}; - for(int i=0; ifunc(b, &set, context->data); - } - } + // Reject any of the simple cases + if( + (a->group && a->group == b->group) || + !(a->layers & b->layers) || + a == b + ) return; + + cpContact contacts[CP_MAX_CONTACTS_PER_ARBITER]; + int numContacts = 0; + + // Shape 'a' should have the lower shape type. (required by cpCollideShapes() ) + if(a->klass->type <= b->klass->type){ + numContacts = cpCollideShapes(a, b, contacts); + } else { + numContacts = cpCollideShapes(b, a, contacts); + for(int i=0; ianyCollision = !(a->sensor || b->sensor); + + if(context->func){ + cpContactPointSet set = {numContacts, {}}; + for(int i=0; ifunc(b, &set, context->data); + } + } } cpBool cpSpaceShapeQuery(cpSpace *space, cpShape *shape, cpSpaceShapeQueryFunc func, void *data) { - cpBody *body = shape->body; - cpBB bb = (body ? cpShapeUpdate(shape, body->p, body->rot) : shape->bb); - shapeQueryContext context = {func, data, cpFalse}; - - cpSpaceLock(space); { - cpSpatialIndexQuery(space->activeShapes, shape, bb, (cpSpatialIndexQueryFunc)shapeQueryHelper, &context); - cpSpatialIndexQuery(space->staticShapes, shape, bb, (cpSpatialIndexQueryFunc)shapeQueryHelper, &context); - } cpSpaceUnlock(space, cpTrue); - - return context.anyCollision; + cpBody *body = shape->body; + cpBB bb = (body ? cpShapeUpdate(shape, body->p, body->rot) : shape->bb); + struct ShapeQueryContext context = {func, data, cpFalse}; + + cpSpaceLock(space); { + cpSpatialIndexQuery(space->activeShapes, shape, bb, (cpSpatialIndexQueryFunc)ShapeQuery, &context); + cpSpatialIndexQuery(space->staticShapes, shape, bb, (cpSpatialIndexQueryFunc)ShapeQuery, &context); + } cpSpaceUnlock(space, cpTrue); + + return context.anyCollision; } diff --git a/chipmunk/src/cpSpaceStep.c b/chipmunk/src/cpSpaceStep.c index eddd4effba..2096e14ffb 100644 --- a/chipmunk/src/cpSpaceStep.c +++ b/chipmunk/src/cpSpaceStep.c @@ -19,79 +19,43 @@ * SOFTWARE. */ -#include -#include -#include - #include "chipmunk_private.h" //MARK: Post Step Callback Functions typedef struct cpPostStepCallback { - cpPostStepFunc func; - void *obj; - void *data; + cpPostStepFunc func; + void *key; + void *data; } cpPostStepCallback; -static cpBool -postStepFuncSetEql(cpPostStepCallback *a, cpPostStepCallback *b){ - return a->obj == b->obj; -} - -static void * -postStepFuncSetTrans(cpPostStepCallback *callback, void *ignored) +void * +cpSpaceGetPostStepData(cpSpace *space, void *key) { - cpPostStepCallback *value = (cpPostStepCallback *)cpcalloc(1, sizeof(cpPostStepCallback)); - (*value) = (*callback); - - return value; + cpArray *arr = space->postStepCallbacks; + for(int i=0; inum; i++){ + cpPostStepCallback *callback = (cpPostStepCallback *)arr->arr[i]; + if(callback->key == key) return callback->data; + } + + return NULL; } void -cpSpaceAddPostStepCallback(cpSpace *space, cpPostStepFunc func, void *obj, void *data) +cpSpaceAddPostStepCallback(cpSpace *space, cpPostStepFunc func, void *key, void *data) { - cpAssertWarn(space->locked, - "Adding a post-step callback when the space is not locked is unnecessary. " - "Post-step callbacks will not called until the end of the next call to cpSpaceStep() or the next query."); - - if(!space->postStepCallbacks){ - space->postStepCallbacks = cpHashSetNew(0, (cpHashSetEqlFunc)postStepFuncSetEql); - } - - cpPostStepCallback callback = {func, obj, data}; - cpHashSetInsert(space->postStepCallbacks, (cpHashValue)obj, &callback, NULL, (cpHashSetTransFunc)postStepFuncSetTrans); -} - -void * -cpSpaceGetPostStepData(cpSpace *space, void *obj) -{ - if(space->postStepCallbacks){ - cpPostStepCallback query = {NULL, obj, NULL}; - cpPostStepCallback *callback = (cpPostStepCallback *)cpHashSetFind(space->postStepCallbacks, (cpHashValue)obj, &query); - return (callback ? callback->data : NULL); - } else { - return NULL; - } -} - -static void -cpSpacePostStepCallbackSetIter(cpPostStepCallback *callback, cpSpace *space) -{ - callback->func(space, callback->obj, callback->data); - cpfree(callback); -} - -static void -cpSpaceRunPostStepCallbacks(cpSpace *space) -{ - // Loop because post step callbacks may add more post step callbacks directly or indirectly. - while(space->postStepCallbacks){ - cpHashSet *callbacks = space->postStepCallbacks; - space->postStepCallbacks = NULL; - - cpHashSetEach(callbacks, (cpHashSetIteratorFunc)cpSpacePostStepCallbackSetIter, space); - cpHashSetFree(callbacks); - } + cpAssertWarn(space->locked, + "Adding a post-step callback when the space is not locked is unnecessary. " + "Post-step callbacks will not called until the end of the next call to cpSpaceStep() or the next query."); + + if(!cpSpaceGetPostStepData(space, key)){ + cpPostStepCallback *callback = (cpPostStepCallback *)cpcalloc(1, sizeof(cpPostStepCallback)); + callback->func = func; + callback->key = key; + callback->data = data; + + cpArrayPush(space->postStepCallbacks, callback); + } } //MARK: Locking Functions @@ -99,103 +63,119 @@ cpSpaceRunPostStepCallbacks(cpSpace *space) void cpSpaceLock(cpSpace *space) { - space->locked++; + space->locked++; } void cpSpaceUnlock(cpSpace *space, cpBool runPostStep) { - space->locked--; - cpAssertHard(space->locked >= 0, "Internal Error: Space lock underflow."); - - if(!space->locked && runPostStep){ - cpArray *waking = space->rousedBodies; - for(int i=0, count=waking->num; iarr[i]); - } - - waking->num = 0; - - cpSpaceRunPostStepCallbacks(space); - } + space->locked--; + cpAssertHard(space->locked >= 0, "Internal Error: Space lock underflow."); + + if(space->locked == 0 && runPostStep && !space->skipPostStep){ + space->skipPostStep = cpTrue; + + cpArray *waking = space->rousedBodies; + for(int i=0, count=waking->num; iarr[i]); + waking->arr[i] = NULL; + } + + cpArray *arr = space->postStepCallbacks; + for(int i=0; inum; i++){ + cpPostStepCallback *callback = (cpPostStepCallback *)arr->arr[i]; + cpPostStepFunc func = callback->func; + + // Mark the func as NULL in case calling it calls cpSpaceRunPostStepCallbacks() again. + callback->func = NULL; + if(func) func(space, callback->key, callback->data); + + arr->arr[i] = NULL; + cpfree(callback); + } + + waking->num = 0; + arr->num = 0; + space->skipPostStep = cpFalse; + } } //MARK: Contact Buffer Functions struct cpContactBufferHeader { - cpTimestamp stamp; - cpContactBufferHeader *next; - unsigned int numContacts; + cpTimestamp stamp; + cpContactBufferHeader *next; + unsigned int numContacts; }; #define CP_CONTACTS_BUFFER_SIZE ((CP_BUFFER_BYTES - sizeof(cpContactBufferHeader))/sizeof(cpContact)) typedef struct cpContactBuffer { - cpContactBufferHeader header; - cpContact contacts[CP_CONTACTS_BUFFER_SIZE]; + cpContactBufferHeader header; + cpContact contacts[CP_CONTACTS_BUFFER_SIZE]; } cpContactBuffer; static cpContactBufferHeader * cpSpaceAllocContactBuffer(cpSpace *space) { - cpContactBuffer *buffer = (cpContactBuffer *)cpcalloc(1, sizeof(cpContactBuffer)); - cpArrayPush(space->allocatedBuffers, buffer); - return (cpContactBufferHeader *)buffer; + cpContactBuffer *buffer = (cpContactBuffer *)cpcalloc(1, sizeof(cpContactBuffer)); + cpArrayPush(space->allocatedBuffers, buffer); + return (cpContactBufferHeader *)buffer; } static cpContactBufferHeader * cpContactBufferHeaderInit(cpContactBufferHeader *header, cpTimestamp stamp, cpContactBufferHeader *splice) { - header->stamp = stamp; - header->next = (splice ? splice->next : header); - header->numContacts = 0; - - return header; + header->stamp = stamp; + header->next = (splice ? splice->next : header); + header->numContacts = 0; + + return header; } void cpSpacePushFreshContactBuffer(cpSpace *space) { - cpTimestamp stamp = space->stamp; - - cpContactBufferHeader *head = space->contactBuffersHead; - - if(!head){ - // No buffers have been allocated, make one - space->contactBuffersHead = cpContactBufferHeaderInit(cpSpaceAllocContactBuffer(space), stamp, NULL); - } else if(stamp - head->next->stamp > space->collisionPersistence){ - // The tail buffer is available, rotate the ring - cpContactBufferHeader *tail = head->next; - space->contactBuffersHead = cpContactBufferHeaderInit(tail, stamp, tail); - } else { - // Allocate a new buffer and push it into the ring - cpContactBufferHeader *buffer = cpContactBufferHeaderInit(cpSpaceAllocContactBuffer(space), stamp, head); - space->contactBuffersHead = head->next = buffer; - } + cpTimestamp stamp = space->stamp; + + cpContactBufferHeader *head = space->contactBuffersHead; + + if(!head){ + // No buffers have been allocated, make one + space->contactBuffersHead = cpContactBufferHeaderInit(cpSpaceAllocContactBuffer(space), stamp, NULL); + } else if(stamp - head->next->stamp > space->collisionPersistence){ + // The tail buffer is available, rotate the ring + cpContactBufferHeader *tail = head->next; + space->contactBuffersHead = cpContactBufferHeaderInit(tail, stamp, tail); + } else { + // Allocate a new buffer and push it into the ring + cpContactBufferHeader *buffer = cpContactBufferHeaderInit(cpSpaceAllocContactBuffer(space), stamp, head); + space->contactBuffersHead = head->next = buffer; + } } cpContact * cpContactBufferGetArray(cpSpace *space) { - if(space->contactBuffersHead->numContacts + CP_MAX_CONTACTS_PER_ARBITER > CP_CONTACTS_BUFFER_SIZE){ - // contact buffer could overflow on the next collision, push a fresh one. - cpSpacePushFreshContactBuffer(space); - } - - cpContactBufferHeader *head = space->contactBuffersHead; - return ((cpContactBuffer *)head)->contacts + head->numContacts; + if(space->contactBuffersHead->numContacts + CP_MAX_CONTACTS_PER_ARBITER > CP_CONTACTS_BUFFER_SIZE){ + // contact buffer could overflow on the next collision, push a fresh one. + cpSpacePushFreshContactBuffer(space); + } + + cpContactBufferHeader *head = space->contactBuffersHead; + return ((cpContactBuffer *)head)->contacts + head->numContacts; } void cpSpacePushContacts(cpSpace *space, int count) { - cpAssertHard(count <= CP_MAX_CONTACTS_PER_ARBITER, "Internal Error: Contact buffer overflow!"); - space->contactBuffersHead->numContacts += count; + cpAssertHard(count <= CP_MAX_CONTACTS_PER_ARBITER, "Internal Error: Contact buffer overflow!"); + space->contactBuffersHead->numContacts += count; } static void cpSpacePopContacts(cpSpace *space, int count){ - space->contactBuffersHead->numContacts -= count; + space->contactBuffersHead->numContacts -= count; } //MARK: Collision Detection Functions @@ -203,129 +183,131 @@ cpSpacePopContacts(cpSpace *space, int count){ static void * cpSpaceArbiterSetTrans(cpShape **shapes, cpSpace *space) { - if(space->pooledArbiters->num == 0){ - // arbiter pool is exhausted, make more - int count = CP_BUFFER_BYTES/sizeof(cpArbiter); - cpAssertHard(count, "Internal Error: Buffer size too small."); - - cpArbiter *buffer = (cpArbiter *)cpcalloc(1, CP_BUFFER_BYTES); - cpArrayPush(space->allocatedBuffers, buffer); - - for(int i=0; ipooledArbiters, buffer + i); - } - - return cpArbiterInit((cpArbiter *)cpArrayPop(space->pooledArbiters), shapes[0], shapes[1]); + if(space->pooledArbiters->num == 0){ + // arbiter pool is exhausted, make more + int count = CP_BUFFER_BYTES/sizeof(cpArbiter); + cpAssertHard(count, "Internal Error: Buffer size too small."); + + cpArbiter *buffer = (cpArbiter *)cpcalloc(1, CP_BUFFER_BYTES); + cpArrayPush(space->allocatedBuffers, buffer); + + for(int i=0; ipooledArbiters, buffer + i); + } + + return cpArbiterInit((cpArbiter *)cpArrayPop(space->pooledArbiters), shapes[0], shapes[1]); } static inline cpBool queryReject(cpShape *a, cpShape *b) { - return ( - // BBoxes must overlap - !cpBBIntersects(a->bb, b->bb) - // Don't collide shapes attached to the same body. - || a->body == b->body - // Don't collide objects in the same non-zero group - || (a->group && a->group == b->group) - // Don't collide objects that don't share at least on layer. - || !(a->layers & b->layers) - ); + return ( + // BBoxes must overlap + !cpBBIntersects(a->bb, b->bb) + // Don't collide shapes attached to the same body. + || a->body == b->body + // Don't collide objects in the same non-zero group + || (a->group && a->group == b->group) + // Don't collide objects that don't share at least on layer. + || !(a->layers & b->layers) + // Don't collide infinite mass objects + || (a->body->m == INFINITY && b->body->m == INFINITY) + ); } // Callback from the spatial hash. void cpSpaceCollideShapes(cpShape *a, cpShape *b, cpSpace *space) { - // Reject any of the simple cases - if(queryReject(a,b)) return; - - cpCollisionHandler *handler = cpSpaceLookupHandler(space, a->collision_type, b->collision_type); - - cpBool sensor = a->sensor || b->sensor; - if(sensor && handler == &cpDefaultCollisionHandler) return; - - // Shape 'a' should have the lower shape type. (required by cpCollideShapes() ) - if(a->klass->type > b->klass->type){ - cpShape *temp = a; - a = b; - b = temp; - } - - // Narrow-phase collision detection. - cpContact *contacts = cpContactBufferGetArray(space); - int numContacts = cpCollideShapes(a, b, contacts); - if(!numContacts) return; // Shapes are not colliding. - cpSpacePushContacts(space, numContacts); - - // Get an arbiter from space->arbiterSet for the two shapes. - // This is where the persistant contact magic comes from. - cpShape *shape_pair[] = {a, b}; - cpHashValue arbHashID = CP_HASH_PAIR((cpHashValue)a, (cpHashValue)b); - cpArbiter *arb = (cpArbiter *)cpHashSetInsert(space->cachedArbiters, arbHashID, shape_pair, space, (cpHashSetTransFunc)cpSpaceArbiterSetTrans); - cpArbiterUpdate(arb, contacts, numContacts, handler, a, b); - - // Call the begin function first if it's the first step - if(arb->state == cpArbiterStateFirstColl && !handler->begin(arb, space, handler->data)){ - cpArbiterIgnore(arb); // permanently ignore the collision until separation - } - - if( - // Ignore the arbiter if it has been flagged - (arb->state != cpArbiterStateIgnore) && - // Call preSolve - handler->preSolve(arb, space, handler->data) && - // Process, but don't add collisions for sensors. - !sensor - ){ - cpArrayPush(space->arbiters, arb); - } else { - cpSpacePopContacts(space, numContacts); - - arb->contacts = NULL; - arb->numContacts = 0; - - // Normally arbiters are set as used after calling the post-solve callback. - // However, post-solve callbacks are not called for sensors or arbiters rejected from pre-solve. - if(arb->state != cpArbiterStateIgnore) arb->state = cpArbiterStateNormal; - } - - // Time stamp the arbiter so we know it was used recently. - arb->stamp = space->stamp; + // Reject any of the simple cases + if(queryReject(a,b)) return; + + cpCollisionHandler *handler = cpSpaceLookupHandler(space, a->collision_type, b->collision_type); + + cpBool sensor = a->sensor || b->sensor; + if(sensor && handler == &cpDefaultCollisionHandler) return; + + // Shape 'a' should have the lower shape type. (required by cpCollideShapes() ) + if(a->klass->type > b->klass->type){ + cpShape *temp = a; + a = b; + b = temp; + } + + // Narrow-phase collision detection. + cpContact *contacts = cpContactBufferGetArray(space); + int numContacts = cpCollideShapes(a, b, contacts); + if(!numContacts) return; // Shapes are not colliding. + cpSpacePushContacts(space, numContacts); + + // Get an arbiter from space->arbiterSet for the two shapes. + // This is where the persistant contact magic comes from. + cpShape *shape_pair[] = {a, b}; + cpHashValue arbHashID = CP_HASH_PAIR((cpHashValue)a, (cpHashValue)b); + cpArbiter *arb = (cpArbiter *)cpHashSetInsert(space->cachedArbiters, arbHashID, shape_pair, space, (cpHashSetTransFunc)cpSpaceArbiterSetTrans); + cpArbiterUpdate(arb, contacts, numContacts, handler, a, b); + + // Call the begin function first if it's the first step + if(arb->state == cpArbiterStateFirstColl && !handler->begin(arb, space, handler->data)){ + cpArbiterIgnore(arb); // permanently ignore the collision until separation + } + + if( + // Ignore the arbiter if it has been flagged + (arb->state != cpArbiterStateIgnore) && + // Call preSolve + handler->preSolve(arb, space, handler->data) && + // Process, but don't add collisions for sensors. + !sensor + ){ + cpArrayPush(space->arbiters, arb); + } else { + cpSpacePopContacts(space, numContacts); + + arb->contacts = NULL; + arb->numContacts = 0; + + // Normally arbiters are set as used after calling the post-solve callback. + // However, post-solve callbacks are not called for sensors or arbiters rejected from pre-solve. + if(arb->state != cpArbiterStateIgnore) arb->state = cpArbiterStateNormal; + } + + // Time stamp the arbiter so we know it was used recently. + arb->stamp = space->stamp; } // Hashset filter func to throw away old arbiters. cpBool cpSpaceArbiterSetFilter(cpArbiter *arb, cpSpace *space) { - cpTimestamp ticks = space->stamp - arb->stamp; - - cpBody *a = arb->body_a, *b = arb->body_b; - - // TODO should make an arbiter state for this so it doesn't require filtering arbiters for dangling body pointers on body removal. - // Preserve arbiters on sensors and rejected arbiters for sleeping objects. - // This prevents errant separate callbacks from happenening. - if( - (cpBodyIsStatic(a) || cpBodyIsSleeping(a)) && - (cpBodyIsStatic(b) || cpBodyIsSleeping(b)) - ){ - return cpTrue; - } - - // Arbiter was used last frame, but not this one - if(ticks >= 1 && arb->state != cpArbiterStateCached){ - cpArbiterCallSeparate(arb, space); - arb->state = cpArbiterStateCached; - } - - if(ticks >= space->collisionPersistence){ - arb->contacts = NULL; - arb->numContacts = 0; - - cpArrayPush(space->pooledArbiters, arb); - return cpFalse; - } - - return cpTrue; + cpTimestamp ticks = space->stamp - arb->stamp; + + cpBody *a = arb->body_a, *b = arb->body_b; + + // TODO should make an arbiter state for this so it doesn't require filtering arbiters for dangling body pointers on body removal. + // Preserve arbiters on sensors and rejected arbiters for sleeping objects. + // This prevents errant separate callbacks from happenening. + if( + (cpBodyIsStatic(a) || cpBodyIsSleeping(a)) && + (cpBodyIsStatic(b) || cpBodyIsSleeping(b)) + ){ + return cpTrue; + } + + // Arbiter was used last frame, but not this one + if(ticks >= 1 && arb->state != cpArbiterStateCached){ + arb->state = cpArbiterStateCached; + cpArbiterCallSeparate(arb, space); + } + + if(ticks >= space->collisionPersistence){ + arb->contacts = NULL; + arb->numContacts = 0; + + cpArrayPush(space->pooledArbiters, arb); + return cpFalse; + } + + return cpTrue; } //MARK: All Important cpSpaceStep() Function @@ -333,121 +315,118 @@ cpSpaceArbiterSetFilter(cpArbiter *arb, cpSpace *space) void cpShapeUpdateFunc(cpShape *shape, void *unused) { - cpBody *body = shape->body; - cpShapeUpdate(shape, body->p, body->rot); + cpBody *body = shape->body; + cpShapeUpdate(shape, body->p, body->rot); } void cpSpaceStep(cpSpace *space, cpFloat dt) { - // don't step if the timestep is 0! - if(dt == 0.0f) return; - - space->stamp++; - - cpFloat prev_dt = space->curr_dt; - space->curr_dt = dt; - - cpArray *bodies = space->bodies; - cpArray *constraints = space->constraints; - cpArray *arbiters = space->arbiters; - - // Reset and empty the arbiter list. - for(int i=0; inum; i++){ - cpArbiter *arb = (cpArbiter *)arbiters->arr[i]; - arb->state = cpArbiterStateNormal; - - // If both bodies are awake, unthread the arbiter from the contact graph. - if(!cpBodyIsSleeping(arb->body_a) && !cpBodyIsSleeping(arb->body_b)){ - cpArbiterUnthread(arb); - } - } - arbiters->num = 0; + // don't step if the timestep is 0! + if(dt == 0.0f) return; + + space->stamp++; + + cpFloat prev_dt = space->curr_dt; + space->curr_dt = dt; + + cpArray *bodies = space->bodies; + cpArray *constraints = space->constraints; + cpArray *arbiters = space->arbiters; + + // Reset and empty the arbiter lists. + for(int i=0; inum; i++){ + cpArbiter *arb = (cpArbiter *)arbiters->arr[i]; + arb->state = cpArbiterStateNormal; + + // If both bodies are awake, unthread the arbiter from the contact graph. + if(!cpBodyIsSleeping(arb->body_a) && !cpBodyIsSleeping(arb->body_b)){ + cpArbiterUnthread(arb); + } + } + arbiters->num = 0; - cpSpaceLock(space); { - // Integrate positions - for(int i=0; inum; i++){ - cpBody *body = (cpBody *)bodies->arr[i]; - body->position_func(body, dt); - } - - // Find colliding pairs. - cpSpacePushFreshContactBuffer(space); - cpSpatialIndexEach(space->activeShapes, (cpSpatialIndexIteratorFunc)cpShapeUpdateFunc, NULL); - cpSpatialIndexReindexQuery(space->activeShapes, (cpSpatialIndexQueryFunc)cpSpaceCollideShapes, space); - } cpSpaceUnlock(space, cpFalse); - - // If body sleeping is enabled, do that now. - if(space->sleepTimeThreshold != INFINITY || space->enableContactGraph){ - cpSpaceProcessComponents(space, dt); - } - - cpSpaceLock(space); { - // Clear out old cached arbiters and call separate callbacks - cpHashSetFilter(space->cachedArbiters, (cpHashSetFilterFunc)cpSpaceArbiterSetFilter, space); + cpSpaceLock(space); { + // Integrate positions + for(int i=0; inum; i++){ + cpBody *body = (cpBody *)bodies->arr[i]; + body->position_func(body, dt); + } + + // Find colliding pairs. + cpSpacePushFreshContactBuffer(space); + cpSpatialIndexEach(space->activeShapes, (cpSpatialIndexIteratorFunc)cpShapeUpdateFunc, NULL); + cpSpatialIndexReindexQuery(space->activeShapes, (cpSpatialIndexQueryFunc)cpSpaceCollideShapes, space); + } cpSpaceUnlock(space, cpFalse); + + // Rebuild the contact graph (and detect sleeping components if sleeping is enabled) + cpSpaceProcessComponents(space, dt); + + cpSpaceLock(space); { + // Clear out old cached arbiters and call separate callbacks + cpHashSetFilter(space->cachedArbiters, (cpHashSetFilterFunc)cpSpaceArbiterSetFilter, space); - // Prestep the arbiters and constraints. - cpFloat slop = space->collisionSlop; - cpFloat biasCoef = 1.0f - cpfpow(space->collisionBias, dt); - for(int i=0; inum; i++){ - cpArbiterPreStep((cpArbiter *)arbiters->arr[i], dt, slop, biasCoef); - } + // Prestep the arbiters and constraints. + cpFloat slop = space->collisionSlop; + cpFloat biasCoef = 1.0f - cpfpow(space->collisionBias, dt); + for(int i=0; inum; i++){ + cpArbiterPreStep((cpArbiter *)arbiters->arr[i], dt, slop, biasCoef); + } - for(int i=0; inum; i++){ - cpConstraint *constraint = (cpConstraint *)constraints->arr[i]; - - cpConstraintPreSolveFunc preSolve = constraint->preSolve; - if(preSolve) preSolve(constraint, space); - - constraint->klass->preStep(constraint, dt); - } - - // Integrate velocities. - cpFloat damping = cpfpow(space->damping, dt); - cpVect gravity = space->gravity; - for(int i=0; inum; i++){ - cpBody *body = (cpBody *)bodies->arr[i]; - body->velocity_func(body, gravity, damping, dt); - } - - // Apply cached impulses - cpFloat dt_coef = (prev_dt == 0.0f ? 0.0f : dt/prev_dt); - for(int i=0; inum; i++){ - cpArbiterApplyCachedImpulse((cpArbiter *)arbiters->arr[i], dt_coef); - } - - for(int i=0; inum; i++){ - cpConstraint *constraint = (cpConstraint *)constraints->arr[i]; - constraint->klass->applyCachedImpulse(constraint, dt_coef); - } - - // Run the impulse solver. - cpSpaceArbiterApplyImpulseFunc applyImpulse = space->arbiterApplyImpulse; - for(int i=0; iiterations; i++){ - for(int j=0; jnum; j++){ - applyImpulse((cpArbiter *)arbiters->arr[j]); - } - - for(int j=0; jnum; j++){ - cpConstraint *constraint = (cpConstraint *)constraints->arr[j]; - constraint->klass->applyImpulse(constraint); - } - } - - // Run the constraint post-solve callbacks - for(int i=0; inum; i++){ - cpConstraint *constraint = (cpConstraint *)constraints->arr[i]; - - cpConstraintPostSolveFunc postSolve = constraint->postSolve; - if(postSolve) postSolve(constraint, space); - } - - // run the post-solve callbacks - for(int i=0; inum; i++){ - cpArbiter *arb = (cpArbiter *) arbiters->arr[i]; - - cpCollisionHandler *handler = arb->handler; - handler->postSolve(arb, space, handler->data); - } - } cpSpaceUnlock(space, cpTrue); + for(int i=0; inum; i++){ + cpConstraint *constraint = (cpConstraint *)constraints->arr[i]; + + cpConstraintPreSolveFunc preSolve = constraint->preSolve; + if(preSolve) preSolve(constraint, space); + + constraint->klass->preStep(constraint, dt); + } + + // Integrate velocities. + cpFloat damping = cpfpow(space->damping, dt); + cpVect gravity = space->gravity; + for(int i=0; inum; i++){ + cpBody *body = (cpBody *)bodies->arr[i]; + body->velocity_func(body, gravity, damping, dt); + } + + // Apply cached impulses + cpFloat dt_coef = (prev_dt == 0.0f ? 0.0f : dt/prev_dt); + for(int i=0; inum; i++){ + cpArbiterApplyCachedImpulse((cpArbiter *)arbiters->arr[i], dt_coef); + } + + for(int i=0; inum; i++){ + cpConstraint *constraint = (cpConstraint *)constraints->arr[i]; + constraint->klass->applyCachedImpulse(constraint, dt_coef); + } + + // Run the impulse solver. + for(int i=0; iiterations; i++){ + for(int j=0; jnum; j++){ + cpArbiterApplyImpulse((cpArbiter *)arbiters->arr[j]); + } + + for(int j=0; jnum; j++){ + cpConstraint *constraint = (cpConstraint *)constraints->arr[j]; + constraint->klass->applyImpulse(constraint); + } + } + + // Run the constraint post-solve callbacks + for(int i=0; inum; i++){ + cpConstraint *constraint = (cpConstraint *)constraints->arr[i]; + + cpConstraintPostSolveFunc postSolve = constraint->postSolve; + if(postSolve) postSolve(constraint, space); + } + + // run the post-solve callbacks + for(int i=0; inum; i++){ + cpArbiter *arb = (cpArbiter *) arbiters->arr[i]; + + cpCollisionHandler *handler = arb->handler; + handler->postSolve(arb, space, handler->data); + } + } cpSpaceUnlock(space, cpTrue); } diff --git a/chipmunk/src/cpSpatialIndex.c b/chipmunk/src/cpSpatialIndex.c index 62ea505f80..f383bdee87 100644 --- a/chipmunk/src/cpSpatialIndex.c +++ b/chipmunk/src/cpSpatialIndex.c @@ -1,50 +1,69 @@ -#include +/* Copyright (c) 2010 Scott Lembcke + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ #include "chipmunk_private.h" void cpSpatialIndexFree(cpSpatialIndex *index) { - if(index){ - cpSpatialIndexDestroy(index); - cpfree(index); - } + if(index){ + cpSpatialIndexDestroy(index); + cpfree(index); + } } cpSpatialIndex * cpSpatialIndexInit(cpSpatialIndex *index, cpSpatialIndexClass *klass, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex) { - index->klass = klass; - index->bbfunc = bbfunc; - index->staticIndex = staticIndex; - - if(staticIndex){ - cpAssertHard(!staticIndex->dynamicIndex, "This static index is already associated with a dynamic index."); - staticIndex->dynamicIndex = index; - } - - return index; + index->klass = klass; + index->bbfunc = bbfunc; + index->staticIndex = staticIndex; + + if(staticIndex){ + cpAssertHard(!staticIndex->dynamicIndex, "This static index is already associated with a dynamic index."); + staticIndex->dynamicIndex = index; + } + + return index; } typedef struct dynamicToStaticContext { - cpSpatialIndexBBFunc bbfunc; - cpSpatialIndex *staticIndex; - cpSpatialIndexQueryFunc queryFunc; - void *data; + cpSpatialIndexBBFunc bbfunc; + cpSpatialIndex *staticIndex; + cpSpatialIndexQueryFunc queryFunc; + void *data; } dynamicToStaticContext; static void dynamicToStaticIter(void *obj, dynamicToStaticContext *context) { - cpSpatialIndexQuery(context->staticIndex, obj, context->bbfunc(obj), context->queryFunc, context->data); + cpSpatialIndexQuery(context->staticIndex, obj, context->bbfunc(obj), context->queryFunc, context->data); } void cpSpatialIndexCollideStatic(cpSpatialIndex *dynamicIndex, cpSpatialIndex *staticIndex, cpSpatialIndexQueryFunc func, void *data) { - if(cpSpatialIndexCount(staticIndex) > 0){ - dynamicToStaticContext context = {dynamicIndex->bbfunc, staticIndex, func, data}; - cpSpatialIndexEach(dynamicIndex, (cpSpatialIndexIteratorFunc)dynamicToStaticIter, &context); - } + if(cpSpatialIndexCount(staticIndex) > 0){ + dynamicToStaticContext context = {dynamicIndex->bbfunc, staticIndex, func, data}; + cpSpatialIndexEach(dynamicIndex, (cpSpatialIndexIteratorFunc)dynamicToStaticIter, &context); + } } diff --git a/chipmunk/src/cpSweep1D.c b/chipmunk/src/cpSweep1D.c index 2bb54e3b45..f617bce021 100644 --- a/chipmunk/src/cpSweep1D.c +++ b/chipmunk/src/cpSweep1D.c @@ -19,9 +19,6 @@ * SOFTWARE. */ -#include -#include - #include "chipmunk_private.h" static inline cpSpatialIndexClass *Klass(); @@ -29,41 +26,41 @@ static inline cpSpatialIndexClass *Klass(); //MARK: Basic Structures typedef struct Bounds { - cpFloat min, max; + cpFloat min, max; } Bounds; typedef struct TableCell { - void *obj; - Bounds bounds; + void *obj; + Bounds bounds; } TableCell; struct cpSweep1D { - cpSpatialIndex spatialIndex; - - int num; - int max; - TableCell *table; + cpSpatialIndex spatialIndex; + + int num; + int max; + TableCell *table; }; static inline cpBool BoundsOverlap(Bounds a, Bounds b) { - return (a.min <= b.max && b.min <= a.max); + return (a.min <= b.max && b.min <= a.max); } static inline Bounds BBToBounds(cpSweep1D *sweep, cpBB bb) { - Bounds bounds = {bb.l, bb.r}; - return bounds; + Bounds bounds = {bb.l, bb.r}; + return bounds; } static inline TableCell MakeTableCell(cpSweep1D *sweep, void *obj) { - TableCell cell = {obj, BBToBounds(sweep, sweep->spatialIndex.bbfunc(obj))}; - return cell; + TableCell cell = {obj, BBToBounds(sweep, sweep->spatialIndex.bbfunc(obj))}; + return cell; } //MARK: Memory Management Functions @@ -71,38 +68,38 @@ MakeTableCell(cpSweep1D *sweep, void *obj) cpSweep1D * cpSweep1DAlloc(void) { - return (cpSweep1D *)cpcalloc(1, sizeof(cpSweep1D)); + return (cpSweep1D *)cpcalloc(1, sizeof(cpSweep1D)); } static void ResizeTable(cpSweep1D *sweep, int size) { - sweep->max = size; - sweep->table = (TableCell *)cprealloc(sweep->table, size*sizeof(TableCell)); + sweep->max = size; + sweep->table = (TableCell *)cprealloc(sweep->table, size*sizeof(TableCell)); } cpSpatialIndex * cpSweep1DInit(cpSweep1D *sweep, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex) { - cpSpatialIndexInit((cpSpatialIndex *)sweep, Klass(), bbfunc, staticIndex); - - sweep->num = 0; - ResizeTable(sweep, 32); - - return (cpSpatialIndex *)sweep; + cpSpatialIndexInit((cpSpatialIndex *)sweep, Klass(), bbfunc, staticIndex); + + sweep->num = 0; + ResizeTable(sweep, 32); + + return (cpSpatialIndex *)sweep; } cpSpatialIndex * cpSweep1DNew(cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex) { - return cpSweep1DInit(cpSweep1DAlloc(), bbfunc, staticIndex); + return cpSweep1DInit(cpSweep1DAlloc(), bbfunc, staticIndex); } static void cpSweep1DDestroy(cpSweep1D *sweep) { - cpfree(sweep->table); - sweep->table = NULL; + cpfree(sweep->table); + sweep->table = NULL; } //MARK: Misc @@ -110,25 +107,25 @@ cpSweep1DDestroy(cpSweep1D *sweep) static int cpSweep1DCount(cpSweep1D *sweep) { - return sweep->num; + return sweep->num; } static void cpSweep1DEach(cpSweep1D *sweep, cpSpatialIndexIteratorFunc func, void *data) { - TableCell *table = sweep->table; - for(int i=0, count=sweep->num; itable; + for(int i=0, count=sweep->num; itable; - for(int i=0, count=sweep->num; itable; + for(int i=0, count=sweep->num; inum == sweep->max) ResizeTable(sweep, sweep->max*2); - - sweep->table[sweep->num] = MakeTableCell(sweep, obj); - sweep->num++; + if(sweep->num == sweep->max) ResizeTable(sweep, sweep->max*2); + + sweep->table[sweep->num] = MakeTableCell(sweep, obj); + sweep->num++; } static void cpSweep1DRemove(cpSweep1D *sweep, void *obj, cpHashValue hashid) { - TableCell *table = sweep->table; - for(int i=0, count=sweep->num; inum; - - table[i] = table[num]; - table[num].obj = NULL; - - return; - } - } + TableCell *table = sweep->table; + for(int i=0, count=sweep->num; inum; + + table[i] = table[num]; + table[num].obj = NULL; + + return; + } + } } //MARK: Reindexing Functions @@ -163,14 +160,14 @@ cpSweep1DRemove(cpSweep1D *sweep, void *obj, cpHashValue hashid) static void cpSweep1DReindexObject(cpSweep1D *sweep, void *obj, cpHashValue hashid) { - // Nothing to do here + // Nothing to do here } static void cpSweep1DReindex(cpSweep1D *sweep) { - // Nothing to do here - // Could perform a sort, but queries are not accelerated anyway. + // Nothing to do here + // Could perform a sort, but queries are not accelerated anyway. } //MARK: Query Functions @@ -178,35 +175,29 @@ cpSweep1DReindex(cpSweep1D *sweep) static void cpSweep1DQuery(cpSweep1D *sweep, void *obj, cpBB bb, cpSpatialIndexQueryFunc func, void *data) { - // Implementing binary search here would allow you to find an upper limit - // but not a lower limit. Probably not worth the hassle. - - Bounds bounds = BBToBounds(sweep, bb); - - TableCell *table = sweep->table; - for(int i=0, count=sweep->num; itable; + for(int i=0, count=sweep->num; itable; - for(int i=0, count=sweep->num; itable; + for(int i=0, count=sweep->num; ibounds.min < b->bounds.min ? -1 : (a->bounds.min > b->bounds.min ? 1 : 0)); + return (a->bounds.min < b->bounds.min ? -1 : (a->bounds.min > b->bounds.min ? 1 : 0)); } static void cpSweep1DReindexQuery(cpSweep1D *sweep, cpSpatialIndexQueryFunc func, void *data) { - TableCell *table = sweep->table; - int count = sweep->num; - - // Update bounds and sort - for(int i=0; ispatialIndex.staticIndex, func, data); + TableCell *table = sweep->table; + int count = sweep->num; + + // Update bounds and sort + for(int i=0; ispatialIndex.staticIndex, func, data); } static cpSpatialIndexClass klass = { - (cpSpatialIndexDestroyImpl)cpSweep1DDestroy, - - (cpSpatialIndexCountImpl)cpSweep1DCount, - (cpSpatialIndexEachImpl)cpSweep1DEach, - (cpSpatialIndexContainsImpl)cpSweep1DContains, - - (cpSpatialIndexInsertImpl)cpSweep1DInsert, - (cpSpatialIndexRemoveImpl)cpSweep1DRemove, - - (cpSpatialIndexReindexImpl)cpSweep1DReindex, - (cpSpatialIndexReindexObjectImpl)cpSweep1DReindexObject, - (cpSpatialIndexReindexQueryImpl)cpSweep1DReindexQuery, - - (cpSpatialIndexPointQueryImpl)cpSweep1DPointQuery, - (cpSpatialIndexSegmentQueryImpl)cpSweep1DSegmentQuery, - (cpSpatialIndexQueryImpl)cpSweep1DQuery, + (cpSpatialIndexDestroyImpl)cpSweep1DDestroy, + + (cpSpatialIndexCountImpl)cpSweep1DCount, + (cpSpatialIndexEachImpl)cpSweep1DEach, + (cpSpatialIndexContainsImpl)cpSweep1DContains, + + (cpSpatialIndexInsertImpl)cpSweep1DInsert, + (cpSpatialIndexRemoveImpl)cpSweep1DRemove, + + (cpSpatialIndexReindexImpl)cpSweep1DReindex, + (cpSpatialIndexReindexObjectImpl)cpSweep1DReindexObject, + (cpSpatialIndexReindexQueryImpl)cpSweep1DReindexQuery, + + (cpSpatialIndexQueryImpl)cpSweep1DQuery, + (cpSpatialIndexSegmentQueryImpl)cpSweep1DSegmentQuery, }; static inline cpSpatialIndexClass *Klass(){return &klass;} diff --git a/chipmunk/src/cpVect.c b/chipmunk/src/cpVect.c index fb160c249d..778ffbd779 100644 --- a/chipmunk/src/cpVect.c +++ b/chipmunk/src/cpVect.c @@ -20,52 +20,51 @@ */ #include -#include #include "chipmunk_private.h" cpFloat cpvlength(const cpVect v) { - return cpfsqrt(cpvdot(v, v)); + return cpfsqrt(cpvdot(v, v)); } inline cpVect cpvslerp(const cpVect v1, const cpVect v2, const cpFloat t) { - cpFloat omega = cpfacos(cpvdot(v1, v2)); - - if(omega){ - cpFloat denom = 1.0f/cpfsin(omega); - return cpvadd(cpvmult(v1, cpfsin((1.0f - t)*omega)*denom), cpvmult(v2, cpfsin(t*omega)*denom)); - } else { - return v1; - } + cpFloat omega = cpfacos(cpvdot(v1, v2)); + + if(omega){ + cpFloat denom = 1.0f/cpfsin(omega); + return cpvadd(cpvmult(v1, cpfsin((1.0f - t)*omega)*denom), cpvmult(v2, cpfsin(t*omega)*denom)); + } else { + return v1; + } } cpVect cpvslerpconst(const cpVect v1, const cpVect v2, const cpFloat a) { - cpFloat angle = cpfacos(cpvdot(v1, v2)); - return cpvslerp(v1, v2, cpfmin(a, angle)/angle); + cpFloat angle = cpfacos(cpvdot(v1, v2)); + return cpvslerp(v1, v2, cpfmin(a, angle)/angle); } cpVect cpvforangle(const cpFloat a) { - return cpv(cpfcos(a), cpfsin(a)); + return cpv(cpfcos(a), cpfsin(a)); } cpFloat cpvtoangle(const cpVect v) { - return cpfatan2(v.y, v.x); + return cpfatan2(v.y, v.x); } char* cpvstr(const cpVect v) { - static char str[256]; - sprintf(str, "(% .3f, % .3f)", v.x, v.y); - return str; + static char str[256]; + sprintf(str, "(% .3f, % .3f)", v.x, v.y); + return str; } diff --git a/chipmunk/src/prime.h b/chipmunk/src/prime.h index d2dc4ff7c2..419bdb89d6 100644 --- a/chipmunk/src/prime.h +++ b/chipmunk/src/prime.h @@ -23,46 +23,46 @@ // Values approximately double. // http://planetmath.org/encyclopedia/GoodHashTablePrimes.html static int primes[] = { - 5, - 13, - 23, - 47, - 97, - 193, - 389, - 769, - 1543, - 3079, - 6151, - 12289, - 24593, - 49157, - 98317, - 196613, - 393241, - 786433, - 1572869, - 3145739, - 6291469, - 12582917, - 25165843, - 50331653, - 100663319, - 201326611, - 402653189, - 805306457, - 1610612741, - 0, + 5, + 13, + 23, + 47, + 97, + 193, + 389, + 769, + 1543, + 3079, + 6151, + 12289, + 24593, + 49157, + 98317, + 196613, + 393241, + 786433, + 1572869, + 3145739, + 6291469, + 12582917, + 25165843, + 50331653, + 100663319, + 201326611, + 402653189, + 805306457, + 1610612741, + 0, }; static inline int next_prime(int n) { - int i = 0; - while(n > primes[i]){ - i++; - cpAssertHard(primes[i], "Tried to resize a hash table to a size greater than 1610612741 O_o"); // realistically this should never happen - } - - return primes[i]; + int i = 0; + while(n > primes[i]){ + i++; + cpAssertHard(primes[i], "Tried to resize a hash table to a size greater than 1610612741 O_o"); // realistically this should never happen + } + + return primes[i]; } From 9c58f13abb705623d7f6aef526d7399e7b630809 Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 12 Jun 2012 09:43:27 +0800 Subject: [PATCH 125/257] set font size when changed --- cocos2dx/label_nodes/CCLabelTTF.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cocos2dx/label_nodes/CCLabelTTF.cpp b/cocos2dx/label_nodes/CCLabelTTF.cpp index 2e48263ec0..372331ad86 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.cpp +++ b/cocos2dx/label_nodes/CCLabelTTF.cpp @@ -198,7 +198,9 @@ float CCLabelTTF::getFontSize() void CCLabelTTF::setFontSize(float fontSize) { if (m_fFontSize != fontSize) - { + { + m_fFontSize = fontSize; + // Force update if (m_string.size() > 0) { From 974f0d714d29e594dcd2d5910dfd877f4c9902d3 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Jun 2012 11:16:31 +0800 Subject: [PATCH 126/257] issue #1310: Updated FontTest. And fixed a compilation error in FontTest. --- tests/tests/ActionsTest/ActionsTest.cpp | 2 +- tests/tests/FontTest/FontTest.cpp | 90 ++++++++++++++++++------- 2 files changed, 67 insertions(+), 25 deletions(-) diff --git a/tests/tests/ActionsTest/ActionsTest.cpp b/tests/tests/ActionsTest/ActionsTest.cpp index 1719327645..a821055ba1 100644 --- a/tests/tests/ActionsTest/ActionsTest.cpp +++ b/tests/tests/ActionsTest/ActionsTest.cpp @@ -1656,7 +1656,7 @@ void PauseResumeActions::pause(float dt) { CCLog("Pausing"); CCDirector *director = CCDirector::sharedDirector(); - this->m_pPausedTargets = director->getActionManager()->pauseAlllRunningActions(); + this->m_pPausedTargets = director->getActionManager()->pauseAllRunningActions(); } void PauseResumeActions::resume(float dt) diff --git a/tests/tests/FontTest/FontTest.cpp b/tests/tests/FontTest/FontTest.cpp index ef4ebe8989..b533e92264 100644 --- a/tests/tests/FontTest/FontTest.cpp +++ b/tests/tests/FontTest/FontTest.cpp @@ -24,19 +24,35 @@ static std::string fontList[] = "fonts/Scissor Cuts.ttf", }; +static int fontCount = sizeof(fontList) / sizeof(*fontList); + +static int vAlignIdx = 0; +static CCVerticalTextAlignment verticalAlignment[] = +{ + kCCVerticalTextAlignmentTop, + kCCVerticalTextAlignmentCenter, + kCCVerticalTextAlignmentBottom, +}; +static int vAlignCount = sizeof(verticalAlignment) / sizeof(*verticalAlignment); + static const char* nextAction(void) { fontIdx++; - fontIdx = fontIdx % (sizeof(fontList) / sizeof(fontList[0])); + if(fontIdx >= fontCount) { + fontIdx = 0; + vAlignIdx = (vAlignIdx + 1) % vAlignCount; + } return fontList[fontIdx].c_str(); } static const char* backAction(void) { fontIdx--; - if (fontIdx < 0) - { - fontIdx += (sizeof(fontList) / sizeof(fontList[0])); + if( fontIdx < 0 ) { + fontIdx = fontCount - 1; + vAlignIdx--; + if(vAlignIdx < 0) + vAlignIdx = vAlignCount - 1; } return fontList[fontIdx].c_str(); @@ -50,16 +66,16 @@ static const char* restartAction(void) FontTest::FontTest() { - CCSize size = CCDirector::sharedDirector()->getWinSize(); + CCSize s = CCDirector::sharedDirector()->getWinSize(); CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(FontTest::backCallback)); CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(FontTest::restartCallback)); CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(FontTest::nextCallback)); CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); menu->setPosition(CCPointZero); - item1->setPosition(ccp(size.width/2 - 100,30)); - item2->setPosition(ccp(size.width/2, 30)); - item3->setPosition(ccp(size.width/2 + 100,30)); + item1->setPosition(ccp( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2)); + item2->setPosition(ccp( s.width/2, item2->getContentSize().height/2)); + item3->setPosition(ccp( s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2)); addChild(menu, 1); showFont(restartAction()); @@ -67,27 +83,53 @@ FontTest::FontTest() void FontTest::showFont(const char *pFont) { + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCSize blockSize = CCSizeMake(s.width/3, 200); + CCFloat fontSize = 26; + removeChildByTag(kTagLabel1, true); removeChildByTag(kTagLabel2, true); removeChildByTag(kTagLabel3, true); removeChildByTag(kTagLabel4, true); - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - CCLabelTTF *top = CCLabelTTF::labelWithString(pFont, pFont, 24); - CCLabelTTF *left = CCLabelTTF::labelWithString("alignment left", CCSizeMake(s.width, 50), kCCTextAlignmentLeft, pFont, 32); - CCLabelTTF *center = CCLabelTTF::labelWithString("alignment center", CCSizeMake(s.width, 50), kCCTextAlignmentCenter, pFont, 32); - CCLabelTTF *right = CCLabelTTF::labelWithString("alignment right", CCSizeMake(s.width, 50), kCCTextAlignmentRight, pFont, 32); - - top->setPosition(ccp(s.width/2, 250)); - left->setPosition(ccp(s.width/2, 200)); - center->setPosition(ccp(s.width/2, 150)); - right->setPosition(ccp(s.width/2, 100)); - - addChild(left, 0, kTagLabel1); - addChild(right, 0, kTagLabel2); - addChild(center, 0, kTagLabel3); - addChild(top, 0, kTagLabel4); + CCLabelTTF *top = CCLabelTTF::labelWithString(pFont, pFont, 24); + CCLabelTTF *left = CCLabelTTF::labelWithString("alignment left", blockSize, kCCTextAlignmentLeft, verticalAlignment[vAlignIdx], pFont, fontSize); + CCLabelTTF *center = CCLabelTTF::labelWithString("alignment center", blockSize, kCCTextAlignmentCenter, verticalAlignment[vAlignIdx], pFont, fontSize); + CCLabelTTF *right = CCLabelTTF::labelWithString("alignment right", blockSize, kCCTextAlignmentRight, verticalAlignment[vAlignIdx], pFont, fontSize); + + CCLayerColor *leftColor = CCLayerColor::layerWithColor(ccc4(100, 100, 100, 255), blockSize.width, blockSize.height); + CCLayerColor *centerColor = CCLayerColor::layerWithColor(ccc4(200, 100, 100, 255), blockSize.width, blockSize.height); + CCLayerColor *rightColor = CCLayerColor::layerWithColor(ccc4(100, 100, 200, 255), blockSize.width, blockSize.height); + + leftColor->setIgnoreAnchorPointForPosition(false); + centerColor->setIgnoreAnchorPointForPosition(false); + rightColor->setIgnoreAnchorPointForPosition(false); + + + top->setAnchorPoint(ccp(0.5, 1)); + left->setAnchorPoint(ccp(0,0.5)); + leftColor->setAnchorPoint(ccp(0,0.5)); + center->setAnchorPoint(ccp(0,0.5)); + centerColor->setAnchorPoint(ccp(0,0.5)); + right->setAnchorPoint(ccp(0,0.5)); + rightColor->setAnchorPoint(ccp(0,0.5)); + + top->setPosition(ccp(s.width/2,s.height-20)); + left->setPosition(ccp(0,s.height/2)); + leftColor->setPosition(left->getPosition()); + center->setPosition(ccp(blockSize.width, s.height/2)); + centerColor->setPosition(center->getPosition()); + right->setPosition(ccp(blockSize.width*2, s.height/2)); + rightColor->setPosition(right->getPosition()); + + this->addChild(leftColor, -1); + this->addChild(left, 0, kTagLabel1); + this->addChild(rightColor, -1); + this->addChild(right, 0, kTagLabel2); + this->addChild(centerColor, -1); + this->addChild(center, 0, kTagLabel3); + this->addChild(top, 0, kTagLabel4); } void FontTest::backCallback(CCObject* pSender) From 916b276607d044d4c46f433e361bb854e0c062aa Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 12 Jun 2012 12:02:15 +0800 Subject: [PATCH 127/257] issue #1310: synchronize CCTexturePVR --- cocos2dx/textures/CCTexturePVR.cpp | 251 ++++++++++-------------- cocos2dx/textures/CCTexturePVR.h | 66 +++---- tests/tests/ActionsTest/ActionsTest.cpp | 2 +- 3 files changed, 133 insertions(+), 186 deletions(-) diff --git a/cocos2dx/textures/CCTexturePVR.cpp b/cocos2dx/textures/CCTexturePVR.cpp index c330117d4e..3bc8348808 100755 --- a/cocos2dx/textures/CCTexturePVR.cpp +++ b/cocos2dx/textures/CCTexturePVR.cpp @@ -39,29 +39,21 @@ THE SOFTWARE. NS_CC_BEGIN #define PVR_TEXTURE_FLAG_TYPE_MASK 0xff -#define PVR_TEXTURE_FLAG_FLIPPED_MASK 0x10000 // Values taken from PVRTexture.h from http://www.imgtec.com enum { - kPVRTextureFlagMipmap = (1<<8), // has mip map levels + kPVRTextureFlagMipmap = (1<<8), // has mip map levels kPVRTextureFlagTwiddle = (1<<9), // is twiddled - kPVRTextureFlagBumpmap = (1<<10), // has normals encoded for a bump map - kPVRTextureFlagTiling = (1<<11), // is bordered for tiled pvr - kPVRTextureFlagCubemap = (1<<12), // is a cubemap/skybox - kPVRTextureFlagFalseMipCol = (1<<13), // are there false coloured MIP levels - kPVRTextureFlagVolume = (1<<14), // is this a volume texture - kPVRTextureFlagAlpha = (1<<15), // v2.1 is there transparency info in the texture - kPVRTextureFlagVerticalFlip = (1<<16), // v2.1 is the texture vertically flipped + kPVRTextureFlagBumpmap = (1<<10), // has normals encoded for a bump map + kPVRTextureFlagTiling = (1<<11), // is bordered for tiled pvr + kPVRTextureFlagCubemap = (1<<12), // is a cubemap/skybox + kPVRTextureFlagFalseMipCol = (1<<13), // are there false coloured MIP levels + kPVRTextureFlagVolume = (1<<14), // is this a volume texture + kPVRTextureFlagAlpha = (1<<15), // v2.1 is there transparency info in the texture + kPVRTextureFlagVerticalFlip = (1<<16), // v2.1 is the texture vertically flipped }; -/* - PVR header contains special field called PVRTag. This tag - is used only to determine that passed file is really pvrt. - - Its set of 4 numbers. Each number casted to the char - must correspond to the "PVR!" string -*/ -static unsigned int gPVRTexIdentifier[] = { 'P', 'V', 'R', '!'}; +static char gPVRTexIdentifier[5] = "PVR!"; /* List of formats in pvr container @@ -73,7 +65,7 @@ enum kPVRTextureFlagTypeRGBA_8888, kPVRTextureFlagTypeRGB_565, kPVRTextureFlagTypeRGB_555, // unsupported - kPVRTextureFlagTypeRGB_888, // unsupported + kPVRTextureFlagTypeRGB_888, kPVRTextureFlagTypeI_8, kPVRTextureFlagTypeAI_88, kPVRTextureFlagTypePVRTC_2, @@ -82,14 +74,6 @@ enum kPVRTextureFlagTypeA_8, }; -/* - Helps us to convert pvr format to the gl compatible bitspaces - - WARNING!! OpenGL ES 1.1. does not support GL_BGRA format. Its PowerVR - extension and it will work only on PowerVR chipsets. It means that - - kPVRTextureFlagTypeBGRA_8888 can be used only on apple devices (or PowerVR compatible) -*/ static const unsigned int tableFormats[][7] = { // - PVR texture format @@ -99,26 +83,23 @@ static const unsigned int tableFormats[][7] = { // - bpp // - compressed // - Cocos2d texture format constant - { kPVRTextureFlagTypeRGBA_4444, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 16, false, kCCTexture2DPixelFormat_RGBA4444 }, - { kPVRTextureFlagTypeRGBA_5551, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 16, false, kCCTexture2DPixelFormat_RGB5A1 }, - { kPVRTextureFlagTypeRGBA_8888, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 32, false, kCCTexture2DPixelFormat_RGBA8888 }, - { kPVRTextureFlagTypeRGB_565, GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 16, false, kCCTexture2DPixelFormat_RGB565 }, - { kPVRTextureFlagTypeA_8, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, 8, false, kCCTexture2DPixelFormat_A8 }, - { kPVRTextureFlagTypeI_8, GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, 8, false, kCCTexture2DPixelFormat_I8 }, - { kPVRTextureFlagTypeAI_88, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 16, false, kCCTexture2DPixelFormat_AI88 }, + {kPVRTextureFlagTypeRGBA_4444, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 16, false, kCCTexture2DPixelFormat_RGBA4444}, + {kPVRTextureFlagTypeRGBA_5551, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 16, false, kCCTexture2DPixelFormat_RGB5A1}, + {kPVRTextureFlagTypeRGBA_8888, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 32, false, kCCTexture2DPixelFormat_RGBA8888}, + {kPVRTextureFlagTypeRGB_565, GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 16, false, kCCTexture2DPixelFormat_RGB565}, + {kPVRTextureFlagTypeA_8, GL_ALPHA, GL_ALPHA,GL_UNSIGNED_BYTE, 8, false, kCCTexture2DPixelFormat_A8}, + {kPVRTextureFlagTypeI_8, GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, 8, false, kCCTexture2DPixelFormat_I8 }, + {kPVRTextureFlagTypeAI_88, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 16, false, kCCTexture2DPixelFormat_AI88 }, #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - { kPVRTextureFlagTypePVRTC_2, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, -1, -1, 2, true, kCCTexture2DPixelFormat_PVRTC2 }, - { kPVRTextureFlagTypePVRTC_4, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, -1, -1, 4, true, kCCTexture2DPixelFormat_PVRTC4 }, - { kPVRTextureFlagTypeBGRA_8888, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE, 32, false, kCCTexture2DPixelFormat_RGBA8888 }, + {kPVRTextureFlagTypePVRTC_2, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, -1, -1, 2, true, kCCTexture2DPixelFormat_PVRTC2 }, + {kPVRTextureFlagTypePVRTC_4, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, -1, -1, 4, true, kCCTexture2DPixelFormat_PVRTC4 }, + {kPVRTextureFlagTypeBGRA_8888, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE, 32, false, kCCTexture2DPixelFormat_RGBA8888 }, #endif }; //Tells How large is tableFormats #define MAX_TABLE_ELEMENTS (sizeof(tableFormats) / sizeof(tableFormats[0])) -/* - Helper enum to traverse tableFormats -*/ enum { kCCInternalPVRTextureFormat, kCCInternalOpenGLInternalFormat, @@ -129,9 +110,6 @@ enum { kCCInternalCCTexture2DPixelFormat, }; -/* - Official PVRT header -*/ typedef struct _PVRTexHeader { unsigned int headerLength; @@ -149,9 +127,15 @@ typedef struct _PVRTexHeader unsigned int numSurfs; } PVRTexHeader; -CCTexturePVR::CCTexturePVR() : - m_uTableFormatIndex(0), - m_uNumberOfMipmaps(0) +CCTexturePVR::CCTexturePVR() +: m_uTableFormatIndex(0) +, m_uNumberOfMipmaps(0) +, m_uWidth(0) +, m_uHeight(0) +, m_bRetainName(false) +, m_bHasAlpha(false) +, m_uName(0) +, m_eFormat(kCCTexture2DPixelFormat_Default) { } @@ -159,43 +143,10 @@ CCTexturePVR::~CCTexturePVR() { CCLOGINFO( "cocos2d: deallocing CCTexturePVR" ); - if (m_uName != 0 && ! m_bRetainName ) - glDeleteTextures(1, &m_uName); -} - -GLuint CCTexturePVR::getName() -{ - return m_uName; -} - -unsigned int CCTexturePVR::getWidth() -{ - return m_uWidth; -} - -unsigned int CCTexturePVR::getHeight() -{ - return m_uHeight; -} - -CCTexture2DPixelFormat CCTexturePVR::getFormat() -{ - return m_eFormat; -} - -bool CCTexturePVR::getHasAlpha() -{ - return m_bHasAlpha; -} - -bool CCTexturePVR::getRetainName() -{ - return m_bRetainName; -} - -void CCTexturePVR::setRetainName(bool var) -{ - m_bRetainName = var; + if (m_uName != 0 && ! m_bRetainName) + { + ccGLDeleteTexture(m_uName); + } } bool CCTexturePVR::unpackPVRData(unsigned char* data, unsigned int len) @@ -228,43 +179,27 @@ bool CCTexturePVR::unpackPVRData(unsigned char* data, unsigned int len) gPVRTexIdentifier[2] != ((pvrTag >> 16) & 0xff) || gPVRTexIdentifier[3] != ((pvrTag >> 24) & 0xff)) { + CCLOG("Unsupported PVR format. Use the Legacy format until the new format is supported"); return false; } CCConfiguration *configuration = CCConfiguration::sharedConfiguration(); - //Get file flags (in correct byte order) flags = CC_SWAP_INT32_LITTLE_TO_HOST(header->flags); - - //Trim to only bites which are needed. Resulting flag is image format formatFlags = flags & PVR_TEXTURE_FLAG_TYPE_MASK; - - /* - When flags combined with flipped mask is not empty (zero). - It means that image is compressed as flipped. We don't - support automatic flipping. - */ bool flipped = (flags & kPVRTextureFlagVerticalFlip) ? true : false; - if ( flipped ) + if (flipped) { CCLOG("cocos2d: WARNING: Image is flipped. Regenerate it using PVRTexTool"); } - if ( ! configuration->isSupportsNPOT() && + if (! configuration->isSupportsNPOT() && (header->width != ccNextPOT(header->width) || header->height != ccNextPOT(header->height))) { CCLOG("cocos2d: ERROR: Loding an NPOT texture (%dx%d) but is not supported on this device", header->width, header->height); return false; } - - //Check that sides of texture are power of two - if(header->width != ccNextPOT(header->width) || header->height != ccNextPOT(header->height)) - { - CCLOG("cocos2d: WARNING: PVR NPOT textures are not supported. Regenerate it."); - return false; - } - //Go thru format array for (m_uTableFormatIndex = 0; m_uTableFormatIndex < (unsigned int)MAX_TABLE_ELEMENTS; m_uTableFormatIndex++) { //Does image format in table fits to the one parsed from header? @@ -279,16 +214,20 @@ bool CCTexturePVR::unpackPVRData(unsigned char* data, unsigned int len) //Do we use alpha ? if (CC_SWAP_INT32_LITTLE_TO_HOST(header->bitmaskAlpha)) + { m_bHasAlpha = true; + } else + { m_bHasAlpha = false; + } //Get ptr to where data starts.. dataLength = CC_SWAP_INT32_LITTLE_TO_HOST(header->dataLength); //Move by size of header bytes = ((unsigned char *)data) + sizeof(PVRTexHeader); - m_eFormat = (CCTexture2DPixelFormat)( tableFormats[m_uTableFormatIndex][kCCInternalCCTexture2DPixelFormat] ); + m_eFormat = (CCTexture2DPixelFormat)(tableFormats[m_uTableFormatIndex][kCCInternalCCTexture2DPixelFormat]); bpp = tableFormats[m_uTableFormatIndex][kCCInternalBPP]; // Calculate the data size for each texture level and respect the minimum number of blocks @@ -299,13 +238,11 @@ bool CCTexturePVR::unpackPVRData(unsigned char* data, unsigned int len) blockSize = 8 * 4; // Pixel by pixel block size for 2bpp widthBlocks = width / 8; heightBlocks = height / 4; - bpp = 2; break; case kPVRTextureFlagTypePVRTC_4: blockSize = 4 * 4; // Pixel by pixel block size for 4bpp widthBlocks = width / 4; heightBlocks = height / 4; - bpp = 4; break; case kPVRTextureFlagTypeBGRA_8888: if (CCConfiguration::sharedConfiguration()->isSupportsBGRA8888() == false) @@ -317,22 +254,25 @@ bool CCTexturePVR::unpackPVRData(unsigned char* data, unsigned int len) blockSize = 1; widthBlocks = width; heightBlocks = height; - bpp = tableFormats[m_uTableFormatIndex][kCCInternalBPP]; break; } // Clamp to minimum number of blocks if (widthBlocks < 2) + { widthBlocks = 2; + } if (heightBlocks < 2) + { heightBlocks = 2; + } dataSize = widthBlocks * heightBlocks * ((blockSize * bpp) / 8); - unsigned int packetLength = (dataLength-dataOffset); + float packetLength = (dataLength - dataOffset); packetLength = packetLength > dataSize ? dataSize : packetLength; //Make record to the mipmaps array and increment coutner - m_asMipmaps[m_uNumberOfMipmaps].address = bytes+dataOffset; + m_asMipmaps[m_uNumberOfMipmaps].address = bytes + dataOffset; m_asMipmaps[m_uNumberOfMipmaps].len = packetLength; m_uNumberOfMipmaps++; @@ -353,9 +293,9 @@ bool CCTexturePVR::unpackPVRData(unsigned char* data, unsigned int len) } } - if (false == success) + if (! success) { - CCLOG("cocos2d: WARNING: Unssupported PVR Pixel Format: 0x%2x", formatFlags); + CCLOG("cocos2d: WARNING: Unsupported PVR Pixel Format: 0x%2x. Re-encode it with a OpenGL pixel format variant", formatFlags); } return success; @@ -374,51 +314,69 @@ bool CCTexturePVR::createGLTexture() ccGLDeleteTexture(m_uName); } + // From PVR sources: "PVR files are never row aligned." + glPixelStorei(GL_UNPACK_ALIGNMENT,1); + glGenTextures(1, &m_uName); glBindTexture(GL_TEXTURE_2D, m_uName); + + // Default: Anti alias. + if (m_uNumberOfMipmaps == 1) + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + } + else + { + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); + } + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); } + + CHECK_GL_ERROR_DEBUG(); // clean possible GL error + + GLenum internalFormat = tableFormats[m_uTableFormatIndex][kCCInternalOpenGLInternalFormat]; + GLenum format = tableFormats[m_uTableFormatIndex][kCCInternalOpenGLFormat]; + GLenum type = tableFormats[m_uTableFormatIndex][kCCInternalOpenGLType]; + bool compressed = tableFormats[m_uTableFormatIndex][kCCInternalCompressedImage]; // Generate textures with mipmaps for (unsigned int i = 0; i < m_uNumberOfMipmaps; ++i) { - GLenum internalFormat = tableFormats[m_uTableFormatIndex][kCCInternalOpenGLInternalFormat]; - GLenum format = tableFormats[m_uTableFormatIndex][kCCInternalOpenGLFormat]; - GLenum type = tableFormats[m_uTableFormatIndex][kCCInternalOpenGLType]; - bool compressed = tableFormats[m_uTableFormatIndex][kCCInternalCompressedImage] == 1; - - if (compressed == true && CCConfiguration::sharedConfiguration()->isSupportsPVRTC() == false) + if (compressed && ! CCConfiguration::sharedConfiguration()->isSupportsNPOT()) { - CCLOG("cocos2d: WARNING: PVRTC images are not supported"); - return false; - } + CCLOG("cocos2d: WARNING: PVRTC images are not supported"); + return false; + } - unsigned char *data = m_asMipmaps[i].address; - unsigned int datalen = m_asMipmaps[i].len; + unsigned char *data = m_asMipmaps[i].address; + unsigned int datalen = m_asMipmaps[i].len; - if (compressed == true) + if (compressed) { - glCompressedTexImage2D(GL_TEXTURE_2D, i, internalFormat, width, height, 0, datalen, data); + glCompressedTexImage2D(GL_TEXTURE_2D, i, internalFormat, width, height, 0, datalen, data); } - else + else { - glTexImage2D(GL_TEXTURE_2D, i, internalFormat, width, height, 0, format, type, data); - } - - if(i > 0 && (width != height || ccNextPOT(width) != width ) ) - { - CCLOG("cocos2d: TexturePVR. WARNING. Mipmap level %lu is not squared. Texture won't render correctly. width=%lu != height=%lu", i, width, height); + glTexImage2D(GL_TEXTURE_2D, i, internalFormat, width, height, 0, format, type, data); } - err = glGetError(); - if (err != GL_NO_ERROR) + if (i > 0 && (width != height || ccNextPOT(width) != width )) { - CCLOG("cocos2d: TexturePVR: Error uploading compressed texture level: %u . glError: 0x%04X", (unsigned int)i, err); - return false; + CCLOG("cocos2d: TexturePVR. WARNING. Mipmap level %u is not squared. Texture won't render correctly. width=%u != height=%u", i, width, height); } - //Update width and height to the next lower power of two - width = MAX(width >> 1, 1); - height = MAX(height >> 1, 1); + err = glGetError(); + if (err != GL_NO_ERROR) + { + CCLOG("cocos2d: TexturePVR: Error uploading compressed texture level: %u . glError: 0x%04X", i, err); + return false; + } + + width = MAX(width >> 1, 1); + height = MAX(height >> 1, 1); } return true; @@ -463,7 +421,7 @@ bool CCTexturePVR::initWithContentsOfFile(const char* path) m_bRetainName = false; // cocos2d integration - if ( !unpackPVRData(pvrdata, pvrlen) || !createGLTexture() ) + if (!unpackPVRData(pvrdata, pvrlen) || !createGLTexture()) { delete [] pvrdata; this->release(); @@ -478,15 +436,20 @@ bool CCTexturePVR::initWithContentsOfFile(const char* path) CCTexturePVR * CCTexturePVR::pvrTextureWithContentsOfFile(const char* path) { CCTexturePVR * pTexture = new CCTexturePVR(); - if(true == pTexture->initWithContentsOfFile(path)) + if (pTexture) { - pTexture->autorelease(); - return pTexture; - } - else - { - return NULL; + if (pTexture->initWithContentsOfFile(path)) + { + pTexture->autorelease(); + } + else + { + delete pTexture; + pTexture = NULL; + } } + + return pTexture; } NS_CC_END diff --git a/cocos2dx/textures/CCTexturePVR.h b/cocos2dx/textures/CCTexturePVR.h index c56ccd1f9b..583cd5d212 100644 --- a/cocos2dx/textures/CCTexturePVR.h +++ b/cocos2dx/textures/CCTexturePVR.h @@ -78,7 +78,6 @@ enum { class CCTexturePVR : public CCObject { public: - CCTexturePVR(); virtual ~CCTexturePVR(); @@ -86,50 +85,35 @@ public: bool initWithContentsOfFile(const char* path); /** creates and initializes a CCTexturePVR with a path */ - static CCTexturePVR * pvrTextureWithContentsOfFile(const char* path); + static CCTexturePVR* pvrTextureWithContentsOfFile(const char* path); + + // properties + + inline unsigned int getName() { return m_uName; } + inline unsigned int getWidth() { return m_uWidth; } + inline unsigned int getHeight() { return m_uHeight; } + inline bool hasAlpha() { return m_bHasAlpha; } + inline unsigned int getNumberOfMipmaps() { return m_uNumberOfMipmaps; } + inline CCTexture2DPixelFormat getFormat() { return m_eFormat; } + inline bool isRetainName() { return m_bRetainName; } + inline void setRetainName(bool retainName) { m_bRetainName = retainName; } - CC_PROPERTY_READONLY(GLuint, m_uName, Name) - CC_PROPERTY_READONLY(unsigned int, m_uWidth, Width) - CC_PROPERTY_READONLY(unsigned int, m_uHeight, Height) - CC_PROPERTY_READONLY(CCTexture2DPixelFormat, m_eFormat, Format) - CC_PROPERTY_READONLY(bool, m_bHasAlpha, HasAlpha) - - // cocos2d integration - CC_PROPERTY(bool, m_bRetainName, RetainName); - -protected: - - /* - Unpacks data (data of pvr texture file) and determine - how many mipmaps it uses (m_uNumberOfMipmaps). Adresses - of mimaps (m_asMipmaps). And basic data like size, format - and alpha presence - */ +private: bool unpackPVRData(unsigned char* data, unsigned int len); - - /* - Binds all mipmaps to the GL state machine as separate - textures - */ bool createGLTexture(); - - /* - Index to the tableFormats array. Which tells us what exact - format is file which initializes this object. - */ + +protected: + struct CCPVRMipmap m_asMipmaps[CC_PVRMIPMAP_MAX]; // pointer to mipmap images + unsigned int m_uNumberOfMipmaps; // number of mipmap used + unsigned int m_uTableFormatIndex; - - /* - How many mipmaps do we have. It must be at least one - when proper initialization finishes - */ - CC_SYNTHESIZE_READONLY(unsigned int, m_uNumberOfMipmaps, NumberOfMipmaps); - - /* - Makrs for mipmaps. Each entry contains position in file - and lenght of data which represents one mipmap. - */ - struct CCPVRMipmap m_asMipmaps[CC_PVRMIPMAP_MAX]; + unsigned int m_uWidth, m_uHeight; + GLuint m_uName; + bool m_bHasAlpha; + + // cocos2d integration + bool m_bRetainName; + CCTexture2DPixelFormat m_eFormat; }; NS_CC_END diff --git a/tests/tests/ActionsTest/ActionsTest.cpp b/tests/tests/ActionsTest/ActionsTest.cpp index 1719327645..a821055ba1 100644 --- a/tests/tests/ActionsTest/ActionsTest.cpp +++ b/tests/tests/ActionsTest/ActionsTest.cpp @@ -1656,7 +1656,7 @@ void PauseResumeActions::pause(float dt) { CCLog("Pausing"); CCDirector *director = CCDirector::sharedDirector(); - this->m_pPausedTargets = director->getActionManager()->pauseAlllRunningActions(); + this->m_pPausedTargets = director->getActionManager()->pauseAllRunningActions(); } void PauseResumeActions::resume(float dt) From 9185f771f105bd8da3dcba4a33a58da2e95f7192 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Jun 2012 14:29:15 +0800 Subject: [PATCH 128/257] issue #1310: Added some resources for tests project. --- tests/Resources/fonts/bitmapFontTest2.bmp.REMOVED.git-id | 1 + tests/Resources/fonts/font-issue1343-hd.png.REMOVED.git-id | 1 + 2 files changed, 2 insertions(+) create mode 100644 tests/Resources/fonts/bitmapFontTest2.bmp.REMOVED.git-id create mode 100644 tests/Resources/fonts/font-issue1343-hd.png.REMOVED.git-id diff --git a/tests/Resources/fonts/bitmapFontTest2.bmp.REMOVED.git-id b/tests/Resources/fonts/bitmapFontTest2.bmp.REMOVED.git-id new file mode 100644 index 0000000000..b934758bd2 --- /dev/null +++ b/tests/Resources/fonts/bitmapFontTest2.bmp.REMOVED.git-id @@ -0,0 +1 @@ +263832e2766c734b77335f353e3066033c158c90 \ No newline at end of file diff --git a/tests/Resources/fonts/font-issue1343-hd.png.REMOVED.git-id b/tests/Resources/fonts/font-issue1343-hd.png.REMOVED.git-id new file mode 100644 index 0000000000..4d9f7c904d --- /dev/null +++ b/tests/Resources/fonts/font-issue1343-hd.png.REMOVED.git-id @@ -0,0 +1 @@ +a6ca8414e453957fa2fbc456b47160ac402ea35e \ No newline at end of file From ef8ec1a941c08f53b9ea43f85ad86e1abf1d5bb5 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Jun 2012 14:32:57 +0800 Subject: [PATCH 129/257] issue #1310: Added some resources for tests project. --- tests/Resources/fonts/futura-48.png.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Resources/fonts/futura-48.png.REMOVED.git-id b/tests/Resources/fonts/futura-48.png.REMOVED.git-id index 451874e3f2..e8460e8f6d 100644 --- a/tests/Resources/fonts/futura-48.png.REMOVED.git-id +++ b/tests/Resources/fonts/futura-48.png.REMOVED.git-id @@ -1 +1 @@ -6a89fbfbe3c98e2d72c84e4d76873375eca87802 \ No newline at end of file +796a33e41fb8a78b122fdf0d8a626510629bbb80 \ No newline at end of file From b770010c4179503c3079a89386d0560c8fdbf04a Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Jun 2012 14:33:53 +0800 Subject: [PATCH 130/257] issue #1310: Updated LabelTest. Added init method for CCLabelBMFont. Fixed a bug in CCLabelAtlas::initWithString. In CCSpriteBatchNode::initWithTexture, when capacity is equal to 0, set it to default value. --- cocos2dx/label_nodes/CCLabelAtlas.cpp | 8 +- cocos2dx/label_nodes/CCLabelBMFont.cpp | 37 +++ cocos2dx/label_nodes/CCLabelBMFont.h | 3 + cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp | 6 + tests/tests/LabelTest/LabelTest.cpp | 278 ++++++++++++++++++-- tests/tests/LabelTest/LabelTest.h | 50 ++++ 6 files changed, 355 insertions(+), 27 deletions(-) diff --git a/cocos2dx/label_nodes/CCLabelAtlas.cpp b/cocos2dx/label_nodes/CCLabelAtlas.cpp index f2ae74627b..f58e482d6e 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.cpp +++ b/cocos2dx/label_nodes/CCLabelAtlas.cpp @@ -87,12 +87,12 @@ bool CCLabelAtlas::initWithString(const char *theString, const char *fntFile) { CCDictionary *dict = CCDictionary::dictionaryWithContentsOfFile(CCFileUtils::sharedFileUtils()->sharedFileUtils()->fullPathFromRelativePath(fntFile)); - CCAssert(((CCInteger*)dict->objectForKey("version"))->getValue() == 1, "Unsupported version. Upgrade cocos2d version"); + CCAssert(((CCString*)dict->objectForKey("version"))->intValue() == 1, "Unsupported version. Upgrade cocos2d version"); CCString *textureFilename = (CCString*)dict->objectForKey("textureFilename"); - unsigned int width = ((CCInteger*)dict->objectForKey("itemWidth"))->getValue() / CC_CONTENT_SCALE_FACTOR(); - unsigned int height = ((CCInteger*)dict->objectForKey("itemHeight"))->getValue() / CC_CONTENT_SCALE_FACTOR(); - unsigned int startChar = ((CCInteger*)dict->objectForKey("firstChar"))->getValue(); + unsigned int width = ((CCString*)dict->objectForKey("itemWidth"))->intValue() / CC_CONTENT_SCALE_FACTOR(); + unsigned int height = ((CCString*)dict->objectForKey("itemHeight"))->intValue() / CC_CONTENT_SCALE_FACTOR(); + unsigned int startChar = ((CCString*)dict->objectForKey("firstChar"))->intValue(); this->initWithString(theString, textureFilename->getCString(), width, height, startChar); diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index 296cbd1520..4a5a8a42aa 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -752,6 +752,11 @@ CCLabelBMFont *CCLabelBMFont::labelWithString(const char *str, const char *fntFi return NULL; } +bool CCLabelBMFont::init() +{ + return initWithString(NULL, NULL, kCCLabelAutomaticWidth, kCCTextAlignmentLeft, CCPointZero); +} + bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile) { return initWithString(theString, fntFile, kCCLabelAutomaticWidth, kCCTextAlignmentLeft, CCPointZero); @@ -788,6 +793,11 @@ bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile, f texture->autorelease(); } + if (theString == NULL) + { + theString = ""; + } + if (CCSpriteBatchNode::initWithTexture(texture, strlen(theString))) { m_pAlignment = alignment; @@ -1352,6 +1362,33 @@ float CCLabelBMFont::getLetterPosXRight( CCSprite* sp ) { return sp->getPosition().x * m_fScaleX + (sp->getContentSize().width * m_fScaleX * sp->getAnchorPoint().x); } + +// LabelBMFont - FntFile +void CCLabelBMFont::setFntFile(const char* fntFile) +{ + if (fntFile != NULL && strcmp(fntFile, m_sFntFile.c_str()) != 0 ) + { + CCBMFontConfiguration *newConf = FNTConfigLoadFile(fntFile); + + CCAssert( newConf, "CCLabelBMFont: Impossible to create font. Please check file"); + + m_sFntFile = fntFile; + + CC_SAFE_RELEASE(m_pConfiguration); + CC_SAFE_RETAIN(newConf); + m_pConfiguration = newConf; + + this->setTexture(CCTextureCache::sharedTextureCache()->addImage(m_pConfiguration->getAtlasName())); + this->createFontChars(); + } +} + +const char* CCLabelBMFont::getFntFile() +{ + return m_sFntFile.c_str(); +} + + //LabelBMFont - Debug draw #if CC_LABELBMFONT_DEBUG_DRAW void CCLabelBMFont::draw() diff --git a/cocos2dx/label_nodes/CCLabelBMFont.h b/cocos2dx/label_nodes/CCLabelBMFont.h index a5a62d33f5..4b063b3c30 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.h +++ b/cocos2dx/label_nodes/CCLabelBMFont.h @@ -192,6 +192,7 @@ public: static CCLabelBMFont * labelWithString(const char *str, const char *fntFile, float width, CCTextAlignment alignment); static CCLabelBMFont * labelWithString(const char *str, const char *fntFile, float width, CCTextAlignment alignment, CCPoint imageOffset); + bool init(); /** init a bitmap font altas with an initial string and the FNT file */ bool initWithString(const char *str, const char *fntFile, float width, CCTextAlignment alignment, CCPoint imageOffset); bool initWithString(const char *str, const char *fntFile, float width, CCTextAlignment alignment); @@ -213,6 +214,8 @@ public: virtual void setScaleX(float scaleX); virtual void setScaleY(float scaleY); + void setFntFile(const char* fntFile); + const char* getFntFile(); #if CC_LABELBMFONT_DEBUG_DRAW virtual void draw(); #endif // CC_LABELBMFONT_DEBUG_DRAW diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp index e25ee087ca..5ace7b88ca 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp @@ -93,6 +93,12 @@ bool CCSpriteBatchNode::initWithTexture(CCTexture2D *tex, unsigned int capacity) m_blendFunc.src = CC_BLEND_SRC; m_blendFunc.dst = CC_BLEND_DST; m_pobTextureAtlas = new CCTextureAtlas(); + + if (0 == capacity) + { + capacity = defaultCapacity; + } + m_pobTextureAtlas->initWithTexture(tex, capacity); updateBlendFunc(); diff --git a/tests/tests/LabelTest/LabelTest.cpp b/tests/tests/LabelTest/LabelTest.cpp index 35ae63bd9f..ed1bfc966d 100644 --- a/tests/tests/LabelTest/LabelTest.cpp +++ b/tests/tests/LabelTest/LabelTest.cpp @@ -40,7 +40,7 @@ CCLayer* restartAtlasAction(); static int sceneIdx = -1; -#define MAX_LAYER 22 +#define MAX_LAYER 26 CCLayer* createAtlasLayer(int nIndex) { @@ -70,6 +70,10 @@ CCLayer* createAtlasLayer(int nIndex) case 19: return new LabelTTFA8Test(); case 20: return new BMFontOneAtlas(); case 21: return new BMFontUnicode(); + case 22: return new BMFontInit(); + case 23: return new TTFFontInit(); + case 24: return new Issue1343(); + case 25: return new LabelTTFAlignment(); } return NULL; @@ -151,9 +155,9 @@ void AtlasDemo::onEnter() CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); menu->setPosition( CCPointZero ); - item1->setPosition( ccp( s.width/2 - 100,30) ); - item2->setPosition( ccp( s.width/2, 30) ); - item3->setPosition( ccp( s.width/2 + 100,30) ); + item1->setPosition( ccp( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2)); + item2->setPosition( ccp( s.width/2, item2->getContentSize().height/2)); + item3->setPosition( ccp( s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2)); addChild(menu, 1); } @@ -265,12 +269,12 @@ LabelAtlasTest::LabelAtlasTest() { m_time = 0; - CCLabelAtlas* label1 = CCLabelAtlas::labelWithString("123 Test", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); + CCLabelAtlas* label1 = CCLabelAtlas::labelWithString("123 Test", "fonts/tuffy_bold_italic-charmap.plist"); addChild(label1, 0, kTagSprite1); label1->setPosition( ccp(10,100) ); label1->setOpacity( 200 ); - CCLabelAtlas *label2 = CCLabelAtlas::labelWithString("0123456789", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); + CCLabelAtlas *label2 = CCLabelAtlas::labelWithString("0123456789", "fonts/tuffy_bold_italic-charmap.plist"); addChild(label2, 0, kTagSprite2); label2->setPosition( ccp(10,200) ); label2->setOpacity( 32 ); @@ -358,6 +362,40 @@ std::string LabelAtlasColorTest::subtitle() } +//------------------------------------------------------------------ +// +// LabelTTFAlignment +// +//------------------------------------------------------------------ +LabelTTFAlignment::LabelTTFAlignment() +{ + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCLabelTTF* ttf0 = CCLabelTTF::labelWithString("Alignment 0\nnew line", CCSizeMake(256, 32), kCCTextAlignmentLeft, "Helvetica", 12); + ttf0->setPosition(ccp(s.width/2,(s.height/6)*2)); + ttf0->setAnchorPoint(ccp(0.5f,0.5f)); + this->addChild(ttf0); + + CCLabelTTF* ttf1 = CCLabelTTF::labelWithString("Alignment 1\nnew line", CCSizeMake(245, 32), kCCTextAlignmentCenter, "Helvetica", 12); + ttf1->setPosition(ccp(s.width/2,(s.height/6)*3)); + ttf1->setAnchorPoint(ccp(0.5f,0.5f)); + this->addChild(ttf1); + + CCLabelTTF* ttf2 = CCLabelTTF::labelWithString("Alignment 2\nnew line", CCSizeMake(245, 32), kCCTextAlignmentRight, "Helvetica", 12); + ttf2->setPosition(ccp(s.width/2,(s.height/6)*4)); + ttf2->setAnchorPoint(ccp(0.5f,0.5f)); + this->addChild(ttf2); +} + +std::string LabelTTFAlignment::title() +{ + return "CCLabelTTF alignment"; +} + +std::string LabelTTFAlignment::subtitle() +{ + return "Tests alignment values"; +} //------------------------------------------------------------------ // // Atlas3 @@ -849,7 +887,7 @@ LabelAtlasHD::LabelAtlasHD() CCSize s = CCDirector::sharedDirector()->getWinSize(); // CCLabelBMFont - CCLabelAtlas *label1 = CCLabelAtlas::labelWithString("TESTING RETINA DISPLAY", "fonts/larabie-16.png", 10, 20, 'A'); + CCLabelAtlas *label1 = CCLabelAtlas::labelWithString("TESTING RETINA DISPLAY", "fonts/larabie-16.plist"); label1->setAnchorPoint(ccp(0.5f, 0.5f)); addChild(label1); @@ -909,20 +947,129 @@ void AtlasTestScene::runThisTest() //------------------------------------------------------------------ LabelTTFTest::LabelTTFTest() { - CCSize s = CCDirector::sharedDirector()->getWinSize(); + CCSize blockSize = CCSizeMake(200, 160); + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCLayerColor *colorLayer = CCLayerColor::layerWithColor(ccc4(100, 100, 100, 255), blockSize.width, blockSize.height); + colorLayer->setAnchorPoint(ccp(0,0)); + colorLayer->setPosition(ccp((s.width - blockSize.width) / 2, (s.height - blockSize.height) / 2)); + + this->addChild(colorLayer); + + CCMenuItemFont::setFontSize(30); + CCMenu *menu = CCMenu::menuWithItems( + CCMenuItemFont::itemWithString("Left", this, menu_selector(LabelTTFTest::setAlignmentLeft)), + CCMenuItemFont::itemWithString("Center", this, menu_selector(LabelTTFTest::setAlignmentCenter)), + CCMenuItemFont::itemWithString("Right", this, menu_selector(LabelTTFTest::setAlignmentRight)), + NULL); + menu->alignItemsVerticallyWithPadding(4); + menu->setPosition(ccp(50, s.height / 2 - 20)); + this->addChild(menu); + + menu = CCMenu::menuWithItems( + CCMenuItemFont::itemWithString("Top", this, menu_selector(LabelTTFTest::setAlignmentTop)), + CCMenuItemFont::itemWithString("Middle", this, menu_selector(LabelTTFTest::setAlignmentMiddle)), + CCMenuItemFont::itemWithString("Bottom", this, menu_selector(LabelTTFTest::setAlignmentBottom)), + NULL); + menu->alignItemsVerticallyWithPadding(4); + menu->setPosition(ccp(s.width - 50, s.height / 2 - 20)); + this->addChild(menu); + + m_plabel = NULL; + m_eHorizAlign = kCCTextAlignmentLeft; + m_eVertAlign = kCCVerticalTextAlignmentTop; + + this->updateAlignment(); +} - // CCLabelBMFont - CCLabelTTF *left = CCLabelTTF::labelWithString("align left", CCSizeMake(s.width, 50), kCCTextAlignmentLeft, "Marker Felt", 32); - CCLabelTTF *center = CCLabelTTF::labelWithString("align center", CCSizeMake(s.width, 50), kCCTextAlignmentCenter, "Marker Felt", 32); - CCLabelTTF *right = CCLabelTTF::labelWithString("align right", CCSizeMake(s.width, 50), kCCTextAlignmentRight, "Marker Felt", 32); +LabelTTFTest::~LabelTTFTest() +{ + CC_SAFE_RELEASE(m_plabel); +} - left->setPosition(ccp(s.width / 2, 200)); - center->setPosition(ccp(s.width / 2, 150)); - right->setPosition(ccp(s.width / 2, 100)); - - addChild(left); - addChild(center); - addChild(right); +void LabelTTFTest::updateAlignment() +{ + CCSize blockSize = CCSizeMake(200, 160); + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + if (m_plabel) + { + m_plabel->removeFromParentAndCleanup(true); + } + + m_plabel = CCLabelTTF::labelWithString(this->getCurrentAlignment(), blockSize, m_eHorizAlign, m_eVertAlign, "Marker Felt", 32); + m_plabel->retain(); + + m_plabel->setAnchorPoint(ccp(0,0)); + m_plabel->setPosition(ccp((s.width - blockSize.width) / 2, (s.height - blockSize.height)/2 )); + + this->addChild(m_plabel); +} + +void LabelTTFTest::setAlignmentLeft(CCObject* pSender) +{ + m_eHorizAlign = kCCTextAlignmentLeft; + this->updateAlignment(); +} + +void LabelTTFTest::setAlignmentCenter(CCObject* pSender) +{ + m_eHorizAlign = kCCTextAlignmentCenter; + this->updateAlignment(); +} + +void LabelTTFTest::setAlignmentRight(CCObject* pSender) +{ + m_eHorizAlign = kCCTextAlignmentRight; + this->updateAlignment(); +} + +void LabelTTFTest::setAlignmentTop(CCObject* pSender) +{ + m_eVertAlign = kCCVerticalTextAlignmentTop; + this->updateAlignment(); +} + +void LabelTTFTest::setAlignmentMiddle(CCObject* pSender) +{ + m_eVertAlign = kCCVerticalTextAlignmentCenter; + this->updateAlignment(); +} + +void LabelTTFTest::setAlignmentBottom(CCObject* pSender) +{ + m_eVertAlign = kCCVerticalTextAlignmentBottom; + this->updateAlignment(); +} + +const char* LabelTTFTest::getCurrentAlignment() +{ + const char* vertical = NULL; + const char* horizontal = NULL; + switch (m_eVertAlign) { + case kCCVerticalTextAlignmentTop: + vertical = "Top"; + break; + case kCCVerticalTextAlignmentCenter: + vertical = "Middle"; + break; + case kCCVerticalTextAlignmentBottom: + vertical = "Bottom"; + break; + } + switch (m_eHorizAlign) { + case kCCTextAlignmentLeft: + horizontal = "Left"; + break; + case kCCTextAlignmentCenter: + horizontal = "Center"; + break; + case kCCTextAlignmentRight: + horizontal = "Right"; + break; + } + + return CCString::stringWithFormat("Alignment %s %s", vertical, horizontal)->getCString(); } string LabelTTFTest::title() @@ -932,16 +1079,20 @@ string LabelTTFTest::title() string LabelTTFTest::subtitle() { - return "You should see 3 labels aligned left, center and right"; + return "Select the buttons on the sides to change alignment"; } LabelTTFMultiline::LabelTTFMultiline() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - // CCLabelBMFont CCLabelTTF *center = CCLabelTTF::labelWithString("word wrap \"testing\" (bla0) bla1 'bla2' [bla3] (bla4) {bla5} {bla6} [bla7] (bla8) [bla9] 'bla0' \"bla1\"", - CCSizeMake(s.width / 2, 200), kCCTextAlignmentCenter, "MarkerFelt.ttc", 32); + CCSizeMake(s.width/2,200), + kCCTextAlignmentCenter, + kCCVerticalTextAlignmentTop, + "Paint Boy", + 32); + center->setPosition(ccp(s.width / 2, 150)); addChild(center); @@ -954,7 +1105,7 @@ string LabelTTFMultiline::title() string LabelTTFMultiline::subtitle() { - return "Word wrap using CCLabelTTF"; + return "Word wrap using CCLabelTTF and a custom TTF font"; } LabelTTFChinese::LabelTTFChinese() @@ -1268,4 +1419,85 @@ std::string BMFontUnicode::title() std::string BMFontUnicode::subtitle() { return "You should see 3 differnt labels: In Spanish, Chinese and Korean"; +} + +// BMFontInit + +BMFontInit::BMFontInit() +{ + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCLabelBMFont* bmFont = new CCLabelBMFont(); + bmFont->init(); + bmFont->autorelease(); + //CCLabelBMFont* bmFont = [CCLabelBMFont labelWithString:@"Foo" fntFile:@"arial-unicode-26.fnt"]; + bmFont->setFntFile("fonts/helvetica-32.fnt"); + bmFont->setString("It is working!"); + this->addChild(bmFont); + bmFont->setPosition(ccp(s.width/2,s.height/4*2)); +} + +std::string BMFontInit::title() +{ + return "CCLabelBMFont init"; } + +std::string BMFontInit::subtitle() +{ + return "Test for support of init method without parameters."; +} + +// TTFFontInit + +TTFFontInit::TTFFontInit() +{ + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCLabelTTF* font = new CCLabelTTF(); + font->init(); + font->autorelease(); + font->setFontName("Marker Felt"); + font->setFontSize(48); + font->setString("It is working!"); + this->addChild(font); + font->setPosition(ccp(s.width/2,s.height/4*2)); +} + +std::string TTFFontInit::title() +{ + return "CCLabelTTF init"; +} + +std::string TTFFontInit::subtitle() +{ + return "Test for support of init method without parameters."; +} + + +// Issue1343 + +Issue1343::Issue1343() +{ + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCLabelBMFont* bmFont = new CCLabelBMFont(); + bmFont->init(); + bmFont->setFntFile("fonts/font-issue1343.fnt"); + bmFont->setString("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz.,'"); + this->addChild(bmFont); + bmFont->release(); + bmFont->setScale(0.3f); + + bmFont->setPosition(ccp(s.width/2,s.height/4*2)); +} + +std::string Issue1343::title() +{ + return "Issue 1343"; +} + +std::string Issue1343::subtitle() +{ + return "You should see: ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz.,'"; +} + diff --git a/tests/tests/LabelTest/LabelTest.h b/tests/tests/LabelTest/LabelTest.h index 0df0c68e6a..b6ebb134c3 100644 --- a/tests/tests/LabelTest/LabelTest.h +++ b/tests/tests/LabelTest/LabelTest.h @@ -54,6 +54,15 @@ public: virtual std::string subtitle(); }; +class LabelTTFAlignment : public AtlasDemo +{ +public: + LabelTTFAlignment(); + virtual std::string title(); + virtual std::string subtitle(); +}; + + class Atlas3 : public AtlasDemo { float m_time; @@ -166,8 +175,22 @@ class LabelTTFTest : public AtlasDemo { public: LabelTTFTest(); + virtual ~LabelTTFTest(); virtual std::string title(); virtual std::string subtitle(); +private: + void setAlignmentLeft(CCObject* pSender); + void setAlignmentCenter(CCObject* pSender); + void setAlignmentRight(CCObject* pSender); + void setAlignmentTop(CCObject* pSender); + void setAlignmentMiddle(CCObject* pSender); + void setAlignmentBottom(CCObject* pSender); + void updateAlignment(); + const char* getCurrentAlignment(); +private: + CCLabelTTF* m_plabel; + CCTextAlignment m_eHorizAlign; + CCVerticalTextAlignment m_eVertAlign; }; class LabelTTFMultiline : public AtlasDemo @@ -241,6 +264,33 @@ public: virtual std::string subtitle(); }; +class BMFontInit : public AtlasDemo +{ +public: + BMFontInit(); + + virtual std::string title(); + virtual std::string subtitle(); +}; + +class TTFFontInit : public AtlasDemo +{ +public: + TTFFontInit(); + + virtual std::string title(); + virtual std::string subtitle(); +}; + +class Issue1343 : public AtlasDemo +{ +public: + Issue1343(); + + virtual std::string title(); + virtual std::string subtitle(); +}; + // we don't support linebreak mode #endif From f5b2a5d33d7a71ae352332db28195f29507abfc9 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Jun 2012 15:14:01 +0800 Subject: [PATCH 131/257] issue #1310: Updated LayerTest. --- tests/tests/LayerTest/LayerTest.cpp | 161 +++++++++++++++++++++++++++- tests/tests/LayerTest/LayerTest.h | 27 +++++ 2 files changed, 184 insertions(+), 4 deletions(-) diff --git a/tests/tests/LayerTest/LayerTest.cpp b/tests/tests/LayerTest/LayerTest.cpp index 79daedbf4a..84ca17dc6f 100644 --- a/tests/tests/LayerTest/LayerTest.cpp +++ b/tests/tests/LayerTest/LayerTest.cpp @@ -12,7 +12,7 @@ CCLayer* restartTestAction(); static int sceneIdx = -1; -#define MAX_LAYER 4 +#define MAX_LAYER 7 CCLayer* createTestLayer(int nIndex) { @@ -22,6 +22,9 @@ CCLayer* createTestLayer(int nIndex) case 1: return new LayerTest2(); case 2: return new LayerTestBlend(); case 3: return new LayerGradient(); + case 4: return new LayerIgnoreAnchorPointPos(); + case 5: return new LayerIgnoreAnchorPointRot(); + case 6: return new LayerIgnoreAnchorPointScale(); } return NULL; @@ -108,9 +111,9 @@ void LayerTest::onEnter() CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); menu->setPosition( CCPointZero ); - item1->setPosition( CCPointMake( s.width/2 - 100,30) ); - item2->setPosition( CCPointMake( s.width/2, 30) ); - item3->setPosition( CCPointMake( s.width/2 + 100,30) ); + item1->setPosition( ccp( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2) ); + item2->setPosition( ccp( s.width/2, item2->getContentSize().height/2) ); + item3->setPosition( ccp( s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2) ); addChild(menu, 1); } @@ -351,6 +354,156 @@ string LayerGradient::subtitle() return "Touch the screen and move your finger"; } +// LayerIgnoreAnchorPointPos + +#define kLayerIgnoreAnchorPoint 1000 + +void LayerIgnoreAnchorPointPos::onEnter() +{ + LayerTest::onEnter(); + + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCLayerColor *l = CCLayerColor::layerWithColor(ccc4(255, 0, 0, 255), 150, 150); + + l->setAnchorPoint(ccp(0.5f, 0.5f)); + l->setPosition(ccp( s.width/2, s.height/2)); + + CCMoveBy *move = CCMoveBy::actionWithDuration(2, ccp(100,2)); + CCMoveBy * back = (CCMoveBy *)move->reverse(); + CCSequence *seq = (CCSequence *)CCSequence::actions(move, back, NULL); + l->runAction(CCRepeatForever::actionWithAction(seq)); + this->addChild(l, 0, kLayerIgnoreAnchorPoint); + + CCSprite *child = CCSprite::spriteWithFile("Images/grossini.png"); + l->addChild(child); + CCSize lsize = l->getContentSize(); + child->setPosition(ccp(lsize.width/2, lsize.height/2)); + + CCMenuItemFont *item = CCMenuItemFont::itemWithString("Toogle ignore anchor point", this, menu_selector(LayerIgnoreAnchorPointPos::onToggle)); + + CCMenu *menu = CCMenu::menuWithItems(item, NULL); + this->addChild(menu); + + menu->setPosition(ccp(s.width/2, s.height/2)); +} + +void LayerIgnoreAnchorPointPos::onToggle(CCObject* pObject) +{ + CCNode* pLayer = this->getChildByTag(kLayerIgnoreAnchorPoint); + bool ignore = pLayer->getIgnoreAnchorPointForPosition(); + pLayer->setIgnoreAnchorPointForPosition(! ignore); +} + +std::string LayerIgnoreAnchorPointPos::title() +{ + return "IgnoreAnchorPoint - Position"; +} + +std::string LayerIgnoreAnchorPointPos::subtitle() +{ + return "Ignoring Anchor Point for position"; +} + +// LayerIgnoreAnchorPointRot + +void LayerIgnoreAnchorPointRot::onEnter() +{ + LayerTest::onEnter(); + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCLayerColor *l = CCLayerColor::layerWithColor(ccc4(255, 0, 0, 255), 200, 200); + + l->setAnchorPoint(ccp(0.5f, 0.5f)); + l->setPosition(ccp( s.width/2, s.height/2)); + + this->addChild(l, 0, kLayerIgnoreAnchorPoint); + + CCRotateBy *rot = CCRotateBy::actionWithDuration(2, 360); + l->runAction(CCRepeatForever::actionWithAction(rot)); + + + CCSprite *child = CCSprite::spriteWithFile("Images/grossini.png"); + l->addChild(child); + CCSize lsize = l->getContentSize(); + child->setPosition(ccp(lsize.width/2, lsize.height/2)); + + CCMenuItemFont *item = CCMenuItemFont::itemWithString("Toogle ignore anchor point", this, menu_selector(LayerIgnoreAnchorPointRot::onToggle)); + + CCMenu *menu = CCMenu::menuWithItems(item, NULL); + this->addChild(menu); + + menu->setPosition(ccp(s.width/2, s.height/2)); +} + +void LayerIgnoreAnchorPointRot::onToggle(CCObject* pObject) +{ + CCNode* pLayer = this->getChildByTag(kLayerIgnoreAnchorPoint); + bool ignore = pLayer->getIgnoreAnchorPointForPosition(); + pLayer->setIgnoreAnchorPointForPosition(! ignore); +} + +std::string LayerIgnoreAnchorPointRot::title() +{ + return "IgnoreAnchorPoint - Rotation"; +} + +std::string LayerIgnoreAnchorPointRot::subtitle() +{ + return "Ignoring Anchor Point for rotations"; +} + +// LayerIgnoreAnchorPointScale +void LayerIgnoreAnchorPointScale::onEnter() +{ + LayerTest::onEnter(); + + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCLayerColor *l = CCLayerColor::layerWithColor(ccc4(255, 0, 0, 255), 200, 200); + + l->setAnchorPoint(ccp(0.5f, 1.0f)); + l->setPosition(ccp( s.width/2, s.height/2)); + + + CCScaleBy *scale = CCScaleBy::actionWithDuration(2, 2); + CCScaleBy* back = (CCScaleBy*)scale->reverse(); + CCSequence *seq = (CCSequence*)CCSequence::actions(scale, back, NULL); + + l->runAction(CCRepeatForever::actionWithAction(seq)); + + this->addChild(l, 0, kLayerIgnoreAnchorPoint); + + CCSprite *child = CCSprite::spriteWithFile("Images/grossini.png"); + l->addChild(child); + CCSize lsize = l->getContentSize(); + child->setPosition(ccp(lsize.width/2, lsize.height/2)); + + CCMenuItemFont *item = CCMenuItemFont::itemWithString("Toogle ignore anchor point", this, menu_selector(LayerIgnoreAnchorPointScale::onToggle)); + + CCMenu *menu = CCMenu::menuWithItems(item, NULL); + this->addChild(menu); + + menu->setPosition(ccp(s.width/2, s.height/2)); +} + +void LayerIgnoreAnchorPointScale::onToggle(CCObject* pObject) +{ + CCNode* pLayer = this->getChildByTag(kLayerIgnoreAnchorPoint); + bool ignore = pLayer->getIgnoreAnchorPointForPosition(); + pLayer->setIgnoreAnchorPointForPosition(! ignore); +} + +std::string LayerIgnoreAnchorPointScale::title() +{ + return "IgnoreAnchorPoint - Scale"; +} + +std::string LayerIgnoreAnchorPointScale::subtitle() +{ + return "Ignoring Anchor Point for scale"; +} + void LayerTestScene::runThisTest() { CCLayer* pLayer = nextTestAction(); diff --git a/tests/tests/LayerTest/LayerTest.h b/tests/tests/LayerTest/LayerTest.h index d23223b835..8ab0f5e12f 100644 --- a/tests/tests/LayerTest/LayerTest.h +++ b/tests/tests/LayerTest/LayerTest.h @@ -62,6 +62,33 @@ public: void toggleItem(cocos2d::CCObject *sender); }; +class LayerIgnoreAnchorPointPos : public LayerTest +{ +public: + virtual void onEnter(); + void onToggle(CCObject* pObject); + virtual std::string title(); + virtual std::string subtitle(); +}; + +class LayerIgnoreAnchorPointRot : public LayerTest +{ +public: + virtual void onEnter(); + void onToggle(CCObject* pObject); + virtual std::string title(); + virtual std::string subtitle(); +}; + +class LayerIgnoreAnchorPointScale : public LayerTest +{ +public: + virtual void onEnter(); + void onToggle(CCObject* pObject); + virtual std::string title(); + virtual std::string subtitle(); +}; + class LayerTestScene : public TestScene { public: From ae1ea76ca168e2d37c6f4c2b29fd8661805f2f8d Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Jun 2012 15:22:42 +0800 Subject: [PATCH 132/257] issue #1310: Updated NodeTest. --- tests/tests/NodeTest/NodeTest.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/tests/NodeTest/NodeTest.cpp b/tests/tests/NodeTest/NodeTest.cpp index e62589dc5d..bf47994156 100644 --- a/tests/tests/NodeTest/NodeTest.cpp +++ b/tests/tests/NodeTest/NodeTest.cpp @@ -123,9 +123,9 @@ void TestCocosNodeDemo::onEnter() CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); menu->setPosition( CCPointZero ); - item1->setPosition( CCPointMake( s.width/2 - 100,30) ); - item2->setPosition( CCPointMake( s.width/2, 30) ); - item3->setPosition( CCPointMake( s.width/2 + 100,30) ); + item1->setPosition( ccp( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2) ); + item2->setPosition( ccp( s.width/2, item2->getContentSize().height/2) ); + item3->setPosition( ccp( s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2) ); addChild(menu, 11); } From 1c0f391e03c49522430733bed62c587890737771 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Jun 2012 15:40:31 +0800 Subject: [PATCH 133/257] issue #1310: Updated ParticleTest. --- tests/tests/ParticleTest/ParticleTest.cpp | 86 ++++++++++++++++++++--- tests/tests/ParticleTest/ParticleTest.h | 16 +++++ 2 files changed, 93 insertions(+), 9 deletions(-) diff --git a/tests/tests/ParticleTest/ParticleTest.cpp b/tests/tests/ParticleTest/ParticleTest.cpp index aa63850ac8..9811d405b3 100644 --- a/tests/tests/ParticleTest/ParticleTest.cpp +++ b/tests/tests/ParticleTest/ParticleTest.cpp @@ -969,7 +969,7 @@ enum static int sceneIdx = -1; -#define MAX_LAYER 41 +#define MAX_LAYER 43 CCLayer* createParticleLayer(int nIndex) { @@ -1017,6 +1017,8 @@ CCLayer* createParticleLayer(int nIndex) case 38: return new MultipleParticleSystemsBatched(); case 39: return new AddAndDeleteParticleSystems(); case 40: return new ReorderParticleSystems(); + case 41: return new PremultipliedAlphaTest(); + case 42: return new PremultipliedAlphaTest2(); default: break; } @@ -1096,24 +1098,24 @@ void ParticleDemo::onEnter(void) CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, item4, NULL); menu->setPosition( CCPointZero ); - item1->setPosition( CCPointMake( s.width/2 - 100,30) ); - item2->setPosition( CCPointMake( s.width/2, 30) ); - item3->setPosition( CCPointMake( s.width/2 + 100,30) ); - item4->setPosition( CCPointMake( 0, 100) ); - item4->setAnchorPoint( CCPointMake(0,0) ); + item1->setPosition( ccp( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2) ); + item2->setPosition( ccp( s.width/2, item2->getContentSize().height/2) ); + item3->setPosition( ccp( s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2) ); + item4->setPosition( ccp( 0, 100) ); + item4->setAnchorPoint( ccp(0,0) ); addChild( menu, 100 ); CCLabelAtlas* labelAtlas = CCLabelAtlas::labelWithString("0000", "fps_images.png", 12, 32, '.'); addChild(labelAtlas, 100, kTagParticleCount); - labelAtlas->setPosition(CCPointMake(s.width-66,50)); + labelAtlas->setPosition(ccp(s.width-66,50)); // moving background m_background = CCSprite::spriteWithFile(s_back3); addChild(m_background, 5); - m_background->setPosition( CCPointMake(s.width/2, s.height-180) ); + m_background->setPosition( ccp(s.width/2, s.height-180) ); - CCActionInterval* move = CCMoveBy::actionWithDuration(4, CCPointMake(300,0) ); + CCActionInterval* move = CCMoveBy::actionWithDuration(4, ccp(300,0) ); CCActionInterval* move_back = move->reverse(); CCFiniteTimeAction* seq = CCSequence::actions( move, move_back, NULL); m_background->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq) ); @@ -1857,7 +1859,73 @@ std::string ReorderParticleSystems::subtitle() { return "changes every 2 seconds"; } + +// PremultipliedAlphaTest + +std::string PremultipliedAlphaTest::title() +{ + return "premultiplied alpha"; +} +std::string PremultipliedAlphaTest::subtitle() +{ + return "no black halo, particles should fade out"; +} + +void PremultipliedAlphaTest::onEnter() +{ + ParticleDemo::onEnter(); + + this->setColor(ccBLUE); + this->removeChild(m_background, true); + m_background = NULL; + + m_emitter = CCParticleSystemQuad::particleWithFile("Particles/BoilingFoam.plist"); + m_emitter->retain(); + // Particle Designer "normal" blend func causes black halo on premul textures (ignores multiplication) + //this->emitter.blendFunc = (ccBlendFunc){ GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA }; + + // Cocos2d "normal" blend func for premul causes alpha to be ignored (oversaturates colors) + ccBlendFunc tBlendFunc = { GL_ONE, GL_ONE_MINUS_SRC_ALPHA }; + m_emitter->setBlendFunc(tBlendFunc); + + CCAssert(m_emitter->getOpacityModifyRGB(), "Particle texture does not have premultiplied alpha, test is useless"); + + // Toggle next line to see old behavior + // this->emitter.opacityModifyRGB = NO; + + m_emitter->setStartColor(ccc4f(1, 1, 1, 1)); + m_emitter->setEndColor(ccc4f(1, 1, 1, 0)); + m_emitter->setStartColorVar(ccc4f(0, 0, 0, 0)); + m_emitter->setEndColorVar(ccc4f(0, 0, 0, 0)); + + this->addChild(m_emitter, 10); +} + +// PremultipliedAlphaTest2 + +void PremultipliedAlphaTest2::onEnter() +{ + ParticleDemo::onEnter(); + + this->setColor(ccBLACK); + this->removeChild(m_background, true); + m_background = NULL; + + m_emitter = CCParticleSystemQuad::particleWithFile("Particles/TestPremultipliedAlpha.plist"); + m_emitter->retain(); + this->addChild(m_emitter ,10); +} + +std::string PremultipliedAlphaTest2::title() +{ + return "premultiplied alpha 2"; +} + +std::string PremultipliedAlphaTest2::subtitle() +{ + return "Arrows should be faded"; +} void ParticleTestScene::runThisTest() { diff --git a/tests/tests/ParticleTest/ParticleTest.h b/tests/tests/ParticleTest/ParticleTest.h index 0156127607..0b0b663f78 100644 --- a/tests/tests/ParticleTest/ParticleTest.h +++ b/tests/tests/ParticleTest/ParticleTest.h @@ -284,4 +284,20 @@ private: CCParticleBatchNode* m_pBatchNode; }; +class PremultipliedAlphaTest : public ParticleDemo +{ +public: + virtual void onEnter(); + virtual std::string title(); + virtual std::string subtitle(); +}; + +class PremultipliedAlphaTest2 : public ParticleDemo +{ +public: + virtual void onEnter(); + virtual std::string title(); + virtual std::string subtitle(); +}; + #endif From 23519ef85c84fdeee9afc741d24db661faa479bc Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Jun 2012 15:55:23 +0800 Subject: [PATCH 134/257] issue #1310: Updated ParallaxTest and RenderTextureTest. --- tests/tests/ParallaxTest/ParallaxTest.cpp | 6 +- .../RenderTextureTest/RenderTextureTest.cpp | 56 +++++++++++++++++-- .../RenderTextureTest/RenderTextureTest.h | 8 +++ 3 files changed, 63 insertions(+), 7 deletions(-) diff --git a/tests/tests/ParallaxTest/ParallaxTest.cpp b/tests/tests/ParallaxTest/ParallaxTest.cpp index 5167090a52..851b507924 100644 --- a/tests/tests/ParallaxTest/ParallaxTest.cpp +++ b/tests/tests/ParallaxTest/ParallaxTest.cpp @@ -255,9 +255,9 @@ void ParallaxDemo::onEnter() CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); menu->setPosition( CCPointZero ); - item1->setPosition( ccp( s.width/2 - 100,30) ); - item2->setPosition( ccp( s.width/2, 30) ); - item3->setPosition( ccp( s.width/2 + 100,30) ); + item1->setPosition( ccp( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2) ); + item2->setPosition( ccp( s.width/2, item2->getContentSize().height/2) ); + item3->setPosition( ccp( s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2) ); addChild(menu, 1); } diff --git a/tests/tests/RenderTextureTest/RenderTextureTest.cpp b/tests/tests/RenderTextureTest/RenderTextureTest.cpp index b4f42d3410..9050b4f03f 100644 --- a/tests/tests/RenderTextureTest/RenderTextureTest.cpp +++ b/tests/tests/RenderTextureTest/RenderTextureTest.cpp @@ -6,7 +6,7 @@ static int sceneIdx = -1; -#define MAX_LAYER 4 +#define MAX_LAYER 5 CCLayer* createTestCase(int nIndex) { @@ -17,6 +17,7 @@ CCLayer* createTestCase(int nIndex) case 1: return new RenderTextureIssue937(); case 2: return new RenderTextureZbuffer(); case 3: return new RenderTextureSave(); + case 4: return new RenderTextureTestDepthStencil(); } return NULL; @@ -78,9 +79,9 @@ void RenderTextureTestDemo::onEnter() CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); menu->setPosition( CCPointZero ); - item1->setPosition( ccp( s.width/2 - 100,30) ); - item2->setPosition( ccp( s.width/2, 30) ); - item3->setPosition( ccp( s.width/2 + 100,30) ); + item1->setPosition( ccp( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2) ); + item2->setPosition( ccp( s.width/2, item2->getContentSize().height/2) ); + item3->setPosition( ccp( s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2) ); addChild(menu, 1); } @@ -569,3 +570,50 @@ void RenderTextureZbuffer::renderScreenShot() NULL)); } + +// RenderTextureTestDepthStencil + +RenderTextureTestDepthStencil::RenderTextureTestDepthStencil() +{ + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCSprite *sprite = CCSprite::spriteWithFile("Images/fire.png"); + sprite->setPosition(ccp(s.width * 0.25f, 0)); + sprite->setScale(10); + CCRenderTexture *rend = CCRenderTexture::renderTextureWithWidthAndHeight(s.width, s.height, kCCTexture2DPixelFormat_RGBA4444, CC_GL_DEPTH24_STENCIL8); + + glStencilMask(0xFF); + rend->beginWithClear(0, 0, 0, 0, 0, 0); + + //! mark sprite quad into stencil buffer + glEnable(GL_STENCIL_TEST); + glStencilFunc(GL_ALWAYS, 1, 0xFF); + glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); + glColorMask(0, 0, 0, 1); + sprite->visit(); + + //! move sprite half width and height, and draw only where not marked + sprite->setPosition(ccpAdd(sprite->getPosition(), ccpMult(ccp(sprite->getContentSize().width * sprite->getScale(), sprite->getContentSize().height * sprite->getScale()), 0.5))); + glStencilFunc(GL_NOTEQUAL, 1, 0xFF); + glColorMask(1, 1, 1, 1); + sprite->visit(); + + rend->end(); + + glDisable(GL_STENCIL_TEST); + + rend->setPosition(ccp(s.width * 0.5f, s.height * 0.5f)); + + this->addChild(rend); +} + +std::string RenderTextureTestDepthStencil::title() +{ + return "Testing depthStencil attachment"; +} + +std::string RenderTextureTestDepthStencil::subtitle() +{ + return "Circle should be missing 1/4 of its region"; +} + diff --git a/tests/tests/RenderTextureTest/RenderTextureTest.h b/tests/tests/RenderTextureTest/RenderTextureTest.h index e3abe3e4fe..59d1598095 100644 --- a/tests/tests/RenderTextureTest/RenderTextureTest.h +++ b/tests/tests/RenderTextureTest/RenderTextureTest.h @@ -89,4 +89,12 @@ private: cocos2d::CCSprite *sp9; }; +class RenderTextureTestDepthStencil : public RenderTextureTest +{ +public: + RenderTextureTestDepthStencil(); + virtual std::string title(); + virtual std::string subtitle(); +}; + #endif From c8b5ad04409770ca5a1b3e806a76579b2cf92276 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Jun 2012 16:22:25 +0800 Subject: [PATCH 135/257] issue #1310: Updated RotateWorldTest and SceneTest. --- .../tests/RotateWorldTest/RotateWorldTest.cpp | 4 +- tests/tests/SceneTest/SceneTest.cpp | 65 +++++++++++++------ tests/tests/SceneTest/SceneTest.h | 10 +-- 3 files changed, 52 insertions(+), 27 deletions(-) diff --git a/tests/tests/RotateWorldTest/RotateWorldTest.cpp b/tests/tests/RotateWorldTest/RotateWorldTest.cpp index 461d6ea1cd..deed92e11b 100644 --- a/tests/tests/RotateWorldTest/RotateWorldTest.cpp +++ b/tests/tests/RotateWorldTest/RotateWorldTest.cpp @@ -107,7 +107,9 @@ void RotateWorldMainLayer::onEnter() green->addChild(TestLayer::node()); white->setScale(0.5f); - white->setPosition(CCPointMake(x/4,y/4)); + white->setPosition(ccp(x/4,y/4)); + white->setIgnoreAnchorPointForPosition(false); + white->setPosition(ccp(x/4*3,y/4*3)); addChild(blue, -1); addChild(white); diff --git a/tests/tests/SceneTest/SceneTest.cpp b/tests/tests/SceneTest/SceneTest.cpp index d325d0a5b8..5ead21a744 100644 --- a/tests/tests/SceneTest/SceneTest.cpp +++ b/tests/tests/SceneTest/SceneTest.cpp @@ -138,22 +138,20 @@ void SceneTestLayer2::onGoBack(CCObject* pSender) void SceneTestLayer2::onReplaceScene(CCObject* pSender) { CCScene* pScene = new SceneTestScene(); - CCLayer* pLayer = new SceneTestLayer3(); + CCLayer* pLayer = SceneTestLayer3::node(); pScene->addChild( pLayer, 0 ); CCDirector::sharedDirector()->replaceScene( pScene ); pScene->release(); - pLayer->release(); } void SceneTestLayer2::onReplaceSceneTran(CCObject* pSender) { CCScene* pScene = new SceneTestScene(); - CCLayer* pLayer = new SceneTestLayer3(); + CCLayer* pLayer = SceneTestLayer3::node(); pScene->addChild( pLayer, 0 ); CCDirector::sharedDirector()->replaceScene( CCTransitionFlipX::transitionWithDuration(2, pScene) ); pScene->release(); - pLayer->release(); } //------------------------------------------------------------------ @@ -164,34 +162,59 @@ void SceneTestLayer2::onReplaceSceneTran(CCObject* pSender) SceneTestLayer3::SceneTestLayer3() { - setIsTouchEnabled( true ); - CCLabelTTF* label = CCLabelTTF::labelWithString("Touch to popScene", "Marker Felt", 28); - addChild(label); - CCSize s = CCDirector::sharedDirector()->getWinSize(); - label->setPosition( CCPointMake(s.width/2, s.height/2) ); - - CCSprite* sprite = CCSprite::spriteWithFile(s_pPathGrossini); - addChild(sprite); - sprite->setPosition( CCPointMake(s.width-40, s.height/2) ); - CCActionInterval* rotate = CCRotateBy::actionWithDuration(2, 360); - CCAction* repeat = CCRepeatForever::actionWithAction(rotate); - sprite->runAction(repeat); - //schedule(); +} + +bool SceneTestLayer3::init() +{ + if (CCLayerColor::initWithColor(ccc4(0,0,255,255))) + { + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCMenuItemFont *item0 = CCMenuItemFont::itemWithString("Touch to pushScene (self)", this, menu_selector(SceneTestLayer3::item0Clicked)); + CCMenuItemFont *item1 = CCMenuItemFont::itemWithString("Touch to popScene", this, menu_selector(SceneTestLayer3::item1Clicked)); + CCMenuItemFont *item2 = CCMenuItemFont::itemWithString("Touch to popToRootScene", this, menu_selector(SceneTestLayer3::item2Clicked)); + + + CCMenu *menu = CCMenu::menuWithItems(item0, item1, item2, NULL); + this->addChild(menu); + menu->alignItemsVertically(); + + this->schedule(schedule_selector(SceneTestLayer3::testDealloc)); + + CCSprite* sprite = CCSprite::spriteWithFile(s_pPathGrossini); + addChild(sprite); + sprite->setPosition( CCPointMake(s.width/2, 40) ); + CCActionInterval* rotate = CCRotateBy::actionWithDuration(2, 360); + CCAction* repeat = CCRepeatForever::actionWithAction(rotate); + sprite->runAction(repeat); + return true; + } + return false; } void SceneTestLayer3::testDealloc(float dt) { - + CCLog("Layer3:testDealloc"); } -void SceneTestLayer3::ccTouchesEnded(CCSet* touches, CCEvent* event) +void SceneTestLayer3::item0Clicked(CCObject* pSender) +{ + CCScene *newScene = CCScene::node(); + newScene->addChild(SceneTestLayer3::node()); + CCDirector::sharedDirector()->pushScene(CCTransitionFade::transitionWithDuration(0.5, newScene, ccc3(0,255,255))); +} + +void SceneTestLayer3::item1Clicked(CCObject* pSender) { -// static int i = 0; - //UXLOG("SceneTestLayer3::ccTouchesEnded(%d)", ++i); CCDirector::sharedDirector()->popScene(); } +void SceneTestLayer3::item2Clicked(CCObject* pSender) +{ + CCDirector::sharedDirector()->popToRootScene(); +} + void SceneTestScene::runThisTest() { CCLayer* pLayer = new SceneTestLayer1(); diff --git a/tests/tests/SceneTest/SceneTest.h b/tests/tests/SceneTest/SceneTest.h index c4bfb75a5d..acf7a65329 100644 --- a/tests/tests/SceneTest/SceneTest.h +++ b/tests/tests/SceneTest/SceneTest.h @@ -39,12 +39,12 @@ class SceneTestLayer3 : public CCLayerColor { public: SceneTestLayer3(); - + bool init(); virtual void testDealloc(float dt); - - virtual void ccTouchesEnded(CCSet* touches, CCEvent* event); - - //CREATE_NODE(SceneTestLayer3); + void item0Clicked(CCObject* pSender); + void item1Clicked(CCObject* pSender); + void item2Clicked(CCObject* pSender); + LAYER_NODE_FUNC(SceneTestLayer3) } ; class SceneTestScene : public TestScene From 9fbe1fef967268daf5853b696bd0288d894a6c65 Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 12 Jun 2012 16:56:34 +0800 Subject: [PATCH 136/257] issue #1310: synchronize some codes --- .../project.pbxproj.REMOVED.git-id | 2 +- .../ChipmunkAccelTouchTest.cpp | 2 +- tests/tests/DirectorTest/DirectorTest.cpp | 211 ----------------- tests/tests/DirectorTest/DirectorTest.h | 40 ---- .../DrawPrimitivesTest/DrawPrimitivesTest.cpp | 10 +- .../EffectsAdvancedTest.cpp | 8 +- tests/tests/EffectsTest/EffectsTest.cpp | 20 +- tests/tests/HiResTest/HiResTest.cpp | 223 ------------------ tests/tests/HiResTest/HiResTest.h | 45 ---- .../MotionStreakTest/MotionStreakTest.cpp | 107 +++++++-- .../tests/MotionStreakTest/MotionStreakTest.h | 16 +- .../PerformanceParticleTest.cpp | 2 +- .../PerformanceTest/PerformanceSpriteTest.cpp | 4 +- tests/tests/controller.cpp | 4 - tests/tests/tests.h | 6 - 15 files changed, 122 insertions(+), 578 deletions(-) delete mode 100644 tests/tests/DirectorTest/DirectorTest.cpp delete mode 100644 tests/tests/DirectorTest/DirectorTest.h delete mode 100644 tests/tests/HiResTest/HiResTest.cpp delete mode 100644 tests/tests/HiResTest/HiResTest.h diff --git a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id index 8f63248979..ef267a6614 100644 --- a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -c16d1dddb12b5a7e7e715f234dfd031657369f96 \ No newline at end of file +108734e79d5bc98e94e74a0803cbcc30dd687eb7 \ No newline at end of file diff --git a/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp b/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp index b61104d6d8..5920602936 100644 --- a/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp +++ b/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp @@ -119,7 +119,7 @@ void ChipmunkAccelTouchTestLayer::initPhysics() CCSize s = CCDirector::sharedDirector()->getWinSize(); // init chipmunk - cpInitChipmunk(); + //cpInitChipmunk(); m_pSpace = cpSpaceNew(); diff --git a/tests/tests/DirectorTest/DirectorTest.cpp b/tests/tests/DirectorTest/DirectorTest.cpp deleted file mode 100644 index 2867a698a7..0000000000 --- a/tests/tests/DirectorTest/DirectorTest.cpp +++ /dev/null @@ -1,211 +0,0 @@ -#include "DirectorTest.h" -#include "../testResource.h" - -#define MAX_LAYER 1 - -CCLayer* nextDirectorTestCase(); -CCLayer* backDirectorTestCase(); -CCLayer* restartDirectorTestCase(); - -static int sceneIdx=-1; -//static ccDeviceOrientation s_currentOrientation = CCDeviceOrientationPortrait; - -CCLayer* createTestCaseLayer(int index) -{ - switch (index) - { - case 0: - { - Director1* pRet = new Director1(); - pRet->init(); - pRet->autorelease(); - return pRet; - } - default: - return NULL; - } -} - -CCLayer* nextDirectorTestCase() -{ - sceneIdx++; - sceneIdx = sceneIdx % MAX_LAYER; - - return createTestCaseLayer(sceneIdx); -} - -CCLayer* backDirectorTestCase() -{ - sceneIdx--; - if( sceneIdx < 0 ) - sceneIdx += MAX_LAYER; - - return createTestCaseLayer(sceneIdx); -} - -CCLayer* restartDirectorTestCase() -{ - return createTestCaseLayer(sceneIdx); -} - -///--------------------------------------- -// -// DirectorTest -// -///--------------------------------------- -bool DirectorTest::init() -{ - bool bRet = false; - do - { - CC_BREAK_IF(! CCLayer::init()); - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - CCLabelTTF *label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 26); - addChild(label, 1); - label->setPosition(ccp(s.width/2, s.height-50)); - - std::string sSubtitle = subtitle(); - if (sSubtitle.length()) - { - CCLabelTTF *l = CCLabelTTF::labelWithString(sSubtitle.c_str(), "Thonburi", 16); - addChild(l, 1); - l->setPosition(ccp(s.width/2, s.height-80)); - } - - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(DirectorTest::backCallback)); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(DirectorTest::restartCallback)); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(DirectorTest::nextCallback)); - - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); - menu->setPosition(CCPointZero); - item1->setPosition(ccp( s.width/2 - 100,30)); - item2->setPosition(ccp( s.width/2, 30)); - item3->setPosition(ccp( s.width/2 + 100,30)); - - bRet = true; - } while (0); - - return bRet; -} - -void DirectorTest::restartCallback(CCObject* pSender) -{ - CCScene *s = new DirectorTestScene(); - s->addChild(restartDirectorTestCase()); - CCDirector::sharedDirector()->replaceScene(s); - s->autorelease(); -} - -void DirectorTest::nextCallback(CCObject* pSender) -{ - CCScene *s = new DirectorTestScene(); - s->addChild(nextDirectorTestCase()); - CCDirector::sharedDirector()->replaceScene(s); - s->autorelease(); -} - -void DirectorTest::backCallback(CCObject* pSender) -{ - CCScene *s = new DirectorTestScene(); - s->addChild(backDirectorTestCase()); - CCDirector::sharedDirector()->replaceScene(s); - s->autorelease(); -} - -std::string DirectorTest::title() -{ - return "No title"; -} - -std::string DirectorTest::subtitle() -{ - return ""; -} - -///--------------------------------------- -// -// Director1 -// -///--------------------------------------- -bool Director1::init() -{ - bool bRet = false; - - do - { - CC_BREAK_IF(! DirectorTest::init()); - - setIsTouchEnabled(true); - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - CCMenuItem *item = CCMenuItemFont::itemWithString("Rotate Device", this, menu_selector(Director1::rotateDevice)); - CCMenu *menu = CCMenu::menuWithItems(item, NULL); - menu->setPosition(ccp( s.width/2, s.height/2)); - addChild(menu); - - bRet = true; - } while (0); - - return bRet; -} - -void Director1::newOrientation() -{ - -} - -void Director1::rotateDevice(CCObject* pSender) -{ - newOrientation(); - restartCallback(NULL); -} - -void Director1::ccTouchesEnded(CCSet * touches, CCEvent* event) -{ - CCSetIterator it; - CCTouch* touch; - - for( it = touches->begin(); it != touches->end(); it++) - { - touch = (CCTouch*)(*it); - - if(!touch) - break; - CCPoint a = touch->locationInView(); - - CCDirector *director = CCDirector::sharedDirector(); - CCPoint b = director->convertToUI(director->convertToGL(a)); - CCLog("(%d,%d) == (%d,%d)", (int) a.x, (int)a.y, (int)b.x, (int)b.y ); - } -} - -std::string Director1::title() -{ - return "Testing conversion"; -} - -std::string Director1::subtitle() -{ - return "Tap screen and see the debug console"; -} - -///--------------------------------------- -// -// DirectorTestScene -// -///--------------------------------------- -void DirectorTestScene::runThisTest() -{ - //s_currentOrientation = CCDeviceOrientationPortrait; - CCLayer* pLayer = nextDirectorTestCase(); - addChild(pLayer); - - CCDirector::sharedDirector()->replaceScene(this); -} - -void DirectorTestScene::MainMenuCallback(CCObject* pSender) -{ - //CCDirector::sharedDirector()->setDeviceOrientation(CCDeviceOrientationPortrait); - TestScene::MainMenuCallback(pSender); -} diff --git a/tests/tests/DirectorTest/DirectorTest.h b/tests/tests/DirectorTest/DirectorTest.h deleted file mode 100644 index e5d0ad1f6c..0000000000 --- a/tests/tests/DirectorTest/DirectorTest.h +++ /dev/null @@ -1,40 +0,0 @@ -#ifndef __DIRECTOR_TEST_H__ -#define __DIRECTOR_TEST_H__ - -#include "../testBasic.h" - -class DirectorTest: public CCLayer -{ -public: - virtual bool init(); - - void restartCallback(CCObject* pSender); - void nextCallback(CCObject* pSender); - void backCallback(CCObject* pSender); - - virtual std::string title(); - virtual std::string subtitle(); -}; - -class Director1 : public DirectorTest -{ -public: - virtual bool init(); - - void newOrientation(); - void rotateDevice(CCObject* pSender); - void ccTouchesEnded(CCSet * touches, CCEvent* event); - - virtual std::string title(); - virtual std::string subtitle(); -}; - -class DirectorTestScene : public TestScene -{ -public: - virtual void runThisTest(); - - virtual void MainMenuCallback(CCObject* pSender); -}; - -#endif diff --git a/tests/tests/DrawPrimitivesTest/DrawPrimitivesTest.cpp b/tests/tests/DrawPrimitivesTest/DrawPrimitivesTest.cpp index 67d30e156f..a012a8bf57 100644 --- a/tests/tests/DrawPrimitivesTest/DrawPrimitivesTest.cpp +++ b/tests/tests/DrawPrimitivesTest/DrawPrimitivesTest.cpp @@ -72,6 +72,11 @@ void DrawPrimitivesTest::draw() ccDrawPoly( vertices, 5, false); CHECK_GL_ERROR_DEBUG(); + + // filled poly + glLineWidth(1); + CCPoint filledVertices[] = { ccp(0,120), ccp(50,120), ccp(50,170), ccp(25,200), ccp(0,170) }; + ccDrawSolidPoly(filledVertices, 5, ccc4f(0.5f, 0.5f, 1, 1 ) ); // closed purble poly ccDrawColor4B(255, 0, 255, 255); @@ -90,8 +95,9 @@ void DrawPrimitivesTest::draw() ccDrawCubicBezier(ccp(s.width/2, s.height/2), ccp(s.width/2+30,s.height/2+50), ccp(s.width/2+60,s.height/2-50),ccp(s.width, s.height/2),100); CHECK_GL_ERROR_DEBUG(); - //draw a solid polygon - CCPoint vertices3[] = {ccp(60,160), ccp(70,190), ccp(100,190), ccp(90,160)}; + + //draw a solid polygon + CCPoint vertices3[] = {ccp(60,160), ccp(70,190), ccp(100,190), ccp(90,160)}; ccDrawSolidPoly( vertices3, 4, ccc4f(1,1,0,1) ); // restore original values diff --git a/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp b/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp index 6e5b8195fa..683b11e083 100644 --- a/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp +++ b/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp @@ -343,10 +343,10 @@ void EffectAdvanceTextLayer::onEnter(void) CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); - menu->setPosition( CCPointZero ); - item1->setPosition( ccp( size.width/2 - 100,30) ); - item2->setPosition( ccp( size.width/2, 30) ); - item3->setPosition( ccp( size.width/2 + 100,30) ); + menu->setPosition(CCPointZero); + item1->setPosition(ccp(size.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2)); + item2->setPosition(ccp(size.width/2, item2->getContentSize().height/2)); + item3->setPosition(ccp(size.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2)); addChild(menu, 1); } diff --git a/tests/tests/EffectsTest/EffectsTest.cpp b/tests/tests/EffectsTest/EffectsTest.cpp index 2d067b22fe..e282e5b415 100644 --- a/tests/tests/EffectsTest/EffectsTest.cpp +++ b/tests/tests/EffectsTest/EffectsTest.cpp @@ -343,19 +343,19 @@ TextLayer::TextLayer(void) float x,y; - CCSize size = CCDirector::sharedDirector()->getWinSize(); - x = size.width; - y = size.height; + CCSize s = CCDirector::sharedDirector()->getWinSize(); + x = s.width; + y = s.height; CCNode* node = CCNode::node(); CCActionInterval* effect = getAction(); - node->runAction(effect) - ; + node->runAction(effect); addChild(node, 0, kTagBackground); CCSprite *bg = CCSprite::spriteWithFile(s_back3); node->addChild(bg, 0); - bg->setAnchorPoint( CCPointZero ); +// bg->setAnchorPoint( CCPointZero ); + bg->setPosition(ccp(s.width/2, s.height/2)); CCSprite* grossini = CCSprite::spriteWithFile(s_pPathSister2); node->addChild(grossini, 1); @@ -383,10 +383,10 @@ TextLayer::TextLayer(void) CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); - menu->setPosition( CCPointZero ); - item1->setPosition( CCPointMake( size.width/2 - 100,30) ); - item2->setPosition( CCPointMake( size.width/2, 30) ); - item3->setPosition( CCPointMake( size.width/2 + 100,30) ); + menu->setPosition(CCPointZero); + item1->setPosition(CCPointMake( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2)); + item2->setPosition(CCPointMake( s.width/2, item2->getContentSize().height/2)); + item3->setPosition(CCPointMake( s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2)); addChild(menu, 1); diff --git a/tests/tests/HiResTest/HiResTest.cpp b/tests/tests/HiResTest/HiResTest.cpp deleted file mode 100644 index 8869250937..0000000000 --- a/tests/tests/HiResTest/HiResTest.cpp +++ /dev/null @@ -1,223 +0,0 @@ -#include "HiResTest.h" -#include "../testResource.h" - -#define MAX_LAYERS 2; -static int sceneIdx = -1; - -CCLayer* nextHiResAction(); -CCLayer* restartHiResAction(); -CCLayer* backHiResAction(); - -CCLayer* createHiResLayer(int idx) -{ - CCLayer* pLayer = NULL; - - switch (idx) - { - case 0: - CCDirector::sharedDirector()->enableRetinaDisplay(false); - pLayer = new HiResTest1(); - break; - case 1: - CCDirector::sharedDirector()->enableRetinaDisplay(true); - pLayer = new HiResTest2(); - break; - } - - return pLayer; -} - -CCLayer* nextHiResAction() -{ - sceneIdx++; - sceneIdx = sceneIdx % MAX_LAYERS; - - CCLayer* pLayer = createHiResLayer(sceneIdx); - return pLayer; -} - -CCLayer* restartHiResAction() -{ - CCLayer* pLayer = createHiResLayer(sceneIdx); - return pLayer; -} - -CCLayer* backHiResAction() -{ - sceneIdx--; - if( sceneIdx < 0 ) - sceneIdx += MAX_LAYERS; - - CCLayer* pLayer = createHiResLayer(sceneIdx); - return pLayer; -} - -//////////////////////////////////// -// -// HiResDemo -// -/////////////////////////////////// -void HiResDemo::onEnter() -{ - CCLayer::onEnter(); - - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - CCLabelTTF *label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32); - label->setPosition(ccp(s.width/2, s.height-50)); - addChild(label, 1); - - std::string sSubTitle = subtitle(); - if (sSubTitle.length()) - { - CCLabelTTF *subLabel = CCLabelTTF::labelWithString(sSubTitle.c_str(), "Thonburi", 16); - subLabel->setPosition(ccp(s.width/2, s.height-80)); - addChild(subLabel, 1); - } - - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(HiResDemo::backCallback) ); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(HiResDemo::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(HiResDemo::nextCallback) ); - - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); - - menu->setPosition( CCPointZero ); - item1->setPosition( CCPointMake( s.width/2 - 100,30) ); - item2->setPosition( CCPointMake( s.width/2, 30) ); - item3->setPosition( CCPointMake( s.width/2 + 100,30) ); - - addChild(menu, 1); -} - -std::string HiResDemo::title() -{ - return "No title"; -} - -std::string HiResDemo::subtitle() -{ - return ""; -} - -void HiResDemo::restartCallback(CCObject* pSender) -{ - CCLayer* pLayer = restartHiResAction(); - - if (pLayer) - { - pLayer->autorelease(); - CCScene* pScene = new HiResTestScene(); - pScene->addChild(pLayer); - - CCDirector::sharedDirector()->replaceScene(pScene); - pScene->release(); - } -} - -void HiResDemo::nextCallback(CCObject* pSender) -{ - CCLayer* pLayer = nextHiResAction(); - - if (pLayer) - { - pLayer->autorelease(); - CCScene* pScene = new HiResTestScene(); - pScene->addChild(pLayer); - - CCDirector::sharedDirector()->replaceScene(pScene); - pScene->release(); - } -} - -void HiResDemo::backCallback(CCObject* pSender) -{ - CCLayer* pLayer = backHiResAction(); - - if (pLayer) - { - pLayer->autorelease(); - CCScene* pScene = new HiResTestScene(); - pScene->addChild(pLayer); - - CCDirector::sharedDirector()->replaceScene(pScene); - pScene->release(); - } -} - -//////////////////////////////////// -// -// HiResTest1 -// -/////////////////////////////////// -void HiResTest1::onEnter() -{ - - HiResDemo::onEnter(); - - CCSize size = CCDirector::sharedDirector()->getWinSize(); - - CCSprite *sprite = CCSprite::spriteWithFile("Images/grossini.png"); - addChild(sprite); - sprite->setPosition(ccp(size.width/2, size.height/2)); -} - -std::string HiResTest1::title() -{ - return "High resolution image test"; -} - -std::string HiResTest1::subtitle() -{ - return "Image without high resolution resource"; -} - -//////////////////////////////////// -// -// HiResTest2 -// -/////////////////////////////////// -void HiResTest2::onEnter() -{ - - HiResDemo::onEnter(); - - CCSize size = CCDirector::sharedDirector()->getWinSize(); - - CCSprite *sprite = CCSprite::spriteWithFile("Images/bugs/picture.png"); - addChild(sprite); - sprite->setPosition(ccp(size.width/2, size.height/2)); -} - -std::string HiResTest2::title() -{ - return "High resolution image test"; -} - -std::string HiResTest2::subtitle() -{ - return "Image with high resolution resource"; -} - -//////////////////////////////////// -// -// HiResTestScene -// -/////////////////////////////////// -bool HiResTestScene::sm_bRitinaDisplay = false; - -void HiResTestScene::runThisTest() -{ - //sm_bRitinaDisplay = CCDirector::sharedDirector()->isRetinaDisplay(); - - CCLayer* pLayer = nextHiResAction(); - addChild(pLayer); - - pLayer->release(); - CCDirector::sharedDirector()->replaceScene(this); -} - -void HiResTestScene::MainMenuCallback(CCObject* pSender) -{ - CCDirector::sharedDirector()->enableRetinaDisplay(sm_bRitinaDisplay); - TestScene::MainMenuCallback(pSender); -} diff --git a/tests/tests/HiResTest/HiResTest.h b/tests/tests/HiResTest/HiResTest.h deleted file mode 100644 index b77bbf1493..0000000000 --- a/tests/tests/HiResTest/HiResTest.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef _HIRES_TEST_H_ -#define _HIRES_TEST_H_ - -#include "../testBasic.h" - -class HiResDemo : public CCLayer -{ -public: - virtual std::string title(); - virtual std::string subtitle(); - virtual void onEnter(); - - void restartCallback(CCObject* pSender); - void nextCallback(CCObject* pSender); - void backCallback(CCObject* pSender); -}; - -class HiResTest1 : public HiResDemo -{ -public: - virtual void onEnter(); - - virtual std::string title(); - virtual std::string subtitle(); -}; - -class HiResTest2 : public HiResDemo -{ -public: - virtual void onEnter(); - - virtual std::string title(); - virtual std::string subtitle(); -}; - -class HiResTestScene : public TestScene -{ -public: - virtual void runThisTest(); - virtual void MainMenuCallback(CCObject* pSender); - - static bool sm_bRitinaDisplay; -}; - -#endif diff --git a/tests/tests/MotionStreakTest/MotionStreakTest.cpp b/tests/tests/MotionStreakTest/MotionStreakTest.cpp index 013bb30b97..f1eef8fff9 100644 --- a/tests/tests/MotionStreakTest/MotionStreakTest.cpp +++ b/tests/tests/MotionStreakTest/MotionStreakTest.cpp @@ -1,6 +1,12 @@ #include "MotionStreakTest.h" #include "../testResource.h" +enum { + kTagLabel = 1, + kTagSprite1 = 2, + kTagSprite2 = 3, +}; + CCLayer* nextMotionAction(); CCLayer* backMotionAction(); CCLayer* restartMotionAction(); @@ -20,16 +26,16 @@ void MotionStreakTest1::onEnter() // the root object just rotates around m_root = CCSprite::spriteWithFile(s_pPathR1); addChild(m_root, 1); - m_root->setPosition( CCPointMake(s.width/2, s.height/2) ); + m_root->setPosition(ccp(s.width/2, s.height/2)); // the target object is offset from root, and the streak is moved to follow it m_target = CCSprite::spriteWithFile(s_pPathR1); m_root->addChild(m_target); - m_target->setPosition( CCPointMake(100,0) ); + m_target->setPosition(ccp(s.width/4, 0)); // create the streak object and add it to the scene - m_streak = CCMotionStreak::streakWithFade(2, 3, 32, ccGREEN, s_streak); - addChild( m_streak ); + streak = CCMotionStreak::streakWithFade(2, 3, 32, ccGREEN, s_streak); + addChild(streak); // schedule an update on each frame so we can syncronize the streak with the target schedule(schedule_selector(MotionStreakTest1::onUpdate)); @@ -50,15 +56,12 @@ void MotionStreakTest1::onEnter() CCTintTo::actionWithDuration(0.2f, 255, 255, 255), NULL)); - m_streak->runAction(colorAction); - - // weak ref - streak = m_streak; + streak->runAction(colorAction); } void MotionStreakTest1::onUpdate(float delta) { - m_streak->setPosition( m_target->convertToWorldSpace(CCPointZero) ); + streak->setPosition( m_target->convertToWorldSpace(CCPointZero) ); } std::string MotionStreakTest1::title() @@ -81,13 +84,10 @@ void MotionStreakTest2::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); // create the streak object and add it to the scene - m_streak = CCMotionStreak::streakWithFade(3, 3, 64, ccWHITE, s_streak ); - addChild( m_streak ); + streak = CCMotionStreak::streakWithFade(3, 3, 64, ccWHITE, s_streak ); + addChild(streak); - m_streak->setPosition( CCPointMake(s.width/2, s.height/2) ); - - // weak ref - streak = m_streak; + streak->setPosition( CCPointMake(s.width/2, s.height/2) ); } void MotionStreakTest2::ccTouchesMoved(CCSet* touches, CCEvent* event) @@ -98,7 +98,7 @@ void MotionStreakTest2::ccTouchesMoved(CCSet* touches, CCEvent* event) CCPoint touchLocation = touch->locationInView(); touchLocation = CCDirector::sharedDirector()->convertToGL( touchLocation ); - m_streak->setPosition( touchLocation ); + streak->setPosition( touchLocation ); } std::string MotionStreakTest2::title() @@ -106,6 +106,47 @@ std::string MotionStreakTest2::title() return "MotionStreak test"; } +//------------------------------------------------------------------ +// +// Issue1358 +// +//------------------------------------------------------------------ + +void Issue1358::onEnter() +{ + MotionStreakTest::onEnter(); + + // ask director the the window size + CCSize size = CCDirector::sharedDirector()->getWinSize(); + + streak = CCMotionStreak::streakWithFade(2.0f, 1.0f, 50.0f, ccc3(255, 255, 0), "Icon.png"); + addChild(streak); + + + m_center = ccp(size.width/2, size.height/2); + m_fRadius = size.width/3; + m_fAngle = 0.0f; + + schedule(schedule_selector(Issue1358::update), 0); +} + +void Issue1358::update(float dt) +{ + m_fAngle += 1.0f; + streak->setPosition(ccp(m_center.x + cosf(m_fAngle/180 * M_PI)*m_fRadius, + m_center.y + sinf(m_fAngle/ 180 * M_PI)*m_fRadius)); +} + +std::string Issue1358::title() +{ + return "Issue 1358"; +} + +std::string Issue1358::subtitle() +{ + return "The tail should use the texture"; +} + //------------------------------------------------------------------ // // MotionStreakTest @@ -121,7 +162,7 @@ std::string MotionStreakTest2::title() static int sceneIdx = -1; -#define MAX_LAYER 2 +#define MAX_LAYER 3 CCLayer* createMotionLayer(int nIndex) { @@ -129,6 +170,7 @@ CCLayer* createMotionLayer(int nIndex) { case 0: return new MotionStreakTest1(); case 1: return new MotionStreakTest2(); + case 2: return new Issue1358(); } return NULL; @@ -180,6 +222,11 @@ std::string MotionStreakTest::title() return "No title"; } +std::string MotionStreakTest::subtitle() +{ + return ""; +} + void MotionStreakTest::onEnter() { CCLayer::onEnter(); @@ -187,8 +234,16 @@ void MotionStreakTest::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32); - addChild(label, 1); - label->setPosition( CCPointMake(s.width/2, s.height-50) ); + addChild(label, 0, kTagLabel); + label->setPosition(CCPointMake(s.width/2, s.height-50)); + + string subTitle = this->subtitle(); + if (subTitle.size() > 0) + { + CCLabelTTF *l = CCLabelTTF::labelWithString(subTitle.c_str(), "Thonburi", 16); + addChild(l, 1); + l->setPosition(ccp(s.width/2, s.height-80)); + } CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(MotionStreakTest::backCallback) ); CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(MotionStreakTest::restartCallback) ); @@ -196,22 +251,22 @@ void MotionStreakTest::onEnter() CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); - menu->setPosition( CCPointZero ); - item1->setPosition( CCPointMake( s.width/2 - 100,30) ); - item2->setPosition( CCPointMake( s.width/2, 30) ); - item3->setPosition( CCPointMake( s.width/2 + 100,30) ); + menu->setPosition(CCPointZero); + item1->setPosition(CCPointMake(s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2)); + item2->setPosition(CCPointMake(s.width/2, item2->getContentSize().height/2)); + item3->setPosition(CCPointMake(s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2)); addChild(menu, 1); CCMenuItemToggle *itemMode = CCMenuItemToggle::itemWithTarget(this, menu_selector(MotionStreakTest::modeCallback), - CCMenuItemFont::itemWithString("Fast"), - CCMenuItemFont::itemWithString("Slow"), + CCMenuItemFont::itemWithString("Use High Quality Mode"), + CCMenuItemFont::itemWithString("Use Fast Mode"), NULL); CCMenu *menuMode = CCMenu::menuWithItems(itemMode, NULL); addChild(menuMode); - menuMode->setPosition(ccp(30, 65)); + menuMode->setPosition(ccp(s.width/2, s.height/4)); } void MotionStreakTest::modeCallback(CCObject *pSender) diff --git a/tests/tests/MotionStreakTest/MotionStreakTest.h b/tests/tests/MotionStreakTest/MotionStreakTest.h index 0925f46a96..bde330acfb 100644 --- a/tests/tests/MotionStreakTest/MotionStreakTest.h +++ b/tests/tests/MotionStreakTest/MotionStreakTest.h @@ -13,6 +13,7 @@ public: ~MotionStreakTest(void); virtual std::string title(); + virtual std::string subtitle(); virtual void onEnter(); void restartCallback(CCObject* pSender); @@ -28,7 +29,6 @@ class MotionStreakTest1 : public MotionStreakTest protected: CCNode* m_root; CCNode* m_target; - CCMotionStreak* m_streak; public: virtual void onEnter(); @@ -41,7 +41,6 @@ class MotionStreakTest2 : public MotionStreakTest protected: CCNode* m_root; CCNode* m_target; - CCMotionStreak* m_streak; public: virtual void onEnter(); @@ -49,6 +48,19 @@ public: virtual std::string title(); }; +class Issue1358 : public MotionStreakTest +{ +public: + virtual std::string title(); + virtual std::string subtitle(); + virtual void onEnter(); + virtual void update(float dt); +private: + CCPoint m_center; + float m_fRadius; + float m_fAngle; +}; + class MotionStreakTestScene : public TestScene { public: diff --git a/tests/tests/PerformanceTest/PerformanceParticleTest.cpp b/tests/tests/PerformanceTest/PerformanceParticleTest.cpp index fec426fcf6..88abd0ddc9 100644 --- a/tests/tests/PerformanceTest/PerformanceParticleTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceParticleTest.cpp @@ -13,7 +13,7 @@ enum { enum { kMaxParticles = 14000, - kNodesIncrease = 100, + kNodesIncrease = 500, }; static int s_nParCurIdx = 0; diff --git a/tests/tests/PerformanceTest/PerformanceSpriteTest.cpp b/tests/tests/PerformanceTest/PerformanceSpriteTest.cpp index 22ac12bdf6..bb80ddca78 100644 --- a/tests/tests/PerformanceTest/PerformanceSpriteTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceSpriteTest.cpp @@ -1,8 +1,8 @@ #include "PerformanceSpriteTest.h" enum { - kMaxNodes = 5000, - kNodesIncrease = 50, + kMaxNodes = 50000, + kNodesIncrease = 250, TEST_COUNT = 7, }; diff --git a/tests/tests/controller.cpp b/tests/tests/controller.cpp index 84904394db..1f722aa004 100644 --- a/tests/tests/controller.cpp +++ b/tests/tests/controller.cpp @@ -81,8 +81,6 @@ static TestScene* CreateTestScene(int nIdx) pScene = new Box2dTestBedScene(); break; case TEST_EFFECT_ADVANCE: pScene = new EffectAdvanceScene(); break; - case TEST_HIRES: - pScene = new HiResTestScene(); break; case TEST_ACCELEROMRTER: pScene = new AccelerometerTestScene(); break; #if (CC_TARGET_PLATFORM != CC_PLATFORM_BADA) @@ -104,8 +102,6 @@ static TestScene* CreateTestScene(int nIdx) #endif case TEST_USERDEFAULT: pScene = new UserDefaultTestScene(); break; - case TEST_DIRECTOR: - pScene = new DirectorTestScene(); break; case TEST_BUGS: pScene = new BugsTestScene(); break; case TEST_FONTS: diff --git a/tests/tests/tests.h b/tests/tests/tests.h index d790dd5614..993be8bb71 100644 --- a/tests/tests/tests.h +++ b/tests/tests/tests.h @@ -27,7 +27,6 @@ #include "Box2DTest/Box2dTest.h" #include "Box2DTestBed/Box2dView.h" #include "EffectsAdvancedTest/EffectsAdvancedTest.h" -#include "HiResTest/HiResTest.h" #include "AccelerometerTest/AccelerometerTest.h" #include "KeypadTest/KeypadTest.h" #include "PerformanceTest/PerformanceTest.h" @@ -35,7 +34,6 @@ #include "CocosDenshionTest/CocosDenshionTest.h" #include "CurlTest/CurlTest.h" #include "UserDefaultTest/UserDefaultTest.h" -#include "DirectorTest/DirectorTest.h" #include "BugsTest/BugsTest.h" #include "Texture2dTest/Texture2dTest.h" #include "FontTest/FontTest.h" @@ -88,7 +86,6 @@ enum TEST_BOX2D, TEST_BOX2DBED, TEST_EFFECT_ADVANCE, - TEST_HIRES, TEST_ACCELEROMRTER, TEST_KEYPAD, TEST_COCOSDENSHION, @@ -96,7 +93,6 @@ enum TEST_ZWOPTEX, TEST_CURL, TEST_USERDEFAULT, - TEST_DIRECTOR, TEST_BUGS, TEST_FONTS, TEST_CURRENT_LANGUAGE, @@ -137,7 +133,6 @@ const std::string g_aTestNames[TESTS_COUNT] = { "Box2dTest", "Box2dTestBed", "EffectAdvancedTest", - "HiResTest", "Accelerometer", "KeypadTest", "CocosDenshionTest", @@ -145,7 +140,6 @@ const std::string g_aTestNames[TESTS_COUNT] = { "ZwoptexTest", "CurlTest", "UserDefaultTest", - "DirectorTest", "BugsTest", "FontTest", "CurrentLanguageTest", From 08fc714a7f208c08cbfabd4a3f8ce8f67db9628a Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Jun 2012 17:07:54 +0800 Subject: [PATCH 137/257] issue #1310: Reverted floatr to CCTimer. --- cocos2dx/CCScheduler.cpp | 34 ++++++++++----------- cocos2dx/CCScheduler.h | 12 ++++---- cocos2dx/script_support/CCScriptSupport.cpp | 2 +- cocos2dx/script_support/CCScriptSupport.h | 6 ++-- tests/tests/NodeTest/NodeTest.cpp | 2 +- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/cocos2dx/CCScheduler.cpp b/cocos2dx/CCScheduler.cpp index 1f486f6e89..72bcd0d762 100644 --- a/cocos2dx/CCScheduler.cpp +++ b/cocos2dx/CCScheduler.cpp @@ -63,15 +63,15 @@ typedef struct _hashSelectorEntry ccArray *timers; CCObject *target; // hash key (retained) unsigned int timerIndex; - floatr *currentTimer; + CCTimer *currentTimer; bool currentTimerSalvaged; bool paused; UT_hash_handle hh; } tHashSelectorEntry; -// implementation floatr +// implementation CCTimer -floatr::floatr() +CCTimer::CCTimer() : m_pfnSelector(NULL) , m_fInterval(0.0f) , m_pTarget(NULL) @@ -86,9 +86,9 @@ floatr::floatr() } -floatr* floatr::timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector) +CCTimer* CCTimer::timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector) { - floatr *pTimer = new floatr(); + CCTimer *pTimer = new CCTimer(); pTimer->initWithTarget(pTarget, pfnSelector, 0.0f, kCCRepeatForever, 0.0f); pTimer->autorelease(); @@ -96,9 +96,9 @@ floatr* floatr::timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector) return pTimer; } -floatr* floatr::timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, float fSeconds) +CCTimer* CCTimer::timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, float fSeconds) { - floatr *pTimer = new floatr(); + CCTimer *pTimer = new CCTimer(); pTimer->initWithTarget(pTarget, pfnSelector, fSeconds, kCCRepeatForever, 0.0f); pTimer->autorelease(); @@ -106,9 +106,9 @@ floatr* floatr::timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, flo return pTimer; } -floatr* floatr::timerWithScriptHandler(int nHandler, float fSeconds) +CCTimer* CCTimer::timerWithScriptHandler(int nHandler, float fSeconds) { - floatr *pTimer = new floatr(); + CCTimer *pTimer = new CCTimer(); pTimer->initWithScriptHandler(nHandler, fSeconds); pTimer->autorelease(); @@ -116,7 +116,7 @@ floatr* floatr::timerWithScriptHandler(int nHandler, float fSeconds) return pTimer; } -bool floatr::initWithScriptHandler(int nHandler, float fSeconds) +bool CCTimer::initWithScriptHandler(int nHandler, float fSeconds) { m_nScriptHandler = nHandler; m_fElapsed = -1; @@ -125,12 +125,12 @@ bool floatr::initWithScriptHandler(int nHandler, float fSeconds) return true; } -bool floatr::initWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector) +bool CCTimer::initWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector) { return initWithTarget(pTarget, pfnSelector, 0, kCCRepeatForever, 0.0f); } -bool floatr::initWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, float fSeconds, unsigned int nRepeat, float fDelay) +bool CCTimer::initWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, float fSeconds, unsigned int nRepeat, float fDelay) { m_pTarget = pTarget; m_pfnSelector = pfnSelector; @@ -143,7 +143,7 @@ bool floatr::initWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, float f return true; } -void floatr::update(float dt) +void CCTimer::update(float dt) { if (m_fElapsed == -1) { @@ -288,7 +288,7 @@ void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, { for (unsigned int i = 0; i < pElement->timers->num; ++i) { - floatr *timer = (floatr*)pElement->timers->arr[i]; + CCTimer *timer = (CCTimer*)pElement->timers->arr[i]; if (pfnSelector == timer->m_pfnSelector) { @@ -300,7 +300,7 @@ void CCScheduler::scheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget, ccArrayEnsureExtraCapacity(pElement->timers, 1); } - floatr *pTimer = new floatr(); + CCTimer *pTimer = new CCTimer(); pTimer->initWithTarget(pTarget, pfnSelector, fInterval, repeat, delay); ccArrayAppendObject(pElement->timers, pTimer); pTimer->release(); @@ -324,7 +324,7 @@ void CCScheduler::unscheduleSelector(SEL_SCHEDULE pfnSelector, CCObject *pTarget { for (unsigned int i = 0; i < pElement->timers->num; ++i) { - floatr *pTimer = (floatr*)(pElement->timers->arr[i]); + CCTimer *pTimer = (CCTimer*)(pElement->timers->arr[i]); if (pfnSelector == pTimer->m_pfnSelector) { @@ -795,7 +795,7 @@ void CCScheduler::update(float dt) // The 'timers' array may change while inside this loop for (elt->timerIndex = 0; elt->timerIndex < elt->timers->num; ++(elt->timerIndex)) { - elt->currentTimer = (floatr*)(elt->timers->arr[elt->timerIndex]); + elt->currentTimer = (CCTimer*)(elt->timers->arr[elt->timerIndex]); elt->currentTimerSalvaged = false; elt->currentTimer->update(dt); diff --git a/cocos2dx/CCScheduler.h b/cocos2dx/CCScheduler.h index 5ae548f980..a2e36f6c65 100644 --- a/cocos2dx/CCScheduler.h +++ b/cocos2dx/CCScheduler.h @@ -40,13 +40,13 @@ NS_CC_BEGIN class CCSet; // -// floatr +// CCTimer // /** @brief Light weight timer */ -class CC_DLL floatr : public CCObject +class CC_DLL CCTimer : public CCObject { public: - floatr(void); + CCTimer(void); /** get interval in seconds */ inline float getInterval(void) { return m_fInterval; } @@ -67,13 +67,13 @@ public: public: /** Allocates a timer with a target and a selector. */ - static floatr* timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector); + static CCTimer* timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector); /** Allocates a timer with a target, a selector and an interval in seconds. */ - static floatr* timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, float fSeconds); + static CCTimer* timerWithTarget(CCObject *pTarget, SEL_SCHEDULE pfnSelector, float fSeconds); /** Allocates a timer with a script callback function and an interval in seconds. */ - static floatr* timerWithScriptHandler(int nHandler, float fSeconds); + static CCTimer* timerWithScriptHandler(int nHandler, float fSeconds); public: SEL_SCHEDULE m_pfnSelector; diff --git a/cocos2dx/script_support/CCScriptSupport.cpp b/cocos2dx/script_support/CCScriptSupport.cpp index 957c380de3..241d0aeafe 100644 --- a/cocos2dx/script_support/CCScriptSupport.cpp +++ b/cocos2dx/script_support/CCScriptSupport.cpp @@ -37,7 +37,7 @@ CCSchedulerScriptHandlerEntry* CCSchedulerScriptHandlerEntry::entryWithHandler(i bool CCSchedulerScriptHandlerEntry::initWithHandler(int nHandler, float fInterval, bool bPaused) { - m_pTimer = new floatr(); + m_pTimer = new CCTimer(); m_pTimer->initWithScriptHandler(nHandler, fInterval); m_pTimer->autorelease(); m_pTimer->retain(); diff --git a/cocos2dx/script_support/CCScriptSupport.h b/cocos2dx/script_support/CCScriptSupport.h index 213e527ef2..d7c1494897 100644 --- a/cocos2dx/script_support/CCScriptSupport.h +++ b/cocos2dx/script_support/CCScriptSupport.h @@ -33,7 +33,7 @@ typedef struct lua_State lua_State; NS_CC_BEGIN -class floatr; +class CCTimer; // Lua support for CCScheduler class CCSchedulerScriptHandlerEntry : public CCObject @@ -43,7 +43,7 @@ public: static CCSchedulerScriptHandlerEntry* entryWithHandler(int nHandler, float fInterval, bool bPaused); ~CCSchedulerScriptHandlerEntry(void); - inline cocos2d::floatr* getTimer(void) { + inline cocos2d::CCTimer* getTimer(void) { return m_pTimer; } @@ -67,7 +67,7 @@ private: CCSchedulerScriptHandlerEntry(void); bool initWithHandler(int nHandler, float fInterval, bool bPaused); - cocos2d::floatr* m_pTimer; + cocos2d::CCTimer* m_pTimer; bool m_bPaused; bool m_bMarkedForDeletion; int m_nHandler; diff --git a/tests/tests/NodeTest/NodeTest.cpp b/tests/tests/NodeTest/NodeTest.cpp index bf47994156..dac460e3ab 100644 --- a/tests/tests/NodeTest/NodeTest.cpp +++ b/tests/tests/NodeTest/NodeTest.cpp @@ -482,7 +482,7 @@ SchedulerTest1::SchedulerTest1() //UXLOG("retain count after addChild is %d", layer->retainCount()); // 2 layer->schedule( schedule_selector(SchedulerTest1::doSomething) ); - //UXLOG("retain count after schedule is %d", layer->retainCount()); // 3 : (object-c viersion), but win32 version is still 2, because floatr class don't save target. + //UXLOG("retain count after schedule is %d", layer->retainCount()); // 3 : (object-c viersion), but win32 version is still 2, because CCTimer class don't save target. layer->unschedule(schedule_selector(SchedulerTest1::doSomething)); //UXLOG("retain count after unschedule is %d", layer->retainCount()); // STILL 3! (win32 is '2') From dab90107b9ac253d7a748482e07385ca84b6b03e Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Jun 2012 18:12:45 +0800 Subject: [PATCH 138/257] issue #1310: Updated SchedulerTest. --- tests/tests/SchedulerTest/SchedulerTest.cpp | 262 +++++++++++++++++++- tests/tests/SchedulerTest/SchedulerTest.h | 53 ++++ 2 files changed, 303 insertions(+), 12 deletions(-) diff --git a/tests/tests/SchedulerTest/SchedulerTest.cpp b/tests/tests/SchedulerTest/SchedulerTest.cpp index 0a8163dba8..5c1f5cc97d 100644 --- a/tests/tests/SchedulerTest/SchedulerTest.cpp +++ b/tests/tests/SchedulerTest/SchedulerTest.cpp @@ -5,7 +5,7 @@ enum { kTagAnimationDance = 1, }; -#define MAX_TESTS 11 +#define MAX_TESTS 13 static int sceneIdx = -1; CCLayer* nextSchedulerTest(); @@ -29,16 +29,20 @@ CCLayer* createSchedulerTest(int nIndex) case 4: pLayer = new SchedulerPauseResume(); break; case 5: - pLayer = new SchedulerUnscheduleAll(); break; + pLayer = new SchedulerPauseResumeAll(); break; case 6: - pLayer = new SchedulerUnscheduleAllHard(); break; + pLayer = new SchedulerUnscheduleAll(); break; case 7: - pLayer = new SchedulerSchedulesAndRemove(); break; + pLayer = new SchedulerUnscheduleAllHard(); break; case 8: - pLayer = new SchedulerUpdate(); break; + pLayer = new SchedulerUnscheduleAllUserLevel(); break; case 9: - pLayer = new SchedulerUpdateAndCustom(); break; + pLayer = new SchedulerSchedulesAndRemove(); break; case 10: + pLayer = new SchedulerUpdate(); break; + case 11: + pLayer = new SchedulerUpdateAndCustom(); break; + case 12: pLayer = new SchedulerUpdateFromCustom(); break; default: break; @@ -100,9 +104,9 @@ void SchedulerTestLayer::onEnter() CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); menu->setPosition(CCPointZero); - item1->setPosition(ccp( s.width/2 - 100,30)); - item2->setPosition(ccp( s.width/2, 30)); - item3->setPosition(ccp( s.width/2 + 100,30)); + item1->setPosition(ccp( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2)); + item2->setPosition(ccp( s.width/2, item2->getContentSize().height/2)); + item3->setPosition(ccp( s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2)); addChild(menu, 1); } @@ -227,6 +231,163 @@ std::string SchedulerPauseResume::subtitle() return "Scheduler should be paused after 3 seconds. See console"; } +//------------------------------------------------------------------ +// +// SchedulerPauseResumeAll +// +//------------------------------------------------------------------ + +SchedulerPauseResumeAll::SchedulerPauseResumeAll() +: m_pPausedTargets(NULL) +{ + +} + +SchedulerPauseResumeAll::~SchedulerPauseResumeAll() +{ + CC_SAFE_RELEASE(m_pPausedTargets); +} + +void SchedulerPauseResumeAll::onEnter() +{ + SchedulerTestLayer::onEnter(); + + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCSprite *sprite = CCSprite::spriteWithFile("Images/grossinis_sister1.png"); + sprite->setPosition(ccp(s.width/2, s.height/2)); + this->addChild(sprite); + sprite->runAction(CCRepeatForever::actionWithAction(CCRotateBy::actionWithDuration(3.0, 360))); + + schedule(schedule_selector(SchedulerPauseResumeAll::tick1), 0.5f); + schedule(schedule_selector(SchedulerPauseResumeAll::tick2), 1.0f); + schedule(schedule_selector(SchedulerPauseResumeAll::pause), 3.0f, false, 0); + //TODO: [self performSelector:@selector(resume) withObject:nil afterDelay:5]; +} + +void SchedulerPauseResumeAll::onExit() +{ + if(m_pPausedTargets != NULL) + { + CCDirector::sharedDirector()->getScheduler()->resumeTargets(m_pPausedTargets); + } +} + +void SchedulerPauseResumeAll::tick1(float dt) +{ + CCLog("tick1"); +} + +void SchedulerPauseResumeAll::tick2(float dt) +{ + CCLog("tick2"); +} + +void SchedulerPauseResumeAll::pause(float dt) +{ + CCLog("Pausing"); + CCDirector* pDirector = CCDirector::sharedDirector(); + m_pPausedTargets = pDirector->getScheduler()->pauseAllTargets(); + CC_SAFE_RETAIN(m_pPausedTargets); +} + +void SchedulerPauseResumeAll::resume(float dt) +{ + CCLog("Resuming"); + CCDirector* pDirector = CCDirector::sharedDirector(); + pDirector->getScheduler()->resumeTargets(m_pPausedTargets); + CC_SAFE_RELEASE_NULL(m_pPausedTargets); +} + +std::string SchedulerPauseResumeAll::title() +{ + return "Pause / Resume"; +} + +std::string SchedulerPauseResumeAll::subtitle() +{ + return "Everything will pause after 3s, then resume at 5s. See console"; +} + +//------------------------------------------------------------------ +// +// SchedulerPauseResumeAllUser +// +//------------------------------------------------------------------ + +SchedulerPauseResumeAllUser::SchedulerPauseResumeAllUser() +: m_pPausedTargets(NULL) +{ + +} + +SchedulerPauseResumeAllUser::~SchedulerPauseResumeAllUser() +{ + CC_SAFE_RELEASE(m_pPausedTargets); +} + +void SchedulerPauseResumeAllUser::onEnter() +{ + SchedulerTestLayer::onEnter(); + + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCSprite *sprite = CCSprite::spriteWithFile("Images/grossinis_sister1.png"); + sprite->setPosition(ccp(s.width/2, s.height/2)); + this->addChild(sprite); + sprite->runAction(CCRepeatForever::actionWithAction(CCRotateBy::actionWithDuration(3.0, 360))); + + schedule(schedule_selector(SchedulerPauseResumeAllUser::tick1), 0.5f); + schedule(schedule_selector(SchedulerPauseResumeAllUser::tick2), 1.0f); + schedule(schedule_selector(SchedulerPauseResumeAllUser::pause), 3.0f, false, 0); + //TODO: [self performSelector:@selector(resume) withObject:nil afterDelay:5]; +} + +void SchedulerPauseResumeAllUser::onExit() +{ + if(m_pPausedTargets != NULL) + { + CCDirector::sharedDirector()->getScheduler()->resumeTargets(m_pPausedTargets); + } +} + +void SchedulerPauseResumeAllUser::tick1(float dt) +{ + CCLog("tick1"); +} + +void SchedulerPauseResumeAllUser::tick2(float dt) +{ + CCLog("tick2"); +} + +void SchedulerPauseResumeAllUser::pause(float dt) +{ + CCLog("Pausing"); + CCDirector* pDirector = CCDirector::sharedDirector(); + m_pPausedTargets = pDirector->getScheduler()->pauseAllTargetsWithMinPriority(kCCPriorityNonSystemMin); + CC_SAFE_RETAIN(m_pPausedTargets); +} + +void SchedulerPauseResumeAllUser::resume(float dt) +{ + CCLog("Resuming"); + CCDirector* pDirector = CCDirector::sharedDirector(); + pDirector->getScheduler()->resumeTargets(m_pPausedTargets); + CC_SAFE_RELEASE_NULL(m_pPausedTargets); +} + +std::string SchedulerPauseResumeAllUser::title() +{ + return "Pause / Resume"; +} + +std::string SchedulerPauseResumeAllUser::subtitle() +{ + return "Everything will pause after 3s, then resume at 5s. See console"; +} + + //------------------------------------------------------------------ // // SchedulerUnscheduleAll @@ -287,6 +448,15 @@ void SchedulerUnscheduleAllHard::onEnter() { SchedulerTestLayer::onEnter(); + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCSprite *sprite = CCSprite::spriteWithFile("Images/grossinis_sister1.png"); + sprite->setPosition(ccp(s.width/2, s.height/2)); + this->addChild(sprite); + sprite->runAction(CCRepeatForever::actionWithAction(CCRotateBy::actionWithDuration(3.0, 360))); + + m_bActionManagerActive = true; + schedule(schedule_selector(SchedulerUnscheduleAllHard::tick1), 0.5f); schedule(schedule_selector(SchedulerUnscheduleAllHard::tick2), 1.0f); schedule(schedule_selector(SchedulerUnscheduleAllHard::tick3), 1.5f); @@ -294,6 +464,15 @@ void SchedulerUnscheduleAllHard::onEnter() schedule(schedule_selector(SchedulerUnscheduleAllHard::unscheduleAll), 4); } +void SchedulerUnscheduleAllHard::onExit() +{ + if(!m_bActionManagerActive) { + // Restore the director's action manager. + CCDirector* director = CCDirector::sharedDirector(); + director->getScheduler()->scheduleUpdateForTarget(director->getActionManager(), kCCPrioritySystem, false); + } +} + void SchedulerUnscheduleAllHard::tick1(float dt) { CCLOG("tick1"); @@ -317,16 +496,75 @@ void SchedulerUnscheduleAllHard::tick4(float dt) void SchedulerUnscheduleAllHard::unscheduleAll(float dt) { CCDirector::sharedDirector()->getScheduler()->unscheduleAllSelectors(); + m_bActionManagerActive = false; } std::string SchedulerUnscheduleAllHard::title() { - return "Unschedule All selectors #2"; + return "Unschedule All selectors (HARD)"; } std::string SchedulerUnscheduleAllHard::subtitle() { - return "Unschedules all selectors after 4s. Uses CCScheduler. See console"; + return "Unschedules all user selectors after 4s. Action will stop. See console"; +} + +//------------------------------------------------------------------ +// +// SchedulerUnscheduleAllUserLevel +// +//------------------------------------------------------------------ +void SchedulerUnscheduleAllUserLevel::onEnter() +{ + SchedulerTestLayer::onEnter(); + + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCSprite *sprite = CCSprite::spriteWithFile("Images/grossinis_sister1.png"); + sprite->setPosition(ccp(s.width/2, s.height/2)); + this->addChild(sprite); + sprite->runAction(CCRepeatForever::actionWithAction(CCRotateBy::actionWithDuration(3.0, 360))); + + schedule(schedule_selector(SchedulerUnscheduleAllUserLevel::tick1), 0.5f); + schedule(schedule_selector(SchedulerUnscheduleAllUserLevel::tick2), 1.0f); + schedule(schedule_selector(SchedulerUnscheduleAllUserLevel::tick3), 1.5f); + schedule(schedule_selector(SchedulerUnscheduleAllUserLevel::tick4), 1.5f); + schedule(schedule_selector(SchedulerUnscheduleAllUserLevel::unscheduleAll), 4); +} + +void SchedulerUnscheduleAllUserLevel::tick1(float dt) +{ + CCLOG("tick1"); +} + +void SchedulerUnscheduleAllUserLevel::tick2(float dt) +{ + CCLOG("tick2"); +} + +void SchedulerUnscheduleAllUserLevel::tick3(float dt) +{ + CCLOG("tick3"); +} + +void SchedulerUnscheduleAllUserLevel::tick4(float dt) +{ + CCLOG("tick4"); +} + +void SchedulerUnscheduleAllUserLevel::unscheduleAll(float dt) +{ + CCDirector::sharedDirector()->getScheduler()->unscheduleAllSelectorsWithMinPriority(kCCPriorityNonSystemMin); +} + +std::string SchedulerUnscheduleAllUserLevel::title() +{ + return "Unschedule All user selectors"; +} + +std::string SchedulerUnscheduleAllUserLevel::subtitle() +{ + return "Unschedules all user selectors after 4s. Action should not stop. See console"; } //------------------------------------------------------------------ @@ -588,7 +826,7 @@ void RescheduleSelector::schedUpdate(float dt) { m_nTicks++; - CCLOG("schedUpdate: %.2f", dt); + CCLOG("schedUpdate: %.4f", dt); if ( m_nTicks > 3 ) { m_fInterval += 1.0f; diff --git a/tests/tests/SchedulerTest/SchedulerTest.h b/tests/tests/SchedulerTest/SchedulerTest.h index f84899375f..0dc4eec257 100644 --- a/tests/tests/SchedulerTest/SchedulerTest.h +++ b/tests/tests/SchedulerTest/SchedulerTest.h @@ -54,6 +54,42 @@ public: void pause(float dt); }; +class SchedulerPauseResumeAll : public SchedulerTestLayer +{ +public: + SchedulerPauseResumeAll(); + virtual ~SchedulerPauseResumeAll(); + virtual void onEnter(); + virtual void onExit(); + virtual std::string title(); + virtual std::string subtitle(); + + void tick1(float dt); + void tick2(float dt); + void pause(float dt); + void resume(float dt); +private: + CCSet* m_pPausedTargets; +}; + +class SchedulerPauseResumeAllUser : public SchedulerTestLayer +{ +public: + SchedulerPauseResumeAllUser(); + virtual ~SchedulerPauseResumeAllUser(); + virtual void onEnter(); + virtual void onExit(); + virtual std::string title(); + virtual std::string subtitle(); + + void tick1(float dt); + void tick2(float dt); + void pause(float dt); + void resume(float dt); +private: + CCSet* m_pPausedTargets; +}; + class SchedulerUnscheduleAll : public SchedulerTestLayer { public: @@ -70,6 +106,23 @@ public: class SchedulerUnscheduleAllHard : public SchedulerTestLayer { +public: + virtual void onEnter(); + virtual void onExit(); + virtual std::string title(); + virtual std::string subtitle(); + + void tick1(float dt); + void tick2(float dt); + void tick3(float dt); + void tick4(float dt); + void unscheduleAll(float dt); +private: + bool m_bActionManagerActive; +}; + +class SchedulerUnscheduleAllUserLevel : public SchedulerTestLayer +{ public: virtual void onEnter(); virtual std::string title(); From 2be8ba120c88a8f8d13ba526e2736a69d8f2ceef Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Jun 2012 18:15:25 +0800 Subject: [PATCH 139/257] issue #1310: Updated vs2008 project setting. --- tests/proj.win32/test.win32.vcproj | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/tests/proj.win32/test.win32.vcproj b/tests/proj.win32/test.win32.vcproj index 501f7bdc80..8bd845e672 100644 --- a/tests/proj.win32/test.win32.vcproj +++ b/tests/proj.win32/test.win32.vcproj @@ -519,18 +519,6 @@ > - - - - - - @@ -655,18 +643,6 @@ > - - - - - - From e943dbf2fda3e84f761aa93beae63074ae423b9e Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Jun 2012 18:22:48 +0800 Subject: [PATCH 140/257] issue #1310: Updated TileMapTest, TransitionsTest, ZwoptexTest. --- tests/tests/TileMapTest/TileMapTest.cpp | 6 +++--- tests/tests/TransitionsTest/TransitionsTest.cpp | 12 ++++++------ tests/tests/ZwoptexTest/ZwoptexTest.cpp | 6 +++--- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/tests/TileMapTest/TileMapTest.cpp b/tests/tests/TileMapTest/TileMapTest.cpp index 799b0bda2e..0a608a6e5f 100644 --- a/tests/tests/TileMapTest/TileMapTest.cpp +++ b/tests/tests/TileMapTest/TileMapTest.cpp @@ -1456,9 +1456,9 @@ TileDemo::TileDemo(void) CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); menu->setPosition( CCPointZero ); - item1->setPosition( ccp( s.width/2 - 100,30) ); - item2->setPosition( ccp( s.width/2, 30) ); - item3->setPosition( ccp( s.width/2 + 100,30) ); + item1->setPosition( ccp( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2) ); + item2->setPosition( ccp( s.width/2, item2->getContentSize().height/2) ); + item3->setPosition( ccp( s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2) ); addChild(menu, 1); } diff --git a/tests/tests/TransitionsTest/TransitionsTest.cpp b/tests/tests/TransitionsTest/TransitionsTest.cpp index 079eae62b9..d7060a888a 100644 --- a/tests/tests/TransitionsTest/TransitionsTest.cpp +++ b/tests/tests/TransitionsTest/TransitionsTest.cpp @@ -304,9 +304,9 @@ TestLayer1::TestLayer1(void) CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); menu->setPosition( CCPointZero ); - item1->setPosition( CCPointMake( size.width/2 - 100,30) ); - item2->setPosition( CCPointMake( size.width/2, 30) ); - item3->setPosition( CCPointMake( size.width/2 + 100,30) ); + item1->setPosition( ccp( size.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2) ); + item2->setPosition( ccp( size.width/2, item2->getContentSize().height/2) ); + item3->setPosition( ccp( size.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2) ); addChild(menu, 1); @@ -433,9 +433,9 @@ TestLayer2::TestLayer2() CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); menu->setPosition( CCPointZero ); - item1->setPosition( CCPointMake( x/2 - 100,30) ); - item2->setPosition( CCPointMake( x/2, 30) ); - item3->setPosition( CCPointMake( x/2 + 100,30) ); + item1->setPosition( ccp( size.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2) ); + item2->setPosition( ccp( size.width/2, item2->getContentSize().height/2) ); + item3->setPosition( ccp( size.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2) ); addChild(menu, 1); diff --git a/tests/tests/ZwoptexTest/ZwoptexTest.cpp b/tests/tests/ZwoptexTest/ZwoptexTest.cpp index 77e23098a8..78fe99e4bf 100644 --- a/tests/tests/ZwoptexTest/ZwoptexTest.cpp +++ b/tests/tests/ZwoptexTest/ZwoptexTest.cpp @@ -81,9 +81,9 @@ void ZwoptexTest::onEnter() CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); menu->setPosition(CCPointZero); - item1->setPosition(ccp( s.width/2 - 100,30)); - item2->setPosition(ccp( s.width/2, 30)); - item3->setPosition(ccp( s.width/2 + 100,30)); + item1->setPosition( ccp( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2) ); + item2->setPosition( ccp( s.width/2, item2->getContentSize().height/2) ); + item3->setPosition( ccp( s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2) ); addChild(menu, 1); } From d2a16c2b76305e69bbf89987cf3a70b63f26c679 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 12 Jun 2012 18:27:36 +0800 Subject: [PATCH 141/257] issue #1310: Updated MotionStreakTest. --- tests/tests/MotionStreakTest/MotionStreakTest.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests/MotionStreakTest/MotionStreakTest.cpp b/tests/tests/MotionStreakTest/MotionStreakTest.cpp index f1eef8fff9..20e3670e56 100644 --- a/tests/tests/MotionStreakTest/MotionStreakTest.cpp +++ b/tests/tests/MotionStreakTest/MotionStreakTest.cpp @@ -119,7 +119,7 @@ void Issue1358::onEnter() // ask director the the window size CCSize size = CCDirector::sharedDirector()->getWinSize(); - streak = CCMotionStreak::streakWithFade(2.0f, 1.0f, 50.0f, ccc3(255, 255, 0), "Icon.png"); + streak = CCMotionStreak::streakWithFade(2.0f, 1.0f, 50.0f, ccc3(255, 255, 0), "Images/Icon.png"); addChild(streak); From 26d470f411e8ec37f520a8c50180df481290a406 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Tue, 12 Jun 2012 11:30:36 -0700 Subject: [PATCH 142/257] CCLabelTTFLoader: Now applying vertical alignment. --- cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp b/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp index 3e845d21b3..748576614f 100644 --- a/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp @@ -69,8 +69,7 @@ void CCLabelTTFLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * p if(strcmp(pPropertyName, PROPERTY_HORIZONTALALIGNMENT) == 0) { ((CCLabelTTF *)pNode)->setHorizontalAlignment(CCTextAlignment(pIntegerLabeled)); } else if(strcmp(pPropertyName, PROPERTY_VERTICALALIGNMENT) == 0) { - // TODO Add support when CCLabelTTF supports it. ( See: 63d9724ac4d81a05c6ec7feea0c01bcd27c8fc6b ) - // ((CCLabelTTF *)pNode)->setVerticalAlignment(pIntegerLabeled); + ((CCLabelTTF *)pNode)->setVerticalAlignment(CCVerticalTextAlignment(pIntegerLabeled)); } else { CCNodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader); } From 895604f42ec86175e15b2a65dec872d7d0ca6368 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Tue, 12 Jun 2012 11:59:49 -0700 Subject: [PATCH 143/257] Unified Header Guards. Added CCNodeLoaderListener, simulating the didLoadFromCCB selector. --- .../extensions/CCBIReader/CCBFileLoader.cpp | 2 +- .../extensions/CCBIReader/CCBFileLoader.h | 4 ++-- .../CCBIReader/CCBMemberVariableAssigner.h | 4 ++-- cocos2dx/extensions/CCBIReader/CCBReader.cpp | 19 ++++++++++++------- cocos2dx/extensions/CCBIReader/CCBReader.h | 12 +++++++----- .../CCBIReader/CCBSelectorResolver.h | 4 ++-- .../CCBIReader/CCControlButtonLoader.cpp | 2 +- .../CCBIReader/CCControlButtonLoader.h | 4 ++-- .../extensions/CCBIReader/CCControlLoader.cpp | 2 +- .../extensions/CCBIReader/CCControlLoader.h | 4 ++-- .../CCBIReader/CCLabelBMFontLoader.cpp | 2 +- .../CCBIReader/CCLabelBMFontLoader.h | 4 ++-- .../CCBIReader/CCLabelTTFLoader.cpp | 2 +- .../extensions/CCBIReader/CCLabelTTFLoader.h | 4 ++-- .../CCBIReader/CCLayerColorLoader.cpp | 2 +- .../CCBIReader/CCLayerColorLoader.h | 4 ++-- .../CCBIReader/CCLayerGradientLoader.cpp | 2 +- .../CCBIReader/CCLayerGradientLoader.h | 4 ++-- .../extensions/CCBIReader/CCLayerLoader.cpp | 2 +- .../extensions/CCBIReader/CCLayerLoader.h | 4 ++-- .../CCBIReader/CCMenuItemImageLoader .cpp | 2 +- .../CCBIReader/CCMenuItemImageLoader.h | 4 ++-- .../CCBIReader/CCMenuItemLoader.cpp | 2 +- .../extensions/CCBIReader/CCMenuItemLoader.h | 4 ++-- .../extensions/CCBIReader/CCMenuLoader.cpp | 2 +- cocos2dx/extensions/CCBIReader/CCMenuLoader.h | 4 ++-- .../extensions/CCBIReader/CCNodeLoader.cpp | 3 ++- cocos2dx/extensions/CCBIReader/CCNodeLoader.h | 4 ++-- .../CCBIReader/CCNodeLoaderLibrary.h | 4 ++-- .../CCBIReader/CCNodeLoaderListener.h | 17 +++++++++++++++++ .../CCBIReader/CCParticleSystemQuadLoader.cpp | 2 +- .../CCBIReader/CCParticleSystemQuadLoader.h | 4 ++-- .../CCBIReader/CCScale9SpriteLoader.cpp | 2 +- .../CCBIReader/CCScale9SpriteLoader.h | 4 ++-- .../extensions/CCBIReader/CCSpriteLoader.cpp | 2 +- .../extensions/CCBIReader/CCSpriteLoader.h | 4 ++-- .../project.pbxproj.REMOVED.git-id | 2 +- 37 files changed, 89 insertions(+), 64 deletions(-) create mode 100644 cocos2dx/extensions/CCBIReader/CCNodeLoaderListener.h diff --git a/cocos2dx/extensions/CCBIReader/CCBFileLoader.cpp b/cocos2dx/extensions/CCBIReader/CCBFileLoader.cpp index 292278626b..45493f4fc3 100644 --- a/cocos2dx/extensions/CCBIReader/CCBFileLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCBFileLoader.cpp @@ -1,4 +1,4 @@ -#import "CCBFileLoader.h" +#include "CCBFileLoader.h" using namespace cocos2d; using namespace cocos2d::extension; diff --git a/cocos2dx/extensions/CCBIReader/CCBFileLoader.h b/cocos2dx/extensions/CCBIReader/CCBFileLoader.h index 0a33589d79..5e644d65d6 100644 --- a/cocos2dx/extensions/CCBIReader/CCBFileLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCBFileLoader.h @@ -1,5 +1,5 @@ -#ifndef _CCBFILE_LOADER_H_ -#define _CCBFILE_LOADER_H_ +#ifndef _CCB_CCBFILELOADER_H_ +#define _CCB_CCBFILELOADER_H_ #include "CCNodeLoader.h" diff --git a/cocos2dx/extensions/CCBIReader/CCBMemberVariableAssigner.h b/cocos2dx/extensions/CCBIReader/CCBMemberVariableAssigner.h index d992c1acf1..0ddc70f0bf 100644 --- a/cocos2dx/extensions/CCBIReader/CCBMemberVariableAssigner.h +++ b/cocos2dx/extensions/CCBIReader/CCBMemberVariableAssigner.h @@ -1,5 +1,5 @@ -#ifndef _CCB_MEMBERVARIABLEASSIGNER_H_ -#define _CCB_MEMBERVARIABLEASSIGNER_H_ +#ifndef _CCB_CCBMEMBERVARIABLEASSIGNER_H_ +#define _CCB_CCBMEMBERVARIABLEASSIGNER_H_ #include "cocos2d.h" diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.cpp b/cocos2dx/extensions/CCBIReader/CCBReader.cpp index 0f880e6017..3fca7b3c18 100644 --- a/cocos2dx/extensions/CCBIReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCBReader.cpp @@ -2,21 +2,26 @@ #include "CCNodeLoader.h" #include "CCNodeLoaderLibrary.h" +#include "CCNodeLoaderListener.h" +#include "CCBMemberVariableAssigner.h" +#include "CCBSelectorResolver.h" #ifdef __CC_PLATFORM_IOS -#import +#include #endif using namespace cocos2d; using namespace cocos2d::extension; -CCBReader::CCBReader(CCNodeLoaderLibrary * pCCNodeLoaderLibrary, CCBMemberVariableAssigner * pCCBMemberVariableAssigner, CCBSelectorResolver * pCCBSelectorResolver) { +CCBReader::CCBReader(CCNodeLoaderLibrary * pCCNodeLoaderLibrary, CCBMemberVariableAssigner * pCCBMemberVariableAssigner, CCBSelectorResolver * pCCBSelectorResolver, CCNodeLoaderListener * pCCNodeLoaderListener) { this->mRootNode = NULL; this->mRootCCBReader = true; this->mCCNodeLoaderLibrary = pCCNodeLoaderLibrary; + this->mCCNodeLoaderLibrary->retain(); this->mCCBMemberVariableAssigner = pCCBMemberVariableAssigner; this->mCCBSelectorResolver = pCCBSelectorResolver; + this->mCCNodeLoaderListener = pCCNodeLoaderListener; this->mResolutionScale = 1; @@ -34,6 +39,8 @@ CCBReader::~CCBReader() { this->mBytes = NULL; } + this->mCCNodeLoaderLibrary->release(); + /* Clear string cache. */ this->mStringCache.clear(); @@ -57,6 +64,7 @@ CCBReader::CCBReader(CCBReader * pCCBReader) { this->mCCNodeLoaderLibrary = pCCBReader->mCCNodeLoaderLibrary; this->mCCBMemberVariableAssigner = pCCBReader->mCCBMemberVariableAssigner; this->mCCBSelectorResolver = pCCBReader->mCCBSelectorResolver; + this->mCCNodeLoaderListener = pCCBReader->mCCNodeLoaderListener; } std::string CCBReader::getCCBRootPath() { @@ -296,12 +304,9 @@ CCNode * CCBReader::readNodeGraph(CCNode * pParent) { node->addChild(child); } - // TODO - /* - if([node respondsToSelector:@selector(didLoadFromCCB)]) { - [node performSelector:@selector(didLoadFromCCB)]; + if(this->mCCNodeLoaderListener != NULL) { + this->mCCNodeLoaderListener->onNodeLoaded(node, ccNodeLoader); } - */ return node; } diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.h b/cocos2dx/extensions/CCBIReader/CCBReader.h index 2adb5a00f2..6216987818 100644 --- a/cocos2dx/extensions/CCBIReader/CCBReader.h +++ b/cocos2dx/extensions/CCBIReader/CCBReader.h @@ -1,9 +1,7 @@ -#ifndef _CCB_READER_H_ -#define _CCB_READER_H_ +#ifndef _CCB_CCBREADER_H_ +#define _CCB_CCBREADER_H_ #include "cocos2d.h" -#include "CCBMemberVariableAssigner.h" -#include "CCBSelectorResolver.h" #define STATIC_NEW_AUTORELEASE_OBJECT_METHOD(T, METHOD) static T * METHOD() { \ T * t = new T(); \ @@ -77,6 +75,9 @@ NS_CC_EXT_BEGIN /* Forward declaration. */ class CCNodeLoader; class CCNodeLoaderLibrary; +class CCNodeLoaderListener; +class CCBMemberVariableAssigner; +class CCBSelectorResolver; /** * @brief Parse CCBI file which is generated by CocosBuilder @@ -95,6 +96,7 @@ class CC_DLL CCBReader : public CCObject { float mResolutionScale; CCNodeLoaderLibrary * mCCNodeLoaderLibrary; + CCNodeLoaderListener * mCCNodeLoaderListener; CCBMemberVariableAssigner * mCCBMemberVariableAssigner; CCBSelectorResolver * mCCBSelectorResolver; @@ -103,7 +105,7 @@ class CC_DLL CCBReader : public CCObject { public: /* Constructor. */ - CCBReader(CCNodeLoaderLibrary *, CCBMemberVariableAssigner * = NULL, CCBSelectorResolver * = NULL); + CCBReader(CCNodeLoaderLibrary *, CCBMemberVariableAssigner * = NULL, CCBSelectorResolver * = NULL, CCNodeLoaderListener * = NULL); CCBReader(CCBReader *); /* Destructor. */ ~CCBReader(); diff --git a/cocos2dx/extensions/CCBIReader/CCBSelectorResolver.h b/cocos2dx/extensions/CCBIReader/CCBSelectorResolver.h index dccf75df52..a29faec091 100644 --- a/cocos2dx/extensions/CCBIReader/CCBSelectorResolver.h +++ b/cocos2dx/extensions/CCBIReader/CCBSelectorResolver.h @@ -1,5 +1,5 @@ -#ifndef _CCB_SELECTORRESOLVER_H_ -#define _CCB_SELECTORRESOLVER_H_ +#ifndef _CCB_CCBSELECTORRESOLVER_H_ +#define _CCB_CCBSELECTORRESOLVER_H_ #include "cocos2d.h" diff --git a/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.cpp b/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.cpp index 25381324fd..b3ca5b6a6c 100644 --- a/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.cpp @@ -1,4 +1,4 @@ -#import "CCControlButtonLoader.h" +#include "CCControlButtonLoader.h" using namespace cocos2d; using namespace cocos2d::extension; diff --git a/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.h b/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.h index 6651bb0bd7..91ca8c00d3 100644 --- a/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.h @@ -1,5 +1,5 @@ -#ifndef _CCCONTROLBUTTON_LOADER_H_ -#define _CCCONTROLBUTTON_LOADER_H_ +#ifndef _CCB_CCCONTROLBUTTONLOADER_H_ +#define _CCB_CCCONTROLBUTTONLOADER_H_ #include "CCControlLoader.h" diff --git a/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp b/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp index 606ea29541..293c1c564c 100644 --- a/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp @@ -1,4 +1,4 @@ -#import "CCControlLoader.h" +#include "CCControlLoader.h" using namespace cocos2d; using namespace cocos2d::extension; diff --git a/cocos2dx/extensions/CCBIReader/CCControlLoader.h b/cocos2dx/extensions/CCBIReader/CCControlLoader.h index a018602001..4638cf5ac4 100644 --- a/cocos2dx/extensions/CCBIReader/CCControlLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCControlLoader.h @@ -1,5 +1,5 @@ -#ifndef _CCCONTROL_LOADER_H_ -#define _CCCONTROL_LOADER_H_ +#ifndef _CCB_CCCONTROLLOADER_H_ +#define _CCB_CCCONTROLLOADER_H_ #include "CCNodeLoader.h" diff --git a/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.cpp b/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.cpp index 3b19d8acab..d95506544c 100644 --- a/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.cpp @@ -1,4 +1,4 @@ -#import "CCLabelBMFontLoader.h" +#include "CCLabelBMFontLoader.h" using namespace cocos2d; using namespace cocos2d::extension; diff --git a/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h b/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h index 4731e818f8..582b11beb5 100644 --- a/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h @@ -1,5 +1,5 @@ -#ifndef _CCLABELBMFONT_LOADER_H_ -#define _CCLABELBMFONT_LOADER_H_ +#ifndef _CCB_CCLABELBMFONTLOADER_H_ +#define _CCB_CCLABELBMFONTLOADER_H_ #include "CCNodeLoader.h" diff --git a/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp b/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp index 748576614f..d38949b80f 100644 --- a/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp @@ -1,4 +1,4 @@ -#import "CCLabelTTFLoader.h" +#include "CCLabelTTFLoader.h" using namespace cocos2d; using namespace cocos2d::extension; diff --git a/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.h b/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.h index 224f62302b..04ee0bc641 100644 --- a/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.h @@ -1,5 +1,5 @@ -#ifndef _CCLABELTTF_LOADER_H_ -#define _CCLABELTTF_LOADER_H_ +#ifndef _CCB_CCLABELTTFLOADER_H_ +#define _CCB_CCLABELTTFLOADER_H_ #include "CCNodeLoader.h" diff --git a/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.cpp b/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.cpp index 07cc6e644b..9d188b7298 100644 --- a/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.cpp @@ -1,4 +1,4 @@ -#import "CCLayerColorLoader.h" +#include "CCLayerColorLoader.h" using namespace cocos2d; using namespace cocos2d::extension; diff --git a/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.h b/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.h index 88a297e1a4..8efd9d872a 100644 --- a/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.h @@ -1,5 +1,5 @@ -#ifndef _CCLAYERCOLOR_LOADER_H_ -#define _CCLAYERCOLOR_LOADER_H_ +#ifndef _CCB_CCLAYERCOLORLOADER_H_ +#define _CCB_CCLAYERCOLORLOADER_H_ #include "CCLayerLoader.h" diff --git a/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.cpp b/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.cpp index f1e4cca492..64250044cf 100644 --- a/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.cpp @@ -1,4 +1,4 @@ -#import "CCLayerGradientLoader.h" +#include "CCLayerGradientLoader.h" using namespace cocos2d; using namespace cocos2d::extension; diff --git a/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.h b/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.h index 9f207269cb..f515a312dc 100644 --- a/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.h @@ -1,5 +1,5 @@ -#ifndef _CCLAYERGRADIENT_LOADER_H_ -#define _CCLAYERGRADIENT_LOADER_H_ +#ifndef _CCB_CCLAYERGRADIENTLOADER_H_ +#define _CCB_CCLAYERGRADIENTLOADER_H_ #include "CCLayerLoader.h" diff --git a/cocos2dx/extensions/CCBIReader/CCLayerLoader.cpp b/cocos2dx/extensions/CCBIReader/CCLayerLoader.cpp index e8326df324..5ec080050f 100644 --- a/cocos2dx/extensions/CCBIReader/CCLayerLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCLayerLoader.cpp @@ -1,4 +1,4 @@ -#import "CCLayerLoader.h" +#include "CCLayerLoader.h" using namespace cocos2d; using namespace cocos2d::extension; diff --git a/cocos2dx/extensions/CCBIReader/CCLayerLoader.h b/cocos2dx/extensions/CCBIReader/CCLayerLoader.h index 162e79cb44..08d56204de 100644 --- a/cocos2dx/extensions/CCBIReader/CCLayerLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCLayerLoader.h @@ -1,5 +1,5 @@ -#ifndef _CCLAYER_LOADER_H_ -#define _CCLAYER_LOADER_H_ +#ifndef _CCB_CCLAYERLOADER_H_ +#define _CCB_CCLAYERLOADER_H_ #include "CCNodeLoader.h" diff --git a/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader .cpp b/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader .cpp index 2a27499629..cd68de6a65 100644 --- a/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader .cpp +++ b/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader .cpp @@ -1,4 +1,4 @@ -#import "CCMenuItemImageLoader.h" +#include "CCMenuItemImageLoader.h" using namespace cocos2d; using namespace cocos2d::extension; diff --git a/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader.h b/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader.h index 09b2a760c1..756474d880 100644 --- a/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader.h @@ -1,5 +1,5 @@ -#ifndef _CCMENUITEMIMAGE_LOADER_H_ -#define _CCMENUITEMIMAGE_LOADER_H_ +#ifndef _CCB_CCMENUITEMIMAGELOADER_H_ +#define _CCB_CCMENUITEMIMAGELOADER_H_ #include "CCMenuItemLoader.h" diff --git a/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp b/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp index 0bc3fc4514..865c97d0f5 100644 --- a/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp @@ -1,4 +1,4 @@ -#import "CCMenuItemLoader.h" +#include "CCMenuItemLoader.h" using namespace cocos2d; using namespace cocos2d::extension; diff --git a/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.h b/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.h index 44643df6ee..e7ff8ff9a5 100644 --- a/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.h @@ -1,5 +1,5 @@ -#ifndef _CCMENUITEM_LOADER_H_ -#define _CCMENUITEM_LOADER_H_ +#ifndef _CCB_CCMENUITEMLOADER_H_ +#define _CCB_CCMENUITEMLOADER_H_ #include "CCLayerLoader.h" diff --git a/cocos2dx/extensions/CCBIReader/CCMenuLoader.cpp b/cocos2dx/extensions/CCBIReader/CCMenuLoader.cpp index 0006481b92..5d77921280 100644 --- a/cocos2dx/extensions/CCBIReader/CCMenuLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCMenuLoader.cpp @@ -1,4 +1,4 @@ -#import "CCMenuLoader.h" +#include "CCMenuLoader.h" using namespace cocos2d; using namespace cocos2d::extension; diff --git a/cocos2dx/extensions/CCBIReader/CCMenuLoader.h b/cocos2dx/extensions/CCBIReader/CCMenuLoader.h index 59fbfc58cf..333c781993 100644 --- a/cocos2dx/extensions/CCBIReader/CCMenuLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCMenuLoader.h @@ -1,5 +1,5 @@ -#ifndef _CCMENU_LOADER_H_ -#define _CCMENU_LOADER_H_ +#ifndef _CCB_CCMENULOADER_H_ +#define _CCB_CCMENULOADER_H_ #include "CCLayerLoader.h" diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp index 8fc166d0d6..420ad7458f 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp @@ -1,4 +1,5 @@ -#import "CCNodeLoader.h" +#include "CCNodeLoader.h" +#include "CCBSelectorResolver.h" #define PROPERTY_POSITION "position" #define PROPERTY_CONTENTSIZE "contentSize" diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.h b/cocos2dx/extensions/CCBIReader/CCNodeLoader.h index 265d010c77..e7aea9f235 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoader.h @@ -1,5 +1,5 @@ -#ifndef _CCNODE_LOADER_H_ -#define _CCNODE_LOADER_H_ +#ifndef _CCB_CCNODELOADER_H_ +#define _CCB_CCNODELOADER_H_ #include "cocos2d.h" #include "CCBReader.h" diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.h b/cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.h index 818e7ae9f0..da4b89cc2a 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.h +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.h @@ -1,5 +1,5 @@ -#ifndef _CCNODE_LOADER_LIBRARY_H_ -#define _CCNODE_LOADER_LIBRARY_H_ +#ifndef _CCB_CCNODELOADERLIBRARY_H_ +#define _CCB_CCNODELOADERLIBRARY_H_ #include "cocos2d.h" #include "CCBReader.h" diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoaderListener.h b/cocos2dx/extensions/CCBIReader/CCNodeLoaderListener.h new file mode 100644 index 0000000000..989f8da166 --- /dev/null +++ b/cocos2dx/extensions/CCBIReader/CCNodeLoaderListener.h @@ -0,0 +1,17 @@ +#ifndef _CCB_CCNODELOADERLISTENER_H_ +#define _CCB_CCNODELOADERLISTENER_H_ + +#include "cocos2d.h" + + + +NS_CC_EXT_BEGIN + +class CCNodeLoaderListener { + public: + virtual void onNodeLoaded(CCNode * pNode, CCNodeLoader * pNodeLoader) = 0; +}; + +NS_CC_EXT_END + +#endif diff --git a/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.cpp b/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.cpp index 490bb29417..62db13eedd 100644 --- a/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.cpp @@ -1,4 +1,4 @@ -#import "CCParticleSystemQuadLoader.h" +#include "CCParticleSystemQuadLoader.h" using namespace cocos2d; using namespace cocos2d::extension; diff --git a/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.h b/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.h index 9d75980758..c2687b3865 100644 --- a/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.h @@ -1,5 +1,5 @@ -#ifndef _CCPARTICLESYSTEMQUAD_LOADER_H_ -#define _CCPARTICLESYSTEMQUAD_LOADER_H_ +#ifndef _CCB_CCPARTICLESYSTEMQUADLOADER_H_ +#define _CCB_CCPARTICLESYSTEMQUADLOADER_H_ #include "CCNodeLoader.h" diff --git a/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.cpp b/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.cpp index 5259f00f13..59a34b4ad8 100644 --- a/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.cpp @@ -1,4 +1,4 @@ -#import "CCScale9SpriteLoader.h" +#include "CCScale9SpriteLoader.h" using namespace cocos2d; using namespace cocos2d::extension; diff --git a/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.h b/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.h index 08f396f6bb..4dd747f622 100644 --- a/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.h @@ -1,5 +1,5 @@ -#ifndef _CCSCALE9SPRITE_LOADER_H_ -#define _CCSCALE9SPRITE_LOADER_H_ +#ifndef _CCB_CCSCALE9SPRITELOADER_H_ +#define _CCB_CCSCALE9SPRITELOADER_H_ #include "CCNodeLoader.h" diff --git a/cocos2dx/extensions/CCBIReader/CCSpriteLoader.cpp b/cocos2dx/extensions/CCBIReader/CCSpriteLoader.cpp index 9d660c3edd..3b987d09a2 100644 --- a/cocos2dx/extensions/CCBIReader/CCSpriteLoader.cpp +++ b/cocos2dx/extensions/CCBIReader/CCSpriteLoader.cpp @@ -1,4 +1,4 @@ -#import "CCSpriteLoader.h" +#include "CCSpriteLoader.h" using namespace cocos2d; using namespace cocos2d::extension; diff --git a/cocos2dx/extensions/CCBIReader/CCSpriteLoader.h b/cocos2dx/extensions/CCBIReader/CCSpriteLoader.h index cf98c92180..65caa1a007 100644 --- a/cocos2dx/extensions/CCBIReader/CCSpriteLoader.h +++ b/cocos2dx/extensions/CCBIReader/CCSpriteLoader.h @@ -1,5 +1,5 @@ -#ifndef _CCSPRITE_LOADER_H_ -#define _CCSPRITE_LOADER_H_ +#ifndef _CCB_CCSPRITELOADER_H_ +#define _CCB_CCSPRITELOADER_H_ #include "CCNodeLoader.h" diff --git a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id index c25c63674f..42a8d0aa15 100644 --- a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -2183a27683dff4601536660a9a71e35cdfc1ce34 \ No newline at end of file +ac9e1ccb05629df842bf61eee24797838c23c929 \ No newline at end of file From b282d52a653e7ae8e6b23f8b19d24a7677aa2516 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 13 Jun 2012 10:41:04 +0800 Subject: [PATCH 145/257] issue #1310:synchronize some codes --- .../Images/test_1021x1024.png.REMOVED.git-id | 1 + ...est_1021x1024_rgb888.pvr.gz.REMOVED.git-id | 1 + ...t_1021x1024_rgba4444.pvr.gz.REMOVED.git-id | 1 + ...t_1021x1024_rgba8888.pvr.gz.REMOVED.git-id | 1 + tests/tests/ShaderTest/ShaderTest.cpp | 6 +- .../SpriteTest/SpriteTest.cpp.REMOVED.git-id | 2 +- tests/tests/Texture2dTest/Texture2dTest.cpp | 162 +++++++++++------- tests/tests/Texture2dTest/Texture2dTest.h | 20 ++- 8 files changed, 122 insertions(+), 72 deletions(-) create mode 100644 tests/Resources/Images/test_1021x1024.png.REMOVED.git-id create mode 100644 tests/Resources/Images/test_1021x1024_rgb888.pvr.gz.REMOVED.git-id create mode 100644 tests/Resources/Images/test_1021x1024_rgba4444.pvr.gz.REMOVED.git-id create mode 100644 tests/Resources/Images/test_1021x1024_rgba8888.pvr.gz.REMOVED.git-id diff --git a/tests/Resources/Images/test_1021x1024.png.REMOVED.git-id b/tests/Resources/Images/test_1021x1024.png.REMOVED.git-id new file mode 100644 index 0000000000..9c42115f32 --- /dev/null +++ b/tests/Resources/Images/test_1021x1024.png.REMOVED.git-id @@ -0,0 +1 @@ +148fa797a0a84fcbfac307b2d8482fd60b3002ff \ No newline at end of file diff --git a/tests/Resources/Images/test_1021x1024_rgb888.pvr.gz.REMOVED.git-id b/tests/Resources/Images/test_1021x1024_rgb888.pvr.gz.REMOVED.git-id new file mode 100644 index 0000000000..72c7f12e73 --- /dev/null +++ b/tests/Resources/Images/test_1021x1024_rgb888.pvr.gz.REMOVED.git-id @@ -0,0 +1 @@ +8e1219b732d1ee3fd7270ce9f60c88e94dbb082a \ No newline at end of file diff --git a/tests/Resources/Images/test_1021x1024_rgba4444.pvr.gz.REMOVED.git-id b/tests/Resources/Images/test_1021x1024_rgba4444.pvr.gz.REMOVED.git-id new file mode 100644 index 0000000000..70f39083b7 --- /dev/null +++ b/tests/Resources/Images/test_1021x1024_rgba4444.pvr.gz.REMOVED.git-id @@ -0,0 +1 @@ +0f2bff88acfd23787b3262d2b3b1f21f27c05e78 \ No newline at end of file diff --git a/tests/Resources/Images/test_1021x1024_rgba8888.pvr.gz.REMOVED.git-id b/tests/Resources/Images/test_1021x1024_rgba8888.pvr.gz.REMOVED.git-id new file mode 100644 index 0000000000..bdb6b44e7e --- /dev/null +++ b/tests/Resources/Images/test_1021x1024_rgba8888.pvr.gz.REMOVED.git-id @@ -0,0 +1 @@ +6dc9a563f11917ddea9db8ed1ff59da6762d34b1 \ No newline at end of file diff --git a/tests/tests/ShaderTest/ShaderTest.cpp b/tests/tests/ShaderTest/ShaderTest.cpp index 3232d8b54d..060c6c34a8 100644 --- a/tests/tests/ShaderTest/ShaderTest.cpp +++ b/tests/tests/ShaderTest/ShaderTest.cpp @@ -85,9 +85,9 @@ bool ShaderTestDemo::init() CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); menu->setPosition(ccp(0, 0)); - item1->setPosition(s.width/2-100, 30); - item2->setPosition(s.width/2, 30); - item3->setPosition(s.width/2 + 100, 30); + item1->setPosition(s.width/2- item2->getContentSize().width*2, item2->getContentSize().height/2); + item2->setPosition(s.width/2, item2->getContentSize().height/2); + item3->setPosition(s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2); addChild(menu, 1); return true; diff --git a/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id b/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id index de1fc1f12a..658b9ce4e6 100644 --- a/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id +++ b/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id @@ -1 +1 @@ -30f90defc4364cbcd8e686f75010ac83a50fb386 \ No newline at end of file +d45a5f1bd2f7a3c21828ba6d806255a3a78f2806 \ No newline at end of file diff --git a/tests/tests/Texture2dTest/Texture2dTest.cpp b/tests/tests/Texture2dTest/Texture2dTest.cpp index 89b671e5b3..a0c63d9c69 100644 --- a/tests/tests/Texture2dTest/Texture2dTest.cpp +++ b/tests/tests/Texture2dTest/Texture2dTest.cpp @@ -86,7 +86,7 @@ CCLayer* createTextureTest(int index) case 33: pLayer = new TextureDrawInRect(); break; case 34: - pLayer = new FileUtilsTest(); break; + pLayer = new TextureMemoryAlloc(); break; default: break; } @@ -1444,65 +1444,6 @@ std::string TextureDrawInRect::subtitle() return "draws 2 textures using drawInRect"; } -// FileUtilsTest -void FileUtilsTest::onEnter() -{ - TextureDemo::onEnter(); - // This test is only valid in Retinadisplay - - if( CC_CONTENT_SCALE_FACTOR() == 2 ) { - - CCSprite *sprite = new CCSprite(); - sprite->initWithFile("Images/bugs/test_issue_1179.png"); - if( sprite ) - CCLog("Test #1 issue 1179: OK"); - else - CCLog("Test #1 issue 1179: FAILED"); - - sprite->release(); - - sprite = new CCSprite(); - sprite->initWithFile("only_in_hd.pvr.ccz"); - if( sprite ) - CCLog("Test #2 issue 1179: OK"); - else - CCLog("Test #2 issue 1179: FAILED"); - - sprite->release(); - - } else { - CCLog("Test issue #1179 failed. Needs to be tested with RetinaDispaly"); - } - - -#if 0 // TODO:(CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - // Testint CCFileUtils API - bool ret = false; - ret = CCFileUtils::sharedFileUtils()->iPhoneRetinaDisplayFileExistsAtPath("Images/bugs/test_issue_1179.png"); - if( ret ) - CCLog("Test #3: retinaDisplayFileExistsAtPath: OK"); - else - CCLog("Test #3: retinaDisplayFileExistsAtPath: FAILED"); - - - ret = CCFileUtils::sharedFileUtils()->iPhoneRetinaDisplayFileExistsAtPath("grossini-does_no_exist.png"); - if( !ret ) - CCLog("Test #4: retinaDisplayFileExistsAtPath: OK"); - else - CCLog("Test #4: retinaDisplayFileExistsAtPath: FAILED"); -#endif -} - -std::string FileUtilsTest::title() -{ - return "CCFileUtils: See console"; -} - -std::string FileUtilsTest::subtitle() -{ - return "See the console"; -} - //------------------------------------------------------------------ // // TextureTestScene @@ -1514,3 +1455,104 @@ void TextureTestScene::runThisTest() addChild(pLayer); CCDirector::sharedDirector()->replaceScene(this); } + +//------------------------------------------------------------------ +// +// TextureMemoryAlloc +// +//------------------------------------------------------------------ +void TextureMemoryAlloc::onEnter() +{ + TextureDemo::onEnter(); + m_pBackground = NULL; + + CCMenuItemFont::setFontSize(24); + + CCMenuItem *item1 = CCMenuItemFont::itemWithString("PNG", this, menu_selector(TextureMemoryAlloc::updateImage)); + item1->setTag(0); + + CCMenuItem *item2 = CCMenuItemFont::itemWithString("RGBA8", this, menu_selector(TextureMemoryAlloc::updateImage)); + item2->setTag(1); + + CCMenuItem *item3 = CCMenuItemFont::itemWithString("RGB8", this, menu_selector(TextureMemoryAlloc::updateImage)); + item3->setTag(2); + + CCMenuItem *item4 = CCMenuItemFont::itemWithString("RGBA4", this, menu_selector(TextureMemoryAlloc::updateImage)); + item4->setTag(3); + + CCMenuItem *item5 = CCMenuItemFont::itemWithString("A8", this, menu_selector(TextureMemoryAlloc::updateImage)); + item5->setTag(4); + + CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, item4, item5, NULL); + menu->alignItemsHorizontally(); + + addChild(menu); + + CCMenuItemFont *warmup = CCMenuItemFont::itemWithString("warm up texture", this, menu_selector(TextureMemoryAlloc::changeBackgroundVisible)); + + CCMenu *menu2 = CCMenu::menuWithItems(warmup, NULL); + + menu2->alignItemsHorizontally(); + + addChild(menu2); + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + menu2->setPosition(ccp(s.width/2, s.height/4)); +} + +void TextureMemoryAlloc::changeBackgroundVisible(cocos2d::CCObject *sender) +{ + if (m_pBackground) + { + m_pBackground->setIsVisible(true); + } +} + +void TextureMemoryAlloc::updateImage(cocos2d::CCObject *sender) +{ + if (m_pBackground) + { + m_pBackground->removeFromParentAndCleanup(true); + } + + CCTextureCache::sharedTextureCache()->removeUnusedTextures(); + + int tag = ((CCNode*)sender)->getTag(); + string file; + switch (tag) + { + case 0: + file = "Images/test_1021x1024.png"; + break; + case 1: + file = "Images/test_1021x1024_rgba8888.pvr.gz"; + break; + case 2: + file = "Images/test_1021x1024_rgb888.pvr.gz"; + break; + case 3: + file = "Images/test_1021x1024_rgba4444.pvr.gz"; + break; + case 4: + file = "Images/test_1021x1024_a8.pvr.gz"; + break; + } + + m_pBackground = CCSprite::spriteWithFile(file.c_str()); + addChild(m_pBackground, -10); + + m_pBackground->setIsVisible(false); + + CCSize s = CCDirector::sharedDirector()->getWinSize(); + m_pBackground->setPosition(ccp(s.width/2, s.height/2)); +} + +string TextureMemoryAlloc::title() +{ + return "Texture memory"; +} + +string TextureMemoryAlloc::subtitle() +{ + return "Testing Texture Memory allocation. Use Instruments + VM Tracker"; +} \ No newline at end of file diff --git a/tests/tests/Texture2dTest/Texture2dTest.h b/tests/tests/Texture2dTest/Texture2dTest.h index ad0c837a19..1135a91891 100644 --- a/tests/tests/Texture2dTest/Texture2dTest.h +++ b/tests/tests/Texture2dTest/Texture2dTest.h @@ -277,14 +277,6 @@ public: virtual void onEnter(); }; -class FileUtilsTest : public TextureDemo -{ -public: - virtual std::string title(); - virtual std::string subtitle(); - virtual void onEnter(); -}; - class TextureDrawAtPoint : public TextureDemo { public: @@ -315,4 +307,16 @@ public: virtual void runThisTest(); }; +class TextureMemoryAlloc : public TextureDemo +{ +public: + virtual void onEnter(); + virtual std::string title(); + virtual std::string subtitle(); + void updateImage(CCObject *sender); + void changeBackgroundVisible(CCObject *sender); +private: + CCSprite *m_pBackground; +}; + #endif // __TEXTURE2D_TEST_H__ From ec4a21eaf4fab4aaf4f46945c9da49c6fabad659 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 13 Jun 2012 11:23:43 +0800 Subject: [PATCH 146/257] issue #1310: modify some format --- cocos2dx/textures/CCTexturePVR.cpp | 72 +++++++++++++++--------------- 1 file changed, 35 insertions(+), 37 deletions(-) diff --git a/cocos2dx/textures/CCTexturePVR.cpp b/cocos2dx/textures/CCTexturePVR.cpp index 3bc8348808..c440773815 100755 --- a/cocos2dx/textures/CCTexturePVR.cpp +++ b/cocos2dx/textures/CCTexturePVR.cpp @@ -55,46 +55,44 @@ enum { static char gPVRTexIdentifier[5] = "PVR!"; -/* - List of formats in pvr container -*/ enum { - kPVRTextureFlagTypeRGBA_4444= 0x10, - kPVRTextureFlagTypeRGBA_5551, - kPVRTextureFlagTypeRGBA_8888, - kPVRTextureFlagTypeRGB_565, - kPVRTextureFlagTypeRGB_555, // unsupported - kPVRTextureFlagTypeRGB_888, - kPVRTextureFlagTypeI_8, - kPVRTextureFlagTypeAI_88, - kPVRTextureFlagTypePVRTC_2, - kPVRTextureFlagTypePVRTC_4, - kPVRTextureFlagTypeBGRA_8888, - kPVRTextureFlagTypeA_8, + kPVRTexturePixelTypeRGBA_4444= 0x10, + kPVRTexturePixelTypeRGBA_5551, + kPVRTexturePixelTypeRGBA_8888, + kPVRTexturePixelTypeRGB_565, + kPVRTexturePixelTypeRGB_555, // unsupported + kPVRTexturePixelTypeRGB_888, + kPVRTexturePixelTypeI_8, + kPVRTexturePixelTypeAI_88, + kPVRTexturePixelTypePVRTC_2, + kPVRTexturePixelTypePVRTC_4, + kPVRTexturePixelTypeBGRA_8888, + kPVRTexturePixelTypeA_8, }; static const unsigned int tableFormats[][7] = { - // - PVR texture format - // - OpenGL internal format - // - OpenGL format - // - OpenGL type - // - bpp - // - compressed - // - Cocos2d texture format constant - {kPVRTextureFlagTypeRGBA_4444, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 16, false, kCCTexture2DPixelFormat_RGBA4444}, - {kPVRTextureFlagTypeRGBA_5551, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 16, false, kCCTexture2DPixelFormat_RGB5A1}, - {kPVRTextureFlagTypeRGBA_8888, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 32, false, kCCTexture2DPixelFormat_RGBA8888}, - {kPVRTextureFlagTypeRGB_565, GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 16, false, kCCTexture2DPixelFormat_RGB565}, - {kPVRTextureFlagTypeA_8, GL_ALPHA, GL_ALPHA,GL_UNSIGNED_BYTE, 8, false, kCCTexture2DPixelFormat_A8}, - {kPVRTextureFlagTypeI_8, GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, 8, false, kCCTexture2DPixelFormat_I8 }, - {kPVRTextureFlagTypeAI_88, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 16, false, kCCTexture2DPixelFormat_AI88 }, -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - {kPVRTextureFlagTypePVRTC_2, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, -1, -1, 2, true, kCCTexture2DPixelFormat_PVRTC2 }, - {kPVRTextureFlagTypePVRTC_4, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, -1, -1, 4, true, kCCTexture2DPixelFormat_PVRTC4 }, - {kPVRTextureFlagTypeBGRA_8888, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE, 32, false, kCCTexture2DPixelFormat_RGBA8888 }, -#endif + // - PVR texture format + // - OpenGL internal format + // - OpenGL format + // - OpenGL type + // - bpp + // - compressed + // - Cocos2d texture format constant + { kPVRTexturePixelTypeRGBA_4444, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, 16, false, kCCTexture2DPixelFormat_RGBA4444 }, + { kPVRTexturePixelTypeRGBA_5551, GL_RGBA, GL_RGBA, GL_UNSIGNED_SHORT_5_5_5_1, 16, false, kCCTexture2DPixelFormat_RGB5A1 }, + { kPVRTexturePixelTypeRGBA_8888, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, 32, false, kCCTexture2DPixelFormat_RGBA8888 }, + { kPVRTexturePixelTypeRGB_565, GL_RGB, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, 16, false, kCCTexture2DPixelFormat_RGB565 }, + { kPVRTexturePixelTypeRGB_888, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, 24, false, kCCTexture2DPixelFormat_RGB888 }, + { kPVRTexturePixelTypeA_8, GL_ALPHA, GL_ALPHA, GL_UNSIGNED_BYTE, 8, false, kCCTexture2DPixelFormat_A8 }, + { kPVRTexturePixelTypeI_8, GL_LUMINANCE, GL_LUMINANCE, GL_UNSIGNED_BYTE, 8, false, kCCTexture2DPixelFormat_I8 }, + { kPVRTexturePixelTypeAI_88, GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE,16, false, kCCTexture2DPixelFormat_AI88 }, +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + { kPVRTexturePixelTypePVRTC_2, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, -1, -1, 2, true, kCCTexture2DPixelFormat_PVRTC2 }, + { kPVRTexturePixelTypePVRTC_4, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, -1, -1, 4, true, kCCTexture2DPixelFormat_PVRTC4 }, +#endif // iphone only + { kPVRTexturePixelTypeBGRA_8888, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE, 32, false, kCCTexture2DPixelFormat_RGBA8888 }, }; //Tells How large is tableFormats @@ -234,17 +232,17 @@ bool CCTexturePVR::unpackPVRData(unsigned char* data, unsigned int len) while (dataOffset < dataLength) { switch (formatFlags) { - case kPVRTextureFlagTypePVRTC_2: + case kPVRTexturePixelTypePVRTC_2: blockSize = 8 * 4; // Pixel by pixel block size for 2bpp widthBlocks = width / 8; heightBlocks = height / 4; break; - case kPVRTextureFlagTypePVRTC_4: + case kPVRTexturePixelTypePVRTC_4: blockSize = 4 * 4; // Pixel by pixel block size for 4bpp widthBlocks = width / 4; heightBlocks = height / 4; break; - case kPVRTextureFlagTypeBGRA_8888: + case kPVRTexturePixelTypeBGRA_8888: if (CCConfiguration::sharedConfiguration()->isSupportsBGRA8888() == false) { CCLOG("cocos2d: TexturePVR. BGRA8888 not supported on this device"); From 15ad463fbe284f243242b703d50e63ba920ab504 Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 13 Jun 2012 16:20:58 +0800 Subject: [PATCH 147/257] issue #1322: vertical alignment ok on iOS --- cocos2dx/include/ccTypes.h | 11 -- cocos2dx/platform/ios/CCImage.mm | 24 ++- cocos2dx/textures/CCTexture2D.cpp | 255 ++++++++++++++--------------- cocos2dx/textures/CCTexture2D.h | 30 ++-- cocos2dx/textures/CCTexturePVR.cpp | 2 +- 5 files changed, 159 insertions(+), 163 deletions(-) diff --git a/cocos2dx/include/ccTypes.h b/cocos2dx/include/ccTypes.h index 2071787d79..de685fb319 100755 --- a/cocos2dx/include/ccTypes.h +++ b/cocos2dx/include/ccTypes.h @@ -339,17 +339,6 @@ typedef enum kCCTextAlignmentRight, } CCTextAlignment; -// XXX: If any of these enums are edited and/or reordered, udpate CCTexture2D.m -//! Line break modes -typedef enum { - kCCLineBreakModeWordWrap, - kCCLineBreakModeCharacterWrap, - kCCLineBreakModeClip, - kCCLineBreakModeHeadTruncation, - kCCLineBreakModeTailTruncation, - kCCLineBreakModeMiddleTruncation -} CCLineBreakMode; - // types for animation in particle systems // texture coordinates for a quad diff --git a/cocos2dx/platform/ios/CCImage.mm b/cocos2dx/platform/ios/CCImage.mm index 5cf6edc95a..55f7684512 100644 --- a/cocos2dx/platform/ios/CCImage.mm +++ b/cocos2dx/platform/ios/CCImage.mm @@ -204,6 +204,11 @@ static CGSize _calculateStringSizeWithFontOrZFont(NSString *str, id font, CGSize return dim; } +// refer CCImage::ETextAlign +#define ALIGN_TOP 1 +#define ALIGN_CENTER 3 +#define ALIGN_BOTTOM 2 + static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAlign, const char * pFontName, int nSize, tImageInfo* pInfo) { bool bRet = false; @@ -259,7 +264,20 @@ static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAl int startH = 0; if (constrainSize.height > dim.height) { - startH = (constrainSize.height - dim.height) / 2; + // vertical alignment + unsigned int vAlignment = (eAlign >> 4) & 0x0F; + if (vAlignment == ALIGN_TOP) + { + startH = 0; + } + else if (vAlignment == ALIGN_CENTER) + { + startH = (constrainSize.height - dim.height) / 2; + } + else + { + startH = constrainSize.height - dim.height; + } } // adjust text rect @@ -282,8 +300,8 @@ static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAl if (! context) { - delete[] data; - break; + delete[] data; + break; } CGContextSetRGBFillColor(context, 1, 1, 1, 1); diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index d16a409a46..bea84a381f 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -178,12 +178,12 @@ bool CCTexture2D::getHasPremultipliedAlpha() bool CCTexture2D::initWithData(const void *data, CCTexture2DPixelFormat pixelFormat, unsigned int pixelsWide, unsigned int pixelsHigh, const CCSize& contentSize) { - // XXX: 32 bits or POT textures uses UNPACK of 4 (is this correct ??? ) - if( pixelFormat == kCCTexture2DPixelFormat_RGBA8888 || ( ccNextPOT(pixelsWide)==pixelsWide && ccNextPOT(pixelsHigh)==pixelsHigh) ) - { - glPixelStorei(GL_UNPACK_ALIGNMENT,4); - } - else + // XXX: 32 bits or POT textures uses UNPACK of 4 (is this correct ??? ) + if( pixelFormat == kCCTexture2DPixelFormat_RGBA8888 || ( ccNextPOT(pixelsWide)==pixelsWide && ccNextPOT(pixelsHigh)==pixelsHigh) ) + { + glPixelStorei(GL_UNPACK_ALIGNMENT,4); + } + else { glPixelStorei(GL_UNPACK_ALIGNMENT,1); } @@ -191,9 +191,9 @@ bool CCTexture2D::initWithData(const void *data, CCTexture2DPixelFormat pixelFor glGenTextures(1, &m_uName); ccGLBindTexture2D(m_uName); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); // Specify OpenGL texture image @@ -427,15 +427,10 @@ bool CCTexture2D::initPremultipliedATextureWithImage(CCImage *image, unsigned in // implementation CCTexture2D (Text) bool CCTexture2D::initWithString(const char *text, const char *fontName, float fontSize) { - return initWithString(text, CCSizeMake(0,0), kCCTextAlignmentCenter, kCCVerticalTextAlignmentTop, kCCLineBreakModeWordWrap, fontName, fontSize); + return initWithString(text, CCSizeMake(0,0), kCCTextAlignmentCenter, kCCVerticalTextAlignmentTop, fontName, fontSize); } bool CCTexture2D::initWithString(const char *text, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize) -{ - return initWithString(text, dimensions, hAlignment, vAlignment, kCCLineBreakModeWordWrap, fontName, fontSize); -} - -bool CCTexture2D::initWithString(const char *text, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, CCLineBreakMode lineBreakMode, const char *fontName, float fontSize) { #if CC_ENABLE_CACHE_TEXTURE_DATA // cache the texture data @@ -624,8 +619,8 @@ void CCTexture2D::generateMipmap() void CCTexture2D::setTexParameters(ccTexParams *texParams) { - CCAssert( (m_uPixelsWide == ccNextPOT(m_uPixelsWide) || texParams->wrapS == GL_CLAMP_TO_EDGE) && - (m_uPixelsHigh == ccNextPOT(m_uPixelsHigh) || texParams->wrapT == GL_CLAMP_TO_EDGE), + CCAssert( (m_uPixelsWide == ccNextPOT(m_uPixelsWide) || texParams->wrapS == GL_CLAMP_TO_EDGE) && + (m_uPixelsHigh == ccNextPOT(m_uPixelsHigh) || texParams->wrapT == GL_CLAMP_TO_EDGE), "GL_CLAMP_TO_EDGE should be used in NPOT dimensions"); ccGLBindTexture2D( m_uName ); @@ -637,78 +632,78 @@ void CCTexture2D::setTexParameters(ccTexParams *texParams) void CCTexture2D::setAliasTexParameters() { - ccGLBindTexture2D( m_uName ); - - if( ! m_bHasMipmaps ) - { - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); - } - else - { - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST ); - } - + ccGLBindTexture2D( m_uName ); + + if( ! m_bHasMipmaps ) + { + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); + } + else + { + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST ); + } + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); } void CCTexture2D::setAntiAliasTexParameters() { - ccGLBindTexture2D( m_uName ); - - if( ! m_bHasMipmaps ) - { - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); - } - else - { - glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST ); - } - + ccGLBindTexture2D( m_uName ); + + if( ! m_bHasMipmaps ) + { + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); + } + else + { + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST ); + } + glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); } -const char* CCTexture2D::stringForFormat() -{ - switch (m_ePixelFormat) - { - case kCCTexture2DPixelFormat_RGBA8888: - return "RGBA8888"; - - case kCCTexture2DPixelFormat_RGB888: - return "RGB888"; - - case kCCTexture2DPixelFormat_RGB565: - return "RGB565"; - - case kCCTexture2DPixelFormat_RGBA4444: - return "RGBA4444"; - - case kCCTexture2DPixelFormat_RGB5A1: - return "RGB5A1"; - - case kCCTexture2DPixelFormat_AI88: - return "AI88"; - - case kCCTexture2DPixelFormat_A8: - return "A8"; - - case kCCTexture2DPixelFormat_I8: - return "I8"; - - case kCCTexture2DPixelFormat_PVRTC4: - return "PVRTC4"; - - case kCCTexture2DPixelFormat_PVRTC2: - return "PVRTC2"; - - default: - CCAssert(false , "unrecognised pixel format"); - CCLOG("stringForFormat: %ld, cannot give useful result", (long)m_ePixelFormat); - break; - } - - return NULL; -} +const char* CCTexture2D::stringForFormat() +{ + switch (m_ePixelFormat) + { + case kCCTexture2DPixelFormat_RGBA8888: + return "RGBA8888"; + + case kCCTexture2DPixelFormat_RGB888: + return "RGB888"; + + case kCCTexture2DPixelFormat_RGB565: + return "RGB565"; + + case kCCTexture2DPixelFormat_RGBA4444: + return "RGBA4444"; + + case kCCTexture2DPixelFormat_RGB5A1: + return "RGB5A1"; + + case kCCTexture2DPixelFormat_AI88: + return "AI88"; + + case kCCTexture2DPixelFormat_A8: + return "A8"; + + case kCCTexture2DPixelFormat_I8: + return "I8"; + + case kCCTexture2DPixelFormat_PVRTC4: + return "PVRTC4"; + + case kCCTexture2DPixelFormat_PVRTC2: + return "PVRTC2"; + + default: + CCAssert(false , "unrecognised pixel format"); + CCLOG("stringForFormat: %ld, cannot give useful result", (long)m_ePixelFormat); + break; + } + + return NULL; +} // @@ -727,55 +722,55 @@ CCTexture2DPixelFormat CCTexture2D::defaultAlphaPixelFormat() return g_defaultAlphaPixelFormat; } -unsigned int CCTexture2D::bitsPerPixelForFormat(CCTexture2DPixelFormat format) -{ - unsigned int ret=0; - - switch (format) { - case kCCTexture2DPixelFormat_RGBA8888: - ret = 32; - break; - case kCCTexture2DPixelFormat_RGB888: - // It is 32 and not 24, since its internal representation uses 32 bits. - ret = 32; - break; - case kCCTexture2DPixelFormat_RGB565: - ret = 16; - break; - case kCCTexture2DPixelFormat_RGBA4444: - ret = 16; - break; - case kCCTexture2DPixelFormat_RGB5A1: - ret = 16; - break; - case kCCTexture2DPixelFormat_AI88: - ret = 16; - break; - case kCCTexture2DPixelFormat_A8: - ret = 8; - break; - case kCCTexture2DPixelFormat_I8: - ret = 8; - break; - case kCCTexture2DPixelFormat_PVRTC4: - ret = 4; - break; - case kCCTexture2DPixelFormat_PVRTC2: - ret = 2; - break; - default: - ret = -1; - CCAssert(false , "unrecognised pixel format"); - CCLOG("bitsPerPixelForFormat: %ld, cannot give useful result", (long)format); - break; - } - return ret; -} - -unsigned int CCTexture2D::bitsPerPixelForFormat() -{ - return this->bitsPerPixelForFormat(m_ePixelFormat); -} +unsigned int CCTexture2D::bitsPerPixelForFormat(CCTexture2DPixelFormat format) +{ + unsigned int ret=0; + + switch (format) { + case kCCTexture2DPixelFormat_RGBA8888: + ret = 32; + break; + case kCCTexture2DPixelFormat_RGB888: + // It is 32 and not 24, since its internal representation uses 32 bits. + ret = 32; + break; + case kCCTexture2DPixelFormat_RGB565: + ret = 16; + break; + case kCCTexture2DPixelFormat_RGBA4444: + ret = 16; + break; + case kCCTexture2DPixelFormat_RGB5A1: + ret = 16; + break; + case kCCTexture2DPixelFormat_AI88: + ret = 16; + break; + case kCCTexture2DPixelFormat_A8: + ret = 8; + break; + case kCCTexture2DPixelFormat_I8: + ret = 8; + break; + case kCCTexture2DPixelFormat_PVRTC4: + ret = 4; + break; + case kCCTexture2DPixelFormat_PVRTC2: + ret = 2; + break; + default: + ret = -1; + CCAssert(false , "unrecognised pixel format"); + CCLOG("bitsPerPixelForFormat: %ld, cannot give useful result", (long)format); + break; + } + return ret; +} + +unsigned int CCTexture2D::bitsPerPixelForFormat() +{ + return this->bitsPerPixelForFormat(m_ePixelFormat); +} NS_CC_END diff --git a/cocos2dx/textures/CCTexture2D.h b/cocos2dx/textures/CCTexture2D.h index 9a8a1414c4..6ae56e19b0 100644 --- a/cocos2dx/textures/CCTexture2D.h +++ b/cocos2dx/textures/CCTexture2D.h @@ -131,12 +131,6 @@ public: bool initWithImage(CCImage *uiImage, ccResolutionType resolution); - /** - Extensions to make it easy to create a CCTexture2D object from a string of text. - Note that the generated textures are of type A8 - use the blending mode (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA). - */ - - bool initWithString(const char *text, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, CCLineBreakMode lineBreakMode, const char *fontName, float fontSize); /** Initializes a texture from a string with dimensions, alignment, font name and font size */ bool initWithString(const char *text, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize); /** Initializes a texture from a string with font name and font size */ @@ -190,19 +184,19 @@ public: */ void generateMipmap(); - /** returns the pixel format. - @since v2.0 - */ - const char* stringForFormat(); - + /** returns the pixel format. + @since v2.0 + */ + const char* stringForFormat(); + /** returns the bits-per-pixel of the in-memory OpenGL texture @since v1.0 */ - unsigned int bitsPerPixelForFormat(); - - /** Helper functions that returns bits per pixels for a given format. - @since v2.0 - */ + unsigned int bitsPerPixelForFormat(); + + /** Helper functions that returns bits per pixels for a given format. + @since v2.0 + */ unsigned int bitsPerPixelForFormat(CCTexture2DPixelFormat format); /** sets the default pixel format for UIImagescontains alpha channel. @@ -216,8 +210,8 @@ public: How does it work ? - If the image is an RGBA (with Alpha) then the default pixel format will be used (it can be a 8-bit, 16-bit or 32-bit texture) - - If the image is an RGB (without Alpha) then: If the default pixel format is RGBA8888 then a RGBA8888 (32-bit) will be used. Otherwise a RGB565 (16-bit texture) will be used. - + - If the image is an RGB (without Alpha) then: If the default pixel format is RGBA8888 then a RGBA8888 (32-bit) will be used. Otherwise a RGB565 (16-bit texture) will be used. + This parameter is not valid for PVR / PVR.CCZ images. @since v0.8 diff --git a/cocos2dx/textures/CCTexturePVR.cpp b/cocos2dx/textures/CCTexturePVR.cpp index c440773815..c8d9ca85e5 100755 --- a/cocos2dx/textures/CCTexturePVR.cpp +++ b/cocos2dx/textures/CCTexturePVR.cpp @@ -343,7 +343,7 @@ bool CCTexturePVR::createGLTexture() // Generate textures with mipmaps for (unsigned int i = 0; i < m_uNumberOfMipmaps; ++i) { - if (compressed && ! CCConfiguration::sharedConfiguration()->isSupportsNPOT()) + if (compressed && ! CCConfiguration::sharedConfiguration()->isSupportsPVRTC()) { CCLOG("cocos2d: WARNING: PVRTC images are not supported"); return false; From 9321a8d025afa7601d60b4e80535168f4744039b Mon Sep 17 00:00:00 2001 From: minggo Date: Wed, 13 Jun 2012 18:33:44 +0800 Subject: [PATCH 148/257] fixed #1322: vertical alignment works ok on android --- .../src/org/cocos2dx/lib/Cocos2dxBitmap.java | 60 ++- .../src/org/cocos2dx/lib/Cocos2dxBitmap.java | 60 ++- cocos2dx/Android.mk | 2 + cocos2dx/platform/android/CCFileUtils.cpp | 6 - cocos2dx/platform/android/CCGL.h | 1 + cocos2dx/platform/android/jni/MessageJni.cpp | 2 +- cocos2dx/textures/CCTexture2D.cpp | 2 +- cocos2dx/textures/CCTextureCache.cpp | 8 +- cocos2dx/textures/CCTextureCache.h | 4 +- cocos2dx/textures/CCTexturePVR.cpp | 3 +- .../src/org/cocos2dx/lib/Cocos2dxBitmap.java | 60 ++- tests/Android.mk | 2 - .../src/org/cocos2dx/lib/Cocos2dxBitmap.java | 60 ++- tests/tests/LabelTest/LabelTest.cpp | 364 +++++++++--------- 14 files changed, 382 insertions(+), 252 deletions(-) diff --git a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java b/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java index 4a8755068f..4b3d0c6788 100644 --- a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java +++ b/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java @@ -40,11 +40,14 @@ import android.util.Log; public class Cocos2dxBitmap{ /* * The values are the same as cocos2dx/platform/CCImage.h. - * I think three alignments are OK. */ - private static final int ALIGNCENTER = 0x33; - private static final int ALIGNLEFT = 0x31; - private static final int ALIGNRIGHT = 0x32; + private static final int HALIGNCENTER = 3; + private static final int HALIGNLEFT = 1; + private static final int HALIGNRIGHT = 2; + // vertical alignment + private static final int VALIGNTOP = 1; + private static final int VALIGNBOTTOM = 2; + private static final int VALIGNCENTER = 3; private static Context context; @@ -74,8 +77,7 @@ public class Cocos2dxBitmap{ // Draw string FontMetricsInt fm = paint.getFontMetricsInt(); int x = 0; - int y = height == 0 ?(-fm.top): - (-fm.top + (height - textProperty.totalHeight)/2); + int y = computeY(fm, height, textProperty.totalHeight, alignment); String[] lines = textProperty.lines; for (String line : lines){ x = computeX(paint, line, textProperty.maxWidth, alignment); @@ -88,17 +90,18 @@ public class Cocos2dxBitmap{ private static int computeX(Paint paint, String content, int w, int alignment){ int ret = 0; + int hAlignment = alignment & 0x0F; - switch (alignment){ - case ALIGNCENTER: + switch (hAlignment){ + case HALIGNCENTER: ret = w / 2; break; // ret = 0 - case ALIGNLEFT: + case HALIGNLEFT: break; - case ALIGNRIGHT: + case HALIGNRIGHT: ret = w; break; @@ -113,6 +116,30 @@ public class Cocos2dxBitmap{ return ret; } + private static int computeY(FontMetricsInt fm, int constrainHeight, int totalHeight, int alignment) { + int y = -fm.top; + + if (constrainHeight > totalHeight) { + int vAlignment = (alignment >> 4) & 0x0F; + + switch (vAlignment) { + case VALIGNTOP: + y = -fm.top; + break; + case VALIGNCENTER: + y = -fm.top + (constrainHeight - totalHeight)/2; + break; + case VALIGNBOTTOM: + y = -fm.top + (constrainHeight - totalHeight); + break; + default: + break; + } + } + + return y; + } + private static class TextProperty{ // The max width of lines int maxWidth; @@ -258,6 +285,10 @@ public class Cocos2dxBitmap{ strList.add(content.substring(start, i)); } } + + // remove spaces at the beginning of a new line + while(content.indexOf(i++) == ' ') { + } start = i; } @@ -301,16 +332,17 @@ public class Cocos2dxBitmap{ paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL)); } - switch (alignment){ - case ALIGNCENTER: + int hAlignment = alignment & 0x0F; + switch (hAlignment){ + case HALIGNCENTER: paint.setTextAlign(Align.CENTER); break; - case ALIGNLEFT: + case HALIGNLEFT: paint.setTextAlign(Align.LEFT); break; - case ALIGNRIGHT: + case HALIGNRIGHT: paint.setTextAlign(Align.RIGHT); break; diff --git a/HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java b/HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java index 4a8755068f..4b3d0c6788 100644 --- a/HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java +++ b/HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java @@ -40,11 +40,14 @@ import android.util.Log; public class Cocos2dxBitmap{ /* * The values are the same as cocos2dx/platform/CCImage.h. - * I think three alignments are OK. */ - private static final int ALIGNCENTER = 0x33; - private static final int ALIGNLEFT = 0x31; - private static final int ALIGNRIGHT = 0x32; + private static final int HALIGNCENTER = 3; + private static final int HALIGNLEFT = 1; + private static final int HALIGNRIGHT = 2; + // vertical alignment + private static final int VALIGNTOP = 1; + private static final int VALIGNBOTTOM = 2; + private static final int VALIGNCENTER = 3; private static Context context; @@ -74,8 +77,7 @@ public class Cocos2dxBitmap{ // Draw string FontMetricsInt fm = paint.getFontMetricsInt(); int x = 0; - int y = height == 0 ?(-fm.top): - (-fm.top + (height - textProperty.totalHeight)/2); + int y = computeY(fm, height, textProperty.totalHeight, alignment); String[] lines = textProperty.lines; for (String line : lines){ x = computeX(paint, line, textProperty.maxWidth, alignment); @@ -88,17 +90,18 @@ public class Cocos2dxBitmap{ private static int computeX(Paint paint, String content, int w, int alignment){ int ret = 0; + int hAlignment = alignment & 0x0F; - switch (alignment){ - case ALIGNCENTER: + switch (hAlignment){ + case HALIGNCENTER: ret = w / 2; break; // ret = 0 - case ALIGNLEFT: + case HALIGNLEFT: break; - case ALIGNRIGHT: + case HALIGNRIGHT: ret = w; break; @@ -113,6 +116,30 @@ public class Cocos2dxBitmap{ return ret; } + private static int computeY(FontMetricsInt fm, int constrainHeight, int totalHeight, int alignment) { + int y = -fm.top; + + if (constrainHeight > totalHeight) { + int vAlignment = (alignment >> 4) & 0x0F; + + switch (vAlignment) { + case VALIGNTOP: + y = -fm.top; + break; + case VALIGNCENTER: + y = -fm.top + (constrainHeight - totalHeight)/2; + break; + case VALIGNBOTTOM: + y = -fm.top + (constrainHeight - totalHeight); + break; + default: + break; + } + } + + return y; + } + private static class TextProperty{ // The max width of lines int maxWidth; @@ -258,6 +285,10 @@ public class Cocos2dxBitmap{ strList.add(content.substring(start, i)); } } + + // remove spaces at the beginning of a new line + while(content.indexOf(i++) == ' ') { + } start = i; } @@ -301,16 +332,17 @@ public class Cocos2dxBitmap{ paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL)); } - switch (alignment){ - case ALIGNCENTER: + int hAlignment = alignment & 0x0F; + switch (hAlignment){ + case HALIGNCENTER: paint.setTextAlign(Align.CENTER); break; - case ALIGNLEFT: + case HALIGNLEFT: paint.setTextAlign(Align.LEFT); break; - case ALIGNRIGHT: + case HALIGNRIGHT: paint.setTextAlign(Align.RIGHT); break; diff --git a/cocos2dx/Android.mk b/cocos2dx/Android.mk index f73df4fca2..acc5e47712 100644 --- a/cocos2dx/Android.mk +++ b/cocos2dx/Android.mk @@ -13,6 +13,7 @@ CCScheduler.cpp \ CCCamera.cpp \ actions/CCAction.cpp \ actions/CCActionCamera.cpp \ +actions/CCActionCatmullRom.cpp \ actions/CCActionEase.cpp \ actions/CCActionGrid.cpp \ actions/CCActionGrid3D.cpp \ @@ -124,6 +125,7 @@ support/CCUserDefault.cpp \ support/base64.cpp \ support/ccUtils.cpp \ support/CCVertex.cpp \ +support/data_support/ccCArray.cpp \ support/image_support/TGAlib.cpp \ support/zip_support/ZipUtils.cpp \ support/zip_support/ioapi.cpp \ diff --git a/cocos2dx/platform/android/CCFileUtils.cpp b/cocos2dx/platform/android/CCFileUtils.cpp index 60c6df25b2..3d2a4b429e 100644 --- a/cocos2dx/platform/android/CCFileUtils.cpp +++ b/cocos2dx/platform/android/CCFileUtils.cpp @@ -144,12 +144,6 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz return pData; } -int CCFileUtils::ccLoadFileIntoMemory(const char *filename, unsigned char **out) -{ - CCAssert(0, "Have not implement!"); - return 0; -} - string CCFileUtils::getWriteablePath() { // the path is: /data/data/ + package name diff --git a/cocos2dx/platform/android/CCGL.h b/cocos2dx/platform/android/CCGL.h index f2701dab0a..b80308e0ad 100644 --- a/cocos2dx/platform/android/CCGL.h +++ b/cocos2dx/platform/android/CCGL.h @@ -29,6 +29,7 @@ THE SOFTWARE. #define glDeleteVertexArrays glDeleteVertexArraysOES #define glGenVertexArrays glGenVertexArraysOES #define glBindVertexArray glBindVertexArrayOES +#define CC_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES // GL_GLEXT_PROTOTYPES isn't defined in glplatform.h on android ndk r7 // we manually define it here diff --git a/cocos2dx/platform/android/jni/MessageJni.cpp b/cocos2dx/platform/android/jni/MessageJni.cpp index a14ca6040f..ec31a63f37 100644 --- a/cocos2dx/platform/android/jni/MessageJni.cpp +++ b/cocos2dx/platform/android/jni/MessageJni.cpp @@ -124,7 +124,7 @@ extern "C" void Java_org_cocos2dx_lib_Cocos2dxActivity_nativeSetPaths(JNIEnv* env, jobject thiz, jstring apkPath) { const char* str = env->GetStringUTFChars(apkPath, NULL); - cocos2d::CCFileUtils::setResourcePath(str); + cocos2d::CCFileUtils::sharedFileUtils()->setResourcePath(str); env->ReleaseStringUTFChars(apkPath, str); } } diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index bea84a381f..eda5d60464 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -434,7 +434,7 @@ bool CCTexture2D::initWithString(const char *text, const CCSize& dimensions, CCT { #if CC_ENABLE_CACHE_TEXTURE_DATA // cache the texture data - VolatileTexture::addStringTexture(this, text, dimensions, alignment, fontName, fontSize); + VolatileTexture::addStringTexture(this, text, dimensions, hAlignment, vAlignment, fontName, fontSize); #endif CCImage image; diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index 8bb6cf5fe1..cdeb8e91ce 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -710,7 +710,8 @@ VolatileTexture::VolatileTexture(CCTexture2D *t) , m_PixelFormat(kTexture2DPixelFormat_RGBA8888) , m_strFileName("") , m_FmtImage(CCImage::kFmtPng) -, m_alignment(CCTextAlignmentCenter) +, m_alignment(kCCTextAlignmentCenter) +, m_vAlignment(kCCVerticalTextAlignmentCenter) , m_strFontName("") , m_strText("") , uiImage(NULL) @@ -786,7 +787,8 @@ void VolatileTexture::addDataTexture(CCTexture2D *tt, void* data, CCTexture2DPix vt->m_TextureSize = contentSize; } -void VolatileTexture::addStringTexture(CCTexture2D *tt, const char* text, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize) +void VolatileTexture::addStringTexture(CCTexture2D *tt, const char* text, const CCSize& dimensions, CCTextAlignment alignment, + CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize) { if (isReloading) { @@ -799,6 +801,7 @@ void VolatileTexture::addStringTexture(CCTexture2D *tt, const char* text, const vt->m_size = dimensions; vt->m_strFontName = fontName; vt->m_alignment = alignment; + vt->m_vAlignment = vAlignment; vt->m_fFontSize = fontSize; vt->m_strText = text; } @@ -878,6 +881,7 @@ void VolatileTexture::reloadAllTextures() vt->texture->initWithString(vt->m_strText.c_str(), vt->m_size, vt->m_alignment, + vt->m_vAlignment, vt->m_strFontName.c_str(), vt->m_fFontSize); } diff --git a/cocos2dx/textures/CCTextureCache.h b/cocos2dx/textures/CCTextureCache.h index def606d5ef..1fe4952e50 100644 --- a/cocos2dx/textures/CCTextureCache.h +++ b/cocos2dx/textures/CCTextureCache.h @@ -185,7 +185,8 @@ public: ~VolatileTexture(); static void addImageTexture(CCTexture2D *tt, const char* imageFileName, CCImage::EImageFormat format); - static void addStringTexture(CCTexture2D *tt, const char* text, const CCSize& dimensions, CCTextAlignment alignment, const char *fontName, float fontSize); + static void addStringTexture(CCTexture2D *tt, const char* text, const CCSize& dimensions, CCTextAlignment alignment, + CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize); static void addDataTexture(CCTexture2D *tt, void* data, CCTexture2DPixelFormat pixelFormat, const CCSize& contentSize); static void addCCImage(CCTexture2D *tt, CCImage *image); @@ -217,6 +218,7 @@ protected: CCSize m_size; CCTextAlignment m_alignment; + CCVerticalTextAlignment m_vAlignment; std::string m_strFontName; std::string m_strText; float m_fFontSize; diff --git a/cocos2dx/textures/CCTexturePVR.cpp b/cocos2dx/textures/CCTexturePVR.cpp index c8d9ca85e5..3c8f4192dd 100755 --- a/cocos2dx/textures/CCTexturePVR.cpp +++ b/cocos2dx/textures/CCTexturePVR.cpp @@ -91,8 +91,9 @@ static const unsigned int tableFormats[][7] = { #if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) { kPVRTexturePixelTypePVRTC_2, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, -1, -1, 2, true, kCCTexture2DPixelFormat_PVRTC2 }, { kPVRTexturePixelTypePVRTC_4, GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG, -1, -1, 4, true, kCCTexture2DPixelFormat_PVRTC4 }, -#endif // iphone only + { kPVRTexturePixelTypeBGRA_8888, GL_RGBA, GL_BGRA, GL_UNSIGNED_BYTE, 32, false, kCCTexture2DPixelFormat_RGBA8888 }, +#endif // iphone only }; //Tells How large is tableFormats diff --git a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java b/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java index 4a8755068f..4b3d0c6788 100644 --- a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java +++ b/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java @@ -40,11 +40,14 @@ import android.util.Log; public class Cocos2dxBitmap{ /* * The values are the same as cocos2dx/platform/CCImage.h. - * I think three alignments are OK. */ - private static final int ALIGNCENTER = 0x33; - private static final int ALIGNLEFT = 0x31; - private static final int ALIGNRIGHT = 0x32; + private static final int HALIGNCENTER = 3; + private static final int HALIGNLEFT = 1; + private static final int HALIGNRIGHT = 2; + // vertical alignment + private static final int VALIGNTOP = 1; + private static final int VALIGNBOTTOM = 2; + private static final int VALIGNCENTER = 3; private static Context context; @@ -74,8 +77,7 @@ public class Cocos2dxBitmap{ // Draw string FontMetricsInt fm = paint.getFontMetricsInt(); int x = 0; - int y = height == 0 ?(-fm.top): - (-fm.top + (height - textProperty.totalHeight)/2); + int y = computeY(fm, height, textProperty.totalHeight, alignment); String[] lines = textProperty.lines; for (String line : lines){ x = computeX(paint, line, textProperty.maxWidth, alignment); @@ -88,17 +90,18 @@ public class Cocos2dxBitmap{ private static int computeX(Paint paint, String content, int w, int alignment){ int ret = 0; + int hAlignment = alignment & 0x0F; - switch (alignment){ - case ALIGNCENTER: + switch (hAlignment){ + case HALIGNCENTER: ret = w / 2; break; // ret = 0 - case ALIGNLEFT: + case HALIGNLEFT: break; - case ALIGNRIGHT: + case HALIGNRIGHT: ret = w; break; @@ -113,6 +116,30 @@ public class Cocos2dxBitmap{ return ret; } + private static int computeY(FontMetricsInt fm, int constrainHeight, int totalHeight, int alignment) { + int y = -fm.top; + + if (constrainHeight > totalHeight) { + int vAlignment = (alignment >> 4) & 0x0F; + + switch (vAlignment) { + case VALIGNTOP: + y = -fm.top; + break; + case VALIGNCENTER: + y = -fm.top + (constrainHeight - totalHeight)/2; + break; + case VALIGNBOTTOM: + y = -fm.top + (constrainHeight - totalHeight); + break; + default: + break; + } + } + + return y; + } + private static class TextProperty{ // The max width of lines int maxWidth; @@ -258,6 +285,10 @@ public class Cocos2dxBitmap{ strList.add(content.substring(start, i)); } } + + // remove spaces at the beginning of a new line + while(content.indexOf(i++) == ' ') { + } start = i; } @@ -301,16 +332,17 @@ public class Cocos2dxBitmap{ paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL)); } - switch (alignment){ - case ALIGNCENTER: + int hAlignment = alignment & 0x0F; + switch (hAlignment){ + case HALIGNCENTER: paint.setTextAlign(Align.CENTER); break; - case ALIGNLEFT: + case HALIGNLEFT: paint.setTextAlign(Align.LEFT); break; - case ALIGNRIGHT: + case HALIGNRIGHT: paint.setTextAlign(Align.RIGHT); break; diff --git a/tests/Android.mk b/tests/Android.mk index 1589dd0532..6cf3ebba20 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -33,7 +33,6 @@ tests/ClickAndMoveTest/ClickAndMoveTest.cpp \ tests/CocosDenshionTest/CocosDenshionTest.cpp \ tests/CurlTest/CurlTest.cpp \ tests/CurrentLanguageTest/CurrentLanguageTest.cpp \ -tests/DirectorTest/DirectorTest.cpp \ tests/DrawPrimitivesTest/DrawPrimitivesTest.cpp \ tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp \ tests/EffectsTest/EffectsTest.cpp \ @@ -48,7 +47,6 @@ tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTes tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp \ tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder.cpp \ tests/FontTest/FontTest.cpp \ -tests/HiResTest/HiResTest.cpp \ tests/IntervalTest/IntervalTest.cpp \ tests/KeypadTest/KeypadTest.cpp \ tests/LabelTest/LabelTest.cpp \ diff --git a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java b/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java index 4a8755068f..4b3d0c6788 100644 --- a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java +++ b/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java @@ -40,11 +40,14 @@ import android.util.Log; public class Cocos2dxBitmap{ /* * The values are the same as cocos2dx/platform/CCImage.h. - * I think three alignments are OK. */ - private static final int ALIGNCENTER = 0x33; - private static final int ALIGNLEFT = 0x31; - private static final int ALIGNRIGHT = 0x32; + private static final int HALIGNCENTER = 3; + private static final int HALIGNLEFT = 1; + private static final int HALIGNRIGHT = 2; + // vertical alignment + private static final int VALIGNTOP = 1; + private static final int VALIGNBOTTOM = 2; + private static final int VALIGNCENTER = 3; private static Context context; @@ -74,8 +77,7 @@ public class Cocos2dxBitmap{ // Draw string FontMetricsInt fm = paint.getFontMetricsInt(); int x = 0; - int y = height == 0 ?(-fm.top): - (-fm.top + (height - textProperty.totalHeight)/2); + int y = computeY(fm, height, textProperty.totalHeight, alignment); String[] lines = textProperty.lines; for (String line : lines){ x = computeX(paint, line, textProperty.maxWidth, alignment); @@ -88,17 +90,18 @@ public class Cocos2dxBitmap{ private static int computeX(Paint paint, String content, int w, int alignment){ int ret = 0; + int hAlignment = alignment & 0x0F; - switch (alignment){ - case ALIGNCENTER: + switch (hAlignment){ + case HALIGNCENTER: ret = w / 2; break; // ret = 0 - case ALIGNLEFT: + case HALIGNLEFT: break; - case ALIGNRIGHT: + case HALIGNRIGHT: ret = w; break; @@ -113,6 +116,30 @@ public class Cocos2dxBitmap{ return ret; } + private static int computeY(FontMetricsInt fm, int constrainHeight, int totalHeight, int alignment) { + int y = -fm.top; + + if (constrainHeight > totalHeight) { + int vAlignment = (alignment >> 4) & 0x0F; + + switch (vAlignment) { + case VALIGNTOP: + y = -fm.top; + break; + case VALIGNCENTER: + y = -fm.top + (constrainHeight - totalHeight)/2; + break; + case VALIGNBOTTOM: + y = -fm.top + (constrainHeight - totalHeight); + break; + default: + break; + } + } + + return y; + } + private static class TextProperty{ // The max width of lines int maxWidth; @@ -258,6 +285,10 @@ public class Cocos2dxBitmap{ strList.add(content.substring(start, i)); } } + + // remove spaces at the beginning of a new line + while(content.indexOf(i++) == ' ') { + } start = i; } @@ -301,16 +332,17 @@ public class Cocos2dxBitmap{ paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL)); } - switch (alignment){ - case ALIGNCENTER: + int hAlignment = alignment & 0x0F; + switch (hAlignment){ + case HALIGNCENTER: paint.setTextAlign(Align.CENTER); break; - case ALIGNLEFT: + case HALIGNLEFT: paint.setTextAlign(Align.LEFT); break; - case ALIGNRIGHT: + case HALIGNRIGHT: paint.setTextAlign(Align.RIGHT); break; diff --git a/tests/tests/LabelTest/LabelTest.cpp b/tests/tests/LabelTest/LabelTest.cpp index ed1bfc966d..790a15b383 100644 --- a/tests/tests/LabelTest/LabelTest.cpp +++ b/tests/tests/LabelTest/LabelTest.cpp @@ -369,21 +369,21 @@ std::string LabelAtlasColorTest::subtitle() //------------------------------------------------------------------ LabelTTFAlignment::LabelTTFAlignment() { - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - CCLabelTTF* ttf0 = CCLabelTTF::labelWithString("Alignment 0\nnew line", CCSizeMake(256, 32), kCCTextAlignmentLeft, "Helvetica", 12); - ttf0->setPosition(ccp(s.width/2,(s.height/6)*2)); - ttf0->setAnchorPoint(ccp(0.5f,0.5f)); - this->addChild(ttf0); - - CCLabelTTF* ttf1 = CCLabelTTF::labelWithString("Alignment 1\nnew line", CCSizeMake(245, 32), kCCTextAlignmentCenter, "Helvetica", 12); - ttf1->setPosition(ccp(s.width/2,(s.height/6)*3)); - ttf1->setAnchorPoint(ccp(0.5f,0.5f)); - this->addChild(ttf1); - - CCLabelTTF* ttf2 = CCLabelTTF::labelWithString("Alignment 2\nnew line", CCSizeMake(245, 32), kCCTextAlignmentRight, "Helvetica", 12); - ttf2->setPosition(ccp(s.width/2,(s.height/6)*4)); - ttf2->setAnchorPoint(ccp(0.5f,0.5f)); + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCLabelTTF* ttf0 = CCLabelTTF::labelWithString("Alignment 0\nnew line", CCSizeMake(256, 32), kCCTextAlignmentLeft, "Helvetica", 12); + ttf0->setPosition(ccp(s.width/2,(s.height/6)*2)); + ttf0->setAnchorPoint(ccp(0.5f,0.5f)); + this->addChild(ttf0); + + CCLabelTTF* ttf1 = CCLabelTTF::labelWithString("Alignment 1\nnew line", CCSizeMake(245, 32), kCCTextAlignmentCenter, "Helvetica", 12); + ttf1->setPosition(ccp(s.width/2,(s.height/6)*3)); + ttf1->setAnchorPoint(ccp(0.5f,0.5f)); + this->addChild(ttf1); + + CCLabelTTF* ttf2 = CCLabelTTF::labelWithString("Alignment 2\nnew line", CCSizeMake(245, 32), kCCTextAlignmentRight, "Helvetica", 12); + ttf2->setPosition(ccp(s.width/2,(s.height/6)*4)); + ttf2->setAnchorPoint(ccp(0.5f,0.5f)); this->addChild(ttf2); } @@ -947,38 +947,38 @@ void AtlasTestScene::runThisTest() //------------------------------------------------------------------ LabelTTFTest::LabelTTFTest() { - CCSize blockSize = CCSizeMake(200, 160); - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - CCLayerColor *colorLayer = CCLayerColor::layerWithColor(ccc4(100, 100, 100, 255), blockSize.width, blockSize.height); - colorLayer->setAnchorPoint(ccp(0,0)); - colorLayer->setPosition(ccp((s.width - blockSize.width) / 2, (s.height - blockSize.height) / 2)); - - this->addChild(colorLayer); - - CCMenuItemFont::setFontSize(30); - CCMenu *menu = CCMenu::menuWithItems( - CCMenuItemFont::itemWithString("Left", this, menu_selector(LabelTTFTest::setAlignmentLeft)), - CCMenuItemFont::itemWithString("Center", this, menu_selector(LabelTTFTest::setAlignmentCenter)), - CCMenuItemFont::itemWithString("Right", this, menu_selector(LabelTTFTest::setAlignmentRight)), - NULL); - menu->alignItemsVerticallyWithPadding(4); - menu->setPosition(ccp(50, s.height / 2 - 20)); - this->addChild(menu); - - menu = CCMenu::menuWithItems( - CCMenuItemFont::itemWithString("Top", this, menu_selector(LabelTTFTest::setAlignmentTop)), - CCMenuItemFont::itemWithString("Middle", this, menu_selector(LabelTTFTest::setAlignmentMiddle)), - CCMenuItemFont::itemWithString("Bottom", this, menu_selector(LabelTTFTest::setAlignmentBottom)), - NULL); - menu->alignItemsVerticallyWithPadding(4); - menu->setPosition(ccp(s.width - 50, s.height / 2 - 20)); - this->addChild(menu); - - m_plabel = NULL; - m_eHorizAlign = kCCTextAlignmentLeft; - m_eVertAlign = kCCVerticalTextAlignmentTop; - + CCSize blockSize = CCSizeMake(200, 160); + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCLayerColor *colorLayer = CCLayerColor::layerWithColor(ccc4(100, 100, 100, 255), blockSize.width, blockSize.height); + colorLayer->setAnchorPoint(ccp(0,0)); + colorLayer->setPosition(ccp((s.width - blockSize.width) / 2, (s.height - blockSize.height) / 2)); + + this->addChild(colorLayer); + + CCMenuItemFont::setFontSize(30); + CCMenu *menu = CCMenu::menuWithItems( + CCMenuItemFont::itemWithString("Left", this, menu_selector(LabelTTFTest::setAlignmentLeft)), + CCMenuItemFont::itemWithString("Center", this, menu_selector(LabelTTFTest::setAlignmentCenter)), + CCMenuItemFont::itemWithString("Right", this, menu_selector(LabelTTFTest::setAlignmentRight)), + NULL); + menu->alignItemsVerticallyWithPadding(4); + menu->setPosition(ccp(50, s.height / 2 - 20)); + this->addChild(menu); + + menu = CCMenu::menuWithItems( + CCMenuItemFont::itemWithString("Top", this, menu_selector(LabelTTFTest::setAlignmentTop)), + CCMenuItemFont::itemWithString("Middle", this, menu_selector(LabelTTFTest::setAlignmentMiddle)), + CCMenuItemFont::itemWithString("Bottom", this, menu_selector(LabelTTFTest::setAlignmentBottom)), + NULL); + menu->alignItemsVerticallyWithPadding(4); + menu->setPosition(ccp(s.width - 50, s.height / 2 - 20)); + this->addChild(menu); + + m_plabel = NULL; + m_eHorizAlign = kCCTextAlignmentLeft; + m_eVertAlign = kCCVerticalTextAlignmentTop; + this->updateAlignment(); } @@ -987,89 +987,89 @@ LabelTTFTest::~LabelTTFTest() CC_SAFE_RELEASE(m_plabel); } -void LabelTTFTest::updateAlignment() -{ - CCSize blockSize = CCSizeMake(200, 160); - CCSize s = CCDirector::sharedDirector()->getWinSize(); - +void LabelTTFTest::updateAlignment() +{ + CCSize blockSize = CCSizeMake(200, 160); + CCSize s = CCDirector::sharedDirector()->getWinSize(); + if (m_plabel) { m_plabel->removeFromParentAndCleanup(true); - } - - m_plabel = CCLabelTTF::labelWithString(this->getCurrentAlignment(), blockSize, m_eHorizAlign, m_eVertAlign, "Marker Felt", 32); - m_plabel->retain(); - - m_plabel->setAnchorPoint(ccp(0,0)); - m_plabel->setPosition(ccp((s.width - blockSize.width) / 2, (s.height - blockSize.height)/2 )); - - this->addChild(m_plabel); -} - -void LabelTTFTest::setAlignmentLeft(CCObject* pSender) -{ - m_eHorizAlign = kCCTextAlignmentLeft; - this->updateAlignment(); -} - -void LabelTTFTest::setAlignmentCenter(CCObject* pSender) -{ - m_eHorizAlign = kCCTextAlignmentCenter; - this->updateAlignment(); -} - -void LabelTTFTest::setAlignmentRight(CCObject* pSender) -{ - m_eHorizAlign = kCCTextAlignmentRight; - this->updateAlignment(); -} - -void LabelTTFTest::setAlignmentTop(CCObject* pSender) -{ - m_eVertAlign = kCCVerticalTextAlignmentTop; - this->updateAlignment(); -} - -void LabelTTFTest::setAlignmentMiddle(CCObject* pSender) -{ - m_eVertAlign = kCCVerticalTextAlignmentCenter; - this->updateAlignment(); -} - -void LabelTTFTest::setAlignmentBottom(CCObject* pSender) -{ - m_eVertAlign = kCCVerticalTextAlignmentBottom; - this->updateAlignment(); -} - -const char* LabelTTFTest::getCurrentAlignment() -{ - const char* vertical = NULL; - const char* horizontal = NULL; - switch (m_eVertAlign) { - case kCCVerticalTextAlignmentTop: - vertical = "Top"; - break; - case kCCVerticalTextAlignmentCenter: - vertical = "Middle"; - break; - case kCCVerticalTextAlignmentBottom: - vertical = "Bottom"; - break; - } - switch (m_eHorizAlign) { - case kCCTextAlignmentLeft: - horizontal = "Left"; - break; - case kCCTextAlignmentCenter: - horizontal = "Center"; - break; - case kCCTextAlignmentRight: - horizontal = "Right"; - break; - } - - return CCString::stringWithFormat("Alignment %s %s", vertical, horizontal)->getCString(); + } + + m_plabel = CCLabelTTF::labelWithString(this->getCurrentAlignment(), blockSize, m_eHorizAlign, m_eVertAlign, "Marker Felt", 32); + m_plabel->retain(); + + m_plabel->setAnchorPoint(ccp(0,0)); + m_plabel->setPosition(ccp((s.width - blockSize.width) / 2, (s.height - blockSize.height)/2 )); + + this->addChild(m_plabel); +} + +void LabelTTFTest::setAlignmentLeft(CCObject* pSender) +{ + m_eHorizAlign = kCCTextAlignmentLeft; + this->updateAlignment(); +} + +void LabelTTFTest::setAlignmentCenter(CCObject* pSender) +{ + m_eHorizAlign = kCCTextAlignmentCenter; + this->updateAlignment(); +} + +void LabelTTFTest::setAlignmentRight(CCObject* pSender) +{ + m_eHorizAlign = kCCTextAlignmentRight; + this->updateAlignment(); +} + +void LabelTTFTest::setAlignmentTop(CCObject* pSender) +{ + m_eVertAlign = kCCVerticalTextAlignmentTop; + this->updateAlignment(); +} + +void LabelTTFTest::setAlignmentMiddle(CCObject* pSender) +{ + m_eVertAlign = kCCVerticalTextAlignmentCenter; + this->updateAlignment(); +} + +void LabelTTFTest::setAlignmentBottom(CCObject* pSender) +{ + m_eVertAlign = kCCVerticalTextAlignmentBottom; + this->updateAlignment(); +} + +const char* LabelTTFTest::getCurrentAlignment() +{ + const char* vertical = NULL; + const char* horizontal = NULL; + switch (m_eVertAlign) { + case kCCVerticalTextAlignmentTop: + vertical = "Top"; + break; + case kCCVerticalTextAlignmentCenter: + vertical = "Middle"; + break; + case kCCVerticalTextAlignmentBottom: + vertical = "Bottom"; + break; + } + switch (m_eHorizAlign) { + case kCCTextAlignmentLeft: + horizontal = "Left"; + break; + case kCCTextAlignmentCenter: + horizontal = "Center"; + break; + case kCCTextAlignmentRight: + horizontal = "Right"; + break; + } + + return CCString::stringWithFormat("Alignment %s %s", vertical, horizontal)->getCString(); } string LabelTTFTest::title() @@ -1419,24 +1419,24 @@ std::string BMFontUnicode::title() std::string BMFontUnicode::subtitle() { return "You should see 3 differnt labels: In Spanish, Chinese and Korean"; -} - -// BMFontInit - -BMFontInit::BMFontInit() -{ - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - CCLabelBMFont* bmFont = new CCLabelBMFont(); - bmFont->init(); - bmFont->autorelease(); - //CCLabelBMFont* bmFont = [CCLabelBMFont labelWithString:@"Foo" fntFile:@"arial-unicode-26.fnt"]; - bmFont->setFntFile("fonts/helvetica-32.fnt"); - bmFont->setString("It is working!"); - this->addChild(bmFont); - bmFont->setPosition(ccp(s.width/2,s.height/4*2)); -} - +} + +// BMFontInit + +BMFontInit::BMFontInit() +{ + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCLabelBMFont* bmFont = new CCLabelBMFont(); + bmFont->init(); + bmFont->autorelease(); + //CCLabelBMFont* bmFont = [CCLabelBMFont labelWithString:@"Foo" fntFile:@"arial-unicode-26.fnt"]; + bmFont->setFntFile("fonts/helvetica-32.fnt"); + bmFont->setString("It is working!"); + this->addChild(bmFont); + bmFont->setPosition(ccp(s.width/2,s.height/4*2)); +} + std::string BMFontInit::title() { return "CCLabelBMFont init"; @@ -1445,24 +1445,24 @@ std::string BMFontInit::title() std::string BMFontInit::subtitle() { return "Test for support of init method without parameters."; -} - -// TTFFontInit - -TTFFontInit::TTFFontInit() -{ - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - CCLabelTTF* font = new CCLabelTTF(); - font->init(); - font->autorelease(); - font->setFontName("Marker Felt"); - font->setFontSize(48); - font->setString("It is working!"); - this->addChild(font); - font->setPosition(ccp(s.width/2,s.height/4*2)); -} - +} + +// TTFFontInit + +TTFFontInit::TTFFontInit() +{ + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCLabelTTF* font = new CCLabelTTF(); + font->init(); + font->autorelease(); + font->setFontName("Marker Felt"); + font->setFontSize(48); + font->setString("It is working!"); + this->addChild(font); + font->setPosition(ccp(s.width/2,s.height/4*2)); +} + std::string TTFFontInit::title() { return "CCLabelTTF init"; @@ -1472,25 +1472,25 @@ std::string TTFFontInit::subtitle() { return "Test for support of init method without parameters."; } - - -// Issue1343 - -Issue1343::Issue1343() -{ - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - CCLabelBMFont* bmFont = new CCLabelBMFont(); - bmFont->init(); - bmFont->setFntFile("fonts/font-issue1343.fnt"); - bmFont->setString("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz.,'"); - this->addChild(bmFont); - bmFont->release(); - bmFont->setScale(0.3f); - - bmFont->setPosition(ccp(s.width/2,s.height/4*2)); -} - + + +// Issue1343 + +Issue1343::Issue1343() +{ + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCLabelBMFont* bmFont = new CCLabelBMFont(); + bmFont->init(); + bmFont->setFntFile("fonts/font-issue1343.fnt"); + bmFont->setString("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz.,'"); + this->addChild(bmFont); + bmFont->release(); + bmFont->setScale(0.3f); + + bmFont->setPosition(ccp(s.width/2,s.height/4*2)); +} + std::string Issue1343::title() { return "Issue 1343"; From 29b22adcccfbadff2ceef0dac8f085a2d83f1724 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 13 Jun 2012 14:19:13 -0700 Subject: [PATCH 149/257] Batch converted manual 'using namespace cocos2d(::extension);' to USING_NS_CC(_EXT);. CocosBuilderExample: Made HelloCococsBuilderLayer selectors work. Made ButtonTestLayer work. --- cocos2dx/CCDirector.cpp | 4 +- cocos2dx/extensions/CCBIReader/CCBReader.h | 155 ---- .../extensions/CCBReader/CCBCustomClass.cpp | 86 -- .../extensions/CCBReader/CCBCustomClass.h | 100 --- .../CCBFileLoader.cpp | 4 +- .../{CCBIReader => CCBReader}/CCBFileLoader.h | 0 .../CCBMemberVariableAssigner.h | 0 .../{CCBIReader => CCBReader}/CCBReader.cpp | 21 +- cocos2dx/extensions/CCBReader/CCBReader.h | 257 +++--- .../extensions/CCBReader/CCBReader_v1.cpp | 710 ---------------- .../extensions/CCBReader/CCBReader_v2.cpp | 771 ------------------ .../CCBSelectorResolver.h | 0 .../CCControlButtonLoader.cpp | 4 +- .../CCControlButtonLoader.h | 0 .../CCControlLoader.cpp | 4 +- .../CCControlLoader.h | 0 .../CCLabelBMFontLoader.cpp | 4 +- .../CCLabelBMFontLoader.h | 0 .../CCLabelTTFLoader.cpp | 4 +- .../CCLabelTTFLoader.h | 0 .../CCLayerColorLoader.cpp | 4 +- .../CCLayerColorLoader.h | 0 .../CCLayerGradientLoader.cpp | 4 +- .../CCLayerGradientLoader.h | 0 .../CCLayerLoader.cpp | 4 +- .../{CCBIReader => CCBReader}/CCLayerLoader.h | 0 .../CCMenuItemImageLoader .cpp | 16 +- .../CCMenuItemImageLoader.h | 0 .../CCMenuItemLoader.cpp | 4 +- .../CCMenuItemLoader.h | 0 .../CCMenuLoader.cpp | 4 +- .../{CCBIReader => CCBReader}/CCMenuLoader.h | 0 .../CCNodeLoader.cpp | 51 +- .../{CCBIReader => CCBReader}/CCNodeLoader.h | 0 .../CCNodeLoaderLibrary.cpp | 8 +- .../CCNodeLoaderLibrary.h | 0 .../CCNodeLoaderListener.h | 2 - .../CCParticleSystemQuadLoader.cpp | 4 +- .../CCParticleSystemQuadLoader.h | 0 .../CCScale9SpriteLoader.cpp | 4 +- .../CCScale9SpriteLoader.h | 0 .../CCSpriteLoader.cpp | 4 +- .../CCSpriteLoader.h | 0 .../CCControlExtension/CCScale9Sprite.cpp | 10 +- cocos2dx/platform/ios/CCFileUtils.mm | 2 +- .../CocosBuilder_v2/TestTemplate.ccbt | 21 - .../pub/res/burst-hd.png.REMOVED.git-id | 1 + .../pub/res/burst-ipad.png.REMOVED.git-id | 1 + .../pub/res/flower.jpg.REMOVED.git-id | 1 + .../markerfelt24shadow.fnt.REMOVED.git-id | 0 .../src/res/burst-hd.png.REMOVED.git-id | 1 + .../src/res/burst-ipad.png.REMOVED.git-id | 1 + .../src/res/flower.jpg.REMOVED.git-id | 1 + .../markerfelt24shadow.fnt.REMOVED.git-id | 0 .../pub/fonts/Droid.ttf.REMOVED.git-id | 0 .../src/fonts/Droid.ttf.REMOVED.git-id | 0 .../project.pbxproj.REMOVED.git-id | 2 +- .../AccelerometerTest/AccelerometerTest.h | 2 +- tests/tests/ActionsEaseTest/ActionsEaseTest.h | 2 +- tests/tests/ActionsTest/ActionsTest.h | 2 +- .../Bug-458/QuestionContainerSprite.cpp | 2 +- .../CocosDenshionTest/CocosDenshionTest.cpp | 2 +- .../CCBIReaderTest/CCBIReaderLayer.cpp | 98 --- .../CCBIReaderTest/CCBIReaderLayer.h | 27 - .../CCBIReaderTest/CCBIReaderTest.cpp | 54 -- .../CCBIReaderTest/CCBIReaderTest.h | 35 - .../CocosBuilderTest/ButtonTestLayer.cpp | 33 + .../CocosBuilderTest/ButtonTestLayer.h | 18 + .../ButtonTestLayerLoader.cpp | 8 + .../CocosBuilderTest/ButtonTestLayerLoader.h | 18 + .../CocosBuilderTest/CocosBuilderTest.cpp | 49 +- .../CocosBuilderTest/CocosBuilderTest.h | 35 +- .../CocosBuilderTest/HelloCocosBuilder.cpp | 96 --- .../CocosBuilderTest/HelloCocosBuilder.h | 63 -- .../HelloCocosBuilderLayer.cpp | 132 +++ .../CocosBuilderTest/HelloCocosBuilderLayer.h | 43 + .../HelloCocosBuilderLayerLoader.cpp | 8 + .../HelloCocosBuilderLayerLoader.h | 18 + .../CocosBuilderTest/TestHeaderLayer.cpp | 34 + .../CocosBuilderTest/TestHeaderLayer.h | 18 + .../TestHeaderLayerLoader.cpp | 8 + .../CocosBuilderTest/TestHeaderLayerLoader.h | 18 + tests/tests/ExtensionsTest/ExtensionsTest.cpp | 13 - .../tests/MotionStreakTest/MotionStreakTest.h | 2 +- .../TextureCacheTest/TextureCacheTest.cpp | 2 +- tests/tests/TouchesTest/Ball.h | 2 +- tests/tests/TouchesTest/Paddle.h | 2 +- tests/tests/TouchesTest/TouchesTest.h | 2 +- tests/tests/TransitionsTest/TransitionsTest.h | 2 +- tests/tests/controller.h | 2 +- 90 files changed, 668 insertions(+), 2456 deletions(-) delete mode 100644 cocos2dx/extensions/CCBIReader/CCBReader.h delete mode 100644 cocos2dx/extensions/CCBReader/CCBCustomClass.cpp delete mode 100644 cocos2dx/extensions/CCBReader/CCBCustomClass.h rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCBFileLoader.cpp (90%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCBFileLoader.h (100%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCBMemberVariableAssigner.h (100%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCBReader.cpp (92%) delete mode 100644 cocos2dx/extensions/CCBReader/CCBReader_v1.cpp delete mode 100644 cocos2dx/extensions/CCBReader/CCBReader_v2.cpp rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCBSelectorResolver.h (100%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCControlButtonLoader.cpp (99%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCControlButtonLoader.h (100%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCControlLoader.cpp (95%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCControlLoader.h (100%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCLabelBMFontLoader.cpp (97%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCLabelBMFontLoader.h (100%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCLabelTTFLoader.cpp (98%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCLabelTTFLoader.h (100%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCLayerColorLoader.cpp (95%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCLayerColorLoader.h (100%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCLayerGradientLoader.cpp (97%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCLayerGradientLoader.h (100%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCLayerLoader.cpp (95%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCLayerLoader.h (100%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCMenuItemImageLoader .cpp (68%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCMenuItemImageLoader.h (100%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCMenuItemLoader.cpp (93%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCMenuItemLoader.h (100%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCMenuLoader.cpp (68%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCMenuLoader.h (100%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCNodeLoader.cpp (94%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCNodeLoader.h (100%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCNodeLoaderLibrary.cpp (96%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCNodeLoaderLibrary.h (100%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCNodeLoaderListener.h (99%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCParticleSystemQuadLoader.cpp (99%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCParticleSystemQuadLoader.h (100%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCScale9SpriteLoader.cpp (98%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCScale9SpriteLoader.h (100%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCSpriteLoader.cpp (97%) rename cocos2dx/extensions/{CCBIReader => CCBReader}/CCSpriteLoader.h (100%) delete mode 100644 tests/Resources/CocosBuilder_v2/TestTemplate.ccbt create mode 100644 tests/Resources/ccb/official/pub/res/burst-hd.png.REMOVED.git-id create mode 100644 tests/Resources/ccb/official/pub/res/burst-ipad.png.REMOVED.git-id create mode 100644 tests/Resources/ccb/official/pub/res/flower.jpg.REMOVED.git-id rename tests/Resources/{CocosBuilder_v1 => ccb/official/pub/res}/markerfelt24shadow.fnt.REMOVED.git-id (100%) create mode 100644 tests/Resources/ccb/official/src/res/burst-hd.png.REMOVED.git-id create mode 100644 tests/Resources/ccb/official/src/res/burst-ipad.png.REMOVED.git-id create mode 100644 tests/Resources/ccb/official/src/res/flower.jpg.REMOVED.git-id rename tests/Resources/{CocosBuilder_v2 => ccb/official/src/res}/markerfelt24shadow.fnt.REMOVED.git-id (100%) rename tests/Resources/ccb/{ => simple}/pub/fonts/Droid.ttf.REMOVED.git-id (100%) rename tests/Resources/ccb/{ => simple}/src/fonts/Droid.ttf.REMOVED.git-id (100%) delete mode 100644 tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.cpp delete mode 100644 tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.h delete mode 100644 tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderTest.cpp delete mode 100644 tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderTest.h create mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.cpp create mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.h create mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayerLoader.cpp create mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayerLoader.h delete mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder.cpp delete mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder.h create mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.cpp create mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.h create mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayerLoader.cpp create mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayerLoader.h create mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.cpp create mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.h create mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayerLoader.cpp create mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayerLoader.h diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 5841f7f6b1..914af848b8 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -54,8 +54,7 @@ THE SOFTWARE. #include "CCEGLView.h" #include "extensions/CCNotificationCenter/CCNotificationCenter.h" #include "extensions/CCTextureWatcher/CCTextureWatcher.h" -#include "extensions/CCBReader/CCBCustomClass.h" -#include "extensions/CCBIReader/CCNodeLoaderLibrary.h" +#include "extensions/CCBReader/CCNodeLoaderLibrary.h" #include using namespace std; @@ -610,7 +609,6 @@ void CCDirector::purgeDirector() CCUserDefault::purgeSharedUserDefault(); extension::CCNotificationCenter::purgeNotificationCenter(); extension::CCTextureWatcher::purgeTextureWatcher(); - extension::CCBCustomClassFactory::purgeFactory(); extension::CCNodeLoaderLibrary::purgeSharedCCNodeLoaderLibrary(); ccGLInvalidateStateCache(); diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.h b/cocos2dx/extensions/CCBIReader/CCBReader.h deleted file mode 100644 index 6216987818..0000000000 --- a/cocos2dx/extensions/CCBIReader/CCBReader.h +++ /dev/null @@ -1,155 +0,0 @@ -#ifndef _CCB_CCBREADER_H_ -#define _CCB_CCBREADER_H_ - -#include "cocos2d.h" - -#define STATIC_NEW_AUTORELEASE_OBJECT_METHOD(T, METHOD) static T * METHOD() { \ -T * t = new T(); \ -t->autorelease(); \ -return t; \ -} - -#define kCCBVersion 2 - -#define kCCBPropTypePosition 0 -#define kCCBPropTypeSize 1 -#define kCCBPropTypePoint 2 -#define kCCBPropTypePointLock 3 -#define kCCBPropTypeScaleLock 4 -#define kCCBPropTypeDegrees 5 -#define kCCBPropTypeInteger 6 -#define kCCBPropTypeFloat 7 -#define kCCBPropTypeFloatVar 8 -#define kCCBPropTypeCheck 9 -#define kCCBPropTypeSpriteFrame 10 -#define kCCBPropTypeTexture 11 -#define kCCBPropTypeByte 12 -#define kCCBPropTypeColor3 13 -#define kCCBPropTypeColor4FVar 14 -#define kCCBPropTypeFlip 15 -#define kCCBPropTypeBlendFunc 16 -#define kCCBPropTypeFntFile 17 -#define kCCBPropTypeText 18 -#define kCCBPropTypeFontTTF 19 -#define kCCBPropTypeIntegerLabeled 20 -#define kCCBPropTypeBlock 21 -#define kCCBPropTypeAnimation 22 -#define kCCBPropTypeCCBFile 23 -#define kCCBPropTypeString 24 -#define kCCBPropTypeBlockCCControl 25 -#define kCCBPropTypeFloatScale 26 - -#define kCCBFloat0 0 -#define kCCBFloat1 1 -#define kCCBFloatMinus1 2 -#define kCCBFloat05 3 -#define kCCBFloatInteger 4 -#define kCCBFloatFull 5 - -#define kCCBPlatformAll 0 -#define kCCBPlatformIOS 1 -#define kCCBPlatformMac 2 - -#define kCCBTargetTypeNone 0 -#define kCCBTargetTypeDocumentRoot 1 -#define kCCBTargetTypeOwner 2 - -#define kCCBPositionTypeRelativeBottomLeft 0 -#define kCCBPositionTypeRelativeTopLeft 1 -#define kCCBPositionTypeRelativeTopRight 2 -#define kCCBPositionTypeRelativeBottomRight 3 -#define kCCBPositionTypePercent 4 - -#define kCCBSizeTypeAbsolute 0 -#define kCCBSizeTypePercent 1 -#define kCCBSizeTypeRelativeContainer 2 -#define kCCBSizeTypeHorizontalPercent 3 -#define kCCBSzieTypeVerticalPercent 4 - - -#define kCCBScaleTypeAbsolute 0 -#define kCCBScaleTypeMultiplyResolution 1 - -NS_CC_EXT_BEGIN - -/* Forward declaration. */ -class CCNodeLoader; -class CCNodeLoaderLibrary; -class CCNodeLoaderListener; -class CCBMemberVariableAssigner; -class CCBSelectorResolver; - -/** - * @brief Parse CCBI file which is generated by CocosBuilder - */ -class CC_DLL CCBReader : public CCObject { - private: - std::string mCCBRootPath; - bool mRootCCBReader; - - unsigned char * mBytes; - int mCurrentByte; - int mCurrentBit; - CCObject * mOwner; - CCNode * mRootNode; - CCSize mRootContainerSize; - float mResolutionScale; - - CCNodeLoaderLibrary * mCCNodeLoaderLibrary; - CCNodeLoaderListener * mCCNodeLoaderListener; - CCBMemberVariableAssigner * mCCBMemberVariableAssigner; - CCBSelectorResolver * mCCBSelectorResolver; - - std::vector mStringCache; - std::set mLoadedSpriteSheets; - - public: - /* Constructor. */ - CCBReader(CCNodeLoaderLibrary *, CCBMemberVariableAssigner * = NULL, CCBSelectorResolver * = NULL, CCNodeLoaderListener * = NULL); - CCBReader(CCBReader *); - /* Destructor. */ - ~CCBReader(); - - CCNode * readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner = NULL); - CCNode * readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize); - CCBMemberVariableAssigner * getCCBMemberVariableAssigner(); - CCBSelectorResolver * getCCBSelectorResolver(); - - std::string getCCBRootPath(); - CCObject * getOwner(); - CCNode * getRootNode(); - CCSize getContainerSize(CCNode *); - float getResolutionScale(); - - bool isSpriteSheetLoaded(const char *); - void addLoadedSpriteSheet(const char *); - - /* Utility methods. */ - std::string lastPathComponent(const char *); - std::string deletePathExtension(const char *); - std::string toLowerCase(const char *); - bool endsWith(const char *, const char *); - std::string concat(const char *, const char *); - - /* Parse methods. */ - int readInt(bool pSign); - unsigned char readByte(); - bool readBool(); - float readFloat(); - std::string readCachedString(); - - private: - bool readHeader(); - bool readStringCache(); - void readStringCacheEntry(); - CCNode * readNodeGraph(); - CCNode * readNodeGraph(CCNode *); - - bool getBit(); - void alignBits(); - const char * readUTF8(); -}; - -NS_CC_EXT_END - -#endif \ No newline at end of file diff --git a/cocos2dx/extensions/CCBReader/CCBCustomClass.cpp b/cocos2dx/extensions/CCBReader/CCBCustomClass.cpp deleted file mode 100644 index 9d886fd8ba..0000000000 --- a/cocos2dx/extensions/CCBReader/CCBCustomClass.cpp +++ /dev/null @@ -1,86 +0,0 @@ -/**************************************************************************** - Copyright (c) 2012 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCBCustomClass.h" - -USING_NS_CC_EXT; - -static CCBCustomClassFactory* g_pFactoryInstance = NULL; - -// CCBCustomClassFactory -CCBCustomClassFactory::CCBCustomClassFactory() -{ - m_pCustomCreatorsMap = new CUSTOM_CLASS_MAP; -} - -CCBCustomClassFactory::~CCBCustomClassFactory() -{ - CC_SAFE_DELETE(m_pCustomCreatorsMap); -} - -CCBCustomClassFactory* CCBCustomClassFactory::sharedFactory() -{ - if (g_pFactoryInstance == NULL) - { - g_pFactoryInstance = new CCBCustomClassFactory(); - } - return g_pFactoryInstance; -} - -void CCBCustomClassFactory::purgeFactory() -{ - CC_SAFE_DELETE(g_pFactoryInstance); -} - -bool CCBCustomClassFactory::registCustomClass(const char* name, FUNC_CUSTON_CLASS_CREATOR pfnCreator) -{ - bool bRetVal = false; - - if (! (*m_pCustomCreatorsMap)[name] ) - { - (*m_pCustomCreatorsMap)[name] = pfnCreator; - bRetVal = true; - } - else - { - CCLOG("CCB: key = [%s] in m_pCustomCreatorsMap is already registed", name); - } - - return bRetVal; -} - -CCBCustomClassProtocol* CCBCustomClassFactory::createCustomClassWithName(const char* name) -{ - CCBCustomClassProtocol* pRetVal = NULL; - FUNC_CUSTON_CLASS_CREATOR pfnCreator = (*m_pCustomCreatorsMap)[name]; - - if (pfnCreator) - { - CCLOG("CCB: creating [%s] object", name); - pRetVal = pfnCreator(); - } - - return pRetVal; -} - diff --git a/cocos2dx/extensions/CCBReader/CCBCustomClass.h b/cocos2dx/extensions/CCBReader/CCBCustomClass.h deleted file mode 100644 index 7f87d7574c..0000000000 --- a/cocos2dx/extensions/CCBReader/CCBCustomClass.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** - Copyright (c) 2012 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef _CC_CUSTOM_CLASS_H_ -#define _CC_CUSTOM_CLASS_H_ - -#include "cocos2d.h" -#include - -NS_CC_EXT_BEGIN - -/** - @brief This is a simple reflection implement for custom classes in CocosBuilder - - You should declare your custom class like: - class MyCustomLayer : public CCBCustomClass, public CCLayer - CCBCustomClass is a pure virtual class. It doesn't inherit CCObject to prevent dead-diamond. -*/ -class CCBCustomClassProtocol -{ -public: - /** You should implement this static function in your custom class, and return a valid object */ - static CCBCustomClassProtocol* createInstance() { return NULL; }; // cannot create virual class here - - CCBCustomClassProtocol() {}; - virtual ~CCBCustomClassProtocol() {}; - - /** This pure virtual methods should be implemented in your custom class - please refer to tests/ExtensionsTest/CocosBuilderTest as a sample */ - virtual bool callbackSetChildren(const char* name, cocos2d::CCObject* node) = 0; - - /** This pure virtual methods should be implemented in your custom class - please refer to tests/ExtensionsTest/CocosBuilderTest as a sample */ - virtual cocos2d::SEL_MenuHandler callbackGetSelectors(const char* selectorName) = 0; - - /** This pure virtual methods should be implemented in your custom class - please refer to tests/ExtensionsTest/CocosBuilderTest as a sample */ - virtual void callbackAfterCCBLoaded() = 0; -}; - -/** - @brief CCBCustomClass should be registed into this factory, then CCBReader can create your custom class via its name string. - - See tests/Extensionstest/CocosBuilderTest/CocosBuilderTest.cpp as the reference - */ -class CC_DLL CCBCustomClassFactory -{ -private: - /// a function pointer for CCCustomClassProtocol::createInstance - typedef CCBCustomClassProtocol* (*FUNC_CUSTON_CLASS_CREATOR)(); - typedef std::map CUSTOM_CLASS_MAP; - CUSTOM_CLASS_MAP* m_pCustomCreatorsMap; - -public: - CCBCustomClassFactory(); - virtual ~CCBCustomClassFactory(); - - /** get the singleton */ - static CCBCustomClassFactory* sharedFactory(); - - /** purge the singleton */ - static void purgeFactory(); - - /** Note that you should regist custom class before invoke CCBReader::nodeGraphFromFile - For example: - CCBCustomClassFactory::sharedFactory()->registCustomClass("HelloCocosBuilder", - HelloCocosBuilder::createInstance); - */ - bool registCustomClass(const char* name, FUNC_CUSTON_CLASS_CREATOR pfnCreator); - - /** This function is only used in CCBReader. Developers don't need to know it */ - CCBCustomClassProtocol* createCustomClassWithName(const char* name); - - -}; - -NS_CC_EXT_END; - -#endif // _CC_CUSTOM_CLASS_H_ diff --git a/cocos2dx/extensions/CCBIReader/CCBFileLoader.cpp b/cocos2dx/extensions/CCBReader/CCBFileLoader.cpp similarity index 90% rename from cocos2dx/extensions/CCBIReader/CCBFileLoader.cpp rename to cocos2dx/extensions/CCBReader/CCBFileLoader.cpp index 45493f4fc3..6d5642f931 100644 --- a/cocos2dx/extensions/CCBIReader/CCBFileLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCBFileLoader.cpp @@ -1,7 +1,7 @@ #include "CCBFileLoader.h" -using namespace cocos2d; -using namespace cocos2d::extension; +USING_NS_CC; +USING_NS_CC_EXT; #define PROPERTY_CCBFILE "ccbFile" diff --git a/cocos2dx/extensions/CCBIReader/CCBFileLoader.h b/cocos2dx/extensions/CCBReader/CCBFileLoader.h similarity index 100% rename from cocos2dx/extensions/CCBIReader/CCBFileLoader.h rename to cocos2dx/extensions/CCBReader/CCBFileLoader.h diff --git a/cocos2dx/extensions/CCBIReader/CCBMemberVariableAssigner.h b/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h similarity index 100% rename from cocos2dx/extensions/CCBIReader/CCBMemberVariableAssigner.h rename to cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h diff --git a/cocos2dx/extensions/CCBIReader/CCBReader.cpp b/cocos2dx/extensions/CCBReader/CCBReader.cpp similarity index 92% rename from cocos2dx/extensions/CCBIReader/CCBReader.cpp rename to cocos2dx/extensions/CCBReader/CCBReader.cpp index 3fca7b3c18..263c7d4de5 100644 --- a/cocos2dx/extensions/CCBIReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader.cpp @@ -10,8 +10,8 @@ #include #endif -using namespace cocos2d; -using namespace cocos2d::extension; +USING_NS_CC; +USING_NS_CC_EXT; CCBReader::CCBReader(CCNodeLoaderLibrary * pCCNodeLoaderLibrary, CCBMemberVariableAssigner * pCCBMemberVariableAssigner, CCBSelectorResolver * pCCBSelectorResolver, CCNodeLoaderListener * pCCNodeLoaderListener) { this->mRootNode = NULL; @@ -62,6 +62,8 @@ CCBReader::CCBReader(CCBReader * pCCBReader) { this->mResolutionScale = pCCBReader->mResolutionScale; this->mLoadedSpriteSheets = pCCBReader->mLoadedSpriteSheets; this->mCCNodeLoaderLibrary = pCCBReader->mCCNodeLoaderLibrary; + this->mCCNodeLoaderLibrary->retain(); + this->mCCBMemberVariableAssigner = pCCBReader->mCCBMemberVariableAssigner; this->mCCBSelectorResolver = pCCBReader->mCCBSelectorResolver; this->mCCNodeLoaderListener = pCCBReader->mCCNodeLoaderListener; @@ -291,7 +293,15 @@ CCNode * CCBReader::readNodeGraph(CCNode * pParent) { } if(target != NULL) { - if(this->mCCBMemberVariableAssigner != NULL) { + bool assigned = false; + + CCBMemberVariableAssigner * targetAsCCBMemberVariableAssigner = dynamic_cast(target); + + if(targetAsCCBMemberVariableAssigner != NULL) { + assigned = targetAsCCBMemberVariableAssigner->onAssignCCBMemberVariable(target, memberVarAssignmentName, node); + } + + if(!assigned && this->mCCBMemberVariableAssigner != NULL) { this->mCCBMemberVariableAssigner->onAssignCCBMemberVariable(target, memberVarAssignmentName, node); } } @@ -304,7 +314,10 @@ CCNode * CCBReader::readNodeGraph(CCNode * pParent) { node->addChild(child); } - if(this->mCCNodeLoaderListener != NULL) { + CCNodeLoaderListener * nodeAsCCNodeLoaderListener = dynamic_cast(node); + if(nodeAsCCNodeLoaderListener != NULL) { + nodeAsCCNodeLoaderListener->onNodeLoaded(node, ccNodeLoader); + } else if(this->mCCNodeLoaderListener != NULL) { this->mCCNodeLoaderListener->onNodeLoaded(node, ccNodeLoader); } diff --git a/cocos2dx/extensions/CCBReader/CCBReader.h b/cocos2dx/extensions/CCBReader/CCBReader.h index 365da70896..6216987818 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader.h +++ b/cocos2dx/extensions/CCBReader/CCBReader.h @@ -1,128 +1,155 @@ -/**************************************************************************** - Copyright (c) 2012 cocos2d-x.org - Copyright (c) 2012 XiaoLong Zhang, Chukong Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - - -#ifndef __CCB_READER_H__ -#define __CCB_READER_H__ +#ifndef _CCB_CCBREADER_H_ +#define _CCB_CCBREADER_H_ #include "cocos2d.h" -#include "CCBCustomClass.h" -#define CCB_READER_VERSION 2 +#define STATIC_NEW_AUTORELEASE_OBJECT_METHOD(T, METHOD) static T * METHOD() { \ +T * t = new T(); \ +t->autorelease(); \ +return t; \ +} + +#define kCCBVersion 2 + +#define kCCBPropTypePosition 0 +#define kCCBPropTypeSize 1 +#define kCCBPropTypePoint 2 +#define kCCBPropTypePointLock 3 +#define kCCBPropTypeScaleLock 4 +#define kCCBPropTypeDegrees 5 +#define kCCBPropTypeInteger 6 +#define kCCBPropTypeFloat 7 +#define kCCBPropTypeFloatVar 8 +#define kCCBPropTypeCheck 9 +#define kCCBPropTypeSpriteFrame 10 +#define kCCBPropTypeTexture 11 +#define kCCBPropTypeByte 12 +#define kCCBPropTypeColor3 13 +#define kCCBPropTypeColor4FVar 14 +#define kCCBPropTypeFlip 15 +#define kCCBPropTypeBlendFunc 16 +#define kCCBPropTypeFntFile 17 +#define kCCBPropTypeText 18 +#define kCCBPropTypeFontTTF 19 +#define kCCBPropTypeIntegerLabeled 20 +#define kCCBPropTypeBlock 21 +#define kCCBPropTypeAnimation 22 +#define kCCBPropTypeCCBFile 23 +#define kCCBPropTypeString 24 +#define kCCBPropTypeBlockCCControl 25 +#define kCCBPropTypeFloatScale 26 + +#define kCCBFloat0 0 +#define kCCBFloat1 1 +#define kCCBFloatMinus1 2 +#define kCCBFloat05 3 +#define kCCBFloatInteger 4 +#define kCCBFloatFull 5 + +#define kCCBPlatformAll 0 +#define kCCBPlatformIOS 1 +#define kCCBPlatformMac 2 + +#define kCCBTargetTypeNone 0 +#define kCCBTargetTypeDocumentRoot 1 +#define kCCBTargetTypeOwner 2 + +#define kCCBPositionTypeRelativeBottomLeft 0 +#define kCCBPositionTypeRelativeTopLeft 1 +#define kCCBPositionTypeRelativeTopRight 2 +#define kCCBPositionTypeRelativeBottomRight 3 +#define kCCBPositionTypePercent 4 + +#define kCCBSizeTypeAbsolute 0 +#define kCCBSizeTypePercent 1 +#define kCCBSizeTypeRelativeContainer 2 +#define kCCBSizeTypeHorizontalPercent 3 +#define kCCBSzieTypeVerticalPercent 4 + + +#define kCCBScaleTypeAbsolute 0 +#define kCCBScaleTypeMultiplyResolution 1 NS_CC_EXT_BEGIN +/* Forward declaration. */ +class CCNodeLoader; +class CCNodeLoaderLibrary; +class CCNodeLoaderListener; +class CCBMemberVariableAssigner; +class CCBSelectorResolver; + /** - @brief Parse CCB file which is generated by CocosBuilder - @warning support CocosBuilder v1 currently. I will update this to v3 when CCB format is stable + * @brief Parse CCBI file which is generated by CocosBuilder */ -class CC_DLL CCBReader : public CCObject -{ -public: - static CCNode* nodeGraphFromFile(const char* ccbFileName, CCNode* owner = NULL); - -private: - static CCNode* nodeGraphFromDictionary(CCDictionary* dict, - CCDictionary* extraProps, - const char* ccbFilePath, - CCNode* owner); - static CCNode* createCustomClassWithName(CCString* className); - - static CCNode* ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extraProps, - const char* assetsDir, CCNode* owner, CCNode* root); - - // read different types of values from dict +class CC_DLL CCBReader : public CCObject { + private: + std::string mCCBRootPath; + bool mRootCCBReader; - static int intValFromDict(CCDictionary* dict, const std::string key); - - static float floatValFromDict(CCDictionary* dict, const std::string key); - - static bool boolValFromDict(CCDictionary* dict, const std::string key); - - static CCPoint pointValFromDict(CCDictionary* dict, const std::string key); - - static CCSize sizeValFromDict(CCDictionary* dict, const std::string key); - - static ccColor3B ccColor3ValFromDict(CCDictionary* dict, - const std::string key); - - static ccColor4F ccColor4fValFromDict(CCDictionary* dict, - const std::string key); - - static ccBlendFunc blendFuncValFromDict(CCDictionary* dict, - const std::string key); - -private: - // set properties + unsigned char * mBytes; + int mCurrentByte; + int mCurrentBit; + CCObject * mOwner; + CCNode * mRootNode; + CCSize mRootContainerSize; + float mResolutionScale; - static void setExtraProp(CCObject* prop, const char* key, int tag, CCDictionary* dict); - - static void setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* extraProps); - - static void setPropsForSprite(CCSprite* node, CCDictionary* props, - CCDictionary* extraProps); - - static void setPropsForLabelBMFont(CCLabelBMFont* node, CCDictionary* props, - CCDictionary* extraProps); - - static void setPropsForParticleSystem(CCParticleSystem* node, CCDictionary* props, CCDictionary* extraProps); - - static void setPropsForMenu(CCMenu* node, CCDictionary* props, CCDictionary* extraProps); - - static void setPropsForMenuItem(CCMenuItem* node, CCDictionary* props, CCDictionary* extraProps); - - static void setPropsForMenuItemImage(CCMenuItemImage* node, CCDictionary* props, CCDictionary* extraProps); - - static void setPropsForLayer(CCLayer* node, CCDictionary* props, CCDictionary* extraProps); - - static void setPropsForLayerColor(CCLayerColor* node, CCDictionary* props, CCDictionary* extraProps); - - static void setPropsForLayerGradient(CCLayerGradient* node, CCDictionary* props, CCDictionary* extraProps); - -private: - enum - { - kCCBMemberVarAssignmentTypeNone = 0, - kCCBMemberVarAssignmentTypeDocumentRoot = 1, - kCCBMemberVarAssignmentTypeOwner = 2, - }; - - enum { - kInvalidRelativePosition = 0, - kBottomLeft = 1, - kBottom = 2, - kBottomRight = 3, - kCenterLeft = 4, - kCenter = 5, - kCenterRight = 6, - kTopLeft = 7, - kTop = 8, - kTopRight = 9, - }; -}; // end of class CCBReader + CCNodeLoaderLibrary * mCCNodeLoaderLibrary; + CCNodeLoaderListener * mCCNodeLoaderListener; + CCBMemberVariableAssigner * mCCBMemberVariableAssigner; + CCBSelectorResolver * mCCBSelectorResolver; + + std::vector mStringCache; + std::set mLoadedSpriteSheets; + + public: + /* Constructor. */ + CCBReader(CCNodeLoaderLibrary *, CCBMemberVariableAssigner * = NULL, CCBSelectorResolver * = NULL, CCNodeLoaderListener * = NULL); + CCBReader(CCBReader *); + /* Destructor. */ + ~CCBReader(); + + CCNode * readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner = NULL); + CCNode * readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize); + CCBMemberVariableAssigner * getCCBMemberVariableAssigner(); + CCBSelectorResolver * getCCBSelectorResolver(); + + std::string getCCBRootPath(); + CCObject * getOwner(); + CCNode * getRootNode(); + CCSize getContainerSize(CCNode *); + float getResolutionScale(); + + bool isSpriteSheetLoaded(const char *); + void addLoadedSpriteSheet(const char *); + + /* Utility methods. */ + std::string lastPathComponent(const char *); + std::string deletePathExtension(const char *); + std::string toLowerCase(const char *); + bool endsWith(const char *, const char *); + std::string concat(const char *, const char *); + + /* Parse methods. */ + int readInt(bool pSign); + unsigned char readByte(); + bool readBool(); + float readFloat(); + std::string readCachedString(); + + private: + bool readHeader(); + bool readStringCache(); + void readStringCacheEntry(); + CCNode * readNodeGraph(); + CCNode * readNodeGraph(CCNode *); + + bool getBit(); + void alignBits(); + const char * readUTF8(); +}; NS_CC_EXT_END -#endif // __CCB_READER_H__ \ No newline at end of file +#endif \ No newline at end of file diff --git a/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp b/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp deleted file mode 100644 index 717ce8c8d8..0000000000 --- a/cocos2dx/extensions/CCBReader/CCBReader_v1.cpp +++ /dev/null @@ -1,710 +0,0 @@ -/**************************************************************************** - Copyright (c) 2012 cocos2d-x.org - Copyright (c) 2012 XiaoLong Zhang, Chukong Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCBReader.h" -#include "CCBCustomClass.h" - -#if CCB_READER_VERSION == 1 - -USING_NS_CC; -USING_NS_CC_EXT; - -// Read value from dictionary - -int CCBReader::intValFromDict(CCDictionary* dict, const std::string key) -{ - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); - return valueString? valueString->intValue() : 0; -} - -float CCBReader::floatValFromDict(CCDictionary* dict, const std::string key) -{ - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); - return valueString? valueString->floatValue() : 0.0f; -} - -bool CCBReader::boolValFromDict(CCDictionary* dict, const std::string key) -{ - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); - return (valueString && valueString->intValue()) ? true : false; -} - -CCPoint CCBReader::pointValFromDict(CCDictionary* dict, const std::string key) -{ - CCArray* arr = (CCArray*)dict->objectForKey(key.c_str()); - - if (!arr) - { - return ccp(0,0); - } - - float x = ((CCString*)arr->objectAtIndex(0))->floatValue(); - float y = ((CCString*)arr->objectAtIndex(1))->floatValue(); - return ccp(x, y); -} - -CCSize CCBReader::sizeValFromDict(CCDictionary* dict, const std::string key) -{ - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - - if (!arr) - { - return CCSize(0, 0); - } - - float w = ((CCString*)arr->objectAtIndex(0))->floatValue(); - float h = ((CCString*)arr->objectAtIndex(1))->floatValue(); - return CCSize(w, h); -} - -ccColor3B CCBReader::ccColor3ValFromDict(CCDictionary* dict, const std::string key) -{ - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - - int r = ((CCString*)arr->objectAtIndex(0))->intValue(); - int g = ((CCString*)arr->objectAtIndex(1))->intValue(); - int b = ((CCString*)arr->objectAtIndex(2))->intValue(); - - return ccc3(r, g, b); -} - -ccColor4F CCBReader::ccColor4fValFromDict(CCDictionary* dict, const std::string key) -{ - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - - ccColor4F color; - color.r = ((CCString*)arr->objectAtIndex(0))->floatValue(); - color.g = ((CCString*)arr->objectAtIndex(1))->floatValue(); - color.b = ((CCString*)arr->objectAtIndex(2))->floatValue(); - color.a = ((CCString*)arr->objectAtIndex(3))->floatValue(); - - return color; -} - -ccBlendFunc CCBReader::blendFuncValFromDict(CCDictionary* dict, const std::string key) -{ - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - - int src = ((CCString*)arr->objectAtIndex(0))->intValue(); - int dst = ((CCString*)arr->objectAtIndex(1))->intValue(); - - ccBlendFunc blendFunc; - blendFunc.src = src; - blendFunc.dst = dst; - - return blendFunc; -} - -// set extra properties - -void CCBReader::setExtraProp(CCObject* prop, const char* key, int tag, CCDictionary* dict) -{ - std::string tagString; - tagString += tag; - CCDictionary* props = (CCDictionary*) dict->objectForKey(tagString.c_str()); - - if (!props) - { - props = new CCDictionary(); - dict->setObject(props, tagString.c_str()); - } - - props->setObject(prop, key); -} - -void CCBReader::setPropsForMenuItem(CCMenuItem* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setIsEnabled(boolValFromDict(props, "isEnabled")); - if (extraProps) - { - setExtraProp((CCDictionary*) props->objectForKey("selector"), "selector", node->getTag(), extraProps); - setExtraProp((CCDictionary*) props->objectForKey("target"), "target", node->getTag(), extraProps); - CCString* spriteFramesFile = (CCString*) props->objectForKey("spriteFramesFile"); - - if (spriteFramesFile) - { - setExtraProp(spriteFramesFile, "spriteSheetFile", node->getTag(), extraProps); - } - } -} - -void CCBReader::setPropsForMenuItemImage(CCMenuItemImage* node, CCDictionary* props, CCDictionary* extraProps) -{ - if (extraProps) - { - setExtraProp(props->objectForKey("spriteFileNormal"), "spriteFileNormal", node->getTag(), extraProps); - setExtraProp(props->objectForKey("spriteFileSelected"), "spriteFileSelected", node->getTag(), extraProps); - setExtraProp(props->objectForKey("spriteFileDisabled"), "spriteFileDisabled", node->getTag(), extraProps); - } -} - -void CCBReader::setPropsForLayerColor(CCLayerColor* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setColor(ccColor3ValFromDict(props, "color")); - node->setOpacity(intValFromDict(props, "opacity")); - node->setBlendFunc(blendFuncValFromDict(props, "blendFunc")); -} - -void CCBReader::setPropsForLayer(CCLayer* node, CCDictionary* props, CCDictionary* extraProps) -{ - if (extraProps) - { - setExtraProp(props->objectForKey("touchEnabled"), "touchEnabled", node->getTag(), extraProps); - setExtraProp(props->objectForKey("accelerometerEnabled"), "accelerometerEnabled", node->getTag(), extraProps); - setExtraProp(props->objectForKey("mouseEnabled"), "mouseEnabled", node->getTag() ,extraProps); - setExtraProp(props->objectForKey("keyboardEnabled"), "keyboardEnabled", node->getTag(), extraProps); - } - else - { - node->setIsTouchEnabled(boolValFromDict(props, "touchEnabled")); - node->setIsAccelerometerEnabled(boolValFromDict(props, "accelerometerEnabled")); - } -} - -void CCBReader::setPropsForMenu(CCMenu* node, CCDictionary* props, CCDictionary* extraProps) -{ - if (extraProps) - { - - } -} - -void CCBReader::setPropsForLabelBMFont(CCLabelBMFont* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setOpacity(intValFromDict(props, "opacity")); - node->setColor(ccColor3ValFromDict(props, "color")); - - if (extraProps) - { - setExtraProp(props->objectForKey("fontFile"), "fontFile", node->getTag(), extraProps); - } -} - -void CCBReader::setPropsForParticleSystem(CCParticleSystem* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setEmitterMode(intValFromDict(props, "emitterMode")); - node->setEmissionRate(floatValFromDict(props, "emissionRate")); - node->setDuration(floatValFromDict(props, "duration")); - node->setPosVar(pointValFromDict(props, "posVar")); - node->setTotalParticles(intValFromDict(props, "totalParticles")); - node->setLife(floatValFromDict(props, "life")); - node->setLifeVar(floatValFromDict(props, "lifeVar")); - node->setStartSize(intValFromDict(props, "startSize")); - node->setStartSizeVar(intValFromDict(props, "startSizeVar")); - node->setEndSize(intValFromDict(props, "endSize")); - node->setEndSizeVar(intValFromDict(props, "endSizeVar")); - - if (dynamic_cast(node)) - { - node->setStartSpin(intValFromDict(props, "startSpin")); - node->setStartSpinVar(intValFromDict(props, "startSpinVar")); - node->setEndSpin(intValFromDict(props, "endSpin")); - node->setEndSpinVar(intValFromDict(props, "endSpinVar")); - } - - node->setStartColor(ccColor4fValFromDict(props, "startColor")); - node->setStartColorVar(ccColor4fValFromDict(props, "startColorVar")); - node->setEndColor(ccColor4fValFromDict(props, "endColor")); - node->setEndColorVar(ccColor4fValFromDict(props, "endColorVar")); - node->setBlendFunc(blendFuncValFromDict(props, "blendFunc")); - - if (node->getEmitterMode() == kCCParticleModeGravity) - { - node->setGravity(pointValFromDict(props, "gravity")); - node->setAngle(intValFromDict(props, "angle")); - node->setAngleVar(intValFromDict(props, "angleVar")); - node->setSpeed(intValFromDict(props, "speed")); - node->setSpeedVar(intValFromDict(props, "speedVar")); - node->setTangentialAccel(intValFromDict(props, "tangentialAccel")); - node->setTangentialAccelVar(intValFromDict(props, "tangentialAccelVar")); - node->setRadialAccel(intValFromDict(props, "radialAccel")); - node->setRadialAccelVar(intValFromDict(props, "radialAccelVar")); - } - else - { - node->setStartRadius(intValFromDict(props, "startRadius")); - node->setStartRadiusVar(intValFromDict(props, "startRadiusVar")); - node->setEndRadius(intValFromDict(props, "endRadius")); - node->setEndRadiusVar(intValFromDict(props, "endRadiusVar")); - node->setRotatePerSecond(intValFromDict(props, "rotatePerSecond")); - node->setRotatePerSecondVar(intValFromDict(props, "rotatePerSecondVar")); - } - - if (extraProps) - { - setExtraProp(props->objectForKey("spriteFile"), "spriteFile", node->getTag(), extraProps); - } - node->setPositionType(kCCPositionTypeGrouped); -} - -void CCBReader::setPropsForLayerGradient(CCLayerGradient* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setStartColor(ccColor3ValFromDict(props, "color")); - node->setStartOpacity(intValFromDict(props, "opacity")); - node->setEndColor(ccColor3ValFromDict(props, "endColor")); - node->setEndOpacity(intValFromDict(props, "endOpacity")); - node->setVector(pointValFromDict(props, "vector")); -} - -CCNode* CCBReader::createCustomClassWithName(CCString* className) -{ - CCNode* pRetVal = NULL; - - if (className && className->length()) - { - CCBCustomClassProtocol* pNewClass = CCBCustomClassFactory::sharedFactory()->createCustomClassWithName(className->getCString()); - pRetVal = dynamic_cast(pNewClass); - pRetVal->autorelease(); - } - - return pRetVal; -} - -void CCBReader::setPropsForSprite(CCSprite* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setOpacity(intValFromDict(props, "opacity")); - node->setColor(ccColor3ValFromDict(props, "color")); - node->setFlipX(boolValFromDict(props, "flipX")); - node->setFlipY(boolValFromDict(props, "flipY")); - node->setBlendFunc(blendFuncValFromDict(props, "blendFunc")); - - if (extraProps) - { - setExtraProp(props->objectForKey("spriteFile"), "spriteFile", node->getTag(), extraProps); - CCString* spriteFramesFile = (CCString*) props->objectForKey("spriteFramesFile"); - - if (spriteFramesFile) - { - setExtraProp(spriteFramesFile, "spriteSheetFile", node->getTag(), extraProps); - } - } -} - -void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* extraProps) -{ - CCPoint position = pointValFromDict(props, "position"); - node->setPosition(position); - - if (dynamic_cast(node) == NULL && - dynamic_cast(node) == NULL && - dynamic_cast(node) == NULL) - { - CCSize size = sizeValFromDict(props, "contentSize"); - //node->setContentSize(size); - } - - node->setScaleX(floatValFromDict(props, "scaleX")); - node->setScaleY(floatValFromDict(props, "scaleY")); - node->setAnchorPoint(pointValFromDict(props, "anchorPoint")); - node->setRotation(floatValFromDict(props, "rotation")); - node->setIsRelativeAnchorPoint(boolValFromDict(props, "isRelativeAnchorPoint")); - node->setIsVisible(boolValFromDict(props, "visible")); - - if (extraProps) - { - if (node->getTag() == -1) - { - node->setTag(extraProps->count() + 1); - } - - setExtraProp(props->objectForKey("tag"), "tag", node->getTag(), extraProps); - - setExtraProp((CCDictionary*) props->objectForKey("customClass"), "customClass", node->getTag(), extraProps); - setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentType"), "memberVarAssignmentType", node->getTag(), extraProps); - setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentName"), "memberVarAssignmentName", node->getTag(), extraProps); - setExtraProp((CCDictionary*) props->objectForKey("lockedScaleRatio"), "lockedScaleRatio", node->getTag(), extraProps); - - // Expanded nodes - bool isExpanded; - CCString* isExpandedObj = (CCString*) props->objectForKey("isExpanded"); - - if (isExpandedObj) { - isExpanded = !isExpandedObj->m_sString.empty(); - } else { - isExpanded = true; - } - - setExtraProp(isExpandedObj, "isExpanded", node->getTag(), extraProps); - } - else - { - node->setTag(intValFromDict(props, "tag")); - } -} - - -CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extraProps, - const char* assetsDir, CCNode* owner, CCNode* root) -{ - CCString* className = (CCString*) dict->objectForKey("class"); - CCDictionary* props = (CCDictionary*) dict->objectForKey("properties"); - CCArray* children = (CCArray*) dict->objectForKey("children"); - - CCString* customClass = (CCString*)props->objectForKey("customClass"); - - if (extraProps) customClass = NULL; - - CCNode* node = NULL; - - if (className->m_sString.compare("CCParticleSystem") == 0) - { - CCString* spriteFile = new CCString(assetsDir); - spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; - - CCParticleSystem* sys = new CCParticleSystemQuad(); - sys->autorelease(); - sys->initWithTotalParticles(2048); - sys->setTexture(CCTextureCache::sharedTextureCache()->addImage(spriteFile->m_sString.c_str())); - CC_SAFE_RELEASE_NULL(spriteFile); - - node = (CCNode*)sys; - - setPropsForNode((CCNode*)node, (CCDictionary*) props, extraProps); - setPropsForParticleSystem((CCParticleSystem*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCMenuItemImage") == 0) - { - CCString* spriteFileNormal = new CCString(assetsDir); - spriteFileNormal->m_sString += ((CCString*)props->objectForKey("spriteFileNormal"))->getCString(); - CCString* spriteFileSelected = new CCString(assetsDir); - spriteFileSelected->m_sString += ((CCString*)props->objectForKey("spriteFileSelected"))->getCString(); - CCString* spriteFileDisabled = new CCString(assetsDir); - spriteFileDisabled->m_sString += ((CCString*)props->objectForKey("spriteFileDisabled"))->getCString(); - - CCSprite* spriteNormal = NULL; - CCSprite* spriteSelected = NULL; - CCSprite* spriteDisabled = NULL; - - CCString* spriteSheetFile = (CCString*)props->objectForKey("spriteFramesFile"); - if (spriteSheetFile && !spriteSheetFile->length()) { - spriteSheetFile->m_sString.insert(0, assetsDir); - } - - if (spriteSheetFile && !spriteSheetFile->length()) - { - CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(spriteSheetFile->m_sString.c_str()); - - spriteNormal = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileNormal"))->getCString()); - spriteSelected = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileSelected"))->getCString()); - spriteDisabled = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileDisabled"))->getCString()); - // TBD: how to defense if exception raise here? - } - else - { - spriteNormal = CCSprite::spriteWithFile(spriteFileNormal->m_sString.c_str()); - spriteSelected = CCSprite::spriteWithFile(spriteFileSelected->m_sString.c_str()); - spriteDisabled = CCSprite::spriteWithFile(spriteFileDisabled->m_sString.c_str()); - } - - //deallocate - CC_SAFE_RELEASE_NULL(spriteFileNormal); - CC_SAFE_RELEASE_NULL(spriteFileSelected); - CC_SAFE_RELEASE_NULL(spriteFileDisabled); - - if (!spriteNormal) spriteNormal = CCSprite::spriteWithFile("missing-texture.png"); - if (!spriteSelected) spriteSelected = CCSprite::spriteWithFile("missing-texture.png"); - if (!spriteDisabled) spriteDisabled = CCSprite::spriteWithFile("missing-texture.png"); - - CCNode *target = NULL ; - if ( extraProps == NULL ) - { - int targetType = ((CCString*)(props->objectForKey("target")))->intValue() ; - if ( targetType == kCCBMemberVarAssignmentTypeDocumentRoot ) - target = (CCNode*)root ; - else if ( targetType == kCCBMemberVarAssignmentTypeOwner ) - target = (CCNode*)owner ; - - } - - CCString *selectorName = (CCString*)props->objectForKey("selector") ; - SEL_MenuHandler sel = NULL; - - if ( selectorName->length() ) - { - sel = dynamic_cast(target)->callbackGetSelectors(selectorName->getCString()); - } - else - { - CCLOG("WARNING! CCMenuItemImage target doesn't respond to selector %@",selectorName) ; - target = NULL ; - } - - node = (CCNode*)CCMenuItemImage::itemWithNormalSprite((CCNode*) spriteNormal, (CCNode*) spriteSelected, (CCNode*) spriteDisabled, target, sel); - - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForMenuItem((CCMenuItem*) node, (CCDictionary*) props, extraProps); - setPropsForMenuItemImage((CCMenuItemImage*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCMenu") == 0) - { - node = (CCNode*)CCMenu::menuWithItems(NULL); - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps); - setPropsForMenu((CCMenu*)node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCLabelBMFont") == 0) - { - CCString* fontFile = new CCString(assetsDir); - fontFile->m_sString += ((CCString*)props->objectForKey("fontFile"))->m_sString; - CCString* stringText = ((CCString*)props->objectForKey("string")); - - node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), - fontFile->m_sString.c_str() ); - - CC_SAFE_RELEASE_NULL(fontFile); - - if (!node) node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), "missing-font.fnt"); - - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLabelBMFont((CCLabelBMFont*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCSprite") == 0) - { - CCString* spriteFile = new CCString(assetsDir); - spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; - CCString* spriteSheetFile = (CCString*)props->objectForKey("spriteFramesFile"); - - if (spriteSheetFile && !spriteSheetFile->length()) - { - spriteSheetFile->m_sString.insert(0, assetsDir); - } - - if (spriteSheetFile && !spriteSheetFile->length()) - { - CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(spriteSheetFile->m_sString.c_str()); - node = (CCNode*)CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFile"))->m_sString.c_str()); - // TBD: how to defense if exception raise here? - } - else - { - CCLOG("spriteFile->m_string.cstr is %s\n", spriteFile->m_sString.c_str()) ; - node = (CCNode*)CCSprite::spriteWithFile(spriteFile->m_sString.c_str()); - } - - CC_SAFE_RELEASE_NULL(spriteFile); - - if (!node) node = (CCNode*)CCSprite::spriteWithFile("missing-texture.png"); - - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForSprite((CCSprite*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCLayerGradient") == 0) - { - node = (CCNode*)createCustomClassWithName(customClass) ; - if (node) - { - if (dynamic_cast(node) == NULL) - { - CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; - node = NULL; - } - } - else - { - node = (CCNode*)CCLayerGradient::node(); - } - - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps); - setPropsForLayerColor((CCLayerColor*) node, (CCDictionary*) props, extraProps); - setPropsForLayerGradient((CCLayerGradient*) node, (CCDictionary*) props, extraProps); - - } - else if (className->m_sString.compare("CCLayerColor") == 0) - { - node = (CCNode*)createCustomClassWithName(customClass) ; - if (node) - { - if (dynamic_cast(node) == NULL) - { - CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; - node = NULL; - } - } - else - { - node = (CCNode*)CCLayerColor::node(); - } - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps); - setPropsForLayerColor((CCLayerColor*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCLayer") == 0) - { - node = (CCNode*)createCustomClassWithName(customClass) ; - if (node) - { - if (dynamic_cast(node) == NULL) - { - CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; - node = NULL; - } - } - else - { - node = (CCNode*)CCLayer::node(); - } - - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCNode") == 0) - { - node = (CCNode*)createCustomClassWithName(customClass) ; - - if (node) - { - if (dynamic_cast(node) == NULL) - { - CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; - node = NULL; - } - } - else - { - node = (CCNode*)CCNode::node(); - } - - setPropsForNode(node, (CCDictionary*) props, extraProps); - } - else - { - CCLOG("WARNING! Class of type %@ couldn't be found", className); - return NULL; - } - - if (!root) root = node; - - // Add children - for (unsigned int i = 0; i < children->count(); i++) - { - CCDictionary* childDict = (CCDictionary*) children->objectAtIndex(i); - CCNode* child = ccObjectFromDictionary(childDict, extraProps, assetsDir, owner, root); - int zOrder = intValFromDict((CCDictionary*) childDict->objectForKey("properties"), "zOrder"); - - if (child && node) - { - node->addChild(child, zOrder); - } - else - { - CCLOG("WARNING! Failed to add child to node"); - } - } - - if ( !extraProps ) - { - CCString* assignmentName = (CCString*)props->objectForKey("memberVarAssignmentName"); - CCLOG("assignmentName is %s", assignmentName->getCString()) ; - int assignmentType = ((CCString*)(props->objectForKey("memberVarAssignmentType")))->intValue() ; - - if ( !assignmentName->m_sString.empty() && - assignmentType) - { - CCBCustomClassProtocol* assignTo = NULL ; - if ( assignmentType == kCCBMemberVarAssignmentTypeOwner ) - { - assignTo = dynamic_cast(owner); - } - else if ( assignmentType == kCCBMemberVarAssignmentTypeDocumentRoot ) - { - assignTo = dynamic_cast(root); - } - - if ( assignTo != NULL ) - { - CCLOG("assign [%s]", assignmentName->getCString()); - assignTo->callbackSetChildren(assignmentName->getCString(), node); - } - } - if (customClass->length()) - { - CCBCustomClassProtocol* pCustom = dynamic_cast(node); - if (pCustom) - { - pCustom->callbackAfterCCBLoaded(); - } - } - - } - return node; -} - -// initialize ccbreader - -CCNode* CCBReader::nodeGraphFromDictionary(CCDictionary* dict, - CCDictionary* extraProps, - const char* assetsDir, - CCNode* owner) -{ - if (!dict) - { - CCLOG("WARNING! Trying to load invalid file type"); - return NULL; - } - - CCString* fileType = (CCString*) dict->objectForKey("fileType"); - int fileVersion = ((CCString*) dict->objectForKey("fileVersion"))->intValue(); - - if (!fileType || fileType->m_sString.compare("CocosBuilder") != 0) - { - CCLOG("WARNING! Trying to load invalid file type"); - } - - if (fileVersion > 1) - { - CCLOG("WARNING! Trying to load file made with a newer version of CocosBuilder, please update the CCBReader class"); - return NULL; - } - - CCDictionary* nodeGraph = (CCDictionary*) dict->objectForKey("nodeGraph"); - return ccObjectFromDictionary(nodeGraph, extraProps, assetsDir, owner, NULL); -} - -CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner) -{ - CCLOG("CCBReader path is: %s", file); - std::string ccbFilePath(file); - std::string ccbFileDir; - - // find ccbFileDir before "/" or "\" - // for example, if ccbFilePath = "CocosBuilder/example.ccb", - // then we should make ccbFileDir = "CocosBuilder/" - size_t lastSlash = ccbFilePath.find_last_of("/"); - if (lastSlash != std::string::npos) - { - ccbFileDir = ccbFilePath.substr(0, lastSlash) + "/"; - } - - CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFile(ccbFilePath.c_str()); - CCAssert(dict != NULL, "CCBReader: file not found"); - return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner); -} - -#endif diff --git a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp deleted file mode 100644 index eed24d56e2..0000000000 --- a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp +++ /dev/null @@ -1,771 +0,0 @@ -/**************************************************************************** - Copyright (c) 2012 cocos2d-x.org - Copyright (c) 2012 XiaoLong Zhang, Chukong Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCBReader.h" -#include "CCBCustomClass.h" - -#if CCB_READER_VERSION == 2 - -USING_NS_CC; -USING_NS_CC_EXT; - -// Read value from dictionary - -int CCBReader::intValFromDict(CCDictionary* dict, const std::string key) -{ - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); - return valueString? valueString->intValue() : 0; -} - -float CCBReader::floatValFromDict(CCDictionary* dict, const std::string key) -{ - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); - return valueString? valueString->floatValue() : 0.0f; -} - -bool CCBReader::boolValFromDict(CCDictionary* dict, const std::string key) -{ - CCString* valueString = (CCString*) dict->objectForKey(key.c_str()); - return (valueString && valueString->intValue()) ? true : false; -} - -CCPoint CCBReader::pointValFromDict(CCDictionary* dict, const std::string key) -{ - CCArray* arr = (CCArray*)dict->objectForKey(key.c_str()); - - if (!arr) - { - return ccp(0,0); - } - - float x = ((CCString*)arr->objectAtIndex(0))->floatValue(); - float y = ((CCString*)arr->objectAtIndex(1))->floatValue(); - return ccp(x, y); -} - -CCSize CCBReader::sizeValFromDict(CCDictionary* dict, const std::string key) -{ - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - - if (!arr) - { - return CCSize(0, 0); - } - - float w = ((CCString*)arr->objectAtIndex(0))->floatValue(); - float h = ((CCString*)arr->objectAtIndex(1))->floatValue(); - return CCSize(w, h); -} - -ccColor3B CCBReader::ccColor3ValFromDict(CCDictionary* dict, const std::string key) -{ - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - - int r = ((CCString*)arr->objectAtIndex(0))->intValue(); - int g = ((CCString*)arr->objectAtIndex(1))->intValue(); - int b = ((CCString*)arr->objectAtIndex(2))->intValue(); - - return ccc3(r, g, b); -} - -ccColor4F CCBReader::ccColor4fValFromDict(CCDictionary* dict, const std::string key) -{ - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - - ccColor4F color; - color.r = ((CCString*)arr->objectAtIndex(0))->floatValue(); - color.g = ((CCString*)arr->objectAtIndex(1))->floatValue(); - color.b = ((CCString*)arr->objectAtIndex(2))->floatValue(); - color.a = ((CCString*)arr->objectAtIndex(3))->floatValue(); - - return color; -} - -ccBlendFunc CCBReader::blendFuncValFromDict(CCDictionary* dict, const std::string key) -{ - CCArray* arr = (CCArray*) dict->objectForKey(key.c_str()); - - int src = ((CCString*)arr->objectAtIndex(0))->intValue(); - int dst = ((CCString*)arr->objectAtIndex(1))->intValue(); - - ccBlendFunc blendFunc; - blendFunc.src = src; - blendFunc.dst = dst; - - return blendFunc; -} - -// set extra properties - -void CCBReader::setExtraProp(CCObject* prop, const char* key, int tag, CCDictionary* dict) -{ - std::string tagString; - tagString += tag; - CCDictionary* props = (CCDictionary*) dict->objectForKey(tagString.c_str()); - - if (!props) - { - props = new CCDictionary(); - dict->setObject(props, tagString.c_str()); - } - - props->setObject(prop, key); -} - -void CCBReader::setPropsForMenuItem(CCMenuItem* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setIsEnabled(boolValFromDict(props, "isEnabled")); - if (extraProps) - { - setExtraProp((CCDictionary*) props->objectForKey("selector"), "selector", node->getTag(), extraProps); - setExtraProp((CCDictionary*) props->objectForKey("target"), "target", node->getTag(), extraProps); - CCString* spriteFramesFile = (CCString*) props->objectForKey("spriteFramesFile"); - - if (spriteFramesFile) - { - setExtraProp(spriteFramesFile, "spriteSheetFile", node->getTag(), extraProps); - } - } -} - -void CCBReader::setPropsForMenuItemImage(CCMenuItemImage* node, CCDictionary* props, CCDictionary* extraProps) -{ - if (extraProps) - { - setExtraProp(props->objectForKey("spriteFileNormal"), "spriteFileNormal", node->getTag(), extraProps); - setExtraProp(props->objectForKey("spriteFileSelected"), "spriteFileSelected", node->getTag(), extraProps); - setExtraProp(props->objectForKey("spriteFileDisabled"), "spriteFileDisabled", node->getTag(), extraProps); - } -} - -void CCBReader::setPropsForLayerColor(CCLayerColor* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setColor(ccColor3ValFromDict(props, "color")); - node->setOpacity(intValFromDict(props, "opacity")); - node->setBlendFunc(blendFuncValFromDict(props, "blendFunc")); -} - -void CCBReader::setPropsForLayer(CCLayer* node, CCDictionary* props, CCDictionary* extraProps) -{ - if (extraProps) - { - setExtraProp(props->objectForKey("touchEnabled"), "touchEnabled", node->getTag(), extraProps); - setExtraProp(props->objectForKey("accelerometerEnabled"), "accelerometerEnabled", node->getTag(), extraProps); - setExtraProp(props->objectForKey("mouseEnabled"), "mouseEnabled", node->getTag() ,extraProps); - setExtraProp(props->objectForKey("keyboardEnabled"), "keyboardEnabled", node->getTag(), extraProps); - } - else - { - node->setIsTouchEnabled(boolValFromDict(props, "touchEnabled")); - node->setIsAccelerometerEnabled(boolValFromDict(props, "accelerometerEnabled")); - } -} - -void CCBReader::setPropsForMenu(CCMenu* node, CCDictionary* props, CCDictionary* extraProps) -{ - if (extraProps) - { - - } -} - -void CCBReader::setPropsForLabelBMFont(CCLabelBMFont* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setOpacity(intValFromDict(props, "opacity")); - node->setColor(ccColor3ValFromDict(props, "color")); - - if (extraProps) - { - setExtraProp(props->objectForKey("fontFile"), "fontFile", node->getTag(), extraProps); - } -} - -void CCBReader::setPropsForParticleSystem(CCParticleSystem* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setEmitterMode(intValFromDict(props, "emitterMode")); - node->setEmissionRate(floatValFromDict(props, "emissionRate")); - node->setDuration(floatValFromDict(props, "duration")); - node->setPosVar(pointValFromDict(props, "posVar")); - node->setTotalParticles(intValFromDict(props, "totalParticles")); - node->setLife(floatValFromDict(props, "life")); - node->setLifeVar(floatValFromDict(props, "lifeVar")); - node->setStartSize(intValFromDict(props, "startSize")); - node->setStartSizeVar(intValFromDict(props, "startSizeVar")); - node->setEndSize(intValFromDict(props, "endSize")); - node->setEndSizeVar(intValFromDict(props, "endSizeVar")); - - if (dynamic_cast(node)) - { - node->setStartSpin(intValFromDict(props, "startSpin")); - node->setStartSpinVar(intValFromDict(props, "startSpinVar")); - node->setEndSpin(intValFromDict(props, "endSpin")); - node->setEndSpinVar(intValFromDict(props, "endSpinVar")); - } - - node->setStartColor(ccColor4fValFromDict(props, "startColor")); - node->setStartColorVar(ccColor4fValFromDict(props, "startColorVar")); - node->setEndColor(ccColor4fValFromDict(props, "endColor")); - node->setEndColorVar(ccColor4fValFromDict(props, "endColorVar")); - node->setBlendFunc(blendFuncValFromDict(props, "blendFunc")); - - if (node->getEmitterMode() == kCCParticleModeGravity) - { - node->setGravity(pointValFromDict(props, "gravity")); - node->setAngle(intValFromDict(props, "angle")); - node->setAngleVar(intValFromDict(props, "angleVar")); - node->setSpeed(intValFromDict(props, "speed")); - node->setSpeedVar(intValFromDict(props, "speedVar")); - node->setTangentialAccel(intValFromDict(props, "tangentialAccel")); - node->setTangentialAccelVar(intValFromDict(props, "tangentialAccelVar")); - node->setRadialAccel(intValFromDict(props, "radialAccel")); - node->setRadialAccelVar(intValFromDict(props, "radialAccelVar")); - } - else - { - node->setStartRadius(intValFromDict(props, "startRadius")); - node->setStartRadiusVar(intValFromDict(props, "startRadiusVar")); - node->setEndRadius(intValFromDict(props, "endRadius")); - node->setEndRadiusVar(intValFromDict(props, "endRadiusVar")); - node->setRotatePerSecond(intValFromDict(props, "rotatePerSecond")); - node->setRotatePerSecondVar(intValFromDict(props, "rotatePerSecondVar")); - } - - if (extraProps) - { - setExtraProp(props->objectForKey("spriteFile"), "spriteFile", node->getTag(), extraProps); - } - node->setPositionType(kCCPositionTypeGrouped); -} - -void CCBReader::setPropsForLayerGradient(CCLayerGradient* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setStartColor(ccColor3ValFromDict(props, "color")); - node->setStartOpacity(intValFromDict(props, "opacity")); - node->setEndColor(ccColor3ValFromDict(props, "endColor")); - node->setEndOpacity(intValFromDict(props, "endOpacity")); - node->setVector(pointValFromDict(props, "vector")); -} - -CCNode* CCBReader::createCustomClassWithName(CCString* className) -{ - CCNode* pRetVal = NULL; - - if (className && className->length()) - { - CCBCustomClassProtocol* pNewClass = CCBCustomClassFactory::sharedFactory()->createCustomClassWithName(className->getCString()); - pRetVal = dynamic_cast(pNewClass); - pRetVal->autorelease(); - } - - return pRetVal; -} - -void CCBReader::setPropsForSprite(CCSprite* node, CCDictionary* props, CCDictionary* extraProps) -{ - node->setOpacity(intValFromDict(props, "opacity")); - node->setColor(ccColor3ValFromDict(props, "color")); - node->setFlipX(boolValFromDict(props, "flipX")); - node->setFlipY(boolValFromDict(props, "flipY")); - node->setBlendFunc(blendFuncValFromDict(props, "blendFunc")); - - if (extraProps) - { - setExtraProp(props->objectForKey("spriteFile"), "spriteFile", node->getTag(), extraProps); - CCString* spriteFramesFile = (CCString*) props->objectForKey("spriteFramesFile"); - - if (spriteFramesFile) - { - setExtraProp(spriteFramesFile, "spriteSheetFile", node->getTag(), extraProps); - } - } -} - -void CCBReader::setPropsForNode(CCNode* node, CCDictionary* props, CCDictionary* extraProps) -{ - CCPoint position = pointValFromDict(props, "position"); - int refPointType = intValFromDict(props, "refPointType"); - - if (refPointType == kInvalidRelativePosition) - { - // normal process. - node->setPosition(position); - } - else - { - // support walzer's relative position - CCPoint positionRelative = pointValFromDict(props, "positionRelative"); - CCPoint refPoint(0,0); - CCSize screenSize = CCDirector::sharedDirector()->getWinSize(); - - switch (refPointType) - { - case kInvalidRelativePosition: - - case kBottomLeft: - refPoint.x = 0; - refPoint.y = 0; - break; - case kBottom: - refPoint.x = screenSize.width / 2; - refPoint.y = 0; - break; - case kBottomRight: - refPoint.x = screenSize.width; - refPoint.y = 0; - break; - case kCenterLeft: - refPoint.x = 0; - refPoint.y = screenSize.height / 2; - break; - case kCenter: - refPoint.x = screenSize.width / 2; - refPoint.y = screenSize.height / 2; - break; - case kCenterRight: - refPoint.x = screenSize.width; - refPoint.y = screenSize.height / 2; - break; - case kTopLeft: - refPoint.x = 0; - refPoint.y = screenSize.height; - break; - case kTop: - refPoint.x = screenSize.width / 2; - refPoint.y = screenSize.height; - break; - case kTopRight: - refPoint.x = screenSize.width; - refPoint.y = screenSize.height; - break; - default: - CCLOG("CCReader::setPropsForNode, unexcpeted refPointType"); - } - - position.x = positionRelative.x + refPoint.x; - position.y = positionRelative.y + refPoint.y; - node->setPosition(position); - } - - if (dynamic_cast(node) == NULL && - dynamic_cast(node) == NULL && - dynamic_cast(node) == NULL) - { - CCSize size = sizeValFromDict(props, "contentSize"); - //node->setContentSize(size); - } - - node->setScaleX(floatValFromDict(props, "scaleX")); - node->setScaleY(floatValFromDict(props, "scaleY")); - node->setAnchorPoint(pointValFromDict(props, "anchorPoint")); - node->setRotation(floatValFromDict(props, "rotation")); - node->setIgnoreAnchorPointForPosition(!boolValFromDict(props, "isRelativeAnchorPoint")); - node->setIsVisible(boolValFromDict(props, "visible")); - - if (extraProps) - { - if (node->getTag() == -1) - { - node->setTag(extraProps->count() + 1); - } - - setExtraProp(props->objectForKey("tag"), "tag", node->getTag(), extraProps); - - setExtraProp((CCDictionary*) props->objectForKey("customClass"), "customClass", node->getTag(), extraProps); - setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentType"), "memberVarAssignmentType", node->getTag(), extraProps); - setExtraProp((CCDictionary*) props->objectForKey("memberVarAssignmentName"), "memberVarAssignmentName", node->getTag(), extraProps); - setExtraProp((CCDictionary*) props->objectForKey("lockedScaleRatio"), "lockedScaleRatio", node->getTag(), extraProps); - - // Expanded nodes - bool isExpanded; - CCString* isExpandedObj = (CCString*) props->objectForKey("isExpanded"); - - if (isExpandedObj) { - isExpanded = !isExpandedObj->m_sString.empty(); - } else { - isExpanded = true; - } - - setExtraProp(isExpandedObj, "isExpanded", node->getTag(), extraProps); - } - else - { - node->setTag(intValFromDict(props, "tag")); - } -} - - -CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extraProps, - const char* assetsDir, CCNode* owner, CCNode* root) -{ - CCString* className = (CCString*) dict->objectForKey("class"); - CCDictionary* props = (CCDictionary*) dict->objectForKey("properties"); - CCArray* children = (CCArray*) dict->objectForKey("children"); - - CCString* customClass = (CCString*)props->objectForKey("customClass"); - - if (extraProps) customClass = NULL; - - CCNode* node = NULL; - - if (className->m_sString.compare("CCParticleSystem") == 0) - { - CCString* spriteFile = new CCString(assetsDir); - spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; - - CCParticleSystem* sys = new CCParticleSystemQuad(); - sys->autorelease(); - sys->initWithTotalParticles(2048); - sys->setTexture(CCTextureCache::sharedTextureCache()->addImage(spriteFile->m_sString.c_str())); - CC_SAFE_RELEASE_NULL(spriteFile); - - node = (CCNode*)sys; - - setPropsForNode((CCNode*)node, (CCDictionary*) props, extraProps); - setPropsForParticleSystem((CCParticleSystem*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCMenuItemImage") == 0) - { - CCString* spriteFileNormal = new CCString(assetsDir); - spriteFileNormal->m_sString += ((CCString*)props->objectForKey("spriteFileNormal"))->getCString(); - CCString* spriteFileSelected = new CCString(assetsDir); - spriteFileSelected->m_sString += ((CCString*)props->objectForKey("spriteFileSelected"))->getCString(); - CCString* spriteFileDisabled = new CCString(assetsDir); - spriteFileDisabled->m_sString += ((CCString*)props->objectForKey("spriteFileDisabled"))->getCString(); - - CCSprite* spriteNormal = NULL; - CCSprite* spriteSelected = NULL; - CCSprite* spriteDisabled = NULL; - - CCString* spriteSheetFile = (CCString*)props->objectForKey("spriteFramesFile"); - if (spriteSheetFile && !spriteSheetFile->length()) { - spriteSheetFile->m_sString.insert(0, assetsDir); - } - - if (spriteSheetFile && !spriteSheetFile->length()) - { - CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(spriteSheetFile->m_sString.c_str()); - - spriteNormal = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileNormal"))->getCString()); - spriteSelected = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileSelected"))->getCString()); - spriteDisabled = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileDisabled"))->getCString()); - // TBD: how to defense if exception raise here? - } - else - { - spriteNormal = CCSprite::spriteWithFile(spriteFileNormal->m_sString.c_str()); - spriteSelected = CCSprite::spriteWithFile(spriteFileSelected->m_sString.c_str()); - spriteDisabled = CCSprite::spriteWithFile(spriteFileDisabled->m_sString.c_str()); - } - - //deallocate - CC_SAFE_RELEASE_NULL(spriteFileNormal); - CC_SAFE_RELEASE_NULL(spriteFileSelected); - CC_SAFE_RELEASE_NULL(spriteFileDisabled); - - if (!spriteNormal) spriteNormal = CCSprite::spriteWithFile("missing-texture.png"); - if (!spriteSelected) spriteSelected = CCSprite::spriteWithFile("missing-texture.png"); - if (!spriteDisabled) spriteDisabled = CCSprite::spriteWithFile("missing-texture.png"); - - CCNode *target = NULL ; - if ( extraProps == NULL ) - { - int targetType = ((CCString*)(props->objectForKey("target")))->intValue() ; - if ( targetType == kCCBMemberVarAssignmentTypeDocumentRoot ) - target = (CCNode*)root ; - else if ( targetType == kCCBMemberVarAssignmentTypeOwner ) - target = (CCNode*)owner ; - - } - - CCString *selectorName = (CCString*)props->objectForKey("selector") ; - SEL_MenuHandler sel = NULL; - - if ( selectorName->length() ) - { - sel = dynamic_cast(target)->callbackGetSelectors(selectorName->getCString()); - } - else - { - CCLOG("WARNING! CCMenuItemImage target doesn't respond to selector %@",selectorName) ; - target = NULL ; - } - - node = (CCNode*)CCMenuItemImage::itemWithNormalSprite((CCNode*) spriteNormal, (CCNode*) spriteSelected, (CCNode*) spriteDisabled, target, sel); - - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForMenuItem((CCMenuItem*) node, (CCDictionary*) props, extraProps); - setPropsForMenuItemImage((CCMenuItemImage*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCMenu") == 0) - { - node = (CCNode*)CCMenu::menuWithItems(NULL); - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps); - setPropsForMenu((CCMenu*)node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCLabelBMFont") == 0) - { - CCString* fontFile = new CCString(assetsDir); - fontFile->m_sString += ((CCString*)props->objectForKey("fontFile"))->m_sString; - CCString* stringText = ((CCString*)props->objectForKey("string")); - - node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), - fontFile->m_sString.c_str() ); - - CC_SAFE_RELEASE_NULL(fontFile); - - if (!node) node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), "missing-font.fnt"); - - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLabelBMFont((CCLabelBMFont*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCSprite") == 0) - { - CCString* spriteFile = new CCString(assetsDir); - spriteFile->m_sString += ((CCString*)props->objectForKey("spriteFile"))->m_sString; - CCString* spriteSheetFile = (CCString*)props->objectForKey("spriteFramesFile"); - - if (spriteSheetFile && !spriteSheetFile->length()) - { - spriteSheetFile->m_sString.insert(0, assetsDir); - } - - if (spriteSheetFile && !spriteSheetFile->length()) - { - CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(spriteSheetFile->m_sString.c_str()); - node = (CCNode*)CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFile"))->m_sString.c_str()); - // TBD: how to defense if exception raise here? - } - else - { - CCLOG("spriteFile->m_string.cstr is %s\n", spriteFile->m_sString.c_str()) ; - node = (CCNode*)CCSprite::spriteWithFile(spriteFile->m_sString.c_str()); - } - - CC_SAFE_RELEASE_NULL(spriteFile); - - if (!node) node = (CCNode*)CCSprite::spriteWithFile("missing-texture.png"); - - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForSprite((CCSprite*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCLayerGradient") == 0) - { - node = (CCNode*)createCustomClassWithName(customClass) ; - if (node) - { - if (dynamic_cast(node) == NULL) - { - CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; - node = NULL; - } - } - else - { - node = (CCNode*)CCLayerGradient::node(); - } - - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps); - setPropsForLayerColor((CCLayerColor*) node, (CCDictionary*) props, extraProps); - setPropsForLayerGradient((CCLayerGradient*) node, (CCDictionary*) props, extraProps); - - } - else if (className->m_sString.compare("CCLayerColor") == 0) - { - node = (CCNode*)createCustomClassWithName(customClass) ; - if (node) - { - if (dynamic_cast(node) == NULL) - { - CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; - node = NULL; - } - } - else - { - node = (CCNode*)CCLayerColor::node(); - } - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps); - setPropsForLayerColor((CCLayerColor*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCLayer") == 0) - { - node = (CCNode*)createCustomClassWithName(customClass) ; - if (node) - { - if (dynamic_cast(node) == NULL) - { - CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; - node = NULL; - } - } - else - { - node = (CCNode*)CCLayer::node(); - } - - setPropsForNode(node, (CCDictionary*) props, extraProps); - setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps); - } - else if (className->m_sString.compare("CCNode") == 0) - { - node = (CCNode*)createCustomClassWithName(customClass) ; - - if (node) - { - if (dynamic_cast(node) == NULL) - { - CCLOG("WARNING! %s is not subclass of CCNode", customClass); - delete node; - node = NULL; - } - } - else - { - node = (CCNode*)CCNode::node(); - } - - setPropsForNode(node, (CCDictionary*) props, extraProps); - } - else - { - CCLOG("WARNING! Class of type %@ couldn't be found", className); - return NULL; - } - - if (!root) root = node; - - // Add children - for (unsigned int i = 0; i < children->count(); i++) - { - CCDictionary* childDict = (CCDictionary*) children->objectAtIndex(i); - CCNode* child = ccObjectFromDictionary(childDict, extraProps, assetsDir, owner, root); - int zOrder = intValFromDict((CCDictionary*) childDict->objectForKey("properties"), "zOrder"); - - if (child && node) - { - node->addChild(child, zOrder); - } - else - { - CCLOG("WARNING! Failed to add child to node"); - } - } - - if ( !extraProps ) - { - CCString* assignmentName = (CCString*)props->objectForKey("memberVarAssignmentName"); - CCLOG("assignmentName is %s", assignmentName->getCString()) ; - int assignmentType = ((CCString*)(props->objectForKey("memberVarAssignmentType")))->intValue() ; - - if ( !assignmentName->m_sString.empty() && - assignmentType) - { - CCBCustomClassProtocol* assignTo = NULL ; - if ( assignmentType == kCCBMemberVarAssignmentTypeOwner ) - { - assignTo = dynamic_cast(owner); - } - else if ( assignmentType == kCCBMemberVarAssignmentTypeDocumentRoot ) - { - assignTo = dynamic_cast(root); - } - - if ( assignTo != NULL ) - { - CCLOG("assign [%s]", assignmentName->getCString()); - assignTo->callbackSetChildren(assignmentName->getCString(), node); - } - } - if (customClass->length()) - { - CCBCustomClassProtocol* pCustom = dynamic_cast(node); - if (pCustom) - { - pCustom->callbackAfterCCBLoaded(); - } - } - - } - return node; -} - -// initialize ccbreader - -CCNode* CCBReader::nodeGraphFromDictionary(CCDictionary* dict, - CCDictionary* extraProps, - const char* assetsDir, - CCNode* owner) -{ - if (!dict) - { - CCLOG("WARNING! Trying to load invalid file type"); - return NULL; - } - - CCString* fileType = (CCString*) dict->objectForKey("fileType"); - int fileVersion = ((CCString*) dict->objectForKey("fileVersion"))->intValue(); - - if (!fileType || fileType->m_sString.compare("CocosBuilder") != 0) - { - CCLOG("WARNING! Trying to load invalid file type"); - } - - if (fileVersion > 2) - { - CCLOG("WARNING! Trying to load file made with a newer version of CocosBuilder, please update the CCBReader class"); - return NULL; - } - - CCDictionary* nodeGraph = (CCDictionary*) dict->objectForKey("nodeGraph"); - return ccObjectFromDictionary(nodeGraph, extraProps, assetsDir, owner, NULL); -} - -CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner) -{ - CCLOG("CCBReader path is: %s", file); - std::string ccbFilePath(file); - std::string ccbFileDir; - - // find ccbFileDir before "/" or "\" - // for example, if ccbFilePath = "CocosBuilder/example.ccb", - // then we should make ccbFileDir = "CocosBuilder/" - size_t lastSlash = ccbFilePath.find_last_of("/"); - if (lastSlash != std::string::npos) - { - ccbFileDir = ccbFilePath.substr(0, lastSlash) + "/"; - } - - CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFile(ccbFilePath.c_str()); - CCAssert(dict != NULL, "CCBReader: file not found"); - return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner); -} - -#endif diff --git a/cocos2dx/extensions/CCBIReader/CCBSelectorResolver.h b/cocos2dx/extensions/CCBReader/CCBSelectorResolver.h similarity index 100% rename from cocos2dx/extensions/CCBIReader/CCBSelectorResolver.h rename to cocos2dx/extensions/CCBReader/CCBSelectorResolver.h diff --git a/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.cpp b/cocos2dx/extensions/CCBReader/CCControlButtonLoader.cpp similarity index 99% rename from cocos2dx/extensions/CCBIReader/CCControlButtonLoader.cpp rename to cocos2dx/extensions/CCBReader/CCControlButtonLoader.cpp index b3ca5b6a6c..2e753aa14b 100644 --- a/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCControlButtonLoader.cpp @@ -1,7 +1,7 @@ #include "CCControlButtonLoader.h" -using namespace cocos2d; -using namespace cocos2d::extension; +USING_NS_CC; +USING_NS_CC_EXT; #define PROPERTY_ZOOMONTOUCHDOWN "zoomOnTouchDown" #define PROPERTY_TITLE_NORMAL "title|1" diff --git a/cocos2dx/extensions/CCBIReader/CCControlButtonLoader.h b/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h similarity index 100% rename from cocos2dx/extensions/CCBIReader/CCControlButtonLoader.h rename to cocos2dx/extensions/CCBReader/CCControlButtonLoader.h diff --git a/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp b/cocos2dx/extensions/CCBReader/CCControlLoader.cpp similarity index 95% rename from cocos2dx/extensions/CCBIReader/CCControlLoader.cpp rename to cocos2dx/extensions/CCBReader/CCControlLoader.cpp index 293c1c564c..7be8f8d5ba 100644 --- a/cocos2dx/extensions/CCBIReader/CCControlLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCControlLoader.cpp @@ -1,7 +1,7 @@ #include "CCControlLoader.h" -using namespace cocos2d; -using namespace cocos2d::extension; +USING_NS_CC; +USING_NS_CC_EXT; #define PROPERTY_ENABLED "enabled" #define PROPERTY_SELECTED "selected" diff --git a/cocos2dx/extensions/CCBIReader/CCControlLoader.h b/cocos2dx/extensions/CCBReader/CCControlLoader.h similarity index 100% rename from cocos2dx/extensions/CCBIReader/CCControlLoader.h rename to cocos2dx/extensions/CCBReader/CCControlLoader.h diff --git a/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.cpp b/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.cpp similarity index 97% rename from cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.cpp rename to cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.cpp index d95506544c..602dbea8af 100644 --- a/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.cpp @@ -1,7 +1,7 @@ #include "CCLabelBMFontLoader.h" -using namespace cocos2d; -using namespace cocos2d::extension; +USING_NS_CC; +USING_NS_CC_EXT; #define PROPERTY_COLOR "color" #define PROPERTY_OPACITY "opacity" diff --git a/cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h b/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h similarity index 100% rename from cocos2dx/extensions/CCBIReader/CCLabelBMFontLoader.h rename to cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h diff --git a/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp b/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.cpp similarity index 98% rename from cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp rename to cocos2dx/extensions/CCBReader/CCLabelTTFLoader.cpp index d38949b80f..1c05c31e5a 100644 --- a/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.cpp @@ -1,7 +1,7 @@ #include "CCLabelTTFLoader.h" -using namespace cocos2d; -using namespace cocos2d::extension; +USING_NS_CC; +USING_NS_CC_EXT; #define PROPERTY_COLOR "color" #define PROPERTY_OPACITY "opacity" diff --git a/cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.h b/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h similarity index 100% rename from cocos2dx/extensions/CCBIReader/CCLabelTTFLoader.h rename to cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h diff --git a/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.cpp b/cocos2dx/extensions/CCBReader/CCLayerColorLoader.cpp similarity index 95% rename from cocos2dx/extensions/CCBIReader/CCLayerColorLoader.cpp rename to cocos2dx/extensions/CCBReader/CCLayerColorLoader.cpp index 9d188b7298..d04fdb0d6d 100644 --- a/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCLayerColorLoader.cpp @@ -1,7 +1,7 @@ #include "CCLayerColorLoader.h" -using namespace cocos2d; -using namespace cocos2d::extension; +USING_NS_CC; +USING_NS_CC_EXT; #define PROPERTY_COLOR "color" #define PROPERTY_OPACITY "opacity" diff --git a/cocos2dx/extensions/CCBIReader/CCLayerColorLoader.h b/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h similarity index 100% rename from cocos2dx/extensions/CCBIReader/CCLayerColorLoader.h rename to cocos2dx/extensions/CCBReader/CCLayerColorLoader.h diff --git a/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.cpp b/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.cpp similarity index 97% rename from cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.cpp rename to cocos2dx/extensions/CCBReader/CCLayerGradientLoader.cpp index 64250044cf..596c491ae3 100644 --- a/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.cpp @@ -1,7 +1,7 @@ #include "CCLayerGradientLoader.h" -using namespace cocos2d; -using namespace cocos2d::extension; +USING_NS_CC; +USING_NS_CC_EXT; #define PROPERTY_STARTCOLOR "startColor" #define PROPERTY_ENDCOLOR "endColor" diff --git a/cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.h b/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h similarity index 100% rename from cocos2dx/extensions/CCBIReader/CCLayerGradientLoader.h rename to cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h diff --git a/cocos2dx/extensions/CCBIReader/CCLayerLoader.cpp b/cocos2dx/extensions/CCBReader/CCLayerLoader.cpp similarity index 95% rename from cocos2dx/extensions/CCBIReader/CCLayerLoader.cpp rename to cocos2dx/extensions/CCBReader/CCLayerLoader.cpp index 5ec080050f..f6942ef5af 100644 --- a/cocos2dx/extensions/CCBIReader/CCLayerLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCLayerLoader.cpp @@ -1,7 +1,7 @@ #include "CCLayerLoader.h" -using namespace cocos2d; -using namespace cocos2d::extension; +USING_NS_CC; +USING_NS_CC_EXT; #define PROPERTY_TOUCH_ENABLED "isTouchEnabled" #define PROPERTY_ACCELEROMETER_ENABLED "isAccelerometerEnabled" diff --git a/cocos2dx/extensions/CCBIReader/CCLayerLoader.h b/cocos2dx/extensions/CCBReader/CCLayerLoader.h similarity index 100% rename from cocos2dx/extensions/CCBIReader/CCLayerLoader.h rename to cocos2dx/extensions/CCBReader/CCLayerLoader.h diff --git a/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader .cpp b/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader .cpp similarity index 68% rename from cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader .cpp rename to cocos2dx/extensions/CCBReader/CCMenuItemImageLoader .cpp index cd68de6a65..8f8babb245 100644 --- a/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader .cpp +++ b/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader .cpp @@ -1,7 +1,7 @@ #include "CCMenuItemImageLoader.h" -using namespace cocos2d; -using namespace cocos2d::extension; +USING_NS_CC; +USING_NS_CC_EXT; #define PROPERTY_NORMALDISPLAYFRAME "normalSpriteFrame" #define PROPERTY_SELECTEDDISPLAYFRAME "selectedSpriteFrame" @@ -13,11 +13,17 @@ CCMenuItemImage * CCMenuItemImageLoader::createCCNode(CCNode * pParent, CCBReade void CCMenuItemImageLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { if(strcmp(pPropertyName, PROPERTY_NORMALDISPLAYFRAME) == 0) { - ((CCMenuItemImage *)pNode)->setNormalSpriteFrame(pCCSpriteFrame); + if(pCCSpriteFrame != NULL) { + ((CCMenuItemImage *)pNode)->setNormalSpriteFrame(pCCSpriteFrame); + } } else if(strcmp(pPropertyName, PROPERTY_SELECTEDDISPLAYFRAME) == 0) { - ((CCMenuItemImage *)pNode)->setSelectedSpriteFrame(pCCSpriteFrame); + if(pCCSpriteFrame != NULL) { + ((CCMenuItemImage *)pNode)->setSelectedSpriteFrame(pCCSpriteFrame); + } } else if(strcmp(pPropertyName, PROPERTY_DISABLEDDISPLAYFRAME) == 0) { - ((CCMenuItemImage *)pNode)->setDisabledSpriteFrame(pCCSpriteFrame); + if(pCCSpriteFrame != NULL) { + ((CCMenuItemImage *)pNode)->setDisabledSpriteFrame(pCCSpriteFrame); + } } else { CCMenuItemLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pCCSpriteFrame, pCCBReader); } diff --git a/cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader.h b/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h similarity index 100% rename from cocos2dx/extensions/CCBIReader/CCMenuItemImageLoader.h rename to cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h diff --git a/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp b/cocos2dx/extensions/CCBReader/CCMenuItemLoader.cpp similarity index 93% rename from cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp rename to cocos2dx/extensions/CCBReader/CCMenuItemLoader.cpp index 865c97d0f5..478f730b2e 100644 --- a/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCMenuItemLoader.cpp @@ -1,7 +1,7 @@ #include "CCMenuItemLoader.h" -using namespace cocos2d; -using namespace cocos2d::extension; +USING_NS_CC; +USING_NS_CC_EXT; #define PROPERTY_BLOCK "block" #define PROPERTY_ISENABLED "isEnabled" diff --git a/cocos2dx/extensions/CCBIReader/CCMenuItemLoader.h b/cocos2dx/extensions/CCBReader/CCMenuItemLoader.h similarity index 100% rename from cocos2dx/extensions/CCBIReader/CCMenuItemLoader.h rename to cocos2dx/extensions/CCBReader/CCMenuItemLoader.h diff --git a/cocos2dx/extensions/CCBIReader/CCMenuLoader.cpp b/cocos2dx/extensions/CCBReader/CCMenuLoader.cpp similarity index 68% rename from cocos2dx/extensions/CCBIReader/CCMenuLoader.cpp rename to cocos2dx/extensions/CCBReader/CCMenuLoader.cpp index 5d77921280..ef768f1d5b 100644 --- a/cocos2dx/extensions/CCBIReader/CCMenuLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCMenuLoader.cpp @@ -1,7 +1,7 @@ #include "CCMenuLoader.h" -using namespace cocos2d; -using namespace cocos2d::extension; +USING_NS_CC; +USING_NS_CC_EXT; CCMenu * CCMenuLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { diff --git a/cocos2dx/extensions/CCBIReader/CCMenuLoader.h b/cocos2dx/extensions/CCBReader/CCMenuLoader.h similarity index 100% rename from cocos2dx/extensions/CCBIReader/CCMenuLoader.h rename to cocos2dx/extensions/CCBReader/CCMenuLoader.h diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp similarity index 94% rename from cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp rename to cocos2dx/extensions/CCBReader/CCNodeLoader.cpp index 420ad7458f..5833315f95 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp @@ -1,5 +1,6 @@ #include "CCNodeLoader.h" #include "CCBSelectorResolver.h" +#include "CCBMemberVariableAssigner.h" #define PROPERTY_POSITION "position" #define PROPERTY_CONTENTSIZE "contentSize" @@ -13,8 +14,8 @@ #define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) printf("Unexpected property: '%s'!\n", PROPERTY); assert(false) #define ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) printf("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false) -using namespace cocos2d; -using namespace cocos2d::extension; +USING_NS_CC; +USING_NS_CC_EXT; CCNode * CCNodeLoader::loadCCNode(CCNode * pParent, CCBReader * pCCBReader) { CCNode * ccNode = this->createCCNode(pParent, pCCBReader); @@ -561,16 +562,29 @@ BlockData * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, C if(target != NULL) { if(strlen(selectorName) > 0) { - CCBSelectorResolver * ccbSelectorResolver = pCCBReader->getCCBSelectorResolver(); - if(ccbSelectorResolver != NULL) { + SEL_MenuHandler selMenuHandler = NULL; + + CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast(target); + + if(targetAsCCBSelectorResolver != NULL) { + selMenuHandler = targetAsCCBSelectorResolver->onResolveCCBCCMenuSelector(target, selectorName); + } + if(selMenuHandler == NULL) { + CCBSelectorResolver * ccbSelectorResolver = pCCBReader->getCCBSelectorResolver(); + if(ccbSelectorResolver != NULL) { + selMenuHandler = ccbSelectorResolver->onResolveCCBCCMenuSelector(target, selectorName); + } + } + + if(selMenuHandler == NULL) { + CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName); + } else { BlockData * blockData = new BlockData(); - blockData->mSELMenuHandler = ccbSelectorResolver->onResolveCCBCCMenuSelector(target, selectorName); + blockData->mSELMenuHandler = selMenuHandler; blockData->mTarget = target; return blockData; - } else { - CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName); } } else { CCLOG("Unexpected empty selector."); @@ -598,17 +612,30 @@ BlockCCControlData * CCNodeLoader::parsePropTypeBlockCCControl(CCNode * pNode, C if(target != NULL) { if(strlen(selectorName) > 0) { - CCBSelectorResolver * ccbSelectorResolver = pCCBReader->getCCBSelectorResolver(); - if(ccbSelectorResolver != NULL) { + SEL_CCControlHandler selCCControlHandler = NULL; + + CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast(target); + + if(targetAsCCBSelectorResolver != NULL) { + selCCControlHandler = targetAsCCBSelectorResolver->onResolveCCBCCControlSelector(target, selectorName); + } + if(selCCControlHandler == NULL) { + CCBSelectorResolver * ccbSelectorResolver = pCCBReader->getCCBSelectorResolver(); + if(ccbSelectorResolver != NULL) { + selCCControlHandler = ccbSelectorResolver->onResolveCCBCCControlSelector(target, selectorName); + } + } + + if(selCCControlHandler == NULL) { + CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName); + } else { BlockCCControlData * blockCCControlData = new BlockCCControlData(); - blockCCControlData->mSELCCControlHandler = ccbSelectorResolver->onResolveCCBCCControlSelector(target, selectorName); + blockCCControlData->mSELCCControlHandler = selCCControlHandler; blockCCControlData->mTarget = target; blockCCControlData->mControlEvents = controlEvents; return blockCCControlData; - } else { - CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName); } } else { CCLOG("Unexpected empty selector."); diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoader.h b/cocos2dx/extensions/CCBReader/CCNodeLoader.h similarity index 100% rename from cocos2dx/extensions/CCBIReader/CCNodeLoader.h rename to cocos2dx/extensions/CCBReader/CCNodeLoader.h diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.cpp b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp similarity index 96% rename from cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.cpp rename to cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp index ae2ed8364a..48b5816f30 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.cpp +++ b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp @@ -14,8 +14,8 @@ #include "CCControlButtonLoader.h" #include "CCParticleSystemQuadLoader.h" -using namespace cocos2d; -using namespace cocos2d::extension; +USING_NS_CC; +USING_NS_CC_EXT; CCNodeLoaderLibrary::CCNodeLoaderLibrary() { @@ -58,8 +58,8 @@ CCNodeLoader * CCNodeLoaderLibrary::getCCNodeLoader(const char * pClassName) { return ccNodeLoadersIterator->second; } -void CCNodeLoaderLibrary::purge(bool pDelete) { - if(pDelete) { +void CCNodeLoaderLibrary::purge(bool pReleaseCCNodeLoaders) { + if(pReleaseCCNodeLoaders) { for(std::map::iterator it = this->mCCNodeLoaders.begin(); it != this->mCCNodeLoaders.end(); it++) { it->second->release(); } diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.h b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h similarity index 100% rename from cocos2dx/extensions/CCBIReader/CCNodeLoaderLibrary.h rename to cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h diff --git a/cocos2dx/extensions/CCBIReader/CCNodeLoaderListener.h b/cocos2dx/extensions/CCBReader/CCNodeLoaderListener.h similarity index 99% rename from cocos2dx/extensions/CCBIReader/CCNodeLoaderListener.h rename to cocos2dx/extensions/CCBReader/CCNodeLoaderListener.h index 989f8da166..16e1c216f6 100644 --- a/cocos2dx/extensions/CCBIReader/CCNodeLoaderListener.h +++ b/cocos2dx/extensions/CCBReader/CCNodeLoaderListener.h @@ -3,8 +3,6 @@ #include "cocos2d.h" - - NS_CC_EXT_BEGIN class CCNodeLoaderListener { diff --git a/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.cpp b/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.cpp similarity index 99% rename from cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.cpp rename to cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.cpp index 62db13eedd..1e1d00b444 100644 --- a/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.cpp @@ -1,7 +1,7 @@ #include "CCParticleSystemQuadLoader.h" -using namespace cocos2d; -using namespace cocos2d::extension; +USING_NS_CC; +USING_NS_CC_EXT; #define PROPERTY_EMITERMODE "emitterMode" #define PROPERTY_POSVAR "posVar" diff --git a/cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.h b/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h similarity index 100% rename from cocos2dx/extensions/CCBIReader/CCParticleSystemQuadLoader.h rename to cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h diff --git a/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.cpp b/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.cpp similarity index 98% rename from cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.cpp rename to cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.cpp index 59a34b4ad8..c135580a5a 100644 --- a/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.cpp @@ -1,7 +1,7 @@ #include "CCScale9SpriteLoader.h" -using namespace cocos2d; -using namespace cocos2d::extension; +USING_NS_CC; +USING_NS_CC_EXT; #define PROPERTY_CONTENTSIZE "contentSize" #define PROPERTY_SPRITEFRAME "spriteFrame" diff --git a/cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.h b/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h similarity index 100% rename from cocos2dx/extensions/CCBIReader/CCScale9SpriteLoader.h rename to cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h diff --git a/cocos2dx/extensions/CCBIReader/CCSpriteLoader.cpp b/cocos2dx/extensions/CCBReader/CCSpriteLoader.cpp similarity index 97% rename from cocos2dx/extensions/CCBIReader/CCSpriteLoader.cpp rename to cocos2dx/extensions/CCBReader/CCSpriteLoader.cpp index 3b987d09a2..d5370289e3 100644 --- a/cocos2dx/extensions/CCBIReader/CCSpriteLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCSpriteLoader.cpp @@ -1,7 +1,7 @@ #include "CCSpriteLoader.h" -using namespace cocos2d; -using namespace cocos2d::extension; +USING_NS_CC; +USING_NS_CC_EXT; #define PROPERTY_FLIP "flip" #define PROPERTY_DISPLAYFRAME "displayFrame" diff --git a/cocos2dx/extensions/CCBIReader/CCSpriteLoader.h b/cocos2dx/extensions/CCBReader/CCSpriteLoader.h similarity index 100% rename from cocos2dx/extensions/CCBIReader/CCSpriteLoader.h rename to cocos2dx/extensions/CCBReader/CCSpriteLoader.h diff --git a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp index e702f3e2f6..18f170316b 100644 --- a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp @@ -413,12 +413,14 @@ CCScale9Sprite* CCScale9Sprite::resizableSpriteWithCapInsets(CCRect capInsets) CCScale9Sprite* CCScale9Sprite::node() { - CCScale9Sprite *pRet = new CCScale9Sprite(); - if (pRet) + CCScale9Sprite *pReturn = new CCScale9Sprite(); + if (pReturn) { - pRet->autorelease(); + pReturn->autorelease(); + return pReturn; } - return pRet; + CC_SAFE_DELETE(pReturn); + return NULL; } diff --git a/cocos2dx/platform/ios/CCFileUtils.mm b/cocos2dx/platform/ios/CCFileUtils.mm index e34f5a5698..c30795aa78 100644 --- a/cocos2dx/platform/ios/CCFileUtils.mm +++ b/cocos2dx/platform/ios/CCFileUtils.mm @@ -39,7 +39,7 @@ THE SOFTWARE. #define MAX_PATH 260 -using namespace cocos2d; +USING_NS_CC; static void static_addValueToCCDict(id key, id value, CCDictionary* pDict); static void static_addItemToCCArray(id item, CCArray* pArray); diff --git a/tests/Resources/CocosBuilder_v2/TestTemplate.ccbt b/tests/Resources/CocosBuilder_v2/TestTemplate.ccbt deleted file mode 100644 index f0acd14e72..0000000000 --- a/tests/Resources/CocosBuilder_v2/TestTemplate.ccbt +++ /dev/null @@ -1,21 +0,0 @@ - - - - - fileType - CocosBuilderTemplate - fileVersion - 1 - customClass - TemplateTest - previewImage - logo.png - propertyFile - TestTemplateProps.plist - previewAnchorpoint - - 0.5 - 0.5 - - - diff --git a/tests/Resources/ccb/official/pub/res/burst-hd.png.REMOVED.git-id b/tests/Resources/ccb/official/pub/res/burst-hd.png.REMOVED.git-id new file mode 100644 index 0000000000..4b8037d9b8 --- /dev/null +++ b/tests/Resources/ccb/official/pub/res/burst-hd.png.REMOVED.git-id @@ -0,0 +1 @@ +723ff604c8b83d6b1c5a72aea87e9c904fe6c699 \ No newline at end of file diff --git a/tests/Resources/ccb/official/pub/res/burst-ipad.png.REMOVED.git-id b/tests/Resources/ccb/official/pub/res/burst-ipad.png.REMOVED.git-id new file mode 100644 index 0000000000..4b8037d9b8 --- /dev/null +++ b/tests/Resources/ccb/official/pub/res/burst-ipad.png.REMOVED.git-id @@ -0,0 +1 @@ +723ff604c8b83d6b1c5a72aea87e9c904fe6c699 \ No newline at end of file diff --git a/tests/Resources/ccb/official/pub/res/flower.jpg.REMOVED.git-id b/tests/Resources/ccb/official/pub/res/flower.jpg.REMOVED.git-id new file mode 100644 index 0000000000..60dddf3fb7 --- /dev/null +++ b/tests/Resources/ccb/official/pub/res/flower.jpg.REMOVED.git-id @@ -0,0 +1 @@ +38e3a5fabac55b5649842cb35930af7594f093ef \ No newline at end of file diff --git a/tests/Resources/CocosBuilder_v1/markerfelt24shadow.fnt.REMOVED.git-id b/tests/Resources/ccb/official/pub/res/markerfelt24shadow.fnt.REMOVED.git-id similarity index 100% rename from tests/Resources/CocosBuilder_v1/markerfelt24shadow.fnt.REMOVED.git-id rename to tests/Resources/ccb/official/pub/res/markerfelt24shadow.fnt.REMOVED.git-id diff --git a/tests/Resources/ccb/official/src/res/burst-hd.png.REMOVED.git-id b/tests/Resources/ccb/official/src/res/burst-hd.png.REMOVED.git-id new file mode 100644 index 0000000000..4b8037d9b8 --- /dev/null +++ b/tests/Resources/ccb/official/src/res/burst-hd.png.REMOVED.git-id @@ -0,0 +1 @@ +723ff604c8b83d6b1c5a72aea87e9c904fe6c699 \ No newline at end of file diff --git a/tests/Resources/ccb/official/src/res/burst-ipad.png.REMOVED.git-id b/tests/Resources/ccb/official/src/res/burst-ipad.png.REMOVED.git-id new file mode 100644 index 0000000000..4b8037d9b8 --- /dev/null +++ b/tests/Resources/ccb/official/src/res/burst-ipad.png.REMOVED.git-id @@ -0,0 +1 @@ +723ff604c8b83d6b1c5a72aea87e9c904fe6c699 \ No newline at end of file diff --git a/tests/Resources/ccb/official/src/res/flower.jpg.REMOVED.git-id b/tests/Resources/ccb/official/src/res/flower.jpg.REMOVED.git-id new file mode 100644 index 0000000000..60dddf3fb7 --- /dev/null +++ b/tests/Resources/ccb/official/src/res/flower.jpg.REMOVED.git-id @@ -0,0 +1 @@ +38e3a5fabac55b5649842cb35930af7594f093ef \ No newline at end of file diff --git a/tests/Resources/CocosBuilder_v2/markerfelt24shadow.fnt.REMOVED.git-id b/tests/Resources/ccb/official/src/res/markerfelt24shadow.fnt.REMOVED.git-id similarity index 100% rename from tests/Resources/CocosBuilder_v2/markerfelt24shadow.fnt.REMOVED.git-id rename to tests/Resources/ccb/official/src/res/markerfelt24shadow.fnt.REMOVED.git-id diff --git a/tests/Resources/ccb/pub/fonts/Droid.ttf.REMOVED.git-id b/tests/Resources/ccb/simple/pub/fonts/Droid.ttf.REMOVED.git-id similarity index 100% rename from tests/Resources/ccb/pub/fonts/Droid.ttf.REMOVED.git-id rename to tests/Resources/ccb/simple/pub/fonts/Droid.ttf.REMOVED.git-id diff --git a/tests/Resources/ccb/src/fonts/Droid.ttf.REMOVED.git-id b/tests/Resources/ccb/simple/src/fonts/Droid.ttf.REMOVED.git-id similarity index 100% rename from tests/Resources/ccb/src/fonts/Droid.ttf.REMOVED.git-id rename to tests/Resources/ccb/simple/src/fonts/Droid.ttf.REMOVED.git-id diff --git a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id index 42a8d0aa15..81bb3edcb7 100644 --- a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -ac9e1ccb05629df842bf61eee24797838c23c929 \ No newline at end of file +650424fef741f04e23213a3ccadc8620df8fd9f1 \ No newline at end of file diff --git a/tests/tests/AccelerometerTest/AccelerometerTest.h b/tests/tests/AccelerometerTest/AccelerometerTest.h index 9f1ef840db..bb00e359a9 100644 --- a/tests/tests/AccelerometerTest/AccelerometerTest.h +++ b/tests/tests/AccelerometerTest/AccelerometerTest.h @@ -3,7 +3,7 @@ #include "../testBasic.h" -using namespace cocos2d; +USING_NS_CC; class AccelerometerTest: public CCLayer { diff --git a/tests/tests/ActionsEaseTest/ActionsEaseTest.h b/tests/tests/ActionsEaseTest/ActionsEaseTest.h index 04a5769af1..772f0e2d8e 100644 --- a/tests/tests/ActionsEaseTest/ActionsEaseTest.h +++ b/tests/tests/ActionsEaseTest/ActionsEaseTest.h @@ -4,7 +4,7 @@ ////----#include "cocos2d.h" #include "../testBasic.h" -using namespace cocos2d; +USING_NS_CC; class EaseSpriteDemo : public CCLayer { diff --git a/tests/tests/ActionsTest/ActionsTest.h b/tests/tests/ActionsTest/ActionsTest.h index d93a9b88cb..3267b1d2fa 100644 --- a/tests/tests/ActionsTest/ActionsTest.h +++ b/tests/tests/ActionsTest/ActionsTest.h @@ -4,7 +4,7 @@ #include "../testBasic.h" ////----#include "cocos2d.h" -using namespace cocos2d; +USING_NS_CC; enum diff --git a/tests/tests/BugsTest/Bug-458/QuestionContainerSprite.cpp b/tests/tests/BugsTest/Bug-458/QuestionContainerSprite.cpp index aaebb986da..5425c00ee4 100644 --- a/tests/tests/BugsTest/Bug-458/QuestionContainerSprite.cpp +++ b/tests/tests/BugsTest/Bug-458/QuestionContainerSprite.cpp @@ -2,7 +2,7 @@ #define kLabelTag -using namespace cocos2d; +USING_NS_CC; bool QuestionContainerSprite::init() { diff --git a/tests/tests/CocosDenshionTest/CocosDenshionTest.cpp b/tests/tests/CocosDenshionTest/CocosDenshionTest.cpp index 4bad47c84b..258d912bda 100644 --- a/tests/tests/CocosDenshionTest/CocosDenshionTest.cpp +++ b/tests/tests/CocosDenshionTest/CocosDenshionTest.cpp @@ -19,7 +19,7 @@ #define MUSIC_FILE "background.mp3" #endif // CC_PLATFORM_WIN32 -using namespace cocos2d; +USING_NS_CC; using namespace CocosDenshion; #define LINE_SPACE 40 diff --git a/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.cpp b/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.cpp deleted file mode 100644 index 154d2ce97b..0000000000 --- a/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.cpp +++ /dev/null @@ -1,98 +0,0 @@ -#include "CCBIReaderLayer.h" -#include "CCBReader.h" -#include "CCNodeLoaderLibrary.h" - -using namespace cocos2d; -using namespace cocos2d::extension; - -CCBIReaderLayer * CCBIReaderLayer::node() { - CCBIReaderLayer *pRet = new CCBIReaderLayer(); - if (pRet && pRet->init()) { - pRet->autorelease(); - return pRet; - } else { - CC_SAFE_DELETE(pRet); - return NULL; - } -} - -bool CCBIReaderLayer::init() { - return CCLayer::init(); -} - -void CCBIReaderLayer::menuCloseCallback(CCObject* pSender) { - CCDirector::sharedDirector()->end(); - -#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - exit(0); -#endif -} - -bool CCBIReaderLayer::onAssignCCBMemberVariable(CCObject * pTarget, const char * pMemberVariableName, CCNode * pNode) { - if(pTarget == this) { - if(strcmp(pMemberVariableName, "mCCControlButton") == 0) { - this->mCCControlButton = dynamic_cast(pNode); - return true; - } else if(strcmp(pMemberVariableName, "mCCMenuItemImage") == 0) { - this->mCCMenuItemImage = dynamic_cast(pNode); - return true; - } - } - return false; -} - -SEL_CCControlHandler CCBIReaderLayer::onResolveCCBCCControlSelector(CCObject * pTarget, const char * pSelectorName) { - if(pTarget == this) { - if(strcmp(pSelectorName, "onCCControlButtonClicked") == 0) { - return cccontrol_selector(CCBIReaderLayer::onCCControlButtonClicked); - } - } - return NULL; -} - -SEL_MenuHandler CCBIReaderLayer::onResolveCCBCCMenuSelector(CCObject * pTarget, const char * pSelectorName) { - if(pTarget == this) { - if(strcmp(pSelectorName, "onCCMenuItemImageClicked") == 0) { - return menu_selector(CCBIReaderLayer::onCCMenuItemImageClicked); - } - } - return NULL; -} - -void CCBIReaderLayer::onCCControlButtonClicked(CCObject * pSender, CCControlEvent pCCControlEvent) { - switch(pCCControlEvent) { - case CCControlEventTouchDown: - CCLOG("onCCControlButtonClicked: Touch Down."); - break; - case CCControlEventTouchDragInside: - CCLOG("onCCControlButtonClicked: Touch Drag Inside."); - break; - case CCControlEventTouchDragOutside: - CCLOG("onCCControlButtonClicked: Touch Drag Outside."); - break; - case CCControlEventTouchDragEnter: - CCLOG("onCCControlButtonClicked: Touch Drag Enter."); - break; - case CCControlEventTouchDragExit: - CCLOG("onCCControlButtonClicked: Touch Drag Exit."); - break; - case CCControlEventTouchUpInside: - CCLOG("onCCControlButtonClicked: Touch Up Inside."); - break; - case CCControlEventTouchUpOutside: - CCLOG("onCCControlButtonClicked: Touch Up Outside."); - break; - case CCControlEventTouchCancel: - CCLOG("onCCControlButtonClicked: Touch Cancel."); - break; - case CCControlEventValueChanged: - CCLOG("onCCControlButtonClicked: Value Changed."); - break; - default: - assert(false); // OH SHIT! - } -} - -void CCBIReaderLayer::onCCMenuItemImageClicked(CCObject * pSender) { - CCLOG("onCCMenuItemImageClicked!"); -} \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.h b/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.h deleted file mode 100644 index ace823bfbf..0000000000 --- a/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderLayer.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _CCBIREADER_LAYER_H_ -#define _CCBIREADER_LAYER_H_ - -#include "cocos2d.h" -#include "CCBMemberVariableAssigner.h" -#include "CCBSelectorResolver.h" - -class CCBIReaderLayer : public cocos2d::CCLayer, public cocos2d::extension::CCBMemberVariableAssigner, public cocos2d::extension::CCBSelectorResolver { - public: - static CCBIReaderLayer * node(); - - virtual bool init(); - - virtual void menuCloseCallback(CCObject * pSender); - - virtual bool onAssignCCBMemberVariable(CCObject * pTarget, const char * pMemberVariableName, CCNode * pNode); - virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(CCObject * pTarget, const char * pSelectorName); - virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(CCObject * pTarget, const char * pSelectorName); - - virtual void onCCControlButtonClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); - virtual void onCCMenuItemImageClicked(CCObject * pSender); - private: - cocos2d::extension::CCControlButton * mCCControlButton; - cocos2d::CCMenuItemImage * mCCMenuItemImage; -}; - -#endif diff --git a/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderTest.cpp b/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderTest.cpp deleted file mode 100644 index fdeb5d98e3..0000000000 --- a/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderTest.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** - Copyright (c) 2012 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "CCBIReaderTest.h" -#include "../../testResource.h" -#include "extensions/CCBIReader/CCBReader.h" -#include "extensions/CCBIReader/CCNodeLoaderLibrary.h" -#include "CCBIReaderLayer.h" - -using namespace cocos2d; -using namespace cocos2d::extension; - -void CCBIReaderTestScene::runThisTest() { - CCBIReaderLayer * ccbiReaderLayer = CCBIReaderLayer::node(); - - /* Create an autorelease CCNodeLoaderLibrary. */ - CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary(); - - /* Create an autorelease CCBReader. */ - CCBReader * ccbReader = new CCBReader(ccNodeLoaderLibrary, ccbiReaderLayer, ccbiReaderLayer); - ccbReader->autorelease(); - - /* Read a ccbi file. */ - CCNode * node = ccbReader->readNodeGraphFromFile("ccb/pub/", "ccb/test.ccbi", ccbiReaderLayer); - - if(node != NULL) { - ccbiReaderLayer->addChild(node); - } - - this->addChild(ccbiReaderLayer); - - CCDirector::sharedDirector()->replaceScene(this); -} diff --git a/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderTest.h b/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderTest.h deleted file mode 100644 index 6b7291d374..0000000000 --- a/tests/tests/ExtensionsTest/CCBIReaderTest/CCBIReaderTest.h +++ /dev/null @@ -1,35 +0,0 @@ -/**************************************************************************** - Copyright (c) 2012 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef _CCBREADER_TEST_H_ -#define _CCBREADER_TEST_H_ - -#include "../../testBasic.h" - -class CCBIReaderTestScene : public TestScene { - public: - virtual void runThisTest(); -}; - -#endif \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.cpp new file mode 100644 index 0000000000..435b89dded --- /dev/null +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.cpp @@ -0,0 +1,33 @@ +#include "ButtonTestLayer.h" + +#include "extensions/CCBReader/CCBReader.h" + +USING_NS_CC; +USING_NS_CC_EXT; + +ButtonTestLayer * ButtonTestLayer::node() { + ButtonTestLayer * ptr = new ButtonTestLayer(); + if(ptr && ptr->init()) { + ptr->autorelease(); + return ptr; + } + CC_SAFE_DELETE(ptr); + return NULL; +} + +SEL_MenuHandler ButtonTestLayer::onResolveCCBCCMenuSelector(CCObject * pTarget, const char * pSelectorName) { + return NULL; +} + +SEL_CCControlHandler ButtonTestLayer::onResolveCCBCCControlSelector(CCObject * pTarget, const char * pSelectorName) { + if(pTarget == this) { + if(strcmp(pSelectorName, "onCCControlButtonClicked") == 0) { + return cccontrol_selector(ButtonTestLayer::onCCControlButtonClicked); + } + } + return NULL; +} + +void ButtonTestLayer::onCCControlButtonClicked(cocos2d::CCObject *pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { + printf("onCCControlButtonClicked\n"); +} \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.h new file mode 100644 index 0000000000..76de9a9b2c --- /dev/null +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.h @@ -0,0 +1,18 @@ +#ifndef _BUTTONTESTLAYER_H_ +#define _BUTTONTESTLAYER_H_ + +#include "cocos2d.h" +#include "CCNodeLoader.h" +#include "CCBSelectorResolver.h" + +class ButtonTestLayer : public cocos2d::extension::CCBSelectorResolver, public cocos2d::CCLayer { + public: + static ButtonTestLayer * node(); + + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(cocos2d::CCObject * pTarget, const char * pSelectorName); + virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, const char * pSelectorName); + + virtual void onCCControlButtonClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); +}; + +#endif \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayerLoader.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayerLoader.cpp new file mode 100644 index 0000000000..88778d7fa5 --- /dev/null +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayerLoader.cpp @@ -0,0 +1,8 @@ +#include "ButtonTestLayerLoader.h" + +USING_NS_CC; +USING_NS_CC_EXT; + +ButtonTestLayer * ButtonTestLayerLoader::createCCNode(CCNode * pParent, cocos2d::extension::CCBReader * pCCBReader) { + return ButtonTestLayer::node(); +} \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayerLoader.h b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayerLoader.h new file mode 100644 index 0000000000..714f14f40d --- /dev/null +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayerLoader.h @@ -0,0 +1,18 @@ +#ifndef _BUTTONTESTLAYERLOADER_H_ +#define _BUTTONTESTLAYERLOADER_H_ + +#include "CCLayerLoader.h" +#include "ButtonTestLayer.h" + +/* Forward declaration. */ +class CCBReader; + +class ButtonTestLayerLoader : public cocos2d::extension::CCLayerLoader { + public: + STATIC_NEW_AUTORELEASE_OBJECT_METHOD(ButtonTestLayerLoader, loader); + + protected: + virtual ButtonTestLayer * createCCNode(cocos2d::CCNode *, cocos2d::extension::CCBReader *); +}; + +#endif diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp index 0469bbbb03..34e89c9fdf 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp @@ -25,18 +25,51 @@ #include "CocosBuilderTest.h" #include "../../testResource.h" #include "extensions/CCBReader/CCBReader.h" -#include "HelloCocosBuilder.h" +#include "extensions/CCBReader/CCNodeLoaderLibrary.h" +#include "HelloCocosBuilderLayerLoader.h" USING_NS_CC; +USING_NS_CC_EXT; -void CocosBuilderTestScene::runThisTest() -{ - CCBCustomClassFactory::sharedFactory()->registCustomClass( - "HelloCocosBuilder", - HelloCocosBuilder::createInstance); +void CocosBuilderTestScene::runThisTest() { + /* Create an autorelease CCNodeLoaderLibrary. */ + CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary(); - CCNode* node = CCBReader::nodeGraphFromFile("CocosBuilder_v2/example_relativeposition.ccb"); - this->addChild(node) ; + ccNodeLoaderLibrary->registerCCNodeLoader("HelloCocosBuilderLayer", HelloCocosBuilderLayerLoader::loader()); + + /* Create an autorelease CCBReader. */ + cocos2d::extension::CCBReader * ccbReader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary); + ccbReader->autorelease(); + /* Read a ccbi file. */ + CCNode * node = ccbReader->readNodeGraphFromFile("ccb/official/pub/", "ccb/HelloCocosBuilder.ccbi", this); + + if(node != NULL) { + this->addChild(node); + } + CCDirector::sharedDirector()->replaceScene(this); } + + +//void CocosBuilderTestScene::runThisTest() { +// CCBIReaderLayer * ccbiReaderLayer = CCBIReaderLayer::node(); +// +// /* Create an autorelease CCNodeLoaderLibrary. */ +// CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary(); +// +// /* Create an autorelease CCBReader. */ +// CCBReader * ccbReader = new CCBReader(ccNodeLoaderLibrary, ccbiReaderLayer, ccbiReaderLayer); +// ccbReader->autorelease(); +// +// /* Read a ccbi file. */ +// CCNode * node = ccbReader->readNodeGraphFromFile("ccb/simple/pub/", "ccb/test.ccbi", ccbiReaderLayer); +// +// if(node != NULL) { +// ccbiReaderLayer->addChild(node); +// } +// +// this->addChild(ccbiReaderLayer); +// +// CCDirector::sharedDirector()->replaceScene(this); +//} diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.h b/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.h index 7ac42fb567..6d63e9fd9c 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.h @@ -1,36 +1,11 @@ -/**************************************************************************** - Copyright (c) 2012 cocos2d-x.org - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef _COCOS_BUILDER_TEST_H_ -#define _COCOS_BUILDER_TEST_H_ +#ifndef _CCBIREADER_TEST_H_ +#define _CCBIREADER_TEST_H_ #include "../../testBasic.h" -class CocosBuilderTestScene : public TestScene -{ -public: - virtual void runThisTest(); +class CocosBuilderTestScene : public TestScene { + public: + virtual void runThisTest(); }; #endif \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder.cpp deleted file mode 100644 index 21329d770d..0000000000 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** - Copyright (c) 2012 cocos2d-x.org - Copyright (c) 2012 XiaoLong Zhang, Chukong Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#include "HelloCocosBuilder.h" - -USING_NS_CC; - -HelloCocosBuilder::HelloCocosBuilder() -:m_pSpriteBurst(NULL) -,m_pSpriteIcon(NULL) -{ -} - -HelloCocosBuilder::~HelloCocosBuilder() -{ - CC_SAFE_RELEASE_NULL(m_pSpriteBurst); - CC_SAFE_RELEASE_NULL(m_pSpriteIcon); -} - -bool HelloCocosBuilder::callbackSetChildren(const char* name, CCObject* node) -{ - bool bRetVal = false; - - if (strcmp(name, "sprtBurst") == 0) - { - m_pSpriteBurst = dynamic_cast(node); - CC_ASSERT(m_pSpriteBurst); - m_pSpriteBurst->retain(); - } - else if (strcmp(name, "sprtIcon") == 0) - { - m_pSpriteIcon = dynamic_cast(node); - CC_ASSERT(m_pSpriteIcon); - m_pSpriteIcon->retain(); - } - - return bRetVal; -}; - -void HelloCocosBuilder::callbackAfterCCBLoaded() -{ - CCLOG("loading.....successed!") ; - void* act = CCRotateBy::actionWithDuration(0.5f, 10) ; - void* act1 = CCRepeatForever::actionWithAction((CCActionInterval*)act) ; - m_pSpriteBurst->runAction((CCAction*)act1) ; -} - -SEL_MenuHandler HelloCocosBuilder::callbackGetSelectors(const char* selectorName) -{ - if (strcmp(selectorName, "pressedButton") == 0) - { - return menu_selector(HelloCocosBuilder::pressedButton); - } - else if (strcmp(selectorName, "pressedButton2") == 0) - { - return menu_selector(HelloCocosBuilder::pressedButton2); - } - else - { - return NULL; - } -} - -void HelloCocosBuilder::pressedButton(CCObject*sender) -{ - m_pSpriteIcon->stopAllActions() ; - void* rotateAction = CCRotateBy::actionWithDuration(1, 360) ; - m_pSpriteIcon->runAction((CCAction*)rotateAction) ; -} - -void HelloCocosBuilder::pressedButton2(CCObject*sender) -{ - CCLOG("pressed successed!") ; -} \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder.h b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder.h deleted file mode 100644 index 82c80426a5..0000000000 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder.h +++ /dev/null @@ -1,63 +0,0 @@ -/**************************************************************************** - Copyright (c) 2012 cocos2d-x.org - Copyright (c) 2012 XiaoLong Zhang, Chukong Inc. - - http://www.cocos2d-x.org - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in - all copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - THE SOFTWARE. - ****************************************************************************/ - -#ifndef cocos2dXReflection_HelloCocosBuilder_h -#define cocos2dXReflection_HelloCocosBuilder_h - -#include "cocos2d.h" -#include "extensions/CCBReader/CCBCustomClass.h" - -namespace cocos2d{ - - class HelloCocosBuilder : public extension::CCBCustomClassProtocol, public CCLayer - { - public: - HelloCocosBuilder(); - ~HelloCocosBuilder(); - - static extension::CCBCustomClassProtocol* createInstance() - { - return new HelloCocosBuilder() ; - } - - public: - // implement 3 pure virtual methods inherited from CCBCustomClass - virtual bool callbackSetChildren(const char* name, CCObject* node); - virtual SEL_MenuHandler callbackGetSelectors(const char* selectorName); - virtual void callbackAfterCCBLoaded(); - - - void pressedButton(CCObject*sender) ; - void pressedButton2(CCObject*sender) ; - - protected: - CCSprite* m_pSpriteBurst ; - CCSprite* m_pSpriteIcon ; - - } ; -} - - -#endif diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.cpp new file mode 100644 index 0000000000..7e9e6b560a --- /dev/null +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.cpp @@ -0,0 +1,132 @@ +#include "HelloCocosBuilderLayer.h" + +#include "extensions/CCBReader/CCBReader.h" +#include "extensions/CCBReader/CCNodeLoaderLibrary.h" + +#include "TestHeaderLayerLoader.h" +#include "ButtonTestLayerLoader.h" +#include "CCTransition.h" + +USING_NS_CC; +USING_NS_CC_EXT; + +HelloCocosBuilderLayer * HelloCocosBuilderLayer::node() { + HelloCocosBuilderLayer * ptr = new HelloCocosBuilderLayer(); + if(ptr && ptr->init()) { + ptr->autorelease(); + return ptr; + } + CC_SAFE_DELETE(ptr); + return NULL; +} + +void HelloCocosBuilderLayer::openTest(const char * pCCBFileName, const char * pCCNodeName, CCNodeLoader * pCCNodeLoader) { + /* Create an autorelease CCNodeLoaderLibrary. */ + CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary(); + + ccNodeLoaderLibrary->registerCCNodeLoader("TestHeaderLayer", TestHeaderLayerLoader::loader()); + if(pCCNodeName != NULL && pCCNodeLoader != NULL) { + ccNodeLoaderLibrary->registerCCNodeLoader(pCCNodeName, pCCNodeLoader); + } + + /* Create an autorelease CCBReader. */ + cocos2d::extension::CCBReader * ccbReader = new cocos2d::extension::CCBReader(ccNodeLoaderLibrary); + ccbReader->autorelease(); + + /* Read a ccbi file. */ + // Load the scene from the ccbi-file, setting this class as + // the owner will cause lblTestTitle to be set by the CCBReader. + // lblTestTitle is in the TestHeader.ccbi, which is referenced + // from each of the test scenes. + CCNode * node = ccbReader->readNodeGraphFromFile("ccb/official/pub/", pCCBFileName, this); + + this->mTestTitleLabelTTF->setString(pCCBFileName); + + CCScene * scene = CCScene::node(); + if(node != NULL) { + scene->addChild(node); + } + + /* Push the new scene with a fancy transition. */ + ccColor3B transitionColor; + transitionColor.r = 0; + transitionColor.g = 0; + transitionColor.b = 0; + + CCDirector::sharedDirector()->pushScene(CCTransitionFade::transitionWithDuration(0.5f, scene, transitionColor)); +} + + +void HelloCocosBuilderLayer::onNodeLoaded(cocos2d::CCNode * pNode, cocos2d::extension::CCNodeLoader * pNodeLoader) { + CCRotateBy * ccRotateBy = CCRotateBy::actionWithDuration(0.5f, 10); + CCRepeatForever * ccRepeatForever = CCRepeatForever::actionWithAction(ccRotateBy); + this->mBurstSprite->runAction(ccRepeatForever); +} + + +SEL_MenuHandler HelloCocosBuilderLayer::onResolveCCBCCMenuSelector(CCObject * pTarget, const char * pSelectorName) { + return NULL; +} + +SEL_CCControlHandler HelloCocosBuilderLayer::onResolveCCBCCControlSelector(CCObject * pTarget, const char * pSelectorName) { + if(pTarget == this) { + if(strcmp(pSelectorName, "onMenuTestClicked") == 0) { + return cccontrol_selector(HelloCocosBuilderLayer::onMenuTestClicked); + } else if(strcmp(pSelectorName, "onSpriteTestClicked") == 0) { + return cccontrol_selector(HelloCocosBuilderLayer::onSpriteTestClicked); + } else if(strcmp(pSelectorName, "onButtonTestClicked") == 0) { + return cccontrol_selector(HelloCocosBuilderLayer::onButtonTestClicked); + } else if(strcmp(pSelectorName, "onLabelTestClicked") == 0) { + return cccontrol_selector(HelloCocosBuilderLayer::onLabelTestClicked); + } else if(strcmp(pSelectorName, "onParticleSystemTestClicked") == 0) { + return cccontrol_selector(HelloCocosBuilderLayer::onParticleSystemTestClicked); + } else if(strcmp(pSelectorName, "onScrollViewTestClicked") == 0) { + return cccontrol_selector(HelloCocosBuilderLayer::onScrollViewTestClicked); + } + } + return NULL; +} + + +bool HelloCocosBuilderLayer::onAssignCCBMemberVariable(CCObject * pTarget, const char * pMemberVariableName, CCNode * pNode) { + if(pTarget == this) { + if(strcmp(pMemberVariableName, "mBurstSprite") == 0) { + this->mBurstSprite = dynamic_cast(pNode); + CC_ASSERT(this->mBurstSprite); + this->mBurstSprite->retain(); + return true; + } else if(strcmp(pMemberVariableName, "mTestTitleLabel") == 0) { + this->mTestTitleLabelTTF = dynamic_cast(pNode); + CC_ASSERT(this->mTestTitleLabelTTF); + this->mTestTitleLabelTTF->retain(); + return true; + } + } + return false; +} + + +void HelloCocosBuilderLayer::onMenuTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { + printf("onMenuTestClicked\n"); +} + +void HelloCocosBuilderLayer::onSpriteTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { + printf("onSpriteTestClicked\n"); +} + +void HelloCocosBuilderLayer::onButtonTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { + printf("onButtonTestClicked\n"); + this->openTest("ccb/ButtonTest.ccbi", "ButtonTestLayer", ButtonTestLayerLoader::loader()); +} + +void HelloCocosBuilderLayer::onLabelTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { + printf("onLabelTestClicked\n"); +} + +void HelloCocosBuilderLayer::onParticleSystemTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { + printf("onParticleSystemTestClicked\n"); +} + +void HelloCocosBuilderLayer::onScrollViewTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { + printf("onScrollViewTestClicked\n"); +} \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.h new file mode 100644 index 0000000000..51b2432b79 --- /dev/null +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.h @@ -0,0 +1,43 @@ +#ifndef _HELLOCOCOSBUILDERLAYER_H_ +#define _HELLOCOCOSBUILDERLAYER_H_ + +#include "cocos2d.h" +#include "CCNodeLoader.h" +#include "CCNodeLoaderListener.h" +#include "CCBSelectorResolver.h" +#include "CCBMemberVariableAssigner.h" + +/* + * Note: for some pretty hard fucked up reason, the order of inheritance is important! + * When CCLayer is the 'first' inherited object: + * During runtime the method call to the (pure virtual) 'interfaces' fails jumping into a bogus method or just doing nothing: + * #0 0x000cf840 in non-virtual thunk to HelloCocos.... + * #1 .... + * + * This thread describes the problem: + * http://www.cocoabuilder.com/archive/xcode/265549-crash-in-virtual-method-call.html + */ +class HelloCocosBuilderLayer : public cocos2d::extension::CCBSelectorResolver, public cocos2d::extension::CCBMemberVariableAssigner, public cocos2d::extension::CCNodeLoaderListener, public cocos2d::CCLayer { + public: + static HelloCocosBuilderLayer * node(); + + void openTest(const char * pCCBFileName, const char * pCCNodeName = NULL, cocos2d::extension::CCNodeLoader * pCCNodeLoader = NULL); + + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(cocos2d::CCObject * pTarget, const char * pSelectorName); + virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, const char * pSelectorName); + virtual bool onAssignCCBMemberVariable(cocos2d::CCObject * pTarget, const char * pMemberVariableName, cocos2d::CCNode * pNode); + virtual void onNodeLoaded(cocos2d::CCNode * pNode, cocos2d::extension::CCNodeLoader * pNodeLoader); + + virtual void onMenuTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); + virtual void onSpriteTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); + virtual void onButtonTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); + virtual void onLabelTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); + virtual void onParticleSystemTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); + virtual void onScrollViewTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); + + private: + cocos2d::CCSprite * mBurstSprite; + cocos2d::CCLabelTTF * mTestTitleLabelTTF; +}; + +#endif diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayerLoader.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayerLoader.cpp new file mode 100644 index 0000000000..10bb08dd21 --- /dev/null +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayerLoader.cpp @@ -0,0 +1,8 @@ +#include "HelloCocosBuilderLayerLoader.h" + +USING_NS_CC; +USING_NS_CC_EXT; + +HelloCocosBuilderLayer * HelloCocosBuilderLayerLoader::createCCNode(CCNode * pParent, cocos2d::extension::CCBReader * pCCBReader) { + return HelloCocosBuilderLayer::node(); +} \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayerLoader.h b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayerLoader.h new file mode 100644 index 0000000000..899ab648cc --- /dev/null +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayerLoader.h @@ -0,0 +1,18 @@ +#ifndef _HELLOCOCOSBUILDERLAYERLOADER_H_ +#define _HELLOCOCOSBUILDERLAYERLOADER_H_ + +#include "CCLayerLoader.h" +#include "HelloCocosBuilderLayer.h" + +/* Forward declaration. */ +class CCBReader; + +class HelloCocosBuilderLayerLoader : public cocos2d::extension::CCLayerLoader { + public: + STATIC_NEW_AUTORELEASE_OBJECT_METHOD(HelloCocosBuilderLayerLoader, loader); + + protected: + virtual HelloCocosBuilderLayer * createCCNode(cocos2d::CCNode *, cocos2d::extension::CCBReader *); +}; + +#endif diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.cpp new file mode 100644 index 0000000000..68198bfb54 --- /dev/null +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.cpp @@ -0,0 +1,34 @@ +#include "TestHeaderLayer.h" + +#include "extensions/CCBReader/CCBReader.h" + +USING_NS_CC; +USING_NS_CC_EXT; + +TestHeaderLayer * TestHeaderLayer::node() { + TestHeaderLayer * ptr = new TestHeaderLayer(); + if(ptr && ptr->init()) { + ptr->autorelease(); + return ptr; + } + CC_SAFE_DELETE(ptr); + return NULL; +} + +SEL_MenuHandler TestHeaderLayer::onResolveCCBCCMenuSelector(CCObject * pTarget, const char * pSelectorName) { + if(pTarget == this) { + if(strcmp(pSelectorName, "onBackClicked") == 0) { + return menu_selector(TestHeaderLayer::onBackClicked); + } + } + return NULL; +} + +SEL_CCControlHandler TestHeaderLayer::onResolveCCBCCControlSelector(CCObject * pTarget, const char * pSelectorName) { + + return NULL; +} + +void TestHeaderLayer::onBackClicked(cocos2d::CCObject *pSender) { + CCDirector::sharedDirector()->popScene(); +} \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.h new file mode 100644 index 0000000000..9a978ca03d --- /dev/null +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.h @@ -0,0 +1,18 @@ +#ifndef _TESTHEADERLAYER_H_ +#define _TESTHEADERLAYER_H_ + +#include "cocos2d.h" +#include "CCNodeLoader.h" +#include "CCBSelectorResolver.h" + +class TestHeaderLayer : public cocos2d::extension::CCBSelectorResolver, public cocos2d::CCLayer { + public: + static TestHeaderLayer * node(); + + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(cocos2d::CCObject * pTarget, const char * pSelectorName); + virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, const char * pSelectorName); + + virtual void onBackClicked(cocos2d::CCObject * pSender); +}; + +#endif \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayerLoader.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayerLoader.cpp new file mode 100644 index 0000000000..024047b31a --- /dev/null +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayerLoader.cpp @@ -0,0 +1,8 @@ +#include "TestHeaderLayerLoader.h" + +USING_NS_CC; +USING_NS_CC_EXT; + +TestHeaderLayer * TestHeaderLayerLoader::createCCNode(CCNode * pParent, cocos2d::extension::CCBReader * pCCBReader) { + return TestHeaderLayer::node(); +} \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayerLoader.h b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayerLoader.h new file mode 100644 index 0000000000..63aa2c7bac --- /dev/null +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayerLoader.h @@ -0,0 +1,18 @@ +#ifndef _TESTHEADERLAYERLOADER_H_ +#define _TESTHEADERLAYERLOADER_H_ + +#include "CCLayerLoader.h" +#include "TestHeaderLayer.h" + +/* Forward declaration. */ +class CCBReader; + +class TestHeaderLayerLoader : public cocos2d::extension::CCLayerLoader { + public: + STATIC_NEW_AUTORELEASE_OBJECT_METHOD(TestHeaderLayerLoader, loader); + + protected: + virtual TestHeaderLayer * createCCNode(cocos2d::CCNode *, cocos2d::extension::CCBReader *); +}; + +#endif diff --git a/tests/tests/ExtensionsTest/ExtensionsTest.cpp b/tests/tests/ExtensionsTest/ExtensionsTest.cpp index cd9358d69b..b02823dfca 100644 --- a/tests/tests/ExtensionsTest/ExtensionsTest.cpp +++ b/tests/tests/ExtensionsTest/ExtensionsTest.cpp @@ -3,7 +3,6 @@ #include "NotificationCenterTest/NotificationCenterTest.h" #include "ControlExtensionTest/CCControlSceneManager.h" #include "CocosBuilderTest/CocosBuilderTest.h" -#include "CCBIReaderTest/CCBIReaderTest.h" enum { @@ -17,7 +16,6 @@ enum TEST_CCCONTROLBUTTON, TEST_TEXTUREWATCHER, TEST_COCOSBUILDER, - TEST_CCBIREADER, TEST_MAX_COUNT, }; @@ -27,7 +25,6 @@ static const std::string testsName[TEST_MAX_COUNT] = "CCControlButtonTest", "TextureWatcherTest", "CocosBuilderTest", - "CCBIReaderTest", }; //////////////////////////////////////////////////////// @@ -92,16 +89,6 @@ void ExtensionsMainLayer::menuCallback(CCObject* pSender) } } break; - case TEST_CCBIREADER: - { - TestScene* pScene = new CCBIReaderTestScene(); - if (pScene) - { - pScene->runThisTest(); - pScene->release(); - } - } - break; default: break; } diff --git a/tests/tests/MotionStreakTest/MotionStreakTest.h b/tests/tests/MotionStreakTest/MotionStreakTest.h index 0925f46a96..d2890d527e 100644 --- a/tests/tests/MotionStreakTest/MotionStreakTest.h +++ b/tests/tests/MotionStreakTest/MotionStreakTest.h @@ -4,7 +4,7 @@ ////----#include "cocos2d.h" #include "../testBasic.h" -//using namespace cocos2d; +//USING_NS_CC; class MotionStreakTest : public CCLayer { diff --git a/tests/tests/TextureCacheTest/TextureCacheTest.cpp b/tests/tests/TextureCacheTest/TextureCacheTest.cpp index bb5d0a8ca0..35351b1246 100644 --- a/tests/tests/TextureCacheTest/TextureCacheTest.cpp +++ b/tests/tests/TextureCacheTest/TextureCacheTest.cpp @@ -3,7 +3,7 @@ #include "TextureCacheTest.h" -using namespace cocos2d; +USING_NS_CC; TextureCacheTest::TextureCacheTest() : m_nNumberOfSprites(20) diff --git a/tests/tests/TouchesTest/Ball.h b/tests/tests/TouchesTest/Ball.h index e3ed1def0f..8d7ed2a55c 100644 --- a/tests/tests/TouchesTest/Ball.h +++ b/tests/tests/TouchesTest/Ball.h @@ -5,7 +5,7 @@ class Paddle; -using namespace cocos2d; +USING_NS_CC; class Ball : public CCSprite { diff --git a/tests/tests/TouchesTest/Paddle.h b/tests/tests/TouchesTest/Paddle.h index 6674b8fe27..9fbaee3755 100644 --- a/tests/tests/TouchesTest/Paddle.h +++ b/tests/tests/TouchesTest/Paddle.h @@ -3,7 +3,7 @@ #include "cocos2d.h" -using namespace cocos2d; +USING_NS_CC; typedef enum tagPaddleState { diff --git a/tests/tests/TouchesTest/TouchesTest.h b/tests/tests/TouchesTest/TouchesTest.h index b3ff280a75..b7b6221d9f 100644 --- a/tests/tests/TouchesTest/TouchesTest.h +++ b/tests/tests/TouchesTest/TouchesTest.h @@ -4,7 +4,7 @@ ////----#include "cocos2d.h" #include "../testBasic.h" -using namespace cocos2d; +USING_NS_CC; class PongScene : public TestScene { diff --git a/tests/tests/TransitionsTest/TransitionsTest.h b/tests/tests/TransitionsTest/TransitionsTest.h index 993aab241d..a1d6816e0e 100644 --- a/tests/tests/TransitionsTest/TransitionsTest.h +++ b/tests/tests/TransitionsTest/TransitionsTest.h @@ -3,7 +3,7 @@ #include "../testBasic.h" -using namespace cocos2d; +USING_NS_CC; class TransitionsTestScene : public TestScene { diff --git a/tests/tests/controller.h b/tests/tests/controller.h index 4298bd0d49..59ce24c090 100644 --- a/tests/tests/controller.h +++ b/tests/tests/controller.h @@ -3,7 +3,7 @@ #include "cocos2d.h" -using namespace cocos2d; +USING_NS_CC; class TestController : public CCLayer { From e2a1a246a0fdd11548da7963d40c394c3c78e6be Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 13 Jun 2012 14:26:28 -0700 Subject: [PATCH 150/257] Converted removed all Carriage Returns (dos line-endings, ^M.) in cocos2dx, except in the windows project/platform files. --- cocos2dx/CCConfiguration.h | 4 +- cocos2dx/CCDrawingPrimitives.h | 32 ++--- cocos2dx/CCScheduler.cpp | 116 +++++++++--------- cocos2dx/CCScheduler.h | 40 +++--- cocos2dx/cocoa/CCArray.cpp | 28 ++--- cocos2dx/cocoa/CCArray.h | 2 +- cocos2dx/misc_nodes/CCMotionStreak.cpp | 18 +-- cocos2dx/misc_nodes/CCRenderTexture.h | 26 ++-- cocos2dx/particle_nodes/CCParticleSystem.h | 4 +- .../particle_nodes/CCParticleSystemQuad.cpp | 4 +- cocos2dx/textures/CCTexture2D.h | 22 ++-- .../tileMap_parallax_nodes/CCTMXLayer.cpp | 92 +++++++------- 12 files changed, 194 insertions(+), 194 deletions(-) diff --git a/cocos2dx/CCConfiguration.h b/cocos2dx/CCConfiguration.h index 299aef6772..5064765dbb 100644 --- a/cocos2dx/CCConfiguration.h +++ b/cocos2dx/CCConfiguration.h @@ -97,8 +97,8 @@ public: return m_bSupportsDiscardFramebuffer; } - /** Whether or not shareable VAOs are supported. - @since v2.0.0 + /** Whether or not shareable VAOs are supported. + @since v2.0.0 */ inline bool isSupportsShareableVAO(void) { diff --git a/cocos2dx/CCDrawingPrimitives.h b/cocos2dx/CCDrawingPrimitives.h index a57b503ef1..71883bae07 100644 --- a/cocos2dx/CCDrawingPrimitives.h +++ b/cocos2dx/CCDrawingPrimitives.h @@ -65,12 +65,12 @@ void CC_DLL ccDrawPoints( const CCPoint *points, unsigned int numberOfPoints ); /** draws a line given the origin and destination point measured in points */ void CC_DLL ccDrawLine( const CCPoint& origin, const CCPoint& destination ); -/** draws a rectangle given the origin and destination point measured in points. */ -void CC_DLL ccDrawRect( CCPoint origin, CCPoint destination ); - -/** draws a solid rectangle given the origin and destination point measured in points. - @since 1.1 - */ +/** draws a rectangle given the origin and destination point measured in points. */ +void CC_DLL ccDrawRect( CCPoint origin, CCPoint destination ); + +/** draws a solid rectangle given the origin and destination point measured in points. + @since 1.1 + */ void CC_DLL ccDrawSolidRect( CCPoint origin, CCPoint destination, ccColor4F color ); /** draws a poligon given a pointer to CCPoint coordiantes and the number of vertices measured in points. @@ -97,16 +97,16 @@ void CC_DLL ccDrawQuadBezier(const CCPoint& origin, const CCPoint& control, cons */ void CC_DLL ccDrawCubicBezier(const CCPoint& origin, const CCPoint& control1, const CCPoint& control2, const CCPoint& destination, unsigned int segments); -/** draws a Catmull Rom path. - @warning This function could be pretty slow. Use it only for debugging purposes. - @since v2.0 - */ -void CC_DLL ccDrawCatmullRom( CCPointArray *arrayOfControlPoints, unsigned int segments ); - -/** draws a Cardinal Spline path. - @warning This function could be pretty slow. Use it only for debugging purposes. - @since v2.0 - */ +/** draws a Catmull Rom path. + @warning This function could be pretty slow. Use it only for debugging purposes. + @since v2.0 + */ +void CC_DLL ccDrawCatmullRom( CCPointArray *arrayOfControlPoints, unsigned int segments ); + +/** draws a Cardinal Spline path. + @warning This function could be pretty slow. Use it only for debugging purposes. + @since v2.0 + */ void CC_DLL ccDrawCardinalSpline( CCPointArray *config, CCFloat tension, unsigned int segments ); /** set the drawing color with 4 unsigned bytes diff --git a/cocos2dx/CCScheduler.cpp b/cocos2dx/CCScheduler.cpp index 1f486f6e89..75c22b6dc3 100644 --- a/cocos2dx/CCScheduler.cpp +++ b/cocos2dx/CCScheduler.cpp @@ -514,7 +514,7 @@ void CCScheduler::unscheduleAllSelectors(void) unscheduleAllSelectorsWithMinPriority(kCCPrioritySystem); } -void CCScheduler::unscheduleAllSelectorsWithMinPriority(int nMinPriority) +void CCScheduler::unscheduleAllSelectorsWithMinPriority(int nMinPriority) { // Custom Selectors tHashSelectorEntry *pElement = NULL; @@ -682,66 +682,66 @@ bool CCScheduler::isTargetPaused(CCObject *pTarget) return false; // should never get here } -CCSet* CCScheduler::pauseAllTargets() -{ - return pauseAllTargetsWithMinPriority(kCCPrioritySystem); -} - -CCSet* CCScheduler::pauseAllTargetsWithMinPriority(int nMinPriority) -{ - CCSet* idsWithSelectors = new CCSet();// setWithCapacity:50]; - idsWithSelectors->autorelease(); - - // Custom Selectors - for(tHashSelectorEntry *element = m_pHashForSelectors; element != NULL; - element = (tHashSelectorEntry*)element->hh.next) - { - element->paused = true; - idsWithSelectors->addObject(element->target); - } - - // Updates selectors - tListEntry *entry, *tmp; - if(nMinPriority < 0) - { - DL_FOREACH_SAFE( m_pUpdatesNegList, entry, tmp ) - { - if(entry->priority >= nMinPriority) - { - entry->paused = true; - idsWithSelectors->addObject(entry->target); - } - } - } - - if(nMinPriority <= 0) - { - DL_FOREACH_SAFE( m_pUpdates0List, entry, tmp ) - { - entry->paused = true; - idsWithSelectors->addObject(entry->target); - } - } - - DL_FOREACH_SAFE( m_pUpdatesPosList, entry, tmp ) - { - if(entry->priority >= nMinPriority) - { - entry->paused = true; - idsWithSelectors->addObject(entry->target); - } - } - - return idsWithSelectors; -} - -void CCScheduler::resumeTargets(CCSet* pTargetsToResume) -{ - CCSetIterator iter; +CCSet* CCScheduler::pauseAllTargets() +{ + return pauseAllTargetsWithMinPriority(kCCPrioritySystem); +} + +CCSet* CCScheduler::pauseAllTargetsWithMinPriority(int nMinPriority) +{ + CCSet* idsWithSelectors = new CCSet();// setWithCapacity:50]; + idsWithSelectors->autorelease(); + + // Custom Selectors + for(tHashSelectorEntry *element = m_pHashForSelectors; element != NULL; + element = (tHashSelectorEntry*)element->hh.next) + { + element->paused = true; + idsWithSelectors->addObject(element->target); + } + + // Updates selectors + tListEntry *entry, *tmp; + if(nMinPriority < 0) + { + DL_FOREACH_SAFE( m_pUpdatesNegList, entry, tmp ) + { + if(entry->priority >= nMinPriority) + { + entry->paused = true; + idsWithSelectors->addObject(entry->target); + } + } + } + + if(nMinPriority <= 0) + { + DL_FOREACH_SAFE( m_pUpdates0List, entry, tmp ) + { + entry->paused = true; + idsWithSelectors->addObject(entry->target); + } + } + + DL_FOREACH_SAFE( m_pUpdatesPosList, entry, tmp ) + { + if(entry->priority >= nMinPriority) + { + entry->paused = true; + idsWithSelectors->addObject(entry->target); + } + } + + return idsWithSelectors; +} + +void CCScheduler::resumeTargets(CCSet* pTargetsToResume) +{ + CCSetIterator iter; for (iter = pTargetsToResume->begin(); iter != pTargetsToResume->end(); ++iter) { resumeTarget(*iter); - } + } } // main loop diff --git a/cocos2dx/CCScheduler.h b/cocos2dx/CCScheduler.h index 5ae548f980..c41487b4ad 100644 --- a/cocos2dx/CCScheduler.h +++ b/cocos2dx/CCScheduler.h @@ -176,10 +176,10 @@ public: */ void unscheduleAllSelectors(void); - /** Unschedules all selectors from all targets with a minimum priority. - You should only call this with kCCPriorityNonSystemMin or higher. - @since v2.0.0 - */ + /** Unschedules all selectors from all targets with a minimum priority. + You should only call this with kCCPriorityNonSystemMin or higher. + @since v2.0.0 + */ void unscheduleAllSelectorsWithMinPriority(int nMinPriority); /** The scheduled script callback will be called every 'interval' seconds. @@ -211,22 +211,22 @@ public: */ bool isTargetPaused(CCObject *pTarget); - /** Pause all selectors from all targets. - You should NEVER call this method, unless you know what you are doing. - @since v2.0.0 - */ - CCSet* pauseAllTargets(); - - /** Pause all selectors from all targets with a minimum priority. - You should only call this with kCCPriorityNonSystemMin or higher. - @since v2.0.0 - */ - CCSet* pauseAllTargetsWithMinPriority(int nMinPriority); - - /** Resume selectors on a set of targets. - This can be useful for undoing a call to pauseAllSelectors. - @since v2.0.0 - */ + /** Pause all selectors from all targets. + You should NEVER call this method, unless you know what you are doing. + @since v2.0.0 + */ + CCSet* pauseAllTargets(); + + /** Pause all selectors from all targets with a minimum priority. + You should only call this with kCCPriorityNonSystemMin or higher. + @since v2.0.0 + */ + CCSet* pauseAllTargetsWithMinPriority(int nMinPriority); + + /** Resume selectors on a set of targets. + This can be useful for undoing a call to pauseAllSelectors. + @since v2.0.0 + */ void resumeTargets(CCSet* targetsToResume); private: diff --git a/cocos2dx/cocoa/CCArray.cpp b/cocos2dx/cocoa/CCArray.cpp index 63ffff4f86..204da85f0e 100644 --- a/cocos2dx/cocoa/CCArray.cpp +++ b/cocos2dx/cocoa/CCArray.cpp @@ -253,16 +253,16 @@ bool CCArray::containsObject(CCObject* object) return ccArrayContainsObject(data, object); } -bool CCArray::isEqualToArray(CCArray* otherArray) -{ - for (unsigned int i = 0; i< this->count(); i++) - { - if (!this->objectAtIndex(i)->isEqual(otherArray->objectAtIndex(i))) - { - return false; - } - } - return true; +bool CCArray::isEqualToArray(CCArray* otherArray) +{ + for (unsigned int i = 0; i< this->count(); i++) + { + if (!this->objectAtIndex(i)->isEqual(otherArray->objectAtIndex(i))) + { + return false; + } + } + return true; } void CCArray::addObject(CCObject* object) @@ -338,10 +338,10 @@ void CCArray::exchangeObjectAtIndex(unsigned int index1, unsigned int index2) ccArraySwapObjectsAtIndexes(data, index1, index2); } -void CCArray::replaceObjectAtIndex(unsigned int index, CCObject* pObject, bool bReleaseObject/* = true*/) -{ - ccArrayInsertObjectAtIndex(data, pObject, index); - ccArrayRemoveObjectAtIndex(data, index+1); +void CCArray::replaceObjectAtIndex(unsigned int index, CCObject* pObject, bool bReleaseObject/* = true*/) +{ + ccArrayInsertObjectAtIndex(data, pObject, index); + ccArrayRemoveObjectAtIndex(data, index+1); } void CCArray::reverseObjects() diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index 500cd82585..71dd1129ae 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -160,7 +160,7 @@ public: CCObject* randomObject(); /** Returns a Boolean value that indicates whether object is present in array. */ bool containsObject(CCObject* object); - /** @since 1.1 */ + /** @since 1.1 */ bool isEqualToArray(CCArray* pOtherArray); // Adding Objects diff --git a/cocos2dx/misc_nodes/CCMotionStreak.cpp b/cocos2dx/misc_nodes/CCMotionStreak.cpp index 94c5b9ae27..32dd1f7025 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.cpp +++ b/cocos2dx/misc_nodes/CCMotionStreak.cpp @@ -319,15 +319,15 @@ void CCMotionStreak::update(float delta) ccVertexLineToPolygon(m_pPointVertexes, m_fStroke, m_pVertices, 0, m_uNuPoints); } - // Updated Tex Coords only if they are different than previous step - if( m_uNuPoints && m_uPreviousNuPoints != m_uNuPoints ) { - float texDelta = 1.0f / m_uNuPoints; - for( i=0; i < m_uNuPoints; i++ ) { - m_pTexCoords[i*2] = tex2(0, texDelta*i); - m_pTexCoords[i*2+1] = tex2(1, texDelta*i); - } - - m_uPreviousNuPoints = m_uNuPoints; + // Updated Tex Coords only if they are different than previous step + if( m_uNuPoints && m_uPreviousNuPoints != m_uNuPoints ) { + float texDelta = 1.0f / m_uNuPoints; + for( i=0; i < m_uNuPoints; i++ ) { + m_pTexCoords[i*2] = tex2(0, texDelta*i); + m_pTexCoords[i*2+1] = tex2(1, texDelta*i); + } + + m_uPreviousNuPoints = m_uNuPoints; } } diff --git a/cocos2dx/misc_nodes/CCRenderTexture.h b/cocos2dx/misc_nodes/CCRenderTexture.h index b04b0832b1..a68d3443f3 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.h +++ b/cocos2dx/misc_nodes/CCRenderTexture.h @@ -59,7 +59,7 @@ public: CCRenderTexture(); virtual ~CCRenderTexture(); - /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format*/ + /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format*/ static CCRenderTexture * renderTextureWithWidthAndHeight(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat); /** creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid */ @@ -71,7 +71,7 @@ public: /** initializes a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid */ bool initWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat); - /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format*/ + /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format*/ bool initWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat); /** starts grabbing */ @@ -81,12 +81,12 @@ public: This is more efficient then calling -clear first and then -begin */ void beginWithClear(float r, float g, float b, float a); - /** starts rendering to the texture while clearing the texture first. - This is more efficient then calling -clear first and then -begin */ - void beginWithClear(float r, float g, float b, float a, float depthValue); - - /** starts rendering to the texture while clearing the texture first. - This is more efficient then calling -clear first and then -begin */ + /** starts rendering to the texture while clearing the texture first. + This is more efficient then calling -clear first and then -begin */ + void beginWithClear(float r, float g, float b, float a, float depthValue); + + /** starts rendering to the texture while clearing the texture first. + This is more efficient then calling -clear first and then -begin */ void beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue); /** end is key word of lua, use other name to export to lua. */ @@ -99,10 +99,10 @@ public: /** clears the texture with a color */ void clear(float r, float g, float b, float a); - /** clears the texture with a specified depth value */ - void clearDepth(float depthValue); - - /** clears the texture with a specified stencil value */ + /** clears the texture with a specified depth value */ + void clearDepth(float depthValue); + + /** clears the texture with a specified stencil value */ void clearStencil(int stencilValue); /* creates a new CCImage from with the texture's data. Caller is responsible for releasing it by calling delete. @@ -130,4 +130,4 @@ protected: NS_CC_END -#endif //__CCRENDER_TEXTURE_H__ \ No newline at end of file +#endif //__CCRENDER_TEXTURE_H__ diff --git a/cocos2dx/particle_nodes/CCParticleSystem.h b/cocos2dx/particle_nodes/CCParticleSystem.h index 60073ffafa..26b4ea1efe 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.h +++ b/cocos2dx/particle_nodes/CCParticleSystem.h @@ -324,8 +324,8 @@ public: CC_PROPERTY(CCTexture2D*, m_pTexture, Texture) /** conforms to CocosNodeTexture protocol */ CC_PROPERTY(ccBlendFunc, m_tBlendFunc, BlendFunc) - /** does the alpha value modify color */ - CC_PROPERTY(bool, m_bOpacityModifyRGB, OpacityModifyRGB) + /** does the alpha value modify color */ + CC_PROPERTY(bool, m_bOpacityModifyRGB, OpacityModifyRGB) /** whether or not the particles are using blend additive. If enabled, the following blending function will be used. diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp index 62c31058b4..144a93f4dc 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp @@ -236,8 +236,8 @@ void CCParticleSystemQuad::updateQuadWithParticle(tCCParticle* particle, const C { quad = &(m_pQuads[m_uParticleIdx]); } - ccColor4B color = (m_bOpacityModifyRGB) - ? ccc4( particle->color.r*particle->color.a*255, particle->color.g*particle->color.a*255, particle->color.b*particle->color.a*255, particle->color.a*255) + ccColor4B color = (m_bOpacityModifyRGB) + ? ccc4( particle->color.r*particle->color.a*255, particle->color.g*particle->color.a*255, particle->color.b*particle->color.a*255, particle->color.a*255) : ccc4( particle->color.r*255, particle->color.g*255, particle->color.b*255, particle->color.a*255); quad->bl.colors = color; diff --git a/cocos2dx/textures/CCTexture2D.h b/cocos2dx/textures/CCTexture2D.h index 1e5aea7c62..523a6cfa4a 100644 --- a/cocos2dx/textures/CCTexture2D.h +++ b/cocos2dx/textures/CCTexture2D.h @@ -195,15 +195,15 @@ public: */ unsigned int bitsPerPixelForFormat(); - /** returns the pixel format in a NSString. - @since v2.0 - */ - CCString* stringForFormat(); - - - /** Helper functions that returns bits per pixels for a given format. - @since v2.0 - */ + /** returns the pixel format in a NSString. + @since v2.0 + */ + CCString* stringForFormat(); + + + /** Helper functions that returns bits per pixels for a given format. + @since v2.0 + */ unsigned int bitsPerPixelForFormat(CCTexture2DPixelFormat format); /** sets the default pixel format for UIImagescontains alpha channel. @@ -217,8 +217,8 @@ public: How does it work ? - If the image is an RGBA (with Alpha) then the default pixel format will be used (it can be a 8-bit, 16-bit or 32-bit texture) - - If the image is an RGB (without Alpha) then: If the default pixel format is RGBA8888 then a RGBA8888 (32-bit) will be used. Otherwise a RGB565 (16-bit texture) will be used. - + - If the image is an RGB (without Alpha) then: If the default pixel format is RGBA8888 then a RGBA8888 (32-bit) will be used. Otherwise a RGB565 (16-bit texture) will be used. + This parameter is not valid for PVR / PVR.CCZ images. @since v0.8 diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp index 3482411195..fc32d7455f 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp @@ -236,52 +236,52 @@ void CCTMXLayer::setupTileSprite(CCSprite* sprite, CCPoint pos, unsigned int gid sprite->setOpacity(m_cOpacity); //issue 1264, flip can be undone as well - sprite->setFlipX(false); - sprite->setFlipX(false); - sprite->setRotation(0.0f); - sprite->setAnchorPoint(ccp(0,0)); - - // Rotation in tiled is achieved using 3 flipped states, flipping across the horizontal, vertical, and diagonal axes of the tiles. - if (gid & kCCTMXTileDiagonalFlag) - { - // put the anchor in the middle for ease of rotation. - sprite->setAnchorPoint(ccp(0.5f,0.5f)); - sprite->setPosition(ccp(positionAt(pos).x + sprite->getContentSize().height/2, - positionAt(pos).y + sprite->getContentSize().width/2 ) ); - - unsigned int flag = gid & (kCCTMXTileHorizontalFlag | kCCTMXTileVerticalFlag ); - - // handle the 4 diagonally flipped states. - if (flag == kCCTMXTileHorizontalFlag) - { - sprite->setRotation(90.0f); - } - else if (flag == kCCTMXTileVerticalFlag) - { - sprite->setRotation(270.0f); - } - else if (flag == (kCCTMXTileVerticalFlag | kCCTMXTileHorizontalFlag) ) - { - sprite->setRotation(90.0f); - sprite->setFlipX(true); - } - else - { - sprite->setRotation(270.0f); - sprite->setFlipX(true); - } - } - else - { - if (gid & kCCTMXTileHorizontalFlag) - { - sprite->setFlipX(true); - } - - if (gid & kCCTMXTileVerticalFlag) - { - sprite->setFlipY(true); - } + sprite->setFlipX(false); + sprite->setFlipX(false); + sprite->setRotation(0.0f); + sprite->setAnchorPoint(ccp(0,0)); + + // Rotation in tiled is achieved using 3 flipped states, flipping across the horizontal, vertical, and diagonal axes of the tiles. + if (gid & kCCTMXTileDiagonalFlag) + { + // put the anchor in the middle for ease of rotation. + sprite->setAnchorPoint(ccp(0.5f,0.5f)); + sprite->setPosition(ccp(positionAt(pos).x + sprite->getContentSize().height/2, + positionAt(pos).y + sprite->getContentSize().width/2 ) ); + + unsigned int flag = gid & (kCCTMXTileHorizontalFlag | kCCTMXTileVerticalFlag ); + + // handle the 4 diagonally flipped states. + if (flag == kCCTMXTileHorizontalFlag) + { + sprite->setRotation(90.0f); + } + else if (flag == kCCTMXTileVerticalFlag) + { + sprite->setRotation(270.0f); + } + else if (flag == (kCCTMXTileVerticalFlag | kCCTMXTileHorizontalFlag) ) + { + sprite->setRotation(90.0f); + sprite->setFlipX(true); + } + else + { + sprite->setRotation(270.0f); + sprite->setFlipX(true); + } + } + else + { + if (gid & kCCTMXTileHorizontalFlag) + { + sprite->setFlipX(true); + } + + if (gid & kCCTMXTileVerticalFlag) + { + sprite->setFlipY(true); + } } } From de95e2c1ed160b72cfbd8c07045fa377163d46f9 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 13 Jun 2012 14:33:39 -0700 Subject: [PATCH 151/257] Applied changes/fixes brough up by minggo. --- cocos2dx/extensions/CCBReader/CCBReader.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cocos2dx/extensions/CCBReader/CCBReader.cpp b/cocos2dx/extensions/CCBReader/CCBReader.cpp index 263c7d4de5..0daf2b4d52 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader.cpp @@ -49,9 +49,7 @@ CCBReader::~CCBReader() { this->mLoadedSpriteSheets.clear(); } - if(this->mRootNode != NULL) { - this->mRootNode->release(); - } + CC_SAFE_RELEASE(this->mRootNode); } CCBReader::CCBReader(CCBReader * pCCBReader) { @@ -99,7 +97,7 @@ CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBRootPath, const char const char * path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(ccbFullFilePath); unsigned long size = 0; - this->mBytes = CCFileUtils::sharedFileUtils()->getFileData(path, "r", &size); + this->mBytes = CCFileUtils::sharedFileUtils()->getFileData(path, "rb", &size); this->mCurrentByte = 0; this->mCurrentBit = 0; @@ -127,7 +125,7 @@ bool CCBReader::readHeader() { int magicBytes = *((int*)(this->mBytes + this->mCurrentByte)); this->mCurrentByte += 4; - if(magicBytes != 'ccbi') { + if(CC_SWAP_INT32_LITTLE_TO_HOST(magicBytes) != 'ccbi') { return false; } From 3e61e1f0147d0c476918cc0f4af8eeab067d797b Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 13 Jun 2012 15:25:59 -0700 Subject: [PATCH 152/257] Updated Android build files to new CCBReader. Fixed a bunch of compiler errors/warnings when building for Android. --- cocos2dx/Android.mk | 17 +++++++++++++++-- cocos2dx/extensions/CCBReader/CCBReader.cpp | 2 ++ ...ageLoader .cpp => CCMenuItemImageLoader.cpp} | 0 cocos2dx/extensions/CCBReader/CCNodeLoader.cpp | 12 ++++++------ tests/Android.mk | 7 ++++++- .../project.pbxproj.REMOVED.git-id | 2 +- .../CocosBuilderTest/ButtonTestLayer.h | 4 ++-- .../CocosBuilderTest/ButtonTestLayerLoader.h | 2 +- .../CocosBuilderTest/HelloCocosBuilderLayer.h | 8 ++++---- .../HelloCocosBuilderLayerLoader.h | 2 +- .../CocosBuilderTest/TestHeaderLayer.h | 4 ++-- .../CocosBuilderTest/TestHeaderLayerLoader.h | 2 +- 12 files changed, 41 insertions(+), 21 deletions(-) rename cocos2dx/extensions/CCBReader/{CCMenuItemImageLoader .cpp => CCMenuItemImageLoader.cpp} (100%) diff --git a/cocos2dx/Android.mk b/cocos2dx/Android.mk index f73df4fca2..074225e43a 100644 --- a/cocos2dx/Android.mk +++ b/cocos2dx/Android.mk @@ -56,8 +56,21 @@ extensions/CCControlExtension/CCSpacer.cpp \ extensions/CCListView/CCListView.cpp \ extensions/CCListView/CCListViewCell.cpp \ extensions/CCTextureWatcher/CCTextureWatcher.cpp \ -extensions/CCBReader/CCBCustomClass.cpp \ -extensions/CCBReader/CCBReader_v2.cpp \ +extensions/CCBReader/CCBFileLoader.cpp \ +extensions/CCBReader/CCBReader.cpp \ +extensions/CCBReader/CCNodeLoaderLibrary.cpp \ +extensions/CCBReader/CCNodeLoader.cpp \ +extensions/CCBReader/CCControlButtonLoader.cpp \ +extensions/CCBReader/CCControlLoader.cpp \ +extensions/CCBReader/CCLabelBMFontLoader.cpp \ +extensions/CCBReader/CCLabelTTFLoader.cpp \ +extensions/CCBReader/CCLayerColorLoader.cpp \ +extensions/CCBReader/CCLayerGradientLoader.cpp \ +extensions/CCBReader/CCMenuLoader.cpp \ +extensions/CCBReader/CCMenuItemLoader.cpp \ +extensions/CCBReader/CCMenuItemImageLoader.cpp \ +extensions/CCBReader/CCSpriteLoader.cpp \ +extensions/CCBReader/CCScale9SpriteLoader.cpp \ kazmath/src/aabb.c \ kazmath/src/mat3.c \ kazmath/src/mat4.c \ diff --git a/cocos2dx/extensions/CCBReader/CCBReader.cpp b/cocos2dx/extensions/CCBReader/CCBReader.cpp index 0daf2b4d52..7f8ce3a891 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader.cpp @@ -1,5 +1,7 @@ #include "CCBReader.h" +#include + #include "CCNodeLoader.h" #include "CCNodeLoaderLibrary.h" #include "CCNodeLoaderListener.h" diff --git a/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader .cpp b/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.cpp similarity index 100% rename from cocos2dx/extensions/CCBReader/CCMenuItemImageLoader .cpp rename to cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.cpp diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp index 5833315f95..98220ee25f 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp @@ -562,21 +562,21 @@ BlockData * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, C if(target != NULL) { if(strlen(selectorName) > 0) { - SEL_MenuHandler selMenuHandler = NULL; + SEL_MenuHandler selMenuHandler = 0; CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast(target); if(targetAsCCBSelectorResolver != NULL) { selMenuHandler = targetAsCCBSelectorResolver->onResolveCCBCCMenuSelector(target, selectorName); } - if(selMenuHandler == NULL) { + if(selMenuHandler == 0) { CCBSelectorResolver * ccbSelectorResolver = pCCBReader->getCCBSelectorResolver(); if(ccbSelectorResolver != NULL) { selMenuHandler = ccbSelectorResolver->onResolveCCBCCMenuSelector(target, selectorName); } } - if(selMenuHandler == NULL) { + if(selMenuHandler == 0) { CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName); } else { BlockData * blockData = new BlockData(); @@ -612,21 +612,21 @@ BlockCCControlData * CCNodeLoader::parsePropTypeBlockCCControl(CCNode * pNode, C if(target != NULL) { if(strlen(selectorName) > 0) { - SEL_CCControlHandler selCCControlHandler = NULL; + SEL_CCControlHandler selCCControlHandler = 0; CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast(target); if(targetAsCCBSelectorResolver != NULL) { selCCControlHandler = targetAsCCBSelectorResolver->onResolveCCBCCControlSelector(target, selectorName); } - if(selCCControlHandler == NULL) { + if(selCCControlHandler == 0) { CCBSelectorResolver * ccbSelectorResolver = pCCBReader->getCCBSelectorResolver(); if(ccbSelectorResolver != NULL) { selCCControlHandler = ccbSelectorResolver->onResolveCCBCCControlSelector(target, selectorName); } } - if(selCCControlHandler == NULL) { + if(selCCControlHandler == 0) { CCLOG("Skipping selector '%s' since no CCBSelectorResolver is present.", selectorName); } else { BlockCCControlData * blockCCControlData = new BlockCCControlData(); diff --git a/tests/Android.mk b/tests/Android.mk index 1589dd0532..393311ea6a 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -46,7 +46,12 @@ tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourP tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp \ tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp \ tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp \ -tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder.cpp \ +tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.cpp \ +tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayerLoader.cpp \ +tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.cpp \ +tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayerLoader.cpp \ +tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.cpp \ +tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayerLoader.cpp \ tests/FontTest/FontTest.cpp \ tests/HiResTest/HiResTest.cpp \ tests/IntervalTest/IntervalTest.cpp \ diff --git a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id index 81bb3edcb7..49e02baeae 100644 --- a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -650424fef741f04e23213a3ccadc8620df8fd9f1 \ No newline at end of file +95c2001184db68b9c04178193c80a7d8eb3d32bd \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.h index 76de9a9b2c..a65497e799 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.h @@ -2,8 +2,8 @@ #define _BUTTONTESTLAYER_H_ #include "cocos2d.h" -#include "CCNodeLoader.h" -#include "CCBSelectorResolver.h" +#include "extensions/CCBReader/CCNodeLoader.h" +#include "extensions/CCBReader/CCBSelectorResolver.h" class ButtonTestLayer : public cocos2d::extension::CCBSelectorResolver, public cocos2d::CCLayer { public: diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayerLoader.h b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayerLoader.h index 714f14f40d..bacacbfc8b 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayerLoader.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayerLoader.h @@ -1,7 +1,7 @@ #ifndef _BUTTONTESTLAYERLOADER_H_ #define _BUTTONTESTLAYERLOADER_H_ -#include "CCLayerLoader.h" +#include "extensions/CCBReader/CCLayerLoader.h" #include "ButtonTestLayer.h" /* Forward declaration. */ diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.h index 51b2432b79..1332a520a9 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.h @@ -2,10 +2,10 @@ #define _HELLOCOCOSBUILDERLAYER_H_ #include "cocos2d.h" -#include "CCNodeLoader.h" -#include "CCNodeLoaderListener.h" -#include "CCBSelectorResolver.h" -#include "CCBMemberVariableAssigner.h" +#include "extensions/CCBReader/CCNodeLoader.h" +#include "extensions/CCBReader/CCNodeLoaderListener.h" +#include "extensions/CCBReader/CCBSelectorResolver.h" +#include "extensions/CCBReader/CCBMemberVariableAssigner.h" /* * Note: for some pretty hard fucked up reason, the order of inheritance is important! diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayerLoader.h b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayerLoader.h index 899ab648cc..2795d04740 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayerLoader.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayerLoader.h @@ -1,7 +1,7 @@ #ifndef _HELLOCOCOSBUILDERLAYERLOADER_H_ #define _HELLOCOCOSBUILDERLAYERLOADER_H_ -#include "CCLayerLoader.h" +#include "extensions/CCBReader/CCLayerLoader.h" #include "HelloCocosBuilderLayer.h" /* Forward declaration. */ diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.h index 9a978ca03d..3b04f2ea4e 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.h @@ -2,8 +2,8 @@ #define _TESTHEADERLAYER_H_ #include "cocos2d.h" -#include "CCNodeLoader.h" -#include "CCBSelectorResolver.h" +#include "extensions/CCBReader/CCNodeLoader.h" +#include "extensions/CCBReader/CCBSelectorResolver.h" class TestHeaderLayer : public cocos2d::extension::CCBSelectorResolver, public cocos2d::CCLayer { public: diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayerLoader.h b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayerLoader.h index 63aa2c7bac..37e4cc3ee2 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayerLoader.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayerLoader.h @@ -1,7 +1,7 @@ #ifndef _TESTHEADERLAYERLOADER_H_ #define _TESTHEADERLAYERLOADER_H_ -#include "CCLayerLoader.h" +#include "extensions/CCBReader/CCLayerLoader.h" #include "TestHeaderLayer.h" /* Forward declaration. */ From 67ab3a1bccd38eea327d30950bf08b642cb9df0b Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 13 Jun 2012 15:57:33 -0700 Subject: [PATCH 153/257] CCSpriteLoader: Fixed a bug calling the wrong superclass method. --- cocos2dx/extensions/CCBReader/CCSpriteLoader.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/extensions/CCBReader/CCSpriteLoader.cpp b/cocos2dx/extensions/CCBReader/CCSpriteLoader.cpp index d5370289e3..578160bd0a 100644 --- a/cocos2dx/extensions/CCBReader/CCSpriteLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCSpriteLoader.cpp @@ -26,7 +26,7 @@ void CCSpriteLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, cons ((CCSprite *)pNode)->setFlipX(pFlip[0]); ((CCSprite *)pNode)->setFlipX(pFlip[1]); } else { - CCNodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pFlip, pCCBReader); + CCNodeLoader::onHandlePropTypeFlip(pNode, pParent, pPropertyName, pFlip, pCCBReader); } } From d4a19f4296ab1d8ee3c475ebb26c62b028b9b2f9 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 13 Jun 2012 15:57:59 -0700 Subject: [PATCH 154/257] CCNodeLoader.h: Added parameter names. --- cocos2dx/extensions/CCBReader/CCLayerLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCNodeLoader.h | 114 +++++++++--------- 2 files changed, 58 insertions(+), 58 deletions(-) diff --git a/cocos2dx/extensions/CCBReader/CCLayerLoader.h b/cocos2dx/extensions/CCBReader/CCLayerLoader.h index 08d56204de..b0277fa95b 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLayerLoader.h @@ -15,7 +15,7 @@ class CCLayerLoader : public CCNodeLoader { protected: virtual CCLayer * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool, CCBReader *); + virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoader.h b/cocos2dx/extensions/CCBReader/CCNodeLoader.h index e7aea9f235..2d70a5afaf 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoader.h +++ b/cocos2dx/extensions/CCBReader/CCNodeLoader.h @@ -24,68 +24,68 @@ class CC_DLL CCNodeLoader : public CCObject { public: STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCNodeLoader, loader); - virtual CCNode * loadCCNode(CCNode *, CCBReader *); - virtual void parseProperties(CCNode *, CCNode *, CCBReader *); + virtual CCNode * loadCCNode(CCNode *, CCBReader * pCCBReader); + virtual void parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); protected: - virtual CCNode * createCCNode(CCNode *, CCBReader *); + virtual CCNode * createCCNode(CCNode * pParent, CCBReader * pCCBReader); - virtual CCPoint parsePropTypePosition(CCNode *, CCNode *, CCBReader *); - virtual CCPoint parsePropTypePoint(CCNode *, CCNode *, CCBReader *); - virtual CCPoint parsePropTypePointLock(CCNode *, CCNode *, CCBReader *); - virtual CCSize parsePropTypeSize(CCNode *, CCNode *, CCBReader *); - virtual float * parsePropTypeScaleLock(CCNode *, CCNode *, CCBReader *); - virtual float parsePropTypeFloat(CCNode *, CCNode *, CCBReader *); - virtual float parsePropTypeDegrees(CCNode *, CCNode *, CCBReader *); - virtual float parsePropTypeFloatScale(CCNode *, CCNode *, CCBReader *); - virtual int parsePropTypeInteger(CCNode *, CCNode *, CCBReader *); - virtual int parsePropTypeIntegerLabeled(CCNode *, CCNode *, CCBReader *); - virtual float * parsePropTypeFloatVar(CCNode *, CCNode *, CCBReader *); - virtual bool parsePropTypeCheck(CCNode *, CCNode *, CCBReader *); - virtual CCSpriteFrame * parsePropTypeSpriteFrame(CCNode *, CCNode *, CCBReader *); - virtual CCAnimation * parsePropTypeAnimation(CCNode *, CCNode *, CCBReader *); - virtual CCTexture2D * parsePropTypeTexture(CCNode *, CCNode *, CCBReader *); - virtual unsigned char parsePropTypeByte(CCNode *, CCNode *, CCBReader *); - virtual ccColor3B parsePropTypeColor3(CCNode *, CCNode *, CCBReader *); - virtual ccColor4F * parsePropTypeColor4FVar(CCNode *, CCNode *, CCBReader *); - virtual bool * parsePropTypeFlip(CCNode *, CCNode *, CCBReader *); - virtual ccBlendFunc parsePropTypeBlendFunc(CCNode *, CCNode *, CCBReader *); - virtual const char * parsePropTypeFntFile(CCNode *, CCNode *, CCBReader *); - virtual const char * parsePropTypeString(CCNode *, CCNode *, CCBReader *); - virtual const char * parsePropTypeText(CCNode *, CCNode *, CCBReader *); - virtual const char * parsePropTypeFontTTF(CCNode *, CCNode *, CCBReader *); - virtual BlockData * parsePropTypeBlock(CCNode *, CCNode *, CCBReader *); - virtual BlockCCControlData * parsePropTypeBlockCCControl(CCNode *, CCNode *, CCBReader *); - virtual CCNode * parsePropTypeCCBFile(CCNode *, CCNode *, CCBReader *); + virtual CCPoint parsePropTypePosition(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual CCPoint parsePropTypePoint(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual CCPoint parsePropTypePointLock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual CCSize parsePropTypeSize(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual float * parsePropTypeScaleLock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual float parsePropTypeFloat(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual float parsePropTypeDegrees(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual float parsePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual int parsePropTypeInteger(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual int parsePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual float * parsePropTypeFloatVar(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual bool parsePropTypeCheck(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual CCSpriteFrame * parsePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual CCAnimation * parsePropTypeAnimation(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual CCTexture2D * parsePropTypeTexture(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual unsigned char parsePropTypeByte(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual ccColor3B parsePropTypeColor3(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual ccColor4F * parsePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual bool * parsePropTypeFlip(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual ccBlendFunc parsePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual const char * parsePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual const char * parsePropTypeString(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual const char * parsePropTypeText(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual const char * parsePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual BlockData * parsePropTypeBlock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual BlockCCControlData * parsePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual CCNode * parsePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); - virtual void onHandlePropTypePosition(CCNode *, CCNode *, const char *, CCPoint, CCBReader *); - virtual void onHandlePropTypePoint(CCNode *, CCNode *, const char *, CCPoint, CCBReader *); - virtual void onHandlePropTypePointLock(CCNode *, CCNode *, const char *, CCPoint, CCBReader *); - virtual void onHandlePropTypeSize(CCNode *, CCNode *, const char *, CCSize, CCBReader *); - virtual void onHandlePropTypeScaleLock(CCNode *, CCNode *, const char *, float *, CCBReader *); - virtual void onHandlePropTypeFloat(CCNode *, CCNode *, const char *, float, CCBReader *); - virtual void onHandlePropTypeDegrees(CCNode *, CCNode *, const char *, float, CCBReader *); - virtual void onHandlePropTypeFloatScale(CCNode *, CCNode *, const char *, float, CCBReader *); - virtual void onHandlePropTypeInteger(CCNode *, CCNode *, const char *, int, CCBReader *); - virtual void onHandlePropTypeIntegerLabeled(CCNode *, CCNode *, const char *, int, CCBReader *); - virtual void onHandlePropTypeFloatVar(CCNode *, CCNode *, const char *, float *, CCBReader *); - virtual void onHandlePropTypeCheck(CCNode *, CCNode *, const char *, bool, CCBReader *); - virtual void onHandlePropTypeSpriteFrame(CCNode *, CCNode *, const char *, CCSpriteFrame *, CCBReader *); - virtual void onHandlePropTypeAnimation(CCNode *, CCNode *, const char *, CCAnimation *, CCBReader *); - virtual void onHandlePropTypeTexture(CCNode *, CCNode *, const char *, CCTexture2D *, CCBReader *); - virtual void onHandlePropTypeByte(CCNode *, CCNode *, const char *, unsigned char, CCBReader *); - virtual void onHandlePropTypeColor3(CCNode *, CCNode *, const char *, ccColor3B, CCBReader *); - virtual void onHandlePropTypeColor4FVar(CCNode *, CCNode *, const char *, ccColor4F *, CCBReader *); - virtual void onHandlePropTypeFlip(CCNode *, CCNode *, const char *, bool *, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode *, CCNode *, const char *, ccBlendFunc, CCBReader *); - virtual void onHandlePropTypeFntFile(CCNode *, CCNode *, const char *, const char *, CCBReader *); - virtual void onHandlePropTypeString(CCNode *, CCNode *, const char *, const char *, CCBReader *); - virtual void onHandlePropTypeText(CCNode *, CCNode *, const char *, const char *, CCBReader *); - virtual void onHandlePropTypeFontTTF(CCNode *, CCNode *, const char *, const char *, CCBReader *); - virtual void onHandlePropTypeBlock(CCNode *, CCNode *, const char *, BlockData *, CCBReader *); - virtual void onHandlePropTypeBlockCCControl(CCNode *, CCNode *, const char *, BlockCCControlData *, CCBReader *); - virtual void onHandlePropTypeCCBFile(CCNode *, CCNode *, const char *, CCNode *, CCBReader *); + virtual void onHandlePropTypePosition(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPosition, CCBReader * pCCBReader); + virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader); + virtual void onHandlePropTypePointLock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPointLock, CCBReader * pCCBReader); + virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize pSize, CCBReader * pCCBReader); + virtual void onHandlePropTypeScaleLock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float * pScaleLock, CCBReader * pCCBReader); + virtual void onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloat, CCBReader * pCCBReader); + virtual void onHandlePropTypeDegrees(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pDegrees, CCBReader * pCCBReader); + virtual void onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloatScale, CCBReader * pCCBReader); + virtual void onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pInteger, CCBReader * pCCBReader); + virtual void onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader); + virtual void onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float * pFoatVar, CCBReader * pCCBReader); + virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader); + virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader); + virtual void onHandlePropTypeAnimation(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCAnimation * pCCAnimation, CCBReader * pCCBReader); + virtual void onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader); + virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader); + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader); + virtual void onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader); + virtual void onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool * pFlip, CCBReader * pCCBReader); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader); + virtual void onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pFntFile, CCBReader * pCCBReader); + virtual void onHandlePropTypeString(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pString, CCBReader * pCCBReader); + virtual void onHandlePropTypeText(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pText, CCBReader * pCCBReader); + virtual void onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * pCCBReader); + virtual void onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader); + virtual void onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader); + virtual void onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader); }; NS_CC_EXT_END From 0c4a6be8ff3fdcd714d0af6ac29d813b79ef4015 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 13 Jun 2012 16:05:31 -0700 Subject: [PATCH 155/257] Added missiong cpp files in Android.mk. Android build now successful. --- cocos2dx/Android.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos2dx/Android.mk b/cocos2dx/Android.mk index 2a5dae4f11..2dc6c2412e 100644 --- a/cocos2dx/Android.mk +++ b/cocos2dx/Android.mk @@ -65,6 +65,7 @@ extensions/CCBReader/CCControlButtonLoader.cpp \ extensions/CCBReader/CCControlLoader.cpp \ extensions/CCBReader/CCLabelBMFontLoader.cpp \ extensions/CCBReader/CCLabelTTFLoader.cpp \ +extensions/CCBReader/CCLayerLoader.cpp \ extensions/CCBReader/CCLayerColorLoader.cpp \ extensions/CCBReader/CCLayerGradientLoader.cpp \ extensions/CCBReader/CCMenuLoader.cpp \ @@ -72,6 +73,7 @@ extensions/CCBReader/CCMenuItemLoader.cpp \ extensions/CCBReader/CCMenuItemImageLoader.cpp \ extensions/CCBReader/CCSpriteLoader.cpp \ extensions/CCBReader/CCScale9SpriteLoader.cpp \ +extensions/CCBReader/CCParticleSystemQuadLoader.cpp \ kazmath/src/aabb.c \ kazmath/src/mat3.c \ kazmath/src/mat4.c \ From b3fb5e6d4cf2e267c3901f9c537fb0c862b77577 Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 14 Jun 2012 10:49:53 +0800 Subject: [PATCH 156/257] fixed #1293:rename getFrames to getTotalFrames and return correct value --- cocos2dx/CCDirector.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/CCDirector.h b/cocos2dx/CCDirector.h index a6ba20d728..ae1ba7f003 100644 --- a/cocos2dx/CCDirector.h +++ b/cocos2dx/CCDirector.h @@ -122,7 +122,7 @@ public: inline bool isPaused(void) { return m_bPaused; } /** How many frames were called since the director started */ - inline unsigned int getFrames(void) { return m_uFrames; } + inline unsigned int getTotalFrames(void) { return m_uTotalFrames; } /** Sets an OpenGL projection @since v0.8.2 From f742de1de35397a752d0dc2f84908ba9c811796f Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 14 Jun 2012 14:41:02 +0800 Subject: [PATCH 157/257] fixed #1257: make CCGrabber the same logic with iphone version --- cocos2dx/effects/CCGrabber.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/cocos2dx/effects/CCGrabber.cpp b/cocos2dx/effects/CCGrabber.cpp index 287be4617d..2e40da327f 100644 --- a/cocos2dx/effects/CCGrabber.cpp +++ b/cocos2dx/effects/CCGrabber.cpp @@ -70,15 +70,15 @@ void CCGrabber::beforeRender(CCTexture2D *pTexture) glGetFloatv(GL_COLOR_CLEAR_VALUE, m_oldClearColor); // BUG XXX: doesn't work with RGB565. - /*glClearColor(0, 0, 0, 0);*/ + glClearColor(0, 0, 0, 0); // BUG #631: To fix #631, uncomment the lines with #631 // Warning: But it CCGrabber won't work with 2 effects at the same time - glClearColor(0.0f,0.0f,0.0f,1.0f); // #631 +// glClearColor(0.0f,0.0f,0.0f,1.0f); // #631 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - glColorMask(true, true, true, false); // #631 +// glColorMask(true, true, true, false); // #631 } void CCGrabber::afterRender(cocos2d::CCTexture2D *pTexture) @@ -86,9 +86,10 @@ void CCGrabber::afterRender(cocos2d::CCTexture2D *pTexture) CC_UNUSED_PARAM(pTexture); glBindFramebuffer(GL_FRAMEBUFFER, m_oldFBO); - glColorMask(true, true, true, true); // #631 +// glColorMask(true, true, true, true); // #631 + // Restore clear color - glClearColor( m_oldClearColor[0], m_oldClearColor[1], m_oldClearColor[2], m_oldClearColor[3] ); + glClearColor(m_oldClearColor[0], m_oldClearColor[1], m_oldClearColor[2], m_oldClearColor[3]); } CCGrabber::~CCGrabber() From 8e67d3e2d63d8e9a3965abb425687302280d1155 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Wed, 13 Jun 2012 23:56:21 -0700 Subject: [PATCH 158/257] Enhanced CCString with two 'constructors' and a compare function. --- cocos2dx/cocoa/CCString.cpp | 30 ++++++++++++++++++++++++++++++ cocos2dx/cocoa/CCString.h | 17 ++++++++++++++++- 2 files changed, 46 insertions(+), 1 deletion(-) diff --git a/cocos2dx/cocoa/CCString.cpp b/cocos2dx/cocoa/CCString.cpp index bc3747c21b..8ec62ea27a 100644 --- a/cocos2dx/cocoa/CCString.cpp +++ b/cocos2dx/cocoa/CCString.cpp @@ -124,6 +124,11 @@ unsigned int CCString::length() const return m_sString.length(); } +int CCString::compare(const char * pStr) const +{ + return strcmp(getCString(), pStr); +} + CCObject* CCString::copyWithZone(CCZone* pZone) { CCAssert(pZone == NULL, "CCString should not be inherited."); @@ -152,6 +157,31 @@ CCString* CCString::stringWithCString(const char* pStr) return pRet; } +CCString* CCString::stringWithString(const std::string& pStr) +{ + CCString* pRet = new CCString(pStr); + pRet->autorelease(); + return pRet; +} + +CCString* CCString::stringWithCStringData(const char* pData, unsigned long nLen) +{ + CCString* pRet = NULL; + if (pData != NULL) + { + char* pStr = (char*)malloc(nLen+1); + if (pStr != NULL) + { + pStr[nLen] = '\0'; + memcpy(pStr, pData, nLen); + pRet = CCString::stringWithCString(pStr); + free(pStr); + } + } + return pRet; + +} + CCString* CCString::stringWithData(unsigned char* pData, unsigned long nLen) { CCString* pRet = NULL; diff --git a/cocos2dx/cocoa/CCString.h b/cocos2dx/cocoa/CCString.h index abb41043ca..7af1b44e8e 100644 --- a/cocos2dx/cocoa/CCString.h +++ b/cocos2dx/cocoa/CCString.h @@ -66,17 +66,32 @@ public: /** get the length of string */ unsigned int length() const; + /** compare to a c string */ + int compare(const char *) const; + /* override functions */ virtual CCObject* copyWithZone(CCZone* pZone); virtual bool isEqual(const CCObject* pObject); /* static funcitons */ - /** create a string with c string + /** create a string with c string * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. */ static CCString* stringWithCString(const char* pStr); + /** create a string with c string + * @return A CCString pointer which is an autorelease object pointer, + * it means that you needn't do a release operation unless you retain it. + */ + static CCString* stringWithCStringData(const char* pData, unsigned long nLen); + + /** create a string with std::string + * @return A CCString pointer which is an autorelease object pointer, + * it means that you needn't do a release operation unless you retain it. + */ + static CCString* stringWithString(const std::string& str); + /** create a string with format, it's similar with the c function 'sprintf', the default buffer size is (1024*100) bytes, * if you want to change it, you should modify the kMaxStringLen macro in CCString.cpp file. * @return A CCString pointer which is an autorelease object pointer, From cdd1fb50ac0a197d5e293a58beb46f09f4fc9690 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Thu, 14 Jun 2012 00:01:01 -0700 Subject: [PATCH 159/257] Moved from std::string to CCString *. Since the std::string utility methods in CCBReader were buggy on Android (for unknown reasons). Made string utility methods in CCBReader static. Android build now working equivalent to iOS build. *YAY* --- .../extensions/CCBReader/CCBFileLoader.cpp | 4 +- cocos2dx/extensions/CCBReader/CCBFileLoader.h | 2 +- .../CCBReader/CCBMemberVariableAssigner.h | 2 +- cocos2dx/extensions/CCBReader/CCBReader.cpp | 133 ++++++++------- cocos2dx/extensions/CCBReader/CCBReader.h | 29 ++-- .../CCBReader/CCBSelectorResolver.h | 4 +- .../CCBReader/CCControlButtonLoader.cpp | 70 ++++---- .../CCBReader/CCControlButtonLoader.h | 16 +- .../extensions/CCBReader/CCControlLoader.cpp | 10 +- .../extensions/CCBReader/CCControlLoader.h | 4 +- .../CCBReader/CCLabelBMFontLoader.cpp | 26 +-- .../CCBReader/CCLabelBMFontLoader.h | 10 +- .../extensions/CCBReader/CCLabelTTFLoader.cpp | 38 ++--- .../extensions/CCBReader/CCLabelTTFLoader.h | 16 +- .../CCBReader/CCLayerColorLoader.cpp | 12 +- .../extensions/CCBReader/CCLayerColorLoader.h | 6 +- .../CCBReader/CCLayerGradientLoader.cpp | 20 +-- .../CCBReader/CCLayerGradientLoader.h | 8 +- .../extensions/CCBReader/CCLayerLoader.cpp | 10 +- cocos2dx/extensions/CCBReader/CCLayerLoader.h | 2 +- .../CCBReader/CCMenuItemImageLoader.cpp | 8 +- .../CCBReader/CCMenuItemImageLoader.h | 2 +- .../extensions/CCBReader/CCMenuItemLoader.cpp | 8 +- .../extensions/CCBReader/CCMenuItemLoader.h | 4 +- .../extensions/CCBReader/CCNodeLoader.cpp | 158 +++++++++--------- cocos2dx/extensions/CCBReader/CCNodeLoader.h | 62 +++---- .../CCBReader/CCNodeLoaderLibrary.cpp | 8 +- .../CCBReader/CCNodeLoaderLibrary.h | 6 +- .../CCBReader/CCParticleSystemQuadLoader.cpp | 60 +++---- .../CCBReader/CCParticleSystemQuadLoader.h | 16 +- .../CCBReader/CCScale9SpriteLoader.cpp | 32 ++-- .../CCBReader/CCScale9SpriteLoader.h | 12 +- .../extensions/CCBReader/CCSpriteLoader.cpp | 20 +-- .../extensions/CCBReader/CCSpriteLoader.h | 10 +- .../project.pbxproj.REMOVED.git-id | 2 +- .../CocosBuilderTest/ButtonTestLayer.cpp | 8 +- .../CocosBuilderTest/ButtonTestLayer.h | 4 +- .../CocosBuilderTest/CocosBuilderTest.cpp | 2 + .../HelloCocosBuilderLayer.cpp | 34 ++-- .../CocosBuilderTest/HelloCocosBuilderLayer.h | 6 +- .../CocosBuilderTest/TestHeaderLayer.cpp | 6 +- .../CocosBuilderTest/TestHeaderLayer.h | 4 +- 42 files changed, 455 insertions(+), 439 deletions(-) diff --git a/cocos2dx/extensions/CCBReader/CCBFileLoader.cpp b/cocos2dx/extensions/CCBReader/CCBFileLoader.cpp index 6d5642f931..83504502e8 100644 --- a/cocos2dx/extensions/CCBReader/CCBFileLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCBFileLoader.cpp @@ -9,8 +9,8 @@ CCNode * CCBFileLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { return CCNode::node(); } -void CCBFileLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_CCBFILE) == 0) { +void CCBFileLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_CCBFILE) == 0) { pNode->addChild(pCCBFileNode); } else { CCNodeLoader::onHandlePropTypeCCBFile(pNode, pParent, pPropertyName, pCCBFileNode, pCCBReader); diff --git a/cocos2dx/extensions/CCBReader/CCBFileLoader.h b/cocos2dx/extensions/CCBReader/CCBFileLoader.h index 5e644d65d6..0fc5bc5f71 100644 --- a/cocos2dx/extensions/CCBReader/CCBFileLoader.h +++ b/cocos2dx/extensions/CCBReader/CCBFileLoader.h @@ -15,7 +15,7 @@ class CCBFileLoader : public CCNodeLoader { protected: virtual CCNode * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCNode *, CCBReader *); + virtual void onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCNode *, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h b/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h index 0ddc70f0bf..370a39ac42 100644 --- a/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h +++ b/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h @@ -7,7 +7,7 @@ NS_CC_EXT_BEGIN class CCBMemberVariableAssigner { public: - virtual bool onAssignCCBMemberVariable(CCObject * pTarget, const char * pMemberVariableName, CCNode * pNode) = 0; + virtual bool onAssignCCBMemberVariable(CCObject * pTarget, cocos2d::CCString * pMemberVariableName, CCNode * pNode) = 0; }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCBReader.cpp b/cocos2dx/extensions/CCBReader/CCBReader.cpp index 7f8ce3a891..ae644deaf3 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader.cpp @@ -35,25 +35,6 @@ CCBReader::CCBReader(CCNodeLoaderLibrary * pCCNodeLoaderLibrary, CCBMemberVariab #endif } -CCBReader::~CCBReader() { - if(this->mBytes != NULL) { - delete this->mBytes; - this->mBytes = NULL; - } - - this->mCCNodeLoaderLibrary->release(); - - /* Clear string cache. */ - this->mStringCache.clear(); - - if(this->mRootCCBReader) { - /* Clear loaded spritesheets. */ - this->mLoadedSpriteSheets.clear(); - } - - CC_SAFE_RELEASE(this->mRootNode); -} - CCBReader::CCBReader(CCBReader * pCCBReader) { this->mRootNode = NULL; this->mRootCCBReader = false; @@ -69,7 +50,25 @@ CCBReader::CCBReader(CCBReader * pCCBReader) { this->mCCNodeLoaderListener = pCCBReader->mCCNodeLoaderListener; } -std::string CCBReader::getCCBRootPath() { +CCBReader::~CCBReader() { + CC_SAFE_DELETE(this->mBytes); + + this->mCCNodeLoaderLibrary->release(); + + /* Clear string cache. */ + std::vector::iterator stringCacheIterator; + for (stringCacheIterator = this->mStringCache.begin(); stringCacheIterator != this->mStringCache.end(); stringCacheIterator++) { + (*stringCacheIterator)->release(); + } + this->mStringCache.clear(); + + if(this->mRootCCBReader) { + /* Clear loaded spritesheets. */ + this->mLoadedSpriteSheets.clear(); + } +} + +CCString * CCBReader::getCCBRootPath() { return this->mCCBRootPath; } @@ -89,32 +88,42 @@ CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBRootPath, const char return this->readNodeGraphFromFile(pCCBRootPath, pCCBFileName, pOwner, CCDirector::sharedDirector()->getWinSize()); } +CCNode * CCBReader::readNodeGraphFromFile(CCString * pCCBRootPath, CCString * pCCBFileName, CCObject * pOwner) { + return this->readNodeGraphFromFile(pCCBRootPath, pCCBFileName, pOwner, CCDirector::sharedDirector()->getWinSize()); +} + CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize) { + return this->readNodeGraphFromFile(CCString::stringWithCString(pCCBRootPath), CCString::stringWithCString(pCCBFileName), pOwner, pRootContainerSize); +} + +CCNode * CCBReader::readNodeGraphFromFile(CCString * pCCBRootPath, CCString * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize) { this->mCCBRootPath = pCCBRootPath; + this->mCCBRootPath->retain(); - char ccbFullFilePath[strlen(pCCBRootPath) + strlen(pCCBFileName) + 1]; - strcpy(ccbFullFilePath, pCCBRootPath); - strcat(ccbFullFilePath, pCCBFileName); + CCString * ccbFullFilePath = CCBReader::concat(pCCBRootPath, pCCBFileName); - const char * path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(ccbFullFilePath); + const char * path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(ccbFullFilePath->getCString()); unsigned long size = 0; this->mBytes = CCFileUtils::sharedFileUtils()->getFileData(path, "rb", &size); this->mCurrentByte = 0; this->mCurrentBit = 0; + this->mOwner = pOwner; + this->mOwner->retain(); this->mRootContainerSize = pRootContainerSize; - if(!this->readHeader()) { - return NULL; + CCNode * node = NULL; + if(this->readHeader() && this->readStringCache()) { + node = this->readNodeGraph(); } - if(!this->readStringCache()) { - return NULL; - } + CC_SAFE_RELEASE(this->mOwner); + CC_SAFE_RELEASE(this->mCCBRootPath); + CC_SAFE_RELEASE(this->mRootNode); - return this->readNodeGraph(); + return node; } bool CCBReader::readHeader() { @@ -158,7 +167,8 @@ void CCBReader::readStringCacheEntry() { int numBytes = b0 << 8 | b1; const char * src = (const char *) (this->mBytes + this->mCurrentByte); - std::string string(src, numBytes); + CCString * string = CCString::stringWithCStringData(src, (unsigned long)numBytes); + string->retain(); this->mCurrentByte += numBytes; @@ -260,22 +270,22 @@ void CCBReader::alignBits() { } } -std::string CCBReader::readCachedString() { +CCString * CCBReader::readCachedString() { int i = this->readInt(false); return this->mStringCache[i]; } CCNode * CCBReader::readNodeGraph(CCNode * pParent) { /* Read class name. */ - const char * className = this->readCachedString().c_str(); + CCString * className = this->readCachedString(); int memberVarAssignmentType = this->readInt(false); - const char * memberVarAssignmentName; + CCString * memberVarAssignmentName; if(memberVarAssignmentType != kCCBTargetTypeNone) { - memberVarAssignmentName = this->readCachedString().c_str(); + memberVarAssignmentName = this->readCachedString(); } - CCNodeLoader * ccNodeLoader = this->mCCNodeLoaderLibrary->getCCNodeLoader(className); + CCNodeLoader * ccNodeLoader = this->mCCNodeLoaderLibrary->getCCNodeLoader(className->m_sString); CCNode * node = ccNodeLoader->loadCCNode(pParent, this); /* Set root node, if not set yet. */ @@ -344,49 +354,54 @@ CCSize CCBReader::getContainerSize(CCNode * pNode) { } } -bool CCBReader::isSpriteSheetLoaded(const char * pSpriteSheet) { - return this->mLoadedSpriteSheets.find(pSpriteSheet) != this->mLoadedSpriteSheets.end(); +bool CCBReader::isSpriteSheetLoaded(CCString * pSpriteSheet) { + return this->mLoadedSpriteSheets.find(pSpriteSheet->m_sString) != this->mLoadedSpriteSheets.end(); } -void CCBReader::addLoadedSpriteSheet(const char * pSpriteSheet) { - this->mLoadedSpriteSheets.insert(pSpriteSheet); +void CCBReader::addLoadedSpriteSheet(CCString * pSpriteSheet) { + pSpriteSheet->retain(); + this->mLoadedSpriteSheets.insert(pSpriteSheet->m_sString); } -std::string CCBReader::lastPathComponent(const char * pPath) { - std::string path(pPath); +CCString * CCBReader::lastPathComponent(CCString * pPath) { + std::string path(pPath->getCString()); int slashPos = path.find_last_of("/"); if(slashPos != std::string::npos) { - return path.substr(slashPos + 1, path.length() - slashPos); + return CCString::stringWithCString(path.substr(slashPos + 1, path.length() - slashPos).c_str()); } - return path; + return CCString::stringWithCString(path.c_str()); } -std::string CCBReader::deletePathExtension(const char * pPath) { - std::string path(pPath); +CCString * CCBReader::deletePathExtension(CCString * pPath) { + std::string path(pPath->getCString()); int dotPos = path.find_last_of("."); if(dotPos != std::string::npos) { - return path.substr(0, dotPos); + return CCString::stringWithCString(path.substr(0, dotPos).c_str()); } - return path; + return CCString::stringWithCString(path.c_str()); } -std::string CCBReader::toLowerCase(const char * pString) { - std::string copy(pString); +CCString * CCBReader::toLowerCase(CCString * pString) { + std::string copy(pString->getCString()); std::transform(copy.begin(), copy.end(), copy.begin(), ::tolower); - return copy; + return CCString::stringWithCString(copy.c_str()); } -std::string CCBReader::concat(const char * pStringA, const char * pStringB) { - std::string stringA(pStringA); - std::string stringB(pStringB); +CCString * CCBReader::concat(CCString * pStringA, CCString * pStringB) { + int concatenatedLength = pStringA->length() + pStringB->length() + 1; + char concatenated[concatenatedLength]; - std::string string = stringA + stringB; - return string; + strcpy(concatenated, pStringA->getCString()); + strcat(concatenated, pStringB->getCString()); + + concatenated[concatenatedLength] = '\0'; + + return CCString::stringWithCString(concatenated); } -bool CCBReader::endsWith(const char * pString, const char * pEnding) { - std::string string(pString); - std::string ending(pEnding); +bool CCBReader::endsWith(CCString * pString, CCString * pEnding) { + std::string string(pString->getCString()); + std::string ending(pEnding->getCString()); if(string.length() >= ending.length()) { return (string.compare(string.length() - ending.length(), ending.length(), ending) == 0); } else { diff --git a/cocos2dx/extensions/CCBReader/CCBReader.h b/cocos2dx/extensions/CCBReader/CCBReader.h index 6216987818..5bacd93585 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader.h +++ b/cocos2dx/extensions/CCBReader/CCBReader.h @@ -84,7 +84,7 @@ class CCBSelectorResolver; */ class CC_DLL CCBReader : public CCObject { private: - std::string mCCBRootPath; + CCString * mCCBRootPath; bool mRootCCBReader; unsigned char * mBytes; @@ -100,7 +100,7 @@ class CC_DLL CCBReader : public CCObject { CCBMemberVariableAssigner * mCCBMemberVariableAssigner; CCBSelectorResolver * mCCBSelectorResolver; - std::vector mStringCache; + std::vector mStringCache; std::set mLoadedSpriteSheets; public: @@ -109,34 +109,37 @@ class CC_DLL CCBReader : public CCObject { CCBReader(CCBReader *); /* Destructor. */ ~CCBReader(); - + CCNode * readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner = NULL); + CCNode * readNodeGraphFromFile(CCString * pCCBRootPath, CCString * pCCBFileName, CCObject * pOwner = NULL); CCNode * readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize); + CCNode * readNodeGraphFromFile(CCString * pCCBRootPath, CCString * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize); + CCBMemberVariableAssigner * getCCBMemberVariableAssigner(); CCBSelectorResolver * getCCBSelectorResolver(); - std::string getCCBRootPath(); + CCString * getCCBRootPath(); CCObject * getOwner(); CCNode * getRootNode(); CCSize getContainerSize(CCNode *); float getResolutionScale(); - bool isSpriteSheetLoaded(const char *); - void addLoadedSpriteSheet(const char *); + bool isSpriteSheetLoaded(CCString *); + void addLoadedSpriteSheet(CCString *); /* Utility methods. */ - std::string lastPathComponent(const char *); - std::string deletePathExtension(const char *); - std::string toLowerCase(const char *); - bool endsWith(const char *, const char *); - std::string concat(const char *, const char *); + static CCString * lastPathComponent(CCString *); + static CCString * deletePathExtension(CCString *); + static CCString * toLowerCase(CCString *); + static bool endsWith(CCString *, CCString *); + static CCString * concat(CCString *, CCString *); /* Parse methods. */ int readInt(bool pSign); unsigned char readByte(); bool readBool(); float readFloat(); - std::string readCachedString(); + CCString * readCachedString(); private: bool readHeader(); @@ -147,7 +150,7 @@ class CC_DLL CCBReader : public CCObject { bool getBit(); void alignBits(); - const char * readUTF8(); + CCString * readUTF8(); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCBSelectorResolver.h b/cocos2dx/extensions/CCBReader/CCBSelectorResolver.h index a29faec091..08bad62358 100644 --- a/cocos2dx/extensions/CCBReader/CCBSelectorResolver.h +++ b/cocos2dx/extensions/CCBReader/CCBSelectorResolver.h @@ -7,8 +7,8 @@ NS_CC_EXT_BEGIN class CCBSelectorResolver { public: - virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(CCObject * pTarget, const char * pSelectorName) = 0; - virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(CCObject * pTarget, const char * pSelectorName) = 0; + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(CCObject * pTarget, CCString * pSelectorName) = 0; + virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(CCObject * pTarget, CCString * pSelectorName) = 0; }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCControlButtonLoader.cpp b/cocos2dx/extensions/CCBReader/CCControlButtonLoader.cpp index 2e753aa14b..5adf9dcfcc 100644 --- a/cocos2dx/extensions/CCBReader/CCControlButtonLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCControlButtonLoader.cpp @@ -26,82 +26,76 @@ CCControl * CCControlButtonLoader::createCCNode(CCNode * pParent, CCBReader * pC return CCControlButton::node(); } -void CCControlButtonLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_ZOOMONTOUCHDOWN) == 0) { +void CCControlButtonLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_ZOOMONTOUCHDOWN) == 0) { ((CCControlButton *)pNode)->setZoomOnTouchDown(pCheck); } else { CCControlLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader); } } -void CCControlButtonLoader::onHandlePropTypeString(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pString, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_TITLE_NORMAL) == 0) { - CCString * ccString = new CCString(pString); - ccString->autorelease(); - ((CCControlButton *)pNode)->setTitleForState(ccString, CCControlStateNormal); - } else if(strcmp(pPropertyName, PROPERTY_TITLE_HIGHLIGHTED) == 0) { - CCString * ccString = new CCString(pString); - ccString->autorelease(); - ((CCControlButton *)pNode)->setTitleForState(ccString, CCControlStateHighlighted); - } else if(strcmp(pPropertyName, PROPERTY_TITLE_DISABLED) == 0) { - CCString * ccString = new CCString(pString); - ccString->autorelease(); - ((CCControlButton *)pNode)->setTitleForState(ccString, CCControlStateDisabled); +void CCControlButtonLoader::onHandlePropTypeString(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pString, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_TITLE_NORMAL) == 0) { + ((CCControlButton *)pNode)->setTitleForState(pString, CCControlStateNormal); + } else if(pPropertyName->compare(PROPERTY_TITLE_HIGHLIGHTED) == 0) { + ((CCControlButton *)pNode)->setTitleForState(pString, CCControlStateHighlighted); + } else if(pPropertyName->compare(PROPERTY_TITLE_DISABLED) == 0) { + ((CCControlButton *)pNode)->setTitleForState(pString, CCControlStateDisabled); } else { CCControlLoader::onHandlePropTypeString(pNode, pParent, pPropertyName, pString, pCCBReader); } } -void CCControlButtonLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_TITLETTF_NORMAL) == 0) { - ((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF, CCControlStateNormal); - } else if(strcmp(pPropertyName, PROPERTY_TITLETTF_HIGHLIGHTED) == 0) { - ((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF, CCControlStateHighlighted); - } else if(strcmp(pPropertyName, PROPERTY_TITLETTF_DISABLED) == 0) { - ((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF, CCControlStateDisabled); +void CCControlButtonLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pFontTTF, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_TITLETTF_NORMAL) == 0) { + ((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF->getCString(), CCControlStateNormal); + } else if(pPropertyName->compare(PROPERTY_TITLETTF_HIGHLIGHTED) == 0) { + ((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF->getCString(), CCControlStateHighlighted); + } else if(pPropertyName->compare(PROPERTY_TITLETTF_DISABLED) == 0) { + ((CCControlButton *)pNode)->setTitleTTFForState(pFontTTF->getCString(), CCControlStateDisabled); } else { CCControlLoader::onHandlePropTypeFontTTF(pNode, pParent, pPropertyName, pFontTTF, pCCBReader); } } -void CCControlButtonLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloatScale, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_TITLETTFSIZE_NORMAL) == 0) { +void CCControlButtonLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloatScale, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_TITLETTFSIZE_NORMAL) == 0) { ((CCControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, CCControlStateNormal); - } else if(strcmp(pPropertyName, PROPERTY_TITLETTFSIZE_HIGHLIGHTED) == 0) { + } else if(pPropertyName->compare(PROPERTY_TITLETTFSIZE_HIGHLIGHTED) == 0) { ((CCControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, CCControlStateHighlighted); - } else if(strcmp(pPropertyName, PROPERTY_TITLETTFSIZE_DISABLED) == 0) { + } else if(pPropertyName->compare(PROPERTY_TITLETTFSIZE_DISABLED) == 0) { ((CCControlButton *)pNode)->setTitleTTFSizeForState(pFloatScale, CCControlStateDisabled); } else { CCControlLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pFloatScale, pCCBReader); } } -void CCControlButtonLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_LABELANCHORPOINT) == 0) { +void CCControlButtonLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_LABELANCHORPOINT) == 0) { ((CCControlButton *)pNode)->setLabelAnchorPoint(pPoint); } else { CCControlLoader::onHandlePropTypePoint(pNode, pParent, pPropertyName, pPoint, pCCBReader); } } -void CCControlButtonLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize pSize, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_PREFEREDSIZE) == 0) { +void CCControlButtonLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize pSize, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_PREFEREDSIZE) == 0) { ((CCControlButton *)pNode)->setPreferredSize(pSize); } else { CCControlLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, pCCBReader); } } -void CCControlButtonLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL) == 0) { +void CCControlButtonLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_BACKGROUNDSPRITEFRAME_NORMAL) == 0) { if(pCCSpriteFrame != NULL) { ((CCControlButton *)pNode)->setBackgroundSpriteFrameForState(pCCSpriteFrame, CCControlStateNormal); } - } else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED) == 0) { + } else if(pPropertyName->compare(PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED) == 0) { if(pCCSpriteFrame != NULL) { ((CCControlButton *)pNode)->setBackgroundSpriteFrameForState(pCCSpriteFrame, CCControlStateHighlighted); } - } else if(strcmp(pPropertyName, PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED) == 0) { + } else if(pPropertyName->compare(PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED) == 0) { if(pCCSpriteFrame != NULL) { ((CCControlButton *)pNode)->setBackgroundSpriteFrameForState(pCCSpriteFrame, CCControlStateDisabled); } @@ -110,12 +104,12 @@ void CCControlButtonLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * } } -void CCControlButtonLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_NORMAL) == 0) { +void CCControlButtonLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_TITLECOLOR_NORMAL) == 0) { ((CCControlButton *)pNode)->setTitleColorForState(pCCColor3B, CCControlStateNormal); - } else if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_HIGHLIGHTED) == 0) { + } else if(pPropertyName->compare(PROPERTY_TITLECOLOR_HIGHLIGHTED) == 0) { ((CCControlButton *)pNode)->setTitleColorForState(pCCColor3B, CCControlStateHighlighted); - } else if(strcmp(pPropertyName, PROPERTY_TITLECOLOR_DISABLED) == 0) { + } else if(pPropertyName->compare(PROPERTY_TITLECOLOR_DISABLED) == 0) { ((CCControlButton *)pNode)->setTitleColorForState(pCCColor3B, CCControlStateDisabled); } else { CCControlLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); diff --git a/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h b/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h index 91ca8c00d3..865a1debd8 100644 --- a/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h +++ b/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h @@ -15,14 +15,14 @@ class CCControlButtonLoader : public CCControlLoader { protected: virtual CCControl * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool, CCBReader *); - virtual void onHandlePropTypeString(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char *, CCBReader *); - virtual void onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char *, CCBReader *); - virtual void onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float, CCBReader *); - virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint, CCBReader *); - virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize, CCBReader *); - virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame *, CCBReader *); - virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B, CCBReader *); + virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool, CCBReader *); + virtual void onHandlePropTypeString(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString *, CCBReader *); + virtual void onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString *, CCBReader *); + virtual void onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float, CCBReader *); + virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint, CCBReader *); + virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize, CCBReader *); + virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame *, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCControlLoader.cpp b/cocos2dx/extensions/CCBReader/CCControlLoader.cpp index 7be8f8d5ba..ed3baa7e54 100644 --- a/cocos2dx/extensions/CCBReader/CCControlLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCControlLoader.cpp @@ -7,18 +7,18 @@ USING_NS_CC_EXT; #define PROPERTY_SELECTED "selected" #define PROPERTY_CCCONTROL "ccControl" -void CCControlLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_ENABLED) == 0) { +void CCControlLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_ENABLED) == 0) { ((CCControl *)pNode)->setIsEnabled(pCheck); - } else if(strcmp(pPropertyName, PROPERTY_SELECTED) == 0) { + } else if(pPropertyName->compare(PROPERTY_SELECTED) == 0) { ((CCControl *)pNode)->setIsSelected(pCheck); } else { CCNodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader); } } -void CCControlLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_CCCONTROL) == 0) { +void CCControlLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_CCCONTROL) == 0) { ((CCControl *)pNode)->addTargetWithActionForControlEvents(pBlockCCControlData->mTarget, pBlockCCControlData->mSELCCControlHandler, pBlockCCControlData->mControlEvents); } else { CCNodeLoader::onHandlePropTypeBlockCCControl(pNode, pParent, pPropertyName, pBlockCCControlData, pCCBReader); diff --git a/cocos2dx/extensions/CCBReader/CCControlLoader.h b/cocos2dx/extensions/CCBReader/CCControlLoader.h index 4638cf5ac4..83cf4d4d57 100644 --- a/cocos2dx/extensions/CCBReader/CCControlLoader.h +++ b/cocos2dx/extensions/CCBReader/CCControlLoader.h @@ -12,8 +12,8 @@ class CCControlLoader : public CCNodeLoader { protected: virtual CCControl * createCCNode(CCNode *, CCBReader *) = 0; - virtual void onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockCCControlData *, CCBReader *); - virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool, CCBReader *); + virtual void onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockCCControlData *, CCBReader *); + virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.cpp b/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.cpp index 602dbea8af..8fd31fb2ed 100644 --- a/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.cpp @@ -13,41 +13,43 @@ CCLabelBMFont * CCLabelBMFontLoader::createCCNode(CCNode * pParent, CCBReader * return CCLabelBMFont::node(); } -void CCLabelBMFontLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) { +void CCLabelBMFontLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_COLOR) == 0) { ((CCLabelBMFont *)pNode)->setColor(pCCColor3B); } else { CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); } } -void CCLabelBMFontLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) { +void CCLabelBMFontLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_OPACITY) == 0) { ((CCLabelBMFont *)pNode)->setOpacity(pByte); } else { CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); } } -void CCLabelBMFontLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { +void CCLabelBMFontLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_BLENDFUNC) == 0) { ((CCLabelBMFont *)pNode)->setBlendFunc(pCCBlendFunc); } else { CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); } } -void CCLabelBMFontLoader::onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pFntFile, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_FNTFILE) == 0) { - ((CCLabelBMFont *)pNode)->setFntFile(pCCBReader->concat(pCCBReader->getCCBRootPath().c_str(), pFntFile).c_str()); +void CCLabelBMFontLoader::onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pFntFile, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_FNTFILE) == 0) { + CCString * fntFilePath = CCBReader::concat(pCCBReader->getCCBRootPath(), pFntFile); + + ((CCLabelBMFont *)pNode)->setFntFile(fntFilePath->getCString()); } else { CCNodeLoader::onHandlePropTypeFntFile(pNode, pParent, pPropertyName, pFntFile, pCCBReader); } } -void CCLabelBMFontLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pText, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_STRING) == 0) { - ((CCLabelBMFont *)pNode)->setString(pText); +void CCLabelBMFontLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pText, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_STRING) == 0) { + ((CCLabelBMFont *)pNode)->setString(pText->getCString()); } else { CCNodeLoader::onHandlePropTypeText(pNode, pParent, pPropertyName, pText, pCCBReader); } diff --git a/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h b/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h index 582b11beb5..e6796c9067 100644 --- a/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h @@ -15,11 +15,11 @@ class CCLabelBMFontLoader : public CCNodeLoader { protected: virtual CCLabelBMFont * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B, CCBReader *); - virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc, CCBReader *); - virtual void onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char *, CCBReader *); - virtual void onHandlePropTypeText(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char *, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *); + virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString *, CCBReader *); + virtual void onHandlePropTypeText(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString *, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.cpp b/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.cpp index 1c05c31e5a..61a6d63bc3 100644 --- a/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.cpp @@ -17,66 +17,66 @@ CCLabelTTF * CCLabelTTFLoader::createCCNode(CCNode * pParent, CCBReader * pCCBRe return CCLabelTTF::node(); } -void CCLabelTTFLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) { +void CCLabelTTFLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_COLOR) == 0) { ((CCLabelTTF *)pNode)->setColor(pCCColor3B); } else { CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); } } -void CCLabelTTFLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) { +void CCLabelTTFLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_OPACITY) == 0) { ((CCLabelTTF *)pNode)->setOpacity(pByte); } else { CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); } } -void CCLabelTTFLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { +void CCLabelTTFLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_BLENDFUNC) == 0) { ((CCLabelTTF *)pNode)->setBlendFunc(pCCBlendFunc); } else { CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); } } -void CCLabelTTFLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_FONTNAME) == 0) { - ((CCLabelTTF *)pNode)->setFontName(pFontTTF); +void CCLabelTTFLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pFontTTF, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_FONTNAME) == 0) { + ((CCLabelTTF *)pNode)->setFontName(pFontTTF->getCString()); } else { CCNodeLoader::onHandlePropTypeFontTTF(pNode, pParent, pPropertyName, pFontTTF, pCCBReader); } } -void CCLabelTTFLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pText, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_STRING) == 0) { - ((CCLabelTTF *)pNode)->setString(pText); +void CCLabelTTFLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pText, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_STRING) == 0) { + ((CCLabelTTF *)pNode)->setString(pText->getCString()); } else { CCNodeLoader::onHandlePropTypeText(pNode, pParent, pPropertyName, pText, pCCBReader); } } -void CCLabelTTFLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloatScale, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_FONTSIZE) == 0) { +void CCLabelTTFLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloatScale, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_FONTSIZE) == 0) { ((CCLabelTTF *)pNode)->setFontSize(pFloatScale); } else { CCNodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pFloatScale, pCCBReader); } } -void CCLabelTTFLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_HORIZONTALALIGNMENT) == 0) { +void CCLabelTTFLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_HORIZONTALALIGNMENT) == 0) { ((CCLabelTTF *)pNode)->setHorizontalAlignment(CCTextAlignment(pIntegerLabeled)); - } else if(strcmp(pPropertyName, PROPERTY_VERTICALALIGNMENT) == 0) { + } else if(pPropertyName->compare(PROPERTY_VERTICALALIGNMENT) == 0) { ((CCLabelTTF *)pNode)->setVerticalAlignment(CCVerticalTextAlignment(pIntegerLabeled)); } else { CCNodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader); } } -void CCLabelTTFLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize pSize, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_DIMENSIONS) == 0) { +void CCLabelTTFLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize pSize, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_DIMENSIONS) == 0) { ((CCLabelTTF *)pNode)->setDimensions(pSize); } else { CCNodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, pCCBReader); diff --git a/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h b/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h index 04ee0bc641..db9115e1e5 100644 --- a/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h @@ -15,14 +15,14 @@ class CCLabelTTFLoader : public CCNodeLoader { protected: virtual CCLabelTTF * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B, CCBReader *); - virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc, CCBReader *); - virtual void onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char *, CCBReader *); - virtual void onHandlePropTypeText(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char *, CCBReader *); - virtual void onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float, CCBReader *); - virtual void onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int, CCBReader *); - virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *); + virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString *, CCBReader *); + virtual void onHandlePropTypeText(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString *, CCBReader *); + virtual void onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float, CCBReader *); + virtual void onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int, CCBReader *); + virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCLayerColorLoader.cpp b/cocos2dx/extensions/CCBReader/CCLayerColorLoader.cpp index d04fdb0d6d..c4b3338efe 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerColorLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCLayerColorLoader.cpp @@ -11,24 +11,24 @@ CCLayerColor * CCLayerColorLoader::createCCNode(CCNode * pParent, CCBReader * pC return CCLayerColor::node(); } -void CCLayerColorLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) { +void CCLayerColorLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_COLOR) == 0) { ((CCLayerColor *)pNode)->setColor(pCCColor3B); } else { CCLayerLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); } } -void CCLayerColorLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) { +void CCLayerColorLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_OPACITY) == 0) { ((CCLayerColor *)pNode)->setOpacity(pByte); } else { CCLayerLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); } } -void CCLayerColorLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { +void CCLayerColorLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_BLENDFUNC) == 0) { ((CCLayerColor *)pNode)->setBlendFunc(pCCBlendFunc); } else { CCLayerLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); diff --git a/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h b/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h index 8efd9d872a..5a88c01dd6 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h @@ -14,9 +14,9 @@ class CCLayerColorLoader : public CCLayerLoader { protected: virtual CCLayerColor * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B, CCBReader *); - virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *); + virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.cpp b/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.cpp index 596c491ae3..5bfae597c1 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.cpp @@ -14,28 +14,28 @@ CCLayerGradient * CCLayerGradientLoader::createCCNode(CCNode * pParent, CCBReade return CCLayerGradient::node(); } -void CCLayerGradientLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_STARTCOLOR) == 0) { +void CCLayerGradientLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_STARTCOLOR) == 0) { ((CCLayerGradient *)pNode)->setStartColor(pCCColor3B); - } else if(strcmp(pPropertyName, PROPERTY_ENDCOLOR) == 0) { + } else if(pPropertyName->compare(PROPERTY_ENDCOLOR) == 0) { ((CCLayerGradient *)pNode)->setEndColor(pCCColor3B); } else { CCLayerLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); } } -void CCLayerGradientLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_STARTOPACITY) == 0) { +void CCLayerGradientLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_STARTOPACITY) == 0) { ((CCLayerGradient *)pNode)->setStartOpacity(pByte); - } else if(strcmp(pPropertyName, PROPERTY_ENDOPACITY) == 0) { + } else if(pPropertyName->compare(PROPERTY_ENDOPACITY) == 0) { ((CCLayerGradient *)pNode)->setEndOpacity(pByte); } else { CCLayerLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); } } -void CCLayerGradientLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { +void CCLayerGradientLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_BLENDFUNC) == 0) { ((CCLayerGradient *)pNode)->setBlendFunc(pCCBlendFunc); } else { CCLayerLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); @@ -43,8 +43,8 @@ void CCLayerGradientLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * p } -void CCLayerGradientLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_VECTOR) == 0) { +void CCLayerGradientLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_VECTOR) == 0) { ((CCLayerGradient *)pNode)->setVector(pPoint); // TODO Not passed along the ccbi file. diff --git a/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h b/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h index f515a312dc..9ee3dc2074 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h @@ -15,10 +15,10 @@ class CCLayerGradientLoader : public CCLayerLoader { protected: virtual CCLayerGradient * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B, CCBReader *); - virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char, CCBReader *); - virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *); + virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *); + virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCLayerLoader.cpp b/cocos2dx/extensions/CCBReader/CCLayerLoader.cpp index f6942ef5af..f13a116b26 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCLayerLoader.cpp @@ -12,15 +12,15 @@ CCLayer * CCLayerLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) return CCLayer::node(); } -void CCLayerLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_TOUCH_ENABLED) == 0) { +void CCLayerLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_TOUCH_ENABLED) == 0) { ((CCLayer *)pNode)->setIsTouchEnabled(pCheck); - } else if(strcmp(pPropertyName, PROPERTY_ACCELEROMETER_ENABLED) == 0) { + } else if(pPropertyName->compare(PROPERTY_ACCELEROMETER_ENABLED) == 0) { ((CCLayer *)pNode)->setIsAccelerometerEnabled(pCheck); - } else if(strcmp(pPropertyName, PROPERTY_MOUSE_ENABLED) == 0) { + } else if(pPropertyName->compare(PROPERTY_MOUSE_ENABLED) == 0) { // TODO XXX CCLOG("The property '%s' is not supported!", PROPERTY_MOUSE_ENABLED); - } else if(strcmp(pPropertyName, PROPERTY_KEYBOARD_ENABLED) == 0) { + } else if(pPropertyName->compare(PROPERTY_KEYBOARD_ENABLED) == 0) { // TODO XXX CCLOG("The property '%s' is not supported!", PROPERTY_KEYBOARD_ENABLED); // This comes closest: ((CCLayer *)pNode)->setIsKeypadEnabled(pCheck); diff --git a/cocos2dx/extensions/CCBReader/CCLayerLoader.h b/cocos2dx/extensions/CCBReader/CCLayerLoader.h index b0277fa95b..33a1119058 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLayerLoader.h @@ -15,7 +15,7 @@ class CCLayerLoader : public CCNodeLoader { protected: virtual CCLayer * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader); + virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.cpp b/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.cpp index 8f8babb245..bb9a1893a8 100644 --- a/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.cpp @@ -11,16 +11,16 @@ CCMenuItemImage * CCMenuItemImageLoader::createCCNode(CCNode * pParent, CCBReade return CCMenuItemImage::node(); } -void CCMenuItemImageLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_NORMALDISPLAYFRAME) == 0) { +void CCMenuItemImageLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_NORMALDISPLAYFRAME) == 0) { if(pCCSpriteFrame != NULL) { ((CCMenuItemImage *)pNode)->setNormalSpriteFrame(pCCSpriteFrame); } - } else if(strcmp(pPropertyName, PROPERTY_SELECTEDDISPLAYFRAME) == 0) { + } else if(pPropertyName->compare(PROPERTY_SELECTEDDISPLAYFRAME) == 0) { if(pCCSpriteFrame != NULL) { ((CCMenuItemImage *)pNode)->setSelectedSpriteFrame(pCCSpriteFrame); } - } else if(strcmp(pPropertyName, PROPERTY_DISABLEDDISPLAYFRAME) == 0) { + } else if(pPropertyName->compare(PROPERTY_DISABLEDDISPLAYFRAME) == 0) { if(pCCSpriteFrame != NULL) { ((CCMenuItemImage *)pNode)->setDisabledSpriteFrame(pCCSpriteFrame); } diff --git a/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h b/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h index 756474d880..d37515173b 100644 --- a/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h +++ b/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h @@ -15,7 +15,7 @@ class CCMenuItemImageLoader : public CCMenuItemLoader { protected: virtual CCMenuItemImage * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame *, CCBReader *); + virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame *, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCMenuItemLoader.cpp b/cocos2dx/extensions/CCBReader/CCMenuItemLoader.cpp index 478f730b2e..51254814e2 100644 --- a/cocos2dx/extensions/CCBReader/CCMenuItemLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCMenuItemLoader.cpp @@ -6,16 +6,16 @@ USING_NS_CC_EXT; #define PROPERTY_BLOCK "block" #define PROPERTY_ISENABLED "isEnabled" -void CCMenuItemLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_BLOCK) == 0) { +void CCMenuItemLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_BLOCK) == 0) { ((CCMenuItem *)pNode)->setTarget(pBlockData->mTarget, pBlockData->mSELMenuHandler); } else { CCNodeLoader::onHandlePropTypeBlock(pNode, pParent, pPropertyName, pBlockData, pCCBReader); } } -void CCMenuItemLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_ISENABLED) == 0) { +void CCMenuItemLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_ISENABLED) == 0) { ((CCMenuItem *)pNode)->setIsEnabled(pCheck); } else { CCNodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader); diff --git a/cocos2dx/extensions/CCBReader/CCMenuItemLoader.h b/cocos2dx/extensions/CCBReader/CCMenuItemLoader.h index e7ff8ff9a5..8e409f1076 100644 --- a/cocos2dx/extensions/CCBReader/CCMenuItemLoader.h +++ b/cocos2dx/extensions/CCBReader/CCMenuItemLoader.h @@ -12,8 +12,8 @@ class CCMenuItemLoader : public CCNodeLoader { protected: virtual CCMenuItem * createCCNode(CCNode *, CCBReader *) = 0; - virtual void onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockData *, CCBReader *); - virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool, CCBReader *); + virtual void onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockData *, CCBReader *); + virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp index 98220ee25f..ad655e6a2a 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp @@ -11,8 +11,8 @@ #define PROPERTY_IGNOREANCHORPOINTFORPOSITION "ignoreAnchorPointForPosition" #define PROPERTY_VISIBLE "visible" -#define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) printf("Unexpected property: '%s'!\n", PROPERTY); assert(false) -#define ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) printf("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false) +#define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) CCLOG("Unexpected property: '%s'!\n", PROPERTY->getCString()); assert(false) +#define ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) CCLOG("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false) USING_NS_CC; USING_NS_CC_EXT; @@ -33,7 +33,7 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * int propertyCount = pCCBReader->readInt(false); for(int i = 0; i < propertyCount; i++) { int type = pCCBReader->readInt(false); - const char * propertyName = pCCBReader->readCachedString().c_str(); + CCString * propertyName = pCCBReader->readCachedString(); // Check if the property can be set for this platform bool setProp = false; @@ -198,28 +198,28 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * break; } case kCCBPropTypeFntFile: { - const char * fntFile = this->parsePropTypeFntFile(pNode, pParent, pCCBReader); + CCString * fntFile = this->parsePropTypeFntFile(pNode, pParent, pCCBReader); if(setProp) { this->onHandlePropTypeFntFile(pNode, pParent, propertyName, fntFile, pCCBReader); } break; } case kCCBPropTypeFontTTF: { - const char * fontTTF = this->parsePropTypeFontTTF(pNode, pParent, pCCBReader); + CCString * fontTTF = this->parsePropTypeFontTTF(pNode, pParent, pCCBReader); if(setProp) { this->onHandlePropTypeFontTTF(pNode, pParent, propertyName, fontTTF, pCCBReader); } break; } case kCCBPropTypeString: { - const char * string = this->parsePropTypeString(pNode, pParent, pCCBReader); + CCString * string = this->parsePropTypeString(pNode, pParent, pCCBReader); if(setProp) { this->onHandlePropTypeString(pNode, pParent, propertyName, string, pCCBReader); } break; } case kCCBPropTypeText: { - const char * text = this->parsePropTypeText(pNode, pParent, pCCBReader); + CCString * text = this->parsePropTypeText(pNode, pParent, pCCBReader); if(setProp) { this->onHandlePropTypeText(pNode, pParent, propertyName, text, pCCBReader); } @@ -406,39 +406,39 @@ bool CCNodeLoader::parsePropTypeCheck(CCNode * pNode, CCNode * pParent, CCBReade CCSpriteFrame * CCNodeLoader::parsePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - const char * spriteSheet = pCCBReader->readCachedString().c_str(); - const char * spriteFile = pCCBReader->readCachedString().c_str(); + CCString * spriteSheet = pCCBReader->readCachedString(); + CCString * spriteFile = pCCBReader->readCachedString(); CCSpriteFrame * spriteFrame; - if(strcmp(spriteSheet, "") == 0) { - if(strcmp(spriteFile, "") == 0) { + if(spriteSheet == NULL || spriteSheet->length() == 0) { + if(spriteFile == NULL || spriteFile->length() == 0) { return NULL; } - const char * spriteFilePath = pCCBReader->concat(pCCBReader->getCCBRootPath().c_str(), spriteFile).c_str(); + CCString * spriteFilePath = CCBReader::concat(pCCBReader->getCCBRootPath(), spriteFile); - CCTexture2D * texture = CCTextureCache::sharedTextureCache()->addImage(spriteFilePath); + CCTexture2D * texture = CCTextureCache::sharedTextureCache()->addImage(spriteFilePath->getCString()); CCRect bounds = CCRect::CCRect(0, 0, texture->getContentSize().width, texture->getContentSize().height); spriteFrame = CCSpriteFrame::frameWithTexture(texture, bounds); } else { CCSpriteFrameCache * frameCache = CCSpriteFrameCache::sharedSpriteFrameCache(); - const char * spriteSheetPath = pCCBReader->concat(pCCBReader->getCCBRootPath().c_str(), spriteSheet).c_str(); + CCString * spriteSheetPath = CCBReader::concat(pCCBReader->getCCBRootPath(), spriteSheet); /* Load the sprite sheet only if it is not loaded. */ if(!pCCBReader->isSpriteSheetLoaded(spriteSheetPath)) { - frameCache->addSpriteFramesWithFile(spriteSheetPath); + frameCache->addSpriteFramesWithFile(spriteSheetPath->getCString()); pCCBReader->addLoadedSpriteSheet(spriteSheetPath); } - spriteFrame = frameCache->spriteFrameByName(spriteFile); + spriteFrame = frameCache->spriteFrameByName(spriteFile->getCString()); } return spriteFrame; } CCAnimation * CCNodeLoader::parsePropTypeAnimation(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - const char * animationFile = pCCBReader->readCachedString().c_str(); - const char * animation = pCCBReader->readCachedString().c_str(); + CCString * animationFile = pCCBReader->readCachedString(); + CCString * animation = pCCBReader->readCachedString(); CCAnimation * ccAnimation = NULL; @@ -447,22 +447,22 @@ CCAnimation * CCNodeLoader::parsePropTypeAnimation(CCNode * pNode, CCNode * pPar // Eventually this should be handled by a client side asset manager // interface which figured out what resources to load. // TODO Does this problem exist in C++? - animation = pCCBReader->lastPathComponent(animation).c_str(); - animationFile = pCCBReader->lastPathComponent(animationFile).c_str(); + animation = CCBReader::lastPathComponent(animation); + animationFile = CCBReader::lastPathComponent(animationFile); - if(strcmp(animation, "") != 0) { + if(animation != NULL && animation->compare("") != 0) { CCAnimationCache * animationCache = CCAnimationCache::sharedAnimationCache(); - animationCache->addAnimationsWithFile(animationFile); + animationCache->addAnimationsWithFile(animationFile->getCString()); - ccAnimation = animationCache->animationByName(animation); + ccAnimation = animationCache->animationByName(animation->getCString()); } return ccAnimation; } CCTexture2D * CCNodeLoader::parsePropTypeTexture(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - const char * spriteFile = pCCBReader->concat(pCCBReader->getCCBRootPath().c_str(), pCCBReader->readCachedString().c_str()).c_str(); + CCString * spriteFile = CCBReader::concat(pCCBReader->getCCBRootPath(), pCCBReader->readCachedString()); - return CCTextureCache::sharedTextureCache()->addImage(spriteFile); + return CCTextureCache::sharedTextureCache()->addImage(spriteFile->getCString()); } unsigned char CCNodeLoader::parsePropTypeByte(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { @@ -524,32 +524,32 @@ ccBlendFunc CCNodeLoader::parsePropTypeBlendFunc(CCNode * pNode, CCNode * pParen return blendFunc; } -const char * CCNodeLoader::parsePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - return pCCBReader->readCachedString().c_str(); +CCString * CCNodeLoader::parsePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + return pCCBReader->readCachedString(); } -const char * CCNodeLoader::parsePropTypeString(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - return pCCBReader->readCachedString().c_str(); +CCString * CCNodeLoader::parsePropTypeString(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + return pCCBReader->readCachedString(); } -const char * CCNodeLoader::parsePropTypeText(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - return pCCBReader->readCachedString().c_str(); +CCString * CCNodeLoader::parsePropTypeText(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + return pCCBReader->readCachedString(); } -const char * CCNodeLoader::parsePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - const char * fnt = pCCBReader->readCachedString().c_str(); +CCString * CCNodeLoader::parsePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { + CCString * fnt = pCCBReader->readCachedString(); - const char * ttfEnding("ttf"); + CCString * ttfEnding = CCString::stringWithCString("ttf"); - if(pCCBReader->endsWith(pCCBReader->toLowerCase(fnt).c_str(), ttfEnding)){ - fnt = pCCBReader->deletePathExtension(pCCBReader->lastPathComponent(fnt).c_str()).c_str(); + if(CCBReader::endsWith(CCBReader::toLowerCase(fnt), ttfEnding)){ + fnt = CCBReader::deletePathExtension(CCBReader::lastPathComponent(fnt)); } return fnt; } BlockData * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - const char * selectorName = pCCBReader->readCachedString().c_str(); + CCString * selectorName = pCCBReader->readCachedString(); int selectorTarget = pCCBReader->readInt(false); if(selectorTarget != kCCBTargetTypeNone) { @@ -561,7 +561,7 @@ BlockData * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, C } if(target != NULL) { - if(strlen(selectorName) > 0) { + if(selectorName->length() > 0) { SEL_MenuHandler selMenuHandler = 0; CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast(target); @@ -598,7 +598,7 @@ BlockData * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, C } BlockCCControlData * CCNodeLoader::parsePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - const char * selectorName = pCCBReader->readCachedString().c_str(); + CCString * selectorName = pCCBReader->readCachedString(); int selectorTarget = pCCBReader->readInt(false); int controlEvents = pCCBReader->readInt(false); @@ -611,7 +611,7 @@ BlockCCControlData * CCNodeLoader::parsePropTypeBlockCCControl(CCNode * pNode, C } if(target != NULL) { - if(strlen(selectorName) > 0) { + if(selectorName->length() > 0) { SEL_CCControlHandler selCCControlHandler = 0; CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast(target); @@ -649,52 +649,52 @@ BlockCCControlData * CCNodeLoader::parsePropTypeBlockCCControl(CCNode * pNode, C } CCNode * CCNodeLoader::parsePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - const char * ccbFileName = pCCBReader->readCachedString().c_str(); + CCString * ccbFileName = pCCBReader->readCachedString(); /* Change path extension to .ccbi. */ - const char * ccbFileWithoutPathExtension = pCCBReader->deletePathExtension(ccbFileName).c_str(); - const char * ccbiFileName = pCCBReader->concat(ccbFileWithoutPathExtension, ".ccbi").c_str(); + CCString * ccbFileWithoutPathExtension = CCBReader::deletePathExtension(ccbFileName); + CCString * ccbiFileName = CCBReader::concat(ccbFileWithoutPathExtension, CCString::stringWithCString(".ccbi")); CCBReader * ccbReader = new CCBReader(pCCBReader); ccbReader->autorelease(); - CCNode * ccbFileNode = ccbReader->readNodeGraphFromFile(pCCBReader->getCCBRootPath().c_str(), ccbiFileName, pCCBReader->getOwner(), pParent->getContentSize()); + CCNode * ccbFileNode = ccbReader->readNodeGraphFromFile(pCCBReader->getCCBRootPath(), ccbiFileName, pCCBReader->getOwner(), pParent->getContentSize()); return ccbFileNode; } -void CCNodeLoader::onHandlePropTypePosition(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPosition, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_POSITION) == 0) { +void CCNodeLoader::onHandlePropTypePosition(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint pPosition, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_POSITION) == 0) { pNode->setPosition(pPosition); } else { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } -void CCNodeLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_ANCHORPOINT) == 0) { +void CCNodeLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_ANCHORPOINT) == 0) { pNode->setAnchorPoint(pPoint); } else { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } -void CCNodeLoader::onHandlePropTypePointLock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPointLock, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypePointLock(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint pPointLock, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize pSize, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_CONTENTSIZE) == 0) { +void CCNodeLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize pSize, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_CONTENTSIZE) == 0) { pNode->setContentSize(pSize); } else { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } -void CCNodeLoader::onHandlePropTypeScaleLock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float * pScaleLock, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_SCALE) == 0) { +void CCNodeLoader::onHandlePropTypeScaleLock(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float * pScaleLock, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_SCALE) == 0) { pNode->setScaleX(pScaleLock[0]); pNode->setScaleY(pScaleLock[1]); } else { @@ -702,104 +702,104 @@ void CCNodeLoader::onHandlePropTypeScaleLock(CCNode * pNode, CCNode * pParent, c } } -void CCNodeLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloat, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloat, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeDegrees(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pDegrees, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_ROTATION) == 0) { +void CCNodeLoader::onHandlePropTypeDegrees(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pDegrees, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_ROTATION) == 0) { pNode->setRotation(pDegrees); } else { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } -void CCNodeLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloatScale, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloatScale, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pInteger, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_TAG) == 0) { +void CCNodeLoader::onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int pInteger, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_TAG) == 0) { pNode->setTag(pInteger); } else { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } -void CCNodeLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float * pFloatVar, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float * pFloatVar, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_VISIBLE) == 0) { +void CCNodeLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_VISIBLE) == 0) { pNode->setIsVisible(pCheck); - } else if(strcmp(pPropertyName, PROPERTY_IGNOREANCHORPOINTFORPOSITION) == 0) { + } else if(pPropertyName->compare(PROPERTY_IGNOREANCHORPOINTFORPOSITION) == 0) { pNode->setIgnoreAnchorPointForPosition(pCheck); } else { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } } -void CCNodeLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeAnimation(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCAnimation * pCCAnimation, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeAnimation(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCAnimation * pCCAnimation, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool * pFlip, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool * pFlip, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pFntFile, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pFntFile, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeString(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pString, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeString(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pString, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pText, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeText(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pText, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pFontTTF, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } -void CCNodeLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader) { +void CCNodeLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader) { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } \ No newline at end of file diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoader.h b/cocos2dx/extensions/CCBReader/CCNodeLoader.h index 2d70a5afaf..3e0143ed8a 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoader.h +++ b/cocos2dx/extensions/CCBReader/CCNodeLoader.h @@ -50,42 +50,42 @@ class CC_DLL CCNodeLoader : public CCObject { virtual ccColor4F * parsePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual bool * parsePropTypeFlip(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual ccBlendFunc parsePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); - virtual const char * parsePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); - virtual const char * parsePropTypeString(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); - virtual const char * parsePropTypeText(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); - virtual const char * parsePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual CCString * parsePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual CCString * parsePropTypeString(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual CCString * parsePropTypeText(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); + virtual CCString * parsePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual BlockData * parsePropTypeBlock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual BlockCCControlData * parsePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual CCNode * parsePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); - virtual void onHandlePropTypePosition(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPosition, CCBReader * pCCBReader); - virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader); - virtual void onHandlePropTypePointLock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPointLock, CCBReader * pCCBReader); - virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize pSize, CCBReader * pCCBReader); - virtual void onHandlePropTypeScaleLock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float * pScaleLock, CCBReader * pCCBReader); - virtual void onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloat, CCBReader * pCCBReader); - virtual void onHandlePropTypeDegrees(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pDegrees, CCBReader * pCCBReader); - virtual void onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloatScale, CCBReader * pCCBReader); - virtual void onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pInteger, CCBReader * pCCBReader); - virtual void onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader); - virtual void onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float * pFoatVar, CCBReader * pCCBReader); - virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader); - virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader); - virtual void onHandlePropTypeAnimation(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCAnimation * pCCAnimation, CCBReader * pCCBReader); - virtual void onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader); - virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader); - virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader); - virtual void onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader); - virtual void onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool * pFlip, CCBReader * pCCBReader); - virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader); - virtual void onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pFntFile, CCBReader * pCCBReader); - virtual void onHandlePropTypeString(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pString, CCBReader * pCCBReader); - virtual void onHandlePropTypeText(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pText, CCBReader * pCCBReader); - virtual void onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, const char * pPropertyName, const char * pFontTTF, CCBReader * pCCBReader); - virtual void onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader); - virtual void onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, const char * pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader); - virtual void onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader); + virtual void onHandlePropTypePosition(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint pPosition, CCBReader * pCCBReader); + virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader); + virtual void onHandlePropTypePointLock(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint pPointLock, CCBReader * pCCBReader); + virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize pSize, CCBReader * pCCBReader); + virtual void onHandlePropTypeScaleLock(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float * pScaleLock, CCBReader * pCCBReader); + virtual void onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloat, CCBReader * pCCBReader); + virtual void onHandlePropTypeDegrees(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pDegrees, CCBReader * pCCBReader); + virtual void onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloatScale, CCBReader * pCCBReader); + virtual void onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int pInteger, CCBReader * pCCBReader); + virtual void onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader); + virtual void onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float * pFoatVar, CCBReader * pCCBReader); + virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader); + virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader); + virtual void onHandlePropTypeAnimation(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCAnimation * pCCAnimation, CCBReader * pCCBReader); + virtual void onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader); + virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader); + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader); + virtual void onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader); + virtual void onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool * pFlip, CCBReader * pCCBReader); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader); + virtual void onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pFntFile, CCBReader * pCCBReader); + virtual void onHandlePropTypeString(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pString, CCBReader * pCCBReader); + virtual void onHandlePropTypeText(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pText, CCBReader * pCCBReader); + virtual void onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pFontTTF, CCBReader * pCCBReader); + virtual void onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader); + virtual void onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader); + virtual void onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp index 48b5816f30..c8014ebaba 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp +++ b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp @@ -41,18 +41,18 @@ void CCNodeLoaderLibrary::registerDefaultCCNodeLoaders() { this->registerCCNodeLoader("CCParticleSystemQuad", CCParticleSystemQuadLoader::loader()); } -void CCNodeLoaderLibrary::registerCCNodeLoader(const char * pClassName, CCNodeLoader * pCCNodeLoader) { - this->mCCNodeLoaders.insert(std::pair(pClassName, pCCNodeLoader)); +void CCNodeLoaderLibrary::registerCCNodeLoader(std::string pClassName, CCNodeLoader * pCCNodeLoader) { pCCNodeLoader->retain(); + this->mCCNodeLoaders.insert(std::pair(pClassName, pCCNodeLoader)); } -void CCNodeLoaderLibrary::unregisterCCNodeLoader(const char * pClassName) { +void CCNodeLoaderLibrary::unregisterCCNodeLoader(std::string pClassName) { std::map::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName); assert(ccNodeLoadersIterator != this->mCCNodeLoaders.end()); ccNodeLoadersIterator->second->release(); } -CCNodeLoader * CCNodeLoaderLibrary::getCCNodeLoader(const char * pClassName) { +CCNodeLoader * CCNodeLoaderLibrary::getCCNodeLoader(std::string pClassName) { std::map::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName); assert(ccNodeLoadersIterator != this->mCCNodeLoaders.end()); return ccNodeLoadersIterator->second; diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h index da4b89cc2a..05352fbcca 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h +++ b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h @@ -17,9 +17,9 @@ class CC_DLL CCNodeLoaderLibrary : public CCObject { ~CCNodeLoaderLibrary(); void registerDefaultCCNodeLoaders(); - void registerCCNodeLoader(const char * pClassName, CCNodeLoader * pCCNodeLoader); - void unregisterCCNodeLoader(const char * pClassName); - CCNodeLoader * getCCNodeLoader(const char * pClassName); + void registerCCNodeLoader(std::string pClassName, CCNodeLoader * pCCNodeLoader); + void unregisterCCNodeLoader(std::string pClassName); + CCNodeLoader * getCCNodeLoader(std::string pClassName); void purge(bool pDelete); public: diff --git a/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.cpp b/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.cpp index 1e1d00b444..01f1077222 100644 --- a/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.cpp @@ -30,77 +30,77 @@ CCParticleSystemQuad * CCParticleSystemQuadLoader::createCCNode(CCNode * pParent return CCParticleSystemQuad::node(); } -void CCParticleSystemQuadLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_EMITERMODE) == 0) { +void CCParticleSystemQuadLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_EMITERMODE) == 0) { ((CCParticleSystemQuad *)pNode)->setEmitterMode(pIntegerLabeled); } else { CCNodeLoader::onHandlePropTypeIntegerLabeled(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader); } } -void CCParticleSystemQuadLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_POSVAR) == 0) { +void CCParticleSystemQuadLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_POSVAR) == 0) { ((CCParticleSystemQuad *)pNode)->setPosVar(pPoint); - } else if(strcmp(pPropertyName, PROPERTY_GRAVITY) == 0) { + } else if(pPropertyName->compare(PROPERTY_GRAVITY) == 0) { ((CCParticleSystemQuad *)pNode)->setGravity(pPoint); } else { CCNodeLoader::onHandlePropTypePoint(pNode, pParent, pPropertyName, pPoint, pCCBReader); } } -void CCParticleSystemQuadLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloat, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_EMISSIONRATE) == 0) { +void CCParticleSystemQuadLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloat, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_EMISSIONRATE) == 0) { ((CCParticleSystemQuad *)pNode)->setEmissionRate(pFloat); - } else if(strcmp(pPropertyName, PROPERTY_DURATION) == 0) { + } else if(pPropertyName->compare(PROPERTY_DURATION) == 0) { ((CCParticleSystemQuad *)pNode)->setDuration(pFloat); } else { CCNodeLoader::onHandlePropTypeFloat(pNode, pParent, pPropertyName, pFloat, pCCBReader); } } -void CCParticleSystemQuadLoader::onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int pInteger, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_TOTALPARTICLES) == 0) { +void CCParticleSystemQuadLoader::onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int pInteger, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_TOTALPARTICLES) == 0) { ((CCParticleSystemQuad *)pNode)->setTotalParticles(pInteger); } else { CCNodeLoader::onHandlePropTypeInteger(pNode, pParent, pPropertyName, pInteger, pCCBReader); } } -void CCParticleSystemQuadLoader::onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float * pFloatVar, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_LIFE) == 0) { +void CCParticleSystemQuadLoader::onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float * pFloatVar, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_LIFE) == 0) { ((CCParticleSystemQuad *)pNode)->setLife(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setLifeVar(pFloatVar[1]); - } else if(strcmp(pPropertyName, PROPERTY_STARTSIZE) == 0) { + } else if(pPropertyName->compare(PROPERTY_STARTSIZE) == 0) { ((CCParticleSystemQuad *)pNode)->setStartSize(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setStartSizeVar(pFloatVar[1]); - } else if(strcmp(pPropertyName, PROPERTY_ENDSIZE) == 0) { + } else if(pPropertyName->compare(PROPERTY_ENDSIZE) == 0) { ((CCParticleSystemQuad *)pNode)->setEndSize(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setEndSizeVar(pFloatVar[1]); - } else if(strcmp(pPropertyName, PROPERTY_STARTSPIN) == 0) { + } else if(pPropertyName->compare(PROPERTY_STARTSPIN) == 0) { ((CCParticleSystemQuad *)pNode)->setStartSpin(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setStartSpinVar(pFloatVar[1]); - } else if(strcmp(pPropertyName, PROPERTY_ENDSPIN) == 0) { + } else if(pPropertyName->compare(PROPERTY_ENDSPIN) == 0) { ((CCParticleSystemQuad *)pNode)->setEndSpin(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setEndSpinVar(pFloatVar[1]); - } else if(strcmp(pPropertyName, PROPERTY_ANGLE) == 0) { + } else if(pPropertyName->compare(PROPERTY_ANGLE) == 0) { ((CCParticleSystemQuad *)pNode)->setAngle(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setAngleVar(pFloatVar[1]); - } else if(strcmp(pPropertyName, PROPERTY_SPEED) == 0) { + } else if(pPropertyName->compare(PROPERTY_SPEED) == 0) { ((CCParticleSystemQuad *)pNode)->setSpeed(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setSpeedVar(pFloatVar[1]); - } else if(strcmp(pPropertyName, PROPERTY_TANGENTIALACCEL) == 0) { + } else if(pPropertyName->compare(PROPERTY_TANGENTIALACCEL) == 0) { ((CCParticleSystemQuad *)pNode)->setTangentialAccel(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setTangentialAccelVar(pFloatVar[1]); - } else if(strcmp(pPropertyName, PROPERTY_RADIALACCEL) == 0) { + } else if(pPropertyName->compare(PROPERTY_RADIALACCEL) == 0) { ((CCParticleSystemQuad *)pNode)->setRadialAccel(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setRadialAccelVar(pFloatVar[1]); - } else if(strcmp(pPropertyName, PROPERTY_STARTRADIUS) == 0) { + } else if(pPropertyName->compare(PROPERTY_STARTRADIUS) == 0) { ((CCParticleSystemQuad *)pNode)->setStartRadius(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setStartRadiusVar(pFloatVar[1]); - } else if(strcmp(pPropertyName, PROPERTY_ENDRADIUS) == 0) { + } else if(pPropertyName->compare(PROPERTY_ENDRADIUS) == 0) { ((CCParticleSystemQuad *)pNode)->setEndRadius(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setEndRadiusVar(pFloatVar[1]); - } else if(strcmp(pPropertyName, PROPERTY_ROTATEPERSECOND) == 0) { + } else if(pPropertyName->compare(PROPERTY_ROTATEPERSECOND) == 0) { ((CCParticleSystemQuad *)pNode)->setRotatePerSecond(pFloatVar[0]); ((CCParticleSystemQuad *)pNode)->setRotatePerSecondVar(pFloatVar[1]); } else { @@ -108,11 +108,11 @@ void CCParticleSystemQuadLoader::onHandlePropTypeFloatVar(CCNode * pNode, CCNode } } -void CCParticleSystemQuadLoader::onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_STARTCOLOR) == 0) { +void CCParticleSystemQuadLoader::onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_STARTCOLOR) == 0) { ((CCParticleSystemQuad *)pNode)->setStartColor(pCCColor4FVar[0]); ((CCParticleSystemQuad *)pNode)->setStartColorVar(pCCColor4FVar[1]); - } else if(strcmp(pPropertyName, PROPERTY_ENDCOLOR) == 0) { + } else if(pPropertyName->compare(PROPERTY_ENDCOLOR) == 0) { ((CCParticleSystemQuad *)pNode)->setEndColor(pCCColor4FVar[0]); ((CCParticleSystemQuad *)pNode)->setEndColorVar(pCCColor4FVar[1]); } else { @@ -120,16 +120,16 @@ void CCParticleSystemQuadLoader::onHandlePropTypeColor4FVar(CCNode * pNode, CCNo } } -void CCParticleSystemQuadLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { +void CCParticleSystemQuadLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_BLENDFUNC) == 0) { ((CCParticleSystemQuad *)pNode)->setBlendFunc(pCCBlendFunc); } else { CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); } } -void CCParticleSystemQuadLoader::onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_TEXTURE) == 0) { +void CCParticleSystemQuadLoader::onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_TEXTURE) == 0) { ((CCParticleSystemQuad *)pNode)->setTexture(pCCTexture2D); } else { CCNodeLoader::onHandlePropTypeTexture(pNode, pParent, pPropertyName, pCCTexture2D, pCCBReader); diff --git a/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h b/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h index c2687b3865..65c50818eb 100644 --- a/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h +++ b/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h @@ -15,14 +15,14 @@ class CCParticleSystemQuadLoader : public CCNodeLoader { protected: virtual CCParticleSystemQuad * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int, CCBReader *); - virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCPoint, CCBReader *); - virtual void onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float, CCBReader *); - virtual void onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, const char * pPropertyName, int, CCBReader *); - virtual void onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float *, CCBReader *); - virtual void onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor4F *, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc, CCBReader *); - virtual void onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCTexture2D *, CCBReader *); + virtual void onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int, CCBReader *); + virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint, CCBReader *); + virtual void onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float, CCBReader *); + virtual void onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int, CCBReader *); + virtual void onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float *, CCBReader *); + virtual void onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor4F *, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCTexture2D *, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.cpp b/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.cpp index c135580a5a..1a4624ddae 100644 --- a/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.cpp @@ -18,32 +18,32 @@ CCScale9Sprite * CCScale9SpriteLoader::createCCNode(CCNode * pParent, CCBReader return CCScale9Sprite::node(); } -void CCScale9SpriteLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_SPRITEFRAME) == 0) { +void CCScale9SpriteLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_SPRITEFRAME) == 0) { ((CCScale9Sprite *)pNode)->initWithSpriteFrame(pCCSpriteFrame); } else { CCNodeLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pCCSpriteFrame, pCCBReader); } } -void CCScale9SpriteLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) { +void CCScale9SpriteLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_COLOR) == 0) { ((CCScale9Sprite *)pNode)->setColor(pCCColor3B); } else { CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); } } -void CCScale9SpriteLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) { +void CCScale9SpriteLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_OPACITY) == 0) { ((CCScale9Sprite *)pNode)->setOpacity(pByte); } else { CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); } } -void CCScale9SpriteLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { +void CCScale9SpriteLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_BLENDFUNC) == 0) { // TODO Not exported by CocosBuilder yet! // ((CCScale9Sprite *)pNode)->setBlendFunc(pCCBlendFunc); } else { @@ -51,24 +51,24 @@ void CCScale9SpriteLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pP } } -void CCScale9SpriteLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize pSize, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_CONTENTSIZE) == 0) { +void CCScale9SpriteLoader::onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize pSize, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_CONTENTSIZE) == 0) { //((CCScale9Sprite *)pNode)->setContentSize(pSize); - } else if(strcmp(pPropertyName, PROPERTY_PREFEREDSIZE) == 0) { + } else if(pPropertyName->compare(PROPERTY_PREFEREDSIZE) == 0) { ((CCScale9Sprite *)pNode)->setPreferredSize(pSize); } else { CCNodeLoader::onHandlePropTypeSize(pNode, pParent, pPropertyName, pSize, pCCBReader); } } -void CCScale9SpriteLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float pFloat, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_INSETLEFT) == 0) { +void CCScale9SpriteLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloat, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_INSETLEFT) == 0) { ((CCScale9Sprite *)pNode)->setInsetLeft(pFloat); - } else if(strcmp(pPropertyName, PROPERTY_INSETTOP) == 0) { + } else if(pPropertyName->compare(PROPERTY_INSETTOP) == 0) { ((CCScale9Sprite *)pNode)->setInsetTop(pFloat); - } else if(strcmp(pPropertyName, PROPERTY_INSETRIGHT) == 0) { + } else if(pPropertyName->compare(PROPERTY_INSETRIGHT) == 0) { ((CCScale9Sprite *)pNode)->setInsetRight(pFloat); - } else if(strcmp(pPropertyName, PROPERTY_INSETBOTTOM) == 0) { + } else if(pPropertyName->compare(PROPERTY_INSETBOTTOM) == 0) { ((CCScale9Sprite *)pNode)->setInsetBottom(pFloat); } else { CCNodeLoader::onHandlePropTypeFloat(pNode, pParent, pPropertyName, pFloat, pCCBReader); diff --git a/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h b/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h index 4dd747f622..c47341ce19 100644 --- a/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h +++ b/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h @@ -15,12 +15,12 @@ class CCScale9SpriteLoader : public CCNodeLoader { protected: virtual CCScale9Sprite * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B, CCBReader *); - virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc, CCBReader *); - virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame *, CCBReader *); - virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSize, CCBReader *); - virtual void onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, const char * pPropertyName, float, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *); + virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame *, CCBReader *); + virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize, CCBReader *); + virtual void onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float, CCBReader *); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCSpriteLoader.cpp b/cocos2dx/extensions/CCBReader/CCSpriteLoader.cpp index 578160bd0a..eef53d0c1b 100644 --- a/cocos2dx/extensions/CCBReader/CCSpriteLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCSpriteLoader.cpp @@ -13,16 +13,16 @@ CCSprite * CCSpriteLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader return CCSprite::node(); } -void CCSpriteLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_DISPLAYFRAME) == 0) { +void CCSpriteLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_DISPLAYFRAME) == 0) { ((CCSprite *)pNode)->setDisplayFrame(pCCSpriteFrame); } else { CCNodeLoader::onHandlePropTypeSpriteFrame(pNode, pParent, pPropertyName, pCCSpriteFrame, pCCBReader); } } -void CCSpriteLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool * pFlip, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_FLIP) == 0) { +void CCSpriteLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool * pFlip, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_FLIP) == 0) { ((CCSprite *)pNode)->setFlipX(pFlip[0]); ((CCSprite *)pNode)->setFlipX(pFlip[1]); } else { @@ -30,24 +30,24 @@ void CCSpriteLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, cons } } -void CCSpriteLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_COLOR) == 0) { +void CCSpriteLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_COLOR) == 0) { ((CCSprite *)pNode)->setColor(pCCColor3B); } else { CCNodeLoader::onHandlePropTypeColor3(pNode, pParent, pPropertyName, pCCColor3B, pCCBReader); } } -void CCSpriteLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_OPACITY) == 0) { +void CCSpriteLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_OPACITY) == 0) { ((CCSprite *)pNode)->setOpacity(pByte); } else { CCNodeLoader::onHandlePropTypeByte(pNode, pParent, pPropertyName, pByte, pCCBReader); } } -void CCSpriteLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { - if(strcmp(pPropertyName, PROPERTY_BLENDFUNC) == 0) { +void CCSpriteLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_BLENDFUNC) == 0) { ((CCSprite *)pNode)->setBlendFunc(pCCBlendFunc); } else { CCNodeLoader::onHandlePropTypeBlendFunc(pNode, pParent, pPropertyName, pCCBlendFunc, pCCBReader); diff --git a/cocos2dx/extensions/CCBReader/CCSpriteLoader.h b/cocos2dx/extensions/CCBReader/CCSpriteLoader.h index 65caa1a007..8be9434206 100644 --- a/cocos2dx/extensions/CCBReader/CCSpriteLoader.h +++ b/cocos2dx/extensions/CCBReader/CCSpriteLoader.h @@ -15,11 +15,11 @@ class CCSpriteLoader : public CCNodeLoader { protected: virtual CCSprite * createCCNode(CCNode *, CCBReader *); - virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccColor3B, CCBReader *); - virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, const char * pPropertyName, unsigned char, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, const char * pPropertyName, ccBlendFunc, CCBReader *); - virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, const char * pPropertyName, CCSpriteFrame *, CCBReader *); - virtual void onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool *, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *); + virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame *, CCBReader *); + virtual void onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool *, CCBReader *); }; NS_CC_EXT_END diff --git a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id index bb7ea0ae95..e0d9ca4b0d 100644 --- a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -2ceb9242ccb6d715680043923827efd103be7d2b \ No newline at end of file +07809358e6957eaaec6329a5211294cf3bbc9105 \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.cpp index 435b89dded..b827a4a96b 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.cpp +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.cpp @@ -15,13 +15,13 @@ ButtonTestLayer * ButtonTestLayer::node() { return NULL; } -SEL_MenuHandler ButtonTestLayer::onResolveCCBCCMenuSelector(CCObject * pTarget, const char * pSelectorName) { +SEL_MenuHandler ButtonTestLayer::onResolveCCBCCMenuSelector(CCObject * pTarget, CCString * pSelectorName) { return NULL; } -SEL_CCControlHandler ButtonTestLayer::onResolveCCBCCControlSelector(CCObject * pTarget, const char * pSelectorName) { +SEL_CCControlHandler ButtonTestLayer::onResolveCCBCCControlSelector(CCObject * pTarget, CCString * pSelectorName) { if(pTarget == this) { - if(strcmp(pSelectorName, "onCCControlButtonClicked") == 0) { + if(pSelectorName->compare("onCCControlButtonClicked") == 0) { return cccontrol_selector(ButtonTestLayer::onCCControlButtonClicked); } } @@ -29,5 +29,5 @@ SEL_CCControlHandler ButtonTestLayer::onResolveCCBCCControlSelector(CCObject * p } void ButtonTestLayer::onCCControlButtonClicked(cocos2d::CCObject *pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - printf("onCCControlButtonClicked\n"); + CCLOG("onCCControlButtonClicked\n"); } \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.h index a65497e799..b0d00928a8 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.h @@ -9,8 +9,8 @@ class ButtonTestLayer : public cocos2d::extension::CCBSelectorResolver, public c public: static ButtonTestLayer * node(); - virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(cocos2d::CCObject * pTarget, const char * pSelectorName); - virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, const char * pSelectorName); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); + virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); virtual void onCCControlButtonClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); }; diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp index 34e89c9fdf..b8ff6499ee 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp @@ -32,6 +32,8 @@ USING_NS_CC; USING_NS_CC_EXT; void CocosBuilderTestScene::runThisTest() { + CCLog("HELLO WORLD"); + /* Create an autorelease CCNodeLoaderLibrary. */ CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary(); diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.cpp index 7e9e6b560a..ed172a9a3f 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.cpp +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.cpp @@ -64,23 +64,23 @@ void HelloCocosBuilderLayer::onNodeLoaded(cocos2d::CCNode * pNode, cocos2d::exte } -SEL_MenuHandler HelloCocosBuilderLayer::onResolveCCBCCMenuSelector(CCObject * pTarget, const char * pSelectorName) { +SEL_MenuHandler HelloCocosBuilderLayer::onResolveCCBCCMenuSelector(CCObject * pTarget, CCString * pSelectorName) { return NULL; } -SEL_CCControlHandler HelloCocosBuilderLayer::onResolveCCBCCControlSelector(CCObject * pTarget, const char * pSelectorName) { +SEL_CCControlHandler HelloCocosBuilderLayer::onResolveCCBCCControlSelector(CCObject * pTarget, CCString * pSelectorName) { if(pTarget == this) { - if(strcmp(pSelectorName, "onMenuTestClicked") == 0) { + if(strcmp(pSelectorName->getCString(), "onMenuTestClicked") == 0) { return cccontrol_selector(HelloCocosBuilderLayer::onMenuTestClicked); - } else if(strcmp(pSelectorName, "onSpriteTestClicked") == 0) { + } else if(strcmp(pSelectorName->getCString(), "onSpriteTestClicked") == 0) { return cccontrol_selector(HelloCocosBuilderLayer::onSpriteTestClicked); - } else if(strcmp(pSelectorName, "onButtonTestClicked") == 0) { + } else if(strcmp(pSelectorName->getCString(), "onButtonTestClicked") == 0) { return cccontrol_selector(HelloCocosBuilderLayer::onButtonTestClicked); - } else if(strcmp(pSelectorName, "onLabelTestClicked") == 0) { + } else if(strcmp(pSelectorName->getCString(), "onLabelTestClicked") == 0) { return cccontrol_selector(HelloCocosBuilderLayer::onLabelTestClicked); - } else if(strcmp(pSelectorName, "onParticleSystemTestClicked") == 0) { + } else if(strcmp(pSelectorName->getCString(), "onParticleSystemTestClicked") == 0) { return cccontrol_selector(HelloCocosBuilderLayer::onParticleSystemTestClicked); - } else if(strcmp(pSelectorName, "onScrollViewTestClicked") == 0) { + } else if(strcmp(pSelectorName->getCString(), "onScrollViewTestClicked") == 0) { return cccontrol_selector(HelloCocosBuilderLayer::onScrollViewTestClicked); } } @@ -88,14 +88,14 @@ SEL_CCControlHandler HelloCocosBuilderLayer::onResolveCCBCCControlSelector(CCObj } -bool HelloCocosBuilderLayer::onAssignCCBMemberVariable(CCObject * pTarget, const char * pMemberVariableName, CCNode * pNode) { +bool HelloCocosBuilderLayer::onAssignCCBMemberVariable(CCObject * pTarget, CCString * pMemberVariableName, CCNode * pNode) { if(pTarget == this) { - if(strcmp(pMemberVariableName, "mBurstSprite") == 0) { + if(strcmp(pMemberVariableName->getCString(), "mBurstSprite") == 0) { this->mBurstSprite = dynamic_cast(pNode); CC_ASSERT(this->mBurstSprite); this->mBurstSprite->retain(); return true; - } else if(strcmp(pMemberVariableName, "mTestTitleLabel") == 0) { + } else if(strcmp(pMemberVariableName->getCString(), "mTestTitleLabel") == 0) { this->mTestTitleLabelTTF = dynamic_cast(pNode); CC_ASSERT(this->mTestTitleLabelTTF); this->mTestTitleLabelTTF->retain(); @@ -107,26 +107,26 @@ bool HelloCocosBuilderLayer::onAssignCCBMemberVariable(CCObject * pTarget, const void HelloCocosBuilderLayer::onMenuTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - printf("onMenuTestClicked\n"); + CCLOG("onMenuTestClicked\n"); } void HelloCocosBuilderLayer::onSpriteTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - printf("onSpriteTestClicked\n"); + CCLOG("onSpriteTestClicked\n"); } void HelloCocosBuilderLayer::onButtonTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - printf("onButtonTestClicked\n"); + CCLOG("onButtonTestClicked\n"); this->openTest("ccb/ButtonTest.ccbi", "ButtonTestLayer", ButtonTestLayerLoader::loader()); } void HelloCocosBuilderLayer::onLabelTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - printf("onLabelTestClicked\n"); + CCLOG("onLabelTestClicked\n"); } void HelloCocosBuilderLayer::onParticleSystemTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - printf("onParticleSystemTestClicked\n"); + CCLOG("onParticleSystemTestClicked\n"); } void HelloCocosBuilderLayer::onScrollViewTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - printf("onScrollViewTestClicked\n"); + CCLOG("onScrollViewTestClicked\n"); } \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.h index 1332a520a9..9001cbbb98 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.h @@ -23,9 +23,9 @@ class HelloCocosBuilderLayer : public cocos2d::extension::CCBSelectorResolver, p void openTest(const char * pCCBFileName, const char * pCCNodeName = NULL, cocos2d::extension::CCNodeLoader * pCCNodeLoader = NULL); - virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(cocos2d::CCObject * pTarget, const char * pSelectorName); - virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, const char * pSelectorName); - virtual bool onAssignCCBMemberVariable(cocos2d::CCObject * pTarget, const char * pMemberVariableName, cocos2d::CCNode * pNode); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); + virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); + virtual bool onAssignCCBMemberVariable(cocos2d::CCObject * pTarget, cocos2d::CCString * pMemberVariableName, cocos2d::CCNode * pNode); virtual void onNodeLoaded(cocos2d::CCNode * pNode, cocos2d::extension::CCNodeLoader * pNodeLoader); virtual void onMenuTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.cpp index 68198bfb54..ab17519682 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.cpp +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.cpp @@ -15,16 +15,16 @@ TestHeaderLayer * TestHeaderLayer::node() { return NULL; } -SEL_MenuHandler TestHeaderLayer::onResolveCCBCCMenuSelector(CCObject * pTarget, const char * pSelectorName) { +SEL_MenuHandler TestHeaderLayer::onResolveCCBCCMenuSelector(CCObject * pTarget, CCString * pSelectorName) { if(pTarget == this) { - if(strcmp(pSelectorName, "onBackClicked") == 0) { + if(pSelectorName->compare("onBackClicked") == 0) { return menu_selector(TestHeaderLayer::onBackClicked); } } return NULL; } -SEL_CCControlHandler TestHeaderLayer::onResolveCCBCCControlSelector(CCObject * pTarget, const char * pSelectorName) { +SEL_CCControlHandler TestHeaderLayer::onResolveCCBCCControlSelector(CCObject * pTarget, CCString * pSelectorName) { return NULL; } diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.h index 3b04f2ea4e..4470d8acf3 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.h @@ -9,8 +9,8 @@ class TestHeaderLayer : public cocos2d::extension::CCBSelectorResolver, public c public: static TestHeaderLayer * node(); - virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(cocos2d::CCObject * pTarget, const char * pSelectorName); - virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, const char * pSelectorName); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); + virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); virtual void onBackClicked(cocos2d::CCObject * pSender); }; From 3f7b44fc23f91b310c33dd8ef2234c8fd9207a1f Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 14 Jun 2012 15:13:16 +0800 Subject: [PATCH 160/257] issue #1324: Added create() for static member functions that new an autorelease object --- HelloWorld/Classes/HelloWorldScene.cpp | 10 +- HelloWorld/Classes/HelloWorldScene.h | 2 +- cocos2dx/actions/CCAction.cpp | 122 ++-- cocos2dx/actions/CCAction.h | 38 +- cocos2dx/actions/CCActionCamera.cpp | 16 +- cocos2dx/actions/CCActionCamera.h | 8 +- cocos2dx/actions/CCActionCatmullRom.cpp | 166 +++++- cocos2dx/actions/CCActionCatmullRom.h | 45 +- cocos2dx/actions/CCActionEase.cpp | 558 ++++++++++++++---- cocos2dx/actions/CCActionEase.h | 155 +++-- cocos2dx/actions/CCActionGrid.cpp | 120 +++- cocos2dx/actions/CCActionGrid.h | 51 +- cocos2dx/actions/CCActionGrid3D.cpp | 191 +++++- cocos2dx/actions/CCActionGrid3D.h | 64 +- cocos2dx/actions/CCActionInstant.cpp | 149 ++++- cocos2dx/actions/CCActionInstant.h | 77 ++- cocos2dx/actions/CCActionInterval.cpp | 480 +++++++++++++-- cocos2dx/actions/CCActionInterval.h | 229 +++++-- cocos2dx/actions/CCActionPageTurn3D.cpp | 21 +- cocos2dx/actions/CCActionPageTurn3D.h | 6 +- cocos2dx/actions/CCActionProgressTimer.cpp | 24 +- cocos2dx/actions/CCActionProgressTimer.h | 14 +- cocos2dx/actions/CCActionTiledGrid.cpp | 268 ++++++++- cocos2dx/actions/CCActionTiledGrid.h | 95 ++- cocos2dx/actions/CCActionTween.cpp | 18 +- cocos2dx/actions/CCActionTween.h | 7 +- cocos2dx/base_nodes/CCAtlasNode.cpp | 26 +- cocos2dx/base_nodes/CCAtlasNode.h | 12 +- cocos2dx/base_nodes/CCNode.cpp | 18 +- cocos2dx/base_nodes/CCNode.h | 10 +- cocos2dx/cocoa/CCArray.cpp | 5 +- cocos2dx/cocoa/CCDictionary.cpp | 10 +- cocos2dx/cocoa/CCGeometry.cpp | 21 + cocos2dx/cocoa/CCGeometry.h | 4 + cocos2dx/effects/CCGrid.cpp | 14 +- cocos2dx/effects/CCGrid.h | 16 +- .../extensions/CCBReader/CCBReader_v2.cpp | 40 +- .../extensions/CCControlExtension/CCControl.h | 2 +- .../CCControlExtension/CCControlButton.cpp | 29 +- .../CCControlExtension/CCControlButton.h | 15 +- .../CCControlColourPicker.cpp | 13 +- .../CCControlColourPicker.h | 6 +- .../CCControlExtension/CCControlHuePicker.cpp | 9 +- .../CCControlExtension/CCControlHuePicker.h | 5 +- .../CCControlSaturationBrightnessPicker.cpp | 7 +- .../CCControlSaturationBrightnessPicker.h | 5 +- .../CCControlExtension/CCControlSlider.cpp | 26 +- .../CCControlExtension/CCControlSlider.h | 22 +- .../CCControlExtension/CCControlSwitch.cpp | 18 +- .../CCControlExtension/CCControlSwitch.h | 16 +- .../CCControlExtension/CCControlUtils.cpp | 2 +- .../CCControlExtension/CCMenuPassive.cpp | 39 +- .../CCControlExtension/CCMenuPassive.h | 23 +- .../CCControlExtension/CCScale9Sprite.cpp | 88 ++- .../CCControlExtension/CCScale9Sprite.h | 103 +++- cocos2dx/extensions/CCListView/CCListView.cpp | 58 +- cocos2dx/extensions/CCListView/CCListView.h | 6 +- .../CCTextureWatcher/CCTextureWatcher.cpp | 32 +- cocos2dx/label_nodes/CCLabelAtlas.cpp | 14 +- cocos2dx/label_nodes/CCLabelAtlas.h | 15 +- cocos2dx/label_nodes/CCLabelBMFont.cpp | 52 +- cocos2dx/label_nodes/CCLabelBMFont.h | 21 +- cocos2dx/label_nodes/CCLabelTTF.cpp | 25 +- cocos2dx/label_nodes/CCLabelTTF.h | 26 +- .../CCLayer.cpp | 62 +- .../layers_scenes_transitions_nodes/CCLayer.h | 133 ++++- .../CCScene.cpp | 7 +- .../layers_scenes_transitions_nodes/CCScene.h | 51 +- .../CCTransition.cpp | 377 ++++++------ .../CCTransition.h | 156 +++-- .../CCTransitionPageTurn.cpp | 27 +- .../CCTransitionPageTurn.h | 10 +- .../CCTransitionProgress.cpp | 33 +- .../CCTransitionProgress.h | 14 +- cocos2dx/menu_nodes/CCMenu.cpp | 45 +- cocos2dx/menu_nodes/CCMenu.h | 32 +- cocos2dx/menu_nodes/CCMenuItem.cpp | 183 +++++- cocos2dx/menu_nodes/CCMenuItem.h | 112 +++- cocos2dx/misc_nodes/CCMotionStreak.cpp | 16 +- cocos2dx/misc_nodes/CCMotionStreak.h | 15 +- cocos2dx/misc_nodes/CCProgressTimer.cpp | 9 +- cocos2dx/misc_nodes/CCProgressTimer.h | 9 +- cocos2dx/misc_nodes/CCRenderTexture.cpp | 24 +- cocos2dx/misc_nodes/CCRenderTexture.h | 21 +- .../particle_nodes/CCParticleBatchNode.cpp | 40 +- cocos2dx/particle_nodes/CCParticleBatchNode.h | 21 +- cocos2dx/particle_nodes/CCParticleExamples.h | 71 ++- cocos2dx/particle_nodes/CCParticleSystem.cpp | 7 +- cocos2dx/particle_nodes/CCParticleSystem.h | 10 +- .../particle_nodes/CCParticleSystemQuad.cpp | 7 +- .../particle_nodes/CCParticleSystemQuad.h | 8 +- cocos2dx/sprite_nodes/CCAnimation.cpp | 41 +- cocos2dx/sprite_nodes/CCAnimation.h | 31 +- cocos2dx/sprite_nodes/CCAnimationCache.cpp | 2 +- cocos2dx/sprite_nodes/CCSprite.cpp | 61 +- cocos2dx/sprite_nodes/CCSprite.h | 60 +- cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp | 34 +- cocos2dx/sprite_nodes/CCSpriteBatchNode.h | 26 +- cocos2dx/sprite_nodes/CCSpriteFrame.cpp | 28 +- cocos2dx/sprite_nodes/CCSpriteFrame.h | 33 +- .../tileMap_parallax_nodes/CCParallaxNode.cpp | 9 +- .../tileMap_parallax_nodes/CCParallaxNode.h | 4 +- .../tileMap_parallax_nodes/CCTMXLayer.cpp | 7 +- cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h | 8 +- .../tileMap_parallax_nodes/CCTMXTiledMap.cpp | 16 +- .../tileMap_parallax_nodes/CCTMXTiledMap.h | 14 +- .../tileMap_parallax_nodes/CCTileMapAtlas.cpp | 7 +- .../tileMap_parallax_nodes/CCTileMapAtlas.h | 9 +- tests/AppDelegate.cpp | 2 +- .../AccelerometerTest/AccelerometerTest.cpp | 4 +- .../ActionManagerTest/ActionManagerTest.cpp | 60 +- .../tests/ActionsEaseTest/ActionsEaseTest.cpp | 254 ++++---- .../ActionsProgressTest.cpp | 126 ++-- tests/tests/ActionsTest/ActionsTest.cpp | 408 ++++++------- tests/tests/Box2DTest/Box2dTest.cpp | 10 +- tests/tests/Box2DTestBed/Box2dView.cpp | 12 +- tests/tests/BugsTest/Bug-1159.cpp | 22 +- tests/tests/BugsTest/Bug-1159.h | 2 +- tests/tests/BugsTest/Bug-350.cpp | 2 +- tests/tests/BugsTest/Bug-422.cpp | 6 +- tests/tests/BugsTest/Bug-458/Bug-458.cpp | 10 +- .../Bug-458/QuestionContainerSprite.cpp | 20 +- tests/tests/BugsTest/Bug-624.cpp | 16 +- tests/tests/BugsTest/Bug-624.h | 4 +- tests/tests/BugsTest/Bug-886.cpp | 4 +- tests/tests/BugsTest/Bug-899.cpp | 2 +- tests/tests/BugsTest/Bug-914.cpp | 12 +- tests/tests/BugsTest/Bug-914.h | 2 +- tests/tests/BugsTest/BugsTest.cpp | 10 +- .../ChipmunkAccelTouchTest.cpp | 10 +- .../ClickAndMoveTest/ClickAndMoveTest.cpp | 18 +- .../CocosDenshionTest/CocosDenshionTest.cpp | 8 +- tests/tests/CurlTest/CurlTest.cpp | 4 +- .../CurrentLanguageTest.cpp | 4 +- .../EffectsAdvancedTest.cpp | 98 +-- tests/tests/EffectsTest/EffectsTest.cpp | 201 ++++--- tests/tests/EffectsTest/EffectsTest.h | 4 +- .../CocosBuilderTest/HelloCocosBuilder.cpp | 6 +- .../CCControlButtonTest.cpp | 36 +- .../CCControlButtonTest/CCControlButtonTest.h | 6 +- .../CCControlColourPickerTest.cpp | 8 +- .../CCControlColourPickerTest.h | 2 +- .../ControlExtensionTest/CCControlScene.cpp | 18 +- .../ControlExtensionTest/CCControlScene.h | 6 +- .../CCControlSliderTest.cpp | 4 +- .../CCControlSliderTest/CCControlSliderTest.h | 2 +- .../CCControlSwitchTest.cpp | 20 +- .../CCControlSwitchTest/CCControlSwitchTest.h | 2 +- tests/tests/ExtensionsTest/ExtensionsTest.cpp | 4 +- .../NotificationCenterTest.cpp | 30 +- tests/tests/FontTest/FontTest.cpp | 24 +- tests/tests/FontTest/FontTest.h | 2 +- tests/tests/IntervalTest/IntervalTest.cpp | 24 +- tests/tests/KeypadTest/KeypadTest.cpp | 4 +- tests/tests/LabelTest/LabelTest.cpp | 180 +++--- tests/tests/LayerTest/LayerTest.cpp | 86 +-- tests/tests/MenuTest/MenuTest.cpp | 140 ++--- .../MotionStreakTest/MotionStreakTest.cpp | 60 +- tests/tests/MutiTouchTest/MutiTouchTest.cpp | 2 +- tests/tests/MutiTouchTest/MutiTouchTest.h | 2 +- tests/tests/NodeTest/NodeTest.cpp | 186 +++--- tests/tests/ParallaxTest/ParallaxTest.cpp | 34 +- tests/tests/ParticleTest/ParticleTest.cpp | 116 ++-- .../PerformanceNodeChildrenTest.cpp | 26 +- .../PerformanceParticleTest.cpp | 16 +- .../PerformanceTest/PerformanceSpriteTest.cpp | 54 +- .../tests/PerformanceTest/PerformanceTest.cpp | 14 +- .../PerformanceTextureTest.cpp | 6 +- .../PerformanceTouchesTest.cpp | 8 +- .../RenderTextureTest/RenderTextureTest.cpp | 74 +-- .../tests/RotateWorldTest/RotateWorldTest.cpp | 40 +- tests/tests/RotateWorldTest/RotateWorldTest.h | 24 +- tests/tests/SceneTest/SceneTest.cpp | 56 +- tests/tests/SceneTest/SceneTest.h | 2 +- tests/tests/SchedulerTest/SchedulerTest.cpp | 70 +-- tests/tests/ShaderTest/ShaderTest.cpp | 26 +- tests/tests/ShaderTest/ShaderTest.h | 2 +- .../SpriteTest/SpriteTest.cpp.REMOVED.git-id | 2 +- tests/tests/TextInputTest/TextInputTest.cpp | 50 +- tests/tests/Texture2dTest/Texture2dTest.cpp | 182 +++--- .../TextureCacheTest/TextureCacheTest.cpp | 44 +- tests/tests/TileMapTest/TileMapTest.cpp | 146 ++--- tests/tests/TouchesTest/TouchesTest.cpp | 2 +- .../tests/TransitionsTest/TransitionsTest.cpp | 170 +++--- .../tests/UserDefaultTest/UserDefaultTest.cpp | 2 +- tests/tests/ZwoptexTest/ZwoptexTest.cpp | 26 +- tests/tests/ZwoptexTest/ZwoptexTest.h | 2 +- tests/tests/controller.cpp | 12 +- tests/tests/testBasic.cpp | 10 +- 189 files changed, 6098 insertions(+), 2984 deletions(-) diff --git a/HelloWorld/Classes/HelloWorldScene.cpp b/HelloWorld/Classes/HelloWorldScene.cpp index cc7b384e38..6c9581a9c8 100644 --- a/HelloWorld/Classes/HelloWorldScene.cpp +++ b/HelloWorld/Classes/HelloWorldScene.cpp @@ -5,10 +5,10 @@ USING_NS_CC; CCScene* HelloWorld::scene() { // 'scene' is an autorelease object - CCScene *scene = CCScene::node(); + CCScene *scene = CCScene::create(); // 'layer' is an autorelease object - HelloWorld *layer = HelloWorld::node(); + HelloWorld *layer = HelloWorld::create(); // add layer as a child to scene scene->addChild(layer); @@ -32,7 +32,7 @@ bool HelloWorld::init() // you may modify it. // add a "close" icon to exit the progress. it's an autorelease object - CCMenuItemImage *pCloseItem = CCMenuItemImage::itemWithNormalImage( + CCMenuItemImage *pCloseItem = CCMenuItemImage::create( "CloseNormal.png", "CloseSelected.png", this, @@ -40,7 +40,7 @@ bool HelloWorld::init() pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) ); // create menu, it's an autorelease object - CCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, NULL); + CCMenu* pMenu = CCMenu::create(pCloseItem, NULL); pMenu->setPosition( CCPointZero ); this->addChild(pMenu, 1); @@ -49,7 +49,7 @@ bool HelloWorld::init() // add a label shows "Hello World" // create and initialize a label - CCLabelTTF* pLabel = CCLabelTTF::labelWithString("Hello World", "Arial", 24); + CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24); // ask director the window size CCSize size = CCDirector::sharedDirector()->getWinSize(); diff --git a/HelloWorld/Classes/HelloWorldScene.h b/HelloWorld/Classes/HelloWorldScene.h index 84026c6b1b..4a6be00fcc 100644 --- a/HelloWorld/Classes/HelloWorldScene.h +++ b/HelloWorld/Classes/HelloWorldScene.h @@ -16,7 +16,7 @@ public: virtual void menuCloseCallback(CCObject* pSender); // implement the "static node()" method manually - LAYER_NODE_FUNC(HelloWorld); + LAYER_CREATE_FUNC(HelloWorld); }; #endif // __HELLOWORLD_SCENE_H__ diff --git a/cocos2dx/actions/CCAction.cpp b/cocos2dx/actions/CCAction.cpp index f63b3d3214..2d0bf2d621 100644 --- a/cocos2dx/actions/CCAction.cpp +++ b/cocos2dx/actions/CCAction.cpp @@ -48,7 +48,14 @@ CCAction::~CCAction() CCLOGINFO("cocos2d: deallocing"); } -CCAction * CCAction::action() +//cjh CCAction * CCAction::action() +// { +// CCAction * pRet = new CCAction(); +// pRet->autorelease(); +// return pRet; +// } + +CCAction* CCAction::create() { CCAction * pRet = new CCAction(); pRet->autorelease(); @@ -124,7 +131,19 @@ CCSpeed::~CCSpeed() CC_SAFE_RELEASE(m_pInnerAction); } -CCSpeed * CCSpeed::actionWithAction(CCActionInterval *pAction, float fSpeed) +//cjh CCSpeed * CCSpeed::actionWithAction(CCActionInterval *pAction, float fSpeed) +// { +// CCSpeed *pRet = new CCSpeed(); +// if (pRet && pRet->initWithAction(pAction, fSpeed)) +// { +// pRet->autorelease(); +// return pRet; +// } +// CC_SAFE_DELETE(pRet); +// return NULL; +// } + +CCSpeed* CCSpeed::create(CCActionInterval* pAction, float fSpeed) { CCSpeed *pRet = new CCSpeed(); if (pRet && pRet->initWithAction(pAction, fSpeed)) @@ -190,7 +209,7 @@ bool CCSpeed::isDone() CCActionInterval *CCSpeed::reverse() { - return (CCActionInterval*)(CCSpeed::actionWithAction(m_pInnerAction->reverse(), m_fSpeed)); + return (CCActionInterval*)(CCSpeed::create(m_pInnerAction->reverse(), m_fSpeed)); } void CCSpeed::setInnerAction(CCActionInterval *pAction) @@ -211,18 +230,19 @@ CCFollow::~CCFollow() CC_SAFE_RELEASE(m_pobFollowedNode); } -CCFollow *CCFollow::actionWithTarget(CCNode *pFollowedNode) -{ - CCFollow *pRet = new CCFollow(); - if (pRet && pRet->initWithTarget(pFollowedNode)) - { - pRet->autorelease(); - return pRet; - } - CC_SAFE_DELETE(pRet); - return NULL; -} -CCFollow *CCFollow::actionWithTarget(CCNode *pFollowedNode, const CCRect& rect) +//cjh CCFollow *CCFollow::actionWithTarget(CCNode *pFollowedNode, const CCRect& rect/* = CCRectZero*/) +// { +// CCFollow *pRet = new CCFollow(); +// if (pRet && pRet->initWithTarget(pFollowedNode, rect)) +// { +// pRet->autorelease(); +// return pRet; +// } +// CC_SAFE_DELETE(pRet); +// return NULL; +// } + +CCFollow* CCFollow::create(CCNode *pFollowedNode, const CCRect& rect/* = CCRectZero*/) { CCFollow *pRet = new CCFollow(); if (pRet && pRet->initWithTarget(pFollowedNode, rect)) @@ -234,56 +254,56 @@ CCFollow *CCFollow::actionWithTarget(CCNode *pFollowedNode, const CCRect& rect) return NULL; } -bool CCFollow::initWithTarget(CCNode *pFollowedNode) +bool CCFollow::initWithTarget(CCNode *pFollowedNode, const CCRect& rect/* = CCRectZero*/) { CCAssert(pFollowedNode != NULL, ""); + pFollowedNode->retain(); m_pobFollowedNode = pFollowedNode; - m_bBoundarySet = false; - m_bBoundaryFullyCovered = false; - - CCSize winSize = CCDirector::sharedDirector()->getWinSize(); - m_obFullScreenSize = CCPointMake(winSize.width, winSize.height); - m_obHalfScreenSize = ccpMult(m_obFullScreenSize, 0.5f); - return true; -} - -bool CCFollow::initWithTarget(CCNode *pFollowedNode, const CCRect& rect) -{ - CCAssert(pFollowedNode != NULL, ""); - pFollowedNode->retain(); - m_pobFollowedNode = pFollowedNode; - m_bBoundarySet = true; + if (CCRect::CCRectEqualToRect(rect, CCRectZero)) + { + m_bBoundarySet = false; + } + else + { + m_bBoundarySet = true; + } + m_bBoundaryFullyCovered = false; CCSize winSize = CCDirector::sharedDirector()->getWinSize(); m_obFullScreenSize = CCPointMake(winSize.width, winSize.height); m_obHalfScreenSize = ccpMult(m_obFullScreenSize, 0.5f); - m_fLeftBoundary = -((rect.origin.x+rect.size.width) - m_obFullScreenSize.x); - m_fRightBoundary = -rect.origin.x ; - m_fTopBoundary = -rect.origin.y; - m_fBottomBoundary = -((rect.origin.y+rect.size.height) - m_obFullScreenSize.y); + if (m_bBoundarySet) + { + m_fLeftBoundary = -((rect.origin.x+rect.size.width) - m_obFullScreenSize.x); + m_fRightBoundary = -rect.origin.x ; + m_fTopBoundary = -rect.origin.y; + m_fBottomBoundary = -((rect.origin.y+rect.size.height) - m_obFullScreenSize.y); - if(m_fRightBoundary < m_fLeftBoundary) - { - // screen width is larger than world's boundary width - //set both in the middle of the world - m_fRightBoundary = m_fLeftBoundary = (m_fLeftBoundary + m_fRightBoundary) / 2; - } - if(m_fTopBoundary < m_fBottomBoundary) - { - // screen width is larger than world's boundary width - //set both in the middle of the world - m_fTopBoundary = m_fBottomBoundary = (m_fTopBoundary + m_fBottomBoundary) / 2; - } + if(m_fRightBoundary < m_fLeftBoundary) + { + // screen width is larger than world's boundary width + //set both in the middle of the world + m_fRightBoundary = m_fLeftBoundary = (m_fLeftBoundary + m_fRightBoundary) / 2; + } + if(m_fTopBoundary < m_fBottomBoundary) + { + // screen width is larger than world's boundary width + //set both in the middle of the world + m_fTopBoundary = m_fBottomBoundary = (m_fTopBoundary + m_fBottomBoundary) / 2; + } - if( (m_fTopBoundary == m_fBottomBoundary) && (m_fLeftBoundary == m_fRightBoundary) ) - { - m_bBoundaryFullyCovered = true; + if( (m_fTopBoundary == m_fBottomBoundary) && (m_fLeftBoundary == m_fRightBoundary) ) + { + m_bBoundaryFullyCovered = true; + } } + return true; } + CCObject *CCFollow::copyWithZone(CCZone *pZone) { CCZone *pNewZone = NULL; @@ -303,6 +323,7 @@ CCObject *CCFollow::copyWithZone(CCZone *pZone) CC_SAFE_DELETE(pNewZone); return pRet; } + void CCFollow::step(float dt) { CC_UNUSED_PARAM(dt); @@ -328,6 +349,7 @@ bool CCFollow::isDone() { return ( !m_pobFollowedNode->getIsRunning() ); } + void CCFollow::stop() { m_pTarget = NULL; diff --git a/cocos2dx/actions/CCAction.h b/cocos2dx/actions/CCAction.h index 62cd64f3b5..750a2684c0 100644 --- a/cocos2dx/actions/CCAction.h +++ b/cocos2dx/actions/CCAction.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. @@ -91,9 +91,13 @@ public: inline void setTag(int nTag) { m_nTag = nTag; } public: - /** Allocates and initializes the action */ - static CCAction* action(); + /** Allocates and initializes the action + @warning: This interface will be deprecated in future. + */ + //static CCAction* action(); + /** Create an action */ + static CCAction* create(); protected: CCNode *m_pOriginalTarget; /** The "target". @@ -174,9 +178,13 @@ public: } public: - /** creates the action */ - static CCSpeed* actionWithAction(CCActionInterval *pAction, float fSpeed); + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCSpeed* actionWithAction(CCActionInterval *pAction, float fSpeed); + /** create the action */ + static CCSpeed* create(CCActionInterval* pAction, float fSpeed); protected: float m_fSpeed; CCActionInterval *m_pInnerAction; @@ -209,11 +217,8 @@ public: /** alter behavior - turn on/off boundary */ inline void setBoudarySet(bool bValue) { m_bBoundarySet = bValue; } - /** initializes the action */ - bool initWithTarget(CCNode *pFollowedNode); - /** initializes the action with a set boundary */ - bool initWithTarget(CCNode *pFollowedNode, const CCRect& rect); + bool initWithTarget(CCNode *pFollowedNode, const CCRect& rect = CCRectZero); virtual CCObject* copyWithZone(CCZone *pZone); virtual void step(float dt); @@ -221,12 +226,15 @@ public: virtual void stop(void); public: - /** creates the action with no boundary set */ - static CCFollow* actionWithTarget(CCNode *pFollowedNode); - - /** creates the action with a set boundary */ - static CCFollow* actionWithTarget(CCNode *pFollowedNode, const CCRect& rect); - + /** creates the action with a set boundary, + It will work with no boundary if @param rect is equal to CCRectZero. + @warning: This interface will be deprecated in future. + */ + //static CCFollow* actionWithTarget(CCNode *pFollowedNode, const CCRect& rect = CCRectZero); + /** creates the action with a set boundary, + It will work with no boundary if @param rect is equal to CCRectZero. + */ + static CCFollow* create(CCNode *pFollowedNode, const CCRect& rect = CCRectZero); protected: // node to follow CCNode *m_pobFollowedNode; diff --git a/cocos2dx/actions/CCActionCamera.cpp b/cocos2dx/actions/CCActionCamera.cpp index 2f279cc689..d871f9d71c 100644 --- a/cocos2dx/actions/CCActionCamera.cpp +++ b/cocos2dx/actions/CCActionCamera.cpp @@ -45,12 +45,24 @@ void CCActionCamera::startWithTarget(CCNode *pTarget) CCActionInterval * CCActionCamera::reverse() { - return CCReverseTime::actionWithAction(this); + return CCReverseTime::create(this); } // // CCOrbitCamera // -CCOrbitCamera * CCOrbitCamera::actionWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX) +//cjh CCOrbitCamera * CCOrbitCamera::actionWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX) +// { +// CCOrbitCamera * pRet = new CCOrbitCamera(); +// if(pRet->initWithDuration(t, radius, deltaRadius, angleZ, deltaAngleZ, angleX, deltaAngleX)) +// { +// pRet->autorelease(); +// return pRet; +// } +// CC_SAFE_DELETE(pRet); +// return NULL; +// } + +CCOrbitCamera * CCOrbitCamera::create(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX) { CCOrbitCamera * pRet = new CCOrbitCamera(); if(pRet->initWithDuration(t, radius, deltaRadius, angleZ, deltaAngleZ, angleX, deltaAngleX)) diff --git a/cocos2dx/actions/CCActionCamera.h b/cocos2dx/actions/CCActionCamera.h index fc4d6459d2..38f46151cb 100644 --- a/cocos2dx/actions/CCActionCamera.h +++ b/cocos2dx/actions/CCActionCamera.h @@ -87,8 +87,14 @@ public: , m_fRadDeltaX(0.0) {} ~CCOrbitCamera(){} + /** creates a CCOrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX + @warning: This interface will be deprecated in future. + */ + //static CCOrbitCamera* actionWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX); + /** creates a CCOrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX */ - static CCOrbitCamera * actionWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX); + static CCOrbitCamera* create(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX); + /** initializes a CCOrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX */ bool initWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX); /** positions the camera according to spherical coordinates */ diff --git a/cocos2dx/actions/CCActionCatmullRom.cpp b/cocos2dx/actions/CCActionCatmullRom.cpp index e7f54cce4e..ee6060cee8 100644 --- a/cocos2dx/actions/CCActionCatmullRom.cpp +++ b/cocos2dx/actions/CCActionCatmullRom.cpp @@ -35,6 +35,7 @@ #include "ccMacros.h" #include "support/CCPointExtension.h" #include "CCActionCatmullRom.h" +#include "CCZone.h" using namespace std; @@ -43,7 +44,26 @@ NS_CC_BEGIN; /* * Implementation of CCPointArray */ -CCPointArray* CCPointArray::arrayWithCapacity(unsigned int capacity) +//cjh CCPointArray* CCPointArray::arrayWithCapacity(unsigned int capacity) +// { +// CCPointArray* ret = new CCPointArray(); +// if (ret) +// { +// if (ret->initWithCapacity(capacity)) +// { +// ret->autorelease(); +// } +// else +// { +// delete ret; +// ret = NULL; +// } +// } +// +// return ret; +// } + +CCPointArray* CCPointArray::create(unsigned int capacity) { CCPointArray* ret = new CCPointArray(); if (ret) @@ -58,10 +78,11 @@ CCPointArray* CCPointArray::arrayWithCapacity(unsigned int capacity) ret = NULL; } } - + return ret; } + bool CCPointArray::initWithCapacity(unsigned int capacity) { m_pControlPoints = new CCArray(capacity); @@ -71,15 +92,8 @@ bool CCPointArray::initWithCapacity(unsigned int capacity) CCObject* CCPointArray::copyWithZone(cocos2d::CCZone *zone) { - CCArray *newArray = new CCArray(); - - CCObject* pObj = NULL; - CCARRAY_FOREACH(m_pControlPoints, pObj) - { - newArray->addObject(pObj); - } - - CCPointArray *points = CCPointArray::arrayWithCapacity(10); + CCArray *newArray = (CCArray*)m_pControlPoints->copy(); + CCPointArray *points = CCPointArray::create(10); points->retain(); points->setControlPoints(newArray); newArray->release(); @@ -158,7 +172,7 @@ CCPointArray* CCPointArray::reverse() { newArray->addObject(m_pControlPoints->objectAtIndex(i)); } - CCPointArray *config = CCPointArray::arrayWithCapacity(0); + CCPointArray *config = CCPointArray::create(0); config->setControlPoints(newArray); newArray->release(); @@ -199,7 +213,25 @@ CCPoint ccCardinalSplineAt(CCPoint &p0, CCPoint &p1, CCPoint &p2, CCPoint &p3, f /* Implementation of CCCardinalSplineTo */ -CCCardinalSplineTo* CCCardinalSplineTo::actionWithDuration(float duration, cocos2d::CCPointArray *points, float tension) +//cjh CCCardinalSplineTo* CCCardinalSplineTo::actionWithDuration(float duration, cocos2d::CCPointArray *points, float tension) +// { +// CCCardinalSplineTo *ret = new CCCardinalSplineTo(); +// if (ret) +// { +// if (ret->initWithDuration(duration, points, tension)) +// { +// ret->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(ret); +// } +// } +// +// return ret; +// } + +CCCardinalSplineTo* CCCardinalSplineTo::create(float duration, cocos2d::CCPointArray *points, float tension) { CCCardinalSplineTo *ret = new CCCardinalSplineTo(); if (ret) @@ -213,7 +245,7 @@ CCCardinalSplineTo* CCCardinalSplineTo::actionWithDuration(float duration, cocos CC_SAFE_RELEASE_NULL(ret); } } - + return ret; } @@ -253,8 +285,24 @@ void CCCardinalSplineTo::startWithTarget(cocos2d::CCNode *pTarget) CCCardinalSplineTo* CCCardinalSplineTo::copyWithZone(cocos2d::CCZone *pZone) { - CCCardinalSplineTo *copy = CCCardinalSplineTo::actionWithDuration(this->getDuration(), this->m_pPoints, this->m_fTension); - return copy; + CCZone* pNewZone = NULL; + CCCardinalSplineTo* pRet = NULL; + if(pZone && pZone->m_pCopyObject) //in case of being called at sub class + { + pRet = (CCCardinalSplineTo*)(pZone->m_pCopyObject); + } + else + { + pRet = new CCCardinalSplineTo(); + pZone = pNewZone = new CCZone(pRet); + } + + CCActionInterval::copyWithZone(pZone); + + pRet->initWithDuration(this->getDuration(), this->m_pPoints, this->m_fTension); + + CC_SAFE_DELETE(pNewZone); + return pRet; } void CCCardinalSplineTo::update(float time) @@ -292,15 +340,33 @@ void CCCardinalSplineTo::updatePosition(cocos2d::CCPoint &newPos) CCActionInterval* CCCardinalSplineTo::reverse() { - CCPointArray *reverse = m_pPoints->reverse(); + CCPointArray *pReverse = m_pPoints->reverse(); - return CCCardinalSplineTo::actionWithDuration(m_fDuration, reverse, m_fTension); + return CCCardinalSplineTo::create(m_fDuration, pReverse, m_fTension); } /* CCCardinalSplineBy */ -CCCardinalSplineBy* CCCardinalSplineBy::actionWithDuration(float duration, cocos2d::CCPointArray *points, float tension) +//cjh CCCardinalSplineBy* CCCardinalSplineBy::actionWithDuration(float duration, cocos2d::CCPointArray *points, float tension) +// { +// CCCardinalSplineBy *ret = new CCCardinalSplineBy(); +// if (ret) +// { +// if (ret->initWithDuration(duration, points, tension)) +// { +// ret->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(ret); +// } +// } +// +// return ret; +// } + +CCCardinalSplineBy* CCCardinalSplineBy::create(float duration, cocos2d::CCPointArray *points, float tension) { CCCardinalSplineBy *ret = new CCCardinalSplineBy(); if (ret) @@ -314,7 +380,7 @@ CCCardinalSplineBy* CCCardinalSplineBy::actionWithDuration(float duration, cocos CC_SAFE_RELEASE_NULL(ret); } } - + return ret; } @@ -347,28 +413,28 @@ CCActionInterval* CCCardinalSplineBy::reverse() // convert to "diffs" to "reverse absolute" - CCPointArray *reverse = copyConfig->reverse(); + CCPointArray *pReverse = copyConfig->reverse(); copyConfig->release(); // 1st element (which should be 0,0) should be here too - p = reverse->getControlPointAtIndex(reverse->count()-1); - reverse->removeControlPointAtIndex(reverse->count()-1); + p = pReverse->getControlPointAtIndex(pReverse->count()-1); + pReverse->removeControlPointAtIndex(pReverse->count()-1); p = ccpNeg(p); - reverse->insertControlPoint(p, 0); + pReverse->insertControlPoint(p, 0); - for (unsigned int i = 1; i < reverse->count(); ++i) + for (unsigned int i = 1; i < pReverse->count(); ++i) { - CCPoint current = reverse->getControlPointAtIndex(i); + CCPoint current = pReverse->getControlPointAtIndex(i); current = ccpNeg(current); CCPoint abs = ccpAdd(current, p); - reverse->replaceControlPoint(abs, i); + pReverse->replaceControlPoint(abs, i); p = abs; } - return CCCardinalSplineBy::actionWithDuration(m_fDuration, reverse, m_fTension); + return CCCardinalSplineBy::create(m_fDuration, pReverse, m_fTension); } void CCCardinalSplineBy::startWithTarget(cocos2d::CCNode *pTarget) @@ -379,7 +445,25 @@ void CCCardinalSplineBy::startWithTarget(cocos2d::CCNode *pTarget) /* CCCatmullRomTo */ -CCCatmullRomTo* CCCatmullRomTo::actionWithDuration(float dt, cocos2d::CCPointArray *points) +// CCCatmullRomTo* CCCatmullRomTo::actionWithDuration(float dt, cocos2d::CCPointArray *points) +// { +// CCCatmullRomTo *ret = new CCCatmullRomTo(); +// if (ret) +// { +// if (ret->initWithDuration(dt, points)) +// { +// ret->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(ret); +// } +// } +// +// return ret; +// } + +CCCatmullRomTo* CCCatmullRomTo::create(float dt, cocos2d::CCPointArray *points) { CCCatmullRomTo *ret = new CCCatmullRomTo(); if (ret) @@ -393,7 +477,7 @@ CCCatmullRomTo* CCCatmullRomTo::actionWithDuration(float dt, cocos2d::CCPointArr CC_SAFE_RELEASE_NULL(ret); } } - + return ret; } @@ -409,7 +493,25 @@ bool CCCatmullRomTo::initWithDuration(float dt, cocos2d::CCPointArray *points) /* CCCatmullRomBy */ -CCCatmullRomBy* CCCatmullRomBy::actionWithDuration(float dt, cocos2d::CCPointArray *points) +// CCCatmullRomBy* CCCatmullRomBy::actionWithDuration(float dt, cocos2d::CCPointArray *points) +// { +// CCCatmullRomBy *ret = new CCCatmullRomBy(); +// if (ret) +// { +// if (ret->initWithDuration(dt, points)) +// { +// ret->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(ret); +// } +// } +// +// return ret; +// } + +CCCatmullRomBy* CCCatmullRomBy::create(float dt, cocos2d::CCPointArray *points) { CCCatmullRomBy *ret = new CCCatmullRomBy(); if (ret) @@ -423,7 +525,7 @@ CCCatmullRomBy* CCCatmullRomBy::actionWithDuration(float dt, cocos2d::CCPointArr CC_SAFE_RELEASE_NULL(ret); } } - + return ret; } diff --git a/cocos2dx/actions/CCActionCatmullRom.h b/cocos2dx/actions/CCActionCatmullRom.h index fbb793965b..a86e14e449 100644 --- a/cocos2dx/actions/CCActionCatmullRom.h +++ b/cocos2dx/actions/CCActionCatmullRom.h @@ -49,9 +49,14 @@ NS_CC_BEGIN; class CC_DLL CCPointArray : public CCNode { public: - /** creates and initializes a Points array with capacity */ - static CCPointArray* arrayWithCapacity(unsigned int capacity); + /** creates and initializes a Points array with capacity + @warning: This interface will be deprecated in future. + */ + //static CCPointArray* arrayWithCapacity(unsigned int capacity); + /** creates and initializes a Points array with capacity */ + static CCPointArray* create(unsigned int capacity); + virtual ~CCPointArray(); CCPointArray(); @@ -102,9 +107,14 @@ private: class CC_DLL CCCardinalSplineTo : public CCActionInterval { public: + /** creates an action with a Cardinal Spline array of points and tension + @warning: This interface will be deprecated in future. + */ + //static CCCardinalSplineTo* actionWithDuration(float duration, CCPointArray* points, float tension); + /** creates an action with a Cardinal Spline array of points and tension */ - static CCCardinalSplineTo* actionWithDuration(float duration, CCPointArray* points, float tension); - + static CCCardinalSplineTo* create(float duration, CCPointArray* points, float tension); + virtual ~CCCardinalSplineTo(); CCCardinalSplineTo(); @@ -140,9 +150,14 @@ protected: class CC_DLL CCCardinalSplineBy : public CCCardinalSplineTo { public: - /** creates an action with a Cardinal Spline array of points and tension */ - static CCCardinalSplineBy* actionWithDuration(float duration, CCPointArray* points, float tension); + /** creates an action with a Cardinal Spline array of points and tension + @warning: This interface will be deprecated in future. + */ + //static CCCardinalSplineBy* actionWithDuration(float duration, CCPointArray* points, float tension); + /** creates an action with a Cardinal Spline array of points and tension */ + static CCCardinalSplineBy* create(float duration, CCPointArray* points, float tension); + CCCardinalSplineBy(); virtual void startWithTarget(CCNode *pTarget); @@ -159,9 +174,14 @@ protected: class CC_DLL CCCatmullRomTo : public CCCardinalSplineTo { public: - /** creates an action with a Cardinal Spline array of points and tension */ - static CCCatmullRomTo* actionWithDuration(float dt, CCPointArray* points); + /** creates an action with a Cardinal Spline array of points and tension + @warning: This interface will be deprecated in future. + */ + //static CCCatmullRomTo* actionWithDuration(float dt, CCPointArray* points); + /** creates an action with a Cardinal Spline array of points and tension */ + static CCCatmullRomTo* create(float dt, CCPointArray* points); + /** initializes the action with a duration and an array of points */ bool initWithDuration(float dt, CCPointArray* points); }; @@ -173,9 +193,14 @@ public: class CC_DLL CCCatmullRomBy : public CCCardinalSplineBy { public: - /** creates an action with a Cardinal Spline array of points and tension */ - static CCCatmullRomBy* actionWithDuration(float dt, CCPointArray* points); + /** creates an action with a Cardinal Spline array of points and tension + @warning: This interface will be deprecated in future. + */ + //static CCCatmullRomBy* actionWithDuration(float dt, CCPointArray* points); + /** creates an action with a Cardinal Spline array of points and tension */ + static CCCatmullRomBy* create(float dt, CCPointArray* points); + /** initializes the action with a duration and an array of points */ bool initWithDuration(float dt, CCPointArray* points); }; diff --git a/cocos2dx/actions/CCActionEase.cpp b/cocos2dx/actions/CCActionEase.cpp index aebdbfae13..0f5321c333 100644 --- a/cocos2dx/actions/CCActionEase.cpp +++ b/cocos2dx/actions/CCActionEase.cpp @@ -42,7 +42,25 @@ NS_CC_BEGIN // // EaseAction // -CCActionEase* CCActionEase::actionWithAction(CCActionInterval *pAction) +//cjh CCActionEase* CCActionEase::actionWithAction(CCActionInterval *pAction) +// { +// CCActionEase *pRet = new CCActionEase(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pRet); +// } +// } +// +// return pRet; +// } + +CCActionEase* CCActionEase::create(CCActionInterval *pAction) { CCActionEase *pRet = new CCActionEase(); if (pRet) @@ -122,13 +140,31 @@ void CCActionEase::update(float time) CCActionInterval* CCActionEase::reverse(void) { - return CCActionEase::actionWithAction(m_pOther->reverse()); + return CCActionEase::create(m_pOther->reverse()); } // // EaseRateAction // -CCEaseRateAction* CCEaseRateAction::actionWithAction(CCActionInterval *pAction, float fRate) +//cjh CCEaseRateAction* CCEaseRateAction::actionWithAction(CCActionInterval *pAction, float fRate) +// { +// CCEaseRateAction *pRet = new CCEaseRateAction(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction, fRate)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pRet); +// } +// } +// +// return pRet; +// } + +CCEaseRateAction* CCEaseRateAction::create(CCActionInterval *pAction, float fRate) { CCEaseRateAction *pRet = new CCEaseRateAction(); if (pRet) @@ -184,13 +220,31 @@ CCEaseRateAction::~CCEaseRateAction(void) CCActionInterval* CCEaseRateAction::reverse(void) { - return CCEaseRateAction::actionWithAction(m_pOther->reverse(), 1 / m_fRate); + return CCEaseRateAction::create(m_pOther->reverse(), 1 / m_fRate); } // // EeseIn // -CCEaseIn* CCEaseIn::actionWithAction(CCActionInterval *pAction, float fRate) +//cjh CCEaseIn* CCEaseIn::actionWithAction(CCActionInterval *pAction, float fRate) +// { +// CCEaseIn *pRet = new CCEaseIn(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction, fRate)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pRet); +// } +// } +// +// return pRet; +// } + +CCEaseIn* CCEaseIn::create(CCActionInterval *pAction, float fRate) { CCEaseIn *pRet = new CCEaseIn(); if (pRet) @@ -236,13 +290,31 @@ void CCEaseIn::update(float time) CCActionInterval* CCEaseIn::reverse(void) { - return CCEaseIn::actionWithAction(m_pOther->reverse(), 1 / m_fRate); + return CCEaseIn::create(m_pOther->reverse(), 1 / m_fRate); } // // EaseOut // -CCEaseOut* CCEaseOut::actionWithAction(CCActionInterval *pAction, float fRate) +//cjh CCEaseOut* CCEaseOut::actionWithAction(CCActionInterval *pAction, float fRate) +// { +// CCEaseOut *pRet = new CCEaseOut(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction, fRate)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pRet); +// } +// } +// +// return pRet; +// } + +CCEaseOut* CCEaseOut::create(CCActionInterval *pAction, float fRate) { CCEaseOut *pRet = new CCEaseOut(); if (pRet) @@ -257,7 +329,7 @@ CCEaseOut* CCEaseOut::actionWithAction(CCActionInterval *pAction, float fRate) } } - return pRet; + return pRet; } CCObject* CCEaseOut::copyWithZone(CCZone *pZone) @@ -288,13 +360,31 @@ void CCEaseOut::update(float time) CCActionInterval* CCEaseOut::reverse() { - return CCEaseOut::actionWithAction(m_pOther->reverse(), 1 / m_fRate); + return CCEaseOut::create(m_pOther->reverse(), 1 / m_fRate); } // // EaseInOut // -CCEaseInOut* CCEaseInOut::actionWithAction(CCActionInterval *pAction, float fRate) +//cjh CCEaseInOut* CCEaseInOut::actionWithAction(CCActionInterval *pAction, float fRate) +// { +// CCEaseInOut *pRet = new CCEaseInOut(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction, fRate)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pRet); +// } +// } +// +// return pRet; +// } + +CCEaseInOut* CCEaseInOut::create(CCActionInterval *pAction, float fRate) { CCEaseInOut *pRet = new CCEaseInOut(); if (pRet) @@ -309,7 +399,7 @@ CCEaseInOut* CCEaseInOut::actionWithAction(CCActionInterval *pAction, float fRat } } - return pRet; + return pRet; } CCObject* CCEaseInOut::copyWithZone(CCZone *pZone) @@ -349,13 +439,31 @@ void CCEaseInOut::update(float time) // InOut and OutIn are symmetrical CCActionInterval* CCEaseInOut::reverse(void) { - return CCEaseInOut::actionWithAction(m_pOther->reverse(), m_fRate); + return CCEaseInOut::create(m_pOther->reverse(), m_fRate); } // // EaseExponentialIn // -CCEaseExponentialIn* CCEaseExponentialIn::actionWithAction(CCActionInterval* pAction) +//cjh CCEaseExponentialIn* CCEaseExponentialIn::actionWithAction(CCActionInterval* pAction) +// { +// CCEaseExponentialIn *pRet = new CCEaseExponentialIn(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pRet); +// } +// } +// +// return pRet; +// } + +CCEaseExponentialIn* CCEaseExponentialIn::create(CCActionInterval* pAction) { CCEaseExponentialIn *pRet = new CCEaseExponentialIn(); if (pRet) @@ -370,7 +478,7 @@ CCEaseExponentialIn* CCEaseExponentialIn::actionWithAction(CCActionInterval* pAc } } - return pRet; + return pRet; } CCObject* CCEaseExponentialIn::copyWithZone(CCZone *pZone) @@ -401,13 +509,31 @@ void CCEaseExponentialIn::update(float time) CCActionInterval* CCEaseExponentialIn::reverse(void) { - return CCEaseExponentialOut::actionWithAction(m_pOther->reverse()); + return CCEaseExponentialOut::create(m_pOther->reverse()); } // // EaseExponentialOut // -CCEaseExponentialOut* CCEaseExponentialOut::actionWithAction(CCActionInterval* pAction) +//cjh CCEaseExponentialOut* CCEaseExponentialOut::actionWithAction(CCActionInterval* pAction) +// { +// CCEaseExponentialOut *pRet = new CCEaseExponentialOut(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pRet); +// } +// } +// +// return pRet; +// } + +CCEaseExponentialOut* CCEaseExponentialOut::create(CCActionInterval* pAction) { CCEaseExponentialOut *pRet = new CCEaseExponentialOut(); if (pRet) @@ -453,13 +579,31 @@ void CCEaseExponentialOut::update(float time) CCActionInterval* CCEaseExponentialOut::reverse(void) { - return CCEaseExponentialIn::actionWithAction(m_pOther->reverse()); + return CCEaseExponentialIn::create(m_pOther->reverse()); } // // EaseExponentialInOut // -CCEaseExponentialInOut* CCEaseExponentialInOut::actionWithAction(CCActionInterval *pAction) +//cjh CCEaseExponentialInOut* CCEaseExponentialInOut::actionWithAction(CCActionInterval *pAction) +// { +// CCEaseExponentialInOut *pRet = new CCEaseExponentialInOut(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pRet); +// } +// } +// +// return pRet; +// } + +CCEaseExponentialInOut* CCEaseExponentialInOut::create(CCActionInterval *pAction) { CCEaseExponentialInOut *pRet = new CCEaseExponentialInOut(); if (pRet) @@ -515,13 +659,31 @@ void CCEaseExponentialInOut::update(float time) CCActionInterval* CCEaseExponentialInOut::reverse() { - return CCEaseExponentialInOut::actionWithAction(m_pOther->reverse()); + return CCEaseExponentialInOut::create(m_pOther->reverse()); } // // EaseSineIn // -CCEaseSineIn* CCEaseSineIn::actionWithAction(CCActionInterval* pAction) +//cjh CCEaseSineIn* CCEaseSineIn::actionWithAction(CCActionInterval* pAction) +// { +// CCEaseSineIn *pRet = new CCEaseSineIn(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pRet); +// } +// } +// +// return pRet; +// } + +CCEaseSineIn* CCEaseSineIn::create(CCActionInterval* pAction) { CCEaseSineIn *pRet = new CCEaseSineIn(); if (pRet) @@ -567,13 +729,31 @@ void CCEaseSineIn::update(float time) CCActionInterval* CCEaseSineIn::reverse(void) { - return CCEaseSineOut::actionWithAction(m_pOther->reverse()); + return CCEaseSineOut::create(m_pOther->reverse()); } // // EaseSineOut // -CCEaseSineOut* CCEaseSineOut::actionWithAction(CCActionInterval* pAction) +//cjh CCEaseSineOut* CCEaseSineOut::actionWithAction(CCActionInterval* pAction) +// { +// CCEaseSineOut *pRet = new CCEaseSineOut(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pRet); +// } +// } +// +// return pRet; +// } + +CCEaseSineOut* CCEaseSineOut::create(CCActionInterval* pAction) { CCEaseSineOut *pRet = new CCEaseSineOut(); if (pRet) @@ -619,13 +799,31 @@ void CCEaseSineOut::update(float time) CCActionInterval* CCEaseSineOut::reverse(void) { - return CCEaseSineIn::actionWithAction(m_pOther->reverse()); + return CCEaseSineIn::create(m_pOther->reverse()); } // // EaseSineInOut // -CCEaseSineInOut* CCEaseSineInOut::actionWithAction(CCActionInterval* pAction) +//cjh CCEaseSineInOut* CCEaseSineInOut::actionWithAction(CCActionInterval* pAction) +// { +// CCEaseSineInOut *pRet = new CCEaseSineInOut(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pRet); +// } +// } +// +// return pRet; +// } + +CCEaseSineInOut* CCEaseSineInOut::create(CCActionInterval* pAction) { CCEaseSineInOut *pRet = new CCEaseSineInOut(); if (pRet) @@ -671,31 +869,32 @@ void CCEaseSineInOut::update(float time) CCActionInterval* CCEaseSineInOut::reverse() { - return CCEaseSineInOut::actionWithAction(m_pOther->reverse()); + return CCEaseSineInOut::create(m_pOther->reverse()); } // // EaseElastic // -CCEaseElastic* CCEaseElastic::actionWithAction(CCActionInterval *pAction) -{ - CCEaseElastic *pRet = new CCEaseElastic(); - if (pRet) - { - if (pRet->initWithAction(pAction)) - { - pRet->autorelease(); - } - else - { - CC_SAFE_RELEASE_NULL(pRet); - } - } - return pRet; -} +//cjh CCEaseElastic* CCEaseElastic::actionWithAction(CCActionInterval *pAction, float fPeriod/* = 0.3f*/) +// { +// CCEaseElastic *pRet = new CCEaseElastic(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction, fPeriod)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pRet); +// } +// } +// +// return pRet; +// } -CCEaseElastic* CCEaseElastic::actionWithAction(CCActionInterval *pAction, float fPeriod) +CCEaseElastic* CCEaseElastic::create(CCActionInterval *pAction, float fPeriod/* = 0.3f*/) { CCEaseElastic *pRet = new CCEaseElastic(); if (pRet) @@ -713,12 +912,7 @@ CCEaseElastic* CCEaseElastic::actionWithAction(CCActionInterval *pAction, float return pRet; } -bool CCEaseElastic::initWithAction(CCActionInterval *pAction) -{ - return initWithAction(pAction, 0.3f); -} - -bool CCEaseElastic::initWithAction(CCActionInterval *pAction, float fPeriod) +bool CCEaseElastic::initWithAction(CCActionInterval *pAction, float fPeriod/* = 0.3f*/) { if (CCActionEase::initWithAction(pAction)) { @@ -760,7 +954,25 @@ CCActionInterval* CCEaseElastic::reverse(void) // // EaseElasticIn // -CCEaseElasticIn* CCEaseElasticIn::actionWithAction(CCActionInterval *pAction, float fPeriod) +//cjh CCEaseElasticIn* CCEaseElasticIn::actionWithAction(CCActionInterval *pAction, float fPeriod/* = 0.3f*/) +// { +// CCEaseElasticIn *pRet = new CCEaseElasticIn(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction, fPeriod)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pRet); +// } +// } +// +// return pRet; +// } + +CCEaseElasticIn* CCEaseElasticIn::create(CCActionInterval *pAction, float fPeriod/* = 0.3f*/) { CCEaseElasticIn *pRet = new CCEaseElasticIn(); if (pRet) @@ -778,24 +990,6 @@ CCEaseElasticIn* CCEaseElasticIn::actionWithAction(CCActionInterval *pAction, fl return pRet; } -CCEaseElasticIn* CCEaseElasticIn::actionWithAction(CCActionInterval *pAction) -{ - CCEaseElasticIn *pRet = new CCEaseElasticIn(); - if (pRet) - { - if (pRet->initWithAction(pAction)) - { - pRet->autorelease(); - } - else - { - CC_SAFE_RELEASE_NULL(pRet); - } - } - - return pRet; -} - CCObject* CCEaseElasticIn::copyWithZone(CCZone *pZone) { CCZone* pNewZone = NULL; @@ -836,31 +1030,32 @@ void CCEaseElasticIn::update(float time) CCActionInterval* CCEaseElasticIn::reverse(void) { - return CCEaseElasticOut::actionWithAction(m_pOther->reverse(), m_fPeriod); + return CCEaseElasticOut::create(m_pOther->reverse(), m_fPeriod); } // // EaseElasticOut // -CCEaseElasticOut* CCEaseElasticOut::actionWithAction(CCActionInterval *pAction) -{ - CCEaseElasticOut *pRet = new CCEaseElasticOut(); - if (pRet) - { - if (pRet->initWithAction(pAction)) - { - pRet->autorelease(); - } - else - { - CC_SAFE_RELEASE_NULL(pRet); - } - } - return pRet; -} +//cjh CCEaseElasticOut* CCEaseElasticOut::actionWithAction(CCActionInterval *pAction, float fPeriod/* = 0.3f*/) +// { +// CCEaseElasticOut *pRet = new CCEaseElasticOut(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction, fPeriod)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pRet); +// } +// } +// +// return pRet; +// } -CCEaseElasticOut* CCEaseElasticOut::actionWithAction(CCActionInterval *pAction, float fPeriod) +CCEaseElasticOut* CCEaseElasticOut::create(CCActionInterval *pAction, float fPeriod/* = 0.3f*/) { CCEaseElasticOut *pRet = new CCEaseElasticOut(); if (pRet) @@ -917,31 +1112,32 @@ void CCEaseElasticOut::update(float time) CCActionInterval* CCEaseElasticOut::reverse(void) { - return CCEaseElasticIn::actionWithAction(m_pOther->reverse(), m_fPeriod); + return CCEaseElasticIn::create(m_pOther->reverse(), m_fPeriod); } // // EaseElasticInOut // -CCEaseElasticInOut* CCEaseElasticInOut::actionWithAction(CCActionInterval *pAction) -{ - CCEaseElasticInOut *pRet = new CCEaseElasticInOut(); - if (pRet) - { - if (pRet->initWithAction(pAction)) - { - pRet->autorelease(); - } - else - { - CC_SAFE_RELEASE_NULL(pRet); - } - } - return pRet; -} +//cjh CCEaseElasticInOut* CCEaseElasticInOut::actionWithAction(CCActionInterval *pAction, float fPeriod/* = 0.3f*/) +// { +// CCEaseElasticInOut *pRet = new CCEaseElasticInOut(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction, fPeriod)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pRet); +// } +// } +// +// return pRet; +// } -CCEaseElasticInOut* CCEaseElasticInOut::actionWithAction(CCActionInterval *pAction, float fPeriod) +CCEaseElasticInOut* CCEaseElasticInOut::create(CCActionInterval *pAction, float fPeriod/* = 0.3f*/) { CCEaseElasticInOut *pRet = new CCEaseElasticInOut(); if (pRet) @@ -1014,13 +1210,31 @@ void CCEaseElasticInOut::update(float time) CCActionInterval* CCEaseElasticInOut::reverse(void) { - return CCEaseElasticInOut::actionWithAction(m_pOther->reverse(), m_fPeriod); + return CCEaseElasticInOut::create(m_pOther->reverse(), m_fPeriod); } // // EaseBounce // -CCEaseBounce* CCEaseBounce::actionWithAction(CCActionInterval* pAction) +//cjh CCEaseBounce* CCEaseBounce::actionWithAction(CCActionInterval* pAction) +// { +// CCEaseBounce *pRet = new CCEaseBounce(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pRet); +// } +// } +// +// return pRet; +// } + +CCEaseBounce* CCEaseBounce::create(CCActionInterval* pAction) { CCEaseBounce *pRet = new CCEaseBounce(); if (pRet) @@ -1082,13 +1296,31 @@ float CCEaseBounce::bounceTime(float time) CCActionInterval* CCEaseBounce::reverse() { - return CCEaseBounce::actionWithAction(m_pOther->reverse()); + return CCEaseBounce::create(m_pOther->reverse()); } // // EaseBounceIn // -CCEaseBounceIn* CCEaseBounceIn::actionWithAction(CCActionInterval* pAction) +//cjh CCEaseBounceIn* CCEaseBounceIn::actionWithAction(CCActionInterval* pAction) +// { +// CCEaseBounceIn *pRet = new CCEaseBounceIn(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pRet); +// } +// } +// +// return pRet; +// } + +CCEaseBounceIn* CCEaseBounceIn::create(CCActionInterval* pAction) { CCEaseBounceIn *pRet = new CCEaseBounceIn(); if (pRet) @@ -1135,13 +1367,31 @@ void CCEaseBounceIn::update(float time) CCActionInterval* CCEaseBounceIn::reverse(void) { - return CCEaseBounceOut::actionWithAction(m_pOther->reverse()); + return CCEaseBounceOut::create(m_pOther->reverse()); } // // EaseBounceOut // -CCEaseBounceOut* CCEaseBounceOut::actionWithAction(CCActionInterval* pAction) +//cjh CCEaseBounceOut* CCEaseBounceOut::actionWithAction(CCActionInterval* pAction) +// { +// CCEaseBounceOut *pRet = new CCEaseBounceOut(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pRet); +// } +// } +// +// return pRet; +// } + +CCEaseBounceOut* CCEaseBounceOut::create(CCActionInterval* pAction) { CCEaseBounceOut *pRet = new CCEaseBounceOut(); if (pRet) @@ -1188,13 +1438,31 @@ void CCEaseBounceOut::update(float time) CCActionInterval* CCEaseBounceOut::reverse(void) { - return CCEaseBounceIn::actionWithAction(m_pOther->reverse()); + return CCEaseBounceIn::create(m_pOther->reverse()); } // // EaseBounceInOut // -CCEaseBounceInOut* CCEaseBounceInOut::actionWithAction(CCActionInterval* pAction) +//cjh CCEaseBounceInOut* CCEaseBounceInOut::actionWithAction(CCActionInterval* pAction) +// { +// CCEaseBounceInOut *pRet = new CCEaseBounceInOut(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pRet); +// } +// } +// +// return pRet; +// } + +CCEaseBounceInOut* CCEaseBounceInOut::create(CCActionInterval* pAction) { CCEaseBounceInOut *pRet = new CCEaseBounceInOut(); if (pRet) @@ -1251,13 +1519,31 @@ void CCEaseBounceInOut::update(float time) CCActionInterval* CCEaseBounceInOut::reverse() { - return CCEaseBounceInOut::actionWithAction(m_pOther->reverse()); + return CCEaseBounceInOut::create(m_pOther->reverse()); } // // EaseBackIn // -CCEaseBackIn* CCEaseBackIn::actionWithAction(CCActionInterval *pAction) +//cjh CCEaseBackIn* CCEaseBackIn::actionWithAction(CCActionInterval *pAction) +// { +// CCEaseBackIn *pRet = new CCEaseBackIn(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pRet); +// } +// } +// +// return pRet; +// } + +CCEaseBackIn* CCEaseBackIn::create(CCActionInterval *pAction) { CCEaseBackIn *pRet = new CCEaseBackIn(); if (pRet) @@ -1304,13 +1590,31 @@ void CCEaseBackIn::update(float time) CCActionInterval* CCEaseBackIn::reverse(void) { - return CCEaseBackOut::actionWithAction(m_pOther->reverse()); + return CCEaseBackOut::create(m_pOther->reverse()); } // // EaseBackOut // -CCEaseBackOut* CCEaseBackOut::actionWithAction(CCActionInterval* pAction) +//cjh CCEaseBackOut* CCEaseBackOut::actionWithAction(CCActionInterval* pAction) +// { +// CCEaseBackOut *pRet = new CCEaseBackOut(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pRet); +// } +// } +// +// return pRet; +// } + +CCEaseBackOut* CCEaseBackOut::create(CCActionInterval* pAction) { CCEaseBackOut *pRet = new CCEaseBackOut(); if (pRet) @@ -1359,13 +1663,31 @@ void CCEaseBackOut::update(float time) CCActionInterval* CCEaseBackOut::reverse(void) { - return CCEaseBackIn::actionWithAction(m_pOther->reverse()); + return CCEaseBackIn::create(m_pOther->reverse()); } // // EaseBackInOut // -CCEaseBackInOut* CCEaseBackInOut::actionWithAction(CCActionInterval* pAction) +//cjh CCEaseBackInOut* CCEaseBackInOut::actionWithAction(CCActionInterval* pAction) +// { +// CCEaseBackInOut *pRet = new CCEaseBackInOut(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pRet); +// } +// } +// +// return pRet; +// } + +CCEaseBackInOut* CCEaseBackInOut::create(CCActionInterval* pAction) { CCEaseBackInOut *pRet = new CCEaseBackInOut(); if (pRet) @@ -1422,7 +1744,7 @@ void CCEaseBackInOut::update(float time) CCActionInterval* CCEaseBackInOut::reverse() { - return CCEaseBackInOut::actionWithAction(m_pOther->reverse()); + return CCEaseBackInOut::create(m_pOther->reverse()); } NS_CC_END diff --git a/cocos2dx/actions/CCActionEase.h b/cocos2dx/actions/CCActionEase.h index 05117c8691..0718d95e7d 100644 --- a/cocos2dx/actions/CCActionEase.h +++ b/cocos2dx/actions/CCActionEase.h @@ -51,8 +51,13 @@ public: virtual CCActionInterval* reverse(void); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCActionEase* actionWithAction(CCActionInterval *pAction); + /** creates the action */ - static CCActionEase* actionWithAction(CCActionInterval *pAction); + static CCActionEase* create(CCActionInterval *pAction); protected: CCActionInterval *m_pOther; @@ -78,8 +83,13 @@ public: virtual CCActionInterval* reverse(void); public: + /** Creates the action with the inner action and the rate parameter + @warning: This interface will be deprecated in future. + */ + //static CCEaseRateAction* actionWithAction(CCActionInterval* pAction, float fRate); + /** Creates the action with the inner action and the rate parameter */ - static CCEaseRateAction* actionWithAction(CCActionInterval* pAction, float fRate); + static CCEaseRateAction* create(CCActionInterval* pAction, float fRate); protected: float m_fRate; @@ -95,8 +105,13 @@ public: virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); public: + /** Creates the action with the inner action and the rate parameter + @warning: This interface will be deprecated in future. + */ + //static CCEaseIn* actionWithAction(CCActionInterval* pAction, float fRate); + /** Creates the action with the inner action and the rate parameter */ - static CCEaseIn* actionWithAction(CCActionInterval* pAction, float fRate); + static CCEaseIn* create(CCActionInterval* pAction, float fRate); }; /** @@ -110,8 +125,13 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); public: + /** Creates the action with the inner action and the rate parameter + @warning: This interface will be deprecated in future. + */ + //static CCEaseOut* actionWithAction(CCActionInterval* pAction, float fRate); + /** Creates the action with the inner action and the rate parameter */ - static CCEaseOut* actionWithAction(CCActionInterval* pAction, float fRate); + static CCEaseOut* create(CCActionInterval* pAction, float fRate); }; /** @@ -125,8 +145,13 @@ public: virtual CCActionInterval* reverse(void); public: + /** Creates the action with the inner action and the rate parameter + @warning: This interface will be deprecated in future. + */ + //static CCEaseInOut* actionWithAction(CCActionInterval* pAction, float fRate); + /** Creates the action with the inner action and the rate parameter */ - static CCEaseInOut* actionWithAction(CCActionInterval* pAction, float fRate); + static CCEaseInOut* create(CCActionInterval* pAction, float fRate); }; /** @@ -140,8 +165,12 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCEaseExponentialIn* actionWithAction(CCActionInterval* pAction); /** creates the action */ - static CCEaseExponentialIn* actionWithAction(CCActionInterval* pAction); + static CCEaseExponentialIn* create(CCActionInterval* pAction); }; /** @@ -155,9 +184,12 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCEaseExponentialOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ - static CCEaseExponentialOut* actionWithAction(CCActionInterval* pAction); - + static CCEaseExponentialOut* create(CCActionInterval* pAction); }; /** @@ -171,9 +203,13 @@ public: virtual CCActionInterval* reverse(); public: - /** creates the action */ - static CCEaseExponentialInOut* actionWithAction(CCActionInterval* pAction); + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCEaseExponentialInOut* actionWithAction(CCActionInterval* pAction); + /** creates the action */ + static CCEaseExponentialInOut* create(CCActionInterval* pAction); }; /** @@ -187,8 +223,12 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCEaseSineIn* actionWithAction(CCActionInterval* pAction); /** creates the action */ - static CCEaseSineIn* actionWithAction(CCActionInterval* pAction); + static CCEaseSineIn* create(CCActionInterval* pAction); }; /** @@ -202,8 +242,12 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCEaseSineOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ - static CCEaseSineOut* actionWithAction(CCActionInterval* pAction); + static CCEaseSineOut* create(CCActionInterval* pAction); }; /** @@ -217,8 +261,12 @@ public: virtual CCActionInterval* reverse(); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCEaseSineInOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ - static CCEaseSineInOut* actionWithAction(CCActionInterval* pAction); + static CCEaseSineInOut* create(CCActionInterval* pAction); }; /** @@ -234,19 +282,18 @@ public: inline void setPeriod(float fPeriod) { m_fPeriod = fPeriod; } /** Initializes the action with the inner action and the period in radians (default is 0.3) */ - bool initWithAction(CCActionInterval *pAction, float fPeriod); - /** initializes the action */ - bool initWithAction(CCActionInterval *pAction); + bool initWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); virtual CCActionInterval* reverse(void); virtual CCObject* copyWithZone(CCZone* pZone); public: - /** creates the action */ - static CCEaseElastic* actionWithAction(CCActionInterval *pAction); + /** Creates the action with the inner action and the period in radians (default is 0.3) + @warning: This interface will be deprecated in future. + */ + //static CCEaseElastic* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); /** Creates the action with the inner action and the period in radians (default is 0.3) */ - static CCEaseElastic* actionWithAction(CCActionInterval *pAction, float fPeriod); - + static CCEaseElastic* create(CCActionInterval *pAction, float fPeriod = 0.3f); protected: float m_fPeriod; }; @@ -264,10 +311,12 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); public: - /** creates the action */ - static CCEaseElasticIn* actionWithAction(CCActionInterval *pAction); + /** Creates the action with the inner action and the period in radians (default is 0.3) + @warning: This interface will be deprecated in future. + */ + //static CCEaseElasticIn* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); /** Creates the action with the inner action and the period in radians (default is 0.3) */ - static CCEaseElasticIn* actionWithAction(CCActionInterval *pAction, float fPeriod); + static CCEaseElasticIn* create(CCActionInterval *pAction, float fPeriod = 0.3f); }; /** @@ -283,10 +332,13 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); public: - /** creates the action */ - static CCEaseElasticOut* actionWithAction(CCActionInterval *pAction); + /** Creates the action with the inner action and the period in radians (default is 0.3) + @warning: This interface will be deprecated in future. + */ + //static CCEaseElasticOut* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); + /** Creates the action with the inner action and the period in radians (default is 0.3) */ - static CCEaseElasticOut* actionWithAction(CCActionInterval *pAction, float fPeriod); + static CCEaseElasticOut* create(CCActionInterval *pAction, float fPeriod = 0.3f); }; /** @@ -302,10 +354,13 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); public: - /** creates the action */ - static CCEaseElasticInOut* actionWithAction(CCActionInterval *pAction); + /** Creates the action with the inner action and the period in radians (default is 0.3) + @warning: This interface will be deprecated in future. + */ + //static CCEaseElasticInOut* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); + /** Creates the action with the inner action and the period in radians (default is 0.3) */ - static CCEaseElasticInOut* actionWithAction(CCActionInterval *pAction, float fPeriod); + static CCEaseElasticInOut* create(CCActionInterval *pAction, float fPeriod = 0.3f); }; /** @@ -320,8 +375,12 @@ public: virtual CCActionInterval* reverse(); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCEaseBounce* actionWithAction(CCActionInterval* pAction); /** creates the action */ - static CCEaseBounce* actionWithAction(CCActionInterval* pAction); + static CCEaseBounce* create(CCActionInterval* pAction); }; /** @@ -337,8 +396,12 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCEaseBounceIn* actionWithAction(CCActionInterval* pAction); /** creates the action */ - static CCEaseBounceIn* actionWithAction(CCActionInterval* pAction); + static CCEaseBounceIn* create(CCActionInterval* pAction); }; /** @@ -354,8 +417,12 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCEaseBounceOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ - static CCEaseBounceOut* actionWithAction(CCActionInterval* pAction); + static CCEaseBounceOut* create(CCActionInterval* pAction); }; /** @@ -371,8 +438,12 @@ public: virtual CCActionInterval* reverse(); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCEaseBounceInOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ - static CCEaseBounceInOut* actionWithAction(CCActionInterval* pAction); + static CCEaseBounceInOut* create(CCActionInterval* pAction); }; /** @@ -388,8 +459,12 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCEaseBackIn* actionWithAction(CCActionInterval* pAction); /** creates the action */ - static CCEaseBackIn* actionWithAction(CCActionInterval* pAction); + static CCEaseBackIn* create(CCActionInterval* pAction); }; /** @@ -405,8 +480,12 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCEaseBackOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ - static CCEaseBackOut* actionWithAction(CCActionInterval* pAction); + static CCEaseBackOut* create(CCActionInterval* pAction); }; /** @@ -422,8 +501,12 @@ public: virtual CCActionInterval* reverse(); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCEaseBackInOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ - static CCEaseBackInOut* actionWithAction(CCActionInterval* pAction); + static CCEaseBackInOut* create(CCActionInterval* pAction); }; NS_CC_END diff --git a/cocos2dx/actions/CCActionGrid.cpp b/cocos2dx/actions/CCActionGrid.cpp index f70ff3050f..3b8d2deb42 100644 --- a/cocos2dx/actions/CCActionGrid.cpp +++ b/cocos2dx/actions/CCActionGrid.cpp @@ -30,7 +30,25 @@ THE SOFTWARE. NS_CC_BEGIN // implementation of CCGridAction -CCGridAction* CCGridAction::actionWithSize(const ccGridSize& gridSize, float duration) +// CCGridAction* CCGridAction::actionWithSize(const ccGridSize& gridSize, float duration) +// { +// CCGridAction *pAction = new CCGridAction(); +// if (pAction) +// { +// if (pAction->initWithSize(gridSize, duration)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_DELETE(pAction); +// } +// } +// +// return pAction; +// } + +CCGridAction* CCGridAction::create(const ccGridSize& gridSize, float duration) { CCGridAction *pAction = new CCGridAction(); if (pAction) @@ -103,7 +121,7 @@ CCGridBase* CCGridAction::getGrid(void) CCActionInterval* CCGridAction::reverse(void) { - return CCReverseTime::actionWithAction(this); + return CCReverseTime::create(this); } CCObject* CCGridAction::copyWithZone(CCZone *pZone) @@ -181,7 +199,25 @@ void CCTiledGrid3DAction::setTile(const ccGridSize& pos, const ccQuad3& coords) // implementation CCAccelDeccelAmplitude -CCAccelDeccelAmplitude* CCAccelDeccelAmplitude::actionWithAction(CCAction *pAction, float duration) +// CCAccelDeccelAmplitude* CCAccelDeccelAmplitude::actionWithAction(CCAction *pAction, float duration) +// { +// CCAccelDeccelAmplitude *pRet = new CCAccelDeccelAmplitude(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction, duration)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_DELETE(pRet); +// } +// } +// +// return pRet; +// } + +CCAccelDeccelAmplitude* CCAccelDeccelAmplitude::create(CCAction *pAction, float duration) { CCAccelDeccelAmplitude *pRet = new CCAccelDeccelAmplitude(); if (pRet) @@ -239,12 +275,30 @@ void CCAccelDeccelAmplitude::update(float time) CCActionInterval* CCAccelDeccelAmplitude::reverse(void) { - return CCAccelDeccelAmplitude::actionWithAction(m_pOther->reverse(), m_fDuration); + return CCAccelDeccelAmplitude::create(m_pOther->reverse(), m_fDuration); } // implementation of AccelAmplitude -CCAccelAmplitude* CCAccelAmplitude::actionWithAction(CCAction *pAction, float duration) +// CCAccelAmplitude* CCAccelAmplitude::actionWithAction(CCAction *pAction, float duration) +// { +// CCAccelAmplitude *pRet = new CCAccelAmplitude(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction, duration)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_DELETE(pRet); +// } +// } +// +// return pRet; +// } + +CCAccelAmplitude* CCAccelAmplitude::create(CCAction *pAction, float duration) { CCAccelAmplitude *pRet = new CCAccelAmplitude(); if (pRet) @@ -295,12 +349,30 @@ void CCAccelAmplitude::update(float time) CCActionInterval* CCAccelAmplitude::reverse(void) { - return CCAccelAmplitude::actionWithAction(m_pOther->reverse(), m_fDuration); + return CCAccelAmplitude::create(m_pOther->reverse(), m_fDuration); } // DeccelAmplitude -CCDeccelAmplitude* CCDeccelAmplitude::actionWithAction(CCAction *pAction, float duration) +// CCDeccelAmplitude* CCDeccelAmplitude::actionWithAction(CCAction *pAction, float duration) +// { +// CCDeccelAmplitude *pRet = new CCDeccelAmplitude(); +// if (pRet) +// { +// if (pRet->initWithAction(pAction, duration)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_DELETE(pRet); +// } +// } +// +// return pRet; +// } + +CCDeccelAmplitude* CCDeccelAmplitude::create(CCAction *pAction, float duration) { CCDeccelAmplitude *pRet = new CCDeccelAmplitude(); if (pRet) @@ -318,6 +390,7 @@ CCDeccelAmplitude* CCDeccelAmplitude::actionWithAction(CCAction *pAction, float return pRet; } + bool CCDeccelAmplitude::initWithAction(CCAction *pAction, float duration) { if (CCActionInterval::initWithDuration(duration)) @@ -351,7 +424,7 @@ void CCDeccelAmplitude::update(float time) CCActionInterval* CCDeccelAmplitude::reverse(void) { - return CCDeccelAmplitude::actionWithAction(m_pOther->reverse(), m_fDuration); + return CCDeccelAmplitude::create(m_pOther->reverse(), m_fDuration); } // implementation of StopGrid @@ -367,17 +440,42 @@ void CCStopGrid::startWithTarget(CCNode *pTarget) } } -CCStopGrid* CCStopGrid::action(void) +// CCStopGrid* CCStopGrid::action(void) +// { +// CCStopGrid* pAction = new CCStopGrid(); +// pAction->autorelease(); +// +// return pAction; +// } + +CCStopGrid* CCStopGrid::create(void) { CCStopGrid* pAction = new CCStopGrid(); pAction->autorelease(); return pAction; } - // implementation of CCReuseGrid -CCReuseGrid* CCReuseGrid::actionWithTimes(int times) +// CCReuseGrid* CCReuseGrid::actionWithTimes(int times) +// { +// CCReuseGrid *pAction = new CCReuseGrid(); +// if (pAction) +// { +// if (pAction->initWithTimes(times)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_DELETE(pAction); +// } +// } +// +// return pAction; +// } + +CCReuseGrid* CCReuseGrid::create(int times) { CCReuseGrid *pAction = new CCReuseGrid(); if (pAction) diff --git a/cocos2dx/actions/CCActionGrid.h b/cocos2dx/actions/CCActionGrid.h index bf115c3a6f..52455a8ab9 100644 --- a/cocos2dx/actions/CCActionGrid.h +++ b/cocos2dx/actions/CCActionGrid.h @@ -46,9 +46,12 @@ public: virtual CCGridBase* getGrid(void); public: + /** creates the action with size and duration + @warning: This interface will be deprecated in future. + */ + //static CCGridAction* actionWithSize(const ccGridSize& gridSize, float duration); /** creates the action with size and duration */ - static CCGridAction* actionWithSize(const ccGridSize& gridSize, float duration); - + static CCGridAction* create(const ccGridSize& gridSize, float duration); protected: ccGridSize m_sGridSize; }; @@ -70,8 +73,12 @@ public: void setVertex(const ccGridSize& pos, const ccVertex3F& vertex); public: + /** creates the action with size and duration + @warning: This interface will be deprecated in future. + */ + //static CCGrid3DAction* actionWithSize(const ccGridSize& gridSize, float duration); /** creates the action with size and duration */ - static CCGrid3DAction* actionWithSize(const ccGridSize& gridSize, float duration); + static CCGrid3DAction* create(const ccGridSize& gridSize, float duration); }; /** @brief Base class for CCTiledGrid3D actions */ @@ -89,8 +96,12 @@ public: virtual CCGridBase* getGrid(void); public: + /** creates the action with size and duration + @warning: This interface will be deprecated in future. + */ + //static CCTiledGrid3DAction* actionWithSize(const ccGridSize& gridSize, float duration); /** creates the action with size and duration */ - static CCTiledGrid3DAction* actionWithSize(const ccGridSize& gridSize, float duration); + static CCTiledGrid3DAction* create(const ccGridSize& gridSize, float duration); }; /** @brief CCAccelDeccelAmplitude action */ @@ -111,8 +122,12 @@ public: inline void setRate(float fRate) { m_fRate = fRate; } public: + /** creates the action with an inner action that has the amplitude property, and a duration time + @warning: This interface will be deprecated in future. + */ + //static CCAccelDeccelAmplitude* actionWithAction(CCAction *pAction, float duration); /** creates the action with an inner action that has the amplitude property, and a duration time */ - static CCAccelDeccelAmplitude* actionWithAction(CCAction *pAction, float duration); + static CCAccelDeccelAmplitude* create(CCAction *pAction, float duration); protected: float m_fRate; @@ -137,9 +152,12 @@ public: virtual CCActionInterval* reverse(void); public: + /** creates the action with an inner action that has the amplitude property, and a duration time + @warning: This interface will be deprecated in future. + */ + //static CCAccelAmplitude* actionWithAction(CCAction *pAction, float duration); /** creates the action with an inner action that has the amplitude property, and a duration time */ - static CCAccelAmplitude* actionWithAction(CCAction *pAction, float duration); - + static CCAccelAmplitude* create(CCAction *pAction, float duration); protected: float m_fRate; CCActionInterval *m_pOther; @@ -163,8 +181,12 @@ public: virtual CCActionInterval* reverse(void); public: + /** creates the action with an inner action that has the amplitude property, and a duration time + @warning: This interface will be deprecated in future. + */ + //static CCDeccelAmplitude* actionWithAction(CCAction *pAction, float duration); /** creates the action with an inner action that has the amplitude property, and a duration time */ - static CCDeccelAmplitude* actionWithAction(CCAction *pAction, float duration); + static CCDeccelAmplitude* create(CCAction *pAction, float duration); protected: float m_fRate; @@ -182,8 +204,12 @@ public: virtual void startWithTarget(CCNode *pTarget); public: + /** Allocates and initializes the action + @warning: This interface will be deprecated in future. + */ + //static CCStopGrid* action(void); /** Allocates and initializes the action */ - static CCStopGrid* action(void); + static CCStopGrid* create(void); }; /** @brief CCReuseGrid action */ @@ -196,9 +222,12 @@ public: virtual void startWithTarget(CCNode *pTarget); public: + /** creates an action with the number of times that the current grid will be reused + @warning: This interface will be deprecated in future. + */ + //static CCReuseGrid* actionWithTimes(int times); /** creates an action with the number of times that the current grid will be reused */ - static CCReuseGrid* actionWithTimes(int times); - + static CCReuseGrid* create(int times); protected: int m_nTimes; }; diff --git a/cocos2dx/actions/CCActionGrid3D.cpp b/cocos2dx/actions/CCActionGrid3D.cpp index 52b4a49861..2613f3033c 100644 --- a/cocos2dx/actions/CCActionGrid3D.cpp +++ b/cocos2dx/actions/CCActionGrid3D.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 On-Core http://www.cocos2d-x.org @@ -31,7 +31,26 @@ THE SOFTWARE. NS_CC_BEGIN // implementation of CCWaves3D -CCWaves3D* CCWaves3D::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) +// CCWaves3D* CCWaves3D::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) +// { +// CCWaves3D *pAction = new CCWaves3D(); +// +// if (pAction) +// { +// if (pAction->initWithWaves(wav, amp, gridSize, duration)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pAction); +// } +// } +// +// return pAction; +// } + +CCWaves3D* CCWaves3D::create(int wav, float amp, const ccGridSize& gridSize, float duration) { CCWaves3D *pAction = new CCWaves3D(); @@ -105,7 +124,26 @@ void CCWaves3D::update(float time) // implementation of CCFlipX3D -CCFlipX3D* CCFlipX3D::actionWithDuration(float duration) +// CCFlipX3D* CCFlipX3D::actionWithDuration(float duration) +// { +// CCFlipX3D *pAction = new CCFlipX3D(); +// +// if (pAction) +// { +// if (pAction->initWithSize(ccg(1, 1), duration)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pAction); +// } +// } +// +// return pAction; +// } + +CCFlipX3D* CCFlipX3D::create(float duration) { CCFlipX3D *pAction = new CCFlipX3D(); @@ -231,7 +269,26 @@ void CCFlipX3D::update(float time) // implementation of FlipY3D -CCFlipY3D* CCFlipY3D::actionWithDuration(float duration) +// CCFlipY3D* CCFlipY3D::actionWithDuration(float duration) +// { +// CCFlipY3D *pAction = new CCFlipY3D(); +// +// if (pAction) +// { +// if (pAction->initWithSize(ccg(1, 1), duration)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pAction); +// } +// } +// +// return pAction; +// } + +CCFlipY3D* CCFlipY3D::create(float duration) { CCFlipY3D *pAction = new CCFlipY3D(); @@ -340,7 +397,26 @@ void CCFlipY3D::update(float time) // implementation of Lens3D -CCLens3D* CCLens3D::actionWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration) +// CCLens3D* CCLens3D::actionWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration) +// { +// CCLens3D *pAction = new CCLens3D(); +// +// if (pAction) +// { +// if (pAction->initWithPosition(pos, r, gridSize, duration)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pAction); +// } +// } +// +// return pAction; +// } + +CCLens3D* CCLens3D::create(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration) { CCLens3D *pAction = new CCLens3D(); @@ -451,7 +527,26 @@ void CCLens3D::update(float time) // implementation of Ripple3D -CCRipple3D* CCRipple3D::actionWithPosition(const CCPoint& pos, float r, int wav, float amp, const ccGridSize& gridSize, float duration) +// CCRipple3D* CCRipple3D::actionWithPosition(const CCPoint& pos, float r, int wav, float amp, const ccGridSize& gridSize, float duration) +// { +// CCRipple3D *pAction = new CCRipple3D(); +// +// if (pAction) +// { +// if (pAction->initWithPosition(pos, r, wav, amp, gridSize, duration)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pAction); +// } +// } +// +// return pAction; +// } + +CCRipple3D* CCRipple3D::create(const CCPoint& pos, float r, int wav, float amp, const ccGridSize& gridSize, float duration) { CCRipple3D *pAction = new CCRipple3D(); @@ -540,7 +635,26 @@ void CCRipple3D::update(float time) // implementation of Shaky3D -CCShaky3D* CCShaky3D::actionWithRange(int range, bool shakeZ, const ccGridSize& gridSize, float duration) +// CCShaky3D* CCShaky3D::actionWithRange(int range, bool shakeZ, const ccGridSize& gridSize, float duration) +// { +// CCShaky3D *pAction = new CCShaky3D(); +// +// if (pAction) +// { +// if (pAction->initWithRange(range, shakeZ, gridSize, duration)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pAction); +// } +// } +// +// return pAction; +// } + +CCShaky3D* CCShaky3D::create(int range, bool shakeZ, const ccGridSize& gridSize, float duration) { CCShaky3D *pAction = new CCShaky3D(); @@ -619,7 +733,26 @@ void CCShaky3D::update(float time) // implementation of Liquid -CCLiquid* CCLiquid::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) +// CCLiquid* CCLiquid::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) +// { +// CCLiquid *pAction = new CCLiquid(); +// +// if (pAction) +// { +// if (pAction->initWithWaves(wav, amp, gridSize, duration)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pAction); +// } +// } +// +// return pAction; +// } + +CCLiquid* CCLiquid::create(int wav, float amp, const ccGridSize& gridSize, float duration) { CCLiquid *pAction = new CCLiquid(); @@ -693,7 +826,26 @@ void CCLiquid::update(float time) // implementation of Waves -CCWaves* CCWaves::actionWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, float duration) +// CCWaves* CCWaves::actionWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, float duration) +// { +// CCWaves *pAction = new CCWaves(); +// +// if (pAction) +// { +// if (pAction->initWithWaves(wav, amp, h, v, gridSize, duration)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pAction); +// } +// } +// +// return pAction; +// } + +CCWaves* CCWaves::create(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, float duration) { CCWaves *pAction = new CCWaves(); @@ -778,7 +930,26 @@ void CCWaves::update(float time) // implementation of Twirl -CCTwirl* CCTwirl::actionWithPosition(CCPoint pos, int t, float amp, const ccGridSize& gridSize, float duration) +// CCTwirl* CCTwirl::actionWithPosition(CCPoint pos, int t, float amp, const ccGridSize& gridSize, float duration) +// { +// CCTwirl *pAction = new CCTwirl(); +// +// if (pAction) +// { +// if (pAction->initWithPosition(pos, t, amp, gridSize, duration)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pAction); +// } +// } +// +// return pAction; +// } + +CCTwirl* CCTwirl::create(CCPoint pos, int t, float amp, const ccGridSize& gridSize, float duration) { CCTwirl *pAction = new CCTwirl(); diff --git a/cocos2dx/actions/CCActionGrid3D.h b/cocos2dx/actions/CCActionGrid3D.h index 83489274a5..a9f6e84d16 100644 --- a/cocos2dx/actions/CCActionGrid3D.h +++ b/cocos2dx/actions/CCActionGrid3D.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009 On-Core http://www.cocos2d-x.org @@ -47,9 +47,12 @@ public: virtual void update(float time); public: + /** create the action + @warning: This interface will be deprecated in future. + */ + //static CCWaves3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); /** create the action */ - static CCWaves3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); - + static CCWaves3D* create(int wav, float amp, const ccGridSize& gridSize, float duration); protected: int m_nWaves; float m_fAmplitude; @@ -67,8 +70,12 @@ public: virtual void update(float time); public: + /** creates the action with duration + @warning: This interface will be deprecated in future. + */ + //static CCFlipX3D* actionWithDuration(float duration); /** creates the action with duration */ - static CCFlipX3D* actionWithDuration(float duration); + static CCFlipX3D* create(float duration); }; /** @brief CCFlipY3D action */ @@ -79,8 +86,12 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); public: + /** creates the action with duration + @warning: This interface will be deprecated in future. + */ + //static CCFlipY3D* actionWithDuration(float duration); /** creates the action with duration */ - static CCFlipY3D* actionWithDuration(float duration); + static CCFlipY3D* create(float duration); }; /** @brief CCLens3D action */ @@ -101,8 +112,12 @@ public: virtual void update(float time); public: + /** creates the action with center position, radius, a grid size and duration + @warning: This interface will be deprecated in future. + */ + //static CCLens3D* actionWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration); /** creates the action with center position, radius, a grid size and duration */ - static CCLens3D* actionWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration); + static CCLens3D* create(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration); protected: /* lens center position */ CCPoint m_position; @@ -135,8 +150,13 @@ public: virtual void update(float time); public: + /** creates the action with radius, number of waves, amplitude, a grid size and duration + @warning: This interface will be deprecated in future. + */ + //static CCRipple3D* actionWithPosition(const CCPoint& pos, float r, int wav, float amp, + // const ccGridSize& gridSize, float duration); /** creates the action with radius, number of waves, amplitude, a grid size and duration */ - static CCRipple3D* actionWithPosition(const CCPoint& pos, float r, int wav, float amp, + static CCRipple3D* create(const CCPoint& pos, float r, int wav, float amp, const ccGridSize& gridSize, float duration); protected: /* center position */ @@ -157,9 +177,12 @@ public: virtual void update(float time); public: + /** creates the action with a range, shake Z vertices, a grid and duration + @warning: This interface will be deprecated in future. + */ + //static CCShaky3D* actionWithRange(int range, bool shakeZ, const ccGridSize& gridSize, float duration); /** creates the action with a range, shake Z vertices, a grid and duration */ - static CCShaky3D* actionWithRange(int range, bool shakeZ, const ccGridSize& gridSize, float duration); - + static CCShaky3D* create(int range, bool shakeZ, const ccGridSize& gridSize, float duration); protected: int m_nRandrange; bool m_bShakeZ; @@ -181,9 +204,12 @@ public: virtual void update(float time); public: + /** creates the action with amplitude, a grid and duration + @warning: This interface will be deprecated in future. + */ + //static CCLiquid* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); /** creates the action with amplitude, a grid and duration */ - static CCLiquid* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); - + static CCLiquid* create(int wav, float amp, const ccGridSize& gridSize, float duration); protected: int m_nWaves; float m_fAmplitude; @@ -207,8 +233,14 @@ public: virtual void update(float time); public: + /** initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration + @warning: This interface will be deprecated in future. + */ +// static CCWaves* actionWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, +// float duration); + /** initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration */ - static CCWaves* actionWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, + static CCWaves* create(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, float duration); protected: int m_nWaves; @@ -240,8 +272,14 @@ public: virtual void update(float time); public: + /** creates the action with center position, number of twirls, amplitude, a grid size and duration + @warning: This interface will be deprecated in future. + */ +// static CCTwirl* actionWithPosition(CCPoint pos, int t, float amp, const ccGridSize& gridSize, +// float duration); + /** creates the action with center position, number of twirls, amplitude, a grid size and duration */ - static CCTwirl* actionWithPosition(CCPoint pos, int t, float amp, const ccGridSize& gridSize, + static CCTwirl* create(CCPoint pos, int t, float amp, const ccGridSize& gridSize, float duration); protected: /* twirl center */ diff --git a/cocos2dx/actions/CCActionInstant.cpp b/cocos2dx/actions/CCActionInstant.cpp index d003c0f10c..4646854bfa 100644 --- a/cocos2dx/actions/CCActionInstant.cpp +++ b/cocos2dx/actions/CCActionInstant.cpp @@ -73,7 +73,17 @@ CCFiniteTimeAction * CCActionInstant::reverse() { // // Show // -CCShow* CCShow::action() { +// CCShow* CCShow::action() { +// CCShow* pRet = new CCShow(); +// +// if (pRet) { +// pRet->autorelease(); +// } +// +// return pRet; +// } + +CCShow* CCShow::create() { CCShow* pRet = new CCShow(); if (pRet) { @@ -89,7 +99,7 @@ void CCShow::update(float time) { } CCFiniteTimeAction* CCShow::reverse() { - return (CCFiniteTimeAction*) (CCHide::action()); + return (CCFiniteTimeAction*) (CCHide::create()); } CCObject* CCShow::copyWithZone(CCZone *pZone) { @@ -111,7 +121,17 @@ CCObject* CCShow::copyWithZone(CCZone *pZone) { // // Hide // -CCHide * CCHide::action() { +// CCHide * CCHide::action() { +// CCHide *pRet = new CCHide(); +// +// if (pRet) { +// pRet->autorelease(); +// } +// +// return pRet; +// } + +CCHide * CCHide::create() { CCHide *pRet = new CCHide(); if (pRet) { @@ -127,7 +147,7 @@ void CCHide::update(float time) { } CCFiniteTimeAction *CCHide::reverse() { - return (CCFiniteTimeAction*) (CCShow::action()); + return (CCFiniteTimeAction*) (CCShow::create()); } CCObject* CCHide::copyWithZone(CCZone *pZone) { @@ -149,7 +169,19 @@ CCObject* CCHide::copyWithZone(CCZone *pZone) { // // ToggleVisibility // -CCToggleVisibility * CCToggleVisibility::action() +// CCToggleVisibility * CCToggleVisibility::action() +// { +// CCToggleVisibility *pRet = new CCToggleVisibility(); +// +// if (pRet) +// { +// pRet->autorelease(); +// } +// +// return pRet; +// } + +CCToggleVisibility * CCToggleVisibility::create() { CCToggleVisibility *pRet = new CCToggleVisibility(); @@ -187,7 +219,19 @@ CCObject* CCToggleVisibility::copyWithZone(CCZone *pZone) // // FlipX // -CCFlipX *CCFlipX::actionWithFlipX(bool x) { +// CCFlipX *CCFlipX::actionWithFlipX(bool x) { +// CCFlipX *pRet = new CCFlipX(); +// +// if (pRet && pRet->initWithFlipX(x)) { +// pRet->autorelease(); +// return pRet; +// } +// +// CC_SAFE_DELETE(pRet); +// return NULL; +// } + +CCFlipX *CCFlipX::create(bool x) { CCFlipX *pRet = new CCFlipX(); if (pRet && pRet->initWithFlipX(x)) { @@ -210,7 +254,7 @@ void CCFlipX::update(float time) { } CCFiniteTimeAction* CCFlipX::reverse() { - return CCFlipX::actionWithFlipX(!m_bFlipX); + return CCFlipX::create(!m_bFlipX); } CCObject * CCFlipX::copyWithZone(CCZone *pZone) { @@ -233,7 +277,19 @@ CCObject * CCFlipX::copyWithZone(CCZone *pZone) { // // FlipY // -CCFlipY * CCFlipY::actionWithFlipY(bool y) { +// CCFlipY * CCFlipY::actionWithFlipY(bool y) { +// CCFlipY *pRet = new CCFlipY(); +// +// if (pRet && pRet->initWithFlipY(y)) { +// pRet->autorelease(); +// return pRet; +// } +// +// CC_SAFE_DELETE(pRet); +// return NULL; +// } + +CCFlipY * CCFlipY::create(bool y) { CCFlipY *pRet = new CCFlipY(); if (pRet && pRet->initWithFlipY(y)) { @@ -256,7 +312,7 @@ void CCFlipY::update(float time) { } CCFiniteTimeAction* CCFlipY::reverse() { - return CCFlipY::actionWithFlipY(!m_bFlipY); + return CCFlipY::create(!m_bFlipY); } CCObject* CCFlipY::copyWithZone(CCZone *pZone) { @@ -279,7 +335,19 @@ CCObject* CCFlipY::copyWithZone(CCZone *pZone) { // // Place // -CCPlace* CCPlace::actionWithPosition(const CCPoint& pos) { +// CCPlace* CCPlace::actionWithPosition(const CCPoint& pos) { +// CCPlace *pRet = new CCPlace(); +// +// if (pRet && pRet->initWithPosition(pos)) { +// pRet->autorelease(); +// return pRet; +// } +// +// CC_SAFE_DELETE(pRet); +// return NULL; +// } + +CCPlace* CCPlace::create(const CCPoint& pos) { CCPlace *pRet = new CCPlace(); if (pRet && pRet->initWithPosition(pos)) { @@ -322,7 +390,21 @@ void CCPlace::update(float time) { // CallFunc // -CCCallFunc * CCCallFunc::actionWithTarget(CCObject* pSelectorTarget, +// CCCallFunc * CCCallFunc::actionWithTarget(CCObject* pSelectorTarget, +// SEL_CallFunc selector) { +// CCCallFunc *pRet = new CCCallFunc(); +// +// if (pRet && pRet->initWithTarget(pSelectorTarget)) { +// pRet->m_pCallFunc = selector; +// pRet->autorelease(); +// return pRet; +// } +// +// CC_SAFE_DELETE(pRet); +// return NULL; +// } + +CCCallFunc * CCCallFunc::create(CCObject* pSelectorTarget, SEL_CallFunc selector) { CCCallFunc *pRet = new CCCallFunc(); @@ -390,7 +472,20 @@ void CCCallFuncN::execute() { } } -CCCallFuncN * CCCallFuncN::actionWithTarget(CCObject* pSelectorTarget, +// CCCallFuncN * CCCallFuncN::actionWithTarget(CCObject* pSelectorTarget, +// SEL_CallFuncN selector) { +// CCCallFuncN *pRet = new CCCallFuncN(); +// +// if (pRet && pRet->initWithTarget(pSelectorTarget, selector)) { +// pRet->autorelease(); +// return pRet; +// } +// +// CC_SAFE_DELETE(pRet); +// return NULL; +// } + +CCCallFuncN * CCCallFuncN::create(CCObject* pSelectorTarget, SEL_CallFuncN selector) { CCCallFuncN *pRet = new CCCallFuncN(); @@ -434,7 +529,20 @@ CCObject * CCCallFuncN::copyWithZone(CCZone* zone) { // // CallFuncND // -CCCallFuncND * CCCallFuncND::actionWithTarget(CCObject* pSelectorTarget, +// CCCallFuncND * CCCallFuncND::actionWithTarget(CCObject* pSelectorTarget, +// SEL_CallFuncND selector, void* d) { +// CCCallFuncND* pRet = new CCCallFuncND(); +// +// if (pRet && pRet->initWithTarget(pSelectorTarget, selector, d)) { +// pRet->autorelease(); +// return pRet; +// } +// +// CC_SAFE_DELETE(pRet); +// return NULL; +// } + +CCCallFuncND * CCCallFuncND::create(CCObject* pSelectorTarget, SEL_CallFuncND selector, void* d) { CCCallFuncND* pRet = new CCCallFuncND(); @@ -499,7 +607,20 @@ void CCCallFuncO::execute() { } } -CCCallFuncO * CCCallFuncO::actionWithTarget(CCObject* pSelectorTarget, +// CCCallFuncO * CCCallFuncO::actionWithTarget(CCObject* pSelectorTarget, +// SEL_CallFuncO selector, CCObject* pObject) { +// CCCallFuncO *pRet = new CCCallFuncO(); +// +// if (pRet && pRet->initWithTarget(pSelectorTarget, selector, pObject)) { +// pRet->autorelease(); +// return pRet; +// } +// +// CC_SAFE_DELETE(pRet); +// return NULL; +// } + +CCCallFuncO * CCCallFuncO::create(CCObject* pSelectorTarget, SEL_CallFuncO selector, CCObject* pObject) { CCCallFuncO *pRet = new CCCallFuncO(); diff --git a/cocos2dx/actions/CCActionInstant.h b/cocos2dx/actions/CCActionInstant.h index 1359e36ee7..80b5be2aad 100644 --- a/cocos2dx/actions/CCActionInstant.h +++ b/cocos2dx/actions/CCActionInstant.h @@ -63,8 +63,13 @@ public: virtual CCObject* copyWithZone(CCZone *pZone); public: //override static method + /** Allocates and initializes the action + @warning: This interface will be deprecated in future. + */ + //static CCShow * action(); + /** Allocates and initializes the action */ - static CCShow * action(); + static CCShow * create(); }; @@ -83,8 +88,13 @@ public: virtual CCObject* copyWithZone(CCZone *pZone); public: //override static method + /** Allocates and initializes the action + @warning: This interface will be deprecated in future. + */ + //static CCHide * action(); + /** Allocates and initializes the action */ - static CCHide * action(); + static CCHide * create(); }; /** @brief Toggles the visibility of a node @@ -99,8 +109,13 @@ public: virtual CCObject* copyWithZone(CCZone *pZone); public: //override static method + /** Allocates and initializes the action + @warning: This interface will be deprecated in future. + */ + //static CCToggleVisibility * action(); + /** Allocates and initializes the action */ - static CCToggleVisibility * action(); + static CCToggleVisibility * create(); }; /** @@ -115,8 +130,14 @@ public: {} virtual ~CCFlipX(){} + /** create the action + @warning: This interface will be deprecated in future. + */ + //static CCFlipX * actionWithFlipX(bool x); + /** create the action */ - static CCFlipX * actionWithFlipX(bool x); + static CCFlipX * create(bool x); + /** init the action */ bool initWithFlipX(bool x); //super methods @@ -140,8 +161,14 @@ public: {} virtual ~CCFlipY(){} + /** create the action + @warning: This interface will be deprecated in future. + */ + //static CCFlipY * actionWithFlipY(bool y); + /** create the action */ - static CCFlipY * actionWithFlipY(bool y); + static CCFlipY * create(bool y); + /** init the action */ bool initWithFlipY(bool y); //super methods @@ -160,8 +187,12 @@ class CC_DLL CCPlace : public CCActionInstant // public: CCPlace(){} virtual ~CCPlace(){} + /** creates a Place action with a position + @warning: This interface will be deprecated in future. + */ + //static CCPlace * actionWithPosition(const CCPoint& pos); /** creates a Place action with a position */ - static CCPlace * actionWithPosition(const CCPoint& pos); + static CCPlace * create(const CCPoint& pos); /** Initializes a Place action with a position */ bool initWithPosition(const CCPoint& pos); //super methods @@ -189,11 +220,18 @@ public: m_pSelectorTarget->release(); } } + /** creates the action with the callback + @warning: This interface will be deprecated in future. + typedef void (CCObject::*SEL_CallFunc)(); + */ + //static CCCallFunc * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFunc selector); + /** creates the action with the callback typedef void (CCObject::*SEL_CallFunc)(); */ - static CCCallFunc * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFunc selector); + static CCCallFunc * create(CCObject* pSelectorTarget, SEL_CallFunc selector); + /** initializes the action with the callback typedef void (CCObject::*SEL_CallFunc)(); @@ -250,11 +288,17 @@ class CC_DLL CCCallFuncN : public CCCallFunc public: CCCallFuncN(){} virtual ~CCCallFuncN(){} + /** creates the action with the callback + @warning: This interface will be deprecated in future. + typedef void (CCObject::*SEL_CallFuncN)(CCNode*); + */ + //static CCCallFuncN * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncN selector); + /** creates the action with the callback typedef void (CCObject::*SEL_CallFuncN)(CCNode*); */ - static CCCallFuncN * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncN selector); + static CCCallFuncN * create(CCObject* pSelectorTarget, SEL_CallFuncN selector); /** initializes the action with the callback typedef void (CCObject::*SEL_CallFuncN)(CCNode*); @@ -274,8 +318,14 @@ class CC_DLL CCCallFuncND : public CCCallFuncN { public: + /** creates the action with the callback and the data to pass as an argument + @warning: This interface will be deprecated in future. + */ + //static CCCallFuncND * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncND selector, void* d); + /** creates the action with the callback and the data to pass as an argument */ - static CCCallFuncND * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncND selector, void* d); + static CCCallFuncND * create(CCObject* pSelectorTarget, SEL_CallFuncND selector, void* d); + /** initializes the action with the callback and the data to pass as an argument */ virtual bool initWithTarget(CCObject* pSelectorTarget, SEL_CallFuncND selector, void* d); // super methods @@ -297,11 +347,18 @@ class CC_DLL CCCallFuncO : public CCCallFunc public: CCCallFuncO(); virtual ~CCCallFuncO(); + /** creates the action with the callback + @warning: This interface will be deprecated in future. + typedef void (CCObject::*SEL_CallFuncO)(CCObject*); + */ + //static CCCallFuncO * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncO selector, CCObject* pObject); + /** creates the action with the callback typedef void (CCObject::*SEL_CallFuncO)(CCObject*); */ - static CCCallFuncO * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncO selector, CCObject* pObject); + static CCCallFuncO * create(CCObject* pSelectorTarget, SEL_CallFuncO selector, CCObject* pObject); + /** initializes the action with the callback typedef void (CCObject::*SEL_CallFuncO)(CCObject*); diff --git a/cocos2dx/actions/CCActionInterval.cpp b/cocos2dx/actions/CCActionInterval.cpp index 347b57e0ae..dc10b21cc2 100644 --- a/cocos2dx/actions/CCActionInterval.cpp +++ b/cocos2dx/actions/CCActionInterval.cpp @@ -38,7 +38,16 @@ NS_CC_BEGIN // // IntervalAction // -CCActionInterval* CCActionInterval::actionWithDuration(float d) +// CCActionInterval* CCActionInterval::actionWithDuration(float d) +// { +// CCActionInterval *pAction = new CCActionInterval(); +// pAction->initWithDuration(d); +// pAction->autorelease(); +// +// return pAction; +// } + +CCActionInterval* CCActionInterval::create(float d) { CCActionInterval *pAction = new CCActionInterval(); pAction->initWithDuration(d); @@ -146,7 +155,16 @@ CCActionInterval* CCActionInterval::reverse(void) // // Sequence // -CCSequence* CCSequence::actionOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo) +// CCSequence* CCSequence::actionOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo) +// { +// CCSequence *pSequence = new CCSequence(); +// pSequence->initOneTwo(pActionOne, pActionTwo); +// pSequence->autorelease(); +// +// return pSequence; +// } + +CCSequence* CCSequence::create(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo) { CCSequence *pSequence = new CCSequence(); pSequence->initOneTwo(pActionOne, pActionTwo); @@ -155,7 +173,32 @@ CCSequence* CCSequence::actionOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTim return pSequence; } -CCFiniteTimeAction* CCSequence::actions(CCFiniteTimeAction *pAction1, ...) +// CCFiniteTimeAction* CCSequence::actions(CCFiniteTimeAction *pAction1, ...) +// { +// va_list params; +// va_start(params, pAction1); +// +// CCFiniteTimeAction *pNow; +// CCFiniteTimeAction *pPrev = pAction1; +// +// while (pAction1) +// { +// pNow = va_arg(params, CCFiniteTimeAction*); +// if (pNow) +// { +// pPrev = actionOneTwo(pPrev, pNow); +// } +// else +// { +// break; +// } +// } +// +// va_end(params); +// return pPrev; +// } + +CCFiniteTimeAction* CCSequence::create(CCFiniteTimeAction *pAction1, ...) { va_list params; va_start(params, pAction1); @@ -168,7 +211,7 @@ CCFiniteTimeAction* CCSequence::actions(CCFiniteTimeAction *pAction1, ...) pNow = va_arg(params, CCFiniteTimeAction*); if (pNow) { - pPrev = actionOneTwo(pPrev, pNow); + pPrev = create(pPrev, pNow); } else { @@ -180,13 +223,25 @@ CCFiniteTimeAction* CCSequence::actions(CCFiniteTimeAction *pAction1, ...) return pPrev; } -CCFiniteTimeAction* CCSequence::actionWithArray(CCArray *actions) +// CCFiniteTimeAction* CCSequence::actionWithArray(CCArray *actions) +// { +// CCFiniteTimeAction* prev = (CCFiniteTimeAction*)actions->objectAtIndex(0); +// +// for (unsigned int i = 1; i < actions->count(); ++i) +// { +// prev = actionOneTwo(prev, (CCFiniteTimeAction*)actions->objectAtIndex(i)); +// } +// +// return prev; +// } + +CCFiniteTimeAction* CCSequence::create(CCArray *actions) { CCFiniteTimeAction* prev = (CCFiniteTimeAction*)actions->objectAtIndex(0); for (unsigned int i = 1; i < actions->count(); ++i) { - prev = actionOneTwo(prev, (CCFiniteTimeAction*)actions->objectAtIndex(i)); + prev = create(prev, (CCFiniteTimeAction*)actions->objectAtIndex(i)); } return prev; @@ -307,13 +362,22 @@ void CCSequence::update(float t) CCActionInterval* CCSequence::reverse(void) { - return CCSequence::actionOneTwo(m_pActions[1]->reverse(), m_pActions[0]->reverse()); + return CCSequence::create(m_pActions[1]->reverse(), m_pActions[0]->reverse()); } // // Repeat // -CCRepeat* CCRepeat::actionWithAction(CCFiniteTimeAction *pAction, unsigned int times) +// CCRepeat* CCRepeat::actionWithAction(CCFiniteTimeAction *pAction, unsigned int times) +// { +// CCRepeat* pRepeat = new CCRepeat(); +// pRepeat->initWithAction(pAction, times); +// pRepeat->autorelease(); +// +// return pRepeat; +// } + +CCRepeat* CCRepeat::create(CCFiniteTimeAction *pAction, unsigned int times) { CCRepeat* pRepeat = new CCRepeat(); pRepeat->initWithAction(pAction, times); @@ -440,7 +504,7 @@ bool CCRepeat::isDone(void) CCActionInterval* CCRepeat::reverse(void) { - return CCRepeat::actionWithAction(m_pInnerAction->reverse(), m_uTimes); + return CCRepeat::create(m_pInnerAction->reverse(), m_uTimes); } // @@ -450,7 +514,20 @@ CCRepeatForever::~CCRepeatForever() { CC_SAFE_RELEASE(m_pInnerAction); } -CCRepeatForever *CCRepeatForever::actionWithAction(CCActionInterval *pAction) + +// CCRepeatForever *CCRepeatForever::actionWithAction(CCActionInterval *pAction) +// { +// CCRepeatForever *pRet = new CCRepeatForever(); +// if (pRet && pRet->initWithAction(pAction)) +// { +// pRet->autorelease(); +// return pRet; +// } +// CC_SAFE_DELETE(pRet); +// return NULL; +// } + +CCRepeatForever *CCRepeatForever::create(CCActionInterval *pAction) { CCRepeatForever *pRet = new CCRepeatForever(); if (pRet && pRet->initWithAction(pAction)) @@ -515,13 +592,38 @@ bool CCRepeatForever::isDone() CCActionInterval *CCRepeatForever::reverse() { - return (CCActionInterval*)(CCRepeatForever::actionWithAction(m_pInnerAction->reverse())); + return (CCActionInterval*)(CCRepeatForever::create(m_pInnerAction->reverse())); } // // Spawn // -CCFiniteTimeAction* CCSpawn::actions(CCFiniteTimeAction *pAction1, ...) +// CCFiniteTimeAction* CCSpawn::actions(CCFiniteTimeAction *pAction1, ...) +// { +// va_list params; +// va_start(params, pAction1); +// +// CCFiniteTimeAction *pNow; +// CCFiniteTimeAction *pPrev = pAction1; +// +// while (pAction1) +// { +// pNow = va_arg(params, CCFiniteTimeAction*); +// if (pNow) +// { +// pPrev = actionOneTwo(pPrev, pNow); +// } +// else +// { +// break; +// } +// } +// +// va_end(params); +// return pPrev; +// } + +CCFiniteTimeAction* CCSpawn::create(CCFiniteTimeAction *pAction1, ...) { va_list params; va_start(params, pAction1); @@ -534,7 +636,7 @@ CCFiniteTimeAction* CCSpawn::actions(CCFiniteTimeAction *pAction1, ...) pNow = va_arg(params, CCFiniteTimeAction*); if (pNow) { - pPrev = actionOneTwo(pPrev, pNow); + pPrev = create(pPrev, pNow); } else { @@ -546,19 +648,40 @@ CCFiniteTimeAction* CCSpawn::actions(CCFiniteTimeAction *pAction1, ...) return pPrev; } -CCFiniteTimeAction* CCSpawn::actionWithArray(CCArray *actions) +// CCFiniteTimeAction* CCSpawn::actionWithArray(CCArray *actions) +// { +// CCFiniteTimeAction* prev = (CCFiniteTimeAction*)actions->objectAtIndex(0); +// +// for (unsigned int i = 1; i < actions->count(); ++i) +// { +// prev = actionOneTwo(prev, (CCFiniteTimeAction*)actions->objectAtIndex(i)); +// } +// +// return prev; +// } + +CCFiniteTimeAction* CCSpawn::create(CCArray *actions) { CCFiniteTimeAction* prev = (CCFiniteTimeAction*)actions->objectAtIndex(0); for (unsigned int i = 1; i < actions->count(); ++i) { - prev = actionOneTwo(prev, (CCFiniteTimeAction*)actions->objectAtIndex(i)); + prev = create(prev, (CCFiniteTimeAction*)actions->objectAtIndex(i)); } return prev; } -CCSpawn* CCSpawn::actionOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2) +// CCSpawn* CCSpawn::actionOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2) +// { +// CCSpawn *pSpawn = new CCSpawn(); +// pSpawn->initOneTwo(pAction1, pAction2); +// pSpawn->autorelease(); +// +// return pSpawn; +// } + +CCSpawn* CCSpawn::create(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2) { CCSpawn *pSpawn = new CCSpawn(); pSpawn->initOneTwo(pAction1, pAction2); @@ -584,11 +707,11 @@ bool CCSpawn:: initOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAct if (d1 > d2) { - m_pTwo = CCSequence::actionOneTwo(pAction2, CCDelayTime::actionWithDuration(d1 - d2)); + m_pTwo = CCSequence::create(pAction2, CCDelayTime::create(d1 - d2)); } else if (d1 < d2) { - m_pOne = CCSequence::actionOneTwo(pAction1, CCDelayTime::actionWithDuration(d2 - d1)); + m_pOne = CCSequence::create(pAction1, CCDelayTime::create(d2 - d1)); } m_pOne->retain(); @@ -660,13 +783,22 @@ void CCSpawn::update(float time) CCActionInterval* CCSpawn::reverse(void) { - return CCSpawn::actionOneTwo(m_pOne->reverse(), m_pTwo->reverse()); + return CCSpawn::create(m_pOne->reverse(), m_pTwo->reverse()); } // // RotateTo // -CCRotateTo* CCRotateTo::actionWithDuration(float duration, float fDeltaAngle) +// CCRotateTo* CCRotateTo::actionWithDuration(float duration, float fDeltaAngle) +// { +// CCRotateTo* pRotateTo = new CCRotateTo(); +// pRotateTo->initWithDuration(duration, fDeltaAngle); +// pRotateTo->autorelease(); +// +// return pRotateTo; +// } + +CCRotateTo* CCRotateTo::create(float duration, float fDeltaAngle) { CCRotateTo* pRotateTo = new CCRotateTo(); pRotateTo->initWithDuration(duration, fDeltaAngle); @@ -748,7 +880,16 @@ void CCRotateTo::update(float time) // // RotateBy // -CCRotateBy* CCRotateBy::actionWithDuration(float duration, float fDeltaAngle) +// CCRotateBy* CCRotateBy::actionWithDuration(float duration, float fDeltaAngle) +// { +// CCRotateBy *pRotateBy = new CCRotateBy(); +// pRotateBy->initWithDuration(duration, fDeltaAngle); +// pRotateBy->autorelease(); +// +// return pRotateBy; +// } + +CCRotateBy* CCRotateBy::create(float duration, float fDeltaAngle) { CCRotateBy *pRotateBy = new CCRotateBy(); pRotateBy->initWithDuration(duration, fDeltaAngle); @@ -808,13 +949,22 @@ void CCRotateBy::update(float time) CCActionInterval* CCRotateBy::reverse(void) { - return CCRotateBy::actionWithDuration(m_fDuration, -m_fAngle); + return CCRotateBy::create(m_fDuration, -m_fAngle); } // // MoveTo // -CCMoveTo* CCMoveTo::actionWithDuration(float duration, const CCPoint& position) +// CCMoveTo* CCMoveTo::actionWithDuration(float duration, const CCPoint& position) +// { +// CCMoveTo *pMoveTo = new CCMoveTo(); +// pMoveTo->initWithDuration(duration, position); +// pMoveTo->autorelease(); +// +// return pMoveTo; +// } + +CCMoveTo* CCMoveTo::create(float duration, const CCPoint& position) { CCMoveTo *pMoveTo = new CCMoveTo(); pMoveTo->initWithDuration(duration, position); @@ -876,7 +1026,16 @@ void CCMoveTo::update(float time) // // MoveBy // -CCMoveBy* CCMoveBy::actionWithDuration(float duration, const CCPoint& position) +// CCMoveBy* CCMoveBy::actionWithDuration(float duration, const CCPoint& position) +// { +// CCMoveBy *pMoveBy = new CCMoveBy(); +// pMoveBy->initWithDuration(duration, position); +// pMoveBy->autorelease(); +// +// return pMoveBy; +// } + +CCMoveBy* CCMoveBy::create(float duration, const CCPoint& position) { CCMoveBy *pMoveBy = new CCMoveBy(); pMoveBy->initWithDuration(duration, position); @@ -928,13 +1087,31 @@ void CCMoveBy::startWithTarget(CCNode *pTarget) CCActionInterval* CCMoveBy::reverse(void) { - return CCMoveBy::actionWithDuration(m_fDuration, ccp(-m_delta.x, -m_delta.y)); + return CCMoveBy::create(m_fDuration, ccp(-m_delta.x, -m_delta.y)); } // // CCSkewTo // -CCSkewTo* CCSkewTo::actionWithDuration(float t, float sx, float sy) +// CCSkewTo* CCSkewTo::actionWithDuration(float t, float sx, float sy) +// { +// CCSkewTo *pSkewTo = new CCSkewTo(); +// if (pSkewTo) +// { +// if (pSkewTo->initWithDuration(t, sx, sy)) +// { +// pSkewTo->autorelease(); +// } +// else +// { +// CC_SAFE_DELETE(pSkewTo); +// } +// } +// +// return pSkewTo; +// } + +CCSkewTo* CCSkewTo::create(float t, float sx, float sy) { CCSkewTo *pSkewTo = new CCSkewTo(); if (pSkewTo) @@ -1060,7 +1237,25 @@ CCSkewTo::CCSkewTo() // // CCSkewBy // -CCSkewBy* CCSkewBy::actionWithDuration(float t, float sx, float sy) +// CCSkewBy* CCSkewBy::actionWithDuration(float t, float sx, float sy) +// { +// CCSkewBy *pSkewBy = new CCSkewBy(); +// if (pSkewBy) +// { +// if (pSkewBy->initWithDuration(t, sx, sy)) +// { +// pSkewBy->autorelease(); +// } +// else +// { +// CC_SAFE_DELETE(pSkewBy); +// } +// } +// +// return pSkewBy; +// } + +CCSkewBy* CCSkewBy::create(float t, float sx, float sy) { CCSkewBy *pSkewBy = new CCSkewBy(); if (pSkewBy) @@ -1104,13 +1299,22 @@ void CCSkewBy::startWithTarget(CCNode *pTarget) CCActionInterval* CCSkewBy::reverse() { - return actionWithDuration(m_fDuration, -m_fSkewX, -m_fSkewY); + return create(m_fDuration, -m_fSkewX, -m_fSkewY); } // // JumpBy // -CCJumpBy* CCJumpBy::actionWithDuration(float duration, const CCPoint& position, float height, unsigned int jumps) +// CCJumpBy* CCJumpBy::actionWithDuration(float duration, const CCPoint& position, float height, unsigned int jumps) +// { +// CCJumpBy *pJumpBy = new CCJumpBy(); +// pJumpBy->initWithDuration(duration, position, height, jumps); +// pJumpBy->autorelease(); +// +// return pJumpBy; +// } + +CCJumpBy* CCJumpBy::create(float duration, const CCPoint& position, float height, unsigned int jumps) { CCJumpBy *pJumpBy = new CCJumpBy(); pJumpBy->initWithDuration(duration, position, height, jumps); @@ -1177,14 +1381,23 @@ void CCJumpBy::update(float time) CCActionInterval* CCJumpBy::reverse(void) { - return CCJumpBy::actionWithDuration(m_fDuration, ccp(-m_delta.x, -m_delta.y), + return CCJumpBy::create(m_fDuration, ccp(-m_delta.x, -m_delta.y), m_height, m_nJumps); } // // JumpTo // -CCJumpTo* CCJumpTo::actionWithDuration(float duration, const CCPoint& position, float height, int jumps) +// CCJumpTo* CCJumpTo::actionWithDuration(float duration, const CCPoint& position, float height, int jumps) +// { +// CCJumpTo *pJumpTo = new CCJumpTo(); +// pJumpTo->initWithDuration(duration, position, height, jumps); +// pJumpTo->autorelease(); +// +// return pJumpTo; +// } + +CCJumpTo* CCJumpTo::create(float duration, const CCPoint& position, float height, int jumps) { CCJumpTo *pJumpTo = new CCJumpTo(); pJumpTo->initWithDuration(duration, position, height, jumps); @@ -1237,7 +1450,16 @@ static inline float bezierat( float a, float b, float c, float d, float t ) // // BezierBy // -CCBezierBy* CCBezierBy::actionWithDuration(float t, const ccBezierConfig& c) +// CCBezierBy* CCBezierBy::actionWithDuration(float t, const ccBezierConfig& c) +// { +// CCBezierBy *pBezierBy = new CCBezierBy(); +// pBezierBy->initWithDuration(t, c); +// pBezierBy->autorelease(); +// +// return pBezierBy; +// } + +CCBezierBy* CCBezierBy::create(float t, const ccBezierConfig& c) { CCBezierBy *pBezierBy = new CCBezierBy(); pBezierBy->initWithDuration(t, c); @@ -1314,14 +1536,23 @@ CCActionInterval* CCBezierBy::reverse(void) r.controlPoint_1 = ccpAdd(m_sConfig.controlPoint_2, ccpNeg(m_sConfig.endPosition)); r.controlPoint_2 = ccpAdd(m_sConfig.controlPoint_1, ccpNeg(m_sConfig.endPosition)); - CCBezierBy *pAction = CCBezierBy::actionWithDuration(m_fDuration, r); + CCBezierBy *pAction = CCBezierBy::create(m_fDuration, r); return pAction; } // // BezierTo // -CCBezierTo* CCBezierTo::actionWithDuration(float t, const ccBezierConfig& c) +// CCBezierTo* CCBezierTo::actionWithDuration(float t, const ccBezierConfig& c) +// { +// CCBezierTo *pBezierTo = new CCBezierTo(); +// pBezierTo->initWithDuration(t, c); +// pBezierTo->autorelease(); +// +// return pBezierTo; +// } + +CCBezierTo* CCBezierTo::create(float t, const ccBezierConfig& c) { CCBezierTo *pBezierTo = new CCBezierTo(); pBezierTo->initWithDuration(t, c); @@ -1330,6 +1561,7 @@ CCBezierTo* CCBezierTo::actionWithDuration(float t, const ccBezierConfig& c) return pBezierTo; } + CCObject* CCBezierTo::copyWithZone(CCZone *pZone) { CCZone* pNewZone = NULL; @@ -1364,7 +1596,16 @@ void CCBezierTo::startWithTarget(CCNode *pTarget) // // ScaleTo // -CCScaleTo* CCScaleTo::actionWithDuration(float duration, float s) +// CCScaleTo* CCScaleTo::actionWithDuration(float duration, float s) +// { +// CCScaleTo *pScaleTo = new CCScaleTo(); +// pScaleTo->initWithDuration(duration, s); +// pScaleTo->autorelease(); +// +// return pScaleTo; +// } + +CCScaleTo* CCScaleTo::create(float duration, float s) { CCScaleTo *pScaleTo = new CCScaleTo(); pScaleTo->initWithDuration(duration, s); @@ -1386,7 +1627,16 @@ bool CCScaleTo::initWithDuration(float duration, float s) return false; } -CCScaleTo* CCScaleTo::actionWithDuration(float duration, float sx, float sy) +// CCScaleTo* CCScaleTo::actionWithDuration(float duration, float sx, float sy) +// { +// CCScaleTo *pScaleTo = new CCScaleTo(); +// pScaleTo->initWithDuration(duration, sx, sy); +// pScaleTo->autorelease(); +// +// return pScaleTo; +// } + +CCScaleTo* CCScaleTo::create(float duration, float sx, float sy) { CCScaleTo *pScaleTo = new CCScaleTo(); pScaleTo->initWithDuration(duration, sx, sy); @@ -1453,7 +1703,25 @@ void CCScaleTo::update(float time) // // ScaleBy // -CCScaleBy* CCScaleBy::actionWithDuration(float duration, float s) +// CCScaleBy* CCScaleBy::actionWithDuration(float duration, float s) +// { +// CCScaleBy *pScaleBy = new CCScaleBy(); +// pScaleBy->initWithDuration(duration, s); +// pScaleBy->autorelease(); +// +// return pScaleBy; +// } +// +// CCScaleBy* CCScaleBy::actionWithDuration(float duration, float sx, float sy) +// { +// CCScaleBy *pScaleBy = new CCScaleBy(); +// pScaleBy->initWithDuration(duration, sx, sy); +// pScaleBy->autorelease(); +// +// return pScaleBy; +// } + +CCScaleBy* CCScaleBy::create(float duration, float s) { CCScaleBy *pScaleBy = new CCScaleBy(); pScaleBy->initWithDuration(duration, s); @@ -1462,7 +1730,7 @@ CCScaleBy* CCScaleBy::actionWithDuration(float duration, float s) return pScaleBy; } -CCScaleBy* CCScaleBy::actionWithDuration(float duration, float sx, float sy) +CCScaleBy* CCScaleBy::create(float duration, float sx, float sy) { CCScaleBy *pScaleBy = new CCScaleBy(); pScaleBy->initWithDuration(duration, sx, sy); @@ -1504,13 +1772,22 @@ void CCScaleBy::startWithTarget(CCNode *pTarget) CCActionInterval* CCScaleBy::reverse(void) { - return CCScaleBy::actionWithDuration(m_fDuration, 1 / m_fEndScaleX, 1 / m_fEndScaleY); + return CCScaleBy::create(m_fDuration, 1 / m_fEndScaleX, 1 / m_fEndScaleY); } // // Blink // -CCBlink* CCBlink::actionWithDuration(float duration, unsigned int uBlinks) +// CCBlink* CCBlink::actionWithDuration(float duration, unsigned int uBlinks) +// { +// CCBlink *pBlink = new CCBlink(); +// pBlink->initWithDuration(duration, uBlinks); +// pBlink->autorelease(); +// +// return pBlink; +// } + +CCBlink* CCBlink::create(float duration, unsigned int uBlinks) { CCBlink *pBlink = new CCBlink(); pBlink->initWithDuration(duration, uBlinks); @@ -1567,18 +1844,28 @@ void CCBlink::update(float time) CCActionInterval* CCBlink::reverse(void) { // return 'self' - return CCBlink::actionWithDuration(m_fDuration, m_nTimes); + return CCBlink::create(m_fDuration, m_nTimes); } // // FadeIn // -CCFadeIn* CCFadeIn::actionWithDuration(float d) +// CCFadeIn* CCFadeIn::actionWithDuration(float d) +// { +// CCFadeIn* pAction = new CCFadeIn(); +// +// pAction->initWithDuration(d); +// pAction->autorelease(); +// +// return pAction; +// } + +CCFadeIn* CCFadeIn::create(float d) { CCFadeIn* pAction = new CCFadeIn(); pAction->initWithDuration(d); - pAction->autorelease(); + pAction->autorelease(); return pAction; } @@ -1617,18 +1904,28 @@ void CCFadeIn::update(float time) CCActionInterval* CCFadeIn::reverse(void) { - return CCFadeOut::actionWithDuration(m_fDuration); + return CCFadeOut::create(m_fDuration); } // // FadeOut // -CCFadeOut* CCFadeOut::actionWithDuration(float d) +// CCFadeOut* CCFadeOut::actionWithDuration(float d) +// { +// CCFadeOut* pAction = new CCFadeOut(); +// +// pAction->initWithDuration(d); +// pAction->autorelease(); +// +// return pAction; +// } + +CCFadeOut* CCFadeOut::create(float d) { CCFadeOut* pAction = new CCFadeOut(); pAction->initWithDuration(d); - pAction->autorelease(); + pAction->autorelease(); return pAction; } @@ -1667,19 +1964,28 @@ void CCFadeOut::update(float time) CCActionInterval* CCFadeOut::reverse(void) { - return CCFadeIn::actionWithDuration(m_fDuration); + return CCFadeIn::create(m_fDuration); } // // FadeTo // -CCFadeTo* CCFadeTo::actionWithDuration(float duration, GLubyte opacity) +// CCFadeTo* CCFadeTo::actionWithDuration(float duration, GLubyte opacity) +// { +// CCFadeTo *pFadeTo = new CCFadeTo(); +// pFadeTo->initWithDuration(duration, opacity); +// pFadeTo->autorelease(); +// +// return pFadeTo; +// } + +CCFadeTo* CCFadeTo::create(float duration, GLubyte opacity) { CCFadeTo *pFadeTo = new CCFadeTo(); pFadeTo->initWithDuration(duration, opacity); pFadeTo->autorelease(); - return pFadeTo; + return pFadeTo; } bool CCFadeTo::initWithDuration(float duration, GLubyte opacity) @@ -1741,7 +2047,16 @@ void CCFadeTo::update(float time) // // TintTo // -CCTintTo* CCTintTo::actionWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue) +// CCTintTo* CCTintTo::actionWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue) +// { +// CCTintTo *pTintTo = new CCTintTo(); +// pTintTo->initWithDuration(duration, red, green, blue); +// pTintTo->autorelease(); +// +// return pTintTo; +// } + +CCTintTo* CCTintTo::create(float duration, GLubyte red, GLubyte green, GLubyte blue) { CCTintTo *pTintTo = new CCTintTo(); pTintTo->initWithDuration(duration, red, green, blue); @@ -1809,7 +2124,16 @@ void CCTintTo::update(float time) // // TintBy // -CCTintBy* CCTintBy::actionWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue) +// CCTintBy* CCTintBy::actionWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue) +// { +// CCTintBy *pTintBy = new CCTintBy(); +// pTintBy->initWithDuration(duration, deltaRed, deltaGreen, deltaBlue); +// pTintBy->autorelease(); +// +// return pTintBy; +// } + +CCTintBy* CCTintBy::create(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue) { CCTintBy *pTintBy = new CCTintBy(); pTintBy->initWithDuration(duration, deltaRed, deltaGreen, deltaBlue); @@ -1882,13 +2206,23 @@ void CCTintBy::update(float time) CCActionInterval* CCTintBy::reverse(void) { - return CCTintBy::actionWithDuration(m_fDuration, -m_deltaR, -m_deltaG, -m_deltaB); + return CCTintBy::create(m_fDuration, -m_deltaR, -m_deltaG, -m_deltaB); } // // DelayTime // -CCDelayTime* CCDelayTime::actionWithDuration(float d) +// CCDelayTime* CCDelayTime::actionWithDuration(float d) +// { +// CCDelayTime* pAction = new CCDelayTime(); +// +// pAction->initWithDuration(d); +// pAction->autorelease(); +// +// return pAction; +// } + +CCDelayTime* CCDelayTime::create(float d) { CCDelayTime* pAction = new CCDelayTime(); @@ -1929,13 +2263,23 @@ void CCDelayTime::update(float time) CCActionInterval* CCDelayTime::reverse(void) { - return CCDelayTime::actionWithDuration(m_fDuration); + return CCDelayTime::create(m_fDuration); } // // ReverseTime // -CCReverseTime* CCReverseTime::actionWithAction(CCFiniteTimeAction *pAction) +// CCReverseTime* CCReverseTime::actionWithAction(CCFiniteTimeAction *pAction) +// { +// // casting to prevent warnings +// CCReverseTime *pReverseTime = new CCReverseTime(); +// pReverseTime->initWithAction(pAction); +// pReverseTime->autorelease(); +// +// return pReverseTime; +// } + +CCReverseTime* CCReverseTime::create(CCFiniteTimeAction *pAction) { // casting to prevent warnings CCReverseTime *pReverseTime = new CCReverseTime(); @@ -2025,7 +2369,16 @@ CCActionInterval* CCReverseTime::reverse(void) // // Animate // -CCAnimate* CCAnimate::actionWithAnimation(CCAnimation *pAnimation) +// CCAnimate* CCAnimate::actionWithAnimation(CCAnimation *pAnimation) +// { +// CCAnimate *pAnimate = new CCAnimate(); +// pAnimate->initWithAnimation(pAnimation); +// pAnimate->autorelease(); +// +// return pAnimate; +// } + +CCAnimate* CCAnimate::create(CCAnimation *pAnimation) { CCAnimate *pAnimate = new CCAnimate(); pAnimate->initWithAnimation(pAnimation); @@ -2197,9 +2550,9 @@ CCActionInterval* CCAnimate::reverse(void) } } - CCAnimation *newAnim = CCAnimation::animationWithAnimationFrames(pNewArray, m_pAnimation->getDelayPerUnit(), m_pAnimation->getLoops()); + CCAnimation *newAnim = CCAnimation::createWithAnimationFrames(pNewArray, m_pAnimation->getDelayPerUnit(), m_pAnimation->getLoops()); newAnim->setRestoreOriginalFrame(m_pAnimation->getRestoreOriginalFrame()); - return actionWithAnimation(newAnim); + return create(newAnim); } // CCTargetedAction @@ -2217,7 +2570,15 @@ CCTargetedAction::~CCTargetedAction() CC_SAFE_RELEASE(m_pAction); } -CCTargetedAction* CCTargetedAction::actionWithTarget(CCNode* pTarget, CCFiniteTimeAction* pAction) +// CCTargetedAction* CCTargetedAction::actionWithTarget(CCNode* pTarget, CCFiniteTimeAction* pAction) +// { +// CCTargetedAction* p = new CCTargetedAction(); +// p->initWithTarget(pTarget, pAction); +// p->autorelease(); +// return p; +// } + +CCTargetedAction* CCTargetedAction::create(CCNode* pTarget, CCFiniteTimeAction* pAction) { CCTargetedAction* p = new CCTargetedAction(); p->initWithTarget(pTarget, pAction); @@ -2225,6 +2586,7 @@ CCTargetedAction* CCTargetedAction::actionWithTarget(CCNode* pTarget, CCFiniteTi return p; } + bool CCTargetedAction::initWithTarget(CCNode* pTarget, CCFiniteTimeAction* pAction) { if(CCActionInterval::initWithDuration(pAction->getDuration())) diff --git a/cocos2dx/actions/CCActionInterval.h b/cocos2dx/actions/CCActionInterval.h index 6107ca4c12..d3584c3b6a 100644 --- a/cocos2dx/actions/CCActionInterval.h +++ b/cocos2dx/actions/CCActionInterval.h @@ -72,8 +72,13 @@ public: virtual CCActionInterval* reverse(void); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCActionInterval* actionWithDuration(float d); + /** creates the action */ - static CCActionInterval* actionWithDuration(float d); + static CCActionInterval* create(float d); public: //extension in CCGridAction @@ -102,13 +107,26 @@ public: virtual CCActionInterval* reverse(void); public: - /** helper constructor to create an array of sequenceable actions */ - static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...); - /** helper contructor to create an array of sequenceable actions given an array */ - static CCFiniteTimeAction* actionWithArray(CCArray *arrayOfActions); + /** helper constructor to create an array of sequenceable actions + @warning: This interface will be deprecated in future. + */ + //static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...); + /** helper contructor to create an array of sequenceable actions given an array + @warning: This interface will be deprecated in future. + */ + //static CCFiniteTimeAction* actionWithArray(CCArray *arrayOfActions); + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCSequence* actionOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo); + /** helper constructor to create an array of sequenceable actions */ + static CCFiniteTimeAction* create(CCFiniteTimeAction *pAction1, ...); + /** helper contructor to create an array of sequenceable actions given an array */ + static CCFiniteTimeAction* create(CCArray *arrayOfActions); /** creates the action */ - static CCSequence* actionOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo); + static CCSequence* create(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo); + protected: CCFiniteTimeAction *m_pActions[2]; float m_split; @@ -149,9 +167,13 @@ public: } public: - /** creates a CCRepeat action. Times is an unsigned integer between 1 and pow(2,30) */ - static CCRepeat* actionWithAction(CCFiniteTimeAction *pAction, unsigned int times); + /** creates a CCRepeat action. Times is an unsigned integer between 1 and pow(2,30) + @warning: This interface will be deprecated in future. + */ + //static CCRepeat* actionWithAction(CCFiniteTimeAction *pAction, unsigned int times); + /** creates a CCRepeat action. Times is an unsigned integer between 1 and pow(2,30) */ + static CCRepeat* create(CCFiniteTimeAction *pAction, unsigned int times); protected: unsigned int m_uTimes; unsigned int m_uTotal; @@ -197,9 +219,12 @@ public: } public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCRepeatForever* actionWithAction(CCActionInterval *pAction); /** creates the action */ - static CCRepeatForever* actionWithAction(CCActionInterval *pAction); - + static CCRepeatForever* create(CCActionInterval *pAction); protected: /** Inner action */ CCActionInterval *m_pInnerAction; @@ -222,14 +247,29 @@ public: virtual CCActionInterval* reverse(void); public: + /** helper constructor to create an array of spawned actions + @warning: This interface will be deprecated in future. + */ + //static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...); + + /** helper contructor to create an array of spawned actions given an array + @warning: This interface will be deprecated in future. + */ + //static CCFiniteTimeAction* actionWithArray(CCArray *arrayOfActions); + + /** creates the Spawn action + @warning: This interface will be deprecated in future. + */ + //static CCSpawn* actionOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2); + /** helper constructor to create an array of spawned actions */ - static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...); + static CCFiniteTimeAction* create(CCFiniteTimeAction *pAction1, ...); /** helper contructor to create an array of spawned actions given an array */ - static CCFiniteTimeAction* actionWithArray(CCArray *arrayOfActions); + static CCFiniteTimeAction* create(CCArray *arrayOfActions); /** creates the Spawn action */ - static CCSpawn* actionOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2); + static CCSpawn* create(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2); protected: CCFiniteTimeAction *m_pOne; @@ -251,9 +291,12 @@ public: virtual void update(float time); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCRotateTo* actionWithDuration(float duration, float fDeltaAngle); /** creates the action */ - static CCRotateTo* actionWithDuration(float duration, float fDeltaAngle); - + static CCRotateTo* create(float duration, float fDeltaAngle); protected: float m_fDstAngle; float m_fStartAngle; @@ -274,9 +317,12 @@ public: virtual CCActionInterval* reverse(void); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCRotateBy* actionWithDuration(float duration, float fDeltaAngle); /** creates the action */ - static CCRotateBy* actionWithDuration(float duration, float fDeltaAngle); - + static CCRotateBy* create(float duration, float fDeltaAngle); protected: float m_fAngle; float m_fStartAngle; @@ -295,9 +341,12 @@ public: virtual void update(float time); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCMoveTo* actionWithDuration(float duration, const CCPoint& position); /** creates the action */ - static CCMoveTo* actionWithDuration(float duration, const CCPoint& position); - + static CCMoveTo* create(float duration, const CCPoint& position); protected: CCPoint m_endPosition; CCPoint m_startPosition; @@ -319,8 +368,12 @@ public: virtual CCActionInterval* reverse(void); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCMoveBy* actionWithDuration(float duration, const CCPoint& position); /** creates the action */ - static CCMoveBy* actionWithDuration(float duration, const CCPoint& position); + static CCMoveBy* create(float duration, const CCPoint& position); }; /** Skews a CCNode object to given angles by modifying it's skewX and skewY attributes @@ -336,8 +389,13 @@ public: virtual void update(float time); public: - static CCSkewTo* actionWithDuration(float t, float sx, float sy); + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCSkewTo* actionWithDuration(float t, float sx, float sy); + /** creates the action */ + static CCSkewTo* create(float t, float sx, float sy); protected: float m_fSkewX; float m_fSkewY; @@ -360,7 +418,12 @@ public: virtual CCActionInterval* reverse(void); public: - static CCSkewBy* actionWithDuration(float t, float deltaSkewX, float deltaSkewY); + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCSkewBy* actionWithDuration(float t, float deltaSkewX, float deltaSkewY); + /** creates the action */ + static CCSkewBy* create(float t, float deltaSkewX, float deltaSkewY); }; /** @brief Moves a CCNode object simulating a parabolic jump movement by modifying it's position attribute. @@ -377,9 +440,12 @@ public: virtual CCActionInterval* reverse(void); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCJumpBy* actionWithDuration(float duration, const CCPoint& position, float height, unsigned int jumps); /** creates the action */ - static CCJumpBy* actionWithDuration(float duration, const CCPoint& position, float height, unsigned int jumps); - + static CCJumpBy* create(float duration, const CCPoint& position, float height, unsigned int jumps); protected: CCPoint m_startPosition; CCPoint m_delta; @@ -396,8 +462,12 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + // static CCJumpTo* actionWithDuration(float duration, const CCPoint& position, float height, int jumps); /** creates the action */ - static CCJumpTo* actionWithDuration(float duration, const CCPoint& position, float height, int jumps); + static CCJumpTo* create(float duration, const CCPoint& position, float height, int jumps); }; /** @typedef bezier configuration structure @@ -425,9 +495,12 @@ public: virtual CCActionInterval* reverse(void); public: + /** creates the action with a duration and a bezier configuration + @warning: This interface will be deprecated in future. + */ + //static CCBezierBy* actionWithDuration(float t, const ccBezierConfig& c); /** creates the action with a duration and a bezier configuration */ - static CCBezierBy* actionWithDuration(float t, const ccBezierConfig& c); - + static CCBezierBy* create(float t, const ccBezierConfig& c); protected: ccBezierConfig m_sConfig; CCPoint m_startPosition; @@ -443,8 +516,13 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); public: + /** creates the action with a duration and a bezier configuration + @warning: This interface will be deprecated in future. + */ + //static CCBezierTo* actionWithDuration(float t, const ccBezierConfig& c); + /** creates the action with a duration and a bezier configuration */ - static CCBezierTo* actionWithDuration(float t, const ccBezierConfig& c); + static CCBezierTo* create(float t, const ccBezierConfig& c); }; /** @brief Scales a CCNode object to a zoom factor by modifying it's scale attribute. @@ -464,11 +542,21 @@ public: virtual void update(float time); public: + /** creates the action with the same scale factor for X and Y + @warning: This interface will be deprecated in future. + */ + //static CCScaleTo* actionWithDuration(float duration, float s); + + /** creates the action with and X factor and a Y factor + @warning: This interface will be deprecated in future. + */ + //static CCScaleTo* actionWithDuration(float duration, float sx, float sy); + /** creates the action with the same scale factor for X and Y */ - static CCScaleTo* actionWithDuration(float duration, float s); + static CCScaleTo* create(float duration, float s); /** creates the action with and X factor and a Y factor */ - static CCScaleTo* actionWithDuration(float duration, float sx, float sy); + static CCScaleTo* create(float duration, float sx, float sy); protected: float m_fScaleX; float m_fScaleY; @@ -490,11 +578,21 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); public: + /** creates the action with the same scale factor for X and Y + @warning: This interface will be deprecated in future. + */ + //static CCScaleBy* actionWithDuration(float duration, float s); + + /** creates the action with and X factor and a Y factor + @warning: This interface will be deprecated in future. + */ + //static CCScaleBy* actionWithDuration(float duration, float sx, float sy); + /** creates the action with the same scale factor for X and Y */ - static CCScaleBy* actionWithDuration(float duration, float s); + static CCScaleBy* create(float duration, float s); /** creates the action with and X factor and a Y factor */ - static CCScaleBy* actionWithDuration(float duration, float sx, float sy); + static CCScaleBy* create(float duration, float sx, float sy); }; /** @brief Blinks a CCNode object by modifying it's visible attribute @@ -510,8 +608,12 @@ public: virtual CCActionInterval* reverse(void); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCBlink* actionWithDuration(float duration, unsigned int uBlinks); /** creates the action */ - static CCBlink* actionWithDuration(float duration, unsigned int uBlinks); + static CCBlink* create(float duration, unsigned int uBlinks); protected: unsigned int m_nTimes; }; @@ -527,8 +629,12 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCFadeIn* actionWithDuration(float d); /** creates the action */ - static CCFadeIn* actionWithDuration(float d); + static CCFadeIn* create(float d); }; /** @brief Fades Out an object that implements the CCRGBAProtocol protocol. It modifies the opacity from 255 to 0. @@ -542,8 +648,13 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCFadeOut* actionWithDuration(float d); + /** creates the action */ - static CCFadeOut* actionWithDuration(float d); + static CCFadeOut* create(float d); }; /** @brief Fades an object that implements the CCRGBAProtocol protocol. It modifies the opacity from the current value to a custom one. @@ -560,9 +671,12 @@ public: virtual void update(float time); public: + /** creates an action with duration and opacity + @warning: This interface will be deprecated in future. + */ + //static CCFadeTo* actionWithDuration(float duration, GLubyte opacity); /** creates an action with duration and opacity */ - static CCFadeTo* actionWithDuration(float duration, GLubyte opacity); - + static CCFadeTo* create(float duration, GLubyte opacity); protected: GLubyte m_toOpacity; GLubyte m_fromOpacity; @@ -583,9 +697,12 @@ public: virtual void update(float time); public: + /** creates an action with duration and color + @warning: This interface will be deprecated in future. + */ + //static CCTintTo* actionWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue); /** creates an action with duration and color */ - static CCTintTo* actionWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue); - + static CCTintTo* create(float duration, GLubyte red, GLubyte green, GLubyte blue); protected: ccColor3B m_to; ccColor3B m_from; @@ -606,9 +723,12 @@ public: virtual CCActionInterval* reverse(void); public: + /** creates an action with duration and color + @warning: This interface will be deprecated in future. + */ + // static CCTintBy* actionWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); /** creates an action with duration and color */ - static CCTintBy* actionWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); - + static CCTintBy* create(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); protected: GLshort m_deltaR; GLshort m_deltaG; @@ -629,8 +749,13 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCDelayTime* actionWithDuration(float d); + /** creates the action */ - static CCDelayTime* actionWithDuration(float d); + static CCDelayTime* create(float d); }; /** @brief Executes an action in reverse order, from time=duration to time=0 @@ -656,9 +781,12 @@ public: virtual CCActionInterval* reverse(void); public: + /** creates the action + @warning: This interface will be deprecated in future. + */ + //static CCReverseTime* actionWithAction(CCFiniteTimeAction *pAction); /** creates the action */ - static CCReverseTime* actionWithAction(CCFiniteTimeAction *pAction); - + static CCReverseTime* create(CCFiniteTimeAction *pAction); protected: CCFiniteTimeAction *m_pOther; }; @@ -682,9 +810,12 @@ public: virtual CCActionInterval* reverse(void); public: + /** creates the action with an Animation and will restore the original frame when the animation is over + @warning: This interface will be deprecated in future. + */ + //static CCAnimate* actionWithAnimation(CCAnimation *pAnimation); /** creates the action with an Animation and will restore the original frame when the animation is over */ - static CCAnimate* actionWithAnimation(CCAnimation *pAnimation); - + static CCAnimate* create(CCAnimation *pAnimation); CC_SYNTHESIZE_RETAIN(CCAnimation*, m_pAnimation, Animation) protected: std::vector* m_pSplitTimes; @@ -701,8 +832,12 @@ class CC_DLL CCTargetedAction : public CCActionInterval public: CCTargetedAction(); virtual ~CCTargetedAction(); + /** Create an action with the specified action and forced target + @warning: This interface will be deprecated in future. + */ + //static CCTargetedAction* actionWithTarget(CCNode* pTarget, CCFiniteTimeAction* pAction); /** Create an action with the specified action and forced target */ - static CCTargetedAction* actionWithTarget(CCNode* pTarget, CCFiniteTimeAction* pAction); + static CCTargetedAction* create(CCNode* pTarget, CCFiniteTimeAction* pAction); /** Init an action with the specified action and forced target */ bool initWithTarget(CCNode* pTarget, CCFiniteTimeAction* pAction); diff --git a/cocos2dx/actions/CCActionPageTurn3D.cpp b/cocos2dx/actions/CCActionPageTurn3D.cpp index 064f3cdf00..b8dcf7b21e 100644 --- a/cocos2dx/actions/CCActionPageTurn3D.cpp +++ b/cocos2dx/actions/CCActionPageTurn3D.cpp @@ -27,7 +27,26 @@ THE SOFTWARE. NS_CC_BEGIN -CCPageTurn3D* CCPageTurn3D::actionWithSize(const ccGridSize& gridSize, float time) +// CCPageTurn3D* CCPageTurn3D::actionWithSize(const ccGridSize& gridSize, float time) +// { +// CCPageTurn3D *pAction = new CCPageTurn3D(); +// +// if (pAction) +// { +// if (pAction->initWithSize(gridSize, time)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pAction); +// } +// } +// +// return pAction; +// } + +CCPageTurn3D* CCPageTurn3D::create(const ccGridSize& gridSize, float time) { CCPageTurn3D *pAction = new CCPageTurn3D(); diff --git a/cocos2dx/actions/CCActionPageTurn3D.h b/cocos2dx/actions/CCActionPageTurn3D.h index 7bdb78e9c7..733756ce6e 100644 --- a/cocos2dx/actions/CCActionPageTurn3D.h +++ b/cocos2dx/actions/CCActionPageTurn3D.h @@ -43,8 +43,12 @@ public: virtual void update(float time); public: + /** create the action + @warning: This interface will be deprecated in future. + */ + //static CCPageTurn3D* actionWithSize(const ccGridSize& gridSize, float time); /** create the action */ - static CCPageTurn3D* actionWithSize(const ccGridSize& gridSize, float time); + static CCPageTurn3D* create(const ccGridSize& gridSize, float time); }; NS_CC_END diff --git a/cocos2dx/actions/CCActionProgressTimer.cpp b/cocos2dx/actions/CCActionProgressTimer.cpp index 6738ccceb9..84ff8e1ca6 100644 --- a/cocos2dx/actions/CCActionProgressTimer.cpp +++ b/cocos2dx/actions/CCActionProgressTimer.cpp @@ -32,7 +32,16 @@ NS_CC_BEGIN // implementation of CCProgressTo -CCProgressTo* CCProgressTo::actionWithDuration(float duration, float fPercent) +// CCProgressTo* CCProgressTo::actionWithDuration(float duration, float fPercent) +// { +// CCProgressTo *pProgressTo = new CCProgressTo(); +// pProgressTo->initWithDuration(duration, fPercent); +// pProgressTo->autorelease(); +// +// return pProgressTo; +// } + +CCProgressTo* CCProgressTo::create(float duration, float fPercent) { CCProgressTo *pProgressTo = new CCProgressTo(); pProgressTo->initWithDuration(duration, fPercent); @@ -96,7 +105,16 @@ void CCProgressTo::update(float time) // implementation of CCProgressFromTo -CCProgressFromTo* CCProgressFromTo::actionWithDuration(float duration, float fFromPercentage, float fToPercentage) +// CCProgressFromTo* CCProgressFromTo::actionWithDuration(float duration, float fFromPercentage, float fToPercentage) +// { +// CCProgressFromTo *pProgressFromTo = new CCProgressFromTo(); +// pProgressFromTo->initWithDuration(duration, fFromPercentage, fToPercentage); +// pProgressFromTo->autorelease(); +// +// return pProgressFromTo; +// } + +CCProgressFromTo* CCProgressFromTo::create(float duration, float fFromPercentage, float fToPercentage) { CCProgressFromTo *pProgressFromTo = new CCProgressFromTo(); pProgressFromTo->initWithDuration(duration, fFromPercentage, fToPercentage); @@ -143,7 +161,7 @@ CCObject* CCProgressFromTo::copyWithZone(CCZone *pZone) CCActionInterval* CCProgressFromTo::reverse(void) { - return CCProgressFromTo::actionWithDuration(m_fDuration, m_fTo, m_fFrom); + return CCProgressFromTo::create(m_fDuration, m_fTo, m_fFrom); } void CCProgressFromTo::startWithTarget(CCNode *pTarget) diff --git a/cocos2dx/actions/CCActionProgressTimer.h b/cocos2dx/actions/CCActionProgressTimer.h index 3ac86890c0..7034c45c80 100644 --- a/cocos2dx/actions/CCActionProgressTimer.h +++ b/cocos2dx/actions/CCActionProgressTimer.h @@ -44,9 +44,12 @@ public: virtual void update(float time); public: + /** Creates and initializes with a duration and a percent + @warning: This interface will be deprecated in future. + */ + //static CCProgressTo* actionWithDuration(float duration, float fPercent); /** Creates and initializes with a duration and a percent */ - static CCProgressTo* actionWithDuration(float duration, float fPercent); - + static CCProgressTo* create(float duration, float fPercent); protected: float m_fTo; float m_fFrom; @@ -68,9 +71,12 @@ public: virtual void update(float time); public: + /** Creates and initializes the action with a duration, a "from" percentage and a "to" percentage + @warning: This interface will be deprecated in future. + */ + //static CCProgressFromTo* actionWithDuration(float duration, float fFromPercentage, float fToPercentage); /** Creates and initializes the action with a duration, a "from" percentage and a "to" percentage */ - static CCProgressFromTo* actionWithDuration(float duration, float fFromPercentage, float fToPercentage); - + static CCProgressFromTo* create(float duration, float fFromPercentage, float fToPercentage); protected: float m_fTo; float m_fFrom; diff --git a/cocos2dx/actions/CCActionTiledGrid.cpp b/cocos2dx/actions/CCActionTiledGrid.cpp index be2d7a2d98..ccfb43994c 100644 --- a/cocos2dx/actions/CCActionTiledGrid.cpp +++ b/cocos2dx/actions/CCActionTiledGrid.cpp @@ -41,7 +41,26 @@ struct Tile // implementation of ShakyTiles3D -CCShakyTiles3D* CCShakyTiles3D::actionWithRange(int nRange, bool bShakeZ,const ccGridSize& gridSize, float duration) +// CCShakyTiles3D* CCShakyTiles3D::actionWithRange(int nRange, bool bShakeZ,const ccGridSize& gridSize, float duration) +// { +// CCShakyTiles3D *pAction = new CCShakyTiles3D(); +// +// if (pAction) +// { +// if (pAction->initWithRange(nRange, bShakeZ, gridSize, duration)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pAction); +// } +// } +// +// return pAction; +// } + +CCShakyTiles3D* CCShakyTiles3D::create(int nRange, bool bShakeZ,const ccGridSize& gridSize, float duration) { CCShakyTiles3D *pAction = new CCShakyTiles3D(); @@ -134,7 +153,26 @@ void CCShakyTiles3D::update(float time) // implementation of CCShatteredTiles3D -CCShatteredTiles3D* CCShatteredTiles3D::actionWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize, float duration) +// CCShatteredTiles3D* CCShatteredTiles3D::actionWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize, float duration) +// { +// CCShatteredTiles3D *pAction = new CCShatteredTiles3D(); +// +// if (pAction) +// { +// if (pAction->initWithRange(nRange, bShatterZ, gridSize, duration)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pAction); +// } +// } +// +// return pAction; +// } + +CCShatteredTiles3D* CCShatteredTiles3D::create(int nRange, bool bShatterZ, const ccGridSize& gridSize, float duration) { CCShatteredTiles3D *pAction = new CCShatteredTiles3D(); @@ -233,7 +271,26 @@ void CCShatteredTiles3D::update(float time) // implementation of CCShuffleTiles -CCShuffleTiles* CCShuffleTiles::actionWithSeed(int s, const ccGridSize& gridSize, float duration) +// CCShuffleTiles* CCShuffleTiles::actionWithSeed(int s, const ccGridSize& gridSize, float duration) +// { +// CCShuffleTiles *pAction = new CCShuffleTiles(); +// +// if (pAction) +// { +// if (pAction->initWithSeed(s, gridSize, duration)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pAction); +// } +// } +// +// return pAction; +// } + +CCShuffleTiles* CCShuffleTiles::create(int s, const ccGridSize& gridSize, float duration) { CCShuffleTiles *pAction = new CCShuffleTiles(); @@ -397,7 +454,26 @@ void CCShuffleTiles::update(float time) // implementation of CCFadeOutTRTiles -CCFadeOutTRTiles* CCFadeOutTRTiles::actionWithSize(const ccGridSize& gridSize, float time) +// CCFadeOutTRTiles* CCFadeOutTRTiles::actionWithSize(const ccGridSize& gridSize, float time) +// { +// CCFadeOutTRTiles *pAction = new CCFadeOutTRTiles(); +// +// if (pAction) +// { +// if (pAction->initWithSize(gridSize, time)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pAction); +// } +// } +// +// return pAction; +// } + +CCFadeOutTRTiles* CCFadeOutTRTiles::create(const ccGridSize& gridSize, float time) { CCFadeOutTRTiles *pAction = new CCFadeOutTRTiles(); @@ -485,7 +561,26 @@ void CCFadeOutTRTiles::update(float time) } // implementation of CCFadeOutBLTiles -CCFadeOutBLTiles* CCFadeOutBLTiles::actionWithSize(const ccGridSize& gridSize, float time) +// CCFadeOutBLTiles* CCFadeOutBLTiles::actionWithSize(const ccGridSize& gridSize, float time) +// { +// CCFadeOutBLTiles *pAction = new CCFadeOutBLTiles(); +// +// if (pAction) +// { +// if (pAction->initWithSize(gridSize, time)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pAction); +// } +// } +// +// return pAction; +// } + +CCFadeOutBLTiles* CCFadeOutBLTiles::create(const ccGridSize& gridSize, float time) { CCFadeOutBLTiles *pAction = new CCFadeOutBLTiles(); @@ -517,7 +612,26 @@ float CCFadeOutBLTiles::testFunc(const ccGridSize& pos, float time) // implementation of CCFadeOutUpTiles -CCFadeOutUpTiles* CCFadeOutUpTiles::actionWithSize(const ccGridSize& gridSize, float time) +// CCFadeOutUpTiles* CCFadeOutUpTiles::actionWithSize(const ccGridSize& gridSize, float time) +// { +// CCFadeOutUpTiles *pAction = new CCFadeOutUpTiles(); +// +// if (pAction) +// { +// if (pAction->initWithSize(gridSize, time)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pAction); +// } +// } +// +// return pAction; +// } + +CCFadeOutUpTiles* CCFadeOutUpTiles::create(const ccGridSize& gridSize, float time) { CCFadeOutUpTiles *pAction = new CCFadeOutUpTiles(); @@ -561,7 +675,26 @@ void CCFadeOutUpTiles::transformTile(const ccGridSize& pos, float distance) } // implementation of CCFadeOutDownTiles -CCFadeOutDownTiles* CCFadeOutDownTiles::actionWithSize(const ccGridSize& gridSize, float time) +// CCFadeOutDownTiles* CCFadeOutDownTiles::actionWithSize(const ccGridSize& gridSize, float time) +// { +// CCFadeOutDownTiles *pAction = new CCFadeOutDownTiles(); +// +// if (pAction) +// { +// if (pAction->initWithSize(gridSize, time)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pAction); +// } +// } +// +// return pAction; +// } + +CCFadeOutDownTiles* CCFadeOutDownTiles::create(const ccGridSize& gridSize, float time) { CCFadeOutDownTiles *pAction = new CCFadeOutDownTiles(); @@ -592,7 +725,21 @@ float CCFadeOutDownTiles::testFunc(const ccGridSize& pos, float time) } // implementation of TurnOffTiles -CCTurnOffTiles* CCTurnOffTiles::actionWithSize(const ccGridSize& size, float d) +// CCTurnOffTiles* CCTurnOffTiles::actionWithSize(const ccGridSize& size, float d) +// { +// CCTurnOffTiles* pAction = new CCTurnOffTiles(); +// if (pAction->initWithSize(size, d)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pAction); +// } +// return pAction; +// } + +CCTurnOffTiles* CCTurnOffTiles::create(const ccGridSize& size, float d) { CCTurnOffTiles* pAction = new CCTurnOffTiles(); if (pAction->initWithSize(size, d)) @@ -606,7 +753,26 @@ CCTurnOffTiles* CCTurnOffTiles::actionWithSize(const ccGridSize& size, float d) return pAction; } -CCTurnOffTiles* CCTurnOffTiles::actionWithSeed(int s, const ccGridSize& gridSize, float duration) +// CCTurnOffTiles* CCTurnOffTiles::actionWithSeed(int s, const ccGridSize& gridSize, float duration) +// { +// CCTurnOffTiles *pAction = new CCTurnOffTiles(); +// +// if (pAction) +// { +// if (pAction->initWithSeed(s, gridSize, duration)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pAction); +// } +// } +// +// return pAction; +// } + +CCTurnOffTiles* CCTurnOffTiles::create(int s, const ccGridSize& gridSize, float duration) { CCTurnOffTiles *pAction = new CCTurnOffTiles(); @@ -736,7 +902,26 @@ void CCTurnOffTiles::update(float time) // implementation of CCWavesTiles3D -CCWavesTiles3D* CCWavesTiles3D::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) +// CCWavesTiles3D* CCWavesTiles3D::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) +// { +// CCWavesTiles3D *pAction = new CCWavesTiles3D(); +// +// if (pAction) +// { +// if (pAction->initWithWaves(wav, amp, gridSize, duration)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pAction); +// } +// } +// +// return pAction; +// } + +CCWavesTiles3D* CCWavesTiles3D::create(int wav, float amp, const ccGridSize& gridSize, float duration) { CCWavesTiles3D *pAction = new CCWavesTiles3D(); @@ -814,7 +999,26 @@ void CCWavesTiles3D::update(float time) // implementation of CCJumpTiles3D -CCJumpTiles3D* CCJumpTiles3D::actionWithJumps(int j, float amp, const ccGridSize& gridSize, float duration) +// CCJumpTiles3D* CCJumpTiles3D::actionWithJumps(int j, float amp, const ccGridSize& gridSize, float duration) +// { +// CCJumpTiles3D *pAction = new CCJumpTiles3D(); +// +// if (pAction) +// { +// if (pAction->initWithJumps(j, amp, gridSize, duration)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pAction); +// } +// } +// +// return pAction; +// } + +CCJumpTiles3D* CCJumpTiles3D::create(int j, float amp, const ccGridSize& gridSize, float duration) { CCJumpTiles3D *pAction = new CCJumpTiles3D(); @@ -903,7 +1107,26 @@ void CCJumpTiles3D::update(float time) // implementation of CCSplitRows -CCSplitRows* CCSplitRows::actionWithRows(int nRows, float duration) +// CCSplitRows* CCSplitRows::actionWithRows(int nRows, float duration) +// { +// CCSplitRows *pAction = new CCSplitRows(); +// +// if (pAction) +// { +// if (pAction->initWithRows(nRows, duration)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pAction); +// } +// } +// +// return pAction; +// } + +CCSplitRows* CCSplitRows::create(int nRows, float duration) { CCSplitRows *pAction = new CCSplitRows(); @@ -982,7 +1205,26 @@ void CCSplitRows::update(float time) // implementation of CCSplitCols -CCSplitCols* CCSplitCols::actionWithCols(int nCols, float duration) +// CCSplitCols* CCSplitCols::actionWithCols(int nCols, float duration) +// { +// CCSplitCols *pAction = new CCSplitCols(); +// +// if (pAction) +// { +// if (pAction->initWithCols(nCols, duration)) +// { +// pAction->autorelease(); +// } +// else +// { +// CC_SAFE_RELEASE_NULL(pAction); +// } +// } +// +// return pAction; +// } + +CCSplitCols* CCSplitCols::create(int nCols, float duration) { CCSplitCols *pAction = new CCSplitCols(); diff --git a/cocos2dx/actions/CCActionTiledGrid.h b/cocos2dx/actions/CCActionTiledGrid.h index 93635638c6..02df236cf9 100644 --- a/cocos2dx/actions/CCActionTiledGrid.h +++ b/cocos2dx/actions/CCActionTiledGrid.h @@ -40,8 +40,14 @@ public: virtual void update(float time); public: + /** creates the action with a range, whether or not to shake Z vertices, a grid size, and duration + @warning: This interface will be deprecated in future. + */ + //static CCShakyTiles3D* actionWithRange(int nRange, bool bShakeZ, const ccGridSize& gridSize, + // float duration); + /** creates the action with a range, whether or not to shake Z vertices, a grid size, and duration */ - static CCShakyTiles3D* actionWithRange(int nRange, bool bShakeZ, const ccGridSize& gridSize, + static CCShakyTiles3D* create(int nRange, bool bShakeZ, const ccGridSize& gridSize, float duration); protected: @@ -61,10 +67,15 @@ public: virtual void update(float time); public: - /** creates the action with a range, whether of not to shatter Z vertices, a grid size and duration */ - static CCShatteredTiles3D* actionWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize, - float duration); + /** creates the action with a range, whether of not to shatter Z vertices, a grid size and duration + @warning: This interface will be deprecated in future. + */ + //static CCShatteredTiles3D* actionWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize, + // float duration); + /** creates the action with a range, whether of not to shatter Z vertices, a grid size and duration */ + static CCShatteredTiles3D* create(int nRange, bool bShatterZ, const ccGridSize& gridSize, + float duration); protected: int m_nRandrange; bool m_bOnce; @@ -90,9 +101,12 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); public: + /** creates the action with a random seed, the grid size and the duration + @warning: This interface will be deprecated in future. + */ + //static CCShuffleTiles* actionWithSeed(int s, const ccGridSize& gridSize, float duration); /** creates the action with a random seed, the grid size and the duration */ - static CCShuffleTiles* actionWithSeed(int s, const ccGridSize& gridSize, float duration); - + static CCShuffleTiles* create(int s, const ccGridSize& gridSize, float duration); protected: int m_nSeed; unsigned int m_nTilesCount; @@ -113,8 +127,13 @@ public: virtual void update(float time); public: + /** creates the action with the grid size and the duration + @warning: This interface will be deprecated in future. + */ + //static CCFadeOutTRTiles* actionWithSize(const ccGridSize& gridSize, float time); + /** creates the action with the grid size and the duration */ - static CCFadeOutTRTiles* actionWithSize(const ccGridSize& gridSize, float time); + static CCFadeOutTRTiles* create(const ccGridSize& gridSize, float time); }; /** @brief CCFadeOutBLTiles action. @@ -126,8 +145,13 @@ public: virtual float testFunc(const ccGridSize& pos, float time); public: + /** creates the action with the grid size and the duration + @warning: This interface will be deprecated in future. + */ + //static CCFadeOutBLTiles* actionWithSize(const ccGridSize& gridSize, float time); + /** creates the action with the grid size and the duration */ - static CCFadeOutBLTiles* actionWithSize(const ccGridSize& gridSize, float time); + static CCFadeOutBLTiles* create(const ccGridSize& gridSize, float time); }; /** @brief CCFadeOutUpTiles action. @@ -140,8 +164,13 @@ public: virtual void transformTile(const ccGridSize& pos, float distance); public: + /** creates the action with the grid size and the duration + @warning: This interface will be deprecated in future. + */ + //static CCFadeOutUpTiles* actionWithSize(const ccGridSize& gridSize, float time); /** creates the action with the grid size and the duration */ - static CCFadeOutUpTiles* actionWithSize(const ccGridSize& gridSize, float time); + static CCFadeOutUpTiles* create(const ccGridSize& gridSize, float time); + }; /** @brief CCFadeOutDownTiles action. @@ -153,8 +182,13 @@ public: virtual float testFunc(const ccGridSize& pos, float time); public: + /** creates the action with the grid size and the duration + @warning: This interface will be deprecated in future. + */ + //static CCFadeOutDownTiles* actionWithSize(const ccGridSize& gridSize, float time); + /** creates the action with the grid size and the duration */ - static CCFadeOutDownTiles* actionWithSize(const ccGridSize& gridSize, float time); + static CCFadeOutDownTiles* create(const ccGridSize& gridSize, float time); }; /** @brief CCTurnOffTiles action. @@ -175,10 +209,19 @@ public: virtual void update(float time); public: + /** creates the action with the grid size and the duration + @warning: This interface will be deprecated in future. + */ + //static CCTurnOffTiles* actionWithSize(const ccGridSize& size, float d); + /** creates the action with a random seed, the grid size and the duration + @warning: This interface will be deprecated in future. + */ + //static CCTurnOffTiles* actionWithSeed(int s, const ccGridSize& gridSize, float duration); + /** creates the action with the grid size and the duration */ - static CCTurnOffTiles* actionWithSize(const ccGridSize& size, float d); + static CCTurnOffTiles* create(const ccGridSize& size, float d); /** creates the action with a random seed, the grid size and the duration */ - static CCTurnOffTiles* actionWithSeed(int s, const ccGridSize& gridSize, float duration); + static CCTurnOffTiles* create(int s, const ccGridSize& gridSize, float duration); protected: int m_nSeed; @@ -205,9 +248,12 @@ public: virtual void update(float time); public: + /** creates the action with a number of waves, the waves amplitude, the grid size and the duration + @warning: This interface will be deprecated in future. + */ + //static CCWavesTiles3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); /** creates the action with a number of waves, the waves amplitude, the grid size and the duration */ - static CCWavesTiles3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); - + static CCWavesTiles3D* create(int wav, float amp, const ccGridSize& gridSize, float duration); protected: int m_nWaves; float m_fAmplitude; @@ -234,9 +280,12 @@ public: virtual void update(float time); public: + /** creates the action with the number of jumps, the sin amplitude, the grid size and the duration + @warning: This interface will be deprecated in future. + */ + //static CCJumpTiles3D* actionWithJumps(int j, float amp, const ccGridSize& gridSize, float duration); /** creates the action with the number of jumps, the sin amplitude, the grid size and the duration */ - static CCJumpTiles3D* actionWithJumps(int j, float amp, const ccGridSize& gridSize, float duration); - + static CCJumpTiles3D* create(int j, float amp, const ccGridSize& gridSize, float duration); protected: int m_nJumps; float m_fAmplitude; @@ -255,9 +304,12 @@ public : virtual void startWithTarget(CCNode *pTarget); public: + /** creates the action with the number of rows to split and the duration + @warning: This interface will be deprecated in future. + */ + //static CCSplitRows* actionWithRows(int nRows, float duration); /** creates the action with the number of rows to split and the duration */ - static CCSplitRows* actionWithRows(int nRows, float duration); - + static CCSplitRows* create(int nRows, float duration); protected: int m_nRows; CCSize m_winSize; @@ -275,9 +327,12 @@ public: virtual void startWithTarget(CCNode *pTarget); public: + /** creates the action with the number of columns to split and the duration + @warning: This interface will be deprecated in future. + */ + //static CCSplitCols* actionWithCols(int nCols, float duration); /** creates the action with the number of columns to split and the duration */ - static CCSplitCols* actionWithCols(int nCols, float duration); - + static CCSplitCols* create(int nCols, float duration); protected: int m_nCols; CCSize m_winSize; diff --git a/cocos2dx/actions/CCActionTween.cpp b/cocos2dx/actions/CCActionTween.cpp index b5d57102fa..214b6e63d4 100644 --- a/cocos2dx/actions/CCActionTween.cpp +++ b/cocos2dx/actions/CCActionTween.cpp @@ -27,7 +27,21 @@ THE SOFTWARE. NS_CC_BEGIN -CCActionTween* CCActionTween::actionWithDuration(float aDuration, const char* key, float from, float to) +// CCActionTween* CCActionTween::actionWithDuration(float aDuration, const char* key, float from, float to) +// { +// CCActionTween* pRet = new CCActionTween(); +// if (pRet && pRet->initWithDuration(aDuration, key, from, to)) +// { +// pRet->autorelease(); +// } +// else +// { +// CC_SAFE_DELETE(pRet); +// } +// return pRet; +// } + +CCActionTween* CCActionTween::create(float aDuration, const char* key, float from, float to) { CCActionTween* pRet = new CCActionTween(); if (pRet && pRet->initWithDuration(aDuration, key, from, to)) @@ -68,7 +82,7 @@ void CCActionTween::update(float dt) CCActionInterval* CCActionTween::reverse() { - return CCActionTween::actionWithDuration(m_fDuration, m_strKey.c_str(), m_fTo, m_fFrom); + return CCActionTween::create(m_fDuration, m_strKey.c_str(), m_fTo, m_fFrom); } diff --git a/cocos2dx/actions/CCActionTween.h b/cocos2dx/actions/CCActionTween.h index 77c85dcf63..23bb968882 100644 --- a/cocos2dx/actions/CCActionTween.h +++ b/cocos2dx/actions/CCActionTween.h @@ -57,9 +57,12 @@ public: class CCActionTween : public CCActionInterval { public: + /** creates an initializes the action with the property name (key), and the from and to parameters. + @warning: This interface will be deprecated in future. + */ + //static CCActionTween* actionWithDuration(float aDuration, const char* key, float from, float to); /** creates an initializes the action with the property name (key), and the from and to parameters. */ - static CCActionTween* actionWithDuration(float aDuration, const char* key, float from, float to); - + static CCActionTween* create(float aDuration, const char* key, float from, float to); /** initializes the action with the property name (key), and the from and to parameters. */ bool initWithDuration(float aDuration, const char* key, float from, float to); diff --git a/cocos2dx/base_nodes/CCAtlasNode.cpp b/cocos2dx/base_nodes/CCAtlasNode.cpp index f73b965429..228f6715f4 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.cpp +++ b/cocos2dx/base_nodes/CCAtlasNode.cpp @@ -60,17 +60,23 @@ CCAtlasNode::~CCAtlasNode() CC_SAFE_RELEASE(m_pTextureAtlas); } -CCAtlasNode * CCAtlasNode::atlasWithTileFile(const char *tile, unsigned int tileWidth, unsigned int tileHeight, - unsigned int itemsToRender) +// CCAtlasNode * CCAtlasNode::atlasWithTileFile(const char *tile, unsigned int tileWidth, unsigned int tileHeight, +// unsigned int itemsToRender) +// { +// return CCAtlasNode::create(tile, tileWidth, tileHeight, itemsToRender); +// } + +CCAtlasNode * CCAtlasNode::create(const char *tile, unsigned int tileWidth, unsigned int tileHeight, + unsigned int itemsToRender) { - CCAtlasNode * pRet = new CCAtlasNode(); - if (pRet->initWithTileFile(tile, tileWidth, tileHeight, itemsToRender)) - { - pRet->autorelease(); - return pRet; - } - CC_SAFE_DELETE(pRet); - return NULL; + CCAtlasNode * pRet = new CCAtlasNode(); + if (pRet->initWithTileFile(tile, tileWidth, tileHeight, itemsToRender)) + { + pRet->autorelease(); + return pRet; + } + CC_SAFE_DELETE(pRet); + return NULL; } bool CCAtlasNode::initWithTileFile(const char *tile, unsigned int tileWidth, unsigned int tileHeight, diff --git a/cocos2dx/base_nodes/CCAtlasNode.h b/cocos2dx/base_nodes/CCAtlasNode.h index 06b6ce2fee..a83e3e35fa 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.h +++ b/cocos2dx/base_nodes/CCAtlasNode.h @@ -76,9 +76,15 @@ public: CCAtlasNode(); virtual ~CCAtlasNode(); - /** creates a CCAtlasNode with an Atlas file the width and height of each item and the quantity of items to render*/ - static CCAtlasNode * atlasWithTileFile(const char* tile,unsigned int tileWidth, unsigned int tileHeight, - unsigned int itemsToRender); + /** creates a CCAtlasNode with an Atlas file the width and height of each item and the quantity of items to render + @warning: This interface will be deprecated in future. + */ +// static CCAtlasNode * atlasWithTileFile(const char* tile,unsigned int tileWidth, unsigned int tileHeight, +// unsigned int itemsToRender); + + /** creates a CCAtlasNode with an Atlas file the width and height of each item and the quantity of items to render*/ + static CCAtlasNode * create(const char* tile,unsigned int tileWidth, unsigned int tileHeight, + unsigned int itemsToRender); /** initializes an CCAtlasNode with an Atlas file the width and height of each item and the quantity of items to render*/ bool initWithTileFile(const char* tile, unsigned int tileWidth, unsigned int tileHeight, unsigned int itemsToRender); diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 4722c90f4f..8b709a830a 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Valentin Milea Copyright (c) 2011 Zynga Inc. @@ -437,13 +437,17 @@ CCRect CCNode::boundingBox() return CCRectApplyAffineTransform(rect, nodeToParentTransform()); } -CCNode * CCNode::node(void) -{ - CCNode * pRet = new CCNode(); - pRet->autorelease(); - return pRet; -} +// CCNode * CCNode::node(void) +// { +// return CCNode::create(); +// } +CCNode * CCNode::create(void) +{ + CCNode * pRet = new CCNode(); + pRet->autorelease(); + return pRet; +} void CCNode::cleanup() { diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index b4bd9bc09f..0e10440db8 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2010-2011 cocos2d-x.org + Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2009 Valentin Milea Copyright (c) 2011 Zynga Inc. @@ -298,8 +298,14 @@ public: /** allocates and initializes a node. The node will be created as "autorelease". + @warning: This interface will be deprecated in future. */ - static CCNode * node(void); + //static CCNode * node(void); + + /** allocates and initializes a node. + The node will be created as "autorelease". + */ + static CCNode * create(void); //scene managment diff --git a/cocos2dx/cocoa/CCArray.cpp b/cocos2dx/cocoa/CCArray.cpp index 63ffff4f86..c390878178 100644 --- a/cocos2dx/cocoa/CCArray.cpp +++ b/cocos2dx/cocoa/CCArray.cpp @@ -377,9 +377,12 @@ CCObject* CCArray::copyWithZone(CCZone* pZone) pArray->initWithCapacity(this->data->num > 0 ? this->data->num : 1); CCObject* pObj = NULL; + CCObject* pTmpObj = NULL; CCARRAY_FOREACH(this, pObj) { - pArray->addObject(pObj->copy()->autorelease()); + pTmpObj = pObj->copy(); + pArray->addObject(pTmpObj); + pTmpObj->release(); } return pArray; } diff --git a/cocos2dx/cocoa/CCDictionary.cpp b/cocos2dx/cocoa/CCDictionary.cpp index 53545d907b..e83591c114 100644 --- a/cocos2dx/cocoa/CCDictionary.cpp +++ b/cocos2dx/cocoa/CCDictionary.cpp @@ -267,18 +267,24 @@ CCObject* CCDictionary::copyWithZone(CCZone* pZone) CCDictionary* pNewDict = new CCDictionary(); CCDictElement* pElement = NULL; + CCObject* pTmpObj = NULL; + if (m_eDictType == kCCDictInt) { CCDICT_FOREACH(this, pElement) { - pNewDict->setObject(pElement->getObject()->copy()->autorelease(), pElement->getIntKey()); + pTmpObj = pElement->getObject()->copy(); + pNewDict->setObject(pTmpObj, pElement->getIntKey()); + pTmpObj->release(); } } else if (m_eDictType == kCCDictStr) { CCDICT_FOREACH(this, pElement) { - pNewDict->setObject(pElement->getObject()->copy()->autorelease(), pElement->getStrKey()); + pTmpObj = pElement->getObject()->copy(); + pNewDict->setObject(pTmpObj, pElement->getStrKey()); + pTmpObj->release(); } } diff --git a/cocos2dx/cocoa/CCGeometry.cpp b/cocos2dx/cocoa/CCGeometry.cpp index 3ecc032ebb..62a12e58eb 100644 --- a/cocos2dx/cocoa/CCGeometry.cpp +++ b/cocos2dx/cocoa/CCGeometry.cpp @@ -55,6 +55,13 @@ void CCPoint::setPoint(float x, float y) this->y = y; } +CCObject* CCPoint::copyWithZone(CCZone* pZone) +{ + CCPoint* pRet = new CCPoint(); + pRet->setPoint(this->x, this->y); + return pRet; +} + bool CCPoint::CCPointEqualToPoint(const CCPoint& point1, const CCPoint& point2) { return ((point1.x == point2.x) && (point1.y == point2.y)); @@ -89,6 +96,13 @@ void CCSize::setSize(float width, float height) this->height = height; } +CCObject* CCSize::copyWithZone(CCZone* pZone) +{ + CCSize* pRet = new CCSize(); + pRet->setSize(this->width, this->width); + return pRet; +} + bool CCSize::CCSizeEqualToSize(const CCSize& size1, const CCSize& size2) { return ((size1.width == size2.width) && (size1.height == size2.height)); @@ -129,6 +143,13 @@ void CCRect::setRect(float x, float y, float width, float height) size.height = height; } +CCObject* CCRect::copyWithZone(CCZone* pZone) +{ + CCRect* pRet = new CCRect(); + pRet->setRect(this->origin.x, this->origin.y, this->size.width, this->size.height); + return pRet; +} + bool CCRect::CCRectEqualToRect(const CCRect& rect1, const CCRect& rect2) { return (CCPoint::CCPointEqualToPoint(rect1.origin, rect2.origin) diff --git a/cocos2dx/cocoa/CCGeometry.h b/cocos2dx/cocoa/CCGeometry.h index e6eb7c9740..5781813b14 100644 --- a/cocos2dx/cocoa/CCGeometry.h +++ b/cocos2dx/cocoa/CCGeometry.h @@ -44,6 +44,8 @@ public: CCPoint(const CCPoint& other); CCPoint& operator= (const CCPoint& other); void setPoint(float x, float y); + virtual CCObject* copyWithZone(CCZone* pZone); + public: static bool CCPointEqualToPoint(const CCPoint& point1, const CCPoint& point2); }; @@ -60,6 +62,7 @@ public: CCSize(const CCSize& other); CCSize& operator= (const CCSize& other); void setSize(float width, float height); + virtual CCObject* copyWithZone(CCZone* pZone); public: static bool CCSizeEqualToSize(const CCSize& size1, const CCSize& size2); }; @@ -76,6 +79,7 @@ public: CCRect(const CCRect& other); CCRect& operator= (const CCRect& other); void setRect(float x, float y, float width, float height); + virtual CCObject* copyWithZone(CCZone* pZone); public: //! return the leftmost x-value of 'rect' static CCFloat CCRectGetMinX(const CCRect& rect); diff --git a/cocos2dx/effects/CCGrid.cpp b/cocos2dx/effects/CCGrid.cpp index a2f7d6742f..1ddef54370 100644 --- a/cocos2dx/effects/CCGrid.cpp +++ b/cocos2dx/effects/CCGrid.cpp @@ -39,7 +39,12 @@ THE SOFTWARE. NS_CC_BEGIN // implementation of CCGridBase -CCGridBase* CCGridBase::gridWithSize(const ccGridSize& gridSize) +// CCGridBase* CCGridBase::gridWithSize(const ccGridSize& gridSize) +// { +// return CCGridBase::create(gridSize); +// } + +CCGridBase* CCGridBase::create(const ccGridSize& gridSize) { CCGridBase *pGridBase = new CCGridBase(); @@ -58,7 +63,12 @@ CCGridBase* CCGridBase::gridWithSize(const ccGridSize& gridSize) return pGridBase; } -CCGridBase* CCGridBase::gridWithSize(const ccGridSize& gridSize, CCTexture2D *texture, bool flipped) +// CCGridBase* CCGridBase::gridWithSize(const ccGridSize& gridSize, CCTexture2D *texture, bool flipped) +// { +// return CCGridBase::create(gridSize, texture, flipped); +// } + +CCGridBase* CCGridBase::create(const ccGridSize& gridSize, CCTexture2D *texture, bool flipped) { CCGridBase *pGridBase = new CCGridBase(); diff --git a/cocos2dx/effects/CCGrid.h b/cocos2dx/effects/CCGrid.h index ffea8d94ef..5b43655d7f 100644 --- a/cocos2dx/effects/CCGrid.h +++ b/cocos2dx/effects/CCGrid.h @@ -76,8 +76,20 @@ public: virtual void calculateVertexPoints(void); public: - static CCGridBase* gridWithSize(const ccGridSize& gridSize, CCTexture2D *texture, bool flipped); - static CCGridBase* gridWithSize(const ccGridSize& gridSize); + /** create one Grid + @warning: This interface will be deprecated in future. + */ + //static CCGridBase* gridWithSize(const ccGridSize& gridSize, CCTexture2D *texture, bool flipped); + /** create one Grid + @warning: This interface will be deprecated in future. + */ + //static CCGridBase* gridWithSize(const ccGridSize& gridSize); + + /** create one Grid */ + static CCGridBase* create(const ccGridSize& gridSize, CCTexture2D *texture, bool flipped); + /** create one Grid */ + static CCGridBase* create(const ccGridSize& gridSize); + void set2DProjection(void); protected: diff --git a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp index eed24d56e2..4ee9d33d4f 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp @@ -467,16 +467,16 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr { CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(spriteSheetFile->m_sString.c_str()); - spriteNormal = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileNormal"))->getCString()); - spriteSelected = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileSelected"))->getCString()); - spriteDisabled = CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileDisabled"))->getCString()); + spriteNormal = CCSprite::createWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileNormal"))->getCString()); + spriteSelected = CCSprite::createWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileSelected"))->getCString()); + spriteDisabled = CCSprite::createWithSpriteFrameName(((CCString*)props->objectForKey("spriteFileDisabled"))->getCString()); // TBD: how to defense if exception raise here? } else { - spriteNormal = CCSprite::spriteWithFile(spriteFileNormal->m_sString.c_str()); - spriteSelected = CCSprite::spriteWithFile(spriteFileSelected->m_sString.c_str()); - spriteDisabled = CCSprite::spriteWithFile(spriteFileDisabled->m_sString.c_str()); + spriteNormal = CCSprite::create(spriteFileNormal->m_sString.c_str()); + spriteSelected = CCSprite::create(spriteFileSelected->m_sString.c_str()); + spriteDisabled = CCSprite::create(spriteFileDisabled->m_sString.c_str()); } //deallocate @@ -484,9 +484,9 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr CC_SAFE_RELEASE_NULL(spriteFileSelected); CC_SAFE_RELEASE_NULL(spriteFileDisabled); - if (!spriteNormal) spriteNormal = CCSprite::spriteWithFile("missing-texture.png"); - if (!spriteSelected) spriteSelected = CCSprite::spriteWithFile("missing-texture.png"); - if (!spriteDisabled) spriteDisabled = CCSprite::spriteWithFile("missing-texture.png"); + if (!spriteNormal) spriteNormal = CCSprite::create("missing-texture.png"); + if (!spriteSelected) spriteSelected = CCSprite::create("missing-texture.png"); + if (!spriteDisabled) spriteDisabled = CCSprite::create("missing-texture.png"); CCNode *target = NULL ; if ( extraProps == NULL ) @@ -512,7 +512,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr target = NULL ; } - node = (CCNode*)CCMenuItemImage::itemWithNormalSprite((CCNode*) spriteNormal, (CCNode*) spriteSelected, (CCNode*) spriteDisabled, target, sel); + node = (CCNode*)CCMenuItemSprite::create((CCNode*) spriteNormal, (CCNode*) spriteSelected, (CCNode*) spriteDisabled, target, sel); setPropsForNode(node, (CCDictionary*) props, extraProps); setPropsForMenuItem((CCMenuItem*) node, (CCDictionary*) props, extraProps); @@ -520,7 +520,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr } else if (className->m_sString.compare("CCMenu") == 0) { - node = (CCNode*)CCMenu::menuWithItems(NULL); + node = (CCNode*)CCMenu::create(); setPropsForNode(node, (CCDictionary*) props, extraProps); setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps); setPropsForMenu((CCMenu*)node, (CCDictionary*) props, extraProps); @@ -531,12 +531,12 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr fontFile->m_sString += ((CCString*)props->objectForKey("fontFile"))->m_sString; CCString* stringText = ((CCString*)props->objectForKey("string")); - node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), + node = (CCNode*)CCLabelBMFont::create(stringText->m_sString.c_str(), fontFile->m_sString.c_str() ); CC_SAFE_RELEASE_NULL(fontFile); - if (!node) node = (CCNode*)CCLabelBMFont::labelWithString(stringText->m_sString.c_str(), "missing-font.fnt"); + if (!node) node = (CCNode*)CCLabelBMFont::create(stringText->m_sString.c_str(), "missing-font.fnt"); setPropsForNode(node, (CCDictionary*) props, extraProps); setPropsForLabelBMFont((CCLabelBMFont*) node, (CCDictionary*) props, extraProps); @@ -555,18 +555,18 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr if (spriteSheetFile && !spriteSheetFile->length()) { CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile(spriteSheetFile->m_sString.c_str()); - node = (CCNode*)CCSprite::spriteWithSpriteFrameName(((CCString*)props->objectForKey("spriteFile"))->m_sString.c_str()); + node = (CCNode*)CCSprite::createWithSpriteFrameName(((CCString*)props->objectForKey("spriteFile"))->m_sString.c_str()); // TBD: how to defense if exception raise here? } else { CCLOG("spriteFile->m_string.cstr is %s\n", spriteFile->m_sString.c_str()) ; - node = (CCNode*)CCSprite::spriteWithFile(spriteFile->m_sString.c_str()); + node = (CCNode*)CCSprite::create(spriteFile->m_sString.c_str()); } CC_SAFE_RELEASE_NULL(spriteFile); - if (!node) node = (CCNode*)CCSprite::spriteWithFile("missing-texture.png"); + if (!node) node = (CCNode*)CCSprite::create("missing-texture.png"); setPropsForNode(node, (CCDictionary*) props, extraProps); setPropsForSprite((CCSprite*) node, (CCDictionary*) props, extraProps); @@ -585,7 +585,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr } else { - node = (CCNode*)CCLayerGradient::node(); + node = (CCNode*)CCLayerGradient::create(); } setPropsForNode(node, (CCDictionary*) props, extraProps); @@ -608,7 +608,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr } else { - node = (CCNode*)CCLayerColor::node(); + node = (CCNode*)CCLayerColor::create(); } setPropsForNode(node, (CCDictionary*) props, extraProps); setPropsForLayer((CCLayer*) node, (CCDictionary*) props, extraProps); @@ -628,7 +628,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr } else { - node = (CCNode*)CCLayer::node(); + node = (CCNode*)CCLayer::create(); } setPropsForNode(node, (CCDictionary*) props, extraProps); @@ -649,7 +649,7 @@ CCNode* CCBReader::ccObjectFromDictionary(CCDictionary* dict, CCDictionary* extr } else { - node = (CCNode*)CCNode::node(); + node = (CCNode*)CCNode::create(); } setPropsForNode(node, (CCDictionary*) props, extraProps); diff --git a/cocos2dx/extensions/CCControlExtension/CCControl.h b/cocos2dx/extensions/CCControlExtension/CCControl.h index a73f15d959..b5cd5ee9c6 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControl.h +++ b/cocos2dx/extensions/CCControlExtension/CCControl.h @@ -202,7 +202,7 @@ public: void addTargetWithActionForControlEvent(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvent); void removeTargetWithActionForControlEvent(CCObject* target, SEL_MenuHandler action, CCControlEvent controlEvent); - LAYER_NODE_FUNC(CCControl); + LAYER_CREATE_FUNC(CCControl); }; diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp index 9a3a95d845..e1bc56441e 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp @@ -122,7 +122,12 @@ bool CCControlButton::initWithLabelAndBackgroundSprite(CCNode* node, CCScale9Spr return false; } -CCControlButton* CCControlButton::buttonWithLabelAndBackgroundSprite(CCNode* label, CCScale9Sprite* backgroundSprite) +// CCControlButton* CCControlButton::buttonWithLabelAndBackgroundSprite(CCNode* label, CCScale9Sprite* backgroundSprite) +// { +// return CCControlButton::create(label, backgroundSprite); +// } + +CCControlButton* CCControlButton::create(CCNode* label, CCScale9Sprite* backgroundSprite) { CCControlButton *pRet = new CCControlButton(); pRet->initWithLabelAndBackgroundSprite(label, backgroundSprite); @@ -132,11 +137,16 @@ CCControlButton* CCControlButton::buttonWithLabelAndBackgroundSprite(CCNode* lab bool CCControlButton::initWithTitleAndFontNameAndFontSize(string title, const char * fontName, float fontSize) { - CCLabelTTF *label = CCLabelTTF::labelWithString(title.c_str(), fontName, fontSize); - return initWithLabelAndBackgroundSprite(label, CCScale9Sprite::node()); + CCLabelTTF *label = CCLabelTTF::create(title.c_str(), fontName, fontSize); + return initWithLabelAndBackgroundSprite(label, CCScale9Sprite::create()); } -CCControlButton* CCControlButton::buttonWithTitleAndFontNameAndFontSize(string title, const char * fontName, float fontSize) +// CCControlButton* CCControlButton::buttonWithTitleAndFontNameAndFontSize(string title, const char * fontName, float fontSize) +// { +// return CCControlButton::create(title, fontName, fontSize); +// } + +CCControlButton* CCControlButton::create(string title, const char * fontName, float fontSize) { CCControlButton *pRet = new CCControlButton(); pRet->initWithTitleAndFontNameAndFontSize(title, fontName, fontSize); @@ -146,11 +156,16 @@ CCControlButton* CCControlButton::buttonWithTitleAndFontNameAndFontSize(string t bool CCControlButton::initWithBackgroundSprite(CCScale9Sprite* sprite) { - CCLabelTTF *label = CCLabelTTF::labelWithString("", "Arial", 30);// + CCLabelTTF *label = CCLabelTTF::create("", "Arial", 30);// return initWithLabelAndBackgroundSprite(label, sprite); } -CCControlButton* CCControlButton::buttonWithBackgroundSprite(CCScale9Sprite* sprite) +// CCControlButton* CCControlButton::buttonWithBackgroundSprite(CCScale9Sprite* sprite) +// { +// return CCControlButton::create(sprite); +// } + +CCControlButton* CCControlButton::create(CCScale9Sprite* sprite) { CCControlButton *pRet = new CCControlButton(); pRet->initWithBackgroundSprite(sprite); @@ -191,7 +206,7 @@ void CCControlButton::setIsHighlighted(bool enabled) if( m_zoomOnTouchDown ) { float scaleValue = (getIsHighlighted() && getIsEnabled() && !getIsSelected()) ? 1.1f : 1.0f; - CCAction *zoomAction =CCScaleTo::actionWithDuration(0.05f, scaleValue); + CCAction *zoomAction =CCScaleTo::create(0.05f, scaleValue); zoomAction->setTag(kZoomActionTag); runAction(zoomAction); } diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.h b/cocos2dx/extensions/CCControlExtension/CCControlButton.h index 8f993d6fe6..a4fe68b086 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.h @@ -94,13 +94,22 @@ protected: public: virtual bool initWithLabelAndBackgroundSprite(CCNode* label, CCScale9Sprite* backgroundSprite); - static CCControlButton* buttonWithLabelAndBackgroundSprite(CCNode* label, CCScale9Sprite* backgroundSprite); + //@warning: This interface will be deprecated in future. + //static CCControlButton* buttonWithLabelAndBackgroundSprite(CCNode* label, CCScale9Sprite* backgroundSprite); + static CCControlButton* create(CCNode* label, CCScale9Sprite* backgroundSprite); virtual bool initWithTitleAndFontNameAndFontSize(std::string title, const char * fontName, float fontSize); - static CCControlButton* buttonWithTitleAndFontNameAndFontSize(std::string title, const char * fontName, float fontSize); + //@warning: This interface will be deprecated in future. + //static CCControlButton* buttonWithTitleAndFontNameAndFontSize(std::string title, const char * fontName, float fontSize); + + static CCControlButton* create(std::string title, const char * fontName, float fontSize); virtual bool initWithBackgroundSprite(CCScale9Sprite* sprite); - static CCControlButton* buttonWithBackgroundSprite(CCScale9Sprite* sprite); + + //@warning: This interface will be deprecated in future. + //static CCControlButton* buttonWithBackgroundSprite(CCScale9Sprite* sprite); + + static CCControlButton* create(CCScale9Sprite* sprite); //events virtual bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp b/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp index cb10c38759..c155e2a13e 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp @@ -44,7 +44,7 @@ bool CCControlColourPicker::init() CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("extensions/CCControlColourPickerSpriteSheet.plist"); // Create the sprite batch node - CCSpriteBatchNode *spriteSheet = CCSpriteBatchNode::batchNodeWithFile("extensions/CCControlColourPickerSpriteSheet.png"); + CCSpriteBatchNode *spriteSheet = CCSpriteBatchNode::create("extensions/CCControlColourPickerSpriteSheet.png"); addChild(spriteSheet); // MIPMAP @@ -67,8 +67,8 @@ bool CCControlColourPicker::init() float hueShift = 8; float colourShift = 28; - m_huePicker=CCControlHuePicker::pickerWithTargetAndPos(spriteSheet, ccp(backgroundPointZero.x + hueShift, backgroundPointZero.y + hueShift)); - m_colourPicker=CCControlSaturationBrightnessPicker::pickerWithTargetAndPos(spriteSheet, ccp(backgroundPointZero.x + colourShift, backgroundPointZero.y + colourShift)); + m_huePicker=CCControlHuePicker::create(spriteSheet, ccp(backgroundPointZero.x + hueShift, backgroundPointZero.y + hueShift)); + m_colourPicker=CCControlSaturationBrightnessPicker::create(spriteSheet, ccp(backgroundPointZero.x + colourShift, backgroundPointZero.y + colourShift)); // Setup events m_huePicker->addTargetWithActionForControlEvents(this, menu_selector(CCControlColourPicker::hueSliderValueChanged), CCControlEventValueChanged); @@ -87,7 +87,12 @@ bool CCControlColourPicker::init() return false; } -CCControlColourPicker* CCControlColourPicker::colourPicker() +// CCControlColourPicker* CCControlColourPicker::colourPicker() +// { +// return CCControlColourPicker::create(); +// } + +CCControlColourPicker* CCControlColourPicker::create() { CCControlColourPicker *pRet = new CCControlColourPicker(); pRet->init(); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.h b/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.h index fd48cabf82..0a7f7ccaa4 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.h @@ -52,7 +52,11 @@ protected: CC_SYNTHESIZE_READONLY(CCSprite*, m_background, Background); public: - static CCControlColourPicker* colourPicker(); + //@warning: This interface will be deprecated in future. + //static CCControlColourPicker* colourPicker(); + + static CCControlColourPicker* create(); + virtual bool init(); //virtual ~CCControlColourPicker(); void hueSliderValueChanged(CCObject * sender); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.cpp b/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.cpp index b0f1006a82..d0244038d2 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.cpp @@ -37,8 +37,13 @@ CCControlHuePicker::~CCControlHuePicker() { } - -CCControlHuePicker* CCControlHuePicker::pickerWithTargetAndPos(CCNode* target, CCPoint pos) + +// CCControlHuePicker* CCControlHuePicker::pickerWithTargetAndPos(CCNode* target, CCPoint pos) +// { +// return CCControlHuePicker::create(target, pos); +// } + +CCControlHuePicker* CCControlHuePicker::create(CCNode* target, CCPoint pos) { CCControlHuePicker *pRet = new CCControlHuePicker(); pRet->initWithTargetAndPos(target, pos); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.h b/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.h index 607b865c62..01c84e2e1b 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.h @@ -54,8 +54,9 @@ class CC_DLL CCControlHuePicker : public CCControl public: virtual ~CCControlHuePicker(); virtual bool initWithTargetAndPos(CCNode* target, CCPoint pos); - static CCControlHuePicker* pickerWithTargetAndPos(CCNode* target, CCPoint pos); - + //@warning: This interface will be deprecated in future. + //static CCControlHuePicker* pickerWithTargetAndPos(CCNode* target, CCPoint pos); + static CCControlHuePicker* create(CCNode* target, CCPoint pos); protected: void updateSliderPosition(CCPoint location); bool checkSliderPosition(CCPoint location); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp b/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp index 96a1d3ec5a..51813521fd 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp @@ -58,7 +58,12 @@ bool CCControlSaturationBrightnessPicker::initWithTargetAndPos(CCNode* target, C return false; } -CCControlSaturationBrightnessPicker* CCControlSaturationBrightnessPicker::pickerWithTargetAndPos(CCNode* target, CCPoint pos) +// CCControlSaturationBrightnessPicker* CCControlSaturationBrightnessPicker::pickerWithTargetAndPos(CCNode* target, CCPoint pos) +// { +// return CCControlSaturationBrightnessPicker::create(target, pos); +// } + +CCControlSaturationBrightnessPicker* CCControlSaturationBrightnessPicker::create(CCNode* target, CCPoint pos) { CCControlSaturationBrightnessPicker *pRet = new CCControlSaturationBrightnessPicker(); pRet->initWithTargetAndPos(target, pos); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.h b/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.h index ab2ad2c49a..652a428a04 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.h @@ -56,7 +56,10 @@ protected: public: virtual ~CCControlSaturationBrightnessPicker(); virtual bool initWithTargetAndPos(CCNode* target, CCPoint pos); - static CCControlSaturationBrightnessPicker* pickerWithTargetAndPos(CCNode* target, CCPoint pos); + + //@warning: This interface will be deprecated in future. + //static CCControlSaturationBrightnessPicker* pickerWithTargetAndPos(CCNode* target, CCPoint pos); + static CCControlSaturationBrightnessPicker* create(CCNode* target, CCPoint pos); virtual void updateWithHSV(HSV hsv); virtual void updateDraggerWithHSV(HSV hsv); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp b/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp index a3c8672215..b727b50645 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp @@ -38,25 +38,35 @@ CCControlSlider::~CCControlSlider() } -CCControlSlider* CCControlSlider::sliderWithFiles(const char* bgFile, const char* progressFile, const char* thumbFile) +// CCControlSlider* CCControlSlider::sliderWithFiles(const char* bgFile, const char* progressFile, const char* thumbFile) +// { +// return CCControlSlider::create(bgFile, progressFile, thumbFile); +// } + +CCControlSlider* CCControlSlider::create(const char* bgFile, const char* progressFile, const char* thumbFile) { // Prepare background for slider - CCSprite *backgroundSprite = CCSprite::spriteWithFile(bgFile); + CCSprite *backgroundSprite = CCSprite::create(bgFile); // Prepare progress for slider - CCSprite *progressSprite = CCSprite::spriteWithFile(progressFile); + CCSprite *progressSprite = CCSprite::create(progressFile); // Prepare thumb (menuItem) for slider - CCSprite *thumbNormal = CCSprite::spriteWithFile(thumbFile); - CCSprite *thumbSelected = CCSprite::spriteWithFile(thumbFile); + CCSprite *thumbNormal = CCSprite::create(thumbFile); + CCSprite *thumbSelected = CCSprite::create(thumbFile); thumbSelected->setColor(ccGRAY); - CCMenuItemSprite* thumbMenuItem =CCMenuItemSprite::itemWithNormalSprite(thumbNormal, thumbSelected); + CCMenuItemSprite* thumbMenuItem =CCMenuItemSprite::create(thumbNormal, thumbSelected); - return CCControlSlider::sliderWithSprites(backgroundSprite, progressSprite, thumbMenuItem); + return CCControlSlider::create(backgroundSprite, progressSprite, thumbMenuItem); } -CCControlSlider* CCControlSlider::sliderWithSprites(CCSprite * backgroundSprite, CCSprite* pogressSprite, CCMenuItem* thumbItem) +// CCControlSlider* CCControlSlider::sliderWithSprites(CCSprite * backgroundSprite, CCSprite* pogressSprite, CCMenuItem* thumbItem) +// { +// return CCControlSlider::create(backgroundSprite, pogressSprite, thumbItem); +// } + +CCControlSlider* CCControlSlider::create(CCSprite * backgroundSprite, CCSprite* pogressSprite, CCMenuItem* thumbItem) { CCControlSlider *pRet = new CCControlSlider(); pRet->initWithSprites(backgroundSprite, pogressSprite, thumbItem); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSlider.h b/cocos2dx/extensions/CCControlExtension/CCControlSlider.h index 0fd5f94690..eac9535a70 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSlider.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlSlider.h @@ -75,8 +75,24 @@ public: /** * Creates slider with a background filename, a progress filename and a * thumb image filename. + @warning: This interface will be deprecated in future. */ - static CCControlSlider* sliderWithFiles(const char* bgFile, const char* progressFile, const char* thumbFile); + //static CCControlSlider* sliderWithFiles(const char* bgFile, const char* progressFile, const char* thumbFile); + + /** + * Creates a slider with a given background sprite and a progress bar and a + * thumb item. + *@warning: This interface will be deprecated in future. + * @see initWithBackgroundSprite:progressSprite:thumbMenuItem: + */ + //static CCControlSlider* sliderWithSprites(CCSprite * backgroundSprite, CCSprite* pogressSprite, CCMenuItem* thumbItem); + + + /** + * Creates slider with a background filename, a progress filename and a + * thumb image filename. + */ + static CCControlSlider* create(const char* bgFile, const char* progressFile, const char* thumbFile); /** * Creates a slider with a given background sprite and a progress bar and a @@ -84,9 +100,7 @@ public: * * @see initWithBackgroundSprite:progressSprite:thumbMenuItem: */ - static CCControlSlider* sliderWithSprites(CCSprite * backgroundSprite, CCSprite* pogressSprite, CCMenuItem* thumbItem); - - + static CCControlSlider* create(CCSprite * backgroundSprite, CCSprite* pogressSprite, CCMenuItem* thumbItem); protected: diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp index 8bae8159e7..e8af2f1e37 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp @@ -206,7 +206,7 @@ void CCControlSwitchSprite::needsLayout() m_pOffSprite->getContentSize().height / 2)); } - CCRenderTexture *rt = CCRenderTexture::renderTextureWithWidthAndHeight((int)m_pMaskTexture->getContentSize().width, (int)m_pMaskTexture->getContentSize().height); + CCRenderTexture *rt = CCRenderTexture::create((int)m_pMaskTexture->getContentSize().width, (int)m_pMaskTexture->getContentSize().height); rt->begin(); m_pOnSprite->visit(); @@ -273,7 +273,12 @@ bool CCControlSwitch::initWithMaskSprite(CCSprite *maskSprite, CCSprite * onSpri return initWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, NULL, NULL); } -CCControlSwitch* CCControlSwitch::switchWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite) +// CCControlSwitch* CCControlSwitch::switchWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite) +// { +// return CCControlSwitch::create(maskSprite, onSprite, offSprite, thumbSprite); +// } + +CCControlSwitch* CCControlSwitch::create(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite) { CCControlSwitch* pRet = new CCControlSwitch(); if (pRet && pRet->initWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, NULL, NULL)) @@ -317,7 +322,12 @@ bool CCControlSwitch::initWithMaskSprite(CCSprite *maskSprite, CCSprite * onSpri return false; } -CCControlSwitch* CCControlSwitch::switchWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite, CCLabelTTF* onLabel, CCLabelTTF* offLabel) +// CCControlSwitch* CCControlSwitch::switchWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite, CCLabelTTF* onLabel, CCLabelTTF* offLabel) +// { +// return CCControlSwitch::create(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel); +// } + +CCControlSwitch* CCControlSwitch::create(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite, CCLabelTTF* onLabel, CCLabelTTF* offLabel) { CCControlSwitch* pRet = new CCControlSwitch(); if (pRet && pRet->initWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel)) @@ -342,7 +352,7 @@ void CCControlSwitch::setOn(bool isOn, bool animated) m_pSwitchSprite->runAction ( - CCActionTween::actionWithDuration + CCActionTween::create ( 0.2f, "sliderXPosition", diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.h b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.h index 13304a693f..a2bc142496 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.h @@ -46,14 +46,26 @@ public: /** Initializes a switch with a mask sprite, on/off sprites for on/off states and a thumb sprite. */ bool initWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite); + /** Creates a switch with a mask sprite, on/off sprites for on/off states and a thumb sprite. + @warning: This interface will be deprecated in future. + */ + //static CCControlSwitch* switchWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite); + /** Creates a switch with a mask sprite, on/off sprites for on/off states and a thumb sprite. */ - static CCControlSwitch* switchWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite); + static CCControlSwitch* create(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite); + /** Initializes a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. */ bool initWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite, CCLabelTTF* onLabel, CCLabelTTF* offLabel); + /** Creates a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. + @warning: This interface will be deprecated in future. + */ + //static CCControlSwitch* switchWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite, CCLabelTTF* onLabel, CCLabelTTF* offLabel); + /** Creates a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. */ - static CCControlSwitch* switchWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite, CCLabelTTF* onLabel, CCLabelTTF* offLabel); + static CCControlSwitch* create(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite, CCLabelTTF* onLabel, CCLabelTTF* offLabel); + /** * Set the state of the switch to On or Off, optionally animating the transition. diff --git a/cocos2dx/extensions/CCControlExtension/CCControlUtils.cpp b/cocos2dx/extensions/CCControlExtension/CCControlUtils.cpp index 33d0ea7c35..5682a633a8 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlUtils.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlUtils.cpp @@ -5,7 +5,7 @@ NS_CC_EXT_BEGIN CCSprite* CCControlUtils::addSpriteToTargetWithPosAndAnchor(const char* spriteName, CCNode * target, CCPoint pos, CCPoint anchor) { - CCSprite *sprite =CCSprite::spriteWithSpriteFrameName(spriteName); + CCSprite *sprite =CCSprite::createWithSpriteFrameName(spriteName); if (!sprite) return NULL; diff --git a/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp b/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp index b641ac732e..fad26e61c7 100644 --- a/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp @@ -16,13 +16,33 @@ enum // //CCMenu // +// CCMenuPassive* CCMenuPassive::node() +// { +// return CCMenuPassive::create(); +// } - CCMenuPassive* CCMenuPassive::node() - { - return menuWithItem(NULL); - } +CCMenuPassive* CCMenuPassive::create() +{ + return create(NULL, NULL); +} -CCMenuPassive * CCMenuPassive::menuWithItems(CCNode* item, ...) +// CCMenuPassive * CCMenuPassive::menuWithItems(CCNode* item, ...) +// { +// va_list args; +// va_start(args,item); +// CCMenuPassive *pRet = new CCMenuPassive(); +// if (pRet && pRet->initWithItems(item, args)) +// { +// pRet->autorelease(); +// va_end(args); +// return pRet; +// } +// va_end(args); +// CC_SAFE_DELETE(pRet); +// return NULL; +// } + +CCMenuPassive * CCMenuPassive::create(CCNode* item, ...) { va_list args; va_start(args,item); @@ -38,9 +58,14 @@ CCMenuPassive * CCMenuPassive::menuWithItems(CCNode* item, ...) return NULL; } -CCMenuPassive* CCMenuPassive::menuWithItem(CCNode* item) +// CCMenuPassive* CCMenuPassive::menuWithItem(CCNode* item) +// { +// return CCMenuPassive::createWithItem(item); +// } + +CCMenuPassive* CCMenuPassive::createWithItem(CCNode* item) { - return menuWithItems(item, NULL); + return create(item, NULL); } bool CCMenuPassive::initWithItems(CCNode* item, va_list args) diff --git a/cocos2dx/extensions/CCControlExtension/CCMenuPassive.h b/cocos2dx/extensions/CCControlExtension/CCMenuPassive.h index d3f72e7a8d..94cfaf17d7 100644 --- a/cocos2dx/extensions/CCControlExtension/CCMenuPassive.h +++ b/cocos2dx/extensions/CCControlExtension/CCMenuPassive.h @@ -17,17 +17,34 @@ class CC_DLL CCMenuPassive : public CCLayer, public CCRGBAProtocol CC_PROPERTY(GLubyte, m_cOpacity, Opacity); public: + /** creates an empty CCMenu + @warning: This interface will be deprecated in future. + */ + //static CCMenuPassive* node(); + + /** creates a CCMenu with it's items + @warning: This interface will be deprecated in future. + */ + //static CCMenuPassive* menuWithItems(CCNode* item, ...); + + /** creates a CCMenu with it's item, then use addChild() to add + * other items. It is used for script, it can't init with undetermined + * number of variables. + @warning: This interface will be deprecated in future. + */ + //static CCMenuPassive* menuWithItem(CCNode* item); + /** creates an empty CCMenu */ - static CCMenuPassive* node(); + static CCMenuPassive* create(); /** creates a CCMenu with it's items */ - static CCMenuPassive* menuWithItems(CCNode* item, ...); + static CCMenuPassive* create(CCNode* item, ...); /** creates a CCMenu with it's item, then use addChild() to add * other items. It is used for script, it can't init with undetermined * number of variables. */ - static CCMenuPassive*menuWithItem(CCNode* item); + static CCMenuPassive* createWithItem(CCNode* item); /** initializes a CCMenu with it's items */ bool initWithItems(CCNode* item, va_list args); diff --git a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp index 220a198119..73a07b52ee 100644 --- a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp @@ -70,25 +70,25 @@ bool CCScale9Sprite::initWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect // // Centre - centre = CCSprite::spriteWithTexture(scale9Image->getTexture(), m_capInsets); + centre = CCSprite::createWithTexture(scale9Image->getTexture(), m_capInsets); scale9Image->addChild(centre ,0 ,pCentre); // Top - top = CCSprite::spriteWithTexture(scale9Image->getTexture(), CCRectMake(m_capInsets.origin.x, + top = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake(m_capInsets.origin.x, t, m_capInsets.size.width, m_capInsets.origin.y - t)); scale9Image->addChild(top, 1, pTop); // Bottom - bottom = CCSprite::spriteWithTexture(scale9Image->getTexture(), CCRectMake( m_capInsets.origin.x, + bottom = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake( m_capInsets.origin.x, m_capInsets.origin.y + m_capInsets.size.height, m_capInsets.size.width, h - (m_capInsets.origin.y - t + m_capInsets.size.height) )); scale9Image->addChild(bottom, 1, pBottom); // Left - left = CCSprite::spriteWithTexture(scale9Image->getTexture(), CCRectMake( + left = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake( l, m_capInsets.origin.y, m_capInsets.origin.x - l, @@ -96,7 +96,7 @@ bool CCScale9Sprite::initWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect scale9Image->addChild(left, 1, pLeft); // Right - right = CCSprite::spriteWithTexture(scale9Image->getTexture(), CCRectMake( + right = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake( m_capInsets.origin.x + m_capInsets.size.width, m_capInsets.origin.y, w - (m_capInsets.origin.x - l + m_capInsets.size.width), @@ -104,7 +104,7 @@ bool CCScale9Sprite::initWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect scale9Image->addChild(right, 1, pRight); // Top left - topLeft = CCSprite::spriteWithTexture(scale9Image->getTexture(), CCRectMake( + topLeft = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake( l, t, m_capInsets.origin.x - l, @@ -113,7 +113,7 @@ bool CCScale9Sprite::initWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect scale9Image->addChild(topLeft, 2, pTopLeft); // Top right - topRight = CCSprite::spriteWithTexture(scale9Image->getTexture(), CCRectMake( + topRight = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake( m_capInsets.origin.x + m_capInsets.size.width, t, w - (m_capInsets.origin.x - l + m_capInsets.size.width), @@ -122,7 +122,7 @@ bool CCScale9Sprite::initWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect scale9Image->addChild(topRight, 2, pTopRight); // Bottom left - bottomLeft = CCSprite::spriteWithTexture(scale9Image->getTexture(), CCRectMake( + bottomLeft = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake( l, m_capInsets.origin.y + m_capInsets.size.height, m_capInsets.origin.x - l, @@ -130,7 +130,7 @@ bool CCScale9Sprite::initWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect scale9Image->addChild(bottomLeft, 2, pBottomLeft); // Bottom right - bottomRight = CCSprite::spriteWithTexture(scale9Image->getTexture(), CCRectMake( + bottomRight = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake( m_capInsets.origin.x + m_capInsets.size.width, m_capInsets.origin.y + m_capInsets.size.height, w - (m_capInsets.origin.x - l + m_capInsets.size.width), @@ -189,12 +189,17 @@ bool CCScale9Sprite::initWithFile(const char* file, CCRect rect, CCRect capInse { CCAssert(file != NULL, "Invalid file for sprite"); - CCSpriteBatchNode *batchnode = CCSpriteBatchNode::batchNodeWithFile(file, 9); + CCSpriteBatchNode *batchnode = CCSpriteBatchNode::create(file, 9); bool pReturn = this->initWithBatchNode(batchnode, rect, capInsets); return pReturn; } -CCScale9Sprite* CCScale9Sprite::spriteWithFile(const char* file, CCRect rect, CCRect capInsets) +// CCScale9Sprite* CCScale9Sprite::spriteWithFile(const char* file, CCRect rect, CCRect capInsets) +// { +// return CCScale9Sprite::create(file, rect, capInsets); +// } + +CCScale9Sprite* CCScale9Sprite::create(const char* file, CCRect rect, CCRect capInsets) { CCScale9Sprite* pReturn = new CCScale9Sprite(); if ( pReturn && pReturn->initWithFile(file, rect, capInsets) ) @@ -211,7 +216,13 @@ bool CCScale9Sprite::initWithFile(const char* file, CCRect rect) bool pReturn = this->initWithFile(file, rect, CCRectZero); return pReturn; } -CCScale9Sprite* CCScale9Sprite::spriteWithFile(const char* file, CCRect rect) + +// CCScale9Sprite* CCScale9Sprite::spriteWithFile(const char* file, CCRect rect) +// { +// return CCScale9Sprite::create(file, rect); +// } + +CCScale9Sprite* CCScale9Sprite::create(const char* file, CCRect rect) { CCScale9Sprite* pReturn = new CCScale9Sprite(); if ( pReturn && pReturn->initWithFile(file, rect) ) @@ -230,7 +241,12 @@ bool CCScale9Sprite::initWithFile(CCRect capInsets, const char* file) return pReturn; } -CCScale9Sprite* CCScale9Sprite::spriteWithFile(CCRect capInsets, const char* file) +// CCScale9Sprite* CCScale9Sprite::spriteWithFile(CCRect capInsets, const char* file) +// { +// return CCScale9Sprite::create(capInsets, file); +// } + +CCScale9Sprite* CCScale9Sprite::create(CCRect capInsets, const char* file) { CCScale9Sprite* pReturn = new CCScale9Sprite(); if ( pReturn && pReturn->initWithFile(file, capInsets) ) @@ -248,7 +264,13 @@ bool CCScale9Sprite::initWithFile(const char* file) return pReturn; } -CCScale9Sprite* CCScale9Sprite::spriteWithFile(const char* file) + +// CCScale9Sprite* CCScale9Sprite::spriteWithFile(const char* file) +// { +// return CCScale9Sprite::create(file); +// } + +CCScale9Sprite* CCScale9Sprite::create(const char* file) { CCScale9Sprite* pReturn = new CCScale9Sprite(); if ( pReturn && pReturn->initWithFile(file) ) @@ -264,12 +286,17 @@ bool CCScale9Sprite::initWithSpriteFrame(CCSpriteFrame* spriteFrame, CCRect capI { CCAssert(spriteFrame != NULL, "Sprite frame must be not nil"); - CCSpriteBatchNode *batchnode = CCSpriteBatchNode::batchNodeWithTexture(spriteFrame->getTexture(), 9); + CCSpriteBatchNode *batchnode = CCSpriteBatchNode::createWithTexture(spriteFrame->getTexture(), 9); bool pReturn = this->initWithBatchNode(batchnode, spriteFrame->getRect(), capInsets); return pReturn; } -CCScale9Sprite* CCScale9Sprite::spriteWithSpriteFrame(CCSpriteFrame* spriteFrame, CCRect capInsets) +// CCScale9Sprite* CCScale9Sprite::spriteWithSpriteFrame(CCSpriteFrame* spriteFrame, CCRect capInsets) +// { +// return CCScale9Sprite::createWithSpriteFrame(spriteFrame, capInsets); +// } + +CCScale9Sprite* CCScale9Sprite::createWithSpriteFrame(CCSpriteFrame* spriteFrame, CCRect capInsets) { CCScale9Sprite* pReturn = new CCScale9Sprite(); if ( pReturn && pReturn->initWithSpriteFrame(spriteFrame, capInsets) ) @@ -286,7 +313,13 @@ bool CCScale9Sprite::initWithSpriteFrame(CCSpriteFrame* spriteFrame) return pReturn; } -CCScale9Sprite* CCScale9Sprite::spriteWithSpriteFrame(CCSpriteFrame* spriteFrame) + +// CCScale9Sprite* CCScale9Sprite::spriteWithSpriteFrame(CCSpriteFrame* spriteFrame) +// { +// return CCScale9Sprite::createWithSpriteFrame(spriteFrame); +// } + +CCScale9Sprite* CCScale9Sprite::createWithSpriteFrame(CCSpriteFrame* spriteFrame) { CCScale9Sprite* pReturn = new CCScale9Sprite(); if ( pReturn && pReturn->initWithSpriteFrame(spriteFrame) ) @@ -307,7 +340,12 @@ bool CCScale9Sprite::initWithSpriteFrameName(const char* spriteFrameName, CCRect return pReturn; } -CCScale9Sprite* CCScale9Sprite::spriteWithSpriteFrameName(const char* spriteFrameName, CCRect capInsets) +// CCScale9Sprite* CCScale9Sprite::spriteWithSpriteFrameName(const char* spriteFrameName, CCRect capInsets) +// { +// return CCScale9Sprite::createWithSpriteFrameName(spriteFrameName, capInsets); +// } + +CCScale9Sprite* CCScale9Sprite::createWithSpriteFrameName(const char* spriteFrameName, CCRect capInsets) { CCScale9Sprite* pReturn = new CCScale9Sprite(); if ( pReturn && pReturn->initWithSpriteFrameName(spriteFrameName, capInsets) ) @@ -326,7 +364,12 @@ bool CCScale9Sprite::initWithSpriteFrameName(const char* spriteFrameName) return pReturn; } -CCScale9Sprite* CCScale9Sprite::spriteWithSpriteFrameName(const char* spriteFrameName) +// CCScale9Sprite* CCScale9Sprite::spriteWithSpriteFrameName(const char* spriteFrameName) +// { +// return CCScale9Sprite::createWithSpriteFrameName(spriteFrameName); +// } + +CCScale9Sprite* CCScale9Sprite::createWithSpriteFrameName(const char* spriteFrameName) { CCScale9Sprite* pReturn = new CCScale9Sprite(); if ( pReturn && pReturn->initWithSpriteFrameName(spriteFrameName) ) @@ -351,7 +394,12 @@ CCScale9Sprite* CCScale9Sprite::resizableSpriteWithCapInsets(CCRect capInsets) return NULL; } -CCScale9Sprite* CCScale9Sprite::node() +// CCScale9Sprite* CCScale9Sprite::node() +// { +// return CCScale9Sprite::create(); +// } + +CCScale9Sprite* CCScale9Sprite::create() { CCScale9Sprite *pRet = new CCScale9Sprite(); if (pRet) diff --git a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h index 7b912463f1..06f164ec48 100644 --- a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h +++ b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h @@ -101,9 +101,18 @@ public: * with the specified cap insets. * * @see initWithFile:rect:centerRegion: + @warning: This interface will be deprecated in future. */ - static CCScale9Sprite* spriteWithFile(const char* file, CCRect rect, CCRect capInsets); + //static CCScale9Sprite* spriteWithFile(const char* file, CCRect rect, CCRect capInsets); + /** + * Creates a 9-slice sprite with a texture file, a delimitation zone and + * with the specified cap insets. + * + * @see initWithFile:rect:centerRegion: + */ + static CCScale9Sprite* create(const char* file, CCRect rect, CCRect capInsets); + /** * Initializes a 9-slice sprite with a texture file and a delimitation zone. The * texture will be broken down into a 3×3 grid of equal blocks. @@ -123,9 +132,18 @@ public: * texture will be broken down into a 3×3 grid of equal blocks. * * @see initWithFile:rect: + @warning: This interface will be deprecated in future. */ - static CCScale9Sprite* spriteWithFile(const char* file, CCRect rect); + //static CCScale9Sprite* spriteWithFile(const char* file, CCRect rect); + /** + * Creates a 9-slice sprite with a texture file and a delimitation zone. The + * texture will be broken down into a 3×3 grid of equal blocks. + * + * @see initWithFile:rect: + */ + static CCScale9Sprite* create(const char* file, CCRect rect); + /** * Initializes a 9-slice sprite with a texture file and with the specified cap * insets. @@ -143,8 +161,17 @@ public: * broken down into a 3×3 grid of equal blocks. * * @see initWithFile:capInsets: + @warning: This interface will be deprecated in future. */ - static CCScale9Sprite* spriteWithFile(CCRect capInsets, const char* file); + //static CCScale9Sprite* spriteWithFile(CCRect capInsets, const char* file); + /** + * Creates a 9-slice sprite with a texture file. The whole texture will be + * broken down into a 3×3 grid of equal blocks. + * + * @see initWithFile:capInsets: + */ + static CCScale9Sprite* create(CCRect capInsets, const char* file); + /** * Initializes a 9-slice sprite with a texture file. The whole texture will be @@ -162,8 +189,17 @@ public: * broken down into a 3×3 grid of equal blocks. * * @see initWithFile: + @warning: This interface will be deprecated in future. */ - static CCScale9Sprite* spriteWithFile(const char* file); + //static CCScale9Sprite* spriteWithFile(const char* file); + + /** + * Creates a 9-slice sprite with a texture file. The whole texture will be + * broken down into a 3×3 grid of equal blocks. + * + * @see initWithFile: + */ + static CCScale9Sprite* create(const char* file); /** * Initializes a 9-slice sprite with an sprite frame and with the specified @@ -184,8 +220,19 @@ public: * It respects the anchorPoint too. * * @see initWithSpriteFrame:centerRegion: + @warning: This interface will be deprecated in future. */ - static CCScale9Sprite* spriteWithSpriteFrame(CCSpriteFrame* spriteFrame, CCRect capInsets); + //static CCScale9Sprite* spriteWithSpriteFrame(CCSpriteFrame* spriteFrame, CCRect capInsets); + + /** + * Creates a 9-slice sprite with an sprite frame and the centre of its zone. + * Once the sprite is created, you can then call its "setContentSize:" method + * to resize the sprite will all it's 9-slice goodness intract. + * It respects the anchorPoint too. + * + * @see initWithSpriteFrame:centerRegion: + */ + static CCScale9Sprite* createWithSpriteFrame(CCSpriteFrame* spriteFrame, CCRect capInsets); /** * Initializes a 9-slice sprite with an sprite frame. * Once the sprite is created, you can then call its "setContentSize:" method @@ -203,8 +250,20 @@ public: * It respects the anchorPoint too. * * @see initWithSpriteFrame: + @warning: This interface will be deprecated in future. */ - static CCScale9Sprite* spriteWithSpriteFrame(CCSpriteFrame* spriteFrame); + //static CCScale9Sprite* spriteWithSpriteFrame(CCSpriteFrame* spriteFrame); + + /** + * Creates a 9-slice sprite with an sprite frame. + * Once the sprite is created, you can then call its "setContentSize:" method + * to resize the sprite will all it's 9-slice goodness intract. + * It respects the anchorPoint too. + * + * @see initWithSpriteFrame: + */ + static CCScale9Sprite* createWithSpriteFrame(CCSpriteFrame* spriteFrame); + /** * Initializes a 9-slice sprite with an sprite frame name and with the specified * cap insets. @@ -224,8 +283,21 @@ public: * It respects the anchorPoint too. * * @see initWithSpriteFrameName:centerRegion: + @warning: This interface will be deprecated in future. */ - static CCScale9Sprite* spriteWithSpriteFrameName(const char*spriteFrameName, CCRect capInsets); + //static CCScale9Sprite* spriteWithSpriteFrameName(const char*spriteFrameName, CCRect capInsets); + + /** + * Creates a 9-slice sprite with an sprite frame name and the centre of its + * zone. + * Once the sprite is created, you can then call its "setContentSize:" method + * to resize the sprite will all it's 9-slice goodness intract. + * It respects the anchorPoint too. + * + * @see initWithSpriteFrameName:centerRegion: + */ + static CCScale9Sprite* createWithSpriteFrameName(const char*spriteFrameName, CCRect capInsets); + /** * Initializes a 9-slice sprite with an sprite frame name. * Once the sprite is created, you can then call its "setContentSize:" method @@ -243,8 +315,19 @@ public: * It respects the anchorPoint too. * * @see initWithSpriteFrameName: + @warning: This interface will be deprecated in future. */ - static CCScale9Sprite* spriteWithSpriteFrameName(const char*spriteFrameName); + //static CCScale9Sprite* spriteWithSpriteFrameName(const char*spriteFrameName); + + /** + * Creates a 9-slice sprite with an sprite frame name. + * Once the sprite is created, you can then call its "setContentSize:" method + * to resize the sprite will all it's 9-slice goodness intract. + * It respects the anchorPoint too. + * + * @see initWithSpriteFrameName: + */ + static CCScale9Sprite* createWithSpriteFrameName(const char*spriteFrameName); /** * Creates and returns a new sprite object with the specified cap insets. @@ -257,8 +340,10 @@ public: CCScale9Sprite* resizableSpriteWithCapInsets(CCRect capInsets); - static CCScale9Sprite* node(); + //static CCScale9Sprite* node(); + static CCScale9Sprite* create(); + // optional /** sets the premultipliedAlphaOpacity property. diff --git a/cocos2dx/extensions/CCListView/CCListView.cpp b/cocos2dx/extensions/CCListView/CCListView.cpp index dd71dee560..cf896e5b93 100644 --- a/cocos2dx/extensions/CCListView/CCListView.cpp +++ b/cocos2dx/extensions/CCListView/CCListView.cpp @@ -35,7 +35,12 @@ NS_CC_EXT_BEGIN /****************************************** **************Public Functions************* *******************************************/ -CCListView* CCListView::viewWithMode(CCListViewMode mode) +// CCListView* CCListView::viewWithMode(CCListViewMode mode) +// { +// return CCListView::create(mode); +// } + +CCListView* CCListView::create(CCListViewMode mode) { CCListView *pRet = new CCListView(); if (pRet && pRet->initWithMode(mode)) @@ -52,14 +57,15 @@ CCListView* CCListView::viewWithMode(CCListViewMode mode) bool CCListView::initWithMode(CCListViewMode mode) { - bool bRet = false; - m_nMode = mode; - m_layerPanel = CCLayer::node(); - this->addChild(m_layerPanel); - - bRet = CCLayerColor::initWithColor(ccc4(255, 255, 255, 0), 0, 0); - setIsTouchEnabled(true); - return bRet; + if (CCLayerColor::initWithColor(ccc4(255, 255, 255, 0), 0, 0)) + { + setIsTouchEnabled(true); + m_nMode = mode; + m_layerPanel = CCLayer::create(); + this->addChild(m_layerPanel); + return true; + } + return false; } CCListView::CCListView(void) @@ -563,9 +569,9 @@ void CCListView::scrollCellToFront(unsigned int nRow, bool bAnimated) if (bAnimated) { - CCMoveBy *moveBy = CCMoveBy::actionWithDuration(m_fActionDuration, CCPointMake(disX, disY)); - CCEaseOut *ease = CCEaseOut::actionWithAction(moveBy, 3); - CCFiniteTimeAction *actions = CCSequence::actions(ease, CCCallFunc::actionWithTarget(this, callfunc_selector(CCListView::finishScroll)), NULL); + CCMoveBy *moveBy = CCMoveBy::create(m_fActionDuration, CCPointMake(disX, disY)); + CCEaseOut *ease = CCEaseOut::create(moveBy, 3); + CCFiniteTimeAction *actions = CCSequence::create(ease, CCCallFunc::create(this, callfunc_selector(CCListView::finishScroll)), NULL); m_layerPanel->runAction(actions); } else @@ -896,9 +902,9 @@ void CCListView::scrollCellToBack(unsigned int nRow, bool bAnimated) if (bAnimated) { - CCMoveBy *moveBy = CCMoveBy::actionWithDuration(m_fActionDuration, CCPointMake(disX, disY)); - CCEaseOut *ease = CCEaseOut::actionWithAction(moveBy, 3); - CCFiniteTimeAction *actions = CCSequence::actions(ease, CCCallFunc::actionWithTarget(this, callfunc_selector(CCListView::finishScroll)), NULL); + CCMoveBy *moveBy = CCMoveBy::create(m_fActionDuration, CCPointMake(disX, disY)); + CCEaseOut *ease = CCEaseOut::create(moveBy, 3); + CCFiniteTimeAction *actions = CCSequence::create(ease, CCCallFunc::create(this, callfunc_selector(CCListView::finishScroll)), NULL); m_layerPanel->runAction(actions); } else @@ -1476,9 +1482,9 @@ void CCListView::fixFirstRow(void) } m_nState = CCListViewStateFix; - CCMoveBy *moveBy = CCMoveBy::actionWithDuration(m_fActionDuration, CCPointMake(disX, disY)); - CCEaseInOut *ease = CCEaseInOut::actionWithAction(moveBy, 2); - CCFiniteTimeAction *actions = CCSequence::actions(ease, CCCallFunc::actionWithTarget(this, callfunc_selector(CCListView::finishFix)), NULL); + CCMoveBy *moveBy = CCMoveBy::create(m_fActionDuration, CCPointMake(disX, disY)); + CCEaseInOut *ease = CCEaseInOut::create(moveBy, 2); + CCFiniteTimeAction *actions = CCSequence::create(ease, CCCallFunc::create(this, callfunc_selector(CCListView::finishFix)), NULL); m_layerPanel->runAction(actions); } else @@ -1515,9 +1521,9 @@ void CCListView::fixLastRow(void) } m_nState = CCListViewStateFix; - CCMoveBy *moveBy = CCMoveBy::actionWithDuration(m_fActionDuration, CCPointMake(disX, disY)); - CCEaseInOut *ease = CCEaseInOut::actionWithAction(moveBy, 2); - CCFiniteTimeAction *actions = CCSequence::actions(ease, CCCallFunc::actionWithTarget(this, callfunc_selector(CCListView::finishFix)), NULL); + CCMoveBy *moveBy = CCMoveBy::create(m_fActionDuration, CCPointMake(disX, disY)); + CCEaseInOut *ease = CCEaseInOut::create(moveBy, 2); + CCFiniteTimeAction *actions = CCSequence::create(ease, CCCallFunc::create(this, callfunc_selector(CCListView::finishFix)), NULL); m_layerPanel->runAction(actions); } else @@ -1723,9 +1729,9 @@ void CCListView::easeOutWithDistance(float dis) } m_nState = CCListViewStateEaseOut; - CCMoveBy *moveBy = CCMoveBy::actionWithDuration(m_fActionDuration, CCPointMake(disX, disY)); - CCEaseOut *ease = CCEaseOut::actionWithAction(moveBy, 3); - CCFiniteTimeAction *actions = CCSequence::actions(ease, CCCallFunc::actionWithTarget(this, callfunc_selector(CCListView::finishEaseOut)), NULL); + CCMoveBy *moveBy = CCMoveBy::create(m_fActionDuration, CCPointMake(disX, disY)); + CCEaseOut *ease = CCEaseOut::create(moveBy, 3); + CCFiniteTimeAction *actions = CCSequence::create(ease, CCCallFunc::create(this, callfunc_selector(CCListView::finishEaseOut)), NULL); m_layerPanel->runAction(actions); } @@ -1820,6 +1826,8 @@ void CCListView::registerWithTouchDispatcher() void CCListView::onEnter(void) { + CCLayerColor::onEnter(); + if (0 == m_nNumberOfRows) { m_layerPanel->setPosition(CCPointZero); @@ -1828,8 +1836,6 @@ void CCListView::onEnter(void) m_nNumberOfRows = triggerNumberOfCells(); displayVisibleRows(); } - - CCLayerColor::onEnter(); } void CCListView::onExit(void) diff --git a/cocos2dx/extensions/CCListView/CCListView.h b/cocos2dx/extensions/CCListView/CCListView.h index 956940429d..4d2faf154a 100644 --- a/cocos2dx/extensions/CCListView/CCListView.h +++ b/cocos2dx/extensions/CCListView/CCListView.h @@ -121,7 +121,11 @@ public: virtual ~CCListView(void); CCListView(void); - static CCListView* viewWithMode(CCListViewMode mode); + // @warning: This interface will be deprecated in future. + //static CCListView* viewWithMode(CCListViewMode mode); + + static CCListView* create(CCListViewMode mode); + bool initWithMode(CCListViewMode mode); void setDelegateName(const char* pszName); diff --git a/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp b/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp index 780e52fc1e..a3630e1176 100644 --- a/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp +++ b/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp @@ -40,7 +40,7 @@ CCTextureWatcher::CCTextureWatcher() m_bFresh = true; m_pTextures = NULL; m_pszString = NULL; - m_pLayer = CCLayerColor::layerWithColor(ccc4(128, 128, 128, 128)); + m_pLayer = CCLayerColor::create(ccc4(128, 128, 128, 128)); m_pLayer->retain(); // layer @@ -50,19 +50,19 @@ CCTextureWatcher::CCTextureWatcher() // the menu of disabling touch event //* - CCLabelTTF *label = CCLabelTTF::labelWithString(" ", size, kCCTextAlignmentLeft, "Arial", 12); - CCMenuItemLabel *menuItem = CCMenuItemLabel::itemWithLabel(label); + CCLabelTTF *label = CCLabelTTF::create(" ", size, kCCTextAlignmentLeft, "Arial", 12); + CCMenuItemLabel *menuItem = CCMenuItemLabel::create(label); menuItem->setAnchorPoint(ccp(0, 0)); menuItem->setPosition(ccp(0, 0)); - CCMenu *menu = CCMenu::menuWithItem(menuItem); + CCMenu *menu = CCMenu::create(menuItem, NULL); menu->setAnchorPoint(ccp(0, 0)); menu->setPosition(ccp(0, 0)); m_pLayer->addChild(menu); //*/ // list - CCListView *list = CCListView::viewWithMode(CCListViewModeHorizontal); + CCListView *list = CCListView::create(CCListViewModeHorizontal); list->setContentSize(size); list->setDelegate(this); list->setSeparatorStyle(CCListViewCellSeparatorStyleNone); @@ -71,13 +71,13 @@ CCTextureWatcher::CCTextureWatcher() // 'Hide' button - CCLabelTTF *labelHide = CCLabelTTF::labelWithString("Hide ", "Arial", 24); + CCLabelTTF *labelHide = CCLabelTTF::create("Hide ", "Arial", 24); labelHide->setColor(ccc3(255, 0, 0)); - CCMenuItemLabel *menuItem2 = CCMenuItemLabel::itemWithLabel(labelHide, this, menu_selector(CCTextureWatcher::actionHide)); + CCMenuItemLabel *menuItem2 = CCMenuItemLabel::create(labelHide, this, menu_selector(CCTextureWatcher::actionHide)); menuItem2->setAnchorPoint(ccp(0, 0)); menuItem2->setPosition(ccp(0, 0)); - CCMenu *menu2 = CCMenu::menuWithItem(menuItem2); + CCMenu *menu2 = CCMenu::create(menuItem2, NULL); menu2->setAnchorPoint(ccp(0, 0)); menu2->setPosition(ccp(size.width - menuItem2->getContentSize().width, 0)); @@ -86,19 +86,19 @@ CCTextureWatcher::CCTextureWatcher() m_menuHide->retain(); // 'Fresh' button - CCLabelTTF *labelFresh = CCLabelTTF::labelWithString("Fresh", "Arial", 24); + CCLabelTTF *labelFresh = CCLabelTTF::create("Fresh", "Arial", 24); labelFresh->setColor(ccc3(255, 0, 0)); - CCMenuItemLabel *menuItem1 = CCMenuItemLabel::itemWithLabel(labelFresh, this, menu_selector(CCTextureWatcher::actionFresh)); + CCMenuItemLabel *menuItem1 = CCMenuItemLabel::create(labelFresh, this, menu_selector(CCTextureWatcher::actionFresh)); menuItem1->setAnchorPoint(ccp(0, 0)); menuItem1->setPosition(ccp(0, 0)); - CCMenu *menu1 = CCMenu::menuWithItem(menuItem1); + CCMenu *menu1 = CCMenu::create(menuItem1, NULL); menu1->setAnchorPoint(ccp(0, 0)); menu1->setPosition(ccp(size.width - menuItem1->getContentSize().width - menuItem2->getContentSize().width * 1.5, 0)); m_pLayer->addChild(menu1); // label page - m_labelPage = CCLabelTTF::labelWithString(" ", CCSizeMake(size.width * 0.1, labelFresh->getContentSize().height), kCCTextAlignmentCenter, "Arial", 16); + m_labelPage = CCLabelTTF::create(" ", CCSizeMake(size.width * 0.1, labelFresh->getContentSize().height), kCCTextAlignmentCenter, "Arial", 16); m_labelPage->setAnchorPoint(ccp(0.5, 0)); m_labelPage->setPosition(ccp(size.width/2.0, 0)); m_pLayer->addChild(m_labelPage, 0); @@ -279,7 +279,7 @@ void CCTextureWatcher::CCListView_cellForRow(CCListView *listView, CCListViewPro { // reference count sprintf(m_pszString, "[%d]", textrue->retainCount() - 2); - CCLabelTTF *labelCount = CCLabelTTF::labelWithString(m_pszString, "Arial", 16); + CCLabelTTF *labelCount = CCLabelTTF::create(m_pszString, "Arial", 16); if (textrue->retainCount() - 2 > 0) { labelCount->setColor(ccc3(0, 255, 0)); @@ -296,7 +296,7 @@ void CCTextureWatcher::CCListView_cellForRow(CCListView *listView, CCListViewPro // texture size sprintf(m_pszString, "%.0f*%.0f", textrue->getContentSize().width, textrue->getContentSize().height); - CCLabelTTF *labelSize = CCLabelTTF::labelWithString(m_pszString, "Arial", 16); + CCLabelTTF *labelSize = CCLabelTTF::create(m_pszString, "Arial", 16); offX = offsetX + listItemSize.width * 0.5f; offY = (listItemSize.height - size.height) * 0.5f + size.height; labelSize->setPosition(ccp(offX, offY)); @@ -314,14 +314,14 @@ void CCTextureWatcher::CCListView_cellForRow(CCListView *listView, CCListViewPro string name = key.substr(pos, len - pos); sprintf(m_pszString, "%s", name.c_str()); CCSize dimensions = CCSizeMake(listItemSize.width * 0.9f, labelSize->getContentSize().height); - CCLabelTTF *labelName = CCLabelTTF::labelWithString(m_pszString, dimensions, kCCTextAlignmentCenter, "Arial", 16); + CCLabelTTF *labelName = CCLabelTTF::create(m_pszString, dimensions, kCCTextAlignmentCenter, "Arial", 16); offX = offsetX + listItemSize.width * 0.5f; offY = offY + labelName->getContentSize().height; labelName->setPosition(ccp(offX, offY)); labelName->setAnchorPoint(ccp(0.5f, 0)); cell->addChild(labelName); - CCSprite *sprite = CCSprite::spriteWithTexture(textrue); + CCSprite *sprite = CCSprite::createWithTexture(textrue); sprite->setAnchorPoint(ccp(0, 0)); CCSize spriteSize = sprite->getContentSize(); diff --git a/cocos2dx/label_nodes/CCLabelAtlas.cpp b/cocos2dx/label_nodes/CCLabelAtlas.cpp index f58e482d6e..18b4974b62 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.cpp +++ b/cocos2dx/label_nodes/CCLabelAtlas.cpp @@ -41,7 +41,12 @@ THE SOFTWARE. NS_CC_BEGIN //CCLabelAtlas - Creation & Init -CCLabelAtlas* CCLabelAtlas::labelWithString(const char *label, const char *charMapFile, unsigned int itemWidth, int unsigned itemHeight, unsigned int startCharMap) +// CCLabelAtlas* CCLabelAtlas::labelWithString(const char *label, const char *charMapFile, unsigned int itemWidth, int unsigned itemHeight, unsigned int startCharMap) +// { +// return CCLabelAtlas::create(label, charMapFile, itemWidth, itemHeight, startCharMap); +// } + +CCLabelAtlas* CCLabelAtlas::create(const char *label, const char *charMapFile, unsigned int itemWidth, int unsigned itemHeight, unsigned int startCharMap) { CCLabelAtlas *pRet = new CCLabelAtlas(); if(pRet && pRet->initWithString(label, charMapFile, itemWidth, itemHeight, startCharMap)) @@ -65,7 +70,12 @@ bool CCLabelAtlas::initWithString(const char *label, const char *charMapFile, un return false; } -CCLabelAtlas* CCLabelAtlas::labelWithString(const char *string, const char *fntFile) +// CCLabelAtlas* CCLabelAtlas::labelWithString(const char *string, const char *fntFile) +// { +// return CCLabelAtlas::create(string, fntFile); +// } + +CCLabelAtlas* CCLabelAtlas::create(const char *string, const char *fntFile) { CCLabelAtlas *ret = new CCLabelAtlas(); if (ret) diff --git a/cocos2dx/label_nodes/CCLabelAtlas.h b/cocos2dx/label_nodes/CCLabelAtlas.h index 343c15b2d2..6cceadd50c 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.h +++ b/cocos2dx/label_nodes/CCLabelAtlas.h @@ -51,13 +51,24 @@ public: { m_sString.clear(); } + /** creates the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas + @warning: This interface will be deprecated in future. + */ + //static CCLabelAtlas * labelWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); + + /** creates the CCLabelAtlas with a string and a configuration file + @warning: This interface will be deprecated in future. + @since v2.0 + */ + //static CCLabelAtlas* labelWithString(const char *sring, const char *fntFile); + /** creates the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */ - static CCLabelAtlas * labelWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); + static CCLabelAtlas * create(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); /** creates the CCLabelAtlas with a string and a configuration file @since v2.0 */ - static CCLabelAtlas* labelWithString(const char *sring, const char *fntFile); + static CCLabelAtlas* create(const char *sring, const char *fntFile); /** initializes the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */ bool initWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index 4a5a8a42aa..baa5d91439 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -372,7 +372,7 @@ CCBMFontConfiguration* FNTConfigLoadFile( const char *fntFile) pRet = (CCBMFontConfiguration*)configurations->objectForKey(fntFile); if( pRet == NULL ) { - pRet = CCBMFontConfiguration::configurationWithFNTFile(fntFile); + pRet = CCBMFontConfiguration::create(fntFile); if (pRet) { configurations->setObject(pRet, fntFile); @@ -405,7 +405,12 @@ typedef struct _KerningHashElement //BitmapFontConfiguration // -CCBMFontConfiguration * CCBMFontConfiguration::configurationWithFNTFile(const char *FNTfile) +// CCBMFontConfiguration * CCBMFontConfiguration::configurationWithFNTFile(const char *FNTfile) +// { +// return CCBMFontConfiguration::create(FNTfile); +// } + +CCBMFontConfiguration * CCBMFontConfiguration::create(const char *FNTfile) { CCBMFontConfiguration * pRet = new CCBMFontConfiguration(); if (pRet->initWithFNTfile(FNTfile)) @@ -713,34 +718,13 @@ void CCLabelBMFont::purgeCachedData() FNTConfigRemoveCache(); } -//LabelBMFont - Creation & Init -CCLabelBMFont *CCLabelBMFont::labelWithString(const char *str, const char *fntFile) -{ - CCLabelBMFont *pRet = new CCLabelBMFont(); - if(pRet && pRet->initWithString(str, fntFile)) - { - pRet->autorelease(); - return pRet; - } - CC_SAFE_DELETE(pRet); - return NULL; -} +// CCLabelBMFont *CCLabelBMFont::labelWithString(const char *str, const char *fntFile, float width/* = kCCLabelAutomaticWidth*/, CCTextAlignment alignment/* = kCCTextAlignmentLeft*/, CCPoint imageOffset/* = CCPointZero*/) +// { +// return CCLabelBMFont::create(str, fntFile, width, alignment, imageOffset); +// } //LabelBMFont - Creation & Init -CCLabelBMFont *CCLabelBMFont::labelWithString(const char *str, const char *fntFile, float width, CCTextAlignment alignment) -{ - CCLabelBMFont *pRet = new CCLabelBMFont(); - if(pRet && pRet->initWithString(str, fntFile, width, alignment)) - { - pRet->autorelease(); - return pRet; - } - CC_SAFE_DELETE(pRet); - return NULL; -} - -//LabelBMFont - Creation & Init -CCLabelBMFont *CCLabelBMFont::labelWithString(const char *str, const char *fntFile, float width, CCTextAlignment alignment, CCPoint imageOffset) +CCLabelBMFont *CCLabelBMFont::create(const char *str, const char *fntFile, float width/* = kCCLabelAutomaticWidth*/, CCTextAlignment alignment/* = kCCTextAlignmentLeft*/, CCPoint imageOffset/* = CCPointZero*/) { CCLabelBMFont *pRet = new CCLabelBMFont(); if(pRet && pRet->initWithString(str, fntFile, width, alignment, imageOffset)) @@ -757,17 +741,7 @@ bool CCLabelBMFont::init() return initWithString(NULL, NULL, kCCLabelAutomaticWidth, kCCTextAlignmentLeft, CCPointZero); } -bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile) -{ - return initWithString(theString, fntFile, kCCLabelAutomaticWidth, kCCTextAlignmentLeft, CCPointZero); -} - -bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile, float width, CCTextAlignment alignment) -{ - return initWithString(theString, fntFile, width, alignment, CCPointZero); -} - -bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile, float width, CCTextAlignment alignment, CCPoint imageOffset) +bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile, float width/* = kCCLabelAutomaticWidth*/, CCTextAlignment alignment/* = kCCTextAlignmentLeft*/, CCPoint imageOffset/* = CCPointZero*/) { CCAssert(!m_pConfiguration, "re-init is no longer supported"); CCAssert( (theString && fntFile) || (theString==NULL && fntFile==NULL), "Invalid params for CCLabelBMFont"); diff --git a/cocos2dx/label_nodes/CCLabelBMFont.h b/cocos2dx/label_nodes/CCLabelBMFont.h index 4b063b3c30..f1dd84e337 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.h +++ b/cocos2dx/label_nodes/CCLabelBMFont.h @@ -103,8 +103,14 @@ public: CCBMFontConfiguration(); virtual ~CCBMFontConfiguration(); const char * description(); + /** allocates a CCBMFontConfiguration with a FNT file + @warning: This interface will be deprecated in future. + */ + //static CCBMFontConfiguration * configurationWithFNTFile(const char *FNTfile); + /** allocates a CCBMFontConfiguration with a FNT file */ - static CCBMFontConfiguration * configurationWithFNTFile(const char *FNTfile); + static CCBMFontConfiguration * create(const char *FNTfile); + /** initializes a BitmapFontConfiguration with a FNT file */ bool initWithFNTfile(const char *FNTfile); @@ -187,16 +193,17 @@ public: @since v0.99.3 */ static void purgeCachedData(); + /** creates a bitmap font altas with an initial string and the FNT file + @warning: This interface will be deprecated in future. + */ + //static CCLabelBMFont * labelWithString(const char *str, const char *fntFile, float width = kCCLabelAutomaticWidth, CCTextAlignment alignment = kCCTextAlignmentLeft, CCPoint imageOffset = CCPointZero); /** creates a bitmap font altas with an initial string and the FNT file */ - static CCLabelBMFont * labelWithString(const char *str, const char *fntFile); - static CCLabelBMFont * labelWithString(const char *str, const char *fntFile, float width, CCTextAlignment alignment); - static CCLabelBMFont * labelWithString(const char *str, const char *fntFile, float width, CCTextAlignment alignment, CCPoint imageOffset); + static CCLabelBMFont * create(const char *str, const char *fntFile, float width = kCCLabelAutomaticWidth, CCTextAlignment alignment = kCCTextAlignmentLeft, CCPoint imageOffset = CCPointZero); bool init(); /** init a bitmap font altas with an initial string and the FNT file */ - bool initWithString(const char *str, const char *fntFile, float width, CCTextAlignment alignment, CCPoint imageOffset); - bool initWithString(const char *str, const char *fntFile, float width, CCTextAlignment alignment); - bool initWithString(const char *str, const char *fntFile); + bool initWithString(const char *str, const char *fntFile, float width = kCCLabelAutomaticWidth, CCTextAlignment alignment = kCCTextAlignmentLeft, CCPoint imageOffset = CCPointZero); + /** updates the font chars based on the string to render */ void createFontChars(); // super method diff --git a/cocos2dx/label_nodes/CCLabelTTF.cpp b/cocos2dx/label_nodes/CCLabelTTF.cpp index 372331ad86..1c6cf41699 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.cpp +++ b/cocos2dx/label_nodes/CCLabelTTF.cpp @@ -53,17 +53,32 @@ CCLabelTTF::~CCLabelTTF() CC_SAFE_DELETE(m_pFontName); } -CCLabelTTF * CCLabelTTF::labelWithString(const char *string, const char *fontName, float fontSize) +// CCLabelTTF * CCLabelTTF::labelWithString(const char *string, const char *fontName, float fontSize) +// { +// return CCLabelTTF::create(string, fontName, fontSize); +// } + +CCLabelTTF * CCLabelTTF::create(const char *string, const char *fontName, float fontSize) { - return labelWithString(string, CCSizeZero, kCCTextAlignmentCenter, kCCVerticalTextAlignmentTop, fontName, fontSize); + return CCLabelTTF::create(string, CCSizeZero, kCCTextAlignmentCenter, kCCVerticalTextAlignmentTop, fontName, fontSize); } -CCLabelTTF * CCLabelTTF::labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, const char *fontName, float fontSize) +// CCLabelTTF * CCLabelTTF::labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, const char *fontName, float fontSize) +// { +// return CCLabelTTF::create(string, dimensions, hAlignment, kCCVerticalTextAlignmentTop, fontName, fontSize); +// } + +CCLabelTTF * CCLabelTTF::create(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, const char *fontName, float fontSize) { - return labelWithString(string, dimensions, hAlignment, kCCVerticalTextAlignmentTop, fontName, fontSize); + return CCLabelTTF::create(string, dimensions, hAlignment, kCCVerticalTextAlignmentTop, fontName, fontSize); } -CCLabelTTF* CCLabelTTF::labelWithString(const char *string, const cocos2d::CCSize &dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize) +// CCLabelTTF* CCLabelTTF::labelWithString(const char *string, const cocos2d::CCSize &dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize) +// { +// return CCLabelTTF::create(string, dimensions, hAlignment, vAlignment, fontName, fontSize); +// } + +CCLabelTTF* CCLabelTTF::create(const char *string, const cocos2d::CCSize &dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize) { CCLabelTTF *pRet = new CCLabelTTF(); if(pRet && pRet->initWithString(string, dimensions, hAlignment, vAlignment, fontName, fontSize)) diff --git a/cocos2dx/label_nodes/CCLabelTTF.h b/cocos2dx/label_nodes/CCLabelTTF.h index 78dd76b999..eeebb4fdfe 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.h +++ b/cocos2dx/label_nodes/CCLabelTTF.h @@ -43,19 +43,37 @@ public: virtual ~CCLabelTTF(); const char* description(); + /** creates a CCLabelTTF with a font name and font size in points + @warning: This interface will be deprecated in future. + */ + //static CCLabelTTF * labelWithString(const char *string, const char *fontName, float fontSize); + + /** creates a CCLabelTTF from a fontname, horizontal alignment, dimension in points, and font size in points. + @warning: This interface will be deprecated in future. + @since v1.0 + */ + //static CCLabelTTF * labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, + // const char *fontName, float fontSize); + + /** creates a CCLabel from a fontname, alignment, dimension in points and font size in points + @warning: This interface will be deprecated in future. + */ + //static CCLabelTTF * labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, + // CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize); + /** creates a CCLabelTTF with a font name and font size in points*/ - static CCLabelTTF * labelWithString(const char *string, const char *fontName, float fontSize); + static CCLabelTTF * create(const char *string, const char *fontName, float fontSize); /** creates a CCLabelTTF from a fontname, horizontal alignment, dimension in points, and font size in points. @since v1.0 */ - static CCLabelTTF * labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, + static CCLabelTTF * create(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, const char *fontName, float fontSize); /** creates a CCLabel from a fontname, alignment, dimension in points and font size in points*/ - static CCLabelTTF * labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, + static CCLabelTTF * create(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize); - + /** initializes the CCLabelTTF with a font name, alignment, dimension and font size */ bool initWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, const char *fontName, float fontSize); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index 3e160e7808..b8d055e25d 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -73,7 +73,12 @@ bool CCLayer::init() return bRet; } -CCLayer *CCLayer::node() +// CCLayer *CCLayer::node() +// { +// return CCLayer::create(); +// } + +CCLayer *CCLayer::create() { CCLayer *pRet = new CCLayer(); if (pRet && pRet->init()) @@ -421,8 +426,12 @@ void CCLayerColor::setBlendFunc(ccBlendFunc var) m_tBlendFunc = var; } +// CCLayerColor * CCLayerColor::layerWithColor(const ccColor4B& color, GLfloat width, GLfloat height) +// { +// return CCLayerColor::create(color,width,height); +// } -CCLayerColor * CCLayerColor::layerWithColor(const ccColor4B& color, GLfloat width, GLfloat height) +CCLayerColor * CCLayerColor::create(const ccColor4B& color, GLfloat width, GLfloat height) { CCLayerColor * pLayer = new CCLayerColor(); if( pLayer && pLayer->initWithColor(color,width,height)) @@ -433,7 +442,13 @@ CCLayerColor * CCLayerColor::layerWithColor(const ccColor4B& color, GLfloat widt CC_SAFE_DELETE(pLayer); return NULL; } -CCLayerColor * CCLayerColor::layerWithColor(const ccColor4B& color) + +// CCLayerColor * CCLayerColor::layerWithColor(const ccColor4B& color) +// { +// return CCLayerColor::create(color); +// } + +CCLayerColor * CCLayerColor::create(const ccColor4B& color) { CCLayerColor * pLayer = new CCLayerColor(); if(pLayer && pLayer->initWithColor(color)) @@ -543,7 +558,12 @@ void CCLayerColor::draw() // // CCLayerGradient // -CCLayerGradient* CCLayerGradient::layerWithColor(const ccColor4B& start, const ccColor4B& end) +// CCLayerGradient* CCLayerGradient::layerWithColor(const ccColor4B& start, const ccColor4B& end) +// { +// return CCLayerGradient::create(start, end); +// } + +CCLayerGradient* CCLayerGradient::create(const ccColor4B& start, const ccColor4B& end) { CCLayerGradient * pLayer = new CCLayerGradient(); if( pLayer && pLayer->initWithColor(start, end)) @@ -555,7 +575,12 @@ CCLayerGradient* CCLayerGradient::layerWithColor(const ccColor4B& start, const c return NULL; } -CCLayerGradient* CCLayerGradient::layerWithColor(const ccColor4B& start, const ccColor4B& end, const CCPoint& v) +// CCLayerGradient* CCLayerGradient::layerWithColor(const ccColor4B& start, const ccColor4B& end, const CCPoint& v) +// { +// return CCLayerGradient::create(start, end, v); +// } + +CCLayerGradient* CCLayerGradient::create(const ccColor4B& start, const ccColor4B& end, const CCPoint& v) { CCLayerGradient * pLayer = new CCLayerGradient(); if( pLayer && pLayer->initWithColor(start, end, v)) @@ -720,7 +745,24 @@ CCLayerMultiplex::~CCLayerMultiplex() CC_SAFE_RELEASE(m_pLayers); } -CCLayerMultiplex * CCLayerMultiplex::layerWithLayers(CCLayer * layer, ...) +// CCLayerMultiplex * CCLayerMultiplex::layerWithLayers(CCLayer * layer, ...) +// { +// va_list args; +// va_start(args,layer); +// +// CCLayerMultiplex * pMultiplexLayer = new CCLayerMultiplex(); +// if(pMultiplexLayer && pMultiplexLayer->initWithLayers(layer, args)) +// { +// pMultiplexLayer->autorelease(); +// va_end(args); +// return pMultiplexLayer; +// } +// va_end(args); +// CC_SAFE_DELETE(pMultiplexLayer); +// return NULL; +// } + +CCLayerMultiplex * CCLayerMultiplex::create(CCLayer * layer, ...) { va_list args; va_start(args,layer); @@ -737,13 +779,19 @@ CCLayerMultiplex * CCLayerMultiplex::layerWithLayers(CCLayer * layer, ...) return NULL; } -CCLayerMultiplex * CCLayerMultiplex::layerWithLayer(CCLayer* layer) +// CCLayerMultiplex * CCLayerMultiplex::layerWithLayer(CCLayer* layer) +// { +// return CCLayerMultiplex::create(layer); +// } + +CCLayerMultiplex * CCLayerMultiplex::create(CCLayer* layer) { CCLayerMultiplex * pMultiplexLayer = new CCLayerMultiplex(); pMultiplexLayer->initWithLayer(layer); pMultiplexLayer->autorelease(); return pMultiplexLayer; } + void CCLayerMultiplex::addLayer(CCLayer* layer) { CCAssert(m_pLayers, ""); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h index d42b3eae98..f405836f57 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h @@ -53,7 +53,11 @@ public: CCLayer(); virtual ~CCLayer(); bool init(); - static CCLayer *node(void); + + // @warning: This interface will be deprecated in future. + //static CCLayer *node(void); + /** create one layer */ + static CCLayer *create(void); virtual void onEnter(); virtual void onExit(); @@ -115,25 +119,64 @@ private: }; // for the subclass of CCLayer, each has to implement the static "node" method -#define LAYER_NODE_FUNC(layer) \ -static layer* node() \ -{ \ -layer *pRet = new layer(); \ -if (pRet && pRet->init()) \ -{ \ -pRet->autorelease(); \ -return pRet; \ -} \ -else \ -{ \ -delete pRet; \ -pRet = NULL; \ -return NULL; \ -} \ -}; +// @warning: This interface will be deprecated in future. +//#define LAYER_NODE_FUNC(layer) \ +// static layer* node() \ +// { \ +// layer *pRet = new layer(); \ +// if (pRet && pRet->init()) \ +// { \ +// pRet->autorelease(); \ +// return pRet; \ +// } \ +// else \ +// { \ +// delete pRet; \ +// pRet = NULL; \ +// return NULL; \ +// } \ +// } -#define LAYER_NODE_FUNC_PARAM(layer,__PARAMTYPE__,__PARAM__) \ - static layer* node(__PARAMTYPE__ __PARAM__) \ + +// for the subclass of CCLayer, each has to implement the static "node" method +#define LAYER_CREATE_FUNC(layer) \ + static layer* create() \ + { \ + layer *pRet = new layer(); \ + if (pRet && pRet->init()) \ + { \ + pRet->autorelease(); \ + return pRet; \ + } \ + else \ + { \ + delete pRet; \ + pRet = NULL; \ + return NULL; \ + } \ +} + +// @warning: This interface will be deprecated in future. +//#define LAYER_NODE_FUNC_PARAM(layer,__PARAMTYPE__,__PARAM__) \ +// static layer* node(__PARAMTYPE__ __PARAM__) \ +// { \ +// layer *pRet = new layer(); \ +// if (pRet && pRet->init(__PARAM__)) \ +// { \ +// pRet->autorelease(); \ +// return pRet; \ +// } \ +// else \ +// { \ +// delete pRet; \ +// pRet = NULL; \ +// return NULL; \ +// } \ +// } + + +#define LAYER_CREATE_FUNC_PARAM(layer,__PARAMTYPE__,__PARAM__) \ + static layer* create(__PARAMTYPE__ __PARAM__) \ { \ layer *pRet = new layer(); \ if (pRet && pRet->init(__PARAM__)) \ @@ -148,8 +191,6 @@ return NULL; \ return NULL; \ } \ } - - // // CCLayerColor // @@ -173,10 +214,19 @@ public: virtual void draw(); virtual void setContentSize(const CCSize& var); + /** creates a CCLayer with color, width and height in Points + @warning: This interface will be deprecated in future. + */ + //static CCLayerColor * layerWithColor(const ccColor4B& color, GLfloat width, GLfloat height); + /** creates a CCLayer with color. Width and height are the window size. + @warning: This interface will be deprecated in future. + */ + //static CCLayerColor * layerWithColor(const ccColor4B& color); + /** creates a CCLayer with color, width and height in Points */ - static CCLayerColor * layerWithColor(const ccColor4B& color, GLfloat width, GLfloat height); + static CCLayerColor * create(const ccColor4B& color, GLfloat width, GLfloat height); /** creates a CCLayer with color. Width and height are the window size. */ - static CCLayerColor * layerWithColor(const ccColor4B& color); + static CCLayerColor * create(const ccColor4B& color); virtual bool init(); /** initializes a CCLayer with color, width and height in Points */ @@ -202,7 +252,7 @@ public: virtual void setIsOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} virtual bool getIsOpacityModifyRGB(void) { return false;} - LAYER_NODE_FUNC(CCLayerColor); + LAYER_CREATE_FUNC(CCLayerColor); protected: virtual void updateColor(); @@ -234,11 +284,21 @@ If ' compressedInterpolation' is enabled (default mode) you will see both the st class CC_DLL CCLayerGradient : public CCLayerColor { public: + /** Creates a full-screen CCLayer with a gradient between start and end. + @warning: This interface will be deprecated in future. + */ + //static CCLayerGradient* layerWithColor(const ccColor4B& start, const ccColor4B& end); + + /** Creates a full-screen CCLayer with a gradient between start and end in the direction of v. + @warning: This interface will be deprecated in future. + */ + //static CCLayerGradient* layerWithColor(const ccColor4B& start, const ccColor4B& end, const CCPoint& v); + /** Creates a full-screen CCLayer with a gradient between start and end. */ - static CCLayerGradient* layerWithColor(const ccColor4B& start, const ccColor4B& end); + static CCLayerGradient* create(const ccColor4B& start, const ccColor4B& end); /** Creates a full-screen CCLayer with a gradient between start and end in the direction of v. */ - static CCLayerGradient* layerWithColor(const ccColor4B& start, const ccColor4B& end, const CCPoint& v); + static CCLayerGradient* create(const ccColor4B& start, const ccColor4B& end, const CCPoint& v); /** Initializes the CCLayer with a gradient between start and end. */ virtual bool initWithColor(const ccColor4B& start, const ccColor4B& end); @@ -257,7 +317,7 @@ public: */ CC_PROPERTY(bool, m_bCompressedInterpolation, IsCompressedInterpolation) - LAYER_NODE_FUNC(CCLayerGradient); + LAYER_CREATE_FUNC(CCLayerGradient); protected: virtual void updateColor(); }; @@ -277,14 +337,27 @@ public: CCLayerMultiplex(); virtual ~CCLayerMultiplex(); + /** creates a CCLayerMultiplex with one or more layers using a variable argument list. + @warning: This interface will be deprecated in future. + */ + //static CCLayerMultiplex * layerWithLayers(CCLayer* layer, ... ); + + /** + * lua script can not init with undetermined number of variables + * so add these functinons to be used with lua. + @warning: This interface will be deprecated in future. + */ + //static CCLayerMultiplex * layerWithLayer(CCLayer* layer); + /** creates a CCLayerMultiplex with one or more layers using a variable argument list. */ - static CCLayerMultiplex * layerWithLayers(CCLayer* layer, ... ); + static CCLayerMultiplex * create(CCLayer* layer, ... ); /** * lua script can not init with undetermined number of variables * so add these functinons to be used with lua. */ - static CCLayerMultiplex * layerWithLayer(CCLayer* layer); + static CCLayerMultiplex * create(CCLayer* layer); + void addLayer(CCLayer* layer); bool initWithLayer(CCLayer* layer); @@ -299,7 +372,7 @@ public: */ void switchToAndReleaseMe(unsigned int n); - LAYER_NODE_FUNC(CCLayerMultiplex); + LAYER_CREATE_FUNC(CCLayerMultiplex); }; NS_CC_END diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp index fa684792e2..818cb049f2 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp @@ -54,7 +54,12 @@ bool CCScene::init() return bRet; } -CCScene *CCScene::node() +// CCScene *CCScene::node() +// { +// return CCScene::create(); +// } + +CCScene *CCScene::create() { CCScene *pRet = new CCScene(); if (pRet && pRet->init()) diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCScene.h b/cocos2dx/layers_scenes_transitions_nodes/CCScene.h index 72d5cead50..997e43e6dc 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCScene.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCScene.h @@ -47,14 +47,50 @@ public: CCScene(); virtual ~CCScene(); bool init(); - static CCScene *node(void); + //static CCScene *node(void); + static CCScene *create(void); }; NS_CC_END +// for the subclass of CCScene, each has to implement the static "node" method +// @warning: This interface will be deprecated in future. +// #define SCENE_NODE_FUNC(scene) \ +// static scene* node() \ +// { \ +// scene *pRet = new scene(); \ +// if (pRet && pRet->init()) \ +// { \ +// pRet->autorelease(); \ +// return pRet; \ +// } \ +// else \ +// { \ +// delete pRet; \ +// pRet = NULL; \ +// return NULL; \ +// } \ +// }; + +// @warning: This interface will be deprecated in future. +// #define SCENE_FUNC_PARAM(__TYPE__,__PARAMTYPE__,__PARAM__) \ +// static cocos2d::CCScene* node(__PARAMTYPE__ __PARAM__) \ +// { \ +// cocos2d::CCScene * scene = NULL; \ +// do \ +// { \ +// scene = cocos2d::CCScene::node(); \ +// CC_BREAK_IF(! scene); \ +// __TYPE__ *layer = __TYPE__::node(__PARAM__); \ +// CC_BREAK_IF(! layer); \ +// scene->addChild(layer); \ +// } while (0); \ +// return scene; \ +// } + // for the subclass of CCScene, each has to implement the static "node" method -#define SCENE_NODE_FUNC(scene) \ -static scene* node() \ +#define SCENE_CREATE_FUNC(scene) \ +static scene* create() \ { \ scene *pRet = new scene(); \ if (pRet && pRet->init()) \ @@ -70,20 +106,19 @@ static scene* node() \ } \ }; -#define SCENE_FUNC_PARAM(__TYPE__,__PARAMTYPE__,__PARAM__) \ - static cocos2d::CCScene* node(__PARAMTYPE__ __PARAM__) \ +#define SCENE_CREATE_FUNC_PARAM(__TYPE__,__PARAMTYPE__,__PARAM__) \ + static cocos2d::CCScene* create(__PARAMTYPE__ __PARAM__) \ { \ cocos2d::CCScene * scene = NULL; \ do \ { \ - scene = cocos2d::CCScene::node(); \ + scene = cocos2d::CCScene::create(); \ CC_BREAK_IF(! scene); \ - __TYPE__ *layer = __TYPE__::node(__PARAM__); \ + __TYPE__ *layer = __TYPE__::create(__PARAM__); \ CC_BREAK_IF(! layer); \ scene->addChild(layer); \ } while (0); \ return scene; \ } - #endif // __CCSCENE_H__ diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp index 3c1e527ef2..acf3c10f32 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp @@ -51,7 +51,12 @@ CCTransitionScene::~CCTransitionScene() m_pOutScene->release(); } -CCTransitionScene * CCTransitionScene::transitionWithDuration(float t, CCScene *scene) +// CCTransitionScene * CCTransitionScene::transitionWithDuration(float t, CCScene *scene) +// { +// return CCTransitionScene::create(t,scene); +// } + +CCTransitionScene * CCTransitionScene::create(float t, CCScene *scene) { CCTransitionScene * pScene = new CCTransitionScene(); if(pScene && pScene->initWithDuration(t,scene)) @@ -77,7 +82,7 @@ bool CCTransitionScene::initWithDuration(float t, CCScene *scene) m_pOutScene = CCDirector::sharedDirector()->getRunningScene(); if (m_pOutScene == NULL) { - m_pOutScene = CCScene::node(); + m_pOutScene = CCScene::create(); m_pOutScene->init(); } m_pOutScene->retain(); @@ -190,14 +195,21 @@ void CCTransitionScene::cleanup() // // Oriented Transition // + CCTransitionSceneOriented::CCTransitionSceneOriented() { } + CCTransitionSceneOriented::~CCTransitionSceneOriented() { } -CCTransitionSceneOriented * CCTransitionSceneOriented::transitionWithDuration(float t, CCScene *scene, tOrientation orientation) +// CCTransitionSceneOriented * CCTransitionSceneOriented::transitionWithDuration(float t, CCScene *scene, tOrientation orientation) +// { +// return CCTransitionSceneOriented::create(t,scene,orientation); +// } + +CCTransitionSceneOriented * CCTransitionSceneOriented::create(float t, CCScene *scene, tOrientation orientation) { CCTransitionSceneOriented * pScene = new CCTransitionSceneOriented(); pScene->initWithDuration(t,scene,orientation); @@ -220,6 +232,7 @@ bool CCTransitionSceneOriented::initWithDuration(float t, CCScene *scene, tOrien CCTransitionRotoZoom::CCTransitionRotoZoom() { } + CCTransitionRotoZoom::~CCTransitionRotoZoom() { } @@ -234,33 +247,30 @@ void CCTransitionRotoZoom:: onEnter() m_pInScene->setAnchorPoint(ccp(0.5f, 0.5f)); m_pOutScene->setAnchorPoint(ccp(0.5f, 0.5f)); - CCActionInterval *rotozoom = (CCActionInterval*)(CCSequence::actions + CCActionInterval *rotozoom = (CCActionInterval*)(CCSequence::create ( - CCSpawn::actions + CCSpawn::create ( - CCScaleBy::actionWithDuration(m_fDuration/2, 0.001f), - CCRotateBy::actionWithDuration(m_fDuration/2, 360 * 2), + CCScaleBy::create(m_fDuration/2, 0.001f), + CCRotateBy::create(m_fDuration/2, 360 * 2), NULL ), - CCDelayTime::actionWithDuration(m_fDuration/2), + CCDelayTime::create(m_fDuration/2), NULL )); m_pOutScene->runAction(rotozoom); m_pInScene->runAction ( - CCSequence::actions + CCSequence::create ( rotozoom->reverse(), - CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)), + CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)), NULL ) ); } -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionRotoZoom) - - // // JumpZoom // @@ -281,36 +291,35 @@ void CCTransitionJumpZoom::onEnter() m_pInScene->setAnchorPoint(ccp(0.5f, 0.5f)); m_pOutScene->setAnchorPoint(ccp(0.5f, 0.5f)); - CCActionInterval *jump = CCJumpBy::actionWithDuration(m_fDuration/4, ccp(-s.width,0), s.width/4, 2); - CCActionInterval *scaleIn = CCScaleTo::actionWithDuration(m_fDuration/4, 1.0f); - CCActionInterval *scaleOut = CCScaleTo::actionWithDuration(m_fDuration/4, 0.5f); + CCActionInterval *jump = CCJumpBy::create(m_fDuration/4, ccp(-s.width,0), s.width/4, 2); + CCActionInterval *scaleIn = CCScaleTo::create(m_fDuration/4, 1.0f); + CCActionInterval *scaleOut = CCScaleTo::create(m_fDuration/4, 0.5f); - CCActionInterval *jumpZoomOut = (CCActionInterval*)(CCSequence::actions(scaleOut, jump, NULL)); - CCActionInterval *jumpZoomIn = (CCActionInterval*)(CCSequence::actions(jump, scaleIn, NULL)); + CCActionInterval *jumpZoomOut = (CCActionInterval*)(CCSequence::create(scaleOut, jump, NULL)); + CCActionInterval *jumpZoomIn = (CCActionInterval*)(CCSequence::create(jump, scaleIn, NULL)); - CCActionInterval *delay = CCDelayTime::actionWithDuration(m_fDuration/2); + CCActionInterval *delay = CCDelayTime::create(m_fDuration/2); m_pOutScene->runAction(jumpZoomOut); m_pInScene->runAction ( - CCSequence::actions + CCSequence::create ( delay, jumpZoomIn, - CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)), + CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)), NULL ) ); } -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionJumpZoom) - // // MoveInL // CCTransitionMoveInL::CCTransitionMoveInL() { } + CCTransitionMoveInL::~CCTransitionMoveInL() { } @@ -324,10 +333,10 @@ void CCTransitionMoveInL::onEnter() m_pInScene->runAction ( - CCSequence::actions + CCSequence::create ( this->easeActionWithAction(a), - CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)), + CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)), NULL ) ); @@ -335,12 +344,12 @@ void CCTransitionMoveInL::onEnter() CCActionInterval* CCTransitionMoveInL::action() { - return CCMoveTo::actionWithDuration(m_fDuration, ccp(0,0)); + return CCMoveTo::create(m_fDuration, ccp(0,0)); } CCActionInterval* CCTransitionMoveInL::easeActionWithAction(CCActionInterval* action) { - return CCEaseOut::actionWithAction(action, 2.0f); + return CCEaseOut::create(action, 2.0f); // return [EaseElasticOut actionWithAction:action period:0.4f]; } @@ -350,8 +359,6 @@ void CCTransitionMoveInL::initScenes() m_pInScene->setPosition( ccp(-s.width,0) ); } -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionMoveInL) - // // MoveInR // @@ -368,8 +375,6 @@ void CCTransitionMoveInR::initScenes() m_pInScene->setPosition( ccp(s.width,0) ); } -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionMoveInR) - // // MoveInT // @@ -386,8 +391,6 @@ void CCTransitionMoveInT::initScenes() m_pInScene->setPosition( ccp(0,s.height) ); } -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionMoveInT) - // // MoveInB // @@ -404,8 +407,6 @@ void CCTransitionMoveInB::initScenes() m_pInScene->setPosition( ccp(0,-s.height) ); } -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionMoveInB) - // // SlideInL @@ -432,10 +433,10 @@ void CCTransitionSlideInL::onEnter() CCActionInterval *out = this->action(); CCActionInterval* inAction = easeActionWithAction(in); - CCActionInterval* outAction = (CCActionInterval*)CCSequence::actions + CCActionInterval* outAction = (CCActionInterval*)CCSequence::create ( easeActionWithAction(out), - CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)), + CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)), NULL ); m_pInScene->runAction(inAction); @@ -456,17 +457,15 @@ void CCTransitionSlideInL:: initScenes() CCActionInterval* CCTransitionSlideInL::action() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - return CCMoveBy::actionWithDuration(m_fDuration, ccp(s.width-ADJUST_FACTOR,0)); + return CCMoveBy::create(m_fDuration, ccp(s.width-ADJUST_FACTOR,0)); } CCActionInterval* CCTransitionSlideInL::easeActionWithAction(CCActionInterval* action) { - return CCEaseOut::actionWithAction(action, 2.0f); + return CCEaseOut::create(action, 2.0f); // return [EaseElasticOut actionWithAction:action period:0.4f]; } -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionSlideInL) - // // SlideInR @@ -493,11 +492,9 @@ void CCTransitionSlideInR::initScenes() CCActionInterval* CCTransitionSlideInR:: action() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - return CCMoveBy::actionWithDuration(m_fDuration, ccp(-(s.width-ADJUST_FACTOR),0)); + return CCMoveBy::create(m_fDuration, ccp(-(s.width-ADJUST_FACTOR),0)); } -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionSlideInR) - // // SlideInT @@ -524,11 +521,9 @@ void CCTransitionSlideInT::initScenes() CCActionInterval* CCTransitionSlideInT::action() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - return CCMoveBy::actionWithDuration(m_fDuration, ccp(0,-(s.height-ADJUST_FACTOR))); + return CCMoveBy::create(m_fDuration, ccp(0,-(s.height-ADJUST_FACTOR))); } -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionSlideInT) - // // SlideInB // @@ -554,11 +549,9 @@ void CCTransitionSlideInB:: initScenes() CCActionInterval* CCTransitionSlideInB:: action() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - return CCMoveBy::actionWithDuration(m_fDuration, ccp(0,s.height-ADJUST_FACTOR)); + return CCMoveBy::create(m_fDuration, ccp(0,s.height-ADJUST_FACTOR)); } -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionSlideInB) - // // ShrinkGrow Transition // @@ -579,28 +572,26 @@ void CCTransitionShrinkGrow::onEnter() m_pInScene->setAnchorPoint(ccp(2/3.0f,0.5f)); m_pOutScene->setAnchorPoint(ccp(1/3.0f,0.5f)); - CCActionInterval* scaleOut = CCScaleTo::actionWithDuration(m_fDuration, 0.01f); - CCActionInterval* scaleIn = CCScaleTo::actionWithDuration(m_fDuration, 1.0f); + CCActionInterval* scaleOut = CCScaleTo::create(m_fDuration, 0.01f); + CCActionInterval* scaleIn = CCScaleTo::create(m_fDuration, 1.0f); m_pInScene->runAction(this->easeActionWithAction(scaleIn)); m_pOutScene->runAction ( - CCSequence::actions + CCSequence::create ( this->easeActionWithAction(scaleOut), - CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)), + CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)), NULL ) ); } CCActionInterval* CCTransitionShrinkGrow:: easeActionWithAction(CCActionInterval* action) { - return CCEaseOut::actionWithAction(action, 2.0f); + return CCEaseOut::create(action, 2.0f); // return [EaseElasticOut actionWithAction:action period:0.3f]; } -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionShrinkGrow) - // // FlipX Transition // @@ -636,20 +627,20 @@ void CCTransitionFlipX::onEnter() outAngleZ = 0; } - inA = (CCActionInterval*)CCSequence::actions + inA = (CCActionInterval*)CCSequence::create ( - CCDelayTime::actionWithDuration(m_fDuration/2), - CCShow::action(), - CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, 0, 0), - CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)), + CCDelayTime::create(m_fDuration/2), + CCShow::create(), + CCOrbitCamera::create(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, 0, 0), + CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)), NULL ); - outA = (CCActionInterval *)CCSequence::actions + outA = (CCActionInterval *)CCSequence::create ( - CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0, outAngleZ, outDeltaZ, 0, 0), - CCHide::action(), - CCDelayTime::actionWithDuration(m_fDuration/2), + CCOrbitCamera::create(m_fDuration/2, 1, 0, outAngleZ, outDeltaZ, 0, 0), + CCHide::create(), + CCDelayTime::create(m_fDuration/2), NULL ); @@ -657,7 +648,12 @@ void CCTransitionFlipX::onEnter() m_pOutScene->runAction(outA); } -CCTransitionFlipX* CCTransitionFlipX::transitionWithDuration(float t, CCScene* s, tOrientation o) +// CCTransitionFlipX* CCTransitionFlipX::transitionWithDuration(float t, CCScene* s, tOrientation o) +// { +// return CCTransitionFlipX::create(t, s, o); +// } + +CCTransitionFlipX* CCTransitionFlipX::create(float t, CCScene* s, tOrientation o) { CCTransitionFlipX* pScene = new CCTransitionFlipX(); pScene->initWithDuration(t, s, o); @@ -701,19 +697,19 @@ void CCTransitionFlipY::onEnter() outAngleZ = 0; } - inA = (CCActionInterval*)CCSequence::actions + inA = (CCActionInterval*)CCSequence::create ( - CCDelayTime::actionWithDuration(m_fDuration/2), - CCShow::action(), - CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, 90, 0), - CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)), + CCDelayTime::create(m_fDuration/2), + CCShow::create(), + CCOrbitCamera::create(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, 90, 0), + CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)), NULL ); - outA = (CCActionInterval*)CCSequence::actions + outA = (CCActionInterval*)CCSequence::create ( - CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0, outAngleZ, outDeltaZ, 90, 0), - CCHide::action(), - CCDelayTime::actionWithDuration(m_fDuration/2), + CCOrbitCamera::create(m_fDuration/2, 1, 0, outAngleZ, outDeltaZ, 90, 0), + CCHide::create(), + CCDelayTime::create(m_fDuration/2), NULL ); @@ -722,7 +718,12 @@ void CCTransitionFlipY::onEnter() } -CCTransitionFlipY* CCTransitionFlipY::transitionWithDuration(float t, CCScene* s, tOrientation o) +// CCTransitionFlipY* CCTransitionFlipY::transitionWithDuration(float t, CCScene* s, tOrientation o) +// { +// return CCTransitionFlipY::create(t, s, o); +// } + +CCTransitionFlipY* CCTransitionFlipY::create(float t, CCScene* s, tOrientation o) { CCTransitionFlipY* pScene = new CCTransitionFlipY(); pScene->initWithDuration(t, s, o); @@ -737,6 +738,7 @@ CCTransitionFlipY* CCTransitionFlipY::transitionWithDuration(float t, CCScene* s CCTransitionFlipAngular::CCTransitionFlipAngular() { } + CCTransitionFlipAngular::~CCTransitionFlipAngular() { } @@ -766,19 +768,19 @@ void CCTransitionFlipAngular::onEnter() outAngleZ = 0; } - inA = (CCActionInterval *)CCSequence::actions + inA = (CCActionInterval *)CCSequence::create ( - CCDelayTime::actionWithDuration(m_fDuration/2), - CCShow::action(), - CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, -45, 0), - CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)), + CCDelayTime::create(m_fDuration/2), + CCShow::create(), + CCOrbitCamera::create(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, -45, 0), + CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)), NULL ); - outA = (CCActionInterval *)CCSequence::actions + outA = (CCActionInterval *)CCSequence::create ( - CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0, outAngleZ, outDeltaZ, 45, 0), - CCHide::action(), - CCDelayTime::actionWithDuration(m_fDuration/2), + CCOrbitCamera::create(m_fDuration/2, 1, 0, outAngleZ, outDeltaZ, 45, 0), + CCHide::create(), + CCDelayTime::create(m_fDuration/2), NULL ); @@ -786,7 +788,12 @@ void CCTransitionFlipAngular::onEnter() m_pOutScene->runAction(outA); } -CCTransitionFlipAngular* CCTransitionFlipAngular::transitionWithDuration(float t, CCScene* s, tOrientation o) +// CCTransitionFlipAngular* CCTransitionFlipAngular::transitionWithDuration(float t, CCScene* s, tOrientation o) +// { +// return CCTransitionFlipAngular::create(t, s, o); +// } + +CCTransitionFlipAngular* CCTransitionFlipAngular::create(float t, CCScene* s, tOrientation o) { CCTransitionFlipAngular* pScene = new CCTransitionFlipAngular(); pScene->initWithDuration(t, s, o); @@ -828,29 +835,29 @@ void CCTransitionZoomFlipX::onEnter() outDeltaZ = -90; outAngleZ = 0; } - inA = (CCActionInterval *)CCSequence::actions + inA = (CCActionInterval *)CCSequence::create ( - CCDelayTime::actionWithDuration(m_fDuration/2), - CCSpawn::actions + CCDelayTime::create(m_fDuration/2), + CCSpawn::create ( - CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, 0, 0), - CCScaleTo::actionWithDuration(m_fDuration/2, 1), - CCShow::action(), + CCOrbitCamera::create(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, 0, 0), + CCScaleTo::create(m_fDuration/2, 1), + CCShow::create(), NULL ), - CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)), + CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)), NULL ); - outA = (CCActionInterval *)CCSequence::actions + outA = (CCActionInterval *)CCSequence::create ( - CCSpawn::actions + CCSpawn::create ( - CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0, outAngleZ, outDeltaZ, 0, 0), - CCScaleTo::actionWithDuration(m_fDuration/2, 0.5f), + CCOrbitCamera::create(m_fDuration/2, 1, 0, outAngleZ, outDeltaZ, 0, 0), + CCScaleTo::create(m_fDuration/2, 0.5f), NULL ), - CCHide::action(), - CCDelayTime::actionWithDuration(m_fDuration/2), + CCHide::create(), + CCDelayTime::create(m_fDuration/2), NULL ); @@ -859,7 +866,12 @@ void CCTransitionZoomFlipX::onEnter() m_pOutScene->runAction(outA); } -CCTransitionZoomFlipX* CCTransitionZoomFlipX::transitionWithDuration(float t, CCScene* s, tOrientation o) +// CCTransitionZoomFlipX* CCTransitionZoomFlipX::transitionWithDuration(float t, CCScene* s, tOrientation o) +// { +// return CCTransitionZoomFlipX::create(t, s, o); +// } + +CCTransitionZoomFlipX* CCTransitionZoomFlipX::create(float t, CCScene* s, tOrientation o) { CCTransitionZoomFlipX* pScene = new CCTransitionZoomFlipX(); pScene->initWithDuration(t, s, o); @@ -874,6 +886,7 @@ CCTransitionZoomFlipX* CCTransitionZoomFlipX::transitionWithDuration(float t, CC CCTransitionZoomFlipY::CCTransitionZoomFlipY() { } + CCTransitionZoomFlipY::~CCTransitionZoomFlipY() { } @@ -900,30 +913,30 @@ void CCTransitionZoomFlipY::onEnter() outAngleZ = 0; } - inA = (CCActionInterval *)CCSequence::actions + inA = (CCActionInterval *)CCSequence::create ( - CCDelayTime::actionWithDuration(m_fDuration/2), - CCSpawn::actions + CCDelayTime::create(m_fDuration/2), + CCSpawn::create ( - CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, 90, 0), - CCScaleTo::actionWithDuration(m_fDuration/2, 1), - CCShow::action(), + CCOrbitCamera::create(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, 90, 0), + CCScaleTo::create(m_fDuration/2, 1), + CCShow::create(), NULL ), - CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)), + CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)), NULL ); - outA = (CCActionInterval *)CCSequence::actions + outA = (CCActionInterval *)CCSequence::create ( - CCSpawn::actions + CCSpawn::create ( - CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0, outAngleZ, outDeltaZ, 90, 0), - CCScaleTo::actionWithDuration(m_fDuration/2, 0.5f), + CCOrbitCamera::create(m_fDuration/2, 1, 0, outAngleZ, outDeltaZ, 90, 0), + CCScaleTo::create(m_fDuration/2, 0.5f), NULL ), - CCHide::action(), - CCDelayTime::actionWithDuration(m_fDuration/2), + CCHide::create(), + CCDelayTime::create(m_fDuration/2), NULL ); @@ -932,7 +945,12 @@ void CCTransitionZoomFlipY::onEnter() m_pOutScene->runAction(outA); } -CCTransitionZoomFlipY* CCTransitionZoomFlipY::transitionWithDuration(float t, CCScene* s, tOrientation o) +// CCTransitionZoomFlipY* CCTransitionZoomFlipY::transitionWithDuration(float t, CCScene* s, tOrientation o) +// { +// return CCTransitionZoomFlipY::create(t, s, o); +// } + +CCTransitionZoomFlipY* CCTransitionZoomFlipY::create(float t, CCScene* s, tOrientation o) { CCTransitionZoomFlipY* pScene = new CCTransitionZoomFlipY(); pScene->initWithDuration(t, s, o); @@ -976,30 +994,30 @@ void CCTransitionZoomFlipAngular::onEnter() outAngleZ = 0; } - inA = (CCActionInterval *)CCSequence::actions + inA = (CCActionInterval *)CCSequence::create ( - CCDelayTime::actionWithDuration(m_fDuration/2), - CCSpawn::actions + CCDelayTime::create(m_fDuration/2), + CCSpawn::create ( - CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, -45, 0), - CCScaleTo::actionWithDuration(m_fDuration/2, 1), - CCShow::action(), + CCOrbitCamera::create(m_fDuration/2, 1, 0, inAngleZ, inDeltaZ, -45, 0), + CCScaleTo::create(m_fDuration/2, 1), + CCShow::create(), NULL ), - CCShow::action(), - CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)), + CCShow::create(), + CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)), NULL ); - outA = (CCActionInterval *)CCSequence::actions + outA = (CCActionInterval *)CCSequence::create ( - CCSpawn::actions + CCSpawn::create ( - CCOrbitCamera::actionWithDuration(m_fDuration/2, 1, 0 , outAngleZ, outDeltaZ, 45, 0), - CCScaleTo::actionWithDuration(m_fDuration/2, 0.5f), + CCOrbitCamera::create(m_fDuration/2, 1, 0 , outAngleZ, outDeltaZ, 45, 0), + CCScaleTo::create(m_fDuration/2, 0.5f), NULL ), - CCHide::action(), - CCDelayTime::actionWithDuration(m_fDuration/2), + CCHide::create(), + CCDelayTime::create(m_fDuration/2), NULL ); @@ -1008,7 +1026,12 @@ void CCTransitionZoomFlipAngular::onEnter() m_pOutScene->runAction(outA); } -CCTransitionZoomFlipAngular* CCTransitionZoomFlipAngular::transitionWithDuration(float t, CCScene* s, tOrientation o) +// CCTransitionZoomFlipAngular* CCTransitionZoomFlipAngular::transitionWithDuration(float t, CCScene* s, tOrientation o) +// { +// return CCTransitionZoomFlipAngular::create(t, s, o); +// } + +CCTransitionZoomFlipAngular* CCTransitionZoomFlipAngular::create(float t, CCScene* s, tOrientation o) { CCTransitionZoomFlipAngular* pScene = new CCTransitionZoomFlipAngular(); pScene->initWithDuration(t, s, o); @@ -1027,8 +1050,12 @@ CCTransitionFade::~CCTransitionFade() { } +// CCTransitionFade * CCTransitionFade::transitionWithDuration(float duration, CCScene *scene, const ccColor3B& color) +// { +// return CCTransitionFade::create(duration, scene, color); +// } -CCTransitionFade * CCTransitionFade::transitionWithDuration(float duration, CCScene *scene, const ccColor3B& color) +CCTransitionFade * CCTransitionFade::create(float duration, CCScene *scene, const ccColor3B& color) { CCTransitionFade * pTransition = new CCTransitionFade(); pTransition->initWithDuration(duration, scene, color); @@ -1058,18 +1085,18 @@ void CCTransitionFade :: onEnter() { CCTransitionScene::onEnter(); - CCLayerColor* l = CCLayerColor::layerWithColor(m_tColor); + CCLayerColor* l = CCLayerColor::create(m_tColor); m_pInScene->setIsVisible(false); addChild(l, 2, kSceneFade); CCNode* f = getChildByTag(kSceneFade); - CCActionInterval* a = (CCActionInterval *)CCSequence::actions + CCActionInterval* a = (CCActionInterval *)CCSequence::create ( - CCFadeIn::actionWithDuration(m_fDuration/2), - CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::hideOutShowIn)),//CCCallFunc::actionWithTarget:self selector:@selector(hideOutShowIn)], - CCFadeOut::actionWithDuration(m_fDuration/2), - CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)), //:self selector:@selector(finish)], + CCFadeIn::create(m_fDuration/2), + CCCallFunc::create(this, callfunc_selector(CCTransitionScene::hideOutShowIn)),//CCCallFunc::create:self selector:@selector(hideOutShowIn)], + CCFadeOut::create(m_fDuration/2), + CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)), //:self selector:@selector(finish)], NULL ); f->runAction(a); @@ -1105,10 +1132,10 @@ void CCTransitionCrossFade::onEnter() // in which we are going to add our rendertextures ccColor4B color = {0,0,0,0}; CCSize size = CCDirector::sharedDirector()->getWinSize(); - CCLayerColor* layer = CCLayerColor::layerWithColor(color); + CCLayerColor* layer = CCLayerColor::create(color); // create the first render texture for inScene - CCRenderTexture* inTexture = CCRenderTexture::renderTextureWithWidthAndHeight((int)size.width, (int)size.height); + CCRenderTexture* inTexture = CCRenderTexture::create((int)size.width, (int)size.height); if (NULL == inTexture) { @@ -1125,7 +1152,7 @@ void CCTransitionCrossFade::onEnter() inTexture->end(); // create the second render texture for outScene - CCRenderTexture* outTexture = CCRenderTexture::renderTextureWithWidthAndHeight((int)size.width, (int)size.height); + CCRenderTexture* outTexture = CCRenderTexture::create((int)size.width, (int)size.height); outTexture->getSprite()->setAnchorPoint( ccp(0.5f,0.5f) ); outTexture->setPosition( ccp(size.width/2, size.height/2) ); outTexture->setAnchorPoint( ccp(0.5f,0.5f) ); @@ -1153,11 +1180,11 @@ void CCTransitionCrossFade::onEnter() outTexture->getSprite()->setOpacity(255); // create the blend action - CCAction* layerAction = CCSequence::actions + CCAction* layerAction = CCSequence::create ( - CCFadeTo::actionWithDuration(m_fDuration, 0), - CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::hideOutShowIn)), - CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)), + CCFadeTo::create(m_fDuration, 0), + CCCallFunc::create(this, callfunc_selector(CCTransitionScene::hideOutShowIn)), + CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)), NULL ); @@ -1177,21 +1204,13 @@ void CCTransitionCrossFade::onExit() CCTransitionScene::onExit(); } -CCTransitionCrossFade* CCTransitionCrossFade::transitionWithDuration(float d, CCScene* s) -{ - CCTransitionCrossFade* Transition = new CCTransitionCrossFade(); - Transition->initWithDuration(d, s); - Transition->autorelease(); - - return Transition; -} - // // TurnOffTilesTransition // CCTransitionTurnOffTiles::CCTransitionTurnOffTiles() { } + CCTransitionTurnOffTiles::~CCTransitionTurnOffTiles() { } @@ -1211,15 +1230,15 @@ void CCTransitionTurnOffTiles::onEnter() int x = (int)(12 * aspect); int y = 12; - CCTurnOffTiles* toff = CCTurnOffTiles::actionWithSize( ccg(x,y), m_fDuration); + CCTurnOffTiles* toff = CCTurnOffTiles::create( ccg(x,y), m_fDuration); CCActionInterval* action = easeActionWithAction(toff); m_pOutScene->runAction ( - CCSequence::actions + CCSequence::create ( action, - CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)), - CCStopGrid::action(), + CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)), + CCStopGrid::create(), NULL ) ); @@ -1231,8 +1250,6 @@ CCActionInterval* CCTransitionTurnOffTiles:: easeActionWithAction(CCActionInterv return action; } -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionTurnOffTiles) - // // SplitCols Transition // @@ -1250,21 +1267,21 @@ void CCTransitionSplitCols::onEnter() m_pInScene->setIsVisible(false); CCActionInterval* split = action(); - CCActionInterval* seq = (CCActionInterval*)CCSequence::actions + CCActionInterval* seq = (CCActionInterval*)CCSequence::create ( split, - CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::hideOutShowIn)), + CCCallFunc::create(this, callfunc_selector(CCTransitionScene::hideOutShowIn)), split->reverse(), NULL ); this->runAction ( - CCSequence::actions + CCSequence::create ( easeActionWithAction(seq), - CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)), - CCStopGrid::action(), + CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)), + CCStopGrid::create(), NULL ) ); @@ -1273,17 +1290,15 @@ void CCTransitionSplitCols::onEnter() CCActionInterval* CCTransitionSplitCols:: action() { - return CCSplitCols::actionWithCols(3, m_fDuration/2.0f); + return CCSplitCols::create(3, m_fDuration/2.0f); } CCActionInterval* CCTransitionSplitCols::easeActionWithAction(CCActionInterval * action) { - return CCEaseInOut::actionWithAction(action, 3.0f); + return CCEaseInOut::create(action, 3.0f); } -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionSplitCols) - // // SplitRows Transition @@ -1298,11 +1313,9 @@ CCTransitionSplitRows::~CCTransitionSplitRows() CCActionInterval* CCTransitionSplitRows::action() { - return CCSplitRows::actionWithRows(3, m_fDuration/2.0f); + return CCSplitRows::create(3, m_fDuration/2.0f); } -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionSplitRows) - // // FadeTR Transition // @@ -1332,11 +1345,11 @@ void CCTransitionFadeTR::onEnter() m_pOutScene->runAction ( - CCSequence::actions + CCSequence::create ( easeActionWithAction(action), - CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)), - CCStopGrid::action(), + CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)), + CCStopGrid::create(), NULL ) ); @@ -1345,7 +1358,7 @@ void CCTransitionFadeTR::onEnter() CCActionInterval* CCTransitionFadeTR::actionWithSize(const ccGridSize& size) { - return CCFadeOutTRTiles::actionWithSize(size, m_fDuration); + return CCFadeOutTRTiles::create(size, m_fDuration); } CCActionInterval* CCTransitionFadeTR:: easeActionWithAction(CCActionInterval* action) @@ -1353,8 +1366,6 @@ CCActionInterval* CCTransitionFadeTR:: easeActionWithAction(CCActionInterval* ac return action; } -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionFadeTR) - // // FadeBL Transition @@ -1369,11 +1380,9 @@ CCTransitionFadeBL::~CCTransitionFadeBL() CCActionInterval* CCTransitionFadeBL::actionWithSize(const ccGridSize& size) { - return CCFadeOutBLTiles::actionWithSize(size, m_fDuration); + return CCFadeOutBLTiles::create(size, m_fDuration); } -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionFadeBL) - // // FadeUp Transition // @@ -1386,11 +1395,9 @@ CCTransitionFadeUp::~CCTransitionFadeUp() CCActionInterval* CCTransitionFadeUp::actionWithSize(const ccGridSize& size) { - return CCFadeOutUpTiles::actionWithSize(size, m_fDuration); + return CCFadeOutUpTiles::create(size, m_fDuration); } -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionFadeUp) - // // FadeDown Transition // @@ -1403,9 +1410,7 @@ CCTransitionFadeDown::~CCTransitionFadeDown() CCActionInterval* CCTransitionFadeDown::actionWithSize(const ccGridSize& size) { - return CCFadeOutDownTiles::actionWithSize(size, m_fDuration); + return CCFadeOutDownTiles::create(size, m_fDuration); } -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionFadeDown) - NS_CC_END diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h index 14fb22b473..d166bcd29a 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h @@ -35,20 +35,47 @@ NS_CC_BEGIN //static creation function macro //c/c++ don't support object creation of using class name //so, all classes need creation method. -#define DECLEAR_TRANSITIONWITHDURATION(_Type)\ - static _Type* transitionWithDuration(float t, CCScene* scene); -#define IMPLEMENT_TRANSITIONWITHDURATION(_Type)\ - _Type* _Type::transitionWithDuration(float t, CCScene* scene)\ - {\ - _Type* pScene = new _Type();\ - if(pScene && pScene->initWithDuration(t, scene)){\ - pScene->autorelease();\ - return pScene;}\ - CC_SAFE_DELETE(pScene);\ - return NULL;\ -} +// @warning: This interface will be deprecated in future. +// #define DECLEAR_TRANSITIONWITHDURATION(_Type)\ +// static _Type* transitionWithDuration(float t, CCScene* scene); +// +// #define IMPLEMENT_TRANSITIONWITHDURATION(_Type)\ +// _Type* _Type::transitionWithDuration(float t, CCScene* scene)\ +// {\ +// _Type* pScene = new _Type();\ +// if(pScene && pScene->initWithDuration(t, scene)){\ +// pScene->autorelease();\ +// return pScene;}\ +// CC_SAFE_DELETE(pScene);\ +// return NULL;\ +// +#define OLD_TRANSITION_CREATE_FUNC(_Type) \ + static _Type* transitionWithDuration(float t, CCScene* scene) \ + { \ + _Type* pScene = new _Type(); \ + if(pScene && pScene->initWithDuration(t, scene)) \ + { \ + pScene->autorelease(); \ + return pScene; \ + } \ + CC_SAFE_DELETE(pScene); \ + return NULL; \ + } + +#define TRANSITION_CREATE_FUNC(_Type) \ + static _Type* create(float t, CCScene* scene) \ + { \ + _Type* pScene = new _Type(); \ + if(pScene && pScene->initWithDuration(t, scene)) \ + { \ + pScene->autorelease(); \ + return pScene; \ + } \ + CC_SAFE_DELETE(pScene); \ + return NULL; \ + } class CCActionInterval; class CCNode; @@ -99,8 +126,13 @@ public: virtual void onExit(); virtual void cleanup(); + /** creates a base transition with duration and incoming scene + @warning: This interface will be deprecated in future. + */ + //static CCTransitionScene * transitionWithDuration(float t, CCScene *scene); + /** creates a base transition with duration and incoming scene */ - static CCTransitionScene * transitionWithDuration(float t, CCScene *scene); + static CCTransitionScene * create(float t, CCScene *scene); /** initializes a transition with duration and incoming scene */ virtual bool initWithDuration(float t,CCScene* scene); @@ -130,8 +162,14 @@ public: CCTransitionSceneOriented(); virtual ~CCTransitionSceneOriented(); + /** creates a base transition with duration and incoming scene + @warning: This interface will be deprecated in future. + */ + // static CCTransitionSceneOriented * transitionWithDuration(float t,CCScene* scene, tOrientation orientation); + /** creates a base transition with duration and incoming scene */ - static CCTransitionSceneOriented * transitionWithDuration(float t,CCScene* scene, tOrientation orientation); + static CCTransitionSceneOriented * create(float t,CCScene* scene, tOrientation orientation); + /** initializes a transition with duration and incoming scene */ virtual bool initWithDuration(float t,CCScene* scene,tOrientation orientation); }; @@ -146,7 +184,8 @@ public: virtual ~CCTransitionRotoZoom(); virtual void onEnter(); - DECLEAR_TRANSITIONWITHDURATION(CCTransitionRotoZoom); + TRANSITION_CREATE_FUNC(CCTransitionRotoZoom); + OLD_TRANSITION_CREATE_FUNC(CCTransitionRotoZoom); }; /** @brief CCTransitionJumpZoom: @@ -159,7 +198,8 @@ public: virtual ~CCTransitionJumpZoom(); virtual void onEnter(); - DECLEAR_TRANSITIONWITHDURATION(CCTransitionJumpZoom); + TRANSITION_CREATE_FUNC(CCTransitionJumpZoom); + OLD_TRANSITION_CREATE_FUNC(CCTransitionJumpZoom); }; /** @brief CCTransitionMoveInL: @@ -179,7 +219,8 @@ public: virtual void onEnter(); - DECLEAR_TRANSITIONWITHDURATION(CCTransitionMoveInL); + TRANSITION_CREATE_FUNC(CCTransitionMoveInL); + OLD_TRANSITION_CREATE_FUNC(CCTransitionMoveInL); }; /** @brief CCTransitionMoveInR: @@ -192,7 +233,8 @@ public: virtual ~CCTransitionMoveInR(); virtual void initScenes(); - DECLEAR_TRANSITIONWITHDURATION(CCTransitionMoveInR); + TRANSITION_CREATE_FUNC(CCTransitionMoveInR); + OLD_TRANSITION_CREATE_FUNC(CCTransitionMoveInR); }; /** @brief CCTransitionMoveInT: @@ -205,7 +247,8 @@ public: virtual ~CCTransitionMoveInT(); virtual void initScenes(); - DECLEAR_TRANSITIONWITHDURATION(CCTransitionMoveInT); + TRANSITION_CREATE_FUNC(CCTransitionMoveInT); + OLD_TRANSITION_CREATE_FUNC(CCTransitionMoveInT); }; /** @brief CCTransitionMoveInB: @@ -218,7 +261,8 @@ public: virtual ~CCTransitionMoveInB(); virtual void initScenes(); - DECLEAR_TRANSITIONWITHDURATION(CCTransitionMoveInB); + TRANSITION_CREATE_FUNC(CCTransitionMoveInB); + OLD_TRANSITION_CREATE_FUNC(CCTransitionMoveInB); }; /** @brief CCTransitionSlideInL: @@ -239,7 +283,8 @@ public: virtual CCActionInterval* easeActionWithAction(CCActionInterval * action); - DECLEAR_TRANSITIONWITHDURATION(CCTransitionSlideInL); + TRANSITION_CREATE_FUNC(CCTransitionSlideInL); + OLD_TRANSITION_CREATE_FUNC(CCTransitionSlideInL); protected: virtual void sceneOrder(); }; @@ -258,7 +303,8 @@ public: /** returns the action that will be performed by the incomming and outgoing scene */ virtual CCActionInterval* action(void); - DECLEAR_TRANSITIONWITHDURATION(CCTransitionSlideInR); + TRANSITION_CREATE_FUNC(CCTransitionSlideInR); + OLD_TRANSITION_CREATE_FUNC(CCTransitionSlideInR); protected: virtual void sceneOrder(); }; @@ -277,7 +323,8 @@ public: /** returns the action that will be performed by the incomming and outgoing scene */ virtual CCActionInterval* action(void); - DECLEAR_TRANSITIONWITHDURATION(CCTransitionSlideInB); + TRANSITION_CREATE_FUNC(CCTransitionSlideInB); + OLD_TRANSITION_CREATE_FUNC(CCTransitionSlideInB); protected: virtual void sceneOrder(); }; @@ -296,7 +343,8 @@ public: /** returns the action that will be performed by the incomming and outgoing scene */ virtual CCActionInterval* action(void); - DECLEAR_TRANSITIONWITHDURATION(CCTransitionSlideInT); + TRANSITION_CREATE_FUNC(CCTransitionSlideInT); + OLD_TRANSITION_CREATE_FUNC(CCTransitionSlideInT); protected: virtual void sceneOrder(); }; @@ -313,7 +361,8 @@ public: virtual void onEnter(); virtual CCActionInterval* easeActionWithAction(CCActionInterval * action); - DECLEAR_TRANSITIONWITHDURATION(CCTransitionShrinkGrow); + TRANSITION_CREATE_FUNC(CCTransitionShrinkGrow); + OLD_TRANSITION_CREATE_FUNC(CCTransitionShrinkGrow); }; /** @brief CCTransitionFlipX: @@ -328,7 +377,9 @@ public: virtual void onEnter(); - static CCTransitionFlipX* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); + // @warning: This interface will be deprecated in future. + //static CCTransitionFlipX* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionFlipX* create(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; /** @brief CCTransitionFlipY: @@ -343,7 +394,9 @@ public: virtual void onEnter(); - static CCTransitionFlipY* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationUpOver); + //@warning: This interface will be deprecated in future. + //static CCTransitionFlipY* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationUpOver); + static CCTransitionFlipY* create(float t, CCScene* s, tOrientation o = kOrientationUpOver); }; /** @brief CCTransitionFlipAngular: @@ -358,7 +411,9 @@ public: virtual void onEnter(); - static CCTransitionFlipAngular* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); + //@warning: This interface will be deprecated in future. + //static CCTransitionFlipAngular* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionFlipAngular* create(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; /** @brief CCTransitionZoomFlipX: @@ -373,7 +428,9 @@ public: virtual void onEnter(); - static CCTransitionZoomFlipX* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); + //@warning: This interface will be deprecated in future. + //static CCTransitionZoomFlipX* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionZoomFlipX* create(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; /** @brief CCTransitionZoomFlipY: @@ -388,7 +445,9 @@ public: virtual void onEnter(); - static CCTransitionZoomFlipY* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationUpOver); + //@warning: This interface will be deprecated in future. + //static CCTransitionZoomFlipY* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationUpOver); + static CCTransitionZoomFlipY* create(float t, CCScene* s, tOrientation o = kOrientationUpOver); }; /** @brief CCTransitionZoomFlipAngular: @@ -403,7 +462,9 @@ public: virtual void onEnter(); - static CCTransitionZoomFlipAngular* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); + //@warning: This interface will be deprecated in future. + //static CCTransitionZoomFlipAngular* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionZoomFlipAngular* create(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; /** @brief CCTransitionFade: @@ -421,8 +482,15 @@ public: /** creates the transition with a duration and with an RGB color * Example: FadeTransition::transitionWithDuration(2, scene, ccc3(255,0,0); // red color + @warning: This interface will be deprecated in future. */ - static CCTransitionFade* transitionWithDuration(float duration,CCScene* scene, const ccColor3B& color = ccBLACK); + //static CCTransitionFade* transitionWithDuration(float duration,CCScene* scene, const ccColor3B& color = ccBLACK); + + /** creates the transition with a duration and with an RGB color + * Example: FadeTransition::create(2, scene, ccc3(255,0,0); // red color + */ + static CCTransitionFade* create(float duration,CCScene* scene, const ccColor3B& color = ccBLACK); + /** initializes the transition with a duration and with an RGB color */ virtual bool initWithDuration(float t, CCScene*scene ,const ccColor3B& color); @@ -447,7 +515,8 @@ public : virtual void onExit(); public: - DECLEAR_TRANSITIONWITHDURATION(CCTransitionCrossFade); + TRANSITION_CREATE_FUNC(CCTransitionCrossFade); + OLD_TRANSITION_CREATE_FUNC(CCTransitionCrossFade); }; /** @brief CCTransitionTurnOffTiles: @@ -463,7 +532,8 @@ public : virtual CCActionInterval * easeActionWithAction(CCActionInterval * action); public: - DECLEAR_TRANSITIONWITHDURATION(CCTransitionTurnOffTiles); + TRANSITION_CREATE_FUNC(CCTransitionTurnOffTiles); + OLD_TRANSITION_CREATE_FUNC(CCTransitionTurnOffTiles); protected: virtual void sceneOrder(); }; @@ -482,7 +552,8 @@ public: virtual CCActionInterval * easeActionWithAction(CCActionInterval * action); public: - DECLEAR_TRANSITIONWITHDURATION(CCTransitionSplitCols); + TRANSITION_CREATE_FUNC(CCTransitionSplitCols); + OLD_TRANSITION_CREATE_FUNC(CCTransitionSplitCols); }; /** @brief CCTransitionSplitRows: @@ -497,7 +568,8 @@ public: virtual CCActionInterval* action(void); public: - DECLEAR_TRANSITIONWITHDURATION(CCTransitionSplitRows) + TRANSITION_CREATE_FUNC(CCTransitionSplitRows) + OLD_TRANSITION_CREATE_FUNC(CCTransitionSplitRows) }; /** @brief CCTransitionFadeTR: @@ -513,7 +585,8 @@ public: virtual CCActionInterval* easeActionWithAction(CCActionInterval * action); public: - DECLEAR_TRANSITIONWITHDURATION(CCTransitionFadeTR) + TRANSITION_CREATE_FUNC(CCTransitionFadeTR) + OLD_TRANSITION_CREATE_FUNC(CCTransitionFadeTR) protected: virtual void sceneOrder(); @@ -530,7 +603,8 @@ public: virtual CCActionInterval* actionWithSize(const ccGridSize& size); public: - DECLEAR_TRANSITIONWITHDURATION(CCTransitionFadeBL) + TRANSITION_CREATE_FUNC(CCTransitionFadeBL) + OLD_TRANSITION_CREATE_FUNC(CCTransitionFadeBL) }; /** @brief CCTransitionFadeUp: @@ -544,7 +618,8 @@ public: virtual CCActionInterval* actionWithSize(const ccGridSize& size); public: - DECLEAR_TRANSITIONWITHDURATION(CCTransitionFadeUp) + TRANSITION_CREATE_FUNC(CCTransitionFadeUp) + OLD_TRANSITION_CREATE_FUNC(CCTransitionFadeUp) }; /** @brief CCTransitionFadeDown: @@ -558,7 +633,8 @@ public: virtual CCActionInterval* actionWithSize(const ccGridSize& size); public: - DECLEAR_TRANSITIONWITHDURATION(CCTransitionFadeDown) + TRANSITION_CREATE_FUNC(CCTransitionFadeDown) + OLD_TRANSITION_CREATE_FUNC(CCTransitionFadeDown) }; NS_CC_END diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp index ef1f5f6d8f..5fdfc140f8 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp @@ -40,8 +40,13 @@ CCTransitionPageTurn::~CCTransitionPageTurn() { } +// CCTransitionPageTurn * CCTransitionPageTurn::transitionWithDuration(float t, CCScene *scene, bool backwards) +// { +// return CCTransitionPageTurn::create(t,scene,backwards); +// } + /** creates a base transition with duration and incoming scene */ -CCTransitionPageTurn * CCTransitionPageTurn::transitionWithDuration(float t, CCScene *scene, bool backwards) +CCTransitionPageTurn * CCTransitionPageTurn::create(float t, CCScene *scene, bool backwards) { CCTransitionPageTurn * pTransition = new CCTransitionPageTurn(); pTransition->initWithDuration(t,scene,backwards); @@ -89,11 +94,11 @@ void CCTransitionPageTurn::onEnter() { m_pOutScene->runAction ( - CCSequence::actions + CCSequence::create ( action, - CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)), - CCStopGrid::action(), + CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)), + CCStopGrid::create(), NULL ) ); @@ -104,12 +109,12 @@ void CCTransitionPageTurn::onEnter() m_pInScene->setIsVisible(false); m_pInScene->runAction ( - CCSequence::actions + CCSequence::create ( - CCShow::action(), + CCShow::create(), action, - CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionScene::finish)), - CCStopGrid::action(), + CCCallFunc::create(this, callfunc_selector(CCTransitionScene::finish)), + CCStopGrid::create(), NULL ) ); @@ -122,15 +127,15 @@ CCActionInterval* CCTransitionPageTurn:: actionWithSize(const ccGridSize& vector if( m_bBack ) { // Get hold of the PageTurn3DAction - return CCReverseTime::actionWithAction + return CCReverseTime::create ( - CCPageTurn3D::actionWithSize(vector, m_fDuration) + CCPageTurn3D::create(vector, m_fDuration) ); } else { // Get hold of the PageTurn3DAction - return CCPageTurn3D::actionWithSize(vector, m_fDuration); + return CCPageTurn3D::create(vector, m_fDuration); } } diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h index 02fd2c19f2..ec2ae213a1 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h @@ -54,8 +54,16 @@ public: * Creates a base transition with duration and incoming scene. * If back is true then the effect is reversed to appear as if the incoming * scene is being turned from left over the outgoing scene. + @warning: This interface will be deprecated in future. */ - static CCTransitionPageTurn* transitionWithDuration(float t,CCScene* scene,bool backwards); + //static CCTransitionPageTurn* transitionWithDuration(float t,CCScene* scene,bool backwards); + + /** + * Creates a base transition with duration and incoming scene. + * If back is true then the effect is reversed to appear as if the incoming + * scene is being turned from left over the outgoing scene. + */ + static CCTransitionPageTurn* create(float t,CCScene* scene,bool backwards); /** * Creates a base transition with duration and incoming scene. diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp index 32096364f9..8afb04835b 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp @@ -40,8 +40,6 @@ enum { kCCSceneRadial = 0xc001, }; -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionProgress) - CCTransitionProgress::CCTransitionProgress() : to_(0.0f) , from_(0.0f) @@ -62,7 +60,7 @@ void CCTransitionProgress::onEnter() CCSize size = CCDirector::sharedDirector()->getWinSize(); // create the second render texture for outScene - CCRenderTexture *texture = CCRenderTexture::renderTextureWithWidthAndHeight((int)size.width, (int)size.height); + CCRenderTexture *texture = CCRenderTexture::create((int)size.width, (int)size.height); texture->getSprite()->setAnchorPoint(ccp(0.5f,0.5f)); texture->setPosition(ccp(size.width/2, size.height/2)); texture->setAnchorPoint(ccp(0.5f,0.5f)); @@ -83,9 +81,9 @@ void CCTransitionProgress::onEnter() CCProgressTimer *pNode = progressTimerNodeWithRenderTexture(texture); // create the blend action - CCActionInterval* layerAction = (CCActionInterval*)CCSequence::actions( - CCProgressFromTo::actionWithDuration(m_fDuration, from_, to_), - CCCallFunc::actionWithTarget(this, callfunc_selector(CCTransitionProgress::finish)), + CCActionInterval* layerAction = (CCActionInterval*)CCSequence::create( + CCProgressFromTo::create(m_fDuration, from_, to_), + CCCallFunc::create(this, callfunc_selector(CCTransitionProgress::finish)), NULL); // run the blend action pNode->runAction(layerAction); @@ -122,13 +120,12 @@ CCProgressTimer* CCTransitionProgress::progressTimerNodeWithRenderTexture(CCRend // CCTransitionProgressRadialCCW -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionProgressRadialCCW) CCProgressTimer* CCTransitionProgressRadialCCW::progressTimerNodeWithRenderTexture(CCRenderTexture* texture) { CCSize size = CCDirector::sharedDirector()->getWinSize(); - CCProgressTimer* pNode = CCProgressTimer::progressWithSprite(texture->getSprite()); + CCProgressTimer* pNode = CCProgressTimer::create(texture->getSprite()); // but it is flipped upside down so we flip the sprite pNode->getSprite()->setFlipY(true); @@ -145,13 +142,11 @@ CCProgressTimer* CCTransitionProgressRadialCCW::progressTimerNodeWithRenderTextu // CCTransitionProgressRadialCW -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionProgressRadialCW) - CCProgressTimer* CCTransitionProgressRadialCW::progressTimerNodeWithRenderTexture(CCRenderTexture* texture) { CCSize size = CCDirector::sharedDirector()->getWinSize(); - CCProgressTimer* pNode = CCProgressTimer::progressWithSprite(texture->getSprite()); + CCProgressTimer* pNode = CCProgressTimer::create(texture->getSprite()); // but it is flipped upside down so we flip the sprite pNode->getSprite()->setFlipY(true); @@ -168,13 +163,11 @@ CCProgressTimer* CCTransitionProgressRadialCW::progressTimerNodeWithRenderTextur // CCTransitionProgressHorizontal -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionProgressHorizontal) - CCProgressTimer* CCTransitionProgressHorizontal::progressTimerNodeWithRenderTexture(CCRenderTexture* texture) { CCSize size = CCDirector::sharedDirector()->getWinSize(); - CCProgressTimer* pNode = CCProgressTimer::progressWithSprite(texture->getSprite()); + CCProgressTimer* pNode = CCProgressTimer::create(texture->getSprite()); // but it is flipped upside down so we flip the sprite pNode->getSprite()->setFlipY(true); @@ -192,13 +185,11 @@ CCProgressTimer* CCTransitionProgressHorizontal::progressTimerNodeWithRenderText // CCTransitionProgressVertical -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionProgressVertical) - CCProgressTimer* CCTransitionProgressVertical::progressTimerNodeWithRenderTexture(CCRenderTexture* texture) { CCSize size = CCDirector::sharedDirector()->getWinSize(); - CCProgressTimer* pNode = CCProgressTimer::progressWithSprite(texture->getSprite()); + CCProgressTimer* pNode = CCProgressTimer::create(texture->getSprite()); // but it is flipped upside down so we flip the sprite pNode->getSprite()->setFlipY(true); @@ -217,8 +208,6 @@ CCProgressTimer* CCTransitionProgressVertical::progressTimerNodeWithRenderTextur // CCTransitionProgressInOut -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionProgressInOut) - void CCTransitionProgressInOut::sceneOrder() { m_bIsInSceneOnTop = false; @@ -235,7 +224,7 @@ CCProgressTimer* CCTransitionProgressInOut::progressTimerNodeWithRenderTexture(C { CCSize size = CCDirector::sharedDirector()->getWinSize(); - CCProgressTimer* pNode = CCProgressTimer::progressWithSprite(texture->getSprite()); + CCProgressTimer* pNode = CCProgressTimer::create(texture->getSprite()); // but it is flipped upside down so we flip the sprite pNode->getSprite()->setFlipY(true); @@ -254,13 +243,11 @@ CCProgressTimer* CCTransitionProgressInOut::progressTimerNodeWithRenderTexture(C // CCTransitionProgressOutIn -IMPLEMENT_TRANSITIONWITHDURATION(CCTransitionProgressOutIn) - CCProgressTimer* CCTransitionProgressOutIn::progressTimerNodeWithRenderTexture(CCRenderTexture* texture) { CCSize size = CCDirector::sharedDirector()->getWinSize(); - CCProgressTimer* pNode = CCProgressTimer::progressWithSprite(texture->getSprite()); + CCProgressTimer* pNode = CCProgressTimer::create(texture->getSprite()); // but it is flipped upside down so we flip the sprite pNode->getSprite()->setFlipY(true); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.h b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.h index 8f815e3cfa..060b11dbf8 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.h @@ -37,7 +37,7 @@ class CCRenderTexture; class CC_DLL CCTransitionProgress : public CCTransitionScene { public: - DECLEAR_TRANSITIONWITHDURATION(CCTransitionProgress) + TRANSITION_CREATE_FUNC(CCTransitionProgress) CCTransitionProgress(); virtual void onEnter(); @@ -58,7 +58,7 @@ protected: class CC_DLL CCTransitionProgressRadialCCW : public CCTransitionProgress { public: - DECLEAR_TRANSITIONWITHDURATION(CCTransitionProgressRadialCCW) + TRANSITION_CREATE_FUNC(CCTransitionProgressRadialCCW) protected: virtual CCProgressTimer* progressTimerNodeWithRenderTexture(CCRenderTexture* texture); @@ -71,7 +71,7 @@ protected: class CC_DLL CCTransitionProgressRadialCW : public CCTransitionProgress { public: - DECLEAR_TRANSITIONWITHDURATION(CCTransitionProgressRadialCW) + TRANSITION_CREATE_FUNC(CCTransitionProgressRadialCW) protected: virtual CCProgressTimer* progressTimerNodeWithRenderTexture(CCRenderTexture* texture); @@ -83,7 +83,7 @@ protected: class CC_DLL CCTransitionProgressHorizontal : public CCTransitionProgress { public: - DECLEAR_TRANSITIONWITHDURATION(CCTransitionProgressHorizontal) + TRANSITION_CREATE_FUNC(CCTransitionProgressHorizontal) protected: virtual CCProgressTimer* progressTimerNodeWithRenderTexture(CCRenderTexture* texture); @@ -92,7 +92,7 @@ protected: class CC_DLL CCTransitionProgressVertical : public CCTransitionProgress { public: - DECLEAR_TRANSITIONWITHDURATION(CCTransitionProgressVertical) + TRANSITION_CREATE_FUNC(CCTransitionProgressVertical) protected: virtual CCProgressTimer* progressTimerNodeWithRenderTexture(CCRenderTexture* texture); @@ -101,7 +101,7 @@ protected: class CC_DLL CCTransitionProgressInOut : public CCTransitionProgress { public: - DECLEAR_TRANSITIONWITHDURATION(CCTransitionProgressInOut) + TRANSITION_CREATE_FUNC(CCTransitionProgressInOut) protected: virtual CCProgressTimer* progressTimerNodeWithRenderTexture(CCRenderTexture* texture); virtual void sceneOrder(); @@ -111,7 +111,7 @@ protected: class CC_DLL CCTransitionProgressOutIn : public CCTransitionProgress { public: - DECLEAR_TRANSITIONWITHDURATION(CCTransitionProgressOutIn) + TRANSITION_CREATE_FUNC(CCTransitionProgressOutIn) protected: virtual CCProgressTimer* progressTimerNodeWithRenderTexture(CCRenderTexture* texture); diff --git a/cocos2dx/menu_nodes/CCMenu.cpp b/cocos2dx/menu_nodes/CCMenu.cpp index 9d07aced9e..4cabca4272 100644 --- a/cocos2dx/menu_nodes/CCMenu.cpp +++ b/cocos2dx/menu_nodes/CCMenu.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada http://www.cocos2d-x.org @@ -46,12 +46,33 @@ enum //CCMenu // -CCMenu* CCMenu::node() +// CCMenu* CCMenu::node() +// { +// return CCMenu::create(); +// } + +CCMenu* CCMenu::create() { - return menuWithItem(NULL); + return CCMenu::create(NULL, NULL); } -CCMenu * CCMenu::menuWithItems(CCMenuItem* item, ...) +// CCMenu * CCMenu::menuWithItems(CCMenuItem* item, ...) +// { +// va_list args; +// va_start(args,item); +// CCMenu *pRet = new CCMenu(); +// if (pRet && pRet->initWithItems(item, args)) +// { +// pRet->autorelease(); +// va_end(args); +// return pRet; +// } +// va_end(args); +// CC_SAFE_DELETE(pRet); +// return NULL; +// } + +CCMenu * CCMenu::create(CCMenuItem* item, ...) { va_list args; va_start(args,item); @@ -67,7 +88,12 @@ CCMenu * CCMenu::menuWithItems(CCMenuItem* item, ...) return NULL; } -CCMenu* CCMenu::menuWithArray(CCArray* pArrayOfItems) +// CCMenu* CCMenu::menuWithArray(CCArray* pArrayOfItems) +// { +// return CCMenu::create(pArrayOfItems); +// } + +CCMenu* CCMenu::create(CCArray* pArrayOfItems) { CCMenu *pRet = new CCMenu(); if (pRet && pRet->initWithArray(pArrayOfItems)) @@ -82,9 +108,14 @@ CCMenu* CCMenu::menuWithArray(CCArray* pArrayOfItems) return pRet; } -CCMenu* CCMenu::menuWithItem(CCMenuItem* item) +// CCMenu* CCMenu::menuWithItem(CCMenuItem* item) +// { +// return CCMenu::createWithItem(item); +// } + +CCMenu* CCMenu::createWithItem(CCMenuItem* item) { - return menuWithItems(item, NULL); + return CCMenu::create(item, NULL); } bool CCMenu::init() diff --git a/cocos2dx/menu_nodes/CCMenu.h b/cocos2dx/menu_nodes/CCMenu.h index 8dc7f71e0e..9aa9155a37 100644 --- a/cocos2dx/menu_nodes/CCMenu.h +++ b/cocos2dx/menu_nodes/CCMenu.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada http://www.cocos2d-x.org @@ -62,20 +62,42 @@ public: {} virtual ~CCMenu(){} + /** creates an empty CCMenu + @warning: This interface will be deprecated in future. + */ + //static CCMenu* node(); + + /** creates a CCMenu with it's items + @warning: This interface will be deprecated in future. + */ + //static CCMenu* menuWithItems(CCMenuItem* item, ...); + + /** creates a CCMenu with a NSArray of CCMenuItem objects + @warning: This interface will be deprecated in future. + */ + //static CCMenu* menuWithArray(CCArray* pArrayOfItems); + + /** creates a CCMenu with it's item, then use addChild() to add + * other items. It is used for script, it can't init with undetermined + * number of variables. + @warning: This interface will be deprecated in future. + */ + //static CCMenu* menuWithItem(CCMenuItem* item); + /** creates an empty CCMenu */ - static CCMenu* node(); + static CCMenu* create(); /** creates a CCMenu with it's items */ - static CCMenu* menuWithItems(CCMenuItem* item, ...); + static CCMenu* create(CCMenuItem* item, ...); /** creates a CCMenu with a NSArray of CCMenuItem objects */ - static CCMenu* menuWithArray(CCArray* pArrayOfItems); + static CCMenu* create(CCArray* pArrayOfItems); /** creates a CCMenu with it's item, then use addChild() to add * other items. It is used for script, it can't init with undetermined * number of variables. */ - static CCMenu* menuWithItem(CCMenuItem* item); + static CCMenu* createWithItem(CCMenuItem* item); /** initializes an empty CCMenu */ bool init(); diff --git a/cocos2dx/menu_nodes/CCMenuItem.cpp b/cocos2dx/menu_nodes/CCMenuItem.cpp index dadc273c80..b9b4bbf2ac 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.cpp +++ b/cocos2dx/menu_nodes/CCMenuItem.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2011 Ricardo Quesada Copyright (c) 2011 Zynga Inc. @@ -48,13 +48,19 @@ const unsigned int kDisableTag = 0x3; // // CCMenuItem // -CCMenuItem * CCMenuItem::itemWithTarget(CCObject *rec, SEL_MenuHandler selector) +// CCMenuItem * CCMenuItem::itemWithTarget(CCObject *rec, SEL_MenuHandler selector) +// { +// return CCMenuItem::create(rec, selector); +// } + +CCMenuItem * CCMenuItem::create(CCObject *rec, SEL_MenuHandler selector) { CCMenuItem *pRet = new CCMenuItem(); pRet->initWithTarget(rec, selector); pRet->autorelease(); return pRet; } + bool CCMenuItem::initWithTarget(CCObject *rec, SEL_MenuHandler selector) { setAnchorPoint(ccp(0.5f, 0.5f)); @@ -172,20 +178,33 @@ void CCMenuItemLabel::setLabel(CCNode* var) m_pLabel = var; } -CCMenuItemLabel * CCMenuItemLabel::itemWithLabel(CCNode*label, CCObject* target, SEL_MenuHandler selector) + +// CCMenuItemLabel * CCMenuItemLabel::itemWithLabel(CCNode*label, CCObject* target, SEL_MenuHandler selector) +// { +// return CCMenuItemLabel::create(label, target, selector); +// } + +CCMenuItemLabel * CCMenuItemLabel::create(CCNode*label, CCObject* target, SEL_MenuHandler selector) { CCMenuItemLabel *pRet = new CCMenuItemLabel(); pRet->initWithLabel(label, target, selector); pRet->autorelease(); return pRet; } -CCMenuItemLabel* CCMenuItemLabel::itemWithLabel(CCNode *label) + +// CCMenuItemLabel* CCMenuItemLabel::itemWithLabel(CCNode *label) +// { +// return CCMenuItemLabel::create(label); +// } + +CCMenuItemLabel* CCMenuItemLabel::create(CCNode *label) { CCMenuItemLabel *pRet = new CCMenuItemLabel(); pRet->initWithLabel(label, NULL, NULL); pRet->autorelease(); return pRet; } + bool CCMenuItemLabel::initWithLabel(CCNode* label, CCObject* target, SEL_MenuHandler selector) { CCMenuItem::initWithTarget(target, selector); @@ -195,14 +214,17 @@ bool CCMenuItemLabel::initWithLabel(CCNode* label, CCObject* target, SEL_MenuHan this->setLabel(label); return true; } + CCMenuItemLabel::~CCMenuItemLabel() { } + void CCMenuItemLabel::setString(const char * label) { dynamic_cast(m_pLabel)->setString(label); this->setContentSize(m_pLabel->getContentSize()); } + void CCMenuItemLabel::activate() { if(m_bIsEnabled) @@ -212,6 +234,7 @@ void CCMenuItemLabel::activate() CCMenuItem::activate(); } } + void CCMenuItemLabel::selected() { // subclass to change the default action @@ -229,11 +252,12 @@ void CCMenuItemLabel::selected() m_fOriginalScale = this->getScale(); } - CCAction *zoomAction = CCScaleTo::actionWithDuration(0.1f, m_fOriginalScale * 1.2f); + CCAction *zoomAction = CCScaleTo::create(0.1f, m_fOriginalScale * 1.2f); zoomAction->setTag(kZoomActionTag); this->runAction(zoomAction); } } + void CCMenuItemLabel::unselected() { // subclass to change the default action @@ -241,11 +265,12 @@ void CCMenuItemLabel::unselected() { CCMenuItem::unselected(); this->stopActionByTag(kZoomActionTag); - CCAction *zoomAction = CCScaleTo::actionWithDuration(0.1f, m_fOriginalScale); + CCAction *zoomAction = CCScaleTo::create(0.1f, m_fOriginalScale); zoomAction->setTag(kZoomActionTag); this->runAction(zoomAction); } } + void CCMenuItemLabel::setIsEnabled(bool enabled) { if( m_bIsEnabled != enabled ) @@ -262,18 +287,22 @@ void CCMenuItemLabel::setIsEnabled(bool enabled) } CCMenuItem::setIsEnabled(enabled); } + void CCMenuItemLabel::setOpacity(GLubyte opacity) { dynamic_cast(m_pLabel)->setOpacity(opacity); } + GLubyte CCMenuItemLabel::getOpacity() { return dynamic_cast(m_pLabel)->getOpacity(); } + void CCMenuItemLabel::setColor(const ccColor3B& color) { dynamic_cast(m_pLabel)->setColor(color); } + const ccColor3B& CCMenuItemLabel::getColor() { return dynamic_cast(m_pLabel)->getColor(); @@ -282,18 +311,29 @@ const ccColor3B& CCMenuItemLabel::getColor() // //CCMenuItemAtlasFont // -CCMenuItemAtlasFont * CCMenuItemAtlasFont::itemWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap) +// CCMenuItemAtlasFont * CCMenuItemAtlasFont::itemWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap) +// { +// return CCMenuItemAtlasFont::create(value, charMapFile, itemWidth, itemHeight, startCharMap); +// } + +CCMenuItemAtlasFont * CCMenuItemAtlasFont::create(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap) { - return CCMenuItemAtlasFont::itemWithString(value, charMapFile, itemWidth, itemHeight, startCharMap, NULL, NULL); + return CCMenuItemAtlasFont::create(value, charMapFile, itemWidth, itemHeight, startCharMap, NULL, NULL); } -CCMenuItemAtlasFont * CCMenuItemAtlasFont::itemWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, CCObject* target, SEL_MenuHandler selector) +// CCMenuItemAtlasFont * CCMenuItemAtlasFont::itemWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, CCObject* target, SEL_MenuHandler selector) +// { +// return CCMenuItemAtlasFont::create(value, charMapFile, itemWidth, itemHeight, startCharMap, target, selector); +// } + +CCMenuItemAtlasFont * CCMenuItemAtlasFont::create(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, CCObject* target, SEL_MenuHandler selector) { CCMenuItemAtlasFont *pRet = new CCMenuItemAtlasFont(); pRet->initWithString(value, charMapFile, itemWidth, itemHeight, startCharMap, target, selector); pRet->autorelease(); return pRet; } + bool CCMenuItemAtlasFont::initWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, CCObject* target, SEL_MenuHandler selector) { CCAssert( value != NULL && strlen(value) != 0, "value length must be greater than 0"); @@ -313,10 +353,12 @@ void CCMenuItemFont::setFontSize(unsigned int s) { _fontSize = s; } + unsigned int CCMenuItemFont::fontSize() { return _fontSize; } + void CCMenuItemFont::setFontName(const char *name) { if( _fontNameRelease ) @@ -326,24 +368,38 @@ void CCMenuItemFont::setFontName(const char *name) _fontName = name; _fontNameRelease = true; } + const char * CCMenuItemFont::fontName() { return _fontName.c_str(); } -CCMenuItemFont * CCMenuItemFont::itemWithString(const char *value, CCObject* target, SEL_MenuHandler selector) + +// CCMenuItemFont * CCMenuItemFont::itemWithString(const char *value, CCObject* target, SEL_MenuHandler selector) +// { +// return CCMenuItemFont::create(value, target, selector); +// } + +CCMenuItemFont * CCMenuItemFont::create(const char *value, CCObject* target, SEL_MenuHandler selector) { CCMenuItemFont *pRet = new CCMenuItemFont(); pRet->initWithString(value, target, selector); pRet->autorelease(); return pRet; } -CCMenuItemFont * CCMenuItemFont::itemWithString(const char *value) + +// CCMenuItemFont * CCMenuItemFont::itemWithString(const char *value) +// { +// return CCMenuItemFont::create(value); +// } + +CCMenuItemFont * CCMenuItemFont::create(const char *value) { CCMenuItemFont *pRet = new CCMenuItemFont(); pRet->initWithString(value, NULL, NULL); pRet->autorelease(); return pRet; } + bool CCMenuItemFont::initWithString(const char *value, CCObject* target, SEL_MenuHandler selector) { CCAssert( value != NULL && strlen(value) != 0, "Value length must be greater than 0"); @@ -351,7 +407,7 @@ bool CCMenuItemFont::initWithString(const char *value, CCObject* target, SEL_Men m_strFontName = _fontName; m_uFontSize = _fontSize; - CCLabelTTF *label = CCLabelTTF::labelWithString(value, m_strFontName.c_str(), (float)m_uFontSize); + CCLabelTTF *label = CCLabelTTF::create(value, m_strFontName.c_str(), (float)m_uFontSize); if (CCMenuItemLabel::initWithLabel(label, target, selector)) { // do something ? @@ -361,7 +417,7 @@ bool CCMenuItemFont::initWithString(const char *value, CCObject* target, SEL_Men void CCMenuItemFont::recreateLabel() { - CCLabelTTF *label = CCLabelTTF::labelWithString(dynamic_cast(m_pLabel)->getString(), + CCLabelTTF *label = CCLabelTTF::create(dynamic_cast(m_pLabel)->getString(), m_strFontName.c_str(), (float)m_uFontSize); this->setLabel(label); } @@ -395,6 +451,7 @@ CCNode * CCMenuItemSprite::getNormalImage() { return m_pNormalImage; } + void CCMenuItemSprite::setNormalImage(CCNode* pImage) { if (pImage != m_pNormalImage) @@ -415,10 +472,12 @@ void CCMenuItemSprite::setNormalImage(CCNode* pImage) this->updateImagesVisibility(); } } + CCNode * CCMenuItemSprite::getSelectedImage() { return m_pSelectedImage; } + void CCMenuItemSprite::setSelectedImage(CCNode* pImage) { if (pImage != m_pNormalImage) @@ -464,6 +523,7 @@ void CCMenuItemSprite::setDisabledImage(CCNode* pImage) this->updateImagesVisibility(); } } + // //CCMenuItemSprite - CCRGBAProtocol protocol // @@ -481,6 +541,7 @@ void CCMenuItemSprite::setOpacity(GLubyte opacity) dynamic_cast(m_pDisabledImage)->setOpacity(opacity); } } + void CCMenuItemSprite::setColor(const ccColor3B& color) { dynamic_cast(m_pNormalImage)->setColor(color); @@ -495,29 +556,50 @@ void CCMenuItemSprite::setColor(const ccColor3B& color) dynamic_cast(m_pDisabledImage)->setColor(color); } } + GLubyte CCMenuItemSprite::getOpacity() { return dynamic_cast(m_pNormalImage)->getOpacity(); } + const ccColor3B& CCMenuItemSprite::getColor() { return dynamic_cast(m_pNormalImage)->getColor(); } -CCMenuItemSprite * CCMenuItemSprite::itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite) + +// CCMenuItemSprite * CCMenuItemSprite::itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite) +// { +// return CCMenuItemSprite::create(normalSprite, selectedSprite, disabledSprite); +// } + +CCMenuItemSprite * CCMenuItemSprite::create(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite) { - return CCMenuItemSprite::itemWithNormalSprite(normalSprite, selectedSprite, disabledSprite, NULL, NULL); + return CCMenuItemSprite::create(normalSprite, selectedSprite, disabledSprite, NULL, NULL); } -CCMenuItemSprite * CCMenuItemSprite::itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCObject* target, SEL_MenuHandler selector) + +// CCMenuItemSprite * CCMenuItemSprite::itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCObject* target, SEL_MenuHandler selector) +// { +// return CCMenuItemSprite::create(normalSprite, selectedSprite, target, selector); +// } + +CCMenuItemSprite * CCMenuItemSprite::create(CCNode* normalSprite, CCNode* selectedSprite, CCObject* target, SEL_MenuHandler selector) { - return CCMenuItemSprite::itemWithNormalSprite(normalSprite, selectedSprite, NULL, target, selector); + return CCMenuItemSprite::create(normalSprite, selectedSprite, NULL, target, selector); } -CCMenuItemSprite * CCMenuItemSprite::itemWithNormalSprite(CCNode *normalSprite, CCNode *selectedSprite, CCNode *disabledSprite, CCObject *target, SEL_MenuHandler selector) + +// CCMenuItemSprite * CCMenuItemSprite::itemWithNormalSprite(CCNode *normalSprite, CCNode *selectedSprite, CCNode *disabledSprite, CCObject *target, SEL_MenuHandler selector) +// { +// return CCMenuItemSprite::create(normalSprite, selectedSprite, disabledSprite, target, selector); +// } + +CCMenuItemSprite * CCMenuItemSprite::create(CCNode *normalSprite, CCNode *selectedSprite, CCNode *disabledSprite, CCObject *target, SEL_MenuHandler selector) { CCMenuItemSprite *pRet = new CCMenuItemSprite(); pRet->initWithNormalSprite(normalSprite, selectedSprite, disabledSprite, target, selector); pRet->autorelease(); return pRet; } + bool CCMenuItemSprite::initWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, CCObject* target, SEL_MenuHandler selector) { CCAssert(normalSprite != NULL, ""); @@ -605,17 +687,32 @@ void CCMenuItemSprite::updateImagesVisibility() } } -CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, const char *selectedImage) +// CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, const char *selectedImage) +// { +// CCMenuItemImage::create(normalImage, selectedImage); +// } + +CCMenuItemImage * CCMenuItemImage::create(const char *normalImage, const char *selectedImage) { - return CCMenuItemImage::itemWithNormalImage(normalImage, selectedImage, NULL, NULL, NULL); + return CCMenuItemImage::create(normalImage, selectedImage, NULL, NULL, NULL); } -CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, const char *selectedImage, CCObject* target, SEL_MenuHandler selector) +// CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, const char *selectedImage, CCObject* target, SEL_MenuHandler selector) +// { +// return CCMenuItemImage::create(normalImage, selectedImage, target, selector); +// } + +CCMenuItemImage * CCMenuItemImage::create(const char *normalImage, const char *selectedImage, CCObject* target, SEL_MenuHandler selector) { - return CCMenuItemImage::itemWithNormalImage(normalImage, selectedImage, NULL, target, selector); + return CCMenuItemImage::create(normalImage, selectedImage, NULL, target, selector); } -CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector) +// CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector) +// { +// return CCMenuItemImage::create(normalImage, selectedImage, disabledImage, target, selector); +// } + +CCMenuItemImage * CCMenuItemImage::create(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector) { CCMenuItemImage *pRet = new CCMenuItemImage(); if (pRet && pRet->initWithNormalImage(normalImage, selectedImage, disabledImage, target, selector)) @@ -627,7 +724,12 @@ CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, return NULL; } -CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage) +// CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage) +// { +// return CCMenuItemImage::create(normalImage, selectedImage, disabledImage); +// } + +CCMenuItemImage * CCMenuItemImage::create(const char *normalImage, const char *selectedImage, const char *disabledImage) { CCMenuItemImage *pRet = new CCMenuItemImage(); if (pRet && pRet->initWithNormalImage(normalImage, selectedImage, disabledImage, NULL, NULL)) @@ -641,18 +743,18 @@ CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, bool CCMenuItemImage::initWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector) { - CCNode *normalSprite = CCSprite::spriteWithFile(normalImage); + CCNode *normalSprite = CCSprite::create(normalImage); CCNode *selectedSprite = NULL; CCNode *disabledSprite = NULL; if (selectedImage) { - selectedSprite = CCSprite::spriteWithFile(selectedImage); + selectedSprite = CCSprite::create(selectedImage); } if(disabledImage) { - disabledSprite = CCSprite::spriteWithFile(disabledImage); + disabledSprite = CCSprite::create(disabledImage); } return initWithNormalSprite(normalSprite, selectedSprite, disabledSprite, target, selector); } @@ -661,17 +763,17 @@ bool CCMenuItemImage::initWithNormalImage(const char *normalImage, const char *s // void CCMenuItemImage::setNormalSpriteFrame(CCSpriteFrame * frame) { - setNormalImage(CCSprite::spriteWithSpriteFrame(frame)); + setNormalImage(CCSprite::createWithSpriteFrame(frame)); } void CCMenuItemImage::setSelectedSpriteFrame(CCSpriteFrame * frame) { - setSelectedImage(CCSprite::spriteWithSpriteFrame(frame)); + setSelectedImage(CCSprite::createWithSpriteFrame(frame)); } void CCMenuItemImage::setDisabledSpriteFrame(CCSpriteFrame * frame) { - setDisabledImage(CCSprite::spriteWithSpriteFrame(frame)); + setDisabledImage(CCSprite::createWithSpriteFrame(frame)); } // @@ -688,7 +790,19 @@ CCArray* CCMenuItemToggle::getSubItems() { return m_pSubItems; } -CCMenuItemToggle * CCMenuItemToggle::itemWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...) + +// CCMenuItemToggle * CCMenuItemToggle::itemWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...) +// { +// va_list args; +// va_start(args, item); +// CCMenuItemToggle *pRet = new CCMenuItemToggle(); +// pRet->initWithTarget(target, selector, item, args); +// pRet->autorelease(); +// va_end(args); +// return pRet; +// } + +CCMenuItemToggle * CCMenuItemToggle::create(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...) { va_list args; va_start(args, item); @@ -717,7 +831,12 @@ bool CCMenuItemToggle::initWithTarget(CCObject* target, SEL_MenuHandler selector return true; } -CCMenuItemToggle* CCMenuItemToggle::itemWithItem(CCMenuItem *item) +// CCMenuItemToggle* CCMenuItemToggle::itemWithItem(CCMenuItem *item) +// { +// return CCMenuItemToggle::create(item); +// } + +CCMenuItemToggle* CCMenuItemToggle::create(CCMenuItem *item) { CCMenuItemToggle *pRet = new CCMenuItemToggle(); pRet->initWithItem(item); diff --git a/cocos2dx/menu_nodes/CCMenuItem.h b/cocos2dx/menu_nodes/CCMenuItem.h index d650d3d042..b04af1308e 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.h +++ b/cocos2dx/menu_nodes/CCMenuItem.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2011 Ricardo Quesada Copyright (c) 2011 Zynga Inc. @@ -59,8 +59,12 @@ public: , m_nScriptHandler(0) {} virtual ~CCMenuItem(); + /** Creates a CCMenuItem with a target/selector + @warning: This interface will be deprecated in future. + */ + //static CCMenuItem * itemWithTarget(CCObject *rec, SEL_MenuHandler selector); /** Creates a CCMenuItem with a target/selector */ - static CCMenuItem * itemWithTarget(CCObject *rec, SEL_MenuHandler selector); + static CCMenuItem * create(CCObject *rec, SEL_MenuHandler selector); /** Initializes a CCMenuItem with a target/selector */ bool initWithTarget(CCObject *rec, SEL_MenuHandler selector); /** Returns the outside box */ @@ -103,10 +107,20 @@ public: , m_fOriginalScale(0.0) {} virtual ~CCMenuItemLabel(); + /** creates a CCMenuItemLabel with a Label, target and selector + @warning: This interface will be deprecated in future. + */ + //static CCMenuItemLabel * itemWithLabel(CCNode*label, CCObject* target, SEL_MenuHandler selector); + /** creates a CCMenuItemLabel with a Label. Target and selector will be nill + @warning: This interface will be deprecated in future. + */ + //static CCMenuItemLabel* itemWithLabel(CCNode *label); + /** creates a CCMenuItemLabel with a Label, target and selector */ - static CCMenuItemLabel * itemWithLabel(CCNode*label, CCObject* target, SEL_MenuHandler selector); + static CCMenuItemLabel * create(CCNode*label, CCObject* target, SEL_MenuHandler selector); /** creates a CCMenuItemLabel with a Label. Target and selector will be nill */ - static CCMenuItemLabel* itemWithLabel(CCNode *label); + static CCMenuItemLabel* create(CCNode *label); + /** initializes a CCMenuItemLabel with a Label, target and selector */ bool initWithLabel(CCNode* label, CCObject* target, SEL_MenuHandler selector); /** sets a new string to the inner label */ @@ -139,10 +153,19 @@ class CC_DLL CCMenuItemAtlasFont : public CCMenuItemLabel public: CCMenuItemAtlasFont(){} virtual ~CCMenuItemAtlasFont(){} + /** creates a menu item from a string and atlas with a target/selector + @warning: This interface will be deprecated in future. + */ + //static CCMenuItemAtlasFont* itemWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap); + /** creates a menu item from a string and atlas. Use it with MenuItemToggle + @warning: This interface will be deprecated in future. + */ + //static CCMenuItemAtlasFont* itemWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, CCObject* target, SEL_MenuHandler selector); + /** creates a menu item from a string and atlas with a target/selector */ - static CCMenuItemAtlasFont* itemWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap); + static CCMenuItemAtlasFont* create(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap); /** creates a menu item from a string and atlas. Use it with MenuItemToggle */ - static CCMenuItemAtlasFont* itemWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, CCObject* target, SEL_MenuHandler selector); + static CCMenuItemAtlasFont* create(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, CCObject* target, SEL_MenuHandler selector); /** initializes a menu item from a string and atlas with a target/selector */ bool initWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, CCObject* target, SEL_MenuHandler selector); }; @@ -163,10 +186,20 @@ public: static void setFontName(const char *name); /** get the default font name */ static const char *fontName(); + /** creates a menu item from a string without target/selector. To be used with CCMenuItemToggle + @warning: This interface will be deprecated in future. + */ + //static CCMenuItemFont * itemWithString(const char *value); + /** creates a menu item from a string with a target/selector + @warning: This interface will be deprecated in future. + */ + //static CCMenuItemFont * itemWithString(const char *value, CCObject* target, SEL_MenuHandler selector); + /** creates a menu item from a string without target/selector. To be used with CCMenuItemToggle */ - static CCMenuItemFont * itemWithString(const char *value); + static CCMenuItemFont * create(const char *value); /** creates a menu item from a string with a target/selector */ - static CCMenuItemFont * itemWithString(const char *value, CCObject* target, SEL_MenuHandler selector); + static CCMenuItemFont * create(const char *value, CCObject* target, SEL_MenuHandler selector); + /** initializes a menu item from a string with a target/selector */ bool initWithString(const char *value, CCObject* target, SEL_MenuHandler selector); @@ -216,12 +249,26 @@ public: ,m_pSelectedImage(NULL) ,m_pDisabledImage(NULL) {} + /** creates a menu item with a normal, selected and disabled image + @warning: This interface will be deprecated in future. + */ + //static CCMenuItemSprite * itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite = NULL); + /** creates a menu item with a normal and selected image with target/selector + @warning: This interface will be deprecated in future. + */ + //static CCMenuItemSprite * itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCObject* target, SEL_MenuHandler selector); + /** creates a menu item with a normal,selected and disabled image with target/selector + @warning: This interface will be deprecated in future. + */ + //static CCMenuItemSprite * itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, CCObject* target, SEL_MenuHandler selector); + /** creates a menu item with a normal, selected and disabled image*/ - static CCMenuItemSprite * itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite = NULL); + static CCMenuItemSprite * create(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite = NULL); /** creates a menu item with a normal and selected image with target/selector */ - static CCMenuItemSprite * itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCObject* target, SEL_MenuHandler selector); + static CCMenuItemSprite * create(CCNode* normalSprite, CCNode* selectedSprite, CCObject* target, SEL_MenuHandler selector); /** creates a menu item with a normal,selected and disabled image with target/selector */ - static CCMenuItemSprite * itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, CCObject* target, SEL_MenuHandler selector); + static CCMenuItemSprite * create(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, CCObject* target, SEL_MenuHandler selector); + /** initializes a menu item with a normal, selected and disabled image with target/selector */ bool initWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, CCObject* target, SEL_MenuHandler selector); // super methods @@ -256,14 +303,32 @@ class CC_DLL CCMenuItemImage : public CCMenuItemSprite public: CCMenuItemImage(){} virtual ~CCMenuItemImage(){} + /** creates a menu item with a normal and selected image + @warning: This interface will be deprecated in future. + */ + //static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage); + /** creates a menu item with a normal,selected and disabled image + @warning: This interface will be deprecated in future. + */ + //static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage); + /** creates a menu item with a normal and selected image with target/selector + @warning: This interface will be deprecated in future. + */ + //static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage, CCObject* target, SEL_MenuHandler selector); + /** creates a menu item with a normal,selected and disabled image with target/selector + @warning: This interface will be deprecated in future. + */ + //static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector); + /** creates a menu item with a normal and selected image*/ - static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage); + static CCMenuItemImage* create(const char *normalImage, const char *selectedImage); /** creates a menu item with a normal,selected and disabled image*/ - static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage); + static CCMenuItemImage* create(const char *normalImage, const char *selectedImage, const char *disabledImage); /** creates a menu item with a normal and selected image with target/selector */ - static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage, CCObject* target, SEL_MenuHandler selector); + static CCMenuItemImage* create(const char *normalImage, const char *selectedImage, CCObject* target, SEL_MenuHandler selector); /** creates a menu item with a normal,selected and disabled image with target/selector */ - static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector); + static CCMenuItemImage* create(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector); + /** initializes a menu item with a normal, selected and disabled image with target/selector */ bool initWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector); /** sets the sprite frame for the normal image */ @@ -297,14 +362,27 @@ public: , m_pSubItems(NULL) {} virtual ~CCMenuItemToggle(); + + /** creates a menu item from a list of items with a target/selector + @warning: This interface will be deprecated in future. + */ + //static CCMenuItemToggle* itemWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...); + /** creates a menu item from a list of items with a target/selector */ - static CCMenuItemToggle* itemWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...); + static CCMenuItemToggle* create(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...); + /** initializes a menu item from a list of items with a target selector */ bool initWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, va_list args); // The follow methods offered to lua + /** creates a menu item with a item + @warning: This interface will be deprecated in future. + */ + //static CCMenuItemToggle* itemWithItem(CCMenuItem *item); + /** creates a menu item with a item */ - static CCMenuItemToggle* itemWithItem(CCMenuItem *item); + static CCMenuItemToggle* create(CCMenuItem *item); + /** initializes a menu item with a item */ bool initWithItem(CCMenuItem *item); /** add more menu item */ diff --git a/cocos2dx/misc_nodes/CCMotionStreak.cpp b/cocos2dx/misc_nodes/CCMotionStreak.cpp index 94c5b9ae27..aea81458c0 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.cpp +++ b/cocos2dx/misc_nodes/CCMotionStreak.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 ForzeField Studios S.L. http://www.cocos2d-x.org @@ -66,7 +66,12 @@ CCMotionStreak::~CCMotionStreak() CC_SAFE_FREE(m_pTexCoords); } -CCMotionStreak* CCMotionStreak::streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, const char* path) +// CCMotionStreak* CCMotionStreak::streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, const char* path) +// { +// return CCMotionStreak::create(fade, minSeg, stroke, color, path); +// } + +CCMotionStreak* CCMotionStreak::create(float fade, float minSeg, float stroke, ccColor3B color, const char* path) { CCMotionStreak *pRet = new CCMotionStreak(); if (pRet && pRet->initWithFade(fade, minSeg, stroke, color, path)) @@ -79,7 +84,12 @@ CCMotionStreak* CCMotionStreak::streakWithFade(float fade, float minSeg, float s return NULL; } -CCMotionStreak* CCMotionStreak::streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, CCTexture2D* texture) +// CCMotionStreak* CCMotionStreak::streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, CCTexture2D* texture) +// { +// return CCMotionStreak::create(fade, minSeg, stroke, color, texture); +// } + +CCMotionStreak* CCMotionStreak::create(float fade, float minSeg, float stroke, ccColor3B color, CCTexture2D* texture) { CCMotionStreak *pRet = new CCMotionStreak(); if (pRet && pRet->initWithFade(fade, minSeg, stroke, color, texture)) diff --git a/cocos2dx/misc_nodes/CCMotionStreak.h b/cocos2dx/misc_nodes/CCMotionStreak.h index 68ce88435d..4627e7545b 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.h +++ b/cocos2dx/misc_nodes/CCMotionStreak.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2011 ForzeField Studios S.L. http://www.cocos2d-x.org @@ -41,10 +41,19 @@ class CC_DLL CCMotionStreak : public CCNode, public CCTextureProtocol, public CC public: CCMotionStreak(); virtual ~CCMotionStreak(); + /** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture filename + @warning: This interface will be deprecated in future. + */ + //static CCMotionStreak* streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, const char* path); + /** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture + @warning: This interface will be deprecated in future. + */ + //static CCMotionStreak* streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, CCTexture2D* texture); + /** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture filename */ - static CCMotionStreak* streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, const char* path); + static CCMotionStreak* create(float fade, float minSeg, float stroke, ccColor3B color, const char* path); /** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture */ - static CCMotionStreak* streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, CCTexture2D* texture); + static CCMotionStreak* create(float fade, float minSeg, float stroke, ccColor3B color, CCTexture2D* texture); /** initializes a motion streak with fade in seconds, minimum segments, stroke's width, color and texture filename */ bool initWithFade(float fade, float minSeg, float stroke, ccColor3B color, const char* path); diff --git a/cocos2dx/misc_nodes/CCProgressTimer.cpp b/cocos2dx/misc_nodes/CCProgressTimer.cpp index 9eac755a38..958949e881 100644 --- a/cocos2dx/misc_nodes/CCProgressTimer.cpp +++ b/cocos2dx/misc_nodes/CCProgressTimer.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2010 Lam Pham http://www.cocos2d-x.org @@ -56,7 +56,12 @@ CCProgressTimer::CCProgressTimer() ,m_bReverseDirection(false) {} -CCProgressTimer* CCProgressTimer::progressWithSprite(CCSprite* sp) +// CCProgressTimer* CCProgressTimer::progressWithSprite(CCSprite* sp) +// { +// return CCProgressTimer::create(sp); +// } + +CCProgressTimer* CCProgressTimer::create(CCSprite* sp) { CCProgressTimer *pProgressTimer = new CCProgressTimer(); if (pProgressTimer->initWithSprite(sp)) diff --git a/cocos2dx/misc_nodes/CCProgressTimer.h b/cocos2dx/misc_nodes/CCProgressTimer.h index ab2127ba3d..1bc8fd5b7f 100644 --- a/cocos2dx/misc_nodes/CCProgressTimer.h +++ b/cocos2dx/misc_nodes/CCProgressTimer.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2010 Lam Pham http://www.cocos2d-x.org @@ -79,9 +79,12 @@ public: virtual bool getIsOpacityModifyRGB(void); public: + /** Creates a progress timer with the sprite as the shape the timer goes through + @warning: This interface will be deprecated in future. + */ + //static CCProgressTimer* progressWithSprite(CCSprite* sp); /** Creates a progress timer with the sprite as the shape the timer goes through */ - static CCProgressTimer* progressWithSprite(CCSprite* sp); - + static CCProgressTimer* create(CCSprite* sp); protected: ccTex2F textureCoordFromAlphaPoint(CCPoint alpha); ccVertex2F vertexFromAlphaPoint(CCPoint alpha); diff --git a/cocos2dx/misc_nodes/CCRenderTexture.cpp b/cocos2dx/misc_nodes/CCRenderTexture.cpp index 01e57622ae..fc42028490 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.cpp +++ b/cocos2dx/misc_nodes/CCRenderTexture.cpp @@ -67,12 +67,18 @@ CCSprite * CCRenderTexture::getSprite() { return m_pSprite; } + void CCRenderTexture::setSprite(CCSprite* var) { m_pSprite = var; } -CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat) +// CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat) +// { +// return CCRenderTexture::create(w, h, eFormat); +// } + +CCRenderTexture * CCRenderTexture::create(int w, int h, CCTexture2DPixelFormat eFormat) { CCRenderTexture *pRet = new CCRenderTexture(); @@ -85,7 +91,12 @@ CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w, int h, return NULL; } -CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat) +// CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat) +// { +// return CCRenderTexture::create(w, h, eFormat, uDepthStencilFormat); +// } + +CCRenderTexture * CCRenderTexture::create(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat) { CCRenderTexture *pRet = new CCRenderTexture(); @@ -98,7 +109,12 @@ CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w ,int h, return NULL; } -CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w, int h) +// CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w, int h) +// { +// return CCRenderTexture::create(w, h); +// } + +CCRenderTexture * CCRenderTexture::create(int w, int h) { CCRenderTexture *pRet = new CCRenderTexture(); @@ -181,7 +197,7 @@ bool CCRenderTexture::initWithWidthAndHeight(int w, int h, CCTexture2DPixelForma m_pTexture->setAliasTexParameters(); - m_pSprite = CCSprite::spriteWithTexture(m_pTexture); + m_pSprite = CCSprite::createWithTexture(m_pTexture); m_pTexture->release(); m_pSprite->setScaleY(-1); diff --git a/cocos2dx/misc_nodes/CCRenderTexture.h b/cocos2dx/misc_nodes/CCRenderTexture.h index b04b0832b1..1a1a4851a8 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.h +++ b/cocos2dx/misc_nodes/CCRenderTexture.h @@ -59,14 +59,29 @@ public: CCRenderTexture(); virtual ~CCRenderTexture(); + /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format + @warning: This interface will be deprecated in future. + */ + //static CCRenderTexture * renderTextureWithWidthAndHeight(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat); + + /** creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid + @warning: This interface will be deprecated in future. + */ + //static CCRenderTexture * renderTextureWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat); + + /** creates a RenderTexture object with width and height in Points, pixel format is RGBA8888 + @warning: This interface will be deprecated in future. + */ + //static CCRenderTexture * renderTextureWithWidthAndHeight(int w, int h); + /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format*/ - static CCRenderTexture * renderTextureWithWidthAndHeight(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat); + static CCRenderTexture * create(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat); /** creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid */ - static CCRenderTexture * renderTextureWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat); + static CCRenderTexture * create(int w, int h, CCTexture2DPixelFormat eFormat); /** creates a RenderTexture object with width and height in Points, pixel format is RGBA8888 */ - static CCRenderTexture * renderTextureWithWidthAndHeight(int w, int h); + static CCRenderTexture * create(int w, int h); /** initializes a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid */ bool initWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat); diff --git a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp index ee560604ab..b4b5fc4e24 100644 --- a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp +++ b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2011 cocos2d-x.org + * Copyright (c) 2010-2012 cocos2d-x.org * Copyright (C) 2009 Matt Oswald * Copyright (c) 2009-2010 Ricardo Quesada * Copyright (c) 2011 Zynga Inc. @@ -45,8 +45,6 @@ NS_CC_BEGIN -#define kCCParticleDefaultCapacity 500 - CCParticleBatchNode::CCParticleBatchNode() : m_pTextureAtlas(NULL) { @@ -60,19 +58,12 @@ CCParticleBatchNode::~CCParticleBatchNode() /* * creation with CCTexture2D */ -CCParticleBatchNode* CCParticleBatchNode::batchNodeWithTexture(CCTexture2D * tex) -{ - CCParticleBatchNode * p = new CCParticleBatchNode(); - if( p && p->initWithTexture(tex, kCCParticleDefaultCapacity)) - { - p->autorelease(); - return p; - } - CC_SAFE_DELETE(p); - return NULL; -} +// CCParticleBatchNode* CCParticleBatchNode::batchNodeWithTexture(CCTexture2D *tex, unsigned int capacity/* = kCCParticleDefaultCapacity*/) +// { +// return CCParticleBatchNode::createWithTexture(tex, capacity); +// } -CCParticleBatchNode* CCParticleBatchNode::batchNodeWithTexture(CCTexture2D *tex, unsigned int capacity) +CCParticleBatchNode* CCParticleBatchNode::createWithTexture(CCTexture2D *tex, unsigned int capacity/* = kCCParticleDefaultCapacity*/) { CCParticleBatchNode * p = new CCParticleBatchNode(); if( p && p->initWithTexture(tex, capacity)) @@ -87,7 +78,12 @@ CCParticleBatchNode* CCParticleBatchNode::batchNodeWithTexture(CCTexture2D *tex, /* * creation with File Image */ -CCParticleBatchNode* CCParticleBatchNode::batchNodeWithFile(const char* imageFile, unsigned int capacity) +// CCParticleBatchNode* CCParticleBatchNode::batchNodeWithFile(const char* imageFile, unsigned int capacity/* = kCCParticleDefaultCapacity*/) +// { +// return CCParticleBatchNode::create(imageFile, capacity); +// } + +CCParticleBatchNode* CCParticleBatchNode::create(const char* imageFile, unsigned int capacity/* = kCCParticleDefaultCapacity*/) { CCParticleBatchNode * p = new CCParticleBatchNode(); if( p && p->initWithFile(imageFile, capacity)) @@ -99,18 +95,6 @@ CCParticleBatchNode* CCParticleBatchNode::batchNodeWithFile(const char* imageFil return NULL; } -CCParticleBatchNode* CCParticleBatchNode::batchNodeWithFile(const char* imageFile) -{ - CCParticleBatchNode * p = new CCParticleBatchNode(); - if( p && p->initWithFile(imageFile, kCCParticleDefaultCapacity)) - { - p->autorelease(); - return p; - } - CC_SAFE_DELETE(p); - return NULL; -} - /* * init with CCTexture2D */ diff --git a/cocos2dx/particle_nodes/CCParticleBatchNode.h b/cocos2dx/particle_nodes/CCParticleBatchNode.h index f54a478a65..c2d175553e 100644 --- a/cocos2dx/particle_nodes/CCParticleBatchNode.h +++ b/cocos2dx/particle_nodes/CCParticleBatchNode.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010-2011 cocos2d-x.org + * Copyright (c) 2010-2012 cocos2d-x.org * Copyright (C) 2009 Matt Oswald * Copyright (c) 2009-2010 Ricardo Quesada * Copyright (c) 2011 Zynga Inc. @@ -38,6 +38,8 @@ class CCTexture2D; class CCTextureAtlas; class CCParticleSystem; +#define kCCParticleDefaultCapacity 500 + /** CCParticleBatchNode is like a batch node: if it contains children, it will draw them in 1 single OpenGL call * (often known as "batch draw"). * @@ -62,17 +64,22 @@ class CC_DLL CCParticleBatchNode : public CCNode, public CCTextureProtocol public: CCParticleBatchNode(); virtual ~CCParticleBatchNode(); - /** initializes the particle system with CCTexture2D, a default capacity of 500 */ - static CCParticleBatchNode* batchNodeWithTexture(CCTexture2D * tex); - /** initializes the particle system with the name of a file on disk (for a list of supported formats look at the CCTexture2D class), a default capacity of 500 particles */ - static CCParticleBatchNode* batchNodeWithFile(const char* imageFile); + /** initializes the particle system with CCTexture2D, a capacity of particles, which particle system to use + @warning: This interface will be deprecated in future. + */ + //static CCParticleBatchNode* batchNodeWithTexture(CCTexture2D *tex, unsigned int capacity = kCCParticleDefaultCapacity); + + /** initializes the particle system with the name of a file on disk (for a list of supported formats look at the CCTexture2D class), a capacity of particles + @warning: This interface will be deprecated in future. + */ + //static CCParticleBatchNode* batchNodeWithFile(const char* fileImage, unsigned int capacity = kCCParticleDefaultCapacity); /** initializes the particle system with CCTexture2D, a capacity of particles, which particle system to use */ - static CCParticleBatchNode* batchNodeWithTexture(CCTexture2D *tex, unsigned int capacity); + static CCParticleBatchNode* createWithTexture(CCTexture2D *tex, unsigned int capacity = kCCParticleDefaultCapacity); /** initializes the particle system with the name of a file on disk (for a list of supported formats look at the CCTexture2D class), a capacity of particles */ - static CCParticleBatchNode* batchNodeWithFile(const char* fileImage, unsigned int capacity); + static CCParticleBatchNode* create(const char* fileImage, unsigned int capacity = kCCParticleDefaultCapacity); /** initializes the particle system with CCTexture2D, a capacity of particles */ bool initWithTexture(CCTexture2D *tex, unsigned int capacity); diff --git a/cocos2dx/particle_nodes/CCParticleExamples.h b/cocos2dx/particle_nodes/CCParticleExamples.h index 7ecee40876..ab8cfded24 100644 --- a/cocos2dx/particle_nodes/CCParticleExamples.h +++ b/cocos2dx/particle_nodes/CCParticleExamples.h @@ -39,7 +39,12 @@ public: virtual ~CCParticleFire(){} bool init(){ return initWithTotalParticles(250); } virtual bool initWithTotalParticles(unsigned int numberOfParticles); - static CCParticleFire * node() +// static CCParticleFire * node() +// { +// return create(); +// } + + static CCParticleFire * create() { CCParticleFire *pRet = new CCParticleFire(); if (pRet->init()) @@ -60,7 +65,12 @@ public: virtual ~CCParticleFireworks(){} bool init(){ return initWithTotalParticles(1500); } virtual bool initWithTotalParticles(unsigned int numberOfParticles); - static CCParticleFireworks * node() +// static CCParticleFireworks * node() +// { +// return create(); +// } + + static CCParticleFireworks * create() { CCParticleFireworks *pRet = new CCParticleFireworks(); if (pRet->init()) @@ -81,7 +91,11 @@ public: virtual ~CCParticleSun(){} bool init(){ return initWithTotalParticles(350); } virtual bool initWithTotalParticles(unsigned int numberOfParticles); - static CCParticleSun * node() +// static CCParticleSun * node() +// { +// return create(); +// } + static CCParticleSun * create() { CCParticleSun *pRet = new CCParticleSun(); if (pRet->init()) @@ -102,7 +116,12 @@ public: virtual ~CCParticleGalaxy(){} bool init(){ return initWithTotalParticles(200); } virtual bool initWithTotalParticles(unsigned int numberOfParticles); - static CCParticleGalaxy * node() +// static CCParticleGalaxy * node() +// { +// return create(); +// } + + static CCParticleGalaxy * create() { CCParticleGalaxy *pRet = new CCParticleGalaxy(); if (pRet->init()) @@ -123,7 +142,12 @@ public: virtual ~CCParticleFlower(){} bool init(){ return initWithTotalParticles(250); } virtual bool initWithTotalParticles(unsigned int numberOfParticles); - static CCParticleFlower * node() +// static CCParticleFlower * node() +// { +// return create(); +// } + + static CCParticleFlower * create() { CCParticleFlower *pRet = new CCParticleFlower(); if (pRet->init()) @@ -144,7 +168,11 @@ public: virtual ~CCParticleMeteor(){} bool init(){ return initWithTotalParticles(150); } virtual bool initWithTotalParticles(unsigned int numberOfParticles); - static CCParticleMeteor * node() +// static CCParticleMeteor * node() +// { +// return create(); +// } + static CCParticleMeteor * create() { CCParticleMeteor *pRet = new CCParticleMeteor(); if (pRet->init()) @@ -165,7 +193,11 @@ public: virtual ~CCParticleSpiral(){} bool init(){ return initWithTotalParticles(500); } virtual bool initWithTotalParticles(unsigned int numberOfParticles); - static CCParticleSpiral * node() +// static CCParticleSpiral * node() +// { +// return create(); +// } + static CCParticleSpiral * create() { CCParticleSpiral *pRet = new CCParticleSpiral(); if (pRet->init()) @@ -186,7 +218,11 @@ public: virtual ~CCParticleExplosion(){} bool init(){ return initWithTotalParticles(700); } virtual bool initWithTotalParticles(unsigned int numberOfParticles); - static CCParticleExplosion * node() +// static CCParticleExplosion * node() +// { +// return create(); +// } + static CCParticleExplosion * create() { CCParticleExplosion *pRet = new CCParticleExplosion(); if (pRet->init()) @@ -207,7 +243,11 @@ public: virtual ~CCParticleSmoke(){} bool init(){ return initWithTotalParticles(200); } virtual bool initWithTotalParticles(unsigned int numberOfParticles); - static CCParticleSmoke * node() +// static CCParticleSmoke * node() +// { +// return create(); +// } + static CCParticleSmoke * create() { CCParticleSmoke *pRet = new CCParticleSmoke(); if (pRet->init()) @@ -228,7 +268,12 @@ public: virtual ~CCParticleSnow(){} bool init(){ return initWithTotalParticles(700); } virtual bool initWithTotalParticles(unsigned int numberOfParticles); - static CCParticleSnow * node() +// static CCParticleSnow * node() +// { +// return create(); +// } + + static CCParticleSnow * create() { CCParticleSnow *pRet = new CCParticleSnow(); if (pRet->init()) @@ -249,7 +294,11 @@ public: virtual ~CCParticleRain(){} bool init(){ return initWithTotalParticles(1000); } virtual bool initWithTotalParticles(unsigned int numberOfParticles); - static CCParticleRain * node() +// static CCParticleRain * node() +// { +// return create(); +// } + static CCParticleRain * create() { CCParticleRain *pRet = new CCParticleRain(); if (pRet->init()) diff --git a/cocos2dx/particle_nodes/CCParticleSystem.cpp b/cocos2dx/particle_nodes/CCParticleSystem.cpp index b307d02596..9ecd15da76 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystem.cpp @@ -130,7 +130,12 @@ CCParticleSystem::CCParticleSystem() m_tBlendFunc.dst = CC_BLEND_DST; } // implementation CCParticleSystem -CCParticleSystem * CCParticleSystem::particleWithFile(const char *plistFile) +// CCParticleSystem * CCParticleSystem::particleWithFile(const char *plistFile) +// { +// return CCParticleSystem::create(plistFile); +// } + +CCParticleSystem * CCParticleSystem::create(const char *plistFile) { CCParticleSystem *pRet = new CCParticleSystem(); if (pRet && pRet->initWithFile(plistFile)) diff --git a/cocos2dx/particle_nodes/CCParticleSystem.h b/cocos2dx/particle_nodes/CCParticleSystem.h index 60073ffafa..d469b59837 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.h +++ b/cocos2dx/particle_nodes/CCParticleSystem.h @@ -356,9 +356,17 @@ public: /** creates an initializes a CCParticleSystem from a plist file. This plist files can be creted manually or with Particle Designer: http://particledesigner.71squared.com/ + @warning: This interface will be deprecated in future. @since v0.99.3 */ - static CCParticleSystem * particleWithFile(const char *plistFile); + //static CCParticleSystem * particleWithFile(const char *plistFile); + + /** creates an initializes a CCParticleSystem from a plist file. + This plist files can be creted manually or with Particle Designer: + http://particledesigner.71squared.com/ + @since v2.0 + */ + static CCParticleSystem * create(const char *plistFile); /** initializes a CCParticleSystem*/ bool init(); diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp index 306f1c336d..2fc1ec2526 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp @@ -103,7 +103,12 @@ CCParticleSystemQuad::~CCParticleSystemQuad() } // implementation CCParticleSystemQuad -CCParticleSystemQuad * CCParticleSystemQuad::particleWithFile(const char *plistFile) +// CCParticleSystemQuad * CCParticleSystemQuad::particleWithFile(const char *plistFile) +// { +// return CCParticleSystemQuad::create(plistFile); +// } + +CCParticleSystemQuad * CCParticleSystemQuad::create(const char *plistFile) { CCParticleSystemQuad *pRet = new CCParticleSystemQuad(); if (pRet && pRet->initWithFile(plistFile)) diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.h b/cocos2dx/particle_nodes/CCParticleSystemQuad.h index c170d619c6..1011f47936 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.h +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.h @@ -63,8 +63,14 @@ public: /** creates an initializes a CCParticleSystemQuad from a plist file. This plist files can be creted manually or with Particle Designer: + @warning: This interface will be deprecated in future. */ - static CCParticleSystemQuad * particleWithFile(const char *plistFile); + //static CCParticleSystemQuad * particleWithFile(const char *plistFile); + + /** creates an initializes a CCParticleSystemQuad from a plist file. + This plist files can be creted manually or with Particle Designer: + */ + static CCParticleSystemQuad * create(const char *plistFile); /** initialices the indices for the vertices*/ void setupIndices(); diff --git a/cocos2dx/sprite_nodes/CCAnimation.cpp b/cocos2dx/sprite_nodes/CCAnimation.cpp index 22aea11492..0bc2681b17 100644 --- a/cocos2dx/sprite_nodes/CCAnimation.cpp +++ b/cocos2dx/sprite_nodes/CCAnimation.cpp @@ -81,7 +81,12 @@ CCObject* CCAnimationFrame::copyWithZone(CCZone* pZone) // implementation of CCAnimation -CCAnimation* CCAnimation::animation(void) +// CCAnimation* CCAnimation::animation(void) +// { +// return CCAnimation::create(); +// } + +CCAnimation* CCAnimation::create(void) { CCAnimation *pAnimation = new CCAnimation(); pAnimation->init(); @@ -90,16 +95,12 @@ CCAnimation* CCAnimation::animation(void) return pAnimation; } -CCAnimation* CCAnimation::animationWithSpriteFrames(CCArray *frames) -{ - CCAnimation *pAnimation = new CCAnimation(); - pAnimation->initWithSpriteFrames(frames); - pAnimation->autorelease(); +// CCAnimation* CCAnimation::animationWithSpriteFrames(CCArray *frames, float delay/* = 0.0f*/) +// { +// return CCAnimation::createWithSpriteFrames(frames, delay); +// } - return pAnimation; -} - -CCAnimation* CCAnimation::animationWithSpriteFrames(CCArray *frames, float delay) +CCAnimation* CCAnimation::createWithSpriteFrames(CCArray *frames, float delay/* = 0.0f*/) { CCAnimation *pAnimation = new CCAnimation(); pAnimation->initWithSpriteFrames(frames, delay); @@ -108,10 +109,15 @@ CCAnimation* CCAnimation::animationWithSpriteFrames(CCArray *frames, float delay return pAnimation; } -CCAnimation* CCAnimation::animationWithAnimationFrames(CCArray* arrayOfSpriteFrameNames, float delayPerUnit, unsigned int loops) +// CCAnimation* CCAnimation::animationWithAnimationFrames(CCArray* arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops) +// { +// return CCAnimation::createWithAnimationFrames(arrayOfAnimationFrameNames, delayPerUnit, loops); +// } + +CCAnimation* CCAnimation::createWithAnimationFrames(CCArray* arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops) { CCAnimation *pAnimation = new CCAnimation(); - pAnimation->initWithAnimationFrames(arrayOfSpriteFrameNames, delayPerUnit, loops); + pAnimation->initWithAnimationFrames(arrayOfAnimationFrameNames, delayPerUnit, loops); pAnimation->autorelease(); return pAnimation; } @@ -121,12 +127,7 @@ bool CCAnimation::init() return initWithSpriteFrames(NULL, 0.0f); } -bool CCAnimation::initWithSpriteFrames(CCArray* pFrames) -{ - return initWithSpriteFrames(pFrames, 0.0f); -} - -bool CCAnimation::initWithSpriteFrames(CCArray *pFrames, float delay) +bool CCAnimation::initWithSpriteFrames(CCArray *pFrames, float delay/* = 0.0f*/) { CCARRAY_VERIFY_TYPE(pFrames, CCSpriteFrame*); @@ -204,13 +205,13 @@ void CCAnimation::addSpriteFrameWithFileName(const char *pszFileName) CCTexture2D *pTexture = CCTextureCache::sharedTextureCache()->addImage(pszFileName); CCRect rect = CCRectZero; rect.size = pTexture->getContentSize(); - CCSpriteFrame *pFrame = CCSpriteFrame::frameWithTexture(pTexture, rect); + CCSpriteFrame *pFrame = CCSpriteFrame::create(pTexture, rect); addSpriteFrame(pFrame); } void CCAnimation::addSpriteFrameWithTexture(CCTexture2D *pobTexture, const CCRect& rect) { - CCSpriteFrame *pFrame = CCSpriteFrame::frameWithTexture(pobTexture, rect); + CCSpriteFrame *pFrame = CCSpriteFrame::create(pobTexture, rect); addSpriteFrame(pFrame); } diff --git a/cocos2dx/sprite_nodes/CCAnimation.h b/cocos2dx/sprite_nodes/CCAnimation.h index a40675f408..1999826eeb 100644 --- a/cocos2dx/sprite_nodes/CCAnimation.h +++ b/cocos2dx/sprite_nodes/CCAnimation.h @@ -84,26 +84,39 @@ public: ~CCAnimation(void); public: /** Creates an animation + @warning: This interface will be deprecated in future. @since v0.99.5 */ - static CCAnimation* animation(void); + //static CCAnimation* animation(void); - /** Creates an animation with an array of CCSpriteFrame. - The frames will be created with one "delay unit". + /* Creates an animation with an array of CCSpriteFrame and a delay between frames in seconds. + The frames will be added with one "delay unit". + @warning: This interface will be deprecated in future. + @since v0.99.5 + */ + //static CCAnimation* animationWithSpriteFrames(CCArray* arrayOfSpriteFrameNames, float delay = 0.0f); + + /* Creates an animation with an array of CCAnimationFrame, the delay per units in seconds and and how many times it should be executed. + @warning: This interface will be deprecated in future. + @since v2.0 + */ + //static CCAnimation* animationWithAnimationFrames(CCArray *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops); + + /** Creates an animation @since v0.99.5 */ - static CCAnimation* animationWithSpriteFrames(CCArray* arrayOfSpriteFrameNames); + static CCAnimation* create(void); /* Creates an animation with an array of CCSpriteFrame and a delay between frames in seconds. The frames will be added with one "delay unit". @since v0.99.5 */ - static CCAnimation* animationWithSpriteFrames(CCArray* arrayOfSpriteFrameNames, float delay); + static CCAnimation* createWithSpriteFrames(CCArray* arrayOfSpriteFrameNames, float delay = 0.0f); /* Creates an animation with an array of CCAnimationFrame, the delay per units in seconds and and how many times it should be executed. @since v2.0 */ - static CCAnimation* animationWithAnimationFrames(CCArray *arrayOfSpriteFrameNames, float delayPerUnit, unsigned int loops); + static CCAnimation* createWithAnimationFrames(CCArray *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops); /** Adds a CCSpriteFrame to a CCAnimation. The frame will be added with one "delay unit". @@ -123,15 +136,11 @@ public: void addSpriteFrameWithTexture(CCTexture2D* pobTexture, const CCRect& rect); bool init(); - /** Initializes a CCAnimation with frames. - @since v0.99.5 - */ - bool initWithSpriteFrames(CCArray *pFrames); /** Initializes a CCAnimation with frames and a delay between frames @since v0.99.5 */ - bool initWithSpriteFrames(CCArray *pFrames, float delay); + bool initWithSpriteFrames(CCArray *pFrames, float delay = 0.0f); /** Initializes a CCAnimation with CCAnimationFrame @since v2.0 diff --git a/cocos2dx/sprite_nodes/CCAnimationCache.cpp b/cocos2dx/sprite_nodes/CCAnimationCache.cpp index 3428ee8f80..c490674e90 100644 --- a/cocos2dx/sprite_nodes/CCAnimationCache.cpp +++ b/cocos2dx/sprite_nodes/CCAnimationCache.cpp @@ -136,7 +136,7 @@ void CCAnimationCache::parseVersion1(CCDictionary* animations) CCLOG("cocos2d: CCAnimationCache: An animation in your dictionary refers to a frame which is not in the CCSpriteFrameCache. Some or all of the frames for the animation '%s' may be missing.", pElement->getStrKey()); } - animation = CCAnimation::animationWithAnimationFrames(frames, delay, 1); + animation = CCAnimation::createWithAnimationFrames(frames, delay, 1); CCAnimationCache::sharedAnimationCache()->addAnimation(animation, pElement->getStrKey()); frames->release(); diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index a1c27ee50e..4b2ee0cc18 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -58,7 +58,12 @@ NS_CC_BEGIN #define RENDER_IN_SUBPIXEL(__A__) ( (int)(__A__)) #endif -CCSprite* CCSprite::spriteWithTexture(CCTexture2D *pTexture) +// CCSprite* CCSprite::spriteWithTexture(CCTexture2D *pTexture) +// { +// return CCSprite::createWithTexture(pTexture); +// } + +CCSprite* CCSprite::createWithTexture(CCTexture2D *pTexture) { CCSprite *pobSprite = new CCSprite(); if (pobSprite && pobSprite->initWithTexture(pTexture)) @@ -70,7 +75,12 @@ CCSprite* CCSprite::spriteWithTexture(CCTexture2D *pTexture) return NULL; } -CCSprite* CCSprite::spriteWithTexture(CCTexture2D *pTexture, const CCRect& rect) +// CCSprite* CCSprite::spriteWithTexture(CCTexture2D *pTexture, const CCRect& rect) +// { +// return CCSprite::createWithTexture(pTexture, rect); +// } + +CCSprite* CCSprite::createWithTexture(CCTexture2D *pTexture, const CCRect& rect) { CCSprite *pobSprite = new CCSprite(); if (pobSprite && pobSprite->initWithTexture(pTexture, rect)) @@ -82,17 +92,12 @@ CCSprite* CCSprite::spriteWithTexture(CCTexture2D *pTexture, const CCRect& rect) return NULL; } -CCSprite* CCSprite::spriteWithTexture(CCTexture2D *pTexture, const CCRect& rect, const CCPoint& offset) -{ - CC_UNUSED_PARAM(pTexture); - CC_UNUSED_PARAM(rect); - CC_UNUSED_PARAM(offset); - // not implement - CCAssert(0, ""); - return NULL; -} +// CCSprite* CCSprite::spriteWithFile(const char *pszFileName) +// { +// CCSprite::create(pszFileName); +// } -CCSprite* CCSprite::spriteWithFile(const char *pszFileName) +CCSprite* CCSprite::create(const char *pszFileName) { CCSprite *pobSprite = new CCSprite(); if (pobSprite && pobSprite->initWithFile(pszFileName)) @@ -104,7 +109,12 @@ CCSprite* CCSprite::spriteWithFile(const char *pszFileName) return NULL; } -CCSprite* CCSprite::spriteWithFile(const char *pszFileName, const CCRect& rect) +// CCSprite* CCSprite::spriteWithFile(const char *pszFileName, const CCRect& rect) +// { +// return CCSprite::create(pszFileName, rect); +// } + +CCSprite* CCSprite::create(const char *pszFileName, const CCRect& rect) { CCSprite *pobSprite = new CCSprite(); if (pobSprite && pobSprite->initWithFile(pszFileName, rect)) @@ -116,7 +126,12 @@ CCSprite* CCSprite::spriteWithFile(const char *pszFileName, const CCRect& rect) return NULL; } -CCSprite* CCSprite::spriteWithSpriteFrame(CCSpriteFrame *pSpriteFrame) +// CCSprite* CCSprite::spriteWithSpriteFrame(CCSpriteFrame *pSpriteFrame) +// { +// return CCSprite::createWithSpriteFrame(pSpriteFrame); +// } + +CCSprite* CCSprite::createWithSpriteFrame(CCSpriteFrame *pSpriteFrame) { CCSprite *pobSprite = new CCSprite(); if (pobSprite && pobSprite->initWithSpriteFrame(pSpriteFrame)) @@ -128,17 +143,27 @@ CCSprite* CCSprite::spriteWithSpriteFrame(CCSpriteFrame *pSpriteFrame) return NULL; } -CCSprite* CCSprite::spriteWithSpriteFrameName(const char *pszSpriteFrameName) +// CCSprite* CCSprite::spriteWithSpriteFrameName(const char *pszSpriteFrameName) +// { +// return CCSprite::createWithSpriteFrameName(pszSpriteFrameName); +// } + +CCSprite* CCSprite::createWithSpriteFrameName(const char *pszSpriteFrameName) { CCSpriteFrame *pFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(pszSpriteFrameName); char msg[256] = {0}; sprintf(msg, "Invalid spriteFrameName: %s", pszSpriteFrameName); CCAssert(pFrame != NULL, msg); - return spriteWithSpriteFrame(pFrame); + return createWithSpriteFrame(pFrame); } -CCSprite* CCSprite::node() +// CCSprite* CCSprite::node() +// { +// return CCSprite::create(); +// } + +CCSprite* CCSprite::create() { CCSprite *pSprite = new CCSprite(); if (pSprite && pSprite->init()) @@ -1000,7 +1025,7 @@ bool CCSprite::isFrameDisplayed(CCSpriteFrame *pFrame) CCSpriteFrame* CCSprite::displayFrame(void) { - return CCSpriteFrame::frameWithTexture(m_pobTexture, + return CCSpriteFrame::create(m_pobTexture, CC_RECT_POINTS_TO_PIXELS(m_obRect), m_bRectRotated, m_obUnflippedOffsetPositionFromCenter, diff --git a/cocos2dx/sprite_nodes/CCSprite.h b/cocos2dx/sprite_nodes/CCSprite.h index f66830adfe..0223e1a2ae 100644 --- a/cocos2dx/sprite_nodes/CCSprite.h +++ b/cocos2dx/sprite_nodes/CCSprite.h @@ -123,41 +123,81 @@ public: /** Creates an sprite with a texture. The rect used will be the size of the texture. The offset will be (0,0). + @warning: This interface will be deprecated in future. */ - static CCSprite* spriteWithTexture(CCTexture2D *pTexture); + //static CCSprite* spriteWithTexture(CCTexture2D *pTexture); + + /** Creates an sprite with a texture and a rect. + The offset will be (0,0). + @warning: This interface will be deprecated in future. + */ + //static CCSprite* spriteWithTexture(CCTexture2D *pTexture, const CCRect& rect); + + /** Creates an sprite with a texture. + The rect used will be the size of the texture. + The offset will be (0,0). + */ + static CCSprite* createWithTexture(CCTexture2D *pTexture); /** Creates an sprite with a texture and a rect. The offset will be (0,0). */ - static CCSprite* spriteWithTexture(CCTexture2D *pTexture, const CCRect& rect); + static CCSprite* createWithTexture(CCTexture2D *pTexture, const CCRect& rect); - /** Creates an sprite with a texture, a rect and offset. */ - static CCSprite* spriteWithTexture(CCTexture2D *pTexture, const CCRect& rect, const CCPoint& offset); + /** Creates an sprite with an sprite frame. + @warning: This interface will be deprecated in future. + */ + // static CCSprite* spriteWithSpriteFrame(CCSpriteFrame *pSpriteFrame); + + /** Creates an sprite with an sprite frame name. + An CCSpriteFrame will be fetched from the CCSpriteFrameCache by name. + If the CCSpriteFrame doesn't exist it will raise an exception. + @warning: This interface will be deprecated in future. + @since v0.9 + */ + //static CCSprite* spriteWithSpriteFrameName(const char *pszSpriteFrameName); /** Creates an sprite with an sprite frame. */ - static CCSprite* spriteWithSpriteFrame(CCSpriteFrame *pSpriteFrame); + static CCSprite* createWithSpriteFrame(CCSpriteFrame *pSpriteFrame); /** Creates an sprite with an sprite frame name. An CCSpriteFrame will be fetched from the CCSpriteFrameCache by name. If the CCSpriteFrame doesn't exist it will raise an exception. @since v0.9 */ - static CCSprite* spriteWithSpriteFrameName(const char *pszSpriteFrameName); + static CCSprite* createWithSpriteFrameName(const char *pszSpriteFrameName); + /** Creates an sprite with an image filename. + The rect used will be the size of the image. + @warning: This interface will be deprecated in future. + The offset will be (0,0). + */ + //static CCSprite* spriteWithFile(const char *pszFileName); + + /** Creates an sprite with an image filename and a rect. + The offset will be (0,0). + @warning: This interface will be deprecated in future. + */ + //static CCSprite* spriteWithFile(const char *pszFileName, const CCRect& rect); + /** Creates an sprite with an image filename. The rect used will be the size of the image. The offset will be (0,0). */ - static CCSprite* spriteWithFile(const char *pszFileName); + static CCSprite* create(const char *pszFileName); /** Creates an sprite with an image filename and a rect. The offset will be (0,0). */ - static CCSprite* spriteWithFile(const char *pszFileName, const CCRect& rect); - + static CCSprite* create(const char *pszFileName, const CCRect& rect); + + /** Creates an sprite. + @warning: This interface will be deprecated in future. + */ + //static CCSprite* node(); /** Creates an sprite. */ - static CCSprite* node(); + static CCSprite* create(); public: CCSprite(void); virtual ~CCSprite(void); diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp index 5ace7b88ca..bb6a4191c1 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009-2010 Ricardo Quesada Copyright (c) 2009 Matt Oswald Copyright (c) 2011 Zynga Inc. @@ -42,20 +42,16 @@ THE SOFTWARE. NS_CC_BEGIN -static const int defaultCapacity = 29; /* * creation with CCTexture2D */ -CCSpriteBatchNode* CCSpriteBatchNode::batchNodeWithTexture(CCTexture2D *tex) -{ - CCSpriteBatchNode *batchNode = new CCSpriteBatchNode(); - batchNode->initWithTexture(tex, defaultCapacity); - batchNode->autorelease(); - return batchNode; -} +// CCSpriteBatchNode* CCSpriteBatchNode::batchNodeWithTexture(CCTexture2D* tex, unsigned int capacity/* = kDefaultSpriteBatchCapacity*/) +// { +// return CCSpriteBatchNode::createWithTexture(tex, capacity); +// } -CCSpriteBatchNode* CCSpriteBatchNode::batchNodeWithTexture(CCTexture2D* tex, unsigned int capacity) +CCSpriteBatchNode* CCSpriteBatchNode::createWithTexture(CCTexture2D* tex, unsigned int capacity/* = kDefaultSpriteBatchCapacity*/) { CCSpriteBatchNode *batchNode = new CCSpriteBatchNode(); batchNode->initWithTexture(tex, capacity); @@ -67,7 +63,12 @@ CCSpriteBatchNode* CCSpriteBatchNode::batchNodeWithTexture(CCTexture2D* tex, uns /* * creation with File Image */ -CCSpriteBatchNode* CCSpriteBatchNode::batchNodeWithFile(const char *fileImage, unsigned int capacity) +// CCSpriteBatchNode* CCSpriteBatchNode::batchNodeWithFile(const char *fileImage, unsigned int capacity/* = kDefaultSpriteBatchCapacity*/) +// { +// return CCSpriteBatchNode::create(fileImage, capacity); +// } + +CCSpriteBatchNode* CCSpriteBatchNode::create(const char *fileImage, unsigned int capacity/* = kDefaultSpriteBatchCapacity*/) { CCSpriteBatchNode *batchNode = new CCSpriteBatchNode(); batchNode->initWithFile(fileImage, capacity); @@ -76,15 +77,6 @@ CCSpriteBatchNode* CCSpriteBatchNode::batchNodeWithFile(const char *fileImage, u return batchNode; } -CCSpriteBatchNode* CCSpriteBatchNode::batchNodeWithFile(const char *fileImage) -{ - CCSpriteBatchNode *batchNode = new CCSpriteBatchNode(); - batchNode->initWithFile(fileImage, defaultCapacity); - batchNode->autorelease(); - - return batchNode; -} - /* * init with CCTexture2D */ @@ -96,7 +88,7 @@ bool CCSpriteBatchNode::initWithTexture(CCTexture2D *tex, unsigned int capacity) if (0 == capacity) { - capacity = defaultCapacity; + capacity = kDefaultSpriteBatchCapacity; } m_pobTextureAtlas->initWithTexture(tex, capacity); diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.h b/cocos2dx/sprite_nodes/CCSpriteBatchNode.h index 037bddfaaa..22d57b7ef4 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.h +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2009-2010 Ricardo Quesada Copyright (C) 2009 Matt Oswald Copyright (c) 2011 Zynga Inc. @@ -36,6 +36,8 @@ THE SOFTWARE. NS_CC_BEGIN +#define kDefaultSpriteBatchCapacity 29 + class CCSprite; /** CCSpriteBatchNode is like a batch node: if it contains children, it will draw them in 1 single OpenGL call @@ -74,27 +76,29 @@ public: inline CCArray* getDescendants(void) { return m_pobDescendants; } - /** creates a CCSpriteBatchNode with a texture2d and a default capacity of 29 children. + /** creates a CCSpriteBatchNode with a texture2d and capacity of children. The capacity will be increased in 33% in runtime if it run out of space. + @warning: This interface will be deprecated in future. */ - static CCSpriteBatchNode* batchNodeWithTexture(CCTexture2D *tex); + //static CCSpriteBatchNode* batchNodeWithTexture(CCTexture2D* tex, unsigned int capacity = kDefaultSpriteBatchCapacity); + + /** creates a CCSpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and capacity of children. + The capacity will be increased in 33% in runtime if it run out of space. + The file will be loaded using the TextureMgr. + @warning: This interface will be deprecated in future. + */ + //static CCSpriteBatchNode* batchNodeWithFile(const char* fileImage, unsigned int capacity = kDefaultSpriteBatchCapacity); /** creates a CCSpriteBatchNode with a texture2d and capacity of children. The capacity will be increased in 33% in runtime if it run out of space. */ - static CCSpriteBatchNode* batchNodeWithTexture(CCTexture2D* tex, unsigned int capacity); - - /** creates a CCSpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) with a default capacity of 29 children. - The capacity will be increased in 33% in runtime if it run out of space. - The file will be loaded using the TextureMgr. - */ - static CCSpriteBatchNode* batchNodeWithFile(const char* fileImage); + static CCSpriteBatchNode* createWithTexture(CCTexture2D* tex, unsigned int capacity = kDefaultSpriteBatchCapacity); /** creates a CCSpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and capacity of children. The capacity will be increased in 33% in runtime if it run out of space. The file will be loaded using the TextureMgr. */ - static CCSpriteBatchNode* batchNodeWithFile(const char* fileImage, unsigned int capacity); + static CCSpriteBatchNode* create(const char* fileImage, unsigned int capacity = kDefaultSpriteBatchCapacity); /** initializes a CCSpriteBatchNode with a texture2d and capacity of children. The capacity will be increased in 33% in runtime if it run out of space. diff --git a/cocos2dx/sprite_nodes/CCSpriteFrame.cpp b/cocos2dx/sprite_nodes/CCSpriteFrame.cpp index c1842330ce..de5709082a 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrame.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrame.cpp @@ -31,7 +31,12 @@ NS_CC_BEGIN // implementation of CCSpriteFrame -CCSpriteFrame* CCSpriteFrame::frameWithTexture(CCTexture2D *pobTexture, const CCRect& rect) +// CCSpriteFrame* CCSpriteFrame::frameWithTexture(CCTexture2D *pobTexture, const CCRect& rect) +// { +// return CCSpriteFrame::create(pobTexture, rect); +// } + +CCSpriteFrame* CCSpriteFrame::create(CCTexture2D *pobTexture, const CCRect& rect) { CCSpriteFrame *pSpriteFrame = new CCSpriteFrame();; pSpriteFrame->initWithTexture(pobTexture, rect); @@ -40,7 +45,12 @@ CCSpriteFrame* CCSpriteFrame::frameWithTexture(CCTexture2D *pobTexture, const CC return pSpriteFrame; } -CCSpriteFrame* CCSpriteFrame::frameWithTextureFilename(const char* filename, const CCRect& rect) +// CCSpriteFrame* CCSpriteFrame::frameWithTextureFilename(const char* filename, const CCRect& rect) +// { +// return createWithTextureFilename(filename, rect); +// } + +CCSpriteFrame* CCSpriteFrame::createWithTextureFilename(const char* filename, const CCRect& rect) { CCSpriteFrame *pSpriteFrame = new CCSpriteFrame();; pSpriteFrame->initWithTextureFilename(filename, rect); @@ -49,7 +59,12 @@ CCSpriteFrame* CCSpriteFrame::frameWithTextureFilename(const char* filename, con return pSpriteFrame; } -CCSpriteFrame* CCSpriteFrame::frameWithTexture(CCTexture2D* pobTexture, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize) +// CCSpriteFrame* CCSpriteFrame::frameWithTexture(CCTexture2D* pobTexture, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize) +// { +// return CCSpriteFrame::create(pobTexture, rect, rotated, offset, originalSize); +// } + +CCSpriteFrame* CCSpriteFrame::create(CCTexture2D* pobTexture, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize) { CCSpriteFrame *pSpriteFrame = new CCSpriteFrame();; pSpriteFrame->initWithTexture(pobTexture, rect, rotated, offset, originalSize); @@ -58,7 +73,12 @@ CCSpriteFrame* CCSpriteFrame::frameWithTexture(CCTexture2D* pobTexture, const CC return pSpriteFrame; } -CCSpriteFrame* CCSpriteFrame::frameWithTextureFilename(const char* filename, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize) +// CCSpriteFrame* CCSpriteFrame::frameWithTextureFilename(const char* filename, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize) +// { +// return CCSpriteFrame::createWithTextureFilename(filename, rect, rotated, offset, originalSize); +// } + +CCSpriteFrame* CCSpriteFrame::createWithTextureFilename(const char* filename, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize) { CCSpriteFrame *pSpriteFrame = new CCSpriteFrame();; pSpriteFrame->initWithTextureFilename(filename, rect, rotated, offset, originalSize); diff --git a/cocos2dx/sprite_nodes/CCSpriteFrame.h b/cocos2dx/sprite_nodes/CCSpriteFrame.h index 2db6576ef9..559bd7e89e 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrame.h +++ b/cocos2dx/sprite_nodes/CCSpriteFrame.h @@ -91,24 +91,49 @@ public: virtual CCObject* copyWithZone(CCZone *pZone); /** Create a CCSpriteFrame with a texture, rect in points. + @warning: This interface will be deprecated in future. It is assumed that the frame was not trimmed. */ - static CCSpriteFrame* frameWithTexture(CCTexture2D* pobTexture, const CCRect& rect); + //static CCSpriteFrame* frameWithTexture(CCTexture2D* pobTexture, const CCRect& rect); + + /** Create a CCSpriteFrame with a texture filename, rect in points. + It is assumed that the frame was not trimmed. + @warning: This interface will be deprecated in future. + */ + //static CCSpriteFrame* frameWithTextureFilename(const char* filename, const CCRect& rect); + + /** Create a CCSpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. + The originalSize is the size in points of the frame before being trimmed. + @warning: This interface will be deprecated in future. + */ + //static CCSpriteFrame* frameWithTexture(CCTexture2D* pobTexture, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize); + + /** Create a CCSpriteFrame with a texture filename, rect, rotated, offset and originalSize in pixels. + The originalSize is the size in pixels of the frame before being trimmed. + @warning: This interface will be deprecated in future. + */ + //static CCSpriteFrame* frameWithTextureFilename(const char* filename, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize); + + /** Create a CCSpriteFrame with a texture, rect in points. + It is assumed that the frame was not trimmed. + */ + static CCSpriteFrame* create(CCTexture2D* pobTexture, const CCRect& rect); /** Create a CCSpriteFrame with a texture filename, rect in points. It is assumed that the frame was not trimmed. */ - static CCSpriteFrame* frameWithTextureFilename(const char* filename, const CCRect& rect); + static CCSpriteFrame* createWithTextureFilename(const char* filename, const CCRect& rect); /** Create a CCSpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. The originalSize is the size in points of the frame before being trimmed. */ - static CCSpriteFrame* frameWithTexture(CCTexture2D* pobTexture, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize); + static CCSpriteFrame* create(CCTexture2D* pobTexture, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize); /** Create a CCSpriteFrame with a texture filename, rect, rotated, offset and originalSize in pixels. The originalSize is the size in pixels of the frame before being trimmed. */ - static CCSpriteFrame* frameWithTextureFilename(const char* filename, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize); + static CCSpriteFrame* createWithTextureFilename(const char* filename, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize); + public: /** Initializes a CCSpriteFrame with a texture, rect in points. It is assumed that the frame was not trimmed. diff --git a/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.cpp b/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.cpp index 6ab842eb4b..c119a5735f 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.cpp @@ -64,12 +64,19 @@ CCParallaxNode::~CCParallaxNode() m_pParallaxArray = NULL; } } -CCParallaxNode * CCParallaxNode::node() + +// CCParallaxNode * CCParallaxNode::node() +// { +// return CCParallaxNode::create(); +// } + +CCParallaxNode * CCParallaxNode::create() { CCParallaxNode *pRet = new CCParallaxNode(); pRet->autorelease(); return pRet; } + void CCParallaxNode::addChild(CCNode * child, unsigned int zOrder, int tag) { CC_UNUSED_PARAM(zOrder); diff --git a/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h b/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h index 844e922e9e..dff3035a75 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h +++ b/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h @@ -50,7 +50,9 @@ public: */ CCParallaxNode(); virtual ~CCParallaxNode(); - static CCParallaxNode * node(); + //@warning: This interface will be deprecated in future. + //static CCParallaxNode * node(); + static CCParallaxNode * create(); virtual void addChild(CCNode * child, unsigned int z, const CCPoint& parallaxRatio, const CCPoint& positionOffset); // super methods virtual void addChild(CCNode * child, unsigned int zOrder, int tag); diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp index 3482411195..2ac1a5e95c 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp @@ -38,7 +38,12 @@ NS_CC_BEGIN // CCTMXLayer - init & alloc & dealloc -CCTMXLayer * CCTMXLayer::layerWithTilesetInfo(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo) +// CCTMXLayer * CCTMXLayer::layerWithTilesetInfo(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo) +// { +// return CCTMXLayer::create(tilesetInfo, layerInfo, mapInfo); +// } + +CCTMXLayer * CCTMXLayer::create(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo) { CCTMXLayer *pRet = new CCTMXLayer(); if (pRet->initWithTilesetInfo(tilesetInfo, layerInfo, mapInfo)) diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h index 86d2331bd8..c65cb3cea2 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h @@ -83,8 +83,14 @@ class CC_DLL CCTMXLayer : public CCSpriteBatchNode public: CCTMXLayer(); virtual ~CCTMXLayer(); + /** creates a CCTMXLayer with an tileset info, a layer info and a map info + @warning: This interface will be deprecated in future. + */ + //static CCTMXLayer * layerWithTilesetInfo(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo); + /** creates a CCTMXLayer with an tileset info, a layer info and a map info */ - static CCTMXLayer * layerWithTilesetInfo(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo); + static CCTMXLayer * create(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo); + /** initializes a CCTMXLayer with a tileset info, a layer info and a map info */ bool initWithTilesetInfo(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo); diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp index d4fd318ced..5e8340d941 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp @@ -32,7 +32,12 @@ THE SOFTWARE. NS_CC_BEGIN // implementation CCTMXTiledMap -CCTMXTiledMap * CCTMXTiledMap::tiledMapWithTMXFile(const char *tmxFile) +// CCTMXTiledMap * CCTMXTiledMap::tiledMapWithTMXFile(const char *tmxFile) +// { +// return CCTMXTiledMap::create(tmxFile); +// } + +CCTMXTiledMap * CCTMXTiledMap::create(const char *tmxFile) { CCTMXTiledMap *pRet = new CCTMXTiledMap(); if (pRet->initWithTMXFile(tmxFile)) @@ -44,7 +49,12 @@ CCTMXTiledMap * CCTMXTiledMap::tiledMapWithTMXFile(const char *tmxFile) return NULL; } -CCTMXTiledMap* CCTMXTiledMap::tiledMapWithXML(const char* tmxString, const char* resourcePath) +// CCTMXTiledMap* CCTMXTiledMap::tiledMapWithXML(const char* tmxString, const char* resourcePath) +// { +// return CCTMXTiledMap::create(tmxString, resourcePath); +// } + +CCTMXTiledMap* CCTMXTiledMap::create(const char* tmxString, const char* resourcePath) { CCTMXTiledMap *pRet = new CCTMXTiledMap(); if (pRet->initWithXML(tmxString, resourcePath)) @@ -129,7 +139,7 @@ void CCTMXTiledMap::setProperties(CCDictionary* var) CCTMXLayer * CCTMXTiledMap::parseLayer(CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo) { CCTMXTilesetInfo *tileset = tilesetForLayer(layerInfo, mapInfo); - CCTMXLayer *layer = CCTMXLayer::layerWithTilesetInfo(tileset, layerInfo, mapInfo); + CCTMXLayer *layer = CCTMXLayer::create(tileset, layerInfo, mapInfo); // tell the layerinfo to release the ownership of the tiles map. layerInfo->m_bOwnTiles = false; diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h index 3276d391be..1186ab10b5 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h @@ -116,11 +116,21 @@ public: CCTMXTiledMap(); virtual ~CCTMXTiledMap(); + /** creates a TMX Tiled Map with a TMX file. + @warning: This interface will be deprecated in future. + */ + //static CCTMXTiledMap* tiledMapWithTMXFile(const char *tmxFile); + + /** initializes a TMX Tiled Map with a TMX formatted XML string and a path to TMX resources + @warning: This interface will be deprecated in future. + */ + //static CCTMXTiledMap* tiledMapWithXML(const char* tmxString, const char* resourcePath); + /** creates a TMX Tiled Map with a TMX file.*/ - static CCTMXTiledMap* tiledMapWithTMXFile(const char *tmxFile); + static CCTMXTiledMap* create(const char *tmxFile); /** initializes a TMX Tiled Map with a TMX formatted XML string and a path to TMX resources */ - static CCTMXTiledMap* tiledMapWithXML(const char* tmxString, const char* resourcePath); + static CCTMXTiledMap* create(const char* tmxString, const char* resourcePath); /** initializes a TMX Tiled Map with a TMX file */ bool initWithTMXFile(const char *tmxFile); diff --git a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp index c8ae96e89f..96bc83f4fa 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp @@ -36,7 +36,12 @@ NS_CC_BEGIN // implementation CCTileMapAtlas -CCTileMapAtlas * CCTileMapAtlas::tileMapAtlasWithTileFile(const char *tile, const char *mapFile, int tileWidth, int tileHeight) +// CCTileMapAtlas * CCTileMapAtlas::tileMapAtlasWithTileFile(const char *tile, const char *mapFile, int tileWidth, int tileHeight) +// { +// return CCTileMapAtlas::create(tile, mapFile, tileWidth, tileHeight); +// } + +CCTileMapAtlas * CCTileMapAtlas::create(const char *tile, const char *mapFile, int tileWidth, int tileHeight) { CCTileMapAtlas *pRet = new CCTileMapAtlas(); if (pRet->initWithTileFile(tile, mapFile, tileWidth, tileHeight)) diff --git a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h index eb68b7ef48..e042bba63e 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h @@ -57,8 +57,15 @@ public: virtual ~CCTileMapAtlas(); /** creates a CCTileMap with a tile file (atlas) with a map file and the width and height of each tile in points. The tile file will be loaded using the TextureMgr. + @warning: This interface will be deprecated in future. */ - static CCTileMapAtlas * tileMapAtlasWithTileFile(const char *tile, const char *mapFile, int tileWidth, int tileHeight); + //static CCTileMapAtlas * tileMapAtlasWithTileFile(const char *tile, const char *mapFile, int tileWidth, int tileHeight); + + /** creates a CCTileMap with a tile file (atlas) with a map file and the width and height of each tile in points. + The tile file will be loaded using the TextureMgr. + */ + static CCTileMapAtlas * create(const char *tile, const char *mapFile, int tileWidth, int tileHeight); + /** initializes a CCTileMap with a tile file (atlas) with a map file and the width and height of each tile in points. The file will be loaded using the TextureMgr. */ diff --git a/tests/AppDelegate.cpp b/tests/AppDelegate.cpp index 2a58f05895..e373b3e5c7 100644 --- a/tests/AppDelegate.cpp +++ b/tests/AppDelegate.cpp @@ -31,7 +31,7 @@ bool AppDelegate::applicationDidFinishLaunching() // set FPS. the default value is 1.0/60 if you don't call this pDirector->setAnimationInterval(1.0 / 60); - CCScene * pScene = CCScene::node(); + CCScene * pScene = CCScene::create(); CCLayer * pLayer = new TestController(); pLayer->autorelease(); diff --git a/tests/tests/AccelerometerTest/AccelerometerTest.cpp b/tests/tests/AccelerometerTest/AccelerometerTest.cpp index 17ee0f61b4..0b951f2485 100644 --- a/tests/tests/AccelerometerTest/AccelerometerTest.cpp +++ b/tests/tests/AccelerometerTest/AccelerometerTest.cpp @@ -36,11 +36,11 @@ void AccelerometerTest::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32); + CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 32); addChild(label, 1); label->setPosition( CCPointMake(s.width/2, s.height-50) ); - m_pBall = CCSprite::spriteWithFile("Images/ball.png"); + m_pBall = CCSprite::create("Images/ball.png"); m_pBall->setPosition(ccp(s.width / 2, s.height / 2)); addChild(m_pBall); diff --git a/tests/tests/ActionManagerTest/ActionManagerTest.cpp b/tests/tests/ActionManagerTest/ActionManagerTest.cpp index 4bbac03725..a5090d6553 100644 --- a/tests/tests/ActionManagerTest/ActionManagerTest.cpp +++ b/tests/tests/ActionManagerTest/ActionManagerTest.cpp @@ -88,15 +88,15 @@ void ActionManagerTest::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32); + CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 32); addChild(label, 1); label->setPosition(CCPointMake(s.width/2, s.height-50)); - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(ActionManagerTest::backCallback) ); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(ActionManagerTest::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(ActionManagerTest::nextCallback)); + CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(ActionManagerTest::backCallback) ); + CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(ActionManagerTest::restartCallback) ); + CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(ActionManagerTest::nextCallback)); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition(CCPointZero); item1->setPosition(CCPointMake(s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2)); @@ -141,22 +141,22 @@ void CrashTest::onEnter() { ActionManagerTest::onEnter(); - CCSprite* child = CCSprite::spriteWithFile(s_pPathGrossini); + CCSprite* child = CCSprite::create(s_pPathGrossini); child->setPosition( CCPointMake(200,200) ); addChild(child, 1); //Sum of all action's duration is 1.5 second. - child->runAction(CCRotateBy::actionWithDuration(1.5f, 90)); - child->runAction(CCSequence::actions( - CCDelayTime::actionWithDuration(1.4f), - CCFadeOut::actionWithDuration(1.1f), + child->runAction(CCRotateBy::create(1.5f, 90)); + child->runAction(CCSequence::create( + CCDelayTime::create(1.4f), + CCFadeOut::create(1.1f), NULL) ); //After 1.5 second, self will be removed. - runAction( CCSequence::actions( - CCDelayTime::actionWithDuration(1.4f), - CCCallFunc::actionWithTarget(this, callfunc_selector(CrashTest::removeThis)), + runAction( CCSequence::create( + CCDelayTime::create(1.4f), + CCCallFunc::create(this, callfunc_selector(CrashTest::removeThis)), NULL) ); } @@ -182,13 +182,13 @@ void LogicTest::onEnter() { ActionManagerTest::onEnter(); - CCSprite* grossini = CCSprite::spriteWithFile(s_pPathGrossini); + CCSprite* grossini = CCSprite::create(s_pPathGrossini); addChild(grossini, 0, 2); grossini->setPosition(CCPointMake(200,200)); - grossini->runAction( CCSequence::actions( - CCMoveBy::actionWithDuration(1, CCPointMake(150,0)), - CCCallFuncN::actionWithTarget(this, callfuncN_selector(LogicTest::bugMe)), + grossini->runAction( CCSequence::create( + CCMoveBy::create(1, CCPointMake(150,0)), + CCCallFuncN::create(this, callfuncN_selector(LogicTest::bugMe)), NULL) ); } @@ -196,7 +196,7 @@ void LogicTest::onEnter() void LogicTest::bugMe(CCNode* node) { node->stopAllActions(); //After this stop next action not working, if remove this stop everything is working - node->runAction(CCScaleTo::actionWithDuration(2, 2)); + node->runAction(CCScaleTo::create(2, 2)); } std::string LogicTest::title() @@ -220,7 +220,7 @@ void PauseTest::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF* l = CCLabelTTF::labelWithString("After 5 seconds grossini should move", "Thonburi", 16); + CCLabelTTF* l = CCLabelTTF::create("After 5 seconds grossini should move", "Thonburi", 16); addChild(l); l->setPosition( CCPointMake(s.width/2, 245) ); @@ -228,11 +228,11 @@ void PauseTest::onEnter() // // Also, this test MUST be done, after [super onEnter] // - CCSprite* grossini = CCSprite::spriteWithFile(s_pPathGrossini); + CCSprite* grossini = CCSprite::create(s_pPathGrossini); addChild(grossini, 0, kTagGrossini); grossini->setPosition( CCPointMake(200,200) ); - CCAction* action = CCMoveBy::actionWithDuration(1, CCPointMake(150,0)); + CCAction* action = CCMoveBy::create(1, CCPointMake(150,0)); CCDirector* pDirector = CCDirector::sharedDirector(); pDirector->getActionManager()->addAction(action, grossini, true); @@ -264,16 +264,16 @@ void RemoveTest::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF* l = CCLabelTTF::labelWithString("Should not crash", "Thonburi", 16); + CCLabelTTF* l = CCLabelTTF::create("Should not crash", "Thonburi", 16); addChild(l); l->setPosition( CCPointMake(s.width/2, 245) ); - CCMoveBy* pMove = CCMoveBy::actionWithDuration(2, CCPointMake(200, 0)); - CCCallFunc* pCallback = CCCallFunc::actionWithTarget(this, callfunc_selector(RemoveTest::stopAction)); - CCActionInterval* pSequence = (CCActionInterval*) CCSequence::actions(pMove, pCallback, NULL); + CCMoveBy* pMove = CCMoveBy::create(2, CCPointMake(200, 0)); + CCCallFunc* pCallback = CCCallFunc::create(this, callfunc_selector(RemoveTest::stopAction)); + CCActionInterval* pSequence = (CCActionInterval*) CCSequence::create(pMove, pCallback, NULL); pSequence->setTag(kTagSequence); - CCSprite* pChild = CCSprite::spriteWithFile(s_pPathGrossini); + CCSprite* pChild = CCSprite::create(s_pPathGrossini); pChild->setPosition(CCPointMake(200, 200)); addChild(pChild, 1, kTagGrossini); @@ -307,19 +307,19 @@ void ResumeTest::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF* l = CCLabelTTF::labelWithString("Grossini only rotate/scale in 3 seconds", "Thonburi", 16); + CCLabelTTF* l = CCLabelTTF::create("Grossini only rotate/scale in 3 seconds", "Thonburi", 16); addChild(l); l->setPosition( CCPointMake(s.width/2, 245)); - CCSprite* pGrossini = CCSprite::spriteWithFile(s_pPathGrossini); + CCSprite* pGrossini = CCSprite::create(s_pPathGrossini); addChild(pGrossini, 0, kTagGrossini); pGrossini->setPosition(CCPointMake(s.width / 2, s.height / 2)); - pGrossini->runAction(CCScaleBy::actionWithDuration(2, 2)); + pGrossini->runAction(CCScaleBy::create(2, 2)); CCDirector* pDirector = CCDirector::sharedDirector(); pDirector->getActionManager()->pauseTarget(pGrossini); - pGrossini->runAction(CCRotateBy::actionWithDuration(2, 360)); + pGrossini->runAction(CCRotateBy::create(2, 360)); this->schedule(schedule_selector(ResumeTest::resumeGrossini), 3.0f); } diff --git a/tests/tests/ActionsEaseTest/ActionsEaseTest.cpp b/tests/tests/ActionsEaseTest/ActionsEaseTest.cpp index 412f171309..1519ef1655 100644 --- a/tests/tests/ActionsEaseTest/ActionsEaseTest.cpp +++ b/tests/tests/ActionsEaseTest/ActionsEaseTest.cpp @@ -23,29 +23,29 @@ void SpriteEase::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130,0)); + CCActionInterval* move = CCMoveBy::create(3, CCPointMake(s.width-130,0)); CCActionInterval* move_back = move->reverse(); - CCActionInterval* move_ease_in = CCEaseIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 2.5f); + CCActionInterval* move_ease_in = CCEaseIn::create((CCActionInterval*)(move->copy()->autorelease()), 2.5f); CCActionInterval* move_ease_in_back = move_ease_in->reverse(); - CCActionInterval* move_ease_out = CCEaseOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 2.5f); + CCActionInterval* move_ease_out = CCEaseOut::create((CCActionInterval*)(move->copy()->autorelease()), 2.5f); CCActionInterval* move_ease_out_back = move_ease_out->reverse(); - CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f); + CCDelayTime *delay = CCDelayTime::create(0.25f); - CCFiniteTimeAction* seq1 = CCSequence::actions(move, delay, move_back, CCCA(delay), NULL); - CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL); - CCFiniteTimeAction* seq3 = CCSequence::actions(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL); - CCAction *a2 = m_grossini->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq1)); + CCAction *a2 = m_grossini->runAction(CCRepeatForever::create((CCActionInterval*)seq1)); a2->setTag(1); - CCAction *a1 = m_tamara->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq2)); + CCAction *a1 = m_tamara->runAction(CCRepeatForever::create((CCActionInterval*)seq2)); a1->setTag(1); - CCAction *a = m_kathia->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq3)); + CCAction *a = m_kathia->runAction(CCRepeatForever::create((CCActionInterval*)seq3)); a->setTag(1); schedule(schedule_selector(SpriteEase::testStopAction), 6.25f); @@ -77,27 +77,27 @@ void SpriteEaseInOut::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130,0)); + CCActionInterval* move = CCMoveBy::create(3, CCPointMake(s.width-130,0)); // id move_back = move->reverse(); - CCActionInterval* move_ease_inout1 = CCEaseInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 0.65f); + CCActionInterval* move_ease_inout1 = CCEaseInOut::create((CCActionInterval*)(move->copy()->autorelease()), 0.65f); CCActionInterval* move_ease_inout_back1 = move_ease_inout1->reverse(); - CCActionInterval* move_ease_inout2 = CCEaseInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 1.35f); + CCActionInterval* move_ease_inout2 = CCEaseInOut::create((CCActionInterval*)(move->copy()->autorelease()), 1.35f); CCActionInterval* move_ease_inout_back2 = move_ease_inout2->reverse(); - CCActionInterval* move_ease_inout3 = CCEaseInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 1.0f); + CCActionInterval* move_ease_inout3 = CCEaseInOut::create((CCActionInterval*)(move->copy()->autorelease()), 1.0f); CCActionInterval* move_ease_inout_back3 = move_ease_inout3->reverse(); - CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f); + CCDelayTime *delay = CCDelayTime::create(0.25f); - CCFiniteTimeAction* seq1 = CCSequence::actions( move_ease_inout1, delay, move_ease_inout_back1, CCCA(delay), NULL); - CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease_inout2, CCCA(delay), move_ease_inout_back2, CCCA(delay), NULL); - CCFiniteTimeAction* seq3 = CCSequence::actions( move_ease_inout3, CCCA(delay), move_ease_inout_back3, CCCA(delay), NULL); + CCFiniteTimeAction* seq1 = CCSequence::create( move_ease_inout1, delay, move_ease_inout_back1, CCCA(delay), NULL); + CCFiniteTimeAction* seq2 = CCSequence::create( move_ease_inout2, CCCA(delay), move_ease_inout_back2, CCCA(delay), NULL); + CCFiniteTimeAction* seq3 = CCSequence::create( move_ease_inout3, CCCA(delay), move_ease_inout_back3, CCCA(delay), NULL); - m_tamara->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq1)); - m_kathia->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq2)); - m_grossini->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq3)); + m_tamara->runAction(CCRepeatForever::create((CCActionInterval*)seq1)); + m_kathia->runAction(CCRepeatForever::create((CCActionInterval*)seq2)); + m_grossini->runAction(CCRepeatForever::create((CCActionInterval*)seq3)); } @@ -118,25 +118,25 @@ void SpriteEaseExponential::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130,0)); + CCActionInterval* move = CCMoveBy::create(3, CCPointMake(s.width-130,0)); CCActionInterval* move_back = move->reverse(); - CCActionInterval* move_ease_in = CCEaseExponentialIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); + CCActionInterval* move_ease_in = CCEaseExponentialIn::create((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_in_back = move_ease_in->reverse(); - CCActionInterval* move_ease_out = CCEaseExponentialOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); + CCActionInterval* move_ease_out = CCEaseExponentialOut::create((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_out_back = move_ease_out->reverse(); - CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f); + CCDelayTime *delay = CCDelayTime::create(0.25f); - CCFiniteTimeAction* seq1 = CCSequence::actions(move, delay, move_back, CCCA(delay), NULL); - CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL); - CCFiniteTimeAction* seq3 = CCSequence::actions(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL); - m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1)); - m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2)); - m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3)); + m_grossini->runAction( CCRepeatForever::create((CCActionInterval*)seq1)); + m_tamara->runAction( CCRepeatForever::create((CCActionInterval*)seq2)); + m_kathia->runAction( CCRepeatForever::create((CCActionInterval*)seq3)); } @@ -156,21 +156,21 @@ void SpriteEaseExponentialInOut::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130, 0)); + CCActionInterval* move = CCMoveBy::create(3, CCPointMake(s.width-130, 0)); CCActionInterval* move_back = move->reverse(); - CCActionInterval* move_ease = CCEaseExponentialInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); + CCActionInterval* move_ease = CCEaseExponentialInOut::create((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_back = move_ease->reverse(); //--> reverse() - CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f); + CCDelayTime *delay = CCDelayTime::create(0.25f); - CCFiniteTimeAction* seq1 = CCSequence::actions( move, delay, move_back, CCCA(delay), NULL); - CCFiniteTimeAction* seq2 = CCSequence::actions( move_ease, delay, move_ease_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq1 = CCSequence::create( move, delay, move_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq2 = CCSequence::create( move_ease, delay, move_ease_back, CCCA(delay), NULL); this->positionForTwo(); - m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1)); - m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2)); + m_grossini->runAction( CCRepeatForever::create((CCActionInterval*)seq1)); + m_tamara->runAction( CCRepeatForever::create((CCActionInterval*)seq2)); } @@ -191,25 +191,25 @@ void SpriteEaseSine::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130, 0)); + CCActionInterval* move = CCMoveBy::create(3, CCPointMake(s.width-130, 0)); CCActionInterval* move_back = move->reverse(); - CCActionInterval* move_ease_in = CCEaseSineIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); + CCActionInterval* move_ease_in = CCEaseSineIn::create((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_in_back = move_ease_in->reverse(); - CCActionInterval* move_ease_out = CCEaseSineOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); + CCActionInterval* move_ease_out = CCEaseSineOut::create((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_out_back = move_ease_out->reverse(); - CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f); + CCDelayTime *delay = CCDelayTime::create(0.25f); - CCFiniteTimeAction* seq1 = CCSequence::actions(move, delay, move_back, CCCA(delay), NULL); - CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL); - CCFiniteTimeAction* seq3 = CCSequence::actions(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL); - m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1)); - m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2)); - m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3)); + m_grossini->runAction( CCRepeatForever::create((CCActionInterval*)seq1)); + m_tamara->runAction( CCRepeatForever::create((CCActionInterval*)seq2)); + m_kathia->runAction( CCRepeatForever::create((CCActionInterval*)seq3)); } @@ -230,21 +230,21 @@ void SpriteEaseSineInOut::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130,0)); + CCActionInterval* move = CCMoveBy::create(3, CCPointMake(s.width-130,0)); CCActionInterval* move_back = move->reverse(); - CCActionInterval* move_ease = CCEaseSineInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); + CCActionInterval* move_ease = CCEaseSineInOut::create((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_back = move_ease->reverse(); - CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f); + CCDelayTime *delay = CCDelayTime::create(0.25f); - CCFiniteTimeAction* seq1 = CCSequence::actions(move, delay, move_back, CCCA(delay), NULL); - CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease, CCCA(delay), move_ease_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq2 = CCSequence::create(move_ease, CCCA(delay), move_ease_back, CCCA(delay), NULL); this->positionForTwo(); - m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1)); - m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2)); + m_grossini->runAction( CCRepeatForever::create((CCActionInterval*)seq1)); + m_tamara->runAction( CCRepeatForever::create((CCActionInterval*)seq2)); } @@ -264,24 +264,24 @@ void SpriteEaseElastic::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130, 0)); + CCActionInterval* move = CCMoveBy::create(3, CCPointMake(s.width-130, 0)); CCActionInterval* move_back = move->reverse(); - CCActionInterval* move_ease_in = CCEaseElasticIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); + CCActionInterval* move_ease_in = CCEaseElasticIn::create((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_in_back = move_ease_in->reverse(); - CCActionInterval* move_ease_out = CCEaseElasticOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); + CCActionInterval* move_ease_out = CCEaseElasticOut::create((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_out_back = move_ease_out->reverse(); - CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f); + CCDelayTime *delay = CCDelayTime::create(0.25f); - CCFiniteTimeAction* seq1 = CCSequence::actions(move, delay, move_back, CCCA(delay), NULL); - CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL); - CCFiniteTimeAction* seq3 = CCSequence::actions(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL); - m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1)); - m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2)); - m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3)); + m_grossini->runAction( CCRepeatForever::create((CCActionInterval*)seq1)); + m_tamara->runAction( CCRepeatForever::create((CCActionInterval*)seq2)); + m_kathia->runAction( CCRepeatForever::create((CCActionInterval*)seq3)); } @@ -302,26 +302,26 @@ void SpriteEaseElasticInOut::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130, 0)); + CCActionInterval* move = CCMoveBy::create(3, CCPointMake(s.width-130, 0)); - CCActionInterval* move_ease_inout1 = CCEaseElasticInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 0.3f); + CCActionInterval* move_ease_inout1 = CCEaseElasticInOut::create((CCActionInterval*)(move->copy()->autorelease()), 0.3f); CCActionInterval* move_ease_inout_back1 = move_ease_inout1->reverse(); - CCActionInterval* move_ease_inout2 = CCEaseElasticInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 0.45f); + CCActionInterval* move_ease_inout2 = CCEaseElasticInOut::create((CCActionInterval*)(move->copy()->autorelease()), 0.45f); CCActionInterval* move_ease_inout_back2 = move_ease_inout2->reverse(); - CCActionInterval* move_ease_inout3 = CCEaseElasticInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 0.6f); + CCActionInterval* move_ease_inout3 = CCEaseElasticInOut::create((CCActionInterval*)(move->copy()->autorelease()), 0.6f); CCActionInterval* move_ease_inout_back3 = move_ease_inout3->reverse(); - CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f); + CCDelayTime *delay = CCDelayTime::create(0.25f); - CCFiniteTimeAction* seq1 = CCSequence::actions(move_ease_inout1, delay, move_ease_inout_back1, CCCA(delay), NULL); - CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease_inout2, CCCA(delay), move_ease_inout_back2, CCCA(delay), NULL); - CCFiniteTimeAction* seq3 = CCSequence::actions(move_ease_inout3, CCCA(delay), move_ease_inout_back3, CCCA(delay), NULL); + CCFiniteTimeAction* seq1 = CCSequence::create(move_ease_inout1, delay, move_ease_inout_back1, CCCA(delay), NULL); + CCFiniteTimeAction* seq2 = CCSequence::create(move_ease_inout2, CCCA(delay), move_ease_inout_back2, CCCA(delay), NULL); + CCFiniteTimeAction* seq3 = CCSequence::create(move_ease_inout3, CCCA(delay), move_ease_inout_back3, CCCA(delay), NULL); - m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1)); - m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2)); - m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3)); + m_tamara->runAction( CCRepeatForever::create((CCActionInterval*)seq1)); + m_kathia->runAction( CCRepeatForever::create((CCActionInterval*)seq2)); + m_grossini->runAction( CCRepeatForever::create((CCActionInterval*)seq3)); } @@ -343,24 +343,24 @@ void SpriteEaseBounce::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130, 0)); + CCActionInterval* move = CCMoveBy::create(3, CCPointMake(s.width-130, 0)); CCActionInterval* move_back = move->reverse(); - CCActionInterval* move_ease_in = CCEaseBounceIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); + CCActionInterval* move_ease_in = CCEaseBounceIn::create((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_in_back = move_ease_in->reverse(); - CCActionInterval* move_ease_out = CCEaseBounceOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); + CCActionInterval* move_ease_out = CCEaseBounceOut::create((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_out_back = move_ease_out->reverse(); - CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f); + CCDelayTime *delay = CCDelayTime::create(0.25f); - CCFiniteTimeAction* seq1 = CCSequence::actions(move, delay, move_back, CCCA(delay), NULL); - CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL); - CCFiniteTimeAction* seq3 = CCSequence::actions(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL); - m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1)); - m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2)); - m_kathia->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3)); + m_grossini->runAction( CCRepeatForever::create((CCActionInterval*)seq1)); + m_tamara->runAction( CCRepeatForever::create((CCActionInterval*)seq2)); + m_kathia->runAction( CCRepeatForever::create((CCActionInterval*)seq3)); } @@ -382,21 +382,21 @@ void SpriteEaseBounceInOut::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130, 0)); + CCActionInterval* move = CCMoveBy::create(3, CCPointMake(s.width-130, 0)); CCActionInterval* move_back = move->reverse(); - CCActionInterval* move_ease = CCEaseBounceInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); + CCActionInterval* move_ease = CCEaseBounceInOut::create((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_back = move_ease->reverse(); - CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f); + CCDelayTime *delay = CCDelayTime::create(0.25f); - CCFiniteTimeAction* seq1 = CCSequence::actions(move, delay, move_back, CCCA(delay), NULL); - CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease, CCCA(delay), move_ease_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq2 = CCSequence::create(move_ease, CCCA(delay), move_ease_back, CCCA(delay), NULL); this->positionForTwo(); - m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1)); - m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2)); + m_grossini->runAction( CCRepeatForever::create((CCActionInterval*)seq1)); + m_tamara->runAction( CCRepeatForever::create((CCActionInterval*)seq2)); } @@ -417,24 +417,24 @@ void SpriteEaseBack::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130, 0)); + CCActionInterval* move = CCMoveBy::create(3, CCPointMake(s.width-130, 0)); CCActionInterval* move_back = move->reverse(); - CCActionInterval* move_ease_in = CCEaseBackIn::actionWithAction((CCActionInterval*)(move->copy()->autorelease())); + CCActionInterval* move_ease_in = CCEaseBackIn::create((CCActionInterval*)(move->copy()->autorelease())); CCActionInterval* move_ease_in_back = move_ease_in->reverse(); - CCActionInterval* move_ease_out = CCEaseBackOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease())); + CCActionInterval* move_ease_out = CCEaseBackOut::create((CCActionInterval*)(move->copy()->autorelease())); CCActionInterval* move_ease_out_back = move_ease_out->reverse(); - CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f); + CCDelayTime *delay = CCDelayTime::create(0.25f); - CCFiniteTimeAction* seq1 = CCSequence::actions(move, delay, move_back, CCCA(delay), NULL); - CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL); - CCFiniteTimeAction* seq3 = CCSequence::actions(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq2 = CCSequence::create(move_ease_in, CCCA(delay), move_ease_in_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq3 = CCSequence::create(move_ease_out, CCCA(delay), move_ease_out_back, CCCA(delay), NULL); - m_grossini->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq1)); - m_tamara->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq2)); - m_kathia->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq3)); + m_grossini->runAction(CCRepeatForever::create((CCActionInterval*)seq1)); + m_tamara->runAction(CCRepeatForever::create((CCActionInterval*)seq2)); + m_kathia->runAction(CCRepeatForever::create((CCActionInterval*)seq3)); } @@ -455,21 +455,21 @@ void SpriteEaseBackInOut::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(s.width-130, 0)); + CCActionInterval* move = CCMoveBy::create(3, CCPointMake(s.width-130, 0)); CCActionInterval* move_back = move->reverse(); - CCActionInterval* move_ease = CCEaseBackInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()) ); + CCActionInterval* move_ease = CCEaseBackInOut::create((CCActionInterval*)(move->copy()->autorelease()) ); CCActionInterval* move_ease_back = move_ease->reverse(); - CCDelayTime *delay = CCDelayTime::actionWithDuration(0.25f); + CCDelayTime *delay = CCDelayTime::create(0.25f); - CCFiniteTimeAction* seq1 = CCSequence::actions(move, delay, move_back, CCCA(delay), NULL); - CCFiniteTimeAction* seq2 = CCSequence::actions(move_ease, CCCA(delay), move_ease_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq1 = CCSequence::create(move, delay, move_back, CCCA(delay), NULL); + CCFiniteTimeAction* seq2 = CCSequence::create(move_ease, CCCA(delay), move_ease_back, CCCA(delay), NULL); this->positionForTwo(); - m_grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq1)); - m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq2)); + m_grossini->runAction( CCRepeatForever::create((CCActionInterval*)seq1)); + m_tamara->runAction( CCRepeatForever::create((CCActionInterval*)seq2)); } @@ -491,15 +491,15 @@ void SpeedTest::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); // rotate and jump - CCActionInterval *jump1 = CCJumpBy::actionWithDuration(4, CCPointMake(-s.width+80, 0), 100, 4); + CCActionInterval *jump1 = CCJumpBy::create(4, CCPointMake(-s.width+80, 0), 100, 4); CCActionInterval *jump2 = jump1->reverse(); - CCActionInterval *rot1 = CCRotateBy::actionWithDuration(4, 360*2); + CCActionInterval *rot1 = CCRotateBy::create(4, 360*2); CCActionInterval *rot2 = rot1->reverse(); - CCFiniteTimeAction* seq3_1 = CCSequence::actions(jump2, jump1, NULL); - CCFiniteTimeAction* seq3_2 = CCSequence::actions( rot1, rot2, NULL); - CCFiniteTimeAction* spawn = CCSpawn::actions(seq3_1, seq3_2, NULL); - CCSpeed* action = CCSpeed::actionWithAction(CCRepeatForever::actionWithAction((CCActionInterval*)spawn), 1.0f); + CCFiniteTimeAction* seq3_1 = CCSequence::create(jump2, jump1, NULL); + CCFiniteTimeAction* seq3_2 = CCSequence::create( rot1, rot2, NULL); + CCFiniteTimeAction* spawn = CCSpawn::create(seq3_1, seq3_2, NULL); + CCSpeed* action = CCSpeed::create(CCRepeatForever::create((CCActionInterval*)spawn), 1.0f); action->setTag(kTagAction1); CCAction* action2 = (CCAction*)(action->copy()->autorelease()); @@ -635,9 +635,9 @@ void EaseSpriteDemo::onEnter() CCLayer::onEnter(); // Or you can create an sprite using a filename. PNG and BMP files are supported. Probably TIFF too - m_grossini = CCSprite::spriteWithFile(s_pPathGrossini); m_grossini->retain(); - m_tamara = CCSprite::spriteWithFile(s_pPathSister1); m_tamara->retain(); - m_kathia = CCSprite::spriteWithFile(s_pPathSister2); m_kathia->retain(); + m_grossini = CCSprite::create(s_pPathGrossini); m_grossini->retain(); + m_tamara = CCSprite::create(s_pPathSister1); m_tamara->retain(); + m_kathia = CCSprite::create(s_pPathSister2); m_kathia->retain(); addChild( m_grossini, 3); addChild( m_kathia, 2); @@ -649,15 +649,15 @@ void EaseSpriteDemo::onEnter() m_kathia->setPosition(CCPointMake(60, s.height*2.5f/5)); m_tamara->setPosition(CCPointMake(60, s.height*4/5)); - CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32); + CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 32); addChild(label); label->setPosition(CCPointMake(s.width/2, s.height-50)); - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(EaseSpriteDemo::backCallback) ); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(EaseSpriteDemo::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(EaseSpriteDemo::nextCallback) ); + CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(EaseSpriteDemo::backCallback) ); + CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(EaseSpriteDemo::restartCallback) ); + CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(EaseSpriteDemo::nextCallback) ); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition(CCPointZero); item1->setPosition(CCPointMake(s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2)); @@ -669,7 +669,7 @@ void EaseSpriteDemo::onEnter() void EaseSpriteDemo::restartCallback(CCObject* pSender) { - CCScene* s = new ActionsEaseTestScene();//CCScene::node(); + CCScene* s = new ActionsEaseTestScene();//CCScene::create(); s->addChild(restartEaseAction()); CCDirector::sharedDirector()->replaceScene(s); @@ -678,7 +678,7 @@ void EaseSpriteDemo::restartCallback(CCObject* pSender) void EaseSpriteDemo::nextCallback(CCObject* pSender) { - CCScene* s = new ActionsEaseTestScene();//CCScene::node(); + CCScene* s = new ActionsEaseTestScene();//CCScene::create(); s->addChild( nextEaseAction() ); CCDirector::sharedDirector()->replaceScene(s); s->release(); @@ -686,7 +686,7 @@ void EaseSpriteDemo::nextCallback(CCObject* pSender) void EaseSpriteDemo::backCallback(CCObject* pSender) { - CCScene* s = new ActionsEaseTestScene();//CCScene::node(); + CCScene* s = new ActionsEaseTestScene();//CCScene::create(); s->addChild( backEaseAction() ); CCDirector::sharedDirector()->replaceScene(s); s->release(); diff --git a/tests/tests/ActionsProgressTest/ActionsProgressTest.cpp b/tests/tests/ActionsProgressTest/ActionsProgressTest.cpp index aecd192f42..3b050b11bd 100644 --- a/tests/tests/ActionsProgressTest/ActionsProgressTest.cpp +++ b/tests/tests/ActionsProgressTest/ActionsProgressTest.cpp @@ -94,30 +94,30 @@ void SpriteDemo::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 18); + CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 18); addChild(label, 1); label->setPosition( CCPointMake(s.width/2, s.height-50) ); std::string strSubtitle = subtitle(); if( ! strSubtitle.empty() ) { - CCLabelTTF* l = CCLabelTTF::labelWithString(strSubtitle.c_str(), "Thonburi", 22); + CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 22); addChild(l, 1); l->setPosition( CCPointMake(s.width/2, s.height-80) ); } - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(SpriteDemo::backCallback) ); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(SpriteDemo::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(SpriteDemo::nextCallback) ); + CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(SpriteDemo::backCallback) ); + CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(SpriteDemo::restartCallback) ); + CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(SpriteDemo::nextCallback) ); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition(CCPointZero); item1->setPosition(CCPointMake( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2)); item2->setPosition(CCPointMake( s.width/2, item2->getContentSize().height/2)); item3->setPosition(CCPointMake( s.width/2 + item2->getContentSize().width*2, item2->getContentSize().height/2)); addChild(menu, 1); - CCLayerColor *background = CCLayerColor::layerWithColor(ccc4(255,0,0,255)); + CCLayerColor *background = CCLayerColor::create(ccc4(255,0,0,255)); addChild(background, -10); } @@ -157,22 +157,22 @@ void SpriteProgressToRadial::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCProgressTo *to1 = CCProgressTo::actionWithDuration(2, 100); - CCProgressTo *to2 = CCProgressTo::actionWithDuration(2, 100); + CCProgressTo *to1 = CCProgressTo::create(2, 100); + CCProgressTo *to2 = CCProgressTo::create(2, 100); - CCProgressTimer *left = CCProgressTimer::progressWithSprite(CCSprite::spriteWithFile(s_pPathSister1)); + CCProgressTimer *left = CCProgressTimer::create(CCSprite::create(s_pPathSister1)); left->setType( kCCProgressTimerTypeRadial ); addChild(left); left->setPosition(CCPointMake(100, s.height/2)); - left->runAction( CCRepeatForever::actionWithAction(to1)); + left->runAction( CCRepeatForever::create(to1)); - CCProgressTimer *right = CCProgressTimer::progressWithSprite(CCSprite::spriteWithFile(s_pPathBlock)); + CCProgressTimer *right = CCProgressTimer::create(CCSprite::create(s_pPathBlock)); right->setType(kCCProgressTimerTypeRadial); // Makes the ridial CCW right->setReverseProgress(true); addChild(right); right->setPosition(CCPointMake(s.width-100, s.height/2)); - right->runAction( CCRepeatForever::actionWithAction(to2)); + right->runAction( CCRepeatForever::create(to2)); } std::string SpriteProgressToRadial::subtitle() @@ -192,10 +192,10 @@ void SpriteProgressToHorizontal::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCProgressTo *to1 = CCProgressTo::actionWithDuration(2, 100); - CCProgressTo *to2 = CCProgressTo::actionWithDuration(2, 100); + CCProgressTo *to1 = CCProgressTo::create(2, 100); + CCProgressTo *to2 = CCProgressTo::create(2, 100); - CCProgressTimer *left = CCProgressTimer::progressWithSprite(CCSprite::spriteWithFile(s_pPathSister1)); + CCProgressTimer *left = CCProgressTimer::create(CCSprite::create(s_pPathSister1)); left->setType(kCCProgressTimerTypeBar); // Setup for a bar starting from the left since the midpoint is 0 for the x left->setMidpoint(ccp(0,0)); @@ -203,9 +203,9 @@ void SpriteProgressToHorizontal::onEnter() left->setBarChangeRate(ccp(1, 0)); addChild(left); left->setPosition(CCPointMake(100, s.height/2)); - left->runAction( CCRepeatForever::actionWithAction(to1)); + left->runAction( CCRepeatForever::create(to1)); - CCProgressTimer *right = CCProgressTimer::progressWithSprite(CCSprite::spriteWithFile(s_pPathSister2)); + CCProgressTimer *right = CCProgressTimer::create(CCSprite::create(s_pPathSister2)); right->setType(kCCProgressTimerTypeBar); // Setup for a bar starting from the left since the midpoint is 1 for the x right->setMidpoint(ccp(1, 0)); @@ -213,7 +213,7 @@ void SpriteProgressToHorizontal::onEnter() right->setBarChangeRate(ccp(1, 0)); addChild(right); right->setPosition(CCPointMake(s.width-100, s.height/2)); - right->runAction( CCRepeatForever::actionWithAction(to2)); + right->runAction( CCRepeatForever::create(to2)); } std::string SpriteProgressToHorizontal::subtitle() @@ -232,10 +232,10 @@ void SpriteProgressToVertical::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCProgressTo *to1 = CCProgressTo::actionWithDuration(2, 100); - CCProgressTo *to2 = CCProgressTo::actionWithDuration(2, 100); + CCProgressTo *to1 = CCProgressTo::create(2, 100); + CCProgressTo *to2 = CCProgressTo::create(2, 100); - CCProgressTimer *left = CCProgressTimer::progressWithSprite(CCSprite::spriteWithFile(s_pPathSister1)); + CCProgressTimer *left = CCProgressTimer::create(CCSprite::create(s_pPathSister1)); left->setType(kCCProgressTimerTypeBar); // Setup for a bar starting from the bottom since the midpoint is 0 for the y @@ -244,9 +244,9 @@ void SpriteProgressToVertical::onEnter() left->setBarChangeRate(ccp(0, 1)); addChild(left); left->setPosition(CCPointMake(100, s.height/2)); - left->runAction( CCRepeatForever::actionWithAction(to1)); + left->runAction( CCRepeatForever::create(to1)); - CCProgressTimer *right = CCProgressTimer::progressWithSprite(CCSprite::spriteWithFile(s_pPathSister2)); + CCProgressTimer *right = CCProgressTimer::create(CCSprite::create(s_pPathSister2)); right->setType(kCCProgressTimerTypeBar); // Setup for a bar starting from the bottom since the midpoint is 0 for the y right->setMidpoint(ccp(0, 1)); @@ -254,7 +254,7 @@ void SpriteProgressToVertical::onEnter() right->setBarChangeRate(ccp(0, 1)); addChild(right); right->setPosition(CCPointMake(s.width-100, s.height/2)); - right->runAction( CCRepeatForever::actionWithAction(to2)); + right->runAction( CCRepeatForever::create(to2)); } std::string SpriteProgressToVertical::subtitle() @@ -273,22 +273,22 @@ void SpriteProgressToRadialMidpointChanged::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCProgressTo *action = CCProgressTo::actionWithDuration(2, 100); + CCProgressTo *action = CCProgressTo::create(2, 100); /** * Our image on the left should be a radial progress indicator, clockwise */ - CCProgressTimer *left = CCProgressTimer::progressWithSprite(CCSprite::spriteWithFile(s_pPathBlock)); + CCProgressTimer *left = CCProgressTimer::create(CCSprite::create(s_pPathBlock)); left->setType(kCCProgressTimerTypeRadial); addChild(left); left->setMidpoint(ccp(0.25f, 0.75f)); left->setPosition(ccp(100, s.height/2)); - left->runAction(CCRepeatForever::actionWithAction((CCActionInterval *)action->copy()->autorelease())); + left->runAction(CCRepeatForever::create((CCActionInterval *)action->copy()->autorelease())); /** * Our image on the left should be a radial progress indicator, counter clockwise */ - CCProgressTimer *right = CCProgressTimer::progressWithSprite(CCSprite::spriteWithFile(s_pPathBlock)); + CCProgressTimer *right = CCProgressTimer::create(CCSprite::create(s_pPathBlock)); right->setType(kCCProgressTimerTypeRadial); right->setMidpoint(ccp(0.75f, 0.25f)); @@ -298,7 +298,7 @@ void SpriteProgressToRadialMidpointChanged::onEnter() */ addChild(right); right->setPosition(ccp(s.width-100, s.height/2)); - right->runAction(CCRepeatForever::actionWithAction((CCActionInterval *)action->copy()->autorelease())); + right->runAction(CCRepeatForever::create((CCActionInterval *)action->copy()->autorelease())); } std::string SpriteProgressToRadialMidpointChanged::subtitle() @@ -317,9 +317,9 @@ void SpriteProgressBarVarious::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCProgressTo *to = CCProgressTo::actionWithDuration(2, 100); + CCProgressTo *to = CCProgressTo::create(2, 100); - CCProgressTimer *left = CCProgressTimer::progressWithSprite(CCSprite::spriteWithFile(s_pPathSister1)); + CCProgressTimer *left = CCProgressTimer::create(CCSprite::create(s_pPathSister1)); left->setType(kCCProgressTimerTypeBar); // Setup for a bar starting from the bottom since the midpoint is 0 for the y @@ -328,9 +328,9 @@ void SpriteProgressBarVarious::onEnter() left->setBarChangeRate(ccp(1, 0)); addChild(left); left->setPosition(ccp(100, s.height/2)); - left->runAction(CCRepeatForever::actionWithAction((CCActionInterval *)to->copy()->autorelease())); + left->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease())); - CCProgressTimer *middle = CCProgressTimer::progressWithSprite(CCSprite::spriteWithFile(s_pPathSister2)); + CCProgressTimer *middle = CCProgressTimer::create(CCSprite::create(s_pPathSister2)); middle->setType(kCCProgressTimerTypeBar); // Setup for a bar starting from the bottom since the midpoint is 0 for the y middle->setMidpoint(ccp(0.5f, 0.5f)); @@ -338,9 +338,9 @@ void SpriteProgressBarVarious::onEnter() middle->setBarChangeRate(ccp(1,1)); addChild(middle); middle->setPosition(ccp(s.width/2, s.height/2)); - middle->runAction(CCRepeatForever::actionWithAction((CCActionInterval *)to->copy()->autorelease())); + middle->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease())); - CCProgressTimer *right = CCProgressTimer::progressWithSprite(CCSprite::spriteWithFile(s_pPathSister2)); + CCProgressTimer *right = CCProgressTimer::create(CCSprite::create(s_pPathSister2)); right->setType(kCCProgressTimerTypeBar); // Setup for a bar starting from the bottom since the midpoint is 0 for the y right->setMidpoint(ccp(0.5f, 0.5f)); @@ -348,7 +348,7 @@ void SpriteProgressBarVarious::onEnter() right->setBarChangeRate(ccp(0, 1)); addChild(right); right->setPosition(ccp(s.width-100, s.height/2)); - right->runAction(CCRepeatForever::actionWithAction((CCActionInterval *)to->copy()->autorelease())); + right->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease())); } std::string SpriteProgressBarVarious::subtitle() @@ -367,16 +367,16 @@ void SpriteProgressBarTintAndFade::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCProgressTo *to = CCProgressTo::actionWithDuration(6, 100); - CCAction *tint = CCSequence::actions(CCTintTo::actionWithDuration(1, 255, 0, 0), - CCTintTo::actionWithDuration(1, 0, 255, 0), - CCTintTo::actionWithDuration(1, 0, 0, 255), + CCProgressTo *to = CCProgressTo::create(6, 100); + CCAction *tint = CCSequence::create(CCTintTo::create(1, 255, 0, 0), + CCTintTo::create(1, 0, 255, 0), + CCTintTo::create(1, 0, 0, 255), NULL); - CCAction *fade = CCSequence::actions(CCFadeTo::actionWithDuration(1.0f, 0), - CCFadeTo::actionWithDuration(1.0f, 255), + CCAction *fade = CCSequence::create(CCFadeTo::create(1.0f, 0), + CCFadeTo::create(1.0f, 255), NULL); - CCProgressTimer *left = CCProgressTimer::progressWithSprite(CCSprite::spriteWithFile(s_pPathSister1)); + CCProgressTimer *left = CCProgressTimer::create(CCSprite::create(s_pPathSister1)); left->setType(kCCProgressTimerTypeBar); // Setup for a bar starting from the bottom since the midpoint is 0 for the y @@ -385,12 +385,12 @@ void SpriteProgressBarTintAndFade::onEnter() left->setBarChangeRate(ccp(1, 0)); addChild(left); left->setPosition(ccp(100, s.height/2)); - left->runAction(CCRepeatForever::actionWithAction((CCActionInterval *)to->copy()->autorelease())); - left->runAction(CCRepeatForever::actionWithAction((CCActionInterval *)tint->copy()->autorelease())); + left->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease())); + left->runAction(CCRepeatForever::create((CCActionInterval *)tint->copy()->autorelease())); - left->addChild(CCLabelTTF::labelWithString("Tint", "Marker Felt", 20.0f)); + left->addChild(CCLabelTTF::create("Tint", "Marker Felt", 20.0f)); - CCProgressTimer *middle = CCProgressTimer::progressWithSprite(CCSprite::spriteWithFile(s_pPathSister2)); + CCProgressTimer *middle = CCProgressTimer::create(CCSprite::create(s_pPathSister2)); middle->setType(kCCProgressTimerTypeBar); // Setup for a bar starting from the bottom since the midpoint is 0 for the y middle->setMidpoint(ccp(0.5f, 0.5f)); @@ -398,12 +398,12 @@ void SpriteProgressBarTintAndFade::onEnter() middle->setBarChangeRate(ccp(1, 1)); addChild(middle); middle->setPosition(ccp(s.width/2, s.height/2)); - middle->runAction(CCRepeatForever::actionWithAction((CCActionInterval *)to->copy()->autorelease())); - middle->runAction(CCRepeatForever::actionWithAction((CCActionInterval *)fade->copy()->autorelease())); + middle->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease())); + middle->runAction(CCRepeatForever::create((CCActionInterval *)fade->copy()->autorelease())); - middle->addChild(CCLabelTTF::labelWithString("Fade", "Marker Felt", 20.0f)); + middle->addChild(CCLabelTTF::create("Fade", "Marker Felt", 20.0f)); - CCProgressTimer *right = CCProgressTimer::progressWithSprite(CCSprite::spriteWithFile(s_pPathSister2)); + CCProgressTimer *right = CCProgressTimer::create(CCSprite::create(s_pPathSister2)); right->setType(kCCProgressTimerTypeBar); // Setup for a bar starting from the bottom since the midpoint is 0 for the y right->setMidpoint(ccp(0.5f, 0.5f)); @@ -411,11 +411,11 @@ void SpriteProgressBarTintAndFade::onEnter() right->setBarChangeRate(ccp(0, 1)); addChild(right); right->setPosition(ccp(s.width-100, s.height/2)); - right->runAction(CCRepeatForever::actionWithAction((CCActionInterval *)to->copy()->autorelease())); - right->runAction(CCRepeatForever::actionWithAction((CCActionInterval *)tint->copy()->autorelease())); - right->runAction(CCRepeatForever::actionWithAction((CCActionInterval *)fade->copy()->autorelease())); + right->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease())); + right->runAction(CCRepeatForever::create((CCActionInterval *)tint->copy()->autorelease())); + right->runAction(CCRepeatForever::create((CCActionInterval *)fade->copy()->autorelease())); - right->addChild(CCLabelTTF::labelWithString("Tint and Fade", "Marker Felt", 20.0f)); + right->addChild(CCLabelTTF::create("Tint and Fade", "Marker Felt", 20.0f)); } std::string SpriteProgressBarTintAndFade::subtitle() @@ -434,11 +434,11 @@ void SpriteProgressWithSpriteFrame::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCProgressTo *to = CCProgressTo::actionWithDuration(6, 100); + CCProgressTo *to = CCProgressTo::create(6, 100); CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("zwoptex/grossini.plist"); - CCProgressTimer *left = CCProgressTimer::progressWithSprite(CCSprite::spriteWithSpriteFrameName("grossini_dance_01.png")); + CCProgressTimer *left = CCProgressTimer::create(CCSprite::createWithSpriteFrameName("grossini_dance_01.png")); left->setType(kCCProgressTimerTypeBar); // Setup for a bar starting from the bottom since the midpoint is 0 for the y left->setMidpoint(ccp(0.5f, 0.5f)); @@ -446,9 +446,9 @@ void SpriteProgressWithSpriteFrame::onEnter() left->setBarChangeRate(ccp(1, 0)); addChild(left); left->setPosition(ccp(100, s.height/2)); - left->runAction(CCRepeatForever::actionWithAction((CCActionInterval *)to->copy()->autorelease())); + left->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease())); - CCProgressTimer *middle = CCProgressTimer::progressWithSprite(CCSprite::spriteWithSpriteFrameName("grossini_dance_02.png")); + CCProgressTimer *middle = CCProgressTimer::create(CCSprite::createWithSpriteFrameName("grossini_dance_02.png")); middle->setType(kCCProgressTimerTypeBar); // Setup for a bar starting from the bottom since the midpoint is 0 for the y middle->setMidpoint(ccp(0.5f, 0.5f)); @@ -456,9 +456,9 @@ void SpriteProgressWithSpriteFrame::onEnter() middle->setBarChangeRate(ccp(1, 1)); addChild(middle); middle->setPosition(ccp(s.width/2, s.height/2)); - middle->runAction(CCRepeatForever::actionWithAction((CCActionInterval *)to->copy()->autorelease())); + middle->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease())); - CCProgressTimer *right = CCProgressTimer::progressWithSprite(CCSprite::spriteWithSpriteFrameName("grossini_dance_03.png")); + CCProgressTimer *right = CCProgressTimer::create(CCSprite::createWithSpriteFrameName("grossini_dance_03.png")); right->setType(kCCProgressTimerTypeRadial); // Setup for a bar starting from the bottom since the midpoint is 0 for the y right->setMidpoint(ccp(0.5f, 0.5f)); @@ -466,7 +466,7 @@ void SpriteProgressWithSpriteFrame::onEnter() right->setBarChangeRate(ccp(0, 1)); addChild(right); right->setPosition(ccp(s.width-100, s.height/2)); - right->runAction(CCRepeatForever::actionWithAction((CCActionInterval *)to->copy()->autorelease())); + right->runAction(CCRepeatForever::create((CCActionInterval *)to->copy()->autorelease())); } std::string SpriteProgressWithSpriteFrame::subtitle() diff --git a/tests/tests/ActionsTest/ActionsTest.cpp b/tests/tests/ActionsTest/ActionsTest.cpp index a821055ba1..6fe8607c33 100644 --- a/tests/tests/ActionsTest/ActionsTest.cpp +++ b/tests/tests/ActionsTest/ActionsTest.cpp @@ -150,13 +150,13 @@ void ActionsDemo::onEnter() CCLayer::onEnter(); // Or you can create an sprite using a filename. only PNG is supported now. Probably TIFF too - m_grossini = CCSprite::spriteWithFile(s_pPathGrossini); + m_grossini = CCSprite::create(s_pPathGrossini); m_grossini->retain(); - m_tamara = CCSprite::spriteWithFile(s_pPathSister1); + m_tamara = CCSprite::create(s_pPathSister1); m_tamara->retain(); - m_kathia = CCSprite::spriteWithFile(s_pPathSister2); + m_kathia = CCSprite::create(s_pPathSister2); m_kathia->retain(); addChild(m_grossini, 1); @@ -172,24 +172,24 @@ void ActionsDemo::onEnter() // add title and subtitle std::string str = title(); const char * pTitle = str.c_str(); - CCLabelTTF* label = CCLabelTTF::labelWithString(pTitle, "Arial", 18); + CCLabelTTF* label = CCLabelTTF::create(pTitle, "Arial", 18); addChild(label, 1); label->setPosition( CCPointMake(s.width/2, s.height - 30) ); std::string strSubtitle = subtitle(); if( ! strSubtitle.empty() ) { - CCLabelTTF* l = CCLabelTTF::labelWithString(strSubtitle.c_str(), "Thonburi", 22); + CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 22); addChild(l, 1); l->setPosition( CCPointMake(s.width/2, s.height - 60) ); } // add menu - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(ActionsDemo::backCallback) ); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(ActionsDemo::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(ActionsDemo::nextCallback) ); + CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(ActionsDemo::backCallback) ); + CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(ActionsDemo::restartCallback) ); + CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(ActionsDemo::nextCallback) ); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition(CCPointZero); item1->setPosition(CCPointMake(s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2)); @@ -328,13 +328,13 @@ void ActionMove::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCActionInterval* actionTo = CCMoveTo::actionWithDuration(2, CCPointMake(s.width-40, s.height-40)); - CCActionInterval* actionBy = CCMoveBy::actionWithDuration(2, CCPointMake(80,80)); + CCActionInterval* actionTo = CCMoveTo::create(2, CCPointMake(s.width-40, s.height-40)); + CCActionInterval* actionBy = CCMoveBy::create(2, CCPointMake(80,80)); CCActionInterval* actionByBack = actionBy->reverse(); m_tamara->runAction( actionTo); - m_grossini->runAction( CCSequence::actions(actionBy, actionByBack, NULL)); - m_kathia->runAction(CCMoveTo::actionWithDuration(1, CCPointMake(40,40))); + m_grossini->runAction( CCSequence::create(actionBy, actionByBack, NULL)); + m_kathia->runAction(CCMoveTo::create(1, CCPointMake(40,40))); } std::string ActionMove::subtitle() @@ -353,14 +353,14 @@ void ActionScale::onEnter() centerSprites(3); - CCActionInterval* actionTo = CCScaleTo::actionWithDuration( 2.0f, 0.5f); - CCActionInterval* actionBy = CCScaleBy::actionWithDuration(2.0f , 1.0f, 10.0f); - CCActionInterval* actionBy2 = CCScaleBy::actionWithDuration(2.0f, 5.0f, 1.0f); + CCActionInterval* actionTo = CCScaleTo::create( 2.0f, 0.5f); + CCActionInterval* actionBy = CCScaleBy::create(2.0f , 1.0f, 10.0f); + CCActionInterval* actionBy2 = CCScaleBy::create(2.0f, 5.0f, 1.0f); CCActionInterval* actionByBack = actionBy->reverse(); m_grossini->runAction( actionTo); - m_tamara->runAction( CCSequence::actions(actionBy, actionByBack->reverse(), NULL)); - m_kathia->runAction( CCSequence::actions(actionBy2, actionBy2->reverse(), NULL)); + m_tamara->runAction( CCSequence::create(actionBy, actionByBack->reverse(), NULL)); + m_kathia->runAction( CCSequence::create(actionBy2, actionBy2->reverse(), NULL)); } std::string ActionScale::subtitle() @@ -379,16 +379,16 @@ void ActionSkew::onEnter() centerSprites(3); - CCActionInterval *actionTo = CCSkewTo::actionWithDuration(2, 37.2f, -37.2f); - CCActionInterval *actionToBack = CCSkewTo::actionWithDuration(2, 0, 0); - CCActionInterval *actionBy = CCSkewBy::actionWithDuration(2, 0.0f, -90.0f); - CCActionInterval *actionBy2 = CCSkewBy::actionWithDuration(2, 45.0f, 45.0f); + CCActionInterval *actionTo = CCSkewTo::create(2, 37.2f, -37.2f); + CCActionInterval *actionToBack = CCSkewTo::create(2, 0, 0); + CCActionInterval *actionBy = CCSkewBy::create(2, 0.0f, -90.0f); + CCActionInterval *actionBy2 = CCSkewBy::create(2, 45.0f, 45.0f); CCActionInterval *actionByBack = actionBy->reverse(); - m_tamara->runAction(CCSequence::actions(actionTo, actionToBack, NULL)); - m_grossini->runAction(CCSequence::actions(actionBy, actionByBack, NULL)); + m_tamara->runAction(CCSequence::create(actionTo, actionToBack, NULL)); + m_grossini->runAction(CCSequence::create(actionBy, actionByBack, NULL)); - m_kathia->runAction(CCSequence::actions(actionBy2, actionBy2->reverse(), NULL)); + m_kathia->runAction(CCSequence::create(actionBy2, actionBy2->reverse(), NULL)); } string ActionSkew::subtitle() @@ -406,36 +406,36 @@ void ActionSkewRotateScale::onEnter() CCSize boxSize = CCSizeMake(100.0f, 100.0f); - CCLayerColor *box = CCLayerColor::layerWithColor(ccc4(255, 255, 0, 255)); + CCLayerColor *box = CCLayerColor::create(ccc4(255, 255, 0, 255)); box->setAnchorPoint(ccp(0, 0)); box->setPosition(ccp(190, 110)); box->setContentSize(boxSize); static float markrside = 10.0f; - CCLayerColor *uL = CCLayerColor::layerWithColor(ccc4(255, 0, 0, 255)); + CCLayerColor *uL = CCLayerColor::create(ccc4(255, 0, 0, 255)); box->addChild(uL); uL->setContentSize(CCSizeMake(markrside, markrside)); uL->setPosition(ccp(0.f, boxSize.height - markrside)); uL->setAnchorPoint(ccp(0, 0)); - CCLayerColor *uR = CCLayerColor::layerWithColor(ccc4(0, 0, 255, 255)); + CCLayerColor *uR = CCLayerColor::create(ccc4(0, 0, 255, 255)); box->addChild(uR); uR->setContentSize(CCSizeMake(markrside, markrside)); uR->setPosition(ccp(boxSize.width - markrside, boxSize.height - markrside)); uR->setAnchorPoint(ccp(0, 0)); addChild(box); - CCActionInterval *actionTo = CCSkewTo::actionWithDuration(2, 0.f, 2.f); - CCActionInterval *rotateTo = CCRotateTo::actionWithDuration(2, 61.0f); - CCActionInterval *actionScaleTo = CCScaleTo::actionWithDuration(2, -0.44f, 0.47f); + CCActionInterval *actionTo = CCSkewTo::create(2, 0.f, 2.f); + CCActionInterval *rotateTo = CCRotateTo::create(2, 61.0f); + CCActionInterval *actionScaleTo = CCScaleTo::create(2, -0.44f, 0.47f); - CCActionInterval *actionScaleToBack = CCScaleTo::actionWithDuration(2, 1.0f, 1.0f); - CCActionInterval *rotateToBack = CCRotateTo::actionWithDuration(2, 0); - CCActionInterval *actionToBack = CCSkewTo::actionWithDuration(2, 0, 0); + CCActionInterval *actionScaleToBack = CCScaleTo::create(2, 1.0f, 1.0f); + CCActionInterval *rotateToBack = CCRotateTo::create(2, 0); + CCActionInterval *actionToBack = CCSkewTo::create(2, 0, 0); - box->runAction(CCSequence::actions(actionTo, actionToBack, NULL)); - box->runAction(CCSequence::actions(rotateTo, rotateToBack, NULL)); - box->runAction(CCSequence::actions(actionScaleTo, actionScaleToBack, NULL)); + box->runAction(CCSequence::create(actionTo, actionToBack, NULL)); + box->runAction(CCSequence::create(rotateTo, rotateToBack, NULL)); + box->runAction(CCSequence::create(actionScaleTo, actionScaleToBack, NULL)); } string ActionSkewRotateScale::subtitle() @@ -454,16 +454,16 @@ void ActionRotate::onEnter() centerSprites(3); - CCActionInterval* actionTo = CCRotateTo::actionWithDuration( 2, 45); - CCActionInterval* actionTo2 = CCRotateTo::actionWithDuration( 2, -45); - CCActionInterval* actionTo0 = CCRotateTo::actionWithDuration(2 , 0); - m_tamara->runAction( CCSequence::actions(actionTo, actionTo0, NULL)); + CCActionInterval* actionTo = CCRotateTo::create( 2, 45); + CCActionInterval* actionTo2 = CCRotateTo::create( 2, -45); + CCActionInterval* actionTo0 = CCRotateTo::create(2 , 0); + m_tamara->runAction( CCSequence::create(actionTo, actionTo0, NULL)); - CCActionInterval* actionBy = CCRotateBy::actionWithDuration(2 , 360); + CCActionInterval* actionBy = CCRotateBy::create(2 , 360); CCActionInterval* actionByBack = actionBy->reverse(); - m_grossini->runAction( CCSequence::actions(actionBy, actionByBack, NULL)); + m_grossini->runAction( CCSequence::create(actionBy, actionByBack, NULL)); - m_kathia->runAction( CCSequence::actions(actionTo2, actionTo0->copy()->autorelease(), NULL)); + m_kathia->runAction( CCSequence::create(actionTo2, actionTo0->copy()->autorelease(), NULL)); } std::string ActionRotate::subtitle() @@ -482,14 +482,14 @@ void ActionJump::onEnter() centerSprites(3); - CCActionInterval* actionTo = CCJumpTo::actionWithDuration(2, CCPointMake(300,300), 50, 4); - CCActionInterval* actionBy = CCJumpBy::actionWithDuration(2, CCPointMake(300,0), 50, 4); - CCActionInterval* actionUp = CCJumpBy::actionWithDuration(2, CCPointMake(0,0), 80, 4); + CCActionInterval* actionTo = CCJumpTo::create(2, CCPointMake(300,300), 50, 4); + CCActionInterval* actionBy = CCJumpBy::create(2, CCPointMake(300,0), 50, 4); + CCActionInterval* actionUp = CCJumpBy::create(2, CCPointMake(0,0), 80, 4); CCActionInterval* actionByBack = actionBy->reverse(); m_tamara->runAction( actionTo); - m_grossini->runAction( CCSequence::actions(actionBy, actionByBack, NULL)); - m_kathia->runAction( CCRepeatForever::actionWithAction(actionUp)); + m_grossini->runAction( CCSequence::create(actionBy, actionByBack, NULL)); + m_kathia->runAction( CCRepeatForever::create(actionUp)); } std::string ActionJump::subtitle() { @@ -520,9 +520,9 @@ void ActionBezier::onEnter() bezier.controlPoint_2 = CCPointMake(300, -s.height/2); bezier.endPosition = CCPointMake(300,100); - CCActionInterval* bezierForward = CCBezierBy::actionWithDuration(3, bezier); + CCActionInterval* bezierForward = CCBezierBy::create(3, bezier); CCActionInterval* bezierBack = bezierForward->reverse(); - CCAction* rep = CCRepeatForever::actionWithAction((CCActionInterval*)CCSequence::actions( bezierForward, bezierBack, NULL)); + CCAction* rep = CCRepeatForever::create((CCActionInterval*)CCSequence::create( bezierForward, bezierBack, NULL)); // sprite 2 @@ -532,11 +532,11 @@ void ActionBezier::onEnter() bezier2.controlPoint_2 = CCPointMake(200, -s.height/2); bezier2.endPosition = CCPointMake(240,160); - CCActionInterval* bezierTo1 = CCBezierTo::actionWithDuration(2, bezier2); + CCActionInterval* bezierTo1 = CCBezierTo::create(2, bezier2); // sprite 3 m_kathia->setPosition(CCPointMake(400,160)); - CCActionInterval* bezierTo2 = CCBezierTo::actionWithDuration(2, bezier2); + CCActionInterval* bezierTo2 = CCBezierTo::create(2, bezier2); m_grossini->runAction( rep); m_tamara->runAction(bezierTo1); @@ -560,8 +560,8 @@ void ActionBlink::onEnter() centerSprites(2); - CCActionInterval* action1 = CCBlink::actionWithDuration(2, 10); - CCActionInterval* action2 = CCBlink::actionWithDuration(2, 5); + CCActionInterval* action1 = CCBlink::create(2, 10); + CCActionInterval* action2 = CCBlink::create(2, 5); m_tamara->runAction( action1); m_kathia->runAction(action2); @@ -584,14 +584,14 @@ void ActionFade::onEnter() centerSprites(2); m_tamara->setOpacity( 0 ); - CCActionInterval* action1 = CCFadeIn::actionWithDuration(1.0f); + CCActionInterval* action1 = CCFadeIn::create(1.0f); CCActionInterval* action1Back = action1->reverse(); - CCActionInterval* action2 = CCFadeOut::actionWithDuration(1.0f); + CCActionInterval* action2 = CCFadeOut::create(1.0f); CCActionInterval* action2Back = action2->reverse(); - m_tamara->runAction( CCSequence::actions( action1, action1Back, NULL)); - m_kathia->runAction( CCSequence::actions( action2, action2Back, NULL)); + m_tamara->runAction( CCSequence::create( action1, action1Back, NULL)); + m_kathia->runAction( CCSequence::create( action2, action2Back, NULL)); } std::string ActionFade::subtitle() @@ -611,12 +611,12 @@ void ActionTint::onEnter() centerSprites(2); - CCActionInterval* action1 = CCTintTo::actionWithDuration(2, 255, 0, 255); - CCActionInterval* action2 = CCTintBy::actionWithDuration(2, -127, -255, -127); + CCActionInterval* action1 = CCTintTo::create(2, 255, 0, 255); + CCActionInterval* action2 = CCTintBy::create(2, -127, -255, -127); CCActionInterval* action2Back = action2->reverse(); m_tamara->runAction( action1); - m_kathia->runAction( CCSequence::actions( action2, action2Back, NULL)); + m_kathia->runAction( CCSequence::create( action2, action2Back, NULL)); } std::string ActionTint::subtitle() @@ -638,7 +638,7 @@ void ActionAnimate::onEnter() // // Manual animation // - CCAnimation* animation = CCAnimation::animation(); + CCAnimation* animation = CCAnimation::create(); for( int i=1;i<15;i++) { char szName[100] = {0}; @@ -649,8 +649,8 @@ void ActionAnimate::onEnter() animation->setDelayPerUnit(2.8f / 14.0f); animation->setRestoreOriginalFrame(true); - CCAnimate* action = CCAnimate::actionWithAnimation(animation); - m_grossini->runAction(CCSequence::actions(action, action->reverse(), NULL)); + CCAnimate* action = CCAnimate::create(animation); + m_grossini->runAction(CCSequence::create(action, action->reverse(), NULL)); // @@ -661,8 +661,8 @@ void ActionAnimate::onEnter() cache->addAnimationsWithFile("animations/animations-2.plist"); CCAnimation *animation2 = cache->animationByName("dance_1"); - CCAnimate* action2 = CCAnimate::actionWithAnimation(animation2); - m_tamara->runAction(CCSequence::actions(action2, action2->reverse(), NULL)); + CCAnimate* action2 = CCAnimate::create(animation2); + m_tamara->runAction(CCSequence::create(action2, action2->reverse(), NULL)); // TODO: // observer_ = [[NSNotificationCenter defaultCenter] addObserverForName:CCAnimationFrameDisplayedNotification object:nil queue:nil usingBlock:^(NSNotification* notification) { @@ -680,7 +680,7 @@ void ActionAnimate::onEnter() animation3->setLoops(4); - CCAnimate* action3 = CCAnimate::actionWithAnimation(animation3); + CCAnimate* action3 = CCAnimate::create(animation3); m_kathia->runAction(action3); } @@ -711,9 +711,9 @@ void ActionSequence::onEnter() alignSpritesLeft(1); - CCFiniteTimeAction* action = CCSequence::actions( - CCMoveBy::actionWithDuration( 2, CCPointMake(240,0)), - CCRotateBy::actionWithDuration( 2, 540), + CCFiniteTimeAction* action = CCSequence::create( + CCMoveBy::create( 2, CCPointMake(240,0)), + CCRotateBy::create( 2, 540), NULL); m_grossini->runAction(action); @@ -737,13 +737,13 @@ void ActionSequence2::onEnter() m_grossini->setIsVisible(false); - CCFiniteTimeAction* action = CCSequence::actions( - CCPlace::actionWithPosition(CCPointMake(200,200)), - CCShow::action(), - CCMoveBy::actionWithDuration(1, CCPointMake(100,0)), - CCCallFunc::actionWithTarget(this, callfunc_selector(ActionSequence2::callback1)), - CCCallFuncN::actionWithTarget(this, callfuncN_selector(ActionSequence2::callback2)), - CCCallFuncND::actionWithTarget(this, callfuncND_selector(ActionSequence2::callback3), (void*)0xbebabeba), + CCFiniteTimeAction* action = CCSequence::create( + CCPlace::create(CCPointMake(200,200)), + CCShow::create(), + CCMoveBy::create(1, CCPointMake(100,0)), + CCCallFunc::create(this, callfunc_selector(ActionSequence2::callback1)), + CCCallFuncN::create(this, callfuncN_selector(ActionSequence2::callback2)), + CCCallFuncND::create(this, callfuncND_selector(ActionSequence2::callback3), (void*)0xbebabeba), NULL); m_grossini->runAction(action); @@ -752,7 +752,7 @@ void ActionSequence2::onEnter() void ActionSequence2::callback1() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF *label = CCLabelTTF::labelWithString("callback 1 called", "Marker Felt", 16); + CCLabelTTF *label = CCLabelTTF::create("callback 1 called", "Marker Felt", 16); label->setPosition(CCPointMake( s.width/4*1,s.height/2)); addChild(label); @@ -761,7 +761,7 @@ void ActionSequence2::callback1() void ActionSequence2::callback2(CCNode* sender) { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF *label = CCLabelTTF::labelWithString("callback 2 called", "Marker Felt", 16); + CCLabelTTF *label = CCLabelTTF::create("callback 2 called", "Marker Felt", 16); label->setPosition(CCPointMake( s.width/4*2,s.height/2)); addChild(label); @@ -770,7 +770,7 @@ void ActionSequence2::callback2(CCNode* sender) void ActionSequence2::callback3(CCNode* sender, void* data) { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF *label = CCLabelTTF::labelWithString("callback 3 called", "Marker Felt", 16); + CCLabelTTF *label = CCLabelTTF::create("callback 3 called", "Marker Felt", 16); label->setPosition(CCPointMake( s.width/4*3,s.height/2)); addChild(label); @@ -792,21 +792,21 @@ void ActionCallFunc::onEnter() centerSprites(3); - CCFiniteTimeAction* action = CCSequence::actions( - CCMoveBy::actionWithDuration(2, CCPointMake(200,0)), - CCCallFunc::actionWithTarget(this, callfunc_selector(ActionCallFunc::callback1)), + CCFiniteTimeAction* action = CCSequence::create( + CCMoveBy::create(2, CCPointMake(200,0)), + CCCallFunc::create(this, callfunc_selector(ActionCallFunc::callback1)), NULL); - CCFiniteTimeAction* action2 = CCSequence::actions( - CCScaleBy::actionWithDuration(2 , 2), - CCFadeOut::actionWithDuration(2), - CCCallFuncN::actionWithTarget(this, callfuncN_selector(ActionSequence2::callback2)), + CCFiniteTimeAction* action2 = CCSequence::create( + CCScaleBy::create(2 , 2), + CCFadeOut::create(2), + CCCallFuncN::create(this, callfuncN_selector(ActionSequence2::callback2)), NULL); - CCFiniteTimeAction* action3 = CCSequence::actions( - CCRotateBy::actionWithDuration(3 , 360), - CCFadeOut::actionWithDuration(2), - CCCallFuncND::actionWithTarget(this, callfuncND_selector(ActionSequence2::callback3), (void*)0xbebabeba), + CCFiniteTimeAction* action3 = CCSequence::create( + CCRotateBy::create(3 , 360), + CCFadeOut::create(2), + CCCallFuncND::create(this, callfuncND_selector(ActionSequence2::callback3), (void*)0xbebabeba), NULL); m_grossini->runAction(action); @@ -818,7 +818,7 @@ void ActionCallFunc::onEnter() void ActionCallFunc::callback1() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF *label = CCLabelTTF::labelWithString("callback 1 called", "Marker Felt", 16); + CCLabelTTF *label = CCLabelTTF::create("callback 1 called", "Marker Felt", 16); label->setPosition(CCPointMake( s.width/4*1,s.height/2)); addChild(label); @@ -827,7 +827,7 @@ void ActionCallFunc::callback1() void ActionCallFunc::callback2(CCNode* pSender) { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF *label = CCLabelTTF::labelWithString("callback 2 called", "Marker Felt", 16); + CCLabelTTF *label = CCLabelTTF::create("callback 2 called", "Marker Felt", 16); label->setPosition(CCPointMake( s.width/4*2,s.height/2)); addChild(label); @@ -836,7 +836,7 @@ void ActionCallFunc::callback2(CCNode* pSender) void ActionCallFunc::callback3(CCNode* pTarget, void* data) { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF *label = CCLabelTTF::labelWithString("callback 3 called", "Marker Felt", 16); + CCLabelTTF *label = CCLabelTTF::create("callback 3 called", "Marker Felt", 16); label->setPosition(CCPointMake( s.width/4*3,s.height/2)); addChild(label); } @@ -857,8 +857,8 @@ void ActionCallFuncND::onEnter() centerSprites(1); - CCFiniteTimeAction* action = CCSequence::actions(CCMoveBy::actionWithDuration(2.0f, ccp(200,0)), - CCCallFuncND::actionWithTarget(this, callfuncND_selector(ActionCallFuncND::removeFromParentAndCleanup), (void*)true), + CCFiniteTimeAction* action = CCSequence::create(CCMoveBy::create(2.0f, ccp(200,0)), + CCCallFuncND::create(this, callfuncND_selector(ActionCallFuncND::removeFromParentAndCleanup), (void*)true), NULL); m_grossini->runAction(action); @@ -893,9 +893,9 @@ void ActionSpawn::onEnter() alignSpritesLeft(1); - CCAction* action = CCSpawn::actions( - CCJumpBy::actionWithDuration(2, CCPointMake(300,0), 50, 4), - CCRotateBy::actionWithDuration( 2, 720), + CCAction* action = CCSpawn::create( + CCJumpBy::create(2, CCPointMake(300,0), 50, 4), + CCRotateBy::create( 2, 720), NULL); m_grossini->runAction(action); @@ -918,9 +918,9 @@ void ActionRepeatForever::onEnter() centerSprites(1); - CCFiniteTimeAction* action = CCSequence::actions( - CCDelayTime::actionWithDuration(1), - CCCallFuncN::actionWithTarget( this, callfuncN_selector(ActionRepeatForever::repeatForever) ), + CCFiniteTimeAction* action = CCSequence::create( + CCDelayTime::create(1), + CCCallFuncN::create( this, callfuncN_selector(ActionRepeatForever::repeatForever) ), NULL); m_grossini->runAction(action); @@ -928,7 +928,7 @@ void ActionRepeatForever::onEnter() void ActionRepeatForever::repeatForever(CCNode* pSender) { - CCRepeatForever *repeat = CCRepeatForever::actionWithAction( CCRotateBy::actionWithDuration(1.0f, 360) ); + CCRepeatForever *repeat = CCRepeatForever::create( CCRotateBy::create(1.0f, 360) ); pSender->runAction(repeat); } @@ -950,11 +950,11 @@ void ActionRotateToRepeat::onEnter() centerSprites(2); - CCActionInterval* act1 = CCRotateTo::actionWithDuration(1, 90); - CCActionInterval* act2 = CCRotateTo::actionWithDuration(1, 0); - CCActionInterval* seq = (CCActionInterval*)(CCSequence::actions(act1, act2, NULL)); - CCAction* rep1 = CCRepeatForever::actionWithAction(seq); - CCActionInterval* rep2 = CCRepeat::actionWithAction((CCFiniteTimeAction*)(seq->copy()->autorelease()), 10); + CCActionInterval* act1 = CCRotateTo::create(1, 90); + CCActionInterval* act2 = CCRotateTo::create(1, 0); + CCActionInterval* seq = (CCActionInterval*)(CCSequence::create(act1, act2, NULL)); + CCAction* rep1 = CCRepeatForever::create(seq); + CCActionInterval* rep2 = CCRepeat::create((CCFiniteTimeAction*)(seq->copy()->autorelease()), 10); m_tamara->runAction(rep1); m_kathia->runAction(rep2); @@ -977,13 +977,13 @@ void ActionRotateJerk::onEnter() centerSprites(2); - CCFiniteTimeAction* seq = CCSequence::actions( - CCRotateTo::actionWithDuration(0.5f, -20), - CCRotateTo::actionWithDuration(0.5f, 20), + CCFiniteTimeAction* seq = CCSequence::create( + CCRotateTo::create(0.5f, -20), + CCRotateTo::create(0.5f, 20), NULL); - CCActionInterval* rep1 = CCRepeat::actionWithAction(seq, 10); - CCAction* rep2 = CCRepeatForever::actionWithAction( (CCActionInterval*)(seq->copy()->autorelease()) ); + CCActionInterval* rep1 = CCRepeat::create(seq, 10); + CCAction* rep2 = CCRepeatForever::create( (CCActionInterval*)(seq->copy()->autorelease()) ); m_tamara->runAction(rep1); m_kathia->runAction(rep2); @@ -1005,8 +1005,8 @@ void ActionReverse::onEnter() alignSpritesLeft(1); - CCActionInterval* jump = CCJumpBy::actionWithDuration(2, CCPointMake(300,0), 50, 4); - CCFiniteTimeAction* action = CCSequence::actions( jump, jump->reverse(), NULL); + CCActionInterval* jump = CCJumpBy::create(2, CCPointMake(300,0), 50, 4); + CCFiniteTimeAction* action = CCSequence::create( jump, jump->reverse(), NULL); m_grossini->runAction(action); } @@ -1028,8 +1028,8 @@ void ActionDelayTime::onEnter() alignSpritesLeft(1); - CCActionInterval* move = CCMoveBy::actionWithDuration(1, CCPointMake(150,0)); - CCFiniteTimeAction* action = CCSequence::actions( move, CCDelayTime::actionWithDuration(2), move, NULL); + CCActionInterval* move = CCMoveBy::create(1, CCPointMake(150,0)); + CCFiniteTimeAction* action = CCSequence::create( move, CCDelayTime::create(2), move, NULL); m_grossini->runAction(action); } @@ -1051,10 +1051,10 @@ void ActionReverseSequence::onEnter() alignSpritesLeft(1); - CCActionInterval* move1 = CCMoveBy::actionWithDuration(1, CCPointMake(250,0)); - CCActionInterval* move2 = CCMoveBy::actionWithDuration(1, CCPointMake(0,50)); - CCFiniteTimeAction* seq = CCSequence::actions( move1, move2, move1->reverse(), NULL); - CCFiniteTimeAction* action = CCSequence::actions( seq, seq->reverse(), NULL); + CCActionInterval* move1 = CCMoveBy::create(1, CCPointMake(250,0)); + CCActionInterval* move2 = CCMoveBy::create(1, CCPointMake(0,50)); + CCFiniteTimeAction* seq = CCSequence::create( move1, move2, move1->reverse(), NULL); + CCFiniteTimeAction* action = CCSequence::create( seq, seq->reverse(), NULL); m_grossini->runAction(action); } @@ -1079,14 +1079,14 @@ void ActionReverseSequence2::onEnter() // Test: // Sequence should work both with IntervalAction and InstantActions - CCActionInterval* move1 = CCMoveBy::actionWithDuration(1, CCPointMake(250,0)); - CCActionInterval* move2 = CCMoveBy::actionWithDuration(1, CCPointMake(0,50)); + CCActionInterval* move1 = CCMoveBy::create(1, CCPointMake(250,0)); + CCActionInterval* move2 = CCMoveBy::create(1, CCPointMake(0,50)); CCToggleVisibility* tog1 = new CCToggleVisibility(); CCToggleVisibility* tog2 = new CCToggleVisibility(); tog1->autorelease(); tog2->autorelease(); - CCFiniteTimeAction* seq = CCSequence::actions( move1, tog1, move2, tog2, move1->reverse(), NULL); - CCActionInterval* action = CCRepeat::actionWithAction((CCActionInterval*)(CCSequence::actions( seq, seq->reverse(), NULL)), 3); + CCFiniteTimeAction* seq = CCSequence::create( move1, tog1, move2, tog2, move1->reverse(), NULL); + CCActionInterval* action = CCRepeat::create((CCActionInterval*)(CCSequence::create( seq, seq->reverse(), NULL)), 3); @@ -1094,13 +1094,13 @@ void ActionReverseSequence2::onEnter() // Also test that the reverse of Hide is Show, and vice-versa m_kathia->runAction(action); - CCActionInterval* move_tamara = CCMoveBy::actionWithDuration(1, CCPointMake(100,0)); - CCActionInterval* move_tamara2 = CCMoveBy::actionWithDuration(1, CCPointMake(50,0)); + CCActionInterval* move_tamara = CCMoveBy::create(1, CCPointMake(100,0)); + CCActionInterval* move_tamara2 = CCMoveBy::create(1, CCPointMake(50,0)); CCActionInstant* hide = new CCHide(); hide->autorelease(); - CCFiniteTimeAction* seq_tamara = CCSequence::actions( move_tamara, hide, move_tamara2, NULL); + CCFiniteTimeAction* seq_tamara = CCSequence::create( move_tamara, hide, move_tamara2, NULL); CCFiniteTimeAction* seq_back = seq_tamara->reverse(); - m_tamara->runAction( CCSequence::actions( seq_tamara, seq_back, NULL)); + m_tamara->runAction( CCSequence::create( seq_tamara, seq_back, NULL)); } std::string ActionReverseSequence2::subtitle() { @@ -1119,12 +1119,12 @@ void ActionRepeat::onEnter() alignSpritesLeft(2); - CCActionInterval* a1 = CCMoveBy::actionWithDuration(1, CCPointMake(150,0)); - CCActionInterval* action1 = CCRepeat::actionWithAction( - CCSequence::actions( CCPlace::actionWithPosition(CCPointMake(60,60)), a1, NULL) , + CCActionInterval* a1 = CCMoveBy::create(1, CCPointMake(150,0)); + CCActionInterval* action1 = CCRepeat::create( + CCSequence::create( CCPlace::create(CCPointMake(60,60)), a1, NULL) , 3); - CCAction* action2 = CCRepeatForever::actionWithAction( - (CCActionInterval*)(CCSequence::actions((CCActionInterval*)(a1->copy()->autorelease()), a1->reverse(), NULL)) + CCAction* action2 = CCRepeatForever::create( + (CCActionInterval*)(CCSequence::create((CCActionInterval*)(a1->copy()->autorelease()), a1->reverse(), NULL)) ); m_kathia->runAction(action1); @@ -1147,32 +1147,32 @@ void ActionOrbit::onEnter() centerSprites(3); - CCActionInterval* orbit1 = CCOrbitCamera::actionWithDuration(2,1, 0, 0, 180, 0, 0); - CCFiniteTimeAction* action1 = CCSequence::actions( + CCActionInterval* orbit1 = CCOrbitCamera::create(2,1, 0, 0, 180, 0, 0); + CCFiniteTimeAction* action1 = CCSequence::create( orbit1, orbit1->reverse(), NULL); - CCActionInterval* orbit2 = CCOrbitCamera::actionWithDuration(2,1, 0, 0, 180, -45, 0); - CCFiniteTimeAction* action2 = CCSequence::actions( + CCActionInterval* orbit2 = CCOrbitCamera::create(2,1, 0, 0, 180, -45, 0); + CCFiniteTimeAction* action2 = CCSequence::create( orbit2, orbit2->reverse(), NULL); - CCActionInterval* orbit3 = CCOrbitCamera::actionWithDuration(2,1, 0, 0, 180, 90, 0); - CCFiniteTimeAction* action3 = CCSequence::actions( + CCActionInterval* orbit3 = CCOrbitCamera::create(2,1, 0, 0, 180, 90, 0); + CCFiniteTimeAction* action3 = CCSequence::create( orbit3, orbit3->reverse(), NULL); - m_kathia->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)action1)); - m_tamara->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)action2)); - m_grossini->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)action3)); + m_kathia->runAction(CCRepeatForever::create((CCActionInterval*)action1)); + m_tamara->runAction(CCRepeatForever::create((CCActionInterval*)action2)); + m_grossini->runAction(CCRepeatForever::create((CCActionInterval*)action3)); - CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(100,-100)); + CCActionInterval* move = CCMoveBy::create(3, CCPointMake(100,-100)); CCActionInterval* move_back = move->reverse(); - CCFiniteTimeAction* seq = CCSequence::actions(move, move_back, NULL); - CCAction* rfe = CCRepeatForever::actionWithAction((CCActionInterval*)seq); + CCFiniteTimeAction* seq = CCSequence::create(move, move_back, NULL); + CCAction* rfe = CCRepeatForever::create((CCActionInterval*)seq); m_kathia->runAction(rfe); m_tamara->runAction((CCAction*)(rfe->copy()->autorelease())); m_grossini->runAction((CCAction*)(rfe->copy()->autorelease())); @@ -1196,14 +1196,14 @@ void ActionFollow::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); m_grossini->setPosition(CCPointMake(-200, s.height / 2)); - CCActionInterval* move = CCMoveBy::actionWithDuration(2, CCPointMake(s.width * 3, 0)); + CCActionInterval* move = CCMoveBy::create(2, CCPointMake(s.width * 3, 0)); CCActionInterval* move_back = move->reverse(); - CCFiniteTimeAction* seq = CCSequence::actions(move, move_back, NULL); - CCAction* rep = CCRepeatForever::actionWithAction((CCActionInterval*)seq); + CCFiniteTimeAction* seq = CCSequence::create(move, move_back, NULL); + CCAction* rep = CCRepeatForever::create((CCActionInterval*)seq); m_grossini->runAction(rep); - this->runAction(CCFollow::actionWithTarget(m_grossini, CCRectMake(0, 0, s.width * 2 - 100, s.height))); + this->runAction(CCFollow::create(m_grossini, CCRectMake(0, 0, s.width * 2 - 100, s.height))); } std::string ActionFollow::subtitle() @@ -1217,17 +1217,17 @@ void ActionTargeted::onEnter() centerSprites(2); - CCJumpBy* jump1 = CCJumpBy::actionWithDuration(2,CCPointZero,100,3); + CCJumpBy* jump1 = CCJumpBy::create(2,CCPointZero,100,3); CCJumpBy* jump2 = (CCJumpBy*)jump1->copy()->autorelease(); - CCRotateBy* rot1 = CCRotateBy::actionWithDuration(1, 360); + CCRotateBy* rot1 = CCRotateBy::create(1, 360); CCRotateBy* rot2 = (CCRotateBy*)rot1->copy()->autorelease(); - CCTargetedAction *t1 = CCTargetedAction::actionWithTarget(m_kathia, jump2); - CCTargetedAction *t2 = CCTargetedAction::actionWithTarget(m_kathia, rot2); + CCTargetedAction *t1 = CCTargetedAction::create(m_kathia, jump2); + CCTargetedAction *t2 = CCTargetedAction::create(m_kathia, rot2); - CCSequence* seq = (CCSequence*)CCSequence::actions(jump1, t1, rot1, t2, NULL); - CCRepeatForever *always = CCRepeatForever::actionWithAction(seq); + CCSequence* seq = (CCSequence*)CCSequence::create(jump1, t1, rot1, t2, NULL); + CCRepeatForever *always = CCRepeatForever::create(seq); m_tamara->runAction(always); } @@ -1247,14 +1247,14 @@ void Issue1305::onEnter() ActionsDemo::onEnter(); centerSprites(0); - m_pSpriteTmp = CCSprite::spriteWithFile("Images/grossini.png"); + m_pSpriteTmp = CCSprite::create("Images/grossini.png"); /* c++ can't support block, so we use CCCallFuncN instead. [spriteTmp_ runAction:[CCCallBlockN actionWithBlock:^(CCNode* node) { NSLog(@"This message SHALL ONLY appear when the sprite is added to the scene, NOT BEFORE"); }] ]; */ - m_pSpriteTmp->runAction(CCCallFuncN::actionWithTarget(this, callfuncN_selector(Issue1305::log))); + m_pSpriteTmp->runAction(CCCallFuncN::create(this, callfuncN_selector(Issue1305::log))); m_pSpriteTmp->retain(); scheduleOnce(schedule_selector(Issue1305::addSprite), 2); @@ -1292,38 +1292,38 @@ void Issue1305_2::onEnter() ActionsDemo::onEnter(); centerSprites(0); - CCSprite *spr = CCSprite::spriteWithFile("Images/grossini.png"); + CCSprite *spr = CCSprite::create("Images/grossini.png"); spr->setPosition(ccp(200,200)); addChild(spr); - CCMoveBy* act1 = CCMoveBy::actionWithDuration(2 ,ccp(0, 100)); + CCMoveBy* act1 = CCMoveBy::create(2 ,ccp(0, 100)); /* c++ can't support block, so we use CCCallFuncN instead. id act2 = [CCCallBlock actionWithBlock:^{ NSLog(@"1st block"); }]; - id act3 = [CCMoveBy actionWithDuration:2 position:ccp(0, -100)]; + id act3 = [CCMoveBy create:2 position:ccp(0, -100)]; id act4 = [CCCallBlock actionWithBlock:^{ NSLog(@"2nd block"); }]; - id act5 = [CCMoveBy actionWithDuration:2 position:ccp(100, -100)]; + id act5 = [CCMoveBy create:2 position:ccp(100, -100)]; id act6 = [CCCallBlock actionWithBlock:^{ NSLog(@"3rd block"); }]; - id act7 = [CCMoveBy actionWithDuration:2 position:ccp(-100, 0)]; + id act7 = [CCMoveBy create:2 position:ccp(-100, 0)]; id act8 = [CCCallBlock actionWithBlock:^{ NSLog(@"4th block"); }]; */ - CCCallFunc* act2 = CCCallFunc::actionWithTarget(this, callfunc_selector(Issue1305_2::log1)) ; - CCMoveBy* act3 = CCMoveBy::actionWithDuration(2, ccp(0, -100)); - CCCallFunc* act4 = CCCallFunc::actionWithTarget(this, callfunc_selector(Issue1305_2::log2)) ; - CCMoveBy* act5 = CCMoveBy::actionWithDuration(2, ccp(100, -100)); - CCCallFunc* act6 = CCCallFunc::actionWithTarget(this, callfunc_selector(Issue1305_2::log3)) ; - CCMoveBy* act7 = CCMoveBy::actionWithDuration(2, ccp(-100, 0)); - CCCallFunc* act8 = CCCallFunc::actionWithTarget(this, callfunc_selector(Issue1305_2::log4)) ; + CCCallFunc* act2 = CCCallFunc::create(this, callfunc_selector(Issue1305_2::log1)) ; + CCMoveBy* act3 = CCMoveBy::create(2, ccp(0, -100)); + CCCallFunc* act4 = CCCallFunc::create(this, callfunc_selector(Issue1305_2::log2)) ; + CCMoveBy* act5 = CCMoveBy::create(2, ccp(100, -100)); + CCCallFunc* act6 = CCCallFunc::create(this, callfunc_selector(Issue1305_2::log3)) ; + CCMoveBy* act7 = CCMoveBy::create(2, ccp(-100, 0)); + CCCallFunc* act8 = CCCallFunc::create(this, callfunc_selector(Issue1305_2::log4)) ; - CCFiniteTimeAction* actF = CCSequence::actions(act1, act2, act3, act4, act5, act6, act7, act8, NULL); + CCFiniteTimeAction* actF = CCSequence::create(act1, act2, act3, act4, act5, act6, act7, act8, NULL); // [spr runAction:actF]; CCDirector::sharedDirector()->getActionManager()->addAction(actF ,spr, false); @@ -1365,14 +1365,14 @@ void Issue1288::onEnter() ActionsDemo::onEnter(); centerSprites(0); - CCSprite *spr = CCSprite::spriteWithFile("Images/grossini.png"); + CCSprite *spr = CCSprite::create("Images/grossini.png"); spr->setPosition(ccp(100, 100)); addChild(spr); - CCMoveBy* act1 = CCMoveBy::actionWithDuration(0.5, ccp(100, 0)); + CCMoveBy* act1 = CCMoveBy::create(0.5, ccp(100, 0)); CCMoveBy* act2 = (CCMoveBy*)act1->reverse(); - CCFiniteTimeAction* act3 = CCSequence::actions(act1, act2, NULL); - CCRepeat* act4 = CCRepeat::actionWithAction(act3, 2); + CCFiniteTimeAction* act3 = CCSequence::create(act1, act2, NULL); + CCRepeat* act4 = CCRepeat::create(act3, 2); spr->runAction(act4); } @@ -1392,12 +1392,12 @@ void Issue1288_2::onEnter() ActionsDemo::onEnter(); centerSprites(0); - CCSprite *spr = CCSprite::spriteWithFile("Images/grossini.png"); + CCSprite *spr = CCSprite::create("Images/grossini.png"); spr->setPosition(ccp(100, 100)); addChild(spr); - CCMoveBy* act1 = CCMoveBy::actionWithDuration(0.5, ccp(100, 0)); - spr->runAction(CCRepeat::actionWithAction(act1, 1)); + CCMoveBy* act1 = CCMoveBy::create(0.5, ccp(100, 0)); + spr->runAction(CCRepeat::create(act1, 1)); } std::string Issue1288_2::title() @@ -1416,21 +1416,21 @@ void Issue1327::onEnter() ActionsDemo::onEnter(); centerSprites(0); - CCSprite *spr = CCSprite::spriteWithFile("Images/grossini.png"); + CCSprite *spr = CCSprite::create("Images/grossini.png"); spr->setPosition(ccp(100, 100)); addChild(spr); - CCCallFuncN* act1 = CCCallFuncN::actionWithTarget(this, callfuncN_selector(Issue1327::logSprRotation)); - CCRotateBy* act2 = CCRotateBy::actionWithDuration(0.25, 45); - CCCallFuncN* act3 = CCCallFuncN::actionWithTarget(this, callfuncN_selector(Issue1327::logSprRotation)); - CCRotateBy* act4 = CCRotateBy::actionWithDuration(0.25, 45); - CCCallFuncN* act5 = CCCallFuncN::actionWithTarget(this, callfuncN_selector(Issue1327::logSprRotation)); - CCRotateBy* act6 = CCRotateBy::actionWithDuration(0.25, 45); - CCCallFuncN* act7 = CCCallFuncN::actionWithTarget(this, callfuncN_selector(Issue1327::logSprRotation)); - CCRotateBy* act8 = CCRotateBy::actionWithDuration(0.25, 45); - CCCallFuncN* act9 = CCCallFuncN::actionWithTarget(this, callfuncN_selector(Issue1327::logSprRotation)); + CCCallFuncN* act1 = CCCallFuncN::create(this, callfuncN_selector(Issue1327::logSprRotation)); + CCRotateBy* act2 = CCRotateBy::create(0.25, 45); + CCCallFuncN* act3 = CCCallFuncN::create(this, callfuncN_selector(Issue1327::logSprRotation)); + CCRotateBy* act4 = CCRotateBy::create(0.25, 45); + CCCallFuncN* act5 = CCCallFuncN::create(this, callfuncN_selector(Issue1327::logSprRotation)); + CCRotateBy* act6 = CCRotateBy::create(0.25, 45); + CCCallFuncN* act7 = CCCallFuncN::create(this, callfuncN_selector(Issue1327::logSprRotation)); + CCRotateBy* act8 = CCRotateBy::create(0.25, 45); + CCCallFuncN* act9 = CCCallFuncN::create(this, callfuncN_selector(Issue1327::logSprRotation)); - CCFiniteTimeAction* actF = CCSequence::actions(act1, act2, act3, act4, act5, act6, act7, act8, act9, NULL); + CCFiniteTimeAction* actF = CCSequence::create(act1, act2, act3, act4, act5, act6, act7, act8, act9, NULL); spr->runAction(actF); } @@ -1468,7 +1468,7 @@ void ActionCatmullRom::onEnter() m_tamara->setPosition(ccp(50, 50)); - CCPointArray *array = CCPointArray::arrayWithCapacity(20); + CCPointArray *array = CCPointArray::create(20); array->addControlPoint(ccp(0, 0)); array->addControlPoint(ccp(80, 80)); @@ -1478,10 +1478,10 @@ void ActionCatmullRom::onEnter() array->addControlPoint(ccp(80, 80)); array->addControlPoint(ccp(s.width / 2, s.height / 2)); - CCCatmullRomBy *action = CCCatmullRomBy::actionWithDuration(3, array); + CCCatmullRomBy *action = CCCatmullRomBy::create(3, array); CCFiniteTimeAction *reverse = action->reverse(); - CCFiniteTimeAction *seq = CCSequence::actions(action, reverse, NULL); + CCFiniteTimeAction *seq = CCSequence::create(action, reverse, NULL); m_tamara->runAction(seq); @@ -1493,7 +1493,7 @@ void ActionCatmullRom::onEnter() // The initial position will be the 1st point of the Catmull Rom path // - CCPointArray *array2 = CCPointArray::arrayWithCapacity(20); + CCPointArray *array2 = CCPointArray::create(20); array2->addControlPoint(ccp(s.width / 2, 30)); array2->addControlPoint(ccp(s.width -80, 30)); @@ -1501,10 +1501,10 @@ void ActionCatmullRom::onEnter() array2->addControlPoint(ccp(s.width / 2, s.height - 80)); array2->addControlPoint(ccp(s.width / 2, 30)); - CCCatmullRomTo *action2 = CCCatmullRomTo::actionWithDuration(3, array2); + CCCatmullRomTo *action2 = CCCatmullRomTo::create(3, array2); CCFiniteTimeAction *reverse2 = action2->reverse(); - CCFiniteTimeAction *seq2 = CCSequence::actions(action2, reverse2, NULL); + CCFiniteTimeAction *seq2 = CCSequence::create(action2, reverse2, NULL); m_kathia->runAction(seq2); @@ -1553,7 +1553,7 @@ void ActionCardinalSpline::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCPointArray *array = CCPointArray::arrayWithCapacity(20); + CCPointArray *array = CCPointArray::create(20); array->addControlPoint(ccp(0, 0)); array->addControlPoint(ccp(s.width/2-30, 0)); @@ -1567,10 +1567,10 @@ void ActionCardinalSpline::onEnter() // Spline with no tension (tension==0) // - CCCardinalSplineBy *action = CCCardinalSplineBy::actionWithDuration(3, array, 0); + CCCardinalSplineBy *action = CCCardinalSplineBy::create(3, array, 0); CCActionInterval *reverse = action->reverse(); - CCFiniteTimeAction *seq = CCSequence::actions(action, reverse, NULL); + CCFiniteTimeAction *seq = CCSequence::create(action, reverse, NULL); m_tamara->setPosition(ccp(50, 50)); m_tamara->runAction(seq); @@ -1581,10 +1581,10 @@ void ActionCardinalSpline::onEnter() // Spline with high tension (tension==1) // - CCCardinalSplineBy *action2 = CCCardinalSplineBy::actionWithDuration(3, array, 1); + CCCardinalSplineBy *action2 = CCCardinalSplineBy::create(3, array, 1); CCActionInterval *reverse2 = action2->reverse(); - CCFiniteTimeAction *seq2 = CCSequence::actions(action2, reverse2, NULL); + CCFiniteTimeAction *seq2 = CCSequence::create(action2, reverse2, NULL); m_kathia->setPosition(ccp(s.width/2, 50)); m_kathia->runAction(seq2); @@ -1634,9 +1634,9 @@ void PauseResumeActions::onEnter() this->centerSprites(2); - m_tamara->runAction(CCRepeatForever::actionWithAction(CCRotateBy::actionWithDuration(3, 360))); - m_grossini->runAction(CCRepeatForever::actionWithAction(CCRotateBy::actionWithDuration(3, -360))); - m_kathia->runAction(CCRepeatForever::actionWithAction(CCRotateBy::actionWithDuration(3, 360))); + m_tamara->runAction(CCRepeatForever::create(CCRotateBy::create(3, 360))); + m_grossini->runAction(CCRepeatForever::create(CCRotateBy::create(3, -360))); + m_kathia->runAction(CCRepeatForever::create(CCRotateBy::create(3, 360))); this->schedule(schedule_selector(PauseResumeActions::pause), 3, false, 0); this->schedule(schedule_selector(PauseResumeActions::resume), 5, false, 0); diff --git a/tests/tests/Box2DTest/Box2dTest.cpp b/tests/tests/Box2DTest/Box2dTest.cpp index 1211366201..b74632336c 100644 --- a/tests/tests/Box2DTest/Box2dTest.cpp +++ b/tests/tests/Box2DTest/Box2dTest.cpp @@ -72,19 +72,19 @@ Box2DTestLayer::Box2DTestLayer() //Set up sprite #if 1 // Use batch node. Faster - CCSpriteBatchNode *parent = CCSpriteBatchNode::batchNodeWithFile("Images/blocks.png", 100); + CCSpriteBatchNode *parent = CCSpriteBatchNode::create("Images/blocks.png", 100); m_pSpriteTexture = parent->getTexture(); #else // doesn't use batch node. Slower m_pSpriteTexture = CCTextureCache::sharedTextureCache()->addImage("Images/blocks.png"); - CCNode *parent = CCNode::node(); + CCNode *parent = CCNode::create(); #endif addChild(parent, 0, kTagParentNode); addNewSpriteAtPosition(ccp(s.width/2, s.height/2)); - CCLabelTTF *label = CCLabelTTF::labelWithString("Tap screen", "Marker Felt", 32); + CCLabelTTF *label = CCLabelTTF::create("Tap screen", "Marker Felt", 32); addChild(label, 0); label->setColor(ccc3(0,0,255)); label->setPosition(ccp( s.width/2, s.height-50)); @@ -158,9 +158,9 @@ void Box2DTestLayer::initPhysics() void Box2DTestLayer::createResetButton() { - CCMenuItemImage *reset = CCMenuItemImage::itemWithNormalImage("Images/r1.png", "Images/r2.png", this, menu_selector(Box2DTestLayer::reset)); + CCMenuItemImage *reset = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", this, menu_selector(Box2DTestLayer::reset)); - CCMenu *menu = CCMenu::menuWithItems(reset, NULL); + CCMenu *menu = CCMenu::create(reset, NULL); CCSize s = CCDirector::sharedDirector()->getWinSize(); diff --git a/tests/tests/Box2DTestBed/Box2dView.cpp b/tests/tests/Box2DTestBed/Box2dView.cpp index 0ac3284864..24e1f909be 100644 --- a/tests/tests/Box2DTestBed/Box2dView.cpp +++ b/tests/tests/Box2DTestBed/Box2dView.cpp @@ -58,18 +58,18 @@ bool MenuLayer::initWithEntryID(int entryId) view->setAnchorPoint( ccp(0,0) ); view->setPosition( ccp(s.width/2, s.height/3) ); //#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE) -// CCLabelBMFont* label = CCLabelBMFont::labelWithString(view->title().c_str(), "fonts/arial16.fnt"); +// CCLabelBMFont* label = CCLabelBMFont::create(view->title().c_str(), "fonts/arial16.fnt"); //#else - CCLabelTTF* label = CCLabelTTF::labelWithString(view->title().c_str(), "Arial", 28); + CCLabelTTF* label = CCLabelTTF::create(view->title().c_str(), "Arial", 28); //#endif addChild(label, 1); label->setPosition( ccp(s.width/2, s.height-50) ); - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage("Images/b1.png", "Images/b2.png", this, menu_selector(MenuLayer::backCallback) ); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage("Images/r1.png","Images/r2.png", this, menu_selector(MenuLayer::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage("Images/f1.png", "Images/f2.png", this, menu_selector(MenuLayer::nextCallback) ); + CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(MenuLayer::backCallback) ); + CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png","Images/r2.png", this, menu_selector(MenuLayer::restartCallback) ); + CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(MenuLayer::nextCallback) ); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition( CCPointZero ); item1->setPosition( ccp( s.width/2 - 100,30) ); diff --git a/tests/tests/BugsTest/Bug-1159.cpp b/tests/tests/BugsTest/Bug-1159.cpp index 8805514228..8cdc4bfb7f 100644 --- a/tests/tests/BugsTest/Bug-1159.cpp +++ b/tests/tests/BugsTest/Bug-1159.cpp @@ -11,8 +11,8 @@ CCScene* Bug1159Layer::scene() { - CCScene *pScene = CCScene::node(); - Bug1159Layer* layer = Bug1159Layer::node(); + CCScene *pScene = CCScene::create(); + Bug1159Layer* layer = Bug1159Layer::create(); pScene->addChild(layer); return pScene; @@ -24,28 +24,28 @@ bool Bug1159Layer::init() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLayerColor *background = CCLayerColor::layerWithColor(ccc4(255, 0, 255, 255)); + CCLayerColor *background = CCLayerColor::create(ccc4(255, 0, 255, 255)); addChild(background); - CCLayerColor *sprite_a = CCLayerColor::layerWithColor(ccc4(255, 0, 0, 255), 700, 700); + CCLayerColor *sprite_a = CCLayerColor::create(ccc4(255, 0, 0, 255), 700, 700); sprite_a->setAnchorPoint(ccp(0.5f, 0.5f)); sprite_a->setIgnoreAnchorPointForPosition(false); sprite_a->setPosition(ccp(0.0f, s.height/2)); addChild(sprite_a); - sprite_a->runAction(CCRepeatForever::actionWithAction((CCActionInterval*) CCSequence::actions( - CCMoveTo::actionWithDuration(1.0f, ccp(1024.0f, 384.0f)), - CCMoveTo::actionWithDuration(1.0f, ccp(0.0f, 384.0f)), + sprite_a->runAction(CCRepeatForever::create((CCActionInterval*) CCSequence::create( + CCMoveTo::create(1.0f, ccp(1024.0f, 384.0f)), + CCMoveTo::create(1.0f, ccp(0.0f, 384.0f)), NULL))); - CCLayerColor *sprite_b = CCLayerColor::layerWithColor(ccc4(0, 0, 255, 255), 400, 400); + CCLayerColor *sprite_b = CCLayerColor::create(ccc4(0, 0, 255, 255), 400, 400); sprite_b->setAnchorPoint(ccp(0.5f, 0.5f)); sprite_b->setIgnoreAnchorPointForPosition(false); sprite_b->setPosition(ccp(s.width/2, s.height/2)); addChild(sprite_b); - CCMenuItemLabel *label = CCMenuItemLabel::itemWithLabel(CCLabelTTF::labelWithString("Flip Me", "Helvetica", 24), this, menu_selector(Bug1159Layer::callBack)); - CCMenu *menu = CCMenu::menuWithItems(label, NULL); + CCMenuItemLabel *label = CCMenuItemLabel::create(CCLabelTTF::create("Flip Me", "Helvetica", 24), this, menu_selector(Bug1159Layer::callBack)); + CCMenu *menu = CCMenu::create(label, NULL); menu->setPosition(ccp(s.width - 200.0f, 50.0f)); addChild(menu); @@ -57,5 +57,5 @@ bool Bug1159Layer::init() void Bug1159Layer::callBack(CCObject* pSender) { - CCDirector::sharedDirector()->replaceScene(CCTransitionPageTurn::transitionWithDuration(1.0f, Bug1159Layer::scene(), false)); + CCDirector::sharedDirector()->replaceScene(CCTransitionPageTurn::create(1.0f, Bug1159Layer::scene(), false)); } diff --git a/tests/tests/BugsTest/Bug-1159.h b/tests/tests/BugsTest/Bug-1159.h index aaebb88bed..f4b87e402c 100644 --- a/tests/tests/BugsTest/Bug-1159.h +++ b/tests/tests/BugsTest/Bug-1159.h @@ -10,7 +10,7 @@ public: static CCScene* scene(); void callBack(CCObject* pSender); - LAYER_NODE_FUNC(Bug1159Layer); + LAYER_CREATE_FUNC(Bug1159Layer); }; #endif // __BUG_1159_H__ diff --git a/tests/tests/BugsTest/Bug-350.cpp b/tests/tests/BugsTest/Bug-350.cpp index 5779ffa7aa..d9cff8ac47 100644 --- a/tests/tests/BugsTest/Bug-350.cpp +++ b/tests/tests/BugsTest/Bug-350.cpp @@ -10,7 +10,7 @@ bool Bug350Layer::init() if (BugsTestBaseLayer::init()) { CCSize size = CCDirector::sharedDirector()->getWinSize(); - CCSprite *background = CCSprite::spriteWithFile("Hello.png"); + CCSprite *background = CCSprite::create("Hello.png"); background->setPosition(ccp(size.width/2, size.height/2)); addChild(background); return true; diff --git a/tests/tests/BugsTest/Bug-422.cpp b/tests/tests/BugsTest/Bug-422.cpp index ee195fd9b0..317d06031e 100644 --- a/tests/tests/BugsTest/Bug-422.cpp +++ b/tests/tests/BugsTest/Bug-422.cpp @@ -31,10 +31,10 @@ void Bug422Layer::reset() removeChild(node, false); // [self removeChildByTag:localtag-1 cleanup:NO]; - CCMenuItem *item1 = CCMenuItemFont::itemWithString("One", this, menu_selector(Bug422Layer::menuCallback)); + CCMenuItem *item1 = CCMenuItemFont::create("One", this, menu_selector(Bug422Layer::menuCallback)); CCLog("MenuItemFont: %p", item1); - CCMenuItem *item2 = CCMenuItemFont::itemWithString("Two", this, menu_selector(Bug422Layer::menuCallback)); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, NULL); + CCMenuItem *item2 = CCMenuItemFont::create("Two", this, menu_selector(Bug422Layer::menuCallback)); + CCMenu *menu = CCMenu::create(item1, item2, NULL); menu->alignItemsVertically(); float x = CCRANDOM_0_1() * 50; diff --git a/tests/tests/BugsTest/Bug-458/Bug-458.cpp b/tests/tests/BugsTest/Bug-458/Bug-458.cpp index edacb8118e..5f513f2fdf 100644 --- a/tests/tests/BugsTest/Bug-458/Bug-458.cpp +++ b/tests/tests/BugsTest/Bug-458/Bug-458.cpp @@ -21,14 +21,14 @@ bool Bug458Layer::init() // [question setContentSize:CGSizeMake(50,50)]; // [question2 setContentSize:CGSizeMake(50,50)]; - CCMenuItemSprite* sprite = CCMenuItemSprite::itemWithNormalSprite(question2, question, this, menu_selector(Bug458Layer::selectAnswer)); - CCLayerColor* layer = CCLayerColor::layerWithColor(ccc4(0,0,255,255), 100, 100); + CCMenuItemSprite* sprite = CCMenuItemSprite::create(question2, question, this, menu_selector(Bug458Layer::selectAnswer)); + CCLayerColor* layer = CCLayerColor::create(ccc4(0,0,255,255), 100, 100); question->release(); question2->release(); - CCLayerColor* layer2 = CCLayerColor::layerWithColor(ccc4(255,0,0,255), 100, 100); - CCMenuItemSprite* sprite2 = CCMenuItemSprite::itemWithNormalSprite(layer, layer2, this, menu_selector(Bug458Layer::selectAnswer)); - CCMenu* menu = CCMenu::menuWithItems(sprite, sprite2, NULL); + CCLayerColor* layer2 = CCLayerColor::create(ccc4(255,0,0,255), 100, 100); + CCMenuItemSprite* sprite2 = CCMenuItemSprite::create(layer, layer2, this, menu_selector(Bug458Layer::selectAnswer)); + CCMenu* menu = CCMenu::create(sprite, sprite2, NULL); menu->alignItemsVerticallyWithPadding(100); menu->setPosition(ccp(size.width / 2, size.height / 2)); diff --git a/tests/tests/BugsTest/Bug-458/QuestionContainerSprite.cpp b/tests/tests/BugsTest/Bug-458/QuestionContainerSprite.cpp index aaebb986da..33876b5c44 100644 --- a/tests/tests/BugsTest/Bug-458/QuestionContainerSprite.cpp +++ b/tests/tests/BugsTest/Bug-458/QuestionContainerSprite.cpp @@ -9,16 +9,16 @@ bool QuestionContainerSprite::init() if (CCSprite::init()) { //Add label - CCLabelTTF* label = CCLabelTTF::labelWithString("Answer 1", "Arial", 12); + CCLabelTTF* label = CCLabelTTF::create("Answer 1", "Arial", 12); label->setTag(100); //Add the background CCSize size = CCDirector::sharedDirector()->getWinSize(); - CCSprite* corner = CCSprite::spriteWithFile("Images/bugs/corner.png"); + CCSprite* corner = CCSprite::create("Images/bugs/corner.png"); int width = size.width * 0.9f - (corner->getContentSize().width * 2); int height = size.height * 0.15f - (corner->getContentSize().height * 2); - CCLayerColor* layer = CCLayerColor::layerWithColor(ccc4(255, 255, 255, 255 * .75), width, height); + CCLayerColor* layer = CCLayerColor::create(ccc4(255, 255, 255, 255 * .75), width, height); layer->setPosition(ccp(-width / 2, -height / 2)); //First button is blue, @@ -39,40 +39,40 @@ bool QuestionContainerSprite::init() corner->setPosition(ccp(-(width / 2 + corner->getContentSize().width / 2), -(height / 2 + corner->getContentSize().height / 2))); addChild(corner); - CCSprite* corner2 = CCSprite::spriteWithFile("Images/bugs/corner.png"); + CCSprite* corner2 = CCSprite::create("Images/bugs/corner.png"); corner2->setPosition(ccp(-corner->getPosition().x, corner->getPosition().y)); corner2->setFlipX(true); addChild(corner2); - CCSprite* corner3 = CCSprite::spriteWithFile("Images/bugs/corner.png"); + CCSprite* corner3 = CCSprite::create("Images/bugs/corner.png"); corner3->setPosition(ccp(corner->getPosition().x, -corner->getPosition().y)); corner3->setFlipY(true); addChild(corner3); - CCSprite* corner4 = CCSprite::spriteWithFile("Images/bugs/corner.png"); + CCSprite* corner4 = CCSprite::create("Images/bugs/corner.png"); corner4->setPosition(ccp(corner2->getPosition().x, -corner2->getPosition().y)); corner4->setFlipX(true); corner4->setFlipY(true); addChild(corner4); - CCSprite* edge = CCSprite::spriteWithFile("Images/bugs/edge.png"); + CCSprite* edge = CCSprite::create("Images/bugs/edge.png"); edge->setScaleX(width); edge->setPosition(ccp(corner->getPosition().x + (corner->getContentSize().width / 2) + (width / 2), corner->getPosition().y)); addChild(edge); - CCSprite* edge2 = CCSprite::spriteWithFile("Images/bugs/edge.png"); + CCSprite* edge2 = CCSprite::create("Images/bugs/edge.png"); edge2->setScaleX(width); edge2->setPosition(ccp(corner->getPosition().x + (corner->getContentSize().width / 2) + (width / 2), -corner->getPosition().y)); edge2->setFlipY(true); addChild(edge2); - CCSprite* edge3 = CCSprite::spriteWithFile("Images/bugs/edge.png"); + CCSprite* edge3 = CCSprite::create("Images/bugs/edge.png"); edge3->setRotation(90); edge3->setScaleX(height); edge3->setPosition(ccp(corner->getPosition().x, corner->getPosition().y + (corner->getContentSize().height / 2) + (height / 2))); addChild(edge3); - CCSprite* edge4 = CCSprite::spriteWithFile("Images/bugs/edge.png"); + CCSprite* edge4 = CCSprite::create("Images/bugs/edge.png"); edge4->setRotation(270); edge4->setScaleX(height); edge4->setPosition(ccp(-corner->getPosition().x, corner->getPosition().y + (corner->getContentSize().height / 2) + (height / 2))); diff --git a/tests/tests/BugsTest/Bug-624.cpp b/tests/tests/BugsTest/Bug-624.cpp index 08419cb1ed..0ba9dd5176 100644 --- a/tests/tests/BugsTest/Bug-624.cpp +++ b/tests/tests/BugsTest/Bug-624.cpp @@ -15,7 +15,7 @@ bool Bug624Layer::init() if(BugsTestBaseLayer::init()) { CCSize size = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF *label = CCLabelTTF::labelWithString("Layer1", "Marker Felt", 36); + CCLabelTTF *label = CCLabelTTF::create("Layer1", "Marker Felt", 36); label->setPosition(ccp(size.width/2, size.height/2)); addChild(label); @@ -32,9 +32,9 @@ void Bug624Layer::switchLayer(float dt) { unschedule(schedule_selector(Bug624Layer::switchLayer)); - CCScene *scene = CCScene::node(); - scene->addChild(Bug624Layer2::node(), 0); - CCDirector::sharedDirector()->replaceScene(CCTransitionFade::transitionWithDuration(2.0f, scene, ccWHITE)); + CCScene *scene = CCScene::create(); + scene->addChild(Bug624Layer2::create(), 0); + CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(2.0f, scene, ccWHITE)); } void Bug624Layer::didAccelerate(CCAcceleration* acceleration) @@ -52,7 +52,7 @@ bool Bug624Layer2::init() if(BugsTestBaseLayer::init()) { CCSize size = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF *label = CCLabelTTF::labelWithString("Layer2", "Marker Felt", 36); + CCLabelTTF *label = CCLabelTTF::create("Layer2", "Marker Felt", 36); label->setPosition(ccp(size.width/2, size.height/2)); addChild(label); @@ -69,9 +69,9 @@ void Bug624Layer2::switchLayer(float dt) { unschedule(schedule_selector(Bug624Layer::switchLayer)); - CCScene *scene = CCScene::node(); - scene->addChild(Bug624Layer::node(), 0); - CCDirector::sharedDirector()->replaceScene(CCTransitionFade::transitionWithDuration(2.0f, scene, ccRED)); + CCScene *scene = CCScene::create(); + scene->addChild(Bug624Layer::create(), 0); + CCDirector::sharedDirector()->replaceScene(CCTransitionFade::create(2.0f, scene, ccRED)); } void Bug624Layer2::didAccelerate(CCAcceleration* acceleration) diff --git a/tests/tests/BugsTest/Bug-624.h b/tests/tests/BugsTest/Bug-624.h index d407fb4d31..37b8e703db 100644 --- a/tests/tests/BugsTest/Bug-624.h +++ b/tests/tests/BugsTest/Bug-624.h @@ -10,7 +10,7 @@ public: void switchLayer(float dt); virtual void didAccelerate(CCAcceleration* pAccelerationValue); - LAYER_NODE_FUNC(Bug624Layer); + LAYER_CREATE_FUNC(Bug624Layer); }; class Bug624Layer2 : public BugsTestBaseLayer @@ -20,7 +20,7 @@ public: void switchLayer(float dt); virtual void didAccelerate(CCAcceleration* pAccelerationValue); - LAYER_NODE_FUNC(Bug624Layer2); + LAYER_CREATE_FUNC(Bug624Layer2); }; #endif // __BUG_624_H__ diff --git a/tests/tests/BugsTest/Bug-886.cpp b/tests/tests/BugsTest/Bug-886.cpp index 4c0b5dfeda..d8530f1287 100644 --- a/tests/tests/BugsTest/Bug-886.cpp +++ b/tests/tests/BugsTest/Bug-886.cpp @@ -12,13 +12,13 @@ bool Bug886Layer::init() // ask director the the window size // CGSize size = [[CCDirector sharedDirector] winSize]; - CCSprite* sprite = CCSprite::spriteWithFile("Images/bugs/bug886.jpg"); + CCSprite* sprite = CCSprite::create("Images/bugs/bug886.jpg"); sprite->setAnchorPoint(CCPointZero); sprite->setPosition(CCPointZero); sprite->setScaleX(0.6f); addChild(sprite); - CCSprite* sprite2 = CCSprite::spriteWithFile("Images/bugs/bug886.png"); + CCSprite* sprite2 = CCSprite::create("Images/bugs/bug886.png"); sprite2->setAnchorPoint(CCPointZero); sprite2->setScaleX(0.6f); sprite2->setPosition(ccp(sprite->getContentSize().width * 0.6f + 10, 0)); diff --git a/tests/tests/BugsTest/Bug-899.cpp b/tests/tests/BugsTest/Bug-899.cpp index 3ad33bcf5c..3d29611ad0 100644 --- a/tests/tests/BugsTest/Bug-899.cpp +++ b/tests/tests/BugsTest/Bug-899.cpp @@ -12,7 +12,7 @@ bool Bug899Layer::init() CCDirector::sharedDirector()->enableRetinaDisplay(true); if (BugsTestBaseLayer::init()) { - CCSprite *bg = CCSprite::spriteWithFile("Images/bugs/RetinaDisplay.jpg"); + CCSprite *bg = CCSprite::create("Images/bugs/RetinaDisplay.jpg"); addChild(bg, 0); bg->setAnchorPoint(CCPointZero); diff --git a/tests/tests/BugsTest/Bug-914.cpp b/tests/tests/BugsTest/Bug-914.cpp index 05187d07d8..117e059dd0 100644 --- a/tests/tests/BugsTest/Bug-914.cpp +++ b/tests/tests/BugsTest/Bug-914.cpp @@ -12,9 +12,9 @@ CCScene* Bug914Layer::scene() { // 'scene' is an autorelease object. - CCScene *pScene = CCScene::node(); + CCScene *pScene = CCScene::create(); // 'layer' is an autorelease object. - Bug914Layer* layer = Bug914Layer::node(); + Bug914Layer* layer = Bug914Layer::create(); // add layer as a child to scene pScene->addChild(layer); @@ -36,7 +36,7 @@ bool Bug914Layer::init() CCLayerColor *layer; for( int i=0;i < 5;i++) { - layer = CCLayerColor::layerWithColor(ccc4(i*20, i*20, i*20,255)); + layer = CCLayerColor::create(ccc4(i*20, i*20, i*20,255)); layer->setContentSize(CCSizeMake(i*100, i*100)); layer->setPosition(ccp(size.width/2, size.height/2)); layer->setAnchorPoint(ccp(0.5f, 0.5f)); @@ -45,10 +45,10 @@ bool Bug914Layer::init() } // create and initialize a Label - CCLabelTTF *label = CCLabelTTF::labelWithString("Hello World", "Marker Felt", 64); - CCMenuItem *item1 = CCMenuItemFont::itemWithString("restart", this, menu_selector(Bug914Layer::restart)); + CCLabelTTF *label = CCLabelTTF::create("Hello World", "Marker Felt", 64); + CCMenuItem *item1 = CCMenuItemFont::create("restart", this, menu_selector(Bug914Layer::restart)); - CCMenu *menu = CCMenu::menuWithItems(item1, NULL); + CCMenu *menu = CCMenu::create(item1, NULL); menu->alignItemsVertically(); menu->setPosition(ccp(size.width/2, 100)); addChild(menu); diff --git a/tests/tests/BugsTest/Bug-914.h b/tests/tests/BugsTest/Bug-914.h index 75dad0f5f3..912c89188c 100644 --- a/tests/tests/BugsTest/Bug-914.h +++ b/tests/tests/BugsTest/Bug-914.h @@ -13,7 +13,7 @@ public: void ccTouchesBegan(CCSet *touches, CCEvent * event); void restart(CCObject* sender); - LAYER_NODE_FUNC(Bug914Layer); + LAYER_CREATE_FUNC(Bug914Layer); }; #endif // __BUG_914_H__ diff --git a/tests/tests/BugsTest/BugsTest.cpp b/tests/tests/BugsTest/BugsTest.cpp index 870a020884..0db9e76fda 100644 --- a/tests/tests/BugsTest/BugsTest.cpp +++ b/tests/tests/BugsTest/BugsTest.cpp @@ -11,7 +11,7 @@ #define TEST_BUG(bugNO) \ { \ -CCScene* pScene = CCScene::node(); \ +CCScene* pScene = CCScene::create(); \ Bug##bugNO##Layer* pLayer = new Bug##bugNO##Layer(); \ pLayer->init(); \ pScene->addChild(pLayer); \ @@ -51,12 +51,12 @@ void BugsTestMainLayer::onEnter() CCLayer::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - m_pItmeMenu = CCMenu::menuWithItems(NULL); + m_pItmeMenu = CCMenu::create(); CCMenuItemFont::setFontName("Arial"); CCMenuItemFont::setFontSize(24); for (int i = 0; i < MAX_COUNT; ++i) { - CCMenuItemFont* pItem = CCMenuItemFont::itemWithString(testsName[i].c_str(), this, + CCMenuItemFont* pItem = CCMenuItemFont::create(testsName[i].c_str(), this, menu_selector(BugsTestMainLayer::menuCallback)); pItem->setPosition(ccp(s.width / 2, s.height - (i + 1) * LINE_SPACE)); m_pItmeMenu->addChild(pItem, kItemTagBasic + i); @@ -157,10 +157,10 @@ void BugsTestBaseLayer::onEnter() CCMenuItemFont::setFontName("Arial"); CCMenuItemFont::setFontSize(24); - CCMenuItemFont* pMainItem = CCMenuItemFont::itemWithString("Back", this, + CCMenuItemFont* pMainItem = CCMenuItemFont::create("Back", this, menu_selector(BugsTestBaseLayer::backCallback)); pMainItem->setPosition(ccp(s.width - 50, 25)); - CCMenu* pMenu = CCMenu::menuWithItems(pMainItem, NULL); + CCMenu* pMenu = CCMenu::create(pMainItem, NULL); pMenu->setPosition( CCPointZero ); addChild(pMenu); } diff --git a/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp b/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp index 5920602936..62c9951f0d 100644 --- a/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp +++ b/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp @@ -77,7 +77,7 @@ ChipmunkAccelTouchTestLayer::ChipmunkAccelTouchTestLayer() CCSize s = CCDirector::sharedDirector()->getWinSize(); // title - CCLabelTTF *label = CCLabelTTF::labelWithString("Multi touch the screen", "Marker Felt", 36); + CCLabelTTF *label = CCLabelTTF::create("Multi touch the screen", "Marker Felt", 36); label->setPosition(ccp( s.width / 2, s.height - 30)); this->addChild(label, -1); @@ -89,12 +89,12 @@ ChipmunkAccelTouchTestLayer::ChipmunkAccelTouchTestLayer() #if 1 // Use batch node. Faster - CCSpriteBatchNode *parent = CCSpriteBatchNode::batchNodeWithFile("Images/grossini_dance_atlas.png", 100); + CCSpriteBatchNode *parent = CCSpriteBatchNode::create("Images/grossini_dance_atlas.png", 100); m_pSpriteTexture = parent->getTexture(); #else // doesn't use batch node. Slower m_pSpriteTexture = CCTextureCache::sharedTextureCache()->addImage("Images/grossini_dance_atlas.png"); - CCNode *parent = CCNode::node(); + CCNode *parent = CCNode::create(); #endif addChild(parent, 0, kTagParentNode); @@ -161,9 +161,9 @@ void ChipmunkAccelTouchTestLayer::update(float delta) void ChipmunkAccelTouchTestLayer::createResetButton() { - CCMenuItemImage *reset = CCMenuItemImage::itemWithNormalImage("Images/r1.png", "Images/r2.png", this, menu_selector(ChipmunkAccelTouchTestLayer::reset)); + CCMenuItemImage *reset = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", this, menu_selector(ChipmunkAccelTouchTestLayer::reset)); - CCMenu *menu = CCMenu::menuWithItems(reset, NULL); + CCMenu *menu = CCMenu::create(reset, NULL); CCSize s = CCDirector::sharedDirector()->getWinSize(); diff --git a/tests/tests/ClickAndMoveTest/ClickAndMoveTest.cpp b/tests/tests/ClickAndMoveTest/ClickAndMoveTest.cpp index ec28d201f9..78f5621fe0 100644 --- a/tests/tests/ClickAndMoveTest/ClickAndMoveTest.cpp +++ b/tests/tests/ClickAndMoveTest/ClickAndMoveTest.cpp @@ -19,20 +19,20 @@ MainLayer::MainLayer() { setIsTouchEnabled(true); - CCSprite* sprite = CCSprite::spriteWithFile(s_pPathGrossini); + CCSprite* sprite = CCSprite::create(s_pPathGrossini); - CCLayer* layer = CCLayerColor::layerWithColor(ccc4(255,255,0,255)); + CCLayer* layer = CCLayerColor::create(ccc4(255,255,0,255)); addChild(layer, -1); addChild(sprite, 0, kTagSprite); sprite->setPosition( CCPointMake(20,150) ); - sprite->runAction( CCJumpTo::actionWithDuration(4, CCPointMake(300,48), 100, 4) ); + sprite->runAction( CCJumpTo::create(4, CCPointMake(300,48), 100, 4) ); - layer->runAction( CCRepeatForever::actionWithAction( - (CCActionInterval*)( CCSequence::actions( - CCFadeIn::actionWithDuration(1), - CCFadeOut::actionWithDuration(1), + layer->runAction( CCRepeatForever::create( + (CCActionInterval*)( CCSequence::create( + CCFadeIn::create(1), + CCFadeOut::create(1), NULL) ) ) ); } @@ -47,7 +47,7 @@ void MainLayer::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent) CCNode* s = getChildByTag(kTagSprite); s->stopAllActions(); - s->runAction( CCMoveTo::actionWithDuration(1, CCPointMake(convertedLocation.x, convertedLocation.y) ) ); + s->runAction( CCMoveTo::create(1, CCPointMake(convertedLocation.x, convertedLocation.y) ) ); float o = convertedLocation.x - s->getPosition().x; float a = convertedLocation.y - s->getPosition().y; float at = (float) CC_RADIANS_TO_DEGREES( atanf( o/a) ); @@ -60,5 +60,5 @@ void MainLayer::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent) at = 180 - fabs(at); } - s->runAction( CCRotateTo::actionWithDuration(1, at) ); + s->runAction( CCRotateTo::create(1, at) ); } diff --git a/tests/tests/CocosDenshionTest/CocosDenshionTest.cpp b/tests/tests/CocosDenshionTest/CocosDenshionTest.cpp index 4bad47c84b..f02993ac93 100644 --- a/tests/tests/CocosDenshionTest/CocosDenshionTest.cpp +++ b/tests/tests/CocosDenshionTest/CocosDenshionTest.cpp @@ -52,18 +52,18 @@ m_nSoundId(0) }; // add menu items for tests - m_pItmeMenu = CCMenu::menuWithItems(NULL); + m_pItmeMenu = CCMenu::create(); CCSize s = CCDirector::sharedDirector()->getWinSize(); m_nTestCount = sizeof(testItems) / sizeof(testItems[0]); for (int i = 0; i < m_nTestCount; ++i) { //#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE) -// CCLabelBMFont* label = CCLabelBMFont::labelWithString(testItems[i].c_str(), "fonts/arial16.fnt"); +// CCLabelBMFont* label = CCLabelBMFont::create(testItems[i].c_str(), "fonts/arial16.fnt"); //#else - CCLabelTTF* label = CCLabelTTF::labelWithString(testItems[i].c_str(), "Arial", 24); + CCLabelTTF* label = CCLabelTTF::create(testItems[i].c_str(), "Arial", 24); //#endif - CCMenuItemLabel* pMenuItem = CCMenuItemLabel::itemWithLabel(label, this, menu_selector(CocosDenshionTest::menuCallback)); + CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(CocosDenshionTest::menuCallback)); m_pItmeMenu->addChild(pMenuItem, i + 10000); pMenuItem->setPosition( CCPointMake( s.width / 2, (s.height - (i + 1) * LINE_SPACE) )); diff --git a/tests/tests/CurlTest/CurlTest.cpp b/tests/tests/CurlTest/CurlTest.cpp index d5125799dd..8121dae18f 100644 --- a/tests/tests/CurlTest/CurlTest.cpp +++ b/tests/tests/CurlTest/CurlTest.cpp @@ -6,14 +6,14 @@ CurlTest::CurlTest() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF* label = CCLabelTTF::labelWithString("Curl Test", "Arial", 28); + CCLabelTTF* label = CCLabelTTF::create("Curl Test", "Arial", 28); addChild(label, 0); label->setPosition( ccp(s.width/2, s.height-50) ); setIsTouchEnabled(true); // create a label to display the tip string - m_pLabel = CCLabelTTF::labelWithString("Touch the screen to connect", "Arial", 22); + m_pLabel = CCLabelTTF::create("Touch the screen to connect", "Arial", 22); m_pLabel->setPosition(ccp(s.width / 2, s.height / 2)); addChild(m_pLabel, 0); diff --git a/tests/tests/CurrentLanguageTest/CurrentLanguageTest.cpp b/tests/tests/CurrentLanguageTest/CurrentLanguageTest.cpp index 513bc508d8..4b4c7f1e0b 100644 --- a/tests/tests/CurrentLanguageTest/CurrentLanguageTest.cpp +++ b/tests/tests/CurrentLanguageTest/CurrentLanguageTest.cpp @@ -3,11 +3,11 @@ CurrentLanguageTest::CurrentLanguageTest() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF* label = CCLabelTTF::labelWithString("Current language Test", "Arial", 28); + CCLabelTTF* label = CCLabelTTF::create("Current language Test", "Arial", 28); addChild(label, 0); label->setPosition( ccp(s.width/2, s.height-50) ); - CCLabelTTF *labelLanguage = CCLabelTTF::labelWithString("", "Arial", 20); + CCLabelTTF *labelLanguage = CCLabelTTF::create("", "Arial", 20); labelLanguage->setPosition(ccp(s.width/2, s.height/2)); ccLanguageType currentLanguageType = CCApplication::sharedApplication().getCurrentLanguage(); diff --git a/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp b/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp index 683b11e083..b00ab2b3d9 100644 --- a/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp +++ b/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp @@ -28,17 +28,17 @@ void Effect1::onEnter() // Waves3D is Grid3D and it's size is (15,10) CCSize size = CCDirector::sharedDirector()->getWinSize(); - CCActionInterval* lens = CCLens3D::actionWithPosition(ccp(size.width/2,size.height/2), 240, ccg(15,10), 0.0f); - CCActionInterval* waves = CCWaves3D::actionWithWaves(18, 15, ccg(15,10), 10); + CCActionInterval* lens = CCLens3D::create(ccp(size.width/2,size.height/2), 240, ccg(15,10), 0.0f); + CCActionInterval* waves = CCWaves3D::create(18, 15, ccg(15,10), 10); - CCFiniteTimeAction* reuse = CCReuseGrid::actionWithTimes(1); - CCActionInterval* delay = CCDelayTime::actionWithDuration(8); + CCFiniteTimeAction* reuse = CCReuseGrid::create(1); + CCActionInterval* delay = CCDelayTime::create(8); - CCActionInterval* orbit = CCOrbitCamera::actionWithDuration(5, 1, 2, 0, 180, 0, -90); + CCActionInterval* orbit = CCOrbitCamera::create(5, 1, 2, 0, 180, 0, -90); CCActionInterval* orbit_back = orbit->reverse(); - target->runAction( CCRepeatForever::actionWithAction( (CCActionInterval *)(CCSequence::actions( orbit, orbit_back, NULL) ) ) ); - target->runAction( CCSequence::actions(lens, delay, reuse, waves, NULL) ); + target->runAction( CCRepeatForever::create( (CCActionInterval *)(CCSequence::create( orbit, orbit_back, NULL) ) ) ); + target->runAction( CCSequence::create(lens, delay, reuse, waves, NULL) ); } std::string Effect1::title() @@ -62,24 +62,24 @@ void Effect2::onEnter() // ShakyTiles is TiledGrid3D and it's size is (15,10) // Shuffletiles is TiledGrid3D and it's size is (15,10) // TurnOfftiles is TiledGrid3D and it's size is (15,10) - CCActionInterval* shaky = CCShakyTiles3D::actionWithRange(4, false, ccg(15,10), 5); - CCActionInterval* shuffle = CCShuffleTiles::actionWithSeed(0, ccg(15,10), 3); - CCActionInterval* turnoff = CCTurnOffTiles::actionWithSeed(0, ccg(15,10), 3); + CCActionInterval* shaky = CCShakyTiles3D::create(4, false, ccg(15,10), 5); + CCActionInterval* shuffle = CCShuffleTiles::create(0, ccg(15,10), 3); + CCActionInterval* turnoff = CCTurnOffTiles::create(0, ccg(15,10), 3); CCActionInterval* turnon = turnoff->reverse(); // reuse 2 times: // 1 for shuffle // 2 for turn off // turnon tiles will use a new grid - CCFiniteTimeAction* reuse = CCReuseGrid::actionWithTimes(2); + CCFiniteTimeAction* reuse = CCReuseGrid::create(2); - CCActionInterval* delay = CCDelayTime::actionWithDuration(1); + CCActionInterval* delay = CCDelayTime::create(1); -// id orbit = [OrbitCamera::actionWithDuration:5 radius:1 deltaRadius:2 angleZ:0 deltaAngleZ:180 angleX:0 deltaAngleX:-90]; +// id orbit = [OrbitCamera::create:5 radius:1 deltaRadius:2 angleZ:0 deltaAngleZ:180 angleX:0 deltaAngleX:-90]; // id orbit_back = [orbit reverse]; // -// [target runAction: [RepeatForever::actionWithAction: [Sequence actions: orbit, orbit_back, nil]]]; - target->runAction( (CCActionInterval *)(CCSequence::actions( shaky, delay, reuse, shuffle, delay->copy()->autorelease(), turnoff, turnon, NULL) ) ); +// [target runAction: [RepeatForever::create: [Sequence actions: orbit, orbit_back, nil]]]; + target->runAction( (CCActionInterval *)(CCSequence::create( shaky, delay, reuse, shuffle, delay->copy()->autorelease(), turnoff, turnon, NULL) ) ); } std::string Effect2::title() @@ -101,15 +101,15 @@ void Effect3::onEnter() CCNode* target1 = bg->getChildByTag(kTagSprite1); CCNode* target2 = bg->getChildByTag(kTagSprite2); - CCActionInterval* waves = CCWaves::actionWithWaves(5, 20, true, false, ccg(15,10), 5); - CCActionInterval* shaky = CCShaky3D::actionWithRange(4, false, ccg(15,10), 5); + CCActionInterval* waves = CCWaves::create(5, 20, true, false, ccg(15,10), 5); + CCActionInterval* shaky = CCShaky3D::create(4, false, ccg(15,10), 5); - target1->runAction( CCRepeatForever::actionWithAction( waves ) ); - target2->runAction( CCRepeatForever::actionWithAction( shaky ) ); + target1->runAction( CCRepeatForever::create( waves ) ); + target2->runAction( CCRepeatForever::create( shaky ) ); // moving background. Testing issue #244 - CCActionInterval* move = CCMoveBy::actionWithDuration(3, ccp(200,0) ); - bg->runAction(CCRepeatForever::actionWithAction( (CCActionInterval *)(CCSequence::actions(move, move->reverse(), NULL) ) ) ); + CCActionInterval* move = CCMoveBy::create(3, ccp(200,0) ); + bg->runAction(CCRepeatForever::create( (CCActionInterval *)(CCSequence::create(move, move->reverse(), NULL) ) ) ); } std::string Effect3::title() @@ -127,15 +127,15 @@ void Effect4::onEnter() { EffectAdvanceTextLayer::onEnter(); - CCActionInterval* lens = CCLens3D::actionWithPosition(ccp(100,180), 150, ccg(32,24), 10); - //id move = [MoveBy::actionWithDuration:5 position:ccp(400,0)]; + CCActionInterval* lens = CCLens3D::create(ccp(100,180), 150, ccg(32,24), 10); + //id move = [MoveBy::create:5 position:ccp(400,0)]; /** @todo we only support CCNode run actions now. */ -// CCActionInterval* move = CCJumpBy::actionWithDuration(5, ccp(380,0), 100, 4); +// CCActionInterval* move = CCJumpBy::create(5, ccp(380,0), 100, 4); // CCActionInterval* move_back = move->reverse(); -// CCActionInterval* seq = (CCActionInterval *)(CCSequence::actions( move, move_back, NULL)); +// CCActionInterval* seq = (CCActionInterval *)(CCSequence::create( move, move_back, NULL)); // CCActionManager::sharedManager()->addAction(seq, lens, false); runAction( lens ); @@ -157,13 +157,13 @@ void Effect5::onEnter() //CCDirector::sharedDirector()->setProjection(CCDirectorProjection2D); - CCActionInterval* effect = CCLiquid::actionWithWaves(1, 20, ccg(32,24), 2); + CCActionInterval* effect = CCLiquid::create(1, 20, ccg(32,24), 2); - CCActionInterval* stopEffect = (CCActionInterval *)( CCSequence::actions( + CCActionInterval* stopEffect = (CCActionInterval *)( CCSequence::create( effect, - CCDelayTime::actionWithDuration(2), - CCStopGrid::action(), - // [DelayTime::actionWithDuration:2], + CCDelayTime::create(2), + CCStopGrid::create(), + // [DelayTime::create:2], // [[effect copy] autorelease], NULL) ); @@ -192,29 +192,29 @@ void Issue631::onEnter() { EffectAdvanceTextLayer::onEnter(); - CCActionInterval* effect = (CCActionInterval*)(CCSequence::actions( CCDelayTime::actionWithDuration(2.0f), CCShaky3D::actionWithRange(16, false, ccg(5, 5), 5.0f), NULL)); + CCActionInterval* effect = (CCActionInterval*)(CCSequence::create( CCDelayTime::create(2.0f), CCShaky3D::create(16, false, ccg(5, 5), 5.0f), NULL)); // cleanup CCNode* bg = getChildByTag(kTagBackground); removeChild(bg, true); // background - CCLayerColor* layer = CCLayerColor::layerWithColor( ccc4(255,0,0,255) ); + CCLayerColor* layer = CCLayerColor::create( ccc4(255,0,0,255) ); addChild(layer, -10); - CCSprite* sprite = CCSprite::spriteWithFile("Images/grossini.png"); + CCSprite* sprite = CCSprite::create("Images/grossini.png"); sprite->setPosition( ccp(50,80) ); layer->addChild(sprite, 10); // foreground - CCLayerColor* layer2 = CCLayerColor::layerWithColor(ccc4( 0, 255,0,255 ) ); - CCSprite* fog = CCSprite::spriteWithFile("Images/Fog.png"); + CCLayerColor* layer2 = CCLayerColor::create(ccc4( 0, 255,0,255 ) ); + CCSprite* fog = CCSprite::create("Images/Fog.png"); ccBlendFunc bf = {GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA}; fog->setBlendFunc(bf); layer2->addChild(fog, 1); addChild(layer2, 1); - layer2->runAction( CCRepeatForever::actionWithAction(effect) ); + layer2->runAction( CCRepeatForever::create(effect) ); } std::string Issue631::title() @@ -305,25 +305,25 @@ void EffectAdvanceTextLayer::onEnter(void) x = size.width; y = size.height; - CCSprite *bg = CCSprite::spriteWithFile("Images/background3.png"); + CCSprite *bg = CCSprite::create("Images/background3.png"); addChild(bg, 0, kTagBackground); bg->setPosition( ccp(x/2,y/2) ); - CCSprite* grossini = CCSprite::spriteWithFile("Images/grossinis_sister2.png"); + CCSprite* grossini = CCSprite::create("Images/grossinis_sister2.png"); bg->addChild(grossini, 1, kTagSprite1); grossini->setPosition( ccp(x/3.0f,200) ); - CCActionInterval* sc = CCScaleBy::actionWithDuration(2, 5); + CCActionInterval* sc = CCScaleBy::create(2, 5); CCActionInterval* sc_back = sc->reverse(); - grossini->runAction( CCRepeatForever::actionWithAction( (CCActionInterval*)(CCSequence::actions(sc, sc_back, NULL)) ) ); + grossini->runAction( CCRepeatForever::create( (CCActionInterval*)(CCSequence::create(sc, sc_back, NULL)) ) ); - CCSprite* tamara = CCSprite::spriteWithFile("Images/grossinis_sister1.png"); + CCSprite* tamara = CCSprite::create("Images/grossinis_sister1.png"); bg->addChild(tamara, 1, kTagSprite2); tamara->setPosition( ccp(2*x/3.0f,200) ); - CCActionInterval* sc2 = CCScaleBy::actionWithDuration(2, 5); + CCActionInterval* sc2 = CCScaleBy::create(2, 5); CCActionInterval* sc2_back = sc2->reverse(); - tamara->runAction( CCRepeatForever::actionWithAction( (CCActionInterval*)(CCSequence::actions(sc2, sc2_back, NULL)) ) ); + tamara->runAction( CCRepeatForever::create( (CCActionInterval*)(CCSequence::create(sc2, sc2_back, NULL)) ) ); - CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Marker Felt", 28); + CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Marker Felt", 28); label->setPosition( ccp(x/2,y-80) ); addChild(label); @@ -332,16 +332,16 @@ void EffectAdvanceTextLayer::onEnter(void) std::string strSubtitle = subtitle(); if( ! strSubtitle.empty() ) { - CCLabelTTF* l = CCLabelTTF::labelWithString(strSubtitle.c_str(), "Thonburi", 16); + CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16); addChild(l, 101); l->setPosition( ccp(size.width/2, size.height-80) ); } - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage("Images/b1.png", "Images/b2.png", this, menu_selector(EffectAdvanceTextLayer::backCallback) ); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage("Images/r1.png","Images/r2.png", this, menu_selector(EffectAdvanceTextLayer::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage("Images/f1.png", "Images/f2.png", this, menu_selector(EffectAdvanceTextLayer::nextCallback) ); + CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(EffectAdvanceTextLayer::backCallback) ); + CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png","Images/r2.png", this, menu_selector(EffectAdvanceTextLayer::restartCallback) ); + CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(EffectAdvanceTextLayer::nextCallback) ); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition(CCPointZero); item1->setPosition(ccp(size.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2)); diff --git a/tests/tests/EffectsTest/EffectsTest.cpp b/tests/tests/EffectsTest/EffectsTest.cpp index e282e5b415..937e4602a1 100644 --- a/tests/tests/EffectsTest/EffectsTest.cpp +++ b/tests/tests/EffectsTest/EffectsTest.cpp @@ -39,54 +39,54 @@ static std::string effectsList[] = class Shaky3DDemo : public CCShaky3D { public: - static CCActionInterval* actionWithDuration(float t) + static CCActionInterval* create(float t) { - return CCShaky3D::actionWithRange(5, false, ccg(15,10), t); + return CCShaky3D::create(5, false, ccg(15,10), t); } }; class Waves3DDemo : public CCWaves3D { public: - static CCActionInterval* actionWithDuration(float t) + static CCActionInterval* create(float t) { - return CCWaves3D::actionWithWaves(5, 40, ccg(15,10), t); + return CCWaves3D::create(5, 40, ccg(15,10), t); } }; class FlipX3DDemo : public CCFlipX3D { public: - static CCActionInterval* actionWithDuration(float t) + static CCActionInterval* create(float t) { - CCFlipX3D* flipx = CCFlipX3D::actionWithDuration(t); + CCFlipX3D* flipx = CCFlipX3D::create(t); CCActionInterval* flipx_back = flipx->reverse(); - CCDelayTime* delay = CCDelayTime::actionWithDuration(2); + CCDelayTime* delay = CCDelayTime::create(2); - return (CCActionInterval*)(CCSequence::actions(flipx, delay, flipx_back, NULL)); + return (CCActionInterval*)(CCSequence::create(flipx, delay, flipx_back, NULL)); } }; class FlipY3DDemo : public CCFlipY3D { public: - static CCActionInterval* actionWithDuration(float t) + static CCActionInterval* create(float t) { - CCFlipY3D* flipy = CCFlipY3D::actionWithDuration(t); + CCFlipY3D* flipy = CCFlipY3D::create(t); CCActionInterval* flipy_back = flipy->reverse(); - CCDelayTime* delay = CCDelayTime::actionWithDuration(2); + CCDelayTime* delay = CCDelayTime::create(2); - return (CCActionInterval*)(CCSequence::actions(flipy, delay, flipy_back, NULL)); + return (CCActionInterval*)(CCSequence::create(flipy, delay, flipy_back, NULL)); } }; class Lens3DDemo : public CCLens3D { public: - static CCActionInterval* actionWithDuration(float t) + static CCActionInterval* create(float t) { CCSize size = CCDirector::sharedDirector()->getWinSize(); - return CCLens3D::actionWithPosition(CCPointMake(size.width/2,size.height/2), 240, ccg(15,10), t); + return CCLens3D::create(CCPointMake(size.width/2,size.height/2), 240, ccg(15,10), t); } }; @@ -94,10 +94,10 @@ public: class Ripple3DDemo : public CCRipple3D { public: - static CCActionInterval* actionWithDuration(float t) + static CCActionInterval* create(float t) { CCSize size = CCDirector::sharedDirector()->getWinSize(); - return CCRipple3D::actionWithPosition(CCPointMake(size.width/2,size.height/2), 240, 4, 160, ccg(32,24), t); + return CCRipple3D::create(CCPointMake(size.width/2,size.height/2), 240, 4, 160, ccg(32,24), t); } }; @@ -105,9 +105,9 @@ public: class LiquidDemo : public CCLiquid { public: - static CCActionInterval* actionWithDuration(float t) + static CCActionInterval* create(float t) { - return CCLiquid::actionWithWaves(4, 20, ccg(16,12), t); + return CCLiquid::create(4, 20, ccg(16,12), t); } }; @@ -115,9 +115,9 @@ public: class WavesDemo : public CCWaves { public: - static CCActionInterval* actionWithDuration(float t) + static CCActionInterval* create(float t) { - return CCWaves::actionWithWaves(4, 20, true, true, ccg(16,12), t); + return CCWaves::create(4, 20, true, true, ccg(16,12), t); } }; @@ -125,10 +125,10 @@ public: class TwirlDemo : public CCTwirl { public: - static CCActionInterval* actionWithDuration(float t) + static CCActionInterval* create(float t) { CCSize size = CCDirector::sharedDirector()->getWinSize(); - return CCTwirl::actionWithPosition(CCPointMake(size.width/2, size.height/2), 1, 2.5f, ccg(12,8), t); + return CCTwirl::create(CCPointMake(size.width/2, size.height/2), 1, 2.5f, ccg(12,8), t); } }; @@ -136,9 +136,9 @@ public: class ShakyTiles3DDemo : public CCShakyTiles3D { public: - static CCActionInterval* actionWithDuration(float t) + static CCActionInterval* create(float t) { - return CCShakyTiles3D::actionWithRange(5, false, ccg(16,12), t) ; + return CCShakyTiles3D::create(5, false, ccg(16,12), t) ; } }; @@ -146,9 +146,9 @@ public: class ShatteredTiles3DDemo : public CCShatteredTiles3D { public: - static CCActionInterval* actionWithDuration(float t) + static CCActionInterval* create(float t) { - return CCShatteredTiles3D::actionWithRange(5, false, ccg(16,12), t); + return CCShatteredTiles3D::create(5, false, ccg(16,12), t); } }; @@ -156,13 +156,13 @@ public: class ShuffleTilesDemo : public CCShuffleTiles { public: - static CCActionInterval* actionWithDuration(float t) + static CCActionInterval* create(float t) { - CCShuffleTiles* shuffle = CCShuffleTiles::actionWithSeed(25, ccg(16,12), t); + CCShuffleTiles* shuffle = CCShuffleTiles::create(25, ccg(16,12), t); CCActionInterval* shuffle_back = shuffle->reverse(); - CCDelayTime* delay = CCDelayTime::actionWithDuration(2); + CCDelayTime* delay = CCDelayTime::create(2); - return (CCActionInterval*)(CCSequence::actions(shuffle, delay, shuffle_back, NULL)); + return (CCActionInterval*)(CCSequence::create(shuffle, delay, shuffle_back, NULL)); } }; @@ -170,13 +170,13 @@ public: class FadeOutTRTilesDemo : public CCFadeOutTRTiles { public: - static CCActionInterval* actionWithDuration(float t) + static CCActionInterval* create(float t) { - CCFadeOutTRTiles* fadeout = CCFadeOutTRTiles::actionWithSize(ccg(16,12), t); + CCFadeOutTRTiles* fadeout = CCFadeOutTRTiles::create(ccg(16,12), t); CCActionInterval* back = fadeout->reverse(); - CCDelayTime* delay = CCDelayTime::actionWithDuration(0.5f); + CCDelayTime* delay = CCDelayTime::create(0.5f); - return (CCActionInterval*)(CCSequence::actions(fadeout, delay, back, NULL)); + return (CCActionInterval*)(CCSequence::create(fadeout, delay, back, NULL)); } }; @@ -184,13 +184,13 @@ public: class FadeOutBLTilesDemo : public CCFadeOutBLTiles { public: - static CCActionInterval* actionWithDuration(float t) + static CCActionInterval* create(float t) { - CCFadeOutBLTiles* fadeout = CCFadeOutBLTiles::actionWithSize(ccg(16,12), t); + CCFadeOutBLTiles* fadeout = CCFadeOutBLTiles::create(ccg(16,12), t); CCActionInterval* back = fadeout->reverse(); - CCDelayTime* delay = CCDelayTime::actionWithDuration(0.5f); + CCDelayTime* delay = CCDelayTime::create(0.5f); - return (CCActionInterval*)(CCSequence::actions(fadeout, delay, back, NULL)); + return (CCActionInterval*)(CCSequence::create(fadeout, delay, back, NULL)); } }; @@ -198,86 +198,86 @@ public: class FadeOutUpTilesDemo : public CCFadeOutUpTiles { public: - static CCActionInterval* actionWithDuration(float t) + static CCActionInterval* create(float t) { - CCFadeOutUpTiles* fadeout = CCFadeOutUpTiles::actionWithSize(ccg(16,12), t); + CCFadeOutUpTiles* fadeout = CCFadeOutUpTiles::create(ccg(16,12), t); CCActionInterval* back = fadeout->reverse(); - CCDelayTime* delay = CCDelayTime::actionWithDuration(0.5f); + CCDelayTime* delay = CCDelayTime::create(0.5f); - return (CCActionInterval*)(CCSequence::actions(fadeout, delay, back, NULL)); + return (CCActionInterval*)(CCSequence::create(fadeout, delay, back, NULL)); } }; class FadeOutDownTilesDemo : public CCFadeOutDownTiles { public: - static CCActionInterval* actionWithDuration(float t) + static CCActionInterval* create(float t) { - CCFadeOutDownTiles* fadeout = CCFadeOutDownTiles::actionWithSize(ccg(16,12), t); + CCFadeOutDownTiles* fadeout = CCFadeOutDownTiles::create(ccg(16,12), t); CCActionInterval* back = fadeout->reverse(); - CCDelayTime* delay = CCDelayTime::actionWithDuration(0.5f); + CCDelayTime* delay = CCDelayTime::create(0.5f); - return (CCActionInterval*)(CCSequence::actions(fadeout, delay, back, NULL)); + return (CCActionInterval*)(CCSequence::create(fadeout, delay, back, NULL)); } }; class TurnOffTilesDemo : public CCTurnOffTiles { public: - static CCActionInterval* actionWithDuration(float t) + static CCActionInterval* create(float t) { - CCTurnOffTiles* fadeout = CCTurnOffTiles::actionWithSeed(25, ccg(48,32) , t); + CCTurnOffTiles* fadeout = CCTurnOffTiles::create(25, ccg(48,32) , t); CCActionInterval* back = fadeout->reverse(); - CCDelayTime* delay = CCDelayTime::actionWithDuration(0.5f); + CCDelayTime* delay = CCDelayTime::create(0.5f); - return (CCActionInterval*)(CCSequence::actions(fadeout, delay, back, NULL)); + return (CCActionInterval*)(CCSequence::create(fadeout, delay, back, NULL)); } }; class WavesTiles3DDemo : public CCWavesTiles3D { public: - static CCActionInterval* actionWithDuration(float t) + static CCActionInterval* create(float t) { - return CCWavesTiles3D::actionWithWaves(4, 120, ccg(15,10), t); + return CCWavesTiles3D::create(4, 120, ccg(15,10), t); } }; class JumpTiles3DDemo : public CCJumpTiles3D { public: - static CCActionInterval* actionWithDuration(float t) + static CCActionInterval* create(float t) { CCSize size = CCDirector::sharedDirector()->getWinSize(); - return CCJumpTiles3D::actionWithJumps(2, 30, ccg(15,10), t); + return CCJumpTiles3D::create(2, 30, ccg(15,10), t); } }; class SplitRowsDemo : public CCSplitRows { public: - static CCActionInterval* actionWithDuration(float t) + static CCActionInterval* create(float t) { - return CCSplitRows::actionWithRows(9, t); + return CCSplitRows::create(9, t); } }; class SplitColsDemo : public CCSplitCols { public: - static CCActionInterval* actionWithDuration(float t) + static CCActionInterval* create(float t) { - return CCSplitCols::actionWithCols(9, t); + return CCSplitCols::create(9, t); } }; class PageTurn3DDemo : public CCPageTurn3D { public: - static CCActionInterval* actionWithDuration(float t) + static CCActionInterval* create(float t) { CCDirector::sharedDirector()->setDepthTest(true); - return CCPageTurn3D::actionWithSize(ccg(15,10), t); + return CCPageTurn3D::create(ccg(15,10), t); } }; @@ -295,28 +295,28 @@ CCActionInterval* createEffect(int nIndex, float t) switch(nIndex) { - case 0: return Shaky3DDemo::actionWithDuration(t); - case 1: return Waves3DDemo::actionWithDuration(t); - case 2: return FlipX3DDemo::actionWithDuration(t); - case 3: return FlipY3DDemo::actionWithDuration(t); - case 4: return Lens3DDemo::actionWithDuration(t); - case 5: return Ripple3DDemo::actionWithDuration(t); - case 6: return LiquidDemo::actionWithDuration(t); - case 7: return WavesDemo::actionWithDuration(t); - case 8: return TwirlDemo::actionWithDuration(t); - case 9: return ShakyTiles3DDemo::actionWithDuration(t); - case 10: return ShatteredTiles3DDemo::actionWithDuration(t); - case 11: return ShuffleTilesDemo::actionWithDuration(t); - case 12: return FadeOutTRTilesDemo::actionWithDuration(t); - case 13: return FadeOutBLTilesDemo::actionWithDuration(t); - case 14: return FadeOutUpTilesDemo::actionWithDuration(t); - case 15: return FadeOutDownTilesDemo::actionWithDuration(t); - case 16: return TurnOffTilesDemo::actionWithDuration(t); - case 17: return WavesTiles3DDemo::actionWithDuration(t); - case 18: return JumpTiles3DDemo::actionWithDuration(t); - case 19: return SplitRowsDemo::actionWithDuration(t); - case 20: return SplitColsDemo::actionWithDuration(t); - case 21: return PageTurn3DDemo::actionWithDuration(t); + case 0: return Shaky3DDemo::create(t); + case 1: return Waves3DDemo::create(t); + case 2: return FlipX3DDemo::create(t); + case 3: return FlipY3DDemo::create(t); + case 4: return Lens3DDemo::create(t); + case 5: return Ripple3DDemo::create(t); + case 6: return LiquidDemo::create(t); + case 7: return WavesDemo::create(t); + case 8: return TwirlDemo::create(t); + case 9: return ShakyTiles3DDemo::create(t); + case 10: return ShatteredTiles3DDemo::create(t); + case 11: return ShuffleTilesDemo::create(t); + case 12: return FadeOutTRTilesDemo::create(t); + case 13: return FadeOutBLTilesDemo::create(t); + case 14: return FadeOutUpTilesDemo::create(t); + case 15: return FadeOutDownTilesDemo::create(t); + case 16: return TurnOffTilesDemo::create(t); + case 17: return WavesTiles3DDemo::create(t); + case 18: return JumpTiles3DDemo::create(t); + case 19: return SplitRowsDemo::create(t); + case 20: return SplitColsDemo::create(t); + case 21: return PageTurn3DDemo::create(t); } return NULL; @@ -331,7 +331,7 @@ CCActionInterval* getAction() void EffectTestScene::runThisTest() { - addChild(TextLayer::node()); + addChild(TextLayer::create()); CCDirector::sharedDirector()->replaceScene(this); } @@ -347,41 +347,41 @@ TextLayer::TextLayer(void) x = s.width; y = s.height; - CCNode* node = CCNode::node(); + CCNode* node = CCNode::create(); CCActionInterval* effect = getAction(); node->runAction(effect); addChild(node, 0, kTagBackground); - CCSprite *bg = CCSprite::spriteWithFile(s_back3); + CCSprite *bg = CCSprite::create(s_back3); node->addChild(bg, 0); // bg->setAnchorPoint( CCPointZero ); bg->setPosition(ccp(s.width/2, s.height/2)); - CCSprite* grossini = CCSprite::spriteWithFile(s_pPathSister2); + CCSprite* grossini = CCSprite::create(s_pPathSister2); node->addChild(grossini, 1); grossini->setPosition( CCPointMake(x/3,y/2) ); - CCActionInterval* sc = CCScaleBy::actionWithDuration(2, 5); + CCActionInterval* sc = CCScaleBy::create(2, 5); CCActionInterval* sc_back = sc->reverse(); - grossini->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)(CCSequence::actions(sc, sc_back, NULL)) ) ); + grossini->runAction( CCRepeatForever::create((CCActionInterval*)(CCSequence::create(sc, sc_back, NULL)) ) ); - CCSprite* tamara = CCSprite::spriteWithFile(s_pPathSister1); + CCSprite* tamara = CCSprite::create(s_pPathSister1); node->addChild(tamara, 1); tamara->setPosition( CCPointMake(2*x/3,y/2) ); - CCActionInterval* sc2 = CCScaleBy::actionWithDuration(2, 5); + CCActionInterval* sc2 = CCScaleBy::create(2, 5); CCActionInterval* sc2_back = sc2->reverse(); - tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)(CCSequence::actions(sc2, sc2_back, NULL))) ); + tamara->runAction( CCRepeatForever::create((CCActionInterval*)(CCSequence::create(sc2, sc2_back, NULL))) ); - CCLabelTTF* label = CCLabelTTF::labelWithString((effectsList[actionIdx]).c_str(), "Marker Felt", 32); + CCLabelTTF* label = CCLabelTTF::create((effectsList[actionIdx]).c_str(), "Marker Felt", 32); label->setPosition( CCPointMake(x/2,y-80) ); addChild(label); label->setTag( kTagLabel ); - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(TextLayer::backCallback) ); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(TextLayer::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(TextLayer::nextCallback) ); + CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(TextLayer::backCallback) ); + CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(TextLayer::restartCallback) ); + CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(TextLayer::nextCallback) ); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition(CCPointZero); item1->setPosition(CCPointMake( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2)); @@ -405,7 +405,12 @@ TextLayer::~TextLayer(void) { } -TextLayer* TextLayer::node() +// TextLayer* TextLayer::node() +// { +// return TextLayer::create(); +// } + +TextLayer* TextLayer::create() { TextLayer* pLayer = new TextLayer(); pLayer->autorelease(); @@ -421,7 +426,7 @@ void TextLayer::onEnter() void TextLayer::newScene() { CCScene* s = new EffectTestScene(); - CCNode* child = TextLayer::node(); + CCNode* child = TextLayer::create(); s->addChild(child); CCDirector::sharedDirector()->replaceScene(s); s->release(); diff --git a/tests/tests/EffectsTest/EffectsTest.h b/tests/tests/EffectsTest/EffectsTest.h index 022d0e8306..60b04f04b3 100644 --- a/tests/tests/EffectsTest/EffectsTest.h +++ b/tests/tests/EffectsTest/EffectsTest.h @@ -28,7 +28,9 @@ public: void newScene(); - static TextLayer* node(); + // @warning: This interface will be deprecated in future. + //static TextLayer* node(); + static TextLayer* create(); }; #endif diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder.cpp index 21329d770d..5241b835b1 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder.cpp +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder.cpp @@ -62,8 +62,8 @@ bool HelloCocosBuilder::callbackSetChildren(const char* name, CCObject* node) void HelloCocosBuilder::callbackAfterCCBLoaded() { CCLOG("loading.....successed!") ; - void* act = CCRotateBy::actionWithDuration(0.5f, 10) ; - void* act1 = CCRepeatForever::actionWithAction((CCActionInterval*)act) ; + void* act = CCRotateBy::create(0.5f, 10) ; + void* act1 = CCRepeatForever::create((CCActionInterval*)act) ; m_pSpriteBurst->runAction((CCAction*)act1) ; } @@ -86,7 +86,7 @@ SEL_MenuHandler HelloCocosBuilder::callbackGetSelectors(const char* selectorName void HelloCocosBuilder::pressedButton(CCObject*sender) { m_pSpriteIcon->stopAllActions() ; - void* rotateAction = CCRotateBy::actionWithDuration(1, 360) ; + void* rotateAction = CCRotateBy::create(1, 360) ; m_pSpriteIcon->runAction((CCAction*)rotateAction) ; } diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp index eb25a05279..b08b66ae01 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp @@ -39,7 +39,7 @@ bool CCControlButtonTest_HelloVariableSize::init() ccs("!"), NULL); - CCNode *layer = CCNode::node(); + CCNode *layer = CCNode::create(); addChild(layer, 1); double total_width = 0, height = 0; @@ -64,7 +64,7 @@ bool CCControlButtonTest_HelloVariableSize::init() layer->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f)); // Add the black background - CCScale9Sprite *background = CCScale9Sprite::spriteWithFile("extensions/buttonBackground.png"); + CCScale9Sprite *background = CCScale9Sprite::create("extensions/buttonBackground.png"); background->setContentSize(CCSizeMake(total_width + 14, height + 14)); background->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f)); addChild(background); @@ -76,14 +76,14 @@ bool CCControlButtonTest_HelloVariableSize::init() CCControlButton *CCControlButtonTest_HelloVariableSize::standardButtonWithTitle(const char * title) { /** Creates and return a button with a default background and title color. */ - CCScale9Sprite *backgroundButton = CCScale9Sprite::spriteWithFile("extensions/button.png"); - CCScale9Sprite *backgroundHighlightedButton = CCScale9Sprite::spriteWithFile("extensions/buttonHighlighted.png"); + CCScale9Sprite *backgroundButton = CCScale9Sprite::create("extensions/button.png"); + CCScale9Sprite *backgroundHighlightedButton = CCScale9Sprite::create("extensions/buttonHighlighted.png"); - CCLabelTTF *titleButton = CCLabelTTF::labelWithString(title, "Marker Felt", 30); + CCLabelTTF *titleButton = CCLabelTTF::create(title, "Marker Felt", 30); titleButton->setColor(ccc3(159, 168, 176)); - CCControlButton *button = CCControlButton::buttonWithLabelAndBackgroundSprite(titleButton, backgroundButton); + CCControlButton *button = CCControlButton::create(titleButton, backgroundButton); button->setBackgroundSpriteForState(backgroundHighlightedButton, CCControlStateHighlighted); button->setTitleColorForState(ccWHITE, CCControlStateHighlighted); @@ -108,20 +108,20 @@ bool CCControlButtonTest_Event::init() CCSize screenSize = CCDirector::sharedDirector()->getWinSize(); // Add a label in which the button events will be displayed - setDisplayValueLabel(CCLabelTTF::labelWithString("No Event", "Marker Felt", 32)); + setDisplayValueLabel(CCLabelTTF::create("No Event", "Marker Felt", 32)); m_pDisplayValueLabel->setAnchorPoint(ccp(0.5f, -1)); m_pDisplayValueLabel->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f)); addChild(m_pDisplayValueLabel, 1); // Add the button - CCScale9Sprite *backgroundButton = CCScale9Sprite::spriteWithFile("extensions/button.png"); - CCScale9Sprite *backgroundHighlightedButton = CCScale9Sprite::spriteWithFile("extensions/buttonHighlighted.png"); + CCScale9Sprite *backgroundButton = CCScale9Sprite::create("extensions/button.png"); + CCScale9Sprite *backgroundHighlightedButton = CCScale9Sprite::create("extensions/buttonHighlighted.png"); - CCLabelTTF *titleButton = CCLabelTTF::labelWithString("Touch Me!", "Marker Felt", 30); + CCLabelTTF *titleButton = CCLabelTTF::create("Touch Me!", "Marker Felt", 30); titleButton->setColor(ccc3(159, 168, 176)); - CCControlButton *controlButton = CCControlButton::buttonWithLabelAndBackgroundSprite(titleButton, backgroundButton); + CCControlButton *controlButton = CCControlButton::create(titleButton, backgroundButton); controlButton->setBackgroundSpriteForState(backgroundHighlightedButton, CCControlStateHighlighted); controlButton->setTitleColorForState(ccWHITE, CCControlStateHighlighted); @@ -130,7 +130,7 @@ bool CCControlButtonTest_Event::init() addChild(controlButton, 1); // Add the black background - CCScale9Sprite *background = CCScale9Sprite::spriteWithFile("extensions/buttonBackground.png"); + CCScale9Sprite *background = CCScale9Sprite::create("extensions/buttonBackground.png"); background->setContentSize(CCSizeMake(300, 170)); background->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f)); addChild(background); @@ -198,7 +198,7 @@ bool CCControlButtonTest_Styling::init() { CCSize screenSize = CCDirector::sharedDirector()->getWinSize(); - CCNode *layer = CCNode::node(); + CCNode *layer = CCNode::create(); addChild(layer, 1); int space = 10; // px @@ -226,7 +226,7 @@ bool CCControlButtonTest_Styling::init() layer->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f)); // Add the black background - CCScale9Sprite *backgroundButton = CCScale9Sprite::spriteWithFile("extensions/buttonBackground.png"); + CCScale9Sprite *backgroundButton = CCScale9Sprite::create("extensions/buttonBackground.png"); backgroundButton->setContentSize(CCSizeMake(max_w + 14, max_h + 14)); backgroundButton->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f)); addChild(backgroundButton); @@ -241,16 +241,16 @@ bool CCControlButtonTest_Styling::init() CCControlButton *CCControlButtonTest_Styling::standardButtonWithTitle(const char *title) { /** Creates and return a button with a default background and title color. */ - CCScale9Sprite *backgroundButton = CCScale9Sprite::spriteWithFile("extensions/button.png"); + CCScale9Sprite *backgroundButton = CCScale9Sprite::create("extensions/button.png"); backgroundButton->setPreferredSize(CCSizeMake(45, 45)); // Set the prefered size - CCScale9Sprite *backgroundHighlightedButton = CCScale9Sprite::spriteWithFile("extensions/buttonHighlighted.png"); + CCScale9Sprite *backgroundHighlightedButton = CCScale9Sprite::create("extensions/buttonHighlighted.png"); backgroundHighlightedButton->setPreferredSize(CCSizeMake(45, 45)); // Set the prefered size - CCLabelTTF *titleButton = CCLabelTTF::labelWithString(title, "Marker Felt", 30); + CCLabelTTF *titleButton = CCLabelTTF::create(title, "Marker Felt", 30); titleButton->setColor(ccc3(159, 168, 176)); - CCControlButton *button = CCControlButton::buttonWithLabelAndBackgroundSprite(titleButton, backgroundButton); + CCControlButton *button = CCControlButton::create(titleButton, backgroundButton); button->setBackgroundSpriteForState(backgroundHighlightedButton, CCControlStateHighlighted); button->setTitleColorForState(ccWHITE, CCControlStateHighlighted); diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h index 557bc334ff..a9089a1fb4 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h @@ -35,7 +35,7 @@ public: /** Creates and return a button with a default background and title color. */ CCControlButton *standardButtonWithTitle(const char * title); - CONTROL_SCENE_NODE_FUNC(CCControlButtonTest_HelloVariableSize) + CONTROL_SCENE_CREATE_FUNC(CCControlButtonTest_HelloVariableSize) }; class CCControlButtonTest_Event : public CCControlScene @@ -54,7 +54,7 @@ public: void touchCancelAction(CCObject *sender); protected: CC_SYNTHESIZE_RETAIN(CCLabelTTF *, m_pDisplayValueLabel, DisplayValueLabel) - CONTROL_SCENE_NODE_FUNC(CCControlButtonTest_Event) + CONTROL_SCENE_CREATE_FUNC(CCControlButtonTest_Event) }; @@ -63,7 +63,7 @@ class CCControlButtonTest_Styling : public CCControlScene public: bool init(); CCControlButton *standardButtonWithTitle(const char *title); - CONTROL_SCENE_NODE_FUNC(CCControlButtonTest_Styling) + CONTROL_SCENE_CREATE_FUNC(CCControlButtonTest_Styling) }; diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp index 0253fe9de0..e9fda7c44d 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp @@ -36,14 +36,14 @@ bool CCControlColourPickerTest::init() { CCSize screenSize = CCDirector::sharedDirector()->getWinSize(); - CCNode *layer = CCNode::node(); + CCNode *layer = CCNode::create(); layer->setPosition(ccp (screenSize.width / 2, screenSize.height / 2)); addChild(layer, 1); double layer_width = 0; // Create the colour picker - CCControlColourPicker *colourPicker = CCControlColourPicker::colourPicker(); + CCControlColourPicker *colourPicker = CCControlColourPicker::create(); colourPicker->setColor(ccc3(37, 46, 252)); colourPicker->setPosition(ccp (colourPicker->getContentSize().width / 2, 0)); @@ -57,14 +57,14 @@ bool CCControlColourPickerTest::init() layer_width += colourPicker->getContentSize().width; // Add the black background for the text - CCScale9Sprite *background = CCScale9Sprite::spriteWithFile("extensions/buttonBackground.png"); + CCScale9Sprite *background = CCScale9Sprite::create("extensions/buttonBackground.png"); background->setContentSize(CCSizeMake(150, 50)); background->setPosition(ccp(layer_width + background->getContentSize().width / 2.0f, 0)); layer->addChild(background); layer_width += background->getContentSize().width; - m_pColorLabel = CCLabelTTF::labelWithString("#color", "Marker Felt", 30); + m_pColorLabel = CCLabelTTF::create("#color", "Marker Felt", 30); m_pColorLabel->retain(); m_pColorLabel->setPosition(background->getPosition()); diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.h b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.h index 3888243cea..7d60c50343 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.h +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.h @@ -36,6 +36,6 @@ public: CC_SYNTHESIZE_RETAIN(CCLabelTTF*, m_pColorLabel, ColorLabel) - CONTROL_SCENE_NODE_FUNC(CCControlColourPickerTest) + CONTROL_SCENE_CREATE_FUNC(CCControlColourPickerTest) }; diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp index 0823afe5fc..fa4e477a67 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlScene.cpp @@ -45,35 +45,35 @@ bool CCControlScene::init() // Get the sceensize CCSize screensize = CCDirector::sharedDirector()->getWinSize(); - CCMenuItemFont* pBackItem = CCMenuItemFont::itemWithString("Back", this, + CCMenuItemFont* pBackItem = CCMenuItemFont::create("Back", this, menu_selector(CCControlScene::toExtensionsMainLayer)); pBackItem->setPosition(ccp(screensize.width - 50, 25)); - CCMenu* pBackMenu = CCMenu::menuWithItems(pBackItem, NULL); + CCMenu* pBackMenu = CCMenu::create(pBackItem, NULL); pBackMenu->setPosition( CCPointZero ); addChild(pBackMenu, 10); // Add the generated background - CCSprite *background = CCSprite::spriteWithFile("extensions/background.png"); + CCSprite *background = CCSprite::create("extensions/background.png"); background->setPosition(ccp(screensize.width / 2, screensize.height / 2)); addChild(background); // Add the ribbon - CCScale9Sprite *ribbon = CCScale9Sprite::spriteWithFile("extensions/ribbon.png", CCRectMake(1, 1, 48, 55)); + CCScale9Sprite *ribbon = CCScale9Sprite::create("extensions/ribbon.png", CCRectMake(1, 1, 48, 55)); ribbon->setContentSize(CCSizeMake(screensize.width, 57)); ribbon->setPosition(ccp(screensize.width / 2.0f, screensize.height - ribbon->getContentSize().height / 2.0f)); addChild(ribbon); // Add the title - setSceneTitleLabel(CCLabelTTF::labelWithString("Title", "Arial", 12)); + setSceneTitleLabel(CCLabelTTF::create("Title", "Arial", 12)); m_pSceneTitleLabel->setPosition(ccp (screensize.width / 2, screensize.height - m_pSceneTitleLabel->getContentSize().height / 2 - 5)); addChild(m_pSceneTitleLabel, 1); // Add the menu - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage("Images/b1.png", "Images/b2.png", this, menu_selector(CCControlScene::previousCallback)); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage("Images/r1.png", "Images/r2.png", this, menu_selector(CCControlScene::restartCallback)); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage("Images/f1.png", "Images/f2.png", this, menu_selector(CCControlScene::nextCallback)); + CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(CCControlScene::previousCallback)); + CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png", "Images/r2.png", this, menu_selector(CCControlScene::restartCallback)); + CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(CCControlScene::nextCallback)); - CCMenu *menu = CCMenu::menuWithItems(item1, item3, item2, NULL); + CCMenu *menu = CCMenu::create(item1, item3, item2, NULL); menu->setPosition(CCPointZero); item1->setPosition(ccp(screensize.width / 2 - 100, 37)); item2->setPosition(ccp(screensize.width / 2, 35)); diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlScene.h b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlScene.h index c2d99c5da1..cd4bc737e8 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlScene.h +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlScene.h @@ -32,11 +32,11 @@ USING_NS_CC; USING_NS_CC_EXT; -#define CONTROL_SCENE_NODE_FUNC(controlScene) \ +#define CONTROL_SCENE_CREATE_FUNC(controlScene) \ public: \ static CCScene* sceneWithTitle(const char * title) \ { \ - CCScene* pScene = CCScene::node(); \ + CCScene* pScene = CCScene::create(); \ controlScene* controlLayer = new controlScene(); \ if (controlLayer && controlLayer->init()) \ { \ @@ -67,7 +67,7 @@ public: /** Title label of the scene. */ CC_SYNTHESIZE_RETAIN(cocos2d::CCLabelTTF*, m_pSceneTitleLabel, SceneTitleLabel) - CONTROL_SCENE_NODE_FUNC(CCControlScene); + CONTROL_SCENE_CREATE_FUNC(CCControlScene); }; #endif /* __CCCONTROLSCENE_H__ */ diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp index cd2df363e3..50c5f8332a 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp @@ -43,14 +43,14 @@ bool CCControlSliderTest::init() CCSize screenSize = CCDirector::sharedDirector()->getWinSize(); // Add a label in which the slider value will be displayed - m_pDisplayValueLabel = CCLabelTTF::labelWithString("Move the slider thumb!" ,"Marker Felt", 32); + m_pDisplayValueLabel = CCLabelTTF::create("Move the slider thumb!" ,"Marker Felt", 32); m_pDisplayValueLabel->retain(); m_pDisplayValueLabel->setAnchorPoint(ccp(0.5f, -1.0f)); m_pDisplayValueLabel->setPosition(ccp(screenSize.width / 2.0f, screenSize.height / 2.0f)); addChild(m_pDisplayValueLabel); // Add the slider - CCControlSlider *slider = CCControlSlider::sliderWithFiles("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png"); + CCControlSlider *slider = CCControlSlider::create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png"); slider->setAnchorPoint(ccp(0.5f, 1.0f)); slider->setMinimumValue(0.0f); // Sets the min value of range slider->setMaximumValue(5.0f); // Sets the max value of range diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.h b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.h index 42e3db1f53..5e7fd7c536 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.h +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.h @@ -34,6 +34,6 @@ public: void valueChanged(CCObject *sender); protected: CCLabelTTF* m_pDisplayValueLabel; - CONTROL_SCENE_NODE_FUNC(CCControlSliderTest) + CONTROL_SCENE_CREATE_FUNC(CCControlSliderTest) }; diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp index 2a05144934..6c609b5cdf 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp @@ -38,35 +38,35 @@ bool CCControlSwitchTest::init() { CCSize screenSize = CCDirector::sharedDirector()->getWinSize(); - CCNode *layer = CCNode::node(); + CCNode *layer = CCNode::create(); layer->setPosition(ccp (screenSize.width / 2, screenSize.height / 2)); addChild(layer, 1); double layer_width = 0; // Add the black background for the text - CCScale9Sprite *background = CCScale9Sprite::spriteWithFile("extensions/buttonBackground.png"); + CCScale9Sprite *background = CCScale9Sprite::create("extensions/buttonBackground.png"); background->setContentSize(CCSizeMake(80, 50)); background->setPosition(ccp(layer_width + background->getContentSize().width / 2.0f, 0)); layer->addChild(background); layer_width += background->getContentSize().width; - m_pDisplayValueLabel = CCLabelTTF::labelWithString("#color" ,"Marker Felt" ,30); + m_pDisplayValueLabel = CCLabelTTF::create("#color" ,"Marker Felt" ,30); m_pDisplayValueLabel->retain(); m_pDisplayValueLabel->setPosition(background->getPosition()); layer->addChild(m_pDisplayValueLabel); // Create the switch - CCControlSwitch *switchControl = CCControlSwitch::switchWithMaskSprite + CCControlSwitch *switchControl = CCControlSwitch::create ( - CCSprite::spriteWithFile("extensions/switch-mask.png"), - CCSprite::spriteWithFile("extensions/switch-on.png"), - CCSprite::spriteWithFile("extensions/switch-off.png"), - CCSprite::spriteWithFile("extensions/switch-thumb.png"), - CCLabelTTF::labelWithString("On", "Arial-BoldMT", 16), - CCLabelTTF::labelWithString("Off", "Arial-BoldMT", 16) + CCSprite::create("extensions/switch-mask.png"), + CCSprite::create("extensions/switch-on.png"), + CCSprite::create("extensions/switch-off.png"), + CCSprite::create("extensions/switch-thumb.png"), + CCLabelTTF::create("On", "Arial-BoldMT", 16), + CCLabelTTF::create("Off", "Arial-BoldMT", 16) ); switchControl->setPosition(ccp (layer_width + 10 + switchControl->getContentSize().width / 2, 0)); layer->addChild(switchControl); diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.h b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.h index d97a272398..6efbc50294 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.h +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.h @@ -34,6 +34,6 @@ public: /** Callback for the change value. */ void valueChanged(CCObject* sender); CCLabelTTF *m_pDisplayValueLabel; - CONTROL_SCENE_NODE_FUNC(CCControlSwitchTest) + CONTROL_SCENE_CREATE_FUNC(CCControlSwitchTest) }; diff --git a/tests/tests/ExtensionsTest/ExtensionsTest.cpp b/tests/tests/ExtensionsTest/ExtensionsTest.cpp index b02823dfca..800a54bd2c 100644 --- a/tests/tests/ExtensionsTest/ExtensionsTest.cpp +++ b/tests/tests/ExtensionsTest/ExtensionsTest.cpp @@ -38,13 +38,13 @@ void ExtensionsMainLayer::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCMenu* pMenu = CCMenu::menuWithItems(NULL); + CCMenu* pMenu = CCMenu::create(); pMenu->setPosition( CCPointZero ); CCMenuItemFont::setFontName("Arial"); CCMenuItemFont::setFontSize(24); for (int i = 0; i < TEST_MAX_COUNT; ++i) { - CCMenuItemFont* pItem = CCMenuItemFont::itemWithString(testsName[i].c_str(), this, + CCMenuItemFont* pItem = CCMenuItemFont::create(testsName[i].c_str(), this, menu_selector(ExtensionsMainLayer::menuCallback)); pItem->setPosition(ccp(s.width / 2, s.height - (i + 1) * LINE_SPACE)); pMenu->addChild(pItem, kItemTagBasic + i); diff --git a/tests/tests/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp b/tests/tests/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp index d1f26c7468..9edbdd1393 100644 --- a/tests/tests/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp +++ b/tests/tests/ExtensionsTest/NotificationCenterTest/NotificationCenterTest.cpp @@ -83,25 +83,25 @@ NotificationCenterTest::NotificationCenterTest() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCMenuItemFont* pBackItem = CCMenuItemFont::itemWithString("Back", this, + CCMenuItemFont* pBackItem = CCMenuItemFont::create("Back", this, menu_selector(NotificationCenterTest::toExtensionsMainLayer)); pBackItem->setPosition(ccp(s.width - 50, 25)); - CCMenu* pBackMenu = CCMenu::menuWithItems(pBackItem, NULL); + CCMenu* pBackMenu = CCMenu::create(pBackItem, NULL); pBackMenu->setPosition( CCPointZero ); addChild(pBackMenu); - CCLabelTTF *label1 = CCLabelTTF::labelWithString("switch off", "Marker Felt", 26); - CCLabelTTF *label2 = CCLabelTTF::labelWithString("switch on", "Marker Felt", 26); - CCMenuItemLabel *item1 = CCMenuItemLabel::itemWithLabel(label1); - CCMenuItemLabel *item2 = CCMenuItemLabel::itemWithLabel(label2); - CCMenuItemToggle *item = CCMenuItemToggle::itemWithTarget(this, menu_selector(NotificationCenterTest::toggleSwitch), item1, item2, NULL); + CCLabelTTF *label1 = CCLabelTTF::create("switch off", "Marker Felt", 26); + CCLabelTTF *label2 = CCLabelTTF::create("switch on", "Marker Felt", 26); + CCMenuItemLabel *item1 = CCMenuItemLabel::create(label1); + CCMenuItemLabel *item2 = CCMenuItemLabel::create(label2); + CCMenuItemToggle *item = CCMenuItemToggle::create(this, menu_selector(NotificationCenterTest::toggleSwitch), item1, item2, NULL); // turn on item->setSelectedIndex(1); - CCMenu *menu = CCMenu::menuWithItems(item, NULL); + CCMenu *menu = CCMenu::create(item, NULL); menu->setPosition(ccp(s.width/2+100, s.height/2)); addChild(menu); - CCMenu *menuConnect = CCMenu::menuWithItems(NULL); + CCMenu *menuConnect = CCMenu::create(); menuConnect->setPosition(CCPointZero); addChild(menuConnect); @@ -112,11 +112,11 @@ NotificationCenterTest::NotificationCenterTest() light->setPosition(ccp(100, s.height/4*i)); addChild(light); - CCLabelTTF *label1 = CCLabelTTF::labelWithString("not connected", "Marker Felt", 26); - CCLabelTTF *label2 = CCLabelTTF::labelWithString("connected", "Marker Felt", 26); - CCMenuItemLabel *item1 = CCMenuItemLabel::itemWithLabel(label1); - CCMenuItemLabel *item2 = CCMenuItemLabel::itemWithLabel(label2); - CCMenuItemToggle *item = CCMenuItemToggle::itemWithTarget(this, menu_selector(NotificationCenterTest::connectToSwitch), item1, item2, NULL); + CCLabelTTF *label1 = CCLabelTTF::create("not connected", "Marker Felt", 26); + CCLabelTTF *label2 = CCLabelTTF::create("connected", "Marker Felt", 26); + CCMenuItemLabel *item1 = CCMenuItemLabel::create(label1); + CCMenuItemLabel *item2 = CCMenuItemLabel::create(label2); + CCMenuItemToggle *item = CCMenuItemToggle::create(this, menu_selector(NotificationCenterTest::connectToSwitch), item1, item2, NULL); item->setTag(kTagConnect+i); item->setPosition(ccp(light->getPosition().x, light->getPosition().y+50)); menuConnect->addChild(item, 0); @@ -155,7 +155,7 @@ void NotificationCenterTest::connectToSwitch(CCObject *sender) void runNotificationCenterTest() { - CCScene* pScene = CCScene::node(); + CCScene* pScene = CCScene::create(); NotificationCenterTest* pLayer = new NotificationCenterTest(); pScene->addChild(pLayer); CCDirector::sharedDirector()->replaceScene(pScene); diff --git a/tests/tests/FontTest/FontTest.cpp b/tests/tests/FontTest/FontTest.cpp index b533e92264..05a87c2857 100644 --- a/tests/tests/FontTest/FontTest.cpp +++ b/tests/tests/FontTest/FontTest.cpp @@ -67,11 +67,11 @@ static const char* restartAction(void) FontTest::FontTest() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(FontTest::backCallback)); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(FontTest::restartCallback)); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(FontTest::nextCallback)); + CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(FontTest::backCallback)); + CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(FontTest::restartCallback)); + CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(FontTest::nextCallback)); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition(CCPointZero); item1->setPosition(ccp( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2)); item2->setPosition(ccp( s.width/2, item2->getContentSize().height/2)); @@ -93,14 +93,14 @@ void FontTest::showFont(const char *pFont) removeChildByTag(kTagLabel3, true); removeChildByTag(kTagLabel4, true); - CCLabelTTF *top = CCLabelTTF::labelWithString(pFont, pFont, 24); - CCLabelTTF *left = CCLabelTTF::labelWithString("alignment left", blockSize, kCCTextAlignmentLeft, verticalAlignment[vAlignIdx], pFont, fontSize); - CCLabelTTF *center = CCLabelTTF::labelWithString("alignment center", blockSize, kCCTextAlignmentCenter, verticalAlignment[vAlignIdx], pFont, fontSize); - CCLabelTTF *right = CCLabelTTF::labelWithString("alignment right", blockSize, kCCTextAlignmentRight, verticalAlignment[vAlignIdx], pFont, fontSize); + CCLabelTTF *top = CCLabelTTF::create(pFont, pFont, 24); + CCLabelTTF *left = CCLabelTTF::create("alignment left", blockSize, kCCTextAlignmentLeft, verticalAlignment[vAlignIdx], pFont, fontSize); + CCLabelTTF *center = CCLabelTTF::create("alignment center", blockSize, kCCTextAlignmentCenter, verticalAlignment[vAlignIdx], pFont, fontSize); + CCLabelTTF *right = CCLabelTTF::create("alignment right", blockSize, kCCTextAlignmentRight, verticalAlignment[vAlignIdx], pFont, fontSize); - CCLayerColor *leftColor = CCLayerColor::layerWithColor(ccc4(100, 100, 100, 255), blockSize.width, blockSize.height); - CCLayerColor *centerColor = CCLayerColor::layerWithColor(ccc4(200, 100, 100, 255), blockSize.width, blockSize.height); - CCLayerColor *rightColor = CCLayerColor::layerWithColor(ccc4(100, 100, 200, 255), blockSize.width, blockSize.height); + CCLayerColor *leftColor = CCLayerColor::create(ccc4(100, 100, 100, 255), blockSize.width, blockSize.height); + CCLayerColor *centerColor = CCLayerColor::create(ccc4(200, 100, 100, 255), blockSize.width, blockSize.height); + CCLayerColor *rightColor = CCLayerColor::create(ccc4(100, 100, 200, 255), blockSize.width, blockSize.height); leftColor->setIgnoreAnchorPointForPosition(false); centerColor->setIgnoreAnchorPointForPosition(false); @@ -159,7 +159,7 @@ void FontTest::restartCallback(CCObject* pSender) ///--------------------------------------- void FontTestScene::runThisTest() { - CCLayer* pLayer = FontTest::node(); + CCLayer* pLayer = FontTest::create(); addChild(pLayer); CCDirector::sharedDirector()->replaceScene(this); diff --git a/tests/tests/FontTest/FontTest.h b/tests/tests/FontTest/FontTest.h index e81b5396c9..ac87cb55cc 100644 --- a/tests/tests/FontTest/FontTest.h +++ b/tests/tests/FontTest/FontTest.h @@ -21,7 +21,7 @@ public: void backCallback(CCObject* pSender); virtual std::string title(); - LAYER_NODE_FUNC(FontTest); + LAYER_CREATE_FUNC(FontTest); }; #endif // _FONT_TEST_H_ diff --git a/tests/tests/IntervalTest/IntervalTest.cpp b/tests/tests/IntervalTest/IntervalTest.cpp index f471b45049..18f8173abd 100644 --- a/tests/tests/IntervalTest/IntervalTest.cpp +++ b/tests/tests/IntervalTest/IntervalTest.cpp @@ -15,7 +15,7 @@ IntervalLayer::IntervalLayer() CCSize s = CCDirector::sharedDirector()->getWinSize(); // sun - CCParticleSystem* sun = CCParticleSun::node(); + CCParticleSystem* sun = CCParticleSun::create(); sun->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png")); sun->setPosition( CCPointMake(s.width-32,s.height-32) ); @@ -24,11 +24,11 @@ IntervalLayer::IntervalLayer() this->addChild(sun); // timers - m_label0 = CCLabelBMFont::labelWithString("0", "fonts/bitmapFontTest4.fnt"); - m_label1 = CCLabelBMFont::labelWithString("0", "fonts/bitmapFontTest4.fnt"); - m_label2 = CCLabelBMFont::labelWithString("0", "fonts/bitmapFontTest4.fnt"); - m_label3 = CCLabelBMFont::labelWithString("0", "fonts/bitmapFontTest4.fnt"); - m_label4 = CCLabelBMFont::labelWithString("0", "fonts/bitmapFontTest4.fnt"); + m_label0 = CCLabelBMFont::create("0", "fonts/bitmapFontTest4.fnt"); + m_label1 = CCLabelBMFont::create("0", "fonts/bitmapFontTest4.fnt"); + m_label2 = CCLabelBMFont::create("0", "fonts/bitmapFontTest4.fnt"); + m_label3 = CCLabelBMFont::create("0", "fonts/bitmapFontTest4.fnt"); + m_label4 = CCLabelBMFont::create("0", "fonts/bitmapFontTest4.fnt"); scheduleUpdate(); schedule(schedule_selector(IntervalLayer::step1)); @@ -49,19 +49,19 @@ IntervalLayer::IntervalLayer() addChild(m_label4); // Sprite - CCSprite* sprite = CCSprite::spriteWithFile(s_pPathGrossini); + CCSprite* sprite = CCSprite::create(s_pPathGrossini); sprite->setPosition( CCPointMake(40,50) ); - CCJumpBy* jump = CCJumpBy::actionWithDuration(3, CCPointMake(s.width-80,0), 50, 4); + CCJumpBy* jump = CCJumpBy::create(3, CCPointMake(s.width-80,0), 50, 4); addChild(sprite); - sprite->runAction( CCRepeatForever::actionWithAction( - (CCActionInterval*)(CCSequence::actions(jump, jump->reverse(), NULL )) + sprite->runAction( CCRepeatForever::create( + (CCActionInterval*)(CCSequence::create(jump, jump->reverse(), NULL )) ) ); // pause button - CCMenuItem* item1 = CCMenuItemFont::itemWithString("Pause", this, menu_selector(IntervalLayer::onPause) ); - CCMenu* menu = CCMenu::menuWithItems(item1, NULL); + CCMenuItem* item1 = CCMenuItemFont::create("Pause", this, menu_selector(IntervalLayer::onPause) ); + CCMenu* menu = CCMenu::create(item1, NULL); menu->setPosition( CCPointMake(s.width/2, s.height-50) ); addChild( menu ); diff --git a/tests/tests/KeypadTest/KeypadTest.cpp b/tests/tests/KeypadTest/KeypadTest.cpp index 3072280681..b59b3b66c1 100644 --- a/tests/tests/KeypadTest/KeypadTest.cpp +++ b/tests/tests/KeypadTest/KeypadTest.cpp @@ -4,14 +4,14 @@ KeypadTest::KeypadTest() : m_bShow(true) { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF* label = CCLabelTTF::labelWithString("Keypad Test", "Arial", 28); + CCLabelTTF* label = CCLabelTTF::create("Keypad Test", "Arial", 28); addChild(label, 0); label->setPosition( ccp(s.width/2, s.height-50) ); setIsKeypadEnabled(true); // create a label to display the tip string - m_pLabel = CCLabelTTF::labelWithString("Please press any key...", "Arial", 22); + m_pLabel = CCLabelTTF::create("Please press any key...", "Arial", 22); m_pLabel->setPosition(ccp(s.width / 2, s.height / 2)); addChild(m_pLabel, 0); diff --git a/tests/tests/LabelTest/LabelTest.cpp b/tests/tests/LabelTest/LabelTest.cpp index ed1bfc966d..637753efe0 100644 --- a/tests/tests/LabelTest/LabelTest.cpp +++ b/tests/tests/LabelTest/LabelTest.cpp @@ -136,23 +136,23 @@ void AtlasDemo::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 28); + CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 28); addChild(label, 1); label->setPosition( ccp(s.width/2, s.height-50) ); std::string strSubtitle = subtitle(); if( ! strSubtitle.empty() ) { - CCLabelTTF* l = CCLabelTTF::labelWithString(strSubtitle.c_str(), "Thonburi", 16); + CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16); addChild(l, 1); l->setPosition( ccp(s.width/2, s.height-80) ); } - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(AtlasDemo::backCallback) ); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(AtlasDemo::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(AtlasDemo::nextCallback) ); + CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(AtlasDemo::backCallback) ); + CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(AtlasDemo::restartCallback) ); + CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(AtlasDemo::nextCallback) ); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition( CCPointZero ); item1->setPosition( ccp( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2)); @@ -269,12 +269,12 @@ LabelAtlasTest::LabelAtlasTest() { m_time = 0; - CCLabelAtlas* label1 = CCLabelAtlas::labelWithString("123 Test", "fonts/tuffy_bold_italic-charmap.plist"); + CCLabelAtlas* label1 = CCLabelAtlas::create("123 Test", "fonts/tuffy_bold_italic-charmap.plist"); addChild(label1, 0, kTagSprite1); label1->setPosition( ccp(10,100) ); label1->setOpacity( 200 ); - CCLabelAtlas *label2 = CCLabelAtlas::labelWithString("0123456789", "fonts/tuffy_bold_italic-charmap.plist"); + CCLabelAtlas *label2 = CCLabelAtlas::create("0123456789", "fonts/tuffy_bold_italic-charmap.plist"); addChild(label2, 0, kTagSprite2); label2->setPosition( ccp(10,200) ); label2->setOpacity( 32 ); @@ -316,20 +316,20 @@ std::string LabelAtlasTest::subtitle() //------------------------------------------------------------------ LabelAtlasColorTest::LabelAtlasColorTest() { - CCLabelAtlas* label1 = CCLabelAtlas::labelWithString("123 Test", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); + CCLabelAtlas* label1 = CCLabelAtlas::create("123 Test", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); addChild(label1, 0, kTagSprite1); label1->setPosition( ccp(10,100) ); label1->setOpacity( 200 ); - CCLabelAtlas* label2 = CCLabelAtlas::labelWithString("0123456789", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); + CCLabelAtlas* label2 = CCLabelAtlas::create("0123456789", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); addChild(label2, 0, kTagSprite2); label2->setPosition( ccp(10,200) ); label2->setColor( ccRED ); - CCActionInterval* fade = CCFadeOut::actionWithDuration(1.0f); + CCActionInterval* fade = CCFadeOut::create(1.0f); CCActionInterval* fade_in = fade->reverse(); - CCFiniteTimeAction* seq = CCSequence::actions(fade, fade_in, NULL); - CCAction* repeat = CCRepeatForever::actionWithAction( (CCActionInterval*)seq ); + CCFiniteTimeAction* seq = CCSequence::create(fade, fade_in, NULL); + CCAction* repeat = CCRepeatForever::create( (CCActionInterval*)seq ); label2->runAction( repeat ); m_time = 0; @@ -371,17 +371,17 @@ LabelTTFAlignment::LabelTTFAlignment() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF* ttf0 = CCLabelTTF::labelWithString("Alignment 0\nnew line", CCSizeMake(256, 32), kCCTextAlignmentLeft, "Helvetica", 12); + CCLabelTTF* ttf0 = CCLabelTTF::create("Alignment 0\nnew line", CCSizeMake(256, 32), kCCTextAlignmentLeft, "Helvetica", 12); ttf0->setPosition(ccp(s.width/2,(s.height/6)*2)); ttf0->setAnchorPoint(ccp(0.5f,0.5f)); this->addChild(ttf0); - CCLabelTTF* ttf1 = CCLabelTTF::labelWithString("Alignment 1\nnew line", CCSizeMake(245, 32), kCCTextAlignmentCenter, "Helvetica", 12); + CCLabelTTF* ttf1 = CCLabelTTF::create("Alignment 1\nnew line", CCSizeMake(245, 32), kCCTextAlignmentCenter, "Helvetica", 12); ttf1->setPosition(ccp(s.width/2,(s.height/6)*3)); ttf1->setAnchorPoint(ccp(0.5f,0.5f)); this->addChild(ttf1); - CCLabelTTF* ttf2 = CCLabelTTF::labelWithString("Alignment 2\nnew line", CCSizeMake(245, 32), kCCTextAlignmentRight, "Helvetica", 12); + CCLabelTTF* ttf2 = CCLabelTTF::create("Alignment 2\nnew line", CCSizeMake(245, 32), kCCTextAlignmentRight, "Helvetica", 12); ttf2->setPosition(ccp(s.width/2,(s.height/6)*4)); ttf2->setAnchorPoint(ccp(0.5f,0.5f)); this->addChild(ttf2); @@ -411,18 +411,18 @@ Atlas3::Atlas3() { m_time = 0; - CCLayerColor* col = CCLayerColor::layerWithColor( ccc4(128,128,128,255) ); + CCLayerColor* col = CCLayerColor::create( ccc4(128,128,128,255) ); addChild(col, -10); - CCLabelBMFont* label1 = CCLabelBMFont::labelWithString("Test", "fonts/bitmapFontTest2.fnt"); + CCLabelBMFont* label1 = CCLabelBMFont::create("Test", "fonts/bitmapFontTest2.fnt"); // testing anchors label1->setAnchorPoint( ccp(0,0) ); addChild(label1, 0, kTagBitmapAtlas1); - CCActionInterval* fade = CCFadeOut::actionWithDuration(1.0f); + CCActionInterval* fade = CCFadeOut::create(1.0f); CCActionInterval* fade_in = fade->reverse(); - CCFiniteTimeAction* seq = CCSequence::actions(fade, fade_in, NULL); - CCAction* repeat = CCRepeatForever::actionWithAction((CCActionInterval*)seq); + CCFiniteTimeAction* seq = CCSequence::create(fade, fade_in, NULL); + CCAction* repeat = CCRepeatForever::create((CCActionInterval*)seq); label1->runAction(repeat); @@ -430,14 +430,14 @@ Atlas3::Atlas3() // color and opacity work OK because bitmapFontAltas2 loads a BMP image (not a PNG image) // If you want to use both opacity and color, it is recommended to use NON premultiplied images like BMP images // Of course, you can also tell XCode not to compress PNG images, but I think it doesn't work as expected - CCLabelBMFont *label2 = CCLabelBMFont::labelWithString("Test", "fonts/bitmapFontTest2.fnt"); + CCLabelBMFont *label2 = CCLabelBMFont::create("Test", "fonts/bitmapFontTest2.fnt"); // testing anchors label2->setAnchorPoint( ccp(0.5f, 0.5f) ); label2->setColor( ccRED ); addChild(label2, 0, kTagBitmapAtlas2); label2->runAction( (CCAction*)(repeat->copy()->autorelease()) ); - CCLabelBMFont* label3 = CCLabelBMFont::labelWithString("Test", "fonts/bitmapFontTest2.fnt"); + CCLabelBMFont* label3 = CCLabelBMFont::create("Test", "fonts/bitmapFontTest2.fnt"); // testing anchors label3->setAnchorPoint( ccp(1,1) ); addChild(label3, 0, kTagBitmapAtlas3); @@ -496,7 +496,7 @@ Atlas4::Atlas4() m_time = 0; // Upper Label - CCLabelBMFont *label = CCLabelBMFont::labelWithString("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt"); + CCLabelBMFont *label = CCLabelBMFont::create("Bitmap Font Atlas", "fonts/bitmapFontTest.fnt"); addChild(label); CCSize s = CCDirector::sharedDirector()->getWinSize(); @@ -510,21 +510,21 @@ Atlas4::Atlas4() CCSprite* AChar = (CCSprite*) label->getChildByTag(12); - CCActionInterval* rotate = CCRotateBy::actionWithDuration(2, 360); - CCAction* rot_4ever = CCRepeatForever::actionWithAction(rotate); + CCActionInterval* rotate = CCRotateBy::create(2, 360); + CCAction* rot_4ever = CCRepeatForever::create(rotate); - CCActionInterval* scale = CCScaleBy::actionWithDuration(2, 1.5f); + CCActionInterval* scale = CCScaleBy::create(2, 1.5f); CCActionInterval* scale_back = scale->reverse(); - CCFiniteTimeAction* scale_seq = CCSequence::actions(scale, scale_back,NULL); - CCAction* scale_4ever = CCRepeatForever::actionWithAction((CCActionInterval*)scale_seq); + CCFiniteTimeAction* scale_seq = CCSequence::create(scale, scale_back,NULL); + CCAction* scale_4ever = CCRepeatForever::create((CCActionInterval*)scale_seq); - CCActionInterval* jump = CCJumpBy::actionWithDuration(0.5f, CCPointZero, 60, 1); - CCAction* jump_4ever = CCRepeatForever::actionWithAction(jump); + CCActionInterval* jump = CCJumpBy::create(0.5f, CCPointZero, 60, 1); + CCAction* jump_4ever = CCRepeatForever::create(jump); - CCActionInterval* fade_out = CCFadeOut::actionWithDuration(1); - CCActionInterval* fade_in = CCFadeIn::actionWithDuration(1); - CCFiniteTimeAction* seq = CCSequence::actions(fade_out, fade_in, NULL); - CCAction* fade_4ever = CCRepeatForever::actionWithAction((CCActionInterval*)seq); + CCActionInterval* fade_out = CCFadeOut::create(1); + CCActionInterval* fade_in = CCFadeIn::create(1); + CCFiniteTimeAction* seq = CCSequence::create(fade_out, fade_in, NULL); + CCAction* fade_4ever = CCRepeatForever::create((CCActionInterval*)seq); BChar->runAction(rot_4ever); BChar->runAction(scale_4ever); @@ -533,7 +533,7 @@ Atlas4::Atlas4() // Bottom Label - CCLabelBMFont *label2 = CCLabelBMFont::labelWithString("00.0", "fonts/bitmapFontTest.fnt"); + CCLabelBMFont *label2 = CCLabelBMFont::create("00.0", "fonts/bitmapFontTest.fnt"); addChild(label2, 0, kTagBitmapAtlas2); label2->setPosition( ccp(s.width/2.0f, 80) ); @@ -586,7 +586,7 @@ std::string Atlas4::subtitle() Atlas5::Atlas5() { - CCLabelBMFont *label = CCLabelBMFont::labelWithString("abcdefg", "fonts/bitmapFontTest4.fnt"); + CCLabelBMFont *label = CCLabelBMFont::create("abcdefg", "fonts/bitmapFontTest4.fnt"); addChild(label); CCSize s = CCDirector::sharedDirector()->getWinSize(); @@ -621,17 +621,17 @@ Atlas6::Atlas6() CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLabelBMFont* label = NULL; - label = CCLabelBMFont::labelWithString("FaFeFiFoFu", "fonts/bitmapFontTest5.fnt"); + label = CCLabelBMFont::create("FaFeFiFoFu", "fonts/bitmapFontTest5.fnt"); addChild(label); label->setPosition( ccp(s.width/2, s.height/2+50) ); label->setAnchorPoint( ccp(0.5f, 0.5f) ) ; - label = CCLabelBMFont::labelWithString("fafefifofu", "fonts/bitmapFontTest5.fnt"); + label = CCLabelBMFont::create("fafefifofu", "fonts/bitmapFontTest5.fnt"); addChild(label); label->setPosition( ccp(s.width/2, s.height/2) ); label->setAnchorPoint( ccp(0.5f, 0.5f) ); - label = CCLabelBMFont::labelWithString("aeiou", "fonts/bitmapFontTest5.fnt"); + label = CCLabelBMFont::create("aeiou", "fonts/bitmapFontTest5.fnt"); addChild(label); label->setPosition( ccp(s.width/2, s.height/2-50) ); label->setAnchorPoint( ccp(0.5f, 0.5f) ); @@ -663,19 +663,19 @@ AtlasBitmapColor::AtlasBitmapColor() CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLabelBMFont* label = NULL; - label = CCLabelBMFont::labelWithString("Blue", "fonts/bitmapFontTest5.fnt"); + label = CCLabelBMFont::create("Blue", "fonts/bitmapFontTest5.fnt"); label->setColor( ccBLUE ); addChild(label); label->setPosition( ccp(s.width/2, s.height/4) ); label->setAnchorPoint( ccp(0.5f, 0.5f) ); - label = CCLabelBMFont::labelWithString("Red", "fonts/bitmapFontTest5.fnt"); + label = CCLabelBMFont::create("Red", "fonts/bitmapFontTest5.fnt"); addChild(label); label->setPosition( ccp(s.width/2, 2*s.height/4) ); label->setAnchorPoint( ccp(0.5f, 0.5f) ); label->setColor( ccRED ); - label = CCLabelBMFont::labelWithString("G", "fonts/bitmapFontTest5.fnt"); + label = CCLabelBMFont::create("G", "fonts/bitmapFontTest5.fnt"); addChild(label); label->setPosition( ccp(s.width/2, 3*s.height/4) ); label->setAnchorPoint( ccp(0.5f, 0.5f) ); @@ -712,7 +712,7 @@ AtlasFastBitmap::AtlasFastBitmap() { char str[6] = {0}; sprintf(str, "-%d-", i); - CCLabelBMFont* label = CCLabelBMFont::labelWithString(str, "fonts/bitmapFontTest.fnt"); + CCLabelBMFont* label = CCLabelBMFont::create(str, "fonts/bitmapFontTest.fnt"); addChild(label); CCSize s = CCDirector::sharedDirector()->getWinSize(); @@ -749,7 +749,7 @@ BitmapFontMultiLine::BitmapFontMultiLine() CCSize s; // Left - CCLabelBMFont *label1 = CCLabelBMFont::labelWithString(" Multi line\nLeft", "fonts/bitmapFontTest3.fnt"); + CCLabelBMFont *label1 = CCLabelBMFont::create(" Multi line\nLeft", "fonts/bitmapFontTest3.fnt"); label1->setAnchorPoint(ccp(0,0)); addChild(label1, 0, kTagBitmapAtlas1); @@ -758,7 +758,7 @@ BitmapFontMultiLine::BitmapFontMultiLine() // Center - CCLabelBMFont *label2 = CCLabelBMFont::labelWithString("Multi line\nCenter", "fonts/bitmapFontTest3.fnt"); + CCLabelBMFont *label2 = CCLabelBMFont::create("Multi line\nCenter", "fonts/bitmapFontTest3.fnt"); label2->setAnchorPoint(ccp(0.5f, 0.5f)); addChild(label2, 0, kTagBitmapAtlas2); @@ -766,7 +766,7 @@ BitmapFontMultiLine::BitmapFontMultiLine() CCLOG("content size: %.2fx%.2f", s.width, s.height); // right - CCLabelBMFont *label3 = CCLabelBMFont::labelWithString("Multi line\nRight\nThree lines Three", "fonts/bitmapFontTest3.fnt"); + CCLabelBMFont *label3 = CCLabelBMFont::create("Multi line\nRight\nThree lines Three", "fonts/bitmapFontTest3.fnt"); label3->setAnchorPoint(ccp(1, 1)); addChild(label3, 0, kTagBitmapAtlas3); @@ -799,17 +799,17 @@ LabelsEmpty::LabelsEmpty() CCSize s = CCDirector::sharedDirector()->getWinSize(); // CCLabelBMFont - CCLabelBMFont *label1 = CCLabelBMFont::labelWithString("", "fonts/bitmapFontTest3.fnt"); + CCLabelBMFont *label1 = CCLabelBMFont::create("", "fonts/bitmapFontTest3.fnt"); addChild(label1, 0, kTagBitmapAtlas1); label1->setPosition(ccp(s.width/2, s.height-100)); // CCLabelTTF - CCLabelTTF* label2 = CCLabelTTF::labelWithString("", "Arial", 24); + CCLabelTTF* label2 = CCLabelTTF::create("", "Arial", 24); addChild(label2, 0, kTagBitmapAtlas2); label2->setPosition(ccp(s.width/2, s.height/2)); // CCLabelAtlas - CCLabelAtlas *label3 = CCLabelAtlas::labelWithString("", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); + CCLabelAtlas *label3 = CCLabelAtlas::create("", "fonts/tuffy_bold_italic-charmap.png", 48, 64, ' '); addChild(label3, 0, kTagBitmapAtlas3); label3->setPosition(ccp(s.width/2, 0+100)); @@ -862,7 +862,7 @@ LabelBMFontHD::LabelBMFontHD() CCSize s = CCDirector::sharedDirector()->getWinSize(); // CCLabelBMFont - CCLabelBMFont *label1 = CCLabelBMFont::labelWithString("TESTING RETINA DISPLAY", "fonts/konqa32.fnt"); + CCLabelBMFont *label1 = CCLabelBMFont::create("TESTING RETINA DISPLAY", "fonts/konqa32.fnt"); addChild(label1); label1->setPosition(ccp(s.width/2, s.height/2)); } @@ -887,7 +887,7 @@ LabelAtlasHD::LabelAtlasHD() CCSize s = CCDirector::sharedDirector()->getWinSize(); // CCLabelBMFont - CCLabelAtlas *label1 = CCLabelAtlas::labelWithString("TESTING RETINA DISPLAY", "fonts/larabie-16.plist"); + CCLabelAtlas *label1 = CCLabelAtlas::create("TESTING RETINA DISPLAY", "fonts/larabie-16.plist"); label1->setAnchorPoint(ccp(0.5f, 0.5f)); addChild(label1); @@ -913,11 +913,11 @@ LabelGlyphDesigner::LabelGlyphDesigner() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLayerColor *layer = CCLayerColor::layerWithColor(ccc4(128,128,128,255)); + CCLayerColor *layer = CCLayerColor::create(ccc4(128,128,128,255)); addChild(layer, -10); // CCLabelBMFont - CCLabelBMFont *label1 = CCLabelBMFont::labelWithString("Testing Glyph Designer", "fonts/futura-48.fnt"); + CCLabelBMFont *label1 = CCLabelBMFont::create("Testing Glyph Designer", "fonts/futura-48.fnt"); addChild(label1); label1->setPosition(ccp(s.width/2, s.height/2)); } @@ -950,26 +950,26 @@ LabelTTFTest::LabelTTFTest() CCSize blockSize = CCSizeMake(200, 160); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLayerColor *colorLayer = CCLayerColor::layerWithColor(ccc4(100, 100, 100, 255), blockSize.width, blockSize.height); + CCLayerColor *colorLayer = CCLayerColor::create(ccc4(100, 100, 100, 255), blockSize.width, blockSize.height); colorLayer->setAnchorPoint(ccp(0,0)); colorLayer->setPosition(ccp((s.width - blockSize.width) / 2, (s.height - blockSize.height) / 2)); this->addChild(colorLayer); CCMenuItemFont::setFontSize(30); - CCMenu *menu = CCMenu::menuWithItems( - CCMenuItemFont::itemWithString("Left", this, menu_selector(LabelTTFTest::setAlignmentLeft)), - CCMenuItemFont::itemWithString("Center", this, menu_selector(LabelTTFTest::setAlignmentCenter)), - CCMenuItemFont::itemWithString("Right", this, menu_selector(LabelTTFTest::setAlignmentRight)), + CCMenu *menu = CCMenu::create( + CCMenuItemFont::create("Left", this, menu_selector(LabelTTFTest::setAlignmentLeft)), + CCMenuItemFont::create("Center", this, menu_selector(LabelTTFTest::setAlignmentCenter)), + CCMenuItemFont::create("Right", this, menu_selector(LabelTTFTest::setAlignmentRight)), NULL); menu->alignItemsVerticallyWithPadding(4); menu->setPosition(ccp(50, s.height / 2 - 20)); this->addChild(menu); - menu = CCMenu::menuWithItems( - CCMenuItemFont::itemWithString("Top", this, menu_selector(LabelTTFTest::setAlignmentTop)), - CCMenuItemFont::itemWithString("Middle", this, menu_selector(LabelTTFTest::setAlignmentMiddle)), - CCMenuItemFont::itemWithString("Bottom", this, menu_selector(LabelTTFTest::setAlignmentBottom)), + menu = CCMenu::create( + CCMenuItemFont::create("Top", this, menu_selector(LabelTTFTest::setAlignmentTop)), + CCMenuItemFont::create("Middle", this, menu_selector(LabelTTFTest::setAlignmentMiddle)), + CCMenuItemFont::create("Bottom", this, menu_selector(LabelTTFTest::setAlignmentBottom)), NULL); menu->alignItemsVerticallyWithPadding(4); menu->setPosition(ccp(s.width - 50, s.height / 2 - 20)); @@ -997,7 +997,7 @@ void LabelTTFTest::updateAlignment() m_plabel->removeFromParentAndCleanup(true); } - m_plabel = CCLabelTTF::labelWithString(this->getCurrentAlignment(), blockSize, m_eHorizAlign, m_eVertAlign, "Marker Felt", 32); + m_plabel = CCLabelTTF::create(this->getCurrentAlignment(), blockSize, m_eHorizAlign, m_eVertAlign, "Marker Felt", 32); m_plabel->retain(); m_plabel->setAnchorPoint(ccp(0,0)); @@ -1086,7 +1086,7 @@ LabelTTFMultiline::LabelTTFMultiline() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF *center = CCLabelTTF::labelWithString("word wrap \"testing\" (bla0) bla1 'bla2' [bla3] (bla4) {bla5} {bla6} [bla7] (bla8) [bla9] 'bla0' \"bla1\"", + CCLabelTTF *center = CCLabelTTF::create("word wrap \"testing\" (bla0) bla1 'bla2' [bla3] (bla4) {bla5} {bla6} [bla7] (bla8) [bla9] 'bla0' \"bla1\"", CCSizeMake(s.width/2,200), kCCTextAlignmentCenter, kCCVerticalTextAlignmentTop, @@ -1111,7 +1111,7 @@ string LabelTTFMultiline::subtitle() LabelTTFChinese::LabelTTFChinese() { CCSize size = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF *pLable = CCLabelTTF::labelWithString("中国", "Marker Felt", 30); + CCLabelTTF *pLable = CCLabelTTF::create("中国", "Marker Felt", 30); pLable->setPosition(ccp(size.width / 2, size.height /2)); this->addChild(pLable); } @@ -1124,7 +1124,7 @@ string LabelTTFChinese::title() LabelBMFontChinese::LabelBMFontChinese() { CCSize size = CCDirector::sharedDirector()->getWinSize(); - CCLabelBMFont* pLable = CCLabelBMFont::labelWithString("中国", "fonts/bitmapFontChinese.fnt"); + CCLabelBMFont* pLable = CCLabelBMFont::create("中国", "fonts/bitmapFontChinese.fnt"); pLable->setPosition(ccp(size.width / 2, size.height /2)); this->addChild(pLable); } @@ -1161,19 +1161,19 @@ BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment() CCSize size = CCDirector::sharedDirector()->getWinSize(); // create and initialize a Label - this->m_pLabelShouldRetain = CCLabelBMFont::labelWithString(LongSentencesExample, "fonts/markerFelt.fnt", size.width/1.5, kCCTextAlignmentCenter); + this->m_pLabelShouldRetain = CCLabelBMFont::create(LongSentencesExample, "fonts/markerFelt.fnt", size.width/1.5, kCCTextAlignmentCenter); this->m_pLabelShouldRetain->retain(); - this->m_pArrowsBarShouldRetain = CCSprite::spriteWithFile("Images/arrowsBar.png"); + this->m_pArrowsBarShouldRetain = CCSprite::create("Images/arrowsBar.png"); this->m_pArrowsBarShouldRetain->retain(); - this->m_pArrowsShouldRetain = CCSprite::spriteWithFile("Images/arrows.png"); + this->m_pArrowsShouldRetain = CCSprite::create("Images/arrows.png"); this->m_pArrowsShouldRetain->retain(); CCMenuItemFont::setFontSize(20); - CCMenuItemFont *longSentences = CCMenuItemFont::itemWithString("Long Flowing Sentences", this, menu_selector(BitmapFontMultiLineAlignment::stringChanged)); - CCMenuItemFont *lineBreaks = CCMenuItemFont::itemWithString("Short Sentences With Intentional Line Breaks", this, menu_selector(BitmapFontMultiLineAlignment::stringChanged)); - CCMenuItemFont *mixed = CCMenuItemFont::itemWithString("Long Sentences Mixed With Intentional Line Breaks", this, menu_selector(BitmapFontMultiLineAlignment::stringChanged)); - CCMenu *stringMenu = CCMenu::menuWithItems(longSentences, lineBreaks, mixed, NULL); + CCMenuItemFont *longSentences = CCMenuItemFont::create("Long Flowing Sentences", this, menu_selector(BitmapFontMultiLineAlignment::stringChanged)); + CCMenuItemFont *lineBreaks = CCMenuItemFont::create("Short Sentences With Intentional Line Breaks", this, menu_selector(BitmapFontMultiLineAlignment::stringChanged)); + CCMenuItemFont *mixed = CCMenuItemFont::create("Long Sentences Mixed With Intentional Line Breaks", this, menu_selector(BitmapFontMultiLineAlignment::stringChanged)); + CCMenu *stringMenu = CCMenu::create(longSentences, lineBreaks, mixed, NULL); stringMenu->alignItemsVertically(); longSentences->setColor(ccRED); @@ -1184,10 +1184,10 @@ BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment() CCMenuItemFont::setFontSize(30); - CCMenuItemFont *left = CCMenuItemFont::itemWithString("Left", this, menu_selector(BitmapFontMultiLineAlignment::alignmentChanged)); - CCMenuItemFont *center = CCMenuItemFont::itemWithString("Center", this, menu_selector(BitmapFontMultiLineAlignment::alignmentChanged)); - CCMenuItemFont *right = CCMenuItemFont::itemWithString("Right", this, menu_selector(BitmapFontMultiLineAlignment::alignmentChanged)); - CCMenu *alignmentMenu = CCMenu::menuWithItems(left, center, right, NULL); + CCMenuItemFont *left = CCMenuItemFont::create("Left", this, menu_selector(BitmapFontMultiLineAlignment::alignmentChanged)); + CCMenuItemFont *center = CCMenuItemFont::create("Center", this, menu_selector(BitmapFontMultiLineAlignment::alignmentChanged)); + CCMenuItemFont *right = CCMenuItemFont::create("Right", this, menu_selector(BitmapFontMultiLineAlignment::alignmentChanged)); + CCMenu *alignmentMenu = CCMenu::create(left, center, right, NULL); alignmentMenu->alignItemsHorizontallyWithPadding(alignmentItemPadding); center->setColor(ccRED); @@ -1337,19 +1337,19 @@ LabelTTFA8Test::LabelTTFA8Test() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLayerColor *layer = CCLayerColor::layerWithColor(ccc4(128, 128, 128, 255)); + CCLayerColor *layer = CCLayerColor::create(ccc4(128, 128, 128, 255)); addChild(layer, -10); // CCLabelBMFont - CCLabelTTF *label1 = CCLabelTTF::labelWithString("Testing A8 Format", "Marker Felt", 48); + CCLabelTTF *label1 = CCLabelTTF::create("Testing A8 Format", "Marker Felt", 48); addChild(label1); label1->setColor(ccRED); label1->setPosition(ccp(s.width/2, s.height/2)); - CCFadeOut *fadeOut = CCFadeOut::actionWithDuration(2); - CCFadeIn *fadeIn = CCFadeIn::actionWithDuration(2); - CCFiniteTimeAction *seq = CCSequence::actions(fadeOut, fadeIn, NULL); - CCRepeatForever *forever = CCRepeatForever::actionWithAction((CCActionInterval *)seq); + CCFadeOut *fadeOut = CCFadeOut::create(2); + CCFadeIn *fadeIn = CCFadeIn::create(2); + CCFiniteTimeAction *seq = CCSequence::create(fadeOut, fadeIn, NULL); + CCRepeatForever *forever = CCRepeatForever::create((CCActionInterval *)seq); label1->runAction(forever); } @@ -1368,11 +1368,11 @@ BMFontOneAtlas::BMFontOneAtlas() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelBMFont *label1 = CCLabelBMFont::labelWithString("This is Helvetica", "fonts/helvetica-32.fnt", kCCLabelAutomaticWidth, kCCTextAlignmentLeft, CCPointZero); + CCLabelBMFont *label1 = CCLabelBMFont::create("This is Helvetica", "fonts/helvetica-32.fnt", kCCLabelAutomaticWidth, kCCTextAlignmentLeft, CCPointZero); addChild(label1); label1->setPosition(ccp(s.width/2, s.height/3*2)); - CCLabelBMFont *label2 = CCLabelBMFont::labelWithString("And this is Geneva", "fonts/geneva-32.fnt", kCCLabelAutomaticWidth, kCCTextAlignmentLeft, ccp(0, 128)); + CCLabelBMFont *label2 = CCLabelBMFont::create("And this is Geneva", "fonts/geneva-32.fnt", kCCLabelAutomaticWidth, kCCTextAlignmentLeft, ccp(0, 128)); addChild(label2); label2->setPosition(ccp(s.width/2, s.height/3*1)); } @@ -1398,15 +1398,15 @@ BMFontUnicode::BMFontUnicode() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelBMFont *label1 = CCLabelBMFont::labelWithString(spanish, "fonts/arial-unicode-26.fnt", 200, kCCTextAlignmentLeft); + CCLabelBMFont *label1 = CCLabelBMFont::create(spanish, "fonts/arial-unicode-26.fnt", 200, kCCTextAlignmentLeft); addChild(label1); label1->setPosition(ccp(s.width/2, s.height/4*3)); - CCLabelBMFont *label2 = CCLabelBMFont::labelWithString(chinese, "fonts/arial-unicode-26.fnt"); + CCLabelBMFont *label2 = CCLabelBMFont::create(chinese, "fonts/arial-unicode-26.fnt"); addChild(label2); label2->setPosition(ccp(s.width/2, s.height/4*2)); - CCLabelBMFont *label3 = CCLabelBMFont::labelWithString(japanese, "fonts/arial-unicode-26.fnt"); + CCLabelBMFont *label3 = CCLabelBMFont::create(japanese, "fonts/arial-unicode-26.fnt"); addChild(label3); label3->setPosition(ccp(s.width/2, s.height/4*1)); } @@ -1430,7 +1430,7 @@ BMFontInit::BMFontInit() CCLabelBMFont* bmFont = new CCLabelBMFont(); bmFont->init(); bmFont->autorelease(); - //CCLabelBMFont* bmFont = [CCLabelBMFont labelWithString:@"Foo" fntFile:@"arial-unicode-26.fnt"]; + //CCLabelBMFont* bmFont = [CCLabelBMFont create:@"Foo" fntFile:@"arial-unicode-26.fnt"]; bmFont->setFntFile("fonts/helvetica-32.fnt"); bmFont->setString("It is working!"); this->addChild(bmFont); diff --git a/tests/tests/LayerTest/LayerTest.cpp b/tests/tests/LayerTest/LayerTest.cpp index 84ca17dc6f..ea19200183 100644 --- a/tests/tests/LayerTest/LayerTest.cpp +++ b/tests/tests/LayerTest/LayerTest.cpp @@ -92,23 +92,23 @@ void LayerTest::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32); + CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 32); addChild(label, 1); label->setPosition( CCPointMake(s.width/2, s.height-50) ); string subtitle_ = subtitle(); if (subtitle_.size() > 0) { - CCLabelTTF *l = CCLabelTTF::labelWithString(subtitle_.c_str(), "Thonburi", 16); + CCLabelTTF *l = CCLabelTTF::create(subtitle_.c_str(), "Thonburi", 16); addChild(l, 1); l->setPosition(ccp(s.width / 2, s.height - 80)); } - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(LayerTest::backCallback) ); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(LayerTest::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(LayerTest::nextCallback) ); + CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(LayerTest::backCallback) ); + CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(LayerTest::restartCallback) ); + CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(LayerTest::nextCallback) ); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition( CCPointZero ); item1->setPosition( ccp( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2) ); @@ -155,7 +155,7 @@ void LayerTest1::onEnter() setIsTouchEnabled(true); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLayerColor* layer = CCLayerColor::layerWithColor( ccc4(0xFF, 0x00, 0x00, 0x80), 200, 200); + CCLayerColor* layer = CCLayerColor::create( ccc4(0xFF, 0x00, 0x00, 0x80), 200, 200); layer->setIgnoreAnchorPointForPosition(false); layer->setPosition( CCPointMake(s.width/2, s.height/2) ); @@ -220,24 +220,24 @@ void LayerTest2::onEnter() LayerTest::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLayerColor* layer1 = CCLayerColor::layerWithColor( ccc4(255, 255, 0, 80), 100, 300); + CCLayerColor* layer1 = CCLayerColor::create( ccc4(255, 255, 0, 80), 100, 300); layer1->setPosition(CCPointMake(s.width/3, s.height/2)); layer1->setIgnoreAnchorPointForPosition(false); addChild(layer1, 1); - CCLayerColor* layer2 = CCLayerColor::layerWithColor( ccc4(0, 0, 255, 255), 100, 300); + CCLayerColor* layer2 = CCLayerColor::create( ccc4(0, 0, 255, 255), 100, 300); layer2->setPosition(CCPointMake((s.width/3)*2, s.height/2)); layer2->setIgnoreAnchorPointForPosition(false); addChild(layer2, 1); - CCActionInterval* actionTint = CCTintBy::actionWithDuration(2, -255, -127, 0); + CCActionInterval* actionTint = CCTintBy::create(2, -255, -127, 0); CCActionInterval* actionTintBack = actionTint->reverse(); - CCActionInterval* seq1 = (CCActionInterval*)CCSequence::actions( actionTint, actionTintBack, NULL); + CCActionInterval* seq1 = (CCActionInterval*)CCSequence::create( actionTint, actionTintBack, NULL); layer1->runAction(seq1); - CCActionInterval* actionFade = CCFadeOut::actionWithDuration(2.0f); + CCActionInterval* actionFade = CCFadeOut::create(2.0f); CCActionInterval* actionFadeBack = actionFade->reverse(); - CCActionInterval* seq2 = (CCActionInterval*)CCSequence::actions(actionFade, actionFadeBack, NULL); + CCActionInterval* seq2 = (CCActionInterval*)CCSequence::create(actionFade, actionFadeBack, NULL); layer2->runAction(seq2); } @@ -255,10 +255,10 @@ std::string LayerTest2::title() LayerTestBlend::LayerTestBlend() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLayerColor* layer1 = CCLayerColor::layerWithColor( ccc4(255, 255, 255, 80) ); + CCLayerColor* layer1 = CCLayerColor::create( ccc4(255, 255, 255, 80) ); - CCSprite* sister1 = CCSprite::spriteWithFile(s_pPathSister1); - CCSprite* sister2 = CCSprite::spriteWithFile(s_pPathSister2); + CCSprite* sister1 = CCSprite::create(s_pPathSister1); + CCSprite* sister2 = CCSprite::create(s_pPathSister2); addChild(sister1); addChild(sister2); @@ -305,18 +305,18 @@ std::string LayerTestBlend::title() //------------------------------------------------------------------ LayerGradient::LayerGradient() { - CCLayerGradient* layer1 = CCLayerGradient::layerWithColor(ccc4(255,0,0,255), ccc4(0,255,0,255), ccp(0.9f, 0.9f)); + CCLayerGradient* layer1 = CCLayerGradient::create(ccc4(255,0,0,255), ccc4(0,255,0,255), ccp(0.9f, 0.9f)); addChild(layer1, 0, kTagLayer); setIsTouchEnabled(true); - CCLabelTTF *label1 = CCLabelTTF::labelWithString("Compressed Interpolation: Enabled", "Marker Felt", 26); - CCLabelTTF *label2 = CCLabelTTF::labelWithString("Compressed Interpolation: Disabled", "Marker Felt", 26); - CCMenuItemLabel *item1 = CCMenuItemLabel::itemWithLabel(label1); - CCMenuItemLabel *item2 = CCMenuItemLabel::itemWithLabel(label2); - CCMenuItemToggle *item = CCMenuItemToggle::itemWithTarget(this, menu_selector(LayerGradient::toggleItem), item1, item2, NULL); + CCLabelTTF *label1 = CCLabelTTF::create("Compressed Interpolation: Enabled", "Marker Felt", 26); + CCLabelTTF *label2 = CCLabelTTF::create("Compressed Interpolation: Disabled", "Marker Felt", 26); + CCMenuItemLabel *item1 = CCMenuItemLabel::create(label1); + CCMenuItemLabel *item2 = CCMenuItemLabel::create(label2); + CCMenuItemToggle *item = CCMenuItemToggle::create(this, menu_selector(LayerGradient::toggleItem), item1, item2, NULL); - CCMenu *menu = CCMenu::menuWithItems(item, NULL); + CCMenu *menu = CCMenu::create(item, NULL); addChild(menu); CCSize s = CCDirector::sharedDirector()->getWinSize(); menu->setPosition(ccp(s.width / 2, 100)); @@ -364,25 +364,25 @@ void LayerIgnoreAnchorPointPos::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLayerColor *l = CCLayerColor::layerWithColor(ccc4(255, 0, 0, 255), 150, 150); + CCLayerColor *l = CCLayerColor::create(ccc4(255, 0, 0, 255), 150, 150); l->setAnchorPoint(ccp(0.5f, 0.5f)); l->setPosition(ccp( s.width/2, s.height/2)); - CCMoveBy *move = CCMoveBy::actionWithDuration(2, ccp(100,2)); + CCMoveBy *move = CCMoveBy::create(2, ccp(100,2)); CCMoveBy * back = (CCMoveBy *)move->reverse(); - CCSequence *seq = (CCSequence *)CCSequence::actions(move, back, NULL); - l->runAction(CCRepeatForever::actionWithAction(seq)); + CCSequence *seq = (CCSequence *)CCSequence::create(move, back, NULL); + l->runAction(CCRepeatForever::create(seq)); this->addChild(l, 0, kLayerIgnoreAnchorPoint); - CCSprite *child = CCSprite::spriteWithFile("Images/grossini.png"); + CCSprite *child = CCSprite::create("Images/grossini.png"); l->addChild(child); CCSize lsize = l->getContentSize(); child->setPosition(ccp(lsize.width/2, lsize.height/2)); - CCMenuItemFont *item = CCMenuItemFont::itemWithString("Toogle ignore anchor point", this, menu_selector(LayerIgnoreAnchorPointPos::onToggle)); + CCMenuItemFont *item = CCMenuItemFont::create("Toogle ignore anchor point", this, menu_selector(LayerIgnoreAnchorPointPos::onToggle)); - CCMenu *menu = CCMenu::menuWithItems(item, NULL); + CCMenu *menu = CCMenu::create(item, NULL); this->addChild(menu); menu->setPosition(ccp(s.width/2, s.height/2)); @@ -412,25 +412,25 @@ void LayerIgnoreAnchorPointRot::onEnter() LayerTest::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLayerColor *l = CCLayerColor::layerWithColor(ccc4(255, 0, 0, 255), 200, 200); + CCLayerColor *l = CCLayerColor::create(ccc4(255, 0, 0, 255), 200, 200); l->setAnchorPoint(ccp(0.5f, 0.5f)); l->setPosition(ccp( s.width/2, s.height/2)); this->addChild(l, 0, kLayerIgnoreAnchorPoint); - CCRotateBy *rot = CCRotateBy::actionWithDuration(2, 360); - l->runAction(CCRepeatForever::actionWithAction(rot)); + CCRotateBy *rot = CCRotateBy::create(2, 360); + l->runAction(CCRepeatForever::create(rot)); - CCSprite *child = CCSprite::spriteWithFile("Images/grossini.png"); + CCSprite *child = CCSprite::create("Images/grossini.png"); l->addChild(child); CCSize lsize = l->getContentSize(); child->setPosition(ccp(lsize.width/2, lsize.height/2)); - CCMenuItemFont *item = CCMenuItemFont::itemWithString("Toogle ignore anchor point", this, menu_selector(LayerIgnoreAnchorPointRot::onToggle)); + CCMenuItemFont *item = CCMenuItemFont::create("Toogle ignore anchor point", this, menu_selector(LayerIgnoreAnchorPointRot::onToggle)); - CCMenu *menu = CCMenu::menuWithItems(item, NULL); + CCMenu *menu = CCMenu::create(item, NULL); this->addChild(menu); menu->setPosition(ccp(s.width/2, s.height/2)); @@ -460,28 +460,28 @@ void LayerIgnoreAnchorPointScale::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLayerColor *l = CCLayerColor::layerWithColor(ccc4(255, 0, 0, 255), 200, 200); + CCLayerColor *l = CCLayerColor::create(ccc4(255, 0, 0, 255), 200, 200); l->setAnchorPoint(ccp(0.5f, 1.0f)); l->setPosition(ccp( s.width/2, s.height/2)); - CCScaleBy *scale = CCScaleBy::actionWithDuration(2, 2); + CCScaleBy *scale = CCScaleBy::create(2, 2); CCScaleBy* back = (CCScaleBy*)scale->reverse(); - CCSequence *seq = (CCSequence*)CCSequence::actions(scale, back, NULL); + CCSequence *seq = (CCSequence*)CCSequence::create(scale, back, NULL); - l->runAction(CCRepeatForever::actionWithAction(seq)); + l->runAction(CCRepeatForever::create(seq)); this->addChild(l, 0, kLayerIgnoreAnchorPoint); - CCSprite *child = CCSprite::spriteWithFile("Images/grossini.png"); + CCSprite *child = CCSprite::create("Images/grossini.png"); l->addChild(child); CCSize lsize = l->getContentSize(); child->setPosition(ccp(lsize.width/2, lsize.height/2)); - CCMenuItemFont *item = CCMenuItemFont::itemWithString("Toogle ignore anchor point", this, menu_selector(LayerIgnoreAnchorPointScale::onToggle)); + CCMenuItemFont *item = CCMenuItemFont::create("Toogle ignore anchor point", this, menu_selector(LayerIgnoreAnchorPointScale::onToggle)); - CCMenu *menu = CCMenu::menuWithItems(item, NULL); + CCMenu *menu = CCMenu::create(item, NULL); this->addChild(menu); menu->setPosition(ccp(s.width/2, s.height/2)); diff --git a/tests/tests/MenuTest/MenuTest.cpp b/tests/tests/MenuTest/MenuTest.cpp index bbea03ed64..fabae6e55e 100644 --- a/tests/tests/MenuTest/MenuTest.cpp +++ b/tests/tests/MenuTest/MenuTest.cpp @@ -31,50 +31,50 @@ MenuLayerMainMenu::MenuLayerMainMenu() setIsTouchEnabled(true); // Font Item - CCSprite* spriteNormal = CCSprite::spriteWithFile(s_MenuItem, CCRectMake(0,23*2,115,23)); - CCSprite* spriteSelected = CCSprite::spriteWithFile(s_MenuItem, CCRectMake(0,23*1,115,23)); - CCSprite* spriteDisabled = CCSprite::spriteWithFile(s_MenuItem, CCRectMake(0,23*0,115,23)); + CCSprite* spriteNormal = CCSprite::create(s_MenuItem, CCRectMake(0,23*2,115,23)); + CCSprite* spriteSelected = CCSprite::create(s_MenuItem, CCRectMake(0,23*1,115,23)); + CCSprite* spriteDisabled = CCSprite::create(s_MenuItem, CCRectMake(0,23*0,115,23)); //dynamic_cast(mgr)->addChild(spriteNormal); //dynamic_cast(mgr)->addChild(spriteSelected); //dynamic_cast(mgr)->addChild(spriteDisabled); - CCMenuItemSprite* item1 = CCMenuItemSprite::itemWithNormalSprite(spriteNormal, spriteSelected, spriteDisabled, this, menu_selector(MenuLayerMainMenu::menuCallback) ); + CCMenuItemSprite* item1 = CCMenuItemSprite::create(spriteNormal, spriteSelected, spriteDisabled, this, menu_selector(MenuLayerMainMenu::menuCallback) ); // Image Item - CCMenuItem* item2 = CCMenuItemImage::itemWithNormalImage(s_SendScore, s_PressSendScore, this, menu_selector(MenuLayerMainMenu::menuCallback2) ); + CCMenuItem* item2 = CCMenuItemImage::create(s_SendScore, s_PressSendScore, this, menu_selector(MenuLayerMainMenu::menuCallback2) ); // Label Item (LabelAtlas) - CCLabelAtlas* labelAtlas = CCLabelAtlas::labelWithString("0123456789", "fonts/labelatlas.png", 16, 24, '.'); - CCMenuItemLabel* item3 = CCMenuItemLabel::itemWithLabel(labelAtlas, this, menu_selector(MenuLayerMainMenu::menuCallbackDisabled) ); + CCLabelAtlas* labelAtlas = CCLabelAtlas::create("0123456789", "fonts/labelatlas.png", 16, 24, '.'); + CCMenuItemLabel* item3 = CCMenuItemLabel::create(labelAtlas, this, menu_selector(MenuLayerMainMenu::menuCallbackDisabled) ); item3->setDisabledColor( ccc3(32,32,64) ); item3->setColor( ccc3(200,200,255) ); // Font Item - CCMenuItemFont *item4 = CCMenuItemFont::itemWithString("I toggle enable items", this, menu_selector(MenuLayerMainMenu::menuCallbackEnable) ); + CCMenuItemFont *item4 = CCMenuItemFont::create("I toggle enable items", this, menu_selector(MenuLayerMainMenu::menuCallbackEnable) ); item4->setFontSizeObj(20); item4->setFontName("Marker Felt"); // Label Item (CCLabelBMFont) - CCLabelBMFont* label = CCLabelBMFont::labelWithString("configuration", "fonts/bitmapFontTest3.fnt"); - CCMenuItemLabel* item5 = CCMenuItemLabel::itemWithLabel(label, this, menu_selector(MenuLayerMainMenu::menuCallbackConfig)); + CCLabelBMFont* label = CCLabelBMFont::create("configuration", "fonts/bitmapFontTest3.fnt"); + CCMenuItemLabel* item5 = CCMenuItemLabel::create(label, this, menu_selector(MenuLayerMainMenu::menuCallbackConfig)); // Testing issue #500 item5->setScale( 0.8f ); // Events CCMenuItemFont::setFontName("Marker Felt"); - CCMenuItemFont *item6 = CCMenuItemFont::itemWithString("Priority Test", this, menu_selector(MenuLayerMainMenu::menuCallbackPriorityTest)); + CCMenuItemFont *item6 = CCMenuItemFont::create("Priority Test", this, menu_selector(MenuLayerMainMenu::menuCallbackPriorityTest)); // Font Item - CCMenuItemFont* item7 = CCMenuItemFont::itemWithString("Quit", this, menu_selector(MenuLayerMainMenu::onQuit)); + CCMenuItemFont* item7 = CCMenuItemFont::create("Quit", this, menu_selector(MenuLayerMainMenu::onQuit)); - CCActionInterval* color_action = CCTintBy::actionWithDuration(0.5f, 0, -255, -255); + CCActionInterval* color_action = CCTintBy::create(0.5f, 0, -255, -255); CCActionInterval* color_back = color_action->reverse(); - CCFiniteTimeAction* seq = CCSequence::actions(color_action, color_back, NULL); - item7->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq)); + CCFiniteTimeAction* seq = CCSequence::create(color_action, color_back, NULL); + item7->runAction(CCRepeatForever::create((CCActionInterval*)seq)); - CCMenu* menu = CCMenu::menuWithItems( item1, item2, item3, item4, item5, item6, item7, NULL); + CCMenu* menu = CCMenu::create( item1, item2, item3, item4, item5, item6, item7, NULL); menu->alignItemsVertically(); @@ -99,8 +99,8 @@ MenuLayerMainMenu::MenuLayerMainMenu() child->setPosition( CCPointMake( dstPoint.x + offset, dstPoint.y) ); child->runAction( - CCEaseElasticOut::actionWithAction( - CCMoveBy::actionWithDuration(2, CCPointMake(dstPoint.x - offset,0)), 0.35f + CCEaseElasticOut::create( + CCMoveBy::create(2, CCPointMake(dstPoint.x - offset,0)), 0.35f ) ); i++; @@ -198,15 +198,15 @@ MenuLayer2::MenuLayer2() { for( int i=0;i < 2;i++ ) { - CCMenuItemImage* item1 = CCMenuItemImage::itemWithNormalImage(s_PlayNormal, s_PlaySelect, this, menu_selector(MenuLayer2::menuCallback)); - CCMenuItemImage* item2 = CCMenuItemImage::itemWithNormalImage(s_HighNormal, s_HighSelect, this, menu_selector(MenuLayer2::menuCallbackOpacity) ); - CCMenuItemImage* item3 = CCMenuItemImage::itemWithNormalImage(s_AboutNormal, s_AboutSelect, this, menu_selector(MenuLayer2::menuCallbackAlign) ); + CCMenuItemImage* item1 = CCMenuItemImage::create(s_PlayNormal, s_PlaySelect, this, menu_selector(MenuLayer2::menuCallback)); + CCMenuItemImage* item2 = CCMenuItemImage::create(s_HighNormal, s_HighSelect, this, menu_selector(MenuLayer2::menuCallbackOpacity) ); + CCMenuItemImage* item3 = CCMenuItemImage::create(s_AboutNormal, s_AboutSelect, this, menu_selector(MenuLayer2::menuCallbackAlign) ); item1->setScaleX( 1.5f ); item2->setScaleX( 0.5f ); item3->setScaleX( 0.5f ); - CCMenu* menu = CCMenu::menuWithItems(item1, item2, item3, NULL); + CCMenu* menu = CCMenu::create(item1, item2, item3, NULL); CCSize s = CCDirector::sharedDirector()->getWinSize(); menu->setPosition(ccp(s.width/2, s.height/2)); @@ -308,20 +308,20 @@ MenuLayer3::MenuLayer3() CCMenuItemFont::setFontName("Marker Felt"); CCMenuItemFont::setFontSize(28); - CCLabelBMFont* label = CCLabelBMFont::labelWithString("Enable AtlasItem", "fonts/bitmapFontTest3.fnt"); - CCMenuItemLabel* item1 = CCMenuItemLabel::itemWithLabel(label, this, menu_selector(MenuLayer3::menuCallback2) ); - CCMenuItemFont* item2 = CCMenuItemFont::itemWithString("--- Go Back ---", this, menu_selector(MenuLayer3::menuCallback) ); + CCLabelBMFont* label = CCLabelBMFont::create("Enable AtlasItem", "fonts/bitmapFontTest3.fnt"); + CCMenuItemLabel* item1 = CCMenuItemLabel::create(label, this, menu_selector(MenuLayer3::menuCallback2) ); + CCMenuItemFont* item2 = CCMenuItemFont::create("--- Go Back ---", this, menu_selector(MenuLayer3::menuCallback) ); - CCSprite *spriteNormal = CCSprite::spriteWithFile(s_MenuItem, CCRectMake(0,23*2,115,23)); - CCSprite *spriteSelected = CCSprite::spriteWithFile(s_MenuItem, CCRectMake(0,23*1,115,23)); - CCSprite *spriteDisabled = CCSprite::spriteWithFile(s_MenuItem, CCRectMake(0,23*0,115,23)); + CCSprite *spriteNormal = CCSprite::create(s_MenuItem, CCRectMake(0,23*2,115,23)); + CCSprite *spriteSelected = CCSprite::create(s_MenuItem, CCRectMake(0,23*1,115,23)); + CCSprite *spriteDisabled = CCSprite::create(s_MenuItem, CCRectMake(0,23*0,115,23)); - CCMenuItemSprite* item3 = CCMenuItemSprite::itemWithNormalSprite(spriteNormal, spriteSelected, spriteDisabled, this, menu_selector(MenuLayer3::menuCallback3)); + CCMenuItemSprite* item3 = CCMenuItemSprite::create(spriteNormal, spriteSelected, spriteDisabled, this, menu_selector(MenuLayer3::menuCallback3)); m_disabledItem = item3; item3->retain(); m_disabledItem->setIsEnabled( false ); - CCMenu *menu = CCMenu::menuWithItems( item1, item2, item3, NULL); + CCMenu *menu = CCMenu::create( item1, item2, item3, NULL); menu->setPosition( CCPointMake(0,0) ); CCSize s = CCDirector::sharedDirector()->getWinSize(); @@ -330,18 +330,18 @@ MenuLayer3::MenuLayer3() item2->setPosition( CCPointMake(s.width/2 - 200, s.height/2) ); item3->setPosition( CCPointMake(s.width/2, s.height/2 - 100) ); - CCJumpBy* jump = CCJumpBy::actionWithDuration(3, CCPointMake(400,0), 50, 4); - item2->runAction( CCRepeatForever::actionWithAction( - (CCActionInterval*)(CCSequence::actions( jump, jump->reverse(), NULL)) + CCJumpBy* jump = CCJumpBy::create(3, CCPointMake(400,0), 50, 4); + item2->runAction( CCRepeatForever::create( + (CCActionInterval*)(CCSequence::create( jump, jump->reverse(), NULL)) ) ); - CCActionInterval* spin1 = CCRotateBy::actionWithDuration(3, 360); + CCActionInterval* spin1 = CCRotateBy::create(3, 360); CCActionInterval* spin2 = (CCActionInterval*)(spin1->copy()->autorelease()); CCActionInterval* spin3 = (CCActionInterval*)(spin1->copy()->autorelease()); - item1->runAction( CCRepeatForever::actionWithAction(spin1) ); - item2->runAction( CCRepeatForever::actionWithAction(spin2) ); - item3->runAction( CCRepeatForever::actionWithAction(spin3) ); + item1->runAction( CCRepeatForever::create(spin1) ); + item2->runAction( CCRepeatForever::create(spin2) ); + item3->runAction( CCRepeatForever::create(spin3) ); addChild( menu ); @@ -379,60 +379,60 @@ MenuLayer4::MenuLayer4() { CCMenuItemFont::setFontName("American Typewriter"); CCMenuItemFont::setFontSize(18); - CCMenuItemFont*title1 = CCMenuItemFont::itemWithString("Sound"); + CCMenuItemFont*title1 = CCMenuItemFont::create("Sound"); title1->setIsEnabled(false); CCMenuItemFont::setFontName( "Marker Felt" ); CCMenuItemFont::setFontSize(34); - CCMenuItemToggle* item1 = CCMenuItemToggle::itemWithTarget( this, + CCMenuItemToggle* item1 = CCMenuItemToggle::create( this, menu_selector(MenuLayer4::menuCallback), - CCMenuItemFont::itemWithString( "On" ), - CCMenuItemFont::itemWithString( "Off"), + CCMenuItemFont::create( "On" ), + CCMenuItemFont::create( "Off"), NULL ); CCMenuItemFont::setFontName( "American Typewriter" ); CCMenuItemFont::setFontSize(18); - CCMenuItemFont* title2 = CCMenuItemFont::itemWithString( "Music" ); + CCMenuItemFont* title2 = CCMenuItemFont::create( "Music" ); title2->setIsEnabled(false); CCMenuItemFont::setFontName( "Marker Felt" ); CCMenuItemFont::setFontSize(34); - CCMenuItemToggle *item2 = CCMenuItemToggle::itemWithTarget( this, + CCMenuItemToggle *item2 = CCMenuItemToggle::create( this, menu_selector(MenuLayer4::menuCallback), - CCMenuItemFont::itemWithString( "On" ), - CCMenuItemFont::itemWithString( "Off"), + CCMenuItemFont::create( "On" ), + CCMenuItemFont::create( "Off"), NULL ); CCMenuItemFont::setFontName( "American Typewriter" ); CCMenuItemFont::setFontSize(18); - CCMenuItemFont* title3 = CCMenuItemFont::itemWithString( "Quality" ); + CCMenuItemFont* title3 = CCMenuItemFont::create( "Quality" ); title3->setIsEnabled( false ); CCMenuItemFont::setFontName( "Marker Felt" ); CCMenuItemFont::setFontSize(34); - CCMenuItemToggle *item3 = CCMenuItemToggle::itemWithTarget( this, + CCMenuItemToggle *item3 = CCMenuItemToggle::create( this, menu_selector(MenuLayer4::menuCallback), - CCMenuItemFont::itemWithString( "High" ), - CCMenuItemFont::itemWithString( "Low" ), + CCMenuItemFont::create( "High" ), + CCMenuItemFont::create( "Low" ), NULL ); CCMenuItemFont::setFontName( "American Typewriter" ); CCMenuItemFont::setFontSize(18); - CCMenuItemFont* title4 = CCMenuItemFont::itemWithString( "Orientation" ); + CCMenuItemFont* title4 = CCMenuItemFont::create( "Orientation" ); title4->setIsEnabled(false); CCMenuItemFont::setFontName( "Marker Felt" ); CCMenuItemFont::setFontSize(34); - CCMenuItemToggle *item4 = CCMenuItemToggle::itemWithTarget( this, + CCMenuItemToggle *item4 = CCMenuItemToggle::create( this, menu_selector(MenuLayer4::menuCallback), - CCMenuItemFont::itemWithString( "Off" ), + CCMenuItemFont::create( "Off" ), NULL ); //UxArray* more_items = UxArray::arrayWithObjects( - // CCMenuItemFont::itemWithString( "33%" ), - // CCMenuItemFont::itemWithString( "66%" ), - // CCMenuItemFont::itemWithString( "100%" ), + // CCMenuItemFont::create( "33%" ), + // CCMenuItemFont::create( "66%" ), + // CCMenuItemFont::create( "100%" ), // NULL ); // TIP: you can manipulate the items like any other CCMutableArray - item4->getSubItems()->addObject( CCMenuItemFont::itemWithString( "33%" ) ); - item4->getSubItems()->addObject( CCMenuItemFont::itemWithString( "66%" ) ); - item4->getSubItems()->addObject( CCMenuItemFont::itemWithString( "100%" ) ); + item4->getSubItems()->addObject( CCMenuItemFont::create( "33%" ) ); + item4->getSubItems()->addObject( CCMenuItemFont::create( "66%" ) ); + item4->getSubItems()->addObject( CCMenuItemFont::create( "100%" ) ); // you can change the one of the items by doing this item4->setSelectedIndex( 2 ); @@ -440,10 +440,10 @@ MenuLayer4::MenuLayer4() CCMenuItemFont::setFontName( "Marker Felt" ); CCMenuItemFont::setFontSize( 34 ); - CCLabelBMFont *label = CCLabelBMFont::labelWithString( "go back", "fonts/bitmapFontTest3.fnt" ); - CCMenuItemLabel* back = CCMenuItemLabel::itemWithLabel(label, this, menu_selector(MenuLayer4::backCallback) ); + CCLabelBMFont *label = CCLabelBMFont::create( "go back", "fonts/bitmapFontTest3.fnt" ); + CCMenuItemLabel* back = CCMenuItemLabel::create(label, this, menu_selector(MenuLayer4::backCallback) ); - CCMenu *menu = CCMenu::menuWithItems( + CCMenu *menu = CCMenu::create( title1, title2, item1, item2, title3, title4, @@ -475,15 +475,15 @@ void MenuLayer4::backCallback(CCObject* sender) MenuLayerPriorityTest::MenuLayerPriorityTest() { // Testing empty menu - m_pMenu1 = CCMenu::node(); - m_pMenu2 = CCMenu::node(); + m_pMenu1 = CCMenu::create(); + m_pMenu2 = CCMenu::create(); // Menu 1 CCMenuItemFont::setFontName("Marker Felt"); CCMenuItemFont::setFontSize(18); - CCMenuItemFont *item1 = CCMenuItemFont::itemWithString("Return to Main Menu", this, menu_selector(MenuLayerPriorityTest::menuCallback)); - CCMenuItemFont *item2 = CCMenuItemFont::itemWithString("Disable menu for 5 seconds", this, menu_selector(MenuLayerPriorityTest::disableMenuCallback)); + CCMenuItemFont *item1 = CCMenuItemFont::create("Return to Main Menu", this, menu_selector(MenuLayerPriorityTest::menuCallback)); + CCMenuItemFont *item2 = CCMenuItemFont::create("Disable menu for 5 seconds", this, menu_selector(MenuLayerPriorityTest::disableMenuCallback)); m_pMenu1->addChild(item1); @@ -496,7 +496,7 @@ MenuLayerPriorityTest::MenuLayerPriorityTest() // Menu 2 m_bPriority = true; CCMenuItemFont::setFontSize(48); - item1 = CCMenuItemFont::itemWithString("Toggle priority", this, menu_selector(MenuLayerPriorityTest::togglePriorityCallback)); + item1 = CCMenuItemFont::create("Toggle priority", this, menu_selector(MenuLayerPriorityTest::togglePriorityCallback)); item1->setColor(ccc3(0,0,255)); m_pMenu2->addChild(item1); addChild(m_pMenu2); @@ -516,10 +516,10 @@ void MenuLayerPriorityTest::menuCallback(CCObject* pSender) void MenuLayerPriorityTest::disableMenuCallback(CCObject* pSender) { m_pMenu1->setEnabled(false); - CCDelayTime *wait = CCDelayTime::actionWithDuration(5); - CCCallFunc *enable = CCCallFunc::actionWithTarget(this, callfunc_selector(MenuLayerPriorityTest::enableMenuCallback)); + CCDelayTime *wait = CCDelayTime::create(5); + CCCallFunc *enable = CCCallFunc::create(this, callfunc_selector(MenuLayerPriorityTest::enableMenuCallback)); - CCFiniteTimeAction* seq = CCSequence::actions(wait, enable, NULL); + CCFiniteTimeAction* seq = CCSequence::create(wait, enable, NULL); m_pMenu1->runAction(seq); } @@ -547,7 +547,7 @@ void MenuTestScene::runThisTest() CCLayer* pLayer4 = new MenuLayer4(); CCLayer* pLayer5 = new MenuLayerPriorityTest(); - CCLayerMultiplex* layer = CCLayerMultiplex::layerWithLayers(pLayer1, pLayer2, pLayer3, pLayer4, pLayer5, NULL); + CCLayerMultiplex* layer = CCLayerMultiplex::create(pLayer1, pLayer2, pLayer3, pLayer4, pLayer5, NULL); addChild(layer, 0); pLayer1->release(); diff --git a/tests/tests/MotionStreakTest/MotionStreakTest.cpp b/tests/tests/MotionStreakTest/MotionStreakTest.cpp index 20e3670e56..5b00c582b5 100644 --- a/tests/tests/MotionStreakTest/MotionStreakTest.cpp +++ b/tests/tests/MotionStreakTest/MotionStreakTest.cpp @@ -24,36 +24,36 @@ void MotionStreakTest1::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); // the root object just rotates around - m_root = CCSprite::spriteWithFile(s_pPathR1); + m_root = CCSprite::create(s_pPathR1); addChild(m_root, 1); m_root->setPosition(ccp(s.width/2, s.height/2)); // the target object is offset from root, and the streak is moved to follow it - m_target = CCSprite::spriteWithFile(s_pPathR1); + m_target = CCSprite::create(s_pPathR1); m_root->addChild(m_target); m_target->setPosition(ccp(s.width/4, 0)); // create the streak object and add it to the scene - streak = CCMotionStreak::streakWithFade(2, 3, 32, ccGREEN, s_streak); + streak = CCMotionStreak::create(2, 3, 32, ccGREEN, s_streak); addChild(streak); // schedule an update on each frame so we can syncronize the streak with the target schedule(schedule_selector(MotionStreakTest1::onUpdate)); - CCActionInterval* a1 = CCRotateBy::actionWithDuration(2, 360); + CCActionInterval* a1 = CCRotateBy::create(2, 360); - CCAction* action1 = CCRepeatForever::actionWithAction(a1); - CCActionInterval* motion = CCMoveBy::actionWithDuration(2, CCPointMake(100,0) ); - m_root->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)(CCSequence::actions(motion, motion->reverse(), NULL)) ) ); + CCAction* action1 = CCRepeatForever::create(a1); + CCActionInterval* motion = CCMoveBy::create(2, CCPointMake(100,0) ); + m_root->runAction( CCRepeatForever::create((CCActionInterval*)(CCSequence::create(motion, motion->reverse(), NULL)) ) ); m_root->runAction( action1 ); - CCActionInterval *colorAction = CCRepeatForever::actionWithAction((CCActionInterval *)CCSequence::actions( - CCTintTo::actionWithDuration(0.2f, 255, 0, 0), - CCTintTo::actionWithDuration(0.2f, 0, 255, 0), - CCTintTo::actionWithDuration(0.2f, 0, 0, 255), - CCTintTo::actionWithDuration(0.2f, 0, 255, 255), - CCTintTo::actionWithDuration(0.2f, 255, 255, 0), - CCTintTo::actionWithDuration(0.2f, 255, 0, 255), - CCTintTo::actionWithDuration(0.2f, 255, 255, 255), + CCActionInterval *colorAction = CCRepeatForever::create((CCActionInterval *)CCSequence::create( + CCTintTo::create(0.2f, 255, 0, 0), + CCTintTo::create(0.2f, 0, 255, 0), + CCTintTo::create(0.2f, 0, 0, 255), + CCTintTo::create(0.2f, 0, 255, 255), + CCTintTo::create(0.2f, 255, 255, 0), + CCTintTo::create(0.2f, 255, 0, 255), + CCTintTo::create(0.2f, 255, 255, 255), NULL)); streak->runAction(colorAction); @@ -84,7 +84,7 @@ void MotionStreakTest2::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); // create the streak object and add it to the scene - streak = CCMotionStreak::streakWithFade(3, 3, 64, ccWHITE, s_streak ); + streak = CCMotionStreak::create(3, 3, 64, ccWHITE, s_streak ); addChild(streak); streak->setPosition( CCPointMake(s.width/2, s.height/2) ); @@ -119,7 +119,7 @@ void Issue1358::onEnter() // ask director the the window size CCSize size = CCDirector::sharedDirector()->getWinSize(); - streak = CCMotionStreak::streakWithFade(2.0f, 1.0f, 50.0f, ccc3(255, 255, 0), "Images/Icon.png"); + streak = CCMotionStreak::create(2.0f, 1.0f, 50.0f, ccc3(255, 255, 0), "Images/Icon.png"); addChild(streak); @@ -233,23 +233,23 @@ void MotionStreakTest::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32); + CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 32); addChild(label, 0, kTagLabel); label->setPosition(CCPointMake(s.width/2, s.height-50)); string subTitle = this->subtitle(); if (subTitle.size() > 0) { - CCLabelTTF *l = CCLabelTTF::labelWithString(subTitle.c_str(), "Thonburi", 16); + CCLabelTTF *l = CCLabelTTF::create(subTitle.c_str(), "Thonburi", 16); addChild(l, 1); l->setPosition(ccp(s.width/2, s.height-80)); } - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(MotionStreakTest::backCallback) ); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(MotionStreakTest::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(MotionStreakTest::nextCallback) ); + CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(MotionStreakTest::backCallback) ); + CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(MotionStreakTest::restartCallback) ); + CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(MotionStreakTest::nextCallback) ); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition(CCPointZero); item1->setPosition(CCPointMake(s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2)); @@ -258,12 +258,12 @@ void MotionStreakTest::onEnter() addChild(menu, 1); - CCMenuItemToggle *itemMode = CCMenuItemToggle::itemWithTarget(this, menu_selector(MotionStreakTest::modeCallback), - CCMenuItemFont::itemWithString("Use High Quality Mode"), - CCMenuItemFont::itemWithString("Use Fast Mode"), + CCMenuItemToggle *itemMode = CCMenuItemToggle::create(this, menu_selector(MotionStreakTest::modeCallback), + CCMenuItemFont::create("Use High Quality Mode"), + CCMenuItemFont::create("Use Fast Mode"), NULL); - CCMenu *menuMode = CCMenu::menuWithItems(itemMode, NULL); + CCMenu *menuMode = CCMenu::create(itemMode, NULL); addChild(menuMode); menuMode->setPosition(ccp(s.width/2, s.height/4)); @@ -277,7 +277,7 @@ void MotionStreakTest::modeCallback(CCObject *pSender) void MotionStreakTest::restartCallback(CCObject* pSender) { - CCScene* s = new MotionStreakTestScene();//CCScene::node(); + CCScene* s = new MotionStreakTestScene();//CCScene::create(); s->addChild(restartMotionAction()); CCDirector::sharedDirector()->replaceScene(s); @@ -286,7 +286,7 @@ void MotionStreakTest::restartCallback(CCObject* pSender) void MotionStreakTest::nextCallback(CCObject* pSender) { - CCScene* s = new MotionStreakTestScene();//CCScene::node(); + CCScene* s = new MotionStreakTestScene();//CCScene::create(); s->addChild( nextMotionAction() ); CCDirector::sharedDirector()->replaceScene(s); s->release(); @@ -294,7 +294,7 @@ void MotionStreakTest::nextCallback(CCObject* pSender) void MotionStreakTest::backCallback(CCObject* pSender) { - CCScene* s = new MotionStreakTestScene;//CCScene::node(); + CCScene* s = new MotionStreakTestScene;//CCScene::create(); s->addChild( backMotionAction() ); CCDirector::sharedDirector()->replaceScene(s); s->release(); diff --git a/tests/tests/MutiTouchTest/MutiTouchTest.cpp b/tests/tests/MutiTouchTest/MutiTouchTest.cpp index 0e9199c544..d30d696695 100644 --- a/tests/tests/MutiTouchTest/MutiTouchTest.cpp +++ b/tests/tests/MutiTouchTest/MutiTouchTest.cpp @@ -121,7 +121,7 @@ void MutiTouchTestLayer::ccTouchesCancelled(CCSet *pTouches, CCEvent *pEvent) void MutiTouchTestScene::runThisTest() { - MutiTouchTestLayer* pLayer = MutiTouchTestLayer::node(); + MutiTouchTestLayer* pLayer = MutiTouchTestLayer::create(); addChild(pLayer, 0); diff --git a/tests/tests/MutiTouchTest/MutiTouchTest.h b/tests/tests/MutiTouchTest/MutiTouchTest.h index df8db6c149..88978798be 100644 --- a/tests/tests/MutiTouchTest/MutiTouchTest.h +++ b/tests/tests/MutiTouchTest/MutiTouchTest.h @@ -14,7 +14,7 @@ public: virtual void ccTouchesEnded(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent); virtual void ccTouchesCancelled(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent); - LAYER_NODE_FUNC(MutiTouchTestLayer) + LAYER_CREATE_FUNC(MutiTouchTestLayer) }; class MutiTouchTestScene : public TestScene diff --git a/tests/tests/NodeTest/NodeTest.cpp b/tests/tests/NodeTest/NodeTest.cpp index dac460e3ab..6aa50c812b 100644 --- a/tests/tests/NodeTest/NodeTest.cpp +++ b/tests/tests/NodeTest/NodeTest.cpp @@ -104,23 +104,23 @@ void TestCocosNodeDemo::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32); + CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 32); addChild(label, 10); label->setPosition( CCPointMake(s.width/2, s.height-50) ); std::string strSubtitle = subtitle(); if( ! strSubtitle.empty() ) { - CCLabelTTF* l = CCLabelTTF::labelWithString(strSubtitle.c_str(), "Thonburi", 16); + CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16); addChild(l, 1); l->setPosition( CCPointMake(s.width/2, s.height-80) ); } - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(TestCocosNodeDemo::backCallback) ); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1,s_pPathR2, this, menu_selector(TestCocosNodeDemo::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(TestCocosNodeDemo::nextCallback) ); + CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(TestCocosNodeDemo::backCallback) ); + CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1,s_pPathR2, this, menu_selector(TestCocosNodeDemo::restartCallback) ); + CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(TestCocosNodeDemo::nextCallback) ); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition( CCPointZero ); item1->setPosition( ccp( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2) ); @@ -132,7 +132,7 @@ void TestCocosNodeDemo::onEnter() void TestCocosNodeDemo::restartCallback(CCObject* pSender) { - CCScene* s = new CocosNodeTestScene();//CCScene::node(); + CCScene* s = new CocosNodeTestScene();//CCScene::create(); s->addChild(restartCocosNodeAction()); CCDirector::sharedDirector()->replaceScene(s); @@ -141,7 +141,7 @@ void TestCocosNodeDemo::restartCallback(CCObject* pSender) void TestCocosNodeDemo::nextCallback(CCObject* pSender) { - CCScene* s = new CocosNodeTestScene();//CCScene::node(); + CCScene* s = new CocosNodeTestScene();//CCScene::create(); s->addChild( nextCocosNodeAction() ); CCDirector::sharedDirector()->replaceScene(s); s->release(); @@ -149,7 +149,7 @@ void TestCocosNodeDemo::nextCallback(CCObject* pSender) void TestCocosNodeDemo::backCallback(CCObject* pSender) { - CCScene* s = new CocosNodeTestScene();//CCScene::node(); + CCScene* s = new CocosNodeTestScene();//CCScene::create(); s->addChild( backCocosNodeAction() ); CCDirector::sharedDirector()->replaceScene(s); s->release(); @@ -167,10 +167,10 @@ void Test2::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *sp1 = CCSprite::spriteWithFile(s_pPathSister1); - CCSprite *sp2 = CCSprite::spriteWithFile(s_pPathSister2); - CCSprite *sp3 = CCSprite::spriteWithFile(s_pPathSister1); - CCSprite *sp4 = CCSprite::spriteWithFile(s_pPathSister2); + CCSprite *sp1 = CCSprite::create(s_pPathSister1); + CCSprite *sp2 = CCSprite::create(s_pPathSister2); + CCSprite *sp3 = CCSprite::create(s_pPathSister1); + CCSprite *sp4 = CCSprite::create(s_pPathSister2); sp1->setPosition(CCPointMake(100, s.height /2 )); sp2->setPosition(CCPointMake(380, s.height /2 )); @@ -183,14 +183,14 @@ void Test2::onEnter() sp1->addChild(sp3); sp2->addChild(sp4); - CCActionInterval* a1 = CCRotateBy::actionWithDuration(2, 360); - CCActionInterval* a2 = CCScaleBy::actionWithDuration(2, 2); + CCActionInterval* a1 = CCRotateBy::create(2, 360); + CCActionInterval* a2 = CCScaleBy::create(2, 2); - CCAction* action1 = CCRepeatForever::actionWithAction( - (CCActionInterval*)(CCSequence::actions(a1, a2, a2->reverse(), NULL)) + CCAction* action1 = CCRepeatForever::create( + (CCActionInterval*)(CCSequence::create(a1, a2, a2->reverse(), NULL)) ); - CCAction* action2 = CCRepeatForever::actionWithAction( - (CCActionInterval*)(CCSequence::actions( + CCAction* action2 = CCRepeatForever::create( + (CCActionInterval*)(CCSequence::create( (CCActionInterval*)(a1->copy()->autorelease()), (CCActionInterval*)(a2->copy()->autorelease()), a2->reverse(), @@ -219,8 +219,8 @@ std::string Test2::title() Test4::Test4() { - CCSprite *sp1 = CCSprite::spriteWithFile(s_pPathSister1); - CCSprite *sp2 = CCSprite::spriteWithFile(s_pPathSister2); + CCSprite *sp1 = CCSprite::create(s_pPathSister1); + CCSprite *sp2 = CCSprite::create(s_pPathSister2); sp1->setPosition( CCPointMake(100,160) ); sp2->setPosition( CCPointMake(380,160) ); @@ -235,7 +235,7 @@ Test4::Test4() void Test4::delay2(float dt) { CCSprite* node = (CCSprite*)(getChildByTag(2)); - CCAction* action1 = CCRotateBy::actionWithDuration(1, 360); + CCAction* action1 = CCRotateBy::create(1, 360); node->runAction(action1); } @@ -258,16 +258,16 @@ std::string Test4::title() //------------------------------------------------------------------ Test5::Test5() { - CCSprite* sp1 = CCSprite::spriteWithFile(s_pPathSister1); - CCSprite* sp2 = CCSprite::spriteWithFile(s_pPathSister2); + CCSprite* sp1 = CCSprite::create(s_pPathSister1); + CCSprite* sp2 = CCSprite::create(s_pPathSister2); sp1->setPosition(CCPointMake(100,160)); sp2->setPosition(CCPointMake(380,160)); - CCRotateBy* rot = CCRotateBy::actionWithDuration(2, 360); + CCRotateBy* rot = CCRotateBy::create(2, 360); CCActionInterval* rot_back = rot->reverse(); - CCAction* forever = CCRepeatForever::actionWithAction( - (CCActionInterval*)(CCSequence::actions(rot, rot_back, NULL)) + CCAction* forever = CCRepeatForever::create( + (CCActionInterval*)(CCSequence::create(rot, rot_back, NULL)) ); CCAction* forever2 = (CCAction*)(forever->copy()->autorelease()); forever->setTag(101); @@ -312,19 +312,19 @@ std::string Test5::title() //------------------------------------------------------------------ Test6::Test6() { - CCSprite* sp1 = CCSprite::spriteWithFile(s_pPathSister1); - CCSprite* sp11 = CCSprite::spriteWithFile(s_pPathSister1); + CCSprite* sp1 = CCSprite::create(s_pPathSister1); + CCSprite* sp11 = CCSprite::create(s_pPathSister1); - CCSprite* sp2 = CCSprite::spriteWithFile(s_pPathSister2); - CCSprite* sp21 = CCSprite::spriteWithFile(s_pPathSister2); + CCSprite* sp2 = CCSprite::create(s_pPathSister2); + CCSprite* sp21 = CCSprite::create(s_pPathSister2); sp1->setPosition(CCPointMake(100,160)); sp2->setPosition(CCPointMake(380,160)); - CCActionInterval* rot = CCRotateBy::actionWithDuration(2, 360); + CCActionInterval* rot = CCRotateBy::create(2, 360); CCActionInterval* rot_back = rot->reverse(); - CCAction* forever1 = CCRepeatForever::actionWithAction( - (CCActionInterval*)(CCSequence::actions(rot, rot_back, NULL))); + CCAction* forever1 = CCRepeatForever::create( + (CCActionInterval*)(CCSequence::create(rot, rot_back, NULL))); CCAction* forever11 = (CCAction*)(forever1->copy()->autorelease()); CCAction* forever2 = (CCAction*)(forever1->copy()->autorelease()); @@ -376,7 +376,7 @@ StressTest1::StressTest1() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *sp1 = CCSprite::spriteWithFile(s_pPathSister1); + CCSprite *sp1 = CCSprite::create(s_pPathSister1); addChild(sp1, 0, kTagSprite1); sp1->setPosition( CCPointMake(s.width/2, s.height/2) ); @@ -391,17 +391,17 @@ void StressTest1::shouldNotCrash(float dt) CCSize s = CCDirector::sharedDirector()->getWinSize(); // if the node has timers, it crashes - CCNode* explosion = CCParticleSun::node(); + CCNode* explosion = CCParticleSun::create(); ((CCParticleSun*)explosion)->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png")); // if it doesn't, it works Ok. -// CocosNode *explosion = [Sprite spriteWithFile:@"grossinis_sister2.png"); +// CocosNode *explosion = [Sprite create:@"grossinis_sister2.png"); explosion->setPosition( CCPointMake(s.width/2, s.height/2) ); - runAction( CCSequence::actions( - CCRotateBy::actionWithDuration(2, 360), - CCCallFuncN::actionWithTarget(this, callfuncN_selector(StressTest1::removeMe)), + runAction( CCSequence::create( + CCRotateBy::create(2, 360), + CCCallFuncN::create(this, callfuncN_selector(StressTest1::removeMe)), NULL) ); addChild(explosion); @@ -429,25 +429,25 @@ StressTest2::StressTest2() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLayer* sublayer = CCLayer::node(); + CCLayer* sublayer = CCLayer::create(); - CCSprite *sp1 = CCSprite::spriteWithFile(s_pPathSister1); + CCSprite *sp1 = CCSprite::create(s_pPathSister1); sp1->setPosition( CCPointMake(80, s.height/2) ); - CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(350,0)); - CCActionInterval* move_ease_inout3 = CCEaseInOut::actionWithAction((CCActionInterval*)(move->copy()->autorelease()), 2.0f); + CCActionInterval* move = CCMoveBy::create(3, CCPointMake(350,0)); + CCActionInterval* move_ease_inout3 = CCEaseInOut::create((CCActionInterval*)(move->copy()->autorelease()), 2.0f); CCActionInterval* move_ease_inout_back3 = move_ease_inout3->reverse(); - CCFiniteTimeAction* seq3 = CCSequence::actions( move_ease_inout3, move_ease_inout_back3, NULL); - sp1->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq3) ); + CCFiniteTimeAction* seq3 = CCSequence::create( move_ease_inout3, move_ease_inout_back3, NULL); + sp1->runAction( CCRepeatForever::create((CCActionInterval*)seq3) ); sublayer->addChild(sp1, 1); - CCParticleFire* fire = CCParticleFire::node(); + CCParticleFire* fire = CCParticleFire::create(); fire->setTexture(CCTextureCache::sharedTextureCache()->addImage("Images/fire.png")); fire->setPosition( CCPointMake(80, s.height/2-50) ); CCActionInterval* copy_seq3 = (CCActionInterval*)(seq3->copy()->autorelease()); - fire->runAction( CCRepeatForever::actionWithAction(copy_seq3) ); + fire->runAction( CCRepeatForever::create(copy_seq3) ); sublayer->addChild(fire, 2); schedule(schedule_selector(StressTest2::shouldNotLeak), 6.0f); @@ -475,7 +475,7 @@ std::string StressTest2::title() //------------------------------------------------------------------ SchedulerTest1::SchedulerTest1() { - CCLayer*layer = CCLayer::node(); + CCLayer*layer = CCLayer::create(); //UXLOG("retain count after init is %d", layer->retainCount()); // 1 addChild(layer, 0); @@ -510,25 +510,25 @@ NodeToWorld::NodeToWorld() // - It tests different anchor Points // - It tests different children anchor points - CCSprite *back = CCSprite::spriteWithFile(s_back3); + CCSprite *back = CCSprite::create(s_back3); addChild( back, -10); back->setAnchorPoint( CCPointMake(0,0) ); CCSize backSize = back->getContentSize(); - CCMenuItem *item = CCMenuItemImage::itemWithNormalImage(s_PlayNormal, s_PlaySelect); - CCMenu *menu = CCMenu::menuWithItems(item, NULL); + CCMenuItem *item = CCMenuItemImage::create(s_PlayNormal, s_PlaySelect); + CCMenu *menu = CCMenu::create(item, NULL); menu->alignItemsVertically(); menu->setPosition( CCPointMake(backSize.width/2, backSize.height/2)); back->addChild(menu); - CCActionInterval* rot = CCRotateBy::actionWithDuration(5, 360); - CCAction* fe = CCRepeatForever::actionWithAction( rot); + CCActionInterval* rot = CCRotateBy::create(5, 360); + CCAction* fe = CCRepeatForever::create( rot); item->runAction( fe ); - CCActionInterval* move = CCMoveBy::actionWithDuration(3, CCPointMake(200,0)); + CCActionInterval* move = CCMoveBy::create(3, CCPointMake(200,0)); CCActionInterval* move_back = move->reverse(); - CCFiniteTimeAction* seq = CCSequence::actions( move, move_back, NULL); - CCAction* fe2 = CCRepeatForever::actionWithAction((CCActionInterval*)seq); + CCFiniteTimeAction* seq = CCSequence::create( move, move_back, NULL); + CCAction* fe2 = CCRepeatForever::create((CCActionInterval*)seq); back->runAction(fe2); } @@ -558,7 +558,7 @@ CameraOrbitTest::CameraOrbitTest() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *p = CCSprite::spriteWithFile(s_back3); + CCSprite *p = CCSprite::create(s_back3); addChild( p, 0); p->setPosition( CCPointMake(s.width/2, s.height/2) ); p->setOpacity( 128 ); @@ -570,36 +570,36 @@ CameraOrbitTest::CameraOrbitTest() // LEFT s = p->getContentSize(); - sprite = CCSprite::spriteWithFile(s_pPathGrossini); + sprite = CCSprite::create(s_pPathGrossini); sprite->setScale(0.5f); p->addChild(sprite, 0); sprite->setPosition( CCPointMake(s.width/4*1, s.height/2) ); cam = sprite->getCamera(); - orbit = CCOrbitCamera::actionWithDuration(2, 1, 0, 0, 360, 0, 0); - sprite->runAction( CCRepeatForever::actionWithAction( orbit ) ); + orbit = CCOrbitCamera::create(2, 1, 0, 0, 360, 0, 0); + sprite->runAction( CCRepeatForever::create( orbit ) ); // CENTER - sprite = CCSprite::spriteWithFile(s_pPathGrossini); + sprite = CCSprite::create(s_pPathGrossini); sprite->setScale( 1.0f ); p->addChild(sprite, 0); sprite->setPosition( CCPointMake(s.width/4*2, s.height/2) ); - orbit = CCOrbitCamera::actionWithDuration(2, 1, 0, 0, 360, 45, 0); - sprite->runAction( CCRepeatForever::actionWithAction( orbit ) ); + orbit = CCOrbitCamera::create(2, 1, 0, 0, 360, 45, 0); + sprite->runAction( CCRepeatForever::create( orbit ) ); // RIGHT - sprite = CCSprite::spriteWithFile(s_pPathGrossini); + sprite = CCSprite::create(s_pPathGrossini); sprite->setScale( 2.0f ); p->addChild(sprite, 0); sprite->setPosition( CCPointMake(s.width/4*3, s.height/2) ); ss = sprite->getContentSize(); - orbit = CCOrbitCamera::actionWithDuration(2, 1, 0, 0, 360, 90, -45), - sprite->runAction( CCRepeatForever::actionWithAction(orbit) ); + orbit = CCOrbitCamera::create(2, 1, 0, 0, 360, 90, -45), + sprite->runAction( CCRepeatForever::create(orbit) ); // PARENT - orbit = CCOrbitCamera::actionWithDuration(10, 1, 0, 0, 360, 0, 90); - p->runAction( CCRepeatForever::actionWithAction( orbit ) ); + orbit = CCOrbitCamera::create(10, 1, 0, 0, 360, 0, 90); + p->runAction( CCRepeatForever::create( orbit ) ); setScale( 1 ); } @@ -636,7 +636,7 @@ CameraZoomTest::CameraZoomTest() CCCamera *cam; // LEFT - sprite = CCSprite::spriteWithFile(s_pPathGrossini); + sprite = CCSprite::create(s_pPathGrossini); addChild( sprite, 0); sprite->setPosition( CCPointMake(s.width/4*1, s.height/2) ); cam = sprite->getCamera(); @@ -644,12 +644,12 @@ CameraZoomTest::CameraZoomTest() cam->setCenterXYZ(0, 0, 0); // CENTER - sprite = CCSprite::spriteWithFile(s_pPathGrossini); + sprite = CCSprite::create(s_pPathGrossini); addChild( sprite, 0, 40); sprite->setPosition(CCPointMake(s.width/4*2, s.height/2)); // RIGHT - sprite = CCSprite::spriteWithFile(s_pPathGrossini); + sprite = CCSprite::create(s_pPathGrossini); addChild( sprite, 0, 20); sprite->setPosition(CCPointMake(s.width/4*3, s.height/2)); @@ -691,54 +691,54 @@ CameraCenterTest::CameraCenterTest() CCOrbitCamera *orbit; // LEFT-TOP - sprite = CCSprite::spriteWithFile("Images/white-512x512.png"); + sprite = CCSprite::create("Images/white-512x512.png"); addChild( sprite, 0); sprite->setPosition(CCPointMake(s.width/5*1, s.height/5*1)); sprite->setColor(ccRED); sprite->setTextureRect(CCRectMake(0, 0, 120, 50)); - orbit = CCOrbitCamera::actionWithDuration(10, 1, 0, 0, 360, 0, 0); - sprite->runAction(CCRepeatForever::actionWithAction( orbit )); + orbit = CCOrbitCamera::create(10, 1, 0, 0, 360, 0, 0); + sprite->runAction(CCRepeatForever::create( orbit )); // [sprite setAnchorPoint: CCPointMake(0,1)); // LEFT-BOTTOM - sprite = CCSprite::spriteWithFile("Images/white-512x512.png"); + sprite = CCSprite::create("Images/white-512x512.png"); addChild( sprite, 0, 40); sprite->setPosition(CCPointMake(s.width/5*1, s.height/5*4)); sprite->setColor(ccBLUE); sprite->setTextureRect(CCRectMake(0, 0, 120, 50)); - orbit = CCOrbitCamera::actionWithDuration(10, 1, 0, 0, 360, 0, 0); - sprite->runAction(CCRepeatForever::actionWithAction( orbit )); + orbit = CCOrbitCamera::create(10, 1, 0, 0, 360, 0, 0); + sprite->runAction(CCRepeatForever::create( orbit )); // RIGHT-TOP - sprite = CCSprite::spriteWithFile("Images/white-512x512.png"); + sprite = CCSprite::create("Images/white-512x512.png"); addChild( sprite, 0); sprite->setPosition(CCPointMake(s.width/5*4, s.height/5*1)); sprite->setColor(ccYELLOW); sprite->setTextureRect(CCRectMake(0, 0, 120, 50)); - orbit = CCOrbitCamera::actionWithDuration(10, 1, 0, 0, 360, 0, 0); - sprite->runAction(CCRepeatForever::actionWithAction( orbit) ); + orbit = CCOrbitCamera::create(10, 1, 0, 0, 360, 0, 0); + sprite->runAction(CCRepeatForever::create( orbit) ); // RIGHT-BOTTOM - sprite = CCSprite::spriteWithFile("Images/white-512x512.png"); + sprite = CCSprite::create("Images/white-512x512.png"); addChild( sprite, 0, 40); sprite->setPosition(CCPointMake(s.width/5*4, s.height/5*4)); sprite->setColor(ccGREEN); sprite->setTextureRect(CCRectMake(0, 0, 120, 50)); - orbit = CCOrbitCamera::actionWithDuration(10, 1, 0, 0, 360, 0, 0); - sprite->runAction( CCRepeatForever::actionWithAction( orbit ) ); + orbit = CCOrbitCamera::create(10, 1, 0, 0, 360, 0, 0); + sprite->runAction( CCRepeatForever::create( orbit ) ); // CENTER - sprite = CCSprite::spriteWithFile("Images/white-512x512.png"); + sprite = CCSprite::create("Images/white-512x512.png"); addChild( sprite, 0, 40); sprite->setPosition(CCPointMake(s.width/2, s.height/2)); sprite->setColor(ccWHITE); sprite->setTextureRect(CCRectMake(0, 0, 120, 50)); - orbit = CCOrbitCamera::actionWithDuration(10, 1, 0, 0, 360, 0, 0); - sprite->runAction(CCRepeatForever::actionWithAction( orbit ) ); + orbit = CCOrbitCamera::create(10, 1, 0, 0, 360, 0, 0); + sprite->runAction(CCRepeatForever::create( orbit ) ); } std::string CameraCenterTest::title() @@ -761,14 +761,14 @@ ConvertToNode::ConvertToNode() setIsTouchEnabled(true); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCRotateBy* rotate = CCRotateBy::actionWithDuration(10, 360); - CCRepeatForever* action = CCRepeatForever::actionWithAction(rotate); + CCRotateBy* rotate = CCRotateBy::create(10, 360); + CCRepeatForever* action = CCRepeatForever::create(rotate); for(int i = 0; i < 3; i++) { - CCSprite *sprite = CCSprite::spriteWithFile("Images/grossini.png"); + CCSprite *sprite = CCSprite::create("Images/grossini.png"); sprite->setPosition(ccp( s.width/4*(i+1), s.height/2)); - CCSprite *point = CCSprite::spriteWithFile("Images/r1.png"); + CCSprite *point = CCSprite::create("Images/r1.png"); point->setScale(0.25f); point->setPosition(sprite->getPosition()); addChild(point, 10, 100 + i); @@ -835,7 +835,7 @@ NodeOpaqueTest::NodeOpaqueTest() for (int i = 0; i < 50; i++) { - background = CCSprite::spriteWithFile("Images/background1.png"); + background = CCSprite::create("Images/background1.png"); background->setGLServerState((ccGLServerState)(background->getGLServerState() & (~CC_GL_BLEND))); background->setAnchorPoint(CCPointZero); addChild(background); @@ -860,7 +860,7 @@ NodeNonOpaqueTest::NodeNonOpaqueTest() for (int i = 0; i < 50; i++) { - background = CCSprite::spriteWithFile("Images/background1.jpg"); + background = CCSprite::create("Images/background1.jpg"); background->setGLServerState((ccGLServerState)(background->getGLServerState() | CC_GL_BLEND)); background->setAnchorPoint(CCPointZero); addChild(background); diff --git a/tests/tests/ParallaxTest/ParallaxTest.cpp b/tests/tests/ParallaxTest/ParallaxTest.cpp index 851b507924..13b7bcbd3a 100644 --- a/tests/tests/ParallaxTest/ParallaxTest.cpp +++ b/tests/tests/ParallaxTest/ParallaxTest.cpp @@ -20,7 +20,7 @@ CCLayer* restartParallaxAction(); Parallax1::Parallax1() { // Top Layer, a simple image - CCSprite* cocosImage = CCSprite::spriteWithFile(s_Power); + CCSprite* cocosImage = CCSprite::create(s_Power); // scale the image (optional) cocosImage->setScale( 2.5f ); // change the transform anchor point to 0,0 (optional) @@ -28,7 +28,7 @@ Parallax1::Parallax1() // Middle layer: a Tile map atlas - CCTileMapAtlas *tilemap = CCTileMapAtlas::tileMapAtlasWithTileFile(s_TilesPng, s_LevelMapTga, 16, 16); + CCTileMapAtlas *tilemap = CCTileMapAtlas::create(s_TilesPng, s_LevelMapTga, 16, 16); tilemap->releaseMap(); // change the transform anchor to 0,0 (optional) @@ -39,7 +39,7 @@ Parallax1::Parallax1() // background layer: another image - CCSprite* background = CCSprite::spriteWithFile(s_back); + CCSprite* background = CCSprite::create(s_back); // scale the image (optional) background->setScale( 1.5f ); // change the transform anchor point (optional) @@ -47,7 +47,7 @@ Parallax1::Parallax1() // create a void node, a parent node - CCParallaxNode* voidNode = CCParallaxNode::node(); + CCParallaxNode* voidNode = CCParallaxNode::create(); // NOW add the 3 layers to the 'void' node @@ -64,12 +64,12 @@ Parallax1::Parallax1() // now create some actions that will move the 'void' node // and the children of the 'void' node will move at different // speed, thus, simulation the 3D environment - CCActionInterval* goUp = CCMoveBy::actionWithDuration(4, ccp(0,-500) ); + CCActionInterval* goUp = CCMoveBy::create(4, ccp(0,-500) ); CCActionInterval* goDown = goUp->reverse(); - CCActionInterval* go = CCMoveBy::actionWithDuration(8, ccp(-1000,0) ); + CCActionInterval* go = CCMoveBy::create(8, ccp(-1000,0) ); CCActionInterval* goBack = go->reverse(); - CCFiniteTimeAction* seq = CCSequence::actions(goUp, go, goDown, goBack, NULL); - voidNode->runAction( (CCRepeatForever::actionWithAction((CCActionInterval*) seq) )); + CCFiniteTimeAction* seq = CCSequence::create(goUp, go, goDown, goBack, NULL); + voidNode->runAction( (CCRepeatForever::create((CCActionInterval*) seq) )); addChild( voidNode ); } @@ -90,7 +90,7 @@ Parallax2::Parallax2() setIsTouchEnabled( true ); // Top Layer, a simple image - CCSprite* cocosImage = CCSprite::spriteWithFile(s_Power); + CCSprite* cocosImage = CCSprite::create(s_Power); // scale the image (optional) cocosImage->setScale( 2.5f ); // change the transform anchor point to 0,0 (optional) @@ -98,7 +98,7 @@ Parallax2::Parallax2() // Middle layer: a Tile map atlas - CCTileMapAtlas* tilemap = CCTileMapAtlas::tileMapAtlasWithTileFile(s_TilesPng, s_LevelMapTga, 16, 16); + CCTileMapAtlas* tilemap = CCTileMapAtlas::create(s_TilesPng, s_LevelMapTga, 16, 16); tilemap->releaseMap(); // change the transform anchor to 0,0 (optional) @@ -109,7 +109,7 @@ Parallax2::Parallax2() // background layer: another image - CCSprite* background = CCSprite::spriteWithFile(s_back); + CCSprite* background = CCSprite::create(s_back); // scale the image (optional) background->setScale( 1.5f ); // change the transform anchor point (optional) @@ -117,7 +117,7 @@ Parallax2::Parallax2() // create a void node, a parent node - CCParallaxNode* voidNode = CCParallaxNode::node(); + CCParallaxNode* voidNode = CCParallaxNode::create(); // NOW add the 3 layers to the 'void' node @@ -244,15 +244,15 @@ void ParallaxDemo::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 28); + CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 28); addChild(label, 1); label->setPosition( ccp(s.width/2, s.height-50) ); - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(ParallaxDemo::backCallback) ); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(ParallaxDemo::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(ParallaxDemo::nextCallback) ); + CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(ParallaxDemo::backCallback) ); + CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(ParallaxDemo::restartCallback) ); + CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(ParallaxDemo::nextCallback) ); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition( CCPointZero ); item1->setPosition( ccp( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2) ); diff --git a/tests/tests/ParticleTest/ParticleTest.cpp b/tests/tests/ParticleTest/ParticleTest.cpp index 9811d405b3..29a5d1a9d6 100644 --- a/tests/tests/ParticleTest/ParticleTest.cpp +++ b/tests/tests/ParticleTest/ParticleTest.cpp @@ -24,7 +24,7 @@ void DemoFirework::onEnter() { ParticleDemo::onEnter(); - m_emitter = CCParticleFireworks::node(); + m_emitter = CCParticleFireworks::create(); m_emitter->retain(); m_background->addChild(m_emitter, 10); @@ -48,7 +48,7 @@ void DemoFire::onEnter() { ParticleDemo::onEnter(); - m_emitter = CCParticleFire::node(); + m_emitter = CCParticleFire::create(); m_emitter->retain(); m_background->addChild(m_emitter, 10); @@ -73,7 +73,7 @@ void DemoSun::onEnter() { ParticleDemo::onEnter(); - m_emitter = CCParticleSun::node(); + m_emitter = CCParticleSun::create(); m_emitter->retain(); m_background->addChild(m_emitter, 10); @@ -96,7 +96,7 @@ void DemoGalaxy::onEnter() { ParticleDemo::onEnter(); - m_emitter = CCParticleGalaxy::node(); + m_emitter = CCParticleGalaxy::create(); m_emitter->retain(); m_background->addChild(m_emitter, 10); @@ -119,7 +119,7 @@ void DemoFlower::onEnter() { ParticleDemo::onEnter(); - m_emitter = CCParticleFlower::node(); + m_emitter = CCParticleFlower::create(); m_emitter->retain(); m_background->addChild(m_emitter, 10); m_emitter->setTexture( CCTextureCache::sharedTextureCache()->addImage(s_stars1) ); @@ -310,7 +310,7 @@ void DemoMeteor::onEnter() { ParticleDemo::onEnter(); - m_emitter = CCParticleMeteor::node(); + m_emitter = CCParticleMeteor::create(); m_emitter->retain(); m_background->addChild(m_emitter, 10); @@ -333,7 +333,7 @@ void DemoSpiral::onEnter() { ParticleDemo::onEnter(); - m_emitter = CCParticleSpiral::node(); + m_emitter = CCParticleSpiral::create(); m_emitter->retain(); m_background->addChild(m_emitter, 10); @@ -356,7 +356,7 @@ void DemoExplosion::onEnter() { ParticleDemo::onEnter(); - m_emitter = CCParticleExplosion::node(); + m_emitter = CCParticleExplosion::create(); m_emitter->retain(); m_background->addChild(m_emitter, 10); @@ -381,7 +381,7 @@ void DemoSmoke::onEnter() { ParticleDemo::onEnter(); - m_emitter = CCParticleSmoke::node(); + m_emitter = CCParticleSmoke::create(); m_emitter->retain(); m_background->addChild(m_emitter, 10); m_emitter->setTexture( CCTextureCache::sharedTextureCache()->addImage(s_fire) ); @@ -406,7 +406,7 @@ void DemoSnow::onEnter() { ParticleDemo::onEnter(); - m_emitter = CCParticleSnow::node(); + m_emitter = CCParticleSnow::create(); m_emitter->retain(); m_background->addChild(m_emitter, 10); @@ -454,7 +454,7 @@ void DemoRain::onEnter() { ParticleDemo::onEnter(); - m_emitter = CCParticleRain::node(); + m_emitter = CCParticleRain::create(); m_emitter->retain(); m_background->addChild(m_emitter, 10); @@ -568,7 +568,7 @@ void DemoRing::onEnter() { ParticleDemo::onEnter(); - m_emitter = CCParticleFlower::node(); + m_emitter = CCParticleFlower::create(); m_emitter->retain(); m_background->addChild(m_emitter, 10); @@ -600,30 +600,30 @@ void ParallaxParticle::onEnter() m_background->getParent()->removeChild(m_background, true); m_background = NULL; - CCParallaxNode* p = CCParallaxNode::node(); + CCParallaxNode* p = CCParallaxNode::create(); addChild(p, 5); - CCSprite *p1 = CCSprite::spriteWithFile(s_back3); - CCSprite *p2 = CCSprite::spriteWithFile(s_back3); + CCSprite *p1 = CCSprite::create(s_back3); + CCSprite *p2 = CCSprite::create(s_back3); p->addChild( p1, 1, CCPointMake(0.5f,1), CCPointMake(0,250) ); p->addChild(p2, 2, CCPointMake(1.5f,1), CCPointMake(0,50) ); - m_emitter = CCParticleFlower::node(); + m_emitter = CCParticleFlower::create(); m_emitter->retain(); m_emitter->setTexture( CCTextureCache::sharedTextureCache()->addImage(s_fire) ); p1->addChild(m_emitter, 10); m_emitter->setPosition( CCPointMake(250,200) ); - CCParticleSun* par = CCParticleSun::node(); + CCParticleSun* par = CCParticleSun::create(); p2->addChild(par, 10); par->setTexture( CCTextureCache::sharedTextureCache()->addImage(s_fire) ); - CCActionInterval* move = CCMoveBy::actionWithDuration(4, CCPointMake(300,0)); + CCActionInterval* move = CCMoveBy::create(4, CCPointMake(300,0)); CCActionInterval* move_back = move->reverse(); - CCFiniteTimeAction* seq = CCSequence::actions( move, move_back, NULL); - p->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)seq)); + CCFiniteTimeAction* seq = CCSequence::create( move, move_back, NULL); + p->runAction(CCRepeatForever::create((CCActionInterval*)seq)); } std::string ParallaxParticle::title() @@ -877,8 +877,8 @@ void Issue704::onEnter() // additive m_emitter->setIsBlendAdditive(false); - CCRotateBy* rot = CCRotateBy::actionWithDuration(16, 360); - m_emitter->runAction(CCRepeatForever::actionWithAction(rot)); + CCRotateBy* rot = CCRotateBy::create(16, 360); + m_emitter->runAction(CCRepeatForever::create(rot)); } std::string Issue704::title() @@ -1075,27 +1075,27 @@ void ParticleDemo::onEnter(void) setIsTouchEnabled( true ); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 28); + CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 28); addChild(label, 100, 1000); label->setPosition( CCPointMake(s.width/2, s.height-50) ); - CCLabelTTF *sub = CCLabelTTF::labelWithString(subtitle().c_str(), "Arial", 16); + CCLabelTTF *sub = CCLabelTTF::create(subtitle().c_str(), "Arial", 16); addChild(sub, 100); sub->setPosition(CCPointMake(s.width/2, s.height-80)); - CCMenuItemImage* item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(ParticleDemo::backCallback) ); - CCMenuItemImage* item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(ParticleDemo::restartCallback) ); - CCMenuItemImage* item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(ParticleDemo::nextCallback) ); + CCMenuItemImage* item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(ParticleDemo::backCallback) ); + CCMenuItemImage* item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(ParticleDemo::restartCallback) ); + CCMenuItemImage* item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(ParticleDemo::nextCallback) ); - CCMenuItemToggle* item4 = CCMenuItemToggle::itemWithTarget( this, + CCMenuItemToggle* item4 = CCMenuItemToggle::create( this, menu_selector(ParticleDemo::toggleCallback), - CCMenuItemFont::itemWithString( "Free Movement" ), - CCMenuItemFont::itemWithString( "Relative Movement" ), - CCMenuItemFont::itemWithString( "Grouped Movement" ), + CCMenuItemFont::create( "Free Movement" ), + CCMenuItemFont::create( "Relative Movement" ), + CCMenuItemFont::create( "Grouped Movement" ), NULL ); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, item4, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, item4, NULL); menu->setPosition( CCPointZero ); item1->setPosition( ccp( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2) ); @@ -1106,19 +1106,19 @@ void ParticleDemo::onEnter(void) addChild( menu, 100 ); - CCLabelAtlas* labelAtlas = CCLabelAtlas::labelWithString("0000", "fps_images.png", 12, 32, '.'); + CCLabelAtlas* labelAtlas = CCLabelAtlas::create("0000", "fps_images.png", 12, 32, '.'); addChild(labelAtlas, 100, kTagParticleCount); labelAtlas->setPosition(ccp(s.width-66,50)); // moving background - m_background = CCSprite::spriteWithFile(s_back3); + m_background = CCSprite::create(s_back3); addChild(m_background, 5); m_background->setPosition( ccp(s.width/2, s.height-180) ); - CCActionInterval* move = CCMoveBy::actionWithDuration(4, ccp(300,0) ); + CCActionInterval* move = CCMoveBy::create(4, ccp(300,0) ); CCActionInterval* move_back = move->reverse(); - CCFiniteTimeAction* seq = CCSequence::actions( move, move_back, NULL); - m_background->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq) ); + CCFiniteTimeAction* seq = CCSequence::create( move, move_back, NULL); + m_background->runAction( CCRepeatForever::create((CCActionInterval*)seq) ); scheduleUpdate(); @@ -1237,9 +1237,9 @@ void ParticleBatchHybrid::onEnter() removeChild(m_background, true); m_background = NULL; - m_emitter = CCParticleSystemQuad::particleWithFile("Particles/LavaFlow.plist"); + m_emitter = CCParticleSystemQuad::create("Particles/LavaFlow.plist"); m_emitter->retain(); - CCParticleBatchNode *batch = CCParticleBatchNode::batchNodeWithTexture(m_emitter->getTexture()); + CCParticleBatchNode *batch = CCParticleBatchNode::createWithTexture(m_emitter->getTexture()); batch->addChild(m_emitter); @@ -1247,7 +1247,7 @@ void ParticleBatchHybrid::onEnter() schedule(schedule_selector(ParticleBatchHybrid::switchRender), 2.0f); - CCNode *node = CCNode::node(); + CCNode *node = CCNode::create(); addChild(node); m_pParent1 = batch; @@ -1285,11 +1285,11 @@ void ParticleBatchMultipleEmitters::onEnter() removeChild(m_background, true); m_background = NULL; - CCParticleSystemQuad *emitter1 = CCParticleSystemQuad::particleWithFile("Particles/LavaFlow.plist"); + CCParticleSystemQuad *emitter1 = CCParticleSystemQuad::create("Particles/LavaFlow.plist"); emitter1->setStartColor(ccc4f(1,0,0,1)); - CCParticleSystemQuad *emitter2 = CCParticleSystemQuad::particleWithFile("Particles/LavaFlow.plist"); + CCParticleSystemQuad *emitter2 = CCParticleSystemQuad::create("Particles/LavaFlow.plist"); emitter2->setStartColor(ccc4f(0,1,0,1)); - CCParticleSystemQuad *emitter3 = CCParticleSystemQuad::particleWithFile("Particles/LavaFlow.plist"); + CCParticleSystemQuad *emitter3 = CCParticleSystemQuad::create("Particles/LavaFlow.plist"); emitter3->setStartColor(ccc4f(0,0,1,1)); CCSize s = CCDirector::sharedDirector()->getWinSize(); @@ -1298,7 +1298,7 @@ void ParticleBatchMultipleEmitters::onEnter() emitter2->setPosition(ccp( s.width/2, s.height/2)); emitter3->setPosition(ccp( s.width/4, s.height/4)); - CCParticleBatchNode *batch = CCParticleBatchNode::batchNodeWithTexture(emitter1->getTexture()); + CCParticleBatchNode *batch = CCParticleBatchNode::createWithTexture(emitter1->getTexture()); batch->addChild(emitter1, 0); batch->addChild(emitter2, 0); @@ -1328,22 +1328,22 @@ void ParticleReorder::onEnter() removeChild(m_background, true); m_background = NULL; - CCParticleSystem* ignore = CCParticleSystemQuad::particleWithFile("Particles/SmallSun.plist"); - CCNode *parent1 = CCNode::node(); - CCNode *parent2 = CCParticleBatchNode::batchNodeWithTexture(ignore->getTexture()); + CCParticleSystem* ignore = CCParticleSystemQuad::create("Particles/SmallSun.plist"); + CCNode *parent1 = CCNode::create(); + CCNode *parent2 = CCParticleBatchNode::createWithTexture(ignore->getTexture()); ignore->unscheduleUpdate(); for( unsigned int i=0; i<2;i++) { CCNode *parent = ( i==0 ? parent1 : parent2 ); - CCParticleSystemQuad *emitter1 = CCParticleSystemQuad::particleWithFile("Particles/SmallSun.plist"); + CCParticleSystemQuad *emitter1 = CCParticleSystemQuad::create("Particles/SmallSun.plist"); emitter1->setStartColor(ccc4f(1,0,0,1)); emitter1->setIsBlendAdditive(false); - CCParticleSystemQuad *emitter2 = CCParticleSystemQuad::particleWithFile("Particles/SmallSun.plist"); + CCParticleSystemQuad *emitter2 = CCParticleSystemQuad::create("Particles/SmallSun.plist"); emitter2->setStartColor(ccc4f(0,1,0,1)); emitter2->setIsBlendAdditive(false); - CCParticleSystemQuad *emitter3 = CCParticleSystemQuad::particleWithFile("Particles/SmallSun.plist"); + CCParticleSystemQuad *emitter3 = CCParticleSystemQuad::create("Particles/SmallSun.plist"); emitter3->setStartColor(ccc4f(0,0,1,1)); emitter3->setIsBlendAdditive(false); @@ -1531,7 +1531,7 @@ void MultipleParticleSystems::onEnter() CCTextureCache::sharedTextureCache()->addImage("Images/particles.png"); for (int i = 0; i<5; i++) { - CCParticleSystemQuad *particleSystem = CCParticleSystemQuad::particleWithFile("Particles/SpinningPeas.plist"); + CCParticleSystemQuad *particleSystem = CCParticleSystemQuad::create("Particles/SpinningPeas.plist"); particleSystem->setPosition(ccp(i*50 ,i*50)); @@ -1590,7 +1590,7 @@ void MultipleParticleSystemsBatched::onEnter() for (int i = 0; i<5; i++) { - CCParticleSystemQuad *particleSystem = CCParticleSystemQuad::particleWithFile("Particles/SpinningPeas.plist"); + CCParticleSystemQuad *particleSystem = CCParticleSystemQuad::create("Particles/SpinningPeas.plist"); particleSystem->setPositionType(kCCPositionTypeGrouped); particleSystem->setPosition(ccp(i*50 ,i*50)); @@ -1646,13 +1646,13 @@ void AddAndDeleteParticleSystems::onEnter() m_background = NULL; //adds the texture inside the plist to the texture cache - m_pBatchNode = CCParticleBatchNode::batchNodeWithTexture(NULL, 16000); + m_pBatchNode = CCParticleBatchNode::createWithTexture(NULL, 16000); addChild(m_pBatchNode, 1, 2); for (int i = 0; i<6; i++) { - CCParticleSystemQuad *particleSystem = CCParticleSystemQuad::particleWithFile("Particles/Spiral.plist"); + CCParticleSystemQuad *particleSystem = CCParticleSystemQuad::create("Particles/Spiral.plist"); m_pBatchNode->setTexture(particleSystem->getTexture()); particleSystem->setPositionType(kCCPositionTypeGrouped); @@ -1679,7 +1679,7 @@ void AddAndDeleteParticleSystems::removeSystem(float dt) unsigned int uRand = rand() % (nChildrenCount - 1); m_pBatchNode->removeChild((CCNode*)m_pBatchNode->getChildren()->objectAtIndex(uRand), true); - CCParticleSystemQuad *particleSystem = CCParticleSystemQuad::particleWithFile("Particles/Spiral.plist"); + CCParticleSystemQuad *particleSystem = CCParticleSystemQuad::create("Particles/Spiral.plist"); //add new particleSystem->setPositionType(kCCPositionTypeGrouped); @@ -1734,7 +1734,7 @@ void ReorderParticleSystems::onEnter() removeChild(m_background ,true); m_background = NULL; - m_pBatchNode = CCParticleBatchNode::batchNodeWithFile("Images/stars-grayscale.png" ,3000); + m_pBatchNode = CCParticleBatchNode::create("Images/stars-grayscale.png" ,3000); addChild(m_pBatchNode, 1, 2); @@ -1880,7 +1880,7 @@ void PremultipliedAlphaTest::onEnter() this->removeChild(m_background, true); m_background = NULL; - m_emitter = CCParticleSystemQuad::particleWithFile("Particles/BoilingFoam.plist"); + m_emitter = CCParticleSystemQuad::create("Particles/BoilingFoam.plist"); m_emitter->retain(); // Particle Designer "normal" blend func causes black halo on premul textures (ignores multiplication) //this->emitter.blendFunc = (ccBlendFunc){ GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA }; @@ -1912,7 +1912,7 @@ void PremultipliedAlphaTest2::onEnter() this->removeChild(m_background, true); m_background = NULL; - m_emitter = CCParticleSystemQuad::particleWithFile("Particles/TestPremultipliedAlpha.plist"); + m_emitter = CCParticleSystemQuad::create("Particles/TestPremultipliedAlpha.plist"); m_emitter->retain(); this->addChild(m_emitter ,10); } diff --git a/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp b/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp index 676cf01904..b29281c3cc 100644 --- a/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -73,7 +73,7 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) CCSize s = CCDirector::sharedDirector()->getWinSize(); // Title - CCLabelTTF *label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 40); + CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 40); addChild(label, 1); label->setPosition(ccp(s.width/2, s.height-32)); label->setColor(ccc3(255,255,40)); @@ -82,7 +82,7 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) std::string strSubTitle = subtitle(); if(strSubTitle.length()) { - CCLabelTTF *l = CCLabelTTF::labelWithString(strSubTitle.c_str(), "Thonburi", 16); + CCLabelTTF *l = CCLabelTTF::create(strSubTitle.c_str(), "Thonburi", 16); addChild(l, 1); l->setPosition(ccp(s.width/2, s.height-80)); } @@ -92,17 +92,17 @@ void NodeChildrenMainScene::initWithQuantityOfNodes(unsigned int nNodes) quantityOfNodes = nNodes; CCMenuItemFont::setFontSize(65); - CCMenuItemFont *decrease = CCMenuItemFont::itemWithString(" - ", this, menu_selector(NodeChildrenMainScene::onDecrease)); + CCMenuItemFont *decrease = CCMenuItemFont::create(" - ", this, menu_selector(NodeChildrenMainScene::onDecrease)); decrease->setColor(ccc3(0,200,20)); - CCMenuItemFont *increase = CCMenuItemFont::itemWithString(" + ", this, menu_selector(NodeChildrenMainScene::onIncrease)); + CCMenuItemFont *increase = CCMenuItemFont::create(" + ", this, menu_selector(NodeChildrenMainScene::onIncrease)); increase->setColor(ccc3(0,200,20)); - CCMenu *menu = CCMenu::menuWithItems(decrease, increase, NULL); + CCMenu *menu = CCMenu::create(decrease, increase, NULL); menu->alignItemsHorizontally(); menu->setPosition(ccp(s.width/2, s.height/2+15)); addChild(menu, 1); - CCLabelTTF *infoLabel = CCLabelTTF::labelWithString("0 nodes", "Marker Felt", 30); + CCLabelTTF *infoLabel = CCLabelTTF::create("0 nodes", "Marker Felt", 30); infoLabel->setColor(ccc3(0,200,20)); infoLabel->setPosition(ccp(s.width/2, s.height/2-15)); addChild(infoLabel, 1, kTagInfoLayer); @@ -180,7 +180,7 @@ void IterateSpriteSheet::updateQuantityOfNodes() { for(int i = 0; i < (quantityOfNodes-currentQuantityOfNodes); i++) { - CCSprite *sprite = CCSprite::spriteWithTexture(batchNode->getTexture(), CCRectMake(0, 0, 32, 32)); + CCSprite *sprite = CCSprite::createWithTexture(batchNode->getTexture(), CCRectMake(0, 0, 32, 32)); batchNode->addChild(sprite); sprite->setPosition(ccp( CCRANDOM_0_1()*s.width, CCRANDOM_0_1()*s.height)); } @@ -201,7 +201,7 @@ void IterateSpriteSheet::updateQuantityOfNodes() void IterateSpriteSheet::initWithQuantityOfNodes(unsigned int nNodes) { - batchNode = CCSpriteBatchNode::batchNodeWithFile("Images/spritesheet1.png"); + batchNode = CCSpriteBatchNode::create("Images/spritesheet1.png"); addChild(batchNode); NodeChildrenMainScene::initWithQuantityOfNodes(nNodes); @@ -316,7 +316,7 @@ AddRemoveSpriteSheet::~AddRemoveSpriteSheet() void AddRemoveSpriteSheet::initWithQuantityOfNodes(unsigned int nNodes) { - batchNode = CCSpriteBatchNode::batchNodeWithFile("Images/spritesheet1.png"); + batchNode = CCSpriteBatchNode::create("Images/spritesheet1.png"); addChild(batchNode); NodeChildrenMainScene::initWithQuantityOfNodes(nNodes); @@ -337,7 +337,7 @@ void AddRemoveSpriteSheet::updateQuantityOfNodes() { for (int i=0; i < (quantityOfNodes-currentQuantityOfNodes); i++) { - CCSprite *sprite = CCSprite::spriteWithTexture(batchNode->getTexture(), CCRectMake(0, 0, 32, 32)); + CCSprite *sprite = CCSprite::createWithTexture(batchNode->getTexture(), CCRectMake(0, 0, 32, 32)); batchNode->addChild(sprite); sprite->setPosition(ccp( CCRANDOM_0_1()*s.width, CCRANDOM_0_1()*s.height)); sprite->setIsVisible(false); @@ -382,7 +382,7 @@ void AddSpriteSheet::update(float dt) // Don't include the sprite creation time and random as part of the profiling for(int i=0; igetTexture(), CCRectMake(0,0,32,32)); + CCSprite* pSprite = CCSprite::createWithTexture(batchNode->getTexture(), CCRectMake(0,0,32,32)); sprites->addObject(pSprite); zs[i] = CCRANDOM_MINUS1_1() * 50; } @@ -445,7 +445,7 @@ void RemoveSpriteSheet::update(float dt) // Don't include the sprite creation time as part of the profiling for(int i=0;igetTexture(), CCRectMake(0,0,32,32)); + CCSprite* pSprite = CCSprite::createWithTexture(batchNode->getTexture(), CCRectMake(0,0,32,32)); sprites->addObject(pSprite); } @@ -505,7 +505,7 @@ void ReorderSpriteSheet::update(float dt) // Don't include the sprite creation time as part of the profiling for(int i=0;igetTexture(), CCRectMake(0,0,32,32)); + CCSprite* pSprite = CCSprite::createWithTexture(batchNode->getTexture(), CCRectMake(0,0,32,32)); sprites->addObject(pSprite); } diff --git a/tests/tests/PerformanceTest/PerformanceParticleTest.cpp b/tests/tests/PerformanceTest/PerformanceParticleTest.cpp index 88abd0ddc9..b62ec0352e 100644 --- a/tests/tests/PerformanceTest/PerformanceParticleTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceParticleTest.cpp @@ -79,23 +79,23 @@ void ParticleMainScene::initWithSubTest(int asubtest, int particles) quantityParticles = particles; CCMenuItemFont::setFontSize(65); - CCMenuItemFont *decrease = CCMenuItemFont::itemWithString(" - ", this, menu_selector(ParticleMainScene::onDecrease)); + CCMenuItemFont *decrease = CCMenuItemFont::create(" - ", this, menu_selector(ParticleMainScene::onDecrease)); decrease->setColor(ccc3(0,200,20)); - CCMenuItemFont *increase = CCMenuItemFont::itemWithString(" + ", this, menu_selector(ParticleMainScene::onIncrease)); + CCMenuItemFont *increase = CCMenuItemFont::create(" + ", this, menu_selector(ParticleMainScene::onIncrease)); increase->setColor(ccc3(0,200,20)); - CCMenu *menu = CCMenu::menuWithItems(decrease, increase, NULL); + CCMenu *menu = CCMenu::create(decrease, increase, NULL); menu->alignItemsHorizontally(); menu->setPosition(ccp(s.width/2, s.height/2+15)); addChild(menu, 1); - CCLabelTTF *infoLabel = CCLabelTTF::labelWithString("0 nodes", "Marker Felt", 30); + CCLabelTTF *infoLabel = CCLabelTTF::create("0 nodes", "Marker Felt", 30); infoLabel->setColor(ccc3(0,200,20)); infoLabel->setPosition(ccp(s.width/2, s.height - 90)); addChild(infoLabel, 1, kTagInfoLayer); // particles on stage - CCLabelAtlas *labelAtlas = CCLabelAtlas::labelWithString("0000", "fps_images.png", 12, 32, '.'); + CCLabelAtlas *labelAtlas = CCLabelAtlas::create("0000", "fps_images.png", 12, 32, '.'); addChild(labelAtlas, 0, kTagLabelAtlas); labelAtlas->setPosition(ccp(s.width-66,50)); @@ -106,12 +106,12 @@ void ParticleMainScene::initWithSubTest(int asubtest, int particles) // Sub Tests CCMenuItemFont::setFontSize(40); - CCMenu* pSubMenu = CCMenu::menuWithItems(NULL); + CCMenu* pSubMenu = CCMenu::create(); for (int i = 1; i <= 6; ++i) { char str[10] = {0}; sprintf(str, "%d ", i); - CCMenuItemFont* itemFont = CCMenuItemFont::itemWithString(str, this, menu_selector(ParticleMainScene::testNCallback)); + CCMenuItemFont* itemFont = CCMenuItemFont::create(str, this, menu_selector(ParticleMainScene::testNCallback)); itemFont->setTag(i); pSubMenu->addChild(itemFont, 10); @@ -128,7 +128,7 @@ void ParticleMainScene::initWithSubTest(int asubtest, int particles) pSubMenu->setPosition(ccp(s.width/2, 80)); addChild(pSubMenu, 2); - CCLabelTTF *label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 40); + CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 40); addChild(label, 1); label->setPosition(ccp(s.width/2, s.height-32)); label->setColor(ccc3(255,255,40)); diff --git a/tests/tests/PerformanceTest/PerformanceSpriteTest.cpp b/tests/tests/PerformanceTest/PerformanceSpriteTest.cpp index bb80ddca78..b174e03007 100644 --- a/tests/tests/PerformanceTest/PerformanceSpriteTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceSpriteTest.cpp @@ -68,36 +68,36 @@ void SubTest::initWithSubTest(int nSubTest, CCNode* p) /// case 2: CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888); - batchNode = CCSpriteBatchNode::batchNodeWithFile("Images/grossinis_sister1.png", 100); + batchNode = CCSpriteBatchNode::create("Images/grossinis_sister1.png", 100); p->addChild(batchNode, 0); break; case 3: CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444); - batchNode = CCSpriteBatchNode::batchNodeWithFile("Images/grossinis_sister1.png", 100); + batchNode = CCSpriteBatchNode::create("Images/grossinis_sister1.png", 100); p->addChild(batchNode, 0); break; /// case 5: CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888); - batchNode = CCSpriteBatchNode::batchNodeWithFile("Images/grossini_dance_atlas.png", 100); + batchNode = CCSpriteBatchNode::create("Images/grossini_dance_atlas.png", 100); p->addChild(batchNode, 0); break; case 6: CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444); - batchNode = CCSpriteBatchNode::batchNodeWithFile("Images/grossini_dance_atlas.png", 100); + batchNode = CCSpriteBatchNode::create("Images/grossini_dance_atlas.png", 100); p->addChild(batchNode, 0); break; /// case 8: CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888); - batchNode = CCSpriteBatchNode::batchNodeWithFile("Images/spritesheet1.png", 100); + batchNode = CCSpriteBatchNode::create("Images/spritesheet1.png", 100); p->addChild(batchNode, 0); break; case 9: CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444); - batchNode = CCSpriteBatchNode::batchNodeWithFile("Images/spritesheet1.png", 100); + batchNode = CCSpriteBatchNode::create("Images/spritesheet1.png", 100); p->addChild(batchNode, 0); break; @@ -123,14 +123,14 @@ CCSprite* SubTest::createSpriteWithTag(int tag) { case 1: { - sprite = CCSprite::spriteWithFile("Images/grossinis_sister1.png"); + sprite = CCSprite::create("Images/grossinis_sister1.png"); parent->addChild(sprite, 0, tag+100); break; } case 2: case 3: { - sprite = CCSprite::spriteWithTexture(batchNode->getTexture(), CCRectMake(0, 0, 52, 139)); + sprite = CCSprite::createWithTexture(batchNode->getTexture(), CCRectMake(0, 0, 52, 139)); batchNode->addChild(sprite, 0, tag+100); break; } @@ -139,7 +139,7 @@ CCSprite* SubTest::createSpriteWithTag(int tag) int idx = (CCRANDOM_0_1() * 1400 / 100) + 1; char str[32] = {0}; sprintf(str, "Images/grossini_dance_%02d.png", idx); - sprite = CCSprite::spriteWithFile(str); + sprite = CCSprite::create(str); parent->addChild(sprite, 0, tag+100); break; } @@ -154,7 +154,7 @@ CCSprite* SubTest::createSpriteWithTag(int tag) x *= 85; y *= 121; - sprite = CCSprite::spriteWithTexture(batchNode->getTexture(), CCRectMake(x,y,85,121)); + sprite = CCSprite::createWithTexture(batchNode->getTexture(), CCRectMake(x,y,85,121)); batchNode->addChild(sprite, 0, tag+100); break; } @@ -169,7 +169,7 @@ CCSprite* SubTest::createSpriteWithTag(int tag) char str[40] = {0}; sprintf(str, "Images/sprites_test/sprite-%d-%d.png", x, y); - sprite = CCSprite::spriteWithFile(str); + sprite = CCSprite::create(str); parent->addChild(sprite, 0, tag+100); break; } @@ -185,7 +185,7 @@ CCSprite* SubTest::createSpriteWithTag(int tag) x *= 32; y *= 32; - sprite = CCSprite::spriteWithTexture(batchNode->getTexture(), CCRectMake(x,y,32,32)); + sprite = CCSprite::createWithTexture(batchNode->getTexture(), CCRectMake(x,y,32,32)); batchNode->addChild(sprite, 0, tag+100); break; } @@ -287,17 +287,17 @@ void SpriteMainScene::initWithSubTest(int asubtest, int nNodes) quantityNodes = 0; CCMenuItemFont::setFontSize(65); - CCMenuItemFont *decrease = CCMenuItemFont::itemWithString(" - ", this, menu_selector(SpriteMainScene::onDecrease)); + CCMenuItemFont *decrease = CCMenuItemFont::create(" - ", this, menu_selector(SpriteMainScene::onDecrease)); decrease->setColor(ccc3(0,200,20)); - CCMenuItemFont *increase = CCMenuItemFont::itemWithString(" + ", this, menu_selector(SpriteMainScene::onIncrease)); + CCMenuItemFont *increase = CCMenuItemFont::create(" + ", this, menu_selector(SpriteMainScene::onIncrease)); increase->setColor(ccc3(0,200,20)); - CCMenu *menu = CCMenu::menuWithItems(decrease, increase, NULL); + CCMenu *menu = CCMenu::create(decrease, increase, NULL); menu->alignItemsHorizontally(); menu->setPosition(ccp(s.width/2, s.height-65)); addChild(menu, 1); - CCLabelTTF *infoLabel = CCLabelTTF::labelWithString("0 nodes", "Marker Felt", 30); + CCLabelTTF *infoLabel = CCLabelTTF::create("0 nodes", "Marker Felt", 30); infoLabel->setColor(ccc3(0,200,20)); infoLabel->setPosition(ccp(s.width/2, s.height-90)); addChild(infoLabel, 1, kTagInfoLayer); @@ -309,12 +309,12 @@ void SpriteMainScene::initWithSubTest(int asubtest, int nNodes) // Sub Tests CCMenuItemFont::setFontSize(32); - CCMenu* pSubMenu = CCMenu::menuWithItems(NULL); + CCMenu* pSubMenu = CCMenu::create(); for (int i = 1; i <= 9; ++i) { char str[10] = {0}; sprintf(str, "%d ", i); - CCMenuItemFont* itemFont = CCMenuItemFont::itemWithString(str, this, menu_selector(SpriteMainScene::testNCallback)); + CCMenuItemFont* itemFont = CCMenuItemFont::create(str, this, menu_selector(SpriteMainScene::testNCallback)); itemFont->setTag(i); pSubMenu->addChild(itemFont, 10); @@ -331,7 +331,7 @@ void SpriteMainScene::initWithSubTest(int asubtest, int nNodes) addChild(pSubMenu, 2); // add title label - CCLabelTTF *label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 40); + CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 40); addChild(label, 1); label->setPosition(ccp(s.width/2, s.height-32)); label->setColor(ccc3(255,255,40)); @@ -414,14 +414,14 @@ void performanceActions(CCSprite* pSprite) pSprite->setPosition(ccp((rand() % (int)size.width), (rand() % (int)size.height))); float period = 0.5f + (rand() % 1000) / 500.0f; - CCRotateBy* rot = CCRotateBy::actionWithDuration(period, 360.0f * CCRANDOM_0_1()); + CCRotateBy* rot = CCRotateBy::create(period, 360.0f * CCRANDOM_0_1()); CCActionInterval* rot_back = rot->reverse(); - CCAction *permanentRotation = CCRepeatForever::actionWithAction((CCActionInterval *)CCSequence::actions(rot, rot_back, NULL)); + CCAction *permanentRotation = CCRepeatForever::create((CCActionInterval *)CCSequence::create(rot, rot_back, NULL)); pSprite->runAction(permanentRotation); float growDuration = 0.5f + (rand() % 1000) / 500.0f; - CCActionInterval *grow = CCScaleBy::actionWithDuration(growDuration, 0.5f, 0.5f); - CCAction *permanentScaleLoop = CCRepeatForever::actionWithAction((CCActionInterval *)CCSequence::actionOneTwo(grow, grow->reverse())); + CCActionInterval *grow = CCScaleBy::create(growDuration, 0.5f, 0.5f); + CCAction *permanentScaleLoop = CCRepeatForever::create((CCActionInterval *)CCSequence::create(grow, grow->reverse())); pSprite->runAction(permanentScaleLoop); } @@ -434,14 +434,14 @@ void performanceActions20(CCSprite* pSprite) pSprite->setPosition(ccp( -1000, -1000)); float period = 0.5f + (rand() % 1000) / 500.0f; - CCRotateBy* rot = CCRotateBy::actionWithDuration(period, 360.0f * CCRANDOM_0_1()); + CCRotateBy* rot = CCRotateBy::create(period, 360.0f * CCRANDOM_0_1()); CCActionInterval* rot_back = rot->reverse(); - CCAction *permanentRotation = CCRepeatForever::actionWithAction((CCActionInterval *)CCSequence::actions(rot, rot_back, NULL)); + CCAction *permanentRotation = CCRepeatForever::create((CCActionInterval *)CCSequence::create(rot, rot_back, NULL)); pSprite->runAction(permanentRotation); float growDuration = 0.5f + (rand() % 1000) / 500.0f; - CCActionInterval *grow = CCScaleBy::actionWithDuration(growDuration, 0.5f, 0.5f); - CCAction *permanentScaleLoop = CCRepeatForever::actionWithAction(CCSequence::actionOneTwo(grow, grow->reverse())); + CCActionInterval *grow = CCScaleBy::create(growDuration, 0.5f, 0.5f); + CCAction *permanentScaleLoop = CCRepeatForever::create(CCSequence::create(grow, grow->reverse())); pSprite->runAction(permanentScaleLoop); } diff --git a/tests/tests/PerformanceTest/PerformanceTest.cpp b/tests/tests/PerformanceTest/PerformanceTest.cpp index 3fe7d77094..a4dee167c4 100644 --- a/tests/tests/PerformanceTest/PerformanceTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceTest.cpp @@ -33,13 +33,13 @@ void PerformanceMainLayer::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCMenu* pMenu = CCMenu::menuWithItems(NULL); + CCMenu* pMenu = CCMenu::create(); pMenu->setPosition( CCPointZero ); CCMenuItemFont::setFontName("Arial"); CCMenuItemFont::setFontSize(24); for (int i = 0; i < MAX_COUNT; ++i) { - CCMenuItemFont* pItem = CCMenuItemFont::itemWithString(testsName[i].c_str(), this, + CCMenuItemFont* pItem = CCMenuItemFont::create(testsName[i].c_str(), this, menu_selector(PerformanceMainLayer::menuCallback)); pItem->setPosition(ccp(s.width / 2, s.height - (i + 1) * LINE_SPACE)); pMenu->addChild(pItem, kItemTagBasic + i); @@ -96,17 +96,17 @@ void PerformBasicLayer::onEnter() CCMenuItemFont::setFontName("Arial"); CCMenuItemFont::setFontSize(24); - CCMenuItemFont* pMainItem = CCMenuItemFont::itemWithString("Back", this, + CCMenuItemFont* pMainItem = CCMenuItemFont::create("Back", this, menu_selector(PerformBasicLayer::toMainLayer)); pMainItem->setPosition(ccp(s.width - 50, 25)); - CCMenu* pMenu = CCMenu::menuWithItems(pMainItem, NULL); + CCMenu* pMenu = CCMenu::create(pMainItem, NULL); pMenu->setPosition( CCPointZero ); if (m_bControlMenuVisible) { - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(PerformBasicLayer::backCallback) ); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(PerformBasicLayer::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(PerformBasicLayer::nextCallback) ); + CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(PerformBasicLayer::backCallback) ); + CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(PerformBasicLayer::restartCallback) ); + CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(PerformBasicLayer::nextCallback) ); item1->setPosition( ccp( s.width/2 - 100,30) ); item2->setPosition( ccp( s.width/2, 30) ); item3->setPosition( ccp( s.width/2 + 100,30) ); diff --git a/tests/tests/PerformanceTest/PerformanceTextureTest.cpp b/tests/tests/PerformanceTest/PerformanceTextureTest.cpp index c66933bb2b..05e8de353f 100644 --- a/tests/tests/PerformanceTest/PerformanceTextureTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceTextureTest.cpp @@ -48,7 +48,7 @@ void TextureMenuLayer::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); // Title - CCLabelTTF *label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 40); + CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 40); addChild(label, 1); label->setPosition(ccp(s.width/2, s.height-32)); label->setColor(ccc3(255,255,40)); @@ -57,7 +57,7 @@ void TextureMenuLayer::onEnter() std::string strSubTitle = subtitle(); if(strSubTitle.length()) { - CCLabelTTF *l = CCLabelTTF::labelWithString(strSubTitle.c_str(), "Thonburi", 16); + CCLabelTTF *l = CCLabelTTF::create(strSubTitle.c_str(), "Thonburi", 16); addChild(l, 1); l->setPosition(ccp(s.width/2, s.height-80)); } @@ -344,7 +344,7 @@ std::string TextureTest::subtitle() CCScene* TextureTest::scene() { - CCScene *pScene = CCScene::node(); + CCScene *pScene = CCScene::create(); TextureTest *layer = new TextureTest(false, TEST_COUNT, s_nTexCurCase); pScene->addChild(layer); layer->release(); diff --git a/tests/tests/PerformanceTest/PerformanceTouchesTest.cpp b/tests/tests/PerformanceTest/PerformanceTouchesTest.cpp index e4e0b5782b..8624102397 100644 --- a/tests/tests/PerformanceTest/PerformanceTouchesTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceTouchesTest.cpp @@ -28,7 +28,7 @@ void TouchesMainScene::showCurrentTest() if (pLayer) { - CCScene* pScene = CCScene::node(); + CCScene* pScene = CCScene::create(); pScene->addChild(pLayer); pLayer->release(); @@ -43,13 +43,13 @@ void TouchesMainScene::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); // add title - CCLabelTTF *label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32); + CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 32); addChild(label, 1); label->setPosition(ccp(s.width/2, s.height-50)); scheduleUpdate(); - m_plabel = CCLabelBMFont::labelWithString("00.0", "fonts/arial16.fnt"); + m_plabel = CCLabelBMFont::create("00.0", "fonts/arial16.fnt"); m_plabel->setPosition(ccp(s.width/2, s.height/2)); addChild(m_plabel); @@ -168,7 +168,7 @@ void TouchesPerformTest2::ccTouchesCancelled(CCSet* touches, CCEvent* event) void runTouchesTest() { s_nTouchCurCase = 0; - CCScene* pScene = CCScene::node(); + CCScene* pScene = CCScene::create(); CCLayer* pLayer = new TouchesPerformTest1(true, TEST_COUNT, s_nTouchCurCase); pScene->addChild(pLayer); diff --git a/tests/tests/RenderTextureTest/RenderTextureTest.cpp b/tests/tests/RenderTextureTest/RenderTextureTest.cpp index 9050b4f03f..4c23d3e83c 100644 --- a/tests/tests/RenderTextureTest/RenderTextureTest.cpp +++ b/tests/tests/RenderTextureTest/RenderTextureTest.cpp @@ -60,23 +60,23 @@ void RenderTextureTestDemo::onEnter() CCLayer::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 28); + CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 28); addChild(label, 1); label->setPosition( ccp(s.width/2, s.height-50) ); std::string strSubtitle = subtitle(); if( ! strSubtitle.empty() ) { - CCLabelTTF* l = CCLabelTTF::labelWithString(strSubtitle.c_str(), "Thonburi", 16); + CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16); addChild(l, 1); l->setPosition( ccp(s.width/2, s.height-80) ); } - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage("Images/b1.png", "Images/b2.png", this, menu_selector(RenderTextureTestDemo::backCallback) ); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage("Images/r1.png","Images/r2.png", this, menu_selector(RenderTextureTestDemo::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage("Images/f1.png", "Images/f2.png", this, menu_selector(RenderTextureTestDemo::nextCallback) ); + CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(RenderTextureTestDemo::backCallback) ); + CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png","Images/r2.png", this, menu_selector(RenderTextureTestDemo::restartCallback) ); + CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(RenderTextureTestDemo::nextCallback) ); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition( CCPointZero ); item1->setPosition( ccp( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2) ); @@ -127,7 +127,7 @@ RenderTextureTest::RenderTextureTest() CCSize s = CCDirector::sharedDirector()->getWinSize(); // create a render texture, this is what we're going to draw into - m_target = CCRenderTexture::renderTextureWithWidthAndHeight(s.width, s.height); + m_target = CCRenderTexture::create(s.width, s.height); if (NULL == m_target) { @@ -141,7 +141,7 @@ RenderTextureTest::RenderTextureTest() addChild(m_target, 1); // create a brush image to draw into the texture with - m_brush = CCSprite::spriteWithFile("Images/stars.png"); + m_brush = CCSprite::create("Images/stars.png"); m_brush->retain(); ccBlendFunc bf = { GL_ONE, GL_ONE_MINUS_SRC_ALPHA }; @@ -230,7 +230,7 @@ RenderTextureSave::RenderTextureSave() CCSize s = CCDirector::sharedDirector()->getWinSize(); // create a render texture, this is what we are going to draw into - m_pTarget = CCRenderTexture::renderTextureWithWidthAndHeight(s.width, s.height, kCCTexture2DPixelFormat_RGBA8888); + m_pTarget = CCRenderTexture::create(s.width, s.height, kCCTexture2DPixelFormat_RGBA8888); m_pTarget->retain(); m_pTarget->setPosition(ccp(s.width / 2, s.height / 2)); @@ -239,7 +239,7 @@ RenderTextureSave::RenderTextureSave() this->addChild(m_pTarget, -1); // create a brush image to draw into the texture with - m_pBrush = CCSprite::spriteWithFile("Images/fire.png"); + m_pBrush = CCSprite::create("Images/fire.png"); m_pBrush->retain(); m_pBrush->setColor(ccRED); m_pBrush->setOpacity(20); @@ -247,9 +247,9 @@ RenderTextureSave::RenderTextureSave() // Save Image menu CCMenuItemFont::setFontSize(16); - CCMenuItem *item1 = CCMenuItemFont::itemWithString("Save Image", this, menu_selector(RenderTextureSave::saveImage)); - CCMenuItem *item2 = CCMenuItemFont::itemWithString("Clear", this, menu_selector(RenderTextureSave::clearImage)); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, NULL); + CCMenuItem *item1 = CCMenuItemFont::create("Save Image", this, menu_selector(RenderTextureSave::saveImage)); + CCMenuItem *item2 = CCMenuItemFont::create("Clear", this, menu_selector(RenderTextureSave::clearImage)); + CCMenu *menu = CCMenu::create(item1, item2, NULL); this->addChild(menu); menu->alignItemsVertically(); menu->setPosition(ccp(s.width - 80, s.height - 30)); @@ -289,7 +289,7 @@ void RenderTextureSave::saveImage(cocos2d::CCObject *pSender) CC_SAFE_DELETE(pImage); - CCSprite *sprite = CCSprite::spriteWithTexture(tex); + CCSprite *sprite = CCSprite::createWithTexture(tex); sprite->setScale(0.3f); addChild(sprite); @@ -363,20 +363,20 @@ RenderTextureIssue937::RenderTextureIssue937() * B1: non-premulti sprite * B2: non-premulti render */ - CCLayerColor *background = CCLayerColor::layerWithColor(ccc4(200,200,200,255)); + CCLayerColor *background = CCLayerColor::create(ccc4(200,200,200,255)); addChild(background); - CCSprite *spr_premulti = CCSprite::spriteWithFile("Images/fire.png"); + CCSprite *spr_premulti = CCSprite::create("Images/fire.png"); spr_premulti->setPosition(ccp(16,48)); - CCSprite *spr_nonpremulti = CCSprite::spriteWithFile("Images/fire.png"); + CCSprite *spr_nonpremulti = CCSprite::create("Images/fire.png"); spr_nonpremulti->setPosition(ccp(16,16)); /* A2 & B2 setup */ - CCRenderTexture *rend = CCRenderTexture::renderTextureWithWidthAndHeight(32, 64, kCCTexture2DPixelFormat_RGBA8888); + CCRenderTexture *rend = CCRenderTexture::create(32, 64, kCCTexture2DPixelFormat_RGBA8888); if (NULL == rend) { @@ -431,15 +431,15 @@ RenderTextureZbuffer::RenderTextureZbuffer() { this->setIsTouchEnabled(true); CCSize size = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF *label = CCLabelTTF::labelWithString("vertexZ = 50", "Marker Felt", 64); + CCLabelTTF *label = CCLabelTTF::create("vertexZ = 50", "Marker Felt", 64); label->setPosition(ccp(size.width / 2, size.height * 0.25f)); this->addChild(label); - CCLabelTTF *label2 = CCLabelTTF::labelWithString("vertexZ = 0", "Marker Felt", 64); + CCLabelTTF *label2 = CCLabelTTF::create("vertexZ = 0", "Marker Felt", 64); label2->setPosition(ccp(size.width / 2, size.height * 0.5f)); this->addChild(label2); - CCLabelTTF *label3 = CCLabelTTF::labelWithString("vertexZ = -50", "Marker Felt", 64); + CCLabelTTF *label3 = CCLabelTTF::create("vertexZ = -50", "Marker Felt", 64); label3->setPosition(ccp(size.width / 2, size.height * 0.75f)); this->addChild(label3); @@ -448,17 +448,17 @@ RenderTextureZbuffer::RenderTextureZbuffer() label3->setVertexZ(-50); CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("Images/bugs/circle.plist"); - mgr = CCSpriteBatchNode::batchNodeWithFile("Images/bugs/circle.png", 9); + mgr = CCSpriteBatchNode::create("Images/bugs/circle.png", 9); this->addChild(mgr); - sp1 = CCSprite::spriteWithSpriteFrameName("circle.png"); - sp2 = CCSprite::spriteWithSpriteFrameName("circle.png"); - sp3 = CCSprite::spriteWithSpriteFrameName("circle.png"); - sp4 = CCSprite::spriteWithSpriteFrameName("circle.png"); - sp5 = CCSprite::spriteWithSpriteFrameName("circle.png"); - sp6 = CCSprite::spriteWithSpriteFrameName("circle.png"); - sp7 = CCSprite::spriteWithSpriteFrameName("circle.png"); - sp8 = CCSprite::spriteWithSpriteFrameName("circle.png"); - sp9 = CCSprite::spriteWithSpriteFrameName("circle.png"); + sp1 = CCSprite::createWithSpriteFrameName("circle.png"); + sp2 = CCSprite::createWithSpriteFrameName("circle.png"); + sp3 = CCSprite::createWithSpriteFrameName("circle.png"); + sp4 = CCSprite::createWithSpriteFrameName("circle.png"); + sp5 = CCSprite::createWithSpriteFrameName("circle.png"); + sp6 = CCSprite::createWithSpriteFrameName("circle.png"); + sp7 = CCSprite::createWithSpriteFrameName("circle.png"); + sp8 = CCSprite::createWithSpriteFrameName("circle.png"); + sp9 = CCSprite::createWithSpriteFrameName("circle.png"); mgr->addChild(sp1, 9); mgr->addChild(sp2, 8); @@ -545,7 +545,7 @@ void RenderTextureZbuffer::ccTouchesEnded(CCSet* touches, CCEvent* event) void RenderTextureZbuffer::renderScreenShot() { - CCRenderTexture *texture = CCRenderTexture::renderTextureWithWidthAndHeight(512, 512); + CCRenderTexture *texture = CCRenderTexture::create(512, 512); if (NULL == texture) { return; @@ -557,7 +557,7 @@ void RenderTextureZbuffer::renderScreenShot() texture->end(); - CCSprite *sprite = CCSprite::spriteWithTexture(texture->getSprite()->getTexture()); + CCSprite *sprite = CCSprite::createWithTexture(texture->getSprite()->getTexture()); sprite->setPosition(ccp(256, 256)); sprite->setOpacity(182); @@ -565,8 +565,8 @@ void RenderTextureZbuffer::renderScreenShot() this->addChild(sprite, 999999); sprite->setColor(ccGREEN); - sprite->runAction(CCSequence::actions(CCFadeTo::actionWithDuration(2, 0), - CCHide::action(), + sprite->runAction(CCSequence::create(CCFadeTo::create(2, 0), + CCHide::create(), NULL)); } @@ -577,10 +577,10 @@ RenderTextureTestDepthStencil::RenderTextureTestDepthStencil() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *sprite = CCSprite::spriteWithFile("Images/fire.png"); + CCSprite *sprite = CCSprite::create("Images/fire.png"); sprite->setPosition(ccp(s.width * 0.25f, 0)); sprite->setScale(10); - CCRenderTexture *rend = CCRenderTexture::renderTextureWithWidthAndHeight(s.width, s.height, kCCTexture2DPixelFormat_RGBA4444, CC_GL_DEPTH24_STENCIL8); + CCRenderTexture *rend = CCRenderTexture::create(s.width, s.height, kCCTexture2DPixelFormat_RGBA4444, CC_GL_DEPTH24_STENCIL8); glStencilMask(0xFF); rend->beginWithClear(0, 0, 0, 0, 0, 0); diff --git a/tests/tests/RotateWorldTest/RotateWorldTest.cpp b/tests/tests/RotateWorldTest/RotateWorldTest.cpp index deed92e11b..da77ac5535 100644 --- a/tests/tests/RotateWorldTest/RotateWorldTest.cpp +++ b/tests/tests/RotateWorldTest/RotateWorldTest.cpp @@ -19,7 +19,7 @@ void TestLayer::onEnter() //CCMutableArray *array = [UIFont familyNames]; //for( CCString *s in array ) // NSLog( s ); - CCLabelTTF* label = CCLabelTTF::labelWithString("cocos2d", "Tahoma", 64); + CCLabelTTF* label = CCLabelTTF::create("cocos2d", "Tahoma", 64); label->setPosition( CCPointMake(x/2,y/2) ); @@ -41,9 +41,9 @@ void SpriteLayer::onEnter() x = size.width; y = size.height; - CCSprite* sprite = CCSprite::spriteWithFile(s_pPathGrossini); - CCSprite* spriteSister1 = CCSprite::spriteWithFile(s_pPathSister1); - CCSprite* spriteSister2 = CCSprite::spriteWithFile(s_pPathSister2); + CCSprite* sprite = CCSprite::create(s_pPathGrossini); + CCSprite* spriteSister1 = CCSprite::create(s_pPathSister1); + CCSprite* spriteSister2 = CCSprite::create(s_pPathSister2); sprite->setScale(1.5f); spriteSister1->setScale(1.5f); @@ -53,7 +53,7 @@ void SpriteLayer::onEnter() spriteSister1->setPosition(CCPointMake(40,y/2)); spriteSister2->setPosition(CCPointMake(x-40,y/2)); - CCAction *rot = CCRotateBy::actionWithDuration(16, -3600); + CCAction *rot = CCRotateBy::create(16, -3600); addChild(sprite); addChild(spriteSister1); @@ -61,17 +61,17 @@ void SpriteLayer::onEnter() sprite->runAction(rot); - CCActionInterval *jump1 = CCJumpBy::actionWithDuration(4, CCPointMake(-400,0), 100, 4); + CCActionInterval *jump1 = CCJumpBy::create(4, CCPointMake(-400,0), 100, 4); CCActionInterval *jump2 = jump1->reverse(); - CCActionInterval *rot1 = CCRotateBy::actionWithDuration(4, 360*2); + CCActionInterval *rot1 = CCRotateBy::create(4, 360*2); CCActionInterval *rot2 = rot1->reverse(); - spriteSister1->runAction(CCRepeat::actionWithAction( CCSequence::actions(jump2, jump1, NULL), 5 )); - spriteSister2->runAction(CCRepeat::actionWithAction( CCSequence::actions((CCFiniteTimeAction *)(jump1->copy()->autorelease()), (CCFiniteTimeAction *)(jump2->copy()->autorelease()), NULL), 5 )); + spriteSister1->runAction(CCRepeat::create( CCSequence::create(jump2, jump1, NULL), 5 )); + spriteSister2->runAction(CCRepeat::create( CCSequence::create((CCFiniteTimeAction *)(jump1->copy()->autorelease()), (CCFiniteTimeAction *)(jump2->copy()->autorelease()), NULL), 5 )); - spriteSister1->runAction(CCRepeat::actionWithAction( CCSequence::actions(rot1, rot2, NULL), 5 )); - spriteSister2->runAction(CCRepeat::actionWithAction( CCSequence::actions((CCFiniteTimeAction *)(rot2->copy()->autorelease()), (CCFiniteTimeAction *)(rot1->copy()->autorelease()), NULL), 5 )); + spriteSister1->runAction(CCRepeat::create( CCSequence::create(rot1, rot2, NULL), 5 )); + spriteSister2->runAction(CCRepeat::create( CCSequence::create((CCFiniteTimeAction *)(rot2->copy()->autorelease()), (CCFiniteTimeAction *)(rot1->copy()->autorelease()), NULL), 5 )); } //------------------------------------------------------------------ @@ -90,21 +90,21 @@ void RotateWorldMainLayer::onEnter() x = size.width; y = size.height; - CCNode* blue = CCLayerColor::layerWithColor(ccc4(0,0,255,255)); - CCNode* red = CCLayerColor::layerWithColor(ccc4(255,0,0,255)); - CCNode* green = CCLayerColor::layerWithColor(ccc4(0,255,0,255)); - CCNode* white = CCLayerColor::layerWithColor(ccc4(255,255,255,255)); + CCNode* blue = CCLayerColor::create(ccc4(0,0,255,255)); + CCNode* red = CCLayerColor::create(ccc4(255,0,0,255)); + CCNode* green = CCLayerColor::create(ccc4(0,255,0,255)); + CCNode* white = CCLayerColor::create(ccc4(255,255,255,255)); blue->setScale(0.5f); blue->setPosition(CCPointMake(-x/4,-y/4)); - blue->addChild( SpriteLayer::node() ); + blue->addChild( SpriteLayer::create() ); red->setScale(0.5f); red->setPosition(CCPointMake(x/4,-y/4)); green->setScale(0.5f); green->setPosition(CCPointMake(-x/4,y/4)); - green->addChild(TestLayer::node()); + green->addChild(TestLayer::create()); white->setScale(0.5f); white->setPosition(ccp(x/4,y/4)); @@ -116,7 +116,7 @@ void RotateWorldMainLayer::onEnter() addChild(green); addChild(red); - CCAction* rot = CCRotateBy::actionWithDuration(8, 720); + CCAction* rot = CCRotateBy::create(8, 720); blue->runAction(rot); red->runAction((CCAction *)(rot->copy()->autorelease())); @@ -126,10 +126,10 @@ void RotateWorldMainLayer::onEnter() void RotateWorldTestScene::runThisTest() { - CCLayer* pLayer = RotateWorldMainLayer::node(); + CCLayer* pLayer = RotateWorldMainLayer::create(); addChild(pLayer); - runAction( CCRotateBy::actionWithDuration(4, -360) ); + runAction( CCRotateBy::create(4, -360) ); CCDirector::sharedDirector()->replaceScene(this); diff --git a/tests/tests/RotateWorldTest/RotateWorldTest.h b/tests/tests/RotateWorldTest/RotateWorldTest.h index e916fd7e7a..2248be0e54 100644 --- a/tests/tests/RotateWorldTest/RotateWorldTest.h +++ b/tests/tests/RotateWorldTest/RotateWorldTest.h @@ -13,13 +13,7 @@ class SpriteLayer : public CCLayer { public: virtual void onEnter(); - static SpriteLayer* node() - { - SpriteLayer* pNode = new SpriteLayer(); - pNode->autorelease(); - - return pNode; - } + LAYER_CREATE_FUNC(SpriteLayer) }; class TestLayer : public CCLayer @@ -27,13 +21,7 @@ class TestLayer : public CCLayer public: virtual void onEnter(); - static TestLayer* node() - { - TestLayer* pNode = new TestLayer(); - pNode->autorelease(); - - return pNode; - } + LAYER_CREATE_FUNC(TestLayer) }; class RotateWorldMainLayer : public CCLayer @@ -41,13 +29,7 @@ class RotateWorldMainLayer : public CCLayer public: virtual void onEnter(); - static RotateWorldMainLayer* node() - { - RotateWorldMainLayer* pNode = new RotateWorldMainLayer(); - pNode->autorelease(); - - return pNode; - } + LAYER_CREATE_FUNC(RotateWorldMainLayer) }; #endif diff --git a/tests/tests/SceneTest/SceneTest.cpp b/tests/tests/SceneTest/SceneTest.cpp index 5ead21a744..f9096b87bd 100644 --- a/tests/tests/SceneTest/SceneTest.cpp +++ b/tests/tests/SceneTest/SceneTest.cpp @@ -18,21 +18,21 @@ enum SceneTestLayer1::SceneTestLayer1() { - CCMenuItemFont* item1 = CCMenuItemFont::itemWithString( "Test pushScene", this, menu_selector(SceneTestLayer1::onPushScene) ); - CCMenuItemFont* item2 = CCMenuItemFont::itemWithString( "Test pushScene w/transition", this, menu_selector(SceneTestLayer1::onPushSceneTran) ); - CCMenuItemFont* item3 = CCMenuItemFont::itemWithString( "Quit", this, menu_selector(SceneTestLayer1::onQuit) ); + CCMenuItemFont* item1 = CCMenuItemFont::create( "Test pushScene", this, menu_selector(SceneTestLayer1::onPushScene) ); + CCMenuItemFont* item2 = CCMenuItemFont::create( "Test pushScene w/transition", this, menu_selector(SceneTestLayer1::onPushSceneTran) ); + CCMenuItemFont* item3 = CCMenuItemFont::create( "Quit", this, menu_selector(SceneTestLayer1::onQuit) ); - CCMenu* menu = CCMenu::menuWithItems( item1, item2, item3, NULL ); + CCMenu* menu = CCMenu::create( item1, item2, item3, NULL ); menu->alignItemsVertically(); addChild( menu ); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite* sprite = CCSprite::spriteWithFile(s_pPathGrossini); + CCSprite* sprite = CCSprite::create(s_pPathGrossini); addChild(sprite); sprite->setPosition( CCPointMake(s.width-40, s.height/2) ); - CCActionInterval* rotate = CCRotateBy::actionWithDuration(2, 360); - CCAction* repeat = CCRepeatForever::actionWithAction(rotate); + CCActionInterval* rotate = CCRotateBy::create(2, 360); + CCAction* repeat = CCRepeatForever::create(rotate); sprite->runAction(repeat); schedule( schedule_selector(SceneTestLayer1::testDealloc) ); @@ -76,7 +76,7 @@ void SceneTestLayer1::onPushSceneTran(CCObject* pSender) CCLayer* pLayer = new SceneTestLayer2(); scene->addChild( pLayer, 0 ); - CCDirector::sharedDirector()->pushScene( CCTransitionSlideInT::transitionWithDuration(1, scene) ); + CCDirector::sharedDirector()->pushScene( CCTransitionSlideInT::create(1, scene) ); scene->release(); pLayer->release(); } @@ -103,21 +103,21 @@ SceneTestLayer2::SceneTestLayer2() { m_timeCounter = 0; - CCMenuItemFont* item1 = CCMenuItemFont::itemWithString( "replaceScene", this, menu_selector(SceneTestLayer2::onReplaceScene) ); - CCMenuItemFont* item2 = CCMenuItemFont::itemWithString( "replaceScene w/transition", this, menu_selector(SceneTestLayer2::onReplaceSceneTran) ); - CCMenuItemFont* item3 = CCMenuItemFont::itemWithString( "Go Back", this, menu_selector(SceneTestLayer2::onGoBack) ); + CCMenuItemFont* item1 = CCMenuItemFont::create( "replaceScene", this, menu_selector(SceneTestLayer2::onReplaceScene) ); + CCMenuItemFont* item2 = CCMenuItemFont::create( "replaceScene w/transition", this, menu_selector(SceneTestLayer2::onReplaceSceneTran) ); + CCMenuItemFont* item3 = CCMenuItemFont::create( "Go Back", this, menu_selector(SceneTestLayer2::onGoBack) ); - CCMenu* menu = CCMenu::menuWithItems( item1, item2, item3, NULL ); + CCMenu* menu = CCMenu::create( item1, item2, item3, NULL ); menu->alignItemsVertically(); addChild( menu ); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite* sprite = CCSprite::spriteWithFile(s_pPathGrossini); + CCSprite* sprite = CCSprite::create(s_pPathGrossini); addChild(sprite); sprite->setPosition( CCPointMake(s.width-40, s.height/2) ); - CCActionInterval* rotate = CCRotateBy::actionWithDuration(2, 360); - CCAction* repeat = CCRepeatForever::actionWithAction(rotate); + CCActionInterval* rotate = CCRotateBy::create(2, 360); + CCAction* repeat = CCRepeatForever::create(rotate); sprite->runAction(repeat); schedule( schedule_selector(SceneTestLayer2::testDealloc) ); @@ -138,7 +138,7 @@ void SceneTestLayer2::onGoBack(CCObject* pSender) void SceneTestLayer2::onReplaceScene(CCObject* pSender) { CCScene* pScene = new SceneTestScene(); - CCLayer* pLayer = SceneTestLayer3::node(); + CCLayer* pLayer = SceneTestLayer3::create(); pScene->addChild( pLayer, 0 ); CCDirector::sharedDirector()->replaceScene( pScene ); pScene->release(); @@ -148,9 +148,9 @@ void SceneTestLayer2::onReplaceScene(CCObject* pSender) void SceneTestLayer2::onReplaceSceneTran(CCObject* pSender) { CCScene* pScene = new SceneTestScene(); - CCLayer* pLayer = SceneTestLayer3::node(); + CCLayer* pLayer = SceneTestLayer3::create(); pScene->addChild( pLayer, 0 ); - CCDirector::sharedDirector()->replaceScene( CCTransitionFlipX::transitionWithDuration(2, pScene) ); + CCDirector::sharedDirector()->replaceScene( CCTransitionFlipX::create(2, pScene) ); pScene->release(); } @@ -171,22 +171,22 @@ bool SceneTestLayer3::init() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCMenuItemFont *item0 = CCMenuItemFont::itemWithString("Touch to pushScene (self)", this, menu_selector(SceneTestLayer3::item0Clicked)); - CCMenuItemFont *item1 = CCMenuItemFont::itemWithString("Touch to popScene", this, menu_selector(SceneTestLayer3::item1Clicked)); - CCMenuItemFont *item2 = CCMenuItemFont::itemWithString("Touch to popToRootScene", this, menu_selector(SceneTestLayer3::item2Clicked)); + CCMenuItemFont *item0 = CCMenuItemFont::create("Touch to pushScene (self)", this, menu_selector(SceneTestLayer3::item0Clicked)); + CCMenuItemFont *item1 = CCMenuItemFont::create("Touch to popScene", this, menu_selector(SceneTestLayer3::item1Clicked)); + CCMenuItemFont *item2 = CCMenuItemFont::create("Touch to popToRootScene", this, menu_selector(SceneTestLayer3::item2Clicked)); - CCMenu *menu = CCMenu::menuWithItems(item0, item1, item2, NULL); + CCMenu *menu = CCMenu::create(item0, item1, item2, NULL); this->addChild(menu); menu->alignItemsVertically(); this->schedule(schedule_selector(SceneTestLayer3::testDealloc)); - CCSprite* sprite = CCSprite::spriteWithFile(s_pPathGrossini); + CCSprite* sprite = CCSprite::create(s_pPathGrossini); addChild(sprite); sprite->setPosition( CCPointMake(s.width/2, 40) ); - CCActionInterval* rotate = CCRotateBy::actionWithDuration(2, 360); - CCAction* repeat = CCRepeatForever::actionWithAction(rotate); + CCActionInterval* rotate = CCRotateBy::create(2, 360); + CCAction* repeat = CCRepeatForever::create(rotate); sprite->runAction(repeat); return true; } @@ -200,9 +200,9 @@ void SceneTestLayer3::testDealloc(float dt) void SceneTestLayer3::item0Clicked(CCObject* pSender) { - CCScene *newScene = CCScene::node(); - newScene->addChild(SceneTestLayer3::node()); - CCDirector::sharedDirector()->pushScene(CCTransitionFade::transitionWithDuration(0.5, newScene, ccc3(0,255,255))); + CCScene *newScene = CCScene::create(); + newScene->addChild(SceneTestLayer3::create()); + CCDirector::sharedDirector()->pushScene(CCTransitionFade::create(0.5, newScene, ccc3(0,255,255))); } void SceneTestLayer3::item1Clicked(CCObject* pSender) diff --git a/tests/tests/SceneTest/SceneTest.h b/tests/tests/SceneTest/SceneTest.h index acf7a65329..d6c4320bde 100644 --- a/tests/tests/SceneTest/SceneTest.h +++ b/tests/tests/SceneTest/SceneTest.h @@ -44,7 +44,7 @@ public: void item0Clicked(CCObject* pSender); void item1Clicked(CCObject* pSender); void item2Clicked(CCObject* pSender); - LAYER_NODE_FUNC(SceneTestLayer3) + LAYER_CREATE_FUNC(SceneTestLayer3) } ; class SceneTestScene : public TestScene diff --git a/tests/tests/SchedulerTest/SchedulerTest.cpp b/tests/tests/SchedulerTest/SchedulerTest.cpp index 5c1f5cc97d..afb245f6fd 100644 --- a/tests/tests/SchedulerTest/SchedulerTest.cpp +++ b/tests/tests/SchedulerTest/SchedulerTest.cpp @@ -86,23 +86,23 @@ void SchedulerTestLayer::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 32); + CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 32); addChild(label); label->setPosition(ccp(s.width/2, s.height-50)); std::string subTitle = subtitle(); if(! subTitle.empty()) { - CCLabelTTF* l = CCLabelTTF::labelWithString(subTitle.c_str(), "Thonburi", 16); + CCLabelTTF* l = CCLabelTTF::create(subTitle.c_str(), "Thonburi", 16); addChild(l, 1); l->setPosition(ccp(s.width/2, s.height-80)); } - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage("Images/b1.png", "Images/b2.png", this, menu_selector(SchedulerTestLayer::backCallback)); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage("Images/r1.png","Images/r2.png", this, menu_selector(SchedulerTestLayer::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage("Images/f1.png", "Images/f2.png", this, menu_selector(SchedulerTestLayer::nextCallback) ); + CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(SchedulerTestLayer::backCallback)); + CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png","Images/r2.png", this, menu_selector(SchedulerTestLayer::restartCallback) ); + CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(SchedulerTestLayer::nextCallback) ); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition(CCPointZero); item1->setPosition(ccp( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2)); item2->setPosition(ccp( s.width/2, item2->getContentSize().height/2)); @@ -254,10 +254,10 @@ void SchedulerPauseResumeAll::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *sprite = CCSprite::spriteWithFile("Images/grossinis_sister1.png"); + CCSprite *sprite = CCSprite::create("Images/grossinis_sister1.png"); sprite->setPosition(ccp(s.width/2, s.height/2)); this->addChild(sprite); - sprite->runAction(CCRepeatForever::actionWithAction(CCRotateBy::actionWithDuration(3.0, 360))); + sprite->runAction(CCRepeatForever::create(CCRotateBy::create(3.0, 360))); schedule(schedule_selector(SchedulerPauseResumeAll::tick1), 0.5f); schedule(schedule_selector(SchedulerPauseResumeAll::tick2), 1.0f); @@ -332,10 +332,10 @@ void SchedulerPauseResumeAllUser::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *sprite = CCSprite::spriteWithFile("Images/grossinis_sister1.png"); + CCSprite *sprite = CCSprite::create("Images/grossinis_sister1.png"); sprite->setPosition(ccp(s.width/2, s.height/2)); this->addChild(sprite); - sprite->runAction(CCRepeatForever::actionWithAction(CCRotateBy::actionWithDuration(3.0, 360))); + sprite->runAction(CCRepeatForever::create(CCRotateBy::create(3.0, 360))); schedule(schedule_selector(SchedulerPauseResumeAllUser::tick1), 0.5f); schedule(schedule_selector(SchedulerPauseResumeAllUser::tick2), 1.0f); @@ -450,10 +450,10 @@ void SchedulerUnscheduleAllHard::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *sprite = CCSprite::spriteWithFile("Images/grossinis_sister1.png"); + CCSprite *sprite = CCSprite::create("Images/grossinis_sister1.png"); sprite->setPosition(ccp(s.width/2, s.height/2)); this->addChild(sprite); - sprite->runAction(CCRepeatForever::actionWithAction(CCRotateBy::actionWithDuration(3.0, 360))); + sprite->runAction(CCRepeatForever::create(CCRotateBy::create(3.0, 360))); m_bActionManagerActive = true; @@ -520,10 +520,10 @@ void SchedulerUnscheduleAllUserLevel::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *sprite = CCSprite::spriteWithFile("Images/grossinis_sister1.png"); + CCSprite *sprite = CCSprite::create("Images/grossinis_sister1.png"); sprite->setPosition(ccp(s.width/2, s.height/2)); this->addChild(sprite); - sprite->runAction(CCRepeatForever::actionWithAction(CCRotateBy::actionWithDuration(3.0, 360))); + sprite->runAction(CCRepeatForever::create(CCRotateBy::create(3.0, 360))); schedule(schedule_selector(SchedulerUnscheduleAllUserLevel::tick1), 0.5f); schedule(schedule_selector(SchedulerUnscheduleAllUserLevel::tick2), 1.0f); @@ -863,7 +863,7 @@ void SchedulerDelayAndRepeat::update(float dt) CCControlSlider* SchedulerTimeScale::sliderCtl() { - CCControlSlider * slider = CCControlSlider::sliderWithFiles("extensions/sliderTrack2.png","extensions/sliderProgress2.png" ,"extensions/sliderThumb.png"); + CCControlSlider * slider = CCControlSlider::create("extensions/sliderTrack2.png","extensions/sliderProgress2.png" ,"extensions/sliderThumb.png"); slider->addTargetWithActionForControlEvents(this, menu_selector(SchedulerTimeScale::sliderAction), CCControlEventValueChanged); @@ -890,22 +890,22 @@ void SchedulerTimeScale::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); // rotate and jump - CCActionInterval *jump1 = CCJumpBy::actionWithDuration(4, ccp(-s.width+80,0), 100, 4); + CCActionInterval *jump1 = CCJumpBy::create(4, ccp(-s.width+80,0), 100, 4); CCActionInterval *jump2 = jump1->reverse(); - CCActionInterval *rot1 = CCRotateBy::actionWithDuration(4, 360*2); + CCActionInterval *rot1 = CCRotateBy::create(4, 360*2); CCActionInterval *rot2 = rot1->reverse(); - CCFiniteTimeAction* seq3_1 = CCSequence::actions(jump2, jump1, NULL); - CCFiniteTimeAction* seq3_2 = CCSequence::actions(rot1, rot2, NULL); - CCFiniteTimeAction* spawn = CCSpawn::actions(seq3_1, seq3_2, NULL); - CCRepeat* action = CCRepeat::actionWithAction(spawn, 50); + CCFiniteTimeAction* seq3_1 = CCSequence::create(jump2, jump1, NULL); + CCFiniteTimeAction* seq3_2 = CCSequence::create(rot1, rot2, NULL); + CCFiniteTimeAction* spawn = CCSpawn::create(seq3_1, seq3_2, NULL); + CCRepeat* action = CCRepeat::create(spawn, 50); CCRepeat* action2 = (CCRepeat*)action->copy()->autorelease(); CCRepeat* action3 = (CCRepeat*)action->copy()->autorelease(); - CCSprite *grossini = CCSprite::spriteWithFile("Images/grossini.png"); - CCSprite *tamara = CCSprite::spriteWithFile("Images/grossinis_sister1.png"); - CCSprite *kathia = CCSprite::spriteWithFile("Images/grossinis_sister2.png"); + CCSprite *grossini = CCSprite::create("Images/grossini.png"); + CCSprite *tamara = CCSprite::create("Images/grossinis_sister1.png"); + CCSprite *kathia = CCSprite::create("Images/grossinis_sister2.png"); grossini->setPosition(ccp(40,80)); tamara->setPosition(ccp(40,80)); @@ -915,11 +915,11 @@ void SchedulerTimeScale::onEnter() addChild(tamara); addChild(kathia); - grossini->runAction(CCSpeed::actionWithAction(action, 0.5f)); - tamara->runAction(CCSpeed::actionWithAction(action2, 1.5f)); - kathia->runAction(CCSpeed::actionWithAction(action3, 1.0f)); + grossini->runAction(CCSpeed::create(action, 0.5f)); + tamara->runAction(CCSpeed::create(action2, 1.5f)); + kathia->runAction(CCSpeed::create(action3, 1.0f)); - CCParticleSystem *emitter = CCParticleFireworks::node(); + CCParticleSystem *emitter = CCParticleFireworks::create(); emitter->setTexture( CCTextureCache::sharedTextureCache()->addImage(s_stars1) ); addChild(emitter); @@ -951,7 +951,7 @@ std::string SchedulerTimeScale::subtitle() CCControlSlider *TwoSchedulers::sliderCtl() { // CGRect frame = CGRectMake(12.0f, 12.0f, 120.0f, 7.0f); - CCControlSlider *slider = CCControlSlider::sliderWithFiles("extensions/sliderTrack2.png","extensions/sliderProgress2.png" ,"extensions/sliderThumb.png"); + CCControlSlider *slider = CCControlSlider::create("extensions/sliderTrack2.png","extensions/sliderProgress2.png" ,"extensions/sliderThumb.png"); //[[UISlider alloc] initWithFrame:frame]; slider->addTargetWithActionForControlEvents(this, menu_selector(TwoSchedulers::sliderAction), CCControlEventValueChanged); @@ -986,16 +986,16 @@ void TwoSchedulers::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); // rotate and jump - CCActionInterval *jump1 = CCJumpBy::actionWithDuration(4, ccp(0,0), 100, 4); + CCActionInterval *jump1 = CCJumpBy::create(4, ccp(0,0), 100, 4); CCActionInterval *jump2 = jump1->reverse(); - CCFiniteTimeAction* seq = CCSequence::actions(jump2, jump1, NULL); - CCRepeatForever* action = CCRepeatForever::actionWithAction((CCActionInterval *)seq); + CCFiniteTimeAction* seq = CCSequence::create(jump2, jump1, NULL); + CCRepeatForever* action = CCRepeatForever::create((CCActionInterval *)seq); // // Center // - CCSprite *grossini = CCSprite::spriteWithFile("Images/grossini.png"); + CCSprite *grossini = CCSprite::create("Images/grossini.png"); addChild(grossini); grossini->setPosition(ccp(s.width/2,100)); grossini->runAction((CCAction*)action->copy()->autorelease()); @@ -1019,7 +1019,7 @@ void TwoSchedulers::onEnter() for( unsigned int i=0; i < 10; i++ ) { - CCSprite *sprite = CCSprite::spriteWithFile("Images/grossinis_sister1.png"); + CCSprite *sprite = CCSprite::create("Images/grossinis_sister1.png"); // IMPORTANT: Set the actionManager running any action sprite->setActionManager(actionManager1); @@ -1044,7 +1044,7 @@ void TwoSchedulers::onEnter() sched2->scheduleUpdateForTarget(actionManager2, 0, false); for( unsigned int i=0; i < 10; i++ ) { - CCSprite *sprite = CCSprite::spriteWithFile("Images/grossinis_sister2.png"); + CCSprite *sprite = CCSprite::create("Images/grossinis_sister2.png"); // IMPORTANT: Set the actionManager running any action sprite->setActionManager(actionManager2); diff --git a/tests/tests/ShaderTest/ShaderTest.cpp b/tests/tests/ShaderTest/ShaderTest.cpp index 060c6c34a8..8447831855 100644 --- a/tests/tests/ShaderTest/ShaderTest.cpp +++ b/tests/tests/ShaderTest/ShaderTest.cpp @@ -65,7 +65,7 @@ bool ShaderTestDemo::init() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF *label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 26); + CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 26); addChild(label, 1); label->setPosition(ccp(s.width/2, s.height-50)); label->setColor(ccRED); @@ -73,16 +73,16 @@ bool ShaderTestDemo::init() std::string subtitle = this->subtitle(); if (subtitle.length() > 0) { - CCLabelTTF *l = CCLabelTTF::labelWithString(subtitle.c_str(), "Thonburi", 16); + CCLabelTTF *l = CCLabelTTF::create(subtitle.c_str(), "Thonburi", 16); addChild(l, 1); l->setPosition(ccp(s.width/2, s.height-80)); } - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(ShaderTestDemo::backCallback)); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(ShaderTestDemo::restartCallback)); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(ShaderTestDemo::nextCallback)); + CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(ShaderTestDemo::backCallback)); + CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(ShaderTestDemo::restartCallback)); + CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(ShaderTestDemo::nextCallback)); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition(ccp(0, 0)); item1->setPosition(s.width/2- item2->getContentSize().width*2, item2->getContentSize().height/2); @@ -104,7 +104,7 @@ void ShaderTestDemo::backCallback(CCObject* pSender) void ShaderTestDemo::nextCallback(CCObject* pSender) { - CCScene* s = new ShaderTestScene();//CCScene::node(); + CCScene* s = new ShaderTestScene();//CCScene::create(); s->addChild( nextAction() ); CCDirector::sharedDirector()->replaceScene(s); s->release(); @@ -442,7 +442,7 @@ public: bool initWithTexture(CCTexture2D* texture, const CCRect& rect); void draw(); - static SpriteBlur* spriteWithFile(const char *pszFileName); + static SpriteBlur* create(const char *pszFileName); CCPoint blur_; GLfloat sub_[4]; @@ -451,7 +451,7 @@ public: GLuint subLocation; }; -SpriteBlur* SpriteBlur::spriteWithFile(const char *pszFileName) +SpriteBlur* SpriteBlur::create(const char *pszFileName) { SpriteBlur* pRet = new SpriteBlur(); if (pRet && pRet->initWithFile(pszFileName)) @@ -573,7 +573,7 @@ CCControlSlider* ShaderBlur::createSliderCtl() { CCSize screenSize = CCDirector::sharedDirector()->getWinSize(); - CCControlSlider *slider = CCControlSlider::sliderWithFiles("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png"); + CCControlSlider *slider = CCControlSlider::create("extensions/sliderTrack.png","extensions/sliderProgress.png" ,"extensions/sliderThumb.png"); slider->setAnchorPoint(ccp(0.5f, 1.0f)); slider->setMinimumValue(0.0f); // Sets the min value of range slider->setMaximumValue(3.0f); // Sets the max value of range @@ -591,9 +591,9 @@ bool ShaderBlur::init() { if( ShaderTestDemo::init() ) { - m_pBlurSprite = SpriteBlur::spriteWithFile("Images/grossini.png"); + m_pBlurSprite = SpriteBlur::create("Images/grossini.png"); - CCSprite *sprite = CCSprite::spriteWithFile("Images/grossini.png"); + CCSprite *sprite = CCSprite::create("Images/grossini.png"); CCSize s = CCDirector::sharedDirector()->getWinSize(); m_pBlurSprite->setPosition(ccp(s.width/3, s.height/2)); @@ -644,7 +644,7 @@ bool ShaderRetroEffect::init() CCDirector *director = CCDirector::sharedDirector(); CCSize s = director->getWinSize(); - m_pLabel = CCLabelBMFont::labelWithString("RETRO EFFECT", "fonts/west_england-64.fnt"); + m_pLabel = CCLabelBMFont::create("RETRO EFFECT", "fonts/west_england-64.fnt"); m_pLabel->setShaderProgram(p); diff --git a/tests/tests/ShaderTest/ShaderTest.h b/tests/tests/ShaderTest/ShaderTest.h index 99250a659c..f83c03c9db 100644 --- a/tests/tests/ShaderTest/ShaderTest.h +++ b/tests/tests/ShaderTest/ShaderTest.h @@ -17,7 +17,7 @@ public: void nextCallback(CCObject* pSender); void backCallback(CCObject* pSender); - LAYER_NODE_FUNC(ShaderTestDemo); + LAYER_CREATE_FUNC(ShaderTestDemo); }; class ShaderMonjori : public ShaderTestDemo diff --git a/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id b/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id index 658b9ce4e6..57683d0f9e 100644 --- a/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id +++ b/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id @@ -1 +1 @@ -d45a5f1bd2f7a3c21828ba6d806255a3a78f2806 \ No newline at end of file +6824810bc1cfa5dd0dbf72f9966524b82ebe0a52 \ No newline at end of file diff --git a/tests/tests/TextInputTest/TextInputTest.cpp b/tests/tests/TextInputTest/TextInputTest.cpp index d870c6447a..388f764f58 100644 --- a/tests/tests/TextInputTest/TextInputTest.cpp +++ b/tests/tests/TextInputTest/TextInputTest.cpp @@ -120,23 +120,23 @@ void TextInputTest::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 24); + CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 24); addChild(label); label->setPosition(ccp(s.width/2, s.height-50)); std::string subTitle = m_pNotificationLayer->subtitle(); if(! subTitle.empty()) { - CCLabelTTF* l = CCLabelTTF::labelWithString(subTitle.c_str(), "Thonburi", 16); + CCLabelTTF* l = CCLabelTTF::create(subTitle.c_str(), "Thonburi", 16); addChild(l, 1); l->setPosition(ccp(s.width/2, s.height-80)); } - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage("Images/b1.png", "Images/b2.png", this, menu_selector(TextInputTest::backCallback)); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage("Images/r1.png","Images/r2.png", this, menu_selector(TextInputTest::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage("Images/f1.png", "Images/f2.png", this, menu_selector(TextInputTest::nextCallback) ); + CCMenuItemImage *item1 = CCMenuItemImage::create("Images/b1.png", "Images/b2.png", this, menu_selector(TextInputTest::backCallback)); + CCMenuItemImage *item2 = CCMenuItemImage::create("Images/r1.png","Images/r2.png", this, menu_selector(TextInputTest::restartCallback) ); + CCMenuItemImage *item3 = CCMenuItemImage::create("Images/f1.png", "Images/f2.png", this, menu_selector(TextInputTest::nextCallback) ); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition(CCPointZero); item1->setPosition(ccp( s.width/2 - 100,30)); item2->setPosition(ccp( s.width/2, 30)); @@ -322,10 +322,10 @@ void TextFieldTTFActionTest::onEnter() m_nCharLimit = 12; - m_pTextFieldAction = CCRepeatForever::actionWithAction( - (CCActionInterval*)CCSequence::actions( - CCFadeOut::actionWithDuration(0.25), - CCFadeIn::actionWithDuration(0.25), + m_pTextFieldAction = CCRepeatForever::create( + (CCActionInterval*)CCSequence::create( + CCFadeOut::create(0.25), + CCFadeIn::create(0.25), 0 )); m_pTextFieldAction->retain(); @@ -395,7 +395,7 @@ bool TextFieldTTFActionTest::onTextFieldInsertText(CCTextFieldTTF * pSender, con } // create a insert text sprite and do some action - CCLabelTTF * label = CCLabelTTF::labelWithString(text, FONT_NAME, FONT_SIZE); + CCLabelTTF * label = CCLabelTTF::create(text, FONT_NAME, FONT_SIZE); this->addChild(label); ccColor3B color = { 226, 121, 7}; label->setColor(color); @@ -413,13 +413,13 @@ bool TextFieldTTFActionTest::onTextFieldInsertText(CCTextFieldTTF * pSender, con label->setPosition(beginPos); label->setScale(8); - CCAction * seq = CCSequence::actions( - CCSpawn::actions( - CCMoveTo::actionWithDuration(duration, endPos), - CCScaleTo::actionWithDuration(duration, 1), - CCFadeOut::actionWithDuration(duration), + CCAction * seq = CCSequence::create( + CCSpawn::create( + CCMoveTo::create(duration, endPos), + CCScaleTo::create(duration, 1), + CCFadeOut::create(duration), 0), - CCCallFuncN::actionWithTarget(this, callfuncN_selector(TextFieldTTFActionTest::callbackRemoveNodeWhenDidAction)), + CCCallFuncN::create(this, callfuncN_selector(TextFieldTTFActionTest::callbackRemoveNodeWhenDidAction)), 0); label->runAction(seq); return false; @@ -428,7 +428,7 @@ bool TextFieldTTFActionTest::onTextFieldInsertText(CCTextFieldTTF * pSender, con bool TextFieldTTFActionTest::onTextFieldDeleteBackward(CCTextFieldTTF * pSender, const char * delText, int nLen) { // create a delete text sprite and do some action - CCLabelTTF * label = CCLabelTTF::labelWithString(delText, FONT_NAME, FONT_SIZE); + CCLabelTTF * label = CCLabelTTF::create(delText, FONT_NAME, FONT_SIZE); this->addChild(label); // move the sprite to fly out @@ -445,15 +445,15 @@ bool TextFieldTTFActionTest::onTextFieldDeleteBackward(CCTextFieldTTF * pSender, int repeatTime = 5; label->setPosition(beginPos); - CCAction * seq = CCSequence::actions( - CCSpawn::actions( - CCMoveTo::actionWithDuration(duration, endPos), - CCRepeat::actionWithAction( - CCRotateBy::actionWithDuration(rotateDuration, (rand()%2) ? 360 : -360), + CCAction * seq = CCSequence::create( + CCSpawn::create( + CCMoveTo::create(duration, endPos), + CCRepeat::create( + CCRotateBy::create(rotateDuration, (rand()%2) ? 360 : -360), repeatTime), - CCFadeOut::actionWithDuration(duration), + CCFadeOut::create(duration), 0), - CCCallFuncN::actionWithTarget(this, callfuncN_selector(TextFieldTTFActionTest::callbackRemoveNodeWhenDidAction)), + CCCallFuncN::create(this, callfuncN_selector(TextFieldTTFActionTest::callbackRemoveNodeWhenDidAction)), 0); label->runAction(seq); return false; diff --git a/tests/tests/Texture2dTest/Texture2dTest.cpp b/tests/tests/Texture2dTest/Texture2dTest.cpp index a0c63d9c69..c393beb301 100644 --- a/tests/tests/Texture2dTest/Texture2dTest.cpp +++ b/tests/tests/Texture2dTest/Texture2dTest.cpp @@ -136,23 +136,23 @@ void TextureDemo::onEnter() CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF *label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 26); + CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 26); addChild(label, 1, kTagLabel); label->setPosition(ccp(s.width/2, s.height-50)); std::string strSubtitle = subtitle(); if(strSubtitle.length()) { - CCLabelTTF *l = CCLabelTTF::labelWithString(strSubtitle.c_str(), "Thonburi", 16); + CCLabelTTF *l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16); addChild(l, 1); l->setPosition(ccp(s.width/2, s.height-80)); } - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(TextureDemo::backCallback) ); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(TextureDemo::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(TextureDemo::nextCallback) ); + CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(TextureDemo::backCallback) ); + CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(TextureDemo::restartCallback) ); + CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(TextureDemo::nextCallback) ); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition(CCPointZero); item1->setPosition(ccp( s.width/2 - 100,30)); item2->setPosition(ccp( s.width/2, 30)); @@ -212,7 +212,7 @@ void TextureTIFF::onEnter() TextureDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *img = CCSprite::spriteWithFile("Images/test_image.tiff"); + CCSprite *img = CCSprite::create("Images/test_image.tiff"); img->setPosition(ccp( s.width/2.0f, s.height/2.0f)); this->addChild(img); CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo(); @@ -234,7 +234,7 @@ void TexturePNG::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *img = CCSprite::spriteWithFile("Images/test_image.png"); + CCSprite *img = CCSprite::create("Images/test_image.png"); img->setPosition(ccp( s.width/2.0f, s.height/2.0f)); addChild(img); CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo(); @@ -255,7 +255,7 @@ void TextureJPEG::onEnter() TextureDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *img = CCSprite::spriteWithFile("Images/test_image.jpeg"); + CCSprite *img = CCSprite::create("Images/test_image.jpeg"); img->setPosition(ccp( s.width/2.0f, s.height/2.0f)); addChild(img); CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo(); @@ -283,26 +283,26 @@ void TextureMipMap::onEnter() CCTexture2D *texture1 = CCTextureCache::sharedTextureCache()->addImage("Images/grossini_dance_atlas_nomipmap.png"); - CCSprite *img0 = CCSprite::spriteWithTexture(texture0); + CCSprite *img0 = CCSprite::createWithTexture(texture0); img0->setTextureRect(CCRectMake(85, 121, 85, 121)); img0->setPosition(ccp( s.width/3.0f, s.height/2.0f)); addChild(img0); - CCSprite *img1 = CCSprite::spriteWithTexture(texture1); + CCSprite *img1 = CCSprite::createWithTexture(texture1); img1->setTextureRect(CCRectMake(85, 121, 85, 121)); img1->setPosition(ccp( 2*s.width/3.0f, s.height/2.0f)); addChild(img1); - CCEaseOut* scale1 = CCEaseOut::actionWithAction(CCScaleBy::actionWithDuration(4, 0.01f), 3); + CCEaseOut* scale1 = CCEaseOut::create(CCScaleBy::create(4, 0.01f), 3); CCActionInterval* sc_back = scale1->reverse(); CCEaseOut* scale2 = (CCEaseOut*) (scale1->copy()); scale2->autorelease(); CCActionInterval* sc_back2 = scale2->reverse(); - img0->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)(CCSequence::actions(scale1, sc_back, NULL)))); - img1->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)(CCSequence::actions(scale2, sc_back2, NULL)))); + img0->runAction(CCRepeatForever::create((CCActionInterval*)(CCSequence::create(scale1, sc_back, NULL)))); + img1->runAction(CCRepeatForever::create((CCActionInterval*)(CCSequence::create(scale2, sc_back2, NULL)))); CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo(); } @@ -328,7 +328,7 @@ void TexturePVRMipMap::onEnter() TextureDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *imgMipMap = CCSprite::spriteWithFile("Images/logo-mipmap.pvr"); + CCSprite *imgMipMap = CCSprite::create("Images/logo-mipmap.pvr"); if( imgMipMap ) { imgMipMap->setPosition(ccp( s.width/2.0f-100, s.height/2.0f)); @@ -339,21 +339,21 @@ void TexturePVRMipMap::onEnter() imgMipMap->getTexture()->setTexParameters(&texParams); } - CCSprite *img = CCSprite::spriteWithFile("Images/logo-nomipmap.pvr"); + CCSprite *img = CCSprite::create("Images/logo-nomipmap.pvr"); if( img ) { img->setPosition(ccp( s.width/2.0f+100, s.height/2.0f)); addChild(img); - CCEaseOut* scale1 = CCEaseOut::actionWithAction(CCScaleBy::actionWithDuration(4, 0.01f), 3); + CCEaseOut* scale1 = CCEaseOut::create(CCScaleBy::create(4, 0.01f), 3); CCActionInterval* sc_back = scale1->reverse(); CCEaseOut* scale2 = (CCEaseOut*) (scale1->copy()); scale2->autorelease(); CCActionInterval* sc_back2 = scale2->reverse(); - imgMipMap->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)(CCSequence::actions(scale1, sc_back, NULL)))); - img->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)(CCSequence::actions(scale2, sc_back2, NULL)))); + imgMipMap->runAction(CCRepeatForever::create((CCActionInterval*)(CCSequence::create(scale1, sc_back, NULL)))); + img->runAction(CCRepeatForever::create((CCActionInterval*)(CCSequence::create(scale2, sc_back2, NULL)))); } CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo(); } @@ -377,7 +377,7 @@ void TexturePVRMipMap2::onEnter() TextureDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *imgMipMap = CCSprite::spriteWithFile("Images/test_image_rgba4444_mipmap.pvr"); + CCSprite *imgMipMap = CCSprite::create("Images/test_image_rgba4444_mipmap.pvr"); imgMipMap->setPosition(ccp( s.width/2.0f-100, s.height/2.0f)); addChild(imgMipMap); @@ -385,19 +385,19 @@ void TexturePVRMipMap2::onEnter() ccTexParams texParams = { GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE }; imgMipMap->getTexture()->setTexParameters(&texParams); - CCSprite *img = CCSprite::spriteWithFile("Images/test_image.png"); + CCSprite *img = CCSprite::create("Images/test_image.png"); img->setPosition(ccp( s.width/2.0f+100, s.height/2.0f)); addChild(img); - CCEaseOut* scale1 = CCEaseOut::actionWithAction(CCScaleBy::actionWithDuration(4, 0.01f), 3); + CCEaseOut* scale1 = CCEaseOut::create(CCScaleBy::create(4, 0.01f), 3); CCActionInterval* sc_back = scale1->reverse(); CCEaseOut* scale2 = (CCEaseOut*) (scale1->copy()); scale2->autorelease(); CCActionInterval* sc_back2 = scale2->reverse(); - imgMipMap->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)(CCSequence::actions(scale1, sc_back, NULL)))); - img->runAction(CCRepeatForever::actionWithAction((CCActionInterval*)(CCSequence::actions(scale2, sc_back2, NULL)))); + imgMipMap->runAction(CCRepeatForever::create((CCActionInterval*)(CCSequence::create(scale1, sc_back, NULL)))); + img->runAction(CCRepeatForever::create((CCActionInterval*)(CCSequence::create(scale2, sc_back2, NULL)))); CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo(); } @@ -423,7 +423,7 @@ void TexturePVR2BPP::onEnter() TextureDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *img = CCSprite::spriteWithFile("Images/test_image_pvrtc2bpp.pvr"); + CCSprite *img = CCSprite::create("Images/test_image_pvrtc2bpp.pvr"); if( img ) { @@ -450,7 +450,7 @@ void TexturePVR::onEnter() TextureDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *img = CCSprite::spriteWithFile("Images/test_image.pvr"); + CCSprite *img = CCSprite::create("Images/test_image.pvr"); if( img ) { @@ -482,7 +482,7 @@ void TexturePVR4BPP::onEnter() TextureDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *img = CCSprite::spriteWithFile("Images/test_image_pvrtc4bpp.pvr"); + CCSprite *img = CCSprite::create("Images/test_image_pvrtc4bpp.pvr"); if( img ) { @@ -513,7 +513,7 @@ void TexturePVRRGBA8888::onEnter() TextureDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *img = CCSprite::spriteWithFile("Images/test_image_rgba8888.pvr"); + CCSprite *img = CCSprite::create("Images/test_image_rgba8888.pvr"); img->setPosition(ccp( s.width/2.0f, s.height/2.0f)); addChild(img); CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo(); @@ -536,7 +536,7 @@ void TexturePVRBGRA8888::onEnter() TextureDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *img = CCSprite::spriteWithFile("Images/test_image_bgra8888.pvr"); + CCSprite *img = CCSprite::create("Images/test_image_bgra8888.pvr"); if( img ) { img->setPosition(ccp( s.width/2.0f, s.height/2.0f)); @@ -566,7 +566,7 @@ void TexturePVRRGBA5551::onEnter() TextureDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *img = CCSprite::spriteWithFile("Images/test_image_rgba5551.pvr"); + CCSprite *img = CCSprite::create("Images/test_image_rgba5551.pvr"); img->setPosition(ccp( s.width/2.0f, s.height/2.0f)); addChild(img); CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo(); @@ -589,7 +589,7 @@ void TexturePVRRGBA4444::onEnter() TextureDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *img = CCSprite::spriteWithFile("Images/test_image_rgba4444.pvr"); + CCSprite *img = CCSprite::create("Images/test_image_rgba4444.pvr"); img->setPosition(ccp( s.width/2.0f, s.height/2.0f)); addChild(img); CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo(); @@ -614,9 +614,9 @@ void TexturePVRRGBA4444GZ::onEnter() #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) // android can not pack .gz file into apk file - CCSprite *img = CCSprite::spriteWithFile("Images/test_image_rgba4444.pvr"); + CCSprite *img = CCSprite::create("Images/test_image_rgba4444.pvr"); #else - CCSprite *img = CCSprite::spriteWithFile("Images/test_image_rgba4444.pvr.gz"); + CCSprite *img = CCSprite::create("Images/test_image_rgba4444.pvr.gz"); #endif img->setPosition(ccp( s.width/2.0f, s.height/2.0f)); addChild(img); @@ -645,7 +645,7 @@ void TexturePVRRGBA4444CCZ::onEnter() TextureDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *img = CCSprite::spriteWithFile("Images/test_image_rgba4444.pvr.ccz"); + CCSprite *img = CCSprite::create("Images/test_image_rgba4444.pvr.ccz"); img->setPosition(ccp( s.width/2.0f, s.height/2.0f)); addChild(img); CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo(); @@ -673,7 +673,7 @@ void TexturePVRRGB565::onEnter() TextureDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *img = CCSprite::spriteWithFile("Images/test_image_rgb565.pvr"); + CCSprite *img = CCSprite::create("Images/test_image_rgb565.pvr"); img->setPosition(ccp( s.width/2.0f, s.height/2.0f)); addChild(img); CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo(); @@ -692,7 +692,7 @@ void TexturePVRRGB888::onEnter() TextureDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *img = CCSprite::spriteWithFile("Images/test_image_rgb888.pvr"); + CCSprite *img = CCSprite::create("Images/test_image_rgb888.pvr"); if (img != NULL) { img->setPosition(ccp( s.width/2.0f, s.height/2.0f)); @@ -719,7 +719,7 @@ void TexturePVRA8::onEnter() TextureDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *img = CCSprite::spriteWithFile("Images/test_image_a8.pvr"); + CCSprite *img = CCSprite::create("Images/test_image_a8.pvr"); img->setPosition(ccp( s.width/2.0f, s.height/2.0f)); addChild(img); CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo(); @@ -743,7 +743,7 @@ void TexturePVRI8::onEnter() TextureDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *img = CCSprite::spriteWithFile("Images/test_image_i8.pvr"); + CCSprite *img = CCSprite::create("Images/test_image_i8.pvr"); img->setPosition(ccp( s.width/2.0f, s.height/2.0f)); addChild(img); CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo(); @@ -766,7 +766,7 @@ void TexturePVRAI88::onEnter() TextureDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *img = CCSprite::spriteWithFile("Images/test_image_ai88.pvr"); + CCSprite *img = CCSprite::create("Images/test_image_ai88.pvr"); img->setPosition(ccp( s.width/2.0f, s.height/2.0f)); addChild(img); CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo(); @@ -789,7 +789,7 @@ void TexturePVRBadEncoding::onEnter() TextureDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *img = CCSprite::spriteWithFile("Images/test_image-bad_encoding.pvr"); + CCSprite *img = CCSprite::create("Images/test_image-bad_encoding.pvr"); if( img ) { img->setPosition(ccp( s.width/2.0f, s.height/2.0f)); @@ -817,7 +817,7 @@ void TexturePVRNonSquare::onEnter() TextureDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *img = CCSprite::spriteWithFile("Images/grossini_128x256_mipmap.pvr"); + CCSprite *img = CCSprite::create("Images/grossini_128x256_mipmap.pvr"); img->setPosition(ccp( s.width/2.0f, s.height/2.0f)); addChild(img); CCTextureCache::sharedTextureCache()->dumpCachedTextureInfo(); @@ -843,7 +843,7 @@ void TexturePVRNPOT4444::onEnter() TextureDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *img = CCSprite::spriteWithFile("Images/grossini_pvr_rgba4444.pvr"); + CCSprite *img = CCSprite::create("Images/grossini_pvr_rgba4444.pvr"); if ( img ) { img->setPosition(ccp( s.width/2.0f, s.height/2.0f)); @@ -872,7 +872,7 @@ void TexturePVRNPOT8888::onEnter() TextureDemo::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCSprite *img = CCSprite::spriteWithFile("Images/grossini_pvr_rgba8888.pvr"); + CCSprite *img = CCSprite::create("Images/grossini_pvr_rgba8888.pvr"); if( img ) { img->setPosition(ccp( s.width/2.0f, s.height/2.0f)); @@ -906,7 +906,7 @@ void TextureAlias::onEnter() // // Default filter is GL_LINEAR - CCSprite *sprite = CCSprite::spriteWithFile("Images/grossinis_sister1.png"); + CCSprite *sprite = CCSprite::create("Images/grossinis_sister1.png"); sprite->setPosition(ccp( s.width/3.0f, s.height/2.0f)); addChild(sprite); @@ -917,7 +917,7 @@ void TextureAlias::onEnter() // Sprite 1: GL_NEAREST // - CCSprite *sprite2 = CCSprite::spriteWithFile("Images/grossinis_sister2.png"); + CCSprite *sprite2 = CCSprite::create("Images/grossinis_sister2.png"); sprite2->setPosition(ccp( 2*s.width/3.0f, s.height/2.0f)); addChild(sprite2); @@ -925,9 +925,9 @@ void TextureAlias::onEnter() sprite2->getTexture()->setAliasTexParameters(); // scale them to show - CCScaleBy* sc = CCScaleBy::actionWithDuration(3, 8.0f); + CCScaleBy* sc = CCScaleBy::create(3, 8.0f); CCScaleBy* sc_back = (CCScaleBy*) (sc->reverse()); - CCRepeatForever* scaleforever = CCRepeatForever::actionWithAction((CCActionInterval*) (CCSequence::actions(sc, sc_back, NULL))); + CCRepeatForever* scaleforever = CCRepeatForever::create((CCActionInterval*) (CCSequence::create(sc, sc_back, NULL))); CCRepeatForever* scaleToo = (CCRepeatForever*) (scaleforever->copy()); scaleToo->autorelease(); @@ -967,12 +967,12 @@ void TexturePixelFormat::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLayerColor *background = CCLayerColor::layerWithColor(ccc4(128,128,128,255), s.width, s.height); + CCLayerColor *background = CCLayerColor::create(ccc4(128,128,128,255), s.width, s.height); addChild(background, -1); // RGBA 8888 image (32-bit) CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA8888); - CCSprite *sprite1 = CCSprite::spriteWithFile("Images/test-rgba1.png"); + CCSprite *sprite1 = CCSprite::create("Images/test-rgba1.png"); sprite1->setPosition(ccp(1*s.width/7, s.height/2+32)); addChild(sprite1, 0); @@ -981,7 +981,7 @@ void TexturePixelFormat::onEnter() // RGBA 4444 image (16-bit) CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGBA4444); - CCSprite *sprite2 = CCSprite::spriteWithFile("Images/test-rgba1.png"); + CCSprite *sprite2 = CCSprite::create("Images/test-rgba1.png"); sprite2->setPosition(ccp(2*s.width/7, s.height/2-32)); addChild(sprite2, 0); @@ -990,7 +990,7 @@ void TexturePixelFormat::onEnter() // RGB5A1 image (16-bit) CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGB5A1); - CCSprite *sprite3 = CCSprite::spriteWithFile("Images/test-rgba1.png"); + CCSprite *sprite3 = CCSprite::create("Images/test-rgba1.png"); sprite3->setPosition(ccp(3*s.width/7, s.height/2+32)); addChild(sprite3, 0); @@ -999,7 +999,7 @@ void TexturePixelFormat::onEnter() // RGB888 image CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGB888); - CCSprite *sprite4 = CCSprite::spriteWithFile("Images/test-rgba1.png"); + CCSprite *sprite4 = CCSprite::create("Images/test-rgba1.png"); sprite4->setPosition(ccp(4*s.width/7, s.height/2-32)); addChild(sprite4, 0); @@ -1008,7 +1008,7 @@ void TexturePixelFormat::onEnter() // RGB565 image (16-bit) CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_RGB565); - CCSprite *sprite5 = CCSprite::spriteWithFile("Images/test-rgba1.png"); + CCSprite *sprite5 = CCSprite::create("Images/test-rgba1.png"); sprite5->setPosition(ccp(5*s.width/7, s.height/2+32)); addChild(sprite5, 0); @@ -1017,17 +1017,17 @@ void TexturePixelFormat::onEnter() // A8 image (8-bit) CCTexture2D::setDefaultAlphaPixelFormat(kCCTexture2DPixelFormat_A8); - CCSprite *sprite6 = CCSprite::spriteWithFile("Images/test-rgba1.png"); + CCSprite *sprite6 = CCSprite::create("Images/test-rgba1.png"); sprite6->setPosition(ccp(6*s.width/7, s.height/2-32)); addChild(sprite6, 0); // remove texture from texture manager CCTextureCache::sharedTextureCache()->removeTexture(sprite6->getTexture()); - CCFadeOut* fadeout = CCFadeOut::actionWithDuration(2); - CCFadeIn* fadein = CCFadeIn::actionWithDuration(2); - CCFiniteTimeAction* seq = CCSequence::actions(CCDelayTime::actionWithDuration(2), fadeout, fadein, NULL); - CCRepeatForever* seq_4ever = CCRepeatForever::actionWithAction((CCActionInterval*) seq); + CCFadeOut* fadeout = CCFadeOut::create(2); + CCFadeIn* fadein = CCFadeIn::create(2); + CCFiniteTimeAction* seq = CCSequence::create(CCDelayTime::create(2), fadeout, fadein, NULL); + CCRepeatForever* seq_4ever = CCRepeatForever::create((CCActionInterval*) seq); CCRepeatForever* seq_4ever2 = (CCRepeatForever*) (seq_4ever->copy()); seq_4ever2->autorelease(); CCRepeatForever* seq_4ever3 = (CCRepeatForever*) (seq_4ever->copy()); seq_4ever3->autorelease(); CCRepeatForever* seq_4ever4 = (CCRepeatForever*) (seq_4ever->copy()); seq_4ever4->autorelease(); @@ -1067,7 +1067,7 @@ void TextureBlend::onEnter() { // BOTTOM sprites have alpha pre-multiplied // they use by default GL_ONE, GL_ONE_MINUS_SRC_ALPHA - CCSprite *cloud = CCSprite::spriteWithFile("Images/test_blend.png"); + CCSprite *cloud = CCSprite::create("Images/test_blend.png"); addChild(cloud, i+1, 100+i); cloud->setPosition(ccp(50+25*i, 80)); ccBlendFunc blendFunc1 = { GL_ONE, GL_ONE_MINUS_SRC_ALPHA }; @@ -1075,7 +1075,7 @@ void TextureBlend::onEnter() // CENTER sprites have also alpha pre-multiplied // they use by default GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA - cloud = CCSprite::spriteWithFile("Images/test_blend.png"); + cloud = CCSprite::create("Images/test_blend.png"); addChild(cloud, i+1, 200+i); cloud->setPosition(ccp(50+25*i, 160)); ccBlendFunc blendFunc2 = { GL_ONE_MINUS_DST_COLOR, GL_ZERO }; @@ -1083,7 +1083,7 @@ void TextureBlend::onEnter() // UPPER sprites are using custom blending function // You can set any blend function to your sprites - cloud = CCSprite::spriteWithFile("Images/test_blend.png"); + cloud = CCSprite::create("Images/test_blend.png"); addChild(cloud, i+1, 200+i); cloud->setPosition(ccp(50+25*i, 320-80)); ccBlendFunc blendFunc3 = { GL_SRC_ALPHA, GL_ONE }; @@ -1116,14 +1116,14 @@ void TextureAsync::onEnter() CCSize size =CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF *label = CCLabelTTF::labelWithString("Loading...", "Marker Felt", 32); + CCLabelTTF *label = CCLabelTTF::create("Loading...", "Marker Felt", 32); label->setPosition(ccp( size.width/2, size.height/2)); addChild(label, 10); - CCScaleBy* scale = CCScaleBy::actionWithDuration(0.3f, 2); + CCScaleBy* scale = CCScaleBy::create(0.3f, 2); CCScaleBy* scale_back = (CCScaleBy*)scale->reverse(); - CCSequence* seq = (CCSequence*)CCSequence::actions(scale, scale_back, NULL); - label->runAction(CCRepeatForever::actionWithAction(seq)); + CCSequence* seq = (CCSequence*)CCSequence::create(scale, scale_back, NULL); + label->runAction(CCRepeatForever::create(seq)); scheduleOnce(schedule_selector(TextureAsync::loadImages), 1.0f); } @@ -1162,7 +1162,7 @@ void TextureAsync::imageLoaded(CCObject* pObj) // This test just creates a sprite based on the Texture - CCSprite *sprite = CCSprite::spriteWithTexture(tex); + CCSprite *sprite = CCSprite::createWithTexture(tex); sprite->setAnchorPoint(ccp(0,0)); addChild(sprite, -1); @@ -1199,17 +1199,17 @@ void TextureGlClamp::onEnter() // The .png image MUST be power of 2 in order to create a continue effect. // eg: 32x64, 512x128, 256x1024, 64x64, etc.. - CCSprite *sprite = CCSprite::spriteWithFile("Images/pattern1.png", CCRectMake(0,0,512,256)); + CCSprite *sprite = CCSprite::create("Images/pattern1.png", CCRectMake(0,0,512,256)); addChild(sprite, -1, kTagSprite1); sprite->setPosition(ccp(size.width/2,size.height/2)); ccTexParams params = {GL_LINEAR,GL_LINEAR,GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE}; sprite->getTexture()->setTexParameters(¶ms); - CCRotateBy* rotate = CCRotateBy::actionWithDuration(4, 360); + CCRotateBy* rotate = CCRotateBy::create(4, 360); sprite->runAction(rotate); - CCScaleBy* scale = CCScaleBy::actionWithDuration(2, 0.04f); + CCScaleBy* scale = CCScaleBy::create(2, 0.04f); CCScaleBy* scaleBack = (CCScaleBy*) (scale->reverse()); - CCFiniteTimeAction* seq = CCSequence::actions(scale, scaleBack, NULL); + CCFiniteTimeAction* seq = CCSequence::create(scale, scaleBack, NULL); sprite->runAction(seq); } @@ -1236,17 +1236,17 @@ void TextureGlRepeat::onEnter() // The .png image MUST be power of 2 in order to create a continue effect. // eg: 32x64, 512x128, 256x1024, 64x64, etc.. - CCSprite *sprite = CCSprite::spriteWithFile("Images/pattern1.png", CCRectMake(0, 0, 4096, 4096)); + CCSprite *sprite = CCSprite::create("Images/pattern1.png", CCRectMake(0, 0, 4096, 4096)); addChild(sprite, -1, kTagSprite1); sprite->setPosition(ccp(size.width/2,size.height/2)); ccTexParams params = {GL_LINEAR,GL_LINEAR,GL_REPEAT,GL_REPEAT}; sprite->getTexture()->setTexParameters(¶ms); - CCRotateBy* rotate = CCRotateBy::actionWithDuration(4, 360); + CCRotateBy* rotate = CCRotateBy::create(4, 360); sprite->runAction(rotate); - CCScaleBy* scale = CCScaleBy::actionWithDuration(2, 0.04f); + CCScaleBy* scale = CCScaleBy::create(2, 0.04f); CCScaleBy* scaleBack = (CCScaleBy*) (scale->reverse()); - CCFiniteTimeAction* seq = CCSequence::actions(scale, scaleBack, NULL); + CCFiniteTimeAction* seq = CCSequence::create(scale, scaleBack, NULL); sprite->runAction(seq); } @@ -1271,28 +1271,28 @@ void TextureSizeTest::onEnter() CCSprite *sprite = NULL; CCLog("Loading 512x512 image..."); - sprite = CCSprite::spriteWithFile("Images/texture512x512.png"); + sprite = CCSprite::create("Images/texture512x512.png"); if( sprite ) CCLog("OK\n"); else CCLog("Error\n"); CCLog("Loading 1024x1024 image..."); - sprite = CCSprite::spriteWithFile("Images/texture1024x1024.png"); + sprite = CCSprite::create("Images/texture1024x1024.png"); if( sprite ) CCLog("OK\n"); else CCLog("Error\n"); // @todo // CCLog("Loading 2048x2048 image..."); -// sprite = CCSprite::spriteWithFile("Images/texture2048x2048.png"); +// sprite = CCSprite::create("Images/texture2048x2048.png"); // if( sprite ) // CCLog("OK\n"); // else // CCLog("Error\n"); // // CCLog("Loading 4096x4096 image..."); -// sprite = CCSprite::spriteWithFile("Images/texture4096x4096.png"); +// sprite = CCSprite::create("Images/texture4096x4096.png"); // if( sprite ) // CCLog("OK\n"); // else @@ -1322,7 +1322,7 @@ void TextureCache1::onEnter() CCSprite *sprite; - sprite = CCSprite::spriteWithFile("Images/grossinis_sister1.png"); + sprite = CCSprite::create("Images/grossinis_sister1.png"); sprite->setPosition(ccp(s.width/5*1, s.height/2)); sprite->getTexture()->setAliasTexParameters(); sprite->setScale(2); @@ -1330,7 +1330,7 @@ void TextureCache1::onEnter() CCTextureCache::sharedTextureCache()->removeTexture(sprite->getTexture()); - sprite = CCSprite::spriteWithFile("Images/grossinis_sister1.png"); + sprite = CCSprite::create("Images/grossinis_sister1.png"); sprite->setPosition(ccp(s.width/5*2, s.height/2)); sprite->getTexture()->setAntiAliasTexParameters(); sprite->setScale(2); @@ -1338,7 +1338,7 @@ void TextureCache1::onEnter() // 2nd set of sprites - sprite = CCSprite::spriteWithFile("Images/grossinis_sister2.png"); + sprite = CCSprite::create("Images/grossinis_sister2.png"); sprite->setPosition(ccp(s.width/5*3, s.height/2)); sprite->getTexture()->setAliasTexParameters(); sprite->setScale(2); @@ -1346,7 +1346,7 @@ void TextureCache1::onEnter() CCTextureCache::sharedTextureCache()->removeTextureForKey("Images/grossinis_sister2.png"); - sprite = CCSprite::spriteWithFile("Images/grossinis_sister2.png"); + sprite = CCSprite::create("Images/grossinis_sister2.png"); sprite->setPosition(ccp(s.width/5*4, s.height/2)); sprite->getTexture()->setAntiAliasTexParameters(); sprite->setScale(2); @@ -1468,29 +1468,29 @@ void TextureMemoryAlloc::onEnter() CCMenuItemFont::setFontSize(24); - CCMenuItem *item1 = CCMenuItemFont::itemWithString("PNG", this, menu_selector(TextureMemoryAlloc::updateImage)); + CCMenuItem *item1 = CCMenuItemFont::create("PNG", this, menu_selector(TextureMemoryAlloc::updateImage)); item1->setTag(0); - CCMenuItem *item2 = CCMenuItemFont::itemWithString("RGBA8", this, menu_selector(TextureMemoryAlloc::updateImage)); + CCMenuItem *item2 = CCMenuItemFont::create("RGBA8", this, menu_selector(TextureMemoryAlloc::updateImage)); item2->setTag(1); - CCMenuItem *item3 = CCMenuItemFont::itemWithString("RGB8", this, menu_selector(TextureMemoryAlloc::updateImage)); + CCMenuItem *item3 = CCMenuItemFont::create("RGB8", this, menu_selector(TextureMemoryAlloc::updateImage)); item3->setTag(2); - CCMenuItem *item4 = CCMenuItemFont::itemWithString("RGBA4", this, menu_selector(TextureMemoryAlloc::updateImage)); + CCMenuItem *item4 = CCMenuItemFont::create("RGBA4", this, menu_selector(TextureMemoryAlloc::updateImage)); item4->setTag(3); - CCMenuItem *item5 = CCMenuItemFont::itemWithString("A8", this, menu_selector(TextureMemoryAlloc::updateImage)); + CCMenuItem *item5 = CCMenuItemFont::create("A8", this, menu_selector(TextureMemoryAlloc::updateImage)); item5->setTag(4); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, item4, item5, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, item4, item5, NULL); menu->alignItemsHorizontally(); addChild(menu); - CCMenuItemFont *warmup = CCMenuItemFont::itemWithString("warm up texture", this, menu_selector(TextureMemoryAlloc::changeBackgroundVisible)); + CCMenuItemFont *warmup = CCMenuItemFont::create("warm up texture", this, menu_selector(TextureMemoryAlloc::changeBackgroundVisible)); - CCMenu *menu2 = CCMenu::menuWithItems(warmup, NULL); + CCMenu *menu2 = CCMenu::create(warmup, NULL); menu2->alignItemsHorizontally(); @@ -1538,7 +1538,7 @@ void TextureMemoryAlloc::updateImage(cocos2d::CCObject *sender) break; } - m_pBackground = CCSprite::spriteWithFile(file.c_str()); + m_pBackground = CCSprite::create(file.c_str()); addChild(m_pBackground, -10); m_pBackground->setIsVisible(false); diff --git a/tests/tests/TextureCacheTest/TextureCacheTest.cpp b/tests/tests/TextureCacheTest/TextureCacheTest.cpp index bb5d0a8ca0..848c4f4ec1 100644 --- a/tests/tests/TextureCacheTest/TextureCacheTest.cpp +++ b/tests/tests/TextureCacheTest/TextureCacheTest.cpp @@ -11,8 +11,8 @@ TextureCacheTest::TextureCacheTest() { CCSize size = CCDirector::sharedDirector()->getWinSize(); - m_pLabelLoading = CCLabelTTF::labelWithString("loading...", "Arial", 15); - m_pLabelPercent = CCLabelTTF::labelWithString("%0", "Arial", 15); + m_pLabelLoading = CCLabelTTF::create("loading...", "Arial", 15); + m_pLabelPercent = CCLabelTTF::create("%0", "Arial", 15); m_pLabelLoading->setPosition(CCPointMake(size.width / 2, size.height / 2 - 20)); m_pLabelPercent->setPosition(CCPointMake(size.width / 2, size.height / 2 + 20)); @@ -64,30 +64,30 @@ void TextureCacheTest::addSprite() // create sprites - CCSprite *bg = CCSprite::spriteWithFile("Images/HelloWorld.png"); + CCSprite *bg = CCSprite::create("Images/HelloWorld.png"); bg->setPosition(CCPointMake(size.width / 2, size.height / 2)); - CCSprite *s1 = CCSprite::spriteWithFile("Images/grossini.png"); - CCSprite *s2 = CCSprite::spriteWithFile("Images/grossini_dance_01.png"); - CCSprite *s3 = CCSprite::spriteWithFile("Images/grossini_dance_02.png"); - CCSprite *s4 = CCSprite::spriteWithFile("Images/grossini_dance_03.png"); - CCSprite *s5 = CCSprite::spriteWithFile("Images/grossini_dance_04.png"); - CCSprite *s6 = CCSprite::spriteWithFile("Images/grossini_dance_05.png"); - CCSprite *s7 = CCSprite::spriteWithFile("Images/grossini_dance_06.png"); - CCSprite *s8 = CCSprite::spriteWithFile("Images/grossini_dance_07.png"); - CCSprite *s9 = CCSprite::spriteWithFile("Images/grossini_dance_08.png"); - CCSprite *s10 = CCSprite::spriteWithFile("Images/grossini_dance_09.png"); - CCSprite *s11 = CCSprite::spriteWithFile("Images/grossini_dance_10.png"); - CCSprite *s12 = CCSprite::spriteWithFile("Images/grossini_dance_11.png"); - CCSprite *s13 = CCSprite::spriteWithFile("Images/grossini_dance_12.png"); - CCSprite *s14 = CCSprite::spriteWithFile("Images/grossini_dance_13.png"); - CCSprite *s15 = CCSprite::spriteWithFile("Images/grossini_dance_14.png"); + CCSprite *s1 = CCSprite::create("Images/grossini.png"); + CCSprite *s2 = CCSprite::create("Images/grossini_dance_01.png"); + CCSprite *s3 = CCSprite::create("Images/grossini_dance_02.png"); + CCSprite *s4 = CCSprite::create("Images/grossini_dance_03.png"); + CCSprite *s5 = CCSprite::create("Images/grossini_dance_04.png"); + CCSprite *s6 = CCSprite::create("Images/grossini_dance_05.png"); + CCSprite *s7 = CCSprite::create("Images/grossini_dance_06.png"); + CCSprite *s8 = CCSprite::create("Images/grossini_dance_07.png"); + CCSprite *s9 = CCSprite::create("Images/grossini_dance_08.png"); + CCSprite *s10 = CCSprite::create("Images/grossini_dance_09.png"); + CCSprite *s11 = CCSprite::create("Images/grossini_dance_10.png"); + CCSprite *s12 = CCSprite::create("Images/grossini_dance_11.png"); + CCSprite *s13 = CCSprite::create("Images/grossini_dance_12.png"); + CCSprite *s14 = CCSprite::create("Images/grossini_dance_13.png"); + CCSprite *s15 = CCSprite::create("Images/grossini_dance_14.png"); // just loading textures to slow down - CCSprite::spriteWithFile("Images/background1.png"); - CCSprite::spriteWithFile("Images/background2.png"); - CCSprite::spriteWithFile("Images/background3.png"); - CCSprite::spriteWithFile("Images/blocks.png"); + CCSprite::create("Images/background1.png"); + CCSprite::create("Images/background2.png"); + CCSprite::create("Images/background3.png"); + CCSprite::create("Images/blocks.png"); s1->setPosition(CCPointMake(50, 50)); s2->setPosition(CCPointMake(60, 50)); diff --git a/tests/tests/TileMapTest/TileMapTest.cpp b/tests/tests/TileMapTest/TileMapTest.cpp index 0a608a6e5f..4cd79dabdc 100644 --- a/tests/tests/TileMapTest/TileMapTest.cpp +++ b/tests/tests/TileMapTest/TileMapTest.cpp @@ -17,7 +17,7 @@ CCLayer* restartTileMapAction(); //------------------------------------------------------------------ TileMapTest::TileMapTest() { - CCTileMapAtlas* map = CCTileMapAtlas::tileMapAtlasWithTileFile(s_TilesPng, s_LevelMapTga, 16, 16); + CCTileMapAtlas* map = CCTileMapAtlas::create(s_TilesPng, s_LevelMapTga, 16, 16); // Convert it to "alias" (GL_LINEAR filtering) map->getTexture()->setAntiAliasTexParameters(); @@ -32,12 +32,12 @@ TileMapTest::TileMapTest() map->setAnchorPoint( ccp(0, 0.5f) ); - CCScaleBy *scale = CCScaleBy::actionWithDuration(4, 0.8f); + CCScaleBy *scale = CCScaleBy::create(4, 0.8f); CCActionInterval *scaleBack = scale->reverse(); - CCFiniteTimeAction* seq = CCSequence::actions(scale, scaleBack, NULL); + CCFiniteTimeAction* seq = CCSequence::create(scale, scaleBack, NULL); - map->runAction(CCRepeatForever::actionWithAction((CCActionInterval *)seq)); + map->runAction(CCRepeatForever::create((CCActionInterval *)seq)); } std::string TileMapTest::title() @@ -52,7 +52,7 @@ std::string TileMapTest::title() //------------------------------------------------------------------ TileMapEditTest::TileMapEditTest() { - CCTileMapAtlas* map = CCTileMapAtlas::tileMapAtlasWithTileFile(s_TilesPng, s_LevelMapTga, 16, 16); + CCTileMapAtlas* map = CCTileMapAtlas::create(s_TilesPng, s_LevelMapTga, 16, 16); // Create an Aliased Atlas map->getTexture()->setAliasTexParameters(); @@ -119,10 +119,10 @@ TMXOrthoTest::TMXOrthoTest() // // it should not flicker. No artifacts should appear // - //CCLayerColor* color = CCLayerColor::layerWithColor( ccc4(64,64,64,255) ); + //CCLayerColor* color = CCLayerColor::create( ccc4(64,64,64,255) ); //addChild(color, -1); - CCTMXTiledMap* map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/orthogonal-test2.tmx"); + CCTMXTiledMap* map = CCTMXTiledMap::create("TileMaps/orthogonal-test2.tmx"); addChild(map, 0, kTagTileMap); CCSize s = map->getContentSize(); @@ -171,7 +171,7 @@ std::string TMXOrthoTest::title() //------------------------------------------------------------------ TMXOrthoTest2::TMXOrthoTest2() { - CCTMXTiledMap* map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/orthogonal-test1.tmx"); + CCTMXTiledMap* map = CCTMXTiledMap::create("TileMaps/orthogonal-test1.tmx"); addChild(map, 0, kTagTileMap); CCSize s = map->getContentSize(); @@ -190,7 +190,7 @@ TMXOrthoTest2::TMXOrthoTest2() child->getTexture()->setAntiAliasTexParameters(); } - map->runAction( CCScaleBy::actionWithDuration(2, 0.5f) ) ; + map->runAction( CCScaleBy::create(2, 0.5f) ) ; } std::string TMXOrthoTest2::title() @@ -205,7 +205,7 @@ std::string TMXOrthoTest2::title() //------------------------------------------------------------------ TMXOrthoTest3::TMXOrthoTest3() { - CCTMXTiledMap *map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/orthogonal-test3.tmx"); + CCTMXTiledMap *map = CCTMXTiledMap::create("TileMaps/orthogonal-test3.tmx"); addChild(map, 0, kTagTileMap); CCSize s = map->getContentSize(); @@ -240,7 +240,7 @@ std::string TMXOrthoTest3::title() //------------------------------------------------------------------ TMXOrthoTest4::TMXOrthoTest4() { - CCTMXTiledMap *map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/orthogonal-test4.tmx"); + CCTMXTiledMap *map = CCTMXTiledMap::create("TileMaps/orthogonal-test4.tmx"); addChild(map, 0, kTagTileMap); CCSize s1 = map->getContentSize(); @@ -311,7 +311,7 @@ TMXReadWriteTest::TMXReadWriteTest() { m_gid = 0; - CCTMXTiledMap* map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/orthogonal-test2.tmx"); + CCTMXTiledMap* map = CCTMXTiledMap::create("TileMaps/orthogonal-test2.tmx"); addChild(map, 0, kTagTileMap); CCSize s = map->getContentSize(); @@ -332,14 +332,14 @@ TMXReadWriteTest::TMXReadWriteTest() tile2->setAnchorPoint( ccp(0.5f, 0.5f) ); tile3->setAnchorPoint( ccp(0.5f, 0.5f) ); - CCActionInterval* move = CCMoveBy::actionWithDuration(0.5f, ccp(0,160)); - CCActionInterval* rotate = CCRotateBy::actionWithDuration(2, 360); - CCActionInterval* scale = CCScaleBy::actionWithDuration(2, 5); - CCActionInterval* opacity = CCFadeOut::actionWithDuration(2); - CCActionInterval* fadein = CCFadeIn::actionWithDuration(2); - CCActionInterval* scaleback = CCScaleTo::actionWithDuration(1, 1); - CCActionInstant* finish = CCCallFuncN::actionWithTarget(this, callfuncN_selector(TMXReadWriteTest::removeSprite)); - CCFiniteTimeAction* seq0 = CCSequence::actions(move, rotate, scale, opacity, fadein, scaleback, finish, NULL); + CCActionInterval* move = CCMoveBy::create(0.5f, ccp(0,160)); + CCActionInterval* rotate = CCRotateBy::create(2, 360); + CCActionInterval* scale = CCScaleBy::create(2, 5); + CCActionInterval* opacity = CCFadeOut::create(2); + CCActionInterval* fadein = CCFadeIn::create(2); + CCActionInterval* scaleback = CCScaleTo::create(1, 1); + CCActionInstant* finish = CCCallFuncN::create(this, callfuncN_selector(TMXReadWriteTest::removeSprite)); + CCFiniteTimeAction* seq0 = CCSequence::create(move, rotate, scale, opacity, fadein, scaleback, finish, NULL); CCActionInterval* seq1 = (CCActionInterval*)(seq0->copy()->autorelease()); CCActionInterval* seq2 = (CCActionInterval*)(seq0->copy()->autorelease()); CCActionInterval* seq3 = (CCActionInterval*)(seq0->copy()->autorelease()); @@ -439,10 +439,10 @@ std::string TMXReadWriteTest::title() //------------------------------------------------------------------ TMXHexTest::TMXHexTest() { - CCLayerColor* color = CCLayerColor::layerWithColor( ccc4(64,64,64,255) ); + CCLayerColor* color = CCLayerColor::create( ccc4(64,64,64,255) ); addChild(color, -1); - CCTMXTiledMap* map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/hexa-test.tmx"); + CCTMXTiledMap* map = CCTMXTiledMap::create("TileMaps/hexa-test.tmx"); addChild(map, 0, kTagTileMap); CCSize s = map->getContentSize(); @@ -461,16 +461,16 @@ std::string TMXHexTest::title() //------------------------------------------------------------------ TMXIsoTest::TMXIsoTest() { - CCLayerColor* color = CCLayerColor::layerWithColor( ccc4(64,64,64,255) ); + CCLayerColor* color = CCLayerColor::create( ccc4(64,64,64,255) ); addChild(color, -1); - CCTMXTiledMap* map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/iso-test.tmx"); + CCTMXTiledMap* map = CCTMXTiledMap::create("TileMaps/iso-test.tmx"); addChild(map, 0, kTagTileMap); // move map to the center of the screen CCSize ms = map->getMapSize(); CCSize ts = map->getTileSize(); - map->runAction( CCMoveTo::actionWithDuration(1.0f, ccp( -ms.width * ts.width/2, -ms.height * ts.height/2 )) ); + map->runAction( CCMoveTo::create(1.0f, ccp( -ms.width * ts.width/2, -ms.height * ts.height/2 )) ); } std::string TMXIsoTest::title() @@ -485,10 +485,10 @@ std::string TMXIsoTest::title() //------------------------------------------------------------------ TMXIsoTest1::TMXIsoTest1() { - CCLayerColor* color = CCLayerColor::layerWithColor( ccc4(64,64,64,255) ); + CCLayerColor* color = CCLayerColor::create( ccc4(64,64,64,255) ); addChild(color, -1); - CCTMXTiledMap *map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/iso-test1.tmx"); + CCTMXTiledMap *map = CCTMXTiledMap::create("TileMaps/iso-test1.tmx"); addChild(map, 0, kTagTileMap); CCSize s = map->getContentSize(); @@ -509,10 +509,10 @@ std::string TMXIsoTest1::title() //------------------------------------------------------------------ TMXIsoTest2::TMXIsoTest2() { - CCLayerColor* color = CCLayerColor::layerWithColor( ccc4(64,64,64,255) ); + CCLayerColor* color = CCLayerColor::create( ccc4(64,64,64,255) ); addChild(color, -1); - CCTMXTiledMap *map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/iso-test2.tmx"); + CCTMXTiledMap *map = CCTMXTiledMap::create("TileMaps/iso-test2.tmx"); addChild(map, 0, kTagTileMap); CCSize s = map->getContentSize(); @@ -521,7 +521,7 @@ TMXIsoTest2::TMXIsoTest2() // move map to the center of the screen CCSize ms = map->getMapSize(); CCSize ts = map->getTileSize(); - map->runAction( CCMoveTo::actionWithDuration(1.0f, ccp( -ms.width * ts.width/2, -ms.height * ts.height/2 ) )); + map->runAction( CCMoveTo::create(1.0f, ccp( -ms.width * ts.width/2, -ms.height * ts.height/2 ) )); } std::string TMXIsoTest2::title() @@ -536,10 +536,10 @@ std::string TMXIsoTest2::title() //------------------------------------------------------------------ TMXUncompressedTest::TMXUncompressedTest() { - CCLayerColor* color = CCLayerColor::layerWithColor( ccc4(64,64,64,255) ); + CCLayerColor* color = CCLayerColor::create( ccc4(64,64,64,255) ); addChild(color, -1); - CCTMXTiledMap *map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/iso-test2-uncompressed.tmx"); + CCTMXTiledMap *map = CCTMXTiledMap::create("TileMaps/iso-test2-uncompressed.tmx"); addChild(map, 0, kTagTileMap); CCSize s = map->getContentSize(); @@ -548,7 +548,7 @@ TMXUncompressedTest::TMXUncompressedTest() // move map to the center of the screen CCSize ms = map->getMapSize(); CCSize ts = map->getTileSize(); - map->runAction(CCMoveTo::actionWithDuration(1.0f, ccp( -ms.width * ts.width/2, -ms.height * ts.height/2 ) )); + map->runAction(CCMoveTo::create(1.0f, ccp( -ms.width * ts.width/2, -ms.height * ts.height/2 ) )); // testing release map CCArray* pChildrenArray = map->getChildren(); @@ -578,7 +578,7 @@ std::string TMXUncompressedTest::title() //------------------------------------------------------------------ TMXTilesetTest::TMXTilesetTest() { - CCTMXTiledMap *map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/orthogonal-test5.tmx"); + CCTMXTiledMap *map = CCTMXTiledMap::create("TileMaps/orthogonal-test5.tmx"); addChild(map, 0, kTagTileMap); CCSize s = map->getContentSize(); @@ -607,7 +607,7 @@ std::string TMXTilesetTest::title() //------------------------------------------------------------------ TMXOrthoObjectsTest::TMXOrthoObjectsTest() { - CCTMXTiledMap *map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/ortho-objects.tmx"); + CCTMXTiledMap *map = CCTMXTiledMap::create("TileMaps/ortho-objects.tmx"); addChild(map, -1, kTagTileMap); CCSize s = map->getContentSize(); @@ -687,7 +687,7 @@ std::string TMXOrthoObjectsTest::subtitle() TMXIsoObjectsTest::TMXIsoObjectsTest() { - CCTMXTiledMap* map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/iso-test-objectgroup.tmx"); + CCTMXTiledMap* map = CCTMXTiledMap::create("TileMaps/iso-test-objectgroup.tmx"); addChild(map, -1, kTagTileMap); CCSize s = map->getContentSize(); @@ -764,7 +764,7 @@ std::string TMXIsoObjectsTest::subtitle() TMXResizeTest::TMXResizeTest() { - CCTMXTiledMap* map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/orthogonal-test5.tmx"); + CCTMXTiledMap* map = CCTMXTiledMap::create("TileMaps/orthogonal-test5.tmx"); addChild(map, 0, kTagTileMap); CCSize s = map->getContentSize(); @@ -801,14 +801,14 @@ std::string TMXResizeTest::subtitle() //------------------------------------------------------------------ TMXIsoZorder::TMXIsoZorder() { - CCTMXTiledMap *map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/iso-test-zorder.tmx"); + CCTMXTiledMap *map = CCTMXTiledMap::create("TileMaps/iso-test-zorder.tmx"); addChild(map, 0, kTagTileMap); CCSize s = map->getContentSize(); CCLOG("ContentSize: %f, %f", s.width,s.height); map->setPosition(ccp(-s.width/2,0)); - m_tamara = CCSprite::spriteWithFile(s_pPathSister1); + m_tamara = CCSprite::create(s_pPathSister1); map->addChild(m_tamara, map->getChildren()->count() ); m_tamara->retain(); int mapWidth = map->getMapSize().width * map->getTileSize().width; @@ -816,10 +816,10 @@ TMXIsoZorder::TMXIsoZorder() m_tamara->setAnchorPoint(ccp(0.5f,0)); - CCActionInterval* move = CCMoveBy::actionWithDuration(10, ccp(300,250)); + CCActionInterval* move = CCMoveBy::create(10, ccp(300,250)); CCActionInterval* back = move->reverse(); - CCFiniteTimeAction* seq = CCSequence::actions(move, back,NULL); - m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*) seq) ); + CCFiniteTimeAction* seq = CCSequence::create(move, back,NULL); + m_tamara->runAction( CCRepeatForever::create((CCActionInterval*) seq) ); schedule( schedule_selector(TMXIsoZorder::repositionSprite) ); } @@ -870,22 +870,22 @@ std::string TMXIsoZorder::subtitle() //------------------------------------------------------------------ TMXOrthoZorder::TMXOrthoZorder() { - CCTMXTiledMap *map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/orthogonal-test-zorder.tmx"); + CCTMXTiledMap *map = CCTMXTiledMap::create("TileMaps/orthogonal-test-zorder.tmx"); addChild(map, 0, kTagTileMap); CCSize s = map->getContentSize(); ////----UXLOG("ContentSize: %f, %f", s.width,s.height); - m_tamara = CCSprite::spriteWithFile(s_pPathSister1); + m_tamara = CCSprite::create(s_pPathSister1); map->addChild(m_tamara, map->getChildren()->count()); m_tamara->retain(); m_tamara->setAnchorPoint(ccp(0.5f,0)); - CCActionInterval* move = CCMoveBy::actionWithDuration(10, ccp(400,450)); + CCActionInterval* move = CCMoveBy::create(10, ccp(400,450)); CCActionInterval* back = move->reverse(); - CCFiniteTimeAction* seq = CCSequence::actions(move, back,NULL); - m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq)); + CCFiniteTimeAction* seq = CCSequence::create(move, back,NULL); + m_tamara->runAction( CCRepeatForever::create((CCActionInterval*)seq)); schedule( schedule_selector(TMXOrthoZorder::repositionSprite)); } @@ -931,7 +931,7 @@ std::string TMXOrthoZorder::subtitle() //------------------------------------------------------------------ TMXIsoVertexZ::TMXIsoVertexZ() { - CCTMXTiledMap *map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/iso-test-vertexz.tmx"); + CCTMXTiledMap *map = CCTMXTiledMap::create("TileMaps/iso-test-vertexz.tmx"); addChild(map, 0, kTagTileMap); CCSize s = map->getContentSize(); @@ -944,10 +944,10 @@ TMXIsoVertexZ::TMXIsoVertexZ() m_tamara = layer->tileAt( ccp(29,29) ); m_tamara->retain(); - CCActionInterval* move = CCMoveBy::actionWithDuration(10, ccpMult( ccp(300,250), 1/CC_CONTENT_SCALE_FACTOR() ) ); + CCActionInterval* move = CCMoveBy::create(10, ccpMult( ccp(300,250), 1/CC_CONTENT_SCALE_FACTOR() ) ); CCActionInterval* back = move->reverse(); - CCFiniteTimeAction* seq = CCSequence::actions(move, back,NULL); - m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*) seq) ); + CCFiniteTimeAction* seq = CCSequence::create(move, back,NULL); + m_tamara->runAction( CCRepeatForever::create((CCActionInterval*) seq) ); schedule( schedule_selector(TMXIsoVertexZ::repositionSprite)); @@ -1001,7 +1001,7 @@ std::string TMXIsoVertexZ::subtitle() //------------------------------------------------------------------ TMXOrthoVertexZ::TMXOrthoVertexZ() { - CCTMXTiledMap *map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/orthogonal-test-vertexz.tmx"); + CCTMXTiledMap *map = CCTMXTiledMap::create("TileMaps/orthogonal-test-vertexz.tmx"); addChild(map, 0, kTagTileMap); CCSize s = map->getContentSize(); @@ -1014,10 +1014,10 @@ TMXOrthoVertexZ::TMXOrthoVertexZ() CCLOG("%p vertexZ: %f", m_tamara, m_tamara->getVertexZ()); m_tamara->retain(); - CCActionInterval* move = CCMoveBy::actionWithDuration(10, ccpMult( ccp(400,450), 1/CC_CONTENT_SCALE_FACTOR())); + CCActionInterval* move = CCMoveBy::create(10, ccpMult( ccp(400,450), 1/CC_CONTENT_SCALE_FACTOR())); CCActionInterval* back = move->reverse(); - CCFiniteTimeAction* seq = CCSequence::actions(move, back,NULL); - m_tamara->runAction( CCRepeatForever::actionWithAction((CCActionInterval*)seq)); + CCFiniteTimeAction* seq = CCSequence::create(move, back,NULL); + m_tamara->runAction( CCRepeatForever::create((CCActionInterval*)seq)); schedule(schedule_selector(TMXOrthoVertexZ::repositionSprite)); @@ -1070,7 +1070,7 @@ std::string TMXOrthoVertexZ::subtitle() //------------------------------------------------------------------ TMXIsoMoveLayer::TMXIsoMoveLayer() { - CCTMXTiledMap* map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/iso-test-movelayer.tmx"); + CCTMXTiledMap* map = CCTMXTiledMap::create("TileMaps/iso-test-movelayer.tmx"); addChild(map, 0, kTagTileMap); map->setPosition(ccp(-700,-50)); @@ -1097,7 +1097,7 @@ std::string TMXIsoMoveLayer::subtitle() //------------------------------------------------------------------ TMXOrthoMoveLayer::TMXOrthoMoveLayer() { - CCTMXTiledMap *map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/orthogonal-test-movelayer.tmx"); + CCTMXTiledMap *map = CCTMXTiledMap::create("TileMaps/orthogonal-test-movelayer.tmx"); addChild(map, 0, kTagTileMap); CCSize s = map->getContentSize(); @@ -1122,7 +1122,7 @@ std::string TMXOrthoMoveLayer::subtitle() TMXTilePropertyTest::TMXTilePropertyTest() { - CCTMXTiledMap *map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/ortho-tile-property.tmx"); + CCTMXTiledMap *map = CCTMXTiledMap::create("TileMaps/ortho-tile-property.tmx"); addChild(map ,0 ,kTagTileMap); for(int i=1;i<=20;i++){ @@ -1148,7 +1148,7 @@ std::string TMXTilePropertyTest::subtitle() TMXOrthoFlipTest::TMXOrthoFlipTest() { - CCTMXTiledMap *map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/ortho-rotation-test.tmx"); + CCTMXTiledMap *map = CCTMXTiledMap::create("TileMaps/ortho-rotation-test.tmx"); addChild(map, 0, kTagTileMap); CCSize s = map->getContentSize(); @@ -1161,7 +1161,7 @@ TMXOrthoFlipTest::TMXOrthoFlipTest() child->getTexture()->setAntiAliasTexParameters(); } - CCScaleBy* action = CCScaleBy::actionWithDuration(2, 0.5f); + CCScaleBy* action = CCScaleBy::create(2, 0.5f); map->runAction(action); } @@ -1178,7 +1178,7 @@ std::string TMXOrthoFlipTest::title() TMXOrthoFlipRunTimeTest::TMXOrthoFlipRunTimeTest() { - CCTMXTiledMap *map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/ortho-rotation-test.tmx"); + CCTMXTiledMap *map = CCTMXTiledMap::create("TileMaps/ortho-rotation-test.tmx"); addChild(map, 0, kTagTileMap); CCSize s = map->getContentSize(); @@ -1191,7 +1191,7 @@ TMXOrthoFlipRunTimeTest::TMXOrthoFlipRunTimeTest() child->getTexture()->setAntiAliasTexParameters(); } - CCScaleBy* action = CCScaleBy::actionWithDuration(2, 0.5f); + CCScaleBy* action = CCScaleBy::create(2, 0.5f); map->runAction(action); schedule(schedule_selector(TMXOrthoFlipRunTimeTest::flipIt), 1.0f); @@ -1257,7 +1257,7 @@ TMXOrthoFromXMLTest::TMXOrthoFromXMLTest() CCString* str = CCString::stringWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(file.c_str())); CCAssert(str != NULL, "Unable to open file"); - CCTMXTiledMap *map = CCTMXTiledMap::tiledMapWithXML(str->getCString() ,resources.c_str()); + CCTMXTiledMap *map = CCTMXTiledMap::create(str->getCString() ,resources.c_str()); addChild(map, 0, kTagTileMap); CCSize s = map->getContentSize(); @@ -1270,7 +1270,7 @@ TMXOrthoFromXMLTest::TMXOrthoFromXMLTest() child->getTexture()->setAntiAliasTexParameters(); } - CCScaleBy* action = CCScaleBy::actionWithDuration(2, 0.5f); + CCScaleBy* action = CCScaleBy::create(2, 0.5f); map->runAction(action); } @@ -1286,7 +1286,7 @@ std::string TMXOrthoFromXMLTest::title() //------------------------------------------------------------------ TMXBug987::TMXBug987() { - CCTMXTiledMap *map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/orthogonal-test6.tmx"); + CCTMXTiledMap *map = CCTMXTiledMap::create("TileMaps/orthogonal-test6.tmx"); addChild(map, 0, kTagTileMap); CCSize s1 = map->getContentSize(); @@ -1324,7 +1324,7 @@ std::string TMXBug987::subtitle() //------------------------------------------------------------------ TMXBug787::TMXBug787() { - CCTMXTiledMap *map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/iso-test-bug787.tmx"); + CCTMXTiledMap *map = CCTMXTiledMap::create("TileMaps/iso-test-bug787.tmx"); addChild(map, 0, kTagTileMap); map->setScale(0.25f); @@ -1433,7 +1433,7 @@ TileDemo::TileDemo(void) CCSize s = CCDirector::sharedDirector()->getWinSize(); - m_label = CCLabelTTF::labelWithString("", "Arial", 28); + m_label = CCLabelTTF::create("", "Arial", 28); addChild(m_label, 1); m_label->setPosition( ccp(s.width/2, s.height-50) ); m_label->retain(); @@ -1441,7 +1441,7 @@ TileDemo::TileDemo(void) std::string strSubtitle = subtitle(); if( ! strSubtitle.empty() ) { - CCLabelTTF* l = CCLabelTTF::labelWithString(strSubtitle.c_str(), "Thonburi", 16); + CCLabelTTF* l = CCLabelTTF::create(strSubtitle.c_str(), "Thonburi", 16); addChild(l, 1); l->setPosition( ccp(s.width/2, s.height-80) ); @@ -1449,11 +1449,11 @@ TileDemo::TileDemo(void) m_subtitle->retain(); } - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(TileDemo::backCallback) ); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(TileDemo::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(TileDemo::nextCallback) ); + CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(TileDemo::backCallback) ); + CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(TileDemo::restartCallback) ); + CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(TileDemo::nextCallback) ); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition( CCPointZero ); item1->setPosition( ccp( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2) ); @@ -1561,7 +1561,7 @@ void TileMapTestScene::runThisTest() TMXGIDObjectsTest::TMXGIDObjectsTest() { - CCTMXTiledMap *map = CCTMXTiledMap::tiledMapWithTMXFile("TileMaps/test-object-layer.tmx"); + CCTMXTiledMap *map = CCTMXTiledMap::create("TileMaps/test-object-layer.tmx"); addChild(map, -1, kTagTileMap); CCSize s = map->getContentSize(); diff --git a/tests/tests/TouchesTest/TouchesTest.cpp b/tests/tests/TouchesTest/TouchesTest.cpp index ad97c1d64d..fd34bb4f12 100644 --- a/tests/tests/TouchesTest/TouchesTest.cpp +++ b/tests/tests/TouchesTest/TouchesTest.cpp @@ -25,7 +25,7 @@ enum //------------------------------------------------------------------ PongScene::PongScene() { - PongLayer *pongLayer = new PongLayer();//PongLayer::node(); + PongLayer *pongLayer = new PongLayer();//PongLayer::create(); addChild(pongLayer); pongLayer->release(); } diff --git a/tests/tests/TransitionsTest/TransitionsTest.cpp b/tests/tests/TransitionsTest/TransitionsTest.cpp index d7060a888a..d7e7c0297f 100644 --- a/tests/tests/TransitionsTest/TransitionsTest.cpp +++ b/tests/tests/TransitionsTest/TransitionsTest.cpp @@ -7,90 +7,90 @@ class FadeWhiteTransition : public CCTransitionFade { public: - static CCTransitionScene* transitionWithDuration(float t, CCScene* s) + static CCTransitionScene* create(float t, CCScene* s) { - return CCTransitionFade::transitionWithDuration(t, s, ccWHITE); + return CCTransitionFade::create(t, s, ccWHITE); } }; class FlipXLeftOver : public CCTransitionFlipX { public: - static CCTransitionScene* transitionWithDuration(float t, CCScene* s) + static CCTransitionScene* create(float t, CCScene* s) { - return CCTransitionFlipX::transitionWithDuration(t, s, kOrientationLeftOver); + return CCTransitionFlipX::create(t, s, kOrientationLeftOver); } }; class FlipXRightOver : public CCTransitionFlipX { public: - static CCTransitionScene* transitionWithDuration(float t, CCScene* s) + static CCTransitionScene* create(float t, CCScene* s) { - return CCTransitionFlipX::transitionWithDuration(t, s, kOrientationRightOver); + return CCTransitionFlipX::create(t, s, kOrientationRightOver); } }; class FlipYUpOver : public CCTransitionFlipY { public: - static CCTransitionScene* transitionWithDuration(float t, CCScene* s) + static CCTransitionScene* create(float t, CCScene* s) { - return CCTransitionFlipY::transitionWithDuration(t, s, kOrientationUpOver); + return CCTransitionFlipY::create(t, s, kOrientationUpOver); } }; class FlipYDownOver : public CCTransitionFlipY { public: - static CCTransitionScene* transitionWithDuration(float t, CCScene* s) + static CCTransitionScene* create(float t, CCScene* s) { - return CCTransitionFlipY::transitionWithDuration(t, s, kOrientationDownOver); + return CCTransitionFlipY::create(t, s, kOrientationDownOver); } }; class FlipAngularLeftOver : public CCTransitionFlipAngular { public: - static CCTransitionScene* transitionWithDuration(float t, CCScene* s) + static CCTransitionScene* create(float t, CCScene* s) { - return CCTransitionFlipAngular::transitionWithDuration(t, s, kOrientationLeftOver); + return CCTransitionFlipAngular::create(t, s, kOrientationLeftOver); } }; class FlipAngularRightOver : public CCTransitionFlipAngular { public: - static CCTransitionScene* transitionWithDuration(float t, CCScene* s) + static CCTransitionScene* create(float t, CCScene* s) { - return CCTransitionFlipAngular::transitionWithDuration(t, s, kOrientationRightOver); + return CCTransitionFlipAngular::create(t, s, kOrientationRightOver); } }; class ZoomFlipXLeftOver : public CCTransitionZoomFlipX { public: - static CCTransitionScene* transitionWithDuration(float t, CCScene* s) + static CCTransitionScene* create(float t, CCScene* s) { - return CCTransitionZoomFlipX::transitionWithDuration(t, s, kOrientationLeftOver); + return CCTransitionZoomFlipX::create(t, s, kOrientationLeftOver); } }; class ZoomFlipXRightOver : public CCTransitionZoomFlipX { public: - static CCTransitionScene* transitionWithDuration(float t, CCScene* s) + static CCTransitionScene* create(float t, CCScene* s) { - return CCTransitionZoomFlipX::transitionWithDuration(t, s, kOrientationRightOver); + return CCTransitionZoomFlipX::create(t, s, kOrientationRightOver); } }; class ZoomFlipYUpOver : public CCTransitionZoomFlipY { public: - static CCTransitionScene* transitionWithDuration(float t, CCScene* s) + static CCTransitionScene* create(float t, CCScene* s) { - return CCTransitionZoomFlipY::transitionWithDuration(t, s, kOrientationUpOver); + return CCTransitionZoomFlipY::create(t, s, kOrientationUpOver); } }; @@ -98,47 +98,47 @@ public: class ZoomFlipYDownOver : public CCTransitionZoomFlipY { public: - static CCTransitionScene* transitionWithDuration(float t, CCScene* s) + static CCTransitionScene* create(float t, CCScene* s) { - return CCTransitionZoomFlipY::transitionWithDuration(t, s, kOrientationDownOver); + return CCTransitionZoomFlipY::create(t, s, kOrientationDownOver); } }; class ZoomFlipAngularLeftOver : public CCTransitionZoomFlipAngular { public: - static CCTransitionScene* transitionWithDuration(float t, CCScene* s) + static CCTransitionScene* create(float t, CCScene* s) { - return CCTransitionZoomFlipAngular::transitionWithDuration(t, s, kOrientationLeftOver); + return CCTransitionZoomFlipAngular::create(t, s, kOrientationLeftOver); } }; class ZoomFlipAngularRightOver : public CCTransitionZoomFlipAngular { public: - static CCTransitionScene* transitionWithDuration(float t, CCScene* s) + static CCTransitionScene* create(float t, CCScene* s) { - return CCTransitionZoomFlipAngular::transitionWithDuration(t, s, kOrientationRightOver); + return CCTransitionZoomFlipAngular::create(t, s, kOrientationRightOver); } }; class PageTransitionForward : public CCTransitionPageTurn { public: - static CCTransitionScene* transitionWithDuration(float t, CCScene* s) + static CCTransitionScene* create(float t, CCScene* s) { CCDirector::sharedDirector()->setDepthTest(true); - return CCTransitionPageTurn::transitionWithDuration(t, s, false); + return CCTransitionPageTurn::create(t, s, false); } }; class PageTransitionBackward : public CCTransitionPageTurn { public: - static CCTransitionScene* transitionWithDuration(float t, CCScene* s) + static CCTransitionScene* create(float t, CCScene* s) { CCDirector::sharedDirector()->setDepthTest(true); - return CCTransitionPageTurn::transitionWithDuration(t, s, true); + return CCTransitionPageTurn::create(t, s, true); } }; @@ -205,58 +205,58 @@ CCTransitionScene* createTransition(int nIndex, float t, CCScene* s) switch(nIndex) { - case 0: return CCTransitionJumpZoom::transitionWithDuration(t, s); + case 0: return CCTransitionJumpZoom::create(t, s); - case 1: return CCTransitionProgressRadialCCW::transitionWithDuration(t, s); - case 2: return CCTransitionProgressRadialCW::transitionWithDuration(t, s); - case 3: return CCTransitionProgressHorizontal::transitionWithDuration(t, s); - case 4: return CCTransitionProgressVertical::transitionWithDuration(t, s); - case 5: return CCTransitionProgressInOut::transitionWithDuration(t, s); - case 6: return CCTransitionProgressOutIn::transitionWithDuration(t, s); + case 1: return CCTransitionProgressRadialCCW::create(t, s); + case 2: return CCTransitionProgressRadialCW::create(t, s); + case 3: return CCTransitionProgressHorizontal::create(t, s); + case 4: return CCTransitionProgressVertical::create(t, s); + case 5: return CCTransitionProgressInOut::create(t, s); + case 6: return CCTransitionProgressOutIn::create(t, s); - case 7: return CCTransitionCrossFade::transitionWithDuration(t,s); + case 7: return CCTransitionCrossFade::create(t,s); - case 8: return PageTransitionForward::transitionWithDuration(t, s); - case 9: return PageTransitionBackward::transitionWithDuration(t, s); - case 10: return CCTransitionFadeTR::transitionWithDuration(t, s); - case 11: return CCTransitionFadeBL::transitionWithDuration(t, s); - case 12: return CCTransitionFadeUp::transitionWithDuration(t, s); - case 13: return CCTransitionFadeDown::transitionWithDuration(t, s); + case 8: return PageTransitionForward::create(t, s); + case 9: return PageTransitionBackward::create(t, s); + case 10: return CCTransitionFadeTR::create(t, s); + case 11: return CCTransitionFadeBL::create(t, s); + case 12: return CCTransitionFadeUp::create(t, s); + case 13: return CCTransitionFadeDown::create(t, s); - case 14: return CCTransitionTurnOffTiles::transitionWithDuration(t, s); + case 14: return CCTransitionTurnOffTiles::create(t, s); - case 15: return CCTransitionSplitRows::transitionWithDuration(t, s); - case 16: return CCTransitionSplitCols::transitionWithDuration(t, s); + case 15: return CCTransitionSplitRows::create(t, s); + case 16: return CCTransitionSplitCols::create(t, s); - case 17: return CCTransitionFade::transitionWithDuration(t, s); - case 18: return FadeWhiteTransition::transitionWithDuration(t, s); + case 17: return CCTransitionFade::create(t, s); + case 18: return FadeWhiteTransition::create(t, s); - case 19: return FlipXLeftOver::transitionWithDuration(t, s); - case 20: return FlipXRightOver::transitionWithDuration(t, s); - case 21: return FlipYUpOver::transitionWithDuration(t, s); - case 22: return FlipYDownOver::transitionWithDuration(t, s); - case 23: return FlipAngularLeftOver::transitionWithDuration(t, s); - case 24: return FlipAngularRightOver::transitionWithDuration(t, s); + case 19: return FlipXLeftOver::create(t, s); + case 20: return FlipXRightOver::create(t, s); + case 21: return FlipYUpOver::create(t, s); + case 22: return FlipYDownOver::create(t, s); + case 23: return FlipAngularLeftOver::create(t, s); + case 24: return FlipAngularRightOver::create(t, s); - case 25: return ZoomFlipXLeftOver::transitionWithDuration(t, s); - case 26: return ZoomFlipXRightOver::transitionWithDuration(t, s); - case 27: return ZoomFlipYUpOver::transitionWithDuration(t, s); - case 28: return ZoomFlipYDownOver::transitionWithDuration(t, s); - case 29: return ZoomFlipAngularLeftOver::transitionWithDuration(t, s); - case 30: return ZoomFlipAngularRightOver::transitionWithDuration(t, s); + case 25: return ZoomFlipXLeftOver::create(t, s); + case 26: return ZoomFlipXRightOver::create(t, s); + case 27: return ZoomFlipYUpOver::create(t, s); + case 28: return ZoomFlipYDownOver::create(t, s); + case 29: return ZoomFlipAngularLeftOver::create(t, s); + case 30: return ZoomFlipAngularRightOver::create(t, s); - case 31: return CCTransitionShrinkGrow::transitionWithDuration(t, s); - case 32: return CCTransitionRotoZoom::transitionWithDuration(t, s); + case 31: return CCTransitionShrinkGrow::create(t, s); + case 32: return CCTransitionRotoZoom::create(t, s); - case 33: return CCTransitionMoveInL::transitionWithDuration(t, s); - case 34: return CCTransitionMoveInR::transitionWithDuration(t, s); - case 35: return CCTransitionMoveInT::transitionWithDuration(t, s); - case 36: return CCTransitionMoveInB::transitionWithDuration(t, s); + case 33: return CCTransitionMoveInL::create(t, s); + case 34: return CCTransitionMoveInR::create(t, s); + case 35: return CCTransitionMoveInT::create(t, s); + case 36: return CCTransitionMoveInB::create(t, s); - case 37: return CCTransitionSlideInL::transitionWithDuration(t, s); - case 38: return CCTransitionSlideInR::transitionWithDuration(t, s); - case 39: return CCTransitionSlideInT::transitionWithDuration(t, s); - case 40: return CCTransitionSlideInB::transitionWithDuration(t, s); + case 37: return CCTransitionSlideInL::create(t, s); + case 38: return CCTransitionSlideInR::create(t, s); + case 39: return CCTransitionSlideInT::create(t, s); + case 40: return CCTransitionSlideInB::create(t, s); default: break; } @@ -282,26 +282,26 @@ TestLayer1::TestLayer1(void) x = size.width; y = size.height; - CCSprite* bg1 = CCSprite::spriteWithFile(s_back1); + CCSprite* bg1 = CCSprite::create(s_back1); bg1->setPosition( CCPointMake(size.width/2, size.height/2) ); addChild(bg1, -1); - CCLabelTTF* title = CCLabelTTF::labelWithString( (transitions[s_nSceneIdx]).c_str(), "Thonburi", 32 ); + CCLabelTTF* title = CCLabelTTF::create( (transitions[s_nSceneIdx]).c_str(), "Thonburi", 32 ); addChild(title); title->setColor( ccc3(255,32,32) ); title->setPosition( CCPointMake(x/2, y-100) ); - CCLabelTTF* label = CCLabelTTF::labelWithString("SCENE 1", "Marker Felt", 38); + CCLabelTTF* label = CCLabelTTF::create("SCENE 1", "Marker Felt", 38); label->setColor( ccc3(16,16,255)); label->setPosition( CCPointMake(x/2,y/2)); addChild( label); // menu - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(TestLayer1::backCallback) ); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(TestLayer1::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(TestLayer1::nextCallback) ); + CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(TestLayer1::backCallback) ); + CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(TestLayer1::restartCallback) ); + CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(TestLayer1::nextCallback) ); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition( CCPointZero ); item1->setPosition( ccp( size.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2) ); @@ -411,26 +411,26 @@ TestLayer2::TestLayer2() x = size.width; y = size.height; - CCSprite* bg1 = CCSprite::spriteWithFile(s_back2); + CCSprite* bg1 = CCSprite::create(s_back2); bg1->setPosition( CCPointMake(size.width/2, size.height/2) ); addChild(bg1, -1); - CCLabelTTF* title = CCLabelTTF::labelWithString((transitions[s_nSceneIdx]).c_str(), "Thonburi", 32 ); + CCLabelTTF* title = CCLabelTTF::create((transitions[s_nSceneIdx]).c_str(), "Thonburi", 32 ); addChild(title); title->setColor( ccc3(255,32,32) ); title->setPosition( CCPointMake(x/2, y-100) ); - CCLabelTTF* label = CCLabelTTF::labelWithString("SCENE 2", "Marker Felt", 38); + CCLabelTTF* label = CCLabelTTF::create("SCENE 2", "Marker Felt", 38); label->setColor( ccc3(16,16,255)); label->setPosition( CCPointMake(x/2,y/2)); addChild( label); // menu - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(TestLayer2::backCallback) ); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(TestLayer2::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(TestLayer2::nextCallback) ); + CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(TestLayer2::backCallback) ); + CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(TestLayer2::restartCallback) ); + CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(TestLayer2::nextCallback) ); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition( CCPointZero ); item1->setPosition( ccp( size.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2) ); diff --git a/tests/tests/UserDefaultTest/UserDefaultTest.cpp b/tests/tests/UserDefaultTest/UserDefaultTest.cpp index c8e3da0e1f..e25fc37983 100644 --- a/tests/tests/UserDefaultTest/UserDefaultTest.cpp +++ b/tests/tests/UserDefaultTest/UserDefaultTest.cpp @@ -8,7 +8,7 @@ UserDefaultTest::UserDefaultTest() { CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF* label = CCLabelTTF::labelWithString("CCUserDefault test see log", "Arial", 28); + CCLabelTTF* label = CCLabelTTF::create("CCUserDefault test see log", "Arial", 28); addChild(label, 0); label->setPosition( ccp(s.width/2, s.height-50) ); diff --git a/tests/tests/ZwoptexTest/ZwoptexTest.cpp b/tests/tests/ZwoptexTest/ZwoptexTest.cpp index 78fe99e4bf..bb143af603 100644 --- a/tests/tests/ZwoptexTest/ZwoptexTest.cpp +++ b/tests/tests/ZwoptexTest/ZwoptexTest.cpp @@ -62,23 +62,23 @@ void ZwoptexTest::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF *label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 26); + CCLabelTTF *label = CCLabelTTF::create(title().c_str(), "Arial", 26); addChild(label, 1); label->setPosition(ccp(s.width/2, s.height-50)); std::string strSubTitle = subtitle(); if (strSubTitle.length() > 0) { - CCLabelTTF *l = CCLabelTTF::labelWithString(strSubTitle.c_str(), "Thonburi", 16); + CCLabelTTF *l = CCLabelTTF::create(strSubTitle.c_str(), "Thonburi", 16); addChild(l, 1); l->setPosition(ccp(s.width/2, s.height-80)); } - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage(s_pPathB1, s_pPathB2, this, menu_selector(ZwoptexTest::backCallback) ); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage(s_pPathR1, s_pPathR2, this, menu_selector(ZwoptexTest::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage(s_pPathF1, s_pPathF2, this, menu_selector(ZwoptexTest::nextCallback) ); + CCMenuItemImage *item1 = CCMenuItemImage::create(s_pPathB1, s_pPathB2, this, menu_selector(ZwoptexTest::backCallback) ); + CCMenuItemImage *item2 = CCMenuItemImage::create(s_pPathR1, s_pPathR2, this, menu_selector(ZwoptexTest::restartCallback) ); + CCMenuItemImage *item3 = CCMenuItemImage::create(s_pPathF1, s_pPathF2, this, menu_selector(ZwoptexTest::nextCallback) ); - CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); + CCMenu *menu = CCMenu::create(item1, item2, item3, NULL); menu->setPosition(CCPointZero); item1->setPosition( ccp( s.width/2 - item2->getContentSize().width*2, item2->getContentSize().height/2) ); @@ -89,21 +89,21 @@ void ZwoptexTest::onEnter() void ZwoptexTest::restartCallback(CCObject* pSender) { - CCScene *s = ZwoptexTestScene::node(); + CCScene *s = ZwoptexTestScene::create(); s->addChild(restartZwoptexTest()); CCDirector::sharedDirector()->replaceScene(s); } void ZwoptexTest::nextCallback(CCObject* pSender) { - CCScene *s = ZwoptexTestScene::node(); + CCScene *s = ZwoptexTestScene::create(); s->addChild(nextZwoptexTest()); CCDirector::sharedDirector()->replaceScene(s); } void ZwoptexTest::backCallback(CCObject* pSender) { - CCScene *s = ZwoptexTestScene::node(); + CCScene *s = ZwoptexTestScene::create(); s->addChild(backZwoptexTest()); CCDirector::sharedDirector()->replaceScene(s); } @@ -132,22 +132,22 @@ void ZwoptexGenericTest::onEnter() CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("zwoptex/grossini.plist"); CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("zwoptex/grossini-generic.plist"); - CCLayerColor *layer1 = CCLayerColor::layerWithColor(ccc4(255, 0, 0, 255), 85, 121); + CCLayerColor *layer1 = CCLayerColor::create(ccc4(255, 0, 0, 255), 85, 121); layer1->setPosition(ccp(s.width/2-80 - (85.0f * 0.5f), s.height/2 - (121.0f * 0.5f))); addChild(layer1); - sprite1 = CCSprite::spriteWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("grossini_dance_01.png")); + sprite1 = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("grossini_dance_01.png")); sprite1->setPosition(ccp( s.width/2-80, s.height/2)); addChild(sprite1); sprite1->setFlipX(false); sprite1->setFlipY(false); - CCLayerColor *layer2 = CCLayerColor::layerWithColor(ccc4(255, 0, 0, 255), 85, 121); + CCLayerColor *layer2 = CCLayerColor::create(ccc4(255, 0, 0, 255), 85, 121); layer2->setPosition(ccp(s.width/2+80 - (85.0f * 0.5f), s.height/2 - (121.0f * 0.5f))); addChild(layer2); - sprite2 = CCSprite::spriteWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("grossini_dance_generic_01.png")); + sprite2 = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("grossini_dance_generic_01.png")); sprite2->setPosition(ccp( s.width/2 + 80, s.height/2)); addChild(sprite2); diff --git a/tests/tests/ZwoptexTest/ZwoptexTest.h b/tests/tests/ZwoptexTest/ZwoptexTest.h index 85fc9074c8..367683dc74 100644 --- a/tests/tests/ZwoptexTest/ZwoptexTest.h +++ b/tests/tests/ZwoptexTest/ZwoptexTest.h @@ -38,7 +38,7 @@ class ZwoptexTestScene : public TestScene public: virtual void runThisTest(); - SCENE_NODE_FUNC(ZwoptexTestScene); + SCENE_CREATE_FUNC(ZwoptexTestScene); }; #endif // __ZWOPTEX_TEST_H__ diff --git a/tests/tests/controller.cpp b/tests/tests/controller.cpp index 1f722aa004..b69ebac2b8 100644 --- a/tests/tests/controller.cpp +++ b/tests/tests/controller.cpp @@ -133,23 +133,23 @@ TestController::TestController() : m_tBeginPos(CCPointZero) { // add close menu - CCMenuItemImage *pCloseItem = CCMenuItemImage::itemWithNormalImage(s_pPathClose, s_pPathClose, this, menu_selector(TestController::closeCallback) ); - CCMenu* pMenu =CCMenu::menuWithItems(pCloseItem, NULL); + CCMenuItemImage *pCloseItem = CCMenuItemImage::create(s_pPathClose, s_pPathClose, this, menu_selector(TestController::closeCallback) ); + CCMenu* pMenu =CCMenu::create(pCloseItem, NULL); CCSize s = CCDirector::sharedDirector()->getWinSize(); pMenu->setPosition( CCPointZero ); pCloseItem->setPosition(CCPointMake( s.width - 30, s.height - 30)); // add menu items for tests - m_pItemMenu = CCMenu::menuWithItems(NULL); + m_pItemMenu = CCMenu::create(); for (int i = 0; i < TESTS_COUNT; ++i) { // #if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE) -// CCLabelBMFont* label = CCLabelBMFont::labelWithString(g_aTestNames[i].c_str(), "fonts/arial16.fnt"); +// CCLabelBMFont* label = CCLabelBMFont::create(g_aTestNames[i].c_str(), "fonts/arial16.fnt"); // #else - CCLabelTTF* label = CCLabelTTF::labelWithString(g_aTestNames[i].c_str(), "Arial", 24); + CCLabelTTF* label = CCLabelTTF::create(g_aTestNames[i].c_str(), "Arial", 24); // #endif - CCMenuItemLabel* pMenuItem = CCMenuItemLabel::itemWithLabel(label, this, menu_selector(TestController::menuCallback)); + CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(TestController::menuCallback)); m_pItemMenu->addChild(pMenuItem, i + 10000); pMenuItem->setPosition( CCPointMake( s.width / 2, (s.height - (i + 1) * LINE_SPACE) )); diff --git a/tests/tests/testBasic.cpp b/tests/tests/testBasic.cpp index 480515e5cc..a3ffca4967 100644 --- a/tests/tests/testBasic.cpp +++ b/tests/tests/testBasic.cpp @@ -13,13 +13,13 @@ void TestScene::onEnter() //add the menu item for back to main menu //#if (CC_TARGET_PLATFORM == CC_PLATFORM_MARMALADE) -// CCLabelBMFont* label = CCLabelBMFont::labelWithString("MainMenu", "fonts/arial16.fnt"); +// CCLabelBMFont* label = CCLabelBMFont::create("MainMenu", "fonts/arial16.fnt"); //#else - CCLabelTTF* label = CCLabelTTF::labelWithString("MainMenu", "Arial", 20); + CCLabelTTF* label = CCLabelTTF::create("MainMenu", "Arial", 20); //#endif - CCMenuItemLabel* pMenuItem = CCMenuItemLabel::itemWithLabel(label, this, menu_selector(TestScene::MainMenuCallback)); + CCMenuItemLabel* pMenuItem = CCMenuItemLabel::create(label, this, menu_selector(TestScene::MainMenuCallback)); - CCMenu* pMenu =CCMenu::menuWithItems(pMenuItem, NULL); + CCMenu* pMenu =CCMenu::create(pMenuItem, NULL); CCSize s = CCDirector::sharedDirector()->getWinSize(); pMenu->setPosition( CCPointZero ); pMenuItem->setPosition( CCPointMake( s.width - 50, 25) ); @@ -29,7 +29,7 @@ void TestScene::onEnter() void TestScene::MainMenuCallback(CCObject* pSender) { - CCScene* pScene = CCScene::node(); + CCScene* pScene = CCScene::create(); CCLayer* pLayer = new TestController(); pLayer->autorelease(); From af9ada06af8e59d997017a7034f666bfc942d78c Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 14 Jun 2012 15:20:17 +0800 Subject: [PATCH 161/257] fixed #iss1299_simpleaudioengine: can not reusme effect that not in paused state --- CocosDenshion/ios/CocosDenshion.m | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/CocosDenshion/ios/CocosDenshion.m b/CocosDenshion/ios/CocosDenshion.m index fe980938a7..2efece4c29 100644 --- a/CocosDenshion/ios/CocosDenshion.m +++ b/CocosDenshion/ios/CocosDenshion.m @@ -975,7 +975,7 @@ static BOOL _mixerRateSet = NO; return; } alSourcePause(sourceId); - alGetError();//Clear error in case we stopped any sounds that couldn't be paused + alGetError();//Clear error in case we pause any sounds that couldn't be paused } - (void) pauseAllSounds { @@ -989,6 +989,15 @@ static BOOL _mixerRateSet = NO; if (!functioning_) { return; } + + // only resume a sound id that is paused + ALint state; + alGetSourcei(soundId, AL_SOURCE_STATE, &state); + if (state != AL_PAUSED) + { + return; + } + alSourcePlay(soundId); alGetError();//Clear error in case we stopped any sounds that couldn't be resumed } From 23574172ffceb38552b36a5e8d5a0f47ba8b2b80 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 14 Jun 2012 16:05:58 +0800 Subject: [PATCH 162/257] issue #1324: Added create() for static member functions that new an autorelease object, updated cocoa folder. --- cocos2dx/CCCamera.cpp | 2 +- cocos2dx/CCScheduler.cpp | 2 +- cocos2dx/actions/CCAction.cpp | 2 +- cocos2dx/actions/CCActionInterval.cpp | 2 +- cocos2dx/base_nodes/CCNode.cpp | 4 +- cocos2dx/cocoa/CCArray.cpp | 78 ++++++++++++++++--- cocos2dx/cocoa/CCArray.h | 49 ++++++++++-- cocos2dx/cocoa/CCData.cpp | 75 ------------------ cocos2dx/cocoa/CCData.h | 51 ------------ cocos2dx/cocoa/CCDictionary.cpp | 43 +++++++--- cocos2dx/cocoa/CCDictionary.h | 27 ++++++- cocos2dx/cocoa/CCInteger.h | 8 +- cocos2dx/cocoa/CCString.cpp | 42 ++++++++-- cocos2dx/cocoa/CCString.h | 39 ++++++++-- .../extensions/CCBReader/CCBReader_v2.cpp | 2 +- .../CCControlExtension/CCControl.cpp | 2 +- .../CCControlExtension/CCControlButton.cpp | 2 +- .../CCNotificationCenter.cpp | 2 +- cocos2dx/include/cocos2d.h | 1 - .../keypad_dispatcher/CCKeypadDispatcher.cpp | 2 +- cocos2dx/label_nodes/CCLabelAtlas.cpp | 2 +- cocos2dx/label_nodes/CCLabelBMFont.cpp | 4 +- cocos2dx/label_nodes/CCLabelTTF.cpp | 2 +- .../CCLayer.cpp | 4 +- cocos2dx/menu_nodes/CCMenu.cpp | 2 +- cocos2dx/menu_nodes/CCMenuItem.cpp | 4 +- cocos2dx/misc_nodes/CCRenderTexture.h | 1 - cocos2dx/particle_nodes/CCParticleSystem.cpp | 2 +- cocos2dx/platform/CCImageCommon_cpp.h | 4 +- cocos2dx/platform/CCPlatformMacros.h | 2 +- cocos2dx/platform/CCSAXParser.cpp | 2 +- cocos2dx/proj.win32/cocos2d-win32.vcproj | 8 -- cocos2dx/shaders/CCGLProgram.cpp | 8 +- cocos2dx/sprite_nodes/CCAnimation.cpp | 4 +- cocos2dx/sprite_nodes/CCAnimationCache.cpp | 6 +- cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp | 14 ++-- cocos2dx/support/image_support/TGAlib.cpp | 2 +- cocos2dx/support/zip_support/ZipUtils.cpp | 2 +- cocos2dx/textures/CCTexture2D.cpp | 2 +- cocos2dx/textures/CCTextureAtlas.cpp | 2 +- cocos2dx/textures/CCTextureCache.cpp | 13 ++-- cocos2dx/textures/CCTexturePVR.cpp | 3 +- cocos2dx/textures/CCTexturePVR.h | 3 - .../tileMap_parallax_nodes/CCTMXLayer.cpp | 2 +- .../CCTMXObjectGroup.cpp | 2 +- .../tileMap_parallax_nodes/CCTMXXMLParser.cpp | 14 +--- .../tileMap_parallax_nodes/CCTMXXMLParser.h | 3 - .../tileMap_parallax_nodes/CCTileMapAtlas.cpp | 6 +- .../touch_dispatcher/CCTouchDispatcher.cpp | 6 +- .../CCControlButtonTest.cpp | 20 ++--- .../CCControlColourPickerTest.cpp | 2 +- .../CCControlSliderTest.cpp | 2 +- tests/tests/LabelTest/LabelTest.cpp | 6 +- .../PerformanceNodeChildrenTest.cpp | 6 +- tests/tests/ShaderTest/ShaderTest.cpp | 4 +- .../SpriteTest/SpriteTest.cpp.REMOVED.git-id | 2 +- tests/tests/TileMapTest/TileMapTest.cpp | 2 +- tests/tests/TouchesTest/TouchesTest.cpp | 2 +- 58 files changed, 326 insertions(+), 284 deletions(-) delete mode 100644 cocos2dx/cocoa/CCData.cpp delete mode 100644 cocos2dx/cocoa/CCData.h diff --git a/cocos2dx/CCCamera.cpp b/cocos2dx/CCCamera.cpp index 5b4cd0e8c9..7637779267 100644 --- a/cocos2dx/CCCamera.cpp +++ b/cocos2dx/CCCamera.cpp @@ -46,7 +46,7 @@ CCCamera::~CCCamera(void) const char* CCCamera::description(void) { - return CCString::stringWithFormat("", m_fCenterX, m_fCenterY, m_fCenterZ)->getCString(); + return CCString::createWithFormat("", m_fCenterX, m_fCenterY, m_fCenterZ)->getCString(); } void CCCamera::init(void) diff --git a/cocos2dx/CCScheduler.cpp b/cocos2dx/CCScheduler.cpp index 72bcd0d762..0ac01bac5d 100644 --- a/cocos2dx/CCScheduler.cpp +++ b/cocos2dx/CCScheduler.cpp @@ -604,7 +604,7 @@ unsigned int CCScheduler::scheduleScriptFunc(unsigned int nHandler, float fInter CCSchedulerScriptHandlerEntry* pEntry = CCSchedulerScriptHandlerEntry::entryWithHandler(nHandler, fInterval, bPaused); if (!m_pScriptHandlerEntries) { - m_pScriptHandlerEntries = CCArray::arrayWithCapacity(20); + m_pScriptHandlerEntries = CCArray::create(20); m_pScriptHandlerEntries->retain(); } m_pScriptHandlerEntries->addObject(pEntry); diff --git a/cocos2dx/actions/CCAction.cpp b/cocos2dx/actions/CCAction.cpp index 2d0bf2d621..45b60b6821 100644 --- a/cocos2dx/actions/CCAction.cpp +++ b/cocos2dx/actions/CCAction.cpp @@ -64,7 +64,7 @@ CCAction* CCAction::create() const char* CCAction::description() { - return CCString::stringWithFormat("", m_nTag)->getCString(); + return CCString::createWithFormat("", m_nTag)->getCString(); } CCObject* CCAction::copyWithZone(CCZone *pZone) diff --git a/cocos2dx/actions/CCActionInterval.cpp b/cocos2dx/actions/CCActionInterval.cpp index dc10b21cc2..3f9e1ab6a7 100644 --- a/cocos2dx/actions/CCActionInterval.cpp +++ b/cocos2dx/actions/CCActionInterval.cpp @@ -2531,7 +2531,7 @@ void CCAnimate::update(float t) CCActionInterval* CCAnimate::reverse(void) { CCArray* pOldArray = m_pAnimation->getFrames(); - CCArray* pNewArray = CCArray::arrayWithCapacity(pOldArray->count()); + CCArray* pNewArray = CCArray::create(pOldArray->count()); CCARRAY_VERIFY_TYPE(pOldArray, CCAnimationFrame*); diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 8b709a830a..6b1c7b914b 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -462,13 +462,13 @@ void CCNode::cleanup() const char* CCNode::description() { - return CCString::stringWithFormat("", m_nTag)->getCString(); + return CCString::createWithFormat("", m_nTag)->getCString(); } // lazy allocs void CCNode::childrenAlloc(void) { - m_pChildren = CCArray::arrayWithCapacity(4); + m_pChildren = CCArray::create(4); m_pChildren->retain(); } diff --git a/cocos2dx/cocoa/CCArray.cpp b/cocos2dx/cocoa/CCArray.cpp index c390878178..314f3e3ba9 100644 --- a/cocos2dx/cocoa/CCArray.cpp +++ b/cocos2dx/cocoa/CCArray.cpp @@ -40,7 +40,12 @@ CCArray::CCArray(unsigned int capacity) initWithCapacity(capacity); } -CCArray* CCArray::array() +// CCArray* CCArray::array() +// { +// return CCArray::create(); +// } + +CCArray* CCArray::create() { CCArray* pArray = new CCArray(); @@ -56,7 +61,12 @@ CCArray* CCArray::array() return pArray; } -CCArray* CCArray::arrayWithObject(CCObject* pObject) +// CCArray* CCArray::arrayWithObject(CCObject* pObject) +// { +// return CCArray::createWithObject(pObject); +// } + +CCArray* CCArray::createWithObject(CCObject* pObject) { CCArray* pArray = new CCArray(); @@ -72,12 +82,38 @@ CCArray* CCArray::arrayWithObject(CCObject* pObject) return pArray; } -CCArray* CCArray::arrayWithObjects(CCObject* pObject, ...) +// CCArray* CCArray::arrayWithObjects(CCObject* pObject, ...) +// { +// va_list args; +// va_start(args,pObject); +// +// CCArray* pArray = create(); +// if (pArray && pObject) +// { +// pArray->addObject(pObject); +// CCObject *i = va_arg(args, CCObject*); +// while(i) +// { +// pArray->addObject(i); +// i = va_arg(args, CCObject*); +// } +// } +// else +// { +// CC_SAFE_DELETE(pArray); +// } +// +// va_end(args); +// +// return pArray; +// } + +CCArray* CCArray::create(CCObject* pObject, ...) { va_list args; va_start(args,pObject); - - CCArray* pArray = array(); + + CCArray* pArray = create(); if (pArray && pObject) { pArray->addObject(pObject); @@ -94,11 +130,16 @@ CCArray* CCArray::arrayWithObjects(CCObject* pObject, ...) } va_end(args); - + return pArray; } -CCArray* CCArray::arrayWithCapacity(unsigned int capacity) +// CCArray* CCArray::arrayWithCapacity(unsigned int capacity) +// { +// return CCArray::create(capacity); +// } + +CCArray* CCArray::create(unsigned int capacity) { CCArray* pArray = new CCArray(); @@ -114,16 +155,26 @@ CCArray* CCArray::arrayWithCapacity(unsigned int capacity) return pArray; } -CCArray* CCArray::arrayWithArray(CCArray* otherArray) +// CCArray* CCArray::arrayWithArray(CCArray* otherArray) +// { +// return CCArray::create(otherArray); +// } + +CCArray* CCArray::create(CCArray* otherArray) { CCArray* pRet = (CCArray*)otherArray->copy(); pRet->autorelease(); return pRet; } -CCArray* CCArray::arrayWithContentsOfFile(const char* pFileName) +// CCArray* CCArray::arrayWithContentsOfFile(const char* pFileName) +// { +// return CCArray::createWithContentsOfFile(pFileName); +// } + +CCArray* CCArray::createWithContentsOfFile(const char* pFileName) { - CCArray* pRet = arrayWithContentsOfFileThreadSafe(pFileName); + CCArray* pRet = createWithContentsOfFileThreadSafe(pFileName); if (pRet != NULL) { pRet->autorelease(); @@ -133,7 +184,12 @@ CCArray* CCArray::arrayWithContentsOfFile(const char* pFileName) extern CCArray* ccFileUtils_arrayWithContentsOfFileThreadSafe(const char* pFileName); -CCArray* CCArray::arrayWithContentsOfFileThreadSafe(const char* pFileName) +// CCArray* CCArray::arrayWithContentsOfFileThreadSafe(const char* pFileName) +// { +// return CCArray::createWithContentsOfFileThreadSafe(pFileName); +// } + +CCArray* CCArray::createWithContentsOfFileThreadSafe(const char* pFileName) { return ccFileUtils_arrayWithContentsOfFileThreadSafe(pFileName); } diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index 500cd82585..3642bd8da0 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -110,28 +110,63 @@ public: ~CCArray(); /* static functions */ + /** Create an array + @warning: This interface will be deprecated in future. + */ + //static CCArray* array(); + /** Create an array with one object + @warning: This interface will be deprecated in future. + */ + //static CCArray* arrayWithObject(CCObject* pObject); + /** Create an array with some objects + @warning: This interface will be deprecated in future. + */ + //static CCArray* arrayWithObjects(CCObject* pObject, ...); + /** Create an array with capacity + @warning: This interface will be deprecated in future. + */ + //static CCArray* arrayWithCapacity(unsigned int capacity); + /** Create an array with an existing array + @warning: This interface will be deprecated in future. + */ + //static CCArray* arrayWithArray(CCArray* otherArray); + /** + @brief Generate a CCArray pointer by file + @param pFileName The file name of *.plist file + @return The CCArray pointer generated from the file + @warning: This interface will be deprecated in future. + */ + //static CCArray* arrayWithContentsOfFile(const char* pFileName); + + /* + @brief The same meaning as arrayWithContentsOfFile(), but it doesn't call autorelease, so the + invoker should call release(). + @warning: This interface will be deprecated in future. + */ + //static CCArray* arrayWithContentsOfFileThreadSafe(const char* pFileName); + /** Create an array */ - static CCArray* array(); + static CCArray* create(); /** Create an array with one object */ - static CCArray* arrayWithObject(CCObject* pObject); + static CCArray* createWithObject(CCObject* pObject); /** Create an array with some objects */ - static CCArray* arrayWithObjects(CCObject* pObject, ...); + static CCArray* create(CCObject* pObject, ...); /** Create an array with capacity */ - static CCArray* arrayWithCapacity(unsigned int capacity); + static CCArray* create(unsigned int capacity); /** Create an array with an existing array */ - static CCArray* arrayWithArray(CCArray* otherArray); + static CCArray* create(CCArray* otherArray); /** @brief Generate a CCArray pointer by file @param pFileName The file name of *.plist file @return The CCArray pointer generated from the file */ - static CCArray* arrayWithContentsOfFile(const char* pFileName); + static CCArray* createWithContentsOfFile(const char* pFileName); /* @brief The same meaning as arrayWithContentsOfFile(), but it doesn't call autorelease, so the invoker should call release(). */ - static CCArray* arrayWithContentsOfFileThreadSafe(const char* pFileName); + static CCArray* createWithContentsOfFileThreadSafe(const char* pFileName); /** Initializes an array */ bool init(); diff --git a/cocos2dx/cocoa/CCData.cpp b/cocos2dx/cocoa/CCData.cpp deleted file mode 100644 index 89b390ce1d..0000000000 --- a/cocos2dx/cocoa/CCData.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - - -#include "CCData.h" -#include "CCFileUtils.h" - -#include - -using namespace std; - -NS_CC_BEGIN - -CCData::CCData(void) -: m_pData(NULL) -{ -} - -CCData::~CCData(void) -{ - CC_SAFE_DELETE_ARRAY(m_pData); -} - -CCData* CCData::dataWithContentsOfFile(const string &strPath) -{ - unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(strPath.c_str(), "rb", &nSize); - - if (! pBuffer) - { - return NULL; - } - - CCData *pRet = new CCData(); - pRet->m_pData = new char[nSize]; - memcpy(pRet->m_pData, pBuffer, nSize); - - return pRet; -} - -void* CCData::bytes(void) -{ - return m_pData; -} - -//@todo implement -CCData* CCData::dataWithBytes(unsigned char *pBytes, int size) -{ - CC_UNUSED_PARAM(pBytes); - CC_UNUSED_PARAM(size); - return NULL; -} - -NS_CC_END diff --git a/cocos2dx/cocoa/CCData.h b/cocos2dx/cocoa/CCData.h deleted file mode 100644 index cfbd20e6d9..0000000000 --- a/cocos2dx/cocoa/CCData.h +++ /dev/null @@ -1,51 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -#ifndef __CCDATA_H__ -#define __CCDATA_H__ - -#include "CCObject.h" -#include - -NS_CC_BEGIN - -class CC_DLL CCData : public CCObject -{ -public: - CCData(void); - ~CCData(void); - - void* bytes(void); - -public: - static CCData* dataWithBytes(unsigned char *pBytes, int size); - static CCData* dataWithContentsOfFile(const std::string &strPath); - -private: - char *m_pData; -}; - -NS_CC_END - -#endif //__CCDATA_H__ diff --git a/cocos2dx/cocoa/CCDictionary.cpp b/cocos2dx/cocoa/CCDictionary.cpp index e83591c114..97be4a3e1f 100644 --- a/cocos2dx/cocoa/CCDictionary.cpp +++ b/cocos2dx/cocoa/CCDictionary.cpp @@ -28,7 +28,8 @@ CCArray* CCDictionary::allKeys() { int iKeyCount = this->count(); if (iKeyCount <= 0) return NULL; - CCArray* pArray = CCArray::arrayWithCapacity(iKeyCount); + + CCArray* pArray = CCArray::create(iKeyCount); CCDictElement *pElement, *tmp; if (m_eDictType == kCCDictStr) @@ -57,7 +58,7 @@ CCArray* CCDictionary::allKeysForObject(CCObject* object) { int iKeyCount = this->count(); if (iKeyCount <= 0) return NULL; - CCArray* pArray = CCArray::array(); + CCArray* pArray = CCArray::create(); CCDictElement *pElement, *tmp; @@ -68,8 +69,8 @@ CCArray* CCDictionary::allKeysForObject(CCObject* object) if (object == pElement->m_pObject) { CCString* pOneKey = new CCString(pElement->m_szKey); - pOneKey->autorelease(); pArray->addObject(pOneKey); + pOneKey->release(); } } } @@ -80,8 +81,8 @@ CCArray* CCDictionary::allKeysForObject(CCObject* object) if (object == pElement->m_pObject) { CCInteger* pOneKey = new CCInteger(pElement->m_iKey); - pOneKey->autorelease(); pArray->addObject(pOneKey); + pOneKey->release(); } } } @@ -123,7 +124,7 @@ const CCString* CCDictionary::valueForKey(const std::string& key) CCString* pStr = (CCString*)objectForKey(key); if (pStr == NULL) { - pStr = CCString::stringWithCString(""); + pStr = CCString::create(""); } return pStr; } @@ -133,7 +134,7 @@ const CCString* CCDictionary::valueForKey(int key) CCString* pStr = (CCString*)objectForKey(key); if (pStr == NULL) { - pStr = CCString::stringWithCString(""); + pStr = CCString::create(""); } return pStr; } @@ -291,7 +292,12 @@ CCObject* CCDictionary::copyWithZone(CCZone* pZone) return pNewDict; } -CCDictionary* CCDictionary::dictionary() +// CCDictionary* CCDictionary::dictionary() +// { +// return CCDictionary::create(); +// } + +CCDictionary* CCDictionary::create() { CCDictionary* pRet = new CCDictionary(); if (pRet != NULL) @@ -301,7 +307,12 @@ CCDictionary* CCDictionary::dictionary() return pRet; } -CCDictionary* CCDictionary::dictionaryWithDictionary(CCDictionary* srcDict) +// CCDictionary* CCDictionary::dictionaryWithDictionary(CCDictionary* srcDict) +// { +// return CCDictionary::createWithDictionary(srcDict); +// } + +CCDictionary* CCDictionary::createWithDictionary(CCDictionary* srcDict) { CCDictionary* pNewDict = (CCDictionary*)srcDict->copy(); pNewDict->autorelease(); @@ -310,14 +321,24 @@ CCDictionary* CCDictionary::dictionaryWithDictionary(CCDictionary* srcDict) extern CCDictionary* ccFileUtils_dictionaryWithContentsOfFileThreadSafe(const char *pFileName); -CCDictionary* CCDictionary::dictionaryWithContentsOfFileThreadSafe(const char *pFileName) +// CCDictionary* CCDictionary::dictionaryWithContentsOfFileThreadSafe(const char *pFileName) +// { +// return CCDictionary::createWithContentsOfFileThreadSafe(pFileName); +// } + +CCDictionary* CCDictionary::createWithContentsOfFileThreadSafe(const char *pFileName) { return ccFileUtils_dictionaryWithContentsOfFileThreadSafe(pFileName); } -CCDictionary* CCDictionary::dictionaryWithContentsOfFile(const char *pFileName) +// CCDictionary* CCDictionary::dictionaryWithContentsOfFile(const char *pFileName) +// { +// return CCDictionary::createWithContentsOfFile(pFileName); +// } + +CCDictionary* CCDictionary::createWithContentsOfFile(const char *pFileName) { - CCDictionary* pRet = dictionaryWithContentsOfFileThreadSafe(pFileName); + CCDictionary* pRet = createWithContentsOfFileThreadSafe(pFileName); pRet->autorelease(); return pRet; } diff --git a/cocos2dx/cocoa/CCDictionary.h b/cocos2dx/cocoa/CCDictionary.h index c4d22030c0..bc8c66044b 100644 --- a/cocos2dx/cocoa/CCDictionary.h +++ b/cocos2dx/cocoa/CCDictionary.h @@ -136,21 +136,40 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); /* static functions */ - static CCDictionary* dictionary(); + //@warning: This interface will be deprecated in future. + //static CCDictionary* dictionary(); - static CCDictionary* dictionaryWithDictionary(CCDictionary* srcDict); + //static CCDictionary* dictionaryWithDictionary(CCDictionary* srcDict); + /** + @brief Generate a CCDictionary pointer by file + @param pFileName The file name of *.plist file + @return The CCDictionary pointer generated from the file + @warning: This interface will be deprecated in future. + */ + //static CCDictionary* dictionaryWithContentsOfFile(const char *pFileName); + + /* + @brief The same meaning as dictionaryWithContentsOfFile(), but it doesn't call autorelease, so the + invoker should call release(). + @warning: This interface will be deprecated in future. + */ + //static CCDictionary* dictionaryWithContentsOfFileThreadSafe(const char *pFileName); + + static CCDictionary* create(); + + static CCDictionary* createWithDictionary(CCDictionary* srcDict); /** @brief Generate a CCDictionary pointer by file @param pFileName The file name of *.plist file @return The CCDictionary pointer generated from the file */ - static CCDictionary* dictionaryWithContentsOfFile(const char *pFileName); + static CCDictionary* createWithContentsOfFile(const char *pFileName); /* @brief The same meaning as dictionaryWithContentsOfFile(), but it doesn't call autorelease, so the invoker should call release(). */ - static CCDictionary* dictionaryWithContentsOfFileThreadSafe(const char *pFileName); + static CCDictionary* createWithContentsOfFileThreadSafe(const char *pFileName); private: void setObjectUnSafe(CCObject* pObject, const std::string& key); diff --git a/cocos2dx/cocoa/CCInteger.h b/cocos2dx/cocoa/CCInteger.h index 7779b92858..f098e6b5bf 100644 --- a/cocos2dx/cocoa/CCInteger.h +++ b/cocos2dx/cocoa/CCInteger.h @@ -12,7 +12,13 @@ public: : m_nValue(v) {} int getValue() const {return m_nValue;} - static CCInteger* integerWithInt(int v) + // @warning: This interface will be deprecated in future. +// static CCInteger* integerWithInt(int v) +// { +// return CCInteger::create(v); +// } + + static CCInteger* create(int v) { CCInteger* pRet = new CCInteger(v); pRet->autorelease(); diff --git a/cocos2dx/cocoa/CCString.cpp b/cocos2dx/cocoa/CCString.cpp index bc3747c21b..e712cc11a2 100644 --- a/cocos2dx/cocoa/CCString.cpp +++ b/cocos2dx/cocoa/CCString.cpp @@ -145,14 +145,24 @@ bool CCString::isEqual(const CCObject* pObject) return bRet; } -CCString* CCString::stringWithCString(const char* pStr) +// CCString* CCString::stringWithCString(const char* pStr) +// { +// return CCString::create(pStr); +// } + +CCString* CCString::create(const char* pStr) { CCString* pRet = new CCString(pStr); pRet->autorelease(); return pRet; } -CCString* CCString::stringWithData(unsigned char* pData, unsigned long nLen) +// CCString* CCString::stringWithData(unsigned char* pData, unsigned long nLen) +// { +// return CCString::createWithData(pData, nLen); +// } + +CCString* CCString::createWithData(unsigned char* pData, unsigned long nLen) { CCString* pRet = NULL; if (pData != NULL && nLen > 0) @@ -162,16 +172,27 @@ CCString* CCString::stringWithData(unsigned char* pData, unsigned long nLen) { pStr[nLen] = '\0'; memcpy(pStr, pData, nLen); - pRet = CCString::stringWithCString(pStr); + pRet = CCString::create(pStr); free(pStr); } } return pRet; } -CCString* CCString::stringWithFormat(const char* format, ...) +// CCString* CCString::stringWithFormat(const char* format, ...) +// { +// CCString* pRet = CCString::create(""); +// va_list ap; +// va_start(ap, format); +// pRet->initWithFormatAndValist(format, ap); +// va_end(ap); +// +// return pRet; +// } + +CCString* CCString::createWithFormat(const char* format, ...) { - CCString* pRet = CCString::stringWithCString(""); + CCString* pRet = CCString::create(""); va_list ap; va_start(ap, format); pRet->initWithFormatAndValist(format, ap); @@ -180,13 +201,18 @@ CCString* CCString::stringWithFormat(const char* format, ...) return pRet; } -CCString* CCString::stringWithContentsOfFile(const char* pszFileName) +// CCString* CCString::stringWithContentsOfFile(const char* pszFileName) +// { +// return CCString::createWithContentsOfFile(pszFileName); +// } + +CCString* CCString::createWithContentsOfFile(const char* pszFileName) { unsigned long size = 0; unsigned char* pData = 0; CCString* pRet = NULL; - pData = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(pszFileName, "rb", &size); - pRet = stringWithData(pData, size); + pData = CCFileUtils::sharedFileUtils()->getFileData(pszFileName, "rb", &size); + pRet = CCString::createWithData(pData, size); CC_SAFE_DELETE_ARRAY(pData); return pRet; } diff --git a/cocos2dx/cocoa/CCString.h b/cocos2dx/cocoa/CCString.h index abb41043ca..beedd83184 100644 --- a/cocos2dx/cocoa/CCString.h +++ b/cocos2dx/cocoa/CCString.h @@ -74,27 +74,56 @@ public: /** create a string with c string * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. + @warning: This interface will be deprecated in future. */ - static CCString* stringWithCString(const char* pStr); + //static CCString* stringWithCString(const char* pStr); + + /** create a string with format, it's similar with the c function 'sprintf', the default buffer size is (1024*100) bytes, + * if you want to change it, you should modify the kMaxStringLen macro in CCString.cpp file. + * @return A CCString pointer which is an autorelease object pointer, + * it means that you needn't do a release operation unless you retain it. + @warning: This interface will be deprecated in future. + */ + //static CCString* stringWithFormat(const char* format, ...); + + /** create a string with binary data + * @return A CCString pointer which is an autorelease object pointer, + * it means that you needn't do a release operation unless you retain it. + @warning: This interface will be deprecated in future. + */ + //static CCString* stringWithData(unsigned char* pData, unsigned long nLen); + + /** create a string with a file, + * @return A CCString pointer which is an autorelease object pointer, + * it means that you needn't do a release operation unless you retain it. + @warning: This interface will be deprecated in future. + */ + //static CCString* stringWithContentsOfFile(const char* pszFileName); + + /** create a string with c string + * @return A CCString pointer which is an autorelease object pointer, + * it means that you needn't do a release operation unless you retain it. + */ + static CCString* create(const char* pStr); /** create a string with format, it's similar with the c function 'sprintf', the default buffer size is (1024*100) bytes, * if you want to change it, you should modify the kMaxStringLen macro in CCString.cpp file. * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. */ - static CCString* stringWithFormat(const char* format, ...); + static CCString* createWithFormat(const char* format, ...); /** create a string with binary data * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. */ - static CCString* stringWithData(unsigned char* pData, unsigned long nLen); + static CCString* createWithData(unsigned char* pData, unsigned long nLen); /** create a string with a file, * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. */ - static CCString* stringWithContentsOfFile(const char* pszFileName); + static CCString* createWithContentsOfFile(const char* pszFileName); private: @@ -105,7 +134,7 @@ public: std::string m_sString; }; -#define CCStringMake(str) CCString::stringWithCString(str) +#define CCStringMake(str) CCString::create(str) #define ccs CCStringMake diff --git a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp index 4ee9d33d4f..d299b8bd21 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader_v2.cpp @@ -763,7 +763,7 @@ CCNode* CCBReader::nodeGraphFromFile(const char* file, CCNode* owner) ccbFileDir = ccbFilePath.substr(0, lastSlash) + "/"; } - CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFile(ccbFilePath.c_str()); + CCDictionary* dict = CCDictionary::createWithContentsOfFile(ccbFilePath.c_str()); CCAssert(dict != NULL, "CCBReader: file not found"); return nodeGraphFromDictionary(dict, NULL, ccbFileDir.c_str(), owner); } diff --git a/cocos2dx/extensions/CCControlExtension/CCControl.cpp b/cocos2dx/extensions/CCControlExtension/CCControl.cpp index 3af099067a..18abe39d7a 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControl.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControl.cpp @@ -293,7 +293,7 @@ CCArray* CCControl::dispatchListforControlEvent(CCControlEvent controlEvent) // If the invocation list does not exist for the dispatch table, we create it if (invocationList == NULL) { - invocationList = CCArray::arrayWithCapacity(1); + invocationList = CCArray::create(1); dispatchTable->setObject(invocationList, controlEvent); } return invocationList; diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp index e1bc56441e..e0bcabc416 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp @@ -99,7 +99,7 @@ bool CCControlButton::initWithLabelAndBackgroundSprite(CCNode* node, CCScale9Spr // Initialize the dispatch table - CCString* tempString = CCString::stringWithCString(label->getString()); + CCString* tempString = CCString::create(label->getString()); //tempString->autorelease(); setTitleForState(tempString, CCControlStateNormal); setTitleColorForState(rgbaLabel->getColor(), CCControlStateNormal); diff --git a/cocos2dx/extensions/CCNotificationCenter/CCNotificationCenter.cpp b/cocos2dx/extensions/CCNotificationCenter/CCNotificationCenter.cpp index 9521a03943..9acc3110df 100644 --- a/cocos2dx/extensions/CCNotificationCenter/CCNotificationCenter.cpp +++ b/cocos2dx/extensions/CCNotificationCenter/CCNotificationCenter.cpp @@ -34,7 +34,7 @@ static CCNotificationCenter *s_sharedNotifCenter = NULL; CCNotificationCenter::CCNotificationCenter() { - m_observers = CCArray::arrayWithCapacity(3); + m_observers = CCArray::create(3); m_observers->retain(); } diff --git a/cocos2dx/include/cocos2d.h b/cocos2dx/include/cocos2d.h index d3bcff4233..789ed06bf4 100755 --- a/cocos2dx/include/cocos2d.h +++ b/cocos2dx/include/cocos2d.h @@ -61,7 +61,6 @@ THE SOFTWARE. #include "CCAutoreleasePool.h" #include "CCInteger.h" #include "CCString.h" -#include "CCData.h" #include "CCNS.h" #include "CCZone.h" diff --git a/cocos2dx/keypad_dispatcher/CCKeypadDispatcher.cpp b/cocos2dx/keypad_dispatcher/CCKeypadDispatcher.cpp index 4ca25e0573..d2ccb7186f 100644 --- a/cocos2dx/keypad_dispatcher/CCKeypadDispatcher.cpp +++ b/cocos2dx/keypad_dispatcher/CCKeypadDispatcher.cpp @@ -37,7 +37,7 @@ CCKeypadDispatcher::CCKeypadDispatcher() , m_bToAdd(false) , m_bToRemove(false) { - m_pDelegates = CCArray::array(); + m_pDelegates = CCArray::create(); m_pDelegates->retain(); m_pHandlersToAdd = ccCArrayNew(8); diff --git a/cocos2dx/label_nodes/CCLabelAtlas.cpp b/cocos2dx/label_nodes/CCLabelAtlas.cpp index 18b4974b62..7532b7e3d3 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.cpp +++ b/cocos2dx/label_nodes/CCLabelAtlas.cpp @@ -95,7 +95,7 @@ CCLabelAtlas* CCLabelAtlas::create(const char *string, const char *fntFile) bool CCLabelAtlas::initWithString(const char *theString, const char *fntFile) { - CCDictionary *dict = CCDictionary::dictionaryWithContentsOfFile(CCFileUtils::sharedFileUtils()->sharedFileUtils()->fullPathFromRelativePath(fntFile)); + CCDictionary *dict = CCDictionary::createWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(fntFile)); CCAssert(((CCString*)dict->objectForKey("version"))->intValue() == 1, "Unsupported version. Upgrade cocos2d version"); diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index baa5d91439..a3ba1529c5 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -452,7 +452,7 @@ CCBMFontConfiguration::~CCBMFontConfiguration() const char* CCBMFontConfiguration::description(void) { - return CCString::stringWithFormat( + return CCString::createWithFormat( "", this, HASH_COUNT(m_pFontDefDictionary), @@ -486,7 +486,7 @@ void CCBMFontConfiguration::purgeFontDefDictionary() bool CCBMFontConfiguration::parseConfigFile(const char *controlFile) { std::string fullpath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(controlFile); - CCString *contents = CCString::stringWithContentsOfFile(fullpath.c_str()); + CCString *contents = CCString::createWithContentsOfFile(fullpath.c_str()); CCAssert(contents, "CCBMFontConfiguration::parseConfigFile | Open file error."); diff --git a/cocos2dx/label_nodes/CCLabelTTF.cpp b/cocos2dx/label_nodes/CCLabelTTF.cpp index 1c6cf41699..351b9e9eb5 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.cpp +++ b/cocos2dx/label_nodes/CCLabelTTF.cpp @@ -145,7 +145,7 @@ const char* CCLabelTTF::getString(void) const char* CCLabelTTF::description() { - return CCString::stringWithFormat("", m_pFontName->c_str(), m_fFontSize)->getCString(); + return CCString::createWithFormat("", m_pFontName->c_str(), m_fFontSize)->getCString(); } CCTextAlignment CCLabelTTF::getHorizontalAlignment() diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index b8d055e25d..73ee4bbeec 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -800,7 +800,7 @@ void CCLayerMultiplex::addLayer(CCLayer* layer) bool CCLayerMultiplex::initWithLayer(CCLayer* layer) { - m_pLayers = CCArray::array(); + m_pLayers = CCArray::create(); m_pLayers->retain(); m_pLayers->addObject(layer); m_nEnabledLayer = 0; @@ -810,7 +810,7 @@ bool CCLayerMultiplex::initWithLayer(CCLayer* layer) bool CCLayerMultiplex::initWithLayers(CCLayer *layer, va_list params) { - m_pLayers = CCArray::arrayWithCapacity(5); + m_pLayers = CCArray::create(5); m_pLayers->retain(); m_pLayers->addObject(layer); diff --git a/cocos2dx/menu_nodes/CCMenu.cpp b/cocos2dx/menu_nodes/CCMenu.cpp index 4cabca4272..82f6245e8d 100644 --- a/cocos2dx/menu_nodes/CCMenu.cpp +++ b/cocos2dx/menu_nodes/CCMenu.cpp @@ -128,7 +128,7 @@ bool CCMenu::initWithItems(CCMenuItem* item, va_list args) CCArray* pArray = NULL; if( item ) { - pArray = CCArray::arrayWithObject(item); + pArray = CCArray::create(item, NULL); CCMenuItem *i = va_arg(args, CCMenuItem*); while(i) { diff --git a/cocos2dx/menu_nodes/CCMenuItem.cpp b/cocos2dx/menu_nodes/CCMenuItem.cpp index b9b4bbf2ac..d9a351f7ed 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.cpp +++ b/cocos2dx/menu_nodes/CCMenuItem.cpp @@ -816,7 +816,7 @@ CCMenuItemToggle * CCMenuItemToggle::create(CCObject* target, SEL_MenuHandler se bool CCMenuItemToggle::initWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, va_list args) { CCMenuItem::initWithTarget(target, selector); - this->m_pSubItems = CCArray::array(); + this->m_pSubItems = CCArray::create(); this->m_pSubItems->retain(); int z = 0; CCMenuItem *i = item; @@ -847,7 +847,7 @@ CCMenuItemToggle* CCMenuItemToggle::create(CCMenuItem *item) bool CCMenuItemToggle::initWithItem(CCMenuItem *item) { CCMenuItem::initWithTarget(NULL, NULL); - this->m_pSubItems = CCArray::array(); + this->m_pSubItems = CCArray::create(); this->m_pSubItems->retain(); m_pSubItems->addObject(item); m_uSelectedIndex = UINT_MAX; diff --git a/cocos2dx/misc_nodes/CCRenderTexture.h b/cocos2dx/misc_nodes/CCRenderTexture.h index 1a1a4851a8..30370412d2 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.h +++ b/cocos2dx/misc_nodes/CCRenderTexture.h @@ -25,7 +25,6 @@ THE SOFTWARE. #ifndef __CCRENDER_TEXTURE_H__ #define __CCRENDER_TEXTURE_H__ -#include "CCData.h" #include "CCNode.h" #include "CCSprite.h" #include "kazmath/mat4.h" diff --git a/cocos2dx/particle_nodes/CCParticleSystem.cpp b/cocos2dx/particle_nodes/CCParticleSystem.cpp index 9ecd15da76..3bc36bc19b 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystem.cpp @@ -156,7 +156,7 @@ bool CCParticleSystem::initWithFile(const char *plistFile) { bool bRet = false; m_sPlistFile = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(plistFile); - CCDictionary *dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(m_sPlistFile.c_str()); + CCDictionary *dict = CCDictionary::createWithContentsOfFileThreadSafe(m_sPlistFile.c_str()); CCAssert( dict != NULL, "Particles: file not found"); bRet = this->initWithDictionary(dict); diff --git a/cocos2dx/platform/CCImageCommon_cpp.h b/cocos2dx/platform/CCImageCommon_cpp.h index 80e7788683..cf0a451e36 100644 --- a/cocos2dx/platform/CCImageCommon_cpp.h +++ b/cocos2dx/platform/CCImageCommon_cpp.h @@ -97,7 +97,7 @@ bool CCImage::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = e CC_UNUSED_PARAM(eImgFmt); unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(strPath), "rb", &nSize); + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->getFileData(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(strPath), "rb", &nSize); return initWithImageData(pBuffer, nSize, eImgFmt); } @@ -107,7 +107,7 @@ bool CCImage::initWithImageFileThreadSafe(const char *fullpath, EImageFormat ima CC_UNUSED_PARAM(imageType); unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(fullpath, "rb", &nSize); + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->getFileData(fullpath, "rb", &nSize); return initWithImageData(pBuffer, nSize, imageType); } diff --git a/cocos2dx/platform/CCPlatformMacros.h b/cocos2dx/platform/CCPlatformMacros.h index b1d5a458c8..2e7e21fcf5 100644 --- a/cocos2dx/platform/CCPlatformMacros.h +++ b/cocos2dx/platform/CCPlatformMacros.h @@ -167,7 +167,7 @@ public: virtual void set##funName(varType var) \ #define CC_BREAK_IF(cond) if(cond) break #define __CCLOGWITHFUNCTION(s, ...) \ - CCLog("%s : %s",__FUNCTION__, CCString::stringWithFormat(s, ##__VA_ARGS__)->getCString()) + CCLog("%s : %s",__FUNCTION__, CCString::createWithFormat(s, ##__VA_ARGS__)->getCString()) // cocos2d debug #if !defined(COCOS2D_DEBUG) || COCOS2D_DEBUG == 0 diff --git a/cocos2dx/platform/CCSAXParser.cpp b/cocos2dx/platform/CCSAXParser.cpp index 3c7c9cbd3d..a351d8099a 100644 --- a/cocos2dx/platform/CCSAXParser.cpp +++ b/cocos2dx/platform/CCSAXParser.cpp @@ -84,7 +84,7 @@ bool CCSAXParser::parse(const char* pXMLData, unsigned int uDataLength) bool CCSAXParser::parse(const char *pszFile) { unsigned long size; - char *pBuffer = (char*)CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(pszFile, "rt", &size); + char *pBuffer = (char*)CCFileUtils::sharedFileUtils()->getFileData(pszFile, "rt", &size); if (!pBuffer) { diff --git a/cocos2dx/proj.win32/cocos2d-win32.vcproj b/cocos2dx/proj.win32/cocos2d-win32.vcproj index fb354843a5..96cc4a5e72 100755 --- a/cocos2dx/proj.win32/cocos2d-win32.vcproj +++ b/cocos2dx/proj.win32/cocos2d-win32.vcproj @@ -231,14 +231,6 @@ RelativePath="..\cocoa\CCAutoreleasePool.h" > - - - - diff --git a/cocos2dx/shaders/CCGLProgram.cpp b/cocos2dx/shaders/CCGLProgram.cpp index 7c32c832a8..94e464a8e3 100644 --- a/cocos2dx/shaders/CCGLProgram.cpp +++ b/cocos2dx/shaders/CCGLProgram.cpp @@ -116,15 +116,15 @@ bool CCGLProgram::initWithVertexShaderByteArray(const GLchar* vShaderByteArray, bool CCGLProgram::initWithVertexShaderFilename(const char* vShaderFilename, const char* fShaderFilename) { - const GLchar * vertexSource = (GLchar*) CCString::stringWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(vShaderFilename))->getCString(); - const GLchar * fragmentSource = (GLchar*) CCString::stringWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(fShaderFilename))->getCString(); + const GLchar * vertexSource = (GLchar*) CCString::createWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(vShaderFilename))->getCString(); + const GLchar * fragmentSource = (GLchar*) CCString::createWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(fShaderFilename))->getCString(); return initWithVertexShaderByteArray(vertexSource, fragmentSource); } const char* CCGLProgram::description() { - return CCString::stringWithFormat("", this, m_uProgram, m_uVertShader, m_uFragShader)->getCString(); + return CCString::createWithFormat("", this, m_uProgram, m_uVertShader, m_uFragShader)->getCString(); } bool CCGLProgram::compileShader(GLuint * shader, GLenum type, const GLchar* source) @@ -219,7 +219,7 @@ const char* CCGLProgram::logForOpenGLObject(GLuint object, GLInfoFunction infoFu char *logBytes = (char*)malloc(logLength); logFunc(object, logLength, &charsWritten, logBytes); - CCString* log = CCString::stringWithCString(logBytes); + CCString* log = CCString::create(logBytes); free(logBytes); return log->getCString(); diff --git a/cocos2dx/sprite_nodes/CCAnimation.cpp b/cocos2dx/sprite_nodes/CCAnimation.cpp index 0bc2681b17..2f908fbcfb 100644 --- a/cocos2dx/sprite_nodes/CCAnimation.cpp +++ b/cocos2dx/sprite_nodes/CCAnimation.cpp @@ -133,7 +133,7 @@ bool CCAnimation::initWithSpriteFrames(CCArray *pFrames, float delay/* = 0.0f*/) m_uLoops = 1; m_fDelayPerUnit = delay; - CCArray* pTmpFrames = CCArray::array(); + CCArray* pTmpFrames = CCArray::create(); setFrames(pTmpFrames); if (pFrames != NULL) @@ -161,7 +161,7 @@ bool CCAnimation::initWithAnimationFrames(CCArray* arrayOfAnimationFrames, float m_fDelayPerUnit = delayPerUnit; m_uLoops = loops; - setFrames(CCArray::arrayWithArray(arrayOfAnimationFrames)); + setFrames(CCArray::create(arrayOfAnimationFrames)); CCObject* pObj = NULL; CCARRAY_FOREACH(m_pFrames, pObj) diff --git a/cocos2dx/sprite_nodes/CCAnimationCache.cpp b/cocos2dx/sprite_nodes/CCAnimationCache.cpp index c490674e90..bba721d5f5 100644 --- a/cocos2dx/sprite_nodes/CCAnimationCache.cpp +++ b/cocos2dx/sprite_nodes/CCAnimationCache.cpp @@ -108,7 +108,7 @@ void CCAnimationCache::parseVersion1(CCDictionary* animations) continue; } - CCArray* frames = CCArray::arrayWithCapacity(frameNames->count()); + CCArray* frames = CCArray::create(frameNames->count()); frames->retain(); CCObject* pObj = NULL; @@ -164,7 +164,7 @@ void CCAnimationCache::parseVersion2(CCDictionary* animations) } // Array of AnimationFrames - CCArray* array = CCArray::arrayWithCapacity(frameArray->count()); + CCArray* array = CCArray::create(frameArray->count()); array->retain(); CCObject* pObj = NULL; @@ -245,7 +245,7 @@ void CCAnimationCache::addAnimationsWithFile(const char* plist) CCAssert( plist, "Invalid texture file name"); const char* path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(plist); - CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFile(path); + CCDictionary* dict = CCDictionary::createWithContentsOfFile(path); CCAssert( dict, "CCAnimationCache: File could not be found"); diff --git a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp index 97a3695446..f574e9fcc5 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp @@ -203,7 +203,7 @@ void CCSpriteFrameCache::addSpriteFramesWithDictionary(CCDictionary* dictionary, void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist, CCTexture2D *pobTexture) { const char *pszPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pszPlist); - CCDictionary *dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(pszPath); + CCDictionary *dict = CCDictionary::createWithContentsOfFileThreadSafe(pszPath); addSpriteFramesWithDictionary(dict, pobTexture); @@ -232,7 +232,7 @@ void CCSpriteFrameCache::addSpriteFramesWithFile(const char *pszPlist) if (m_pLoadedFileNames->find(pszPlist) == m_pLoadedFileNames->end()) { const char *pszPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(pszPlist); - CCDictionary *dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(pszPath); + CCDictionary *dict = CCDictionary::createWithContentsOfFileThreadSafe(pszPath); string texturePath(""); @@ -343,7 +343,7 @@ void CCSpriteFrameCache::removeSpriteFrameByName(const char *pszName) void CCSpriteFrameCache::removeSpriteFramesFromFile(const char* plist) { const char* path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(plist); - CCDictionary* dict = CCDictionary::dictionaryWithContentsOfFileThreadSafe(path); + CCDictionary* dict = CCDictionary::createWithContentsOfFileThreadSafe(path); removeSpriteFramesFromDictionary((CCDictionary*)dict); @@ -360,14 +360,14 @@ void CCSpriteFrameCache::removeSpriteFramesFromFile(const char* plist) void CCSpriteFrameCache::removeSpriteFramesFromDictionary(CCDictionary* dictionary) { CCDictionary* framesDict = (CCDictionary*)dictionary->objectForKey("frames"); - CCArray* keysToRemove = CCArray::array(); + CCArray* keysToRemove = CCArray::create(); CCDictElement* pElement = NULL; CCDICT_FOREACH(framesDict, pElement) { if (m_pSpriteFrames->objectForKey(pElement->getStrKey())) { - keysToRemove->addObject(CCString::stringWithCString(pElement->getStrKey())); + keysToRemove->addObject(CCString::create(pElement->getStrKey())); } } @@ -376,7 +376,7 @@ void CCSpriteFrameCache::removeSpriteFramesFromDictionary(CCDictionary* dictiona void CCSpriteFrameCache::removeSpriteFramesFromTexture(CCTexture2D* texture) { - CCArray* keysToRemove = CCArray::array(); + CCArray* keysToRemove = CCArray::create(); CCDictElement* pElement = NULL; CCDICT_FOREACH(m_pSpriteFrames, pElement) @@ -385,7 +385,7 @@ void CCSpriteFrameCache::removeSpriteFramesFromTexture(CCTexture2D* texture) CCSpriteFrame* frame = (CCSpriteFrame*)m_pSpriteFrames->objectForKey(key.c_str()); if (frame && (frame->getTexture() == texture)) { - keysToRemove->addObject(CCString::stringWithCString(pElement->getStrKey())); + keysToRemove->addObject(CCString::create(pElement->getStrKey())); } } diff --git a/cocos2dx/support/image_support/TGAlib.cpp b/cocos2dx/support/image_support/TGAlib.cpp index 9cfce7ffe6..7f97cfafe0 100644 --- a/cocos2dx/support/image_support/TGAlib.cpp +++ b/cocos2dx/support/image_support/TGAlib.cpp @@ -199,7 +199,7 @@ tImageTGA * tgaLoad(const char *pszFilename) tImageTGA *info = NULL; unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(pszFilename, "rb", &nSize); + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->getFileData(pszFilename, "rb", &nSize); do { diff --git a/cocos2dx/support/zip_support/ZipUtils.cpp b/cocos2dx/support/zip_support/ZipUtils.cpp index f8217f7639..ece5c179e5 100644 --- a/cocos2dx/support/zip_support/ZipUtils.cpp +++ b/cocos2dx/support/zip_support/ZipUtils.cpp @@ -217,7 +217,7 @@ namespace cocos2d unsigned char *compressed = NULL; int fileLen = 0; - compressed = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(path, "rb", (unsigned long *)(&fileLen)); + compressed = CCFileUtils::sharedFileUtils()->getFileData(path, "rb", (unsigned long *)(&fileLen)); // int fileLen = CCFileUtils::sharedFileUtils()->ccLoadFileIntoMemory( path, &compressed ); if( fileLen < 0 ) diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index d16a409a46..9e93d0c515 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -248,7 +248,7 @@ bool CCTexture2D::initWithData(const void *data, CCTexture2DPixelFormat pixelFor const char* CCTexture2D::description(void) { - return CCString::stringWithFormat("", m_uName, m_uPixelsWide, m_uPixelsHigh, m_fMaxS, m_fMaxT)->getCString(); + return CCString::createWithFormat("", m_uName, m_uPixelsWide, m_uPixelsHigh, m_fMaxS, m_fMaxT)->getCString(); } // implementation CCTexture2D (Image) diff --git a/cocos2dx/textures/CCTextureAtlas.cpp b/cocos2dx/textures/CCTextureAtlas.cpp index 8ce755d087..1ef0c59c81 100644 --- a/cocos2dx/textures/CCTextureAtlas.cpp +++ b/cocos2dx/textures/CCTextureAtlas.cpp @@ -209,7 +209,7 @@ void CCTextureAtlas::listenBackToForeground(CCObject *obj) const char* CCTextureAtlas::description() { - return CCString::stringWithFormat("", m_uTotalQuads)->getCString(); + return CCString::createWithFormat("", m_uTotalQuads)->getCString(); } diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index 8bb6cf5fe1..2eb64308d6 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -32,7 +32,6 @@ THE SOFTWARE. #include "CCTextureCache.h" #include "CCTexture2D.h" #include "ccMacros.h" -#include "CCData.h" #include "CCDirector.h" #include "platform/platform.h" #include "CCFileUtils.h" @@ -235,7 +234,7 @@ void CCTextureCache::purgeSharedTextureCache() const char* CCTextureCache::description() { - return CCString::stringWithFormat("", m_pTextures->count())->getCString(); + return CCString::createWithFormat("", m_pTextures->count())->getCString(); } CCDictionary* CCTextureCache::snapshotTextures() @@ -440,7 +439,7 @@ CCTexture2D * CCTextureCache::addImage(const char * path) CCImage image; unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(fullpath.c_str(), "rb", &nSize); + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->getFileData(fullpath.c_str(), "rb", &nSize); CC_BREAK_IF(! image.initWithImageData((void*)pBuffer, nSize, eImageFormat)); texture = new CCTexture2D(); @@ -488,10 +487,12 @@ CCTexture2D* CCTextureCache::addPVRTCImage(const char* path, int bpp, bool hasAl // Split up directory and filename std::string fullpath( CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(path) ); - CCData * data = CCData::dataWithContentsOfFile(fullpath); + unsigned long nLen = 0; + unsigned char* pData = CCFileUtils::sharedFileUtils()->getFileData(fullpath.c_str(), "rb", &nLen); + texture = new CCTexture2D(); - if( texture->initWithPVRTCData(data->bytes(), 0, bpp, hasAlpha, width, + if( texture->initWithPVRTCData(pData, 0, bpp, hasAlpha, width, (bpp==2 ? kCCTexture2DPixelFormat_PVRTC2 : kCCTexture2DPixelFormat_PVRTC4))) { m_pTextures->setObject(texture, temp.c_str()); @@ -851,7 +852,7 @@ void VolatileTexture::reloadAllTextures() else { unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(vt->m_strFileName.c_str(), "rb", &nSize); + unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->getFileData(vt->m_strFileName.c_str(), "rb", &nSize); if (image.initWithImageData((void*)pBuffer, nSize, vt->m_FmtImage)) diff --git a/cocos2dx/textures/CCTexturePVR.cpp b/cocos2dx/textures/CCTexturePVR.cpp index c440773815..85167905df 100755 --- a/cocos2dx/textures/CCTexturePVR.cpp +++ b/cocos2dx/textures/CCTexturePVR.cpp @@ -27,7 +27,6 @@ THE SOFTWARE. #include "CCTexture2D.h" #include "CCTexturePVR.h" #include "ccMacros.h" -#include "CCData.h" #include "CCConfiguration.h" #include "support/ccUtils.h" #include "CCStdC.h" @@ -402,7 +401,7 @@ bool CCTexturePVR::initWithContentsOfFile(const char* path) } else { - pvrdata = CCFileUtils::sharedFileUtils()->sharedFileUtils()->getFileData(path, "rb", (unsigned long *)(&pvrlen)); + pvrdata = CCFileUtils::sharedFileUtils()->getFileData(path, "rb", (unsigned long *)(&pvrlen)); } if (pvrlen < 0) diff --git a/cocos2dx/textures/CCTexturePVR.h b/cocos2dx/textures/CCTexturePVR.h index 583cd5d212..70ce55544a 100644 --- a/cocos2dx/textures/CCTexturePVR.h +++ b/cocos2dx/textures/CCTexturePVR.h @@ -33,9 +33,6 @@ THE SOFTWARE. NS_CC_BEGIN -//Forward definition for CCData -class CCData; - /** @brief Structure which can tell where mimap begins and how long is it */ diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp index 2ac1a5e95c..cf962bd06b 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp @@ -75,7 +75,7 @@ bool CCTMXLayer::initWithTilesetInfo(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerIn m_uMinGID = layerInfo->m_uMinGID; m_uMaxGID = layerInfo->m_uMaxGID; m_cOpacity = layerInfo->m_cOpacity; - setProperties(CCDictionary::dictionaryWithDictionary(layerInfo->getProperties())); + setProperties(CCDictionary::createWithDictionary(layerInfo->getProperties())); m_fContentScaleFactor = CCDirector::sharedDirector()->getContentScaleFactor(); // tilesetInfo diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXObjectGroup.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXObjectGroup.cpp index 84f4a406ea..ff74ded472 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXObjectGroup.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXObjectGroup.cpp @@ -35,7 +35,7 @@ CCTMXObjectGroup::CCTMXObjectGroup() :m_tPositionOffset(CCPointZero) ,m_sGroupName("") { - m_pObjects = CCArray::array(); + m_pObjects = CCArray::create(); m_pObjects->retain(); m_pProperties = new CCDictionary(); } diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp index b32a1011d1..c58ba1b371 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp @@ -28,7 +28,6 @@ THE SOFTWARE. #include #include "CCTMXXMLParser.h" #include "CCTMXTiledMap.h" -#include "CCData.h" #include "ccMacros.h" #include "CCFileUtils.h" #include "support/zip_support/ZipUtils.h" @@ -150,10 +149,10 @@ CCTMXMapInfo * CCTMXMapInfo::formatWithXML(const char* tmxString, const char* re void CCTMXMapInfo::internalInit(const char* tmxFileName, const char* resourcePath) { - m_pTilesets = CCArray::array(); + m_pTilesets = CCArray::create(); m_pTilesets->retain(); - m_pLayers = CCArray::array(); + m_pLayers = CCArray::create(); m_pLayers->retain(); if (tmxFileName != NULL) @@ -166,7 +165,7 @@ void CCTMXMapInfo::internalInit(const char* tmxFileName, const char* resourcePat m_sResources = resourcePath; } - m_pObjectGroups = CCArray::arrayWithCapacity(4); + m_pObjectGroups = CCArray::create(4); m_pObjectGroups->retain(); m_pProperties = new CCDictionary(); @@ -284,13 +283,6 @@ bool CCTMXMapInfo::parseXMLString(const char *xmlString) return parser.parse(xmlString, len); } -bool CCTMXMapInfo::parseXMLData(const CCData* data) -{ - //TODO: implementation. - CCAssert(false, "not implement!"); - return false; -} - bool CCTMXMapInfo::parseXMLFile(const char *xmlFilename) { CCSAXParser parser; diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.h b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.h index dcc8cd1e64..7dacf16fdb 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.h @@ -37,7 +37,6 @@ THE SOFTWARE. NS_CC_BEGIN -class CCData; class CCTMXObjectGroup; /** @file @@ -181,8 +180,6 @@ public: bool parseXMLFile(const char *xmlFilename); /* initalises parsing of an XML string, either a tmx (Map) string or tsx (Tileset) string */ bool parseXMLString(const char *xmlString); - /* handles the work of parsing for parseXMLFile: and parseXMLString: */ - bool parseXMLData(const CCData* data); CCDictionary* getTileProperties(); void setTileProperties(CCDictionary* tileProperties); diff --git a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp index 96bc83f4fa..a14274fc3f 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp @@ -157,7 +157,7 @@ void CCTileMapAtlas::setTile(const ccColor3B& tile, const ccGridSize& position) // XXX: this method consumes a lot of memory // XXX: a tree of something like that shall be impolemented - CCInteger *num = (CCInteger*)m_pPosToAtlasIndex->objectForKey(CCString::stringWithFormat("%d,%d", position.x, position.y)->getCString()); + CCInteger *num = (CCInteger*)m_pPosToAtlasIndex->objectForKey(CCString::createWithFormat("%d,%d", position.x, position.y)->getCString()); this->updateAtlasValueAt(position, tile, num->getValue()); } } @@ -251,8 +251,8 @@ void CCTileMapAtlas::updateAtlasValues() { this->updateAtlasValueAt(ccg(x,y), value, total); - CCString *key = CCString::stringWithFormat("%d,%d", x,y); - CCInteger *num = CCInteger::integerWithInt(total); + CCString *key = CCString::createWithFormat("%d,%d", x,y); + CCInteger *num = CCInteger::create(total); m_pPosToAtlasIndex->setObject(num, key->getCString()); total++; diff --git a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp index 544276241c..3435c5ccea 100644 --- a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp +++ b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp @@ -67,11 +67,11 @@ void CCTouchDispatcher::setDispatchEvents(bool bDispatchEvents) bool CCTouchDispatcher::init(void) { m_bDispatchEvents = true; - m_pTargetedHandlers = CCArray::arrayWithCapacity(8); + m_pTargetedHandlers = CCArray::create(8); m_pTargetedHandlers->retain(); - m_pStandardHandlers = CCArray::arrayWithCapacity(4); + m_pStandardHandlers = CCArray::create(4); m_pStandardHandlers->retain(); - m_pHandlersToAdd = CCArray::arrayWithCapacity(8); + m_pHandlersToAdd = CCArray::create(8); m_pHandlersToAdd->retain(); m_pHandlersToRemove = ccCArrayNew(8); diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp index b08b66ae01..f33e4d4fa2 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp @@ -32,7 +32,7 @@ bool CCControlButtonTest_HelloVariableSize::init() CCSize screenSize = CCDirector::sharedDirector()->getWinSize(); // Defines an array of title to create buttons dynamically - CCArray *stringArray = CCArray::arrayWithObjects( + CCArray *stringArray = CCArray::create( ccs("Hello"), ccs("Variable"), ccs("Size"), @@ -151,42 +151,42 @@ bool CCControlButtonTest_Event::init() void CCControlButtonTest_Event::touchDownAction(CCObject *sender) { - m_pDisplayValueLabel->setString(CCString::stringWithFormat("Touch Down")->getCString()); + m_pDisplayValueLabel->setString(CCString::createWithFormat("Touch Down")->getCString()); } void CCControlButtonTest_Event::touchDragInsideAction(CCObject *sender) { - m_pDisplayValueLabel->setString(CCString::stringWithFormat("Drag Inside")->getCString()); + m_pDisplayValueLabel->setString(CCString::createWithFormat("Drag Inside")->getCString()); } void CCControlButtonTest_Event::touchDragOutsideAction(CCObject *sender) { - m_pDisplayValueLabel->setString(CCString::stringWithFormat("Drag Outside")->getCString()); + m_pDisplayValueLabel->setString(CCString::createWithFormat("Drag Outside")->getCString()); } void CCControlButtonTest_Event::touchDragEnterAction(CCObject *sender) { - m_pDisplayValueLabel->setString(CCString::stringWithFormat("Drag Enter")->getCString()); + m_pDisplayValueLabel->setString(CCString::createWithFormat("Drag Enter")->getCString()); } void CCControlButtonTest_Event::touchDragExitAction(CCObject *sender) { - m_pDisplayValueLabel->setString(CCString::stringWithFormat("Drag Exit")->getCString()); + m_pDisplayValueLabel->setString(CCString::createWithFormat("Drag Exit")->getCString()); } void CCControlButtonTest_Event::touchUpInsideAction(CCObject *sender) { - m_pDisplayValueLabel->setString(CCString::stringWithFormat("Touch Up Inside.")->getCString()); + m_pDisplayValueLabel->setString(CCString::createWithFormat("Touch Up Inside.")->getCString()); } void CCControlButtonTest_Event::touchUpOutsideAction(CCObject *sender) { - m_pDisplayValueLabel->setString(CCString::stringWithFormat("Touch Up Outside.")->getCString()); + m_pDisplayValueLabel->setString(CCString::createWithFormat("Touch Up Outside.")->getCString()); } void CCControlButtonTest_Event::touchCancelAction(CCObject *sender) { - m_pDisplayValueLabel->setString(CCString::stringWithFormat("Touch Cancel")->getCString()); + m_pDisplayValueLabel->setString(CCString::createWithFormat("Touch Cancel")->getCString()); } @@ -209,7 +209,7 @@ bool CCControlButtonTest_Styling::init() for (int j = 0; j < 3; j++) { // Add the buttons - CCControlButton *button = standardButtonWithTitle(CCString::stringWithFormat("%d",rand() % 30)->getCString()); + CCControlButton *button = standardButtonWithTitle(CCString::createWithFormat("%d",rand() % 30)->getCString()); button->setAdjustBackgroundImage(false); // Tells the button that the background image must not be adjust // It'll use the prefered size of the background image button->setPosition(ccp (button->getContentSize().width / 2 + (button->getContentSize().width + space) * i, diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp index e9fda7c44d..f591024f12 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp @@ -90,7 +90,7 @@ CCControlColourPickerTest::~CCControlColourPickerTest() void CCControlColourPickerTest::colourValueChanged(CCObject *sender) { CCControlColourPicker* pPicker = (CCControlColourPicker*)sender; - m_pColorLabel->setString(CCString::stringWithFormat("#%02X%02X%02X",pPicker->getColorValue().r, pPicker->getColorValue().g, pPicker->getColorValue().b)->getCString()); + m_pColorLabel->setString(CCString::createWithFormat("#%02X%02X%02X",pPicker->getColorValue().r, pPicker->getColorValue().g, pPicker->getColorValue().b)->getCString()); } diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp index 50c5f8332a..e992f9d6eb 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp @@ -69,6 +69,6 @@ void CCControlSliderTest::valueChanged(CCObject *sender) { CCControlSlider* pSlider = (CCControlSlider*)sender; // Change value of label. - m_pDisplayValueLabel->setString(CCString::stringWithFormat("Slider value = %.02f", pSlider->getValue())->getCString()); + m_pDisplayValueLabel->setString(CCString::createWithFormat("Slider value = %.02f", pSlider->getValue())->getCString()); } diff --git a/tests/tests/LabelTest/LabelTest.cpp b/tests/tests/LabelTest/LabelTest.cpp index 637753efe0..21e21dd7ef 100644 --- a/tests/tests/LabelTest/LabelTest.cpp +++ b/tests/tests/LabelTest/LabelTest.cpp @@ -342,7 +342,7 @@ void LabelAtlasColorTest::step(float dt) m_time += dt; char string[12] = {0}; sprintf(string, "%2.2f Test", m_time); - //std::string string = std::string::stringWithFormat("%2.2f Test", m_time); + //std::string string = std::string::createWithFormat("%2.2f Test", m_time); CCLabelAtlas* label1 = (CCLabelAtlas*)getChildByTag(kTagSprite1); label1->setString(string); @@ -1069,7 +1069,7 @@ const char* LabelTTFTest::getCurrentAlignment() break; } - return CCString::stringWithFormat("Alignment %s %s", vertical, horizontal)->getCString(); + return CCString::createWithFormat("Alignment %s %s", vertical, horizontal)->getCString(); } string LabelTTFTest::title() @@ -1390,7 +1390,7 @@ std::string BMFontOneAtlas::subtitle() /// BMFontUnicode BMFontUnicode::BMFontUnicode() { - CCDictionary *strings = CCDictionary::dictionaryWithContentsOfFile("fonts/strings.xml"); + CCDictionary *strings = CCDictionary::createWithContentsOfFile("fonts/strings.xml"); const char *chinese = ((CCString*)strings->objectForKey("chinese1"))->m_sString.c_str(); const char *japanese = ((CCString*)strings->objectForKey("japanese"))->m_sString.c_str(); const char *spanish = ((CCString*)strings->objectForKey("spanish"))->m_sString.c_str(); diff --git a/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp b/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp index b29281c3cc..a7ded9ab5e 100644 --- a/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -376,7 +376,7 @@ void AddSpriteSheet::update(float dt) if( totalToAdd > 0 ) { - CCArray* sprites = CCArray::arrayWithCapacity(totalToAdd); + CCArray* sprites = CCArray::create(totalToAdd); int *zs = new int[totalToAdd]; // Don't include the sprite creation time and random as part of the profiling @@ -440,7 +440,7 @@ void RemoveSpriteSheet::update(float dt) if( totalToAdd > 0 ) { - CCArray* sprites = CCArray::arrayWithCapacity(totalToAdd); + CCArray* sprites = CCArray::create(totalToAdd); // Don't include the sprite creation time as part of the profiling for(int i=0;i 0 ) { - CCArray* sprites = CCArray::arrayWithCapacity(totalToAdd); + CCArray* sprites = CCArray::create(totalToAdd); // Don't include the sprite creation time as part of the profiling for(int i=0;ifullPathFromRelativePath("Shaders/example_Blur.fsh"))->getCString(); CCGLProgram* pProgram = new CCGLProgram(); pProgram->initWithVertexShaderByteArray(ccPositionTextureColor_vert, fragSource); @@ -630,7 +630,7 @@ bool ShaderRetroEffect::init() { if( ShaderTestDemo::init() ) { - GLchar * fragSource = (GLchar*) CCString::stringWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("Shaders/example_HorizontalColor.fsh"))->getCString(); + GLchar * fragSource = (GLchar*) CCString::createWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("Shaders/example_HorizontalColor.fsh"))->getCString(); CCGLProgram *p = new CCGLProgram(); p->initWithVertexShaderByteArray(ccPositionTexture_vert, fragSource); diff --git a/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id b/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id index 57683d0f9e..9ee094da2e 100644 --- a/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id +++ b/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id @@ -1 +1 @@ -6824810bc1cfa5dd0dbf72f9966524b82ebe0a52 \ No newline at end of file +23a3acf70514939732acc9dab32c55a9bfddbc46 \ No newline at end of file diff --git a/tests/tests/TileMapTest/TileMapTest.cpp b/tests/tests/TileMapTest/TileMapTest.cpp index 4cd79dabdc..aee87bfff1 100644 --- a/tests/tests/TileMapTest/TileMapTest.cpp +++ b/tests/tests/TileMapTest/TileMapTest.cpp @@ -1254,7 +1254,7 @@ TMXOrthoFromXMLTest::TMXOrthoFromXMLTest() string resources = "TileMaps"; // partial paths are OK as resource paths. string file = resources + "/orthogonal-test1.tmx"; - CCString* str = CCString::stringWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(file.c_str())); + CCString* str = CCString::createWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(file.c_str())); CCAssert(str != NULL, "Unable to open file"); CCTMXTiledMap *map = CCTMXTiledMap::create(str->getCString() ,resources.c_str()); diff --git a/tests/tests/TouchesTest/TouchesTest.cpp b/tests/tests/TouchesTest/TouchesTest.cpp index fd34bb4f12..4bfcadda60 100644 --- a/tests/tests/TouchesTest/TouchesTest.cpp +++ b/tests/tests/TouchesTest/TouchesTest.cpp @@ -54,7 +54,7 @@ PongLayer::PongLayer() CCTexture2D* paddleTexture = CCTextureCache::sharedTextureCache()->addImage(s_Paddle); - CCArray *paddlesM = CCArray::arrayWithCapacity(4); + CCArray *paddlesM = CCArray::create(4); Paddle* paddle = Paddle::paddleWithTexture(paddleTexture); paddle->setPosition( CCPointMake(m_tWinSize.width/2, 15) ); From 4c6bf89167e8363443af647e14d82c19de0b4453 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Thu, 14 Jun 2012 01:16:54 -0700 Subject: [PATCH 163/257] Cleaned up public interface of CCNodeLoaderLibrary (now takes either const char * or CCString, instead of std::string). --- cocos2dx/extensions/CCBReader/CCBReader.cpp | 2 +- cocos2dx/extensions/CCBReader/CCNodeLoader.cpp | 4 ++-- .../extensions/CCBReader/CCNodeLoaderLibrary.cpp | 15 ++++++++++----- .../extensions/CCBReader/CCNodeLoaderLibrary.h | 9 ++++++--- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/cocos2dx/extensions/CCBReader/CCBReader.cpp b/cocos2dx/extensions/CCBReader/CCBReader.cpp index ae644deaf3..0dd0fea3e3 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader.cpp @@ -285,7 +285,7 @@ CCNode * CCBReader::readNodeGraph(CCNode * pParent) { memberVarAssignmentName = this->readCachedString(); } - CCNodeLoader * ccNodeLoader = this->mCCNodeLoaderLibrary->getCCNodeLoader(className->m_sString); + CCNodeLoader * ccNodeLoader = this->mCCNodeLoaderLibrary->getCCNodeLoader(className); CCNode * node = ccNodeLoader->loadCCNode(pParent, this); /* Set root node, if not set yet. */ diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp index ad655e6a2a..e14056cb06 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp @@ -11,8 +11,8 @@ #define PROPERTY_IGNOREANCHORPOINTFORPOSITION "ignoreAnchorPointForPosition" #define PROPERTY_VISIBLE "visible" -#define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) CCLOG("Unexpected property: '%s'!\n", PROPERTY->getCString()); assert(false) -#define ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) CCLOG("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false) +#define ASSERT_FAIL_UNEXPECTED_PROPERTY(PROPERTY) CCLog("Unexpected property: '%s'!\n", PROPERTY->getCString()); assert(false) +#define ASSERT_FAIL_UNEXPECTED_PROPERTYTYPE(PROPERTYTYPE) CCLog("Unexpected property type: '%d'!\n", PROPERTYTYPE); assert(false) USING_NS_CC; USING_NS_CC_EXT; diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp index c8014ebaba..759861ac08 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp +++ b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp @@ -41,19 +41,24 @@ void CCNodeLoaderLibrary::registerDefaultCCNodeLoaders() { this->registerCCNodeLoader("CCParticleSystemQuad", CCParticleSystemQuadLoader::loader()); } -void CCNodeLoaderLibrary::registerCCNodeLoader(std::string pClassName, CCNodeLoader * pCCNodeLoader) { +void CCNodeLoaderLibrary::registerCCNodeLoader(const char * pClassName, CCNodeLoader * pCCNodeLoader) { pCCNodeLoader->retain(); this->mCCNodeLoaders.insert(std::pair(pClassName, pCCNodeLoader)); } -void CCNodeLoaderLibrary::unregisterCCNodeLoader(std::string pClassName) { - std::map::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName); +void CCNodeLoaderLibrary::registerCCNodeLoader(CCString * pClassName, CCNodeLoader * pCCNodeLoader) { + pCCNodeLoader->retain(); + this->mCCNodeLoaders.insert(std::pair(pClassName->m_sString, pCCNodeLoader)); +} + +void CCNodeLoaderLibrary::unregisterCCNodeLoader(CCString * pClassName) { + std::map::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName->m_sString); assert(ccNodeLoadersIterator != this->mCCNodeLoaders.end()); ccNodeLoadersIterator->second->release(); } -CCNodeLoader * CCNodeLoaderLibrary::getCCNodeLoader(std::string pClassName) { - std::map::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName); +CCNodeLoader * CCNodeLoaderLibrary::getCCNodeLoader(CCString * pClassName) { + std::map::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName->m_sString); assert(ccNodeLoadersIterator != this->mCCNodeLoaders.end()); return ccNodeLoadersIterator->second; } diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h index 05352fbcca..17eedec1dc 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h +++ b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h @@ -17,9 +17,12 @@ class CC_DLL CCNodeLoaderLibrary : public CCObject { ~CCNodeLoaderLibrary(); void registerDefaultCCNodeLoaders(); - void registerCCNodeLoader(std::string pClassName, CCNodeLoader * pCCNodeLoader); - void unregisterCCNodeLoader(std::string pClassName); - CCNodeLoader * getCCNodeLoader(std::string pClassName); + void registerCCNodeLoader(const char * pClassName, CCNodeLoader * pCCNodeLoader); + void registerCCNodeLoader(CCString * pClassName, CCNodeLoader * pCCNodeLoader); + void unregisterCCNodeLoader(const char * pClassName); + void unregisterCCNodeLoader(CCString * pClassName); + CCNodeLoader * getCCNodeLoader(const char * pClassName); + CCNodeLoader * getCCNodeLoader(CCString * pClassName); void purge(bool pDelete); public: From cc5eabeb28016d5eb62d7b775263f9ebfb666b99 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Thu, 14 Jun 2012 01:32:52 -0700 Subject: [PATCH 164/257] ButtonTestLayer: Now showing the CCControlEvent information on screen. Fixed CCLOG -> CCLog (because CCLOG doesn't show up on Android.). --- .../CocosBuilderTest/ButtonTestLayer.cpp | 44 ++++++++++++++++++- .../CocosBuilderTest/ButtonTestLayer.h | 7 ++- .../CocosBuilderTest/CocosBuilderTest.cpp | 2 - .../HelloCocosBuilderLayer.cpp | 12 ++--- 4 files changed, 55 insertions(+), 10 deletions(-) diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.cpp index b827a4a96b..a8bb330c03 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.cpp +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.cpp @@ -28,6 +28,48 @@ SEL_CCControlHandler ButtonTestLayer::onResolveCCBCCControlSelector(CCObject * p return NULL; } +bool ButtonTestLayer::onAssignCCBMemberVariable(CCObject * pTarget, CCString * pMemberVariableName, CCNode * pNode) { + if(pTarget == this) { + if(strcmp(pMemberVariableName->getCString(), "mCCControlEventLabel") == 0) { + this->mCCControlEventLabel = dynamic_cast(pNode); + CC_ASSERT(this->mCCControlEventLabel); + this->mCCControlEventLabel->retain(); + return true; + } + } + return false; +} + void ButtonTestLayer::onCCControlButtonClicked(cocos2d::CCObject *pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - CCLOG("onCCControlButtonClicked\n"); + switch(pCCControlEvent) { + case CCControlEventTouchDown: + this->mCCControlEventLabel->setString("Touch Down."); + break; + case CCControlEventTouchDragInside: + this->mCCControlEventLabel->setString("Touch Drag Inside."); + break; + case CCControlEventTouchDragOutside: + this->mCCControlEventLabel->setString("Touch Drag Outside."); + break; + case CCControlEventTouchDragEnter: + this->mCCControlEventLabel->setString("Touch Drag Enter."); + break; + case CCControlEventTouchDragExit: + this->mCCControlEventLabel->setString("Touch Drag Exit."); + break; + case CCControlEventTouchUpInside: + this->mCCControlEventLabel->setString("Touch Up Inside."); + break; + case CCControlEventTouchUpOutside: + this->mCCControlEventLabel->setString("Touch Up Outside."); + break; + case CCControlEventTouchCancel: + this->mCCControlEventLabel->setString("Touch Cancel."); + break; + case CCControlEventValueChanged: + this->mCCControlEventLabel->setString("Value Changed."); + break; + default: + assert(false); // OH SHIT! + } } \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.h index b0d00928a8..a8c6dcbd7d 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.h @@ -4,15 +4,20 @@ #include "cocos2d.h" #include "extensions/CCBReader/CCNodeLoader.h" #include "extensions/CCBReader/CCBSelectorResolver.h" +#include "extensions/CCBReader/CCBMemberVariableAssigner.h" -class ButtonTestLayer : public cocos2d::extension::CCBSelectorResolver, public cocos2d::CCLayer { +class ButtonTestLayer : public cocos2d::extension::CCBSelectorResolver, public cocos2d::extension::CCBMemberVariableAssigner, public cocos2d::CCLayer { public: static ButtonTestLayer * node(); virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); + virtual bool onAssignCCBMemberVariable(cocos2d::CCObject * pTarget, cocos2d::CCString * pMemberVariableName, cocos2d::CCNode * pNode); virtual void onCCControlButtonClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); + + private: + cocos2d::CCLabelBMFont * mCCControlEventLabel; }; #endif \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp index b8ff6499ee..34e89c9fdf 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp @@ -32,8 +32,6 @@ USING_NS_CC; USING_NS_CC_EXT; void CocosBuilderTestScene::runThisTest() { - CCLog("HELLO WORLD"); - /* Create an autorelease CCNodeLoaderLibrary. */ CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary(); diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.cpp index ed172a9a3f..7ec673abce 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.cpp +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.cpp @@ -107,26 +107,26 @@ bool HelloCocosBuilderLayer::onAssignCCBMemberVariable(CCObject * pTarget, CCStr void HelloCocosBuilderLayer::onMenuTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - CCLOG("onMenuTestClicked\n"); + CCLog("onMenuTestClicked\n"); } void HelloCocosBuilderLayer::onSpriteTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - CCLOG("onSpriteTestClicked\n"); + CCLog("onSpriteTestClicked\n"); } void HelloCocosBuilderLayer::onButtonTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - CCLOG("onButtonTestClicked\n"); + CCLog("onButtonTestClicked\n"); this->openTest("ccb/ButtonTest.ccbi", "ButtonTestLayer", ButtonTestLayerLoader::loader()); } void HelloCocosBuilderLayer::onLabelTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - CCLOG("onLabelTestClicked\n"); + CCLog("onLabelTestClicked\n"); } void HelloCocosBuilderLayer::onParticleSystemTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - CCLOG("onParticleSystemTestClicked\n"); + CCLog("onParticleSystemTestClicked\n"); } void HelloCocosBuilderLayer::onScrollViewTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - CCLOG("onScrollViewTestClicked\n"); + CCLog("onScrollViewTestClicked\n"); } \ No newline at end of file From 7fe3f7357ea9aa1257a3ecfca1cf9d2d9f77d215 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 14 Jun 2012 17:18:05 +0800 Subject: [PATCH 165/257] issue #1324: Reverted old interfaces. --- cocos2dx/actions/CCAction.cpp | 40 +- cocos2dx/actions/CCAction.h | 6 +- cocos2dx/actions/CCActionCamera.cpp | 15 +- cocos2dx/actions/CCActionCamera.h | 2 +- cocos2dx/actions/CCActionCatmullRom.cpp | 64 +-- cocos2dx/actions/CCActionCatmullRom.h | 10 +- cocos2dx/actions/CCActionEase.cpp | 462 +++------------- cocos2dx/actions/CCActionEase.h | 44 +- cocos2dx/actions/CCActionGrid.cpp | 116 +--- cocos2dx/actions/CCActionGrid.h | 16 +- cocos2dx/actions/CCActionGrid3D.cpp | 198 ++----- cocos2dx/actions/CCActionGrid3D.h | 24 +- cocos2dx/actions/CCActionInstant.cpp | 187 +++---- cocos2dx/actions/CCActionInstant.h | 22 +- cocos2dx/actions/CCActionInterval.cpp | 500 ++++++------------ cocos2dx/actions/CCActionInterval.h | 66 +-- cocos2dx/actions/CCActionPageTurn3D.cpp | 22 +- cocos2dx/actions/CCActionPageTurn3D.h | 2 +- cocos2dx/actions/CCActionProgressTimer.cpp | 24 +- cocos2dx/actions/CCActionProgressTimer.h | 4 +- cocos2dx/actions/CCActionTiledGrid.cpp | 281 ++-------- cocos2dx/actions/CCActionTiledGrid.h | 32 +- cocos2dx/actions/CCActionTween.cpp | 17 +- cocos2dx/actions/CCActionTween.h | 2 +- cocos2dx/base_nodes/CCAtlasNode.cpp | 10 +- cocos2dx/base_nodes/CCAtlasNode.h | 4 +- cocos2dx/base_nodes/CCNode.cpp | 8 +- cocos2dx/base_nodes/CCNode.h | 2 +- cocos2dx/cocoa/CCArray.cpp | 98 ++-- cocos2dx/cocoa/CCArray.h | 14 +- cocos2dx/cocoa/CCDictionary.cpp | 32 +- cocos2dx/cocoa/CCDictionary.h | 8 +- cocos2dx/cocoa/CCInteger.h | 8 +- cocos2dx/cocoa/CCString.cpp | 44 +- cocos2dx/cocoa/CCString.h | 8 +- cocos2dx/effects/CCGrid.cpp | 16 +- cocos2dx/effects/CCGrid.h | 4 +- .../CCControlExtension/CCControlButton.cpp | 24 +- .../CCControlExtension/CCControlButton.h | 6 +- .../CCControlColourPicker.cpp | 8 +- .../CCControlColourPicker.h | 2 +- .../CCControlExtension/CCControlHuePicker.cpp | 8 +- .../CCControlExtension/CCControlHuePicker.h | 2 +- .../CCControlSaturationBrightnessPicker.cpp | 8 +- .../CCControlSaturationBrightnessPicker.h | 2 +- .../CCControlExtension/CCControlSlider.cpp | 16 +- .../CCControlExtension/CCControlSlider.h | 4 +- .../CCControlExtension/CCControlSwitch.cpp | 16 +- .../CCControlExtension/CCControlSwitch.h | 4 +- .../CCControlExtension/CCMenuPassive.cpp | 46 +- .../CCControlExtension/CCMenuPassive.h | 6 +- .../CCControlExtension/CCScale9Sprite.cpp | 72 +-- .../CCControlExtension/CCScale9Sprite.h | 18 +- cocos2dx/extensions/CCListView/CCListView.cpp | 8 +- cocos2dx/extensions/CCListView/CCListView.h | 2 +- cocos2dx/label_nodes/CCLabelAtlas.cpp | 16 +- cocos2dx/label_nodes/CCLabelAtlas.h | 4 +- cocos2dx/label_nodes/CCLabelBMFont.cpp | 16 +- cocos2dx/label_nodes/CCLabelBMFont.h | 4 +- cocos2dx/label_nodes/CCLabelTTF.cpp | 24 +- cocos2dx/label_nodes/CCLabelTTF.h | 10 +- .../CCLayer.cpp | 82 +-- .../layers_scenes_transitions_nodes/CCLayer.h | 80 +-- .../CCScene.cpp | 8 +- .../layers_scenes_transitions_nodes/CCScene.h | 62 +-- .../CCTransition.cpp | 64 +-- .../CCTransition.h | 18 +- .../CCTransitionPageTurn.cpp | 8 +- .../CCTransitionPageTurn.h | 2 +- cocos2dx/menu_nodes/CCMenu.cpp | 54 +- cocos2dx/menu_nodes/CCMenu.h | 8 +- cocos2dx/menu_nodes/CCMenuItem.cpp | 140 ++--- cocos2dx/menu_nodes/CCMenuItem.h | 32 +- cocos2dx/misc_nodes/CCMotionStreak.cpp | 16 +- cocos2dx/misc_nodes/CCMotionStreak.h | 4 +- cocos2dx/misc_nodes/CCProgressTimer.cpp | 8 +- cocos2dx/misc_nodes/CCProgressTimer.h | 2 +- cocos2dx/misc_nodes/CCRenderTexture.cpp | 24 +- cocos2dx/misc_nodes/CCRenderTexture.h | 6 +- .../particle_nodes/CCParticleBatchNode.cpp | 16 +- cocos2dx/particle_nodes/CCParticleBatchNode.h | 4 +- cocos2dx/particle_nodes/CCParticleSystem.cpp | 8 +- cocos2dx/particle_nodes/CCParticleSystem.h | 2 +- .../particle_nodes/CCParticleSystemQuad.cpp | 8 +- .../particle_nodes/CCParticleSystemQuad.h | 2 +- cocos2dx/sprite_nodes/CCAnimation.cpp | 24 +- cocos2dx/sprite_nodes/CCAnimation.h | 6 +- cocos2dx/sprite_nodes/CCSprite.cpp | 56 +- cocos2dx/sprite_nodes/CCSprite.h | 14 +- cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp | 16 +- cocos2dx/sprite_nodes/CCSpriteBatchNode.h | 4 +- cocos2dx/sprite_nodes/CCSpriteFrame.cpp | 32 +- cocos2dx/sprite_nodes/CCSpriteFrame.h | 8 +- .../tileMap_parallax_nodes/CCParallaxNode.cpp | 8 +- .../tileMap_parallax_nodes/CCParallaxNode.h | 2 +- .../tileMap_parallax_nodes/CCTMXLayer.cpp | 8 +- cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h | 2 +- .../tileMap_parallax_nodes/CCTMXTiledMap.cpp | 16 +- .../tileMap_parallax_nodes/CCTMXTiledMap.h | 4 +- .../tileMap_parallax_nodes/CCTileMapAtlas.cpp | 8 +- .../tileMap_parallax_nodes/CCTileMapAtlas.h | 2 +- 101 files changed, 1317 insertions(+), 2289 deletions(-) diff --git a/cocos2dx/actions/CCAction.cpp b/cocos2dx/actions/CCAction.cpp index 45b60b6821..05ae20b8f1 100644 --- a/cocos2dx/actions/CCAction.cpp +++ b/cocos2dx/actions/CCAction.cpp @@ -48,12 +48,10 @@ CCAction::~CCAction() CCLOGINFO("cocos2d: deallocing"); } -//cjh CCAction * CCAction::action() -// { -// CCAction * pRet = new CCAction(); -// pRet->autorelease(); -// return pRet; -// } +CCAction * CCAction::action() +{ + return CCAction::create(); +} CCAction* CCAction::create() { @@ -131,17 +129,10 @@ CCSpeed::~CCSpeed() CC_SAFE_RELEASE(m_pInnerAction); } -//cjh CCSpeed * CCSpeed::actionWithAction(CCActionInterval *pAction, float fSpeed) -// { -// CCSpeed *pRet = new CCSpeed(); -// if (pRet && pRet->initWithAction(pAction, fSpeed)) -// { -// pRet->autorelease(); -// return pRet; -// } -// CC_SAFE_DELETE(pRet); -// return NULL; -// } +CCSpeed * CCSpeed::actionWithAction(CCActionInterval *pAction, float fSpeed) +{ + return CCSpeed::create(pAction, fSpeed); +} CCSpeed* CCSpeed::create(CCActionInterval* pAction, float fSpeed) { @@ -230,17 +221,10 @@ CCFollow::~CCFollow() CC_SAFE_RELEASE(m_pobFollowedNode); } -//cjh CCFollow *CCFollow::actionWithTarget(CCNode *pFollowedNode, const CCRect& rect/* = CCRectZero*/) -// { -// CCFollow *pRet = new CCFollow(); -// if (pRet && pRet->initWithTarget(pFollowedNode, rect)) -// { -// pRet->autorelease(); -// return pRet; -// } -// CC_SAFE_DELETE(pRet); -// return NULL; -// } +CCFollow *CCFollow::actionWithTarget(CCNode *pFollowedNode, const CCRect& rect/* = CCRectZero*/) +{ + return CCFollow::create(pFollowedNode, rect); +} CCFollow* CCFollow::create(CCNode *pFollowedNode, const CCRect& rect/* = CCRectZero*/) { diff --git a/cocos2dx/actions/CCAction.h b/cocos2dx/actions/CCAction.h index 750a2684c0..cc0fcf1362 100644 --- a/cocos2dx/actions/CCAction.h +++ b/cocos2dx/actions/CCAction.h @@ -94,7 +94,7 @@ public: /** Allocates and initializes the action @warning: This interface will be deprecated in future. */ - //static CCAction* action(); + static CCAction* action(); /** Create an action */ static CCAction* create(); @@ -181,7 +181,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCSpeed* actionWithAction(CCActionInterval *pAction, float fSpeed); + static CCSpeed* actionWithAction(CCActionInterval *pAction, float fSpeed); /** create the action */ static CCSpeed* create(CCActionInterval* pAction, float fSpeed); @@ -230,7 +230,7 @@ public: It will work with no boundary if @param rect is equal to CCRectZero. @warning: This interface will be deprecated in future. */ - //static CCFollow* actionWithTarget(CCNode *pFollowedNode, const CCRect& rect = CCRectZero); + static CCFollow* actionWithTarget(CCNode *pFollowedNode, const CCRect& rect = CCRectZero); /** creates the action with a set boundary, It will work with no boundary if @param rect is equal to CCRectZero. */ diff --git a/cocos2dx/actions/CCActionCamera.cpp b/cocos2dx/actions/CCActionCamera.cpp index d871f9d71c..7b49d83349 100644 --- a/cocos2dx/actions/CCActionCamera.cpp +++ b/cocos2dx/actions/CCActionCamera.cpp @@ -50,17 +50,10 @@ CCActionInterval * CCActionCamera::reverse() // // CCOrbitCamera // -//cjh CCOrbitCamera * CCOrbitCamera::actionWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX) -// { -// CCOrbitCamera * pRet = new CCOrbitCamera(); -// if(pRet->initWithDuration(t, radius, deltaRadius, angleZ, deltaAngleZ, angleX, deltaAngleX)) -// { -// pRet->autorelease(); -// return pRet; -// } -// CC_SAFE_DELETE(pRet); -// return NULL; -// } +CCOrbitCamera * CCOrbitCamera::actionWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX) +{ + return CCOrbitCamera::create(t, radius, deltaRadius, angleZ, deltaAngleZ, angleX, deltaAngleX); +} CCOrbitCamera * CCOrbitCamera::create(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX) { diff --git a/cocos2dx/actions/CCActionCamera.h b/cocos2dx/actions/CCActionCamera.h index 38f46151cb..49a5d18c20 100644 --- a/cocos2dx/actions/CCActionCamera.h +++ b/cocos2dx/actions/CCActionCamera.h @@ -90,7 +90,7 @@ public: /** creates a CCOrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX @warning: This interface will be deprecated in future. */ - //static CCOrbitCamera* actionWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX); + static CCOrbitCamera* actionWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX); /** creates a CCOrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX */ static CCOrbitCamera* create(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX); diff --git a/cocos2dx/actions/CCActionCatmullRom.cpp b/cocos2dx/actions/CCActionCatmullRom.cpp index ee6060cee8..abce168a15 100644 --- a/cocos2dx/actions/CCActionCatmullRom.cpp +++ b/cocos2dx/actions/CCActionCatmullRom.cpp @@ -44,24 +44,10 @@ NS_CC_BEGIN; /* * Implementation of CCPointArray */ -//cjh CCPointArray* CCPointArray::arrayWithCapacity(unsigned int capacity) -// { -// CCPointArray* ret = new CCPointArray(); -// if (ret) -// { -// if (ret->initWithCapacity(capacity)) -// { -// ret->autorelease(); -// } -// else -// { -// delete ret; -// ret = NULL; -// } -// } -// -// return ret; -// } +CCPointArray* CCPointArray::arrayWithCapacity(unsigned int capacity) +{ + return CCPointArray::create(capacity); +} CCPointArray* CCPointArray::create(unsigned int capacity) { @@ -213,23 +199,10 @@ CCPoint ccCardinalSplineAt(CCPoint &p0, CCPoint &p1, CCPoint &p2, CCPoint &p3, f /* Implementation of CCCardinalSplineTo */ -//cjh CCCardinalSplineTo* CCCardinalSplineTo::actionWithDuration(float duration, cocos2d::CCPointArray *points, float tension) -// { -// CCCardinalSplineTo *ret = new CCCardinalSplineTo(); -// if (ret) -// { -// if (ret->initWithDuration(duration, points, tension)) -// { -// ret->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(ret); -// } -// } -// -// return ret; -// } +CCCardinalSplineTo* CCCardinalSplineTo::actionWithDuration(float duration, cocos2d::CCPointArray *points, float tension) +{ + return CCCardinalSplineTo::create(duration, points, tension); +} CCCardinalSplineTo* CCCardinalSplineTo::create(float duration, cocos2d::CCPointArray *points, float tension) { @@ -348,23 +321,10 @@ CCActionInterval* CCCardinalSplineTo::reverse() /* CCCardinalSplineBy */ -//cjh CCCardinalSplineBy* CCCardinalSplineBy::actionWithDuration(float duration, cocos2d::CCPointArray *points, float tension) -// { -// CCCardinalSplineBy *ret = new CCCardinalSplineBy(); -// if (ret) -// { -// if (ret->initWithDuration(duration, points, tension)) -// { -// ret->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(ret); -// } -// } -// -// return ret; -// } +CCCardinalSplineBy* CCCardinalSplineBy::actionWithDuration(float duration, cocos2d::CCPointArray *points, float tension) +{ + return CCCardinalSplineBy::create(duration, points, tension); +} CCCardinalSplineBy* CCCardinalSplineBy::create(float duration, cocos2d::CCPointArray *points, float tension) { diff --git a/cocos2dx/actions/CCActionCatmullRom.h b/cocos2dx/actions/CCActionCatmullRom.h index a86e14e449..1477e468ef 100644 --- a/cocos2dx/actions/CCActionCatmullRom.h +++ b/cocos2dx/actions/CCActionCatmullRom.h @@ -52,7 +52,7 @@ public: /** creates and initializes a Points array with capacity @warning: This interface will be deprecated in future. */ - //static CCPointArray* arrayWithCapacity(unsigned int capacity); + static CCPointArray* arrayWithCapacity(unsigned int capacity); /** creates and initializes a Points array with capacity */ static CCPointArray* create(unsigned int capacity); @@ -110,7 +110,7 @@ public: /** creates an action with a Cardinal Spline array of points and tension @warning: This interface will be deprecated in future. */ - //static CCCardinalSplineTo* actionWithDuration(float duration, CCPointArray* points, float tension); + static CCCardinalSplineTo* actionWithDuration(float duration, CCPointArray* points, float tension); /** creates an action with a Cardinal Spline array of points and tension */ static CCCardinalSplineTo* create(float duration, CCPointArray* points, float tension); @@ -153,7 +153,7 @@ public: /** creates an action with a Cardinal Spline array of points and tension @warning: This interface will be deprecated in future. */ - //static CCCardinalSplineBy* actionWithDuration(float duration, CCPointArray* points, float tension); + static CCCardinalSplineBy* actionWithDuration(float duration, CCPointArray* points, float tension); /** creates an action with a Cardinal Spline array of points and tension */ static CCCardinalSplineBy* create(float duration, CCPointArray* points, float tension); @@ -177,7 +177,7 @@ public: /** creates an action with a Cardinal Spline array of points and tension @warning: This interface will be deprecated in future. */ - //static CCCatmullRomTo* actionWithDuration(float dt, CCPointArray* points); + static CCCatmullRomTo* actionWithDuration(float dt, CCPointArray* points); /** creates an action with a Cardinal Spline array of points and tension */ static CCCatmullRomTo* create(float dt, CCPointArray* points); @@ -196,7 +196,7 @@ public: /** creates an action with a Cardinal Spline array of points and tension @warning: This interface will be deprecated in future. */ - //static CCCatmullRomBy* actionWithDuration(float dt, CCPointArray* points); + static CCCatmullRomBy* actionWithDuration(float dt, CCPointArray* points); /** creates an action with a Cardinal Spline array of points and tension */ static CCCatmullRomBy* create(float dt, CCPointArray* points); diff --git a/cocos2dx/actions/CCActionEase.cpp b/cocos2dx/actions/CCActionEase.cpp index 0f5321c333..3908352adf 100644 --- a/cocos2dx/actions/CCActionEase.cpp +++ b/cocos2dx/actions/CCActionEase.cpp @@ -42,23 +42,10 @@ NS_CC_BEGIN // // EaseAction // -//cjh CCActionEase* CCActionEase::actionWithAction(CCActionInterval *pAction) -// { -// CCActionEase *pRet = new CCActionEase(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pRet); -// } -// } -// -// return pRet; -// } +CCActionEase* CCActionEase::actionWithAction(CCActionInterval *pAction) +{ + return CCActionEase::create(pAction); +} CCActionEase* CCActionEase::create(CCActionInterval *pAction) { @@ -146,23 +133,10 @@ CCActionInterval* CCActionEase::reverse(void) // // EaseRateAction // -//cjh CCEaseRateAction* CCEaseRateAction::actionWithAction(CCActionInterval *pAction, float fRate) -// { -// CCEaseRateAction *pRet = new CCEaseRateAction(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction, fRate)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pRet); -// } -// } -// -// return pRet; -// } +CCEaseRateAction* CCEaseRateAction::actionWithAction(CCActionInterval *pAction, float fRate) +{ + return CCEaseRateAction::create(pAction, fRate); +} CCEaseRateAction* CCEaseRateAction::create(CCActionInterval *pAction, float fRate) { @@ -226,23 +200,10 @@ CCActionInterval* CCEaseRateAction::reverse(void) // // EeseIn // -//cjh CCEaseIn* CCEaseIn::actionWithAction(CCActionInterval *pAction, float fRate) -// { -// CCEaseIn *pRet = new CCEaseIn(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction, fRate)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pRet); -// } -// } -// -// return pRet; -// } +CCEaseIn* CCEaseIn::actionWithAction(CCActionInterval *pAction, float fRate) +{ + return CCEaseIn::create(pAction, fRate); +} CCEaseIn* CCEaseIn::create(CCActionInterval *pAction, float fRate) { @@ -296,23 +257,10 @@ CCActionInterval* CCEaseIn::reverse(void) // // EaseOut // -//cjh CCEaseOut* CCEaseOut::actionWithAction(CCActionInterval *pAction, float fRate) -// { -// CCEaseOut *pRet = new CCEaseOut(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction, fRate)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pRet); -// } -// } -// -// return pRet; -// } +CCEaseOut* CCEaseOut::actionWithAction(CCActionInterval *pAction, float fRate) +{ + return CCEaseOut::create(pAction, fRate); +} CCEaseOut* CCEaseOut::create(CCActionInterval *pAction, float fRate) { @@ -366,23 +314,10 @@ CCActionInterval* CCEaseOut::reverse() // // EaseInOut // -//cjh CCEaseInOut* CCEaseInOut::actionWithAction(CCActionInterval *pAction, float fRate) -// { -// CCEaseInOut *pRet = new CCEaseInOut(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction, fRate)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pRet); -// } -// } -// -// return pRet; -// } +CCEaseInOut* CCEaseInOut::actionWithAction(CCActionInterval *pAction, float fRate) +{ + return CCEaseInOut::create(pAction, fRate); +} CCEaseInOut* CCEaseInOut::create(CCActionInterval *pAction, float fRate) { @@ -445,23 +380,10 @@ CCActionInterval* CCEaseInOut::reverse(void) // // EaseExponentialIn // -//cjh CCEaseExponentialIn* CCEaseExponentialIn::actionWithAction(CCActionInterval* pAction) -// { -// CCEaseExponentialIn *pRet = new CCEaseExponentialIn(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pRet); -// } -// } -// -// return pRet; -// } +CCEaseExponentialIn* CCEaseExponentialIn::actionWithAction(CCActionInterval* pAction) +{ + return CCEaseExponentialIn::create(pAction); +} CCEaseExponentialIn* CCEaseExponentialIn::create(CCActionInterval* pAction) { @@ -515,23 +437,10 @@ CCActionInterval* CCEaseExponentialIn::reverse(void) // // EaseExponentialOut // -//cjh CCEaseExponentialOut* CCEaseExponentialOut::actionWithAction(CCActionInterval* pAction) -// { -// CCEaseExponentialOut *pRet = new CCEaseExponentialOut(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pRet); -// } -// } -// -// return pRet; -// } +CCEaseExponentialOut* CCEaseExponentialOut::actionWithAction(CCActionInterval* pAction) +{ + return CCEaseExponentialOut::create(pAction); +} CCEaseExponentialOut* CCEaseExponentialOut::create(CCActionInterval* pAction) { @@ -585,23 +494,10 @@ CCActionInterval* CCEaseExponentialOut::reverse(void) // // EaseExponentialInOut // -//cjh CCEaseExponentialInOut* CCEaseExponentialInOut::actionWithAction(CCActionInterval *pAction) -// { -// CCEaseExponentialInOut *pRet = new CCEaseExponentialInOut(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pRet); -// } -// } -// -// return pRet; -// } +CCEaseExponentialInOut* CCEaseExponentialInOut::actionWithAction(CCActionInterval *pAction) +{ + return CCEaseExponentialInOut::create(pAction); +} CCEaseExponentialInOut* CCEaseExponentialInOut::create(CCActionInterval *pAction) { @@ -665,23 +561,10 @@ CCActionInterval* CCEaseExponentialInOut::reverse() // // EaseSineIn // -//cjh CCEaseSineIn* CCEaseSineIn::actionWithAction(CCActionInterval* pAction) -// { -// CCEaseSineIn *pRet = new CCEaseSineIn(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pRet); -// } -// } -// -// return pRet; -// } +CCEaseSineIn* CCEaseSineIn::actionWithAction(CCActionInterval* pAction) +{ + return CCEaseSineIn::create(pAction); +} CCEaseSineIn* CCEaseSineIn::create(CCActionInterval* pAction) { @@ -735,23 +618,10 @@ CCActionInterval* CCEaseSineIn::reverse(void) // // EaseSineOut // -//cjh CCEaseSineOut* CCEaseSineOut::actionWithAction(CCActionInterval* pAction) -// { -// CCEaseSineOut *pRet = new CCEaseSineOut(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pRet); -// } -// } -// -// return pRet; -// } +CCEaseSineOut* CCEaseSineOut::actionWithAction(CCActionInterval* pAction) +{ + return CCEaseSineOut::create(pAction); +} CCEaseSineOut* CCEaseSineOut::create(CCActionInterval* pAction) { @@ -805,23 +675,10 @@ CCActionInterval* CCEaseSineOut::reverse(void) // // EaseSineInOut // -//cjh CCEaseSineInOut* CCEaseSineInOut::actionWithAction(CCActionInterval* pAction) -// { -// CCEaseSineInOut *pRet = new CCEaseSineInOut(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pRet); -// } -// } -// -// return pRet; -// } +CCEaseSineInOut* CCEaseSineInOut::actionWithAction(CCActionInterval* pAction) +{ + return CCEaseSineInOut::create(pAction); +} CCEaseSineInOut* CCEaseSineInOut::create(CCActionInterval* pAction) { @@ -876,23 +733,10 @@ CCActionInterval* CCEaseSineInOut::reverse() // EaseElastic // -//cjh CCEaseElastic* CCEaseElastic::actionWithAction(CCActionInterval *pAction, float fPeriod/* = 0.3f*/) -// { -// CCEaseElastic *pRet = new CCEaseElastic(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction, fPeriod)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pRet); -// } -// } -// -// return pRet; -// } +CCEaseElastic* CCEaseElastic::actionWithAction(CCActionInterval *pAction, float fPeriod/* = 0.3f*/) +{ + return CCEaseElastic::create(pAction, fPeriod); +} CCEaseElastic* CCEaseElastic::create(CCActionInterval *pAction, float fPeriod/* = 0.3f*/) { @@ -954,23 +798,10 @@ CCActionInterval* CCEaseElastic::reverse(void) // // EaseElasticIn // -//cjh CCEaseElasticIn* CCEaseElasticIn::actionWithAction(CCActionInterval *pAction, float fPeriod/* = 0.3f*/) -// { -// CCEaseElasticIn *pRet = new CCEaseElasticIn(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction, fPeriod)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pRet); -// } -// } -// -// return pRet; -// } +CCEaseElasticIn* CCEaseElasticIn::actionWithAction(CCActionInterval *pAction, float fPeriod/* = 0.3f*/) +{ + return CCEaseElasticIn::create(pAction, fPeriod); +} CCEaseElasticIn* CCEaseElasticIn::create(CCActionInterval *pAction, float fPeriod/* = 0.3f*/) { @@ -1037,23 +868,10 @@ CCActionInterval* CCEaseElasticIn::reverse(void) // EaseElasticOut // -//cjh CCEaseElasticOut* CCEaseElasticOut::actionWithAction(CCActionInterval *pAction, float fPeriod/* = 0.3f*/) -// { -// CCEaseElasticOut *pRet = new CCEaseElasticOut(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction, fPeriod)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pRet); -// } -// } -// -// return pRet; -// } +CCEaseElasticOut* CCEaseElasticOut::actionWithAction(CCActionInterval *pAction, float fPeriod/* = 0.3f*/) +{ + return CCEaseElasticOut::create(pAction, fPeriod); +} CCEaseElasticOut* CCEaseElasticOut::create(CCActionInterval *pAction, float fPeriod/* = 0.3f*/) { @@ -1119,23 +937,10 @@ CCActionInterval* CCEaseElasticOut::reverse(void) // EaseElasticInOut // -//cjh CCEaseElasticInOut* CCEaseElasticInOut::actionWithAction(CCActionInterval *pAction, float fPeriod/* = 0.3f*/) -// { -// CCEaseElasticInOut *pRet = new CCEaseElasticInOut(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction, fPeriod)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pRet); -// } -// } -// -// return pRet; -// } +CCEaseElasticInOut* CCEaseElasticInOut::actionWithAction(CCActionInterval *pAction, float fPeriod/* = 0.3f*/) +{ + return CCEaseElasticInOut::create(pAction, fPeriod); +} CCEaseElasticInOut* CCEaseElasticInOut::create(CCActionInterval *pAction, float fPeriod/* = 0.3f*/) { @@ -1216,23 +1021,10 @@ CCActionInterval* CCEaseElasticInOut::reverse(void) // // EaseBounce // -//cjh CCEaseBounce* CCEaseBounce::actionWithAction(CCActionInterval* pAction) -// { -// CCEaseBounce *pRet = new CCEaseBounce(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pRet); -// } -// } -// -// return pRet; -// } +CCEaseBounce* CCEaseBounce::actionWithAction(CCActionInterval* pAction) +{ + return CCEaseBounce::create(pAction); +} CCEaseBounce* CCEaseBounce::create(CCActionInterval* pAction) { @@ -1302,23 +1094,10 @@ CCActionInterval* CCEaseBounce::reverse() // // EaseBounceIn // -//cjh CCEaseBounceIn* CCEaseBounceIn::actionWithAction(CCActionInterval* pAction) -// { -// CCEaseBounceIn *pRet = new CCEaseBounceIn(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pRet); -// } -// } -// -// return pRet; -// } +CCEaseBounceIn* CCEaseBounceIn::actionWithAction(CCActionInterval* pAction) +{ + return CCEaseBounceIn::create(pAction); +} CCEaseBounceIn* CCEaseBounceIn::create(CCActionInterval* pAction) { @@ -1373,23 +1152,10 @@ CCActionInterval* CCEaseBounceIn::reverse(void) // // EaseBounceOut // -//cjh CCEaseBounceOut* CCEaseBounceOut::actionWithAction(CCActionInterval* pAction) -// { -// CCEaseBounceOut *pRet = new CCEaseBounceOut(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pRet); -// } -// } -// -// return pRet; -// } +CCEaseBounceOut* CCEaseBounceOut::actionWithAction(CCActionInterval* pAction) +{ + return CCEaseBounceOut::create(pAction); +} CCEaseBounceOut* CCEaseBounceOut::create(CCActionInterval* pAction) { @@ -1444,23 +1210,10 @@ CCActionInterval* CCEaseBounceOut::reverse(void) // // EaseBounceInOut // -//cjh CCEaseBounceInOut* CCEaseBounceInOut::actionWithAction(CCActionInterval* pAction) -// { -// CCEaseBounceInOut *pRet = new CCEaseBounceInOut(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pRet); -// } -// } -// -// return pRet; -// } +CCEaseBounceInOut* CCEaseBounceInOut::actionWithAction(CCActionInterval* pAction) +{ + return CCEaseBounceInOut::create(pAction); +} CCEaseBounceInOut* CCEaseBounceInOut::create(CCActionInterval* pAction) { @@ -1525,23 +1278,10 @@ CCActionInterval* CCEaseBounceInOut::reverse() // // EaseBackIn // -//cjh CCEaseBackIn* CCEaseBackIn::actionWithAction(CCActionInterval *pAction) -// { -// CCEaseBackIn *pRet = new CCEaseBackIn(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pRet); -// } -// } -// -// return pRet; -// } +CCEaseBackIn* CCEaseBackIn::actionWithAction(CCActionInterval *pAction) +{ + return CCEaseBackIn::create(pAction); +} CCEaseBackIn* CCEaseBackIn::create(CCActionInterval *pAction) { @@ -1596,23 +1336,10 @@ CCActionInterval* CCEaseBackIn::reverse(void) // // EaseBackOut // -//cjh CCEaseBackOut* CCEaseBackOut::actionWithAction(CCActionInterval* pAction) -// { -// CCEaseBackOut *pRet = new CCEaseBackOut(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pRet); -// } -// } -// -// return pRet; -// } +CCEaseBackOut* CCEaseBackOut::actionWithAction(CCActionInterval* pAction) +{ + return CCEaseBackOut::create(pAction); +} CCEaseBackOut* CCEaseBackOut::create(CCActionInterval* pAction) { @@ -1669,23 +1396,10 @@ CCActionInterval* CCEaseBackOut::reverse(void) // // EaseBackInOut // -//cjh CCEaseBackInOut* CCEaseBackInOut::actionWithAction(CCActionInterval* pAction) -// { -// CCEaseBackInOut *pRet = new CCEaseBackInOut(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pRet); -// } -// } -// -// return pRet; -// } +CCEaseBackInOut* CCEaseBackInOut::actionWithAction(CCActionInterval* pAction) +{ + return CCEaseBackInOut::create(pAction); +} CCEaseBackInOut* CCEaseBackInOut::create(CCActionInterval* pAction) { diff --git a/cocos2dx/actions/CCActionEase.h b/cocos2dx/actions/CCActionEase.h index 0718d95e7d..45402a79c2 100644 --- a/cocos2dx/actions/CCActionEase.h +++ b/cocos2dx/actions/CCActionEase.h @@ -54,7 +54,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCActionEase* actionWithAction(CCActionInterval *pAction); + static CCActionEase* actionWithAction(CCActionInterval *pAction); /** creates the action */ static CCActionEase* create(CCActionInterval *pAction); @@ -86,7 +86,7 @@ public: /** Creates the action with the inner action and the rate parameter @warning: This interface will be deprecated in future. */ - //static CCEaseRateAction* actionWithAction(CCActionInterval* pAction, float fRate); + static CCEaseRateAction* actionWithAction(CCActionInterval* pAction, float fRate); /** Creates the action with the inner action and the rate parameter */ static CCEaseRateAction* create(CCActionInterval* pAction, float fRate); @@ -108,7 +108,7 @@ public: /** Creates the action with the inner action and the rate parameter @warning: This interface will be deprecated in future. */ - //static CCEaseIn* actionWithAction(CCActionInterval* pAction, float fRate); + static CCEaseIn* actionWithAction(CCActionInterval* pAction, float fRate); /** Creates the action with the inner action and the rate parameter */ static CCEaseIn* create(CCActionInterval* pAction, float fRate); @@ -128,7 +128,7 @@ public: /** Creates the action with the inner action and the rate parameter @warning: This interface will be deprecated in future. */ - //static CCEaseOut* actionWithAction(CCActionInterval* pAction, float fRate); + static CCEaseOut* actionWithAction(CCActionInterval* pAction, float fRate); /** Creates the action with the inner action and the rate parameter */ static CCEaseOut* create(CCActionInterval* pAction, float fRate); @@ -148,7 +148,7 @@ public: /** Creates the action with the inner action and the rate parameter @warning: This interface will be deprecated in future. */ - //static CCEaseInOut* actionWithAction(CCActionInterval* pAction, float fRate); + static CCEaseInOut* actionWithAction(CCActionInterval* pAction, float fRate); /** Creates the action with the inner action and the rate parameter */ static CCEaseInOut* create(CCActionInterval* pAction, float fRate); @@ -168,7 +168,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCEaseExponentialIn* actionWithAction(CCActionInterval* pAction); + static CCEaseExponentialIn* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseExponentialIn* create(CCActionInterval* pAction); }; @@ -187,7 +187,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCEaseExponentialOut* actionWithAction(CCActionInterval* pAction); + static CCEaseExponentialOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseExponentialOut* create(CCActionInterval* pAction); }; @@ -206,7 +206,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCEaseExponentialInOut* actionWithAction(CCActionInterval* pAction); + static CCEaseExponentialInOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseExponentialInOut* create(CCActionInterval* pAction); @@ -226,7 +226,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCEaseSineIn* actionWithAction(CCActionInterval* pAction); + static CCEaseSineIn* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseSineIn* create(CCActionInterval* pAction); }; @@ -245,7 +245,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCEaseSineOut* actionWithAction(CCActionInterval* pAction); + static CCEaseSineOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseSineOut* create(CCActionInterval* pAction); }; @@ -264,7 +264,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCEaseSineInOut* actionWithAction(CCActionInterval* pAction); + static CCEaseSineInOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseSineInOut* create(CCActionInterval* pAction); }; @@ -291,7 +291,7 @@ public: /** Creates the action with the inner action and the period in radians (default is 0.3) @warning: This interface will be deprecated in future. */ - //static CCEaseElastic* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); + static CCEaseElastic* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); /** Creates the action with the inner action and the period in radians (default is 0.3) */ static CCEaseElastic* create(CCActionInterval *pAction, float fPeriod = 0.3f); protected: @@ -314,7 +314,7 @@ public: /** Creates the action with the inner action and the period in radians (default is 0.3) @warning: This interface will be deprecated in future. */ - //static CCEaseElasticIn* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); + static CCEaseElasticIn* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); /** Creates the action with the inner action and the period in radians (default is 0.3) */ static CCEaseElasticIn* create(CCActionInterval *pAction, float fPeriod = 0.3f); }; @@ -335,7 +335,7 @@ public: /** Creates the action with the inner action and the period in radians (default is 0.3) @warning: This interface will be deprecated in future. */ - //static CCEaseElasticOut* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); + static CCEaseElasticOut* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); /** Creates the action with the inner action and the period in radians (default is 0.3) */ static CCEaseElasticOut* create(CCActionInterval *pAction, float fPeriod = 0.3f); @@ -357,7 +357,7 @@ public: /** Creates the action with the inner action and the period in radians (default is 0.3) @warning: This interface will be deprecated in future. */ - //static CCEaseElasticInOut* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); + static CCEaseElasticInOut* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); /** Creates the action with the inner action and the period in radians (default is 0.3) */ static CCEaseElasticInOut* create(CCActionInterval *pAction, float fPeriod = 0.3f); @@ -378,7 +378,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCEaseBounce* actionWithAction(CCActionInterval* pAction); + static CCEaseBounce* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseBounce* create(CCActionInterval* pAction); }; @@ -399,7 +399,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCEaseBounceIn* actionWithAction(CCActionInterval* pAction); + static CCEaseBounceIn* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseBounceIn* create(CCActionInterval* pAction); }; @@ -420,7 +420,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCEaseBounceOut* actionWithAction(CCActionInterval* pAction); + static CCEaseBounceOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseBounceOut* create(CCActionInterval* pAction); }; @@ -441,7 +441,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCEaseBounceInOut* actionWithAction(CCActionInterval* pAction); + static CCEaseBounceInOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseBounceInOut* create(CCActionInterval* pAction); }; @@ -462,7 +462,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCEaseBackIn* actionWithAction(CCActionInterval* pAction); + static CCEaseBackIn* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseBackIn* create(CCActionInterval* pAction); }; @@ -483,7 +483,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCEaseBackOut* actionWithAction(CCActionInterval* pAction); + static CCEaseBackOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseBackOut* create(CCActionInterval* pAction); }; @@ -504,7 +504,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCEaseBackInOut* actionWithAction(CCActionInterval* pAction); + static CCEaseBackInOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseBackInOut* create(CCActionInterval* pAction); }; diff --git a/cocos2dx/actions/CCActionGrid.cpp b/cocos2dx/actions/CCActionGrid.cpp index 3b8d2deb42..929b41da76 100644 --- a/cocos2dx/actions/CCActionGrid.cpp +++ b/cocos2dx/actions/CCActionGrid.cpp @@ -30,23 +30,10 @@ THE SOFTWARE. NS_CC_BEGIN // implementation of CCGridAction -// CCGridAction* CCGridAction::actionWithSize(const ccGridSize& gridSize, float duration) -// { -// CCGridAction *pAction = new CCGridAction(); -// if (pAction) -// { -// if (pAction->initWithSize(gridSize, duration)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_DELETE(pAction); -// } -// } -// -// return pAction; -// } +CCGridAction* CCGridAction::actionWithSize(const ccGridSize& gridSize, float duration) +{ + return CCGridAction::create(gridSize, duration); +} CCGridAction* CCGridAction::create(const ccGridSize& gridSize, float duration) { @@ -199,23 +186,10 @@ void CCTiledGrid3DAction::setTile(const ccGridSize& pos, const ccQuad3& coords) // implementation CCAccelDeccelAmplitude -// CCAccelDeccelAmplitude* CCAccelDeccelAmplitude::actionWithAction(CCAction *pAction, float duration) -// { -// CCAccelDeccelAmplitude *pRet = new CCAccelDeccelAmplitude(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction, duration)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_DELETE(pRet); -// } -// } -// -// return pRet; -// } +CCAccelDeccelAmplitude* CCAccelDeccelAmplitude::actionWithAction(CCAction *pAction, float duration) +{ + return CCAccelDeccelAmplitude::create(pAction, duration); +} CCAccelDeccelAmplitude* CCAccelDeccelAmplitude::create(CCAction *pAction, float duration) { @@ -280,23 +254,10 @@ CCActionInterval* CCAccelDeccelAmplitude::reverse(void) // implementation of AccelAmplitude -// CCAccelAmplitude* CCAccelAmplitude::actionWithAction(CCAction *pAction, float duration) -// { -// CCAccelAmplitude *pRet = new CCAccelAmplitude(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction, duration)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_DELETE(pRet); -// } -// } -// -// return pRet; -// } +CCAccelAmplitude* CCAccelAmplitude::actionWithAction(CCAction *pAction, float duration) +{ + return CCAccelAmplitude::create(pAction, duration); +} CCAccelAmplitude* CCAccelAmplitude::create(CCAction *pAction, float duration) { @@ -354,23 +315,10 @@ CCActionInterval* CCAccelAmplitude::reverse(void) // DeccelAmplitude -// CCDeccelAmplitude* CCDeccelAmplitude::actionWithAction(CCAction *pAction, float duration) -// { -// CCDeccelAmplitude *pRet = new CCDeccelAmplitude(); -// if (pRet) -// { -// if (pRet->initWithAction(pAction, duration)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_DELETE(pRet); -// } -// } -// -// return pRet; -// } +CCDeccelAmplitude* CCDeccelAmplitude::actionWithAction(CCAction *pAction, float duration) +{ + return CCDeccelAmplitude::create(pAction, duration); +} CCDeccelAmplitude* CCDeccelAmplitude::create(CCAction *pAction, float duration) { @@ -440,13 +388,10 @@ void CCStopGrid::startWithTarget(CCNode *pTarget) } } -// CCStopGrid* CCStopGrid::action(void) -// { -// CCStopGrid* pAction = new CCStopGrid(); -// pAction->autorelease(); -// -// return pAction; -// } +CCStopGrid* CCStopGrid::action(void) +{ + return CCStopGrid::create(); +} CCStopGrid* CCStopGrid::create(void) { @@ -457,23 +402,10 @@ CCStopGrid* CCStopGrid::create(void) } // implementation of CCReuseGrid -// CCReuseGrid* CCReuseGrid::actionWithTimes(int times) -// { -// CCReuseGrid *pAction = new CCReuseGrid(); -// if (pAction) -// { -// if (pAction->initWithTimes(times)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_DELETE(pAction); -// } -// } -// -// return pAction; -// } +CCReuseGrid* CCReuseGrid::actionWithTimes(int times) +{ + return CCReuseGrid::create(times); +} CCReuseGrid* CCReuseGrid::create(int times) { diff --git a/cocos2dx/actions/CCActionGrid.h b/cocos2dx/actions/CCActionGrid.h index 52455a8ab9..74cca70d40 100644 --- a/cocos2dx/actions/CCActionGrid.h +++ b/cocos2dx/actions/CCActionGrid.h @@ -49,7 +49,7 @@ public: /** creates the action with size and duration @warning: This interface will be deprecated in future. */ - //static CCGridAction* actionWithSize(const ccGridSize& gridSize, float duration); + static CCGridAction* actionWithSize(const ccGridSize& gridSize, float duration); /** creates the action with size and duration */ static CCGridAction* create(const ccGridSize& gridSize, float duration); protected: @@ -76,7 +76,7 @@ public: /** creates the action with size and duration @warning: This interface will be deprecated in future. */ - //static CCGrid3DAction* actionWithSize(const ccGridSize& gridSize, float duration); + static CCGrid3DAction* actionWithSize(const ccGridSize& gridSize, float duration); /** creates the action with size and duration */ static CCGrid3DAction* create(const ccGridSize& gridSize, float duration); }; @@ -99,7 +99,7 @@ public: /** creates the action with size and duration @warning: This interface will be deprecated in future. */ - //static CCTiledGrid3DAction* actionWithSize(const ccGridSize& gridSize, float duration); + static CCTiledGrid3DAction* actionWithSize(const ccGridSize& gridSize, float duration); /** creates the action with size and duration */ static CCTiledGrid3DAction* create(const ccGridSize& gridSize, float duration); }; @@ -125,7 +125,7 @@ public: /** creates the action with an inner action that has the amplitude property, and a duration time @warning: This interface will be deprecated in future. */ - //static CCAccelDeccelAmplitude* actionWithAction(CCAction *pAction, float duration); + static CCAccelDeccelAmplitude* actionWithAction(CCAction *pAction, float duration); /** creates the action with an inner action that has the amplitude property, and a duration time */ static CCAccelDeccelAmplitude* create(CCAction *pAction, float duration); @@ -155,7 +155,7 @@ public: /** creates the action with an inner action that has the amplitude property, and a duration time @warning: This interface will be deprecated in future. */ - //static CCAccelAmplitude* actionWithAction(CCAction *pAction, float duration); + static CCAccelAmplitude* actionWithAction(CCAction *pAction, float duration); /** creates the action with an inner action that has the amplitude property, and a duration time */ static CCAccelAmplitude* create(CCAction *pAction, float duration); protected: @@ -184,7 +184,7 @@ public: /** creates the action with an inner action that has the amplitude property, and a duration time @warning: This interface will be deprecated in future. */ - //static CCDeccelAmplitude* actionWithAction(CCAction *pAction, float duration); + static CCDeccelAmplitude* actionWithAction(CCAction *pAction, float duration); /** creates the action with an inner action that has the amplitude property, and a duration time */ static CCDeccelAmplitude* create(CCAction *pAction, float duration); @@ -207,7 +207,7 @@ public: /** Allocates and initializes the action @warning: This interface will be deprecated in future. */ - //static CCStopGrid* action(void); + static CCStopGrid* action(void); /** Allocates and initializes the action */ static CCStopGrid* create(void); }; @@ -225,7 +225,7 @@ public: /** creates an action with the number of times that the current grid will be reused @warning: This interface will be deprecated in future. */ - //static CCReuseGrid* actionWithTimes(int times); + static CCReuseGrid* actionWithTimes(int times); /** creates an action with the number of times that the current grid will be reused */ static CCReuseGrid* create(int times); protected: diff --git a/cocos2dx/actions/CCActionGrid3D.cpp b/cocos2dx/actions/CCActionGrid3D.cpp index 2613f3033c..80c7fda10d 100644 --- a/cocos2dx/actions/CCActionGrid3D.cpp +++ b/cocos2dx/actions/CCActionGrid3D.cpp @@ -31,24 +31,10 @@ THE SOFTWARE. NS_CC_BEGIN // implementation of CCWaves3D -// CCWaves3D* CCWaves3D::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) -// { -// CCWaves3D *pAction = new CCWaves3D(); -// -// if (pAction) -// { -// if (pAction->initWithWaves(wav, amp, gridSize, duration)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pAction); -// } -// } -// -// return pAction; -// } +CCWaves3D* CCWaves3D::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) +{ + return CCWaves3D::create(wav, amp, gridSize, duration); +} CCWaves3D* CCWaves3D::create(int wav, float amp, const ccGridSize& gridSize, float duration) { @@ -124,24 +110,10 @@ void CCWaves3D::update(float time) // implementation of CCFlipX3D -// CCFlipX3D* CCFlipX3D::actionWithDuration(float duration) -// { -// CCFlipX3D *pAction = new CCFlipX3D(); -// -// if (pAction) -// { -// if (pAction->initWithSize(ccg(1, 1), duration)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pAction); -// } -// } -// -// return pAction; -// } +CCFlipX3D* CCFlipX3D::actionWithDuration(float duration) +{ + return CCFlipX3D::create(duration); +} CCFlipX3D* CCFlipX3D::create(float duration) { @@ -269,24 +241,10 @@ void CCFlipX3D::update(float time) // implementation of FlipY3D -// CCFlipY3D* CCFlipY3D::actionWithDuration(float duration) -// { -// CCFlipY3D *pAction = new CCFlipY3D(); -// -// if (pAction) -// { -// if (pAction->initWithSize(ccg(1, 1), duration)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pAction); -// } -// } -// -// return pAction; -// } +CCFlipY3D* CCFlipY3D::actionWithDuration(float duration) +{ + return CCFlipY3D::create(duration); +} CCFlipY3D* CCFlipY3D::create(float duration) { @@ -397,24 +355,10 @@ void CCFlipY3D::update(float time) // implementation of Lens3D -// CCLens3D* CCLens3D::actionWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration) -// { -// CCLens3D *pAction = new CCLens3D(); -// -// if (pAction) -// { -// if (pAction->initWithPosition(pos, r, gridSize, duration)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pAction); -// } -// } -// -// return pAction; -// } +CCLens3D* CCLens3D::actionWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration) +{ + return CCLens3D::create(pos, r, gridSize, duration); +} CCLens3D* CCLens3D::create(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration) { @@ -527,24 +471,10 @@ void CCLens3D::update(float time) // implementation of Ripple3D -// CCRipple3D* CCRipple3D::actionWithPosition(const CCPoint& pos, float r, int wav, float amp, const ccGridSize& gridSize, float duration) -// { -// CCRipple3D *pAction = new CCRipple3D(); -// -// if (pAction) -// { -// if (pAction->initWithPosition(pos, r, wav, amp, gridSize, duration)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pAction); -// } -// } -// -// return pAction; -// } +CCRipple3D* CCRipple3D::actionWithPosition(const CCPoint& pos, float r, int wav, float amp, const ccGridSize& gridSize, float duration) +{ + return CCRipple3D::create(pos, r, wav, amp, gridSize, duration); +} CCRipple3D* CCRipple3D::create(const CCPoint& pos, float r, int wav, float amp, const ccGridSize& gridSize, float duration) { @@ -635,24 +565,10 @@ void CCRipple3D::update(float time) // implementation of Shaky3D -// CCShaky3D* CCShaky3D::actionWithRange(int range, bool shakeZ, const ccGridSize& gridSize, float duration) -// { -// CCShaky3D *pAction = new CCShaky3D(); -// -// if (pAction) -// { -// if (pAction->initWithRange(range, shakeZ, gridSize, duration)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pAction); -// } -// } -// -// return pAction; -// } +CCShaky3D* CCShaky3D::actionWithRange(int range, bool shakeZ, const ccGridSize& gridSize, float duration) +{ + return CCShaky3D::create(range, shakeZ, gridSize, duration); +} CCShaky3D* CCShaky3D::create(int range, bool shakeZ, const ccGridSize& gridSize, float duration) { @@ -733,24 +649,10 @@ void CCShaky3D::update(float time) // implementation of Liquid -// CCLiquid* CCLiquid::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) -// { -// CCLiquid *pAction = new CCLiquid(); -// -// if (pAction) -// { -// if (pAction->initWithWaves(wav, amp, gridSize, duration)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pAction); -// } -// } -// -// return pAction; -// } +CCLiquid* CCLiquid::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) +{ + return CCLiquid::create(wav, amp, gridSize, duration); +} CCLiquid* CCLiquid::create(int wav, float amp, const ccGridSize& gridSize, float duration) { @@ -826,24 +728,10 @@ void CCLiquid::update(float time) // implementation of Waves -// CCWaves* CCWaves::actionWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, float duration) -// { -// CCWaves *pAction = new CCWaves(); -// -// if (pAction) -// { -// if (pAction->initWithWaves(wav, amp, h, v, gridSize, duration)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pAction); -// } -// } -// -// return pAction; -// } +CCWaves* CCWaves::actionWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, float duration) +{ + return CCWaves::create(wav, amp, h, v, gridSize, duration); +} CCWaves* CCWaves::create(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, float duration) { @@ -930,24 +818,10 @@ void CCWaves::update(float time) // implementation of Twirl -// CCTwirl* CCTwirl::actionWithPosition(CCPoint pos, int t, float amp, const ccGridSize& gridSize, float duration) -// { -// CCTwirl *pAction = new CCTwirl(); -// -// if (pAction) -// { -// if (pAction->initWithPosition(pos, t, amp, gridSize, duration)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pAction); -// } -// } -// -// return pAction; -// } +CCTwirl* CCTwirl::actionWithPosition(CCPoint pos, int t, float amp, const ccGridSize& gridSize, float duration) +{ + return CCTwirl::create(pos, t, amp, gridSize, duration); +} CCTwirl* CCTwirl::create(CCPoint pos, int t, float amp, const ccGridSize& gridSize, float duration) { diff --git a/cocos2dx/actions/CCActionGrid3D.h b/cocos2dx/actions/CCActionGrid3D.h index a9f6e84d16..b509b4e22f 100644 --- a/cocos2dx/actions/CCActionGrid3D.h +++ b/cocos2dx/actions/CCActionGrid3D.h @@ -50,7 +50,7 @@ public: /** create the action @warning: This interface will be deprecated in future. */ - //static CCWaves3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); + static CCWaves3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); /** create the action */ static CCWaves3D* create(int wav, float amp, const ccGridSize& gridSize, float duration); protected: @@ -73,7 +73,7 @@ public: /** creates the action with duration @warning: This interface will be deprecated in future. */ - //static CCFlipX3D* actionWithDuration(float duration); + static CCFlipX3D* actionWithDuration(float duration); /** creates the action with duration */ static CCFlipX3D* create(float duration); }; @@ -89,7 +89,7 @@ public: /** creates the action with duration @warning: This interface will be deprecated in future. */ - //static CCFlipY3D* actionWithDuration(float duration); + static CCFlipY3D* actionWithDuration(float duration); /** creates the action with duration */ static CCFlipY3D* create(float duration); }; @@ -115,7 +115,7 @@ public: /** creates the action with center position, radius, a grid size and duration @warning: This interface will be deprecated in future. */ - //static CCLens3D* actionWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration); + static CCLens3D* actionWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration); /** creates the action with center position, radius, a grid size and duration */ static CCLens3D* create(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration); protected: @@ -153,8 +153,8 @@ public: /** creates the action with radius, number of waves, amplitude, a grid size and duration @warning: This interface will be deprecated in future. */ - //static CCRipple3D* actionWithPosition(const CCPoint& pos, float r, int wav, float amp, - // const ccGridSize& gridSize, float duration); + static CCRipple3D* actionWithPosition(const CCPoint& pos, float r, int wav, float amp, + const ccGridSize& gridSize, float duration); /** creates the action with radius, number of waves, amplitude, a grid size and duration */ static CCRipple3D* create(const CCPoint& pos, float r, int wav, float amp, const ccGridSize& gridSize, float duration); @@ -180,7 +180,7 @@ public: /** creates the action with a range, shake Z vertices, a grid and duration @warning: This interface will be deprecated in future. */ - //static CCShaky3D* actionWithRange(int range, bool shakeZ, const ccGridSize& gridSize, float duration); + static CCShaky3D* actionWithRange(int range, bool shakeZ, const ccGridSize& gridSize, float duration); /** creates the action with a range, shake Z vertices, a grid and duration */ static CCShaky3D* create(int range, bool shakeZ, const ccGridSize& gridSize, float duration); protected: @@ -207,7 +207,7 @@ public: /** creates the action with amplitude, a grid and duration @warning: This interface will be deprecated in future. */ - //static CCLiquid* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); + static CCLiquid* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); /** creates the action with amplitude, a grid and duration */ static CCLiquid* create(int wav, float amp, const ccGridSize& gridSize, float duration); protected: @@ -236,8 +236,8 @@ public: /** initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration @warning: This interface will be deprecated in future. */ -// static CCWaves* actionWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, -// float duration); + static CCWaves* actionWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, + float duration); /** initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration */ static CCWaves* create(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, @@ -275,8 +275,8 @@ public: /** creates the action with center position, number of twirls, amplitude, a grid size and duration @warning: This interface will be deprecated in future. */ -// static CCTwirl* actionWithPosition(CCPoint pos, int t, float amp, const ccGridSize& gridSize, -// float duration); + static CCTwirl* actionWithPosition(CCPoint pos, int t, float amp, const ccGridSize& gridSize, + float duration); /** creates the action with center position, number of twirls, amplitude, a grid size and duration */ static CCTwirl* create(CCPoint pos, int t, float amp, const ccGridSize& gridSize, diff --git a/cocos2dx/actions/CCActionInstant.cpp b/cocos2dx/actions/CCActionInstant.cpp index 4646854bfa..0516d1466e 100644 --- a/cocos2dx/actions/CCActionInstant.cpp +++ b/cocos2dx/actions/CCActionInstant.cpp @@ -1,5 +1,5 @@ /**************************************************************************** - Copyright (c) 2010-2011 cocos2d-x.org + Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. @@ -73,17 +73,13 @@ CCFiniteTimeAction * CCActionInstant::reverse() { // // Show // -// CCShow* CCShow::action() { -// CCShow* pRet = new CCShow(); -// -// if (pRet) { -// pRet->autorelease(); -// } -// -// return pRet; -// } +CCShow* CCShow::action() +{ + return CCShow::create(); +} -CCShow* CCShow::create() { +CCShow* CCShow::create() +{ CCShow* pRet = new CCShow(); if (pRet) { @@ -121,17 +117,13 @@ CCObject* CCShow::copyWithZone(CCZone *pZone) { // // Hide // -// CCHide * CCHide::action() { -// CCHide *pRet = new CCHide(); -// -// if (pRet) { -// pRet->autorelease(); -// } -// -// return pRet; -// } +CCHide * CCHide::action() +{ + return CCHide::create(); +} -CCHide * CCHide::create() { +CCHide * CCHide::create() +{ CCHide *pRet = new CCHide(); if (pRet) { @@ -169,17 +161,10 @@ CCObject* CCHide::copyWithZone(CCZone *pZone) { // // ToggleVisibility // -// CCToggleVisibility * CCToggleVisibility::action() -// { -// CCToggleVisibility *pRet = new CCToggleVisibility(); -// -// if (pRet) -// { -// pRet->autorelease(); -// } -// -// return pRet; -// } +CCToggleVisibility * CCToggleVisibility::action() +{ + return CCToggleVisibility::create(); +} CCToggleVisibility * CCToggleVisibility::create() { @@ -219,19 +204,13 @@ CCObject* CCToggleVisibility::copyWithZone(CCZone *pZone) // // FlipX // -// CCFlipX *CCFlipX::actionWithFlipX(bool x) { -// CCFlipX *pRet = new CCFlipX(); -// -// if (pRet && pRet->initWithFlipX(x)) { -// pRet->autorelease(); -// return pRet; -// } -// -// CC_SAFE_DELETE(pRet); -// return NULL; -// } +CCFlipX *CCFlipX::actionWithFlipX(bool x) +{ + return CCFlipX::create(x); +} -CCFlipX *CCFlipX::create(bool x) { +CCFlipX *CCFlipX::create(bool x) +{ CCFlipX *pRet = new CCFlipX(); if (pRet && pRet->initWithFlipX(x)) { @@ -277,19 +256,13 @@ CCObject * CCFlipX::copyWithZone(CCZone *pZone) { // // FlipY // -// CCFlipY * CCFlipY::actionWithFlipY(bool y) { -// CCFlipY *pRet = new CCFlipY(); -// -// if (pRet && pRet->initWithFlipY(y)) { -// pRet->autorelease(); -// return pRet; -// } -// -// CC_SAFE_DELETE(pRet); -// return NULL; -// } +CCFlipY * CCFlipY::actionWithFlipY(bool y) +{ + return CCFlipY::create(y); +} -CCFlipY * CCFlipY::create(bool y) { +CCFlipY * CCFlipY::create(bool y) +{ CCFlipY *pRet = new CCFlipY(); if (pRet && pRet->initWithFlipY(y)) { @@ -335,19 +308,13 @@ CCObject* CCFlipY::copyWithZone(CCZone *pZone) { // // Place // -// CCPlace* CCPlace::actionWithPosition(const CCPoint& pos) { -// CCPlace *pRet = new CCPlace(); -// -// if (pRet && pRet->initWithPosition(pos)) { -// pRet->autorelease(); -// return pRet; -// } -// -// CC_SAFE_DELETE(pRet); -// return NULL; -// } +CCPlace* CCPlace::actionWithPosition(const CCPoint& pos) +{ + return CCPlace::create(pos); +} -CCPlace* CCPlace::create(const CCPoint& pos) { +CCPlace* CCPlace::create(const CCPoint& pos) +{ CCPlace *pRet = new CCPlace(); if (pRet && pRet->initWithPosition(pos)) { @@ -390,22 +357,13 @@ void CCPlace::update(float time) { // CallFunc // -// CCCallFunc * CCCallFunc::actionWithTarget(CCObject* pSelectorTarget, -// SEL_CallFunc selector) { -// CCCallFunc *pRet = new CCCallFunc(); -// -// if (pRet && pRet->initWithTarget(pSelectorTarget)) { -// pRet->m_pCallFunc = selector; -// pRet->autorelease(); -// return pRet; -// } -// -// CC_SAFE_DELETE(pRet); -// return NULL; -// } +CCCallFunc * CCCallFunc::actionWithTarget(CCObject* pSelectorTarget, SEL_CallFunc selector) +{ + return CCCallFunc::create(pSelectorTarget, selector); +} -CCCallFunc * CCCallFunc::create(CCObject* pSelectorTarget, - SEL_CallFunc selector) { +CCCallFunc * CCCallFunc::create(CCObject* pSelectorTarget, SEL_CallFunc selector) +{ CCCallFunc *pRet = new CCCallFunc(); if (pRet && pRet->initWithTarget(pSelectorTarget)) { @@ -472,24 +430,17 @@ void CCCallFuncN::execute() { } } -// CCCallFuncN * CCCallFuncN::actionWithTarget(CCObject* pSelectorTarget, -// SEL_CallFuncN selector) { -// CCCallFuncN *pRet = new CCCallFuncN(); -// -// if (pRet && pRet->initWithTarget(pSelectorTarget, selector)) { -// pRet->autorelease(); -// return pRet; -// } -// -// CC_SAFE_DELETE(pRet); -// return NULL; -// } +CCCallFuncN * CCCallFuncN::actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncN selector) +{ + return CCCallFuncN::create(pSelectorTarget, selector); +} -CCCallFuncN * CCCallFuncN::create(CCObject* pSelectorTarget, - SEL_CallFuncN selector) { +CCCallFuncN * CCCallFuncN::create(CCObject* pSelectorTarget, SEL_CallFuncN selector) +{ CCCallFuncN *pRet = new CCCallFuncN(); - if (pRet && pRet->initWithTarget(pSelectorTarget, selector)) { + if (pRet && pRet->initWithTarget(pSelectorTarget, selector)) + { pRet->autorelease(); return pRet; } @@ -529,21 +480,13 @@ CCObject * CCCallFuncN::copyWithZone(CCZone* zone) { // // CallFuncND // -// CCCallFuncND * CCCallFuncND::actionWithTarget(CCObject* pSelectorTarget, -// SEL_CallFuncND selector, void* d) { -// CCCallFuncND* pRet = new CCCallFuncND(); -// -// if (pRet && pRet->initWithTarget(pSelectorTarget, selector, d)) { -// pRet->autorelease(); -// return pRet; -// } -// -// CC_SAFE_DELETE(pRet); -// return NULL; -// } +CCCallFuncND * CCCallFuncND::actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncND selector, void* d) +{ + return CCCallFuncND::create(pSelectorTarget, selector, d); +} -CCCallFuncND * CCCallFuncND::create(CCObject* pSelectorTarget, - SEL_CallFuncND selector, void* d) { +CCCallFuncND * CCCallFuncND::create(CCObject* pSelectorTarget, SEL_CallFuncND selector, void* d) +{ CCCallFuncND* pRet = new CCCallFuncND(); if (pRet && pRet->initWithTarget(pSelectorTarget, selector, d)) { @@ -607,21 +550,13 @@ void CCCallFuncO::execute() { } } -// CCCallFuncO * CCCallFuncO::actionWithTarget(CCObject* pSelectorTarget, -// SEL_CallFuncO selector, CCObject* pObject) { -// CCCallFuncO *pRet = new CCCallFuncO(); -// -// if (pRet && pRet->initWithTarget(pSelectorTarget, selector, pObject)) { -// pRet->autorelease(); -// return pRet; -// } -// -// CC_SAFE_DELETE(pRet); -// return NULL; -// } +CCCallFuncO * CCCallFuncO::actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncO selector, CCObject* pObject) +{ + return CCCallFuncO::create(pSelectorTarget, selector, pObject); +} -CCCallFuncO * CCCallFuncO::create(CCObject* pSelectorTarget, - SEL_CallFuncO selector, CCObject* pObject) { +CCCallFuncO * CCCallFuncO::create(CCObject* pSelectorTarget, SEL_CallFuncO selector, CCObject* pObject) +{ CCCallFuncO *pRet = new CCCallFuncO(); if (pRet && pRet->initWithTarget(pSelectorTarget, selector, pObject)) { diff --git a/cocos2dx/actions/CCActionInstant.h b/cocos2dx/actions/CCActionInstant.h index 80b5be2aad..14d0afaeba 100644 --- a/cocos2dx/actions/CCActionInstant.h +++ b/cocos2dx/actions/CCActionInstant.h @@ -1,5 +1,5 @@ /**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org +Copyright (c) 2010-2012 cocos2d-x.org Copyright (c) 2008-2010 Ricardo Quesada Copyright (c) 2011 Zynga Inc. @@ -66,7 +66,7 @@ public: /** Allocates and initializes the action @warning: This interface will be deprecated in future. */ - //static CCShow * action(); + static CCShow * action(); /** Allocates and initializes the action */ static CCShow * create(); @@ -91,7 +91,7 @@ public: /** Allocates and initializes the action @warning: This interface will be deprecated in future. */ - //static CCHide * action(); + static CCHide * action(); /** Allocates and initializes the action */ static CCHide * create(); @@ -112,7 +112,7 @@ public: /** Allocates and initializes the action @warning: This interface will be deprecated in future. */ - //static CCToggleVisibility * action(); + static CCToggleVisibility * action(); /** Allocates and initializes the action */ static CCToggleVisibility * create(); @@ -133,7 +133,7 @@ public: /** create the action @warning: This interface will be deprecated in future. */ - //static CCFlipX * actionWithFlipX(bool x); + static CCFlipX * actionWithFlipX(bool x); /** create the action */ static CCFlipX * create(bool x); @@ -164,7 +164,7 @@ public: /** create the action @warning: This interface will be deprecated in future. */ - //static CCFlipY * actionWithFlipY(bool y); + static CCFlipY * actionWithFlipY(bool y); /** create the action */ static CCFlipY * create(bool y); @@ -190,7 +190,7 @@ public: /** creates a Place action with a position @warning: This interface will be deprecated in future. */ - //static CCPlace * actionWithPosition(const CCPoint& pos); + static CCPlace * actionWithPosition(const CCPoint& pos); /** creates a Place action with a position */ static CCPlace * create(const CCPoint& pos); /** Initializes a Place action with a position */ @@ -224,7 +224,7 @@ public: @warning: This interface will be deprecated in future. typedef void (CCObject::*SEL_CallFunc)(); */ - //static CCCallFunc * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFunc selector); + static CCCallFunc * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFunc selector); /** creates the action with the callback @@ -292,7 +292,7 @@ public: @warning: This interface will be deprecated in future. typedef void (CCObject::*SEL_CallFuncN)(CCNode*); */ - //static CCCallFuncN * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncN selector); + static CCCallFuncN * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncN selector); /** creates the action with the callback @@ -321,7 +321,7 @@ public: /** creates the action with the callback and the data to pass as an argument @warning: This interface will be deprecated in future. */ - //static CCCallFuncND * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncND selector, void* d); + static CCCallFuncND * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncND selector, void* d); /** creates the action with the callback and the data to pass as an argument */ static CCCallFuncND * create(CCObject* pSelectorTarget, SEL_CallFuncND selector, void* d); @@ -351,7 +351,7 @@ public: @warning: This interface will be deprecated in future. typedef void (CCObject::*SEL_CallFuncO)(CCObject*); */ - //static CCCallFuncO * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncO selector, CCObject* pObject); + static CCCallFuncO * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncO selector, CCObject* pObject); /** creates the action with the callback diff --git a/cocos2dx/actions/CCActionInterval.cpp b/cocos2dx/actions/CCActionInterval.cpp index 3f9e1ab6a7..e250a4a996 100644 --- a/cocos2dx/actions/CCActionInterval.cpp +++ b/cocos2dx/actions/CCActionInterval.cpp @@ -38,14 +38,10 @@ NS_CC_BEGIN // // IntervalAction // -// CCActionInterval* CCActionInterval::actionWithDuration(float d) -// { -// CCActionInterval *pAction = new CCActionInterval(); -// pAction->initWithDuration(d); -// pAction->autorelease(); -// -// return pAction; -// } +CCActionInterval* CCActionInterval::actionWithDuration(float d) +{ + return CCActionInterval::create(d); +} CCActionInterval* CCActionInterval::create(float d) { @@ -155,14 +151,10 @@ CCActionInterval* CCActionInterval::reverse(void) // // Sequence // -// CCSequence* CCSequence::actionOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo) -// { -// CCSequence *pSequence = new CCSequence(); -// pSequence->initOneTwo(pActionOne, pActionTwo); -// pSequence->autorelease(); -// -// return pSequence; -// } +CCSequence* CCSequence::actionOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo) +{ + return CCSequence::create(pActionOne, pActionTwo); +} CCSequence* CCSequence::create(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo) { @@ -173,30 +165,30 @@ CCSequence* CCSequence::create(CCFiniteTimeAction *pActionOne, CCFiniteTimeActio return pSequence; } -// CCFiniteTimeAction* CCSequence::actions(CCFiniteTimeAction *pAction1, ...) -// { -// va_list params; -// va_start(params, pAction1); -// -// CCFiniteTimeAction *pNow; -// CCFiniteTimeAction *pPrev = pAction1; -// -// while (pAction1) -// { -// pNow = va_arg(params, CCFiniteTimeAction*); -// if (pNow) -// { -// pPrev = actionOneTwo(pPrev, pNow); -// } -// else -// { -// break; -// } -// } -// -// va_end(params); -// return pPrev; -// } +CCFiniteTimeAction* CCSequence::actions(CCFiniteTimeAction *pAction1, ...) +{ + va_list params; + va_start(params, pAction1); + + CCFiniteTimeAction *pNow; + CCFiniteTimeAction *pPrev = pAction1; + + while (pAction1) + { + pNow = va_arg(params, CCFiniteTimeAction*); + if (pNow) + { + pPrev = actionOneTwo(pPrev, pNow); + } + else + { + break; + } + } + + va_end(params); + return pPrev; +} CCFiniteTimeAction* CCSequence::create(CCFiniteTimeAction *pAction1, ...) { @@ -223,17 +215,10 @@ CCFiniteTimeAction* CCSequence::create(CCFiniteTimeAction *pAction1, ...) return pPrev; } -// CCFiniteTimeAction* CCSequence::actionWithArray(CCArray *actions) -// { -// CCFiniteTimeAction* prev = (CCFiniteTimeAction*)actions->objectAtIndex(0); -// -// for (unsigned int i = 1; i < actions->count(); ++i) -// { -// prev = actionOneTwo(prev, (CCFiniteTimeAction*)actions->objectAtIndex(i)); -// } -// -// return prev; -// } +CCFiniteTimeAction* CCSequence::actionWithArray(CCArray *actions) +{ + return CCSequence::create(actions); +} CCFiniteTimeAction* CCSequence::create(CCArray *actions) { @@ -368,14 +353,10 @@ CCActionInterval* CCSequence::reverse(void) // // Repeat // -// CCRepeat* CCRepeat::actionWithAction(CCFiniteTimeAction *pAction, unsigned int times) -// { -// CCRepeat* pRepeat = new CCRepeat(); -// pRepeat->initWithAction(pAction, times); -// pRepeat->autorelease(); -// -// return pRepeat; -// } +CCRepeat* CCRepeat::actionWithAction(CCFiniteTimeAction *pAction, unsigned int times) +{ + return CCRepeat::create(pAction, times); +} CCRepeat* CCRepeat::create(CCFiniteTimeAction *pAction, unsigned int times) { @@ -515,17 +496,10 @@ CCRepeatForever::~CCRepeatForever() CC_SAFE_RELEASE(m_pInnerAction); } -// CCRepeatForever *CCRepeatForever::actionWithAction(CCActionInterval *pAction) -// { -// CCRepeatForever *pRet = new CCRepeatForever(); -// if (pRet && pRet->initWithAction(pAction)) -// { -// pRet->autorelease(); -// return pRet; -// } -// CC_SAFE_DELETE(pRet); -// return NULL; -// } +CCRepeatForever *CCRepeatForever::actionWithAction(CCActionInterval *pAction) +{ + return CCRepeatForever::create(pAction); +} CCRepeatForever *CCRepeatForever::create(CCActionInterval *pAction) { @@ -598,30 +572,30 @@ CCActionInterval *CCRepeatForever::reverse() // // Spawn // -// CCFiniteTimeAction* CCSpawn::actions(CCFiniteTimeAction *pAction1, ...) -// { -// va_list params; -// va_start(params, pAction1); -// -// CCFiniteTimeAction *pNow; -// CCFiniteTimeAction *pPrev = pAction1; -// -// while (pAction1) -// { -// pNow = va_arg(params, CCFiniteTimeAction*); -// if (pNow) -// { -// pPrev = actionOneTwo(pPrev, pNow); -// } -// else -// { -// break; -// } -// } -// -// va_end(params); -// return pPrev; -// } +CCFiniteTimeAction* CCSpawn::actions(CCFiniteTimeAction *pAction1, ...) +{ + va_list params; + va_start(params, pAction1); + + CCFiniteTimeAction *pNow; + CCFiniteTimeAction *pPrev = pAction1; + + while (pAction1) + { + pNow = va_arg(params, CCFiniteTimeAction*); + if (pNow) + { + pPrev = actionOneTwo(pPrev, pNow); + } + else + { + break; + } + } + + va_end(params); + return pPrev; +} CCFiniteTimeAction* CCSpawn::create(CCFiniteTimeAction *pAction1, ...) { @@ -648,17 +622,10 @@ CCFiniteTimeAction* CCSpawn::create(CCFiniteTimeAction *pAction1, ...) return pPrev; } -// CCFiniteTimeAction* CCSpawn::actionWithArray(CCArray *actions) -// { -// CCFiniteTimeAction* prev = (CCFiniteTimeAction*)actions->objectAtIndex(0); -// -// for (unsigned int i = 1; i < actions->count(); ++i) -// { -// prev = actionOneTwo(prev, (CCFiniteTimeAction*)actions->objectAtIndex(i)); -// } -// -// return prev; -// } +CCFiniteTimeAction* CCSpawn::actionWithArray(CCArray *actions) +{ + return CCSpawn::create(actions); +} CCFiniteTimeAction* CCSpawn::create(CCArray *actions) { @@ -672,14 +639,10 @@ CCFiniteTimeAction* CCSpawn::create(CCArray *actions) return prev; } -// CCSpawn* CCSpawn::actionOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2) -// { -// CCSpawn *pSpawn = new CCSpawn(); -// pSpawn->initOneTwo(pAction1, pAction2); -// pSpawn->autorelease(); -// -// return pSpawn; -// } +CCSpawn* CCSpawn::actionOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2) +{ + return CCSpawn::create(pAction1, pAction2); +} CCSpawn* CCSpawn::create(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2) { @@ -789,14 +752,10 @@ CCActionInterval* CCSpawn::reverse(void) // // RotateTo // -// CCRotateTo* CCRotateTo::actionWithDuration(float duration, float fDeltaAngle) -// { -// CCRotateTo* pRotateTo = new CCRotateTo(); -// pRotateTo->initWithDuration(duration, fDeltaAngle); -// pRotateTo->autorelease(); -// -// return pRotateTo; -// } +CCRotateTo* CCRotateTo::actionWithDuration(float duration, float fDeltaAngle) +{ + return CCRotateTo::create(duration, fDeltaAngle); +} CCRotateTo* CCRotateTo::create(float duration, float fDeltaAngle) { @@ -880,14 +839,10 @@ void CCRotateTo::update(float time) // // RotateBy // -// CCRotateBy* CCRotateBy::actionWithDuration(float duration, float fDeltaAngle) -// { -// CCRotateBy *pRotateBy = new CCRotateBy(); -// pRotateBy->initWithDuration(duration, fDeltaAngle); -// pRotateBy->autorelease(); -// -// return pRotateBy; -// } +CCRotateBy* CCRotateBy::actionWithDuration(float duration, float fDeltaAngle) +{ + return CCRotateBy::create(duration, fDeltaAngle); +} CCRotateBy* CCRotateBy::create(float duration, float fDeltaAngle) { @@ -955,14 +910,10 @@ CCActionInterval* CCRotateBy::reverse(void) // // MoveTo // -// CCMoveTo* CCMoveTo::actionWithDuration(float duration, const CCPoint& position) -// { -// CCMoveTo *pMoveTo = new CCMoveTo(); -// pMoveTo->initWithDuration(duration, position); -// pMoveTo->autorelease(); -// -// return pMoveTo; -// } +CCMoveTo* CCMoveTo::actionWithDuration(float duration, const CCPoint& position) +{ + return CCMoveTo::create(duration, position); +} CCMoveTo* CCMoveTo::create(float duration, const CCPoint& position) { @@ -1026,14 +977,10 @@ void CCMoveTo::update(float time) // // MoveBy // -// CCMoveBy* CCMoveBy::actionWithDuration(float duration, const CCPoint& position) -// { -// CCMoveBy *pMoveBy = new CCMoveBy(); -// pMoveBy->initWithDuration(duration, position); -// pMoveBy->autorelease(); -// -// return pMoveBy; -// } +CCMoveBy* CCMoveBy::actionWithDuration(float duration, const CCPoint& position) +{ + return CCMoveBy::create(duration, position); +} CCMoveBy* CCMoveBy::create(float duration, const CCPoint& position) { @@ -1093,23 +1040,10 @@ CCActionInterval* CCMoveBy::reverse(void) // // CCSkewTo // -// CCSkewTo* CCSkewTo::actionWithDuration(float t, float sx, float sy) -// { -// CCSkewTo *pSkewTo = new CCSkewTo(); -// if (pSkewTo) -// { -// if (pSkewTo->initWithDuration(t, sx, sy)) -// { -// pSkewTo->autorelease(); -// } -// else -// { -// CC_SAFE_DELETE(pSkewTo); -// } -// } -// -// return pSkewTo; -// } +CCSkewTo* CCSkewTo::actionWithDuration(float t, float sx, float sy) +{ + return CCSkewTo::create(t, sx, sy); +} CCSkewTo* CCSkewTo::create(float t, float sx, float sy) { @@ -1237,23 +1171,10 @@ CCSkewTo::CCSkewTo() // // CCSkewBy // -// CCSkewBy* CCSkewBy::actionWithDuration(float t, float sx, float sy) -// { -// CCSkewBy *pSkewBy = new CCSkewBy(); -// if (pSkewBy) -// { -// if (pSkewBy->initWithDuration(t, sx, sy)) -// { -// pSkewBy->autorelease(); -// } -// else -// { -// CC_SAFE_DELETE(pSkewBy); -// } -// } -// -// return pSkewBy; -// } +CCSkewBy* CCSkewBy::actionWithDuration(float t, float sx, float sy) +{ + return CCSkewBy::create(t, sx, sy); +} CCSkewBy* CCSkewBy::create(float t, float sx, float sy) { @@ -1305,14 +1226,10 @@ CCActionInterval* CCSkewBy::reverse() // // JumpBy // -// CCJumpBy* CCJumpBy::actionWithDuration(float duration, const CCPoint& position, float height, unsigned int jumps) -// { -// CCJumpBy *pJumpBy = new CCJumpBy(); -// pJumpBy->initWithDuration(duration, position, height, jumps); -// pJumpBy->autorelease(); -// -// return pJumpBy; -// } +CCJumpBy* CCJumpBy::actionWithDuration(float duration, const CCPoint& position, float height, unsigned int jumps) +{ + return CCJumpBy::create(duration, position, height, jumps); +} CCJumpBy* CCJumpBy::create(float duration, const CCPoint& position, float height, unsigned int jumps) { @@ -1388,14 +1305,10 @@ CCActionInterval* CCJumpBy::reverse(void) // // JumpTo // -// CCJumpTo* CCJumpTo::actionWithDuration(float duration, const CCPoint& position, float height, int jumps) -// { -// CCJumpTo *pJumpTo = new CCJumpTo(); -// pJumpTo->initWithDuration(duration, position, height, jumps); -// pJumpTo->autorelease(); -// -// return pJumpTo; -// } +CCJumpTo* CCJumpTo::actionWithDuration(float duration, const CCPoint& position, float height, int jumps) +{ + return CCJumpTo::create(duration, position, height, jumps); +} CCJumpTo* CCJumpTo::create(float duration, const CCPoint& position, float height, int jumps) { @@ -1450,14 +1363,10 @@ static inline float bezierat( float a, float b, float c, float d, float t ) // // BezierBy // -// CCBezierBy* CCBezierBy::actionWithDuration(float t, const ccBezierConfig& c) -// { -// CCBezierBy *pBezierBy = new CCBezierBy(); -// pBezierBy->initWithDuration(t, c); -// pBezierBy->autorelease(); -// -// return pBezierBy; -// } +CCBezierBy* CCBezierBy::actionWithDuration(float t, const ccBezierConfig& c) +{ + return CCBezierBy::create(t, c); +} CCBezierBy* CCBezierBy::create(float t, const ccBezierConfig& c) { @@ -1543,14 +1452,10 @@ CCActionInterval* CCBezierBy::reverse(void) // // BezierTo // -// CCBezierTo* CCBezierTo::actionWithDuration(float t, const ccBezierConfig& c) -// { -// CCBezierTo *pBezierTo = new CCBezierTo(); -// pBezierTo->initWithDuration(t, c); -// pBezierTo->autorelease(); -// -// return pBezierTo; -// } +CCBezierTo* CCBezierTo::actionWithDuration(float t, const ccBezierConfig& c) +{ + return CCBezierTo::create(t, c); +} CCBezierTo* CCBezierTo::create(float t, const ccBezierConfig& c) { @@ -1596,14 +1501,10 @@ void CCBezierTo::startWithTarget(CCNode *pTarget) // // ScaleTo // -// CCScaleTo* CCScaleTo::actionWithDuration(float duration, float s) -// { -// CCScaleTo *pScaleTo = new CCScaleTo(); -// pScaleTo->initWithDuration(duration, s); -// pScaleTo->autorelease(); -// -// return pScaleTo; -// } +CCScaleTo* CCScaleTo::actionWithDuration(float duration, float s) +{ + return CCScaleTo::create(duration, s); +} CCScaleTo* CCScaleTo::create(float duration, float s) { @@ -1627,14 +1528,10 @@ bool CCScaleTo::initWithDuration(float duration, float s) return false; } -// CCScaleTo* CCScaleTo::actionWithDuration(float duration, float sx, float sy) -// { -// CCScaleTo *pScaleTo = new CCScaleTo(); -// pScaleTo->initWithDuration(duration, sx, sy); -// pScaleTo->autorelease(); -// -// return pScaleTo; -// } +CCScaleTo* CCScaleTo::actionWithDuration(float duration, float sx, float sy) +{ + return CCScaleTo::create(duration, sx, sy); +} CCScaleTo* CCScaleTo::create(float duration, float sx, float sy) { @@ -1703,23 +1600,15 @@ void CCScaleTo::update(float time) // // ScaleBy // -// CCScaleBy* CCScaleBy::actionWithDuration(float duration, float s) -// { -// CCScaleBy *pScaleBy = new CCScaleBy(); -// pScaleBy->initWithDuration(duration, s); -// pScaleBy->autorelease(); -// -// return pScaleBy; -// } -// -// CCScaleBy* CCScaleBy::actionWithDuration(float duration, float sx, float sy) -// { -// CCScaleBy *pScaleBy = new CCScaleBy(); -// pScaleBy->initWithDuration(duration, sx, sy); -// pScaleBy->autorelease(); -// -// return pScaleBy; -// } +CCScaleBy* CCScaleBy::actionWithDuration(float duration, float s) +{ + return create(duration, s); +} + +CCScaleBy* CCScaleBy::actionWithDuration(float duration, float sx, float sy) +{ + return create(duration, sx, sy); +} CCScaleBy* CCScaleBy::create(float duration, float s) { @@ -1778,14 +1667,10 @@ CCActionInterval* CCScaleBy::reverse(void) // // Blink // -// CCBlink* CCBlink::actionWithDuration(float duration, unsigned int uBlinks) -// { -// CCBlink *pBlink = new CCBlink(); -// pBlink->initWithDuration(duration, uBlinks); -// pBlink->autorelease(); -// -// return pBlink; -// } +CCBlink* CCBlink::actionWithDuration(float duration, unsigned int uBlinks) +{ + return CCBlink::create(duration, uBlinks); +} CCBlink* CCBlink::create(float duration, unsigned int uBlinks) { @@ -1850,15 +1735,10 @@ CCActionInterval* CCBlink::reverse(void) // // FadeIn // -// CCFadeIn* CCFadeIn::actionWithDuration(float d) -// { -// CCFadeIn* pAction = new CCFadeIn(); -// -// pAction->initWithDuration(d); -// pAction->autorelease(); -// -// return pAction; -// } +CCFadeIn* CCFadeIn::actionWithDuration(float d) +{ + return CCFadeIn::create(d); +} CCFadeIn* CCFadeIn::create(float d) { @@ -1910,15 +1790,10 @@ CCActionInterval* CCFadeIn::reverse(void) // // FadeOut // -// CCFadeOut* CCFadeOut::actionWithDuration(float d) -// { -// CCFadeOut* pAction = new CCFadeOut(); -// -// pAction->initWithDuration(d); -// pAction->autorelease(); -// -// return pAction; -// } +CCFadeOut* CCFadeOut::actionWithDuration(float d) +{ + return CCFadeOut::create(d); +} CCFadeOut* CCFadeOut::create(float d) { @@ -1970,14 +1845,10 @@ CCActionInterval* CCFadeOut::reverse(void) // // FadeTo // -// CCFadeTo* CCFadeTo::actionWithDuration(float duration, GLubyte opacity) -// { -// CCFadeTo *pFadeTo = new CCFadeTo(); -// pFadeTo->initWithDuration(duration, opacity); -// pFadeTo->autorelease(); -// -// return pFadeTo; -// } +CCFadeTo* CCFadeTo::actionWithDuration(float duration, GLubyte opacity) +{ + return CCFadeTo::create(duration, opacity); +} CCFadeTo* CCFadeTo::create(float duration, GLubyte opacity) { @@ -2047,14 +1918,10 @@ void CCFadeTo::update(float time) // // TintTo // -// CCTintTo* CCTintTo::actionWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue) -// { -// CCTintTo *pTintTo = new CCTintTo(); -// pTintTo->initWithDuration(duration, red, green, blue); -// pTintTo->autorelease(); -// -// return pTintTo; -// } +CCTintTo* CCTintTo::actionWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue) +{ + return CCTintTo::create(duration, red, green, blue); +} CCTintTo* CCTintTo::create(float duration, GLubyte red, GLubyte green, GLubyte blue) { @@ -2124,14 +1991,10 @@ void CCTintTo::update(float time) // // TintBy // -// CCTintBy* CCTintBy::actionWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue) -// { -// CCTintBy *pTintBy = new CCTintBy(); -// pTintBy->initWithDuration(duration, deltaRed, deltaGreen, deltaBlue); -// pTintBy->autorelease(); -// -// return pTintBy; -// } +CCTintBy* CCTintBy::actionWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue) +{ + return CCTintBy::create(duration, deltaRed, deltaGreen, deltaBlue); +} CCTintBy* CCTintBy::create(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue) { @@ -2212,15 +2075,10 @@ CCActionInterval* CCTintBy::reverse(void) // // DelayTime // -// CCDelayTime* CCDelayTime::actionWithDuration(float d) -// { -// CCDelayTime* pAction = new CCDelayTime(); -// -// pAction->initWithDuration(d); -// pAction->autorelease(); -// -// return pAction; -// } +CCDelayTime* CCDelayTime::actionWithDuration(float d) +{ + return CCDelayTime::create(d); +} CCDelayTime* CCDelayTime::create(float d) { @@ -2269,15 +2127,10 @@ CCActionInterval* CCDelayTime::reverse(void) // // ReverseTime // -// CCReverseTime* CCReverseTime::actionWithAction(CCFiniteTimeAction *pAction) -// { -// // casting to prevent warnings -// CCReverseTime *pReverseTime = new CCReverseTime(); -// pReverseTime->initWithAction(pAction); -// pReverseTime->autorelease(); -// -// return pReverseTime; -// } +CCReverseTime* CCReverseTime::actionWithAction(CCFiniteTimeAction *pAction) +{ + return CCReverseTime::create(pAction); +} CCReverseTime* CCReverseTime::create(CCFiniteTimeAction *pAction) { @@ -2369,14 +2222,10 @@ CCActionInterval* CCReverseTime::reverse(void) // // Animate // -// CCAnimate* CCAnimate::actionWithAnimation(CCAnimation *pAnimation) -// { -// CCAnimate *pAnimate = new CCAnimate(); -// pAnimate->initWithAnimation(pAnimation); -// pAnimate->autorelease(); -// -// return pAnimate; -// } +CCAnimate* CCAnimate::actionWithAnimation(CCAnimation *pAnimation) +{ + return CCAnimate::create(pAnimation); +} CCAnimate* CCAnimate::create(CCAnimation *pAnimation) { @@ -2570,13 +2419,10 @@ CCTargetedAction::~CCTargetedAction() CC_SAFE_RELEASE(m_pAction); } -// CCTargetedAction* CCTargetedAction::actionWithTarget(CCNode* pTarget, CCFiniteTimeAction* pAction) -// { -// CCTargetedAction* p = new CCTargetedAction(); -// p->initWithTarget(pTarget, pAction); -// p->autorelease(); -// return p; -// } +CCTargetedAction* CCTargetedAction::actionWithTarget(CCNode* pTarget, CCFiniteTimeAction* pAction) +{ + return CCTargetedAction::create(pTarget, pAction); +} CCTargetedAction* CCTargetedAction::create(CCNode* pTarget, CCFiniteTimeAction* pAction) { diff --git a/cocos2dx/actions/CCActionInterval.h b/cocos2dx/actions/CCActionInterval.h index d3584c3b6a..399976941c 100644 --- a/cocos2dx/actions/CCActionInterval.h +++ b/cocos2dx/actions/CCActionInterval.h @@ -75,7 +75,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCActionInterval* actionWithDuration(float d); + static CCActionInterval* actionWithDuration(float d); /** creates the action */ static CCActionInterval* create(float d); @@ -110,15 +110,15 @@ public: /** helper constructor to create an array of sequenceable actions @warning: This interface will be deprecated in future. */ - //static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...); + static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...); /** helper contructor to create an array of sequenceable actions given an array @warning: This interface will be deprecated in future. */ - //static CCFiniteTimeAction* actionWithArray(CCArray *arrayOfActions); + static CCFiniteTimeAction* actionWithArray(CCArray *arrayOfActions); /** creates the action @warning: This interface will be deprecated in future. */ - //static CCSequence* actionOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo); + static CCSequence* actionOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo); /** helper constructor to create an array of sequenceable actions */ static CCFiniteTimeAction* create(CCFiniteTimeAction *pAction1, ...); @@ -170,7 +170,7 @@ public: /** creates a CCRepeat action. Times is an unsigned integer between 1 and pow(2,30) @warning: This interface will be deprecated in future. */ - //static CCRepeat* actionWithAction(CCFiniteTimeAction *pAction, unsigned int times); + static CCRepeat* actionWithAction(CCFiniteTimeAction *pAction, unsigned int times); /** creates a CCRepeat action. Times is an unsigned integer between 1 and pow(2,30) */ static CCRepeat* create(CCFiniteTimeAction *pAction, unsigned int times); @@ -222,7 +222,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCRepeatForever* actionWithAction(CCActionInterval *pAction); + static CCRepeatForever* actionWithAction(CCActionInterval *pAction); /** creates the action */ static CCRepeatForever* create(CCActionInterval *pAction); protected: @@ -250,17 +250,17 @@ public: /** helper constructor to create an array of spawned actions @warning: This interface will be deprecated in future. */ - //static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...); + static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...); /** helper contructor to create an array of spawned actions given an array @warning: This interface will be deprecated in future. */ - //static CCFiniteTimeAction* actionWithArray(CCArray *arrayOfActions); + static CCFiniteTimeAction* actionWithArray(CCArray *arrayOfActions); /** creates the Spawn action @warning: This interface will be deprecated in future. */ - //static CCSpawn* actionOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2); + static CCSpawn* actionOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2); /** helper constructor to create an array of spawned actions */ static CCFiniteTimeAction* create(CCFiniteTimeAction *pAction1, ...); @@ -294,7 +294,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCRotateTo* actionWithDuration(float duration, float fDeltaAngle); + static CCRotateTo* actionWithDuration(float duration, float fDeltaAngle); /** creates the action */ static CCRotateTo* create(float duration, float fDeltaAngle); protected: @@ -320,7 +320,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCRotateBy* actionWithDuration(float duration, float fDeltaAngle); + static CCRotateBy* actionWithDuration(float duration, float fDeltaAngle); /** creates the action */ static CCRotateBy* create(float duration, float fDeltaAngle); protected: @@ -344,7 +344,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCMoveTo* actionWithDuration(float duration, const CCPoint& position); + static CCMoveTo* actionWithDuration(float duration, const CCPoint& position); /** creates the action */ static CCMoveTo* create(float duration, const CCPoint& position); protected: @@ -371,7 +371,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCMoveBy* actionWithDuration(float duration, const CCPoint& position); + static CCMoveBy* actionWithDuration(float duration, const CCPoint& position); /** creates the action */ static CCMoveBy* create(float duration, const CCPoint& position); }; @@ -392,7 +392,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCSkewTo* actionWithDuration(float t, float sx, float sy); + static CCSkewTo* actionWithDuration(float t, float sx, float sy); /** creates the action */ static CCSkewTo* create(float t, float sx, float sy); @@ -421,7 +421,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCSkewBy* actionWithDuration(float t, float deltaSkewX, float deltaSkewY); + static CCSkewBy* actionWithDuration(float t, float deltaSkewX, float deltaSkewY); /** creates the action */ static CCSkewBy* create(float t, float deltaSkewX, float deltaSkewY); }; @@ -443,7 +443,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCJumpBy* actionWithDuration(float duration, const CCPoint& position, float height, unsigned int jumps); + static CCJumpBy* actionWithDuration(float duration, const CCPoint& position, float height, unsigned int jumps); /** creates the action */ static CCJumpBy* create(float duration, const CCPoint& position, float height, unsigned int jumps); protected: @@ -465,7 +465,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - // static CCJumpTo* actionWithDuration(float duration, const CCPoint& position, float height, int jumps); + static CCJumpTo* actionWithDuration(float duration, const CCPoint& position, float height, int jumps); /** creates the action */ static CCJumpTo* create(float duration, const CCPoint& position, float height, int jumps); }; @@ -498,7 +498,7 @@ public: /** creates the action with a duration and a bezier configuration @warning: This interface will be deprecated in future. */ - //static CCBezierBy* actionWithDuration(float t, const ccBezierConfig& c); + static CCBezierBy* actionWithDuration(float t, const ccBezierConfig& c); /** creates the action with a duration and a bezier configuration */ static CCBezierBy* create(float t, const ccBezierConfig& c); protected: @@ -519,7 +519,7 @@ public: /** creates the action with a duration and a bezier configuration @warning: This interface will be deprecated in future. */ - //static CCBezierTo* actionWithDuration(float t, const ccBezierConfig& c); + static CCBezierTo* actionWithDuration(float t, const ccBezierConfig& c); /** creates the action with a duration and a bezier configuration */ static CCBezierTo* create(float t, const ccBezierConfig& c); @@ -545,12 +545,12 @@ public: /** creates the action with the same scale factor for X and Y @warning: This interface will be deprecated in future. */ - //static CCScaleTo* actionWithDuration(float duration, float s); + static CCScaleTo* actionWithDuration(float duration, float s); /** creates the action with and X factor and a Y factor @warning: This interface will be deprecated in future. */ - //static CCScaleTo* actionWithDuration(float duration, float sx, float sy); + static CCScaleTo* actionWithDuration(float duration, float sx, float sy); /** creates the action with the same scale factor for X and Y */ static CCScaleTo* create(float duration, float s); @@ -581,12 +581,12 @@ public: /** creates the action with the same scale factor for X and Y @warning: This interface will be deprecated in future. */ - //static CCScaleBy* actionWithDuration(float duration, float s); + static CCScaleBy* actionWithDuration(float duration, float s); /** creates the action with and X factor and a Y factor @warning: This interface will be deprecated in future. */ - //static CCScaleBy* actionWithDuration(float duration, float sx, float sy); + static CCScaleBy* actionWithDuration(float duration, float sx, float sy); /** creates the action with the same scale factor for X and Y */ static CCScaleBy* create(float duration, float s); @@ -611,7 +611,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCBlink* actionWithDuration(float duration, unsigned int uBlinks); + static CCBlink* actionWithDuration(float duration, unsigned int uBlinks); /** creates the action */ static CCBlink* create(float duration, unsigned int uBlinks); protected: @@ -632,7 +632,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCFadeIn* actionWithDuration(float d); + static CCFadeIn* actionWithDuration(float d); /** creates the action */ static CCFadeIn* create(float d); }; @@ -651,7 +651,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCFadeOut* actionWithDuration(float d); + static CCFadeOut* actionWithDuration(float d); /** creates the action */ static CCFadeOut* create(float d); @@ -674,7 +674,7 @@ public: /** creates an action with duration and opacity @warning: This interface will be deprecated in future. */ - //static CCFadeTo* actionWithDuration(float duration, GLubyte opacity); + static CCFadeTo* actionWithDuration(float duration, GLubyte opacity); /** creates an action with duration and opacity */ static CCFadeTo* create(float duration, GLubyte opacity); protected: @@ -700,7 +700,7 @@ public: /** creates an action with duration and color @warning: This interface will be deprecated in future. */ - //static CCTintTo* actionWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue); + static CCTintTo* actionWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue); /** creates an action with duration and color */ static CCTintTo* create(float duration, GLubyte red, GLubyte green, GLubyte blue); protected: @@ -726,7 +726,7 @@ public: /** creates an action with duration and color @warning: This interface will be deprecated in future. */ - // static CCTintBy* actionWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); + static CCTintBy* actionWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); /** creates an action with duration and color */ static CCTintBy* create(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); protected: @@ -752,7 +752,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCDelayTime* actionWithDuration(float d); + static CCDelayTime* actionWithDuration(float d); /** creates the action */ static CCDelayTime* create(float d); @@ -784,7 +784,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - //static CCReverseTime* actionWithAction(CCFiniteTimeAction *pAction); + static CCReverseTime* actionWithAction(CCFiniteTimeAction *pAction); /** creates the action */ static CCReverseTime* create(CCFiniteTimeAction *pAction); protected: @@ -813,7 +813,7 @@ public: /** creates the action with an Animation and will restore the original frame when the animation is over @warning: This interface will be deprecated in future. */ - //static CCAnimate* actionWithAnimation(CCAnimation *pAnimation); + static CCAnimate* actionWithAnimation(CCAnimation *pAnimation); /** creates the action with an Animation and will restore the original frame when the animation is over */ static CCAnimate* create(CCAnimation *pAnimation); CC_SYNTHESIZE_RETAIN(CCAnimation*, m_pAnimation, Animation) @@ -835,7 +835,7 @@ public: /** Create an action with the specified action and forced target @warning: This interface will be deprecated in future. */ - //static CCTargetedAction* actionWithTarget(CCNode* pTarget, CCFiniteTimeAction* pAction); + static CCTargetedAction* actionWithTarget(CCNode* pTarget, CCFiniteTimeAction* pAction); /** Create an action with the specified action and forced target */ static CCTargetedAction* create(CCNode* pTarget, CCFiniteTimeAction* pAction); diff --git a/cocos2dx/actions/CCActionPageTurn3D.cpp b/cocos2dx/actions/CCActionPageTurn3D.cpp index b8dcf7b21e..413d738669 100644 --- a/cocos2dx/actions/CCActionPageTurn3D.cpp +++ b/cocos2dx/actions/CCActionPageTurn3D.cpp @@ -27,24 +27,10 @@ THE SOFTWARE. NS_CC_BEGIN -// CCPageTurn3D* CCPageTurn3D::actionWithSize(const ccGridSize& gridSize, float time) -// { -// CCPageTurn3D *pAction = new CCPageTurn3D(); -// -// if (pAction) -// { -// if (pAction->initWithSize(gridSize, time)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pAction); -// } -// } -// -// return pAction; -// } +CCPageTurn3D* CCPageTurn3D::actionWithSize(const ccGridSize& gridSize, float time) +{ + return CCPageTurn3D::create(gridSize, time); +} CCPageTurn3D* CCPageTurn3D::create(const ccGridSize& gridSize, float time) { diff --git a/cocos2dx/actions/CCActionPageTurn3D.h b/cocos2dx/actions/CCActionPageTurn3D.h index 733756ce6e..7ec14caac2 100644 --- a/cocos2dx/actions/CCActionPageTurn3D.h +++ b/cocos2dx/actions/CCActionPageTurn3D.h @@ -46,7 +46,7 @@ public: /** create the action @warning: This interface will be deprecated in future. */ - //static CCPageTurn3D* actionWithSize(const ccGridSize& gridSize, float time); + static CCPageTurn3D* actionWithSize(const ccGridSize& gridSize, float time); /** create the action */ static CCPageTurn3D* create(const ccGridSize& gridSize, float time); }; diff --git a/cocos2dx/actions/CCActionProgressTimer.cpp b/cocos2dx/actions/CCActionProgressTimer.cpp index 84ff8e1ca6..b778d9e6f4 100644 --- a/cocos2dx/actions/CCActionProgressTimer.cpp +++ b/cocos2dx/actions/CCActionProgressTimer.cpp @@ -32,14 +32,10 @@ NS_CC_BEGIN // implementation of CCProgressTo -// CCProgressTo* CCProgressTo::actionWithDuration(float duration, float fPercent) -// { -// CCProgressTo *pProgressTo = new CCProgressTo(); -// pProgressTo->initWithDuration(duration, fPercent); -// pProgressTo->autorelease(); -// -// return pProgressTo; -// } +CCProgressTo* CCProgressTo::actionWithDuration(float duration, float fPercent) +{ + return CCProgressTo::create(duration, fPercent); +} CCProgressTo* CCProgressTo::create(float duration, float fPercent) { @@ -105,14 +101,10 @@ void CCProgressTo::update(float time) // implementation of CCProgressFromTo -// CCProgressFromTo* CCProgressFromTo::actionWithDuration(float duration, float fFromPercentage, float fToPercentage) -// { -// CCProgressFromTo *pProgressFromTo = new CCProgressFromTo(); -// pProgressFromTo->initWithDuration(duration, fFromPercentage, fToPercentage); -// pProgressFromTo->autorelease(); -// -// return pProgressFromTo; -// } +CCProgressFromTo* CCProgressFromTo::actionWithDuration(float duration, float fFromPercentage, float fToPercentage) +{ + return CCProgressFromTo::create(duration, fFromPercentage, fToPercentage); +} CCProgressFromTo* CCProgressFromTo::create(float duration, float fFromPercentage, float fToPercentage) { diff --git a/cocos2dx/actions/CCActionProgressTimer.h b/cocos2dx/actions/CCActionProgressTimer.h index 7034c45c80..9e09094e53 100644 --- a/cocos2dx/actions/CCActionProgressTimer.h +++ b/cocos2dx/actions/CCActionProgressTimer.h @@ -47,7 +47,7 @@ public: /** Creates and initializes with a duration and a percent @warning: This interface will be deprecated in future. */ - //static CCProgressTo* actionWithDuration(float duration, float fPercent); + static CCProgressTo* actionWithDuration(float duration, float fPercent); /** Creates and initializes with a duration and a percent */ static CCProgressTo* create(float duration, float fPercent); protected: @@ -74,7 +74,7 @@ public: /** Creates and initializes the action with a duration, a "from" percentage and a "to" percentage @warning: This interface will be deprecated in future. */ - //static CCProgressFromTo* actionWithDuration(float duration, float fFromPercentage, float fToPercentage); + static CCProgressFromTo* actionWithDuration(float duration, float fFromPercentage, float fToPercentage); /** Creates and initializes the action with a duration, a "from" percentage and a "to" percentage */ static CCProgressFromTo* create(float duration, float fFromPercentage, float fToPercentage); protected: diff --git a/cocos2dx/actions/CCActionTiledGrid.cpp b/cocos2dx/actions/CCActionTiledGrid.cpp index ccfb43994c..9c38fc8c04 100644 --- a/cocos2dx/actions/CCActionTiledGrid.cpp +++ b/cocos2dx/actions/CCActionTiledGrid.cpp @@ -41,24 +41,10 @@ struct Tile // implementation of ShakyTiles3D -// CCShakyTiles3D* CCShakyTiles3D::actionWithRange(int nRange, bool bShakeZ,const ccGridSize& gridSize, float duration) -// { -// CCShakyTiles3D *pAction = new CCShakyTiles3D(); -// -// if (pAction) -// { -// if (pAction->initWithRange(nRange, bShakeZ, gridSize, duration)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pAction); -// } -// } -// -// return pAction; -// } +CCShakyTiles3D* CCShakyTiles3D::actionWithRange(int nRange, bool bShakeZ,const ccGridSize& gridSize, float duration) +{ + return CCShakyTiles3D::create(nRange, bShakeZ, gridSize, duration); +} CCShakyTiles3D* CCShakyTiles3D::create(int nRange, bool bShakeZ,const ccGridSize& gridSize, float duration) { @@ -153,24 +139,10 @@ void CCShakyTiles3D::update(float time) // implementation of CCShatteredTiles3D -// CCShatteredTiles3D* CCShatteredTiles3D::actionWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize, float duration) -// { -// CCShatteredTiles3D *pAction = new CCShatteredTiles3D(); -// -// if (pAction) -// { -// if (pAction->initWithRange(nRange, bShatterZ, gridSize, duration)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pAction); -// } -// } -// -// return pAction; -// } +CCShatteredTiles3D* CCShatteredTiles3D::actionWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize, float duration) +{ + return CCShatteredTiles3D::create(nRange, bShatterZ, gridSize, duration); +} CCShatteredTiles3D* CCShatteredTiles3D::create(int nRange, bool bShatterZ, const ccGridSize& gridSize, float duration) { @@ -271,24 +243,10 @@ void CCShatteredTiles3D::update(float time) // implementation of CCShuffleTiles -// CCShuffleTiles* CCShuffleTiles::actionWithSeed(int s, const ccGridSize& gridSize, float duration) -// { -// CCShuffleTiles *pAction = new CCShuffleTiles(); -// -// if (pAction) -// { -// if (pAction->initWithSeed(s, gridSize, duration)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pAction); -// } -// } -// -// return pAction; -// } +CCShuffleTiles* CCShuffleTiles::actionWithSeed(int s, const ccGridSize& gridSize, float duration) +{ + return CCShuffleTiles::create(s, gridSize, duration); +} CCShuffleTiles* CCShuffleTiles::create(int s, const ccGridSize& gridSize, float duration) { @@ -454,24 +412,10 @@ void CCShuffleTiles::update(float time) // implementation of CCFadeOutTRTiles -// CCFadeOutTRTiles* CCFadeOutTRTiles::actionWithSize(const ccGridSize& gridSize, float time) -// { -// CCFadeOutTRTiles *pAction = new CCFadeOutTRTiles(); -// -// if (pAction) -// { -// if (pAction->initWithSize(gridSize, time)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pAction); -// } -// } -// -// return pAction; -// } +CCFadeOutTRTiles* CCFadeOutTRTiles::actionWithSize(const ccGridSize& gridSize, float time) +{ + return CCFadeOutTRTiles::create( gridSize, time); +} CCFadeOutTRTiles* CCFadeOutTRTiles::create(const ccGridSize& gridSize, float time) { @@ -561,24 +505,10 @@ void CCFadeOutTRTiles::update(float time) } // implementation of CCFadeOutBLTiles -// CCFadeOutBLTiles* CCFadeOutBLTiles::actionWithSize(const ccGridSize& gridSize, float time) -// { -// CCFadeOutBLTiles *pAction = new CCFadeOutBLTiles(); -// -// if (pAction) -// { -// if (pAction->initWithSize(gridSize, time)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pAction); -// } -// } -// -// return pAction; -// } +CCFadeOutBLTiles* CCFadeOutBLTiles::actionWithSize(const ccGridSize& gridSize, float time) +{ + return CCFadeOutBLTiles::create(gridSize, time); +} CCFadeOutBLTiles* CCFadeOutBLTiles::create(const ccGridSize& gridSize, float time) { @@ -612,24 +542,10 @@ float CCFadeOutBLTiles::testFunc(const ccGridSize& pos, float time) // implementation of CCFadeOutUpTiles -// CCFadeOutUpTiles* CCFadeOutUpTiles::actionWithSize(const ccGridSize& gridSize, float time) -// { -// CCFadeOutUpTiles *pAction = new CCFadeOutUpTiles(); -// -// if (pAction) -// { -// if (pAction->initWithSize(gridSize, time)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pAction); -// } -// } -// -// return pAction; -// } +CCFadeOutUpTiles* CCFadeOutUpTiles::actionWithSize(const ccGridSize& gridSize, float time) +{ + return CCFadeOutUpTiles::create(gridSize, time); +} CCFadeOutUpTiles* CCFadeOutUpTiles::create(const ccGridSize& gridSize, float time) { @@ -675,24 +591,10 @@ void CCFadeOutUpTiles::transformTile(const ccGridSize& pos, float distance) } // implementation of CCFadeOutDownTiles -// CCFadeOutDownTiles* CCFadeOutDownTiles::actionWithSize(const ccGridSize& gridSize, float time) -// { -// CCFadeOutDownTiles *pAction = new CCFadeOutDownTiles(); -// -// if (pAction) -// { -// if (pAction->initWithSize(gridSize, time)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pAction); -// } -// } -// -// return pAction; -// } +CCFadeOutDownTiles* CCFadeOutDownTiles::actionWithSize(const ccGridSize& gridSize, float time) +{ + return CCFadeOutDownTiles::create(gridSize, time); +} CCFadeOutDownTiles* CCFadeOutDownTiles::create(const ccGridSize& gridSize, float time) { @@ -725,19 +627,10 @@ float CCFadeOutDownTiles::testFunc(const ccGridSize& pos, float time) } // implementation of TurnOffTiles -// CCTurnOffTiles* CCTurnOffTiles::actionWithSize(const ccGridSize& size, float d) -// { -// CCTurnOffTiles* pAction = new CCTurnOffTiles(); -// if (pAction->initWithSize(size, d)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pAction); -// } -// return pAction; -// } +CCTurnOffTiles* CCTurnOffTiles::actionWithSize(const ccGridSize& size, float d) +{ + return CCTurnOffTiles::create( size, d); +} CCTurnOffTiles* CCTurnOffTiles::create(const ccGridSize& size, float d) { @@ -753,24 +646,10 @@ CCTurnOffTiles* CCTurnOffTiles::create(const ccGridSize& size, float d) return pAction; } -// CCTurnOffTiles* CCTurnOffTiles::actionWithSeed(int s, const ccGridSize& gridSize, float duration) -// { -// CCTurnOffTiles *pAction = new CCTurnOffTiles(); -// -// if (pAction) -// { -// if (pAction->initWithSeed(s, gridSize, duration)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pAction); -// } -// } -// -// return pAction; -// } +CCTurnOffTiles* CCTurnOffTiles::actionWithSeed(int s, const ccGridSize& gridSize, float duration) +{ + return CCTurnOffTiles::create(s, gridSize, duration); +} CCTurnOffTiles* CCTurnOffTiles::create(int s, const ccGridSize& gridSize, float duration) { @@ -902,24 +781,10 @@ void CCTurnOffTiles::update(float time) // implementation of CCWavesTiles3D -// CCWavesTiles3D* CCWavesTiles3D::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) -// { -// CCWavesTiles3D *pAction = new CCWavesTiles3D(); -// -// if (pAction) -// { -// if (pAction->initWithWaves(wav, amp, gridSize, duration)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pAction); -// } -// } -// -// return pAction; -// } +CCWavesTiles3D* CCWavesTiles3D::actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration) +{ + return CCWavesTiles3D::create(wav, amp, gridSize, duration); +} CCWavesTiles3D* CCWavesTiles3D::create(int wav, float amp, const ccGridSize& gridSize, float duration) { @@ -999,24 +864,10 @@ void CCWavesTiles3D::update(float time) // implementation of CCJumpTiles3D -// CCJumpTiles3D* CCJumpTiles3D::actionWithJumps(int j, float amp, const ccGridSize& gridSize, float duration) -// { -// CCJumpTiles3D *pAction = new CCJumpTiles3D(); -// -// if (pAction) -// { -// if (pAction->initWithJumps(j, amp, gridSize, duration)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pAction); -// } -// } -// -// return pAction; -// } +CCJumpTiles3D* CCJumpTiles3D::actionWithJumps(int j, float amp, const ccGridSize& gridSize, float duration) +{ + return CCJumpTiles3D::create(j, amp, gridSize, duration); +} CCJumpTiles3D* CCJumpTiles3D::create(int j, float amp, const ccGridSize& gridSize, float duration) { @@ -1107,24 +958,10 @@ void CCJumpTiles3D::update(float time) // implementation of CCSplitRows -// CCSplitRows* CCSplitRows::actionWithRows(int nRows, float duration) -// { -// CCSplitRows *pAction = new CCSplitRows(); -// -// if (pAction) -// { -// if (pAction->initWithRows(nRows, duration)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pAction); -// } -// } -// -// return pAction; -// } +CCSplitRows* CCSplitRows::actionWithRows(int nRows, float duration) +{ + return CCSplitRows::create(nRows, duration); +} CCSplitRows* CCSplitRows::create(int nRows, float duration) { @@ -1205,24 +1042,10 @@ void CCSplitRows::update(float time) // implementation of CCSplitCols -// CCSplitCols* CCSplitCols::actionWithCols(int nCols, float duration) -// { -// CCSplitCols *pAction = new CCSplitCols(); -// -// if (pAction) -// { -// if (pAction->initWithCols(nCols, duration)) -// { -// pAction->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(pAction); -// } -// } -// -// return pAction; -// } +CCSplitCols* CCSplitCols::actionWithCols(int nCols, float duration) +{ + return CCSplitCols::create(nCols, duration); +} CCSplitCols* CCSplitCols::create(int nCols, float duration) { diff --git a/cocos2dx/actions/CCActionTiledGrid.h b/cocos2dx/actions/CCActionTiledGrid.h index 02df236cf9..1c67f09d98 100644 --- a/cocos2dx/actions/CCActionTiledGrid.h +++ b/cocos2dx/actions/CCActionTiledGrid.h @@ -43,12 +43,10 @@ public: /** creates the action with a range, whether or not to shake Z vertices, a grid size, and duration @warning: This interface will be deprecated in future. */ - //static CCShakyTiles3D* actionWithRange(int nRange, bool bShakeZ, const ccGridSize& gridSize, - // float duration); + static CCShakyTiles3D* actionWithRange(int nRange, bool bShakeZ, const ccGridSize& gridSize, float duration); /** creates the action with a range, whether or not to shake Z vertices, a grid size, and duration */ - static CCShakyTiles3D* create(int nRange, bool bShakeZ, const ccGridSize& gridSize, - float duration); + static CCShakyTiles3D* create(int nRange, bool bShakeZ, const ccGridSize& gridSize, float duration); protected: int m_nRandrange; @@ -70,8 +68,8 @@ public: /** creates the action with a range, whether of not to shatter Z vertices, a grid size and duration @warning: This interface will be deprecated in future. */ - //static CCShatteredTiles3D* actionWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize, - // float duration); + static CCShatteredTiles3D* actionWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize, + float duration); /** creates the action with a range, whether of not to shatter Z vertices, a grid size and duration */ static CCShatteredTiles3D* create(int nRange, bool bShatterZ, const ccGridSize& gridSize, @@ -104,7 +102,7 @@ public: /** creates the action with a random seed, the grid size and the duration @warning: This interface will be deprecated in future. */ - //static CCShuffleTiles* actionWithSeed(int s, const ccGridSize& gridSize, float duration); + static CCShuffleTiles* actionWithSeed(int s, const ccGridSize& gridSize, float duration); /** creates the action with a random seed, the grid size and the duration */ static CCShuffleTiles* create(int s, const ccGridSize& gridSize, float duration); protected: @@ -130,7 +128,7 @@ public: /** creates the action with the grid size and the duration @warning: This interface will be deprecated in future. */ - //static CCFadeOutTRTiles* actionWithSize(const ccGridSize& gridSize, float time); + static CCFadeOutTRTiles* actionWithSize(const ccGridSize& gridSize, float time); /** creates the action with the grid size and the duration */ static CCFadeOutTRTiles* create(const ccGridSize& gridSize, float time); @@ -148,7 +146,7 @@ public: /** creates the action with the grid size and the duration @warning: This interface will be deprecated in future. */ - //static CCFadeOutBLTiles* actionWithSize(const ccGridSize& gridSize, float time); + static CCFadeOutBLTiles* actionWithSize(const ccGridSize& gridSize, float time); /** creates the action with the grid size and the duration */ static CCFadeOutBLTiles* create(const ccGridSize& gridSize, float time); @@ -167,7 +165,7 @@ public: /** creates the action with the grid size and the duration @warning: This interface will be deprecated in future. */ - //static CCFadeOutUpTiles* actionWithSize(const ccGridSize& gridSize, float time); + static CCFadeOutUpTiles* actionWithSize(const ccGridSize& gridSize, float time); /** creates the action with the grid size and the duration */ static CCFadeOutUpTiles* create(const ccGridSize& gridSize, float time); @@ -185,7 +183,7 @@ public: /** creates the action with the grid size and the duration @warning: This interface will be deprecated in future. */ - //static CCFadeOutDownTiles* actionWithSize(const ccGridSize& gridSize, float time); + static CCFadeOutDownTiles* actionWithSize(const ccGridSize& gridSize, float time); /** creates the action with the grid size and the duration */ static CCFadeOutDownTiles* create(const ccGridSize& gridSize, float time); @@ -212,11 +210,11 @@ public: /** creates the action with the grid size and the duration @warning: This interface will be deprecated in future. */ - //static CCTurnOffTiles* actionWithSize(const ccGridSize& size, float d); + static CCTurnOffTiles* actionWithSize(const ccGridSize& size, float d); /** creates the action with a random seed, the grid size and the duration @warning: This interface will be deprecated in future. */ - //static CCTurnOffTiles* actionWithSeed(int s, const ccGridSize& gridSize, float duration); + static CCTurnOffTiles* actionWithSeed(int s, const ccGridSize& gridSize, float duration); /** creates the action with the grid size and the duration */ static CCTurnOffTiles* create(const ccGridSize& size, float d); @@ -251,7 +249,7 @@ public: /** creates the action with a number of waves, the waves amplitude, the grid size and the duration @warning: This interface will be deprecated in future. */ - //static CCWavesTiles3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); + static CCWavesTiles3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); /** creates the action with a number of waves, the waves amplitude, the grid size and the duration */ static CCWavesTiles3D* create(int wav, float amp, const ccGridSize& gridSize, float duration); protected: @@ -283,7 +281,7 @@ public: /** creates the action with the number of jumps, the sin amplitude, the grid size and the duration @warning: This interface will be deprecated in future. */ - //static CCJumpTiles3D* actionWithJumps(int j, float amp, const ccGridSize& gridSize, float duration); + static CCJumpTiles3D* actionWithJumps(int j, float amp, const ccGridSize& gridSize, float duration); /** creates the action with the number of jumps, the sin amplitude, the grid size and the duration */ static CCJumpTiles3D* create(int j, float amp, const ccGridSize& gridSize, float duration); protected: @@ -307,7 +305,7 @@ public: /** creates the action with the number of rows to split and the duration @warning: This interface will be deprecated in future. */ - //static CCSplitRows* actionWithRows(int nRows, float duration); + static CCSplitRows* actionWithRows(int nRows, float duration); /** creates the action with the number of rows to split and the duration */ static CCSplitRows* create(int nRows, float duration); protected: @@ -330,7 +328,7 @@ public: /** creates the action with the number of columns to split and the duration @warning: This interface will be deprecated in future. */ - //static CCSplitCols* actionWithCols(int nCols, float duration); + static CCSplitCols* actionWithCols(int nCols, float duration); /** creates the action with the number of columns to split and the duration */ static CCSplitCols* create(int nCols, float duration); protected: diff --git a/cocos2dx/actions/CCActionTween.cpp b/cocos2dx/actions/CCActionTween.cpp index 214b6e63d4..7e775cf614 100644 --- a/cocos2dx/actions/CCActionTween.cpp +++ b/cocos2dx/actions/CCActionTween.cpp @@ -27,19 +27,10 @@ THE SOFTWARE. NS_CC_BEGIN -// CCActionTween* CCActionTween::actionWithDuration(float aDuration, const char* key, float from, float to) -// { -// CCActionTween* pRet = new CCActionTween(); -// if (pRet && pRet->initWithDuration(aDuration, key, from, to)) -// { -// pRet->autorelease(); -// } -// else -// { -// CC_SAFE_DELETE(pRet); -// } -// return pRet; -// } +CCActionTween* CCActionTween::actionWithDuration(float aDuration, const char* key, float from, float to) +{ + return CCActionTween::create(aDuration, key, from, to); +} CCActionTween* CCActionTween::create(float aDuration, const char* key, float from, float to) { diff --git a/cocos2dx/actions/CCActionTween.h b/cocos2dx/actions/CCActionTween.h index 23bb968882..e3ceca34d0 100644 --- a/cocos2dx/actions/CCActionTween.h +++ b/cocos2dx/actions/CCActionTween.h @@ -60,7 +60,7 @@ public: /** creates an initializes the action with the property name (key), and the from and to parameters. @warning: This interface will be deprecated in future. */ - //static CCActionTween* actionWithDuration(float aDuration, const char* key, float from, float to); + static CCActionTween* actionWithDuration(float aDuration, const char* key, float from, float to); /** creates an initializes the action with the property name (key), and the from and to parameters. */ static CCActionTween* create(float aDuration, const char* key, float from, float to); /** initializes the action with the property name (key), and the from and to parameters. */ diff --git a/cocos2dx/base_nodes/CCAtlasNode.cpp b/cocos2dx/base_nodes/CCAtlasNode.cpp index 228f6715f4..455818a8de 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.cpp +++ b/cocos2dx/base_nodes/CCAtlasNode.cpp @@ -60,11 +60,11 @@ CCAtlasNode::~CCAtlasNode() CC_SAFE_RELEASE(m_pTextureAtlas); } -// CCAtlasNode * CCAtlasNode::atlasWithTileFile(const char *tile, unsigned int tileWidth, unsigned int tileHeight, -// unsigned int itemsToRender) -// { -// return CCAtlasNode::create(tile, tileWidth, tileHeight, itemsToRender); -// } +CCAtlasNode * CCAtlasNode::atlasWithTileFile(const char *tile, unsigned int tileWidth, unsigned int tileHeight, + unsigned int itemsToRender) +{ + return CCAtlasNode::create(tile, tileWidth, tileHeight, itemsToRender); +} CCAtlasNode * CCAtlasNode::create(const char *tile, unsigned int tileWidth, unsigned int tileHeight, unsigned int itemsToRender) diff --git a/cocos2dx/base_nodes/CCAtlasNode.h b/cocos2dx/base_nodes/CCAtlasNode.h index a83e3e35fa..806ad8587d 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.h +++ b/cocos2dx/base_nodes/CCAtlasNode.h @@ -79,8 +79,8 @@ public: /** creates a CCAtlasNode with an Atlas file the width and height of each item and the quantity of items to render @warning: This interface will be deprecated in future. */ -// static CCAtlasNode * atlasWithTileFile(const char* tile,unsigned int tileWidth, unsigned int tileHeight, -// unsigned int itemsToRender); + static CCAtlasNode * atlasWithTileFile(const char* tile,unsigned int tileWidth, unsigned int tileHeight, + unsigned int itemsToRender); /** creates a CCAtlasNode with an Atlas file the width and height of each item and the quantity of items to render*/ static CCAtlasNode * create(const char* tile,unsigned int tileWidth, unsigned int tileHeight, diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 6b1c7b914b..656abf28fd 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -437,10 +437,10 @@ CCRect CCNode::boundingBox() return CCRectApplyAffineTransform(rect, nodeToParentTransform()); } -// CCNode * CCNode::node(void) -// { -// return CCNode::create(); -// } +CCNode * CCNode::node(void) +{ + return CCNode::create(); +} CCNode * CCNode::create(void) { diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index 0e10440db8..836ac2ee72 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -300,7 +300,7 @@ public: The node will be created as "autorelease". @warning: This interface will be deprecated in future. */ - //static CCNode * node(void); + static CCNode * node(void); /** allocates and initializes a node. The node will be created as "autorelease". diff --git a/cocos2dx/cocoa/CCArray.cpp b/cocos2dx/cocoa/CCArray.cpp index 314f3e3ba9..34084614a8 100644 --- a/cocos2dx/cocoa/CCArray.cpp +++ b/cocos2dx/cocoa/CCArray.cpp @@ -40,10 +40,10 @@ CCArray::CCArray(unsigned int capacity) initWithCapacity(capacity); } -// CCArray* CCArray::array() -// { -// return CCArray::create(); -// } +CCArray* CCArray::array() +{ + return CCArray::create(); +} CCArray* CCArray::create() { @@ -61,10 +61,10 @@ CCArray* CCArray::create() return pArray; } -// CCArray* CCArray::arrayWithObject(CCObject* pObject) -// { -// return CCArray::createWithObject(pObject); -// } +CCArray* CCArray::arrayWithObject(CCObject* pObject) +{ + return CCArray::createWithObject(pObject); +} CCArray* CCArray::createWithObject(CCObject* pObject) { @@ -82,31 +82,31 @@ CCArray* CCArray::createWithObject(CCObject* pObject) return pArray; } -// CCArray* CCArray::arrayWithObjects(CCObject* pObject, ...) -// { -// va_list args; -// va_start(args,pObject); -// -// CCArray* pArray = create(); -// if (pArray && pObject) -// { -// pArray->addObject(pObject); -// CCObject *i = va_arg(args, CCObject*); -// while(i) -// { -// pArray->addObject(i); -// i = va_arg(args, CCObject*); -// } -// } -// else -// { -// CC_SAFE_DELETE(pArray); -// } -// -// va_end(args); -// -// return pArray; -// } +CCArray* CCArray::arrayWithObjects(CCObject* pObject, ...) +{ + va_list args; + va_start(args,pObject); + + CCArray* pArray = create(); + if (pArray && pObject) + { + pArray->addObject(pObject); + CCObject *i = va_arg(args, CCObject*); + while(i) + { + pArray->addObject(i); + i = va_arg(args, CCObject*); + } + } + else + { + CC_SAFE_DELETE(pArray); + } + + va_end(args); + + return pArray; +} CCArray* CCArray::create(CCObject* pObject, ...) { @@ -134,10 +134,10 @@ CCArray* CCArray::create(CCObject* pObject, ...) return pArray; } -// CCArray* CCArray::arrayWithCapacity(unsigned int capacity) -// { -// return CCArray::create(capacity); -// } +CCArray* CCArray::arrayWithCapacity(unsigned int capacity) +{ + return CCArray::create(capacity); +} CCArray* CCArray::create(unsigned int capacity) { @@ -155,10 +155,10 @@ CCArray* CCArray::create(unsigned int capacity) return pArray; } -// CCArray* CCArray::arrayWithArray(CCArray* otherArray) -// { -// return CCArray::create(otherArray); -// } +CCArray* CCArray::arrayWithArray(CCArray* otherArray) +{ + return CCArray::create(otherArray); +} CCArray* CCArray::create(CCArray* otherArray) { @@ -167,10 +167,10 @@ CCArray* CCArray::create(CCArray* otherArray) return pRet; } -// CCArray* CCArray::arrayWithContentsOfFile(const char* pFileName) -// { -// return CCArray::createWithContentsOfFile(pFileName); -// } +CCArray* CCArray::arrayWithContentsOfFile(const char* pFileName) +{ + return CCArray::createWithContentsOfFile(pFileName); +} CCArray* CCArray::createWithContentsOfFile(const char* pFileName) { @@ -184,10 +184,10 @@ CCArray* CCArray::createWithContentsOfFile(const char* pFileName) extern CCArray* ccFileUtils_arrayWithContentsOfFileThreadSafe(const char* pFileName); -// CCArray* CCArray::arrayWithContentsOfFileThreadSafe(const char* pFileName) -// { -// return CCArray::createWithContentsOfFileThreadSafe(pFileName); -// } +CCArray* CCArray::arrayWithContentsOfFileThreadSafe(const char* pFileName) +{ + return CCArray::createWithContentsOfFileThreadSafe(pFileName); +} CCArray* CCArray::createWithContentsOfFileThreadSafe(const char* pFileName) { diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index 3642bd8da0..8bf655e957 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -113,37 +113,37 @@ public: /** Create an array @warning: This interface will be deprecated in future. */ - //static CCArray* array(); + static CCArray* array(); /** Create an array with one object @warning: This interface will be deprecated in future. */ - //static CCArray* arrayWithObject(CCObject* pObject); + static CCArray* arrayWithObject(CCObject* pObject); /** Create an array with some objects @warning: This interface will be deprecated in future. */ - //static CCArray* arrayWithObjects(CCObject* pObject, ...); + static CCArray* arrayWithObjects(CCObject* pObject, ...); /** Create an array with capacity @warning: This interface will be deprecated in future. */ - //static CCArray* arrayWithCapacity(unsigned int capacity); + static CCArray* arrayWithCapacity(unsigned int capacity); /** Create an array with an existing array @warning: This interface will be deprecated in future. */ - //static CCArray* arrayWithArray(CCArray* otherArray); + static CCArray* arrayWithArray(CCArray* otherArray); /** @brief Generate a CCArray pointer by file @param pFileName The file name of *.plist file @return The CCArray pointer generated from the file @warning: This interface will be deprecated in future. */ - //static CCArray* arrayWithContentsOfFile(const char* pFileName); + static CCArray* arrayWithContentsOfFile(const char* pFileName); /* @brief The same meaning as arrayWithContentsOfFile(), but it doesn't call autorelease, so the invoker should call release(). @warning: This interface will be deprecated in future. */ - //static CCArray* arrayWithContentsOfFileThreadSafe(const char* pFileName); + static CCArray* arrayWithContentsOfFileThreadSafe(const char* pFileName); /** Create an array */ static CCArray* create(); diff --git a/cocos2dx/cocoa/CCDictionary.cpp b/cocos2dx/cocoa/CCDictionary.cpp index 97be4a3e1f..a2d67c3aca 100644 --- a/cocos2dx/cocoa/CCDictionary.cpp +++ b/cocos2dx/cocoa/CCDictionary.cpp @@ -292,10 +292,10 @@ CCObject* CCDictionary::copyWithZone(CCZone* pZone) return pNewDict; } -// CCDictionary* CCDictionary::dictionary() -// { -// return CCDictionary::create(); -// } +CCDictionary* CCDictionary::dictionary() +{ + return CCDictionary::create(); +} CCDictionary* CCDictionary::create() { @@ -307,10 +307,10 @@ CCDictionary* CCDictionary::create() return pRet; } -// CCDictionary* CCDictionary::dictionaryWithDictionary(CCDictionary* srcDict) -// { -// return CCDictionary::createWithDictionary(srcDict); -// } +CCDictionary* CCDictionary::dictionaryWithDictionary(CCDictionary* srcDict) +{ + return CCDictionary::createWithDictionary(srcDict); +} CCDictionary* CCDictionary::createWithDictionary(CCDictionary* srcDict) { @@ -321,20 +321,20 @@ CCDictionary* CCDictionary::createWithDictionary(CCDictionary* srcDict) extern CCDictionary* ccFileUtils_dictionaryWithContentsOfFileThreadSafe(const char *pFileName); -// CCDictionary* CCDictionary::dictionaryWithContentsOfFileThreadSafe(const char *pFileName) -// { -// return CCDictionary::createWithContentsOfFileThreadSafe(pFileName); -// } +CCDictionary* CCDictionary::dictionaryWithContentsOfFileThreadSafe(const char *pFileName) +{ + return CCDictionary::createWithContentsOfFileThreadSafe(pFileName); +} CCDictionary* CCDictionary::createWithContentsOfFileThreadSafe(const char *pFileName) { return ccFileUtils_dictionaryWithContentsOfFileThreadSafe(pFileName); } -// CCDictionary* CCDictionary::dictionaryWithContentsOfFile(const char *pFileName) -// { -// return CCDictionary::createWithContentsOfFile(pFileName); -// } +CCDictionary* CCDictionary::dictionaryWithContentsOfFile(const char *pFileName) +{ + return CCDictionary::createWithContentsOfFile(pFileName); +} CCDictionary* CCDictionary::createWithContentsOfFile(const char *pFileName) { diff --git a/cocos2dx/cocoa/CCDictionary.h b/cocos2dx/cocoa/CCDictionary.h index bc8c66044b..86dfa07d9a 100644 --- a/cocos2dx/cocoa/CCDictionary.h +++ b/cocos2dx/cocoa/CCDictionary.h @@ -137,23 +137,23 @@ public: /* static functions */ //@warning: This interface will be deprecated in future. - //static CCDictionary* dictionary(); + static CCDictionary* dictionary(); - //static CCDictionary* dictionaryWithDictionary(CCDictionary* srcDict); + static CCDictionary* dictionaryWithDictionary(CCDictionary* srcDict); /** @brief Generate a CCDictionary pointer by file @param pFileName The file name of *.plist file @return The CCDictionary pointer generated from the file @warning: This interface will be deprecated in future. */ - //static CCDictionary* dictionaryWithContentsOfFile(const char *pFileName); + static CCDictionary* dictionaryWithContentsOfFile(const char *pFileName); /* @brief The same meaning as dictionaryWithContentsOfFile(), but it doesn't call autorelease, so the invoker should call release(). @warning: This interface will be deprecated in future. */ - //static CCDictionary* dictionaryWithContentsOfFileThreadSafe(const char *pFileName); + static CCDictionary* dictionaryWithContentsOfFileThreadSafe(const char *pFileName); static CCDictionary* create(); diff --git a/cocos2dx/cocoa/CCInteger.h b/cocos2dx/cocoa/CCInteger.h index f098e6b5bf..b8d550cf18 100644 --- a/cocos2dx/cocoa/CCInteger.h +++ b/cocos2dx/cocoa/CCInteger.h @@ -13,10 +13,10 @@ public: int getValue() const {return m_nValue;} // @warning: This interface will be deprecated in future. -// static CCInteger* integerWithInt(int v) -// { -// return CCInteger::create(v); -// } + static CCInteger* integerWithInt(int v) + { + return CCInteger::create(v); + } static CCInteger* create(int v) { diff --git a/cocos2dx/cocoa/CCString.cpp b/cocos2dx/cocoa/CCString.cpp index e712cc11a2..74325bf0a2 100644 --- a/cocos2dx/cocoa/CCString.cpp +++ b/cocos2dx/cocoa/CCString.cpp @@ -145,10 +145,10 @@ bool CCString::isEqual(const CCObject* pObject) return bRet; } -// CCString* CCString::stringWithCString(const char* pStr) -// { -// return CCString::create(pStr); -// } +CCString* CCString::stringWithCString(const char* pStr) +{ + return CCString::create(pStr); +} CCString* CCString::create(const char* pStr) { @@ -157,10 +157,10 @@ CCString* CCString::create(const char* pStr) return pRet; } -// CCString* CCString::stringWithData(unsigned char* pData, unsigned long nLen) -// { -// return CCString::createWithData(pData, nLen); -// } +CCString* CCString::stringWithData(unsigned char* pData, unsigned long nLen) +{ + return CCString::createWithData(pData, nLen); +} CCString* CCString::createWithData(unsigned char* pData, unsigned long nLen) { @@ -179,16 +179,16 @@ CCString* CCString::createWithData(unsigned char* pData, unsigned long nLen) return pRet; } -// CCString* CCString::stringWithFormat(const char* format, ...) -// { -// CCString* pRet = CCString::create(""); -// va_list ap; -// va_start(ap, format); -// pRet->initWithFormatAndValist(format, ap); -// va_end(ap); -// -// return pRet; -// } +CCString* CCString::stringWithFormat(const char* format, ...) +{ + CCString* pRet = CCString::create(""); + va_list ap; + va_start(ap, format); + pRet->initWithFormatAndValist(format, ap); + va_end(ap); + + return pRet; +} CCString* CCString::createWithFormat(const char* format, ...) { @@ -201,10 +201,10 @@ CCString* CCString::createWithFormat(const char* format, ...) return pRet; } -// CCString* CCString::stringWithContentsOfFile(const char* pszFileName) -// { -// return CCString::createWithContentsOfFile(pszFileName); -// } +CCString* CCString::stringWithContentsOfFile(const char* pszFileName) +{ + return CCString::createWithContentsOfFile(pszFileName); +} CCString* CCString::createWithContentsOfFile(const char* pszFileName) { diff --git a/cocos2dx/cocoa/CCString.h b/cocos2dx/cocoa/CCString.h index beedd83184..ccfeaa1769 100644 --- a/cocos2dx/cocoa/CCString.h +++ b/cocos2dx/cocoa/CCString.h @@ -76,7 +76,7 @@ public: * it means that you needn't do a release operation unless you retain it. @warning: This interface will be deprecated in future. */ - //static CCString* stringWithCString(const char* pStr); + static CCString* stringWithCString(const char* pStr); /** create a string with format, it's similar with the c function 'sprintf', the default buffer size is (1024*100) bytes, * if you want to change it, you should modify the kMaxStringLen macro in CCString.cpp file. @@ -84,21 +84,21 @@ public: * it means that you needn't do a release operation unless you retain it. @warning: This interface will be deprecated in future. */ - //static CCString* stringWithFormat(const char* format, ...); + static CCString* stringWithFormat(const char* format, ...); /** create a string with binary data * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. @warning: This interface will be deprecated in future. */ - //static CCString* stringWithData(unsigned char* pData, unsigned long nLen); + static CCString* stringWithData(unsigned char* pData, unsigned long nLen); /** create a string with a file, * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. @warning: This interface will be deprecated in future. */ - //static CCString* stringWithContentsOfFile(const char* pszFileName); + static CCString* stringWithContentsOfFile(const char* pszFileName); /** create a string with c string * @return A CCString pointer which is an autorelease object pointer, diff --git a/cocos2dx/effects/CCGrid.cpp b/cocos2dx/effects/CCGrid.cpp index 1ddef54370..f0901a8b82 100644 --- a/cocos2dx/effects/CCGrid.cpp +++ b/cocos2dx/effects/CCGrid.cpp @@ -39,10 +39,10 @@ THE SOFTWARE. NS_CC_BEGIN // implementation of CCGridBase -// CCGridBase* CCGridBase::gridWithSize(const ccGridSize& gridSize) -// { -// return CCGridBase::create(gridSize); -// } +CCGridBase* CCGridBase::gridWithSize(const ccGridSize& gridSize) +{ + return CCGridBase::create(gridSize); +} CCGridBase* CCGridBase::create(const ccGridSize& gridSize) { @@ -63,10 +63,10 @@ CCGridBase* CCGridBase::create(const ccGridSize& gridSize) return pGridBase; } -// CCGridBase* CCGridBase::gridWithSize(const ccGridSize& gridSize, CCTexture2D *texture, bool flipped) -// { -// return CCGridBase::create(gridSize, texture, flipped); -// } +CCGridBase* CCGridBase::gridWithSize(const ccGridSize& gridSize, CCTexture2D *texture, bool flipped) +{ + return CCGridBase::create(gridSize, texture, flipped); +} CCGridBase* CCGridBase::create(const ccGridSize& gridSize, CCTexture2D *texture, bool flipped) { diff --git a/cocos2dx/effects/CCGrid.h b/cocos2dx/effects/CCGrid.h index 5b43655d7f..422f9ea272 100644 --- a/cocos2dx/effects/CCGrid.h +++ b/cocos2dx/effects/CCGrid.h @@ -79,11 +79,11 @@ public: /** create one Grid @warning: This interface will be deprecated in future. */ - //static CCGridBase* gridWithSize(const ccGridSize& gridSize, CCTexture2D *texture, bool flipped); + static CCGridBase* gridWithSize(const ccGridSize& gridSize, CCTexture2D *texture, bool flipped); /** create one Grid @warning: This interface will be deprecated in future. */ - //static CCGridBase* gridWithSize(const ccGridSize& gridSize); + static CCGridBase* gridWithSize(const ccGridSize& gridSize); /** create one Grid */ static CCGridBase* create(const ccGridSize& gridSize, CCTexture2D *texture, bool flipped); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp index e0bcabc416..7ab9dc0866 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp @@ -122,10 +122,10 @@ bool CCControlButton::initWithLabelAndBackgroundSprite(CCNode* node, CCScale9Spr return false; } -// CCControlButton* CCControlButton::buttonWithLabelAndBackgroundSprite(CCNode* label, CCScale9Sprite* backgroundSprite) -// { -// return CCControlButton::create(label, backgroundSprite); -// } +CCControlButton* CCControlButton::buttonWithLabelAndBackgroundSprite(CCNode* label, CCScale9Sprite* backgroundSprite) +{ + return CCControlButton::create(label, backgroundSprite); +} CCControlButton* CCControlButton::create(CCNode* label, CCScale9Sprite* backgroundSprite) { @@ -141,10 +141,10 @@ bool CCControlButton::initWithTitleAndFontNameAndFontSize(string title, const ch return initWithLabelAndBackgroundSprite(label, CCScale9Sprite::create()); } -// CCControlButton* CCControlButton::buttonWithTitleAndFontNameAndFontSize(string title, const char * fontName, float fontSize) -// { -// return CCControlButton::create(title, fontName, fontSize); -// } +CCControlButton* CCControlButton::buttonWithTitleAndFontNameAndFontSize(string title, const char * fontName, float fontSize) +{ + return CCControlButton::create(title, fontName, fontSize); +} CCControlButton* CCControlButton::create(string title, const char * fontName, float fontSize) { @@ -160,10 +160,10 @@ bool CCControlButton::initWithBackgroundSprite(CCScale9Sprite* sprite) return initWithLabelAndBackgroundSprite(label, sprite); } -// CCControlButton* CCControlButton::buttonWithBackgroundSprite(CCScale9Sprite* sprite) -// { -// return CCControlButton::create(sprite); -// } +CCControlButton* CCControlButton::buttonWithBackgroundSprite(CCScale9Sprite* sprite) +{ + return CCControlButton::create(sprite); +} CCControlButton* CCControlButton::create(CCScale9Sprite* sprite) { diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.h b/cocos2dx/extensions/CCControlExtension/CCControlButton.h index a4fe68b086..c7d8f11c77 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.h @@ -95,19 +95,19 @@ protected: public: virtual bool initWithLabelAndBackgroundSprite(CCNode* label, CCScale9Sprite* backgroundSprite); //@warning: This interface will be deprecated in future. - //static CCControlButton* buttonWithLabelAndBackgroundSprite(CCNode* label, CCScale9Sprite* backgroundSprite); + static CCControlButton* buttonWithLabelAndBackgroundSprite(CCNode* label, CCScale9Sprite* backgroundSprite); static CCControlButton* create(CCNode* label, CCScale9Sprite* backgroundSprite); virtual bool initWithTitleAndFontNameAndFontSize(std::string title, const char * fontName, float fontSize); //@warning: This interface will be deprecated in future. - //static CCControlButton* buttonWithTitleAndFontNameAndFontSize(std::string title, const char * fontName, float fontSize); + static CCControlButton* buttonWithTitleAndFontNameAndFontSize(std::string title, const char * fontName, float fontSize); static CCControlButton* create(std::string title, const char * fontName, float fontSize); virtual bool initWithBackgroundSprite(CCScale9Sprite* sprite); //@warning: This interface will be deprecated in future. - //static CCControlButton* buttonWithBackgroundSprite(CCScale9Sprite* sprite); + static CCControlButton* buttonWithBackgroundSprite(CCScale9Sprite* sprite); static CCControlButton* create(CCScale9Sprite* sprite); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp b/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp index c155e2a13e..a114f59f6e 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp @@ -87,10 +87,10 @@ bool CCControlColourPicker::init() return false; } -// CCControlColourPicker* CCControlColourPicker::colourPicker() -// { -// return CCControlColourPicker::create(); -// } +CCControlColourPicker* CCControlColourPicker::colourPicker() +{ + return CCControlColourPicker::create(); +} CCControlColourPicker* CCControlColourPicker::create() { diff --git a/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.h b/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.h index 0a7f7ccaa4..66b3cb0eec 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.h @@ -53,7 +53,7 @@ protected: public: //@warning: This interface will be deprecated in future. - //static CCControlColourPicker* colourPicker(); + static CCControlColourPicker* colourPicker(); static CCControlColourPicker* create(); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.cpp b/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.cpp index d0244038d2..a2ff8c2d22 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.cpp @@ -38,10 +38,10 @@ CCControlHuePicker::~CCControlHuePicker() } -// CCControlHuePicker* CCControlHuePicker::pickerWithTargetAndPos(CCNode* target, CCPoint pos) -// { -// return CCControlHuePicker::create(target, pos); -// } +CCControlHuePicker* CCControlHuePicker::pickerWithTargetAndPos(CCNode* target, CCPoint pos) +{ + return CCControlHuePicker::create(target, pos); +} CCControlHuePicker* CCControlHuePicker::create(CCNode* target, CCPoint pos) { diff --git a/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.h b/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.h index 01c84e2e1b..aa0f4c51df 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.h @@ -55,7 +55,7 @@ public: virtual ~CCControlHuePicker(); virtual bool initWithTargetAndPos(CCNode* target, CCPoint pos); //@warning: This interface will be deprecated in future. - //static CCControlHuePicker* pickerWithTargetAndPos(CCNode* target, CCPoint pos); + static CCControlHuePicker* pickerWithTargetAndPos(CCNode* target, CCPoint pos); static CCControlHuePicker* create(CCNode* target, CCPoint pos); protected: void updateSliderPosition(CCPoint location); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp b/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp index 51813521fd..36b998fdcf 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp @@ -58,10 +58,10 @@ bool CCControlSaturationBrightnessPicker::initWithTargetAndPos(CCNode* target, C return false; } -// CCControlSaturationBrightnessPicker* CCControlSaturationBrightnessPicker::pickerWithTargetAndPos(CCNode* target, CCPoint pos) -// { -// return CCControlSaturationBrightnessPicker::create(target, pos); -// } +CCControlSaturationBrightnessPicker* CCControlSaturationBrightnessPicker::pickerWithTargetAndPos(CCNode* target, CCPoint pos) +{ + return CCControlSaturationBrightnessPicker::create(target, pos); +} CCControlSaturationBrightnessPicker* CCControlSaturationBrightnessPicker::create(CCNode* target, CCPoint pos) { diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.h b/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.h index 652a428a04..8669d51092 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.h @@ -58,7 +58,7 @@ public: virtual bool initWithTargetAndPos(CCNode* target, CCPoint pos); //@warning: This interface will be deprecated in future. - //static CCControlSaturationBrightnessPicker* pickerWithTargetAndPos(CCNode* target, CCPoint pos); + static CCControlSaturationBrightnessPicker* pickerWithTargetAndPos(CCNode* target, CCPoint pos); static CCControlSaturationBrightnessPicker* create(CCNode* target, CCPoint pos); virtual void updateWithHSV(HSV hsv); virtual void updateDraggerWithHSV(HSV hsv); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp b/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp index b727b50645..6f4609f25f 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp @@ -38,10 +38,10 @@ CCControlSlider::~CCControlSlider() } -// CCControlSlider* CCControlSlider::sliderWithFiles(const char* bgFile, const char* progressFile, const char* thumbFile) -// { -// return CCControlSlider::create(bgFile, progressFile, thumbFile); -// } +CCControlSlider* CCControlSlider::sliderWithFiles(const char* bgFile, const char* progressFile, const char* thumbFile) +{ + return CCControlSlider::create(bgFile, progressFile, thumbFile); +} CCControlSlider* CCControlSlider::create(const char* bgFile, const char* progressFile, const char* thumbFile) { @@ -61,10 +61,10 @@ CCControlSlider* CCControlSlider::create(const char* bgFile, const char* progres return CCControlSlider::create(backgroundSprite, progressSprite, thumbMenuItem); } -// CCControlSlider* CCControlSlider::sliderWithSprites(CCSprite * backgroundSprite, CCSprite* pogressSprite, CCMenuItem* thumbItem) -// { -// return CCControlSlider::create(backgroundSprite, pogressSprite, thumbItem); -// } +CCControlSlider* CCControlSlider::sliderWithSprites(CCSprite * backgroundSprite, CCSprite* pogressSprite, CCMenuItem* thumbItem) +{ + return CCControlSlider::create(backgroundSprite, pogressSprite, thumbItem); +} CCControlSlider* CCControlSlider::create(CCSprite * backgroundSprite, CCSprite* pogressSprite, CCMenuItem* thumbItem) { diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSlider.h b/cocos2dx/extensions/CCControlExtension/CCControlSlider.h index eac9535a70..59db5356c2 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSlider.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlSlider.h @@ -77,7 +77,7 @@ public: * thumb image filename. @warning: This interface will be deprecated in future. */ - //static CCControlSlider* sliderWithFiles(const char* bgFile, const char* progressFile, const char* thumbFile); + static CCControlSlider* sliderWithFiles(const char* bgFile, const char* progressFile, const char* thumbFile); /** * Creates a slider with a given background sprite and a progress bar and a @@ -85,7 +85,7 @@ public: *@warning: This interface will be deprecated in future. * @see initWithBackgroundSprite:progressSprite:thumbMenuItem: */ - //static CCControlSlider* sliderWithSprites(CCSprite * backgroundSprite, CCSprite* pogressSprite, CCMenuItem* thumbItem); + static CCControlSlider* sliderWithSprites(CCSprite * backgroundSprite, CCSprite* pogressSprite, CCMenuItem* thumbItem); /** diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp index e8af2f1e37..2e6b1bd030 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp @@ -273,10 +273,10 @@ bool CCControlSwitch::initWithMaskSprite(CCSprite *maskSprite, CCSprite * onSpri return initWithMaskSprite(maskSprite, onSprite, offSprite, thumbSprite, NULL, NULL); } -// CCControlSwitch* CCControlSwitch::switchWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite) -// { -// return CCControlSwitch::create(maskSprite, onSprite, offSprite, thumbSprite); -// } +CCControlSwitch* CCControlSwitch::switchWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite) +{ + return CCControlSwitch::create(maskSprite, onSprite, offSprite, thumbSprite); +} CCControlSwitch* CCControlSwitch::create(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite) { @@ -322,10 +322,10 @@ bool CCControlSwitch::initWithMaskSprite(CCSprite *maskSprite, CCSprite * onSpri return false; } -// CCControlSwitch* CCControlSwitch::switchWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite, CCLabelTTF* onLabel, CCLabelTTF* offLabel) -// { -// return CCControlSwitch::create(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel); -// } +CCControlSwitch* CCControlSwitch::switchWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite, CCLabelTTF* onLabel, CCLabelTTF* offLabel) +{ + return CCControlSwitch::create(maskSprite, onSprite, offSprite, thumbSprite, onLabel, offLabel); +} CCControlSwitch* CCControlSwitch::create(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite, CCLabelTTF* onLabel, CCLabelTTF* offLabel) { diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.h b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.h index a2bc142496..ecfe426260 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.h @@ -49,7 +49,7 @@ public: /** Creates a switch with a mask sprite, on/off sprites for on/off states and a thumb sprite. @warning: This interface will be deprecated in future. */ - //static CCControlSwitch* switchWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite); + static CCControlSwitch* switchWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite); /** Creates a switch with a mask sprite, on/off sprites for on/off states and a thumb sprite. */ static CCControlSwitch* create(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite); @@ -61,7 +61,7 @@ public: /** Creates a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. @warning: This interface will be deprecated in future. */ - //static CCControlSwitch* switchWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite, CCLabelTTF* onLabel, CCLabelTTF* offLabel); + static CCControlSwitch* switchWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite, CCLabelTTF* onLabel, CCLabelTTF* offLabel); /** Creates a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. */ static CCControlSwitch* create(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite, CCLabelTTF* onLabel, CCLabelTTF* offLabel); diff --git a/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp b/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp index fad26e61c7..6661c3a228 100644 --- a/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp @@ -16,31 +16,31 @@ enum // //CCMenu // -// CCMenuPassive* CCMenuPassive::node() -// { -// return CCMenuPassive::create(); -// } +CCMenuPassive* CCMenuPassive::node() +{ + return CCMenuPassive::create(); +} CCMenuPassive* CCMenuPassive::create() { return create(NULL, NULL); } -// CCMenuPassive * CCMenuPassive::menuWithItems(CCNode* item, ...) -// { -// va_list args; -// va_start(args,item); -// CCMenuPassive *pRet = new CCMenuPassive(); -// if (pRet && pRet->initWithItems(item, args)) -// { -// pRet->autorelease(); -// va_end(args); -// return pRet; -// } -// va_end(args); -// CC_SAFE_DELETE(pRet); -// return NULL; -// } +CCMenuPassive * CCMenuPassive::menuWithItems(CCNode* item, ...) +{ + va_list args; + va_start(args,item); + CCMenuPassive *pRet = new CCMenuPassive(); + if (pRet && pRet->initWithItems(item, args)) + { + pRet->autorelease(); + va_end(args); + return pRet; + } + va_end(args); + CC_SAFE_DELETE(pRet); + return NULL; +} CCMenuPassive * CCMenuPassive::create(CCNode* item, ...) { @@ -58,10 +58,10 @@ CCMenuPassive * CCMenuPassive::create(CCNode* item, ...) return NULL; } -// CCMenuPassive* CCMenuPassive::menuWithItem(CCNode* item) -// { -// return CCMenuPassive::createWithItem(item); -// } +CCMenuPassive* CCMenuPassive::menuWithItem(CCNode* item) +{ + return CCMenuPassive::createWithItem(item); +} CCMenuPassive* CCMenuPassive::createWithItem(CCNode* item) { diff --git a/cocos2dx/extensions/CCControlExtension/CCMenuPassive.h b/cocos2dx/extensions/CCControlExtension/CCMenuPassive.h index 94cfaf17d7..65d95709ac 100644 --- a/cocos2dx/extensions/CCControlExtension/CCMenuPassive.h +++ b/cocos2dx/extensions/CCControlExtension/CCMenuPassive.h @@ -20,19 +20,19 @@ public: /** creates an empty CCMenu @warning: This interface will be deprecated in future. */ - //static CCMenuPassive* node(); + static CCMenuPassive* node(); /** creates a CCMenu with it's items @warning: This interface will be deprecated in future. */ - //static CCMenuPassive* menuWithItems(CCNode* item, ...); + static CCMenuPassive* menuWithItems(CCNode* item, ...); /** creates a CCMenu with it's item, then use addChild() to add * other items. It is used for script, it can't init with undetermined * number of variables. @warning: This interface will be deprecated in future. */ - //static CCMenuPassive* menuWithItem(CCNode* item); + static CCMenuPassive* menuWithItem(CCNode* item); /** creates an empty CCMenu */ static CCMenuPassive* create(); diff --git a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp index 73a07b52ee..9d0eb1dff4 100644 --- a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp @@ -194,10 +194,10 @@ bool CCScale9Sprite::initWithFile(const char* file, CCRect rect, CCRect capInse return pReturn; } -// CCScale9Sprite* CCScale9Sprite::spriteWithFile(const char* file, CCRect rect, CCRect capInsets) -// { -// return CCScale9Sprite::create(file, rect, capInsets); -// } +CCScale9Sprite* CCScale9Sprite::spriteWithFile(const char* file, CCRect rect, CCRect capInsets) +{ + return CCScale9Sprite::create(file, rect, capInsets); +} CCScale9Sprite* CCScale9Sprite::create(const char* file, CCRect rect, CCRect capInsets) { @@ -217,10 +217,10 @@ bool CCScale9Sprite::initWithFile(const char* file, CCRect rect) return pReturn; } -// CCScale9Sprite* CCScale9Sprite::spriteWithFile(const char* file, CCRect rect) -// { -// return CCScale9Sprite::create(file, rect); -// } +CCScale9Sprite* CCScale9Sprite::spriteWithFile(const char* file, CCRect rect) +{ + return CCScale9Sprite::create(file, rect); +} CCScale9Sprite* CCScale9Sprite::create(const char* file, CCRect rect) { @@ -241,10 +241,10 @@ bool CCScale9Sprite::initWithFile(CCRect capInsets, const char* file) return pReturn; } -// CCScale9Sprite* CCScale9Sprite::spriteWithFile(CCRect capInsets, const char* file) -// { -// return CCScale9Sprite::create(capInsets, file); -// } +CCScale9Sprite* CCScale9Sprite::spriteWithFile(CCRect capInsets, const char* file) +{ + return CCScale9Sprite::create(capInsets, file); +} CCScale9Sprite* CCScale9Sprite::create(CCRect capInsets, const char* file) { @@ -265,10 +265,10 @@ bool CCScale9Sprite::initWithFile(const char* file) } -// CCScale9Sprite* CCScale9Sprite::spriteWithFile(const char* file) -// { -// return CCScale9Sprite::create(file); -// } +CCScale9Sprite* CCScale9Sprite::spriteWithFile(const char* file) +{ + return CCScale9Sprite::create(file); +} CCScale9Sprite* CCScale9Sprite::create(const char* file) { @@ -291,10 +291,10 @@ bool CCScale9Sprite::initWithSpriteFrame(CCSpriteFrame* spriteFrame, CCRect capI return pReturn; } -// CCScale9Sprite* CCScale9Sprite::spriteWithSpriteFrame(CCSpriteFrame* spriteFrame, CCRect capInsets) -// { -// return CCScale9Sprite::createWithSpriteFrame(spriteFrame, capInsets); -// } +CCScale9Sprite* CCScale9Sprite::spriteWithSpriteFrame(CCSpriteFrame* spriteFrame, CCRect capInsets) +{ + return CCScale9Sprite::createWithSpriteFrame(spriteFrame, capInsets); +} CCScale9Sprite* CCScale9Sprite::createWithSpriteFrame(CCSpriteFrame* spriteFrame, CCRect capInsets) { @@ -314,10 +314,10 @@ bool CCScale9Sprite::initWithSpriteFrame(CCSpriteFrame* spriteFrame) } -// CCScale9Sprite* CCScale9Sprite::spriteWithSpriteFrame(CCSpriteFrame* spriteFrame) -// { -// return CCScale9Sprite::createWithSpriteFrame(spriteFrame); -// } +CCScale9Sprite* CCScale9Sprite::spriteWithSpriteFrame(CCSpriteFrame* spriteFrame) +{ + return CCScale9Sprite::createWithSpriteFrame(spriteFrame); +} CCScale9Sprite* CCScale9Sprite::createWithSpriteFrame(CCSpriteFrame* spriteFrame) { @@ -340,10 +340,10 @@ bool CCScale9Sprite::initWithSpriteFrameName(const char* spriteFrameName, CCRect return pReturn; } -// CCScale9Sprite* CCScale9Sprite::spriteWithSpriteFrameName(const char* spriteFrameName, CCRect capInsets) -// { -// return CCScale9Sprite::createWithSpriteFrameName(spriteFrameName, capInsets); -// } +CCScale9Sprite* CCScale9Sprite::spriteWithSpriteFrameName(const char* spriteFrameName, CCRect capInsets) +{ + return CCScale9Sprite::createWithSpriteFrameName(spriteFrameName, capInsets); +} CCScale9Sprite* CCScale9Sprite::createWithSpriteFrameName(const char* spriteFrameName, CCRect capInsets) { @@ -364,10 +364,10 @@ bool CCScale9Sprite::initWithSpriteFrameName(const char* spriteFrameName) return pReturn; } -// CCScale9Sprite* CCScale9Sprite::spriteWithSpriteFrameName(const char* spriteFrameName) -// { -// return CCScale9Sprite::createWithSpriteFrameName(spriteFrameName); -// } +CCScale9Sprite* CCScale9Sprite::spriteWithSpriteFrameName(const char* spriteFrameName) +{ + return CCScale9Sprite::createWithSpriteFrameName(spriteFrameName); +} CCScale9Sprite* CCScale9Sprite::createWithSpriteFrameName(const char* spriteFrameName) { @@ -394,10 +394,10 @@ CCScale9Sprite* CCScale9Sprite::resizableSpriteWithCapInsets(CCRect capInsets) return NULL; } -// CCScale9Sprite* CCScale9Sprite::node() -// { -// return CCScale9Sprite::create(); -// } +CCScale9Sprite* CCScale9Sprite::node() +{ + return CCScale9Sprite::create(); +} CCScale9Sprite* CCScale9Sprite::create() { diff --git a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h index 06f164ec48..a2ee851cf4 100644 --- a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h +++ b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h @@ -103,7 +103,7 @@ public: * @see initWithFile:rect:centerRegion: @warning: This interface will be deprecated in future. */ - //static CCScale9Sprite* spriteWithFile(const char* file, CCRect rect, CCRect capInsets); + static CCScale9Sprite* spriteWithFile(const char* file, CCRect rect, CCRect capInsets); /** * Creates a 9-slice sprite with a texture file, a delimitation zone and @@ -134,7 +134,7 @@ public: * @see initWithFile:rect: @warning: This interface will be deprecated in future. */ - //static CCScale9Sprite* spriteWithFile(const char* file, CCRect rect); + static CCScale9Sprite* spriteWithFile(const char* file, CCRect rect); /** * Creates a 9-slice sprite with a texture file and a delimitation zone. The @@ -163,7 +163,7 @@ public: * @see initWithFile:capInsets: @warning: This interface will be deprecated in future. */ - //static CCScale9Sprite* spriteWithFile(CCRect capInsets, const char* file); + static CCScale9Sprite* spriteWithFile(CCRect capInsets, const char* file); /** * Creates a 9-slice sprite with a texture file. The whole texture will be * broken down into a 3×3 grid of equal blocks. @@ -191,7 +191,7 @@ public: * @see initWithFile: @warning: This interface will be deprecated in future. */ - //static CCScale9Sprite* spriteWithFile(const char* file); + static CCScale9Sprite* spriteWithFile(const char* file); /** * Creates a 9-slice sprite with a texture file. The whole texture will be @@ -222,7 +222,7 @@ public: * @see initWithSpriteFrame:centerRegion: @warning: This interface will be deprecated in future. */ - //static CCScale9Sprite* spriteWithSpriteFrame(CCSpriteFrame* spriteFrame, CCRect capInsets); + static CCScale9Sprite* spriteWithSpriteFrame(CCSpriteFrame* spriteFrame, CCRect capInsets); /** * Creates a 9-slice sprite with an sprite frame and the centre of its zone. @@ -252,7 +252,7 @@ public: * @see initWithSpriteFrame: @warning: This interface will be deprecated in future. */ - //static CCScale9Sprite* spriteWithSpriteFrame(CCSpriteFrame* spriteFrame); + static CCScale9Sprite* spriteWithSpriteFrame(CCSpriteFrame* spriteFrame); /** * Creates a 9-slice sprite with an sprite frame. @@ -285,7 +285,7 @@ public: * @see initWithSpriteFrameName:centerRegion: @warning: This interface will be deprecated in future. */ - //static CCScale9Sprite* spriteWithSpriteFrameName(const char*spriteFrameName, CCRect capInsets); + static CCScale9Sprite* spriteWithSpriteFrameName(const char*spriteFrameName, CCRect capInsets); /** * Creates a 9-slice sprite with an sprite frame name and the centre of its @@ -317,7 +317,7 @@ public: * @see initWithSpriteFrameName: @warning: This interface will be deprecated in future. */ - //static CCScale9Sprite* spriteWithSpriteFrameName(const char*spriteFrameName); + static CCScale9Sprite* spriteWithSpriteFrameName(const char*spriteFrameName); /** * Creates a 9-slice sprite with an sprite frame name. @@ -340,7 +340,7 @@ public: CCScale9Sprite* resizableSpriteWithCapInsets(CCRect capInsets); - //static CCScale9Sprite* node(); + static CCScale9Sprite* node(); static CCScale9Sprite* create(); diff --git a/cocos2dx/extensions/CCListView/CCListView.cpp b/cocos2dx/extensions/CCListView/CCListView.cpp index cf896e5b93..4f6afda652 100644 --- a/cocos2dx/extensions/CCListView/CCListView.cpp +++ b/cocos2dx/extensions/CCListView/CCListView.cpp @@ -35,10 +35,10 @@ NS_CC_EXT_BEGIN /****************************************** **************Public Functions************* *******************************************/ -// CCListView* CCListView::viewWithMode(CCListViewMode mode) -// { -// return CCListView::create(mode); -// } +CCListView* CCListView::viewWithMode(CCListViewMode mode) +{ + return CCListView::create(mode); +} CCListView* CCListView::create(CCListViewMode mode) { diff --git a/cocos2dx/extensions/CCListView/CCListView.h b/cocos2dx/extensions/CCListView/CCListView.h index 4d2faf154a..913f79e875 100644 --- a/cocos2dx/extensions/CCListView/CCListView.h +++ b/cocos2dx/extensions/CCListView/CCListView.h @@ -122,7 +122,7 @@ public: CCListView(void); // @warning: This interface will be deprecated in future. - //static CCListView* viewWithMode(CCListViewMode mode); + static CCListView* viewWithMode(CCListViewMode mode); static CCListView* create(CCListViewMode mode); diff --git a/cocos2dx/label_nodes/CCLabelAtlas.cpp b/cocos2dx/label_nodes/CCLabelAtlas.cpp index 7532b7e3d3..4cf3541c84 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.cpp +++ b/cocos2dx/label_nodes/CCLabelAtlas.cpp @@ -41,10 +41,10 @@ THE SOFTWARE. NS_CC_BEGIN //CCLabelAtlas - Creation & Init -// CCLabelAtlas* CCLabelAtlas::labelWithString(const char *label, const char *charMapFile, unsigned int itemWidth, int unsigned itemHeight, unsigned int startCharMap) -// { -// return CCLabelAtlas::create(label, charMapFile, itemWidth, itemHeight, startCharMap); -// } +CCLabelAtlas* CCLabelAtlas::labelWithString(const char *label, const char *charMapFile, unsigned int itemWidth, int unsigned itemHeight, unsigned int startCharMap) +{ + return CCLabelAtlas::create(label, charMapFile, itemWidth, itemHeight, startCharMap); +} CCLabelAtlas* CCLabelAtlas::create(const char *label, const char *charMapFile, unsigned int itemWidth, int unsigned itemHeight, unsigned int startCharMap) { @@ -70,10 +70,10 @@ bool CCLabelAtlas::initWithString(const char *label, const char *charMapFile, un return false; } -// CCLabelAtlas* CCLabelAtlas::labelWithString(const char *string, const char *fntFile) -// { -// return CCLabelAtlas::create(string, fntFile); -// } +CCLabelAtlas* CCLabelAtlas::labelWithString(const char *string, const char *fntFile) +{ + return CCLabelAtlas::create(string, fntFile); +} CCLabelAtlas* CCLabelAtlas::create(const char *string, const char *fntFile) { diff --git a/cocos2dx/label_nodes/CCLabelAtlas.h b/cocos2dx/label_nodes/CCLabelAtlas.h index 6cceadd50c..17ed42e037 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.h +++ b/cocos2dx/label_nodes/CCLabelAtlas.h @@ -54,13 +54,13 @@ public: /** creates the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas @warning: This interface will be deprecated in future. */ - //static CCLabelAtlas * labelWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); + static CCLabelAtlas * labelWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); /** creates the CCLabelAtlas with a string and a configuration file @warning: This interface will be deprecated in future. @since v2.0 */ - //static CCLabelAtlas* labelWithString(const char *sring, const char *fntFile); + static CCLabelAtlas* labelWithString(const char *sring, const char *fntFile); /** creates the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */ static CCLabelAtlas * create(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index a3ba1529c5..a19d535de8 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -405,10 +405,10 @@ typedef struct _KerningHashElement //BitmapFontConfiguration // -// CCBMFontConfiguration * CCBMFontConfiguration::configurationWithFNTFile(const char *FNTfile) -// { -// return CCBMFontConfiguration::create(FNTfile); -// } +CCBMFontConfiguration * CCBMFontConfiguration::configurationWithFNTFile(const char *FNTfile) +{ + return CCBMFontConfiguration::create(FNTfile); +} CCBMFontConfiguration * CCBMFontConfiguration::create(const char *FNTfile) { @@ -718,10 +718,10 @@ void CCLabelBMFont::purgeCachedData() FNTConfigRemoveCache(); } -// CCLabelBMFont *CCLabelBMFont::labelWithString(const char *str, const char *fntFile, float width/* = kCCLabelAutomaticWidth*/, CCTextAlignment alignment/* = kCCTextAlignmentLeft*/, CCPoint imageOffset/* = CCPointZero*/) -// { -// return CCLabelBMFont::create(str, fntFile, width, alignment, imageOffset); -// } +CCLabelBMFont *CCLabelBMFont::labelWithString(const char *str, const char *fntFile, float width/* = kCCLabelAutomaticWidth*/, CCTextAlignment alignment/* = kCCTextAlignmentLeft*/, CCPoint imageOffset/* = CCPointZero*/) +{ + return CCLabelBMFont::create(str, fntFile, width, alignment, imageOffset); +} //LabelBMFont - Creation & Init CCLabelBMFont *CCLabelBMFont::create(const char *str, const char *fntFile, float width/* = kCCLabelAutomaticWidth*/, CCTextAlignment alignment/* = kCCTextAlignmentLeft*/, CCPoint imageOffset/* = CCPointZero*/) diff --git a/cocos2dx/label_nodes/CCLabelBMFont.h b/cocos2dx/label_nodes/CCLabelBMFont.h index f1dd84e337..65469d89e2 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.h +++ b/cocos2dx/label_nodes/CCLabelBMFont.h @@ -106,7 +106,7 @@ public: /** allocates a CCBMFontConfiguration with a FNT file @warning: This interface will be deprecated in future. */ - //static CCBMFontConfiguration * configurationWithFNTFile(const char *FNTfile); + static CCBMFontConfiguration * configurationWithFNTFile(const char *FNTfile); /** allocates a CCBMFontConfiguration with a FNT file */ static CCBMFontConfiguration * create(const char *FNTfile); @@ -196,7 +196,7 @@ public: /** creates a bitmap font altas with an initial string and the FNT file @warning: This interface will be deprecated in future. */ - //static CCLabelBMFont * labelWithString(const char *str, const char *fntFile, float width = kCCLabelAutomaticWidth, CCTextAlignment alignment = kCCTextAlignmentLeft, CCPoint imageOffset = CCPointZero); + static CCLabelBMFont * labelWithString(const char *str, const char *fntFile, float width = kCCLabelAutomaticWidth, CCTextAlignment alignment = kCCTextAlignmentLeft, CCPoint imageOffset = CCPointZero); /** creates a bitmap font altas with an initial string and the FNT file */ static CCLabelBMFont * create(const char *str, const char *fntFile, float width = kCCLabelAutomaticWidth, CCTextAlignment alignment = kCCTextAlignmentLeft, CCPoint imageOffset = CCPointZero); diff --git a/cocos2dx/label_nodes/CCLabelTTF.cpp b/cocos2dx/label_nodes/CCLabelTTF.cpp index 351b9e9eb5..8074a01b97 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.cpp +++ b/cocos2dx/label_nodes/CCLabelTTF.cpp @@ -53,30 +53,30 @@ CCLabelTTF::~CCLabelTTF() CC_SAFE_DELETE(m_pFontName); } -// CCLabelTTF * CCLabelTTF::labelWithString(const char *string, const char *fontName, float fontSize) -// { -// return CCLabelTTF::create(string, fontName, fontSize); -// } +CCLabelTTF * CCLabelTTF::labelWithString(const char *string, const char *fontName, float fontSize) +{ + return CCLabelTTF::create(string, fontName, fontSize); +} CCLabelTTF * CCLabelTTF::create(const char *string, const char *fontName, float fontSize) { return CCLabelTTF::create(string, CCSizeZero, kCCTextAlignmentCenter, kCCVerticalTextAlignmentTop, fontName, fontSize); } -// CCLabelTTF * CCLabelTTF::labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, const char *fontName, float fontSize) -// { -// return CCLabelTTF::create(string, dimensions, hAlignment, kCCVerticalTextAlignmentTop, fontName, fontSize); -// } +CCLabelTTF * CCLabelTTF::labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, const char *fontName, float fontSize) +{ + return CCLabelTTF::create(string, dimensions, hAlignment, kCCVerticalTextAlignmentTop, fontName, fontSize); +} CCLabelTTF * CCLabelTTF::create(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, const char *fontName, float fontSize) { return CCLabelTTF::create(string, dimensions, hAlignment, kCCVerticalTextAlignmentTop, fontName, fontSize); } -// CCLabelTTF* CCLabelTTF::labelWithString(const char *string, const cocos2d::CCSize &dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize) -// { -// return CCLabelTTF::create(string, dimensions, hAlignment, vAlignment, fontName, fontSize); -// } +CCLabelTTF* CCLabelTTF::labelWithString(const char *string, const cocos2d::CCSize &dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize) +{ + return CCLabelTTF::create(string, dimensions, hAlignment, vAlignment, fontName, fontSize); +} CCLabelTTF* CCLabelTTF::create(const char *string, const cocos2d::CCSize &dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize) { diff --git a/cocos2dx/label_nodes/CCLabelTTF.h b/cocos2dx/label_nodes/CCLabelTTF.h index eeebb4fdfe..682411bdf8 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.h +++ b/cocos2dx/label_nodes/CCLabelTTF.h @@ -46,20 +46,20 @@ public: /** creates a CCLabelTTF with a font name and font size in points @warning: This interface will be deprecated in future. */ - //static CCLabelTTF * labelWithString(const char *string, const char *fontName, float fontSize); + static CCLabelTTF * labelWithString(const char *string, const char *fontName, float fontSize); /** creates a CCLabelTTF from a fontname, horizontal alignment, dimension in points, and font size in points. @warning: This interface will be deprecated in future. @since v1.0 */ - //static CCLabelTTF * labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, - // const char *fontName, float fontSize); + static CCLabelTTF * labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, + const char *fontName, float fontSize); /** creates a CCLabel from a fontname, alignment, dimension in points and font size in points @warning: This interface will be deprecated in future. */ - //static CCLabelTTF * labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, - // CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize); + static CCLabelTTF * labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, + CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize); /** creates a CCLabelTTF with a font name and font size in points*/ static CCLabelTTF * create(const char *string, const char *fontName, float fontSize); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index 73ee4bbeec..07191e751c 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -73,10 +73,10 @@ bool CCLayer::init() return bRet; } -// CCLayer *CCLayer::node() -// { -// return CCLayer::create(); -// } +CCLayer *CCLayer::node() +{ + return CCLayer::create(); +} CCLayer *CCLayer::create() { @@ -426,10 +426,10 @@ void CCLayerColor::setBlendFunc(ccBlendFunc var) m_tBlendFunc = var; } -// CCLayerColor * CCLayerColor::layerWithColor(const ccColor4B& color, GLfloat width, GLfloat height) -// { -// return CCLayerColor::create(color,width,height); -// } +CCLayerColor * CCLayerColor::layerWithColor(const ccColor4B& color, GLfloat width, GLfloat height) +{ + return CCLayerColor::create(color,width,height); +} CCLayerColor * CCLayerColor::create(const ccColor4B& color, GLfloat width, GLfloat height) { @@ -443,10 +443,10 @@ CCLayerColor * CCLayerColor::create(const ccColor4B& color, GLfloat width, GLflo return NULL; } -// CCLayerColor * CCLayerColor::layerWithColor(const ccColor4B& color) -// { -// return CCLayerColor::create(color); -// } +CCLayerColor * CCLayerColor::layerWithColor(const ccColor4B& color) +{ + return CCLayerColor::create(color); +} CCLayerColor * CCLayerColor::create(const ccColor4B& color) { @@ -558,10 +558,10 @@ void CCLayerColor::draw() // // CCLayerGradient // -// CCLayerGradient* CCLayerGradient::layerWithColor(const ccColor4B& start, const ccColor4B& end) -// { -// return CCLayerGradient::create(start, end); -// } +CCLayerGradient* CCLayerGradient::layerWithColor(const ccColor4B& start, const ccColor4B& end) +{ + return CCLayerGradient::create(start, end); +} CCLayerGradient* CCLayerGradient::create(const ccColor4B& start, const ccColor4B& end) { @@ -575,10 +575,10 @@ CCLayerGradient* CCLayerGradient::create(const ccColor4B& start, const ccColor4B return NULL; } -// CCLayerGradient* CCLayerGradient::layerWithColor(const ccColor4B& start, const ccColor4B& end, const CCPoint& v) -// { -// return CCLayerGradient::create(start, end, v); -// } +CCLayerGradient* CCLayerGradient::layerWithColor(const ccColor4B& start, const ccColor4B& end, const CCPoint& v) +{ + return CCLayerGradient::create(start, end, v); +} CCLayerGradient* CCLayerGradient::create(const ccColor4B& start, const ccColor4B& end, const CCPoint& v) { @@ -745,22 +745,22 @@ CCLayerMultiplex::~CCLayerMultiplex() CC_SAFE_RELEASE(m_pLayers); } -// CCLayerMultiplex * CCLayerMultiplex::layerWithLayers(CCLayer * layer, ...) -// { -// va_list args; -// va_start(args,layer); -// -// CCLayerMultiplex * pMultiplexLayer = new CCLayerMultiplex(); -// if(pMultiplexLayer && pMultiplexLayer->initWithLayers(layer, args)) -// { -// pMultiplexLayer->autorelease(); -// va_end(args); -// return pMultiplexLayer; -// } -// va_end(args); -// CC_SAFE_DELETE(pMultiplexLayer); -// return NULL; -// } +CCLayerMultiplex * CCLayerMultiplex::layerWithLayers(CCLayer * layer, ...) +{ + va_list args; + va_start(args,layer); + + CCLayerMultiplex * pMultiplexLayer = new CCLayerMultiplex(); + if(pMultiplexLayer && pMultiplexLayer->initWithLayers(layer, args)) + { + pMultiplexLayer->autorelease(); + va_end(args); + return pMultiplexLayer; + } + va_end(args); + CC_SAFE_DELETE(pMultiplexLayer); + return NULL; +} CCLayerMultiplex * CCLayerMultiplex::create(CCLayer * layer, ...) { @@ -779,12 +779,12 @@ CCLayerMultiplex * CCLayerMultiplex::create(CCLayer * layer, ...) return NULL; } -// CCLayerMultiplex * CCLayerMultiplex::layerWithLayer(CCLayer* layer) -// { -// return CCLayerMultiplex::create(layer); -// } +CCLayerMultiplex * CCLayerMultiplex::layerWithLayer(CCLayer* layer) +{ + return CCLayerMultiplex::createWithLayer(layer); +} -CCLayerMultiplex * CCLayerMultiplex::create(CCLayer* layer) +CCLayerMultiplex * CCLayerMultiplex::createWithLayer(CCLayer* layer) { CCLayerMultiplex * pMultiplexLayer = new CCLayerMultiplex(); pMultiplexLayer->initWithLayer(layer); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h index f405836f57..0181b1799a 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h @@ -55,7 +55,7 @@ public: bool init(); // @warning: This interface will be deprecated in future. - //static CCLayer *node(void); + static CCLayer *node(void); /** create one layer */ static CCLayer *create(void); @@ -120,22 +120,22 @@ private: // for the subclass of CCLayer, each has to implement the static "node" method // @warning: This interface will be deprecated in future. -//#define LAYER_NODE_FUNC(layer) \ -// static layer* node() \ -// { \ -// layer *pRet = new layer(); \ -// if (pRet && pRet->init()) \ -// { \ -// pRet->autorelease(); \ -// return pRet; \ -// } \ -// else \ -// { \ -// delete pRet; \ -// pRet = NULL; \ -// return NULL; \ -// } \ -// } +#define LAYER_NODE_FUNC(layer) \ + static layer* node() \ + { \ + layer *pRet = new layer(); \ + if (pRet && pRet->init()) \ + { \ + pRet->autorelease(); \ + return pRet; \ + } \ + else \ + { \ + delete pRet; \ + pRet = NULL; \ + return NULL; \ + } \ +} // for the subclass of CCLayer, each has to implement the static "node" method @@ -157,22 +157,22 @@ private: } // @warning: This interface will be deprecated in future. -//#define LAYER_NODE_FUNC_PARAM(layer,__PARAMTYPE__,__PARAM__) \ -// static layer* node(__PARAMTYPE__ __PARAM__) \ -// { \ -// layer *pRet = new layer(); \ -// if (pRet && pRet->init(__PARAM__)) \ -// { \ -// pRet->autorelease(); \ -// return pRet; \ -// } \ -// else \ -// { \ -// delete pRet; \ -// pRet = NULL; \ -// return NULL; \ -// } \ -// } +#define LAYER_NODE_FUNC_PARAM(layer,__PARAMTYPE__,__PARAM__) \ + static layer* node(__PARAMTYPE__ __PARAM__) \ + { \ + layer *pRet = new layer(); \ + if (pRet && pRet->init(__PARAM__)) \ + { \ + pRet->autorelease(); \ + return pRet; \ + } \ + else \ + { \ + delete pRet; \ + pRet = NULL; \ + return NULL; \ + } \ + } #define LAYER_CREATE_FUNC_PARAM(layer,__PARAMTYPE__,__PARAM__) \ @@ -217,11 +217,11 @@ public: /** creates a CCLayer with color, width and height in Points @warning: This interface will be deprecated in future. */ - //static CCLayerColor * layerWithColor(const ccColor4B& color, GLfloat width, GLfloat height); + static CCLayerColor * layerWithColor(const ccColor4B& color, GLfloat width, GLfloat height); /** creates a CCLayer with color. Width and height are the window size. @warning: This interface will be deprecated in future. */ - //static CCLayerColor * layerWithColor(const ccColor4B& color); + static CCLayerColor * layerWithColor(const ccColor4B& color); /** creates a CCLayer with color, width and height in Points */ static CCLayerColor * create(const ccColor4B& color, GLfloat width, GLfloat height); @@ -287,12 +287,12 @@ public: /** Creates a full-screen CCLayer with a gradient between start and end. @warning: This interface will be deprecated in future. */ - //static CCLayerGradient* layerWithColor(const ccColor4B& start, const ccColor4B& end); + static CCLayerGradient* layerWithColor(const ccColor4B& start, const ccColor4B& end); /** Creates a full-screen CCLayer with a gradient between start and end in the direction of v. @warning: This interface will be deprecated in future. */ - //static CCLayerGradient* layerWithColor(const ccColor4B& start, const ccColor4B& end, const CCPoint& v); + static CCLayerGradient* layerWithColor(const ccColor4B& start, const ccColor4B& end, const CCPoint& v); /** Creates a full-screen CCLayer with a gradient between start and end. */ static CCLayerGradient* create(const ccColor4B& start, const ccColor4B& end); @@ -340,14 +340,14 @@ public: /** creates a CCLayerMultiplex with one or more layers using a variable argument list. @warning: This interface will be deprecated in future. */ - //static CCLayerMultiplex * layerWithLayers(CCLayer* layer, ... ); + static CCLayerMultiplex * layerWithLayers(CCLayer* layer, ... ); /** * lua script can not init with undetermined number of variables * so add these functinons to be used with lua. @warning: This interface will be deprecated in future. */ - //static CCLayerMultiplex * layerWithLayer(CCLayer* layer); + static CCLayerMultiplex * layerWithLayer(CCLayer* layer); /** creates a CCLayerMultiplex with one or more layers using a variable argument list. */ static CCLayerMultiplex * create(CCLayer* layer, ... ); @@ -356,7 +356,7 @@ public: * lua script can not init with undetermined number of variables * so add these functinons to be used with lua. */ - static CCLayerMultiplex * create(CCLayer* layer); + static CCLayerMultiplex * createWithLayer(CCLayer* layer); void addLayer(CCLayer* layer); bool initWithLayer(CCLayer* layer); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp index 818cb049f2..b7b9def3c9 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp @@ -54,10 +54,10 @@ bool CCScene::init() return bRet; } -// CCScene *CCScene::node() -// { -// return CCScene::create(); -// } +CCScene *CCScene::node() +{ + return CCScene::create(); +} CCScene *CCScene::create() { diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCScene.h b/cocos2dx/layers_scenes_transitions_nodes/CCScene.h index 997e43e6dc..346d73eb8d 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCScene.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCScene.h @@ -47,7 +47,7 @@ public: CCScene(); virtual ~CCScene(); bool init(); - //static CCScene *node(void); + static CCScene *node(void); static CCScene *create(void); }; @@ -55,38 +55,38 @@ NS_CC_END // for the subclass of CCScene, each has to implement the static "node" method // @warning: This interface will be deprecated in future. -// #define SCENE_NODE_FUNC(scene) \ -// static scene* node() \ -// { \ -// scene *pRet = new scene(); \ -// if (pRet && pRet->init()) \ -// { \ -// pRet->autorelease(); \ -// return pRet; \ -// } \ -// else \ -// { \ -// delete pRet; \ -// pRet = NULL; \ -// return NULL; \ -// } \ -// }; +#define SCENE_NODE_FUNC(scene) \ +static scene* node() \ +{ \ + scene *pRet = new scene(); \ + if (pRet && pRet->init()) \ + { \ + pRet->autorelease(); \ + return pRet; \ + } \ + else \ + { \ + delete pRet; \ + pRet = NULL; \ + return NULL; \ + } \ +}; // @warning: This interface will be deprecated in future. -// #define SCENE_FUNC_PARAM(__TYPE__,__PARAMTYPE__,__PARAM__) \ -// static cocos2d::CCScene* node(__PARAMTYPE__ __PARAM__) \ -// { \ -// cocos2d::CCScene * scene = NULL; \ -// do \ -// { \ -// scene = cocos2d::CCScene::node(); \ -// CC_BREAK_IF(! scene); \ -// __TYPE__ *layer = __TYPE__::node(__PARAM__); \ -// CC_BREAK_IF(! layer); \ -// scene->addChild(layer); \ -// } while (0); \ -// return scene; \ -// } +#define SCENE_FUNC_PARAM(__TYPE__,__PARAMTYPE__,__PARAM__) \ + static cocos2d::CCScene* node(__PARAMTYPE__ __PARAM__) \ + { \ + cocos2d::CCScene * scene = NULL; \ + do \ + { \ + scene = cocos2d::CCScene::node(); \ + CC_BREAK_IF(! scene); \ + __TYPE__ *layer = __TYPE__::node(__PARAM__); \ + CC_BREAK_IF(! layer); \ + scene->addChild(layer); \ + } while (0); \ + return scene; \ + } // for the subclass of CCScene, each has to implement the static "node" method #define SCENE_CREATE_FUNC(scene) \ diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp index acf3c10f32..555923f233 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp @@ -51,10 +51,10 @@ CCTransitionScene::~CCTransitionScene() m_pOutScene->release(); } -// CCTransitionScene * CCTransitionScene::transitionWithDuration(float t, CCScene *scene) -// { -// return CCTransitionScene::create(t,scene); -// } +CCTransitionScene * CCTransitionScene::transitionWithDuration(float t, CCScene *scene) +{ + return CCTransitionScene::create(t,scene); +} CCTransitionScene * CCTransitionScene::create(float t, CCScene *scene) { @@ -204,10 +204,10 @@ CCTransitionSceneOriented::~CCTransitionSceneOriented() { } -// CCTransitionSceneOriented * CCTransitionSceneOriented::transitionWithDuration(float t, CCScene *scene, tOrientation orientation) -// { -// return CCTransitionSceneOriented::create(t,scene,orientation); -// } +CCTransitionSceneOriented * CCTransitionSceneOriented::transitionWithDuration(float t, CCScene *scene, tOrientation orientation) +{ + return CCTransitionSceneOriented::create(t,scene,orientation); +} CCTransitionSceneOriented * CCTransitionSceneOriented::create(float t, CCScene *scene, tOrientation orientation) { @@ -648,10 +648,10 @@ void CCTransitionFlipX::onEnter() m_pOutScene->runAction(outA); } -// CCTransitionFlipX* CCTransitionFlipX::transitionWithDuration(float t, CCScene* s, tOrientation o) -// { -// return CCTransitionFlipX::create(t, s, o); -// } +CCTransitionFlipX* CCTransitionFlipX::transitionWithDuration(float t, CCScene* s, tOrientation o) +{ + return CCTransitionFlipX::create(t, s, o); +} CCTransitionFlipX* CCTransitionFlipX::create(float t, CCScene* s, tOrientation o) { @@ -718,10 +718,10 @@ void CCTransitionFlipY::onEnter() } -// CCTransitionFlipY* CCTransitionFlipY::transitionWithDuration(float t, CCScene* s, tOrientation o) -// { -// return CCTransitionFlipY::create(t, s, o); -// } +CCTransitionFlipY* CCTransitionFlipY::transitionWithDuration(float t, CCScene* s, tOrientation o) +{ + return CCTransitionFlipY::create(t, s, o); +} CCTransitionFlipY* CCTransitionFlipY::create(float t, CCScene* s, tOrientation o) { @@ -866,10 +866,10 @@ void CCTransitionZoomFlipX::onEnter() m_pOutScene->runAction(outA); } -// CCTransitionZoomFlipX* CCTransitionZoomFlipX::transitionWithDuration(float t, CCScene* s, tOrientation o) -// { -// return CCTransitionZoomFlipX::create(t, s, o); -// } +CCTransitionZoomFlipX* CCTransitionZoomFlipX::transitionWithDuration(float t, CCScene* s, tOrientation o) +{ + return CCTransitionZoomFlipX::create(t, s, o); +} CCTransitionZoomFlipX* CCTransitionZoomFlipX::create(float t, CCScene* s, tOrientation o) { @@ -945,10 +945,10 @@ void CCTransitionZoomFlipY::onEnter() m_pOutScene->runAction(outA); } -// CCTransitionZoomFlipY* CCTransitionZoomFlipY::transitionWithDuration(float t, CCScene* s, tOrientation o) -// { -// return CCTransitionZoomFlipY::create(t, s, o); -// } +CCTransitionZoomFlipY* CCTransitionZoomFlipY::transitionWithDuration(float t, CCScene* s, tOrientation o) +{ + return CCTransitionZoomFlipY::create(t, s, o); +} CCTransitionZoomFlipY* CCTransitionZoomFlipY::create(float t, CCScene* s, tOrientation o) { @@ -1026,10 +1026,10 @@ void CCTransitionZoomFlipAngular::onEnter() m_pOutScene->runAction(outA); } -// CCTransitionZoomFlipAngular* CCTransitionZoomFlipAngular::transitionWithDuration(float t, CCScene* s, tOrientation o) -// { -// return CCTransitionZoomFlipAngular::create(t, s, o); -// } +CCTransitionZoomFlipAngular* CCTransitionZoomFlipAngular::transitionWithDuration(float t, CCScene* s, tOrientation o) +{ + return CCTransitionZoomFlipAngular::create(t, s, o); +} CCTransitionZoomFlipAngular* CCTransitionZoomFlipAngular::create(float t, CCScene* s, tOrientation o) { @@ -1050,10 +1050,10 @@ CCTransitionFade::~CCTransitionFade() { } -// CCTransitionFade * CCTransitionFade::transitionWithDuration(float duration, CCScene *scene, const ccColor3B& color) -// { -// return CCTransitionFade::create(duration, scene, color); -// } +CCTransitionFade * CCTransitionFade::transitionWithDuration(float duration, CCScene *scene, const ccColor3B& color) +{ + return CCTransitionFade::create(duration, scene, color); +} CCTransitionFade * CCTransitionFade::create(float duration, CCScene *scene, const ccColor3B& color) { diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h index d166bcd29a..d4c4d962ce 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h @@ -129,7 +129,7 @@ public: /** creates a base transition with duration and incoming scene @warning: This interface will be deprecated in future. */ - //static CCTransitionScene * transitionWithDuration(float t, CCScene *scene); + static CCTransitionScene * transitionWithDuration(float t, CCScene *scene); /** creates a base transition with duration and incoming scene */ static CCTransitionScene * create(float t, CCScene *scene); @@ -165,7 +165,7 @@ public: /** creates a base transition with duration and incoming scene @warning: This interface will be deprecated in future. */ - // static CCTransitionSceneOriented * transitionWithDuration(float t,CCScene* scene, tOrientation orientation); + static CCTransitionSceneOriented * transitionWithDuration(float t,CCScene* scene, tOrientation orientation); /** creates a base transition with duration and incoming scene */ static CCTransitionSceneOriented * create(float t,CCScene* scene, tOrientation orientation); @@ -378,7 +378,7 @@ public: virtual void onEnter(); // @warning: This interface will be deprecated in future. - //static CCTransitionFlipX* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionFlipX* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); static CCTransitionFlipX* create(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; @@ -395,7 +395,7 @@ public: virtual void onEnter(); //@warning: This interface will be deprecated in future. - //static CCTransitionFlipY* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationUpOver); + static CCTransitionFlipY* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationUpOver); static CCTransitionFlipY* create(float t, CCScene* s, tOrientation o = kOrientationUpOver); }; @@ -412,7 +412,7 @@ public: virtual void onEnter(); //@warning: This interface will be deprecated in future. - //static CCTransitionFlipAngular* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionFlipAngular* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); static CCTransitionFlipAngular* create(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; @@ -429,7 +429,7 @@ public: virtual void onEnter(); //@warning: This interface will be deprecated in future. - //static CCTransitionZoomFlipX* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionZoomFlipX* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); static CCTransitionZoomFlipX* create(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; @@ -446,7 +446,7 @@ public: virtual void onEnter(); //@warning: This interface will be deprecated in future. - //static CCTransitionZoomFlipY* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationUpOver); + static CCTransitionZoomFlipY* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationUpOver); static CCTransitionZoomFlipY* create(float t, CCScene* s, tOrientation o = kOrientationUpOver); }; @@ -463,7 +463,7 @@ public: virtual void onEnter(); //@warning: This interface will be deprecated in future. - //static CCTransitionZoomFlipAngular* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionZoomFlipAngular* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); static CCTransitionZoomFlipAngular* create(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; @@ -484,7 +484,7 @@ public: * Example: FadeTransition::transitionWithDuration(2, scene, ccc3(255,0,0); // red color @warning: This interface will be deprecated in future. */ - //static CCTransitionFade* transitionWithDuration(float duration,CCScene* scene, const ccColor3B& color = ccBLACK); + static CCTransitionFade* transitionWithDuration(float duration,CCScene* scene, const ccColor3B& color = ccBLACK); /** creates the transition with a duration and with an RGB color * Example: FadeTransition::create(2, scene, ccc3(255,0,0); // red color diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp index 5fdfc140f8..ac6ec99b1f 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp @@ -40,10 +40,10 @@ CCTransitionPageTurn::~CCTransitionPageTurn() { } -// CCTransitionPageTurn * CCTransitionPageTurn::transitionWithDuration(float t, CCScene *scene, bool backwards) -// { -// return CCTransitionPageTurn::create(t,scene,backwards); -// } +CCTransitionPageTurn * CCTransitionPageTurn::transitionWithDuration(float t, CCScene *scene, bool backwards) +{ + return CCTransitionPageTurn::create(t,scene,backwards); +} /** creates a base transition with duration and incoming scene */ CCTransitionPageTurn * CCTransitionPageTurn::create(float t, CCScene *scene, bool backwards) diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h index ec2ae213a1..b002c77e18 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h @@ -56,7 +56,7 @@ public: * scene is being turned from left over the outgoing scene. @warning: This interface will be deprecated in future. */ - //static CCTransitionPageTurn* transitionWithDuration(float t,CCScene* scene,bool backwards); + static CCTransitionPageTurn* transitionWithDuration(float t,CCScene* scene,bool backwards); /** * Creates a base transition with duration and incoming scene. diff --git a/cocos2dx/menu_nodes/CCMenu.cpp b/cocos2dx/menu_nodes/CCMenu.cpp index 82f6245e8d..f40c026ee7 100644 --- a/cocos2dx/menu_nodes/CCMenu.cpp +++ b/cocos2dx/menu_nodes/CCMenu.cpp @@ -46,31 +46,31 @@ enum //CCMenu // -// CCMenu* CCMenu::node() -// { -// return CCMenu::create(); -// } +CCMenu* CCMenu::node() +{ + return CCMenu::create(); +} CCMenu* CCMenu::create() { return CCMenu::create(NULL, NULL); } -// CCMenu * CCMenu::menuWithItems(CCMenuItem* item, ...) -// { -// va_list args; -// va_start(args,item); -// CCMenu *pRet = new CCMenu(); -// if (pRet && pRet->initWithItems(item, args)) -// { -// pRet->autorelease(); -// va_end(args); -// return pRet; -// } -// va_end(args); -// CC_SAFE_DELETE(pRet); -// return NULL; -// } +CCMenu * CCMenu::menuWithItems(CCMenuItem* item, ...) +{ + va_list args; + va_start(args,item); + CCMenu *pRet = new CCMenu(); + if (pRet && pRet->initWithItems(item, args)) + { + pRet->autorelease(); + va_end(args); + return pRet; + } + va_end(args); + CC_SAFE_DELETE(pRet); + return NULL; +} CCMenu * CCMenu::create(CCMenuItem* item, ...) { @@ -88,10 +88,10 @@ CCMenu * CCMenu::create(CCMenuItem* item, ...) return NULL; } -// CCMenu* CCMenu::menuWithArray(CCArray* pArrayOfItems) -// { -// return CCMenu::create(pArrayOfItems); -// } +CCMenu* CCMenu::menuWithArray(CCArray* pArrayOfItems) +{ + return CCMenu::create(pArrayOfItems); +} CCMenu* CCMenu::create(CCArray* pArrayOfItems) { @@ -108,10 +108,10 @@ CCMenu* CCMenu::create(CCArray* pArrayOfItems) return pRet; } -// CCMenu* CCMenu::menuWithItem(CCMenuItem* item) -// { -// return CCMenu::createWithItem(item); -// } +CCMenu* CCMenu::menuWithItem(CCMenuItem* item) +{ + return CCMenu::createWithItem(item); +} CCMenu* CCMenu::createWithItem(CCMenuItem* item) { diff --git a/cocos2dx/menu_nodes/CCMenu.h b/cocos2dx/menu_nodes/CCMenu.h index 9aa9155a37..5d0a4c2e4f 100644 --- a/cocos2dx/menu_nodes/CCMenu.h +++ b/cocos2dx/menu_nodes/CCMenu.h @@ -65,24 +65,24 @@ public: /** creates an empty CCMenu @warning: This interface will be deprecated in future. */ - //static CCMenu* node(); + static CCMenu* node(); /** creates a CCMenu with it's items @warning: This interface will be deprecated in future. */ - //static CCMenu* menuWithItems(CCMenuItem* item, ...); + static CCMenu* menuWithItems(CCMenuItem* item, ...); /** creates a CCMenu with a NSArray of CCMenuItem objects @warning: This interface will be deprecated in future. */ - //static CCMenu* menuWithArray(CCArray* pArrayOfItems); + static CCMenu* menuWithArray(CCArray* pArrayOfItems); /** creates a CCMenu with it's item, then use addChild() to add * other items. It is used for script, it can't init with undetermined * number of variables. @warning: This interface will be deprecated in future. */ - //static CCMenu* menuWithItem(CCMenuItem* item); + static CCMenu* menuWithItem(CCMenuItem* item); /** creates an empty CCMenu */ static CCMenu* create(); diff --git a/cocos2dx/menu_nodes/CCMenuItem.cpp b/cocos2dx/menu_nodes/CCMenuItem.cpp index d9a351f7ed..4d80c3dae4 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.cpp +++ b/cocos2dx/menu_nodes/CCMenuItem.cpp @@ -48,10 +48,10 @@ const unsigned int kDisableTag = 0x3; // // CCMenuItem // -// CCMenuItem * CCMenuItem::itemWithTarget(CCObject *rec, SEL_MenuHandler selector) -// { -// return CCMenuItem::create(rec, selector); -// } +CCMenuItem * CCMenuItem::itemWithTarget(CCObject *rec, SEL_MenuHandler selector) +{ + return CCMenuItem::create(rec, selector); +} CCMenuItem * CCMenuItem::create(CCObject *rec, SEL_MenuHandler selector) { @@ -179,10 +179,10 @@ void CCMenuItemLabel::setLabel(CCNode* var) m_pLabel = var; } -// CCMenuItemLabel * CCMenuItemLabel::itemWithLabel(CCNode*label, CCObject* target, SEL_MenuHandler selector) -// { -// return CCMenuItemLabel::create(label, target, selector); -// } +CCMenuItemLabel * CCMenuItemLabel::itemWithLabel(CCNode*label, CCObject* target, SEL_MenuHandler selector) +{ + return CCMenuItemLabel::create(label, target, selector); +} CCMenuItemLabel * CCMenuItemLabel::create(CCNode*label, CCObject* target, SEL_MenuHandler selector) { @@ -192,10 +192,10 @@ CCMenuItemLabel * CCMenuItemLabel::create(CCNode*label, CCObject* target, SEL_Me return pRet; } -// CCMenuItemLabel* CCMenuItemLabel::itemWithLabel(CCNode *label) -// { -// return CCMenuItemLabel::create(label); -// } +CCMenuItemLabel* CCMenuItemLabel::itemWithLabel(CCNode *label) +{ + return CCMenuItemLabel::create(label); +} CCMenuItemLabel* CCMenuItemLabel::create(CCNode *label) { @@ -311,20 +311,20 @@ const ccColor3B& CCMenuItemLabel::getColor() // //CCMenuItemAtlasFont // -// CCMenuItemAtlasFont * CCMenuItemAtlasFont::itemWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap) -// { -// return CCMenuItemAtlasFont::create(value, charMapFile, itemWidth, itemHeight, startCharMap); -// } +CCMenuItemAtlasFont * CCMenuItemAtlasFont::itemWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap) +{ + return CCMenuItemAtlasFont::create(value, charMapFile, itemWidth, itemHeight, startCharMap); +} CCMenuItemAtlasFont * CCMenuItemAtlasFont::create(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap) { return CCMenuItemAtlasFont::create(value, charMapFile, itemWidth, itemHeight, startCharMap, NULL, NULL); } -// CCMenuItemAtlasFont * CCMenuItemAtlasFont::itemWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, CCObject* target, SEL_MenuHandler selector) -// { -// return CCMenuItemAtlasFont::create(value, charMapFile, itemWidth, itemHeight, startCharMap, target, selector); -// } +CCMenuItemAtlasFont * CCMenuItemAtlasFont::itemWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, CCObject* target, SEL_MenuHandler selector) +{ + return CCMenuItemAtlasFont::create(value, charMapFile, itemWidth, itemHeight, startCharMap, target, selector); +} CCMenuItemAtlasFont * CCMenuItemAtlasFont::create(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, CCObject* target, SEL_MenuHandler selector) { @@ -374,10 +374,10 @@ const char * CCMenuItemFont::fontName() return _fontName.c_str(); } -// CCMenuItemFont * CCMenuItemFont::itemWithString(const char *value, CCObject* target, SEL_MenuHandler selector) -// { -// return CCMenuItemFont::create(value, target, selector); -// } +CCMenuItemFont * CCMenuItemFont::itemWithString(const char *value, CCObject* target, SEL_MenuHandler selector) +{ + return CCMenuItemFont::create(value, target, selector); +} CCMenuItemFont * CCMenuItemFont::create(const char *value, CCObject* target, SEL_MenuHandler selector) { @@ -387,10 +387,10 @@ CCMenuItemFont * CCMenuItemFont::create(const char *value, CCObject* target, SEL return pRet; } -// CCMenuItemFont * CCMenuItemFont::itemWithString(const char *value) -// { -// return CCMenuItemFont::create(value); -// } +CCMenuItemFont * CCMenuItemFont::itemWithString(const char *value) +{ + return CCMenuItemFont::create(value); +} CCMenuItemFont * CCMenuItemFont::create(const char *value) { @@ -567,30 +567,30 @@ const ccColor3B& CCMenuItemSprite::getColor() return dynamic_cast(m_pNormalImage)->getColor(); } -// CCMenuItemSprite * CCMenuItemSprite::itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite) -// { -// return CCMenuItemSprite::create(normalSprite, selectedSprite, disabledSprite); -// } +CCMenuItemSprite * CCMenuItemSprite::itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite) +{ + return CCMenuItemSprite::create(normalSprite, selectedSprite, disabledSprite); +} CCMenuItemSprite * CCMenuItemSprite::create(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite) { return CCMenuItemSprite::create(normalSprite, selectedSprite, disabledSprite, NULL, NULL); } -// CCMenuItemSprite * CCMenuItemSprite::itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCObject* target, SEL_MenuHandler selector) -// { -// return CCMenuItemSprite::create(normalSprite, selectedSprite, target, selector); -// } +CCMenuItemSprite * CCMenuItemSprite::itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCObject* target, SEL_MenuHandler selector) +{ + return CCMenuItemSprite::create(normalSprite, selectedSprite, target, selector); +} CCMenuItemSprite * CCMenuItemSprite::create(CCNode* normalSprite, CCNode* selectedSprite, CCObject* target, SEL_MenuHandler selector) { return CCMenuItemSprite::create(normalSprite, selectedSprite, NULL, target, selector); } -// CCMenuItemSprite * CCMenuItemSprite::itemWithNormalSprite(CCNode *normalSprite, CCNode *selectedSprite, CCNode *disabledSprite, CCObject *target, SEL_MenuHandler selector) -// { -// return CCMenuItemSprite::create(normalSprite, selectedSprite, disabledSprite, target, selector); -// } +CCMenuItemSprite * CCMenuItemSprite::itemWithNormalSprite(CCNode *normalSprite, CCNode *selectedSprite, CCNode *disabledSprite, CCObject *target, SEL_MenuHandler selector) +{ + return CCMenuItemSprite::create(normalSprite, selectedSprite, disabledSprite, target, selector); +} CCMenuItemSprite * CCMenuItemSprite::create(CCNode *normalSprite, CCNode *selectedSprite, CCNode *disabledSprite, CCObject *target, SEL_MenuHandler selector) { @@ -687,30 +687,30 @@ void CCMenuItemSprite::updateImagesVisibility() } } -// CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, const char *selectedImage) -// { -// CCMenuItemImage::create(normalImage, selectedImage); -// } +CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, const char *selectedImage) +{ + return CCMenuItemImage::create(normalImage, selectedImage); +} CCMenuItemImage * CCMenuItemImage::create(const char *normalImage, const char *selectedImage) { return CCMenuItemImage::create(normalImage, selectedImage, NULL, NULL, NULL); } -// CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, const char *selectedImage, CCObject* target, SEL_MenuHandler selector) -// { -// return CCMenuItemImage::create(normalImage, selectedImage, target, selector); -// } +CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, const char *selectedImage, CCObject* target, SEL_MenuHandler selector) +{ + return CCMenuItemImage::create(normalImage, selectedImage, target, selector); +} CCMenuItemImage * CCMenuItemImage::create(const char *normalImage, const char *selectedImage, CCObject* target, SEL_MenuHandler selector) { return CCMenuItemImage::create(normalImage, selectedImage, NULL, target, selector); } -// CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector) -// { -// return CCMenuItemImage::create(normalImage, selectedImage, disabledImage, target, selector); -// } +CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector) +{ + return CCMenuItemImage::create(normalImage, selectedImage, disabledImage, target, selector); +} CCMenuItemImage * CCMenuItemImage::create(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector) { @@ -724,10 +724,10 @@ CCMenuItemImage * CCMenuItemImage::create(const char *normalImage, const char *s return NULL; } -// CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage) -// { -// return CCMenuItemImage::create(normalImage, selectedImage, disabledImage); -// } +CCMenuItemImage * CCMenuItemImage::itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage) +{ + return CCMenuItemImage::create(normalImage, selectedImage, disabledImage); +} CCMenuItemImage * CCMenuItemImage::create(const char *normalImage, const char *selectedImage, const char *disabledImage) { @@ -791,16 +791,16 @@ CCArray* CCMenuItemToggle::getSubItems() return m_pSubItems; } -// CCMenuItemToggle * CCMenuItemToggle::itemWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...) -// { -// va_list args; -// va_start(args, item); -// CCMenuItemToggle *pRet = new CCMenuItemToggle(); -// pRet->initWithTarget(target, selector, item, args); -// pRet->autorelease(); -// va_end(args); -// return pRet; -// } +CCMenuItemToggle * CCMenuItemToggle::itemWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...) +{ + va_list args; + va_start(args, item); + CCMenuItemToggle *pRet = new CCMenuItemToggle(); + pRet->initWithTarget(target, selector, item, args); + pRet->autorelease(); + va_end(args); + return pRet; +} CCMenuItemToggle * CCMenuItemToggle::create(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...) { @@ -831,10 +831,10 @@ bool CCMenuItemToggle::initWithTarget(CCObject* target, SEL_MenuHandler selector return true; } -// CCMenuItemToggle* CCMenuItemToggle::itemWithItem(CCMenuItem *item) -// { -// return CCMenuItemToggle::create(item); -// } +CCMenuItemToggle* CCMenuItemToggle::itemWithItem(CCMenuItem *item) +{ + return CCMenuItemToggle::create(item); +} CCMenuItemToggle* CCMenuItemToggle::create(CCMenuItem *item) { diff --git a/cocos2dx/menu_nodes/CCMenuItem.h b/cocos2dx/menu_nodes/CCMenuItem.h index b04af1308e..b4d40301af 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.h +++ b/cocos2dx/menu_nodes/CCMenuItem.h @@ -62,7 +62,7 @@ public: /** Creates a CCMenuItem with a target/selector @warning: This interface will be deprecated in future. */ - //static CCMenuItem * itemWithTarget(CCObject *rec, SEL_MenuHandler selector); + static CCMenuItem * itemWithTarget(CCObject *rec, SEL_MenuHandler selector); /** Creates a CCMenuItem with a target/selector */ static CCMenuItem * create(CCObject *rec, SEL_MenuHandler selector); /** Initializes a CCMenuItem with a target/selector */ @@ -110,11 +110,11 @@ public: /** creates a CCMenuItemLabel with a Label, target and selector @warning: This interface will be deprecated in future. */ - //static CCMenuItemLabel * itemWithLabel(CCNode*label, CCObject* target, SEL_MenuHandler selector); + static CCMenuItemLabel * itemWithLabel(CCNode*label, CCObject* target, SEL_MenuHandler selector); /** creates a CCMenuItemLabel with a Label. Target and selector will be nill @warning: This interface will be deprecated in future. */ - //static CCMenuItemLabel* itemWithLabel(CCNode *label); + static CCMenuItemLabel* itemWithLabel(CCNode *label); /** creates a CCMenuItemLabel with a Label, target and selector */ static CCMenuItemLabel * create(CCNode*label, CCObject* target, SEL_MenuHandler selector); @@ -156,11 +156,11 @@ public: /** creates a menu item from a string and atlas with a target/selector @warning: This interface will be deprecated in future. */ - //static CCMenuItemAtlasFont* itemWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap); + static CCMenuItemAtlasFont* itemWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap); /** creates a menu item from a string and atlas. Use it with MenuItemToggle @warning: This interface will be deprecated in future. */ - //static CCMenuItemAtlasFont* itemWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, CCObject* target, SEL_MenuHandler selector); + static CCMenuItemAtlasFont* itemWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, CCObject* target, SEL_MenuHandler selector); /** creates a menu item from a string and atlas with a target/selector */ static CCMenuItemAtlasFont* create(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap); @@ -189,11 +189,11 @@ public: /** creates a menu item from a string without target/selector. To be used with CCMenuItemToggle @warning: This interface will be deprecated in future. */ - //static CCMenuItemFont * itemWithString(const char *value); + static CCMenuItemFont * itemWithString(const char *value); /** creates a menu item from a string with a target/selector @warning: This interface will be deprecated in future. */ - //static CCMenuItemFont * itemWithString(const char *value, CCObject* target, SEL_MenuHandler selector); + static CCMenuItemFont * itemWithString(const char *value, CCObject* target, SEL_MenuHandler selector); /** creates a menu item from a string without target/selector. To be used with CCMenuItemToggle */ static CCMenuItemFont * create(const char *value); @@ -252,15 +252,15 @@ public: /** creates a menu item with a normal, selected and disabled image @warning: This interface will be deprecated in future. */ - //static CCMenuItemSprite * itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite = NULL); + static CCMenuItemSprite * itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite = NULL); /** creates a menu item with a normal and selected image with target/selector @warning: This interface will be deprecated in future. */ - //static CCMenuItemSprite * itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCObject* target, SEL_MenuHandler selector); + static CCMenuItemSprite * itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCObject* target, SEL_MenuHandler selector); /** creates a menu item with a normal,selected and disabled image with target/selector @warning: This interface will be deprecated in future. */ - //static CCMenuItemSprite * itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, CCObject* target, SEL_MenuHandler selector); + static CCMenuItemSprite * itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, CCObject* target, SEL_MenuHandler selector); /** creates a menu item with a normal, selected and disabled image*/ static CCMenuItemSprite * create(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite = NULL); @@ -306,19 +306,19 @@ public: /** creates a menu item with a normal and selected image @warning: This interface will be deprecated in future. */ - //static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage); + static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage); /** creates a menu item with a normal,selected and disabled image @warning: This interface will be deprecated in future. */ - //static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage); + static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage); /** creates a menu item with a normal and selected image with target/selector @warning: This interface will be deprecated in future. */ - //static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage, CCObject* target, SEL_MenuHandler selector); + static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage, CCObject* target, SEL_MenuHandler selector); /** creates a menu item with a normal,selected and disabled image with target/selector @warning: This interface will be deprecated in future. */ - //static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector); + static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector); /** creates a menu item with a normal and selected image*/ static CCMenuItemImage* create(const char *normalImage, const char *selectedImage); @@ -366,7 +366,7 @@ public: /** creates a menu item from a list of items with a target/selector @warning: This interface will be deprecated in future. */ - //static CCMenuItemToggle* itemWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...); + static CCMenuItemToggle* itemWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...); /** creates a menu item from a list of items with a target/selector */ static CCMenuItemToggle* create(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...); @@ -378,7 +378,7 @@ public: /** creates a menu item with a item @warning: This interface will be deprecated in future. */ - //static CCMenuItemToggle* itemWithItem(CCMenuItem *item); + static CCMenuItemToggle* itemWithItem(CCMenuItem *item); /** creates a menu item with a item */ static CCMenuItemToggle* create(CCMenuItem *item); diff --git a/cocos2dx/misc_nodes/CCMotionStreak.cpp b/cocos2dx/misc_nodes/CCMotionStreak.cpp index aea81458c0..2cb2bb4362 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.cpp +++ b/cocos2dx/misc_nodes/CCMotionStreak.cpp @@ -66,10 +66,10 @@ CCMotionStreak::~CCMotionStreak() CC_SAFE_FREE(m_pTexCoords); } -// CCMotionStreak* CCMotionStreak::streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, const char* path) -// { -// return CCMotionStreak::create(fade, minSeg, stroke, color, path); -// } +CCMotionStreak* CCMotionStreak::streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, const char* path) +{ + return CCMotionStreak::create(fade, minSeg, stroke, color, path); +} CCMotionStreak* CCMotionStreak::create(float fade, float minSeg, float stroke, ccColor3B color, const char* path) { @@ -84,10 +84,10 @@ CCMotionStreak* CCMotionStreak::create(float fade, float minSeg, float stroke, c return NULL; } -// CCMotionStreak* CCMotionStreak::streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, CCTexture2D* texture) -// { -// return CCMotionStreak::create(fade, minSeg, stroke, color, texture); -// } +CCMotionStreak* CCMotionStreak::streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, CCTexture2D* texture) +{ + return CCMotionStreak::create(fade, minSeg, stroke, color, texture); +} CCMotionStreak* CCMotionStreak::create(float fade, float minSeg, float stroke, ccColor3B color, CCTexture2D* texture) { diff --git a/cocos2dx/misc_nodes/CCMotionStreak.h b/cocos2dx/misc_nodes/CCMotionStreak.h index 4627e7545b..4253408b8c 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.h +++ b/cocos2dx/misc_nodes/CCMotionStreak.h @@ -44,11 +44,11 @@ public: /** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture filename @warning: This interface will be deprecated in future. */ - //static CCMotionStreak* streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, const char* path); + static CCMotionStreak* streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, const char* path); /** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture @warning: This interface will be deprecated in future. */ - //static CCMotionStreak* streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, CCTexture2D* texture); + static CCMotionStreak* streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, CCTexture2D* texture); /** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture filename */ static CCMotionStreak* create(float fade, float minSeg, float stroke, ccColor3B color, const char* path); diff --git a/cocos2dx/misc_nodes/CCProgressTimer.cpp b/cocos2dx/misc_nodes/CCProgressTimer.cpp index 958949e881..63a92d60c1 100644 --- a/cocos2dx/misc_nodes/CCProgressTimer.cpp +++ b/cocos2dx/misc_nodes/CCProgressTimer.cpp @@ -56,10 +56,10 @@ CCProgressTimer::CCProgressTimer() ,m_bReverseDirection(false) {} -// CCProgressTimer* CCProgressTimer::progressWithSprite(CCSprite* sp) -// { -// return CCProgressTimer::create(sp); -// } +CCProgressTimer* CCProgressTimer::progressWithSprite(CCSprite* sp) +{ + return CCProgressTimer::create(sp); +} CCProgressTimer* CCProgressTimer::create(CCSprite* sp) { diff --git a/cocos2dx/misc_nodes/CCProgressTimer.h b/cocos2dx/misc_nodes/CCProgressTimer.h index 1bc8fd5b7f..a0f1171e83 100644 --- a/cocos2dx/misc_nodes/CCProgressTimer.h +++ b/cocos2dx/misc_nodes/CCProgressTimer.h @@ -82,7 +82,7 @@ public: /** Creates a progress timer with the sprite as the shape the timer goes through @warning: This interface will be deprecated in future. */ - //static CCProgressTimer* progressWithSprite(CCSprite* sp); + static CCProgressTimer* progressWithSprite(CCSprite* sp); /** Creates a progress timer with the sprite as the shape the timer goes through */ static CCProgressTimer* create(CCSprite* sp); protected: diff --git a/cocos2dx/misc_nodes/CCRenderTexture.cpp b/cocos2dx/misc_nodes/CCRenderTexture.cpp index fc42028490..3c3b8ca5b2 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.cpp +++ b/cocos2dx/misc_nodes/CCRenderTexture.cpp @@ -73,10 +73,10 @@ void CCRenderTexture::setSprite(CCSprite* var) m_pSprite = var; } -// CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat) -// { -// return CCRenderTexture::create(w, h, eFormat); -// } +CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat) +{ + return CCRenderTexture::create(w, h, eFormat); +} CCRenderTexture * CCRenderTexture::create(int w, int h, CCTexture2DPixelFormat eFormat) { @@ -91,10 +91,10 @@ CCRenderTexture * CCRenderTexture::create(int w, int h, CCTexture2DPixelFormat e return NULL; } -// CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat) -// { -// return CCRenderTexture::create(w, h, eFormat, uDepthStencilFormat); -// } +CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat) +{ + return CCRenderTexture::create(w, h, eFormat, uDepthStencilFormat); +} CCRenderTexture * CCRenderTexture::create(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat) { @@ -109,10 +109,10 @@ CCRenderTexture * CCRenderTexture::create(int w ,int h, CCTexture2DPixelFormat e return NULL; } -// CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w, int h) -// { -// return CCRenderTexture::create(w, h); -// } +CCRenderTexture * CCRenderTexture::renderTextureWithWidthAndHeight(int w, int h) +{ + return CCRenderTexture::create(w, h); +} CCRenderTexture * CCRenderTexture::create(int w, int h) { diff --git a/cocos2dx/misc_nodes/CCRenderTexture.h b/cocos2dx/misc_nodes/CCRenderTexture.h index 30370412d2..b4a2ed9ff0 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.h +++ b/cocos2dx/misc_nodes/CCRenderTexture.h @@ -61,17 +61,17 @@ public: /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format @warning: This interface will be deprecated in future. */ - //static CCRenderTexture * renderTextureWithWidthAndHeight(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat); + static CCRenderTexture * renderTextureWithWidthAndHeight(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat); /** creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid @warning: This interface will be deprecated in future. */ - //static CCRenderTexture * renderTextureWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat); + static CCRenderTexture * renderTextureWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat); /** creates a RenderTexture object with width and height in Points, pixel format is RGBA8888 @warning: This interface will be deprecated in future. */ - //static CCRenderTexture * renderTextureWithWidthAndHeight(int w, int h); + static CCRenderTexture * renderTextureWithWidthAndHeight(int w, int h); /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format*/ static CCRenderTexture * create(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat); diff --git a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp index b4b5fc4e24..5ee0f4eb54 100644 --- a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp +++ b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp @@ -58,10 +58,10 @@ CCParticleBatchNode::~CCParticleBatchNode() /* * creation with CCTexture2D */ -// CCParticleBatchNode* CCParticleBatchNode::batchNodeWithTexture(CCTexture2D *tex, unsigned int capacity/* = kCCParticleDefaultCapacity*/) -// { -// return CCParticleBatchNode::createWithTexture(tex, capacity); -// } +CCParticleBatchNode* CCParticleBatchNode::batchNodeWithTexture(CCTexture2D *tex, unsigned int capacity/* = kCCParticleDefaultCapacity*/) +{ + return CCParticleBatchNode::createWithTexture(tex, capacity); +} CCParticleBatchNode* CCParticleBatchNode::createWithTexture(CCTexture2D *tex, unsigned int capacity/* = kCCParticleDefaultCapacity*/) { @@ -78,10 +78,10 @@ CCParticleBatchNode* CCParticleBatchNode::createWithTexture(CCTexture2D *tex, un /* * creation with File Image */ -// CCParticleBatchNode* CCParticleBatchNode::batchNodeWithFile(const char* imageFile, unsigned int capacity/* = kCCParticleDefaultCapacity*/) -// { -// return CCParticleBatchNode::create(imageFile, capacity); -// } +CCParticleBatchNode* CCParticleBatchNode::batchNodeWithFile(const char* imageFile, unsigned int capacity/* = kCCParticleDefaultCapacity*/) +{ + return CCParticleBatchNode::create(imageFile, capacity); +} CCParticleBatchNode* CCParticleBatchNode::create(const char* imageFile, unsigned int capacity/* = kCCParticleDefaultCapacity*/) { diff --git a/cocos2dx/particle_nodes/CCParticleBatchNode.h b/cocos2dx/particle_nodes/CCParticleBatchNode.h index c2d175553e..15fb0e0edf 100644 --- a/cocos2dx/particle_nodes/CCParticleBatchNode.h +++ b/cocos2dx/particle_nodes/CCParticleBatchNode.h @@ -68,12 +68,12 @@ public: /** initializes the particle system with CCTexture2D, a capacity of particles, which particle system to use @warning: This interface will be deprecated in future. */ - //static CCParticleBatchNode* batchNodeWithTexture(CCTexture2D *tex, unsigned int capacity = kCCParticleDefaultCapacity); + static CCParticleBatchNode* batchNodeWithTexture(CCTexture2D *tex, unsigned int capacity = kCCParticleDefaultCapacity); /** initializes the particle system with the name of a file on disk (for a list of supported formats look at the CCTexture2D class), a capacity of particles @warning: This interface will be deprecated in future. */ - //static CCParticleBatchNode* batchNodeWithFile(const char* fileImage, unsigned int capacity = kCCParticleDefaultCapacity); + static CCParticleBatchNode* batchNodeWithFile(const char* fileImage, unsigned int capacity = kCCParticleDefaultCapacity); /** initializes the particle system with CCTexture2D, a capacity of particles, which particle system to use */ static CCParticleBatchNode* createWithTexture(CCTexture2D *tex, unsigned int capacity = kCCParticleDefaultCapacity); diff --git a/cocos2dx/particle_nodes/CCParticleSystem.cpp b/cocos2dx/particle_nodes/CCParticleSystem.cpp index 3bc36bc19b..b30f207b94 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystem.cpp @@ -130,10 +130,10 @@ CCParticleSystem::CCParticleSystem() m_tBlendFunc.dst = CC_BLEND_DST; } // implementation CCParticleSystem -// CCParticleSystem * CCParticleSystem::particleWithFile(const char *plistFile) -// { -// return CCParticleSystem::create(plistFile); -// } +CCParticleSystem * CCParticleSystem::particleWithFile(const char *plistFile) +{ + return CCParticleSystem::create(plistFile); +} CCParticleSystem * CCParticleSystem::create(const char *plistFile) { diff --git a/cocos2dx/particle_nodes/CCParticleSystem.h b/cocos2dx/particle_nodes/CCParticleSystem.h index d469b59837..a39078a4af 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.h +++ b/cocos2dx/particle_nodes/CCParticleSystem.h @@ -359,7 +359,7 @@ public: @warning: This interface will be deprecated in future. @since v0.99.3 */ - //static CCParticleSystem * particleWithFile(const char *plistFile); + static CCParticleSystem * particleWithFile(const char *plistFile); /** creates an initializes a CCParticleSystem from a plist file. This plist files can be creted manually or with Particle Designer: diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp index 2fc1ec2526..404118c4ef 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp @@ -103,10 +103,10 @@ CCParticleSystemQuad::~CCParticleSystemQuad() } // implementation CCParticleSystemQuad -// CCParticleSystemQuad * CCParticleSystemQuad::particleWithFile(const char *plistFile) -// { -// return CCParticleSystemQuad::create(plistFile); -// } +CCParticleSystemQuad * CCParticleSystemQuad::particleWithFile(const char *plistFile) +{ + return CCParticleSystemQuad::create(plistFile); +} CCParticleSystemQuad * CCParticleSystemQuad::create(const char *plistFile) { diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.h b/cocos2dx/particle_nodes/CCParticleSystemQuad.h index 1011f47936..29d7b88e10 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.h +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.h @@ -65,7 +65,7 @@ public: This plist files can be creted manually or with Particle Designer: @warning: This interface will be deprecated in future. */ - //static CCParticleSystemQuad * particleWithFile(const char *plistFile); + static CCParticleSystemQuad * particleWithFile(const char *plistFile); /** creates an initializes a CCParticleSystemQuad from a plist file. This plist files can be creted manually or with Particle Designer: diff --git a/cocos2dx/sprite_nodes/CCAnimation.cpp b/cocos2dx/sprite_nodes/CCAnimation.cpp index 2f908fbcfb..28c1e6853f 100644 --- a/cocos2dx/sprite_nodes/CCAnimation.cpp +++ b/cocos2dx/sprite_nodes/CCAnimation.cpp @@ -81,10 +81,10 @@ CCObject* CCAnimationFrame::copyWithZone(CCZone* pZone) // implementation of CCAnimation -// CCAnimation* CCAnimation::animation(void) -// { -// return CCAnimation::create(); -// } +CCAnimation* CCAnimation::animation(void) +{ + return CCAnimation::create(); +} CCAnimation* CCAnimation::create(void) { @@ -95,10 +95,10 @@ CCAnimation* CCAnimation::create(void) return pAnimation; } -// CCAnimation* CCAnimation::animationWithSpriteFrames(CCArray *frames, float delay/* = 0.0f*/) -// { -// return CCAnimation::createWithSpriteFrames(frames, delay); -// } +CCAnimation* CCAnimation::animationWithSpriteFrames(CCArray *frames, float delay/* = 0.0f*/) +{ + return CCAnimation::createWithSpriteFrames(frames, delay); +} CCAnimation* CCAnimation::createWithSpriteFrames(CCArray *frames, float delay/* = 0.0f*/) { @@ -109,10 +109,10 @@ CCAnimation* CCAnimation::createWithSpriteFrames(CCArray *frames, float delay/* return pAnimation; } -// CCAnimation* CCAnimation::animationWithAnimationFrames(CCArray* arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops) -// { -// return CCAnimation::createWithAnimationFrames(arrayOfAnimationFrameNames, delayPerUnit, loops); -// } +CCAnimation* CCAnimation::animationWithAnimationFrames(CCArray* arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops) +{ + return CCAnimation::createWithAnimationFrames(arrayOfAnimationFrameNames, delayPerUnit, loops); +} CCAnimation* CCAnimation::createWithAnimationFrames(CCArray* arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops) { diff --git a/cocos2dx/sprite_nodes/CCAnimation.h b/cocos2dx/sprite_nodes/CCAnimation.h index 1999826eeb..c0f25a14ed 100644 --- a/cocos2dx/sprite_nodes/CCAnimation.h +++ b/cocos2dx/sprite_nodes/CCAnimation.h @@ -87,20 +87,20 @@ public: @warning: This interface will be deprecated in future. @since v0.99.5 */ - //static CCAnimation* animation(void); + static CCAnimation* animation(void); /* Creates an animation with an array of CCSpriteFrame and a delay between frames in seconds. The frames will be added with one "delay unit". @warning: This interface will be deprecated in future. @since v0.99.5 */ - //static CCAnimation* animationWithSpriteFrames(CCArray* arrayOfSpriteFrameNames, float delay = 0.0f); + static CCAnimation* animationWithSpriteFrames(CCArray* arrayOfSpriteFrameNames, float delay = 0.0f); /* Creates an animation with an array of CCAnimationFrame, the delay per units in seconds and and how many times it should be executed. @warning: This interface will be deprecated in future. @since v2.0 */ - //static CCAnimation* animationWithAnimationFrames(CCArray *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops); + static CCAnimation* animationWithAnimationFrames(CCArray *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops); /** Creates an animation @since v0.99.5 diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index 4b2ee0cc18..5ae7674ea2 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -58,10 +58,10 @@ NS_CC_BEGIN #define RENDER_IN_SUBPIXEL(__A__) ( (int)(__A__)) #endif -// CCSprite* CCSprite::spriteWithTexture(CCTexture2D *pTexture) -// { -// return CCSprite::createWithTexture(pTexture); -// } +CCSprite* CCSprite::spriteWithTexture(CCTexture2D *pTexture) +{ + return CCSprite::createWithTexture(pTexture); +} CCSprite* CCSprite::createWithTexture(CCTexture2D *pTexture) { @@ -75,10 +75,10 @@ CCSprite* CCSprite::createWithTexture(CCTexture2D *pTexture) return NULL; } -// CCSprite* CCSprite::spriteWithTexture(CCTexture2D *pTexture, const CCRect& rect) -// { -// return CCSprite::createWithTexture(pTexture, rect); -// } +CCSprite* CCSprite::spriteWithTexture(CCTexture2D *pTexture, const CCRect& rect) +{ + return CCSprite::createWithTexture(pTexture, rect); +} CCSprite* CCSprite::createWithTexture(CCTexture2D *pTexture, const CCRect& rect) { @@ -92,10 +92,10 @@ CCSprite* CCSprite::createWithTexture(CCTexture2D *pTexture, const CCRect& rect) return NULL; } -// CCSprite* CCSprite::spriteWithFile(const char *pszFileName) -// { -// CCSprite::create(pszFileName); -// } +CCSprite* CCSprite::spriteWithFile(const char *pszFileName) +{ + return CCSprite::create(pszFileName); +} CCSprite* CCSprite::create(const char *pszFileName) { @@ -109,10 +109,10 @@ CCSprite* CCSprite::create(const char *pszFileName) return NULL; } -// CCSprite* CCSprite::spriteWithFile(const char *pszFileName, const CCRect& rect) -// { -// return CCSprite::create(pszFileName, rect); -// } +CCSprite* CCSprite::spriteWithFile(const char *pszFileName, const CCRect& rect) +{ + return CCSprite::create(pszFileName, rect); +} CCSprite* CCSprite::create(const char *pszFileName, const CCRect& rect) { @@ -126,10 +126,10 @@ CCSprite* CCSprite::create(const char *pszFileName, const CCRect& rect) return NULL; } -// CCSprite* CCSprite::spriteWithSpriteFrame(CCSpriteFrame *pSpriteFrame) -// { -// return CCSprite::createWithSpriteFrame(pSpriteFrame); -// } +CCSprite* CCSprite::spriteWithSpriteFrame(CCSpriteFrame *pSpriteFrame) +{ + return CCSprite::createWithSpriteFrame(pSpriteFrame); +} CCSprite* CCSprite::createWithSpriteFrame(CCSpriteFrame *pSpriteFrame) { @@ -143,10 +143,10 @@ CCSprite* CCSprite::createWithSpriteFrame(CCSpriteFrame *pSpriteFrame) return NULL; } -// CCSprite* CCSprite::spriteWithSpriteFrameName(const char *pszSpriteFrameName) -// { -// return CCSprite::createWithSpriteFrameName(pszSpriteFrameName); -// } +CCSprite* CCSprite::spriteWithSpriteFrameName(const char *pszSpriteFrameName) +{ + return CCSprite::createWithSpriteFrameName(pszSpriteFrameName); +} CCSprite* CCSprite::createWithSpriteFrameName(const char *pszSpriteFrameName) { @@ -158,10 +158,10 @@ CCSprite* CCSprite::createWithSpriteFrameName(const char *pszSpriteFrameName) return createWithSpriteFrame(pFrame); } -// CCSprite* CCSprite::node() -// { -// return CCSprite::create(); -// } +CCSprite* CCSprite::node() +{ + return CCSprite::create(); +} CCSprite* CCSprite::create() { diff --git a/cocos2dx/sprite_nodes/CCSprite.h b/cocos2dx/sprite_nodes/CCSprite.h index 0223e1a2ae..ae7ded7499 100644 --- a/cocos2dx/sprite_nodes/CCSprite.h +++ b/cocos2dx/sprite_nodes/CCSprite.h @@ -125,13 +125,13 @@ public: The offset will be (0,0). @warning: This interface will be deprecated in future. */ - //static CCSprite* spriteWithTexture(CCTexture2D *pTexture); + static CCSprite* spriteWithTexture(CCTexture2D *pTexture); /** Creates an sprite with a texture and a rect. The offset will be (0,0). @warning: This interface will be deprecated in future. */ - //static CCSprite* spriteWithTexture(CCTexture2D *pTexture, const CCRect& rect); + static CCSprite* spriteWithTexture(CCTexture2D *pTexture, const CCRect& rect); /** Creates an sprite with a texture. The rect used will be the size of the texture. @@ -147,7 +147,7 @@ public: /** Creates an sprite with an sprite frame. @warning: This interface will be deprecated in future. */ - // static CCSprite* spriteWithSpriteFrame(CCSpriteFrame *pSpriteFrame); + static CCSprite* spriteWithSpriteFrame(CCSpriteFrame *pSpriteFrame); /** Creates an sprite with an sprite frame name. An CCSpriteFrame will be fetched from the CCSpriteFrameCache by name. @@ -155,7 +155,7 @@ public: @warning: This interface will be deprecated in future. @since v0.9 */ - //static CCSprite* spriteWithSpriteFrameName(const char *pszSpriteFrameName); + static CCSprite* spriteWithSpriteFrameName(const char *pszSpriteFrameName); /** Creates an sprite with an sprite frame. */ static CCSprite* createWithSpriteFrame(CCSpriteFrame *pSpriteFrame); @@ -172,13 +172,13 @@ public: @warning: This interface will be deprecated in future. The offset will be (0,0). */ - //static CCSprite* spriteWithFile(const char *pszFileName); + static CCSprite* spriteWithFile(const char *pszFileName); /** Creates an sprite with an image filename and a rect. The offset will be (0,0). @warning: This interface will be deprecated in future. */ - //static CCSprite* spriteWithFile(const char *pszFileName, const CCRect& rect); + static CCSprite* spriteWithFile(const char *pszFileName, const CCRect& rect); /** Creates an sprite with an image filename. The rect used will be the size of the image. @@ -194,7 +194,7 @@ public: /** Creates an sprite. @warning: This interface will be deprecated in future. */ - //static CCSprite* node(); + static CCSprite* node(); /** Creates an sprite. */ static CCSprite* create(); diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp index bb6a4191c1..57a35358cc 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp @@ -46,10 +46,10 @@ NS_CC_BEGIN * creation with CCTexture2D */ -// CCSpriteBatchNode* CCSpriteBatchNode::batchNodeWithTexture(CCTexture2D* tex, unsigned int capacity/* = kDefaultSpriteBatchCapacity*/) -// { -// return CCSpriteBatchNode::createWithTexture(tex, capacity); -// } +CCSpriteBatchNode* CCSpriteBatchNode::batchNodeWithTexture(CCTexture2D* tex, unsigned int capacity/* = kDefaultSpriteBatchCapacity*/) +{ + return CCSpriteBatchNode::createWithTexture(tex, capacity); +} CCSpriteBatchNode* CCSpriteBatchNode::createWithTexture(CCTexture2D* tex, unsigned int capacity/* = kDefaultSpriteBatchCapacity*/) { @@ -63,10 +63,10 @@ CCSpriteBatchNode* CCSpriteBatchNode::createWithTexture(CCTexture2D* tex, unsign /* * creation with File Image */ -// CCSpriteBatchNode* CCSpriteBatchNode::batchNodeWithFile(const char *fileImage, unsigned int capacity/* = kDefaultSpriteBatchCapacity*/) -// { -// return CCSpriteBatchNode::create(fileImage, capacity); -// } +CCSpriteBatchNode* CCSpriteBatchNode::batchNodeWithFile(const char *fileImage, unsigned int capacity/* = kDefaultSpriteBatchCapacity*/) +{ + return CCSpriteBatchNode::create(fileImage, capacity); +} CCSpriteBatchNode* CCSpriteBatchNode::create(const char *fileImage, unsigned int capacity/* = kDefaultSpriteBatchCapacity*/) { diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.h b/cocos2dx/sprite_nodes/CCSpriteBatchNode.h index 22d57b7ef4..c2dbd03717 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.h +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.h @@ -80,14 +80,14 @@ public: The capacity will be increased in 33% in runtime if it run out of space. @warning: This interface will be deprecated in future. */ - //static CCSpriteBatchNode* batchNodeWithTexture(CCTexture2D* tex, unsigned int capacity = kDefaultSpriteBatchCapacity); + static CCSpriteBatchNode* batchNodeWithTexture(CCTexture2D* tex, unsigned int capacity = kDefaultSpriteBatchCapacity); /** creates a CCSpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and capacity of children. The capacity will be increased in 33% in runtime if it run out of space. The file will be loaded using the TextureMgr. @warning: This interface will be deprecated in future. */ - //static CCSpriteBatchNode* batchNodeWithFile(const char* fileImage, unsigned int capacity = kDefaultSpriteBatchCapacity); + static CCSpriteBatchNode* batchNodeWithFile(const char* fileImage, unsigned int capacity = kDefaultSpriteBatchCapacity); /** creates a CCSpriteBatchNode with a texture2d and capacity of children. The capacity will be increased in 33% in runtime if it run out of space. diff --git a/cocos2dx/sprite_nodes/CCSpriteFrame.cpp b/cocos2dx/sprite_nodes/CCSpriteFrame.cpp index de5709082a..4f1ab52cb9 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrame.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrame.cpp @@ -31,10 +31,10 @@ NS_CC_BEGIN // implementation of CCSpriteFrame -// CCSpriteFrame* CCSpriteFrame::frameWithTexture(CCTexture2D *pobTexture, const CCRect& rect) -// { -// return CCSpriteFrame::create(pobTexture, rect); -// } +CCSpriteFrame* CCSpriteFrame::frameWithTexture(CCTexture2D *pobTexture, const CCRect& rect) +{ + return CCSpriteFrame::create(pobTexture, rect); +} CCSpriteFrame* CCSpriteFrame::create(CCTexture2D *pobTexture, const CCRect& rect) { @@ -45,10 +45,10 @@ CCSpriteFrame* CCSpriteFrame::create(CCTexture2D *pobTexture, const CCRect& rect return pSpriteFrame; } -// CCSpriteFrame* CCSpriteFrame::frameWithTextureFilename(const char* filename, const CCRect& rect) -// { -// return createWithTextureFilename(filename, rect); -// } +CCSpriteFrame* CCSpriteFrame::frameWithTextureFilename(const char* filename, const CCRect& rect) +{ + return createWithTextureFilename(filename, rect); +} CCSpriteFrame* CCSpriteFrame::createWithTextureFilename(const char* filename, const CCRect& rect) { @@ -59,10 +59,10 @@ CCSpriteFrame* CCSpriteFrame::createWithTextureFilename(const char* filename, co return pSpriteFrame; } -// CCSpriteFrame* CCSpriteFrame::frameWithTexture(CCTexture2D* pobTexture, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize) -// { -// return CCSpriteFrame::create(pobTexture, rect, rotated, offset, originalSize); -// } +CCSpriteFrame* CCSpriteFrame::frameWithTexture(CCTexture2D* pobTexture, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize) +{ + return CCSpriteFrame::create(pobTexture, rect, rotated, offset, originalSize); +} CCSpriteFrame* CCSpriteFrame::create(CCTexture2D* pobTexture, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize) { @@ -73,10 +73,10 @@ CCSpriteFrame* CCSpriteFrame::create(CCTexture2D* pobTexture, const CCRect& rect return pSpriteFrame; } -// CCSpriteFrame* CCSpriteFrame::frameWithTextureFilename(const char* filename, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize) -// { -// return CCSpriteFrame::createWithTextureFilename(filename, rect, rotated, offset, originalSize); -// } +CCSpriteFrame* CCSpriteFrame::frameWithTextureFilename(const char* filename, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize) +{ + return CCSpriteFrame::createWithTextureFilename(filename, rect, rotated, offset, originalSize); +} CCSpriteFrame* CCSpriteFrame::createWithTextureFilename(const char* filename, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize) { diff --git a/cocos2dx/sprite_nodes/CCSpriteFrame.h b/cocos2dx/sprite_nodes/CCSpriteFrame.h index 559bd7e89e..9d5b310e60 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrame.h +++ b/cocos2dx/sprite_nodes/CCSpriteFrame.h @@ -94,25 +94,25 @@ public: @warning: This interface will be deprecated in future. It is assumed that the frame was not trimmed. */ - //static CCSpriteFrame* frameWithTexture(CCTexture2D* pobTexture, const CCRect& rect); + static CCSpriteFrame* frameWithTexture(CCTexture2D* pobTexture, const CCRect& rect); /** Create a CCSpriteFrame with a texture filename, rect in points. It is assumed that the frame was not trimmed. @warning: This interface will be deprecated in future. */ - //static CCSpriteFrame* frameWithTextureFilename(const char* filename, const CCRect& rect); + static CCSpriteFrame* frameWithTextureFilename(const char* filename, const CCRect& rect); /** Create a CCSpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. The originalSize is the size in points of the frame before being trimmed. @warning: This interface will be deprecated in future. */ - //static CCSpriteFrame* frameWithTexture(CCTexture2D* pobTexture, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize); + static CCSpriteFrame* frameWithTexture(CCTexture2D* pobTexture, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize); /** Create a CCSpriteFrame with a texture filename, rect, rotated, offset and originalSize in pixels. The originalSize is the size in pixels of the frame before being trimmed. @warning: This interface will be deprecated in future. */ - //static CCSpriteFrame* frameWithTextureFilename(const char* filename, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize); + static CCSpriteFrame* frameWithTextureFilename(const char* filename, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize); /** Create a CCSpriteFrame with a texture, rect in points. It is assumed that the frame was not trimmed. diff --git a/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.cpp b/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.cpp index c119a5735f..2d5fb74957 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.cpp @@ -65,10 +65,10 @@ CCParallaxNode::~CCParallaxNode() } } -// CCParallaxNode * CCParallaxNode::node() -// { -// return CCParallaxNode::create(); -// } +CCParallaxNode * CCParallaxNode::node() +{ + return CCParallaxNode::create(); +} CCParallaxNode * CCParallaxNode::create() { diff --git a/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h b/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h index dff3035a75..b164933f0e 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h +++ b/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h @@ -51,7 +51,7 @@ public: CCParallaxNode(); virtual ~CCParallaxNode(); //@warning: This interface will be deprecated in future. - //static CCParallaxNode * node(); + static CCParallaxNode * node(); static CCParallaxNode * create(); virtual void addChild(CCNode * child, unsigned int z, const CCPoint& parallaxRatio, const CCPoint& positionOffset); // super methods diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp index cf962bd06b..898840cde4 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp @@ -38,10 +38,10 @@ NS_CC_BEGIN // CCTMXLayer - init & alloc & dealloc -// CCTMXLayer * CCTMXLayer::layerWithTilesetInfo(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo) -// { -// return CCTMXLayer::create(tilesetInfo, layerInfo, mapInfo); -// } +CCTMXLayer * CCTMXLayer::layerWithTilesetInfo(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo) +{ + return CCTMXLayer::create(tilesetInfo, layerInfo, mapInfo); +} CCTMXLayer * CCTMXLayer::create(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo) { diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h index c65cb3cea2..d232dca5f1 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h @@ -86,7 +86,7 @@ public: /** creates a CCTMXLayer with an tileset info, a layer info and a map info @warning: This interface will be deprecated in future. */ - //static CCTMXLayer * layerWithTilesetInfo(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo); + static CCTMXLayer * layerWithTilesetInfo(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo); /** creates a CCTMXLayer with an tileset info, a layer info and a map info */ static CCTMXLayer * create(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo); diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp index 5e8340d941..2920f6cec5 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp @@ -32,10 +32,10 @@ THE SOFTWARE. NS_CC_BEGIN // implementation CCTMXTiledMap -// CCTMXTiledMap * CCTMXTiledMap::tiledMapWithTMXFile(const char *tmxFile) -// { -// return CCTMXTiledMap::create(tmxFile); -// } +CCTMXTiledMap * CCTMXTiledMap::tiledMapWithTMXFile(const char *tmxFile) +{ + return CCTMXTiledMap::create(tmxFile); +} CCTMXTiledMap * CCTMXTiledMap::create(const char *tmxFile) { @@ -49,10 +49,10 @@ CCTMXTiledMap * CCTMXTiledMap::create(const char *tmxFile) return NULL; } -// CCTMXTiledMap* CCTMXTiledMap::tiledMapWithXML(const char* tmxString, const char* resourcePath) -// { -// return CCTMXTiledMap::create(tmxString, resourcePath); -// } +CCTMXTiledMap* CCTMXTiledMap::tiledMapWithXML(const char* tmxString, const char* resourcePath) +{ + return CCTMXTiledMap::create(tmxString, resourcePath); +} CCTMXTiledMap* CCTMXTiledMap::create(const char* tmxString, const char* resourcePath) { diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h index 1186ab10b5..a8730b9fa0 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h @@ -119,12 +119,12 @@ public: /** creates a TMX Tiled Map with a TMX file. @warning: This interface will be deprecated in future. */ - //static CCTMXTiledMap* tiledMapWithTMXFile(const char *tmxFile); + static CCTMXTiledMap* tiledMapWithTMXFile(const char *tmxFile); /** initializes a TMX Tiled Map with a TMX formatted XML string and a path to TMX resources @warning: This interface will be deprecated in future. */ - //static CCTMXTiledMap* tiledMapWithXML(const char* tmxString, const char* resourcePath); + static CCTMXTiledMap* tiledMapWithXML(const char* tmxString, const char* resourcePath); /** creates a TMX Tiled Map with a TMX file.*/ static CCTMXTiledMap* create(const char *tmxFile); diff --git a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp index a14274fc3f..7fb8899ca0 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp @@ -36,10 +36,10 @@ NS_CC_BEGIN // implementation CCTileMapAtlas -// CCTileMapAtlas * CCTileMapAtlas::tileMapAtlasWithTileFile(const char *tile, const char *mapFile, int tileWidth, int tileHeight) -// { -// return CCTileMapAtlas::create(tile, mapFile, tileWidth, tileHeight); -// } +CCTileMapAtlas * CCTileMapAtlas::tileMapAtlasWithTileFile(const char *tile, const char *mapFile, int tileWidth, int tileHeight) +{ + return CCTileMapAtlas::create(tile, mapFile, tileWidth, tileHeight); +} CCTileMapAtlas * CCTileMapAtlas::create(const char *tile, const char *mapFile, int tileWidth, int tileHeight) { diff --git a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h index e042bba63e..e70e3979d9 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h @@ -59,7 +59,7 @@ public: The tile file will be loaded using the TextureMgr. @warning: This interface will be deprecated in future. */ - //static CCTileMapAtlas * tileMapAtlasWithTileFile(const char *tile, const char *mapFile, int tileWidth, int tileHeight); + static CCTileMapAtlas * tileMapAtlasWithTileFile(const char *tile, const char *mapFile, int tileWidth, int tileHeight); /** creates a CCTileMap with a tile file (atlas) with a map file and the width and height of each tile in points. The tile file will be loaded using the TextureMgr. From 740e28dbc12f344cfec7b9425f146994c41195d0 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 14 Jun 2012 17:29:23 +0800 Subject: [PATCH 166/257] issue #1324: Uncommented old interfaces. --- cocos2dx/actions/CCActionCatmullRom.cpp | 42 ++------- .../CCTransition.cpp | 8 +- cocos2dx/particle_nodes/CCParticleExamples.h | 88 +++++++++---------- 3 files changed, 56 insertions(+), 82 deletions(-) diff --git a/cocos2dx/actions/CCActionCatmullRom.cpp b/cocos2dx/actions/CCActionCatmullRom.cpp index abce168a15..4614fba02b 100644 --- a/cocos2dx/actions/CCActionCatmullRom.cpp +++ b/cocos2dx/actions/CCActionCatmullRom.cpp @@ -405,23 +405,10 @@ void CCCardinalSplineBy::startWithTarget(cocos2d::CCNode *pTarget) /* CCCatmullRomTo */ -// CCCatmullRomTo* CCCatmullRomTo::actionWithDuration(float dt, cocos2d::CCPointArray *points) -// { -// CCCatmullRomTo *ret = new CCCatmullRomTo(); -// if (ret) -// { -// if (ret->initWithDuration(dt, points)) -// { -// ret->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(ret); -// } -// } -// -// return ret; -// } +CCCatmullRomTo* CCCatmullRomTo::actionWithDuration(float dt, cocos2d::CCPointArray *points) +{ + return CCCatmullRomTo::create(dt, points); +} CCCatmullRomTo* CCCatmullRomTo::create(float dt, cocos2d::CCPointArray *points) { @@ -453,23 +440,10 @@ bool CCCatmullRomTo::initWithDuration(float dt, cocos2d::CCPointArray *points) /* CCCatmullRomBy */ -// CCCatmullRomBy* CCCatmullRomBy::actionWithDuration(float dt, cocos2d::CCPointArray *points) -// { -// CCCatmullRomBy *ret = new CCCatmullRomBy(); -// if (ret) -// { -// if (ret->initWithDuration(dt, points)) -// { -// ret->autorelease(); -// } -// else -// { -// CC_SAFE_RELEASE_NULL(ret); -// } -// } -// -// return ret; -// } +CCCatmullRomBy* CCCatmullRomBy::actionWithDuration(float dt, cocos2d::CCPointArray *points) +{ + return CCCatmullRomBy::create(dt, points); +} CCCatmullRomBy* CCCatmullRomBy::create(float dt, cocos2d::CCPointArray *points) { diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp index 555923f233..8c2d266717 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp @@ -788,10 +788,10 @@ void CCTransitionFlipAngular::onEnter() m_pOutScene->runAction(outA); } -// CCTransitionFlipAngular* CCTransitionFlipAngular::transitionWithDuration(float t, CCScene* s, tOrientation o) -// { -// return CCTransitionFlipAngular::create(t, s, o); -// } +CCTransitionFlipAngular* CCTransitionFlipAngular::transitionWithDuration(float t, CCScene* s, tOrientation o) +{ + return CCTransitionFlipAngular::create(t, s, o); +} CCTransitionFlipAngular* CCTransitionFlipAngular::create(float t, CCScene* s, tOrientation o) { diff --git a/cocos2dx/particle_nodes/CCParticleExamples.h b/cocos2dx/particle_nodes/CCParticleExamples.h index ab8cfded24..d043c255a6 100644 --- a/cocos2dx/particle_nodes/CCParticleExamples.h +++ b/cocos2dx/particle_nodes/CCParticleExamples.h @@ -39,10 +39,10 @@ public: virtual ~CCParticleFire(){} bool init(){ return initWithTotalParticles(250); } virtual bool initWithTotalParticles(unsigned int numberOfParticles); -// static CCParticleFire * node() -// { -// return create(); -// } + static CCParticleFire * node() + { + return create(); + } static CCParticleFire * create() { @@ -65,10 +65,10 @@ public: virtual ~CCParticleFireworks(){} bool init(){ return initWithTotalParticles(1500); } virtual bool initWithTotalParticles(unsigned int numberOfParticles); -// static CCParticleFireworks * node() -// { -// return create(); -// } + static CCParticleFireworks * node() + { + return create(); + } static CCParticleFireworks * create() { @@ -91,10 +91,10 @@ public: virtual ~CCParticleSun(){} bool init(){ return initWithTotalParticles(350); } virtual bool initWithTotalParticles(unsigned int numberOfParticles); -// static CCParticleSun * node() -// { -// return create(); -// } + static CCParticleSun * node() + { + return create(); + } static CCParticleSun * create() { CCParticleSun *pRet = new CCParticleSun(); @@ -116,10 +116,10 @@ public: virtual ~CCParticleGalaxy(){} bool init(){ return initWithTotalParticles(200); } virtual bool initWithTotalParticles(unsigned int numberOfParticles); -// static CCParticleGalaxy * node() -// { -// return create(); -// } + static CCParticleGalaxy * node() + { + return create(); + } static CCParticleGalaxy * create() { @@ -142,10 +142,10 @@ public: virtual ~CCParticleFlower(){} bool init(){ return initWithTotalParticles(250); } virtual bool initWithTotalParticles(unsigned int numberOfParticles); -// static CCParticleFlower * node() -// { -// return create(); -// } + static CCParticleFlower * node() + { + return create(); + } static CCParticleFlower * create() { @@ -168,10 +168,10 @@ public: virtual ~CCParticleMeteor(){} bool init(){ return initWithTotalParticles(150); } virtual bool initWithTotalParticles(unsigned int numberOfParticles); -// static CCParticleMeteor * node() -// { -// return create(); -// } + static CCParticleMeteor * node() + { + return create(); + } static CCParticleMeteor * create() { CCParticleMeteor *pRet = new CCParticleMeteor(); @@ -193,10 +193,10 @@ public: virtual ~CCParticleSpiral(){} bool init(){ return initWithTotalParticles(500); } virtual bool initWithTotalParticles(unsigned int numberOfParticles); -// static CCParticleSpiral * node() -// { -// return create(); -// } + static CCParticleSpiral * node() + { + return create(); + } static CCParticleSpiral * create() { CCParticleSpiral *pRet = new CCParticleSpiral(); @@ -218,10 +218,10 @@ public: virtual ~CCParticleExplosion(){} bool init(){ return initWithTotalParticles(700); } virtual bool initWithTotalParticles(unsigned int numberOfParticles); -// static CCParticleExplosion * node() -// { -// return create(); -// } + static CCParticleExplosion * node() + { + return create(); + } static CCParticleExplosion * create() { CCParticleExplosion *pRet = new CCParticleExplosion(); @@ -243,10 +243,10 @@ public: virtual ~CCParticleSmoke(){} bool init(){ return initWithTotalParticles(200); } virtual bool initWithTotalParticles(unsigned int numberOfParticles); -// static CCParticleSmoke * node() -// { -// return create(); -// } + static CCParticleSmoke * node() + { + return create(); + } static CCParticleSmoke * create() { CCParticleSmoke *pRet = new CCParticleSmoke(); @@ -268,10 +268,10 @@ public: virtual ~CCParticleSnow(){} bool init(){ return initWithTotalParticles(700); } virtual bool initWithTotalParticles(unsigned int numberOfParticles); -// static CCParticleSnow * node() -// { -// return create(); -// } + static CCParticleSnow * node() + { + return create(); + } static CCParticleSnow * create() { @@ -294,10 +294,10 @@ public: virtual ~CCParticleRain(){} bool init(){ return initWithTotalParticles(1000); } virtual bool initWithTotalParticles(unsigned int numberOfParticles); -// static CCParticleRain * node() -// { -// return create(); -// } + static CCParticleRain * node() + { + return create(); + } static CCParticleRain * create() { CCParticleRain *pRet = new CCParticleRain(); From 052d8ea931d987bf73c15e07197e0fed47156992 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 14 Jun 2012 18:32:44 +0800 Subject: [PATCH 167/257] fixed #1324: Added some create methods. Compiling successfully on win32 by vs2008. --- cocos2dx/extensions/CCBReader/CCBFileLoader.h | 2 +- .../CCBReader/CCBMemberVariableAssigner.h | 2 +- cocos2dx/extensions/CCBReader/CCBReader.cpp | 5 +- .../CCBReader/CCBSelectorResolver.h | 2 +- .../CCBReader/CCControlButtonLoader.h | 2 +- .../extensions/CCBReader/CCControlLoader.h | 2 +- .../CCBReader/CCLabelBMFontLoader.h | 2 +- .../extensions/CCBReader/CCLabelTTFLoader.h | 2 +- .../extensions/CCBReader/CCLayerColorLoader.h | 2 +- .../CCBReader/CCLayerGradientLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCLayerLoader.h | 2 +- .../CCBReader/CCMenuItemImageLoader.h | 2 +- .../extensions/CCBReader/CCMenuItemLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCMenuLoader.h | 2 +- .../CCBReader/CCNodeLoaderListener.h | 2 +- .../CCBReader/CCParticleSystemQuadLoader.h | 2 +- .../CCBReader/CCScale9SpriteLoader.h | 2 +- .../extensions/CCBReader/CCSpriteLoader.h | 2 +- .../CCControlColourPicker.cpp | 4 +- .../CCControlColourPicker.h | 4 +- cocos2dx/label_nodes/CCLabelBMFont.cpp | 4 + cocos2dx/label_nodes/CCLabelBMFont.h | 5 + cocos2dx/label_nodes/CCLabelTTF.cpp | 5 + cocos2dx/label_nodes/CCLabelTTF.h | 4 + .../layers_scenes_transitions_nodes/CCLayer.h | 14 +- cocos2dx/menu_nodes/CCMenuItem.cpp | 6 +- cocos2dx/menu_nodes/CCMenuItem.h | 5 + .../particle_nodes/CCParticleSystemQuad.cpp | 7 +- .../particle_nodes/CCParticleSystemQuad.h | 3 + cocos2dx/proj.win32/cocos2d-win32.vcproj | 138 +++++++++++++++++- tests/proj.win32/test.win32.vcproj | 44 +++++- .../CCControlButtonTest.cpp | 16 +- .../CCControlButtonTest/CCControlButtonTest.h | 16 +- .../CCControlColourPickerTest.cpp | 4 +- .../CCControlColourPickerTest.h | 2 +- .../CCControlSliderTest.cpp | 2 +- .../CCControlSliderTest/CCControlSliderTest.h | 2 +- .../CCControlSwitchTest.cpp | 4 +- .../CCControlSwitchTest/CCControlSwitchTest.h | 2 +- tests/tests/SchedulerTest/SchedulerTest.cpp | 4 +- tests/tests/SchedulerTest/SchedulerTest.h | 4 +- tests/tests/ShaderTest/ShaderTest.cpp | 2 +- tests/tests/ShaderTest/ShaderTest.h | 2 +- 43 files changed, 279 insertions(+), 63 deletions(-) diff --git a/cocos2dx/extensions/CCBReader/CCBFileLoader.h b/cocos2dx/extensions/CCBReader/CCBFileLoader.h index 5e644d65d6..0870451dd9 100644 --- a/cocos2dx/extensions/CCBReader/CCBFileLoader.h +++ b/cocos2dx/extensions/CCBReader/CCBFileLoader.h @@ -8,7 +8,7 @@ NS_CC_EXT_BEGIN /* Forward declaration. */ class CCBReader; -class CCBFileLoader : public CCNodeLoader { +class CC_DLL CCBFileLoader : public CCNodeLoader { public: STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCBFileLoader, loader); diff --git a/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h b/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h index 0ddc70f0bf..78658e5582 100644 --- a/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h +++ b/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h @@ -5,7 +5,7 @@ NS_CC_EXT_BEGIN -class CCBMemberVariableAssigner { +class CC_DLL CCBMemberVariableAssigner { public: virtual bool onAssignCCBMemberVariable(CCObject * pTarget, const char * pMemberVariableName, CCNode * pNode) = 0; }; diff --git a/cocos2dx/extensions/CCBReader/CCBReader.cpp b/cocos2dx/extensions/CCBReader/CCBReader.cpp index 7f8ce3a891..bb9300a668 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader.cpp @@ -92,12 +92,15 @@ CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBRootPath, const char CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize) { this->mCCBRootPath = pCCBRootPath; - char ccbFullFilePath[strlen(pCCBRootPath) + strlen(pCCBFileName) + 1]; + char* ccbFullFilePath = (char*)malloc(strlen(pCCBRootPath) + strlen(pCCBFileName) + 1); + strcpy(ccbFullFilePath, pCCBRootPath); strcat(ccbFullFilePath, pCCBFileName); const char * path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(ccbFullFilePath); + CC_SAFE_FREE(ccbFullFilePath); + unsigned long size = 0; this->mBytes = CCFileUtils::sharedFileUtils()->getFileData(path, "rb", &size); diff --git a/cocos2dx/extensions/CCBReader/CCBSelectorResolver.h b/cocos2dx/extensions/CCBReader/CCBSelectorResolver.h index a29faec091..ff67a84054 100644 --- a/cocos2dx/extensions/CCBReader/CCBSelectorResolver.h +++ b/cocos2dx/extensions/CCBReader/CCBSelectorResolver.h @@ -5,7 +5,7 @@ NS_CC_EXT_BEGIN -class CCBSelectorResolver { +class CC_DLL CCBSelectorResolver { public: virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(CCObject * pTarget, const char * pSelectorName) = 0; virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(CCObject * pTarget, const char * pSelectorName) = 0; diff --git a/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h b/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h index 91ca8c00d3..7baea69fb7 100644 --- a/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h +++ b/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h @@ -8,7 +8,7 @@ NS_CC_EXT_BEGIN /* Forward declaration. */ class CCBReader; -class CCControlButtonLoader : public CCControlLoader { +class CC_DLL CCControlButtonLoader : public CCControlLoader { public: STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCControlButtonLoader, loader); diff --git a/cocos2dx/extensions/CCBReader/CCControlLoader.h b/cocos2dx/extensions/CCBReader/CCControlLoader.h index 4638cf5ac4..07bb23c23e 100644 --- a/cocos2dx/extensions/CCBReader/CCControlLoader.h +++ b/cocos2dx/extensions/CCBReader/CCControlLoader.h @@ -8,7 +8,7 @@ NS_CC_EXT_BEGIN /* Forward declaration. */ class CCBReader; -class CCControlLoader : public CCNodeLoader { +class CC_DLL CCControlLoader : public CCNodeLoader { protected: virtual CCControl * createCCNode(CCNode *, CCBReader *) = 0; diff --git a/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h b/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h index 582b11beb5..659ff28ca9 100644 --- a/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h @@ -8,7 +8,7 @@ NS_CC_EXT_BEGIN /* Forward declaration. */ class CCBReader; -class CCLabelBMFontLoader : public CCNodeLoader { +class CC_DLL CCLabelBMFontLoader : public CCNodeLoader { public: STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLabelBMFontLoader, loader); diff --git a/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h b/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h index 04ee0bc641..aa406d7cb4 100644 --- a/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h @@ -8,7 +8,7 @@ NS_CC_EXT_BEGIN /* Forward declaration. */ class CCBReader; -class CCLabelTTFLoader : public CCNodeLoader { +class CC_DLL CCLabelTTFLoader : public CCNodeLoader { public: STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLabelTTFLoader, loader); diff --git a/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h b/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h index 8efd9d872a..ce5d36ae4f 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h @@ -8,7 +8,7 @@ NS_CC_EXT_BEGIN /* Forward declaration. */ class CCBReader; -class CCLayerColorLoader : public CCLayerLoader { +class CC_DLL CCLayerColorLoader : public CCLayerLoader { public: STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerColorLoader, loader); protected: diff --git a/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h b/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h index f515a312dc..78d2033e2c 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h @@ -8,7 +8,7 @@ NS_CC_EXT_BEGIN /* Forward declaration. */ class CCBReader; -class CCLayerGradientLoader : public CCLayerLoader { +class CC_DLL CCLayerGradientLoader : public CCLayerLoader { public: STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerGradientLoader, loader); diff --git a/cocos2dx/extensions/CCBReader/CCLayerLoader.h b/cocos2dx/extensions/CCBReader/CCLayerLoader.h index b0277fa95b..49ffa9b095 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLayerLoader.h @@ -8,7 +8,7 @@ NS_CC_EXT_BEGIN /* Forward declaration. */ class CCBReader; -class CCLayerLoader : public CCNodeLoader { +class CC_DLL CCLayerLoader : public CCNodeLoader { public: STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerLoader, loader); diff --git a/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h b/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h index 756474d880..e452726302 100644 --- a/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h +++ b/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h @@ -8,7 +8,7 @@ NS_CC_EXT_BEGIN /* Forward declaration. */ class CCBReader; -class CCMenuItemImageLoader : public CCMenuItemLoader { +class CC_DLL CCMenuItemImageLoader : public CCMenuItemLoader { public: STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCMenuItemImageLoader, loader); diff --git a/cocos2dx/extensions/CCBReader/CCMenuItemLoader.h b/cocos2dx/extensions/CCBReader/CCMenuItemLoader.h index e7ff8ff9a5..16030aeba7 100644 --- a/cocos2dx/extensions/CCBReader/CCMenuItemLoader.h +++ b/cocos2dx/extensions/CCBReader/CCMenuItemLoader.h @@ -8,7 +8,7 @@ NS_CC_EXT_BEGIN /* Forward declaration. */ class CCBReader; -class CCMenuItemLoader : public CCNodeLoader { +class CC_DLL CCMenuItemLoader : public CCNodeLoader { protected: virtual CCMenuItem * createCCNode(CCNode *, CCBReader *) = 0; diff --git a/cocos2dx/extensions/CCBReader/CCMenuLoader.h b/cocos2dx/extensions/CCBReader/CCMenuLoader.h index 333c781993..c98b43ca35 100644 --- a/cocos2dx/extensions/CCBReader/CCMenuLoader.h +++ b/cocos2dx/extensions/CCBReader/CCMenuLoader.h @@ -8,7 +8,7 @@ NS_CC_EXT_BEGIN /* Forward declaration. */ class CCBReader; -class CCMenuLoader : public CCLayerLoader { +class CC_DLL CCMenuLoader : public CCLayerLoader { public: STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCMenuLoader, loader); diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoaderListener.h b/cocos2dx/extensions/CCBReader/CCNodeLoaderListener.h index 16e1c216f6..a7730c581b 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoaderListener.h +++ b/cocos2dx/extensions/CCBReader/CCNodeLoaderListener.h @@ -5,7 +5,7 @@ NS_CC_EXT_BEGIN -class CCNodeLoaderListener { +class CC_DLL CCNodeLoaderListener { public: virtual void onNodeLoaded(CCNode * pNode, CCNodeLoader * pNodeLoader) = 0; }; diff --git a/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h b/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h index c2687b3865..e2c6fdfe68 100644 --- a/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h +++ b/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h @@ -8,7 +8,7 @@ NS_CC_EXT_BEGIN /* Forward declaration. */ class CCBReader; -class CCParticleSystemQuadLoader : public CCNodeLoader { +class CC_DLL CCParticleSystemQuadLoader : public CCNodeLoader { public: STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCParticleSystemQuadLoader, loader); diff --git a/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h b/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h index 4dd747f622..0a2bc8a667 100644 --- a/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h +++ b/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h @@ -8,7 +8,7 @@ NS_CC_EXT_BEGIN /* Forward declaration. */ class CCBReader; -class CCScale9SpriteLoader : public CCNodeLoader { +class CC_DLL CCScale9SpriteLoader : public CCNodeLoader { public: STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCScale9SpriteLoader, loader); diff --git a/cocos2dx/extensions/CCBReader/CCSpriteLoader.h b/cocos2dx/extensions/CCBReader/CCSpriteLoader.h index 65caa1a007..2e54247a67 100644 --- a/cocos2dx/extensions/CCBReader/CCSpriteLoader.h +++ b/cocos2dx/extensions/CCBReader/CCSpriteLoader.h @@ -8,7 +8,7 @@ NS_CC_EXT_BEGIN /* Forward declaration. */ class CCBReader; -class CCSpriteLoader : public CCNodeLoader { +class CC_DLL CCSpriteLoader : public CCNodeLoader { public: STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCSpriteLoader, loader); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp b/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp index 081c34b551..c0192c43dd 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp @@ -130,7 +130,7 @@ void CCControlColourPicker::updateHueAndControlPicker() } -void CCControlColourPicker::hueSliderValueChanged(CCObject * sender) +void CCControlColourPicker::hueSliderValueChanged(CCObject * sender, CCControlEvent controlEvent) { m_hsv.h = ((CCControlHuePicker*)sender)->getHue(); @@ -143,7 +143,7 @@ void CCControlColourPicker::hueSliderValueChanged(CCObject * sender) updateControlPicker(); } -void CCControlColourPicker::colourSliderValueChanged(CCObject * sender) +void CCControlColourPicker::colourSliderValueChanged(CCObject * sender, CCControlEvent controlEvent) { m_hsv.s=((CCControlSaturationBrightnessPicker*)sender)->getSaturation(); m_hsv.v=((CCControlSaturationBrightnessPicker*)sender)->getBrightness(); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.h b/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.h index 66b3cb0eec..60fe18d5ee 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.h @@ -59,8 +59,8 @@ public: virtual bool init(); //virtual ~CCControlColourPicker(); - void hueSliderValueChanged(CCObject * sender); - void colourSliderValueChanged(CCObject * sender); + void hueSliderValueChanged(CCObject * sender, CCControlEvent controlEvent); + void colourSliderValueChanged(CCObject * sender, CCControlEvent controlEvent); protected: void updateControlPicker(); diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index 1f7c681b1e..adc0c48eaf 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -718,6 +718,10 @@ void CCLabelBMFont::purgeCachedData() FNTConfigRemoveCache(); } +CCLabelBMFont * CCLabelBMFont::node() { return CCLabelBMFont::create(); } + +CCLabelBMFont * CCLabelBMFont::create() { CCLabelBMFont * pRet = new CCLabelBMFont(); if (pRet && pRet->init()) { pRet->autorelease(); return pRet; } CC_SAFE_DELETE(pRet); return NULL; } + CCLabelBMFont *CCLabelBMFont::labelWithString(const char *str, const char *fntFile, float width/* = kCCLabelAutomaticWidth*/, CCTextAlignment alignment/* = kCCTextAlignmentLeft*/, CCPoint imageOffset/* = CCPointZero*/) { return CCLabelBMFont::create(str, fntFile, width, alignment, imageOffset); diff --git a/cocos2dx/label_nodes/CCLabelBMFont.h b/cocos2dx/label_nodes/CCLabelBMFont.h index 0c28322645..b0e0f5eb1d 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.h +++ b/cocos2dx/label_nodes/CCLabelBMFont.h @@ -201,9 +201,14 @@ public: static CCLabelBMFont * create(const char *str, const char *fntFile, float width = kCCLabelAutomaticWidth, CCTextAlignment alignment = kCCTextAlignmentLeft, CCPoint imageOffset = CCPointZero); /** Creates an label. + @warning: This interface will be deprecated in future. */ static CCLabelBMFont * node(); + /** Creates an label. + */ + static CCLabelBMFont * create(); + bool init(); /** init a bitmap font altas with an initial string and the FNT file */ bool initWithString(const char *str, const char *fntFile, float width = kCCLabelAutomaticWidth, CCTextAlignment alignment = kCCTextAlignmentLeft, CCPoint imageOffset = CCPointZero); diff --git a/cocos2dx/label_nodes/CCLabelTTF.cpp b/cocos2dx/label_nodes/CCLabelTTF.cpp index 3ea6555b0e..0fa03771bd 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.cpp +++ b/cocos2dx/label_nodes/CCLabelTTF.cpp @@ -54,6 +54,11 @@ CCLabelTTF::~CCLabelTTF() } CCLabelTTF * CCLabelTTF::node() +{ + return CCLabelTTF::create(); +} + +CCLabelTTF * CCLabelTTF::create() { CCLabelTTF * pRet = new CCLabelTTF(); if (pRet && pRet->init()) diff --git a/cocos2dx/label_nodes/CCLabelTTF.h b/cocos2dx/label_nodes/CCLabelTTF.h index f5fe5fdd29..27427e1d11 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.h +++ b/cocos2dx/label_nodes/CCLabelTTF.h @@ -90,6 +90,10 @@ public: */ static CCLabelTTF * node(); + /** Creates an label. + */ + static CCLabelTTF * create(); + /** changes the string to render * @warning Changing the string is as expensive as creating a new CCLabelTTF. To obtain better performance use CCLabelAtlas */ diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h index 0181b1799a..645d01eaf7 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h @@ -252,8 +252,9 @@ public: virtual void setIsOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} virtual bool getIsOpacityModifyRGB(void) { return false;} - LAYER_CREATE_FUNC(CCLayerColor); - + //@warning: This interface will be deprecated in future. + LAYER_CREATE_FUNC(CCLayerColor) + LAYER_NODE_FUNC(CCLayerColor) protected: virtual void updateColor(); }; @@ -317,7 +318,9 @@ public: */ CC_PROPERTY(bool, m_bCompressedInterpolation, IsCompressedInterpolation) - LAYER_CREATE_FUNC(CCLayerGradient); + // @warning: This interface will be deprecated in future. + LAYER_NODE_FUNC(CCLayerGradient) + LAYER_CREATE_FUNC(CCLayerGradient) protected: virtual void updateColor(); }; @@ -372,7 +375,10 @@ public: */ void switchToAndReleaseMe(unsigned int n); - LAYER_CREATE_FUNC(CCLayerMultiplex); + //@warning: This interface will be deprecated in future. + LAYER_NODE_FUNC(CCLayerMultiplex) + + LAYER_CREATE_FUNC(CCLayerMultiplex) }; NS_CC_END diff --git a/cocos2dx/menu_nodes/CCMenuItem.cpp b/cocos2dx/menu_nodes/CCMenuItem.cpp index ce3feec0be..5765cf5bc7 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.cpp +++ b/cocos2dx/menu_nodes/CCMenuItem.cpp @@ -693,8 +693,12 @@ void CCMenuItemSprite::updateImagesVisibility() } } - CCMenuItemImage* CCMenuItemImage::node() +{ + return CCMenuItemImage::create(); +} + +CCMenuItemImage* CCMenuItemImage::create() { CCMenuItemImage *pRet = new CCMenuItemImage(); if (pRet && pRet->init()) diff --git a/cocos2dx/menu_nodes/CCMenuItem.h b/cocos2dx/menu_nodes/CCMenuItem.h index 409d5b0a5f..726e012095 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.h +++ b/cocos2dx/menu_nodes/CCMenuItem.h @@ -339,8 +339,13 @@ public: /** sets the sprite frame for the disabled image */ void setDisabledSpriteFrame(CCSpriteFrame* frame); /** Creates an CCMenuItemImage. + @warning: This interface will be deprecated in future. */ static CCMenuItemImage* node(); + + /** Creates an CCMenuItemImage. + */ + static CCMenuItemImage* create(); }; /** @brief A CCMenuItemToggle diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp index bdbeea51ab..07cab0b9a7 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp @@ -569,7 +569,12 @@ void CCParticleSystemQuad::setBatchNode(CCParticleBatchNode * batchNode) } } -CCParticleSystemQuad * CCParticleSystemQuad::node() { +CCParticleSystemQuad * CCParticleSystemQuad::node() +{ + return CCParticleSystemQuad::create(); +} + +CCParticleSystemQuad * CCParticleSystemQuad::create() { CCParticleSystemQuad *pParticleSystemQuad = new CCParticleSystemQuad(); if (pParticleSystemQuad && pParticleSystemQuad->init()) { diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.h b/cocos2dx/particle_nodes/CCParticleSystemQuad.h index a358f3ae34..cbe8d42fd6 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.h +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.h @@ -101,7 +101,10 @@ public: */ void listenBackToForeground(CCObject *obj); + //@warning: This interface will be deprecated in future. static CCParticleSystemQuad * node(); + + static CCParticleSystemQuad * create(); private: #if CC_TEXTURE_ATLAS_USE_VAO void setupVBOandVAO(); diff --git a/cocos2dx/proj.win32/cocos2d-win32.vcproj b/cocos2dx/proj.win32/cocos2d-win32.vcproj index 96cc4a5e72..7611402e1f 100755 --- a/cocos2dx/proj.win32/cocos2d-win32.vcproj +++ b/cocos2dx/proj.win32/cocos2d-win32.vcproj @@ -1239,11 +1239,19 @@ Name="CCBReader" > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/proj.win32/test.win32.vcproj b/tests/proj.win32/test.win32.vcproj index 8bd845e672..3a0a332e6f 100644 --- a/tests/proj.win32/test.win32.vcproj +++ b/tests/proj.win32/test.win32.vcproj @@ -893,6 +893,22 @@ + + + + + + + + @@ -902,11 +918,35 @@ > + + + + + + + + + + + + diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp index 5d72ec032d..9c14505f42 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.cpp @@ -149,42 +149,42 @@ bool CCControlButtonTest_Event::init() return false; } -void CCControlButtonTest_Event::touchDownAction(CCObject *sender) +void CCControlButtonTest_Event::touchDownAction(CCObject *senderz, CCControlEvent controlEvent) { m_pDisplayValueLabel->setString(CCString::createWithFormat("Touch Down")->getCString()); } -void CCControlButtonTest_Event::touchDragInsideAction(CCObject *sender) +void CCControlButtonTest_Event::touchDragInsideAction(CCObject *sender, CCControlEvent controlEvent) { m_pDisplayValueLabel->setString(CCString::createWithFormat("Drag Inside")->getCString()); } -void CCControlButtonTest_Event::touchDragOutsideAction(CCObject *sender) +void CCControlButtonTest_Event::touchDragOutsideAction(CCObject *sender, CCControlEvent controlEvent) { m_pDisplayValueLabel->setString(CCString::createWithFormat("Drag Outside")->getCString()); } -void CCControlButtonTest_Event::touchDragEnterAction(CCObject *sender) +void CCControlButtonTest_Event::touchDragEnterAction(CCObject *sender, CCControlEvent controlEvent) { m_pDisplayValueLabel->setString(CCString::createWithFormat("Drag Enter")->getCString()); } -void CCControlButtonTest_Event::touchDragExitAction(CCObject *sender) +void CCControlButtonTest_Event::touchDragExitAction(CCObject *sender, CCControlEvent controlEvent) { m_pDisplayValueLabel->setString(CCString::createWithFormat("Drag Exit")->getCString()); } -void CCControlButtonTest_Event::touchUpInsideAction(CCObject *sender) +void CCControlButtonTest_Event::touchUpInsideAction(CCObject *sender, CCControlEvent controlEvent) { m_pDisplayValueLabel->setString(CCString::createWithFormat("Touch Up Inside.")->getCString()); } -void CCControlButtonTest_Event::touchUpOutsideAction(CCObject *sender) +void CCControlButtonTest_Event::touchUpOutsideAction(CCObject *sender, CCControlEvent controlEvent) { m_pDisplayValueLabel->setString(CCString::createWithFormat("Touch Up Outside.")->getCString()); } -void CCControlButtonTest_Event::touchCancelAction(CCObject *sender) +void CCControlButtonTest_Event::touchCancelAction(CCObject *sender, CCControlEvent controlEvent) { m_pDisplayValueLabel->setString(CCString::createWithFormat("Touch Cancel")->getCString()); } diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h index a9089a1fb4..1b885ecde8 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlButtonTest/CCControlButtonTest.h @@ -44,14 +44,14 @@ public: CCControlButtonTest_Event(); ~CCControlButtonTest_Event(); bool init(); - void touchDownAction(CCObject *sender); - void touchDragInsideAction(CCObject *sender); - void touchDragOutsideAction(CCObject *sender); - void touchDragEnterAction(CCObject *sender); - void touchDragExitAction(CCObject *sender); - void touchUpInsideAction(CCObject *sender); - void touchUpOutsideAction(CCObject *sender); - void touchCancelAction(CCObject *sender); + void touchDownAction(CCObject *sender, CCControlEvent controlEvent); + void touchDragInsideAction(CCObject *sender, CCControlEvent controlEvent); + void touchDragOutsideAction(CCObject *sender, CCControlEvent controlEvent); + void touchDragEnterAction(CCObject *sender, CCControlEvent controlEvent); + void touchDragExitAction(CCObject *sender, CCControlEvent controlEvent); + void touchUpInsideAction(CCObject *sender, CCControlEvent controlEvent); + void touchUpOutsideAction(CCObject *sender, CCControlEvent controlEvent); + void touchCancelAction(CCObject *sender, CCControlEvent controlEvent); protected: CC_SYNTHESIZE_RETAIN(CCLabelTTF *, m_pDisplayValueLabel, DisplayValueLabel) CONTROL_SCENE_CREATE_FUNC(CCControlButtonTest_Event) diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp index e18e39bd11..3e7f9040c2 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.cpp @@ -75,7 +75,7 @@ bool CCControlColourPickerTest::init() layer->setAnchorPoint(ccp (0.5f, 0.5f)); // Update the color text - colourValueChanged(colourPicker); + colourValueChanged(colourPicker, CCControlEventValueChanged); return true; } return false; @@ -87,7 +87,7 @@ CCControlColourPickerTest::~CCControlColourPickerTest() CC_SAFE_RELEASE(m_pColorLabel); } -void CCControlColourPickerTest::colourValueChanged(CCObject *sender) +void CCControlColourPickerTest::colourValueChanged(CCObject *sender, CCControlEvent controlEvent) { CCControlColourPicker* pPicker = (CCControlColourPicker*)sender; m_pColorLabel->setString(CCString::createWithFormat("#%02X%02X%02X",pPicker->getColorValue().r, pPicker->getColorValue().g, pPicker->getColorValue().b)->getCString()); diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.h b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.h index 7d60c50343..7e3660d4d8 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.h +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourPickerTest.h @@ -32,7 +32,7 @@ public: virtual ~CCControlColourPickerTest(); bool init(); /** Callback for the change value. */ - void colourValueChanged(CCObject *sender); + void colourValueChanged(CCObject *sender, CCControlEvent controlEvent); CC_SYNTHESIZE_RETAIN(CCLabelTTF*, m_pColorLabel, ColorLabel) diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp index d7fefb973b..6dd4ff2bef 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp @@ -65,7 +65,7 @@ bool CCControlSliderTest::init() return false; } -void CCControlSliderTest::valueChanged(CCObject *sender) +void CCControlSliderTest::valueChanged(CCObject *sender, CCControlEvent controlEvent) { CCControlSlider* pSlider = (CCControlSlider*)sender; // Change value of label. diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.h b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.h index 5e7fd7c536..de5242ab47 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.h +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.h @@ -31,7 +31,7 @@ public: CCControlSliderTest(); virtual ~CCControlSliderTest(); bool init(); - void valueChanged(CCObject *sender); + void valueChanged(CCObject *sender, CCControlEvent controlEvent); protected: CCLabelTTF* m_pDisplayValueLabel; CONTROL_SCENE_CREATE_FUNC(CCControlSliderTest) diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp index 9ebff11d66..d89a88a46d 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp @@ -78,13 +78,13 @@ bool CCControlSwitchTest::init() layer->setAnchorPoint(ccp (0.5f, 0.5f)); // Update the value label - valueChanged(switchControl); + valueChanged(switchControl, CCControlEventValueChanged); return true; } return false; } -void CCControlSwitchTest::valueChanged(CCObject* sender) +void CCControlSwitchTest::valueChanged(CCObject* sender, CCControlEvent controlEvent) { CCControlSwitch* pSwitch = (CCControlSwitch*)sender; if (pSwitch->getIsOn()) diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.h b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.h index 6efbc50294..b62a8a0bd7 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.h +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.h @@ -32,7 +32,7 @@ public: virtual ~CCControlSwitchTest(); bool init(); /** Callback for the change value. */ - void valueChanged(CCObject* sender); + void valueChanged(CCObject* sender, CCControlEvent controlEvent); CCLabelTTF *m_pDisplayValueLabel; CONTROL_SCENE_CREATE_FUNC(CCControlSwitchTest) }; diff --git a/tests/tests/SchedulerTest/SchedulerTest.cpp b/tests/tests/SchedulerTest/SchedulerTest.cpp index 8ffc63257c..4e5f4daa66 100644 --- a/tests/tests/SchedulerTest/SchedulerTest.cpp +++ b/tests/tests/SchedulerTest/SchedulerTest.cpp @@ -874,7 +874,7 @@ CCControlSlider* SchedulerTimeScale::sliderCtl() return slider; } -void SchedulerTimeScale::sliderAction(CCObject* pSender) +void SchedulerTimeScale::sliderAction(CCObject* pSender, CCControlEvent controlEvent) { CCControlSlider* pSliderCtl = (CCControlSlider*)pSender; float scale; @@ -966,7 +966,7 @@ CCControlSlider *TwoSchedulers::sliderCtl() return slider; } -void TwoSchedulers::sliderAction(CCObject* sender) +void TwoSchedulers::sliderAction(CCObject* sender, CCControlEvent controlEvent) { float scale; diff --git a/tests/tests/SchedulerTest/SchedulerTest.h b/tests/tests/SchedulerTest/SchedulerTest.h index 0dc4eec257..c18d67f6e0 100644 --- a/tests/tests/SchedulerTest/SchedulerTest.h +++ b/tests/tests/SchedulerTest/SchedulerTest.h @@ -223,7 +223,7 @@ public: virtual std::string title(); virtual std::string subtitle(); CCControlSlider* sliderCtl(); - void sliderAction(CCObject* pSender); + void sliderAction(CCObject* pSender, CCControlEvent controlEvent); CCControlSlider* m_pSliderCtl; }; @@ -236,7 +236,7 @@ public: virtual std::string subtitle(); void onEnter(); CCControlSlider* sliderCtl(); - void sliderAction(CCObject* sender); + void sliderAction(CCObject* sender, CCControlEvent controlEvent); CCScheduler *sched1; CCScheduler *sched2; CCActionManager *actionManager1; diff --git a/tests/tests/ShaderTest/ShaderTest.cpp b/tests/tests/ShaderTest/ShaderTest.cpp index e62db14f94..eb0e8c222b 100644 --- a/tests/tests/ShaderTest/ShaderTest.cpp +++ b/tests/tests/ShaderTest/ShaderTest.cpp @@ -611,7 +611,7 @@ bool ShaderBlur::init() return false; } -void ShaderBlur::sliderAction(CCObject* sender) +void ShaderBlur::sliderAction(CCObject* sender, CCControlEvent controlEvent) { CCControlSlider* pSlider = (CCControlSlider*)sender; m_pBlurSprite->setBlurSize(pSlider->getValue()); diff --git a/tests/tests/ShaderTest/ShaderTest.h b/tests/tests/ShaderTest/ShaderTest.h index f83c03c9db..47bb3a631c 100644 --- a/tests/tests/ShaderTest/ShaderTest.h +++ b/tests/tests/ShaderTest/ShaderTest.h @@ -89,7 +89,7 @@ public: virtual std::string subtitle(); virtual bool init(); CCControlSlider* createSliderCtl(); - void sliderAction(CCObject* sender); + void sliderAction(CCObject* sender, CCControlEvent controlEvent); protected: SpriteBlur* m_pBlurSprite; CCControlSlider* m_pSliderCtl; From 9d9e2579e36cfa3e333e1157f8a3952670d0184b Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 14 Jun 2012 18:37:57 +0800 Subject: [PATCH 168/257] issue #1181: save render texture when comming to background --- cocos2dx/include/CCEventType.h | 8 + cocos2dx/misc_nodes/CCRenderTexture.cpp | 57 +++-- cocos2dx/misc_nodes/CCRenderTexture.h | 8 +- cocos2dx/platform/android/jni/MessageJni.cpp | 16 +- .../RenderTextureTest/RenderTextureTest.cpp | 215 +++++------------- .../RenderTextureTest/RenderTextureTest.h | 34 +-- 6 files changed, 124 insertions(+), 214 deletions(-) diff --git a/cocos2dx/include/CCEventType.h b/cocos2dx/include/CCEventType.h index 3a9ad5add2..56378de27d 100644 --- a/cocos2dx/include/CCEventType.h +++ b/cocos2dx/include/CCEventType.h @@ -6,6 +6,14 @@ * This header is used for defining event types using in CCNotificationCenter */ +// The application will come to foreground. +// This message is used for reloading resources before come to foreground on Android. +// This message is posted in main.cpp. #define EVNET_COME_TO_FOREGROUND "event_come_to_foreground" +// The application will come to background. +// This message is used for doing something before coming to background, such as save CCRenderTexture. +// This message is posted in cocos2dx/platform/android/jni/MessageJni.cpp. +#define EVENT_COME_TO_BACKGROUND "event_come_to_background" + #endif // __CCEVENT_TYPE_H__ diff --git a/cocos2dx/misc_nodes/CCRenderTexture.cpp b/cocos2dx/misc_nodes/CCRenderTexture.cpp index 054a8127c5..cd92592a5b 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.cpp +++ b/cocos2dx/misc_nodes/CCRenderTexture.cpp @@ -35,6 +35,8 @@ THE SOFTWARE. #include "CCTextureCache.h" #include "CCFileUtils.h" #include "CCGL.h" +#include "extensions/CCNotificationCenter/CCNotificationCenter.h" +#include "CCEventType.h" // extern #include "kazmath/GL/matrix.h" @@ -50,17 +52,46 @@ CCRenderTexture::CCRenderTexture() , m_pUITextureImage(NULL) , m_ePixelFormat(kCCTexture2DPixelFormat_RGBA8888) { + // Listen this event to save render texture before come to background. + // Then it can be restored after coming to foreground on Android. + extension::CCNotificationCenter::sharedNotificationCenter()->addObserver(this, + callfuncO_selector(CCRenderTexture::listenToBackground), + EVENT_COME_TO_BACKGROUND, + NULL); } CCRenderTexture::~CCRenderTexture() { -//TODO: 2.0 remove this line. removeAllChildrenWithCleanup(true); glDeleteFramebuffers(1, &m_uFBO); if (m_uDepthRenderBufffer) { glDeleteRenderbuffers(1, &m_uDepthRenderBufffer); } CC_SAFE_DELETE(m_pUITextureImage); + + extension::CCNotificationCenter::sharedNotificationCenter()->removeObserver(this, EVENT_COME_TO_BACKGROUND); +} + +void CCRenderTexture::listenToBackground(cocos2d::CCObject *obj) +{ +#if CC_ENABLE_CACHE_TEXTURE_DATA + + CC_SAFE_DELETE(m_pUITextureImage); + + // to get the rendered texture data + m_pUITextureImage = newCCImage(); + + + if (m_pUITextureImage) + { + const CCSize& s = m_pTexture->getContentSizeInPixels(); + VolatileTexture::addDataTexture(m_pTexture, m_pUITextureImage->getData(), kTexture2DPixelFormat_RGBA8888, s); + } + else + { + CCLOG("Cache rendertexture failed!"); + } +#endif } CCSprite * CCRenderTexture::getSprite() @@ -281,7 +312,7 @@ void CCRenderTexture::beginWithClear(float r, float g, float b, float a, float d glClearStencil(stencilClearValue); } -void CCRenderTexture::end(bool bIsTOCacheTexture) +void CCRenderTexture::end() { glBindFramebuffer(GL_FRAMEBUFFER, m_nOldFBO); kmGLPopMatrix(); @@ -300,26 +331,6 @@ void CCRenderTexture::end(bool bIsTOCacheTexture) } director->setProjection(director->getProjection()); - -#if CC_ENABLE_CACHE_TEXTURE_DATA - if (bIsTOCacheTexture) - { - CC_SAFE_DELETE(m_pUITextureImage); - - // to get the rendered texture data - const CCSize& s = m_pTexture->getContentSizeInPixels(); - m_pUITextureImage = newCCImage(); - - if (m_pUITextureImage) - { - VolatileTexture::addDataTexture(m_pTexture, m_pUITextureImage->getData(), kTexture2DPixelFormat_RGBA8888, s); - } - else - { - CCLOG("Cache rendertexture failed!"); - } - } -#endif } void CCRenderTexture::clear(float r, float g, float b, float a) @@ -426,7 +437,7 @@ CCImage* CCRenderTexture::newCCImage() this->begin(); glPixelStorei(GL_PACK_ALIGNMENT, 1); glReadPixels(0,0,nSavedBufferWidth, nSavedBufferHeight,GL_RGBA,GL_UNSIGNED_BYTE, pTempData); - this->end(false); + this->end(); // to get the actual texture data // #640 the image read from rendertexture is upseted diff --git a/cocos2dx/misc_nodes/CCRenderTexture.h b/cocos2dx/misc_nodes/CCRenderTexture.h index a68d3443f3..635f98bd41 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.h +++ b/cocos2dx/misc_nodes/CCRenderTexture.h @@ -93,8 +93,7 @@ public: inline void endToLua(){ end();}; /** ends grabbing*/ - // para bIsTOCacheTexture the parameter is only used for android to cache the texture - void end(bool bIsTOCacheTexture = true); + void end(); /** clears the texture with a color */ void clear(float r, float g, float b, float a); @@ -118,6 +117,11 @@ public: Returns YES if the operation is successful. */ bool saveToFile(const char *name, tCCImageFormat format); + + /** Listen "come to background" message, and save render texture. + It only has effect on Android. + */ + void listenToBackground(CCObject *obj); protected: GLuint m_uFBO; diff --git a/cocos2dx/platform/android/jni/MessageJni.cpp b/cocos2dx/platform/android/jni/MessageJni.cpp index ec31a63f37..024633c953 100644 --- a/cocos2dx/platform/android/jni/MessageJni.cpp +++ b/cocos2dx/platform/android/jni/MessageJni.cpp @@ -26,6 +26,8 @@ THE SOFTWARE. #include "JniHelper.h" #include "CCApplication.h" #include "CCFileUtils.h" +#include "CCEventType.h" +#include "extensions/CCNotificationCenter/CCNotificationCenter.h" #include #include @@ -55,16 +57,18 @@ extern "C" void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnPause() { - CCApplication::sharedApplication().applicationDidEnterBackground(); + CCApplication::sharedApplication().applicationDidEnterBackground(); + + extension::CCNotificationCenter::sharedNotificationCenter()->postNotification(EVENT_COME_TO_BACKGROUND, NULL); } void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnResume() { - // Shared OpenGL View instance doesn't exist yet when Activity.onResume is first called - if (CCDirector::sharedDirector()->getOpenGLView()) - { - CCApplication::sharedApplication().applicationWillEnterForeground(); - } + // Shared OpenGL View instance doesn't exist yet when Activity.onResume is first called + if (CCDirector::sharedDirector()->getOpenGLView()) + { + CCApplication::sharedApplication().applicationWillEnterForeground(); + } } void showMessageBoxJNI(const char * pszMsg, const char * pszTitle) diff --git a/tests/tests/RenderTextureTest/RenderTextureTest.cpp b/tests/tests/RenderTextureTest/RenderTextureTest.cpp index 9050b4f03f..a143aa5228 100644 --- a/tests/tests/RenderTextureTest/RenderTextureTest.cpp +++ b/tests/tests/RenderTextureTest/RenderTextureTest.cpp @@ -6,18 +6,17 @@ static int sceneIdx = -1; -#define MAX_LAYER 5 +#define MAX_LAYER 4 CCLayer* createTestCase(int nIndex) { switch(nIndex) { - case 0: return new RenderTextureTest(); + case 0: return new RenderTextureSave(); case 1: return new RenderTextureIssue937(); - case 2: return new RenderTextureZbuffer(); - case 3: return new RenderTextureSave(); - case 4: return new RenderTextureTestDepthStencil(); + case 2: return new RenderTextureZbuffer(); + case 3: return new RenderTextureTestDepthStencil(); } return NULL; @@ -55,12 +54,12 @@ CCLayer* restartTestCase() return pLayer; } -void RenderTextureTestDemo::onEnter() +void RenderTextureTest::onEnter() { CCLayer::onEnter(); CCSize s = CCDirector::sharedDirector()->getWinSize(); - CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 28); + CCLabelTTF* label = CCLabelTTF::labelWithString(title().c_str(), "Arial", 26); addChild(label, 1); label->setPosition( ccp(s.width/2, s.height-50) ); @@ -72,9 +71,9 @@ void RenderTextureTestDemo::onEnter() l->setPosition( ccp(s.width/2, s.height-80) ); } - CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage("Images/b1.png", "Images/b2.png", this, menu_selector(RenderTextureTestDemo::backCallback) ); - CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage("Images/r1.png","Images/r2.png", this, menu_selector(RenderTextureTestDemo::restartCallback) ); - CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage("Images/f1.png", "Images/f2.png", this, menu_selector(RenderTextureTestDemo::nextCallback) ); + CCMenuItemImage *item1 = CCMenuItemImage::itemWithNormalImage("Images/b1.png", "Images/b2.png", this, menu_selector(RenderTextureTest::backCallback) ); + CCMenuItemImage *item2 = CCMenuItemImage::itemWithNormalImage("Images/r1.png","Images/r2.png", this, menu_selector(RenderTextureTest::restartCallback) ); + CCMenuItemImage *item3 = CCMenuItemImage::itemWithNormalImage("Images/f1.png", "Images/f2.png", this, menu_selector(RenderTextureTest::nextCallback) ); CCMenu *menu = CCMenu::menuWithItems(item1, item2, item3, NULL); @@ -86,7 +85,7 @@ void RenderTextureTestDemo::onEnter() addChild(menu, 1); } -void RenderTextureTestDemo::restartCallback(CCObject* pSender) +void RenderTextureTest::restartCallback(CCObject* pSender) { CCScene* s = new RenderTextureScene(); s->addChild(restartTestCase()); @@ -95,7 +94,7 @@ void RenderTextureTestDemo::restartCallback(CCObject* pSender) s->release(); } -void RenderTextureTestDemo::nextCallback(CCObject* pSender) +void RenderTextureTest::nextCallback(CCObject* pSender) { CCScene* s = new RenderTextureScene(); s->addChild( nextTestCase() ); @@ -103,7 +102,7 @@ void RenderTextureTestDemo::nextCallback(CCObject* pSender) s->release(); } -void RenderTextureTestDemo::backCallback(CCObject* pSender) +void RenderTextureTest::backCallback(CCObject* pSender) { CCScene* s = new RenderTextureScene(); s->addChild( backTestCase() ); @@ -111,117 +110,16 @@ void RenderTextureTestDemo::backCallback(CCObject* pSender) s->release(); } -std::string RenderTextureTestDemo::title() +std::string RenderTextureTest::title() { - return "Render Texture Test"; + return "No title"; } -std::string RenderTextureTestDemo::subtitle() +std::string RenderTextureTest::subtitle() { return ""; } -RenderTextureTest::RenderTextureTest() -: m_brush(NULL) -{ - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - // create a render texture, this is what we're going to draw into - m_target = CCRenderTexture::renderTextureWithWidthAndHeight(s.width, s.height); - - if (NULL == m_target) - { - return; - } - - m_target->setPosition(ccp(s.width/2, s.height/2)); - - // note that the render texture is a cocosnode, and contains a sprite of it's texture for convience, - // so we can just parent it to the scene like any other cocos node - addChild(m_target, 1); - - // create a brush image to draw into the texture with - m_brush = CCSprite::spriteWithFile("Images/stars.png"); - m_brush->retain(); - - ccBlendFunc bf = { GL_ONE, GL_ONE_MINUS_SRC_ALPHA }; - m_brush->setBlendFunc( bf); - m_brush->setOpacity(20); - setIsTouchEnabled(true); -} - -RenderTextureTest::~RenderTextureTest() -{ - if (NULL != m_brush) - { - m_brush->release(); - m_brush = NULL; - } -} - -void RenderTextureTest::ccTouchesMoved(CCSet* touches, CCEvent* event) -{ - CCSetIterator it = touches->begin(); - CCTouch* touch = (CCTouch*)(*it); - CCPoint start = touch->locationInView(); - start = CCDirector::sharedDirector()->convertToGL( start ); - CCPoint end = touch->previousLocationInView(); - end = CCDirector::sharedDirector()->convertToGL(end); - - // begin drawing to the render texture - m_target->begin(); - - // for extra points, we'll draw this smoothly from the last position and vary the sprite's - // scale/rotation/offset - float distance = ccpDistance(start, end); - if (distance > 1) - { - int d = (int)distance; - for (int i = 0; i < d; i++) - { - float difx = end.x - start.x; - float dify = end.y - start.y; - float delta = (float)i / distance; - m_brush->setPosition(ccp(start.x + (difx * delta), start.y + (dify * delta)) ); - m_brush->setRotation( rand()%360 ); - float r = ((float)(rand()%50)/50.f) + 0.25f; - m_brush->setScale( r ); - // Call visit to draw the brush, don't call draw.. - m_brush->visit(); - } - } - // finish drawing and return context back to the screen - m_target->end(false); -} - -void RenderTextureTest::ccTouchesEnded(CCSet* touches, CCEvent* event) -{ -#if CC_ENABLE_CACHE_TEXTURE_DATA - - CCSetIterator it; - CCTouch* touch; - - for( it = touches->begin(); it != touches->end(); it++) - { - touch = (CCTouch*)(*it); - - if(!touch) - break; - - CCPoint location = touch->locationInView(); - - location = CCDirector::sharedDirector()->convertToGL(location); - - m_brush->setPosition(location); - m_brush->setRotation( rand()%360 ); - } - - m_target->begin(); - m_brush->visit(); - m_target->end(true); -#endif -} - /** * Impelmentation of RenderTextureSave */ @@ -314,6 +212,7 @@ void RenderTextureSave::ccTouchesMoved(CCSet* touches, CCEvent* event) CCPoint start = touch->locationInView(); start = CCDirector::sharedDirector()->convertToGL(start); CCPoint end = touch->previousLocationInView(); + end = CCDirector::sharedDirector()->convertToGL(end); // begin drawing to the render texture m_pTarget->begin(); @@ -570,50 +469,50 @@ void RenderTextureZbuffer::renderScreenShot() NULL)); } - -// RenderTextureTestDepthStencil - -RenderTextureTestDepthStencil::RenderTextureTestDepthStencil() -{ - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - CCSprite *sprite = CCSprite::spriteWithFile("Images/fire.png"); - sprite->setPosition(ccp(s.width * 0.25f, 0)); - sprite->setScale(10); - CCRenderTexture *rend = CCRenderTexture::renderTextureWithWidthAndHeight(s.width, s.height, kCCTexture2DPixelFormat_RGBA4444, CC_GL_DEPTH24_STENCIL8); - - glStencilMask(0xFF); - rend->beginWithClear(0, 0, 0, 0, 0, 0); - - //! mark sprite quad into stencil buffer - glEnable(GL_STENCIL_TEST); - glStencilFunc(GL_ALWAYS, 1, 0xFF); - glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); - glColorMask(0, 0, 0, 1); - sprite->visit(); - - //! move sprite half width and height, and draw only where not marked - sprite->setPosition(ccpAdd(sprite->getPosition(), ccpMult(ccp(sprite->getContentSize().width * sprite->getScale(), sprite->getContentSize().height * sprite->getScale()), 0.5))); - glStencilFunc(GL_NOTEQUAL, 1, 0xFF); - glColorMask(1, 1, 1, 1); - sprite->visit(); - - rend->end(); - - glDisable(GL_STENCIL_TEST); - - rend->setPosition(ccp(s.width * 0.5f, s.height * 0.5f)); - - this->addChild(rend); -} - + +// RenderTextureTestDepthStencil + +RenderTextureTestDepthStencil::RenderTextureTestDepthStencil() +{ + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCSprite *sprite = CCSprite::spriteWithFile("Images/fire.png"); + sprite->setPosition(ccp(s.width * 0.25f, 0)); + sprite->setScale(10); + CCRenderTexture *rend = CCRenderTexture::renderTextureWithWidthAndHeight(s.width, s.height, kCCTexture2DPixelFormat_RGBA4444, CC_GL_DEPTH24_STENCIL8); + + glStencilMask(0xFF); + rend->beginWithClear(0, 0, 0, 0, 0, 0); + + //! mark sprite quad into stencil buffer + glEnable(GL_STENCIL_TEST); + glStencilFunc(GL_ALWAYS, 1, 0xFF); + glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); + glColorMask(0, 0, 0, 1); + sprite->visit(); + + //! move sprite half width and height, and draw only where not marked + sprite->setPosition(ccpAdd(sprite->getPosition(), ccpMult(ccp(sprite->getContentSize().width * sprite->getScale(), sprite->getContentSize().height * sprite->getScale()), 0.5))); + glStencilFunc(GL_NOTEQUAL, 1, 0xFF); + glColorMask(1, 1, 1, 1); + sprite->visit(); + + rend->end(); + + glDisable(GL_STENCIL_TEST); + + rend->setPosition(ccp(s.width * 0.5f, s.height * 0.5f)); + + this->addChild(rend); +} + std::string RenderTextureTestDepthStencil::title() { return "Testing depthStencil attachment"; } -std::string RenderTextureTestDepthStencil::subtitle() -{ - return "Circle should be missing 1/4 of its region"; -} +std::string RenderTextureTestDepthStencil::subtitle() +{ + return "Circle should be missing 1/4 of its region"; +} diff --git a/tests/tests/RenderTextureTest/RenderTextureTest.h b/tests/tests/RenderTextureTest/RenderTextureTest.h index 59d1598095..c3790b40a8 100644 --- a/tests/tests/RenderTextureTest/RenderTextureTest.h +++ b/tests/tests/RenderTextureTest/RenderTextureTest.h @@ -4,7 +4,7 @@ #include "cocos2d.h" #include "../testBasic.h" -class RenderTextureTestDemo : public CCLayer +class RenderTextureTest : public CCLayer { public: virtual void onEnter(); @@ -16,23 +16,7 @@ public: void backCallback(CCObject* pSender); }; -/** -@todo refactor the save image feature -*/ -class RenderTextureTest : public RenderTextureTestDemo -{ -public: - RenderTextureTest(); - ~RenderTextureTest(); - virtual void ccTouchesMoved(CCSet* touches, CCEvent* event); - virtual void ccTouchesEnded(CCSet* touches, CCEvent* event); - -private: - CCRenderTexture* m_target; - CCSprite* m_brush; -}; - -class RenderTextureSave : public RenderTextureTestDemo +class RenderTextureSave : public RenderTextureTest { public: RenderTextureSave(); @@ -48,7 +32,7 @@ private: CCSprite *m_pBrush; }; -class RenderTextureIssue937 : public RenderTextureTestDemo +class RenderTextureIssue937 : public RenderTextureTest { public: RenderTextureIssue937(); @@ -62,7 +46,7 @@ public: virtual void runThisTest(); }; -class RenderTextureZbuffer : public RenderTextureTestDemo +class RenderTextureZbuffer : public RenderTextureTest { public: RenderTextureZbuffer(); @@ -89,12 +73,12 @@ private: cocos2d::CCSprite *sp9; }; -class RenderTextureTestDepthStencil : public RenderTextureTest -{ -public: - RenderTextureTestDepthStencil(); +class RenderTextureTestDepthStencil : public RenderTextureTest +{ +public: + RenderTextureTestDepthStencil(); virtual std::string title(); - virtual std::string subtitle(); + virtual std::string subtitle(); }; #endif From 221be759c6ece52cf8a9ceb955aeb7490327397b Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 14 Jun 2012 18:54:05 +0800 Subject: [PATCH 169/257] issue #1324: merge James Chen's codes --- .../proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- .../HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- cocos2dx/Android.mk | 1 - cocos2dx/extensions/CCBReader/CCBReader.cpp | 1 + cocos2dx/textures/CCTextureCache.cpp | 2 +- testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- 7 files changed, 6 insertions(+), 6 deletions(-) diff --git a/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id b/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id index a719cf6fd3..2e21e7243c 100644 --- a/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -054e166ed7b342f0cd56308efb308551f9488951 \ No newline at end of file +cbcce8ff39bec50486918e1f66c700960446d536 \ No newline at end of file diff --git a/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id b/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id index 43f6702dd0..5405d51a18 100644 --- a/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -e725a16819b832fcdbd8496ae63d0b24c76af31a \ No newline at end of file +b9567f1b9c51fbce0bc5ed542e3101c8d32179db \ No newline at end of file diff --git a/cocos2dx/Android.mk b/cocos2dx/Android.mk index 2dc6c2412e..1d288987eb 100644 --- a/cocos2dx/Android.mk +++ b/cocos2dx/Android.mk @@ -29,7 +29,6 @@ base_nodes/CCNode.cpp \ cocoa/CCAffineTransform.cpp \ cocoa/CCGeometry.cpp \ cocoa/CCAutoreleasePool.cpp \ -cocoa/CCData.cpp \ cocoa/CCDictionary.cpp \ cocoa/CCNS.cpp \ cocoa/CCObject.cpp \ diff --git a/cocos2dx/extensions/CCBReader/CCBReader.cpp b/cocos2dx/extensions/CCBReader/CCBReader.cpp index bb9300a668..05fe6cdfe8 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader.cpp @@ -93,6 +93,7 @@ CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBRootPath, const char this->mCCBRootPath = pCCBRootPath; char* ccbFullFilePath = (char*)malloc(strlen(pCCBRootPath) + strlen(pCCBFileName) + 1); + ccbFullFilePath[strlen(pCCBRootPath) + strlen(pCCBFileName)] = '\0'; strcpy(ccbFullFilePath, pCCBRootPath); strcat(ccbFullFilePath, pCCBFileName); diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index c4ea5d5423..14ec6419ed 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -502,7 +502,7 @@ CCTexture2D* CCTextureCache::addPVRTCImage(const char* path, int bpp, bool hasAl { CCLOG("cocos2d: Couldn't add PVRTCImage:%s in CCTextureCache",path); } - CC_SAFE_DELETE(data); + CC_SAFE_DELETE_ARRAY(pData); return texture; } diff --git a/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id b/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id index 2997ec0aac..7f2a149d0c 100644 --- a/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -594b0f9fe97d6f6dd1d56c71ccd7e1c61b5522b3 \ No newline at end of file +5a548bf62fdc41ace1f6ab427eb8663a9098ac25 \ No newline at end of file diff --git a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id index bb7ea0ae95..2896a3bec7 100644 --- a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -2ceb9242ccb6d715680043923827efd103be7d2b \ No newline at end of file +2e55dcc2dc68c6b6b24af67634d5107fc04c35bf \ No newline at end of file From 2554f25cd886d7cb7f41f38c97e0a5d881fe99c0 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Thu, 14 Jun 2012 13:50:47 -0700 Subject: [PATCH 170/257] CCString: Added CCStringCompare operator (can be used i.e. in stl containers). --- cocos2dx/cocoa/CCString.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cocos2dx/cocoa/CCString.h b/cocos2dx/cocoa/CCString.h index 7af1b44e8e..15c2735308 100644 --- a/cocos2dx/cocoa/CCString.h +++ b/cocos2dx/cocoa/CCString.h @@ -120,6 +120,13 @@ public: std::string m_sString; }; +struct CCStringCompare : public std::binary_function { + public: + bool operator() (CCString * a, CCString * b) const { + return strcmp(a->getCString(), b->getCString()) < 0; + } +}; + #define CCStringMake(str) CCString::stringWithCString(str) #define ccs CCStringMake From c7daca43d097ace6efe25c7d8f6ce6ccc384f301 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Thu, 14 Jun 2012 13:51:32 -0700 Subject: [PATCH 171/257] CCNodeLoaderLibrary: Now free from direct std::string usage. --- .../CCBReader/CCNodeLoaderLibrary.cpp | 17 +++++++++++------ .../extensions/CCBReader/CCNodeLoaderLibrary.h | 5 ++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp index 759861ac08..810f8e6b9c 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp +++ b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp @@ -42,30 +42,35 @@ void CCNodeLoaderLibrary::registerDefaultCCNodeLoaders() { } void CCNodeLoaderLibrary::registerCCNodeLoader(const char * pClassName, CCNodeLoader * pCCNodeLoader) { - pCCNodeLoader->retain(); - this->mCCNodeLoaders.insert(std::pair(pClassName, pCCNodeLoader)); + this->registerCCNodeLoader(CCString::stringWithCString(pClassName), pCCNodeLoader); } void CCNodeLoaderLibrary::registerCCNodeLoader(CCString * pClassName, CCNodeLoader * pCCNodeLoader) { + pClassName->retain(); pCCNodeLoader->retain(); - this->mCCNodeLoaders.insert(std::pair(pClassName->m_sString, pCCNodeLoader)); + this->mCCNodeLoaders.insert(CCNodeLoaderMapEntry(pClassName, pCCNodeLoader)); +} + +void CCNodeLoaderLibrary::unregisterCCNodeLoader(const char * pClassName) { + this->unregisterCCNodeLoader(CCString::stringWithCString(pClassName)); } void CCNodeLoaderLibrary::unregisterCCNodeLoader(CCString * pClassName) { - std::map::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName->m_sString); + CCNodeLoaderMap::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName); assert(ccNodeLoadersIterator != this->mCCNodeLoaders.end()); + ccNodeLoadersIterator->first->release(); ccNodeLoadersIterator->second->release(); } CCNodeLoader * CCNodeLoaderLibrary::getCCNodeLoader(CCString * pClassName) { - std::map::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName->m_sString); + CCNodeLoaderMap::iterator ccNodeLoadersIterator = this->mCCNodeLoaders.find(pClassName); assert(ccNodeLoadersIterator != this->mCCNodeLoaders.end()); return ccNodeLoadersIterator->second; } void CCNodeLoaderLibrary::purge(bool pReleaseCCNodeLoaders) { if(pReleaseCCNodeLoaders) { - for(std::map::iterator it = this->mCCNodeLoaders.begin(); it != this->mCCNodeLoaders.end(); it++) { + for(CCNodeLoaderMap::iterator it = this->mCCNodeLoaders.begin(); it != this->mCCNodeLoaders.end(); it++) { it->second->release(); } } diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h index 17eedec1dc..a5605b6adb 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h +++ b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h @@ -6,9 +6,12 @@ NS_CC_EXT_BEGIN +typedef std::map CCNodeLoaderMap; +typedef std::pair CCNodeLoaderMapEntry; + class CC_DLL CCNodeLoaderLibrary : public CCObject { private: - std::map mCCNodeLoaders; + CCNodeLoaderMap mCCNodeLoaders; public: STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCNodeLoaderLibrary, library); From a7ad34864f0c87bf348860f1fbfdc9787bd6bd1f Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Thu, 14 Jun 2012 14:23:53 -0700 Subject: [PATCH 172/257] CocosBuilderTest: Simplified the 'XYZLoader' classes to be header only, with nice and short macros to do the boilderplate stuff. --- cocos2dx/extensions/CCBReader/CCBFileLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCBReader.h | 2 +- cocos2dx/extensions/CCBReader/CCControlButtonLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCLayerColorLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCLayerLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCMenuLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCNodeLoader.h | 6 +++++- cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h | 2 +- .../extensions/CCBReader/CCParticleSystemQuadLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCSpriteLoader.h | 2 +- tests/Android.mk | 9 +++------ .../test.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- .../{ => ButtonTest}/ButtonTestLayer.cpp | 0 .../CocosBuilderTest/{ => ButtonTest}/ButtonTestLayer.h | 0 .../{ => ButtonTest}/ButtonTestLayerLoader.h | 4 ++-- .../CocosBuilderTest/ButtonTestLayerLoader.cpp | 8 -------- .../ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp | 2 +- .../{ => HelloCocosBuilder}/HelloCocosBuilderLayer.cpp | 5 ++--- .../{ => HelloCocosBuilder}/HelloCocosBuilderLayer.h | 0 .../HelloCocosBuilderLayerLoader.h | 4 ++-- .../CocosBuilderTest/HelloCocosBuilderLayerLoader.cpp | 8 -------- .../{ => TestHeader}/TestHeaderLayer.cpp | 0 .../CocosBuilderTest/{ => TestHeader}/TestHeaderLayer.h | 0 .../{ => TestHeader}/TestHeaderLayerLoader.h | 4 ++-- .../CocosBuilderTest/TestHeaderLayerLoader.cpp | 8 -------- 30 files changed, 32 insertions(+), 56 deletions(-) rename tests/tests/ExtensionsTest/CocosBuilderTest/{ => ButtonTest}/ButtonTestLayer.cpp (100%) rename tests/tests/ExtensionsTest/CocosBuilderTest/{ => ButtonTest}/ButtonTestLayer.h (100%) rename tests/tests/ExtensionsTest/CocosBuilderTest/{ => ButtonTest}/ButtonTestLayerLoader.h (63%) delete mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayerLoader.cpp rename tests/tests/ExtensionsTest/CocosBuilderTest/{ => HelloCocosBuilder}/HelloCocosBuilderLayer.cpp (98%) rename tests/tests/ExtensionsTest/CocosBuilderTest/{ => HelloCocosBuilder}/HelloCocosBuilderLayer.h (100%) rename tests/tests/ExtensionsTest/CocosBuilderTest/{ => HelloCocosBuilder}/HelloCocosBuilderLayerLoader.h (63%) delete mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayerLoader.cpp rename tests/tests/ExtensionsTest/CocosBuilderTest/{ => TestHeader}/TestHeaderLayer.cpp (100%) rename tests/tests/ExtensionsTest/CocosBuilderTest/{ => TestHeader}/TestHeaderLayer.h (100%) rename tests/tests/ExtensionsTest/CocosBuilderTest/{ => TestHeader}/TestHeaderLayerLoader.h (63%) delete mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayerLoader.cpp diff --git a/cocos2dx/extensions/CCBReader/CCBFileLoader.h b/cocos2dx/extensions/CCBReader/CCBFileLoader.h index 0fc5bc5f71..f4a00ac76f 100644 --- a/cocos2dx/extensions/CCBReader/CCBFileLoader.h +++ b/cocos2dx/extensions/CCBReader/CCBFileLoader.h @@ -10,7 +10,7 @@ class CCBReader; class CCBFileLoader : public CCNodeLoader { public: - STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCBFileLoader, loader); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCBFileLoader, loader); protected: virtual CCNode * createCCNode(CCNode *, CCBReader *); diff --git a/cocos2dx/extensions/CCBReader/CCBReader.h b/cocos2dx/extensions/CCBReader/CCBReader.h index 5bacd93585..859bc3228c 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader.h +++ b/cocos2dx/extensions/CCBReader/CCBReader.h @@ -3,7 +3,7 @@ #include "cocos2d.h" -#define STATIC_NEW_AUTORELEASE_OBJECT_METHOD(T, METHOD) static T * METHOD() { \ +#define CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(T, METHOD) static T * METHOD() { \ T * t = new T(); \ t->autorelease(); \ return t; \ diff --git a/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h b/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h index 865a1debd8..07873db2c1 100644 --- a/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h +++ b/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h @@ -10,7 +10,7 @@ class CCBReader; class CCControlButtonLoader : public CCControlLoader { public: - STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCControlButtonLoader, loader); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCControlButtonLoader, loader); protected: virtual CCControl * createCCNode(CCNode *, CCBReader *); diff --git a/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h b/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h index e6796c9067..6f17a47063 100644 --- a/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h @@ -10,7 +10,7 @@ class CCBReader; class CCLabelBMFontLoader : public CCNodeLoader { public: - STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLabelBMFontLoader, loader); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLabelBMFontLoader, loader); protected: virtual CCLabelBMFont * createCCNode(CCNode *, CCBReader *); diff --git a/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h b/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h index db9115e1e5..3d463ba3b9 100644 --- a/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h @@ -10,7 +10,7 @@ class CCBReader; class CCLabelTTFLoader : public CCNodeLoader { public: - STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLabelTTFLoader, loader); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLabelTTFLoader, loader); protected: virtual CCLabelTTF * createCCNode(CCNode *, CCBReader *); diff --git a/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h b/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h index 5a88c01dd6..f192c55cc9 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h @@ -10,7 +10,7 @@ class CCBReader; class CCLayerColorLoader : public CCLayerLoader { public: - STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerColorLoader, loader); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerColorLoader, loader); protected: virtual CCLayerColor * createCCNode(CCNode *, CCBReader *); diff --git a/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h b/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h index 9ee3dc2074..a1ab521b8b 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h @@ -10,7 +10,7 @@ class CCBReader; class CCLayerGradientLoader : public CCLayerLoader { public: - STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerGradientLoader, loader); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerGradientLoader, loader); protected: virtual CCLayerGradient * createCCNode(CCNode *, CCBReader *); diff --git a/cocos2dx/extensions/CCBReader/CCLayerLoader.h b/cocos2dx/extensions/CCBReader/CCLayerLoader.h index 33a1119058..a049359650 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLayerLoader.h @@ -10,7 +10,7 @@ class CCBReader; class CCLayerLoader : public CCNodeLoader { public: - STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerLoader, loader); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerLoader, loader); protected: virtual CCLayer * createCCNode(CCNode *, CCBReader *); diff --git a/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h b/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h index d37515173b..5cb0df02b2 100644 --- a/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h +++ b/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h @@ -10,7 +10,7 @@ class CCBReader; class CCMenuItemImageLoader : public CCMenuItemLoader { public: - STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCMenuItemImageLoader, loader); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCMenuItemImageLoader, loader); protected: virtual CCMenuItemImage * createCCNode(CCNode *, CCBReader *); diff --git a/cocos2dx/extensions/CCBReader/CCMenuLoader.h b/cocos2dx/extensions/CCBReader/CCMenuLoader.h index 333c781993..8a055e951e 100644 --- a/cocos2dx/extensions/CCBReader/CCMenuLoader.h +++ b/cocos2dx/extensions/CCBReader/CCMenuLoader.h @@ -10,7 +10,7 @@ class CCBReader; class CCMenuLoader : public CCLayerLoader { public: - STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCMenuLoader, loader); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCMenuLoader, loader); protected: virtual CCMenu * createCCNode(CCNode *, CCBReader *); diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoader.h b/cocos2dx/extensions/CCBReader/CCNodeLoader.h index 3e0143ed8a..141592ae5e 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoader.h +++ b/cocos2dx/extensions/CCBReader/CCNodeLoader.h @@ -6,6 +6,10 @@ NS_CC_EXT_BEGIN +#define CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(T) virtual T * createCCNode(cocos2d::CCNode * pParent, cocos2d::extension::CCBReader * pCCBReader) { \ +return T::node(); \ +} + struct BlockData { SEL_MenuHandler mSELMenuHandler; CCObject * mTarget; @@ -22,7 +26,7 @@ class CCBReader; class CC_DLL CCNodeLoader : public CCObject { public: - STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCNodeLoader, loader); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCNodeLoader, loader); virtual CCNode * loadCCNode(CCNode *, CCBReader * pCCBReader); virtual void parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h index a5605b6adb..aab5fb8cd4 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h +++ b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h @@ -14,7 +14,7 @@ class CC_DLL CCNodeLoaderLibrary : public CCObject { CCNodeLoaderMap mCCNodeLoaders; public: - STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCNodeLoaderLibrary, library); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCNodeLoaderLibrary, library); CCNodeLoaderLibrary(); ~CCNodeLoaderLibrary(); diff --git a/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h b/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h index 65c50818eb..1a22846137 100644 --- a/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h +++ b/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h @@ -10,7 +10,7 @@ class CCBReader; class CCParticleSystemQuadLoader : public CCNodeLoader { public: - STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCParticleSystemQuadLoader, loader); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCParticleSystemQuadLoader, loader); protected: virtual CCParticleSystemQuad * createCCNode(CCNode *, CCBReader *); diff --git a/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h b/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h index c47341ce19..7f1d8f3809 100644 --- a/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h +++ b/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h @@ -10,7 +10,7 @@ class CCBReader; class CCScale9SpriteLoader : public CCNodeLoader { public: - STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCScale9SpriteLoader, loader); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCScale9SpriteLoader, loader); protected: virtual CCScale9Sprite * createCCNode(CCNode *, CCBReader *); diff --git a/cocos2dx/extensions/CCBReader/CCSpriteLoader.h b/cocos2dx/extensions/CCBReader/CCSpriteLoader.h index 8be9434206..b86031aad1 100644 --- a/cocos2dx/extensions/CCBReader/CCSpriteLoader.h +++ b/cocos2dx/extensions/CCBReader/CCSpriteLoader.h @@ -10,7 +10,7 @@ class CCBReader; class CCSpriteLoader : public CCNodeLoader { public: - STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCSpriteLoader, loader); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCSpriteLoader, loader); protected: virtual CCSprite * createCCNode(CCNode *, CCBReader *); diff --git a/tests/Android.mk b/tests/Android.mk index 5f54ef168e..a93dee4d08 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -45,12 +45,9 @@ tests/ExtensionsTest/ControlExtensionTest/CCControlColourPicker/CCControlColourP tests/ExtensionsTest/ControlExtensionTest/CCControlSliderTest/CCControlSliderTest.cpp \ tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp \ tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp \ -tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.cpp \ -tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayerLoader.cpp \ -tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.cpp \ -tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayerLoader.cpp \ -tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.cpp \ -tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayerLoader.cpp \ +tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp \ +tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp \ +tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp \ tests/FontTest/FontTest.cpp \ tests/IntervalTest/IntervalTest.cpp \ tests/KeypadTest/KeypadTest.cpp \ diff --git a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id index e0d9ca4b0d..6c826f4f8c 100644 --- a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -07809358e6957eaaec6329a5211294cf3bbc9105 \ No newline at end of file +d727e1e6cfa9788ab0caf37b3c27d2c85bbf9c75 \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp similarity index 100% rename from tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.cpp rename to tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h similarity index 100% rename from tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayer.h rename to tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayerLoader.h b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayerLoader.h similarity index 63% rename from tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayerLoader.h rename to tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayerLoader.h index bacacbfc8b..eb8be854eb 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayerLoader.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayerLoader.h @@ -9,10 +9,10 @@ class CCBReader; class ButtonTestLayerLoader : public cocos2d::extension::CCLayerLoader { public: - STATIC_NEW_AUTORELEASE_OBJECT_METHOD(ButtonTestLayerLoader, loader); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(ButtonTestLayerLoader, loader); protected: - virtual ButtonTestLayer * createCCNode(cocos2d::CCNode *, cocos2d::extension::CCBReader *); + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(ButtonTestLayer); }; #endif diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayerLoader.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayerLoader.cpp deleted file mode 100644 index 88778d7fa5..0000000000 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTestLayerLoader.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "ButtonTestLayerLoader.h" - -USING_NS_CC; -USING_NS_CC_EXT; - -ButtonTestLayer * ButtonTestLayerLoader::createCCNode(CCNode * pParent, cocos2d::extension::CCBReader * pCCBReader) { - return ButtonTestLayer::node(); -} \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp index 34e89c9fdf..62f1089b12 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp @@ -26,7 +26,7 @@ #include "../../testResource.h" #include "extensions/CCBReader/CCBReader.h" #include "extensions/CCBReader/CCNodeLoaderLibrary.h" -#include "HelloCocosBuilderLayerLoader.h" +#include "HelloCocosBuilder/HelloCocosBuilderLayerLoader.h" USING_NS_CC; USING_NS_CC_EXT; diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp similarity index 98% rename from tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.cpp rename to tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp index 7ec673abce..8e622cc9c8 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.cpp +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp @@ -3,9 +3,8 @@ #include "extensions/CCBReader/CCBReader.h" #include "extensions/CCBReader/CCNodeLoaderLibrary.h" -#include "TestHeaderLayerLoader.h" -#include "ButtonTestLayerLoader.h" -#include "CCTransition.h" +#include "../TestHeader/TestHeaderLayerLoader.h" +#include "../ButtonTest/ButtonTestLayerLoader.h" USING_NS_CC; USING_NS_CC_EXT; diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h similarity index 100% rename from tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayer.h rename to tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayerLoader.h b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayerLoader.h similarity index 63% rename from tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayerLoader.h rename to tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayerLoader.h index 2795d04740..73f73b2401 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayerLoader.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayerLoader.h @@ -9,10 +9,10 @@ class CCBReader; class HelloCocosBuilderLayerLoader : public cocos2d::extension::CCLayerLoader { public: - STATIC_NEW_AUTORELEASE_OBJECT_METHOD(HelloCocosBuilderLayerLoader, loader); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(HelloCocosBuilderLayerLoader, loader); protected: - virtual HelloCocosBuilderLayer * createCCNode(cocos2d::CCNode *, cocos2d::extension::CCBReader *); + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(HelloCocosBuilderLayer); }; #endif diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayerLoader.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayerLoader.cpp deleted file mode 100644 index 10bb08dd21..0000000000 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilderLayerLoader.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "HelloCocosBuilderLayerLoader.h" - -USING_NS_CC; -USING_NS_CC_EXT; - -HelloCocosBuilderLayer * HelloCocosBuilderLayerLoader::createCCNode(CCNode * pParent, cocos2d::extension::CCBReader * pCCBReader) { - return HelloCocosBuilderLayer::node(); -} \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp similarity index 100% rename from tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.cpp rename to tests/tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h similarity index 100% rename from tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayer.h rename to tests/tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayerLoader.h b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayerLoader.h similarity index 63% rename from tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayerLoader.h rename to tests/tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayerLoader.h index 37e4cc3ee2..1e757662d4 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayerLoader.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayerLoader.h @@ -9,10 +9,10 @@ class CCBReader; class TestHeaderLayerLoader : public cocos2d::extension::CCLayerLoader { public: - STATIC_NEW_AUTORELEASE_OBJECT_METHOD(TestHeaderLayerLoader, loader); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(TestHeaderLayerLoader, loader); protected: - virtual TestHeaderLayer * createCCNode(cocos2d::CCNode *, cocos2d::extension::CCBReader *); + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(TestHeaderLayer); }; #endif diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayerLoader.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayerLoader.cpp deleted file mode 100644 index 024047b31a..0000000000 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeaderLayerLoader.cpp +++ /dev/null @@ -1,8 +0,0 @@ -#include "TestHeaderLayerLoader.h" - -USING_NS_CC; -USING_NS_CC_EXT; - -TestHeaderLayer * TestHeaderLayerLoader::createCCNode(CCNode * pParent, cocos2d::extension::CCBReader * pCCBReader) { - return TestHeaderLayer::node(); -} \ No newline at end of file From 8d7dce09993f263c70c6d88516783a1b4b188a7d Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Thu, 14 Jun 2012 18:16:54 -0700 Subject: [PATCH 173/257] Added glue macros to reduce boilerplate code when implementing CCBSelectorResolver and CCBMemberVariableAssigner. Added LabelTest, MenuTest and SpriteTest. --- .../CCBReader/CCBMemberVariableAssigner.h | 7 +++ cocos2dx/extensions/CCBReader/CCBReader.h | 20 +++++- .../CCBReader/CCBSelectorResolver.h | 10 ++- .../extensions/CCBReader/CCNodeLoader.cpp | 4 +- tests/Android.mk | 1 + .../project.pbxproj.REMOVED.git-id | 2 +- .../ButtonTest/ButtonTestLayer.cpp | 29 ++------- .../ButtonTest/ButtonTestLayer.h | 4 +- .../HelloCocosBuilderLayer.cpp | 61 ++++++------------- .../HelloCocosBuilderLayer.h | 4 +- .../LabelTest/LabelTestLayer.h | 12 ++++ .../LabelTest/LabelTestLayerLoader.h | 18 ++++++ .../MenuTest/MenuTestLayer.cpp | 37 +++++++++++ .../CocosBuilderTest/MenuTest/MenuTestLayer.h | 25 ++++++++ .../MenuTest/MenuTestLayerLoader.h | 18 ++++++ .../SpriteTest/SpriteTestLayer.h | 12 ++++ .../SpriteTest/SpriteTestLayerLoader.h | 18 ++++++ .../TestHeader/TestHeaderLayer.cpp | 17 +----- .../TestHeader/TestHeaderLayer.h | 4 +- 19 files changed, 207 insertions(+), 96 deletions(-) create mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/LabelTest/LabelTestLayer.h create mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/LabelTest/LabelTestLayerLoader.h create mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp create mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h create mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayerLoader.h create mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/SpriteTest/SpriteTestLayer.h create mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/SpriteTest/SpriteTestLayerLoader.h diff --git a/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h b/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h index 370a39ac42..96dbbf8e73 100644 --- a/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h +++ b/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h @@ -5,6 +5,13 @@ NS_CC_EXT_BEGIN +#define CCB_MEMBERVARIABLEASSIGNER_GLUE(TARGET, MEMBERVARIABLENAME, MEMBERVARIABLETYPE, MEMBERVARIABLE) if(pTarget == TARGET && pMemberVariableName->compare(MEMBERVARIABLENAME) == 0) { \ + MEMBERVARIABLE = dynamic_cast(pNode); \ + CC_ASSERT(MEMBERVARIABLE); \ + MEMBERVARIABLE->retain(); \ + return true; \ +} + class CCBMemberVariableAssigner { public: virtual bool onAssignCCBMemberVariable(CCObject * pTarget, cocos2d::CCString * pMemberVariableName, CCNode * pNode) = 0; diff --git a/cocos2dx/extensions/CCBReader/CCBReader.h b/cocos2dx/extensions/CCBReader/CCBReader.h index 859bc3228c..155ebfe54d 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader.h +++ b/cocos2dx/extensions/CCBReader/CCBReader.h @@ -4,9 +4,23 @@ #include "cocos2d.h" #define CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(T, METHOD) static T * METHOD() { \ -T * t = new T(); \ -t->autorelease(); \ -return t; \ + T * ptr = new T(); \ + if(ptr != NULL) { \ + ptr->autorelease(); \ + return ptr; \ + } \ + CC_SAFE_DELETE(ptr); \ + return NULL; \ +} + +#define CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(T, METHOD) static T * METHOD() { \ + T * ptr = new T(); \ + if(ptr != NULL && ptr->init()) { \ + ptr->autorelease(); \ + return ptr; \ + } \ + CC_SAFE_DELETE(ptr); \ + return NULL; \ } #define kCCBVersion 2 diff --git a/cocos2dx/extensions/CCBReader/CCBSelectorResolver.h b/cocos2dx/extensions/CCBReader/CCBSelectorResolver.h index 08bad62358..1ff2c2b48f 100644 --- a/cocos2dx/extensions/CCBReader/CCBSelectorResolver.h +++ b/cocos2dx/extensions/CCBReader/CCBSelectorResolver.h @@ -5,9 +5,17 @@ NS_CC_EXT_BEGIN +#define CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(TARGET, SELECTORNAME, METHOD) if(pTarget == TARGET && pSelectorName->compare(SELECTORNAME) == 0) { \ + return menu_selector(METHOD); \ +} + +#define CCB_SELECTORRESOLVER_CCCONTROL_GLUE(TARGET, SELECTORNAME, METHOD) if(pTarget == TARGET && pSelectorName->compare(SELECTORNAME) == 0) { \ + return cccontrol_selector(METHOD); \ +} + class CCBSelectorResolver { public: - virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(CCObject * pTarget, CCString * pSelectorName) = 0; + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName) = 0; virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(CCObject * pTarget, CCString * pSelectorName) = 0; }; diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp index e14056cb06..53bc15040f 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp @@ -567,12 +567,12 @@ BlockData * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, C CCBSelectorResolver * targetAsCCBSelectorResolver = dynamic_cast(target); if(targetAsCCBSelectorResolver != NULL) { - selMenuHandler = targetAsCCBSelectorResolver->onResolveCCBCCMenuSelector(target, selectorName); + selMenuHandler = targetAsCCBSelectorResolver->onResolveCCBCCMenuItemSelector(target, selectorName); } if(selMenuHandler == 0) { CCBSelectorResolver * ccbSelectorResolver = pCCBReader->getCCBSelectorResolver(); if(ccbSelectorResolver != NULL) { - selMenuHandler = ccbSelectorResolver->onResolveCCBCCMenuSelector(target, selectorName); + selMenuHandler = ccbSelectorResolver->onResolveCCBCCMenuItemSelector(target, selectorName); } } diff --git a/tests/Android.mk b/tests/Android.mk index a93dee4d08..c9fe5eba53 100644 --- a/tests/Android.mk +++ b/tests/Android.mk @@ -48,6 +48,7 @@ tests/ExtensionsTest/CocosBuilderTest/CocosBuilderTest.cpp \ tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp \ tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp \ tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp \ +tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp \ tests/FontTest/FontTest.cpp \ tests/IntervalTest/IntervalTest.cpp \ tests/KeypadTest/KeypadTest.cpp \ diff --git a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id index 6c826f4f8c..14135b7a59 100644 --- a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -d727e1e6cfa9788ab0caf37b3c27d2c85bbf9c75 \ No newline at end of file +862a940ac3fd58a64c60cec2e314ac0c7dc8d95a \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp index a8bb330c03..5ccf142ea6 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp @@ -5,38 +5,19 @@ USING_NS_CC; USING_NS_CC_EXT; -ButtonTestLayer * ButtonTestLayer::node() { - ButtonTestLayer * ptr = new ButtonTestLayer(); - if(ptr && ptr->init()) { - ptr->autorelease(); - return ptr; - } - CC_SAFE_DELETE(ptr); - return NULL; -} - -SEL_MenuHandler ButtonTestLayer::onResolveCCBCCMenuSelector(CCObject * pTarget, CCString * pSelectorName) { +SEL_MenuHandler ButtonTestLayer::onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName) { return NULL; } SEL_CCControlHandler ButtonTestLayer::onResolveCCBCCControlSelector(CCObject * pTarget, CCString * pSelectorName) { - if(pTarget == this) { - if(pSelectorName->compare("onCCControlButtonClicked") == 0) { - return cccontrol_selector(ButtonTestLayer::onCCControlButtonClicked); - } - } + CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onCCControlButtonClicked", ButtonTestLayer::onCCControlButtonClicked); + return NULL; } bool ButtonTestLayer::onAssignCCBMemberVariable(CCObject * pTarget, CCString * pMemberVariableName, CCNode * pNode) { - if(pTarget == this) { - if(strcmp(pMemberVariableName->getCString(), "mCCControlEventLabel") == 0) { - this->mCCControlEventLabel = dynamic_cast(pNode); - CC_ASSERT(this->mCCControlEventLabel); - this->mCCControlEventLabel->retain(); - return true; - } - } + CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mCCControlEventLabel", CCLabelBMFont *, this->mCCControlEventLabel); + return false; } diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h index a8c6dcbd7d..e63798a69c 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h @@ -8,9 +8,9 @@ class ButtonTestLayer : public cocos2d::extension::CCBSelectorResolver, public cocos2d::extension::CCBMemberVariableAssigner, public cocos2d::CCLayer { public: - static ButtonTestLayer * node(); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(ButtonTestLayer, node); - virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); virtual bool onAssignCCBMemberVariable(cocos2d::CCObject * pTarget, cocos2d::CCString * pMemberVariableName, cocos2d::CCNode * pNode); diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp index 8e622cc9c8..164ee1dd24 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp @@ -4,21 +4,14 @@ #include "extensions/CCBReader/CCNodeLoaderLibrary.h" #include "../TestHeader/TestHeaderLayerLoader.h" +#include "../LabelTest/LabelTestLayerLoader.h" #include "../ButtonTest/ButtonTestLayerLoader.h" +#include "../SpriteTest/SpriteTestLayerLoader.h" +#include "../MenuTest/MenuTestLayerLoader.h" USING_NS_CC; USING_NS_CC_EXT; -HelloCocosBuilderLayer * HelloCocosBuilderLayer::node() { - HelloCocosBuilderLayer * ptr = new HelloCocosBuilderLayer(); - if(ptr && ptr->init()) { - ptr->autorelease(); - return ptr; - } - CC_SAFE_DELETE(ptr); - return NULL; -} - void HelloCocosBuilderLayer::openTest(const char * pCCBFileName, const char * pCCNodeName, CCNodeLoader * pCCNodeLoader) { /* Create an autorelease CCNodeLoaderLibrary. */ CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary(); @@ -63,63 +56,43 @@ void HelloCocosBuilderLayer::onNodeLoaded(cocos2d::CCNode * pNode, cocos2d::exte } -SEL_MenuHandler HelloCocosBuilderLayer::onResolveCCBCCMenuSelector(CCObject * pTarget, CCString * pSelectorName) { +SEL_MenuHandler HelloCocosBuilderLayer::onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName) { return NULL; } SEL_CCControlHandler HelloCocosBuilderLayer::onResolveCCBCCControlSelector(CCObject * pTarget, CCString * pSelectorName) { - if(pTarget == this) { - if(strcmp(pSelectorName->getCString(), "onMenuTestClicked") == 0) { - return cccontrol_selector(HelloCocosBuilderLayer::onMenuTestClicked); - } else if(strcmp(pSelectorName->getCString(), "onSpriteTestClicked") == 0) { - return cccontrol_selector(HelloCocosBuilderLayer::onSpriteTestClicked); - } else if(strcmp(pSelectorName->getCString(), "onButtonTestClicked") == 0) { - return cccontrol_selector(HelloCocosBuilderLayer::onButtonTestClicked); - } else if(strcmp(pSelectorName->getCString(), "onLabelTestClicked") == 0) { - return cccontrol_selector(HelloCocosBuilderLayer::onLabelTestClicked); - } else if(strcmp(pSelectorName->getCString(), "onParticleSystemTestClicked") == 0) { - return cccontrol_selector(HelloCocosBuilderLayer::onParticleSystemTestClicked); - } else if(strcmp(pSelectorName->getCString(), "onScrollViewTestClicked") == 0) { - return cccontrol_selector(HelloCocosBuilderLayer::onScrollViewTestClicked); - } - } + CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onMenuTestClicked", HelloCocosBuilderLayer::onMenuTestClicked); + CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onSpriteTestClicked", HelloCocosBuilderLayer::onSpriteTestClicked); + CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onButtonTestClicked", HelloCocosBuilderLayer::onButtonTestClicked); + CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onLabelTestClicked", HelloCocosBuilderLayer::onLabelTestClicked); + CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onParticleSystemTestClicked", HelloCocosBuilderLayer::onParticleSystemTestClicked); + CCB_SELECTORRESOLVER_CCCONTROL_GLUE(this, "onScrollViewTestClicked", HelloCocosBuilderLayer::onScrollViewTestClicked); + return NULL; } - bool HelloCocosBuilderLayer::onAssignCCBMemberVariable(CCObject * pTarget, CCString * pMemberVariableName, CCNode * pNode) { - if(pTarget == this) { - if(strcmp(pMemberVariableName->getCString(), "mBurstSprite") == 0) { - this->mBurstSprite = dynamic_cast(pNode); - CC_ASSERT(this->mBurstSprite); - this->mBurstSprite->retain(); - return true; - } else if(strcmp(pMemberVariableName->getCString(), "mTestTitleLabel") == 0) { - this->mTestTitleLabelTTF = dynamic_cast(pNode); - CC_ASSERT(this->mTestTitleLabelTTF); - this->mTestTitleLabelTTF->retain(); - return true; - } - } + CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mBurstSprite", CCSprite *, this->mBurstSprite); + CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mTestTitleLabel", CCLabelTTF *, this->mTestTitleLabelTTF); + return false; } void HelloCocosBuilderLayer::onMenuTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - CCLog("onMenuTestClicked\n"); + this->openTest("ccb/MenuTest.ccbi", "MenuTestLayer", MenuTestLayerLoader::loader()); } void HelloCocosBuilderLayer::onSpriteTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - CCLog("onSpriteTestClicked\n"); + this->openTest("ccb/SpriteTest.ccbi", "SpriteTestLayer", SpriteTestLayerLoader::loader()); } void HelloCocosBuilderLayer::onButtonTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - CCLog("onButtonTestClicked\n"); this->openTest("ccb/ButtonTest.ccbi", "ButtonTestLayer", ButtonTestLayerLoader::loader()); } void HelloCocosBuilderLayer::onLabelTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - CCLog("onLabelTestClicked\n"); + this->openTest("ccb/LabelTest.ccbi", "LabelTestLayer", LabelTestLayerLoader::loader()); } void HelloCocosBuilderLayer::onParticleSystemTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h index 9001cbbb98..6244a042dc 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h @@ -19,11 +19,11 @@ */ class HelloCocosBuilderLayer : public cocos2d::extension::CCBSelectorResolver, public cocos2d::extension::CCBMemberVariableAssigner, public cocos2d::extension::CCNodeLoaderListener, public cocos2d::CCLayer { public: - static HelloCocosBuilderLayer * node(); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(HelloCocosBuilderLayer, node); void openTest(const char * pCCBFileName, const char * pCCNodeName = NULL, cocos2d::extension::CCNodeLoader * pCCNodeLoader = NULL); - virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); virtual bool onAssignCCBMemberVariable(cocos2d::CCObject * pTarget, cocos2d::CCString * pMemberVariableName, cocos2d::CCNode * pNode); virtual void onNodeLoaded(cocos2d::CCNode * pNode, cocos2d::extension::CCNodeLoader * pNodeLoader); diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/LabelTest/LabelTestLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/LabelTest/LabelTestLayer.h new file mode 100644 index 0000000000..8d72c06299 --- /dev/null +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/LabelTest/LabelTestLayer.h @@ -0,0 +1,12 @@ +#ifndef _LABELTESTLAYER_H_ +#define _LABELTESTLAYER_H_ + +#include "cocos2d.h" +#include "extensions/CCBReader/CCBReader.h" + +class LabelTestLayer : public cocos2d::CCLayer { + public: + CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(LabelTestLayer, node); +}; + +#endif \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/LabelTest/LabelTestLayerLoader.h b/tests/tests/ExtensionsTest/CocosBuilderTest/LabelTest/LabelTestLayerLoader.h new file mode 100644 index 0000000000..affbac5008 --- /dev/null +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/LabelTest/LabelTestLayerLoader.h @@ -0,0 +1,18 @@ +#ifndef _LABELTESTLAYERLOADER_H_ +#define _LABELTESTLAYERLOADER_H_ + +#include "extensions/CCBReader/CCLayerLoader.h" +#include "LabelTestLayer.h" + +/* Forward declaration. */ +class CCBReader; + +class LabelTestLayerLoader : public cocos2d::extension::CCLayerLoader { + public: + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(LabelTestLayerLoader, loader); + + protected: + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(LabelTestLayer); +}; + +#endif diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp new file mode 100644 index 0000000000..9204ea6044 --- /dev/null +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp @@ -0,0 +1,37 @@ +#include "MenuTestLayer.h" + +#include "extensions/CCBReader/CCBReader.h" + +USING_NS_CC; +USING_NS_CC_EXT; + + +SEL_MenuHandler MenuTestLayer::onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName) { + CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(this, "onMenuItemAClicked", MenuTestLayer::onMenuItemAClicked); + CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(this, "onMenuItemBClicked", MenuTestLayer::onMenuItemBClicked); + CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(this, "onMenuItemCClicked", MenuTestLayer::onMenuItemCClicked); + + return NULL; +} + +SEL_CCControlHandler MenuTestLayer::onResolveCCBCCControlSelector(CCObject * pTarget, CCString * pSelectorName) { + return NULL; +} + +bool MenuTestLayer::onAssignCCBMemberVariable(CCObject * pTarget, CCString * pMemberVariableName, CCNode * pNode) { + CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mMenuItemStatusLabelBMFont", CCLabelBMFont *, this->mMenuItemStatusLabelBMFont); + + return false; +} + +void MenuTestLayer::onMenuItemAClicked(cocos2d::CCObject *pSender) { + this->mMenuItemStatusLabelBMFont->setString("Menu Item A clicked."); +} + +void MenuTestLayer::onMenuItemBClicked(cocos2d::CCObject *pSender) { + this->mMenuItemStatusLabelBMFont->setString("Menu Item B clicked."); +} + +void MenuTestLayer::onMenuItemCClicked(cocos2d::CCObject *pSender) { + this->mMenuItemStatusLabelBMFont->setString("Menu Item C clicked."); +} \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h new file mode 100644 index 0000000000..a764368082 --- /dev/null +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h @@ -0,0 +1,25 @@ +#ifndef _MENUTESTLAYER_H_ +#define _MENUTESTLAYER_H_ + +#include "cocos2d.h" +#include "extensions/CCBReader/CCNodeLoader.h" +#include "extensions/CCBReader/CCBSelectorResolver.h" +#include "extensions/CCBReader/CCBMemberVariableAssigner.h" + +class MenuTestLayer : public cocos2d::extension::CCBSelectorResolver, public cocos2d::extension::CCBMemberVariableAssigner, public cocos2d::CCLayer { + public: + CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(MenuTestLayer, node); + + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); + virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); + virtual bool onAssignCCBMemberVariable(cocos2d::CCObject * pTarget, cocos2d::CCString * pMemberVariableName, cocos2d::CCNode * pNode); + + virtual void onMenuItemAClicked(cocos2d::CCObject * pSender); + virtual void onMenuItemBClicked(cocos2d::CCObject * pSender); + virtual void onMenuItemCClicked(cocos2d::CCObject * pSender); + + private: + cocos2d::CCLabelBMFont * mMenuItemStatusLabelBMFont; +}; + +#endif \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayerLoader.h b/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayerLoader.h new file mode 100644 index 0000000000..37cf0a034a --- /dev/null +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayerLoader.h @@ -0,0 +1,18 @@ +#ifndef _MENUTESTLAYERLOADER_H_ +#define _MENUTESTLAYERLOADER_H_ + +#include "extensions/CCBReader/CCLayerLoader.h" +#include "MenuTestLayer.h" + +/* Forward declaration. */ +class CCBReader; + +class MenuTestLayerLoader : public cocos2d::extension::CCLayerLoader { + public: + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(MenuTestLayerLoader, loader); + + protected: + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(MenuTestLayer); +}; + +#endif diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/SpriteTest/SpriteTestLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/SpriteTest/SpriteTestLayer.h new file mode 100644 index 0000000000..11bce158c1 --- /dev/null +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/SpriteTest/SpriteTestLayer.h @@ -0,0 +1,12 @@ +#ifndef _SPRITETESTLAYER_H_ +#define _SPRITETESTLAYER_H_ + +#include "cocos2d.h" +#include "extensions/CCBReader/CCBReader.h" + +class SpriteTestLayer : public cocos2d::CCLayer { + public: + CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(SpriteTestLayer, node); +}; + +#endif \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/SpriteTest/SpriteTestLayerLoader.h b/tests/tests/ExtensionsTest/CocosBuilderTest/SpriteTest/SpriteTestLayerLoader.h new file mode 100644 index 0000000000..6dc62f03d7 --- /dev/null +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/SpriteTest/SpriteTestLayerLoader.h @@ -0,0 +1,18 @@ +#ifndef _SPRITETESTLAYERLOADER_H_ +#define _SPRITETESTLAYERLOADER_H_ + +#include "extensions/CCBReader/CCLayerLoader.h" +#include "SpriteTestLayer.h" + +/* Forward declaration. */ +class CCBReader; + +class SpriteTestLayerLoader : public cocos2d::extension::CCLayerLoader { + public: + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(SpriteTestLayerLoader, loader); + + protected: + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(SpriteTestLayer); +}; + +#endif diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp index ab17519682..1d0bc3915b 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.cpp @@ -5,22 +5,9 @@ USING_NS_CC; USING_NS_CC_EXT; -TestHeaderLayer * TestHeaderLayer::node() { - TestHeaderLayer * ptr = new TestHeaderLayer(); - if(ptr && ptr->init()) { - ptr->autorelease(); - return ptr; - } - CC_SAFE_DELETE(ptr); - return NULL; -} +SEL_MenuHandler TestHeaderLayer::onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName) { + CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(this, "onBackClicked", TestHeaderLayer::onBackClicked); -SEL_MenuHandler TestHeaderLayer::onResolveCCBCCMenuSelector(CCObject * pTarget, CCString * pSelectorName) { - if(pTarget == this) { - if(pSelectorName->compare("onBackClicked") == 0) { - return menu_selector(TestHeaderLayer::onBackClicked); - } - } return NULL; } diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h index 4470d8acf3..6cbe677b1a 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h @@ -7,9 +7,9 @@ class TestHeaderLayer : public cocos2d::extension::CCBSelectorResolver, public cocos2d::CCLayer { public: - static TestHeaderLayer * node(); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(TestHeaderLayer, node); - virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); virtual void onBackClicked(cocos2d::CCObject * pSender); From 6aa1879f84f6a37b3131b0c9fc6340dab3919fe0 Mon Sep 17 00:00:00 2001 From: folecr Date: Thu, 14 Jun 2012 18:39:56 -0700 Subject: [PATCH 174/257] Add gen/ and local.properties to gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 8b619efdb3..877c40389b 100644 --- a/.gitignore +++ b/.gitignore @@ -32,10 +32,12 @@ _ReSharper*/ libs/ bin/ obj/ +gen/ assets/ .classpath .project .cproject +local.properties # Ignore files build by linux *.o From b6164c7590117e0bd0688e2190772517a88ec80e Mon Sep 17 00:00:00 2001 From: folecr Date: Mon, 21 May 2012 15:20:18 -0700 Subject: [PATCH 175/257] Create a library named cocos2dandroid * Based on sources from HelloWorld that should be common across all cocos2d-x android projects * Rename, use prefix cocos2dx_default_ for items in layout * Project files for android library, targeted to android-8 --- .../platform/android/java/AndroidManifest.xml | 6 ++ cocos2dx/platform/android/java/ant.properties | 17 ++++ cocos2dx/platform/android/java/build.xml | 83 +++++++++++++++++++ .../android/java/proguard-project.txt | 20 +++++ .../platform/android/java/project.properties | 15 ++++ .../layout/cocos2dx_default_screen_layout.xml | 4 +- .../cocos2dx/lib/Cocos2dxAccelerometer.java | 0 .../org/cocos2dx/lib/Cocos2dxActivity.java | 0 .../src/org/cocos2dx/lib/Cocos2dxBitmap.java | 0 .../org/cocos2dx/lib/Cocos2dxEditText.java | 0 .../cocos2dx/lib/Cocos2dxGLSurfaceView.java | 0 .../src/org/cocos2dx/lib/Cocos2dxMusic.java | 0 .../org/cocos2dx/lib/Cocos2dxRenderer.java | 0 .../src/org/cocos2dx/lib/Cocos2dxSound.java | 0 .../org/cocos2dx/lib/Cocos2dxTypefaces.java | 0 15 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 cocos2dx/platform/android/java/AndroidManifest.xml create mode 100644 cocos2dx/platform/android/java/ant.properties create mode 100644 cocos2dx/platform/android/java/build.xml create mode 100644 cocos2dx/platform/android/java/proguard-project.txt create mode 100644 cocos2dx/platform/android/java/project.properties rename HelloWorld/proj.android/res/layout/helloworld_demo.xml => cocos2dx/platform/android/java/res/layout/cocos2dx_default_screen_layout.xml (80%) rename {HelloWorld/proj.android => cocos2dx/platform/android/java}/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java (100%) rename {HelloWorld/proj.android => cocos2dx/platform/android/java}/src/org/cocos2dx/lib/Cocos2dxActivity.java (100%) rename {HelloWorld/proj.android => cocos2dx/platform/android/java}/src/org/cocos2dx/lib/Cocos2dxBitmap.java (100%) rename {HelloWorld/proj.android => cocos2dx/platform/android/java}/src/org/cocos2dx/lib/Cocos2dxEditText.java (100%) rename {HelloWorld/proj.android => cocos2dx/platform/android/java}/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java (100%) rename {HelloWorld/proj.android => cocos2dx/platform/android/java}/src/org/cocos2dx/lib/Cocos2dxMusic.java (100%) rename {HelloWorld/proj.android => cocos2dx/platform/android/java}/src/org/cocos2dx/lib/Cocos2dxRenderer.java (100%) rename {HelloWorld/proj.android => cocos2dx/platform/android/java}/src/org/cocos2dx/lib/Cocos2dxSound.java (100%) rename {HelloWorld/proj.android => cocos2dx/platform/android/java}/src/org/cocos2dx/lib/Cocos2dxTypefaces.java (100%) diff --git a/cocos2dx/platform/android/java/AndroidManifest.xml b/cocos2dx/platform/android/java/AndroidManifest.xml new file mode 100644 index 0000000000..d93da3f7f9 --- /dev/null +++ b/cocos2dx/platform/android/java/AndroidManifest.xml @@ -0,0 +1,6 @@ + + + diff --git a/cocos2dx/platform/android/java/ant.properties b/cocos2dx/platform/android/java/ant.properties new file mode 100644 index 0000000000..b0971e891e --- /dev/null +++ b/cocos2dx/platform/android/java/ant.properties @@ -0,0 +1,17 @@ +# This file is used to override default values used by the Ant build system. +# +# This file must be checked into Version Control Systems, as it is +# integral to the build system of your project. + +# This file is only used by the Ant script. + +# You can use this to override default values such as +# 'source.dir' for the location of your java source folder and +# 'out.dir' for the location of your output folder. + +# You can also use it define how the release builds are signed by declaring +# the following properties: +# 'key.store' for the location of your keystore and +# 'key.alias' for the name of the key to use. +# The password will be asked during the build when you use the 'release' target. + diff --git a/cocos2dx/platform/android/java/build.xml b/cocos2dx/platform/android/java/build.xml new file mode 100644 index 0000000000..885e6eed8a --- /dev/null +++ b/cocos2dx/platform/android/java/build.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/cocos2dx/platform/android/java/proguard-project.txt b/cocos2dx/platform/android/java/proguard-project.txt new file mode 100644 index 0000000000..f2fe1559a2 --- /dev/null +++ b/cocos2dx/platform/android/java/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/cocos2dx/platform/android/java/project.properties b/cocos2dx/platform/android/java/project.properties new file mode 100644 index 0000000000..cd0ca122a3 --- /dev/null +++ b/cocos2dx/platform/android/java/project.properties @@ -0,0 +1,15 @@ +# This file is automatically generated by Android Tools. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file must be checked in Version Control Systems. +# +# To customize properties used by the Ant build system edit +# "ant.properties", and override values to adapt the script to your +# project structure. +# +# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): +#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt + +android.library=true +# Project target. +target=android-8 diff --git a/HelloWorld/proj.android/res/layout/helloworld_demo.xml b/cocos2dx/platform/android/java/res/layout/cocos2dx_default_screen_layout.xml similarity index 80% rename from HelloWorld/proj.android/res/layout/helloworld_demo.xml rename to cocos2dx/platform/android/java/res/layout/cocos2dx_default_screen_layout.xml index e684f4c4e0..18a9ec1f6b 100644 --- a/HelloWorld/proj.android/res/layout/helloworld_demo.xml +++ b/cocos2dx/platform/android/java/res/layout/cocos2dx_default_screen_layout.xml @@ -5,13 +5,13 @@ android:orientation="vertical"> diff --git a/HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java similarity index 100% rename from HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java rename to cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java diff --git a/HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxActivity.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java similarity index 100% rename from HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxActivity.java rename to cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java diff --git a/HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java similarity index 100% rename from HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java rename to cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java diff --git a/HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxEditText.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditText.java similarity index 100% rename from HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxEditText.java rename to cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditText.java diff --git a/HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java similarity index 100% rename from HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java rename to cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java diff --git a/HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxMusic.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxMusic.java similarity index 100% rename from HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxMusic.java rename to cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxMusic.java diff --git a/HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxRenderer.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxRenderer.java similarity index 100% rename from HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxRenderer.java rename to cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxRenderer.java diff --git a/HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxSound.java similarity index 100% rename from HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java rename to cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxSound.java diff --git a/HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxTypefaces.java b/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxTypefaces.java similarity index 100% rename from HelloWorld/proj.android/src/org/cocos2dx/lib/Cocos2dxTypefaces.java rename to cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxTypefaces.java From 6bd444913c88752e1a9767f4ff597faa3e96b0be Mon Sep 17 00:00:00 2001 From: folecr Date: Mon, 21 May 2012 17:55:49 -0700 Subject: [PATCH 176/257] HelloWorld : Use cocos2dandroid library * Add library as a dependency for HelloWorld * Use cocos2dx_default_ resources --- HelloWorld/proj.android/project.properties | 2 ++ .../src/org/cocos2dx/application/ApplicationDemo.java | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/HelloWorld/proj.android/project.properties b/HelloWorld/proj.android/project.properties index ea89160e01..1d45f1ffd3 100644 --- a/HelloWorld/proj.android/project.properties +++ b/HelloWorld/proj.android/project.properties @@ -9,3 +9,5 @@ # Project target. target=android-8 + +android.library.reference.1=../../cocos2dx/platform/android/java diff --git a/HelloWorld/proj.android/src/org/cocos2dx/application/ApplicationDemo.java b/HelloWorld/proj.android/src/org/cocos2dx/application/ApplicationDemo.java index 7b74c9fa5b..331d161346 100644 --- a/HelloWorld/proj.android/src/org/cocos2dx/application/ApplicationDemo.java +++ b/HelloWorld/proj.android/src/org/cocos2dx/application/ApplicationDemo.java @@ -45,9 +45,9 @@ public class ApplicationDemo extends Cocos2dxActivity{ String packageName = getApplication().getPackageName(); super.setPackageName(packageName); - setContentView(R.layout.helloworld_demo); - mGLView = (Cocos2dxGLSurfaceView) findViewById(R.id.helloworld_gl_surfaceview); - mGLView.setTextField((Cocos2dxEditText)findViewById(R.id.textField)); + setContentView(R.layout.cocos2dx_default_screen_layout); + mGLView = (Cocos2dxGLSurfaceView) findViewById(R.id.cocos2dx_default_gl_surfaceview); + mGLView.setTextField((Cocos2dxEditText)findViewById(R.id.cocos2dx_default_textField)); mGLView.setEGLContextClientVersion(2); mGLView.setCocos2dxRenderer(new Cocos2dxRenderer()); } From 32497bb3d6b22a1692bee11b6c23bc61d1d6d7ad Mon Sep 17 00:00:00 2001 From: folecr Date: Wed, 16 May 2012 14:53:43 -0700 Subject: [PATCH 177/257] HelloWorld : Ant build file --- HelloWorld/proj.android/build.xml | 85 +++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 HelloWorld/proj.android/build.xml diff --git a/HelloWorld/proj.android/build.xml b/HelloWorld/proj.android/build.xml new file mode 100644 index 0000000000..e225e378da --- /dev/null +++ b/HelloWorld/proj.android/build.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + + + + + + + + From 0529ccf34036923b08a619679fc979daa70ddf0b Mon Sep 17 00:00:00 2001 From: folecr Date: Tue, 22 May 2012 16:05:52 -0700 Subject: [PATCH 178/257] HelloLua : Use cocos2dandroid library * Add reference to android library project * Remove code and resources that are now in a library --- HelloLua/proj.android/project.properties | 2 + .../proj.android/res/layout/game_demo.xml | 18 - .../cocos2dx/lib/Cocos2dxAccelerometer.java | 107 ----- .../org/cocos2dx/lib/Cocos2dxActivity.java | 253 ----------- .../src/org/cocos2dx/lib/Cocos2dxBitmap.java | 413 ----------------- .../org/cocos2dx/lib/Cocos2dxEditText.java | 65 --- .../cocos2dx/lib/Cocos2dxGLSurfaceView.java | 417 ------------------ .../src/org/cocos2dx/lib/Cocos2dxMusic.java | 228 ---------- .../org/cocos2dx/lib/Cocos2dxRenderer.java | 137 ------ .../src/org/cocos2dx/lib/Cocos2dxSound.java | 245 ---------- .../org/cocos2dx/lib/Cocos2dxTypefaces.java | 44 -- 11 files changed, 2 insertions(+), 1927 deletions(-) delete mode 100644 HelloLua/proj.android/res/layout/game_demo.xml delete mode 100644 HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java delete mode 100644 HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxActivity.java delete mode 100644 HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java delete mode 100644 HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxEditText.java delete mode 100644 HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java delete mode 100644 HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxMusic.java delete mode 100644 HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxRenderer.java delete mode 100644 HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java delete mode 100644 HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxTypefaces.java diff --git a/HelloLua/proj.android/project.properties b/HelloLua/proj.android/project.properties index ea89160e01..1d45f1ffd3 100644 --- a/HelloLua/proj.android/project.properties +++ b/HelloLua/proj.android/project.properties @@ -9,3 +9,5 @@ # Project target. target=android-8 + +android.library.reference.1=../../cocos2dx/platform/android/java diff --git a/HelloLua/proj.android/res/layout/game_demo.xml b/HelloLua/proj.android/res/layout/game_demo.xml deleted file mode 100644 index 54eb7de5a5..0000000000 --- a/HelloLua/proj.android/res/layout/game_demo.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - diff --git a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java b/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java deleted file mode 100644 index c515349cab..0000000000 --- a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import android.content.Context; -import android.content.res.Configuration; -import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; -import android.hardware.SensorManager; -import android.view.Display; -import android.view.Surface; -import android.view.WindowManager; - -/** - * - * This class is used for controlling the Accelerometer - * - */ -public class Cocos2dxAccelerometer implements SensorEventListener { - - private static final String TAG = "Cocos2dxAccelerometer"; - private Context mContext; - private SensorManager mSensorManager; - private Sensor mAccelerometer; - private int mNaturalOrientation; - - public Cocos2dxAccelerometer(Context context){ - mContext = context; - - //Get an instance of the SensorManager - mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE); - mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); - - Display display = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); - mNaturalOrientation = display.getOrientation(); - } - - public void enable() { - mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME); - } - - public void disable () { - mSensorManager.unregisterListener(this); - } - - @Override - public void onSensorChanged(SensorEvent event) { - - if (event.sensor.getType() != Sensor.TYPE_ACCELEROMETER){ - return; - } - - float x = event.values[0]; - float y = event.values[1]; - float z = event.values[2]; - - /* - * Because the axes are not swapped when the device's screen orientation changes. - * So we should swap it here. - * In tablets such as Motorola Xoom, the default orientation is landscape, so should - * consider this. - */ - int orientation = mContext.getResources().getConfiguration().orientation; - if ((orientation == Configuration.ORIENTATION_LANDSCAPE) && (mNaturalOrientation != Surface.ROTATION_0)){ - float tmp = x; - x = -y; - y = tmp; - } - else if ((orientation == Configuration.ORIENTATION_PORTRAIT) && (mNaturalOrientation != Surface.ROTATION_0)) - { - float tmp = x; - x = y; - y = -tmp; - } - - onSensorChanged(x, y, z, event.timestamp); - // Log.d(TAG, "x = " + event.values[0] + " y = " + event.values[1] + " z = " + event.values[2]); - } - - @Override - public void onAccuracyChanged(Sensor sensor, int accuracy) { - } - - private static native void onSensorChanged(float x, float y, float z, long timeStamp); -} diff --git a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxActivity.java b/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxActivity.java deleted file mode 100644 index c5b65df061..0000000000 --- a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxActivity.java +++ /dev/null @@ -1,253 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -package org.cocos2dx.lib; - -import android.app.Activity; -import android.app.AlertDialog; -import android.app.Dialog; -import android.content.DialogInterface; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.util.DisplayMetrics; -import android.util.Log; - -public class Cocos2dxActivity extends Activity{ - private static Cocos2dxMusic backgroundMusicPlayer; - private static Cocos2dxSound soundPlayer; - private static Cocos2dxAccelerometer accelerometer; - private static boolean accelerometerEnabled = false; - private static Handler handler; - private final static int HANDLER_SHOW_DIALOG = 1; - private static String packageName; - - private static native void nativeSetPaths(String apkPath); - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - // get frame size - DisplayMetrics dm = new DisplayMetrics(); - getWindowManager().getDefaultDisplay().getMetrics(dm); - accelerometer = new Cocos2dxAccelerometer(this); - - // init media player and sound player - backgroundMusicPlayer = new Cocos2dxMusic(this); - soundPlayer = new Cocos2dxSound(this); - - // init bitmap context - Cocos2dxBitmap.setContext(this); - - handler = new Handler(){ - public void handleMessage(Message msg){ - switch(msg.what){ - case HANDLER_SHOW_DIALOG: - showDialog(((DialogMessage)msg.obj).title, ((DialogMessage)msg.obj).message); - break; - } - } - }; - } - - public static String getCurrentLanguage() { - String languageName = java.util.Locale.getDefault().getLanguage(); - return languageName; - } - - public static void showMessageBox(String title, String message){ - Message msg = new Message(); - msg.what = HANDLER_SHOW_DIALOG; - msg.obj = new DialogMessage(title, message); - - handler.sendMessage(msg); - } - - public static void enableAccelerometer() { - accelerometerEnabled = true; - accelerometer.enable(); - } - - public static void disableAccelerometer() { - accelerometerEnabled = false; - accelerometer.disable(); - } - - public static void preloadBackgroundMusic(String path){ - backgroundMusicPlayer.preloadBackgroundMusic(path); - } - - public static void playBackgroundMusic(String path, boolean isLoop){ - backgroundMusicPlayer.playBackgroundMusic(path, isLoop); - } - - public static void stopBackgroundMusic(){ - backgroundMusicPlayer.stopBackgroundMusic(); - } - - public static void pauseBackgroundMusic(){ - backgroundMusicPlayer.pauseBackgroundMusic(); - } - - public static void resumeBackgroundMusic(){ - backgroundMusicPlayer.resumeBackgroundMusic(); - } - - public static void rewindBackgroundMusic(){ - backgroundMusicPlayer.rewindBackgroundMusic(); - } - - public static boolean isBackgroundMusicPlaying(){ - return backgroundMusicPlayer.isBackgroundMusicPlaying(); - } - - public static float getBackgroundMusicVolume(){ - return backgroundMusicPlayer.getBackgroundVolume(); - } - - public static void setBackgroundMusicVolume(float volume){ - backgroundMusicPlayer.setBackgroundVolume(volume); - } - - public static int playEffect(String path, boolean isLoop){ - return soundPlayer.playEffect(path, isLoop); - } - - public static void stopEffect(int soundId){ - soundPlayer.stopEffect(soundId); - } - - public static void pauseEffect(int soundId){ - soundPlayer.pauseEffect(soundId); - } - - public static void resumeEffect(int soundId){ - soundPlayer.resumeEffect(soundId); - } - - public static float getEffectsVolume(){ - return soundPlayer.getEffectsVolume(); - } - - public static void setEffectsVolume(float volume){ - soundPlayer.setEffectsVolume(volume); - } - - public static void preloadEffect(String path){ - soundPlayer.preloadEffect(path); - } - - public static void unloadEffect(String path){ - soundPlayer.unloadEffect(path); - } - - public static void stopAllEffects(){ - soundPlayer.stopAllEffects(); - } - - public static void pauseAllEffects(){ - soundPlayer.pauseAllEffects(); - } - - public static void resumeAllEffects(){ - soundPlayer.resumeAllEffects(); - } - - public static void end(){ - backgroundMusicPlayer.end(); - soundPlayer.end(); - } - - public static String getCocos2dxPackageName(){ - return packageName; - } - - public static void terminateProcess(){ - android.os.Process.killProcess(android.os.Process.myPid()); - } - - @Override - protected void onResume() { - super.onResume(); - if (accelerometerEnabled) { - accelerometer.enable(); - } - } - - @Override - protected void onPause() { - super.onPause(); - if (accelerometerEnabled) { - accelerometer.disable(); - } - } - - protected void setPackageName(String packageName) { - Cocos2dxActivity.packageName = packageName; - - String apkFilePath = ""; - ApplicationInfo appInfo = null; - PackageManager packMgmr = getApplication().getPackageManager(); - try { - appInfo = packMgmr.getApplicationInfo(packageName, 0); - } catch (NameNotFoundException e) { - e.printStackTrace(); - throw new RuntimeException("Unable to locate assets, aborting..."); - } - apkFilePath = appInfo.sourceDir; - Log.w("apk path", apkFilePath); - - // add this link at the renderer class - nativeSetPaths(apkFilePath); - } - - private void showDialog(String title, String message){ - Dialog dialog = new AlertDialog.Builder(this) - .setTitle(title) - .setMessage(message) - .setPositiveButton("Ok", - new DialogInterface.OnClickListener() - { - public void onClick(DialogInterface dialog, int whichButton){ - - } - }).create(); - - dialog.show(); - } -} - -class DialogMessage { - public String title; - public String message; - - public DialogMessage(String title, String message){ - this.message = message; - this.title = title; - } -} diff --git a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java b/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java deleted file mode 100644 index 4b3d0c6788..0000000000 --- a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java +++ /dev/null @@ -1,413 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.LinkedList; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Typeface; -import android.graphics.Paint.Align; -import android.graphics.Paint.FontMetricsInt; -import android.util.Log; - -public class Cocos2dxBitmap{ - /* - * The values are the same as cocos2dx/platform/CCImage.h. - */ - private static final int HALIGNCENTER = 3; - private static final int HALIGNLEFT = 1; - private static final int HALIGNRIGHT = 2; - // vertical alignment - private static final int VALIGNTOP = 1; - private static final int VALIGNBOTTOM = 2; - private static final int VALIGNCENTER = 3; - - private static Context context; - - public static void setContext(Context context){ - Cocos2dxBitmap.context = context; - } - - /* - * @width: the width to draw, it can be 0 - * @height: the height to draw, it can be 0 - */ - public static void createTextBitmap(String content, String fontName, - int fontSize, int alignment, int width, int height){ - - content = refactorString(content); - Paint paint = newPaint(fontName, fontSize, alignment); - - TextProperty textProperty = computeTextProperty(content, paint, width, height); - - int bitmapTotalHeight = (height == 0 ? textProperty.totalHeight:height); - - // Draw text to bitmap - Bitmap bitmap = Bitmap.createBitmap(textProperty.maxWidth, - bitmapTotalHeight, Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(bitmap); - - // Draw string - FontMetricsInt fm = paint.getFontMetricsInt(); - int x = 0; - int y = computeY(fm, height, textProperty.totalHeight, alignment); - String[] lines = textProperty.lines; - for (String line : lines){ - x = computeX(paint, line, textProperty.maxWidth, alignment); - canvas.drawText(line, x, y, paint); - y += textProperty.heightPerLine; - } - - initNativeObject(bitmap); - } - - private static int computeX(Paint paint, String content, int w, int alignment){ - int ret = 0; - int hAlignment = alignment & 0x0F; - - switch (hAlignment){ - case HALIGNCENTER: - ret = w / 2; - break; - - // ret = 0 - case HALIGNLEFT: - break; - - case HALIGNRIGHT: - ret = w; - break; - - /* - * Default is align left. - * Should be same as newPaint(). - */ - default: - break; - } - - return ret; - } - - private static int computeY(FontMetricsInt fm, int constrainHeight, int totalHeight, int alignment) { - int y = -fm.top; - - if (constrainHeight > totalHeight) { - int vAlignment = (alignment >> 4) & 0x0F; - - switch (vAlignment) { - case VALIGNTOP: - y = -fm.top; - break; - case VALIGNCENTER: - y = -fm.top + (constrainHeight - totalHeight)/2; - break; - case VALIGNBOTTOM: - y = -fm.top + (constrainHeight - totalHeight); - break; - default: - break; - } - } - - return y; - } - - private static class TextProperty{ - // The max width of lines - int maxWidth; - // The height of all lines - int totalHeight; - int heightPerLine; - String[] lines; - - TextProperty(int w, int h, String[] lines){ - this.maxWidth = w; - this.heightPerLine = h; - this.totalHeight = h * lines.length; - this.lines = lines; - } - } - - private static TextProperty computeTextProperty(String content, Paint paint, - int maxWidth, int maxHeight){ - FontMetricsInt fm = paint.getFontMetricsInt(); - int h = (int)Math.ceil(fm.bottom - fm.top); - int maxContentWidth = 0; - - String[] lines = splitString(content, maxHeight, maxWidth, paint); - - if (maxWidth != 0){ - maxContentWidth = maxWidth; - } - else { - /* - * Compute the max width - */ - int temp = 0; - for (String line : lines){ - temp = (int)Math.ceil(paint.measureText(line, 0, line.length())); - if (temp > maxContentWidth){ - maxContentWidth = temp; - } - } - } - - return new TextProperty(maxContentWidth, h, lines); - } - - /* - * If maxWidth or maxHeight is not 0, - * split the string to fix the maxWidth and maxHeight. - */ - private static String[] splitString(String content, int maxHeight, int maxWidth, - Paint paint){ - String[] lines = content.split("\\n"); - String[] ret = null; - FontMetricsInt fm = paint.getFontMetricsInt(); - int heightPerLine = (int)Math.ceil(fm.bottom - fm.top); - int maxLines = maxHeight / heightPerLine; - - if (maxWidth != 0){ - LinkedList strList = new LinkedList(); - for (String line : lines){ - /* - * The width of line is exceed maxWidth, should divide it into - * two or more lines. - */ - int lineWidth = (int)Math.ceil(paint.measureText(line)); - if (lineWidth > maxWidth){ - strList.addAll(divideStringWithMaxWidth(paint, line, maxWidth)); - } - else{ - strList.add(line); - } - - /* - * Should not exceed the max height; - */ - if (maxLines > 0 && strList.size() >= maxLines){ - break; - } - } - - /* - * Remove exceeding lines - */ - if (maxLines > 0 && strList.size() > maxLines){ - while (strList.size() > maxLines){ - strList.removeLast(); - } - } - - ret = new String[strList.size()]; - strList.toArray(ret); - } else - if (maxHeight != 0 && lines.length > maxLines) { - /* - * Remove exceeding lines - */ - LinkedList strList = new LinkedList(); - for (int i = 0; i < maxLines; i++){ - strList.add(lines[i]); - } - ret = new String[strList.size()]; - strList.toArray(ret); - } - else { - ret = lines; - } - - return ret; - } - - private static LinkedList divideStringWithMaxWidth(Paint paint, String content, - int width){ - int charLength = content.length(); - int start = 0; - int tempWidth = 0; - LinkedList strList = new LinkedList(); - - /* - * Break a String into String[] by the width & should wrap the word - */ - for (int i = 1; i <= charLength; ++i){ - tempWidth = (int)Math.ceil(paint.measureText(content, start, i)); - if (tempWidth >= width){ - int lastIndexOfSpace = content.substring(0, i).lastIndexOf(" "); - - if (lastIndexOfSpace != -1 && lastIndexOfSpace > start){ - /** - * Should wrap the word - */ - strList.add(content.substring(start, lastIndexOfSpace)); - i = lastIndexOfSpace; - } - else { - /* - * Should not exceed the width - */ - if (tempWidth > width){ - strList.add(content.substring(start, i - 1)); - /* - * compute from previous char - */ - --i; - } - else { - strList.add(content.substring(start, i)); - } - } - - // remove spaces at the beginning of a new line - while(content.indexOf(i++) == ' ') { - } - - start = i; - } - } - - /* - * Add the last chars - */ - if (start < charLength){ - strList.add(content.substring(start)); - } - - return strList; - } - - private static Paint newPaint(String fontName, int fontSize, int alignment){ - Paint paint = new Paint(); - paint.setColor(Color.WHITE); - paint.setTextSize(fontSize); - paint.setAntiAlias(true); - - /* - * Set type face for paint, now it support .ttf file. - */ - if (fontName.endsWith(".ttf")){ - try { - //Typeface typeFace = Typeface.createFromAsset(context.getAssets(), fontName); - Typeface typeFace = Cocos2dxTypefaces.get(context, fontName); - paint.setTypeface(typeFace); - } catch (Exception e){ - Log.e("Cocos2dxBitmap", - "error to create ttf type face: " + fontName); - - /* - * The file may not find, use system font - */ - paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL)); - } - } - else { - paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL)); - } - - int hAlignment = alignment & 0x0F; - switch (hAlignment){ - case HALIGNCENTER: - paint.setTextAlign(Align.CENTER); - break; - - case HALIGNLEFT: - paint.setTextAlign(Align.LEFT); - break; - - case HALIGNRIGHT: - paint.setTextAlign(Align.RIGHT); - break; - - default: - paint.setTextAlign(Align.LEFT); - break; - } - - return paint; - } - - private static String refactorString(String str){ - // Avoid error when content is "" - if (str.compareTo("") == 0){ - return " "; - } - - /* - * If the font of "\n" is "" or "\n", insert " " in front of it. - * - * For example: - * "\nabc" -> " \nabc" - * "\nabc\n\n" -> " \nabc\n \n" - */ - StringBuilder strBuilder = new StringBuilder(str); - int start = 0; - int index = strBuilder.indexOf("\n"); - while (index != -1){ - if (index == 0 || strBuilder.charAt(index -1) == '\n'){ - strBuilder.insert(start, " "); - start = index + 2; - } else { - start = index + 1; - } - - if (start > strBuilder.length() || index == strBuilder.length()){ - break; - } - - index = strBuilder.indexOf("\n", start); - } - - return strBuilder.toString(); - } - - private static void initNativeObject(Bitmap bitmap){ - byte[] pixels = getPixels(bitmap); - if (pixels == null){ - return; - } - - nativeInitBitmapDC(bitmap.getWidth(), bitmap.getHeight(), pixels); - } - - private static byte[] getPixels(Bitmap bitmap){ - if (bitmap != null){ - byte[] pixels = new byte[bitmap.getWidth() * bitmap.getHeight() * 4]; - ByteBuffer buf = ByteBuffer.wrap(pixels); - buf.order(ByteOrder.nativeOrder()); - bitmap.copyPixelsToBuffer(buf); - return pixels; - } - - return null; - } - - private static native void nativeInitBitmapDC(int width, int height, byte[] pixels); -} diff --git a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxEditText.java b/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxEditText.java deleted file mode 100644 index 1c9778293f..0000000000 --- a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxEditText.java +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -Copyright (c) 2012 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -package org.cocos2dx.lib; - -import android.content.Context; -import android.util.AttributeSet; -import android.view.KeyEvent; -import android.widget.EditText; - -public class Cocos2dxEditText extends EditText { - - private Cocos2dxGLSurfaceView mView; - - public Cocos2dxEditText(Context context) { - super(context); - // TODO Auto-generated constructor stub - } - - public Cocos2dxEditText(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public Cocos2dxEditText(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - public void setMainView(Cocos2dxGLSurfaceView glSurfaceView) { - mView = glSurfaceView; - } - - /* - * Let GlSurfaceView get focus if back key is input - */ - public boolean onKeyDown(int keyCode, KeyEvent event) { - super.onKeyDown(keyCode, event); - - if (keyCode == KeyEvent.KEYCODE_BACK) { - mView.requestFocus(); - } - - return true; - } -} diff --git a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java b/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java deleted file mode 100644 index e7c4721cf3..0000000000 --- a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java +++ /dev/null @@ -1,417 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import android.content.Context; -import android.opengl.GLSurfaceView; -import android.os.Handler; -import android.os.Message; -import android.text.Editable; -import android.text.TextWatcher; -import android.util.AttributeSet; -import android.util.Log; -import android.view.KeyEvent; -import android.view.MotionEvent; -import android.view.inputmethod.InputMethodManager; -import android.widget.TextView; -import android.widget.TextView.OnEditorActionListener; - -class TextInputWraper implements TextWatcher, OnEditorActionListener { - - private static final Boolean debug = false; - private void LogD(String msg) { - if (debug) Log.d("TextInputFilter", msg); - } - - private Cocos2dxGLSurfaceView mMainView; - private String mText; - private String mOriginText; - - private Boolean isFullScreenEdit() { - InputMethodManager imm = (InputMethodManager)mMainView.getTextField().getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - return imm.isFullscreenMode(); - } - - public TextInputWraper(Cocos2dxGLSurfaceView view) { - mMainView = view; - } - - public void setOriginText(String text) { - mOriginText = text; - } - - @Override - public void afterTextChanged(Editable s) { - if (isFullScreenEdit()) { - return; - } - - LogD("afterTextChanged: " + s); - int nModified = s.length() - mText.length(); - if (nModified > 0) { - final String insertText = s.subSequence(mText.length(), s.length()).toString(); - mMainView.insertText(insertText); - LogD("insertText(" + insertText + ")"); - } - else { - for (; nModified < 0; ++nModified) { - mMainView.deleteBackward(); - LogD("deleteBackward"); - } - } - mText = s.toString(); - } - - @Override - public void beforeTextChanged(CharSequence s, int start, int count, - int after) { - LogD("beforeTextChanged(" + s + ")start: " + start + ",count: " + count + ",after: " + after); - mText = s.toString(); - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - } - - @Override - public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { - if (mMainView.getTextField() == v && isFullScreenEdit()) { - // user press the action button, delete all old text and insert new text - for (int i = mOriginText.length(); i > 0; --i) { - mMainView.deleteBackward(); - LogD("deleteBackward"); - } - String text = v.getText().toString(); - - /* - * If user input nothing, translate "\n" to engine. - */ - if (text.compareTo("") == 0){ - text = "\n"; - } - - if ('\n' != text.charAt(text.length() - 1)) { - text += '\n'; - } - - final String insertText = text; - mMainView.insertText(insertText); - LogD("insertText(" + insertText + ")"); - } - return false; - } -} - -public class Cocos2dxGLSurfaceView extends GLSurfaceView { - - static private Cocos2dxGLSurfaceView mainView; - - private static final String TAG = Cocos2dxGLSurfaceView.class.getCanonicalName(); - private Cocos2dxRenderer mRenderer; - - private static final boolean debug = false; - - /////////////////////////////////////////////////////////////////////////// - // for initialize - /////////////////////////////////////////////////////////////////////////// - public Cocos2dxGLSurfaceView(Context context) { - super(context); - initView(); - } - - public Cocos2dxGLSurfaceView(Context context, AttributeSet attrs) { - super(context, attrs); - initView(); - } - - public void setCocos2dxRenderer(Cocos2dxRenderer renderer){ - mRenderer = renderer; - setRenderer(mRenderer); - } - - protected void initView() { - setFocusableInTouchMode(true); - - textInputWraper = new TextInputWraper(this); - - handler = new Handler(){ - public void handleMessage(Message msg){ - switch(msg.what){ - case HANDLER_OPEN_IME_KEYBOARD: - if (null != mTextField && mTextField.requestFocus()) { - mTextField.removeTextChangedListener(textInputWraper); - mTextField.setText(""); - String text = (String)msg.obj; - mTextField.append(text); - textInputWraper.setOriginText(text); - mTextField.addTextChangedListener(textInputWraper); - InputMethodManager imm = (InputMethodManager)mainView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - imm.showSoftInput(mTextField, 0); - Log.d("GLSurfaceView", "showSoftInput"); - } - break; - - case HANDLER_CLOSE_IME_KEYBOARD: - if (null != mTextField) { - mTextField.removeTextChangedListener(textInputWraper); - InputMethodManager imm = (InputMethodManager)mainView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(mTextField.getWindowToken(), 0); - Log.d("GLSurfaceView", "HideSoftInput"); - } - break; - } - } - }; - - mainView = this; - } - - public void onPause(){ - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleOnPause(); - } - }); - - super.onPause(); - } - - public void onResume(){ - super.onResume(); - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleOnResume(); - } - }); - } - - /////////////////////////////////////////////////////////////////////////// - // for text input - /////////////////////////////////////////////////////////////////////////// - private final static int HANDLER_OPEN_IME_KEYBOARD = 2; - private final static int HANDLER_CLOSE_IME_KEYBOARD = 3; - private static Handler handler; - private static TextInputWraper textInputWraper; - private Cocos2dxEditText mTextField; - - public TextView getTextField() { - return mTextField; - } - - public void setTextField(Cocos2dxEditText view) { - mTextField = view; - if (null != mTextField && null != textInputWraper) { - mTextField.setOnEditorActionListener(textInputWraper); - mTextField.setMainView(this); - this.requestFocus(); - } - } - - public static void openIMEKeyboard() { - Message msg = new Message(); - msg.what = HANDLER_OPEN_IME_KEYBOARD; - msg.obj = mainView.getContentText(); - handler.sendMessage(msg); - - } - - private String getContentText() { - return mRenderer.getContentText(); - } - - public static void closeIMEKeyboard() { - Message msg = new Message(); - msg.what = HANDLER_CLOSE_IME_KEYBOARD; - handler.sendMessage(msg); - } - - public void insertText(final String text) { - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleInsertText(text); - } - }); - } - - public void deleteBackward() { - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleDeleteBackward(); - } - }); - } - - /////////////////////////////////////////////////////////////////////////// - // for touch event - /////////////////////////////////////////////////////////////////////////// - - public boolean onTouchEvent(final MotionEvent event) { - // these data are used in ACTION_MOVE and ACTION_CANCEL - final int pointerNumber = event.getPointerCount(); - final int[] ids = new int[pointerNumber]; - final float[] xs = new float[pointerNumber]; - final float[] ys = new float[pointerNumber]; - - for (int i = 0; i < pointerNumber; i++) { - ids[i] = event.getPointerId(i); - xs[i] = event.getX(i); - ys[i] = event.getY(i); - } - - switch (event.getAction() & MotionEvent.ACTION_MASK) { - case MotionEvent.ACTION_POINTER_DOWN: - final int indexPointerDown = event.getAction() >> MotionEvent.ACTION_POINTER_ID_SHIFT; - final int idPointerDown = event.getPointerId(indexPointerDown); - final float xPointerDown = event.getX(indexPointerDown); - final float yPointerDown = event.getY(indexPointerDown); - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionDown(idPointerDown, xPointerDown, yPointerDown); - } - }); - break; - - case MotionEvent.ACTION_DOWN: - // there are only one finger on the screen - final int idDown = event.getPointerId(0); - final float xDown = xs[0]; - final float yDown = ys[0]; - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionDown(idDown, xDown, yDown); - } - }); - break; - - case MotionEvent.ACTION_MOVE: - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionMove(ids, xs, ys); - } - }); - break; - - case MotionEvent.ACTION_POINTER_UP: - final int indexPointUp = event.getAction() >> MotionEvent.ACTION_POINTER_ID_SHIFT; - final int idPointerUp = event.getPointerId(indexPointUp); - final float xPointerUp = event.getX(indexPointUp); - final float yPointerUp = event.getY(indexPointUp); - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionUp(idPointerUp, xPointerUp, yPointerUp); - } - }); - break; - - case MotionEvent.ACTION_UP: - // there are only one finger on the screen - final int idUp = event.getPointerId(0); - final float xUp = xs[0]; - final float yUp = ys[0]; - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionUp(idUp, xUp, yUp); - } - }); - break; - - case MotionEvent.ACTION_CANCEL: - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionCancel(ids, xs, ys); - } - }); - break; - } - - if (debug){ - dumpEvent(event); - } - return true; - } - - /* - * This function is called before Cocos2dxRenderer.nativeInit(), so the width and height is correct. - */ - protected void onSizeChanged(int w, int h, int oldw, int oldh){ - this.mRenderer.setScreenWidthAndHeight(w, h); - } - - @Override - public boolean onKeyDown(int keyCode, KeyEvent event) { - final int kc = keyCode; - if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) { - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleKeyDown(kc); - } - }); - return true; - } - return super.onKeyDown(keyCode, event); - } - - // Show an event in the LogCat view, for debugging - private void dumpEvent(MotionEvent event) { - String names[] = { "DOWN" , "UP" , "MOVE" , "CANCEL" , "OUTSIDE" , - "POINTER_DOWN" , "POINTER_UP" , "7?" , "8?" , "9?" }; - StringBuilder sb = new StringBuilder(); - int action = event.getAction(); - int actionCode = action & MotionEvent.ACTION_MASK; - sb.append("event ACTION_" ).append(names[actionCode]); - if (actionCode == MotionEvent.ACTION_POINTER_DOWN - || actionCode == MotionEvent.ACTION_POINTER_UP) { - sb.append("(pid " ).append( - action >> MotionEvent.ACTION_POINTER_ID_SHIFT); - sb.append(")" ); - } - sb.append("[" ); - for (int i = 0; i < event.getPointerCount(); i++) { - sb.append("#" ).append(i); - sb.append("(pid " ).append(event.getPointerId(i)); - sb.append(")=" ).append((int) event.getX(i)); - sb.append("," ).append((int) event.getY(i)); - if (i + 1 < event.getPointerCount()) - sb.append(";" ); - } - sb.append("]" ); - Log.d(TAG, sb.toString()); - } -} diff --git a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxMusic.java b/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxMusic.java deleted file mode 100644 index 10e3e5f3c6..0000000000 --- a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxMusic.java +++ /dev/null @@ -1,228 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import android.content.Context; -import android.content.res.AssetFileDescriptor; -import android.media.MediaPlayer; -import android.util.Log; - -/** - * - * This class is used for controlling background music - * - */ -public class Cocos2dxMusic { - - private static final String TAG = "Cocos2dxMusic"; - private float mLeftVolume; - private float mRightVolume; - private Context mContext; - private MediaPlayer mBackgroundMediaPlayer; - private boolean mIsPaused; - private String mCurrentPath; - - public Cocos2dxMusic(Context context){ - this.mContext = context; - initData(); - } - - public void preloadBackgroundMusic(String path){ - if ((mCurrentPath == null) || (! mCurrentPath.equals(path))){ - // preload new background music - - // release old resource and create a new one - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.release(); - } - - mBackgroundMediaPlayer = createMediaplayerFromAssets(path); - - // record the path - mCurrentPath = path; - } - } - - public void playBackgroundMusic(String path, boolean isLoop){ - if (mCurrentPath == null){ - // it is the first time to play background music - // or end() was called - mBackgroundMediaPlayer = createMediaplayerFromAssets(path); - mCurrentPath = path; - } - else { - if (! mCurrentPath.equals(path)){ - // play new background music - - // release old resource and create a new one - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.release(); - } - mBackgroundMediaPlayer = createMediaplayerFromAssets(path); - - // record the path - mCurrentPath = path; - } - } - - if (mBackgroundMediaPlayer == null){ - Log.e(TAG, "playBackgroundMusic: background media player is null"); - } else { - // if the music is playing or paused, stop it - mBackgroundMediaPlayer.stop(); - - mBackgroundMediaPlayer.setLooping(isLoop); - - try { - mBackgroundMediaPlayer.prepare(); - mBackgroundMediaPlayer.seekTo(0); - mBackgroundMediaPlayer.start(); - - this.mIsPaused = false; - } catch (Exception e){ - Log.e(TAG, "playBackgroundMusic: error state"); - } - } - } - - public void stopBackgroundMusic(){ - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.stop(); - - // should set the state, if not , the following sequence will be error - // play -> pause -> stop -> resume - this.mIsPaused = false; - } - } - - public void pauseBackgroundMusic(){ - if (mBackgroundMediaPlayer != null && mBackgroundMediaPlayer.isPlaying()){ - mBackgroundMediaPlayer.pause(); - this.mIsPaused = true; - } - } - - public void resumeBackgroundMusic(){ - if (mBackgroundMediaPlayer != null && this.mIsPaused){ - mBackgroundMediaPlayer.start(); - this.mIsPaused = false; - } - } - - public void rewindBackgroundMusic(){ - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.stop(); - - try { - mBackgroundMediaPlayer.prepare(); - mBackgroundMediaPlayer.seekTo(0); - mBackgroundMediaPlayer.start(); - - this.mIsPaused = false; - } catch (Exception e){ - Log.e(TAG, "rewindBackgroundMusic: error state"); - } - } - } - - public boolean isBackgroundMusicPlaying(){ - boolean ret = false; - - if (mBackgroundMediaPlayer == null){ - ret = false; - } else { - ret = mBackgroundMediaPlayer.isPlaying(); - } - - return ret; - } - - public void end(){ - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.release(); - } - - initData(); - } - - public float getBackgroundVolume(){ - if (this.mBackgroundMediaPlayer != null){ - return (this.mLeftVolume + this.mRightVolume) / 2; - } else { - return 0.0f; - } - } - - public void setBackgroundVolume(float volume){ - if (volume < 0.0f){ - volume = 0.0f; - } - - if (volume > 1.0f){ - volume = 1.0f; - } - - this.mLeftVolume = this.mRightVolume = volume; - if (this.mBackgroundMediaPlayer != null){ - this.mBackgroundMediaPlayer.setVolume(this.mLeftVolume, this.mRightVolume); - } - } - - private void initData(){ - mLeftVolume =0.5f; - mRightVolume = 0.5f; - mBackgroundMediaPlayer = null; - mIsPaused = false; - mCurrentPath = null; - } - - /** - * create mediaplayer for music - * @param path the path relative to assets - * @return - */ - private MediaPlayer createMediaplayerFromAssets(String path){ - MediaPlayer mediaPlayer = new MediaPlayer(); - - try{ - if (path.startsWith("/")) { - mediaPlayer.setDataSource(path); - } - else { - AssetFileDescriptor assetFileDescritor = mContext.getAssets().openFd(path); - mediaPlayer.setDataSource(assetFileDescritor.getFileDescriptor(), - assetFileDescritor.getStartOffset(), assetFileDescritor.getLength()); - } - - mediaPlayer.prepare(); - - mediaPlayer.setVolume(mLeftVolume, mRightVolume); - }catch (Exception e) { - mediaPlayer = null; - Log.e(TAG, "error: " + e.getMessage(), e); - } - - return mediaPlayer; - } -} diff --git a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxRenderer.java b/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxRenderer.java deleted file mode 100644 index fad0974f42..0000000000 --- a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxRenderer.java +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.opengles.GL10; - -import android.opengl.GLSurfaceView; - -public class Cocos2dxRenderer implements GLSurfaceView.Renderer { - private final static long NANOSECONDSPERSECOND = 1000000000L; - private final static long NANOSECONDSPERMINISECOND = 1000000; - private static long animationInterval = (long)(1.0 / 60 * NANOSECONDSPERSECOND); - private long last; - private int screenWidth; - private int screenHeight; - - public void onSurfaceCreated(GL10 gl, EGLConfig config) { - nativeInit(screenWidth, screenHeight); - last = System.nanoTime(); - } - - public void setScreenWidthAndHeight(int w, int h){ - this.screenWidth = w; - this.screenHeight = h; - } - - public void onSurfaceChanged(GL10 gl, int w, int h) { - } - - public void onDrawFrame(GL10 gl) { - - long now = System.nanoTime(); - long interval = now - last; - - // should render a frame when onDrawFrame() is called - // or there is a "ghost" - nativeRender(); - - // fps controlling - if (interval < animationInterval){ - try { - // because we render it before, so we should sleep twice time interval - Thread.sleep((animationInterval - interval) * 2 / NANOSECONDSPERMINISECOND); - } catch (Exception e){} - } - - last = now; - } - - public void handleActionDown(int id, float x, float y) - { - nativeTouchesBegin(id, x, y); - } - - public void handleActionUp(int id, float x, float y) - { - nativeTouchesEnd(id, x, y); - } - - public void handleActionCancel(int[] id, float[] x, float[] y) - { - nativeTouchesCancel(id, x, y); - } - - public void handleActionMove(int[] id, float[] x, float[] y) - { - nativeTouchesMove(id, x, y); - } - - public void handleKeyDown(int keyCode) - { - nativeKeyDown(keyCode); - } - - public void handleOnPause(){ - nativeOnPause(); - } - - public void handleOnResume(){ - nativeOnResume(); - } - - public static void setAnimationInterval(double interval){ - animationInterval = (long)(interval * NANOSECONDSPERSECOND); - } - private static native void nativeTouchesBegin(int id, float x, float y); - private static native void nativeTouchesEnd(int id, float x, float y); - private static native void nativeTouchesMove(int[] id, float[] x, float[] y); - private static native void nativeTouchesCancel(int[] id, float[] x, float[] y); - private static native boolean nativeKeyDown(int keyCode); - private static native void nativeRender(); - private static native void nativeInit(int w, int h); - private static native void nativeOnPause(); - private static native void nativeOnResume(); - - ///////////////////////////////////////////////////////////////////////////////// - // handle input method edit message - ///////////////////////////////////////////////////////////////////////////////// - - public void handleInsertText(final String text) { - nativeInsertText(text); - } - - public void handleDeleteBackward() { - nativeDeleteBackward(); - } - - public String getContentText() { - return nativeGetContentText(); - } - - private static native void nativeInsertText(String text); - private static native void nativeDeleteBackward(); - private static native String nativeGetContentText(); -} diff --git a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java b/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java deleted file mode 100644 index e7061f74de..0000000000 --- a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java +++ /dev/null @@ -1,245 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import android.content.Context; -import android.media.AudioManager; -import android.media.SoundPool; -import android.util.Log; - -/** - * - * This class is used for controlling effect - * - */ - -public class Cocos2dxSound { - private Context mContext; - private SoundPool mSoundPool; - private float mLeftVolume; - private float mRightVolume; - - // sound path and stream ids map - // a file may be played many times at the same time - // so there is an array map to a file path - private HashMap> mPathStreamIDsMap; - - private HashMap mPathSoundIdMap; - - private static final String TAG = "Cocos2dxSound"; - private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 5; - private static final float SOUND_RATE = 1.0f; - private static final int SOUND_PRIORITY = 1; - private static final int SOUND_QUALITY = 5; - - private final static int INVALID_SOUND_ID = -1; - private final static int INVALID_STREAM_ID = -1; - - public Cocos2dxSound(Context context){ - this.mContext = context; - initData(); - } - - public int preloadEffect(String path){ - Integer soundID = this.mPathSoundIdMap.get(path); - - if (soundID == null) { - soundID = createSoundIdFromAsset(path); - this.mPathSoundIdMap.put(path, soundID); - } - - return soundID; - } - - public void unloadEffect(String path){ - // stop effects - ArrayList streamIDs = this.mPathStreamIDsMap.get(path); - if (streamIDs != null) { - for (Integer streamID : streamIDs) { - this.mSoundPool.stop(streamID); - } - } - this.mPathStreamIDsMap.remove(path); - - // unload effect - Integer soundID = this.mPathSoundIdMap.get(path); - this.mSoundPool.unload(soundID); - this.mPathSoundIdMap.remove(path); - } - - public int playEffect(String path, boolean isLoop){ - Integer soundId = this.mPathSoundIdMap.get(path); - int streamId = INVALID_STREAM_ID; - - if (soundId != null){ - // play sound - streamId = this.mSoundPool.play(soundId.intValue(), this.mLeftVolume, - this.mRightVolume, SOUND_PRIORITY, isLoop ? -1 : 0, SOUND_RATE); - - // record stream id - ArrayList streamIds = this.mPathStreamIDsMap.get(path); - if (streamIds == null) { - streamIds = new ArrayList(); - this.mPathStreamIDsMap.put(path, streamIds); - } - streamIds.add(streamId); - } else { - // the effect is not prepared - soundId = preloadEffect(path); - if (soundId == INVALID_SOUND_ID){ - // can not preload effect - return INVALID_SOUND_ID; - } - - /* - * Someone reports that, it can not play effect for the - * first time. If you are lucky to meet it. There are two - * ways to resolve it. - * 1. Add some delay here. I don't know how long it is, so - * I don't add it here. - * 2. If you use 2.2(API level 8), you can call - * SoundPool.setOnLoadCompleteListener() to play the effect. - * Because the method is supported from 2.2, so I can't use - * it here. - */ - playEffect(path, isLoop); - } - - return streamId; - } - - public void stopEffect(int streamID){ - this.mSoundPool.stop(streamID); - - // remove record - for (String path : this.mPathStreamIDsMap.keySet()) { - if (this.mPathStreamIDsMap.get(path).contains(streamID)) { - this.mPathStreamIDsMap.get(path).remove(this.mPathStreamIDsMap.get(path).indexOf(streamID)); - break; - } - } - } - - public void pauseEffect(int streamID){ - this.mSoundPool.pause(streamID); - } - - public void resumeEffect(int streamID){ - this.mSoundPool.resume(streamID); - } - - public void pauseAllEffects(){ - this.mSoundPool.autoPause(); - } - - public void resumeAllEffects(){ - // autoPause() is available since level 8 - this.mSoundPool.autoResume(); - } - - @SuppressWarnings("unchecked") - public void stopAllEffects(){ - // stop effects - if (! this.mPathStreamIDsMap.isEmpty()) { - Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry> entry = (Map.Entry>)iter.next(); - for (int streamID : entry.getValue()) { - this.mSoundPool.stop(streamID); - } - } - } - - // remove records - this.mPathStreamIDsMap.clear(); - } - - public float getEffectsVolume(){ - return (this.mLeftVolume + this.mRightVolume) / 2; - } - - @SuppressWarnings("unchecked") - public void setEffectsVolume(float volume){ - // volume should be in [0, 1.0] - if (volume < 0){ - volume = 0; - } - if (volume > 1){ - volume = 1; - } - - this.mLeftVolume = this.mRightVolume = volume; - - // change the volume of playing sounds - if (! this.mPathStreamIDsMap.isEmpty()) { - Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry> entry = (Map.Entry>)iter.next(); - for (int streamID : entry.getValue()) { - this.mSoundPool.setVolume(streamID, mLeftVolume, mRightVolume); - } - } - } - } - - public void end(){ - this.mSoundPool.release(); - this.mPathStreamIDsMap.clear(); - this.mPathSoundIdMap.clear(); - - initData(); - } - - public int createSoundIdFromAsset(String path){ - int soundId = INVALID_SOUND_ID; - - try { - if (path.startsWith("/")){ - soundId = mSoundPool.load(path, 0); - } - else { - soundId = mSoundPool.load(mContext.getAssets().openFd(path), 0); - } - } catch(Exception e){ - soundId = INVALID_SOUND_ID; - Log.e(TAG, "error: " + e.getMessage(), e); - } - - return soundId; - } - - private void initData(){ - this.mPathStreamIDsMap = new HashMap>(); - this.mPathSoundIdMap = new HashMap(); - mSoundPool = new SoundPool(MAX_SIMULTANEOUS_STREAMS_DEFAULT, AudioManager.STREAM_MUSIC, SOUND_QUALITY); - - this.mLeftVolume = 0.5f; - this.mRightVolume = 0.5f; - } -} diff --git a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxTypefaces.java b/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxTypefaces.java deleted file mode 100644 index 79af1ed3af..0000000000 --- a/HelloLua/proj.android/src/org/cocos2dx/lib/Cocos2dxTypefaces.java +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import java.util.Hashtable; - -import android.content.Context; -import android.graphics.Typeface; - -public class Cocos2dxTypefaces { - private static final Hashtable cache = new Hashtable(); - - public static Typeface get(Context context, String name){ - synchronized(cache){ - if (! cache.containsKey(name)){ - Typeface t = Typeface.createFromAsset(context.getAssets(), name); - cache.put(name, t); - } - - return cache.get(name); - } - } -} From 4a4d051ceedc3004f19bc21dfd523faba915e357 Mon Sep 17 00:00:00 2001 From: folecr Date: Tue, 22 May 2012 16:08:33 -0700 Subject: [PATCH 179/257] HelloLua : Ant build and configuration files --- HelloLua/proj.android/ant.properties | 17 +++++ HelloLua/proj.android/build.xml | 83 ++++++++++++++++++++++ HelloLua/proj.android/proguard-project.txt | 20 ++++++ 3 files changed, 120 insertions(+) create mode 100644 HelloLua/proj.android/ant.properties create mode 100644 HelloLua/proj.android/build.xml create mode 100644 HelloLua/proj.android/proguard-project.txt diff --git a/HelloLua/proj.android/ant.properties b/HelloLua/proj.android/ant.properties new file mode 100644 index 0000000000..b0971e891e --- /dev/null +++ b/HelloLua/proj.android/ant.properties @@ -0,0 +1,17 @@ +# This file is used to override default values used by the Ant build system. +# +# This file must be checked into Version Control Systems, as it is +# integral to the build system of your project. + +# This file is only used by the Ant script. + +# You can use this to override default values such as +# 'source.dir' for the location of your java source folder and +# 'out.dir' for the location of your output folder. + +# You can also use it define how the release builds are signed by declaring +# the following properties: +# 'key.store' for the location of your keystore and +# 'key.alias' for the name of the key to use. +# The password will be asked during the build when you use the 'release' target. + diff --git a/HelloLua/proj.android/build.xml b/HelloLua/proj.android/build.xml new file mode 100644 index 0000000000..ff293087f2 --- /dev/null +++ b/HelloLua/proj.android/build.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/HelloLua/proj.android/proguard-project.txt b/HelloLua/proj.android/proguard-project.txt new file mode 100644 index 0000000000..f2fe1559a2 --- /dev/null +++ b/HelloLua/proj.android/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} From d86e088e9f17578d589e4a4e3b73ce9cbee43f34 Mon Sep 17 00:00:00 2001 From: folecr Date: Tue, 22 May 2012 18:32:35 -0700 Subject: [PATCH 180/257] Tests : Use cocos2dandroid library * Remove code and resources that are now in a library * Add library as a dependency for HelloWorld * Use cocos2dx_default_ resources --- tests/proj.android/project.properties | 2 + tests/proj.android/res/layout/test_demo.xml | 18 - .../cocos2dx/lib/Cocos2dxAccelerometer.java | 107 ----- .../org/cocos2dx/lib/Cocos2dxActivity.java | 253 ----------- .../src/org/cocos2dx/lib/Cocos2dxBitmap.java | 413 ----------------- .../org/cocos2dx/lib/Cocos2dxEditText.java | 65 --- .../cocos2dx/lib/Cocos2dxGLSurfaceView.java | 417 ------------------ .../src/org/cocos2dx/lib/Cocos2dxMusic.java | 228 ---------- .../org/cocos2dx/lib/Cocos2dxRenderer.java | 137 ------ .../src/org/cocos2dx/lib/Cocos2dxSound.java | 245 ---------- .../org/cocos2dx/lib/Cocos2dxTypefaces.java | 44 -- .../src/org/cocos2dx/tests/TestsDemo.java | 6 +- 12 files changed, 5 insertions(+), 1930 deletions(-) delete mode 100644 tests/proj.android/res/layout/test_demo.xml delete mode 100644 tests/proj.android/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java delete mode 100644 tests/proj.android/src/org/cocos2dx/lib/Cocos2dxActivity.java delete mode 100644 tests/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java delete mode 100644 tests/proj.android/src/org/cocos2dx/lib/Cocos2dxEditText.java delete mode 100644 tests/proj.android/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java delete mode 100644 tests/proj.android/src/org/cocos2dx/lib/Cocos2dxMusic.java delete mode 100644 tests/proj.android/src/org/cocos2dx/lib/Cocos2dxRenderer.java delete mode 100644 tests/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java delete mode 100644 tests/proj.android/src/org/cocos2dx/lib/Cocos2dxTypefaces.java diff --git a/tests/proj.android/project.properties b/tests/proj.android/project.properties index ea89160e01..1d45f1ffd3 100644 --- a/tests/proj.android/project.properties +++ b/tests/proj.android/project.properties @@ -9,3 +9,5 @@ # Project target. target=android-8 + +android.library.reference.1=../../cocos2dx/platform/android/java diff --git a/tests/proj.android/res/layout/test_demo.xml b/tests/proj.android/res/layout/test_demo.xml deleted file mode 100644 index a42c755915..0000000000 --- a/tests/proj.android/res/layout/test_demo.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - diff --git a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java b/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java deleted file mode 100644 index c515349cab..0000000000 --- a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import android.content.Context; -import android.content.res.Configuration; -import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; -import android.hardware.SensorManager; -import android.view.Display; -import android.view.Surface; -import android.view.WindowManager; - -/** - * - * This class is used for controlling the Accelerometer - * - */ -public class Cocos2dxAccelerometer implements SensorEventListener { - - private static final String TAG = "Cocos2dxAccelerometer"; - private Context mContext; - private SensorManager mSensorManager; - private Sensor mAccelerometer; - private int mNaturalOrientation; - - public Cocos2dxAccelerometer(Context context){ - mContext = context; - - //Get an instance of the SensorManager - mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE); - mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); - - Display display = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); - mNaturalOrientation = display.getOrientation(); - } - - public void enable() { - mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME); - } - - public void disable () { - mSensorManager.unregisterListener(this); - } - - @Override - public void onSensorChanged(SensorEvent event) { - - if (event.sensor.getType() != Sensor.TYPE_ACCELEROMETER){ - return; - } - - float x = event.values[0]; - float y = event.values[1]; - float z = event.values[2]; - - /* - * Because the axes are not swapped when the device's screen orientation changes. - * So we should swap it here. - * In tablets such as Motorola Xoom, the default orientation is landscape, so should - * consider this. - */ - int orientation = mContext.getResources().getConfiguration().orientation; - if ((orientation == Configuration.ORIENTATION_LANDSCAPE) && (mNaturalOrientation != Surface.ROTATION_0)){ - float tmp = x; - x = -y; - y = tmp; - } - else if ((orientation == Configuration.ORIENTATION_PORTRAIT) && (mNaturalOrientation != Surface.ROTATION_0)) - { - float tmp = x; - x = y; - y = -tmp; - } - - onSensorChanged(x, y, z, event.timestamp); - // Log.d(TAG, "x = " + event.values[0] + " y = " + event.values[1] + " z = " + event.values[2]); - } - - @Override - public void onAccuracyChanged(Sensor sensor, int accuracy) { - } - - private static native void onSensorChanged(float x, float y, float z, long timeStamp); -} diff --git a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxActivity.java b/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxActivity.java deleted file mode 100644 index c5b65df061..0000000000 --- a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxActivity.java +++ /dev/null @@ -1,253 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -package org.cocos2dx.lib; - -import android.app.Activity; -import android.app.AlertDialog; -import android.app.Dialog; -import android.content.DialogInterface; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.util.DisplayMetrics; -import android.util.Log; - -public class Cocos2dxActivity extends Activity{ - private static Cocos2dxMusic backgroundMusicPlayer; - private static Cocos2dxSound soundPlayer; - private static Cocos2dxAccelerometer accelerometer; - private static boolean accelerometerEnabled = false; - private static Handler handler; - private final static int HANDLER_SHOW_DIALOG = 1; - private static String packageName; - - private static native void nativeSetPaths(String apkPath); - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - // get frame size - DisplayMetrics dm = new DisplayMetrics(); - getWindowManager().getDefaultDisplay().getMetrics(dm); - accelerometer = new Cocos2dxAccelerometer(this); - - // init media player and sound player - backgroundMusicPlayer = new Cocos2dxMusic(this); - soundPlayer = new Cocos2dxSound(this); - - // init bitmap context - Cocos2dxBitmap.setContext(this); - - handler = new Handler(){ - public void handleMessage(Message msg){ - switch(msg.what){ - case HANDLER_SHOW_DIALOG: - showDialog(((DialogMessage)msg.obj).title, ((DialogMessage)msg.obj).message); - break; - } - } - }; - } - - public static String getCurrentLanguage() { - String languageName = java.util.Locale.getDefault().getLanguage(); - return languageName; - } - - public static void showMessageBox(String title, String message){ - Message msg = new Message(); - msg.what = HANDLER_SHOW_DIALOG; - msg.obj = new DialogMessage(title, message); - - handler.sendMessage(msg); - } - - public static void enableAccelerometer() { - accelerometerEnabled = true; - accelerometer.enable(); - } - - public static void disableAccelerometer() { - accelerometerEnabled = false; - accelerometer.disable(); - } - - public static void preloadBackgroundMusic(String path){ - backgroundMusicPlayer.preloadBackgroundMusic(path); - } - - public static void playBackgroundMusic(String path, boolean isLoop){ - backgroundMusicPlayer.playBackgroundMusic(path, isLoop); - } - - public static void stopBackgroundMusic(){ - backgroundMusicPlayer.stopBackgroundMusic(); - } - - public static void pauseBackgroundMusic(){ - backgroundMusicPlayer.pauseBackgroundMusic(); - } - - public static void resumeBackgroundMusic(){ - backgroundMusicPlayer.resumeBackgroundMusic(); - } - - public static void rewindBackgroundMusic(){ - backgroundMusicPlayer.rewindBackgroundMusic(); - } - - public static boolean isBackgroundMusicPlaying(){ - return backgroundMusicPlayer.isBackgroundMusicPlaying(); - } - - public static float getBackgroundMusicVolume(){ - return backgroundMusicPlayer.getBackgroundVolume(); - } - - public static void setBackgroundMusicVolume(float volume){ - backgroundMusicPlayer.setBackgroundVolume(volume); - } - - public static int playEffect(String path, boolean isLoop){ - return soundPlayer.playEffect(path, isLoop); - } - - public static void stopEffect(int soundId){ - soundPlayer.stopEffect(soundId); - } - - public static void pauseEffect(int soundId){ - soundPlayer.pauseEffect(soundId); - } - - public static void resumeEffect(int soundId){ - soundPlayer.resumeEffect(soundId); - } - - public static float getEffectsVolume(){ - return soundPlayer.getEffectsVolume(); - } - - public static void setEffectsVolume(float volume){ - soundPlayer.setEffectsVolume(volume); - } - - public static void preloadEffect(String path){ - soundPlayer.preloadEffect(path); - } - - public static void unloadEffect(String path){ - soundPlayer.unloadEffect(path); - } - - public static void stopAllEffects(){ - soundPlayer.stopAllEffects(); - } - - public static void pauseAllEffects(){ - soundPlayer.pauseAllEffects(); - } - - public static void resumeAllEffects(){ - soundPlayer.resumeAllEffects(); - } - - public static void end(){ - backgroundMusicPlayer.end(); - soundPlayer.end(); - } - - public static String getCocos2dxPackageName(){ - return packageName; - } - - public static void terminateProcess(){ - android.os.Process.killProcess(android.os.Process.myPid()); - } - - @Override - protected void onResume() { - super.onResume(); - if (accelerometerEnabled) { - accelerometer.enable(); - } - } - - @Override - protected void onPause() { - super.onPause(); - if (accelerometerEnabled) { - accelerometer.disable(); - } - } - - protected void setPackageName(String packageName) { - Cocos2dxActivity.packageName = packageName; - - String apkFilePath = ""; - ApplicationInfo appInfo = null; - PackageManager packMgmr = getApplication().getPackageManager(); - try { - appInfo = packMgmr.getApplicationInfo(packageName, 0); - } catch (NameNotFoundException e) { - e.printStackTrace(); - throw new RuntimeException("Unable to locate assets, aborting..."); - } - apkFilePath = appInfo.sourceDir; - Log.w("apk path", apkFilePath); - - // add this link at the renderer class - nativeSetPaths(apkFilePath); - } - - private void showDialog(String title, String message){ - Dialog dialog = new AlertDialog.Builder(this) - .setTitle(title) - .setMessage(message) - .setPositiveButton("Ok", - new DialogInterface.OnClickListener() - { - public void onClick(DialogInterface dialog, int whichButton){ - - } - }).create(); - - dialog.show(); - } -} - -class DialogMessage { - public String title; - public String message; - - public DialogMessage(String title, String message){ - this.message = message; - this.title = title; - } -} diff --git a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java b/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java deleted file mode 100644 index 4b3d0c6788..0000000000 --- a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java +++ /dev/null @@ -1,413 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.LinkedList; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Typeface; -import android.graphics.Paint.Align; -import android.graphics.Paint.FontMetricsInt; -import android.util.Log; - -public class Cocos2dxBitmap{ - /* - * The values are the same as cocos2dx/platform/CCImage.h. - */ - private static final int HALIGNCENTER = 3; - private static final int HALIGNLEFT = 1; - private static final int HALIGNRIGHT = 2; - // vertical alignment - private static final int VALIGNTOP = 1; - private static final int VALIGNBOTTOM = 2; - private static final int VALIGNCENTER = 3; - - private static Context context; - - public static void setContext(Context context){ - Cocos2dxBitmap.context = context; - } - - /* - * @width: the width to draw, it can be 0 - * @height: the height to draw, it can be 0 - */ - public static void createTextBitmap(String content, String fontName, - int fontSize, int alignment, int width, int height){ - - content = refactorString(content); - Paint paint = newPaint(fontName, fontSize, alignment); - - TextProperty textProperty = computeTextProperty(content, paint, width, height); - - int bitmapTotalHeight = (height == 0 ? textProperty.totalHeight:height); - - // Draw text to bitmap - Bitmap bitmap = Bitmap.createBitmap(textProperty.maxWidth, - bitmapTotalHeight, Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(bitmap); - - // Draw string - FontMetricsInt fm = paint.getFontMetricsInt(); - int x = 0; - int y = computeY(fm, height, textProperty.totalHeight, alignment); - String[] lines = textProperty.lines; - for (String line : lines){ - x = computeX(paint, line, textProperty.maxWidth, alignment); - canvas.drawText(line, x, y, paint); - y += textProperty.heightPerLine; - } - - initNativeObject(bitmap); - } - - private static int computeX(Paint paint, String content, int w, int alignment){ - int ret = 0; - int hAlignment = alignment & 0x0F; - - switch (hAlignment){ - case HALIGNCENTER: - ret = w / 2; - break; - - // ret = 0 - case HALIGNLEFT: - break; - - case HALIGNRIGHT: - ret = w; - break; - - /* - * Default is align left. - * Should be same as newPaint(). - */ - default: - break; - } - - return ret; - } - - private static int computeY(FontMetricsInt fm, int constrainHeight, int totalHeight, int alignment) { - int y = -fm.top; - - if (constrainHeight > totalHeight) { - int vAlignment = (alignment >> 4) & 0x0F; - - switch (vAlignment) { - case VALIGNTOP: - y = -fm.top; - break; - case VALIGNCENTER: - y = -fm.top + (constrainHeight - totalHeight)/2; - break; - case VALIGNBOTTOM: - y = -fm.top + (constrainHeight - totalHeight); - break; - default: - break; - } - } - - return y; - } - - private static class TextProperty{ - // The max width of lines - int maxWidth; - // The height of all lines - int totalHeight; - int heightPerLine; - String[] lines; - - TextProperty(int w, int h, String[] lines){ - this.maxWidth = w; - this.heightPerLine = h; - this.totalHeight = h * lines.length; - this.lines = lines; - } - } - - private static TextProperty computeTextProperty(String content, Paint paint, - int maxWidth, int maxHeight){ - FontMetricsInt fm = paint.getFontMetricsInt(); - int h = (int)Math.ceil(fm.bottom - fm.top); - int maxContentWidth = 0; - - String[] lines = splitString(content, maxHeight, maxWidth, paint); - - if (maxWidth != 0){ - maxContentWidth = maxWidth; - } - else { - /* - * Compute the max width - */ - int temp = 0; - for (String line : lines){ - temp = (int)Math.ceil(paint.measureText(line, 0, line.length())); - if (temp > maxContentWidth){ - maxContentWidth = temp; - } - } - } - - return new TextProperty(maxContentWidth, h, lines); - } - - /* - * If maxWidth or maxHeight is not 0, - * split the string to fix the maxWidth and maxHeight. - */ - private static String[] splitString(String content, int maxHeight, int maxWidth, - Paint paint){ - String[] lines = content.split("\\n"); - String[] ret = null; - FontMetricsInt fm = paint.getFontMetricsInt(); - int heightPerLine = (int)Math.ceil(fm.bottom - fm.top); - int maxLines = maxHeight / heightPerLine; - - if (maxWidth != 0){ - LinkedList strList = new LinkedList(); - for (String line : lines){ - /* - * The width of line is exceed maxWidth, should divide it into - * two or more lines. - */ - int lineWidth = (int)Math.ceil(paint.measureText(line)); - if (lineWidth > maxWidth){ - strList.addAll(divideStringWithMaxWidth(paint, line, maxWidth)); - } - else{ - strList.add(line); - } - - /* - * Should not exceed the max height; - */ - if (maxLines > 0 && strList.size() >= maxLines){ - break; - } - } - - /* - * Remove exceeding lines - */ - if (maxLines > 0 && strList.size() > maxLines){ - while (strList.size() > maxLines){ - strList.removeLast(); - } - } - - ret = new String[strList.size()]; - strList.toArray(ret); - } else - if (maxHeight != 0 && lines.length > maxLines) { - /* - * Remove exceeding lines - */ - LinkedList strList = new LinkedList(); - for (int i = 0; i < maxLines; i++){ - strList.add(lines[i]); - } - ret = new String[strList.size()]; - strList.toArray(ret); - } - else { - ret = lines; - } - - return ret; - } - - private static LinkedList divideStringWithMaxWidth(Paint paint, String content, - int width){ - int charLength = content.length(); - int start = 0; - int tempWidth = 0; - LinkedList strList = new LinkedList(); - - /* - * Break a String into String[] by the width & should wrap the word - */ - for (int i = 1; i <= charLength; ++i){ - tempWidth = (int)Math.ceil(paint.measureText(content, start, i)); - if (tempWidth >= width){ - int lastIndexOfSpace = content.substring(0, i).lastIndexOf(" "); - - if (lastIndexOfSpace != -1 && lastIndexOfSpace > start){ - /** - * Should wrap the word - */ - strList.add(content.substring(start, lastIndexOfSpace)); - i = lastIndexOfSpace; - } - else { - /* - * Should not exceed the width - */ - if (tempWidth > width){ - strList.add(content.substring(start, i - 1)); - /* - * compute from previous char - */ - --i; - } - else { - strList.add(content.substring(start, i)); - } - } - - // remove spaces at the beginning of a new line - while(content.indexOf(i++) == ' ') { - } - - start = i; - } - } - - /* - * Add the last chars - */ - if (start < charLength){ - strList.add(content.substring(start)); - } - - return strList; - } - - private static Paint newPaint(String fontName, int fontSize, int alignment){ - Paint paint = new Paint(); - paint.setColor(Color.WHITE); - paint.setTextSize(fontSize); - paint.setAntiAlias(true); - - /* - * Set type face for paint, now it support .ttf file. - */ - if (fontName.endsWith(".ttf")){ - try { - //Typeface typeFace = Typeface.createFromAsset(context.getAssets(), fontName); - Typeface typeFace = Cocos2dxTypefaces.get(context, fontName); - paint.setTypeface(typeFace); - } catch (Exception e){ - Log.e("Cocos2dxBitmap", - "error to create ttf type face: " + fontName); - - /* - * The file may not find, use system font - */ - paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL)); - } - } - else { - paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL)); - } - - int hAlignment = alignment & 0x0F; - switch (hAlignment){ - case HALIGNCENTER: - paint.setTextAlign(Align.CENTER); - break; - - case HALIGNLEFT: - paint.setTextAlign(Align.LEFT); - break; - - case HALIGNRIGHT: - paint.setTextAlign(Align.RIGHT); - break; - - default: - paint.setTextAlign(Align.LEFT); - break; - } - - return paint; - } - - private static String refactorString(String str){ - // Avoid error when content is "" - if (str.compareTo("") == 0){ - return " "; - } - - /* - * If the font of "\n" is "" or "\n", insert " " in front of it. - * - * For example: - * "\nabc" -> " \nabc" - * "\nabc\n\n" -> " \nabc\n \n" - */ - StringBuilder strBuilder = new StringBuilder(str); - int start = 0; - int index = strBuilder.indexOf("\n"); - while (index != -1){ - if (index == 0 || strBuilder.charAt(index -1) == '\n'){ - strBuilder.insert(start, " "); - start = index + 2; - } else { - start = index + 1; - } - - if (start > strBuilder.length() || index == strBuilder.length()){ - break; - } - - index = strBuilder.indexOf("\n", start); - } - - return strBuilder.toString(); - } - - private static void initNativeObject(Bitmap bitmap){ - byte[] pixels = getPixels(bitmap); - if (pixels == null){ - return; - } - - nativeInitBitmapDC(bitmap.getWidth(), bitmap.getHeight(), pixels); - } - - private static byte[] getPixels(Bitmap bitmap){ - if (bitmap != null){ - byte[] pixels = new byte[bitmap.getWidth() * bitmap.getHeight() * 4]; - ByteBuffer buf = ByteBuffer.wrap(pixels); - buf.order(ByteOrder.nativeOrder()); - bitmap.copyPixelsToBuffer(buf); - return pixels; - } - - return null; - } - - private static native void nativeInitBitmapDC(int width, int height, byte[] pixels); -} diff --git a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxEditText.java b/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxEditText.java deleted file mode 100644 index 1c9778293f..0000000000 --- a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxEditText.java +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -Copyright (c) 2012 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -package org.cocos2dx.lib; - -import android.content.Context; -import android.util.AttributeSet; -import android.view.KeyEvent; -import android.widget.EditText; - -public class Cocos2dxEditText extends EditText { - - private Cocos2dxGLSurfaceView mView; - - public Cocos2dxEditText(Context context) { - super(context); - // TODO Auto-generated constructor stub - } - - public Cocos2dxEditText(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public Cocos2dxEditText(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - public void setMainView(Cocos2dxGLSurfaceView glSurfaceView) { - mView = glSurfaceView; - } - - /* - * Let GlSurfaceView get focus if back key is input - */ - public boolean onKeyDown(int keyCode, KeyEvent event) { - super.onKeyDown(keyCode, event); - - if (keyCode == KeyEvent.KEYCODE_BACK) { - mView.requestFocus(); - } - - return true; - } -} diff --git a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java b/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java deleted file mode 100644 index e7c4721cf3..0000000000 --- a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java +++ /dev/null @@ -1,417 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import android.content.Context; -import android.opengl.GLSurfaceView; -import android.os.Handler; -import android.os.Message; -import android.text.Editable; -import android.text.TextWatcher; -import android.util.AttributeSet; -import android.util.Log; -import android.view.KeyEvent; -import android.view.MotionEvent; -import android.view.inputmethod.InputMethodManager; -import android.widget.TextView; -import android.widget.TextView.OnEditorActionListener; - -class TextInputWraper implements TextWatcher, OnEditorActionListener { - - private static final Boolean debug = false; - private void LogD(String msg) { - if (debug) Log.d("TextInputFilter", msg); - } - - private Cocos2dxGLSurfaceView mMainView; - private String mText; - private String mOriginText; - - private Boolean isFullScreenEdit() { - InputMethodManager imm = (InputMethodManager)mMainView.getTextField().getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - return imm.isFullscreenMode(); - } - - public TextInputWraper(Cocos2dxGLSurfaceView view) { - mMainView = view; - } - - public void setOriginText(String text) { - mOriginText = text; - } - - @Override - public void afterTextChanged(Editable s) { - if (isFullScreenEdit()) { - return; - } - - LogD("afterTextChanged: " + s); - int nModified = s.length() - mText.length(); - if (nModified > 0) { - final String insertText = s.subSequence(mText.length(), s.length()).toString(); - mMainView.insertText(insertText); - LogD("insertText(" + insertText + ")"); - } - else { - for (; nModified < 0; ++nModified) { - mMainView.deleteBackward(); - LogD("deleteBackward"); - } - } - mText = s.toString(); - } - - @Override - public void beforeTextChanged(CharSequence s, int start, int count, - int after) { - LogD("beforeTextChanged(" + s + ")start: " + start + ",count: " + count + ",after: " + after); - mText = s.toString(); - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - } - - @Override - public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { - if (mMainView.getTextField() == v && isFullScreenEdit()) { - // user press the action button, delete all old text and insert new text - for (int i = mOriginText.length(); i > 0; --i) { - mMainView.deleteBackward(); - LogD("deleteBackward"); - } - String text = v.getText().toString(); - - /* - * If user input nothing, translate "\n" to engine. - */ - if (text.compareTo("") == 0){ - text = "\n"; - } - - if ('\n' != text.charAt(text.length() - 1)) { - text += '\n'; - } - - final String insertText = text; - mMainView.insertText(insertText); - LogD("insertText(" + insertText + ")"); - } - return false; - } -} - -public class Cocos2dxGLSurfaceView extends GLSurfaceView { - - static private Cocos2dxGLSurfaceView mainView; - - private static final String TAG = Cocos2dxGLSurfaceView.class.getCanonicalName(); - private Cocos2dxRenderer mRenderer; - - private static final boolean debug = false; - - /////////////////////////////////////////////////////////////////////////// - // for initialize - /////////////////////////////////////////////////////////////////////////// - public Cocos2dxGLSurfaceView(Context context) { - super(context); - initView(); - } - - public Cocos2dxGLSurfaceView(Context context, AttributeSet attrs) { - super(context, attrs); - initView(); - } - - public void setCocos2dxRenderer(Cocos2dxRenderer renderer){ - mRenderer = renderer; - setRenderer(mRenderer); - } - - protected void initView() { - setFocusableInTouchMode(true); - - textInputWraper = new TextInputWraper(this); - - handler = new Handler(){ - public void handleMessage(Message msg){ - switch(msg.what){ - case HANDLER_OPEN_IME_KEYBOARD: - if (null != mTextField && mTextField.requestFocus()) { - mTextField.removeTextChangedListener(textInputWraper); - mTextField.setText(""); - String text = (String)msg.obj; - mTextField.append(text); - textInputWraper.setOriginText(text); - mTextField.addTextChangedListener(textInputWraper); - InputMethodManager imm = (InputMethodManager)mainView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - imm.showSoftInput(mTextField, 0); - Log.d("GLSurfaceView", "showSoftInput"); - } - break; - - case HANDLER_CLOSE_IME_KEYBOARD: - if (null != mTextField) { - mTextField.removeTextChangedListener(textInputWraper); - InputMethodManager imm = (InputMethodManager)mainView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(mTextField.getWindowToken(), 0); - Log.d("GLSurfaceView", "HideSoftInput"); - } - break; - } - } - }; - - mainView = this; - } - - public void onPause(){ - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleOnPause(); - } - }); - - super.onPause(); - } - - public void onResume(){ - super.onResume(); - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleOnResume(); - } - }); - } - - /////////////////////////////////////////////////////////////////////////// - // for text input - /////////////////////////////////////////////////////////////////////////// - private final static int HANDLER_OPEN_IME_KEYBOARD = 2; - private final static int HANDLER_CLOSE_IME_KEYBOARD = 3; - private static Handler handler; - private static TextInputWraper textInputWraper; - private Cocos2dxEditText mTextField; - - public TextView getTextField() { - return mTextField; - } - - public void setTextField(Cocos2dxEditText view) { - mTextField = view; - if (null != mTextField && null != textInputWraper) { - mTextField.setOnEditorActionListener(textInputWraper); - mTextField.setMainView(this); - this.requestFocus(); - } - } - - public static void openIMEKeyboard() { - Message msg = new Message(); - msg.what = HANDLER_OPEN_IME_KEYBOARD; - msg.obj = mainView.getContentText(); - handler.sendMessage(msg); - - } - - private String getContentText() { - return mRenderer.getContentText(); - } - - public static void closeIMEKeyboard() { - Message msg = new Message(); - msg.what = HANDLER_CLOSE_IME_KEYBOARD; - handler.sendMessage(msg); - } - - public void insertText(final String text) { - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleInsertText(text); - } - }); - } - - public void deleteBackward() { - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleDeleteBackward(); - } - }); - } - - /////////////////////////////////////////////////////////////////////////// - // for touch event - /////////////////////////////////////////////////////////////////////////// - - public boolean onTouchEvent(final MotionEvent event) { - // these data are used in ACTION_MOVE and ACTION_CANCEL - final int pointerNumber = event.getPointerCount(); - final int[] ids = new int[pointerNumber]; - final float[] xs = new float[pointerNumber]; - final float[] ys = new float[pointerNumber]; - - for (int i = 0; i < pointerNumber; i++) { - ids[i] = event.getPointerId(i); - xs[i] = event.getX(i); - ys[i] = event.getY(i); - } - - switch (event.getAction() & MotionEvent.ACTION_MASK) { - case MotionEvent.ACTION_POINTER_DOWN: - final int indexPointerDown = event.getAction() >> MotionEvent.ACTION_POINTER_ID_SHIFT; - final int idPointerDown = event.getPointerId(indexPointerDown); - final float xPointerDown = event.getX(indexPointerDown); - final float yPointerDown = event.getY(indexPointerDown); - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionDown(idPointerDown, xPointerDown, yPointerDown); - } - }); - break; - - case MotionEvent.ACTION_DOWN: - // there are only one finger on the screen - final int idDown = event.getPointerId(0); - final float xDown = xs[0]; - final float yDown = ys[0]; - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionDown(idDown, xDown, yDown); - } - }); - break; - - case MotionEvent.ACTION_MOVE: - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionMove(ids, xs, ys); - } - }); - break; - - case MotionEvent.ACTION_POINTER_UP: - final int indexPointUp = event.getAction() >> MotionEvent.ACTION_POINTER_ID_SHIFT; - final int idPointerUp = event.getPointerId(indexPointUp); - final float xPointerUp = event.getX(indexPointUp); - final float yPointerUp = event.getY(indexPointUp); - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionUp(idPointerUp, xPointerUp, yPointerUp); - } - }); - break; - - case MotionEvent.ACTION_UP: - // there are only one finger on the screen - final int idUp = event.getPointerId(0); - final float xUp = xs[0]; - final float yUp = ys[0]; - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionUp(idUp, xUp, yUp); - } - }); - break; - - case MotionEvent.ACTION_CANCEL: - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionCancel(ids, xs, ys); - } - }); - break; - } - - if (debug){ - dumpEvent(event); - } - return true; - } - - /* - * This function is called before Cocos2dxRenderer.nativeInit(), so the width and height is correct. - */ - protected void onSizeChanged(int w, int h, int oldw, int oldh){ - this.mRenderer.setScreenWidthAndHeight(w, h); - } - - @Override - public boolean onKeyDown(int keyCode, KeyEvent event) { - final int kc = keyCode; - if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) { - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleKeyDown(kc); - } - }); - return true; - } - return super.onKeyDown(keyCode, event); - } - - // Show an event in the LogCat view, for debugging - private void dumpEvent(MotionEvent event) { - String names[] = { "DOWN" , "UP" , "MOVE" , "CANCEL" , "OUTSIDE" , - "POINTER_DOWN" , "POINTER_UP" , "7?" , "8?" , "9?" }; - StringBuilder sb = new StringBuilder(); - int action = event.getAction(); - int actionCode = action & MotionEvent.ACTION_MASK; - sb.append("event ACTION_" ).append(names[actionCode]); - if (actionCode == MotionEvent.ACTION_POINTER_DOWN - || actionCode == MotionEvent.ACTION_POINTER_UP) { - sb.append("(pid " ).append( - action >> MotionEvent.ACTION_POINTER_ID_SHIFT); - sb.append(")" ); - } - sb.append("[" ); - for (int i = 0; i < event.getPointerCount(); i++) { - sb.append("#" ).append(i); - sb.append("(pid " ).append(event.getPointerId(i)); - sb.append(")=" ).append((int) event.getX(i)); - sb.append("," ).append((int) event.getY(i)); - if (i + 1 < event.getPointerCount()) - sb.append(";" ); - } - sb.append("]" ); - Log.d(TAG, sb.toString()); - } -} diff --git a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxMusic.java b/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxMusic.java deleted file mode 100644 index 10e3e5f3c6..0000000000 --- a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxMusic.java +++ /dev/null @@ -1,228 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import android.content.Context; -import android.content.res.AssetFileDescriptor; -import android.media.MediaPlayer; -import android.util.Log; - -/** - * - * This class is used for controlling background music - * - */ -public class Cocos2dxMusic { - - private static final String TAG = "Cocos2dxMusic"; - private float mLeftVolume; - private float mRightVolume; - private Context mContext; - private MediaPlayer mBackgroundMediaPlayer; - private boolean mIsPaused; - private String mCurrentPath; - - public Cocos2dxMusic(Context context){ - this.mContext = context; - initData(); - } - - public void preloadBackgroundMusic(String path){ - if ((mCurrentPath == null) || (! mCurrentPath.equals(path))){ - // preload new background music - - // release old resource and create a new one - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.release(); - } - - mBackgroundMediaPlayer = createMediaplayerFromAssets(path); - - // record the path - mCurrentPath = path; - } - } - - public void playBackgroundMusic(String path, boolean isLoop){ - if (mCurrentPath == null){ - // it is the first time to play background music - // or end() was called - mBackgroundMediaPlayer = createMediaplayerFromAssets(path); - mCurrentPath = path; - } - else { - if (! mCurrentPath.equals(path)){ - // play new background music - - // release old resource and create a new one - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.release(); - } - mBackgroundMediaPlayer = createMediaplayerFromAssets(path); - - // record the path - mCurrentPath = path; - } - } - - if (mBackgroundMediaPlayer == null){ - Log.e(TAG, "playBackgroundMusic: background media player is null"); - } else { - // if the music is playing or paused, stop it - mBackgroundMediaPlayer.stop(); - - mBackgroundMediaPlayer.setLooping(isLoop); - - try { - mBackgroundMediaPlayer.prepare(); - mBackgroundMediaPlayer.seekTo(0); - mBackgroundMediaPlayer.start(); - - this.mIsPaused = false; - } catch (Exception e){ - Log.e(TAG, "playBackgroundMusic: error state"); - } - } - } - - public void stopBackgroundMusic(){ - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.stop(); - - // should set the state, if not , the following sequence will be error - // play -> pause -> stop -> resume - this.mIsPaused = false; - } - } - - public void pauseBackgroundMusic(){ - if (mBackgroundMediaPlayer != null && mBackgroundMediaPlayer.isPlaying()){ - mBackgroundMediaPlayer.pause(); - this.mIsPaused = true; - } - } - - public void resumeBackgroundMusic(){ - if (mBackgroundMediaPlayer != null && this.mIsPaused){ - mBackgroundMediaPlayer.start(); - this.mIsPaused = false; - } - } - - public void rewindBackgroundMusic(){ - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.stop(); - - try { - mBackgroundMediaPlayer.prepare(); - mBackgroundMediaPlayer.seekTo(0); - mBackgroundMediaPlayer.start(); - - this.mIsPaused = false; - } catch (Exception e){ - Log.e(TAG, "rewindBackgroundMusic: error state"); - } - } - } - - public boolean isBackgroundMusicPlaying(){ - boolean ret = false; - - if (mBackgroundMediaPlayer == null){ - ret = false; - } else { - ret = mBackgroundMediaPlayer.isPlaying(); - } - - return ret; - } - - public void end(){ - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.release(); - } - - initData(); - } - - public float getBackgroundVolume(){ - if (this.mBackgroundMediaPlayer != null){ - return (this.mLeftVolume + this.mRightVolume) / 2; - } else { - return 0.0f; - } - } - - public void setBackgroundVolume(float volume){ - if (volume < 0.0f){ - volume = 0.0f; - } - - if (volume > 1.0f){ - volume = 1.0f; - } - - this.mLeftVolume = this.mRightVolume = volume; - if (this.mBackgroundMediaPlayer != null){ - this.mBackgroundMediaPlayer.setVolume(this.mLeftVolume, this.mRightVolume); - } - } - - private void initData(){ - mLeftVolume =0.5f; - mRightVolume = 0.5f; - mBackgroundMediaPlayer = null; - mIsPaused = false; - mCurrentPath = null; - } - - /** - * create mediaplayer for music - * @param path the path relative to assets - * @return - */ - private MediaPlayer createMediaplayerFromAssets(String path){ - MediaPlayer mediaPlayer = new MediaPlayer(); - - try{ - if (path.startsWith("/")) { - mediaPlayer.setDataSource(path); - } - else { - AssetFileDescriptor assetFileDescritor = mContext.getAssets().openFd(path); - mediaPlayer.setDataSource(assetFileDescritor.getFileDescriptor(), - assetFileDescritor.getStartOffset(), assetFileDescritor.getLength()); - } - - mediaPlayer.prepare(); - - mediaPlayer.setVolume(mLeftVolume, mRightVolume); - }catch (Exception e) { - mediaPlayer = null; - Log.e(TAG, "error: " + e.getMessage(), e); - } - - return mediaPlayer; - } -} diff --git a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxRenderer.java b/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxRenderer.java deleted file mode 100644 index fad0974f42..0000000000 --- a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxRenderer.java +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.opengles.GL10; - -import android.opengl.GLSurfaceView; - -public class Cocos2dxRenderer implements GLSurfaceView.Renderer { - private final static long NANOSECONDSPERSECOND = 1000000000L; - private final static long NANOSECONDSPERMINISECOND = 1000000; - private static long animationInterval = (long)(1.0 / 60 * NANOSECONDSPERSECOND); - private long last; - private int screenWidth; - private int screenHeight; - - public void onSurfaceCreated(GL10 gl, EGLConfig config) { - nativeInit(screenWidth, screenHeight); - last = System.nanoTime(); - } - - public void setScreenWidthAndHeight(int w, int h){ - this.screenWidth = w; - this.screenHeight = h; - } - - public void onSurfaceChanged(GL10 gl, int w, int h) { - } - - public void onDrawFrame(GL10 gl) { - - long now = System.nanoTime(); - long interval = now - last; - - // should render a frame when onDrawFrame() is called - // or there is a "ghost" - nativeRender(); - - // fps controlling - if (interval < animationInterval){ - try { - // because we render it before, so we should sleep twice time interval - Thread.sleep((animationInterval - interval) * 2 / NANOSECONDSPERMINISECOND); - } catch (Exception e){} - } - - last = now; - } - - public void handleActionDown(int id, float x, float y) - { - nativeTouchesBegin(id, x, y); - } - - public void handleActionUp(int id, float x, float y) - { - nativeTouchesEnd(id, x, y); - } - - public void handleActionCancel(int[] id, float[] x, float[] y) - { - nativeTouchesCancel(id, x, y); - } - - public void handleActionMove(int[] id, float[] x, float[] y) - { - nativeTouchesMove(id, x, y); - } - - public void handleKeyDown(int keyCode) - { - nativeKeyDown(keyCode); - } - - public void handleOnPause(){ - nativeOnPause(); - } - - public void handleOnResume(){ - nativeOnResume(); - } - - public static void setAnimationInterval(double interval){ - animationInterval = (long)(interval * NANOSECONDSPERSECOND); - } - private static native void nativeTouchesBegin(int id, float x, float y); - private static native void nativeTouchesEnd(int id, float x, float y); - private static native void nativeTouchesMove(int[] id, float[] x, float[] y); - private static native void nativeTouchesCancel(int[] id, float[] x, float[] y); - private static native boolean nativeKeyDown(int keyCode); - private static native void nativeRender(); - private static native void nativeInit(int w, int h); - private static native void nativeOnPause(); - private static native void nativeOnResume(); - - ///////////////////////////////////////////////////////////////////////////////// - // handle input method edit message - ///////////////////////////////////////////////////////////////////////////////// - - public void handleInsertText(final String text) { - nativeInsertText(text); - } - - public void handleDeleteBackward() { - nativeDeleteBackward(); - } - - public String getContentText() { - return nativeGetContentText(); - } - - private static native void nativeInsertText(String text); - private static native void nativeDeleteBackward(); - private static native String nativeGetContentText(); -} diff --git a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java b/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java deleted file mode 100644 index e7061f74de..0000000000 --- a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java +++ /dev/null @@ -1,245 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import android.content.Context; -import android.media.AudioManager; -import android.media.SoundPool; -import android.util.Log; - -/** - * - * This class is used for controlling effect - * - */ - -public class Cocos2dxSound { - private Context mContext; - private SoundPool mSoundPool; - private float mLeftVolume; - private float mRightVolume; - - // sound path and stream ids map - // a file may be played many times at the same time - // so there is an array map to a file path - private HashMap> mPathStreamIDsMap; - - private HashMap mPathSoundIdMap; - - private static final String TAG = "Cocos2dxSound"; - private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 5; - private static final float SOUND_RATE = 1.0f; - private static final int SOUND_PRIORITY = 1; - private static final int SOUND_QUALITY = 5; - - private final static int INVALID_SOUND_ID = -1; - private final static int INVALID_STREAM_ID = -1; - - public Cocos2dxSound(Context context){ - this.mContext = context; - initData(); - } - - public int preloadEffect(String path){ - Integer soundID = this.mPathSoundIdMap.get(path); - - if (soundID == null) { - soundID = createSoundIdFromAsset(path); - this.mPathSoundIdMap.put(path, soundID); - } - - return soundID; - } - - public void unloadEffect(String path){ - // stop effects - ArrayList streamIDs = this.mPathStreamIDsMap.get(path); - if (streamIDs != null) { - for (Integer streamID : streamIDs) { - this.mSoundPool.stop(streamID); - } - } - this.mPathStreamIDsMap.remove(path); - - // unload effect - Integer soundID = this.mPathSoundIdMap.get(path); - this.mSoundPool.unload(soundID); - this.mPathSoundIdMap.remove(path); - } - - public int playEffect(String path, boolean isLoop){ - Integer soundId = this.mPathSoundIdMap.get(path); - int streamId = INVALID_STREAM_ID; - - if (soundId != null){ - // play sound - streamId = this.mSoundPool.play(soundId.intValue(), this.mLeftVolume, - this.mRightVolume, SOUND_PRIORITY, isLoop ? -1 : 0, SOUND_RATE); - - // record stream id - ArrayList streamIds = this.mPathStreamIDsMap.get(path); - if (streamIds == null) { - streamIds = new ArrayList(); - this.mPathStreamIDsMap.put(path, streamIds); - } - streamIds.add(streamId); - } else { - // the effect is not prepared - soundId = preloadEffect(path); - if (soundId == INVALID_SOUND_ID){ - // can not preload effect - return INVALID_SOUND_ID; - } - - /* - * Someone reports that, it can not play effect for the - * first time. If you are lucky to meet it. There are two - * ways to resolve it. - * 1. Add some delay here. I don't know how long it is, so - * I don't add it here. - * 2. If you use 2.2(API level 8), you can call - * SoundPool.setOnLoadCompleteListener() to play the effect. - * Because the method is supported from 2.2, so I can't use - * it here. - */ - playEffect(path, isLoop); - } - - return streamId; - } - - public void stopEffect(int streamID){ - this.mSoundPool.stop(streamID); - - // remove record - for (String path : this.mPathStreamIDsMap.keySet()) { - if (this.mPathStreamIDsMap.get(path).contains(streamID)) { - this.mPathStreamIDsMap.get(path).remove(this.mPathStreamIDsMap.get(path).indexOf(streamID)); - break; - } - } - } - - public void pauseEffect(int streamID){ - this.mSoundPool.pause(streamID); - } - - public void resumeEffect(int streamID){ - this.mSoundPool.resume(streamID); - } - - public void pauseAllEffects(){ - this.mSoundPool.autoPause(); - } - - public void resumeAllEffects(){ - // autoPause() is available since level 8 - this.mSoundPool.autoResume(); - } - - @SuppressWarnings("unchecked") - public void stopAllEffects(){ - // stop effects - if (! this.mPathStreamIDsMap.isEmpty()) { - Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry> entry = (Map.Entry>)iter.next(); - for (int streamID : entry.getValue()) { - this.mSoundPool.stop(streamID); - } - } - } - - // remove records - this.mPathStreamIDsMap.clear(); - } - - public float getEffectsVolume(){ - return (this.mLeftVolume + this.mRightVolume) / 2; - } - - @SuppressWarnings("unchecked") - public void setEffectsVolume(float volume){ - // volume should be in [0, 1.0] - if (volume < 0){ - volume = 0; - } - if (volume > 1){ - volume = 1; - } - - this.mLeftVolume = this.mRightVolume = volume; - - // change the volume of playing sounds - if (! this.mPathStreamIDsMap.isEmpty()) { - Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry> entry = (Map.Entry>)iter.next(); - for (int streamID : entry.getValue()) { - this.mSoundPool.setVolume(streamID, mLeftVolume, mRightVolume); - } - } - } - } - - public void end(){ - this.mSoundPool.release(); - this.mPathStreamIDsMap.clear(); - this.mPathSoundIdMap.clear(); - - initData(); - } - - public int createSoundIdFromAsset(String path){ - int soundId = INVALID_SOUND_ID; - - try { - if (path.startsWith("/")){ - soundId = mSoundPool.load(path, 0); - } - else { - soundId = mSoundPool.load(mContext.getAssets().openFd(path), 0); - } - } catch(Exception e){ - soundId = INVALID_SOUND_ID; - Log.e(TAG, "error: " + e.getMessage(), e); - } - - return soundId; - } - - private void initData(){ - this.mPathStreamIDsMap = new HashMap>(); - this.mPathSoundIdMap = new HashMap(); - mSoundPool = new SoundPool(MAX_SIMULTANEOUS_STREAMS_DEFAULT, AudioManager.STREAM_MUSIC, SOUND_QUALITY); - - this.mLeftVolume = 0.5f; - this.mRightVolume = 0.5f; - } -} diff --git a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxTypefaces.java b/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxTypefaces.java deleted file mode 100644 index 79af1ed3af..0000000000 --- a/tests/proj.android/src/org/cocos2dx/lib/Cocos2dxTypefaces.java +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import java.util.Hashtable; - -import android.content.Context; -import android.graphics.Typeface; - -public class Cocos2dxTypefaces { - private static final Hashtable cache = new Hashtable(); - - public static Typeface get(Context context, String name){ - synchronized(cache){ - if (! cache.containsKey(name)){ - Typeface t = Typeface.createFromAsset(context.getAssets(), name); - cache.put(name, t); - } - - return cache.get(name); - } - } -} diff --git a/tests/proj.android/src/org/cocos2dx/tests/TestsDemo.java b/tests/proj.android/src/org/cocos2dx/tests/TestsDemo.java index a534137091..2c15ed0abd 100644 --- a/tests/proj.android/src/org/cocos2dx/tests/TestsDemo.java +++ b/tests/proj.android/src/org/cocos2dx/tests/TestsDemo.java @@ -45,10 +45,10 @@ public class TestsDemo extends Cocos2dxActivity{ String packageName = getApplication().getPackageName(); super.setPackageName(packageName); - setContentView(R.layout.test_demo); + setContentView(R.layout.cocos2dx_default_screen_layout); - mGLView = (Cocos2dxGLSurfaceView) findViewById(R.id.test_demo_gl_surfaceview); - mGLView.setTextField((Cocos2dxEditText)findViewById(R.id.textField)); + mGLView = (Cocos2dxGLSurfaceView) findViewById(R.id.cocos2dx_default_gl_surfaceview); + mGLView.setTextField((Cocos2dxEditText)findViewById(R.id.cocos2dx_default_textField)); mGLView.setEGLContextClientVersion(2); mGLView.setCocos2dxRenderer(new Cocos2dxRenderer()); } From d651da6f0d87679970d904805273a296e54d5320 Mon Sep 17 00:00:00 2001 From: folecr Date: Tue, 22 May 2012 18:42:14 -0700 Subject: [PATCH 181/257] Tests : Ant build project files --- tests/proj.android/ant.properties | 17 +++++ tests/proj.android/build.xml | 83 +++++++++++++++++++++++++ tests/proj.android/proguard-project.txt | 20 ++++++ 3 files changed, 120 insertions(+) create mode 100644 tests/proj.android/ant.properties create mode 100644 tests/proj.android/build.xml create mode 100644 tests/proj.android/proguard-project.txt diff --git a/tests/proj.android/ant.properties b/tests/proj.android/ant.properties new file mode 100644 index 0000000000..b0971e891e --- /dev/null +++ b/tests/proj.android/ant.properties @@ -0,0 +1,17 @@ +# This file is used to override default values used by the Ant build system. +# +# This file must be checked into Version Control Systems, as it is +# integral to the build system of your project. + +# This file is only used by the Ant script. + +# You can use this to override default values such as +# 'source.dir' for the location of your java source folder and +# 'out.dir' for the location of your output folder. + +# You can also use it define how the release builds are signed by declaring +# the following properties: +# 'key.store' for the location of your keystore and +# 'key.alias' for the name of the key to use. +# The password will be asked during the build when you use the 'release' target. + diff --git a/tests/proj.android/build.xml b/tests/proj.android/build.xml new file mode 100644 index 0000000000..0ab7005e21 --- /dev/null +++ b/tests/proj.android/build.xml @@ -0,0 +1,83 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/proj.android/proguard-project.txt b/tests/proj.android/proguard-project.txt new file mode 100644 index 0000000000..f2fe1559a2 --- /dev/null +++ b/tests/proj.android/proguard-project.txt @@ -0,0 +1,20 @@ +# To enable ProGuard in your project, edit project.properties +# to define the proguard.config property as described in that file. +# +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in ${sdk.dir}/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the ProGuard +# include property in project.properties. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} From 4c1ca36aa80dcfa588f1259ea2077e40abc476a2 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 15 Jun 2012 10:51:53 +0800 Subject: [PATCH 182/257] fixed #1326: The compilation of Hellolua and testjs project was broken after synchronizing to rc2. --- HelloLua/Classes/AppDelegate.cpp | 4 +- .../CCTransitionProgress.h | 7 +++ js/JSBindings/ScriptingCore.cpp | 6 +- .../cocos2d_generated.cpp.REMOVED.git-id | 2 +- .../cocos2d_generated.hpp.REMOVED.git-id | 2 +- js/JSBindings/cocos2d_manual_bindings.cpp | 6 +- lua/cocos2dx_support/CCLuaEngine.cpp | 2 +- lua/cocos2dx_support/CCLuaEngine.h | 2 +- lua/cocos2dx_support/Cocos2dxLuaLoader.cpp | 12 +--- .../LuaCocos2d.cpp.REMOVED.git-id | 2 +- .../Templates/1033/Classes/AppDelegate.cpp | 4 +- .../Classes/HelloWorldScene.cpp | 2 +- .../Classes/HelloWorldScene.cpp | 2 +- .../Classes/AppDelegate.cpp | 4 +- .../template/Classes/AppDelegate.cpp | 4 +- tools/tolua++/CCAction.pkg | 56 ++++++++--------- tools/tolua++/CCActionGrid.pkg | 8 +-- tools/tolua++/CCActionGrid3D.pkg | 18 +++--- tools/tolua++/CCActionPageTurn3D.pkg | 2 +- tools/tolua++/CCActionProgressTimer.pkg | 4 +- tools/tolua++/CCActionTiledGrid.pkg | 26 ++++---- tools/tolua++/CCDirector.pkg | 2 +- tools/tolua++/CCFileUtils.pkg | 3 +- tools/tolua++/CCNode.pkg | 4 +- tools/tolua++/CCScheduler.pkg | 12 ++-- tools/tolua++/CCSprite.pkg | 4 +- tools/tolua++/CCTexture2D.pkg | 4 +- tools/tolua++/CCTransition.pkg | 60 +++++++++---------- tools/tolua++/ccTypes.pkg | 19 ++++-- 29 files changed, 146 insertions(+), 137 deletions(-) diff --git a/HelloLua/Classes/AppDelegate.cpp b/HelloLua/Classes/AppDelegate.cpp index 0fcf6dbe98..9fedb01fd5 100644 --- a/HelloLua/Classes/AppDelegate.cpp +++ b/HelloLua/Classes/AppDelegate.cpp @@ -40,13 +40,13 @@ bool AppDelegate::applicationDidFinishLaunching() CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua"); + CCString* pstrFileContent = CCString::createWithContentsOfFile("hello.lua"); if (pstrFileContent) { pEngine->executeString(pstrFileContent->getCString()); } #else - std::string path = CCFileUtils::fullPathFromRelativePath("hello.lua"); + std::string path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("hello.lua"); pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str()); pEngine->executeScriptFile(path.c_str()); #endif diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.h b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.h index 060b11dbf8..029ab67cc9 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.h @@ -37,6 +37,7 @@ class CCRenderTexture; class CC_DLL CCTransitionProgress : public CCTransitionScene { public: + OLD_TRANSITION_CREATE_FUNC(CCTransitionProgress) TRANSITION_CREATE_FUNC(CCTransitionProgress) CCTransitionProgress(); @@ -58,6 +59,7 @@ protected: class CC_DLL CCTransitionProgressRadialCCW : public CCTransitionProgress { public: + OLD_TRANSITION_CREATE_FUNC(CCTransitionProgressRadialCCW) TRANSITION_CREATE_FUNC(CCTransitionProgressRadialCCW) protected: virtual CCProgressTimer* progressTimerNodeWithRenderTexture(CCRenderTexture* texture); @@ -71,6 +73,7 @@ protected: class CC_DLL CCTransitionProgressRadialCW : public CCTransitionProgress { public: + OLD_TRANSITION_CREATE_FUNC(CCTransitionProgressRadialCW) TRANSITION_CREATE_FUNC(CCTransitionProgressRadialCW) protected: virtual CCProgressTimer* progressTimerNodeWithRenderTexture(CCRenderTexture* texture); @@ -83,6 +86,7 @@ protected: class CC_DLL CCTransitionProgressHorizontal : public CCTransitionProgress { public: + OLD_TRANSITION_CREATE_FUNC(CCTransitionProgressHorizontal) TRANSITION_CREATE_FUNC(CCTransitionProgressHorizontal) protected: virtual CCProgressTimer* progressTimerNodeWithRenderTexture(CCRenderTexture* texture); @@ -92,6 +96,7 @@ protected: class CC_DLL CCTransitionProgressVertical : public CCTransitionProgress { public: + OLD_TRANSITION_CREATE_FUNC(CCTransitionProgressVertical) TRANSITION_CREATE_FUNC(CCTransitionProgressVertical) protected: virtual CCProgressTimer* progressTimerNodeWithRenderTexture(CCRenderTexture* texture); @@ -101,6 +106,7 @@ protected: class CC_DLL CCTransitionProgressInOut : public CCTransitionProgress { public: + OLD_TRANSITION_CREATE_FUNC(CCTransitionProgressInOut) TRANSITION_CREATE_FUNC(CCTransitionProgressInOut) protected: virtual CCProgressTimer* progressTimerNodeWithRenderTexture(CCRenderTexture* texture); @@ -111,6 +117,7 @@ protected: class CC_DLL CCTransitionProgressOutIn : public CCTransitionProgress { public: + OLD_TRANSITION_CREATE_FUNC(CCTransitionProgressOutIn) TRANSITION_CREATE_FUNC(CCTransitionProgressOutIn) protected: virtual CCProgressTimer* progressTimerNodeWithRenderTexture(CCRenderTexture* texture); diff --git a/js/JSBindings/ScriptingCore.cpp b/js/JSBindings/ScriptingCore.cpp index 33a78b4e72..4a19a79888 100644 --- a/js/JSBindings/ScriptingCore.cpp +++ b/js/JSBindings/ScriptingCore.cpp @@ -246,11 +246,11 @@ void ScriptingCore::runScript(const char *path) // std::string dpath("/Users/rabarca/Desktop/testjs/testjs/"); std::string dpath(""); dpath += path; - const char *realPath = CCFileUtils::fullPathFromRelativePath(dpath.c_str()); + const char *realPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(dpath.c_str()); #else - const char *realPath = CCFileUtils::fullPathFromRelativePath(path); + const char *realPath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(path); #endif - const char* content = CCString::stringWithContentsOfFile(realPath)->getCString(); + const char* content = CCString::createWithContentsOfFile(realPath)->getCString(); if (content && strlen(content) > 0) { JSBool ok; jsval rval; diff --git a/js/JSBindings/cocos2d_generated.cpp.REMOVED.git-id b/js/JSBindings/cocos2d_generated.cpp.REMOVED.git-id index 05cd982ee9..ad4a4ea0fa 100644 --- a/js/JSBindings/cocos2d_generated.cpp.REMOVED.git-id +++ b/js/JSBindings/cocos2d_generated.cpp.REMOVED.git-id @@ -1 +1 @@ -2ef6f502d16098ac1a18aee1ab7a64815c241af6 \ No newline at end of file +83e960279cac86d7cb43efbfa0f4445bf6b4f2b5 \ No newline at end of file diff --git a/js/JSBindings/cocos2d_generated.hpp.REMOVED.git-id b/js/JSBindings/cocos2d_generated.hpp.REMOVED.git-id index 650571e3ce..8874928cea 100644 --- a/js/JSBindings/cocos2d_generated.hpp.REMOVED.git-id +++ b/js/JSBindings/cocos2d_generated.hpp.REMOVED.git-id @@ -1 +1 @@ -27f42f585ea7195531f863d34fff314117000630 \ No newline at end of file +b0931db6aa50254f26db328117aa6b772c3dd86c \ No newline at end of file diff --git a/js/JSBindings/cocos2d_manual_bindings.cpp b/js/JSBindings/cocos2d_manual_bindings.cpp index e8a4ca5877..58fb15906e 100644 --- a/js/JSBindings/cocos2d_manual_bindings.cpp +++ b/js/JSBindings/cocos2d_manual_bindings.cpp @@ -128,7 +128,7 @@ JSBool S_CCFileUtils::jsgetFileData(JSContext *cx, uint32_t argc, jsval *vp) { JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1); char *narg0 = JS_EncodeString(cx, arg0); char *narg1 = JS_EncodeString(cx, arg1); - unsigned char *ret = CCFileUtils::getFileData(narg0, narg1, &len); + unsigned char *ret = CCFileUtils::sharedFileUtils()->getFileData(narg0, narg1, &len); if (ret == NULL) { JS_SET_RVAL(cx, vp, JSVAL_NULL); return JS_TRUE; @@ -146,7 +146,7 @@ JSBool S_CCFileUtils::jsfullPathFromRelativePath(JSContext *cx, uint32_t argc, j JSString *arg0; JS_ConvertArguments(cx, 1, JS_ARGV(cx, vp), "S", &arg0); char *narg0 = JS_EncodeString(cx, arg0); - const char *ret = CCFileUtils::fullPathFromRelativePath(narg0); + const char *ret = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(narg0); if (ret == NULL) { JS_SET_RVAL(cx, vp, JSVAL_NULL); return JS_TRUE; @@ -166,7 +166,7 @@ JSBool S_CCFileUtils::jsfullPathFromRelativeFile(JSContext *cx, uint32_t argc, j JS_ConvertArguments(cx, 2, JS_ARGV(cx, vp), "SS", &arg0, &arg1); char *narg0 = JS_EncodeString(cx, arg0); char *narg1 = JS_EncodeString(cx, arg1); - const char *ret = CCFileUtils::fullPathFromRelativeFile(narg0, narg1); + const char *ret = CCFileUtils::sharedFileUtils()->fullPathFromRelativeFile(narg0, narg1); if (ret == NULL) { JS_SET_RVAL(cx, vp, JSVAL_NULL); return JS_TRUE; diff --git a/lua/cocos2dx_support/CCLuaEngine.cpp b/lua/cocos2dx_support/CCLuaEngine.cpp index 9a8c7999ab..d3c2a5b6a2 100644 --- a/lua/cocos2dx_support/CCLuaEngine.cpp +++ b/lua/cocos2dx_support/CCLuaEngine.cpp @@ -282,7 +282,7 @@ int CCLuaEngine::executeTouchesEvent(int nHandler, int eventType, CCSet *pTouche return executeFunctionByHandler(nHandler, 2); } -int CCLuaEngine::executeSchedule(int nHandler, ccTime dt) +int CCLuaEngine::executeSchedule(int nHandler, float dt) { return executeFunctionWithFloatData(nHandler, dt); } diff --git a/lua/cocos2dx_support/CCLuaEngine.h b/lua/cocos2dx_support/CCLuaEngine.h index 6862ff778c..6b89bcecb5 100644 --- a/lua/cocos2dx_support/CCLuaEngine.h +++ b/lua/cocos2dx_support/CCLuaEngine.h @@ -112,7 +112,7 @@ public: virtual int executeTouchesEvent(int nHandler, int eventType, cocos2d::CCSet *pTouches); // execute a schedule function - virtual int executeSchedule(int nHandler, cocos2d::ccTime dt); + virtual int executeSchedule(int nHandler, float dt); // Add lua loader, now it is used on android virtual void addLuaLoader(lua_CFunction func); diff --git a/lua/cocos2dx_support/Cocos2dxLuaLoader.cpp b/lua/cocos2dx_support/Cocos2dxLuaLoader.cpp index 154827590a..df1c51906e 100644 --- a/lua/cocos2dx_support/Cocos2dxLuaLoader.cpp +++ b/lua/cocos2dx_support/Cocos2dxLuaLoader.cpp @@ -33,23 +33,15 @@ extern "C" std::string filename(luaL_checkstring(L, 1)); filename.append(".lua"); - unsigned long size; - char *pFileContent = (char*)CCFileUtils::getFileData(filename.c_str(), "r", &size); + CCString* pFileContent = CCString::createWithContentsOfFile(filename.c_str()); if (pFileContent) { - // copy the file contents and add '\0' at the end, or the lua parser can not parse it - char *pCodes = new char[size + 1]; - pCodes[size] = '\0'; - memcpy(pCodes, pFileContent, size); - delete[] pFileContent; - - if (luaL_loadstring(L, pCodes) != 0) + if (luaL_loadstring(L, pFileContent->getCString()) != 0) { luaL_error(L, "error loading module %s from file %s :\n\t%s", lua_tostring(L, 1), filename.c_str(), lua_tostring(L, -1)); } - delete []pCodes; } else { diff --git a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index 3cb6d0e67e..c1a9e0f395 100644 --- a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -b44166abef4b62f6277ccfa7730bde51123f4295 \ No newline at end of file +c96a0297e226ff452dacd39b6d832b23622d34b7 \ No newline at end of file diff --git a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.cpp b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.cpp index 2d57ea041f..680d7d11e4 100644 --- a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.cpp +++ b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.cpp @@ -46,13 +46,13 @@ bool AppDelegate::applicationDidFinishLaunching() CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua"); + CCString* pstrFileContent = CCString::createWithContentsOfFile("hello.lua"); if (pstrFileContent) { pEngine->executeString(pstrFileContent->getCString()); } #else - std::string path = CCFileUtils::fullPathFromRelativePath("hello.lua"); + std::string path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("hello.lua"); pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str()); pEngine->executeScriptFile(path.c_str()); #endif diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.cpp b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.cpp index ab54b1cb3c..bb47c90d56 100644 --- a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.cpp +++ b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.cpp @@ -44,7 +44,7 @@ CCAffineTransform PhysicsSprite::nodeToParentTransform(void) float x = pos.x * PTM_RATIO; float y = pos.y * PTM_RATIO; - if ( !getIsRelativeAnchorPoint() ) { + if ( getIgnoreAnchorPointForPosition() ) { x += m_tAnchorPointInPoints.x; y += m_tAnchorPointInPoints.y; } diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/HelloWorldScene.cpp b/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/HelloWorldScene.cpp index 4ed0410564..e9ae38b0b1 100644 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/HelloWorldScene.cpp +++ b/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/HelloWorldScene.cpp @@ -53,7 +53,7 @@ CCAffineTransform ChipmunkPhysicsSprite::nodeToParentTransform(void) CCFloat x = m_pBody->p.x; CCFloat y = m_pBody->p.y; - if ( !getIsRelativeAnchorPoint() ) { + if ( getIgnoreAnchorPointForPosition() ) { x += m_tAnchorPointInPoints.x; y += m_tAnchorPointInPoints.y; } diff --git a/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp index 984bba4348..6ae1789ddc 100644 --- a/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp +++ b/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp @@ -41,13 +41,13 @@ bool AppDelegate::applicationDidFinishLaunching() CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua"); + CCString* pstrFileContent = CCString::createWithContentsOfFile("hello.lua"); if (pstrFileContent) { pEngine->executeString(pstrFileContent->getCString()); } #else - string path = CCFileUtils::fullPathFromRelativePath("hello.lua"); + string path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("hello.lua"); pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str()); pEngine->executeScriptFile(path.c_str()); #endif diff --git a/tools/lua_project_generator/template/Classes/AppDelegate.cpp b/tools/lua_project_generator/template/Classes/AppDelegate.cpp index e341801473..65124a268f 100644 --- a/tools/lua_project_generator/template/Classes/AppDelegate.cpp +++ b/tools/lua_project_generator/template/Classes/AppDelegate.cpp @@ -38,13 +38,13 @@ bool AppDelegate::applicationDidFinishLaunching() CCScriptEngineManager::sharedManager()->setScriptEngine(pEngine); #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) - CCString* pstrFileContent = CCString::stringWithContentsOfFile("hello.lua"); + CCString* pstrFileContent = CCString::createWithContentsOfFile("hello.lua"); if (pstrFileContent) { pEngine->executeString(pstrFileContent->getCString()); } #else - std::string path = CCFileUtils::fullPathFromRelativePath("hello.lua"); + std::string path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("hello.lua"); pEngine->addSearchPath(path.substr(0, path.find_last_of("/")).c_str()); pEngine->executeScriptFile(path.c_str()); #endif diff --git a/tools/tolua++/CCAction.pkg b/tools/tolua++/CCAction.pkg index dcffb9e2e5..e085d4917e 100644 --- a/tools/tolua++/CCAction.pkg +++ b/tools/tolua++/CCAction.pkg @@ -18,15 +18,15 @@ class CCAction : public CCObject class CCActionInterval : public CCAction { - // ccTime getElapsed(void); + // float getElapsed(void); // void setAmplitudeRate(CGFloat amp); // CGFloat getAmplitudeRate(void); }; class CCFiniteTimeAction : public CCActionInterval { - // ccTime getDuration(void); - // void setDuration(ccTime duration); + // float getDuration(void); + // void setDuration(float duration); // CCFiniteTimeAction* reverse(void); }; @@ -52,7 +52,7 @@ class CCFollow : public CCAction class CCSequence : public CCActionInterval { static CCFiniteTimeAction* actionOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo); - static CCFiniteTimeAction* actionsWithArray(CCArray *actions); + static CCFiniteTimeAction* actionWithArray(CCArray *actions); }; class CCRepeat : public CCActionInterval @@ -67,48 +67,48 @@ class CCRepeatForever : public CCActionInterval class CCSpawn : public CCActionInterval { - static CCFiniteTimeAction* actionsWithArray(CCArray *actions); + static CCFiniteTimeAction* actionWithArray(CCArray *actions); static CCSpawn* actionOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2); }; class CCRotateTo : public CCActionInterval { - static CCRotateTo* actionWithDuration(ccTime duration, float fDeltaAngle); + static CCRotateTo* actionWithDuration(float duration, float fDeltaAngle); }; class CCRotateBy : public CCActionInterval { - static CCRotateBy* actionWithDuration(ccTime duration, float fDeltaAngle); + static CCRotateBy* actionWithDuration(float duration, float fDeltaAngle); }; class CCMoveTo : public CCActionInterval { - static CCMoveTo* actionWithDuration(ccTime duration, CCPoint position); + static CCMoveTo* actionWithDuration(float duration, CCPoint position); }; class CCMoveBy : public CCActionInterval { - static CCMoveBy* actionWithDuration(ccTime duration, CCPoint position); + static CCMoveBy* actionWithDuration(float duration, CCPoint position); }; class CCSkewTo : public CCActionInterval { - static CCSkewTo* actionWithDuration(ccTime t, float sx, float sy); + static CCSkewTo* actionWithDuration(float t, float sx, float sy); }; class CCSkewBy : public CCActionInterval { - static CCSkewBy* actionWithDuration(ccTime t, float deltaSkewX, float deltaSkewY); + static CCSkewBy* actionWithDuration(float t, float deltaSkewX, float deltaSkewY); }; class CCJumpBy : public CCActionInterval { - static CCJumpBy* actionWithDuration(ccTime duration, CCPoint position, ccTime height, int jumps); + static CCJumpBy* actionWithDuration(float duration, CCPoint position, float height, int jumps); }; class CCJumpTo : public CCActionInterval { - static CCJumpTo* actionWithDuration(ccTime duration, CCPoint position, ccTime height, int jumps); + static CCJumpTo* actionWithDuration(float duration, CCPoint position, float height, int jumps); }; typedef struct _ccBezierConfig { @@ -119,59 +119,59 @@ typedef struct _ccBezierConfig { class CCBezierBy : public CCActionInterval { - static CCBezierBy* actionWithDuration(ccTime t, ccBezierConfig c); + static CCBezierBy* actionWithDuration(float t, ccBezierConfig c); }; class CCBezierTo : public CCActionInterval { - static CCBezierTo* actionWithDuration(ccTime t, ccBezierConfig c); + static CCBezierTo* actionWithDuration(float t, ccBezierConfig c); }; class CCScaleTo : public CCActionInterval { - static CCScaleTo* actionWithDuration(ccTime duration, float s); - static CCScaleTo* actionWithDuration(ccTime duration, float sx, float sy); + static CCScaleTo* actionWithDuration(float duration, float s); + static CCScaleTo* actionWithDuration(float duration, float sx, float sy); }; class CCScaleBy : public CCActionInterval { - static CCScaleBy* actionWithDuration(ccTime duration, float s); - static CCScaleBy* actionWithDuration(ccTime duration, float sx, float sy); + static CCScaleBy* actionWithDuration(float duration, float s); + static CCScaleBy* actionWithDuration(float duration, float sx, float sy); }; class CCBlink : public CCActionInterval { - static CCBlink* actionWithDuration(ccTime duration, unsigned int uBlinks); + static CCBlink* actionWithDuration(float duration, unsigned int uBlinks); }; class CCFadeIn : public CCActionInterval { - static CCFadeIn* actionWithDuration(ccTime d); + static CCFadeIn* actionWithDuration(float d); }; class CCFadeOut : public CCActionInterval { - static CCFadeOut* actionWithDuration(ccTime d); + static CCFadeOut* actionWithDuration(float d); }; class CCFadeTo : public CCActionInterval { - static CCFadeTo* actionWithDuration(ccTime duration, GLubyte opacity); + static CCFadeTo* actionWithDuration(float duration, GLubyte opacity); }; class CCTintTo : public CCActionInterval { - static CCTintTo* actionWithDuration(ccTime duration, GLubyte red, GLubyte green, GLubyte blue); + static CCTintTo* actionWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue); }; class CCTintBy : public CCActionInterval { - static CCTintBy* actionWithDuration(ccTime duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); + static CCTintBy* actionWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); }; class CCDelayTime : public CCActionInterval { - static CCDelayTime* actionWithDuration(ccTime d); + static CCDelayTime* actionWithDuration(float d); }; class CCReverseTime : public CCActionInterval @@ -189,12 +189,12 @@ class CCAnimate : public CCActionInterval class CCProgressTo : public CCAction { - static CCAction* actionWithDuration(ccTime duration, float fPercent); + static CCAction* actionWithDuration(float duration, float fPercent); }; class CCProgressFromTo : public CCAction { - static CCAction* actionWithDuration(ccTime duration, float fFromPercentage, float fToPercentage); + static CCAction* actionWithDuration(float duration, float fFromPercentage, float fToPercentage); }; diff --git a/tools/tolua++/CCActionGrid.pkg b/tools/tolua++/CCActionGrid.pkg index e2371e4b72..b06f2f6a07 100644 --- a/tools/tolua++/CCActionGrid.pkg +++ b/tools/tolua++/CCActionGrid.pkg @@ -3,7 +3,7 @@ class CCGridAction : public CCActionInterval { CCGridBase* getGrid(void); - static CCGridAction* actionWithSize(ccGridSize gridSize, ccTime duration); + static CCGridAction* actionWithSize(ccGridSize gridSize, float duration); }; class CCAccelDeccelAmplitude : public CCActionInterval @@ -11,7 +11,7 @@ class CCAccelDeccelAmplitude : public CCActionInterval float getRate(void); void setRate(float fRate); - static CCAccelDeccelAmplitude* actionWithAction(CCAction *pAction, ccTime duration); + static CCAccelDeccelAmplitude* actionWithAction(CCAction *pAction, float duration); }; class CCAccelAmplitude : public CCActionInterval @@ -19,7 +19,7 @@ class CCAccelAmplitude : public CCActionInterval float getRate(void); void setRate(float fRate); - static CCAccelAmplitude* actionWithAction(CCAction *pAction, ccTime duration); + static CCAccelAmplitude* actionWithAction(CCAction *pAction, float duration); }; class CCDeccelAmplitude : public CCActionInterval @@ -27,7 +27,7 @@ class CCDeccelAmplitude : public CCActionInterval float getRate(void); void setRate(float fRate); - static CCDeccelAmplitude* actionWithAction(CCAction *pAction, ccTime duration); + static CCDeccelAmplitude* actionWithAction(CCAction *pAction, float duration); }; class CCStopGrid : public CCActionInstant diff --git a/tools/tolua++/CCActionGrid3D.pkg b/tools/tolua++/CCActionGrid3D.pkg index 5913b3b5d6..a6259e24e2 100644 --- a/tools/tolua++/CCActionGrid3D.pkg +++ b/tools/tolua++/CCActionGrid3D.pkg @@ -6,17 +6,17 @@ class CCWaves3D : public CCGrid3DAction float getAmplitudeRate(void); void setAmplitudeRate(float fAmplitudeRate); - static CCWaves3D* actionWithWaves(int wav, float amp, ccGridSize gridSize, ccTime duration); + static CCWaves3D* actionWithWaves(int wav, float amp, ccGridSize gridSize, float duration); }; class CCFlipX3D : public CCGrid3DAction { - static CCFlipX3D* actionWithDuration(ccTime duration); + static CCFlipX3D* actionWithDuration(float duration); }; class CCFlipY3D : public CCFlipX3D { - static CCFlipY3D* actionWithDuration(ccTime duration); + static CCFlipY3D* actionWithDuration(float duration); }; class CCLens3D : public CCGrid3DAction @@ -26,7 +26,7 @@ class CCLens3D : public CCGrid3DAction CCPoint getPosition(void); void setPosition(CCPoint position); - static CCLens3D* actionWithPosition(CCPoint pos, float r, ccGridSize gridSize, ccTime duration); + static CCLens3D* actionWithPosition(CCPoint pos, float r, ccGridSize gridSize, float duration); }; class CCRipple3D : public CCGrid3DAction @@ -38,12 +38,12 @@ class CCRipple3D : public CCGrid3DAction float getAmplitudeRate(void); void setAmplitudeRate(float fAmplitudeRate); - static CCRipple3D* actionWithPosition(CCPoint pos, float r, int wav, float amp, ccGridSize gridSize, ccTime duration); + static CCRipple3D* actionWithPosition(CCPoint pos, float r, int wav, float amp, ccGridSize gridSize, float duration); }; class CCShaky3D : public CCGrid3DAction { - static CCShaky3D* actionWithRange(int range, bool shakeZ, ccGridSize gridSize, ccTime duration); + static CCShaky3D* actionWithRange(int range, bool shakeZ, ccGridSize gridSize, float duration); }; class CCLiquid : public CCGrid3DAction @@ -53,7 +53,7 @@ class CCLiquid : public CCGrid3DAction float getAmplitudeRate(void); void setAmplitudeRate(float fAmplitudeRate); - static CCLiquid* actionWithWaves(int wav, float amp, ccGridSize gridSize, ccTime duration); + static CCLiquid* actionWithWaves(int wav, float amp, ccGridSize gridSize, float duration); }; class CCWaves : public CCGrid3DAction @@ -63,7 +63,7 @@ class CCWaves : public CCGrid3DAction float getAmplitudeRate(void); void setAmplitudeRate(float fAmplitudeRate); - static CCWaves* actionWithWaves(int wav, float amp, bool h, bool v, ccGridSize gridSize,ccTime duration); + static CCWaves* actionWithWaves(int wav, float amp, bool h, bool v, ccGridSize gridSize,float duration); }; class CCTwirl : public CCGrid3DAction @@ -75,5 +75,5 @@ class CCTwirl : public CCGrid3DAction float getAmplitudeRate(void); void setAmplitudeRate(float fAmplitudeRate); - static CCTwirl* actionWithPosition(CCPoint pos, int t, float amp, ccGridSize gridSize,ccTime duration); + static CCTwirl* actionWithPosition(CCPoint pos, int t, float amp, ccGridSize gridSize,float duration); }; diff --git a/tools/tolua++/CCActionPageTurn3D.pkg b/tools/tolua++/CCActionPageTurn3D.pkg index 2a2b53d8eb..c24dd064e4 100644 --- a/tools/tolua++/CCActionPageTurn3D.pkg +++ b/tools/tolua++/CCActionPageTurn3D.pkg @@ -1,5 +1,5 @@ class CCPageTurn3D : public CCGrid3DAction { - static CCPageTurn3D* actionWithSize(ccGridSize gridSize, ccTime time); + static CCPageTurn3D* actionWithSize(ccGridSize gridSize, float time); }; diff --git a/tools/tolua++/CCActionProgressTimer.pkg b/tools/tolua++/CCActionProgressTimer.pkg index f887b2d901..ff33aebeef 100644 --- a/tools/tolua++/CCActionProgressTimer.pkg +++ b/tools/tolua++/CCActionProgressTimer.pkg @@ -1,10 +1,10 @@ class CCProgressTo : public CCActionInterval { - static CCProgressTo* actionWithDuration(ccTime duration, float fPercent); + static CCProgressTo* actionWithDuration(float duration, float fPercent); }; class CCProgressFromTo : public CCActionInterval { - static CCProgressFromTo* actionWithDuration(ccTime duration, float fFromPercentage, float fToPercentage); + static CCProgressFromTo* actionWithDuration(float duration, float fFromPercentage, float fToPercentage); }; diff --git a/tools/tolua++/CCActionTiledGrid.pkg b/tools/tolua++/CCActionTiledGrid.pkg index 1e73f620c3..08f08d811f 100644 --- a/tools/tolua++/CCActionTiledGrid.pkg +++ b/tools/tolua++/CCActionTiledGrid.pkg @@ -1,12 +1,12 @@ class CCShakyTiles3D : public CCTiledGrid3DAction { - static CCShakyTiles3D* actionWithRange(int nRange, bool bShakeZ, ccGridSize gridSize, ccTime duration); + static CCShakyTiles3D* actionWithRange(int nRange, bool bShakeZ, ccGridSize gridSize, float duration); }; class CCShatteredTiles3D : public CCTiledGrid3DAction { - static CCShatteredTiles3D* actionWithRange(int nRange, bool bShatterZ, ccGridSize gridSize, ccTime duration); + static CCShatteredTiles3D* actionWithRange(int nRange, bool bShatterZ, ccGridSize gridSize, float duration); }; class CCShuffleTiles : public CCTiledGrid3DAction @@ -15,7 +15,7 @@ class CCShuffleTiles : public CCTiledGrid3DAction ccGridSize getDelta(ccGridSize pos); void placeTile(ccGridSize pos, Tile *t); - static CCShuffleTiles* actionWithSeed(int s, ccGridSize gridSize, ccTime duration); + static CCShuffleTiles* actionWithSeed(int s, ccGridSize gridSize, float duration); }; class CCFadeOutTRTiles : public CCTiledGrid3DAction @@ -24,22 +24,22 @@ class CCFadeOutTRTiles : public CCTiledGrid3DAction void turnOffTile(ccGridSize pos); void transformTile(ccGridSize pos, float distance); - static CCFadeOutTRTiles* actionWithSize(ccGridSize gridSize, ccTime time); + static CCFadeOutTRTiles* actionWithSize(ccGridSize gridSize, float time); }; class CCFadeOutBLTiles : public CCFadeOutTRTiles { - static CCFadeOutBLTiles* actionWithSize(ccGridSize gridSize, ccTime time); + static CCFadeOutBLTiles* actionWithSize(ccGridSize gridSize, float time); }; class CCFadeOutUpTiles : public CCFadeOutTRTiles { - static CCFadeOutUpTiles* actionWithSize(ccGridSize gridSize, ccTime time); + static CCFadeOutUpTiles* actionWithSize(ccGridSize gridSize, float time); }; class CCFadeOutDownTiles : public CCFadeOutUpTiles { - static CCFadeOutDownTiles* actionWithSize(ccGridSize gridSize, ccTime time); + static CCFadeOutDownTiles* actionWithSize(ccGridSize gridSize, float time); }; class CCTurnOffTiles : public CCTiledGrid3DAction @@ -48,8 +48,8 @@ class CCTurnOffTiles : public CCTiledGrid3DAction void turnOnTile(ccGridSize pos); void turnOffTile(ccGridSize pos); - static CCTurnOffTiles* actionWithSize(ccGridSize size, ccTime d); - static CCTurnOffTiles* actionWithSeed(int s, ccGridSize gridSize, ccTime duration); + static CCTurnOffTiles* actionWithSize(ccGridSize size, float d); + static CCTurnOffTiles* actionWithSeed(int s, ccGridSize gridSize, float duration); }; class CCWavesTiles3D : public CCTiledGrid3DAction @@ -59,7 +59,7 @@ class CCWavesTiles3D : public CCTiledGrid3DAction float getAmplitudeRate(void); void setAmplitudeRate(float fAmplitudeRate); - static CCWavesTiles3D* actionWithWaves(int wav, float amp, ccGridSize gridSize, ccTime duration); + static CCWavesTiles3D* actionWithWaves(int wav, float amp, ccGridSize gridSize, float duration); }; class CCJumpTiles3D : public CCTiledGrid3DAction @@ -69,15 +69,15 @@ class CCJumpTiles3D : public CCTiledGrid3DAction float getAmplitudeRate(void); void setAmplitudeRate(float fAmplitudeRate); - static CCJumpTiles3D* actionWithJumps(int j, float amp, ccGridSize gridSize, ccTime duration); + static CCJumpTiles3D* actionWithJumps(int j, float amp, ccGridSize gridSize, float duration); }; class CCSplitRows : public CCTiledGrid3DAction { - static CCSplitRows* actionWithRows(int nRows, ccTime duration); + static CCSplitRows* actionWithRows(int nRows, float duration); }; class CCSplitCols : public CCTiledGrid3DAction { - static CCSplitCols* actionWithCols(int nCols, ccTime duration); + static CCSplitCols* actionWithCols(int nCols, float duration); }; diff --git a/tools/tolua++/CCDirector.pkg b/tools/tolua++/CCDirector.pkg index 9313e80af1..2832270833 100644 --- a/tools/tolua++/CCDirector.pkg +++ b/tools/tolua++/CCDirector.pkg @@ -9,7 +9,7 @@ class CCDirector : public CCObject void setDisplayStats(bool bDisplayFPS); bool isPaused(void); - unsigned int getFrames(void); + unsigned int getTotalFrames(void); CCSize getWinSize(void); CCSize getWinSizeInPixels(void); diff --git a/tools/tolua++/CCFileUtils.pkg b/tools/tolua++/CCFileUtils.pkg index a4b5e488b7..ee212bd7e0 100644 --- a/tools/tolua++/CCFileUtils.pkg +++ b/tools/tolua++/CCFileUtils.pkg @@ -1,5 +1,6 @@ class CCFileUtils { - static std::string getWriteablePath(); + static CCFileUtils* sharedFileUtils(); + std::string getWriteablePath(); }; diff --git a/tools/tolua++/CCNode.pkg b/tools/tolua++/CCNode.pkg index 7701c84e67..e00b1e4a94 100644 --- a/tools/tolua++/CCNode.pkg +++ b/tools/tolua++/CCNode.pkg @@ -65,8 +65,8 @@ class CCNode : public CCObject bool getIsRunning(); CCNode* getParent(); void setParent(CCNode * var); - bool getIsRelativeAnchorPoint(); - void setIsRelativeAnchorPoint(bool newValue); + bool getIgnoreAnchorPointForPosition(); + void setIgnoreAnchorPointForPosition(bool newValue); void* getUserData(); void setUserData(void *var); void addChild(CCNode * child); diff --git a/tools/tolua++/CCScheduler.pkg b/tools/tolua++/CCScheduler.pkg index 0caed4128c..33b526a663 100644 --- a/tools/tolua++/CCScheduler.pkg +++ b/tools/tolua++/CCScheduler.pkg @@ -1,18 +1,18 @@ class CCTimer : public CCObject { - ccTime getInterval(void); - void setInterval(ccTime fInterval); - void update(ccTime dt); + float getInterval(void); + void setInterval(float fInterval); + void update(float dt); }; class CCScheduler : public CCObject { - ccTime getTimeScale(void); - void setTimeScale(ccTime fTimeScale); + float getTimeScale(void); + void setTimeScale(float fTimeScale); - unsigned int scheduleScriptFunc(LUA_FUNCTION funcID, ccTime fInterval, bool bPaused); + unsigned int scheduleScriptFunc(LUA_FUNCTION funcID, float fInterval, bool bPaused); void unscheduleScriptEntry(unsigned int uScheduleScriptEntryID); void scheduleUpdateForTarget(CCObject *pTarget, int nPriority, bool bPaused); diff --git a/tools/tolua++/CCSprite.pkg b/tools/tolua++/CCSprite.pkg index 17566b146f..3ec9c4a6d7 100644 --- a/tools/tolua++/CCSprite.pkg +++ b/tools/tolua++/CCSprite.pkg @@ -40,7 +40,7 @@ class CCSprite : public CCNode //CCPoint getOffsetPositionInPixels(void); void setDirtyRecursively(bool bValue); - void setIsRelativeAnchorPoint(bool bRelative); + void setIgnoreAnchorPointForPosition(bool newValue); void setFlipX(bool bFlipX); void setFlipY(bool bFlipY); bool isFlipX(void); @@ -72,7 +72,7 @@ class CCSprite : public CCNode static CCSprite* spriteWithTexture(CCTexture2D *pTexture); static CCSprite* spriteWithTexture(CCTexture2D *pTexture, CCRect rect); - static CCSprite* spriteWithTexture(CCTexture2D *pTexture, CCRect rect, CCPoint offset); +// static CCSprite* spriteWithTexture(CCTexture2D *pTexture, CCRect rect, CCPoint offset); static CCSprite* spriteWithSpriteFrame(CCSpriteFrame *pSpriteFrame); static CCSprite* spriteWithSpriteFrameName(const char *pszSpriteFrameName); static CCSprite* spriteWithFile(const char *pszFileName); diff --git a/tools/tolua++/CCTexture2D.pkg b/tools/tolua++/CCTexture2D.pkg index 4d98485165..1550c29c0a 100644 --- a/tools/tolua++/CCTexture2D.pkg +++ b/tools/tolua++/CCTexture2D.pkg @@ -1,6 +1,6 @@ typedef enum { - kCCTexture2DPixelFormat_Automatic = 0, +// kCCTexture2DPixelFormat_Automatic = 0, //! 32-bit texture: RGBA8888 kCCTexture2DPixelFormat_RGBA8888, //! 24-bit texture: RGBA888 @@ -26,7 +26,7 @@ typedef enum { kCCTexture2DPixelFormat_Default = kCCTexture2DPixelFormat_RGBA8888, // backward compatibility stuff - kTexture2DPixelFormat_Automatic = kCCTexture2DPixelFormat_Automatic, + // kTexture2DPixelFormat_Automatic = kCCTexture2DPixelFormat_Automatic, kTexture2DPixelFormat_RGBA8888 = kCCTexture2DPixelFormat_RGBA8888, kTexture2DPixelFormat_RGB888 = kCCTexture2DPixelFormat_RGB888, kTexture2DPixelFormat_RGB565 = kCCTexture2DPixelFormat_RGB565, diff --git a/tools/tolua++/CCTransition.pkg b/tools/tolua++/CCTransition.pkg index 2381cb47f8..b3c82a0434 100644 --- a/tools/tolua++/CCTransition.pkg +++ b/tools/tolua++/CCTransition.pkg @@ -12,152 +12,152 @@ typedef enum { class CCTransitionSceneOriented : public CCScene { - static CCTransitionSceneOriented* transitionWithDuration(ccTime t, CCScene* scene, tOrientation o); + static CCTransitionSceneOriented* transitionWithDuration(float t, CCScene* scene, tOrientation o); }; class CCTransitionRotoZoom : public CCScene { - static CCTransitionRotoZoom* transitionWithDuration(ccTime t, CCScene* scene); + static CCTransitionRotoZoom* transitionWithDuration(float t, CCScene* scene); }; class CCTransitionJumpZoom : public CCScene { - static CCTransitionJumpZoom* transitionWithDuration(ccTime t, CCScene* scene); + static CCTransitionJumpZoom* transitionWithDuration(float t, CCScene* scene); }; class CCTransitionMoveInL : public CCScene { - static CCTransitionMoveInL* transitionWithDuration(ccTime t, CCScene* scene); + static CCTransitionMoveInL* transitionWithDuration(float t, CCScene* scene); }; class CCTransitionMoveInR : public CCScene { - static CCTransitionMoveInR* transitionWithDuration(ccTime t, CCScene* scene); + static CCTransitionMoveInR* transitionWithDuration(float t, CCScene* scene); }; class CCTransitionMoveInT : public CCScene { - static CCTransitionMoveInT* transitionWithDuration(ccTime t, CCScene* scene); + static CCTransitionMoveInT* transitionWithDuration(float t, CCScene* scene); }; class CCTransitionMoveInB : public CCScene { - static CCTransitionMoveInB* transitionWithDuration(ccTime t, CCScene* scene); + static CCTransitionMoveInB* transitionWithDuration(float t, CCScene* scene); }; class CCTransitionSlideInL : public CCScene { - static CCTransitionSlideInL* transitionWithDuration(ccTime t, CCScene* scene); + static CCTransitionSlideInL* transitionWithDuration(float t, CCScene* scene); }; class CCTransitionSlideInR : public CCScene { - static CCTransitionSlideInR* transitionWithDuration(ccTime t, CCScene* scene); + static CCTransitionSlideInR* transitionWithDuration(float t, CCScene* scene); }; class CCTransitionSlideInB : public CCScene { - static CCTransitionSlideInB* transitionWithDuration(ccTime t, CCScene* scene); + static CCTransitionSlideInB* transitionWithDuration(float t, CCScene* scene); }; class CCTransitionSlideInT : public CCScene { - static CCTransitionSlideInT* transitionWithDuration(ccTime t, CCScene* scene); + static CCTransitionSlideInT* transitionWithDuration(float t, CCScene* scene); }; class CCTransitionShrinkGrow : public CCScene { - static CCTransitionShrinkGrow* transitionWithDuration(ccTime t, CCScene* scene); + static CCTransitionShrinkGrow* transitionWithDuration(float t, CCScene* scene); }; class CCTransitionFlipX : public CCScene { - static CCTransitionFlipX* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionFlipX* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; class CCTransitionFlipY : public CCScene { - static CCTransitionFlipY* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationUpOver); + static CCTransitionFlipY* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationUpOver); }; class CCTransitionFlipAngular : public CCScene { - static CCTransitionFlipAngular* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionFlipAngular* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; class CCTransitionZoomFlipX : public CCScene { - static CCTransitionZoomFlipX* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionZoomFlipX* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; class CCTransitionZoomFlipY : public CCScene { - static CCTransitionZoomFlipY* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationUpOver); + static CCTransitionZoomFlipY* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationUpOver); }; class CCTransitionZoomFlipAngular : public CCScene { - static CCTransitionZoomFlipAngular* transitionWithDuration(ccTime t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionZoomFlipAngular* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; class CCTransitionFade : public CCScene { - static CCTransitionFade* transitionWithDuration(ccTime duration,CCScene* scene, ccColor3B color = ccBLACK); + static CCTransitionFade* transitionWithDuration(float duration,CCScene* scene, ccColor3B color = ccBLACK); }; class CCTransitionCrossFade : public CCScene { - static CCTransitionCrossFade* transitionWithDuration(ccTime t, CCScene* scene); + static CCTransitionCrossFade* transitionWithDuration(float t, CCScene* scene); }; class CCTransitionTurnOffTiles : public CCScene { - static CCTransitionTurnOffTiles* transitionWithDuration(ccTime t, CCScene* scene); + static CCTransitionTurnOffTiles* transitionWithDuration(float t, CCScene* scene); }; class CCTransitionSplitCols : public CCScene { - static CCTransitionSplitCols* transitionWithDuration(ccTime t, CCScene* scene); + static CCTransitionSplitCols* transitionWithDuration(float t, CCScene* scene); }; class CCTransitionSplitRows : public CCScene { - static CCTransitionSplitRows* transitionWithDuration(ccTime t, CCScene* scene); + static CCTransitionSplitRows* transitionWithDuration(float t, CCScene* scene); }; class CCTransitionFadeTR : public CCScene { - static CCTransitionFadeTR* transitionWithDuration(ccTime t, CCScene* scene); + static CCTransitionFadeTR* transitionWithDuration(float t, CCScene* scene); }; class CCTransitionFadeBL : public CCScene { - static CCTransitionFadeBL* transitionWithDuration(ccTime t, CCScene* scene); + static CCTransitionFadeBL* transitionWithDuration(float t, CCScene* scene); }; class CCTransitionFadeUp : public CCScene { - static CCTransitionFadeUp* transitionWithDuration(ccTime t, CCScene* scene); + static CCTransitionFadeUp* transitionWithDuration(float t, CCScene* scene); }; class CCTransitionFadeDown : public CCScene { - static CCTransitionFadeDown* transitionWithDuration(ccTime t, CCScene* scene); + static CCTransitionFadeDown* transitionWithDuration(float t, CCScene* scene); }; /* class CCTransitionRadialCCW : public CCScene { - static CCTransitionRadialCCW* transitionWithDuration(ccTime t, CCScene* scene); + static CCTransitionRadialCCW* transitionWithDuration(float t, CCScene* scene); }; class CCTransitionRadialCW : public CCScene { - static CCTransitionRadialCW* transitionWithDuration(ccTime t, CCScene* scene); + static CCTransitionRadialCW* transitionWithDuration(float t, CCScene* scene); }; */ class CCTransitionPageTurn : public CCScene { CCActionInterval* actionWithSize(ccGridSize vector); - static CCTransitionPageTurn* transitionWithDuration(ccTime t,CCScene* scene,bool backwards); + static CCTransitionPageTurn* transitionWithDuration(float t,CCScene* scene,bool backwards); }; diff --git a/tools/tolua++/ccTypes.pkg b/tools/tolua++/ccTypes.pkg index 215ec82095..d86f19fd6a 100644 --- a/tools/tolua++/ccTypes.pkg +++ b/tools/tolua++/ccTypes.pkg @@ -9,7 +9,6 @@ typedef unsigned short GLushort; typedef unsigned int GLuint; typedef float GLfloat; -typedef float ccTime; typedef struct _ccColor3B { GLubyte r; @@ -234,11 +233,21 @@ typedef struct _ccBlendFunc //! delta time type //! if you want more resolution redefine it as a double -//typedef double ccTime; +//typedef double float; typedef enum { - CCTextAlignmentLeft, - CCTextAlignmentCenter, - CCTextAlignmentRight, + kCCVerticalTextAlignmentTop, + kCCVerticalTextAlignmentCenter, + kCCVerticalTextAlignmentBottom, +} CCVerticalTextAlignment; + +// XXX: If any of these enums are edited and/or reordered, udpate CCTexture2D.m +//! Horizontal text alignment type +typedef enum +{ + kCCTextAlignmentLeft, + kCCTextAlignmentCenter, + kCCTextAlignmentRight, } CCTextAlignment; + From 172b90cbfe0951dfb38af073f29ddc76fbfed841 Mon Sep 17 00:00:00 2001 From: folecr Date: Wed, 23 May 2012 14:02:56 -0700 Subject: [PATCH 183/257] Android project generation script copies library sources * mkdir parent folder with project name * create android project in proj.android subfolder * copy library sources to generated project * remove unnecessary function that moves files from top directory to proj.android --- create-android-project.bat | 2 ++ create-android-project.sh | 5 ++++- template/android/copy_files.sh | 28 +++++----------------------- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/create-android-project.bat b/create-android-project.bat index 0eba67338e..78adab206d 100644 --- a/create-android-project.bat +++ b/create-android-project.bat @@ -33,6 +33,8 @@ set /P _TARGETID=Please input target id: set _PROJECTDIR=%CD%\%_PROJECTNAME% echo Create android project +mkdir %_PROJECTDIR% +echo Create Android project inside proj.android call "%_ANDROIDTOOLS%\android.bat" create project -n %_PROJECTNAME% -t %_TARGETID% -k %_PACKAGEPATH% -a %_PROJECTNAME% -p %_PROJECTDIR% :: Resolve ___.sh to /cygdrive based *nix path and store in %_CYGSCRIPT% diff --git a/create-android-project.sh b/create-android-project.sh index 4c52767cad..79d63ff2c8 100755 --- a/create-android-project.sh +++ b/create-android-project.sh @@ -113,7 +113,10 @@ create_android_project(){ exit fi - $ANDROID_SDK_ROOT_LOCAL/tools/android create project -n $PROJECT_NAME -t $TARGET_ID -k $PACKAGE_PATH -a $PROJECT_NAME -p $PROJECT_DIR + # Make project directory + mkdir $PROJECT_DIR + # Create Android project inside proj.android + $ANDROID_SDK_ROOT_LOCAL/tools/android create project -n $PROJECT_NAME -t $TARGET_ID -k $PACKAGE_PATH -a $PROJECT_NAME -p $PROJECT_DIR/proj.android } check_path diff --git a/template/android/copy_files.sh b/template/android/copy_files.sh index b127ecc876..eadbe68fbb 100644 --- a/template/android/copy_files.sh +++ b/template/android/copy_files.sh @@ -17,24 +17,6 @@ convert_package_path_to_dir(){ PACKAGE_PATH_DIR=`echo $1 | sed -e "s/\./\//g"` } -# make director andorid and copy all files and directories into it -move_files_into_android(){ - mkdir $APP_DIR/proj.android - - for file in $APP_DIR/* - do - if [ -d $file ]; then - if [ $file != $APP_DIR/proj.android ]; then - mv -f $file $APP_DIR/proj.android - fi - fi - - if [ -f $file ]; then - mv $file $APP_DIR/proj.android - fi - done -} - copy_cpp_h_from_helloworld(){ mkdir $APP_DIR/Classes for file in `ls $HELLOWORLD_ROOT/Classes/* | grep -E '.*\.(cpp|h|mk)' ` @@ -64,6 +46,10 @@ copy_src_and_jni(){ sh $COCOS2DX_ROOT/template/android/gamemk.sh $APP_DIR/proj.android/jni/Android.mk $NEED_BOX2D $NEED_CHIPMUNK $NEED_LUA } +copy_library_src(){ + cp -rf $COCOSJAVALIB_ROOT/src/* $APP_DIR/proj.android/src/ +} + # copy build_native.sh and replace something copy_build_native(){ # here should use # instead of /, why?? @@ -88,10 +74,7 @@ modify_applicationdemo(){ } modify_layout(){ - cp $HELLOWORLD_ROOT/proj.android/res/layout/helloworld_demo.xml $APP_DIR/proj.android/res/layout - sed "s/helloworld_gl_surfaceview/game_gl_surfaceview/" $APP_DIR/proj.android/res/layout/helloworld_demo.xml > $APP_DIR/proj.android/res/layout/game_demo.xml rm -f $APP_DIR/proj.android/res/layout/main.xml - rm -f $APP_DIR/proj.android/res/layout/helloworld_demo.xml } # android.bat of android 4.0 don't create res/drawable-hdpi res/drawable-ldpi and res/drawable-mdpi. @@ -104,11 +87,10 @@ copy_icon(){ fi } - -move_files_into_android copy_cpp_h_from_helloworld copy_resouces copy_src_and_jni +copy_library_src copy_build_native modify_androidmanifest modify_applicationdemo From 4e5a64fd9eb9f1d8883a59689446fd364a44a22a Mon Sep 17 00:00:00 2001 From: folecr Date: Fri, 25 May 2012 18:11:16 -0700 Subject: [PATCH 184/257] Minimal layout directives in XML --- .../java/res/layout/cocos2dx_default_screen_layout.xml | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/cocos2dx/platform/android/java/res/layout/cocos2dx_default_screen_layout.xml b/cocos2dx/platform/android/java/res/layout/cocos2dx_default_screen_layout.xml index 18a9ec1f6b..cfc9bc4975 100644 --- a/cocos2dx/platform/android/java/res/layout/cocos2dx_default_screen_layout.xml +++ b/cocos2dx/platform/android/java/res/layout/cocos2dx_default_screen_layout.xml @@ -1,18 +1,16 @@ + android:layout_height="fill_parent"> + android:layout_height="wrap_content"/> - \ No newline at end of file + From 6fc2dc5ed9341f645419f58ad51097369ebd822f Mon Sep 17 00:00:00 2001 From: folecr Date: Thu, 24 May 2012 17:12:48 -0700 Subject: [PATCH 185/257] Use Java code instead of XML to define layout * Android layout for cocos apps are very simple (full screen) * Avoids creation of R.java for loading the layout * Can package entire library in jar * Remove unused layout resource --- .../src/org/cocos2dx/hellolua/HelloLua.java | 30 ++++++++++++++- .../cocos2dx/application/ApplicationDemo.java | 32 ++++++++++++++-- .../layout/cocos2dx_default_screen_layout.xml | 16 -------- template/android/copy_files.sh | 1 + .../src/org/cocos2dx/tests/TestsDemo.java | 37 ++++++++++++++++--- 5 files changed, 90 insertions(+), 26 deletions(-) delete mode 100644 cocos2dx/platform/android/java/res/layout/cocos2dx_default_screen_layout.xml diff --git a/HelloLua/proj.android/src/org/cocos2dx/hellolua/HelloLua.java b/HelloLua/proj.android/src/org/cocos2dx/hellolua/HelloLua.java index b8cb76b3de..7bc6482867 100644 --- a/HelloLua/proj.android/src/org/cocos2dx/hellolua/HelloLua.java +++ b/HelloLua/proj.android/src/org/cocos2dx/hellolua/HelloLua.java @@ -23,6 +23,7 @@ THE SOFTWARE. ****************************************************************************/ package org.cocos2dx.hellolua; import org.cocos2dx.lib.Cocos2dxActivity; +import org.cocos2dx.lib.Cocos2dxEditText; import org.cocos2dx.lib.Cocos2dxGLSurfaceView; import org.cocos2dx.lib.Cocos2dxRenderer; @@ -33,6 +34,8 @@ import android.opengl.GLSurfaceView; import android.os.Bundle; import android.util.Log; import android.view.KeyEvent; +import android.widget.FrameLayout; +import android.view.ViewGroup; public class HelloLua extends Cocos2dxActivity{ protected void onCreate(Bundle savedInstanceState){ @@ -43,10 +46,35 @@ public class HelloLua extends Cocos2dxActivity{ String packageName = getApplication().getPackageName(); super.setPackageName(packageName); + // FrameLayout + ViewGroup.LayoutParams framelayout_params = + new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.FILL_PARENT); + FrameLayout framelayout = new FrameLayout(this); + framelayout.setLayoutParams(framelayout_params); + + // Cocos2dxEditText layout + ViewGroup.LayoutParams edittext_layout_params = + new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT); + Cocos2dxEditText edittext = new Cocos2dxEditText(this); + edittext.setLayoutParams(edittext_layout_params); + + // ...add to FrameLayout + framelayout.addView(edittext); + + // LuaGLSurfaceView mGLView = new LuaGLSurfaceView(this); - setContentView(mGLView); + + // ...add to FrameLayout + framelayout.addView(mGLView); + mGLView.setEGLContextClientVersion(2); mGLView.setCocos2dxRenderer(new Cocos2dxRenderer()); + mGLView.setTextField(edittext); + + // Set framelayout as the content view + setContentView(framelayout); } else { Log.d("activity", "don't support gles2.0"); diff --git a/HelloWorld/proj.android/src/org/cocos2dx/application/ApplicationDemo.java b/HelloWorld/proj.android/src/org/cocos2dx/application/ApplicationDemo.java index 331d161346..eb39238aac 100644 --- a/HelloWorld/proj.android/src/org/cocos2dx/application/ApplicationDemo.java +++ b/HelloWorld/proj.android/src/org/cocos2dx/application/ApplicationDemo.java @@ -33,6 +33,8 @@ import android.content.Context; import android.content.pm.ConfigurationInfo; import android.os.Bundle; import android.util.Log; +import android.widget.FrameLayout; +import android.view.ViewGroup; public class ApplicationDemo extends Cocos2dxActivity{ private Cocos2dxGLSurfaceView mGLView; @@ -45,11 +47,35 @@ public class ApplicationDemo extends Cocos2dxActivity{ String packageName = getApplication().getPackageName(); super.setPackageName(packageName); - setContentView(R.layout.cocos2dx_default_screen_layout); - mGLView = (Cocos2dxGLSurfaceView) findViewById(R.id.cocos2dx_default_gl_surfaceview); - mGLView.setTextField((Cocos2dxEditText)findViewById(R.id.cocos2dx_default_textField)); + // FrameLayout + ViewGroup.LayoutParams framelayout_params = + new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.FILL_PARENT); + FrameLayout framelayout = new FrameLayout(this); + framelayout.setLayoutParams(framelayout_params); + + // Cocos2dxEditText layout + ViewGroup.LayoutParams edittext_layout_params = + new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT); + Cocos2dxEditText edittext = new Cocos2dxEditText(this); + edittext.setLayoutParams(edittext_layout_params); + + // ...add to FrameLayout + framelayout.addView(edittext); + + // Cocos2dxGLSurfaceView + mGLView = new Cocos2dxGLSurfaceView(this); + + // ...add to FrameLayout + framelayout.addView(mGLView); + mGLView.setEGLContextClientVersion(2); mGLView.setCocos2dxRenderer(new Cocos2dxRenderer()); + mGLView.setTextField(edittext); + + // Set framelayout as the content view + setContentView(framelayout); } else { Log.d("activity", "don't support gles2.0"); diff --git a/cocos2dx/platform/android/java/res/layout/cocos2dx_default_screen_layout.xml b/cocos2dx/platform/android/java/res/layout/cocos2dx_default_screen_layout.xml deleted file mode 100644 index cfc9bc4975..0000000000 --- a/cocos2dx/platform/android/java/res/layout/cocos2dx_default_screen_layout.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - diff --git a/template/android/copy_files.sh b/template/android/copy_files.sh index eadbe68fbb..5fa8148cfe 100644 --- a/template/android/copy_files.sh +++ b/template/android/copy_files.sh @@ -6,6 +6,7 @@ APP_NAME=$2 COCOS2DX_ROOT=$1 APP_DIR=$COCOS2DX_ROOT/$APP_NAME HELLOWORLD_ROOT=$COCOS2DX_ROOT/HelloWorld +COCOSJAVALIB_ROOT=$COCOS2DX_ROOT/cocos2dx/platform/android/java NDK_ROOT=$3 PACKAGE_PATH=$4 NEED_BOX2D=$5 diff --git a/tests/proj.android/src/org/cocos2dx/tests/TestsDemo.java b/tests/proj.android/src/org/cocos2dx/tests/TestsDemo.java index 2c15ed0abd..08652a53ec 100644 --- a/tests/proj.android/src/org/cocos2dx/tests/TestsDemo.java +++ b/tests/proj.android/src/org/cocos2dx/tests/TestsDemo.java @@ -33,6 +33,8 @@ import android.content.Context; import android.content.pm.ConfigurationInfo; import android.os.Bundle; import android.util.Log; +import android.widget.FrameLayout; +import android.view.ViewGroup; public class TestsDemo extends Cocos2dxActivity{ private Cocos2dxGLSurfaceView mGLView; @@ -45,12 +47,35 @@ public class TestsDemo extends Cocos2dxActivity{ String packageName = getApplication().getPackageName(); super.setPackageName(packageName); - setContentView(R.layout.cocos2dx_default_screen_layout); - - mGLView = (Cocos2dxGLSurfaceView) findViewById(R.id.cocos2dx_default_gl_surfaceview); - mGLView.setTextField((Cocos2dxEditText)findViewById(R.id.cocos2dx_default_textField)); - mGLView.setEGLContextClientVersion(2); - mGLView.setCocos2dxRenderer(new Cocos2dxRenderer()); + // FrameLayout + ViewGroup.LayoutParams framelayout_params = + new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.FILL_PARENT); + FrameLayout framelayout = new FrameLayout(this); + framelayout.setLayoutParams(framelayout_params); + + // Cocos2dxEditText layout + ViewGroup.LayoutParams edittext_layout_params = + new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, + ViewGroup.LayoutParams.WRAP_CONTENT); + Cocos2dxEditText edittext = new Cocos2dxEditText(this); + edittext.setLayoutParams(edittext_layout_params); + + // ...add to FrameLayout + framelayout.addView(edittext); + + // Cocos2dxGLSurfaceView + mGLView = new Cocos2dxGLSurfaceView(this); + + // ...add to FrameLayout + framelayout.addView(mGLView); + + mGLView.setEGLContextClientVersion(2); + mGLView.setCocos2dxRenderer(new Cocos2dxRenderer()); + mGLView.setTextField(edittext); + + // Set framelayout as the content view + setContentView(framelayout); } else { Log.d("activity", "don't support gles2.0"); From bc150ea5a9185fbc8ba192ddb6067a7f458ce58f Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 15 Jun 2012 11:46:51 +0800 Subject: [PATCH 186/257] fixed #1327: Exported 'create' method for lua bindings. --- HelloLua/Resources/app.icf | 20 ----- HelloLua/Resources/hello.lua | 36 ++++---- HelloWorld/Resources/app.config.txt | 5 -- HelloWorld/Resources/app.icf | 17 ---- .../LuaCocos2d.cpp.REMOVED.git-id | 2 +- tests/Resources/app.config.txt | 5 -- tests/Resources/app.icf | 35 -------- tools/tolua++/CCAction.pkg | 82 +++++++++---------- tools/tolua++/CCActionCamera.pkg | 2 +- tools/tolua++/CCActionEase.pkg | 52 ++++++------ tools/tolua++/CCActionGrid.pkg | 8 +- tools/tolua++/CCActionGrid3D.pkg | 18 ++-- tools/tolua++/CCActionPageTurn3D.pkg | 2 +- tools/tolua++/CCActionProgressTimer.pkg | 4 +- tools/tolua++/CCActionTiledGrid.pkg | 26 +++--- tools/tolua++/CCAnimation.pkg | 8 +- tools/tolua++/CCArray.pkg | 10 +-- tools/tolua++/CCAtlasNode.pkg | 2 +- tools/tolua++/CCDictionary.pkg | 6 +- tools/tolua++/CCLabelAtlas.pkg | 4 +- tools/tolua++/CCLabelBMFont.pkg | 2 +- tools/tolua++/CCLabelTTF.pkg | 5 +- tools/tolua++/CCLayer.pkg | 12 +-- tools/tolua++/CCMenu.pkg | 14 +++- tools/tolua++/CCMenuItem.pkg | 16 ++-- tools/tolua++/CCMotionStreak.pkg | 4 +- tools/tolua++/CCNode.pkg | 2 +- tools/tolua++/CCParallaxNode.pkg | 2 +- tools/tolua++/CCParticleSystem.pkg | 4 +- tools/tolua++/CCProgressTimer.pkg | 2 +- tools/tolua++/CCRenderTexture.pkg | 9 +- tools/tolua++/CCRibbon.pkg | 2 +- tools/tolua++/CCScene.pkg | 2 +- tools/tolua++/CCSprite.pkg | 12 +-- tools/tolua++/CCSpriteBatchNode.pkg | 6 +- tools/tolua++/CCSpriteFrame.pkg | 6 +- tools/tolua++/CCString.pkg | 6 +- tools/tolua++/CCTMXLayer.pkg | 2 +- tools/tolua++/CCTMXTiledMap.pkg | 2 +- tools/tolua++/CCTileMapAtlas.pkg | 5 +- 40 files changed, 196 insertions(+), 263 deletions(-) delete mode 100644 HelloLua/Resources/app.icf delete mode 100644 HelloWorld/Resources/app.config.txt delete mode 100644 HelloWorld/Resources/app.icf delete mode 100644 tests/Resources/app.config.txt delete mode 100644 tests/Resources/app.icf diff --git a/HelloLua/Resources/app.icf b/HelloLua/Resources/app.icf deleted file mode 100644 index f880030bf1..0000000000 --- a/HelloLua/Resources/app.icf +++ /dev/null @@ -1,20 +0,0 @@ -# This file is for configuration settings for your -# application. -# -# The syntax is similar to windows .ini files ie -# -# [GroupName] -# Setting = Value -# -# Which can be read by your application using -# e.g s3eConfigGetString("GroupName", "Setting", string) -# -# All settings must be documented in .config.txt files. -# New settings specific to this application should be -# documented in app.config.txt -# -# Some conditional operations are also permitted, see the -# S3E documentation for details. - -[S3E] -MemSize=12000000 diff --git a/HelloLua/Resources/hello.lua b/HelloLua/Resources/hello.lua index 3fa0545712..365a7a4ba0 100644 --- a/HelloLua/Resources/hello.lua +++ b/HelloLua/Resources/hello.lua @@ -22,22 +22,22 @@ local function creatDog() -- create dog animate local textureDog = CCTextureCache:sharedTextureCache():addImage("dog.png") local rect = CCRectMake(0, 0, frameWidth, frameHeight) - local frame0 = CCSpriteFrame:frameWithTexture(textureDog, rect) + local frame0 = CCSpriteFrame:create(textureDog, rect) rect = CCRectMake(frameWidth, 0, frameWidth, frameHeight) - local frame1 = CCSpriteFrame:frameWithTexture(textureDog, rect) + local frame1 = CCSpriteFrame:create(textureDog, rect) - local spriteDog = CCSprite:spriteWithSpriteFrame(frame0) + local spriteDog = CCSprite:createWithSpriteFrame(frame0) spriteDog.isPaused = false spriteDog:setPosition(0, winSize.height / 4 * 3) - local animFrames = CCArray:arrayWithCapacity(2) + local animFrames = CCArray:create(2) animFrames:addObject(frame0) animFrames:addObject(frame1) - local animation = CCAnimation:animationWithSpriteFrames(animFrames, 0.5) - local animate = CCAnimate:actionWithAnimation(animation); - spriteDog:runAction(CCRepeatForever:actionWithAction(animate)) + local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.5) + local animate = CCAnimate:create(animation); + spriteDog:runAction(CCRepeatForever:create(animate)) -- moving dog at every frame local function tick() @@ -59,17 +59,17 @@ end -- create farm local function createLayerFram() - local layerFarm = CCLayer:node() + local layerFarm = CCLayer:create() -- add in farm background - local bg = CCSprite:spriteWithFile("farm.jpg") + local bg = CCSprite:create("farm.jpg") bg:setPosition(winSize.width / 2 + 80, winSize.height / 2) layerFarm:addChild(bg) -- add land sprite for i = 0, 3 do for j = 0, 1 do - local spriteLand = CCSprite:spriteWithFile("land.png") + local spriteLand = CCSprite:create("land.png") spriteLand:setPosition(200 + j * 180 - i % 2 * 90, 10 + i * 95 / 2) layerFarm:addChild(spriteLand) end @@ -77,10 +77,10 @@ local function createLayerFram() -- add crop local textureCrop = CCTextureCache:sharedTextureCache():addImage("crop.png") - local frameCrop = CCSpriteFrame:frameWithTexture(textureCrop, CCRectMake(0, 0, 105, 95)) + local frameCrop = CCSpriteFrame:create(textureCrop, CCRectMake(0, 0, 105, 95)) for i = 0, 3 do for j = 0, 1 do - local spriteCrop = CCSprite:spriteWithSpriteFrame(frameCrop); + local spriteCrop = CCSprite:createWithSpriteFrame(frameCrop); spriteCrop:setPosition(10 + 200 + j * 180 - i % 2 * 90, 30 + 10 + i * 95 / 2) layerFarm:addChild(spriteCrop) end @@ -136,7 +136,7 @@ end -- create menu local function createLayerMenu() - local layerMenu = CCLayer:node() + local layerMenu = CCLayer:create() local menuPopup, menuTools, effectID @@ -153,19 +153,19 @@ local function createLayerMenu() end -- add a popup menu - local menuPopupItem = CCMenuItemImage:itemWithNormalImage("menu2.png", "menu2.png") + local menuPopupItem = CCMenuItemImage:create("menu2.png", "menu2.png") menuPopupItem:setPosition(0, 0) menuPopupItem:registerScriptHandler(menuCallbackClosePopup) - menuPopup = CCMenu:menuWithItem(menuPopupItem) + menuPopup = CCMenu:createWithItem(menuPopupItem) menuPopup:setPosition(winSize.width / 2, winSize.height / 2) menuPopup:setIsVisible(false) layerMenu:addChild(menuPopup) -- add the left-bottom "tools" menu to invoke menuPopup - local menuToolsItem = CCMenuItemImage:itemWithNormalImage("menu1.png", "menu1.png") + local menuToolsItem = CCMenuItemImage:create("menu1.png", "menu1.png") menuToolsItem:setPosition(0, 0) menuToolsItem:registerScriptHandler(menuCallbackOpenPopup) - menuTools = CCMenu:menuWithItem(menuToolsItem) + menuTools = CCMenu:createWithItem(menuToolsItem) menuTools:setPosition(30, 40) layerMenu:addChild(menuTools) @@ -177,7 +177,7 @@ SimpleAudioEngine:sharedEngine():playBackgroundMusic("background.mp3", true); SimpleAudioEngine:sharedEngine():preloadEffect("effect1.wav"); -- run -local sceneGame = CCScene:node() +local sceneGame = CCScene:create() sceneGame:addChild(createLayerFram()) sceneGame:addChild(createLayerMenu()) CCDirector:sharedDirector():runWithScene(sceneGame) diff --git a/HelloWorld/Resources/app.config.txt b/HelloWorld/Resources/app.config.txt deleted file mode 100644 index 104530ed60..0000000000 --- a/HelloWorld/Resources/app.config.txt +++ /dev/null @@ -1,5 +0,0 @@ -[Trace] -GAME <0 or 1> Game Channel - -[Assert] -GAME <0 or 1> Game Assert Channel \ No newline at end of file diff --git a/HelloWorld/Resources/app.icf b/HelloWorld/Resources/app.icf deleted file mode 100644 index b61c5d2d55..0000000000 --- a/HelloWorld/Resources/app.icf +++ /dev/null @@ -1,17 +0,0 @@ -[S3E] -MemSize=4000000 -#MemFlags0=USE_STACK_ALLOCATOR -#SysStackSwitch=1 -#landscape -#DispFixRot=2 -#or portrait -#DispFixRot=1 -#autorotate -#DispFixRot=0 -# fix for new ati drivers in simulator -# DisableGL=1 - -[Trace] -GAME=1 -IW_GL=1 -IW_GL_VERBOSE=1 diff --git a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index c1a9e0f395..a6cf00ee32 100644 --- a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -c96a0297e226ff452dacd39b6d832b23622d34b7 \ No newline at end of file +6b0bec0c232235cbdf61396805f812c6c8264bae \ No newline at end of file diff --git a/tests/Resources/app.config.txt b/tests/Resources/app.config.txt deleted file mode 100644 index 104530ed60..0000000000 --- a/tests/Resources/app.config.txt +++ /dev/null @@ -1,5 +0,0 @@ -[Trace] -GAME <0 or 1> Game Channel - -[Assert] -GAME <0 or 1> Game Assert Channel \ No newline at end of file diff --git a/tests/Resources/app.icf b/tests/Resources/app.icf deleted file mode 100644 index 18b2db5289..0000000000 --- a/tests/Resources/app.icf +++ /dev/null @@ -1,35 +0,0 @@ -# This file is for configuration settings for your -# application. -# -# The syntax is similar to windows .ini files ie -# -# [GroupName] -# Setting = Value -# -# Which can be read by your application using -# e.g s3eConfigGetString("GroupName", "Setting", string) -# -# All settings must be documented in .config.txt files. -# New settings specific to this application should be -# documented in app.config.txt -# -# Some conditional operations are also permitted, see the -# S3E documentation for details. -[S3E] - -MemSize=[s3e]DispAreaQ + 50331648 -#MemFlags0=USE_STACK_ALLOCATOR -SysStackSwitch=1 -#landscape -#DispFixRot=2 -#or portrait -DispFixRot=1 -#autorotate -#DispFixRot=0 -# fix for new ati drivers in simulator -# DisableGL=1 - -[Trace] -GAME=1 -IW_GL=1 -IW_GL_VERBOSE=1 \ No newline at end of file diff --git a/tools/tolua++/CCAction.pkg b/tools/tolua++/CCAction.pkg index e085d4917e..80b9349896 100644 --- a/tools/tolua++/CCAction.pkg +++ b/tools/tolua++/CCAction.pkg @@ -13,7 +13,7 @@ class CCAction : public CCObject // int getTag(void); // void setTag(int nTag); - // static CCAction* action(); + // static CCAction* create(); }; class CCActionInterval : public CCAction @@ -37,7 +37,7 @@ class CCSpeed : public CCAction void setSpeed(float fSpeed); CCAction* reverse(void); - static CCSpeed* actionWithAction(CCActionInterval *pAction, float fRate); + static CCSpeed* create(CCActionInterval *pAction, float fRate); }; class CCFollow : public CCAction @@ -45,70 +45,70 @@ class CCFollow : public CCAction bool isBoundarySet(void); void setBoudarySet(bool bValue); - static CCFollow* actionWithTarget(CCNode *pFollowedNode); - static CCFollow* actionWithTarget(CCNode *pFollowedNode, CCRect rect); + static CCFollow* create(CCNode *pFollowedNode); + static CCFollow* create(CCNode *pFollowedNode, CCRect rect); }; class CCSequence : public CCActionInterval { - static CCFiniteTimeAction* actionOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo); - static CCFiniteTimeAction* actionWithArray(CCArray *actions); + static CCFiniteTimeAction* create(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo); + static CCFiniteTimeAction* create(CCArray *actions); }; class CCRepeat : public CCActionInterval { - static CCRepeat* actionWithAction(CCActionInterval *pAction, unsigned int times); + static CCRepeat* create(CCActionInterval *pAction, unsigned int times); }; class CCRepeatForever : public CCActionInterval { - static CCRepeatForever* actionWithAction(CCActionInterval *pAction); + static CCRepeatForever* create(CCActionInterval *pAction); }; class CCSpawn : public CCActionInterval { - static CCFiniteTimeAction* actionWithArray(CCArray *actions); - static CCSpawn* actionOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2); + static CCFiniteTimeAction* create(CCArray *actions); + static CCSpawn* create(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2); }; class CCRotateTo : public CCActionInterval { - static CCRotateTo* actionWithDuration(float duration, float fDeltaAngle); + static CCRotateTo* create(float duration, float fDeltaAngle); }; class CCRotateBy : public CCActionInterval { - static CCRotateBy* actionWithDuration(float duration, float fDeltaAngle); + static CCRotateBy* create(float duration, float fDeltaAngle); }; class CCMoveTo : public CCActionInterval { - static CCMoveTo* actionWithDuration(float duration, CCPoint position); + static CCMoveTo* create(float duration, CCPoint position); }; class CCMoveBy : public CCActionInterval { - static CCMoveBy* actionWithDuration(float duration, CCPoint position); + static CCMoveBy* create(float duration, CCPoint position); }; class CCSkewTo : public CCActionInterval { - static CCSkewTo* actionWithDuration(float t, float sx, float sy); + static CCSkewTo* create(float t, float sx, float sy); }; class CCSkewBy : public CCActionInterval { - static CCSkewBy* actionWithDuration(float t, float deltaSkewX, float deltaSkewY); + static CCSkewBy* create(float t, float deltaSkewX, float deltaSkewY); }; class CCJumpBy : public CCActionInterval { - static CCJumpBy* actionWithDuration(float duration, CCPoint position, float height, int jumps); + static CCJumpBy* create(float duration, CCPoint position, float height, int jumps); }; class CCJumpTo : public CCActionInterval { - static CCJumpTo* actionWithDuration(float duration, CCPoint position, float height, int jumps); + static CCJumpTo* create(float duration, CCPoint position, float height, int jumps); }; typedef struct _ccBezierConfig { @@ -119,64 +119,64 @@ typedef struct _ccBezierConfig { class CCBezierBy : public CCActionInterval { - static CCBezierBy* actionWithDuration(float t, ccBezierConfig c); + static CCBezierBy* create(float t, ccBezierConfig c); }; class CCBezierTo : public CCActionInterval { - static CCBezierTo* actionWithDuration(float t, ccBezierConfig c); + static CCBezierTo* create(float t, ccBezierConfig c); }; class CCScaleTo : public CCActionInterval { - static CCScaleTo* actionWithDuration(float duration, float s); - static CCScaleTo* actionWithDuration(float duration, float sx, float sy); + static CCScaleTo* create(float duration, float s); + static CCScaleTo* create(float duration, float sx, float sy); }; class CCScaleBy : public CCActionInterval { - static CCScaleBy* actionWithDuration(float duration, float s); - static CCScaleBy* actionWithDuration(float duration, float sx, float sy); + static CCScaleBy* create(float duration, float s); + static CCScaleBy* create(float duration, float sx, float sy); }; class CCBlink : public CCActionInterval { - static CCBlink* actionWithDuration(float duration, unsigned int uBlinks); + static CCBlink* create(float duration, unsigned int uBlinks); }; class CCFadeIn : public CCActionInterval { - static CCFadeIn* actionWithDuration(float d); + static CCFadeIn* create(float d); }; class CCFadeOut : public CCActionInterval { - static CCFadeOut* actionWithDuration(float d); + static CCFadeOut* create(float d); }; class CCFadeTo : public CCActionInterval { - static CCFadeTo* actionWithDuration(float duration, GLubyte opacity); + static CCFadeTo* create(float duration, GLubyte opacity); }; class CCTintTo : public CCActionInterval { - static CCTintTo* actionWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue); + static CCTintTo* create(float duration, GLubyte red, GLubyte green, GLubyte blue); }; class CCTintBy : public CCActionInterval { - static CCTintBy* actionWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); + static CCTintBy* create(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); }; class CCDelayTime : public CCActionInterval { - static CCDelayTime* actionWithDuration(float d); + static CCDelayTime* create(float d); }; class CCReverseTime : public CCActionInterval { - static CCReverseTime* actionWithAction(CCFiniteTimeAction *pAction); + static CCReverseTime* create(CCFiniteTimeAction *pAction); }; class CCAnimate : public CCActionInterval @@ -184,47 +184,47 @@ class CCAnimate : public CCActionInterval CCAnimation* getAnimation(void); void setAnimation(CCAnimation *pAnimation); - static CCAction* actionWithAnimation(CCAnimation *pAnimation); + static CCAction* create(CCAnimation *pAnimation); }; class CCProgressTo : public CCAction { - static CCAction* actionWithDuration(float duration, float fPercent); + static CCAction* create(float duration, float fPercent); }; class CCProgressFromTo : public CCAction { - static CCAction* actionWithDuration(float duration, float fFromPercentage, float fToPercentage); + static CCAction* create(float duration, float fFromPercentage, float fToPercentage); }; // CCActionInstant class CCShow : public CCAction { - static CCAction* action(); + static CCAction* create(); }; class CCHide : public CCAction { - static CCAction* action(); + static CCAction* create(); }; class CCToggleVisibility : public CCAction { - static CCAction* action(); + static CCAction* create(); }; class CCFlipX : public CCAction { - static CCAction* actionWithFlipX(bool x); + static CCAction* create(bool x); }; class CCFlipY : public CCAction { - static CCAction* actionWithFlipY(bool y); + static CCAction* create(bool y); }; class CCPlace : public CCAction // { - static CCAction* actionWithPosition(CCPoint pos); + static CCAction* create(CCPoint pos); }; diff --git a/tools/tolua++/CCActionCamera.pkg b/tools/tolua++/CCActionCamera.pkg index 848c4b1bb8..b76d064c8c 100644 --- a/tools/tolua++/CCActionCamera.pkg +++ b/tools/tolua++/CCActionCamera.pkg @@ -8,5 +8,5 @@ class CCOrbitCamera : public CCActionCamera { void sphericalRadius(float *r, float *zenith, float *azimuth); - static CCOrbitCamera * actionWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX); + static CCOrbitCamera * create(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX); }; diff --git a/tools/tolua++/CCActionEase.pkg b/tools/tolua++/CCActionEase.pkg index bfe49b9c81..9455a1a7bb 100644 --- a/tools/tolua++/CCActionEase.pkg +++ b/tools/tolua++/CCActionEase.pkg @@ -1,114 +1,114 @@ class CCActionEase : public CCActionInterval { - static CCActionInterval* actionWithAction(CCActionInterval *pAction); + static CCActionInterval* create(CCActionInterval *pAction); }; class CCEaseRateAction : public CCActionInterval { - static CCActionInterval* actionWithAction(CCActionInterval* pAction, float fRate); + static CCActionInterval* create(CCActionInterval* pAction, float fRate); }; class CCEaseIn : public CCActionInterval { - static CCActionInterval* actionWithAction(CCActionInterval* pAction, float fRate); + static CCActionInterval* create(CCActionInterval* pAction, float fRate); }; class CCEaseOut : public CCActionInterval { - static CCActionInterval* actionWithAction(CCActionInterval* pAction, float fRate); + static CCActionInterval* create(CCActionInterval* pAction, float fRate); }; class CCEaseInOut : public CCActionInterval { - static CCActionInterval* actionWithAction(CCActionInterval* pAction, float fRate); + static CCActionInterval* create(CCActionInterval* pAction, float fRate); }; class CCEaseExponentialIn : public CCActionInterval { - static CCActionInterval* actionWithAction(CCActionInterval* pAction); + static CCActionInterval* create(CCActionInterval* pAction); }; class CCEaseExponentialOut : public CCActionInterval { - static CCActionInterval* actionWithAction(CCActionInterval* pAction); + static CCActionInterval* create(CCActionInterval* pAction); }; class CCEaseExponentialInOut : public CCActionInterval { - static CCActionInterval* actionWithAction(CCActionInterval* pAction); + static CCActionInterval* create(CCActionInterval* pAction); }; class CCEaseSineIn : public CCActionInterval { - static CCActionInterval* actionWithAction(CCActionInterval* pAction); + static CCActionInterval* create(CCActionInterval* pAction); }; class CCEaseSineOut : public CCActionInterval { - static CCActionInterval* actionWithAction(CCActionInterval* pAction); + static CCActionInterval* create(CCActionInterval* pAction); }; class CCEaseSineInOut : public CCActionInterval { - static CCActionInterval* actionWithAction(CCActionInterval* pAction); + static CCActionInterval* create(CCActionInterval* pAction); }; class CCEaseElastic : public CCActionInterval { - static CCActionInterval* actionWithAction(CCActionInterval *pAction); - static CCActionInterval* actionWithAction(CCActionInterval *pAction, float fPeriod); + static CCActionInterval* create(CCActionInterval *pAction); + static CCActionInterval* create(CCActionInterval *pAction, float fPeriod); }; class CCEaseElasticIn : public CCActionInterval { - static CCActionInterval* actionWithAction(CCActionInterval *pAction); - static CCActionInterval* actionWithAction(CCActionInterval *pAction, float fPeriod); + static CCActionInterval* create(CCActionInterval *pAction); + static CCActionInterval* create(CCActionInterval *pAction, float fPeriod); }; class CCEaseElasticOut : public CCActionInterval { - static CCActionInterval* actionWithAction(CCActionInterval *pAction); - static CCActionInterval* actionWithAction(CCActionInterval *pAction, float fPeriod); + static CCActionInterval* create(CCActionInterval *pAction); + static CCActionInterval* create(CCActionInterval *pAction, float fPeriod); }; class CCEaseElasticInOut : public CCActionInterval { - static CCActionInterval* actionWithAction(CCActionInterval *pAction); - static CCActionInterval* actionWithAction(CCActionInterval *pAction, float fPeriod); + static CCActionInterval* create(CCActionInterval *pAction); + static CCActionInterval* create(CCActionInterval *pAction, float fPeriod); }; class CCEaseBounce : public CCActionInterval { - static CCActionInterval* actionWithAction(CCActionInterval* pAction); + static CCActionInterval* create(CCActionInterval* pAction); }; class CCEaseBounceIn : public CCActionInterval { - static CCActionInterval* actionWithAction(CCActionInterval* pAction); + static CCActionInterval* create(CCActionInterval* pAction); }; class CCEaseBounceOut : public CCActionInterval { - static CCActionInterval* actionWithAction(CCActionInterval* pAction); + static CCActionInterval* create(CCActionInterval* pAction); }; class CCEaseBounceInOut : public CCActionInterval { - static CCActionInterval* actionWithAction(CCActionInterval* pAction); + static CCActionInterval* create(CCActionInterval* pAction); }; class CCEaseBackIn : public CCActionInterval { - static CCActionInterval* actionWithAction(CCActionInterval* pAction); + static CCActionInterval* create(CCActionInterval* pAction); }; class CCEaseBackOut : public CCActionInterval { - static CCActionInterval* actionWithAction(CCActionInterval* pAction); + static CCActionInterval* create(CCActionInterval* pAction); }; class CCEaseBackInOut : public CCActionInterval { - static CCActionInterval* actionWithAction(CCActionInterval* pAction); + static CCActionInterval* create(CCActionInterval* pAction); }; diff --git a/tools/tolua++/CCActionGrid.pkg b/tools/tolua++/CCActionGrid.pkg index b06f2f6a07..59baa85db2 100644 --- a/tools/tolua++/CCActionGrid.pkg +++ b/tools/tolua++/CCActionGrid.pkg @@ -3,7 +3,7 @@ class CCGridAction : public CCActionInterval { CCGridBase* getGrid(void); - static CCGridAction* actionWithSize(ccGridSize gridSize, float duration); + static CCGridAction* create(ccGridSize gridSize, float duration); }; class CCAccelDeccelAmplitude : public CCActionInterval @@ -11,7 +11,7 @@ class CCAccelDeccelAmplitude : public CCActionInterval float getRate(void); void setRate(float fRate); - static CCAccelDeccelAmplitude* actionWithAction(CCAction *pAction, float duration); + static CCAccelDeccelAmplitude* create(CCAction *pAction, float duration); }; class CCAccelAmplitude : public CCActionInterval @@ -19,7 +19,7 @@ class CCAccelAmplitude : public CCActionInterval float getRate(void); void setRate(float fRate); - static CCAccelAmplitude* actionWithAction(CCAction *pAction, float duration); + static CCAccelAmplitude* create(CCAction *pAction, float duration); }; class CCDeccelAmplitude : public CCActionInterval @@ -27,7 +27,7 @@ class CCDeccelAmplitude : public CCActionInterval float getRate(void); void setRate(float fRate); - static CCDeccelAmplitude* actionWithAction(CCAction *pAction, float duration); + static CCDeccelAmplitude* create(CCAction *pAction, float duration); }; class CCStopGrid : public CCActionInstant diff --git a/tools/tolua++/CCActionGrid3D.pkg b/tools/tolua++/CCActionGrid3D.pkg index a6259e24e2..c3fca6ebfc 100644 --- a/tools/tolua++/CCActionGrid3D.pkg +++ b/tools/tolua++/CCActionGrid3D.pkg @@ -6,17 +6,17 @@ class CCWaves3D : public CCGrid3DAction float getAmplitudeRate(void); void setAmplitudeRate(float fAmplitudeRate); - static CCWaves3D* actionWithWaves(int wav, float amp, ccGridSize gridSize, float duration); + static CCWaves3D* create(int wav, float amp, ccGridSize gridSize, float duration); }; class CCFlipX3D : public CCGrid3DAction { - static CCFlipX3D* actionWithDuration(float duration); + static CCFlipX3D* create(float duration); }; class CCFlipY3D : public CCFlipX3D { - static CCFlipY3D* actionWithDuration(float duration); + static CCFlipY3D* create(float duration); }; class CCLens3D : public CCGrid3DAction @@ -26,7 +26,7 @@ class CCLens3D : public CCGrid3DAction CCPoint getPosition(void); void setPosition(CCPoint position); - static CCLens3D* actionWithPosition(CCPoint pos, float r, ccGridSize gridSize, float duration); + static CCLens3D* create(CCPoint pos, float r, ccGridSize gridSize, float duration); }; class CCRipple3D : public CCGrid3DAction @@ -38,12 +38,12 @@ class CCRipple3D : public CCGrid3DAction float getAmplitudeRate(void); void setAmplitudeRate(float fAmplitudeRate); - static CCRipple3D* actionWithPosition(CCPoint pos, float r, int wav, float amp, ccGridSize gridSize, float duration); + static CCRipple3D* create(CCPoint pos, float r, int wav, float amp, ccGridSize gridSize, float duration); }; class CCShaky3D : public CCGrid3DAction { - static CCShaky3D* actionWithRange(int range, bool shakeZ, ccGridSize gridSize, float duration); + static CCShaky3D* create(int range, bool shakeZ, ccGridSize gridSize, float duration); }; class CCLiquid : public CCGrid3DAction @@ -53,7 +53,7 @@ class CCLiquid : public CCGrid3DAction float getAmplitudeRate(void); void setAmplitudeRate(float fAmplitudeRate); - static CCLiquid* actionWithWaves(int wav, float amp, ccGridSize gridSize, float duration); + static CCLiquid* create(int wav, float amp, ccGridSize gridSize, float duration); }; class CCWaves : public CCGrid3DAction @@ -63,7 +63,7 @@ class CCWaves : public CCGrid3DAction float getAmplitudeRate(void); void setAmplitudeRate(float fAmplitudeRate); - static CCWaves* actionWithWaves(int wav, float amp, bool h, bool v, ccGridSize gridSize,float duration); + static CCWaves* create(int wav, float amp, bool h, bool v, ccGridSize gridSize,float duration); }; class CCTwirl : public CCGrid3DAction @@ -75,5 +75,5 @@ class CCTwirl : public CCGrid3DAction float getAmplitudeRate(void); void setAmplitudeRate(float fAmplitudeRate); - static CCTwirl* actionWithPosition(CCPoint pos, int t, float amp, ccGridSize gridSize,float duration); + static CCTwirl* create(CCPoint pos, int t, float amp, ccGridSize gridSize,float duration); }; diff --git a/tools/tolua++/CCActionPageTurn3D.pkg b/tools/tolua++/CCActionPageTurn3D.pkg index c24dd064e4..f810cc277f 100644 --- a/tools/tolua++/CCActionPageTurn3D.pkg +++ b/tools/tolua++/CCActionPageTurn3D.pkg @@ -1,5 +1,5 @@ class CCPageTurn3D : public CCGrid3DAction { - static CCPageTurn3D* actionWithSize(ccGridSize gridSize, float time); + static CCPageTurn3D* create(ccGridSize gridSize, float time); }; diff --git a/tools/tolua++/CCActionProgressTimer.pkg b/tools/tolua++/CCActionProgressTimer.pkg index ff33aebeef..6e3c911fd8 100644 --- a/tools/tolua++/CCActionProgressTimer.pkg +++ b/tools/tolua++/CCActionProgressTimer.pkg @@ -1,10 +1,10 @@ class CCProgressTo : public CCActionInterval { - static CCProgressTo* actionWithDuration(float duration, float fPercent); + static CCProgressTo* create(float duration, float fPercent); }; class CCProgressFromTo : public CCActionInterval { - static CCProgressFromTo* actionWithDuration(float duration, float fFromPercentage, float fToPercentage); + static CCProgressFromTo* create(float duration, float fFromPercentage, float fToPercentage); }; diff --git a/tools/tolua++/CCActionTiledGrid.pkg b/tools/tolua++/CCActionTiledGrid.pkg index 08f08d811f..5018acaa99 100644 --- a/tools/tolua++/CCActionTiledGrid.pkg +++ b/tools/tolua++/CCActionTiledGrid.pkg @@ -1,12 +1,12 @@ class CCShakyTiles3D : public CCTiledGrid3DAction { - static CCShakyTiles3D* actionWithRange(int nRange, bool bShakeZ, ccGridSize gridSize, float duration); + static CCShakyTiles3D* create(int nRange, bool bShakeZ, ccGridSize gridSize, float duration); }; class CCShatteredTiles3D : public CCTiledGrid3DAction { - static CCShatteredTiles3D* actionWithRange(int nRange, bool bShatterZ, ccGridSize gridSize, float duration); + static CCShatteredTiles3D* create(int nRange, bool bShatterZ, ccGridSize gridSize, float duration); }; class CCShuffleTiles : public CCTiledGrid3DAction @@ -15,7 +15,7 @@ class CCShuffleTiles : public CCTiledGrid3DAction ccGridSize getDelta(ccGridSize pos); void placeTile(ccGridSize pos, Tile *t); - static CCShuffleTiles* actionWithSeed(int s, ccGridSize gridSize, float duration); + static CCShuffleTiles* create(int s, ccGridSize gridSize, float duration); }; class CCFadeOutTRTiles : public CCTiledGrid3DAction @@ -24,22 +24,22 @@ class CCFadeOutTRTiles : public CCTiledGrid3DAction void turnOffTile(ccGridSize pos); void transformTile(ccGridSize pos, float distance); - static CCFadeOutTRTiles* actionWithSize(ccGridSize gridSize, float time); + static CCFadeOutTRTiles* create(ccGridSize gridSize, float time); }; class CCFadeOutBLTiles : public CCFadeOutTRTiles { - static CCFadeOutBLTiles* actionWithSize(ccGridSize gridSize, float time); + static CCFadeOutBLTiles* create(ccGridSize gridSize, float time); }; class CCFadeOutUpTiles : public CCFadeOutTRTiles { - static CCFadeOutUpTiles* actionWithSize(ccGridSize gridSize, float time); + static CCFadeOutUpTiles* create(ccGridSize gridSize, float time); }; class CCFadeOutDownTiles : public CCFadeOutUpTiles { - static CCFadeOutDownTiles* actionWithSize(ccGridSize gridSize, float time); + static CCFadeOutDownTiles* create(ccGridSize gridSize, float time); }; class CCTurnOffTiles : public CCTiledGrid3DAction @@ -48,8 +48,8 @@ class CCTurnOffTiles : public CCTiledGrid3DAction void turnOnTile(ccGridSize pos); void turnOffTile(ccGridSize pos); - static CCTurnOffTiles* actionWithSize(ccGridSize size, float d); - static CCTurnOffTiles* actionWithSeed(int s, ccGridSize gridSize, float duration); + static CCTurnOffTiles* create(ccGridSize size, float d); + static CCTurnOffTiles* create(int s, ccGridSize gridSize, float duration); }; class CCWavesTiles3D : public CCTiledGrid3DAction @@ -59,7 +59,7 @@ class CCWavesTiles3D : public CCTiledGrid3DAction float getAmplitudeRate(void); void setAmplitudeRate(float fAmplitudeRate); - static CCWavesTiles3D* actionWithWaves(int wav, float amp, ccGridSize gridSize, float duration); + static CCWavesTiles3D* create(int wav, float amp, ccGridSize gridSize, float duration); }; class CCJumpTiles3D : public CCTiledGrid3DAction @@ -69,15 +69,15 @@ class CCJumpTiles3D : public CCTiledGrid3DAction float getAmplitudeRate(void); void setAmplitudeRate(float fAmplitudeRate); - static CCJumpTiles3D* actionWithJumps(int j, float amp, ccGridSize gridSize, float duration); + static CCJumpTiles3D* create(int j, float amp, ccGridSize gridSize, float duration); }; class CCSplitRows : public CCTiledGrid3DAction { - static CCSplitRows* actionWithRows(int nRows, float duration); + static CCSplitRows* create(int nRows, float duration); }; class CCSplitCols : public CCTiledGrid3DAction { - static CCSplitCols* actionWithCols(int nCols, float duration); + static CCSplitCols* create(int nCols, float duration); }; diff --git a/tools/tolua++/CCAnimation.pkg b/tools/tolua++/CCAnimation.pkg index cb65a9fd38..0e528ed731 100644 --- a/tools/tolua++/CCAnimation.pkg +++ b/tools/tolua++/CCAnimation.pkg @@ -22,10 +22,10 @@ class CCAnimation : public CCObject CCAnimation(); ~CCAnimation(void); - static CCAnimation* animation(void); - static CCAnimation* animationWithSpriteFrames(CCArray* arrayOfSpriteFrameNames); - static CCAnimation* animationWithSpriteFrames(CCArray* arrayOfSpriteFrameNames, float delay); - static CCAnimation* animationWithAnimationFrames(CCArray *arrayOfSpriteFrameNames, float delayPerUnit, unsigned int loops); + static CCAnimation* create(void); + static CCAnimation* createWithSpriteFrames(CCArray* arrayOfSpriteFrameNames); + static CCAnimation* createWithSpriteFrames(CCArray* arrayOfSpriteFrameNames, float delay); + static CCAnimation* createWithAnimationFrames(CCArray *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops); void addSpriteFrame(CCSpriteFrame *pFrame); void addSpriteFrameWithFileName(const char *pszFileName); diff --git a/tools/tolua++/CCArray.pkg b/tools/tolua++/CCArray.pkg index 1e3fa5819b..c075ca8763 100644 --- a/tools/tolua++/CCArray.pkg +++ b/tools/tolua++/CCArray.pkg @@ -2,11 +2,11 @@ class CCArray : public CCObject { public: - static CCArray* array(); - static CCArray* arrayWithObject(CCObject* pObject); - static CCArray* arrayWithCapacity(unsigned int capacity); - static CCArray* arrayWithArray(CCArray* otherArray); - static CCArray* arrayWithContentsOfFile(const char* pFileName); + static CCArray* create(); + static CCArray* createWithObject(CCObject* pObject); + static CCArray* create(unsigned int capacity); + static CCArray* create(CCArray* otherArray); + static CCArray* createWithContentsOfFile(const char* pFileName); unsigned int count(); diff --git a/tools/tolua++/CCAtlasNode.pkg b/tools/tolua++/CCAtlasNode.pkg index 0644405929..3b6ce53f69 100644 --- a/tools/tolua++/CCAtlasNode.pkg +++ b/tools/tolua++/CCAtlasNode.pkg @@ -5,5 +5,5 @@ class CCAtlasNode : public CCNode CCTexture2D* getTexture(void); void setTexture(CCTexture2D *texture); - static CCAtlasNode * atlasWithTileFile(const char* tile,unsigned int tileWidth, unsigned int tileHeight, unsigned int itemsToRender); + static CCAtlasNode * create(const char* tile,unsigned int tileWidth, unsigned int tileHeight, unsigned int itemsToRender); }; diff --git a/tools/tolua++/CCDictionary.pkg b/tools/tolua++/CCDictionary.pkg index 1884038dfb..3c87553265 100644 --- a/tools/tolua++/CCDictionary.pkg +++ b/tools/tolua++/CCDictionary.pkg @@ -18,9 +18,9 @@ class CCDictionary : public CCObject void removeObjectsForKeys(CCArray* pKeyArray); void removeAllObjects(); - static CCDictionary* dictionary(); - static CCDictionary* dictionaryWithDictionary(CCDictionary* srcDict); - static CCDictionary* dictionaryWithContentsOfFile(const char *pFileName); + static CCDictionary* create(); + static CCDictionary* createWithDictionary(CCDictionary* srcDict); + static CCDictionary* createWithContentsOfFile(const char *pFileName); }; diff --git a/tools/tolua++/CCLabelAtlas.pkg b/tools/tolua++/CCLabelAtlas.pkg index f4c26e577a..51ed11c101 100644 --- a/tools/tolua++/CCLabelAtlas.pkg +++ b/tools/tolua++/CCLabelAtlas.pkg @@ -9,6 +9,6 @@ class CCLabelAtlas : public CCAtlasNode CCTexture2D* getTexture(void); void setTexture(CCTexture2D *texture); - static CCLabelAtlas * labelWithString(const char *label, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap); - static CCAtlasNode * atlasWithTileFile(const char* tile,int tileWidth, int tileHeight, int itemsToRender); + static CCLabelAtlas* create(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); + static CCLabelAtlas* create(const char *sring, const char *fntFile); }; diff --git a/tools/tolua++/CCLabelBMFont.pkg b/tools/tolua++/CCLabelBMFont.pkg index 2a70ea01fb..cde548f9b3 100644 --- a/tools/tolua++/CCLabelBMFont.pkg +++ b/tools/tolua++/CCLabelBMFont.pkg @@ -13,5 +13,5 @@ class CCLabelBMFont : public CCNode tolua_property__CCOpacity GLubyte opacity; static void purgeCachedData(); - static CCLabelBMFont * labelWithString(const char *str, const char *fntFile); + static CCLabelBMFont * create(const char *str, const char *fntFile); }; diff --git a/tools/tolua++/CCLabelTTF.pkg b/tools/tolua++/CCLabelTTF.pkg index 7531d3e394..d8495a5cdb 100644 --- a/tools/tolua++/CCLabelTTF.pkg +++ b/tools/tolua++/CCLabelTTF.pkg @@ -4,6 +4,7 @@ class CCLabelTTF : public CCSprite void setString(const char *label); const char* getString(void); - static CCLabelTTF * labelWithString(const char *label, CCSize dimensions, CCTextAlignment alignment, const char *fontName, float fontSize); - static CCLabelTTF * labelWithString(const char *label, const char *fontName, float fontSize); + static CCLabelTTF * create(const char *label, CCSize dimensions, CCTextAlignment hAlignment,CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize); + static CCLabelTTF * create(const char *label, CCSize dimensions, CCTextAlignment alignment, const char *fontName, float fontSize); + static CCLabelTTF * create(const char *label, const char *fontName, float fontSize); }; diff --git a/tools/tolua++/CCLayer.pkg b/tools/tolua++/CCLayer.pkg index 19c82e3278..d75dbc02de 100644 --- a/tools/tolua++/CCLayer.pkg +++ b/tools/tolua++/CCLayer.pkg @@ -16,7 +16,7 @@ class CCLayer : public CCNode bool bSwallowsTouches = false); void unregisterScriptTouchHandler(); - static CCLayer *node(void); + static CCLayer *create(void); }; class CCLayerColor : public CCLayer @@ -32,8 +32,8 @@ class CCLayerColor : public CCLayer void setBlendFunc(ccBlendFunc Value); ccBlendFunc getBlendFunc(void); - static CCLayerColor * layerWithColor(ccColor4B color, GLfloat width, GLfloat height); - static CCLayerColor * layerWithColor(ccColor4B color); + static CCLayerColor * create(ccColor4B color, GLfloat width, GLfloat height); + static CCLayerColor * create(ccColor4B color); }; class CCLayerGradient : public CCLayerColor @@ -52,8 +52,8 @@ class CCLayerGradient : public CCLayerColor void setIsCompressedInterpolation(bool Value); bool getIsCompressedInterpolation(void); - static CCLayerGradient* layerWithColor(ccColor4B start, ccColor4B end); - static CCLayerGradient* layerWithColor(ccColor4B start, ccColor4B end, CCPoint v); + static CCLayerGradient* create(ccColor4B start, ccColor4B end); + static CCLayerGradient* create(ccColor4B start, ccColor4B end, CCPoint v); }; class CCLayerMultiplex : public CCLayer @@ -62,5 +62,5 @@ class CCLayerMultiplex : public CCLayer void switchTo(unsigned int n); void switchToAndReleaseMe(unsigned int n); - static CCLayerMultiplex * layerWithLayer(CCLayer* layer); + static CCLayerMultiplex * create(CCLayer* layer); }; diff --git a/tools/tolua++/CCMenu.pkg b/tools/tolua++/CCMenu.pkg index 14c5ac6b22..0aa98fd3f6 100644 --- a/tools/tolua++/CCMenu.pkg +++ b/tools/tolua++/CCMenu.pkg @@ -1,7 +1,13 @@ /* +typedef enum +{ + kCCMenuStateWaiting, + kCCMenuStateTrackingTouch +} tCCMenuState; + enum { - //* priority used by the menu - kCCMenuTouchPriority = -128, + //* priority used by the menu for the event handler + kCCMenuHandlerPriority = -128, }; */ class CCMenu : public CCLayer @@ -20,6 +26,6 @@ class CCMenu : public CCLayer void setColor(ccColor3B color); ccColor3B getColor(void); - static CCMenu* node(); - static CCMenu* menuWithItem(CCMenuItem* item); + static CCMenu* create(); + static CCMenu* createWithItem(CCMenuItem* item); }; diff --git a/tools/tolua++/CCMenuItem.pkg b/tools/tolua++/CCMenuItem.pkg index a985daad43..f5c231f866 100644 --- a/tools/tolua++/CCMenuItem.pkg +++ b/tools/tolua++/CCMenuItem.pkg @@ -24,12 +24,12 @@ class CCMenuItemLabel : public CCMenuItem void setColor(ccColor3B color); ccColor3B getColor(); - static CCMenuItemLabel* itemWithLabel(CCNode* label); + static CCMenuItemLabel* create(CCNode* label); }; class CCMenuItemAtlasFont : public CCMenuItem { - static CCMenuItemAtlasFont* itemWithString(const char* value, + static CCMenuItemAtlasFont* create(const char* value, const char* charMapFile, int itemWidth, int itemHeight, @@ -42,7 +42,7 @@ class CCMenuItemFont : public CCMenuItem static int fontSize(); static void setFontName(const char* name); static const char* fontName(); - static CCMenuItemFont * itemWithString(const char* value); + static CCMenuItemFont * create(const char* value); }; class CCMenuItemSprite : public CCMenuItem @@ -52,9 +52,9 @@ class CCMenuItemSprite : public CCMenuItem void setOpacity(GLubyte opacity); GLubyte getOpacity(); - static CCMenuItemSprite * itemWithNormalSprite(CCNode* normalSprite, + static CCMenuItemSprite * create(CCNode* normalSprite, CCNode* selectedSprite); - static CCMenuItemSprite * itemWithNormalSprite(CCNode* normalSprite, + static CCMenuItemSprite * create(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite); }; @@ -66,9 +66,9 @@ class CCMenuItemImage : public CCMenuItem void setOpacity(GLubyte opacity); GLubyte getOpacity(); - static CCMenuItemImage* itemWithNormalImage(const char* normalImage, + static CCMenuItemImage* create(const char* normalImage, const char* selectedImage); - static CCMenuItemImage* itemWithNormalImage(const char* normalImage, + static CCMenuItemImage* create(const char* normalImage, const char* selectedImage, const char* disabledImage); }; @@ -78,5 +78,5 @@ class CCMenuItemToggle : public CCMenuItem void addSubItem(CCMenuItem *item); CCMenuItem* selectedItem(); - static CCMenuItemToggle* itemWithItem(CCMenuItem *item); + static CCMenuItemToggle* create(CCMenuItem *item); }; diff --git a/tools/tolua++/CCMotionStreak.pkg b/tools/tolua++/CCMotionStreak.pkg index 97e0f890d1..882adcaaad 100644 --- a/tools/tolua++/CCMotionStreak.pkg +++ b/tools/tolua++/CCMotionStreak.pkg @@ -1,7 +1,7 @@ class CCMotionStreak : public CCNode { - static CCMotionStreak* streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, const char* path); - static CCMotionStreak* streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, CCTexture2D* texture); + static CCMotionStreak* create(float fade, float minSeg, float stroke, ccColor3B color, const char* path); + static CCMotionStreak* create(float fade, float minSeg, float stroke, ccColor3B color, CCTexture2D* texture); void tintWithColor(ccColor3B colors); void reset(); diff --git a/tools/tolua++/CCNode.pkg b/tools/tolua++/CCNode.pkg index e00b1e4a94..ac5451acdc 100644 --- a/tools/tolua++/CCNode.pkg +++ b/tools/tolua++/CCNode.pkg @@ -118,5 +118,5 @@ class CCNode : public CCObject void registerScriptHandler(LUA_FUNCTION funcID); void unregisterScriptHandler(void); - static CCNode * node(void); + static CCNode * create(void); }; diff --git a/tools/tolua++/CCParallaxNode.pkg b/tools/tolua++/CCParallaxNode.pkg index 631b52c812..c4d68d9d07 100644 --- a/tools/tolua++/CCParallaxNode.pkg +++ b/tools/tolua++/CCParallaxNode.pkg @@ -17,5 +17,5 @@ class CCParallaxNode : public CCNode struct _ccArray* getParallaxArray(); void setParallaxArray(struct _ccArray * val); - static CCParallaxNode* node(); + static CCParallaxNode* create(); }; diff --git a/tools/tolua++/CCParticleSystem.pkg b/tools/tolua++/CCParticleSystem.pkg index ff8dd16c28..6d89808535 100644 --- a/tools/tolua++/CCParticleSystem.pkg +++ b/tools/tolua++/CCParticleSystem.pkg @@ -46,10 +46,10 @@ class CCParticleSystem : public CCNode ccBlendFunc getBlendFunc(void); void setBlendFunc(ccBlendFunc var); - static CCParticleSystem * particleWithFile(const char *plistFile); + static CCParticleSystem * create(const char *plistFile); }; class CCParticleSystemQuad : public CCParticleSystem { - static CCParticleSystemQuad * particleWithFile(const char *plistFile); + static CCParticleSystemQuad * create(const char *plistFile); }; diff --git a/tools/tolua++/CCProgressTimer.pkg b/tools/tolua++/CCProgressTimer.pkg index ec84778f19..5b2da789cf 100644 --- a/tools/tolua++/CCProgressTimer.pkg +++ b/tools/tolua++/CCProgressTimer.pkg @@ -24,7 +24,7 @@ class CCProgressTimer : public CCNode void setIsOpacityModifyRGB(bool bValue); bool getIsOpacityModifyRGB(void); - static CCProgressTimer* progressWithSprite(CCSprite* sp); + static CCProgressTimer* create(CCSprite* sp); CCPoint getMidpoint(); void setMidpoint(CCPoint pt); diff --git a/tools/tolua++/CCRenderTexture.pkg b/tools/tolua++/CCRenderTexture.pkg index 99f79277bf..bbdf231073 100644 --- a/tools/tolua++/CCRenderTexture.pkg +++ b/tools/tolua++/CCRenderTexture.pkg @@ -13,14 +13,19 @@ class CCRenderTexture : public CCNode void begin(); void endToLua(); void beginWithClear(float r, float g, float b, float a); + void beginWithClear(float r, float g, float b, float a, float depthValue); + void beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue); void clear(float r, float g, float b, float a); + void clearDepth(float depthValue); + void clearStencil(int stencilValue); CCImage* newCCImage(); bool saveToFile(const char *szFilePath); bool saveToFile(const char *name, tCCImageFormat format); - static CCRenderTexture * renderTextureWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat); - static CCRenderTexture * renderTextureWithWidthAndHeight(int w, int h); + static CCRenderTexture * create(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat); + static CCRenderTexture * create(int w, int h, CCTexture2DPixelFormat eFormat); + static CCRenderTexture * create(int w, int h); }; diff --git a/tools/tolua++/CCRibbon.pkg b/tools/tolua++/CCRibbon.pkg index 303b23ddd2..a4fd5bdc87 100644 --- a/tools/tolua++/CCRibbon.pkg +++ b/tools/tolua++/CCRibbon.pkg @@ -16,5 +16,5 @@ class CCRibbon: public CCNode void addPointAt(CCPoint location, float width); float sideOfLine(CCPoint p, CCPoint l1, CCPoint l2); - static CCRibbon * ribbonWithWidth(float w, const char *path, float length, ccColor4B color, float fade); + static CCRibbon * create(float w, const char *path, float length, ccColor4B color, float fade); }; diff --git a/tools/tolua++/CCScene.pkg b/tools/tolua++/CCScene.pkg index acbf2b6a6f..350672772d 100644 --- a/tools/tolua++/CCScene.pkg +++ b/tools/tolua++/CCScene.pkg @@ -1,5 +1,5 @@ class CCScene : public CCNode { - static CCScene *node(void); + static CCScene *create(void); }; diff --git a/tools/tolua++/CCSprite.pkg b/tools/tolua++/CCSprite.pkg index 3ec9c4a6d7..f29940c283 100644 --- a/tools/tolua++/CCSprite.pkg +++ b/tools/tolua++/CCSprite.pkg @@ -70,12 +70,12 @@ class CCSprite : public CCNode //CCSpriteFrame* displayedFrame(void); void setDisplayFrameWithAnimationName(const char *animationName, int frameIndex); - static CCSprite* spriteWithTexture(CCTexture2D *pTexture); - static CCSprite* spriteWithTexture(CCTexture2D *pTexture, CCRect rect); + static CCSprite* createWithTexture(CCTexture2D *pTexture); + static CCSprite* createWithTexture(CCTexture2D *pTexture, CCRect rect); // static CCSprite* spriteWithTexture(CCTexture2D *pTexture, CCRect rect, CCPoint offset); - static CCSprite* spriteWithSpriteFrame(CCSpriteFrame *pSpriteFrame); - static CCSprite* spriteWithSpriteFrameName(const char *pszSpriteFrameName); - static CCSprite* spriteWithFile(const char *pszFileName); - static CCSprite* spriteWithFile(const char *pszFileName, CCRect rect); + static CCSprite* createWithSpriteFrame(CCSpriteFrame *pSpriteFrame); + static CCSprite* createWithSpriteFrameName(const char *pszSpriteFrameName); + static CCSprite* create(const char *pszFileName); + static CCSprite* create(const char *pszFileName, CCRect rect); //static CCSprite* spriteWithBatchNode(CCSpriteBatchNode *batchNode, CCRect rect); }; diff --git a/tools/tolua++/CCSpriteBatchNode.pkg b/tools/tolua++/CCSpriteBatchNode.pkg index 7ffd73ac28..629266d7cd 100644 --- a/tools/tolua++/CCSpriteBatchNode.pkg +++ b/tools/tolua++/CCSpriteBatchNode.pkg @@ -20,6 +20,8 @@ class CCSpriteBatchNode : public CCNode void setBlendFunc(ccBlendFunc blendFunc); ccBlendFunc getBlendFunc(void); - static CCSpriteBatchNode* batchNodeWithTexture(CCTexture2D *tex); - static CCSpriteBatchNode* batchNodeWithTexture(CCTexture2D* tex, unsigned int capacity); + static CCSpriteBatchNode* createWithTexture(CCTexture2D *tex); + static CCSpriteBatchNode* createWithTexture(CCTexture2D* tex, unsigned int capacity); + static CCSpriteBatchNode* create(const char* fileImage); + static CCSpriteBatchNode* create(const char* fileImage, unsigned int capacity); }; diff --git a/tools/tolua++/CCSpriteFrame.pkg b/tools/tolua++/CCSpriteFrame.pkg index e54d8aa406..7ec0e5578a 100644 --- a/tools/tolua++/CCSpriteFrame.pkg +++ b/tools/tolua++/CCSpriteFrame.pkg @@ -19,6 +19,8 @@ class CCSpriteFrame : public CCObject CCTexture2D* getTexture(void); void setTexture(CCTexture2D* pobTexture); - static CCSpriteFrame* frameWithTexture(CCTexture2D* pobTexture, CCRect rect); - static CCSpriteFrame* frameWithTexture(CCTexture2D* pobTexture, CCRect rect, bool rotated, CCPoint offset, CCSize originalSize); + static CCSpriteFrame* create(CCTexture2D* pobTexture, CCRect rect); + static CCSpriteFrame* create(CCTexture2D* pobTexture, CCRect rect, bool rotated, CCPoint offset, CCSize originalSize); + static CCSpriteFrame* createWithTextureFilename(const char* filename, CCRect rect); + static CCSpriteFrame* createWithTextureFilename(const char* filename, CCRect rect, bool rotated, CCPoint offset, CCSize originalSize); }; diff --git a/tools/tolua++/CCString.pkg b/tools/tolua++/CCString.pkg index bf0aa0f6e9..ea8df4181a 100644 --- a/tools/tolua++/CCString.pkg +++ b/tools/tolua++/CCString.pkg @@ -11,8 +11,8 @@ class CCString : public CCObject bool isEqual(const CCObject* pObject); - static CCString* stringWithCString(const char* pStr); - static CCString* stringWithData(unsigned char* pData, unsigned long nLen); - static CCString* stringWithContentsOfFile(const char* pszFileName); + static CCString* create(const char* pStr); + static CCString* createWithData(unsigned char* pData, unsigned long nLen); + static CCString* createWithContentsOfFile(const char* pszFileName); }; diff --git a/tools/tolua++/CCTMXLayer.pkg b/tools/tolua++/CCTMXLayer.pkg index 15c53fd7de..758735f357 100644 --- a/tools/tolua++/CCTMXLayer.pkg +++ b/tools/tolua++/CCTMXLayer.pkg @@ -34,5 +34,5 @@ class CCTMXLayer : public CCSpriteBatchNode void setLayerName(const char *layerName); const char* getLayerName(); - static CCTMXLayer * layerWithTilesetInfo(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo); + static CCTMXLayer * create(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo); }; diff --git a/tools/tolua++/CCTMXTiledMap.pkg b/tools/tolua++/CCTMXTiledMap.pkg index ff779e0380..b01e9764b3 100644 --- a/tools/tolua++/CCTMXTiledMap.pkg +++ b/tools/tolua++/CCTMXTiledMap.pkg @@ -31,5 +31,5 @@ class CCTMXTiledMap : public CCNode CCString *propertyNamed(const char *propertyName); CCDictionary *propertiesForGID(int GID); - static CCTMXTiledMap * tiledMapWithTMXFile(const char *tmxFile); + static CCTMXTiledMap * create(const char *tmxFile); }; diff --git a/tools/tolua++/CCTileMapAtlas.pkg b/tools/tolua++/CCTileMapAtlas.pkg index 9e3e4788ce..4125983ee9 100644 --- a/tools/tolua++/CCTileMapAtlas.pkg +++ b/tools/tolua++/CCTileMapAtlas.pkg @@ -1,6 +1,5 @@ -typedef std::map StringToIntegerDictionary; -typedef std::pair StringToIntegerPair; + struct sImageTGA; class CCTileMapAtlas : public CCAtlasNode @@ -11,5 +10,5 @@ class CCTileMapAtlas : public CCAtlasNode void setTile(ccColor3B tile, ccGridSize position); void releaseMap(); - static CCTileMapAtlas * tileMapAtlasWithTileFile(const char *tile, const char *mapFile, int tileWidth, int tileHeight); + static CCTileMapAtlas * create(const char *tile, const char *mapFile, int tileWidth, int tileHeight); }; From 159b91b6cdc85b75ab197bff1d8b82db5fbd6b70 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 15 Jun 2012 13:56:27 +0800 Subject: [PATCH 187/257] Fixed a logic error in ActionScaleTest. --- tests/tests/ActionsTest/ActionsTest.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/tests/ActionsTest/ActionsTest.cpp b/tests/tests/ActionsTest/ActionsTest.cpp index 06e0101edf..9973061b8c 100644 --- a/tests/tests/ActionsTest/ActionsTest.cpp +++ b/tests/tests/ActionsTest/ActionsTest.cpp @@ -353,13 +353,12 @@ void ActionScale::onEnter() centerSprites(3); - CCActionInterval* actionTo = CCScaleTo::create( 2.0f, 0.5f); - CCActionInterval* actionBy = CCScaleBy::create(2.0f , 1.0f, 10.0f); + CCActionInterval* actionTo = CCScaleTo::create(2.0f, 0.5f); + CCActionInterval* actionBy = CCScaleBy::create(2.0f, 1.0f, 10.0f); CCActionInterval* actionBy2 = CCScaleBy::create(2.0f, 5.0f, 1.0f); - CCActionInterval* actionByBack = actionBy->reverse(); m_grossini->runAction( actionTo); - m_tamara->runAction( CCSequence::create(actionBy, actionByBack->reverse(), NULL)); + m_tamara->runAction( CCSequence::create(actionBy, actionBy->reverse(), NULL)); m_kathia->runAction( CCSequence::create(actionBy2, actionBy2->reverse(), NULL)); } From d0f905992ae9f6e53005ae0961a420738c774231 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 15 Jun 2012 15:10:40 +0800 Subject: [PATCH 188/257] issue #1292:make some function names more readable --- cocos2dx/CCCamera.h | 2 +- cocos2dx/CCConfiguration.h | 10 +- cocos2dx/CCDirector.cpp | 2 +- cocos2dx/actions/CCAction.cpp | 2 +- cocos2dx/actions/CCActionInstant.cpp | 6 +- cocos2dx/actions/CCActionInstant.h | 20 +- cocos2dx/actions/CCActionInterval.cpp | 2 +- cocos2dx/base_nodes/CCAtlasNode.cpp | 8 +- cocos2dx/base_nodes/CCAtlasNode.h | 5 +- cocos2dx/base_nodes/CCNode.cpp | 11 +- cocos2dx/base_nodes/CCNode.h | 11 +- cocos2dx/effects/CCGrid.cpp | 4 +- cocos2dx/effects/CCGrid.h | 2 +- .../extensions/CCBReader/CCLayerLoader.cpp | 4 +- .../extensions/CCBReader/CCNodeLoader.cpp | 4 +- .../CCControlExtension/CCControl.cpp | 6 +- .../extensions/CCControlExtension/CCControl.h | 4 +- .../CCControlExtension/CCControlButton.cpp | 18 +- .../CCControlColourPicker.cpp | 2 +- .../CCControlExtension/CCControlHuePicker.cpp | 2 +- .../CCControlSaturationBrightnessPicker.cpp | 2 +- .../CCControlExtension/CCControlSlider.cpp | 6 +- .../CCControlExtension/CCControlSwitch.cpp | 4 +- .../CCControlExtension/CCMenuPassive.cpp | 2 +- .../CCControlExtension/CCMenuPassive.h | 4 +- .../CCControlExtension/CCScale9Sprite.cpp | 6 +- .../CCControlExtension/CCScale9Sprite.h | 4 +- cocos2dx/extensions/CCListView/CCListView.cpp | 6 +- .../extensions/CCListView/CCListViewCell.cpp | 2 +- cocos2dx/include/CCProtocols.h | 4 +- cocos2dx/label_nodes/CCLabelAtlas.h | 1 - cocos2dx/label_nodes/CCLabelBMFont.cpp | 79 ++-- cocos2dx/label_nodes/CCLabelBMFont.h | 4 +- .../CCLayer.cpp | 12 +- .../layers_scenes_transitions_nodes/CCLayer.h | 18 +- .../CCTransition.cpp | 26 +- .../CCTransitionPageTurn.cpp | 2 +- .../CCTransitionProgress.cpp | 28 +- .../CCTransitionProgress.h | 6 +- cocos2dx/menu_nodes/CCMenu.cpp | 9 +- cocos2dx/menu_nodes/CCMenu.h | 10 +- cocos2dx/menu_nodes/CCMenuItem.cpp | 44 +-- cocos2dx/menu_nodes/CCMenuItem.h | 21 +- cocos2dx/misc_nodes/CCMotionStreak.cpp | 6 +- cocos2dx/misc_nodes/CCMotionStreak.h | 4 +- cocos2dx/misc_nodes/CCProgressTimer.cpp | 4 +- cocos2dx/misc_nodes/CCProgressTimer.h | 9 +- cocos2dx/misc_nodes/CCRenderTexture.cpp | 2 +- .../particle_nodes/CCParticleBatchNode.cpp | 4 +- .../particle_nodes/CCParticleExamples.cpp | 22 +- cocos2dx/particle_nodes/CCParticleSystem.cpp | 10 +- cocos2dx/particle_nodes/CCParticleSystem.h | 8 +- cocos2dx/sprite_nodes/CCSprite.cpp | 16 +- cocos2dx/sprite_nodes/CCSprite.h | 6 +- cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp | 2 +- cocos2dx/textures/CCTexture2D.cpp | 9 +- cocos2dx/textures/CCTexture2D.h | 7 +- cocos2dx/textures/CCTexturePVR.cpp | 6 +- .../project.pbxproj.REMOVED.git-id | 2 +- .../AccelerometerTest/AccelerometerTest.cpp | 2 +- tests/tests/Box2DTest/Box2dTest.cpp | 6 +- tests/tests/Box2DTestBed/Box2dView.cpp | 4 +- tests/tests/BugsTest/Bug-1159.cpp | 4 +- tests/tests/BugsTest/Bug-624.cpp | 4 +- tests/tests/BugsTest/Bug-914.cpp | 4 +- tests/tests/BugsTest/BugsTest.cpp | 2 +- .../ChipmunkAccelTouchTest.cpp | 6 +- .../ClickAndMoveTest/ClickAndMoveTest.cpp | 2 +- .../CocosDenshionTest/CocosDenshionTest.cpp | 2 +- tests/tests/CurlTest/CurlTest.cpp | 2 +- tests/tests/FontTest/FontTest.cpp | 112 +++--- tests/tests/KeypadTest/KeypadTest.cpp | 2 +- tests/tests/LabelTest/LabelTest.cpp | 366 +++++++++--------- tests/tests/LayerTest/LayerTest.cpp | 276 ++++++------- tests/tests/MenuTest/MenuTest.cpp | 6 +- .../MotionStreakTest/MotionStreakTest.cpp | 2 +- tests/tests/MutiTouchTest/MutiTouchTest.cpp | 2 +- tests/tests/NodeTest/NodeTest.cpp | 2 +- tests/tests/ParallaxTest/ParallaxTest.cpp | 2 +- tests/tests/ParticleTest/ParticleTest.cpp | 136 +++---- .../PerformanceParticleTest.cpp | 8 +- .../PerformanceTouchesTest.cpp | 4 +- .../RenderTextureTest/RenderTextureTest.cpp | 4 +- .../tests/RotateWorldTest/RotateWorldTest.cpp | 2 +- .../SpriteTest/SpriteTest.cpp.REMOVED.git-id | 2 +- tests/tests/TextInputTest/TextInputTest.cpp | 2 +- tests/tests/TileMapTest/TileMapTest.cpp | 2 +- tests/tests/controller.cpp | 2 +- 88 files changed, 777 insertions(+), 735 deletions(-) diff --git a/cocos2dx/CCCamera.h b/cocos2dx/CCCamera.h index 76facc6091..a454320eed 100644 --- a/cocos2dx/CCCamera.h +++ b/cocos2dx/CCCamera.h @@ -84,7 +84,7 @@ public: /** sets the dirty value */ inline void setDirty(bool bValue) { m_bDirty = bValue; } /** get the dirty value */ - inline bool getDirty(void) { return m_bDirty; } + inline bool isDirty(void) { return m_bDirty; } /** sets the camera in the default position */ void restore(void); diff --git a/cocos2dx/CCConfiguration.h b/cocos2dx/CCConfiguration.h index 5064765dbb..56199a52be 100644 --- a/cocos2dx/CCConfiguration.h +++ b/cocos2dx/CCConfiguration.h @@ -70,13 +70,13 @@ public: @since v0.99.2 */ - inline bool isSupportsNPOT(void) + inline bool supportsNPOT(void) { return m_bSupportsNPOT; } /** Whether or not PVR Texture Compressed is supported */ - inline bool isSupportsPVRTC(void) + inline bool supportsPVRTC(void) { return m_bSupportsPVRTC; } @@ -84,7 +84,7 @@ public: /** Whether or not BGRA8888 textures are supported. @since v0.99.2 */ - inline bool isSupportsBGRA8888(void) + inline bool supportsBGRA8888(void) { return m_bSupportsBGRA8888; } @@ -92,7 +92,7 @@ public: /** Whether or not glDiscardFramebufferEXT is supported @since v0.99.2 */ - inline bool isSupportsDiscardFramebuffer(void) + inline bool supportsDiscardFramebuffer(void) { return m_bSupportsDiscardFramebuffer; } @@ -100,7 +100,7 @@ public: /** Whether or not shareable VAOs are supported. @since v2.0.0 */ - inline bool isSupportsShareableVAO(void) + inline bool supportsShareableVAO(void) { return m_bSupportsShareableVAO; } diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 914af848b8..83a0e0f29a 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -546,7 +546,7 @@ void CCDirector::popToRootScene(void) while (c > 1) { CCScene *current = (CCScene*)m_pobScenesStack->lastObject(); - if( current->getIsRunning() ) + if( current->isRunning() ) { current->onExit(); } diff --git a/cocos2dx/actions/CCAction.cpp b/cocos2dx/actions/CCAction.cpp index 05ae20b8f1..91398b6c1c 100644 --- a/cocos2dx/actions/CCAction.cpp +++ b/cocos2dx/actions/CCAction.cpp @@ -331,7 +331,7 @@ void CCFollow::step(float dt) bool CCFollow::isDone() { - return ( !m_pobFollowedNode->getIsRunning() ); + return ( !m_pobFollowedNode->isRunning() ); } void CCFollow::stop() diff --git a/cocos2dx/actions/CCActionInstant.cpp b/cocos2dx/actions/CCActionInstant.cpp index 0516d1466e..f2eaa36c70 100644 --- a/cocos2dx/actions/CCActionInstant.cpp +++ b/cocos2dx/actions/CCActionInstant.cpp @@ -91,7 +91,7 @@ CCShow* CCShow::create() void CCShow::update(float time) { CC_UNUSED_PARAM(time); - m_pTarget->setIsVisible(true); + m_pTarget->setVisible(true); } CCFiniteTimeAction* CCShow::reverse() { @@ -135,7 +135,7 @@ CCHide * CCHide::create() void CCHide::update(float time) { CC_UNUSED_PARAM(time); - m_pTarget->setIsVisible(false); + m_pTarget->setVisible(false); } CCFiniteTimeAction *CCHide::reverse() { @@ -181,7 +181,7 @@ CCToggleVisibility * CCToggleVisibility::create() void CCToggleVisibility::update(float time) { CC_UNUSED_PARAM(time); - m_pTarget->setIsVisible(!m_pTarget->getIsVisible()); + m_pTarget->setVisible(!m_pTarget->isVisible()); } CCObject* CCToggleVisibility::copyWithZone(CCZone *pZone) diff --git a/cocos2dx/actions/CCActionInstant.h b/cocos2dx/actions/CCActionInstant.h index 14d0afaeba..bd9fa64204 100644 --- a/cocos2dx/actions/CCActionInstant.h +++ b/cocos2dx/actions/CCActionInstant.h @@ -210,15 +210,11 @@ public: CCCallFunc() : m_pSelectorTarget(NULL) , m_pCallFunc(NULL) - { } virtual ~CCCallFunc() { - if (m_pSelectorTarget) - { - m_pSelectorTarget->release(); - } + CC_SAFE_RELEASE(m_pSelectorTarget); } /** creates the action with the callback @warning: This interface will be deprecated in future. @@ -252,17 +248,9 @@ public: { if (pSel != m_pSelectorTarget) { - if (m_pSelectorTarget) - { - m_pSelectorTarget->release(); - } - - m_pSelectorTarget = pSel; - - if (m_pSelectorTarget) - { - m_pSelectorTarget->retain(); - } + CC_SAFE_RETAIN(pSel); + CC_SAFE_RELEASE(m_pSelectorTarget); + m_pSelectorTarget = pSel; } } diff --git a/cocos2dx/actions/CCActionInterval.cpp b/cocos2dx/actions/CCActionInterval.cpp index e250a4a996..f8b5de9005 100644 --- a/cocos2dx/actions/CCActionInterval.cpp +++ b/cocos2dx/actions/CCActionInterval.cpp @@ -1722,7 +1722,7 @@ void CCBlink::update(float time) { float slice = 1.0f / m_nTimes; float m = fmodf(time, slice); - m_pTarget->setIsVisible(m > slice / 2 ? true : false); + m_pTarget->setVisible(m > slice / 2 ? true : false); } } diff --git a/cocos2dx/base_nodes/CCAtlasNode.cpp b/cocos2dx/base_nodes/CCAtlasNode.cpp index 455818a8de..deb87cc22b 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.cpp +++ b/cocos2dx/base_nodes/CCAtlasNode.cpp @@ -184,21 +184,21 @@ void CCAtlasNode::setOpacity(GLubyte opacity) this->setColor(m_tColorUnmodified); } -void CCAtlasNode::setIsOpacityModifyRGB(bool bValue) +void CCAtlasNode::setOpacityModifyRGB(bool bValue) { ccColor3B oldColor = this->m_tColor; m_bIsOpacityModifyRGB = bValue; this->m_tColor = oldColor; } -bool CCAtlasNode::getIsOpacityModifyRGB() +bool CCAtlasNode::isOpacityModifyRGB() { return m_bIsOpacityModifyRGB; } void CCAtlasNode::updateOpacityModifyRGB() { - m_bIsOpacityModifyRGB = m_pTextureAtlas->getTexture()->getHasPremultipliedAlpha(); + m_bIsOpacityModifyRGB = m_pTextureAtlas->getTexture()->hasPremultipliedAlpha(); } // CCAtlasNode - CocosNodeTexture protocol @@ -215,7 +215,7 @@ void CCAtlasNode::setBlendFunc(ccBlendFunc blendFunc) void CCAtlasNode::updateBlendFunc() { - if( ! m_pTextureAtlas->getTexture()->getHasPremultipliedAlpha() ) { + if( ! m_pTextureAtlas->getTexture()->hasPremultipliedAlpha() ) { m_tBlendFunc.src = GL_SRC_ALPHA; m_tBlendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; } diff --git a/cocos2dx/base_nodes/CCAtlasNode.h b/cocos2dx/base_nodes/CCAtlasNode.h index 806ad8587d..ecd4231a38 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.h +++ b/cocos2dx/base_nodes/CCAtlasNode.h @@ -63,7 +63,10 @@ protected: CC_PROPERTY(CCTextureAtlas*, m_pTextureAtlas, TextureAtlas); // protocol variables - CC_PROPERTY(bool, m_bIsOpacityModifyRGB, IsOpacityModifyRGB) + bool m_bIsOpacityModifyRGB; + bool isOpacityModifyRGB(); + void setOpacityModifyRGB(bool isOpacityModifyRGB); + CC_PROPERTY(ccBlendFunc, m_tBlendFunc, BlendFunc); CC_PROPERTY(GLubyte, m_cOpacity, Opacity); CC_PROPERTY_PASS_BY_REF(ccColor3B, m_tColor, Color); diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 656abf28fd..82f98cfeab 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -324,13 +324,13 @@ void CCNode::setGrid(CCGridBase* pGrid) /// isVisible getter -bool CCNode::getIsVisible() +bool CCNode::isVisible() { return m_bIsVisible; } /// isVisible setter -void CCNode::setIsVisible(bool var) +void CCNode::setVisible(bool var) { m_bIsVisible = var; } @@ -374,12 +374,11 @@ void CCNode::setContentSize(const CCSize& size) } // isRunning getter -bool CCNode::getIsRunning() +bool CCNode::isRunning() { return m_bIsRunning; } - /// parent getter CCNode * CCNode::getParent() { @@ -392,12 +391,12 @@ void CCNode::setParent(CCNode * var) } /// isRelativeAnchorPoint getter -bool CCNode::getIgnoreAnchorPointForPosition() +bool CCNode::isIgnoreAnchorPointForPosition() { return m_bIgnoreAnchorPointForPosition; } /// isRelativeAnchorPoint setter -void CCNode::setIgnoreAnchorPointForPosition(bool newValue) +void CCNode::ignoreAnchorPointForPosition(bool newValue) { if (newValue != m_bIgnoreAnchorPointForPosition) { diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index 836ac2ee72..f5977ef97e 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -196,7 +196,9 @@ class CC_DLL CCNode : public CCObject CC_PROPERTY(CCGridBase *, m_pGrid, Grid) /** Whether of not the node is visible. Default is true */ - CC_PROPERTY(bool, m_bIsVisible, IsVisible) + bool m_bIsVisible; + bool isVisible(); + void setVisible(bool visible); /** anchorPoint is the point around which all transformations and positioning manipulations take place. It's like a pin in the node where it is "attached" to its parent. @@ -220,14 +222,17 @@ class CC_DLL CCNode : public CCObject CC_PROPERTY_PASS_BY_REF(CCSize, m_tContentSize, ContentSize) /** whether or not the node is running */ - CC_PROPERTY_READONLY(bool, m_bIsRunning, IsRunning) + bool m_bIsRunning; + bool isRunning(); /** A weak reference to the parent */ CC_PROPERTY(CCNode *, m_pParent, Parent) // If ture, the Anchor Point will be (0,0) when you position the CCNode. // Used by CCLayer and CCScene - CC_PROPERTY(bool, m_bIgnoreAnchorPointForPosition, IgnoreAnchorPointForPosition); + bool m_bIgnoreAnchorPointForPosition; + bool isIgnoreAnchorPointForPosition(); + void ignoreAnchorPointForPosition(bool isIgnoreAnchorPointForPosition); /** A tag used to identify the node easily */ CC_PROPERTY(int, m_nTag, Tag) diff --git a/cocos2dx/effects/CCGrid.cpp b/cocos2dx/effects/CCGrid.cpp index f0901a8b82..c8326f765e 100644 --- a/cocos2dx/effects/CCGrid.cpp +++ b/cocos2dx/effects/CCGrid.cpp @@ -178,7 +178,7 @@ void CCGridBase::setActive(bool bActive) } } -void CCGridBase::setIsTextureFlipped(bool bFlipped) +void CCGridBase::setTextureFlipped(bool bFlipped) { if (m_bIsTextureFlipped != bFlipped) { @@ -228,7 +228,7 @@ void CCGridBase::afterDraw(cocos2d::CCNode *pTarget) CCDirector *director = CCDirector::sharedDirector(); director->setProjection(m_directorProjection); - if (pTarget->getCamera()->getDirty()) + if (pTarget->getCamera()->isDirty()) { const CCPoint& offset = pTarget->getAnchorPointInPoints(); diff --git a/cocos2dx/effects/CCGrid.h b/cocos2dx/effects/CCGrid.h index 422f9ea272..24946cc215 100644 --- a/cocos2dx/effects/CCGrid.h +++ b/cocos2dx/effects/CCGrid.h @@ -64,7 +64,7 @@ public: /** is texture flipped */ inline bool isTextureFlipped(void) { return m_bIsTextureFlipped; } - void setIsTextureFlipped(bool bFlipped); + void setTextureFlipped(bool bFlipped); bool initWithSize(const ccGridSize& gridSize, CCTexture2D *pTexture, bool bFlipped); bool initWithSize(const ccGridSize& gridSize); diff --git a/cocos2dx/extensions/CCBReader/CCLayerLoader.cpp b/cocos2dx/extensions/CCBReader/CCLayerLoader.cpp index f6942ef5af..025708bf01 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCLayerLoader.cpp @@ -14,9 +14,9 @@ CCLayer * CCLayerLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) void CCLayerLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader) { if(strcmp(pPropertyName, PROPERTY_TOUCH_ENABLED) == 0) { - ((CCLayer *)pNode)->setIsTouchEnabled(pCheck); + ((CCLayer *)pNode)->setTouchEnabled(pCheck); } else if(strcmp(pPropertyName, PROPERTY_ACCELEROMETER_ENABLED) == 0) { - ((CCLayer *)pNode)->setIsAccelerometerEnabled(pCheck); + ((CCLayer *)pNode)->setAccelerometerEnabled(pCheck); } else if(strcmp(pPropertyName, PROPERTY_MOUSE_ENABLED) == 0) { // TODO XXX CCLOG("The property '%s' is not supported!", PROPERTY_MOUSE_ENABLED); diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp index 98220ee25f..ffbd3082fa 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp @@ -736,9 +736,9 @@ void CCNodeLoader::onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, co void CCNodeLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader) { if(strcmp(pPropertyName, PROPERTY_VISIBLE) == 0) { - pNode->setIsVisible(pCheck); + pNode->setVisible(pCheck); } else if(strcmp(pPropertyName, PROPERTY_IGNOREANCHORPOINTFORPOSITION) == 0) { - pNode->setIgnoreAnchorPointForPosition(pCheck); + pNode->ignoreAnchorPointForPosition(pCheck); } else { ASSERT_FAIL_UNEXPECTED_PROPERTY(pPropertyName); } diff --git a/cocos2dx/extensions/CCControlExtension/CCControl.cpp b/cocos2dx/extensions/CCControlExtension/CCControl.cpp index 2b07a8d2aa..a11e5598a6 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControl.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControl.cpp @@ -249,7 +249,7 @@ GLubyte CCControl::getOpacity() } -void CCControl::setIsOpacityModifyRGB(bool opacityModifyRGB) +void CCControl::setOpacityModifyRGB(bool opacityModifyRGB) { m_bIsOpacityModifyRGB=opacityModifyRGB; CCObject* child; @@ -259,12 +259,12 @@ void CCControl::setIsOpacityModifyRGB(bool opacityModifyRGB) CCRGBAProtocol* pNode = dynamic_cast(child); if (pNode) { - pNode->setIsOpacityModifyRGB(opacityModifyRGB); + pNode->setOpacityModifyRGB(opacityModifyRGB); } } } -bool CCControl::getIsOpacityModifyRGB() +bool CCControl::isOpacityModifyRGB() { return m_bIsOpacityModifyRGB; } diff --git a/cocos2dx/extensions/CCControlExtension/CCControl.h b/cocos2dx/extensions/CCControlExtension/CCControl.h index 2c905aa6d5..620d29acd8 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControl.h +++ b/cocos2dx/extensions/CCControlExtension/CCControl.h @@ -84,7 +84,9 @@ class CC_DLL CCControl : public CCLayer, public CCRGBAProtocol //CCRGBAProtocol CC_PROPERTY(GLubyte, m_cOpacity, Opacity); CC_PROPERTY_PASS_BY_REF(ccColor3B, m_tColor, Color); - CC_PROPERTY(bool, m_bIsOpacityModifyRGB, IsOpacityModifyRGB); + bool m_bIsOpacityModifyRGB; + bool isOpacityModifyRGB(); + void setOpacityModifyRGB(bool isOpacityModifyRGB); /** Changes the priority of the button. The lower the number, the higher the priority. */ CC_SYNTHESIZE(int, m_nDefaultTouchPriority, DefaultTouchPriority); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp index cf672b89ca..ac3005e8ff 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp @@ -66,7 +66,7 @@ bool CCControlButton::initWithLabelAndBackgroundSprite(CCNode* node, CCScale9Spr CCRGBAProtocol* rgbaLabel = dynamic_cast(node); assert(label != NULL || rgbaLabel!=NULL || backgroundSprite != NULL); - setIsTouchEnabled(true); + setTouchEnabled(true); pushed=false; m_zoomOnTouchDown = true; m_nState=CCControlStateInitial; @@ -81,7 +81,7 @@ bool CCControlButton::initWithLabelAndBackgroundSprite(CCNode* node, CCScale9Spr m_zoomOnTouchDown = true; // Set the default anchor point - setIgnoreAnchorPointForPosition(false); + ignoreAnchorPointForPosition(false); setAnchorPoint(ccp(0.5f, 0.5f)); // Set the nodes @@ -102,7 +102,7 @@ bool CCControlButton::initWithLabelAndBackgroundSprite(CCNode* node, CCScale9Spr // Set the default color and opacity setColor(ccc3(255, 255, 255)); setOpacity(255); - setIsOpacityModifyRGB(true); + setOpacityModifyRGB(true); // Initialize the dispatch table @@ -356,7 +356,7 @@ void CCControlButton::setTitleLabelForState(CCNode* titleLabel, CCControlState s } m_titleLabelDispatchTable->setObject(titleLabel, state); - titleLabel->setIsVisible(false); + titleLabel->setVisible(false); titleLabel->setAnchorPoint(ccp(0.5f, 0.5f)); addChild(titleLabel, 1); @@ -458,7 +458,7 @@ void CCControlButton::setBackgroundSpriteForState(CCScale9Sprite* sprite, CCCont } m_backgroundSpriteDispatchTable->setObject(sprite, state); - sprite->setIsVisible(false); + sprite->setVisible(false); sprite->setAnchorPoint(ccp(0.5f, 0.5f)); addChild(sprite); @@ -484,8 +484,8 @@ void CCControlButton::setBackgroundSpriteFrameForState(CCSpriteFrame * spriteFra void CCControlButton::needsLayout() { // Hide the background and the label - m_titleLabel->setIsVisible(false); - m_backgroundSprite->setIsVisible(false); + m_titleLabel->setVisible(false); + m_backgroundSprite->setVisible(false); // Update anchor of all labels this->setLabelAnchorPoint(this->m_labelAnchorPoint); @@ -545,8 +545,8 @@ void CCControlButton::needsLayout() m_backgroundSprite->setPosition(ccp(getContentSize().width/2, getContentSize().height/2)); // Make visible the background and the label - m_titleLabel->setIsVisible(true); - m_backgroundSprite->setIsVisible(true); + m_titleLabel->setVisible(true); + m_backgroundSprite->setVisible(true); } diff --git a/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp b/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp index c0192c43dd..cd0717c447 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp @@ -39,7 +39,7 @@ bool CCControlColourPicker::init() { if (CCControl::init()) { - setIsTouchEnabled(true); + setTouchEnabled(true); // Cache the sprites CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("extensions/CCControlColourPickerSpriteSheet.plist"); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.cpp b/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.cpp index a2ff8c2d22..e2ea4cf85d 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.cpp @@ -56,7 +56,7 @@ bool CCControlHuePicker::initWithTargetAndPos(CCNode* target, CCPoint pos) { if (CCControl::init()) { - setIsTouchEnabled(true); + setTouchEnabled(true); // Add background and slider sprites m_background=CCControlUtils::addSpriteToTargetWithPosAndAnchor("huePickerBackground.png", target, pos, ccp(0.0f, 0.0f)); m_slider=CCControlUtils::addSpriteToTargetWithPosAndAnchor("colourPicker.png", target, pos, ccp(0.5f, 0.5f)); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp b/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp index 36b998fdcf..c37ee8373d 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp @@ -42,7 +42,7 @@ bool CCControlSaturationBrightnessPicker::initWithTargetAndPos(CCNode* target, C { if (CCControl::init()) { - setIsTouchEnabled(true); + setTouchEnabled(true); // Add background and slider sprites m_background=CCControlUtils::addSpriteToTargetWithPosAndAnchor("colourPickerBackground.png", target, pos, ccp(0.0f, 0.0f)); m_overlay=CCControlUtils::addSpriteToTargetWithPosAndAnchor("colourPickerOverlay.png", target, pos, ccp(0.0f, 0.0f)); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp b/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp index 6f4609f25f..f309d038e2 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp @@ -78,8 +78,8 @@ CCControlSlider* CCControlSlider::create(CCSprite * backgroundSprite, CCSprite* { if (CCControl::init()) { - setIgnoreAnchorPointForPosition(false); - setIsTouchEnabled(true); + ignoreAnchorPointForPosition(false); + setTouchEnabled(true); m_backgroundSprite=backgroundSprite; m_progressSprite=progessSprite; @@ -215,7 +215,7 @@ void CCControlSlider::sliderMoved(CCPoint location) void CCControlSlider::sliderEnded(CCPoint location) { - if (m_thumbItem->getIsSelected()) + if (m_thumbItem->isSelected()) { m_thumbItem->unselected(); setValue(valueForLocation(m_thumbItem->getPosition())); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp index 2e6b1bd030..2260ef67bc 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp @@ -301,7 +301,7 @@ bool CCControlSwitch::initWithMaskSprite(CCSprite *maskSprite, CCSprite * onSpri CCAssert(offSprite, "offSprite must not be nil."); CCAssert(thumbSprite, "thumbSprite must not be nil."); - setIsTouchEnabled(true); + setTouchEnabled(true); m_bOn = true; m_pSwitchSprite = new CCControlSwitchSprite(); @@ -314,7 +314,7 @@ bool CCControlSwitch::initWithMaskSprite(CCSprite *maskSprite, CCSprite * onSpri m_pSwitchSprite->setPosition(ccp (m_pSwitchSprite->getContentSize().width / 2, m_pSwitchSprite->getContentSize().height / 2)); addChild(m_pSwitchSprite); - setIgnoreAnchorPointForPosition(false); + ignoreAnchorPointForPosition(false); setAnchorPoint(ccp (0.5f, 0.5f)); setContentSize(m_pSwitchSprite->getContentSize()); return true; diff --git a/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp b/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp index 6661c3a228..13a3713527 100644 --- a/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp @@ -78,7 +78,7 @@ bool CCMenuPassive::initWithItems(CCNode* item, va_list args) CCSize s = CCDirector::sharedDirector()->getWinSize(); // Set the default anchor point - setIgnoreAnchorPointForPosition(true); + ignoreAnchorPointForPosition(true); setAnchorPoint(ccp(0.5f, 0.5f)); this->setContentSize(s); diff --git a/cocos2dx/extensions/CCControlExtension/CCMenuPassive.h b/cocos2dx/extensions/CCControlExtension/CCMenuPassive.h index 65d95709ac..e4beb6036f 100644 --- a/cocos2dx/extensions/CCControlExtension/CCMenuPassive.h +++ b/cocos2dx/extensions/CCControlExtension/CCMenuPassive.h @@ -72,8 +72,8 @@ public: void alignItemsInRows(unsigned int rows, va_list args); //RGBA protocol - virtual void setIsOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} - virtual bool getIsOpacityModifyRGB(void) { return false;} + virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} + virtual bool isOpacityModifyRGB(void) { return false;} }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp index 97fc0b06dc..13129f0654 100644 --- a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp @@ -570,7 +570,7 @@ void CCScale9Sprite::updateCapInset() this->setCapInsets(insets); } -void CCScale9Sprite::setIsOpacityModifyRGB(bool var) +void CCScale9Sprite::setOpacityModifyRGB(bool var) { m_bIsOpacityModifyRGB = var; if (scale9Image->getChildren() && scale9Image->getChildren()->count() != 0) @@ -581,7 +581,7 @@ void CCScale9Sprite::setIsOpacityModifyRGB(bool var) CCRGBAProtocol* pNode = dynamic_cast(child); if (pNode) { - pNode->setIsOpacityModifyRGB(m_bIsOpacityModifyRGB); + pNode->setOpacityModifyRGB(m_bIsOpacityModifyRGB); } //CCNode* pNode = (CCNode*) child; //if (pNode) @@ -595,7 +595,7 @@ void CCScale9Sprite::setIsOpacityModifyRGB(bool var) } } } -bool CCScale9Sprite::getIsOpacityModifyRGB() +bool CCScale9Sprite::isOpacityModifyRGB() { return m_bIsOpacityModifyRGB; } diff --git a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h index cf34fd83d5..0e1a5a8c93 100644 --- a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h +++ b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h @@ -363,12 +363,12 @@ public: Textures with premultiplied alpha will have this property by default on YES. Otherwise the default value is NO @since v0.8 */ - virtual void setIsOpacityModifyRGB(bool bValue); + virtual void setOpacityModifyRGB(bool bValue); /** returns whether or not the opacity will be applied using glColor(R,G,B,opacity) or glColor(opacity, opacity, opacity, opacity); @since v0.8 */ - virtual bool getIsOpacityModifyRGB(void); + virtual bool isOpacityModifyRGB(void); virtual bool updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect, CCRect capInsets); diff --git a/cocos2dx/extensions/CCListView/CCListView.cpp b/cocos2dx/extensions/CCListView/CCListView.cpp index 4f6afda652..8402fdc00a 100644 --- a/cocos2dx/extensions/CCListView/CCListView.cpp +++ b/cocos2dx/extensions/CCListView/CCListView.cpp @@ -59,7 +59,7 @@ bool CCListView::initWithMode(CCListViewMode mode) { if (CCLayerColor::initWithColor(ccc4(255, 255, 255, 0), 0, 0)) { - setIsTouchEnabled(true); + setTouchEnabled(true); m_nMode = mode; m_layerPanel = CCLayer::create(); this->addChild(m_layerPanel); @@ -962,7 +962,7 @@ int CCListView::rowForTouch(cocos2d::CCTouch *touch) CCARRAY_FOREACH(pChildren, pObject) { CCNode* pChild = (CCNode*) pObject; - if (pChild && pChild->getIsVisible()) + if (pChild && pChild->isVisible()) { CCPoint local = pChild->convertToNodeSpace(touchLocation); CCRect r = CCRectZero; @@ -1869,7 +1869,7 @@ bool CCListView::ccTouchBegan(CCTouch* touch, CCEvent* event) { CC_UNUSED_PARAM(event); - if (!isTouchInside(touch) || !getIsVisible() || !m_bIsEnabled) + if (!isTouchInside(touch) || !isVisible() || !m_bIsEnabled) { return false; } diff --git a/cocos2dx/extensions/CCListView/CCListViewCell.cpp b/cocos2dx/extensions/CCListView/CCListViewCell.cpp index a16864e230..43f15491a7 100644 --- a/cocos2dx/extensions/CCListView/CCListViewCell.cpp +++ b/cocos2dx/extensions/CCListView/CCListViewCell.cpp @@ -42,7 +42,7 @@ CCListViewCell::CCListViewCell(void) :m_nSeparatorStyle(CCListViewCellSeparatorStyleNone) ,m_bIsSelected(false) { - setIsTouchEnabled(true); + setTouchEnabled(true); m_selectionColor = ccc4(0, 0, 255, 255); m_separatorLineColor = ccc3(128, 128, 128); } diff --git a/cocos2dx/include/CCProtocols.h b/cocos2dx/include/CCProtocols.h index 7f6bfee32a..476697a61a 100755 --- a/cocos2dx/include/CCProtocols.h +++ b/cocos2dx/include/CCProtocols.h @@ -63,12 +63,12 @@ public: Textures with premultiplied alpha will have this property by default on YES. Otherwise the default value is NO @since v0.8 */ - virtual void setIsOpacityModifyRGB(bool bValue) = 0; + virtual void setOpacityModifyRGB(bool bValue) = 0; /** returns whether or not the opacity will be applied using glColor(R,G,B,opacity) or glColor(opacity, opacity, opacity, opacity); @since v0.8 */ - virtual bool getIsOpacityModifyRGB(void) = 0; + virtual bool isOpacityModifyRGB(void) = 0; }; /** diff --git a/cocos2dx/label_nodes/CCLabelAtlas.h b/cocos2dx/label_nodes/CCLabelAtlas.h index 17ed42e037..93c7089fd4 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.h +++ b/cocos2dx/label_nodes/CCLabelAtlas.h @@ -85,7 +85,6 @@ public: virtual void draw(); #endif - virtual CCLabelProtocol* convertToLabelProtocol() { return (CCLabelProtocol*)this; } protected: // string to render std::string m_sString; diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index adc0c48eaf..5b46a69768 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -718,9 +718,22 @@ void CCLabelBMFont::purgeCachedData() FNTConfigRemoveCache(); } -CCLabelBMFont * CCLabelBMFont::node() { return CCLabelBMFont::create(); } +CCLabelBMFont * CCLabelBMFont::node() +{ + return CCLabelBMFont::create(); +} -CCLabelBMFont * CCLabelBMFont::create() { CCLabelBMFont * pRet = new CCLabelBMFont(); if (pRet && pRet->init()) { pRet->autorelease(); return pRet; } CC_SAFE_DELETE(pRet); return NULL; } +CCLabelBMFont * CCLabelBMFont::create() +{ + CCLabelBMFont * pRet = new CCLabelBMFont(); + if (pRet && pRet->init()) + { + pRet->autorelease(); + return pRet; + } + CC_SAFE_DELETE(pRet); + return NULL; +} CCLabelBMFont *CCLabelBMFont::labelWithString(const char *str, const char *fntFile, float width/* = kCCLabelAutomaticWidth*/, CCTextAlignment alignment/* = kCCTextAlignmentLeft*/, CCPoint imageOffset/* = CCPointZero*/) { @@ -784,7 +797,7 @@ bool CCLabelBMFont::initWithString(const char *theString, const char *fntFile, f m_cOpacity = 255; m_tColor = ccWHITE; m_tContentSize = CCSizeZero; - m_bIsOpacityModifyRGB = m_pobTextureAtlas->getTexture()->getHasPremultipliedAlpha(); + m_bIsOpacityModifyRGB = m_pobTextureAtlas->getTexture()->hasPremultipliedAlpha(); this->setString(theString); setAnchorPoint(ccp(0.5f, 0.5f)); return true; @@ -913,7 +926,7 @@ void CCLabelBMFont::createFontChars() prev = c; // Apply label properties - fontChar->setIsOpacityModifyRGB(m_bIsOpacityModifyRGB); + fontChar->setOpacityModifyRGB(m_bIsOpacityModifyRGB); // Color MUST be set before opacity, since opacity might change color if OpacityModifyRGB is on fontChar->setColor(m_tColor); @@ -962,7 +975,7 @@ void CCLabelBMFont::updateString(bool fromUpdate) CCNode* pNode = (CCNode*) child; if (pNode) { - pNode->setIsVisible(false); + pNode->setVisible(false); } } } @@ -1028,7 +1041,7 @@ GLubyte CCLabelBMFont::getOpacity() { return m_cOpacity; } -void CCLabelBMFont::setIsOpacityModifyRGB(bool var) +void CCLabelBMFont::setOpacityModifyRGB(bool var) { m_bIsOpacityModifyRGB = var; if (m_pChildren && m_pChildren->count() != 0) @@ -1042,13 +1055,13 @@ void CCLabelBMFont::setIsOpacityModifyRGB(bool var) CCRGBAProtocol *pRGBAProtocol = dynamic_cast(pNode); if (pRGBAProtocol) { - pRGBAProtocol->setIsOpacityModifyRGB(m_bIsOpacityModifyRGB); + pRGBAProtocol->setOpacityModifyRGB(m_bIsOpacityModifyRGB); } } } } } -bool CCLabelBMFont::getIsOpacityModifyRGB() +bool CCLabelBMFont::isOpacityModifyRGB() { return m_bIsOpacityModifyRGB; } @@ -1091,7 +1104,7 @@ void CCLabelBMFont::updateLabel() while (!(characterSprite = (CCSprite*)this->getChildByTag(j + skip))) skip++; - if (!characterSprite->getIsVisible()) continue; + if (!characterSprite->isVisible()) continue; if (i >= stringLength) break; @@ -1339,30 +1352,30 @@ float CCLabelBMFont::getLetterPosXRight( CCSprite* sp ) return sp->getPosition().x * m_fScaleX + (sp->getContentSize().width * m_fScaleX * sp->getAnchorPoint().x); } -// LabelBMFont - FntFile -void CCLabelBMFont::setFntFile(const char* fntFile) -{ - if (fntFile != NULL && strcmp(fntFile, m_sFntFile.c_str()) != 0 ) - { - CCBMFontConfiguration *newConf = FNTConfigLoadFile(fntFile); - - CCAssert( newConf, "CCLabelBMFont: Impossible to create font. Please check file"); - - m_sFntFile = fntFile; - - CC_SAFE_RELEASE(m_pConfiguration); - CC_SAFE_RETAIN(newConf); - m_pConfiguration = newConf; - - this->setTexture(CCTextureCache::sharedTextureCache()->addImage(m_pConfiguration->getAtlasName())); - this->createFontChars(); - } -} - -const char* CCLabelBMFont::getFntFile() -{ - return m_sFntFile.c_str(); -} +// LabelBMFont - FntFile +void CCLabelBMFont::setFntFile(const char* fntFile) +{ + if (fntFile != NULL && strcmp(fntFile, m_sFntFile.c_str()) != 0 ) + { + CCBMFontConfiguration *newConf = FNTConfigLoadFile(fntFile); + + CCAssert( newConf, "CCLabelBMFont: Impossible to create font. Please check file"); + + m_sFntFile = fntFile; + + CC_SAFE_RELEASE(m_pConfiguration); + CC_SAFE_RETAIN(newConf); + m_pConfiguration = newConf; + + this->setTexture(CCTextureCache::sharedTextureCache()->addImage(m_pConfiguration->getAtlasName())); + this->createFontChars(); + } +} + +const char* CCLabelBMFont::getFntFile() +{ + return m_sFntFile.c_str(); +} //LabelBMFont - Debug draw diff --git a/cocos2dx/label_nodes/CCLabelBMFont.h b/cocos2dx/label_nodes/CCLabelBMFont.h index b0e0f5eb1d..667271fd89 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.h +++ b/cocos2dx/label_nodes/CCLabelBMFont.h @@ -164,7 +164,9 @@ class CC_DLL CCLabelBMFont : public CCSpriteBatchNode, public CCLabelProtocol, p /** conforms to CCRGBAProtocol protocol */ CC_PROPERTY_PASS_BY_REF(ccColor3B, m_tColor, Color) /** conforms to CCRGBAProtocol protocol */ - CC_PROPERTY(bool, m_bIsOpacityModifyRGB, IsOpacityModifyRGB) + bool m_bIsOpacityModifyRGB; + bool isOpacityModifyRGB(); + void setOpacityModifyRGB(bool isOpacityModifyRGB); protected: // string to render unsigned short* m_sString; diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index 07191e751c..3889bd96a6 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -144,12 +144,12 @@ int CCLayer::excuteScriptTouchHandler(int nEventType, CCSet *pTouches) } /// isTouchEnabled getter -bool CCLayer::getIsTouchEnabled() +bool CCLayer::isTouchEnabled() { return m_bIsTouchEnabled; } /// isTouchEnabled setter -void CCLayer::setIsTouchEnabled(bool enabled) +void CCLayer::setTouchEnabled(bool enabled) { if (m_bIsTouchEnabled != enabled) { @@ -171,12 +171,12 @@ void CCLayer::setIsTouchEnabled(bool enabled) } /// isAccelerometerEnabled getter -bool CCLayer::getIsAccelerometerEnabled() +bool CCLayer::isAccelerometerEnabled() { return m_bIsAccelerometerEnabled; } /// isAccelerometerEnabled setter -void CCLayer::setIsAccelerometerEnabled(bool enabled) +void CCLayer::setAccelerometerEnabled(bool enabled) { if (enabled != m_bIsAccelerometerEnabled) { @@ -198,12 +198,12 @@ void CCLayer::setIsAccelerometerEnabled(bool enabled) } /// isKeypadEnabled getter -bool CCLayer::getIsKeypadEnabled() +bool CCLayer::isKeypadEnabled() { return m_bIsKeypadEnabled; } /// isKeypadEnabled setter -void CCLayer::setIsKeypadEnabled(bool enabled) +void CCLayer::setKeypadEnabled(bool enabled) { if (enabled != m_bIsKeypadEnabled) { diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h index 645d01eaf7..6e596864ed 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h @@ -99,17 +99,25 @@ public: Only the touches of this node will be affected. This "method" is not propagated to it's children. @since v0.8.1 */ - CC_PROPERTY(bool, m_bIsTouchEnabled, IsTouchEnabled) + bool isTouchEnabled(); + void setTouchEnabled(bool value); /** whether or not it will receive Accelerometer events You can enable / disable accelerometer events with this property. @since v0.8.1 */ - CC_PROPERTY(bool, m_bIsAccelerometerEnabled, IsAccelerometerEnabled) + bool isAccelerometerEnabled(); + void setAccelerometerEnabled(bool value); /** whether or not it will receive keypad events You can enable / disable accelerometer events with this property. it's new in cocos2d-x */ - CC_PROPERTY(bool, m_bIsKeypadEnabled, IsKeypadEnabled) + bool isKeypadEnabled(); + void setKeypadEnabled(bool value); + +protected: + bool m_bIsTouchEnabled; + bool m_bIsAccelerometerEnabled; + bool m_bIsKeypadEnabled; private: // Script touch events handler @@ -250,8 +258,8 @@ public: /** BlendFunction. Conforms to CCBlendProtocol protocol */ CC_PROPERTY(ccBlendFunc, m_tBlendFunc, BlendFunc) - virtual void setIsOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} - virtual bool getIsOpacityModifyRGB(void) { return false;} + virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} + virtual bool isOpacityModifyRGB(void) { return false;} //@warning: This interface will be deprecated in future. LAYER_CREATE_FUNC(CCLayerColor) LAYER_NODE_FUNC(CCLayerColor) diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp index 8c2d266717..c22ff9d45d 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp @@ -123,13 +123,13 @@ void CCTransitionScene::draw() void CCTransitionScene::finish() { // clean up - m_pInScene->setIsVisible(true); + m_pInScene->setVisible(true); m_pInScene->setPosition(ccp(0,0)); m_pInScene->setScale(1.0f); m_pInScene->setRotation(0.0f); m_pInScene->getCamera()->restore(); - m_pOutScene->setIsVisible(false); + m_pOutScene->setVisible(false); m_pOutScene->setPosition(ccp(0,0)); m_pOutScene->setScale(1.0f); m_pOutScene->setRotation(0.0f); @@ -154,13 +154,13 @@ void CCTransitionScene::setNewScene(float dt) // enable events while transitions director->getTouchDispatcher()->setDispatchEvents(true); // issue #267 - m_pOutScene->setIsVisible(true); + m_pOutScene->setVisible(true); } void CCTransitionScene::hideOutShowIn() { - m_pInScene->setIsVisible(true); - m_pOutScene->setIsVisible(false); + m_pInScene->setVisible(true); + m_pOutScene->setVisible(false); } @@ -607,7 +607,7 @@ void CCTransitionFlipX::onEnter() CCTransitionSceneOriented::onEnter(); CCActionInterval *inA, *outA; - m_pInScene->setIsVisible(false); + m_pInScene->setVisible(false); float inDeltaZ, inAngleZ; float outDeltaZ, outAngleZ; @@ -677,7 +677,7 @@ void CCTransitionFlipY::onEnter() CCTransitionSceneOriented::onEnter(); CCActionInterval *inA, *outA; - m_pInScene->setIsVisible(false); + m_pInScene->setVisible(false); float inDeltaZ, inAngleZ; float outDeltaZ, outAngleZ; @@ -748,7 +748,7 @@ void CCTransitionFlipAngular::onEnter() CCTransitionSceneOriented::onEnter(); CCActionInterval *inA, *outA; - m_pInScene->setIsVisible(false); + m_pInScene->setVisible(false); float inDeltaZ, inAngleZ; float outDeltaZ, outAngleZ; @@ -817,7 +817,7 @@ void CCTransitionZoomFlipX::onEnter() CCTransitionSceneOriented::onEnter(); CCActionInterval *inA, *outA; - m_pInScene->setIsVisible(false); + m_pInScene->setVisible(false); float inDeltaZ, inAngleZ; float outDeltaZ, outAngleZ; @@ -896,7 +896,7 @@ void CCTransitionZoomFlipY::onEnter() CCTransitionSceneOriented::onEnter(); CCActionInterval *inA, *outA; - m_pInScene->setIsVisible(false); + m_pInScene->setVisible(false); float inDeltaZ, inAngleZ; float outDeltaZ, outAngleZ; @@ -975,7 +975,7 @@ void CCTransitionZoomFlipAngular::onEnter() CCTransitionSceneOriented::onEnter(); CCActionInterval *inA, *outA; - m_pInScene->setIsVisible(false); + m_pInScene->setVisible(false); float inDeltaZ, inAngleZ; float outDeltaZ, outAngleZ; @@ -1086,7 +1086,7 @@ void CCTransitionFade :: onEnter() CCTransitionScene::onEnter(); CCLayerColor* l = CCLayerColor::create(m_tColor); - m_pInScene->setIsVisible(false); + m_pInScene->setVisible(false); addChild(l, 2, kSceneFade); CCNode* f = getChildByTag(kSceneFade); @@ -1264,7 +1264,7 @@ CCTransitionSplitCols::~CCTransitionSplitCols() void CCTransitionSplitCols::onEnter() { CCTransitionScene::onEnter(); - m_pInScene->setIsVisible(false); + m_pInScene->setVisible(false); CCActionInterval* split = action(); CCActionInterval* seq = (CCActionInterval*)CCSequence::create diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp index ac6ec99b1f..d39178f438 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp @@ -106,7 +106,7 @@ void CCTransitionPageTurn::onEnter() else { // to prevent initial flicker - m_pInScene->setIsVisible(false); + m_pInScene->setVisible(false); m_pInScene->runAction ( CCSequence::create diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp index 8afb04835b..0b6f6c870c 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp @@ -41,9 +41,9 @@ enum { }; CCTransitionProgress::CCTransitionProgress() -: to_(0.0f) -, from_(0.0f) -, sceneToBeModified_(NULL) +: m_fTo(0.0f) +, m_fFrom(0.0f) +, m_pSceneToBeModified(NULL) { } @@ -68,12 +68,12 @@ void CCTransitionProgress::onEnter() // render outScene to its texturebuffer texture->clear(0, 0, 0, 1); texture->begin(); - sceneToBeModified_->visit(); + m_pSceneToBeModified->visit(); texture->end(); // Since we've passed the outScene to the texture we don't need it. - if( sceneToBeModified_ == m_pOutScene ) + if (m_pSceneToBeModified == m_pOutScene) { hideOutShowIn(); } @@ -82,7 +82,7 @@ void CCTransitionProgress::onEnter() // create the blend action CCActionInterval* layerAction = (CCActionInterval*)CCSequence::create( - CCProgressFromTo::create(m_fDuration, from_, to_), + CCProgressFromTo::create(m_fDuration, m_fFrom, m_fTo), CCCallFunc::create(this, callfunc_selector(CCTransitionProgress::finish)), NULL); // run the blend action @@ -107,9 +107,9 @@ void CCTransitionProgress::sceneOrder() void CCTransitionProgress::setupTransition() { - sceneToBeModified_ = m_pOutScene; - from_ = 100; - to_ = 0; + m_pSceneToBeModified = m_pOutScene; + m_fFrom = 100; + m_fTo = 0; } CCProgressTimer* CCTransitionProgress::progressTimerNodeWithRenderTexture(CCRenderTexture* texture) @@ -132,7 +132,7 @@ CCProgressTimer* CCTransitionProgressRadialCCW::progressTimerNodeWithRenderTextu pNode->setType(kCCProgressTimerTypeRadial); // Return the radial type that we want to use - pNode->setIsReverseDirection(false); + pNode->setReverseDirection(false); pNode->setPercentage(100); pNode->setPosition(ccp(size.width/2, size.height/2)); pNode->setAnchorPoint(ccp(0.5f,0.5f)); @@ -153,7 +153,7 @@ CCProgressTimer* CCTransitionProgressRadialCW::progressTimerNodeWithRenderTextur pNode->setType( kCCProgressTimerTypeRadial ); // Return the radial type that we want to use - pNode->setIsReverseDirection(true); + pNode->setReverseDirection(true); pNode->setPercentage(100); pNode->setPosition(ccp(size.width/2, size.height/2)); pNode->setAnchorPoint(ccp(0.5f,0.5f)); @@ -215,9 +215,9 @@ void CCTransitionProgressInOut::sceneOrder() void CCTransitionProgressInOut::setupTransition() { - sceneToBeModified_ = m_pInScene; - from_ = 0; - to_ = 100; + m_pSceneToBeModified = m_pInScene; + m_fFrom = 0; + m_fTo = 100; } CCProgressTimer* CCTransitionProgressInOut::progressTimerNodeWithRenderTexture(CCRenderTexture* texture) diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.h b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.h index 060b11dbf8..df8c990dab 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.h @@ -46,9 +46,9 @@ protected: virtual CCProgressTimer* progressTimerNodeWithRenderTexture(CCRenderTexture* texture); virtual void setupTransition(); virtual void sceneOrder(); - float to_; - float from_; - CCScene* sceneToBeModified_; + float m_fTo; + float m_fFrom; + CCScene* m_pSceneToBeModified; }; diff --git a/cocos2dx/menu_nodes/CCMenu.cpp b/cocos2dx/menu_nodes/CCMenu.cpp index f40c026ee7..7bd15a97c5 100644 --- a/cocos2dx/menu_nodes/CCMenu.cpp +++ b/cocos2dx/menu_nodes/CCMenu.cpp @@ -144,13 +144,13 @@ bool CCMenu::initWithArray(CCArray* pArrayOfItems) { if (CCLayer::init()) { - setIsTouchEnabled(true); + setTouchEnabled(true); m_bEnabled = true; // menu in the center of the screen CCSize s = CCDirector::sharedDirector()->getWinSize(); - this->setIgnoreAnchorPointForPosition(true); + this->ignoreAnchorPointForPosition(true); setAnchorPoint(ccp(0.5f, 0.5f)); this->setContentSize(s); @@ -231,7 +231,7 @@ bool CCMenu::ccTouchBegan(CCTouch* touch, CCEvent* event) for (CCNode *c = this->m_pParent; c != NULL; c = c->getParent()) { - if (c->getIsVisible() == false) + if (c->isVisible() == false) { return false; } @@ -654,7 +654,7 @@ CCMenuItem* CCMenu::itemForTouch(CCTouch *touch) CCARRAY_FOREACH(m_pChildren, pObject) { CCNode* pChild = dynamic_cast(pObject); - if (pChild && pChild->getIsVisible() && ((CCMenuItem*)pChild)->getIsEnabled()) + if (pChild && pChild->isVisible() && ((CCMenuItem*)pChild)->isEnabled()) { CCPoint local = pChild->convertToNodeSpace(touchLocation); CCRect r = ((CCMenuItem*)pChild)->rect(); @@ -666,7 +666,6 @@ CCMenuItem* CCMenu::itemForTouch(CCTouch *touch) } } } - } return NULL; diff --git a/cocos2dx/menu_nodes/CCMenu.h b/cocos2dx/menu_nodes/CCMenu.h index 5d0a4c2e4f..77b5833338 100644 --- a/cocos2dx/menu_nodes/CCMenu.h +++ b/cocos2dx/menu_nodes/CCMenu.h @@ -54,7 +54,8 @@ class CC_DLL CCMenu : public CCLayer, public CCRGBAProtocol /** Opacity: conforms with CCRGBAProtocol protocol */ CC_PROPERTY(GLubyte, m_cOpacity, Opacity); /** whether or not the menu will receive events */ - CC_SYNTHESIZE(bool, m_bEnabled, Enabled); + bool m_bEnabled; + public: CCMenu() : m_cOpacity(0) @@ -153,8 +154,11 @@ public: */ virtual void onExit(); - virtual void setIsOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} - virtual bool getIsOpacityModifyRGB(void) { return false;} + virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} + virtual bool isOpacityModifyRGB(void) { return false;} + + virtual bool isEnabled() { return m_bEnabled; } + virtual void setEnabled(bool value) { m_bEnabled = value; }; protected: CCMenuItem* itemForTouch(CCTouch * touch); diff --git a/cocos2dx/menu_nodes/CCMenuItem.cpp b/cocos2dx/menu_nodes/CCMenuItem.cpp index 5765cf5bc7..54618528be 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.cpp +++ b/cocos2dx/menu_nodes/CCMenuItem.cpp @@ -124,7 +124,7 @@ void CCMenuItem::setIsEnabled(bool enabled) m_bIsEnabled = enabled; } -bool CCMenuItem::getIsEnabled() +bool CCMenuItem::isEnabled() { return m_bIsEnabled; } @@ -136,7 +136,7 @@ CCRect CCMenuItem::rect() m_tContentSize.width, m_tContentSize.height); } -bool CCMenuItem::getIsSelected() +bool CCMenuItem::isSelected() { return m_bIsSelected; } @@ -624,17 +624,17 @@ void CCMenuItemSprite::selected() { if (m_pDisabledImage) { - m_pDisabledImage->setIsVisible(false); + m_pDisabledImage->setVisible(false); } if (m_pSelectedImage) { - m_pNormalImage->setIsVisible(false); - m_pSelectedImage->setIsVisible(true); + m_pNormalImage->setVisible(false); + m_pSelectedImage->setVisible(true); } else { - m_pNormalImage->setIsVisible(true); + m_pNormalImage->setVisible(true); } } } @@ -644,26 +644,26 @@ void CCMenuItemSprite::unselected() CCMenuItem::unselected(); if (m_pNormalImage) { - m_pNormalImage->setIsVisible(true); + m_pNormalImage->setVisible(true); if (m_pSelectedImage) { - m_pSelectedImage->setIsVisible(false); + m_pSelectedImage->setVisible(false); } if (m_pDisabledImage) { - m_pDisabledImage->setIsVisible(false); + m_pDisabledImage->setVisible(false); } } } void CCMenuItemSprite::setIsEnabled(bool bEnabled) { - if( m_bIsEnabled != bEnabled ) - { - CCMenuItem::setIsEnabled(bEnabled); - this->updateImagesVisibility(); + if( m_bIsEnabled != bEnabled ) + { + CCMenuItem::setIsEnabled(bEnabled); + this->updateImagesVisibility(); } } @@ -672,23 +672,23 @@ void CCMenuItemSprite::updateImagesVisibility() { if (m_bIsEnabled) { - if (m_pNormalImage) m_pNormalImage->setIsVisible(true); - if (m_pSelectedImage) m_pSelectedImage->setIsVisible(false); - if (m_pDisabledImage) m_pDisabledImage->setIsVisible(false); + if (m_pNormalImage) m_pNormalImage->setVisible(true); + if (m_pSelectedImage) m_pSelectedImage->setVisible(false); + if (m_pDisabledImage) m_pDisabledImage->setVisible(false); } else { if (m_pDisabledImage) { - if (m_pNormalImage) m_pNormalImage->setIsVisible(false); - if (m_pSelectedImage) m_pSelectedImage->setIsVisible(false); - if (m_pDisabledImage) m_pDisabledImage->setIsVisible(true); + if (m_pNormalImage) m_pNormalImage->setVisible(false); + if (m_pSelectedImage) m_pSelectedImage->setVisible(false); + if (m_pDisabledImage) m_pDisabledImage->setVisible(true); } else { - if (m_pNormalImage) m_pNormalImage->setIsVisible(true); - if (m_pSelectedImage) m_pSelectedImage->setIsVisible(false); - if (m_pDisabledImage) m_pDisabledImage->setIsVisible(false); + if (m_pNormalImage) m_pNormalImage->setVisible(true); + if (m_pSelectedImage) m_pSelectedImage->setVisible(false); + if (m_pDisabledImage) m_pDisabledImage->setVisible(false); } } } diff --git a/cocos2dx/menu_nodes/CCMenuItem.h b/cocos2dx/menu_nodes/CCMenuItem.h index 726e012095..7a947b7f9f 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.h +++ b/cocos2dx/menu_nodes/CCMenuItem.h @@ -45,11 +45,12 @@ class CCSpriteFrame; */ class CC_DLL CCMenuItem : public CCNode { +protected: /** whether or not the item is selected @since v0.8.2 */ - CC_PROPERTY_READONLY(bool, m_bIsSelected, IsSelected); - CC_PROPERTY(bool, m_bIsEnabled, IsEnabled); + bool m_bIsEnabled; + bool m_bIsSelected; public: CCMenuItem() : m_bIsSelected(false) @@ -80,6 +81,10 @@ public: virtual void registerScriptHandler(int nHandler); virtual void unregisterScriptHandler(void); + bool isEnabled(); + void setIsEnabled(bool value); + bool isSelected(); + /** set the target/selector of the menu item*/ void setTarget(CCObject *rec, SEL_MenuHandler selector); protected: @@ -138,8 +143,8 @@ public: virtual void setColor(const ccColor3B& color); virtual const ccColor3B& getColor(); - virtual void setIsOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} - virtual bool getIsOpacityModifyRGB(void) { return false;} + virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} + virtual bool isOpacityModifyRGB(void) { return false;} protected: ccColor3B m_tColorBackup; float m_fOriginalScale; @@ -284,8 +289,8 @@ public: virtual void unselected(); virtual void setIsEnabled(bool bEnabled); - virtual void setIsOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} - virtual bool getIsOpacityModifyRGB(void) { return false;} + virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} + virtual bool isOpacityModifyRGB(void) { return false;} protected: virtual void updateImagesVisibility(); }; @@ -405,8 +410,8 @@ public: virtual void unselected(); virtual void setIsEnabled(bool var); - virtual void setIsOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} - virtual bool getIsOpacityModifyRGB(void) { return false;} + virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} + virtual bool isOpacityModifyRGB(void) { return false;} }; NS_CC_END diff --git a/cocos2dx/misc_nodes/CCMotionStreak.cpp b/cocos2dx/misc_nodes/CCMotionStreak.cpp index 881989dd8c..35eaaafbfb 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.cpp +++ b/cocos2dx/misc_nodes/CCMotionStreak.cpp @@ -114,7 +114,7 @@ bool CCMotionStreak::initWithFade(float fade, float minSeg, float stroke, ccColo { CCNode::setPosition(CCPointZero); setAnchorPoint(CCPointZero); - setIgnoreAnchorPointForPosition(true); + ignoreAnchorPointForPosition(true); m_bStartingPositionInitialized = false; m_tPositionR = CCPointZero; @@ -211,12 +211,12 @@ GLubyte CCMotionStreak::getOpacity(void) return 0; } -void CCMotionStreak::setIsOpacityModifyRGB(bool bValue) +void CCMotionStreak::setOpacityModifyRGB(bool bValue) { CC_UNUSED_PARAM(bValue); } -bool CCMotionStreak::getIsOpacityModifyRGB(void) +bool CCMotionStreak::isOpacityModifyRGB(void) { return false; } diff --git a/cocos2dx/misc_nodes/CCMotionStreak.h b/cocos2dx/misc_nodes/CCMotionStreak.h index 4253408b8c..e66ed3ade9 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.h +++ b/cocos2dx/misc_nodes/CCMotionStreak.h @@ -80,8 +80,8 @@ public: virtual const ccColor3B& getColor(void); virtual GLubyte getOpacity(void); virtual void setOpacity(GLubyte opacity); - virtual void setIsOpacityModifyRGB(bool bValue); - virtual bool getIsOpacityModifyRGB(void); + virtual void setOpacityModifyRGB(bool bValue); + virtual bool isOpacityModifyRGB(void); /** When fast mode is enbled, new points are added faster but with lower precision */ CC_SYNTHESIZE(bool, m_bFastMode, IsFastMode); diff --git a/cocos2dx/misc_nodes/CCProgressTimer.cpp b/cocos2dx/misc_nodes/CCProgressTimer.cpp index 63a92d60c1..d53063cc42 100644 --- a/cocos2dx/misc_nodes/CCProgressTimer.cpp +++ b/cocos2dx/misc_nodes/CCProgressTimer.cpp @@ -176,12 +176,12 @@ GLubyte CCProgressTimer::getOpacity(void) return m_pSprite->getOpacity(); } -void CCProgressTimer::setIsOpacityModifyRGB(bool bValue) +void CCProgressTimer::setOpacityModifyRGB(bool bValue) { CC_UNUSED_PARAM(bValue); } -bool CCProgressTimer::getIsOpacityModifyRGB(void) +bool CCProgressTimer::isOpacityModifyRGB(void) { return false; } diff --git a/cocos2dx/misc_nodes/CCProgressTimer.h b/cocos2dx/misc_nodes/CCProgressTimer.h index a0f1171e83..263dcfaa76 100644 --- a/cocos2dx/misc_nodes/CCProgressTimer.h +++ b/cocos2dx/misc_nodes/CCProgressTimer.h @@ -75,8 +75,11 @@ public: virtual const ccColor3B& getColor(void); virtual GLubyte getOpacity(void); virtual void setOpacity(GLubyte opacity); - virtual void setIsOpacityModifyRGB(bool bValue); - virtual bool getIsOpacityModifyRGB(void); + virtual void setOpacityModifyRGB(bool bValue); + virtual bool isOpacityModifyRGB(void); + + inline bool isReverseDirection() { return m_bReverseDirection; }; + inline void setReverseDirection(bool value) { m_bReverseDirection = value; }; public: /** Creates a progress timer with the sprite as the shape the timer goes through @@ -121,7 +124,7 @@ protected: */ CC_SYNTHESIZE(CCPoint, m_tBarChangeRate, BarChangeRate); - CC_SYNTHESIZE(bool ,m_bReverseDirection, IsReverseDirection); + bool m_bReverseDirection; }; NS_CC_END diff --git a/cocos2dx/misc_nodes/CCRenderTexture.cpp b/cocos2dx/misc_nodes/CCRenderTexture.cpp index bedc7b8362..3b167fabdd 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.cpp +++ b/cocos2dx/misc_nodes/CCRenderTexture.cpp @@ -179,7 +179,7 @@ bool CCRenderTexture::initWithWidthAndHeight(int w, int h, CCTexture2DPixelForma unsigned int powW = 0; unsigned int powH = 0; - if( CCConfiguration::sharedConfiguration()->isSupportsNPOT() ) { + if( CCConfiguration::sharedConfiguration()->supportsNPOT() ) { powW = w; powH = h; } else { diff --git a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp index 5ee0f4eb54..dabedb6f10 100644 --- a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp +++ b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp @@ -493,7 +493,7 @@ void CCParticleBatchNode::updateAllAtlasIndexes() void CCParticleBatchNode::updateBlendFunc(void) { - if( ! m_pTextureAtlas->getTexture()->getHasPremultipliedAlpha()) { + if( ! m_pTextureAtlas->getTexture()->hasPremultipliedAlpha()) { m_tBlendFunc.src = GL_SRC_ALPHA; m_tBlendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; } @@ -504,7 +504,7 @@ void CCParticleBatchNode::setTexture(CCTexture2D* texture) m_pTextureAtlas->setTexture(texture); // If the new texture has No premultiplied alpha, AND the blendFunc hasn't been changed, then update it - if( texture && ! texture->getHasPremultipliedAlpha() && ( m_tBlendFunc.src == CC_BLEND_SRC && m_tBlendFunc.dst == CC_BLEND_DST ) ) + if( texture && ! texture->hasPremultipliedAlpha() && ( m_tBlendFunc.src == CC_BLEND_SRC && m_tBlendFunc.dst == CC_BLEND_DST ) ) { m_tBlendFunc.src = GL_SRC_ALPHA; m_tBlendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; diff --git a/cocos2dx/particle_nodes/CCParticleExamples.cpp b/cocos2dx/particle_nodes/CCParticleExamples.cpp index af96a3ed65..c9603fef91 100644 --- a/cocos2dx/particle_nodes/CCParticleExamples.cpp +++ b/cocos2dx/particle_nodes/CCParticleExamples.cpp @@ -94,7 +94,7 @@ bool CCParticleFire::initWithTotalParticles(unsigned int numberOfParticles) m_tEndColorVar.a = 0.0f; // additive - this->setIsBlendAdditive(true); + this->setBlendAdditive(true); return true; } return false; @@ -162,7 +162,7 @@ bool CCParticleFireworks::initWithTotalParticles(unsigned int numberOfParticles) m_fEndSize = kCCParticleStartSizeEqualToEndSize; // additive - this->setIsBlendAdditive(false); + this->setBlendAdditive(false); return true; } return false; @@ -175,7 +175,7 @@ bool CCParticleSun::initWithTotalParticles(unsigned int numberOfParticles) if( CCParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // additive - this->setIsBlendAdditive(true); + this->setBlendAdditive(true); // duration m_fDuration = kCCParticleDurationInfinity; @@ -307,7 +307,7 @@ bool CCParticleGalaxy::initWithTotalParticles(unsigned int numberOfParticles) m_tEndColorVar.a = 0.0f; // additive - this->setIsBlendAdditive(true); + this->setBlendAdditive(true); return true; } return false; @@ -381,7 +381,7 @@ bool CCParticleFlower::initWithTotalParticles(unsigned int numberOfParticles) m_tEndColorVar.a = 0.0f; // additive - this->setIsBlendAdditive(true); + this->setBlendAdditive(true); return true; } return false; @@ -454,7 +454,7 @@ bool CCParticleMeteor::initWithTotalParticles(unsigned int numberOfParticles) m_tEndColorVar.a = 0.0f; // additive - this->setIsBlendAdditive(true); + this->setBlendAdditive(true); return true; } return false; @@ -528,7 +528,7 @@ bool CCParticleSpiral::initWithTotalParticles(unsigned int numberOfParticles) m_tEndColorVar.a = 0.0f; // additive - this->setIsBlendAdditive(false); + this->setBlendAdditive(false); return true; } return false; @@ -601,7 +601,7 @@ bool CCParticleExplosion::initWithTotalParticles(unsigned int numberOfParticles) m_tEndColorVar.a = 0.0f; // additive - this->setIsBlendAdditive(false); + this->setBlendAdditive(false); return true; } return false; @@ -671,7 +671,7 @@ bool CCParticleSmoke::initWithTotalParticles(unsigned int numberOfParticles) m_tEndColorVar.a = 0.0f; // additive - this->setIsBlendAdditive(false); + this->setBlendAdditive(false); return true; } return false; @@ -744,7 +744,7 @@ bool CCParticleSnow::initWithTotalParticles(unsigned int numberOfParticles) m_tEndColorVar.a = 0.0f; // additive - this->setIsBlendAdditive(false); + this->setBlendAdditive(false); return true; } return false; @@ -817,7 +817,7 @@ bool CCParticleRain::initWithTotalParticles(unsigned int numberOfParticles) m_tEndColorVar.a = 0.0f; // additive - this->setIsBlendAdditive(false); + this->setBlendAdditive(false); return true; } return false; diff --git a/cocos2dx/particle_nodes/CCParticleSystem.cpp b/cocos2dx/particle_nodes/CCParticleSystem.cpp index 69d68b6295..53c66cb460 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystem.cpp @@ -748,7 +748,7 @@ void CCParticleSystem::updateBlendFunc() if(m_pTexture) { - bool premultiplied = m_pTexture->getHasPremultipliedAlpha(); + bool premultiplied = m_pTexture->hasPremultipliedAlpha(); m_bOpacityModifyRGB = false; @@ -773,7 +773,7 @@ CCTexture2D * CCParticleSystem::getTexture() } // ParticleSystem - Additive Blending -void CCParticleSystem::setIsBlendAdditive(bool additive) +void CCParticleSystem::setBlendAdditive(bool additive) { if( additive ) { @@ -782,7 +782,7 @@ void CCParticleSystem::setIsBlendAdditive(bool additive) } else { - if( m_pTexture && ! m_pTexture->getHasPremultipliedAlpha() ) + if( m_pTexture && ! m_pTexture->hasPremultipliedAlpha() ) { m_tBlendFunc.src = GL_SRC_ALPHA; m_tBlendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; @@ -795,7 +795,7 @@ void CCParticleSystem::setIsBlendAdditive(bool additive) } } -bool CCParticleSystem::getIsBlendAdditive() +bool CCParticleSystem::isBlendAdditive() { return( m_tBlendFunc.src == GL_SRC_ALPHA && m_tBlendFunc.dst == GL_ONE); } @@ -958,7 +958,7 @@ float CCParticleSystem::getRotatePerSecondVar() return modeB.rotatePerSecondVar; } -bool CCParticleSystem::getIsActive() +bool CCParticleSystem::isActive() { return m_bIsActive; } diff --git a/cocos2dx/particle_nodes/CCParticleSystem.h b/cocos2dx/particle_nodes/CCParticleSystem.h index 61ab337c77..cdbe7bd227 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.h +++ b/cocos2dx/particle_nodes/CCParticleSystem.h @@ -237,7 +237,7 @@ protected: unsigned int m_uAllocatedParticles; /** Is the emitter active */ - CC_PROPERTY_READONLY(bool, m_bIsActive, IsActive) + bool m_bIsActive; /** Quantity of particles that are being simulated at the moment */ CC_PROPERTY_READONLY(unsigned int, m_uParticleCount, ParticleCount) /** How many seconds the emitter wil run. -1 means 'forever' */ @@ -290,6 +290,10 @@ public: virtual void setRotation(float newRotation); virtual void setScaleX(float newScaleX); virtual void setScaleY(float newScaleY); + + virtual bool isActive(); + virtual bool isBlendAdditive(); + virtual void setBlendAdditive(bool value); ////////////////////////////////////////////////////////////////////////// /** start size in pixels of each particle */ @@ -334,7 +338,7 @@ public: dest blend function = GL_ONE; @endcode */ - CC_PROPERTY(bool, m_bIsBlendAdditive, IsBlendAdditive) + bool m_bIsBlendAdditive; /** particles movement type: Free or Grouped @since v0.8 */ diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index 930726ce15..f1ffd31921 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -852,15 +852,15 @@ void CCSprite::setAnchorPoint(const CCPoint& anchor) SET_DIRTY_RECURSIVELY(); } -void CCSprite::setIgnoreAnchorPointForPosition(bool value) +void CCSprite::ignoreAnchorPointForPosition(bool value) { CCAssert(! m_pobBatchNode, "ignoreAnchorPointForPosition is invalid in CCSprite"); - CCNode::setIgnoreAnchorPointForPosition(value); + CCNode::ignoreAnchorPointForPosition(value); } void CCSprite::setIsVisible(bool bVisible) { - CCNode::setIsVisible(bVisible); + CCNode::setVisible(bVisible); SET_DIRTY_RECURSIVELY(); } @@ -966,14 +966,14 @@ void CCSprite::setColor(const ccColor3B& color3) updateColor(); } -void CCSprite::setIsOpacityModifyRGB(bool bValue) +void CCSprite::setOpacityModifyRGB(bool bValue) { ccColor3B oldColor = m_sColor; m_bOpacityModifyRGB = bValue; m_sColor = oldColor; } -bool CCSprite::getIsOpacityModifyRGB(void) +bool CCSprite::isOpacityModifyRGB(void) { return m_bOpacityModifyRGB; } @@ -1070,17 +1070,17 @@ void CCSprite::updateBlendFunc(void) CCAssert (! m_pobBatchNode, "CCSprite: updateBlendFunc doesn't work when the sprite is rendered using a CCSpriteSheet"); // it is possible to have an untextured sprite - if (! m_pobTexture || ! m_pobTexture->getHasPremultipliedAlpha()) + if (! m_pobTexture || ! m_pobTexture->hasPremultipliedAlpha()) { m_sBlendFunc.src = GL_SRC_ALPHA; m_sBlendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; - setIsOpacityModifyRGB(false); + setOpacityModifyRGB(false); } else { m_sBlendFunc.src = CC_BLEND_SRC; m_sBlendFunc.dst = CC_BLEND_DST; - setIsOpacityModifyRGB(true); + setOpacityModifyRGB(true); } } diff --git a/cocos2dx/sprite_nodes/CCSprite.h b/cocos2dx/sprite_nodes/CCSprite.h index ae7ded7499..a71e3b4944 100644 --- a/cocos2dx/sprite_nodes/CCSprite.h +++ b/cocos2dx/sprite_nodes/CCSprite.h @@ -221,7 +221,7 @@ public: virtual void setScale(float fScale); virtual void setVertexZ(float fVertexZ); virtual void setAnchorPoint(const CCPoint& anchor); - virtual void setIgnoreAnchorPointForPosition(bool value); + virtual void ignoreAnchorPointForPosition(bool value); virtual void setIsVisible(bool bVisible); void setFlipX(bool bFlipX); void setFlipY(bool bFlipY); @@ -245,8 +245,8 @@ public: void updateColor(void); // RGBAProtocol /** opacity: conforms to CCRGBAProtocol protocol */ - virtual void setIsOpacityModifyRGB(bool bValue); - virtual bool getIsOpacityModifyRGB(void); + virtual void setOpacityModifyRGB(bool bValue); + virtual bool isOpacityModifyRGB(void); // CCTextureProtocol virtual void setTexture(CCTexture2D *texture); diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp index 5140a5ee3a..77334eb979 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp @@ -668,7 +668,7 @@ void CCSpriteBatchNode::removeSpriteFromAtlas(CCSprite *pobSprite) void CCSpriteBatchNode::updateBlendFunc(void) { - if (! m_pobTextureAtlas->getTexture()->getHasPremultipliedAlpha()) + if (! m_pobTextureAtlas->getTexture()->hasPremultipliedAlpha()) { m_blendFunc.src = GL_SRC_ALPHA; m_blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA; diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index 13b14656cb..43bf1b4025 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -171,7 +171,7 @@ void* CCTexture2D::keepData(void *data, unsigned int length) return data; } -bool CCTexture2D::getHasPremultipliedAlpha() +bool CCTexture2D::hasPremultipliedAlpha() { return m_bHasPremultipliedAlpha; } @@ -530,7 +530,7 @@ void CCTexture2D::drawInRect(const CCRect& rect) // implementation CCTexture2D (PVRTC); bool CCTexture2D::initWithPVRTCData(const void *data, int level, int bpp, bool hasAlpha, int length, CCTexture2DPixelFormat pixelFormat) { - if( !(CCConfiguration::sharedConfiguration()->isSupportsPVRTC()) ) + if( !(CCConfiguration::sharedConfiguration()->supportsPVRTC()) ) { CCLOG("cocos2d: WARNING: PVRTC images is not supported."); this->release(); @@ -617,6 +617,11 @@ void CCTexture2D::generateMipmap() m_bHasMipmaps = true; } +bool CCTexture2D::hasMipmaps() +{ + return m_bHasMipmaps; +} + void CCTexture2D::setTexParameters(ccTexParams *texParams) { CCAssert( (m_uPixelsWide == ccNextPOT(m_uPixelsWide) || texParams->wrapS == GL_CLAMP_TO_EDGE) && diff --git a/cocos2dx/textures/CCTexture2D.h b/cocos2dx/textures/CCTexture2D.h index 6ae56e19b0..4885f4e56a 100644 --- a/cocos2dx/textures/CCTexture2D.h +++ b/cocos2dx/textures/CCTexture2D.h @@ -235,6 +235,9 @@ public: /** content size */ const CCSize& getContentSizeInPixels(); + + bool hasPremultipliedAlpha(); + bool hasMipmaps(); private: bool initPremultipliedATextureWithImage(CCImage * image, unsigned int pixelsWide, unsigned int pixelsHigh); @@ -259,9 +262,9 @@ private: CC_PROPERTY_READONLY(CCSize, m_tContentSize, ContentSize) /** whether or not the texture has their Alpha premultiplied */ - CC_PROPERTY_READONLY(bool, m_bHasPremultipliedAlpha, HasPremultipliedAlpha); + bool m_bHasPremultipliedAlpha; - CC_SYNTHESIZE_READONLY(bool, m_bHasMipmaps, HasMipmaps); + bool m_bHasMipmaps; /** shader program used by drawAtPoint and drawInRect */ CC_PROPERTY(CCGLProgram*, m_pShaderProgram, ShaderProgram); diff --git a/cocos2dx/textures/CCTexturePVR.cpp b/cocos2dx/textures/CCTexturePVR.cpp index 6349353a81..0028e2b34f 100755 --- a/cocos2dx/textures/CCTexturePVR.cpp +++ b/cocos2dx/textures/CCTexturePVR.cpp @@ -191,7 +191,7 @@ bool CCTexturePVR::unpackPVRData(unsigned char* data, unsigned int len) CCLOG("cocos2d: WARNING: Image is flipped. Regenerate it using PVRTexTool"); } - if (! configuration->isSupportsNPOT() && + if (! configuration->supportsNPOT() && (header->width != ccNextPOT(header->width) || header->height != ccNextPOT(header->height))) { CCLOG("cocos2d: ERROR: Loding an NPOT texture (%dx%d) but is not supported on this device", header->width, header->height); @@ -243,7 +243,7 @@ bool CCTexturePVR::unpackPVRData(unsigned char* data, unsigned int len) heightBlocks = height / 4; break; case kPVRTexturePixelTypeBGRA_8888: - if (CCConfiguration::sharedConfiguration()->isSupportsBGRA8888() == false) + if (CCConfiguration::sharedConfiguration()->supportsBGRA8888() == false) { CCLOG("cocos2d: TexturePVR. BGRA8888 not supported on this device"); return false; @@ -343,7 +343,7 @@ bool CCTexturePVR::createGLTexture() // Generate textures with mipmaps for (unsigned int i = 0; i < m_uNumberOfMipmaps; ++i) { - if (compressed && ! CCConfiguration::sharedConfiguration()->isSupportsPVRTC()) + if (compressed && ! CCConfiguration::sharedConfiguration()->supportsPVRTC()) { CCLOG("cocos2d: WARNING: PVRTC images are not supported"); return false; diff --git a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id index 2896a3bec7..96bd907819 100644 --- a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -2e55dcc2dc68c6b6b24af67634d5107fc04c35bf \ No newline at end of file +e7a48f141ba644f5dc6c8d2f786899216a211a9a \ No newline at end of file diff --git a/tests/tests/AccelerometerTest/AccelerometerTest.cpp b/tests/tests/AccelerometerTest/AccelerometerTest.cpp index 0b951f2485..18e148507e 100644 --- a/tests/tests/AccelerometerTest/AccelerometerTest.cpp +++ b/tests/tests/AccelerometerTest/AccelerometerTest.cpp @@ -32,7 +32,7 @@ void AccelerometerTest::onEnter() { CCLayer::onEnter(); - setIsAccelerometerEnabled(true); + setAccelerometerEnabled(true); CCSize s = CCDirector::sharedDirector()->getWinSize(); diff --git a/tests/tests/Box2DTest/Box2dTest.cpp b/tests/tests/Box2DTest/Box2dTest.cpp index b74632336c..e3df477b90 100644 --- a/tests/tests/Box2DTest/Box2dTest.cpp +++ b/tests/tests/Box2DTest/Box2dTest.cpp @@ -34,7 +34,7 @@ CCAffineTransform PhysicsSprite::nodeToParentTransform(void) float x = pos.x * PTM_RATIO; float y = pos.y * PTM_RATIO; - if ( getIgnoreAnchorPointForPosition() ) { + if ( isIgnoreAnchorPointForPosition() ) { x += m_tAnchorPointInPoints.x; y += m_tAnchorPointInPoints.y; } @@ -60,8 +60,8 @@ CCAffineTransform PhysicsSprite::nodeToParentTransform(void) Box2DTestLayer::Box2DTestLayer() : m_pSpriteTexture(NULL) { - setIsTouchEnabled( true ); - setIsAccelerometerEnabled( true ); + setTouchEnabled( true ); + setAccelerometerEnabled( true ); CCSize s = CCDirector::sharedDirector()->getWinSize(); // init physics diff --git a/tests/tests/Box2DTestBed/Box2dView.cpp b/tests/tests/Box2DTestBed/Box2dView.cpp index 24e1f909be..42b95ee702 100644 --- a/tests/tests/Box2DTestBed/Box2dView.cpp +++ b/tests/tests/Box2DTestBed/Box2dView.cpp @@ -50,7 +50,7 @@ bool MenuLayer::initWithEntryID(int entryId) m_entryID = entryId; - setIsTouchEnabled( true ); + setTouchEnabled( true ); Box2DView* view = Box2DView::viewWithEntryID( entryId ); addChild(view, 0, kTagBox2DNode); @@ -172,7 +172,7 @@ Box2DView* Box2DView::viewWithEntryID(int entryId) bool Box2DView::initWithEntryID(int entryId) { // setIsAccelerometerEnabled( true ); - setIsTouchEnabled( true ); + setTouchEnabled( true ); schedule( schedule_selector(Box2DView::tick) ); diff --git a/tests/tests/BugsTest/Bug-1159.cpp b/tests/tests/BugsTest/Bug-1159.cpp index 8cdc4bfb7f..e1a9a6cc17 100644 --- a/tests/tests/BugsTest/Bug-1159.cpp +++ b/tests/tests/BugsTest/Bug-1159.cpp @@ -29,7 +29,7 @@ bool Bug1159Layer::init() CCLayerColor *sprite_a = CCLayerColor::create(ccc4(255, 0, 0, 255), 700, 700); sprite_a->setAnchorPoint(ccp(0.5f, 0.5f)); - sprite_a->setIgnoreAnchorPointForPosition(false); + sprite_a->ignoreAnchorPointForPosition(false); sprite_a->setPosition(ccp(0.0f, s.height/2)); addChild(sprite_a); @@ -40,7 +40,7 @@ bool Bug1159Layer::init() CCLayerColor *sprite_b = CCLayerColor::create(ccc4(0, 0, 255, 255), 400, 400); sprite_b->setAnchorPoint(ccp(0.5f, 0.5f)); - sprite_b->setIgnoreAnchorPointForPosition(false); + sprite_b->ignoreAnchorPointForPosition(false); sprite_b->setPosition(ccp(s.width/2, s.height/2)); addChild(sprite_b); diff --git a/tests/tests/BugsTest/Bug-624.cpp b/tests/tests/BugsTest/Bug-624.cpp index 0ba9dd5176..1f06faafca 100644 --- a/tests/tests/BugsTest/Bug-624.cpp +++ b/tests/tests/BugsTest/Bug-624.cpp @@ -19,7 +19,7 @@ bool Bug624Layer::init() label->setPosition(ccp(size.width/2, size.height/2)); addChild(label); - setIsAccelerometerEnabled(true); + setAccelerometerEnabled(true); schedule(schedule_selector(Bug624Layer::switchLayer), 5.0f); return true; @@ -56,7 +56,7 @@ bool Bug624Layer2::init() label->setPosition(ccp(size.width/2, size.height/2)); addChild(label); - setIsAccelerometerEnabled(true); + setAccelerometerEnabled(true); schedule(schedule_selector(Bug624Layer2::switchLayer), 5.0f); return true; diff --git a/tests/tests/BugsTest/Bug-914.cpp b/tests/tests/BugsTest/Bug-914.cpp index 117e059dd0..c06c4048b3 100644 --- a/tests/tests/BugsTest/Bug-914.cpp +++ b/tests/tests/BugsTest/Bug-914.cpp @@ -30,7 +30,7 @@ bool Bug914Layer::init() // Apple recommends to re-assign "self" with the "super" return value if (BugsTestBaseLayer::init()) { - setIsTouchEnabled(true); + setTouchEnabled(true); // ask director the the window size CCSize size = CCDirector::sharedDirector()->getWinSize(); CCLayerColor *layer; @@ -40,7 +40,7 @@ bool Bug914Layer::init() layer->setContentSize(CCSizeMake(i*100, i*100)); layer->setPosition(ccp(size.width/2, size.height/2)); layer->setAnchorPoint(ccp(0.5f, 0.5f)); - layer->setIgnoreAnchorPointForPosition(false); + layer->ignoreAnchorPointForPosition(false); addChild(layer, -1-i); } diff --git a/tests/tests/BugsTest/BugsTest.cpp b/tests/tests/BugsTest/BugsTest.cpp index 0db9e76fda..3ce7c7c1e9 100644 --- a/tests/tests/BugsTest/BugsTest.cpp +++ b/tests/tests/BugsTest/BugsTest.cpp @@ -64,7 +64,7 @@ void BugsTestMainLayer::onEnter() m_pItmeMenu->setPosition(s_tCurPos); addChild(m_pItmeMenu); - setIsTouchEnabled(true); + setTouchEnabled(true); } void BugsTestMainLayer::menuCallback(CCObject* pSender) diff --git a/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp b/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp index 62c9951f0d..94a5563888 100644 --- a/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp +++ b/tests/tests/ChipmunkAccelTouchTest/ChipmunkAccelTouchTest.cpp @@ -46,7 +46,7 @@ CCAffineTransform ChipmunkPhysicsSprite::nodeToParentTransform(void) CCFloat x = m_pBody->p.x; CCFloat y = m_pBody->p.y; - if ( getIgnoreAnchorPointForPosition() ) { + if ( isIgnoreAnchorPointForPosition() ) { x += m_tAnchorPointInPoints.x; y += m_tAnchorPointInPoints.y; } @@ -71,8 +71,8 @@ CCAffineTransform ChipmunkPhysicsSprite::nodeToParentTransform(void) ChipmunkAccelTouchTestLayer::ChipmunkAccelTouchTestLayer() { // enable events - setIsTouchEnabled(true); - setIsAccelerometerEnabled(true); + setTouchEnabled(true); + setAccelerometerEnabled(true); CCSize s = CCDirector::sharedDirector()->getWinSize(); diff --git a/tests/tests/ClickAndMoveTest/ClickAndMoveTest.cpp b/tests/tests/ClickAndMoveTest/ClickAndMoveTest.cpp index 78f5621fe0..ddedc25961 100644 --- a/tests/tests/ClickAndMoveTest/ClickAndMoveTest.cpp +++ b/tests/tests/ClickAndMoveTest/ClickAndMoveTest.cpp @@ -17,7 +17,7 @@ void ClickAndMoveTestScene::runThisTest() MainLayer::MainLayer() { - setIsTouchEnabled(true); + setTouchEnabled(true); CCSprite* sprite = CCSprite::create(s_pPathGrossini); diff --git a/tests/tests/CocosDenshionTest/CocosDenshionTest.cpp b/tests/tests/CocosDenshionTest/CocosDenshionTest.cpp index 304765fcd4..f07806b843 100644 --- a/tests/tests/CocosDenshionTest/CocosDenshionTest.cpp +++ b/tests/tests/CocosDenshionTest/CocosDenshionTest.cpp @@ -73,7 +73,7 @@ m_nSoundId(0) m_pItmeMenu->setPosition(CCPointZero); addChild(m_pItmeMenu); - setIsTouchEnabled(true); + setTouchEnabled(true); // preload background music and effect SimpleAudioEngine::sharedEngine()->preloadBackgroundMusic( CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(MUSIC_FILE) ); diff --git a/tests/tests/CurlTest/CurlTest.cpp b/tests/tests/CurlTest/CurlTest.cpp index 8121dae18f..e4d47265ec 100644 --- a/tests/tests/CurlTest/CurlTest.cpp +++ b/tests/tests/CurlTest/CurlTest.cpp @@ -10,7 +10,7 @@ CurlTest::CurlTest() addChild(label, 0); label->setPosition( ccp(s.width/2, s.height-50) ); - setIsTouchEnabled(true); + setTouchEnabled(true); // create a label to display the tip string m_pLabel = CCLabelTTF::create("Touch the screen to connect", "Arial", 22); diff --git a/tests/tests/FontTest/FontTest.cpp b/tests/tests/FontTest/FontTest.cpp index 05a87c2857..62b854677f 100644 --- a/tests/tests/FontTest/FontTest.cpp +++ b/tests/tests/FontTest/FontTest.cpp @@ -24,23 +24,23 @@ static std::string fontList[] = "fonts/Scissor Cuts.ttf", }; -static int fontCount = sizeof(fontList) / sizeof(*fontList); - -static int vAlignIdx = 0; -static CCVerticalTextAlignment verticalAlignment[] = -{ - kCCVerticalTextAlignmentTop, - kCCVerticalTextAlignmentCenter, - kCCVerticalTextAlignmentBottom, -}; +static int fontCount = sizeof(fontList) / sizeof(*fontList); + +static int vAlignIdx = 0; +static CCVerticalTextAlignment verticalAlignment[] = +{ + kCCVerticalTextAlignmentTop, + kCCVerticalTextAlignmentCenter, + kCCVerticalTextAlignmentBottom, +}; static int vAlignCount = sizeof(verticalAlignment) / sizeof(*verticalAlignment); static const char* nextAction(void) { fontIdx++; - if(fontIdx >= fontCount) { - fontIdx = 0; - vAlignIdx = (vAlignIdx + 1) % vAlignCount; + if(fontIdx >= fontCount) { + fontIdx = 0; + vAlignIdx = (vAlignIdx + 1) % vAlignCount; } return fontList[fontIdx].c_str(); } @@ -48,11 +48,11 @@ static const char* nextAction(void) static const char* backAction(void) { fontIdx--; - if( fontIdx < 0 ) { - fontIdx = fontCount - 1; - vAlignIdx--; - if(vAlignIdx < 0) - vAlignIdx = vAlignCount - 1; + if( fontIdx < 0 ) { + fontIdx = fontCount - 1; + vAlignIdx--; + if(vAlignIdx < 0) + vAlignIdx = vAlignCount - 1; } return fontList[fontIdx].c_str(); @@ -83,9 +83,9 @@ FontTest::FontTest() void FontTest::showFont(const char *pFont) { - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - CCSize blockSize = CCSizeMake(s.width/3, 200); + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCSize blockSize = CCSizeMake(s.width/3, 200); CCFloat fontSize = 26; removeChildByTag(kTagLabel1, true); @@ -93,42 +93,42 @@ void FontTest::showFont(const char *pFont) removeChildByTag(kTagLabel3, true); removeChildByTag(kTagLabel4, true); - CCLabelTTF *top = CCLabelTTF::create(pFont, pFont, 24); - CCLabelTTF *left = CCLabelTTF::create("alignment left", blockSize, kCCTextAlignmentLeft, verticalAlignment[vAlignIdx], pFont, fontSize); - CCLabelTTF *center = CCLabelTTF::create("alignment center", blockSize, kCCTextAlignmentCenter, verticalAlignment[vAlignIdx], pFont, fontSize); - CCLabelTTF *right = CCLabelTTF::create("alignment right", blockSize, kCCTextAlignmentRight, verticalAlignment[vAlignIdx], pFont, fontSize); - - CCLayerColor *leftColor = CCLayerColor::create(ccc4(100, 100, 100, 255), blockSize.width, blockSize.height); - CCLayerColor *centerColor = CCLayerColor::create(ccc4(200, 100, 100, 255), blockSize.width, blockSize.height); - CCLayerColor *rightColor = CCLayerColor::create(ccc4(100, 100, 200, 255), blockSize.width, blockSize.height); - - leftColor->setIgnoreAnchorPointForPosition(false); - centerColor->setIgnoreAnchorPointForPosition(false); - rightColor->setIgnoreAnchorPointForPosition(false); - - - top->setAnchorPoint(ccp(0.5, 1)); - left->setAnchorPoint(ccp(0,0.5)); - leftColor->setAnchorPoint(ccp(0,0.5)); - center->setAnchorPoint(ccp(0,0.5)); - centerColor->setAnchorPoint(ccp(0,0.5)); - right->setAnchorPoint(ccp(0,0.5)); - rightColor->setAnchorPoint(ccp(0,0.5)); - - top->setPosition(ccp(s.width/2,s.height-20)); - left->setPosition(ccp(0,s.height/2)); - leftColor->setPosition(left->getPosition()); - center->setPosition(ccp(blockSize.width, s.height/2)); - centerColor->setPosition(center->getPosition()); - right->setPosition(ccp(blockSize.width*2, s.height/2)); - rightColor->setPosition(right->getPosition()); - - this->addChild(leftColor, -1); - this->addChild(left, 0, kTagLabel1); - this->addChild(rightColor, -1); - this->addChild(right, 0, kTagLabel2); - this->addChild(centerColor, -1); - this->addChild(center, 0, kTagLabel3); + CCLabelTTF *top = CCLabelTTF::create(pFont, pFont, 24); + CCLabelTTF *left = CCLabelTTF::create("alignment left", blockSize, kCCTextAlignmentLeft, verticalAlignment[vAlignIdx], pFont, fontSize); + CCLabelTTF *center = CCLabelTTF::create("alignment center", blockSize, kCCTextAlignmentCenter, verticalAlignment[vAlignIdx], pFont, fontSize); + CCLabelTTF *right = CCLabelTTF::create("alignment right", blockSize, kCCTextAlignmentRight, verticalAlignment[vAlignIdx], pFont, fontSize); + + CCLayerColor *leftColor = CCLayerColor::create(ccc4(100, 100, 100, 255), blockSize.width, blockSize.height); + CCLayerColor *centerColor = CCLayerColor::create(ccc4(200, 100, 100, 255), blockSize.width, blockSize.height); + CCLayerColor *rightColor = CCLayerColor::create(ccc4(100, 100, 200, 255), blockSize.width, blockSize.height); + + leftColor->ignoreAnchorPointForPosition(false); + centerColor->ignoreAnchorPointForPosition(false); + rightColor->ignoreAnchorPointForPosition(false); + + + top->setAnchorPoint(ccp(0.5, 1)); + left->setAnchorPoint(ccp(0,0.5)); + leftColor->setAnchorPoint(ccp(0,0.5)); + center->setAnchorPoint(ccp(0,0.5)); + centerColor->setAnchorPoint(ccp(0,0.5)); + right->setAnchorPoint(ccp(0,0.5)); + rightColor->setAnchorPoint(ccp(0,0.5)); + + top->setPosition(ccp(s.width/2,s.height-20)); + left->setPosition(ccp(0,s.height/2)); + leftColor->setPosition(left->getPosition()); + center->setPosition(ccp(blockSize.width, s.height/2)); + centerColor->setPosition(center->getPosition()); + right->setPosition(ccp(blockSize.width*2, s.height/2)); + rightColor->setPosition(right->getPosition()); + + this->addChild(leftColor, -1); + this->addChild(left, 0, kTagLabel1); + this->addChild(rightColor, -1); + this->addChild(right, 0, kTagLabel2); + this->addChild(centerColor, -1); + this->addChild(center, 0, kTagLabel3); this->addChild(top, 0, kTagLabel4); } diff --git a/tests/tests/KeypadTest/KeypadTest.cpp b/tests/tests/KeypadTest/KeypadTest.cpp index b59b3b66c1..9720f7c165 100644 --- a/tests/tests/KeypadTest/KeypadTest.cpp +++ b/tests/tests/KeypadTest/KeypadTest.cpp @@ -8,7 +8,7 @@ KeypadTest::KeypadTest() addChild(label, 0); label->setPosition( ccp(s.width/2, s.height-50) ); - setIsKeypadEnabled(true); + setKeypadEnabled(true); // create a label to display the tip string m_pLabel = CCLabelTTF::create("Please press any key...", "Arial", 22); diff --git a/tests/tests/LabelTest/LabelTest.cpp b/tests/tests/LabelTest/LabelTest.cpp index 21e21dd7ef..77f3db398d 100644 --- a/tests/tests/LabelTest/LabelTest.cpp +++ b/tests/tests/LabelTest/LabelTest.cpp @@ -369,21 +369,21 @@ std::string LabelAtlasColorTest::subtitle() //------------------------------------------------------------------ LabelTTFAlignment::LabelTTFAlignment() { - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - CCLabelTTF* ttf0 = CCLabelTTF::create("Alignment 0\nnew line", CCSizeMake(256, 32), kCCTextAlignmentLeft, "Helvetica", 12); - ttf0->setPosition(ccp(s.width/2,(s.height/6)*2)); - ttf0->setAnchorPoint(ccp(0.5f,0.5f)); - this->addChild(ttf0); - - CCLabelTTF* ttf1 = CCLabelTTF::create("Alignment 1\nnew line", CCSizeMake(245, 32), kCCTextAlignmentCenter, "Helvetica", 12); - ttf1->setPosition(ccp(s.width/2,(s.height/6)*3)); - ttf1->setAnchorPoint(ccp(0.5f,0.5f)); - this->addChild(ttf1); - - CCLabelTTF* ttf2 = CCLabelTTF::create("Alignment 2\nnew line", CCSizeMake(245, 32), kCCTextAlignmentRight, "Helvetica", 12); - ttf2->setPosition(ccp(s.width/2,(s.height/6)*4)); - ttf2->setAnchorPoint(ccp(0.5f,0.5f)); + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCLabelTTF* ttf0 = CCLabelTTF::create("Alignment 0\nnew line", CCSizeMake(256, 32), kCCTextAlignmentLeft, "Helvetica", 12); + ttf0->setPosition(ccp(s.width/2,(s.height/6)*2)); + ttf0->setAnchorPoint(ccp(0.5f,0.5f)); + this->addChild(ttf0); + + CCLabelTTF* ttf1 = CCLabelTTF::create("Alignment 1\nnew line", CCSizeMake(245, 32), kCCTextAlignmentCenter, "Helvetica", 12); + ttf1->setPosition(ccp(s.width/2,(s.height/6)*3)); + ttf1->setAnchorPoint(ccp(0.5f,0.5f)); + this->addChild(ttf1); + + CCLabelTTF* ttf2 = CCLabelTTF::create("Alignment 2\nnew line", CCSizeMake(245, 32), kCCTextAlignmentRight, "Helvetica", 12); + ttf2->setPosition(ccp(s.width/2,(s.height/6)*4)); + ttf2->setAnchorPoint(ccp(0.5f,0.5f)); this->addChild(ttf2); } @@ -947,38 +947,38 @@ void AtlasTestScene::runThisTest() //------------------------------------------------------------------ LabelTTFTest::LabelTTFTest() { - CCSize blockSize = CCSizeMake(200, 160); - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - CCLayerColor *colorLayer = CCLayerColor::create(ccc4(100, 100, 100, 255), blockSize.width, blockSize.height); - colorLayer->setAnchorPoint(ccp(0,0)); - colorLayer->setPosition(ccp((s.width - blockSize.width) / 2, (s.height - blockSize.height) / 2)); - - this->addChild(colorLayer); - - CCMenuItemFont::setFontSize(30); - CCMenu *menu = CCMenu::create( - CCMenuItemFont::create("Left", this, menu_selector(LabelTTFTest::setAlignmentLeft)), - CCMenuItemFont::create("Center", this, menu_selector(LabelTTFTest::setAlignmentCenter)), - CCMenuItemFont::create("Right", this, menu_selector(LabelTTFTest::setAlignmentRight)), - NULL); - menu->alignItemsVerticallyWithPadding(4); - menu->setPosition(ccp(50, s.height / 2 - 20)); - this->addChild(menu); - - menu = CCMenu::create( - CCMenuItemFont::create("Top", this, menu_selector(LabelTTFTest::setAlignmentTop)), - CCMenuItemFont::create("Middle", this, menu_selector(LabelTTFTest::setAlignmentMiddle)), - CCMenuItemFont::create("Bottom", this, menu_selector(LabelTTFTest::setAlignmentBottom)), - NULL); - menu->alignItemsVerticallyWithPadding(4); - menu->setPosition(ccp(s.width - 50, s.height / 2 - 20)); - this->addChild(menu); - - m_plabel = NULL; - m_eHorizAlign = kCCTextAlignmentLeft; - m_eVertAlign = kCCVerticalTextAlignmentTop; - + CCSize blockSize = CCSizeMake(200, 160); + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCLayerColor *colorLayer = CCLayerColor::create(ccc4(100, 100, 100, 255), blockSize.width, blockSize.height); + colorLayer->setAnchorPoint(ccp(0,0)); + colorLayer->setPosition(ccp((s.width - blockSize.width) / 2, (s.height - blockSize.height) / 2)); + + this->addChild(colorLayer); + + CCMenuItemFont::setFontSize(30); + CCMenu *menu = CCMenu::create( + CCMenuItemFont::create("Left", this, menu_selector(LabelTTFTest::setAlignmentLeft)), + CCMenuItemFont::create("Center", this, menu_selector(LabelTTFTest::setAlignmentCenter)), + CCMenuItemFont::create("Right", this, menu_selector(LabelTTFTest::setAlignmentRight)), + NULL); + menu->alignItemsVerticallyWithPadding(4); + menu->setPosition(ccp(50, s.height / 2 - 20)); + this->addChild(menu); + + menu = CCMenu::create( + CCMenuItemFont::create("Top", this, menu_selector(LabelTTFTest::setAlignmentTop)), + CCMenuItemFont::create("Middle", this, menu_selector(LabelTTFTest::setAlignmentMiddle)), + CCMenuItemFont::create("Bottom", this, menu_selector(LabelTTFTest::setAlignmentBottom)), + NULL); + menu->alignItemsVerticallyWithPadding(4); + menu->setPosition(ccp(s.width - 50, s.height / 2 - 20)); + this->addChild(menu); + + m_plabel = NULL; + m_eHorizAlign = kCCTextAlignmentLeft; + m_eVertAlign = kCCVerticalTextAlignmentTop; + this->updateAlignment(); } @@ -987,89 +987,89 @@ LabelTTFTest::~LabelTTFTest() CC_SAFE_RELEASE(m_plabel); } -void LabelTTFTest::updateAlignment() -{ - CCSize blockSize = CCSizeMake(200, 160); - CCSize s = CCDirector::sharedDirector()->getWinSize(); - +void LabelTTFTest::updateAlignment() +{ + CCSize blockSize = CCSizeMake(200, 160); + CCSize s = CCDirector::sharedDirector()->getWinSize(); + if (m_plabel) { m_plabel->removeFromParentAndCleanup(true); - } - - m_plabel = CCLabelTTF::create(this->getCurrentAlignment(), blockSize, m_eHorizAlign, m_eVertAlign, "Marker Felt", 32); - m_plabel->retain(); - - m_plabel->setAnchorPoint(ccp(0,0)); - m_plabel->setPosition(ccp((s.width - blockSize.width) / 2, (s.height - blockSize.height)/2 )); - - this->addChild(m_plabel); -} - -void LabelTTFTest::setAlignmentLeft(CCObject* pSender) -{ - m_eHorizAlign = kCCTextAlignmentLeft; - this->updateAlignment(); -} - -void LabelTTFTest::setAlignmentCenter(CCObject* pSender) -{ - m_eHorizAlign = kCCTextAlignmentCenter; - this->updateAlignment(); -} - -void LabelTTFTest::setAlignmentRight(CCObject* pSender) -{ - m_eHorizAlign = kCCTextAlignmentRight; - this->updateAlignment(); -} - -void LabelTTFTest::setAlignmentTop(CCObject* pSender) -{ - m_eVertAlign = kCCVerticalTextAlignmentTop; - this->updateAlignment(); -} - -void LabelTTFTest::setAlignmentMiddle(CCObject* pSender) -{ - m_eVertAlign = kCCVerticalTextAlignmentCenter; - this->updateAlignment(); -} - -void LabelTTFTest::setAlignmentBottom(CCObject* pSender) -{ - m_eVertAlign = kCCVerticalTextAlignmentBottom; - this->updateAlignment(); -} - -const char* LabelTTFTest::getCurrentAlignment() -{ - const char* vertical = NULL; - const char* horizontal = NULL; - switch (m_eVertAlign) { - case kCCVerticalTextAlignmentTop: - vertical = "Top"; - break; - case kCCVerticalTextAlignmentCenter: - vertical = "Middle"; - break; - case kCCVerticalTextAlignmentBottom: - vertical = "Bottom"; - break; - } - switch (m_eHorizAlign) { - case kCCTextAlignmentLeft: - horizontal = "Left"; - break; - case kCCTextAlignmentCenter: - horizontal = "Center"; - break; - case kCCTextAlignmentRight: - horizontal = "Right"; - break; - } - - return CCString::createWithFormat("Alignment %s %s", vertical, horizontal)->getCString(); + } + + m_plabel = CCLabelTTF::create(this->getCurrentAlignment(), blockSize, m_eHorizAlign, m_eVertAlign, "Marker Felt", 32); + m_plabel->retain(); + + m_plabel->setAnchorPoint(ccp(0,0)); + m_plabel->setPosition(ccp((s.width - blockSize.width) / 2, (s.height - blockSize.height)/2 )); + + this->addChild(m_plabel); +} + +void LabelTTFTest::setAlignmentLeft(CCObject* pSender) +{ + m_eHorizAlign = kCCTextAlignmentLeft; + this->updateAlignment(); +} + +void LabelTTFTest::setAlignmentCenter(CCObject* pSender) +{ + m_eHorizAlign = kCCTextAlignmentCenter; + this->updateAlignment(); +} + +void LabelTTFTest::setAlignmentRight(CCObject* pSender) +{ + m_eHorizAlign = kCCTextAlignmentRight; + this->updateAlignment(); +} + +void LabelTTFTest::setAlignmentTop(CCObject* pSender) +{ + m_eVertAlign = kCCVerticalTextAlignmentTop; + this->updateAlignment(); +} + +void LabelTTFTest::setAlignmentMiddle(CCObject* pSender) +{ + m_eVertAlign = kCCVerticalTextAlignmentCenter; + this->updateAlignment(); +} + +void LabelTTFTest::setAlignmentBottom(CCObject* pSender) +{ + m_eVertAlign = kCCVerticalTextAlignmentBottom; + this->updateAlignment(); +} + +const char* LabelTTFTest::getCurrentAlignment() +{ + const char* vertical = NULL; + const char* horizontal = NULL; + switch (m_eVertAlign) { + case kCCVerticalTextAlignmentTop: + vertical = "Top"; + break; + case kCCVerticalTextAlignmentCenter: + vertical = "Middle"; + break; + case kCCVerticalTextAlignmentBottom: + vertical = "Bottom"; + break; + } + switch (m_eHorizAlign) { + case kCCTextAlignmentLeft: + horizontal = "Left"; + break; + case kCCTextAlignmentCenter: + horizontal = "Center"; + break; + case kCCTextAlignmentRight: + horizontal = "Right"; + break; + } + + return CCString::createWithFormat("Alignment %s %s", vertical, horizontal)->getCString(); } string LabelTTFTest::title() @@ -1155,7 +1155,7 @@ static float alignmentItemPadding = 50; static float menuItemPaddingCenter = 50; BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment() { - this->setIsTouchEnabled(true); + this->setTouchEnabled(true); // ask director the the window size CCSize size = CCDirector::sharedDirector()->getWinSize(); @@ -1419,24 +1419,24 @@ std::string BMFontUnicode::title() std::string BMFontUnicode::subtitle() { return "You should see 3 differnt labels: In Spanish, Chinese and Korean"; -} - -// BMFontInit - -BMFontInit::BMFontInit() -{ - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - CCLabelBMFont* bmFont = new CCLabelBMFont(); - bmFont->init(); - bmFont->autorelease(); - //CCLabelBMFont* bmFont = [CCLabelBMFont create:@"Foo" fntFile:@"arial-unicode-26.fnt"]; - bmFont->setFntFile("fonts/helvetica-32.fnt"); - bmFont->setString("It is working!"); - this->addChild(bmFont); - bmFont->setPosition(ccp(s.width/2,s.height/4*2)); -} - +} + +// BMFontInit + +BMFontInit::BMFontInit() +{ + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCLabelBMFont* bmFont = new CCLabelBMFont(); + bmFont->init(); + bmFont->autorelease(); + //CCLabelBMFont* bmFont = [CCLabelBMFont create:@"Foo" fntFile:@"arial-unicode-26.fnt"]; + bmFont->setFntFile("fonts/helvetica-32.fnt"); + bmFont->setString("It is working!"); + this->addChild(bmFont); + bmFont->setPosition(ccp(s.width/2,s.height/4*2)); +} + std::string BMFontInit::title() { return "CCLabelBMFont init"; @@ -1445,24 +1445,24 @@ std::string BMFontInit::title() std::string BMFontInit::subtitle() { return "Test for support of init method without parameters."; -} - -// TTFFontInit - -TTFFontInit::TTFFontInit() -{ - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - CCLabelTTF* font = new CCLabelTTF(); - font->init(); - font->autorelease(); - font->setFontName("Marker Felt"); - font->setFontSize(48); - font->setString("It is working!"); - this->addChild(font); - font->setPosition(ccp(s.width/2,s.height/4*2)); -} - +} + +// TTFFontInit + +TTFFontInit::TTFFontInit() +{ + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCLabelTTF* font = new CCLabelTTF(); + font->init(); + font->autorelease(); + font->setFontName("Marker Felt"); + font->setFontSize(48); + font->setString("It is working!"); + this->addChild(font); + font->setPosition(ccp(s.width/2,s.height/4*2)); +} + std::string TTFFontInit::title() { return "CCLabelTTF init"; @@ -1472,25 +1472,25 @@ std::string TTFFontInit::subtitle() { return "Test for support of init method without parameters."; } - - -// Issue1343 - -Issue1343::Issue1343() -{ - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - CCLabelBMFont* bmFont = new CCLabelBMFont(); - bmFont->init(); - bmFont->setFntFile("fonts/font-issue1343.fnt"); - bmFont->setString("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz.,'"); - this->addChild(bmFont); - bmFont->release(); - bmFont->setScale(0.3f); - - bmFont->setPosition(ccp(s.width/2,s.height/4*2)); -} - + + +// Issue1343 + +Issue1343::Issue1343() +{ + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCLabelBMFont* bmFont = new CCLabelBMFont(); + bmFont->init(); + bmFont->setFntFile("fonts/font-issue1343.fnt"); + bmFont->setString("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890abcdefghijklmnopqrstuvwxyz.,'"); + this->addChild(bmFont); + bmFont->release(); + bmFont->setScale(0.3f); + + bmFont->setPosition(ccp(s.width/2,s.height/4*2)); +} + std::string Issue1343::title() { return "Issue 1343"; diff --git a/tests/tests/LayerTest/LayerTest.cpp b/tests/tests/LayerTest/LayerTest.cpp index ea19200183..7057c5ca47 100644 --- a/tests/tests/LayerTest/LayerTest.cpp +++ b/tests/tests/LayerTest/LayerTest.cpp @@ -152,12 +152,12 @@ void LayerTest1::onEnter() { LayerTest::onEnter(); - setIsTouchEnabled(true); + setTouchEnabled(true); CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLayerColor* layer = CCLayerColor::create( ccc4(0xFF, 0x00, 0x00, 0x80), 200, 200); - layer->setIgnoreAnchorPointForPosition(false); + layer->ignoreAnchorPointForPosition(false); layer->setPosition( CCPointMake(s.width/2, s.height/2) ); addChild(layer, 1, kTagLayer); } @@ -222,12 +222,12 @@ void LayerTest2::onEnter() CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLayerColor* layer1 = CCLayerColor::create( ccc4(255, 255, 0, 80), 100, 300); layer1->setPosition(CCPointMake(s.width/3, s.height/2)); - layer1->setIgnoreAnchorPointForPosition(false); + layer1->ignoreAnchorPointForPosition(false); addChild(layer1, 1); CCLayerColor* layer2 = CCLayerColor::create( ccc4(0, 0, 255, 255), 100, 300); layer2->setPosition(CCPointMake((s.width/3)*2, s.height/2)); - layer2->setIgnoreAnchorPointForPosition(false); + layer2->ignoreAnchorPointForPosition(false); addChild(layer2, 1); CCActionInterval* actionTint = CCTintBy::create(2, -255, -127, 0); @@ -308,7 +308,7 @@ LayerGradient::LayerGradient() CCLayerGradient* layer1 = CCLayerGradient::create(ccc4(255,0,0,255), ccc4(0,255,0,255), ccp(0.9f, 0.9f)); addChild(layer1, 0, kTagLayer); - setIsTouchEnabled(true); + setTouchEnabled(true); CCLabelTTF *label1 = CCLabelTTF::create("Compressed Interpolation: Enabled", "Marker Felt", 26); CCLabelTTF *label2 = CCLabelTTF::create("Compressed Interpolation: Disabled", "Marker Felt", 26); @@ -354,154 +354,154 @@ string LayerGradient::subtitle() return "Touch the screen and move your finger"; } -// LayerIgnoreAnchorPointPos - -#define kLayerIgnoreAnchorPoint 1000 - -void LayerIgnoreAnchorPointPos::onEnter() -{ - LayerTest::onEnter(); - - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - CCLayerColor *l = CCLayerColor::create(ccc4(255, 0, 0, 255), 150, 150); - - l->setAnchorPoint(ccp(0.5f, 0.5f)); - l->setPosition(ccp( s.width/2, s.height/2)); - - CCMoveBy *move = CCMoveBy::create(2, ccp(100,2)); - CCMoveBy * back = (CCMoveBy *)move->reverse(); - CCSequence *seq = (CCSequence *)CCSequence::create(move, back, NULL); - l->runAction(CCRepeatForever::create(seq)); - this->addChild(l, 0, kLayerIgnoreAnchorPoint); - - CCSprite *child = CCSprite::create("Images/grossini.png"); - l->addChild(child); - CCSize lsize = l->getContentSize(); - child->setPosition(ccp(lsize.width/2, lsize.height/2)); - - CCMenuItemFont *item = CCMenuItemFont::create("Toogle ignore anchor point", this, menu_selector(LayerIgnoreAnchorPointPos::onToggle)); - - CCMenu *menu = CCMenu::create(item, NULL); - this->addChild(menu); - - menu->setPosition(ccp(s.width/2, s.height/2)); -} - -void LayerIgnoreAnchorPointPos::onToggle(CCObject* pObject) -{ - CCNode* pLayer = this->getChildByTag(kLayerIgnoreAnchorPoint); - bool ignore = pLayer->getIgnoreAnchorPointForPosition(); - pLayer->setIgnoreAnchorPointForPosition(! ignore); -} - +// LayerIgnoreAnchorPointPos + +#define kLayerIgnoreAnchorPoint 1000 + +void LayerIgnoreAnchorPointPos::onEnter() +{ + LayerTest::onEnter(); + + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCLayerColor *l = CCLayerColor::create(ccc4(255, 0, 0, 255), 150, 150); + + l->setAnchorPoint(ccp(0.5f, 0.5f)); + l->setPosition(ccp( s.width/2, s.height/2)); + + CCMoveBy *move = CCMoveBy::create(2, ccp(100,2)); + CCMoveBy * back = (CCMoveBy *)move->reverse(); + CCSequence *seq = (CCSequence *)CCSequence::create(move, back, NULL); + l->runAction(CCRepeatForever::create(seq)); + this->addChild(l, 0, kLayerIgnoreAnchorPoint); + + CCSprite *child = CCSprite::create("Images/grossini.png"); + l->addChild(child); + CCSize lsize = l->getContentSize(); + child->setPosition(ccp(lsize.width/2, lsize.height/2)); + + CCMenuItemFont *item = CCMenuItemFont::create("Toogle ignore anchor point", this, menu_selector(LayerIgnoreAnchorPointPos::onToggle)); + + CCMenu *menu = CCMenu::create(item, NULL); + this->addChild(menu); + + menu->setPosition(ccp(s.width/2, s.height/2)); +} + +void LayerIgnoreAnchorPointPos::onToggle(CCObject* pObject) +{ + CCNode* pLayer = this->getChildByTag(kLayerIgnoreAnchorPoint); + bool ignore = pLayer->isIgnoreAnchorPointForPosition(); + pLayer->ignoreAnchorPointForPosition(! ignore); +} + std::string LayerIgnoreAnchorPointPos::title() { return "IgnoreAnchorPoint - Position"; } -std::string LayerIgnoreAnchorPointPos::subtitle() -{ - return "Ignoring Anchor Point for position"; -} - -// LayerIgnoreAnchorPointRot - -void LayerIgnoreAnchorPointRot::onEnter() -{ - LayerTest::onEnter(); - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - CCLayerColor *l = CCLayerColor::create(ccc4(255, 0, 0, 255), 200, 200); - - l->setAnchorPoint(ccp(0.5f, 0.5f)); - l->setPosition(ccp( s.width/2, s.height/2)); - - this->addChild(l, 0, kLayerIgnoreAnchorPoint); - - CCRotateBy *rot = CCRotateBy::create(2, 360); - l->runAction(CCRepeatForever::create(rot)); - - - CCSprite *child = CCSprite::create("Images/grossini.png"); - l->addChild(child); - CCSize lsize = l->getContentSize(); - child->setPosition(ccp(lsize.width/2, lsize.height/2)); - - CCMenuItemFont *item = CCMenuItemFont::create("Toogle ignore anchor point", this, menu_selector(LayerIgnoreAnchorPointRot::onToggle)); - - CCMenu *menu = CCMenu::create(item, NULL); - this->addChild(menu); - - menu->setPosition(ccp(s.width/2, s.height/2)); -} - -void LayerIgnoreAnchorPointRot::onToggle(CCObject* pObject) -{ - CCNode* pLayer = this->getChildByTag(kLayerIgnoreAnchorPoint); - bool ignore = pLayer->getIgnoreAnchorPointForPosition(); - pLayer->setIgnoreAnchorPointForPosition(! ignore); -} - +std::string LayerIgnoreAnchorPointPos::subtitle() +{ + return "Ignoring Anchor Point for position"; +} + +// LayerIgnoreAnchorPointRot + +void LayerIgnoreAnchorPointRot::onEnter() +{ + LayerTest::onEnter(); + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCLayerColor *l = CCLayerColor::create(ccc4(255, 0, 0, 255), 200, 200); + + l->setAnchorPoint(ccp(0.5f, 0.5f)); + l->setPosition(ccp( s.width/2, s.height/2)); + + this->addChild(l, 0, kLayerIgnoreAnchorPoint); + + CCRotateBy *rot = CCRotateBy::create(2, 360); + l->runAction(CCRepeatForever::create(rot)); + + + CCSprite *child = CCSprite::create("Images/grossini.png"); + l->addChild(child); + CCSize lsize = l->getContentSize(); + child->setPosition(ccp(lsize.width/2, lsize.height/2)); + + CCMenuItemFont *item = CCMenuItemFont::create("Toogle ignore anchor point", this, menu_selector(LayerIgnoreAnchorPointRot::onToggle)); + + CCMenu *menu = CCMenu::create(item, NULL); + this->addChild(menu); + + menu->setPosition(ccp(s.width/2, s.height/2)); +} + +void LayerIgnoreAnchorPointRot::onToggle(CCObject* pObject) +{ + CCNode* pLayer = this->getChildByTag(kLayerIgnoreAnchorPoint); + bool ignore = pLayer->isIgnoreAnchorPointForPosition(); + pLayer->ignoreAnchorPointForPosition(! ignore); +} + std::string LayerIgnoreAnchorPointRot::title() { return "IgnoreAnchorPoint - Rotation"; } -std::string LayerIgnoreAnchorPointRot::subtitle() -{ - return "Ignoring Anchor Point for rotations"; -} - -// LayerIgnoreAnchorPointScale -void LayerIgnoreAnchorPointScale::onEnter() -{ - LayerTest::onEnter(); - - CCSize s = CCDirector::sharedDirector()->getWinSize(); - - CCLayerColor *l = CCLayerColor::create(ccc4(255, 0, 0, 255), 200, 200); - - l->setAnchorPoint(ccp(0.5f, 1.0f)); - l->setPosition(ccp( s.width/2, s.height/2)); - - - CCScaleBy *scale = CCScaleBy::create(2, 2); - CCScaleBy* back = (CCScaleBy*)scale->reverse(); - CCSequence *seq = (CCSequence*)CCSequence::create(scale, back, NULL); - - l->runAction(CCRepeatForever::create(seq)); - - this->addChild(l, 0, kLayerIgnoreAnchorPoint); - - CCSprite *child = CCSprite::create("Images/grossini.png"); - l->addChild(child); - CCSize lsize = l->getContentSize(); - child->setPosition(ccp(lsize.width/2, lsize.height/2)); - - CCMenuItemFont *item = CCMenuItemFont::create("Toogle ignore anchor point", this, menu_selector(LayerIgnoreAnchorPointScale::onToggle)); - - CCMenu *menu = CCMenu::create(item, NULL); - this->addChild(menu); - - menu->setPosition(ccp(s.width/2, s.height/2)); -} - -void LayerIgnoreAnchorPointScale::onToggle(CCObject* pObject) -{ - CCNode* pLayer = this->getChildByTag(kLayerIgnoreAnchorPoint); - bool ignore = pLayer->getIgnoreAnchorPointForPosition(); - pLayer->setIgnoreAnchorPointForPosition(! ignore); -} - +std::string LayerIgnoreAnchorPointRot::subtitle() +{ + return "Ignoring Anchor Point for rotations"; +} + +// LayerIgnoreAnchorPointScale +void LayerIgnoreAnchorPointScale::onEnter() +{ + LayerTest::onEnter(); + + CCSize s = CCDirector::sharedDirector()->getWinSize(); + + CCLayerColor *l = CCLayerColor::create(ccc4(255, 0, 0, 255), 200, 200); + + l->setAnchorPoint(ccp(0.5f, 1.0f)); + l->setPosition(ccp( s.width/2, s.height/2)); + + + CCScaleBy *scale = CCScaleBy::create(2, 2); + CCScaleBy* back = (CCScaleBy*)scale->reverse(); + CCSequence *seq = (CCSequence*)CCSequence::create(scale, back, NULL); + + l->runAction(CCRepeatForever::create(seq)); + + this->addChild(l, 0, kLayerIgnoreAnchorPoint); + + CCSprite *child = CCSprite::create("Images/grossini.png"); + l->addChild(child); + CCSize lsize = l->getContentSize(); + child->setPosition(ccp(lsize.width/2, lsize.height/2)); + + CCMenuItemFont *item = CCMenuItemFont::create("Toogle ignore anchor point", this, menu_selector(LayerIgnoreAnchorPointScale::onToggle)); + + CCMenu *menu = CCMenu::create(item, NULL); + this->addChild(menu); + + menu->setPosition(ccp(s.width/2, s.height/2)); +} + +void LayerIgnoreAnchorPointScale::onToggle(CCObject* pObject) +{ + CCNode* pLayer = this->getChildByTag(kLayerIgnoreAnchorPoint); + bool ignore = pLayer->isIgnoreAnchorPointForPosition(); + pLayer->ignoreAnchorPointForPosition(! ignore); +} + std::string LayerIgnoreAnchorPointScale::title() { return "IgnoreAnchorPoint - Scale"; } -std::string LayerIgnoreAnchorPointScale::subtitle() -{ - return "Ignoring Anchor Point for scale"; +std::string LayerIgnoreAnchorPointScale::subtitle() +{ + return "Ignoring Anchor Point for scale"; } void LayerTestScene::runThisTest() diff --git a/tests/tests/MenuTest/MenuTest.cpp b/tests/tests/MenuTest/MenuTest.cpp index fabae6e55e..6346a0bebf 100644 --- a/tests/tests/MenuTest/MenuTest.cpp +++ b/tests/tests/MenuTest/MenuTest.cpp @@ -28,7 +28,7 @@ MenuLayerMainMenu::MenuLayerMainMenu() CCMenuItemFont::setFontSize( 30 ); CCMenuItemFont::setFontName("Courier New"); - setIsTouchEnabled(true); + setTouchEnabled(true); // Font Item CCSprite* spriteNormal = CCSprite::create(s_MenuItem, CCRectMake(0,23*2,115,23)); @@ -170,7 +170,7 @@ void MenuLayerMainMenu::menuCallbackDisabled(CCObject* sender) void MenuLayerMainMenu::menuCallbackEnable(CCObject* sender) { - m_disabledItem->setIsEnabled(! m_disabledItem->getIsEnabled() ); + m_disabledItem->setIsEnabled(! m_disabledItem->isEnabled() ); } void MenuLayerMainMenu::menuCallback2(CCObject* sender) @@ -361,7 +361,7 @@ void MenuLayer3::menuCallback(CCObject* sender) void MenuLayer3::menuCallback2(CCObject* sender) { //UXLOG("Label clicked. Toogling AtlasSprite"); - m_disabledItem->setIsEnabled( ! m_disabledItem->getIsEnabled() ); + m_disabledItem->setIsEnabled( ! m_disabledItem->isEnabled() ); m_disabledItem->stopAllActions(); } diff --git a/tests/tests/MotionStreakTest/MotionStreakTest.cpp b/tests/tests/MotionStreakTest/MotionStreakTest.cpp index 5b00c582b5..d64b9a6ada 100644 --- a/tests/tests/MotionStreakTest/MotionStreakTest.cpp +++ b/tests/tests/MotionStreakTest/MotionStreakTest.cpp @@ -79,7 +79,7 @@ void MotionStreakTest2::onEnter() { MotionStreakTest::onEnter(); - setIsTouchEnabled(true); + setTouchEnabled(true); CCSize s = CCDirector::sharedDirector()->getWinSize(); diff --git a/tests/tests/MutiTouchTest/MutiTouchTest.cpp b/tests/tests/MutiTouchTest/MutiTouchTest.cpp index d30d696695..0e9d4c7eed 100644 --- a/tests/tests/MutiTouchTest/MutiTouchTest.cpp +++ b/tests/tests/MutiTouchTest/MutiTouchTest.cpp @@ -56,7 +56,7 @@ bool MutiTouchTestLayer::init() { if (CCLayer::init()) { - setIsTouchEnabled(true); + setTouchEnabled(true); return true; } return false; diff --git a/tests/tests/NodeTest/NodeTest.cpp b/tests/tests/NodeTest/NodeTest.cpp index 6aa50c812b..4a425606b3 100644 --- a/tests/tests/NodeTest/NodeTest.cpp +++ b/tests/tests/NodeTest/NodeTest.cpp @@ -758,7 +758,7 @@ std::string CameraCenterTest::subtitle() //------------------------------------------------------------------ ConvertToNode::ConvertToNode() { - setIsTouchEnabled(true); + setTouchEnabled(true); CCSize s = CCDirector::sharedDirector()->getWinSize(); CCRotateBy* rotate = CCRotateBy::create(10, 360); diff --git a/tests/tests/ParallaxTest/ParallaxTest.cpp b/tests/tests/ParallaxTest/ParallaxTest.cpp index 13b7bcbd3a..36cdd028e3 100644 --- a/tests/tests/ParallaxTest/ParallaxTest.cpp +++ b/tests/tests/ParallaxTest/ParallaxTest.cpp @@ -87,7 +87,7 @@ std::string Parallax1::title() Parallax2::Parallax2() { - setIsTouchEnabled( true ); + setTouchEnabled( true ); // Top Layer, a simple image CCSprite* cocosImage = CCSprite::create(s_Power); diff --git a/tests/tests/ParticleTest/ParticleTest.cpp b/tests/tests/ParticleTest/ParticleTest.cpp index 29a5d1a9d6..e2389d8efa 100644 --- a/tests/tests/ParticleTest/ParticleTest.cpp +++ b/tests/tests/ParticleTest/ParticleTest.cpp @@ -206,7 +206,7 @@ void DemoBigFlower::onEnter() m_emitter->setEmissionRate(m_emitter->getTotalParticles()/m_emitter->getLife()); // additive - m_emitter->setIsBlendAdditive(true); + m_emitter->setBlendAdditive(true); setEmitterPosition(); } @@ -291,7 +291,7 @@ void DemoRotFlower::onEnter() m_emitter->setEmissionRate(m_emitter->getTotalParticles()/m_emitter->getLife()); // additive - m_emitter->setIsBlendAdditive(false); + m_emitter->setBlendAdditive(false); setEmitterPosition(); } @@ -549,7 +549,7 @@ void DemoModernArt::onEnter() m_emitter->setTexture( CCTextureCache::sharedTextureCache()->addImage(s_fire) ); // additive - m_emitter->setIsBlendAdditive(false); + m_emitter->setBlendAdditive(false); setEmitterPosition(); } @@ -707,7 +707,7 @@ void RadiusMode1::onEnter() m_emitter->setEmissionRate(m_emitter->getTotalParticles() / m_emitter->getLife()); // additive - m_emitter->setIsBlendAdditive(false); + m_emitter->setBlendAdditive(false); } std::string RadiusMode1::title() @@ -791,7 +791,7 @@ void RadiusMode2::onEnter() m_emitter->setEmissionRate(m_emitter->getTotalParticles() / m_emitter->getLife()); // additive - m_emitter->setIsBlendAdditive(false); + m_emitter->setBlendAdditive(false); } std::string RadiusMode2::title() @@ -875,7 +875,7 @@ void Issue704::onEnter() m_emitter->setEmissionRate(m_emitter->getTotalParticles() / m_emitter->getLife()); // additive - m_emitter->setIsBlendAdditive(false); + m_emitter->setBlendAdditive(false); CCRotateBy* rot = CCRotateBy::create(16, 360); m_emitter->runAction(CCRepeatForever::create(rot)); @@ -1072,7 +1072,7 @@ void ParticleDemo::onEnter(void) m_emitter = NULL; - setIsTouchEnabled( true ); + setTouchEnabled( true ); CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLabelTTF* label = CCLabelTTF::create(title().c_str(), "Arial", 28); @@ -1339,13 +1339,13 @@ void ParticleReorder::onEnter() CCParticleSystemQuad *emitter1 = CCParticleSystemQuad::create("Particles/SmallSun.plist"); emitter1->setStartColor(ccc4f(1,0,0,1)); - emitter1->setIsBlendAdditive(false); + emitter1->setBlendAdditive(false); CCParticleSystemQuad *emitter2 = CCParticleSystemQuad::create("Particles/SmallSun.plist"); emitter2->setStartColor(ccc4f(0,1,0,1)); - emitter2->setIsBlendAdditive(false); + emitter2->setBlendAdditive(false); CCParticleSystemQuad *emitter3 = CCParticleSystemQuad::create("Particles/SmallSun.plist"); emitter3->setStartColor(ccc4f(0,0,1,1)); - emitter3->setIsBlendAdditive(false); + emitter3->setBlendAdditive(false); CCSize s = CCDirector::sharedDirector()->getWinSize(); @@ -1422,7 +1422,7 @@ bool RainbowEffect::initWithTotalParticles(unsigned int numberOfParticles) if( CCParticleSystemQuad::initWithTotalParticles(numberOfParticles) ) { // additive - setIsBlendAdditive(false); + setBlendAdditive(false); // duration setDuration(kCCParticleDurationInfinity); @@ -1859,73 +1859,73 @@ std::string ReorderParticleSystems::subtitle() { return "changes every 2 seconds"; } - -// PremultipliedAlphaTest - + +// PremultipliedAlphaTest + std::string PremultipliedAlphaTest::title() { return "premultiplied alpha"; } -std::string PremultipliedAlphaTest::subtitle() -{ - return "no black halo, particles should fade out"; -} - -void PremultipliedAlphaTest::onEnter() -{ - ParticleDemo::onEnter(); - - this->setColor(ccBLUE); - this->removeChild(m_background, true); - m_background = NULL; - - m_emitter = CCParticleSystemQuad::create("Particles/BoilingFoam.plist"); - m_emitter->retain(); - // Particle Designer "normal" blend func causes black halo on premul textures (ignores multiplication) - //this->emitter.blendFunc = (ccBlendFunc){ GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA }; - - // Cocos2d "normal" blend func for premul causes alpha to be ignored (oversaturates colors) - ccBlendFunc tBlendFunc = { GL_ONE, GL_ONE_MINUS_SRC_ALPHA }; - m_emitter->setBlendFunc(tBlendFunc); - - CCAssert(m_emitter->getOpacityModifyRGB(), "Particle texture does not have premultiplied alpha, test is useless"); - - // Toggle next line to see old behavior - // this->emitter.opacityModifyRGB = NO; - - m_emitter->setStartColor(ccc4f(1, 1, 1, 1)); - m_emitter->setEndColor(ccc4f(1, 1, 1, 0)); - m_emitter->setStartColorVar(ccc4f(0, 0, 0, 0)); - m_emitter->setEndColorVar(ccc4f(0, 0, 0, 0)); - - this->addChild(m_emitter, 10); -} - -// PremultipliedAlphaTest2 - -void PremultipliedAlphaTest2::onEnter() -{ - ParticleDemo::onEnter(); - - this->setColor(ccBLACK); - this->removeChild(m_background, true); - m_background = NULL; - - m_emitter = CCParticleSystemQuad::create("Particles/TestPremultipliedAlpha.plist"); - m_emitter->retain(); - this->addChild(m_emitter ,10); -} - +std::string PremultipliedAlphaTest::subtitle() +{ + return "no black halo, particles should fade out"; +} + +void PremultipliedAlphaTest::onEnter() +{ + ParticleDemo::onEnter(); + + this->setColor(ccBLUE); + this->removeChild(m_background, true); + m_background = NULL; + + m_emitter = CCParticleSystemQuad::create("Particles/BoilingFoam.plist"); + m_emitter->retain(); + // Particle Designer "normal" blend func causes black halo on premul textures (ignores multiplication) + //this->emitter.blendFunc = (ccBlendFunc){ GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA }; + + // Cocos2d "normal" blend func for premul causes alpha to be ignored (oversaturates colors) + ccBlendFunc tBlendFunc = { GL_ONE, GL_ONE_MINUS_SRC_ALPHA }; + m_emitter->setBlendFunc(tBlendFunc); + + CCAssert(m_emitter->getOpacityModifyRGB(), "Particle texture does not have premultiplied alpha, test is useless"); + + // Toggle next line to see old behavior + // this->emitter.opacityModifyRGB = NO; + + m_emitter->setStartColor(ccc4f(1, 1, 1, 1)); + m_emitter->setEndColor(ccc4f(1, 1, 1, 0)); + m_emitter->setStartColorVar(ccc4f(0, 0, 0, 0)); + m_emitter->setEndColorVar(ccc4f(0, 0, 0, 0)); + + this->addChild(m_emitter, 10); +} + +// PremultipliedAlphaTest2 + +void PremultipliedAlphaTest2::onEnter() +{ + ParticleDemo::onEnter(); + + this->setColor(ccBLACK); + this->removeChild(m_background, true); + m_background = NULL; + + m_emitter = CCParticleSystemQuad::create("Particles/TestPremultipliedAlpha.plist"); + m_emitter->retain(); + this->addChild(m_emitter ,10); +} + std::string PremultipliedAlphaTest2::title() { return "premultiplied alpha 2"; } -std::string PremultipliedAlphaTest2::subtitle() -{ - return "Arrows should be faded"; -} +std::string PremultipliedAlphaTest2::subtitle() +{ + return "Arrows should be faded"; +} void ParticleTestScene::runThisTest() { diff --git a/tests/tests/PerformanceTest/PerformanceParticleTest.cpp b/tests/tests/PerformanceTest/PerformanceParticleTest.cpp index b62ec0352e..758ea6a1f6 100644 --- a/tests/tests/PerformanceTest/PerformanceParticleTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceParticleTest.cpp @@ -349,7 +349,7 @@ void ParticlePerformTest1::doTest() particleSystem->setStartSizeVar(0); // additive - particleSystem->setIsBlendAdditive(false); + particleSystem->setBlendAdditive(false); } //////////////////////////////////////////////////////// @@ -419,7 +419,7 @@ void ParticlePerformTest2::doTest() particleSystem->setStartSizeVar(0); // additive - particleSystem->setIsBlendAdditive(false); + particleSystem->setBlendAdditive(false); } //////////////////////////////////////////////////////// @@ -489,7 +489,7 @@ void ParticlePerformTest3::doTest() particleSystem->setStartSizeVar(0); // additive - particleSystem->setIsBlendAdditive(false); + particleSystem->setBlendAdditive(false); } //////////////////////////////////////////////////////// @@ -559,7 +559,7 @@ void ParticlePerformTest4::doTest() particleSystem->setStartSizeVar(0); // additive - particleSystem->setIsBlendAdditive(false); + particleSystem->setBlendAdditive(false); } diff --git a/tests/tests/PerformanceTest/PerformanceTouchesTest.cpp b/tests/tests/PerformanceTest/PerformanceTouchesTest.cpp index 8624102397..7219e54e09 100644 --- a/tests/tests/PerformanceTest/PerformanceTouchesTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceTouchesTest.cpp @@ -89,7 +89,7 @@ std::string TouchesMainScene::title() void TouchesPerformTest1::onEnter() { TouchesMainScene::onEnter(); - setIsTouchEnabled(true); + setTouchEnabled(true); } std::string TouchesPerformTest1::title() @@ -132,7 +132,7 @@ void TouchesPerformTest1::ccTouchCancelled(CCTouch* touch, CCEvent* event) void TouchesPerformTest2::onEnter() { TouchesMainScene::onEnter(); - setIsTouchEnabled(true); + setTouchEnabled(true); } std::string TouchesPerformTest2::title() diff --git a/tests/tests/RenderTextureTest/RenderTextureTest.cpp b/tests/tests/RenderTextureTest/RenderTextureTest.cpp index 86c78cbf84..b156546d3f 100644 --- a/tests/tests/RenderTextureTest/RenderTextureTest.cpp +++ b/tests/tests/RenderTextureTest/RenderTextureTest.cpp @@ -142,7 +142,7 @@ RenderTextureSave::RenderTextureSave() m_pBrush->retain(); m_pBrush->setColor(ccRED); m_pBrush->setOpacity(20); - this->setIsTouchEnabled(true); + this->setTouchEnabled(true); // Save Image menu CCMenuItemFont::setFontSize(16); @@ -329,7 +329,7 @@ void RenderTextureScene::runThisTest() RenderTextureZbuffer::RenderTextureZbuffer() { - this->setIsTouchEnabled(true); + this->setTouchEnabled(true); CCSize size = CCDirector::sharedDirector()->getWinSize(); CCLabelTTF *label = CCLabelTTF::create("vertexZ = 50", "Marker Felt", 64); label->setPosition(ccp(size.width / 2, size.height * 0.25f)); diff --git a/tests/tests/RotateWorldTest/RotateWorldTest.cpp b/tests/tests/RotateWorldTest/RotateWorldTest.cpp index da77ac5535..db97d16360 100644 --- a/tests/tests/RotateWorldTest/RotateWorldTest.cpp +++ b/tests/tests/RotateWorldTest/RotateWorldTest.cpp @@ -108,7 +108,7 @@ void RotateWorldMainLayer::onEnter() white->setScale(0.5f); white->setPosition(ccp(x/4,y/4)); - white->setIgnoreAnchorPointForPosition(false); + white->ignoreAnchorPointForPosition(false); white->setPosition(ccp(x/4*3,y/4*3)); addChild(blue, -1); diff --git a/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id b/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id index 9ee094da2e..5667da698f 100644 --- a/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id +++ b/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id @@ -1 +1 @@ -23a3acf70514939732acc9dab32c55a9bfddbc46 \ No newline at end of file +7c5d19797ef70af4121f85f8e97926b1f42a3705 \ No newline at end of file diff --git a/tests/tests/TextInputTest/TextInputTest.cpp b/tests/tests/TextInputTest/TextInputTest.cpp index 388f764f58..741be22ec3 100644 --- a/tests/tests/TextInputTest/TextInputTest.cpp +++ b/tests/tests/TextInputTest/TextInputTest.cpp @@ -152,7 +152,7 @@ void TextInputTest::onEnter() KeyboardNotificationLayer::KeyboardNotificationLayer() : m_pTrackNode(0) { - setIsTouchEnabled(true); + setTouchEnabled(true); } void KeyboardNotificationLayer::registerWithTouchDispatcher() diff --git a/tests/tests/TileMapTest/TileMapTest.cpp b/tests/tests/TileMapTest/TileMapTest.cpp index aee87bfff1..334ccddbc6 100644 --- a/tests/tests/TileMapTest/TileMapTest.cpp +++ b/tests/tests/TileMapTest/TileMapTest.cpp @@ -1429,7 +1429,7 @@ CCLayer* restartTileMapAction() TileDemo::TileDemo(void) { - setIsTouchEnabled( true ); + setTouchEnabled( true ); CCSize s = CCDirector::sharedDirector()->getWinSize(); diff --git a/tests/tests/controller.cpp b/tests/tests/controller.cpp index b69ebac2b8..d5d3ebddeb 100644 --- a/tests/tests/controller.cpp +++ b/tests/tests/controller.cpp @@ -159,7 +159,7 @@ TestController::TestController() m_pItemMenu->setPosition(s_tCurPos); addChild(m_pItemMenu); - setIsTouchEnabled(true); + setTouchEnabled(true); addChild(pMenu, 1); From c17091ac7050dea97aa1a671fd9668fe8bc01521 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 15 Jun 2012 15:24:22 +0800 Subject: [PATCH 189/257] fixed #1310: Updated vs2010 project configuration after synchronizing to rc2. --- cocos2dx/proj.win32/cocos2d-win32.vcxproj | 44 +++++- .../proj.win32/cocos2d-win32.vcxproj.filters | 138 +++++++++++++++--- .../cocos2d_generated.cpp.REMOVED.git-id | 2 +- .../Templates/1033/Templates.inf | 5 +- tests/proj.win32/test.win32.vcxproj | 18 ++- tests/proj.win32/test.win32.vcxproj.filters | 52 ++++--- 6 files changed, 207 insertions(+), 52 deletions(-) diff --git a/cocos2dx/proj.win32/cocos2d-win32.vcxproj b/cocos2dx/proj.win32/cocos2d-win32.vcxproj index d15885d496..48922d00c3 100755 --- a/cocos2dx/proj.win32/cocos2d-win32.vcxproj +++ b/cocos2dx/proj.win32/cocos2d-win32.vcxproj @@ -132,6 +132,7 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ + @@ -152,7 +153,6 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ - @@ -163,8 +163,23 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ - - + + + + + + + + + + + + + + + + + @@ -241,6 +256,7 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ + @@ -264,6 +280,7 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ + @@ -284,7 +301,6 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ - @@ -295,8 +311,26 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ - + + + + + + + + + + + + + + + + + + + diff --git a/cocos2dx/proj.win32/cocos2d-win32.vcxproj.filters b/cocos2dx/proj.win32/cocos2d-win32.vcxproj.filters index b815d74410..1ad962d5bc 100755 --- a/cocos2dx/proj.win32/cocos2d-win32.vcxproj.filters +++ b/cocos2dx/proj.win32/cocos2d-win32.vcxproj.filters @@ -180,9 +180,6 @@ cocoa - - cocoa - cocoa @@ -480,15 +477,66 @@ extensions\CCListView - - extensions\CCBReader - - - extensions\CCBReader - platform\win32 + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + support\data_support + + + actions + @@ -569,9 +617,6 @@ cocoa - - cocoa - cocoa @@ -976,14 +1021,71 @@ extensions\CCListView - - extensions\CCBReader - - - extensions\CCBReader - platform\win32 + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + extensions\CCBReader + + + actions + \ No newline at end of file diff --git a/js/JSBindings/cocos2d_generated.cpp.REMOVED.git-id b/js/JSBindings/cocos2d_generated.cpp.REMOVED.git-id index ad4a4ea0fa..00cf46e3b8 100644 --- a/js/JSBindings/cocos2d_generated.cpp.REMOVED.git-id +++ b/js/JSBindings/cocos2d_generated.cpp.REMOVED.git-id @@ -1 +1 @@ -83e960279cac86d7cb43efbfa0f4445bf6b4f2b5 \ No newline at end of file +80e25f0506e93a93d244735fd6deb92cec8055d2 \ No newline at end of file diff --git a/template/msvc/CCAppWiz.win32/Templates/1033/Templates.inf b/template/msvc/CCAppWiz.win32/Templates/1033/Templates.inf index 21af41c984..38ad3870a1 100644 --- a/template/msvc/CCAppWiz.win32/Templates/1033/Templates.inf +++ b/template/msvc/CCAppWiz.win32/Templates/1033/Templates.inf @@ -40,5 +40,6 @@ Resources/CloseSelected.png Resources/CloseNormal.png Resources/HelloWorld.png [! endif] -Resources/fps_images.fnt -Resources/fps_images.png \ No newline at end of file +Resources/fps_images.png +Resources/fps_images-hd.png +Resources/fps_images-ipadhd.png diff --git a/tests/proj.win32/test.win32.vcxproj b/tests/proj.win32/test.win32.vcxproj index e3dd681dd5..900f6aca6d 100644 --- a/tests/proj.win32/test.win32.vcxproj +++ b/tests/proj.win32/test.win32.vcxproj @@ -125,9 +125,13 @@ - + + - + + + + @@ -174,7 +178,6 @@ - @@ -205,9 +208,13 @@ - + + - + + + + @@ -292,7 +299,6 @@ - diff --git a/tests/proj.win32/test.win32.vcxproj.filters b/tests/proj.win32/test.win32.vcxproj.filters index 75bc255de4..92df584143 100644 --- a/tests/proj.win32/test.win32.vcxproj.filters +++ b/tests/proj.win32/test.win32.vcxproj.filters @@ -82,9 +82,6 @@ {4221f5af-c188-4880-84f4-6fdd49407dca} - - {af973cd5-e645-4f37-abde-df2d2ad84846} - {cc2c4496-ec68-430b-b640-cd34bf6ed005} @@ -112,9 +109,6 @@ {858c5109-0abf-42db-9fa8-33d44063c1af} - - {4621182d-8908-4538-9b77-9e1da1233300} - {193709f6-8330-4eac-bda3-ff56f4c57e6c} @@ -270,9 +264,6 @@ classes\tests\EffectsAdvancedTest - - classes\tests\HiResTest - classes\tests\KeypadTest @@ -342,9 +333,6 @@ classes\tests\BugsTest\Bug-458 - - classes\tests\DirectorTest - classes\tests\Texture2DTest @@ -402,10 +390,25 @@ classes\tests\MutiTouchTest + + classes\tests\ExtensionsTest\CocosBuilderTest + + + classes\tests\ExtensionsTest\CocosBuilderTest + classes\tests\ExtensionsTest\CocosBuilderTest - + + classes\tests\ExtensionsTest\CocosBuilderTest + + + classes\tests\ExtensionsTest\CocosBuilderTest + + + classes\tests\ExtensionsTest\CocosBuilderTest + + classes\tests\ExtensionsTest\CocosBuilderTest @@ -620,9 +623,6 @@ classes\tests\EffectsAdvancedTest - - classes\tests\HiResTest - classes\tests\KeypadTest @@ -692,9 +692,6 @@ classes\tests\BugsTest\Bug-458 - - classes\tests\DirectorTest - classes\tests\Texture2DTest @@ -752,10 +749,25 @@ classes\tests\MutiTouchTest + + classes\tests\ExtensionsTest\CocosBuilderTest + + + classes\tests\ExtensionsTest\CocosBuilderTest + classes\tests\ExtensionsTest\CocosBuilderTest - + + classes\tests\ExtensionsTest\CocosBuilderTest + + + classes\tests\ExtensionsTest\CocosBuilderTest + + + classes\tests\ExtensionsTest\CocosBuilderTest + + classes\tests\ExtensionsTest\CocosBuilderTest From e7628de8570d44d6564a85d66da94081fcf1d09e Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 15 Jun 2012 15:36:36 +0800 Subject: [PATCH 190/257] fixed a warning in CCScale9Sprite::initWithBatchNode. --- cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp index 13129f0654..fde1a2233f 100644 --- a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp @@ -43,7 +43,7 @@ bool CCScale9Sprite::initWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect } this->m_positionsAreDirty = true; - return this; + return true; } bool CCScale9Sprite::updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect rect, CCRect capInsets) From 595a402c83897cbcae7d1982f259492c9bbdbc9a Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 15 Jun 2012 16:47:30 +0800 Subject: [PATCH 191/257] fixed #1292:make some function names more readable. --- cocos2dx/base_nodes/CCNode.h | 7 ++-- .../extensions/CCBReader/CCControlLoader.cpp | 4 +-- .../CCBReader/CCLayerGradientLoader.cpp | 2 +- .../extensions/CCBReader/CCLayerLoader.cpp | 2 +- .../extensions/CCBReader/CCMenuItemLoader.cpp | 2 +- .../CCControlExtension/CCControl.cpp | 32 ++++++++++++++++++- .../extensions/CCControlExtension/CCControl.h | 21 ++++++++---- .../CCControlExtension/CCControlButton.cpp | 28 ++++++++-------- .../CCControlExtension/CCControlButton.h | 6 ++-- .../CCControlExtension/CCControlSwitch.cpp | 4 +-- .../CCControlExtension/CCControlSwitch.h | 4 +-- .../CCControlExtension/CCScale9Sprite.cpp | 2 +- cocos2dx/extensions/CCListView/CCListView.cpp | 4 +-- cocos2dx/extensions/CCListView/CCListView.h | 4 +-- cocos2dx/label_nodes/CCLabelBMFont.cpp | 2 +- .../CCLayer.cpp | 6 ++-- .../layers_scenes_transitions_nodes/CCLayer.h | 6 +++- cocos2dx/menu_nodes/CCMenuItem.cpp | 16 +++++----- cocos2dx/menu_nodes/CCMenuItem.h | 15 +++++---- cocos2dx/particle_nodes/CCParticleSystem.cpp | 10 +++--- cocos2dx/particle_nodes/CCParticleSystem.h | 7 +++- cocos2dx/platform/CCFileUtils.h | 4 +-- cocos2dx/platform/CCFileUtilsCommon_cpp.h | 4 +-- cocos2dx/platform/win32/CCFileUtils.cpp | 2 +- cocos2dx/script_support/CCScriptSupport.h | 2 +- cocos2dx/sprite_nodes/CCSprite.cpp | 2 +- cocos2dx/sprite_nodes/CCSprite.h | 2 +- .../tests/ActionsEaseTest/ActionsEaseTest.cpp | 2 +- tests/tests/ActionsTest/ActionsTest.cpp | 20 ++++++------ .../CCControlSwitchTest.cpp | 2 +- tests/tests/LabelTest/LabelTest.cpp | 6 ++-- tests/tests/LayerTest/LayerTest.cpp | 2 +- tests/tests/MenuTest/MenuTest.cpp | 16 +++++----- tests/tests/ParticleTest/ParticleTest.cpp | 2 +- .../PerformanceNodeChildrenTest.cpp | 6 ++-- .../SpriteTest/SpriteTest.cpp.REMOVED.git-id | 2 +- tests/tests/Texture2dTest/Texture2dTest.cpp | 4 +-- 37 files changed, 157 insertions(+), 105 deletions(-) diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index f5977ef97e..317c52adfb 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -196,9 +196,12 @@ class CC_DLL CCNode : public CCObject CC_PROPERTY(CCGridBase *, m_pGrid, Grid) /** Whether of not the node is visible. Default is true */ +protected: bool m_bIsVisible; - bool isVisible(); - void setVisible(bool visible); +public: + virtual bool isVisible(); + virtual void setVisible(bool visible); + /** anchorPoint is the point around which all transformations and positioning manipulations take place. It's like a pin in the node where it is "attached" to its parent. diff --git a/cocos2dx/extensions/CCBReader/CCControlLoader.cpp b/cocos2dx/extensions/CCBReader/CCControlLoader.cpp index 7be8f8d5ba..a1ce3791b2 100644 --- a/cocos2dx/extensions/CCBReader/CCControlLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCControlLoader.cpp @@ -9,9 +9,9 @@ USING_NS_CC_EXT; void CCControlLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader) { if(strcmp(pPropertyName, PROPERTY_ENABLED) == 0) { - ((CCControl *)pNode)->setIsEnabled(pCheck); + ((CCControl *)pNode)->setEnabled(pCheck); } else if(strcmp(pPropertyName, PROPERTY_SELECTED) == 0) { - ((CCControl *)pNode)->setIsSelected(pCheck); + ((CCControl *)pNode)->setSelected(pCheck); } else { CCNodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader); } diff --git a/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.cpp b/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.cpp index 596c491ae3..944e95dd00 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.cpp @@ -48,7 +48,7 @@ void CCLayerGradientLoader::onHandlePropTypePoint(CCNode * pNode, CCNode * pPare ((CCLayerGradient *)pNode)->setVector(pPoint); // TODO Not passed along the ccbi file. - // ((CCLayerGradient *)pNode)->setIsCompressedInterpolation(true); + // ((CCLayerGradient *)pNode)->setCompressedInterpolation(true); } else { CCLayerLoader::onHandlePropTypePoint(pNode, pParent, pPropertyName, pPoint, pCCBReader); } diff --git a/cocos2dx/extensions/CCBReader/CCLayerLoader.cpp b/cocos2dx/extensions/CCBReader/CCLayerLoader.cpp index 025708bf01..27bde8f263 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCLayerLoader.cpp @@ -23,7 +23,7 @@ void CCLayerLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, cons } else if(strcmp(pPropertyName, PROPERTY_KEYBOARD_ENABLED) == 0) { // TODO XXX CCLOG("The property '%s' is not supported!", PROPERTY_KEYBOARD_ENABLED); - // This comes closest: ((CCLayer *)pNode)->setIsKeypadEnabled(pCheck); + // This comes closest: ((CCLayer *)pNode)->setKeypadEnabled(pCheck); } else { CCNodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader); } diff --git a/cocos2dx/extensions/CCBReader/CCMenuItemLoader.cpp b/cocos2dx/extensions/CCBReader/CCMenuItemLoader.cpp index 478f730b2e..eadabc16f1 100644 --- a/cocos2dx/extensions/CCBReader/CCMenuItemLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCMenuItemLoader.cpp @@ -16,7 +16,7 @@ void CCMenuItemLoader::onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, c void CCMenuItemLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, const char * pPropertyName, bool pCheck, CCBReader * pCCBReader) { if(strcmp(pPropertyName, PROPERTY_ISENABLED) == 0) { - ((CCMenuItem *)pNode)->setIsEnabled(pCheck); + ((CCMenuItem *)pNode)->setEnabled(pCheck); } else { CCNodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader); } diff --git a/cocos2dx/extensions/CCControlExtension/CCControl.cpp b/cocos2dx/extensions/CCControlExtension/CCControl.cpp index a11e5598a6..a7f50ead50 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControl.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControl.cpp @@ -43,7 +43,7 @@ bool CCControl::init() { if (CCLayer::init()) { - //this->setIsTouchEnabled(true); + //this->setTouchEnabled(true); //m_bIsTouchEnabled=true; // Initialise instance variables m_nState=CCControlStateNormal; @@ -299,4 +299,34 @@ CCArray* CCControl::dispatchListforControlEvent(CCControlEvent controlEvent) return invocationList; } +void CCControl::setEnabled(bool bEnabled) +{ + m_bEnabled = bEnabled; +} + +bool CCControl::isEnabled() +{ + return m_bEnabled; +} + +void CCControl::setSelected(bool bSelected) +{ + m_bSelected = bSelected; +} + +bool CCControl::isSelected() +{ + return m_bSelected; +} + +void CCControl::setHighlighted(bool bHighlighted) +{ + m_bHighlighted = bHighlighted; +} + +bool CCControl::isHighlighted() +{ + return m_bHighlighted; +} + NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCControlExtension/CCControl.h b/cocos2dx/extensions/CCControlExtension/CCControl.h index 620d29acd8..65705c269e 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControl.h +++ b/cocos2dx/extensions/CCControlExtension/CCControl.h @@ -92,14 +92,23 @@ class CC_DLL CCControl : public CCLayer, public CCRGBAProtocol CC_SYNTHESIZE(int, m_nDefaultTouchPriority, DefaultTouchPriority); /** The current control state constant. */ CC_SYNTHESIZE_READONLY(CCControlState, m_nState, State); + +public: /** Tells whether the control is enabled. */ - CC_SYNTHESIZE(bool, m_bEnabled, IsEnabled); - /** A Boolean value that determines the control’s selected state. */ - CC_SYNTHESIZE(bool, m_bSelected, IsSelected); + virtual void setEnabled(bool bEnabled); + virtual bool isEnabled(); + /** A Boolean value that determines the control selected state. */ + virtual void setSelected(bool bSelected); + virtual bool isSelected(); /** A Boolean value that determines whether the control is highlighted. */ - CC_SYNTHESIZE(bool, m_bHighlighted, IsHighlighted); - - protected: + virtual void setHighlighted(bool bHighlighted); + virtual bool isHighlighted(); + +protected: + bool m_bEnabled; + bool m_bSelected; + bool m_bHighlighted; + // CCControlState, CCArray CCDictionary* dispatchTable; diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp index ac3005e8ff..871456868e 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp @@ -190,21 +190,21 @@ void CCControlButton::setMargins(int marginH, int marginV) needsLayout(); } -void CCControlButton::setIsEnabled(bool enabled) +void CCControlButton::setEnabled(bool enabled) { - CCControl::setIsEnabled(enabled); + CCControl::setEnabled(enabled); needsLayout(); } -void CCControlButton::setIsSelected(bool enabled) +void CCControlButton::setSelected(bool enabled) { - CCControl::setIsSelected(enabled); + CCControl::setSelected(enabled); needsLayout(); } -void CCControlButton::setIsHighlighted(bool enabled) +void CCControlButton::setHighlighted(bool enabled) { - CCControl::setIsHighlighted(enabled); + CCControl::setHighlighted(enabled); CCAction *action =getActionByTag(kZoomActionTag); if (action) @@ -214,7 +214,7 @@ void CCControlButton::setIsHighlighted(bool enabled) needsLayout(); if( m_zoomOnTouchDown ) { - float scaleValue = (getIsHighlighted() && getIsEnabled() && !getIsSelected()) ? 1.1f : 1.0f; + float scaleValue = (isHighlighted() && isEnabled() && !isSelected()) ? 1.1f : 1.0f; CCAction *zoomAction =CCScaleTo::create(0.05f, scaleValue); zoomAction->setTag(kZoomActionTag); runAction(zoomAction); @@ -553,14 +553,14 @@ void CCControlButton::needsLayout() bool CCControlButton::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent) { - if (!isTouchInside(pTouch) || !getIsEnabled()) + if (!isTouchInside(pTouch) || !isEnabled()) { return false; } m_nState=CCControlStateHighlighted; pushed=true; - this->setIsHighlighted(true); + this->setHighlighted(true); sendActionsForControlEvents(CCControlEventTouchDown); return true; } @@ -571,7 +571,7 @@ void CCControlButton::ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent) { if (m_bHighlighted) { - setIsHighlighted(false); + setHighlighted(false); } return; } @@ -580,7 +580,7 @@ void CCControlButton::ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent) if (isTouchMoveInside && !m_bHighlighted) { m_nState = CCControlStateHighlighted; - setIsHighlighted(true); + setHighlighted(true); sendActionsForControlEvents(CCControlEventTouchDragEnter); } else if (isTouchMoveInside && m_bHighlighted) @@ -590,7 +590,7 @@ void CCControlButton::ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent) else if (!isTouchMoveInside && m_bHighlighted) { m_nState = CCControlStateNormal; - setIsHighlighted(false); + setHighlighted(false); sendActionsForControlEvents(CCControlEventTouchDragExit); } @@ -603,7 +603,7 @@ void CCControlButton::ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent) { m_nState = CCControlStateNormal; pushed = false; - setIsHighlighted(false); + setHighlighted(false); if (isTouchInside(pTouch)) @@ -647,7 +647,7 @@ void CCControlButton::ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent) { m_nState = CCControlStateNormal; pushed = false; - setIsHighlighted(false); + setHighlighted(false); sendActionsForControlEvents(CCControlEventTouchCancel); } diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.h b/cocos2dx/extensions/CCControlExtension/CCControlButton.h index e9ff4c73dd..39f704889a 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.h @@ -42,9 +42,9 @@ public: virtual ~CCControlButton(); virtual void needsLayout(void); - virtual void setIsEnabled(bool enabled); - virtual void setIsSelected(bool enabled); - virtual void setIsHighlighted(bool enabled); + virtual void setEnabled(bool enabled); + virtual void setSelected(bool enabled); + virtual void setHighlighted(bool enabled); protected: // CCRGBAProtocol //bool m_bIsOpacityModifyRGB; diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp index 2260ef67bc..9a1aa977ff 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.cpp @@ -364,7 +364,7 @@ void CCControlSwitch::setOn(bool isOn, bool animated) sendActionsForControlEvents(CCControlEventValueChanged); } -void CCControlSwitch::setIsEnabled(bool enabled) +void CCControlSwitch::setEnabled(bool enabled) { m_bEnabled = enabled; @@ -383,7 +383,7 @@ CCPoint CCControlSwitch::locationFromTouch(CCTouch* pTouch) bool CCControlSwitch::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent) { if (!this->isTouchInside(pTouch) - || !this->getIsEnabled()) + || !this->isEnabled()) { return false; } diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.h b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.h index ecfe426260..45ba0d7ca7 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.h @@ -77,9 +77,9 @@ public: */ void setOn(bool isOn, bool animated); void setOn(bool isOn); - bool getIsOn(void) { return m_bOn; } + bool isOn(void) { return m_bOn; } bool hasMoved() { return m_bMoved; } - void setIsEnabled(bool enabled); + virtual void setEnabled(bool enabled); CCPoint locationFromTouch(CCTouch* touch); //events diff --git a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp index fde1a2233f..7a7964c3e8 100644 --- a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp @@ -589,7 +589,7 @@ void CCScale9Sprite::setOpacityModifyRGB(bool var) // CCRGBAProtocol *pRGBAProtocol = (CCRGBAProtocol *)pNode; // if (pRGBAProtocol) // { - // pRGBAProtocol->setIsOpacityModifyRGB(m_bIsOpacityModifyRGB); + // pRGBAProtocol->setOpacityModifyRGB(m_bIsOpacityModifyRGB); // } //} } diff --git a/cocos2dx/extensions/CCListView/CCListView.cpp b/cocos2dx/extensions/CCListView/CCListView.cpp index 8402fdc00a..205323cb24 100644 --- a/cocos2dx/extensions/CCListView/CCListView.cpp +++ b/cocos2dx/extensions/CCListView/CCListView.cpp @@ -984,7 +984,7 @@ void CCListView::finishFix(void) { if(m_pListViewParent) { - m_pListViewParent->setIsEnabled(true); + m_pListViewParent->setEnabled(true); } m_nState = CCListViewStateWatting; m_nSlideDir = CCListViewSlideDirNone; @@ -2026,7 +2026,7 @@ void CCListView::ccTouchMoved(CCTouch* touch, CCEvent* event) if (CCListViewSlideDirNone != m_nSlideDir && m_pListViewParent) { - m_pListViewParent->setIsEnabled(false); + m_pListViewParent->setEnabled(false); } } diff --git a/cocos2dx/extensions/CCListView/CCListView.h b/cocos2dx/extensions/CCListView/CCListView.h index 913f79e875..7f00ef93db 100644 --- a/cocos2dx/extensions/CCListView/CCListView.h +++ b/cocos2dx/extensions/CCListView/CCListView.h @@ -148,8 +148,8 @@ public: inline void setListViewParent(CCListView *pParent) { m_pListViewParent = pParent; } inline CCListView *getListViewParent(void) { return m_pListViewParent; } - inline void setIsEnabled(bool bEnabled) { m_bIsEnabled = bEnabled; } - inline bool getIsEnabled(void) { return m_bIsEnabled; } + inline void setEnabled(bool bEnabled) { m_bIsEnabled = bEnabled; } + inline bool isEnabled(void) { return m_bIsEnabled; } // un void setDelegate(const CCListViewDelegate *pDelegate) { m_pDelegate = const_cast(pDelegate);} diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index 5b46a69768..8167357579 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -911,7 +911,7 @@ void CCLabelBMFont::createFontChars() fontChar->setTextureRect(rect, false, rect.size); // restore to default in case they were modified - fontChar->setIsVisible(true); + fontChar->setVisible(true); fontChar->setOpacity(255); } diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index 3889bd96a6..dbea7251dd 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -100,7 +100,7 @@ void CCLayer::registerWithTouchDispatcher() CCDirector* pDirector = CCDirector::sharedDirector(); if (m_pScriptHandlerEntry) { - if (m_pScriptHandlerEntry->getIsMultiTouches()) + if (m_pScriptHandlerEntry->isMultiTouches()) { pDirector->getTouchDispatcher()->addStandardDelegate(this, 0); LUALOG("[LUA] Add multi-touches event handler: %d", m_pScriptHandlerEntry->getHandler()); @@ -722,12 +722,12 @@ const CCPoint& CCLayerGradient::getVector() return m_AlongVector; } -bool CCLayerGradient::getIsCompressedInterpolation() +bool CCLayerGradient::isCompressedInterpolation() { return m_bCompressedInterpolation; } -void CCLayerGradient::setIsCompressedInterpolation(bool compress) +void CCLayerGradient::setCompressedInterpolation(bool compress) { m_bCompressedInterpolation = compress; updateColor(); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h index 6e596864ed..21745e4bc7 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h @@ -324,7 +324,11 @@ public: /** Whether or not the interpolation will be compressed in order to display all the colors of the gradient both in canonical and non canonical vectors Default: YES */ - CC_PROPERTY(bool, m_bCompressedInterpolation, IsCompressedInterpolation) +protected: + bool m_bCompressedInterpolation; +public: + virtual void setCompressedInterpolation(bool bCompressedInterpolation); + virtual bool isCompressedInterpolation(); // @warning: This interface will be deprecated in future. LAYER_NODE_FUNC(CCLayerGradient) diff --git a/cocos2dx/menu_nodes/CCMenuItem.cpp b/cocos2dx/menu_nodes/CCMenuItem.cpp index 54618528be..17a7e65aad 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.cpp +++ b/cocos2dx/menu_nodes/CCMenuItem.cpp @@ -119,7 +119,7 @@ void CCMenuItem::activate() } } -void CCMenuItem::setIsEnabled(bool enabled) +void CCMenuItem::setEnabled(bool enabled) { m_bIsEnabled = enabled; } @@ -271,7 +271,7 @@ void CCMenuItemLabel::unselected() } } -void CCMenuItemLabel::setIsEnabled(bool enabled) +void CCMenuItemLabel::setEnabled(bool enabled) { if( m_bIsEnabled != enabled ) { @@ -285,7 +285,7 @@ void CCMenuItemLabel::setIsEnabled(bool enabled) dynamic_cast(m_pLabel)->setColor(m_tColorBackup); } } - CCMenuItem::setIsEnabled(enabled); + CCMenuItem::setEnabled(enabled); } void CCMenuItemLabel::setOpacity(GLubyte opacity) @@ -658,11 +658,11 @@ void CCMenuItemSprite::unselected() } } -void CCMenuItemSprite::setIsEnabled(bool bEnabled) +void CCMenuItemSprite::setEnabled(bool bEnabled) { if( m_bIsEnabled != bEnabled ) { - CCMenuItem::setIsEnabled(bEnabled); + CCMenuItem::setEnabled(bEnabled); this->updateImagesVisibility(); } } @@ -937,11 +937,11 @@ void CCMenuItemToggle::activate() } CCMenuItem::activate(); } -void CCMenuItemToggle::setIsEnabled(bool enabled) +void CCMenuItemToggle::setEnabled(bool enabled) { if (m_bIsEnabled != enabled) { - CCMenuItem::setIsEnabled(enabled); + CCMenuItem::setEnabled(enabled); if(m_pSubItems && m_pSubItems->count() > 0) { @@ -949,7 +949,7 @@ void CCMenuItemToggle::setIsEnabled(bool enabled) CCARRAY_FOREACH(m_pSubItems, pObj) { CCMenuItem* pItem = (CCMenuItem*)pObj; - pItem->setIsEnabled(enabled); + pItem->setEnabled(enabled); } } } diff --git a/cocos2dx/menu_nodes/CCMenuItem.h b/cocos2dx/menu_nodes/CCMenuItem.h index 7a947b7f9f..d845708ab0 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.h +++ b/cocos2dx/menu_nodes/CCMenuItem.h @@ -81,9 +81,10 @@ public: virtual void registerScriptHandler(int nHandler); virtual void unregisterScriptHandler(void); - bool isEnabled(); - void setIsEnabled(bool value); - bool isSelected(); + virtual bool isEnabled(); + //@note: It's 'setIsEnable' in cocos2d-iphone. + virtual void setEnabled(bool value); + virtual bool isSelected(); /** set the target/selector of the menu item*/ void setTarget(CCObject *rec, SEL_MenuHandler selector); @@ -135,9 +136,9 @@ public: virtual void selected(); virtual void unselected(); /** Enable or disabled the CCMenuItemFont - @warning setIsEnabled changes the RGB color of the font + @warning setEnabled changes the RGB color of the font */ - virtual void setIsEnabled(bool enabled); + virtual void setEnabled(bool enabled); virtual void setOpacity(GLubyte opacity); virtual GLubyte getOpacity(); virtual void setColor(const ccColor3B& color); @@ -287,7 +288,7 @@ public: */ virtual void selected(); virtual void unselected(); - virtual void setIsEnabled(bool bEnabled); + virtual void setEnabled(bool bEnabled); virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} virtual bool isOpacityModifyRGB(void) { return false;} @@ -408,7 +409,7 @@ public: virtual void activate(); virtual void selected(); virtual void unselected(); - virtual void setIsEnabled(bool var); + virtual void setEnabled(bool var); virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} virtual bool isOpacityModifyRGB(void) { return false;} diff --git a/cocos2dx/particle_nodes/CCParticleSystem.cpp b/cocos2dx/particle_nodes/CCParticleSystem.cpp index 53c66cb460..a0c4416d0d 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystem.cpp @@ -288,12 +288,12 @@ bool CCParticleSystem::initWithDictionary(CCDictionary *dictionary) if (strlen(textureName) > 0) { // set not pop-up message box when load image failed - bool bNotify = CCFileUtils::sharedFileUtils()->getIsPopupNotify(); - CCFileUtils::sharedFileUtils()->setIsPopupNotify(false); + bool bNotify = CCFileUtils::sharedFileUtils()->isPopupNotify(); + CCFileUtils::sharedFileUtils()->popupNotify(false); tex = CCTextureCache::sharedTextureCache()->addImage(fullpath.c_str()); // reset the value of UIImage notify - CCFileUtils::sharedFileUtils()->setIsPopupNotify(bNotify); + CCFileUtils::sharedFileUtils()->popupNotify(bNotify); } if (tex) @@ -1211,12 +1211,12 @@ void CCParticleSystem::setPositionType(tCCPositionType var) m_ePositionType = var; } -bool CCParticleSystem::getIsAutoRemoveOnFinish() +bool CCParticleSystem::isAutoRemoveOnFinish() { return m_bIsAutoRemoveOnFinish; } -void CCParticleSystem::setIsAutoRemoveOnFinish(bool var) +void CCParticleSystem::setAutoRemoveOnFinish(bool var) { m_bIsAutoRemoveOnFinish = var; } diff --git a/cocos2dx/particle_nodes/CCParticleSystem.h b/cocos2dx/particle_nodes/CCParticleSystem.h index cdbe7bd227..66bb385492 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.h +++ b/cocos2dx/particle_nodes/CCParticleSystem.h @@ -347,7 +347,12 @@ public: By default it is false. @since v0.8 */ - CC_PROPERTY(bool, m_bIsAutoRemoveOnFinish, IsAutoRemoveOnFinish) +protected: + bool m_bIsAutoRemoveOnFinish; +public: + virtual bool isAutoRemoveOnFinish(); + virtual void setAutoRemoveOnFinish(bool var); + /** Switch between different kind of emitter modes: - kCCParticleModeGravity: uses gravity, speed, radial and tangential acceleration - kCCParticleModeRadius: uses radius movement + rotation diff --git a/cocos2dx/platform/CCFileUtils.h b/cocos2dx/platform/CCFileUtils.h index 5d3250959c..2b5221f696 100644 --- a/cocos2dx/platform/CCFileUtils.h +++ b/cocos2dx/platform/CCFileUtils.h @@ -157,8 +157,8 @@ public: /** @brief Set/Get whether pop-up a message box when the image load failed */ - void setIsPopupNotify(bool bNotify); - bool getIsPopupNotify(); + void popupNotify(bool bNotify); + bool isPopupNotify(); }; NS_CC_END diff --git a/cocos2dx/platform/CCFileUtilsCommon_cpp.h b/cocos2dx/platform/CCFileUtilsCommon_cpp.h index 1f31c569f3..8949907144 100644 --- a/cocos2dx/platform/CCFileUtilsCommon_cpp.h +++ b/cocos2dx/platform/CCFileUtilsCommon_cpp.h @@ -442,12 +442,12 @@ bool CCFileUtils::iPhoneRetinaDisplayFileExistsAtPath(const char *filename) ////////////////////////////////////////////////////////////////////////// static bool s_bPopupNotify = true; -void CCFileUtils::setIsPopupNotify(bool bNotify) +void CCFileUtils::popupNotify(bool bNotify) { s_bPopupNotify = bNotify; } -bool CCFileUtils::getIsPopupNotify() +bool CCFileUtils::isPopupNotify() { return s_bPopupNotify; } diff --git a/cocos2dx/platform/win32/CCFileUtils.cpp b/cocos2dx/platform/win32/CCFileUtils.cpp index 73105bc103..87ee6ef4ed 100644 --- a/cocos2dx/platform/win32/CCFileUtils.cpp +++ b/cocos2dx/platform/win32/CCFileUtils.cpp @@ -208,7 +208,7 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz fclose(fp); } while (0); - if (! pBuffer && getIsPopupNotify()) + if (! pBuffer && isPopupNotify()) { std::string title = "Notification"; std::string msg = "Get data from file("; diff --git a/cocos2dx/script_support/CCScriptSupport.h b/cocos2dx/script_support/CCScriptSupport.h index d7c1494897..f9bf9816b7 100644 --- a/cocos2dx/script_support/CCScriptSupport.h +++ b/cocos2dx/script_support/CCScriptSupport.h @@ -86,7 +86,7 @@ public: return m_nHandler; } - inline bool getIsMultiTouches(void) { + inline bool isMultiTouches(void) { return m_bIsMultiTouches; } diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index f1ffd31921..e0525895e0 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -858,7 +858,7 @@ void CCSprite::ignoreAnchorPointForPosition(bool value) CCNode::ignoreAnchorPointForPosition(value); } -void CCSprite::setIsVisible(bool bVisible) +void CCSprite::setVisible(bool bVisible) { CCNode::setVisible(bVisible); SET_DIRTY_RECURSIVELY(); diff --git a/cocos2dx/sprite_nodes/CCSprite.h b/cocos2dx/sprite_nodes/CCSprite.h index a71e3b4944..1e52ed4c46 100644 --- a/cocos2dx/sprite_nodes/CCSprite.h +++ b/cocos2dx/sprite_nodes/CCSprite.h @@ -222,7 +222,7 @@ public: virtual void setVertexZ(float fVertexZ); virtual void setAnchorPoint(const CCPoint& anchor); virtual void ignoreAnchorPointForPosition(bool value); - virtual void setIsVisible(bool bVisible); + virtual void setVisible(bool bVisible); void setFlipX(bool bFlipX); void setFlipY(bool bFlipY); /** whether or not the sprite is flipped horizontally. diff --git a/tests/tests/ActionsEaseTest/ActionsEaseTest.cpp b/tests/tests/ActionsEaseTest/ActionsEaseTest.cpp index 1519ef1655..333af20dfb 100644 --- a/tests/tests/ActionsEaseTest/ActionsEaseTest.cpp +++ b/tests/tests/ActionsEaseTest/ActionsEaseTest.cpp @@ -621,7 +621,7 @@ void EaseSpriteDemo::positionForTwo() m_grossini->setPosition(CCPointMake(60, s.height*1/5)); m_tamara->setPosition(CCPointMake( 60, s.height*4/5)); - m_kathia->setIsVisible(false); + m_kathia->setVisible(false); } diff --git a/tests/tests/ActionsTest/ActionsTest.cpp b/tests/tests/ActionsTest/ActionsTest.cpp index 9973061b8c..c9ea475e42 100644 --- a/tests/tests/ActionsTest/ActionsTest.cpp +++ b/tests/tests/ActionsTest/ActionsTest.cpp @@ -238,21 +238,21 @@ void ActionsDemo::centerSprites(unsigned int numberOfSprites) if( numberOfSprites == 0 ) { - m_tamara->setIsVisible(false); - m_kathia->setIsVisible(false); - m_grossini->setIsVisible(false); + m_tamara->setVisible(false); + m_kathia->setVisible(false); + m_grossini->setVisible(false); } else if ( numberOfSprites == 1 ) { - m_tamara->setIsVisible(false); - m_kathia->setIsVisible(false); + m_tamara->setVisible(false); + m_kathia->setVisible(false); m_grossini->setPosition(CCPointMake(s.width/2, s.height/2)); } else if( numberOfSprites == 2 ) { m_kathia->setPosition( CCPointMake(s.width/3, s.height/2)); m_tamara->setPosition( CCPointMake(2*s.width/3, s.height/2)); - m_grossini->setIsVisible(false); + m_grossini->setVisible(false); } else if( numberOfSprites == 3 ) { @@ -268,15 +268,15 @@ void ActionsDemo::alignSpritesLeft(unsigned int numberOfSprites) if( numberOfSprites == 1 ) { - m_tamara->setIsVisible(false); - m_kathia->setIsVisible(false); + m_tamara->setVisible(false); + m_kathia->setVisible(false); m_grossini->setPosition(CCPointMake(60, s.height/2)); } else if( numberOfSprites == 2 ) { m_kathia->setPosition( CCPointMake(60, s.height/3)); m_tamara->setPosition( CCPointMake(60, 2*s.height/3)); - m_grossini->setIsVisible( false ); + m_grossini->setVisible( false ); } else if( numberOfSprites == 3 ) { @@ -734,7 +734,7 @@ void ActionSequence2::onEnter() alignSpritesLeft(1); - m_grossini->setIsVisible(false); + m_grossini->setVisible(false); CCFiniteTimeAction* action = CCSequence::create( CCPlace::create(CCPointMake(200,200)), diff --git a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp index d89a88a46d..f274e125f2 100644 --- a/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp +++ b/tests/tests/ExtensionsTest/ControlExtensionTest/CCControlSwitchTest/CCControlSwitchTest.cpp @@ -87,7 +87,7 @@ bool CCControlSwitchTest::init() void CCControlSwitchTest::valueChanged(CCObject* sender, CCControlEvent controlEvent) { CCControlSwitch* pSwitch = (CCControlSwitch*)sender; - if (pSwitch->getIsOn()) + if (pSwitch->isOn()) { m_pDisplayValueLabel->setString("On"); } diff --git a/tests/tests/LabelTest/LabelTest.cpp b/tests/tests/LabelTest/LabelTest.cpp index 77f3db398d..8b5c1a3b7b 100644 --- a/tests/tests/LabelTest/LabelTest.cpp +++ b/tests/tests/LabelTest/LabelTest.cpp @@ -1199,7 +1199,7 @@ BitmapFontMultiLineAlignment::BitmapFontMultiLineAlignment() // position the label on the center of the screen this->m_pLabelShouldRetain->setPosition(ccp(size.width/2, size.height/2)); - this->m_pArrowsBarShouldRetain->setIsVisible(false); + this->m_pArrowsBarShouldRetain->setVisible(false); float arrowsWidth = (ArrowsMax - ArrowsMin) * size.width; this->m_pArrowsBarShouldRetain->setScaleX(arrowsWidth / this->m_pArrowsBarShouldRetain->getContentSize().width); @@ -1294,7 +1294,7 @@ void BitmapFontMultiLineAlignment::ccTouchesBegan(cocos2d::CCSet *pTouches, coco if (CCRect::CCRectContainsPoint(this->m_pArrowsShouldRetain->boundingBox(), location)) { m_drag = true; - this->m_pArrowsBarShouldRetain->setIsVisible(true); + this->m_pArrowsBarShouldRetain->setVisible(true); } } @@ -1303,7 +1303,7 @@ void BitmapFontMultiLineAlignment::ccTouchesEnded(cocos2d::CCSet *pTouches, coco m_drag = false; this->snapArrowsToEdge(); - this->m_pArrowsBarShouldRetain->setIsVisible(false); + this->m_pArrowsBarShouldRetain->setVisible(false); } void BitmapFontMultiLineAlignment::ccTouchesMoved(cocos2d::CCSet *pTouches, cocos2d::CCEvent *pEvent) diff --git a/tests/tests/LayerTest/LayerTest.cpp b/tests/tests/LayerTest/LayerTest.cpp index 7057c5ca47..72de4d3596 100644 --- a/tests/tests/LayerTest/LayerTest.cpp +++ b/tests/tests/LayerTest/LayerTest.cpp @@ -325,7 +325,7 @@ LayerGradient::LayerGradient() void LayerGradient::toggleItem(CCObject *sender) { CCLayerGradient *gradient = (CCLayerGradient*)getChildByTag(kTagLayer); - gradient->setIsCompressedInterpolation(! gradient->getIsCompressedInterpolation()); + gradient->setCompressedInterpolation(! gradient->isCompressedInterpolation()); } void LayerGradient::ccTouchesMoved(CCSet * touches, CCEvent *event) diff --git a/tests/tests/MenuTest/MenuTest.cpp b/tests/tests/MenuTest/MenuTest.cpp index 6346a0bebf..761ae744b5 100644 --- a/tests/tests/MenuTest/MenuTest.cpp +++ b/tests/tests/MenuTest/MenuTest.cpp @@ -107,7 +107,7 @@ MenuLayerMainMenu::MenuLayerMainMenu() } m_disabledItem = item3; item3->retain(); - m_disabledItem->setIsEnabled( false ); + m_disabledItem->setEnabled( false ); addChild(menu); menu->setPosition(ccp(s.width/2, s.height/2)); @@ -170,7 +170,7 @@ void MenuLayerMainMenu::menuCallbackDisabled(CCObject* sender) void MenuLayerMainMenu::menuCallbackEnable(CCObject* sender) { - m_disabledItem->setIsEnabled(! m_disabledItem->isEnabled() ); + m_disabledItem->setEnabled(! m_disabledItem->isEnabled() ); } void MenuLayerMainMenu::menuCallback2(CCObject* sender) @@ -319,7 +319,7 @@ MenuLayer3::MenuLayer3() CCMenuItemSprite* item3 = CCMenuItemSprite::create(spriteNormal, spriteSelected, spriteDisabled, this, menu_selector(MenuLayer3::menuCallback3)); m_disabledItem = item3; item3->retain(); - m_disabledItem->setIsEnabled( false ); + m_disabledItem->setEnabled( false ); CCMenu *menu = CCMenu::create( item1, item2, item3, NULL); menu->setPosition( CCPointMake(0,0) ); @@ -361,7 +361,7 @@ void MenuLayer3::menuCallback(CCObject* sender) void MenuLayer3::menuCallback2(CCObject* sender) { //UXLOG("Label clicked. Toogling AtlasSprite"); - m_disabledItem->setIsEnabled( ! m_disabledItem->isEnabled() ); + m_disabledItem->setEnabled( ! m_disabledItem->isEnabled() ); m_disabledItem->stopAllActions(); } @@ -380,7 +380,7 @@ MenuLayer4::MenuLayer4() CCMenuItemFont::setFontName("American Typewriter"); CCMenuItemFont::setFontSize(18); CCMenuItemFont*title1 = CCMenuItemFont::create("Sound"); - title1->setIsEnabled(false); + title1->setEnabled(false); CCMenuItemFont::setFontName( "Marker Felt" ); CCMenuItemFont::setFontSize(34); CCMenuItemToggle* item1 = CCMenuItemToggle::create( this, @@ -392,7 +392,7 @@ MenuLayer4::MenuLayer4() CCMenuItemFont::setFontName( "American Typewriter" ); CCMenuItemFont::setFontSize(18); CCMenuItemFont* title2 = CCMenuItemFont::create( "Music" ); - title2->setIsEnabled(false); + title2->setEnabled(false); CCMenuItemFont::setFontName( "Marker Felt" ); CCMenuItemFont::setFontSize(34); CCMenuItemToggle *item2 = CCMenuItemToggle::create( this, @@ -404,7 +404,7 @@ MenuLayer4::MenuLayer4() CCMenuItemFont::setFontName( "American Typewriter" ); CCMenuItemFont::setFontSize(18); CCMenuItemFont* title3 = CCMenuItemFont::create( "Quality" ); - title3->setIsEnabled( false ); + title3->setEnabled( false ); CCMenuItemFont::setFontName( "Marker Felt" ); CCMenuItemFont::setFontSize(34); CCMenuItemToggle *item3 = CCMenuItemToggle::create( this, @@ -416,7 +416,7 @@ MenuLayer4::MenuLayer4() CCMenuItemFont::setFontName( "American Typewriter" ); CCMenuItemFont::setFontSize(18); CCMenuItemFont* title4 = CCMenuItemFont::create( "Orientation" ); - title4->setIsEnabled(false); + title4->setEnabled(false); CCMenuItemFont::setFontName( "Marker Felt" ); CCMenuItemFont::setFontSize(34); CCMenuItemToggle *item4 = CCMenuItemToggle::create( this, diff --git a/tests/tests/ParticleTest/ParticleTest.cpp b/tests/tests/ParticleTest/ParticleTest.cpp index e2389d8efa..3d8f5f3309 100644 --- a/tests/tests/ParticleTest/ParticleTest.cpp +++ b/tests/tests/ParticleTest/ParticleTest.cpp @@ -362,7 +362,7 @@ void DemoExplosion::onEnter() m_emitter->setTexture( CCTextureCache::sharedTextureCache()->addImage(s_stars1) ); - m_emitter->setIsAutoRemoveOnFinish(true); + m_emitter->setAutoRemoveOnFinish(true); setEmitterPosition(); } diff --git a/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp b/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp index a7ded9ab5e..732b60e341 100644 --- a/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -236,7 +236,7 @@ void IterateSpriteSheetFastEnum::update(float dt) CCARRAY_FOREACH(pChildren, pObject) { CCSprite* pSprite = (CCSprite*) pObject; - pSprite->setIsVisible(false); + pSprite->setVisible(false); } #if CC_ENABLE_PROFILERS @@ -277,7 +277,7 @@ void IterateSpriteSheetCArray::update(float dt) CCARRAY_FOREACH(pChildren, pObject) { CCSprite* pSprite = (CCSprite*)pObject; - pSprite->setIsVisible(false); + pSprite->setVisible(false); } #if CC_ENABLE_PROFILERS @@ -340,7 +340,7 @@ void AddRemoveSpriteSheet::updateQuantityOfNodes() CCSprite *sprite = CCSprite::createWithTexture(batchNode->getTexture(), CCRectMake(0, 0, 32, 32)); batchNode->addChild(sprite); sprite->setPosition(ccp( CCRANDOM_0_1()*s.width, CCRANDOM_0_1()*s.height)); - sprite->setIsVisible(false); + sprite->setVisible(false); } } // decrease nodes diff --git a/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id b/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id index 5667da698f..5f7a8ab926 100644 --- a/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id +++ b/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id @@ -1 +1 @@ -7c5d19797ef70af4121f85f8e97926b1f42a3705 \ No newline at end of file +830b848e5d80adc751de8b576dfeba1423ff77b4 \ No newline at end of file diff --git a/tests/tests/Texture2dTest/Texture2dTest.cpp b/tests/tests/Texture2dTest/Texture2dTest.cpp index c393beb301..979536e486 100644 --- a/tests/tests/Texture2dTest/Texture2dTest.cpp +++ b/tests/tests/Texture2dTest/Texture2dTest.cpp @@ -1504,7 +1504,7 @@ void TextureMemoryAlloc::changeBackgroundVisible(cocos2d::CCObject *sender) { if (m_pBackground) { - m_pBackground->setIsVisible(true); + m_pBackground->setVisible(true); } } @@ -1541,7 +1541,7 @@ void TextureMemoryAlloc::updateImage(cocos2d::CCObject *sender) m_pBackground = CCSprite::create(file.c_str()); addChild(m_pBackground, -10); - m_pBackground->setIsVisible(false); + m_pBackground->setVisible(false); CCSize s = CCDirector::sharedDirector()->getWinSize(); m_pBackground->setPosition(ccp(s.width/2, s.height/2)); From 61719d813efa5d67d4407d6354e7aa697a448025 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 15 Jun 2012 16:47:54 +0800 Subject: [PATCH 192/257] fixed #1292:make some function names more readable. --- cocos2dx/platform/ios/CCFileUtils.mm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos2dx/platform/ios/CCFileUtils.mm b/cocos2dx/platform/ios/CCFileUtils.mm index c30795aa78..a75250a1ec 100644 --- a/cocos2dx/platform/ios/CCFileUtils.mm +++ b/cocos2dx/platform/ios/CCFileUtils.mm @@ -476,12 +476,12 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz // notification support when getFileData from a invalid file static bool s_bPopupNotify = true; -void CCFileUtils::setIsPopupNotify(bool bNotify) +void CCFileUtils::popupNotify(bool bNotify) { s_bPopupNotify = bNotify; } -bool CCFileUtils::getIsPopupNotify() +bool CCFileUtils::isPopupNotify() { return s_bPopupNotify; } From 1d0fa4a9aa407d25cb73babe5c0f744edea948ab Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 15 Jun 2012 17:26:11 +0800 Subject: [PATCH 193/257] fixed #1292: Updated lua bindings. --- HelloLua/Resources/hello.lua | 8 ++-- cocos2dx/misc_nodes/CCMotionStreak.h | 12 ++++- .../LuaCocos2d.cpp.REMOVED.git-id | 2 +- .../Templates/1033/Resources/hello.lua | 44 +++++++++---------- .../Resources/hello.lua | 44 +++++++++---------- tools/tolua++/CCCamera.pkg | 2 +- tools/tolua++/CCLayer.pkg | 16 +++---- tools/tolua++/CCMenuItem.pkg | 8 ++-- tools/tolua++/CCMotionStreak.pkg | 12 ++--- tools/tolua++/CCNode.pkg | 12 ++--- tools/tolua++/CCParticleSystem.pkg | 9 ++++ tools/tolua++/CCProgressTimer.pkg | 8 ++-- tools/tolua++/CCSprite.pkg | 6 +-- tools/tolua++/CCTexture2D.pkg | 3 +- 14 files changed, 102 insertions(+), 84 deletions(-) diff --git a/HelloLua/Resources/hello.lua b/HelloLua/Resources/hello.lua index 365a7a4ba0..0f99068474 100644 --- a/HelloLua/Resources/hello.lua +++ b/HelloLua/Resources/hello.lua @@ -128,7 +128,7 @@ local function createLayerFram() end layerFarm:registerScriptTouchHandler(onTouch) - layerFarm:setIsTouchEnabled(true) + layerFarm:setTouchEnabled(true) return layerFarm end @@ -143,13 +143,13 @@ local function createLayerMenu() local function menuCallbackClosePopup() -- stop test sound effect SimpleAudioEngine:sharedEngine():stopEffect(effectID) - menuPopup:setIsVisible(false) + menuPopup:setVisible(false) end local function menuCallbackOpenPopup() -- loop test sound effect effectID = SimpleAudioEngine:sharedEngine():playEffect("effect1.wav") - menuPopup:setIsVisible(true) + menuPopup:setVisible(true) end -- add a popup menu @@ -158,7 +158,7 @@ local function createLayerMenu() menuPopupItem:registerScriptHandler(menuCallbackClosePopup) menuPopup = CCMenu:createWithItem(menuPopupItem) menuPopup:setPosition(winSize.width / 2, winSize.height / 2) - menuPopup:setIsVisible(false) + menuPopup:setVisible(false) layerMenu:addChild(menuPopup) -- add the left-bottom "tools" menu to invoke menuPopup diff --git a/cocos2dx/misc_nodes/CCMotionStreak.h b/cocos2dx/misc_nodes/CCMotionStreak.h index e66ed3ade9..63e50836b8 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.h +++ b/cocos2dx/misc_nodes/CCMotionStreak.h @@ -84,9 +84,17 @@ public: virtual bool isOpacityModifyRGB(void); /** When fast mode is enbled, new points are added faster but with lower precision */ - CC_SYNTHESIZE(bool, m_bFastMode, IsFastMode); + inline bool isFastMode() { return m_bFastMode; } + inline void setFastMode(bool bFastMode) { m_bFastMode = bFastMode; } - CC_SYNTHESIZE(bool, m_bStartingPositionInitialized, StartingPositionInitialized); + inline bool isStartingPositionInitialized() { return m_bStartingPositionInitialized; } + inline void setStartingPositionInitialized(bool bStartingPositionInitialized) + { + m_bStartingPositionInitialized = bStartingPositionInitialized; + } +protected: + bool m_bFastMode; + bool m_bStartingPositionInitialized; private: /** texture used for the motion streak */ CCTexture2D* m_pTexture; diff --git a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index a6cf00ee32..c70d137ce4 100644 --- a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -6b0bec0c232235cbdf61396805f812c6c8264bae \ No newline at end of file +cf9109aeec89b5dafb4bc9588c59b279c734d0a2 \ No newline at end of file diff --git a/template/msvc/CCAppWiz.win32/Templates/1033/Resources/hello.lua b/template/msvc/CCAppWiz.win32/Templates/1033/Resources/hello.lua index 3fa0545712..0f99068474 100644 --- a/template/msvc/CCAppWiz.win32/Templates/1033/Resources/hello.lua +++ b/template/msvc/CCAppWiz.win32/Templates/1033/Resources/hello.lua @@ -22,22 +22,22 @@ local function creatDog() -- create dog animate local textureDog = CCTextureCache:sharedTextureCache():addImage("dog.png") local rect = CCRectMake(0, 0, frameWidth, frameHeight) - local frame0 = CCSpriteFrame:frameWithTexture(textureDog, rect) + local frame0 = CCSpriteFrame:create(textureDog, rect) rect = CCRectMake(frameWidth, 0, frameWidth, frameHeight) - local frame1 = CCSpriteFrame:frameWithTexture(textureDog, rect) + local frame1 = CCSpriteFrame:create(textureDog, rect) - local spriteDog = CCSprite:spriteWithSpriteFrame(frame0) + local spriteDog = CCSprite:createWithSpriteFrame(frame0) spriteDog.isPaused = false spriteDog:setPosition(0, winSize.height / 4 * 3) - local animFrames = CCArray:arrayWithCapacity(2) + local animFrames = CCArray:create(2) animFrames:addObject(frame0) animFrames:addObject(frame1) - local animation = CCAnimation:animationWithSpriteFrames(animFrames, 0.5) - local animate = CCAnimate:actionWithAnimation(animation); - spriteDog:runAction(CCRepeatForever:actionWithAction(animate)) + local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.5) + local animate = CCAnimate:create(animation); + spriteDog:runAction(CCRepeatForever:create(animate)) -- moving dog at every frame local function tick() @@ -59,17 +59,17 @@ end -- create farm local function createLayerFram() - local layerFarm = CCLayer:node() + local layerFarm = CCLayer:create() -- add in farm background - local bg = CCSprite:spriteWithFile("farm.jpg") + local bg = CCSprite:create("farm.jpg") bg:setPosition(winSize.width / 2 + 80, winSize.height / 2) layerFarm:addChild(bg) -- add land sprite for i = 0, 3 do for j = 0, 1 do - local spriteLand = CCSprite:spriteWithFile("land.png") + local spriteLand = CCSprite:create("land.png") spriteLand:setPosition(200 + j * 180 - i % 2 * 90, 10 + i * 95 / 2) layerFarm:addChild(spriteLand) end @@ -77,10 +77,10 @@ local function createLayerFram() -- add crop local textureCrop = CCTextureCache:sharedTextureCache():addImage("crop.png") - local frameCrop = CCSpriteFrame:frameWithTexture(textureCrop, CCRectMake(0, 0, 105, 95)) + local frameCrop = CCSpriteFrame:create(textureCrop, CCRectMake(0, 0, 105, 95)) for i = 0, 3 do for j = 0, 1 do - local spriteCrop = CCSprite:spriteWithSpriteFrame(frameCrop); + local spriteCrop = CCSprite:createWithSpriteFrame(frameCrop); spriteCrop:setPosition(10 + 200 + j * 180 - i % 2 * 90, 30 + 10 + i * 95 / 2) layerFarm:addChild(spriteCrop) end @@ -128,7 +128,7 @@ local function createLayerFram() end layerFarm:registerScriptTouchHandler(onTouch) - layerFarm:setIsTouchEnabled(true) + layerFarm:setTouchEnabled(true) return layerFarm end @@ -136,36 +136,36 @@ end -- create menu local function createLayerMenu() - local layerMenu = CCLayer:node() + local layerMenu = CCLayer:create() local menuPopup, menuTools, effectID local function menuCallbackClosePopup() -- stop test sound effect SimpleAudioEngine:sharedEngine():stopEffect(effectID) - menuPopup:setIsVisible(false) + menuPopup:setVisible(false) end local function menuCallbackOpenPopup() -- loop test sound effect effectID = SimpleAudioEngine:sharedEngine():playEffect("effect1.wav") - menuPopup:setIsVisible(true) + menuPopup:setVisible(true) end -- add a popup menu - local menuPopupItem = CCMenuItemImage:itemWithNormalImage("menu2.png", "menu2.png") + local menuPopupItem = CCMenuItemImage:create("menu2.png", "menu2.png") menuPopupItem:setPosition(0, 0) menuPopupItem:registerScriptHandler(menuCallbackClosePopup) - menuPopup = CCMenu:menuWithItem(menuPopupItem) + menuPopup = CCMenu:createWithItem(menuPopupItem) menuPopup:setPosition(winSize.width / 2, winSize.height / 2) - menuPopup:setIsVisible(false) + menuPopup:setVisible(false) layerMenu:addChild(menuPopup) -- add the left-bottom "tools" menu to invoke menuPopup - local menuToolsItem = CCMenuItemImage:itemWithNormalImage("menu1.png", "menu1.png") + local menuToolsItem = CCMenuItemImage:create("menu1.png", "menu1.png") menuToolsItem:setPosition(0, 0) menuToolsItem:registerScriptHandler(menuCallbackOpenPopup) - menuTools = CCMenu:menuWithItem(menuToolsItem) + menuTools = CCMenu:createWithItem(menuToolsItem) menuTools:setPosition(30, 40) layerMenu:addChild(menuTools) @@ -177,7 +177,7 @@ SimpleAudioEngine:sharedEngine():playBackgroundMusic("background.mp3", true); SimpleAudioEngine:sharedEngine():preloadEffect("effect1.wav"); -- run -local sceneGame = CCScene:node() +local sceneGame = CCScene:create() sceneGame:addChild(createLayerFram()) sceneGame:addChild(createLayerMenu()) CCDirector:sharedDirector():runWithScene(sceneGame) diff --git a/template/xcode4/cocos2dx_lua.xctemplate/Resources/hello.lua b/template/xcode4/cocos2dx_lua.xctemplate/Resources/hello.lua index 3fa0545712..0f99068474 100644 --- a/template/xcode4/cocos2dx_lua.xctemplate/Resources/hello.lua +++ b/template/xcode4/cocos2dx_lua.xctemplate/Resources/hello.lua @@ -22,22 +22,22 @@ local function creatDog() -- create dog animate local textureDog = CCTextureCache:sharedTextureCache():addImage("dog.png") local rect = CCRectMake(0, 0, frameWidth, frameHeight) - local frame0 = CCSpriteFrame:frameWithTexture(textureDog, rect) + local frame0 = CCSpriteFrame:create(textureDog, rect) rect = CCRectMake(frameWidth, 0, frameWidth, frameHeight) - local frame1 = CCSpriteFrame:frameWithTexture(textureDog, rect) + local frame1 = CCSpriteFrame:create(textureDog, rect) - local spriteDog = CCSprite:spriteWithSpriteFrame(frame0) + local spriteDog = CCSprite:createWithSpriteFrame(frame0) spriteDog.isPaused = false spriteDog:setPosition(0, winSize.height / 4 * 3) - local animFrames = CCArray:arrayWithCapacity(2) + local animFrames = CCArray:create(2) animFrames:addObject(frame0) animFrames:addObject(frame1) - local animation = CCAnimation:animationWithSpriteFrames(animFrames, 0.5) - local animate = CCAnimate:actionWithAnimation(animation); - spriteDog:runAction(CCRepeatForever:actionWithAction(animate)) + local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.5) + local animate = CCAnimate:create(animation); + spriteDog:runAction(CCRepeatForever:create(animate)) -- moving dog at every frame local function tick() @@ -59,17 +59,17 @@ end -- create farm local function createLayerFram() - local layerFarm = CCLayer:node() + local layerFarm = CCLayer:create() -- add in farm background - local bg = CCSprite:spriteWithFile("farm.jpg") + local bg = CCSprite:create("farm.jpg") bg:setPosition(winSize.width / 2 + 80, winSize.height / 2) layerFarm:addChild(bg) -- add land sprite for i = 0, 3 do for j = 0, 1 do - local spriteLand = CCSprite:spriteWithFile("land.png") + local spriteLand = CCSprite:create("land.png") spriteLand:setPosition(200 + j * 180 - i % 2 * 90, 10 + i * 95 / 2) layerFarm:addChild(spriteLand) end @@ -77,10 +77,10 @@ local function createLayerFram() -- add crop local textureCrop = CCTextureCache:sharedTextureCache():addImage("crop.png") - local frameCrop = CCSpriteFrame:frameWithTexture(textureCrop, CCRectMake(0, 0, 105, 95)) + local frameCrop = CCSpriteFrame:create(textureCrop, CCRectMake(0, 0, 105, 95)) for i = 0, 3 do for j = 0, 1 do - local spriteCrop = CCSprite:spriteWithSpriteFrame(frameCrop); + local spriteCrop = CCSprite:createWithSpriteFrame(frameCrop); spriteCrop:setPosition(10 + 200 + j * 180 - i % 2 * 90, 30 + 10 + i * 95 / 2) layerFarm:addChild(spriteCrop) end @@ -128,7 +128,7 @@ local function createLayerFram() end layerFarm:registerScriptTouchHandler(onTouch) - layerFarm:setIsTouchEnabled(true) + layerFarm:setTouchEnabled(true) return layerFarm end @@ -136,36 +136,36 @@ end -- create menu local function createLayerMenu() - local layerMenu = CCLayer:node() + local layerMenu = CCLayer:create() local menuPopup, menuTools, effectID local function menuCallbackClosePopup() -- stop test sound effect SimpleAudioEngine:sharedEngine():stopEffect(effectID) - menuPopup:setIsVisible(false) + menuPopup:setVisible(false) end local function menuCallbackOpenPopup() -- loop test sound effect effectID = SimpleAudioEngine:sharedEngine():playEffect("effect1.wav") - menuPopup:setIsVisible(true) + menuPopup:setVisible(true) end -- add a popup menu - local menuPopupItem = CCMenuItemImage:itemWithNormalImage("menu2.png", "menu2.png") + local menuPopupItem = CCMenuItemImage:create("menu2.png", "menu2.png") menuPopupItem:setPosition(0, 0) menuPopupItem:registerScriptHandler(menuCallbackClosePopup) - menuPopup = CCMenu:menuWithItem(menuPopupItem) + menuPopup = CCMenu:createWithItem(menuPopupItem) menuPopup:setPosition(winSize.width / 2, winSize.height / 2) - menuPopup:setIsVisible(false) + menuPopup:setVisible(false) layerMenu:addChild(menuPopup) -- add the left-bottom "tools" menu to invoke menuPopup - local menuToolsItem = CCMenuItemImage:itemWithNormalImage("menu1.png", "menu1.png") + local menuToolsItem = CCMenuItemImage:create("menu1.png", "menu1.png") menuToolsItem:setPosition(0, 0) menuToolsItem:registerScriptHandler(menuCallbackOpenPopup) - menuTools = CCMenu:menuWithItem(menuToolsItem) + menuTools = CCMenu:createWithItem(menuToolsItem) menuTools:setPosition(30, 40) layerMenu:addChild(menuTools) @@ -177,7 +177,7 @@ SimpleAudioEngine:sharedEngine():playBackgroundMusic("background.mp3", true); SimpleAudioEngine:sharedEngine():preloadEffect("effect1.wav"); -- run -local sceneGame = CCScene:node() +local sceneGame = CCScene:create() sceneGame:addChild(createLayerFram()) sceneGame:addChild(createLayerMenu()) CCDirector:sharedDirector():runWithScene(sceneGame) diff --git a/tools/tolua++/CCCamera.pkg b/tools/tolua++/CCCamera.pkg index bceb318470..5d69c3b860 100644 --- a/tools/tolua++/CCCamera.pkg +++ b/tools/tolua++/CCCamera.pkg @@ -7,7 +7,7 @@ class CCCamera : public CCObject char * description(void); void setDirty(bool bValue); - bool getDirty(void); + bool isDirty(void); void restore(void); void locate(void); void setEyeXYZ(float fEyeX, float fEyeY, float fEyeZ); diff --git a/tools/tolua++/CCLayer.pkg b/tools/tolua++/CCLayer.pkg index d75dbc02de..6085bd9074 100644 --- a/tools/tolua++/CCLayer.pkg +++ b/tools/tolua++/CCLayer.pkg @@ -1,14 +1,14 @@ class CCLayer : public CCNode { - void setIsTouchEnabled(bool bValue); - bool getIsTouchEnabled(); + void setTouchEnabled(bool bValue); + bool isTouchEnabled(); - void setIsAccelerometerEnabled(bool bValue); - bool getIsAccelerometerEnabled(); + void setAccelerometerEnabled(bool bValue); + bool isAccelerometerEnabled(); - void setIsKeypadEnabled(bool bValue); - bool getIsKeypadEnabled(); + void setKeypadEnabled(bool bValue); + bool isKeypadEnabled(); void registerScriptTouchHandler(LUA_FUNCTION funcID, bool bIsMultiTouches = false, @@ -49,8 +49,8 @@ class CCLayerGradient : public CCLayerColor void setVector(CCPoint Value); CCPoint getVector(void); - void setIsCompressedInterpolation(bool Value); - bool getIsCompressedInterpolation(void); + void setCompressedInterpolation(bool Value); + bool isCompressedInterpolation(void); static CCLayerGradient* create(ccColor4B start, ccColor4B end); static CCLayerGradient* create(ccColor4B start, ccColor4B end, CCPoint v); diff --git a/tools/tolua++/CCMenuItem.pkg b/tools/tolua++/CCMenuItem.pkg index f5c231f866..554b3229c0 100644 --- a/tools/tolua++/CCMenuItem.pkg +++ b/tools/tolua++/CCMenuItem.pkg @@ -5,11 +5,9 @@ class CCMenuItem : public CCNode void activate(); void selected(); void unselected(); - void setIsEnabled(bool enabled); - bool getIsEnabled(); - bool getIsSelected(); - - tolua_property__CCIsEnabled bool isEnabled; + void setEnabled(bool enabled); + bool isEnabled(); + bool isSelected(); void registerScriptHandler(LUA_FUNCTION funcID); void unregisterScriptHandler(void); diff --git a/tools/tolua++/CCMotionStreak.pkg b/tools/tolua++/CCMotionStreak.pkg index 882adcaaad..4a5b35b50d 100644 --- a/tools/tolua++/CCMotionStreak.pkg +++ b/tools/tolua++/CCMotionStreak.pkg @@ -16,8 +16,10 @@ class CCMotionStreak : public CCNode const ccColor3B& getColor(void); GLubyte getOpacity(void); void setOpacity(GLubyte opacity); - void setIsOpacityModifyRGB(bool bValue); - bool getIsOpacityModifyRGB(void); - bool getIsFastMode(); - void setIsFastMode(bool mode); -}; \ No newline at end of file + void setOpacityModifyRGB(bool bValue); + bool isOpacityModifyRGB(void); + bool isFastMode(); + void setFastMode(bool bFastMode); + bool isStartingPositionInitialized(); + void setStartingPositionInitialized(bool bStartingPositionInitialized); +}; diff --git a/tools/tolua++/CCNode.pkg b/tools/tolua++/CCNode.pkg index ac5451acdc..bfd8441f53 100644 --- a/tools/tolua++/CCNode.pkg +++ b/tools/tolua++/CCNode.pkg @@ -29,8 +29,8 @@ class CCNode : public CCObject void setSkewX(float skewX); float getSkewY(); void setSkewY(float skewY); - bool getIsVisible(); - void setIsVisible(bool var); + bool isVisible(); + void setVisible(bool var); CCPoint getAnchorPoint(); void setAnchorPoint(CCPoint point); CCSize getContentSize(); @@ -48,7 +48,7 @@ class CCNode : public CCObject tolua_property__CCPositionY float y; tolua_property__CCSkewX float skewX; tolua_property__CCSkewY float skewY; - tolua_property__CCIsVisible bool isVisible; +// tolua_property__CCIsVisible bool isVisible; tolua_property__CCAnchorPoint CCPoint anchorPoint; tolua_property__CCContentSize CCSize contentSize; tolua_property__CCTag int tag; @@ -62,11 +62,11 @@ class CCNode : public CCObject //CCPoint getAnchorPointInPixels(); //CCSize getContentSizeInPixels(); //void setContentSizeInPixels(CCSize sz); - bool getIsRunning(); + bool isRunning(); CCNode* getParent(); void setParent(CCNode * var); - bool getIgnoreAnchorPointForPosition(); - void setIgnoreAnchorPointForPosition(bool newValue); + bool isIgnoreAnchorPointForPosition(); + void ignoreAnchorPointForPosition(bool newValue); void* getUserData(); void setUserData(void *var); void addChild(CCNode * child); diff --git a/tools/tolua++/CCParticleSystem.pkg b/tools/tolua++/CCParticleSystem.pkg index 6d89808535..b7bb784375 100644 --- a/tools/tolua++/CCParticleSystem.pkg +++ b/tools/tolua++/CCParticleSystem.pkg @@ -46,6 +46,15 @@ class CCParticleSystem : public CCNode ccBlendFunc getBlendFunc(void); void setBlendFunc(ccBlendFunc var); + void setScale(float s); + void setRotation(float newRotation); + void setScaleX(float newScaleX); + void setScaleY(float newScaleY); + + bool isActive(); + bool isBlendAdditive(); + void setBlendAdditive(bool value); + static CCParticleSystem * create(const char *plistFile); }; diff --git a/tools/tolua++/CCProgressTimer.pkg b/tools/tolua++/CCProgressTimer.pkg index 5b2da789cf..5932d3d69a 100644 --- a/tools/tolua++/CCProgressTimer.pkg +++ b/tools/tolua++/CCProgressTimer.pkg @@ -21,8 +21,8 @@ class CCProgressTimer : public CCNode const ccColor3B& getColor(void); GLubyte getOpacity(void); void setOpacity(GLubyte opacity); - void setIsOpacityModifyRGB(bool bValue); - bool getIsOpacityModifyRGB(void); + void setOpacityModifyRGB(bool bValue); + bool isOpacityModifyRGB(void); static CCProgressTimer* create(CCSprite* sp); @@ -31,6 +31,6 @@ class CCProgressTimer : public CCNode CCPoint getBarChangeRate(); void setBarChangeRate(CCPoint rate); - bool getIsReverseDirection(); - void setIsReverseDirection(bool bReverseDir); + bool isReverseDirection(); + void setReverseDirection(bool bReverseDir); }; diff --git a/tools/tolua++/CCSprite.pkg b/tools/tolua++/CCSprite.pkg index f29940c283..2bbbe57584 100644 --- a/tools/tolua++/CCSprite.pkg +++ b/tools/tolua++/CCSprite.pkg @@ -40,7 +40,7 @@ class CCSprite : public CCNode //CCPoint getOffsetPositionInPixels(void); void setDirtyRecursively(bool bValue); - void setIgnoreAnchorPointForPosition(bool newValue); + void ignoreAnchorPointForPosition(bool newValue); void setFlipX(bool bFlipX); void setFlipY(bool bFlipY); bool isFlipX(void); @@ -54,8 +54,8 @@ class CCSprite : public CCNode void setColor(ccColor3B color3); ccColor3B getColor(void); - void setIsOpacityModifyRGB(bool bValue); - bool getIsOpacityModifyRGB(void); + void setOpacityModifyRGB(bool bValue); + bool isOpacityModifyRGB(void); void setTexture(CCTexture2D *texture); CCTexture2D* getTexture(void); diff --git a/tools/tolua++/CCTexture2D.pkg b/tools/tolua++/CCTexture2D.pkg index 1550c29c0a..5585f964f5 100644 --- a/tools/tolua++/CCTexture2D.pkg +++ b/tools/tolua++/CCTexture2D.pkg @@ -53,7 +53,8 @@ class CCTexture2D : public CCObject GLfloat getMaxT(); void setMaxT(GLfloat val); - bool getHasPremultipliedAlpha(); + bool hasPremultipliedAlpha(); + bool hasMipmaps(); void drawAtPoint(CCPoint point); void drawInRect(CCRect rect); From 899022d107e17a186e78a836a39b2176ae8d03c8 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 15 Jun 2012 17:39:13 +0800 Subject: [PATCH 194/257] fixed #1292:fix some bugs that caused by modify function name --- cocos2dx/platform/android/CCFileUtils.cpp | 2 +- cocos2dx/platform/ios/CCFileUtils.mm | 2 +- tests/tests/MotionStreakTest/MotionStreakTest.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos2dx/platform/android/CCFileUtils.cpp b/cocos2dx/platform/android/CCFileUtils.cpp index 3d2a4b429e..5a6fd454db 100644 --- a/cocos2dx/platform/android/CCFileUtils.cpp +++ b/cocos2dx/platform/android/CCFileUtils.cpp @@ -133,7 +133,7 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz } while (0); } - if (! pData && getIsPopupNotify()) + if (! pData && isPopupNotify()) { std::string title = "Notification"; std::string msg = "Get data from file("; diff --git a/cocos2dx/platform/ios/CCFileUtils.mm b/cocos2dx/platform/ios/CCFileUtils.mm index a75250a1ec..0ab53e89be 100644 --- a/cocos2dx/platform/ios/CCFileUtils.mm +++ b/cocos2dx/platform/ios/CCFileUtils.mm @@ -462,7 +462,7 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz fclose(fp); } while (0); - if (! pBuffer && getIsPopupNotify()) + if (! pBuffer && isPopupNotify()) { std::string title = "Notification"; std::string msg = "Get data from file("; diff --git a/tests/tests/MotionStreakTest/MotionStreakTest.cpp b/tests/tests/MotionStreakTest/MotionStreakTest.cpp index d64b9a6ada..6e393be72b 100644 --- a/tests/tests/MotionStreakTest/MotionStreakTest.cpp +++ b/tests/tests/MotionStreakTest/MotionStreakTest.cpp @@ -271,8 +271,8 @@ void MotionStreakTest::onEnter() void MotionStreakTest::modeCallback(CCObject *pSender) { - bool fastMode = streak->getIsFastMode(); - streak->setIsFastMode(! fastMode); + bool fastMode = streak->isFastMode(); + streak->setFastMode(! fastMode); } void MotionStreakTest::restartCallback(CCObject* pSender) From cc572ab8e71e3d6684fa8fb28db06abb3c78c321 Mon Sep 17 00:00:00 2001 From: James Chen Date: Fri, 15 Jun 2012 18:15:43 +0800 Subject: [PATCH 195/257] fixed #1329: Moved all java files part of engine into a certain directory, then all projects refer to them. --- .gitignore | 6 +- HelloLua/proj.android/.classpath | 9 + HelloLua/proj.android/.project | 40 ++ HelloWorld/proj.android/.classpath | 9 + HelloWorld/proj.android/.project | 40 ++ .../cocos2dx/lib/Cocos2dxAccelerometer.java | 0 .../org/cocos2dx/lib/Cocos2dxActivity.java | 0 .../org/cocos2dx/lib/Cocos2dxBitmap.java | 0 .../org/cocos2dx/lib/Cocos2dxEditText.java | 0 .../cocos2dx/lib/Cocos2dxGLSurfaceView.java | 0 .../org/cocos2dx/lib/Cocos2dxMusic.java | 0 .../org/cocos2dx/lib/Cocos2dxRenderer.java | 0 .../org/cocos2dx/lib/Cocos2dxSound.java | 0 .../org/cocos2dx/lib/Cocos2dxTypefaces.java | 0 testjs/proj.android/.classpath | 9 + testjs/proj.android/.project | 40 ++ .../cocos2dx/lib/Cocos2dxAccelerometer.java | 107 ----- .../org/cocos2dx/lib/Cocos2dxActivity.java | 253 ----------- .../src/org/cocos2dx/lib/Cocos2dxBitmap.java | 413 ----------------- .../org/cocos2dx/lib/Cocos2dxEditText.java | 65 --- .../cocos2dx/lib/Cocos2dxGLSurfaceView.java | 417 ------------------ .../src/org/cocos2dx/lib/Cocos2dxMusic.java | 228 ---------- .../org/cocos2dx/lib/Cocos2dxRenderer.java | 137 ------ .../src/org/cocos2dx/lib/Cocos2dxSound.java | 245 ---------- .../org/cocos2dx/lib/Cocos2dxTypefaces.java | 44 -- tests/proj.android/.classpath | 9 + tests/proj.android/.project | 40 ++ tests/proj.android/project.properties | 2 +- 28 files changed, 200 insertions(+), 1913 deletions(-) create mode 100644 HelloLua/proj.android/.classpath create mode 100644 HelloLua/proj.android/.project create mode 100644 HelloWorld/proj.android/.classpath create mode 100644 HelloWorld/proj.android/.project rename cocos2dx/platform/android/java/{src => src_common}/org/cocos2dx/lib/Cocos2dxAccelerometer.java (100%) rename cocos2dx/platform/android/java/{src => src_common}/org/cocos2dx/lib/Cocos2dxActivity.java (100%) rename cocos2dx/platform/android/java/{src => src_common}/org/cocos2dx/lib/Cocos2dxBitmap.java (100%) rename cocos2dx/platform/android/java/{src => src_common}/org/cocos2dx/lib/Cocos2dxEditText.java (100%) rename cocos2dx/platform/android/java/{src => src_common}/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java (100%) rename cocos2dx/platform/android/java/{src => src_common}/org/cocos2dx/lib/Cocos2dxMusic.java (100%) rename cocos2dx/platform/android/java/{src => src_common}/org/cocos2dx/lib/Cocos2dxRenderer.java (100%) rename cocos2dx/platform/android/java/{src => src_common}/org/cocos2dx/lib/Cocos2dxSound.java (100%) rename cocos2dx/platform/android/java/{src => src_common}/org/cocos2dx/lib/Cocos2dxTypefaces.java (100%) create mode 100644 testjs/proj.android/.classpath create mode 100644 testjs/proj.android/.project delete mode 100644 testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java delete mode 100644 testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxActivity.java delete mode 100644 testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java delete mode 100644 testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxEditText.java delete mode 100644 testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java delete mode 100644 testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxMusic.java delete mode 100644 testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxRenderer.java delete mode 100644 testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java delete mode 100644 testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxTypefaces.java create mode 100644 tests/proj.android/.classpath create mode 100644 tests/proj.android/.project diff --git a/.gitignore b/.gitignore index 877c40389b..c7d48f102e 100644 --- a/.gitignore +++ b/.gitignore @@ -34,9 +34,9 @@ bin/ obj/ gen/ assets/ -.classpath -.project -.cproject +#.classpath +#.project +#.cproject local.properties # Ignore files build by linux diff --git a/HelloLua/proj.android/.classpath b/HelloLua/proj.android/.classpath new file mode 100644 index 0000000000..dc00167933 --- /dev/null +++ b/HelloLua/proj.android/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/HelloLua/proj.android/.project b/HelloLua/proj.android/.project new file mode 100644 index 0000000000..58e30464ba --- /dev/null +++ b/HelloLua/proj.android/.project @@ -0,0 +1,40 @@ + + + HelloLua + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + + + src_common + 2 + PARENT-2-PROJECT_LOC/cocos2dx/platform/android/java/src_common + + + diff --git a/HelloWorld/proj.android/.classpath b/HelloWorld/proj.android/.classpath new file mode 100644 index 0000000000..58d9761beb --- /dev/null +++ b/HelloWorld/proj.android/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/HelloWorld/proj.android/.project b/HelloWorld/proj.android/.project new file mode 100644 index 0000000000..25b0bba63c --- /dev/null +++ b/HelloWorld/proj.android/.project @@ -0,0 +1,40 @@ + + + HelloWorld + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + + + src_common + 2 + PARENT-2-PROJECT_LOC/cocos2dx/platform/android/java/src_common + + + diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java b/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxAccelerometer.java similarity index 100% rename from cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java rename to cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxAccelerometer.java diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java b/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxActivity.java similarity index 100% rename from cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxActivity.java rename to cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxActivity.java diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java b/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxBitmap.java similarity index 100% rename from cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxBitmap.java rename to cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxBitmap.java diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditText.java b/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxEditText.java similarity index 100% rename from cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxEditText.java rename to cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxEditText.java diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java b/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java similarity index 100% rename from cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java rename to cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxMusic.java b/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxMusic.java similarity index 100% rename from cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxMusic.java rename to cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxMusic.java diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxRenderer.java b/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxRenderer.java similarity index 100% rename from cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxRenderer.java rename to cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxRenderer.java diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxSound.java b/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxSound.java similarity index 100% rename from cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxSound.java rename to cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxSound.java diff --git a/cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxTypefaces.java b/cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxTypefaces.java similarity index 100% rename from cocos2dx/platform/android/java/src/org/cocos2dx/lib/Cocos2dxTypefaces.java rename to cocos2dx/platform/android/java/src_common/org/cocos2dx/lib/Cocos2dxTypefaces.java diff --git a/testjs/proj.android/.classpath b/testjs/proj.android/.classpath new file mode 100644 index 0000000000..dc00167933 --- /dev/null +++ b/testjs/proj.android/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/testjs/proj.android/.project b/testjs/proj.android/.project new file mode 100644 index 0000000000..4b51ca3b35 --- /dev/null +++ b/testjs/proj.android/.project @@ -0,0 +1,40 @@ + + + TestJS + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + + + src_common + 2 + PARENT-2-PROJECT_LOC/cocos2dx/platform/android/java/src_common + + + diff --git a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java b/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java deleted file mode 100644 index c515349cab..0000000000 --- a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxAccelerometer.java +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import android.content.Context; -import android.content.res.Configuration; -import android.hardware.Sensor; -import android.hardware.SensorEvent; -import android.hardware.SensorEventListener; -import android.hardware.SensorManager; -import android.view.Display; -import android.view.Surface; -import android.view.WindowManager; - -/** - * - * This class is used for controlling the Accelerometer - * - */ -public class Cocos2dxAccelerometer implements SensorEventListener { - - private static final String TAG = "Cocos2dxAccelerometer"; - private Context mContext; - private SensorManager mSensorManager; - private Sensor mAccelerometer; - private int mNaturalOrientation; - - public Cocos2dxAccelerometer(Context context){ - mContext = context; - - //Get an instance of the SensorManager - mSensorManager = (SensorManager) mContext.getSystemService(Context.SENSOR_SERVICE); - mAccelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER); - - Display display = ((WindowManager)mContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); - mNaturalOrientation = display.getOrientation(); - } - - public void enable() { - mSensorManager.registerListener(this, mAccelerometer, SensorManager.SENSOR_DELAY_GAME); - } - - public void disable () { - mSensorManager.unregisterListener(this); - } - - @Override - public void onSensorChanged(SensorEvent event) { - - if (event.sensor.getType() != Sensor.TYPE_ACCELEROMETER){ - return; - } - - float x = event.values[0]; - float y = event.values[1]; - float z = event.values[2]; - - /* - * Because the axes are not swapped when the device's screen orientation changes. - * So we should swap it here. - * In tablets such as Motorola Xoom, the default orientation is landscape, so should - * consider this. - */ - int orientation = mContext.getResources().getConfiguration().orientation; - if ((orientation == Configuration.ORIENTATION_LANDSCAPE) && (mNaturalOrientation != Surface.ROTATION_0)){ - float tmp = x; - x = -y; - y = tmp; - } - else if ((orientation == Configuration.ORIENTATION_PORTRAIT) && (mNaturalOrientation != Surface.ROTATION_0)) - { - float tmp = x; - x = y; - y = -tmp; - } - - onSensorChanged(x, y, z, event.timestamp); - // Log.d(TAG, "x = " + event.values[0] + " y = " + event.values[1] + " z = " + event.values[2]); - } - - @Override - public void onAccuracyChanged(Sensor sensor, int accuracy) { - } - - private static native void onSensorChanged(float x, float y, float z, long timeStamp); -} diff --git a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxActivity.java b/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxActivity.java deleted file mode 100644 index c5b65df061..0000000000 --- a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxActivity.java +++ /dev/null @@ -1,253 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -package org.cocos2dx.lib; - -import android.app.Activity; -import android.app.AlertDialog; -import android.app.Dialog; -import android.content.DialogInterface; -import android.content.pm.ApplicationInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.os.Bundle; -import android.os.Handler; -import android.os.Message; -import android.util.DisplayMetrics; -import android.util.Log; - -public class Cocos2dxActivity extends Activity{ - private static Cocos2dxMusic backgroundMusicPlayer; - private static Cocos2dxSound soundPlayer; - private static Cocos2dxAccelerometer accelerometer; - private static boolean accelerometerEnabled = false; - private static Handler handler; - private final static int HANDLER_SHOW_DIALOG = 1; - private static String packageName; - - private static native void nativeSetPaths(String apkPath); - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - // get frame size - DisplayMetrics dm = new DisplayMetrics(); - getWindowManager().getDefaultDisplay().getMetrics(dm); - accelerometer = new Cocos2dxAccelerometer(this); - - // init media player and sound player - backgroundMusicPlayer = new Cocos2dxMusic(this); - soundPlayer = new Cocos2dxSound(this); - - // init bitmap context - Cocos2dxBitmap.setContext(this); - - handler = new Handler(){ - public void handleMessage(Message msg){ - switch(msg.what){ - case HANDLER_SHOW_DIALOG: - showDialog(((DialogMessage)msg.obj).title, ((DialogMessage)msg.obj).message); - break; - } - } - }; - } - - public static String getCurrentLanguage() { - String languageName = java.util.Locale.getDefault().getLanguage(); - return languageName; - } - - public static void showMessageBox(String title, String message){ - Message msg = new Message(); - msg.what = HANDLER_SHOW_DIALOG; - msg.obj = new DialogMessage(title, message); - - handler.sendMessage(msg); - } - - public static void enableAccelerometer() { - accelerometerEnabled = true; - accelerometer.enable(); - } - - public static void disableAccelerometer() { - accelerometerEnabled = false; - accelerometer.disable(); - } - - public static void preloadBackgroundMusic(String path){ - backgroundMusicPlayer.preloadBackgroundMusic(path); - } - - public static void playBackgroundMusic(String path, boolean isLoop){ - backgroundMusicPlayer.playBackgroundMusic(path, isLoop); - } - - public static void stopBackgroundMusic(){ - backgroundMusicPlayer.stopBackgroundMusic(); - } - - public static void pauseBackgroundMusic(){ - backgroundMusicPlayer.pauseBackgroundMusic(); - } - - public static void resumeBackgroundMusic(){ - backgroundMusicPlayer.resumeBackgroundMusic(); - } - - public static void rewindBackgroundMusic(){ - backgroundMusicPlayer.rewindBackgroundMusic(); - } - - public static boolean isBackgroundMusicPlaying(){ - return backgroundMusicPlayer.isBackgroundMusicPlaying(); - } - - public static float getBackgroundMusicVolume(){ - return backgroundMusicPlayer.getBackgroundVolume(); - } - - public static void setBackgroundMusicVolume(float volume){ - backgroundMusicPlayer.setBackgroundVolume(volume); - } - - public static int playEffect(String path, boolean isLoop){ - return soundPlayer.playEffect(path, isLoop); - } - - public static void stopEffect(int soundId){ - soundPlayer.stopEffect(soundId); - } - - public static void pauseEffect(int soundId){ - soundPlayer.pauseEffect(soundId); - } - - public static void resumeEffect(int soundId){ - soundPlayer.resumeEffect(soundId); - } - - public static float getEffectsVolume(){ - return soundPlayer.getEffectsVolume(); - } - - public static void setEffectsVolume(float volume){ - soundPlayer.setEffectsVolume(volume); - } - - public static void preloadEffect(String path){ - soundPlayer.preloadEffect(path); - } - - public static void unloadEffect(String path){ - soundPlayer.unloadEffect(path); - } - - public static void stopAllEffects(){ - soundPlayer.stopAllEffects(); - } - - public static void pauseAllEffects(){ - soundPlayer.pauseAllEffects(); - } - - public static void resumeAllEffects(){ - soundPlayer.resumeAllEffects(); - } - - public static void end(){ - backgroundMusicPlayer.end(); - soundPlayer.end(); - } - - public static String getCocos2dxPackageName(){ - return packageName; - } - - public static void terminateProcess(){ - android.os.Process.killProcess(android.os.Process.myPid()); - } - - @Override - protected void onResume() { - super.onResume(); - if (accelerometerEnabled) { - accelerometer.enable(); - } - } - - @Override - protected void onPause() { - super.onPause(); - if (accelerometerEnabled) { - accelerometer.disable(); - } - } - - protected void setPackageName(String packageName) { - Cocos2dxActivity.packageName = packageName; - - String apkFilePath = ""; - ApplicationInfo appInfo = null; - PackageManager packMgmr = getApplication().getPackageManager(); - try { - appInfo = packMgmr.getApplicationInfo(packageName, 0); - } catch (NameNotFoundException e) { - e.printStackTrace(); - throw new RuntimeException("Unable to locate assets, aborting..."); - } - apkFilePath = appInfo.sourceDir; - Log.w("apk path", apkFilePath); - - // add this link at the renderer class - nativeSetPaths(apkFilePath); - } - - private void showDialog(String title, String message){ - Dialog dialog = new AlertDialog.Builder(this) - .setTitle(title) - .setMessage(message) - .setPositiveButton("Ok", - new DialogInterface.OnClickListener() - { - public void onClick(DialogInterface dialog, int whichButton){ - - } - }).create(); - - dialog.show(); - } -} - -class DialogMessage { - public String title; - public String message; - - public DialogMessage(String title, String message){ - this.message = message; - this.title = title; - } -} diff --git a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java b/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java deleted file mode 100644 index 4b3d0c6788..0000000000 --- a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxBitmap.java +++ /dev/null @@ -1,413 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.util.LinkedList; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Typeface; -import android.graphics.Paint.Align; -import android.graphics.Paint.FontMetricsInt; -import android.util.Log; - -public class Cocos2dxBitmap{ - /* - * The values are the same as cocos2dx/platform/CCImage.h. - */ - private static final int HALIGNCENTER = 3; - private static final int HALIGNLEFT = 1; - private static final int HALIGNRIGHT = 2; - // vertical alignment - private static final int VALIGNTOP = 1; - private static final int VALIGNBOTTOM = 2; - private static final int VALIGNCENTER = 3; - - private static Context context; - - public static void setContext(Context context){ - Cocos2dxBitmap.context = context; - } - - /* - * @width: the width to draw, it can be 0 - * @height: the height to draw, it can be 0 - */ - public static void createTextBitmap(String content, String fontName, - int fontSize, int alignment, int width, int height){ - - content = refactorString(content); - Paint paint = newPaint(fontName, fontSize, alignment); - - TextProperty textProperty = computeTextProperty(content, paint, width, height); - - int bitmapTotalHeight = (height == 0 ? textProperty.totalHeight:height); - - // Draw text to bitmap - Bitmap bitmap = Bitmap.createBitmap(textProperty.maxWidth, - bitmapTotalHeight, Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(bitmap); - - // Draw string - FontMetricsInt fm = paint.getFontMetricsInt(); - int x = 0; - int y = computeY(fm, height, textProperty.totalHeight, alignment); - String[] lines = textProperty.lines; - for (String line : lines){ - x = computeX(paint, line, textProperty.maxWidth, alignment); - canvas.drawText(line, x, y, paint); - y += textProperty.heightPerLine; - } - - initNativeObject(bitmap); - } - - private static int computeX(Paint paint, String content, int w, int alignment){ - int ret = 0; - int hAlignment = alignment & 0x0F; - - switch (hAlignment){ - case HALIGNCENTER: - ret = w / 2; - break; - - // ret = 0 - case HALIGNLEFT: - break; - - case HALIGNRIGHT: - ret = w; - break; - - /* - * Default is align left. - * Should be same as newPaint(). - */ - default: - break; - } - - return ret; - } - - private static int computeY(FontMetricsInt fm, int constrainHeight, int totalHeight, int alignment) { - int y = -fm.top; - - if (constrainHeight > totalHeight) { - int vAlignment = (alignment >> 4) & 0x0F; - - switch (vAlignment) { - case VALIGNTOP: - y = -fm.top; - break; - case VALIGNCENTER: - y = -fm.top + (constrainHeight - totalHeight)/2; - break; - case VALIGNBOTTOM: - y = -fm.top + (constrainHeight - totalHeight); - break; - default: - break; - } - } - - return y; - } - - private static class TextProperty{ - // The max width of lines - int maxWidth; - // The height of all lines - int totalHeight; - int heightPerLine; - String[] lines; - - TextProperty(int w, int h, String[] lines){ - this.maxWidth = w; - this.heightPerLine = h; - this.totalHeight = h * lines.length; - this.lines = lines; - } - } - - private static TextProperty computeTextProperty(String content, Paint paint, - int maxWidth, int maxHeight){ - FontMetricsInt fm = paint.getFontMetricsInt(); - int h = (int)Math.ceil(fm.bottom - fm.top); - int maxContentWidth = 0; - - String[] lines = splitString(content, maxHeight, maxWidth, paint); - - if (maxWidth != 0){ - maxContentWidth = maxWidth; - } - else { - /* - * Compute the max width - */ - int temp = 0; - for (String line : lines){ - temp = (int)Math.ceil(paint.measureText(line, 0, line.length())); - if (temp > maxContentWidth){ - maxContentWidth = temp; - } - } - } - - return new TextProperty(maxContentWidth, h, lines); - } - - /* - * If maxWidth or maxHeight is not 0, - * split the string to fix the maxWidth and maxHeight. - */ - private static String[] splitString(String content, int maxHeight, int maxWidth, - Paint paint){ - String[] lines = content.split("\\n"); - String[] ret = null; - FontMetricsInt fm = paint.getFontMetricsInt(); - int heightPerLine = (int)Math.ceil(fm.bottom - fm.top); - int maxLines = maxHeight / heightPerLine; - - if (maxWidth != 0){ - LinkedList strList = new LinkedList(); - for (String line : lines){ - /* - * The width of line is exceed maxWidth, should divide it into - * two or more lines. - */ - int lineWidth = (int)Math.ceil(paint.measureText(line)); - if (lineWidth > maxWidth){ - strList.addAll(divideStringWithMaxWidth(paint, line, maxWidth)); - } - else{ - strList.add(line); - } - - /* - * Should not exceed the max height; - */ - if (maxLines > 0 && strList.size() >= maxLines){ - break; - } - } - - /* - * Remove exceeding lines - */ - if (maxLines > 0 && strList.size() > maxLines){ - while (strList.size() > maxLines){ - strList.removeLast(); - } - } - - ret = new String[strList.size()]; - strList.toArray(ret); - } else - if (maxHeight != 0 && lines.length > maxLines) { - /* - * Remove exceeding lines - */ - LinkedList strList = new LinkedList(); - for (int i = 0; i < maxLines; i++){ - strList.add(lines[i]); - } - ret = new String[strList.size()]; - strList.toArray(ret); - } - else { - ret = lines; - } - - return ret; - } - - private static LinkedList divideStringWithMaxWidth(Paint paint, String content, - int width){ - int charLength = content.length(); - int start = 0; - int tempWidth = 0; - LinkedList strList = new LinkedList(); - - /* - * Break a String into String[] by the width & should wrap the word - */ - for (int i = 1; i <= charLength; ++i){ - tempWidth = (int)Math.ceil(paint.measureText(content, start, i)); - if (tempWidth >= width){ - int lastIndexOfSpace = content.substring(0, i).lastIndexOf(" "); - - if (lastIndexOfSpace != -1 && lastIndexOfSpace > start){ - /** - * Should wrap the word - */ - strList.add(content.substring(start, lastIndexOfSpace)); - i = lastIndexOfSpace; - } - else { - /* - * Should not exceed the width - */ - if (tempWidth > width){ - strList.add(content.substring(start, i - 1)); - /* - * compute from previous char - */ - --i; - } - else { - strList.add(content.substring(start, i)); - } - } - - // remove spaces at the beginning of a new line - while(content.indexOf(i++) == ' ') { - } - - start = i; - } - } - - /* - * Add the last chars - */ - if (start < charLength){ - strList.add(content.substring(start)); - } - - return strList; - } - - private static Paint newPaint(String fontName, int fontSize, int alignment){ - Paint paint = new Paint(); - paint.setColor(Color.WHITE); - paint.setTextSize(fontSize); - paint.setAntiAlias(true); - - /* - * Set type face for paint, now it support .ttf file. - */ - if (fontName.endsWith(".ttf")){ - try { - //Typeface typeFace = Typeface.createFromAsset(context.getAssets(), fontName); - Typeface typeFace = Cocos2dxTypefaces.get(context, fontName); - paint.setTypeface(typeFace); - } catch (Exception e){ - Log.e("Cocos2dxBitmap", - "error to create ttf type face: " + fontName); - - /* - * The file may not find, use system font - */ - paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL)); - } - } - else { - paint.setTypeface(Typeface.create(fontName, Typeface.NORMAL)); - } - - int hAlignment = alignment & 0x0F; - switch (hAlignment){ - case HALIGNCENTER: - paint.setTextAlign(Align.CENTER); - break; - - case HALIGNLEFT: - paint.setTextAlign(Align.LEFT); - break; - - case HALIGNRIGHT: - paint.setTextAlign(Align.RIGHT); - break; - - default: - paint.setTextAlign(Align.LEFT); - break; - } - - return paint; - } - - private static String refactorString(String str){ - // Avoid error when content is "" - if (str.compareTo("") == 0){ - return " "; - } - - /* - * If the font of "\n" is "" or "\n", insert " " in front of it. - * - * For example: - * "\nabc" -> " \nabc" - * "\nabc\n\n" -> " \nabc\n \n" - */ - StringBuilder strBuilder = new StringBuilder(str); - int start = 0; - int index = strBuilder.indexOf("\n"); - while (index != -1){ - if (index == 0 || strBuilder.charAt(index -1) == '\n'){ - strBuilder.insert(start, " "); - start = index + 2; - } else { - start = index + 1; - } - - if (start > strBuilder.length() || index == strBuilder.length()){ - break; - } - - index = strBuilder.indexOf("\n", start); - } - - return strBuilder.toString(); - } - - private static void initNativeObject(Bitmap bitmap){ - byte[] pixels = getPixels(bitmap); - if (pixels == null){ - return; - } - - nativeInitBitmapDC(bitmap.getWidth(), bitmap.getHeight(), pixels); - } - - private static byte[] getPixels(Bitmap bitmap){ - if (bitmap != null){ - byte[] pixels = new byte[bitmap.getWidth() * bitmap.getHeight() * 4]; - ByteBuffer buf = ByteBuffer.wrap(pixels); - buf.order(ByteOrder.nativeOrder()); - bitmap.copyPixelsToBuffer(buf); - return pixels; - } - - return null; - } - - private static native void nativeInitBitmapDC(int width, int height, byte[] pixels); -} diff --git a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxEditText.java b/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxEditText.java deleted file mode 100644 index 1c9778293f..0000000000 --- a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxEditText.java +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -Copyright (c) 2012 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ - -package org.cocos2dx.lib; - -import android.content.Context; -import android.util.AttributeSet; -import android.view.KeyEvent; -import android.widget.EditText; - -public class Cocos2dxEditText extends EditText { - - private Cocos2dxGLSurfaceView mView; - - public Cocos2dxEditText(Context context) { - super(context); - // TODO Auto-generated constructor stub - } - - public Cocos2dxEditText(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public Cocos2dxEditText(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - public void setMainView(Cocos2dxGLSurfaceView glSurfaceView) { - mView = glSurfaceView; - } - - /* - * Let GlSurfaceView get focus if back key is input - */ - public boolean onKeyDown(int keyCode, KeyEvent event) { - super.onKeyDown(keyCode, event); - - if (keyCode == KeyEvent.KEYCODE_BACK) { - mView.requestFocus(); - } - - return true; - } -} diff --git a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java b/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java deleted file mode 100644 index e7c4721cf3..0000000000 --- a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxGLSurfaceView.java +++ /dev/null @@ -1,417 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import android.content.Context; -import android.opengl.GLSurfaceView; -import android.os.Handler; -import android.os.Message; -import android.text.Editable; -import android.text.TextWatcher; -import android.util.AttributeSet; -import android.util.Log; -import android.view.KeyEvent; -import android.view.MotionEvent; -import android.view.inputmethod.InputMethodManager; -import android.widget.TextView; -import android.widget.TextView.OnEditorActionListener; - -class TextInputWraper implements TextWatcher, OnEditorActionListener { - - private static final Boolean debug = false; - private void LogD(String msg) { - if (debug) Log.d("TextInputFilter", msg); - } - - private Cocos2dxGLSurfaceView mMainView; - private String mText; - private String mOriginText; - - private Boolean isFullScreenEdit() { - InputMethodManager imm = (InputMethodManager)mMainView.getTextField().getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - return imm.isFullscreenMode(); - } - - public TextInputWraper(Cocos2dxGLSurfaceView view) { - mMainView = view; - } - - public void setOriginText(String text) { - mOriginText = text; - } - - @Override - public void afterTextChanged(Editable s) { - if (isFullScreenEdit()) { - return; - } - - LogD("afterTextChanged: " + s); - int nModified = s.length() - mText.length(); - if (nModified > 0) { - final String insertText = s.subSequence(mText.length(), s.length()).toString(); - mMainView.insertText(insertText); - LogD("insertText(" + insertText + ")"); - } - else { - for (; nModified < 0; ++nModified) { - mMainView.deleteBackward(); - LogD("deleteBackward"); - } - } - mText = s.toString(); - } - - @Override - public void beforeTextChanged(CharSequence s, int start, int count, - int after) { - LogD("beforeTextChanged(" + s + ")start: " + start + ",count: " + count + ",after: " + after); - mText = s.toString(); - } - - @Override - public void onTextChanged(CharSequence s, int start, int before, int count) { - } - - @Override - public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { - if (mMainView.getTextField() == v && isFullScreenEdit()) { - // user press the action button, delete all old text and insert new text - for (int i = mOriginText.length(); i > 0; --i) { - mMainView.deleteBackward(); - LogD("deleteBackward"); - } - String text = v.getText().toString(); - - /* - * If user input nothing, translate "\n" to engine. - */ - if (text.compareTo("") == 0){ - text = "\n"; - } - - if ('\n' != text.charAt(text.length() - 1)) { - text += '\n'; - } - - final String insertText = text; - mMainView.insertText(insertText); - LogD("insertText(" + insertText + ")"); - } - return false; - } -} - -public class Cocos2dxGLSurfaceView extends GLSurfaceView { - - static private Cocos2dxGLSurfaceView mainView; - - private static final String TAG = Cocos2dxGLSurfaceView.class.getCanonicalName(); - private Cocos2dxRenderer mRenderer; - - private static final boolean debug = false; - - /////////////////////////////////////////////////////////////////////////// - // for initialize - /////////////////////////////////////////////////////////////////////////// - public Cocos2dxGLSurfaceView(Context context) { - super(context); - initView(); - } - - public Cocos2dxGLSurfaceView(Context context, AttributeSet attrs) { - super(context, attrs); - initView(); - } - - public void setCocos2dxRenderer(Cocos2dxRenderer renderer){ - mRenderer = renderer; - setRenderer(mRenderer); - } - - protected void initView() { - setFocusableInTouchMode(true); - - textInputWraper = new TextInputWraper(this); - - handler = new Handler(){ - public void handleMessage(Message msg){ - switch(msg.what){ - case HANDLER_OPEN_IME_KEYBOARD: - if (null != mTextField && mTextField.requestFocus()) { - mTextField.removeTextChangedListener(textInputWraper); - mTextField.setText(""); - String text = (String)msg.obj; - mTextField.append(text); - textInputWraper.setOriginText(text); - mTextField.addTextChangedListener(textInputWraper); - InputMethodManager imm = (InputMethodManager)mainView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - imm.showSoftInput(mTextField, 0); - Log.d("GLSurfaceView", "showSoftInput"); - } - break; - - case HANDLER_CLOSE_IME_KEYBOARD: - if (null != mTextField) { - mTextField.removeTextChangedListener(textInputWraper); - InputMethodManager imm = (InputMethodManager)mainView.getContext().getSystemService(Context.INPUT_METHOD_SERVICE); - imm.hideSoftInputFromWindow(mTextField.getWindowToken(), 0); - Log.d("GLSurfaceView", "HideSoftInput"); - } - break; - } - } - }; - - mainView = this; - } - - public void onPause(){ - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleOnPause(); - } - }); - - super.onPause(); - } - - public void onResume(){ - super.onResume(); - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleOnResume(); - } - }); - } - - /////////////////////////////////////////////////////////////////////////// - // for text input - /////////////////////////////////////////////////////////////////////////// - private final static int HANDLER_OPEN_IME_KEYBOARD = 2; - private final static int HANDLER_CLOSE_IME_KEYBOARD = 3; - private static Handler handler; - private static TextInputWraper textInputWraper; - private Cocos2dxEditText mTextField; - - public TextView getTextField() { - return mTextField; - } - - public void setTextField(Cocos2dxEditText view) { - mTextField = view; - if (null != mTextField && null != textInputWraper) { - mTextField.setOnEditorActionListener(textInputWraper); - mTextField.setMainView(this); - this.requestFocus(); - } - } - - public static void openIMEKeyboard() { - Message msg = new Message(); - msg.what = HANDLER_OPEN_IME_KEYBOARD; - msg.obj = mainView.getContentText(); - handler.sendMessage(msg); - - } - - private String getContentText() { - return mRenderer.getContentText(); - } - - public static void closeIMEKeyboard() { - Message msg = new Message(); - msg.what = HANDLER_CLOSE_IME_KEYBOARD; - handler.sendMessage(msg); - } - - public void insertText(final String text) { - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleInsertText(text); - } - }); - } - - public void deleteBackward() { - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleDeleteBackward(); - } - }); - } - - /////////////////////////////////////////////////////////////////////////// - // for touch event - /////////////////////////////////////////////////////////////////////////// - - public boolean onTouchEvent(final MotionEvent event) { - // these data are used in ACTION_MOVE and ACTION_CANCEL - final int pointerNumber = event.getPointerCount(); - final int[] ids = new int[pointerNumber]; - final float[] xs = new float[pointerNumber]; - final float[] ys = new float[pointerNumber]; - - for (int i = 0; i < pointerNumber; i++) { - ids[i] = event.getPointerId(i); - xs[i] = event.getX(i); - ys[i] = event.getY(i); - } - - switch (event.getAction() & MotionEvent.ACTION_MASK) { - case MotionEvent.ACTION_POINTER_DOWN: - final int indexPointerDown = event.getAction() >> MotionEvent.ACTION_POINTER_ID_SHIFT; - final int idPointerDown = event.getPointerId(indexPointerDown); - final float xPointerDown = event.getX(indexPointerDown); - final float yPointerDown = event.getY(indexPointerDown); - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionDown(idPointerDown, xPointerDown, yPointerDown); - } - }); - break; - - case MotionEvent.ACTION_DOWN: - // there are only one finger on the screen - final int idDown = event.getPointerId(0); - final float xDown = xs[0]; - final float yDown = ys[0]; - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionDown(idDown, xDown, yDown); - } - }); - break; - - case MotionEvent.ACTION_MOVE: - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionMove(ids, xs, ys); - } - }); - break; - - case MotionEvent.ACTION_POINTER_UP: - final int indexPointUp = event.getAction() >> MotionEvent.ACTION_POINTER_ID_SHIFT; - final int idPointerUp = event.getPointerId(indexPointUp); - final float xPointerUp = event.getX(indexPointUp); - final float yPointerUp = event.getY(indexPointUp); - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionUp(idPointerUp, xPointerUp, yPointerUp); - } - }); - break; - - case MotionEvent.ACTION_UP: - // there are only one finger on the screen - final int idUp = event.getPointerId(0); - final float xUp = xs[0]; - final float yUp = ys[0]; - - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionUp(idUp, xUp, yUp); - } - }); - break; - - case MotionEvent.ACTION_CANCEL: - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleActionCancel(ids, xs, ys); - } - }); - break; - } - - if (debug){ - dumpEvent(event); - } - return true; - } - - /* - * This function is called before Cocos2dxRenderer.nativeInit(), so the width and height is correct. - */ - protected void onSizeChanged(int w, int h, int oldw, int oldh){ - this.mRenderer.setScreenWidthAndHeight(w, h); - } - - @Override - public boolean onKeyDown(int keyCode, KeyEvent event) { - final int kc = keyCode; - if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_MENU) { - queueEvent(new Runnable() { - @Override - public void run() { - mRenderer.handleKeyDown(kc); - } - }); - return true; - } - return super.onKeyDown(keyCode, event); - } - - // Show an event in the LogCat view, for debugging - private void dumpEvent(MotionEvent event) { - String names[] = { "DOWN" , "UP" , "MOVE" , "CANCEL" , "OUTSIDE" , - "POINTER_DOWN" , "POINTER_UP" , "7?" , "8?" , "9?" }; - StringBuilder sb = new StringBuilder(); - int action = event.getAction(); - int actionCode = action & MotionEvent.ACTION_MASK; - sb.append("event ACTION_" ).append(names[actionCode]); - if (actionCode == MotionEvent.ACTION_POINTER_DOWN - || actionCode == MotionEvent.ACTION_POINTER_UP) { - sb.append("(pid " ).append( - action >> MotionEvent.ACTION_POINTER_ID_SHIFT); - sb.append(")" ); - } - sb.append("[" ); - for (int i = 0; i < event.getPointerCount(); i++) { - sb.append("#" ).append(i); - sb.append("(pid " ).append(event.getPointerId(i)); - sb.append(")=" ).append((int) event.getX(i)); - sb.append("," ).append((int) event.getY(i)); - if (i + 1 < event.getPointerCount()) - sb.append(";" ); - } - sb.append("]" ); - Log.d(TAG, sb.toString()); - } -} diff --git a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxMusic.java b/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxMusic.java deleted file mode 100644 index 10e3e5f3c6..0000000000 --- a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxMusic.java +++ /dev/null @@ -1,228 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import android.content.Context; -import android.content.res.AssetFileDescriptor; -import android.media.MediaPlayer; -import android.util.Log; - -/** - * - * This class is used for controlling background music - * - */ -public class Cocos2dxMusic { - - private static final String TAG = "Cocos2dxMusic"; - private float mLeftVolume; - private float mRightVolume; - private Context mContext; - private MediaPlayer mBackgroundMediaPlayer; - private boolean mIsPaused; - private String mCurrentPath; - - public Cocos2dxMusic(Context context){ - this.mContext = context; - initData(); - } - - public void preloadBackgroundMusic(String path){ - if ((mCurrentPath == null) || (! mCurrentPath.equals(path))){ - // preload new background music - - // release old resource and create a new one - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.release(); - } - - mBackgroundMediaPlayer = createMediaplayerFromAssets(path); - - // record the path - mCurrentPath = path; - } - } - - public void playBackgroundMusic(String path, boolean isLoop){ - if (mCurrentPath == null){ - // it is the first time to play background music - // or end() was called - mBackgroundMediaPlayer = createMediaplayerFromAssets(path); - mCurrentPath = path; - } - else { - if (! mCurrentPath.equals(path)){ - // play new background music - - // release old resource and create a new one - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.release(); - } - mBackgroundMediaPlayer = createMediaplayerFromAssets(path); - - // record the path - mCurrentPath = path; - } - } - - if (mBackgroundMediaPlayer == null){ - Log.e(TAG, "playBackgroundMusic: background media player is null"); - } else { - // if the music is playing or paused, stop it - mBackgroundMediaPlayer.stop(); - - mBackgroundMediaPlayer.setLooping(isLoop); - - try { - mBackgroundMediaPlayer.prepare(); - mBackgroundMediaPlayer.seekTo(0); - mBackgroundMediaPlayer.start(); - - this.mIsPaused = false; - } catch (Exception e){ - Log.e(TAG, "playBackgroundMusic: error state"); - } - } - } - - public void stopBackgroundMusic(){ - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.stop(); - - // should set the state, if not , the following sequence will be error - // play -> pause -> stop -> resume - this.mIsPaused = false; - } - } - - public void pauseBackgroundMusic(){ - if (mBackgroundMediaPlayer != null && mBackgroundMediaPlayer.isPlaying()){ - mBackgroundMediaPlayer.pause(); - this.mIsPaused = true; - } - } - - public void resumeBackgroundMusic(){ - if (mBackgroundMediaPlayer != null && this.mIsPaused){ - mBackgroundMediaPlayer.start(); - this.mIsPaused = false; - } - } - - public void rewindBackgroundMusic(){ - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.stop(); - - try { - mBackgroundMediaPlayer.prepare(); - mBackgroundMediaPlayer.seekTo(0); - mBackgroundMediaPlayer.start(); - - this.mIsPaused = false; - } catch (Exception e){ - Log.e(TAG, "rewindBackgroundMusic: error state"); - } - } - } - - public boolean isBackgroundMusicPlaying(){ - boolean ret = false; - - if (mBackgroundMediaPlayer == null){ - ret = false; - } else { - ret = mBackgroundMediaPlayer.isPlaying(); - } - - return ret; - } - - public void end(){ - if (mBackgroundMediaPlayer != null){ - mBackgroundMediaPlayer.release(); - } - - initData(); - } - - public float getBackgroundVolume(){ - if (this.mBackgroundMediaPlayer != null){ - return (this.mLeftVolume + this.mRightVolume) / 2; - } else { - return 0.0f; - } - } - - public void setBackgroundVolume(float volume){ - if (volume < 0.0f){ - volume = 0.0f; - } - - if (volume > 1.0f){ - volume = 1.0f; - } - - this.mLeftVolume = this.mRightVolume = volume; - if (this.mBackgroundMediaPlayer != null){ - this.mBackgroundMediaPlayer.setVolume(this.mLeftVolume, this.mRightVolume); - } - } - - private void initData(){ - mLeftVolume =0.5f; - mRightVolume = 0.5f; - mBackgroundMediaPlayer = null; - mIsPaused = false; - mCurrentPath = null; - } - - /** - * create mediaplayer for music - * @param path the path relative to assets - * @return - */ - private MediaPlayer createMediaplayerFromAssets(String path){ - MediaPlayer mediaPlayer = new MediaPlayer(); - - try{ - if (path.startsWith("/")) { - mediaPlayer.setDataSource(path); - } - else { - AssetFileDescriptor assetFileDescritor = mContext.getAssets().openFd(path); - mediaPlayer.setDataSource(assetFileDescritor.getFileDescriptor(), - assetFileDescritor.getStartOffset(), assetFileDescritor.getLength()); - } - - mediaPlayer.prepare(); - - mediaPlayer.setVolume(mLeftVolume, mRightVolume); - }catch (Exception e) { - mediaPlayer = null; - Log.e(TAG, "error: " + e.getMessage(), e); - } - - return mediaPlayer; - } -} diff --git a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxRenderer.java b/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxRenderer.java deleted file mode 100644 index fad0974f42..0000000000 --- a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxRenderer.java +++ /dev/null @@ -1,137 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import javax.microedition.khronos.egl.EGLConfig; -import javax.microedition.khronos.opengles.GL10; - -import android.opengl.GLSurfaceView; - -public class Cocos2dxRenderer implements GLSurfaceView.Renderer { - private final static long NANOSECONDSPERSECOND = 1000000000L; - private final static long NANOSECONDSPERMINISECOND = 1000000; - private static long animationInterval = (long)(1.0 / 60 * NANOSECONDSPERSECOND); - private long last; - private int screenWidth; - private int screenHeight; - - public void onSurfaceCreated(GL10 gl, EGLConfig config) { - nativeInit(screenWidth, screenHeight); - last = System.nanoTime(); - } - - public void setScreenWidthAndHeight(int w, int h){ - this.screenWidth = w; - this.screenHeight = h; - } - - public void onSurfaceChanged(GL10 gl, int w, int h) { - } - - public void onDrawFrame(GL10 gl) { - - long now = System.nanoTime(); - long interval = now - last; - - // should render a frame when onDrawFrame() is called - // or there is a "ghost" - nativeRender(); - - // fps controlling - if (interval < animationInterval){ - try { - // because we render it before, so we should sleep twice time interval - Thread.sleep((animationInterval - interval) * 2 / NANOSECONDSPERMINISECOND); - } catch (Exception e){} - } - - last = now; - } - - public void handleActionDown(int id, float x, float y) - { - nativeTouchesBegin(id, x, y); - } - - public void handleActionUp(int id, float x, float y) - { - nativeTouchesEnd(id, x, y); - } - - public void handleActionCancel(int[] id, float[] x, float[] y) - { - nativeTouchesCancel(id, x, y); - } - - public void handleActionMove(int[] id, float[] x, float[] y) - { - nativeTouchesMove(id, x, y); - } - - public void handleKeyDown(int keyCode) - { - nativeKeyDown(keyCode); - } - - public void handleOnPause(){ - nativeOnPause(); - } - - public void handleOnResume(){ - nativeOnResume(); - } - - public static void setAnimationInterval(double interval){ - animationInterval = (long)(interval * NANOSECONDSPERSECOND); - } - private static native void nativeTouchesBegin(int id, float x, float y); - private static native void nativeTouchesEnd(int id, float x, float y); - private static native void nativeTouchesMove(int[] id, float[] x, float[] y); - private static native void nativeTouchesCancel(int[] id, float[] x, float[] y); - private static native boolean nativeKeyDown(int keyCode); - private static native void nativeRender(); - private static native void nativeInit(int w, int h); - private static native void nativeOnPause(); - private static native void nativeOnResume(); - - ///////////////////////////////////////////////////////////////////////////////// - // handle input method edit message - ///////////////////////////////////////////////////////////////////////////////// - - public void handleInsertText(final String text) { - nativeInsertText(text); - } - - public void handleDeleteBackward() { - nativeDeleteBackward(); - } - - public String getContentText() { - return nativeGetContentText(); - } - - private static native void nativeInsertText(String text); - private static native void nativeDeleteBackward(); - private static native String nativeGetContentText(); -} diff --git a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java b/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java deleted file mode 100644 index e7061f74de..0000000000 --- a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxSound.java +++ /dev/null @@ -1,245 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; - -import android.content.Context; -import android.media.AudioManager; -import android.media.SoundPool; -import android.util.Log; - -/** - * - * This class is used for controlling effect - * - */ - -public class Cocos2dxSound { - private Context mContext; - private SoundPool mSoundPool; - private float mLeftVolume; - private float mRightVolume; - - // sound path and stream ids map - // a file may be played many times at the same time - // so there is an array map to a file path - private HashMap> mPathStreamIDsMap; - - private HashMap mPathSoundIdMap; - - private static final String TAG = "Cocos2dxSound"; - private static final int MAX_SIMULTANEOUS_STREAMS_DEFAULT = 5; - private static final float SOUND_RATE = 1.0f; - private static final int SOUND_PRIORITY = 1; - private static final int SOUND_QUALITY = 5; - - private final static int INVALID_SOUND_ID = -1; - private final static int INVALID_STREAM_ID = -1; - - public Cocos2dxSound(Context context){ - this.mContext = context; - initData(); - } - - public int preloadEffect(String path){ - Integer soundID = this.mPathSoundIdMap.get(path); - - if (soundID == null) { - soundID = createSoundIdFromAsset(path); - this.mPathSoundIdMap.put(path, soundID); - } - - return soundID; - } - - public void unloadEffect(String path){ - // stop effects - ArrayList streamIDs = this.mPathStreamIDsMap.get(path); - if (streamIDs != null) { - for (Integer streamID : streamIDs) { - this.mSoundPool.stop(streamID); - } - } - this.mPathStreamIDsMap.remove(path); - - // unload effect - Integer soundID = this.mPathSoundIdMap.get(path); - this.mSoundPool.unload(soundID); - this.mPathSoundIdMap.remove(path); - } - - public int playEffect(String path, boolean isLoop){ - Integer soundId = this.mPathSoundIdMap.get(path); - int streamId = INVALID_STREAM_ID; - - if (soundId != null){ - // play sound - streamId = this.mSoundPool.play(soundId.intValue(), this.mLeftVolume, - this.mRightVolume, SOUND_PRIORITY, isLoop ? -1 : 0, SOUND_RATE); - - // record stream id - ArrayList streamIds = this.mPathStreamIDsMap.get(path); - if (streamIds == null) { - streamIds = new ArrayList(); - this.mPathStreamIDsMap.put(path, streamIds); - } - streamIds.add(streamId); - } else { - // the effect is not prepared - soundId = preloadEffect(path); - if (soundId == INVALID_SOUND_ID){ - // can not preload effect - return INVALID_SOUND_ID; - } - - /* - * Someone reports that, it can not play effect for the - * first time. If you are lucky to meet it. There are two - * ways to resolve it. - * 1. Add some delay here. I don't know how long it is, so - * I don't add it here. - * 2. If you use 2.2(API level 8), you can call - * SoundPool.setOnLoadCompleteListener() to play the effect. - * Because the method is supported from 2.2, so I can't use - * it here. - */ - playEffect(path, isLoop); - } - - return streamId; - } - - public void stopEffect(int streamID){ - this.mSoundPool.stop(streamID); - - // remove record - for (String path : this.mPathStreamIDsMap.keySet()) { - if (this.mPathStreamIDsMap.get(path).contains(streamID)) { - this.mPathStreamIDsMap.get(path).remove(this.mPathStreamIDsMap.get(path).indexOf(streamID)); - break; - } - } - } - - public void pauseEffect(int streamID){ - this.mSoundPool.pause(streamID); - } - - public void resumeEffect(int streamID){ - this.mSoundPool.resume(streamID); - } - - public void pauseAllEffects(){ - this.mSoundPool.autoPause(); - } - - public void resumeAllEffects(){ - // autoPause() is available since level 8 - this.mSoundPool.autoResume(); - } - - @SuppressWarnings("unchecked") - public void stopAllEffects(){ - // stop effects - if (! this.mPathStreamIDsMap.isEmpty()) { - Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry> entry = (Map.Entry>)iter.next(); - for (int streamID : entry.getValue()) { - this.mSoundPool.stop(streamID); - } - } - } - - // remove records - this.mPathStreamIDsMap.clear(); - } - - public float getEffectsVolume(){ - return (this.mLeftVolume + this.mRightVolume) / 2; - } - - @SuppressWarnings("unchecked") - public void setEffectsVolume(float volume){ - // volume should be in [0, 1.0] - if (volume < 0){ - volume = 0; - } - if (volume > 1){ - volume = 1; - } - - this.mLeftVolume = this.mRightVolume = volume; - - // change the volume of playing sounds - if (! this.mPathStreamIDsMap.isEmpty()) { - Iterator iter = this.mPathStreamIDsMap.entrySet().iterator(); - while (iter.hasNext()){ - Map.Entry> entry = (Map.Entry>)iter.next(); - for (int streamID : entry.getValue()) { - this.mSoundPool.setVolume(streamID, mLeftVolume, mRightVolume); - } - } - } - } - - public void end(){ - this.mSoundPool.release(); - this.mPathStreamIDsMap.clear(); - this.mPathSoundIdMap.clear(); - - initData(); - } - - public int createSoundIdFromAsset(String path){ - int soundId = INVALID_SOUND_ID; - - try { - if (path.startsWith("/")){ - soundId = mSoundPool.load(path, 0); - } - else { - soundId = mSoundPool.load(mContext.getAssets().openFd(path), 0); - } - } catch(Exception e){ - soundId = INVALID_SOUND_ID; - Log.e(TAG, "error: " + e.getMessage(), e); - } - - return soundId; - } - - private void initData(){ - this.mPathStreamIDsMap = new HashMap>(); - this.mPathSoundIdMap = new HashMap(); - mSoundPool = new SoundPool(MAX_SIMULTANEOUS_STREAMS_DEFAULT, AudioManager.STREAM_MUSIC, SOUND_QUALITY); - - this.mLeftVolume = 0.5f; - this.mRightVolume = 0.5f; - } -} diff --git a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxTypefaces.java b/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxTypefaces.java deleted file mode 100644 index 79af1ed3af..0000000000 --- a/testjs/proj.android/src/org/cocos2dx/lib/Cocos2dxTypefaces.java +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** -Copyright (c) 2010-2011 cocos2d-x.org - -http://www.cocos2d-x.org - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -****************************************************************************/ -package org.cocos2dx.lib; - -import java.util.Hashtable; - -import android.content.Context; -import android.graphics.Typeface; - -public class Cocos2dxTypefaces { - private static final Hashtable cache = new Hashtable(); - - public static Typeface get(Context context, String name){ - synchronized(cache){ - if (! cache.containsKey(name)){ - Typeface t = Typeface.createFromAsset(context.getAssets(), name); - cache.put(name, t); - } - - return cache.get(name); - } - } -} diff --git a/tests/proj.android/.classpath b/tests/proj.android/.classpath new file mode 100644 index 0000000000..dc00167933 --- /dev/null +++ b/tests/proj.android/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/tests/proj.android/.project b/tests/proj.android/.project new file mode 100644 index 0000000000..861d9cfe4f --- /dev/null +++ b/tests/proj.android/.project @@ -0,0 +1,40 @@ + + + tests + + + + + + com.android.ide.eclipse.adt.ResourceManagerBuilder + + + + + com.android.ide.eclipse.adt.PreCompilerBuilder + + + + + org.eclipse.jdt.core.javabuilder + + + + + com.android.ide.eclipse.adt.ApkBuilder + + + + + + com.android.ide.eclipse.adt.AndroidNature + org.eclipse.jdt.core.javanature + + + + src_common + 2 + PARENT-2-PROJECT_LOC/cocos2dx/platform/android/java/src_common + + + diff --git a/tests/proj.android/project.properties b/tests/proj.android/project.properties index 1d45f1ffd3..d0866d92a7 100644 --- a/tests/proj.android/project.properties +++ b/tests/proj.android/project.properties @@ -8,6 +8,6 @@ # project structure. # Project target. -target=android-8 +target=android-10 android.library.reference.1=../../cocos2dx/platform/android/java From 06f941b8c0285361bccf01a251e1bc95b597837c Mon Sep 17 00:00:00 2001 From: folecr Date: Fri, 15 Jun 2012 09:17:42 -0700 Subject: [PATCH 196/257] Script uses updated directory name when copying files --- template/android/copy_files.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/android/copy_files.sh b/template/android/copy_files.sh index 5fa8148cfe..9749766fc2 100644 --- a/template/android/copy_files.sh +++ b/template/android/copy_files.sh @@ -48,7 +48,7 @@ copy_src_and_jni(){ } copy_library_src(){ - cp -rf $COCOSJAVALIB_ROOT/src/* $APP_DIR/proj.android/src/ + cp -rf $COCOSJAVALIB_ROOT/src_common/* $APP_DIR/proj.android/src/ } # copy build_native.sh and replace something From 90a6a654045ce4e9a0de049cb4a80aa07a38d879 Mon Sep 17 00:00:00 2001 From: folecr Date: Fri, 15 Jun 2012 09:24:10 -0700 Subject: [PATCH 197/257] Modify source.dir to match updated directory name --- cocos2dx/platform/android/java/ant.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/cocos2dx/platform/android/java/ant.properties b/cocos2dx/platform/android/java/ant.properties index b0971e891e..e06eefd0d1 100644 --- a/cocos2dx/platform/android/java/ant.properties +++ b/cocos2dx/platform/android/java/ant.properties @@ -15,3 +15,4 @@ # 'key.alias' for the name of the key to use. # The password will be asked during the build when you use the 'release' target. +source.dir=src_common From 420d9ef41babc60f06c49a015f636b4c5f23e048 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Fri, 15 Jun 2012 14:01:57 -0700 Subject: [PATCH 198/257] Fixed fntFile and fontTTF properties not having the full path prexifed, if they are non system fonts. --- .../extensions/CCBReader/CCLabelBMFontLoader.cpp | 4 +--- cocos2dx/extensions/CCBReader/CCNodeLoader.cpp | 15 +++++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.cpp b/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.cpp index 8fd31fb2ed..894876df04 100644 --- a/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.cpp @@ -39,9 +39,7 @@ void CCLabelBMFontLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pPa void CCLabelBMFontLoader::onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pFntFile, CCBReader * pCCBReader) { if(pPropertyName->compare(PROPERTY_FNTFILE) == 0) { - CCString * fntFilePath = CCBReader::concat(pCCBReader->getCCBRootPath(), pFntFile); - - ((CCLabelBMFont *)pNode)->setFntFile(fntFilePath->getCString()); + ((CCLabelBMFont *)pNode)->setFntFile(pFntFile->getCString()); } else { CCNodeLoader::onHandlePropTypeFntFile(pNode, pParent, pPropertyName, pFntFile, pCCBReader); } diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp index 53bc15040f..3be76147d4 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp @@ -525,7 +525,9 @@ ccBlendFunc CCNodeLoader::parsePropTypeBlendFunc(CCNode * pNode, CCNode * pParen } CCString * CCNodeLoader::parsePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - return pCCBReader->readCachedString(); + CCString * fntFile = pCCBReader->readCachedString(); + + return CCBReader::concat(pCCBReader->getCCBRootPath(), fntFile); } CCString * CCNodeLoader::parsePropTypeString(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { @@ -537,15 +539,16 @@ CCString * CCNodeLoader::parsePropTypeText(CCNode * pNode, CCNode * pParent, CCB } CCString * CCNodeLoader::parsePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { - CCString * fnt = pCCBReader->readCachedString(); + CCString * fontTTF = pCCBReader->readCachedString(); - CCString * ttfEnding = CCString::stringWithCString("ttf"); + CCString * ttfEnding = CCString::stringWithCString(".ttf"); - if(CCBReader::endsWith(CCBReader::toLowerCase(fnt), ttfEnding)){ - fnt = CCBReader::deletePathExtension(CCBReader::lastPathComponent(fnt)); + /* System fonts come without the ".ttf" extension, so remove the path if there is one. */ + if(CCBReader::endsWith(CCBReader::toLowerCase(fontTTF), ttfEnding)){ + fontTTF = CCBReader::concat(pCCBReader->getCCBRootPath(), fontTTF); } - return fnt; + return fontTTF; } BlockData * CCNodeLoader::parsePropTypeBlock(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { From f0c1a4001c10df0450e6b7eafa68ee6ef5124721 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Fri, 15 Jun 2012 14:06:01 -0700 Subject: [PATCH 199/257] Removed CC_FONT_LABEL_SUPPORT since it wasn't defined anywhere and now custom TTF fonts work. --- cocos2dx/platform/ios/CCImage.mm | 24 +++++++++--------------- cocos2dx/textures/CCTexture2D.cpp | 4 ---- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/cocos2dx/platform/ios/CCImage.mm b/cocos2dx/platform/ios/CCImage.mm index 55f7684512..c46644dc2f 100644 --- a/cocos2dx/platform/ios/CCImage.mm +++ b/cocos2dx/platform/ios/CCImage.mm @@ -230,17 +230,14 @@ static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAl dim = _calculateStringSizeWithFontOrZFont(str, font, &constrainSize, false); } -#if CC_FONT_LABEL_SUPPORT if (! font) { font = [[FontManager sharedManager] zFontWithName:fntName pointSize:nSize]; if (font) { - //dim = [str sizeWithZFont:font]; - dim =_caculateStringSizeWithFontOrZFont(str, font, &constrainSize, true); + dim =_calculateStringSizeWithFontOrZFont(str, font, &constrainSize, true); } } -#endif // CC_FONT_LABEL_SUPPORT if (! font) { @@ -316,17 +313,14 @@ static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAl : UITextAlignmentLeft; // normal fonts - if( [font isKindOfClass:[UIFont class] ] ) - { - [str drawInRect:CGRectMake(0, startH, dim.width, dim.height) withFont:font lineBreakMode:UILineBreakModeWordWrap alignment:align]; - } - -#if CC_FONT_LABEL_SUPPORT - else // ZFont class - { - [FontLabelStringDrawingHelper drawInRect:str rect:CGRectMake(0, startH, dim.width, dim.height) withZFont:font lineBreakMode:UILineBreakModeWordWrap alignment:align]; - } -#endif + if( [font isKindOfClass:[UIFont class] ] ) + { + [str drawInRect:CGRectMake(0, startH, dim.width, dim.height) withFont:font lineBreakMode:UILineBreakModeWordWrap alignment:align]; + } + else // ZFont class + { + [FontLabelStringDrawingHelper drawInRect:str rect:CGRectMake(0, startH, dim.width, dim.height) withZFont:font lineBreakMode:UILineBreakModeWordWrap alignment:align]; + } UIGraphicsPopContext(); diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index eda5d60464..9df0bfee43 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -51,10 +51,6 @@ THE SOFTWARE. NS_CC_BEGIN -#if CC_FONT_LABEL_SUPPORT -// FontLabel support -#endif// CC_FONT_LABEL_SUPPORT - //CLASS IMPLEMENTATIONS: // If the image has alpha, you can create RGBA8 (32-bit) or RGBA4 (16-bit) or RGB5A1 (16-bit) From d175884f79ec2fc87e45291da4c8d800bb2627cd Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Fri, 15 Jun 2012 14:48:36 -0700 Subject: [PATCH 200/257] Added ParticleSystemTest. --- .../HelloCocosBuilderLayer.cpp | 5 +++-- .../ParticleSystemTestLayer.h | 12 ++++++++++++ .../ParticleSystemTestLayerLoader.h | 18 ++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/ParticleSystemTest/ParticleSystemTestLayer.h create mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/ParticleSystemTest/ParticleSystemTestLayerLoader.h diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp index 164ee1dd24..384ff6a6b7 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp @@ -8,6 +8,7 @@ #include "../ButtonTest/ButtonTestLayerLoader.h" #include "../SpriteTest/SpriteTestLayerLoader.h" #include "../MenuTest/MenuTestLayerLoader.h" +#include "../ParticleSystemTest/ParticleSystemTestLayerLoader.h" USING_NS_CC; USING_NS_CC_EXT; @@ -73,7 +74,7 @@ SEL_CCControlHandler HelloCocosBuilderLayer::onResolveCCBCCControlSelector(CCObj bool HelloCocosBuilderLayer::onAssignCCBMemberVariable(CCObject * pTarget, CCString * pMemberVariableName, CCNode * pNode) { CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mBurstSprite", CCSprite *, this->mBurstSprite); - CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mTestTitleLabel", CCLabelTTF *, this->mTestTitleLabelTTF); + CCB_MEMBERVARIABLEASSIGNER_GLUE(this, "mTestTitleLabelTTF", CCLabelTTF *, this->mTestTitleLabelTTF); return false; } @@ -96,7 +97,7 @@ void HelloCocosBuilderLayer::onLabelTestClicked(CCObject * pSender, cocos2d::ext } void HelloCocosBuilderLayer::onParticleSystemTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - CCLog("onParticleSystemTestClicked\n"); + this->openTest("ccb/ParticleSystemTest.ccbi", "ParticleSystemTestLayer", ParticleSystemTestLayerLoader::loader()); } void HelloCocosBuilderLayer::onScrollViewTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ParticleSystemTest/ParticleSystemTestLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/ParticleSystemTest/ParticleSystemTestLayer.h new file mode 100644 index 0000000000..f876b09456 --- /dev/null +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/ParticleSystemTest/ParticleSystemTestLayer.h @@ -0,0 +1,12 @@ +#ifndef _PARTICLESYSTEMTESTLAYER_H_ +#define _PARTICLESYSTEMTESTLAYER_H_ + +#include "cocos2d.h" +#include "extensions/CCBReader/CCBReader.h" + +class ParticleSystemTestLayer : public cocos2d::CCLayer { + public: + CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(ParticleSystemTestLayer, node); +}; + +#endif \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ParticleSystemTest/ParticleSystemTestLayerLoader.h b/tests/tests/ExtensionsTest/CocosBuilderTest/ParticleSystemTest/ParticleSystemTestLayerLoader.h new file mode 100644 index 0000000000..4a6dcafde2 --- /dev/null +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/ParticleSystemTest/ParticleSystemTestLayerLoader.h @@ -0,0 +1,18 @@ +#ifndef _PARTICLESYSTEMTESTLOADER_H_ +#define _PARTICLESYSTEMTESTLOADER_H_ + +#include "extensions/CCBReader/CCLayerLoader.h" +#include "ParticleSystemTestLayer.h" + +/* Forward declaration. */ +class CCBReader; + +class ParticleSystemTestLayerLoader : public cocos2d::extension::CCLayerLoader { + public: + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(ParticleSystemTestLayerLoader, loader); + + protected: + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(ParticleSystemTestLayer); +}; + +#endif From 54944ab1f983b18121550429c7640845ebd74874 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Fri, 15 Jun 2012 16:06:54 -0700 Subject: [PATCH 201/257] Fixed a comment. --- cocos2dx/extensions/CCBReader/CCNodeLoader.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp index 3be76147d4..a08373aac2 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp @@ -540,10 +540,11 @@ CCString * CCNodeLoader::parsePropTypeText(CCNode * pNode, CCNode * pParent, CCB CCString * CCNodeLoader::parsePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { CCString * fontTTF = pCCBReader->readCachedString(); - + CCString * ttfEnding = CCString::stringWithCString(".ttf"); - /* System fonts come without the ".ttf" extension, so remove the path if there is one. */ + /* If the fontTTF comes with the ".ttf" extension, prepend the absolute path. + * System fonts come without the ".ttf" extension and do not need the path prepended. */ if(CCBReader::endsWith(CCBReader::toLowerCase(fontTTF), ttfEnding)){ fontTTF = CCBReader::concat(pCCBReader->getCCBRootPath(), fontTTF); } From c38bfd0a24ce1a9aff7ea2b45b2269de893c3eb0 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Fri, 15 Jun 2012 16:16:08 -0700 Subject: [PATCH 202/257] Updated xcode project file. --- tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id index 14135b7a59..1c73b6b5a2 100644 --- a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -862a940ac3fd58a64c60cec2e314ac0c7dc8d95a \ No newline at end of file +27383209967a9766d9a97aed9f11c975331fd3bf \ No newline at end of file From 73c9707d5d7d83f542a9be2091270bb541c25e46 Mon Sep 17 00:00:00 2001 From: James Chen Date: Sat, 16 Jun 2012 12:48:20 +0800 Subject: [PATCH 203/257] CCBIReader fixes + building and running flawless on iOS and Android. Made it works on win32. --- cocos2dx/cocoa/CCString.h | 1 + cocos2dx/extensions/CCBReader/CCBReader.cpp | 15 +- tests/proj.win32/test.win32.vcproj | 134 ++++++++++++------ .../ButtonTest/ButtonTestLayer.h | 6 +- .../HelloCocosBuilderLayer.h | 7 +- .../CocosBuilderTest/MenuTest/MenuTestLayer.h | 6 +- .../TestHeader/TestHeaderLayer.h | 5 +- 7 files changed, 121 insertions(+), 53 deletions(-) diff --git a/cocos2dx/cocoa/CCString.h b/cocos2dx/cocoa/CCString.h index 49c619a742..b1d2e55bb8 100644 --- a/cocos2dx/cocoa/CCString.h +++ b/cocos2dx/cocoa/CCString.h @@ -25,6 +25,7 @@ THE SOFTWARE. #define __CCSTRING_H__ #include +#include #include "CCObject.h" NS_CC_BEGIN diff --git a/cocos2dx/extensions/CCBReader/CCBReader.cpp b/cocos2dx/extensions/CCBReader/CCBReader.cpp index 2a17be97f9..3ad4472939 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader.cpp @@ -51,7 +51,7 @@ CCBReader::CCBReader(CCBReader * pCCBReader) { } CCBReader::~CCBReader() { - CC_SAFE_DELETE(this->mBytes); + CC_SAFE_DELETE_ARRAY(this->mBytes); this->mCCNodeLoaderLibrary->release(); @@ -104,8 +104,6 @@ CCNode * CCBReader::readNodeGraphFromFile(CCString * pCCBRootPath, CCString * pC const char * path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(ccbFullFilePath->getCString()); - CC_SAFE_FREE(ccbFullFilePath); - unsigned long size = 0; this->mBytes = CCFileUtils::sharedFileUtils()->getFileData(path, "rb", &size); @@ -390,15 +388,16 @@ CCString * CCBReader::toLowerCase(CCString * pString) { } CCString * CCBReader::concat(CCString * pStringA, CCString * pStringB) { - int concatenatedLength = pStringA->length() + pStringB->length() + 1; - char concatenated[concatenatedLength]; - + int concatenatedLength = pStringA->length() + pStringB->length(); + char* concatenated = (char*) malloc(concatenatedLength+1); + CCString* pRet = NULL; strcpy(concatenated, pStringA->getCString()); strcat(concatenated, pStringB->getCString()); concatenated[concatenatedLength] = '\0'; - - return CCString::stringWithCString(concatenated); + pRet = CCString::stringWithCString(concatenated); + CC_SAFE_FREE(concatenated); + return pRet; } bool CCBReader::endsWith(CCString * pString, CCString * pEnding) { diff --git a/tests/proj.win32/test.win32.vcproj b/tests/proj.win32/test.win32.vcproj index 3a0a332e6f..b948c75801 100644 --- a/tests/proj.win32/test.win32.vcproj +++ b/tests/proj.win32/test.win32.vcproj @@ -893,22 +893,6 @@ - - - - - - - - @@ -917,38 +901,106 @@ RelativePath="..\tests\ExtensionsTest\CocosBuilderTest\CocosBuilderTest.h" > - - - + + + + + + + - - + + + + + + + - - + + + + + - - + + + + + + + - - + + + + + - - + + + + + - - - + + + + + + + Date: Sat, 16 Jun 2012 13:04:23 +0800 Subject: [PATCH 204/257] issue #1330: Added virtual destructor for interfaces. --- cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h | 1 + cocos2dx/extensions/CCBReader/CCBSelectorResolver.h | 1 + cocos2dx/extensions/CCBReader/CCNodeLoaderListener.h | 1 + 3 files changed, 3 insertions(+) diff --git a/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h b/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h index 3df8d02e4e..8843fdef31 100644 --- a/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h +++ b/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h @@ -14,6 +14,7 @@ NS_CC_EXT_BEGIN class CC_DLL CCBMemberVariableAssigner { public: + virtual ~CCBMemberVariableAssigner() {} virtual bool onAssignCCBMemberVariable(CCObject * pTarget, cocos2d::CCString * pMemberVariableName, CCNode * pNode) = 0; }; diff --git a/cocos2dx/extensions/CCBReader/CCBSelectorResolver.h b/cocos2dx/extensions/CCBReader/CCBSelectorResolver.h index 2944428fc5..589d292d9d 100644 --- a/cocos2dx/extensions/CCBReader/CCBSelectorResolver.h +++ b/cocos2dx/extensions/CCBReader/CCBSelectorResolver.h @@ -15,6 +15,7 @@ NS_CC_EXT_BEGIN class CC_DLL CCBSelectorResolver { public: + virtual ~CCBSelectorResolver() {} virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName) = 0; virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(CCObject * pTarget, CCString * pSelectorName) = 0; }; diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoaderListener.h b/cocos2dx/extensions/CCBReader/CCNodeLoaderListener.h index a7730c581b..8c389c7289 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoaderListener.h +++ b/cocos2dx/extensions/CCBReader/CCNodeLoaderListener.h @@ -7,6 +7,7 @@ NS_CC_EXT_BEGIN class CC_DLL CCNodeLoaderListener { public: + virtual ~CCNodeLoaderListener() {} virtual void onNodeLoaded(CCNode * pNode, CCNodeLoader * pNodeLoader) = 0; }; From 453a7c63d3e1e1f0d56f93655a4d77334f0fb5fb Mon Sep 17 00:00:00 2001 From: James Chen Date: Sat, 16 Jun 2012 14:31:57 +0800 Subject: [PATCH 205/257] issue #1330: Some memory leaks fixes. --- cocos2dx/extensions/CCBReader/CCNodeLoader.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp index f828b89437..d1e9b5edca 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp @@ -86,7 +86,7 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * if(setProp) { this->onHandlePropTypeScaleLock(pNode, pParent, propertyName, scaleLock, pCCBReader); } - delete scaleLock; + delete[] scaleLock; break; } case kCCBPropTypeFloat: { @@ -129,7 +129,7 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * if(setProp) { this->onHandlePropTypeFloatVar(pNode, pParent, propertyName, floatVar, pCCBReader); } - delete floatVar; + delete[] floatVar; break; } case kCCBPropTypeCheck: { @@ -179,7 +179,7 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * if(setProp) { this->onHandlePropTypeColor4FVar(pNode, pParent, propertyName, color4FVar, pCCBReader); } - delete color4FVar; + delete[] color4FVar; break; } case kCCBPropTypeFlip: { @@ -187,7 +187,7 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * if(setProp) { this->onHandlePropTypeFlip(pNode, pParent, propertyName, flip, pCCBReader); } - delete flip; + delete[] flip; break; } case kCCBPropTypeBlendFunc: { From 3cf0f3555c4b467330caec3b3ed36d8d7d300ec4 Mon Sep 17 00:00:00 2001 From: James Chen Date: Sat, 16 Jun 2012 15:22:23 +0800 Subject: [PATCH 206/257] issue #1330: Removed virtual for callback functions. --- .../CocosBuilderTest/ButtonTest/ButtonTestLayer.h | 2 +- .../HelloCocosBuilder/HelloCocosBuilderLayer.h | 12 ++++++------ .../CocosBuilderTest/MenuTest/MenuTestLayer.h | 6 +++--- .../CocosBuilderTest/TestHeader/TestHeaderLayer.h | 2 +- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h index f9dfc63e82..34aa2c01c7 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h @@ -18,7 +18,7 @@ class ButtonTestLayer virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); virtual bool onAssignCCBMemberVariable(cocos2d::CCObject * pTarget, cocos2d::CCString * pMemberVariableName, cocos2d::CCNode * pNode); - virtual void onCCControlButtonClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); + void onCCControlButtonClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); private: cocos2d::CCLabelBMFont * mCCControlEventLabel; diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h index a93531b190..1a3524b361 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h @@ -33,12 +33,12 @@ class HelloCocosBuilderLayer virtual bool onAssignCCBMemberVariable(cocos2d::CCObject * pTarget, cocos2d::CCString * pMemberVariableName, cocos2d::CCNode * pNode); virtual void onNodeLoaded(cocos2d::CCNode * pNode, cocos2d::extension::CCNodeLoader * pNodeLoader); - virtual void onMenuTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); - virtual void onSpriteTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); - virtual void onButtonTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); - virtual void onLabelTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); - virtual void onParticleSystemTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); - virtual void onScrollViewTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); + void onMenuTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); + void onSpriteTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); + void onButtonTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); + void onLabelTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); + void onParticleSystemTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); + void onScrollViewTestClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); private: cocos2d::CCSprite * mBurstSprite; diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h index fd4ff6538e..c4cd5e30eb 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h @@ -18,9 +18,9 @@ class MenuTestLayer virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); virtual bool onAssignCCBMemberVariable(cocos2d::CCObject * pTarget, cocos2d::CCString * pMemberVariableName, cocos2d::CCNode * pNode); - virtual void onMenuItemAClicked(cocos2d::CCObject * pSender); - virtual void onMenuItemBClicked(cocos2d::CCObject * pSender); - virtual void onMenuItemCClicked(cocos2d::CCObject * pSender); + void onMenuItemAClicked(cocos2d::CCObject * pSender); + void onMenuItemBClicked(cocos2d::CCObject * pSender); + void onMenuItemCClicked(cocos2d::CCObject * pSender); private: cocos2d::CCLabelBMFont * mMenuItemStatusLabelBMFont; diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h index 91730d19bd..4c9acfa9c6 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h @@ -15,7 +15,7 @@ class TestHeaderLayer virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); - virtual void onBackClicked(cocos2d::CCObject * pSender); + void onBackClicked(cocos2d::CCObject * pSender); }; #endif \ No newline at end of file From d53a9fc06eed2bfb7fbde8def852763236ed2718 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 18 Jun 2012 11:48:03 +0800 Subject: [PATCH 207/257] modify xcode project setting for HelloWorld HelloLua and testjs --- .../proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- .../HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id b/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id index 2e21e7243c..a1877f023a 100644 --- a/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -cbcce8ff39bec50486918e1f66c700960446d536 \ No newline at end of file +27504f6baf10e5dd447e1b9e149a88b963074dec \ No newline at end of file diff --git a/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id b/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id index 5405d51a18..e2ea9875ed 100644 --- a/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -b9567f1b9c51fbce0bc5ed542e3101c8d32179db \ No newline at end of file +f4f9e78d583a826744b48fcc5ca3103438b744cf \ No newline at end of file diff --git a/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id b/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id index 7f2a149d0c..ee865c2c7b 100644 --- a/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -5a548bf62fdc41ace1f6ab427eb8663a9098ac25 \ No newline at end of file +36966a60baa47675db677ea1bbb2cc5eb30d2fe6 \ No newline at end of file From c1f5d173efb6aa87c6806256ef1c7407f1e5d161 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 18 Jun 2012 16:16:09 +0800 Subject: [PATCH 208/257] fixed #1332: add cocos2d version --- cocos2dx/include/cocos2d.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cocos2dx/include/cocos2d.h b/cocos2dx/include/cocos2d.h index 789ed06bf4..a708e7c56c 100755 --- a/cocos2dx/include/cocos2d.h +++ b/cocos2dx/include/cocos2d.h @@ -27,6 +27,10 @@ THE SOFTWARE. #ifndef __COCOS2D_H__ #define __COCOS2D_H__ +// 0x00 HI ME LO +// 00 02 00 00 +#define COCOS2D_VERSION 0x00020000 + // // all cocos2d include files // From 85ff7054155532ea29cdb0e8a5dfcfbc8129a24d Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 18 Jun 2012 18:30:07 +0800 Subject: [PATCH 209/257] fixed #1333: added CCScrollView to extension. --- .../extensions/CCScrollView/CCScrollView.cpp | 712 ++++++++++++++++++ .../extensions/CCScrollView/CCScrollView.h | 336 +++++++++ 2 files changed, 1048 insertions(+) create mode 100644 cocos2dx/extensions/CCScrollView/CCScrollView.cpp create mode 100644 cocos2dx/extensions/CCScrollView/CCScrollView.h diff --git a/cocos2dx/extensions/CCScrollView/CCScrollView.cpp b/cocos2dx/extensions/CCScrollView/CCScrollView.cpp new file mode 100644 index 0000000000..5837794431 --- /dev/null +++ b/cocos2dx/extensions/CCScrollView/CCScrollView.cpp @@ -0,0 +1,712 @@ +// +// SWScrollView.m +// SWGameLib +// +// Copyright (c) 2010-2012 cocos2d-x.org +// Copyright (c) 2010 Sangwoo Im +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN false EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +// Created by Sangwoo Im on 6/3/10. +// Copyright 2010 Sangwoo Im. All rights reserved. +// + +#include "CCScrollView.h" +#include "CCActionInterval.h" +#include "CCActionTween.h" +#include "CCActionInstant.h" +#include "CCPointExtension.h" +#include "CCTouchDispatcher.h" +#include "CCGrid.h" +#include "CCDirector.h" +#include "kazmath/GL/matrix.h" +#include "CCTouch.h" + +NS_CC_EXT_BEGIN + +#define SCROLL_DEACCEL_RATE 0.95f +#define SCROLL_DEACCEL_DIST 1.0f +#define BOUNCE_DURATION 0.15f +#define INSET_RATIO 0.2f + + +CCScrollView::CCScrollView() +: m_fZoomScale(0.0f) +, m_fMinZoomScale(0.0f) +, m_fMaxZoomScale(0.0f) +, m_pDelegate(NULL) +, m_bDragging(false) +, m_bBounceable(false) +, m_eDirection(CCScrollViewDirectionBoth) +, m_bClippingToBounds(false) +, m_pContainer(NULL) +, m_bTouchMoved(false) +, m_fTouchLength(0.0f) +, m_pTouches(NULL) +, m_fMinScale(0.0f) +, m_fMaxScale(0.0f) +{ + +} + +CCScrollView::~CCScrollView() +{ + m_pTouches->release(); +} + +CCScrollView* CCScrollView::viewWithViewSize(CCSize size, CCNode* container/* = NULL*/) +{ + return CCScrollView::create(size, container); +} + +CCScrollView* CCScrollView::create(CCSize size, CCNode* container/* = NULL*/) +{ + CCScrollView* pRet = new CCScrollView(); + if (pRet && pRet->initWithViewSize(size, container)) + { + pRet->autorelease(); + } + else + { + CC_SAFE_DELETE(pRet); + } + return pRet; +} + +CCScrollView* CCScrollView::node() +{ + return CCScrollView::create(); +} + +CCScrollView* CCScrollView::create() +{ + CCScrollView* pRet = new CCScrollView(); + if (pRet && pRet->init()) + { + pRet->autorelease(); + } + else + { + CC_SAFE_DELETE(pRet); + } + return pRet; +} + + +bool CCScrollView::initWithViewSize(CCSize size, CCNode *container/* = NULL*/) +{ + if (CCLayer::init()) + { + m_pContainer = container; + + if (!this->m_pContainer) + { + m_pContainer = CCLayer::node(); + } + + this->setViewSize(size); + + setTouchEnabled(true); + m_pTouches = new CCArray(); + m_pDelegate = NULL; + m_bBounceable = true; + m_bClippingToBounds = true; + m_pContainer->setContentSize(CCSizeZero); + m_eDirection = CCScrollViewDirectionBoth; + m_pContainer->setPosition(ccp(0.0f, 0.0f)); + m_fTouchLength = 0.0f; + + this->addChild(m_pContainer); + m_fMinScale = m_fMaxScale = 1.0f; + return true; + } + return false; +} + +bool CCScrollView::init() +{ + return this->initWithViewSize(CCSizeMake(200, 200), NULL); +} + +void CCScrollView::registerWithTouchDispatcher() +{ + CCDirector::sharedDirector()->getTouchDispatcher()->addTargetedDelegate(this, 0, false); +} + +bool CCScrollView::isNodeVisible(CCNode* node) +{ + const CCPoint offset = this->getContentOffset(); + const CCSize size = this->getViewSize(); + const float scale = this->getZoomScale(); + + CCRect viewRect; + + viewRect = CCRectMake(-offset.x/scale, -offset.y/scale, size.width/scale, size.height/scale); + + return CCRect::CCRectIntersectsRect(viewRect, node->boundingBox()); +} + +void CCScrollView::pause(CCObject* sender) +{ + m_pContainer->pauseSchedulerAndActions(); + + CCObject* pObj = NULL; + CCArray* pChildren = m_pContainer->getChildren(); + + CCARRAY_FOREACH(pChildren, pObj) + { + CCNode* pChild = (CCNode*)pObj; + pChild->pauseSchedulerAndActions(); + } +} + +void CCScrollView::resume(CCObject* sender) +{ + CCObject* pObj = NULL; + CCArray* pChildren = m_pContainer->getChildren(); + + CCARRAY_FOREACH(pChildren, pObj) + { + CCNode* pChild = (CCNode*)pObj; + pChild->resumeSchedulerAndActions(); + } + + m_pContainer->resumeSchedulerAndActions(); +} + +void CCScrollView::setTouchEnabled(bool e) +{ + CCLayer::setTouchEnabled(e); + if (!e) + { + m_bDragging = false; + m_bTouchMoved = false; + m_pTouches->removeAllObjects(); + } +} + +void CCScrollView::setContentOffset(CCPoint offset, bool animated/* = false*/) +{ + if (animated) + { //animate scrolling + this->setContentOffsetInDuration(offset, BOUNCE_DURATION); + } + else + { //set the container position directly + if (!m_bBounceable) + { + const CCPoint minOffset = this->minContainerOffset(); + const CCPoint maxOffset = this->maxContainerOffset(); + + offset.x = MAX(minOffset.x, MIN(maxOffset.x, offset.x)); + offset.y = MAX(minOffset.y, MIN(maxOffset.y, offset.y)); + } + + m_pContainer->setPosition(offset); + + if (m_pDelegate != NULL) + { + m_pDelegate->scrollViewDidScroll(this); + } + } +} + +void CCScrollView::setContentOffsetInDuration(CCPoint offset, float dt) +{ + CCFiniteTimeAction *scroll, *expire; + + scroll = CCMoveTo::actionWithDuration(dt, offset); + expire = CCCallFuncN::actionWithTarget(this, callfuncN_selector(CCScrollView::stoppedAnimatedScroll)); + m_pContainer->runAction(CCSequence::actions(scroll, expire, NULL)); + this->schedule(schedule_selector(CCScrollView::performedAnimatedScroll)); +} + +CCPoint CCScrollView::getContentOffset() +{ + return m_pContainer->getPosition(); +} + +void CCScrollView::setZoomScale(float s) +{ + if (m_pContainer->getScale() != s) + { + CCPoint oldCenter, newCenter; + CCPoint center; + + if (m_fTouchLength == 0.0f) + { + center = ccp(m_tViewSize.width*0.5f, m_tViewSize.height*0.5f); + center = this->convertToWorldSpace(center); + } + else + { + center = m_tTouchPoint; + } + + oldCenter = m_pContainer->convertToNodeSpace(center); + m_pContainer->setScale(MAX(m_fMinScale, MIN(m_fMaxScale, s))); + newCenter = m_pContainer->convertToWorldSpace(oldCenter); + + const CCPoint offset = ccpSub(center, newCenter); + if (m_pDelegate != NULL) + { + m_pDelegate->scrollViewDidZoom(this); + } + this->setContentOffset(ccpAdd(m_pContainer->getPosition(),offset)); + } +} + +CCFloat CCScrollView::getZoomScale() +{ + return m_pContainer->getScale(); +} + +void CCScrollView::setZoomScale(float s, bool animated) +{ + if (animated) + { + this->setZoomScaleInDuration(s, BOUNCE_DURATION); + } + else + { + this->setZoomScale(s); + } +} + +void CCScrollView::setZoomScaleInDuration(float s, float dt) +{ + if (dt > 0) + { + if (m_pContainer->getScale() != s) + { + CCActionTween *scaleAction; + scaleAction = CCActionTween::actionWithDuration(dt, "zoomScale", m_pContainer->getScale(), s); + this->runAction(scaleAction); + } + } + else + { + this->setZoomScale(s); + } +} + +void CCScrollView::setViewSize(CCSize size) +{ + if (!CCSize::CCSizeEqualToSize(m_tViewSize, size)) + { + m_tViewSize = size; + m_fMaxInset = this->maxContainerOffset(); + m_fMaxInset = ccp(m_fMaxInset.x + m_tViewSize.width * INSET_RATIO, + m_fMaxInset.y + m_tViewSize.height * INSET_RATIO); + m_fMinInset = this->minContainerOffset(); + m_fMinInset = ccp(m_fMinInset.x - m_tViewSize.width * INSET_RATIO, + m_fMinInset.y - m_tViewSize.height * INSET_RATIO); + } +} + +void CCScrollView::relocateContainer(bool animated) +{ + CCPoint oldPoint, min, max; + CCFloat newX, newY; + + min = this->minContainerOffset(); + max = this->maxContainerOffset(); + + oldPoint = m_pContainer->getPosition(); + + newX = oldPoint.x; + newY = oldPoint.y; + if (m_eDirection == CCScrollViewDirectionBoth || m_eDirection == CCScrollViewDirectionHorizontal) + { + newX = MIN(newX, max.x); + newX = MAX(newX, min.x); + } + + if (m_eDirection == CCScrollViewDirectionBoth || m_eDirection == CCScrollViewDirectionVertical) + { + newY = MIN(newY, max.y); + newY = MAX(newY, min.y); + } + + if (newY != oldPoint.y || newX != oldPoint.x) + { + this->setContentOffset(ccp(newX, newY), animated); + } +} + +CCPoint CCScrollView::maxContainerOffset() +{ + return ccp(0.0f, 0.0f); +} + +CCPoint CCScrollView::minContainerOffset() +{ + return ccp(m_tViewSize.width - m_pContainer->getContentSize().width*m_pContainer->getScaleX(), + m_tViewSize.height - m_pContainer->getContentSize().height*m_pContainer->getScaleY()); +} + +void CCScrollView::deaccelerateScrolling(float dt) +{ + if (m_bDragging) + { + this->unschedule(schedule_selector(CCScrollView::deaccelerateScrolling)); + return; + } + + CCFloat newX, newY; + CCPoint maxInset, minInset; + + m_pContainer->setPosition(ccpAdd(m_pContainer->getPosition(), m_tScrollDistance)); + + if (m_bBounceable) + { + maxInset = m_fMaxInset; + minInset = m_fMinInset; + } + else + { + maxInset = this->maxContainerOffset(); + minInset = this->minContainerOffset(); + } + + //check to see if offset lies within the inset bounds + newX = MIN(m_pContainer->getPosition().x, maxInset.x); + newX = MAX(newX, minInset.x); + newY = MIN(m_pContainer->getPosition().y, maxInset.y); + newY = MAX(newY, minInset.y); + + m_tScrollDistance = ccpSub(m_tScrollDistance, ccp(newX - m_pContainer->getPosition().x, newY - m_pContainer->getPosition().y)); + m_tScrollDistance = ccpMult(m_tScrollDistance, SCROLL_DEACCEL_RATE); + this->setContentOffset(ccp(newX,newY)); + + if ((fabsf(m_tScrollDistance.x) <= SCROLL_DEACCEL_DIST && + fabsf(m_tScrollDistance.y) <= SCROLL_DEACCEL_DIST) || + newX == maxInset.x || newX == minInset.x || + newY == maxInset.y || newY == minInset.y) + { + this->unschedule(schedule_selector(CCScrollView::deaccelerateScrolling)); + this->relocateContainer(true); + } +} + +void CCScrollView::stoppedAnimatedScroll(CCNode * node) +{ + this->unschedule(schedule_selector(CCScrollView::performedAnimatedScroll)); +} + +void CCScrollView::performedAnimatedScroll(float dt) +{ + if (m_bDragging) + { + this->unschedule(schedule_selector(CCScrollView::performedAnimatedScroll)); + return; + } + + if (m_pDelegate != NULL) + { + m_pDelegate->scrollViewDidScroll(this); + } +} + + +CCSize CCScrollView::getContentSize() +{ + return CCSizeMake(m_pContainer->getContentSize().width, m_pContainer->getContentSize().height); +} + +void CCScrollView::setContentSize(CCSize size) +{ +// this->setViewSize(size); + + if (m_pContainer != NULL) + { + m_pContainer->setContentSize(size); + m_fMaxInset = this->maxContainerOffset(); + m_fMaxInset = ccp(m_fMaxInset.x + m_tViewSize.width * INSET_RATIO, + m_fMaxInset.y + m_tViewSize.height * INSET_RATIO); + m_fMinInset = this->minContainerOffset(); + m_fMinInset = ccp(m_fMinInset.x - m_tViewSize.width * INSET_RATIO, + m_fMinInset.y - m_tViewSize.height * INSET_RATIO); + } +} +/** + * make sure all children go to the container + */ + +void CCScrollView::addChild(CCNode * child, int zOrder, int tag) +{ + child->ignoreAnchorPointForPosition(false); + child->setAnchorPoint(ccp(0.0f, 0.0f)); + if (m_pContainer != child) { + m_pContainer->addChild(child, zOrder, tag); + } else { + CCLayer::addChild(child, zOrder, tag); + } +} + +void CCScrollView::addChild(CCNode * child, int zOrder) +{ + this->addChild(child, zOrder, child->getTag()); +} + +void CCScrollView::addChild(CCNode * child) +{ + this->addChild(child, child->getZOrder(), child->getTag()); +} + +/** + * clip this view so that outside of the visible bounds can be hidden. + */ + +void CCScrollView::beforeDraw() +{ + if (m_bClippingToBounds) + { + // TODO: This scrollview should respect parents' positions + CCPoint screenPos = this->convertToWorldSpace(this->getParent()->getPosition()); + + glEnable(GL_SCISSOR_TEST); + float s = this->getScale(); + + CCDirector *director = CCDirector::sharedDirector(); + s *= director->getContentScaleFactor(); + + glScissor((GLint)screenPos.x, (GLint)screenPos.y, (GLsizei)(m_tViewSize.width*s), (GLsizei)(m_tViewSize.height*s)); + + } +} + +/** + * retract what's done in beforeDraw so that there's no side effect to + * other nodes. + */ +void CCScrollView::afterDraw() +{ + if (m_bClippingToBounds) + { + glDisable(GL_SCISSOR_TEST); + } +} + +void CCScrollView::visit() +{ + // quick return if not visible + if (!isVisible()) + { + return; + } + + kmGLPushMatrix(); + +// glPushMatrix(); + + if (m_pGrid && m_pGrid->isActive()) + { + m_pGrid->beforeDraw(); + this->transformAncestors(); + } + + this->transform(); + this->beforeDraw(); + + if(m_pChildren) + { + ccArray *arrayData = m_pChildren->data; + unsigned int i=0; + + // draw children zOrder < 0 + for( ; i < arrayData->num; i++ ) + { + CCNode *child = (CCNode*)arrayData->arr[i]; + if ( child->getZOrder() < 0 ) + { + child->visit(); + } + else + { + break; + } + } + + // this draw + this->draw(); + + // draw children zOrder >= 0 + for( ; i < arrayData->num; i++ ) + { + CCNode* child = (CCNode*)arrayData->arr[i]; + child->visit(); + } + + } + else + { + this->draw(); + } + + this->afterDraw(); + if ( m_pGrid && m_pGrid->isActive()) + { + m_pGrid->afterDraw(this); + } + + kmGLPopMatrix(); + +// glPopMatrix(); +} + +bool CCScrollView::ccTouchBegan(CCTouch* touch, CCEvent* event) +{ + if (!this->isVisible()) + { + return false; + } + CCRect frame; + frame = CCRectMake(this->getPosition().x, this->getPosition().y, m_tViewSize.width, m_tViewSize.height); + + //dispatcher does not know about clipping. reject touches outside visible bounds. + if (m_pTouches->count() > 2 || + m_bTouchMoved || + !CCRect::CCRectContainsPoint(frame, m_pContainer->convertToWorldSpace(m_pContainer->convertTouchToNodeSpace(touch)))) + { + return false; + } + + if (!m_pTouches->containsObject(touch)) + { + m_pTouches->addObject(touch); + } + + if (m_pTouches->count() == 1) + { // scrolling + m_tTouchPoint = this->convertTouchToNodeSpace(touch); + m_bTouchMoved = false; + m_bDragging = true; //dragging started + m_tScrollDistance = ccp(0.0f, 0.0f); + m_fTouchLength = 0.0f; + } + else if (m_pTouches->count() == 2) + { + m_tTouchPoint = ccpMidpoint(this->convertTouchToNodeSpace((CCTouch*)m_pTouches->objectAtIndex(0)), + this->convertTouchToNodeSpace((CCTouch*)m_pTouches->objectAtIndex(1))); + m_fTouchLength = ccpDistance(m_pContainer->convertTouchToNodeSpace((CCTouch*)m_pTouches->objectAtIndex(0)), + m_pContainer->convertTouchToNodeSpace((CCTouch*)m_pTouches->objectAtIndex(1))); + m_bDragging = false; + } + return true; +} + +void CCScrollView::ccTouchMoved(CCTouch* touch, CCEvent* event) +{ + if (!this->isVisible()) + { + return; + } + + if (m_pTouches->containsObject(touch)) + { + if (m_pTouches->count() == 1 && m_bDragging) + { // scrolling + CCPoint moveDistance, newPoint, maxInset, minInset; + CCRect frame; + CCFloat newX, newY; + + m_bTouchMoved = true; + frame = CCRectMake(this->getPosition().x, this->getPosition().y, m_tViewSize.width, m_tViewSize.height); + newPoint = this->convertTouchToNodeSpace((CCTouch*)m_pTouches->objectAtIndex(0)); + CCLOG("new x = %f, y = %f; old x = %f, y = %f", newPoint.x, newPoint.y, m_tTouchPoint.x, m_tTouchPoint.y); + moveDistance = ccpSub(newPoint, m_tTouchPoint); + m_tTouchPoint = newPoint; + + if (CCRect::CCRectContainsPoint(frame, this->convertToWorldSpace(newPoint))) + { + switch (m_eDirection) + { + case CCScrollViewDirectionVertical: + moveDistance = ccp(0.0f, moveDistance.y); + break; + case CCScrollViewDirectionHorizontal: + moveDistance = ccp(moveDistance.x, 0.0f); + break; + default: + break; + } + CCLOG("moveDistance = %f", moveDistance); + m_pContainer->setPosition(ccpAdd(m_pContainer->getPosition(), moveDistance)); + + maxInset = m_fMaxInset; + minInset = m_fMinInset; + + + //check to see if offset lies within the inset bounds + newX = MIN(m_pContainer->getPosition().x, maxInset.x); + newX = MAX(newX, minInset.x); + newY = MIN(m_pContainer->getPosition().y, maxInset.y); + newY = MAX(newY, minInset.y); + + m_tScrollDistance = ccpSub(moveDistance, ccp(newX - m_pContainer->getPosition().x, newY - m_pContainer->getPosition().y)); + this->setContentOffset(ccp(newX, newY)); + } + } + else if (m_pTouches->count() == 2 && !m_bDragging) + { + const CCFloat len = ccpDistance(m_pContainer->convertTouchToNodeSpace((CCTouch*)m_pTouches->objectAtIndex(0)), + m_pContainer->convertTouchToNodeSpace((CCTouch*)m_pTouches->objectAtIndex(1))); + this->setZoomScale(this->getZoomScale()*len/m_fTouchLength); + } + } +} + +void CCScrollView::ccTouchEnded(CCTouch* touch, CCEvent* event) +{ + if (!this->isVisible()) + { + return; + } + if (m_pTouches->containsObject(touch)) + { + if (m_pTouches->count() == 1 && m_bTouchMoved) + { + this->schedule(schedule_selector(CCScrollView::deaccelerateScrolling)); + } + m_pTouches->removeObject(touch); + } + + if (m_pTouches->count() == 0) + { + m_bDragging = false; + m_bTouchMoved = false; + } +} + +void CCScrollView::ccTouchCancelled(CCTouch* touch, CCEvent* event) +{ + if (!this->isVisible()) + { + return; + } + m_pTouches->removeObject(touch); + if (m_pTouches->count() == 0) + { + m_bDragging = false; + m_bTouchMoved = false; + } +} + +NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCScrollView/CCScrollView.h b/cocos2dx/extensions/CCScrollView/CCScrollView.h new file mode 100644 index 0000000000..f357f72c57 --- /dev/null +++ b/cocos2dx/extensions/CCScrollView/CCScrollView.h @@ -0,0 +1,336 @@ +// +// SWScrollView.h +// SWGameLib +// +// Copyright (c) 2010-2012 cocos2d-x.org +// Copyright (c) 2010 Sangwoo Im +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +// +// +// Created by Sangwoo Im on 6/3/10. +// Copyright 2010 Sangwoo Im. All rights reserved. +// + +#ifndef __CCSCROLLVIEW_H__ +#define __CCSCROLLVIEW_H__ + +#include "CCLayer.h" + +NS_CC_EXT_BEGIN + +typedef enum { + CCScrollViewDirectionHorizontal = 0, + CCScrollViewDirectionVertical, + CCScrollViewDirectionBoth +} CCScrollViewDirection; + +class CCScrollView; + +class CC_DLL CCScrollViewDelegate +{ +public: + virtual ~CCScrollViewDelegate() {} + virtual void scrollViewDidScroll(CCScrollView* view) = 0; + virtual void scrollViewDidZoom(CCScrollView* view) = 0; +}; + + +/** + * ScrollView support for cocos2d for iphone. + * It provides scroll view functionalities to cocos2d projects natively. + */ +class CC_DLL CCScrollView : public CCLayer +{ +public: + CCScrollView(); + virtual ~CCScrollView(); + + bool init(); + virtual void registerWithTouchDispatcher(); + /** + * Returns an autoreleased scroll view object. + * @warning: This interface will be deprecated in future. + * @param size view size + * @param container parent object + * @return autoreleased scroll view object + */ + static CCScrollView* viewWithViewSize(CCSize size, CCNode* container = NULL); + + /** + * Returns an autoreleased scroll view object. + * + * @param size view size + * @param container parent object + * @return autoreleased scroll view object + */ + static CCScrollView* create(CCSize size, CCNode* container = NULL); + + /** + * Returns an autoreleased scroll view object. + * @warning: This interface will be deprecated in future. + * @param size view size + * @param container parent object + * @return autoreleased scroll view object + */ + static CCScrollView* node(); + + /** + * Returns an autoreleased scroll view object. + * + * @param size view size + * @param container parent object + * @return autoreleased scroll view object + */ + static CCScrollView* create(); + + /** + * Returns a scroll view object + * + * @param size view size + * @param container parent object + * @return scroll view object + */ + bool initWithViewSize(CCSize size, CCNode* container = NULL); + + + /** + * Sets a new content offset. It ignores max/min offset. It just sets what's given. (just like UIKit's UIScrollView) + * + * @param offset new offset + * @param If YES, the view scrolls to the new offset + */ + void setContentOffset(CCPoint offset, bool animated = false); + CCPoint getContentOffset(); + /** + * Sets a new content offset. It ignores max/min offset. It just sets what's given. (just like UIKit's UIScrollView) + * You can override the animation duration with this method. + * + * @param offset new offset + * @param animation duration + */ + void setContentOffsetInDuration(CCPoint offset, float dt); + + void setZoomScale(float s); + /** + * Sets a new scale and does that for a predefined duration. + * + * @param s a new scale vale + * @param animated if YES, scaling is animated + */ + void setZoomScale(float s, bool animated); + + CCFloat getZoomScale(); + + /** + * Sets a new scale for container in a given duration. + * + * @param s a new scale value + * @param animation duration + */ + void setZoomScaleInDuration(float s, float dt); + /** + * Returns the current container's minimum offset. You may want this while you animate scrolling by yourself + */ + CCPoint minContainerOffset(); + /** + * Returns the current container's maximum offset. You may want this while you animate scrolling by yourself + */ + CCPoint maxContainerOffset(); + /** + * Determines if a given node's bounding box is in visible bounds + * + * @return YES if it is in visible bounds + */ + bool isNodeVisible(CCNode * node); + /** + * Provided to make scroll view compatible with SWLayer's pause method + */ + void pause(CCObject* sender); + /** + * Provided to make scroll view compatible with SWLayer's resume method + */ + void resume(CCObject* sender); + + + bool isDragging() {return m_bDragging;} + bool isTouchMoved() { return m_bTouchMoved; } + bool isBounceable() { return m_bBounceable; } + void setBounceable(bool bBounceable) { m_bBounceable = bBounceable; } + + /** + * direction allowed to scroll. CCScrollViewDirectionBoth by default. + */ + CCScrollViewDirection getDirection() { return m_eDirection; } + void setDirection(CCScrollViewDirection eDirection) { m_eDirection = eDirection; } + + CCScrollViewDelegate* getDelegate() { return m_pDelegate; } + void setDelegate(CCScrollViewDelegate* pDelegate) { m_pDelegate = pDelegate; } + + /** override functions */ + // optional + virtual bool ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent); + virtual void ccTouchMoved(CCTouch *pTouch, CCEvent *pEvent); + virtual void ccTouchEnded(CCTouch *pTouch, CCEvent *pEvent); + virtual void ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent); + + virtual void setContentSize(CCSize size); + virtual CCSize getContentSize(); + + /** + * Determines whether it clips its children or not. + */ + bool isClippingToBounds() { return m_bClippingToBounds; } + void setClippingToBounds(bool bClippingToBounds) { m_bClippingToBounds = bClippingToBounds; } + + virtual void visit(); + virtual void addChild(CCNode * child, int zOrder, int tag); + virtual void addChild(CCNode * child, int zOrder); + virtual void addChild(CCNode * child); + void setTouchEnabled(bool e); +private: + /** + * Init this object with a given size to clip its content. + * + * @param size view size + * @return initialized scroll view object + */ + bool initWithViewSize(CCSize size); + /** + * Relocates the container at the proper offset, in bounds of max/min offsets. + * + * @param animated If YES, relocation is animated + */ + void relocateContainer(bool animated); + /** + * implements auto-scrolling behavior. change SCROLL_DEACCEL_RATE as needed to choose + * deacceleration speed. it must be less than 1.0f. + * + * @param dt delta + */ + void deaccelerateScrolling(float dt); + /** + * This method makes sure auto scrolling causes delegate to invoke its method + */ + void performedAnimatedScroll(float dt); + /** + * Expire animated scroll delegate calls + */ + void stoppedAnimatedScroll(CCNode* node); + /** + * clip this view so that outside of the visible bounds can be hidden. + */ + void beforeDraw(); + /** + * retract what's done in beforeDraw so that there's no side effect to + * other nodes. + */ + void afterDraw(); + /** + * Zoom handling + */ + void handleZoom(); + +protected: + /** + * current zoom scale + */ + CCFloat m_fZoomScale; + /** + * min zoom scale + */ + CCFloat m_fMinZoomScale; + /** + * max zoom scale + */ + CCFloat m_fMaxZoomScale; + /** + * scroll view delegate + */ + CCScrollViewDelegate* m_pDelegate; + + CCScrollViewDirection m_eDirection; + /** + * If YES, the view is being dragged. + */ + bool m_bDragging; + + /** + * Content offset. Note that left-bottom point is the origin + */ + CCPoint m_tContentOffset; + + /** + * Container holds scroll view contents, Sets the scrollable container object of the scroll view + */ + CCNode* m_pContainer; + /** + * Determiens whether user touch is moved after begin phase. + */ + bool m_bTouchMoved; + /** + * max inset point to limit scrolling by touch + */ + CCPoint m_fMaxInset; + /** + * min inset point to limit scrolling by touch + */ + CCPoint m_fMinInset; + /** + * Determines whether the scroll view is allowed to bounce or not. + */ + bool m_bBounceable; + + bool m_bClippingToBounds; + + /** + * scroll speed + */ + CCPoint m_tScrollDistance; + /** + * Touch point + */ + CCPoint m_tTouchPoint; + /** + * length between two fingers + */ + CCFloat m_fTouchLength; + /** + * UITouch objects to detect multitouch + */ + CCArray* m_pTouches; + /** + * size to clip. CCNode boundingBox uses contentSize directly. + * It's semantically different what it actually means to common scroll views. + * Hence, this scroll view will use a separate size property. + */ + CCSize m_tViewSize; +public: + CCSize getViewSize() { return m_tViewSize; } + void setViewSize(CCSize size); +protected: + /** + * max and min scale + */ + CCFloat m_fMinScale, m_fMaxScale; +}; + +NS_CC_EXT_END + +#endif /* __CCSCROLLVIEW_H__ */ From b66be5515611d2455275be0a12a7cb6ba0cc18ea Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 18 Jun 2012 18:31:29 +0800 Subject: [PATCH 210/257] issue #1333: Use CC_PROPERTY instead of CC_PROPERTY_PASS_BY_REF for m_tContenSize --- cocos2dx/base_nodes/CCNode.cpp | 4 ++-- cocos2dx/base_nodes/CCNode.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index 82f98cfeab..af0feb5a23 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -357,12 +357,12 @@ void CCNode::setAnchorPoint(const CCPoint& point) } /// contentSize getter -const CCSize& CCNode::getContentSize() +CCSize CCNode::getContentSize() { return m_tContentSize; } -void CCNode::setContentSize(const CCSize& size) +void CCNode::setContentSize(CCSize size) { if( ! CCSize::CCSizeEqualToSize(size, m_tContentSize) ) { diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index 317c52adfb..391bea64cb 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -222,7 +222,7 @@ public: All nodes has a size. Layer and Scene has the same size of the screen. @since v0.8 */ - CC_PROPERTY_PASS_BY_REF(CCSize, m_tContentSize, ContentSize) + CC_PROPERTY(CCSize, m_tContentSize, ContentSize) /** whether or not the node is running */ bool m_bIsRunning; From 579e6a1100b31f5fd34a51ccfcf715d5b57f2193 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 18 Jun 2012 18:32:17 +0800 Subject: [PATCH 211/257] issue #1333: export CCTouch class. --- cocos2dx/include/cocos2dExt.h | 1 + cocos2dx/touch_dispatcher/CCTouch.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cocos2dx/include/cocos2dExt.h b/cocos2dx/include/cocos2dExt.h index 7b1b83725f..c88271fd68 100644 --- a/cocos2dx/include/cocos2dExt.h +++ b/cocos2dx/include/cocos2dExt.h @@ -5,5 +5,6 @@ #include "extensions/CCControlExtension/CCControlExtensions.h" #include "extensions/CCListView/CCListView.h" #include "extensions/CCTextureWatcher/CCTextureWatcher.h" +#include "extensions/CCScrollView/CCScrollView.h" #endif /* __COCOS2DEXT_H__ */ diff --git a/cocos2dx/touch_dispatcher/CCTouch.h b/cocos2dx/touch_dispatcher/CCTouch.h index 6b533e2592..065e96e838 100644 --- a/cocos2dx/touch_dispatcher/CCTouch.h +++ b/cocos2dx/touch_dispatcher/CCTouch.h @@ -30,7 +30,7 @@ THE SOFTWARE. NS_CC_BEGIN -class CCTouch : public CCObject +class CC_DLL CCTouch : public CCObject { public: CCTouch() @@ -59,7 +59,7 @@ private: CCPoint m_prevPoint; }; -class CCEvent : public CCObject +class CC_DLL CCEvent : public CCObject { }; From f346d0944961a2777523bc52068811bee5642eeb Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 18 Jun 2012 19:00:26 +0800 Subject: [PATCH 212/257] issue #1333: Added CCScrollViewLoader. Not implement. --- .../CCBReader/CCNodeLoaderLibrary.cpp | 2 ++ .../CCBReader/CCScrollViewLoader.cpp | 34 +++++++++++++++++++ .../extensions/CCBReader/CCScrollViewLoader.h | 28 +++++++++++++++ cocos2dx/proj.win32/cocos2d-win32.vcproj | 20 +++++++++++ 4 files changed, 84 insertions(+) create mode 100644 cocos2dx/extensions/CCBReader/CCScrollViewLoader.cpp create mode 100644 cocos2dx/extensions/CCBReader/CCScrollViewLoader.h diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp index 810f8e6b9c..8082098df3 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp +++ b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp @@ -13,6 +13,7 @@ #include "CCMenuItemImageLoader.h" #include "CCControlButtonLoader.h" #include "CCParticleSystemQuadLoader.h" +#include "CCScrollViewLoader.h" USING_NS_CC; USING_NS_CC_EXT; @@ -34,6 +35,7 @@ void CCNodeLoaderLibrary::registerDefaultCCNodeLoaders() { this->registerCCNodeLoader("CCLabelBMFont", CCLabelBMFontLoader::loader()); this->registerCCNodeLoader("CCLabelTTF", CCLabelTTFLoader::loader()); this->registerCCNodeLoader("CCScale9Sprite", CCScale9SpriteLoader::loader()); + this->registerCCNodeLoader("CCScrollView", CCScrollViewLoader::loader()); this->registerCCNodeLoader("CCBFile", CCBFileLoader::loader()); this->registerCCNodeLoader("CCMenu", CCMenuLoader::loader()); this->registerCCNodeLoader("CCMenuItemImage", CCMenuItemImageLoader::loader()); diff --git a/cocos2dx/extensions/CCBReader/CCScrollViewLoader.cpp b/cocos2dx/extensions/CCBReader/CCScrollViewLoader.cpp new file mode 100644 index 0000000000..ffd3e41901 --- /dev/null +++ b/cocos2dx/extensions/CCBReader/CCScrollViewLoader.cpp @@ -0,0 +1,34 @@ +#include "CCScrollViewLoader.h" + +NS_CC_EXT_BEGIN + +CCScrollView * CCScrollViewLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { + return CCScrollView::node(); +} + +void CCScrollViewLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { + +} + +void CCScrollViewLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool * pFlip, CCBReader * pCCBReader) { + +} + +void CCScrollViewLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { + +} + +void CCScrollViewLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { + +} + +void CCScrollViewLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { + +} + +void CCScrollViewLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloat, CCBReader * pCCBReader) +{ + +} + +NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCScrollViewLoader.h b/cocos2dx/extensions/CCBReader/CCScrollViewLoader.h new file mode 100644 index 0000000000..edab481da2 --- /dev/null +++ b/cocos2dx/extensions/CCBReader/CCScrollViewLoader.h @@ -0,0 +1,28 @@ +#ifndef _CCB_CCSCROLLVIEWLOADER_H_ +#define _CCB_CCSCROLLVIEWLOADER_H_ + +#include "CCNodeLoader.h" + +NS_CC_EXT_BEGIN + +/* Forward declaration. */ +class CCBReader; + +class CC_DLL CCScrollViewLoader : public CCNodeLoader { + public: + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCScrollViewLoader, loader); + + protected: + virtual CCScrollView * createCCNode(CCNode *, CCBReader *); + + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *); + virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame *, CCBReader *); + virtual void onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool *, CCBReader *); + virtual void onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloat, CCBReader * pCCBReader); +}; + +NS_CC_EXT_END + +#endif diff --git a/cocos2dx/proj.win32/cocos2d-win32.vcproj b/cocos2dx/proj.win32/cocos2d-win32.vcproj index 7611402e1f..b9b8ebcfbb 100755 --- a/cocos2dx/proj.win32/cocos2d-win32.vcproj +++ b/cocos2dx/proj.win32/cocos2d-win32.vcproj @@ -1378,6 +1378,14 @@ RelativePath="..\extensions\CCBReader\CCScale9SpriteLoader.h" > + + + + @@ -1387,6 +1395,18 @@ > + + + + + + Date: Mon, 18 Jun 2012 19:18:10 +0800 Subject: [PATCH 213/257] issue #1333: Updated Android.mk. --- cocos2dx/Android.mk | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cocos2dx/Android.mk b/cocos2dx/Android.mk index 1d288987eb..29c713eda3 100644 --- a/cocos2dx/Android.mk +++ b/cocos2dx/Android.mk @@ -53,6 +53,7 @@ extensions/CCControlExtension/CCInvocation.cpp \ extensions/CCControlExtension/CCMenuPassive.cpp \ extensions/CCControlExtension/CCScale9Sprite.cpp \ extensions/CCControlExtension/CCSpacer.cpp \ +extensions/CCScrollView/CCScrollView.cpp \ extensions/CCListView/CCListView.cpp \ extensions/CCListView/CCListViewCell.cpp \ extensions/CCTextureWatcher/CCTextureWatcher.cpp \ @@ -73,6 +74,7 @@ extensions/CCBReader/CCMenuItemImageLoader.cpp \ extensions/CCBReader/CCSpriteLoader.cpp \ extensions/CCBReader/CCScale9SpriteLoader.cpp \ extensions/CCBReader/CCParticleSystemQuadLoader.cpp \ +extensions/CCBReader/CCScrollViewLoader.cpp \ kazmath/src/aabb.c \ kazmath/src/mat3.c \ kazmath/src/mat4.c \ From 6d0608d0f1021bed5eca10b618be6337ab5fa3b6 Mon Sep 17 00:00:00 2001 From: minggo Date: Mon, 18 Jun 2012 19:24:47 +0800 Subject: [PATCH 214/257] fixed #1333: add CCScrollView for iOS --- .../proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- .../HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- cocos2dx/Android.mk | 2 ++ cocos2dx/extensions/CCScrollView/CCScrollView.cpp | 3 +-- lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id | 2 +- .../proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- tools/tolua++/CCNode.pkg | 2 +- 8 files changed, 9 insertions(+), 8 deletions(-) diff --git a/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id b/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id index a1877f023a..088fc09b0d 100644 --- a/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -27504f6baf10e5dd447e1b9e149a88b963074dec \ No newline at end of file +88867c1b018265536f23e8000dea7f11019ede50 \ No newline at end of file diff --git a/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id b/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id index e2ea9875ed..29e98438ae 100644 --- a/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -f4f9e78d583a826744b48fcc5ca3103438b744cf \ No newline at end of file +8cc36df8f26f125c4cfa42a7ad91351456f7bf0d \ No newline at end of file diff --git a/cocos2dx/Android.mk b/cocos2dx/Android.mk index 1d288987eb..39ff7215aa 100644 --- a/cocos2dx/Android.mk +++ b/cocos2dx/Android.mk @@ -72,7 +72,9 @@ extensions/CCBReader/CCMenuItemLoader.cpp \ extensions/CCBReader/CCMenuItemImageLoader.cpp \ extensions/CCBReader/CCSpriteLoader.cpp \ extensions/CCBReader/CCScale9SpriteLoader.cpp \ +extensions/CCBReader/CCScrollViewLoader.cpp \ extensions/CCBReader/CCParticleSystemQuadLoader.cpp \ +extensions/CCScrollView/CCScrollView.cpp \ kazmath/src/aabb.c \ kazmath/src/mat3.c \ kazmath/src/mat4.c \ diff --git a/cocos2dx/extensions/CCScrollView/CCScrollView.cpp b/cocos2dx/extensions/CCScrollView/CCScrollView.cpp index 5837794431..c9e922d205 100644 --- a/cocos2dx/extensions/CCScrollView/CCScrollView.cpp +++ b/cocos2dx/extensions/CCScrollView/CCScrollView.cpp @@ -630,7 +630,6 @@ void CCScrollView::ccTouchMoved(CCTouch* touch, CCEvent* event) m_bTouchMoved = true; frame = CCRectMake(this->getPosition().x, this->getPosition().y, m_tViewSize.width, m_tViewSize.height); newPoint = this->convertTouchToNodeSpace((CCTouch*)m_pTouches->objectAtIndex(0)); - CCLOG("new x = %f, y = %f; old x = %f, y = %f", newPoint.x, newPoint.y, m_tTouchPoint.x, m_tTouchPoint.y); moveDistance = ccpSub(newPoint, m_tTouchPoint); m_tTouchPoint = newPoint; @@ -647,7 +646,7 @@ void CCScrollView::ccTouchMoved(CCTouch* touch, CCEvent* event) default: break; } - CCLOG("moveDistance = %f", moveDistance); + m_pContainer->setPosition(ccpAdd(m_pContainer->getPosition(), moveDistance)); maxInset = m_fMaxInset; diff --git a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index c70d137ce4..e4aa0c4526 100644 --- a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -cf9109aeec89b5dafb4bc9588c59b279c734d0a2 \ No newline at end of file +c13eb2b1ec38e28d1537f0671e700e1af00dd31e \ No newline at end of file diff --git a/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id b/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id index ee865c2c7b..d15cf33ab6 100644 --- a/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -36966a60baa47675db677ea1bbb2cc5eb30d2fe6 \ No newline at end of file +0ea589e32663b43f0dc281fed71656028252be6b \ No newline at end of file diff --git a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id index b020f13da9..29cead04fd 100644 --- a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -cf47c05a8260b8bdde74155d3dc2382ae9735b76 \ No newline at end of file +b0bc510824d786752a37f8b48a77a4c418c146b4 \ No newline at end of file diff --git a/tools/tolua++/CCNode.pkg b/tools/tolua++/CCNode.pkg index bfd8441f53..fa41e72604 100644 --- a/tools/tolua++/CCNode.pkg +++ b/tools/tolua++/CCNode.pkg @@ -50,7 +50,7 @@ class CCNode : public CCObject tolua_property__CCSkewY float skewY; // tolua_property__CCIsVisible bool isVisible; tolua_property__CCAnchorPoint CCPoint anchorPoint; - tolua_property__CCContentSize CCSize contentSize; +// tolua_property__CCContentSize CCSize contentSize; tolua_property__CCTag int tag; CCArray* getChildren(); From 2f3fed2562f4ff3df4a423ab5ae173ebdd9fab7b Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Mon, 18 Jun 2012 11:43:46 -0700 Subject: [PATCH 215/257] CCNodeLoader: Replaced manual deletes with 'safe' Macros. --- cocos2dx/extensions/CCBReader/CCNodeLoader.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp index d1e9b5edca..90fab40e7b 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp @@ -86,7 +86,7 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * if(setProp) { this->onHandlePropTypeScaleLock(pNode, pParent, propertyName, scaleLock, pCCBReader); } - delete[] scaleLock; + CC_SAFE_DELETE_ARRAY(scaleLock); break; } case kCCBPropTypeFloat: { @@ -129,7 +129,7 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * if(setProp) { this->onHandlePropTypeFloatVar(pNode, pParent, propertyName, floatVar, pCCBReader); } - delete[] floatVar; + CC_SAFE_DELETE_ARRAY(floatVar); break; } case kCCBPropTypeCheck: { @@ -179,7 +179,7 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * if(setProp) { this->onHandlePropTypeColor4FVar(pNode, pParent, propertyName, color4FVar, pCCBReader); } - delete[] color4FVar; + CC_SAFE_DELETE_ARRAY(color4FVar); break; } case kCCBPropTypeFlip: { @@ -187,7 +187,7 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * if(setProp) { this->onHandlePropTypeFlip(pNode, pParent, propertyName, flip, pCCBReader); } - delete[] flip; + CC_SAFE_DELETE_ARRAY(flip); break; } case kCCBPropTypeBlendFunc: { @@ -230,7 +230,7 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * if(setProp) { this->onHandlePropTypeBlock(pNode, pParent, propertyName, blockData, pCCBReader); } - delete blockData; + CC_SAFE_DELETE(blockData); break; } case kCCBPropTypeBlockCCControl: { @@ -238,7 +238,7 @@ void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * if(setProp && blockCCControlData != NULL) { this->onHandlePropTypeBlockCCControl(pNode, pParent, propertyName, blockCCControlData, pCCBReader); } - delete blockCCControlData; + CC_SAFE_DELETE(blockCCControlData); break; } case kCCBPropTypeCCBFile: { From aa83408ba78a52b44e42fe37972f6d2dd07f57bb Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Mon, 18 Jun 2012 12:03:06 -0700 Subject: [PATCH 216/257] Addded virtual destructors to all classes in the CCBReader extension. CCBReader: named some parameters in the header. --- cocos2dx/extensions/CCBReader/CCBFileLoader.h | 1 + .../CCBReader/CCBMemberVariableAssigner.h | 3 +- cocos2dx/extensions/CCBReader/CCBReader.cpp | 4 +-- cocos2dx/extensions/CCBReader/CCBReader.h | 28 +++++++++---------- .../CCBReader/CCBSelectorResolver.h | 3 +- .../CCBReader/CCControlButtonLoader.h | 1 + .../extensions/CCBReader/CCControlLoader.h | 3 ++ .../CCBReader/CCLabelBMFontLoader.h | 1 + .../extensions/CCBReader/CCLabelTTFLoader.h | 1 + .../extensions/CCBReader/CCLayerColorLoader.h | 2 ++ .../CCBReader/CCLayerGradientLoader.h | 1 + cocos2dx/extensions/CCBReader/CCLayerLoader.h | 1 + .../CCBReader/CCMenuItemImageLoader.h | 1 + .../extensions/CCBReader/CCMenuItemLoader.h | 2 ++ cocos2dx/extensions/CCBReader/CCMenuLoader.h | 1 + cocos2dx/extensions/CCBReader/CCNodeLoader.h | 1 + .../CCBReader/CCNodeLoaderLibrary.h | 2 +- .../CCBReader/CCNodeLoaderListener.h | 3 +- .../CCBReader/CCParticleSystemQuadLoader.h | 1 + .../CCBReader/CCScale9SpriteLoader.h | 1 + .../extensions/CCBReader/CCScrollViewLoader.h | 1 + .../extensions/CCBReader/CCSpriteLoader.h | 1 + 22 files changed, 42 insertions(+), 21 deletions(-) diff --git a/cocos2dx/extensions/CCBReader/CCBFileLoader.h b/cocos2dx/extensions/CCBReader/CCBFileLoader.h index 9902507991..9f01199b1e 100644 --- a/cocos2dx/extensions/CCBReader/CCBFileLoader.h +++ b/cocos2dx/extensions/CCBReader/CCBFileLoader.h @@ -10,6 +10,7 @@ class CCBReader; class CC_DLL CCBFileLoader : public CCNodeLoader { public: + virtual ~CCBFileLoader() {}; CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCBFileLoader, loader); protected: diff --git a/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h b/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h index 8843fdef31..3a0cb73812 100644 --- a/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h +++ b/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h @@ -14,7 +14,8 @@ NS_CC_EXT_BEGIN class CC_DLL CCBMemberVariableAssigner { public: - virtual ~CCBMemberVariableAssigner() {} + virtual ~CCBMemberVariableAssigner() {}; + virtual bool onAssignCCBMemberVariable(CCObject * pTarget, cocos2d::CCString * pMemberVariableName, CCNode * pNode) = 0; }; diff --git a/cocos2dx/extensions/CCBReader/CCBReader.cpp b/cocos2dx/extensions/CCBReader/CCBReader.cpp index 3ad4472939..a205dab924 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader.cpp @@ -185,7 +185,7 @@ bool CCBReader::readBool() { return this->readByte(); } -int CCBReader::readInt(bool pSign) { +int CCBReader::readInt(bool pSigned) { int numBits = 0; while(!this->getBit()) { numBits++; @@ -200,7 +200,7 @@ int CCBReader::readInt(bool pSign) { current |= 1 << numBits; int num; - if(pSign) { + if(pSigned) { int s = current % 2; if(s) { num = (int)(current / 2); diff --git a/cocos2dx/extensions/CCBReader/CCBReader.h b/cocos2dx/extensions/CCBReader/CCBReader.h index 155ebfe54d..7bb6d7a393 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader.h +++ b/cocos2dx/extensions/CCBReader/CCBReader.h @@ -118,11 +118,9 @@ class CC_DLL CCBReader : public CCObject { std::set mLoadedSpriteSheets; public: - /* Constructor. */ - CCBReader(CCNodeLoaderLibrary *, CCBMemberVariableAssigner * = NULL, CCBSelectorResolver * = NULL, CCNodeLoaderListener * = NULL); - CCBReader(CCBReader *); - /* Destructor. */ - ~CCBReader(); + CCBReader(CCNodeLoaderLibrary * pCCNodeLoaderLibrary, CCBMemberVariableAssigner * pCCBMemberVariableAssigner = NULL, CCBSelectorResolver * pCCBSelectorResolver = NULL, CCNodeLoaderListener * pCCNodeLoaderListener = NULL); + CCBReader(CCBReader * pCCBReader); + virtual ~CCBReader(); CCNode * readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner = NULL); CCNode * readNodeGraphFromFile(CCString * pCCBRootPath, CCString * pCCBFileName, CCObject * pOwner = NULL); @@ -135,21 +133,21 @@ class CC_DLL CCBReader : public CCObject { CCString * getCCBRootPath(); CCObject * getOwner(); CCNode * getRootNode(); - CCSize getContainerSize(CCNode *); + CCSize getContainerSize(CCNode * pNode); float getResolutionScale(); - bool isSpriteSheetLoaded(CCString *); - void addLoadedSpriteSheet(CCString *); + bool isSpriteSheetLoaded(CCString * pSpriteSheet); + void addLoadedSpriteSheet(CCString * pSpriteSheet); /* Utility methods. */ - static CCString * lastPathComponent(CCString *); - static CCString * deletePathExtension(CCString *); - static CCString * toLowerCase(CCString *); - static bool endsWith(CCString *, CCString *); - static CCString * concat(CCString *, CCString *); + static CCString * lastPathComponent(CCString * pString); + static CCString * deletePathExtension(CCString * pString); + static CCString * toLowerCase(CCString * pCCString); + static bool endsWith(CCString * pString, CCString * pEnding); + static CCString * concat(CCString * pStringA, CCString * pStringB); /* Parse methods. */ - int readInt(bool pSign); + int readInt(bool pSigned); unsigned char readByte(); bool readBool(); float readFloat(); @@ -160,7 +158,7 @@ class CC_DLL CCBReader : public CCObject { bool readStringCache(); void readStringCacheEntry(); CCNode * readNodeGraph(); - CCNode * readNodeGraph(CCNode *); + CCNode * readNodeGraph(CCNode * pParent); bool getBit(); void alignBits(); diff --git a/cocos2dx/extensions/CCBReader/CCBSelectorResolver.h b/cocos2dx/extensions/CCBReader/CCBSelectorResolver.h index 589d292d9d..a79ac3a5d5 100644 --- a/cocos2dx/extensions/CCBReader/CCBSelectorResolver.h +++ b/cocos2dx/extensions/CCBReader/CCBSelectorResolver.h @@ -15,7 +15,8 @@ NS_CC_EXT_BEGIN class CC_DLL CCBSelectorResolver { public: - virtual ~CCBSelectorResolver() {} + virtual ~CCBSelectorResolver() {}; + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName) = 0; virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(CCObject * pTarget, CCString * pSelectorName) = 0; }; diff --git a/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h b/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h index a8d734eaf5..9b9113a188 100644 --- a/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h +++ b/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h @@ -10,6 +10,7 @@ class CCBReader; class CC_DLL CCControlButtonLoader : public CCControlLoader { public: + virtual ~CCControlButtonLoader() {}; CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCControlButtonLoader, loader); protected: diff --git a/cocos2dx/extensions/CCBReader/CCControlLoader.h b/cocos2dx/extensions/CCBReader/CCControlLoader.h index d34c979720..51f8dacbc0 100644 --- a/cocos2dx/extensions/CCBReader/CCControlLoader.h +++ b/cocos2dx/extensions/CCBReader/CCControlLoader.h @@ -9,6 +9,9 @@ NS_CC_EXT_BEGIN class CCBReader; class CC_DLL CCControlLoader : public CCNodeLoader { + public: + virtual ~CCControlLoader() {}; + protected: virtual CCControl * createCCNode(CCNode *, CCBReader *) = 0; diff --git a/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h b/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h index 8c4e9e04eb..b26f87fef7 100644 --- a/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h @@ -10,6 +10,7 @@ class CCBReader; class CC_DLL CCLabelBMFontLoader : public CCNodeLoader { public: + virtual ~CCLabelBMFontLoader() {}; CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLabelBMFontLoader, loader); protected: diff --git a/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h b/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h index 908e2157e8..2055be359c 100644 --- a/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h @@ -10,6 +10,7 @@ class CCBReader; class CC_DLL CCLabelTTFLoader : public CCNodeLoader { public: + virtual ~CCLabelTTFLoader() {}; CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLabelTTFLoader, loader); protected: diff --git a/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h b/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h index 9170492e8f..77c2fe241f 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h @@ -10,7 +10,9 @@ class CCBReader; class CC_DLL CCLayerColorLoader : public CCLayerLoader { public: + virtual ~CCLayerColorLoader() {}; CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerColorLoader, loader); + protected: virtual CCLayerColor * createCCNode(CCNode *, CCBReader *); diff --git a/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h b/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h index 2d15da0ecc..ac525ca665 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h @@ -10,6 +10,7 @@ class CCBReader; class CC_DLL CCLayerGradientLoader : public CCLayerLoader { public: + virtual ~CCLayerGradientLoader() {}; CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerGradientLoader, loader); protected: diff --git a/cocos2dx/extensions/CCBReader/CCLayerLoader.h b/cocos2dx/extensions/CCBReader/CCLayerLoader.h index 81d75ea87e..f94b94ccaa 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLayerLoader.h @@ -10,6 +10,7 @@ class CCBReader; class CC_DLL CCLayerLoader : public CCNodeLoader { public: + virtual ~CCLayerLoader() {}; CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerLoader, loader); protected: diff --git a/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h b/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h index 562baee5de..c0464b6f9d 100644 --- a/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h +++ b/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h @@ -10,6 +10,7 @@ class CCBReader; class CC_DLL CCMenuItemImageLoader : public CCMenuItemLoader { public: + virtual ~CCMenuItemImageLoader() {}; CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCMenuItemImageLoader, loader); protected: diff --git a/cocos2dx/extensions/CCBReader/CCMenuItemLoader.h b/cocos2dx/extensions/CCBReader/CCMenuItemLoader.h index 153f4cf75c..e8d59db9ca 100644 --- a/cocos2dx/extensions/CCBReader/CCMenuItemLoader.h +++ b/cocos2dx/extensions/CCBReader/CCMenuItemLoader.h @@ -9,6 +9,8 @@ NS_CC_EXT_BEGIN class CCBReader; class CC_DLL CCMenuItemLoader : public CCNodeLoader { + public: + virtual ~CCMenuItemLoader() {}; protected: virtual CCMenuItem * createCCNode(CCNode *, CCBReader *) = 0; diff --git a/cocos2dx/extensions/CCBReader/CCMenuLoader.h b/cocos2dx/extensions/CCBReader/CCMenuLoader.h index 959da9e1c9..0dc6d94fb2 100644 --- a/cocos2dx/extensions/CCBReader/CCMenuLoader.h +++ b/cocos2dx/extensions/CCBReader/CCMenuLoader.h @@ -10,6 +10,7 @@ class CCBReader; class CC_DLL CCMenuLoader : public CCLayerLoader { public: + virtual ~CCMenuLoader() {}; CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCMenuLoader, loader); protected: diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoader.h b/cocos2dx/extensions/CCBReader/CCNodeLoader.h index 141592ae5e..1fbee9815e 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoader.h +++ b/cocos2dx/extensions/CCBReader/CCNodeLoader.h @@ -26,6 +26,7 @@ class CCBReader; class CC_DLL CCNodeLoader : public CCObject { public: + virtual ~CCNodeLoader() {}; CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCNodeLoader, loader); virtual CCNode * loadCCNode(CCNode *, CCBReader * pCCBReader); diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h index aab5fb8cd4..a75aab374f 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h +++ b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.h @@ -17,7 +17,7 @@ class CC_DLL CCNodeLoaderLibrary : public CCObject { CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCNodeLoaderLibrary, library); CCNodeLoaderLibrary(); - ~CCNodeLoaderLibrary(); + virtual ~CCNodeLoaderLibrary(); void registerDefaultCCNodeLoaders(); void registerCCNodeLoader(const char * pClassName, CCNodeLoader * pCCNodeLoader); diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoaderListener.h b/cocos2dx/extensions/CCBReader/CCNodeLoaderListener.h index 8c389c7289..82d7921268 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoaderListener.h +++ b/cocos2dx/extensions/CCBReader/CCNodeLoaderListener.h @@ -7,7 +7,8 @@ NS_CC_EXT_BEGIN class CC_DLL CCNodeLoaderListener { public: - virtual ~CCNodeLoaderListener() {} + virtual ~CCNodeLoaderListener() {}; + virtual void onNodeLoaded(CCNode * pNode, CCNodeLoader * pNodeLoader) = 0; }; diff --git a/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h b/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h index cf7420ec6d..a36be566b2 100644 --- a/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h +++ b/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h @@ -10,6 +10,7 @@ class CCBReader; class CC_DLL CCParticleSystemQuadLoader : public CCNodeLoader { public: + virtual ~CCParticleSystemQuadLoader() {}; CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCParticleSystemQuadLoader, loader); protected: diff --git a/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h b/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h index 7f56cb3807..f51e182dd3 100644 --- a/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h +++ b/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h @@ -10,6 +10,7 @@ class CCBReader; class CC_DLL CCScale9SpriteLoader : public CCNodeLoader { public: + virtual ~CCScale9SpriteLoader() {}; CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCScale9SpriteLoader, loader); protected: diff --git a/cocos2dx/extensions/CCBReader/CCScrollViewLoader.h b/cocos2dx/extensions/CCBReader/CCScrollViewLoader.h index edab481da2..7caa70c9d4 100644 --- a/cocos2dx/extensions/CCBReader/CCScrollViewLoader.h +++ b/cocos2dx/extensions/CCBReader/CCScrollViewLoader.h @@ -10,6 +10,7 @@ class CCBReader; class CC_DLL CCScrollViewLoader : public CCNodeLoader { public: + virtual ~CCScrollViewLoader() {}; CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCScrollViewLoader, loader); protected: diff --git a/cocos2dx/extensions/CCBReader/CCSpriteLoader.h b/cocos2dx/extensions/CCBReader/CCSpriteLoader.h index 8ec38ff15e..161dbe9c83 100644 --- a/cocos2dx/extensions/CCBReader/CCSpriteLoader.h +++ b/cocos2dx/extensions/CCBReader/CCSpriteLoader.h @@ -10,6 +10,7 @@ class CCBReader; class CC_DLL CCSpriteLoader : public CCNodeLoader { public: + virtual ~CCSpriteLoader() {}; CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCSpriteLoader, loader); protected: From 227683bfa4b0b72de4ed86713c0b9c6e3937766e Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Mon, 18 Jun 2012 13:33:19 -0700 Subject: [PATCH 217/257] Cleaned up CCNodeLoaders by using the Marco instead of having a boilerplate createCCNode method in all the cpp files. --- cocos2dx/Android.mk | 1 - cocos2dx/extensions/CCBReader/CCBFileLoader.cpp | 4 ---- cocos2dx/extensions/CCBReader/CCBFileLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCControlButtonLoader.cpp | 4 ---- cocos2dx/extensions/CCBReader/CCControlButtonLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCControlLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.cpp | 4 ---- cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCLabelTTFLoader.cpp | 4 ---- cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCLayerColorLoader.cpp | 4 ---- cocos2dx/extensions/CCBReader/CCLayerColorLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCLayerGradientLoader.cpp | 4 ---- cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCLayerLoader.cpp | 4 ---- cocos2dx/extensions/CCBReader/CCLayerLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.cpp | 4 ---- cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCMenuItemLoader.h | 3 ++- cocos2dx/extensions/CCBReader/CCMenuLoader.cpp | 9 --------- cocos2dx/extensions/CCBReader/CCMenuLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCNodeLoader.cpp | 4 ---- cocos2dx/extensions/CCBReader/CCNodeLoader.h | 6 ++++-- .../extensions/CCBReader/CCParticleSystemQuadLoader.cpp | 4 ---- .../extensions/CCBReader/CCParticleSystemQuadLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.cpp | 4 ---- cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCScrollViewLoader.cpp | 9 ++------- cocos2dx/extensions/CCBReader/CCScrollViewLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCSpriteLoader.cpp | 4 ---- cocos2dx/extensions/CCBReader/CCSpriteLoader.h | 2 +- .../test.xcodeproj/project.pbxproj.REMOVED.git-id | 2 +- 32 files changed, 23 insertions(+), 83 deletions(-) delete mode 100644 cocos2dx/extensions/CCBReader/CCMenuLoader.cpp diff --git a/cocos2dx/Android.mk b/cocos2dx/Android.mk index 39ff7215aa..eb4e3c6bd0 100644 --- a/cocos2dx/Android.mk +++ b/cocos2dx/Android.mk @@ -67,7 +67,6 @@ extensions/CCBReader/CCLabelTTFLoader.cpp \ extensions/CCBReader/CCLayerLoader.cpp \ extensions/CCBReader/CCLayerColorLoader.cpp \ extensions/CCBReader/CCLayerGradientLoader.cpp \ -extensions/CCBReader/CCMenuLoader.cpp \ extensions/CCBReader/CCMenuItemLoader.cpp \ extensions/CCBReader/CCMenuItemImageLoader.cpp \ extensions/CCBReader/CCSpriteLoader.cpp \ diff --git a/cocos2dx/extensions/CCBReader/CCBFileLoader.cpp b/cocos2dx/extensions/CCBReader/CCBFileLoader.cpp index 83504502e8..1e01aa75e1 100644 --- a/cocos2dx/extensions/CCBReader/CCBFileLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCBFileLoader.cpp @@ -5,10 +5,6 @@ USING_NS_CC_EXT; #define PROPERTY_CCBFILE "ccbFile" -CCNode * CCBFileLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { - return CCNode::node(); -} - void CCBFileLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader) { if(pPropertyName->compare(PROPERTY_CCBFILE) == 0) { pNode->addChild(pCCBFileNode); diff --git a/cocos2dx/extensions/CCBReader/CCBFileLoader.h b/cocos2dx/extensions/CCBReader/CCBFileLoader.h index 9f01199b1e..b9443bfa70 100644 --- a/cocos2dx/extensions/CCBReader/CCBFileLoader.h +++ b/cocos2dx/extensions/CCBReader/CCBFileLoader.h @@ -14,7 +14,7 @@ class CC_DLL CCBFileLoader : public CCNodeLoader { CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCBFileLoader, loader); protected: - virtual CCNode * createCCNode(CCNode *, CCBReader *); + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCNode); virtual void onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCNode *, CCBReader *); }; diff --git a/cocos2dx/extensions/CCBReader/CCControlButtonLoader.cpp b/cocos2dx/extensions/CCBReader/CCControlButtonLoader.cpp index 5adf9dcfcc..65d1d4af0f 100644 --- a/cocos2dx/extensions/CCBReader/CCControlButtonLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCControlButtonLoader.cpp @@ -22,10 +22,6 @@ USING_NS_CC_EXT; #define PROPERTY_BACKGROUNDSPRITEFRAME_HIGHLIGHTED "backgroundSpriteFrame|2" #define PROPERTY_BACKGROUNDSPRITEFRAME_DISABLED "backgroundSpriteFrame|3" -CCControl * CCControlButtonLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { - return CCControlButton::node(); -} - void CCControlButtonLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader) { if(pPropertyName->compare(PROPERTY_ZOOMONTOUCHDOWN) == 0) { ((CCControlButton *)pNode)->setZoomOnTouchDown(pCheck); diff --git a/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h b/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h index 9b9113a188..78946c1d08 100644 --- a/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h +++ b/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h @@ -14,7 +14,7 @@ class CC_DLL CCControlButtonLoader : public CCControlLoader { CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCControlButtonLoader, loader); protected: - virtual CCControl * createCCNode(CCNode *, CCBReader *); + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCControlButton); virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool, CCBReader *); virtual void onHandlePropTypeString(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString *, CCBReader *); diff --git a/cocos2dx/extensions/CCBReader/CCControlLoader.h b/cocos2dx/extensions/CCBReader/CCControlLoader.h index 51f8dacbc0..5383586d37 100644 --- a/cocos2dx/extensions/CCBReader/CCControlLoader.h +++ b/cocos2dx/extensions/CCBReader/CCControlLoader.h @@ -13,7 +13,7 @@ class CC_DLL CCControlLoader : public CCNodeLoader { virtual ~CCControlLoader() {}; protected: - virtual CCControl * createCCNode(CCNode *, CCBReader *) = 0; + CCB_PURE_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCControl); virtual void onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockCCControlData *, CCBReader *); virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool, CCBReader *); diff --git a/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.cpp b/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.cpp index 894876df04..fd5be341b4 100644 --- a/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.cpp @@ -9,10 +9,6 @@ USING_NS_CC_EXT; #define PROPERTY_FNTFILE "fntFile" #define PROPERTY_STRING "string" -CCLabelBMFont * CCLabelBMFontLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { - return CCLabelBMFont::node(); -} - void CCLabelBMFontLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { if(pPropertyName->compare(PROPERTY_COLOR) == 0) { ((CCLabelBMFont *)pNode)->setColor(pCCColor3B); diff --git a/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h b/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h index b26f87fef7..f2452bffcf 100644 --- a/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h @@ -14,7 +14,7 @@ class CC_DLL CCLabelBMFontLoader : public CCNodeLoader { CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLabelBMFontLoader, loader); protected: - virtual CCLabelBMFont * createCCNode(CCNode *, CCBReader *); + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCLabelBMFont); virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *); virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *); diff --git a/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.cpp b/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.cpp index 61a6d63bc3..154a035eee 100644 --- a/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.cpp @@ -13,10 +13,6 @@ USING_NS_CC_EXT; #define PROPERTY_STRING "string" #define PROPERTY_DIMENSIONS "dimensions" -CCLabelTTF * CCLabelTTFLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { - return CCLabelTTF::node(); -} - void CCLabelTTFLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { if(pPropertyName->compare(PROPERTY_COLOR) == 0) { ((CCLabelTTF *)pNode)->setColor(pCCColor3B); diff --git a/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h b/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h index 2055be359c..dced2ad066 100644 --- a/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h @@ -14,7 +14,7 @@ class CC_DLL CCLabelTTFLoader : public CCNodeLoader { CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLabelTTFLoader, loader); protected: - virtual CCLabelTTF * createCCNode(CCNode *, CCBReader *); + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCLabelTTF); virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *); virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *); diff --git a/cocos2dx/extensions/CCBReader/CCLayerColorLoader.cpp b/cocos2dx/extensions/CCBReader/CCLayerColorLoader.cpp index c4b3338efe..2c609635df 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerColorLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCLayerColorLoader.cpp @@ -7,10 +7,6 @@ USING_NS_CC_EXT; #define PROPERTY_OPACITY "opacity" #define PROPERTY_BLENDFUNC "blendFunc" -CCLayerColor * CCLayerColorLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { - return CCLayerColor::node(); -} - void CCLayerColorLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { if(pPropertyName->compare(PROPERTY_COLOR) == 0) { ((CCLayerColor *)pNode)->setColor(pCCColor3B); diff --git a/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h b/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h index 77c2fe241f..1091f4b417 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h @@ -14,7 +14,7 @@ class CC_DLL CCLayerColorLoader : public CCLayerLoader { CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerColorLoader, loader); protected: - virtual CCLayerColor * createCCNode(CCNode *, CCBReader *); + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCLayerColor); virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *); virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *); diff --git a/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.cpp b/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.cpp index 1130cef867..efbbeea896 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.cpp @@ -10,10 +10,6 @@ USING_NS_CC_EXT; #define PROPERTY_VECTOR "vector" #define PROPERTY_BLENDFUNC "blendFunc" -CCLayerGradient * CCLayerGradientLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { - return CCLayerGradient::node(); -} - void CCLayerGradientLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { if(pPropertyName->compare(PROPERTY_STARTCOLOR) == 0) { ((CCLayerGradient *)pNode)->setStartColor(pCCColor3B); diff --git a/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h b/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h index ac525ca665..58603ea18d 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h @@ -14,7 +14,7 @@ class CC_DLL CCLayerGradientLoader : public CCLayerLoader { CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerGradientLoader, loader); protected: - virtual CCLayerGradient * createCCNode(CCNode *, CCBReader *); + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCLayerGradient); virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *); virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *); diff --git a/cocos2dx/extensions/CCBReader/CCLayerLoader.cpp b/cocos2dx/extensions/CCBReader/CCLayerLoader.cpp index 223cfc804b..e768e9937b 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCLayerLoader.cpp @@ -8,10 +8,6 @@ USING_NS_CC_EXT; #define PROPERTY_MOUSE_ENABLED "isMouseEnabled" #define PROPERTY_KEYBOARD_ENABLED "isKeyboardEnabled" -CCLayer * CCLayerLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { - return CCLayer::node(); -} - void CCLayerLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader) { if(pPropertyName->compare(PROPERTY_TOUCH_ENABLED) == 0) { ((CCLayer *)pNode)->setTouchEnabled(pCheck); diff --git a/cocos2dx/extensions/CCBReader/CCLayerLoader.h b/cocos2dx/extensions/CCBReader/CCLayerLoader.h index f94b94ccaa..b19cc8405e 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLayerLoader.h @@ -14,7 +14,7 @@ class CC_DLL CCLayerLoader : public CCNodeLoader { CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCLayerLoader, loader); protected: - virtual CCLayer * createCCNode(CCNode *, CCBReader *); + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCLayer); virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader); }; diff --git a/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.cpp b/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.cpp index bb9a1893a8..5de485c770 100644 --- a/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.cpp @@ -7,10 +7,6 @@ USING_NS_CC_EXT; #define PROPERTY_SELECTEDDISPLAYFRAME "selectedSpriteFrame" #define PROPERTY_DISABLEDDISPLAYFRAME "disabledSpriteFrame" -CCMenuItemImage * CCMenuItemImageLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { - return CCMenuItemImage::node(); -} - void CCMenuItemImageLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { if(pPropertyName->compare(PROPERTY_NORMALDISPLAYFRAME) == 0) { if(pCCSpriteFrame != NULL) { diff --git a/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h b/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h index c0464b6f9d..d9b204ae5a 100644 --- a/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h +++ b/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h @@ -14,7 +14,7 @@ class CC_DLL CCMenuItemImageLoader : public CCMenuItemLoader { CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCMenuItemImageLoader, loader); protected: - virtual CCMenuItemImage * createCCNode(CCNode *, CCBReader *); + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCMenuItemImage); virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame *, CCBReader *); }; diff --git a/cocos2dx/extensions/CCBReader/CCMenuItemLoader.h b/cocos2dx/extensions/CCBReader/CCMenuItemLoader.h index e8d59db9ca..ed0278d3b0 100644 --- a/cocos2dx/extensions/CCBReader/CCMenuItemLoader.h +++ b/cocos2dx/extensions/CCBReader/CCMenuItemLoader.h @@ -11,8 +11,9 @@ class CCBReader; class CC_DLL CCMenuItemLoader : public CCNodeLoader { public: virtual ~CCMenuItemLoader() {}; + protected: - virtual CCMenuItem * createCCNode(CCNode *, CCBReader *) = 0; + CCB_PURE_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCMenuItem); virtual void onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockData *, CCBReader *); virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool, CCBReader *); diff --git a/cocos2dx/extensions/CCBReader/CCMenuLoader.cpp b/cocos2dx/extensions/CCBReader/CCMenuLoader.cpp deleted file mode 100644 index ef768f1d5b..0000000000 --- a/cocos2dx/extensions/CCBReader/CCMenuLoader.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "CCMenuLoader.h" - -USING_NS_CC; -USING_NS_CC_EXT; - - -CCMenu * CCMenuLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { - return CCMenu::node(); -} \ No newline at end of file diff --git a/cocos2dx/extensions/CCBReader/CCMenuLoader.h b/cocos2dx/extensions/CCBReader/CCMenuLoader.h index 0dc6d94fb2..57866a0ff7 100644 --- a/cocos2dx/extensions/CCBReader/CCMenuLoader.h +++ b/cocos2dx/extensions/CCBReader/CCMenuLoader.h @@ -14,7 +14,7 @@ class CC_DLL CCMenuLoader : public CCLayerLoader { CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCMenuLoader, loader); protected: - virtual CCMenu * createCCNode(CCNode *, CCBReader *); + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCMenu); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp index 90fab40e7b..e658508c31 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp @@ -25,10 +25,6 @@ CCNode * CCNodeLoader::loadCCNode(CCNode * pParent, CCBReader * pCCBReader) { return ccNode; } -CCNode * CCNodeLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { - return CCNode::node(); -} - void CCNodeLoader::parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { int propertyCount = pCCBReader->readInt(false); for(int i = 0; i < propertyCount; i++) { diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoader.h b/cocos2dx/extensions/CCBReader/CCNodeLoader.h index 1fbee9815e..e4f03cdd4c 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoader.h +++ b/cocos2dx/extensions/CCBReader/CCNodeLoader.h @@ -7,9 +7,11 @@ NS_CC_EXT_BEGIN #define CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(T) virtual T * createCCNode(cocos2d::CCNode * pParent, cocos2d::extension::CCBReader * pCCBReader) { \ -return T::node(); \ + return T::node(); \ } +#define CCB_PURE_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(T) virtual T * createCCNode(cocos2d::CCNode * pParent, cocos2d::extension::CCBReader * pCCBReader) = 0 + struct BlockData { SEL_MenuHandler mSELMenuHandler; CCObject * mTarget; @@ -33,7 +35,7 @@ class CC_DLL CCNodeLoader : public CCObject { virtual void parseProperties(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); protected: - virtual CCNode * createCCNode(CCNode * pParent, CCBReader * pCCBReader); + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCNode); virtual CCPoint parsePropTypePosition(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); virtual CCPoint parsePropTypePoint(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader); diff --git a/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.cpp b/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.cpp index 01f1077222..fe555779d3 100644 --- a/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.cpp @@ -26,10 +26,6 @@ USING_NS_CC_EXT; #define PROPERTY_ENDRADIUS "endRadius" #define PROPERTY_ROTATEPERSECOND "rotatePerSecond" -CCParticleSystemQuad * CCParticleSystemQuadLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { - return CCParticleSystemQuad::node(); -} - void CCParticleSystemQuadLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { if(pPropertyName->compare(PROPERTY_EMITERMODE) == 0) { ((CCParticleSystemQuad *)pNode)->setEmitterMode(pIntegerLabeled); diff --git a/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h b/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h index a36be566b2..1a6e85beb5 100644 --- a/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h +++ b/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h @@ -14,7 +14,7 @@ class CC_DLL CCParticleSystemQuadLoader : public CCNodeLoader { CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCParticleSystemQuadLoader, loader); protected: - virtual CCParticleSystemQuad * createCCNode(CCNode *, CCBReader *); + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCParticleSystemQuad); virtual void onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int, CCBReader *); virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint, CCBReader *); diff --git a/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.cpp b/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.cpp index 1a4624ddae..50a3062c79 100644 --- a/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.cpp @@ -14,10 +14,6 @@ USING_NS_CC_EXT; #define PROPERTY_INSETRIGHT "insetRight" #define PROPERTY_INSETBOTTOM "insetBottom" -CCScale9Sprite * CCScale9SpriteLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { - return CCScale9Sprite::node(); -} - void CCScale9SpriteLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { if(pPropertyName->compare(PROPERTY_SPRITEFRAME) == 0) { ((CCScale9Sprite *)pNode)->initWithSpriteFrame(pCCSpriteFrame); diff --git a/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h b/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h index f51e182dd3..97658767d1 100644 --- a/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h +++ b/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h @@ -14,7 +14,7 @@ class CC_DLL CCScale9SpriteLoader : public CCNodeLoader { CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCScale9SpriteLoader, loader); protected: - virtual CCScale9Sprite * createCCNode(CCNode *, CCBReader *); + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCScale9Sprite); virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *); virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *); diff --git a/cocos2dx/extensions/CCBReader/CCScrollViewLoader.cpp b/cocos2dx/extensions/CCBReader/CCScrollViewLoader.cpp index ffd3e41901..8fa0938f69 100644 --- a/cocos2dx/extensions/CCBReader/CCScrollViewLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCScrollViewLoader.cpp @@ -1,10 +1,7 @@ #include "CCScrollViewLoader.h" -NS_CC_EXT_BEGIN - -CCScrollView * CCScrollViewLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { - return CCScrollView::node(); -} +USING_NS_CC; +USING_NS_CC_EXT; void CCScrollViewLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { @@ -30,5 +27,3 @@ void CCScrollViewLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, { } - -NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCScrollViewLoader.h b/cocos2dx/extensions/CCBReader/CCScrollViewLoader.h index 7caa70c9d4..11c635d274 100644 --- a/cocos2dx/extensions/CCBReader/CCScrollViewLoader.h +++ b/cocos2dx/extensions/CCBReader/CCScrollViewLoader.h @@ -14,7 +14,7 @@ class CC_DLL CCScrollViewLoader : public CCNodeLoader { CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCScrollViewLoader, loader); protected: - virtual CCScrollView * createCCNode(CCNode *, CCBReader *); + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCScrollView); virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *); virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *); diff --git a/cocos2dx/extensions/CCBReader/CCSpriteLoader.cpp b/cocos2dx/extensions/CCBReader/CCSpriteLoader.cpp index eef53d0c1b..e884f4de33 100644 --- a/cocos2dx/extensions/CCBReader/CCSpriteLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCSpriteLoader.cpp @@ -9,10 +9,6 @@ USING_NS_CC_EXT; #define PROPERTY_OPACITY "opacity" #define PROPERTY_BLENDFUNC "blendFunc" -CCSprite * CCSpriteLoader::createCCNode(CCNode * pParent, CCBReader * pCCBReader) { - return CCSprite::node(); -} - void CCSpriteLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { if(pPropertyName->compare(PROPERTY_DISPLAYFRAME) == 0) { ((CCSprite *)pNode)->setDisplayFrame(pCCSpriteFrame); diff --git a/cocos2dx/extensions/CCBReader/CCSpriteLoader.h b/cocos2dx/extensions/CCBReader/CCSpriteLoader.h index 161dbe9c83..e748ccd7f9 100644 --- a/cocos2dx/extensions/CCBReader/CCSpriteLoader.h +++ b/cocos2dx/extensions/CCBReader/CCSpriteLoader.h @@ -14,7 +14,7 @@ class CC_DLL CCSpriteLoader : public CCNodeLoader { CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(CCSpriteLoader, loader); protected: - virtual CCSprite * createCCNode(CCNode *, CCBReader *); + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCSprite); virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *); virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *); diff --git a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id index 29cead04fd..e8bf743ac2 100644 --- a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -b0bc510824d786752a37f8b48a77a4c418c146b4 \ No newline at end of file +96920b02a30e4746149c7b1b150ff3f6d9cd4e68 \ No newline at end of file From fea4401681635675aaacc56032e3eea595e812fd Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Mon, 18 Jun 2012 13:41:48 -0700 Subject: [PATCH 218/257] CCBReader: Named a whole bunch of parameters in the CCNodeLoader headers. --- cocos2dx/extensions/CCBReader/CCBFileLoader.h | 2 +- .../extensions/CCBReader/CCControlButtonLoader.h | 16 ++++++++-------- cocos2dx/extensions/CCBReader/CCControlLoader.h | 4 ++-- .../extensions/CCBReader/CCLabelBMFontLoader.h | 10 +++++----- cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h | 16 ++++++++-------- .../extensions/CCBReader/CCLayerColorLoader.h | 6 +++--- .../extensions/CCBReader/CCLayerGradientLoader.h | 8 ++++---- .../extensions/CCBReader/CCMenuItemImageLoader.h | 2 +- cocos2dx/extensions/CCBReader/CCMenuItemLoader.h | 4 ++-- .../CCBReader/CCParticleSystemQuadLoader.h | 16 ++++++++-------- .../extensions/CCBReader/CCScale9SpriteLoader.h | 12 ++++++------ cocos2dx/extensions/CCBReader/CCSpriteLoader.h | 10 +++++----- 12 files changed, 53 insertions(+), 53 deletions(-) diff --git a/cocos2dx/extensions/CCBReader/CCBFileLoader.h b/cocos2dx/extensions/CCBReader/CCBFileLoader.h index b9443bfa70..94de956ebf 100644 --- a/cocos2dx/extensions/CCBReader/CCBFileLoader.h +++ b/cocos2dx/extensions/CCBReader/CCBFileLoader.h @@ -16,7 +16,7 @@ class CC_DLL CCBFileLoader : public CCNodeLoader { protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCNode); - virtual void onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCNode *, CCBReader *); + virtual void onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h b/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h index 78946c1d08..87eb55b0cc 100644 --- a/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h +++ b/cocos2dx/extensions/CCBReader/CCControlButtonLoader.h @@ -16,14 +16,14 @@ class CC_DLL CCControlButtonLoader : public CCControlLoader { protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCControlButton); - virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool, CCBReader *); - virtual void onHandlePropTypeString(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString *, CCBReader *); - virtual void onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString *, CCBReader *); - virtual void onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float, CCBReader *); - virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint, CCBReader *); - virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize, CCBReader *); - virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame *, CCBReader *); - virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *); + virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader); + virtual void onHandlePropTypeString(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pString, CCBReader * pCCBReader); + virtual void onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pFontTTF, CCBReader * pCCBReader); + virtual void onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloatScale, CCBReader * pCCBReader); + virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader); + virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize pSize, CCBReader * pCCBReader); + virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader); + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCControlLoader.h b/cocos2dx/extensions/CCBReader/CCControlLoader.h index 5383586d37..fe191cc5fe 100644 --- a/cocos2dx/extensions/CCBReader/CCControlLoader.h +++ b/cocos2dx/extensions/CCBReader/CCControlLoader.h @@ -15,8 +15,8 @@ class CC_DLL CCControlLoader : public CCNodeLoader { protected: CCB_PURE_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCControl); - virtual void onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockCCControlData *, CCBReader *); - virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool, CCBReader *); + virtual void onHandlePropTypeBlockCCControl(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockCCControlData * pBlockCCControlData, CCBReader * pCCBReader); + virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h b/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h index f2452bffcf..5ba9ca8211 100644 --- a/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLabelBMFontLoader.h @@ -16,11 +16,11 @@ class CC_DLL CCLabelBMFontLoader : public CCNodeLoader { protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCLabelBMFont); - virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *); - virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc, CCBReader *); - virtual void onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString *, CCBReader *); - virtual void onHandlePropTypeText(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString *, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader); + virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader); + virtual void onHandlePropTypeFntFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pFntFile, CCBReader * pCCBReader); + virtual void onHandlePropTypeText(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pText, CCBReader * pCCBReader); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h b/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h index dced2ad066..e15befe58c 100644 --- a/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLabelTTFLoader.h @@ -16,14 +16,14 @@ class CC_DLL CCLabelTTFLoader : public CCNodeLoader { protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCLabelTTF); - virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *); - virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc, CCBReader *); - virtual void onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString *, CCBReader *); - virtual void onHandlePropTypeText(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString *, CCBReader *); - virtual void onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float, CCBReader *); - virtual void onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int, CCBReader *); - virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader); + virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader); + virtual void onHandlePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pFontTTF, CCBReader * pCCBReader); + virtual void onHandlePropTypeText(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCString * pText, CCBReader * pCCBReader); + virtual void onHandlePropTypeFloatScale(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloatScale, CCBReader * pCCBReader); + virtual void onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader); + virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize pSize, CCBReader * pCCBReader); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h b/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h index 1091f4b417..81ca6c2855 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLayerColorLoader.h @@ -16,9 +16,9 @@ class CC_DLL CCLayerColorLoader : public CCLayerLoader { protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCLayerColor); - virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *); - virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader); + virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h b/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h index 58603ea18d..da0ac1fa32 100644 --- a/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h +++ b/cocos2dx/extensions/CCBReader/CCLayerGradientLoader.h @@ -16,10 +16,10 @@ class CC_DLL CCLayerGradientLoader : public CCLayerLoader { protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCLayerGradient); - virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *); - virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *); - virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader); + virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader); + virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h b/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h index d9b204ae5a..ba973a6757 100644 --- a/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h +++ b/cocos2dx/extensions/CCBReader/CCMenuItemImageLoader.h @@ -16,7 +16,7 @@ class CC_DLL CCMenuItemImageLoader : public CCMenuItemLoader { protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCMenuItemImage); - virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame *, CCBReader *); + virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCMenuItemLoader.h b/cocos2dx/extensions/CCBReader/CCMenuItemLoader.h index ed0278d3b0..177be209e0 100644 --- a/cocos2dx/extensions/CCBReader/CCMenuItemLoader.h +++ b/cocos2dx/extensions/CCBReader/CCMenuItemLoader.h @@ -15,8 +15,8 @@ class CC_DLL CCMenuItemLoader : public CCNodeLoader { protected: CCB_PURE_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCMenuItem); - virtual void onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockData *, CCBReader *); - virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool, CCBReader *); + virtual void onHandlePropTypeBlock(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, BlockData * pBlockData, CCBReader * pCCBReader); + virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h b/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h index 1a6e85beb5..1fb972051d 100644 --- a/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h +++ b/cocos2dx/extensions/CCBReader/CCParticleSystemQuadLoader.h @@ -16,14 +16,14 @@ class CC_DLL CCParticleSystemQuadLoader : public CCNodeLoader { protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCParticleSystemQuad); - virtual void onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int, CCBReader *); - virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint, CCBReader *); - virtual void onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float, CCBReader *); - virtual void onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int, CCBReader *); - virtual void onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float *, CCBReader *); - virtual void onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor4F *, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc, CCBReader *); - virtual void onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCTexture2D *, CCBReader *); + virtual void onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader); + virtual void onHandlePropTypePoint(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCPoint pPoint, CCBReader * pCCBReader); + virtual void onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloat, CCBReader * pCCBReader); + virtual void onHandlePropTypeInteger(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int pInteger, CCBReader * pCCBReader); + virtual void onHandlePropTypeFloatVar(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float * pFloatVar, CCBReader * pCCBReader); + virtual void onHandlePropTypeColor4FVar(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor4F * pCCColor4FVar, CCBReader * pCCBReader); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader); + virtual void onHandlePropTypeTexture(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCTexture2D * pCCTexture2D, CCBReader * pCCBReader); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h b/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h index 97658767d1..15bc0b648f 100644 --- a/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h +++ b/cocos2dx/extensions/CCBReader/CCScale9SpriteLoader.h @@ -16,12 +16,12 @@ class CC_DLL CCScale9SpriteLoader : public CCNodeLoader { protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCScale9Sprite); - virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *); - virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc, CCBReader *); - virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame *, CCBReader *); - virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize, CCBReader *); - virtual void onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader); + virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader); + virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader); + virtual void onHandlePropTypeSize(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSize pSize, CCBReader * pCCBReader); + virtual void onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloat, CCBReader * pCCBReader); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCBReader/CCSpriteLoader.h b/cocos2dx/extensions/CCBReader/CCSpriteLoader.h index e748ccd7f9..3cb31a139c 100644 --- a/cocos2dx/extensions/CCBReader/CCSpriteLoader.h +++ b/cocos2dx/extensions/CCBReader/CCSpriteLoader.h @@ -16,11 +16,11 @@ class CC_DLL CCSpriteLoader : public CCNodeLoader { protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCSprite); - virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *); - virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc, CCBReader *); - virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame *, CCBReader *); - virtual void onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool *, CCBReader *); + virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader); + virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader); + virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBBlendFunc, CCBReader * pCCBReader); + virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader); + virtual void onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool * pFlip, CCBReader * pCCBReader); }; NS_CC_EXT_END From 6f26ea7a5688d6bae93b17cc0129caad2412af0e Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Mon, 18 Jun 2012 13:59:45 -0700 Subject: [PATCH 219/257] Added actual implementation of CCScrollViewLoader. Added ScrollViewTest to CococsBuilderTest. --- .../CCBReader/CCScrollViewLoader.cpp | 49 ++++++++++++------- .../extensions/CCBReader/CCScrollViewLoader.h | 8 ++- .../project.pbxproj.REMOVED.git-id | 2 +- .../HelloCocosBuilderLayer.cpp | 3 +- .../ScrollViewTest/ScrollViewTestLayer.h | 12 +++++ .../ScrollViewTestLayerLoader.h | 18 +++++++ 6 files changed, 68 insertions(+), 24 deletions(-) create mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/ScrollViewTest/ScrollViewTestLayer.h create mode 100644 tests/tests/ExtensionsTest/CocosBuilderTest/ScrollViewTest/ScrollViewTestLayerLoader.h diff --git a/cocos2dx/extensions/CCBReader/CCScrollViewLoader.cpp b/cocos2dx/extensions/CCBReader/CCScrollViewLoader.cpp index 8fa0938f69..2f02bb55b3 100644 --- a/cocos2dx/extensions/CCBReader/CCScrollViewLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCScrollViewLoader.cpp @@ -3,27 +3,42 @@ USING_NS_CC; USING_NS_CC_EXT; -void CCScrollViewLoader::onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame * pCCSpriteFrame, CCBReader * pCCBReader) { +#define PROPERTY_CONTAINER "container" +#define PROPERTY_DIRECTION "direction" +#define PROPERTY_CLIPSTOBOUNDS "clipsToBounds" +#define PROPERTY_BOUNCES "bounces" +#define PROPERTY_SCALE "scale" +void CCScrollViewLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_CLIPSTOBOUNDS) == 0) { + ((CCScrollView *)pNode)->setClippingToBounds(pCheck); + } else if(pPropertyName->compare(PROPERTY_BOUNCES) == 0) { + ((CCScrollView *)pNode)->setBounceable(pCheck); + } else { + CCNodeLoader::onHandlePropTypeCheck(pNode, pParent, pPropertyName, pCheck, pCCBReader); + } } -void CCScrollViewLoader::onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool * pFlip, CCBReader * pCCBReader) { - +void CCScrollViewLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_CONTAINER) == 0) { + ((CCScrollView *)pNode)->addChild(pCCBFileNode); + } else { + CCNodeLoader::onHandlePropTypeCCBFile(pNode, pParent, pPropertyName, pCCBFileNode, pCCBReader); + } } -void CCScrollViewLoader::onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B pCCColor3B, CCBReader * pCCBReader) { - +void CCScrollViewLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloat, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_SCALE) == 0) { + ((CCScrollView *)pNode)->setScale(pFloat); + } else { + CCNodeLoader::onHandlePropTypeFloat(pNode, pParent, pPropertyName, pFloat, pCCBReader); + } } -void CCScrollViewLoader::onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char pByte, CCBReader * pCCBReader) { - -} - -void CCScrollViewLoader::onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc pCCBlendFunc, CCBReader * pCCBReader) { - -} - -void CCScrollViewLoader::onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloat, CCBReader * pCCBReader) -{ - -} +void CCScrollViewLoader::onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader) { + if(pPropertyName->compare(PROPERTY_DIRECTION) == 0) { + ((CCScrollView *)pNode)->setDirection(CCScrollViewDirection(pIntegerLabeled)); + } else { + CCNodeLoader::onHandlePropTypeFloatScale(pNode, pParent, pPropertyName, pIntegerLabeled, pCCBReader); + } +} \ No newline at end of file diff --git a/cocos2dx/extensions/CCBReader/CCScrollViewLoader.h b/cocos2dx/extensions/CCBReader/CCScrollViewLoader.h index 11c635d274..ae37e998ab 100644 --- a/cocos2dx/extensions/CCBReader/CCScrollViewLoader.h +++ b/cocos2dx/extensions/CCBReader/CCScrollViewLoader.h @@ -16,12 +16,10 @@ class CC_DLL CCScrollViewLoader : public CCNodeLoader { protected: CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(CCScrollView); - virtual void onHandlePropTypeColor3(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccColor3B, CCBReader *); - virtual void onHandlePropTypeByte(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, unsigned char, CCBReader *); - virtual void onHandlePropTypeBlendFunc(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, ccBlendFunc, CCBReader *); - virtual void onHandlePropTypeSpriteFrame(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCSpriteFrame *, CCBReader *); - virtual void onHandlePropTypeFlip(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool *, CCBReader *); + virtual void onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader); + virtual void onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, bool pCheck, CCBReader * pCCBReader); virtual void onHandlePropTypeFloat(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, float pFloat, CCBReader * pCCBReader); + virtual void onHandlePropTypeIntegerLabeled(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, int pIntegerLabeled, CCBReader * pCCBReader); }; NS_CC_EXT_END diff --git a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id index e8bf743ac2..dec87038f9 100644 --- a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -96920b02a30e4746149c7b1b150ff3f6d9cd4e68 \ No newline at end of file +9be43d656b596e6fcb7ccbefa70129c2ccaf855e \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp index 384ff6a6b7..b26473bfa5 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp @@ -9,6 +9,7 @@ #include "../SpriteTest/SpriteTestLayerLoader.h" #include "../MenuTest/MenuTestLayerLoader.h" #include "../ParticleSystemTest/ParticleSystemTestLayerLoader.h" +#include "../ScrollViewTest/ScrollViewTestLayerLoader.h" USING_NS_CC; USING_NS_CC_EXT; @@ -101,5 +102,5 @@ void HelloCocosBuilderLayer::onParticleSystemTestClicked(CCObject * pSender, coc } void HelloCocosBuilderLayer::onScrollViewTestClicked(CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent) { - CCLog("onScrollViewTestClicked\n"); + this->openTest("ccb/ScrollViewTest.ccbi", "ScrollViewTestLayer", ScrollViewTestLayerLoader::loader()); } \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ScrollViewTest/ScrollViewTestLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/ScrollViewTest/ScrollViewTestLayer.h new file mode 100644 index 0000000000..836850de64 --- /dev/null +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/ScrollViewTest/ScrollViewTestLayer.h @@ -0,0 +1,12 @@ +#ifndef _SCROLLVIEWTESTLAYER_H_ +#define _SCROLLVIEWTESTLAYER_H_ + +#include "cocos2d.h" +#include "extensions/CCBReader/CCBReader.h" + +class ScrollViewTestLayer : public cocos2d::CCLayer { + public: + CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(ScrollViewTestLayer, node); +}; + +#endif \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ScrollViewTest/ScrollViewTestLayerLoader.h b/tests/tests/ExtensionsTest/CocosBuilderTest/ScrollViewTest/ScrollViewTestLayerLoader.h new file mode 100644 index 0000000000..39f3e57734 --- /dev/null +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/ScrollViewTest/ScrollViewTestLayerLoader.h @@ -0,0 +1,18 @@ +#ifndef _SCROLLVIEWTESTLAYERLOADER_H_ +#define _SCROLLVIEWTESTLAYERLOADER_H_ + +#include "extensions/CCBReader/CCLayerLoader.h" +#include "ScrollViewTestLayer.h" + +/* Forward declaration. */ +class CCBReader; + +class ScrollViewTestLayerLoader : public cocos2d::extension::CCLayerLoader { + public: + CCB_STATIC_NEW_AUTORELEASE_OBJECT_METHOD(ScrollViewTestLayerLoader, loader); + + protected: + CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(ScrollViewTestLayer); +}; + +#endif From ac4a56a38c196bd64fdb72ecd966b7ee9513c110 Mon Sep 17 00:00:00 2001 From: Nicolas Gramlich Date: Mon, 18 Jun 2012 18:43:53 -0700 Subject: [PATCH 220/257] Fixed CCScrollView (since it was behaving differently compared to the cocos2d-iphone version). --- .../CCBReader/CCScrollViewLoader.cpp | 2 +- .../extensions/CCScrollView/CCScrollView.cpp | 45 ++++++++++++------- .../extensions/CCScrollView/CCScrollView.h | 2 + 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/cocos2dx/extensions/CCBReader/CCScrollViewLoader.cpp b/cocos2dx/extensions/CCBReader/CCScrollViewLoader.cpp index 2f02bb55b3..71ef9154f8 100644 --- a/cocos2dx/extensions/CCBReader/CCScrollViewLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCScrollViewLoader.cpp @@ -21,7 +21,7 @@ void CCScrollViewLoader::onHandlePropTypeCheck(CCNode * pNode, CCNode * pParent, void CCScrollViewLoader::onHandlePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CCString * pPropertyName, CCNode * pCCBFileNode, CCBReader * pCCBReader) { if(pPropertyName->compare(PROPERTY_CONTAINER) == 0) { - ((CCScrollView *)pNode)->addChild(pCCBFileNode); + ((CCScrollView *)pNode)->setContainer(pCCBFileNode); } else { CCNodeLoader::onHandlePropTypeCCBFile(pNode, pParent, pPropertyName, pCCBFileNode, pCCBReader); } diff --git a/cocos2dx/extensions/CCScrollView/CCScrollView.cpp b/cocos2dx/extensions/CCScrollView/CCScrollView.cpp index c9e922d205..afaccbd753 100644 --- a/cocos2dx/extensions/CCScrollView/CCScrollView.cpp +++ b/cocos2dx/extensions/CCScrollView/CCScrollView.cpp @@ -127,7 +127,7 @@ bool CCScrollView::initWithViewSize(CCSize size, CCNode *container/* = NULL*/) m_pDelegate = NULL; m_bBounceable = true; m_bClippingToBounds = true; - m_pContainer->setContentSize(CCSizeZero); + //m_pContainer->setContentSize(CCSizeZero); m_eDirection = CCScrollViewDirectionBoth; m_pContainer->setPosition(ccp(0.0f, 0.0f)); m_fTouchLength = 0.0f; @@ -308,9 +308,10 @@ void CCScrollView::setZoomScaleInDuration(float s, float dt) void CCScrollView::setViewSize(CCSize size) { - if (!CCSize::CCSizeEqualToSize(m_tViewSize, size)) + m_tViewSize = size; + + if (this->m_pContainer != NULL) { - m_tViewSize = size; m_fMaxInset = this->maxContainerOffset(); m_fMaxInset = ccp(m_fMaxInset.x + m_tViewSize.width * INSET_RATIO, m_fMaxInset.y + m_tViewSize.height * INSET_RATIO); @@ -318,6 +319,29 @@ void CCScrollView::setViewSize(CCSize size) m_fMinInset = ccp(m_fMinInset.x - m_tViewSize.width * INSET_RATIO, m_fMinInset.y - m_tViewSize.height * INSET_RATIO); } + + CCLayer::setContentSize(size); +} + +CCNode * CCScrollView::getContainer() +{ + return this->m_pContainer; +} + +void CCScrollView::setContainer(CCNode * pContainer) +{ + this->removeAllChildrenWithCleanup(true); + + if (!pContainer) return; + + this->m_pContainer = pContainer; + + this->m_pContainer->ignoreAnchorPointForPosition(false); + this->m_pContainer->setAnchorPoint(ccp(0.0f, 0.0f)); + + this->addChild(this->m_pContainer); + + this->setViewSize(this->m_tViewSize); } void CCScrollView::relocateContainer(bool animated) @@ -432,23 +456,11 @@ CCSize CCScrollView::getContentSize() void CCScrollView::setContentSize(CCSize size) { -// this->setViewSize(size); - - if (m_pContainer != NULL) - { - m_pContainer->setContentSize(size); - m_fMaxInset = this->maxContainerOffset(); - m_fMaxInset = ccp(m_fMaxInset.x + m_tViewSize.width * INSET_RATIO, - m_fMaxInset.y + m_tViewSize.height * INSET_RATIO); - m_fMinInset = this->minContainerOffset(); - m_fMinInset = ccp(m_fMinInset.x - m_tViewSize.width * INSET_RATIO, - m_fMinInset.y - m_tViewSize.height * INSET_RATIO); - } + this->setViewSize(size); } /** * make sure all children go to the container */ - void CCScrollView::addChild(CCNode * child, int zOrder, int tag) { child->ignoreAnchorPointForPosition(false); @@ -473,7 +485,6 @@ void CCScrollView::addChild(CCNode * child) /** * clip this view so that outside of the visible bounds can be hidden. */ - void CCScrollView::beforeDraw() { if (m_bClippingToBounds) diff --git a/cocos2dx/extensions/CCScrollView/CCScrollView.h b/cocos2dx/extensions/CCScrollView/CCScrollView.h index f357f72c57..382aef2308 100644 --- a/cocos2dx/extensions/CCScrollView/CCScrollView.h +++ b/cocos2dx/extensions/CCScrollView/CCScrollView.h @@ -324,6 +324,8 @@ protected: public: CCSize getViewSize() { return m_tViewSize; } void setViewSize(CCSize size); + CCNode * getContainer(); + void setContainer(CCNode * pContainer); protected: /** * max and min scale From 9fa74721a7b506d820e2348c04717da17501dce5 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 19 Jun 2012 10:34:15 +0800 Subject: [PATCH 221/257] fixed #1334: Add ScrollViewTest to CocosBuilderTest. --- .../CCBReader/CCNodeLoaderLibrary.cpp | 2 +- .../extensions/CCScrollView/CCScrollView.h | 12 +- cocos2dx/proj.win32/cocos2d-win32.vcproj | 4 - cocos2dx/proj.win32/cocos2d-win32.vcxproj | 5 +- .../proj.win32/cocos2d-win32.vcxproj.filters | 18 ++- .../cocos2d_generated.cpp.REMOVED.git-id | 2 +- tests/proj.win32/test.win32.vcproj | 12 ++ tests/proj.win32/test.win32.vcxproj | 32 ++++-- tests/proj.win32/test.win32.vcxproj.filters | 104 +++++++++++++----- 9 files changed, 137 insertions(+), 54 deletions(-) diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp index 8082098df3..1d1b2bca93 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp +++ b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp @@ -98,7 +98,7 @@ void CCNodeLoaderLibrary::purgeSharedCCNodeLoaderLibrary() { CCNodeLoaderLibrary * CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary() { CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::library(); - + ccNodeLoaderLibrary->registerDefaultCCNodeLoaders(); return ccNodeLoaderLibrary; diff --git a/cocos2dx/extensions/CCScrollView/CCScrollView.h b/cocos2dx/extensions/CCScrollView/CCScrollView.h index f357f72c57..bb3bed9b28 100644 --- a/cocos2dx/extensions/CCScrollView/CCScrollView.h +++ b/cocos2dx/extensions/CCScrollView/CCScrollView.h @@ -174,6 +174,14 @@ public: bool isBounceable() { return m_bBounceable; } void setBounceable(bool bBounceable) { m_bBounceable = bBounceable; } + /** + * size to clip. CCNode boundingBox uses contentSize directly. + * It's semantically different what it actually means to common scroll views. + * Hence, this scroll view will use a separate size property. + */ + CCSize getViewSize() { return m_tViewSize; } + void setViewSize(CCSize size); + /** * direction allowed to scroll. CCScrollViewDirectionBoth by default. */ @@ -321,10 +329,6 @@ protected: * Hence, this scroll view will use a separate size property. */ CCSize m_tViewSize; -public: - CCSize getViewSize() { return m_tViewSize; } - void setViewSize(CCSize size); -protected: /** * max and min scale */ diff --git a/cocos2dx/proj.win32/cocos2d-win32.vcproj b/cocos2dx/proj.win32/cocos2d-win32.vcproj index b9b8ebcfbb..c0d356da8e 100755 --- a/cocos2dx/proj.win32/cocos2d-win32.vcproj +++ b/cocos2dx/proj.win32/cocos2d-win32.vcproj @@ -1334,10 +1334,6 @@ RelativePath="..\extensions\CCBReader\CCMenuItemLoader.h" > - - diff --git a/cocos2dx/proj.win32/cocos2d-win32.vcxproj b/cocos2dx/proj.win32/cocos2d-win32.vcxproj index 48922d00c3..39197d3e98 100755 --- a/cocos2dx/proj.win32/cocos2d-win32.vcxproj +++ b/cocos2dx/proj.win32/cocos2d-win32.vcxproj @@ -174,11 +174,11 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ - + @@ -195,6 +195,7 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ + @@ -330,6 +331,7 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ + @@ -348,6 +350,7 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ + diff --git a/cocos2dx/proj.win32/cocos2d-win32.vcxproj.filters b/cocos2dx/proj.win32/cocos2d-win32.vcxproj.filters index 1ad962d5bc..2ba5ad8086 100755 --- a/cocos2dx/proj.win32/cocos2d-win32.vcxproj.filters +++ b/cocos2dx/proj.win32/cocos2d-win32.vcxproj.filters @@ -109,6 +109,9 @@ {4647762c-52c3-475d-968a-96aa48dbcd0c} + + {a9d9fee5-8d26-4082-b526-2b7830770446} + @@ -510,9 +513,6 @@ extensions\CCBReader - - extensions\CCBReader - extensions\CCBReader @@ -537,6 +537,12 @@ actions + + extensions\CCScrollView + + + extensions\CCBReader + @@ -1087,5 +1093,11 @@ actions + + extensions\CCScrollView + + + extensions\CCBReader + \ No newline at end of file diff --git a/js/JSBindings/cocos2d_generated.cpp.REMOVED.git-id b/js/JSBindings/cocos2d_generated.cpp.REMOVED.git-id index 00cf46e3b8..b7f0783248 100644 --- a/js/JSBindings/cocos2d_generated.cpp.REMOVED.git-id +++ b/js/JSBindings/cocos2d_generated.cpp.REMOVED.git-id @@ -1 +1 @@ -80e25f0506e93a93d244735fd6deb92cec8055d2 \ No newline at end of file +237baaafa1073d1c133294a70e84bcd2849ec57d \ No newline at end of file diff --git a/tests/proj.win32/test.win32.vcproj b/tests/proj.win32/test.win32.vcproj index b948c75801..bfc51c715b 100644 --- a/tests/proj.win32/test.win32.vcproj +++ b/tests/proj.win32/test.win32.vcproj @@ -1001,6 +1001,18 @@ > + + + + + + - - + - - - - + + + @@ -208,13 +206,23 @@ - - + + - - - - + + + + + + + + + + + + + + diff --git a/tests/proj.win32/test.win32.vcxproj.filters b/tests/proj.win32/test.win32.vcxproj.filters index 92df584143..3887f6c834 100644 --- a/tests/proj.win32/test.win32.vcxproj.filters +++ b/tests/proj.win32/test.win32.vcxproj.filters @@ -166,6 +166,30 @@ {2e6b7147-7836-4a98-a2f5-a00080e7ca23} + + {b6567e7e-4af7-4e84-857a-affc03c1332a} + + + {5b3fcb56-0c0f-4433-a209-50ffca282f88} + + + {629b76d1-2144-49f0-a2ef-357caa97d0dc} + + + {eee8a971-55ff-46ca-8d1f-7b03feb9481c} + + + {ff19ea2d-70c2-444d-8d41-7ce3cd208dbd} + + + {706efc28-51b2-48d9-bcd9-b76f49eb68a5} + + + {8a4f12b4-f105-495c-83d6-0005d05b61a0} + + + {4c0682f3-b85a-4418-adda-9b25de410af0} + @@ -390,26 +414,20 @@ classes\tests\MutiTouchTest - - classes\tests\ExtensionsTest\CocosBuilderTest - - - classes\tests\ExtensionsTest\CocosBuilderTest - classes\tests\ExtensionsTest\CocosBuilderTest - - classes\tests\ExtensionsTest\CocosBuilderTest + + classes\tests\ExtensionsTest\CocosBuilderTest\TestHeader - - classes\tests\ExtensionsTest\CocosBuilderTest + + classes\tests\ExtensionsTest\CocosBuilderTest\MenuTest - - classes\tests\ExtensionsTest\CocosBuilderTest + + classes\tests\ExtensionsTest\CocosBuilderTest\HelloCocosBuilder - - classes\tests\ExtensionsTest\CocosBuilderTest + + classes\tests\ExtensionsTest\CocosBuilderTest\ButtonTest @@ -749,26 +767,56 @@ classes\tests\MutiTouchTest - - classes\tests\ExtensionsTest\CocosBuilderTest - - - classes\tests\ExtensionsTest\CocosBuilderTest - classes\tests\ExtensionsTest\CocosBuilderTest - - classes\tests\ExtensionsTest\CocosBuilderTest + + classes\tests\ExtensionsTest\CocosBuilderTest\TestHeader - - classes\tests\ExtensionsTest\CocosBuilderTest + + classes\tests\ExtensionsTest\CocosBuilderTest\TestHeader - - classes\tests\ExtensionsTest\CocosBuilderTest + + classes\tests\ExtensionsTest\CocosBuilderTest\SpriteTest - - classes\tests\ExtensionsTest\CocosBuilderTest + + classes\tests\ExtensionsTest\CocosBuilderTest\SpriteTest + + + classes\tests\ExtensionsTest\CocosBuilderTest\ScrollViewTest + + + classes\tests\ExtensionsTest\CocosBuilderTest\ScrollViewTest + + + classes\tests\ExtensionsTest\CocosBuilderTest\ParticleSystemTest + + + classes\tests\ExtensionsTest\CocosBuilderTest\ParticleSystemTest + + + classes\tests\ExtensionsTest\CocosBuilderTest\MenuTest + + + classes\tests\ExtensionsTest\CocosBuilderTest\MenuTest + + + classes\tests\ExtensionsTest\CocosBuilderTest\LabelTest + + + classes\tests\ExtensionsTest\CocosBuilderTest\LabelTest + + + classes\tests\ExtensionsTest\CocosBuilderTest\HelloCocosBuilder + + + classes\tests\ExtensionsTest\CocosBuilderTest\HelloCocosBuilder + + + classes\tests\ExtensionsTest\CocosBuilderTest\ButtonTest + + + classes\tests\ExtensionsTest\CocosBuilderTest\ButtonTest \ No newline at end of file From c1883c1237c3bff798603534c47ab45f3e7cebc6 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 19 Jun 2012 10:55:52 +0800 Subject: [PATCH 222/257] fixed #1334: Updated CCScrollView.h --- cocos2dx/extensions/CCScrollView/CCScrollView.h | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/cocos2dx/extensions/CCScrollView/CCScrollView.h b/cocos2dx/extensions/CCScrollView/CCScrollView.h index d997a26388..1fb168e5e0 100644 --- a/cocos2dx/extensions/CCScrollView/CCScrollView.h +++ b/cocos2dx/extensions/CCScrollView/CCScrollView.h @@ -184,6 +184,7 @@ public: CCNode * getContainer(); void setContainer(CCNode * pContainer); + /** * direction allowed to scroll. CCScrollViewDirectionBoth by default. */ @@ -331,12 +332,6 @@ protected: * Hence, this scroll view will use a separate size property. */ CCSize m_tViewSize; -public: - CCSize getViewSize() { return m_tViewSize; } - void setViewSize(CCSize size); - CCNode * getContainer(); - void setContainer(CCNode * pContainer); -protected: /** * max and min scale */ From 9ec29d715a7555e324656d24e23a9c94c6737ab2 Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 19 Jun 2012 13:50:11 +0800 Subject: [PATCH 223/257] issue #1269:make tests HelloWorld HelloLua and testjs refer subproject cocos2dx --- HelloLua/Classes/AppDelegate.cpp | 2 +- .../HelloLua.xcodeproj/project.pbxproj | 804 ++++++++++++++++ .../project.pbxproj.REMOVED.git-id | 1 - HelloWorld/Classes/AppDelegate.cpp | 4 - HelloWorld/Classes/AppDelegate.h | 2 +- .../HelloWorld.xcodeproj/project.pbxproj | 405 ++++++++ .../project.pbxproj.REMOVED.git-id | 1 - cocos2dx/CCCamera.h | 4 +- cocos2dx/CCConfiguration.h | 4 +- cocos2dx/CCDirector.h | 8 +- cocos2dx/CCDrawingPrimitives.h | 2 +- cocos2dx/CCScheduler.h | 2 +- cocos2dx/actions/CCAction.h | 5 +- cocos2dx/actions/CCActionCatmullRom.h | 4 +- cocos2dx/actions/CCActionInterval.h | 6 +- cocos2dx/actions/CCActionManager.h | 4 +- cocos2dx/base_nodes/CCNode.h | 8 +- cocos2dx/cocoa/CCAffineTransform.h | 2 +- cocos2dx/cocoa/CCGeometry.h | 2 +- cocos2dx/cocoa/CCObject.h | 2 +- cocos2dx/cocoa/CCZone.h | 2 +- cocos2dx/effects/CCGrabber.h | 2 +- cocos2dx/effects/CCGrid.h | 6 +- .../extensions/CCControlExtension/CCControl.h | 2 +- .../CCControlExtension/CCControlSlider.h | 4 +- .../CCControlExtension/CCControlUtils.h | 2 +- .../CCControlExtension/CCInvocation.h | 2 +- .../CCControlExtension/CCScale9Sprite.h | 2 +- .../extensions/CCControlExtension/CCSpacer.h | 2 +- cocos2dx/extensions/CCListView/CCListView.h | 10 +- .../extensions/CCListView/CCListViewCell.h | 2 +- .../CCNotificationCenter.h | 2 +- cocos2dx/include/CCProtocols.h | 2 +- cocos2dx/include/ccConfig.h | 2 +- cocos2dx/include/ccMacros.h | 2 +- cocos2dx/include/ccTypes.h | 2 +- cocos2dx/include/cocos2d.h | 206 +++-- cocos2dx/kazmath/include/kazmath/GL/matrix.h | 2 +- cocos2dx/kazmath/include/kazmath/aabb.h | 2 +- cocos2dx/kazmath/include/kazmath/mat3.h | 2 +- cocos2dx/kazmath/include/kazmath/mat4.h | 2 +- cocos2dx/kazmath/include/kazmath/plane.h | 2 +- cocos2dx/kazmath/include/kazmath/quaternion.h | 2 +- cocos2dx/kazmath/include/kazmath/ray2.h | 2 +- cocos2dx/kazmath/include/kazmath/utility.h | 2 +- cocos2dx/kazmath/include/kazmath/vec2.h | 2 +- cocos2dx/kazmath/include/kazmath/vec3.h | 2 +- cocos2dx/keypad_dispatcher/CCKeypadDelegate.h | 2 +- .../keypad_dispatcher/CCKeypadDispatcher.h | 2 +- cocos2dx/label_nodes/CCLabelAtlas.h | 2 +- cocos2dx/label_nodes/CCLabelBMFont.h | 2 +- cocos2dx/label_nodes/CCLabelTTF.h | 4 +- .../layers_scenes_transitions_nodes/CCLayer.h | 10 +- .../layers_scenes_transitions_nodes/CCScene.h | 2 +- cocos2dx/menu_nodes/CCMenu.h | 2 +- cocos2dx/menu_nodes/CCMenuItem.h | 4 +- cocos2dx/misc_nodes/CCMotionStreak.h | 4 +- cocos2dx/misc_nodes/CCProgressTimer.h | 2 +- cocos2dx/misc_nodes/CCRenderTexture.h | 34 +- cocos2dx/particle_nodes/CCParticleBatchNode.h | 2 +- cocos2dx/particle_nodes/CCParticleSystem.h | 6 +- cocos2dx/platform/CCImage.h | 2 +- cocos2dx/platform/CCPlatformMacros.h | 1 + cocos2dx/platform/ios/CCAccelerometer.h | 2 +- cocos2dx/platform/ios/CCApplication.h | 4 +- cocos2dx/platform/ios/CCEGLView.h | 4 +- cocos2dx/platform/ios/CCESRenderer.h | 2 +- cocos2dx/platform/ios/CCStdC.h | 2 +- cocos2dx/proj.ios/cocos2dx-Prefix.pch | 7 + .../project.pbxproj.REMOVED.git-id | 1 + .../cocos2dx.xcodeproj/project.pbxproj | 232 +++++ .../cocos2dx/cocos2dx/cocos2dx-Prefix.pch | 7 + .../proj.ios/cocos2dx/cocos2dx/cocos2dx.h | 13 + .../proj.ios/cocos2dx/cocos2dx/cocos2dx.m | 13 + cocos2dx/proj.ios/libcocos2dx-Prefix.pch | 9 - .../project.pbxproj.REMOVED.git-id | 1 - cocos2dx/script_support/CCScriptSupport.h | 6 +- cocos2dx/shaders/CCGLProgram.h | 2 +- cocos2dx/shaders/CCShaderCache.h | 2 +- cocos2dx/shaders/ccGLStateCache.h | 2 +- cocos2dx/shaders/ccShaders.h | 2 +- cocos2dx/sprite_nodes/CCAnimation.h | 10 +- cocos2dx/sprite_nodes/CCAnimationCache.h | 4 +- cocos2dx/sprite_nodes/CCSprite.h | 6 +- cocos2dx/sprite_nodes/CCSpriteBatchNode.h | 6 +- cocos2dx/sprite_nodes/CCSpriteFrame.h | 6 +- cocos2dx/sprite_nodes/CCSpriteFrameCache.h | 8 +- cocos2dx/support/CCPointExtension.h | 2 +- cocos2dx/support/CCProfiling.h | 6 +- cocos2dx/support/CCUserDefault.h | 2 +- cocos2dx/support/data_support/ccCArray.h | 5 +- cocos2dx/text_input_node/CCIMEDelegate.h | 2 +- cocos2dx/text_input_node/CCTextFieldTTF.h | 6 +- cocos2dx/textures/CCTexture2D.h | 4 +- cocos2dx/textures/CCTextureAtlas.h | 4 +- cocos2dx/textures/CCTextureCache.h | 6 +- cocos2dx/textures/CCTexturePVR.h | 4 +- .../tileMap_parallax_nodes/CCParallaxNode.h | 2 +- cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h | 4 +- .../tileMap_parallax_nodes/CCTMXObjectGroup.h | 8 +- .../tileMap_parallax_nodes/CCTMXTiledMap.h | 3 +- .../tileMap_parallax_nodes/CCTMXXMLParser.h | 8 +- .../tileMap_parallax_nodes/CCTileMapAtlas.h | 2 +- cocos2dx/touch_dispatcher/CCTouch.h | 4 +- .../CCTouchDelegateProtocol.h | 2 +- cocos2dx/touch_dispatcher/CCTouchDispatcher.h | 4 +- cocos2dx/touch_dispatcher/CCTouchHandler.h | 4 +- lua/cocos2dx_support/CCLuaEngine.cpp | 2 +- lua/cocos2dx_support/CCLuaEngine.h | 10 +- .../proj.ios/testjs.xcodeproj/project.pbxproj | 863 ++++++++++++++++++ .../project.pbxproj.REMOVED.git-id | 1 - tests/AppDelegate.h | 2 +- .../project.pbxproj.REMOVED.git-id | 2 +- tests/tests/ActionsTest/ActionsTest.cpp | 5 +- tests/tests/Box2DTestBed/GLES-Render.cpp | 3 +- tests/tests/ShaderTest/ShaderTest.cpp | 2 +- 116 files changed, 2652 insertions(+), 296 deletions(-) create mode 100644 HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj delete mode 100644 HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id create mode 100644 HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj delete mode 100644 HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id create mode 100644 cocos2dx/proj.ios/cocos2dx-Prefix.pch create mode 100644 cocos2dx/proj.ios/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id create mode 100644 cocos2dx/proj.ios/cocos2dx/cocos2dx.xcodeproj/project.pbxproj create mode 100644 cocos2dx/proj.ios/cocos2dx/cocos2dx/cocos2dx-Prefix.pch create mode 100644 cocos2dx/proj.ios/cocos2dx/cocos2dx/cocos2dx.h create mode 100644 cocos2dx/proj.ios/cocos2dx/cocos2dx/cocos2dx.m delete mode 100644 cocos2dx/proj.ios/libcocos2dx-Prefix.pch delete mode 100644 cocos2dx/proj.ios/libcocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id create mode 100644 testjs/proj.ios/testjs.xcodeproj/project.pbxproj delete mode 100644 testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id diff --git a/HelloLua/Classes/AppDelegate.cpp b/HelloLua/Classes/AppDelegate.cpp index 9fedb01fd5..1eae5c1570 100644 --- a/HelloLua/Classes/AppDelegate.cpp +++ b/HelloLua/Classes/AppDelegate.cpp @@ -1,7 +1,7 @@ #include "cocos2d.h" #include "AppDelegate.h" #include "SimpleAudioEngine.h" -#include "CCScriptSupport.h" +#include "script_support/CCScriptSupport.h" #include "CCLuaEngine.h" USING_NS_CC; diff --git a/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj b/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..a88bebe6a2 --- /dev/null +++ b/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj @@ -0,0 +1,804 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 45; + objects = { + +/* Begin PBXBuildFile section */ + 159A66601590486A003AEEC0 /* libcocos2dx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 159A665D159047B3003AEEC0 /* libcocos2dx.a */; }; + 15DD6D83156DD1EF003E7567 /* fps_images.png in Resources */ = {isa = PBXBuildFile; fileRef = 15DD6D81156DD1EF003E7567 /* fps_images.png */; }; + 506EDB88102F4C4000A389B3 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 506EDB87102F4C4000A389B3 /* libz.dylib */; }; + 506EDBA5102F4C9F00A389B3 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 506EDBA4102F4C9F00A389B3 /* AVFoundation.framework */; }; + 78947C6D14EBB9B100DBD5A6 /* background.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = 78947C5E14EBB9B000DBD5A6 /* background.mp3 */; }; + 78947C6E14EBB9B100DBD5A6 /* crop.png in Resources */ = {isa = PBXBuildFile; fileRef = 78947C5F14EBB9B000DBD5A6 /* crop.png */; }; + 78947C7014EBB9B100DBD5A6 /* dog.png in Resources */ = {isa = PBXBuildFile; fileRef = 78947C6114EBB9B000DBD5A6 /* dog.png */; }; + 78947C7114EBB9B100DBD5A6 /* effect1.wav in Resources */ = {isa = PBXBuildFile; fileRef = 78947C6214EBB9B000DBD5A6 /* effect1.wav */; }; + 78947C7214EBB9B100DBD5A6 /* farm.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 78947C6314EBB9B000DBD5A6 /* farm.jpg */; }; + 78947C7414EBB9B100DBD5A6 /* hello.lua in Resources */ = {isa = PBXBuildFile; fileRef = 78947C6614EBB9B000DBD5A6 /* hello.lua */; }; + 78947C7514EBB9B100DBD5A6 /* hello2.lua in Resources */ = {isa = PBXBuildFile; fileRef = 78947C6714EBB9B000DBD5A6 /* hello2.lua */; }; + 78947C7714EBB9B100DBD5A6 /* land.png in Resources */ = {isa = PBXBuildFile; fileRef = 78947C6914EBB9B000DBD5A6 /* land.png */; }; + 78947C7814EBB9B100DBD5A6 /* menu1.png in Resources */ = {isa = PBXBuildFile; fileRef = 78947C6A14EBB9B000DBD5A6 /* menu1.png */; }; + 78947C7914EBB9B100DBD5A6 /* menu2.png in Resources */ = {isa = PBXBuildFile; fileRef = 78947C6B14EBB9B000DBD5A6 /* menu2.png */; }; + 78947C8B14EBBB0300DBD5A6 /* CDAudioManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 78947C8214EBBB0300DBD5A6 /* CDAudioManager.m */; }; + 78947C8C14EBBB0300DBD5A6 /* CDOpenALSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = 78947C8514EBBB0300DBD5A6 /* CDOpenALSupport.m */; }; + 78947C8D14EBBB0300DBD5A6 /* CocosDenshion.m in Sources */ = {isa = PBXBuildFile; fileRef = 78947C8714EBBB0300DBD5A6 /* CocosDenshion.m */; }; + 78947C8E14EBBB0300DBD5A6 /* SimpleAudioEngine.mm in Sources */ = {isa = PBXBuildFile; fileRef = 78947C8814EBBB0300DBD5A6 /* SimpleAudioEngine.mm */; }; + 78947C8F14EBBB0300DBD5A6 /* SimpleAudioEngine_objc.m in Sources */ = {isa = PBXBuildFile; fileRef = 78947C8A14EBBB0300DBD5A6 /* SimpleAudioEngine_objc.m */; }; + 78DC4C9A15490B9500317402 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 78DC4C9815490B9500317402 /* Default.png */; }; + 78DC4C9B15490B9500317402 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 78DC4C9915490B9500317402 /* Icon.png */; }; + BF82F41713A864D700616D55 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BF82F41513A864D700616D55 /* AppDelegate.cpp */; }; + BF82F42113A8652A00616D55 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = BF82F41F13A8652A00616D55 /* AppController.mm */; }; + BF82F42213A8652A00616D55 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = BF82F42013A8652A00616D55 /* main.m */; }; + D403B5D9135D1AF1004B518D /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D403B5D8135D1AF1004B518D /* libxml2.dylib */; }; + D4CEAD7913B4634300780515 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = D4CEAD7713B4634300780515 /* RootViewController.mm */; }; + DC6640030F83B3EA000B3E49 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */; }; + DC6640050F83B3EA000B3E49 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DC6640040F83B3EA000B3E49 /* OpenAL.framework */; }; + DCCBF1B70F6022AE0040855A /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCCBF1B60F6022AE0040855A /* CoreGraphics.framework */; }; + DCCBF1B90F6022AE0040855A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCCBF1B80F6022AE0040855A /* Foundation.framework */; }; + DCCBF1BB0F6022AE0040855A /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCCBF1BA0F6022AE0040855A /* OpenGLES.framework */; }; + DCCBF1BD0F6022AE0040855A /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCCBF1BC0F6022AE0040855A /* QuartzCore.framework */; }; + DCCBF1BF0F6022AE0040855A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DCCBF1BE0F6022AE0040855A /* UIKit.framework */; }; + F4808BF414E3CB6C0021A5F8 /* CCLuaEngine.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F48087E114E3CB6A0021A5F8 /* CCLuaEngine.cpp */; }; + F4808BF514E3CB6C0021A5F8 /* Cocos2dxLuaLoader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F48087E314E3CB6A0021A5F8 /* Cocos2dxLuaLoader.cpp */; }; + F4808BF614E3CB6C0021A5F8 /* LuaCocos2d.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F48087E514E3CB6A0021A5F8 /* LuaCocos2d.cpp */; }; + F4808BF714E3CB6C0021A5F8 /* tolua_fix.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087E714E3CB6A0021A5F8 /* tolua_fix.c */; }; + F4808BF814E3CB6C0021A5F8 /* lapi.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087EA14E3CB6A0021A5F8 /* lapi.c */; }; + F4808BF914E3CB6C0021A5F8 /* lauxlib.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087EC14E3CB6A0021A5F8 /* lauxlib.c */; }; + F4808BFA14E3CB6C0021A5F8 /* lbaselib.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087EE14E3CB6A0021A5F8 /* lbaselib.c */; }; + F4808BFB14E3CB6C0021A5F8 /* lcode.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087EF14E3CB6A0021A5F8 /* lcode.c */; }; + F4808BFC14E3CB6C0021A5F8 /* ldblib.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087F114E3CB6A0021A5F8 /* ldblib.c */; }; + F4808BFD14E3CB6C0021A5F8 /* ldebug.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087F214E3CB6A0021A5F8 /* ldebug.c */; }; + F4808BFE14E3CB6C0021A5F8 /* ldo.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087F414E3CB6A0021A5F8 /* ldo.c */; }; + F4808BFF14E3CB6C0021A5F8 /* ldump.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087F614E3CB6A0021A5F8 /* ldump.c */; }; + F4808C0014E3CB6C0021A5F8 /* lfunc.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087F714E3CB6A0021A5F8 /* lfunc.c */; }; + F4808C0114E3CB6C0021A5F8 /* lgc.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087F914E3CB6A0021A5F8 /* lgc.c */; }; + F4808C0214E3CB6C0021A5F8 /* linit.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087FB14E3CB6A0021A5F8 /* linit.c */; }; + F4808C0314E3CB6C0021A5F8 /* liolib.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087FC14E3CB6A0021A5F8 /* liolib.c */; }; + F4808C0414E3CB6C0021A5F8 /* llex.c in Sources */ = {isa = PBXBuildFile; fileRef = F48087FD14E3CB6A0021A5F8 /* llex.c */; }; + F4808C0514E3CB6C0021A5F8 /* lmathlib.c in Sources */ = {isa = PBXBuildFile; fileRef = F480880014E3CB6A0021A5F8 /* lmathlib.c */; }; + F4808C0614E3CB6C0021A5F8 /* lmem.c in Sources */ = {isa = PBXBuildFile; fileRef = F480880114E3CB6A0021A5F8 /* lmem.c */; }; + F4808C0714E3CB6C0021A5F8 /* loadlib.c in Sources */ = {isa = PBXBuildFile; fileRef = F480880314E3CB6A0021A5F8 /* loadlib.c */; }; + F4808C0814E3CB6C0021A5F8 /* lobject.c in Sources */ = {isa = PBXBuildFile; fileRef = F480880414E3CB6A0021A5F8 /* lobject.c */; }; + F4808C0914E3CB6C0021A5F8 /* lopcodes.c in Sources */ = {isa = PBXBuildFile; fileRef = F480880614E3CB6A0021A5F8 /* lopcodes.c */; }; + F4808C0A14E3CB6C0021A5F8 /* loslib.c in Sources */ = {isa = PBXBuildFile; fileRef = F480880814E3CB6A0021A5F8 /* loslib.c */; }; + F4808C0B14E3CB6C0021A5F8 /* lparser.c in Sources */ = {isa = PBXBuildFile; fileRef = F480880914E3CB6A0021A5F8 /* lparser.c */; }; + F4808C0C14E3CB6C0021A5F8 /* lstate.c in Sources */ = {isa = PBXBuildFile; fileRef = F480880B14E3CB6A0021A5F8 /* lstate.c */; }; + F4808C0D14E3CB6C0021A5F8 /* lstring.c in Sources */ = {isa = PBXBuildFile; fileRef = F480880D14E3CB6A0021A5F8 /* lstring.c */; }; + F4808C0E14E3CB6C0021A5F8 /* lstrlib.c in Sources */ = {isa = PBXBuildFile; fileRef = F480880F14E3CB6A0021A5F8 /* lstrlib.c */; }; + F4808C0F14E3CB6C0021A5F8 /* ltable.c in Sources */ = {isa = PBXBuildFile; fileRef = F480881014E3CB6A0021A5F8 /* ltable.c */; }; + F4808C1014E3CB6C0021A5F8 /* ltablib.c in Sources */ = {isa = PBXBuildFile; fileRef = F480881214E3CB6A0021A5F8 /* ltablib.c */; }; + F4808C1114E3CB6C0021A5F8 /* ltm.c in Sources */ = {isa = PBXBuildFile; fileRef = F480881314E3CB6A0021A5F8 /* ltm.c */; }; + F4808C1214E3CB6C0021A5F8 /* lua.c in Sources */ = {isa = PBXBuildFile; fileRef = F480881514E3CB6A0021A5F8 /* lua.c */; }; + F4808C1314E3CB6C0021A5F8 /* lundump.c in Sources */ = {isa = PBXBuildFile; fileRef = F480881914E3CB6A0021A5F8 /* lundump.c */; }; + F4808C1414E3CB6C0021A5F8 /* lvm.c in Sources */ = {isa = PBXBuildFile; fileRef = F480881B14E3CB6A0021A5F8 /* lvm.c */; }; + F4808C1514E3CB6C0021A5F8 /* lzio.c in Sources */ = {isa = PBXBuildFile; fileRef = F480881D14E3CB6A0021A5F8 /* lzio.c */; }; + F4808C1614E3CB6C0021A5F8 /* print.c in Sources */ = {isa = PBXBuildFile; fileRef = F480881F14E3CB6A0021A5F8 /* print.c */; }; + F4808C1D14E3CB6C0021A5F8 /* tolua_event.c in Sources */ = {isa = PBXBuildFile; fileRef = F480882B14E3CB6A0021A5F8 /* tolua_event.c */; }; + F4808C1E14E3CB6C0021A5F8 /* tolua_is.c in Sources */ = {isa = PBXBuildFile; fileRef = F480882D14E3CB6A0021A5F8 /* tolua_is.c */; }; + F4808C1F14E3CB6C0021A5F8 /* tolua_map.c in Sources */ = {isa = PBXBuildFile; fileRef = F480882E14E3CB6A0021A5F8 /* tolua_map.c */; }; + F4808C2014E3CB6C0021A5F8 /* tolua_push.c in Sources */ = {isa = PBXBuildFile; fileRef = F480882F14E3CB6A0021A5F8 /* tolua_push.c */; }; + F4808C2114E3CB6C0021A5F8 /* tolua_to.c in Sources */ = {isa = PBXBuildFile; fileRef = F480883014E3CB6A0021A5F8 /* tolua_to.c */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 159A665C159047B3003AEEC0 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 159A6655159047B3003AEEC0 /* cocos2dx.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 1551A33F158F2AB200E66CFE; + remoteInfo = cocos2dx; + }; + 159A665E15904864003AEEC0 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 159A6655159047B3003AEEC0 /* cocos2dx.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = 1551A33E158F2AB200E66CFE; + remoteInfo = cocos2dx; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 159A6655159047B3003AEEC0 /* cocos2dx.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2dx.xcodeproj; path = ../../cocos2dx/proj.ios/cocos2dx.xcodeproj; sourceTree = ""; }; + 15DD6D81156DD1EF003E7567 /* fps_images.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = fps_images.png; sourceTree = ""; }; + 1D6058910D05DD3D006BFB54 /* HelloLua.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloLua.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 506EDB87102F4C4000A389B3 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; + 506EDBA4102F4C9F00A389B3 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; + 78947C5E14EBB9B000DBD5A6 /* background.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = background.mp3; sourceTree = ""; }; + 78947C5F14EBB9B000DBD5A6 /* crop.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = crop.png; sourceTree = ""; }; + 78947C6114EBB9B000DBD5A6 /* dog.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = dog.png; sourceTree = ""; }; + 78947C6214EBB9B000DBD5A6 /* effect1.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = effect1.wav; sourceTree = ""; }; + 78947C6314EBB9B000DBD5A6 /* farm.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = farm.jpg; sourceTree = ""; }; + 78947C6614EBB9B000DBD5A6 /* hello.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = hello.lua; sourceTree = ""; }; + 78947C6714EBB9B000DBD5A6 /* hello2.lua */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = hello2.lua; sourceTree = ""; }; + 78947C6914EBB9B000DBD5A6 /* land.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = land.png; sourceTree = ""; }; + 78947C6A14EBB9B000DBD5A6 /* menu1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = menu1.png; sourceTree = ""; }; + 78947C6B14EBB9B000DBD5A6 /* menu2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = menu2.png; sourceTree = ""; }; + 78947C8114EBBB0300DBD5A6 /* CDAudioManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDAudioManager.h; sourceTree = ""; }; + 78947C8214EBBB0300DBD5A6 /* CDAudioManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDAudioManager.m; sourceTree = ""; }; + 78947C8314EBBB0300DBD5A6 /* CDConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDConfig.h; sourceTree = ""; }; + 78947C8414EBBB0300DBD5A6 /* CDOpenALSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDOpenALSupport.h; sourceTree = ""; }; + 78947C8514EBBB0300DBD5A6 /* CDOpenALSupport.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDOpenALSupport.m; sourceTree = ""; }; + 78947C8614EBBB0300DBD5A6 /* CocosDenshion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocosDenshion.h; sourceTree = ""; }; + 78947C8714EBBB0300DBD5A6 /* CocosDenshion.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CocosDenshion.m; sourceTree = ""; }; + 78947C8814EBBB0300DBD5A6 /* SimpleAudioEngine.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SimpleAudioEngine.mm; sourceTree = ""; }; + 78947C8914EBBB0300DBD5A6 /* SimpleAudioEngine_objc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleAudioEngine_objc.h; sourceTree = ""; }; + 78947C8A14EBBB0300DBD5A6 /* SimpleAudioEngine_objc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SimpleAudioEngine_objc.m; sourceTree = ""; }; + 78DC4C9815490B9500317402 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = SOURCE_ROOT; }; + 78DC4C9915490B9500317402 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = SOURCE_ROOT; }; + BF82F41513A864D700616D55 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = AppDelegate.cpp; path = ../Classes/AppDelegate.cpp; sourceTree = SOURCE_ROOT; }; + BF82F41613A864D700616D55 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = ../Classes/AppDelegate.h; sourceTree = SOURCE_ROOT; }; + BF82F41E13A8652A00616D55 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = ""; }; + BF82F41F13A8652A00616D55 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = ""; }; + BF82F42013A8652A00616D55 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + BF82F42313A8654600616D55 /* HelloLua_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HelloLua_Prefix.pch; sourceTree = ""; }; + D403B5D8135D1AF1004B518D /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = usr/lib/libxml2.dylib; sourceTree = SDKROOT; }; + D4CEAD7713B4634300780515 /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; + D4CEAD7813B4634300780515 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; + DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; + DC6640040F83B3EA000B3E49 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; + DCCBF1B60F6022AE0040855A /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + DCCBF1B80F6022AE0040855A /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + DCCBF1BA0F6022AE0040855A /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; + DCCBF1BC0F6022AE0040855A /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; + DCCBF1BE0F6022AE0040855A /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + F480877714E3CB6A0021A5F8 /* Export.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Export.h; sourceTree = ""; }; + F480877814E3CB6A0021A5F8 /* SimpleAudioEngine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleAudioEngine.h; sourceTree = ""; }; + F48087E114E3CB6A0021A5F8 /* CCLuaEngine.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCLuaEngine.cpp; sourceTree = ""; }; + F48087E214E3CB6A0021A5F8 /* CCLuaEngine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCLuaEngine.h; sourceTree = ""; }; + F48087E314E3CB6A0021A5F8 /* Cocos2dxLuaLoader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Cocos2dxLuaLoader.cpp; sourceTree = ""; }; + F48087E414E3CB6A0021A5F8 /* Cocos2dxLuaLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Cocos2dxLuaLoader.h; sourceTree = ""; }; + F48087E514E3CB6A0021A5F8 /* LuaCocos2d.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LuaCocos2d.cpp; sourceTree = ""; }; + F48087E614E3CB6A0021A5F8 /* LuaCocos2d.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LuaCocos2d.h; sourceTree = ""; }; + F48087E714E3CB6A0021A5F8 /* tolua_fix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tolua_fix.c; sourceTree = ""; }; + F48087E814E3CB6A0021A5F8 /* tolua_fix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tolua_fix.h; sourceTree = ""; }; + F48087EA14E3CB6A0021A5F8 /* lapi.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lapi.c; sourceTree = ""; }; + F48087EB14E3CB6A0021A5F8 /* lapi.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lapi.h; sourceTree = ""; }; + F48087EC14E3CB6A0021A5F8 /* lauxlib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lauxlib.c; sourceTree = ""; }; + F48087ED14E3CB6A0021A5F8 /* lauxlib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lauxlib.h; sourceTree = ""; }; + F48087EE14E3CB6A0021A5F8 /* lbaselib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lbaselib.c; sourceTree = ""; }; + F48087EF14E3CB6A0021A5F8 /* lcode.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lcode.c; sourceTree = ""; }; + F48087F014E3CB6A0021A5F8 /* lcode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lcode.h; sourceTree = ""; }; + F48087F114E3CB6A0021A5F8 /* ldblib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ldblib.c; sourceTree = ""; }; + F48087F214E3CB6A0021A5F8 /* ldebug.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ldebug.c; sourceTree = ""; }; + F48087F314E3CB6A0021A5F8 /* ldebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ldebug.h; sourceTree = ""; }; + F48087F414E3CB6A0021A5F8 /* ldo.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ldo.c; sourceTree = ""; }; + F48087F514E3CB6A0021A5F8 /* ldo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ldo.h; sourceTree = ""; }; + F48087F614E3CB6A0021A5F8 /* ldump.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ldump.c; sourceTree = ""; }; + F48087F714E3CB6A0021A5F8 /* lfunc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lfunc.c; sourceTree = ""; }; + F48087F814E3CB6A0021A5F8 /* lfunc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lfunc.h; sourceTree = ""; }; + F48087F914E3CB6A0021A5F8 /* lgc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lgc.c; sourceTree = ""; }; + F48087FA14E3CB6A0021A5F8 /* lgc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lgc.h; sourceTree = ""; }; + F48087FB14E3CB6A0021A5F8 /* linit.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = linit.c; sourceTree = ""; }; + F48087FC14E3CB6A0021A5F8 /* liolib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = liolib.c; sourceTree = ""; }; + F48087FD14E3CB6A0021A5F8 /* llex.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = llex.c; sourceTree = ""; }; + F48087FE14E3CB6A0021A5F8 /* llex.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = llex.h; sourceTree = ""; }; + F48087FF14E3CB6A0021A5F8 /* llimits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = llimits.h; sourceTree = ""; }; + F480880014E3CB6A0021A5F8 /* lmathlib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lmathlib.c; sourceTree = ""; }; + F480880114E3CB6A0021A5F8 /* lmem.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lmem.c; sourceTree = ""; }; + F480880214E3CB6A0021A5F8 /* lmem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lmem.h; sourceTree = ""; }; + F480880314E3CB6A0021A5F8 /* loadlib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = loadlib.c; sourceTree = ""; }; + F480880414E3CB6A0021A5F8 /* lobject.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lobject.c; sourceTree = ""; }; + F480880514E3CB6A0021A5F8 /* lobject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lobject.h; sourceTree = ""; }; + F480880614E3CB6A0021A5F8 /* lopcodes.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lopcodes.c; sourceTree = ""; }; + F480880714E3CB6A0021A5F8 /* lopcodes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lopcodes.h; sourceTree = ""; }; + F480880814E3CB6A0021A5F8 /* loslib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = loslib.c; sourceTree = ""; }; + F480880914E3CB6A0021A5F8 /* lparser.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lparser.c; sourceTree = ""; }; + F480880A14E3CB6A0021A5F8 /* lparser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lparser.h; sourceTree = ""; }; + F480880B14E3CB6A0021A5F8 /* lstate.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lstate.c; sourceTree = ""; }; + F480880C14E3CB6A0021A5F8 /* lstate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lstate.h; sourceTree = ""; }; + F480880D14E3CB6A0021A5F8 /* lstring.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lstring.c; sourceTree = ""; }; + F480880E14E3CB6A0021A5F8 /* lstring.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lstring.h; sourceTree = ""; }; + F480880F14E3CB6A0021A5F8 /* lstrlib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lstrlib.c; sourceTree = ""; }; + F480881014E3CB6A0021A5F8 /* ltable.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ltable.c; sourceTree = ""; }; + F480881114E3CB6A0021A5F8 /* ltable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ltable.h; sourceTree = ""; }; + F480881214E3CB6A0021A5F8 /* ltablib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ltablib.c; sourceTree = ""; }; + F480881314E3CB6A0021A5F8 /* ltm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ltm.c; sourceTree = ""; }; + F480881414E3CB6A0021A5F8 /* ltm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ltm.h; sourceTree = ""; }; + F480881514E3CB6A0021A5F8 /* lua.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lua.c; sourceTree = ""; }; + F480881614E3CB6A0021A5F8 /* lua.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lua.h; sourceTree = ""; }; + F480881714E3CB6A0021A5F8 /* luaconf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = luaconf.h; sourceTree = ""; }; + F480881814E3CB6A0021A5F8 /* lualib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lualib.h; sourceTree = ""; }; + F480881914E3CB6A0021A5F8 /* lundump.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lundump.c; sourceTree = ""; }; + F480881A14E3CB6A0021A5F8 /* lundump.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lundump.h; sourceTree = ""; }; + F480881B14E3CB6A0021A5F8 /* lvm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lvm.c; sourceTree = ""; }; + F480881C14E3CB6A0021A5F8 /* lvm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lvm.h; sourceTree = ""; }; + F480881D14E3CB6A0021A5F8 /* lzio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = lzio.c; sourceTree = ""; }; + F480881E14E3CB6A0021A5F8 /* lzio.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = lzio.h; sourceTree = ""; }; + F480881F14E3CB6A0021A5F8 /* print.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = print.c; sourceTree = ""; }; + F480882A14E3CB6A0021A5F8 /* tolua++.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "tolua++.h"; sourceTree = ""; }; + F480882B14E3CB6A0021A5F8 /* tolua_event.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tolua_event.c; sourceTree = ""; }; + F480882C14E3CB6A0021A5F8 /* tolua_event.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = tolua_event.h; sourceTree = ""; }; + F480882D14E3CB6A0021A5F8 /* tolua_is.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tolua_is.c; sourceTree = ""; }; + F480882E14E3CB6A0021A5F8 /* tolua_map.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tolua_map.c; sourceTree = ""; }; + F480882F14E3CB6A0021A5F8 /* tolua_push.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tolua_push.c; sourceTree = ""; }; + F480883014E3CB6A0021A5F8 /* tolua_to.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = tolua_to.c; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 1D60588F0D05DD3D006BFB54 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 159A66601590486A003AEEC0 /* libcocos2dx.a in Frameworks */, + DCCBF1B70F6022AE0040855A /* CoreGraphics.framework in Frameworks */, + DCCBF1B90F6022AE0040855A /* Foundation.framework in Frameworks */, + DCCBF1BB0F6022AE0040855A /* OpenGLES.framework in Frameworks */, + DCCBF1BD0F6022AE0040855A /* QuartzCore.framework in Frameworks */, + DCCBF1BF0F6022AE0040855A /* UIKit.framework in Frameworks */, + DC6640030F83B3EA000B3E49 /* AudioToolbox.framework in Frameworks */, + DC6640050F83B3EA000B3E49 /* OpenAL.framework in Frameworks */, + 506EDB88102F4C4000A389B3 /* libz.dylib in Frameworks */, + 506EDBA5102F4C9F00A389B3 /* AVFoundation.framework in Frameworks */, + D403B5D9135D1AF1004B518D /* libxml2.dylib in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 159A6656159047B3003AEEC0 /* Products */ = { + isa = PBXGroup; + children = ( + 159A665D159047B3003AEEC0 /* libcocos2dx.a */, + ); + name = Products; + sourceTree = ""; + }; + 19C28FACFE9D520D11CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + 1D6058910D05DD3D006BFB54 /* HelloLua.app */, + ); + name = Products; + sourceTree = ""; + }; + 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { + isa = PBXGroup; + children = ( + 159A6655159047B3003AEEC0 /* cocos2dx.xcodeproj */, + 78947C5C14EBB9B000DBD5A6 /* Resources */, + BF82F41413A864B000616D55 /* Classes */, + 506EDAA3102F461B00A389B3 /* libs */, + 29B97315FDCFA39411CA2CEA /* Other Sources */, + 29B97323FDCFA39411CA2CEA /* Frameworks */, + 19C28FACFE9D520D11CA2CBB /* Products */, + ); + name = CustomTemplate; + sourceTree = ""; + }; + 29B97315FDCFA39411CA2CEA /* Other Sources */ = { + isa = PBXGroup; + children = ( + D4CEAD7713B4634300780515 /* RootViewController.mm */, + D4CEAD7813B4634300780515 /* RootViewController.h */, + BF82F42313A8654600616D55 /* HelloLua_Prefix.pch */, + BF82F41E13A8652A00616D55 /* AppController.h */, + BF82F41F13A8652A00616D55 /* AppController.mm */, + BF82F42013A8652A00616D55 /* main.m */, + ); + name = "Other Sources"; + sourceTree = ""; + }; + 29B97323FDCFA39411CA2CEA /* Frameworks */ = { + isa = PBXGroup; + children = ( + DCCBF1B60F6022AE0040855A /* CoreGraphics.framework */, + DCCBF1B80F6022AE0040855A /* Foundation.framework */, + DCCBF1BA0F6022AE0040855A /* OpenGLES.framework */, + DCCBF1BC0F6022AE0040855A /* QuartzCore.framework */, + DCCBF1BE0F6022AE0040855A /* UIKit.framework */, + DC6640040F83B3EA000B3E49 /* OpenAL.framework */, + DC6640020F83B3EA000B3E49 /* AudioToolbox.framework */, + 506EDB87102F4C4000A389B3 /* libz.dylib */, + 506EDBA4102F4C9F00A389B3 /* AVFoundation.framework */, + D403B5D8135D1AF1004B518D /* libxml2.dylib */, + ); + name = Frameworks; + sourceTree = ""; + }; + 506EDAA3102F461B00A389B3 /* libs */ = { + isa = PBXGroup; + children = ( + F480871B14E3CB6A0021A5F8 /* CocosDenshion */, + F48087DF14E3CB6A0021A5F8 /* lua */, + ); + name = libs; + sourceTree = ""; + }; + 78947C5C14EBB9B000DBD5A6 /* Resources */ = { + isa = PBXGroup; + children = ( + 15DD6D81156DD1EF003E7567 /* fps_images.png */, + 78947C5E14EBB9B000DBD5A6 /* background.mp3 */, + 78947C5F14EBB9B000DBD5A6 /* crop.png */, + 78DC4C9815490B9500317402 /* Default.png */, + 78947C6114EBB9B000DBD5A6 /* dog.png */, + 78947C6214EBB9B000DBD5A6 /* effect1.wav */, + 78947C6314EBB9B000DBD5A6 /* farm.jpg */, + 78947C6614EBB9B000DBD5A6 /* hello.lua */, + 78947C6714EBB9B000DBD5A6 /* hello2.lua */, + 78DC4C9915490B9500317402 /* Icon.png */, + 78947C6914EBB9B000DBD5A6 /* land.png */, + 78947C6A14EBB9B000DBD5A6 /* menu1.png */, + 78947C6B14EBB9B000DBD5A6 /* menu2.png */, + ); + name = Resources; + path = ../Resources; + sourceTree = ""; + }; + 78947C8014EBBB0300DBD5A6 /* ios */ = { + isa = PBXGroup; + children = ( + 78947C8114EBBB0300DBD5A6 /* CDAudioManager.h */, + 78947C8214EBBB0300DBD5A6 /* CDAudioManager.m */, + 78947C8314EBBB0300DBD5A6 /* CDConfig.h */, + 78947C8414EBBB0300DBD5A6 /* CDOpenALSupport.h */, + 78947C8514EBBB0300DBD5A6 /* CDOpenALSupport.m */, + 78947C8614EBBB0300DBD5A6 /* CocosDenshion.h */, + 78947C8714EBBB0300DBD5A6 /* CocosDenshion.m */, + 78947C8814EBBB0300DBD5A6 /* SimpleAudioEngine.mm */, + 78947C8914EBBB0300DBD5A6 /* SimpleAudioEngine_objc.h */, + 78947C8A14EBBB0300DBD5A6 /* SimpleAudioEngine_objc.m */, + ); + path = ios; + sourceTree = ""; + }; + BF82F41413A864B000616D55 /* Classes */ = { + isa = PBXGroup; + children = ( + BF82F41513A864D700616D55 /* AppDelegate.cpp */, + BF82F41613A864D700616D55 /* AppDelegate.h */, + ); + name = Classes; + sourceTree = ""; + }; + F480871B14E3CB6A0021A5F8 /* CocosDenshion */ = { + isa = PBXGroup; + children = ( + 78947C8014EBBB0300DBD5A6 /* ios */, + F480877614E3CB6A0021A5F8 /* include */, + ); + name = CocosDenshion; + path = ../../CocosDenshion; + sourceTree = ""; + }; + F480877614E3CB6A0021A5F8 /* include */ = { + isa = PBXGroup; + children = ( + F480877714E3CB6A0021A5F8 /* Export.h */, + F480877814E3CB6A0021A5F8 /* SimpleAudioEngine.h */, + ); + path = include; + sourceTree = ""; + }; + F48087DF14E3CB6A0021A5F8 /* lua */ = { + isa = PBXGroup; + children = ( + F48087E014E3CB6A0021A5F8 /* cocos2dx_support */, + F48087E914E3CB6A0021A5F8 /* lua */, + F480882914E3CB6A0021A5F8 /* tolua */, + ); + name = lua; + path = ../../lua; + sourceTree = ""; + }; + F48087E014E3CB6A0021A5F8 /* cocos2dx_support */ = { + isa = PBXGroup; + children = ( + F48087E114E3CB6A0021A5F8 /* CCLuaEngine.cpp */, + F48087E214E3CB6A0021A5F8 /* CCLuaEngine.h */, + F48087E314E3CB6A0021A5F8 /* Cocos2dxLuaLoader.cpp */, + F48087E414E3CB6A0021A5F8 /* Cocos2dxLuaLoader.h */, + F48087E514E3CB6A0021A5F8 /* LuaCocos2d.cpp */, + F48087E614E3CB6A0021A5F8 /* LuaCocos2d.h */, + F48087E714E3CB6A0021A5F8 /* tolua_fix.c */, + F48087E814E3CB6A0021A5F8 /* tolua_fix.h */, + ); + path = cocos2dx_support; + sourceTree = ""; + }; + F48087E914E3CB6A0021A5F8 /* lua */ = { + isa = PBXGroup; + children = ( + F48087EA14E3CB6A0021A5F8 /* lapi.c */, + F48087EB14E3CB6A0021A5F8 /* lapi.h */, + F48087EC14E3CB6A0021A5F8 /* lauxlib.c */, + F48087ED14E3CB6A0021A5F8 /* lauxlib.h */, + F48087EE14E3CB6A0021A5F8 /* lbaselib.c */, + F48087EF14E3CB6A0021A5F8 /* lcode.c */, + F48087F014E3CB6A0021A5F8 /* lcode.h */, + F48087F114E3CB6A0021A5F8 /* ldblib.c */, + F48087F214E3CB6A0021A5F8 /* ldebug.c */, + F48087F314E3CB6A0021A5F8 /* ldebug.h */, + F48087F414E3CB6A0021A5F8 /* ldo.c */, + F48087F514E3CB6A0021A5F8 /* ldo.h */, + F48087F614E3CB6A0021A5F8 /* ldump.c */, + F48087F714E3CB6A0021A5F8 /* lfunc.c */, + F48087F814E3CB6A0021A5F8 /* lfunc.h */, + F48087F914E3CB6A0021A5F8 /* lgc.c */, + F48087FA14E3CB6A0021A5F8 /* lgc.h */, + F48087FB14E3CB6A0021A5F8 /* linit.c */, + F48087FC14E3CB6A0021A5F8 /* liolib.c */, + F48087FD14E3CB6A0021A5F8 /* llex.c */, + F48087FE14E3CB6A0021A5F8 /* llex.h */, + F48087FF14E3CB6A0021A5F8 /* llimits.h */, + F480880014E3CB6A0021A5F8 /* lmathlib.c */, + F480880114E3CB6A0021A5F8 /* lmem.c */, + F480880214E3CB6A0021A5F8 /* lmem.h */, + F480880314E3CB6A0021A5F8 /* loadlib.c */, + F480880414E3CB6A0021A5F8 /* lobject.c */, + F480880514E3CB6A0021A5F8 /* lobject.h */, + F480880614E3CB6A0021A5F8 /* lopcodes.c */, + F480880714E3CB6A0021A5F8 /* lopcodes.h */, + F480880814E3CB6A0021A5F8 /* loslib.c */, + F480880914E3CB6A0021A5F8 /* lparser.c */, + F480880A14E3CB6A0021A5F8 /* lparser.h */, + F480880B14E3CB6A0021A5F8 /* lstate.c */, + F480880C14E3CB6A0021A5F8 /* lstate.h */, + F480880D14E3CB6A0021A5F8 /* lstring.c */, + F480880E14E3CB6A0021A5F8 /* lstring.h */, + F480880F14E3CB6A0021A5F8 /* lstrlib.c */, + F480881014E3CB6A0021A5F8 /* ltable.c */, + F480881114E3CB6A0021A5F8 /* ltable.h */, + F480881214E3CB6A0021A5F8 /* ltablib.c */, + F480881314E3CB6A0021A5F8 /* ltm.c */, + F480881414E3CB6A0021A5F8 /* ltm.h */, + F480881514E3CB6A0021A5F8 /* lua.c */, + F480881614E3CB6A0021A5F8 /* lua.h */, + F480881714E3CB6A0021A5F8 /* luaconf.h */, + F480881814E3CB6A0021A5F8 /* lualib.h */, + F480881914E3CB6A0021A5F8 /* lundump.c */, + F480881A14E3CB6A0021A5F8 /* lundump.h */, + F480881B14E3CB6A0021A5F8 /* lvm.c */, + F480881C14E3CB6A0021A5F8 /* lvm.h */, + F480881D14E3CB6A0021A5F8 /* lzio.c */, + F480881E14E3CB6A0021A5F8 /* lzio.h */, + F480881F14E3CB6A0021A5F8 /* print.c */, + ); + path = lua; + sourceTree = ""; + }; + F480882914E3CB6A0021A5F8 /* tolua */ = { + isa = PBXGroup; + children = ( + F480882A14E3CB6A0021A5F8 /* tolua++.h */, + F480882B14E3CB6A0021A5F8 /* tolua_event.c */, + F480882C14E3CB6A0021A5F8 /* tolua_event.h */, + F480882D14E3CB6A0021A5F8 /* tolua_is.c */, + F480882E14E3CB6A0021A5F8 /* tolua_map.c */, + F480882F14E3CB6A0021A5F8 /* tolua_push.c */, + F480883014E3CB6A0021A5F8 /* tolua_to.c */, + ); + path = tolua; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 1D6058900D05DD3D006BFB54 /* HelloLua */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "HelloLua" */; + buildPhases = ( + 1D60588D0D05DD3D006BFB54 /* Resources */, + 1D60588E0D05DD3D006BFB54 /* Sources */, + 1D60588F0D05DD3D006BFB54 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + 159A665F15904864003AEEC0 /* PBXTargetDependency */, + ); + name = HelloLua; + productName = HelloLua; + productReference = 1D6058910D05DD3D006BFB54 /* HelloLua.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 29B97313FDCFA39411CA2CEA /* Project object */ = { + isa = PBXProject; + buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HelloLua" */; + compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; + hasScannedForEncodings = 1; + knownRegions = ( + English, + Japanese, + French, + German, + ); + mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; + projectDirPath = ""; + projectReferences = ( + { + ProductGroup = 159A6656159047B3003AEEC0 /* Products */; + ProjectRef = 159A6655159047B3003AEEC0 /* cocos2dx.xcodeproj */; + }, + ); + projectRoot = ""; + targets = ( + 1D6058900D05DD3D006BFB54 /* HelloLua */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXReferenceProxy section */ + 159A665D159047B3003AEEC0 /* libcocos2dx.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libcocos2dx.a; + remoteRef = 159A665C159047B3003AEEC0 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + +/* Begin PBXResourcesBuildPhase section */ + 1D60588D0D05DD3D006BFB54 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 78947C6D14EBB9B100DBD5A6 /* background.mp3 in Resources */, + 78947C6E14EBB9B100DBD5A6 /* crop.png in Resources */, + 78947C7014EBB9B100DBD5A6 /* dog.png in Resources */, + 78947C7114EBB9B100DBD5A6 /* effect1.wav in Resources */, + 78947C7214EBB9B100DBD5A6 /* farm.jpg in Resources */, + 78947C7414EBB9B100DBD5A6 /* hello.lua in Resources */, + 78947C7514EBB9B100DBD5A6 /* hello2.lua in Resources */, + 78947C7714EBB9B100DBD5A6 /* land.png in Resources */, + 78947C7814EBB9B100DBD5A6 /* menu1.png in Resources */, + 78947C7914EBB9B100DBD5A6 /* menu2.png in Resources */, + 78DC4C9A15490B9500317402 /* Default.png in Resources */, + 78DC4C9B15490B9500317402 /* Icon.png in Resources */, + 15DD6D83156DD1EF003E7567 /* fps_images.png in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 1D60588E0D05DD3D006BFB54 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BF82F41713A864D700616D55 /* AppDelegate.cpp in Sources */, + BF82F42113A8652A00616D55 /* AppController.mm in Sources */, + BF82F42213A8652A00616D55 /* main.m in Sources */, + D4CEAD7913B4634300780515 /* RootViewController.mm in Sources */, + F4808BF414E3CB6C0021A5F8 /* CCLuaEngine.cpp in Sources */, + F4808BF514E3CB6C0021A5F8 /* Cocos2dxLuaLoader.cpp in Sources */, + F4808BF614E3CB6C0021A5F8 /* LuaCocos2d.cpp in Sources */, + F4808BF714E3CB6C0021A5F8 /* tolua_fix.c in Sources */, + F4808BF814E3CB6C0021A5F8 /* lapi.c in Sources */, + F4808BF914E3CB6C0021A5F8 /* lauxlib.c in Sources */, + F4808BFA14E3CB6C0021A5F8 /* lbaselib.c in Sources */, + F4808BFB14E3CB6C0021A5F8 /* lcode.c in Sources */, + F4808BFC14E3CB6C0021A5F8 /* ldblib.c in Sources */, + F4808BFD14E3CB6C0021A5F8 /* ldebug.c in Sources */, + F4808BFE14E3CB6C0021A5F8 /* ldo.c in Sources */, + F4808BFF14E3CB6C0021A5F8 /* ldump.c in Sources */, + F4808C0014E3CB6C0021A5F8 /* lfunc.c in Sources */, + F4808C0114E3CB6C0021A5F8 /* lgc.c in Sources */, + F4808C0214E3CB6C0021A5F8 /* linit.c in Sources */, + F4808C0314E3CB6C0021A5F8 /* liolib.c in Sources */, + F4808C0414E3CB6C0021A5F8 /* llex.c in Sources */, + F4808C0514E3CB6C0021A5F8 /* lmathlib.c in Sources */, + F4808C0614E3CB6C0021A5F8 /* lmem.c in Sources */, + F4808C0714E3CB6C0021A5F8 /* loadlib.c in Sources */, + F4808C0814E3CB6C0021A5F8 /* lobject.c in Sources */, + F4808C0914E3CB6C0021A5F8 /* lopcodes.c in Sources */, + F4808C0A14E3CB6C0021A5F8 /* loslib.c in Sources */, + F4808C0B14E3CB6C0021A5F8 /* lparser.c in Sources */, + F4808C0C14E3CB6C0021A5F8 /* lstate.c in Sources */, + F4808C0D14E3CB6C0021A5F8 /* lstring.c in Sources */, + F4808C0E14E3CB6C0021A5F8 /* lstrlib.c in Sources */, + F4808C0F14E3CB6C0021A5F8 /* ltable.c in Sources */, + F4808C1014E3CB6C0021A5F8 /* ltablib.c in Sources */, + F4808C1114E3CB6C0021A5F8 /* ltm.c in Sources */, + F4808C1214E3CB6C0021A5F8 /* lua.c in Sources */, + F4808C1314E3CB6C0021A5F8 /* lundump.c in Sources */, + F4808C1414E3CB6C0021A5F8 /* lvm.c in Sources */, + F4808C1514E3CB6C0021A5F8 /* lzio.c in Sources */, + F4808C1614E3CB6C0021A5F8 /* print.c in Sources */, + F4808C1D14E3CB6C0021A5F8 /* tolua_event.c in Sources */, + F4808C1E14E3CB6C0021A5F8 /* tolua_is.c in Sources */, + F4808C1F14E3CB6C0021A5F8 /* tolua_map.c in Sources */, + F4808C2014E3CB6C0021A5F8 /* tolua_push.c in Sources */, + F4808C2114E3CB6C0021A5F8 /* tolua_to.c in Sources */, + 78947C8B14EBBB0300DBD5A6 /* CDAudioManager.m in Sources */, + 78947C8C14EBBB0300DBD5A6 /* CDOpenALSupport.m in Sources */, + 78947C8D14EBBB0300DBD5A6 /* CocosDenshion.m in Sources */, + 78947C8E14EBBB0300DBD5A6 /* SimpleAudioEngine.mm in Sources */, + 78947C8F14EBBB0300DBD5A6 /* SimpleAudioEngine_objc.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 159A665F15904864003AEEC0 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = cocos2dx; + targetProxy = 159A665E15904864003AEEC0 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 1D6058940D05DD3E006BFB54 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_DYNAMIC_NO_PIC = NO; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + GCC_FAST_OBJC_DISPATCH = YES; + GCC_INLINES_ARE_PRIVATE_EXTERN = NO; + GCC_OBJC_CALL_CXX_CDTORS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = HelloLua_Prefix.pch; + GCC_PREPROCESSOR_DEFINITIONS = ( + USE_FILE32API, + TARGET_OS_IPHONE, + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_TREAT_WARNINGS_AS_ERRORS = NO; + GCC_VERSION = ""; + GCC_WARN_ALLOW_INCOMPLETE_PROTOCOL = NO; + HEADER_SEARCH_PATHS = ( + "\"$(SDKROOT)/usr/include/libxml2/\"", + "\"$(SRCROOT)/../../cocos2dx/\"", + "\"$(SRCROOT)/../../cocos2dx/kazmath/include\"", + "\"$(SRCROOT)/../../lua/tolua\"", + "\"$(SRCROOT)/../../lua/src\"", + "$(SRCROOT)/../../lua/cocos2dx_support", + "$(SRCROOT)/../../cocos2dx/platform/ios", + "$(SRCROOT)/../../cocos2dx/include", + ); + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 5.0; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/../../cocos2dx/platform/third_party/ios/libraries\"", + ); + ONLY_ACTIVE_ARCH = YES; + OTHER_LDFLAGS = ( + "-ObjC", + "-all_load", + ); + PREBINDING = NO; + PRODUCT_NAME = HelloLua; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = NO; + WARNING_CFLAGS = ""; + }; + name = Debug; + }; + 1D6058950D05DD3E006BFB54 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = YES; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + GCC_ENABLE_FIX_AND_CONTINUE = NO; + GCC_FAST_OBJC_DISPATCH = YES; + GCC_INLINES_ARE_PRIVATE_EXTERN = NO; + GCC_OBJC_CALL_CXX_CDTORS = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = HelloLua_Prefix.pch; + GCC_PREPROCESSOR_DEFINITIONS = ( + USE_FILE32API, + TARGET_OS_IPHONE, + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_TREAT_WARNINGS_AS_ERRORS = NO; + GCC_VERSION = ""; + GCC_WARN_ALLOW_INCOMPLETE_PROTOCOL = NO; + HEADER_SEARCH_PATHS = ( + "\"$(SDKROOT)/usr/include/libxml2/\"", + "\"$(SRCROOT)/../../cocos2dx/\"", + "\"$(SRCROOT)/../../cocos2dx/kazmath/include\"", + "\"$(SRCROOT)/../../lua/tolua\"", + "\"$(SRCROOT)/../../lua/src\"", + "$(SRCROOT)/../../lua/cocos2dx_support", + "$(SRCROOT)/../../cocos2dx/platform/ios", + "$(SRCROOT)/../../cocos2dx/include", + ); + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 5.0; + LIBRARY_SEARCH_PATHS = ( + "$(inherited)", + "\"$(SRCROOT)/../../cocos2dx/platform/third_party/ios/libraries\"", + ); + ONLY_ACTIVE_ARCH = NO; + OTHER_LDFLAGS = ( + "-ObjC", + "-all_load", + ); + PREBINDING = NO; + PRODUCT_NAME = HelloLua; + SDKROOT = iphoneos; + SKIP_INSTALL = YES; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = NO; + WARNING_CFLAGS = ""; + }; + name = Release; + }; + C01FCF4F08A954540054247B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_PREPROCESSOR_DEFINITIONS = ( + DEBUG, + "COCOS2D_DEBUG=1", + "CD_DEBUG=1", + ); + "GCC_THUMB_SUPPORT[arch=armv6]" = NO; + "GCC_THUMB_SUPPORT[arch=armv7]" = YES; + GCC_VERSION = ""; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 3.0; + ONLY_ACTIVE_ARCH = YES; + PREBINDING = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALID_ARCHS = "armv6 armv7 i386"; + }; + name = Debug; + }; + C01FCF5008A954540054247B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + GCC_C_LANGUAGE_STANDARD = c99; + "GCC_THUMB_SUPPORT[arch=armv6]" = NO; + "GCC_THUMB_SUPPORT[arch=armv7]" = YES; + GCC_UNROLL_LOOPS = YES; + GCC_VERSION = ""; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 3.0; + PREBINDING = NO; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALID_ARCHS = "armv6 armv7 i386"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "HelloLua" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1D6058940D05DD3E006BFB54 /* Debug */, + 1D6058950D05DD3E006BFB54 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HelloLua" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C01FCF4F08A954540054247B /* Debug */, + C01FCF5008A954540054247B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; +} diff --git a/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id b/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id deleted file mode 100644 index a1877f023a..0000000000 --- a/HelloLua/proj.ios/HelloLua.xcodeproj/project.pbxproj.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -27504f6baf10e5dd447e1b9e149a88b963074dec \ No newline at end of file diff --git a/HelloWorld/Classes/AppDelegate.cpp b/HelloWorld/Classes/AppDelegate.cpp index 875c3da4e4..65e92b315f 100644 --- a/HelloWorld/Classes/AppDelegate.cpp +++ b/HelloWorld/Classes/AppDelegate.cpp @@ -1,10 +1,6 @@ #include "AppDelegate.h" - -#include "cocos2d.h" #include "HelloWorldScene.h" -#include "CCEGLView.h" - USING_NS_CC; AppDelegate::AppDelegate() { diff --git a/HelloWorld/Classes/AppDelegate.h b/HelloWorld/Classes/AppDelegate.h index 76c1c6089f..268c6c6504 100644 --- a/HelloWorld/Classes/AppDelegate.h +++ b/HelloWorld/Classes/AppDelegate.h @@ -1,7 +1,7 @@ #ifndef _APP_DELEGATE_H_ #define _APP_DELEGATE_H_ -#include "CCApplication.h" +#include "cocos2d.h" /** @brief The cocos2d Application. diff --git a/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj b/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..5de2704754 --- /dev/null +++ b/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj @@ -0,0 +1,405 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 45; + objects = { + +/* Begin PBXBuildFile section */ + 1551A89A158F33C400E66CFE /* libcocos2dx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1551A897158F2F7D00E66CFE /* libcocos2dx.a */; }; + 15DD6D7A156DD120003E7567 /* fps_images.png in Resources */ = {isa = PBXBuildFile; fileRef = 15DD6D78156DD120003E7567 /* fps_images.png */; }; + 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; + 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; + 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; }; + 782F4619153FEDF0009FC2E5 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 782F4617153FEDF0009FC2E5 /* Default.png */; }; + 782F461A153FEDF0009FC2E5 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = 782F4618153FEDF0009FC2E5 /* Icon.png */; }; + 784521CE14EBA449009D533B /* CloseNormal.png in Resources */ = {isa = PBXBuildFile; fileRef = 784521C514EBA449009D533B /* CloseNormal.png */; }; + 784521CF14EBA449009D533B /* CloseSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = 784521C614EBA449009D533B /* CloseSelected.png */; }; + 784521D214EBA449009D533B /* HelloWorld.png in Resources */ = {isa = PBXBuildFile; fileRef = 784521CA14EBA449009D533B /* HelloWorld.png */; }; + BF1373EF128A898400D9F789 /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF492D4B1289302400A09262 /* OpenGLES.framework */; }; + BF1373F0128A899500D9F789 /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BF492C21128924A800A09262 /* libxml2.dylib */; }; + BF1373F1128A899E00D9F789 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = BF492B6912891AC600A09262 /* libz.dylib */; }; + BF13742F128A8E6A00D9F789 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BF137426128A8E4600D9F789 /* QuartzCore.framework */; }; + BF23D4E7143315EB00657E08 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BF23D4E3143315EB00657E08 /* AppDelegate.cpp */; }; + BF23D4E8143315EB00657E08 /* HelloWorldScene.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BF23D4E5143315EB00657E08 /* HelloWorldScene.cpp */; }; + BF365AA812A103F70050DCF4 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = BF365AA712A103F70050DCF4 /* AppController.mm */; }; + BF4DE6AD138BB89600CF907D /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = BF4DE6AC138BB89600CF907D /* RootViewController.mm */; }; + D4ABB4B313B4395300552E6E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D4ABB4B213B4395300552E6E /* main.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 1551A896158F2F7D00E66CFE /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1551A88F158F2F7D00E66CFE /* cocos2dx.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 1551A33F158F2AB200E66CFE; + remoteInfo = cocos2dx; + }; + 1551A898158F339F00E66CFE /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 1551A88F158F2F7D00E66CFE /* cocos2dx.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = 1551A33E158F2AB200E66CFE; + remoteInfo = cocos2dx; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 1551A88F158F2F7D00E66CFE /* cocos2dx.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2dx.xcodeproj; path = ../../cocos2dx/proj.ios/cocos2dx.xcodeproj; sourceTree = ""; }; + 15DD6D78156DD120003E7567 /* fps_images.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = fps_images.png; sourceTree = ""; }; + 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 1D6058910D05DD3D006BFB54 /* HelloWorld.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HelloWorld.app; sourceTree = BUILT_PRODUCTS_DIR; }; + 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + 288765A40DF7441C002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + 781C33B11547F06B00633F88 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; + 781C33B31547F06B00633F88 /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; + 781C33B51547F06B00633F88 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; + 782F4617153FEDF0009FC2E5 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = SOURCE_ROOT; }; + 782F4618153FEDF0009FC2E5 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = SOURCE_ROOT; }; + 784521C514EBA449009D533B /* CloseNormal.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = CloseNormal.png; sourceTree = ""; }; + 784521C614EBA449009D533B /* CloseSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = CloseSelected.png; sourceTree = ""; }; + 784521CA14EBA449009D533B /* HelloWorld.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = HelloWorld.png; sourceTree = ""; }; + BF137426128A8E4600D9F789 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; + BF23D4E3143315EB00657E08 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = ""; }; + BF23D4E4143315EB00657E08 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; + BF23D4E5143315EB00657E08 /* HelloWorldScene.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HelloWorldScene.cpp; sourceTree = ""; }; + BF23D4E6143315EB00657E08 /* HelloWorldScene.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HelloWorldScene.h; sourceTree = ""; }; + BF365AA612A103F70050DCF4 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = ""; }; + BF365AA712A103F70050DCF4 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = ""; }; + BF492B6912891AC600A09262 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; + BF492C21128924A800A09262 /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = usr/lib/libxml2.dylib; sourceTree = SDKROOT; }; + BF492D4B1289302400A09262 /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; + BF4DE6AB138BB89600CF907D /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; + BF4DE6AC138BB89600CF907D /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; + D4ABB4B213B4395300552E6E /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 1D60588F0D05DD3D006BFB54 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 1551A89A158F33C400E66CFE /* libcocos2dx.a in Frameworks */, + 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */, + 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */, + 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */, + BF1373EF128A898400D9F789 /* OpenGLES.framework in Frameworks */, + BF1373F0128A899500D9F789 /* libxml2.dylib in Frameworks */, + BF1373F1128A899E00D9F789 /* libz.dylib in Frameworks */, + BF13742F128A8E6A00D9F789 /* QuartzCore.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 1551A890158F2F7D00E66CFE /* Products */ = { + isa = PBXGroup; + children = ( + 1551A897158F2F7D00E66CFE /* libcocos2dx.a */, + ); + name = Products; + sourceTree = ""; + }; + 19C28FACFE9D520D11CA2CBB /* Products */ = { + isa = PBXGroup; + children = ( + 1D6058910D05DD3D006BFB54 /* HelloWorld.app */, + ); + name = Products; + sourceTree = ""; + }; + 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { + isa = PBXGroup; + children = ( + 1551A88F158F2F7D00E66CFE /* cocos2dx.xcodeproj */, + BF23D4E2143315EB00657E08 /* Classes */, + 29B97323FDCFA39411CA2CEA /* Frameworks */, + BF5681CC1313A84D0055EEAC /* ios */, + 19C28FACFE9D520D11CA2CBB /* Products */, + 784521C214EBA449009D533B /* Resources */, + ); + name = CustomTemplate; + sourceTree = ""; + }; + 29B97323FDCFA39411CA2CEA /* Frameworks */ = { + isa = PBXGroup; + children = ( + BF492B6912891AC600A09262 /* libz.dylib */, + BF137426128A8E4600D9F789 /* QuartzCore.framework */, + BF492D4B1289302400A09262 /* OpenGLES.framework */, + BF492C21128924A800A09262 /* libxml2.dylib */, + 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */, + 1D30AB110D05D00D00671497 /* Foundation.framework */, + 288765A40DF7441C002DB57D /* CoreGraphics.framework */, + 781C33B11547F06B00633F88 /* OpenAL.framework */, + 781C33B31547F06B00633F88 /* AudioToolbox.framework */, + 781C33B51547F06B00633F88 /* AVFoundation.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 784521C214EBA449009D533B /* Resources */ = { + isa = PBXGroup; + children = ( + 15DD6D78156DD120003E7567 /* fps_images.png */, + 782F4617153FEDF0009FC2E5 /* Default.png */, + 782F4618153FEDF0009FC2E5 /* Icon.png */, + 784521C514EBA449009D533B /* CloseNormal.png */, + 784521C614EBA449009D533B /* CloseSelected.png */, + 784521CA14EBA449009D533B /* HelloWorld.png */, + ); + name = Resources; + path = ../Resources; + sourceTree = ""; + }; + BF23D4E2143315EB00657E08 /* Classes */ = { + isa = PBXGroup; + children = ( + BF23D4E3143315EB00657E08 /* AppDelegate.cpp */, + BF23D4E4143315EB00657E08 /* AppDelegate.h */, + BF23D4E5143315EB00657E08 /* HelloWorldScene.cpp */, + BF23D4E6143315EB00657E08 /* HelloWorldScene.h */, + ); + name = Classes; + path = ../Classes; + sourceTree = SOURCE_ROOT; + }; + BF5681CC1313A84D0055EEAC /* ios */ = { + isa = PBXGroup; + children = ( + D4ABB4B213B4395300552E6E /* main.m */, + BF365AA612A103F70050DCF4 /* AppController.h */, + BF365AA712A103F70050DCF4 /* AppController.mm */, + BF4DE6AB138BB89600CF907D /* RootViewController.h */, + BF4DE6AC138BB89600CF907D /* RootViewController.mm */, + ); + name = ios; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 1D6058900D05DD3D006BFB54 /* HelloWorld */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "HelloWorld" */; + buildPhases = ( + 1D60588D0D05DD3D006BFB54 /* Resources */, + 1D60588E0D05DD3D006BFB54 /* Sources */, + 1D60588F0D05DD3D006BFB54 /* Frameworks */, + ); + buildRules = ( + ); + dependencies = ( + 1551A899158F339F00E66CFE /* PBXTargetDependency */, + ); + name = HelloWorld; + productName = HelloWorld; + productReference = 1D6058910D05DD3D006BFB54 /* HelloWorld.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 29B97313FDCFA39411CA2CEA /* Project object */ = { + isa = PBXProject; + buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HelloWorld" */; + compatibilityVersion = "Xcode 3.1"; + developmentRegion = English; + hasScannedForEncodings = 1; + knownRegions = ( + English, + Japanese, + French, + German, + ); + mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; + projectDirPath = ""; + projectReferences = ( + { + ProductGroup = 1551A890158F2F7D00E66CFE /* Products */; + ProjectRef = 1551A88F158F2F7D00E66CFE /* cocos2dx.xcodeproj */; + }, + ); + projectRoot = ""; + targets = ( + 1D6058900D05DD3D006BFB54 /* HelloWorld */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXReferenceProxy section */ + 1551A897158F2F7D00E66CFE /* libcocos2dx.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libcocos2dx.a; + remoteRef = 1551A896158F2F7D00E66CFE /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + +/* Begin PBXResourcesBuildPhase section */ + 1D60588D0D05DD3D006BFB54 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 784521CE14EBA449009D533B /* CloseNormal.png in Resources */, + 784521CF14EBA449009D533B /* CloseSelected.png in Resources */, + 784521D214EBA449009D533B /* HelloWorld.png in Resources */, + 782F4619153FEDF0009FC2E5 /* Default.png in Resources */, + 782F461A153FEDF0009FC2E5 /* Icon.png in Resources */, + 15DD6D7A156DD120003E7567 /* fps_images.png in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 1D60588E0D05DD3D006BFB54 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + BF365AA812A103F70050DCF4 /* AppController.mm in Sources */, + BF4DE6AD138BB89600CF907D /* RootViewController.mm in Sources */, + D4ABB4B313B4395300552E6E /* main.m in Sources */, + BF23D4E7143315EB00657E08 /* AppDelegate.cpp in Sources */, + BF23D4E8143315EB00657E08 /* HelloWorldScene.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 1551A899158F339F00E66CFE /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = cocos2dx; + targetProxy = 1551A898158F339F00E66CFE /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + 1D6058940D05DD3E006BFB54 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_INLINES_ARE_PRIVATE_EXTERN = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = HelloWorld_Prefix.pch; + GCC_PREPROCESSOR_DEFINITIONS = ( + USE_FILE32API, + TARGET_OS_IPHONE, + "COCOS2D_DEBUG=1", + ); + GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = ""; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_VERSION = ""; + HEADER_SEARCH_PATHS = ( + "\"$(SDKROOT)/usr/include/libxml2/\"", + "\"$(SRCROOT)/../../cocos2dx/include\"", + "\"$(SRCROOT)/../../cocos2dx\"", + "\"$(SRCROOT)/../../cocos2dx/platform/ios\"", + "\"$(SRCROOT)/../../cocos2dx/kazmath/include\"", + ); + INFOPLIST_FILE = "HelloWorld-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 4.0; + PRODUCT_NAME = HelloWorld; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALID_ARCHS = "armv6 armv7 i386"; + }; + name = Debug; + }; + 1D6058950D05DD3E006BFB54 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + COPY_PHASE_STRIP = YES; + GCC_INLINES_ARE_PRIVATE_EXTERN = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = HelloWorld_Prefix.pch; + GCC_PREPROCESSOR_DEFINITIONS = ( + USE_FILE32API, + TARGET_OS_IPHONE, + ); + GCC_PREPROCESSOR_DEFINITIONS_NOT_USED_IN_PRECOMPS = ""; + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_VERSION = ""; + HEADER_SEARCH_PATHS = ( + "\"$(SDKROOT)/usr/include/libxml2/\"", + "\"$(SRCROOT)/../../cocos2dx/include\"", + "\"$(SRCROOT)/../../cocos2dx\"", + "\"$(SRCROOT)/../../cocos2dx/platform/ios\"", + "\"$(SRCROOT)/../../cocos2dx/kazmath/include\"", + ); + INFOPLIST_FILE = "HelloWorld-Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 4.0; + PRODUCT_NAME = HelloWorld; + SDKROOT = iphoneos; + TARGETED_DEVICE_FAMILY = "1,2"; + VALIDATE_PRODUCT = YES; + VALID_ARCHS = "armv6 armv7 i386"; + }; + name = Release; + }; + C01FCF4F08A954540054247B /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_VERSION = ""; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + PREBINDING = NO; + SDKROOT = iphoneos; + VALID_ARCHS = "armv6 armv7 i386"; + }; + name = Debug; + }; + C01FCF5008A954540054247B /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + GCC_C_LANGUAGE_STANDARD = c99; + GCC_VERSION = ""; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; + PREBINDING = NO; + SDKROOT = iphoneos; + VALID_ARCHS = "armv6 armv7 i386"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "HelloWorld" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1D6058940D05DD3E006BFB54 /* Debug */, + 1D6058950D05DD3E006BFB54 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + C01FCF4E08A954540054247B /* Build configuration list for PBXProject "HelloWorld" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + C01FCF4F08A954540054247B /* Debug */, + C01FCF5008A954540054247B /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; +} diff --git a/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id b/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id deleted file mode 100644 index e2ea9875ed..0000000000 --- a/HelloWorld/proj.ios/HelloWorld.xcodeproj/project.pbxproj.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -f4f9e78d583a826744b48fcc5ca3103438b744cf \ No newline at end of file diff --git a/cocos2dx/CCCamera.h b/cocos2dx/CCCamera.h index a454320eed..b5d4858eed 100644 --- a/cocos2dx/CCCamera.h +++ b/cocos2dx/CCCamera.h @@ -27,10 +27,10 @@ THE SOFTWARE. #ifndef __CCCAMERA_H__ #define __CCCAMERA_H__ -#include "CCObject.h" +#include "cocoa/CCObject.h" #include "ccMacros.h" -#include #include "kazmath/mat4.h" +#include NS_CC_BEGIN diff --git a/cocos2dx/CCConfiguration.h b/cocos2dx/CCConfiguration.h index 56199a52be..9d94e606e4 100644 --- a/cocos2dx/CCConfiguration.h +++ b/cocos2dx/CCConfiguration.h @@ -26,9 +26,9 @@ THE SOFTWARE. #ifndef __CCCONFIGURATION_H__ #define __CCCONFIGURATION_H__ -#include "CCObject.h" -#include +#include "cocoa/CCObject.h" #include "CCGL.h" +#include NS_CC_BEGIN diff --git a/cocos2dx/CCDirector.h b/cocos2dx/CCDirector.h index ae1ba7f003..62e341b06a 100644 --- a/cocos2dx/CCDirector.h +++ b/cocos2dx/CCDirector.h @@ -27,11 +27,11 @@ THE SOFTWARE. #ifndef __CCDIRECTOR_H__ #define __CCDIRECTOR_H__ -#include "CCPlatformMacros.h" -#include "CCObject.h" +#include "platform/CCPlatformMacros.h" +#include "cocoa/CCObject.h" #include "ccTypes.h" -#include "CCGeometry.h" -#include "CCArray.h" +#include "cocoa/CCGeometry.h" +#include "cocoa/CCArray.h" #include "CCGL.h" #include "kazmath/mat4.h" diff --git a/cocos2dx/CCDrawingPrimitives.h b/cocos2dx/CCDrawingPrimitives.h index 71883bae07..55c1845ec4 100644 --- a/cocos2dx/CCDrawingPrimitives.h +++ b/cocos2dx/CCDrawingPrimitives.h @@ -45,7 +45,7 @@ THE SOFTWARE. */ #include "ccTypes.h" #include "ccMacros.h" -#include "CCGeometry.h" // for CCPoint +#include "cocoa/CCGeometry.h" // for CCPoint NS_CC_BEGIN diff --git a/cocos2dx/CCScheduler.h b/cocos2dx/CCScheduler.h index 327892becf..d70184e95e 100644 --- a/cocos2dx/CCScheduler.h +++ b/cocos2dx/CCScheduler.h @@ -27,7 +27,7 @@ THE SOFTWARE. #ifndef __CCSCHEDULER_H__ #define __CCSCHEDULER_H__ -#include "CCObject.h" +#include "cocoa/CCObject.h" #include "support/data_support/uthash.h" NS_CC_BEGIN diff --git a/cocos2dx/actions/CCAction.h b/cocos2dx/actions/CCAction.h index cc0fcf1362..d51d0a075f 100644 --- a/cocos2dx/actions/CCAction.h +++ b/cocos2dx/actions/CCAction.h @@ -27,8 +27,9 @@ THE SOFTWARE. #ifndef __ACTIONS_CCACTION_H__ #define __ACTIONS_CCACTION_H__ -#include "CCObject.h" -#include "CCGeometry.h" +#include "cocoa/CCObject.h" +#include "cocoa/CCGeometry.h" +#include "platform/CCPlatformMacros.h" NS_CC_BEGIN diff --git a/cocos2dx/actions/CCActionCatmullRom.h b/cocos2dx/actions/CCActionCatmullRom.h index 1477e468ef..4f6fd87c3e 100644 --- a/cocos2dx/actions/CCActionCatmullRom.h +++ b/cocos2dx/actions/CCActionCatmullRom.h @@ -38,8 +38,8 @@ #define __CCACTION_CATMULLROM_H__ #include "CCActionInterval.h" -#include "CCNode.h" -#include "CCGeometry.h" +#include "base_nodes/CCNode.h" +#include "cocoa/CCGeometry.h" NS_CC_BEGIN; diff --git a/cocos2dx/actions/CCActionInterval.h b/cocos2dx/actions/CCActionInterval.h index 399976941c..78b56db756 100644 --- a/cocos2dx/actions/CCActionInterval.h +++ b/cocos2dx/actions/CCActionInterval.h @@ -27,11 +27,11 @@ THE SOFTWARE. #ifndef __ACTION_CCINTERVAL_ACTION_H__ #define __ACTION_CCINTERVAL_ACTION_H__ -#include "CCNode.h" +#include "base_nodes/CCNode.h" #include "CCAction.h" #include "CCProtocols.h" -#include "CCSpriteFrame.h" -#include "CCAnimation.h" +#include "sprite_nodes/CCSpriteFrame.h" +#include "sprite_nodes/CCAnimation.h" #include NS_CC_BEGIN diff --git a/cocos2dx/actions/CCActionManager.h b/cocos2dx/actions/CCActionManager.h index 60cddaaaf1..8e10821d15 100644 --- a/cocos2dx/actions/CCActionManager.h +++ b/cocos2dx/actions/CCActionManager.h @@ -29,8 +29,8 @@ THE SOFTWARE. #define __ACTION_CCACTION_MANAGER_H__ #include "CCAction.h" -#include "CCArray.h" -#include "CCObject.h" +#include "cocoa/CCArray.h" +#include "cocoa/CCObject.h" NS_CC_BEGIN diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index 317c52adfb..445df6d477 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -29,11 +29,11 @@ #define __PLATFOMR_CCNODE_H__ #include "ccMacros.h" -#include "CCAffineTransform.h" -#include "CCArray.h" +#include "cocoa/CCAffineTransform.h" +#include "cocoa/CCArray.h" #include "CCGL.h" -#include "ccGLStateCache.h" -#include "CCGLProgram.h" +#include "shaders/ccGLStateCache.h" +#include "shaders/CCGLProgram.h" #include "kazmath/kazmath.h" NS_CC_BEGIN diff --git a/cocos2dx/cocoa/CCAffineTransform.h b/cocos2dx/cocoa/CCAffineTransform.h index 09ec21c94f..4bb5775950 100644 --- a/cocos2dx/cocoa/CCAffineTransform.h +++ b/cocos2dx/cocoa/CCAffineTransform.h @@ -26,7 +26,7 @@ THE SOFTWARE. #define __COCOA_CGAFFINETRANSFORM_H__ #include "CCGeometry.h" -#include "CCPlatformMacros.h" +#include "platform/CCPlatformMacros.h" NS_CC_BEGIN diff --git a/cocos2dx/cocoa/CCGeometry.h b/cocos2dx/cocoa/CCGeometry.h index 5781813b14..6be663ba6b 100644 --- a/cocos2dx/cocoa/CCGeometry.h +++ b/cocos2dx/cocoa/CCGeometry.h @@ -25,7 +25,7 @@ THE SOFTWARE. #ifndef __CCGEMETRY_H__ #define __CCGEMETRY_H__ -#include "CCPlatformMacros.h" +#include "platform/CCPlatformMacros.h" #include "CCObject.h" NS_CC_BEGIN diff --git a/cocos2dx/cocoa/CCObject.h b/cocos2dx/cocoa/CCObject.h index ef3c2d45e9..564e16ac16 100644 --- a/cocos2dx/cocoa/CCObject.h +++ b/cocos2dx/cocoa/CCObject.h @@ -25,7 +25,7 @@ THE SOFTWARE. #ifndef __CCOBJECT_H__ #define __CCOBJECT_H__ -#include "CCPlatformMacros.h" +#include "platform/CCPlatformMacros.h" NS_CC_BEGIN diff --git a/cocos2dx/cocoa/CCZone.h b/cocos2dx/cocoa/CCZone.h index aa9460a4ea..e18496c0a2 100644 --- a/cocos2dx/cocoa/CCZone.h +++ b/cocos2dx/cocoa/CCZone.h @@ -25,8 +25,8 @@ THE SOFTWARE. #ifndef __CC_ZONE_H__ #define __CC_ZONE_H__ +#include "platform/CCPlatformMacros.h" #include -#include "CCPlatformMacros.h" NS_CC_BEGIN diff --git a/cocos2dx/effects/CCGrabber.h b/cocos2dx/effects/CCGrabber.h index be51d4afee..cb22892d3a 100644 --- a/cocos2dx/effects/CCGrabber.h +++ b/cocos2dx/effects/CCGrabber.h @@ -26,7 +26,7 @@ THE SOFTWARE. #define __EFFECTS_CCGRABBER_H__ #include "CCConfiguration.h" -#include "CCObject.h" +#include "cocoa/CCObject.h" #include "CCGL.h" NS_CC_BEGIN diff --git a/cocos2dx/effects/CCGrid.h b/cocos2dx/effects/CCGrid.h index 24946cc215..fd4b645113 100644 --- a/cocos2dx/effects/CCGrid.h +++ b/cocos2dx/effects/CCGrid.h @@ -25,11 +25,11 @@ THE SOFTWARE. #ifndef __EFFECTS_CCGRID_H__ #define __EFFECTS_CCGRID_H__ -#include "CCObject.h" -#include "CCNode.h" +#include "cocoa/CCObject.h" +#include "base_nodes/CCNode.h" #include "CCCamera.h" #include "ccTypes.h" -#include "CCTexture2D.h" +#include "textures/CCTexture2D.h" #include "CCDirector.h" #include "kazmath/mat4.h" diff --git a/cocos2dx/extensions/CCControlExtension/CCControl.h b/cocos2dx/extensions/CCControlExtension/CCControl.h index 65705c269e..9eab3048cd 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControl.h +++ b/cocos2dx/extensions/CCControlExtension/CCControl.h @@ -31,7 +31,7 @@ #include "CCInvocation.h" #include "CCControlUtils.h" -#include "CCLayer.h" +#include "layers_scenes_transitions_nodes/CCLayer.h" NS_CC_EXT_BEGIN diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSlider.h b/cocos2dx/extensions/CCControlExtension/CCControlSlider.h index 59db5356c2..58eb60fc39 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSlider.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlSlider.h @@ -31,8 +31,8 @@ #include "CCControl.h" #include "CCInvocation.h" -#include "CCSprite.h" -#include "CCMenuItem.h" +#include "sprite_nodes/CCSprite.h" +#include "menu_nodes/CCMenuItem.h" #define SLIDER_MARGIN_H 24 #define SLIDER_MARGIN_V 8 diff --git a/cocos2dx/extensions/CCControlExtension/CCControlUtils.h b/cocos2dx/extensions/CCControlExtension/CCControlUtils.h index 6bea70c9a8..e8c765a71c 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlUtils.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlUtils.h @@ -32,7 +32,7 @@ #ifndef __CCCONTROL_UTILS_H__ #define __CCCONTROL_UTILS_H__ -#include "CCSprite.h" +#include "sprite_nodes/CCSprite.h" NS_CC_EXT_BEGIN diff --git a/cocos2dx/extensions/CCControlExtension/CCInvocation.h b/cocos2dx/extensions/CCControlExtension/CCInvocation.h index 8c9c7482b8..535ef70546 100644 --- a/cocos2dx/extensions/CCControlExtension/CCInvocation.h +++ b/cocos2dx/extensions/CCControlExtension/CCInvocation.h @@ -5,7 +5,7 @@ #ifndef __CCINVOCATION_H__ #define __CCINVOCATION_H__ -#include "CCObject.h" +#include "cocoa/CCObject.h" NS_CC_EXT_BEGIN diff --git a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h index 0e1a5a8c93..b454a12515 100644 --- a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h +++ b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h @@ -9,7 +9,7 @@ #ifndef __CCScale9Sprite_H__ #define __CCScale9Sprite_H__ -#include "CCNode.h" +#include "base_nodes/CCNode.h" #include "CCProtocols.h" diff --git a/cocos2dx/extensions/CCControlExtension/CCSpacer.h b/cocos2dx/extensions/CCControlExtension/CCSpacer.h index 7dbe4e6b16..7384395f7f 100644 --- a/cocos2dx/extensions/CCControlExtension/CCSpacer.h +++ b/cocos2dx/extensions/CCControlExtension/CCSpacer.h @@ -1,7 +1,7 @@ #ifndef __CCSPACER_H__ #define __CCSPACER_H__ -#include "CCLayer.h" +#include "layers_scenes_transitions_nodes/CCLayer.h" NS_CC_EXT_BEGIN diff --git a/cocos2dx/extensions/CCListView/CCListView.h b/cocos2dx/extensions/CCListView/CCListView.h index 7f00ef93db..7b848697fc 100644 --- a/cocos2dx/extensions/CCListView/CCListView.h +++ b/cocos2dx/extensions/CCListView/CCListView.h @@ -26,12 +26,12 @@ THE SOFTWARE. #ifndef __CC_LIST_VIEW_H__ #define __CC_LIST_VIEW_H__ -#include -#include "platform.h" -#include -#include -//#include "../lua/cocos2dx_support/CCLuaEngine.h" + +#include "platform/platform.h" #include "CCListViewCell.h" +#include +#include +#include NS_CC_EXT_BEGIN diff --git a/cocos2dx/extensions/CCListView/CCListViewCell.h b/cocos2dx/extensions/CCListView/CCListViewCell.h index 459c026874..21eefb39c5 100644 --- a/cocos2dx/extensions/CCListView/CCListViewCell.h +++ b/cocos2dx/extensions/CCListView/CCListViewCell.h @@ -27,7 +27,7 @@ THE SOFTWARE. #define __CC_LIST_VIEW_CELL_H_ #include "CCControlDefine.h" -#include "CCLayer.h" +#include "layers_scenes_transitions_nodes/CCLayer.h" NS_CC_EXT_BEGIN diff --git a/cocos2dx/extensions/CCNotificationCenter/CCNotificationCenter.h b/cocos2dx/extensions/CCNotificationCenter/CCNotificationCenter.h index 24965cab6f..0ea1d3a30b 100644 --- a/cocos2dx/extensions/CCNotificationCenter/CCNotificationCenter.h +++ b/cocos2dx/extensions/CCNotificationCenter/CCNotificationCenter.h @@ -25,7 +25,7 @@ THE SOFTWARE. #ifndef __CCNOTIFICATIONCENTER_H__ #define __CCNOTIFICATIONCENTER_H__ -#include "CCObject.h" +#include "cocoa/CCObject.h" namespace cocos2d { class CCArray; } diff --git a/cocos2dx/include/CCProtocols.h b/cocos2dx/include/CCProtocols.h index 476697a61a..2dd5c0b87f 100755 --- a/cocos2dx/include/CCProtocols.h +++ b/cocos2dx/include/CCProtocols.h @@ -27,7 +27,7 @@ THE SOFTWARE. #define __CCPROTOCOLS_H__ #include "ccTypes.h" -#include "CCTexture2D.h" +#include "textures/CCTexture2D.h" #include NS_CC_BEGIN diff --git a/cocos2dx/include/ccConfig.h b/cocos2dx/include/ccConfig.h index b1eead860b..e51a21809a 100755 --- a/cocos2dx/include/ccConfig.h +++ b/cocos2dx/include/ccConfig.h @@ -27,7 +27,7 @@ THE SOFTWARE. #ifndef __CCCONFIG_H__ #define __CCCONFIG_H__ -#include "CCPlatformConfig.h" +#include "platform/CCPlatformConfig.h" /** @file diff --git a/cocos2dx/include/ccMacros.h b/cocos2dx/include/ccMacros.h index 46245f6592..49252d46bb 100644 --- a/cocos2dx/include/ccMacros.h +++ b/cocos2dx/include/ccMacros.h @@ -31,7 +31,7 @@ THE SOFTWARE. #define _USE_MATH_DEFINES #endif -#include "CCCommon.h" +#include "platform/CCCommon.h" #include "CCStdC.h" #ifndef CCAssert diff --git a/cocos2dx/include/ccTypes.h b/cocos2dx/include/ccTypes.h index de685fb319..15d9704f1a 100755 --- a/cocos2dx/include/ccTypes.h +++ b/cocos2dx/include/ccTypes.h @@ -27,7 +27,7 @@ THE SOFTWARE. #ifndef __CCTYPES_H__ #define __CCTYPES_H__ -#include "CCGeometry.h" +#include "cocoa/CCGeometry.h" #include "CCGL.h" NS_CC_BEGIN diff --git a/cocos2dx/include/cocos2d.h b/cocos2dx/include/cocos2d.h index a708e7c56c..3ece330dc9 100755 --- a/cocos2dx/include/cocos2d.h +++ b/cocos2dx/include/cocos2d.h @@ -38,39 +38,40 @@ THE SOFTWARE. #include "ccConfig.h" // actions -#include "CCAction.h" -#include "CCActionInterval.h" -#include "CCActionCamera.h" -#include "CCActionManager.h" -#include "CCActionEase.h" -#include "CCActionPageTurn3D.h" -#include "CCActionGrid.h" -#include "CCActionProgressTimer.h" -#include "CCActionGrid3D.h" -#include "CCActionTiledGrid.h" -#include "CCActionInstant.h" -#include "CCActionTween.h" +#include "actions/CCAction.h" +#include "actions/CCActionInterval.h" +#include "actions/CCActionCamera.h" +#include "actions/CCActionManager.h" +#include "actions/CCActionEase.h" +#include "actions/CCActionPageTurn3D.h" +#include "actions/CCActionGrid.h" +#include "actions/CCActionProgressTimer.h" +#include "actions/CCActionGrid3D.h" +#include "actions/CCActionTiledGrid.h" +#include "actions/CCActionInstant.h" +#include "actions/CCActionTween.h" +#include "actions/CCActionCatmullRom.h" // base_nodes -#include "CCNode.h" -#include "CCAtlasNode.h" +#include "base_nodes/CCNode.h" +#include "base_nodes/CCAtlasNode.h" // cocoa -#include "CCAffineTransform.h" -#include "CCDictionary.h" -#include "CCObject.h" -#include "CCArray.h" -#include "CCGeometry.h" -#include "CCSet.h" -#include "CCAutoreleasePool.h" -#include "CCInteger.h" -#include "CCString.h" -#include "CCNS.h" -#include "CCZone.h" +#include "cocoa/CCAffineTransform.h" +#include "cocoa/CCDictionary.h" +#include "cocoa/CCObject.h" +#include "cocoa/CCArray.h" +#include "cocoa/CCGeometry.h" +#include "cocoa/CCSet.h" +#include "cocoa/CCAutoreleasePool.h" +#include "cocoa/CCInteger.h" +#include "cocoa/CCString.h" +#include "cocoa/CCNS.h" +#include "cocoa/CCZone.h" // effects -#include "CCGrabber.h" -#include "CCGrid.h" +#include "effects/CCGrabber.h" +#include "effects/CCGrid.h" // include #include "CCEventType.h" @@ -81,100 +82,123 @@ THE SOFTWARE. #include "cocos2dExt.h" // kazmath -#include "kazmath/kazmath.h" -#include "kazmath/GL/matrix.h" +#include "kazmath/include/kazmath/kazmath.h" +#include "kazmath/include/kazmath/GL/matrix.h" // keypad_dispatcher -#include "CCKeypadDelegate.h" -#include "CCKeypadDispatcher.h" +#include "keypad_dispatcher/CCKeypadDelegate.h" +#include "keypad_dispatcher/CCKeypadDispatcher.h" // label_nodes -#include "CCLabelAtlas.h" -#include "CCLabelTTF.h" -#include "CCLabelBMFont.h" +#include "label_nodes/CCLabelAtlas.h" +#include "label_nodes/CCLabelTTF.h" +#include "label_nodes/CCLabelBMFont.h" // layers_scenes_transitions_nodes -#include "CCLayer.h" -#include "CCScene.h" -#include "CCTransition.h" -#include "CCTransitionPageTurn.h" -#include "CCTransitionProgress.h" +#include "layers_scenes_transitions_nodes/CCLayer.h" +#include "layers_scenes_transitions_nodes/CCScene.h" +#include "layers_scenes_transitions_nodes/CCTransition.h" +#include "layers_scenes_transitions_nodes/CCTransitionPageTurn.h" +#include "layers_scenes_transitions_nodes/CCTransitionProgress.h" // menu_nodes -#include "CCMenu.h" -#include "CCMenuItem.h" +#include "menu_nodes/CCMenu.h" +#include "menu_nodes/CCMenuItem.h" // misc_nodes -#include "CCMotionStreak.h" -#include "CCProgressTimer.h" -#include "CCRenderTexture.h" +#include "misc_nodes/CCMotionStreak.h" +#include "misc_nodes/CCProgressTimer.h" +#include "misc_nodes/CCRenderTexture.h" // particle_nodes -#include "CCParticleBatchNode.h" -#include "CCParticleSystem.h" -#include "CCParticleExamples.h" -#include "CCParticleSystemQuad.h" +#include "particle_nodes/CCParticleBatchNode.h" +#include "particle_nodes/CCParticleSystem.h" +#include "particle_nodes/CCParticleExamples.h" +#include "particle_nodes/CCParticleSystemQuad.h" // platform -#include "CCAccelerometer.h" -#include "CCApplication.h" -#include "CCEGLView.h" -#include "CCGL.h" -#include "CCCommon.h" -#include "CCFileUtils.h" -#include "CCImage.h" -#include "CCSAXParser.h" -#include "CCStdC.h" -#include "CCThread.h" -#include "platform.h" + +#include "platform/CCCommon.h" +#include "platform/CCFileUtils.h" +#include "platform/CCImage.h" +#include "platform/CCSAXParser.h" +#include "platform/CCThread.h" +#include "platform/platform.h" +#include "platform/CCPlatformConfig.h" +#include "platform/CCPlatformMacros.h" + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + #include "platform/ios/CCAccelerometer.h" + #include "platform/ios/CCApplication.h" + #include "platform/ios/CCEGLView.h" + #include "platform/ios/CCGL.h" + #include "platform/ios/CCStdC.h" +#endif // CC_TARGET_PLATFORM == CC_PLATFORM_IOS + +#if (CC_TARGET_PLATFROM == CC_PLATFORM_ANDROID) + #include "platform/android/CCAccelerometer.h" + #include "platform/android/CCApplication.h" + #include "platform/android/CCEGLView.h" + #include "platform/android/CCGL.h" + #include "platform/android/CCStdC.h" +#endif // CC_TARGET_PLATFROM == CC_PLATFORM_ANDROID + +#if (CC_TARGET_PLATFROM == CC_PLATFORM_WIN32) +#include "platform/win32/CCAccelerometer.h" +#include "platform/win32/CCApplication.h" +#include "platform/win32/CCEGLView.h" +#include "platform/win32/CCGL.h" +#include "platform/win32/CCStdC.h" +#endif // CC_TARGET_PLATFROM == CC_PLATFORM_WIN32 + // script_support -#include "CCScriptSupport.h" +#include "script_support/CCScriptSupport.h" // shaders -#include "CCGLProgram.h" -#include "ccGLStateCache.h" -#include "CCShaderCache.h" -#include "ccShaders.h" +#include "shaders/CCGLProgram.h" +#include "shaders/ccGLStateCache.h" +#include "shaders/CCShaderCache.h" +#include "shaders/ccShaders.h" // sprite_nodes -#include "CCAnimation.h" -#include "CCAnimationCache.h" -#include "CCSprite.h" -#include "CCSpriteBatchNode.h" -#include "CCSpriteFrame.h" -#include "CCSpriteFrameCache.h" +#include "sprite_nodes/CCAnimation.h" +#include "sprite_nodes/CCAnimationCache.h" +#include "sprite_nodes/CCSprite.h" +#include "sprite_nodes/CCSpriteBatchNode.h" +#include "sprite_nodes/CCSpriteFrame.h" +#include "sprite_nodes/CCSpriteFrameCache.h" // support -#include "CCPointExtension.h" -#include "CCProfiling.h" -#include "CCUserDefault.h" -#include "CCVertex.h" +#include "support/CCPointExtension.h" +#include "support/CCProfiling.h" +#include "support/CCUserDefault.h" +#include "support/CCVertex.h" // text_input_node -#include "CCIMEDelegate.h" -#include "CCIMEDispatcher.h" -#include "CCTextFieldTTF.h" +#include "text_input_node/CCIMEDelegate.h" +#include "text_input_node/CCIMEDispatcher.h" +#include "text_input_node/CCTextFieldTTF.h" // textures -#include "CCTexture2D.h" -#include "CCTextureAtlas.h" -#include "CCTextureCache.h" -#include "CCTexturePVR.h" +#include "textures/CCTexture2D.h" +#include "textures/CCTextureAtlas.h" +#include "textures/CCTextureCache.h" +#include "textures/CCTexturePVR.h" // tileMap_parallax_nodes -#include "CCParallaxNode.h" -#include "CCTMXLayer.h" -#include "CCTMXObjectGroup.h" -#include "CCTMXTiledMap.h" -#include "CCTMXXMLParser.h" -#include "CCTileMapAtlas.h" +#include "tileMap_parallax_nodes/CCParallaxNode.h" +#include "tileMap_parallax_nodes/CCTMXLayer.h" +#include "tileMap_parallax_nodes/CCTMXObjectGroup.h" +#include "tileMap_parallax_nodes/CCTMXTiledMap.h" +#include "tileMap_parallax_nodes/CCTMXXMLParser.h" +#include "tileMap_parallax_nodes/CCTileMapAtlas.h" // touch_dispatcher -#include "CCTouch.h" -#include "CCTouchDelegateProtocol.h" -#include "CCTouchDispatcher.h" -#include "CCTouchHandler.h" +#include "touch_dispatcher/CCTouch.h" +#include "touch_dispatcher/CCTouchDelegateProtocol.h" +#include "touch_dispatcher/CCTouchDispatcher.h" +#include "touch_dispatcher/CCTouchHandler.h" // root #include "CCCamera.h" diff --git a/cocos2dx/kazmath/include/kazmath/GL/matrix.h b/cocos2dx/kazmath/include/kazmath/GL/matrix.h index 8b624a9868..a1c95f8bf9 100644 --- a/cocos2dx/kazmath/include/kazmath/GL/matrix.h +++ b/cocos2dx/kazmath/include/kazmath/GL/matrix.h @@ -26,7 +26,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef KM_GL_MATRIX_H_INCLUDED #define KM_GL_MATRIX_H_INCLUDED -#include "CCPlatformMacros.h" +#include "platform/CCPlatformMacros.h" #define KM_GL_MODELVIEW 0x1700 #define KM_GL_PROJECTION 0x1701 diff --git a/cocos2dx/kazmath/include/kazmath/aabb.h b/cocos2dx/kazmath/include/kazmath/aabb.h index 5c2e997bec..6b1860c13b 100644 --- a/cocos2dx/kazmath/include/kazmath/aabb.h +++ b/cocos2dx/kazmath/include/kazmath/aabb.h @@ -26,7 +26,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef KAZMATH_AABB_H_INCLUDED #define KAZMATH_AABB_H_INCLUDED -#include "CCPlatformMacros.h" +#include "platform/CCPlatformMacros.h" #include "vec3.h" #include "utility.h" diff --git a/cocos2dx/kazmath/include/kazmath/mat3.h b/cocos2dx/kazmath/include/kazmath/mat3.h index fc0668b20d..4d22dfb28a 100644 --- a/cocos2dx/kazmath/include/kazmath/mat3.h +++ b/cocos2dx/kazmath/include/kazmath/mat3.h @@ -27,7 +27,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef MAT3_H_INCLUDED #define MAT3_H_INCLUDED -#include "CCPlatformMacros.h" +#include "platform/CCPlatformMacros.h" #include "utility.h" struct kmVec3; diff --git a/cocos2dx/kazmath/include/kazmath/mat4.h b/cocos2dx/kazmath/include/kazmath/mat4.h index f8ad019d5f..241a0b9ec0 100644 --- a/cocos2dx/kazmath/include/kazmath/mat4.h +++ b/cocos2dx/kazmath/include/kazmath/mat4.h @@ -26,7 +26,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef MAT4_H_INCLUDED #define MAT4_H_INCLUDED -#include "CCPlatformMacros.h" +#include "platform/CCPlatformMacros.h" #include "utility.h" struct kmVec3; diff --git a/cocos2dx/kazmath/include/kazmath/plane.h b/cocos2dx/kazmath/include/kazmath/plane.h index 105b1cbcaa..0a42daf63e 100644 --- a/cocos2dx/kazmath/include/kazmath/plane.h +++ b/cocos2dx/kazmath/include/kazmath/plane.h @@ -33,7 +33,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define KM_PLANE_NEAR 4 #define KM_PLANE_FAR 5 -#include "CCPlatformMacros.h" +#include "platform/CCPlatformMacros.h" #include "utility.h" struct kmVec3; diff --git a/cocos2dx/kazmath/include/kazmath/quaternion.h b/cocos2dx/kazmath/include/kazmath/quaternion.h index 2e9bb582c4..a3632f0ff9 100644 --- a/cocos2dx/kazmath/include/kazmath/quaternion.h +++ b/cocos2dx/kazmath/include/kazmath/quaternion.h @@ -30,7 +30,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. extern "C" { #endif -#include "CCPlatformMacros.h" +#include "platform/CCPlatformMacros.h" #include "utility.h" struct kmMat4; diff --git a/cocos2dx/kazmath/include/kazmath/ray2.h b/cocos2dx/kazmath/include/kazmath/ray2.h index c93c3b4a4e..6734a95611 100644 --- a/cocos2dx/kazmath/include/kazmath/ray2.h +++ b/cocos2dx/kazmath/include/kazmath/ray2.h @@ -26,7 +26,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef RAY_2_H #define RAY_2_H -#include "CCPlatformMacros.h" +#include "platform/CCPlatformMacros.h" #include "utility.h" #include "vec2.h" diff --git a/cocos2dx/kazmath/include/kazmath/utility.h b/cocos2dx/kazmath/include/kazmath/utility.h index 62b196be1c..ed6bff6854 100644 --- a/cocos2dx/kazmath/include/kazmath/utility.h +++ b/cocos2dx/kazmath/include/kazmath/utility.h @@ -26,7 +26,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef UTILITY_H_INCLUDED #define UTILITY_H_INCLUDED -#include "CCPlatformMacros.h" +#include "platform/CCPlatformMacros.h" #include #ifndef kmScalar diff --git a/cocos2dx/kazmath/include/kazmath/vec2.h b/cocos2dx/kazmath/include/kazmath/vec2.h index d8fdf82e41..6c29d4005f 100644 --- a/cocos2dx/kazmath/include/kazmath/vec2.h +++ b/cocos2dx/kazmath/include/kazmath/vec2.h @@ -26,7 +26,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef VEC2_H_INCLUDED #define VEC2_H_INCLUDED -#include "CCPlatformMacros.h" +#include "platform/CCPlatformMacros.h" struct kmMat3; diff --git a/cocos2dx/kazmath/include/kazmath/vec3.h b/cocos2dx/kazmath/include/kazmath/vec3.h index d8c8641cf4..eb74d41b61 100644 --- a/cocos2dx/kazmath/include/kazmath/vec3.h +++ b/cocos2dx/kazmath/include/kazmath/vec3.h @@ -26,7 +26,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef VEC3_H_INCLUDED #define VEC3_H_INCLUDED -#include "CCPlatformMacros.h" +#include "platform/CCPlatformMacros.h" #include #ifndef kmScalar diff --git a/cocos2dx/keypad_dispatcher/CCKeypadDelegate.h b/cocos2dx/keypad_dispatcher/CCKeypadDelegate.h index 0bdaefdd6a..5526094d4b 100644 --- a/cocos2dx/keypad_dispatcher/CCKeypadDelegate.h +++ b/cocos2dx/keypad_dispatcher/CCKeypadDelegate.h @@ -26,7 +26,7 @@ THE SOFTWARE. #define __CCKEYPAD_DELEGATE_H__ -#include "CCObject.h" +#include "cocoa/CCObject.h" NS_CC_BEGIN diff --git a/cocos2dx/keypad_dispatcher/CCKeypadDispatcher.h b/cocos2dx/keypad_dispatcher/CCKeypadDispatcher.h index 4e39b636e8..9637d8f9e5 100644 --- a/cocos2dx/keypad_dispatcher/CCKeypadDispatcher.h +++ b/cocos2dx/keypad_dispatcher/CCKeypadDispatcher.h @@ -26,7 +26,7 @@ THE SOFTWARE. #define __CCKEYPAD_DISPATCHER_H__ #include "CCKeypadDelegate.h" -#include "CCArray.h" +#include "cocoa/CCArray.h" NS_CC_BEGIN diff --git a/cocos2dx/label_nodes/CCLabelAtlas.h b/cocos2dx/label_nodes/CCLabelAtlas.h index 93c7089fd4..a252a6960a 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.h +++ b/cocos2dx/label_nodes/CCLabelAtlas.h @@ -26,7 +26,7 @@ THE SOFTWARE. #ifndef __CCLABEL_ATLAS_H__ #define __CCLABEL_ATLAS_H__ -#include "CCAtlasNode.h" +#include "base_nodes/CCAtlasNode.h" NS_CC_BEGIN diff --git a/cocos2dx/label_nodes/CCLabelBMFont.h b/cocos2dx/label_nodes/CCLabelBMFont.h index 667271fd89..9fb9182591 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.h +++ b/cocos2dx/label_nodes/CCLabelBMFont.h @@ -33,7 +33,7 @@ Use any of these editors to generate BMFonts: #ifndef __CCBITMAP_FONT_ATLAS_H__ #define __CCBITMAP_FONT_ATLAS_H__ -#include "CCSpriteBatchNode.h" +#include "sprite_nodes/CCSpriteBatchNode.h" #include #include #include diff --git a/cocos2dx/label_nodes/CCLabelTTF.h b/cocos2dx/label_nodes/CCLabelTTF.h index 27427e1d11..9f5b728b00 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.h +++ b/cocos2dx/label_nodes/CCLabelTTF.h @@ -25,8 +25,8 @@ THE SOFTWARE. #ifndef __CCLABELTTF_H__ #define __CCLABELTTF_H__ -#include "CCSprite.h" -#include "CCTexture2D.h" +#include "sprite_nodes/CCSprite.h" +#include "textures/CCTexture2D.h" NS_CC_BEGIN diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h index 21745e4bc7..03bc7e9a9c 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h @@ -27,12 +27,12 @@ THE SOFTWARE. #ifndef __CCLAYER_H__ #define __CCLAYER_H__ -#include "CCNode.h" +#include "base_nodes/CCNode.h" #include "CCProtocols.h" -#include "CCTouchDelegateProtocol.h" -#include "CCAccelerometerDelegate.h" -#include "CCKeypadDelegate.h" -#include "CCArray.h" +#include "touch_dispatcher/CCTouchDelegateProtocol.h" +#include "platform/CCAccelerometerDelegate.h" +#include "keypad_dispatcher/CCKeypadDelegate.h" +#include "cocoa/CCArray.h" NS_CC_BEGIN diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCScene.h b/cocos2dx/layers_scenes_transitions_nodes/CCScene.h index 346d73eb8d..143a32be64 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCScene.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCScene.h @@ -27,7 +27,7 @@ THE SOFTWARE. #ifndef __CCSCENE_H__ #define __CCSCENE_H__ -#include "CCNode.h" +#include "base_nodes/CCNode.h" NS_CC_BEGIN diff --git a/cocos2dx/menu_nodes/CCMenu.h b/cocos2dx/menu_nodes/CCMenu.h index 77b5833338..9790568f6d 100644 --- a/cocos2dx/menu_nodes/CCMenu.h +++ b/cocos2dx/menu_nodes/CCMenu.h @@ -26,7 +26,7 @@ THE SOFTWARE. #define __CCMENU_H_ #include "CCMenuItem.h" -#include "CCLayer.h" +#include "layers_scenes_transitions_nodes/CCLayer.h" NS_CC_BEGIN diff --git a/cocos2dx/menu_nodes/CCMenuItem.h b/cocos2dx/menu_nodes/CCMenuItem.h index d845708ab0..5c37532b24 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.h +++ b/cocos2dx/menu_nodes/CCMenuItem.h @@ -27,9 +27,9 @@ THE SOFTWARE. #ifndef __CCMENU_ITEM_H__ #define __CCMENU_ITEM_H__ -#include "CCNode.h" +#include "base_nodes/CCNode.h" #include "CCProtocols.h" -#include "CCArray.h" +#include "cocoa/CCArray.h" NS_CC_BEGIN diff --git a/cocos2dx/misc_nodes/CCMotionStreak.h b/cocos2dx/misc_nodes/CCMotionStreak.h index 63e50836b8..80af657693 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.h +++ b/cocos2dx/misc_nodes/CCMotionStreak.h @@ -26,9 +26,9 @@ THE SOFTWARE. #define __CCMOTION_STREAK_H__ #include "CCProtocols.h" -#include "CCTexture2D.h" +#include "textures/CCTexture2D.h" #include "ccTypes.h" -#include "CCNode.h" +#include "base_nodes/CCNode.h" NS_CC_BEGIN diff --git a/cocos2dx/misc_nodes/CCProgressTimer.h b/cocos2dx/misc_nodes/CCProgressTimer.h index 263dcfaa76..553373123e 100644 --- a/cocos2dx/misc_nodes/CCProgressTimer.h +++ b/cocos2dx/misc_nodes/CCProgressTimer.h @@ -25,7 +25,7 @@ THE SOFTWARE. #ifndef __MISC_NODE_CCPROGRESS_TIMER_H__ #define __MISC_NODE_CCPROGRESS_TIMER_H__ -#include "CCSprite.h" +#include "sprite_nodes/CCSprite.h" NS_CC_BEGIN diff --git a/cocos2dx/misc_nodes/CCRenderTexture.h b/cocos2dx/misc_nodes/CCRenderTexture.h index 49d1a2c4af..79f8a3f50b 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.h +++ b/cocos2dx/misc_nodes/CCRenderTexture.h @@ -25,8 +25,8 @@ THE SOFTWARE. #ifndef __CCRENDER_TEXTURE_H__ #define __CCRENDER_TEXTURE_H__ -#include "CCNode.h" -#include "CCSprite.h" +#include "base_nodes/CCNode.h" +#include "sprite_nodes/CCSprite.h" #include "kazmath/mat4.h" NS_CC_BEGIN @@ -58,9 +58,9 @@ public: CCRenderTexture(); virtual ~CCRenderTexture(); - /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format - @warning: This interface will be deprecated in future. - */ + /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format + @warning: This interface will be deprecated in future. + */ static CCRenderTexture * renderTextureWithWidthAndHeight(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat); /** creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid @@ -73,7 +73,7 @@ public: */ static CCRenderTexture * renderTextureWithWidthAndHeight(int w, int h); - /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format*/ + /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format*/ static CCRenderTexture * create(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat); /** creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid */ @@ -85,7 +85,7 @@ public: /** initializes a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid */ bool initWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat); - /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format*/ + /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format*/ bool initWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat); /** starts grabbing */ @@ -95,12 +95,12 @@ public: This is more efficient then calling -clear first and then -begin */ void beginWithClear(float r, float g, float b, float a); - /** starts rendering to the texture while clearing the texture first. - This is more efficient then calling -clear first and then -begin */ - void beginWithClear(float r, float g, float b, float a, float depthValue); - - /** starts rendering to the texture while clearing the texture first. - This is more efficient then calling -clear first and then -begin */ + /** starts rendering to the texture while clearing the texture first. + This is more efficient then calling -clear first and then -begin */ + void beginWithClear(float r, float g, float b, float a, float depthValue); + + /** starts rendering to the texture while clearing the texture first. + This is more efficient then calling -clear first and then -begin */ void beginWithClear(float r, float g, float b, float a, float depthValue, int stencilValue); /** end is key word of lua, use other name to export to lua. */ @@ -112,10 +112,10 @@ public: /** clears the texture with a color */ void clear(float r, float g, float b, float a); - /** clears the texture with a specified depth value */ - void clearDepth(float depthValue); - - /** clears the texture with a specified stencil value */ + /** clears the texture with a specified depth value */ + void clearDepth(float depthValue); + + /** clears the texture with a specified stencil value */ void clearStencil(int stencilValue); /* creates a new CCImage from with the texture's data. Caller is responsible for releasing it by calling delete. diff --git a/cocos2dx/particle_nodes/CCParticleBatchNode.h b/cocos2dx/particle_nodes/CCParticleBatchNode.h index 15fb0e0edf..26ab2bdd13 100644 --- a/cocos2dx/particle_nodes/CCParticleBatchNode.h +++ b/cocos2dx/particle_nodes/CCParticleBatchNode.h @@ -29,7 +29,7 @@ #ifndef __CCPARTICLEBATCHNODE_H__ #define __CCPARTICLEBATCHNODE_H__ -#include "CCNode.h" +#include "base_nodes/CCNode.h" #include "CCProtocols.h" NS_CC_BEGIN diff --git a/cocos2dx/particle_nodes/CCParticleSystem.h b/cocos2dx/particle_nodes/CCParticleSystem.h index 66bb385492..4268295282 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.h +++ b/cocos2dx/particle_nodes/CCParticleSystem.h @@ -27,9 +27,9 @@ THE SOFTWARE. #define __CCPARTICLE_SYSTEM_H__ #include "CCProtocols.h" -#include "CCNode.h" -#include "CCDictionary.h" -#include "CCString.h" +#include "base_nodes/CCNode.h" +#include "cocoa/CCDictionary.h" +#include "cocoa/CCString.h" NS_CC_BEGIN diff --git a/cocos2dx/platform/CCImage.h b/cocos2dx/platform/CCImage.h index f7322740c9..efca8a56e3 100644 --- a/cocos2dx/platform/CCImage.h +++ b/cocos2dx/platform/CCImage.h @@ -25,7 +25,7 @@ THE SOFTWARE. #ifndef __CC_IMAGE_H__ #define __CC_IMAGE_H__ -#include "CCObject.h" +#include "cocoa/CCObject.h" NS_CC_BEGIN diff --git a/cocos2dx/platform/CCPlatformMacros.h b/cocos2dx/platform/CCPlatformMacros.h index 2e7e21fcf5..bd2f263048 100644 --- a/cocos2dx/platform/CCPlatformMacros.h +++ b/cocos2dx/platform/CCPlatformMacros.h @@ -31,6 +31,7 @@ #include "CCPlatformConfig.h" #include "CCPlatformDefine.h" + /** @def CC_ENABLE_CACHE_TEXTURE_DATA Enable it if you want to cache the texture data. Basically,it's only enabled in android diff --git a/cocos2dx/platform/ios/CCAccelerometer.h b/cocos2dx/platform/ios/CCAccelerometer.h index afcf169b59..051a954b4e 100644 --- a/cocos2dx/platform/ios/CCAccelerometer.h +++ b/cocos2dx/platform/ios/CCAccelerometer.h @@ -25,7 +25,7 @@ THE SOFTWARE. #ifndef __PLATFORM_IPHONE_CCACCELEROMETER_H__ #define __PLATFORM_IPHONE_CCACCELEROMETER_H__ -#include "CCAccelerometerDelegate.h" +#include "platform/CCAccelerometerDelegate.h" NS_CC_BEGIN diff --git a/cocos2dx/platform/ios/CCApplication.h b/cocos2dx/platform/ios/CCApplication.h index c35f8f627a..627380c958 100644 --- a/cocos2dx/platform/ios/CCApplication.h +++ b/cocos2dx/platform/ios/CCApplication.h @@ -25,8 +25,8 @@ THE SOFTWARE. #ifndef __CC_APPLICATION_IOS_H__ #define __CC_APPLICATION_IOS_H__ -#include "CCCommon.h" -#include "CCApplicationProtocol.h" +#include "platform/CCCommon.h" +#include "platform/CCApplicationProtocol.h" NS_CC_BEGIN diff --git a/cocos2dx/platform/ios/CCEGLView.h b/cocos2dx/platform/ios/CCEGLView.h index e1aaf1bc9d..6094941cd7 100644 --- a/cocos2dx/platform/ios/CCEGLView.h +++ b/cocos2dx/platform/ios/CCEGLView.h @@ -25,8 +25,8 @@ THE SOFTWARE. #ifndef __CC_EGLVIEW_IPHONE_H__ #define __CC_EGLVIEW_IPHONE_H__ -#include "CCCommon.h" -#include "CCEGLViewProtocol.h" +#include "platform/CCCommon.h" +#include "platform/CCEGLViewProtocol.h" NS_CC_BEGIN diff --git a/cocos2dx/platform/ios/CCESRenderer.h b/cocos2dx/platform/ios/CCESRenderer.h index b299a51d0e..7dfb474c8e 100644 --- a/cocos2dx/platform/ios/CCESRenderer.h +++ b/cocos2dx/platform/ios/CCESRenderer.h @@ -28,7 +28,7 @@ // Only compile this code on iOS. These files should NOT be included on your Mac project. // But in case they are included, it won't be compiled. -#import "CCPlatformMacros.h" +#import "platform/CCPlatformMacros.h" #import #import diff --git a/cocos2dx/platform/ios/CCStdC.h b/cocos2dx/platform/ios/CCStdC.h index c959eefe13..21747332ef 100644 --- a/cocos2dx/platform/ios/CCStdC.h +++ b/cocos2dx/platform/ios/CCStdC.h @@ -25,7 +25,7 @@ THE SOFTWARE. #ifndef __CC_STD_C_H__ #define __CC_STD_C_H__ -#include "CCPlatformMacros.h" +#include "platform/CCPlatformMacros.h" #include #include #include diff --git a/cocos2dx/proj.ios/cocos2dx-Prefix.pch b/cocos2dx/proj.ios/cocos2dx-Prefix.pch new file mode 100644 index 0000000000..fec5647078 --- /dev/null +++ b/cocos2dx/proj.ios/cocos2dx-Prefix.pch @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'cocos2dx' target in the 'cocos2dx' project +// + +#ifdef __OBJC__ + #import +#endif diff --git a/cocos2dx/proj.ios/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2dx/proj.ios/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id new file mode 100644 index 0000000000..0769fe000a --- /dev/null +++ b/cocos2dx/proj.ios/cocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id @@ -0,0 +1 @@ +09db4ca2f8aea11791d3c39709ea90d4dabd3327 \ No newline at end of file diff --git a/cocos2dx/proj.ios/cocos2dx/cocos2dx.xcodeproj/project.pbxproj b/cocos2dx/proj.ios/cocos2dx/cocos2dx.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..d962742386 --- /dev/null +++ b/cocos2dx/proj.ios/cocos2dx/cocos2dx.xcodeproj/project.pbxproj @@ -0,0 +1,232 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 1551A343158F2AB200E66CFE /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1551A342158F2AB200E66CFE /* Foundation.framework */; }; + 1551A349158F2AB200E66CFE /* cocos2dx.m in Sources */ = {isa = PBXBuildFile; fileRef = 1551A348158F2AB200E66CFE /* cocos2dx.m */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 1551A33F158F2AB200E66CFE /* libcocos2dx.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libcocos2dx.a; sourceTree = BUILT_PRODUCTS_DIR; }; + 1551A342158F2AB200E66CFE /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + 1551A346158F2AB200E66CFE /* cocos2dx-Prefix.pch */ = {isa = PBXFileReference; path = "cocos2dx-Prefix.pch"; sourceTree = ""; }; + 1551A347158F2AB200E66CFE /* cocos2dx.h */ = {isa = PBXFileReference; path = cocos2dx.h; sourceTree = ""; }; + 1551A348158F2AB200E66CFE /* cocos2dx.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = cocos2dx.m; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 1551A33C158F2AB200E66CFE /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 1551A343158F2AB200E66CFE /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 1551A334158F2AB200E66CFE = { + isa = PBXGroup; + children = ( + 1551A344158F2AB200E66CFE /* cocos2dx */, + 1551A341158F2AB200E66CFE /* Frameworks */, + 1551A340158F2AB200E66CFE /* Products */, + ); + sourceTree = ""; + }; + 1551A340158F2AB200E66CFE /* Products */ = { + isa = PBXGroup; + children = ( + 1551A33F158F2AB200E66CFE /* libcocos2dx.a */, + ); + name = Products; + sourceTree = ""; + }; + 1551A341158F2AB200E66CFE /* Frameworks */ = { + isa = PBXGroup; + children = ( + 1551A342158F2AB200E66CFE /* Foundation.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + 1551A344158F2AB200E66CFE /* cocos2dx */ = { + isa = PBXGroup; + children = ( + 1551A347158F2AB200E66CFE /* cocos2dx.h */, + 1551A348158F2AB200E66CFE /* cocos2dx.m */, + 1551A345158F2AB200E66CFE /* Supporting Files */, + ); + path = cocos2dx; + sourceTree = ""; + }; + 1551A345158F2AB200E66CFE /* Supporting Files */ = { + isa = PBXGroup; + children = ( + 1551A346158F2AB200E66CFE /* cocos2dx-Prefix.pch */, + ); + name = "Supporting Files"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + 1551A33D158F2AB200E66CFE /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + 1551A33E158F2AB200E66CFE /* cocos2dx */ = { + isa = PBXNativeTarget; + buildConfigurationList = 1551A34C158F2AB200E66CFE /* Build configuration list for PBXNativeTarget "cocos2dx" */; + buildPhases = ( + 1551A33B158F2AB200E66CFE /* Sources */, + 1551A33C158F2AB200E66CFE /* Frameworks */, + 1551A33D158F2AB200E66CFE /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = cocos2dx; + productName = cocos2dx; + productReference = 1551A33F158F2AB200E66CFE /* libcocos2dx.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 1551A336158F2AB200E66CFE /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0430; + ORGANIZATIONNAME = "厦门雅基软件有é™å…¬å¸"; + }; + buildConfigurationList = 1551A339158F2AB200E66CFE /* Build configuration list for PBXProject "cocos2dx" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = 1551A334158F2AB200E66CFE; + productRefGroup = 1551A340158F2AB200E66CFE /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 1551A33E158F2AB200E66CFE /* cocos2dx */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXSourcesBuildPhase section */ + 1551A33B158F2AB200E66CFE /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 1551A349158F2AB200E66CFE /* cocos2dx.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 1551A34A158F2AB200E66CFE /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + COPY_PHASE_STRIP = NO; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_DYNAMIC_NO_PIC = NO; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 5.1; + SDKROOT = iphoneos; + }; + name = Debug; + }; + 1551A34B158F2AB200E66CFE /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + COPY_PHASE_STRIP = YES; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 5.1; + SDKROOT = iphoneos; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 1551A34D158F2AB200E66CFE /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + DSTROOT = /tmp/cocos2dx.dst; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "cocos2dx/cocos2dx-Prefix.pch"; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + 1551A34E158F2AB200E66CFE /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + DSTROOT = /tmp/cocos2dx.dst; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = "cocos2dx/cocos2dx-Prefix.pch"; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 1551A339158F2AB200E66CFE /* Build configuration list for PBXProject "cocos2dx" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1551A34A158F2AB200E66CFE /* Debug */, + 1551A34B158F2AB200E66CFE /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 1551A34C158F2AB200E66CFE /* Build configuration list for PBXNativeTarget "cocos2dx" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 1551A34D158F2AB200E66CFE /* Debug */, + 1551A34E158F2AB200E66CFE /* Release */, + ); + defaultConfigurationIsVisible = 0; + }; +/* End XCConfigurationList section */ + }; + rootObject = 1551A336158F2AB200E66CFE /* Project object */; +} diff --git a/cocos2dx/proj.ios/cocos2dx/cocos2dx/cocos2dx-Prefix.pch b/cocos2dx/proj.ios/cocos2dx/cocos2dx/cocos2dx-Prefix.pch new file mode 100644 index 0000000000..fec5647078 --- /dev/null +++ b/cocos2dx/proj.ios/cocos2dx/cocos2dx/cocos2dx-Prefix.pch @@ -0,0 +1,7 @@ +// +// Prefix header for all source files of the 'cocos2dx' target in the 'cocos2dx' project +// + +#ifdef __OBJC__ + #import +#endif diff --git a/cocos2dx/proj.ios/cocos2dx/cocos2dx/cocos2dx.h b/cocos2dx/proj.ios/cocos2dx/cocos2dx/cocos2dx.h new file mode 100644 index 0000000000..ac129f614a --- /dev/null +++ b/cocos2dx/proj.ios/cocos2dx/cocos2dx/cocos2dx.h @@ -0,0 +1,13 @@ +// +// cocos2dx.h +// cocos2dx +// +// Created by mingo on 12-6-18. +// Copyright (c) 2012å¹´ 厦门雅基软件有é™å…¬å¸. All rights reserved. +// + +#import + +@interface cocos2dx : NSObject + +@end diff --git a/cocos2dx/proj.ios/cocos2dx/cocos2dx/cocos2dx.m b/cocos2dx/proj.ios/cocos2dx/cocos2dx/cocos2dx.m new file mode 100644 index 0000000000..520800fdfa --- /dev/null +++ b/cocos2dx/proj.ios/cocos2dx/cocos2dx/cocos2dx.m @@ -0,0 +1,13 @@ +// +// cocos2dx.m +// cocos2dx +// +// Created by mingo on 12-6-18. +// Copyright (c) 2012å¹´ 厦门雅基软件有é™å…¬å¸. All rights reserved. +// + +#import "cocos2dx.h" + +@implementation cocos2dx + +@end diff --git a/cocos2dx/proj.ios/libcocos2dx-Prefix.pch b/cocos2dx/proj.ios/libcocos2dx-Prefix.pch deleted file mode 100644 index 93338f705e..0000000000 --- a/cocos2dx/proj.ios/libcocos2dx-Prefix.pch +++ /dev/null @@ -1,9 +0,0 @@ -// -// Prefix header for all source files of the 'libcocos2dx' target in the 'libcocos2dx' project -// - -#ifdef __OBJC__ - #import -#endif - -//#import "cocos2d.h" \ No newline at end of file diff --git a/cocos2dx/proj.ios/libcocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id b/cocos2dx/proj.ios/libcocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id deleted file mode 100644 index c59752cd2c..0000000000 --- a/cocos2dx/proj.ios/libcocos2dx.xcodeproj/project.pbxproj.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -e9d68567e9d01d8eda8e981ab8a8d1fe12fd8a0b \ No newline at end of file diff --git a/cocos2dx/script_support/CCScriptSupport.h b/cocos2dx/script_support/CCScriptSupport.h index f9bf9816b7..cf1f83cb1e 100644 --- a/cocos2dx/script_support/CCScriptSupport.h +++ b/cocos2dx/script_support/CCScriptSupport.h @@ -25,9 +25,9 @@ THE SOFTWARE. #ifndef __SCRIPT_SUPPORT_H__ #define __SCRIPT_SUPPORT_H__ -#include "CCCommon.h" -#include "CCTouch.h" -#include "CCSet.h" +#include "platform/CCCommon.h" +#include "touch_dispatcher/CCTouch.h" +#include "cocoa/CCSet.h" typedef struct lua_State lua_State; diff --git a/cocos2dx/shaders/CCGLProgram.h b/cocos2dx/shaders/CCGLProgram.h index fd5f480dff..19610287b5 100644 --- a/cocos2dx/shaders/CCGLProgram.h +++ b/cocos2dx/shaders/CCGLProgram.h @@ -29,7 +29,7 @@ THE SOFTWARE. #define __CCGLPROGRAM_H__ #include "ccMacros.h" -#include "CCObject.h" +#include "cocoa/CCObject.h" #include "CCGL.h" diff --git a/cocos2dx/shaders/CCShaderCache.h b/cocos2dx/shaders/CCShaderCache.h index 2636855414..2583c36869 100644 --- a/cocos2dx/shaders/CCShaderCache.h +++ b/cocos2dx/shaders/CCShaderCache.h @@ -27,7 +27,7 @@ THE SOFTWARE. #ifndef __CCSHADERCACHE_H__ #define __CCSHADERCACHE_H__ -#include "CCDictionary.h" +#include "cocoa/CCDictionary.h" NS_CC_BEGIN diff --git a/cocos2dx/shaders/ccGLStateCache.h b/cocos2dx/shaders/ccGLStateCache.h index d920c0b3f5..9086fc8c7c 100644 --- a/cocos2dx/shaders/ccGLStateCache.h +++ b/cocos2dx/shaders/ccGLStateCache.h @@ -28,7 +28,7 @@ THE SOFTWARE. #define __CCGLSTATE_H__ #include "CCGL.h" -#include "CCPlatformMacros.h" +#include "platform/CCPlatformMacros.h" NS_CC_BEGIN diff --git a/cocos2dx/shaders/ccShaders.h b/cocos2dx/shaders/ccShaders.h index 834d1393db..fca8899bd7 100644 --- a/cocos2dx/shaders/ccShaders.h +++ b/cocos2dx/shaders/ccShaders.h @@ -26,7 +26,7 @@ THE SOFTWARE. #define __CCSHADER_H__ #include "CCGL.h" -#include "CCPlatformMacros.h" +#include "platform/CCPlatformMacros.h" NS_CC_BEGIN diff --git a/cocos2dx/sprite_nodes/CCAnimation.h b/cocos2dx/sprite_nodes/CCAnimation.h index c0f25a14ed..dbf3ffc7ed 100644 --- a/cocos2dx/sprite_nodes/CCAnimation.h +++ b/cocos2dx/sprite_nodes/CCAnimation.h @@ -26,11 +26,11 @@ THE SOFTWARE. #ifndef __CC_ANIMATION_H__ #define __CC_ANIMATION_H__ -#include "CCPlatformConfig.h" -#include "CCObject.h" -#include "CCArray.h" -#include "CCDictionary.h" -#include "CCGeometry.h" +#include "platform/CCPlatformConfig.h" +#include "cocoa/CCObject.h" +#include "cocoa/CCArray.h" +#include "cocoa/CCDictionary.h" +#include "cocoa/CCGeometry.h" #include "CCSpriteFrame.h" #include diff --git a/cocos2dx/sprite_nodes/CCAnimationCache.h b/cocos2dx/sprite_nodes/CCAnimationCache.h index 2eb3fb7fce..ecf241aec7 100644 --- a/cocos2dx/sprite_nodes/CCAnimationCache.h +++ b/cocos2dx/sprite_nodes/CCAnimationCache.h @@ -26,8 +26,8 @@ THE SOFTWARE. #ifndef __CC_ANIMATION_CACHE_H__ #define __CC_ANIMATION_CACHE_H__ -#include "CCObject.h" -#include "CCDictionary.h" +#include "cocoa/CCObject.h" +#include "cocoa/CCDictionary.h" #include diff --git a/cocos2dx/sprite_nodes/CCSprite.h b/cocos2dx/sprite_nodes/CCSprite.h index 1e52ed4c46..8964775736 100644 --- a/cocos2dx/sprite_nodes/CCSprite.h +++ b/cocos2dx/sprite_nodes/CCSprite.h @@ -27,11 +27,11 @@ THE SOFTWARE. #ifndef __SPITE_NODE_CCSPRITE_H__ #define __SPITE_NODE_CCSPRITE_H__ -#include "CCNode.h" +#include "base_nodes/CCNode.h" #include "CCProtocols.h" -#include "CCTextureAtlas.h" +#include "textures/CCTextureAtlas.h" #include "ccTypes.h" -#include "CCDictionary.h" +#include "cocoa/CCDictionary.h" #include NS_CC_BEGIN diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.h b/cocos2dx/sprite_nodes/CCSpriteBatchNode.h index 86eaba68b2..a686d2646c 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.h +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.h @@ -28,11 +28,11 @@ THE SOFTWARE. #ifndef __CC_SPRITE_BATCH_NODE_H__ #define __CC_SPRITE_BATCH_NODE_H__ -#include "CCNode.h" +#include "base_nodes/CCNode.h" #include "CCProtocols.h" -#include "CCTextureAtlas.h" +#include "textures/CCTextureAtlas.h" #include "ccMacros.h" -#include "CCArray.h" +#include "cocoa/CCArray.h" NS_CC_BEGIN diff --git a/cocos2dx/sprite_nodes/CCSpriteFrame.h b/cocos2dx/sprite_nodes/CCSpriteFrame.h index 9d5b310e60..965d63ea1d 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrame.h +++ b/cocos2dx/sprite_nodes/CCSpriteFrame.h @@ -27,10 +27,10 @@ THE SOFTWARE. #ifndef __SPRITE_CCSPRITE_FRAME_H__ #define __SPRITE_CCSPRITE_FRAME_H__ -#include "CCNode.h" +#include "base_nodes/CCNode.h" #include "CCProtocols.h" -#include "CCObject.h" -#include "CCGeometry.h" +#include "cocoa/CCObject.h" +#include "cocoa/CCGeometry.h" NS_CC_BEGIN diff --git a/cocos2dx/sprite_nodes/CCSpriteFrameCache.h b/cocos2dx/sprite_nodes/CCSpriteFrameCache.h index c0439e6893..3d0e0efe30 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrameCache.h +++ b/cocos2dx/sprite_nodes/CCSpriteFrameCache.h @@ -34,11 +34,11 @@ THE SOFTWARE. * http://zwoptex.zwopple.com/ */ -#include -#include "CCSpriteFrame.h" -#include "CCTexture2D.h" -#include "CCObject.h" +#include "sprite_nodes/CCSpriteFrame.h" +#include "textures/CCTexture2D.h" +#include "cocoa/CCObject.h" #include +#include NS_CC_BEGIN diff --git a/cocos2dx/support/CCPointExtension.h b/cocos2dx/support/CCPointExtension.h index 14841f190e..e99986d63b 100644 --- a/cocos2dx/support/CCPointExtension.h +++ b/cocos2dx/support/CCPointExtension.h @@ -43,7 +43,7 @@ THE SOFTWARE. - cpvadd( CCPointMake(1,1), CCPointMake(2,2) ); // mixing chipmunk and CG (avoid) */ -#include "CCGeometry.h" +#include "cocoa/CCGeometry.h" #include NS_CC_BEGIN diff --git a/cocos2dx/support/CCProfiling.h b/cocos2dx/support/CCProfiling.h index 338f28909e..93d071ca68 100644 --- a/cocos2dx/support/CCProfiling.h +++ b/cocos2dx/support/CCProfiling.h @@ -26,10 +26,10 @@ THE SOFTWARE. #define __SUPPORT_CCPROFILING_H__ #include "ccConfig.h" -#include -#include "CCObject.h" +#include "cocoa/CCObject.h" #include "platform/platform.h" -#include "CCDictionary.h" +#include "cocoa/CCDictionary.h" +#include NS_CC_BEGIN diff --git a/cocos2dx/support/CCUserDefault.h b/cocos2dx/support/CCUserDefault.h index 148f4c4677..5be1e834ee 100644 --- a/cocos2dx/support/CCUserDefault.h +++ b/cocos2dx/support/CCUserDefault.h @@ -24,7 +24,7 @@ THE SOFTWARE. #ifndef __SUPPORT_CCUSERDEFAULT_H__ #define __SUPPORT_CCUSERDEFAULT_H__ -#include "CCPlatformMacros.h" +#include "platform/CCPlatformMacros.h" #include NS_CC_BEGIN diff --git a/cocos2dx/support/data_support/ccCArray.h b/cocos2dx/support/data_support/ccCArray.h index 1ceba49aca..a6afcbc256 100644 --- a/cocos2dx/support/data_support/ccCArray.h +++ b/cocos2dx/support/data_support/ccCArray.h @@ -42,11 +42,12 @@ THE SOFTWARE. #ifndef CC_ARRAY_H #define CC_ARRAY_H +#include "ccMacros.h" +#include "cocoa/CCObject.h" + #include #include #include -#include "ccMacros.h" -#include "CCObject.h" NS_CC_BEGIN diff --git a/cocos2dx/text_input_node/CCIMEDelegate.h b/cocos2dx/text_input_node/CCIMEDelegate.h index 00bdbefdd1..6a324fc0cf 100644 --- a/cocos2dx/text_input_node/CCIMEDelegate.h +++ b/cocos2dx/text_input_node/CCIMEDelegate.h @@ -25,7 +25,7 @@ THE SOFTWARE. #ifndef __CC_IME_DELEGATE_H__ #define __CC_IME_DELEGATE_H__ -#include "CCGeometry.h" +#include "cocoa/CCGeometry.h" NS_CC_BEGIN diff --git a/cocos2dx/text_input_node/CCTextFieldTTF.h b/cocos2dx/text_input_node/CCTextFieldTTF.h index b9a34f7bec..5643316b2f 100644 --- a/cocos2dx/text_input_node/CCTextFieldTTF.h +++ b/cocos2dx/text_input_node/CCTextFieldTTF.h @@ -25,9 +25,9 @@ THE SOFTWARE. #ifndef __CC_TEXT_FIELD_H__ #define __CC_TEXT_FIELD_H__ -#include "CCLabelTTF.h" -#include "CCIMEDelegate.h" -#include "CCTouchDelegateProtocol.h" +#include "label_nodes/CCLabelTTF.h" +#include "text_input_node/CCIMEDelegate.h" +#include "touch_dispatcher/CCTouchDelegateProtocol.h" NS_CC_BEGIN diff --git a/cocos2dx/textures/CCTexture2D.h b/cocos2dx/textures/CCTexture2D.h index 4885f4e56a..43fca76341 100644 --- a/cocos2dx/textures/CCTexture2D.h +++ b/cocos2dx/textures/CCTexture2D.h @@ -27,8 +27,8 @@ THE SOFTWARE. #define __CCTEXTURE2D_H__ #include -#include "CCObject.h" -#include "CCGeometry.h" +#include "cocoa/CCObject.h" +#include "cocoa/CCGeometry.h" #include "ccTypes.h" NS_CC_BEGIN diff --git a/cocos2dx/textures/CCTextureAtlas.h b/cocos2dx/textures/CCTextureAtlas.h index 7a0ba81671..dd352aa57d 100644 --- a/cocos2dx/textures/CCTextureAtlas.h +++ b/cocos2dx/textures/CCTextureAtlas.h @@ -27,10 +27,10 @@ THE SOFTWARE. #ifndef __CCTEXTURE_ATLAS_H__ #define __CCTEXTURE_ATLAS_H__ -#include #include "ccTypes.h" -#include "CCObject.h" +#include "cocoa/CCObject.h" #include "ccConfig.h" +#include NS_CC_BEGIN diff --git a/cocos2dx/textures/CCTextureCache.h b/cocos2dx/textures/CCTextureCache.h index 1fe4952e50..1b194acc6f 100644 --- a/cocos2dx/textures/CCTextureCache.h +++ b/cocos2dx/textures/CCTextureCache.h @@ -27,10 +27,10 @@ THE SOFTWARE. #ifndef __CCTEXTURE_CACHE_H__ #define __CCTEXTURE_CACHE_H__ +#include "cocoa/CCObject.h" +#include "cocoa/CCDictionary.h" +#include "textures/CCTexture2D.h" #include -#include "CCObject.h" -#include "CCDictionary.h" -#include "CCTexture2D.h" #if CC_ENABLE_CACHE_TEXTURE_DATA diff --git a/cocos2dx/textures/CCTexturePVR.h b/cocos2dx/textures/CCTexturePVR.h index 70ce55544a..0f2b328df6 100644 --- a/cocos2dx/textures/CCTexturePVR.h +++ b/cocos2dx/textures/CCTexturePVR.h @@ -28,8 +28,8 @@ THE SOFTWARE. #include "CCStdC.h" #include "CCGL.h" -#include "CCObject.h" -#include "CCArray.h" +#include "cocoa/CCObject.h" +#include "cocoa/CCArray.h" NS_CC_BEGIN diff --git a/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h b/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h index b164933f0e..d243e8b0bb 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h +++ b/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h @@ -26,7 +26,7 @@ THE SOFTWARE. #ifndef __CCPARALLAX_NODE_H__ #define __CCPARALLAX_NODE_H__ -#include "CCNode.h" +#include "base_nodes/CCNode.h" /*#include "support/data_support/ccArray.h"*/ NS_CC_BEGIN diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h index d232dca5f1..63dc1194de 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h @@ -27,8 +27,8 @@ THE SOFTWARE. #define __CCTMX_LAYER_H__ #include "CCTMXObjectGroup.h" -#include "CCAtlasNode.h" -#include "CCSpriteBatchNode.h" +#include "base_nodes/CCAtlasNode.h" +#include "sprite_nodes/CCSpriteBatchNode.h" #include "CCTMXXMLParser.h" NS_CC_BEGIN diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXObjectGroup.h b/cocos2dx/tileMap_parallax_nodes/CCTMXObjectGroup.h index fc836a2848..04bbc13577 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXObjectGroup.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXObjectGroup.h @@ -27,10 +27,10 @@ THE SOFTWARE. #ifndef __CCTMX_OBJECT_GROUP_H__ #define __CCTMX_OBJECT_GROUP_H__ -#include "CCGeometry.h" -#include "CCString.h" -#include "CCArray.h" -#include "CCDictionary.h" +#include "cocoa/CCGeometry.h" +#include "cocoa/CCString.h" +#include "cocoa/CCArray.h" +#include "cocoa/CCDictionary.h" NS_CC_BEGIN diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h index a8730b9fa0..4b1536ef56 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h @@ -25,7 +25,8 @@ THE SOFTWARE. ****************************************************************************/ #ifndef __CCTMX_TILE_MAP_H__ #define __CCTMX_TILE_MAP_H__ -#include "CCNode.h" + +#include "base_nodes/CCNode.h" #include "CCTMXObjectGroup.h" NS_CC_BEGIN diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.h b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.h index 7dacf16fdb..13fcee038c 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.h @@ -27,11 +27,11 @@ THE SOFTWARE. #ifndef __CC_TM_XML_PARSER__ #define __CC_TM_XML_PARSER__ -#include "CCArray.h" -#include "CCDictionary.h" -#include "CCGeometry.h" -#include "../platform/CCSAXParser.h" +#include "cocoa/CCArray.h" +#include "cocoa/CCDictionary.h" +#include "cocoa/CCGeometry.h" +#include "platform/CCSAXParser.h" #include diff --git a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h index e70e3979d9..e48e00cb15 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h @@ -27,7 +27,7 @@ THE SOFTWARE. #define __CCTILE_MAP_ATLAS__ -#include "CCAtlasNode.h" +#include "base_nodes/CCAtlasNode.h" NS_CC_BEGIN diff --git a/cocos2dx/touch_dispatcher/CCTouch.h b/cocos2dx/touch_dispatcher/CCTouch.h index 6b533e2592..7056eb95a2 100644 --- a/cocos2dx/touch_dispatcher/CCTouch.h +++ b/cocos2dx/touch_dispatcher/CCTouch.h @@ -25,8 +25,8 @@ THE SOFTWARE. #ifndef __CC_TOUCH_H__ #define __CC_TOUCH_H__ -#include "CCObject.h" -#include "CCGeometry.h" +#include "cocoa/CCObject.h" +#include "cocoa/CCGeometry.h" NS_CC_BEGIN diff --git a/cocos2dx/touch_dispatcher/CCTouchDelegateProtocol.h b/cocos2dx/touch_dispatcher/CCTouchDelegateProtocol.h index 4fa3d740fa..94ddcbb1cc 100644 --- a/cocos2dx/touch_dispatcher/CCTouchDelegateProtocol.h +++ b/cocos2dx/touch_dispatcher/CCTouchDelegateProtocol.h @@ -26,7 +26,7 @@ THE SOFTWARE. #ifndef __TOUCH_DISPATHCHER_CCTOUCH_DELEGATE_PROTOCOL_H__ #define __TOUCH_DISPATHCHER_CCTOUCH_DELEGATE_PROTOCOL_H__ -#include "CCObject.h" +#include "cocoa/CCObject.h" #include "ccConfig.h" NS_CC_BEGIN diff --git a/cocos2dx/touch_dispatcher/CCTouchDispatcher.h b/cocos2dx/touch_dispatcher/CCTouchDispatcher.h index 52c6b63dba..b74d7c575c 100644 --- a/cocos2dx/touch_dispatcher/CCTouchDispatcher.h +++ b/cocos2dx/touch_dispatcher/CCTouchDispatcher.h @@ -27,8 +27,8 @@ THE SOFTWARE. #define __TOUCH_DISPATCHER_CCTOUCH_DISPATCHER_H__ #include "CCTouchDelegateProtocol.h" -#include "CCObject.h" -#include "CCArray.h" +#include "cocoa/CCObject.h" +#include "cocoa/CCArray.h" NS_CC_BEGIN diff --git a/cocos2dx/touch_dispatcher/CCTouchHandler.h b/cocos2dx/touch_dispatcher/CCTouchHandler.h index d99b566f1f..012e6d32a1 100644 --- a/cocos2dx/touch_dispatcher/CCTouchHandler.h +++ b/cocos2dx/touch_dispatcher/CCTouchHandler.h @@ -28,8 +28,8 @@ THE SOFTWARE. #include "CCTouchDelegateProtocol.h" #include "CCTouchDispatcher.h" -#include "CCObject.h" -#include "CCSet.h" +#include "cocoa/CCObject.h" +#include "cocoa/CCSet.h" NS_CC_BEGIN diff --git a/lua/cocos2dx_support/CCLuaEngine.cpp b/lua/cocos2dx_support/CCLuaEngine.cpp index d3c2a5b6a2..2f2a0ee6d3 100644 --- a/lua/cocos2dx_support/CCLuaEngine.cpp +++ b/lua/cocos2dx_support/CCLuaEngine.cpp @@ -33,7 +33,7 @@ extern "C" { #include "cocos2d.h" #include "LuaCocos2d.h" -#include "CCArray.h" +#include "cocoa/CCArray.h" #include "CCScheduler.h" #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) diff --git a/lua/cocos2dx_support/CCLuaEngine.h b/lua/cocos2dx_support/CCLuaEngine.h index 6b89bcecb5..257c24f660 100644 --- a/lua/cocos2dx_support/CCLuaEngine.h +++ b/lua/cocos2dx_support/CCLuaEngine.h @@ -30,11 +30,11 @@ extern "C" { } #include "ccTypes.h" -#include "CCObject.h" -#include "CCTouch.h" -#include "CCSet.h" -#include "CCNode.h" -#include "CCScriptSupport.h" +#include "cocoa/CCObject.h" +#include "touch_dispatcher/CCTouch.h" +#include "cocoa/CCSet.h" +#include "base_nodes/CCNode.h" +#include "script_support/CCScriptSupport.h" NS_CC_BEGIN diff --git a/testjs/proj.ios/testjs.xcodeproj/project.pbxproj b/testjs/proj.ios/testjs.xcodeproj/project.pbxproj new file mode 100644 index 0000000000..1a8a2cd44e --- /dev/null +++ b/testjs/proj.ios/testjs.xcodeproj/project.pbxproj @@ -0,0 +1,863 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 46; + objects = { + +/* Begin PBXBuildFile section */ + 1554941A15737858009041F8 /* JS in Resources */ = {isa = PBXBuildFile; fileRef = 1554941915737858009041F8 /* JS */; }; + 1554941F15737A4D009041F8 /* simple_class.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1554941B15737A4D009041F8 /* simple_class.cpp */; }; + 1554942015737A4D009041F8 /* simple_native_generated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1554941D15737A4D009041F8 /* simple_native_generated.cpp */; }; + 159A6671159048C8003AEEC0 /* libcocos2dx.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 159A666E15904899003AEEC0 /* libcocos2dx.a */; }; + 15DD7075156F2C6A003E7567 /* fps_images.fnt in Resources */ = {isa = PBXBuildFile; fileRef = 15DD7073156F2C6A003E7567 /* fps_images.fnt */; }; + 15DD7076156F2C6A003E7567 /* fps_images.png in Resources */ = {isa = PBXBuildFile; fileRef = 15DD7074156F2C6A003E7567 /* fps_images.png */; }; + A92275421517C094001B78AA /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275411517C094001B78AA /* QuartzCore.framework */; }; + A92275441517C094001B78AA /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275431517C094001B78AA /* OpenGLES.framework */; }; + A92275461517C094001B78AA /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275451517C094001B78AA /* OpenAL.framework */; }; + A92275481517C094001B78AA /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275471517C094001B78AA /* AudioToolbox.framework */; }; + A922754A1517C094001B78AA /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275491517C094001B78AA /* AVFoundation.framework */; }; + A922754C1517C094001B78AA /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A922754B1517C094001B78AA /* UIKit.framework */; }; + A922754E1517C094001B78AA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A922754D1517C094001B78AA /* Foundation.framework */; }; + A92275501517C094001B78AA /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A922754F1517C094001B78AA /* CoreGraphics.framework */; }; + D4544505156DE56E00887EB5 /* cocos2d_generated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D45440B4156DE56B00887EB5 /* cocos2d_generated.cpp */; }; + D4544506156DE56E00887EB5 /* cocos2d_manual_bindings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D45440B6156DE56B00887EB5 /* cocos2d_manual_bindings.cpp */; }; + D4544507156DE56E00887EB5 /* cocos_denshion_generated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D45440B7156DE56B00887EB5 /* cocos_denshion_generated.cpp */; }; + D4544509156DE56E00887EB5 /* ScriptingCore.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D45440BA156DE56B00887EB5 /* ScriptingCore.cpp */; }; + D45446D3156DE74F00887EB5 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = D45446CE156DE74F00887EB5 /* AppController.mm */; }; + D45446D4156DE74F00887EB5 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D45446CF156DE74F00887EB5 /* main.m */; }; + D45446D5156DE74F00887EB5 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = D45446D2156DE74F00887EB5 /* RootViewController.mm */; }; + D4544710156DE7F300887EB5 /* b1-hd.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446D9156DE7F300887EB5 /* b1-hd.png */; }; + D4544711156DE7F300887EB5 /* b1-ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446DA156DE7F300887EB5 /* b1-ipad.png */; }; + D4544712156DE7F300887EB5 /* b1.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446DB156DE7F300887EB5 /* b1.png */; }; + D4544713156DE7F300887EB5 /* b2-hd.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446DC156DE7F300887EB5 /* b2-hd.png */; }; + D4544714156DE7F300887EB5 /* b2-ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446DD156DE7F300887EB5 /* b2-ipad.png */; }; + D4544715156DE7F300887EB5 /* b2.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446DE156DE7F300887EB5 /* b2.png */; }; + D4544716156DE7F300887EB5 /* background.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446DF156DE7F300887EB5 /* background.png */; }; + D4544717156DE7F300887EB5 /* ballbounce.wav in Resources */ = {isa = PBXBuildFile; fileRef = D45446E0156DE7F300887EB5 /* ballbounce.wav */; }; + D4544718156DE7F300887EB5 /* BoilingFoam.plist in Resources */ = {isa = PBXBuildFile; fileRef = D45446E1156DE7F300887EB5 /* BoilingFoam.plist */; }; + D4544719156DE7F300887EB5 /* BurstPipe.plist in Resources */ = {isa = PBXBuildFile; fileRef = D45446E2156DE7F300887EB5 /* BurstPipe.plist */; }; + D454471A156DE7F300887EB5 /* CloseNormal.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446E3156DE7F300887EB5 /* CloseNormal.png */; }; + D454471B156DE7F300887EB5 /* CloseSelected.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446E4156DE7F300887EB5 /* CloseSelected.png */; }; + D454471C156DE7F300887EB5 /* Comet.plist in Resources */ = {isa = PBXBuildFile; fileRef = D45446E5156DE7F300887EB5 /* Comet.plist */; }; + D454471D156DE7F300887EB5 /* debian.plist in Resources */ = {isa = PBXBuildFile; fileRef = D45446E6156DE7F300887EB5 /* debian.plist */; }; + D454471E156DE7F300887EB5 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446E7156DE7F300887EB5 /* Default.png */; }; + D454471F156DE7F300887EB5 /* ExplodingRing.plist in Resources */ = {isa = PBXBuildFile; fileRef = D45446E8156DE7F300887EB5 /* ExplodingRing.plist */; }; + D4544720156DE7F300887EB5 /* f1-hd.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446E9156DE7F300887EB5 /* f1-hd.png */; }; + D4544721156DE7F300887EB5 /* f1-ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446EA156DE7F300887EB5 /* f1-ipad.png */; }; + D4544722156DE7F300887EB5 /* f1.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446EB156DE7F300887EB5 /* f1.png */; }; + D4544723156DE7F300887EB5 /* f2-hd.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446EC156DE7F300887EB5 /* f2-hd.png */; }; + D4544724156DE7F300887EB5 /* f2-ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446ED156DE7F300887EB5 /* f2-ipad.png */; }; + D4544725156DE7F300887EB5 /* f2.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446EE156DE7F300887EB5 /* f2.png */; }; + D4544726156DE7F300887EB5 /* Flower.plist in Resources */ = {isa = PBXBuildFile; fileRef = D45446EF156DE7F300887EB5 /* Flower.plist */; }; + D4544727156DE7F300887EB5 /* ForestFire.plist in Resources */ = {isa = PBXBuildFile; fileRef = D45446F0156DE7F300887EB5 /* ForestFire.plist */; }; + D4544728156DE7F300887EB5 /* Galaxy.plist in Resources */ = {isa = PBXBuildFile; fileRef = D45446F1156DE7F300887EB5 /* Galaxy.plist */; }; + D4544729156DE7F300887EB5 /* grossini_dance_05.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446F2156DE7F300887EB5 /* grossini_dance_05.png */; }; + D454472A156DE7F300887EB5 /* grossinis_sister1.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446F3156DE7F300887EB5 /* grossinis_sister1.png */; }; + D454472B156DE7F300887EB5 /* grossinis_sister2.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446F4156DE7F300887EB5 /* grossinis_sister2.png */; }; + D454472C156DE7F300887EB5 /* HelloWorld.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446F5156DE7F300887EB5 /* HelloWorld.png */; }; + D454472D156DE7F300887EB5 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446F6156DE7F300887EB5 /* Icon-72.png */; }; + D454472E156DE7F300887EB5 /* Icon-Small-50.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446F7156DE7F300887EB5 /* Icon-Small-50.png */; }; + D454472F156DE7F300887EB5 /* Icon-Small.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446F8156DE7F300887EB5 /* Icon-Small.png */; }; + D4544730156DE7F300887EB5 /* Icon-Small@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446F9156DE7F300887EB5 /* Icon-Small@2x.png */; }; + D4544731156DE7F300887EB5 /* Icon.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446FA156DE7F300887EB5 /* Icon.png */; }; + D4544732156DE7F300887EB5 /* Icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446FB156DE7F300887EB5 /* Icon@2x.png */; }; + D4544733156DE7F300887EB5 /* iTunesArtwork in Resources */ = {isa = PBXBuildFile; fileRef = D45446FC156DE7F300887EB5 /* iTunesArtwork */; }; + D4544734156DE7F300887EB5 /* LavaFlow.plist in Resources */ = {isa = PBXBuildFile; fileRef = D45446FD156DE7F300887EB5 /* LavaFlow.plist */; }; + D4544735156DE7F300887EB5 /* Phoenix.plist in Resources */ = {isa = PBXBuildFile; fileRef = D45446FE156DE7F300887EB5 /* Phoenix.plist */; }; + D4544736156DE7F300887EB5 /* r1-hd.png in Resources */ = {isa = PBXBuildFile; fileRef = D45446FF156DE7F300887EB5 /* r1-hd.png */; }; + D4544737156DE7F300887EB5 /* r1-ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = D4544700156DE7F300887EB5 /* r1-ipad.png */; }; + D4544738156DE7F300887EB5 /* r1.png in Resources */ = {isa = PBXBuildFile; fileRef = D4544701156DE7F300887EB5 /* r1.png */; }; + D4544739156DE7F300887EB5 /* r2-hd.png in Resources */ = {isa = PBXBuildFile; fileRef = D4544702156DE7F300887EB5 /* r2-hd.png */; }; + D454473A156DE7F300887EB5 /* r2-ipad.png in Resources */ = {isa = PBXBuildFile; fileRef = D4544703156DE7F300887EB5 /* r2-ipad.png */; }; + D454473B156DE7F300887EB5 /* r2.png in Resources */ = {isa = PBXBuildFile; fileRef = D4544704156DE7F300887EB5 /* r2.png */; }; + D454473C156DE7F300887EB5 /* Silly Fun Theme A.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = D4544705156DE7F300887EB5 /* Silly Fun Theme A.mp3 */; }; + D454473D156DE7F300887EB5 /* SmallSun.plist in Resources */ = {isa = PBXBuildFile; fileRef = D4544706156DE7F300887EB5 /* SmallSun.plist */; }; + D454473E156DE7F300887EB5 /* SpinningPeas.plist in Resources */ = {isa = PBXBuildFile; fileRef = D4544707156DE7F300887EB5 /* SpinningPeas.plist */; }; + D454473F156DE7F300887EB5 /* Spiral.plist in Resources */ = {isa = PBXBuildFile; fileRef = D4544708156DE7F300887EB5 /* Spiral.plist */; }; + D4544740156DE7F300887EB5 /* SpookyPeas.plist in Resources */ = {isa = PBXBuildFile; fileRef = D4544709156DE7F300887EB5 /* SpookyPeas.plist */; }; + D4544741156DE7F300887EB5 /* stars2.png in Resources */ = {isa = PBXBuildFile; fileRef = D454470A156DE7F300887EB5 /* stars2.png */; }; + D4544742156DE7F300887EB5 /* tank.plist in Resources */ = {isa = PBXBuildFile; fileRef = D454470B156DE7F300887EB5 /* tank.plist */; }; + D4544743156DE7F300887EB5 /* tank.png in Resources */ = {isa = PBXBuildFile; fileRef = D454470C156DE7F300887EB5 /* tank.png */; }; + D4544744156DE7F300887EB5 /* tank.tps in Resources */ = {isa = PBXBuildFile; fileRef = D454470D156DE7F300887EB5 /* tank.tps */; }; + D4544745156DE7F300887EB5 /* tank1.png in Resources */ = {isa = PBXBuildFile; fileRef = D454470E156DE7F300887EB5 /* tank1.png */; }; + D4544746156DE7F300887EB5 /* Upsidedown.plist in Resources */ = {isa = PBXBuildFile; fileRef = D454470F156DE7F300887EB5 /* Upsidedown.plist */; }; + D45451B3156E071600887EB5 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A922754D1517C094001B78AA /* Foundation.framework */; }; + D45451F9156E072400887EB5 /* Export.h in Headers */ = {isa = PBXBuildFile; fileRef = D45451C5156E072400887EB5 /* Export.h */; }; + D45451FA156E072400887EB5 /* SimpleAudioEngine.h in Headers */ = {isa = PBXBuildFile; fileRef = D45451C6156E072400887EB5 /* SimpleAudioEngine.h */; }; + D45451FB156E072400887EB5 /* CDAudioManager.h in Headers */ = {isa = PBXBuildFile; fileRef = D45451C8156E072400887EB5 /* CDAudioManager.h */; }; + D45451FC156E072400887EB5 /* CDAudioManager.m in Sources */ = {isa = PBXBuildFile; fileRef = D45451C9156E072400887EB5 /* CDAudioManager.m */; }; + D45451FD156E072400887EB5 /* CDConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = D45451CA156E072400887EB5 /* CDConfig.h */; }; + D45451FE156E072400887EB5 /* CDOpenALSupport.h in Headers */ = {isa = PBXBuildFile; fileRef = D45451CB156E072400887EB5 /* CDOpenALSupport.h */; }; + D45451FF156E072400887EB5 /* CDOpenALSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = D45451CC156E072400887EB5 /* CDOpenALSupport.m */; }; + D4545200156E072400887EB5 /* CocosDenshion.h in Headers */ = {isa = PBXBuildFile; fileRef = D45451CD156E072400887EB5 /* CocosDenshion.h */; }; + D4545201156E072400887EB5 /* CocosDenshion.m in Sources */ = {isa = PBXBuildFile; fileRef = D45451CE156E072400887EB5 /* CocosDenshion.m */; }; + D4545202156E072400887EB5 /* SimpleAudioEngine.mm in Sources */ = {isa = PBXBuildFile; fileRef = D45451CF156E072400887EB5 /* SimpleAudioEngine.mm */; }; + D4545203156E072400887EB5 /* SimpleAudioEngine_objc.h in Headers */ = {isa = PBXBuildFile; fileRef = D45451D0156E072400887EB5 /* SimpleAudioEngine_objc.h */; }; + D4545204156E072400887EB5 /* SimpleAudioEngine_objc.m in Sources */ = {isa = PBXBuildFile; fileRef = D45451D1156E072400887EB5 /* SimpleAudioEngine_objc.m */; }; + D4545208156E219600887EB5 /* libCocosDenshion.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D45451B2156E071600887EB5 /* libCocosDenshion.a */; }; + D454520A156E22B400887EB5 /* libxml2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D4545209156E22B400887EB5 /* libxml2.dylib */; }; + D454520C156E22BD00887EB5 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D454520B156E22BD00887EB5 /* libz.dylib */; }; + D4545227156E28EF00887EB5 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D4545215156E28EF00887EB5 /* AppDelegate.cpp */; }; +/* End PBXBuildFile section */ + +/* Begin PBXContainerItemProxy section */ + 159A666D15904899003AEEC0 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 159A666615904899003AEEC0 /* cocos2dx.xcodeproj */; + proxyType = 2; + remoteGlobalIDString = 1551A33F158F2AB200E66CFE; + remoteInfo = cocos2dx; + }; + 159A666F159048A4003AEEC0 /* PBXContainerItemProxy */ = { + isa = PBXContainerItemProxy; + containerPortal = 159A666615904899003AEEC0 /* cocos2dx.xcodeproj */; + proxyType = 1; + remoteGlobalIDString = 1551A33E158F2AB200E66CFE; + remoteInfo = cocos2dx; + }; +/* End PBXContainerItemProxy section */ + +/* Begin PBXFileReference section */ + 1554941915737858009041F8 /* JS */ = {isa = PBXFileReference; lastKnownFileType = folder; path = JS; sourceTree = ""; }; + 1554941B15737A4D009041F8 /* simple_class.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = simple_class.cpp; sourceTree = ""; }; + 1554941C15737A4D009041F8 /* simple_class.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = simple_class.h; sourceTree = ""; }; + 1554941D15737A4D009041F8 /* simple_native_generated.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = simple_native_generated.cpp; sourceTree = ""; }; + 1554941E15737A4D009041F8 /* simple_native_generated.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = simple_native_generated.hpp; sourceTree = ""; }; + 159A666615904899003AEEC0 /* cocos2dx.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2dx.xcodeproj; path = ../../cocos2dx/proj.ios/cocos2dx.xcodeproj; sourceTree = ""; }; + 15DD7073156F2C6A003E7567 /* fps_images.fnt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = fps_images.fnt; sourceTree = ""; }; + 15DD7074156F2C6A003E7567 /* fps_images.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = fps_images.png; sourceTree = ""; }; + A922753D1517C094001B78AA /* testjs.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = testjs.app; sourceTree = BUILT_PRODUCTS_DIR; }; + A92275411517C094001B78AA /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; + A92275431517C094001B78AA /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; + A92275451517C094001B78AA /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; + A92275471517C094001B78AA /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; + A92275491517C094001B78AA /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; + A922754B1517C094001B78AA /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; + A922754D1517C094001B78AA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; + A922754F1517C094001B78AA /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; + D45440B4156DE56B00887EB5 /* cocos2d_generated.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cocos2d_generated.cpp; sourceTree = ""; }; + D45440B5156DE56B00887EB5 /* cocos2d_generated.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cocos2d_generated.hpp; sourceTree = ""; }; + D45440B6156DE56B00887EB5 /* cocos2d_manual_bindings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cocos2d_manual_bindings.cpp; sourceTree = ""; }; + D45440B7156DE56B00887EB5 /* cocos_denshion_generated.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = cocos_denshion_generated.cpp; sourceTree = ""; }; + D45440B8156DE56B00887EB5 /* cocos_denshion_generated.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = cocos_denshion_generated.hpp; sourceTree = ""; }; + D45440BA156DE56B00887EB5 /* ScriptingCore.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ScriptingCore.cpp; sourceTree = ""; }; + D45440BB156DE56B00887EB5 /* ScriptingCore.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptingCore.h; sourceTree = ""; }; + D45446CD156DE74F00887EB5 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = ""; }; + D45446CE156DE74F00887EB5 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = ""; }; + D45446CF156DE74F00887EB5 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; + D45446D0156DE74F00887EB5 /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; }; + D45446D1156DE74F00887EB5 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RootViewController.h; sourceTree = ""; }; + D45446D2156DE74F00887EB5 /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = RootViewController.mm; sourceTree = ""; }; + D45446D6156DE79D00887EB5 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + D45446D9156DE7F300887EB5 /* b1-hd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "b1-hd.png"; sourceTree = ""; }; + D45446DA156DE7F300887EB5 /* b1-ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "b1-ipad.png"; sourceTree = ""; }; + D45446DB156DE7F300887EB5 /* b1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = b1.png; sourceTree = ""; }; + D45446DC156DE7F300887EB5 /* b2-hd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "b2-hd.png"; sourceTree = ""; }; + D45446DD156DE7F300887EB5 /* b2-ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "b2-ipad.png"; sourceTree = ""; }; + D45446DE156DE7F300887EB5 /* b2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = b2.png; sourceTree = ""; }; + D45446DF156DE7F300887EB5 /* background.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = background.png; sourceTree = ""; }; + D45446E0156DE7F300887EB5 /* ballbounce.wav */ = {isa = PBXFileReference; lastKnownFileType = audio.wav; path = ballbounce.wav; sourceTree = ""; }; + D45446E1156DE7F300887EB5 /* BoilingFoam.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = BoilingFoam.plist; sourceTree = ""; }; + D45446E2156DE7F300887EB5 /* BurstPipe.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = BurstPipe.plist; sourceTree = ""; }; + D45446E3156DE7F300887EB5 /* CloseNormal.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = CloseNormal.png; sourceTree = ""; }; + D45446E4156DE7F300887EB5 /* CloseSelected.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = CloseSelected.png; sourceTree = ""; }; + D45446E5156DE7F300887EB5 /* Comet.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Comet.plist; sourceTree = ""; }; + D45446E6156DE7F300887EB5 /* debian.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = debian.plist; sourceTree = ""; }; + D45446E7156DE7F300887EB5 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; + D45446E8156DE7F300887EB5 /* ExplodingRing.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = ExplodingRing.plist; sourceTree = ""; }; + D45446E9156DE7F300887EB5 /* f1-hd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "f1-hd.png"; sourceTree = ""; }; + D45446EA156DE7F300887EB5 /* f1-ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "f1-ipad.png"; sourceTree = ""; }; + D45446EB156DE7F300887EB5 /* f1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = f1.png; sourceTree = ""; }; + D45446EC156DE7F300887EB5 /* f2-hd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "f2-hd.png"; sourceTree = ""; }; + D45446ED156DE7F300887EB5 /* f2-ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "f2-ipad.png"; sourceTree = ""; }; + D45446EE156DE7F300887EB5 /* f2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = f2.png; sourceTree = ""; }; + D45446EF156DE7F300887EB5 /* Flower.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Flower.plist; sourceTree = ""; }; + D45446F0156DE7F300887EB5 /* ForestFire.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = ForestFire.plist; sourceTree = ""; }; + D45446F1156DE7F300887EB5 /* Galaxy.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Galaxy.plist; sourceTree = ""; }; + D45446F2156DE7F300887EB5 /* grossini_dance_05.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = grossini_dance_05.png; sourceTree = ""; }; + D45446F3156DE7F300887EB5 /* grossinis_sister1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = grossinis_sister1.png; sourceTree = ""; }; + D45446F4156DE7F300887EB5 /* grossinis_sister2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = grossinis_sister2.png; sourceTree = ""; }; + D45446F5156DE7F300887EB5 /* HelloWorld.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = HelloWorld.png; sourceTree = ""; }; + D45446F6156DE7F300887EB5 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-72.png"; sourceTree = ""; }; + D45446F7156DE7F300887EB5 /* Icon-Small-50.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-Small-50.png"; sourceTree = ""; }; + D45446F8156DE7F300887EB5 /* Icon-Small.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-Small.png"; sourceTree = ""; }; + D45446F9156DE7F300887EB5 /* Icon-Small@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon-Small@2x.png"; sourceTree = ""; }; + D45446FA156DE7F300887EB5 /* Icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Icon.png; sourceTree = ""; }; + D45446FB156DE7F300887EB5 /* Icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Icon@2x.png"; sourceTree = ""; }; + D45446FC156DE7F300887EB5 /* iTunesArtwork */ = {isa = PBXFileReference; lastKnownFileType = file; path = iTunesArtwork; sourceTree = ""; }; + D45446FD156DE7F300887EB5 /* LavaFlow.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = LavaFlow.plist; sourceTree = ""; }; + D45446FE156DE7F300887EB5 /* Phoenix.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Phoenix.plist; sourceTree = ""; }; + D45446FF156DE7F300887EB5 /* r1-hd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "r1-hd.png"; sourceTree = ""; }; + D4544700156DE7F300887EB5 /* r1-ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "r1-ipad.png"; sourceTree = ""; }; + D4544701156DE7F300887EB5 /* r1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = r1.png; sourceTree = ""; }; + D4544702156DE7F300887EB5 /* r2-hd.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "r2-hd.png"; sourceTree = ""; }; + D4544703156DE7F300887EB5 /* r2-ipad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "r2-ipad.png"; sourceTree = ""; }; + D4544704156DE7F300887EB5 /* r2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = r2.png; sourceTree = ""; }; + D4544705156DE7F300887EB5 /* Silly Fun Theme A.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = "Silly Fun Theme A.mp3"; sourceTree = ""; }; + D4544706156DE7F300887EB5 /* SmallSun.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = SmallSun.plist; sourceTree = ""; }; + D4544707156DE7F300887EB5 /* SpinningPeas.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = SpinningPeas.plist; sourceTree = ""; }; + D4544708156DE7F300887EB5 /* Spiral.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Spiral.plist; sourceTree = ""; }; + D4544709156DE7F300887EB5 /* SpookyPeas.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = SpookyPeas.plist; sourceTree = ""; }; + D454470A156DE7F300887EB5 /* stars2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = stars2.png; sourceTree = ""; }; + D454470B156DE7F300887EB5 /* tank.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = tank.plist; sourceTree = ""; }; + D454470C156DE7F300887EB5 /* tank.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = tank.png; sourceTree = ""; }; + D454470D156DE7F300887EB5 /* tank.tps */ = {isa = PBXFileReference; lastKnownFileType = file; path = tank.tps; sourceTree = ""; }; + D454470E156DE7F300887EB5 /* tank1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = tank1.png; sourceTree = ""; }; + D454470F156DE7F300887EB5 /* Upsidedown.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Upsidedown.plist; sourceTree = ""; }; + D45451B2156E071600887EB5 /* libCocosDenshion.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCocosDenshion.a; sourceTree = BUILT_PRODUCTS_DIR; }; + D45451C5156E072400887EB5 /* Export.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Export.h; sourceTree = ""; }; + D45451C6156E072400887EB5 /* SimpleAudioEngine.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleAudioEngine.h; sourceTree = ""; }; + D45451C8156E072400887EB5 /* CDAudioManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDAudioManager.h; sourceTree = ""; }; + D45451C9156E072400887EB5 /* CDAudioManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDAudioManager.m; sourceTree = ""; }; + D45451CA156E072400887EB5 /* CDConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDConfig.h; sourceTree = ""; }; + D45451CB156E072400887EB5 /* CDOpenALSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CDOpenALSupport.h; sourceTree = ""; }; + D45451CC156E072400887EB5 /* CDOpenALSupport.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CDOpenALSupport.m; sourceTree = ""; }; + D45451CD156E072400887EB5 /* CocosDenshion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CocosDenshion.h; sourceTree = ""; }; + D45451CE156E072400887EB5 /* CocosDenshion.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CocosDenshion.m; sourceTree = ""; }; + D45451CF156E072400887EB5 /* SimpleAudioEngine.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SimpleAudioEngine.mm; sourceTree = ""; }; + D45451D0156E072400887EB5 /* SimpleAudioEngine_objc.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SimpleAudioEngine_objc.h; sourceTree = ""; }; + D45451D1156E072400887EB5 /* SimpleAudioEngine_objc.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SimpleAudioEngine_objc.m; sourceTree = ""; }; + D4545209156E22B400887EB5 /* libxml2.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libxml2.dylib; path = usr/lib/libxml2.dylib; sourceTree = SDKROOT; }; + D454520B156E22BD00887EB5 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; + D4545215156E28EF00887EB5 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = ""; }; + D4545216156E28EF00887EB5 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + A922753A1517C094001B78AA /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 159A6671159048C8003AEEC0 /* libcocos2dx.a in Frameworks */, + D454520C156E22BD00887EB5 /* libz.dylib in Frameworks */, + D454520A156E22B400887EB5 /* libxml2.dylib in Frameworks */, + D4545208156E219600887EB5 /* libCocosDenshion.a in Frameworks */, + A92275421517C094001B78AA /* QuartzCore.framework in Frameworks */, + A92275441517C094001B78AA /* OpenGLES.framework in Frameworks */, + A92275461517C094001B78AA /* OpenAL.framework in Frameworks */, + A92275481517C094001B78AA /* AudioToolbox.framework in Frameworks */, + A922754A1517C094001B78AA /* AVFoundation.framework in Frameworks */, + A922754C1517C094001B78AA /* UIKit.framework in Frameworks */, + A922754E1517C094001B78AA /* Foundation.framework in Frameworks */, + A92275501517C094001B78AA /* CoreGraphics.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D45451AF156E071600887EB5 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + D45451B3156E071600887EB5 /* Foundation.framework in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 159A666715904899003AEEC0 /* Products */ = { + isa = PBXGroup; + children = ( + 159A666E15904899003AEEC0 /* libcocos2dx.a */, + ); + name = Products; + sourceTree = ""; + }; + A92275321517C094001B78AA = { + isa = PBXGroup; + children = ( + 159A666615904899003AEEC0 /* cocos2dx.xcodeproj */, + D4545214156E28EF00887EB5 /* Classes */, + D45451BD156E072400887EB5 /* CocosDenshion */, + D45446D8156DE7F300887EB5 /* Resources */, + D45446CC156DE73F00887EB5 /* ios */, + D45440AC156DE56B00887EB5 /* JS */, + A92275401517C094001B78AA /* Frameworks */, + A922753E1517C094001B78AA /* Products */, + ); + sourceTree = ""; + }; + A922753E1517C094001B78AA /* Products */ = { + isa = PBXGroup; + children = ( + A922753D1517C094001B78AA /* testjs.app */, + D45451B2156E071600887EB5 /* libCocosDenshion.a */, + ); + name = Products; + sourceTree = ""; + }; + A92275401517C094001B78AA /* Frameworks */ = { + isa = PBXGroup; + children = ( + D454520B156E22BD00887EB5 /* libz.dylib */, + D4545209156E22B400887EB5 /* libxml2.dylib */, + A92275411517C094001B78AA /* QuartzCore.framework */, + A92275431517C094001B78AA /* OpenGLES.framework */, + A92275451517C094001B78AA /* OpenAL.framework */, + A92275471517C094001B78AA /* AudioToolbox.framework */, + A92275491517C094001B78AA /* AVFoundation.framework */, + A922754B1517C094001B78AA /* UIKit.framework */, + A922754D1517C094001B78AA /* Foundation.framework */, + A922754F1517C094001B78AA /* CoreGraphics.framework */, + ); + name = Frameworks; + sourceTree = ""; + }; + D45440AC156DE56B00887EB5 /* JS */ = { + isa = PBXGroup; + children = ( + D45440B3156DE56B00887EB5 /* JSBindings */, + ); + name = JS; + path = ../../js; + sourceTree = ""; + }; + D45440B3156DE56B00887EB5 /* JSBindings */ = { + isa = PBXGroup; + children = ( + D45440B4156DE56B00887EB5 /* cocos2d_generated.cpp */, + D45440B5156DE56B00887EB5 /* cocos2d_generated.hpp */, + D45440B6156DE56B00887EB5 /* cocos2d_manual_bindings.cpp */, + D45440B7156DE56B00887EB5 /* cocos_denshion_generated.cpp */, + D45440B8156DE56B00887EB5 /* cocos_denshion_generated.hpp */, + D45440BA156DE56B00887EB5 /* ScriptingCore.cpp */, + D45440BB156DE56B00887EB5 /* ScriptingCore.h */, + ); + path = JSBindings; + sourceTree = ""; + }; + D45446CC156DE73F00887EB5 /* ios */ = { + isa = PBXGroup; + children = ( + D45446D6156DE79D00887EB5 /* Info.plist */, + D45446CD156DE74F00887EB5 /* AppController.h */, + D45446CE156DE74F00887EB5 /* AppController.mm */, + D45446CF156DE74F00887EB5 /* main.m */, + D45446D0156DE74F00887EB5 /* Prefix.pch */, + D45446D1156DE74F00887EB5 /* RootViewController.h */, + D45446D2156DE74F00887EB5 /* RootViewController.mm */, + ); + name = ios; + sourceTree = ""; + }; + D45446D8156DE7F300887EB5 /* Resources */ = { + isa = PBXGroup; + children = ( + 1554941915737858009041F8 /* JS */, + 15DD7073156F2C6A003E7567 /* fps_images.fnt */, + 15DD7074156F2C6A003E7567 /* fps_images.png */, + D4544747156DE80400887EB5 /* Particles */, + D45446D9156DE7F300887EB5 /* b1-hd.png */, + D45446DA156DE7F300887EB5 /* b1-ipad.png */, + D45446DB156DE7F300887EB5 /* b1.png */, + D45446DC156DE7F300887EB5 /* b2-hd.png */, + D45446DD156DE7F300887EB5 /* b2-ipad.png */, + D45446DE156DE7F300887EB5 /* b2.png */, + D45446DF156DE7F300887EB5 /* background.png */, + D45446E0156DE7F300887EB5 /* ballbounce.wav */, + D45446E3156DE7F300887EB5 /* CloseNormal.png */, + D45446E4156DE7F300887EB5 /* CloseSelected.png */, + D45446E7156DE7F300887EB5 /* Default.png */, + D45446E9156DE7F300887EB5 /* f1-hd.png */, + D45446EA156DE7F300887EB5 /* f1-ipad.png */, + D45446EB156DE7F300887EB5 /* f1.png */, + D45446EC156DE7F300887EB5 /* f2-hd.png */, + D45446ED156DE7F300887EB5 /* f2-ipad.png */, + D45446EE156DE7F300887EB5 /* f2.png */, + D45446F2156DE7F300887EB5 /* grossini_dance_05.png */, + D45446F3156DE7F300887EB5 /* grossinis_sister1.png */, + D45446F4156DE7F300887EB5 /* grossinis_sister2.png */, + D45446F5156DE7F300887EB5 /* HelloWorld.png */, + D45446F6156DE7F300887EB5 /* Icon-72.png */, + D45446F7156DE7F300887EB5 /* Icon-Small-50.png */, + D45446F8156DE7F300887EB5 /* Icon-Small.png */, + D45446F9156DE7F300887EB5 /* Icon-Small@2x.png */, + D45446FA156DE7F300887EB5 /* Icon.png */, + D45446FB156DE7F300887EB5 /* Icon@2x.png */, + D45446FC156DE7F300887EB5 /* iTunesArtwork */, + D45446FF156DE7F300887EB5 /* r1-hd.png */, + D4544700156DE7F300887EB5 /* r1-ipad.png */, + D4544701156DE7F300887EB5 /* r1.png */, + D4544702156DE7F300887EB5 /* r2-hd.png */, + D4544703156DE7F300887EB5 /* r2-ipad.png */, + D4544704156DE7F300887EB5 /* r2.png */, + D4544705156DE7F300887EB5 /* Silly Fun Theme A.mp3 */, + D454470B156DE7F300887EB5 /* tank.plist */, + D454470C156DE7F300887EB5 /* tank.png */, + D454470D156DE7F300887EB5 /* tank.tps */, + D454470E156DE7F300887EB5 /* tank1.png */, + ); + name = Resources; + path = ../Resources; + sourceTree = ""; + }; + D4544747156DE80400887EB5 /* Particles */ = { + isa = PBXGroup; + children = ( + D454470A156DE7F300887EB5 /* stars2.png */, + D45446F0156DE7F300887EB5 /* ForestFire.plist */, + D45446E1156DE7F300887EB5 /* BoilingFoam.plist */, + D45446E2156DE7F300887EB5 /* BurstPipe.plist */, + D45446E5156DE7F300887EB5 /* Comet.plist */, + D45446E6156DE7F300887EB5 /* debian.plist */, + D45446E8156DE7F300887EB5 /* ExplodingRing.plist */, + D45446EF156DE7F300887EB5 /* Flower.plist */, + D45446F1156DE7F300887EB5 /* Galaxy.plist */, + D45446FD156DE7F300887EB5 /* LavaFlow.plist */, + D45446FE156DE7F300887EB5 /* Phoenix.plist */, + D4544706156DE7F300887EB5 /* SmallSun.plist */, + D4544707156DE7F300887EB5 /* SpinningPeas.plist */, + D4544708156DE7F300887EB5 /* Spiral.plist */, + D4544709156DE7F300887EB5 /* SpookyPeas.plist */, + D454470F156DE7F300887EB5 /* Upsidedown.plist */, + ); + name = Particles; + sourceTree = ""; + }; + D45451BD156E072400887EB5 /* CocosDenshion */ = { + isa = PBXGroup; + children = ( + D45451C4156E072400887EB5 /* include */, + D45451C7156E072400887EB5 /* ios */, + ); + name = CocosDenshion; + path = ../../CocosDenshion; + sourceTree = ""; + }; + D45451C4156E072400887EB5 /* include */ = { + isa = PBXGroup; + children = ( + D45451C5156E072400887EB5 /* Export.h */, + D45451C6156E072400887EB5 /* SimpleAudioEngine.h */, + ); + path = include; + sourceTree = ""; + }; + D45451C7156E072400887EB5 /* ios */ = { + isa = PBXGroup; + children = ( + D45451C8156E072400887EB5 /* CDAudioManager.h */, + D45451C9156E072400887EB5 /* CDAudioManager.m */, + D45451CA156E072400887EB5 /* CDConfig.h */, + D45451CB156E072400887EB5 /* CDOpenALSupport.h */, + D45451CC156E072400887EB5 /* CDOpenALSupport.m */, + D45451CD156E072400887EB5 /* CocosDenshion.h */, + D45451CE156E072400887EB5 /* CocosDenshion.m */, + D45451CF156E072400887EB5 /* SimpleAudioEngine.mm */, + D45451D0156E072400887EB5 /* SimpleAudioEngine_objc.h */, + D45451D1156E072400887EB5 /* SimpleAudioEngine_objc.m */, + ); + path = ios; + sourceTree = ""; + }; + D4545214156E28EF00887EB5 /* Classes */ = { + isa = PBXGroup; + children = ( + 1554941B15737A4D009041F8 /* simple_class.cpp */, + 1554941C15737A4D009041F8 /* simple_class.h */, + 1554941D15737A4D009041F8 /* simple_native_generated.cpp */, + 1554941E15737A4D009041F8 /* simple_native_generated.hpp */, + D4545215156E28EF00887EB5 /* AppDelegate.cpp */, + D4545216156E28EF00887EB5 /* AppDelegate.h */, + ); + name = Classes; + path = ../Classes; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXHeadersBuildPhase section */ + D45451B0156E071600887EB5 /* Headers */ = { + isa = PBXHeadersBuildPhase; + buildActionMask = 2147483647; + files = ( + D45451F9156E072400887EB5 /* Export.h in Headers */, + D45451FA156E072400887EB5 /* SimpleAudioEngine.h in Headers */, + D45451FB156E072400887EB5 /* CDAudioManager.h in Headers */, + D45451FD156E072400887EB5 /* CDConfig.h in Headers */, + D45451FE156E072400887EB5 /* CDOpenALSupport.h in Headers */, + D4545200156E072400887EB5 /* CocosDenshion.h in Headers */, + D4545203156E072400887EB5 /* SimpleAudioEngine_objc.h in Headers */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXHeadersBuildPhase section */ + +/* Begin PBXNativeTarget section */ + A922753C1517C094001B78AA /* testjs */ = { + isa = PBXNativeTarget; + buildConfigurationList = A92277001517C097001B78AA /* Build configuration list for PBXNativeTarget "testjs" */; + buildPhases = ( + A92275391517C094001B78AA /* Sources */, + A922753A1517C094001B78AA /* Frameworks */, + A922753B1517C094001B78AA /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + 159A6670159048A4003AEEC0 /* PBXTargetDependency */, + ); + name = testjs; + productName = testjs; + productReference = A922753D1517C094001B78AA /* testjs.app */; + productType = "com.apple.product-type.application"; + }; + D45451B1156E071600887EB5 /* CocosDenshion */ = { + isa = PBXNativeTarget; + buildConfigurationList = D45451BA156E071600887EB5 /* Build configuration list for PBXNativeTarget "CocosDenshion" */; + buildPhases = ( + D45451AE156E071600887EB5 /* Sources */, + D45451AF156E071600887EB5 /* Frameworks */, + D45451B0156E071600887EB5 /* Headers */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = CocosDenshion; + productName = CocosDenshion; + productReference = D45451B2156E071600887EB5 /* libCocosDenshion.a */; + productType = "com.apple.product-type.library.static"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + A92275341517C094001B78AA /* Project object */ = { + isa = PBXProject; + attributes = { + LastUpgradeCheck = 0430; + }; + buildConfigurationList = A92275371517C094001B78AA /* Build configuration list for PBXProject "testjs" */; + compatibilityVersion = "Xcode 3.2"; + developmentRegion = English; + hasScannedForEncodings = 0; + knownRegions = ( + en, + ); + mainGroup = A92275321517C094001B78AA; + productRefGroup = A922753E1517C094001B78AA /* Products */; + projectDirPath = ""; + projectReferences = ( + { + ProductGroup = 159A666715904899003AEEC0 /* Products */; + ProjectRef = 159A666615904899003AEEC0 /* cocos2dx.xcodeproj */; + }, + ); + projectRoot = ""; + targets = ( + A922753C1517C094001B78AA /* testjs */, + D45451B1156E071600887EB5 /* CocosDenshion */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXReferenceProxy section */ + 159A666E15904899003AEEC0 /* libcocos2dx.a */ = { + isa = PBXReferenceProxy; + fileType = archive.ar; + path = libcocos2dx.a; + remoteRef = 159A666D15904899003AEEC0 /* PBXContainerItemProxy */; + sourceTree = BUILT_PRODUCTS_DIR; + }; +/* End PBXReferenceProxy section */ + +/* Begin PBXResourcesBuildPhase section */ + A922753B1517C094001B78AA /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D4544710156DE7F300887EB5 /* b1-hd.png in Resources */, + D4544711156DE7F300887EB5 /* b1-ipad.png in Resources */, + D4544712156DE7F300887EB5 /* b1.png in Resources */, + D4544713156DE7F300887EB5 /* b2-hd.png in Resources */, + D4544714156DE7F300887EB5 /* b2-ipad.png in Resources */, + D4544715156DE7F300887EB5 /* b2.png in Resources */, + D4544716156DE7F300887EB5 /* background.png in Resources */, + D4544717156DE7F300887EB5 /* ballbounce.wav in Resources */, + D4544718156DE7F300887EB5 /* BoilingFoam.plist in Resources */, + D4544719156DE7F300887EB5 /* BurstPipe.plist in Resources */, + D454471A156DE7F300887EB5 /* CloseNormal.png in Resources */, + D454471B156DE7F300887EB5 /* CloseSelected.png in Resources */, + D454471C156DE7F300887EB5 /* Comet.plist in Resources */, + D454471D156DE7F300887EB5 /* debian.plist in Resources */, + D454471E156DE7F300887EB5 /* Default.png in Resources */, + D454471F156DE7F300887EB5 /* ExplodingRing.plist in Resources */, + D4544720156DE7F300887EB5 /* f1-hd.png in Resources */, + D4544721156DE7F300887EB5 /* f1-ipad.png in Resources */, + D4544722156DE7F300887EB5 /* f1.png in Resources */, + D4544723156DE7F300887EB5 /* f2-hd.png in Resources */, + D4544724156DE7F300887EB5 /* f2-ipad.png in Resources */, + D4544725156DE7F300887EB5 /* f2.png in Resources */, + D4544726156DE7F300887EB5 /* Flower.plist in Resources */, + D4544727156DE7F300887EB5 /* ForestFire.plist in Resources */, + D4544728156DE7F300887EB5 /* Galaxy.plist in Resources */, + D4544729156DE7F300887EB5 /* grossini_dance_05.png in Resources */, + D454472A156DE7F300887EB5 /* grossinis_sister1.png in Resources */, + D454472B156DE7F300887EB5 /* grossinis_sister2.png in Resources */, + D454472C156DE7F300887EB5 /* HelloWorld.png in Resources */, + D454472D156DE7F300887EB5 /* Icon-72.png in Resources */, + D454472E156DE7F300887EB5 /* Icon-Small-50.png in Resources */, + D454472F156DE7F300887EB5 /* Icon-Small.png in Resources */, + D4544730156DE7F300887EB5 /* Icon-Small@2x.png in Resources */, + D4544731156DE7F300887EB5 /* Icon.png in Resources */, + D4544732156DE7F300887EB5 /* Icon@2x.png in Resources */, + D4544733156DE7F300887EB5 /* iTunesArtwork in Resources */, + D4544734156DE7F300887EB5 /* LavaFlow.plist in Resources */, + D4544735156DE7F300887EB5 /* Phoenix.plist in Resources */, + D4544736156DE7F300887EB5 /* r1-hd.png in Resources */, + D4544737156DE7F300887EB5 /* r1-ipad.png in Resources */, + D4544738156DE7F300887EB5 /* r1.png in Resources */, + D4544739156DE7F300887EB5 /* r2-hd.png in Resources */, + D454473A156DE7F300887EB5 /* r2-ipad.png in Resources */, + D454473B156DE7F300887EB5 /* r2.png in Resources */, + D454473C156DE7F300887EB5 /* Silly Fun Theme A.mp3 in Resources */, + D454473D156DE7F300887EB5 /* SmallSun.plist in Resources */, + D454473E156DE7F300887EB5 /* SpinningPeas.plist in Resources */, + D454473F156DE7F300887EB5 /* Spiral.plist in Resources */, + D4544740156DE7F300887EB5 /* SpookyPeas.plist in Resources */, + D4544741156DE7F300887EB5 /* stars2.png in Resources */, + D4544742156DE7F300887EB5 /* tank.plist in Resources */, + D4544743156DE7F300887EB5 /* tank.png in Resources */, + D4544744156DE7F300887EB5 /* tank.tps in Resources */, + D4544745156DE7F300887EB5 /* tank1.png in Resources */, + D4544746156DE7F300887EB5 /* Upsidedown.plist in Resources */, + 15DD7075156F2C6A003E7567 /* fps_images.fnt in Resources */, + 15DD7076156F2C6A003E7567 /* fps_images.png in Resources */, + 1554941A15737858009041F8 /* JS in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + A92275391517C094001B78AA /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D4544505156DE56E00887EB5 /* cocos2d_generated.cpp in Sources */, + D4544506156DE56E00887EB5 /* cocos2d_manual_bindings.cpp in Sources */, + D4544507156DE56E00887EB5 /* cocos_denshion_generated.cpp in Sources */, + D4544509156DE56E00887EB5 /* ScriptingCore.cpp in Sources */, + D45446D3156DE74F00887EB5 /* AppController.mm in Sources */, + D45446D4156DE74F00887EB5 /* main.m in Sources */, + D45446D5156DE74F00887EB5 /* RootViewController.mm in Sources */, + D4545227156E28EF00887EB5 /* AppDelegate.cpp in Sources */, + 1554941F15737A4D009041F8 /* simple_class.cpp in Sources */, + 1554942015737A4D009041F8 /* simple_native_generated.cpp in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; + D45451AE156E071600887EB5 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + D45451FC156E072400887EB5 /* CDAudioManager.m in Sources */, + D45451FF156E072400887EB5 /* CDOpenALSupport.m in Sources */, + D4545201156E072400887EB5 /* CocosDenshion.m in Sources */, + D4545202156E072400887EB5 /* SimpleAudioEngine.mm in Sources */, + D4545204156E072400887EB5 /* SimpleAudioEngine_objc.m in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXTargetDependency section */ + 159A6670159048A4003AEEC0 /* PBXTargetDependency */ = { + isa = PBXTargetDependency; + name = cocos2dx; + targetProxy = 159A666F159048A4003AEEC0 /* PBXContainerItemProxy */; + }; +/* End PBXTargetDependency section */ + +/* Begin XCBuildConfiguration section */ + A92276FE1517C097001B78AA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + DEBUG, + "COCOS2D_DEBUG=1", + USE_FILE32API, + TARGET_OS_IPHONE, + ); + GCC_SYMBOLS_PRIVATE_EXTERN = NO; + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "\"$(PROJECT_NAME)/libs/cocos2dx\"", + "\"$(PROJECT_NAME)/libs/CocosDenshion/include\"", + "\"$(SDKROOT)/usr/include/libxml2\"", + ); + IPHONEOS_DEPLOYMENT_TARGET = 5.1; + SDKROOT = iphoneos; + }; + name = Debug; + }; + A92276FF1517C097001B78AA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ARCHS = "$(ARCHS_STANDARD_32_BIT)"; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; + GCC_C_LANGUAGE_STANDARD = gnu99; + GCC_PREPROCESSOR_DEFINITIONS = ( + NDEBUG, + USE_FILE32API, + TARGET_OS_IPHONE, + ); + GCC_WARN_ABOUT_RETURN_TYPE = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + HEADER_SEARCH_PATHS = ( + "\"$(PROJECT_NAME)/libs/cocos2dx\"", + "\"$(PROJECT_NAME)/libs/CocosDenshion/include\"", + "\"$(SDKROOT)/usr/include/libxml2\"", + ); + IPHONEOS_DEPLOYMENT_TARGET = 5.1; + OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; + SDKROOT = iphoneos; + }; + name = Release; + }; + A92277011517C097001B78AA /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = NO; + GCC_DYNAMIC_NO_PIC = NO; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = Prefix.pch; + "GCC_THUMB_SUPPORT[arch=armv6]" = ""; + HEADER_SEARCH_PATHS = ( + "\"$(SRCROOT)/../../cocos2dx\"", + "\"$(SRCROOT)/../../cocos2dx/kazmath/include\"", + "\"$(SRCROOT)/../../CocosDenshion/include\"", + "\"$(SDKROOT)/usr/include/libxml2\"", + "\"$(SRCROOT)/../../js/spidermonkey-ios/include\"", + "\"$(SRCROOT)/../../js/JSBindings\"", + "$(SRCROOT)/../../cocos2dx/include", + "$(SRCROOT)/../../cocos2dx/platform/ios", + ); + INFOPLIST_FILE = Info.plist; + LIBRARY_SEARCH_PATHS = ( + "\"$(SRCROOT)/../../js/spidermonkey-ios/lib\"", + "\"$(SRCROOT)/../../cocos2dx/platform/third_party/ios/libraries\"", + ); + OTHER_LDFLAGS = ( + "-lxml2", + "-lz", + "-ljs_static", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + WRAPPER_EXTENSION = app; + }; + name = Debug; + }; + A92277021517C097001B78AA /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = YES; + GCC_PRECOMPILE_PREFIX_HEADER = YES; + GCC_PREFIX_HEADER = Prefix.pch; + "GCC_THUMB_SUPPORT[arch=armv6]" = ""; + HEADER_SEARCH_PATHS = ( + "\"$(SRCROOT)/../../cocos2dx\"", + "\"$(SRCROOT)/../../cocos2dx/kazmath/include\"", + "\"$(SRCROOT)/../../CocosDenshion/include\"", + "\"$(SDKROOT)/usr/include/libxml2\"", + "\"$(SRCROOT)/../../js/spidermonkey-ios/include\"", + "\"$(SRCROOT)/../../js/JSBindings\"", + "$(SRCROOT)/../../cocos2dx/include", + "$(SRCROOT)/../../cocos2dx/platform/ios", + ); + INFOPLIST_FILE = Info.plist; + LIBRARY_SEARCH_PATHS = ( + "\"$(SRCROOT)/../../js/spidermonkey-ios/lib\"", + "\"$(SRCROOT)/../../cocos2dx/platform/third_party/ios/libraries\"", + ); + OTHER_LDFLAGS = ( + "-lxml2", + "-lz", + "-ljs_static", + ); + PRODUCT_NAME = "$(TARGET_NAME)"; + VALIDATE_PRODUCT = YES; + WRAPPER_EXTENSION = app; + }; + name = Release; + }; + D45451BB156E071600887EB5 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = NO; + DSTROOT = /tmp/CocosDenshion.dst; + GCC_DYNAMIC_NO_PIC = NO; + GCC_PRECOMPILE_PREFIX_HEADER = NO; + GCC_PREFIX_HEADER = ""; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + }; + name = Debug; + }; + D45451BC156E071600887EB5 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + COPY_PHASE_STRIP = YES; + DSTROOT = /tmp/CocosDenshion.dst; + GCC_PRECOMPILE_PREFIX_HEADER = NO; + GCC_PREFIX_HEADER = ""; + GCC_VERSION = com.apple.compilers.llvm.clang.1_0; + GCC_WARN_UNINITIALIZED_AUTOS = YES; + OTHER_LDFLAGS = "-ObjC"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SKIP_INSTALL = YES; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + A92275371517C094001B78AA /* Build configuration list for PBXProject "testjs" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A92276FE1517C097001B78AA /* Debug */, + A92276FF1517C097001B78AA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + A92277001517C097001B78AA /* Build configuration list for PBXNativeTarget "testjs" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + A92277011517C097001B78AA /* Debug */, + A92277021517C097001B78AA /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + D45451BA156E071600887EB5 /* Build configuration list for PBXNativeTarget "CocosDenshion" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + D45451BB156E071600887EB5 /* Debug */, + D45451BC156E071600887EB5 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + }; + rootObject = A92275341517C094001B78AA /* Project object */; +} diff --git a/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id b/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id deleted file mode 100644 index ee865c2c7b..0000000000 --- a/testjs/proj.ios/testjs.xcodeproj/project.pbxproj.REMOVED.git-id +++ /dev/null @@ -1 +0,0 @@ -36966a60baa47675db677ea1bbb2cc5eb30d2fe6 \ No newline at end of file diff --git a/tests/AppDelegate.h b/tests/AppDelegate.h index 76c1c6089f..268c6c6504 100644 --- a/tests/AppDelegate.h +++ b/tests/AppDelegate.h @@ -1,7 +1,7 @@ #ifndef _APP_DELEGATE_H_ #define _APP_DELEGATE_H_ -#include "CCApplication.h" +#include "cocos2d.h" /** @brief The cocos2d Application. diff --git a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id index b020f13da9..4f52665cff 100644 --- a/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id +++ b/tests/proj.ios/test.xcodeproj/project.pbxproj.REMOVED.git-id @@ -1 +1 @@ -cf47c05a8260b8bdde74155d3dc2382ae9735b76 \ No newline at end of file +b6dbd4e646f8633a38bbdc3015458ad20c9cc8a8 \ No newline at end of file diff --git a/tests/tests/ActionsTest/ActionsTest.cpp b/tests/tests/ActionsTest/ActionsTest.cpp index c9ea475e42..b90cfc96af 100644 --- a/tests/tests/ActionsTest/ActionsTest.cpp +++ b/tests/tests/ActionsTest/ActionsTest.cpp @@ -1,6 +1,7 @@ #include "ActionsTest.h" -#include "../testResource.h" -#include "CCActionCatmullRom.h" +#include "testResource.h" +#include "cocos2d.h" + CCLayer* NextAction(); CCLayer* BackAction(); diff --git a/tests/tests/Box2DTestBed/GLES-Render.cpp b/tests/tests/Box2DTestBed/GLES-Render.cpp index ac03b9f32b..097136f665 100644 --- a/tests/tests/Box2DTestBed/GLES-Render.cpp +++ b/tests/tests/Box2DTestBed/GLES-Render.cpp @@ -19,8 +19,7 @@ */ #include "GLES-Render.h" -#include "CCGLProgram.h" -#include "CCShaderCache.h" +#include "cocos2d.h" #include #include #include diff --git a/tests/tests/ShaderTest/ShaderTest.cpp b/tests/tests/ShaderTest/ShaderTest.cpp index eb0e8c222b..d99c78025e 100644 --- a/tests/tests/ShaderTest/ShaderTest.cpp +++ b/tests/tests/ShaderTest/ShaderTest.cpp @@ -1,6 +1,6 @@ #include "ShaderTest.h" #include "../testResource.h" -#include "ccShaders.h" +#include "cocos2d.h" static int sceneIdx = -1; From 90448ec7d09c99e51ffd5b844ad1c45db7bf8749 Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 19 Jun 2012 16:20:46 +0800 Subject: [PATCH 224/257] issue #1269:fix some compiling error because of including error header files --- CocosDenshion/android/Android.mk | 5 +- .../android/jni/SimpleAudioEngineJni.cpp | 2 +- .../proj.android/jni/helloworld/main.cpp | 2 - cocos2dx/Android.mk | 46 ++----------------- cocos2dx/CCCamera.cpp | 2 +- cocos2dx/CCDirector.cpp | 37 ++++++++------- cocos2dx/CCDrawingPrimitives.cpp | 10 ++-- cocos2dx/CCScheduler.cpp | 4 +- cocos2dx/actions/CCAction.cpp | 6 +-- cocos2dx/actions/CCActionCamera.cpp | 4 +- cocos2dx/actions/CCActionCatmullRom.cpp | 2 +- cocos2dx/actions/CCActionEase.cpp | 2 +- cocos2dx/actions/CCActionGrid.cpp | 2 +- cocos2dx/actions/CCActionGrid3D.cpp | 4 +- cocos2dx/actions/CCActionInstant.cpp | 6 +-- cocos2dx/actions/CCActionInterval.cpp | 8 ++-- cocos2dx/actions/CCActionManager.cpp | 4 +- cocos2dx/actions/CCActionPageTurn3D.cpp | 2 +- cocos2dx/actions/CCActionProgressTimer.cpp | 4 +- cocos2dx/actions/CCActionTiledGrid.cpp | 4 +- cocos2dx/base_nodes/CCAtlasNode.cpp | 8 ++-- cocos2dx/base_nodes/CCNode.cpp | 12 ++--- cocos2dx/cocoa/CCObject.cpp | 2 +- cocos2dx/effects/CCGrabber.cpp | 2 +- cocos2dx/effects/CCGrid.cpp | 8 ++-- .../CCControlExtension/CCControl.cpp | 6 +-- .../CCControlExtension/CCControlButton.cpp | 10 ++-- .../CCControlColourPicker.cpp | 6 +-- .../CCControlExtension/CCControlHuePicker.cpp | 2 +- .../CCControlSaturationBrightnessPicker.cpp | 2 +- .../CCControlExtension/CCControlSlider.cpp | 4 +- .../CCControlExtension/CCControlUtils.cpp | 2 +- .../CCControlExtension/CCMenuPassive.cpp | 4 +- .../CCControlExtension/CCScale9Sprite.cpp | 10 ++-- .../CCNotificationCenter.cpp | 2 +- .../extensions/CCScrollView/CCScrollView.cpp | 14 +++--- cocos2dx/include/cocos2d.h | 4 +- cocos2dx/label_nodes/CCLabelAtlas.cpp | 14 +++--- cocos2dx/label_nodes/CCLabelBMFont.cpp | 12 ++--- cocos2dx/label_nodes/CCLabelTTF.cpp | 4 +- .../CCLayer.cpp | 14 +++--- .../CCScene.cpp | 2 +- .../CCTransition.cpp | 19 ++++---- .../CCTransitionPageTurn.cpp | 8 ++-- .../CCTransitionProgress.cpp | 10 ++-- cocos2dx/menu_nodes/CCMenu.cpp | 6 +-- cocos2dx/menu_nodes/CCMenuItem.cpp | 15 +++--- cocos2dx/misc_nodes/CCMotionStreak.cpp | 10 ++-- cocos2dx/misc_nodes/CCProgressTimer.cpp | 10 ++-- cocos2dx/misc_nodes/CCRenderTexture.cpp | 12 ++--- .../particle_nodes/CCParticleBatchNode.cpp | 14 +++--- .../particle_nodes/CCParticleExamples.cpp | 4 +- cocos2dx/particle_nodes/CCParticleSystem.cpp | 10 ++-- .../particle_nodes/CCParticleSystemQuad.cpp | 10 ++-- cocos2dx/platform/CCEGLViewProtocol.cpp | 10 ++-- cocos2dx/platform/CCFileUtilsCommon_cpp.h | 9 ++-- cocos2dx/platform/CCSAXParser.cpp | 2 +- cocos2dx/platform/android/CCAccelerometer.h | 4 +- cocos2dx/platform/android/CCApplication.h | 5 +- cocos2dx/platform/android/CCCommon.cpp | 4 +- cocos2dx/platform/android/CCEGLView.cpp | 7 +-- cocos2dx/platform/android/CCEGLView.h | 5 +- cocos2dx/platform/android/CCFileUtils.cpp | 4 +- cocos2dx/platform/android/CCImage.cpp | 9 ++-- cocos2dx/platform/android/CCStdC.h | 2 +- cocos2dx/platform/android/jni/IMEJni.cpp | 2 +- cocos2dx/platform/android/jni/JniHelper.h | 2 +- cocos2dx/platform/android/jni/MessageJni.cpp | 4 +- cocos2dx/platform/android/jni/SensorJni.cpp | 5 +- .../platform/android/jni/SystemInfoJni.cpp | 2 +- cocos2dx/platform/android/jni/TouchesJni.cpp | 10 ++-- cocos2dx/shaders/CCGLProgram.cpp | 4 +- cocos2dx/sprite_nodes/CCAnimation.cpp | 8 ++-- cocos2dx/sprite_nodes/CCAnimationCache.cpp | 4 +- cocos2dx/sprite_nodes/CCSprite.cpp | 16 +++---- cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp | 10 ++-- cocos2dx/sprite_nodes/CCSpriteFrame.cpp | 2 +- cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp | 10 ++-- cocos2dx/support/TransformUtils.cpp | 2 +- cocos2dx/support/data_support/ccCArray.cpp | 2 +- cocos2dx/textures/CCTexture2D.cpp | 10 ++-- cocos2dx/textures/CCTextureAtlas.cpp | 6 +-- cocos2dx/textures/CCTextureCache.cpp | 22 ++++----- cocos2dx/textures/CCTexturePVR.cpp | 4 +- .../tileMap_parallax_nodes/CCParallaxNode.cpp | 2 +- .../tileMap_parallax_nodes/CCTMXLayer.cpp | 10 ++-- .../tileMap_parallax_nodes/CCTMXTiledMap.cpp | 4 +- .../tileMap_parallax_nodes/CCTMXXMLParser.cpp | 4 +- .../tileMap_parallax_nodes/CCTileMapAtlas.cpp | 32 ++++++------- .../touch_dispatcher/CCTouchDispatcher.cpp | 6 +-- tests/tests/ActionsTest/ActionsTest.cpp | 2 +- 91 files changed, 317 insertions(+), 357 deletions(-) diff --git a/CocosDenshion/android/Android.mk b/CocosDenshion/android/Android.mk index 7e0c5b48f1..e2ab457728 100644 --- a/CocosDenshion/android/Android.mk +++ b/CocosDenshion/android/Android.mk @@ -11,10 +11,9 @@ jni/SimpleAudioEngineJni.cpp LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/../include LOCAL_C_INCLUDES := $(LOCAL_PATH)/../include \ + $(LOCAL_PATH)/../../cocos2dx \ $(LOCAL_PATH)/../../cocos2dx/include \ - $(LOCAL_PATH)/../../cocos2dx/platform \ - $(LOCAL_PATH)/../../cocos2dx/platform/android \ - $(LOCAL_PATH)/../../cocos2dx/platform/android/jni + $(LOCAL_PATH)/../../cocos2dx/platform/android LOCAL_LDLIBS := -llog diff --git a/CocosDenshion/android/jni/SimpleAudioEngineJni.cpp b/CocosDenshion/android/jni/SimpleAudioEngineJni.cpp index 13891d18a5..ec588f8087 100644 --- a/CocosDenshion/android/jni/SimpleAudioEngineJni.cpp +++ b/CocosDenshion/android/jni/SimpleAudioEngineJni.cpp @@ -1,5 +1,5 @@ #include "SimpleAudioEngineJni.h" -#include "JniHelper.h" +#include "platform/android/jni/JniHelper.h" #include diff --git a/HelloWorld/proj.android/jni/helloworld/main.cpp b/HelloWorld/proj.android/jni/helloworld/main.cpp index 4da6f3544f..ee1d5a9ab7 100644 --- a/HelloWorld/proj.android/jni/helloworld/main.cpp +++ b/HelloWorld/proj.android/jni/helloworld/main.cpp @@ -1,7 +1,5 @@ #include "AppDelegate.h" -#include "cocos2d.h" #include "platform/android/jni/JniHelper.h" -#include "CCEventType.h" #include #include diff --git a/cocos2dx/Android.mk b/cocos2dx/Android.mk index eb4e3c6bd0..2b39ffbcf8 100644 --- a/cocos2dx/Android.mk +++ b/cocos2dx/Android.mk @@ -160,60 +160,22 @@ tileMap_parallax_nodes/CCTileMapAtlas.cpp \ touch_dispatcher/CCTouchDispatcher.cpp \ touch_dispatcher/CCTouchHandler.cpp -LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/ \ - $(LOCAL_PATH)/actions \ - $(LOCAL_PATH)/base_nodes \ - $(LOCAL_PATH)/cocoa \ - $(LOCAL_PATH)/effects \ - $(LOCAL_PATH)/extensions \ +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/include \ $(LOCAL_PATH)/kazmath/include \ - $(LOCAL_PATH)/keypad_dispatcher \ - $(LOCAL_PATH)/label_nodes \ - $(LOCAL_PATH)/layers_scenes_transitions_nodes \ - $(LOCAL_PATH)/menu_nodes \ - $(LOCAL_PATH)/misc_nodes \ - $(LOCAL_PATH)/particle_nodes \ $(LOCAL_PATH)/platform \ - $(LOCAL_PATH)/platform/android \ - $(LOCAL_PATH)/script_support \ - $(LOCAL_PATH)/shaders \ - $(LOCAL_PATH)/sprite_nodes \ - $(LOCAL_PATH)/support \ - $(LOCAL_PATH)/text_input_node \ - $(LOCAL_PATH)/textures \ - $(LOCAL_PATH)/tileMap_parallax_nodes \ - $(LOCAL_PATH)/touch_dispatcher + $(LOCAL_PATH)/platform/android LOCAL_EXPORT_LDLIBS := -llog\ -lz \ -lGLESv2 -LOCAL_C_INCLUDES := $(LOCAL_PATH)/ \ - $(LOCAL_PATH)/actions \ - $(LOCAL_PATH)/base_nodes \ - $(LOCAL_PATH)/cocoa \ - $(LOCAL_PATH)/effects \ - $(LOCAL_PATH)/extensions \ +LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/include \ $(LOCAL_PATH)/kazmath/include \ - $(LOCAL_PATH)/keypad_dispatcher \ - $(LOCAL_PATH)/label_nodes \ - $(LOCAL_PATH)/layers_scenes_transitions_nodes \ - $(LOCAL_PATH)/menu_nodes \ - $(LOCAL_PATH)/misc_nodes \ - $(LOCAL_PATH)/particle_nodes \ $(LOCAL_PATH)/platform \ - $(LOCAL_PATH)/platform/android \ - $(LOCAL_PATH)/script_support \ - $(LOCAL_PATH)/shaders \ - $(LOCAL_PATH)/sprite_nodes \ - $(LOCAL_PATH)/support \ - $(LOCAL_PATH)/text_input_node \ - $(LOCAL_PATH)/textures \ - $(LOCAL_PATH)/tileMap_parallax_nodes \ - $(LOCAL_PATH)/touch_dispatcher + $(LOCAL_PATH)/platform/android LOCAL_LDLIBS := -lGLESv2 \ diff --git a/cocos2dx/CCCamera.cpp b/cocos2dx/CCCamera.cpp index 7637779267..d13020e7cb 100644 --- a/cocos2dx/CCCamera.cpp +++ b/cocos2dx/CCCamera.cpp @@ -24,7 +24,7 @@ THE SOFTWARE. ****************************************************************************/ #include "CCCamera.h" -#include "CCString.h" +#include "cocoa/CCString.h" #include "CCGL.h" #include "CCDrawingPrimitives.h" diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 83a0e0f29a..6932e32495 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -24,30 +24,29 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCDirector.h" -#include "CCNS.h" -#include "CCScene.h" -#include "CCArray.h" +#include "cocoa/CCNS.h" +#include "layers_scenes_transitions_nodes/CCScene.h" +#include "cocoa/CCArray.h" #include "CCScheduler.h" #include "ccMacros.h" -#include "CCTouchDispatcher.h" -#include "CCPointExtension.h" -#include "CCTransition.h" -#include "CCTextureCache.h" -#include "CCTransition.h" -#include "CCSpriteFrameCache.h" -#include "CCAutoreleasePool.h" -#include "platform.h" +#include "touch_dispatcher/CCTouchDispatcher.h" +#include "support/CCPointExtension.h" +#include "layers_scenes_transitions_nodes/CCTransition.h" +#include "textures/CCTextureCache.h" +#include "sprite_nodes/CCSpriteFrameCache.h" +#include "cocoa/CCAutoreleasePool.h" +#include "platform/platform.h" #include "CCApplication.h" -#include "CCLabelBMFont.h" -#include "CCActionManager.h" +#include "label_nodes/CCLabelBMFont.h" +#include "actions/CCActionManager.h" #include "CCConfiguration.h" -#include "CCKeypadDispatcher.h" +#include "keypad_dispatcher/CCKeypadDispatcher.h" #include "CCAccelerometer.h" -#include "CCAnimationCache.h" -#include "CCTouch.h" -#include "CCUserDefault.h" -#include "ccGLStateCache.h" -#include "CCShaderCache.h" +#include "sprite_nodes/CCAnimationCache.h" +#include "touch_dispatcher/CCTouch.h" +#include "support/CCUserDefault.h" +#include "shaders/ccGLStateCache.h" +#include "shaders/CCShaderCache.h" #include "kazmath/kazmath.h" #include "kazmath/GL/matrix.h" #include "support/CCProfiling.h" diff --git a/cocos2dx/CCDrawingPrimitives.cpp b/cocos2dx/CCDrawingPrimitives.cpp index 2c7d4e0193..8299202943 100644 --- a/cocos2dx/CCDrawingPrimitives.cpp +++ b/cocos2dx/CCDrawingPrimitives.cpp @@ -29,11 +29,11 @@ THE SOFTWARE. #include "ccMacros.h" #include "CCGL.h" #include "CCDirector.h" -#include "ccGLStateCache.h" -#include "CCShaderCache.h" -#include "CCGLProgram.h" -#include "CCActionCatmullRom.h" -#include "CCPointExtension.h" +#include "shaders/ccGLStateCache.h" +#include "shaders/CCShaderCache.h" +#include "shaders/CCGLProgram.h" +#include "actions/CCActionCatmullRom.h" +#include "support/CCPointExtension.h" #include #include diff --git a/cocos2dx/CCScheduler.cpp b/cocos2dx/CCScheduler.cpp index 1e903b5e59..e51df61f58 100644 --- a/cocos2dx/CCScheduler.cpp +++ b/cocos2dx/CCScheduler.cpp @@ -29,8 +29,8 @@ THE SOFTWARE. #include "CCDirector.h" #include "support/data_support/utlist.h" #include "support/data_support/ccCArray.h" -#include "CCArray.h" -#include "CCScriptSupport.h" +#include "cocoa/CCArray.h" +#include "script_support/CCScriptSupport.h" using namespace std; diff --git a/cocos2dx/actions/CCAction.cpp b/cocos2dx/actions/CCAction.cpp index 91398b6c1c..1be62d2139 100644 --- a/cocos2dx/actions/CCAction.cpp +++ b/cocos2dx/actions/CCAction.cpp @@ -26,10 +26,10 @@ THE SOFTWARE. #include "CCAction.h" #include "CCActionInterval.h" -#include "CCNode.h" -#include "CCPointExtension.h" +#include "base_nodes/CCNode.h" +#include "support/CCPointExtension.h" #include "CCDirector.h" -#include "CCZone.h" +#include "cocoa/CCZone.h" NS_CC_BEGIN // diff --git a/cocos2dx/actions/CCActionCamera.cpp b/cocos2dx/actions/CCActionCamera.cpp index 7b49d83349..bcc8f6d669 100644 --- a/cocos2dx/actions/CCActionCamera.cpp +++ b/cocos2dx/actions/CCActionCamera.cpp @@ -24,10 +24,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCActionCamera.h" -#include "CCNode.h" +#include "base_nodes/CCNode.h" #include "CCCamera.h" #include "CCStdC.h" -#include "CCZone.h" +#include "cocoa/CCZone.h" NS_CC_BEGIN // diff --git a/cocos2dx/actions/CCActionCatmullRom.cpp b/cocos2dx/actions/CCActionCatmullRom.cpp index 4614fba02b..47f5c40a66 100644 --- a/cocos2dx/actions/CCActionCatmullRom.cpp +++ b/cocos2dx/actions/CCActionCatmullRom.cpp @@ -35,7 +35,7 @@ #include "ccMacros.h" #include "support/CCPointExtension.h" #include "CCActionCatmullRom.h" -#include "CCZone.h" +#include "cocoa/CCZone.h" using namespace std; diff --git a/cocos2dx/actions/CCActionEase.cpp b/cocos2dx/actions/CCActionEase.cpp index 3908352adf..6951827241 100644 --- a/cocos2dx/actions/CCActionEase.cpp +++ b/cocos2dx/actions/CCActionEase.cpp @@ -31,7 +31,7 @@ THE SOFTWARE. */ #include "CCActionEase.h" -#include "CCZone.h" +#include "cocoa/CCZone.h" NS_CC_BEGIN diff --git a/cocos2dx/actions/CCActionGrid.cpp b/cocos2dx/actions/CCActionGrid.cpp index 929b41da76..cb0f32fe3a 100644 --- a/cocos2dx/actions/CCActionGrid.cpp +++ b/cocos2dx/actions/CCActionGrid.cpp @@ -25,7 +25,7 @@ THE SOFTWARE. #include "CCActionGrid.h" #include "CCDirector.h" #include "effects/CCGrid.h" -#include "CCZone.h" +#include "cocoa/CCZone.h" NS_CC_BEGIN // implementation of CCGridAction diff --git a/cocos2dx/actions/CCActionGrid3D.cpp b/cocos2dx/actions/CCActionGrid3D.cpp index 80c7fda10d..539e007c99 100644 --- a/cocos2dx/actions/CCActionGrid3D.cpp +++ b/cocos2dx/actions/CCActionGrid3D.cpp @@ -23,9 +23,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCActionGrid3D.h" -#include "CCPointExtension.h" +#include "support/CCPointExtension.h" #include "CCDirector.h" -#include "CCZone.h" +#include "cocoa/CCZone.h" #include NS_CC_BEGIN diff --git a/cocos2dx/actions/CCActionInstant.cpp b/cocos2dx/actions/CCActionInstant.cpp index f2eaa36c70..8a96c919d1 100644 --- a/cocos2dx/actions/CCActionInstant.cpp +++ b/cocos2dx/actions/CCActionInstant.cpp @@ -25,9 +25,9 @@ ****************************************************************************/ #include "CCActionInstant.h" -#include "CCNode.h" -#include "CCSprite.h" -#include "CCZone.h" +#include "base_nodes/CCNode.h" +#include "sprite_nodes/CCSprite.h" +#include "cocoa/CCZone.h" NS_CC_BEGIN // diff --git a/cocos2dx/actions/CCActionInterval.cpp b/cocos2dx/actions/CCActionInterval.cpp index f8b5de9005..599bd9b9ef 100644 --- a/cocos2dx/actions/CCActionInterval.cpp +++ b/cocos2dx/actions/CCActionInterval.cpp @@ -25,12 +25,12 @@ THE SOFTWARE. ****************************************************************************/ #include "CCActionInterval.h" -#include "CCSprite.h" -#include "CCNode.h" -#include "CCPointExtension.h" +#include "sprite_nodes/CCSprite.h" +#include "base_nodes/CCNode.h" +#include "support/CCPointExtension.h" #include "CCStdC.h" #include "CCActionInstant.h" -#include "CCZone.h" +#include "cocoa/CCZone.h" #include NS_CC_BEGIN diff --git a/cocos2dx/actions/CCActionManager.cpp b/cocos2dx/actions/CCActionManager.cpp index f4a2e153d7..63b0b7a119 100644 --- a/cocos2dx/actions/CCActionManager.cpp +++ b/cocos2dx/actions/CCActionManager.cpp @@ -26,12 +26,12 @@ THE SOFTWARE. ****************************************************************************/ #include "CCActionManager.h" -#include "CCNode.h" +#include "base_nodes/CCNode.h" #include "CCScheduler.h" #include "ccMacros.h" #include "support/data_support/ccCArray.h" #include "support/data_support/uthash.h" -#include "CCSet.h" +#include "cocoa/CCSet.h" NS_CC_BEGIN // diff --git a/cocos2dx/actions/CCActionPageTurn3D.cpp b/cocos2dx/actions/CCActionPageTurn3D.cpp index 413d738669..125cd94cbd 100644 --- a/cocos2dx/actions/CCActionPageTurn3D.cpp +++ b/cocos2dx/actions/CCActionPageTurn3D.cpp @@ -23,7 +23,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCActionPageTurn3D.h" -#include "CCZone.h" +#include "cocoa/CCZone.h" NS_CC_BEGIN diff --git a/cocos2dx/actions/CCActionProgressTimer.cpp b/cocos2dx/actions/CCActionProgressTimer.cpp index b778d9e6f4..bb6846dff7 100644 --- a/cocos2dx/actions/CCActionProgressTimer.cpp +++ b/cocos2dx/actions/CCActionProgressTimer.cpp @@ -23,8 +23,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCActionProgressTimer.h" -#include "CCProgressTimer.h" -#include "CCZone.h" +#include "misc_nodes/CCProgressTimer.h" +#include "cocoa/CCZone.h" NS_CC_BEGIN diff --git a/cocos2dx/actions/CCActionTiledGrid.cpp b/cocos2dx/actions/CCActionTiledGrid.cpp index 9c38fc8c04..c37bbdcc03 100644 --- a/cocos2dx/actions/CCActionTiledGrid.cpp +++ b/cocos2dx/actions/CCActionTiledGrid.cpp @@ -25,9 +25,9 @@ THE SOFTWARE. #include "CCActionTiledGrid.h" #include "CCDirector.h" #include "ccMacros.h" -#include "CCPointExtension.h" +#include "support/CCPointExtension.h" #include "effects/CCGrid.h" -#include "CCZone.h" +#include "cocoa/CCZone.h" #include NS_CC_BEGIN diff --git a/cocos2dx/base_nodes/CCAtlasNode.cpp b/cocos2dx/base_nodes/CCAtlasNode.cpp index deb87cc22b..46d42e3f51 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.cpp +++ b/cocos2dx/base_nodes/CCAtlasNode.cpp @@ -25,11 +25,11 @@ THE SOFTWARE. ****************************************************************************/ #include "CCAtlasNode.h" -#include "CCTextureAtlas.h" +#include "textures/CCTextureAtlas.h" #include "CCDirector.h" -#include "CCGLProgram.h" -#include "CCShaderCache.h" -#include "ccGLStateCache.h" +#include "shaders/CCGLProgram.h" +#include "shaders/CCShaderCache.h" +#include "shaders/ccGLStateCache.h" #include "CCDirector.h" #include "support/TransformUtils.h" diff --git a/cocos2dx/base_nodes/CCNode.cpp b/cocos2dx/base_nodes/CCNode.cpp index af0feb5a23..a57637b974 100644 --- a/cocos2dx/base_nodes/CCNode.cpp +++ b/cocos2dx/base_nodes/CCNode.cpp @@ -24,18 +24,18 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "CCString.h" +#include "cocoa/CCString.h" #include "CCNode.h" -#include "CCPointExtension.h" +#include "support/CCPointExtension.h" #include "support/TransformUtils.h" #include "CCCamera.h" #include "effects/CCGrid.h" #include "CCDirector.h" #include "CCScheduler.h" -#include "CCTouch.h" -#include "CCActionManager.h" -#include "CCScriptSupport.h" -#include "CCGLProgram.h" +#include "touch_dispatcher/CCTouch.h" +#include "actions/CCActionManager.h" +#include "script_support/CCScriptSupport.h" +#include "shaders/CCGLProgram.h" // externals #include "kazmath/GL/matrix.h" diff --git a/cocos2dx/cocoa/CCObject.cpp b/cocos2dx/cocoa/CCObject.cpp index 4781c740d9..d99eabe97a 100644 --- a/cocos2dx/cocoa/CCObject.cpp +++ b/cocos2dx/cocoa/CCObject.cpp @@ -26,7 +26,7 @@ THE SOFTWARE. #include "CCObject.h" #include "CCAutoreleasePool.h" #include "ccMacros.h" -#include "CCScriptSupport.h" +#include "script_support/CCScriptSupport.h" NS_CC_BEGIN diff --git a/cocos2dx/effects/CCGrabber.cpp b/cocos2dx/effects/CCGrabber.cpp index 2e40da327f..dac9879136 100644 --- a/cocos2dx/effects/CCGrabber.cpp +++ b/cocos2dx/effects/CCGrabber.cpp @@ -24,7 +24,7 @@ THE SOFTWARE. ****************************************************************************/ #include "CCGrabber.h" #include "ccMacros.h" -#include "CCTexture2D.h" +#include "textures/CCTexture2D.h" #include "platform/platform.h" NS_CC_BEGIN diff --git a/cocos2dx/effects/CCGrid.cpp b/cocos2dx/effects/CCGrid.cpp index c8326f765e..d061564f95 100644 --- a/cocos2dx/effects/CCGrid.cpp +++ b/cocos2dx/effects/CCGrid.cpp @@ -27,11 +27,11 @@ THE SOFTWARE. #include "CCDirector.h" #include "effects/CCGrabber.h" #include "support/ccUtils.h" -#include "CCGLProgram.h" -#include "CCShaderCache.h" -#include "ccGLStateCache.h" +#include "shaders/CCGLProgram.h" +#include "shaders/CCShaderCache.h" +#include "shaders/ccGLStateCache.h" #include "CCGL.h" -#include "CCPointExtension.h" +#include "support/CCPointExtension.h" #include "support/TransformUtils.h" #include "kazmath/kazmath.h" #include "kazmath/GL/matrix.h" diff --git a/cocos2dx/extensions/CCControlExtension/CCControl.cpp b/cocos2dx/extensions/CCControlExtension/CCControl.cpp index a7f50ead50..543a9ae3a5 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControl.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControl.cpp @@ -28,9 +28,9 @@ #include "CCControl.h" #include "CCDirector.h" -#include "CCTouchDispatcher.h" -#include "CCMenu.h" -#include "CCTouch.h" +#include "touch_dispatcher/CCTouchDispatcher.h" +#include "menu_nodes/CCMenu.h" +#include "touch_dispatcher/CCTouch.h" NS_CC_EXT_BEGIN diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp index 871456868e..a3446921d0 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp @@ -26,11 +26,11 @@ #include "CCControlButton.h" #include "CCScale9Sprite.h" -#include "CCPointExtension.h" -#include "CCLabelTTF.h" -#include "CCLabelBMFont.h" -#include "CCAction.h" -#include "CCActionInterval.h" +#include "support/CCPointExtension.h" +#include "label_nodes/CCLabelTTF.h" +#include "label_nodes/CCLabelBMFont.h" +#include "actions/CCAction.h" +#include "actions/CCActionInterval.h" using namespace std; diff --git a/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp b/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp index cd0717c447..ec6cbd4303 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.cpp @@ -29,9 +29,9 @@ */ #include "CCControlColourPicker.h" -#include "CCPointExtension.h" -#include "CCSpriteFrameCache.h" -#include "CCSpriteBatchNode.h" +#include "support/CCPointExtension.h" +#include "sprite_nodes/CCSpriteFrameCache.h" +#include "sprite_nodes/CCSpriteBatchNode.h" NS_CC_EXT_BEGIN diff --git a/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.cpp b/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.cpp index e2ea4cf85d..0eae341e85 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.cpp @@ -29,7 +29,7 @@ */ #include "CCControlHuePicker.h" -#include "CCPointExtension.h" +#include "support/CCPointExtension.h" NS_CC_EXT_BEGIN diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp b/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp index c37ee8373d..2586f89b96 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.cpp @@ -29,7 +29,7 @@ */ #include "CCControlSaturationBrightnessPicker.h" -#include "CCPointExtension.h" +#include "support/CCPointExtension.h" NS_CC_EXT_BEGIN diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp b/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp index f309d038e2..eaf6757709 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlSlider.cpp @@ -27,8 +27,8 @@ */ #include "CCControlSlider.h" -#include "CCPointExtension.h" -#include "CCTouch.h" +#include "support/CCPointExtension.h" +#include "touch_dispatcher/CCTouch.h" #include "CCDirector.h" NS_CC_EXT_BEGIN diff --git a/cocos2dx/extensions/CCControlExtension/CCControlUtils.cpp b/cocos2dx/extensions/CCControlExtension/CCControlUtils.cpp index 5682a633a8..e72b4ae698 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlUtils.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlUtils.cpp @@ -1,5 +1,5 @@ #include "CCControlUtils.h" -#include "CCPointExtension.h" +#include "support/CCPointExtension.h" NS_CC_EXT_BEGIN diff --git a/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp b/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp index 13a3713527..24592b9403 100644 --- a/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCMenuPassive.cpp @@ -1,7 +1,7 @@ #include "CCMenuPassive.h" #include "CCDirector.h" -#include "CCPointExtension.h" -#include "CCMenuItem.h" +#include "support/CCPointExtension.h" +#include "menu_nodes/CCMenuItem.h" #include using namespace std; diff --git a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp index 7a7964c3e8..52b0639ca8 100644 --- a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp @@ -7,11 +7,11 @@ // #include "CCScale9Sprite.h" -#include "CCSpriteBatchNode.h" -#include "CCSpriteFrame.h" -#include "CCSpriteFrameCache.h" -#include "CCSprite.h" -#include "CCPointExtension.h" +#include "sprite_nodes/CCSpriteBatchNode.h" +#include "sprite_nodes/CCSpriteFrame.h" +#include "sprite_nodes/CCSpriteFrameCache.h" +#include "sprite_nodes/CCSprite.h" +#include "support/CCPointExtension.h" NS_CC_EXT_BEGIN diff --git a/cocos2dx/extensions/CCNotificationCenter/CCNotificationCenter.cpp b/cocos2dx/extensions/CCNotificationCenter/CCNotificationCenter.cpp index 9acc3110df..c5579a30d8 100644 --- a/cocos2dx/extensions/CCNotificationCenter/CCNotificationCenter.cpp +++ b/cocos2dx/extensions/CCNotificationCenter/CCNotificationCenter.cpp @@ -23,7 +23,7 @@ THE SOFTWARE. ****************************************************************************/ #include "CCNotificationCenter.h" -#include "CCArray.h" +#include "cocoa/CCArray.h" #include using namespace std; diff --git a/cocos2dx/extensions/CCScrollView/CCScrollView.cpp b/cocos2dx/extensions/CCScrollView/CCScrollView.cpp index afaccbd753..aa36ab0ab8 100644 --- a/cocos2dx/extensions/CCScrollView/CCScrollView.cpp +++ b/cocos2dx/extensions/CCScrollView/CCScrollView.cpp @@ -28,15 +28,15 @@ // #include "CCScrollView.h" -#include "CCActionInterval.h" -#include "CCActionTween.h" -#include "CCActionInstant.h" -#include "CCPointExtension.h" -#include "CCTouchDispatcher.h" -#include "CCGrid.h" +#include "actions/CCActionInterval.h" +#include "actions/CCActionTween.h" +#include "actions/CCActionInstant.h" +#include "support/CCPointExtension.h" +#include "touch_dispatcher/CCTouchDispatcher.h" +#include "effects/CCGrid.h" #include "CCDirector.h" #include "kazmath/GL/matrix.h" -#include "CCTouch.h" +#include "touch_dispatcher/CCTouch.h" NS_CC_EXT_BEGIN diff --git a/cocos2dx/include/cocos2d.h b/cocos2dx/include/cocos2d.h index 3ece330dc9..285f580ac3 100755 --- a/cocos2dx/include/cocos2d.h +++ b/cocos2dx/include/cocos2d.h @@ -135,7 +135,7 @@ THE SOFTWARE. #include "platform/ios/CCStdC.h" #endif // CC_TARGET_PLATFORM == CC_PLATFORM_IOS -#if (CC_TARGET_PLATFROM == CC_PLATFORM_ANDROID) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) #include "platform/android/CCAccelerometer.h" #include "platform/android/CCApplication.h" #include "platform/android/CCEGLView.h" @@ -143,7 +143,7 @@ THE SOFTWARE. #include "platform/android/CCStdC.h" #endif // CC_TARGET_PLATFROM == CC_PLATFORM_ANDROID -#if (CC_TARGET_PLATFROM == CC_PLATFORM_WIN32) +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) #include "platform/win32/CCAccelerometer.h" #include "platform/win32/CCApplication.h" #include "platform/win32/CCEGLView.h" diff --git a/cocos2dx/label_nodes/CCLabelAtlas.cpp b/cocos2dx/label_nodes/CCLabelAtlas.cpp index 4cf3541c84..61b2d03620 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.cpp +++ b/cocos2dx/label_nodes/CCLabelAtlas.cpp @@ -24,17 +24,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCLabelAtlas.h" -#include "CCTextureAtlas.h" -#include "CCPointExtension.h" +#include "textures/CCTextureAtlas.h" +#include "support/CCPointExtension.h" #include "CCDrawingPrimitives.h" #include "ccConfig.h" -#include "CCShaderCache.h" -#include "CCGLProgram.h" -#include "ccGLStateCache.h" +#include "shaders/CCShaderCache.h" +#include "shaders/CCGLProgram.h" +#include "shaders/ccGLStateCache.h" #include "CCDirector.h" #include "support/TransformUtils.h" -#include "CCInteger.h" -#include "CCFileUtils.h" +#include "cocoa/CCInteger.h" +#include "platform/CCFileUtils.h" // external #include "kazmath/GL/matrix.h" diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index 8167357579..02b8dda441 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -31,17 +31,17 @@ http://www.angelcode.com/products/bmfont/ (Free, Windows only) ****************************************************************************/ #include "CCLabelBMFont.h" -#include "CCString.h" +#include "cocoa/CCString.h" #include "platform/platform.h" -#include "CCDictionary.h" +#include "cocoa/CCDictionary.h" #include "CCConfiguration.h" #include "CCDrawingPrimitives.h" -#include "CCSprite.h" -#include "CCPointExtension.h" -#include "CCFileUtils.h" +#include "sprite_nodes/CCSprite.h" +#include "support/CCPointExtension.h" +#include "platform/CCFileUtils.h" #include "support/data_support/uthash.h" #include "CCDirector.h" -#include "CCTextureCache.h" +#include "textures/CCTextureCache.h" using namespace std; diff --git a/cocos2dx/label_nodes/CCLabelTTF.cpp b/cocos2dx/label_nodes/CCLabelTTF.cpp index 0fa03771bd..236057746a 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.cpp +++ b/cocos2dx/label_nodes/CCLabelTTF.cpp @@ -24,8 +24,8 @@ THE SOFTWARE. ****************************************************************************/ #include "CCLabelTTF.h" #include "CCDirector.h" -#include "CCGLProgram.h" -#include "CCShaderCache.h" +#include "shaders/CCGLProgram.h" +#include "shaders/CCShaderCache.h" #include "CCApplication.h" NS_CC_BEGIN diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index dbea7251dd..d189784841 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -26,15 +26,15 @@ THE SOFTWARE. #include #include "CCLayer.h" -#include "CCTouchDispatcher.h" -#include "CCKeypadDispatcher.h" +#include "touch_dispatcher/CCTouchDispatcher.h" +#include "keypad_dispatcher/CCKeypadDispatcher.h" #include "CCAccelerometer.h" #include "CCDirector.h" -#include "CCPointExtension.h" -#include "CCScriptSupport.h" -#include "CCShaderCache.h" -#include "CCGLProgram.h" -#include "ccGLStateCache.h" +#include "support/CCPointExtension.h" +#include "script_support/CCScriptSupport.h" +#include "shaders/CCShaderCache.h" +#include "shaders/CCGLProgram.h" +#include "shaders/ccGLStateCache.h" #include "support/TransformUtils.h" // extern #include "kazmath/GL/matrix.h" diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp index b7b9def3c9..ccda2f7ef3 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCScene.cpp @@ -25,7 +25,7 @@ THE SOFTWARE. ****************************************************************************/ #include "CCScene.h" -#include "CCPointExtension.h" +#include "support/CCPointExtension.h" #include "CCDirector.h" NS_CC_BEGIN diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp index c22ff9d45d..8a0fa94a5f 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.cpp @@ -26,17 +26,18 @@ THE SOFTWARE. #include "CCTransition.h" #include "CCCamera.h" -#include "CCPointExtension.h" +#include "support/CCPointExtension.h" #include "CCDirector.h" -#include "CCTouchDispatcher.h" -#include "CCActionInterval.h" -#include "CCActionInstant.h" -#include "CCActionEase.h" -#include "CCActionCamera.h" +#include "touch_dispatcher/CCTouchDispatcher.h" +#include "actions/CCActionInterval.h" +#include "actions/CCActionInstant.h" +#include "actions/CCActionEase.h" +#include "actions/CCActionCamera.h" +#include "actions/CCActionTiledGrid.h" +#include "actions/CCActionGrid.h" #include "CCLayer.h" -#include "CCActionGrid.h" -#include "CCRenderTexture.h" -#include "CCActionTiledGrid.h" +#include "misc_nodes/CCRenderTexture.h" + NS_CC_BEGIN diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp index d39178f438..14986f6f69 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.cpp @@ -25,10 +25,10 @@ THE SOFTWARE. #include "CCTransitionPageTurn.h" #include "CCDirector.h" -#include "CCActionInterval.h" -#include "CCActionInstant.h" -#include "CCActionGrid.h" -#include "CCActionPageTurn3D.h" +#include "actions/CCActionInterval.h" +#include "actions/CCActionInstant.h" +#include "actions/CCActionGrid.h" +#include "actions/CCActionPageTurn3D.h" NS_CC_BEGIN diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp index 0b6f6c870c..ee9b0cfb69 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionProgress.cpp @@ -27,12 +27,12 @@ THE SOFTWARE. #include "CCTransitionProgress.h" #include "CCDirector.h" -#include "CCRenderTexture.h" +#include "misc_nodes/CCRenderTexture.h" +#include "misc_nodes/CCProgressTimer.h" #include "CCLayer.h" -#include "CCActionInstant.h" -#include "CCProgressTimer.h" -#include "CCActionProgressTimer.h" -#include "CCPointExtension.h" +#include "actions/CCActionInstant.h" +#include "actions/CCActionProgressTimer.h" +#include "support/CCPointExtension.h" NS_CC_BEGIN diff --git a/cocos2dx/menu_nodes/CCMenu.cpp b/cocos2dx/menu_nodes/CCMenu.cpp index 7bd15a97c5..1dfe17fc76 100644 --- a/cocos2dx/menu_nodes/CCMenu.cpp +++ b/cocos2dx/menu_nodes/CCMenu.cpp @@ -25,9 +25,9 @@ THE SOFTWARE. #include "CCMenu.h" #include "CCDirector.h" #include "CCApplication.h" -#include "CCPointExtension.h" -#include "CCTouchDispatcher.h" -#include "CCTouch.h" +#include "support/CCPointExtension.h" +#include "touch_dispatcher/CCTouchDispatcher.h" +#include "touch_dispatcher/CCTouch.h" #include "CCStdC.h" #include diff --git a/cocos2dx/menu_nodes/CCMenuItem.cpp b/cocos2dx/menu_nodes/CCMenuItem.cpp index 17a7e65aad..1667befd8d 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.cpp +++ b/cocos2dx/menu_nodes/CCMenuItem.cpp @@ -23,15 +23,16 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include + #include "CCMenuItem.h" -#include "CCPointExtension.h" -#include "CCActionInterval.h" -#include "CCSprite.h" -#include "CCLabelAtlas.h" -#include "CCLabelTTF.h" -#include "CCScriptSupport.h" +#include "support/CCPointExtension.h" +#include "actions/CCActionInterval.h" +#include "sprite_nodes/CCSprite.h" +#include "label_nodes/CCLabelAtlas.h" +#include "label_nodes/CCLabelTTF.h" +#include "script_support/CCScriptSupport.h" #include +#include NS_CC_BEGIN diff --git a/cocos2dx/misc_nodes/CCMotionStreak.cpp b/cocos2dx/misc_nodes/CCMotionStreak.cpp index 35eaaafbfb..30c13792d3 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.cpp +++ b/cocos2dx/misc_nodes/CCMotionStreak.cpp @@ -23,14 +23,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCMotionStreak.h" -#include "CCTextureCache.h" -#include "ccGLStateCache.h" -#include "CCGLProgram.h" -#include "CCShaderCache.h" +#include "textures/CCTextureCache.h" +#include "shaders/ccGLStateCache.h" +#include "shaders/CCGLProgram.h" +#include "shaders/CCShaderCache.h" #include "ccMacros.h" #include "support/CCVertex.h" -#include "CCPointExtension.h" +#include "support/CCPointExtension.h" NS_CC_BEGIN diff --git a/cocos2dx/misc_nodes/CCProgressTimer.cpp b/cocos2dx/misc_nodes/CCProgressTimer.cpp index d53063cc42..fa98613a04 100644 --- a/cocos2dx/misc_nodes/CCProgressTimer.cpp +++ b/cocos2dx/misc_nodes/CCProgressTimer.cpp @@ -25,11 +25,11 @@ THE SOFTWARE. #include "CCProgressTimer.h" #include "ccMacros.h" -#include "CCTextureCache.h" -#include "CCPointExtension.h" -#include "CCGLProgram.h" -#include "CCShaderCache.h" -#include "ccGLStateCache.h" +#include "textures/CCTextureCache.h" +#include "support/CCPointExtension.h" +#include "shaders/CCGLProgram.h" +#include "shaders/CCShaderCache.h" +#include "shaders/ccGLStateCache.h" #include "CCDirector.h" #include "support/TransformUtils.h" #include "CCDrawingPrimitives.h" diff --git a/cocos2dx/misc_nodes/CCRenderTexture.cpp b/cocos2dx/misc_nodes/CCRenderTexture.cpp index 3b167fabdd..6fbe66efe4 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.cpp +++ b/cocos2dx/misc_nodes/CCRenderTexture.cpp @@ -24,16 +24,16 @@ THE SOFTWARE. ****************************************************************************/ #include "CCConfiguration.h" -#include "CCRenderTexture.h" +#include "misc_nodes/CCRenderTexture.h" #include "CCDirector.h" #include "platform/platform.h" -#include "CCImage.h" -#include "CCGLProgram.h" -#include "ccGLStateCache.h" +#include "platform/CCImage.h" +#include "shaders/CCGLProgram.h" +#include "shaders/ccGLStateCache.h" #include "CCConfiguration.h" #include "support/ccUtils.h" -#include "CCTextureCache.h" -#include "CCFileUtils.h" +#include "textures/CCTextureCache.h" +#include "platform/CCFileUtils.h" #include "CCGL.h" #include "extensions/CCNotificationCenter/CCNotificationCenter.h" #include "CCEventType.h" diff --git a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp index dabedb6f10..86da441a9b 100644 --- a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp +++ b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp @@ -28,19 +28,19 @@ */ #include "CCParticleBatchNode.h" -#include "CCTextureCache.h" -#include "CCTextureAtlas.h" +#include "textures/CCTextureCache.h" +#include "textures/CCTextureAtlas.h" #include "ccConfig.h" #include "ccMacros.h" #include "effects/CCGrid.h" -#include "CCPointExtension.h" +#include "support/CCPointExtension.h" #include "CCParticleSystem.h" -#include "CCShaderCache.h" -#include "CCGLProgram.h" -#include "ccGLStateCache.h" +#include "shaders/CCShaderCache.h" +#include "shaders/CCGLProgram.h" +#include "shaders/ccGLStateCache.h" #include "support/base64.h" #include "support/zip_support/ZipUtils.h" -#include "CCFileUtils.h" +#include "platform/CCFileUtils.h" #include "kazmath/GL/matrix.h" NS_CC_BEGIN diff --git a/cocos2dx/particle_nodes/CCParticleExamples.cpp b/cocos2dx/particle_nodes/CCParticleExamples.cpp index c9603fef91..2aa2cc3379 100644 --- a/cocos2dx/particle_nodes/CCParticleExamples.cpp +++ b/cocos2dx/particle_nodes/CCParticleExamples.cpp @@ -25,8 +25,8 @@ THE SOFTWARE. ****************************************************************************/ #include "CCParticleExamples.h" #include "CCDirector.h" -#include "CCTextureCache.h" -#include "CCPointExtension.h" +#include "textures/CCTextureCache.h" +#include "support/CCPointExtension.h" NS_CC_BEGIN // diff --git a/cocos2dx/particle_nodes/CCParticleSystem.cpp b/cocos2dx/particle_nodes/CCParticleSystem.cpp index a0c4416d0d..a2881502e7 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystem.cpp @@ -44,12 +44,12 @@ THE SOFTWARE. #include "CCParticleSystem.h" #include "CCParticleBatchNode.h" #include "ccTypes.h" -#include "CCTextureCache.h" -#include "CCTextureAtlas.h" +#include "textures/CCTextureCache.h" +#include "textures/CCTextureAtlas.h" #include "support/base64.h" -#include "CCPointExtension.h" -#include "CCFileUtils.h" -#include "CCImage.h" +#include "support/CCPointExtension.h" +#include "platform/CCFileUtils.h" +#include "platform/CCImage.h" #include "platform/platform.h" #include "support/zip_support/ZipUtils.h" #include "CCDirector.h" diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp index 07cab0b9a7..9e40d58d6c 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.cpp @@ -27,13 +27,13 @@ THE SOFTWARE. #include "CCGL.h" #include "CCParticleSystemQuad.h" -#include "CCSpriteFrame.h" +#include "sprite_nodes/CCSpriteFrame.h" #include "CCDirector.h" #include "CCParticleBatchNode.h" -#include "CCTextureAtlas.h" -#include "CCShaderCache.h" -#include "ccGLStateCache.h" -#include "CCGLProgram.h" +#include "textures/CCTextureAtlas.h" +#include "shaders/CCShaderCache.h" +#include "shaders/ccGLStateCache.h" +#include "shaders/CCGLProgram.h" #include "support/TransformUtils.h" #include "extensions/CCNotificationCenter/CCNotificationCenter.h" #include "CCEventType.h" diff --git a/cocos2dx/platform/CCEGLViewProtocol.cpp b/cocos2dx/platform/CCEGLViewProtocol.cpp index d3de801602..2d12ca13de 100644 --- a/cocos2dx/platform/CCEGLViewProtocol.cpp +++ b/cocos2dx/platform/CCEGLViewProtocol.cpp @@ -1,10 +1,10 @@ #include "CCEGLViewProtocol.h" -#include "CCTouchDispatcher.h" +#include "touch_dispatcher/CCTouchDispatcher.h" +#include "touch_dispatcher/CCTouch.h" #include "CCDirector.h" -#include "CCSet.h" -#include "CCTouch.h" -#include "CCDictionary.h" -#include "CCInteger.h" +#include "cocoa/CCSet.h" +#include "cocoa/CCDictionary.h" +#include "cocoa/CCInteger.h" NS_CC_BEGIN diff --git a/cocos2dx/platform/CCFileUtilsCommon_cpp.h b/cocos2dx/platform/CCFileUtilsCommon_cpp.h index 8949907144..2b78ab679b 100644 --- a/cocos2dx/platform/CCFileUtilsCommon_cpp.h +++ b/cocos2dx/platform/CCFileUtilsCommon_cpp.h @@ -27,17 +27,18 @@ THE SOFTWARE. #include "CCFileUtils.h" #include "CCDirector.h" -#include "CCDictionary.h" +#include "cocoa/CCDictionary.h" #if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS) +#include "cocoa/CCString.h" +#include "CCSAXParser.h" +#include "support/zip_support/unzip.h" + #include #include #include #include -#include "CCString.h" -#include "CCSAXParser.h" -#include "support/zip_support/unzip.h" NS_CC_BEGIN diff --git a/cocos2dx/platform/CCSAXParser.cpp b/cocos2dx/platform/CCSAXParser.cpp index a351d8099a..983ca0b80f 100644 --- a/cocos2dx/platform/CCSAXParser.cpp +++ b/cocos2dx/platform/CCSAXParser.cpp @@ -25,7 +25,7 @@ #include #include #include "CCSAXParser.h" -#include "CCDictionary.h" +#include "cocoa/CCDictionary.h" #include "CCFileUtils.h" NS_CC_BEGIN diff --git a/cocos2dx/platform/android/CCAccelerometer.h b/cocos2dx/platform/android/CCAccelerometer.h index 650ae367ba..542c8a375f 100644 --- a/cocos2dx/platform/android/CCAccelerometer.h +++ b/cocos2dx/platform/android/CCAccelerometer.h @@ -25,8 +25,8 @@ THE SOFTWARE. #ifndef __PLATFORM_ANDROID_CCACCELEROMETER_H__ #define __PLATFORM_ANDROID_CCACCELEROMETER_H__ -#include "CCCommon.h" -#include "CCAccelerometerDelegate.h" +#include "platform/CCCommon.h" +#include "platform/CCAccelerometerDelegate.h" namespace cocos2d { diff --git a/cocos2dx/platform/android/CCApplication.h b/cocos2dx/platform/android/CCApplication.h index 6840cc8ede..f5b7da3ca6 100644 --- a/cocos2dx/platform/android/CCApplication.h +++ b/cocos2dx/platform/android/CCApplication.h @@ -1,9 +1,8 @@ #ifndef __CC_APPLICATION_ANDROID_H__ #define __CC_APPLICATION_ANDROID_H__ -#include "CCApplication.h" -#include "CCCommon.h" -#include "CCApplicationProtocol.h" +#include "platform/CCCommon.h" +#include "platform/CCApplicationProtocol.h" NS_CC_BEGIN diff --git a/cocos2dx/platform/android/CCCommon.cpp b/cocos2dx/platform/android/CCCommon.cpp index eb5e82dd8b..d12cd330a2 100644 --- a/cocos2dx/platform/android/CCCommon.cpp +++ b/cocos2dx/platform/android/CCCommon.cpp @@ -22,14 +22,14 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "CCCommon.h" +#include "platform/CCCommon.h" #define MAX_LEN (cocos2d::kMaxLogLen + 1) +#include "android/jni/MessageJni.h" #include #include #include -#include "android/jni/MessageJni.h" NS_CC_BEGIN diff --git a/cocos2dx/platform/android/CCEGLView.cpp b/cocos2dx/platform/android/CCEGLView.cpp index 0fe313fd62..524019c894 100644 --- a/cocos2dx/platform/android/CCEGLView.cpp +++ b/cocos2dx/platform/android/CCEGLView.cpp @@ -22,16 +22,17 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCEGLView.h" -#include "CCSet.h" +#include "cocoa/CCSet.h" #include "CCDirector.h" #include "ccMacros.h" -#include "CCTouchDispatcher.h" +#include "touch_dispatcher/CCTouchDispatcher.h" #include "jni/IMEJni.h" #include "jni/MessageJni.h" +#include "CCGL.h" #include #include -#include "CCGL.h" + #if CC_TEXTURE_ATLAS_USE_VAO diff --git a/cocos2dx/platform/android/CCEGLView.h b/cocos2dx/platform/android/CCEGLView.h index 8336aa8432..84b3f2d2da 100644 --- a/cocos2dx/platform/android/CCEGLView.h +++ b/cocos2dx/platform/android/CCEGLView.h @@ -25,8 +25,9 @@ THE SOFTWARE. #ifndef __CC_EGLVIEW_ANDROID_H__ #define __CC_EGLVIEW_ANDROID_H__ -#include "CCGeometry.h" -#include "CCEGLViewProtocol.h" +#include "cocoa/CCGeometry.h" +#include "platform/CCEGLViewProtocol.h" +#include "platform/CCPlatFormMacros.h" NS_CC_BEGIN diff --git a/cocos2dx/platform/android/CCFileUtils.cpp b/cocos2dx/platform/android/CCFileUtils.cpp index 5a6fd454db..dceff8381a 100644 --- a/cocos2dx/platform/android/CCFileUtils.cpp +++ b/cocos2dx/platform/android/CCFileUtils.cpp @@ -23,13 +23,13 @@ THE SOFTWARE. ****************************************************************************/ #define __CC_PLATFORM_FILEUTILS_CPP__ -#include "CCFileUtilsCommon_cpp.h" +#include "platform/CCFileUtilsCommon_cpp.h" using namespace std; NS_CC_BEGIN -#include "CCCommon.h" +#include "platform/CCCommon.h" #include "jni/SystemInfoJni.h" // record the resource path diff --git a/cocos2dx/platform/android/CCImage.cpp b/cocos2dx/platform/android/CCImage.cpp index 00d0b064ec..333d6f0e87 100644 --- a/cocos2dx/platform/android/CCImage.cpp +++ b/cocos2dx/platform/android/CCImage.cpp @@ -25,16 +25,15 @@ THE SOFTWARE. //#define COCOS2D_DEBUG 1 #define __CC_PLATFORM_IMAGE_CPP__ -#include "CCImageCommon_cpp.h" +#include "platform/CCImageCommon_cpp.h" +#include "platform/CCPlatformMacros.h" +#include "CCImage.h" +#include "jni/JniHelper.h" #include #include #include -#include "CCPlatformMacros.h" -#include "CCImage.h" -#include "jni/JniHelper.h" - NS_CC_BEGIN diff --git a/cocos2dx/platform/android/CCStdC.h b/cocos2dx/platform/android/CCStdC.h index c959eefe13..21747332ef 100644 --- a/cocos2dx/platform/android/CCStdC.h +++ b/cocos2dx/platform/android/CCStdC.h @@ -25,7 +25,7 @@ THE SOFTWARE. #ifndef __CC_STD_C_H__ #define __CC_STD_C_H__ -#include "CCPlatformMacros.h" +#include "platform/CCPlatformMacros.h" #include #include #include diff --git a/cocos2dx/platform/android/jni/IMEJni.cpp b/cocos2dx/platform/android/jni/IMEJni.cpp index 5e3937bb9e..9a6b548aea 100644 --- a/cocos2dx/platform/android/jni/IMEJni.cpp +++ b/cocos2dx/platform/android/jni/IMEJni.cpp @@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "IMEJni.h" -#include "CCIMEDispatcher.h" +#include "text_input_node/CCIMEDispatcher.h" #include "JniHelper.h" #include diff --git a/cocos2dx/platform/android/jni/JniHelper.h b/cocos2dx/platform/android/jni/JniHelper.h index f23d3ca1c6..7d716b2da0 100644 --- a/cocos2dx/platform/android/jni/JniHelper.h +++ b/cocos2dx/platform/android/jni/JniHelper.h @@ -26,7 +26,7 @@ THE SOFTWARE. #include #include -#include "CCPlatformMacros.h" +#include "platform/CCPlatformMacros.h" NS_CC_BEGIN diff --git a/cocos2dx/platform/android/jni/MessageJni.cpp b/cocos2dx/platform/android/jni/MessageJni.cpp index 024633c953..e7c85ea6df 100644 --- a/cocos2dx/platform/android/jni/MessageJni.cpp +++ b/cocos2dx/platform/android/jni/MessageJni.cpp @@ -24,8 +24,8 @@ THE SOFTWARE. #include "MessageJni.h" #include "CCDirector.h" #include "JniHelper.h" -#include "CCApplication.h" -#include "CCFileUtils.h" +#include "../CCApplication.h" +#include "platform/CCFileUtils.h" #include "CCEventType.h" #include "extensions/CCNotificationCenter/CCNotificationCenter.h" diff --git a/cocos2dx/platform/android/jni/SensorJni.cpp b/cocos2dx/platform/android/jni/SensorJni.cpp index 18ba9a2c37..361ccdf9e4 100644 --- a/cocos2dx/platform/android/jni/SensorJni.cpp +++ b/cocos2dx/platform/android/jni/SensorJni.cpp @@ -22,10 +22,9 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "SensorJni.h" -#include "CCGeometry.h" -#include "CCAccelerometer.h" +#include "cocoa/CCGeometry.h" #include "platform/android/CCAccelerometer.h" -#include "CCEGLView.h" +#include "../CCEGLView.h" #include "JniHelper.h" #include #include diff --git a/cocos2dx/platform/android/jni/SystemInfoJni.cpp b/cocos2dx/platform/android/jni/SystemInfoJni.cpp index 759f4bd710..5f5d7a921f 100644 --- a/cocos2dx/platform/android/jni/SystemInfoJni.cpp +++ b/cocos2dx/platform/android/jni/SystemInfoJni.cpp @@ -23,7 +23,7 @@ THE SOFTWARE. ****************************************************************************/ #include "SystemInfoJni.h" #include "JniHelper.h" -#include "CCString.h" +#include "cocoa/CCString.h" #include #include diff --git a/cocos2dx/platform/android/jni/TouchesJni.cpp b/cocos2dx/platform/android/jni/TouchesJni.cpp index 1d066ea0b6..62ed575602 100644 --- a/cocos2dx/platform/android/jni/TouchesJni.cpp +++ b/cocos2dx/platform/android/jni/TouchesJni.cpp @@ -21,12 +21,12 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "CCSet.h" +#include "cocoa/CCSet.h" #include "CCDirector.h" -#include "CCKeypadDispatcher.h" -#include "CCTouch.h" -#include "CCEGLView.h" -#include "CCTouchDispatcher.h" +#include "keypad_dispatcher/CCKeypadDispatcher.h" +#include "touch_dispatcher/CCTouch.h" +#include "../CCEGLView.h" +#include "touch_dispatcher/CCTouchDispatcher.h" #include #include diff --git a/cocos2dx/shaders/CCGLProgram.cpp b/cocos2dx/shaders/CCGLProgram.cpp index 94e464a8e3..7b6ecf4428 100644 --- a/cocos2dx/shaders/CCGLProgram.cpp +++ b/cocos2dx/shaders/CCGLProgram.cpp @@ -28,9 +28,9 @@ THE SOFTWARE. #include "CCGLProgram.h" #include "ccGLStateCache.h" #include "ccMacros.h" -#include "CCFileUtils.h" +#include "platform/CCFileUtils.h" #include "support/data_support/uthash.h" -#include "CCString.h" +#include "cocoa/CCString.h" // extern #include "kazmath/GL/matrix.h" #include "kazmath/kazmath.h" diff --git a/cocos2dx/sprite_nodes/CCAnimation.cpp b/cocos2dx/sprite_nodes/CCAnimation.cpp index 28c1e6853f..1d7af65e4c 100644 --- a/cocos2dx/sprite_nodes/CCAnimation.cpp +++ b/cocos2dx/sprite_nodes/CCAnimation.cpp @@ -24,11 +24,11 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCAnimation.h" -#include "CCTextureCache.h" -#include "CCTexture2D.h" +#include "textures/CCTextureCache.h" +#include "textures/CCTexture2D.h" #include "ccMacros.h" -#include "CCSpriteFrame.h" -#include "CCZone.h" +#include "sprite_nodes/CCSpriteFrame.h" +#include "cocoa/CCZone.h" NS_CC_BEGIN diff --git a/cocos2dx/sprite_nodes/CCAnimationCache.cpp b/cocos2dx/sprite_nodes/CCAnimationCache.cpp index bba721d5f5..328800cd1b 100644 --- a/cocos2dx/sprite_nodes/CCAnimationCache.cpp +++ b/cocos2dx/sprite_nodes/CCAnimationCache.cpp @@ -28,8 +28,8 @@ THE SOFTWARE. #include "CCAnimation.h" #include "CCSpriteFrame.h" #include "CCSpriteFrameCache.h" -#include "CCString.h" -#include "CCFileUtils.h" +#include "cocoa/CCString.h" +#include "platform/CCFileUtils.h" using namespace std; diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index e0525895e0..2aff4cc096 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -31,17 +31,17 @@ THE SOFTWARE. #include "CCSprite.h" #include "CCSpriteFrame.h" #include "CCSpriteFrameCache.h" -#include "CCTextureCache.h" +#include "textures/CCTextureCache.h" #include "CCDrawingPrimitives.h" -#include "CCShaderCache.h" -#include "ccGLStateCache.h" -#include "CCGLProgram.h" +#include "shaders/CCShaderCache.h" +#include "shaders/ccGLStateCache.h" +#include "shaders/CCGLProgram.h" #include "CCDirector.h" -#include "CCPointExtension.h" +#include "support/CCPointExtension.h" #include "CCDrawingPrimitives.h" -#include "CCGeometry.h" -#include "CCTexture2D.h" -#include "CCAffineTransform.h" +#include "cocoa/CCGeometry.h" +#include "textures/CCTexture2D.h" +#include "cocoa/CCAffineTransform.h" #include "support/TransformUtils.h" #include "support/CCProfiling.h" // external diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp index 77334eb979..ac82b54d03 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp @@ -29,11 +29,11 @@ THE SOFTWARE. #include "CCSprite.h" #include "effects/CCGrid.h" #include "CCDrawingPrimitives.h" -#include "CCTextureCache.h" -#include "CCPointExtension.h" -#include "CCShaderCache.h" -#include "CCGLProgram.h" -#include "ccGLStateCache.h" +#include "textures/CCTextureCache.h" +#include "support/CCPointExtension.h" +#include "shaders/CCShaderCache.h" +#include "shaders/CCGLProgram.h" +#include "shaders/ccGLStateCache.h" #include "CCDirector.h" #include "support/TransformUtils.h" #include "support/CCProfiling.h" diff --git a/cocos2dx/sprite_nodes/CCSpriteFrame.cpp b/cocos2dx/sprite_nodes/CCSpriteFrame.cpp index 4f1ab52cb9..4a0a8c1fbf 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrame.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrame.cpp @@ -23,7 +23,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "CCTextureCache.h" +#include "textures/CCTextureCache.h" #include "CCSpriteFrame.h" #include "CCDirector.h" diff --git a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp index b7086ca31b..056ed7f98b 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrameCache.cpp @@ -28,15 +28,15 @@ THE SOFTWARE. #include "cocoa/CCNS.h" #include "ccMacros.h" -#include "CCTextureCache.h" +#include "textures/CCTextureCache.h" #include "CCSpriteFrameCache.h" #include "CCSpriteFrame.h" #include "CCSprite.h" #include "support/TransformUtils.h" -#include "CCFileUtils.h" -#include "CCString.h" -#include "CCArray.h" -#include "CCDictionary.h" +#include "platform/CCFileUtils.h" +#include "cocoa/CCString.h" +#include "cocoa/CCArray.h" +#include "cocoa/CCDictionary.h" #include using namespace std; diff --git a/cocos2dx/support/TransformUtils.cpp b/cocos2dx/support/TransformUtils.cpp index 1daa87e36f..0958670e22 100644 --- a/cocos2dx/support/TransformUtils.cpp +++ b/cocos2dx/support/TransformUtils.cpp @@ -24,7 +24,7 @@ THE SOFTWARE. ****************************************************************************/ #include "TransformUtils.h" -#include "CCAffineTransform.h" +#include "cocoa/CCAffineTransform.h" namespace cocos2d { diff --git a/cocos2dx/support/data_support/ccCArray.cpp b/cocos2dx/support/data_support/ccCArray.cpp index dd7966e873..3255ac7289 100644 --- a/cocos2dx/support/data_support/ccCArray.cpp +++ b/cocos2dx/support/data_support/ccCArray.cpp @@ -24,7 +24,7 @@ THE SOFTWARE. ****************************************************************************/ #include "ccCArray.h" -#include "CCObject.h" +#include "cocoa/CCObject.h" NS_CC_BEGIN diff --git a/cocos2dx/textures/CCTexture2D.cpp b/cocos2dx/textures/CCTexture2D.cpp index 7f3598e4fd..4916e0bb57 100644 --- a/cocos2dx/textures/CCTexture2D.cpp +++ b/cocos2dx/textures/CCTexture2D.cpp @@ -35,15 +35,15 @@ THE SOFTWARE. #include "ccMacros.h" #include "CCConfiguration.h" #include "platform/platform.h" -#include "CCImage.h" +#include "platform/CCImage.h" #include "CCGL.h" #include "support/ccUtils.h" #include "platform/CCPlatformMacros.h" -#include "CCTexturePVR.h" +#include "textures/CCTexturePVR.h" #include "CCDirector.h" -#include "CCGLProgram.h" -#include "ccGLStateCache.h" -#include "CCShaderCache.h" +#include "shaders/CCGLProgram.h" +#include "shaders/ccGLStateCache.h" +#include "shaders/CCShaderCache.h" #if CC_ENABLE_CACHE_TEXTURE_DATA #include "CCTextureCache.h" diff --git a/cocos2dx/textures/CCTextureAtlas.cpp b/cocos2dx/textures/CCTextureAtlas.cpp index 1ef0c59c81..9c1ca76f65 100644 --- a/cocos2dx/textures/CCTextureAtlas.cpp +++ b/cocos2dx/textures/CCTextureAtlas.cpp @@ -28,13 +28,13 @@ THE SOFTWARE. #include "CCTextureAtlas.h" #include "CCTextureCache.h" #include "ccMacros.h" -#include "CCGLProgram.h" -#include "ccGLStateCache.h" +#include "shaders/CCGLProgram.h" +#include "shaders/ccGLStateCache.h" #include "extensions/CCNotificationCenter/CCNotificationCenter.h" #include "CCEventType.h" // support #include "CCTexture2D.h" -#include "CCString.h" +#include "cocoa/CCString.h" #include //According to some tests GL_TRIANGLE_STRIP is slower, MUCH slower. Probably I'm doing something very wrong diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index 14ec6419ed..06522e8219 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -24,25 +24,25 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include -#include -#include -#include -#include #include "CCTextureCache.h" #include "CCTexture2D.h" #include "ccMacros.h" #include "CCDirector.h" #include "platform/platform.h" -#include "CCFileUtils.h" -#include "CCImage.h" +#include "platform/CCFileUtils.h" +#include "platform/CCThread.h" +#include "platform/CCImage.h" #include "support/ccUtils.h" #include "CCScheduler.h" -#include "pthread.h" -#include "CCThread.h" -#include "semaphore.h" -#include "CCString.h" +#include "cocoa/CCString.h" #include +#include +#include +#include +#include +#include +#include +#include using namespace std; diff --git a/cocos2dx/textures/CCTexturePVR.cpp b/cocos2dx/textures/CCTexturePVR.cpp index 0028e2b34f..ae8e826fba 100755 --- a/cocos2dx/textures/CCTexturePVR.cpp +++ b/cocos2dx/textures/CCTexturePVR.cpp @@ -30,9 +30,9 @@ THE SOFTWARE. #include "CCConfiguration.h" #include "support/ccUtils.h" #include "CCStdC.h" -#include "CCFileUtils.h" +#include "platform/CCFileUtils.h" #include "support/zip_support/ZipUtils.h" -#include "ccGLStateCache.h" +#include "shaders/ccGLStateCache.h" #include NS_CC_BEGIN diff --git a/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.cpp b/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.cpp index 2d5fb74957..acac250722 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.cpp @@ -24,7 +24,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCParallaxNode.h" -#include "CCPointExtension.h" +#include "support/CCPointExtension.h" #include "support/data_support/ccCArray.h" NS_CC_BEGIN diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp index 9c06e4a902..fc52c93355 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp @@ -26,11 +26,11 @@ THE SOFTWARE. #include "CCTMXLayer.h" #include "CCTMXXMLParser.h" #include "CCTMXTiledMap.h" -#include "CCSprite.h" -#include "CCTextureCache.h" -#include "CCShaderCache.h" -#include "CCGLProgram.h" -#include "CCPointExtension.h" +#include "sprite_nodes/CCSprite.h" +#include "textures/CCTextureCache.h" +#include "shaders/CCShaderCache.h" +#include "shaders/CCGLProgram.h" +#include "support/CCPointExtension.h" #include "support/data_support/ccCArray.h" #include "CCDirector.h" diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp index 2920f6cec5..17d2b25ed3 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.cpp @@ -26,8 +26,8 @@ THE SOFTWARE. #include "CCTMXTiledMap.h" #include "CCTMXXMLParser.h" #include "CCTMXLayer.h" -#include "CCSprite.h" -#include "CCPointExtension.h" +#include "sprite_nodes/CCSprite.h" +#include "support/CCPointExtension.h" NS_CC_BEGIN diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp index c58ba1b371..7c6b3db0ca 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.cpp @@ -29,9 +29,9 @@ THE SOFTWARE. #include "CCTMXXMLParser.h" #include "CCTMXTiledMap.h" #include "ccMacros.h" -#include "CCFileUtils.h" +#include "platform/CCFileUtils.h" #include "support/zip_support/ZipUtils.h" -#include "CCPointExtension.h" +#include "support/CCPointExtension.h" #include "support/base64.h" #include "platform/platform.h" diff --git a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp index 7fb8899ca0..2760737c98 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.cpp @@ -24,12 +24,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCTileMapAtlas.h" -#include "CCFileUtils.h" -#include "CCTextureAtlas.h" +#include "platform/CCFileUtils.h" +#include "textures/CCTextureAtlas.h" #include "support/image_support/TGAlib.h" #include "ccConfig.h" -#include "CCDictionary.h" -#include "CCInteger.h" +#include "cocoa/CCDictionary.h" +#include "cocoa/CCInteger.h" #include "CCDirector.h" NS_CC_BEGIN @@ -155,9 +155,9 @@ void CCTileMapAtlas::setTile(const ccColor3B& tile, const ccGridSize& position) { ptr[position.x + position.y * m_pTGAInfo->width] = tile; - // XXX: this method consumes a lot of memory - // XXX: a tree of something like that shall be impolemented - CCInteger *num = (CCInteger*)m_pPosToAtlasIndex->objectForKey(CCString::createWithFormat("%d,%d", position.x, position.y)->getCString()); + // XXX: this method consumes a lot of memory + // XXX: a tree of something like that shall be impolemented + CCInteger *num = (CCInteger*)m_pPosToAtlasIndex->objectForKey(CCString::createWithFormat("%d,%d", position.x, position.y)->getCString()); this->updateAtlasValueAt(position, tile, num->getValue()); } } @@ -186,7 +186,7 @@ void CCTileMapAtlas::updateAtlasValueAt(const ccGridSize& pos, const ccColor3B& float textureWide = (float) (m_pTextureAtlas->getTexture()->getPixelsWide()); float textureHigh = (float) (m_pTextureAtlas->getTexture()->getPixelsHigh()); - float itemWidthInPixels = m_uItemWidth * CC_CONTENT_SCALE_FACTOR(); + float itemWidthInPixels = m_uItemWidth * CC_CONTENT_SCALE_FACTOR(); float itemHeightInPixels = m_uItemHeight * CC_CONTENT_SCALE_FACTOR(); #if CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL @@ -223,10 +223,10 @@ void CCTileMapAtlas::updateAtlasValueAt(const ccGridSize& pos, const ccColor3B& quad.tr.vertices.y = (float)(y * m_uItemHeight + m_uItemHeight); quad.tr.vertices.z = 0.0f; - ccColor4B color = { m_tColor.r, m_tColor.g, m_tColor.b, m_cOpacity }; - quad.tr.colors = color; - quad.tl.colors = color; - quad.br.colors = color; + ccColor4B color = { m_tColor.r, m_tColor.g, m_tColor.b, m_cOpacity }; + quad.tr.colors = color; + quad.tl.colors = color; + quad.br.colors = color; quad.bl.colors = color; m_pTextureAtlas->updateQuad(&quad, index); @@ -251,10 +251,10 @@ void CCTileMapAtlas::updateAtlasValues() { this->updateAtlasValueAt(ccg(x,y), value, total); - CCString *key = CCString::createWithFormat("%d,%d", x,y); - CCInteger *num = CCInteger::create(total); - m_pPosToAtlasIndex->setObject(num, key->getCString()); - + CCString *key = CCString::createWithFormat("%d,%d", x,y); + CCInteger *num = CCInteger::create(total); + m_pPosToAtlasIndex->setObject(num, key->getCString()); + total++; } } diff --git a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp index 3435c5ccea..ba46d4d3e7 100644 --- a/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp +++ b/cocos2dx/touch_dispatcher/CCTouchDispatcher.cpp @@ -25,10 +25,10 @@ THE SOFTWARE. #include "CCTouchDispatcher.h" #include "CCTouchHandler.h" -#include "CCArray.h" -#include "CCSet.h" +#include "cocoa/CCArray.h" +#include "cocoa/CCSet.h" #include "CCTouch.h" -#include "CCTexture2D.h" +#include "textures/CCTexture2D.h" #include "support/data_support/ccCArray.h" #include "ccMacros.h" #include diff --git a/tests/tests/ActionsTest/ActionsTest.cpp b/tests/tests/ActionsTest/ActionsTest.cpp index b90cfc96af..1ad65b9133 100644 --- a/tests/tests/ActionsTest/ActionsTest.cpp +++ b/tests/tests/ActionsTest/ActionsTest.cpp @@ -1,5 +1,5 @@ #include "ActionsTest.h" -#include "testResource.h" +#include "../testResource.h" #include "cocos2d.h" From 591566b43afc254c4a4e6f96bcc08f84ad0e6962 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 19 Jun 2012 16:31:26 +0800 Subject: [PATCH 225/257] fixed #1335: Memory leaks in cocos2dx and CCBReader. --- .../CCBReader/CCBMemberVariableAssigner.h | 17 +- cocos2dx/extensions/CCBReader/CCBReader.cpp | 3 +- .../extensions/CCBReader/CCNodeLoader.cpp | 2 +- .../CCBReader/CCNodeLoaderLibrary.cpp | 1 + cocos2dx/label_nodes/CCLabelBMFont.cpp | 19 +- cocos2dx/platform/CCFileUtils.h | 4 +- cocos2dx/platform/CCImageCommon_cpp.h | 28 +- cocos2dx/platform/CCSAXParser.cpp | 13 +- cocos2dx/platform/ios/CCFileUtils.mm | 3 +- cocos2dx/platform/ios/CCImage.mm | 38 +- cocos2dx/platform/win32/CCFileUtils.cpp | 7 +- cocos2dx/support/image_support/TGAlib.cpp | 6 +- cocos2dx/support/zip_support/ZipUtils.cpp | 443 +++++++++--------- cocos2dx/textures/CCTextureCache.cpp | 15 +- cocos2dx/textures/CCTexturePVR.cpp | 4 +- .../ButtonTest/ButtonTestLayer.cpp | 9 + .../ButtonTest/ButtonTestLayer.h | 19 +- .../HelloCocosBuilderLayer.cpp | 11 + .../HelloCocosBuilderLayer.h | 3 + .../MenuTest/MenuTestLayer.cpp | 8 + .../CocosBuilderTest/MenuTest/MenuTestLayer.h | 3 + 21 files changed, 362 insertions(+), 294 deletions(-) diff --git a/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h b/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h index 3a0cb73812..eda0f81e23 100644 --- a/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h +++ b/cocos2dx/extensions/CCBReader/CCBMemberVariableAssigner.h @@ -5,12 +5,17 @@ NS_CC_EXT_BEGIN -#define CCB_MEMBERVARIABLEASSIGNER_GLUE(TARGET, MEMBERVARIABLENAME, MEMBERVARIABLETYPE, MEMBERVARIABLE) if(pTarget == TARGET && pMemberVariableName->compare(MEMBERVARIABLENAME) == 0) { \ - MEMBERVARIABLE = dynamic_cast(pNode); \ - CC_ASSERT(MEMBERVARIABLE); \ - MEMBERVARIABLE->retain(); \ - return true; \ -} +#define CCB_MEMBERVARIABLEASSIGNER_GLUE(TARGET, MEMBERVARIABLENAME, MEMBERVARIABLETYPE, MEMBERVARIABLE) \ + if (pTarget == TARGET && pMemberVariableName->compare(MEMBERVARIABLENAME) == 0) { \ + MEMBERVARIABLETYPE pOldVar = MEMBERVARIABLE; \ + MEMBERVARIABLE = dynamic_cast(pNode); \ + CC_ASSERT(MEMBERVARIABLE); \ + if (pOldVar != MEMBERVARIABLE) { \ + CC_SAFE_RELEASE(pOldVar); \ + MEMBERVARIABLE->retain(); \ + } \ + return true; \ + } class CC_DLL CCBMemberVariableAssigner { public: diff --git a/cocos2dx/extensions/CCBReader/CCBReader.cpp b/cocos2dx/extensions/CCBReader/CCBReader.cpp index a205dab924..822406653f 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader.cpp @@ -359,7 +359,8 @@ bool CCBReader::isSpriteSheetLoaded(CCString * pSpriteSheet) { } void CCBReader::addLoadedSpriteSheet(CCString * pSpriteSheet) { - pSpriteSheet->retain(); + // Since std::set will copy the string from pSpriteSheet, we needn't to retain 'pSpriteSheet'. + // pSpriteSheet->retain(); this->mLoadedSpriteSheets.insert(pSpriteSheet->m_sString); } diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp index e658508c31..5ebc34972b 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp @@ -414,7 +414,7 @@ CCSpriteFrame * CCNodeLoader::parsePropTypeSpriteFrame(CCNode * pNode, CCNode * CCString * spriteFilePath = CCBReader::concat(pCCBReader->getCCBRootPath(), spriteFile); CCTexture2D * texture = CCTextureCache::sharedTextureCache()->addImage(spriteFilePath->getCString()); - CCRect bounds = CCRect::CCRect(0, 0, texture->getContentSize().width, texture->getContentSize().height); + CCRect bounds = CCRectMake(0, 0, texture->getContentSize().width, texture->getContentSize().height); spriteFrame = CCSpriteFrame::frameWithTexture(texture, bounds); } else { CCSpriteFrameCache * frameCache = CCSpriteFrameCache::sharedSpriteFrameCache(); diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp index 1d1b2bca93..ff25b171ac 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp +++ b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp @@ -73,6 +73,7 @@ CCNodeLoader * CCNodeLoaderLibrary::getCCNodeLoader(CCString * pClassName) { void CCNodeLoaderLibrary::purge(bool pReleaseCCNodeLoaders) { if(pReleaseCCNodeLoaders) { for(CCNodeLoaderMap::iterator it = this->mCCNodeLoaders.begin(); it != this->mCCNodeLoaders.end(); it++) { + it->first->release(); it->second->release(); } } diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index 8167357579..de86c8afaf 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -359,23 +359,24 @@ static std::vector cc_utf16_vec_from_utf16_str(const unsigned sh // //FNTConfig Cache - free functions // -CCDictionary *configurations = NULL; +static CCDictionary* s_pConfigurations = NULL; + CCBMFontConfiguration* FNTConfigLoadFile( const char *fntFile) { CCBMFontConfiguration* pRet = NULL; - if( configurations == NULL ) + if( s_pConfigurations == NULL ) { - configurations = new CCDictionary(); + s_pConfigurations = new CCDictionary(); } - pRet = (CCBMFontConfiguration*)configurations->objectForKey(fntFile); + pRet = (CCBMFontConfiguration*)s_pConfigurations->objectForKey(fntFile); if( pRet == NULL ) { pRet = CCBMFontConfiguration::create(fntFile); if (pRet) { - configurations->setObject(pRet, fntFile); + s_pConfigurations->setObject(pRet, fntFile); } } @@ -384,10 +385,10 @@ CCBMFontConfiguration* FNTConfigLoadFile( const char *fntFile) void FNTConfigRemoveCache( void ) { - if (configurations) + if (s_pConfigurations) { - configurations->removeAllObjects(); - CC_SAFE_RELEASE_NULL(configurations); + s_pConfigurations->removeAllObjects(); + CC_SAFE_RELEASE_NULL(s_pConfigurations); } } @@ -1363,8 +1364,8 @@ void CCLabelBMFont::setFntFile(const char* fntFile) m_sFntFile = fntFile; - CC_SAFE_RELEASE(m_pConfiguration); CC_SAFE_RETAIN(newConf); + CC_SAFE_RELEASE(m_pConfiguration); m_pConfiguration = newConf; this->setTexture(CCTextureCache::sharedTextureCache()->addImage(m_pConfiguration->getAtlasName())); diff --git a/cocos2dx/platform/CCFileUtils.h b/cocos2dx/platform/CCFileUtils.h index 2b5221f696..0459244d08 100644 --- a/cocos2dx/platform/CCFileUtils.h +++ b/cocos2dx/platform/CCFileUtils.h @@ -44,7 +44,7 @@ public: @param[in] pszMode The read mode of the file @param[out] pSize If get the file data succeed the it will be the data size,or it will be 0 @return if success,the pointer of data will be returned,or NULL is returned - @warning If you get the file data succeed,you must delete it after used. + @warning If you get the file data succeed,you must delete[] it after used. */ unsigned char* getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize); @@ -53,7 +53,7 @@ public: @param[in] pszFileName The resource file name which contain the relative path of zip file @param[out] pSize If get the file data succeed the it will be the data size,or it will be 0 @return if success,the pointer of data will be returned,or NULL is returned - @warning If you get the file data succeed,you must delete it after used. + @warning If you get the file data succeed,you must delete[] it after used. */ unsigned char* getFileDataFromZip(const char* pszZipFilePath, const char* pszFileName, unsigned long * pSize); diff --git a/cocos2dx/platform/CCImageCommon_cpp.h b/cocos2dx/platform/CCImageCommon_cpp.h index cf0a451e36..4d65976e7f 100644 --- a/cocos2dx/platform/CCImageCommon_cpp.h +++ b/cocos2dx/platform/CCImageCommon_cpp.h @@ -94,22 +94,28 @@ CCImage::~CCImage() bool CCImage::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFmtPng*/) { - CC_UNUSED_PARAM(eImgFmt); - - unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->getFileData(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(strPath), "rb", &nSize); - - return initWithImageData(pBuffer, nSize, eImgFmt); + bool bRet = false; + unsigned long nSize = 0; + unsigned char* pBuffer = CCFileUtils::sharedFileUtils()->getFileData(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(strPath), "rb", &nSize); + if (pBuffer != NULL && nSize > 0) + { + bRet = initWithImageData(pBuffer, nSize, eImgFmt); + } + CC_SAFE_DELETE_ARRAY(pBuffer); + return bRet; } bool CCImage::initWithImageFileThreadSafe(const char *fullpath, EImageFormat imageType) { - CC_UNUSED_PARAM(imageType); - - unsigned long nSize; + bool bRet = false; + unsigned long nSize = 0; unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->getFileData(fullpath, "rb", &nSize); - - return initWithImageData(pBuffer, nSize, imageType); + if (pBuffer != NULL && nSize > 0) + { + bRet = initWithImageData(pBuffer, nSize, imageType); + } + CC_SAFE_DELETE_ARRAY(pBuffer); + return bRet; } bool CCImage::initWithImageData(void * pData, diff --git a/cocos2dx/platform/CCSAXParser.cpp b/cocos2dx/platform/CCSAXParser.cpp index a351d8099a..a1ee98ef5e 100644 --- a/cocos2dx/platform/CCSAXParser.cpp +++ b/cocos2dx/platform/CCSAXParser.cpp @@ -83,14 +83,15 @@ bool CCSAXParser::parse(const char* pXMLData, unsigned int uDataLength) bool CCSAXParser::parse(const char *pszFile) { - unsigned long size; - char *pBuffer = (char*)CCFileUtils::sharedFileUtils()->getFileData(pszFile, "rt", &size); - - if (!pBuffer) + bool bRet = false; + unsigned long size = 0; + char* pBuffer = (char*)CCFileUtils::sharedFileUtils()->getFileData(pszFile, "rt", &size); + if (pBuffer != NULL && size > 0) { - return false; + bRet = parse(pBuffer, size); } - return parse(pBuffer, size); + CC_SAFE_DELETE_ARRAY(pBuffer); + return bRet; } void CCSAXParser::startElement(void *ctx, const CC_XML_CHAR *name, const CC_XML_CHAR **atts) diff --git a/cocos2dx/platform/ios/CCFileUtils.mm b/cocos2dx/platform/ios/CCFileUtils.mm index 0ab53e89be..229212aa87 100644 --- a/cocos2dx/platform/ios/CCFileUtils.mm +++ b/cocos2dx/platform/ios/CCFileUtils.mm @@ -447,7 +447,8 @@ CCArray* ccFileUtils_arrayWithContentsOfFileThreadSafe(const char* pFileName) unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize) { unsigned char * pBuffer = NULL; - + CCAssert(pszFileName != NULL && pSize != NULL && pszMode != NULL, "Invaild parameters."); + *pSize = 0; do { // read the file from hardware diff --git a/cocos2dx/platform/ios/CCImage.mm b/cocos2dx/platform/ios/CCImage.mm index c46644dc2f..43932a9654 100644 --- a/cocos2dx/platform/ios/CCImage.mm +++ b/cocos2dx/platform/ios/CCImage.mm @@ -359,23 +359,35 @@ CCImage::~CCImage() bool CCImage::initWithImageFile(const char * strPath, EImageFormat eImgFmt/* = eFmtPng*/) { - unsigned long nSize; - CCFileUtils *fileUtils = CCFileUtils::sharedFileUtils(); - unsigned char *pBuffer = fileUtils->getFileData(fileUtils->fullPathFromRelativePath(strPath), "rb", &nSize); - - return initWithImageData(pBuffer, nSize, eImgFmt); + bool bRet = false; + unsigned long nSize = 0; + unsigned char* pBuffer = CCFileUtils::sharedFileUtils()->getFileData( + CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(strPath), + "rb", + &nSize); + + if (pBuffer != NULL && nSize > 0) + { + bRet = initWithImageData(pBuffer, nSize, eImgFmt); + } + CC_SAFE_DELETE_ARRAY(pBuffer); + return bRet; } bool CCImage::initWithImageFileThreadSafe(const char *fullpath, EImageFormat imageType) { - CC_UNUSED_PARAM(imageType); - /* - * CCFileUtils::fullPathFromRelativePath() is not thread-safe, it use autorelease(). - */ - unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->getFileData(fullpath, "rb", &nSize); - - return initWithImageData(pBuffer, nSize, imageType); + /* + * CCFileUtils::fullPathFromRelativePath() is not thread-safe, it use autorelease(). + */ + bool bRet = false; + unsigned long nSize = 0; + unsigned char* pBuffer = CCFileUtils::sharedFileUtils()->getFileData(fullpath, "rb", &nSize); + if (pBuffer != NULL && nSize > 0) + { + bRet = initWithImageData(pBuffer, nSize, imageType); + } + CC_SAFE_DELETE_ARRAY(pBuffer); + return bRet; } bool CCImage::initWithImageData(void * pData, diff --git a/cocos2dx/platform/win32/CCFileUtils.cpp b/cocos2dx/platform/win32/CCFileUtils.cpp index 87ee6ef4ed..f6ce0c42e2 100644 --- a/cocos2dx/platform/win32/CCFileUtils.cpp +++ b/cocos2dx/platform/win32/CCFileUtils.cpp @@ -190,10 +190,11 @@ const char *CCFileUtils::fullPathFromRelativeFile(const char *pszFilename, const return pRet->m_sString.c_str(); } -unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* pszMode, unsigned long * pSize) +unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* pszMode, unsigned long* pSize) { - unsigned char * pBuffer = NULL; - + unsigned char* pBuffer = NULL; + CCAssert(pszFileName != NULL && pSize != NULL && pszMode != NULL, "Invaild parameters."); + *pSize = 0; do { // read the file from hardware diff --git a/cocos2dx/support/image_support/TGAlib.cpp b/cocos2dx/support/image_support/TGAlib.cpp index 7f97cfafe0..5e81daca0f 100644 --- a/cocos2dx/support/image_support/TGAlib.cpp +++ b/cocos2dx/support/image_support/TGAlib.cpp @@ -198,8 +198,8 @@ tImageTGA * tgaLoad(const char *pszFilename) int mode,total; tImageTGA *info = NULL; - unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->getFileData(pszFilename, "rb", &nSize); + unsigned long nSize = 0; + unsigned char* pBuffer = CCFileUtils::sharedFileUtils()->getFileData(pszFilename, "rb", &nSize); do { @@ -270,6 +270,8 @@ tImageTGA * tgaLoad(const char *pszFilename) } } while(0); + CC_SAFE_DELETE_ARRAY(pBuffer); + return info; } diff --git a/cocos2dx/support/zip_support/ZipUtils.cpp b/cocos2dx/support/zip_support/ZipUtils.cpp index ece5c179e5..199ba3db83 100644 --- a/cocos2dx/support/zip_support/ZipUtils.cpp +++ b/cocos2dx/support/zip_support/ZipUtils.cpp @@ -29,256 +29,255 @@ THE SOFTWARE. #include "ccMacros.h" #include "CCFileUtils.h" -namespace cocos2d +NS_CC_BEGIN + +// memory in iPhone is precious +// Should buffer factor be 1.5 instead of 2 ? +#define BUFFER_INC_FACTOR (2) + +int ZipUtils::ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int *outLength, unsigned int outLenghtHint) { - // memory in iPhone is precious - // Should buffer factor be 1.5 instead of 2 ? - #define BUFFER_INC_FACTOR (2) + /* ret value */ + int err = Z_OK; - int ZipUtils::ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int *outLength, unsigned int outLenghtHint) - { - /* ret value */ - int err = Z_OK; + int bufferSize = outLenghtHint; + *out = new unsigned char[bufferSize]; - int bufferSize = outLenghtHint; - *out = new unsigned char[bufferSize]; + z_stream d_stream; /* decompression stream */ + d_stream.zalloc = (alloc_func)0; + d_stream.zfree = (free_func)0; + d_stream.opaque = (voidpf)0; - z_stream d_stream; /* decompression stream */ - d_stream.zalloc = (alloc_func)0; - d_stream.zfree = (free_func)0; - d_stream.opaque = (voidpf)0; + d_stream.next_in = in; + d_stream.avail_in = inLength; + d_stream.next_out = *out; + d_stream.avail_out = bufferSize; - d_stream.next_in = in; - d_stream.avail_in = inLength; - d_stream.next_out = *out; - d_stream.avail_out = bufferSize; - - /* window size to hold 256k */ - if( (err = inflateInit2(&d_stream, 15 + 32)) != Z_OK ) - return err; - - for (;;) - { - err = inflate(&d_stream, Z_NO_FLUSH); - - if (err == Z_STREAM_END) - { - break; - } - - switch (err) - { - case Z_NEED_DICT: - err = Z_DATA_ERROR; - case Z_DATA_ERROR: - case Z_MEM_ERROR: - inflateEnd(&d_stream); - return err; - } - - // not enough memory ? - if (err != Z_STREAM_END) - { - delete [] *out; - *out = new unsigned char[bufferSize * BUFFER_INC_FACTOR]; - - /* not enough memory, ouch */ - if (! *out ) - { - CCLOG("cocos2d: ZipUtils: realloc failed"); - inflateEnd(&d_stream); - return Z_MEM_ERROR; - } - - d_stream.next_out = *out + bufferSize; - d_stream.avail_out = bufferSize; - bufferSize *= BUFFER_INC_FACTOR; - } - } - - *outLength = bufferSize - d_stream.avail_out; - err = inflateEnd(&d_stream); + /* window size to hold 256k */ + if( (err = inflateInit2(&d_stream, 15 + 32)) != Z_OK ) return err; - } - int ZipUtils::ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int outLengthHint) + for (;;) { - unsigned int outLength = 0; - int err = ccInflateMemoryWithHint(in, inLength, out, &outLength, outLengthHint); + err = inflate(&d_stream, Z_NO_FLUSH); - if (err != Z_OK || *out == NULL) { - if (err == Z_MEM_ERROR) - { - CCLOG("cocos2d: ZipUtils: Out of memory while decompressing map data!"); - } else - if (err == Z_VERSION_ERROR) - { - CCLOG("cocos2d: ZipUtils: Incompatible zlib version!"); - } else - if (err == Z_DATA_ERROR) - { - CCLOG("cocos2d: ZipUtils: Incorrect zlib compressed data!"); - } - else - { - CCLOG("cocos2d: ZipUtils: Unknown error while decompressing map data!"); - } - - delete[] *out; - *out = NULL; - outLength = 0; + if (err == Z_STREAM_END) + { + break; } - return outLength; + switch (err) + { + case Z_NEED_DICT: + err = Z_DATA_ERROR; + case Z_DATA_ERROR: + case Z_MEM_ERROR: + inflateEnd(&d_stream); + return err; + } + + // not enough memory ? + if (err != Z_STREAM_END) + { + delete [] *out; + *out = new unsigned char[bufferSize * BUFFER_INC_FACTOR]; + + /* not enough memory, ouch */ + if (! *out ) + { + CCLOG("cocos2d: ZipUtils: realloc failed"); + inflateEnd(&d_stream); + return Z_MEM_ERROR; + } + + d_stream.next_out = *out + bufferSize; + d_stream.avail_out = bufferSize; + bufferSize *= BUFFER_INC_FACTOR; + } } - int ZipUtils::ccInflateMemory(unsigned char *in, unsigned int inLength, unsigned char **out) - { - // 256k for hint - return ccInflateMemoryWithHint(in, inLength, out, 256 * 1024); + *outLength = bufferSize - d_stream.avail_out; + err = inflateEnd(&d_stream); + return err; +} + +int ZipUtils::ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int outLengthHint) +{ + unsigned int outLength = 0; + int err = ccInflateMemoryWithHint(in, inLength, out, &outLength, outLengthHint); + + if (err != Z_OK || *out == NULL) { + if (err == Z_MEM_ERROR) + { + CCLOG("cocos2d: ZipUtils: Out of memory while decompressing map data!"); + } else + if (err == Z_VERSION_ERROR) + { + CCLOG("cocos2d: ZipUtils: Incompatible zlib version!"); + } else + if (err == Z_DATA_ERROR) + { + CCLOG("cocos2d: ZipUtils: Incorrect zlib compressed data!"); + } + else + { + CCLOG("cocos2d: ZipUtils: Unknown error while decompressing map data!"); + } + + delete[] *out; + *out = NULL; + outLength = 0; } - int ZipUtils::ccInflateGZipFile(const char *path, unsigned char **out) + return outLength; +} + +int ZipUtils::ccInflateMemory(unsigned char *in, unsigned int inLength, unsigned char **out) +{ + // 256k for hint + return ccInflateMemoryWithHint(in, inLength, out, 256 * 1024); +} + +int ZipUtils::ccInflateGZipFile(const char *path, unsigned char **out) +{ + int len; + unsigned int offset = 0; + + CCAssert(out, ""); + CCAssert(&*out, ""); + + gzFile inFile = gzopen(path, "rb"); + if( inFile == NULL ) { + CCLOG("cocos2d: ZipUtils: error open gzip file: %s", path); + return -1; + } + + /* 512k initial decompress buffer */ + unsigned int bufferSize = 512 * 1024; + unsigned int totalBufferSize = bufferSize; + + *out = (unsigned char*)malloc( bufferSize ); + if( ! out ) { - int len; - unsigned int offset = 0; + CCLOG("cocos2d: ZipUtils: out of memory"); + return -1; + } - CCAssert(out, ""); - CCAssert(&*out, ""); - - gzFile inFile = gzopen(path, "rb"); - if( inFile == NULL ) { - CCLOG("cocos2d: ZipUtils: error open gzip file: %s", path); + for (;;) { + len = gzread(inFile, *out + offset, bufferSize); + if (len < 0) + { + CCLOG("cocos2d: ZipUtils: error in gzread"); + free( *out ); + *out = NULL; return -1; } + if (len == 0) + { + break; + } - /* 512k initial decompress buffer */ - unsigned int bufferSize = 512 * 1024; - unsigned int totalBufferSize = bufferSize; + offset += len; - *out = (unsigned char*)malloc( bufferSize ); - if( ! out ) + // finish reading the file + if( (unsigned int)len < bufferSize ) + { + break; + } + + bufferSize *= BUFFER_INC_FACTOR; + totalBufferSize += bufferSize; + unsigned char *tmp = (unsigned char*)realloc(*out, totalBufferSize ); + + if( ! tmp ) { CCLOG("cocos2d: ZipUtils: out of memory"); + free( *out ); + *out = NULL; return -1; } - for (;;) { - len = gzread(inFile, *out + offset, bufferSize); - if (len < 0) - { - CCLOG("cocos2d: ZipUtils: error in gzread"); - free( *out ); - *out = NULL; - return -1; - } - if (len == 0) - { - break; - } - - offset += len; - - // finish reading the file - if( (unsigned int)len < bufferSize ) - { - break; - } - - bufferSize *= BUFFER_INC_FACTOR; - totalBufferSize += bufferSize; - unsigned char *tmp = (unsigned char*)realloc(*out, totalBufferSize ); - - if( ! tmp ) - { - CCLOG("cocos2d: ZipUtils: out of memory"); - free( *out ); - *out = NULL; - return -1; - } - - *out = tmp; - } - - if (gzclose(inFile) != Z_OK) - { - CCLOG("cocos2d: ZipUtils: gzclose failed"); - } - - return offset; + *out = tmp; } - int ZipUtils::ccInflateCCZFile(const char *path, unsigned char **out) + if (gzclose(inFile) != Z_OK) { - CCAssert(out, ""); - CCAssert(&*out, ""); - - // load file into memory - unsigned char *compressed = NULL; - - int fileLen = 0; - compressed = CCFileUtils::sharedFileUtils()->getFileData(path, "rb", (unsigned long *)(&fileLen)); - // int fileLen = CCFileUtils::sharedFileUtils()->ccLoadFileIntoMemory( path, &compressed ); - - if( fileLen < 0 ) - { - CCLOG("cocos2d: Error loading CCZ compressed file"); - return -1; - } - - struct CCZHeader *header = (struct CCZHeader*) compressed; - - // verify header - if( header->sig[0] != 'C' || header->sig[1] != 'C' || header->sig[2] != 'Z' || header->sig[3] != '!' ) - { - CCLOG("cocos2d: Invalid CCZ file"); - delete [] compressed; - return -1; - } - - // verify header version - unsigned int version = CC_SWAP_INT16_BIG_TO_HOST( header->version ); - if( version > 2 ) - { - CCLOG("cocos2d: Unsupported CCZ header format"); - delete [] compressed; - return -1; - } - - // verify compression format - if( CC_SWAP_INT16_BIG_TO_HOST(header->compression_type) != CCZ_COMPRESSION_ZLIB ) - { - CCLOG("cocos2d: CCZ Unsupported compression method"); - delete [] compressed; - return -1; - } - - unsigned int len = CC_SWAP_INT32_BIG_TO_HOST( header->len ); - - *out = (unsigned char*)malloc( len ); - if(! *out ) - { - CCLOG("cocos2d: CCZ: Failed to allocate memory for texture"); - delete [] compressed; - return -1; - } - - - unsigned long destlen = len; - unsigned long source = (unsigned long) compressed + sizeof(*header); - int ret = uncompress(*out, &destlen, (Bytef*)source, fileLen - sizeof(*header) ); - - delete [] compressed; - - if( ret != Z_OK ) - { - CCLOG("cocos2d: CCZ: Failed to uncompress data"); - free( *out ); - *out = NULL; - return -1; - } - - return len; + CCLOG("cocos2d: ZipUtils: gzclose failed"); } -} // end of namespace cocos2d + return offset; +} + +int ZipUtils::ccInflateCCZFile(const char *path, unsigned char **out) +{ + CCAssert(out, ""); + CCAssert(&*out, ""); + + // load file into memory + unsigned char* compressed = NULL; + + unsigned long fileLen = 0; + compressed = CCFileUtils::sharedFileUtils()->getFileData(path, "rb", &fileLen); + + if(NULL == compressed || 0 == fileLen) + { + CCLOG("cocos2d: Error loading CCZ compressed file"); + return -1; + } + + struct CCZHeader *header = (struct CCZHeader*) compressed; + + // verify header + if( header->sig[0] != 'C' || header->sig[1] != 'C' || header->sig[2] != 'Z' || header->sig[3] != '!' ) + { + CCLOG("cocos2d: Invalid CCZ file"); + delete [] compressed; + return -1; + } + + // verify header version + unsigned int version = CC_SWAP_INT16_BIG_TO_HOST( header->version ); + if( version > 2 ) + { + CCLOG("cocos2d: Unsupported CCZ header format"); + delete [] compressed; + return -1; + } + + // verify compression format + if( CC_SWAP_INT16_BIG_TO_HOST(header->compression_type) != CCZ_COMPRESSION_ZLIB ) + { + CCLOG("cocos2d: CCZ Unsupported compression method"); + delete [] compressed; + return -1; + } + + unsigned int len = CC_SWAP_INT32_BIG_TO_HOST( header->len ); + + *out = (unsigned char*)malloc( len ); + if(! *out ) + { + CCLOG("cocos2d: CCZ: Failed to allocate memory for texture"); + delete [] compressed; + return -1; + } + + + unsigned long destlen = len; + unsigned long source = (unsigned long) compressed + sizeof(*header); + int ret = uncompress(*out, &destlen, (Bytef*)source, fileLen - sizeof(*header) ); + + delete [] compressed; + + if( ret != Z_OK ) + { + CCLOG("cocos2d: CCZ: Failed to uncompress data"); + free( *out ); + *out = NULL; + return -1; + } + + return len; +} + +NS_CC_END diff --git a/cocos2dx/textures/CCTextureCache.cpp b/cocos2dx/textures/CCTextureCache.cpp index 14ec6419ed..3cf920ada0 100644 --- a/cocos2dx/textures/CCTextureCache.cpp +++ b/cocos2dx/textures/CCTextureCache.cpp @@ -438,9 +438,10 @@ CCTexture2D * CCTextureCache::addImage(const char * path) } CCImage image; - unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->getFileData(fullpath.c_str(), "rb", &nSize); + unsigned long nSize = 0; + unsigned char* pBuffer = CCFileUtils::sharedFileUtils()->getFileData(fullpath.c_str(), "rb", &nSize); CC_BREAK_IF(! image.initWithImageData((void*)pBuffer, nSize, eImageFormat)); + CC_SAFE_DELETE_ARRAY(pBuffer); texture = new CCTexture2D(); texture->initWithImage(&image, resolution); @@ -453,8 +454,7 @@ CCTexture2D * CCTextureCache::addImage(const char * path) #endif m_pTextures->setObject(texture, pathKey.c_str()); - // autorelease prevents possible crash in multithreaded environments - texture->autorelease(); + texture->release(); } else { @@ -854,9 +854,8 @@ void VolatileTexture::reloadAllTextures() } else { - unsigned long nSize; - unsigned char *pBuffer = CCFileUtils::sharedFileUtils()->getFileData(vt->m_strFileName.c_str(), "rb", &nSize); - + unsigned long nSize = 0; + unsigned char* pBuffer = CCFileUtils::sharedFileUtils()->getFileData(vt->m_strFileName.c_str(), "rb", &nSize); if (image.initWithImageData((void*)pBuffer, nSize, vt->m_FmtImage)) { @@ -865,6 +864,8 @@ void VolatileTexture::reloadAllTextures() vt->texture->initWithImage(&image); CCTexture2D::setDefaultAlphaPixelFormat(oldPixelFormat); } + + CC_SAFE_DELETE_ARRAY(pBuffer); } } break; diff --git a/cocos2dx/textures/CCTexturePVR.cpp b/cocos2dx/textures/CCTexturePVR.cpp index 0028e2b34f..ce9a6a5f7b 100755 --- a/cocos2dx/textures/CCTexturePVR.cpp +++ b/cocos2dx/textures/CCTexturePVR.cpp @@ -421,12 +421,12 @@ bool CCTexturePVR::initWithContentsOfFile(const char* path) if (!unpackPVRData(pvrdata, pvrlen) || !createGLTexture()) { - delete [] pvrdata; + CC_SAFE_DELETE_ARRAY(pvrdata); this->release(); return false; } - delete [] pvrdata; + CC_SAFE_DELETE_ARRAY(pvrdata); return true; } diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp index 5ccf142ea6..6e5457b37e 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.cpp @@ -5,6 +5,15 @@ USING_NS_CC; USING_NS_CC_EXT; +ButtonTestLayer::ButtonTestLayer() +: mCCControlEventLabel(NULL) +{} + +ButtonTestLayer::~ButtonTestLayer() +{ + CC_SAFE_RELEASE(mCCControlEventLabel); +} + SEL_MenuHandler ButtonTestLayer::onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName) { return NULL; } diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h index 34aa2c01c7..0234353a2a 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h @@ -11,17 +11,20 @@ class ButtonTestLayer , public cocos2d::extension::CCBMemberVariableAssigner , public cocos2d::extension::CCBSelectorResolver { - public: - CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(ButtonTestLayer, node); +public: + CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(ButtonTestLayer, node); - virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); - virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); - virtual bool onAssignCCBMemberVariable(cocos2d::CCObject * pTarget, cocos2d::CCString * pMemberVariableName, cocos2d::CCNode * pNode); + ButtonTestLayer(); + virtual ~ButtonTestLayer(); - void onCCControlButtonClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); + virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); + virtual bool onAssignCCBMemberVariable(cocos2d::CCObject * pTarget, cocos2d::CCString * pMemberVariableName, cocos2d::CCNode * pNode); - private: - cocos2d::CCLabelBMFont * mCCControlEventLabel; + void onCCControlButtonClicked(cocos2d::CCObject * pSender, cocos2d::extension::CCControlEvent pCCControlEvent); + +private: + cocos2d::CCLabelBMFont * mCCControlEventLabel; }; #endif \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp index b26473bfa5..9c33fe7b97 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp @@ -14,6 +14,17 @@ USING_NS_CC; USING_NS_CC_EXT; +HelloCocosBuilderLayer::HelloCocosBuilderLayer() +: mBurstSprite(NULL) +, mTestTitleLabelTTF(NULL) +{} + +HelloCocosBuilderLayer::~HelloCocosBuilderLayer() +{ + CC_SAFE_RELEASE(mBurstSprite); + CC_SAFE_RELEASE(mTestTitleLabelTTF); +} + void HelloCocosBuilderLayer::openTest(const char * pCCBFileName, const char * pCCNodeName, CCNodeLoader * pCCNodeLoader) { /* Create an autorelease CCNodeLoaderLibrary. */ CCNodeLoaderLibrary * ccNodeLoaderLibrary = CCNodeLoaderLibrary::newDefaultCCNodeLoaderLibrary(); diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h index 1a3524b361..b5bc30e368 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h @@ -26,6 +26,9 @@ class HelloCocosBuilderLayer public: CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(HelloCocosBuilderLayer, node); + HelloCocosBuilderLayer(); + virtual ~HelloCocosBuilderLayer(); + void openTest(const char * pCCBFileName, const char * pCCNodeName = NULL, cocos2d::extension::CCNodeLoader * pCCNodeLoader = NULL); virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp index 9204ea6044..75ed49390c 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.cpp @@ -5,6 +5,14 @@ USING_NS_CC; USING_NS_CC_EXT; +MenuTestLayer::MenuTestLayer() +: mMenuItemStatusLabelBMFont(NULL) +{} + +MenuTestLayer::~MenuTestLayer() +{ + CC_SAFE_RELEASE(mMenuItemStatusLabelBMFont); +} SEL_MenuHandler MenuTestLayer::onResolveCCBCCMenuItemSelector(CCObject * pTarget, CCString * pSelectorName) { CCB_SELECTORRESOLVER_CCMENUITEM_GLUE(this, "onMenuItemAClicked", MenuTestLayer::onMenuItemAClicked); diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h index c4cd5e30eb..160fedd979 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h @@ -14,6 +14,9 @@ class MenuTestLayer public: CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(MenuTestLayer, node); + MenuTestLayer(); + virtual ~MenuTestLayer(); + virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); virtual bool onAssignCCBMemberVariable(cocos2d::CCObject * pTarget, cocos2d::CCString * pMemberVariableName, cocos2d::CCNode * pNode); From c4056b1bb07bb228f58048c81316dbae9bba94c9 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 19 Jun 2012 17:22:55 +0800 Subject: [PATCH 226/257] fixed #1269: Updated include search paths for win32 and android. --- HelloLua/proj.win32/HelloLua.win32.vcproj | 4 ++-- HelloLua/proj.win32/HelloLua.win32.vcxproj | 4 ++-- HelloWorld/proj.win32/HelloWorld.win32.vcproj | 4 ++-- HelloWorld/proj.win32/HelloWorld.win32.vcxproj | 4 ++-- cocos2dx/Android.mk | 2 -- cocos2dx/cocoa/CCString.cpp | 2 +- cocos2dx/kazmath/include/kazmath/vec4.h | 2 +- cocos2dx/platform/android/CCApplication.cpp | 5 ++--- cocos2dx/platform/android/CCCommon.cpp | 7 +++---- cocos2dx/platform/android/CCImage.cpp | 2 +- cocos2dx/platform/win32/CCAccelerometer.h | 2 +- cocos2dx/platform/win32/CCApplication.h | 4 ++-- cocos2dx/platform/win32/CCCommon.cpp | 8 +++----- cocos2dx/platform/win32/CCEGLView.cpp | 10 +++++----- cocos2dx/platform/win32/CCEGLView.h | 6 +++--- cocos2dx/platform/win32/CCFileUtils.cpp | 4 ++-- cocos2dx/platform/win32/CCImage.cpp | 2 +- cocos2dx/platform/win32/CCStdC.h | 2 +- cocos2dx/proj.win32/cocos2d-win32.vcproj | 4 ++-- cocos2dx/proj.win32/cocos2d-win32.vcxproj | 4 ++-- cocos2dx/support/CCUserDefault.cpp | 2 +- cocos2dx/support/image_support/TGAlib.cpp | 2 +- cocos2dx/support/zip_support/ZipUtils.cpp | 2 +- cocos2dx/support/zip_support/ioapi.h | 2 +- cocos2dx/textures/CCTextureCache.h | 2 +- testjs/proj.win32/testjs.win32.vcproj | 4 ++-- testjs/proj.win32/testjs.win32.vcxproj | 4 ++-- tests/proj.win32/test.win32.vcproj | 4 ++-- tests/proj.win32/test.win32.vcxproj | 4 ++-- 29 files changed, 51 insertions(+), 57 deletions(-) diff --git a/HelloLua/proj.win32/HelloLua.win32.vcproj b/HelloLua/proj.win32/HelloLua.win32.vcproj index e4efafcfb0..1e4f31e3ba 100644 --- a/HelloLua/proj.win32/HelloLua.win32.vcproj +++ b/HelloLua/proj.win32/HelloLua.win32.vcproj @@ -49,7 +49,7 @@ Disabled - .;..\Classes;..\..\cocos2dx;..\..\cocos2dx\actions;..\..\cocos2dx\base_nodes;..\..\cocos2dx\cocoa;..\..\cocos2dx\effects;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\keypad_dispatcher;..\..\cocos2dx\label_nodes;..\..\cocos2dx\layers_scenes_transitions_nodes;..\..\cocos2dx\menu_nodes;..\..\cocos2dx\misc_nodes;..\..\cocos2dx\particle_nodes;..\..\cocos2dx\script_support;..\..\cocos2dx\shaders;..\..\cocos2dx\sprite_nodes;..\..\cocos2dx\support;..\..\cocos2dx\text_input_node;..\..\cocos2dx\textures;..\..\cocos2dx\tileMap_parallax_nodes;..\..\cocos2dx\touch_dispatcher;..\..\cocos2dx\platform;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;..\..\lua\cocos2dx_support;..\..\lua\tolua;..\..\lua\lua;%(AdditionalIncludeDirectories) + .;..\Classes;..\..\cocos2dx;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;..\..\lua\cocos2dx_support;..\..\lua\tolua;..\..\lua\lua;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;_DEBUG;COCOS2D_DEBUG=1;ENABLE_LUA;%(PreprocessorDefinitions) true EnableFastChecks @@ -102,7 +102,7 @@ HelloLua_p.c - .;..\Classes;..\..\cocos2dx;..\..\cocos2dx\actions;..\..\cocos2dx\base_nodes;..\..\cocos2dx\cocoa;..\..\cocos2dx\effects;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\keypad_dispatcher;..\..\cocos2dx\label_nodes;..\..\cocos2dx\layers_scenes_transitions_nodes;..\..\cocos2dx\menu_nodes;..\..\cocos2dx\misc_nodes;..\..\cocos2dx\particle_nodes;..\..\cocos2dx\script_support;..\..\cocos2dx\shaders;..\..\cocos2dx\sprite_nodes;..\..\cocos2dx\support;..\..\cocos2dx\text_input_node;..\..\cocos2dx\textures;..\..\cocos2dx\tileMap_parallax_nodes;..\..\cocos2dx\touch_dispatcher;..\..\cocos2dx\platform;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;..\..\lua\cocos2dx_support;..\..\lua\tolua;..\..\lua\lua;%(AdditionalIncludeDirectories) + .;..\Classes;..\..\cocos2dx;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;..\..\lua\cocos2dx_support;..\..\lua\tolua;..\..\lua\lua;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;%(PreprocessorDefinitions) diff --git a/HelloWorld/proj.win32/HelloWorld.win32.vcproj b/HelloWorld/proj.win32/HelloWorld.win32.vcproj index 9dc1b267d0..eb3f3b68a9 100644 --- a/HelloWorld/proj.win32/HelloWorld.win32.vcproj +++ b/HelloWorld/proj.win32/HelloWorld.win32.vcproj @@ -41,7 +41,7 @@ Disabled - .;..\Classes;..\..\cocos2dx;..\..\cocos2dx\actions;..\..\cocos2dx\base_nodes;..\..\cocos2dx\cocoa;..\..\cocos2dx\effects;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\keypad_dispatcher;..\..\cocos2dx\label_nodes;..\..\cocos2dx\layers_scenes_transitions_nodes;..\..\cocos2dx\menu_nodes;..\..\cocos2dx\misc_nodes;..\..\cocos2dx\particle_nodes;..\..\cocos2dx\script_support;..\..\cocos2dx\shaders;..\..\cocos2dx\sprite_nodes;..\..\cocos2dx\support;..\..\cocos2dx\text_input_node;..\..\cocos2dx\textures;..\..\cocos2dx\tileMap_parallax_nodes;..\..\cocos2dx\touch_dispatcher;..\..\cocos2dx\platform;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories) + .;..\Classes;..\..\cocos2dx;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) true EnableFastChecks @@ -81,7 +81,7 @@ MaxSpeed true - .;..\Classes;..\..\cocos2dx;..\..\cocos2dx\actions;..\..\cocos2dx\base_nodes;..\..\cocos2dx\cocoa;..\..\cocos2dx\effects;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\keypad_dispatcher;..\..\cocos2dx\label_nodes;..\..\cocos2dx\layers_scenes_transitions_nodes;..\..\cocos2dx\menu_nodes;..\..\cocos2dx\misc_nodes;..\..\cocos2dx\particle_nodes;..\..\cocos2dx\script_support;..\..\cocos2dx\shaders;..\..\cocos2dx\sprite_nodes;..\..\cocos2dx\support;..\..\cocos2dx\text_input_node;..\..\cocos2dx\textures;..\..\cocos2dx\tileMap_parallax_nodes;..\..\cocos2dx\touch_dispatcher;..\..\cocos2dx\platform;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories) + .;..\Classes;..\..\cocos2dx;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) MultiThreadedDLL true diff --git a/cocos2dx/Android.mk b/cocos2dx/Android.mk index 2b39ffbcf8..df272165c6 100644 --- a/cocos2dx/Android.mk +++ b/cocos2dx/Android.mk @@ -163,7 +163,6 @@ touch_dispatcher/CCTouchHandler.cpp LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/include \ $(LOCAL_PATH)/kazmath/include \ - $(LOCAL_PATH)/platform \ $(LOCAL_PATH)/platform/android @@ -174,7 +173,6 @@ LOCAL_EXPORT_LDLIBS := -llog\ LOCAL_C_INCLUDES := $(LOCAL_PATH) \ $(LOCAL_PATH)/include \ $(LOCAL_PATH)/kazmath/include \ - $(LOCAL_PATH)/platform \ $(LOCAL_PATH)/platform/android diff --git a/cocos2dx/cocoa/CCString.cpp b/cocos2dx/cocoa/CCString.cpp index c7bbc558d6..96fb38e841 100644 --- a/cocos2dx/cocoa/CCString.cpp +++ b/cocos2dx/cocoa/CCString.cpp @@ -1,5 +1,5 @@ #include "CCString.h" -#include "CCFileUtils.h" +#include "platform/CCFileUtils.h" #include "ccMacros.h" #include #include diff --git a/cocos2dx/kazmath/include/kazmath/vec4.h b/cocos2dx/kazmath/include/kazmath/vec4.h index ffdb70423d..7956d2a794 100644 --- a/cocos2dx/kazmath/include/kazmath/vec4.h +++ b/cocos2dx/kazmath/include/kazmath/vec4.h @@ -26,7 +26,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef VEC4_H_INCLUDED #define VEC4_H_INCLUDED -#include "CCPlatformMacros.h" +#include "platform/CCPlatformMacros.h" #include "utility.h" struct kmMat4; diff --git a/cocos2dx/platform/android/CCApplication.cpp b/cocos2dx/platform/android/CCApplication.cpp index 684dfa0b3f..86fdace4b8 100644 --- a/cocos2dx/platform/android/CCApplication.cpp +++ b/cocos2dx/platform/android/CCApplication.cpp @@ -1,11 +1,10 @@ -#include "CCApplication.h" #include "jni/JniHelper.h" +#include "jni/SystemInfoJni.h" +#include "CCApplication.h" #include "CCDirector.h" #include "CCEGLView.h" -#include "android/jni/SystemInfoJni.h" #include #include - #include #define LOG_TAG "CCApplication_android Debug" diff --git a/cocos2dx/platform/android/CCCommon.cpp b/cocos2dx/platform/android/CCCommon.cpp index d12cd330a2..eef3ad11bd 100644 --- a/cocos2dx/platform/android/CCCommon.cpp +++ b/cocos2dx/platform/android/CCCommon.cpp @@ -23,16 +23,15 @@ THE SOFTWARE. ****************************************************************************/ #include "platform/CCCommon.h" - -#define MAX_LEN (cocos2d::kMaxLogLen + 1) - -#include "android/jni/MessageJni.h" +#include "jni/MessageJni.h" #include #include #include NS_CC_BEGIN +#define MAX_LEN (cocos2d::kMaxLogLen + 1) + void CCLog(const char * pszFormat, ...) { char buf[MAX_LEN]; diff --git a/cocos2dx/platform/android/CCImage.cpp b/cocos2dx/platform/android/CCImage.cpp index 333d6f0e87..7c585947f7 100644 --- a/cocos2dx/platform/android/CCImage.cpp +++ b/cocos2dx/platform/android/CCImage.cpp @@ -27,7 +27,7 @@ THE SOFTWARE. #define __CC_PLATFORM_IMAGE_CPP__ #include "platform/CCImageCommon_cpp.h" #include "platform/CCPlatformMacros.h" -#include "CCImage.h" +#include "platform/CCImage.h" #include "jni/JniHelper.h" #include diff --git a/cocos2dx/platform/win32/CCAccelerometer.h b/cocos2dx/platform/win32/CCAccelerometer.h index 1b7c314a32..4854eed5f6 100644 --- a/cocos2dx/platform/win32/CCAccelerometer.h +++ b/cocos2dx/platform/win32/CCAccelerometer.h @@ -25,7 +25,7 @@ THE SOFTWARE. #ifndef __PLATFORM_WIN32_UIACCELEROMETER_H__ #define __PLATFORM_WIN32_UIACCELEROMETER_H__ -#include "CCAccelerometerDelegate.h" +#include "platform/CCAccelerometerDelegate.h" NS_CC_BEGIN diff --git a/cocos2dx/platform/win32/CCApplication.h b/cocos2dx/platform/win32/CCApplication.h index 94e1790a97..5c41718405 100644 --- a/cocos2dx/platform/win32/CCApplication.h +++ b/cocos2dx/platform/win32/CCApplication.h @@ -2,8 +2,8 @@ #define __CC_APPLICATION_WIN32_H__ #include -#include "CCCommon.h" -#include "CCApplicationProtocol.h" +#include "platform/CCCommon.h" +#include "platform/CCApplicationProtocol.h" NS_CC_BEGIN diff --git a/cocos2dx/platform/win32/CCCommon.cpp b/cocos2dx/platform/win32/CCCommon.cpp index 3133f44abb..ba7526d26f 100644 --- a/cocos2dx/platform/win32/CCCommon.cpp +++ b/cocos2dx/platform/win32/CCCommon.cpp @@ -21,16 +21,14 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ - -#include "CCCommon.h" - -#define MAX_LEN (cocos2d::kMaxLogLen + 1) - #include +#include "platform/CCCommon.h" #include "CCStdC.h" NS_CC_BEGIN +#define MAX_LEN (cocos2d::kMaxLogLen + 1) + void CCLog(const char * pszFormat, ...) { char szBuf[MAX_LEN]; diff --git a/cocos2dx/platform/win32/CCEGLView.cpp b/cocos2dx/platform/win32/CCEGLView.cpp index 976b75289a..b387f5da31 100644 --- a/cocos2dx/platform/win32/CCEGLView.cpp +++ b/cocos2dx/platform/win32/CCEGLView.cpp @@ -23,13 +23,13 @@ THE SOFTWARE. ****************************************************************************/ #include "CCEGLView.h" -#include "CCSet.h" +#include "cocoa/CCSet.h" #include "ccMacros.h" #include "CCDirector.h" -#include "CCTouch.h" -#include "CCTouchDispatcher.h" -#include "CCIMEDispatcher.h" -#include "CCKeypadDispatcher.h" +#include "touch_dispatcher/CCTouch.h" +#include "touch_dispatcher/CCTouchDispatcher.h" +#include "text_input_node/CCIMEDispatcher.h" +#include "keypad_dispatcher/CCKeypadDispatcher.h" #include "CCApplication.h" NS_CC_BEGIN diff --git a/cocos2dx/platform/win32/CCEGLView.h b/cocos2dx/platform/win32/CCEGLView.h index 017db9b38c..1fdddce4e7 100644 --- a/cocos2dx/platform/win32/CCEGLView.h +++ b/cocos2dx/platform/win32/CCEGLView.h @@ -26,9 +26,9 @@ THE SOFTWARE. #define __CC_EGLVIEW_WIN32_H__ #include -#include "CCCommon.h" -#include "CCGeometry.h" -#include "CCEGLViewProtocol.h" +#include "platform/CCCommon.h" +#include "cocoa/CCGeometry.h" +#include "platform/CCEGLViewProtocol.h" NS_CC_BEGIN diff --git a/cocos2dx/platform/win32/CCFileUtils.cpp b/cocos2dx/platform/win32/CCFileUtils.cpp index 87ee6ef4ed..7a6d0040a8 100644 --- a/cocos2dx/platform/win32/CCFileUtils.cpp +++ b/cocos2dx/platform/win32/CCFileUtils.cpp @@ -22,8 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #define __CC_PLATFORM_FILEUTILS_CPP__ -#include "CCFileUtilsCommon_cpp.h" -#include "windows.h" +#include "platform/CCFileUtilsCommon_cpp.h" +#include #include "CCDirector.h" #define CC_RETINA_DISPLAY_FILENAME_SUFFIX "-hd" diff --git a/cocos2dx/platform/win32/CCImage.cpp b/cocos2dx/platform/win32/CCImage.cpp index 5ddd5fa0c8..d68e3ef098 100644 --- a/cocos2dx/platform/win32/CCImage.cpp +++ b/cocos2dx/platform/win32/CCImage.cpp @@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #define __CC_PLATFORM_IMAGE_CPP__ -#include "CCImageCommon_cpp.h" +#include "platform/CCImageCommon_cpp.h" NS_CC_BEGIN diff --git a/cocos2dx/platform/win32/CCStdC.h b/cocos2dx/platform/win32/CCStdC.h index 52b0cb6ce0..6c310f6643 100644 --- a/cocos2dx/platform/win32/CCStdC.h +++ b/cocos2dx/platform/win32/CCStdC.h @@ -25,7 +25,7 @@ THE SOFTWARE. #ifndef __CC_STD_C_H__ #define __CC_STD_C_H__ -#include "CCPlatformMacros.h" +#include "platform/CCPlatformMacros.h" #include // for math.h on win32 platform diff --git a/cocos2dx/proj.win32/cocos2d-win32.vcproj b/cocos2dx/proj.win32/cocos2d-win32.vcproj index c0d356da8e..dfdc58248b 100755 --- a/cocos2dx/proj.win32/cocos2d-win32.vcproj +++ b/cocos2dx/proj.win32/cocos2d-win32.vcproj @@ -42,7 +42,7 @@ Disabled - ..;..\platform;..\platform\win32;..\platform\third_party\win32\iconv;..\platform\third_party\win32\zlib;..\platform\third_party\win32\libpng;..\platform\third_party\win32\libtiff;..\platform\third_party\win32\libjpeg;..\platform\third_party\win32\libxml2;..\platform\third_party\win32\pthread;..\platform\third_party\win32\OGLES;..\include;..\kazmath\include;..\actions;..\base_nodes;..\cocoa;..\effects;..\extensions;..\keypad_dispatcher;..\label_nodes;..\layers_scenes_transitions_nodes;..\menu_nodes;..\misc_nodes;..\particle_nodes;..\script_support;..\shaders;..\sprite_nodes;..\text_input_node;..\textures;..\tileMap_parallax_nodes;..\touch_dispatcher;..\support;%(AdditionalIncludeDirectories) + ..;..\platform\win32;..\platform\third_party\win32\iconv;..\platform\third_party\win32\zlib;..\platform\third_party\win32\libpng;..\platform\third_party\win32\libtiff;..\platform\third_party\win32\libjpeg;..\platform\third_party\win32\libxml2;..\platform\third_party\win32\pthread;..\platform\third_party\win32\OGLES;..\include;..\kazmath\include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USRDLL;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) true EnableFastChecks @@ -97,7 +97,7 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ - ..;..\platform;..\platform\win32;..\platform\third_party\win32\iconv;..\platform\third_party\win32\zlib;..\platform\third_party\win32\libpng;..\platform\third_party\win32\libtiff;..\platform\third_party\win32\libjpeg;..\platform\third_party\win32\libxml2;..\platform\third_party\win32\pthread;..\platform\third_party\win32\OGLES;..\include;..\kazmath\include;..\actions;..\base_nodes;..\cocoa;..\effects;..\extensions;..\keypad_dispatcher;..\label_nodes;..\layers_scenes_transitions_nodes;..\menu_nodes;..\misc_nodes;..\particle_nodes;..\script_support;..\shaders;..\sprite_nodes;..\text_input_node;..\textures;..\tileMap_parallax_nodes;..\touch_dispatcher;..\support;%(AdditionalIncludeDirectories) + ..;..\platform\win32;..\platform\third_party\win32\iconv;..\platform\third_party\win32\zlib;..\platform\third_party\win32\libpng;..\platform\third_party\win32\libtiff;..\platform\third_party\win32\libjpeg;..\platform\third_party\win32\libxml2;..\platform\third_party\win32\pthread;..\platform\third_party\win32\OGLES;..\include;..\kazmath\include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USRDLL;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) MultiThreadedDLL diff --git a/cocos2dx/support/CCUserDefault.cpp b/cocos2dx/support/CCUserDefault.cpp index 030ef9c26b..6714b255ab 100644 --- a/cocos2dx/support/CCUserDefault.cpp +++ b/cocos2dx/support/CCUserDefault.cpp @@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ #include "CCUserDefault.h" -#include "CCCommon.h" +#include "platform/CCCommon.h" #include "platform/CCFileUtils.h" #include #include diff --git a/cocos2dx/support/image_support/TGAlib.cpp b/cocos2dx/support/image_support/TGAlib.cpp index 7f97cfafe0..13994d2d67 100644 --- a/cocos2dx/support/image_support/TGAlib.cpp +++ b/cocos2dx/support/image_support/TGAlib.cpp @@ -26,7 +26,7 @@ THE SOFTWARE. #include #include "TGAlib.h" -#include "CCFileUtils.h" +#include "platform/CCFileUtils.h" namespace cocos2d { diff --git a/cocos2dx/support/zip_support/ZipUtils.cpp b/cocos2dx/support/zip_support/ZipUtils.cpp index ece5c179e5..766d38a0a0 100644 --- a/cocos2dx/support/zip_support/ZipUtils.cpp +++ b/cocos2dx/support/zip_support/ZipUtils.cpp @@ -27,7 +27,7 @@ THE SOFTWARE. #include "ZipUtils.h" #include "ccMacros.h" -#include "CCFileUtils.h" +#include "platform/CCFileUtils.h" namespace cocos2d { diff --git a/cocos2dx/support/zip_support/ioapi.h b/cocos2dx/support/zip_support/ioapi.h index 29c6147b1e..4eeddaadf8 100644 --- a/cocos2dx/support/zip_support/ioapi.h +++ b/cocos2dx/support/zip_support/ioapi.h @@ -21,7 +21,7 @@ #ifndef _ZLIBIOAPI64_H #define _ZLIBIOAPI64_H -#include "CCPlatformConfig.h" +#include "platform/CCPlatformConfig.h" #if (!defined(_WIN32)) && (!defined(WIN32)) diff --git a/cocos2dx/textures/CCTextureCache.h b/cocos2dx/textures/CCTextureCache.h index 1b194acc6f..7cb799879e 100644 --- a/cocos2dx/textures/CCTextureCache.h +++ b/cocos2dx/textures/CCTextureCache.h @@ -34,7 +34,7 @@ THE SOFTWARE. #if CC_ENABLE_CACHE_TEXTURE_DATA - #include "CCImage.h" + #include "platform/CCImage.h" #include #endif diff --git a/testjs/proj.win32/testjs.win32.vcproj b/testjs/proj.win32/testjs.win32.vcproj index 712f215622..3bd1d5c5cc 100644 --- a/testjs/proj.win32/testjs.win32.vcproj +++ b/testjs/proj.win32/testjs.win32.vcproj @@ -48,7 +48,7 @@ Disabled - .;..\Classes;..\..\js\spidermonkey-win32\include;..\..\js\JSBindings;..\..\js\BindingsExample;..\..\cocos2dx;..\..\cocos2dx\actions;..\..\cocos2dx\base_nodes;..\..\cocos2dx\cocoa;..\..\cocos2dx\effects;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\keypad_dispatcher;..\..\cocos2dx\label_nodes;..\..\cocos2dx\layers_scenes_transitions_nodes;..\..\cocos2dx\menu_nodes;..\..\cocos2dx\misc_nodes;..\..\cocos2dx\particle_nodes;..\..\cocos2dx\script_support;..\..\cocos2dx\shaders;..\..\cocos2dx\sprite_nodes;..\..\cocos2dx\support;..\..\cocos2dx\text_input_node;..\..\cocos2dx\textures;..\..\cocos2dx\tileMap_parallax_nodes;..\..\cocos2dx\touch_dispatcher;..\..\cocos2dx\platform;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories) + .;..\Classes;..\..\js\spidermonkey-win32\include;..\..\js\JSBindings;..\..\js\BindingsExample;..\..\cocos2dx;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) true EnableFastChecks @@ -106,7 +106,7 @@ xcopy /Y /Q "$(SolutionDir)js\spidermonkey-win32\lib\*.*" "$(OutDir)" testjs_p.c - .;..\Classes;..\..\js\spidermonkey-win32\include;..\..\js\JSBindings;..\..\js\BindingsExample;..\..\cocos2dx;..\..\cocos2dx\actions;..\..\cocos2dx\base_nodes;..\..\cocos2dx\cocoa;..\..\cocos2dx\effects;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\keypad_dispatcher;..\..\cocos2dx\label_nodes;..\..\cocos2dx\layers_scenes_transitions_nodes;..\..\cocos2dx\menu_nodes;..\..\cocos2dx\misc_nodes;..\..\cocos2dx\particle_nodes;..\..\cocos2dx\script_support;..\..\cocos2dx\shaders;..\..\cocos2dx\sprite_nodes;..\..\cocos2dx\support;..\..\cocos2dx\text_input_node;..\..\cocos2dx\textures;..\..\cocos2dx\tileMap_parallax_nodes;..\..\cocos2dx\touch_dispatcher;..\..\cocos2dx\platform;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories) + .;..\Classes;..\..\js\spidermonkey-win32\include;..\..\js\JSBindings;..\..\js\BindingsExample;..\..\cocos2dx;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories) WIN32;_WINDOWS;STRICT;NDEBUG;%(PreprocessorDefinitions) diff --git a/tests/proj.win32/test.win32.vcproj b/tests/proj.win32/test.win32.vcproj index bfc51c715b..e484186f32 100644 --- a/tests/proj.win32/test.win32.vcproj +++ b/tests/proj.win32/test.win32.vcproj @@ -41,7 +41,7 @@ Disabled - .;..;..\tests;..\..;..\..\chipmunk\include\chipmunk;..\..\cocos2dx;..\..\cocos2dx\actions;..\..\cocos2dx\base_nodes;..\..\cocos2dx\cocoa;..\..\cocos2dx\effects;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\keypad_dispatcher;..\..\cocos2dx\label_nodes;..\..\cocos2dx\layers_scenes_transitions_nodes;..\..\cocos2dx\menu_nodes;..\..\cocos2dx\misc_nodes;..\..\cocos2dx\particle_nodes;..\..\cocos2dx\script_support;..\..\cocos2dx\shaders;..\..\cocos2dx\sprite_nodes;..\..\cocos2dx\support;..\..\cocos2dx\text_input_node;..\..\cocos2dx\textures;..\..\cocos2dx\tileMap_parallax_nodes;..\..\cocos2dx\touch_dispatcher;..\..\cocos2dx\platform;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories) + .;..;..\tests;..\..;..\..\chipmunk\include\chipmunk;..\..\cocos2dx;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories) WIN32;_DEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) true EnableFastChecks @@ -83,7 +83,7 @@ MaxSpeed true - .;..;..\tests;..\..;..\..\chipmunk\include\chipmunk;..\..\cocos2dx;..\..\cocos2dx\actions;..\..\cocos2dx\base_nodes;..\..\cocos2dx\cocoa;..\..\cocos2dx\effects;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\keypad_dispatcher;..\..\cocos2dx\label_nodes;..\..\cocos2dx\layers_scenes_transitions_nodes;..\..\cocos2dx\menu_nodes;..\..\cocos2dx\misc_nodes;..\..\cocos2dx\particle_nodes;..\..\cocos2dx\script_support;..\..\cocos2dx\shaders;..\..\cocos2dx\sprite_nodes;..\..\cocos2dx\support;..\..\cocos2dx\text_input_node;..\..\cocos2dx\textures;..\..\cocos2dx\tileMap_parallax_nodes;..\..\cocos2dx\touch_dispatcher;..\..\cocos2dx\platform;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories) + .;..;..\tests;..\..;..\..\chipmunk\include\chipmunk;..\..\cocos2dx;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories) WIN32;NDEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) MultiThreadedDLL true From b818c0afa63ae783c2d27af10d423c8bf53bc165 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 20 Jun 2012 11:48:31 +0800 Subject: [PATCH 227/257] fixed #1336: Used CC_DEPRECATED_ATTRIBUTE macro to mark deprecated interfaces. --- HelloLua/proj.win32/HelloLua.win32.vcproj | 8 +-- HelloLua/proj.win32/HelloLua.win32.vcxproj | 8 +-- HelloWorld/proj.win32/HelloWorld.win32.vcproj | 6 +- .../proj.win32/HelloWorld.win32.vcxproj | 6 +- cocos2dx/CCDirector.cpp | 2 +- cocos2dx/actions/CCAction.h | 6 +- cocos2dx/actions/CCActionCamera.h | 2 +- cocos2dx/actions/CCActionCatmullRom.cpp | 10 +-- cocos2dx/actions/CCActionCatmullRom.h | 10 +-- cocos2dx/actions/CCActionEase.h | 44 ++++++------- cocos2dx/actions/CCActionGrid.h | 16 ++--- cocos2dx/actions/CCActionGrid3D.h | 18 ++--- cocos2dx/actions/CCActionInstant.h | 20 +++--- cocos2dx/actions/CCActionInterval.cpp | 28 ++++---- cocos2dx/actions/CCActionInterval.h | 66 +++++++++---------- cocos2dx/actions/CCActionPageTurn3D.h | 2 +- cocos2dx/actions/CCActionProgressTimer.h | 4 +- cocos2dx/actions/CCActionTiledGrid.h | 26 ++++---- cocos2dx/actions/CCActionTween.h | 2 +- cocos2dx/base_nodes/CCAtlasNode.h | 2 +- cocos2dx/base_nodes/CCNode.h | 2 +- cocos2dx/cocoa/CCArray.h | 14 ++-- cocos2dx/cocoa/CCDictionary.h | 9 +-- cocos2dx/cocoa/CCInteger.h | 2 +- cocos2dx/cocoa/CCString.cpp | 40 ++++------- cocos2dx/cocoa/CCString.h | 22 +++---- cocos2dx/effects/CCGrid.h | 4 +- cocos2dx/extensions/CCBReader/CCBReader.cpp | 22 +++---- .../extensions/CCBReader/CCNodeLoader.cpp | 6 +- cocos2dx/extensions/CCBReader/CCNodeLoader.h | 2 +- .../CCBReader/CCNodeLoaderLibrary.cpp | 4 +- .../CCControlExtension/CCControlButton.cpp | 15 +++-- .../CCControlExtension/CCControlButton.h | 9 +-- .../CCControlColourPicker.h | 2 +- .../CCControlExtension/CCControlHuePicker.h | 2 +- .../CCControlSaturationBrightnessPicker.h | 2 +- .../CCControlExtension/CCControlSlider.h | 4 +- .../CCControlExtension/CCControlSwitch.h | 4 +- .../CCControlExtension/CCMenuPassive.h | 6 +- .../CCControlExtension/CCScale9Sprite.cpp | 2 +- .../CCControlExtension/CCScale9Sprite.h | 18 ++--- cocos2dx/extensions/CCListView/CCListView.h | 2 +- .../extensions/CCScrollView/CCScrollView.cpp | 10 +-- .../extensions/CCScrollView/CCScrollView.h | 4 +- cocos2dx/label_nodes/CCLabelAtlas.h | 4 +- cocos2dx/label_nodes/CCLabelBMFont.h | 6 +- cocos2dx/label_nodes/CCLabelTTF.h | 6 +- .../layers_scenes_transitions_nodes/CCLayer.h | 18 ++--- .../layers_scenes_transitions_nodes/CCScene.h | 4 +- .../CCTransition.h | 35 +++------- .../CCTransitionPageTurn.h | 2 +- cocos2dx/menu_nodes/CCMenu.h | 8 +-- cocos2dx/menu_nodes/CCMenuItem.h | 34 +++++----- cocos2dx/misc_nodes/CCMotionStreak.h | 4 +- cocos2dx/misc_nodes/CCProgressTimer.h | 2 +- cocos2dx/misc_nodes/CCRenderTexture.h | 6 +- cocos2dx/particle_nodes/CCParticleBatchNode.h | 4 +- cocos2dx/particle_nodes/CCParticleSystem.h | 2 +- .../particle_nodes/CCParticleSystemQuad.h | 4 +- cocos2dx/platform/CCPlatformMacros.h | 10 +++ cocos2dx/proj.win32/cocos2d-win32.vcproj | 8 +-- cocos2dx/proj.win32/cocos2d-win32.vcxproj | 8 +-- cocos2dx/sprite_nodes/CCAnimation.h | 6 +- cocos2dx/sprite_nodes/CCSprite.h | 14 ++-- cocos2dx/sprite_nodes/CCSpriteBatchNode.h | 4 +- cocos2dx/sprite_nodes/CCSpriteFrame.h | 8 +-- cocos2dx/support/zip_support/ioapi.cpp | 5 -- cocos2dx/textures/CCTexturePVR.cpp | 2 +- .../tileMap_parallax_nodes/CCParallaxNode.h | 2 +- cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h | 2 +- .../tileMap_parallax_nodes/CCTMXTiledMap.h | 4 +- .../tileMap_parallax_nodes/CCTileMapAtlas.h | 2 +- tests/proj.win32/test.win32.vcproj | 8 +-- tests/proj.win32/test.win32.vcxproj | 8 +-- tests/tests/EffectsTest/EffectsTest.h | 2 - .../ButtonTest/ButtonTestLayer.h | 2 +- .../HelloCocosBuilderLayer.cpp | 6 +- .../HelloCocosBuilderLayer.h | 2 +- .../LabelTest/LabelTestLayer.h | 2 +- .../CocosBuilderTest/MenuTest/MenuTestLayer.h | 2 +- .../ParticleSystemTestLayer.h | 2 +- .../ScrollViewTest/ScrollViewTestLayer.h | 2 +- .../SpriteTest/SpriteTestLayer.h | 2 +- .../TestHeader/TestHeaderLayer.h | 2 +- 84 files changed, 363 insertions(+), 384 deletions(-) diff --git a/HelloLua/proj.win32/HelloLua.win32.vcproj b/HelloLua/proj.win32/HelloLua.win32.vcproj index 1e4f31e3ba..5057a8e546 100644 --- a/HelloLua/proj.win32/HelloLua.win32.vcproj +++ b/HelloLua/proj.win32/HelloLua.win32.vcproj @@ -50,14 +50,14 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..\Classes;"$(SolutionDir)\lua\cocos2dx_support";"$(SolutionDir)\lua\CocosDenshion_support";"$(SolutionDir)\lua\lua";"$(SolutionDir)\lua\tolua";"$(SolutionDir)\lua\src";.;"$(SolutionDir)cocos2dx";"$(SolutionDir)cocos2dx\include";"$(SolutionDir)cocos2dx\kazmath\include";"$(SolutionDir)cocos2dx\platform\win32";"$(SolutionDir)cocos2dx\platform\third_party\win32\OGLES";"$(SolutionDir)CocosDenshion\include"" - PreprocessorDefinitions="WIN32;_WINDOWS;STRICT;_DEBUG;COCOS2D_DEBUG=1" + PreprocessorDefinitions="WIN32;_WINDOWS;STRICT;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" UsePrecompiledHeader="0" WarningLevel="3" DebugInformationFormat="4" - DisableSpecificWarnings="4251" + DisableSpecificWarnings="4267;4251;4244" /> Disabled .;..\Classes;..\..\cocos2dx;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;..\..\lua\cocos2dx_support;..\..\lua\tolua;..\..\lua\lua;%(AdditionalIncludeDirectories) - WIN32;_WINDOWS;STRICT;_DEBUG;COCOS2D_DEBUG=1;ENABLE_LUA;%(PreprocessorDefinitions) + WIN32;_WINDOWS;STRICT;_DEBUG;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -73,7 +73,7 @@ Level3 EditAndContinue - 4251;%(DisableSpecificWarnings) + 4267;4251;4244;%(DisableSpecificWarnings) _DEBUG;%(PreprocessorDefinitions) @@ -103,7 +103,7 @@ .;..\Classes;..\..\cocos2dx;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;..\..\lua\cocos2dx_support;..\..\lua\tolua;..\..\lua\lua;%(AdditionalIncludeDirectories) - WIN32;_WINDOWS;STRICT;NDEBUG;%(PreprocessorDefinitions) + WIN32;_WINDOWS;STRICT;NDEBUG;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL @@ -112,7 +112,7 @@ Level3 - 4251;%(DisableSpecificWarnings) + 4267;4251;4244;%(DisableSpecificWarnings) NDEBUG;%(PreprocessorDefinitions) diff --git a/HelloWorld/proj.win32/HelloWorld.win32.vcproj b/HelloWorld/proj.win32/HelloWorld.win32.vcproj index eb3f3b68a9..3c5bbb16fb 100644 --- a/HelloWorld/proj.win32/HelloWorld.win32.vcproj +++ b/HelloWorld/proj.win32/HelloWorld.win32.vcproj @@ -42,13 +42,14 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=""$(SolutionDir)cocos2dx";"$(SolutionDir)cocos2dx\include";"$(SolutionDir)cocos2dx\kazmath\include";"$(SolutionDir)cocos2dx\platform\win32";"$(SolutionDir)cocos2dx\platform\third_party\win32\OGLES";..\Classes" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" UsePrecompiledHeader="0" WarningLevel="3" DebugInformationFormat="4" + DisableSpecificWarnings="4267;4251;4244" /> Disabled .;..\Classes;..\..\cocos2dx;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -63,6 +63,7 @@ Level3 EditAndContinue + 4267;4251;4244 libcocos2d.lib;%(AdditionalDependencies) @@ -82,13 +83,14 @@ MaxSpeed true .;..\Classes;..\..\cocos2dx;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL true Level3 ProgramDatabase + 4267;4251;4244 libcocos2d.lib;%(AdditionalDependencies) diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 6932e32495..603dfc0a4f 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -596,7 +596,7 @@ void CCDirector::purgeDirector() // purge bitmap cache CCLabelBMFont::purgeCachedData(); - // purge all managers ï¼ caches + // purge all managed caches CCAnimationCache::purgeSharedAnimationCache(); CCSpriteFrameCache::purgeSharedSpriteFrameCache(); CCTextureCache::purgeSharedTextureCache(); diff --git a/cocos2dx/actions/CCAction.h b/cocos2dx/actions/CCAction.h index d51d0a075f..02723c1735 100644 --- a/cocos2dx/actions/CCAction.h +++ b/cocos2dx/actions/CCAction.h @@ -95,7 +95,7 @@ public: /** Allocates and initializes the action @warning: This interface will be deprecated in future. */ - static CCAction* action(); + CC_DEPRECATED_ATTRIBUTE static CCAction* action(); /** Create an action */ static CCAction* create(); @@ -182,7 +182,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCSpeed* actionWithAction(CCActionInterval *pAction, float fSpeed); + CC_DEPRECATED_ATTRIBUTE static CCSpeed* actionWithAction(CCActionInterval *pAction, float fSpeed); /** create the action */ static CCSpeed* create(CCActionInterval* pAction, float fSpeed); @@ -231,7 +231,7 @@ public: It will work with no boundary if @param rect is equal to CCRectZero. @warning: This interface will be deprecated in future. */ - static CCFollow* actionWithTarget(CCNode *pFollowedNode, const CCRect& rect = CCRectZero); + CC_DEPRECATED_ATTRIBUTE static CCFollow* actionWithTarget(CCNode *pFollowedNode, const CCRect& rect = CCRectZero); /** creates the action with a set boundary, It will work with no boundary if @param rect is equal to CCRectZero. */ diff --git a/cocos2dx/actions/CCActionCamera.h b/cocos2dx/actions/CCActionCamera.h index 49a5d18c20..9c2e9cb5a0 100644 --- a/cocos2dx/actions/CCActionCamera.h +++ b/cocos2dx/actions/CCActionCamera.h @@ -90,7 +90,7 @@ public: /** creates a CCOrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX @warning: This interface will be deprecated in future. */ - static CCOrbitCamera* actionWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX); + CC_DEPRECATED_ATTRIBUTE static CCOrbitCamera* actionWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX); /** creates a CCOrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX */ static CCOrbitCamera* create(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX); diff --git a/cocos2dx/actions/CCActionCatmullRom.cpp b/cocos2dx/actions/CCActionCatmullRom.cpp index 47f5c40a66..632cd160a6 100644 --- a/cocos2dx/actions/CCActionCatmullRom.cpp +++ b/cocos2dx/actions/CCActionCatmullRom.cpp @@ -182,14 +182,14 @@ CCPoint ccCardinalSplineAt(CCPoint &p0, CCPoint &p1, CCPoint &p2, CCPoint &p3, f float t3 = t2 * t; /* - * Formula: s(-ttt + 2tt – t)P1 + s(-ttt + tt)P2 + (2ttt – 3tt + 1)P2 + s(ttt – 2tt + t)P3 + (-2ttt + 3tt)P3 + s(ttt – tt)P4 + * Formula: s(-ttt + 2tt - t)P1 + s(-ttt + tt)P2 + (2ttt - 3tt + 1)P2 + s(ttt - 2tt + t)P3 + (-2ttt + 3tt)P3 + s(ttt - tt)P4 */ float s = (1 - tension) / 2; - float b1 = s * ((-t3 + (2 * t2)) - t); // s(-t3 + 2 t2 – t)P1 - float b2 = s * (-t3 + t2) + (2 * t3 - 3 * t2 + 1); // s(-t3 + t2)P2 + (2 t3 – 3 t2 + 1)P2 - float b3 = s * (t3 - 2 * t2 + t) + (-2 * t3 + 3 * t2); // s(t3 – 2 t2 + t)P3 + (-2 t3 + 3 t2)P3 - float b4 = s * (t3 - t2); // s(t3 – t2)P4 + float b1 = s * ((-t3 + (2 * t2)) - t); // s(-t3 + 2 t2 - t)P1 + float b2 = s * (-t3 + t2) + (2 * t3 - 3 * t2 + 1); // s(-t3 + t2)P2 + (2 t3 - 3 t2 + 1)P2 + float b3 = s * (t3 - 2 * t2 + t) + (-2 * t3 + 3 * t2); // s(t3 - 2 t2 + t)P3 + (-2 t3 + 3 t2)P3 + float b4 = s * (t3 - t2); // s(t3 - t2)P4 float x = (p0.x*b1 + p1.x*b2 + p2.x*b3 + p3.x*b4); float y = (p0.y*b1 + p1.y*b2 + p2.y*b3 + p3.y*b4); diff --git a/cocos2dx/actions/CCActionCatmullRom.h b/cocos2dx/actions/CCActionCatmullRom.h index 4f6fd87c3e..ae62c6ff7f 100644 --- a/cocos2dx/actions/CCActionCatmullRom.h +++ b/cocos2dx/actions/CCActionCatmullRom.h @@ -52,7 +52,7 @@ public: /** creates and initializes a Points array with capacity @warning: This interface will be deprecated in future. */ - static CCPointArray* arrayWithCapacity(unsigned int capacity); + CC_DEPRECATED_ATTRIBUTE static CCPointArray* arrayWithCapacity(unsigned int capacity); /** creates and initializes a Points array with capacity */ static CCPointArray* create(unsigned int capacity); @@ -110,7 +110,7 @@ public: /** creates an action with a Cardinal Spline array of points and tension @warning: This interface will be deprecated in future. */ - static CCCardinalSplineTo* actionWithDuration(float duration, CCPointArray* points, float tension); + CC_DEPRECATED_ATTRIBUTE static CCCardinalSplineTo* actionWithDuration(float duration, CCPointArray* points, float tension); /** creates an action with a Cardinal Spline array of points and tension */ static CCCardinalSplineTo* create(float duration, CCPointArray* points, float tension); @@ -153,7 +153,7 @@ public: /** creates an action with a Cardinal Spline array of points and tension @warning: This interface will be deprecated in future. */ - static CCCardinalSplineBy* actionWithDuration(float duration, CCPointArray* points, float tension); + CC_DEPRECATED_ATTRIBUTE static CCCardinalSplineBy* actionWithDuration(float duration, CCPointArray* points, float tension); /** creates an action with a Cardinal Spline array of points and tension */ static CCCardinalSplineBy* create(float duration, CCPointArray* points, float tension); @@ -177,7 +177,7 @@ public: /** creates an action with a Cardinal Spline array of points and tension @warning: This interface will be deprecated in future. */ - static CCCatmullRomTo* actionWithDuration(float dt, CCPointArray* points); + CC_DEPRECATED_ATTRIBUTE static CCCatmullRomTo* actionWithDuration(float dt, CCPointArray* points); /** creates an action with a Cardinal Spline array of points and tension */ static CCCatmullRomTo* create(float dt, CCPointArray* points); @@ -196,7 +196,7 @@ public: /** creates an action with a Cardinal Spline array of points and tension @warning: This interface will be deprecated in future. */ - static CCCatmullRomBy* actionWithDuration(float dt, CCPointArray* points); + CC_DEPRECATED_ATTRIBUTE static CCCatmullRomBy* actionWithDuration(float dt, CCPointArray* points); /** creates an action with a Cardinal Spline array of points and tension */ static CCCatmullRomBy* create(float dt, CCPointArray* points); diff --git a/cocos2dx/actions/CCActionEase.h b/cocos2dx/actions/CCActionEase.h index 45402a79c2..9946643f86 100644 --- a/cocos2dx/actions/CCActionEase.h +++ b/cocos2dx/actions/CCActionEase.h @@ -54,7 +54,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCActionEase* actionWithAction(CCActionInterval *pAction); + CC_DEPRECATED_ATTRIBUTE static CCActionEase* actionWithAction(CCActionInterval *pAction); /** creates the action */ static CCActionEase* create(CCActionInterval *pAction); @@ -86,7 +86,7 @@ public: /** Creates the action with the inner action and the rate parameter @warning: This interface will be deprecated in future. */ - static CCEaseRateAction* actionWithAction(CCActionInterval* pAction, float fRate); + CC_DEPRECATED_ATTRIBUTE static CCEaseRateAction* actionWithAction(CCActionInterval* pAction, float fRate); /** Creates the action with the inner action and the rate parameter */ static CCEaseRateAction* create(CCActionInterval* pAction, float fRate); @@ -108,7 +108,7 @@ public: /** Creates the action with the inner action and the rate parameter @warning: This interface will be deprecated in future. */ - static CCEaseIn* actionWithAction(CCActionInterval* pAction, float fRate); + CC_DEPRECATED_ATTRIBUTE static CCEaseIn* actionWithAction(CCActionInterval* pAction, float fRate); /** Creates the action with the inner action and the rate parameter */ static CCEaseIn* create(CCActionInterval* pAction, float fRate); @@ -128,7 +128,7 @@ public: /** Creates the action with the inner action and the rate parameter @warning: This interface will be deprecated in future. */ - static CCEaseOut* actionWithAction(CCActionInterval* pAction, float fRate); + CC_DEPRECATED_ATTRIBUTE static CCEaseOut* actionWithAction(CCActionInterval* pAction, float fRate); /** Creates the action with the inner action and the rate parameter */ static CCEaseOut* create(CCActionInterval* pAction, float fRate); @@ -148,7 +148,7 @@ public: /** Creates the action with the inner action and the rate parameter @warning: This interface will be deprecated in future. */ - static CCEaseInOut* actionWithAction(CCActionInterval* pAction, float fRate); + CC_DEPRECATED_ATTRIBUTE static CCEaseInOut* actionWithAction(CCActionInterval* pAction, float fRate); /** Creates the action with the inner action and the rate parameter */ static CCEaseInOut* create(CCActionInterval* pAction, float fRate); @@ -168,7 +168,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCEaseExponentialIn* actionWithAction(CCActionInterval* pAction); + CC_DEPRECATED_ATTRIBUTE static CCEaseExponentialIn* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseExponentialIn* create(CCActionInterval* pAction); }; @@ -187,7 +187,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCEaseExponentialOut* actionWithAction(CCActionInterval* pAction); + CC_DEPRECATED_ATTRIBUTE static CCEaseExponentialOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseExponentialOut* create(CCActionInterval* pAction); }; @@ -206,7 +206,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCEaseExponentialInOut* actionWithAction(CCActionInterval* pAction); + CC_DEPRECATED_ATTRIBUTE static CCEaseExponentialInOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseExponentialInOut* create(CCActionInterval* pAction); @@ -226,7 +226,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCEaseSineIn* actionWithAction(CCActionInterval* pAction); + CC_DEPRECATED_ATTRIBUTE static CCEaseSineIn* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseSineIn* create(CCActionInterval* pAction); }; @@ -245,7 +245,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCEaseSineOut* actionWithAction(CCActionInterval* pAction); + CC_DEPRECATED_ATTRIBUTE static CCEaseSineOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseSineOut* create(CCActionInterval* pAction); }; @@ -264,7 +264,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCEaseSineInOut* actionWithAction(CCActionInterval* pAction); + CC_DEPRECATED_ATTRIBUTE static CCEaseSineInOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseSineInOut* create(CCActionInterval* pAction); }; @@ -291,7 +291,7 @@ public: /** Creates the action with the inner action and the period in radians (default is 0.3) @warning: This interface will be deprecated in future. */ - static CCEaseElastic* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); + CC_DEPRECATED_ATTRIBUTE static CCEaseElastic* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); /** Creates the action with the inner action and the period in radians (default is 0.3) */ static CCEaseElastic* create(CCActionInterval *pAction, float fPeriod = 0.3f); protected: @@ -314,7 +314,7 @@ public: /** Creates the action with the inner action and the period in radians (default is 0.3) @warning: This interface will be deprecated in future. */ - static CCEaseElasticIn* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); + CC_DEPRECATED_ATTRIBUTE static CCEaseElasticIn* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); /** Creates the action with the inner action and the period in radians (default is 0.3) */ static CCEaseElasticIn* create(CCActionInterval *pAction, float fPeriod = 0.3f); }; @@ -335,7 +335,7 @@ public: /** Creates the action with the inner action and the period in radians (default is 0.3) @warning: This interface will be deprecated in future. */ - static CCEaseElasticOut* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); + CC_DEPRECATED_ATTRIBUTE static CCEaseElasticOut* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); /** Creates the action with the inner action and the period in radians (default is 0.3) */ static CCEaseElasticOut* create(CCActionInterval *pAction, float fPeriod = 0.3f); @@ -357,7 +357,7 @@ public: /** Creates the action with the inner action and the period in radians (default is 0.3) @warning: This interface will be deprecated in future. */ - static CCEaseElasticInOut* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); + CC_DEPRECATED_ATTRIBUTE static CCEaseElasticInOut* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); /** Creates the action with the inner action and the period in radians (default is 0.3) */ static CCEaseElasticInOut* create(CCActionInterval *pAction, float fPeriod = 0.3f); @@ -378,7 +378,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCEaseBounce* actionWithAction(CCActionInterval* pAction); + CC_DEPRECATED_ATTRIBUTE static CCEaseBounce* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseBounce* create(CCActionInterval* pAction); }; @@ -399,7 +399,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCEaseBounceIn* actionWithAction(CCActionInterval* pAction); + CC_DEPRECATED_ATTRIBUTE static CCEaseBounceIn* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseBounceIn* create(CCActionInterval* pAction); }; @@ -420,7 +420,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCEaseBounceOut* actionWithAction(CCActionInterval* pAction); + CC_DEPRECATED_ATTRIBUTE static CCEaseBounceOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseBounceOut* create(CCActionInterval* pAction); }; @@ -441,7 +441,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCEaseBounceInOut* actionWithAction(CCActionInterval* pAction); + CC_DEPRECATED_ATTRIBUTE static CCEaseBounceInOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseBounceInOut* create(CCActionInterval* pAction); }; @@ -462,7 +462,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCEaseBackIn* actionWithAction(CCActionInterval* pAction); + CC_DEPRECATED_ATTRIBUTE static CCEaseBackIn* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseBackIn* create(CCActionInterval* pAction); }; @@ -483,7 +483,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCEaseBackOut* actionWithAction(CCActionInterval* pAction); + CC_DEPRECATED_ATTRIBUTE static CCEaseBackOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseBackOut* create(CCActionInterval* pAction); }; @@ -504,7 +504,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCEaseBackInOut* actionWithAction(CCActionInterval* pAction); + CC_DEPRECATED_ATTRIBUTE static CCEaseBackInOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ static CCEaseBackInOut* create(CCActionInterval* pAction); }; diff --git a/cocos2dx/actions/CCActionGrid.h b/cocos2dx/actions/CCActionGrid.h index 74cca70d40..675d18adce 100644 --- a/cocos2dx/actions/CCActionGrid.h +++ b/cocos2dx/actions/CCActionGrid.h @@ -49,7 +49,7 @@ public: /** creates the action with size and duration @warning: This interface will be deprecated in future. */ - static CCGridAction* actionWithSize(const ccGridSize& gridSize, float duration); + CC_DEPRECATED_ATTRIBUTE static CCGridAction* actionWithSize(const ccGridSize& gridSize, float duration); /** creates the action with size and duration */ static CCGridAction* create(const ccGridSize& gridSize, float duration); protected: @@ -76,7 +76,7 @@ public: /** creates the action with size and duration @warning: This interface will be deprecated in future. */ - static CCGrid3DAction* actionWithSize(const ccGridSize& gridSize, float duration); + CC_DEPRECATED_ATTRIBUTE static CCGrid3DAction* actionWithSize(const ccGridSize& gridSize, float duration); /** creates the action with size and duration */ static CCGrid3DAction* create(const ccGridSize& gridSize, float duration); }; @@ -99,7 +99,7 @@ public: /** creates the action with size and duration @warning: This interface will be deprecated in future. */ - static CCTiledGrid3DAction* actionWithSize(const ccGridSize& gridSize, float duration); + CC_DEPRECATED_ATTRIBUTE static CCTiledGrid3DAction* actionWithSize(const ccGridSize& gridSize, float duration); /** creates the action with size and duration */ static CCTiledGrid3DAction* create(const ccGridSize& gridSize, float duration); }; @@ -125,7 +125,7 @@ public: /** creates the action with an inner action that has the amplitude property, and a duration time @warning: This interface will be deprecated in future. */ - static CCAccelDeccelAmplitude* actionWithAction(CCAction *pAction, float duration); + CC_DEPRECATED_ATTRIBUTE static CCAccelDeccelAmplitude* actionWithAction(CCAction *pAction, float duration); /** creates the action with an inner action that has the amplitude property, and a duration time */ static CCAccelDeccelAmplitude* create(CCAction *pAction, float duration); @@ -155,7 +155,7 @@ public: /** creates the action with an inner action that has the amplitude property, and a duration time @warning: This interface will be deprecated in future. */ - static CCAccelAmplitude* actionWithAction(CCAction *pAction, float duration); + CC_DEPRECATED_ATTRIBUTE static CCAccelAmplitude* actionWithAction(CCAction *pAction, float duration); /** creates the action with an inner action that has the amplitude property, and a duration time */ static CCAccelAmplitude* create(CCAction *pAction, float duration); protected: @@ -184,7 +184,7 @@ public: /** creates the action with an inner action that has the amplitude property, and a duration time @warning: This interface will be deprecated in future. */ - static CCDeccelAmplitude* actionWithAction(CCAction *pAction, float duration); + CC_DEPRECATED_ATTRIBUTE static CCDeccelAmplitude* actionWithAction(CCAction *pAction, float duration); /** creates the action with an inner action that has the amplitude property, and a duration time */ static CCDeccelAmplitude* create(CCAction *pAction, float duration); @@ -207,7 +207,7 @@ public: /** Allocates and initializes the action @warning: This interface will be deprecated in future. */ - static CCStopGrid* action(void); + CC_DEPRECATED_ATTRIBUTE static CCStopGrid* action(void); /** Allocates and initializes the action */ static CCStopGrid* create(void); }; @@ -225,7 +225,7 @@ public: /** creates an action with the number of times that the current grid will be reused @warning: This interface will be deprecated in future. */ - static CCReuseGrid* actionWithTimes(int times); + CC_DEPRECATED_ATTRIBUTE static CCReuseGrid* actionWithTimes(int times); /** creates an action with the number of times that the current grid will be reused */ static CCReuseGrid* create(int times); protected: diff --git a/cocos2dx/actions/CCActionGrid3D.h b/cocos2dx/actions/CCActionGrid3D.h index b509b4e22f..c8d36bc4ca 100644 --- a/cocos2dx/actions/CCActionGrid3D.h +++ b/cocos2dx/actions/CCActionGrid3D.h @@ -50,7 +50,7 @@ public: /** create the action @warning: This interface will be deprecated in future. */ - static CCWaves3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); + CC_DEPRECATED_ATTRIBUTE static CCWaves3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); /** create the action */ static CCWaves3D* create(int wav, float amp, const ccGridSize& gridSize, float duration); protected: @@ -73,7 +73,7 @@ public: /** creates the action with duration @warning: This interface will be deprecated in future. */ - static CCFlipX3D* actionWithDuration(float duration); + CC_DEPRECATED_ATTRIBUTE static CCFlipX3D* actionWithDuration(float duration); /** creates the action with duration */ static CCFlipX3D* create(float duration); }; @@ -89,7 +89,7 @@ public: /** creates the action with duration @warning: This interface will be deprecated in future. */ - static CCFlipY3D* actionWithDuration(float duration); + CC_DEPRECATED_ATTRIBUTE static CCFlipY3D* actionWithDuration(float duration); /** creates the action with duration */ static CCFlipY3D* create(float duration); }; @@ -115,7 +115,7 @@ public: /** creates the action with center position, radius, a grid size and duration @warning: This interface will be deprecated in future. */ - static CCLens3D* actionWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration); + CC_DEPRECATED_ATTRIBUTE static CCLens3D* actionWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration); /** creates the action with center position, radius, a grid size and duration */ static CCLens3D* create(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration); protected: @@ -153,7 +153,7 @@ public: /** creates the action with radius, number of waves, amplitude, a grid size and duration @warning: This interface will be deprecated in future. */ - static CCRipple3D* actionWithPosition(const CCPoint& pos, float r, int wav, float amp, + CC_DEPRECATED_ATTRIBUTE static CCRipple3D* actionWithPosition(const CCPoint& pos, float r, int wav, float amp, const ccGridSize& gridSize, float duration); /** creates the action with radius, number of waves, amplitude, a grid size and duration */ static CCRipple3D* create(const CCPoint& pos, float r, int wav, float amp, @@ -180,7 +180,7 @@ public: /** creates the action with a range, shake Z vertices, a grid and duration @warning: This interface will be deprecated in future. */ - static CCShaky3D* actionWithRange(int range, bool shakeZ, const ccGridSize& gridSize, float duration); + CC_DEPRECATED_ATTRIBUTE static CCShaky3D* actionWithRange(int range, bool shakeZ, const ccGridSize& gridSize, float duration); /** creates the action with a range, shake Z vertices, a grid and duration */ static CCShaky3D* create(int range, bool shakeZ, const ccGridSize& gridSize, float duration); protected: @@ -207,7 +207,7 @@ public: /** creates the action with amplitude, a grid and duration @warning: This interface will be deprecated in future. */ - static CCLiquid* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); + CC_DEPRECATED_ATTRIBUTE static CCLiquid* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); /** creates the action with amplitude, a grid and duration */ static CCLiquid* create(int wav, float amp, const ccGridSize& gridSize, float duration); protected: @@ -236,7 +236,7 @@ public: /** initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration @warning: This interface will be deprecated in future. */ - static CCWaves* actionWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, + CC_DEPRECATED_ATTRIBUTE static CCWaves* actionWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, float duration); /** initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration */ @@ -275,7 +275,7 @@ public: /** creates the action with center position, number of twirls, amplitude, a grid size and duration @warning: This interface will be deprecated in future. */ - static CCTwirl* actionWithPosition(CCPoint pos, int t, float amp, const ccGridSize& gridSize, + CC_DEPRECATED_ATTRIBUTE static CCTwirl* actionWithPosition(CCPoint pos, int t, float amp, const ccGridSize& gridSize, float duration); /** creates the action with center position, number of twirls, amplitude, a grid size and duration */ diff --git a/cocos2dx/actions/CCActionInstant.h b/cocos2dx/actions/CCActionInstant.h index bd9fa64204..bedd94cd76 100644 --- a/cocos2dx/actions/CCActionInstant.h +++ b/cocos2dx/actions/CCActionInstant.h @@ -66,7 +66,7 @@ public: /** Allocates and initializes the action @warning: This interface will be deprecated in future. */ - static CCShow * action(); + CC_DEPRECATED_ATTRIBUTE static CCShow * action(); /** Allocates and initializes the action */ static CCShow * create(); @@ -91,7 +91,7 @@ public: /** Allocates and initializes the action @warning: This interface will be deprecated in future. */ - static CCHide * action(); + CC_DEPRECATED_ATTRIBUTE static CCHide * action(); /** Allocates and initializes the action */ static CCHide * create(); @@ -112,7 +112,7 @@ public: /** Allocates and initializes the action @warning: This interface will be deprecated in future. */ - static CCToggleVisibility * action(); + CC_DEPRECATED_ATTRIBUTE static CCToggleVisibility * action(); /** Allocates and initializes the action */ static CCToggleVisibility * create(); @@ -133,7 +133,7 @@ public: /** create the action @warning: This interface will be deprecated in future. */ - static CCFlipX * actionWithFlipX(bool x); + CC_DEPRECATED_ATTRIBUTE static CCFlipX * actionWithFlipX(bool x); /** create the action */ static CCFlipX * create(bool x); @@ -164,7 +164,7 @@ public: /** create the action @warning: This interface will be deprecated in future. */ - static CCFlipY * actionWithFlipY(bool y); + CC_DEPRECATED_ATTRIBUTE static CCFlipY * actionWithFlipY(bool y); /** create the action */ static CCFlipY * create(bool y); @@ -190,7 +190,7 @@ public: /** creates a Place action with a position @warning: This interface will be deprecated in future. */ - static CCPlace * actionWithPosition(const CCPoint& pos); + CC_DEPRECATED_ATTRIBUTE static CCPlace * actionWithPosition(const CCPoint& pos); /** creates a Place action with a position */ static CCPlace * create(const CCPoint& pos); /** Initializes a Place action with a position */ @@ -220,7 +220,7 @@ public: @warning: This interface will be deprecated in future. typedef void (CCObject::*SEL_CallFunc)(); */ - static CCCallFunc * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFunc selector); + CC_DEPRECATED_ATTRIBUTE static CCCallFunc * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFunc selector); /** creates the action with the callback @@ -280,7 +280,7 @@ public: @warning: This interface will be deprecated in future. typedef void (CCObject::*SEL_CallFuncN)(CCNode*); */ - static CCCallFuncN * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncN selector); + CC_DEPRECATED_ATTRIBUTE static CCCallFuncN * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncN selector); /** creates the action with the callback @@ -309,7 +309,7 @@ public: /** creates the action with the callback and the data to pass as an argument @warning: This interface will be deprecated in future. */ - static CCCallFuncND * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncND selector, void* d); + CC_DEPRECATED_ATTRIBUTE static CCCallFuncND * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncND selector, void* d); /** creates the action with the callback and the data to pass as an argument */ static CCCallFuncND * create(CCObject* pSelectorTarget, SEL_CallFuncND selector, void* d); @@ -339,7 +339,7 @@ public: @warning: This interface will be deprecated in future. typedef void (CCObject::*SEL_CallFuncO)(CCObject*); */ - static CCCallFuncO * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncO selector, CCObject* pObject); + CC_DEPRECATED_ATTRIBUTE static CCCallFuncO * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncO selector, CCObject* pObject); /** creates the action with the callback diff --git a/cocos2dx/actions/CCActionInterval.cpp b/cocos2dx/actions/CCActionInterval.cpp index 599bd9b9ef..cddd12b8c6 100644 --- a/cocos2dx/actions/CCActionInterval.cpp +++ b/cocos2dx/actions/CCActionInterval.cpp @@ -178,7 +178,7 @@ CCFiniteTimeAction* CCSequence::actions(CCFiniteTimeAction *pAction1, ...) pNow = va_arg(params, CCFiniteTimeAction*); if (pNow) { - pPrev = actionOneTwo(pPrev, pNow); + pPrev = CCSequence::create(pPrev, pNow); } else { @@ -215,18 +215,18 @@ CCFiniteTimeAction* CCSequence::create(CCFiniteTimeAction *pAction1, ...) return pPrev; } -CCFiniteTimeAction* CCSequence::actionWithArray(CCArray *actions) +CCFiniteTimeAction* CCSequence::actionWithArray(CCArray* arrayOfActions) { - return CCSequence::create(actions); + return CCSequence::create(arrayOfActions); } -CCFiniteTimeAction* CCSequence::create(CCArray *actions) +CCFiniteTimeAction* CCSequence::create(CCArray* arrayOfActions) { - CCFiniteTimeAction* prev = (CCFiniteTimeAction*)actions->objectAtIndex(0); + CCFiniteTimeAction* prev = (CCFiniteTimeAction*)arrayOfActions->objectAtIndex(0); - for (unsigned int i = 1; i < actions->count(); ++i) + for (unsigned int i = 1; i < arrayOfActions->count(); ++i) { - prev = create(prev, (CCFiniteTimeAction*)actions->objectAtIndex(i)); + prev = create(prev, (CCFiniteTimeAction*)arrayOfActions->objectAtIndex(i)); } return prev; @@ -585,7 +585,7 @@ CCFiniteTimeAction* CCSpawn::actions(CCFiniteTimeAction *pAction1, ...) pNow = va_arg(params, CCFiniteTimeAction*); if (pNow) { - pPrev = actionOneTwo(pPrev, pNow); + pPrev = CCSpawn::create(pPrev, pNow); } else { @@ -622,18 +622,18 @@ CCFiniteTimeAction* CCSpawn::create(CCFiniteTimeAction *pAction1, ...) return pPrev; } -CCFiniteTimeAction* CCSpawn::actionWithArray(CCArray *actions) +CCFiniteTimeAction* CCSpawn::actionWithArray(CCArray *arrayOfActions) { - return CCSpawn::create(actions); + return CCSpawn::create(arrayOfActions); } -CCFiniteTimeAction* CCSpawn::create(CCArray *actions) +CCFiniteTimeAction* CCSpawn::create(CCArray *arrayOfActions) { - CCFiniteTimeAction* prev = (CCFiniteTimeAction*)actions->objectAtIndex(0); + CCFiniteTimeAction* prev = (CCFiniteTimeAction*)arrayOfActions->objectAtIndex(0); - for (unsigned int i = 1; i < actions->count(); ++i) + for (unsigned int i = 1; i < arrayOfActions->count(); ++i) { - prev = create(prev, (CCFiniteTimeAction*)actions->objectAtIndex(i)); + prev = create(prev, (CCFiniteTimeAction*)arrayOfActions->objectAtIndex(i)); } return prev; diff --git a/cocos2dx/actions/CCActionInterval.h b/cocos2dx/actions/CCActionInterval.h index 78b56db756..339794cb5d 100644 --- a/cocos2dx/actions/CCActionInterval.h +++ b/cocos2dx/actions/CCActionInterval.h @@ -75,7 +75,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCActionInterval* actionWithDuration(float d); + CC_DEPRECATED_ATTRIBUTE static CCActionInterval* actionWithDuration(float d); /** creates the action */ static CCActionInterval* create(float d); @@ -110,15 +110,15 @@ public: /** helper constructor to create an array of sequenceable actions @warning: This interface will be deprecated in future. */ - static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...); + CC_DEPRECATED_ATTRIBUTE static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...); /** helper contructor to create an array of sequenceable actions given an array @warning: This interface will be deprecated in future. */ - static CCFiniteTimeAction* actionWithArray(CCArray *arrayOfActions); + CC_DEPRECATED_ATTRIBUTE static CCFiniteTimeAction* actionWithArray(CCArray *arrayOfActions); /** creates the action @warning: This interface will be deprecated in future. */ - static CCSequence* actionOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo); + CC_DEPRECATED_ATTRIBUTE static CCSequence* actionOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo); /** helper constructor to create an array of sequenceable actions */ static CCFiniteTimeAction* create(CCFiniteTimeAction *pAction1, ...); @@ -170,7 +170,7 @@ public: /** creates a CCRepeat action. Times is an unsigned integer between 1 and pow(2,30) @warning: This interface will be deprecated in future. */ - static CCRepeat* actionWithAction(CCFiniteTimeAction *pAction, unsigned int times); + CC_DEPRECATED_ATTRIBUTE static CCRepeat* actionWithAction(CCFiniteTimeAction *pAction, unsigned int times); /** creates a CCRepeat action. Times is an unsigned integer between 1 and pow(2,30) */ static CCRepeat* create(CCFiniteTimeAction *pAction, unsigned int times); @@ -222,7 +222,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCRepeatForever* actionWithAction(CCActionInterval *pAction); + CC_DEPRECATED_ATTRIBUTE static CCRepeatForever* actionWithAction(CCActionInterval *pAction); /** creates the action */ static CCRepeatForever* create(CCActionInterval *pAction); protected: @@ -250,17 +250,17 @@ public: /** helper constructor to create an array of spawned actions @warning: This interface will be deprecated in future. */ - static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...); + CC_DEPRECATED_ATTRIBUTE static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...); /** helper contructor to create an array of spawned actions given an array @warning: This interface will be deprecated in future. */ - static CCFiniteTimeAction* actionWithArray(CCArray *arrayOfActions); + CC_DEPRECATED_ATTRIBUTE static CCFiniteTimeAction* actionWithArray(CCArray *arrayOfActions); /** creates the Spawn action @warning: This interface will be deprecated in future. */ - static CCSpawn* actionOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2); + CC_DEPRECATED_ATTRIBUTE static CCSpawn* actionOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2); /** helper constructor to create an array of spawned actions */ static CCFiniteTimeAction* create(CCFiniteTimeAction *pAction1, ...); @@ -294,7 +294,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCRotateTo* actionWithDuration(float duration, float fDeltaAngle); + CC_DEPRECATED_ATTRIBUTE static CCRotateTo* actionWithDuration(float duration, float fDeltaAngle); /** creates the action */ static CCRotateTo* create(float duration, float fDeltaAngle); protected: @@ -320,7 +320,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCRotateBy* actionWithDuration(float duration, float fDeltaAngle); + CC_DEPRECATED_ATTRIBUTE static CCRotateBy* actionWithDuration(float duration, float fDeltaAngle); /** creates the action */ static CCRotateBy* create(float duration, float fDeltaAngle); protected: @@ -344,7 +344,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCMoveTo* actionWithDuration(float duration, const CCPoint& position); + CC_DEPRECATED_ATTRIBUTE static CCMoveTo* actionWithDuration(float duration, const CCPoint& position); /** creates the action */ static CCMoveTo* create(float duration, const CCPoint& position); protected: @@ -371,7 +371,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCMoveBy* actionWithDuration(float duration, const CCPoint& position); + CC_DEPRECATED_ATTRIBUTE static CCMoveBy* actionWithDuration(float duration, const CCPoint& position); /** creates the action */ static CCMoveBy* create(float duration, const CCPoint& position); }; @@ -392,7 +392,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCSkewTo* actionWithDuration(float t, float sx, float sy); + CC_DEPRECATED_ATTRIBUTE static CCSkewTo* actionWithDuration(float t, float sx, float sy); /** creates the action */ static CCSkewTo* create(float t, float sx, float sy); @@ -421,7 +421,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCSkewBy* actionWithDuration(float t, float deltaSkewX, float deltaSkewY); + CC_DEPRECATED_ATTRIBUTE static CCSkewBy* actionWithDuration(float t, float deltaSkewX, float deltaSkewY); /** creates the action */ static CCSkewBy* create(float t, float deltaSkewX, float deltaSkewY); }; @@ -443,7 +443,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCJumpBy* actionWithDuration(float duration, const CCPoint& position, float height, unsigned int jumps); + CC_DEPRECATED_ATTRIBUTE static CCJumpBy* actionWithDuration(float duration, const CCPoint& position, float height, unsigned int jumps); /** creates the action */ static CCJumpBy* create(float duration, const CCPoint& position, float height, unsigned int jumps); protected: @@ -465,7 +465,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCJumpTo* actionWithDuration(float duration, const CCPoint& position, float height, int jumps); + CC_DEPRECATED_ATTRIBUTE static CCJumpTo* actionWithDuration(float duration, const CCPoint& position, float height, int jumps); /** creates the action */ static CCJumpTo* create(float duration, const CCPoint& position, float height, int jumps); }; @@ -498,7 +498,7 @@ public: /** creates the action with a duration and a bezier configuration @warning: This interface will be deprecated in future. */ - static CCBezierBy* actionWithDuration(float t, const ccBezierConfig& c); + CC_DEPRECATED_ATTRIBUTE static CCBezierBy* actionWithDuration(float t, const ccBezierConfig& c); /** creates the action with a duration and a bezier configuration */ static CCBezierBy* create(float t, const ccBezierConfig& c); protected: @@ -519,7 +519,7 @@ public: /** creates the action with a duration and a bezier configuration @warning: This interface will be deprecated in future. */ - static CCBezierTo* actionWithDuration(float t, const ccBezierConfig& c); + CC_DEPRECATED_ATTRIBUTE static CCBezierTo* actionWithDuration(float t, const ccBezierConfig& c); /** creates the action with a duration and a bezier configuration */ static CCBezierTo* create(float t, const ccBezierConfig& c); @@ -545,12 +545,12 @@ public: /** creates the action with the same scale factor for X and Y @warning: This interface will be deprecated in future. */ - static CCScaleTo* actionWithDuration(float duration, float s); + CC_DEPRECATED_ATTRIBUTE static CCScaleTo* actionWithDuration(float duration, float s); /** creates the action with and X factor and a Y factor @warning: This interface will be deprecated in future. */ - static CCScaleTo* actionWithDuration(float duration, float sx, float sy); + CC_DEPRECATED_ATTRIBUTE static CCScaleTo* actionWithDuration(float duration, float sx, float sy); /** creates the action with the same scale factor for X and Y */ static CCScaleTo* create(float duration, float s); @@ -581,12 +581,12 @@ public: /** creates the action with the same scale factor for X and Y @warning: This interface will be deprecated in future. */ - static CCScaleBy* actionWithDuration(float duration, float s); + CC_DEPRECATED_ATTRIBUTE static CCScaleBy* actionWithDuration(float duration, float s); /** creates the action with and X factor and a Y factor @warning: This interface will be deprecated in future. */ - static CCScaleBy* actionWithDuration(float duration, float sx, float sy); + CC_DEPRECATED_ATTRIBUTE static CCScaleBy* actionWithDuration(float duration, float sx, float sy); /** creates the action with the same scale factor for X and Y */ static CCScaleBy* create(float duration, float s); @@ -611,7 +611,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCBlink* actionWithDuration(float duration, unsigned int uBlinks); + CC_DEPRECATED_ATTRIBUTE static CCBlink* actionWithDuration(float duration, unsigned int uBlinks); /** creates the action */ static CCBlink* create(float duration, unsigned int uBlinks); protected: @@ -632,7 +632,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCFadeIn* actionWithDuration(float d); + CC_DEPRECATED_ATTRIBUTE static CCFadeIn* actionWithDuration(float d); /** creates the action */ static CCFadeIn* create(float d); }; @@ -651,7 +651,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCFadeOut* actionWithDuration(float d); + CC_DEPRECATED_ATTRIBUTE static CCFadeOut* actionWithDuration(float d); /** creates the action */ static CCFadeOut* create(float d); @@ -674,7 +674,7 @@ public: /** creates an action with duration and opacity @warning: This interface will be deprecated in future. */ - static CCFadeTo* actionWithDuration(float duration, GLubyte opacity); + CC_DEPRECATED_ATTRIBUTE static CCFadeTo* actionWithDuration(float duration, GLubyte opacity); /** creates an action with duration and opacity */ static CCFadeTo* create(float duration, GLubyte opacity); protected: @@ -700,7 +700,7 @@ public: /** creates an action with duration and color @warning: This interface will be deprecated in future. */ - static CCTintTo* actionWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue); + CC_DEPRECATED_ATTRIBUTE static CCTintTo* actionWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue); /** creates an action with duration and color */ static CCTintTo* create(float duration, GLubyte red, GLubyte green, GLubyte blue); protected: @@ -726,7 +726,7 @@ public: /** creates an action with duration and color @warning: This interface will be deprecated in future. */ - static CCTintBy* actionWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); + CC_DEPRECATED_ATTRIBUTE static CCTintBy* actionWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); /** creates an action with duration and color */ static CCTintBy* create(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); protected: @@ -752,7 +752,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCDelayTime* actionWithDuration(float d); + CC_DEPRECATED_ATTRIBUTE static CCDelayTime* actionWithDuration(float d); /** creates the action */ static CCDelayTime* create(float d); @@ -784,7 +784,7 @@ public: /** creates the action @warning: This interface will be deprecated in future. */ - static CCReverseTime* actionWithAction(CCFiniteTimeAction *pAction); + CC_DEPRECATED_ATTRIBUTE static CCReverseTime* actionWithAction(CCFiniteTimeAction *pAction); /** creates the action */ static CCReverseTime* create(CCFiniteTimeAction *pAction); protected: @@ -813,7 +813,7 @@ public: /** creates the action with an Animation and will restore the original frame when the animation is over @warning: This interface will be deprecated in future. */ - static CCAnimate* actionWithAnimation(CCAnimation *pAnimation); + CC_DEPRECATED_ATTRIBUTE static CCAnimate* actionWithAnimation(CCAnimation *pAnimation); /** creates the action with an Animation and will restore the original frame when the animation is over */ static CCAnimate* create(CCAnimation *pAnimation); CC_SYNTHESIZE_RETAIN(CCAnimation*, m_pAnimation, Animation) @@ -835,7 +835,7 @@ public: /** Create an action with the specified action and forced target @warning: This interface will be deprecated in future. */ - static CCTargetedAction* actionWithTarget(CCNode* pTarget, CCFiniteTimeAction* pAction); + CC_DEPRECATED_ATTRIBUTE static CCTargetedAction* actionWithTarget(CCNode* pTarget, CCFiniteTimeAction* pAction); /** Create an action with the specified action and forced target */ static CCTargetedAction* create(CCNode* pTarget, CCFiniteTimeAction* pAction); diff --git a/cocos2dx/actions/CCActionPageTurn3D.h b/cocos2dx/actions/CCActionPageTurn3D.h index 7ec14caac2..ce675c5473 100644 --- a/cocos2dx/actions/CCActionPageTurn3D.h +++ b/cocos2dx/actions/CCActionPageTurn3D.h @@ -46,7 +46,7 @@ public: /** create the action @warning: This interface will be deprecated in future. */ - static CCPageTurn3D* actionWithSize(const ccGridSize& gridSize, float time); + CC_DEPRECATED_ATTRIBUTE static CCPageTurn3D* actionWithSize(const ccGridSize& gridSize, float time); /** create the action */ static CCPageTurn3D* create(const ccGridSize& gridSize, float time); }; diff --git a/cocos2dx/actions/CCActionProgressTimer.h b/cocos2dx/actions/CCActionProgressTimer.h index 9e09094e53..d1130b9e15 100644 --- a/cocos2dx/actions/CCActionProgressTimer.h +++ b/cocos2dx/actions/CCActionProgressTimer.h @@ -47,7 +47,7 @@ public: /** Creates and initializes with a duration and a percent @warning: This interface will be deprecated in future. */ - static CCProgressTo* actionWithDuration(float duration, float fPercent); + CC_DEPRECATED_ATTRIBUTE static CCProgressTo* actionWithDuration(float duration, float fPercent); /** Creates and initializes with a duration and a percent */ static CCProgressTo* create(float duration, float fPercent); protected: @@ -74,7 +74,7 @@ public: /** Creates and initializes the action with a duration, a "from" percentage and a "to" percentage @warning: This interface will be deprecated in future. */ - static CCProgressFromTo* actionWithDuration(float duration, float fFromPercentage, float fToPercentage); + CC_DEPRECATED_ATTRIBUTE static CCProgressFromTo* actionWithDuration(float duration, float fFromPercentage, float fToPercentage); /** Creates and initializes the action with a duration, a "from" percentage and a "to" percentage */ static CCProgressFromTo* create(float duration, float fFromPercentage, float fToPercentage); protected: diff --git a/cocos2dx/actions/CCActionTiledGrid.h b/cocos2dx/actions/CCActionTiledGrid.h index 1c67f09d98..c075b284fe 100644 --- a/cocos2dx/actions/CCActionTiledGrid.h +++ b/cocos2dx/actions/CCActionTiledGrid.h @@ -43,7 +43,7 @@ public: /** creates the action with a range, whether or not to shake Z vertices, a grid size, and duration @warning: This interface will be deprecated in future. */ - static CCShakyTiles3D* actionWithRange(int nRange, bool bShakeZ, const ccGridSize& gridSize, float duration); + CC_DEPRECATED_ATTRIBUTE static CCShakyTiles3D* actionWithRange(int nRange, bool bShakeZ, const ccGridSize& gridSize, float duration); /** creates the action with a range, whether or not to shake Z vertices, a grid size, and duration */ static CCShakyTiles3D* create(int nRange, bool bShakeZ, const ccGridSize& gridSize, float duration); @@ -68,7 +68,7 @@ public: /** creates the action with a range, whether of not to shatter Z vertices, a grid size and duration @warning: This interface will be deprecated in future. */ - static CCShatteredTiles3D* actionWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize, + CC_DEPRECATED_ATTRIBUTE static CCShatteredTiles3D* actionWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize, float duration); /** creates the action with a range, whether of not to shatter Z vertices, a grid size and duration */ @@ -102,7 +102,7 @@ public: /** creates the action with a random seed, the grid size and the duration @warning: This interface will be deprecated in future. */ - static CCShuffleTiles* actionWithSeed(int s, const ccGridSize& gridSize, float duration); + CC_DEPRECATED_ATTRIBUTE static CCShuffleTiles* actionWithSeed(int s, const ccGridSize& gridSize, float duration); /** creates the action with a random seed, the grid size and the duration */ static CCShuffleTiles* create(int s, const ccGridSize& gridSize, float duration); protected: @@ -128,7 +128,7 @@ public: /** creates the action with the grid size and the duration @warning: This interface will be deprecated in future. */ - static CCFadeOutTRTiles* actionWithSize(const ccGridSize& gridSize, float time); + CC_DEPRECATED_ATTRIBUTE static CCFadeOutTRTiles* actionWithSize(const ccGridSize& gridSize, float time); /** creates the action with the grid size and the duration */ static CCFadeOutTRTiles* create(const ccGridSize& gridSize, float time); @@ -146,7 +146,7 @@ public: /** creates the action with the grid size and the duration @warning: This interface will be deprecated in future. */ - static CCFadeOutBLTiles* actionWithSize(const ccGridSize& gridSize, float time); + CC_DEPRECATED_ATTRIBUTE static CCFadeOutBLTiles* actionWithSize(const ccGridSize& gridSize, float time); /** creates the action with the grid size and the duration */ static CCFadeOutBLTiles* create(const ccGridSize& gridSize, float time); @@ -165,7 +165,7 @@ public: /** creates the action with the grid size and the duration @warning: This interface will be deprecated in future. */ - static CCFadeOutUpTiles* actionWithSize(const ccGridSize& gridSize, float time); + CC_DEPRECATED_ATTRIBUTE static CCFadeOutUpTiles* actionWithSize(const ccGridSize& gridSize, float time); /** creates the action with the grid size and the duration */ static CCFadeOutUpTiles* create(const ccGridSize& gridSize, float time); @@ -183,7 +183,7 @@ public: /** creates the action with the grid size and the duration @warning: This interface will be deprecated in future. */ - static CCFadeOutDownTiles* actionWithSize(const ccGridSize& gridSize, float time); + CC_DEPRECATED_ATTRIBUTE static CCFadeOutDownTiles* actionWithSize(const ccGridSize& gridSize, float time); /** creates the action with the grid size and the duration */ static CCFadeOutDownTiles* create(const ccGridSize& gridSize, float time); @@ -210,11 +210,11 @@ public: /** creates the action with the grid size and the duration @warning: This interface will be deprecated in future. */ - static CCTurnOffTiles* actionWithSize(const ccGridSize& size, float d); + CC_DEPRECATED_ATTRIBUTE static CCTurnOffTiles* actionWithSize(const ccGridSize& size, float d); /** creates the action with a random seed, the grid size and the duration @warning: This interface will be deprecated in future. */ - static CCTurnOffTiles* actionWithSeed(int s, const ccGridSize& gridSize, float duration); + CC_DEPRECATED_ATTRIBUTE static CCTurnOffTiles* actionWithSeed(int s, const ccGridSize& gridSize, float duration); /** creates the action with the grid size and the duration */ static CCTurnOffTiles* create(const ccGridSize& size, float d); @@ -249,7 +249,7 @@ public: /** creates the action with a number of waves, the waves amplitude, the grid size and the duration @warning: This interface will be deprecated in future. */ - static CCWavesTiles3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); + CC_DEPRECATED_ATTRIBUTE static CCWavesTiles3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); /** creates the action with a number of waves, the waves amplitude, the grid size and the duration */ static CCWavesTiles3D* create(int wav, float amp, const ccGridSize& gridSize, float duration); protected: @@ -281,7 +281,7 @@ public: /** creates the action with the number of jumps, the sin amplitude, the grid size and the duration @warning: This interface will be deprecated in future. */ - static CCJumpTiles3D* actionWithJumps(int j, float amp, const ccGridSize& gridSize, float duration); + CC_DEPRECATED_ATTRIBUTE static CCJumpTiles3D* actionWithJumps(int j, float amp, const ccGridSize& gridSize, float duration); /** creates the action with the number of jumps, the sin amplitude, the grid size and the duration */ static CCJumpTiles3D* create(int j, float amp, const ccGridSize& gridSize, float duration); protected: @@ -305,7 +305,7 @@ public: /** creates the action with the number of rows to split and the duration @warning: This interface will be deprecated in future. */ - static CCSplitRows* actionWithRows(int nRows, float duration); + CC_DEPRECATED_ATTRIBUTE static CCSplitRows* actionWithRows(int nRows, float duration); /** creates the action with the number of rows to split and the duration */ static CCSplitRows* create(int nRows, float duration); protected: @@ -328,7 +328,7 @@ public: /** creates the action with the number of columns to split and the duration @warning: This interface will be deprecated in future. */ - static CCSplitCols* actionWithCols(int nCols, float duration); + CC_DEPRECATED_ATTRIBUTE static CCSplitCols* actionWithCols(int nCols, float duration); /** creates the action with the number of columns to split and the duration */ static CCSplitCols* create(int nCols, float duration); protected: diff --git a/cocos2dx/actions/CCActionTween.h b/cocos2dx/actions/CCActionTween.h index e3ceca34d0..9620437f0d 100644 --- a/cocos2dx/actions/CCActionTween.h +++ b/cocos2dx/actions/CCActionTween.h @@ -60,7 +60,7 @@ public: /** creates an initializes the action with the property name (key), and the from and to parameters. @warning: This interface will be deprecated in future. */ - static CCActionTween* actionWithDuration(float aDuration, const char* key, float from, float to); + CC_DEPRECATED_ATTRIBUTE static CCActionTween* actionWithDuration(float aDuration, const char* key, float from, float to); /** creates an initializes the action with the property name (key), and the from and to parameters. */ static CCActionTween* create(float aDuration, const char* key, float from, float to); /** initializes the action with the property name (key), and the from and to parameters. */ diff --git a/cocos2dx/base_nodes/CCAtlasNode.h b/cocos2dx/base_nodes/CCAtlasNode.h index ecd4231a38..bb4650045d 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.h +++ b/cocos2dx/base_nodes/CCAtlasNode.h @@ -82,7 +82,7 @@ public: /** creates a CCAtlasNode with an Atlas file the width and height of each item and the quantity of items to render @warning: This interface will be deprecated in future. */ - static CCAtlasNode * atlasWithTileFile(const char* tile,unsigned int tileWidth, unsigned int tileHeight, + CC_DEPRECATED_ATTRIBUTE static CCAtlasNode * atlasWithTileFile(const char* tile,unsigned int tileWidth, unsigned int tileHeight, unsigned int itemsToRender); /** creates a CCAtlasNode with an Atlas file the width and height of each item and the quantity of items to render*/ diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index 086e2e8c9d..abf1ee8984 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -308,7 +308,7 @@ public: The node will be created as "autorelease". @warning: This interface will be deprecated in future. */ - static CCNode * node(void); + CC_DEPRECATED_ATTRIBUTE static CCNode * node(void); /** allocates and initializes a node. The node will be created as "autorelease". diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index 5b09f1b74c..e2e52b9085 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -113,37 +113,37 @@ public: /** Create an array @warning: This interface will be deprecated in future. */ - static CCArray* array(); + CC_DEPRECATED_ATTRIBUTE static CCArray* array(); /** Create an array with one object @warning: This interface will be deprecated in future. */ - static CCArray* arrayWithObject(CCObject* pObject); + CC_DEPRECATED_ATTRIBUTE static CCArray* arrayWithObject(CCObject* pObject); /** Create an array with some objects @warning: This interface will be deprecated in future. */ - static CCArray* arrayWithObjects(CCObject* pObject, ...); + CC_DEPRECATED_ATTRIBUTE static CCArray* arrayWithObjects(CCObject* pObject, ...); /** Create an array with capacity @warning: This interface will be deprecated in future. */ - static CCArray* arrayWithCapacity(unsigned int capacity); + CC_DEPRECATED_ATTRIBUTE static CCArray* arrayWithCapacity(unsigned int capacity); /** Create an array with an existing array @warning: This interface will be deprecated in future. */ - static CCArray* arrayWithArray(CCArray* otherArray); + CC_DEPRECATED_ATTRIBUTE static CCArray* arrayWithArray(CCArray* otherArray); /** @brief Generate a CCArray pointer by file @param pFileName The file name of *.plist file @return The CCArray pointer generated from the file @warning: This interface will be deprecated in future. */ - static CCArray* arrayWithContentsOfFile(const char* pFileName); + CC_DEPRECATED_ATTRIBUTE static CCArray* arrayWithContentsOfFile(const char* pFileName); /* @brief The same meaning as arrayWithContentsOfFile(), but it doesn't call autorelease, so the invoker should call release(). @warning: This interface will be deprecated in future. */ - static CCArray* arrayWithContentsOfFileThreadSafe(const char* pFileName); + CC_DEPRECATED_ATTRIBUTE static CCArray* arrayWithContentsOfFileThreadSafe(const char* pFileName); /** Create an array */ static CCArray* create(); diff --git a/cocos2dx/cocoa/CCDictionary.h b/cocos2dx/cocoa/CCDictionary.h index 86dfa07d9a..64614df570 100644 --- a/cocos2dx/cocoa/CCDictionary.h +++ b/cocos2dx/cocoa/CCDictionary.h @@ -137,23 +137,24 @@ public: /* static functions */ //@warning: This interface will be deprecated in future. - static CCDictionary* dictionary(); + CC_DEPRECATED_ATTRIBUTE static CCDictionary* dictionary(); - static CCDictionary* dictionaryWithDictionary(CCDictionary* srcDict); + //@warning: This interface will be deprecated in future. + CC_DEPRECATED_ATTRIBUTE static CCDictionary* dictionaryWithDictionary(CCDictionary* srcDict); /** @brief Generate a CCDictionary pointer by file @param pFileName The file name of *.plist file @return The CCDictionary pointer generated from the file @warning: This interface will be deprecated in future. */ - static CCDictionary* dictionaryWithContentsOfFile(const char *pFileName); + CC_DEPRECATED_ATTRIBUTE static CCDictionary* dictionaryWithContentsOfFile(const char *pFileName); /* @brief The same meaning as dictionaryWithContentsOfFile(), but it doesn't call autorelease, so the invoker should call release(). @warning: This interface will be deprecated in future. */ - static CCDictionary* dictionaryWithContentsOfFileThreadSafe(const char *pFileName); + CC_DEPRECATED_ATTRIBUTE static CCDictionary* dictionaryWithContentsOfFileThreadSafe(const char *pFileName); static CCDictionary* create(); diff --git a/cocos2dx/cocoa/CCInteger.h b/cocos2dx/cocoa/CCInteger.h index b8d550cf18..ff52046405 100644 --- a/cocos2dx/cocoa/CCInteger.h +++ b/cocos2dx/cocoa/CCInteger.h @@ -13,7 +13,7 @@ public: int getValue() const {return m_nValue;} // @warning: This interface will be deprecated in future. - static CCInteger* integerWithInt(int v) + CC_DEPRECATED_ATTRIBUTE static CCInteger* integerWithInt(int v) { return CCInteger::create(v); } diff --git a/cocos2dx/cocoa/CCString.cpp b/cocos2dx/cocoa/CCString.cpp index 96fb38e841..f6ea6d8390 100644 --- a/cocos2dx/cocoa/CCString.cpp +++ b/cocos2dx/cocoa/CCString.cpp @@ -155,9 +155,9 @@ CCString* CCString::stringWithCString(const char* pStr) return CCString::create(pStr); } -CCString* CCString::create(const char* pStr) +CCString* CCString::create(const std::string& str) { - CCString* pRet = new CCString(pStr); + CCString* pRet = new CCString(str); pRet->autorelease(); return pRet; } @@ -169,7 +169,12 @@ CCString* CCString::stringWithString(const std::string& pStr) return pRet; } -CCString* CCString::stringWithCStringData(const char* pData, unsigned long nLen) +CCString* CCString::stringWithData(const unsigned char* pData, unsigned long nLen) +{ + return CCString::createWithData(pData, nLen); +} + +CCString* CCString::createWithData(const unsigned char* pData, unsigned long nLen) { CCString* pRet = NULL; if (pData != NULL) @@ -178,30 +183,11 @@ CCString* CCString::stringWithCStringData(const char* pData, unsigned long nLen) if (pStr != NULL) { pStr[nLen] = '\0'; - memcpy(pStr, pData, nLen); - pRet = CCString::stringWithCString(pStr); - free(pStr); - } - } - return pRet; - -} - -CCString* CCString::stringWithData(unsigned char* pData, unsigned long nLen) -{ - return CCString::createWithData(pData, nLen); -} - -CCString* CCString::createWithData(unsigned char* pData, unsigned long nLen) -{ - CCString* pRet = NULL; - if (pData != NULL && nLen > 0) - { - char* pStr = (char*)malloc(nLen+1); - if (pStr != NULL) - { - pStr[nLen] = '\0'; - memcpy(pStr, pData, nLen); + if (nLen > 0) + { + memcpy(pStr, pData, nLen); + } + pRet = CCString::create(pStr); free(pStr); } diff --git a/cocos2dx/cocoa/CCString.h b/cocos2dx/cocoa/CCString.h index b1d2e55bb8..2712ac0cba 100644 --- a/cocos2dx/cocoa/CCString.h +++ b/cocos2dx/cocoa/CCString.h @@ -80,19 +80,13 @@ public: * it means that you needn't do a release operation unless you retain it. @warning: This interface will be deprecated in future. */ - static CCString* stringWithCString(const char* pStr); - - /** create a string with c string - * @return A CCString pointer which is an autorelease object pointer, - * it means that you needn't do a release operation unless you retain it. - */ - static CCString* stringWithCStringData(const char* pData, unsigned long nLen); + CC_DEPRECATED_ATTRIBUTE static CCString* stringWithCString(const char* pStr); /** create a string with std::string * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. */ - static CCString* stringWithString(const std::string& str); + CC_DEPRECATED_ATTRIBUTE static CCString* stringWithString(const std::string& str); /** create a string with format, it's similar with the c function 'sprintf', the default buffer size is (1024*100) bytes, * if you want to change it, you should modify the kMaxStringLen macro in CCString.cpp file. @@ -100,27 +94,27 @@ public: * it means that you needn't do a release operation unless you retain it. @warning: This interface will be deprecated in future. */ - static CCString* stringWithFormat(const char* format, ...); + CC_DEPRECATED_ATTRIBUTE static CCString* stringWithFormat(const char* format, ...); /** create a string with binary data * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. @warning: This interface will be deprecated in future. */ - static CCString* stringWithData(unsigned char* pData, unsigned long nLen); + CC_DEPRECATED_ATTRIBUTE static CCString* stringWithData(const unsigned char* pData, unsigned long nLen); /** create a string with a file, * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. @warning: This interface will be deprecated in future. */ - static CCString* stringWithContentsOfFile(const char* pszFileName); + CC_DEPRECATED_ATTRIBUTE static CCString* stringWithContentsOfFile(const char* pszFileName); - /** create a string with c string + /** create a string with std string, you can also pass a c string pointer because the default constuctor of std::string can access a c string pointer. * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. */ - static CCString* create(const char* pStr); + static CCString* create(const std::string& str); /** create a string with format, it's similar with the c function 'sprintf', the default buffer size is (1024*100) bytes, * if you want to change it, you should modify the kMaxStringLen macro in CCString.cpp file. @@ -133,7 +127,7 @@ public: * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. */ - static CCString* createWithData(unsigned char* pData, unsigned long nLen); + static CCString* createWithData(const unsigned char* pData, unsigned long nLen); /** create a string with a file, * @return A CCString pointer which is an autorelease object pointer, diff --git a/cocos2dx/effects/CCGrid.h b/cocos2dx/effects/CCGrid.h index fd4b645113..22743dc3b2 100644 --- a/cocos2dx/effects/CCGrid.h +++ b/cocos2dx/effects/CCGrid.h @@ -79,11 +79,11 @@ public: /** create one Grid @warning: This interface will be deprecated in future. */ - static CCGridBase* gridWithSize(const ccGridSize& gridSize, CCTexture2D *texture, bool flipped); + CC_DEPRECATED_ATTRIBUTE static CCGridBase* gridWithSize(const ccGridSize& gridSize, CCTexture2D *texture, bool flipped); /** create one Grid @warning: This interface will be deprecated in future. */ - static CCGridBase* gridWithSize(const ccGridSize& gridSize); + CC_DEPRECATED_ATTRIBUTE static CCGridBase* gridWithSize(const ccGridSize& gridSize); /** create one Grid */ static CCGridBase* create(const ccGridSize& gridSize, CCTexture2D *texture, bool flipped); diff --git a/cocos2dx/extensions/CCBReader/CCBReader.cpp b/cocos2dx/extensions/CCBReader/CCBReader.cpp index 822406653f..76548aab89 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader.cpp @@ -93,7 +93,7 @@ CCNode * CCBReader::readNodeGraphFromFile(CCString * pCCBRootPath, CCString * pC } CCNode * CCBReader::readNodeGraphFromFile(const char * pCCBRootPath, const char * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize) { - return this->readNodeGraphFromFile(CCString::stringWithCString(pCCBRootPath), CCString::stringWithCString(pCCBFileName), pOwner, pRootContainerSize); + return this->readNodeGraphFromFile(CCString::create(pCCBRootPath), CCString::create(pCCBFileName), pOwner, pRootContainerSize); } CCNode * CCBReader::readNodeGraphFromFile(CCString * pCCBRootPath, CCString * pCCBFileName, CCObject * pOwner, CCSize pRootContainerSize) { @@ -166,8 +166,8 @@ void CCBReader::readStringCacheEntry() { int numBytes = b0 << 8 | b1; - const char * src = (const char *) (this->mBytes + this->mCurrentByte); - CCString * string = CCString::stringWithCStringData(src, (unsigned long)numBytes); + const unsigned char * src = (const unsigned char *) (this->mBytes + this->mCurrentByte); + CCString * string = CCString::createWithData(src, (unsigned long)numBytes); string->retain(); this->mCurrentByte += numBytes; @@ -182,7 +182,7 @@ unsigned char CCBReader::readByte() { } bool CCBReader::readBool() { - return this->readByte(); + return 0 == this->readByte() ? false : true; } int CCBReader::readInt(bool pSigned) { @@ -230,7 +230,7 @@ float CCBReader::readFloat() { case kCCBFloat05: return 0.5f; case kCCBFloatInteger: - return this->readInt(true); + return (float)this->readInt(true); default: /* using a memcpy since the compiler isn't * doing the float ptr math correctly on device. @@ -368,24 +368,24 @@ CCString * CCBReader::lastPathComponent(CCString * pPath) { std::string path(pPath->getCString()); int slashPos = path.find_last_of("/"); if(slashPos != std::string::npos) { - return CCString::stringWithCString(path.substr(slashPos + 1, path.length() - slashPos).c_str()); + return CCString::create(path.substr(slashPos + 1, path.length() - slashPos).c_str()); } - return CCString::stringWithCString(path.c_str()); + return CCString::create(path.c_str()); } CCString * CCBReader::deletePathExtension(CCString * pPath) { std::string path(pPath->getCString()); int dotPos = path.find_last_of("."); if(dotPos != std::string::npos) { - return CCString::stringWithCString(path.substr(0, dotPos).c_str()); + return CCString::create(path.substr(0, dotPos).c_str()); } - return CCString::stringWithCString(path.c_str()); + return CCString::create(path.c_str()); } CCString * CCBReader::toLowerCase(CCString * pString) { std::string copy(pString->getCString()); std::transform(copy.begin(), copy.end(), copy.begin(), ::tolower); - return CCString::stringWithCString(copy.c_str()); + return CCString::create(copy.c_str()); } CCString * CCBReader::concat(CCString * pStringA, CCString * pStringB) { @@ -396,7 +396,7 @@ CCString * CCBReader::concat(CCString * pStringA, CCString * pStringB) { strcat(concatenated, pStringB->getCString()); concatenated[concatenatedLength] = '\0'; - pRet = CCString::stringWithCString(concatenated); + pRet = CCString::create(concatenated); CC_SAFE_FREE(concatenated); return pRet; } diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp index 5ebc34972b..e6bcfe96e3 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp +++ b/cocos2dx/extensions/CCBReader/CCNodeLoader.cpp @@ -415,7 +415,7 @@ CCSpriteFrame * CCNodeLoader::parsePropTypeSpriteFrame(CCNode * pNode, CCNode * CCTexture2D * texture = CCTextureCache::sharedTextureCache()->addImage(spriteFilePath->getCString()); CCRect bounds = CCRectMake(0, 0, texture->getContentSize().width, texture->getContentSize().height); - spriteFrame = CCSpriteFrame::frameWithTexture(texture, bounds); + spriteFrame = CCSpriteFrame::create(texture, bounds); } else { CCSpriteFrameCache * frameCache = CCSpriteFrameCache::sharedSpriteFrameCache(); @@ -537,7 +537,7 @@ CCString * CCNodeLoader::parsePropTypeText(CCNode * pNode, CCNode * pParent, CCB CCString * CCNodeLoader::parsePropTypeFontTTF(CCNode * pNode, CCNode * pParent, CCBReader * pCCBReader) { CCString * fontTTF = pCCBReader->readCachedString(); - CCString * ttfEnding = CCString::stringWithCString(".ttf"); + CCString * ttfEnding = CCString::create(".ttf"); /* If the fontTTF comes with the ".ttf" extension, prepend the absolute path. * System fonts come without the ".ttf" extension and do not need the path prepended. */ @@ -653,7 +653,7 @@ CCNode * CCNodeLoader::parsePropTypeCCBFile(CCNode * pNode, CCNode * pParent, CC /* Change path extension to .ccbi. */ CCString * ccbFileWithoutPathExtension = CCBReader::deletePathExtension(ccbFileName); - CCString * ccbiFileName = CCBReader::concat(ccbFileWithoutPathExtension, CCString::stringWithCString(".ccbi")); + CCString * ccbiFileName = CCBReader::concat(ccbFileWithoutPathExtension, CCString::create(".ccbi")); CCBReader * ccbReader = new CCBReader(pCCBReader); ccbReader->autorelease(); diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoader.h b/cocos2dx/extensions/CCBReader/CCNodeLoader.h index e4f03cdd4c..639c7baad5 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoader.h +++ b/cocos2dx/extensions/CCBReader/CCNodeLoader.h @@ -7,7 +7,7 @@ NS_CC_EXT_BEGIN #define CCB_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(T) virtual T * createCCNode(cocos2d::CCNode * pParent, cocos2d::extension::CCBReader * pCCBReader) { \ - return T::node(); \ + return T::create(); \ } #define CCB_PURE_VIRTUAL_NEW_AUTORELEASE_CREATECCNODE_METHOD(T) virtual T * createCCNode(cocos2d::CCNode * pParent, cocos2d::extension::CCBReader * pCCBReader) = 0 diff --git a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp index ff25b171ac..bd5fe95410 100644 --- a/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp +++ b/cocos2dx/extensions/CCBReader/CCNodeLoaderLibrary.cpp @@ -44,7 +44,7 @@ void CCNodeLoaderLibrary::registerDefaultCCNodeLoaders() { } void CCNodeLoaderLibrary::registerCCNodeLoader(const char * pClassName, CCNodeLoader * pCCNodeLoader) { - this->registerCCNodeLoader(CCString::stringWithCString(pClassName), pCCNodeLoader); + this->registerCCNodeLoader(CCString::create(pClassName), pCCNodeLoader); } void CCNodeLoaderLibrary::registerCCNodeLoader(CCString * pClassName, CCNodeLoader * pCCNodeLoader) { @@ -54,7 +54,7 @@ void CCNodeLoaderLibrary::registerCCNodeLoader(CCString * pClassName, CCNodeLoad } void CCNodeLoaderLibrary::unregisterCCNodeLoader(const char * pClassName) { - this->unregisterCCNodeLoader(CCString::stringWithCString(pClassName)); + this->unregisterCCNodeLoader(CCString::create(pClassName)); } void CCNodeLoaderLibrary::unregisterCCNodeLoader(CCString * pClassName) { diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp index a3446921d0..e496e8ce17 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.cpp @@ -53,7 +53,7 @@ CCControlButton::~CCControlButton() bool CCControlButton::init() { - return this->initWithLabelAndBackgroundSprite(CCLabelTTF::labelWithString("", "Helvetica", 12), CCScale9Sprite::node()); + return this->initWithLabelAndBackgroundSprite(CCLabelTTF::create("", "Helvetica", 12), CCScale9Sprite::create()); } @@ -371,7 +371,7 @@ void CCControlButton::setTitleTTFForState(const char * fntFile, CCControlState s { CCString * title = this->getTitleForState(state); if (!title) title = new CCString(""); - this->setTitleLabelForState(CCLabelTTF::labelWithString(title->getCString(), fntFile, 12), state); + this->setTitleLabelForState(CCLabelTTF::create(title->getCString(), fntFile, 12), state); } const char * CCControlButton::getTitleTTFForState(CCControlState state) @@ -419,7 +419,7 @@ void CCControlButton::setTitleBMFontForState(const char * fntFile, CCControlStat { CCString * title = this->getTitleForState(state); if (!title) title = new CCString(""); - this->setTitleLabelForState(CCLabelBMFont::labelWithString(title->getCString(), fntFile), state); + this->setTitleLabelForState(CCLabelBMFont::create(title->getCString(), fntFile), state); } const char * CCControlButton::getTitleBMFontForState(CCControlState state) @@ -476,7 +476,7 @@ void CCControlButton::setBackgroundSpriteForState(CCScale9Sprite* sprite, CCCont void CCControlButton::setBackgroundSpriteFrameForState(CCSpriteFrame * spriteFrame, CCControlState state) { - CCScale9Sprite * sprite = CCScale9Sprite::spriteWithSpriteFrame(spriteFrame); + CCScale9Sprite * sprite = CCScale9Sprite::createWithSpriteFrame(spriteFrame); this->setBackgroundSpriteForState(sprite, state); } @@ -651,7 +651,7 @@ void CCControlButton::ccTouchCancelled(CCTouch *pTouch, CCEvent *pEvent) sendActionsForControlEvents(CCControlEventTouchCancel); } -CCControlButton * CCControlButton::node() +CCControlButton* CCControlButton::create() { CCControlButton *pControlButton = new CCControlButton(); if (pControlButton && pControlButton->init()) @@ -663,4 +663,9 @@ CCControlButton * CCControlButton::node() return NULL; } +CCControlButton* CCControlButton::node() +{ + return CCControlButton::create(); +} + NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.h b/cocos2dx/extensions/CCControlExtension/CCControlButton.h index 39f704889a..b2c1d85c2a 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.h @@ -98,19 +98,19 @@ public: virtual bool init(); virtual bool initWithLabelAndBackgroundSprite(CCNode* label, CCScale9Sprite* backgroundSprite); //@warning: This interface will be deprecated in future. - static CCControlButton* buttonWithLabelAndBackgroundSprite(CCNode* label, CCScale9Sprite* backgroundSprite); + CC_DEPRECATED_ATTRIBUTE static CCControlButton* buttonWithLabelAndBackgroundSprite(CCNode* label, CCScale9Sprite* backgroundSprite); static CCControlButton* create(CCNode* label, CCScale9Sprite* backgroundSprite); virtual bool initWithTitleAndFontNameAndFontSize(std::string title, const char * fontName, float fontSize); //@warning: This interface will be deprecated in future. - static CCControlButton* buttonWithTitleAndFontNameAndFontSize(std::string title, const char * fontName, float fontSize); + CC_DEPRECATED_ATTRIBUTE static CCControlButton* buttonWithTitleAndFontNameAndFontSize(std::string title, const char * fontName, float fontSize); static CCControlButton* create(std::string title, const char * fontName, float fontSize); virtual bool initWithBackgroundSprite(CCScale9Sprite* sprite); //@warning: This interface will be deprecated in future. - static CCControlButton* buttonWithBackgroundSprite(CCScale9Sprite* sprite); + CC_DEPRECATED_ATTRIBUTE static CCControlButton* buttonWithBackgroundSprite(CCScale9Sprite* sprite); static CCControlButton* create(CCScale9Sprite* sprite); @@ -221,7 +221,8 @@ public: */ virtual void setBackgroundSpriteFrameForState(CCSpriteFrame * spriteFrame, CCControlState state); - static CCControlButton * node(); + CC_DEPRECATED_ATTRIBUTE static CCControlButton * node(); + static CCControlButton* create(); }; NS_CC_EXT_END diff --git a/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.h b/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.h index 60fe18d5ee..35ce8b8374 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.h @@ -53,7 +53,7 @@ protected: public: //@warning: This interface will be deprecated in future. - static CCControlColourPicker* colourPicker(); + CC_DEPRECATED_ATTRIBUTE static CCControlColourPicker* colourPicker(); static CCControlColourPicker* create(); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.h b/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.h index aa0f4c51df..c08dd13d6f 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.h @@ -55,7 +55,7 @@ public: virtual ~CCControlHuePicker(); virtual bool initWithTargetAndPos(CCNode* target, CCPoint pos); //@warning: This interface will be deprecated in future. - static CCControlHuePicker* pickerWithTargetAndPos(CCNode* target, CCPoint pos); + CC_DEPRECATED_ATTRIBUTE static CCControlHuePicker* pickerWithTargetAndPos(CCNode* target, CCPoint pos); static CCControlHuePicker* create(CCNode* target, CCPoint pos); protected: void updateSliderPosition(CCPoint location); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.h b/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.h index 8669d51092..e7c13e26bd 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.h @@ -58,7 +58,7 @@ public: virtual bool initWithTargetAndPos(CCNode* target, CCPoint pos); //@warning: This interface will be deprecated in future. - static CCControlSaturationBrightnessPicker* pickerWithTargetAndPos(CCNode* target, CCPoint pos); + CC_DEPRECATED_ATTRIBUTE static CCControlSaturationBrightnessPicker* pickerWithTargetAndPos(CCNode* target, CCPoint pos); static CCControlSaturationBrightnessPicker* create(CCNode* target, CCPoint pos); virtual void updateWithHSV(HSV hsv); virtual void updateDraggerWithHSV(HSV hsv); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSlider.h b/cocos2dx/extensions/CCControlExtension/CCControlSlider.h index 58eb60fc39..d701b5d28c 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSlider.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlSlider.h @@ -77,7 +77,7 @@ public: * thumb image filename. @warning: This interface will be deprecated in future. */ - static CCControlSlider* sliderWithFiles(const char* bgFile, const char* progressFile, const char* thumbFile); + CC_DEPRECATED_ATTRIBUTE static CCControlSlider* sliderWithFiles(const char* bgFile, const char* progressFile, const char* thumbFile); /** * Creates a slider with a given background sprite and a progress bar and a @@ -85,7 +85,7 @@ public: *@warning: This interface will be deprecated in future. * @see initWithBackgroundSprite:progressSprite:thumbMenuItem: */ - static CCControlSlider* sliderWithSprites(CCSprite * backgroundSprite, CCSprite* pogressSprite, CCMenuItem* thumbItem); + CC_DEPRECATED_ATTRIBUTE static CCControlSlider* sliderWithSprites(CCSprite * backgroundSprite, CCSprite* pogressSprite, CCMenuItem* thumbItem); /** diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.h b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.h index 45ba0d7ca7..6c50b1da18 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.h @@ -49,7 +49,7 @@ public: /** Creates a switch with a mask sprite, on/off sprites for on/off states and a thumb sprite. @warning: This interface will be deprecated in future. */ - static CCControlSwitch* switchWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite); + CC_DEPRECATED_ATTRIBUTE static CCControlSwitch* switchWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite); /** Creates a switch with a mask sprite, on/off sprites for on/off states and a thumb sprite. */ static CCControlSwitch* create(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite); @@ -61,7 +61,7 @@ public: /** Creates a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. @warning: This interface will be deprecated in future. */ - static CCControlSwitch* switchWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite, CCLabelTTF* onLabel, CCLabelTTF* offLabel); + CC_DEPRECATED_ATTRIBUTE static CCControlSwitch* switchWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite, CCLabelTTF* onLabel, CCLabelTTF* offLabel); /** Creates a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. */ static CCControlSwitch* create(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite, CCLabelTTF* onLabel, CCLabelTTF* offLabel); diff --git a/cocos2dx/extensions/CCControlExtension/CCMenuPassive.h b/cocos2dx/extensions/CCControlExtension/CCMenuPassive.h index e4beb6036f..ba63cd3ce6 100644 --- a/cocos2dx/extensions/CCControlExtension/CCMenuPassive.h +++ b/cocos2dx/extensions/CCControlExtension/CCMenuPassive.h @@ -20,19 +20,19 @@ public: /** creates an empty CCMenu @warning: This interface will be deprecated in future. */ - static CCMenuPassive* node(); + CC_DEPRECATED_ATTRIBUTE static CCMenuPassive* node(); /** creates a CCMenu with it's items @warning: This interface will be deprecated in future. */ - static CCMenuPassive* menuWithItems(CCNode* item, ...); + CC_DEPRECATED_ATTRIBUTE static CCMenuPassive* menuWithItems(CCNode* item, ...); /** creates a CCMenu with it's item, then use addChild() to add * other items. It is used for script, it can't init with undetermined * number of variables. @warning: This interface will be deprecated in future. */ - static CCMenuPassive* menuWithItem(CCNode* item); + CC_DEPRECATED_ATTRIBUTE static CCMenuPassive* menuWithItem(CCNode* item); /** creates an empty CCMenu */ static CCMenuPassive* create(); diff --git a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp index 52b0639ca8..9913af1eb5 100644 --- a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp @@ -602,7 +602,7 @@ bool CCScale9Sprite::isOpacityModifyRGB() void CCScale9Sprite::setSpriteFrame(CCSpriteFrame * spriteFrame) { - CCSpriteBatchNode * batchnode = CCSpriteBatchNode::batchNodeWithTexture(spriteFrame->getTexture(), 9); + CCSpriteBatchNode * batchnode = CCSpriteBatchNode::createWithTexture(spriteFrame->getTexture(), 9); this->updateWithBatchNode(batchnode, spriteFrame->getRect(), CCRectZero); // Reset insets diff --git a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h index b454a12515..a14f4daece 100644 --- a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h +++ b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h @@ -114,7 +114,7 @@ public: * @see initWithFile:rect:centerRegion: @warning: This interface will be deprecated in future. */ - static CCScale9Sprite* spriteWithFile(const char* file, CCRect rect, CCRect capInsets); + CC_DEPRECATED_ATTRIBUTE static CCScale9Sprite* spriteWithFile(const char* file, CCRect rect, CCRect capInsets); /** * Creates a 9-slice sprite with a texture file, a delimitation zone and @@ -174,7 +174,7 @@ public: * @see initWithFile:capInsets: @warning: This interface will be deprecated in future. */ - static CCScale9Sprite* spriteWithFile(CCRect capInsets, const char* file); + CC_DEPRECATED_ATTRIBUTE static CCScale9Sprite* spriteWithFile(CCRect capInsets, const char* file); /** * Creates a 9-slice sprite with a texture file. The whole texture will be * broken down into a 3×3 grid of equal blocks. @@ -202,7 +202,7 @@ public: * @see initWithFile: @warning: This interface will be deprecated in future. */ - static CCScale9Sprite* spriteWithFile(const char* file); + CC_DEPRECATED_ATTRIBUTE static CCScale9Sprite* spriteWithFile(const char* file); /** * Creates a 9-slice sprite with a texture file. The whole texture will be @@ -233,7 +233,7 @@ public: * @see initWithSpriteFrame:centerRegion: @warning: This interface will be deprecated in future. */ - static CCScale9Sprite* spriteWithSpriteFrame(CCSpriteFrame* spriteFrame, CCRect capInsets); + CC_DEPRECATED_ATTRIBUTE static CCScale9Sprite* spriteWithSpriteFrame(CCSpriteFrame* spriteFrame, CCRect capInsets); /** * Creates a 9-slice sprite with an sprite frame and the centre of its zone. @@ -263,7 +263,7 @@ public: * @see initWithSpriteFrame: @warning: This interface will be deprecated in future. */ - static CCScale9Sprite* spriteWithSpriteFrame(CCSpriteFrame* spriteFrame); + CC_DEPRECATED_ATTRIBUTE static CCScale9Sprite* spriteWithSpriteFrame(CCSpriteFrame* spriteFrame); /** * Creates a 9-slice sprite with an sprite frame. @@ -296,7 +296,7 @@ public: * @see initWithSpriteFrameName:centerRegion: @warning: This interface will be deprecated in future. */ - static CCScale9Sprite* spriteWithSpriteFrameName(const char*spriteFrameName, CCRect capInsets); + CC_DEPRECATED_ATTRIBUTE static CCScale9Sprite* spriteWithSpriteFrameName(const char*spriteFrameName, CCRect capInsets); /** * Creates a 9-slice sprite with an sprite frame name and the centre of its @@ -328,7 +328,7 @@ public: * @see initWithSpriteFrameName: @warning: This interface will be deprecated in future. */ - static CCScale9Sprite* spriteWithSpriteFrameName(const char*spriteFrameName); + CC_DEPRECATED_ATTRIBUTE static CCScale9Sprite* spriteWithSpriteFrameName(const char*spriteFrameName); /** * Creates a 9-slice sprite with an sprite frame name. @@ -350,8 +350,8 @@ public: */ CCScale9Sprite* resizableSpriteWithCapInsets(CCRect capInsets); - - static CCScale9Sprite* node(); + //@warning: This interface will be deprecated in future. + CC_DEPRECATED_ATTRIBUTE static CCScale9Sprite* node(); static CCScale9Sprite* create(); diff --git a/cocos2dx/extensions/CCListView/CCListView.h b/cocos2dx/extensions/CCListView/CCListView.h index 7b848697fc..9764fc7f0c 100644 --- a/cocos2dx/extensions/CCListView/CCListView.h +++ b/cocos2dx/extensions/CCListView/CCListView.h @@ -122,7 +122,7 @@ public: CCListView(void); // @warning: This interface will be deprecated in future. - static CCListView* viewWithMode(CCListViewMode mode); + CC_DEPRECATED_ATTRIBUTE static CCListView* viewWithMode(CCListViewMode mode); static CCListView* create(CCListViewMode mode); diff --git a/cocos2dx/extensions/CCScrollView/CCScrollView.cpp b/cocos2dx/extensions/CCScrollView/CCScrollView.cpp index aa36ab0ab8..e4d2170c45 100644 --- a/cocos2dx/extensions/CCScrollView/CCScrollView.cpp +++ b/cocos2dx/extensions/CCScrollView/CCScrollView.cpp @@ -117,7 +117,7 @@ bool CCScrollView::initWithViewSize(CCSize size, CCNode *container/* = NULL*/) if (!this->m_pContainer) { - m_pContainer = CCLayer::node(); + m_pContainer = CCLayer::create(); } this->setViewSize(size); @@ -231,9 +231,9 @@ void CCScrollView::setContentOffsetInDuration(CCPoint offset, float dt) { CCFiniteTimeAction *scroll, *expire; - scroll = CCMoveTo::actionWithDuration(dt, offset); - expire = CCCallFuncN::actionWithTarget(this, callfuncN_selector(CCScrollView::stoppedAnimatedScroll)); - m_pContainer->runAction(CCSequence::actions(scroll, expire, NULL)); + scroll = CCMoveTo::create(dt, offset); + expire = CCCallFuncN::create(this, callfuncN_selector(CCScrollView::stoppedAnimatedScroll)); + m_pContainer->runAction(CCSequence::create(scroll, expire, NULL)); this->schedule(schedule_selector(CCScrollView::performedAnimatedScroll)); } @@ -296,7 +296,7 @@ void CCScrollView::setZoomScaleInDuration(float s, float dt) if (m_pContainer->getScale() != s) { CCActionTween *scaleAction; - scaleAction = CCActionTween::actionWithDuration(dt, "zoomScale", m_pContainer->getScale(), s); + scaleAction = CCActionTween::create(dt, "zoomScale", m_pContainer->getScale(), s); this->runAction(scaleAction); } } diff --git a/cocos2dx/extensions/CCScrollView/CCScrollView.h b/cocos2dx/extensions/CCScrollView/CCScrollView.h index ef1a8d6f8e..99c997354b 100644 --- a/cocos2dx/extensions/CCScrollView/CCScrollView.h +++ b/cocos2dx/extensions/CCScrollView/CCScrollView.h @@ -71,7 +71,7 @@ public: * @param container parent object * @return autoreleased scroll view object */ - static CCScrollView* viewWithViewSize(CCSize size, CCNode* container = NULL); + CC_DEPRECATED_ATTRIBUTE static CCScrollView* viewWithViewSize(CCSize size, CCNode* container = NULL); /** * Returns an autoreleased scroll view object. @@ -89,7 +89,7 @@ public: * @param container parent object * @return autoreleased scroll view object */ - static CCScrollView* node(); + CC_DEPRECATED_ATTRIBUTE static CCScrollView* node(); /** * Returns an autoreleased scroll view object. diff --git a/cocos2dx/label_nodes/CCLabelAtlas.h b/cocos2dx/label_nodes/CCLabelAtlas.h index a252a6960a..ea31cad5cb 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.h +++ b/cocos2dx/label_nodes/CCLabelAtlas.h @@ -54,13 +54,13 @@ public: /** creates the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas @warning: This interface will be deprecated in future. */ - static CCLabelAtlas * labelWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); + CC_DEPRECATED_ATTRIBUTE static CCLabelAtlas * labelWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); /** creates the CCLabelAtlas with a string and a configuration file @warning: This interface will be deprecated in future. @since v2.0 */ - static CCLabelAtlas* labelWithString(const char *sring, const char *fntFile); + CC_DEPRECATED_ATTRIBUTE static CCLabelAtlas* labelWithString(const char *sring, const char *fntFile); /** creates the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas */ static CCLabelAtlas * create(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); diff --git a/cocos2dx/label_nodes/CCLabelBMFont.h b/cocos2dx/label_nodes/CCLabelBMFont.h index 9fb9182591..193879bb81 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.h +++ b/cocos2dx/label_nodes/CCLabelBMFont.h @@ -106,7 +106,7 @@ public: /** allocates a CCBMFontConfiguration with a FNT file @warning: This interface will be deprecated in future. */ - static CCBMFontConfiguration * configurationWithFNTFile(const char *FNTfile); + CC_DEPRECATED_ATTRIBUTE static CCBMFontConfiguration * configurationWithFNTFile(const char *FNTfile); /** allocates a CCBMFontConfiguration with a FNT file */ static CCBMFontConfiguration * create(const char *FNTfile); @@ -198,14 +198,14 @@ public: /** creates a bitmap font altas with an initial string and the FNT file @warning: This interface will be deprecated in future. */ - static CCLabelBMFont * labelWithString(const char *str, const char *fntFile, float width = kCCLabelAutomaticWidth, CCTextAlignment alignment = kCCTextAlignmentLeft, CCPoint imageOffset = CCPointZero); + CC_DEPRECATED_ATTRIBUTE static CCLabelBMFont * labelWithString(const char *str, const char *fntFile, float width = kCCLabelAutomaticWidth, CCTextAlignment alignment = kCCTextAlignmentLeft, CCPoint imageOffset = CCPointZero); /** creates a bitmap font altas with an initial string and the FNT file */ static CCLabelBMFont * create(const char *str, const char *fntFile, float width = kCCLabelAutomaticWidth, CCTextAlignment alignment = kCCTextAlignmentLeft, CCPoint imageOffset = CCPointZero); /** Creates an label. @warning: This interface will be deprecated in future. */ - static CCLabelBMFont * node(); + CC_DEPRECATED_ATTRIBUTE static CCLabelBMFont * node(); /** Creates an label. */ diff --git a/cocos2dx/label_nodes/CCLabelTTF.h b/cocos2dx/label_nodes/CCLabelTTF.h index 9f5b728b00..ae152031da 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.h +++ b/cocos2dx/label_nodes/CCLabelTTF.h @@ -46,19 +46,19 @@ public: /** creates a CCLabelTTF with a font name and font size in points @warning: This interface will be deprecated in future. */ - static CCLabelTTF * labelWithString(const char *string, const char *fontName, float fontSize); + CC_DEPRECATED_ATTRIBUTE static CCLabelTTF * labelWithString(const char *string, const char *fontName, float fontSize); /** creates a CCLabelTTF from a fontname, horizontal alignment, dimension in points, and font size in points. @warning: This interface will be deprecated in future. @since v1.0 */ - static CCLabelTTF * labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, + CC_DEPRECATED_ATTRIBUTE static CCLabelTTF * labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, const char *fontName, float fontSize); /** creates a CCLabel from a fontname, alignment, dimension in points and font size in points @warning: This interface will be deprecated in future. */ - static CCLabelTTF * labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, + CC_DEPRECATED_ATTRIBUTE static CCLabelTTF * labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize); /** creates a CCLabelTTF with a font name and font size in points*/ diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h index 03bc7e9a9c..48f19439c5 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h @@ -55,7 +55,7 @@ public: bool init(); // @warning: This interface will be deprecated in future. - static CCLayer *node(void); + CC_DEPRECATED_ATTRIBUTE static CCLayer *node(void); /** create one layer */ static CCLayer *create(void); @@ -129,7 +129,7 @@ private: // for the subclass of CCLayer, each has to implement the static "node" method // @warning: This interface will be deprecated in future. #define LAYER_NODE_FUNC(layer) \ - static layer* node() \ + CC_DEPRECATED_ATTRIBUTE static layer* node() \ { \ layer *pRet = new layer(); \ if (pRet && pRet->init()) \ @@ -166,7 +166,7 @@ private: // @warning: This interface will be deprecated in future. #define LAYER_NODE_FUNC_PARAM(layer,__PARAMTYPE__,__PARAM__) \ - static layer* node(__PARAMTYPE__ __PARAM__) \ + CC_DEPRECATED_ATTRIBUTE static layer* node(__PARAMTYPE__ __PARAM__) \ { \ layer *pRet = new layer(); \ if (pRet && pRet->init(__PARAM__)) \ @@ -225,11 +225,11 @@ public: /** creates a CCLayer with color, width and height in Points @warning: This interface will be deprecated in future. */ - static CCLayerColor * layerWithColor(const ccColor4B& color, GLfloat width, GLfloat height); + CC_DEPRECATED_ATTRIBUTE static CCLayerColor * layerWithColor(const ccColor4B& color, GLfloat width, GLfloat height); /** creates a CCLayer with color. Width and height are the window size. @warning: This interface will be deprecated in future. */ - static CCLayerColor * layerWithColor(const ccColor4B& color); + CC_DEPRECATED_ATTRIBUTE static CCLayerColor * layerWithColor(const ccColor4B& color); /** creates a CCLayer with color, width and height in Points */ static CCLayerColor * create(const ccColor4B& color, GLfloat width, GLfloat height); @@ -296,12 +296,12 @@ public: /** Creates a full-screen CCLayer with a gradient between start and end. @warning: This interface will be deprecated in future. */ - static CCLayerGradient* layerWithColor(const ccColor4B& start, const ccColor4B& end); + CC_DEPRECATED_ATTRIBUTE static CCLayerGradient* layerWithColor(const ccColor4B& start, const ccColor4B& end); /** Creates a full-screen CCLayer with a gradient between start and end in the direction of v. @warning: This interface will be deprecated in future. */ - static CCLayerGradient* layerWithColor(const ccColor4B& start, const ccColor4B& end, const CCPoint& v); + CC_DEPRECATED_ATTRIBUTE static CCLayerGradient* layerWithColor(const ccColor4B& start, const ccColor4B& end, const CCPoint& v); /** Creates a full-screen CCLayer with a gradient between start and end. */ static CCLayerGradient* create(const ccColor4B& start, const ccColor4B& end); @@ -355,14 +355,14 @@ public: /** creates a CCLayerMultiplex with one or more layers using a variable argument list. @warning: This interface will be deprecated in future. */ - static CCLayerMultiplex * layerWithLayers(CCLayer* layer, ... ); + CC_DEPRECATED_ATTRIBUTE static CCLayerMultiplex * layerWithLayers(CCLayer* layer, ... ); /** * lua script can not init with undetermined number of variables * so add these functinons to be used with lua. @warning: This interface will be deprecated in future. */ - static CCLayerMultiplex * layerWithLayer(CCLayer* layer); + CC_DEPRECATED_ATTRIBUTE static CCLayerMultiplex * layerWithLayer(CCLayer* layer); /** creates a CCLayerMultiplex with one or more layers using a variable argument list. */ static CCLayerMultiplex * create(CCLayer* layer, ... ); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCScene.h b/cocos2dx/layers_scenes_transitions_nodes/CCScene.h index 143a32be64..d74de75c3e 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCScene.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCScene.h @@ -56,7 +56,7 @@ NS_CC_END // for the subclass of CCScene, each has to implement the static "node" method // @warning: This interface will be deprecated in future. #define SCENE_NODE_FUNC(scene) \ -static scene* node() \ +CC_DEPRECATED_ATTRIBUTE static scene* node() \ { \ scene *pRet = new scene(); \ if (pRet && pRet->init()) \ @@ -74,7 +74,7 @@ static scene* node() \ // @warning: This interface will be deprecated in future. #define SCENE_FUNC_PARAM(__TYPE__,__PARAMTYPE__,__PARAM__) \ - static cocos2d::CCScene* node(__PARAMTYPE__ __PARAM__) \ + CC_DEPRECATED_ATTRIBUTE static cocos2d::CCScene* node(__PARAMTYPE__ __PARAM__) \ { \ cocos2d::CCScene * scene = NULL; \ do \ diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h index d4c4d962ce..fc5fa49d78 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h @@ -36,23 +36,8 @@ NS_CC_BEGIN //c/c++ don't support object creation of using class name //so, all classes need creation method. -// @warning: This interface will be deprecated in future. -// #define DECLEAR_TRANSITIONWITHDURATION(_Type)\ -// static _Type* transitionWithDuration(float t, CCScene* scene); -// -// #define IMPLEMENT_TRANSITIONWITHDURATION(_Type)\ -// _Type* _Type::transitionWithDuration(float t, CCScene* scene)\ -// {\ -// _Type* pScene = new _Type();\ -// if(pScene && pScene->initWithDuration(t, scene)){\ -// pScene->autorelease();\ -// return pScene;}\ -// CC_SAFE_DELETE(pScene);\ -// return NULL;\ -// - #define OLD_TRANSITION_CREATE_FUNC(_Type) \ - static _Type* transitionWithDuration(float t, CCScene* scene) \ + CC_DEPRECATED_ATTRIBUTE static _Type* transitionWithDuration(float t, CCScene* scene) \ { \ _Type* pScene = new _Type(); \ if(pScene && pScene->initWithDuration(t, scene)) \ @@ -129,7 +114,7 @@ public: /** creates a base transition with duration and incoming scene @warning: This interface will be deprecated in future. */ - static CCTransitionScene * transitionWithDuration(float t, CCScene *scene); + CC_DEPRECATED_ATTRIBUTE static CCTransitionScene * transitionWithDuration(float t, CCScene *scene); /** creates a base transition with duration and incoming scene */ static CCTransitionScene * create(float t, CCScene *scene); @@ -165,7 +150,7 @@ public: /** creates a base transition with duration and incoming scene @warning: This interface will be deprecated in future. */ - static CCTransitionSceneOriented * transitionWithDuration(float t,CCScene* scene, tOrientation orientation); + CC_DEPRECATED_ATTRIBUTE static CCTransitionSceneOriented * transitionWithDuration(float t,CCScene* scene, tOrientation orientation); /** creates a base transition with duration and incoming scene */ static CCTransitionSceneOriented * create(float t,CCScene* scene, tOrientation orientation); @@ -378,7 +363,7 @@ public: virtual void onEnter(); // @warning: This interface will be deprecated in future. - static CCTransitionFlipX* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); + CC_DEPRECATED_ATTRIBUTE static CCTransitionFlipX* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); static CCTransitionFlipX* create(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; @@ -395,7 +380,7 @@ public: virtual void onEnter(); //@warning: This interface will be deprecated in future. - static CCTransitionFlipY* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationUpOver); + CC_DEPRECATED_ATTRIBUTE static CCTransitionFlipY* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationUpOver); static CCTransitionFlipY* create(float t, CCScene* s, tOrientation o = kOrientationUpOver); }; @@ -412,7 +397,7 @@ public: virtual void onEnter(); //@warning: This interface will be deprecated in future. - static CCTransitionFlipAngular* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); + CC_DEPRECATED_ATTRIBUTE static CCTransitionFlipAngular* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); static CCTransitionFlipAngular* create(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; @@ -429,7 +414,7 @@ public: virtual void onEnter(); //@warning: This interface will be deprecated in future. - static CCTransitionZoomFlipX* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); + CC_DEPRECATED_ATTRIBUTE static CCTransitionZoomFlipX* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); static CCTransitionZoomFlipX* create(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; @@ -446,7 +431,7 @@ public: virtual void onEnter(); //@warning: This interface will be deprecated in future. - static CCTransitionZoomFlipY* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationUpOver); + CC_DEPRECATED_ATTRIBUTE static CCTransitionZoomFlipY* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationUpOver); static CCTransitionZoomFlipY* create(float t, CCScene* s, tOrientation o = kOrientationUpOver); }; @@ -463,7 +448,7 @@ public: virtual void onEnter(); //@warning: This interface will be deprecated in future. - static CCTransitionZoomFlipAngular* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); + CC_DEPRECATED_ATTRIBUTE static CCTransitionZoomFlipAngular* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); static CCTransitionZoomFlipAngular* create(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; @@ -484,7 +469,7 @@ public: * Example: FadeTransition::transitionWithDuration(2, scene, ccc3(255,0,0); // red color @warning: This interface will be deprecated in future. */ - static CCTransitionFade* transitionWithDuration(float duration,CCScene* scene, const ccColor3B& color = ccBLACK); + CC_DEPRECATED_ATTRIBUTE static CCTransitionFade* transitionWithDuration(float duration,CCScene* scene, const ccColor3B& color = ccBLACK); /** creates the transition with a duration and with an RGB color * Example: FadeTransition::create(2, scene, ccc3(255,0,0); // red color diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h index b002c77e18..7dc3333ecf 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h @@ -56,7 +56,7 @@ public: * scene is being turned from left over the outgoing scene. @warning: This interface will be deprecated in future. */ - static CCTransitionPageTurn* transitionWithDuration(float t,CCScene* scene,bool backwards); + CC_DEPRECATED_ATTRIBUTE static CCTransitionPageTurn* transitionWithDuration(float t,CCScene* scene,bool backwards); /** * Creates a base transition with duration and incoming scene. diff --git a/cocos2dx/menu_nodes/CCMenu.h b/cocos2dx/menu_nodes/CCMenu.h index 9790568f6d..4952c5095d 100644 --- a/cocos2dx/menu_nodes/CCMenu.h +++ b/cocos2dx/menu_nodes/CCMenu.h @@ -66,24 +66,24 @@ public: /** creates an empty CCMenu @warning: This interface will be deprecated in future. */ - static CCMenu* node(); + CC_DEPRECATED_ATTRIBUTE static CCMenu* node(); /** creates a CCMenu with it's items @warning: This interface will be deprecated in future. */ - static CCMenu* menuWithItems(CCMenuItem* item, ...); + CC_DEPRECATED_ATTRIBUTE static CCMenu* menuWithItems(CCMenuItem* item, ...); /** creates a CCMenu with a NSArray of CCMenuItem objects @warning: This interface will be deprecated in future. */ - static CCMenu* menuWithArray(CCArray* pArrayOfItems); + CC_DEPRECATED_ATTRIBUTE static CCMenu* menuWithArray(CCArray* pArrayOfItems); /** creates a CCMenu with it's item, then use addChild() to add * other items. It is used for script, it can't init with undetermined * number of variables. @warning: This interface will be deprecated in future. */ - static CCMenu* menuWithItem(CCMenuItem* item); + CC_DEPRECATED_ATTRIBUTE static CCMenu* menuWithItem(CCMenuItem* item); /** creates an empty CCMenu */ static CCMenu* create(); diff --git a/cocos2dx/menu_nodes/CCMenuItem.h b/cocos2dx/menu_nodes/CCMenuItem.h index 5c37532b24..75fa229504 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.h +++ b/cocos2dx/menu_nodes/CCMenuItem.h @@ -63,7 +63,7 @@ public: /** Creates a CCMenuItem with a target/selector @warning: This interface will be deprecated in future. */ - static CCMenuItem * itemWithTarget(CCObject *rec, SEL_MenuHandler selector); + CC_DEPRECATED_ATTRIBUTE static CCMenuItem * itemWithTarget(CCObject *rec, SEL_MenuHandler selector); /** Creates a CCMenuItem with a target/selector */ static CCMenuItem * create(CCObject *rec, SEL_MenuHandler selector); /** Initializes a CCMenuItem with a target/selector */ @@ -116,11 +116,11 @@ public: /** creates a CCMenuItemLabel with a Label, target and selector @warning: This interface will be deprecated in future. */ - static CCMenuItemLabel * itemWithLabel(CCNode*label, CCObject* target, SEL_MenuHandler selector); + CC_DEPRECATED_ATTRIBUTE static CCMenuItemLabel * itemWithLabel(CCNode*label, CCObject* target, SEL_MenuHandler selector); /** creates a CCMenuItemLabel with a Label. Target and selector will be nill @warning: This interface will be deprecated in future. */ - static CCMenuItemLabel* itemWithLabel(CCNode *label); + CC_DEPRECATED_ATTRIBUTE static CCMenuItemLabel* itemWithLabel(CCNode *label); /** creates a CCMenuItemLabel with a Label, target and selector */ static CCMenuItemLabel * create(CCNode*label, CCObject* target, SEL_MenuHandler selector); @@ -162,11 +162,11 @@ public: /** creates a menu item from a string and atlas with a target/selector @warning: This interface will be deprecated in future. */ - static CCMenuItemAtlasFont* itemWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap); + CC_DEPRECATED_ATTRIBUTE static CCMenuItemAtlasFont* itemWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap); /** creates a menu item from a string and atlas. Use it with MenuItemToggle @warning: This interface will be deprecated in future. */ - static CCMenuItemAtlasFont* itemWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, CCObject* target, SEL_MenuHandler selector); + CC_DEPRECATED_ATTRIBUTE static CCMenuItemAtlasFont* itemWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, CCObject* target, SEL_MenuHandler selector); /** creates a menu item from a string and atlas with a target/selector */ static CCMenuItemAtlasFont* create(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap); @@ -195,11 +195,11 @@ public: /** creates a menu item from a string without target/selector. To be used with CCMenuItemToggle @warning: This interface will be deprecated in future. */ - static CCMenuItemFont * itemWithString(const char *value); + CC_DEPRECATED_ATTRIBUTE static CCMenuItemFont * itemWithString(const char *value); /** creates a menu item from a string with a target/selector @warning: This interface will be deprecated in future. */ - static CCMenuItemFont * itemWithString(const char *value, CCObject* target, SEL_MenuHandler selector); + CC_DEPRECATED_ATTRIBUTE static CCMenuItemFont * itemWithString(const char *value, CCObject* target, SEL_MenuHandler selector); /** creates a menu item from a string without target/selector. To be used with CCMenuItemToggle */ static CCMenuItemFont * create(const char *value); @@ -258,15 +258,15 @@ public: /** creates a menu item with a normal, selected and disabled image @warning: This interface will be deprecated in future. */ - static CCMenuItemSprite * itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite = NULL); + CC_DEPRECATED_ATTRIBUTE static CCMenuItemSprite * itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite = NULL); /** creates a menu item with a normal and selected image with target/selector @warning: This interface will be deprecated in future. */ - static CCMenuItemSprite * itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCObject* target, SEL_MenuHandler selector); + CC_DEPRECATED_ATTRIBUTE static CCMenuItemSprite * itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCObject* target, SEL_MenuHandler selector); /** creates a menu item with a normal,selected and disabled image with target/selector @warning: This interface will be deprecated in future. */ - static CCMenuItemSprite * itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, CCObject* target, SEL_MenuHandler selector); + CC_DEPRECATED_ATTRIBUTE static CCMenuItemSprite * itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, CCObject* target, SEL_MenuHandler selector); /** creates a menu item with a normal, selected and disabled image*/ static CCMenuItemSprite * create(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite = NULL); @@ -312,19 +312,19 @@ public: /** creates a menu item with a normal and selected image @warning: This interface will be deprecated in future. */ - static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage); + CC_DEPRECATED_ATTRIBUTE static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage); /** creates a menu item with a normal,selected and disabled image @warning: This interface will be deprecated in future. */ - static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage); + CC_DEPRECATED_ATTRIBUTE static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage); /** creates a menu item with a normal and selected image with target/selector @warning: This interface will be deprecated in future. */ - static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage, CCObject* target, SEL_MenuHandler selector); + CC_DEPRECATED_ATTRIBUTE static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage, CCObject* target, SEL_MenuHandler selector); /** creates a menu item with a normal,selected and disabled image with target/selector @warning: This interface will be deprecated in future. */ - static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector); + CC_DEPRECATED_ATTRIBUTE static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector); /** creates a menu item with a normal and selected image*/ static CCMenuItemImage* create(const char *normalImage, const char *selectedImage); @@ -347,7 +347,7 @@ public: /** Creates an CCMenuItemImage. @warning: This interface will be deprecated in future. */ - static CCMenuItemImage* node(); + CC_DEPRECATED_ATTRIBUTE static CCMenuItemImage* node(); /** Creates an CCMenuItemImage. */ @@ -381,7 +381,7 @@ public: /** creates a menu item from a list of items with a target/selector @warning: This interface will be deprecated in future. */ - static CCMenuItemToggle* itemWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...); + CC_DEPRECATED_ATTRIBUTE static CCMenuItemToggle* itemWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...); /** creates a menu item from a list of items with a target/selector */ static CCMenuItemToggle* create(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...); @@ -393,7 +393,7 @@ public: /** creates a menu item with a item @warning: This interface will be deprecated in future. */ - static CCMenuItemToggle* itemWithItem(CCMenuItem *item); + CC_DEPRECATED_ATTRIBUTE static CCMenuItemToggle* itemWithItem(CCMenuItem *item); /** creates a menu item with a item */ static CCMenuItemToggle* create(CCMenuItem *item); diff --git a/cocos2dx/misc_nodes/CCMotionStreak.h b/cocos2dx/misc_nodes/CCMotionStreak.h index 80af657693..44d8ba515c 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.h +++ b/cocos2dx/misc_nodes/CCMotionStreak.h @@ -44,11 +44,11 @@ public: /** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture filename @warning: This interface will be deprecated in future. */ - static CCMotionStreak* streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, const char* path); + CC_DEPRECATED_ATTRIBUTE static CCMotionStreak* streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, const char* path); /** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture @warning: This interface will be deprecated in future. */ - static CCMotionStreak* streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, CCTexture2D* texture); + CC_DEPRECATED_ATTRIBUTE static CCMotionStreak* streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, CCTexture2D* texture); /** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture filename */ static CCMotionStreak* create(float fade, float minSeg, float stroke, ccColor3B color, const char* path); diff --git a/cocos2dx/misc_nodes/CCProgressTimer.h b/cocos2dx/misc_nodes/CCProgressTimer.h index 553373123e..aa4e6d1e7a 100644 --- a/cocos2dx/misc_nodes/CCProgressTimer.h +++ b/cocos2dx/misc_nodes/CCProgressTimer.h @@ -85,7 +85,7 @@ public: /** Creates a progress timer with the sprite as the shape the timer goes through @warning: This interface will be deprecated in future. */ - static CCProgressTimer* progressWithSprite(CCSprite* sp); + CC_DEPRECATED_ATTRIBUTE static CCProgressTimer* progressWithSprite(CCSprite* sp); /** Creates a progress timer with the sprite as the shape the timer goes through */ static CCProgressTimer* create(CCSprite* sp); protected: diff --git a/cocos2dx/misc_nodes/CCRenderTexture.h b/cocos2dx/misc_nodes/CCRenderTexture.h index 79f8a3f50b..523e05ba5b 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.h +++ b/cocos2dx/misc_nodes/CCRenderTexture.h @@ -61,17 +61,17 @@ public: /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format @warning: This interface will be deprecated in future. */ - static CCRenderTexture * renderTextureWithWidthAndHeight(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat); + CC_DEPRECATED_ATTRIBUTE static CCRenderTexture * renderTextureWithWidthAndHeight(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat); /** creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid @warning: This interface will be deprecated in future. */ - static CCRenderTexture * renderTextureWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat); + CC_DEPRECATED_ATTRIBUTE static CCRenderTexture * renderTextureWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat); /** creates a RenderTexture object with width and height in Points, pixel format is RGBA8888 @warning: This interface will be deprecated in future. */ - static CCRenderTexture * renderTextureWithWidthAndHeight(int w, int h); + CC_DEPRECATED_ATTRIBUTE static CCRenderTexture * renderTextureWithWidthAndHeight(int w, int h); /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format*/ static CCRenderTexture * create(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat); diff --git a/cocos2dx/particle_nodes/CCParticleBatchNode.h b/cocos2dx/particle_nodes/CCParticleBatchNode.h index 26ab2bdd13..a06908a429 100644 --- a/cocos2dx/particle_nodes/CCParticleBatchNode.h +++ b/cocos2dx/particle_nodes/CCParticleBatchNode.h @@ -68,12 +68,12 @@ public: /** initializes the particle system with CCTexture2D, a capacity of particles, which particle system to use @warning: This interface will be deprecated in future. */ - static CCParticleBatchNode* batchNodeWithTexture(CCTexture2D *tex, unsigned int capacity = kCCParticleDefaultCapacity); + CC_DEPRECATED_ATTRIBUTE static CCParticleBatchNode* batchNodeWithTexture(CCTexture2D *tex, unsigned int capacity = kCCParticleDefaultCapacity); /** initializes the particle system with the name of a file on disk (for a list of supported formats look at the CCTexture2D class), a capacity of particles @warning: This interface will be deprecated in future. */ - static CCParticleBatchNode* batchNodeWithFile(const char* fileImage, unsigned int capacity = kCCParticleDefaultCapacity); + CC_DEPRECATED_ATTRIBUTE static CCParticleBatchNode* batchNodeWithFile(const char* fileImage, unsigned int capacity = kCCParticleDefaultCapacity); /** initializes the particle system with CCTexture2D, a capacity of particles, which particle system to use */ static CCParticleBatchNode* createWithTexture(CCTexture2D *tex, unsigned int capacity = kCCParticleDefaultCapacity); diff --git a/cocos2dx/particle_nodes/CCParticleSystem.h b/cocos2dx/particle_nodes/CCParticleSystem.h index 4268295282..cc08b707bf 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.h +++ b/cocos2dx/particle_nodes/CCParticleSystem.h @@ -368,7 +368,7 @@ public: @warning: This interface will be deprecated in future. @since v0.99.3 */ - static CCParticleSystem * particleWithFile(const char *plistFile); + CC_DEPRECATED_ATTRIBUTE static CCParticleSystem * particleWithFile(const char *plistFile); /** creates an initializes a CCParticleSystem from a plist file. This plist files can be creted manually or with Particle Designer: diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.h b/cocos2dx/particle_nodes/CCParticleSystemQuad.h index cbe8d42fd6..18fe5aa004 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.h +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.h @@ -65,7 +65,7 @@ public: This plist files can be creted manually or with Particle Designer: @warning: This interface will be deprecated in future. */ - static CCParticleSystemQuad * particleWithFile(const char *plistFile); + CC_DEPRECATED_ATTRIBUTE static CCParticleSystemQuad * particleWithFile(const char *plistFile); /** creates an initializes a CCParticleSystemQuad from a plist file. This plist files can be creted manually or with Particle Designer: @@ -102,7 +102,7 @@ public: void listenBackToForeground(CCObject *obj); //@warning: This interface will be deprecated in future. - static CCParticleSystemQuad * node(); + CC_DEPRECATED_ATTRIBUTE static CCParticleSystemQuad * node(); static CCParticleSystemQuad * create(); private: diff --git a/cocos2dx/platform/CCPlatformMacros.h b/cocos2dx/platform/CCPlatformMacros.h index bd2f263048..a929c1fe56 100644 --- a/cocos2dx/platform/CCPlatformMacros.h +++ b/cocos2dx/platform/CCPlatformMacros.h @@ -197,5 +197,15 @@ public: virtual void set##funName(varType var) \ #define LUALOG(format, ...) cocos2d::CCLog(format, ##__VA_ARGS__) #endif // Lua engine debug +/* + * only certain compilers support __attribute__((deprecated)) + */ +#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) + #define CC_DEPRECATED_ATTRIBUTE __attribute__((deprecated)) +#elif _MSC_VER >= 1400 //vs 2005 or higher +#define CC_DEPRECATED_ATTRIBUTE __declspec(deprecated) +#else + #define CC_DEPRECATED_ATTRIBUTE +#endif #endif // __CC_PLATFORM_MACROS_H__ diff --git a/cocos2dx/proj.win32/cocos2d-win32.vcproj b/cocos2dx/proj.win32/cocos2d-win32.vcproj index dfdc58248b..39c79ae412 100755 --- a/cocos2dx/proj.win32/cocos2d-win32.vcproj +++ b/cocos2dx/proj.win32/cocos2d-win32.vcproj @@ -43,7 +43,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="..;..\platform\win32;..\platform\third_party\win32\iconv;..\platform\third_party\win32\zlib;..\platform\third_party\win32\libpng;..\platform\third_party\win32\libjpeg;..\platform\third_party\win32\libtiff;..\platform\third_party\win32\libxml2;..\platform\third_party\win32\pthread;..\platform\third_party\win32\OGLES;..\include;..\kazmath\include" - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -51,7 +51,7 @@ WarningLevel="3" Detect64BitPortabilityProblems="false" DebugInformationFormat="4" - DisableSpecificWarnings="4996;4267" + DisableSpecificWarnings="4267;4251;4244" /> Disabled ..;..\platform\win32;..\platform\third_party\win32\iconv;..\platform\third_party\win32\zlib;..\platform\third_party\win32\libpng;..\platform\third_party\win32\libtiff;..\platform\third_party\win32\libjpeg;..\platform\third_party\win32\libxml2;..\platform\third_party\win32\pthread;..\platform\third_party\win32\OGLES;..\include;..\kazmath\include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USRDLL;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USRDLL;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -66,7 +66,7 @@ Level3 EditAndContinue - 4251;4996;4267;%(DisableSpecificWarnings) + 4267;4251;4244;%(DisableSpecificWarnings) if not exist "$(OutDir)" mkdir "$(OutDir)" @@ -98,13 +98,13 @@ xcopy /Y /Q "$(SolutionDir)cocos2dx\platform\third_party\win32\libraries\*.*" "$ ..;..\platform\win32;..\platform\third_party\win32\iconv;..\platform\third_party\win32\zlib;..\platform\third_party\win32\libpng;..\platform\third_party\win32\libtiff;..\platform\third_party\win32\libjpeg;..\platform\third_party\win32\libxml2;..\platform\third_party\win32\pthread;..\platform\third_party\win32\OGLES;..\include;..\kazmath\include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USRDLL;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USRDLL;COCOS2DXWIN32_EXPORTS;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL Level3 ProgramDatabase - 4251;4996;4267;%(DisableSpecificWarnings) + 4267;4251;4244;%(DisableSpecificWarnings) if not exist "$(OutDir)" mkdir "$(OutDir)" diff --git a/cocos2dx/sprite_nodes/CCAnimation.h b/cocos2dx/sprite_nodes/CCAnimation.h index dbf3ffc7ed..a18c7418a8 100644 --- a/cocos2dx/sprite_nodes/CCAnimation.h +++ b/cocos2dx/sprite_nodes/CCAnimation.h @@ -87,20 +87,20 @@ public: @warning: This interface will be deprecated in future. @since v0.99.5 */ - static CCAnimation* animation(void); + CC_DEPRECATED_ATTRIBUTE static CCAnimation* animation(void); /* Creates an animation with an array of CCSpriteFrame and a delay between frames in seconds. The frames will be added with one "delay unit". @warning: This interface will be deprecated in future. @since v0.99.5 */ - static CCAnimation* animationWithSpriteFrames(CCArray* arrayOfSpriteFrameNames, float delay = 0.0f); + CC_DEPRECATED_ATTRIBUTE static CCAnimation* animationWithSpriteFrames(CCArray* arrayOfSpriteFrameNames, float delay = 0.0f); /* Creates an animation with an array of CCAnimationFrame, the delay per units in seconds and and how many times it should be executed. @warning: This interface will be deprecated in future. @since v2.0 */ - static CCAnimation* animationWithAnimationFrames(CCArray *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops); + CC_DEPRECATED_ATTRIBUTE static CCAnimation* animationWithAnimationFrames(CCArray *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops); /** Creates an animation @since v0.99.5 diff --git a/cocos2dx/sprite_nodes/CCSprite.h b/cocos2dx/sprite_nodes/CCSprite.h index 8964775736..42a8eaab4f 100644 --- a/cocos2dx/sprite_nodes/CCSprite.h +++ b/cocos2dx/sprite_nodes/CCSprite.h @@ -125,13 +125,13 @@ public: The offset will be (0,0). @warning: This interface will be deprecated in future. */ - static CCSprite* spriteWithTexture(CCTexture2D *pTexture); + CC_DEPRECATED_ATTRIBUTE static CCSprite* spriteWithTexture(CCTexture2D *pTexture); /** Creates an sprite with a texture and a rect. The offset will be (0,0). @warning: This interface will be deprecated in future. */ - static CCSprite* spriteWithTexture(CCTexture2D *pTexture, const CCRect& rect); + CC_DEPRECATED_ATTRIBUTE static CCSprite* spriteWithTexture(CCTexture2D *pTexture, const CCRect& rect); /** Creates an sprite with a texture. The rect used will be the size of the texture. @@ -147,7 +147,7 @@ public: /** Creates an sprite with an sprite frame. @warning: This interface will be deprecated in future. */ - static CCSprite* spriteWithSpriteFrame(CCSpriteFrame *pSpriteFrame); + CC_DEPRECATED_ATTRIBUTE static CCSprite* spriteWithSpriteFrame(CCSpriteFrame *pSpriteFrame); /** Creates an sprite with an sprite frame name. An CCSpriteFrame will be fetched from the CCSpriteFrameCache by name. @@ -155,7 +155,7 @@ public: @warning: This interface will be deprecated in future. @since v0.9 */ - static CCSprite* spriteWithSpriteFrameName(const char *pszSpriteFrameName); + CC_DEPRECATED_ATTRIBUTE static CCSprite* spriteWithSpriteFrameName(const char *pszSpriteFrameName); /** Creates an sprite with an sprite frame. */ static CCSprite* createWithSpriteFrame(CCSpriteFrame *pSpriteFrame); @@ -172,13 +172,13 @@ public: @warning: This interface will be deprecated in future. The offset will be (0,0). */ - static CCSprite* spriteWithFile(const char *pszFileName); + CC_DEPRECATED_ATTRIBUTE static CCSprite* spriteWithFile(const char *pszFileName); /** Creates an sprite with an image filename and a rect. The offset will be (0,0). @warning: This interface will be deprecated in future. */ - static CCSprite* spriteWithFile(const char *pszFileName, const CCRect& rect); + CC_DEPRECATED_ATTRIBUTE static CCSprite* spriteWithFile(const char *pszFileName, const CCRect& rect); /** Creates an sprite with an image filename. The rect used will be the size of the image. @@ -194,7 +194,7 @@ public: /** Creates an sprite. @warning: This interface will be deprecated in future. */ - static CCSprite* node(); + CC_DEPRECATED_ATTRIBUTE static CCSprite* node(); /** Creates an sprite. */ static CCSprite* create(); diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.h b/cocos2dx/sprite_nodes/CCSpriteBatchNode.h index a686d2646c..94e643f935 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.h +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.h @@ -80,14 +80,14 @@ public: The capacity will be increased in 33% in runtime if it run out of space. @warning: This interface will be deprecated in future. */ - static CCSpriteBatchNode* batchNodeWithTexture(CCTexture2D* tex, unsigned int capacity = kDefaultSpriteBatchCapacity); + CC_DEPRECATED_ATTRIBUTE static CCSpriteBatchNode* batchNodeWithTexture(CCTexture2D* tex, unsigned int capacity = kDefaultSpriteBatchCapacity); /** creates a CCSpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and capacity of children. The capacity will be increased in 33% in runtime if it run out of space. The file will be loaded using the TextureMgr. @warning: This interface will be deprecated in future. */ - static CCSpriteBatchNode* batchNodeWithFile(const char* fileImage, unsigned int capacity = kDefaultSpriteBatchCapacity); + CC_DEPRECATED_ATTRIBUTE static CCSpriteBatchNode* batchNodeWithFile(const char* fileImage, unsigned int capacity = kDefaultSpriteBatchCapacity); /** creates a CCSpriteBatchNode with a texture2d and capacity of children. The capacity will be increased in 33% in runtime if it run out of space. diff --git a/cocos2dx/sprite_nodes/CCSpriteFrame.h b/cocos2dx/sprite_nodes/CCSpriteFrame.h index 965d63ea1d..3448ceb63c 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrame.h +++ b/cocos2dx/sprite_nodes/CCSpriteFrame.h @@ -94,25 +94,25 @@ public: @warning: This interface will be deprecated in future. It is assumed that the frame was not trimmed. */ - static CCSpriteFrame* frameWithTexture(CCTexture2D* pobTexture, const CCRect& rect); + CC_DEPRECATED_ATTRIBUTE static CCSpriteFrame* frameWithTexture(CCTexture2D* pobTexture, const CCRect& rect); /** Create a CCSpriteFrame with a texture filename, rect in points. It is assumed that the frame was not trimmed. @warning: This interface will be deprecated in future. */ - static CCSpriteFrame* frameWithTextureFilename(const char* filename, const CCRect& rect); + CC_DEPRECATED_ATTRIBUTE static CCSpriteFrame* frameWithTextureFilename(const char* filename, const CCRect& rect); /** Create a CCSpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. The originalSize is the size in points of the frame before being trimmed. @warning: This interface will be deprecated in future. */ - static CCSpriteFrame* frameWithTexture(CCTexture2D* pobTexture, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize); + CC_DEPRECATED_ATTRIBUTE static CCSpriteFrame* frameWithTexture(CCTexture2D* pobTexture, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize); /** Create a CCSpriteFrame with a texture filename, rect, rotated, offset and originalSize in pixels. The originalSize is the size in pixels of the frame before being trimmed. @warning: This interface will be deprecated in future. */ - static CCSpriteFrame* frameWithTextureFilename(const char* filename, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize); + CC_DEPRECATED_ATTRIBUTE static CCSpriteFrame* frameWithTextureFilename(const char* filename, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize); /** Create a CCSpriteFrame with a texture, rect in points. It is assumed that the frame was not trimmed. diff --git a/cocos2dx/support/zip_support/ioapi.cpp b/cocos2dx/support/zip_support/ioapi.cpp index 581ef56b23..3e75d86386 100644 --- a/cocos2dx/support/zip_support/ioapi.cpp +++ b/cocos2dx/support/zip_support/ioapi.cpp @@ -10,13 +10,8 @@ */ -#if (defined(_WIN32)) - #define _CRT_SECURE_NO_WARNINGS -#endif - #include "ioapi.h" - namespace cocos2d { voidpf call_zopen64 (const zlib_filefunc64_32_def* pfilefunc,const void*filename,int mode) diff --git a/cocos2dx/textures/CCTexturePVR.cpp b/cocos2dx/textures/CCTexturePVR.cpp index 7121532bd8..d59b8afb5d 100755 --- a/cocos2dx/textures/CCTexturePVR.cpp +++ b/cocos2dx/textures/CCTexturePVR.cpp @@ -338,7 +338,7 @@ bool CCTexturePVR::createGLTexture() GLenum internalFormat = tableFormats[m_uTableFormatIndex][kCCInternalOpenGLInternalFormat]; GLenum format = tableFormats[m_uTableFormatIndex][kCCInternalOpenGLFormat]; GLenum type = tableFormats[m_uTableFormatIndex][kCCInternalOpenGLType]; - bool compressed = tableFormats[m_uTableFormatIndex][kCCInternalCompressedImage]; + bool compressed = (0 == tableFormats[m_uTableFormatIndex][kCCInternalCompressedImage]) ? false : true; // Generate textures with mipmaps for (unsigned int i = 0; i < m_uNumberOfMipmaps; ++i) diff --git a/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h b/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h index d243e8b0bb..b7110c0a1a 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h +++ b/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h @@ -51,7 +51,7 @@ public: CCParallaxNode(); virtual ~CCParallaxNode(); //@warning: This interface will be deprecated in future. - static CCParallaxNode * node(); + CC_DEPRECATED_ATTRIBUTE static CCParallaxNode * node(); static CCParallaxNode * create(); virtual void addChild(CCNode * child, unsigned int z, const CCPoint& parallaxRatio, const CCPoint& positionOffset); // super methods diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h index 63dc1194de..5d7d64e9c7 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h @@ -86,7 +86,7 @@ public: /** creates a CCTMXLayer with an tileset info, a layer info and a map info @warning: This interface will be deprecated in future. */ - static CCTMXLayer * layerWithTilesetInfo(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo); + CC_DEPRECATED_ATTRIBUTE static CCTMXLayer * layerWithTilesetInfo(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo); /** creates a CCTMXLayer with an tileset info, a layer info and a map info */ static CCTMXLayer * create(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo); diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h index 4b1536ef56..12002b413e 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h @@ -120,12 +120,12 @@ public: /** creates a TMX Tiled Map with a TMX file. @warning: This interface will be deprecated in future. */ - static CCTMXTiledMap* tiledMapWithTMXFile(const char *tmxFile); + CC_DEPRECATED_ATTRIBUTE static CCTMXTiledMap* tiledMapWithTMXFile(const char *tmxFile); /** initializes a TMX Tiled Map with a TMX formatted XML string and a path to TMX resources @warning: This interface will be deprecated in future. */ - static CCTMXTiledMap* tiledMapWithXML(const char* tmxString, const char* resourcePath); + CC_DEPRECATED_ATTRIBUTE static CCTMXTiledMap* tiledMapWithXML(const char* tmxString, const char* resourcePath); /** creates a TMX Tiled Map with a TMX file.*/ static CCTMXTiledMap* create(const char *tmxFile); diff --git a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h index e48e00cb15..cfe84655a0 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h @@ -59,7 +59,7 @@ public: The tile file will be loaded using the TextureMgr. @warning: This interface will be deprecated in future. */ - static CCTileMapAtlas * tileMapAtlasWithTileFile(const char *tile, const char *mapFile, int tileWidth, int tileHeight); + CC_DEPRECATED_ATTRIBUTE static CCTileMapAtlas * tileMapAtlasWithTileFile(const char *tile, const char *mapFile, int tileWidth, int tileHeight); /** creates a CCTileMap with a tile file (atlas) with a map file and the width and height of each tile in points. The tile file will be loaded using the TextureMgr. diff --git a/tests/proj.win32/test.win32.vcproj b/tests/proj.win32/test.win32.vcproj index e484186f32..3def1b8e35 100644 --- a/tests/proj.win32/test.win32.vcproj +++ b/tests/proj.win32/test.win32.vcproj @@ -42,14 +42,14 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=""$(SolutionDir)cocos2dx";"$(SolutionDir)cocos2dx\include";"$(SolutionDir)cocos2dx\kazmath\include";"$(SolutionDir)cocos2dx\platform\win32";"$(SolutionDir)cocos2dx\platform\third_party\win32";"$(SolutionDir)cocos2dx\platform\third_party\win32\OGLES";"$(SolutionDir)";"$(SolutionDir)chipmunk\include\chipmunk";"$(SolutionDir)CocosDenshion\include";..\tests;.." - PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES" + PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" UsePrecompiledHeader="0" WarningLevel="3" DebugInformationFormat="4" - DisableSpecificWarnings="4244;4996" + DisableSpecificWarnings="4267;4251;4244" /> Disabled .;..;..\tests;..\..;..\..\chipmunk\include\chipmunk;..\..\cocos2dx;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) + WIN32;_DEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -64,7 +64,7 @@ Level3 EditAndContinue - 4251;4244;4996;%(DisableSpecificWarnings) + 4267;4251;4244;%(DisableSpecificWarnings) opengl32.lib;glew32.lib;libcocos2d.lib;libBox2d.lib;libchipmunk.lib;libcurl_imp.lib;libCocosDenshion.lib;%(AdditionalDependencies) @@ -84,14 +84,14 @@ MaxSpeed true .;..;..\tests;..\..;..\..\chipmunk\include\chipmunk;..\..\cocos2dx;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;%(PreprocessorDefinitions) + WIN32;NDEBUG;_WINDOWS;_USE_MATH_DEFINES;GL_GLEXT_PROTOTYPES;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL true Level3 ProgramDatabase - 4251;4244;4996;%(DisableSpecificWarnings) + 4267;4251;4244;%(DisableSpecificWarnings) opengl32.lib;glew32.lib;libcocos2d.lib;libBox2d.lib;libchipmunk.lib;libcurl_imp.lib;libCocosDenshion.lib;%(AdditionalDependencies) diff --git a/tests/tests/EffectsTest/EffectsTest.h b/tests/tests/EffectsTest/EffectsTest.h index 60b04f04b3..4e2bbc77f6 100644 --- a/tests/tests/EffectsTest/EffectsTest.h +++ b/tests/tests/EffectsTest/EffectsTest.h @@ -28,8 +28,6 @@ public: void newScene(); - // @warning: This interface will be deprecated in future. - //static TextLayer* node(); static TextLayer* create(); }; diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h index 0234353a2a..5ce2bb5df7 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/ButtonTest/ButtonTestLayer.h @@ -12,7 +12,7 @@ class ButtonTestLayer , public cocos2d::extension::CCBSelectorResolver { public: - CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(ButtonTestLayer, node); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(ButtonTestLayer, create); ButtonTestLayer(); virtual ~ButtonTestLayer(); diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp index 9c33fe7b97..8faedee59f 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp @@ -58,13 +58,13 @@ void HelloCocosBuilderLayer::openTest(const char * pCCBFileName, const char * pC transitionColor.g = 0; transitionColor.b = 0; - CCDirector::sharedDirector()->pushScene(CCTransitionFade::transitionWithDuration(0.5f, scene, transitionColor)); + CCDirector::sharedDirector()->pushScene(CCTransitionFade::create(0.5f, scene, transitionColor)); } void HelloCocosBuilderLayer::onNodeLoaded(cocos2d::CCNode * pNode, cocos2d::extension::CCNodeLoader * pNodeLoader) { - CCRotateBy * ccRotateBy = CCRotateBy::actionWithDuration(0.5f, 10); - CCRepeatForever * ccRepeatForever = CCRepeatForever::actionWithAction(ccRotateBy); + CCRotateBy * ccRotateBy = CCRotateBy::create(0.5f, 10); + CCRepeatForever * ccRepeatForever = CCRepeatForever::create(ccRotateBy); this->mBurstSprite->runAction(ccRepeatForever); } diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h index b5bc30e368..0bdfa37c95 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.h @@ -24,7 +24,7 @@ class HelloCocosBuilderLayer , public cocos2d::extension::CCNodeLoaderListener { public: - CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(HelloCocosBuilderLayer, node); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(HelloCocosBuilderLayer, create); HelloCocosBuilderLayer(); virtual ~HelloCocosBuilderLayer(); diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/LabelTest/LabelTestLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/LabelTest/LabelTestLayer.h index 8d72c06299..f57f8c0328 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/LabelTest/LabelTestLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/LabelTest/LabelTestLayer.h @@ -6,7 +6,7 @@ class LabelTestLayer : public cocos2d::CCLayer { public: - CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(LabelTestLayer, node); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(LabelTestLayer, create); }; #endif \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h index 160fedd979..3d4fa7c01e 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/MenuTest/MenuTestLayer.h @@ -12,7 +12,7 @@ class MenuTestLayer , public cocos2d::extension::CCBMemberVariableAssigner { public: - CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(MenuTestLayer, node); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(MenuTestLayer, create); MenuTestLayer(); virtual ~MenuTestLayer(); diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ParticleSystemTest/ParticleSystemTestLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/ParticleSystemTest/ParticleSystemTestLayer.h index f876b09456..49630f5f14 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/ParticleSystemTest/ParticleSystemTestLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/ParticleSystemTest/ParticleSystemTestLayer.h @@ -6,7 +6,7 @@ class ParticleSystemTestLayer : public cocos2d::CCLayer { public: - CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(ParticleSystemTestLayer, node); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(ParticleSystemTestLayer, create); }; #endif \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/ScrollViewTest/ScrollViewTestLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/ScrollViewTest/ScrollViewTestLayer.h index 836850de64..685e3dc2cb 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/ScrollViewTest/ScrollViewTestLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/ScrollViewTest/ScrollViewTestLayer.h @@ -6,7 +6,7 @@ class ScrollViewTestLayer : public cocos2d::CCLayer { public: - CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(ScrollViewTestLayer, node); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(ScrollViewTestLayer, create); }; #endif \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/SpriteTest/SpriteTestLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/SpriteTest/SpriteTestLayer.h index 11bce158c1..6b7cf5f68f 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/SpriteTest/SpriteTestLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/SpriteTest/SpriteTestLayer.h @@ -6,7 +6,7 @@ class SpriteTestLayer : public cocos2d::CCLayer { public: - CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(SpriteTestLayer, node); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(SpriteTestLayer, create); }; #endif \ No newline at end of file diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h index 4c9acfa9c6..3ec4f490b5 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/TestHeader/TestHeaderLayer.h @@ -10,7 +10,7 @@ class TestHeaderLayer , public cocos2d::extension::CCBSelectorResolver { public: - CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(TestHeaderLayer, node); + CCB_STATIC_NEW_AUTORELEASE_OBJECT_WITH_INIT_METHOD(TestHeaderLayer, create); virtual cocos2d::SEL_MenuHandler onResolveCCBCCMenuItemSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); virtual cocos2d::extension::SEL_CCControlHandler onResolveCCBCCControlSelector(cocos2d::CCObject * pTarget, cocos2d::CCString * pSelectorName); From 411ae21ceee04d609c0c1b3ca82762dff73524e0 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 20 Jun 2012 11:59:35 +0800 Subject: [PATCH 228/257] fixed #1336: Updated lua bindings. --- .../LuaCocos2d.cpp.REMOVED.git-id | 2 +- tools/tolua++/CCActionGrid.pkg | 4 +- tools/tolua++/CCTransition.pkg | 60 +++++++++---------- 3 files changed, 33 insertions(+), 33 deletions(-) diff --git a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index e4aa0c4526..c6e86f7d02 100644 --- a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -c13eb2b1ec38e28d1537f0671e700e1af00dd31e \ No newline at end of file +22628adfacd66254448f16f59cb8bd2af00a92ac \ No newline at end of file diff --git a/tools/tolua++/CCActionGrid.pkg b/tools/tolua++/CCActionGrid.pkg index 59baa85db2..d10e154ac9 100644 --- a/tools/tolua++/CCActionGrid.pkg +++ b/tools/tolua++/CCActionGrid.pkg @@ -32,10 +32,10 @@ class CCDeccelAmplitude : public CCActionInterval class CCStopGrid : public CCActionInstant { - static CCStopGrid* action(void); + static CCStopGrid* create(void); }; class CCReuseGrid : public CCActionInstant { - static CCReuseGrid* actionWithTimes(int times); + static CCReuseGrid* create(int times); }; diff --git a/tools/tolua++/CCTransition.pkg b/tools/tolua++/CCTransition.pkg index b3c82a0434..8ca9834ba3 100644 --- a/tools/tolua++/CCTransition.pkg +++ b/tools/tolua++/CCTransition.pkg @@ -12,152 +12,152 @@ typedef enum { class CCTransitionSceneOriented : public CCScene { - static CCTransitionSceneOriented* transitionWithDuration(float t, CCScene* scene, tOrientation o); + static CCTransitionSceneOriented* create(float t, CCScene* scene, tOrientation o); }; class CCTransitionRotoZoom : public CCScene { - static CCTransitionRotoZoom* transitionWithDuration(float t, CCScene* scene); + static CCTransitionRotoZoom* create(float t, CCScene* scene); }; class CCTransitionJumpZoom : public CCScene { - static CCTransitionJumpZoom* transitionWithDuration(float t, CCScene* scene); + static CCTransitionJumpZoom* create(float t, CCScene* scene); }; class CCTransitionMoveInL : public CCScene { - static CCTransitionMoveInL* transitionWithDuration(float t, CCScene* scene); + static CCTransitionMoveInL* create(float t, CCScene* scene); }; class CCTransitionMoveInR : public CCScene { - static CCTransitionMoveInR* transitionWithDuration(float t, CCScene* scene); + static CCTransitionMoveInR* create(float t, CCScene* scene); }; class CCTransitionMoveInT : public CCScene { - static CCTransitionMoveInT* transitionWithDuration(float t, CCScene* scene); + static CCTransitionMoveInT* create(float t, CCScene* scene); }; class CCTransitionMoveInB : public CCScene { - static CCTransitionMoveInB* transitionWithDuration(float t, CCScene* scene); + static CCTransitionMoveInB* create(float t, CCScene* scene); }; class CCTransitionSlideInL : public CCScene { - static CCTransitionSlideInL* transitionWithDuration(float t, CCScene* scene); + static CCTransitionSlideInL* create(float t, CCScene* scene); }; class CCTransitionSlideInR : public CCScene { - static CCTransitionSlideInR* transitionWithDuration(float t, CCScene* scene); + static CCTransitionSlideInR* create(float t, CCScene* scene); }; class CCTransitionSlideInB : public CCScene { - static CCTransitionSlideInB* transitionWithDuration(float t, CCScene* scene); + static CCTransitionSlideInB* create(float t, CCScene* scene); }; class CCTransitionSlideInT : public CCScene { - static CCTransitionSlideInT* transitionWithDuration(float t, CCScene* scene); + static CCTransitionSlideInT* create(float t, CCScene* scene); }; class CCTransitionShrinkGrow : public CCScene { - static CCTransitionShrinkGrow* transitionWithDuration(float t, CCScene* scene); + static CCTransitionShrinkGrow* create(float t, CCScene* scene); }; class CCTransitionFlipX : public CCScene { - static CCTransitionFlipX* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionFlipX* create(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; class CCTransitionFlipY : public CCScene { - static CCTransitionFlipY* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationUpOver); + static CCTransitionFlipY* create(float t, CCScene* s, tOrientation o = kOrientationUpOver); }; class CCTransitionFlipAngular : public CCScene { - static CCTransitionFlipAngular* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionFlipAngular* create(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; class CCTransitionZoomFlipX : public CCScene { - static CCTransitionZoomFlipX* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionZoomFlipX* create(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; class CCTransitionZoomFlipY : public CCScene { - static CCTransitionZoomFlipY* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationUpOver); + static CCTransitionZoomFlipY* create(float t, CCScene* s, tOrientation o = kOrientationUpOver); }; class CCTransitionZoomFlipAngular : public CCScene { - static CCTransitionZoomFlipAngular* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); + static CCTransitionZoomFlipAngular* create(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; class CCTransitionFade : public CCScene { - static CCTransitionFade* transitionWithDuration(float duration,CCScene* scene, ccColor3B color = ccBLACK); + static CCTransitionFade* create(float duration,CCScene* scene, ccColor3B color = ccBLACK); }; class CCTransitionCrossFade : public CCScene { - static CCTransitionCrossFade* transitionWithDuration(float t, CCScene* scene); + static CCTransitionCrossFade* create(float t, CCScene* scene); }; class CCTransitionTurnOffTiles : public CCScene { - static CCTransitionTurnOffTiles* transitionWithDuration(float t, CCScene* scene); + static CCTransitionTurnOffTiles* create(float t, CCScene* scene); }; class CCTransitionSplitCols : public CCScene { - static CCTransitionSplitCols* transitionWithDuration(float t, CCScene* scene); + static CCTransitionSplitCols* create(float t, CCScene* scene); }; class CCTransitionSplitRows : public CCScene { - static CCTransitionSplitRows* transitionWithDuration(float t, CCScene* scene); + static CCTransitionSplitRows* create(float t, CCScene* scene); }; class CCTransitionFadeTR : public CCScene { - static CCTransitionFadeTR* transitionWithDuration(float t, CCScene* scene); + static CCTransitionFadeTR* create(float t, CCScene* scene); }; class CCTransitionFadeBL : public CCScene { - static CCTransitionFadeBL* transitionWithDuration(float t, CCScene* scene); + static CCTransitionFadeBL* create(float t, CCScene* scene); }; class CCTransitionFadeUp : public CCScene { - static CCTransitionFadeUp* transitionWithDuration(float t, CCScene* scene); + static CCTransitionFadeUp* create(float t, CCScene* scene); }; class CCTransitionFadeDown : public CCScene { - static CCTransitionFadeDown* transitionWithDuration(float t, CCScene* scene); + static CCTransitionFadeDown* create(float t, CCScene* scene); }; /* class CCTransitionRadialCCW : public CCScene { - static CCTransitionRadialCCW* transitionWithDuration(float t, CCScene* scene); + static CCTransitionRadialCCW* create(float t, CCScene* scene); }; class CCTransitionRadialCW : public CCScene { - static CCTransitionRadialCW* transitionWithDuration(float t, CCScene* scene); + static CCTransitionRadialCW* create(float t, CCScene* scene); }; */ class CCTransitionPageTurn : public CCScene { CCActionInterval* actionWithSize(ccGridSize vector); - static CCTransitionPageTurn* transitionWithDuration(float t,CCScene* scene,bool backwards); + static CCTransitionPageTurn* create(float t,CCScene* scene,bool backwards); }; From d3d3288e094dac1f7d6f04acc9c8878cc4836c45 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 20 Jun 2012 12:03:50 +0800 Subject: [PATCH 229/257] fixed #1336: Updated CCScene.h. --- cocos2dx/layers_scenes_transitions_nodes/CCScene.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCScene.h b/cocos2dx/layers_scenes_transitions_nodes/CCScene.h index d74de75c3e..933a32862a 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCScene.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCScene.h @@ -47,7 +47,7 @@ public: CCScene(); virtual ~CCScene(); bool init(); - static CCScene *node(void); + CC_DEPRECATED_ATTRIBUTE static CCScene *node(void); static CCScene *create(void); }; From 2af75ecd65886a5e5f28d6a7651240ea3417299c Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 20 Jun 2012 12:08:34 +0800 Subject: [PATCH 230/257] fixed #1336: HelloCocosBuilder/HelloCocosBuilderLayer.cpp --- .../HelloCocosBuilder/HelloCocosBuilderLayer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp index 8faedee59f..f625e0578d 100644 --- a/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp +++ b/tests/tests/ExtensionsTest/CocosBuilderTest/HelloCocosBuilder/HelloCocosBuilderLayer.cpp @@ -47,7 +47,7 @@ void HelloCocosBuilderLayer::openTest(const char * pCCBFileName, const char * pC this->mTestTitleLabelTTF->setString(pCCBFileName); - CCScene * scene = CCScene::node(); + CCScene * scene = CCScene::create(); if(node != NULL) { scene->addChild(node); } From f748b8726852bfb7009ebb47a15d99961b94bbf3 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 20 Jun 2012 13:56:09 +0800 Subject: [PATCH 231/257] fixed #1336: Updated HelloWorldScene.cpp --- HelloWorld/Classes/HelloWorldScene.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HelloWorld/Classes/HelloWorldScene.cpp b/HelloWorld/Classes/HelloWorldScene.cpp index 6c9581a9c8..890c3b0af1 100644 --- a/HelloWorld/Classes/HelloWorldScene.cpp +++ b/HelloWorld/Classes/HelloWorldScene.cpp @@ -60,7 +60,7 @@ bool HelloWorld::init() this->addChild(pLabel, 1); // add "HelloWorld" splash screen" - CCSprite* pSprite = CCSprite::spriteWithFile("HelloWorld.png"); + CCSprite* pSprite = CCSprite::create("HelloWorld.png"); // position the sprite on the center of the screen pSprite->setPosition( ccp(size.width/2, size.height/2) ); From 24e3ec7499584d1ed9a4e7d42cd9c3c2f56be0d1 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 20 Jun 2012 14:31:36 +0800 Subject: [PATCH 232/257] fixed #1336: Updated comment information for deprecated apis. --- cocos2dx/actions/CCAction.h | 6 +- cocos2dx/actions/CCActionCamera.h | 2 +- cocos2dx/actions/CCActionCatmullRom.h | 10 +-- cocos2dx/actions/CCActionEase.h | 44 ++++++------- cocos2dx/actions/CCActionGrid.h | 16 ++--- cocos2dx/actions/CCActionGrid3D.h | 18 ++--- cocos2dx/actions/CCActionInstant.h | 20 +++--- cocos2dx/actions/CCActionInterval.h | 66 +++++++++---------- cocos2dx/actions/CCActionPageTurn3D.h | 2 +- cocos2dx/actions/CCActionProgressTimer.h | 4 +- cocos2dx/actions/CCActionTiledGrid.h | 26 ++++---- cocos2dx/actions/CCActionTween.h | 2 +- cocos2dx/base_nodes/CCAtlasNode.h | 2 +- cocos2dx/base_nodes/CCNode.h | 2 +- cocos2dx/cocoa/CCArray.h | 14 ++-- cocos2dx/cocoa/CCDictionary.h | 8 +-- cocos2dx/cocoa/CCInteger.h | 2 +- cocos2dx/cocoa/CCString.h | 8 +-- cocos2dx/effects/CCGrid.h | 4 +- .../CCControlExtension/CCControlButton.h | 6 +- .../CCControlColourPicker.h | 2 +- .../CCControlExtension/CCControlHuePicker.h | 2 +- .../CCControlSaturationBrightnessPicker.h | 2 +- .../CCControlExtension/CCControlSlider.h | 4 +- .../CCControlExtension/CCControlSwitch.h | 4 +- .../CCControlExtension/CCMenuPassive.h | 6 +- .../CCControlExtension/CCScale9Sprite.h | 18 ++--- cocos2dx/extensions/CCListView/CCListView.h | 2 +- .../extensions/CCScrollView/CCScrollView.h | 4 +- cocos2dx/label_nodes/CCLabelAtlas.h | 4 +- cocos2dx/label_nodes/CCLabelBMFont.h | 6 +- cocos2dx/label_nodes/CCLabelTTF.h | 6 +- .../layers_scenes_transitions_nodes/CCLayer.h | 24 +++---- .../layers_scenes_transitions_nodes/CCScene.h | 4 +- .../CCTransition.h | 18 ++--- .../CCTransitionPageTurn.h | 2 +- cocos2dx/menu_nodes/CCMenu.h | 8 +-- cocos2dx/menu_nodes/CCMenuItem.h | 34 +++++----- cocos2dx/misc_nodes/CCMotionStreak.h | 4 +- cocos2dx/misc_nodes/CCProgressTimer.h | 2 +- cocos2dx/misc_nodes/CCRenderTexture.h | 6 +- cocos2dx/particle_nodes/CCParticleBatchNode.h | 4 +- cocos2dx/particle_nodes/CCParticleSystem.h | 2 +- .../particle_nodes/CCParticleSystemQuad.h | 4 +- cocos2dx/sprite_nodes/CCAnimation.h | 6 +- cocos2dx/sprite_nodes/CCSprite.h | 14 ++-- cocos2dx/sprite_nodes/CCSpriteBatchNode.h | 4 +- cocos2dx/sprite_nodes/CCSpriteFrame.h | 8 +-- .../tileMap_parallax_nodes/CCParallaxNode.h | 2 +- cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h | 2 +- .../tileMap_parallax_nodes/CCTMXTiledMap.h | 4 +- .../tileMap_parallax_nodes/CCTileMapAtlas.h | 2 +- 52 files changed, 238 insertions(+), 238 deletions(-) diff --git a/cocos2dx/actions/CCAction.h b/cocos2dx/actions/CCAction.h index 02723c1735..3aec80e1f9 100644 --- a/cocos2dx/actions/CCAction.h +++ b/cocos2dx/actions/CCAction.h @@ -93,7 +93,7 @@ public: public: /** Allocates and initializes the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCAction* action(); @@ -180,7 +180,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSpeed* actionWithAction(CCActionInterval *pAction, float fSpeed); @@ -229,7 +229,7 @@ public: public: /** creates the action with a set boundary, It will work with no boundary if @param rect is equal to CCRectZero. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCFollow* actionWithTarget(CCNode *pFollowedNode, const CCRect& rect = CCRectZero); /** creates the action with a set boundary, diff --git a/cocos2dx/actions/CCActionCamera.h b/cocos2dx/actions/CCActionCamera.h index 9c2e9cb5a0..fd117dc199 100644 --- a/cocos2dx/actions/CCActionCamera.h +++ b/cocos2dx/actions/CCActionCamera.h @@ -88,7 +88,7 @@ public: {} ~CCOrbitCamera(){} /** creates a CCOrbitCamera action with radius, delta-radius, z, deltaZ, x, deltaX - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCOrbitCamera* actionWithDuration(float t, float radius, float deltaRadius, float angleZ, float deltaAngleZ, float angleX, float deltaAngleX); diff --git a/cocos2dx/actions/CCActionCatmullRom.h b/cocos2dx/actions/CCActionCatmullRom.h index ae62c6ff7f..9ca20396ef 100644 --- a/cocos2dx/actions/CCActionCatmullRom.h +++ b/cocos2dx/actions/CCActionCatmullRom.h @@ -50,7 +50,7 @@ class CC_DLL CCPointArray : public CCNode { public: /** creates and initializes a Points array with capacity - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCPointArray* arrayWithCapacity(unsigned int capacity); @@ -108,7 +108,7 @@ class CC_DLL CCCardinalSplineTo : public CCActionInterval { public: /** creates an action with a Cardinal Spline array of points and tension - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCCardinalSplineTo* actionWithDuration(float duration, CCPointArray* points, float tension); @@ -151,7 +151,7 @@ class CC_DLL CCCardinalSplineBy : public CCCardinalSplineTo { public: /** creates an action with a Cardinal Spline array of points and tension - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCCardinalSplineBy* actionWithDuration(float duration, CCPointArray* points, float tension); @@ -175,7 +175,7 @@ class CC_DLL CCCatmullRomTo : public CCCardinalSplineTo { public: /** creates an action with a Cardinal Spline array of points and tension - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCCatmullRomTo* actionWithDuration(float dt, CCPointArray* points); @@ -194,7 +194,7 @@ class CC_DLL CCCatmullRomBy : public CCCardinalSplineBy { public: /** creates an action with a Cardinal Spline array of points and tension - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCCatmullRomBy* actionWithDuration(float dt, CCPointArray* points); diff --git a/cocos2dx/actions/CCActionEase.h b/cocos2dx/actions/CCActionEase.h index 9946643f86..fa6292231b 100644 --- a/cocos2dx/actions/CCActionEase.h +++ b/cocos2dx/actions/CCActionEase.h @@ -52,7 +52,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCActionEase* actionWithAction(CCActionInterval *pAction); @@ -84,7 +84,7 @@ public: public: /** Creates the action with the inner action and the rate parameter - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCEaseRateAction* actionWithAction(CCActionInterval* pAction, float fRate); @@ -106,7 +106,7 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); public: /** Creates the action with the inner action and the rate parameter - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCEaseIn* actionWithAction(CCActionInterval* pAction, float fRate); @@ -126,7 +126,7 @@ public: public: /** Creates the action with the inner action and the rate parameter - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCEaseOut* actionWithAction(CCActionInterval* pAction, float fRate); @@ -146,7 +146,7 @@ public: public: /** Creates the action with the inner action and the rate parameter - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCEaseInOut* actionWithAction(CCActionInterval* pAction, float fRate); @@ -166,7 +166,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCEaseExponentialIn* actionWithAction(CCActionInterval* pAction); /** creates the action */ @@ -185,7 +185,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCEaseExponentialOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ @@ -204,7 +204,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCEaseExponentialInOut* actionWithAction(CCActionInterval* pAction); @@ -224,7 +224,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCEaseSineIn* actionWithAction(CCActionInterval* pAction); /** creates the action */ @@ -243,7 +243,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCEaseSineOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ @@ -262,7 +262,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCEaseSineInOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ @@ -289,7 +289,7 @@ public: public: /** Creates the action with the inner action and the period in radians (default is 0.3) - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCEaseElastic* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); /** Creates the action with the inner action and the period in radians (default is 0.3) */ @@ -312,7 +312,7 @@ public: public: /** Creates the action with the inner action and the period in radians (default is 0.3) - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCEaseElasticIn* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); /** Creates the action with the inner action and the period in radians (default is 0.3) */ @@ -333,7 +333,7 @@ public: public: /** Creates the action with the inner action and the period in radians (default is 0.3) - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCEaseElasticOut* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); @@ -355,7 +355,7 @@ public: public: /** Creates the action with the inner action and the period in radians (default is 0.3) - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCEaseElasticInOut* actionWithAction(CCActionInterval *pAction, float fPeriod = 0.3f); @@ -376,7 +376,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCEaseBounce* actionWithAction(CCActionInterval* pAction); /** creates the action */ @@ -397,7 +397,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCEaseBounceIn* actionWithAction(CCActionInterval* pAction); /** creates the action */ @@ -418,7 +418,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCEaseBounceOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ @@ -439,7 +439,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCEaseBounceInOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ @@ -460,7 +460,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCEaseBackIn* actionWithAction(CCActionInterval* pAction); /** creates the action */ @@ -481,7 +481,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCEaseBackOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ @@ -502,7 +502,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCEaseBackInOut* actionWithAction(CCActionInterval* pAction); /** creates the action */ diff --git a/cocos2dx/actions/CCActionGrid.h b/cocos2dx/actions/CCActionGrid.h index 675d18adce..da0e012a25 100644 --- a/cocos2dx/actions/CCActionGrid.h +++ b/cocos2dx/actions/CCActionGrid.h @@ -47,7 +47,7 @@ public: public: /** creates the action with size and duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCGridAction* actionWithSize(const ccGridSize& gridSize, float duration); /** creates the action with size and duration */ @@ -74,7 +74,7 @@ public: public: /** creates the action with size and duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCGrid3DAction* actionWithSize(const ccGridSize& gridSize, float duration); /** creates the action with size and duration */ @@ -97,7 +97,7 @@ public: public: /** creates the action with size and duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCTiledGrid3DAction* actionWithSize(const ccGridSize& gridSize, float duration); /** creates the action with size and duration */ @@ -123,7 +123,7 @@ public: public: /** creates the action with an inner action that has the amplitude property, and a duration time - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCAccelDeccelAmplitude* actionWithAction(CCAction *pAction, float duration); /** creates the action with an inner action that has the amplitude property, and a duration time */ @@ -153,7 +153,7 @@ public: public: /** creates the action with an inner action that has the amplitude property, and a duration time - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCAccelAmplitude* actionWithAction(CCAction *pAction, float duration); /** creates the action with an inner action that has the amplitude property, and a duration time */ @@ -182,7 +182,7 @@ public: public: /** creates the action with an inner action that has the amplitude property, and a duration time - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCDeccelAmplitude* actionWithAction(CCAction *pAction, float duration); /** creates the action with an inner action that has the amplitude property, and a duration time */ @@ -205,7 +205,7 @@ public: public: /** Allocates and initializes the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCStopGrid* action(void); /** Allocates and initializes the action */ @@ -223,7 +223,7 @@ public: public: /** creates an action with the number of times that the current grid will be reused - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCReuseGrid* actionWithTimes(int times); /** creates an action with the number of times that the current grid will be reused */ diff --git a/cocos2dx/actions/CCActionGrid3D.h b/cocos2dx/actions/CCActionGrid3D.h index c8d36bc4ca..62107a0ed6 100644 --- a/cocos2dx/actions/CCActionGrid3D.h +++ b/cocos2dx/actions/CCActionGrid3D.h @@ -48,7 +48,7 @@ public: public: /** create the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCWaves3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); /** create the action */ @@ -71,7 +71,7 @@ public: public: /** creates the action with duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCFlipX3D* actionWithDuration(float duration); /** creates the action with duration */ @@ -87,7 +87,7 @@ public: public: /** creates the action with duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCFlipY3D* actionWithDuration(float duration); /** creates the action with duration */ @@ -113,7 +113,7 @@ public: public: /** creates the action with center position, radius, a grid size and duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCLens3D* actionWithPosition(const CCPoint& pos, float r, const ccGridSize& gridSize, float duration); /** creates the action with center position, radius, a grid size and duration */ @@ -151,7 +151,7 @@ public: public: /** creates the action with radius, number of waves, amplitude, a grid size and duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCRipple3D* actionWithPosition(const CCPoint& pos, float r, int wav, float amp, const ccGridSize& gridSize, float duration); @@ -178,7 +178,7 @@ public: public: /** creates the action with a range, shake Z vertices, a grid and duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCShaky3D* actionWithRange(int range, bool shakeZ, const ccGridSize& gridSize, float duration); /** creates the action with a range, shake Z vertices, a grid and duration */ @@ -205,7 +205,7 @@ public: public: /** creates the action with amplitude, a grid and duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCLiquid* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); /** creates the action with amplitude, a grid and duration */ @@ -234,7 +234,7 @@ public: public: /** initializes the action with amplitude, horizontal sin, vertical sin, a grid and duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCWaves* actionWithWaves(int wav, float amp, bool h, bool v, const ccGridSize& gridSize, float duration); @@ -273,7 +273,7 @@ public: public: /** creates the action with center position, number of twirls, amplitude, a grid size and duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCTwirl* actionWithPosition(CCPoint pos, int t, float amp, const ccGridSize& gridSize, float duration); diff --git a/cocos2dx/actions/CCActionInstant.h b/cocos2dx/actions/CCActionInstant.h index bedd94cd76..5ec5abc8c6 100644 --- a/cocos2dx/actions/CCActionInstant.h +++ b/cocos2dx/actions/CCActionInstant.h @@ -64,7 +64,7 @@ public: public: //override static method /** Allocates and initializes the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCShow * action(); @@ -89,7 +89,7 @@ public: public: //override static method /** Allocates and initializes the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCHide * action(); @@ -110,7 +110,7 @@ public: public: //override static method /** Allocates and initializes the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCToggleVisibility * action(); @@ -131,7 +131,7 @@ public: virtual ~CCFlipX(){} /** create the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCFlipX * actionWithFlipX(bool x); @@ -162,7 +162,7 @@ public: virtual ~CCFlipY(){} /** create the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCFlipY * actionWithFlipY(bool y); @@ -188,7 +188,7 @@ public: CCPlace(){} virtual ~CCPlace(){} /** creates a Place action with a position - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCPlace * actionWithPosition(const CCPoint& pos); /** creates a Place action with a position */ @@ -217,7 +217,7 @@ public: CC_SAFE_RELEASE(m_pSelectorTarget); } /** creates the action with the callback - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. typedef void (CCObject::*SEL_CallFunc)(); */ CC_DEPRECATED_ATTRIBUTE static CCCallFunc * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFunc selector); @@ -277,7 +277,7 @@ public: CCCallFuncN(){} virtual ~CCCallFuncN(){} /** creates the action with the callback - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. typedef void (CCObject::*SEL_CallFuncN)(CCNode*); */ CC_DEPRECATED_ATTRIBUTE static CCCallFuncN * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncN selector); @@ -307,7 +307,7 @@ class CC_DLL CCCallFuncND : public CCCallFuncN public: /** creates the action with the callback and the data to pass as an argument - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCCallFuncND * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncND selector, void* d); @@ -336,7 +336,7 @@ public: CCCallFuncO(); virtual ~CCCallFuncO(); /** creates the action with the callback - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. typedef void (CCObject::*SEL_CallFuncO)(CCObject*); */ CC_DEPRECATED_ATTRIBUTE static CCCallFuncO * actionWithTarget(CCObject* pSelectorTarget, SEL_CallFuncO selector, CCObject* pObject); diff --git a/cocos2dx/actions/CCActionInterval.h b/cocos2dx/actions/CCActionInterval.h index 339794cb5d..4bc4ead98e 100644 --- a/cocos2dx/actions/CCActionInterval.h +++ b/cocos2dx/actions/CCActionInterval.h @@ -73,7 +73,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCActionInterval* actionWithDuration(float d); @@ -108,15 +108,15 @@ public: public: /** helper constructor to create an array of sequenceable actions - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...); /** helper contructor to create an array of sequenceable actions given an array - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCFiniteTimeAction* actionWithArray(CCArray *arrayOfActions); /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSequence* actionOneTwo(CCFiniteTimeAction *pActionOne, CCFiniteTimeAction *pActionTwo); @@ -168,7 +168,7 @@ public: public: /** creates a CCRepeat action. Times is an unsigned integer between 1 and pow(2,30) - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCRepeat* actionWithAction(CCFiniteTimeAction *pAction, unsigned int times); @@ -220,7 +220,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCRepeatForever* actionWithAction(CCActionInterval *pAction); /** creates the action */ @@ -248,17 +248,17 @@ public: public: /** helper constructor to create an array of spawned actions - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCFiniteTimeAction* actions(CCFiniteTimeAction *pAction1, ...); /** helper contructor to create an array of spawned actions given an array - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCFiniteTimeAction* actionWithArray(CCArray *arrayOfActions); /** creates the Spawn action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSpawn* actionOneTwo(CCFiniteTimeAction *pAction1, CCFiniteTimeAction *pAction2); @@ -292,7 +292,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCRotateTo* actionWithDuration(float duration, float fDeltaAngle); /** creates the action */ @@ -318,7 +318,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCRotateBy* actionWithDuration(float duration, float fDeltaAngle); /** creates the action */ @@ -342,7 +342,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMoveTo* actionWithDuration(float duration, const CCPoint& position); /** creates the action */ @@ -369,7 +369,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMoveBy* actionWithDuration(float duration, const CCPoint& position); /** creates the action */ @@ -390,7 +390,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSkewTo* actionWithDuration(float t, float sx, float sy); @@ -419,7 +419,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSkewBy* actionWithDuration(float t, float deltaSkewX, float deltaSkewY); /** creates the action */ @@ -441,7 +441,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCJumpBy* actionWithDuration(float duration, const CCPoint& position, float height, unsigned int jumps); /** creates the action */ @@ -463,7 +463,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCJumpTo* actionWithDuration(float duration, const CCPoint& position, float height, int jumps); /** creates the action */ @@ -496,7 +496,7 @@ public: public: /** creates the action with a duration and a bezier configuration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCBezierBy* actionWithDuration(float t, const ccBezierConfig& c); /** creates the action with a duration and a bezier configuration */ @@ -517,7 +517,7 @@ public: public: /** creates the action with a duration and a bezier configuration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCBezierTo* actionWithDuration(float t, const ccBezierConfig& c); @@ -543,12 +543,12 @@ public: public: /** creates the action with the same scale factor for X and Y - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCScaleTo* actionWithDuration(float duration, float s); /** creates the action with and X factor and a Y factor - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCScaleTo* actionWithDuration(float duration, float sx, float sy); @@ -579,12 +579,12 @@ public: public: /** creates the action with the same scale factor for X and Y - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCScaleBy* actionWithDuration(float duration, float s); /** creates the action with and X factor and a Y factor - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCScaleBy* actionWithDuration(float duration, float sx, float sy); @@ -609,7 +609,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCBlink* actionWithDuration(float duration, unsigned int uBlinks); /** creates the action */ @@ -630,7 +630,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCFadeIn* actionWithDuration(float d); /** creates the action */ @@ -649,7 +649,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCFadeOut* actionWithDuration(float d); @@ -672,7 +672,7 @@ public: public: /** creates an action with duration and opacity - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCFadeTo* actionWithDuration(float duration, GLubyte opacity); /** creates an action with duration and opacity */ @@ -698,7 +698,7 @@ public: public: /** creates an action with duration and color - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCTintTo* actionWithDuration(float duration, GLubyte red, GLubyte green, GLubyte blue); /** creates an action with duration and color */ @@ -724,7 +724,7 @@ public: public: /** creates an action with duration and color - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCTintBy* actionWithDuration(float duration, GLshort deltaRed, GLshort deltaGreen, GLshort deltaBlue); /** creates an action with duration and color */ @@ -750,7 +750,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCDelayTime* actionWithDuration(float d); @@ -782,7 +782,7 @@ public: public: /** creates the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCReverseTime* actionWithAction(CCFiniteTimeAction *pAction); /** creates the action */ @@ -811,7 +811,7 @@ public: public: /** creates the action with an Animation and will restore the original frame when the animation is over - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCAnimate* actionWithAnimation(CCAnimation *pAnimation); /** creates the action with an Animation and will restore the original frame when the animation is over */ @@ -833,7 +833,7 @@ public: CCTargetedAction(); virtual ~CCTargetedAction(); /** Create an action with the specified action and forced target - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCTargetedAction* actionWithTarget(CCNode* pTarget, CCFiniteTimeAction* pAction); /** Create an action with the specified action and forced target */ diff --git a/cocos2dx/actions/CCActionPageTurn3D.h b/cocos2dx/actions/CCActionPageTurn3D.h index ce675c5473..9f718f0438 100644 --- a/cocos2dx/actions/CCActionPageTurn3D.h +++ b/cocos2dx/actions/CCActionPageTurn3D.h @@ -44,7 +44,7 @@ public: public: /** create the action - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCPageTurn3D* actionWithSize(const ccGridSize& gridSize, float time); /** create the action */ diff --git a/cocos2dx/actions/CCActionProgressTimer.h b/cocos2dx/actions/CCActionProgressTimer.h index d1130b9e15..0d8629a9d8 100644 --- a/cocos2dx/actions/CCActionProgressTimer.h +++ b/cocos2dx/actions/CCActionProgressTimer.h @@ -45,7 +45,7 @@ public: public: /** Creates and initializes with a duration and a percent - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCProgressTo* actionWithDuration(float duration, float fPercent); /** Creates and initializes with a duration and a percent */ @@ -72,7 +72,7 @@ public: public: /** Creates and initializes the action with a duration, a "from" percentage and a "to" percentage - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCProgressFromTo* actionWithDuration(float duration, float fFromPercentage, float fToPercentage); /** Creates and initializes the action with a duration, a "from" percentage and a "to" percentage */ diff --git a/cocos2dx/actions/CCActionTiledGrid.h b/cocos2dx/actions/CCActionTiledGrid.h index c075b284fe..aae71d3bf2 100644 --- a/cocos2dx/actions/CCActionTiledGrid.h +++ b/cocos2dx/actions/CCActionTiledGrid.h @@ -41,7 +41,7 @@ public: public: /** creates the action with a range, whether or not to shake Z vertices, a grid size, and duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCShakyTiles3D* actionWithRange(int nRange, bool bShakeZ, const ccGridSize& gridSize, float duration); @@ -66,7 +66,7 @@ public: public: /** creates the action with a range, whether of not to shatter Z vertices, a grid size and duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCShatteredTiles3D* actionWithRange(int nRange, bool bShatterZ, const ccGridSize& gridSize, float duration); @@ -100,7 +100,7 @@ public: public: /** creates the action with a random seed, the grid size and the duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCShuffleTiles* actionWithSeed(int s, const ccGridSize& gridSize, float duration); /** creates the action with a random seed, the grid size and the duration */ @@ -126,7 +126,7 @@ public: public: /** creates the action with the grid size and the duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCFadeOutTRTiles* actionWithSize(const ccGridSize& gridSize, float time); @@ -144,7 +144,7 @@ public: public: /** creates the action with the grid size and the duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCFadeOutBLTiles* actionWithSize(const ccGridSize& gridSize, float time); @@ -163,7 +163,7 @@ public: public: /** creates the action with the grid size and the duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCFadeOutUpTiles* actionWithSize(const ccGridSize& gridSize, float time); /** creates the action with the grid size and the duration */ @@ -181,7 +181,7 @@ public: public: /** creates the action with the grid size and the duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCFadeOutDownTiles* actionWithSize(const ccGridSize& gridSize, float time); @@ -208,11 +208,11 @@ public: public: /** creates the action with the grid size and the duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCTurnOffTiles* actionWithSize(const ccGridSize& size, float d); /** creates the action with a random seed, the grid size and the duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCTurnOffTiles* actionWithSeed(int s, const ccGridSize& gridSize, float duration); @@ -247,7 +247,7 @@ public: public: /** creates the action with a number of waves, the waves amplitude, the grid size and the duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCWavesTiles3D* actionWithWaves(int wav, float amp, const ccGridSize& gridSize, float duration); /** creates the action with a number of waves, the waves amplitude, the grid size and the duration */ @@ -279,7 +279,7 @@ public: public: /** creates the action with the number of jumps, the sin amplitude, the grid size and the duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCJumpTiles3D* actionWithJumps(int j, float amp, const ccGridSize& gridSize, float duration); /** creates the action with the number of jumps, the sin amplitude, the grid size and the duration */ @@ -303,7 +303,7 @@ public : public: /** creates the action with the number of rows to split and the duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSplitRows* actionWithRows(int nRows, float duration); /** creates the action with the number of rows to split and the duration */ @@ -326,7 +326,7 @@ public: public: /** creates the action with the number of columns to split and the duration - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSplitCols* actionWithCols(int nCols, float duration); /** creates the action with the number of columns to split and the duration */ diff --git a/cocos2dx/actions/CCActionTween.h b/cocos2dx/actions/CCActionTween.h index 9620437f0d..76c80bbe2e 100644 --- a/cocos2dx/actions/CCActionTween.h +++ b/cocos2dx/actions/CCActionTween.h @@ -58,7 +58,7 @@ class CCActionTween : public CCActionInterval { public: /** creates an initializes the action with the property name (key), and the from and to parameters. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCActionTween* actionWithDuration(float aDuration, const char* key, float from, float to); /** creates an initializes the action with the property name (key), and the from and to parameters. */ diff --git a/cocos2dx/base_nodes/CCAtlasNode.h b/cocos2dx/base_nodes/CCAtlasNode.h index bb4650045d..8691b9595f 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.h +++ b/cocos2dx/base_nodes/CCAtlasNode.h @@ -80,7 +80,7 @@ public: virtual ~CCAtlasNode(); /** creates a CCAtlasNode with an Atlas file the width and height of each item and the quantity of items to render - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCAtlasNode * atlasWithTileFile(const char* tile,unsigned int tileWidth, unsigned int tileHeight, unsigned int itemsToRender); diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index abf1ee8984..879ec424a6 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -306,7 +306,7 @@ public: /** allocates and initializes a node. The node will be created as "autorelease". - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCNode * node(void); diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index e2e52b9085..22a22a9108 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -111,37 +111,37 @@ public: /* static functions */ /** Create an array - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCArray* array(); /** Create an array with one object - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCArray* arrayWithObject(CCObject* pObject); /** Create an array with some objects - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCArray* arrayWithObjects(CCObject* pObject, ...); /** Create an array with capacity - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCArray* arrayWithCapacity(unsigned int capacity); /** Create an array with an existing array - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCArray* arrayWithArray(CCArray* otherArray); /** @brief Generate a CCArray pointer by file @param pFileName The file name of *.plist file @return The CCArray pointer generated from the file - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCArray* arrayWithContentsOfFile(const char* pFileName); /* @brief The same meaning as arrayWithContentsOfFile(), but it doesn't call autorelease, so the invoker should call release(). - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCArray* arrayWithContentsOfFileThreadSafe(const char* pFileName); diff --git a/cocos2dx/cocoa/CCDictionary.h b/cocos2dx/cocoa/CCDictionary.h index 64614df570..1f97c9094f 100644 --- a/cocos2dx/cocoa/CCDictionary.h +++ b/cocos2dx/cocoa/CCDictionary.h @@ -136,23 +136,23 @@ public: virtual CCObject* copyWithZone(CCZone* pZone); /* static functions */ - //@warning: This interface will be deprecated in future. + //@deprecated: This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCDictionary* dictionary(); - //@warning: This interface will be deprecated in future. + //@deprecated: This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCDictionary* dictionaryWithDictionary(CCDictionary* srcDict); /** @brief Generate a CCDictionary pointer by file @param pFileName The file name of *.plist file @return The CCDictionary pointer generated from the file - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCDictionary* dictionaryWithContentsOfFile(const char *pFileName); /* @brief The same meaning as dictionaryWithContentsOfFile(), but it doesn't call autorelease, so the invoker should call release(). - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCDictionary* dictionaryWithContentsOfFileThreadSafe(const char *pFileName); diff --git a/cocos2dx/cocoa/CCInteger.h b/cocos2dx/cocoa/CCInteger.h index ff52046405..a8b4db49ce 100644 --- a/cocos2dx/cocoa/CCInteger.h +++ b/cocos2dx/cocoa/CCInteger.h @@ -12,7 +12,7 @@ public: : m_nValue(v) {} int getValue() const {return m_nValue;} - // @warning: This interface will be deprecated in future. + // @deprecated: This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCInteger* integerWithInt(int v) { return CCInteger::create(v); diff --git a/cocos2dx/cocoa/CCString.h b/cocos2dx/cocoa/CCString.h index 2712ac0cba..d9dede8f9d 100644 --- a/cocos2dx/cocoa/CCString.h +++ b/cocos2dx/cocoa/CCString.h @@ -78,7 +78,7 @@ public: /** create a string with c string * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCString* stringWithCString(const char* pStr); @@ -92,21 +92,21 @@ public: * if you want to change it, you should modify the kMaxStringLen macro in CCString.cpp file. * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCString* stringWithFormat(const char* format, ...); /** create a string with binary data * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCString* stringWithData(const unsigned char* pData, unsigned long nLen); /** create a string with a file, * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCString* stringWithContentsOfFile(const char* pszFileName); diff --git a/cocos2dx/effects/CCGrid.h b/cocos2dx/effects/CCGrid.h index 22743dc3b2..d7dddbb341 100644 --- a/cocos2dx/effects/CCGrid.h +++ b/cocos2dx/effects/CCGrid.h @@ -77,11 +77,11 @@ public: public: /** create one Grid - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCGridBase* gridWithSize(const ccGridSize& gridSize, CCTexture2D *texture, bool flipped); /** create one Grid - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCGridBase* gridWithSize(const ccGridSize& gridSize); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlButton.h b/cocos2dx/extensions/CCControlExtension/CCControlButton.h index b2c1d85c2a..29b5bc1ab2 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlButton.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlButton.h @@ -97,19 +97,19 @@ protected: public: virtual bool init(); virtual bool initWithLabelAndBackgroundSprite(CCNode* label, CCScale9Sprite* backgroundSprite); - //@warning: This interface will be deprecated in future. + //@deprecated: This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCControlButton* buttonWithLabelAndBackgroundSprite(CCNode* label, CCScale9Sprite* backgroundSprite); static CCControlButton* create(CCNode* label, CCScale9Sprite* backgroundSprite); virtual bool initWithTitleAndFontNameAndFontSize(std::string title, const char * fontName, float fontSize); - //@warning: This interface will be deprecated in future. + //@deprecated: This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCControlButton* buttonWithTitleAndFontNameAndFontSize(std::string title, const char * fontName, float fontSize); static CCControlButton* create(std::string title, const char * fontName, float fontSize); virtual bool initWithBackgroundSprite(CCScale9Sprite* sprite); - //@warning: This interface will be deprecated in future. + //@deprecated: This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCControlButton* buttonWithBackgroundSprite(CCScale9Sprite* sprite); static CCControlButton* create(CCScale9Sprite* sprite); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.h b/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.h index 35ce8b8374..2f4125c6ef 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlColourPicker.h @@ -52,7 +52,7 @@ protected: CC_SYNTHESIZE_READONLY(CCSprite*, m_background, Background); public: - //@warning: This interface will be deprecated in future. + //@deprecated: This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCControlColourPicker* colourPicker(); static CCControlColourPicker* create(); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.h b/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.h index c08dd13d6f..d77f674404 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlHuePicker.h @@ -54,7 +54,7 @@ class CC_DLL CCControlHuePicker : public CCControl public: virtual ~CCControlHuePicker(); virtual bool initWithTargetAndPos(CCNode* target, CCPoint pos); - //@warning: This interface will be deprecated in future. + //@deprecated: This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCControlHuePicker* pickerWithTargetAndPos(CCNode* target, CCPoint pos); static CCControlHuePicker* create(CCNode* target, CCPoint pos); protected: diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.h b/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.h index e7c13e26bd..4eec56ab45 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlSaturationBrightnessPicker.h @@ -57,7 +57,7 @@ public: virtual ~CCControlSaturationBrightnessPicker(); virtual bool initWithTargetAndPos(CCNode* target, CCPoint pos); - //@warning: This interface will be deprecated in future. + //@deprecated: This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCControlSaturationBrightnessPicker* pickerWithTargetAndPos(CCNode* target, CCPoint pos); static CCControlSaturationBrightnessPicker* create(CCNode* target, CCPoint pos); virtual void updateWithHSV(HSV hsv); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSlider.h b/cocos2dx/extensions/CCControlExtension/CCControlSlider.h index d701b5d28c..f1f1bf0c56 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSlider.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlSlider.h @@ -75,14 +75,14 @@ public: /** * Creates slider with a background filename, a progress filename and a * thumb image filename. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCControlSlider* sliderWithFiles(const char* bgFile, const char* progressFile, const char* thumbFile); /** * Creates a slider with a given background sprite and a progress bar and a * thumb item. - *@warning: This interface will be deprecated in future. + *@deprecated: This interface will be deprecated sooner or later. * @see initWithBackgroundSprite:progressSprite:thumbMenuItem: */ CC_DEPRECATED_ATTRIBUTE static CCControlSlider* sliderWithSprites(CCSprite * backgroundSprite, CCSprite* pogressSprite, CCMenuItem* thumbItem); diff --git a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.h b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.h index 6c50b1da18..44fb6f9be6 100644 --- a/cocos2dx/extensions/CCControlExtension/CCControlSwitch.h +++ b/cocos2dx/extensions/CCControlExtension/CCControlSwitch.h @@ -47,7 +47,7 @@ public: bool initWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite); /** Creates a switch with a mask sprite, on/off sprites for on/off states and a thumb sprite. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCControlSwitch* switchWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite); @@ -59,7 +59,7 @@ public: bool initWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite, CCLabelTTF* onLabel, CCLabelTTF* offLabel); /** Creates a switch with a mask sprite, on/off sprites for on/off states, a thumb sprite and an on/off labels. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCControlSwitch* switchWithMaskSprite(CCSprite *maskSprite, CCSprite * onSprite, CCSprite * offSprite, CCSprite * thumbSprite, CCLabelTTF* onLabel, CCLabelTTF* offLabel); diff --git a/cocos2dx/extensions/CCControlExtension/CCMenuPassive.h b/cocos2dx/extensions/CCControlExtension/CCMenuPassive.h index ba63cd3ce6..9aebef1c49 100644 --- a/cocos2dx/extensions/CCControlExtension/CCMenuPassive.h +++ b/cocos2dx/extensions/CCControlExtension/CCMenuPassive.h @@ -18,19 +18,19 @@ class CC_DLL CCMenuPassive : public CCLayer, public CCRGBAProtocol public: /** creates an empty CCMenu - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenuPassive* node(); /** creates a CCMenu with it's items - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenuPassive* menuWithItems(CCNode* item, ...); /** creates a CCMenu with it's item, then use addChild() to add * other items. It is used for script, it can't init with undetermined * number of variables. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenuPassive* menuWithItem(CCNode* item); diff --git a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h index a14f4daece..35a76c9e9a 100644 --- a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h +++ b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.h @@ -112,7 +112,7 @@ public: * with the specified cap insets. * * @see initWithFile:rect:centerRegion: - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCScale9Sprite* spriteWithFile(const char* file, CCRect rect, CCRect capInsets); @@ -143,7 +143,7 @@ public: * texture will be broken down into a 3×3 grid of equal blocks. * * @see initWithFile:rect: - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ static CCScale9Sprite* spriteWithFile(const char* file, CCRect rect); @@ -172,7 +172,7 @@ public: * broken down into a 3×3 grid of equal blocks. * * @see initWithFile:capInsets: - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCScale9Sprite* spriteWithFile(CCRect capInsets, const char* file); /** @@ -200,7 +200,7 @@ public: * broken down into a 3×3 grid of equal blocks. * * @see initWithFile: - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCScale9Sprite* spriteWithFile(const char* file); @@ -231,7 +231,7 @@ public: * It respects the anchorPoint too. * * @see initWithSpriteFrame:centerRegion: - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCScale9Sprite* spriteWithSpriteFrame(CCSpriteFrame* spriteFrame, CCRect capInsets); @@ -261,7 +261,7 @@ public: * It respects the anchorPoint too. * * @see initWithSpriteFrame: - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCScale9Sprite* spriteWithSpriteFrame(CCSpriteFrame* spriteFrame); @@ -294,7 +294,7 @@ public: * It respects the anchorPoint too. * * @see initWithSpriteFrameName:centerRegion: - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCScale9Sprite* spriteWithSpriteFrameName(const char*spriteFrameName, CCRect capInsets); @@ -326,7 +326,7 @@ public: * It respects the anchorPoint too. * * @see initWithSpriteFrameName: - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCScale9Sprite* spriteWithSpriteFrameName(const char*spriteFrameName); @@ -350,7 +350,7 @@ public: */ CCScale9Sprite* resizableSpriteWithCapInsets(CCRect capInsets); - //@warning: This interface will be deprecated in future. + //@deprecated: This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCScale9Sprite* node(); static CCScale9Sprite* create(); diff --git a/cocos2dx/extensions/CCListView/CCListView.h b/cocos2dx/extensions/CCListView/CCListView.h index 9764fc7f0c..7a4b038548 100644 --- a/cocos2dx/extensions/CCListView/CCListView.h +++ b/cocos2dx/extensions/CCListView/CCListView.h @@ -121,7 +121,7 @@ public: virtual ~CCListView(void); CCListView(void); - // @warning: This interface will be deprecated in future. + // @deprecated: This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCListView* viewWithMode(CCListViewMode mode); static CCListView* create(CCListViewMode mode); diff --git a/cocos2dx/extensions/CCScrollView/CCScrollView.h b/cocos2dx/extensions/CCScrollView/CCScrollView.h index 99c997354b..ae9aacaa7b 100644 --- a/cocos2dx/extensions/CCScrollView/CCScrollView.h +++ b/cocos2dx/extensions/CCScrollView/CCScrollView.h @@ -66,7 +66,7 @@ public: virtual void registerWithTouchDispatcher(); /** * Returns an autoreleased scroll view object. - * @warning: This interface will be deprecated in future. + * @deprecated: This interface will be deprecated sooner or later. * @param size view size * @param container parent object * @return autoreleased scroll view object @@ -84,7 +84,7 @@ public: /** * Returns an autoreleased scroll view object. - * @warning: This interface will be deprecated in future. + * @deprecated: This interface will be deprecated sooner or later. * @param size view size * @param container parent object * @return autoreleased scroll view object diff --git a/cocos2dx/label_nodes/CCLabelAtlas.h b/cocos2dx/label_nodes/CCLabelAtlas.h index ea31cad5cb..5cbc89c9e9 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.h +++ b/cocos2dx/label_nodes/CCLabelAtlas.h @@ -52,12 +52,12 @@ public: m_sString.clear(); } /** creates the CCLabelAtlas with a string, a char map file(the atlas), the width and height of each element and the starting char of the atlas - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCLabelAtlas * labelWithString(const char *label, const char *charMapFile, unsigned int itemWidth, unsigned int itemHeight, unsigned int startCharMap); /** creates the CCLabelAtlas with a string and a configuration file - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. @since v2.0 */ CC_DEPRECATED_ATTRIBUTE static CCLabelAtlas* labelWithString(const char *sring, const char *fntFile); diff --git a/cocos2dx/label_nodes/CCLabelBMFont.h b/cocos2dx/label_nodes/CCLabelBMFont.h index 193879bb81..0659792575 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.h +++ b/cocos2dx/label_nodes/CCLabelBMFont.h @@ -104,7 +104,7 @@ public: virtual ~CCBMFontConfiguration(); const char * description(); /** allocates a CCBMFontConfiguration with a FNT file - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCBMFontConfiguration * configurationWithFNTFile(const char *FNTfile); @@ -196,14 +196,14 @@ public: */ static void purgeCachedData(); /** creates a bitmap font altas with an initial string and the FNT file - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCLabelBMFont * labelWithString(const char *str, const char *fntFile, float width = kCCLabelAutomaticWidth, CCTextAlignment alignment = kCCTextAlignmentLeft, CCPoint imageOffset = CCPointZero); /** creates a bitmap font altas with an initial string and the FNT file */ static CCLabelBMFont * create(const char *str, const char *fntFile, float width = kCCLabelAutomaticWidth, CCTextAlignment alignment = kCCTextAlignmentLeft, CCPoint imageOffset = CCPointZero); /** Creates an label. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCLabelBMFont * node(); diff --git a/cocos2dx/label_nodes/CCLabelTTF.h b/cocos2dx/label_nodes/CCLabelTTF.h index ae152031da..088037137a 100644 --- a/cocos2dx/label_nodes/CCLabelTTF.h +++ b/cocos2dx/label_nodes/CCLabelTTF.h @@ -44,19 +44,19 @@ public: const char* description(); /** creates a CCLabelTTF with a font name and font size in points - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCLabelTTF * labelWithString(const char *string, const char *fontName, float fontSize); /** creates a CCLabelTTF from a fontname, horizontal alignment, dimension in points, and font size in points. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. @since v1.0 */ CC_DEPRECATED_ATTRIBUTE static CCLabelTTF * labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, const char *fontName, float fontSize); /** creates a CCLabel from a fontname, alignment, dimension in points and font size in points - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCLabelTTF * labelWithString(const char *string, const CCSize& dimensions, CCTextAlignment hAlignment, CCVerticalTextAlignment vAlignment, const char *fontName, float fontSize); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h index 48f19439c5..e75194a008 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h @@ -54,7 +54,7 @@ public: virtual ~CCLayer(); bool init(); - // @warning: This interface will be deprecated in future. + // @deprecated: This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCLayer *node(void); /** create one layer */ static CCLayer *create(void); @@ -127,7 +127,7 @@ private: }; // for the subclass of CCLayer, each has to implement the static "node" method -// @warning: This interface will be deprecated in future. +// @deprecated: This interface will be deprecated sooner or later. #define LAYER_NODE_FUNC(layer) \ CC_DEPRECATED_ATTRIBUTE static layer* node() \ { \ @@ -164,7 +164,7 @@ private: } \ } -// @warning: This interface will be deprecated in future. +// @deprecated: This interface will be deprecated sooner or later. #define LAYER_NODE_FUNC_PARAM(layer,__PARAMTYPE__,__PARAM__) \ CC_DEPRECATED_ATTRIBUTE static layer* node(__PARAMTYPE__ __PARAM__) \ { \ @@ -223,11 +223,11 @@ public: virtual void setContentSize(const CCSize& var); /** creates a CCLayer with color, width and height in Points - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCLayerColor * layerWithColor(const ccColor4B& color, GLfloat width, GLfloat height); /** creates a CCLayer with color. Width and height are the window size. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCLayerColor * layerWithColor(const ccColor4B& color); @@ -260,7 +260,7 @@ public: virtual void setOpacityModifyRGB(bool bValue) {CC_UNUSED_PARAM(bValue);} virtual bool isOpacityModifyRGB(void) { return false;} - //@warning: This interface will be deprecated in future. + //@deprecated: This interface will be deprecated sooner or later. LAYER_CREATE_FUNC(CCLayerColor) LAYER_NODE_FUNC(CCLayerColor) protected: @@ -294,12 +294,12 @@ class CC_DLL CCLayerGradient : public CCLayerColor { public: /** Creates a full-screen CCLayer with a gradient between start and end. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCLayerGradient* layerWithColor(const ccColor4B& start, const ccColor4B& end); /** Creates a full-screen CCLayer with a gradient between start and end in the direction of v. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCLayerGradient* layerWithColor(const ccColor4B& start, const ccColor4B& end, const CCPoint& v); @@ -330,7 +330,7 @@ public: virtual void setCompressedInterpolation(bool bCompressedInterpolation); virtual bool isCompressedInterpolation(); - // @warning: This interface will be deprecated in future. + // @deprecated: This interface will be deprecated sooner or later. LAYER_NODE_FUNC(CCLayerGradient) LAYER_CREATE_FUNC(CCLayerGradient) protected: @@ -353,14 +353,14 @@ public: virtual ~CCLayerMultiplex(); /** creates a CCLayerMultiplex with one or more layers using a variable argument list. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCLayerMultiplex * layerWithLayers(CCLayer* layer, ... ); /** * lua script can not init with undetermined number of variables * so add these functinons to be used with lua. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCLayerMultiplex * layerWithLayer(CCLayer* layer); @@ -387,7 +387,7 @@ public: */ void switchToAndReleaseMe(unsigned int n); - //@warning: This interface will be deprecated in future. + //@deprecated: This interface will be deprecated sooner or later. LAYER_NODE_FUNC(CCLayerMultiplex) LAYER_CREATE_FUNC(CCLayerMultiplex) diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCScene.h b/cocos2dx/layers_scenes_transitions_nodes/CCScene.h index 933a32862a..23256527bb 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCScene.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCScene.h @@ -54,7 +54,7 @@ public: NS_CC_END // for the subclass of CCScene, each has to implement the static "node" method -// @warning: This interface will be deprecated in future. +// @deprecated: This interface will be deprecated sooner or later. #define SCENE_NODE_FUNC(scene) \ CC_DEPRECATED_ATTRIBUTE static scene* node() \ { \ @@ -72,7 +72,7 @@ CC_DEPRECATED_ATTRIBUTE static scene* node() \ } \ }; -// @warning: This interface will be deprecated in future. +// @deprecated: This interface will be deprecated sooner or later. #define SCENE_FUNC_PARAM(__TYPE__,__PARAMTYPE__,__PARAM__) \ CC_DEPRECATED_ATTRIBUTE static cocos2d::CCScene* node(__PARAMTYPE__ __PARAM__) \ { \ diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h index fc5fa49d78..8feab9553e 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransition.h @@ -112,7 +112,7 @@ public: virtual void cleanup(); /** creates a base transition with duration and incoming scene - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCTransitionScene * transitionWithDuration(float t, CCScene *scene); @@ -148,7 +148,7 @@ public: virtual ~CCTransitionSceneOriented(); /** creates a base transition with duration and incoming scene - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCTransitionSceneOriented * transitionWithDuration(float t,CCScene* scene, tOrientation orientation); @@ -362,7 +362,7 @@ public: virtual void onEnter(); - // @warning: This interface will be deprecated in future. + // @deprecated: This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCTransitionFlipX* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); static CCTransitionFlipX* create(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; @@ -379,7 +379,7 @@ public: virtual void onEnter(); - //@warning: This interface will be deprecated in future. + //@deprecated: This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCTransitionFlipY* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationUpOver); static CCTransitionFlipY* create(float t, CCScene* s, tOrientation o = kOrientationUpOver); }; @@ -396,7 +396,7 @@ public: virtual void onEnter(); - //@warning: This interface will be deprecated in future. + //@deprecated: This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCTransitionFlipAngular* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); static CCTransitionFlipAngular* create(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; @@ -413,7 +413,7 @@ public: virtual void onEnter(); - //@warning: This interface will be deprecated in future. + //@deprecated: This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCTransitionZoomFlipX* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); static CCTransitionZoomFlipX* create(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; @@ -430,7 +430,7 @@ public: virtual void onEnter(); - //@warning: This interface will be deprecated in future. + //@deprecated: This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCTransitionZoomFlipY* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationUpOver); static CCTransitionZoomFlipY* create(float t, CCScene* s, tOrientation o = kOrientationUpOver); }; @@ -447,7 +447,7 @@ public: virtual void onEnter(); - //@warning: This interface will be deprecated in future. + //@deprecated: This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCTransitionZoomFlipAngular* transitionWithDuration(float t, CCScene* s, tOrientation o = kOrientationRightOver); static CCTransitionZoomFlipAngular* create(float t, CCScene* s, tOrientation o = kOrientationRightOver); }; @@ -467,7 +467,7 @@ public: /** creates the transition with a duration and with an RGB color * Example: FadeTransition::transitionWithDuration(2, scene, ccc3(255,0,0); // red color - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCTransitionFade* transitionWithDuration(float duration,CCScene* scene, const ccColor3B& color = ccBLACK); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h index 7dc3333ecf..3e7de98a37 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCTransitionPageTurn.h @@ -54,7 +54,7 @@ public: * Creates a base transition with duration and incoming scene. * If back is true then the effect is reversed to appear as if the incoming * scene is being turned from left over the outgoing scene. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCTransitionPageTurn* transitionWithDuration(float t,CCScene* scene,bool backwards); diff --git a/cocos2dx/menu_nodes/CCMenu.h b/cocos2dx/menu_nodes/CCMenu.h index 4952c5095d..0a3abca5f1 100644 --- a/cocos2dx/menu_nodes/CCMenu.h +++ b/cocos2dx/menu_nodes/CCMenu.h @@ -64,24 +64,24 @@ public: virtual ~CCMenu(){} /** creates an empty CCMenu - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenu* node(); /** creates a CCMenu with it's items - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenu* menuWithItems(CCMenuItem* item, ...); /** creates a CCMenu with a NSArray of CCMenuItem objects - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenu* menuWithArray(CCArray* pArrayOfItems); /** creates a CCMenu with it's item, then use addChild() to add * other items. It is used for script, it can't init with undetermined * number of variables. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenu* menuWithItem(CCMenuItem* item); diff --git a/cocos2dx/menu_nodes/CCMenuItem.h b/cocos2dx/menu_nodes/CCMenuItem.h index 75fa229504..8b2da9ac87 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.h +++ b/cocos2dx/menu_nodes/CCMenuItem.h @@ -61,7 +61,7 @@ public: {} virtual ~CCMenuItem(); /** Creates a CCMenuItem with a target/selector - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenuItem * itemWithTarget(CCObject *rec, SEL_MenuHandler selector); /** Creates a CCMenuItem with a target/selector */ @@ -114,11 +114,11 @@ public: {} virtual ~CCMenuItemLabel(); /** creates a CCMenuItemLabel with a Label, target and selector - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenuItemLabel * itemWithLabel(CCNode*label, CCObject* target, SEL_MenuHandler selector); /** creates a CCMenuItemLabel with a Label. Target and selector will be nill - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenuItemLabel* itemWithLabel(CCNode *label); @@ -160,11 +160,11 @@ public: CCMenuItemAtlasFont(){} virtual ~CCMenuItemAtlasFont(){} /** creates a menu item from a string and atlas with a target/selector - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenuItemAtlasFont* itemWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap); /** creates a menu item from a string and atlas. Use it with MenuItemToggle - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenuItemAtlasFont* itemWithString(const char *value, const char *charMapFile, int itemWidth, int itemHeight, char startCharMap, CCObject* target, SEL_MenuHandler selector); @@ -193,11 +193,11 @@ public: /** get the default font name */ static const char *fontName(); /** creates a menu item from a string without target/selector. To be used with CCMenuItemToggle - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenuItemFont * itemWithString(const char *value); /** creates a menu item from a string with a target/selector - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenuItemFont * itemWithString(const char *value, CCObject* target, SEL_MenuHandler selector); @@ -256,15 +256,15 @@ public: ,m_pDisabledImage(NULL) {} /** creates a menu item with a normal, selected and disabled image - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenuItemSprite * itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite = NULL); /** creates a menu item with a normal and selected image with target/selector - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenuItemSprite * itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCObject* target, SEL_MenuHandler selector); /** creates a menu item with a normal,selected and disabled image with target/selector - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenuItemSprite * itemWithNormalSprite(CCNode* normalSprite, CCNode* selectedSprite, CCNode* disabledSprite, CCObject* target, SEL_MenuHandler selector); @@ -310,19 +310,19 @@ public: CCMenuItemImage(){} virtual ~CCMenuItemImage(){} /** creates a menu item with a normal and selected image - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage); /** creates a menu item with a normal,selected and disabled image - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage); /** creates a menu item with a normal and selected image with target/selector - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage, CCObject* target, SEL_MenuHandler selector); /** creates a menu item with a normal,selected and disabled image with target/selector - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenuItemImage* itemWithNormalImage(const char *normalImage, const char *selectedImage, const char *disabledImage, CCObject* target, SEL_MenuHandler selector); @@ -345,7 +345,7 @@ public: /** sets the sprite frame for the disabled image */ void setDisabledSpriteFrame(CCSpriteFrame* frame); /** Creates an CCMenuItemImage. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenuItemImage* node(); @@ -379,7 +379,7 @@ public: virtual ~CCMenuItemToggle(); /** creates a menu item from a list of items with a target/selector - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenuItemToggle* itemWithTarget(CCObject* target, SEL_MenuHandler selector, CCMenuItem* item, ...); @@ -391,7 +391,7 @@ public: // The follow methods offered to lua /** creates a menu item with a item - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMenuItemToggle* itemWithItem(CCMenuItem *item); diff --git a/cocos2dx/misc_nodes/CCMotionStreak.h b/cocos2dx/misc_nodes/CCMotionStreak.h index 44d8ba515c..388f9f1652 100644 --- a/cocos2dx/misc_nodes/CCMotionStreak.h +++ b/cocos2dx/misc_nodes/CCMotionStreak.h @@ -42,11 +42,11 @@ public: CCMotionStreak(); virtual ~CCMotionStreak(); /** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture filename - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMotionStreak* streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, const char* path); /** creates and initializes a motion streak with fade in seconds, minimum segments, stroke's width, color, texture - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCMotionStreak* streakWithFade(float fade, float minSeg, float stroke, ccColor3B color, CCTexture2D* texture); diff --git a/cocos2dx/misc_nodes/CCProgressTimer.h b/cocos2dx/misc_nodes/CCProgressTimer.h index aa4e6d1e7a..060c540b3b 100644 --- a/cocos2dx/misc_nodes/CCProgressTimer.h +++ b/cocos2dx/misc_nodes/CCProgressTimer.h @@ -83,7 +83,7 @@ public: public: /** Creates a progress timer with the sprite as the shape the timer goes through - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCProgressTimer* progressWithSprite(CCSprite* sp); /** Creates a progress timer with the sprite as the shape the timer goes through */ diff --git a/cocos2dx/misc_nodes/CCRenderTexture.h b/cocos2dx/misc_nodes/CCRenderTexture.h index 523e05ba5b..e3f558f0eb 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.h +++ b/cocos2dx/misc_nodes/CCRenderTexture.h @@ -59,17 +59,17 @@ public: virtual ~CCRenderTexture(); /** initializes a RenderTexture object with width and height in Points and a pixel format( only RGB and RGBA formats are valid ) and depthStencil format - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCRenderTexture * renderTextureWithWidthAndHeight(int w ,int h, CCTexture2DPixelFormat eFormat, GLuint uDepthStencilFormat); /** creates a RenderTexture object with width and height in Points and a pixel format, only RGB and RGBA formats are valid - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCRenderTexture * renderTextureWithWidthAndHeight(int w, int h, CCTexture2DPixelFormat eFormat); /** creates a RenderTexture object with width and height in Points, pixel format is RGBA8888 - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCRenderTexture * renderTextureWithWidthAndHeight(int w, int h); diff --git a/cocos2dx/particle_nodes/CCParticleBatchNode.h b/cocos2dx/particle_nodes/CCParticleBatchNode.h index a06908a429..b8e909b540 100644 --- a/cocos2dx/particle_nodes/CCParticleBatchNode.h +++ b/cocos2dx/particle_nodes/CCParticleBatchNode.h @@ -66,12 +66,12 @@ public: virtual ~CCParticleBatchNode(); /** initializes the particle system with CCTexture2D, a capacity of particles, which particle system to use - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCParticleBatchNode* batchNodeWithTexture(CCTexture2D *tex, unsigned int capacity = kCCParticleDefaultCapacity); /** initializes the particle system with the name of a file on disk (for a list of supported formats look at the CCTexture2D class), a capacity of particles - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCParticleBatchNode* batchNodeWithFile(const char* fileImage, unsigned int capacity = kCCParticleDefaultCapacity); diff --git a/cocos2dx/particle_nodes/CCParticleSystem.h b/cocos2dx/particle_nodes/CCParticleSystem.h index cc08b707bf..c25a0b8807 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.h +++ b/cocos2dx/particle_nodes/CCParticleSystem.h @@ -365,7 +365,7 @@ public: /** creates an initializes a CCParticleSystem from a plist file. This plist files can be creted manually or with Particle Designer: http://particledesigner.71squared.com/ - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. @since v0.99.3 */ CC_DEPRECATED_ATTRIBUTE static CCParticleSystem * particleWithFile(const char *plistFile); diff --git a/cocos2dx/particle_nodes/CCParticleSystemQuad.h b/cocos2dx/particle_nodes/CCParticleSystemQuad.h index 18fe5aa004..c067401de3 100644 --- a/cocos2dx/particle_nodes/CCParticleSystemQuad.h +++ b/cocos2dx/particle_nodes/CCParticleSystemQuad.h @@ -63,7 +63,7 @@ public: /** creates an initializes a CCParticleSystemQuad from a plist file. This plist files can be creted manually or with Particle Designer: - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCParticleSystemQuad * particleWithFile(const char *plistFile); @@ -101,7 +101,7 @@ public: */ void listenBackToForeground(CCObject *obj); - //@warning: This interface will be deprecated in future. + //@deprecated: This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCParticleSystemQuad * node(); static CCParticleSystemQuad * create(); diff --git a/cocos2dx/sprite_nodes/CCAnimation.h b/cocos2dx/sprite_nodes/CCAnimation.h index a18c7418a8..645553b88c 100644 --- a/cocos2dx/sprite_nodes/CCAnimation.h +++ b/cocos2dx/sprite_nodes/CCAnimation.h @@ -84,20 +84,20 @@ public: ~CCAnimation(void); public: /** Creates an animation - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. @since v0.99.5 */ CC_DEPRECATED_ATTRIBUTE static CCAnimation* animation(void); /* Creates an animation with an array of CCSpriteFrame and a delay between frames in seconds. The frames will be added with one "delay unit". - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. @since v0.99.5 */ CC_DEPRECATED_ATTRIBUTE static CCAnimation* animationWithSpriteFrames(CCArray* arrayOfSpriteFrameNames, float delay = 0.0f); /* Creates an animation with an array of CCAnimationFrame, the delay per units in seconds and and how many times it should be executed. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. @since v2.0 */ CC_DEPRECATED_ATTRIBUTE static CCAnimation* animationWithAnimationFrames(CCArray *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops); diff --git a/cocos2dx/sprite_nodes/CCSprite.h b/cocos2dx/sprite_nodes/CCSprite.h index 42a8eaab4f..da71b1822e 100644 --- a/cocos2dx/sprite_nodes/CCSprite.h +++ b/cocos2dx/sprite_nodes/CCSprite.h @@ -123,13 +123,13 @@ public: /** Creates an sprite with a texture. The rect used will be the size of the texture. The offset will be (0,0). - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSprite* spriteWithTexture(CCTexture2D *pTexture); /** Creates an sprite with a texture and a rect. The offset will be (0,0). - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSprite* spriteWithTexture(CCTexture2D *pTexture, const CCRect& rect); @@ -145,14 +145,14 @@ public: static CCSprite* createWithTexture(CCTexture2D *pTexture, const CCRect& rect); /** Creates an sprite with an sprite frame. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSprite* spriteWithSpriteFrame(CCSpriteFrame *pSpriteFrame); /** Creates an sprite with an sprite frame name. An CCSpriteFrame will be fetched from the CCSpriteFrameCache by name. If the CCSpriteFrame doesn't exist it will raise an exception. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. @since v0.9 */ CC_DEPRECATED_ATTRIBUTE static CCSprite* spriteWithSpriteFrameName(const char *pszSpriteFrameName); @@ -169,14 +169,14 @@ public: /** Creates an sprite with an image filename. The rect used will be the size of the image. - @warning: This interface will be deprecated in future. The offset will be (0,0). + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSprite* spriteWithFile(const char *pszFileName); /** Creates an sprite with an image filename and a rect. The offset will be (0,0). - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSprite* spriteWithFile(const char *pszFileName, const CCRect& rect); @@ -192,7 +192,7 @@ public: static CCSprite* create(const char *pszFileName, const CCRect& rect); /** Creates an sprite. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSprite* node(); /** Creates an sprite. diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.h b/cocos2dx/sprite_nodes/CCSpriteBatchNode.h index 94e643f935..5306c08911 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.h +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.h @@ -78,14 +78,14 @@ public: /** creates a CCSpriteBatchNode with a texture2d and capacity of children. The capacity will be increased in 33% in runtime if it run out of space. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSpriteBatchNode* batchNodeWithTexture(CCTexture2D* tex, unsigned int capacity = kDefaultSpriteBatchCapacity); /** creates a CCSpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and capacity of children. The capacity will be increased in 33% in runtime if it run out of space. The file will be loaded using the TextureMgr. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSpriteBatchNode* batchNodeWithFile(const char* fileImage, unsigned int capacity = kDefaultSpriteBatchCapacity); diff --git a/cocos2dx/sprite_nodes/CCSpriteFrame.h b/cocos2dx/sprite_nodes/CCSpriteFrame.h index 3448ceb63c..53fcaa401b 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrame.h +++ b/cocos2dx/sprite_nodes/CCSpriteFrame.h @@ -91,26 +91,26 @@ public: virtual CCObject* copyWithZone(CCZone *pZone); /** Create a CCSpriteFrame with a texture, rect in points. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. It is assumed that the frame was not trimmed. */ CC_DEPRECATED_ATTRIBUTE static CCSpriteFrame* frameWithTexture(CCTexture2D* pobTexture, const CCRect& rect); /** Create a CCSpriteFrame with a texture filename, rect in points. It is assumed that the frame was not trimmed. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSpriteFrame* frameWithTextureFilename(const char* filename, const CCRect& rect); /** Create a CCSpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. The originalSize is the size in points of the frame before being trimmed. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSpriteFrame* frameWithTexture(CCTexture2D* pobTexture, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize); /** Create a CCSpriteFrame with a texture filename, rect, rotated, offset and originalSize in pixels. The originalSize is the size in pixels of the frame before being trimmed. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCSpriteFrame* frameWithTextureFilename(const char* filename, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize); diff --git a/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h b/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h index b7110c0a1a..5ca90419b3 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h +++ b/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h @@ -50,7 +50,7 @@ public: */ CCParallaxNode(); virtual ~CCParallaxNode(); - //@warning: This interface will be deprecated in future. + //@deprecated: This interface will be deprecated sooner or later. CC_DEPRECATED_ATTRIBUTE static CCParallaxNode * node(); static CCParallaxNode * create(); virtual void addChild(CCNode * child, unsigned int z, const CCPoint& parallaxRatio, const CCPoint& positionOffset); diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h index 5d7d64e9c7..4b632975d7 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h @@ -84,7 +84,7 @@ public: CCTMXLayer(); virtual ~CCTMXLayer(); /** creates a CCTMXLayer with an tileset info, a layer info and a map info - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCTMXLayer * layerWithTilesetInfo(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerInfo *layerInfo, CCTMXMapInfo *mapInfo); diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h index 12002b413e..72aa5a31ee 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h @@ -118,12 +118,12 @@ public: virtual ~CCTMXTiledMap(); /** creates a TMX Tiled Map with a TMX file. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCTMXTiledMap* tiledMapWithTMXFile(const char *tmxFile); /** initializes a TMX Tiled Map with a TMX formatted XML string and a path to TMX resources - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCTMXTiledMap* tiledMapWithXML(const char* tmxString, const char* resourcePath); diff --git a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h index cfe84655a0..76df642f35 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h @@ -57,7 +57,7 @@ public: virtual ~CCTileMapAtlas(); /** creates a CCTileMap with a tile file (atlas) with a map file and the width and height of each tile in points. The tile file will be loaded using the TextureMgr. - @warning: This interface will be deprecated in future. + @deprecated: This interface will be deprecated sooner or later. */ CC_DEPRECATED_ATTRIBUTE static CCTileMapAtlas * tileMapAtlasWithTileFile(const char *tile, const char *mapFile, int tileWidth, int tileHeight); From f8ebbccb98b8e17cbcc62344bef3225d78928d63 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 20 Jun 2012 14:38:13 +0800 Subject: [PATCH 233/257] fixed #1292: Renamed CCFileUtils::popupNotify to CCFileUtils::setPopupNotify --- cocos2dx/particle_nodes/CCParticleSystem.cpp | 4 ++-- cocos2dx/platform/CCFileUtils.h | 2 +- cocos2dx/platform/CCFileUtilsCommon_cpp.h | 2 +- cocos2dx/platform/ios/CCFileUtils.mm | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cocos2dx/particle_nodes/CCParticleSystem.cpp b/cocos2dx/particle_nodes/CCParticleSystem.cpp index a2881502e7..f84554c463 100644 --- a/cocos2dx/particle_nodes/CCParticleSystem.cpp +++ b/cocos2dx/particle_nodes/CCParticleSystem.cpp @@ -289,11 +289,11 @@ bool CCParticleSystem::initWithDictionary(CCDictionary *dictionary) { // set not pop-up message box when load image failed bool bNotify = CCFileUtils::sharedFileUtils()->isPopupNotify(); - CCFileUtils::sharedFileUtils()->popupNotify(false); + CCFileUtils::sharedFileUtils()->setPopupNotify(false); tex = CCTextureCache::sharedTextureCache()->addImage(fullpath.c_str()); // reset the value of UIImage notify - CCFileUtils::sharedFileUtils()->popupNotify(bNotify); + CCFileUtils::sharedFileUtils()->setPopupNotify(bNotify); } if (tex) diff --git a/cocos2dx/platform/CCFileUtils.h b/cocos2dx/platform/CCFileUtils.h index 0459244d08..96da5f6008 100644 --- a/cocos2dx/platform/CCFileUtils.h +++ b/cocos2dx/platform/CCFileUtils.h @@ -157,7 +157,7 @@ public: /** @brief Set/Get whether pop-up a message box when the image load failed */ - void popupNotify(bool bNotify); + void setPopupNotify(bool bNotify); bool isPopupNotify(); }; diff --git a/cocos2dx/platform/CCFileUtilsCommon_cpp.h b/cocos2dx/platform/CCFileUtilsCommon_cpp.h index 2b78ab679b..c6a1ce4f84 100644 --- a/cocos2dx/platform/CCFileUtilsCommon_cpp.h +++ b/cocos2dx/platform/CCFileUtilsCommon_cpp.h @@ -443,7 +443,7 @@ bool CCFileUtils::iPhoneRetinaDisplayFileExistsAtPath(const char *filename) ////////////////////////////////////////////////////////////////////////// static bool s_bPopupNotify = true; -void CCFileUtils::popupNotify(bool bNotify) +void CCFileUtils::setPopupNotify(bool bNotify) { s_bPopupNotify = bNotify; } diff --git a/cocos2dx/platform/ios/CCFileUtils.mm b/cocos2dx/platform/ios/CCFileUtils.mm index 229212aa87..7a296d8f70 100644 --- a/cocos2dx/platform/ios/CCFileUtils.mm +++ b/cocos2dx/platform/ios/CCFileUtils.mm @@ -477,7 +477,7 @@ unsigned char* CCFileUtils::getFileData(const char* pszFileName, const char* psz // notification support when getFileData from a invalid file static bool s_bPopupNotify = true; -void CCFileUtils::popupNotify(bool bNotify) +void CCFileUtils::setPopupNotify(bool bNotify) { s_bPopupNotify = bNotify; } From d7162fcfc5100afdef082f925cffdd19de331d96 Mon Sep 17 00:00:00 2001 From: Walzer Date: Wed, 20 Jun 2012 18:07:27 +0800 Subject: [PATCH 234/257] Add groups in all classes for doxygen. Upgrade doxygen to 0.8.1 --- cocos2dx/actions/CCAction.h | 8 ++++++++ doxygen/Groups.h | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 doxygen/Groups.h diff --git a/cocos2dx/actions/CCAction.h b/cocos2dx/actions/CCAction.h index 3aec80e1f9..5dfd20f426 100644 --- a/cocos2dx/actions/CCAction.h +++ b/cocos2dx/actions/CCAction.h @@ -38,6 +38,11 @@ enum { kCCActionTagInvalid = -1, }; +/** + * @addtogroup actions + * @{ + */ + /** @brief Base class for CCAction objects. */ @@ -257,6 +262,9 @@ protected: float m_fBottomBoundary; }; +// end of actions group +/// @} + NS_CC_END #endif // __ACTIONS_CCACTION_H__ diff --git a/doxygen/Groups.h b/doxygen/Groups.h new file mode 100644 index 0000000000..4c623b70fc --- /dev/null +++ b/doxygen/Groups.h @@ -0,0 +1,25 @@ +/** +@defgroup actions Actions +@defgroup data_structures Data Structures +@defgroup base_nodes Base Nodes +@defgroup effects Effects +@defgroup cocosbuilder CocosBuilder Support +@defgroup global Global +@defgroup input Human Machine Interation +@defgroup data_storage Data Storage +@defgroup layer Layer +@defgroup scene Scene +@defgroup transition Transition +@defgroup GUI GUI +@defgroup label Label +@defgroup menu Menu, MenuItem +@defgroup control_extension Control Exntension +@defgroup misc_nodes Misc Nodes +@defgroup particle_nodes Particle System +@defgroup platform Platform Adaptor +@defgroup script_support Script Support +@defgroup shaders Shaders +@defgroup sprite_nodes Sprite Nodes +@defgroup textures Textures +@defgroup tilemap_parallax_nodes TileMap, Parallax + */ \ No newline at end of file From 9eab0c19f849c2f0b5a0d638eb0f1c3a96190bae Mon Sep 17 00:00:00 2001 From: Walzer Date: Wed, 20 Jun 2012 18:09:11 +0800 Subject: [PATCH 235/257] add groups to all classes for doxygen --- cocos2dx/CCCamera.h | 8 + cocos2dx/CCConfiguration.h | 7 + cocos2dx/CCDirector.h | 8 + cocos2dx/CCDrawingPrimitives.h | 8 + cocos2dx/CCScheduler.h | 8 + cocos2dx/actions/CCActionCamera.h | 10 + cocos2dx/actions/CCActionCatmullRom.h | 13 + cocos2dx/actions/CCActionEase.h | 30 +++ cocos2dx/actions/CCActionGrid.h | 8 + cocos2dx/actions/CCActionGrid3D.h | 9 + cocos2dx/actions/CCActionInstant.h | 8 + cocos2dx/actions/CCActionInterval.h | 8 + cocos2dx/actions/CCActionManager.h | 9 + cocos2dx/actions/CCActionPageTurn3D.h | 9 + cocos2dx/actions/CCActionProgressTimer.h | 8 + cocos2dx/actions/CCActionTiledGrid.h | 9 + cocos2dx/actions/CCActionTween.h | 8 + cocos2dx/base_nodes/CCAtlasNode.h | 8 + cocos2dx/base_nodes/CCNode.h | 8 + cocos2dx/cocoa/CCArray.h | 8 + cocos2dx/cocoa/CCAutoreleasePool.h | 8 + cocos2dx/cocoa/CCDictionary.h | 8 + cocos2dx/cocoa/CCGeometry.h | 8 + cocos2dx/cocoa/CCInteger.h | 8 + cocos2dx/cocoa/CCNS.h | 9 + cocos2dx/cocoa/CCObject.h | 8 + cocos2dx/cocoa/CCSet.h | 8 + cocos2dx/cocoa/CCString.h | 7 + cocos2dx/cocoa/CCZone.h | 8 + cocos2dx/effects/CCGrabber.h | 9 + cocos2dx/effects/CCGrid.h | 8 + cocos2dx/extensions/CCBReader/CCBReader.h | 8 + .../extensions/CCControlExtension/CCControl.h | 11 + .../CCControlExtension/CCControlButton.h | 11 + .../CCControlColourPicker.h | 11 + .../CCControlExtension/CCControlHuePicker.h | 11 + .../CCControlSaturationBrightnessPicker.h | 11 + .../CCControlExtension/CCControlSlider.h | 13 +- .../CCControlExtension/CCControlSwitch.h | 10 + .../CCControlExtension/CCControlUtils.h | 10 + .../CCControlExtension/CCInvocation.h | 11 + .../CCControlExtension/CCMenuPassive.h | 11 + .../CCControlExtension/CCScale9Sprite.h | 13 +- .../extensions/CCControlExtension/CCSpacer.h | 11 + cocos2dx/extensions/CCListView/CCListView.h | 8 + .../extensions/CCListView/CCListViewCell.h | 8 + .../extensions/CCScrollView/CCScrollView.h | 8 + cocos2dx/keypad_dispatcher/CCKeypadDelegate.h | 8 + .../keypad_dispatcher/CCKeypadDispatcher.h | 8 + cocos2dx/label_nodes/CCLabelAtlas.h | 12 + cocos2dx/label_nodes/CCLabelBMFont.h | 11 + cocos2dx/label_nodes/CCLabelTTF.h | 11 + .../layers_scenes_transitions_nodes/CCLayer.h | 8 + .../layers_scenes_transitions_nodes/CCScene.h | 8 + .../CCTransition.h | 8 + .../CCTransitionPageTurn.h | 8 + .../CCTransitionProgress.h | 8 + cocos2dx/menu_nodes/CCMenu.h | 10 + cocos2dx/menu_nodes/CCMenuItem.h | 11 + cocos2dx/misc_nodes/CCMotionStreak.h | 7 + cocos2dx/misc_nodes/CCProgressTimer.h | 8 + cocos2dx/misc_nodes/CCRenderTexture.h | 8 + cocos2dx/particle_nodes/CCParticleBatchNode.h | 8 + cocos2dx/particle_nodes/CCParticleExamples.h | 9 +- cocos2dx/particle_nodes/CCParticleSystem.h | 8 + .../particle_nodes/CCParticleSystemQuad.h | 8 + cocos2dx/platform/CCApplicationProtocol.h | 8 + cocos2dx/platform/CCCommon.h | 8 + cocos2dx/platform/CCEGLViewProtocol.h | 8 + cocos2dx/platform/CCFileUtils.h | 8 + cocos2dx/platform/CCImage.h | 8 + cocos2dx/platform/CCSAXParser.h | 8 + cocos2dx/platform/CCThread.h | 8 + cocos2dx/platform/platform.h | 8 + cocos2dx/script_support/CCScriptSupport.h | 8 + cocos2dx/shaders/CCGLProgram.h | 8 + cocos2dx/shaders/CCShaderCache.h | 8 + cocos2dx/shaders/ccGLStateCache.h | 8 + cocos2dx/shaders/ccShaders.h | 8 + cocos2dx/sprite_nodes/CCAnimation.h | 8 + cocos2dx/sprite_nodes/CCAnimationCache.h | 8 + cocos2dx/sprite_nodes/CCSprite.h | 8 + cocos2dx/sprite_nodes/CCSpriteBatchNode.h | 8 + cocos2dx/sprite_nodes/CCSpriteFrame.h | 8 + cocos2dx/sprite_nodes/CCSpriteFrameCache.h | 8 + cocos2dx/support/CCPointExtension.h | 8 + cocos2dx/support/CCProfiling.h | 8 + cocos2dx/support/CCUserDefault.h | 8 + cocos2dx/support/CCVertex.h | 8 + cocos2dx/support/TransformUtils.h | 2 +- cocos2dx/text_input_node/CCIMEDelegate.h | 8 + cocos2dx/text_input_node/CCIMEDispatcher.h | 8 + cocos2dx/text_input_node/CCTextFieldTTF.h | 8 + cocos2dx/textures/CCTexture2D.h | 8 + cocos2dx/textures/CCTextureAtlas.h | 8 + cocos2dx/textures/CCTextureCache.h | 12 +- cocos2dx/textures/CCTexturePVR.h | 8 + .../tileMap_parallax_nodes/CCParallaxNode.h | 8 + cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h | 8 + .../tileMap_parallax_nodes/CCTMXObjectGroup.h | 8 + .../tileMap_parallax_nodes/CCTMXTiledMap.h | 8 + .../tileMap_parallax_nodes/CCTMXXMLParser.h | 8 + .../tileMap_parallax_nodes/CCTileMapAtlas.h | 9 + cocos2dx/touch_dispatcher/CCTouch.h | 8 + .../CCTouchDelegateProtocol.h | 10 +- cocos2dx/touch_dispatcher/CCTouchDispatcher.h | 8 + cocos2dx/touch_dispatcher/CCTouchHandler.h | 8 + doxygen/doxygen.cocos2d-x | 250 ++++++++++++------ 108 files changed, 1105 insertions(+), 88 deletions(-) diff --git a/cocos2dx/CCCamera.h b/cocos2dx/CCCamera.h index b5d4858eed..310031146f 100644 --- a/cocos2dx/CCCamera.h +++ b/cocos2dx/CCCamera.h @@ -34,6 +34,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup base_nodes + * @{ + */ + /** A CCCamera is used in every CCNode. Useful to look at the object from different views. @@ -111,6 +116,9 @@ private: DISALLOW_COPY_AND_ASSIGN(CCCamera); }; +// end of base_node group +/// @} + NS_CC_END #endif // __CCCAMERA_H__ diff --git a/cocos2dx/CCConfiguration.h b/cocos2dx/CCConfiguration.h index 9d94e606e4..0c8a78b78d 100644 --- a/cocos2dx/CCConfiguration.h +++ b/cocos2dx/CCConfiguration.h @@ -32,6 +32,10 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup global + * @{ + */ /** @brief CCConfiguration contains some openGL variables @since v0.99.0 @@ -127,6 +131,9 @@ protected: char * m_pGlExtensions; }; +// end of global group +/// @} + NS_CC_END #endif // __CCCONFIGURATION_H__ diff --git a/cocos2dx/CCDirector.h b/cocos2dx/CCDirector.h index 62e341b06a..d6c024cb7d 100644 --- a/cocos2dx/CCDirector.h +++ b/cocos2dx/CCDirector.h @@ -37,6 +37,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup base_nodes + * @{ + */ + /** @typedef ccDirectorProjection Possible OpenGL projections used by director */ @@ -427,6 +432,9 @@ protected: bool m_bInvalid; }; +// end of base_node group +/// @} + NS_CC_END #endif // __CCDIRECTOR_H__ diff --git a/cocos2dx/CCDrawingPrimitives.h b/cocos2dx/CCDrawingPrimitives.h index 55c1845ec4..8068fa2b52 100644 --- a/cocos2dx/CCDrawingPrimitives.h +++ b/cocos2dx/CCDrawingPrimitives.h @@ -49,6 +49,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup global + * @{ + */ + class CCPointArray; /** initlialize context */ @@ -124,6 +129,9 @@ void CC_DLL ccDrawColor4F( GLfloat r, GLfloat g, GLfloat b, GLfloat a ); */ void CC_DLL ccPointSize( GLfloat pointSize ); +// end of global group +/// @} + NS_CC_END #endif // __CCDRAWING_PRIMITIVES__ diff --git a/cocos2dx/CCScheduler.h b/cocos2dx/CCScheduler.h index d70184e95e..74d80e8f61 100644 --- a/cocos2dx/CCScheduler.h +++ b/cocos2dx/CCScheduler.h @@ -32,6 +32,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup global + * @{ + */ + // Priority level reserved for system services. #define kCCPrioritySystem INT_MIN @@ -258,6 +263,9 @@ protected: CCArray* m_pScriptHandlerEntries; }; +// end of global group +/// @} + NS_CC_END #endif // __CCSCHEDULER_H__ diff --git a/cocos2dx/actions/CCActionCamera.h b/cocos2dx/actions/CCActionCamera.h index fd117dc199..93560acf92 100644 --- a/cocos2dx/actions/CCActionCamera.h +++ b/cocos2dx/actions/CCActionCamera.h @@ -32,8 +32,14 @@ NS_CC_BEGIN class CCCamera; +/** + * @addtogroup actions + * @{ + */ + /** @brief Base class for CCCamera actions +@ingroup Actions */ class CC_DLL CCActionCamera : public CCActionInterval // { @@ -70,6 +76,7 @@ protected: /** @brief CCOrbitCamera action Orbits the camera around the center of the screen using spherical coordinates +@ingroup Actions */ class CC_DLL CCOrbitCamera : public CCActionCamera // { @@ -118,6 +125,9 @@ protected: float m_fRadDeltaX; }; +// end of actions group +/// @} + NS_CC_END #endif //__CCCAMERA_ACTION_H__ \ No newline at end of file diff --git a/cocos2dx/actions/CCActionCatmullRom.h b/cocos2dx/actions/CCActionCatmullRom.h index 9ca20396ef..cd9e12f14e 100644 --- a/cocos2dx/actions/CCActionCatmullRom.h +++ b/cocos2dx/actions/CCActionCatmullRom.h @@ -43,8 +43,14 @@ NS_CC_BEGIN; +/** + * @addtogroup actions + * @{ + */ + /** An Array that contain control points. Used by CCCardinalSplineTo and (By) and CCCatmullRomTo (and By) actions. +@ingroup Actions */ class CC_DLL CCPointArray : public CCNode { @@ -103,6 +109,7 @@ private: /** Cardinal Spline path. http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline +@ingroup Actions */ class CC_DLL CCCardinalSplineTo : public CCActionInterval { @@ -146,6 +153,7 @@ protected: /** Cardinal Spline path. http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Cardinal_spline + @ingroup Actions */ class CC_DLL CCCardinalSplineBy : public CCCardinalSplineTo { @@ -170,6 +178,7 @@ protected: /** An action that moves the target with a CatmullRom curve to a destination point. A Catmull Rom is a Cardinal Spline with a tension of 0.5. http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline + @ingroup Actions */ class CC_DLL CCCatmullRomTo : public CCCardinalSplineTo { @@ -189,6 +198,7 @@ public: /** An action that moves the target with a CatmullRom curve by a certain distance. A Catmull Rom is a Cardinal Spline with a tension of 0.5. http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Catmull.E2.80.93Rom_spline + @ingroup Actions */ class CC_DLL CCCatmullRomBy : public CCCardinalSplineBy { @@ -208,6 +218,9 @@ public: /** Returns the Cardinal Spline position for a given set of control points, tension and time */ extern CC_DLL CCPoint ccCardinalSplineAt(CCPoint &p0, CCPoint &p1, CCPoint &p2, CCPoint &p3, float tension, float t); +// end of actions group +/// @} + NS_CC_END; #endif // __CCACTION_CATMULLROM_H__ diff --git a/cocos2dx/actions/CCActionEase.h b/cocos2dx/actions/CCActionEase.h index fa6292231b..1e51fb4c16 100644 --- a/cocos2dx/actions/CCActionEase.h +++ b/cocos2dx/actions/CCActionEase.h @@ -33,8 +33,14 @@ NS_CC_BEGIN class CCObject; class CCZone; +/** + * @addtogroup actions + * @{ + */ + /** @brief Base class for Easing actions + @ingroup Actions */ class CC_DLL CCActionEase : public CCActionInterval { @@ -65,6 +71,7 @@ protected: /** @brief Base class for Easing actions with rate parameters + @ingroup Actions */ class CC_DLL CCEaseRateAction : public CCActionEase { @@ -97,6 +104,7 @@ protected: /** @brief CCEaseIn action with a rate + @ingroup Actions */ class CC_DLL CCEaseIn : public CCEaseRateAction { @@ -116,6 +124,7 @@ public: /** @brief CCEaseOut action with a rate + @ingroup Actions */ class CC_DLL CCEaseOut : public CCEaseRateAction { @@ -136,6 +145,7 @@ public: /** @brief CCEaseInOut action with a rate + @ingroup Actions */ class CC_DLL CCEaseInOut : public CCEaseRateAction { @@ -156,6 +166,7 @@ public: /** @brief CCEase Exponential In + @ingroup Actions */ class CC_DLL CCEaseExponentialIn : public CCActionEase { @@ -175,6 +186,7 @@ public: /** @brief Ease Exponential Out + @ingroup Actions */ class CC_DLL CCEaseExponentialOut : public CCActionEase { @@ -194,6 +206,7 @@ public: /** @brief Ease Exponential InOut + @ingroup Actions */ class CC_DLL CCEaseExponentialInOut : public CCActionEase { @@ -214,6 +227,7 @@ public: /** @brief Ease Sine In + @ingroup Actions */ class CC_DLL CCEaseSineIn : public CCActionEase { @@ -233,6 +247,7 @@ public: /** @brief Ease Sine Out + @ingroup Actions */ class CC_DLL CCEaseSineOut : public CCActionEase { @@ -252,6 +267,7 @@ public: /** @brief Ease Sine InOut + @ingroup Actions */ class CC_DLL CCEaseSineInOut : public CCActionEase { @@ -272,6 +288,7 @@ public: /** @brief Ease Elastic abstract class @since v0.8.2 + @ingroup Actions */ class CC_DLL CCEaseElastic : public CCActionEase { @@ -302,6 +319,7 @@ protected: @brief Ease Elastic In action. @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 + @ingroup Actions */ class CC_DLL CCEaseElasticIn : public CCEaseElastic { @@ -323,6 +341,7 @@ public: @brief Ease Elastic Out action. @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 + @ingroup Actions */ class CC_DLL CCEaseElasticOut : public CCEaseElastic { @@ -345,6 +364,7 @@ public: @brief Ease Elastic InOut action. @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 + @ingroup Actions */ class CC_DLL CCEaseElasticInOut : public CCEaseElastic { @@ -366,6 +386,7 @@ public: /** @brief CCEaseBounce abstract class. @since v0.8.2 + @ingroup Actions */ class CC_DLL CCEaseBounce : public CCActionEase { @@ -387,6 +408,7 @@ public: @brief CCEaseBounceIn action. @warning This action doesn't use a bijective function. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 + @ingroup Actions */ class CC_DLL CCEaseBounceIn : public CCEaseBounce { @@ -408,6 +430,7 @@ public: @brief EaseBounceOut action. @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 + @ingroup Actions */ class CC_DLL CCEaseBounceOut : public CCEaseBounce { @@ -429,6 +452,7 @@ public: @brief CCEaseBounceInOut action. @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 + @ingroup Actions */ class CC_DLL CCEaseBounceInOut : public CCEaseBounce { @@ -450,6 +474,7 @@ public: @brief CCEaseBackIn action. @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 + @ingroup Actions */ class CC_DLL CCEaseBackIn : public CCActionEase { @@ -471,6 +496,7 @@ public: @brief CCEaseBackOut action. @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 + @ingroup Actions */ class CC_DLL CCEaseBackOut : public CCActionEase { @@ -492,6 +518,7 @@ public: @brief CCEaseBackInOut action. @warning This action doesn't use a bijective fucntion. Actions like Sequence might have an unexpected result when used with this action. @since v0.8.2 + @ingroup Actions */ class CC_DLL CCEaseBackInOut : public CCActionEase { @@ -509,6 +536,9 @@ public: static CCEaseBackInOut* create(CCActionInterval* pAction); }; +// end of actions group +/// @} + NS_CC_END #endif // __ACTION_CCEASE_ACTION_H__ diff --git a/cocos2dx/actions/CCActionGrid.h b/cocos2dx/actions/CCActionGrid.h index da0e012a25..24d5e6e2ef 100644 --- a/cocos2dx/actions/CCActionGrid.h +++ b/cocos2dx/actions/CCActionGrid.h @@ -32,6 +32,11 @@ NS_CC_BEGIN class CCGridBase; +/** + * @addtogroup actions + * @{ + */ + /** @brief Base class for Grid actions */ class CC_DLL CCGridAction : public CCActionInterval { @@ -232,6 +237,9 @@ protected: int m_nTimes; }; +// end of actions group +/// @} + NS_CC_END #endif // __ACTION_CCGRID_ACTION_H__ diff --git a/cocos2dx/actions/CCActionGrid3D.h b/cocos2dx/actions/CCActionGrid3D.h index 62107a0ed6..28ed8a9ab2 100644 --- a/cocos2dx/actions/CCActionGrid3D.h +++ b/cocos2dx/actions/CCActionGrid3D.h @@ -28,6 +28,12 @@ THE SOFTWARE. #include "CCActionGrid.h" NS_CC_BEGIN + +/** + * @addtogroup actions + * @{ + */ + /** @brief CCWaves3D action */ @@ -289,6 +295,9 @@ protected: float m_fAmplitudeRate; }; +// end of actions group +/// @} + NS_CC_END #endif // __ACTION_CCGRID3D_ACTION_H__ diff --git a/cocos2dx/actions/CCActionInstant.h b/cocos2dx/actions/CCActionInstant.h index 5ec5abc8c6..6b77ff69af 100644 --- a/cocos2dx/actions/CCActionInstant.h +++ b/cocos2dx/actions/CCActionInstant.h @@ -32,6 +32,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup actions + * @{ + */ + /** @brief Instant actions are immediate actions. They don't have a duration like the CCIntervalAction actions. @@ -376,6 +381,9 @@ protected: CCObject* m_pObject; }; +// end of actions group +/// @} + NS_CC_END #endif //__CCINSTANT_ACTION_H__ diff --git a/cocos2dx/actions/CCActionInterval.h b/cocos2dx/actions/CCActionInterval.h index 4bc4ead98e..708b4b7820 100644 --- a/cocos2dx/actions/CCActionInterval.h +++ b/cocos2dx/actions/CCActionInterval.h @@ -36,6 +36,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup actions + * @{ + */ + /** @brief An interval action is an action that takes place within a certain period of time. It has an start time, and a finish time. The finish time is the parameter @@ -853,6 +858,9 @@ private: CCFiniteTimeAction* m_pAction; }; +// end of actions group +/// @} + NS_CC_END #endif //__ACTION_CCINTERVAL_ACTION_H__ diff --git a/cocos2dx/actions/CCActionManager.h b/cocos2dx/actions/CCActionManager.h index 8e10821d15..0f2fba72c5 100644 --- a/cocos2dx/actions/CCActionManager.h +++ b/cocos2dx/actions/CCActionManager.h @@ -37,6 +37,12 @@ NS_CC_BEGIN class CCSet; struct _hashElement; + +/** + * @addtogroup actions + * @{ + */ + /** @brief CCActionManager is a singleton that manages all the actions. Normally you won't need to use this singleton directly. 99% of the cases you will use the CCNode interface, @@ -121,6 +127,9 @@ protected: bool m_bCurrentTargetSalvaged; }; +// end of actions group +/// @} + NS_CC_END #endif // __ACTION_CCACTION_MANAGER_H__ diff --git a/cocos2dx/actions/CCActionPageTurn3D.h b/cocos2dx/actions/CCActionPageTurn3D.h index 9f718f0438..6de968494a 100644 --- a/cocos2dx/actions/CCActionPageTurn3D.h +++ b/cocos2dx/actions/CCActionPageTurn3D.h @@ -28,6 +28,12 @@ THE SOFTWARE. #include "CCActionGrid3D.h" NS_CC_BEGIN + +/** + * @addtogroup actions + * @{ + */ + /** @brief This action simulates a page turn from the bottom right hand corner of the screen. It's not much use by itself but is used by the PageTurnTransition. @@ -51,6 +57,9 @@ public: static CCPageTurn3D* create(const ccGridSize& gridSize, float time); }; +// end of actions group +/// @} + NS_CC_END #endif // __ACTION_CCPAGETURN3D_ACTION_H__ diff --git a/cocos2dx/actions/CCActionProgressTimer.h b/cocos2dx/actions/CCActionProgressTimer.h index 0d8629a9d8..e75a529f2a 100644 --- a/cocos2dx/actions/CCActionProgressTimer.h +++ b/cocos2dx/actions/CCActionProgressTimer.h @@ -29,6 +29,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup actions + * @{ + */ + /** @brief Progress to percentage @since v0.99.1 @@ -82,6 +87,9 @@ protected: float m_fFrom; }; +// end of actions group +/// @} + NS_CC_END #endif // __ACTION_CCPROGRESS_TIMER_H__ diff --git a/cocos2dx/actions/CCActionTiledGrid.h b/cocos2dx/actions/CCActionTiledGrid.h index aae71d3bf2..020772fe54 100644 --- a/cocos2dx/actions/CCActionTiledGrid.h +++ b/cocos2dx/actions/CCActionTiledGrid.h @@ -28,6 +28,12 @@ THE SOFTWARE. #include "CCActionGrid.h" NS_CC_BEGIN + +/** + * @addtogroup actions + * @{ + */ + /** @brief CCShakyTiles3D action */ class CC_DLL CCShakyTiles3D : public CCTiledGrid3DAction { @@ -336,6 +342,9 @@ protected: CCSize m_winSize; }; +// end of actions group +/// @} + NS_CC_END #endif // __ACTION_CCTILEDGRID_ACTION_H__ diff --git a/cocos2dx/actions/CCActionTween.h b/cocos2dx/actions/CCActionTween.h index 76c80bbe2e..9e34230d3f 100644 --- a/cocos2dx/actions/CCActionTween.h +++ b/cocos2dx/actions/CCActionTween.h @@ -29,6 +29,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup actions + * @{ + */ + class CCActionTweenDelegate { public: @@ -75,6 +80,9 @@ public: float m_fDelta; }; +// end of actions group +/// @} + NS_CC_END #endif /* __CCACTIONTWEEN_H__ */ diff --git a/cocos2dx/base_nodes/CCAtlasNode.h b/cocos2dx/base_nodes/CCAtlasNode.h index 8691b9595f..f14eb04507 100644 --- a/cocos2dx/base_nodes/CCAtlasNode.h +++ b/cocos2dx/base_nodes/CCAtlasNode.h @@ -33,6 +33,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup base_nodes + * @{ + */ + class CCTextureAtlas; /** @brief CCAtlasNode is a subclass of CCNode that implements the CCRGBAProtocol and @@ -114,6 +119,9 @@ private : }; +// end of base_node group +/// @} + NS_CC_END #endif // __CCATLAS_NODE_H__ diff --git a/cocos2dx/base_nodes/CCNode.h b/cocos2dx/base_nodes/CCNode.h index 879ec424a6..4a274b66c7 100644 --- a/cocos2dx/base_nodes/CCNode.h +++ b/cocos2dx/base_nodes/CCNode.h @@ -48,6 +48,11 @@ class CCLabelProtocol; class CCScheduler; class CCActionManager; +/** + * @addtogroup base_nodes + * @{ + */ + enum { kCCNodeTagInvalid = -1, }; @@ -607,6 +612,9 @@ public: CCPoint convertTouchToNodeSpaceAR(CCTouch * touch); }; +// end of base_node group +/// @} + NS_CC_END #endif // __PLATFOMR_CCNODE_H__ diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index 22a22a9108..1b45372a7a 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -27,6 +27,11 @@ THE SOFTWARE. #include "support/data_support/ccCArray.h" +/** + * @addtogroup data_structures + * @{ + */ + /** @def CCARRAY_FOREACH A convience macro to iterate over a CCArray using. It is faster than the "fast enumeration" interface. @since v0.99.4 @@ -247,6 +252,9 @@ public: CCArray(unsigned int capacity); }; +// end of data_structure group +/// @} + NS_CC_END #endif // __CCARRAY_H__ diff --git a/cocos2dx/cocoa/CCAutoreleasePool.h b/cocos2dx/cocoa/CCAutoreleasePool.h index dc8bbb522d..dc9bec19e8 100644 --- a/cocos2dx/cocoa/CCAutoreleasePool.h +++ b/cocos2dx/cocoa/CCAutoreleasePool.h @@ -29,6 +29,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup base_nodes + * @{ + */ + class CC_DLL CCAutoreleasePool : public CCObject { CCArray* m_pManagedObjectArray; @@ -64,6 +69,9 @@ public: friend class CCAutoreleasePool; }; +// end of base_nodes group +/// @} + NS_CC_END #endif //__AUTORELEASEPOOL_H__ diff --git a/cocos2dx/cocoa/CCDictionary.h b/cocos2dx/cocoa/CCDictionary.h index 1f97c9094f..c6f8e3392f 100644 --- a/cocos2dx/cocoa/CCDictionary.h +++ b/cocos2dx/cocoa/CCDictionary.h @@ -34,6 +34,11 @@ NS_CC_BEGIN class CCDictionary; +/** + * @addtogroup data_structures + * @{ + */ + class CC_DLL CCDictElement { #define MAX_KEY_LEN 256 @@ -190,6 +195,9 @@ private: CCDictType m_eOldDictType; }; +// end of data_structure group +/// @} + NS_CC_END #endif /* __CCDICTIONARY_H__ */ diff --git a/cocos2dx/cocoa/CCGeometry.h b/cocos2dx/cocoa/CCGeometry.h index 6be663ba6b..259ec6d450 100644 --- a/cocos2dx/cocoa/CCGeometry.h +++ b/cocos2dx/cocoa/CCGeometry.h @@ -30,6 +30,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup data_structures + * @{ + */ + typedef float CCFloat; class CC_DLL CCPoint : public CCObject @@ -120,6 +125,9 @@ const CCSize CCSizeZero = CCSizeMake(0,0); /* The "zero" rectangle -- equivalent to CCRectMake(0, 0, 0, 0). */ const CCRect CCRectZero = CCRectMake(0,0,0,0); +// end of data_structure group +/// @} + NS_CC_END #endif // __CCGEMETRY_H__ diff --git a/cocos2dx/cocoa/CCInteger.h b/cocos2dx/cocoa/CCInteger.h index a8b4db49ce..309e5c4c9c 100644 --- a/cocos2dx/cocoa/CCInteger.h +++ b/cocos2dx/cocoa/CCInteger.h @@ -5,6 +5,11 @@ NS_CC_BEGIN +/** + * @addtogroup data_structures + * @{ + */ + class CC_DLL CCInteger : public CCObject { public: @@ -28,6 +33,9 @@ private: int m_nValue; }; +// end of data_structure group +/// @} + NS_CC_END #endif /* __CCINTEGER_H__ */ diff --git a/cocos2dx/cocoa/CCNS.h b/cocos2dx/cocoa/CCNS.h index 10e463dd05..e5d4744120 100644 --- a/cocos2dx/cocoa/CCNS.h +++ b/cocos2dx/cocoa/CCNS.h @@ -28,6 +28,12 @@ THE SOFTWARE. #include "CCGeometry.h" NS_CC_BEGIN + +/** + * @addtogroup data_structures + * @{ + */ + /** @brief Returns a Core Graphics rectangle structure corresponding to the data in a given string. @param pszContent A string object whose contents are of the form "{{x,y},{w, h}}", @@ -64,6 +70,9 @@ CCPoint CC_DLL CCPointFromString(const char* pszContent); */ CCSize CC_DLL CCSizeFromString(const char* pszContent); +// end of data_structure group +/// @} + NS_CC_END #endif // __PLATFOMR_CCNS_H__ diff --git a/cocos2dx/cocoa/CCObject.h b/cocos2dx/cocoa/CCObject.h index 564e16ac16..547308e4a9 100644 --- a/cocos2dx/cocoa/CCObject.h +++ b/cocos2dx/cocoa/CCObject.h @@ -29,6 +29,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup base_nodes + * @{ + */ + class CCZone; class CCObject; class CCNode; @@ -88,6 +93,9 @@ typedef int (CCObject::*SEL_Compare)(CCObject*); #define event_selector(_SELECTOR) (SEL_EventHandler)(&_SELECTOR) #define compare_selector(_SELECTOR) (SEL_Compare)(&_SELECTOR) +// end of base_nodes group +/// @} + NS_CC_END #endif // __CCOBJECT_H__ diff --git a/cocos2dx/cocoa/CCSet.h b/cocos2dx/cocoa/CCSet.h index f6684a2391..6d623ed8c0 100644 --- a/cocos2dx/cocoa/CCSet.h +++ b/cocos2dx/cocoa/CCSet.h @@ -30,6 +30,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup data_structures + * @{ + */ + typedef std::set::iterator CCSetIterator; class CC_DLL CCSet : public CCObject @@ -80,6 +85,9 @@ private: std::set *m_pSet; }; +// end of data_structure group +/// @} + NS_CC_END #endif // __CC_SET_H__ diff --git a/cocos2dx/cocoa/CCString.h b/cocos2dx/cocoa/CCString.h index d9dede8f9d..94912399a0 100644 --- a/cocos2dx/cocoa/CCString.h +++ b/cocos2dx/cocoa/CCString.h @@ -30,6 +30,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup data_structures + * @{ + */ + class CC_DLL CCString : public CCObject { public: @@ -154,6 +159,8 @@ struct CCStringCompare : public std::binary_function* m_pLoadedFileNames; }; +// end of sprite_nodes group +/// @} + NS_CC_END #endif // __SPRITE_CCSPRITE_FRAME_CACHE_H__ diff --git a/cocos2dx/support/CCPointExtension.h b/cocos2dx/support/CCPointExtension.h index e99986d63b..37b0b533a5 100644 --- a/cocos2dx/support/CCPointExtension.h +++ b/cocos2dx/support/CCPointExtension.h @@ -48,6 +48,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup data_structures + * @{ + */ + /** Helper macro that creates a CCPoint @return CCPoint @since v0.7.2 @@ -329,6 +334,9 @@ ccpIntersectPoint returns the intersection point of line A-B, C-D */ CCPoint CC_DLL ccpIntersectPoint(const CCPoint& A, const CCPoint& B, const CCPoint& C, const CCPoint& D); +// end of data_structures group +/// @} + NS_CC_END #endif // __SUPPORT_CGPOINTEXTENSION_H__ diff --git a/cocos2dx/support/CCProfiling.h b/cocos2dx/support/CCProfiling.h index 93d071ca68..3a6b902c47 100644 --- a/cocos2dx/support/CCProfiling.h +++ b/cocos2dx/support/CCProfiling.h @@ -33,6 +33,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup global + * @{ + */ + class CCProfilingTimer; /** CCProfiler @@ -95,6 +100,9 @@ extern bool kCCProfilerCategorySprite; extern bool kCCProfilerCategoryBatchSprite; extern bool kCCProfilerCategoryParticles; +// end of global group +/// @} + NS_CC_END #endif // __SUPPORT_CCPROFILING_H__ diff --git a/cocos2dx/support/CCUserDefault.h b/cocos2dx/support/CCUserDefault.h index 5be1e834ee..9c845f3f7f 100644 --- a/cocos2dx/support/CCUserDefault.h +++ b/cocos2dx/support/CCUserDefault.h @@ -29,6 +29,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup data_storage + * @{ + */ + /** * CCUserDefault acts as a tiny database. You can save and get base type values by it. * For example, setBoolForKey("played", true) will add a bool value true into the database. @@ -112,6 +117,9 @@ private: static bool m_sbIsFilePathInitialized; }; +// end of data_storage group +/// @} + NS_CC_END #endif // __SUPPORT_CCUSERDEFAULT_H__ diff --git a/cocos2dx/support/CCVertex.h b/cocos2dx/support/CCVertex.h index 5e55951b3a..7ea150faaa 100644 --- a/cocos2dx/support/CCVertex.h +++ b/cocos2dx/support/CCVertex.h @@ -29,6 +29,11 @@ NS_CC_BEGIN +/** + * @addtogroup data_structures + * @{ + */ + /** @file CCVertex.h */ /** converts a line to a polygon */ @@ -40,6 +45,9 @@ bool CC_DLL ccVertexLineIntersect(float Ax, float Ay, float Cx, float Cy, float Dx, float Dy, float *T); +// end of data_structures group +/// @} + NS_CC_END #endif /* __CCVERTEX_H__ */ diff --git a/cocos2dx/support/TransformUtils.h b/cocos2dx/support/TransformUtils.h index 67d559ecce..7ea972943e 100644 --- a/cocos2dx/support/TransformUtils.h +++ b/cocos2dx/support/TransformUtils.h @@ -26,7 +26,7 @@ THE SOFTWARE. #ifndef __SUPPORT_TRANSFORM_UTILS_H__ #define __SUPPORT_TRANSFORM_UTILS_H__ -///@todo +// todo: // when in MAC or windows, it includes #include "CCGL.h" diff --git a/cocos2dx/text_input_node/CCIMEDelegate.h b/cocos2dx/text_input_node/CCIMEDelegate.h index 6a324fc0cf..bc70383344 100644 --- a/cocos2dx/text_input_node/CCIMEDelegate.h +++ b/cocos2dx/text_input_node/CCIMEDelegate.h @@ -29,6 +29,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup input + * @{ + */ + typedef struct { CCRect begin; // the soft keyboard rectangle when animatin begin @@ -98,6 +103,9 @@ protected: CCIMEDelegate(); }; +// end of input group +/// @} + NS_CC_END #endif // __CC_IME_DELEGATE_H__ diff --git a/cocos2dx/text_input_node/CCIMEDispatcher.h b/cocos2dx/text_input_node/CCIMEDispatcher.h index 6ca7096ce2..54fdaeb137 100644 --- a/cocos2dx/text_input_node/CCIMEDispatcher.h +++ b/cocos2dx/text_input_node/CCIMEDispatcher.h @@ -29,6 +29,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup input + * @{ + */ + /** @brief Input Method Edit Message Dispatcher. */ @@ -98,6 +103,9 @@ private: Impl * m_pImpl; }; +// end of input group +/// @} + NS_CC_END #endif // __CC_IME_DISPATCHER_H__ diff --git a/cocos2dx/text_input_node/CCTextFieldTTF.h b/cocos2dx/text_input_node/CCTextFieldTTF.h index 5643316b2f..da3d590d94 100644 --- a/cocos2dx/text_input_node/CCTextFieldTTF.h +++ b/cocos2dx/text_input_node/CCTextFieldTTF.h @@ -33,6 +33,11 @@ NS_CC_BEGIN class CCTextFieldTTF; +/** + * @addtogroup input + * @{ + */ + class CC_DLL CCTextFieldDelegate { public: @@ -156,6 +161,9 @@ private: LengthStack * m_pLens; }; +// end of input group +/// @} + NS_CC_END #endif // __CC_TEXT_FIELD_H__ \ No newline at end of file diff --git a/cocos2dx/textures/CCTexture2D.h b/cocos2dx/textures/CCTexture2D.h index 43fca76341..1c3810eb8c 100644 --- a/cocos2dx/textures/CCTexture2D.h +++ b/cocos2dx/textures/CCTexture2D.h @@ -35,6 +35,11 @@ NS_CC_BEGIN class CCImage; +/** + * @addtogroup textures + * @{ + */ + //CONSTANTS: /** @typedef CCTexture2DPixelFormat @@ -281,6 +286,9 @@ private: CC_SYNTHESIZE(ccResolutionType, m_eResolutionType, ResolutionType); }; +// end of textures group +/// @} + NS_CC_END #endif //__CCTEXTURE2D_H__ diff --git a/cocos2dx/textures/CCTextureAtlas.h b/cocos2dx/textures/CCTextureAtlas.h index dd352aa57d..47686f5bcf 100644 --- a/cocos2dx/textures/CCTextureAtlas.h +++ b/cocos2dx/textures/CCTextureAtlas.h @@ -36,6 +36,11 @@ NS_CC_BEGIN class CCTexture2D; +/** + * @addtogroup textures + * @{ + */ + /** @brief A class that implements a Texture Atlas. Supported features: * The atlas file can be a PVRTC, PNG or any other fomrat supported by Texture2D @@ -206,6 +211,9 @@ private: #endif }; +// end of textures group +/// @} + NS_CC_END #endif //__CCTEXTURE_ATLAS_H__ diff --git a/cocos2dx/textures/CCTextureCache.h b/cocos2dx/textures/CCTextureCache.h index 7cb799879e..ee3335c3ba 100644 --- a/cocos2dx/textures/CCTextureCache.h +++ b/cocos2dx/textures/CCTextureCache.h @@ -43,6 +43,11 @@ NS_CC_BEGIN class CCLock; class CCImage; +/** + * @addtogroup textures + * @{ + */ + /** @brief Singleton that handles the loading of textures * Once the texture is loaded, the next time it will return * a reference of the previously loaded texture reducing GPU & CPU memory @@ -55,7 +60,7 @@ protected: private: - // @todo void addImageWithAsyncObject(CCAsyncObject* async); + /// todo: void addImageWithAsyncObject(CCAsyncObject* async); void addImageAsyncCallBack(float dt); public: @@ -100,7 +105,7 @@ public: * If "key" is nil, then a new texture will be created each time. * @since v0.8 */ - // @todo CGImageRef CCTexture2D* addCGImage(CGImageRef image, string & key); + // todo: CGImageRef CCTexture2D* addCGImage(CGImageRef image, string & key); /** Returns a Texture2D object given an UIImage image * If the image was not previously loaded, it will create a new CCTexture2D object and it will return it. * Otherwise it will return a reference of a previously loaded image @@ -226,6 +231,9 @@ protected: #endif +// end of textures group +/// @} + NS_CC_END #endif //__CCTEXTURE_CACHE_H__ diff --git a/cocos2dx/textures/CCTexturePVR.h b/cocos2dx/textures/CCTexturePVR.h index 0f2b328df6..eaa8c26c7f 100644 --- a/cocos2dx/textures/CCTexturePVR.h +++ b/cocos2dx/textures/CCTexturePVR.h @@ -33,6 +33,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup textures + * @{ + */ + /** @brief Structure which can tell where mimap begins and how long is it */ @@ -113,6 +118,9 @@ protected: CCTexture2DPixelFormat m_eFormat; }; +// end of textures group +/// @} + NS_CC_END diff --git a/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h b/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h index 5ca90419b3..ab658b39a4 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h +++ b/cocos2dx/tileMap_parallax_nodes/CCParallaxNode.h @@ -33,6 +33,11 @@ NS_CC_BEGIN struct _ccArray; +/** + * @addtogroup tilemap_parallax_nodes + * @{ + */ + /** @brief CCParallaxNode: A node that simulates a parallax scroller The children will be moved faster / slower than the parent according the the parallax ratio. @@ -65,6 +70,9 @@ protected: CCPoint m_tLastPosition; }; +// end of tilemap_parallax_nodes group +/// @} + NS_CC_END #endif //__CCPARALLAX_NODE_H__ diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h index 4b632975d7..018193f690 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.h @@ -37,6 +37,11 @@ class CCTMXLayerInfo; class CCTMXTilesetInfo; struct _ccCArray; +/** + * @addtogroup tilemap_parallax_nodes + * @{ + */ + /** @brief CCTMXLayer represents the TMX layer. It is a subclass of CCSpriteBatchNode. By default the tiles are rendered using a CCTextureAtlas. @@ -198,6 +203,9 @@ protected: float m_fContentScaleFactor; }; +// end of tilemap_parallax_nodes group +/// @} + NS_CC_END #endif //__CCTMX_LAYER_H__ diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXObjectGroup.h b/cocos2dx/tileMap_parallax_nodes/CCTMXObjectGroup.h index 04bbc13577..667784c2a4 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXObjectGroup.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXObjectGroup.h @@ -34,6 +34,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup tilemap_parallax_nodes + * @{ + */ + /** @brief CCTMXObjectGroup represents the TMX object group. @since v0.99.0 */ @@ -64,6 +69,9 @@ protected: std::string m_sGroupName; }; +// end of tilemap_parallax_nodes group +/// @} + NS_CC_END #endif //__CCTMX_OBJECT_GROUP_H__ \ No newline at end of file diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h index 72aa5a31ee..789ce178dc 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXTiledMap.h @@ -37,6 +37,11 @@ class CCTMXLayerInfo; class CCTMXTilesetInfo; class CCTMXMapInfo; +/** + * @addtogroup tilemap_parallax_nodes + * @{ + */ + /** Possible oritentations of the TMX map */ enum { @@ -161,6 +166,9 @@ protected: }; +// end of tilemap_parallax_nodes group +/// @} + NS_CC_END #endif //__CCTMX_TILE_MAP_H__ diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.h b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.h index 13fcee038c..fddc70fc2a 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXXMLParser.h @@ -47,6 +47,11 @@ class CCTMXObjectGroup; * */ +/** + * @addtogroup tilemap_parallax_nodes + * @{ + */ + enum { TMXLayerAttribNone = 1 << 0, TMXLayerAttribBase64 = 1 << 1, @@ -206,6 +211,9 @@ protected: CCDictionary* m_pTileProperties; }; +// end of tilemap_parallax_nodes group +/// @} + NS_CC_END #endif diff --git a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h index 76df642f35..822b4b34ef 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h +++ b/cocos2dx/tileMap_parallax_nodes/CCTileMapAtlas.h @@ -33,6 +33,12 @@ NS_CC_BEGIN struct sImageTGA; class CCDictionary; + +/** + * @addtogroup tilemap_parallax_nodes + * @{ + */ + /** @brief CCTileMapAtlas is a subclass of CCAtlasNode. It knows how to render a map based of tiles. @@ -93,6 +99,9 @@ protected: int m_nItemsToRender; }; +// end of tilemap_parallax_nodes group +/// @} + NS_CC_END #endif //__CCTILE_MAP_ATLAS__ diff --git a/cocos2dx/touch_dispatcher/CCTouch.h b/cocos2dx/touch_dispatcher/CCTouch.h index 84bc022703..f738464abe 100644 --- a/cocos2dx/touch_dispatcher/CCTouch.h +++ b/cocos2dx/touch_dispatcher/CCTouch.h @@ -30,6 +30,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup input + * @{ + */ + class CC_DLL CCTouch : public CCObject { public: @@ -63,6 +68,9 @@ class CC_DLL CCEvent : public CCObject { }; +// end of input group +/// @} + NS_CC_END #endif // __PLATFORM_TOUCH_H__ diff --git a/cocos2dx/touch_dispatcher/CCTouchDelegateProtocol.h b/cocos2dx/touch_dispatcher/CCTouchDelegateProtocol.h index 94ddcbb1cc..6770d1e421 100644 --- a/cocos2dx/touch_dispatcher/CCTouchDelegateProtocol.h +++ b/cocos2dx/touch_dispatcher/CCTouchDelegateProtocol.h @@ -35,7 +35,12 @@ class CCTouch; class CCEvent; class CCSet; class CCTouchDispatcher; - + +/** + * @addtogroup input + * @{ + */ + class CC_DLL CCTouchDelegate { public: @@ -102,6 +107,9 @@ public: virtual void ccTouchesCancelled(CCSet *pTouches, CCEvent *pEvent) {CC_UNUSED_PARAM(pTouches); CC_UNUSED_PARAM(pEvent);} }; +// end of input group +/// @} + NS_CC_END #endif // __TOUCH_DISPATHCHER_CCTOUCH_DELEGATE_PROTOCOL_H__ diff --git a/cocos2dx/touch_dispatcher/CCTouchDispatcher.h b/cocos2dx/touch_dispatcher/CCTouchDispatcher.h index b74d7c575c..b2b1de685d 100644 --- a/cocos2dx/touch_dispatcher/CCTouchDispatcher.h +++ b/cocos2dx/touch_dispatcher/CCTouchDispatcher.h @@ -32,6 +32,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup input + * @{ + */ + typedef enum { ccTouchSelectorBeganBit = 1 << 0, @@ -165,6 +170,9 @@ protected: struct ccTouchHandlerHelperData m_sHandlerHelperData[ccTouchMax]; }; +// end of input group +/// @} + NS_CC_END #endif // __TOUCH_DISPATCHER_CCTOUCH_DISPATCHER_H__ diff --git a/cocos2dx/touch_dispatcher/CCTouchHandler.h b/cocos2dx/touch_dispatcher/CCTouchHandler.h index 012e6d32a1..89b9d02a2a 100644 --- a/cocos2dx/touch_dispatcher/CCTouchHandler.h +++ b/cocos2dx/touch_dispatcher/CCTouchHandler.h @@ -33,6 +33,11 @@ THE SOFTWARE. NS_CC_BEGIN +/** + * @addtogroup input + * @{ + */ + /** CCTouchHandler Object than contains the delegate and priority of the event handler. @@ -110,6 +115,9 @@ protected: CCSet *m_pClaimedTouches; }; +// end of input group +/// @} + NS_CC_END #endif // __TOUCH_DISPATCHER_CCTOUCH_HANDLER_H__ diff --git a/doxygen/doxygen.cocos2d-x b/doxygen/doxygen.cocos2d-x index d803362032..156fff923d 100644 --- a/doxygen/doxygen.cocos2d-x +++ b/doxygen/doxygen.cocos2d-x @@ -1,4 +1,4 @@ -# Doxyfile 1.7.4 +# Doxyfile 1.8.1.1 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project @@ -22,8 +22,9 @@ DOXYFILE_ENCODING = UTF-8 -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. +# The PROJECT_NAME tag is a single word (or sequence of words) that should +# identify the project. Note that if you do not use Doxywizard you need +# to put quotes around the project name if it contains spaces. PROJECT_NAME = cocos2d-x @@ -31,7 +32,7 @@ PROJECT_NAME = cocos2d-x # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = 1.0.1-x-0.11.0 +PROJECT_NUMBER = 2.1 # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer @@ -44,7 +45,7 @@ PROJECT_BRIEF = # exceed 55 pixels and the maximum width should not exceed 200 pixels. # Doxygen will copy the logo to the output directory. -PROJECT_LOGO = +PROJECT_LOGO = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. @@ -204,6 +205,13 @@ TAB_SIZE = 4 ALIASES = +# This tag can be used to specify a number of word-keyword mappings (TCL only). +# A mapping has the form "name=value". For example adding +# "class=itcl::class" will allow you to use the command class in the +# itcl::class meaning. + +TCL_SUBST = + # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list @@ -242,6 +250,15 @@ OPTIMIZE_OUTPUT_VHDL = NO EXTENSION_MAPPING = +# If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all +# comments according to the Markdown format, which allows for more readable +# documentation. See http://daringfireball.net/projects/markdown/ for details. +# The output of markdown processing is further processed by doxygen, so you +# can mix doxygen, HTML, and XML commands with Markdown formatting. +# Disable only in case of backward compatibilities issues. + +MARKDOWN_SUPPORT = YES + # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and @@ -293,6 +310,15 @@ SUBGROUPING = YES INLINE_GROUPED_CLASSES = NO +# When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and +# unions with only public data fields will be shown inline in the documentation +# of the scope in which they are defined (i.e. file, namespace, or group +# documentation), provided this scope is documented. If set to NO (the default), +# structs, classes, and unions are shown on a separate page (for HTML and Man +# pages) or section (for LaTeX and RTF). + +INLINE_SIMPLE_STRUCTS = NO + # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum # is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct @@ -315,10 +341,21 @@ TYPEDEF_HIDES_STRUCT = YES # a logarithmic scale so increasing the size by one will roughly double the # memory usage. The cache size is given by this formula: # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, -# corresponding to a cache size of 2^16 = 65536 symbols +# corresponding to a cache size of 2^16 = 65536 symbols. SYMBOL_CACHE_SIZE = 0 +# Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be +# set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given +# their name and scope. Since this can be an expensive process and often the +# same symbol appear multiple times in the code, doxygen keeps a cache of +# pre-resolved symbols. If the cache is too small doxygen will become slower. +# If the cache is too large, memory is wasted. The cache size is given by this +# formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols. + +LOOKUP_CACHE_SIZE = 0 + #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- @@ -335,6 +372,11 @@ EXTRACT_ALL = YES EXTRACT_PRIVATE = NO +# If the EXTRACT_PACKAGE tag is set to YES all members with package or internal +# scope will be included in the documentation. + +EXTRACT_PACKAGE = NO + # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. @@ -522,12 +564,6 @@ MAX_INITIALIZER_LINES = 30 SHOW_USED_FILES = YES -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. @@ -552,13 +588,23 @@ FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated -# output files in an output format independent way. The create the layout file +# output files in an output format independent way. To create the layout file # that represents doxygen's defaults, run doxygen with the -l option. # You can optionally specify a file name after the option, if omitted # DoxygenLayout.xml will be used as the name of the layout file. LAYOUT_FILE = +# The CITE_BIB_FILES tag can be used to specify one or more bib files +# containing the references data. This must be a list of .bib files. The +# .bib extension is automatically appended if omitted. Using this command +# requires the bibtex tool to be installed. See also +# http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style +# of the bibliography can be controlled using LATEX_BIB_STYLE. To use this +# feature you need bibtex and perl available in the search path. + +CITE_BIB_FILES = + #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- @@ -620,7 +666,7 @@ WARN_LOGFILE = # with spaces. INPUT = ../CocosDenshion/include \ - ../cocos2dx/include \ + ../cocos2dx \ ../doxygen \ ../lua/cocos2dx_support \ ../cocos2dx/platform @@ -649,14 +695,16 @@ FILE_PATTERNS = *.h RECURSIVE = YES -# The EXCLUDE tag can be used to specify files and/or directories that should +# The EXCLUDE tag can be used to specify files and/or directories that should be # excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. +# subdirectory from a directory tree whose root is specified with the INPUT tag. +# Note that relative paths are relative to the directory from which doxygen is +# run. EXCLUDE = ../cocos2dx/platform/third_party \ ../cocos2dx/include/CCTMXXMLParser.h -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or +# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded # from the input. @@ -668,7 +716,13 @@ EXCLUDE_SYMLINKS = NO # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* -EXCLUDE_PATTERNS = .svn +EXCLUDE_PATTERNS = .svn \ + kazmath \ + FontLabel \ + proj.ios \ + data_support \ + image_support \ + zip_support # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the @@ -676,7 +730,8 @@ EXCLUDE_PATTERNS = .svn # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test -EXCLUDE_SYMBOLS = +EXCLUDE_SYMBOLS = ccArray \ + ccCArray # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see @@ -755,7 +810,7 @@ INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. +# fragments. Normal C, C++ and Fortran comments will always remain visible. STRIP_CODE_COMMENTS = YES @@ -838,13 +893,13 @@ HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a -# standard header. Note that when using a custom header you are responsible +# standard header. Note that when using a custom header you are responsible # for the proper inclusion of any scripts and style sheets that doxygen # needs, which is dependent on the configuration options used. -# It is adviced to generate a default header using "doxygen -w html +# It is advised to generate a default header using "doxygen -w html # header.html footer.html stylesheet.css YourConfigFile" and then modify # that header. Note that the header is subject to change so you typically -# have to redo this when upgrading to a newer version of doxygen or when +# have to redo this when upgrading to a newer version of doxygen or when # changing the value of configuration settings such as GENERATE_TREEVIEW! HTML_HEADER = @@ -860,7 +915,7 @@ HTML_FOOTER = # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! +# style sheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = @@ -874,7 +929,7 @@ HTML_STYLESHEET = HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. -# Doxygen will adjust the colors in the stylesheet and background images +# Doxygen will adjust the colors in the style sheet and background images # according to this color. Hue is specified as an angle on a colorwheel, # see http://en.wikipedia.org/wiki/Hue for more information. # For instance the value 0 represents red, 60 is yellow, 120 is green, @@ -904,20 +959,23 @@ HTML_COLORSTYLE_GAMMA = 80 HTML_TIMESTAMP = YES -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the -# page has loaded. For this to work a browser that supports -# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox -# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). +# page has loaded. HTML_DYNAMIC_SECTIONS = NO +# With HTML_INDEX_NUM_ENTRIES one can control the preferred number of +# entries shown in the various tree structured indices initially; the user +# can expand and collapse entries dynamically later on. Doxygen will expand +# the tree to such a level that at most the specified number of entries are +# visible (unless a fully collapsed tree already exceeds this amount). +# So setting the number of entries 1 will produce a full collapsed tree by +# default. 0 is a special value representing an infinite number of entries +# and will result in a full expanded tree by default. + +HTML_INDEX_NUM_ENTRIES = 100 + # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). @@ -1069,33 +1127,32 @@ GENERATE_ECLIPSEHELP = NO ECLIPSE_DOC_ID = org.doxygen.Project -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. +# The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) +# at top of each HTML page. The value NO (the default) enables the index and +# the value YES disables it. Since the tabs have the same information as the +# navigation tree you can set this option to NO if you already set +# GENERATE_TREEVIEW to YES. DISABLE_INDEX = NO -# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values -# (range [0,1..20]) that doxygen will group on one line in the generated HTML -# documentation. Note that a value of 0 will completely suppress the enum -# values from appearing in the overview section. - -ENUM_VALUES_PER_LINE = 4 - # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to YES, a side panel will be generated # containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). -# Windows users are probably better off using the HTML help feature. +# Windows users are probably better off using the HTML help feature. +# Since the tree basically has the same information as the tab index you +# could consider to set DISABLE_INDEX to NO when enabling this option. -GENERATE_TREEVIEW = NO +GENERATE_TREEVIEW = YES -# By enabling USE_INLINE_TREES, doxygen will generate the Groups, Directories, -# and Class Hierarchy pages using a tree view instead of an ordered list. +# The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values +# (range [0,1..20]) that doxygen will group on one line in the generated HTML +# documentation. Note that a value of 0 will completely suppress the enum +# values from appearing in the overview section. -USE_INLINE_TREES = NO +ENUM_VALUES_PER_LINE = 4 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree @@ -1128,7 +1185,7 @@ FORMULA_TRANSPARENT = YES # (see http://www.mathjax.org) which uses client side Javascript for the # rendering instead of using prerendered bitmaps. Use this if you do not # have LaTeX installed or if you want to formulas look prettier in the HTML -# output. When enabled you also need to install MathJax separately and +# output. When enabled you may also need to install MathJax separately and # configure the path to it using the MATHJAX_RELPATH option. USE_MATHJAX = NO @@ -1137,13 +1194,18 @@ USE_MATHJAX = NO # HTML output directory using the MATHJAX_RELPATH option. The destination # directory should contain the MathJax.js script. For instance, if the mathjax # directory is located at the same level as the HTML output directory, then -# MATHJAX_RELPATH should be ../mathjax. The default value points to the -# mathjax.org site, so you can quickly see the result without installing -# MathJax, but it is strongly recommended to install a local copy of MathJax -# before deployment. +# MATHJAX_RELPATH should be ../mathjax. The default value points to +# the MathJax Content Delivery Network so you can quickly see the result without +# installing MathJax. However, it is strongly recommended to install a local +# copy of MathJax from http://www.mathjax.org before deployment. MATHJAX_RELPATH = http://www.mathjax.org/mathjax +# The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension +# names that should be enabled during MathJax rendering. + +MATHJAX_EXTENSIONS = + # When the SEARCHENGINE tag is enabled doxygen will generate a search box # for the HTML output. The underlying search engine uses javascript # and DHTML and should work on any modern browser. Note that when using @@ -1257,6 +1319,12 @@ LATEX_HIDE_INDICES = NO LATEX_SOURCE_CODE = NO +# The LATEX_BIB_STYLE tag can be used to specify the style to use for the +# bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See +# http://en.wikipedia.org/wiki/BibTeX for more info. + +LATEX_BIB_STYLE = plain + #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- @@ -1288,7 +1356,7 @@ COMPACT_RTF = NO RTF_HYPERLINKS = NO -# Load stylesheet definitions from file. Syntax is similar to doxygen's +# Load style sheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. @@ -1464,7 +1532,13 @@ PREDEFINED = "CC_PROPERTY_READONLY(varType, varName, funName)=protec "CC_SYNTHESIZE_PASS_BY_REF(varType, varName, funName)=protected: varType varName;\n /** get##funName */\n public: virtual const varType& get##funName(void);\n /** set#funName */\n public: virtual void set##funName(const varType& var);" \ "CC_SYNTHESIZE_RETAIN(varType, varName, funName)=protected: varType varName;\n /** get##funName */\n public: virtual varType get##funName(void);\n /** set##funName */\n public: virtual void set##funName(varType var);" \ "CC_SYNTHESIZE_READONLY(varType, varName, funName)=protected: varType varName;\n /** get##funName */\n public: virtual varType get##funName(void);" \ - "CC_SYNTHESIZE_READONLY_PASS_BY_REF(varType, varName, funName)=protected: varType varName;\n /** get##funName */ \n public: virtual const varType& get##funName(void);" + "CC_SYNTHESIZE_READONLY_PASS_BY_REF(varType, varName, funName)=protected: varType varName;\n /** get##funName */ \n public: virtual const varType& get##funName(void);" \ + "NS_CC_BEGIN=namespace cocos2d {" \ + "NS_CC_END=}" \ + "USING_NS_CC=using namsspace cocos2d" \ + "NS_CC_EXT_BEGIN=namespace cocos2d { namespace extension {" \ + "NS_CC_EXT_END=}}" \ + "USING_NS_CC_EXT=using namespace cocos2d::extension" # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. @@ -1485,20 +1559,16 @@ SKIP_FUNCTION_MACROS = NO # Configuration::additions related to external references #--------------------------------------------------------------------------- -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: +# The TAGFILES option can be used to specify one or more tagfiles. For each +# tag file the location of the external documentation should be added. The +# format of a tag file without this location is as follows: # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. +# where "loc1" and "loc2" can be relative or absolute paths +# or URLs. Note that each tag file must have a unique name (where the name does +# NOT include the path). If a tag file is not located in the directory in which +# doxygen is run, you must also specify the path to the tagfile here. TAGFILES = @@ -1566,13 +1636,12 @@ HAVE_DOT = NO DOT_NUM_THREADS = 0 -# By default doxygen will write a font called Helvetica to the output -# directory and reference it in all dot files that doxygen generates. -# When you want a differently looking font you can specify the font name -# using DOT_FONTNAME. You need to make sure dot is able to find the font, -# which can be done by putting it in a standard location or by setting the -# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory -# containing the font. +# By default doxygen will use the Helvetica font for all dot files that +# doxygen generates. When you want a differently looking font you can specify +# the font name using DOT_FONTNAME. You need to make sure dot is able to find +# the font, which can be done by putting it in a standard location or by setting +# the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the +# directory containing the font. DOT_FONTNAME = FreeSans.ttf @@ -1581,17 +1650,16 @@ DOT_FONTNAME = FreeSans.ttf DOT_FONTSIZE = 10 -# By default doxygen will tell dot to use the output directory to look for the -# FreeSans.ttf font (which doxygen will put there itself). If you specify a -# different font using DOT_FONTNAME you can set the path where dot -# can find it using this tag. +# By default doxygen will tell dot to use the Helvetica font. +# If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to +# set the path where dot can find it. DOT_FONTPATH = # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. +# CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES @@ -1613,6 +1681,15 @@ GROUP_GRAPHS = YES UML_LOOK = NO +# If the UML_LOOK tag is enabled, the fields and methods are shown inside +# the class node. If there are many fields or methods and many nodes the +# graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS +# threshold limits the number of items for each type to make the size more +# managable. Set this to 0 for no limit. Note that the threshold may be +# exceeded by 50% before the limit is enforced. + +UML_LIMIT_NUM_FIELDS = 10 + # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. @@ -1653,7 +1730,7 @@ CALLER_GRAPH = NO GRAPHICAL_HIERARCHY = YES -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES +# If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. @@ -1662,10 +1739,21 @@ DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are svg, png, jpg, or gif. -# If left blank png will be used. +# If left blank png will be used. If you choose svg you need to set +# HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible in IE 9+ (other browsers do not have this requirement). DOT_IMAGE_FORMAT = png +# If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to +# enable generation of interactive SVG images that allow zooming and panning. +# Note that this requires a modern browser other than Internet Explorer. +# Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you +# need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files +# visible. Older versions of IE do not have SVG support. + +INTERACTIVE_SVG = NO + # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. From 5cc1f7d230deeebe2875e940935a9fd965fb0b0a Mon Sep 17 00:00:00 2001 From: minggo Date: Thu, 21 Jun 2012 11:42:49 +0800 Subject: [PATCH 236/257] fixed #1338:stop animation when entering background and start animation when comming to foreground --- CocosDenshion/ios/CDAudioManager.m | 29 +++++++++++++++----------- CocosDenshion/ios/CDOpenALSupport.m | 2 ++ CocosDenshion/ios/CocosDenshion.m | 13 ++++++------ CocosDenshion/ios/SimpleAudioEngine.mm | 18 ++++++++-------- HelloLua/Classes/AppDelegate.cpp | 4 ++-- HelloWorld/Classes/AppDelegate.cpp | 4 ++-- testjs/Classes/AppDelegate.cpp | 4 ++-- tests/AppDelegate.cpp | 4 ++-- 8 files changed, 42 insertions(+), 36 deletions(-) diff --git a/CocosDenshion/ios/CDAudioManager.m b/CocosDenshion/ios/CDAudioManager.m index 7df113c5ec..80dc24243b 100644 --- a/CocosDenshion/ios/CDAudioManager.m +++ b/CocosDenshion/ios/CDAudioManager.m @@ -113,6 +113,10 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised"; } -(void) resume { + if (!self->systemPaused) { + return; + } + [audioSourcePlayer play]; } @@ -542,17 +546,18 @@ static BOOL configured = FALSE; { [self.backgroundMusic load:filePath]; - if (!willPlayBackgroundMusic || _mute) { - CDLOGINFO(@"Denshion::CDAudioManager - play bgm aborted because audio is not exclusive or sound is muted"); - return; - } - - if (loop) { - [self.backgroundMusic setNumberOfLoops:-1]; - } else { - [self.backgroundMusic setNumberOfLoops:0]; - } - [self.backgroundMusic play]; + if (loop) { + [self.backgroundMusic setNumberOfLoops:-1]; + } else { + [self.backgroundMusic setNumberOfLoops:0]; + } + + if (!willPlayBackgroundMusic || _mute) { + CDLOGINFO(@"Denshion::CDAudioManager - play bgm aborted because audio is not exclusive or sound is muted"); + return; + } + + [self.backgroundMusic play]; } -(void) stopBackgroundMusic @@ -713,7 +718,7 @@ static BOOL configured = FALSE; [self audioSessionResumed]; } -#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 40000 +#if __CC_PLATFORM_IOS >= 40000 -(void) endInterruptionWithFlags:(NSUInteger)flags { CDLOGINFO(@"Denshion::CDAudioManager - interruption ended with flags %i",flags); if (flags == AVAudioSessionInterruptionFlags_ShouldResume) { diff --git a/CocosDenshion/ios/CDOpenALSupport.m b/CocosDenshion/ios/CDOpenALSupport.m index ca10eb5e8c..22eb5a51d7 100644 --- a/CocosDenshion/ios/CDOpenALSupport.m +++ b/CocosDenshion/ios/CDOpenALSupport.m @@ -88,6 +88,7 @@ void* CDloadWaveAudioData(CFURLRef inFileURL, ALsizei *outDataSize, ALenum *outD theData = malloc(dataSize); if (theData) { + memset(theData, 0, dataSize); AudioFileReadBytes(afid, false, 0, &dataSize, theData); if(err == noErr) { @@ -195,6 +196,7 @@ void* CDloadCafAudioData(CFURLRef inFileURL, ALsizei *outDataSize, ALenum *outDa theData = malloc(dataSize); if (theData) { + memset(theData, 0, dataSize); AudioBufferList theDataBuffer; theDataBuffer.mNumberBuffers = 1; theDataBuffer.mBuffers[0].mDataByteSize = dataSize; diff --git a/CocosDenshion/ios/CocosDenshion.m b/CocosDenshion/ios/CocosDenshion.m index 2efece4c29..8e8cd9c8cc 100644 --- a/CocosDenshion/ios/CocosDenshion.m +++ b/CocosDenshion/ios/CocosDenshion.m @@ -521,7 +521,7 @@ static BOOL _mixerRateSet = NO; if (soundId >= bufferTotal) { //Need to resize the buffers int requiredIncrement = CD_BUFFERS_INCREMENT; - while (bufferTotal + requiredIncrement <= soundId) { + while (bufferTotal + requiredIncrement < soundId) { requiredIncrement += CD_BUFFERS_INCREMENT; } CDLOGINFO(@"Denshion::CDSoundEngine - attempting to resize buffers by %i for sound %i",requiredIncrement,soundId); @@ -1379,12 +1379,11 @@ static BOOL _mixerRateSet = NO; @synthesize filePath, soundId; -(id) init:(int) theSoundId filePath:(const NSString *) theFilePath { - if ((self = [super init])) { - soundId = theSoundId; - filePath = [theFilePath copy];//TODO: is retain necessary or does copy set retain count - [filePath retain]; - } - return self; + if ((self = [super init])) { + soundId = theSoundId; + filePath = [theFilePath copy]; + } + return self; } -(void) dealloc { diff --git a/CocosDenshion/ios/SimpleAudioEngine.mm b/CocosDenshion/ios/SimpleAudioEngine.mm index 175b97f122..24e5a5f9ab 100644 --- a/CocosDenshion/ios/SimpleAudioEngine.mm +++ b/CocosDenshion/ios/SimpleAudioEngine.mm @@ -169,7 +169,7 @@ void SimpleAudioEngine::end() s_pEngine = NULL; } - static_end(); + static_end(); } void SimpleAudioEngine::preloadBackgroundMusic(const char* pszFilePath) @@ -184,42 +184,42 @@ void SimpleAudioEngine::playBackgroundMusic(const char* pszFilePath, bool bLoop) void SimpleAudioEngine::stopBackgroundMusic(bool bReleaseData) { - static_stopBackgroundMusic(); + static_stopBackgroundMusic(); } void SimpleAudioEngine::pauseBackgroundMusic() { - static_pauseBackgroundMusic(); + static_pauseBackgroundMusic(); } void SimpleAudioEngine::resumeBackgroundMusic() { - static_resumeBackgroundMusic(); + static_resumeBackgroundMusic(); } void SimpleAudioEngine::rewindBackgroundMusic() { - static_rewindBackgroundMusic(); + static_rewindBackgroundMusic(); } bool SimpleAudioEngine::willPlayBackgroundMusic() { - return static_willPlayBackgroundMusic(); + return static_willPlayBackgroundMusic(); } bool SimpleAudioEngine::isBackgroundMusicPlaying() { - return static_isBackgroundMusicPlaying(); + return static_isBackgroundMusicPlaying(); } float SimpleAudioEngine::getBackgroundMusicVolume() { - return static_getBackgroundMusicVolume(); + return static_getBackgroundMusicVolume(); } void SimpleAudioEngine::setBackgroundMusicVolume(float volume) { - static_setBackgroundMusicVolume(volume); + static_setBackgroundMusicVolume(volume); } float SimpleAudioEngine::getEffectsVolume() diff --git a/HelloLua/Classes/AppDelegate.cpp b/HelloLua/Classes/AppDelegate.cpp index 1eae5c1570..e992b52762 100644 --- a/HelloLua/Classes/AppDelegate.cpp +++ b/HelloLua/Classes/AppDelegate.cpp @@ -57,13 +57,13 @@ bool AppDelegate::applicationDidFinishLaunching() // This function will be called when the app is inactive. When comes a phone call,it's be invoked too void AppDelegate::applicationDidEnterBackground() { - CCDirector::sharedDirector()->pause(); + CCDirector::sharedDirector()->stopAnimation(); SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); } // this function will be called when the app is active again void AppDelegate::applicationWillEnterForeground() { - CCDirector::sharedDirector()->resume(); + CCDirector::sharedDirector()->startAnimation(); SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); } diff --git a/HelloWorld/Classes/AppDelegate.cpp b/HelloWorld/Classes/AppDelegate.cpp index 65e92b315f..db19511cc8 100644 --- a/HelloWorld/Classes/AppDelegate.cpp +++ b/HelloWorld/Classes/AppDelegate.cpp @@ -37,7 +37,7 @@ bool AppDelegate::applicationDidFinishLaunching() { // This function will be called when the app is inactive. When comes a phone call,it's be invoked too void AppDelegate::applicationDidEnterBackground() { - CCDirector::sharedDirector()->pause(); + CCDirector::sharedDirector()->stopAnimation(); // if you use SimpleAudioEngine, it must be pause // SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); @@ -45,7 +45,7 @@ void AppDelegate::applicationDidEnterBackground() { // this function will be called when the app is active again void AppDelegate::applicationWillEnterForeground() { - CCDirector::sharedDirector()->resume(); + CCDirector::sharedDirector()->startAnimation(); // if you use SimpleAudioEngine, it must resume here // SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); diff --git a/testjs/Classes/AppDelegate.cpp b/testjs/Classes/AppDelegate.cpp index 696ee5aea2..27159ceef5 100644 --- a/testjs/Classes/AppDelegate.cpp +++ b/testjs/Classes/AppDelegate.cpp @@ -66,7 +66,7 @@ bool AppDelegate::applicationDidFinishLaunching() // This function will be called when the app is inactive. When comes a phone call,it's be invoked too void AppDelegate::applicationDidEnterBackground() { - CCDirector::sharedDirector()->pause(); + CCDirector::sharedDirector()->stopAnimation(); // if you use SimpleAudioEngine, it must be pause // SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); @@ -75,7 +75,7 @@ void AppDelegate::applicationDidEnterBackground() // this function will be called when the app is active again void AppDelegate::applicationWillEnterForeground() { - CCDirector::sharedDirector()->resume(); + CCDirector::sharedDirector()->startAnimation(); // if you use SimpleAudioEngine, it must resume here // SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); diff --git a/tests/AppDelegate.cpp b/tests/AppDelegate.cpp index e373b3e5c7..c83a470e45 100644 --- a/tests/AppDelegate.cpp +++ b/tests/AppDelegate.cpp @@ -44,7 +44,7 @@ bool AppDelegate::applicationDidFinishLaunching() // This function will be called when the app is inactive. When comes a phone call,it's be invoked too void AppDelegate::applicationDidEnterBackground() { - CCDirector::sharedDirector()->pause(); + CCDirector::sharedDirector()->stopAnimation(); SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); SimpleAudioEngine::sharedEngine()->pauseAllEffects(); } @@ -52,7 +52,7 @@ void AppDelegate::applicationDidEnterBackground() // this function will be called when the app is active again void AppDelegate::applicationWillEnterForeground() { - CCDirector::sharedDirector()->resume(); + CCDirector::sharedDirector()->startAnimation(); SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); SimpleAudioEngine::sharedEngine()->resumeAllEffects(); } From 28cc77008d05cb96d73237012cba6b41359af3fc Mon Sep 17 00:00:00 2001 From: Ngoc Dao Date: Thu, 21 Jun 2012 14:33:27 +0900 Subject: [PATCH 237/257] "node" -> "create" --- cocos2dx/layers_scenes_transitions_nodes/CCLayer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h index e38416f50f..c888e86076 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h @@ -151,7 +151,7 @@ private: } -// for the subclass of CCLayer, each has to implement the static "node" method +// for the subclass of CCLayer, each has to implement the static "create" method #define LAYER_CREATE_FUNC(layer) \ static layer* create() \ { \ From 5274fc378d630e298a5e35901dc2878cd8b77dbf Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 21 Jun 2012 13:48:57 +0800 Subject: [PATCH 238/257] fixed a typo in CCScene.h. --- cocos2dx/layers_scenes_transitions_nodes/CCScene.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCScene.h b/cocos2dx/layers_scenes_transitions_nodes/CCScene.h index 272f96ea5a..eb78823458 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCScene.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCScene.h @@ -96,7 +96,7 @@ CC_DEPRECATED_ATTRIBUTE static scene* node() \ return scene; \ } -// for the subclass of CCScene, each has to implement the static "node" method +// for the subclass of CCScene, each has to implement the static "create" method #define SCENE_CREATE_FUNC(scene) \ static scene* create() \ { \ From 1d0b7c40e4ed85998b2f7d42e3a850829440d345 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 21 Jun 2012 13:56:56 +0800 Subject: [PATCH 239/257] Removed virtual attribute for callback functions in HelloWorldScene.h. Updated templates. --- HelloWorld/Classes/HelloWorldScene.h | 2 +- .../Templates/1033/Classes/HelloWorldScene.cpp | 12 ++++++------ .../Templates/1033/Classes/HelloWorldScene.h | 4 ++-- .../cocos2dx.xctemplate/Classes/HelloWorldScene.cpp | 12 ++++++------ .../cocos2dx.xctemplate/Classes/HelloWorldScene.h | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/HelloWorld/Classes/HelloWorldScene.h b/HelloWorld/Classes/HelloWorldScene.h index 4a6be00fcc..08442e9fd8 100644 --- a/HelloWorld/Classes/HelloWorldScene.h +++ b/HelloWorld/Classes/HelloWorldScene.h @@ -13,7 +13,7 @@ public: static cocos2d::CCScene* scene(); // a selector callback - virtual void menuCloseCallback(CCObject* pSender); + void menuCloseCallback(CCObject* pSender); // implement the "static node()" method manually LAYER_CREATE_FUNC(HelloWorld); diff --git a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.cpp b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.cpp index e85e95e66a..c51d2a5df5 100644 --- a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.cpp +++ b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.cpp @@ -8,11 +8,11 @@ CCScene* HelloWorld::scene() do { // 'scene' is an autorelease object - scene = CCScene::node(); + scene = CCScene::create(); CC_BREAK_IF(! scene); // 'layer' is an autorelease object - HelloWorld *layer = HelloWorld::node(); + HelloWorld *layer = HelloWorld::create(); CC_BREAK_IF(! layer); // add layer as a child to scene @@ -42,7 +42,7 @@ bool HelloWorld::init() // 1. Add a menu item with "X" image, which is clicked to quit the program. // Create a "close" menu item with close icon, it's an auto release object. - CCMenuItemImage *pCloseItem = CCMenuItemImage::itemWithNormalImage( + CCMenuItemImage *pCloseItem = CCMenuItemImage::create( "CloseNormal.png", "CloseSelected.png", this, @@ -53,7 +53,7 @@ bool HelloWorld::init() pCloseItem->setPosition(ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20)); // Create a menu with the "close" menu item, it's an auto release object. - CCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, NULL); + CCMenu* pMenu = CCMenu::create(pCloseItem, NULL); pMenu->setPosition(CCPointZero); CC_BREAK_IF(! pMenu); @@ -63,7 +63,7 @@ bool HelloWorld::init() // 2. Add a label shows "Hello World". // Create a label and initialize with string "Hello World". - CCLabelTTF* pLabel = CCLabelTTF::labelWithString("Hello World", "Arial", 24); + CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Arial", 24); CC_BREAK_IF(! pLabel); // Get window size and place the label upper. @@ -74,7 +74,7 @@ bool HelloWorld::init() this->addChild(pLabel, 1); // 3. Add add a splash screen, show the cocos2d splash image. - CCSprite* pSprite = CCSprite::spriteWithFile("HelloWorld.png"); + CCSprite* pSprite = CCSprite::create("HelloWorld.png"); CC_BREAK_IF(! pSprite); // Place the sprite on the center of the screen diff --git a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.h b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.h index aebea7b637..64ec3129fe 100644 --- a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.h +++ b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/HelloWorldScene.h @@ -25,10 +25,10 @@ public: static cocos2d::CCScene* scene(); // a selector callback - virtual void menuCloseCallback(CCObject* pSender); + void menuCloseCallback(CCObject* pSender); // implement the "static node()" method manually - LAYER_NODE_FUNC(HelloWorld); + LAYER_CREATE_FUNC(HelloWorld); }; #endif // __HELLOWORLD_SCENE_H__ \ No newline at end of file diff --git a/template/xcode4/cocos2dx.xctemplate/Classes/HelloWorldScene.cpp b/template/xcode4/cocos2dx.xctemplate/Classes/HelloWorldScene.cpp index 04d9a13b41..a936549028 100644 --- a/template/xcode4/cocos2dx.xctemplate/Classes/HelloWorldScene.cpp +++ b/template/xcode4/cocos2dx.xctemplate/Classes/HelloWorldScene.cpp @@ -7,10 +7,10 @@ using namespace CocosDenshion; CCScene* HelloWorld::scene() { // 'scene' is an autorelease object - CCScene *scene = CCScene::node(); + CCScene *scene = CCScene::create(); // 'layer' is an autorelease object - HelloWorld *layer = HelloWorld::node(); + HelloWorld *layer = HelloWorld::create(); // add layer as a child to scene scene->addChild(layer); @@ -34,7 +34,7 @@ bool HelloWorld::init() // you may modify it. // add a "close" icon to exit the progress. it's an autorelease object - CCMenuItemImage *pCloseItem = CCMenuItemImage::itemWithNormalImage( + CCMenuItemImage *pCloseItem = CCMenuItemImage::create( "CloseNormal.png", "CloseSelected.png", this, @@ -42,7 +42,7 @@ bool HelloWorld::init() pCloseItem->setPosition( ccp(CCDirector::sharedDirector()->getWinSize().width - 20, 20) ); // create menu, it's an autorelease object - CCMenu* pMenu = CCMenu::menuWithItems(pCloseItem, NULL); + CCMenu* pMenu = CCMenu::create(pCloseItem, NULL); pMenu->setPosition( CCPointZero ); this->addChild(pMenu, 1); @@ -51,7 +51,7 @@ bool HelloWorld::init() // add a label shows "Hello World" // create and initialize a label - CCLabelTTF* pLabel = CCLabelTTF::labelWithString("Hello World", "Thonburi", 34); + CCLabelTTF* pLabel = CCLabelTTF::create("Hello World", "Thonburi", 34); // ask director the window size CCSize size = CCDirector::sharedDirector()->getWinSize(); @@ -63,7 +63,7 @@ bool HelloWorld::init() this->addChild(pLabel, 1); // add "HelloWorld" splash screen" - CCSprite* pSprite = CCSprite::spriteWithFile("HelloWorld.png"); + CCSprite* pSprite = CCSprite::create("HelloWorld.png"); // position the sprite on the center of the screen pSprite->setPosition( ccp(size.width/2, size.height/2) ); diff --git a/template/xcode4/cocos2dx.xctemplate/Classes/HelloWorldScene.h b/template/xcode4/cocos2dx.xctemplate/Classes/HelloWorldScene.h index 84026c6b1b..08442e9fd8 100644 --- a/template/xcode4/cocos2dx.xctemplate/Classes/HelloWorldScene.h +++ b/template/xcode4/cocos2dx.xctemplate/Classes/HelloWorldScene.h @@ -13,10 +13,10 @@ public: static cocos2d::CCScene* scene(); // a selector callback - virtual void menuCloseCallback(CCObject* pSender); + void menuCloseCallback(CCObject* pSender); // implement the "static node()" method manually - LAYER_NODE_FUNC(HelloWorld); + LAYER_CREATE_FUNC(HelloWorld); }; #endif // __HELLOWORLD_SCENE_H__ From 95707e98848f77039638011c2c228da5e0906cc3 Mon Sep 17 00:00:00 2001 From: Walzer Date: Thu, 21 Jun 2012 14:04:04 +0800 Subject: [PATCH 240/257] Update gles20 --- README.mdown | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.mdown b/README.mdown index aef22c64e5..c2fdbf130b 100644 --- a/README.mdown +++ b/README.mdown @@ -2,14 +2,14 @@ cocos2d-x ================== [cocos2d-x][1] is a multi-platform 2D game engine in C++, based on [cocos2d-iphone][2] and licensed under MIT. -Now this engine has been expended to iOS, Android, Bada, BlackBerry Playbook, Marmalade and desktop operating systems like Linux, WindowsXP & Windows7. +Now this engine has been expanded to iOS, Android, Bada, BlackBerry, Marmalade and desktop operating systems like Linux, WindowsXP & Windows7. Multi Platform ------------- - * iOS: stable, well tested on iOS 4.0 ~ 5.0 SDK. - * Android: stable, well tested on 2.0~3.1, based on ndk r5 ~ r7. + * iOS: stable, well tested on iOS 4.x ~ 5.x SDK. + * Android: stable, well tested on 2.0~4.0, based on ndk r5 ~ r8. * Bada: stable on Bada SDK 1.0 & 2.0 - * BlackBerry Playbook: stable, contribued by engineers working at RIM + * BlackBerry Playbook & BB10: stable, contribued by engineers working at RIM * Marmalade: stable since cocos2d-x-0.11.0 * Windows: stable, tested on WinXP, Vista, Win7. Please upgrde the drive of your video card if you meet problems on OpenGL functions * Linux: usable. @@ -28,7 +28,7 @@ Contact us [1]: http://www.cocos2d-x.org "cocos2d-x" [2]: http://www.cocos2d-iphone.org "cocos2d for iPhone" [3]: http://www.cocos2d-x.org "www.cocos2d-x.org" -[4]: http://www.cocos2d-x.org/embedded/cocos2d-x/classes.html "API References" +[4]: http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Reference "API References" [5]: http://forum.cocos2d-x.org "http://forum.cocos2d-x.org" [6]: http://www.twitter.com/cocos2dx "http://www.twitter.com/cocos2dx" [7]: http://t.sina.com.cn/cocos2dx "http://t.sina.com.cn/cocos2dx" From 55eca9f516b1f69a503113170988fee7613ff365 Mon Sep 17 00:00:00 2001 From: minggo Date: Fri, 22 Jun 2012 12:00:27 +0800 Subject: [PATCH 241/257] fixed #1343: make xcode template work ok --- .../Classes/AppDelegate.cpp | 4 ++-- .../Classes/HelloWorldScene.cpp | 14 +++++++------- .../Classes/HelloWorldScene.h | 2 +- .../Classes/AppDelegate.cpp | 4 ++-- .../Classes/HelloWorldScene.cpp | 16 ++++++++-------- .../Classes/HelloWorldScene.h | 4 ++-- .../Classes/AppDelegate.cpp | 4 ++-- .../TemplateInfo.plist.REMOVED.git-id | 2 +- tools/xcode4_template_generator/run_generator.sh | 10 +++++----- 9 files changed, 30 insertions(+), 30 deletions(-) diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.cpp index 07ffb55c1e..34a55428e7 100644 --- a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.cpp +++ b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/AppDelegate.cpp @@ -49,7 +49,7 @@ bool AppDelegate::applicationDidFinishLaunching() // This function will be called when the app is inactive. When comes a phone call,it's be invoked too void AppDelegate::applicationDidEnterBackground() { - CCDirector::sharedDirector()->pause(); + CCDirector::sharedDirector()->stopAnimation(); // if you use SimpleAudioEngine, it must be pause // SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); @@ -58,7 +58,7 @@ void AppDelegate::applicationDidEnterBackground() // this function will be called when the app is active again void AppDelegate::applicationWillEnterForeground() { - CCDirector::sharedDirector()->resume(); + CCDirector::sharedDirector()->startAnimation(); // if you use SimpleAudioEngine, it must resume here // SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.cpp b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.cpp index bb47c90d56..928c6c0159 100644 --- a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.cpp +++ b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.cpp @@ -44,7 +44,7 @@ CCAffineTransform PhysicsSprite::nodeToParentTransform(void) float x = pos.x * PTM_RATIO; float y = pos.y * PTM_RATIO; - if ( getIgnoreAnchorPointForPosition() ) { + if ( isIgnoreAnchorPointForPosition() ) { x += m_tAnchorPointInPoints.x; y += m_tAnchorPointInPoints.y; } @@ -69,14 +69,14 @@ CCAffineTransform PhysicsSprite::nodeToParentTransform(void) HelloWorld::HelloWorld() { - setIsTouchEnabled( true ); - setIsAccelerometerEnabled( true ); + setTouchEnabled( true ); + setAccelerometerEnabled( true ); CCSize s = CCDirector::sharedDirector()->getWinSize(); // init physics this->initPhysics(); - CCSpriteBatchNode *parent = CCSpriteBatchNode::batchNodeWithFile("blocks.png", 100); + CCSpriteBatchNode *parent = CCSpriteBatchNode::create("blocks.png", 100); m_pSpriteTexture = parent->getTexture(); addChild(parent, 0, kTagParentNode); @@ -84,7 +84,7 @@ HelloWorld::HelloWorld() addNewSpriteAtPosition(ccp(s.width/2, s.height/2)); - CCLabelTTF *label = CCLabelTTF::labelWithString("Tap screen", "Marker Felt", 32); + CCLabelTTF *label = CCLabelTTF::create("Tap screen", "Marker Felt", 32); addChild(label, 0); label->setColor(ccc3(0,0,255)); label->setPosition(ccp( s.width/2, s.height-50)); @@ -214,7 +214,7 @@ void HelloWorld::addNewSpriteAtPosition(CCPoint p) } -void HelloWorld::update(ccTime dt) +void HelloWorld::update(float dt) { //It is recommended that a fixed time step is used with Box2D for stability //of the simulation, however, we are using a variable time step here. @@ -264,7 +264,7 @@ void HelloWorld::ccTouchesEnded(CCSet* touches, CCEvent* event) CCScene* HelloWorld::scene() { // 'scene' is an autorelease object - CCScene *scene = CCScene::node(); + CCScene *scene = CCScene::create(); // add layer as a child to scene CCLayer* layer = new HelloWorld(); diff --git a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.h b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.h index 76c3b63e77..117f33940f 100644 --- a/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.h +++ b/template/xcode4/cocos2dx_box2d.xctemplate/Classes/HelloWorldScene.h @@ -37,7 +37,7 @@ public: virtual void draw(); virtual void ccTouchesEnded(cocos2d::CCSet* touches, cocos2d::CCEvent* event); - void update(cocos2d::ccTime dt); + void update(float dt); private: b2World* world; diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/AppDelegate.cpp index 07ffb55c1e..34a55428e7 100644 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/AppDelegate.cpp +++ b/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/AppDelegate.cpp @@ -49,7 +49,7 @@ bool AppDelegate::applicationDidFinishLaunching() // This function will be called when the app is inactive. When comes a phone call,it's be invoked too void AppDelegate::applicationDidEnterBackground() { - CCDirector::sharedDirector()->pause(); + CCDirector::sharedDirector()->stopAnimation(); // if you use SimpleAudioEngine, it must be pause // SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); @@ -58,7 +58,7 @@ void AppDelegate::applicationDidEnterBackground() // this function will be called when the app is active again void AppDelegate::applicationWillEnterForeground() { - CCDirector::sharedDirector()->resume(); + CCDirector::sharedDirector()->startAnimation(); // if you use SimpleAudioEngine, it must resume here // SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/HelloWorldScene.cpp b/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/HelloWorldScene.cpp index e9ae38b0b1..9cc53922a2 100644 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/HelloWorldScene.cpp +++ b/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/HelloWorldScene.cpp @@ -53,7 +53,7 @@ CCAffineTransform ChipmunkPhysicsSprite::nodeToParentTransform(void) CCFloat x = m_pBody->p.x; CCFloat y = m_pBody->p.y; - if ( getIgnoreAnchorPointForPosition() ) { + if ( isIgnoreAnchorPointForPosition() ) { x += m_tAnchorPointInPoints.x; y += m_tAnchorPointInPoints.y; } @@ -93,10 +93,10 @@ HelloWorld::~HelloWorld() CCScene* HelloWorld::scene() { // 'scene' is an autorelease object. - CCScene *scene = CCScene::node(); + CCScene *scene = CCScene::create(); // 'layer' is an autorelease object. - HelloWorld *layer = HelloWorld::node(); + HelloWorld *layer = HelloWorld::create(); // add layer as a child to scene scene->addChild(layer); @@ -113,13 +113,13 @@ bool HelloWorld::init() } // enable events - setIsTouchEnabled(true); - setIsAccelerometerEnabled(true); + setTouchEnabled(true); + setAccelerometerEnabled(true); CCSize s = CCDirector::sharedDirector()->getWinSize(); // title - CCLabelTTF *label = CCLabelTTF::labelWithString("Multi touch the screen", "Marker Felt", 36); + CCLabelTTF *label = CCLabelTTF::create("Multi touch the screen", "Marker Felt", 36); label->setPosition(ccp( s.width / 2, s.height - 30)); this->addChild(label, -1); @@ -128,7 +128,7 @@ bool HelloWorld::init() #if 1 // Use batch node. Faster - CCSpriteBatchNode *parent = CCSpriteBatchNode::batchNodeWithFile("grossini_dance_atlas.png", 100); + CCSpriteBatchNode *parent = CCSpriteBatchNode::create("grossini_dance_atlas.png", 100); m_pSpriteTexture = parent->getTexture(); #else // doesn't use batch node. Slower @@ -179,7 +179,7 @@ void HelloWorld::initPhysics() } } -void HelloWorld::update(ccTime delta) +void HelloWorld::update(float delta) { // Should use a fixed size step based on the animation interval. int steps = 2; diff --git a/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/HelloWorldScene.h b/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/HelloWorldScene.h index a32ab05ff7..1a0eddc9ee 100644 --- a/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/HelloWorldScene.h +++ b/template/xcode4/cocos2dx_chipmunk.xctemplate/Classes/HelloWorldScene.h @@ -33,11 +33,11 @@ public: ~HelloWorld(); bool init(); static cocos2d::CCScene* scene(); - LAYER_NODE_FUNC(HelloWorld); + LAYER_CREATE_FUNC(HelloWorld); void initPhysics(); void addNewSpriteAtPosition(cocos2d::CCPoint p); - void update(cocos2d::ccTime dt); + void update(float dt); virtual void ccTouchesEnded(cocos2d::CCSet* touches, cocos2d::CCEvent* event); virtual void didAccelerate(cocos2d::CCAcceleration* pAccelerationValue); diff --git a/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp b/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp index 6ae1789ddc..d849a54ed5 100644 --- a/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp +++ b/template/xcode4/cocos2dx_lua.xctemplate/Classes/AppDelegate.cpp @@ -58,7 +58,7 @@ bool AppDelegate::applicationDidFinishLaunching() // This function will be called when the app is inactive. When comes a phone call,it's be invoked too void AppDelegate::applicationDidEnterBackground() { - CCDirector::sharedDirector()->pause(); + CCDirector::sharedDirector()->stopAnimation(); // if you use SimpleAudioEngine, it must be pause // SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); @@ -67,7 +67,7 @@ void AppDelegate::applicationDidEnterBackground() // this function will be called when the app is active again void AppDelegate::applicationWillEnterForeground() { - CCDirector::sharedDirector()->resume(); + CCDirector::sharedDirector()->startAnimation(); // if you use SimpleAudioEngine, it must resume here // SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); diff --git a/template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist.REMOVED.git-id b/template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist.REMOVED.git-id index 280b63ea85..60415a3ef0 100644 --- a/template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist.REMOVED.git-id +++ b/template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist.REMOVED.git-id @@ -1 +1 @@ -44156c1d13cbc3821278cc9d51e878adfd5ea603 \ No newline at end of file +587375a44e095a8d79480f96b3ee1588061edc3c \ No newline at end of file diff --git a/tools/xcode4_template_generator/run_generator.sh b/tools/xcode4_template_generator/run_generator.sh index 410ef5428f..fb5bb77871 100755 --- a/tools/xcode4_template_generator/run_generator.sh +++ b/tools/xcode4_template_generator/run_generator.sh @@ -2,23 +2,23 @@ pushd ../../ echo "generating libcocos2dx" mkdir -p template/xcode4/lib_cocos2dx.xctemplate -python ./tools/xcode4_template_generator/template_generator.py --directory cocos2dx --identifier libcocos2dx --prefix libs --exclude "android win32 airplay wophone bada third_party CCImage.cpp CCThread.cpp proj.ios CCFileUtilsCommon_cpp.h CCImageCommon_cpp.h CCFileUtils.cpp Android.mk Linux linux qnx marmalade CCBReader_v1.cpp" > ./template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist +python ./tools/xcode4_template_generator/template_generator.py --directory cocos2dx --identifier libcocos2dx --prefix libs --exclude "android win32 third_party CCImage.cpp CCThread.cpp proj.ios CCFileUtilsCommon_cpp.h CCImageCommon_cpp.h CCFileUtils.cpp Android.mk" > ./template/xcode4/lib_cocos2dx.xctemplate/TemplateInfo.plist echo "generating libcocosdenshion" mkdir -p template/xcode4/lib_cocosdenshion.xctemplate -python ./tools/xcode4_template_generator/template_generator.py --directory CocosDenshion --identifier libcocosdenshion --prefix libs --exclude "android win32 airplay wophone bada third_party Android.mk Linux linux qnx marmalade" > ./template/xcode4/lib_cocosdenshion.xctemplate/TemplateInfo.plist +python ./tools/xcode4_template_generator/template_generator.py --directory CocosDenshion --identifier libcocosdenshion --prefix libs --exclude "android win32 third_party Android.mk" > ./template/xcode4/lib_cocosdenshion.xctemplate/TemplateInfo.plist echo "generating libbox2d" mkdir -p template/xcode4/lib_box2d.xctemplate -python ./tools/xcode4_template_generator/template_generator.py --directory Box2D --identifier libbox2d --prefix libs --exclude "android win32 airplay wophone bada Android.mk Linux linux qnx marmalade" > ./template/xcode4/lib_box2d.xctemplate/TemplateInfo.plist +python ./tools/xcode4_template_generator/template_generator.py --directory Box2D --identifier libbox2d --prefix libs --exclude "android win32 Android.mk" > ./template/xcode4/lib_box2d.xctemplate/TemplateInfo.plist echo "generating libchipmunk" mkdir -p template/xcode4/lib_chipmunk.xctemplate -python ./tools/xcode4_template_generator/template_generator.py --directory chipmunk --identifier libchipmunk --prefix libs --exclude "android win32 airplay wophone bada Android.mk Linux linux CMakeFiles Makefile qnx marmalade" > ./template/xcode4/lib_chipmunk.xctemplate/TemplateInfo.plist +python ./tools/xcode4_template_generator/template_generator.py --directory chipmunk --identifier libchipmunk --prefix libs --exclude "android win32 Android.mk CMakeFiles Makefile" > ./template/xcode4/lib_chipmunk.xctemplate/TemplateInfo.plist echo "generating liblua" mkdir -p template/xcode4/lib_lua.xctemplate -python ./tools/xcode4_template_generator/template_generator.py --directory lua --identifier liblua --prefix libs --append ./tools/xcode4_template_generator/template_lua_patch.txt --exclude "android win32 airplay wophone bada Makefile Linux linux CMakeFiles qnx marmalade" > ./template/xcode4/lib_lua.xctemplate/TemplateInfo.plist +python ./tools/xcode4_template_generator/template_generator.py --directory lua --identifier liblua --prefix libs --append ./tools/xcode4_template_generator/template_lua_patch.txt --exclude "android win32 Makefile CMakeFiles" > ./template/xcode4/lib_lua.xctemplate/TemplateInfo.plist echo "done" From 28ba42db87b9b424350b1b07a800baa9d8ec7465 Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 25 Jun 2012 11:55:12 +0800 Subject: [PATCH 242/257] fixed #1344: win32 template cannot work after synchronizing to rc2 --- .../CCAppWiz.win32/Scripts/1033/default.js | 33 ++++--------------- .../Templates/1033/Classes/AppDelegate.cpp | 4 +-- .../Templates/1033/Classes/AppDelegate.h | 2 +- 3 files changed, 10 insertions(+), 29 deletions(-) diff --git a/template/msvc/CCAppWiz.win32/Scripts/1033/default.js b/template/msvc/CCAppWiz.win32/Scripts/1033/default.js index 9aabd73bfd..8b7b645f1b 100644 --- a/template/msvc/CCAppWiz.win32/Scripts/1033/default.js +++ b/template/msvc/CCAppWiz.win32/Scripts/1033/default.js @@ -226,30 +226,11 @@ function AddConfigurations(proj, strProjectName) { // Additional Inlcude Directories var strAddIncludeDir = '.;..\\Classes'; strAddIncludeDir += ';..\\..\\cocos2dx'; - strAddIncludeDir += ';..\\..\\cocos2dx\\actions'; - strAddIncludeDir += ';..\\..\\cocos2dx\\base_nodes'; - strAddIncludeDir += ';..\\..\\cocos2dx\\cocoa'; - strAddIncludeDir += ';..\\..\\cocos2dx\\effects'; - strAddIncludeDir += ';..\\..\\cocos2dx\\include'; - strAddIncludeDir += ';..\\..\\cocos2dx\\kazmath\\include'; - strAddIncludeDir += ';..\\..\\cocos2dx\\keypad_dispatcher'; - strAddIncludeDir += ';..\\..\\cocos2dx\\label_nodes'; - strAddIncludeDir += ';..\\..\\cocos2dx\\layers_scenes_transitions_nodes'; - strAddIncludeDir += ';..\\..\\cocos2dx\\menu_nodes'; - strAddIncludeDir += ';..\\..\\cocos2dx\\misc_nodes'; - strAddIncludeDir += ';..\\..\\cocos2dx\\particle_nodes'; - strAddIncludeDir += ';..\\..\\cocos2dx\\script_support'; - strAddIncludeDir += ';..\\..\\cocos2dx\\shaders'; - strAddIncludeDir += ';..\\..\\cocos2dx\\sprite_nodes'; - strAddIncludeDir += ';..\\..\\cocos2dx\\support'; - strAddIncludeDir += ';..\\..\\cocos2dx\\text_input_node'; - strAddIncludeDir += ';..\\..\\cocos2dx\\textures'; - strAddIncludeDir += ';..\\..\\cocos2dx\\tileMap_parallax_nodes'; - strAddIncludeDir += ';..\\..\\cocos2dx\\touch_dispatcher'; - strAddIncludeDir += ';..\\..\\cocos2dx\\platform'; - strAddIncludeDir += ';..\\..\\cocos2dx\\platform\\win32'; - strAddIncludeDir += ';..\\..\\cocos2dx\\platform\\third_party\\win32'; - strAddIncludeDir += ';..\\..\\cocos2dx\\platform\\third_party\\win32\\OGLES'; + strAddIncludeDir += ';..\\..\\cocos2dx\\include'; + strAddIncludeDir += ';..\\..\\cocos2dx\\kazmath\\include'; + strAddIncludeDir += ';..\\..\\cocos2dx\\platform\\win32'; + strAddIncludeDir += ';..\\..\\cocos2dx\\platform\\third_party\\win32'; + strAddIncludeDir += ';..\\..\\cocos2dx\\platform\\third_party\\win32\\OGLES'; if (wizard.FindSymbol('CC_USE_BOX2D')) { strAddIncludeDir += ';..\\..\\'; @@ -283,7 +264,7 @@ function AddConfigurations(proj, strProjectName) { } var strDefines = GetPlatformDefine(config); - strDefines += "_WINDOWS;STRICT;"; + strDefines += "_WINDOWS;STRICT;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS"; if (bDebug) strDefines += "_DEBUG;COCOS2D_DEBUG=1;"; else @@ -291,7 +272,7 @@ function AddConfigurations(proj, strProjectName) { CLTool.PreprocessorDefinitions = strDefines; // Disable special warning - CLTool.DisableSpecificWarnings = "4251"; + CLTool.DisableSpecificWarnings = "4267;4251;4244"; // Linker settings var LinkTool = config.Tools('VCLinkerTool'); diff --git a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.cpp b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.cpp index 680d7d11e4..fd680236cb 100644 --- a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.cpp +++ b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.cpp @@ -69,7 +69,7 @@ bool AppDelegate::applicationDidFinishLaunching() // This function will be called when the app is inactive. When comes a phone call,it's be invoked too void AppDelegate::applicationDidEnterBackground() { - CCDirector::sharedDirector()->pause(); + CCDirector::sharedDirector()->stopAnimation(); [! if CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic(); @@ -79,7 +79,7 @@ void AppDelegate::applicationDidEnterBackground() // this function will be called when the app is active again void AppDelegate::applicationWillEnterForeground() { - CCDirector::sharedDirector()->resume(); + CCDirector::sharedDirector()->startAnimation(); [! if CC_USE_COCOS_DENSHION_SIMPLE_AUDIO_ENGINE] SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic(); diff --git a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.h b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.h index 65dfe75bfe..bcbd54a019 100644 --- a/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.h +++ b/template/msvc/CCAppWiz.win32/Templates/1033/Classes/AppDelegate.h @@ -1,7 +1,7 @@ #ifndef __APP_DELEGATE_H__ #define __APP_DELEGATE_H__ -#include "CCApplication.h" +#include "cocos2d.h" /** @brief The cocos2d Application. From 16310cb5446791f88d51243e5a8ddd20b57754b6 Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 26 Jun 2012 11:02:19 +0800 Subject: [PATCH 243/257] fixed #1364:add paused state --- CocosDenshion/ios/CDAudioManager.h | 3 +++ CocosDenshion/ios/CDAudioManager.m | 16 +++++++++++----- cocos2dx/CCDirector.cpp | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/CocosDenshion/ios/CDAudioManager.h b/CocosDenshion/ios/CDAudioManager.h index 21aa115f5b..af0ab4a98a 100644 --- a/CocosDenshion/ios/CDAudioManager.h +++ b/CocosDenshion/ios/CDAudioManager.h @@ -98,6 +98,8 @@ typedef enum { BOOL mute; BOOL enabled_; BOOL backgroundMusic; + // whether background music is paused + BOOL paused; @public BOOL systemPaused;//Used for auto resign handling NSTimeInterval systemPauseLocation;//Used for auto resign handling @@ -111,6 +113,7 @@ typedef enum { @property (assign) id delegate; /* This long audio source functions as background music */ @property (readwrite, nonatomic) BOOL backgroundMusic; +@property (readonly) BOOL paused; /** Loads the file into the audio source */ -(void) load:(NSString*) filePath; diff --git a/CocosDenshion/ios/CDAudioManager.m b/CocosDenshion/ios/CDAudioManager.m index 80dc24243b..abdf1a8908 100644 --- a/CocosDenshion/ios/CDAudioManager.m +++ b/CocosDenshion/ios/CDAudioManager.m @@ -39,7 +39,7 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised"; @implementation CDLongAudioSource -@synthesize audioSourcePlayer, audioSourceFilePath, delegate, backgroundMusic; +@synthesize audioSourcePlayer, audioSourceFilePath, delegate, backgroundMusic, paused; -(id) init { if ((self = [super init])) { @@ -47,6 +47,7 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised"; volume = 1.0f; mute = NO; enabled_ = YES; + paused = NO; } return self; } @@ -94,6 +95,7 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised"; -(void) play { if (enabled_) { self->systemPaused = NO; + self->paused = NO; [audioSourcePlayer play]; } else { CDLOGINFO(@"Denshion::CDLongAudioSource long audio source didn't play because it is disabled"); @@ -101,22 +103,22 @@ NSString * const kCDN_AudioManagerInitialised = @"kCDN_AudioManagerInitialised"; } -(void) stop { + self->paused = NO; [audioSourcePlayer stop]; } -(void) pause { + self->paused = YES; [audioSourcePlayer pause]; } -(void) rewind { + self->paused = NO; [audioSourcePlayer setCurrentTime:0]; } -(void) resume { - if (!self->systemPaused) { - return; - } - + self->paused = NO; [audioSourcePlayer play]; } @@ -577,6 +579,10 @@ static BOOL configured = FALSE; return; } + if (![self.backgroundMusic paused]) { + return; + } + [self.backgroundMusic resume]; } diff --git a/cocos2dx/CCDirector.cpp b/cocos2dx/CCDirector.cpp index 603dfc0a4f..065e5f5bde 100644 --- a/cocos2dx/CCDirector.cpp +++ b/cocos2dx/CCDirector.cpp @@ -187,7 +187,7 @@ void CCDirector::setGLDefaultValues(void) CCAssert(m_pobOpenGLView, "opengl view should not be null"); setAlphaBlending(true); - setDepthTest(true); + setDepthTest(false); setProjection(m_eProjection); // set other opengl default values From 765da0c80a1829fd3b003d30139de27420655915 Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 26 Jun 2012 11:09:37 +0800 Subject: [PATCH 244/257] enable depth test when running test case:Bug-1159 --- tests/tests/BugsTest/Bug-1159.cpp | 6 ++++++ tests/tests/BugsTest/Bug-1159.h | 1 + 2 files changed, 7 insertions(+) diff --git a/tests/tests/BugsTest/Bug-1159.cpp b/tests/tests/BugsTest/Bug-1159.cpp index e1a9a6cc17..480c1d1b0d 100644 --- a/tests/tests/BugsTest/Bug-1159.cpp +++ b/tests/tests/BugsTest/Bug-1159.cpp @@ -22,6 +22,7 @@ bool Bug1159Layer::init() { if (BugsTestBaseLayer::init()) { + CCDirector::sharedDirector()->setDepthTest(true); CCSize s = CCDirector::sharedDirector()->getWinSize(); CCLayerColor *background = CCLayerColor::create(ccc4(255, 0, 255, 255)); @@ -59,3 +60,8 @@ void Bug1159Layer::callBack(CCObject* pSender) { CCDirector::sharedDirector()->replaceScene(CCTransitionPageTurn::create(1.0f, Bug1159Layer::scene(), false)); } + +void Bug1159Layer::onExit() +{ + CCDirector::sharedDirector()->setDepthTest(false); +} diff --git a/tests/tests/BugsTest/Bug-1159.h b/tests/tests/BugsTest/Bug-1159.h index f4b87e402c..25e9b2fc6b 100644 --- a/tests/tests/BugsTest/Bug-1159.h +++ b/tests/tests/BugsTest/Bug-1159.h @@ -7,6 +7,7 @@ class Bug1159Layer : public BugsTestBaseLayer { public: virtual bool init(); + virtual void onExit(); static CCScene* scene(); void callBack(CCObject* pSender); From 95a2696b6ba866e030b3c9dd4d58dad830337373 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 26 Jun 2012 12:09:23 +0800 Subject: [PATCH 245/257] fixed #1365: Some files of Resources folder which is copied by build_native.sh will lost authority in cygwin. --- HelloLua/proj.android/build_native.sh | 3 +++ HelloWorld/proj.android/build_native.sh | 3 +++ template/android/build_native.sh | 3 +++ testjs/proj.android/build_native.sh | 3 +++ tests/proj.android/build_native.sh | 3 +++ tools/lua_project_generator/template/android/build_native.sh | 3 +++ 6 files changed, 18 insertions(+) diff --git a/HelloLua/proj.android/build_native.sh b/HelloLua/proj.android/build_native.sh index 0b836bf1d3..37afad392c 100755 --- a/HelloLua/proj.android/build_native.sh +++ b/HelloLua/proj.android/build_native.sh @@ -62,6 +62,9 @@ cp $file $GAME_ANDROID_ROOT/assets fi done +# Change the authority of Resources folder. +chmod -R 666 $GAME_ANDROID_ROOT/assets + # build if [[ $buildexternalsfromsource ]]; then echo "Building external dependencies from source" diff --git a/HelloWorld/proj.android/build_native.sh b/HelloWorld/proj.android/build_native.sh index bb0c583c6c..7271cd3289 100755 --- a/HelloWorld/proj.android/build_native.sh +++ b/HelloWorld/proj.android/build_native.sh @@ -60,6 +60,9 @@ cp $file $HELLOWORLD_ROOT/assets fi done +# Change the authority of Resources folder. +chmod -R 666 $HELLOWORLD_ROOT/assets + if [[ $buildexternalsfromsource ]]; then echo "Building external dependencies from source" $NDK_ROOT_LOCAL/ndk-build -C $HELLOWORLD_ROOT $* \ diff --git a/template/android/build_native.sh b/template/android/build_native.sh index 32345d4bd9..4e3535962c 100644 --- a/template/android/build_native.sh +++ b/template/android/build_native.sh @@ -50,6 +50,9 @@ do fi done +# Change the authority of Resources folder. +chmod -R 666 $GAME_ANDROID_ROOT/assets + # copy icons (if they exist) file=$GAME_ANDROID_ROOT/assets/Icon-72.png if [ -f "$file" ]; then diff --git a/testjs/proj.android/build_native.sh b/testjs/proj.android/build_native.sh index bd92dfe50f..e7da87e18a 100755 --- a/testjs/proj.android/build_native.sh +++ b/testjs/proj.android/build_native.sh @@ -60,6 +60,9 @@ cp "$file" $TEST_JS_ROOT/assets fi done +# Change the authority of Resources folder. +chmod -R 666 $TEST_JS_ROOT/assets + if [[ $buildexternalsfromsource ]]; then echo "Building external dependencies from source" $NDK_ROOT_LOCAL/ndk-build -C $TEST_JS_ROOT $* \ diff --git a/tests/proj.android/build_native.sh b/tests/proj.android/build_native.sh index f2d6a51203..10322d529c 100755 --- a/tests/proj.android/build_native.sh +++ b/tests/proj.android/build_native.sh @@ -61,6 +61,9 @@ cp $file $TESTS_ROOT/assets fi done +# Change the authority of Resources folder. +chmod -R 666 $TESTS_ROOT/assets + # remove test_image_rgba4444.pvr.gz rm -f $TESTS_ROOT/assets/Images/test_image_rgba4444.pvr.gz diff --git a/tools/lua_project_generator/template/android/build_native.sh b/tools/lua_project_generator/template/android/build_native.sh index 8e4457cd4f..2ee20bfb9b 100755 --- a/tools/lua_project_generator/template/android/build_native.sh +++ b/tools/lua_project_generator/template/android/build_native.sh @@ -25,6 +25,9 @@ do fi done +# Change the authority of Resources folder. +chmod -R 666 $GAME_ANDROID_ROOT/assets + # build pushd $ANDROID_NDK_ROOT ./ndk-build -C $GAME_ANDROID_ROOT $* From 4f5d1d06e5d0049b9b64fceadbb145f2f6323c3c Mon Sep 17 00:00:00 2001 From: minggo Date: Tue, 26 Jun 2012 15:37:47 +0800 Subject: [PATCH 247/257] modify cocos2d-x version --- cocos2dx/cocos2d.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/cocos2d.cpp b/cocos2dx/cocos2d.cpp index 58f6c1d432..4a0ff0ce08 100644 --- a/cocos2dx/cocos2d.cpp +++ b/cocos2dx/cocos2d.cpp @@ -30,7 +30,7 @@ NS_CC_BEGIN const char* cocos2dVersion() { - return "cocos2d-2.0-rc2-x-2.0"; + return "cocos2d-2.0-rc2-x-2.0.1"; } NS_CC_END From 934a50c673d2cae736807e5d907942063aac9e50 Mon Sep 17 00:00:00 2001 From: James Chen Date: Tue, 26 Jun 2012 23:26:16 +0800 Subject: [PATCH 248/257] fixed #1366: testjs will crash on win32. Resolved by updating spiderMonkey to v1.8.5. --- js/JSBindings/ScriptingCore.h | 12 + js/spidermonkey-win32/include/ds/BitArray.h | 91 - js/spidermonkey-win32/include/gc/Barrier.h | 531 ----- js/spidermonkey-win32/include/gc/Statistics.h | 179 -- js/spidermonkey-win32/include/js-config.h | 2 +- js/spidermonkey-win32/include/js.msg | 377 --- js/spidermonkey-win32/include/js/HashTable.h | 1357 ----------- .../include/js/LegacyIntTypes.h | 92 - .../include/js/MemoryMetrics.h | 190 -- .../include/js/TemplateLib.h | 180 -- js/spidermonkey-win32/include/js/Utility.h | 950 -------- js/spidermonkey-win32/include/js/Vector.h | 1030 --------- js/spidermonkey-win32/include/jsalloc.h | 121 - .../include/jsapi.h.REMOVED.git-id | 2 +- js/spidermonkey-win32/include/jsatom.h | 610 ----- js/spidermonkey-win32/include/jscell.h | 119 - js/spidermonkey-win32/include/jsclass.h | 427 ---- js/spidermonkey-win32/include/jsclist.h | 139 -- .../include/{json.h => jscompat.h} | 56 +- js/spidermonkey-win32/include/jscpucfg.h | 123 +- js/spidermonkey-win32/include/jsdbgapi.h | 586 ----- js/spidermonkey-win32/include/jsdhash.h | 636 ------ js/spidermonkey-win32/include/jsfriendapi.h | 826 ------- js/spidermonkey-win32/include/jsgc.h | 2019 ----------------- js/spidermonkey-win32/include/jshash.h | 153 -- js/spidermonkey-win32/include/jsinttypes.h | 144 ++ js/spidermonkey-win32/include/jslock.h | 87 - js/spidermonkey-win32/include/jslong.h | 167 ++ js/spidermonkey-win32/include/jsotypes.h | 198 ++ js/spidermonkey-win32/include/jsperf.h | 163 -- js/spidermonkey-win32/include/jsprf.h | 115 - js/spidermonkey-win32/include/jsproto.tbl | 61 +- js/spidermonkey-win32/include/jsproxy.h | 224 -- js/spidermonkey-win32/include/jsprvtd.h | 493 ---- js/spidermonkey-win32/include/jspubtd.h | 575 ++++- js/spidermonkey-win32/include/jstypedarray.h | 364 --- js/spidermonkey-win32/include/jstypes.h | 258 ++- js/spidermonkey-win32/include/jsutil.h | 671 +++--- js/spidermonkey-win32/include/jsval.h | 494 ++-- js/spidermonkey-win32/include/jsversion.h | 10 + js/spidermonkey-win32/include/jswrapper.h | 233 -- js/spidermonkey-win32/include/jsxdrapi.h | 215 -- .../include/mozilla/Assertions.h | 307 --- .../include/mozilla/Attributes.h | 344 --- .../include/mozilla/BloomFilter.h | 232 -- .../include/mozilla/GuardObjects.h | 182 -- .../include/mozilla/HashFunctions.h | 112 - .../include/mozilla/Likely.h | 21 - .../include/mozilla/LinkedList.h | 422 ---- .../include/mozilla/MSStdInt.h | 247 -- .../include/mozilla/RangedPtr.h | 283 --- .../include/mozilla/RefPtr.h | 443 ---- .../include/mozilla/StandardInteger.h | 78 - js/spidermonkey-win32/include/mozilla/Types.h | 170 -- js/spidermonkey-win32/include/mozilla/Util.h | 364 --- .../lib/js.dll.REMOVED.git-id | 2 +- .../lib/js.lib.REMOVED.git-id | 2 +- testjs/proj.win32/testjs.win32.vcproj | 5 +- 58 files changed, 1892 insertions(+), 16602 deletions(-) delete mode 100644 js/spidermonkey-win32/include/ds/BitArray.h delete mode 100644 js/spidermonkey-win32/include/gc/Barrier.h delete mode 100644 js/spidermonkey-win32/include/gc/Statistics.h delete mode 100644 js/spidermonkey-win32/include/js.msg delete mode 100644 js/spidermonkey-win32/include/js/HashTable.h delete mode 100644 js/spidermonkey-win32/include/js/LegacyIntTypes.h delete mode 100644 js/spidermonkey-win32/include/js/MemoryMetrics.h delete mode 100644 js/spidermonkey-win32/include/js/TemplateLib.h delete mode 100644 js/spidermonkey-win32/include/js/Utility.h delete mode 100644 js/spidermonkey-win32/include/js/Vector.h delete mode 100644 js/spidermonkey-win32/include/jsalloc.h delete mode 100644 js/spidermonkey-win32/include/jsatom.h delete mode 100644 js/spidermonkey-win32/include/jscell.h delete mode 100644 js/spidermonkey-win32/include/jsclass.h delete mode 100644 js/spidermonkey-win32/include/jsclist.h rename js/spidermonkey-win32/include/{json.h => jscompat.h} (57%) delete mode 100644 js/spidermonkey-win32/include/jsdbgapi.h delete mode 100644 js/spidermonkey-win32/include/jsdhash.h delete mode 100644 js/spidermonkey-win32/include/jsfriendapi.h delete mode 100644 js/spidermonkey-win32/include/jsgc.h delete mode 100644 js/spidermonkey-win32/include/jshash.h create mode 100644 js/spidermonkey-win32/include/jsinttypes.h delete mode 100644 js/spidermonkey-win32/include/jslock.h create mode 100644 js/spidermonkey-win32/include/jslong.h create mode 100644 js/spidermonkey-win32/include/jsotypes.h delete mode 100644 js/spidermonkey-win32/include/jsperf.h delete mode 100644 js/spidermonkey-win32/include/jsprf.h delete mode 100644 js/spidermonkey-win32/include/jsproxy.h delete mode 100644 js/spidermonkey-win32/include/jsprvtd.h delete mode 100644 js/spidermonkey-win32/include/jstypedarray.h delete mode 100644 js/spidermonkey-win32/include/jswrapper.h delete mode 100644 js/spidermonkey-win32/include/jsxdrapi.h delete mode 100644 js/spidermonkey-win32/include/mozilla/Assertions.h delete mode 100644 js/spidermonkey-win32/include/mozilla/Attributes.h delete mode 100644 js/spidermonkey-win32/include/mozilla/BloomFilter.h delete mode 100644 js/spidermonkey-win32/include/mozilla/GuardObjects.h delete mode 100644 js/spidermonkey-win32/include/mozilla/HashFunctions.h delete mode 100644 js/spidermonkey-win32/include/mozilla/Likely.h delete mode 100644 js/spidermonkey-win32/include/mozilla/LinkedList.h delete mode 100644 js/spidermonkey-win32/include/mozilla/MSStdInt.h delete mode 100644 js/spidermonkey-win32/include/mozilla/RangedPtr.h delete mode 100644 js/spidermonkey-win32/include/mozilla/RefPtr.h delete mode 100644 js/spidermonkey-win32/include/mozilla/StandardInteger.h delete mode 100644 js/spidermonkey-win32/include/mozilla/Types.h delete mode 100644 js/spidermonkey-win32/include/mozilla/Util.h diff --git a/js/JSBindings/ScriptingCore.h b/js/JSBindings/ScriptingCore.h index 8a58ac5681..25be9b0071 100644 --- a/js/JSBindings/ScriptingCore.h +++ b/js/JSBindings/ScriptingCore.h @@ -12,6 +12,18 @@ #include "jsapi.h" #include "cocos2d.h" +/* Since there is an ugly bug in spiderMonkey-win32(cocos2d-2.0-rc0a), we updated spiderMonkey to v1.8.5 to resolve it. + But the api is a little different from the old version, so we define two marco here. +*/ +#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) +typedef unsigned int uint32_t; +typedef int int32_t; + +#define JS_GetPrivate(obj) JS_GetPrivate(cx, obj) +#define JS_SetPrivate(obj, data) JS_SetPrivate(cx, obj, data) + +#endif + class ScriptingCore { JSRuntime *rt; diff --git a/js/spidermonkey-win32/include/ds/BitArray.h b/js/spidermonkey-win32/include/ds/BitArray.h deleted file mode 100644 index 91165f919d..0000000000 --- a/js/spidermonkey-win32/include/ds/BitArray.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=4 sw=4 et tw=99 ft=cpp: - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is SpiderMonkey JavaScript engine. - * - * The Initial Developer of the Original Code is - * Mozilla Corporation. - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Terrence Cole - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef BitArray_h__ -#define BitArray_h__ - -#include "jstypes.h" - -#include "js/TemplateLib.h" - -namespace js { - -template -class BitArray { - private: - uintptr_t map[nbits / JS_BITS_PER_WORD + (nbits % JS_BITS_PER_WORD == 0 ? 0 : 1)]; - - public: - void clear(bool value) { - if (value) - memset(map, 0xFF, sizeof(map)); - else - memset(map, 0, sizeof(map)); - } - - inline bool get(size_t offset) const { - uintptr_t index, mask; - getMarkWordAndMask(offset, &index, &mask); - return map[index] & mask; - } - - inline void set(size_t offset) { - uintptr_t index, mask; - getMarkWordAndMask(offset, &index, &mask); - map[index] |= mask; - } - - inline void unset(size_t offset) { - uintptr_t index, mask; - getMarkWordAndMask(offset, &index, &mask); - map[index] &= ~mask; - } - - private: - inline void getMarkWordAndMask(size_t offset, - uintptr_t *indexp, uintptr_t *maskp) const { - *indexp = offset >> tl::FloorLog2::result; - *maskp = uintptr_t(1) << (offset & (JS_BITS_PER_WORD - 1)); - } -}; - -} /* namespace js */ - -#endif diff --git a/js/spidermonkey-win32/include/gc/Barrier.h b/js/spidermonkey-win32/include/gc/Barrier.h deleted file mode 100644 index 4c8b34fdf8..0000000000 --- a/js/spidermonkey-win32/include/gc/Barrier.h +++ /dev/null @@ -1,531 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sw=4 et tw=78: - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is SpiderMonkey global object code. - * - * The Initial Developer of the Original Code is - * the Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef jsgc_barrier_h___ -#define jsgc_barrier_h___ - -#include "jsapi.h" -#include "jscell.h" - -#include "js/HashTable.h" - -/* - * A write barrier is a mechanism used by incremental or generation GCs to - * ensure that every value that needs to be marked is marked. In general, the - * write barrier should be invoked whenever a write can cause the set of things - * traced through by the GC to change. This includes: - * - writes to object properties - * - writes to array slots - * - writes to fields like JSObject::shape_ that we trace through - * - writes to fields in private data, like JSGenerator::obj - * - writes to non-markable fields like JSObject::private that point to - * markable data - * The last category is the trickiest. Even though the private pointers does not - * point to a GC thing, changing the private pointer may change the set of - * objects that are traced by the GC. Therefore it needs a write barrier. - * - * Every barriered write should have the following form: - * - * obj->field = value; // do the actual write - * - * The pre-barrier is used for incremental GC and the post-barrier is for - * generational GC. - * - * PRE-BARRIER - * - * To understand the pre-barrier, let's consider how incremental GC works. The - * GC itself is divided into "slices". Between each slice, JS code is allowed to - * run. Each slice should be short so that the user doesn't notice the - * interruptions. In our GC, the structure of the slices is as follows: - * - * 1. ... JS work, which leads to a request to do GC ... - * 2. [first GC slice, which performs all root marking and possibly more marking] - * 3. ... more JS work is allowed to run ... - * 4. [GC mark slice, which runs entirely in drainMarkStack] - * 5. ... more JS work ... - * 6. [GC mark slice, which runs entirely in drainMarkStack] - * 7. ... more JS work ... - * 8. [GC marking finishes; sweeping done non-incrementally; GC is done] - * 9. ... JS continues uninterrupted now that GC is finishes ... - * - * Of course, there may be a different number of slices depending on how much - * marking is to be done. - * - * The danger inherent in this scheme is that the JS code in steps 3, 5, and 7 - * might change the heap in a way that causes the GC to collect an object that - * is actually reachable. The write barrier prevents this from happening. We use - * a variant of incremental GC called "snapshot at the beginning." This approach - * guarantees the invariant that if an object is reachable in step 2, then we - * will mark it eventually. The name comes from the idea that we take a - * theoretical "snapshot" of all reachable objects in step 2; all objects in - * that snapshot should eventually be marked. (Note that the write barrier - * verifier code takes an actual snapshot.) - * - * The basic correctness invariant of a snapshot-at-the-beginning collector is - * that any object reachable at the end of the GC (step 9) must either: - * (1) have been reachable at the beginning (step 2) and thus in the snapshot - * (2) or must have been newly allocated, in steps 3, 5, or 7. - * To deal with case (2), any objects allocated during an incremental GC are - * automatically marked black. - * - * This strategy is actually somewhat conservative: if an object becomes - * unreachable between steps 2 and 8, it would be safe to collect it. We won't, - * mainly for simplicity. (Also, note that the snapshot is entirely - * theoretical. We don't actually do anything special in step 2 that we wouldn't - * do in a non-incremental GC. - * - * It's the pre-barrier's job to maintain the snapshot invariant. Consider the - * write "obj->field = value". Let the prior value of obj->field be - * value0. Since it's possible that value0 may have been what obj->field - * contained in step 2, when the snapshot was taken, the barrier marks - * value0. Note that it only does this if we're in the middle of an incremental - * GC. Since this is rare, the cost of the write barrier is usually just an - * extra branch. - * - * In practice, we implement the pre-barrier differently based on the type of - * value0. E.g., see JSObject::writeBarrierPre, which is used if obj->field is - * a JSObject*. It takes value0 as a parameter. - * - * POST-BARRIER - * - * These are not yet implemented. Once we get generational GC, they will allow - * us to keep track of pointers from non-nursery space into the nursery. - * - * IMPLEMENTATION DETAILS - * - * Since it would be awkward to change every write to memory into a function - * call, this file contains a bunch of C++ classes and templates that use - * operator overloading to take care of barriers automatically. In many cases, - * all that's necessary to make some field be barriered is to replace - * Type *field; - * with - * HeapPtr field; - * There are also special classes HeapValue and HeapId, which barrier js::Value - * and jsid, respectively. - * - * One additional note: not all object writes need to be barriered. Writes to - * newly allocated objects do not need a barrier as long as the GC is not - * allowed to run in between the allocation and the write. In these cases, we - * use the "obj->field.init(value)" method instead of "obj->field = value". - * We use the init naming idiom in many places to signify that a field is being - * assigned for the first time, and that no GCs have taken place between the - * object allocation and the assignment. - */ - -struct JSXML; - -namespace js { - -/* - * Ideally, we would like to make the argument to functions like MarkShape be a - * HeapPtr. That would ensure that we don't forget to - * barrier any fields that we mark through. However, that would prohibit us from - * passing in a derived class like HeapPtr. - * - * To overcome the problem, we make the argument to MarkShape be a - * MarkablePtr. And we allow conversions from HeapPtr - * to MarkablePtr as long as T can be converted to U. - */ -template -class MarkablePtr -{ - public: - T *value; - - explicit MarkablePtr(T *value) : value(value) {} -}; - -template -class HeapPtr -{ - union { - T *value; - Unioned other; - }; - - public: - HeapPtr() : value(NULL) {} - explicit HeapPtr(T *v) : value(v) { post(); } - explicit HeapPtr(const HeapPtr &v) : value(v.value) { post(); } - - ~HeapPtr() { pre(); } - - /* Use this to install a ptr into a newly allocated object. */ - void init(T *v) { - JS_ASSERT(!IsPoisonedPtr(v)); - value = v; - post(); - } - - /* Use to set the pointer to NULL. */ - void clear() { - pre(); - value = NULL; - } - - /* Use this if the automatic coercion to T* isn't working. */ - T *get() const { return value; } - - /* - * Use these if you want to change the value without invoking the barrier. - * Obviously this is dangerous unless you know the barrier is not needed. - */ - T **unsafeGet() { return &value; } - void unsafeSet(T *v) { value = v; } - - Unioned *unsafeGetUnioned() { return &other; } - - HeapPtr &operator=(T *v) { - pre(); - JS_ASSERT(!IsPoisonedPtr(v)); - value = v; - post(); - return *this; - } - - HeapPtr &operator=(const HeapPtr &v) { - pre(); - JS_ASSERT(!IsPoisonedPtr(v.value)); - value = v.value; - post(); - return *this; - } - - T &operator*() const { return *value; } - T *operator->() const { return value; } - - operator T*() const { return value; } - - /* - * This coerces to MarkablePtr as long as T can coerce to U. See the - * comment for MarkablePtr above. - */ - template - operator MarkablePtr() const { return MarkablePtr(value); } - - private: - void pre() { T::writeBarrierPre(value); } - void post() { T::writeBarrierPost(value, (void *)&value); } - - /* Make this friend so it can access pre() and post(). */ - template - friend inline void - BarrieredSetPair(JSCompartment *comp, - HeapPtr &v1, T1 *val1, - HeapPtr &v2, T2 *val2); -}; - -/* - * This is a hack for RegExpStatics::updateFromMatch. It allows us to do two - * barriers with only one branch to check if we're in an incremental GC. - */ -template -static inline void -BarrieredSetPair(JSCompartment *comp, - HeapPtr &v1, T1 *val1, - HeapPtr &v2, T2 *val2) -{ - if (T1::needWriteBarrierPre(comp)) { - v1.pre(); - v2.pre(); - } - v1.unsafeSet(val1); - v2.unsafeSet(val2); - v1.post(); - v2.post(); -} - -struct Shape; -class BaseShape; -namespace types { struct TypeObject; } - -typedef HeapPtr HeapPtrObject; -typedef HeapPtr HeapPtrFunction; -typedef HeapPtr HeapPtrString; -typedef HeapPtr HeapPtrScript; -typedef HeapPtr HeapPtrShape; -typedef HeapPtr HeapPtrBaseShape; -typedef HeapPtr HeapPtrTypeObject; -typedef HeapPtr HeapPtrXML; - -/* Useful for hashtables with a HeapPtr as key. */ -template -struct HeapPtrHasher -{ - typedef HeapPtr Key; - typedef T *Lookup; - - static HashNumber hash(Lookup obj) { return DefaultHasher::hash(obj); } - static bool match(const Key &k, Lookup l) { return k.get() == l; } -}; - -/* Specialized hashing policy for HeapPtrs. */ -template -struct DefaultHasher< HeapPtr >: HeapPtrHasher { }; - -class EncapsulatedValue -{ - protected: - Value value; - - /* - * Ensure that EncapsulatedValue is not constructable, except by our - * implementations. - */ - EncapsulatedValue() MOZ_DELETE; - EncapsulatedValue(const EncapsulatedValue &v) MOZ_DELETE; - EncapsulatedValue &operator=(const Value &v) MOZ_DELETE; - EncapsulatedValue &operator=(const EncapsulatedValue &v) MOZ_DELETE; - - EncapsulatedValue(const Value &v) : value(v) {} - ~EncapsulatedValue() {} - - public: - const Value &get() const { return value; } - Value *unsafeGet() { return &value; } - operator const Value &() const { return value; } - - bool isUndefined() const { return value.isUndefined(); } - bool isNull() const { return value.isNull(); } - bool isBoolean() const { return value.isBoolean(); } - bool isTrue() const { return value.isTrue(); } - bool isFalse() const { return value.isFalse(); } - bool isNumber() const { return value.isNumber(); } - bool isInt32() const { return value.isInt32(); } - bool isDouble() const { return value.isDouble(); } - bool isString() const { return value.isString(); } - bool isObject() const { return value.isObject(); } - bool isMagic(JSWhyMagic why) const { return value.isMagic(why); } - bool isGCThing() const { return value.isGCThing(); } - bool isMarkable() const { return value.isMarkable(); } - - bool toBoolean() const { return value.toBoolean(); } - double toNumber() const { return value.toNumber(); } - int32_t toInt32() const { return value.toInt32(); } - double toDouble() const { return value.toDouble(); } - JSString *toString() const { return value.toString(); } - JSObject &toObject() const { return value.toObject(); } - JSObject *toObjectOrNull() const { return value.toObjectOrNull(); } - void *toGCThing() const { return value.toGCThing(); } - - JSGCTraceKind gcKind() const { return value.gcKind(); } - - uint64_t asRawBits() const { return value.asRawBits(); } - -#ifdef DEBUG - JSWhyMagic whyMagic() const { return value.whyMagic(); } -#endif - - static inline void writeBarrierPre(const Value &v); - static inline void writeBarrierPre(JSCompartment *comp, const Value &v); - - protected: - inline void pre(); - inline void pre(JSCompartment *comp); -}; - -class HeapValue : public EncapsulatedValue -{ - public: - explicit inline HeapValue(); - explicit inline HeapValue(const Value &v); - explicit inline HeapValue(const HeapValue &v); - inline ~HeapValue(); - - inline void init(const Value &v); - inline void init(JSCompartment *comp, const Value &v); - - inline HeapValue &operator=(const Value &v); - inline HeapValue &operator=(const HeapValue &v); - - /* - * This is a faster version of operator=. Normally, operator= has to - * determine the compartment of the value before it can decide whether to do - * the barrier. If you already know the compartment, it's faster to pass it - * in. - */ - inline void set(JSCompartment *comp, const Value &v); - - static inline void writeBarrierPost(const Value &v, void *addr); - static inline void writeBarrierPost(JSCompartment *comp, const Value &v, void *addr); - - private: - inline void post(); - inline void post(JSCompartment *comp); -}; - -class HeapSlot : public EncapsulatedValue -{ - /* - * Operator= is not valid for HeapSlot because is must take the object and - * slot offset to provide to the post/generational barrier. - */ - inline HeapSlot &operator=(const Value &v) MOZ_DELETE; - inline HeapSlot &operator=(const HeapValue &v) MOZ_DELETE; - inline HeapSlot &operator=(const HeapSlot &v) MOZ_DELETE; - - public: - explicit inline HeapSlot() MOZ_DELETE; - explicit inline HeapSlot(JSObject *obj, uint32_t slot, const Value &v); - explicit inline HeapSlot(JSObject *obj, uint32_t slot, const HeapSlot &v); - inline ~HeapSlot(); - - inline void init(JSObject *owner, uint32_t slot, const Value &v); - inline void init(JSCompartment *comp, JSObject *owner, uint32_t slot, const Value &v); - - inline void set(JSObject *owner, uint32_t slot, const Value &v); - inline void set(JSCompartment *comp, JSObject *owner, uint32_t slot, const Value &v); - - static inline void writeBarrierPost(JSObject *obj, uint32_t slot); - static inline void writeBarrierPost(JSCompartment *comp, JSObject *obj, uint32_t slotno); - - private: - inline void post(JSObject *owner, uint32_t slot); - inline void post(JSCompartment *comp, JSObject *owner, uint32_t slot); -}; - -static inline const Value * -Valueify(const EncapsulatedValue *array) -{ - JS_STATIC_ASSERT(sizeof(HeapValue) == sizeof(Value)); - JS_STATIC_ASSERT(sizeof(HeapSlot) == sizeof(Value)); - return (const Value *)array; -} - -class HeapSlotArray -{ - HeapSlot *array; - - public: - HeapSlotArray(HeapSlot *array) : array(array) {} - - operator const Value *() const { return Valueify(array); } - operator HeapSlot *() const { return array; } - - HeapSlotArray operator +(int offset) const { return HeapSlotArray(array + offset); } - HeapSlotArray operator +(uint32_t offset) const { return HeapSlotArray(array + offset); } -}; - -class HeapId -{ - jsid value; - - public: - explicit HeapId() : value(JSID_VOID) {} - explicit inline HeapId(jsid id); - - inline ~HeapId(); - - inline void init(jsid id); - - inline HeapId &operator=(jsid id); - inline HeapId &operator=(const HeapId &v); - - bool operator==(jsid id) const { return value == id; } - bool operator!=(jsid id) const { return value != id; } - - jsid get() const { return value; } - jsid *unsafeGet() { return &value; } - operator jsid() const { return value; } - - private: - inline void pre(); - inline void post(); - - HeapId(const HeapId &v); -}; - -/* - * Incremental GC requires that weak pointers have read barriers. This is mostly - * an issue for empty shapes stored in JSCompartment. The problem happens when, - * during an incremental GC, some JS code stores one of the compartment's empty - * shapes into an object already marked black. Normally, this would not be a - * problem, because the empty shape would have been part of the initial snapshot - * when the GC started. However, since this is a weak pointer, it isn't. So we - * may collect the empty shape even though a live object points to it. To fix - * this, we mark these empty shapes black whenever they get read out. - */ -template -class ReadBarriered -{ - T *value; - - public: - ReadBarriered() : value(NULL) {} - ReadBarriered(T *value) : value(value) {} - - T *get() const { - if (!value) - return NULL; - T::readBarrier(value); - return value; - } - - operator T*() const { return get(); } - - T &operator*() const { return *get(); } - T *operator->() const { return get(); } - - T *unsafeGet() { return value; } - - void set(T *v) { value = v; } - - operator bool() { return !!value; } - - template - operator MarkablePtr() const { return MarkablePtr(value); } -}; - -class ReadBarrieredValue -{ - Value value; - - public: - ReadBarrieredValue() : value(UndefinedValue()) {} - ReadBarrieredValue(const Value &value) : value(value) {} - - inline const Value &get() const; - inline operator const Value &() const; - - inline JSObject &toObject() const; -}; - -} - -#endif /* jsgc_barrier_h___ */ diff --git a/js/spidermonkey-win32/include/gc/Statistics.h b/js/spidermonkey-win32/include/gc/Statistics.h deleted file mode 100644 index 31b8d5d699..0000000000 --- a/js/spidermonkey-win32/include/gc/Statistics.h +++ /dev/null @@ -1,179 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sw=4 et tw=78: - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is SpiderMonkey JavaScript engine. - * - * The Initial Developer of the Original Code is - * the Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef jsgc_statistics_h___ -#define jsgc_statistics_h___ - -#include - -#include "jsfriendapi.h" -#include "jspubtd.h" -#include "jsutil.h" - -struct JSCompartment; - -namespace js { -namespace gcstats { - -enum Phase { - PHASE_MARK, - PHASE_MARK_ROOTS, - PHASE_MARK_DELAYED, - PHASE_MARK_OTHER, - PHASE_SWEEP, - PHASE_SWEEP_OBJECT, - PHASE_SWEEP_STRING, - PHASE_SWEEP_SCRIPT, - PHASE_SWEEP_SHAPE, - PHASE_DISCARD_CODE, - PHASE_DISCARD_ANALYSIS, - PHASE_XPCONNECT, - PHASE_DESTROY, - - PHASE_LIMIT -}; - -enum Stat { - STAT_NEW_CHUNK, - STAT_DESTROY_CHUNK, - - STAT_LIMIT -}; - -static const size_t BUFFER_SIZE = 8192; - -struct Statistics { - Statistics(JSRuntime *rt); - ~Statistics(); - - void beginPhase(Phase phase); - void endPhase(Phase phase); - - void beginSlice(JSCompartment *comp, gcreason::Reason reason); - void endSlice(); - - void reset(const char *reason) { slices.back().resetReason = reason; } - void nonincremental(const char *reason) { nonincrementalReason = reason; } - - void count(Stat s) { - JS_ASSERT(s < STAT_LIMIT); - counts[s]++; - } - - private: - JSRuntime *runtime; - - int64_t startupTime; - - FILE *fp; - bool fullFormat; - - JSCompartment *compartment; - const char *nonincrementalReason; - - struct SliceData { - SliceData(gcreason::Reason reason, int64_t start) - : reason(reason), resetReason(NULL), start(start) - { - PodArrayZero(phaseTimes); - } - - gcreason::Reason reason; - const char *resetReason; - int64_t start, end; - int64_t phaseTimes[PHASE_LIMIT]; - - int64_t duration() const { return end - start; } - }; - - Vector slices; - - /* Most recent time when the given phase started. */ - int64_t phaseStarts[PHASE_LIMIT]; - - /* Total time in a given phase for this GC. */ - int64_t phaseTimes[PHASE_LIMIT]; - - /* Total time in a given phase over all GCs. */ - int64_t phaseTotals[PHASE_LIMIT]; - - /* Number of events of this type for this GC. */ - unsigned int counts[STAT_LIMIT]; - - char buffer[BUFFER_SIZE]; - bool needComma; - - void beginGC(); - void endGC(); - - int64_t gcDuration(); - double t(int64_t t); - void printStats(); - void fmt(const char *f, ...); - void fmtIfNonzero(const char *name, double t); - void formatPhases(int64_t *times); - const char *formatData(); - - double computeMMU(int64_t resolution); -}; - -struct AutoGCSlice { - AutoGCSlice(Statistics &stats, JSCompartment *comp, gcreason::Reason reason - JS_GUARD_OBJECT_NOTIFIER_PARAM) - : stats(stats) { JS_GUARD_OBJECT_NOTIFIER_INIT; stats.beginSlice(comp, reason); } - ~AutoGCSlice() { stats.endSlice(); } - - Statistics &stats; - JS_DECL_USE_GUARD_OBJECT_NOTIFIER -}; - -struct AutoPhase { - AutoPhase(Statistics &stats, Phase phase JS_GUARD_OBJECT_NOTIFIER_PARAM) - : stats(stats), phase(phase) { JS_GUARD_OBJECT_NOTIFIER_INIT; stats.beginPhase(phase); } - ~AutoPhase() { stats.endPhase(phase); } - - Statistics &stats; - Phase phase; - JS_DECL_USE_GUARD_OBJECT_NOTIFIER -}; - -} /* namespace gcstats */ -} /* namespace js */ - -#endif /* jsgc_statistics_h___ */ diff --git a/js/spidermonkey-win32/include/js-config.h b/js/spidermonkey-win32/include/js-config.h index f6082dfbab..1dd91f0174 100644 --- a/js/spidermonkey-win32/include/js-config.h +++ b/js/spidermonkey-win32/include/js-config.h @@ -90,7 +90,7 @@ /* #undef JS_INT32_TYPE */ /* #undef JS_INT64_TYPE */ /* #undef JS_INTPTR_TYPE */ -#define JS_BYTES_PER_WORD 4 +//#define JS_BYTES_PER_WORD 4 /* Some mozilla code uses JS-friend APIs that depend on JS_METHODJIT being correct. */ diff --git a/js/spidermonkey-win32/include/js.msg b/js/spidermonkey-win32/include/js.msg deleted file mode 100644 index 24bbb58639..0000000000 --- a/js/spidermonkey-win32/include/js.msg +++ /dev/null @@ -1,377 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * This is the JavaScript error message file. - * - * The format for each JS error message is: - * - * MSG_DEF(, , , , - * ) - * - * where ; - * is a legal C identifer that will be used in the - * JS engine source. - * - * is an unique integral value identifying this error. - * - * is an integer literal specifying the total number of - * replaceable arguments in the following format string. - * - * is an exception index from the enum in jsexn.c; - * JSEXN_NONE for none. The given exception index will be raised by the - * engine when the corresponding error occurs. - * - * is a string literal, optionally containing sequences - * {X} where X is an integer representing the argument number that will - * be replaced with a string value when the error is reported. - * - * e.g. - * - * MSG_DEF(JSMSG_NOT_A_SUBSPECIES, 73, JSEXN_NONE, 2, - * "{0} is not a member of the {1} family") - * - * can be used: - * - * JS_ReportErrorNumber(JSMSG_NOT_A_SUBSPECIES, "Rhino", "Monkey"); - * - * to report: - * - * "Rhino is not a member of the Monkey family" - * - * When removing MSG_DEFs, convert them to JSMSG_UNUSED placeholders: - * - * MSG_DEF(JSMSG_UNUSED7, 7, 0, JSEXN_NONE, "") - * - * Before adding a new MSG_DEF at the end, look for existing JSMSG_UNUSED - * free index placeholders in the middle of the list. - */ - -MSG_DEF(JSMSG_NOT_AN_ERROR, 0, 0, JSEXN_NONE, "") -MSG_DEF(JSMSG_NOT_DEFINED, 1, 1, JSEXN_REFERENCEERR, "{0} is not defined") -MSG_DEF(JSMSG_INACTIVE, 2, 0, JSEXN_INTERNALERR, "nothing active on context") -MSG_DEF(JSMSG_MORE_ARGS_NEEDED, 3, 3, JSEXN_TYPEERR, "{0} requires more than {1} argument{2}") -MSG_DEF(JSMSG_BAD_CHAR, 4, 1, JSEXN_INTERNALERR, "invalid format character {0}") -MSG_DEF(JSMSG_BAD_TYPE, 5, 1, JSEXN_TYPEERR, "unknown type {0}") -MSG_DEF(JSMSG_ALLOC_OVERFLOW, 6, 0, JSEXN_INTERNALERR, "allocation size overflow") -MSG_DEF(JSMSG_MISSING_HEXDIGITS, 7, 0, JSEXN_SYNTAXERR, "missing hexadecimal digits after '0x'") -MSG_DEF(JSMSG_INCOMPATIBLE_PROTO, 8, 3, JSEXN_TYPEERR, "{0}.prototype.{1} called on incompatible {2}") -MSG_DEF(JSMSG_NO_CONSTRUCTOR, 9, 1, JSEXN_TYPEERR, "{0} has no constructor") -MSG_DEF(JSMSG_CANT_ALIAS, 10, 3, JSEXN_TYPEERR, "can't alias {0} to {1} in class {2}") -MSG_DEF(JSMSG_NOT_SCRIPTED_FUNCTION, 11, 1, JSEXN_TYPEERR, "{0} is not a scripted function") -MSG_DEF(JSMSG_BAD_SORT_ARG, 12, 0, JSEXN_TYPEERR, "invalid Array.prototype.sort argument") -MSG_DEF(JSMSG_BAD_ATOMIC_NUMBER, 13, 1, JSEXN_INTERNALERR, "internal error: no index for atom {0}") -MSG_DEF(JSMSG_TOO_MANY_LITERALS, 14, 0, JSEXN_INTERNALERR, "too many literals") -MSG_DEF(JSMSG_CANT_WATCH, 15, 1, JSEXN_TYPEERR, "can't watch non-native objects of class {0}") -MSG_DEF(JSMSG_STACK_UNDERFLOW, 16, 2, JSEXN_INTERNALERR, "internal error compiling {0}: stack underflow at pc {1}") -MSG_DEF(JSMSG_NEED_DIET, 17, 1, JSEXN_INTERNALERR, "{0} too large") -MSG_DEF(JSMSG_TOO_MANY_LOCAL_ROOTS, 18, 0, JSEXN_ERR, "out of local root space") -MSG_DEF(JSMSG_READ_ONLY, 19, 1, JSEXN_TYPEERR, "{0} is read-only") -MSG_DEF(JSMSG_BAD_FORMAL, 20, 0, JSEXN_SYNTAXERR, "malformed formal parameter") -MSG_DEF(JSMSG_CANT_DELETE, 21, 1, JSEXN_TYPEERR, "property {0} is non-configurable and can't be deleted") -MSG_DEF(JSMSG_NOT_FUNCTION, 22, 1, JSEXN_TYPEERR, "{0} is not a function") -MSG_DEF(JSMSG_NOT_CONSTRUCTOR, 23, 1, JSEXN_TYPEERR, "{0} is not a constructor") -MSG_DEF(JSMSG_INVALID_DATE, 24, 0, JSEXN_RANGEERR, "invalid date") -MSG_DEF(JSMSG_TOO_DEEP, 25, 1, JSEXN_INTERNALERR, "{0} nested too deeply") -MSG_DEF(JSMSG_OVER_RECURSED, 26, 0, JSEXN_INTERNALERR, "too much recursion") -MSG_DEF(JSMSG_IN_NOT_OBJECT, 27, 1, JSEXN_TYPEERR, "invalid 'in' operand {0}") -MSG_DEF(JSMSG_BAD_NEW_RESULT, 28, 1, JSEXN_TYPEERR, "invalid new expression result {0}") -MSG_DEF(JSMSG_BAD_SHARP_DEF, 29, 1, JSEXN_ERR, "invalid sharp variable definition #{0}=") -MSG_DEF(JSMSG_BAD_SHARP_USE, 30, 1, JSEXN_ERR, "invalid sharp variable use #{0}#") -MSG_DEF(JSMSG_BAD_INSTANCEOF_RHS, 31, 1, JSEXN_TYPEERR, "invalid 'instanceof' operand {0}") -MSG_DEF(JSMSG_BAD_BYTECODE, 32, 1, JSEXN_INTERNALERR, "unimplemented JavaScript bytecode {0}") -MSG_DEF(JSMSG_BAD_RADIX, 33, 0, JSEXN_RANGEERR, "radix must be an integer at least 2 and no greater than 36") -MSG_DEF(JSMSG_PAREN_BEFORE_LET, 34, 0, JSEXN_SYNTAXERR, "missing ( before let head") -MSG_DEF(JSMSG_CANT_CONVERT, 35, 1, JSEXN_ERR, "can't convert {0} to an integer") -MSG_DEF(JSMSG_CYCLIC_VALUE, 36, 1, JSEXN_TYPEERR, "cyclic {0} value") -MSG_DEF(JSMSG_COMPILE_EXECED_SCRIPT, 37, 0, JSEXN_TYPEERR, "can't compile over a script that is currently executing") -MSG_DEF(JSMSG_CANT_CONVERT_TO, 38, 2, JSEXN_TYPEERR, "can't convert {0} to {1}") -MSG_DEF(JSMSG_NO_PROPERTIES, 39, 1, JSEXN_TYPEERR, "{0} has no properties") -MSG_DEF(JSMSG_CANT_FIND_CLASS, 40, 1, JSEXN_TYPEERR, "can't find class id {0}") -MSG_DEF(JSMSG_UNUSED41 , 41, 0, JSEXN_NONE, "") -MSG_DEF(JSMSG_BYTECODE_TOO_BIG, 42, 2, JSEXN_INTERNALERR, "bytecode {0} too large (limit {1})") -MSG_DEF(JSMSG_UNKNOWN_FORMAT, 43, 1, JSEXN_INTERNALERR, "unknown bytecode format {0}") -MSG_DEF(JSMSG_TOO_MANY_CON_ARGS, 44, 0, JSEXN_SYNTAXERR, "too many constructor arguments") -MSG_DEF(JSMSG_TOO_MANY_FUN_ARGS, 45, 0, JSEXN_SYNTAXERR, "too many function arguments") -MSG_DEF(JSMSG_BAD_QUANTIFIER, 46, 0, JSEXN_SYNTAXERR, "invalid quantifier") -MSG_DEF(JSMSG_MIN_TOO_BIG, 47, 1, JSEXN_SYNTAXERR, "overlarge minimum {0}") -MSG_DEF(JSMSG_MAX_TOO_BIG, 48, 1, JSEXN_SYNTAXERR, "overlarge maximum {0}") -MSG_DEF(JSMSG_OUT_OF_ORDER, 49, 1, JSEXN_SYNTAXERR, "maximum {0} less than minimum") -MSG_DEF(JSMSG_BAD_DESTRUCT_DECL, 50, 0, JSEXN_SYNTAXERR, "missing = in destructuring declaration") -MSG_DEF(JSMSG_BAD_DESTRUCT_ASS, 51, 0, JSEXN_REFERENCEERR, "invalid destructuring assignment operator") -MSG_DEF(JSMSG_PAREN_AFTER_LET, 52, 0, JSEXN_SYNTAXERR, "missing ) after let head") -MSG_DEF(JSMSG_CURLY_AFTER_LET, 53, 0, JSEXN_SYNTAXERR, "missing } after let block") -MSG_DEF(JSMSG_MISSING_PAREN, 54, 0, JSEXN_SYNTAXERR, "unterminated parenthetical") -MSG_DEF(JSMSG_UNTERM_CLASS, 55, 1, JSEXN_SYNTAXERR, "unterminated character class {0}") -MSG_DEF(JSMSG_TRAILING_SLASH, 56, 0, JSEXN_SYNTAXERR, "trailing \\ in regular expression") -MSG_DEF(JSMSG_BAD_CLASS_RANGE, 57, 0, JSEXN_SYNTAXERR, "invalid range in character class") -MSG_DEF(JSMSG_BAD_REGEXP_FLAG, 58, 1, JSEXN_SYNTAXERR, "invalid regular expression flag {0}") -MSG_DEF(JSMSG_NO_INPUT, 59, 5, JSEXN_SYNTAXERR, "no input for /{0}/{1}{2}{3}{4}") -MSG_DEF(JSMSG_CANT_OPEN, 60, 2, JSEXN_ERR, "can't open {0}: {1}") -MSG_DEF(JSMSG_TOO_MANY_FUN_APPLY_ARGS, 61, 0, JSEXN_RANGEERR, "arguments array passed to Function.prototype.apply is too large") -MSG_DEF(JSMSG_UNMATCHED_RIGHT_PAREN, 62, 0, JSEXN_SYNTAXERR, "unmatched ) in regular expression") -MSG_DEF(JSMSG_END_OF_DATA, 63, 0, JSEXN_INTERNALERR, "unexpected end of data") -MSG_DEF(JSMSG_SEEK_BEYOND_START, 64, 0, JSEXN_INTERNALERR, "illegal seek beyond start") -MSG_DEF(JSMSG_SEEK_BEYOND_END, 65, 0, JSEXN_INTERNALERR, "illegal seek beyond end") -MSG_DEF(JSMSG_END_SEEK, 66, 0, JSEXN_INTERNALERR, "illegal end-based seek") -MSG_DEF(JSMSG_WHITHER_WHENCE, 67, 1, JSEXN_INTERNALERR, "unknown seek whence: {0}") -MSG_DEF(JSMSG_BAD_SCRIPT_MAGIC, 68, 0, JSEXN_INTERNALERR, "bad script XDR magic number") -MSG_DEF(JSMSG_PAREN_BEFORE_FORMAL, 69, 0, JSEXN_SYNTAXERR, "missing ( before formal parameters") -MSG_DEF(JSMSG_MISSING_FORMAL, 70, 0, JSEXN_SYNTAXERR, "missing formal parameter") -MSG_DEF(JSMSG_PAREN_AFTER_FORMAL, 71, 0, JSEXN_SYNTAXERR, "missing ) after formal parameters") -MSG_DEF(JSMSG_CURLY_BEFORE_BODY, 72, 0, JSEXN_SYNTAXERR, "missing { before function body") -MSG_DEF(JSMSG_CURLY_AFTER_BODY, 73, 0, JSEXN_SYNTAXERR, "missing } after function body") -MSG_DEF(JSMSG_PAREN_BEFORE_COND, 74, 0, JSEXN_SYNTAXERR, "missing ( before condition") -MSG_DEF(JSMSG_PAREN_AFTER_COND, 75, 0, JSEXN_SYNTAXERR, "missing ) after condition") -MSG_DEF(JSMSG_DESTRUCT_DUP_ARG, 76, 0, JSEXN_SYNTAXERR, "duplicate argument is mixed with destructuring pattern") -MSG_DEF(JSMSG_NAME_AFTER_DOT, 77, 0, JSEXN_SYNTAXERR, "missing name after . operator") -MSG_DEF(JSMSG_BRACKET_IN_INDEX, 78, 0, JSEXN_SYNTAXERR, "missing ] in index expression") -MSG_DEF(JSMSG_XML_WHOLE_PROGRAM, 79, 0, JSEXN_SYNTAXERR, "XML can't be the whole program") -MSG_DEF(JSMSG_PAREN_BEFORE_SWITCH, 80, 0, JSEXN_SYNTAXERR, "missing ( before switch expression") -MSG_DEF(JSMSG_PAREN_AFTER_SWITCH, 81, 0, JSEXN_SYNTAXERR, "missing ) after switch expression") -MSG_DEF(JSMSG_CURLY_BEFORE_SWITCH, 82, 0, JSEXN_SYNTAXERR, "missing { before switch body") -MSG_DEF(JSMSG_COLON_AFTER_CASE, 83, 0, JSEXN_SYNTAXERR, "missing : after case label") -MSG_DEF(JSMSG_WHILE_AFTER_DO, 84, 0, JSEXN_SYNTAXERR, "missing while after do-loop body") -MSG_DEF(JSMSG_PAREN_AFTER_FOR, 85, 0, JSEXN_SYNTAXERR, "missing ( after for") -MSG_DEF(JSMSG_SEMI_AFTER_FOR_INIT, 86, 0, JSEXN_SYNTAXERR, "missing ; after for-loop initializer") -MSG_DEF(JSMSG_SEMI_AFTER_FOR_COND, 87, 0, JSEXN_SYNTAXERR, "missing ; after for-loop condition") -MSG_DEF(JSMSG_PAREN_AFTER_FOR_CTRL, 88, 0, JSEXN_SYNTAXERR, "missing ) after for-loop control") -MSG_DEF(JSMSG_CURLY_BEFORE_TRY, 89, 0, JSEXN_SYNTAXERR, "missing { before try block") -MSG_DEF(JSMSG_CURLY_AFTER_TRY, 90, 0, JSEXN_SYNTAXERR, "missing } after try block") -MSG_DEF(JSMSG_PAREN_BEFORE_CATCH, 91, 0, JSEXN_SYNTAXERR, "missing ( before catch") -MSG_DEF(JSMSG_CATCH_IDENTIFIER, 92, 0, JSEXN_SYNTAXERR, "missing identifier in catch") -MSG_DEF(JSMSG_PAREN_AFTER_CATCH, 93, 0, JSEXN_SYNTAXERR, "missing ) after catch") -MSG_DEF(JSMSG_CURLY_BEFORE_CATCH, 94, 0, JSEXN_SYNTAXERR, "missing { before catch block") -MSG_DEF(JSMSG_CURLY_AFTER_CATCH, 95, 0, JSEXN_SYNTAXERR, "missing } after catch block") -MSG_DEF(JSMSG_CURLY_BEFORE_FINALLY, 96, 0, JSEXN_SYNTAXERR, "missing { before finally block") -MSG_DEF(JSMSG_CURLY_AFTER_FINALLY, 97, 0, JSEXN_SYNTAXERR, "missing } after finally block") -MSG_DEF(JSMSG_CATCH_OR_FINALLY, 98, 0, JSEXN_SYNTAXERR, "missing catch or finally after try") -MSG_DEF(JSMSG_PAREN_BEFORE_WITH, 99, 0, JSEXN_SYNTAXERR, "missing ( before with-statement object") -MSG_DEF(JSMSG_PAREN_AFTER_WITH, 100, 0, JSEXN_SYNTAXERR, "missing ) after with-statement object") -MSG_DEF(JSMSG_CURLY_IN_COMPOUND, 101, 0, JSEXN_SYNTAXERR, "missing } in compound statement") -MSG_DEF(JSMSG_NO_VARIABLE_NAME, 102, 0, JSEXN_SYNTAXERR, "missing variable name") -MSG_DEF(JSMSG_COLON_IN_COND, 103, 0, JSEXN_SYNTAXERR, "missing : in conditional expression") -MSG_DEF(JSMSG_PAREN_AFTER_ARGS, 104, 0, JSEXN_SYNTAXERR, "missing ) after argument list") -MSG_DEF(JSMSG_BRACKET_AFTER_LIST, 105, 0, JSEXN_SYNTAXERR, "missing ] after element list") -MSG_DEF(JSMSG_COLON_AFTER_ID, 106, 0, JSEXN_SYNTAXERR, "missing : after property id") -MSG_DEF(JSMSG_CURLY_AFTER_LIST, 107, 0, JSEXN_SYNTAXERR, "missing } after property list") -MSG_DEF(JSMSG_PAREN_IN_PAREN, 108, 0, JSEXN_SYNTAXERR, "missing ) in parenthetical") -MSG_DEF(JSMSG_SEMI_BEFORE_STMNT, 109, 0, JSEXN_SYNTAXERR, "missing ; before statement") -MSG_DEF(JSMSG_NO_RETURN_VALUE, 110, 1, JSEXN_TYPEERR, "function {0} does not always return a value") -MSG_DEF(JSMSG_DUPLICATE_FORMAL, 111, 1, JSEXN_SYNTAXERR, "duplicate formal argument {0}") -MSG_DEF(JSMSG_EQUAL_AS_ASSIGN, 112, 0, JSEXN_SYNTAXERR, "test for equality (==) mistyped as assignment (=)?") -MSG_DEF(JSMSG_OPTIMIZED_CLOSURE_LEAK, 113, 0, JSEXN_INTERNALERR, "can't access optimized closure") -MSG_DEF(JSMSG_TOO_MANY_DEFAULTS, 114, 0, JSEXN_SYNTAXERR, "more than one switch default") -MSG_DEF(JSMSG_TOO_MANY_CASES, 115, 0, JSEXN_INTERNALERR, "too many switch cases") -MSG_DEF(JSMSG_BAD_SWITCH, 116, 0, JSEXN_SYNTAXERR, "invalid switch statement") -MSG_DEF(JSMSG_BAD_FOR_LEFTSIDE, 117, 0, JSEXN_SYNTAXERR, "invalid for/in left-hand side") -MSG_DEF(JSMSG_CATCH_AFTER_GENERAL, 118, 0, JSEXN_SYNTAXERR, "catch after unconditional catch") -MSG_DEF(JSMSG_CATCH_WITHOUT_TRY, 119, 0, JSEXN_SYNTAXERR, "catch without try") -MSG_DEF(JSMSG_FINALLY_WITHOUT_TRY, 120, 0, JSEXN_SYNTAXERR, "finally without try") -MSG_DEF(JSMSG_LABEL_NOT_FOUND, 121, 0, JSEXN_SYNTAXERR, "label not found") -MSG_DEF(JSMSG_TOUGH_BREAK, 122, 0, JSEXN_SYNTAXERR, "unlabeled break must be inside loop or switch") -MSG_DEF(JSMSG_BAD_CONTINUE, 123, 0, JSEXN_SYNTAXERR, "continue must be inside loop") -MSG_DEF(JSMSG_BAD_RETURN_OR_YIELD, 124, 1, JSEXN_SYNTAXERR, "{0} not in function") -MSG_DEF(JSMSG_BAD_LABEL, 125, 0, JSEXN_SYNTAXERR, "invalid label") -MSG_DEF(JSMSG_DUPLICATE_LABEL, 126, 0, JSEXN_SYNTAXERR, "duplicate label") -MSG_DEF(JSMSG_VAR_HIDES_ARG, 127, 1, JSEXN_TYPEERR, "variable {0} redeclares argument") -MSG_DEF(JSMSG_BAD_VAR_INIT, 128, 0, JSEXN_SYNTAXERR, "invalid variable initialization") -MSG_DEF(JSMSG_BAD_LEFTSIDE_OF_ASS, 129, 0, JSEXN_REFERENCEERR, "invalid assignment left-hand side") -MSG_DEF(JSMSG_BAD_OPERAND, 130, 1, JSEXN_SYNTAXERR, "invalid {0} operand") -MSG_DEF(JSMSG_BAD_PROP_ID, 131, 0, JSEXN_SYNTAXERR, "invalid property id") -MSG_DEF(JSMSG_RESERVED_ID, 132, 1, JSEXN_SYNTAXERR, "{0} is a reserved identifier") -MSG_DEF(JSMSG_SYNTAX_ERROR, 133, 0, JSEXN_SYNTAXERR, "syntax error") -MSG_DEF(JSMSG_BAD_SHARP_VAR_DEF, 134, 0, JSEXN_SYNTAXERR, "invalid sharp variable definition") -MSG_DEF(JSMSG_BAD_PROTOTYPE, 135, 1, JSEXN_TYPEERR, "'prototype' property of {0} is not an object") -MSG_DEF(JSMSG_MISSING_EXPONENT, 136, 0, JSEXN_SYNTAXERR, "missing exponent") -MSG_DEF(JSMSG_OUT_OF_MEMORY, 137, 0, JSEXN_ERR, "out of memory") -MSG_DEF(JSMSG_UNTERMINATED_STRING, 138, 0, JSEXN_SYNTAXERR, "unterminated string literal") -MSG_DEF(JSMSG_TOO_MANY_PARENS, 139, 0, JSEXN_INTERNALERR, "too many parentheses in regular expression") -MSG_DEF(JSMSG_UNTERMINATED_COMMENT, 140, 0, JSEXN_SYNTAXERR, "unterminated comment") -MSG_DEF(JSMSG_UNTERMINATED_REGEXP, 141, 0, JSEXN_SYNTAXERR, "unterminated regular expression literal") -MSG_DEF(JSMSG_BAD_CLONE_FUNOBJ_SCOPE, 142, 0, JSEXN_TYPEERR, "bad cloned function scope chain") -MSG_DEF(JSMSG_SHARPVAR_TOO_BIG, 143, 0, JSEXN_SYNTAXERR, "overlarge sharp variable number") -MSG_DEF(JSMSG_ILLEGAL_CHARACTER, 144, 0, JSEXN_SYNTAXERR, "illegal character") -MSG_DEF(JSMSG_BAD_OCTAL, 145, 1, JSEXN_SYNTAXERR, "{0} is not a legal ECMA-262 octal constant") -MSG_DEF(JSMSG_BAD_INDIRECT_CALL, 146, 1, JSEXN_EVALERR, "function {0} must be called directly, and not by way of a function of another name") -MSG_DEF(JSMSG_UNCAUGHT_EXCEPTION, 147, 1, JSEXN_INTERNALERR, "uncaught exception: {0}") -MSG_DEF(JSMSG_INVALID_BACKREF, 148, 0, JSEXN_SYNTAXERR, "non-octal digit in an escape sequence that doesn't match a back-reference") -MSG_DEF(JSMSG_BAD_BACKREF, 149, 0, JSEXN_SYNTAXERR, "back-reference exceeds number of capturing parentheses") -MSG_DEF(JSMSG_PRECISION_RANGE, 150, 1, JSEXN_RANGEERR, "precision {0} out of range") -MSG_DEF(JSMSG_BAD_GETTER_OR_SETTER, 151, 1, JSEXN_TYPEERR, "invalid {0} usage") -MSG_DEF(JSMSG_BAD_ARRAY_LENGTH, 152, 0, JSEXN_RANGEERR, "invalid array length") -MSG_DEF(JSMSG_CANT_DESCRIBE_PROPS, 153, 1, JSEXN_TYPEERR, "can't describe non-native properties of class {0}") -MSG_DEF(JSMSG_BAD_APPLY_ARGS, 154, 1, JSEXN_TYPEERR, "second argument to Function.prototype.{0} must be an array") -MSG_DEF(JSMSG_REDECLARED_VAR, 155, 2, JSEXN_TYPEERR, "redeclaration of {0} {1}") -MSG_DEF(JSMSG_UNDECLARED_VAR, 156, 1, JSEXN_REFERENCEERR, "assignment to undeclared variable {0}") -MSG_DEF(JSMSG_ANON_NO_RETURN_VALUE, 157, 0, JSEXN_TYPEERR, "anonymous function does not always return a value") -MSG_DEF(JSMSG_DEPRECATED_USAGE, 158, 1, JSEXN_REFERENCEERR, "deprecated {0} usage") -MSG_DEF(JSMSG_BAD_URI, 159, 0, JSEXN_URIERR, "malformed URI sequence") -MSG_DEF(JSMSG_GETTER_ONLY, 160, 0, JSEXN_TYPEERR, "setting a property that has only a getter") -MSG_DEF(JSMSG_IDSTART_AFTER_NUMBER, 161, 0, JSEXN_SYNTAXERR, "identifier starts immediately after numeric literal") -MSG_DEF(JSMSG_UNDEFINED_PROP, 162, 1, JSEXN_REFERENCEERR, "reference to undefined property {0}") -MSG_DEF(JSMSG_USELESS_EXPR, 163, 0, JSEXN_TYPEERR, "useless expression") -MSG_DEF(JSMSG_REDECLARED_PARAM, 164, 1, JSEXN_TYPEERR, "redeclaration of formal parameter {0}") -MSG_DEF(JSMSG_NEWREGEXP_FLAGGED, 165, 0, JSEXN_TYPEERR, "can't supply flags when constructing one RegExp from another") -MSG_DEF(JSMSG_RESERVED_SLOT_RANGE, 166, 0, JSEXN_RANGEERR, "reserved slot index out of range") -MSG_DEF(JSMSG_CANT_DECODE_PRINCIPALS, 167, 0, JSEXN_INTERNALERR, "can't decode JSPrincipals") -MSG_DEF(JSMSG_CANT_SEAL_OBJECT, 168, 1, JSEXN_ERR, "can't seal {0} objects") -MSG_DEF(JSMSG_TOO_MANY_CATCH_VARS, 169, 0, JSEXN_SYNTAXERR, "too many catch variables") -MSG_DEF(JSMSG_BAD_XML_MARKUP, 170, 0, JSEXN_SYNTAXERR, "invalid XML markup") -MSG_DEF(JSMSG_BAD_XML_CHARACTER, 171, 0, JSEXN_SYNTAXERR, "illegal XML character") -MSG_DEF(JSMSG_BAD_DEFAULT_XML_NAMESPACE,172,0,JSEXN_SYNTAXERR, "invalid default XML namespace") -MSG_DEF(JSMSG_BAD_XML_NAME_SYNTAX, 173, 0, JSEXN_SYNTAXERR, "invalid XML name") -MSG_DEF(JSMSG_BRACKET_AFTER_ATTR_EXPR,174, 0, JSEXN_SYNTAXERR, "missing ] after attribute expression") -MSG_DEF(JSMSG_NESTING_GENERATOR, 175, 1, JSEXN_TYPEERR, "already executing generator {0}") -MSG_DEF(JSMSG_CURLY_IN_XML_EXPR, 176, 0, JSEXN_SYNTAXERR, "missing } in XML expression") -MSG_DEF(JSMSG_BAD_XML_NAMESPACE, 177, 1, JSEXN_TYPEERR, "invalid XML namespace {0}") -MSG_DEF(JSMSG_BAD_XML_ATTR_NAME, 178, 1, JSEXN_TYPEERR, "invalid XML attribute name {0}") -MSG_DEF(JSMSG_BAD_XML_NAME, 179, 1, JSEXN_TYPEERR, "invalid XML name {0}") -MSG_DEF(JSMSG_BAD_XML_CONVERSION, 180, 1, JSEXN_TYPEERR, "can't convert {0} to XML") -MSG_DEF(JSMSG_BAD_XMLLIST_CONVERSION, 181, 1, JSEXN_TYPEERR, "can't convert {0} to XMLList") -MSG_DEF(JSMSG_BAD_GENERATOR_SEND, 182, 1, JSEXN_TYPEERR, "attempt to send {0} to newborn generator") -MSG_DEF(JSMSG_NO_ASSIGN_IN_XML_ATTR, 183, 0, JSEXN_SYNTAXERR, "missing = in XML attribute") -MSG_DEF(JSMSG_BAD_XML_ATTR_VALUE, 184, 0, JSEXN_SYNTAXERR, "invalid XML attribute value") -MSG_DEF(JSMSG_XML_TAG_NAME_MISMATCH, 185, 1, JSEXN_SYNTAXERR, "XML tag name mismatch (expected {0})") -MSG_DEF(JSMSG_BAD_XML_TAG_SYNTAX, 186, 0, JSEXN_SYNTAXERR, "invalid XML tag syntax") -MSG_DEF(JSMSG_BAD_XML_LIST_SYNTAX, 187, 0, JSEXN_SYNTAXERR, "invalid XML list syntax") -MSG_DEF(JSMSG_INCOMPATIBLE_METHOD, 188, 3, JSEXN_TYPEERR, "{0} {1} called on incompatible {2}") -MSG_DEF(JSMSG_CANT_SET_XML_ATTRS, 189, 0, JSEXN_INTERNALERR, "can't set XML property attributes") -MSG_DEF(JSMSG_END_OF_XML_SOURCE, 190, 0, JSEXN_SYNTAXERR, "unexpected end of XML source") -MSG_DEF(JSMSG_END_OF_XML_ENTITY, 191, 0, JSEXN_SYNTAXERR, "unexpected end of XML entity") -MSG_DEF(JSMSG_BAD_XML_QNAME, 192, 0, JSEXN_SYNTAXERR, "invalid XML qualified name") -MSG_DEF(JSMSG_BAD_FOR_EACH_LOOP, 193, 0, JSEXN_SYNTAXERR, "invalid for each loop") -MSG_DEF(JSMSG_BAD_XMLLIST_PUT, 194, 1, JSEXN_TYPEERR, "can't set property {0} in XMLList") -MSG_DEF(JSMSG_UNKNOWN_XML_ENTITY, 195, 1, JSEXN_TYPEERR, "unknown XML entity {0}") -MSG_DEF(JSMSG_BAD_XML_NCR, 196, 1, JSEXN_TYPEERR, "malformed XML character {0}") -MSG_DEF(JSMSG_UNDEFINED_XML_NAME, 197, 1, JSEXN_REFERENCEERR, "reference to undefined XML name {0}") -MSG_DEF(JSMSG_DUPLICATE_XML_ATTR, 198, 1, JSEXN_TYPEERR, "duplicate XML attribute {0}") -MSG_DEF(JSMSG_TOO_MANY_LOCALS, 199, 0, JSEXN_SYNTAXERR, "too many local variables") -MSG_DEF(JSMSG_ARRAY_INIT_TOO_BIG, 200, 0, JSEXN_INTERNALERR, "array initialiser too large") -MSG_DEF(JSMSG_REGEXP_TOO_COMPLEX, 201, 0, JSEXN_INTERNALERR, "regular expression too complex") -MSG_DEF(JSMSG_BUFFER_TOO_SMALL, 202, 0, JSEXN_INTERNALERR, "buffer too small") -MSG_DEF(JSMSG_BAD_SURROGATE_CHAR, 203, 1, JSEXN_TYPEERR, "bad surrogate character {0}") -MSG_DEF(JSMSG_UTF8_CHAR_TOO_LARGE, 204, 1, JSEXN_TYPEERR, "UTF-8 character {0} too large") -MSG_DEF(JSMSG_MALFORMED_UTF8_CHAR, 205, 1, JSEXN_TYPEERR, "malformed UTF-8 character sequence at offset {0}") -MSG_DEF(JSMSG_USER_DEFINED_ERROR, 206, 0, JSEXN_ERR, "JS_ReportError was called") -MSG_DEF(JSMSG_WRONG_CONSTRUCTOR, 207, 1, JSEXN_TYPEERR, "wrong constructor called for {0}") -MSG_DEF(JSMSG_BAD_GENERATOR_RETURN, 208, 1, JSEXN_TYPEERR, "generator function {0} returns a value") -MSG_DEF(JSMSG_BAD_ANON_GENERATOR_RETURN, 209, 0, JSEXN_TYPEERR, "anonymous generator function returns a value") -MSG_DEF(JSMSG_NAME_AFTER_FOR_PAREN, 210, 0, JSEXN_SYNTAXERR, "missing name after for (") -MSG_DEF(JSMSG_IN_AFTER_FOR_NAME, 211, 0, JSEXN_SYNTAXERR, "missing 'in' or 'of' after for") -MSG_DEF(JSMSG_BAD_TRAP_RETURN_VALUE, 212, 2, JSEXN_TYPEERR,"trap {1} for {0} returned a primitive value") -MSG_DEF(JSMSG_KEYWORD_NOT_NS, 213, 0, JSEXN_SYNTAXERR, "keyword is used as namespace") -MSG_DEF(JSMSG_BAD_GENERATOR_YIELD, 214, 1, JSEXN_TYPEERR, "yield from closing generator {0}") -MSG_DEF(JSMSG_BAD_GENERATOR_SYNTAX, 215, 1, JSEXN_SYNTAXERR, "{0} expression must be parenthesized") -MSG_DEF(JSMSG_ARRAY_COMP_LEFTSIDE, 216, 0, JSEXN_SYNTAXERR, "invalid array comprehension left-hand side") -MSG_DEF(JSMSG_NON_XML_FILTER, 217, 1, JSEXN_TYPEERR, "XML filter is applied to non-XML value {0}") -MSG_DEF(JSMSG_EMPTY_ARRAY_REDUCE, 218, 0, JSEXN_TYPEERR, "reduce of empty array with no initial value") -MSG_DEF(JSMSG_NON_LIST_XML_METHOD, 219, 2, JSEXN_TYPEERR, "can't call {0} method on an XML list with {1} elements") -MSG_DEF(JSMSG_BAD_DELETE_OPERAND, 220, 0, JSEXN_REFERENCEERR, "invalid delete operand") -MSG_DEF(JSMSG_BAD_INCOP_OPERAND, 221, 0, JSEXN_REFERENCEERR, "invalid increment/decrement operand") -MSG_DEF(JSMSG_UNEXPECTED_TYPE, 222, 2, JSEXN_TYPEERR, "{0} is {1}") -MSG_DEF(JSMSG_LET_DECL_NOT_IN_BLOCK, 223, 0, JSEXN_SYNTAXERR, "let declaration not directly within block") -MSG_DEF(JSMSG_BAD_OBJECT_INIT, 224, 0, JSEXN_SYNTAXERR, "invalid object initializer") -MSG_DEF(JSMSG_CANT_SET_ARRAY_ATTRS, 225, 0, JSEXN_INTERNALERR, "can't set attributes on indexed array properties") -MSG_DEF(JSMSG_EVAL_ARITY, 226, 0, JSEXN_TYPEERR, "eval accepts only one parameter") -MSG_DEF(JSMSG_MISSING_FUN_ARG, 227, 2, JSEXN_TYPEERR, "missing argument {0} when calling function {1}") -MSG_DEF(JSMSG_JSON_BAD_PARSE, 228, 1, JSEXN_SYNTAXERR, "JSON.parse: {0}") -MSG_DEF(JSMSG_JSON_BAD_STRINGIFY, 229, 0, JSEXN_ERR, "JSON.stringify") -MSG_DEF(JSMSG_NOT_CALLABLE_OR_UNDEFINED, 230, 0, JSEXN_TYPEERR, "value is not a function or undefined") -MSG_DEF(JSMSG_NOT_NONNULL_OBJECT, 231, 0, JSEXN_TYPEERR, "value is not a non-null object") -MSG_DEF(JSMSG_DEPRECATED_OCTAL, 232, 0, JSEXN_SYNTAXERR, "octal literals and octal escape sequences are deprecated") -MSG_DEF(JSMSG_STRICT_CODE_WITH, 233, 0, JSEXN_SYNTAXERR, "strict mode code may not contain 'with' statements") -MSG_DEF(JSMSG_DUPLICATE_PROPERTY, 234, 1, JSEXN_SYNTAXERR, "property name {0} appears more than once in object literal") -MSG_DEF(JSMSG_DEPRECATED_DELETE_OPERAND, 235, 0, JSEXN_SYNTAXERR, "applying the 'delete' operator to an unqualified name is deprecated") -MSG_DEF(JSMSG_DEPRECATED_ASSIGN, 236, 1, JSEXN_SYNTAXERR, "assignment to {0} is deprecated") -MSG_DEF(JSMSG_BAD_BINDING, 237, 1, JSEXN_SYNTAXERR, "redefining {0} is deprecated") -MSG_DEF(JSMSG_INVALID_DESCRIPTOR, 238, 0, JSEXN_TYPEERR, "property descriptors must not specify a value or be writable when a getter or setter has been specified") -MSG_DEF(JSMSG_OBJECT_NOT_EXTENSIBLE, 239, 1, JSEXN_TYPEERR, "{0} is not extensible") -MSG_DEF(JSMSG_CANT_REDEFINE_PROP, 240, 1, JSEXN_TYPEERR, "can't redefine non-configurable property '{0}'") -MSG_DEF(JSMSG_CANT_APPEND_TO_ARRAY, 241, 0, JSEXN_TYPEERR, "can't add elements past the end of an array if its length property is unwritable") -MSG_DEF(JSMSG_CANT_DEFINE_ARRAY_LENGTH,242, 0, JSEXN_INTERNALERR, "defining the length property on an array is not currently supported") -MSG_DEF(JSMSG_CANT_DEFINE_ARRAY_INDEX,243, 0, JSEXN_TYPEERR, "can't define array index property") -MSG_DEF(JSMSG_TYPED_ARRAY_BAD_INDEX, 244, 0, JSEXN_ERR, "invalid or out-of-range index") -MSG_DEF(JSMSG_TYPED_ARRAY_NEGATIVE_ARG, 245, 1, JSEXN_ERR, "argument {0} must be >= 0") -MSG_DEF(JSMSG_TYPED_ARRAY_BAD_ARGS, 246, 0, JSEXN_ERR, "invalid arguments") -MSG_DEF(JSMSG_CSP_BLOCKED_FUNCTION, 247, 0, JSEXN_ERR, "call to Function() blocked by CSP") -MSG_DEF(JSMSG_BAD_GET_SET_FIELD, 248, 1, JSEXN_TYPEERR, "property descriptor's {0} field is neither undefined nor a function") -MSG_DEF(JSMSG_BAD_PROXY_FIX, 249, 0, JSEXN_TYPEERR, "proxy was fixed while executing the handler") -MSG_DEF(JSMSG_INVALID_EVAL_SCOPE_ARG, 250, 0, JSEXN_EVALERR, "invalid eval scope argument") -MSG_DEF(JSMSG_ACCESSOR_WRONG_ARGS, 251, 3, JSEXN_SYNTAXERR, "{0} functions must have {1} argument{2}") -MSG_DEF(JSMSG_THROW_TYPE_ERROR, 252, 0, JSEXN_TYPEERR, "'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them") -MSG_DEF(JSMSG_BAD_TOISOSTRING_PROP, 253, 0, JSEXN_TYPEERR, "toISOString property is not callable") -MSG_DEF(JSMSG_BAD_PARSE_NODE, 254, 0, JSEXN_INTERNALERR, "bad parse node") -MSG_DEF(JSMSG_NOT_EXPECTED_TYPE, 255, 3, JSEXN_TYPEERR, "{0}: expected {1}, got {2}") -MSG_DEF(JSMSG_CALLER_IS_STRICT, 256, 0, JSEXN_TYPEERR, "access to strict mode caller function is censored") -MSG_DEF(JSMSG_NEED_DEBUG_MODE, 257, 0, JSEXN_ERR, "function can be called only in debug mode") -MSG_DEF(JSMSG_STRICT_CODE_LET_EXPR_STMT, 258, 0, JSEXN_ERR, "strict mode code may not contain unparenthesized let expression statements") -MSG_DEF(JSMSG_CANT_CHANGE_EXTENSIBILITY, 259, 0, JSEXN_TYPEERR, "can't change object's extensibility") -MSG_DEF(JSMSG_SC_BAD_SERIALIZED_DATA, 260, 1, JSEXN_INTERNALERR, "bad serialized structured data ({0})") -MSG_DEF(JSMSG_SC_UNSUPPORTED_TYPE, 261, 0, JSEXN_TYPEERR, "unsupported type for structured data") -MSG_DEF(JSMSG_SC_RECURSION, 262, 0, JSEXN_INTERNALERR, "recursive object") -MSG_DEF(JSMSG_CANT_WRAP_XML_OBJECT, 263, 0, JSEXN_TYPEERR, "can't wrap XML objects") -MSG_DEF(JSMSG_BAD_CLONE_VERSION, 264, 0, JSEXN_ERR, "unsupported structured clone version") -MSG_DEF(JSMSG_CANT_CLONE_OBJECT, 265, 0, JSEXN_TYPEERR, "can't clone object") -MSG_DEF(JSMSG_NON_NATIVE_SCOPE, 266, 0, JSEXN_TYPEERR, "non-native scope object") -MSG_DEF(JSMSG_STRICT_FUNCTION_STATEMENT, 267, 0, JSEXN_SYNTAXERR, "in strict mode code, functions may be declared only at top level or immediately within another function") -MSG_DEF(JSMSG_INVALID_FOR_IN_INIT, 268, 0, JSEXN_SYNTAXERR, "for-in loop let declaration may not have an initializer") -MSG_DEF(JSMSG_CLEARED_SCOPE, 269, 0, JSEXN_TYPEERR, "attempt to run compile-and-go script on a cleared scope") -MSG_DEF(JSMSG_MALFORMED_ESCAPE, 270, 1, JSEXN_SYNTAXERR, "malformed {0} character escape sequence") -MSG_DEF(JSMSG_BAD_GENEXP_BODY, 271, 1, JSEXN_SYNTAXERR, "illegal use of {0} in generator expression") -MSG_DEF(JSMSG_XML_PROTO_FORBIDDEN, 272, 0, JSEXN_TYPEERR, "can't set prototype of an object to an XML value") -MSG_DEF(JSMSG_UNNAMED_FUNCTION_STMT, 273, 0, JSEXN_SYNTAXERR, "function statement requires a name") -MSG_DEF(JSMSG_CCW_REQUIRED, 274, 1, JSEXN_TYPEERR, "{0}: argument must be an object from a different compartment") -MSG_DEF(JSMSG_DEBUG_BAD_RESUMPTION, 275, 0, JSEXN_TYPEERR, "debugger resumption value must be undefined, {throw: val}, {return: val}, or null") -MSG_DEF(JSMSG_ASSIGN_FUNCTION_OR_NULL, 276, 1, JSEXN_TYPEERR, "value assigned to {0} must be a function or null") -MSG_DEF(JSMSG_DEBUG_NOT_LIVE, 277, 1, JSEXN_ERR, "{0} is not live") -MSG_DEF(JSMSG_DEBUG_OBJECT_WRONG_OWNER, 278, 0, JSEXN_TYPEERR, "Debugger.Object belongs to a different Debugger") -MSG_DEF(JSMSG_DEBUG_OBJECT_PROTO, 279, 0, JSEXN_TYPEERR, "Debugger.Object.prototype is not a valid Debugger.Object") -MSG_DEF(JSMSG_DEBUG_LOOP, 280, 0, JSEXN_TYPEERR, "cannot debug an object in same compartment as debugger or a compartment that is already debugging the debugger") -MSG_DEF(JSMSG_DEBUG_NOT_IDLE, 281, 0, JSEXN_ERR, "can't start debugging: a debuggee script is on the stack") -MSG_DEF(JSMSG_DEBUG_BAD_OFFSET, 282, 0, JSEXN_TYPEERR, "invalid script offset") -MSG_DEF(JSMSG_DEBUG_BAD_LINE, 283, 0, JSEXN_TYPEERR, "invalid line number") -MSG_DEF(JSMSG_DEBUG_NOT_DEBUGGING, 284, 0, JSEXN_ERR, "can't set breakpoint: script global is not a debuggee") -MSG_DEF(JSMSG_DEBUG_COMPARTMENT_MISMATCH, 285, 2, JSEXN_TYPEERR, "{0}: descriptor .{1} property is an object in a different compartment than the target object") -MSG_DEF(JSMSG_DEBUG_NOT_SCRIPT_FRAME, 286, 0, JSEXN_ERR, "stack frame is not running JavaScript code") -MSG_DEF(JSMSG_CANT_WATCH_PROP, 287, 0, JSEXN_TYPEERR, "properties whose names are objects can't be watched") -MSG_DEF(JSMSG_CSP_BLOCKED_EVAL, 288, 0, JSEXN_ERR, "call to eval() blocked by CSP") -MSG_DEF(JSMSG_DEBUG_NO_SCOPE_OBJECT, 289, 0, JSEXN_TYPEERR, "declarative Environments don't have binding objects") -MSG_DEF(JSMSG_EMPTY_CONSEQUENT, 290, 0, JSEXN_SYNTAXERR, "mistyped ; after conditional?") -MSG_DEF(JSMSG_NOT_ITERABLE, 291, 1, JSEXN_TYPEERR, "{0} is not iterable") diff --git a/js/spidermonkey-win32/include/js/HashTable.h b/js/spidermonkey-win32/include/js/HashTable.h deleted file mode 100644 index 48cb777574..0000000000 --- a/js/spidermonkey-win32/include/js/HashTable.h +++ /dev/null @@ -1,1357 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sw=4 et tw=99 ft=cpp: - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released - * November 13, 2009. - * - * The Initial Developer of the Original Code is - * the Mozilla Corporation. - * - * Contributor(s): - * Brendan Eich (Original Author) - * Chris Waterson - * L. David Baron , Mozilla Corporation - * Luke Wagner - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef jshashtable_h_ -#define jshashtable_h_ - -#include "TemplateLib.h" -#include "Utility.h" - -namespace js { - -class TempAllocPolicy; - -/* Integral types for all hash functions. */ -typedef uint32_t HashNumber; - -/*****************************************************************************/ - -namespace detail { - -template -class HashTable; - -template -class HashTableEntry { - HashNumber keyHash; - - typedef typename tl::StripConst::result NonConstT; - - static const HashNumber sFreeKey = 0; - static const HashNumber sRemovedKey = 1; - static const HashNumber sCollisionBit = 1; - - template friend class HashTable; - - static bool isLiveHash(HashNumber hash) - { - return hash > sRemovedKey; - } - - public: - HashTableEntry() : keyHash(0), t() {} - HashTableEntry(MoveRef rhs) : keyHash(rhs->keyHash), t(Move(rhs->t)) { } - void operator=(const HashTableEntry &rhs) { keyHash = rhs.keyHash; t = rhs.t; } - void operator=(MoveRef rhs) { keyHash = rhs->keyHash; t = Move(rhs->t); } - - NonConstT t; - - bool isFree() const { return keyHash == sFreeKey; } - void setFree() { keyHash = sFreeKey; t = T(); } - bool isRemoved() const { return keyHash == sRemovedKey; } - void setRemoved() { keyHash = sRemovedKey; t = T(); } - bool isLive() const { return isLiveHash(keyHash); } - void setLive(HashNumber hn) { JS_ASSERT(isLiveHash(hn)); keyHash = hn; } - - void setCollision() { JS_ASSERT(isLive()); keyHash |= sCollisionBit; } - void setCollision(HashNumber collisionBit) { - JS_ASSERT(isLive()); keyHash |= collisionBit; - } - void unsetCollision() { JS_ASSERT(isLive()); keyHash &= ~sCollisionBit; } - bool hasCollision() const { JS_ASSERT(isLive()); return keyHash & sCollisionBit; } - bool matchHash(HashNumber hn) { return (keyHash & ~sCollisionBit) == hn; } - HashNumber getKeyHash() const { JS_ASSERT(!hasCollision()); return keyHash; } -}; - -/* - * js::detail::HashTable is an implementation detail of the js::HashMap and - * js::HashSet templates. For js::Hash{Map,Set} API documentation and examples, - * skip to the end of the detail namespace. - */ - -/* Reusable implementation of HashMap and HashSet. */ -template -class HashTable : private AllocPolicy -{ - typedef typename tl::StripConst::result NonConstT; - typedef typename HashPolicy::KeyType Key; - typedef typename HashPolicy::Lookup Lookup; - - public: - typedef HashTableEntry Entry; - - /* - * A nullable pointer to a hash table element. A Ptr |p| can be tested - * either explicitly |if (p.found()) p->...| or using boolean conversion - * |if (p) p->...|. Ptr objects must not be used after any mutating hash - * table operations unless |generation()| is tested. - */ - class Ptr - { - friend class HashTable; - typedef void (Ptr::* ConvertibleToBool)(); - void nonNull() {} - - Entry *entry; - - protected: - Ptr(Entry &entry) : entry(&entry) {} - - public: - /* Leaves Ptr uninitialized. */ - Ptr() { -#ifdef DEBUG - entry = (Entry *)0xbad; -#endif - } - - bool found() const { return entry->isLive(); } - operator ConvertibleToBool() const { return found() ? &Ptr::nonNull : 0; } - bool operator==(const Ptr &rhs) const { JS_ASSERT(found() && rhs.found()); return entry == rhs.entry; } - bool operator!=(const Ptr &rhs) const { return !(*this == rhs); } - - T &operator*() const { return entry->t; } - T *operator->() const { return &entry->t; } - }; - - /* A Ptr that can be used to add a key after a failed lookup. */ - class AddPtr : public Ptr - { - friend class HashTable; - HashNumber keyHash; -#ifdef DEBUG - uint64_t mutationCount; - - AddPtr(Entry &entry, HashNumber hn, uint64_t mutationCount) - : Ptr(entry), keyHash(hn), mutationCount(mutationCount) {} -#else - AddPtr(Entry &entry, HashNumber hn) : Ptr(entry), keyHash(hn) {} -#endif - public: - /* Leaves AddPtr uninitialized. */ - AddPtr() {} - }; - - /* - * A collection of hash table entries. The collection is enumerated by - * calling |front()| followed by |popFront()| as long as |!empty()|. As - * with Ptr/AddPtr, Range objects must not be used after any mutating hash - * table operation unless the |generation()| is tested. - */ - class Range - { - protected: - friend class HashTable; - - Range(Entry *c, Entry *e) : cur(c), end(e) { - while (cur < end && !cur->isLive()) - ++cur; - } - - Entry *cur, *end; - - public: - Range() : cur(NULL), end(NULL) {} - - bool empty() const { - return cur == end; - } - - T &front() const { - JS_ASSERT(!empty()); - return cur->t; - } - - void popFront() { - JS_ASSERT(!empty()); - while (++cur < end && !cur->isLive()) - continue; - } - }; - - /* - * A Range whose lifetime delimits a mutating enumeration of a hash table. - * Since rehashing when elements were removed during enumeration would be - * bad, it is postponed until |endEnumeration()| is called. If - * |endEnumeration()| is not called before an Enum's constructor, it will - * be called automatically. Since |endEnumeration()| touches the hash - * table, the user must ensure that the hash table is still alive when this - * happens. - */ - class Enum : public Range - { - friend class HashTable; - - HashTable &table; - bool removed; - - /* Not copyable. */ - Enum(const Enum &); - void operator=(const Enum &); - - public: - template explicit - Enum(Map &map) : Range(map.all()), table(map.impl), removed(false) {} - - /* - * Removes the |front()| element from the table, leaving |front()| - * invalid until the next call to |popFront()|. For example: - * - * HashSet s; - * for (HashSet::Enum e(s); !e.empty(); e.popFront()) - * if (e.front() == 42) - * e.removeFront(); - */ - void removeFront() { - table.remove(*this->cur); - removed = true; - } - - /* Potentially rehashes the table. */ - ~Enum() { - if (removed) - table.checkUnderloaded(); - } - - /* Can be used to end the enumeration before the destructor. */ - void endEnumeration() { - if (removed) { - table.checkUnderloaded(); - removed = false; - } - } - }; - - private: - uint32_t hashShift; /* multiplicative hash shift */ - uint32_t entryCount; /* number of entries in table */ - uint32_t gen; /* entry storage generation number */ - uint32_t removedCount; /* removed entry sentinels in table */ - Entry *table; /* entry storage */ - - void setTableSizeLog2(unsigned sizeLog2) { - hashShift = sHashBits - sizeLog2; - } - -#ifdef DEBUG - mutable struct Stats { - uint32_t searches; /* total number of table searches */ - uint32_t steps; /* hash chain links traversed */ - uint32_t hits; /* searches that found key */ - uint32_t misses; /* searches that didn't find key */ - uint32_t addOverRemoved; /* adds that recycled a removed entry */ - uint32_t removes; /* calls to remove */ - uint32_t removeFrees; /* calls to remove that freed the entry */ - uint32_t grows; /* table expansions */ - uint32_t shrinks; /* table contractions */ - uint32_t compresses; /* table compressions */ - } stats; -# define METER(x) x -#else -# define METER(x) -#endif - -#ifdef DEBUG - friend class js::ReentrancyGuard; - mutable bool entered; - uint64_t mutationCount; -#endif - - /* The default initial capacity is 16, but you can ask for as small as 4. */ - static const unsigned sMinSizeLog2 = 2; - static const unsigned sMinSize = 1 << sMinSizeLog2; - static const unsigned sDefaultInitSizeLog2 = 4; - public: - static const unsigned sDefaultInitSize = 1 << sDefaultInitSizeLog2; - private: - static const unsigned sMaxInit = JS_BIT(23); - static const unsigned sMaxCapacity = JS_BIT(24); - static const unsigned sHashBits = tl::BitSize::result; - static const uint8_t sMinAlphaFrac = 64; /* (0x100 * .25) taken from jsdhash.h */ - static const uint8_t sMaxAlphaFrac = 192; /* (0x100 * .75) taken from jsdhash.h */ - static const uint8_t sInvMaxAlpha = 171; /* (ceil(0x100 / .75) >> 1) */ - static const HashNumber sGoldenRatio = 0x9E3779B9U; /* taken from jsdhash.h */ - static const HashNumber sFreeKey = Entry::sFreeKey; - static const HashNumber sRemovedKey = Entry::sRemovedKey; - static const HashNumber sCollisionBit = Entry::sCollisionBit; - - static void staticAsserts() - { - /* Rely on compiler "constant overflow warnings". */ - JS_STATIC_ASSERT(((sMaxInit * sInvMaxAlpha) >> 7) < sMaxCapacity); - JS_STATIC_ASSERT((sMaxCapacity * sInvMaxAlpha) <= UINT32_MAX); - JS_STATIC_ASSERT((sMaxCapacity * sizeof(Entry)) <= UINT32_MAX); - } - - static bool isLiveHash(HashNumber hash) - { - return Entry::isLiveHash(hash); - } - - static HashNumber prepareHash(const Lookup& l) - { - HashNumber keyHash = HashPolicy::hash(l); - - /* Improve keyHash distribution. */ - keyHash *= sGoldenRatio; - - /* Avoid reserved hash codes. */ - if (!isLiveHash(keyHash)) - keyHash -= (sRemovedKey + 1); - return keyHash & ~sCollisionBit; - } - - static Entry *createTable(AllocPolicy &alloc, uint32_t capacity) - { - Entry *newTable = (Entry *)alloc.malloc_(capacity * sizeof(Entry)); - if (!newTable) - return NULL; - for (Entry *e = newTable, *end = e + capacity; e < end; ++e) - new(e) Entry(); - return newTable; - } - - static void destroyTable(AllocPolicy &alloc, Entry *oldTable, uint32_t capacity) - { - for (Entry *e = oldTable, *end = e + capacity; e < end; ++e) - e->~Entry(); - alloc.free_(oldTable); - } - - public: - HashTable(AllocPolicy ap) - : AllocPolicy(ap), - hashShift(sHashBits), - entryCount(0), - gen(0), - removedCount(0), - table(NULL) -#ifdef DEBUG - , entered(false), - mutationCount(0) -#endif - {} - - bool init(uint32_t length) - { - /* Make sure that init isn't called twice. */ - JS_ASSERT(table == NULL); - - /* - * Correct for sMaxAlphaFrac such that the table will not resize - * when adding 'length' entries. - */ - if (length > sMaxInit) { - this->reportAllocOverflow(); - return false; - } - uint32_t capacity = (length * sInvMaxAlpha) >> 7; - - if (capacity < sMinSize) - capacity = sMinSize; - - /* FIXME: use JS_CEILING_LOG2 when PGO stops crashing (bug 543034). */ - uint32_t roundUp = sMinSize, roundUpLog2 = sMinSizeLog2; - while (roundUp < capacity) { - roundUp <<= 1; - ++roundUpLog2; - } - - capacity = roundUp; - JS_ASSERT(capacity <= sMaxCapacity); - - table = createTable(*this, capacity); - if (!table) - return false; - - setTableSizeLog2(roundUpLog2); - METER(memset(&stats, 0, sizeof(stats))); - return true; - } - - bool initialized() const - { - return !!table; - } - - ~HashTable() - { - if (table) - destroyTable(*this, table, capacity()); - } - - private: - static HashNumber hash1(HashNumber hash0, uint32_t shift) { - return hash0 >> shift; - } - - static HashNumber hash2(HashNumber hash0, uint32_t log2, uint32_t shift) { - return ((hash0 << log2) >> shift) | 1; - } - - bool overloaded() { - return entryCount + removedCount >= ((sMaxAlphaFrac * capacity()) >> 8); - } - - bool underloaded() { - uint32_t tableCapacity = capacity(); - return tableCapacity > sMinSize && - entryCount <= ((sMinAlphaFrac * tableCapacity) >> 8); - } - - static bool match(Entry &e, const Lookup &l) { - return HashPolicy::match(HashPolicy::getKey(e.t), l); - } - - Entry &lookup(const Lookup &l, HashNumber keyHash, unsigned collisionBit) const - { - JS_ASSERT(isLiveHash(keyHash)); - JS_ASSERT(!(keyHash & sCollisionBit)); - JS_ASSERT(collisionBit == 0 || collisionBit == sCollisionBit); - JS_ASSERT(table); - METER(stats.searches++); - - /* Compute the primary hash address. */ - HashNumber h1 = hash1(keyHash, hashShift); - Entry *entry = &table[h1]; - - /* Miss: return space for a new entry. */ - if (entry->isFree()) { - METER(stats.misses++); - return *entry; - } - - /* Hit: return entry. */ - if (entry->matchHash(keyHash) && match(*entry, l)) { - METER(stats.hits++); - return *entry; - } - - /* Collision: double hash. */ - unsigned sizeLog2 = sHashBits - hashShift; - HashNumber h2 = hash2(keyHash, sizeLog2, hashShift); - HashNumber sizeMask = (HashNumber(1) << sizeLog2) - 1; - - /* Save the first removed entry pointer so we can recycle later. */ - Entry *firstRemoved = NULL; - - while(true) { - if (JS_UNLIKELY(entry->isRemoved())) { - if (!firstRemoved) - firstRemoved = entry; - } else { - entry->setCollision(collisionBit); - } - - METER(stats.steps++); - h1 -= h2; - h1 &= sizeMask; - - entry = &table[h1]; - if (entry->isFree()) { - METER(stats.misses++); - return firstRemoved ? *firstRemoved : *entry; - } - - if (entry->matchHash(keyHash) && match(*entry, l)) { - METER(stats.hits++); - return *entry; - } - } - } - - /* - * This is a copy of lookup hardcoded to the assumptions: - * 1. the lookup is a lookupForAdd - * 2. the key, whose |keyHash| has been passed is not in the table, - * 3. no entries have been removed from the table. - * This specialized search avoids the need for recovering lookup values - * from entries, which allows more flexible Lookup/Key types. - */ - Entry &findFreeEntry(HashNumber keyHash) - { - METER(stats.searches++); - JS_ASSERT(!(keyHash & sCollisionBit)); - - /* N.B. the |keyHash| has already been distributed. */ - - /* Compute the primary hash address. */ - HashNumber h1 = hash1(keyHash, hashShift); - Entry *entry = &table[h1]; - - /* Miss: return space for a new entry. */ - if (entry->isFree()) { - METER(stats.misses++); - return *entry; - } - - /* Collision: double hash. */ - unsigned sizeLog2 = sHashBits - hashShift; - HashNumber h2 = hash2(keyHash, sizeLog2, hashShift); - HashNumber sizeMask = (HashNumber(1) << sizeLog2) - 1; - - while(true) { - JS_ASSERT(!entry->isRemoved()); - entry->setCollision(); - - METER(stats.steps++); - h1 -= h2; - h1 &= sizeMask; - - entry = &table[h1]; - if (entry->isFree()) { - METER(stats.misses++); - return *entry; - } - } - } - - bool changeTableSize(int deltaLog2) - { - /* Look, but don't touch, until we succeed in getting new entry store. */ - Entry *oldTable = table; - uint32_t oldCap = capacity(); - uint32_t newLog2 = sHashBits - hashShift + deltaLog2; - uint32_t newCapacity = JS_BIT(newLog2); - if (newCapacity > sMaxCapacity) { - this->reportAllocOverflow(); - return false; - } - - Entry *newTable = createTable(*this, newCapacity); - if (!newTable) - return false; - - /* We can't fail from here on, so update table parameters. */ - setTableSizeLog2(newLog2); - removedCount = 0; - gen++; - table = newTable; - - /* Copy only live entries, leaving removed ones behind. */ - for (Entry *src = oldTable, *end = src + oldCap; src < end; ++src) { - if (src->isLive()) { - src->unsetCollision(); - findFreeEntry(src->getKeyHash()) = Move(*src); - } - } - - destroyTable(*this, oldTable, oldCap); - return true; - } - - void remove(Entry &e) - { - METER(stats.removes++); - if (e.hasCollision()) { - e.setRemoved(); - removedCount++; - } else { - METER(stats.removeFrees++); - e.setFree(); - } - entryCount--; -#ifdef DEBUG - mutationCount++; -#endif - } - - void checkUnderloaded() - { - if (underloaded()) { - METER(stats.shrinks++); - (void) changeTableSize(-1); - } - } - - public: - void clear() - { - if (tl::IsPodType::result) { - memset(table, 0, sizeof(*table) * capacity()); - } else { - uint32_t tableCapacity = capacity(); - for (Entry *e = table, *end = table + tableCapacity; e < end; ++e) - *e = Move(Entry()); - } - removedCount = 0; - entryCount = 0; -#ifdef DEBUG - mutationCount++; -#endif - } - - void finish() - { - JS_ASSERT(!entered); - - if (!table) - return; - - destroyTable(*this, table, capacity()); - table = NULL; - gen++; - entryCount = 0; - removedCount = 0; -#ifdef DEBUG - mutationCount++; -#endif - } - - Range all() const { - return Range(table, table + capacity()); - } - - bool empty() const { - return !entryCount; - } - - uint32_t count() const { - return entryCount; - } - - uint32_t capacity() const { - return JS_BIT(sHashBits - hashShift); - } - - uint32_t generation() const { - return gen; - } - - size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const { - return mallocSizeOf(table); - } - - size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const { - return mallocSizeOf(this) + sizeOfExcludingThis(mallocSizeOf); - } - - Ptr lookup(const Lookup &l) const { - ReentrancyGuard g(*this); - HashNumber keyHash = prepareHash(l); - return Ptr(lookup(l, keyHash, 0)); - } - - AddPtr lookupForAdd(const Lookup &l) const { - ReentrancyGuard g(*this); - HashNumber keyHash = prepareHash(l); - Entry &entry = lookup(l, keyHash, sCollisionBit); -#ifdef DEBUG - return AddPtr(entry, keyHash, mutationCount); -#else - return AddPtr(entry, keyHash); -#endif - } - - bool add(AddPtr &p) - { - ReentrancyGuard g(*this); - JS_ASSERT(mutationCount == p.mutationCount); - JS_ASSERT(table); - JS_ASSERT(!p.found()); - JS_ASSERT(!(p.keyHash & sCollisionBit)); - - /* - * Changing an entry from removed to live does not affect whether we - * are overloaded and can be handled separately. - */ - if (p.entry->isRemoved()) { - METER(stats.addOverRemoved++); - removedCount--; - p.keyHash |= sCollisionBit; - } else { - /* If alpha is >= .75, grow or compress the table. */ - if (overloaded()) { - /* Compress if a quarter or more of all entries are removed. */ - int deltaLog2; - if (removedCount >= (capacity() >> 2)) { - METER(stats.compresses++); - deltaLog2 = 0; - } else { - METER(stats.grows++); - deltaLog2 = 1; - } - - if (!changeTableSize(deltaLog2)) - return false; - - /* Preserve the validity of |p.entry|. */ - p.entry = &findFreeEntry(p.keyHash); - } - } - - p.entry->setLive(p.keyHash); - entryCount++; -#ifdef DEBUG - mutationCount++; -#endif - return true; - } - - /* - * There is an important contract between the caller and callee for this - * function: if add() returns true, the caller must assign the T value - * which produced p before using the hashtable again. - */ - bool add(AddPtr &p, T** pentry) - { - if (!add(p)) - return false; - *pentry = &p.entry->t; - return true; - } - - bool add(AddPtr &p, const T &t) - { - if (!add(p)) - return false; - p.entry->t = t; - return true; - } - - bool relookupOrAdd(AddPtr& p, const Lookup &l, const T& t) - { -#ifdef DEBUG - p.mutationCount = mutationCount; -#endif - { - ReentrancyGuard g(*this); - p.entry = &lookup(l, p.keyHash, sCollisionBit); - } - return p.found() || add(p, t); - } - - void remove(Ptr p) - { - ReentrancyGuard g(*this); - JS_ASSERT(p.found()); - remove(*p.entry); - checkUnderloaded(); - } -#undef METER -}; - -} /* namespace detail */ - -/*****************************************************************************/ - -/* - * Hash policy - * - * A hash policy P for a hash table with key-type Key must provide: - * - a type |P::Lookup| to use to lookup table entries; - * - a static member function |P::hash| with signature - * - * static js::HashNumber hash(Lookup) - * - * to use to hash the lookup type; and - * - a static member function |P::match| with signature - * - * static bool match(Key, Lookup) - * - * to use to test equality of key and lookup values. - * - * Normally, Lookup = Key. In general, though, different values and types of - * values can be used to lookup and store. If a Lookup value |l| is != to the - * added Key value |k|, the user must ensure that |P::match(k,l)|. E.g.: - * - * js::HashSet::AddPtr p = h.lookup(l); - * if (!p) { - * assert(P::match(k, l)); // must hold - * h.add(p, k); - * } - */ - -/* Default hashing policies. */ -template -struct DefaultHasher -{ - typedef Key Lookup; - static HashNumber hash(const Lookup &l) { - /* Hash if can implicitly cast to hash number type. */ - return l; - } - static bool match(const Key &k, const Lookup &l) { - /* Use builtin or overloaded operator==. */ - return k == l; - } -}; - -/* - * Pointer hashing policy that strips the lowest zeroBits when calculating the - * hash to improve key distribution. - */ -template -struct PointerHasher -{ - typedef Key Lookup; - static HashNumber hash(const Lookup &l) { - size_t word = reinterpret_cast(l) >> zeroBits; - JS_STATIC_ASSERT(sizeof(HashNumber) == 4); -#if JS_BYTES_PER_WORD == 4 - return HashNumber(word); -#else - JS_STATIC_ASSERT(sizeof word == 8); - return HashNumber((word >> 32) ^ word); -#endif - } - static bool match(const Key &k, const Lookup &l) { - return k == l; - } -}; - -template -struct TaggedPointerHasher -{ - typedef Key Lookup; - - static HashNumber hash(const Lookup &l) { - return PointerHasher::hash(l); - } - - static const uintptr_t COMPARE_MASK = uintptr_t(-1) - 1; - - static bool match(const Key &k, const Lookup &l) { - return (uintptr_t(k) & COMPARE_MASK) == uintptr_t(l); - } -}; - -/* - * Specialized hashing policy for pointer types. It assumes that the type is - * at least word-aligned. For types with smaller size use PointerHasher. - */ -template -struct DefaultHasher: PointerHasher::result> { }; - -/* Looking for a hasher for jsid? Try the DefaultHasher in jsatom.h. */ - -template -class HashMapEntry -{ - template friend class detail::HashTable; - template friend class detail::HashTableEntry; - void operator=(const HashMapEntry &rhs) { - const_cast(key) = rhs.key; - value = rhs.value; - } - - public: - HashMapEntry() : key(), value() {} - - template - HashMapEntry(const KeyInput &k, const ValueInput &v) : key(k), value(v) {} - - HashMapEntry(MoveRef rhs) - : key(Move(rhs->key)), value(Move(rhs->value)) { } - void operator=(MoveRef rhs) { - const_cast(key) = Move(rhs->key); - value = Move(rhs->value); - } - - const Key key; - Value value; -}; - -namespace tl { - -template -struct IsPodType > { - static const bool result = IsPodType::result; -}; - -template -struct IsPodType > -{ - static const bool result = IsPodType::result && IsPodType::result; -}; - -} /* namespace tl */ - -/* - * JS-friendly, STL-like container providing a hash-based map from keys to - * values. In particular, HashMap calls constructors and destructors of all - * objects added so non-PODs may be used safely. - * - * Key/Value requirements: - * - default constructible, copyable, destructible, assignable - * HashPolicy requirements: - * - see "Hash policy" above (default js::DefaultHasher) - * AllocPolicy: - * - see "Allocation policies" in jsalloc.h - * - * N.B: HashMap is not reentrant: Key/Value/HashPolicy/AllocPolicy members - * called by HashMap must not call back into the same HashMap object. - * N.B: Due to the lack of exception handling, the user must call |init()|. - */ -template , - class AllocPolicy = TempAllocPolicy> -class HashMap -{ - public: - typedef typename HashPolicy::Lookup Lookup; - - typedef HashMapEntry Entry; - - private: - /* Implement HashMap using HashTable. Lift |Key| operations to |Entry|. */ - struct MapHashPolicy : HashPolicy - { - typedef Key KeyType; - static const Key &getKey(Entry &e) { return e.key; } - }; - typedef detail::HashTable Impl; - - friend class Impl::Enum; - - /* Not implicitly copyable (expensive). May add explicit |clone| later. */ - HashMap(const HashMap &); - HashMap &operator=(const HashMap &); - - Impl impl; - - public: - /* - * HashMap construction is fallible (due to OOM); thus the user must call - * init after constructing a HashMap and check the return value. - */ - HashMap(AllocPolicy a = AllocPolicy()) : impl(a) {} - bool init(uint32_t len = Impl::sDefaultInitSize) { return impl.init(len); } - bool initialized() const { return impl.initialized(); } - - /* - * Return whether the given lookup value is present in the map. E.g.: - * - * typedef HashMap HM; - * HM h; - * if (HM::Ptr p = h.lookup(3)) { - * const HM::Entry &e = *p; // p acts like a pointer to Entry - * assert(p->key == 3); // Entry contains the key - * char val = p->value; // and value - * } - * - * Also see the definition of Ptr in HashTable above (with T = Entry). - */ - typedef typename Impl::Ptr Ptr; - Ptr lookup(const Lookup &l) const { return impl.lookup(l); } - - /* Assuming |p.found()|, remove |*p|. */ - void remove(Ptr p) { impl.remove(p); } - - /* - * Like |lookup(l)|, but on miss, |p = lookupForAdd(l)| allows efficient - * insertion of Key |k| (where |HashPolicy::match(k,l) == true|) using - * |add(p,k,v)|. After |add(p,k,v)|, |p| points to the new Entry. E.g.: - * - * typedef HashMap HM; - * HM h; - * HM::AddPtr p = h.lookupForAdd(3); - * if (!p) { - * if (!h.add(p, 3, 'a')) - * return false; - * } - * const HM::Entry &e = *p; // p acts like a pointer to Entry - * assert(p->key == 3); // Entry contains the key - * char val = p->value; // and value - * - * Also see the definition of AddPtr in HashTable above (with T = Entry). - * - * N.B. The caller must ensure that no mutating hash table operations - * occur between a pair of |lookupForAdd| and |add| calls. To avoid - * looking up the key a second time, the caller may use the more efficient - * relookupOrAdd method. This method reuses part of the hashing computation - * to more efficiently insert the key if it has not been added. For - * example, a mutation-handling version of the previous example: - * - * HM::AddPtr p = h.lookupForAdd(3); - * if (!p) { - * call_that_may_mutate_h(); - * if (!h.relookupOrAdd(p, 3, 'a')) - * return false; - * } - * const HM::Entry &e = *p; - * assert(p->key == 3); - * char val = p->value; - */ - typedef typename Impl::AddPtr AddPtr; - AddPtr lookupForAdd(const Lookup &l) const { - return impl.lookupForAdd(l); - } - - template - bool add(AddPtr &p, const KeyInput &k, const ValueInput &v) { - Entry *pentry; - if (!impl.add(p, &pentry)) - return false; - const_cast(pentry->key) = k; - pentry->value = v; - return true; - } - - bool add(AddPtr &p, const Key &k, MoveRef v) { - Entry *pentry; - if (!impl.add(p, &pentry)) - return false; - const_cast(pentry->key) = k; - pentry->value = v; - return true; - } - - bool add(AddPtr &p, const Key &k) { - Entry *pentry; - if (!impl.add(p, &pentry)) - return false; - const_cast(pentry->key) = k; - return true; - } - - template - bool relookupOrAdd(AddPtr &p, const KeyInput &k, const ValueInput &v) { - return impl.relookupOrAdd(p, k, Entry(k, v)); - } - - /* - * |all()| returns a Range containing |count()| elements. E.g.: - * - * typedef HashMap HM; - * HM h; - * for (HM::Range r = h.all(); !r.empty(); r.popFront()) - * char c = r.front().value; - * - * Also see the definition of Range in HashTable above (with T = Entry). - */ - typedef typename Impl::Range Range; - Range all() const { return impl.all(); } - uint32_t count() const { return impl.count(); } - size_t capacity() const { return impl.capacity(); } - size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const { - return impl.sizeOfExcludingThis(mallocSizeOf); - } - size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const { - /* - * Don't just call |impl.sizeOfExcludingThis()| because there's no - * guarantee that |impl| is the first field in HashMap. - */ - return mallocSizeOf(this) + impl.sizeOfExcludingThis(mallocSizeOf); - } - - /* - * Typedef for the enumeration class. An Enum may be used to examine and - * remove table entries: - * - * typedef HashMap HM; - * HM s; - * for (HM::Enum e(s); !e.empty(); e.popFront()) - * if (e.front().value == 'l') - * e.removeFront(); - * - * Table resize may occur in Enum's destructor. Also see the definition of - * Enum in HashTable above (with T = Entry). - */ - typedef typename Impl::Enum Enum; - - /* - * Remove all entries. This does not shrink the table. For that consider - * using the finish() method. - */ - void clear() { impl.clear(); } - - /* - * Remove all the entries and release all internal buffers. The map must - * be initialized again before any use. - */ - void finish() { impl.finish(); } - - /* Does the table contain any entries? */ - bool empty() const { return impl.empty(); } - - /* - * If |generation()| is the same before and after a HashMap operation, - * pointers into the table remain valid. - */ - unsigned generation() const { return impl.generation(); } - - /* Shorthand operations: */ - - bool has(const Lookup &l) const { - return impl.lookup(l) != NULL; - } - - /* Overwrite existing value with v. Return NULL on oom. */ - template - Entry *put(const KeyInput &k, const ValueInput &v) { - AddPtr p = lookupForAdd(k); - if (p) { - p->value = v; - return &*p; - } - return add(p, k, v) ? &*p : NULL; - } - - /* Like put, but assert that the given key is not already present. */ - bool putNew(const Key &k, const Value &v) { - AddPtr p = lookupForAdd(k); - JS_ASSERT(!p); - return add(p, k, v); - } - - /* Add (k,defaultValue) if k no found. Return false-y Ptr on oom. */ - Ptr lookupWithDefault(const Key &k, const Value &defaultValue) { - AddPtr p = lookupForAdd(k); - if (p) - return p; - (void)add(p, k, defaultValue); /* p is left false-y on oom. */ - return p; - } - - /* Remove if present. */ - void remove(const Lookup &l) { - if (Ptr p = lookup(l)) - remove(p); - } -}; - -/* - * JS-friendly, STL-like container providing a hash-based set of values. In - * particular, HashSet calls constructors and destructors of all objects added - * so non-PODs may be used safely. - * - * T requirements: - * - default constructible, copyable, destructible, assignable - * HashPolicy requirements: - * - see "Hash policy" above (default js::DefaultHasher) - * AllocPolicy: - * - see "Allocation policies" in jsalloc.h - * - * N.B: HashSet is not reentrant: T/HashPolicy/AllocPolicy members called by - * HashSet must not call back into the same HashSet object. - * N.B: Due to the lack of exception handling, the user must call |init()|. - */ -template , class AllocPolicy = TempAllocPolicy> -class HashSet -{ - typedef typename HashPolicy::Lookup Lookup; - - /* Implement HashSet in terms of HashTable. */ - struct SetOps : HashPolicy { - typedef T KeyType; - static const KeyType &getKey(const T &t) { return t; } - }; - typedef detail::HashTable Impl; - - friend class Impl::Enum; - - /* Not implicitly copyable (expensive). May add explicit |clone| later. */ - HashSet(const HashSet &); - HashSet &operator=(const HashSet &); - - Impl impl; - - public: - /* - * HashSet construction is fallible (due to OOM); thus the user must call - * init after constructing a HashSet and check the return value. - */ - HashSet(AllocPolicy a = AllocPolicy()) : impl(a) {} - bool init(uint32_t len = Impl::sDefaultInitSize) { return impl.init(len); } - bool initialized() const { return impl.initialized(); } - - /* - * Return whether the given lookup value is present in the map. E.g.: - * - * typedef HashSet HS; - * HS h; - * if (HS::Ptr p = h.lookup(3)) { - * assert(*p == 3); // p acts like a pointer to int - * } - * - * Also see the definition of Ptr in HashTable above. - */ - typedef typename Impl::Ptr Ptr; - Ptr lookup(const Lookup &l) const { return impl.lookup(l); } - - /* Assuming |p.found()|, remove |*p|. */ - void remove(Ptr p) { impl.remove(p); } - - /* - * Like |lookup(l)|, but on miss, |p = lookupForAdd(l)| allows efficient - * insertion of T value |t| (where |HashPolicy::match(t,l) == true|) using - * |add(p,t)|. After |add(p,t)|, |p| points to the new element. E.g.: - * - * typedef HashSet HS; - * HS h; - * HS::AddPtr p = h.lookupForAdd(3); - * if (!p) { - * if (!h.add(p, 3)) - * return false; - * } - * assert(*p == 3); // p acts like a pointer to int - * - * Also see the definition of AddPtr in HashTable above. - * - * N.B. The caller must ensure that no mutating hash table operations - * occur between a pair of |lookupForAdd| and |add| calls. To avoid - * looking up the key a second time, the caller may use the more efficient - * relookupOrAdd method. This method reuses part of the hashing computation - * to more efficiently insert the key if it has not been added. For - * example, a mutation-handling version of the previous example: - * - * HS::AddPtr p = h.lookupForAdd(3); - * if (!p) { - * call_that_may_mutate_h(); - * if (!h.relookupOrAdd(p, 3, 3)) - * return false; - * } - * assert(*p == 3); - * - * Note that relookupOrAdd(p,l,t) performs Lookup using l and adds the - * entry t, where the caller ensures match(l,t). - */ - typedef typename Impl::AddPtr AddPtr; - AddPtr lookupForAdd(const Lookup &l) const { - return impl.lookupForAdd(l); - } - - bool add(AddPtr &p, const T &t) { - return impl.add(p, t); - } - - bool relookupOrAdd(AddPtr &p, const Lookup &l, const T &t) { - return impl.relookupOrAdd(p, l, t); - } - - /* - * |all()| returns a Range containing |count()| elements: - * - * typedef HashSet HS; - * HS h; - * for (HS::Range r = h.all(); !r.empty(); r.popFront()) - * int i = r.front(); - * - * Also see the definition of Range in HashTable above. - */ - typedef typename Impl::Range Range; - Range all() const { return impl.all(); } - uint32_t count() const { return impl.count(); } - size_t capacity() const { return impl.capacity(); } - size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const { - return impl.sizeOfExcludingThis(mallocSizeOf); - } - size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const { - /* - * Don't just call |impl.sizeOfExcludingThis()| because there's no - * guarantee that |impl| is the first field in HashSet. - */ - return mallocSizeOf(this) + impl.sizeOfExcludingThis(mallocSizeOf); - } - - /* - * Typedef for the enumeration class. An Enum may be used to examine and - * remove table entries: - * - * typedef HashSet HS; - * HS s; - * for (HS::Enum e(s); !e.empty(); e.popFront()) - * if (e.front() == 42) - * e.removeFront(); - * - * Table resize may occur in Enum's destructor. Also see the definition of - * Enum in HashTable above. - */ - typedef typename Impl::Enum Enum; - - /* - * Remove all entries. This does not shrink the table. For that consider - * using the finish() method. - */ - void clear() { impl.clear(); } - - /* - * Remove all the entries and release all internal buffers. The set must - * be initialized again before any use. - */ - void finish() { impl.finish(); } - - /* Does the table contain any entries? */ - bool empty() const { return impl.empty(); } - - /* - * If |generation()| is the same before and after a HashSet operation, - * pointers into the table remain valid. - */ - unsigned generation() const { return impl.generation(); } - - /* Shorthand operations: */ - - bool has(const Lookup &l) const { - return impl.lookup(l) != NULL; - } - - /* Overwrite existing value with v. Return NULL on oom. */ - const T *put(const T &t) { - AddPtr p = lookupForAdd(t); - return p ? &*p : (add(p, t) ? &*p : NULL); - } - - /* Like put, but assert that the given key is not already present. */ - bool putNew(const T &t) { - AddPtr p = lookupForAdd(t); - JS_ASSERT(!p); - return add(p, t); - } - - bool putNew(const Lookup &l, const T &t) { - AddPtr p = lookupForAdd(l); - JS_ASSERT(!p); - return add(p, t); - } - - void remove(const Lookup &l) { - if (Ptr p = lookup(l)) - remove(p); - } -}; - -} /* namespace js */ - -#endif diff --git a/js/spidermonkey-win32/include/js/LegacyIntTypes.h b/js/spidermonkey-win32/include/js/LegacyIntTypes.h deleted file mode 100644 index 6f6a37bc03..0000000000 --- a/js/spidermonkey-win32/include/js/LegacyIntTypes.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * This section typedefs the old 'native' types to the new types. - * These redefinitions are provided solely to allow JSAPI users to more easily - * transition to types. They are not to be used in the JSAPI, and - * new JSAPI user code should not use them. This mapping file may eventually - * be removed from SpiderMonkey, so don't depend on it in the long run. - */ - -/* - * BEWARE: Comity with other implementers of these types is not guaranteed. - * Indeed, if you use this header and third-party code defining these - * types, *expect* to encounter either compile errors or link errors, - * depending how these types are used and on the order of inclusion. - * It is safest to use only the JSAPI -style types, - * customizing those types using MOZ_CUSTOM_STDINT_H if necessary. - */ -#ifndef PROTYPES_H -#define PROTYPES_H - -#include "mozilla/StandardInteger.h" - -#include "js-config.h" - -typedef uint8_t uint8; -typedef uint16_t uint16; -typedef uint32_t uint32; -typedef uint64_t uint64; - -/* - * On AIX 4.3, sys/inttypes.h (which is included by sys/types.h, a very - * common header file) defines the types int8, int16, int32, and int64. - * So we don't define these four types here to avoid conflicts in case - * the code also includes sys/types.h. - */ -#if defined(AIX) && defined(HAVE_SYS_INTTYPES_H) -#include -#else -typedef int8_t int8; -typedef int16_t int16; -typedef int32_t int32; -typedef int64_t int64; -#endif /* AIX && HAVE_SYS_INTTYPES_H */ - -typedef uint8_t JSUint8; -typedef uint16_t JSUint16; -typedef uint32_t JSUint32; -typedef uint64_t JSUint64; - -typedef int8_t JSInt8; -typedef int16_t JSInt16; -typedef int32_t JSInt32; -typedef int64_t JSInt64; - -#endif /* !defined(PROTYPES_H) */ diff --git a/js/spidermonkey-win32/include/js/MemoryMetrics.h b/js/spidermonkey-win32/include/js/MemoryMetrics.h deleted file mode 100644 index 513db5b5e2..0000000000 --- a/js/spidermonkey-win32/include/js/MemoryMetrics.h +++ /dev/null @@ -1,190 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sw=4 et tw=99 ft=cpp: - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is about:memory glue. - * - * The Initial Developer of the Original Code is - * Ms2ger . - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef js_MemoryMetrics_h -#define js_MemoryMetrics_h - -/* - * These declarations are not within jsapi.h because they are highly likely - * to change in the future. Depend on them at your own risk. - */ - -#include - -#include "jsalloc.h" -#include "jspubtd.h" - -#include "js/Utility.h" -#include "js/Vector.h" - -namespace JS { - -/* Data for tracking analysis/inference memory usage. */ -struct TypeInferenceSizes -{ - size_t scripts; - size_t objects; - size_t tables; - size_t temporary; -}; - -struct CompartmentStats -{ - CompartmentStats() { - memset(this, 0, sizeof(*this)); - } - - void *extra; - size_t gcHeapArenaHeaders; - size_t gcHeapArenaPadding; - size_t gcHeapArenaUnused; - - size_t gcHeapObjectsNonFunction; - size_t gcHeapObjectsFunction; - size_t gcHeapStrings; - size_t gcHeapShapesTree; - size_t gcHeapShapesDict; - size_t gcHeapShapesBase; - size_t gcHeapScripts; - size_t gcHeapTypeObjects; - size_t gcHeapXML; - - size_t objectSlots; - size_t objectElements; - size_t objectMisc; - size_t stringChars; - size_t shapesExtraTreeTables; - size_t shapesExtraDictTables; - size_t shapesExtraTreeShapeKids; - size_t shapesCompartmentTables; - size_t scriptData; - -#ifdef JS_METHODJIT - size_t mjitCode; - size_t mjitData; -#endif - TypeInferenceSizes typeInferenceSizes; -}; - -struct RuntimeStats -{ - RuntimeStats(JSMallocSizeOfFun mallocSizeOf) - : runtimeObject(0) - , runtimeAtomsTable(0) - , runtimeContexts(0) - , runtimeNormal(0) - , runtimeTemporary(0) - , runtimeRegexpCode(0) - , runtimeStackCommitted(0) - , runtimeGCMarker(0) - , gcHeapChunkTotal(0) - , gcHeapChunkCleanUnused(0) - , gcHeapChunkDirtyUnused(0) - , gcHeapChunkCleanDecommitted(0) - , gcHeapChunkDirtyDecommitted(0) - , gcHeapArenaUnused(0) - , gcHeapChunkAdmin(0) - , gcHeapUnusedPercentage(0) - , totalObjects(0) - , totalShapes(0) - , totalScripts(0) - , totalStrings(0) -#ifdef JS_METHODJIT - , totalMjit(0) -#endif - , totalTypeInference(0) - , totalAnalysisTemp(0) - , compartmentStatsVector() - , currCompartmentStats(NULL) - , mallocSizeOf(mallocSizeOf) - {} - - size_t runtimeObject; - size_t runtimeAtomsTable; - size_t runtimeContexts; - size_t runtimeNormal; - size_t runtimeTemporary; - size_t runtimeRegexpCode; - size_t runtimeStackCommitted; - size_t runtimeGCMarker; - size_t gcHeapChunkTotal; - size_t gcHeapChunkCleanUnused; - size_t gcHeapChunkDirtyUnused; - size_t gcHeapChunkCleanDecommitted; - size_t gcHeapChunkDirtyDecommitted; - size_t gcHeapArenaUnused; - size_t gcHeapChunkAdmin; - size_t gcHeapUnusedPercentage; - size_t totalObjects; - size_t totalShapes; - size_t totalScripts; - size_t totalStrings; -#ifdef JS_METHODJIT - size_t totalMjit; -#endif - size_t totalTypeInference; - size_t totalAnalysisTemp; - - js::Vector compartmentStatsVector; - CompartmentStats *currCompartmentStats; - - JSMallocSizeOfFun mallocSizeOf; - - virtual void initExtraCompartmentStats(JSCompartment *c, CompartmentStats *cstats) = 0; -}; - -#ifdef JS_THREADSAFE - -extern JS_PUBLIC_API(bool) -CollectRuntimeStats(JSRuntime *rt, RuntimeStats *rtStats); - -extern JS_PUBLIC_API(int64_t) -GetExplicitNonHeapForRuntime(JSRuntime *rt, JSMallocSizeOfFun mallocSizeOf); - -#endif /* JS_THREADSAFE */ - -extern JS_PUBLIC_API(size_t) -SystemCompartmentCount(const JSRuntime *rt); - -extern JS_PUBLIC_API(size_t) -UserCompartmentCount(const JSRuntime *rt); - -} // namespace JS - -#endif // js_MemoryMetrics_h diff --git a/js/spidermonkey-win32/include/js/TemplateLib.h b/js/spidermonkey-win32/include/js/TemplateLib.h deleted file mode 100644 index 10d609fd4b..0000000000 --- a/js/spidermonkey-win32/include/js/TemplateLib.h +++ /dev/null @@ -1,180 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sw=4 et tw=99 ft=cpp: - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla SpiderMonkey JavaScript code. - * - * The Initial Developer of the Original Code is - * the Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Luke Wagner - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef js_template_lib_h__ -#define js_template_lib_h__ - -#include "jstypes.h" - -/* - * Library of reusable template meta-functions (that is, functions on types and - * compile-time values). Meta-functions are placed inside the 'tl' namespace to - * avoid conflict with non-meta functions that logically have the same name - * (e.g., js::tl::Min vs. js::Min). - */ - -namespace js { -namespace tl { - -/* Compute min/max/clamp. */ -template struct Min { - static const size_t result = i < j ? i : j; -}; -template struct Max { - static const size_t result = i > j ? i : j; -}; -template struct Clamp { - static const size_t result = i < min ? min : (i > max ? max : i); -}; - -/* Compute x^y. */ -template struct Pow { - static const size_t result = x * Pow::result; -}; -template struct Pow { - static const size_t result = 1; -}; - -/* Compute floor(log2(i)). */ -template struct FloorLog2 { - static const size_t result = 1 + FloorLog2::result; -}; -template <> struct FloorLog2<0> { /* Error */ }; -template <> struct FloorLog2<1> { static const size_t result = 0; }; - -/* Compute ceiling(log2(i)). */ -template struct CeilingLog2 { - static const size_t result = FloorLog2<2 * i - 1>::result; -}; - -/* Round up to the nearest power of 2. */ -template struct RoundUpPow2 { - static const size_t result = size_t(1) << CeilingLog2::result; -}; -template <> struct RoundUpPow2<0> { - static const size_t result = 1; -}; - -/* Compute the number of bits in the given unsigned type. */ -template struct BitSize { - static const size_t result = sizeof(T) * JS_BITS_PER_BYTE; -}; - -/* Allow Assertions by only including the 'result' typedef if 'true'. */ -template struct StaticAssert {}; -template <> struct StaticAssert { typedef int result; }; - -/* Boolean test for whether two types are the same. */ -template struct IsSameType { - static const bool result = false; -}; -template struct IsSameType { - static const bool result = true; -}; - -/* - * Produce an N-bit mask, where N <= BitSize::result. Handle the - * language-undefined edge case when N = BitSize::result. - */ -template struct NBitMask { - typedef typename StaticAssert::result>::result _; - static const size_t result = (size_t(1) << N) - 1; -}; -template <> struct NBitMask::result> { - static const size_t result = size_t(-1); -}; - -/* - * For the unsigned integral type size_t, compute a mask M for N such that - * for all X, !(X & M) implies X * N will not overflow (w.r.t size_t) - */ -template struct MulOverflowMask { - static const size_t result = - ~NBitMask::result - CeilingLog2::result>::result; -}; -template <> struct MulOverflowMask<0> { /* Error */ }; -template <> struct MulOverflowMask<1> { static const size_t result = 0; }; - -/* - * Generate a mask for T such that if (X & sUnsafeRangeSizeMask), an X-sized - * array of T's is big enough to cause a ptrdiff_t overflow when subtracting - * a pointer to the end of the array from the beginning. - */ -template struct UnsafeRangeSizeMask { - /* - * The '2' factor means the top bit is clear, sizeof(T) converts from - * units of elements to bytes. - */ - static const size_t result = MulOverflowMask<2 * sizeof(T)>::result; -}; - -/* Return T stripped of any const-ness. */ -template struct StripConst { typedef T result; }; -template struct StripConst { typedef T result; }; - -/* - * Traits class for identifying POD types. Until C++0x, there is no automatic - * way to detect PODs, so for the moment it is done manually. - */ -template struct IsPodType { static const bool result = false; }; -template <> struct IsPodType { static const bool result = true; }; -template <> struct IsPodType { static const bool result = true; }; -template <> struct IsPodType { static const bool result = true; }; -template <> struct IsPodType { static const bool result = true; }; -template <> struct IsPodType { static const bool result = true; }; -template <> struct IsPodType { static const bool result = true; }; -template <> struct IsPodType { static const bool result = true; }; -template <> struct IsPodType { static const bool result = true; }; -template <> struct IsPodType { static const bool result = true; }; -template <> struct IsPodType { static const bool result = true; }; -template <> struct IsPodType { static const bool result = true; }; -template <> struct IsPodType { static const bool result = true; }; -template <> struct IsPodType { static const bool result = true; }; -template <> struct IsPodType { static const bool result = true; }; -template <> struct IsPodType { static const bool result = true; }; -template struct IsPodType { static const bool result = true; }; - -template struct If { static const T result = v1; }; -template struct If { static const T result = v2; }; - -} /* namespace tl */ -} /* namespace js */ - -#endif /* js_template_lib_h__ */ diff --git a/js/spidermonkey-win32/include/js/Utility.h b/js/spidermonkey-win32/include/js/Utility.h deleted file mode 100644 index f5294e3690..0000000000 --- a/js/spidermonkey-win32/include/js/Utility.h +++ /dev/null @@ -1,950 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sw=4 et tw=99 ft=cpp: - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla SpiderMonkey JavaScript code. - * - * The Initial Developer of the Original Code is - * the Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef js_utility_h__ -#define js_utility_h__ - -#include "mozilla/Assertions.h" - -#include -#include - -#ifdef JS_OOM_DO_BACKTRACES -#include -#include -#endif - -#include "jstypes.h" - -#ifdef __cplusplus - -/* The public JS engine namespace. */ -namespace JS {} - -/* The mozilla-shared reusable template/utility namespace. */ -namespace mozilla {} - -/* The private JS engine namespace. */ -namespace js { - -/* The private namespace is a superset of the public/shared namespaces. */ -using namespace JS; -using namespace mozilla; - -} /* namespace js */ -#endif /* __cplusplus */ - -JS_BEGIN_EXTERN_C - -/* - * Pattern used to overwrite freed memory. If you are accessing an object with - * this pattern, you probably have a dangling pointer. - */ -#define JS_FREE_PATTERN 0xDA - -#define JS_ASSERT(expr) MOZ_ASSERT(expr) -#define JS_ASSERT_IF(cond, expr) MOZ_ASSERT_IF(cond, expr) -#define JS_NOT_REACHED(reason) MOZ_NOT_REACHED(reason) -#define JS_ALWAYS_TRUE(expr) MOZ_ALWAYS_TRUE(expr) -#define JS_ALWAYS_FALSE(expr) MOZ_ALWAYS_FALSE(expr) - -#ifdef DEBUG -# ifdef JS_THREADSAFE -# define JS_THREADSAFE_ASSERT(expr) JS_ASSERT(expr) -# else -# define JS_THREADSAFE_ASSERT(expr) ((void) 0) -# endif -#else -# define JS_THREADSAFE_ASSERT(expr) ((void) 0) -#endif - -#define JS_STATIC_ASSERT(cond) MOZ_STATIC_ASSERT(cond, "JS_STATIC_ASSERT") -#define JS_STATIC_ASSERT_IF(cond, expr) MOZ_STATIC_ASSERT_IF(cond, expr, "JS_STATIC_ASSERT_IF") - -/* - * Abort the process in a non-graceful manner. This will cause a core file, - * call to the debugger or other moral equivalent as well as causing the - * entire process to stop. - */ -extern JS_PUBLIC_API(void) JS_Abort(void); - -/* - * Custom allocator support for SpiderMonkey - */ -#if defined JS_USE_CUSTOM_ALLOCATOR -# include "jscustomallocator.h" -#else -# ifdef DEBUG -/* - * In order to test OOM conditions, when the shell command-line option - * |-A NUM| is passed, we fail continuously after the NUM'th allocation. - */ -extern JS_PUBLIC_DATA(uint32_t) OOM_maxAllocations; /* set from shell/js.cpp */ -extern JS_PUBLIC_DATA(uint32_t) OOM_counter; /* data race, who cares. */ - -#ifdef JS_OOM_DO_BACKTRACES -#define JS_OOM_BACKTRACE_SIZE 32 -static JS_ALWAYS_INLINE void -PrintBacktrace() -{ - void* OOM_trace[JS_OOM_BACKTRACE_SIZE]; - char** OOM_traceSymbols = NULL; - int32_t OOM_traceSize = 0; - int32_t OOM_traceIdx = 0; - OOM_traceSize = backtrace(OOM_trace, JS_OOM_BACKTRACE_SIZE); - OOM_traceSymbols = backtrace_symbols(OOM_trace, OOM_traceSize); - - if (!OOM_traceSymbols) - return; - - for (OOM_traceIdx = 0; OOM_traceIdx < OOM_traceSize; ++OOM_traceIdx) { - fprintf(stderr, "#%d %s\n", OOM_traceIdx, OOM_traceSymbols[OOM_traceIdx]); - } - - free(OOM_traceSymbols); -} - -#define JS_OOM_EMIT_BACKTRACE() \ - do {\ - fprintf(stderr, "Forcing artificial memory allocation function failure:\n");\ - PrintBacktrace();\ - } while (0) -# else -# define JS_OOM_EMIT_BACKTRACE() do {} while(0) -#endif /* JS_OOM_DO_BACKTRACES */ - -# define JS_OOM_POSSIBLY_FAIL() \ - do \ - { \ - if (++OOM_counter > OOM_maxAllocations) { \ - JS_OOM_EMIT_BACKTRACE();\ - return NULL; \ - } \ - } while (0) - -# else -# define JS_OOM_POSSIBLY_FAIL() do {} while(0) -# endif - -/* - * SpiderMonkey code should not be calling these allocation functions directly. - * Instead, all calls should go through JSRuntime, JSContext or OffTheBooks. - * However, js_free() can be called directly. - */ -static JS_INLINE void* js_malloc(size_t bytes) -{ - JS_OOM_POSSIBLY_FAIL(); - return malloc(bytes); -} - -static JS_INLINE void* js_calloc(size_t bytes) -{ - JS_OOM_POSSIBLY_FAIL(); - return calloc(bytes, 1); -} - -static JS_INLINE void* js_realloc(void* p, size_t bytes) -{ - JS_OOM_POSSIBLY_FAIL(); - return realloc(p, bytes); -} - -static JS_INLINE void js_free(void* p) -{ - free(p); -} -#endif/* JS_USE_CUSTOM_ALLOCATOR */ - -/* - * Replace bit-scanning code sequences with CPU-specific instructions to - * speedup calculations of ceiling/floor log2. - * - * With GCC 3.4 or later we can use __builtin_clz for that, see bug 327129. - * - * SWS: Added MSVC intrinsic bitscan support. See bugs 349364 and 356856. - */ -#if defined(_WIN32) && (_MSC_VER >= 1300) && (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64)) - -unsigned char _BitScanForward(unsigned long * Index, unsigned long Mask); -unsigned char _BitScanReverse(unsigned long * Index, unsigned long Mask); -# pragma intrinsic(_BitScanForward,_BitScanReverse) - -__forceinline static int -__BitScanForward32(unsigned int val) -{ - unsigned long idx; - - _BitScanForward(&idx, (unsigned long)val); - return (int)idx; -} -__forceinline static int -__BitScanReverse32(unsigned int val) -{ - unsigned long idx; - - _BitScanReverse(&idx, (unsigned long)val); - return (int)(31-idx); -} -# define js_bitscan_ctz32(val) __BitScanForward32(val) -# define js_bitscan_clz32(val) __BitScanReverse32(val) -# define JS_HAS_BUILTIN_BITSCAN32 - -#if defined(_M_AMD64) || defined(_M_X64) -unsigned char _BitScanForward64(unsigned long * Index, unsigned __int64 Mask); -unsigned char _BitScanReverse64(unsigned long * Index, unsigned __int64 Mask); -# pragma intrinsic(_BitScanForward64,_BitScanReverse64) - -__forceinline static int -__BitScanForward64(unsigned __int64 val) -{ - unsigned long idx; - - _BitScanForward64(&idx, val); - return (int)idx; -} -__forceinline static int -__BitScanReverse64(unsigned __int64 val) -{ - unsigned long idx; - - _BitScanReverse64(&idx, val); - return (int)(63-idx); -} -# define js_bitscan_ctz64(val) __BitScanForward64(val) -# define js_bitscan_clz64(val) __BitScanReverse64(val) -# define JS_HAS_BUILTIN_BITSCAN64 -#endif -#elif (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) - -# define js_bitscan_ctz32(val) __builtin_ctz(val) -# define js_bitscan_clz32(val) __builtin_clz(val) -# define JS_HAS_BUILTIN_BITSCAN32 -# if (JS_BYTES_PER_WORD == 8) -# define js_bitscan_ctz64(val) __builtin_ctzll(val) -# define js_bitscan_clz64(val) __builtin_clzll(val) -# define JS_HAS_BUILTIN_BITSCAN64 -# endif - -#endif - -/* -** Macro version of JS_CeilingLog2: Compute the log of the least power of -** 2 greater than or equal to _n. The result is returned in _log2. -*/ -#ifdef JS_HAS_BUILTIN_BITSCAN32 -/* - * Use intrinsic function or count-leading-zeros to calculate ceil(log2(_n)). - * The macro checks for "n <= 1" and not "n != 0" as js_bitscan_clz32(0) is - * undefined. - */ -# define JS_CEILING_LOG2(_log2,_n) \ - JS_BEGIN_MACRO \ - unsigned int j_ = (unsigned int)(_n); \ - (_log2) = (j_ <= 1 ? 0 : 32 - js_bitscan_clz32(j_ - 1)); \ - JS_END_MACRO -#else -# define JS_CEILING_LOG2(_log2,_n) \ - JS_BEGIN_MACRO \ - uint32_t j_ = (uint32_t)(_n); \ - (_log2) = 0; \ - if ((j_) & ((j_)-1)) \ - (_log2) += 1; \ - if ((j_) >> 16) \ - (_log2) += 16, (j_) >>= 16; \ - if ((j_) >> 8) \ - (_log2) += 8, (j_) >>= 8; \ - if ((j_) >> 4) \ - (_log2) += 4, (j_) >>= 4; \ - if ((j_) >> 2) \ - (_log2) += 2, (j_) >>= 2; \ - if ((j_) >> 1) \ - (_log2) += 1; \ - JS_END_MACRO -#endif - -/* -** Macro version of JS_FloorLog2: Compute the log of the greatest power of -** 2 less than or equal to _n. The result is returned in _log2. -** -** This is equivalent to finding the highest set bit in the word. -*/ -#ifdef JS_HAS_BUILTIN_BITSCAN32 -/* - * Use js_bitscan_clz32 or count-leading-zeros to calculate floor(log2(_n)). - * Since js_bitscan_clz32(0) is undefined, the macro set the loweset bit to 1 - * to ensure 0 result when _n == 0. - */ -# define JS_FLOOR_LOG2(_log2,_n) \ - JS_BEGIN_MACRO \ - (_log2) = 31 - js_bitscan_clz32(((unsigned int)(_n)) | 1); \ - JS_END_MACRO -#else -# define JS_FLOOR_LOG2(_log2,_n) \ - JS_BEGIN_MACRO \ - uint32_t j_ = (uint32_t)(_n); \ - (_log2) = 0; \ - if ((j_) >> 16) \ - (_log2) += 16, (j_) >>= 16; \ - if ((j_) >> 8) \ - (_log2) += 8, (j_) >>= 8; \ - if ((j_) >> 4) \ - (_log2) += 4, (j_) >>= 4; \ - if ((j_) >> 2) \ - (_log2) += 2, (j_) >>= 2; \ - if ((j_) >> 1) \ - (_log2) += 1; \ - JS_END_MACRO -#endif - -/* - * Internal function. - * Compute the log of the least power of 2 greater than or equal to n. This is - * a version of JS_CeilingLog2 that operates on unsigned integers with - * CPU-dependant size. - */ -#define JS_CEILING_LOG2W(n) ((n) <= 1 ? 0 : 1 + JS_FLOOR_LOG2W((n) - 1)) - -/* - * Internal function. - * Compute the log of the greatest power of 2 less than or equal to n. - * This is a version of JS_FloorLog2 that operates on unsigned integers with - * CPU-dependant size and requires that n != 0. - */ -#define JS_FLOOR_LOG2W(n) (JS_ASSERT((n) != 0), js_FloorLog2wImpl(n)) - -#if JS_BYTES_PER_WORD == 4 -# ifdef JS_HAS_BUILTIN_BITSCAN32 -# define js_FloorLog2wImpl(n) \ - ((size_t)(JS_BITS_PER_WORD - 1 - js_bitscan_clz32(n))) -# else -JS_PUBLIC_API(size_t) js_FloorLog2wImpl(size_t n); -# endif -#elif JS_BYTES_PER_WORD == 8 -# ifdef JS_HAS_BUILTIN_BITSCAN64 -# define js_FloorLog2wImpl(n) \ - ((size_t)(JS_BITS_PER_WORD - 1 - js_bitscan_clz64(n))) -# else -JS_PUBLIC_API(size_t) js_FloorLog2wImpl(size_t n); -# endif -#else -# error "NOT SUPPORTED" -#endif - -JS_END_EXTERN_C - -#ifdef __cplusplus -#include - -/* - * User guide to memory management within SpiderMonkey: - * - * Quick tips: - * - * Allocation: - * - Prefer to allocate using JSContext: - * cx->{malloc_,realloc_,calloc_,new_,array_new} - * - * - If no JSContext is available, use a JSRuntime: - * rt->{malloc_,realloc_,calloc_,new_,array_new} - * - * - As a last resort, use unaccounted allocation ("OffTheBooks"): - * js::OffTheBooks::{malloc_,realloc_,calloc_,new_,array_new} - * - * Deallocation: - * - When the deallocation occurs on a slow path, use: - * Foreground::{free_,delete_,array_delete} - * - * - Otherwise deallocate on a background thread using a JSContext: - * cx->{free_,delete_,array_delete} - * - * - If no JSContext is available, use a JSRuntime: - * rt->{free_,delete_,array_delete} - * - * - As a last resort, use UnwantedForeground deallocation: - * js::UnwantedForeground::{free_,delete_,array_delete} - * - * General tips: - * - * - Mixing and matching these allocators is allowed (you may free memory - * allocated by any allocator, with any deallocator). - * - * - Never, ever use normal C/C++ memory management: - * malloc, free, new, new[], delete, operator new, etc. - * - * - Never, ever use low-level SpiderMonkey allocators: - * js_malloc(), js_free(), js_calloc(), js_realloc() - * Their use is reserved for the other memory managers. - * - * - Classes which have private constructors or destructors should have - * JS_DECLARE_ALLOCATION_FRIENDS_FOR_PRIVATE_CONSTRUCTOR added to their - * declaration. - * - * Details: - * - * Using vanilla new/new[] is unsafe in SpiderMonkey because they throw on - * failure instead of returning NULL, which is what SpiderMonkey expects. - * (Even overriding them is unsafe, as the system's C++ runtime library may - * throw, which we do not support. We also can't just use the 'nothrow' - * variant of new/new[], because we want to mediate *all* allocations - * within SpiderMonkey, to satisfy any embedders using - * JS_USE_CUSTOM_ALLOCATOR.) - * - * JSContexts and JSRuntimes keep track of memory allocated, and use this - * accounting to schedule GC. OffTheBooks does not. We'd like to remove - * OffTheBooks allocations as much as possible (bug 636558). - * - * On allocation failure, a JSContext correctly reports an error, which a - * JSRuntime and OffTheBooks does not. - * - * A JSContext deallocates in a background thread. A JSRuntime might - * deallocate in the background in the future, but does not now. Foreground - * deallocation is preferable on slow paths. UnwantedForeground deallocations - * occur where we have no JSContext or JSRuntime, and the deallocation is not - * on a slow path. We want to remove UnwantedForeground deallocations (bug - * 636561). - * - * JS_DECLARE_ALLOCATION_FRIENDS_FOR_PRIVATE_CONSTRUCTOR makes the allocation - * classes friends with your class, giving them access to private - * constructors and destructors. - * - * |make check| does a source level check on the number of uses OffTheBooks, - * UnwantedForeground, js_malloc, js_free etc, to prevent regressions. If you - * really must add one, update Makefile.in, and run |make check|. - * - * |make check| also statically prevents the use of vanilla new/new[]. - */ - -#define JS_NEW_BODY(allocator, t, parms) \ - void *memory = allocator(sizeof(t)); \ - return memory ? new(memory) t parms : NULL; - -/* - * Given a class which should provide new_() methods, add - * JS_DECLARE_NEW_METHODS (see JSContext for a usage example). This - * adds new_()s with up to 12 parameters. Add more versions of new_ below if - * you need more than 12 parameters. - * - * Note: Do not add a ; at the end of a use of JS_DECLARE_NEW_METHODS, - * or the build will break. - */ -#define JS_DECLARE_NEW_METHODS(ALLOCATOR, QUALIFIERS)\ - template \ - QUALIFIERS T *new_() {\ - JS_NEW_BODY(ALLOCATOR, T, ())\ - }\ -\ - template \ - QUALIFIERS T *new_(P1 p1) {\ - JS_NEW_BODY(ALLOCATOR, T, (p1))\ - }\ -\ - template \ - QUALIFIERS T *new_(P1 p1, P2 p2) {\ - JS_NEW_BODY(ALLOCATOR, T, (p1, p2))\ - }\ -\ - template \ - QUALIFIERS T *new_(P1 p1, P2 p2, P3 p3) {\ - JS_NEW_BODY(ALLOCATOR, T, (p1, p2, p3))\ - }\ -\ - template \ - QUALIFIERS T *new_(P1 p1, P2 p2, P3 p3, P4 p4) {\ - JS_NEW_BODY(ALLOCATOR, T, (p1, p2, p3, p4))\ - }\ -\ - template \ - QUALIFIERS T *new_(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) {\ - JS_NEW_BODY(ALLOCATOR, T, (p1, p2, p3, p4, p5))\ - }\ -\ - template \ - QUALIFIERS T *new_(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) {\ - JS_NEW_BODY(ALLOCATOR, T, (p1, p2, p3, p4, p5, p6))\ - }\ -\ - template \ - QUALIFIERS T *new_(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) {\ - JS_NEW_BODY(ALLOCATOR, T, (p1, p2, p3, p4, p5, p6, p7))\ - }\ -\ - template \ - QUALIFIERS T *new_(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8) {\ - JS_NEW_BODY(ALLOCATOR, T, (p1, p2, p3, p4, p5, p6, p7, p8))\ - }\ -\ - template \ - QUALIFIERS T *new_(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9) {\ - JS_NEW_BODY(ALLOCATOR, T, (p1, p2, p3, p4, p5, p6, p7, p8, p9))\ - }\ -\ - template \ - QUALIFIERS T *new_(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10) {\ - JS_NEW_BODY(ALLOCATOR, T, (p1, p2, p3, p4, p5, p6, p7, p8, p9, p10))\ - }\ -\ - template \ - QUALIFIERS T *new_(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10, P11 p11) {\ - JS_NEW_BODY(ALLOCATOR, T, (p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11))\ - }\ -\ - template \ - QUALIFIERS T *new_(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10, P11 p11, P12 p12) {\ - JS_NEW_BODY(ALLOCATOR, T, (p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12))\ - }\ - static const int JSMinAlignment = 8;\ - template \ - QUALIFIERS T *array_new(size_t n) {\ - /* The length is stored just before the vector memory. */\ - uint64_t numBytes64 = uint64_t(JSMinAlignment) + uint64_t(sizeof(T)) * uint64_t(n);\ - size_t numBytes = size_t(numBytes64);\ - if (numBytes64 != numBytes) {\ - JS_ASSERT(0); /* we want to know if this happens in debug builds */\ - return NULL;\ - }\ - void *memory = ALLOCATOR(numBytes);\ - if (!memory)\ - return NULL;\ - *(size_t *)memory = n;\ - memory = (void*)(uintptr_t(memory) + JSMinAlignment);\ - return new(memory) T[n];\ - }\ - - -#define JS_DECLARE_DELETE_METHODS(DEALLOCATOR, QUALIFIERS)\ - template \ - QUALIFIERS void delete_(T *p) {\ - if (p) {\ - p->~T();\ - DEALLOCATOR(p);\ - }\ - }\ -\ - template \ - QUALIFIERS void array_delete(T *p) {\ - if (p) {\ - void* p0 = (void *)(uintptr_t(p) - js::OffTheBooks::JSMinAlignment);\ - size_t n = *(size_t *)p0;\ - for (size_t i = 0; i < n; i++)\ - (p + i)->~T();\ - DEALLOCATOR(p0);\ - }\ - } - - -/* - * In general, all allocations should go through a JSContext or JSRuntime, so - * that the garbage collector knows how much memory has been allocated. In - * cases where it is difficult to use a JSContext or JSRuntime, OffTheBooks can - * be used, though this is undesirable. - */ -namespace js { - -class OffTheBooks { -public: - JS_DECLARE_NEW_METHODS(::js_malloc, JS_ALWAYS_INLINE static) - - static JS_INLINE void* malloc_(size_t bytes) { - return ::js_malloc(bytes); - } - - static JS_INLINE void* calloc_(size_t bytes) { - return ::js_calloc(bytes); - } - - static JS_INLINE void* realloc_(void* p, size_t bytes) { - return ::js_realloc(p, bytes); - } -}; - -/* - * We generally prefer deallocating using JSContext because it can happen in - * the background. On slow paths, we may prefer foreground allocation. - */ -class Foreground { -public: - /* See parentheses comment above. */ - static JS_ALWAYS_INLINE void free_(void* p) { - ::js_free(p); - } - - JS_DECLARE_DELETE_METHODS(::js_free, JS_ALWAYS_INLINE static) -}; - -class UnwantedForeground : public Foreground { -}; - -} /* namespace js */ - -/* - * Note lack of ; in JSRuntime below. This is intentional so "calling" this - * looks "normal". - */ -#define JS_DECLARE_ALLOCATION_FRIENDS_FOR_PRIVATE_CONSTRUCTOR \ - friend class js::OffTheBooks;\ - friend class js::Foreground;\ - friend class js::UnwantedForeground;\ - friend struct ::JSContext;\ - friend struct ::JSRuntime - -/* - * The following classes are designed to cause assertions to detect - * inadvertent use of guard objects as temporaries. In other words, - * when we have a guard object whose only purpose is its constructor and - * destructor (and is never otherwise referenced), the intended use - * might be: - * JSAutoTempValueRooter tvr(cx, 1, &val); - * but is is easy to accidentally write: - * JSAutoTempValueRooter(cx, 1, &val); - * which compiles just fine, but runs the destructor well before the - * intended time. - * - * They work by adding (#ifdef DEBUG) an additional parameter to the - * guard object's constructor, with a default value, so that users of - * the guard object's API do not need to do anything. The default value - * of this parameter is a temporary object. C++ (ISO/IEC 14882:1998), - * section 12.2 [class.temporary], clauses 4 and 5 seem to assume a - * guarantee that temporaries are destroyed in the reverse of their - * construction order, but I actually can't find a statement that that - * is true in the general case (beyond the two specific cases mentioned - * there). However, it seems to be true. - * - * These classes are intended to be used only via the macros immediately - * below them: - * JS_DECL_USE_GUARD_OBJECT_NOTIFIER declares (ifdef DEBUG) a member - * variable, and should be put where a declaration of a private - * member variable would be placed. - * JS_GUARD_OBJECT_NOTIFIER_PARAM should be placed at the end of the - * parameters to each constructor of the guard object; it declares - * (ifdef DEBUG) an additional parameter. - * JS_GUARD_OBJECT_NOTIFIER_INIT is a statement that belongs in each - * constructor. It uses the parameter declared by - * JS_GUARD_OBJECT_NOTIFIER_PARAM. - */ -#ifdef DEBUG -class JS_FRIEND_API(JSGuardObjectNotifier) -{ -private: - bool* mStatementDone; -public: - JSGuardObjectNotifier() : mStatementDone(NULL) {} - - ~JSGuardObjectNotifier() { - *mStatementDone = true; - } - - void setStatementDone(bool *aStatementDone) { - mStatementDone = aStatementDone; - } -}; - -class JS_FRIEND_API(JSGuardObjectNotificationReceiver) -{ -private: - bool mStatementDone; -public: - JSGuardObjectNotificationReceiver() : mStatementDone(false) {} - - ~JSGuardObjectNotificationReceiver() { - /* - * Assert that the guard object was not used as a temporary. - * (Note that this assert might also fire if Init is not called - * because the guard object's implementation is not using the - * above macros correctly.) - */ - JS_ASSERT(mStatementDone); - } - - void Init(const JSGuardObjectNotifier &aNotifier) { - /* - * aNotifier is passed as a const reference so that we can pass a - * temporary, but we really intend it as non-const - */ - const_cast(aNotifier). - setStatementDone(&mStatementDone); - } -}; - -#define JS_DECL_USE_GUARD_OBJECT_NOTIFIER \ - JSGuardObjectNotificationReceiver _mCheckNotUsedAsTemporary; -#define JS_GUARD_OBJECT_NOTIFIER_PARAM \ - , const JSGuardObjectNotifier& _notifier = JSGuardObjectNotifier() -#define JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT \ - , const JSGuardObjectNotifier& _notifier -#define JS_GUARD_OBJECT_NOTIFIER_PARAM0 \ - const JSGuardObjectNotifier& _notifier = JSGuardObjectNotifier() -#define JS_GUARD_OBJECT_NOTIFIER_INIT \ - JS_BEGIN_MACRO _mCheckNotUsedAsTemporary.Init(_notifier); JS_END_MACRO - -#else /* defined(DEBUG) */ - -#define JS_DECL_USE_GUARD_OBJECT_NOTIFIER -#define JS_GUARD_OBJECT_NOTIFIER_PARAM -#define JS_GUARD_OBJECT_NOTIFIER_PARAM_NO_INIT -#define JS_GUARD_OBJECT_NOTIFIER_PARAM0 -#define JS_GUARD_OBJECT_NOTIFIER_INIT JS_BEGIN_MACRO JS_END_MACRO - -#endif /* !defined(DEBUG) */ - -namespace js { - -/* - * "Move" References - * - * Some types can be copied much more efficiently if we know the original's - * value need not be preserved --- that is, if we are doing a "move", not a - * "copy". For example, if we have: - * - * Vector u; - * Vector v(u); - * - * the constructor for v must apply a copy constructor to each element of u --- - * taking time linear in the length of u. However, if we know we will not need u - * any more once v has been initialized, then we could initialize v very - * efficiently simply by stealing u's dynamically allocated buffer and giving it - * to v --- a constant-time operation, regardless of the size of u. - * - * Moves often appear in container implementations. For example, when we append - * to a vector, we may need to resize its buffer. This entails moving each of - * its extant elements from the old, smaller buffer to the new, larger buffer. - * But once the elements have been migrated, we're just going to throw away the - * old buffer; we don't care if they still have their values. So if the vector's - * element type can implement "move" more efficiently than "copy", the vector - * resizing should by all means use a "move" operation. Hash tables also need to - * be resized. - * - * The details of the optimization, and whether it's worth applying, vary from - * one type to the next. And while some constructor calls are moves, many really - * are copies, and can't be optimized this way. So we need: - * - * 1) a way for a particular invocation of a copy constructor to say that it's - * really a move, and that the value of the original isn't important - * afterwards (althought it must still be safe to destroy); and - * - * 2) a way for a type (like Vector) to announce that it can be moved more - * efficiently than it can be copied, and provide an implementation of that - * move operation. - * - * The Move(T &) function takes a reference to a T, and returns an MoveRef - * referring to the same value; that's 1). An MoveRef is simply a reference - * to a T, annotated to say that a copy constructor applied to it may move that - * T, instead of copying it. Finally, a constructor that accepts an MoveRef - * should perform a more efficient move, instead of a copy, providing 2). - * - * So, where we might define a copy constructor for a class C like this: - * - * C(const C &rhs) { ... copy rhs to this ... } - * - * we would declare a move constructor like this: - * - * C(MoveRef rhs) { ... move rhs to this ... } - * - * And where we might perform a copy like this: - * - * C c2(c1); - * - * we would perform a move like this: - * - * C c2(Move(c1)) - * - * Note that MoveRef implicitly converts to T &, so you can pass an - * MoveRef to an ordinary copy constructor for a type that doesn't support a - * special move constructor, and you'll just get a copy. This means that - * templates can use Move whenever they know they won't use the original value - * any more, even if they're not sure whether the type at hand has a specialized - * move constructor. If it doesn't, the MoveRef will just convert to a T &, - * and the ordinary copy constructor will apply. - * - * A class with a move constructor can also provide a move assignment operator, - * which runs this's destructor, and then applies the move constructor to - * *this's memory. A typical definition: - * - * C &operator=(MoveRef rhs) { - * this->~C(); - * new(this) C(rhs); - * return *this; - * } - * - * With that in place, one can write move assignments like this: - * - * c2 = Move(c1); - * - * This destroys c1, moves c1's value to c2, and leaves c1 in an undefined but - * destructible state. - * - * This header file defines MoveRef and Move in the js namespace. It's up to - * individual containers to annotate moves as such, by calling Move; and it's up - * to individual types to define move constructors. - * - * One hint: if you're writing a move constructor where the type has members - * that should be moved themselves, it's much nicer to write this: - * - * C(MoveRef c) : x(c->x), y(c->y) { } - * - * than the equivalent: - * - * C(MoveRef c) { new(&x) X(c->x); new(&y) Y(c->y); } - * - * especially since GNU C++ fails to notice that this does indeed initialize x - * and y, which may matter if they're const. - */ -template -class MoveRef { - public: - typedef T Referent; - explicit MoveRef(T &t) : pointer(&t) { } - T &operator*() const { return *pointer; } - T *operator->() const { return pointer; } -#ifdef __GXX_EXPERIMENTAL_CXX0X__ - /* - * If MoveRef is used in a rvalue position (which is expected), we can - * end up in a situation where, without this ifdef, we would try to pass - * a T& to a move constructor, which fails. It is not clear if the compiler - * should instead use the copy constructor, but for now this lets us build - * with clang. See bug 689066 and llvm.org/pr11003 for the details. - * Note: We can probably remove MoveRef completely once we are comfortable - * using c++11. - */ - operator T&& () const { return static_cast(*pointer); } -#else - operator T& () const { return *pointer; } -#endif - private: - T *pointer; -}; - -template -MoveRef Move(T &t) { return MoveRef(t); } - -template -MoveRef Move(const T &t) { return MoveRef(const_cast(t)); } - -/* Useful for implementing containers that assert non-reentrancy */ -class ReentrancyGuard -{ - /* ReentrancyGuard is not copyable. */ - ReentrancyGuard(const ReentrancyGuard &); - void operator=(const ReentrancyGuard &); - -#ifdef DEBUG - bool &entered; -#endif - public: - template -#ifdef DEBUG - ReentrancyGuard(T &obj) - : entered(obj.entered) -#else - ReentrancyGuard(T &/*obj*/) -#endif - { -#ifdef DEBUG - JS_ASSERT(!entered); - entered = true; -#endif - } - ~ReentrancyGuard() - { -#ifdef DEBUG - entered = false; -#endif - } -}; - -/* - * Round x up to the nearest power of 2. This function assumes that the most - * significant bit of x is not set, which would lead to overflow. - */ -JS_ALWAYS_INLINE size_t -RoundUpPow2(size_t x) -{ - return size_t(1) << JS_CEILING_LOG2W(x); -} - -} /* namespace js */ - -#endif /* defined(__cplusplus) */ - -/* - * This is SpiderMonkey's equivalent to |nsMallocSizeOfFun|. - */ -typedef size_t(*JSMallocSizeOfFun)(const void *p); - -/* sixgill annotation defines */ -#ifndef HAVE_STATIC_ANNOTATIONS -# define HAVE_STATIC_ANNOTATIONS -# ifdef XGILL_PLUGIN -# define STATIC_PRECONDITION(COND) __attribute__((precondition(#COND))) -# define STATIC_PRECONDITION_ASSUME(COND) __attribute__((precondition_assume(#COND))) -# define STATIC_POSTCONDITION(COND) __attribute__((postcondition(#COND))) -# define STATIC_POSTCONDITION_ASSUME(COND) __attribute__((postcondition_assume(#COND))) -# define STATIC_INVARIANT(COND) __attribute__((invariant(#COND))) -# define STATIC_INVARIANT_ASSUME(COND) __attribute__((invariant_assume(#COND))) -# define STATIC_PASTE2(X,Y) X ## Y -# define STATIC_PASTE1(X,Y) STATIC_PASTE2(X,Y) -# define STATIC_ASSERT(COND) \ - JS_BEGIN_MACRO \ - __attribute__((assert_static(#COND), unused)) \ - int STATIC_PASTE1(assert_static_, __COUNTER__); \ - JS_END_MACRO -# define STATIC_ASSUME(COND) \ - JS_BEGIN_MACRO \ - __attribute__((assume_static(#COND), unused)) \ - int STATIC_PASTE1(assume_static_, __COUNTER__); \ - JS_END_MACRO -# define STATIC_ASSERT_RUNTIME(COND) \ - JS_BEGIN_MACRO \ - __attribute__((assert_static_runtime(#COND), unused)) \ - int STATIC_PASTE1(assert_static_runtime_, __COUNTER__); \ - JS_END_MACRO -# else /* XGILL_PLUGIN */ -# define STATIC_PRECONDITION(COND) /* nothing */ -# define STATIC_PRECONDITION_ASSUME(COND) /* nothing */ -# define STATIC_POSTCONDITION(COND) /* nothing */ -# define STATIC_POSTCONDITION_ASSUME(COND) /* nothing */ -# define STATIC_INVARIANT(COND) /* nothing */ -# define STATIC_INVARIANT_ASSUME(COND) /* nothing */ -# define STATIC_ASSERT(COND) JS_BEGIN_MACRO /* nothing */ JS_END_MACRO -# define STATIC_ASSUME(COND) JS_BEGIN_MACRO /* nothing */ JS_END_MACRO -# define STATIC_ASSERT_RUNTIME(COND) JS_BEGIN_MACRO /* nothing */ JS_END_MACRO -# endif /* XGILL_PLUGIN */ -# define STATIC_SKIP_INFERENCE STATIC_INVARIANT(skip_inference()) -#endif /* HAVE_STATIC_ANNOTATIONS */ - -#endif /* js_utility_h__ */ diff --git a/js/spidermonkey-win32/include/js/Vector.h b/js/spidermonkey-win32/include/js/Vector.h deleted file mode 100644 index 42b0a7a299..0000000000 --- a/js/spidermonkey-win32/include/js/Vector.h +++ /dev/null @@ -1,1030 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sw=4 et tw=99 ft=cpp: - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released - * June 12, 2009. - * - * The Initial Developer of the Original Code is - * the Mozilla Corporation. - * - * Contributor(s): - * Luke Wagner - * Nicholas Nethercote - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef jsvector_h_ -#define jsvector_h_ - -#include "mozilla/Attributes.h" - -#include "TemplateLib.h" -#include "Utility.h" - -/* Silence dire "bugs in previous versions of MSVC have been fixed" warnings */ -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable:4345) -#endif - -namespace js { - -class TempAllocPolicy; - -template -class Vector; - -/* - * This template class provides a default implementation for vector operations - * when the element type is not known to be a POD, as judged by IsPodType. - */ -template -struct VectorImpl -{ - /* Destroys constructed objects in the range [begin, end). */ - static inline void destroy(T *begin, T *end) { - for (T *p = begin; p != end; ++p) - p->~T(); - } - - /* Constructs objects in the uninitialized range [begin, end). */ - static inline void initialize(T *begin, T *end) { - for (T *p = begin; p != end; ++p) - new(p) T(); - } - - /* - * Copy-constructs objects in the uninitialized range - * [dst, dst+(srcend-srcbeg)) from the range [srcbeg, srcend). - */ - template - static inline void copyConstruct(T *dst, const U *srcbeg, const U *srcend) { - for (const U *p = srcbeg; p != srcend; ++p, ++dst) - new(dst) T(*p); - } - - /* - * Move-constructs objects in the uninitialized range - * [dst, dst+(srcend-srcbeg)) from the range [srcbeg, srcend). - */ - template - static inline void moveConstruct(T *dst, const U *srcbeg, const U *srcend) { - for (const U *p = srcbeg; p != srcend; ++p, ++dst) - new(dst) T(Move(*p)); - } - - /* - * Copy-constructs objects in the uninitialized range [dst, dst+n) from the - * same object u. - */ - template - static inline void copyConstructN(T *dst, size_t n, const U &u) { - for (T *end = dst + n; dst != end; ++dst) - new(dst) T(u); - } - - /* - * Grows the given buffer to have capacity newcap, preserving the objects - * constructed in the range [begin, end) and updating v. Assumes that (1) - * newcap has not overflowed, and (2) multiplying newcap by sizeof(T) will - * not overflow. - */ - static inline bool growTo(Vector &v, size_t newcap) { - JS_ASSERT(!v.usingInlineStorage()); - T *newbuf = reinterpret_cast(v.malloc_(newcap * sizeof(T))); - if (!newbuf) - return false; - for (T *dst = newbuf, *src = v.beginNoCheck(); src != v.endNoCheck(); ++dst, ++src) - new(dst) T(Move(*src)); - VectorImpl::destroy(v.beginNoCheck(), v.endNoCheck()); - v.free_(v.mBegin); - v.mBegin = newbuf; - /* v.mLength is unchanged. */ - v.mCapacity = newcap; - return true; - } -}; - -/* - * This partial template specialization provides a default implementation for - * vector operations when the element type is known to be a POD, as judged by - * IsPodType. - */ -template -struct VectorImpl -{ - static inline void destroy(T *, T *) {} - - static inline void initialize(T *begin, T *end) { - /* - * You would think that memset would be a big win (or even break even) - * when we know T is a POD. But currently it's not. This is probably - * because |append| tends to be given small ranges and memset requires - * a function call that doesn't get inlined. - * - * memset(begin, 0, sizeof(T) * (end-begin)); - */ - for (T *p = begin; p != end; ++p) - new(p) T(); - } - - template - static inline void copyConstruct(T *dst, const U *srcbeg, const U *srcend) { - /* - * See above memset comment. Also, notice that copyConstruct is - * currently templated (T != U), so memcpy won't work without - * requiring T == U. - * - * memcpy(dst, srcbeg, sizeof(T) * (srcend - srcbeg)); - */ - for (const U *p = srcbeg; p != srcend; ++p, ++dst) - *dst = *p; - } - - template - static inline void moveConstruct(T *dst, const U *srcbeg, const U *srcend) { - copyConstruct(dst, srcbeg, srcend); - } - - static inline void copyConstructN(T *dst, size_t n, const T &t) { - for (T *p = dst, *end = dst + n; p != end; ++p) - *p = t; - } - - static inline bool growTo(Vector &v, size_t newcap) { - JS_ASSERT(!v.usingInlineStorage()); - size_t bytes = sizeof(T) * newcap; - size_t oldBytes = sizeof(T) * v.mCapacity; - T *newbuf = reinterpret_cast(v.realloc_(v.mBegin, oldBytes, bytes)); - if (!newbuf) - return false; - v.mBegin = newbuf; - /* v.mLength is unchanged. */ - v.mCapacity = newcap; - return true; - } -}; - -/* - * JS-friendly, STL-like container providing a short-lived, dynamic buffer. - * Vector calls the constructors/destructors of all elements stored in - * its internal buffer, so non-PODs may be safely used. Additionally, - * Vector will store the first N elements in-place before resorting to - * dynamic allocation. - * - * T requirements: - * - default and copy constructible, assignable, destructible - * - operations do not throw - * N requirements: - * - any value, however, N is clamped to min/max values - * AllocPolicy: - * - see "Allocation policies" in jsalloc.h (default js::TempAllocPolicy) - * - * N.B: Vector is not reentrant: T member functions called during Vector member - * functions must not call back into the same object. - */ -template -class Vector : private AllocPolicy -{ - /* utilities */ - - static const bool sElemIsPod = tl::IsPodType::result; - typedef VectorImpl Impl; - friend struct VectorImpl; - - bool calculateNewCapacity(size_t curLength, size_t lengthInc, size_t &newCap); - bool growStorageBy(size_t lengthInc); - bool growHeapStorageBy(size_t lengthInc); - bool convertToHeapStorage(size_t lengthInc); - - template inline bool growByImpl(size_t inc); - - /* magic constants */ - - static const int sMaxInlineBytes = 1024; - - /* compute constants */ - - /* - * Consider element size to be 1 for buffer sizing if there are - * 0 inline elements. This allows us to compile when the definition - * of the element type is not visible here. - * - * Explicit specialization is only allowed at namespace scope, so - * in order to keep everything here, we use a dummy template - * parameter with partial specialization. - */ - template - struct ElemSize { - static const size_t result = sizeof(T); - }; - template - struct ElemSize<0, Dummy> { - static const size_t result = 1; - }; - - static const size_t sInlineCapacity = - tl::Min::result>::result; - - /* Calculate inline buffer size; avoid 0-sized array. */ - static const size_t sInlineBytes = - tl::Max<1, sInlineCapacity * ElemSize::result>::result; - - /* member data */ - - /* - * Pointer to the buffer, be it inline or heap-allocated. Only [mBegin, - * mBegin + mLength) hold valid constructed T objects. The range [mBegin + - * mLength, mBegin + mCapacity) holds uninitialized memory. The range - * [mBegin + mLength, mBegin + mReserved) also holds uninitialized memory - * previously allocated by a call to reserve(). - */ - T *mBegin; - size_t mLength; /* Number of elements in the Vector. */ - size_t mCapacity; /* Max number of elements storable in the Vector without resizing. */ -#ifdef DEBUG - size_t mReserved; /* Max elements of reserved or used space in this vector. */ -#endif - - AlignedStorage storage; - -#ifdef DEBUG - friend class ReentrancyGuard; - bool entered; -#endif - - Vector(const Vector &) MOZ_DELETE; - Vector &operator=(const Vector &) MOZ_DELETE; - - /* private accessors */ - - bool usingInlineStorage() const { - return mBegin == (T *)storage.addr(); - } - - T *beginNoCheck() const { - return mBegin; - } - - T *endNoCheck() { - return mBegin + mLength; - } - - const T *endNoCheck() const { - return mBegin + mLength; - } - -#ifdef DEBUG - size_t reserved() const { - JS_ASSERT(mReserved <= mCapacity); - JS_ASSERT(mLength <= mReserved); - return mReserved; - } -#endif - - /* Append operations guaranteed to succeed due to pre-reserved space. */ - template void internalAppend(U t); - void internalAppendN(const T &t, size_t n); - template void internalAppend(const U *begin, size_t length); - template void internalAppend(const Vector &other); - - public: - static const size_t sMaxInlineStorage = N; - - typedef T ElementType; - - Vector(AllocPolicy = AllocPolicy()); - Vector(MoveRef); /* Move constructor. */ - Vector &operator=(MoveRef); /* Move assignment. */ - ~Vector(); - - /* accessors */ - - const AllocPolicy &allocPolicy() const { - return *this; - } - - AllocPolicy &allocPolicy() { - return *this; - } - - enum { InlineLength = N }; - - size_t length() const { - return mLength; - } - - bool empty() const { - return mLength == 0; - } - - size_t capacity() const { - return mCapacity; - } - - T *begin() { - JS_ASSERT(!entered); - return mBegin; - } - - const T *begin() const { - JS_ASSERT(!entered); - return mBegin; - } - - T *end() { - JS_ASSERT(!entered); - return mBegin + mLength; - } - - const T *end() const { - JS_ASSERT(!entered); - return mBegin + mLength; - } - - T &operator[](size_t i) { - JS_ASSERT(!entered && i < mLength); - return begin()[i]; - } - - const T &operator[](size_t i) const { - JS_ASSERT(!entered && i < mLength); - return begin()[i]; - } - - T &back() { - JS_ASSERT(!entered && !empty()); - return *(end() - 1); - } - - const T &back() const { - JS_ASSERT(!entered && !empty()); - return *(end() - 1); - } - - class Range { - friend class Vector; - T *cur, *end; - Range(T *cur, T *end) : cur(cur), end(end) {} - public: - Range() {} - bool empty() const { return cur == end; } - size_t remain() const { return end - cur; } - T &front() const { return *cur; } - void popFront() { JS_ASSERT(!empty()); ++cur; } - T popCopyFront() { JS_ASSERT(!empty()); return *cur++; } - }; - - Range all() { - return Range(begin(), end()); - } - - /* mutators */ - - /* If reserve(length() + N) succeeds, the N next appends are guaranteed to succeed. */ - bool reserve(size_t capacity); - - /* - * Destroy elements in the range [end() - incr, end()). Does not deallocate - * or unreserve storage for those elements. - */ - void shrinkBy(size_t incr); - - /* Grow the vector by incr elements. */ - bool growBy(size_t incr); - - /* Call shrinkBy or growBy based on whether newSize > length(). */ - bool resize(size_t newLength); - - /* Leave new elements as uninitialized memory. */ - bool growByUninitialized(size_t incr); - bool resizeUninitialized(size_t newLength); - - /* Shorthand for shrinkBy(length()). */ - void clear(); - - /* Clears and releases any heap-allocated storage. */ - void clearAndFree(); - - /* - * Potentially fallible append operations. - * - * The function templates that take an unspecified type U require a - * const T & or a MoveRef. The MoveRef variants move their - * operands into the vector, instead of copying them. If they fail, the - * operand is left unmoved. - */ - template bool append(U t); - bool appendN(const T &t, size_t n); - template bool append(const U *begin, const U *end); - template bool append(const U *begin, size_t length); - template bool append(const Vector &other); - - /* - * Guaranteed-infallible append operations for use upon vectors whose - * memory has been pre-reserved. - */ - void infallibleAppend(const T &t) { - internalAppend(t); - } - void infallibleAppendN(const T &t, size_t n) { - internalAppendN(t, n); - } - template void infallibleAppend(const U *begin, const U *end) { - internalAppend(begin, PointerRangeSize(begin, end)); - } - template void infallibleAppend(const U *begin, size_t length) { - internalAppend(begin, length); - } - template void infallibleAppend(const Vector &other) { - internalAppend(other); - } - - void popBack(); - - T popCopy(); - - /* - * Transfers ownership of the internal buffer used by Vector to the caller. - * After this call, the Vector is empty. Since the returned buffer may need - * to be allocated (if the elements are currently stored in-place), the - * call can fail, returning NULL. - * - * N.B. Although a T*, only the range [0, length()) is constructed. - */ - T *extractRawBuffer(); - - /* - * Transfer ownership of an array of objects into the Vector. - * N.B. This call assumes that there are no uninitialized elements in the - * passed array. - */ - void replaceRawBuffer(T *p, size_t length); - - /* - * Places |val| at position |p|, shifting existing elements - * from |p| onward one position higher. - */ - bool insert(T *p, const T &val); - - /* - * Removes the element |t|, which must fall in the bounds [begin, end), - * shifting existing elements from |t + 1| onward one position lower. - */ - void erase(T *t); - - /* - * Measure the size of the Vector's heap-allocated storage. - */ - size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const; - - /* - * Like sizeOfExcludingThis, but also measures the size of the Vector - * object (which must be heap-allocated) itself. - */ - size_t sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const; -}; - -/* This does the re-entrancy check plus several other sanity checks. */ -#define REENTRANCY_GUARD_ET_AL \ - ReentrancyGuard g(*this); \ - JS_ASSERT_IF(usingInlineStorage(), mCapacity == sInlineCapacity); \ - JS_ASSERT(reserved() <= mCapacity); \ - JS_ASSERT(mLength <= reserved()); \ - JS_ASSERT(mLength <= mCapacity) - -/* Vector Implementation */ - -template -JS_ALWAYS_INLINE -Vector::Vector(AllocPolicy ap) - : AllocPolicy(ap), mBegin((T *)storage.addr()), mLength(0), - mCapacity(sInlineCapacity) -#ifdef DEBUG - , mReserved(0), entered(false) -#endif -{} - -/* Move constructor. */ -template -JS_ALWAYS_INLINE -Vector::Vector(MoveRef rhs) - : AllocPolicy(rhs) -{ - mLength = rhs->mLength; - mCapacity = rhs->mCapacity; -#ifdef DEBUG - mReserved = rhs->mReserved; -#endif - - if (rhs->usingInlineStorage()) { - /* We can't move the buffer over in this case, so copy elements. */ - mBegin = (T *)storage.addr(); - Impl::moveConstruct(mBegin, rhs->beginNoCheck(), rhs->endNoCheck()); - /* - * Leave rhs's mLength, mBegin, mCapacity, and mReserved as they are. - * The elements in its in-line storage still need to be destroyed. - */ - } else { - /* - * Take src's buffer, and turn src into an empty vector using - * in-line storage. - */ - mBegin = rhs->mBegin; - rhs->mBegin = (T *) rhs->storage.addr(); - rhs->mCapacity = sInlineCapacity; - rhs->mLength = 0; -#ifdef DEBUG - rhs->mReserved = 0; -#endif - } -} - -/* Move assignment. */ -template -JS_ALWAYS_INLINE -Vector & -Vector::operator=(MoveRef rhs) -{ - this->~Vector(); - new(this) Vector(rhs); - return *this; -} - -template -JS_ALWAYS_INLINE -Vector::~Vector() -{ - REENTRANCY_GUARD_ET_AL; - Impl::destroy(beginNoCheck(), endNoCheck()); - if (!usingInlineStorage()) - this->free_(beginNoCheck()); -} - -/* - * Calculate a new capacity that is at least lengthInc greater than - * curLength and check for overflow. - */ -template -STATIC_POSTCONDITION(!return || newCap >= curLength + lengthInc) -inline bool -Vector::calculateNewCapacity(size_t curLength, size_t lengthInc, - size_t &newCap) -{ - size_t newMinCap = curLength + lengthInc; - - /* - * Check for overflow in the above addition, below CEILING_LOG2, and later - * multiplication by sizeof(T). - */ - if (newMinCap < curLength || - newMinCap & tl::MulOverflowMask<2 * sizeof(T)>::result) { - this->reportAllocOverflow(); - return false; - } - - /* Round up to next power of 2. */ - newCap = RoundUpPow2(newMinCap); - - /* - * Do not allow a buffer large enough that the expression ((char *)end() - - * (char *)begin()) overflows ptrdiff_t. See Bug 510319. - */ - if (newCap & tl::UnsafeRangeSizeMask::result) { - this->reportAllocOverflow(); - return false; - } - return true; -} - -/* - * This function will grow the current heap capacity to have capacity - * (mLength + lengthInc) and fail on OOM or integer overflow. - */ -template -JS_ALWAYS_INLINE bool -Vector::growHeapStorageBy(size_t lengthInc) -{ - JS_ASSERT(!usingInlineStorage()); - size_t newCap; - return calculateNewCapacity(mLength, lengthInc, newCap) && - Impl::growTo(*this, newCap); -} - -/* - * This function will create a new heap buffer with capacity (mLength + - * lengthInc()), move all elements in the inline buffer to this new buffer, - * and fail on OOM or integer overflow. - */ -template -inline bool -Vector::convertToHeapStorage(size_t lengthInc) -{ - JS_ASSERT(usingInlineStorage()); - size_t newCap; - if (!calculateNewCapacity(mLength, lengthInc, newCap)) - return false; - - /* Allocate buffer. */ - T *newBuf = reinterpret_cast(this->malloc_(newCap * sizeof(T))); - if (!newBuf) - return false; - - /* Copy inline elements into heap buffer. */ - Impl::moveConstruct(newBuf, beginNoCheck(), endNoCheck()); - Impl::destroy(beginNoCheck(), endNoCheck()); - - /* Switch in heap buffer. */ - mBegin = newBuf; - /* mLength is unchanged. */ - mCapacity = newCap; - return true; -} - -template -JS_NEVER_INLINE bool -Vector::growStorageBy(size_t incr) -{ - JS_ASSERT(mLength + incr > mCapacity); - return usingInlineStorage() - ? convertToHeapStorage(incr) - : growHeapStorageBy(incr); -} - -template -inline bool -Vector::reserve(size_t request) -{ - REENTRANCY_GUARD_ET_AL; - if (request > mCapacity && !growStorageBy(request - mLength)) - return false; - -#ifdef DEBUG - if (request > mReserved) - mReserved = request; - JS_ASSERT(mLength <= mReserved); - JS_ASSERT(mReserved <= mCapacity); -#endif - return true; -} - -template -inline void -Vector::shrinkBy(size_t incr) -{ - REENTRANCY_GUARD_ET_AL; - JS_ASSERT(incr <= mLength); - Impl::destroy(endNoCheck() - incr, endNoCheck()); - mLength -= incr; -} - -template -template -JS_ALWAYS_INLINE bool -Vector::growByImpl(size_t incr) -{ - REENTRANCY_GUARD_ET_AL; - if (incr > mCapacity - mLength && !growStorageBy(incr)) - return false; - - JS_ASSERT(mLength + incr <= mCapacity); - T *newend = endNoCheck() + incr; - if (InitNewElems) - Impl::initialize(endNoCheck(), newend); - mLength += incr; -#ifdef DEBUG - if (mLength > mReserved) - mReserved = mLength; -#endif - return true; -} - -template -JS_ALWAYS_INLINE bool -Vector::growBy(size_t incr) -{ - return growByImpl(incr); -} - -template -JS_ALWAYS_INLINE bool -Vector::growByUninitialized(size_t incr) -{ - return growByImpl(incr); -} - -template -STATIC_POSTCONDITION(!return || ubound(this->begin()) >= newLength) -inline bool -Vector::resize(size_t newLength) -{ - size_t curLength = mLength; - if (newLength > curLength) - return growBy(newLength - curLength); - shrinkBy(curLength - newLength); - return true; -} - -template -JS_ALWAYS_INLINE bool -Vector::resizeUninitialized(size_t newLength) -{ - size_t curLength = mLength; - if (newLength > curLength) - return growByUninitialized(newLength - curLength); - shrinkBy(curLength - newLength); - return true; -} - -template -inline void -Vector::clear() -{ - REENTRANCY_GUARD_ET_AL; - Impl::destroy(beginNoCheck(), endNoCheck()); - mLength = 0; -} - -template -inline void -Vector::clearAndFree() -{ - clear(); - - if (usingInlineStorage()) - return; - - this->free_(beginNoCheck()); - mBegin = (T *)storage.addr(); - mCapacity = sInlineCapacity; -#ifdef DEBUG - mReserved = 0; -#endif -} - -template -template -JS_ALWAYS_INLINE bool -Vector::append(U t) -{ - REENTRANCY_GUARD_ET_AL; - if (mLength == mCapacity && !growStorageBy(1)) - return false; - -#ifdef DEBUG - if (mLength + 1 > mReserved) - mReserved = mLength + 1; -#endif - internalAppend(t); - return true; -} - -template -template -JS_ALWAYS_INLINE void -Vector::internalAppend(U t) -{ - JS_ASSERT(mLength + 1 <= mReserved); - JS_ASSERT(mReserved <= mCapacity); - new(endNoCheck()) T(t); - ++mLength; -} - -template -JS_ALWAYS_INLINE bool -Vector::appendN(const T &t, size_t needed) -{ - REENTRANCY_GUARD_ET_AL; - if (mLength + needed > mCapacity && !growStorageBy(needed)) - return false; - -#ifdef DEBUG - if (mLength + needed > mReserved) - mReserved = mLength + needed; -#endif - internalAppendN(t, needed); - return true; -} - -template -JS_ALWAYS_INLINE void -Vector::internalAppendN(const T &t, size_t needed) -{ - JS_ASSERT(mLength + needed <= mReserved); - JS_ASSERT(mReserved <= mCapacity); - Impl::copyConstructN(endNoCheck(), needed, t); - mLength += needed; -} - -template -inline bool -Vector::insert(T *p, const T &val) -{ - JS_ASSERT(begin() <= p && p <= end()); - size_t pos = p - begin(); - JS_ASSERT(pos <= mLength); - size_t oldLength = mLength; - if (pos == oldLength) - return append(val); - { - T oldBack = back(); - if (!append(oldBack)) /* Dup the last element. */ - return false; - } - for (size_t i = oldLength; i > pos; --i) - (*this)[i] = (*this)[i - 1]; - (*this)[pos] = val; - return true; -} - -template -inline void -Vector::erase(T *it) -{ - JS_ASSERT(begin() <= it && it < end()); - while (it + 1 != end()) { - *it = *(it + 1); - ++it; - } - popBack(); -} - -template -template -JS_ALWAYS_INLINE bool -Vector::append(const U *insBegin, const U *insEnd) -{ - REENTRANCY_GUARD_ET_AL; - size_t needed = PointerRangeSize(insBegin, insEnd); - if (mLength + needed > mCapacity && !growStorageBy(needed)) - return false; - -#ifdef DEBUG - if (mLength + needed > mReserved) - mReserved = mLength + needed; -#endif - internalAppend(insBegin, needed); - return true; -} - -template -template -JS_ALWAYS_INLINE void -Vector::internalAppend(const U *insBegin, size_t length) -{ - JS_ASSERT(mLength + length <= mReserved); - JS_ASSERT(mReserved <= mCapacity); - Impl::copyConstruct(endNoCheck(), insBegin, insBegin + length); - mLength += length; -} - -template -template -inline bool -Vector::append(const Vector &other) -{ - return append(other.begin(), other.end()); -} - -template -template -inline void -Vector::internalAppend(const Vector &other) -{ - internalAppend(other.begin(), other.length()); -} - -template -template -JS_ALWAYS_INLINE bool -Vector::append(const U *insBegin, size_t length) -{ - return this->append(insBegin, insBegin + length); -} - -template -JS_ALWAYS_INLINE void -Vector::popBack() -{ - REENTRANCY_GUARD_ET_AL; - JS_ASSERT(!empty()); - --mLength; - endNoCheck()->~T(); -} - -template -JS_ALWAYS_INLINE T -Vector::popCopy() -{ - T ret = back(); - popBack(); - return ret; -} - -template -inline T * -Vector::extractRawBuffer() -{ - T *ret; - if (usingInlineStorage()) { - ret = reinterpret_cast(this->malloc_(mLength * sizeof(T))); - if (!ret) - return NULL; - Impl::copyConstruct(ret, beginNoCheck(), endNoCheck()); - Impl::destroy(beginNoCheck(), endNoCheck()); - /* mBegin, mCapacity are unchanged. */ - mLength = 0; - } else { - ret = mBegin; - mBegin = (T *)storage.addr(); - mLength = 0; - mCapacity = sInlineCapacity; -#ifdef DEBUG - mReserved = 0; -#endif - } - return ret; -} - -template -inline void -Vector::replaceRawBuffer(T *p, size_t length) -{ - REENTRANCY_GUARD_ET_AL; - - /* Destroy what we have. */ - Impl::destroy(beginNoCheck(), endNoCheck()); - if (!usingInlineStorage()) - this->free_(beginNoCheck()); - - /* Take in the new buffer. */ - if (length <= sInlineCapacity) { - /* - * We convert to inline storage if possible, even though p might - * otherwise be acceptable. Maybe this behaviour should be - * specifiable with an argument to this function. - */ - mBegin = (T *)storage.addr(); - mLength = length; - mCapacity = sInlineCapacity; - Impl::moveConstruct(mBegin, p, p + length); - Impl::destroy(p, p + length); - this->free_(p); - } else { - mBegin = p; - mLength = length; - mCapacity = length; - } -#ifdef DEBUG - mReserved = length; -#endif -} - -template -inline size_t -Vector::sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const -{ - return usingInlineStorage() ? 0 : mallocSizeOf(beginNoCheck()); -} - -template -inline size_t -Vector::sizeOfIncludingThis(JSMallocSizeOfFun mallocSizeOf) const -{ - return mallocSizeOf(this) + sizeOfExcludingThis(mallocSizeOf); -} - -} /* namespace js */ - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -#endif /* jsvector_h_ */ diff --git a/js/spidermonkey-win32/include/jsalloc.h b/js/spidermonkey-win32/include/jsalloc.h deleted file mode 100644 index aefc7aac45..0000000000 --- a/js/spidermonkey-win32/include/jsalloc.h +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sw=4 et tw=99 ft=cpp: - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released - * July 16, 2009. - * - * The Initial Developer of the Original Code is - * the Mozilla Corporation. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef jsalloc_h_ -#define jsalloc_h_ - -#include "jspubtd.h" -#include "jsutil.h" - -namespace js { - -/* - * Allocation policies. These model the concept: - * - public copy constructor, assignment, destructor - * - void *malloc_(size_t) - * Responsible for OOM reporting on NULL return value. - * - void *realloc_(size_t) - * Responsible for OOM reporting on NULL return value. - * The *used* bytes of the previous buffer is passed in - * (rather than the old allocation size), in addition to - * the *new* allocation size requested. - * - void free_(void *) - * - reportAllocOverflow() - * Called on overflow before the container returns NULL. - */ - -/* Policy for using system memory functions and doing no error reporting. */ -class SystemAllocPolicy -{ - public: - void *malloc_(size_t bytes) { return js_malloc(bytes); } - void *realloc_(void *p, size_t oldBytes, size_t bytes) { return js_realloc(p, bytes); } - void free_(void *p) { js_free(p); } - void reportAllocOverflow() const {} -}; - -/* - * Allocation policy that calls the system memory functions and reports errors - * to the context. Since the JSContext given on construction is stored for - * the lifetime of the container, this policy may only be used for containers - * whose lifetime is a shorter than the given JSContext. - * - * FIXME bug 647103 - rewrite this in terms of temporary allocation functions, - * not the system ones. - */ -class TempAllocPolicy -{ - JSContext *const cx; - - /* - * Non-inline helper to call JSRuntime::onOutOfMemory with minimal - * code bloat. - */ - JS_FRIEND_API(void *) onOutOfMemory(void *p, size_t nbytes); - - public: - TempAllocPolicy(JSContext *cx) : cx(cx) {} - - JSContext *context() const { - return cx; - } - - void *malloc_(size_t bytes) { - void *p = js_malloc(bytes); - if (JS_UNLIKELY(!p)) - p = onOutOfMemory(NULL, bytes); - return p; - } - - void *realloc_(void *p, size_t oldBytes, size_t bytes) { - void *p2 = js_realloc(p, bytes); - if (JS_UNLIKELY(!p2)) - p2 = onOutOfMemory(p2, bytes); - return p2; - } - - void free_(void *p) { - js_free(p); - } - - JS_FRIEND_API(void) reportAllocOverflow() const; -}; - -} /* namespace js */ - -#endif /* jsalloc_h_ */ diff --git a/js/spidermonkey-win32/include/jsapi.h.REMOVED.git-id b/js/spidermonkey-win32/include/jsapi.h.REMOVED.git-id index 6d72aa0371..fcc5e6a393 100644 --- a/js/spidermonkey-win32/include/jsapi.h.REMOVED.git-id +++ b/js/spidermonkey-win32/include/jsapi.h.REMOVED.git-id @@ -1 +1 @@ -f1ac8e227661a1589523844164213ad53e62260f \ No newline at end of file +7a4bee3a76685b0cfa5b2c0a1e36332f7ed22e49 \ No newline at end of file diff --git a/js/spidermonkey-win32/include/jsatom.h b/js/spidermonkey-win32/include/jsatom.h deleted file mode 100644 index 4564fbb641..0000000000 --- a/js/spidermonkey-win32/include/jsatom.h +++ /dev/null @@ -1,610 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef jsatom_h___ -#define jsatom_h___ - -#include -#include "jsversion.h" -#include "jsalloc.h" -#include "jsapi.h" -#include "jsprvtd.h" -#include "jshash.h" -#include "jspubtd.h" -#include "jslock.h" - -#include "gc/Barrier.h" -#include "js/HashTable.h" - -struct JSIdArray { - int length; - js::HeapId vector[1]; /* actually, length jsid words */ -}; - -/* Engine-internal extensions of jsid */ - -static JS_ALWAYS_INLINE jsid -JSID_FROM_BITS(size_t bits) -{ - jsid id; - JSID_BITS(id) = bits; - return id; -} - -static JS_ALWAYS_INLINE jsid -ATOM_TO_JSID(JSAtom *atom) -{ - JS_ASSERT(((size_t)atom & 0x7) == 0); - return JSID_FROM_BITS((size_t)atom); -} - -/* All strings stored in jsids are atomized. */ -static JS_ALWAYS_INLINE JSBool -JSID_IS_ATOM(jsid id) -{ - return JSID_IS_STRING(id); -} - -static JS_ALWAYS_INLINE JSBool -JSID_IS_ATOM(jsid id, JSAtom *atom) -{ - return JSID_BITS(id) == JSID_BITS(ATOM_TO_JSID(atom)); -} - -static JS_ALWAYS_INLINE JSAtom * -JSID_TO_ATOM(jsid id) -{ - return (JSAtom *)JSID_TO_STRING(id); -} - -extern jsid -js_CheckForStringIndex(jsid id); - -JS_STATIC_ASSERT(sizeof(JSHashNumber) == 4); -JS_STATIC_ASSERT(sizeof(jsid) == JS_BYTES_PER_WORD); - -namespace js { - -static JS_ALWAYS_INLINE JSHashNumber -HashId(jsid id) -{ - JS_ASSERT(js_CheckForStringIndex(id) == id); - JSHashNumber n = -#if JS_BYTES_PER_WORD == 4 - JSHashNumber(JSID_BITS(id)); -#elif JS_BYTES_PER_WORD == 8 - JSHashNumber(JSID_BITS(id)) ^ JSHashNumber(JSID_BITS(id) >> 32); -#else -# error "Unsupported configuration" -#endif - return n * JS_GOLDEN_RATIO; -} - -static JS_ALWAYS_INLINE Value -IdToValue(jsid id) -{ - if (JSID_IS_STRING(id)) - return StringValue(JSID_TO_STRING(id)); - if (JS_LIKELY(JSID_IS_INT(id))) - return Int32Value(JSID_TO_INT(id)); - if (JS_LIKELY(JSID_IS_OBJECT(id))) - return ObjectValue(*JSID_TO_OBJECT(id)); - JS_ASSERT(JSID_IS_DEFAULT_XML_NAMESPACE(id) || JSID_IS_VOID(id)); - return UndefinedValue(); -} - -static JS_ALWAYS_INLINE jsval -IdToJsval(jsid id) -{ - return IdToValue(id); -} - -template<> -struct DefaultHasher -{ - typedef jsid Lookup; - static HashNumber hash(const Lookup &l) { - JS_ASSERT(l == js_CheckForStringIndex(l)); - return HashNumber(JSID_BITS(l)); - } - static bool match(const jsid &id, const Lookup &l) { - JS_ASSERT(l == js_CheckForStringIndex(l)); - return id == l; - } -}; - -} - -#if JS_BYTES_PER_WORD == 4 -# define ATOM_HASH(atom) ((JSHashNumber)(atom) >> 2) -#elif JS_BYTES_PER_WORD == 8 -# define ATOM_HASH(atom) (((JSHashNumber)(uintptr_t)(atom) >> 3) ^ \ - (JSHashNumber)((uintptr_t)(atom) >> 32)) -#else -# error "Unsupported configuration" -#endif - -/* - * Return a printable, lossless char[] representation of a string-type atom. - * The lifetime of the result matches the lifetime of bytes. - */ -extern const char * -js_AtomToPrintableString(JSContext *cx, JSAtom *atom, JSAutoByteString *bytes); - -namespace js { - -/* Compute a hash function from chars/length. */ -inline uint32_t -HashChars(const jschar *chars, size_t length) -{ - uint32_t h = 0; - for (; length; chars++, length--) - h = JS_ROTATE_LEFT32(h, 4) ^ *chars; - return h; -} - -class AtomStateEntry -{ - uintptr_t bits; - - static const uintptr_t NO_TAG_MASK = uintptr_t(-1) - 1; - - public: - AtomStateEntry() : bits(0) {} - AtomStateEntry(const AtomStateEntry &other) : bits(other.bits) {} - AtomStateEntry(JSAtom *ptr, bool tagged) - : bits(uintptr_t(ptr) | uintptr_t(tagged)) - { - JS_ASSERT((uintptr_t(ptr) & 0x1) == 0); - } - - bool isTagged() const { - return bits & 0x1; - } - - /* - * Non-branching code sequence. Note that the const_cast is safe because - * the hash function doesn't consider the tag to be a portion of the key. - */ - void setTagged(bool enabled) const { - const_cast(this)->bits |= uintptr_t(enabled); - } - - JSAtom *asPtr() const; -}; - -struct AtomHasher -{ - struct Lookup - { - const jschar *chars; - size_t length; - const JSAtom *atom; /* Optional. */ - - Lookup(const jschar *chars, size_t length) : chars(chars), length(length), atom(NULL) {} - inline Lookup(const JSAtom *atom); - }; - - static HashNumber hash(const Lookup &l) { return HashChars(l.chars, l.length); } - static inline bool match(const AtomStateEntry &entry, const Lookup &lookup); -}; - -typedef HashSet AtomSet; - -/* - * On encodings: - * - * - Some string functions have an optional FlationCoding argument that allow - * the caller to force CESU-8 encoding handling. - * - Functions that don't take a FlationCoding base their NormalEncoding - * behavior on the js_CStringsAreUTF8 value. NormalEncoding is either raw - * (simple zero-extension) or UTF-8 depending on js_CStringsAreUTF8. - * - Functions that explicitly state their encoding do not use the - * js_CStringsAreUTF8 value. - * - * CESU-8 (Compatibility Encoding Scheme for UTF-16: 8-bit) is a variant of - * UTF-8 that allows us to store any wide character string as a narrow - * character string. For strings containing mostly ascii, it saves space. - * http://www.unicode.org/reports/tr26/ - */ - -enum FlationCoding -{ - NormalEncoding, - CESU8Encoding -}; - -class PropertyName; - -} /* namespace js */ - -struct JSAtomState -{ - js::AtomSet atoms; - - /* - * From this point until the end of struct definition the struct must - * contain only js::PropertyName fields. We use this to access the storage - * occupied by the common atoms in js_FinishCommonAtoms. - * - * js_common_atom_names defined in jsatom.cpp contains C strings for atoms - * in the order of atom fields here. Therefore you must update that array - * if you change member order here. - */ - - /* The rt->emptyString atom, see jsstr.c's js_InitRuntimeStringState. */ - js::PropertyName *emptyAtom; - - /* - * Literal value and type names. - * NB: booleanAtoms must come right before typeAtoms! - */ - js::PropertyName *booleanAtoms[2]; - js::PropertyName *typeAtoms[JSTYPE_LIMIT]; - js::PropertyName *nullAtom; - - /* Standard class constructor or prototype names. */ - js::PropertyName *classAtoms[JSProto_LIMIT]; - - /* Various built-in or commonly-used atoms, pinned on first context. */ - js::PropertyName *anonymousAtom; - js::PropertyName *applyAtom; - js::PropertyName *argumentsAtom; - js::PropertyName *arityAtom; - js::PropertyName *BYTES_PER_ELEMENTAtom; - js::PropertyName *callAtom; - js::PropertyName *calleeAtom; - js::PropertyName *callerAtom; - js::PropertyName *classPrototypeAtom; - js::PropertyName *constructorAtom; - js::PropertyName *eachAtom; - js::PropertyName *evalAtom; - js::PropertyName *fileNameAtom; - js::PropertyName *getAtom; - js::PropertyName *globalAtom; - js::PropertyName *ignoreCaseAtom; - js::PropertyName *indexAtom; - js::PropertyName *inputAtom; - js::PropertyName *toISOStringAtom; - js::PropertyName *iteratorAtom; - js::PropertyName *joinAtom; - js::PropertyName *lastIndexAtom; - js::PropertyName *lengthAtom; - js::PropertyName *lineNumberAtom; - js::PropertyName *messageAtom; - js::PropertyName *multilineAtom; - js::PropertyName *nameAtom; - js::PropertyName *nextAtom; - js::PropertyName *noSuchMethodAtom; - js::PropertyName *objectNullAtom; - js::PropertyName *objectUndefinedAtom; - js::PropertyName *ofAtom; - js::PropertyName *protoAtom; - js::PropertyName *setAtom; - js::PropertyName *sourceAtom; - js::PropertyName *stackAtom; - js::PropertyName *stickyAtom; - js::PropertyName *toGMTStringAtom; - js::PropertyName *toLocaleStringAtom; - js::PropertyName *toSourceAtom; - js::PropertyName *toStringAtom; - js::PropertyName *toUTCStringAtom; - js::PropertyName *valueOfAtom; - js::PropertyName *toJSONAtom; - js::PropertyName *void0Atom; - js::PropertyName *enumerableAtom; - js::PropertyName *configurableAtom; - js::PropertyName *writableAtom; - js::PropertyName *valueAtom; - js::PropertyName *testAtom; - js::PropertyName *useStrictAtom; - js::PropertyName *locAtom; - js::PropertyName *lineAtom; - js::PropertyName *InfinityAtom; - js::PropertyName *NaNAtom; - js::PropertyName *builderAtom; - -#if JS_HAS_XML_SUPPORT - js::PropertyName *etagoAtom; - js::PropertyName *namespaceAtom; - js::PropertyName *ptagcAtom; - js::PropertyName *qualifierAtom; - js::PropertyName *spaceAtom; - js::PropertyName *stagoAtom; - js::PropertyName *starAtom; - js::PropertyName *starQualifierAtom; - js::PropertyName *tagcAtom; - js::PropertyName *xmlAtom; - - /* Represents an invalid URI, for internal use only. */ - js::PropertyName *functionNamespaceURIAtom; -#endif - - js::PropertyName *ProxyAtom; - - js::PropertyName *getOwnPropertyDescriptorAtom; - js::PropertyName *getPropertyDescriptorAtom; - js::PropertyName *definePropertyAtom; - js::PropertyName *deleteAtom; - js::PropertyName *getOwnPropertyNamesAtom; - js::PropertyName *enumerateAtom; - js::PropertyName *fixAtom; - - js::PropertyName *hasAtom; - js::PropertyName *hasOwnAtom; - js::PropertyName *keysAtom; - js::PropertyName *iterateAtom; - - js::PropertyName *WeakMapAtom; - - js::PropertyName *byteLengthAtom; - - js::PropertyName *returnAtom; - js::PropertyName *throwAtom; - - /* Less frequently used atoms, pinned lazily by JS_ResolveStandardClass. */ - struct { - js::PropertyName *XMLListAtom; - js::PropertyName *decodeURIAtom; - js::PropertyName *decodeURIComponentAtom; - js::PropertyName *defineGetterAtom; - js::PropertyName *defineSetterAtom; - js::PropertyName *encodeURIAtom; - js::PropertyName *encodeURIComponentAtom; - js::PropertyName *escapeAtom; - js::PropertyName *hasOwnPropertyAtom; - js::PropertyName *isFiniteAtom; - js::PropertyName *isNaNAtom; - js::PropertyName *isPrototypeOfAtom; - js::PropertyName *isXMLNameAtom; - js::PropertyName *lookupGetterAtom; - js::PropertyName *lookupSetterAtom; - js::PropertyName *parseFloatAtom; - js::PropertyName *parseIntAtom; - js::PropertyName *propertyIsEnumerableAtom; - js::PropertyName *unescapeAtom; - js::PropertyName *unevalAtom; - js::PropertyName *unwatchAtom; - js::PropertyName *watchAtom; - } lazy; - - static const size_t commonAtomsOffset; - static const size_t lazyAtomsOffset; - - void clearLazyAtoms() { - memset(&lazy, 0, sizeof(lazy)); - } - - void junkAtoms() { -#ifdef DEBUG - memset(commonAtomsStart(), JS_FREE_PATTERN, sizeof(*this) - commonAtomsOffset); -#endif - } - - JSAtom **commonAtomsStart() { - return reinterpret_cast(&emptyAtom); - } - - void checkStaticInvariants(); -}; - -extern bool -AtomIsInterned(JSContext *cx, JSAtom *atom); - -#define ATOM(name) cx->runtime->atomState.name##Atom - -#define COMMON_ATOM_INDEX(name) \ - ((offsetof(JSAtomState, name##Atom) - JSAtomState::commonAtomsOffset) \ - / sizeof(JSAtom*)) -#define COMMON_TYPE_ATOM_INDEX(type) \ - ((offsetof(JSAtomState, typeAtoms[type]) - JSAtomState::commonAtomsOffset)\ - / sizeof(JSAtom*)) - -#define ATOM_OFFSET(name) offsetof(JSAtomState, name##Atom) -#define OFFSET_TO_ATOM(rt,off) (*(JSAtom **)((char*)&(rt)->atomState + (off))) -#define CLASS_ATOM_OFFSET(name) offsetof(JSAtomState, classAtoms[JSProto_##name]) -#define CLASS_ATOM(cx,name) ((cx)->runtime->atomState.classAtoms[JSProto_##name]) - -extern const char *const js_common_atom_names[]; -extern const size_t js_common_atom_count; - -/* - * Macros to access C strings for JSType and boolean literals. - */ -#define JS_BOOLEAN_STR(type) (js_common_atom_names[1 + (type)]) -#define JS_TYPE_STR(type) (js_common_atom_names[1 + 2 + (type)]) - -/* Well-known predefined C strings. */ -#define JS_PROTO(name,code,init) extern const char js_##name##_str[]; -#include "jsproto.tbl" -#undef JS_PROTO - -extern const char js_anonymous_str[]; -extern const char js_apply_str[]; -extern const char js_arguments_str[]; -extern const char js_arity_str[]; -extern const char js_BYTES_PER_ELEMENT_str[]; -extern const char js_call_str[]; -extern const char js_callee_str[]; -extern const char js_caller_str[]; -extern const char js_class_prototype_str[]; -extern const char js_close_str[]; -extern const char js_constructor_str[]; -extern const char js_count_str[]; -extern const char js_etago_str[]; -extern const char js_each_str[]; -extern const char js_eval_str[]; -extern const char js_fileName_str[]; -extern const char js_get_str[]; -extern const char js_getter_str[]; -extern const char js_global_str[]; -extern const char js_ignoreCase_str[]; -extern const char js_index_str[]; -extern const char js_input_str[]; -extern const char js_iterator_str[]; -extern const char js_join_str[]; -extern const char js_lastIndex_str[]; -extern const char js_length_str[]; -extern const char js_lineNumber_str[]; -extern const char js_message_str[]; -extern const char js_multiline_str[]; -extern const char js_name_str[]; -extern const char js_namespace_str[]; -extern const char js_next_str[]; -extern const char js_noSuchMethod_str[]; -extern const char js_object_str[]; -extern const char js_proto_str[]; -extern const char js_ptagc_str[]; -extern const char js_qualifier_str[]; -extern const char js_send_str[]; -extern const char js_setter_str[]; -extern const char js_set_str[]; -extern const char js_source_str[]; -extern const char js_space_str[]; -extern const char js_stack_str[]; -extern const char js_sticky_str[]; -extern const char js_stago_str[]; -extern const char js_star_str[]; -extern const char js_starQualifier_str[]; -extern const char js_tagc_str[]; -extern const char js_toGMTString_str[]; -extern const char js_toLocaleString_str[]; -extern const char js_toSource_str[]; -extern const char js_toString_str[]; -extern const char js_toUTCString_str[]; -extern const char js_undefined_str[]; -extern const char js_valueOf_str[]; -extern const char js_toJSON_str[]; -extern const char js_xml_str[]; -extern const char js_enumerable_str[]; -extern const char js_configurable_str[]; -extern const char js_writable_str[]; -extern const char js_value_str[]; -extern const char js_test_str[]; - -/* - * Initialize atom state. Return true on success, false on failure to allocate - * memory. The caller must zero rt->atomState before calling this function and - * only call it after js_InitGC successfully returns. - */ -extern JSBool -js_InitAtomState(JSRuntime *rt); - -/* - * Free and clear atom state including any interned string atoms. This - * function must be called before js_FinishGC. - */ -extern void -js_FinishAtomState(JSRuntime *rt); - -/* - * Atom tracing and garbage collection hooks. - */ - -extern void -js_TraceAtomState(JSTracer *trc); - -extern void -js_SweepAtomState(JSRuntime *rt); - -extern bool -js_InitCommonAtoms(JSContext *cx); - -extern void -js_FinishCommonAtoms(JSContext *cx); - -namespace js { - -/* N.B. must correspond to boolean tagging behavior. */ -enum InternBehavior -{ - DoNotInternAtom = false, - InternAtom = true -}; - -} /* namespace js */ - -extern JSAtom * -js_Atomize(JSContext *cx, const char *bytes, size_t length, - js::InternBehavior ib = js::DoNotInternAtom, - js::FlationCoding fc = js::NormalEncoding); - -extern JSAtom * -js_AtomizeChars(JSContext *cx, const jschar *chars, size_t length, - js::InternBehavior ib = js::DoNotInternAtom); - -extern JSAtom * -js_AtomizeString(JSContext *cx, JSString *str, js::InternBehavior ib = js::DoNotInternAtom); - -/* - * Return an existing atom for the given char array or null if the char - * sequence is currently not atomized. - */ -extern JSAtom * -js_GetExistingStringAtom(JSContext *cx, const jschar *chars, size_t length); - -#ifdef DEBUG - -extern JS_FRIEND_API(void) -js_DumpAtoms(JSContext *cx, FILE *fp); - -#endif - -inline bool -js_ValueToAtom(JSContext *cx, const js::Value &v, JSAtom **atomp); - -inline bool -js_ValueToStringId(JSContext *cx, const js::Value &v, jsid *idp); - -inline bool -js_InternNonIntElementId(JSContext *cx, JSObject *obj, const js::Value &idval, - jsid *idp); -inline bool -js_InternNonIntElementId(JSContext *cx, JSObject *obj, const js::Value &idval, - jsid *idp, js::Value *vp); - -/* - * For all unmapped atoms recorded in al, add a mapping from the atom's index - * to its address. map->length must already be set to the number of atoms in - * the list and map->vector must point to pre-allocated memory. - */ -extern void -js_InitAtomMap(JSContext *cx, js::AtomIndexMap *indices, JSAtom **atoms); - -#endif /* jsatom_h___ */ diff --git a/js/spidermonkey-win32/include/jscell.h b/js/spidermonkey-win32/include/jscell.h deleted file mode 100644 index b7f931671d..0000000000 --- a/js/spidermonkey-win32/include/jscell.h +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is SpiderMonkey code. - * - * The Initial Developer of the Original Code is - * Mozilla Corporation. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Gregor Wagner - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef jscell_h___ -#define jscell_h___ - -#include "jspubtd.h" - -struct JSCompartment; - -namespace js { -namespace gc { - -struct ArenaHeader; -struct Chunk; - -/* The GC allocation kinds. */ -enum AllocKind { - FINALIZE_OBJECT0, - FINALIZE_OBJECT0_BACKGROUND, - FINALIZE_OBJECT2, - FINALIZE_OBJECT2_BACKGROUND, - FINALIZE_OBJECT4, - FINALIZE_OBJECT4_BACKGROUND, - FINALIZE_OBJECT8, - FINALIZE_OBJECT8_BACKGROUND, - FINALIZE_OBJECT12, - FINALIZE_OBJECT12_BACKGROUND, - FINALIZE_OBJECT16, - FINALIZE_OBJECT16_BACKGROUND, - FINALIZE_OBJECT_LAST = FINALIZE_OBJECT16_BACKGROUND, - FINALIZE_SCRIPT, - FINALIZE_SHAPE, - FINALIZE_BASE_SHAPE, - FINALIZE_TYPE_OBJECT, -#if JS_HAS_XML_SUPPORT - FINALIZE_XML, -#endif - FINALIZE_SHORT_STRING, - FINALIZE_STRING, - FINALIZE_EXTERNAL_STRING, - FINALIZE_LAST = FINALIZE_EXTERNAL_STRING -}; - -static const unsigned FINALIZE_LIMIT = FINALIZE_LAST + 1; -static const unsigned FINALIZE_OBJECT_LIMIT = FINALIZE_OBJECT_LAST + 1; - -/* - * Live objects are marked black. How many other additional colors are available - * depends on the size of the GCThing. Objects marked gray are eligible for - * cycle collection. - */ -static const uint32_t BLACK = 0; -static const uint32_t GRAY = 1; - -/* - * A GC cell is the base class for all GC things. - */ -struct Cell { - static const size_t CellShift = 3; - static const size_t CellSize = size_t(1) << CellShift; - static const size_t CellMask = CellSize - 1; - - inline uintptr_t address() const; - inline ArenaHeader *arenaHeader() const; - inline Chunk *chunk() const; - inline AllocKind getAllocKind() const; - - JS_ALWAYS_INLINE bool isMarked(uint32_t color = BLACK) const; - JS_ALWAYS_INLINE bool markIfUnmarked(uint32_t color = BLACK) const; - JS_ALWAYS_INLINE void unmark(uint32_t color) const; - - inline JSCompartment *compartment() const; - -#ifdef DEBUG - inline bool isAligned() const; -#endif -}; - -} /* namespace gc */ -} /* namespace js */ - -#endif /* jscell_h___ */ diff --git a/js/spidermonkey-win32/include/jsclass.h b/js/spidermonkey-win32/include/jsclass.h deleted file mode 100644 index 5fa4e355b6..0000000000 --- a/js/spidermonkey-win32/include/jsclass.h +++ /dev/null @@ -1,427 +0,0 @@ -/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=4 sw=4 et tw=79 ft=cpp: - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is SpiderMonkey JavaScript engine. - * - * The Initial Developer of the Original Code is - * Mozilla Corporation. - * Portions created by the Initial Developer are Copyright (C) 2009 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef jsclass_h__ -#define jsclass_h__ -/* - * A JSClass acts as a vtable for JS objects that allows JSAPI clients to - * control various aspects of the behavior of an object like property lookup. - * js::Class is an engine-private extension that allows more control over - * object behavior and, e.g., allows custom slow layout. - */ -#include "jsapi.h" -#include "jsprvtd.h" - -#ifdef __cplusplus - -namespace js { - -class PropertyName; -class SpecialId; - -static JS_ALWAYS_INLINE jsid -SPECIALID_TO_JSID(const SpecialId &sid); - -/* - * We partition the ways to refer to a property into three: by an index - * (uint32_t); by a string whose characters do not represent an index - * (PropertyName, see vm/String.h); and by various special values. - * - * Special values are encoded using SpecialId, which is layout-compatible but - * non-interconvertible with jsid. A SpecialId may be: an object (used by E4X - * and perhaps eventually by Harmony-proposed private names); JSID_VOID, which - * does not occur in JS scripts but may be used to indicate the absence of a - * valid identifier; or JS_DEFAULT_XML_NAMESPACE_ID, if E4X is enabled. - */ - -class SpecialId { - uintptr_t bits; - - /* Needs access to raw bits. */ - friend JS_ALWAYS_INLINE jsid SPECIALID_TO_JSID(const SpecialId &sid); - - static const uintptr_t TYPE_VOID = JSID_TYPE_VOID; - static const uintptr_t TYPE_OBJECT = JSID_TYPE_OBJECT; - static const uintptr_t TYPE_DEFAULT_XML_NAMESPACE = JSID_TYPE_DEFAULT_XML_NAMESPACE; - static const uintptr_t TYPE_MASK = JSID_TYPE_MASK; - - SpecialId(uintptr_t bits) : bits(bits) { } - - public: - SpecialId() : bits(TYPE_VOID) { } - - /* Object-valued */ - - SpecialId(JSObject &obj) - : bits(uintptr_t(&obj) | TYPE_OBJECT) - { - JS_ASSERT(&obj != NULL); - JS_ASSERT((uintptr_t(&obj) & TYPE_MASK) == 0); - } - - bool isObject() const { - return (bits & TYPE_MASK) == TYPE_OBJECT && bits != TYPE_OBJECT; - } - - JSObject *toObject() const { - JS_ASSERT(isObject()); - return reinterpret_cast(bits & ~TYPE_MASK); - } - - /* Empty */ - - static SpecialId empty() { - SpecialId sid(TYPE_OBJECT); - JS_ASSERT(sid.isEmpty()); - return sid; - } - - bool isEmpty() const { - return bits == TYPE_OBJECT; - } - - /* Void */ - - static SpecialId voidId() { - SpecialId sid(TYPE_VOID); - JS_ASSERT(sid.isVoid()); - return sid; - } - - bool isVoid() const { - return bits == TYPE_VOID; - } - - /* Default XML namespace */ - - static SpecialId defaultXMLNamespace() { - SpecialId sid(TYPE_DEFAULT_XML_NAMESPACE); - JS_ASSERT(sid.isDefaultXMLNamespace()); - return sid; - } - - bool isDefaultXMLNamespace() const { - return bits == TYPE_DEFAULT_XML_NAMESPACE; - } -}; - -static JS_ALWAYS_INLINE jsid -SPECIALID_TO_JSID(const SpecialId &sid) -{ - jsid id; - JSID_BITS(id) = sid.bits; - JS_ASSERT_IF(sid.isObject(), JSID_IS_OBJECT(id) && JSID_TO_OBJECT(id) == sid.toObject()); - JS_ASSERT_IF(sid.isVoid(), JSID_IS_VOID(id)); - JS_ASSERT_IF(sid.isEmpty(), JSID_IS_EMPTY(id)); - JS_ASSERT_IF(sid.isDefaultXMLNamespace(), JSID_IS_DEFAULT_XML_NAMESPACE(id)); - return id; -} - -static JS_ALWAYS_INLINE bool -JSID_IS_SPECIAL(jsid id) -{ - return JSID_IS_OBJECT(id) || JSID_IS_EMPTY(id) || JSID_IS_VOID(id) || - JSID_IS_DEFAULT_XML_NAMESPACE(id); -} - -static JS_ALWAYS_INLINE SpecialId -JSID_TO_SPECIALID(jsid id) -{ - JS_ASSERT(JSID_IS_SPECIAL(id)); - if (JSID_IS_OBJECT(id)) - return SpecialId(*JSID_TO_OBJECT(id)); - if (JSID_IS_EMPTY(id)) - return SpecialId::empty(); - if (JSID_IS_VOID(id)) - return SpecialId::voidId(); - JS_ASSERT(JSID_IS_DEFAULT_XML_NAMESPACE(id)); - return SpecialId::defaultXMLNamespace(); -} - -/* js::Class operation signatures. */ - -typedef JSBool -(* LookupGenericOp)(JSContext *cx, JSObject *obj, jsid id, JSObject **objp, - JSProperty **propp); -typedef JSBool -(* LookupPropOp)(JSContext *cx, JSObject *obj, PropertyName *name, JSObject **objp, - JSProperty **propp); -typedef JSBool -(* LookupElementOp)(JSContext *cx, JSObject *obj, uint32_t index, JSObject **objp, - JSProperty **propp); -typedef JSBool -(* LookupSpecialOp)(JSContext *cx, JSObject *obj, SpecialId sid, JSObject **objp, - JSProperty **propp); -typedef JSBool -(* DefineGenericOp)(JSContext *cx, JSObject *obj, jsid id, const Value *value, - PropertyOp getter, StrictPropertyOp setter, unsigned attrs); -typedef JSBool -(* DefinePropOp)(JSContext *cx, JSObject *obj, PropertyName *name, const Value *value, - PropertyOp getter, StrictPropertyOp setter, unsigned attrs); -typedef JSBool -(* DefineElementOp)(JSContext *cx, JSObject *obj, uint32_t index, const Value *value, - PropertyOp getter, StrictPropertyOp setter, unsigned attrs); -typedef JSBool -(* DefineSpecialOp)(JSContext *cx, JSObject *obj, SpecialId sid, const Value *value, - PropertyOp getter, StrictPropertyOp setter, unsigned attrs); -typedef JSBool -(* GenericIdOp)(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp); -typedef JSBool -(* PropertyIdOp)(JSContext *cx, JSObject *obj, JSObject *receiver, PropertyName *name, Value *vp); -typedef JSBool -(* ElementIdOp)(JSContext *cx, JSObject *obj, JSObject *receiver, uint32_t index, Value *vp); -typedef JSBool -(* ElementIfPresentOp)(JSContext *cx, JSObject *obj, JSObject *receiver, uint32_t index, Value *vp, bool* present); -typedef JSBool -(* SpecialIdOp)(JSContext *cx, JSObject *obj, JSObject *receiver, SpecialId sid, Value *vp); -typedef JSBool -(* StrictGenericIdOp)(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict); -typedef JSBool -(* StrictPropertyIdOp)(JSContext *cx, JSObject *obj, PropertyName *name, Value *vp, JSBool strict); -typedef JSBool -(* StrictElementIdOp)(JSContext *cx, JSObject *obj, uint32_t index, Value *vp, JSBool strict); -typedef JSBool -(* StrictSpecialIdOp)(JSContext *cx, JSObject *obj, SpecialId sid, Value *vp, JSBool strict); -typedef JSBool -(* GenericAttributesOp)(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp); -typedef JSBool -(* PropertyAttributesOp)(JSContext *cx, JSObject *obj, PropertyName *name, unsigned *attrsp); -typedef JSBool -(* ElementAttributesOp)(JSContext *cx, JSObject *obj, uint32_t index, unsigned *attrsp); -typedef JSBool -(* SpecialAttributesOp)(JSContext *cx, JSObject *obj, SpecialId sid, unsigned *attrsp); -typedef JSBool -(* DeletePropertyOp)(JSContext *cx, JSObject *obj, PropertyName *name, Value *vp, JSBool strict); -typedef JSBool -(* DeleteElementOp)(JSContext *cx, JSObject *obj, uint32_t index, Value *vp, JSBool strict); -typedef JSBool -(* DeleteSpecialOp)(JSContext *cx, JSObject *obj, SpecialId sid, Value *vp, JSBool strict); -typedef JSType -(* TypeOfOp)(JSContext *cx, JSObject *obj); - -/* - * Prepare to make |obj| non-extensible; in particular, fully resolve its properties. - * On error, return false. - * If |obj| is now ready to become non-extensible, set |*fixed| to true and return true. - * If |obj| refuses to become non-extensible, set |*fixed| to false and return true; the - * caller will throw an appropriate error. - */ -typedef JSBool -(* FixOp)(JSContext *cx, JSObject *obj, bool *fixed, AutoIdVector *props); - -typedef JSObject * -(* ObjectOp)(JSContext *cx, JSObject *obj); -typedef void -(* FinalizeOp)(JSContext *cx, JSObject *obj); - -#define JS_CLASS_MEMBERS \ - const char *name; \ - uint32_t flags; \ - \ - /* Mandatory non-null function pointer members. */ \ - JSPropertyOp addProperty; \ - JSPropertyOp delProperty; \ - JSPropertyOp getProperty; \ - JSStrictPropertyOp setProperty; \ - JSEnumerateOp enumerate; \ - JSResolveOp resolve; \ - JSConvertOp convert; \ - JSFinalizeOp finalize; \ - \ - /* Optionally non-null members start here. */ \ - JSCheckAccessOp checkAccess; \ - JSNative call; \ - JSNative construct; \ - JSHasInstanceOp hasInstance; \ - JSTraceOp trace - -/* - * The helper struct to measure the size of JS_CLASS_MEMBERS to know how much - * we have to padd js::Class to match the size of JSClass; - */ -struct ClassSizeMeasurement -{ - JS_CLASS_MEMBERS; -}; - -struct ClassExtension -{ - JSEqualityOp equality; - JSObjectOp outerObject; - JSObjectOp innerObject; - JSIteratorOp iteratorObject; - void *unused; - - /* - * isWrappedNative is true only if the class is an XPCWrappedNative. - * WeakMaps use this to override the wrapper disposal optimization. - */ - bool isWrappedNative; -}; - -#define JS_NULL_CLASS_EXT {NULL,NULL,NULL,NULL,NULL,false} - -struct ObjectOps -{ - LookupGenericOp lookupGeneric; - LookupPropOp lookupProperty; - LookupElementOp lookupElement; - LookupSpecialOp lookupSpecial; - DefineGenericOp defineGeneric; - DefinePropOp defineProperty; - DefineElementOp defineElement; - DefineSpecialOp defineSpecial; - GenericIdOp getGeneric; - PropertyIdOp getProperty; - ElementIdOp getElement; - ElementIfPresentOp getElementIfPresent; /* can be null */ - SpecialIdOp getSpecial; - StrictGenericIdOp setGeneric; - StrictPropertyIdOp setProperty; - StrictElementIdOp setElement; - StrictSpecialIdOp setSpecial; - GenericAttributesOp getGenericAttributes; - PropertyAttributesOp getPropertyAttributes; - ElementAttributesOp getElementAttributes; - SpecialAttributesOp getSpecialAttributes; - GenericAttributesOp setGenericAttributes; - PropertyAttributesOp setPropertyAttributes; - ElementAttributesOp setElementAttributes; - SpecialAttributesOp setSpecialAttributes; - DeletePropertyOp deleteProperty; - DeleteElementOp deleteElement; - DeleteSpecialOp deleteSpecial; - - JSNewEnumerateOp enumerate; - TypeOfOp typeOf; - FixOp fix; - ObjectOp thisObject; - FinalizeOp clear; -}; - -#define JS_NULL_OBJECT_OPS \ - {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, \ - NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, \ - NULL,NULL,NULL,NULL,NULL,NULL} - -struct Class -{ - JS_CLASS_MEMBERS; - ClassExtension ext; - ObjectOps ops; - uint8_t pad[sizeof(JSClass) - sizeof(ClassSizeMeasurement) - - sizeof(ClassExtension) - sizeof(ObjectOps)]; - - /* Class is not native and its map is not a scope. */ - static const uint32_t NON_NATIVE = JSCLASS_INTERNAL_FLAG2; - - bool isNative() const { - return !(flags & NON_NATIVE); - } - - bool hasPrivate() const { - return !!(flags & JSCLASS_HAS_PRIVATE); - } -}; - -JS_STATIC_ASSERT(offsetof(JSClass, name) == offsetof(Class, name)); -JS_STATIC_ASSERT(offsetof(JSClass, flags) == offsetof(Class, flags)); -JS_STATIC_ASSERT(offsetof(JSClass, addProperty) == offsetof(Class, addProperty)); -JS_STATIC_ASSERT(offsetof(JSClass, delProperty) == offsetof(Class, delProperty)); -JS_STATIC_ASSERT(offsetof(JSClass, getProperty) == offsetof(Class, getProperty)); -JS_STATIC_ASSERT(offsetof(JSClass, setProperty) == offsetof(Class, setProperty)); -JS_STATIC_ASSERT(offsetof(JSClass, enumerate) == offsetof(Class, enumerate)); -JS_STATIC_ASSERT(offsetof(JSClass, resolve) == offsetof(Class, resolve)); -JS_STATIC_ASSERT(offsetof(JSClass, convert) == offsetof(Class, convert)); -JS_STATIC_ASSERT(offsetof(JSClass, finalize) == offsetof(Class, finalize)); -JS_STATIC_ASSERT(offsetof(JSClass, checkAccess) == offsetof(Class, checkAccess)); -JS_STATIC_ASSERT(offsetof(JSClass, call) == offsetof(Class, call)); -JS_STATIC_ASSERT(offsetof(JSClass, construct) == offsetof(Class, construct)); -JS_STATIC_ASSERT(offsetof(JSClass, hasInstance) == offsetof(Class, hasInstance)); -JS_STATIC_ASSERT(offsetof(JSClass, trace) == offsetof(Class, trace)); -JS_STATIC_ASSERT(sizeof(JSClass) == sizeof(Class)); - -static JS_ALWAYS_INLINE JSClass * -Jsvalify(Class *c) -{ - return (JSClass *)c; -} -static JS_ALWAYS_INLINE const JSClass * -Jsvalify(const Class *c) -{ - return (const JSClass *)c; -} - -static JS_ALWAYS_INLINE Class * -Valueify(JSClass *c) -{ - return (Class *)c; -} -static JS_ALWAYS_INLINE const Class * -Valueify(const JSClass *c) -{ - return (const Class *)c; -} - -/* - * Enumeration describing possible values of the [[Class]] internal property - * value of objects. - */ -enum ESClassValue { - ESClass_Array, ESClass_Number, ESClass_String, ESClass_Boolean, ESClass_RegExp -}; - -/* - * Return whether the given object has the given [[Class]] internal property - * value. Beware, this query says nothing about the js::Class of the JSObject - * so the caller must not assume anything about obj's representation (e.g., obj - * may be a proxy). - */ -inline bool -ObjectClassIs(JSObject &obj, ESClassValue classValue, JSContext *cx); - -/* Just a helper that checks v.isObject before calling ObjectClassIs. */ -inline bool -IsObjectWithClass(const Value &v, ESClassValue classValue, JSContext *cx); - -} /* namespace js */ - -#endif /* __cplusplus */ - -#endif /* jsclass_h__ */ diff --git a/js/spidermonkey-win32/include/jsclist.h b/js/spidermonkey-win32/include/jsclist.h deleted file mode 100644 index 604ec0ec95..0000000000 --- a/js/spidermonkey-win32/include/jsclist.h +++ /dev/null @@ -1,139 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef jsclist_h___ -#define jsclist_h___ - -#include "jstypes.h" - -/* -** Circular linked list -*/ -typedef struct JSCListStr { - struct JSCListStr *next; - struct JSCListStr *prev; -} JSCList; - -/* -** Insert element "_e" into the list, before "_l". -*/ -#define JS_INSERT_BEFORE(_e,_l) \ - JS_BEGIN_MACRO \ - (_e)->next = (_l); \ - (_e)->prev = (_l)->prev; \ - (_l)->prev->next = (_e); \ - (_l)->prev = (_e); \ - JS_END_MACRO - -/* -** Insert element "_e" into the list, after "_l". -*/ -#define JS_INSERT_AFTER(_e,_l) \ - JS_BEGIN_MACRO \ - (_e)->next = (_l)->next; \ - (_e)->prev = (_l); \ - (_l)->next->prev = (_e); \ - (_l)->next = (_e); \ - JS_END_MACRO - -/* -** Return the element following element "_e" -*/ -#define JS_NEXT_LINK(_e) \ - ((_e)->next) -/* -** Return the element preceding element "_e" -*/ -#define JS_PREV_LINK(_e) \ - ((_e)->prev) - -/* -** Append an element "_e" to the end of the list "_l" -*/ -#define JS_APPEND_LINK(_e,_l) JS_INSERT_BEFORE(_e,_l) - -/* -** Insert an element "_e" at the head of the list "_l" -*/ -#define JS_INSERT_LINK(_e,_l) JS_INSERT_AFTER(_e,_l) - -/* Return the head/tail of the list */ -#define JS_LIST_HEAD(_l) (_l)->next -#define JS_LIST_TAIL(_l) (_l)->prev - -/* -** Remove the element "_e" from it's circular list. -*/ -#define JS_REMOVE_LINK(_e) \ - JS_BEGIN_MACRO \ - (_e)->prev->next = (_e)->next; \ - (_e)->next->prev = (_e)->prev; \ - JS_END_MACRO - -/* -** Remove the element "_e" from it's circular list. Also initializes the -** linkage. -*/ -#define JS_REMOVE_AND_INIT_LINK(_e) \ - JS_BEGIN_MACRO \ - (_e)->prev->next = (_e)->next; \ - (_e)->next->prev = (_e)->prev; \ - (_e)->next = (_e); \ - (_e)->prev = (_e); \ - JS_END_MACRO - -/* -** Return non-zero if the given circular list "_l" is empty, zero if the -** circular list is not empty -*/ -#define JS_CLIST_IS_EMPTY(_l) \ - ((_l)->next == (_l)) - -/* -** Initialize a circular list -*/ -#define JS_INIT_CLIST(_l) \ - JS_BEGIN_MACRO \ - (_l)->next = (_l); \ - (_l)->prev = (_l); \ - JS_END_MACRO - -#define JS_INIT_STATIC_CLIST(_l) \ - {(_l), (_l)} - -#endif /* jsclist_h___ */ diff --git a/js/spidermonkey-win32/include/json.h b/js/spidermonkey-win32/include/jscompat.h similarity index 57% rename from js/spidermonkey-win32/include/json.h rename to js/spidermonkey-win32/include/jscompat.h index 64c36dbca0..5ecda6e813 100644 --- a/js/spidermonkey-win32/include/json.h +++ b/js/spidermonkey-win32/include/jscompat.h @@ -1,4 +1,6 @@ -/* ***** BEGIN LICENSE BLOCK ***** +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version @@ -11,15 +13,15 @@ * for the specific language governing rights and limitations under the * License. * - * The Original Code is SpiderMonkey JSON. + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. * * The Initial Developer of the Original Code is - * Mozilla Corporation. + * Netscape Communications Corporation. * Portions created by the Initial Developer are Copyright (C) 1998-1999 * the Initial Developer. All Rights Reserved. * * Contributor(s): - * Robert Sayre * * Alternatively, the contents of this file may be used under the terms of * either of the GNU General Public License Version 2 or later (the "GPL"), @@ -35,39 +37,19 @@ * * ***** END LICENSE BLOCK ***** */ -#ifndef json_h___ -#define json_h___ - -#include "jsprvtd.h" -#include "jspubtd.h" - -#include "js/Vector.h" - -#define JSON_MAX_DEPTH 2048 -#define JSON_PARSER_BUFSIZE 1024 - -extern JSObject * -js_InitJSONClass(JSContext *cx, JSObject *obj); - -extern JSBool -js_Stringify(JSContext *cx, js::Value *vp, JSObject *replacer, js::Value space, - js::StringBuffer &sb); - +#ifndef jscompat_h___ +#define jscompat_h___ /* - * The type of JSON decoding to perform. Strict decoding is to-the-spec; - * legacy decoding accepts a few non-JSON syntaxes historically accepted by the - * implementation. (Full description of these deviations is deliberately - * omitted.) New users should use strict decoding rather than legacy decoding, - * as legacy decoding might be removed at a future time. + * Compatibility glue for various NSPR versions. We must always define int8, + * int16, jsword, and so on to minimize differences with js/ref, no matter what + * the NSPR typedef names may be. */ -enum DecodingMode { STRICT, LEGACY }; +#include "jstypes.h" +#include "jslong.h" -namespace js { - -extern JS_FRIEND_API(JSBool) -ParseJSONWithReviver(JSContext *cx, const jschar *chars, size_t length, const Value &filter, - Value *vp, DecodingMode decodingMode = STRICT); - -} /* namespace js */ - -#endif /* json_h___ */ +typedef JSIntn intN; +typedef JSUintn uintN; +typedef JSUword jsuword; +typedef JSWord jsword; +typedef float float32; +#endif /* jscompat_h___ */ diff --git a/js/spidermonkey-win32/include/jscpucfg.h b/js/spidermonkey-win32/include/jscpucfg.h index 5fd8415bdd..c52a44bfc8 100644 --- a/js/spidermonkey-win32/include/jscpucfg.h +++ b/js/spidermonkey-win32/include/jscpucfg.h @@ -42,113 +42,50 @@ #define JS_HAVE_LONG_LONG +#if defined(XP_WIN) || defined(XP_OS2) || defined(WINCE) + #if defined(_WIN64) -# if defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_) -# define IS_LITTLE_ENDIAN 1 -# undef IS_BIG_ENDIAN -# define JS_BYTES_PER_DOUBLE 8 -# define JS_BYTES_PER_WORD 8 -# define JS_BITS_PER_WORD_LOG2 6 -# define JS_ALIGN_OF_POINTER 8 -# else /* !(defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_)) */ -# error "CPU type is unknown" -# endif /* !(defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_)) */ +#if defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_) +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define JS_BYTES_PER_DOUBLE 8L +#define JS_BYTES_PER_WORD 8L +#define JS_BITS_PER_WORD_LOG2 6 +#define JS_ALIGN_OF_POINTER 8L +#else /* !(defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_)) */ +#error "CPU type is unknown" +#endif /* !(defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_)) */ -#elif defined(_WIN32) || defined(XP_OS2) +#elif defined(_WIN32) || defined(XP_OS2) || defined(WINCE) -# ifdef __WATCOMC__ -# define HAVE_VA_LIST_AS_ARRAY 1 -# endif +#ifdef __WATCOMC__ +#define HAVE_VA_LIST_AS_ARRAY 1 +#endif -# define IS_LITTLE_ENDIAN 1 -# undef IS_BIG_ENDIAN -# define JS_BYTES_PER_DOUBLE 8 -# define JS_BYTES_PER_WORD 4 -# define JS_BITS_PER_WORD_LOG2 5 -# define JS_ALIGN_OF_POINTER 4 +#define IS_LITTLE_ENDIAN 1 +#undef IS_BIG_ENDIAN +#define JS_BYTES_PER_DOUBLE 8L +#define JS_BYTES_PER_WORD 4L +#define JS_BITS_PER_WORD_LOG2 5 +#define JS_ALIGN_OF_POINTER 4L -#elif defined(__APPLE__) -# if __LITTLE_ENDIAN__ -# define IS_LITTLE_ENDIAN 1 -# undef IS_BIG_ENDIAN -# elif __BIG_ENDIAN__ -# undef IS_LITTLE_ENDIAN -# define IS_BIG_ENDIAN 1 -# endif +#endif /* _WIN32 || XP_OS2 || WINCE*/ -#elif defined(JS_HAVE_ENDIAN_H) -# include +#elif defined(XP_UNIX) || defined(XP_BEOS) -# if defined(__BYTE_ORDER) -# if __BYTE_ORDER == __LITTLE_ENDIAN -# define IS_LITTLE_ENDIAN 1 -# undef IS_BIG_ENDIAN -# elif __BYTE_ORDER == __BIG_ENDIAN -# undef IS_LITTLE_ENDIAN -# define IS_BIG_ENDIAN 1 -# endif -# else /* !defined(__BYTE_ORDER) */ -# error "endian.h does not define __BYTE_ORDER. Cannot determine endianness." -# endif +#error "This file is supposed to be auto-generated on UNIX platforms, but the" +#error "static version for Mac and Windows platforms is being used." +#error "Something's probably wrong with paths/headers/dependencies/Makefiles." -/* BSDs */ -#elif defined(JS_HAVE_MACHINE_ENDIAN_H) -# include -# include +#else -# if defined(_BYTE_ORDER) -# if _BYTE_ORDER == _LITTLE_ENDIAN -# define IS_LITTLE_ENDIAN 1 -# undef IS_BIG_ENDIAN -# elif _BYTE_ORDER == _BIG_ENDIAN -# undef IS_LITTLE_ENDIAN -# define IS_BIG_ENDIAN 1 -# endif -# else /* !defined(_BYTE_ORDER) */ -# error "machine/endian.h does not define _BYTE_ORDER. Cannot determine endianness." -# endif +#error "Must define one of XP_BEOS, XP_OS2, XP_WIN, or XP_UNIX" -#elif defined(JS_HAVE_SYS_ISA_DEFS_H) -# include - -# if defined(_BIG_ENDIAN) -# undef IS_LITTLE_ENDIAN -# define IS_BIG_ENDIAN 1 -# elif defined(_LITTLE_ENDIAN) -# define IS_LITTLE_ENDIAN 1 -# undef IS_BIG_ENDIAN -# else /* !defined(_LITTLE_ENDIAN) */ -# error "sys/isa_defs.h does not define _BIG_ENDIAN or _LITTLE_ENDIAN. Cannot determine endianness." -# endif -# if !defined(JS_STACK_GROWTH_DIRECTION) -# if defined(_STACK_GROWS_UPWARD) -# define JS_STACK_GROWTH_DIRECTION (1) -# elif defined(_STACK_GROWS_DOWNWARD) -# define JS_STACK_GROWTH_DIRECTION (-1) -# endif -# endif - -#elif defined(__sparc) || defined(__sparc__) || \ - defined(_POWER) || defined(__powerpc__) || \ - defined(__ppc__) || defined(__hppa) || \ - defined(_MIPSEB) || defined(_BIG_ENDIAN) -/* IA64 running HP-UX will have _BIG_ENDIAN defined. - * IA64 running Linux will have endian.h and be handled above. - */ -# undef IS_LITTLE_ENDIAN -# define IS_BIG_ENDIAN 1 - -#else /* !defined(__sparc) && !defined(__sparc__) && ... */ -# error "Cannot determine endianness of your platform. Please add support to jscpucfg.h." #endif #ifndef JS_STACK_GROWTH_DIRECTION -# ifdef __hppa -# define JS_STACK_GROWTH_DIRECTION (1) -# else -# define JS_STACK_GROWTH_DIRECTION (-1) -# endif +#define JS_STACK_GROWTH_DIRECTION (-1) #endif #endif /* js_cpucfg___ */ diff --git a/js/spidermonkey-win32/include/jsdbgapi.h b/js/spidermonkey-win32/include/jsdbgapi.h deleted file mode 100644 index 5c2e340154..0000000000 --- a/js/spidermonkey-win32/include/jsdbgapi.h +++ /dev/null @@ -1,586 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sw=4 et tw=99: - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Nick Fitzgerald - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef jsdbgapi_h___ -#define jsdbgapi_h___ -/* - * JS debugger API. - */ -#include "jsapi.h" -#include "jsprvtd.h" - -JS_BEGIN_EXTERN_C - -extern JS_PUBLIC_API(JSCrossCompartmentCall *) -JS_EnterCrossCompartmentCallScript(JSContext *cx, JSScript *target); - -extern JS_PUBLIC_API(JSCrossCompartmentCall *) -JS_EnterCrossCompartmentCallStackFrame(JSContext *cx, JSStackFrame *target); - -#ifdef __cplusplus -JS_END_EXTERN_C - -namespace JS { - -class JS_PUBLIC_API(AutoEnterScriptCompartment) -{ - protected: - JSCrossCompartmentCall *call; - - public: - AutoEnterScriptCompartment() : call(NULL) {} - - bool enter(JSContext *cx, JSScript *target); - - bool entered() const { return call != NULL; } - - ~AutoEnterScriptCompartment() { - if (call && call != reinterpret_cast(1)) - JS_LeaveCrossCompartmentCall(call); - } -}; - -class JS_PUBLIC_API(AutoEnterFrameCompartment) : public AutoEnterScriptCompartment -{ - public: - bool enter(JSContext *cx, JSStackFrame *target); -}; - -} /* namespace JS */ - -#ifdef DEBUG -JS_FRIEND_API(void) js_DumpValue(const js::Value &val); -JS_FRIEND_API(void) js_DumpId(jsid id); -JS_FRIEND_API(void) js_DumpStackFrame(JSContext *cx, js::StackFrame *start = NULL); -#endif - -JS_BEGIN_EXTERN_C -#endif - -extern JS_PUBLIC_API(JSString *) -JS_DecompileScript(JSContext *cx, JSScript *script, const char *name, unsigned indent); - -/* - * Currently, we only support runtime-wide debugging. In the future, we should - * be able to support compartment-wide debugging. - */ -extern JS_PUBLIC_API(void) -JS_SetRuntimeDebugMode(JSRuntime *rt, JSBool debug); - -/* - * Debug mode is a compartment-wide mode that enables a debugger to attach - * to and interact with running methodjit-ed frames. In particular, it causes - * every function to be compiled as if an eval was present (so eval-in-frame) - * can work, and it ensures that functions can be re-JITed for other debug - * features. In general, it is not safe to interact with frames that were live - * before debug mode was enabled. For this reason, it is also not safe to - * enable debug mode while frames are live. - */ - -/* Get current state of debugging mode. */ -extern JS_PUBLIC_API(JSBool) -JS_GetDebugMode(JSContext *cx); - -/* - * Turn on/off debugging mode for a single compartment. This should only be - * used when no code from this compartment is running or on the stack in any - * thread. - */ -JS_FRIEND_API(JSBool) -JS_SetDebugModeForCompartment(JSContext *cx, JSCompartment *comp, JSBool debug); - -/* - * Turn on/off debugging mode for a context's compartment. - */ -JS_FRIEND_API(JSBool) -JS_SetDebugMode(JSContext *cx, JSBool debug); - -/* Turn on single step mode. */ -extern JS_PUBLIC_API(JSBool) -JS_SetSingleStepMode(JSContext *cx, JSScript *script, JSBool singleStep); - -/* The closure argument will be marked. */ -extern JS_PUBLIC_API(JSBool) -JS_SetTrap(JSContext *cx, JSScript *script, jsbytecode *pc, - JSTrapHandler handler, jsval closure); - -extern JS_PUBLIC_API(void) -JS_ClearTrap(JSContext *cx, JSScript *script, jsbytecode *pc, - JSTrapHandler *handlerp, jsval *closurep); - -extern JS_PUBLIC_API(void) -JS_ClearScriptTraps(JSContext *cx, JSScript *script); - -extern JS_PUBLIC_API(void) -JS_ClearAllTrapsForCompartment(JSContext *cx); - -extern JS_PUBLIC_API(JSBool) -JS_SetInterrupt(JSRuntime *rt, JSInterruptHook handler, void *closure); - -extern JS_PUBLIC_API(JSBool) -JS_ClearInterrupt(JSRuntime *rt, JSInterruptHook *handlerp, void **closurep); - -/************************************************************************/ - -extern JS_PUBLIC_API(JSBool) -JS_SetWatchPoint(JSContext *cx, JSObject *obj, jsid id, - JSWatchPointHandler handler, JSObject *closure); - -extern JS_PUBLIC_API(JSBool) -JS_ClearWatchPoint(JSContext *cx, JSObject *obj, jsid id, - JSWatchPointHandler *handlerp, JSObject **closurep); - -extern JS_PUBLIC_API(JSBool) -JS_ClearWatchPointsForObject(JSContext *cx, JSObject *obj); - -extern JS_PUBLIC_API(JSBool) -JS_ClearAllWatchPoints(JSContext *cx); - -/************************************************************************/ - -extern JS_PUBLIC_API(unsigned) -JS_PCToLineNumber(JSContext *cx, JSScript *script, jsbytecode *pc); - -extern JS_PUBLIC_API(jsbytecode *) -JS_LineNumberToPC(JSContext *cx, JSScript *script, unsigned lineno); - -extern JS_PUBLIC_API(jsbytecode *) -JS_EndPC(JSContext *cx, JSScript *script); - -extern JS_PUBLIC_API(JSBool) -JS_GetLinePCs(JSContext *cx, JSScript *script, - unsigned startLine, unsigned maxLines, - unsigned* count, unsigned** lines, jsbytecode*** pcs); - -extern JS_PUBLIC_API(unsigned) -JS_GetFunctionArgumentCount(JSContext *cx, JSFunction *fun); - -extern JS_PUBLIC_API(JSBool) -JS_FunctionHasLocalNames(JSContext *cx, JSFunction *fun); - -/* - * N.B. The mark is in the context temp pool and thus the caller must take care - * to call JS_ReleaseFunctionLocalNameArray in a LIFO manner (wrt to any other - * call that may use the temp pool. - */ -extern JS_PUBLIC_API(uintptr_t *) -JS_GetFunctionLocalNameArray(JSContext *cx, JSFunction *fun, void **markp); - -extern JS_PUBLIC_API(JSAtom *) -JS_LocalNameToAtom(uintptr_t w); - -extern JS_PUBLIC_API(JSString *) -JS_AtomKey(JSAtom *atom); - -extern JS_PUBLIC_API(void) -JS_ReleaseFunctionLocalNameArray(JSContext *cx, void *mark); - -extern JS_PUBLIC_API(JSScript *) -JS_GetFunctionScript(JSContext *cx, JSFunction *fun); - -extern JS_PUBLIC_API(JSNative) -JS_GetFunctionNative(JSContext *cx, JSFunction *fun); - -extern JS_PUBLIC_API(JSPrincipals *) -JS_GetScriptPrincipals(JSContext *cx, JSScript *script); - -extern JS_PUBLIC_API(JSPrincipals *) -JS_GetScriptOriginPrincipals(JSContext *cx, JSScript *script); - -/* - * Stack Frame Iterator - * - * Used to iterate through the JS stack frames to extract - * information from the frames. - */ - -extern JS_PUBLIC_API(JSStackFrame *) -JS_FrameIterator(JSContext *cx, JSStackFrame **iteratorp); - -extern JS_PUBLIC_API(JSScript *) -JS_GetFrameScript(JSContext *cx, JSStackFrame *fp); - -extern JS_PUBLIC_API(jsbytecode *) -JS_GetFramePC(JSContext *cx, JSStackFrame *fp); - -/* - * Get the closest scripted frame below fp. If fp is null, start from cx->fp. - */ -extern JS_PUBLIC_API(JSStackFrame *) -JS_GetScriptedCaller(JSContext *cx, JSStackFrame *fp); - -extern JS_PUBLIC_API(void *) -JS_GetFrameAnnotation(JSContext *cx, JSStackFrame *fp); - -extern JS_PUBLIC_API(void) -JS_SetFrameAnnotation(JSContext *cx, JSStackFrame *fp, void *annotation); - -extern JS_PUBLIC_API(JSBool) -JS_IsScriptFrame(JSContext *cx, JSStackFrame *fp); - -extern JS_PUBLIC_API(JSObject *) -JS_GetFrameScopeChain(JSContext *cx, JSStackFrame *fp); - -extern JS_PUBLIC_API(JSObject *) -JS_GetFrameCallObject(JSContext *cx, JSStackFrame *fp); - -extern JS_PUBLIC_API(JSBool) -JS_GetFrameThis(JSContext *cx, JSStackFrame *fp, jsval *thisv); - -extern JS_PUBLIC_API(JSFunction *) -JS_GetFrameFunction(JSContext *cx, JSStackFrame *fp); - -extern JS_PUBLIC_API(JSObject *) -JS_GetFrameFunctionObject(JSContext *cx, JSStackFrame *fp); - -JS_PUBLIC_API(JSFunction *) -JS_GetScriptFunction(JSContext *cx, JSScript *script); - -extern JS_PUBLIC_API(JSObject *) -JS_GetParentOrScopeChain(JSContext *cx, JSObject *obj); - -/* XXXrginda Initially published with typo */ -#define JS_IsContructorFrame JS_IsConstructorFrame -extern JS_PUBLIC_API(JSBool) -JS_IsConstructorFrame(JSContext *cx, JSStackFrame *fp); - -extern JS_PUBLIC_API(JSBool) -JS_IsDebuggerFrame(JSContext *cx, JSStackFrame *fp); - -extern JS_PUBLIC_API(JSBool) -JS_IsGlobalFrame(JSContext *cx, JSStackFrame *fp); - -extern JS_PUBLIC_API(jsval) -JS_GetFrameReturnValue(JSContext *cx, JSStackFrame *fp); - -extern JS_PUBLIC_API(void) -JS_SetFrameReturnValue(JSContext *cx, JSStackFrame *fp, jsval rval); - -/** - * Return fp's callee function object (fp->callee) if it has one. Note that - * this API cannot fail. A null return means "no callee": fp is a global or - * eval-from-global frame, not a call frame. - * - * This API began life as an infallible getter, but now it can return either: - * - * 1. An optimized closure that was compiled assuming the function could not - * escape and be called from sites the compiler could not see. - * - * 2. A "joined function object", an optimization whereby SpiderMonkey avoids - * creating fresh function objects for every evaluation of a function - * expression that is used only once by a consumer that either promises to - * clone later when asked for the value or that cannot leak the value. - * - * Because Mozilla's Gecko embedding of SpiderMonkey (and no doubt other - * embeddings) calls this API in potentially performance-sensitive ways (e.g. - * in nsContentUtils::GetDocumentFromCaller), we are leaving this API alone. It - * may now return an unwrapped non-escaping optimized closure, or a joined - * function object. Such optimized objects may work well if called from the - * correct context, never mutated or compared for identity, etc. - * - * However, if you really need to get the same callee object that JS code would - * see, which means undoing the optimizations, where an undo attempt can fail, - * then use JS_GetValidFrameCalleeObject. - */ -extern JS_PUBLIC_API(JSObject *) -JS_GetFrameCalleeObject(JSContext *cx, JSStackFrame *fp); - -/** - * Return fp's callee function object after running the deferred closure - * cloning "method read barrier". This API can fail! If the frame has no - * callee, this API returns true with JSVAL_IS_VOID(*vp). - */ -extern JS_PUBLIC_API(JSBool) -JS_GetValidFrameCalleeObject(JSContext *cx, JSStackFrame *fp, jsval *vp); - -/************************************************************************/ - -extern JS_PUBLIC_API(const char *) -JS_GetScriptFilename(JSContext *cx, JSScript *script); - -extern JS_PUBLIC_API(const jschar *) -JS_GetScriptSourceMap(JSContext *cx, JSScript *script); - -extern JS_PUBLIC_API(unsigned) -JS_GetScriptBaseLineNumber(JSContext *cx, JSScript *script); - -extern JS_PUBLIC_API(unsigned) -JS_GetScriptLineExtent(JSContext *cx, JSScript *script); - -extern JS_PUBLIC_API(JSVersion) -JS_GetScriptVersion(JSContext *cx, JSScript *script); - -/************************************************************************/ - -/* - * Hook setters for script creation and destruction, see jsprvtd.h for the - * typedefs. These macros provide binary compatibility and newer, shorter - * synonyms. - */ -#define JS_SetNewScriptHook JS_SetNewScriptHookProc -#define JS_SetDestroyScriptHook JS_SetDestroyScriptHookProc - -extern JS_PUBLIC_API(void) -JS_SetNewScriptHook(JSRuntime *rt, JSNewScriptHook hook, void *callerdata); - -extern JS_PUBLIC_API(void) -JS_SetDestroyScriptHook(JSRuntime *rt, JSDestroyScriptHook hook, - void *callerdata); - -/************************************************************************/ - -extern JS_PUBLIC_API(JSBool) -JS_EvaluateUCInStackFrame(JSContext *cx, JSStackFrame *fp, - const jschar *chars, unsigned length, - const char *filename, unsigned lineno, - jsval *rval); - -extern JS_PUBLIC_API(JSBool) -JS_EvaluateInStackFrame(JSContext *cx, JSStackFrame *fp, - const char *bytes, unsigned length, - const char *filename, unsigned lineno, - jsval *rval); - -/************************************************************************/ - -typedef struct JSPropertyDesc { - jsval id; /* primary id, atomized string, or int */ - jsval value; /* property value */ - uint8_t flags; /* flags, see below */ - uint8_t spare; /* unused */ - uint16_t slot; /* argument/variable slot */ - jsval alias; /* alias id if JSPD_ALIAS flag */ -} JSPropertyDesc; - -#define JSPD_ENUMERATE 0x01 /* visible to for/in loop */ -#define JSPD_READONLY 0x02 /* assignment is error */ -#define JSPD_PERMANENT 0x04 /* property cannot be deleted */ -#define JSPD_ALIAS 0x08 /* property has an alias id */ -#define JSPD_ARGUMENT 0x10 /* argument to function */ -#define JSPD_VARIABLE 0x20 /* local variable in function */ -#define JSPD_EXCEPTION 0x40 /* exception occurred fetching the property, */ - /* value is exception */ -#define JSPD_ERROR 0x80 /* native getter returned JS_FALSE without */ - /* throwing an exception */ - -typedef struct JSPropertyDescArray { - uint32_t length; /* number of elements in array */ - JSPropertyDesc *array; /* alloc'd by Get, freed by Put */ -} JSPropertyDescArray; - -typedef struct JSScopeProperty JSScopeProperty; - -extern JS_PUBLIC_API(JSScopeProperty *) -JS_PropertyIterator(JSObject *obj, JSScopeProperty **iteratorp); - -extern JS_PUBLIC_API(JSBool) -JS_GetPropertyDesc(JSContext *cx, JSObject *obj, JSScopeProperty *shape, - JSPropertyDesc *pd); - -extern JS_PUBLIC_API(JSBool) -JS_GetPropertyDescArray(JSContext *cx, JSObject *obj, JSPropertyDescArray *pda); - -extern JS_PUBLIC_API(void) -JS_PutPropertyDescArray(JSContext *cx, JSPropertyDescArray *pda); - -/************************************************************************/ - -extern JS_PUBLIC_API(JSBool) -JS_SetDebuggerHandler(JSRuntime *rt, JSDebuggerHandler hook, void *closure); - -extern JS_PUBLIC_API(JSBool) -JS_SetSourceHandler(JSRuntime *rt, JSSourceHandler handler, void *closure); - -extern JS_PUBLIC_API(JSBool) -JS_SetExecuteHook(JSRuntime *rt, JSInterpreterHook hook, void *closure); - -extern JS_PUBLIC_API(JSBool) -JS_SetCallHook(JSRuntime *rt, JSInterpreterHook hook, void *closure); - -extern JS_PUBLIC_API(JSBool) -JS_SetThrowHook(JSRuntime *rt, JSThrowHook hook, void *closure); - -extern JS_PUBLIC_API(JSBool) -JS_SetDebugErrorHook(JSRuntime *rt, JSDebugErrorHook hook, void *closure); - -/************************************************************************/ - -extern JS_PUBLIC_API(size_t) -JS_GetObjectTotalSize(JSContext *cx, JSObject *obj); - -extern JS_PUBLIC_API(size_t) -JS_GetFunctionTotalSize(JSContext *cx, JSFunction *fun); - -extern JS_PUBLIC_API(size_t) -JS_GetScriptTotalSize(JSContext *cx, JSScript *script); - -/* - * Return true if obj is a "system" object, that is, one created by - * JS_NewSystemObject with the system flag set and not JS_NewObject. - * - * What "system" means is up to the API client. - */ -extern JS_PUBLIC_API(JSBool) -JS_IsSystemObject(JSContext *cx, JSObject *obj); - -/* - * Mark an object as being a system object. This should be called immediately - * after allocating the object. A system object is an object for which - * JS_IsSystemObject returns true. - */ -extern JS_PUBLIC_API(JSBool) -JS_MakeSystemObject(JSContext *cx, JSObject *obj); - -/************************************************************************/ - -extern JS_FRIEND_API(void) -js_RevertVersion(JSContext *cx); - -extern JS_PUBLIC_API(const JSDebugHooks *) -JS_GetGlobalDebugHooks(JSRuntime *rt); - -/** - * Start any profilers that are available and have been configured on for this - * platform. This is NOT thread safe. - * - * The profileName is used by some profilers to describe the current profiling - * run. It may be used for part of the filename of the output, but the - * specifics depend on the profiler. Many profilers will ignore it. Passing in - * NULL is legal; some profilers may use it to output to stdout or similar. - * - * Returns true if no profilers fail to start. - */ -extern JS_PUBLIC_API(JSBool) -JS_StartProfiling(const char *profileName); - -/** - * Stop any profilers that were previously started with JS_StartProfiling. - * Returns true if no profilers fail to stop. - */ -extern JS_PUBLIC_API(JSBool) -JS_StopProfiling(const char *profileName); - -/** - * Write the current profile data to the given file, if applicable to whatever - * profiler is being used. - */ -extern JS_PUBLIC_API(JSBool) -JS_DumpProfile(const char *outfile, const char *profileName); - -/** - * Pause currently active profilers (only supported by some profilers). Returns - * whether any profilers failed to pause. (Profilers that do not support - * pause/resume do not count.) - */ -extern JS_PUBLIC_API(JSBool) -JS_PauseProfilers(const char *profileName); - -/** - * Resume suspended profilers - */ -extern JS_PUBLIC_API(JSBool) -JS_ResumeProfilers(const char *profileName); - -/** - * Add various profiling-related functions as properties of the given object. - */ -extern JS_PUBLIC_API(JSBool) -JS_DefineProfilingFunctions(JSContext *cx, JSObject *obj); - -/* Defined in vm/Debugger.cpp. */ -extern JS_PUBLIC_API(JSBool) -JS_DefineDebuggerObject(JSContext *cx, JSObject *obj); - -/** - * The profiling API calls are not able to report errors, so they use a - * thread-unsafe global memory buffer to hold the last error encountered. This - * should only be called after something returns false. - */ -JS_PUBLIC_API(const char *) -JS_UnsafeGetLastProfilingError(); - -#ifdef MOZ_CALLGRIND - -extern JS_FRIEND_API(JSBool) -js_StopCallgrind(); - -extern JS_FRIEND_API(JSBool) -js_StartCallgrind(); - -extern JS_FRIEND_API(JSBool) -js_DumpCallgrind(const char *outfile); - -#endif /* MOZ_CALLGRIND */ - -#ifdef MOZ_VTUNE - -extern JS_FRIEND_API(bool) -js_StartVtune(const char *profileName); - -extern JS_FRIEND_API(bool) -js_StopVtune(); - -extern JS_FRIEND_API(bool) -js_PauseVtune(); - -extern JS_FRIEND_API(bool) -js_ResumeVtune(); - -#endif /* MOZ_VTUNE */ - -extern JS_PUBLIC_API(void) -JS_DumpBytecode(JSContext *cx, JSScript *script); - -extern JS_PUBLIC_API(void) -JS_DumpCompartmentBytecode(JSContext *cx); - -extern JS_PUBLIC_API(void) -JS_DumpPCCounts(JSContext *cx, JSScript *script); - -extern JS_PUBLIC_API(void) -JS_DumpCompartmentPCCounts(JSContext *cx); - -extern JS_PUBLIC_API(JSObject *) -JS_UnwrapObject(JSObject *obj); - -JS_END_EXTERN_C - -#endif /* jsdbgapi_h___ */ diff --git a/js/spidermonkey-win32/include/jsdhash.h b/js/spidermonkey-win32/include/jsdhash.h deleted file mode 100644 index ec11b83120..0000000000 --- a/js/spidermonkey-win32/include/jsdhash.h +++ /dev/null @@ -1,636 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla JavaScript code. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1999-2001 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Brendan Eich (Original Author) - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef jsdhash_h___ -#define jsdhash_h___ - -/* - * Double hashing, a la Knuth 6. - * - * Try to keep this file in sync with xpcom/glue/pldhash.h. - */ -#include "jstypes.h" -#include "jsutil.h" - -JS_BEGIN_EXTERN_C - -#if defined(__GNUC__) && defined(__i386__) && (__GNUC__ >= 3) && !defined(XP_OS2) -#define JS_DHASH_FASTCALL __attribute__ ((regparm (3),stdcall)) -#elif defined(XP_WIN) -#define JS_DHASH_FASTCALL __fastcall -#else -#define JS_DHASH_FASTCALL -#endif - -#ifdef DEBUG_XXXbrendan -#define JS_DHASHMETER 1 -#endif - -/* Table size limit, do not equal or exceed (see min&maxAlphaFrac, below). */ -#undef JS_DHASH_SIZE_LIMIT -#define JS_DHASH_SIZE_LIMIT JS_BIT(24) - -/* Minimum table size, or gross entry count (net is at most .75 loaded). */ -#ifndef JS_DHASH_MIN_SIZE -#define JS_DHASH_MIN_SIZE 16 -#elif (JS_DHASH_MIN_SIZE & (JS_DHASH_MIN_SIZE - 1)) != 0 -#error "JS_DHASH_MIN_SIZE must be a power of two!" -#endif - -/* - * Multiplicative hash uses an unsigned 32 bit integer and the golden ratio, - * expressed as a fixed-point 32-bit fraction. - */ -#define JS_DHASH_BITS 32 -#define JS_DHASH_GOLDEN_RATIO 0x9E3779B9U - -/* Primitive and forward-struct typedefs. */ -typedef uint32_t JSDHashNumber; -typedef struct JSDHashEntryHdr JSDHashEntryHdr; -typedef struct JSDHashEntryStub JSDHashEntryStub; -typedef struct JSDHashTable JSDHashTable; -typedef struct JSDHashTableOps JSDHashTableOps; - -/* - * Table entry header structure. - * - * In order to allow in-line allocation of key and value, we do not declare - * either here. Instead, the API uses const void *key as a formal parameter. - * The key need not be stored in the entry; it may be part of the value, but - * need not be stored at all. - * - * Callback types are defined below and grouped into the JSDHashTableOps - * structure, for single static initialization per hash table sub-type. - * - * Each hash table sub-type should nest the JSDHashEntryHdr structure at the - * front of its particular entry type. The keyHash member contains the result - * of multiplying the hash code returned from the hashKey callback (see below) - * by JS_DHASH_GOLDEN_RATIO, then constraining the result to avoid the magic 0 - * and 1 values. The stored keyHash value is table size invariant, and it is - * maintained automatically by JS_DHashTableOperate -- users should never set - * it, and its only uses should be via the entry macros below. - * - * The JS_DHASH_ENTRY_IS_LIVE macro tests whether entry is neither free nor - * removed. An entry may be either busy or free; if busy, it may be live or - * removed. Consumers of this API should not access members of entries that - * are not live. - * - * However, use JS_DHASH_ENTRY_IS_BUSY for faster liveness testing of entries - * returned by JS_DHashTableOperate, as JS_DHashTableOperate never returns a - * non-live, busy (i.e., removed) entry pointer to its caller. See below for - * more details on JS_DHashTableOperate's calling rules. - */ -struct JSDHashEntryHdr { - JSDHashNumber keyHash; /* every entry must begin like this */ -}; - -#define JS_DHASH_ENTRY_IS_FREE(entry) ((entry)->keyHash == 0) -#define JS_DHASH_ENTRY_IS_BUSY(entry) (!JS_DHASH_ENTRY_IS_FREE(entry)) -#define JS_DHASH_ENTRY_IS_LIVE(entry) ((entry)->keyHash >= 2) - -/* - * A JSDHashTable is currently 8 words (without the JS_DHASHMETER overhead) - * on most architectures, and may be allocated on the stack or within another - * structure or class (see below for the Init and Finish functions to use). - * - * To decide whether to use double hashing vs. chaining, we need to develop a - * trade-off relation, as follows: - * - * Let alpha be the load factor, esize the entry size in words, count the - * entry count, and pow2 the power-of-two table size in entries. - * - * (JSDHashTable overhead) > (JSHashTable overhead) - * (unused table entry space) > (malloc and .next overhead per entry) + - * (buckets overhead) - * (1 - alpha) * esize * pow2 > 2 * count + pow2 - * - * Notice that alpha is by definition (count / pow2): - * - * (1 - alpha) * esize * pow2 > 2 * alpha * pow2 + pow2 - * (1 - alpha) * esize > 2 * alpha + 1 - * - * esize > (1 + 2 * alpha) / (1 - alpha) - * - * This assumes both tables must keep keyHash, key, and value for each entry, - * where key and value point to separately allocated strings or structures. - * If key and value can be combined into one pointer, then the trade-off is: - * - * esize > (1 + 3 * alpha) / (1 - alpha) - * - * If the entry value can be a subtype of JSDHashEntryHdr, rather than a type - * that must be allocated separately and referenced by an entry.value pointer - * member, and provided key's allocation can be fused with its entry's, then - * k (the words wasted per entry with chaining) is 4. - * - * To see these curves, feed gnuplot input like so: - * - * gnuplot> f(x,k) = (1 + k * x) / (1 - x) - * gnuplot> plot [0:.75] f(x,2), f(x,3), f(x,4) - * - * For k of 2 and a well-loaded table (alpha > .5), esize must be more than 4 - * words for chaining to be more space-efficient than double hashing. - * - * Solving for alpha helps us decide when to shrink an underloaded table: - * - * esize > (1 + k * alpha) / (1 - alpha) - * esize - alpha * esize > 1 + k * alpha - * esize - 1 > (k + esize) * alpha - * (esize - 1) / (k + esize) > alpha - * - * alpha < (esize - 1) / (esize + k) - * - * Therefore double hashing should keep alpha >= (esize - 1) / (esize + k), - * assuming esize is not too large (in which case, chaining should probably be - * used for any alpha). For esize=2 and k=3, we want alpha >= .2; for esize=3 - * and k=2, we want alpha >= .4. For k=4, esize could be 6, and alpha >= .5 - * would still obtain. See the JS_DHASH_MIN_ALPHA macro further below. - * - * The current implementation uses a configurable lower bound on alpha, which - * defaults to .25, when deciding to shrink the table (while still respecting - * JS_DHASH_MIN_SIZE). - * - * Note a qualitative difference between chaining and double hashing: under - * chaining, entry addresses are stable across table shrinks and grows. With - * double hashing, you can't safely hold an entry pointer and use it after an - * ADD or REMOVE operation, unless you sample table->generation before adding - * or removing, and compare the sample after, dereferencing the entry pointer - * only if table->generation has not changed. - * - * The moral of this story: there is no one-size-fits-all hash table scheme, - * but for small table entry size, and assuming entry address stability is not - * required, double hashing wins. - */ -struct JSDHashTable { - const JSDHashTableOps *ops; /* virtual operations, see below */ - void *data; /* ops- and instance-specific data */ - int16_t hashShift; /* multiplicative hash shift */ - uint8_t maxAlphaFrac; /* 8-bit fixed point max alpha */ - uint8_t minAlphaFrac; /* 8-bit fixed point min alpha */ - uint32_t entrySize; /* number of bytes in an entry */ - uint32_t entryCount; /* number of entries in table */ - uint32_t removedCount; /* removed entry sentinels in table */ - uint32_t generation; /* entry storage generation number */ - char *entryStore; /* entry storage */ -#ifdef JS_DHASHMETER - struct JSDHashStats { - uint32_t searches; /* total number of table searches */ - uint32_t steps; /* hash chain links traversed */ - uint32_t hits; /* searches that found key */ - uint32_t misses; /* searches that didn't find key */ - uint32_t lookups; /* number of JS_DHASH_LOOKUPs */ - uint32_t addMisses; /* adds that miss, and do work */ - uint32_t addOverRemoved; /* adds that recycled a removed entry */ - uint32_t addHits; /* adds that hit an existing entry */ - uint32_t addFailures; /* out-of-memory during add growth */ - uint32_t removeHits; /* removes that hit, and do work */ - uint32_t removeMisses; /* useless removes that miss */ - uint32_t removeFrees; /* removes that freed entry directly */ - uint32_t removeEnums; /* removes done by Enumerate */ - uint32_t grows; /* table expansions */ - uint32_t shrinks; /* table contractions */ - uint32_t compresses; /* table compressions */ - uint32_t enumShrinks; /* contractions after Enumerate */ - } stats; -#endif -}; - -/* - * Size in entries (gross, not net of free and removed sentinels) for table. - * We store hashShift rather than sizeLog2 to optimize the collision-free case - * in SearchTable. - */ -#define JS_DHASH_TABLE_SIZE(table) JS_BIT(JS_DHASH_BITS - (table)->hashShift) - -/* - * Table space at entryStore is allocated and freed using these callbacks. - * The allocator should return null on error only (not if called with nbytes - * equal to 0; but note that jsdhash.c code will never call with 0 nbytes). - */ -typedef void * -(* JSDHashAllocTable)(JSDHashTable *table, uint32_t nbytes); - -typedef void -(* JSDHashFreeTable) (JSDHashTable *table, void *ptr); - -/* - * Compute the hash code for a given key to be looked up, added, or removed - * from table. A hash code may have any JSDHashNumber value. - */ -typedef JSDHashNumber -(* JSDHashHashKey) (JSDHashTable *table, const void *key); - -/* - * Compare the key identifying entry in table with the provided key parameter. - * Return JS_TRUE if keys match, JS_FALSE otherwise. - */ -typedef JSBool -(* JSDHashMatchEntry)(JSDHashTable *table, const JSDHashEntryHdr *entry, - const void *key); - -/* - * Copy the data starting at from to the new entry storage at to. Do not add - * reference counts for any strong references in the entry, however, as this - * is a "move" operation: the old entry storage at from will be freed without - * any reference-decrementing callback shortly. - */ -typedef void -(* JSDHashMoveEntry)(JSDHashTable *table, const JSDHashEntryHdr *from, - JSDHashEntryHdr *to); - -/* - * Clear the entry and drop any strong references it holds. This callback is - * invoked during a JS_DHASH_REMOVE operation (see below for operation codes), - * but only if the given key is found in the table. - */ -typedef void -(* JSDHashClearEntry)(JSDHashTable *table, JSDHashEntryHdr *entry); - -/* - * Called when a table (whether allocated dynamically by itself, or nested in - * a larger structure, or allocated on the stack) is finished. This callback - * allows table->ops-specific code to finalize table->data. - */ -typedef void -(* JSDHashFinalize) (JSDHashTable *table); - -/* - * Initialize a new entry, apart from keyHash. This function is called when - * JS_DHashTableOperate's JS_DHASH_ADD case finds no existing entry for the - * given key, and must add a new one. At that point, entry->keyHash is not - * set yet, to avoid claiming the last free entry in a severely overloaded - * table. - */ -typedef JSBool -(* JSDHashInitEntry)(JSDHashTable *table, JSDHashEntryHdr *entry, - const void *key); - -/* - * Finally, the "vtable" structure for JSDHashTable. The first eight hooks - * must be provided by implementations; they're called unconditionally by the - * generic jsdhash.c code. Hooks after these may be null. - * - * Summary of allocation-related hook usage with C++ placement new emphasis: - * allocTable Allocate raw bytes with malloc, no ctors run. - * freeTable Free raw bytes with free, no dtors run. - * initEntry Call placement new using default key-based ctor. - * Return JS_TRUE on success, JS_FALSE on error. - * moveEntry Call placement new using copy ctor, run dtor on old - * entry storage. - * clearEntry Run dtor on entry. - * finalize Stub unless table->data was initialized and needs to - * be finalized. - * - * Note the reason why initEntry is optional: the default hooks (stubs) clear - * entry storage: On successful JS_DHashTableOperate(tbl, key, JS_DHASH_ADD), - * the returned entry pointer addresses an entry struct whose keyHash member - * has been set non-zero, but all other entry members are still clear (null). - * JS_DHASH_ADD callers can test such members to see whether the entry was - * newly created by the JS_DHASH_ADD call that just succeeded. If placement - * new or similar initialization is required, define an initEntry hook. Of - * course, the clearEntry hook must zero or null appropriately. - * - * XXX assumes 0 is null for pointer types. - */ -struct JSDHashTableOps { - /* Mandatory hooks. All implementations must provide these. */ - JSDHashAllocTable allocTable; - JSDHashFreeTable freeTable; - JSDHashHashKey hashKey; - JSDHashMatchEntry matchEntry; - JSDHashMoveEntry moveEntry; - JSDHashClearEntry clearEntry; - JSDHashFinalize finalize; - - /* Optional hooks start here. If null, these are not called. */ - JSDHashInitEntry initEntry; -}; - -/* - * Default implementations for the above ops. - */ -extern JS_PUBLIC_API(void *) -JS_DHashAllocTable(JSDHashTable *table, uint32_t nbytes); - -extern JS_PUBLIC_API(void) -JS_DHashFreeTable(JSDHashTable *table, void *ptr); - -extern JS_PUBLIC_API(JSDHashNumber) -JS_DHashStringKey(JSDHashTable *table, const void *key); - -/* A minimal entry contains a keyHash header and a void key pointer. */ -struct JSDHashEntryStub { - JSDHashEntryHdr hdr; - const void *key; -}; - -extern JS_PUBLIC_API(JSDHashNumber) -JS_DHashVoidPtrKeyStub(JSDHashTable *table, const void *key); - -extern JS_PUBLIC_API(JSBool) -JS_DHashMatchEntryStub(JSDHashTable *table, - const JSDHashEntryHdr *entry, - const void *key); - -extern JS_PUBLIC_API(JSBool) -JS_DHashMatchStringKey(JSDHashTable *table, - const JSDHashEntryHdr *entry, - const void *key); - -extern JS_PUBLIC_API(void) -JS_DHashMoveEntryStub(JSDHashTable *table, - const JSDHashEntryHdr *from, - JSDHashEntryHdr *to); - -extern JS_PUBLIC_API(void) -JS_DHashClearEntryStub(JSDHashTable *table, JSDHashEntryHdr *entry); - -extern JS_PUBLIC_API(void) -JS_DHashFreeStringKey(JSDHashTable *table, JSDHashEntryHdr *entry); - -extern JS_PUBLIC_API(void) -JS_DHashFinalizeStub(JSDHashTable *table); - -/* - * If you use JSDHashEntryStub or a subclass of it as your entry struct, and - * if your entries move via memcpy and clear via memset(0), you can use these - * stub operations. - */ -extern JS_PUBLIC_API(const JSDHashTableOps *) -JS_DHashGetStubOps(void); - -/* - * Dynamically allocate a new JSDHashTable using malloc, initialize it using - * JS_DHashTableInit, and return its address. Return null on malloc failure. - * Note that the entry storage at table->entryStore will be allocated using - * the ops->allocTable callback. - */ -extern JS_PUBLIC_API(JSDHashTable *) -JS_NewDHashTable(const JSDHashTableOps *ops, void *data, uint32_t entrySize, - uint32_t capacity); - -/* - * Finalize table's data, free its entry storage (via table->ops->freeTable), - * and return the memory starting at table to the malloc heap. - */ -extern JS_PUBLIC_API(void) -JS_DHashTableDestroy(JSDHashTable *table); - -/* - * Initialize table with ops, data, entrySize, and capacity. Capacity is a - * guess for the smallest table size at which the table will usually be less - * than 75% loaded (the table will grow or shrink as needed; capacity serves - * only to avoid inevitable early growth from JS_DHASH_MIN_SIZE). - */ -extern JS_PUBLIC_API(JSBool) -JS_DHashTableInit(JSDHashTable *table, const JSDHashTableOps *ops, void *data, - uint32_t entrySize, uint32_t capacity); - -/* - * Set maximum and minimum alpha for table. The defaults are 0.75 and .25. - * maxAlpha must be in [0.5, 0.9375] for the default JS_DHASH_MIN_SIZE; or if - * MinSize=JS_DHASH_MIN_SIZE <= 256, in [0.5, (float)(MinSize-1)/MinSize]; or - * else in [0.5, 255.0/256]. minAlpha must be in [0, maxAlpha / 2), so that - * we don't shrink on the very next remove after growing a table upon adding - * an entry that brings entryCount past maxAlpha * tableSize. - */ -extern JS_PUBLIC_API(void) -JS_DHashTableSetAlphaBounds(JSDHashTable *table, - float maxAlpha, - float minAlpha); - -/* - * Call this macro with k, the number of pointer-sized words wasted per entry - * under chaining, to compute the minimum alpha at which double hashing still - * beats chaining. - */ -#define JS_DHASH_MIN_ALPHA(table, k) \ - ((float)((table)->entrySize / sizeof(void *) - 1) \ - / ((table)->entrySize / sizeof(void *) + (k))) - -/* - * Default max/min alpha, and macros to compute the value for the |capacity| - * parameter to JS_NewDHashTable and JS_DHashTableInit, given default or any - * max alpha, such that adding entryCount entries right after initializing the - * table will not require a reallocation (so JS_DHASH_ADD can't fail for those - * JS_DHashTableOperate calls). - * - * NB: JS_DHASH_CAP is a helper macro meant for use only in JS_DHASH_CAPACITY. - * Don't use it directly! - */ -#define JS_DHASH_DEFAULT_MAX_ALPHA 0.75 -#define JS_DHASH_DEFAULT_MIN_ALPHA 0.25 - -#define JS_DHASH_CAP(entryCount, maxAlpha) \ - ((uint32_t)((double)(entryCount) / (maxAlpha))) - -#define JS_DHASH_CAPACITY(entryCount, maxAlpha) \ - (JS_DHASH_CAP(entryCount, maxAlpha) + \ - (((JS_DHASH_CAP(entryCount, maxAlpha) * (uint8_t)(0x100 * (maxAlpha))) \ - >> 8) < (entryCount))) - -#define JS_DHASH_DEFAULT_CAPACITY(entryCount) \ - JS_DHASH_CAPACITY(entryCount, JS_DHASH_DEFAULT_MAX_ALPHA) - -/* - * Finalize table's data, free its entry storage using table->ops->freeTable, - * and leave its members unchanged from their last live values (which leaves - * pointers dangling). If you want to burn cycles clearing table, it's up to - * your code to call memset. - */ -extern JS_PUBLIC_API(void) -JS_DHashTableFinish(JSDHashTable *table); - -/* - * To consolidate keyHash computation and table grow/shrink code, we use a - * single entry point for lookup, add, and remove operations. The operation - * codes are declared here, along with codes returned by JSDHashEnumerator - * functions, which control JS_DHashTableEnumerate's behavior. - */ -typedef enum JSDHashOperator { - JS_DHASH_LOOKUP = 0, /* lookup entry */ - JS_DHASH_ADD = 1, /* add entry */ - JS_DHASH_REMOVE = 2, /* remove entry, or enumerator says remove */ - JS_DHASH_NEXT = 0, /* enumerator says continue */ - JS_DHASH_STOP = 1 /* enumerator says stop */ -} JSDHashOperator; - -/* - * To lookup a key in table, call: - * - * entry = JS_DHashTableOperate(table, key, JS_DHASH_LOOKUP); - * - * If JS_DHASH_ENTRY_IS_BUSY(entry) is true, key was found and it identifies - * entry. If JS_DHASH_ENTRY_IS_FREE(entry) is true, key was not found. - * - * To add an entry identified by key to table, call: - * - * entry = JS_DHashTableOperate(table, key, JS_DHASH_ADD); - * - * If entry is null upon return, then either the table is severely overloaded, - * and memory can't be allocated for entry storage via table->ops->allocTable; - * Or if table->ops->initEntry is non-null, the table->ops->initEntry op may - * have returned false. - * - * Otherwise, entry->keyHash has been set so that JS_DHASH_ENTRY_IS_BUSY(entry) - * is true, and it is up to the caller to initialize the key and value parts - * of the entry sub-type, if they have not been set already (i.e. if entry was - * not already in the table, and if the optional initEntry hook was not used). - * - * To remove an entry identified by key from table, call: - * - * (void) JS_DHashTableOperate(table, key, JS_DHASH_REMOVE); - * - * If key's entry is found, it is cleared (via table->ops->clearEntry) and - * the entry is marked so that JS_DHASH_ENTRY_IS_FREE(entry). This operation - * returns null unconditionally; you should ignore its return value. - */ -extern JS_PUBLIC_API(JSDHashEntryHdr *) JS_DHASH_FASTCALL -JS_DHashTableOperate(JSDHashTable *table, const void *key, JSDHashOperator op); - -/* - * Remove an entry already accessed via LOOKUP or ADD. - * - * NB: this is a "raw" or low-level routine, intended to be used only where - * the inefficiency of a full JS_DHashTableOperate (which rehashes in order - * to find the entry given its key) is not tolerable. This function does not - * shrink the table if it is underloaded. It does not update stats #ifdef - * JS_DHASHMETER, either. - */ -extern JS_PUBLIC_API(void) -JS_DHashTableRawRemove(JSDHashTable *table, JSDHashEntryHdr *entry); - -/* - * Enumerate entries in table using etor: - * - * count = JS_DHashTableEnumerate(table, etor, arg); - * - * JS_DHashTableEnumerate calls etor like so: - * - * op = etor(table, entry, number, arg); - * - * where number is a zero-based ordinal assigned to live entries according to - * their order in table->entryStore. - * - * The return value, op, is treated as a set of flags. If op is JS_DHASH_NEXT, - * then continue enumerating. If op contains JS_DHASH_REMOVE, then clear (via - * table->ops->clearEntry) and free entry. Then we check whether op contains - * JS_DHASH_STOP; if so, stop enumerating and return the number of live entries - * that were enumerated so far. Return the total number of live entries when - * enumeration completes normally. - * - * If etor calls JS_DHashTableOperate on table with op != JS_DHASH_LOOKUP, it - * must return JS_DHASH_STOP; otherwise undefined behavior results. - * - * If any enumerator returns JS_DHASH_REMOVE, table->entryStore may be shrunk - * or compressed after enumeration, but before JS_DHashTableEnumerate returns. - * Such an enumerator therefore can't safely set aside entry pointers, but an - * enumerator that never returns JS_DHASH_REMOVE can set pointers to entries - * aside, e.g., to avoid copying live entries into an array of the entry type. - * Copying entry pointers is cheaper, and safe so long as the caller of such a - * "stable" Enumerate doesn't use the set-aside pointers after any call either - * to PL_DHashTableOperate, or to an "unstable" form of Enumerate, which might - * grow or shrink entryStore. - * - * If your enumerator wants to remove certain entries, but set aside pointers - * to other entries that it retains, it can use JS_DHashTableRawRemove on the - * entries to be removed, returning JS_DHASH_NEXT to skip them. Likewise, if - * you want to remove entries, but for some reason you do not want entryStore - * to be shrunk or compressed, you can call JS_DHashTableRawRemove safely on - * the entry being enumerated, rather than returning JS_DHASH_REMOVE. - */ -typedef JSDHashOperator -(* JSDHashEnumerator)(JSDHashTable *table, JSDHashEntryHdr *hdr, uint32_t number, void *arg); - -extern JS_PUBLIC_API(uint32_t) -JS_DHashTableEnumerate(JSDHashTable *table, JSDHashEnumerator etor, void *arg); - -typedef size_t -(* JSDHashSizeOfEntryExcludingThisFun)(JSDHashEntryHdr *hdr, - JSMallocSizeOfFun mallocSizeOf, - void *arg); - -/** - * Measure the size of the table's entry storage, and if - * |sizeOfEntryExcludingThis| is non-NULL, measure the size of things pointed - * to by entries. Doesn't measure |ops| because it's often shared between - * tables, nor |data| because it's opaque. - */ -extern JS_PUBLIC_API(size_t) -JS_DHashTableSizeOfExcludingThis(const JSDHashTable *table, - JSDHashSizeOfEntryExcludingThisFun sizeOfEntryExcludingThis, - JSMallocSizeOfFun mallocSizeOf, - void *arg = NULL); - -/** - * Like JS_DHashTableSizeOfExcludingThis, but includes sizeof(*this). - */ -extern JS_PUBLIC_API(size_t) -JS_DHashTableSizeOfIncludingThis(const JSDHashTable *table, - JSDHashSizeOfEntryExcludingThisFun sizeOfEntryExcludingThis, - JSMallocSizeOfFun mallocSizeOf, - void *arg = NULL); - -#ifdef DEBUG -/** - * Mark a table as immutable for the remainder of its lifetime. This - * changes the implementation from ASSERTing one set of invariants to - * ASSERTing a different set. - * - * When a table is NOT marked as immutable, the table implementation - * asserts that the table is not mutated from its own callbacks. It - * assumes the caller protects the table from being accessed on multiple - * threads simultaneously. - * - * When the table is marked as immutable, the re-entry assertions will - * no longer trigger erroneously due to multi-threaded access. Instead, - * mutations will cause assertions. - */ -extern JS_PUBLIC_API(void) -JS_DHashMarkTableImmutable(JSDHashTable *table); -#endif - -#ifdef JS_DHASHMETER -#include - -extern JS_PUBLIC_API(void) -JS_DHashTableDumpMeter(JSDHashTable *table, JSDHashEnumerator dump, FILE *fp); -#endif - -JS_END_EXTERN_C - -#endif /* jsdhash_h___ */ diff --git a/js/spidermonkey-win32/include/jsfriendapi.h b/js/spidermonkey-win32/include/jsfriendapi.h deleted file mode 100644 index b4d2f04182..0000000000 --- a/js/spidermonkey-win32/include/jsfriendapi.h +++ /dev/null @@ -1,826 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * - * The Original Code is SpiderMonkey code. - * - * The Initial Developer of the Original Code is - * Mozilla Corporation. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef jsfriendapi_h___ -#define jsfriendapi_h___ - -#include "jsclass.h" -#include "jspubtd.h" -#include "jsprvtd.h" - -#include "mozilla/GuardObjects.h" - -JS_BEGIN_EXTERN_C - -extern JS_FRIEND_API(void) -JS_SetGrayGCRootsTracer(JSRuntime *rt, JSTraceDataOp traceOp, void *data); - -extern JS_FRIEND_API(JSString *) -JS_GetAnonymousString(JSRuntime *rt); - -extern JS_FRIEND_API(JSObject *) -JS_FindCompilationScope(JSContext *cx, JSObject *obj); - -extern JS_FRIEND_API(JSFunction *) -JS_GetObjectFunction(JSObject *obj); - -extern JS_FRIEND_API(JSObject *) -JS_GetGlobalForFrame(JSStackFrame *fp); - -extern JS_FRIEND_API(JSBool) -JS_SplicePrototype(JSContext *cx, JSObject *obj, JSObject *proto); - -extern JS_FRIEND_API(JSObject *) -JS_NewObjectWithUniqueType(JSContext *cx, JSClass *clasp, JSObject *proto, JSObject *parent); - -extern JS_FRIEND_API(uint32_t) -JS_ObjectCountDynamicSlots(JSObject *obj); - -extern JS_FRIEND_API(void) -JS_ShrinkGCBuffers(JSRuntime *rt); - -extern JS_FRIEND_API(size_t) -JS_GetE4XObjectsCreated(JSContext *cx); - -extern JS_FRIEND_API(size_t) -JS_SetProtoCalled(JSContext *cx); - -extern JS_FRIEND_API(size_t) -JS_GetCustomIteratorCount(JSContext *cx); - -extern JS_FRIEND_API(JSBool) -JS_NondeterministicGetWeakMapKeys(JSContext *cx, JSObject *obj, JSObject **ret); - -/* - * Used by the cycle collector to trace through the shape and all - * shapes it reaches, marking all non-shape children found in the - * process. Uses bounded stack space. - */ -extern JS_FRIEND_API(void) -JS_TraceShapeCycleCollectorChildren(JSTracer *trc, void *shape); - -enum { - JS_TELEMETRY_GC_REASON, - JS_TELEMETRY_GC_IS_COMPARTMENTAL, - JS_TELEMETRY_GC_MS, - JS_TELEMETRY_GC_MARK_MS, - JS_TELEMETRY_GC_SWEEP_MS, - JS_TELEMETRY_GC_SLICE_MS, - JS_TELEMETRY_GC_MMU_50, - JS_TELEMETRY_GC_RESET, - JS_TELEMETRY_GC_INCREMENTAL_DISABLED, - JS_TELEMETRY_GC_NON_INCREMENTAL -}; - -typedef void -(* JSAccumulateTelemetryDataCallback)(int id, uint32_t sample); - -extern JS_FRIEND_API(void) -JS_SetAccumulateTelemetryCallback(JSRuntime *rt, JSAccumulateTelemetryDataCallback callback); - -extern JS_FRIEND_API(JSPrincipals *) -JS_GetCompartmentPrincipals(JSCompartment *compartment); - -/* Safe to call with input obj == NULL. Returns non-NULL iff obj != NULL. */ -extern JS_FRIEND_API(JSObject *) -JS_ObjectToInnerObject(JSContext *cx, JSObject *obj); - -/* Requires obj != NULL. */ -extern JS_FRIEND_API(JSObject *) -JS_ObjectToOuterObject(JSContext *cx, JSObject *obj); - -extern JS_FRIEND_API(JSObject *) -JS_CloneObject(JSContext *cx, JSObject *obj, JSObject *proto, JSObject *parent); - -extern JS_FRIEND_API(JSBool) -js_GetterOnlyPropertyStub(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp); - -JS_FRIEND_API(void) -js_ReportOverRecursed(JSContext *maybecx); - -#ifdef DEBUG - -/* - * Routines to print out values during debugging. These are FRIEND_API to help - * the debugger find them and to support temporarily hacking js_Dump* calls - * into other code. - */ - -extern JS_FRIEND_API(void) -js_DumpString(JSString *str); - -extern JS_FRIEND_API(void) -js_DumpAtom(JSAtom *atom); - -extern JS_FRIEND_API(void) -js_DumpObject(JSObject *obj); - -extern JS_FRIEND_API(void) -js_DumpChars(const jschar *s, size_t n); -#endif - -#ifdef __cplusplus - -extern JS_FRIEND_API(bool) -JS_CopyPropertiesFrom(JSContext *cx, JSObject *target, JSObject *obj); - -extern JS_FRIEND_API(JSBool) -JS_WrapPropertyDescriptor(JSContext *cx, js::PropertyDescriptor *desc); - -extern JS_FRIEND_API(JSBool) -JS_EnumerateState(JSContext *cx, JSObject *obj, JSIterateOp enum_op, js::Value *statep, jsid *idp); - -struct JSFunctionSpecWithHelp { - const char *name; - JSNative call; - uint16_t nargs; - uint16_t flags; - const char *usage; - const char *help; -}; - -#define JS_FN_HELP(name,call,nargs,flags,usage,help) \ - {name, call, nargs, (flags) | JSPROP_ENUMERATE | JSFUN_STUB_GSOPS, usage, help} - -extern JS_FRIEND_API(bool) -JS_DefineFunctionsWithHelp(JSContext *cx, JSObject *obj, const JSFunctionSpecWithHelp *fs); - -#endif - -JS_END_EXTERN_C - -#ifdef __cplusplus - -namespace js { - -struct ContextFriendFields { - JSRuntime *const runtime; - - ContextFriendFields(JSRuntime *rt) - : runtime(rt) { } - - static const ContextFriendFields *get(const JSContext *cx) { - return reinterpret_cast(cx); - } -}; - -struct RuntimeFriendFields { - /* - * If non-zero, we were been asked to call the operation callback as soon - * as possible. - */ - volatile int32_t interrupt; - - /* Limit pointer for checking native stack consumption. */ - uintptr_t nativeStackLimit; - - RuntimeFriendFields() - : interrupt(0), - nativeStackLimit(0) { } - - static const RuntimeFriendFields *get(const JSRuntime *rt) { - return reinterpret_cast(rt); - } -}; - -inline JSRuntime * -GetRuntime(const JSContext *cx) -{ - return ContextFriendFields::get(cx)->runtime; -} - -typedef bool -(* PreserveWrapperCallback)(JSContext *cx, JSObject *obj); - -#ifdef DEBUG - /* - * DEBUG-only method to dump the complete object graph of heap-allocated things. - * fp is the file for the dump output. - */ -extern JS_FRIEND_API(void) -DumpHeapComplete(JSRuntime *rt, FILE *fp); - -#endif - -class JS_FRIEND_API(AutoPreserveCompartment) { - private: - JSContext *cx; - JSCompartment *oldCompartment; - public: - AutoPreserveCompartment(JSContext *cx JS_GUARD_OBJECT_NOTIFIER_PARAM); - ~AutoPreserveCompartment(); - JS_DECL_USE_GUARD_OBJECT_NOTIFIER -}; - -class JS_FRIEND_API(AutoSwitchCompartment) { - private: - JSContext *cx; - JSCompartment *oldCompartment; - public: - AutoSwitchCompartment(JSContext *cx, JSCompartment *newCompartment - JS_GUARD_OBJECT_NOTIFIER_PARAM); - AutoSwitchCompartment(JSContext *cx, JSObject *target JS_GUARD_OBJECT_NOTIFIER_PARAM); - ~AutoSwitchCompartment(); - JS_DECL_USE_GUARD_OBJECT_NOTIFIER -}; - -#ifdef OLD_GETTER_SETTER_METHODS -JS_FRIEND_API(JSBool) obj_defineGetter(JSContext *cx, unsigned argc, js::Value *vp); -JS_FRIEND_API(JSBool) obj_defineSetter(JSContext *cx, unsigned argc, js::Value *vp); -#endif - -extern JS_FRIEND_API(bool) -IsSystemCompartment(const JSCompartment *compartment); - -extern JS_FRIEND_API(bool) -IsAtomsCompartment(const JSCompartment *c); - -/* - * Check whether it is OK to assign an undeclared property with name - * propname of the global object in the current script on cx. Reports - * an error if one needs to be reported (in particular in all cases - * when it returns false). - */ -extern JS_FRIEND_API(bool) -CheckUndeclaredVarAssignment(JSContext *cx, JSString *propname); - -struct WeakMapTracer; - -/* - * Weak map tracer callback, called once for every binding of every - * weak map that was live at the time of the last garbage collection. - * - * m will be NULL if the weak map is not contained in a JS Object. - */ -typedef void -(* WeakMapTraceCallback)(WeakMapTracer *trc, JSObject *m, - void *k, JSGCTraceKind kkind, - void *v, JSGCTraceKind vkind); - -struct WeakMapTracer { - JSRuntime *runtime; - WeakMapTraceCallback callback; - - WeakMapTracer(JSRuntime *rt, WeakMapTraceCallback cb) - : runtime(rt), callback(cb) {} -}; - -extern JS_FRIEND_API(void) -TraceWeakMaps(WeakMapTracer *trc); - -extern JS_FRIEND_API(bool) -GCThingIsMarkedGray(void *thing); - - -/* - * Shadow declarations of JS internal structures, for access by inline access - * functions below. Do not use these structures in any other way. When adding - * new fields for access by inline methods, make sure to add static asserts to - * the original header file to ensure that offsets are consistent. - */ -namespace shadow { - -struct TypeObject { - JSObject *proto; -}; - -struct BaseShape { - js::Class *clasp; - JSObject *parent; -}; - -struct Shape { - BaseShape *base; - jsid _1; - uint32_t slotInfo; - - static const uint32_t FIXED_SLOTS_SHIFT = 27; -}; - -struct Object { - Shape *shape; - TypeObject *type; - js::Value *slots; - js::Value *_1; - - size_t numFixedSlots() const { return shape->slotInfo >> Shape::FIXED_SLOTS_SHIFT; } - Value *fixedSlots() const { - return (Value *)(uintptr_t(this) + sizeof(shadow::Object)); - } - - js::Value &slotRef(size_t slot) const { - size_t nfixed = numFixedSlots(); - if (slot < nfixed) - return fixedSlots()[slot]; - return slots[slot - nfixed]; - } -}; - -struct Atom { - size_t _; - const jschar *chars; -}; - -} /* namespace shadow */ - -extern JS_FRIEND_DATA(js::Class) AnyNameClass; -extern JS_FRIEND_DATA(js::Class) AttributeNameClass; -extern JS_FRIEND_DATA(js::Class) CallClass; -extern JS_FRIEND_DATA(js::Class) DeclEnvClass; -extern JS_FRIEND_DATA(js::Class) FunctionClass; -extern JS_FRIEND_DATA(js::Class) FunctionProxyClass; -extern JS_FRIEND_DATA(js::Class) NamespaceClass; -extern JS_FRIEND_DATA(js::Class) OuterWindowProxyClass; -extern JS_FRIEND_DATA(js::Class) ObjectProxyClass; -extern JS_FRIEND_DATA(js::Class) QNameClass; -extern JS_FRIEND_DATA(js::Class) XMLClass; -extern JS_FRIEND_DATA(js::Class) ObjectClass; - -inline js::Class * -GetObjectClass(const JSObject *obj) -{ - return reinterpret_cast(obj)->shape->base->clasp; -} - -inline JSClass * -GetObjectJSClass(const JSObject *obj) -{ - return js::Jsvalify(GetObjectClass(obj)); -} - -JS_FRIEND_API(bool) -IsScopeObject(JSObject *obj); - -inline JSObject * -GetObjectParent(JSObject *obj) -{ - JS_ASSERT(!IsScopeObject(obj)); - return reinterpret_cast(obj)->shape->base->parent; -} - -JS_FRIEND_API(JSObject *) -GetObjectParentMaybeScope(JSObject *obj); - -JS_FRIEND_API(JSObject *) -GetGlobalForObjectCrossCompartment(JSObject *obj); - -JS_FRIEND_API(bool) -IsOriginalScriptFunction(JSFunction *fun); - -JS_FRIEND_API(JSFunction *) -DefineFunctionWithReserved(JSContext *cx, JSObject *obj, const char *name, JSNative call, - unsigned nargs, unsigned attrs); - -JS_FRIEND_API(JSFunction *) -NewFunctionWithReserved(JSContext *cx, JSNative call, unsigned nargs, unsigned flags, - JSObject *parent, const char *name); - -JS_FRIEND_API(JSFunction *) -NewFunctionByIdWithReserved(JSContext *cx, JSNative native, unsigned nargs, unsigned flags, - JSObject *parent, jsid id); - -JS_FRIEND_API(JSObject *) -InitClassWithReserved(JSContext *cx, JSObject *obj, JSObject *parent_proto, - JSClass *clasp, JSNative constructor, unsigned nargs, - JSPropertySpec *ps, JSFunctionSpec *fs, - JSPropertySpec *static_ps, JSFunctionSpec *static_fs); - -JS_FRIEND_API(const Value &) -GetFunctionNativeReserved(JSObject *fun, size_t which); - -JS_FRIEND_API(void) -SetFunctionNativeReserved(JSObject *fun, size_t which, const Value &val); - -inline JSObject * -GetObjectProto(JSObject *obj) -{ - return reinterpret_cast(obj)->type->proto; -} - -inline void * -GetObjectPrivate(JSObject *obj) -{ - const shadow::Object *nobj = reinterpret_cast(obj); - void **addr = reinterpret_cast(&nobj->fixedSlots()[nobj->numFixedSlots()]); - return *addr; -} - -/* - * Get a slot that is both reserved for object's clasp *and* is fixed (fits - * within the maximum capacity for the object's fixed slots). - */ -inline const Value & -GetReservedSlot(const JSObject *obj, size_t slot) -{ - JS_ASSERT(slot < JSCLASS_RESERVED_SLOTS(GetObjectClass(obj))); - return reinterpret_cast(obj)->slotRef(slot); -} - -JS_FRIEND_API(void) -SetReservedSlotWithBarrier(JSObject *obj, size_t slot, const Value &value); - -inline void -SetReservedSlot(JSObject *obj, size_t slot, const Value &value) -{ - JS_ASSERT(slot < JSCLASS_RESERVED_SLOTS(GetObjectClass(obj))); - shadow::Object *sobj = reinterpret_cast(obj); - if (sobj->slotRef(slot).isMarkable()) - SetReservedSlotWithBarrier(obj, slot, value); - else - sobj->slotRef(slot) = value; -} - -JS_FRIEND_API(uint32_t) -GetObjectSlotSpan(JSObject *obj); - -inline const Value & -GetObjectSlot(JSObject *obj, size_t slot) -{ - JS_ASSERT(slot < GetObjectSlotSpan(obj)); - return reinterpret_cast(obj)->slotRef(slot); -} - -inline Shape * -GetObjectShape(JSObject *obj) -{ - shadow::Shape *shape = reinterpret_cast(obj)->shape; - return reinterpret_cast(shape); -} - -inline const jschar * -GetAtomChars(JSAtom *atom) -{ - return reinterpret_cast(atom)->chars; -} - -inline JSLinearString * -AtomToLinearString(JSAtom *atom) -{ - return reinterpret_cast(atom); -} - -static inline js::PropertyOp -CastAsJSPropertyOp(JSObject *object) -{ - return JS_DATA_TO_FUNC_PTR(js::PropertyOp, object); -} - -static inline js::StrictPropertyOp -CastAsJSStrictPropertyOp(JSObject *object) -{ - return JS_DATA_TO_FUNC_PTR(js::StrictPropertyOp, object); -} - -JS_FRIEND_API(bool) -GetPropertyNames(JSContext *cx, JSObject *obj, unsigned flags, js::AutoIdVector *props); - -JS_FRIEND_API(bool) -StringIsArrayIndex(JSLinearString *str, uint32_t *indexp); - -JS_FRIEND_API(void) -SetPreserveWrapperCallback(JSRuntime *rt, PreserveWrapperCallback callback); - -JS_FRIEND_API(bool) -IsObjectInContextCompartment(const JSObject *obj, const JSContext *cx); - -/* - * NB: these flag bits are encoded into the bytecode stream in the immediate - * operand of JSOP_ITER, so don't change them without advancing jsxdrapi.h's - * JSXDR_BYTECODE_VERSION. - */ -#define JSITER_ENUMERATE 0x1 /* for-in compatible hidden default iterator */ -#define JSITER_FOREACH 0x2 /* return [key, value] pair rather than key */ -#define JSITER_KEYVALUE 0x4 /* destructuring for-in wants [key, value] */ -#define JSITER_OWNONLY 0x8 /* iterate over obj's own properties only */ -#define JSITER_HIDDEN 0x10 /* also enumerate non-enumerable properties */ -#define JSITER_FOR_OF 0x20 /* harmony for-of loop */ - -inline uintptr_t -GetNativeStackLimit(const JSRuntime *rt) -{ - return RuntimeFriendFields::get(rt)->nativeStackLimit; -} - -#define JS_CHECK_RECURSION(cx, onerror) \ - JS_BEGIN_MACRO \ - int stackDummy_; \ - if (!JS_CHECK_STACK_SIZE(js::GetNativeStackLimit(js::GetRuntime(cx)), &stackDummy_)) { \ - js_ReportOverRecursed(cx); \ - onerror; \ - } \ - JS_END_MACRO - -JS_FRIEND_API(void) -StartPCCountProfiling(JSContext *cx); - -JS_FRIEND_API(void) -StopPCCountProfiling(JSContext *cx); - -JS_FRIEND_API(void) -PurgePCCounts(JSContext *cx); - -JS_FRIEND_API(size_t) -GetPCCountScriptCount(JSContext *cx); - -JS_FRIEND_API(JSString *) -GetPCCountScriptSummary(JSContext *cx, size_t script); - -JS_FRIEND_API(JSString *) -GetPCCountScriptContents(JSContext *cx, size_t script); - -#ifdef JS_THREADSAFE -JS_FRIEND_API(void *) -GetOwnerThread(const JSContext *cx); - -JS_FRIEND_API(unsigned) -GetContextOutstandingRequests(const JSContext *cx); - -class JS_FRIEND_API(AutoSkipConservativeScan) -{ - public: - AutoSkipConservativeScan(JSContext *cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM); - ~AutoSkipConservativeScan(); - - private: - JSContext *context; - MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER -}; -#endif - -JS_FRIEND_API(JSCompartment *) -GetContextCompartment(const JSContext *cx); - -JS_FRIEND_API(bool) -HasUnrootedGlobal(const JSContext *cx); - -typedef void -(* ActivityCallback)(void *arg, JSBool active); - -/* - * Sets a callback that is run whenever the runtime goes idle - the - * last active request ceases - and begins activity - when it was - * idle and a request begins. - */ -JS_FRIEND_API(void) -SetActivityCallback(JSRuntime *rt, ActivityCallback cb, void *arg); - -extern JS_FRIEND_API(const JSStructuredCloneCallbacks *) -GetContextStructuredCloneCallbacks(JSContext *cx); - -extern JS_FRIEND_API(JSVersion) -VersionSetXML(JSVersion version, bool enable); - -extern JS_FRIEND_API(bool) -CanCallContextDebugHandler(JSContext *cx); - -extern JS_FRIEND_API(JSTrapStatus) -CallContextDebugHandler(JSContext *cx, JSScript *script, jsbytecode *bc, Value *rval); - -extern JS_FRIEND_API(bool) -IsContextRunningJS(JSContext *cx); - -class SystemAllocPolicy; -typedef Vector CompartmentVector; -extern JS_FRIEND_API(const CompartmentVector&) -GetRuntimeCompartments(JSRuntime *rt); - -extern JS_FRIEND_API(size_t) -SizeOfJSContext(); - -#define GCREASONS(D) \ - /* Reasons internal to the JS engine */ \ - D(API) \ - D(MAYBEGC) \ - D(LAST_CONTEXT) \ - D(DESTROY_CONTEXT) \ - D(LAST_DITCH) \ - D(TOO_MUCH_MALLOC) \ - D(ALLOC_TRIGGER) \ - D(DEBUG_GC) \ - D(UNUSED2) /* was SHAPE */ \ - D(UNUSED3) /* was REFILL */ \ - \ - /* Reasons from Firefox */ \ - D(DOM_WINDOW_UTILS) \ - D(COMPONENT_UTILS) \ - D(MEM_PRESSURE) \ - D(CC_WAITING) \ - D(CC_FORCED) \ - D(LOAD_END) \ - D(POST_COMPARTMENT) \ - D(PAGE_HIDE) \ - D(NSJSCONTEXT_DESTROY) \ - D(SET_NEW_DOCUMENT) \ - D(SET_DOC_SHELL) \ - D(DOM_UTILS) \ - D(DOM_IPC) \ - D(DOM_WORKER) \ - D(INTER_SLICE_GC) \ - D(REFRESH_FRAME) - -namespace gcreason { - -/* GCReasons will end up looking like JSGC_MAYBEGC */ -enum Reason { -#define MAKE_REASON(name) name, - GCREASONS(MAKE_REASON) -#undef MAKE_REASON - NO_REASON, - NUM_REASONS -}; - -} /* namespace gcreason */ - -extern JS_FRIEND_API(void) -GCForReason(JSContext *cx, gcreason::Reason reason); - -extern JS_FRIEND_API(void) -CompartmentGCForReason(JSContext *cx, JSCompartment *comp, gcreason::Reason reason); - -extern JS_FRIEND_API(void) -ShrinkingGC(JSContext *cx, gcreason::Reason reason); - -extern JS_FRIEND_API(void) -IncrementalGC(JSContext *cx, gcreason::Reason reason); - -extern JS_FRIEND_API(void) -SetGCSliceTimeBudget(JSContext *cx, int64_t millis); - -enum GCProgress { - /* - * During non-incremental GC, the GC is bracketed by JSGC_CYCLE_BEGIN/END - * callbacks. During an incremental GC, the sequence of callbacks is as - * follows: - * JSGC_CYCLE_BEGIN, JSGC_SLICE_END (first slice) - * JSGC_SLICE_BEGIN, JSGC_SLICE_END (second slice) - * ... - * JSGC_SLICE_BEGIN, JSGC_CYCLE_END (last slice) - */ - - GC_CYCLE_BEGIN, - GC_SLICE_BEGIN, - GC_SLICE_END, - GC_CYCLE_END -}; - -struct GCDescription { - const char *logMessage; - bool isCompartment; - - GCDescription(const char *msg, bool isCompartment) - : logMessage(msg), isCompartment(isCompartment) {} -}; - -typedef void -(* GCSliceCallback)(JSRuntime *rt, GCProgress progress, const GCDescription &desc); - -extern JS_FRIEND_API(GCSliceCallback) -SetGCSliceCallback(JSRuntime *rt, GCSliceCallback callback); - -extern JS_FRIEND_API(bool) -WantGCSlice(JSRuntime *rt); - -/* - * Signals a good place to do an incremental slice, because the browser is - * drawing a frame. - */ -extern JS_FRIEND_API(void) -NotifyDidPaint(JSContext *cx); - -extern JS_FRIEND_API(bool) -IsIncrementalGCEnabled(JSRuntime *rt); - -extern JS_FRIEND_API(void) -DisableIncrementalGC(JSRuntime *rt); - -extern JS_FRIEND_API(bool) -IsIncrementalBarrierNeeded(JSRuntime *rt); - -extern JS_FRIEND_API(bool) -IsIncrementalBarrierNeeded(JSContext *cx); - -extern JS_FRIEND_API(bool) -IsIncrementalBarrierNeededOnObject(JSObject *obj); - -extern JS_FRIEND_API(void) -IncrementalReferenceBarrier(void *ptr); - -extern JS_FRIEND_API(void) -IncrementalValueBarrier(const Value &v); - -class ObjectPtr -{ - JSObject *value; - - public: - ObjectPtr() : value(NULL) {} - - ObjectPtr(JSObject *obj) : value(obj) {} - - /* Always call finalize before the destructor. */ - ~ObjectPtr() { JS_ASSERT(!value); } - - void finalize(JSRuntime *rt) { - if (IsIncrementalBarrierNeeded(rt)) - IncrementalReferenceBarrier(value); - value = NULL; - } - void finalize(JSContext *cx) { finalize(JS_GetRuntime(cx)); } - - void init(JSObject *obj) { value = obj; } - - JSObject *get() const { return value; } - - void writeBarrierPre(JSRuntime *rt) { - IncrementalReferenceBarrier(value); - } - - ObjectPtr &operator=(JSObject *obj) { - IncrementalReferenceBarrier(value); - value = obj; - return *this; - } - - JSObject &operator*() const { return *value; } - JSObject *operator->() const { return value; } - operator JSObject *() const { return value; } -}; - -extern JS_FRIEND_API(JSObject *) -GetTestingFunctions(JSContext *cx); - -} /* namespace js */ - -#endif - -/* Implemented in jsdate.cpp. */ - -/* - * Detect whether the internal date value is NaN. (Because failure is - * out-of-band for js_DateGet*) - */ -extern JS_FRIEND_API(JSBool) -js_DateIsValid(JSContext *cx, JSObject* obj); - -extern JS_FRIEND_API(double) -js_DateGetMsecSinceEpoch(JSContext *cx, JSObject *obj); - -/* Implemented in jscntxt.cpp. */ - -/* - * Report an exception, which is currently realized as a printf-style format - * string and its arguments. - */ -typedef enum JSErrNum { -#define MSG_DEF(name, number, count, exception, format) \ - name = number, -#include "js.msg" -#undef MSG_DEF - JSErr_Limit -} JSErrNum; - -extern JS_FRIEND_API(const JSErrorFormatString *) -js_GetErrorMessage(void *userRef, const char *locale, const unsigned errorNumber); - -/* Implemented in jsclone.cpp. */ - -extern JS_FRIEND_API(uint64_t) -js_GetSCOffset(JSStructuredCloneWriter* writer); - -#endif /* jsfriendapi_h___ */ diff --git a/js/spidermonkey-win32/include/jsgc.h b/js/spidermonkey-win32/include/jsgc.h deleted file mode 100644 index 246c4e1a3c..0000000000 --- a/js/spidermonkey-win32/include/jsgc.h +++ /dev/null @@ -1,2019 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef jsgc_h___ -#define jsgc_h___ - -/* - * JS Garbage Collector. - */ -#include - -#include "mozilla/Util.h" - -#include "jsalloc.h" -#include "jstypes.h" -#include "jsprvtd.h" -#include "jspubtd.h" -#include "jsdhash.h" -#include "jslock.h" -#include "jsutil.h" -#include "jsversion.h" -#include "jscell.h" - -#include "ds/BitArray.h" -#include "gc/Statistics.h" -#include "js/HashTable.h" -#include "js/Vector.h" -#include "js/TemplateLib.h" - -struct JSCompartment; - -extern "C" void -js_TraceXML(JSTracer *trc, JSXML* thing); - -#if JS_STACK_GROWTH_DIRECTION > 0 -# define JS_CHECK_STACK_SIZE(limit, lval) ((uintptr_t)(lval) < limit) -#else -# define JS_CHECK_STACK_SIZE(limit, lval) ((uintptr_t)(lval) > limit) -#endif - -namespace js { - -class GCHelperThread; -struct Shape; - -namespace gc { - -enum State { - NO_INCREMENTAL, - MARK_ROOTS, - MARK, - SWEEP, - INVALID -}; - -struct Arena; - -/* - * This must be an upper bound, but we do not need the least upper bound, so - * we just exclude non-background objects. - */ -const size_t MAX_BACKGROUND_FINALIZE_KINDS = FINALIZE_LIMIT - FINALIZE_OBJECT_LIMIT / 2; - -/* - * Page size is 4096 by default, except for SPARC, where it is 8192. - * Note: Do not use JS_CPU_SPARC here, this header is used outside JS. - * Bug 692267: Move page size definition to gc/Memory.h and include it - * directly once jsgc.h is no longer an installed header. - */ -#if defined(SOLARIS) && (defined(__sparc) || defined(__sparcv9)) -const size_t PageShift = 13; -#else -const size_t PageShift = 12; -#endif -const size_t PageSize = size_t(1) << PageShift; - -const size_t ChunkShift = 20; -const size_t ChunkSize = size_t(1) << ChunkShift; -const size_t ChunkMask = ChunkSize - 1; - -const size_t ArenaShift = PageShift; -const size_t ArenaSize = PageSize; -const size_t ArenaMask = ArenaSize - 1; - -/* - * This is the maximum number of arenas we allow in the FreeCommitted state - * before we trigger a GC_SHRINK to release free arenas to the OS. - */ -const static uint32_t FreeCommittedArenasThreshold = (32 << 20) / ArenaSize; - -/* - * The mark bitmap has one bit per each GC cell. For multi-cell GC things this - * wastes space but allows to avoid expensive devisions by thing's size when - * accessing the bitmap. In addition this allows to use some bits for colored - * marking during the cycle GC. - */ -const size_t ArenaCellCount = size_t(1) << (ArenaShift - Cell::CellShift); -const size_t ArenaBitmapBits = ArenaCellCount; -const size_t ArenaBitmapBytes = ArenaBitmapBits / 8; -const size_t ArenaBitmapWords = ArenaBitmapBits / JS_BITS_PER_WORD; - -/* - * A FreeSpan represents a contiguous sequence of free cells in an Arena. - * |first| is the address of the first free cell in the span. |last| is the - * address of the last free cell in the span. This last cell holds a FreeSpan - * data structure for the next span unless this is the last span on the list - * of spans in the arena. For this last span |last| points to the last byte of - * the last thing in the arena and no linkage is stored there, so - * |last| == arenaStart + ArenaSize - 1. If the space at the arena end is - * fully used this last span is empty and |first| == |last + 1|. - * - * Thus |first| < |last| implies that we have either the last span with at least - * one element or that the span is not the last and contains at least 2 - * elements. In both cases to allocate a thing from this span we need simply - * to increment |first| by the allocation size. - * - * |first| == |last| implies that we have a one element span that records the - * next span. So to allocate from it we need to update the span list head - * with a copy of the span stored at |last| address so the following - * allocations will use that span. - * - * |first| > |last| implies that we have an empty last span and the arena is - * fully used. - * - * Also only for the last span (|last| & 1)! = 0 as all allocation sizes are - * multiples of Cell::CellSize. - */ -struct FreeSpan { - uintptr_t first; - uintptr_t last; - - public: - FreeSpan() {} - - FreeSpan(uintptr_t first, uintptr_t last) - : first(first), last(last) { - checkSpan(); - } - - /* - * To minimize the size of the arena header the first span is encoded - * there as offsets from the arena start. - */ - static size_t encodeOffsets(size_t firstOffset, size_t lastOffset) { - /* Check that we can pack the offsets into uint16. */ - JS_STATIC_ASSERT(ArenaShift < 16); - JS_ASSERT(firstOffset <= ArenaSize); - JS_ASSERT(lastOffset < ArenaSize); - JS_ASSERT(firstOffset <= ((lastOffset + 1) & ~size_t(1))); - return firstOffset | (lastOffset << 16); - } - - /* - * Encoded offsets for a full arena when its first span is the last one - * and empty. - */ - static const size_t FullArenaOffsets = ArenaSize | ((ArenaSize - 1) << 16); - - static FreeSpan decodeOffsets(uintptr_t arenaAddr, size_t offsets) { - JS_ASSERT(!(arenaAddr & ArenaMask)); - - size_t firstOffset = offsets & 0xFFFF; - size_t lastOffset = offsets >> 16; - JS_ASSERT(firstOffset <= ArenaSize); - JS_ASSERT(lastOffset < ArenaSize); - - /* - * We must not use | when calculating first as firstOffset is - * ArenaMask + 1 for the empty span. - */ - return FreeSpan(arenaAddr + firstOffset, arenaAddr | lastOffset); - } - - void initAsEmpty(uintptr_t arenaAddr = 0) { - JS_ASSERT(!(arenaAddr & ArenaMask)); - first = arenaAddr + ArenaSize; - last = arenaAddr | (ArenaSize - 1); - JS_ASSERT(isEmpty()); - } - - bool isEmpty() const { - checkSpan(); - return first > last; - } - - bool hasNext() const { - checkSpan(); - return !(last & uintptr_t(1)); - } - - const FreeSpan *nextSpan() const { - JS_ASSERT(hasNext()); - return reinterpret_cast(last); - } - - FreeSpan *nextSpanUnchecked(size_t thingSize) const { -#ifdef DEBUG - uintptr_t lastOffset = last & ArenaMask; - JS_ASSERT(!(lastOffset & 1)); - JS_ASSERT((ArenaSize - lastOffset) % thingSize == 0); -#endif - return reinterpret_cast(last); - } - - uintptr_t arenaAddressUnchecked() const { - return last & ~ArenaMask; - } - - uintptr_t arenaAddress() const { - checkSpan(); - return arenaAddressUnchecked(); - } - - ArenaHeader *arenaHeader() const { - return reinterpret_cast(arenaAddress()); - } - - bool isSameNonEmptySpan(const FreeSpan *another) const { - JS_ASSERT(!isEmpty()); - JS_ASSERT(!another->isEmpty()); - return first == another->first && last == another->last; - } - - bool isWithinArena(uintptr_t arenaAddr) const { - JS_ASSERT(!(arenaAddr & ArenaMask)); - - /* Return true for the last empty span as well. */ - return arenaAddress() == arenaAddr; - } - - size_t encodeAsOffsets() const { - /* - * We must use first - arenaAddress(), not first & ArenaMask as - * first == ArenaMask + 1 for an empty span. - */ - uintptr_t arenaAddr = arenaAddress(); - return encodeOffsets(first - arenaAddr, last & ArenaMask); - } - - /* See comments before FreeSpan for details. */ - JS_ALWAYS_INLINE void *allocate(size_t thingSize) { - JS_ASSERT(thingSize % Cell::CellSize == 0); - checkSpan(); - uintptr_t thing = first; - if (thing < last) { - /* Bump-allocate from the current span. */ - first = thing + thingSize; - } else if (JS_LIKELY(thing == last)) { - /* - * Move to the next span. We use JS_LIKELY as without PGO - * compilers mis-predict == here as unlikely to succeed. - */ - *this = *reinterpret_cast(thing); - } else { - return NULL; - } - checkSpan(); - return reinterpret_cast(thing); - } - - /* A version of allocate when we know that the span is not empty. */ - JS_ALWAYS_INLINE void *infallibleAllocate(size_t thingSize) { - JS_ASSERT(thingSize % Cell::CellSize == 0); - checkSpan(); - uintptr_t thing = first; - if (thing < last) { - first = thing + thingSize; - } else { - JS_ASSERT(thing == last); - *this = *reinterpret_cast(thing); - } - checkSpan(); - return reinterpret_cast(thing); - } - - /* - * Allocate from a newly allocated arena. We do not move the free list - * from the arena. Rather we set the arena up as fully used during the - * initialization so to allocate we simply return the first thing in the - * arena and set the free list to point to the second. - */ - JS_ALWAYS_INLINE void *allocateFromNewArena(uintptr_t arenaAddr, size_t firstThingOffset, - size_t thingSize) { - JS_ASSERT(!(arenaAddr & ArenaMask)); - uintptr_t thing = arenaAddr | firstThingOffset; - first = thing + thingSize; - last = arenaAddr | ArenaMask; - checkSpan(); - return reinterpret_cast(thing); - } - - void checkSpan() const { -#ifdef DEBUG - /* We do not allow spans at the end of the address space. */ - JS_ASSERT(last != uintptr_t(-1)); - JS_ASSERT(first); - JS_ASSERT(last); - JS_ASSERT(first - 1 <= last); - uintptr_t arenaAddr = arenaAddressUnchecked(); - if (last & 1) { - /* The span is the last. */ - JS_ASSERT((last & ArenaMask) == ArenaMask); - - if (first - 1 == last) { - /* The span is last and empty. The above start != 0 check - * implies that we are not at the end of the address space. - */ - return; - } - size_t spanLength = last - first + 1; - JS_ASSERT(spanLength % Cell::CellSize == 0); - - /* Start and end must belong to the same arena. */ - JS_ASSERT((first & ~ArenaMask) == arenaAddr); - return; - } - - /* The span is not the last and we have more spans to follow. */ - JS_ASSERT(first <= last); - size_t spanLengthWithoutOneThing = last - first; - JS_ASSERT(spanLengthWithoutOneThing % Cell::CellSize == 0); - - JS_ASSERT((first & ~ArenaMask) == arenaAddr); - - /* - * If there is not enough space before the arena end to allocate one - * more thing, then the span must be marked as the last one to avoid - * storing useless empty span reference. - */ - size_t beforeTail = ArenaSize - (last & ArenaMask); - JS_ASSERT(beforeTail >= sizeof(FreeSpan) + Cell::CellSize); - - FreeSpan *next = reinterpret_cast(last); - - /* - * The GC things on the list of free spans come from one arena - * and the spans are linked in ascending address order with - * at least one non-free thing between spans. - */ - JS_ASSERT(last < next->first); - JS_ASSERT(arenaAddr == next->arenaAddressUnchecked()); - - if (next->first > next->last) { - /* - * The next span is the empty span that terminates the list for - * arenas that do not have any free things at the end. - */ - JS_ASSERT(next->first - 1 == next->last); - JS_ASSERT(arenaAddr + ArenaSize == next->first); - } -#endif - } - -}; - -/* Every arena has a header. */ -struct ArenaHeader { - friend struct FreeLists; - - JSCompartment *compartment; - - /* - * ArenaHeader::next has two purposes: when unallocated, it points to the - * next available Arena's header. When allocated, it points to the next - * arena of the same size class and compartment. - */ - ArenaHeader *next; - - private: - /* - * The first span of free things in the arena. We encode it as the start - * and end offsets within the arena, not as FreeSpan structure, to - * minimize the header size. - */ - size_t firstFreeSpanOffsets; - - /* - * One of AllocKind constants or FINALIZE_LIMIT when the arena does not - * contain any GC things and is on the list of empty arenas in the GC - * chunk. The latter allows to quickly check if the arena is allocated - * during the conservative GC scanning without searching the arena in the - * list. - */ - size_t allocKind : 8; - - /* - * When recursive marking uses too much stack the marking is delayed and - * the corresponding arenas are put into a stack using the following field - * as a linkage. To distinguish the bottom of the stack from the arenas - * not present in the stack we use an extra flag to tag arenas on the - * stack. - * - * Delayed marking is also used for arenas that we allocate into during an - * incremental GC. In this case, we intend to mark all the objects in the - * arena, and it's faster to do this marking in bulk. - * - * To minimize the ArenaHeader size we record the next delayed marking - * linkage as arenaAddress() >> ArenaShift and pack it with the allocKind - * field and hasDelayedMarking flag. We use 8 bits for the allocKind, not - * ArenaShift - 1, so the compiler can use byte-level memory instructions - * to access it. - */ - public: - size_t hasDelayedMarking : 1; - size_t allocatedDuringIncremental : 1; - size_t markOverflow : 1; - size_t nextDelayedMarking : JS_BITS_PER_WORD - 8 - 1 - 1 - 1; - - static void staticAsserts() { - /* We must be able to fit the allockind into uint8_t. */ - JS_STATIC_ASSERT(FINALIZE_LIMIT <= 255); - - /* - * nextDelayedMarkingpacking assumes that ArenaShift has enough bits - * to cover allocKind and hasDelayedMarking. - */ - JS_STATIC_ASSERT(ArenaShift >= 8 + 1 + 1 + 1); - } - - inline uintptr_t address() const; - inline Chunk *chunk() const; - - bool allocated() const { - JS_ASSERT(allocKind <= size_t(FINALIZE_LIMIT)); - return allocKind < size_t(FINALIZE_LIMIT); - } - - void init(JSCompartment *comp, AllocKind kind) { - JS_ASSERT(!allocated()); - JS_ASSERT(!markOverflow); - JS_ASSERT(!allocatedDuringIncremental); - JS_ASSERT(!hasDelayedMarking); - compartment = comp; - - JS_STATIC_ASSERT(FINALIZE_LIMIT <= 255); - allocKind = size_t(kind); - - /* See comments in FreeSpan::allocateFromNewArena. */ - firstFreeSpanOffsets = FreeSpan::FullArenaOffsets; - } - - void setAsNotAllocated() { - allocKind = size_t(FINALIZE_LIMIT); - markOverflow = 0; - allocatedDuringIncremental = 0; - hasDelayedMarking = 0; - nextDelayedMarking = 0; - } - - uintptr_t arenaAddress() const { - return address(); - } - - Arena *getArena() { - return reinterpret_cast(arenaAddress()); - } - - AllocKind getAllocKind() const { - JS_ASSERT(allocated()); - return AllocKind(allocKind); - } - - inline size_t getThingSize() const; - - bool hasFreeThings() const { - return firstFreeSpanOffsets != FreeSpan::FullArenaOffsets; - } - - inline bool isEmpty() const; - - void setAsFullyUsed() { - firstFreeSpanOffsets = FreeSpan::FullArenaOffsets; - } - - FreeSpan getFirstFreeSpan() const { -#ifdef DEBUG - checkSynchronizedWithFreeList(); -#endif - return FreeSpan::decodeOffsets(arenaAddress(), firstFreeSpanOffsets); - } - - void setFirstFreeSpan(const FreeSpan *span) { - JS_ASSERT(span->isWithinArena(arenaAddress())); - firstFreeSpanOffsets = span->encodeAsOffsets(); - } - -#ifdef DEBUG - void checkSynchronizedWithFreeList() const; -#endif - - inline ArenaHeader *getNextDelayedMarking() const; - inline void setNextDelayedMarking(ArenaHeader *aheader); -}; - -struct Arena { - /* - * Layout of an arena: - * An arena is 4K in size and 4K-aligned. It starts with the ArenaHeader - * descriptor followed by some pad bytes. The remainder of the arena is - * filled with the array of T things. The pad bytes ensure that the thing - * array ends exactly at the end of the arena. - * - * +-------------+-----+----+----+-----+----+ - * | ArenaHeader | pad | T0 | T1 | ... | Tn | - * +-------------+-----+----+----+-----+----+ - * - * <----------------------------------------> = ArenaSize bytes - * <-------------------> = first thing offset - */ - ArenaHeader aheader; - uint8_t data[ArenaSize - sizeof(ArenaHeader)]; - - private: - static JS_FRIEND_DATA(const uint32_t) ThingSizes[]; - static JS_FRIEND_DATA(const uint32_t) FirstThingOffsets[]; - - public: - static void staticAsserts(); - - static size_t thingSize(AllocKind kind) { - return ThingSizes[kind]; - } - - static size_t firstThingOffset(AllocKind kind) { - return FirstThingOffsets[kind]; - } - - static size_t thingsPerArena(size_t thingSize) { - JS_ASSERT(thingSize % Cell::CellSize == 0); - - /* We should be able to fit FreeSpan in any GC thing. */ - JS_ASSERT(thingSize >= sizeof(FreeSpan)); - - return (ArenaSize - sizeof(ArenaHeader)) / thingSize; - } - - static size_t thingsSpan(size_t thingSize) { - return thingsPerArena(thingSize) * thingSize; - } - - static bool isAligned(uintptr_t thing, size_t thingSize) { - /* Things ends at the arena end. */ - uintptr_t tailOffset = (ArenaSize - thing) & ArenaMask; - return tailOffset % thingSize == 0; - } - - uintptr_t address() const { - return aheader.address(); - } - - uintptr_t thingsStart(AllocKind thingKind) { - return address() | firstThingOffset(thingKind); - } - - uintptr_t thingsEnd() { - return address() + ArenaSize; - } - - template - bool finalize(JSContext *cx, AllocKind thingKind, size_t thingSize, bool background); -}; - -/* The chunk header (located at the end of the chunk to preserve arena alignment). */ -struct ChunkInfo { - Chunk *next; - Chunk **prevp; - - /* Free arenas are linked together with aheader.next. */ - ArenaHeader *freeArenasHead; - - /* - * Decommitted arenas are tracked by a bitmap in the chunk header. We use - * this offset to start our search iteration close to a decommitted arena - * that we can allocate. - */ - uint32_t lastDecommittedArenaOffset; - - /* Number of free arenas, either committed or decommitted. */ - uint32_t numArenasFree; - - /* Number of free, committed arenas. */ - uint32_t numArenasFreeCommitted; - - /* Number of GC cycles this chunk has survived. */ - uint32_t age; -}; - -/* - * Calculating ArenasPerChunk: - * - * In order to figure out how many Arenas will fit in a chunk, we need to know - * how much extra space is available after we allocate the header data. This - * is a problem because the header size depends on the number of arenas in the - * chunk. The two dependent fields are bitmap and decommittedArenas. - * - * For the mark bitmap, we know that each arena will use a fixed number of full - * bytes: ArenaBitmapBytes. The full size of the header data is this number - * multiplied by the eventual number of arenas we have in the header. We, - * conceptually, distribute this header data among the individual arenas and do - * not include it in the header. This way we do not have to worry about its - * variable size: it gets attached to the variable number we are computing. - * - * For the decommitted arena bitmap, we only have 1 bit per arena, so this - * technique will not work. Instead, we observe that we do not have enough - * header info to fill 8 full arenas: it is currently 4 on 64bit, less on - * 32bit. Thus, with current numbers, we need 64 bytes for decommittedArenas. - * This will not become 63 bytes unless we double the data required in the - * header. Therefore, we just compute the number of bytes required to track - * every possible arena and do not worry about slop bits, since there are too - * few to usefully allocate. - * - * To actually compute the number of arenas we can allocate in a chunk, we - * divide the amount of available space less the header info (not including - * the mark bitmap which is distributed into the arena size) by the size of - * the arena (with the mark bitmap bytes it uses). - */ -const size_t BytesPerArenaWithHeader = ArenaSize + ArenaBitmapBytes; -const size_t ChunkDecommitBitmapBytes = ChunkSize / ArenaSize / JS_BITS_PER_BYTE; -const size_t ChunkBytesAvailable = ChunkSize - sizeof(ChunkInfo) - ChunkDecommitBitmapBytes; -const size_t ArenasPerChunk = ChunkBytesAvailable / BytesPerArenaWithHeader; - -/* A chunk bitmap contains enough mark bits for all the cells in a chunk. */ -struct ChunkBitmap { - uintptr_t bitmap[ArenaBitmapWords * ArenasPerChunk]; - - JS_ALWAYS_INLINE void getMarkWordAndMask(const Cell *cell, uint32_t color, - uintptr_t **wordp, uintptr_t *maskp); - - JS_ALWAYS_INLINE bool isMarked(const Cell *cell, uint32_t color) { - uintptr_t *word, mask; - getMarkWordAndMask(cell, color, &word, &mask); - return *word & mask; - } - - JS_ALWAYS_INLINE bool markIfUnmarked(const Cell *cell, uint32_t color) { - uintptr_t *word, mask; - getMarkWordAndMask(cell, BLACK, &word, &mask); - if (*word & mask) - return false; - *word |= mask; - if (color != BLACK) { - /* - * We use getMarkWordAndMask to recalculate both mask and word as - * doing just mask << color may overflow the mask. - */ - getMarkWordAndMask(cell, color, &word, &mask); - if (*word & mask) - return false; - *word |= mask; - } - return true; - } - - JS_ALWAYS_INLINE void unmark(const Cell *cell, uint32_t color) { - uintptr_t *word, mask; - getMarkWordAndMask(cell, color, &word, &mask); - *word &= ~mask; - } - - void clear() { - PodArrayZero(bitmap); - } - -#ifdef DEBUG - bool noBitsSet(ArenaHeader *aheader) { - /* - * We assume that the part of the bitmap corresponding to the arena - * has the exact number of words so we do not need to deal with a word - * that covers bits from two arenas. - */ - JS_STATIC_ASSERT(ArenaBitmapBits == ArenaBitmapWords * JS_BITS_PER_WORD); - - uintptr_t *word, unused; - getMarkWordAndMask(reinterpret_cast(aheader->address()), BLACK, &word, &unused); - for (size_t i = 0; i != ArenaBitmapWords; i++) { - if (word[i]) - return false; - } - return true; - } -#endif -}; - -JS_STATIC_ASSERT(ArenaBitmapBytes * ArenasPerChunk == sizeof(ChunkBitmap)); - -typedef BitArray PerArenaBitmap; - -const size_t ChunkPadSize = ChunkSize - - (sizeof(Arena) * ArenasPerChunk) - - sizeof(ChunkBitmap) - - sizeof(PerArenaBitmap) - - sizeof(ChunkInfo); -JS_STATIC_ASSERT(ChunkPadSize < BytesPerArenaWithHeader); - -/* - * Chunks contain arenas and associated data structures (mark bitmap, delayed - * marking state). - */ -struct Chunk { - Arena arenas[ArenasPerChunk]; - - /* Pad to full size to ensure cache alignment of ChunkInfo. */ - uint8_t padding[ChunkPadSize]; - - ChunkBitmap bitmap; - PerArenaBitmap decommittedArenas; - ChunkInfo info; - - static Chunk *fromAddress(uintptr_t addr) { - addr &= ~ChunkMask; - return reinterpret_cast(addr); - } - - static bool withinArenasRange(uintptr_t addr) { - uintptr_t offset = addr & ChunkMask; - return offset < ArenasPerChunk * ArenaSize; - } - - static size_t arenaIndex(uintptr_t addr) { - JS_ASSERT(withinArenasRange(addr)); - return (addr & ChunkMask) >> ArenaShift; - } - - uintptr_t address() const { - uintptr_t addr = reinterpret_cast(this); - JS_ASSERT(!(addr & ChunkMask)); - return addr; - } - - bool unused() const { - return info.numArenasFree == ArenasPerChunk; - } - - bool hasAvailableArenas() const { - return info.numArenasFree != 0; - } - - inline void addToAvailableList(JSCompartment *compartment); - inline void insertToAvailableList(Chunk **insertPoint); - inline void removeFromAvailableList(); - - ArenaHeader *allocateArena(JSCompartment *comp, AllocKind kind); - - void releaseArena(ArenaHeader *aheader); - - static Chunk *allocate(JSRuntime *rt); - - /* Must be called with the GC lock taken. */ - static inline void release(JSRuntime *rt, Chunk *chunk); - static inline void releaseList(JSRuntime *rt, Chunk *chunkListHead); - - /* Must be called with the GC lock taken. */ - inline void prepareToBeFreed(JSRuntime *rt); - - /* - * Assuming that the info.prevp points to the next field of the previous - * chunk in a doubly-linked list, get that chunk. - */ - Chunk *getPrevious() { - JS_ASSERT(info.prevp); - return fromPointerToNext(info.prevp); - } - - /* Get the chunk from a pointer to its info.next field. */ - static Chunk *fromPointerToNext(Chunk **nextFieldPtr) { - uintptr_t addr = reinterpret_cast(nextFieldPtr); - JS_ASSERT((addr & ChunkMask) == offsetof(Chunk, info.next)); - return reinterpret_cast(addr - offsetof(Chunk, info.next)); - } - - private: - inline void init(); - - /* Search for a decommitted arena to allocate. */ - unsigned findDecommittedArenaOffset(); - ArenaHeader* fetchNextDecommittedArena(); - - public: - /* Unlink and return the freeArenasHead. */ - inline ArenaHeader* fetchNextFreeArena(JSRuntime *rt); - - inline void addArenaToFreeList(JSRuntime *rt, ArenaHeader *aheader); -}; - -JS_STATIC_ASSERT(sizeof(Chunk) == ChunkSize); - -class ChunkPool { - Chunk *emptyChunkListHead; - size_t emptyCount; - - public: - ChunkPool() - : emptyChunkListHead(NULL), - emptyCount(0) { } - - size_t getEmptyCount() const { - return emptyCount; - } - - inline bool wantBackgroundAllocation(JSRuntime *rt) const; - - /* Must be called with the GC lock taken. */ - inline Chunk *get(JSRuntime *rt); - - /* Must be called either during the GC or with the GC lock taken. */ - inline void put(Chunk *chunk); - - /* - * Return the list of chunks that can be released outside the GC lock. - * Must be called either during the GC or with the GC lock taken. - */ - Chunk *expire(JSRuntime *rt, bool releaseAll); - - /* Must be called with the GC lock taken. */ - void expireAndFree(JSRuntime *rt, bool releaseAll); - - /* Must be called either during the GC or with the GC lock taken. */ - JS_FRIEND_API(int64_t) countCleanDecommittedArenas(JSRuntime *rt); -}; - -inline uintptr_t -Cell::address() const -{ - uintptr_t addr = uintptr_t(this); - JS_ASSERT(addr % Cell::CellSize == 0); - JS_ASSERT(Chunk::withinArenasRange(addr)); - return addr; -} - -inline ArenaHeader * -Cell::arenaHeader() const -{ - uintptr_t addr = address(); - addr &= ~ArenaMask; - return reinterpret_cast(addr); -} - -Chunk * -Cell::chunk() const -{ - uintptr_t addr = uintptr_t(this); - JS_ASSERT(addr % Cell::CellSize == 0); - addr &= ~(ChunkSize - 1); - return reinterpret_cast(addr); -} - -AllocKind -Cell::getAllocKind() const -{ - return arenaHeader()->getAllocKind(); -} - -#ifdef DEBUG -inline bool -Cell::isAligned() const -{ - return Arena::isAligned(address(), arenaHeader()->getThingSize()); -} -#endif - -inline uintptr_t -ArenaHeader::address() const -{ - uintptr_t addr = reinterpret_cast(this); - JS_ASSERT(!(addr & ArenaMask)); - JS_ASSERT(Chunk::withinArenasRange(addr)); - return addr; -} - -inline Chunk * -ArenaHeader::chunk() const -{ - return Chunk::fromAddress(address()); -} - -inline bool -ArenaHeader::isEmpty() const -{ - /* Arena is empty if its first span covers the whole arena. */ - JS_ASSERT(allocated()); - size_t firstThingOffset = Arena::firstThingOffset(getAllocKind()); - return firstFreeSpanOffsets == FreeSpan::encodeOffsets(firstThingOffset, ArenaMask); -} - -inline size_t -ArenaHeader::getThingSize() const -{ - JS_ASSERT(allocated()); - return Arena::thingSize(getAllocKind()); -} - -inline ArenaHeader * -ArenaHeader::getNextDelayedMarking() const -{ - return &reinterpret_cast(nextDelayedMarking << ArenaShift)->aheader; -} - -inline void -ArenaHeader::setNextDelayedMarking(ArenaHeader *aheader) -{ - JS_ASSERT(!(uintptr_t(aheader) & ArenaMask)); - hasDelayedMarking = 1; - nextDelayedMarking = aheader->arenaAddress() >> ArenaShift; -} - -JS_ALWAYS_INLINE void -ChunkBitmap::getMarkWordAndMask(const Cell *cell, uint32_t color, - uintptr_t **wordp, uintptr_t *maskp) -{ - size_t bit = (cell->address() & ChunkMask) / Cell::CellSize + color; - JS_ASSERT(bit < ArenaBitmapBits * ArenasPerChunk); - *maskp = uintptr_t(1) << (bit % JS_BITS_PER_WORD); - *wordp = &bitmap[bit / JS_BITS_PER_WORD]; -} - -static void -AssertValidColor(const void *thing, uint32_t color) -{ -#ifdef DEBUG - ArenaHeader *aheader = reinterpret_cast(thing)->arenaHeader(); - JS_ASSERT_IF(color, color < aheader->getThingSize() / Cell::CellSize); -#endif -} - -inline bool -Cell::isMarked(uint32_t color) const -{ - AssertValidColor(this, color); - return chunk()->bitmap.isMarked(this, color); -} - -bool -Cell::markIfUnmarked(uint32_t color) const -{ - AssertValidColor(this, color); - return chunk()->bitmap.markIfUnmarked(this, color); -} - -void -Cell::unmark(uint32_t color) const -{ - JS_ASSERT(color != BLACK); - AssertValidColor(this, color); - chunk()->bitmap.unmark(this, color); -} - -JSCompartment * -Cell::compartment() const -{ - return arenaHeader()->compartment; -} - -static inline JSGCTraceKind -MapAllocToTraceKind(AllocKind thingKind) -{ - static const JSGCTraceKind map[FINALIZE_LIMIT] = { - JSTRACE_OBJECT, /* FINALIZE_OBJECT0 */ - JSTRACE_OBJECT, /* FINALIZE_OBJECT0_BACKGROUND */ - JSTRACE_OBJECT, /* FINALIZE_OBJECT2 */ - JSTRACE_OBJECT, /* FINALIZE_OBJECT2_BACKGROUND */ - JSTRACE_OBJECT, /* FINALIZE_OBJECT4 */ - JSTRACE_OBJECT, /* FINALIZE_OBJECT4_BACKGROUND */ - JSTRACE_OBJECT, /* FINALIZE_OBJECT8 */ - JSTRACE_OBJECT, /* FINALIZE_OBJECT8_BACKGROUND */ - JSTRACE_OBJECT, /* FINALIZE_OBJECT12 */ - JSTRACE_OBJECT, /* FINALIZE_OBJECT12_BACKGROUND */ - JSTRACE_OBJECT, /* FINALIZE_OBJECT16 */ - JSTRACE_OBJECT, /* FINALIZE_OBJECT16_BACKGROUND */ - JSTRACE_SCRIPT, /* FINALIZE_SCRIPT */ - JSTRACE_SHAPE, /* FINALIZE_SHAPE */ - JSTRACE_BASE_SHAPE, /* FINALIZE_BASE_SHAPE */ - JSTRACE_TYPE_OBJECT,/* FINALIZE_TYPE_OBJECT */ -#if JS_HAS_XML_SUPPORT /* FINALIZE_XML */ - JSTRACE_XML, -#endif - JSTRACE_STRING, /* FINALIZE_SHORT_STRING */ - JSTRACE_STRING, /* FINALIZE_STRING */ - JSTRACE_STRING, /* FINALIZE_EXTERNAL_STRING */ - }; - return map[thingKind]; -} - -inline JSGCTraceKind -GetGCThingTraceKind(const void *thing); - -struct ArenaLists { - - /* - * ArenaList::head points to the start of the list. Normally cursor points - * to the first arena in the list with some free things and all arenas - * before cursor are fully allocated. However, as the arena currently being - * allocated from is considered full while its list of free spans is moved - * into the freeList, during the GC or cell enumeration, when an - * unallocated freeList is moved back to the arena, we can see an arena - * with some free cells before the cursor. The cursor is an indirect - * pointer to allow for efficient list insertion at the cursor point and - * other list manipulations. - */ - struct ArenaList { - ArenaHeader *head; - ArenaHeader **cursor; - - ArenaList() { - clear(); - } - - void clear() { - head = NULL; - cursor = &head; - } - }; - - private: - /* - * For each arena kind its free list is represented as the first span with - * free things. Initially all the spans are initialized as empty. After we - * find a new arena with available things we move its first free span into - * the list and set the arena as fully allocated. way we do not need to - * update the arena header after the initial allocation. When starting the - * GC we only move the head of the of the list of spans back to the arena - * only for the arena that was not fully allocated. - */ - FreeSpan freeLists[FINALIZE_LIMIT]; - - ArenaList arenaLists[FINALIZE_LIMIT]; - -#ifdef JS_THREADSAFE - /* - * The background finalization adds the finalized arenas to the list at - * the *cursor position. backgroundFinalizeState controls the interaction - * between the GC lock and the access to the list from the allocation - * thread. - * - * BFS_DONE indicates that the finalizations is not running or cannot - * affect this arena list. The allocation thread can access the list - * outside the GC lock. - * - * In BFS_RUN and BFS_JUST_FINISHED the allocation thread must take the - * lock. The former indicates that the finalization still runs. The latter - * signals that finalization just added to the list finalized arenas. In - * that case the lock effectively serves as a read barrier to ensure that - * the allocation thread see all the writes done during finalization. - */ - enum BackgroundFinalizeState { - BFS_DONE, - BFS_RUN, - BFS_JUST_FINISHED - }; - - volatile uintptr_t backgroundFinalizeState[FINALIZE_LIMIT]; -#endif - - public: - ArenaLists() { - for (size_t i = 0; i != FINALIZE_LIMIT; ++i) - freeLists[i].initAsEmpty(); -#ifdef JS_THREADSAFE - for (size_t i = 0; i != FINALIZE_LIMIT; ++i) - backgroundFinalizeState[i] = BFS_DONE; -#endif - } - - ~ArenaLists() { - for (size_t i = 0; i != FINALIZE_LIMIT; ++i) { -#ifdef JS_THREADSAFE - /* - * We can only call this during the shutdown after the last GC when - * the background finalization is disabled. - */ - JS_ASSERT(backgroundFinalizeState[i] == BFS_DONE); -#endif - ArenaHeader **headp = &arenaLists[i].head; - while (ArenaHeader *aheader = *headp) { - *headp = aheader->next; - aheader->chunk()->releaseArena(aheader); - } - } - } - - const FreeSpan *getFreeList(AllocKind thingKind) const { - return &freeLists[thingKind]; - } - - ArenaHeader *getFirstArena(AllocKind thingKind) const { - return arenaLists[thingKind].head; - } - - bool arenaListsAreEmpty() const { - for (size_t i = 0; i != FINALIZE_LIMIT; ++i) { -#ifdef JS_THREADSAFE - /* - * The arena cannot be empty if the background finalization is not yet - * done. - */ - if (backgroundFinalizeState[i] != BFS_DONE) - return false; -#endif - if (arenaLists[i].head) - return false; - } - return true; - } - -#ifdef DEBUG - bool checkArenaListAllUnmarked() const { - for (size_t i = 0; i != FINALIZE_LIMIT; ++i) { -# ifdef JS_THREADSAFE - /* The background finalization must have stopped at this point. */ - JS_ASSERT(backgroundFinalizeState[i] == BFS_DONE || - backgroundFinalizeState[i] == BFS_JUST_FINISHED); -# endif - for (ArenaHeader *aheader = arenaLists[i].head; aheader; aheader = aheader->next) { - if (!aheader->chunk()->bitmap.noBitsSet(aheader)) - return false; - } - } - return true; - } -#endif - -#ifdef JS_THREADSAFE - bool doneBackgroundFinalize(AllocKind kind) const { - return backgroundFinalizeState[kind] == BFS_DONE; - } -#endif - - /* - * Return the free list back to the arena so the GC finalization will not - * run the finalizers over unitialized bytes from free things. - */ - void purge() { - for (size_t i = 0; i != FINALIZE_LIMIT; ++i) { - FreeSpan *headSpan = &freeLists[i]; - if (!headSpan->isEmpty()) { - ArenaHeader *aheader = headSpan->arenaHeader(); - aheader->setFirstFreeSpan(headSpan); - headSpan->initAsEmpty(); - } - } - } - - inline void prepareForIncrementalGC(JSRuntime *rt); - - /* - * Temporarily copy the free list heads to the arenas so the code can see - * the proper value in ArenaHeader::freeList when accessing the latter - * outside the GC. - */ - void copyFreeListsToArenas() { - for (size_t i = 0; i != FINALIZE_LIMIT; ++i) - copyFreeListToArena(AllocKind(i)); - } - - void copyFreeListToArena(AllocKind thingKind) { - FreeSpan *headSpan = &freeLists[thingKind]; - if (!headSpan->isEmpty()) { - ArenaHeader *aheader = headSpan->arenaHeader(); - JS_ASSERT(!aheader->hasFreeThings()); - aheader->setFirstFreeSpan(headSpan); - } - } - - /* - * Clear the free lists in arenas that were temporarily set there using - * copyToArenas. - */ - void clearFreeListsInArenas() { - for (size_t i = 0; i != FINALIZE_LIMIT; ++i) - clearFreeListInArena(AllocKind(i)); - } - - - void clearFreeListInArena(AllocKind kind) { - FreeSpan *headSpan = &freeLists[kind]; - if (!headSpan->isEmpty()) { - ArenaHeader *aheader = headSpan->arenaHeader(); - JS_ASSERT(aheader->getFirstFreeSpan().isSameNonEmptySpan(headSpan)); - aheader->setAsFullyUsed(); - } - } - - /* - * Check that the free list is either empty or were synchronized with the - * arena using copyToArena(). - */ - bool isSynchronizedFreeList(AllocKind kind) { - FreeSpan *headSpan = &freeLists[kind]; - if (headSpan->isEmpty()) - return true; - ArenaHeader *aheader = headSpan->arenaHeader(); - if (aheader->hasFreeThings()) { - /* - * If the arena has a free list, it must be the same as one in - * lists. - */ - JS_ASSERT(aheader->getFirstFreeSpan().isSameNonEmptySpan(headSpan)); - return true; - } - return false; - } - - JS_ALWAYS_INLINE void *allocateFromFreeList(AllocKind thingKind, size_t thingSize) { - return freeLists[thingKind].allocate(thingSize); - } - - static void *refillFreeList(JSContext *cx, AllocKind thingKind); - - void checkEmptyFreeLists() { -#ifdef DEBUG - for (size_t i = 0; i < mozilla::ArrayLength(freeLists); ++i) - JS_ASSERT(freeLists[i].isEmpty()); -#endif - } - - void checkEmptyFreeList(AllocKind kind) { - JS_ASSERT(freeLists[kind].isEmpty()); - } - - void finalizeObjects(JSContext *cx); - void finalizeStrings(JSContext *cx); - void finalizeShapes(JSContext *cx); - void finalizeScripts(JSContext *cx); - -#ifdef JS_THREADSAFE - static void backgroundFinalize(JSContext *cx, ArenaHeader *listHead); -#endif - - private: - inline void finalizeNow(JSContext *cx, AllocKind thingKind); - inline void finalizeLater(JSContext *cx, AllocKind thingKind); - - inline void *allocateFromArena(JSCompartment *comp, AllocKind thingKind); -}; - -/* - * Initial allocation size for data structures holding chunks is set to hold - * chunks with total capacity of 16MB to avoid buffer resizes during browser - * startup. - */ -const size_t INITIAL_CHUNK_CAPACITY = 16 * 1024 * 1024 / ChunkSize; - -/* The number of GC cycles an empty chunk can survive before been released. */ -const size_t MAX_EMPTY_CHUNK_AGE = 4; - -inline Cell * -AsCell(JSObject *obj) -{ - return reinterpret_cast(obj); -} - -} /* namespace gc */ - -struct GCPtrHasher -{ - typedef void *Lookup; - - static HashNumber hash(void *key) { - return HashNumber(uintptr_t(key) >> JS_GCTHING_ZEROBITS); - } - - static bool match(void *l, void *k) { return l == k; } -}; - -typedef HashMap GCLocks; - -struct RootInfo { - RootInfo() {} - RootInfo(const char *name, JSGCRootType type) : name(name), type(type) {} - const char *name; - JSGCRootType type; -}; - -typedef js::HashMap, - js::SystemAllocPolicy> RootedValueMap; - -} /* namespace js */ - -extern JS_FRIEND_API(JSGCTraceKind) -js_GetGCThingTraceKind(void *thing); - -extern JSBool -js_InitGC(JSRuntime *rt, uint32_t maxbytes); - -extern void -js_FinishGC(JSRuntime *rt); - -extern JSBool -js_AddRoot(JSContext *cx, js::Value *vp, const char *name); - -extern JSBool -js_AddGCThingRoot(JSContext *cx, void **rp, const char *name); - -#ifdef DEBUG -extern void -js_DumpNamedRoots(JSRuntime *rt, - void (*dump)(const char *name, void *rp, JSGCRootType type, void *data), - void *data); -#endif - -extern uint32_t -js_MapGCRoots(JSRuntime *rt, JSGCRootMapFun map, void *data); - -/* Table of pointers with count valid members. */ -typedef struct JSPtrTable { - size_t count; - void **array; -} JSPtrTable; - -extern JSBool -js_LockGCThingRT(JSRuntime *rt, void *thing); - -extern void -js_UnlockGCThingRT(JSRuntime *rt, void *thing); - -extern JS_FRIEND_API(bool) -IsAboutToBeFinalized(const js::gc::Cell *thing); - -extern bool -IsAboutToBeFinalized(const js::Value &value); - -extern bool -js_IsAddressableGCThing(JSRuntime *rt, uintptr_t w, js::gc::AllocKind *thingKind, void **thing); - -namespace js { - -extern void -MarkCompartmentActive(js::StackFrame *fp); - -extern void -TraceRuntime(JSTracer *trc); - -extern JS_FRIEND_API(void) -MarkContext(JSTracer *trc, JSContext *acx); - -/* Must be called with GC lock taken. */ -extern void -TriggerGC(JSRuntime *rt, js::gcreason::Reason reason); - -/* Must be called with GC lock taken. */ -extern void -TriggerCompartmentGC(JSCompartment *comp, js::gcreason::Reason reason); - -extern void -MaybeGC(JSContext *cx); - -extern void -ShrinkGCBuffers(JSRuntime *rt); - -/* - * Kinds of js_GC invocation. - */ -typedef enum JSGCInvocationKind { - /* Normal invocation. */ - GC_NORMAL = 0, - - /* Minimize GC triggers and release empty GC chunks right away. */ - GC_SHRINK = 1 -} JSGCInvocationKind; - -/* Pass NULL for |comp| to get a full GC. */ -extern void -GC(JSContext *cx, JSCompartment *comp, JSGCInvocationKind gckind, js::gcreason::Reason reason); - -extern void -GCSlice(JSContext *cx, JSCompartment *comp, JSGCInvocationKind gckind, js::gcreason::Reason reason); - -extern void -GCDebugSlice(JSContext *cx, int64_t objCount); - -} /* namespace js */ - -namespace js { - -void -InitTracer(JSTracer *trc, JSRuntime *rt, JSTraceCallback callback); - -#ifdef JS_THREADSAFE - -class GCHelperThread { - enum State { - IDLE, - SWEEPING, - ALLOCATING, - CANCEL_ALLOCATION, - SHUTDOWN - }; - - /* - * During the finalization we do not free immediately. Rather we add the - * corresponding pointers to a buffer which we later release on a - * separated thread. - * - * The buffer is implemented as a vector of 64K arrays of pointers, not as - * a simple vector, to avoid realloc calls during the vector growth and to - * not bloat the binary size of the inlined freeLater method. Any OOM - * during buffer growth results in the pointer being freed immediately. - */ - static const size_t FREE_ARRAY_SIZE = size_t(1) << 16; - static const size_t FREE_ARRAY_LENGTH = FREE_ARRAY_SIZE / sizeof(void *); - - JSRuntime *const rt; - PRThread *thread; - PRCondVar *wakeup; - PRCondVar *done; - volatile State state; - - JSContext *finalizationContext; - bool shrinkFlag; - - Vector freeVector; - void **freeCursor; - void **freeCursorEnd; - - Vector finalizeVector; - - bool backgroundAllocation; - - friend struct js::gc::ArenaLists; - - JS_FRIEND_API(void) - replenishAndFreeLater(void *ptr); - - static void freeElementsAndArray(void **array, void **end) { - JS_ASSERT(array <= end); - for (void **p = array; p != end; ++p) - js::Foreground::free_(*p); - js::Foreground::free_(array); - } - - static void threadMain(void* arg); - void threadLoop(); - - /* Must be called with the GC lock taken. */ - void doSweep(); - - public: - GCHelperThread(JSRuntime *rt) - : rt(rt), - thread(NULL), - wakeup(NULL), - done(NULL), - state(IDLE), - finalizationContext(NULL), - shrinkFlag(false), - freeCursor(NULL), - freeCursorEnd(NULL), - backgroundAllocation(true) - { } - - bool init(); - void finish(); - - /* Must be called with the GC lock taken. */ - void startBackgroundSweep(JSContext *cx, bool shouldShrink); - - /* Must be called with the GC lock taken. */ - void startBackgroundShrink(); - - /* Must be called with the GC lock taken. */ - void waitBackgroundSweepEnd(); - - /* Must be called with the GC lock taken. */ - void waitBackgroundSweepOrAllocEnd(); - - /* Must be called with the GC lock taken. */ - inline void startBackgroundAllocationIfIdle(); - - bool canBackgroundAllocate() const { - return backgroundAllocation; - } - - void disableBackgroundAllocation() { - backgroundAllocation = false; - } - - PRThread *getThread() const { - return thread; - } - - /* - * Outside the GC lock may give true answer when in fact the sweeping has - * been done. - */ - bool sweeping() const { - return state == SWEEPING; - } - - bool shouldShrink() const { - JS_ASSERT(sweeping()); - return shrinkFlag; - } - - void freeLater(void *ptr) { - JS_ASSERT(!sweeping()); - if (freeCursor != freeCursorEnd) - *freeCursor++ = ptr; - else - replenishAndFreeLater(ptr); - } - - /* Must be called with the GC lock taken. */ - bool prepareForBackgroundSweep(); -}; - -#endif /* JS_THREADSAFE */ - -struct GCChunkHasher { - typedef gc::Chunk *Lookup; - - /* - * Strip zeros for better distribution after multiplying by the golden - * ratio. - */ - static HashNumber hash(gc::Chunk *chunk) { - JS_ASSERT(!(uintptr_t(chunk) & gc::ChunkMask)); - return HashNumber(uintptr_t(chunk) >> gc::ChunkShift); - } - - static bool match(gc::Chunk *k, gc::Chunk *l) { - JS_ASSERT(!(uintptr_t(k) & gc::ChunkMask)); - JS_ASSERT(!(uintptr_t(l) & gc::ChunkMask)); - return k == l; - } -}; - -typedef HashSet GCChunkSet; - -template -struct MarkStack { - T *stack; - T *tos; - T *limit; - - T *ballast; - T *ballastLimit; - - size_t sizeLimit; - - MarkStack(size_t sizeLimit) - : stack(NULL), - tos(NULL), - limit(NULL), - ballast(NULL), - ballastLimit(NULL), - sizeLimit(sizeLimit) { } - - ~MarkStack() { - if (stack != ballast) - js_free(stack); - js_free(ballast); - } - - bool init(size_t ballastcap) { - JS_ASSERT(!stack); - - if (ballastcap == 0) - return true; - - ballast = (T *)js_malloc(sizeof(T) * ballastcap); - if (!ballast) - return false; - ballastLimit = ballast + ballastcap; - initFromBallast(); - return true; - } - - void initFromBallast() { - stack = ballast; - limit = ballastLimit; - if (size_t(limit - stack) > sizeLimit) - limit = stack + sizeLimit; - tos = stack; - } - - void setSizeLimit(size_t size) { - JS_ASSERT(isEmpty()); - - sizeLimit = size; - reset(); - } - - bool push(T item) { - if (tos == limit) { - if (!enlarge()) - return false; - } - JS_ASSERT(tos < limit); - *tos++ = item; - return true; - } - - bool push(T item1, T item2, T item3) { - T *nextTos = tos + 3; - if (nextTos > limit) { - if (!enlarge()) - return false; - nextTos = tos + 3; - } - JS_ASSERT(nextTos <= limit); - tos[0] = item1; - tos[1] = item2; - tos[2] = item3; - tos = nextTos; - return true; - } - - bool isEmpty() const { - return tos == stack; - } - - T pop() { - JS_ASSERT(!isEmpty()); - return *--tos; - } - - ptrdiff_t position() const { - return tos - stack; - } - - void reset() { - if (stack != ballast) - js_free(stack); - initFromBallast(); - JS_ASSERT(stack == ballast); - } - - bool enlarge() { - size_t tosIndex = tos - stack; - size_t cap = limit - stack; - if (cap == sizeLimit) - return false; - size_t newcap = cap * 2; - if (newcap == 0) - newcap = 32; - if (newcap > sizeLimit) - newcap = sizeLimit; - - T *newStack; - if (stack == ballast) { - newStack = (T *)js_malloc(sizeof(T) * newcap); - if (!newStack) - return false; - for (T *src = stack, *dst = newStack; src < tos; ) - *dst++ = *src++; - } else { - newStack = (T *)js_realloc(stack, sizeof(T) * newcap); - if (!newStack) - return false; - } - stack = newStack; - tos = stack + tosIndex; - limit = newStack + newcap; - return true; - } - - size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const { - size_t n = 0; - if (stack != ballast) - n += mallocSizeOf(stack); - n += mallocSizeOf(ballast); - return n; - } -}; - -/* - * This class records how much work has been done in a given GC slice, so that - * we can return before pausing for too long. Some slices are allowed to run for - * unlimited time, and others are bounded. To reduce the number of gettimeofday - * calls, we only check the time every 1000 operations. - */ -struct SliceBudget { - int64_t deadline; /* in microseconds */ - intptr_t counter; - - static const intptr_t CounterReset = 1000; - - static const int64_t Unlimited = 0; - static int64_t TimeBudget(int64_t millis); - static int64_t WorkBudget(int64_t work); - - /* Equivalent to SliceBudget(UnlimitedBudget). */ - SliceBudget(); - - /* Instantiate as SliceBudget(Time/WorkBudget(n)). */ - SliceBudget(int64_t budget); - - void reset() { - deadline = INT64_MAX; - counter = INTPTR_MAX; - } - - void step() { - counter--; - } - - bool checkOverBudget(); - - bool isOverBudget() { - if (counter > 0) - return false; - return checkOverBudget(); - } -}; - -static const size_t MARK_STACK_LENGTH = 32768; - -struct GCMarker : public JSTracer { - private: - /* - * We use a common mark stack to mark GC things of different types and use - * the explicit tags to distinguish them when it cannot be deduced from - * the context of push or pop operation. - */ - enum StackTag { - ValueArrayTag, - ObjectTag, - TypeTag, - XmlTag, - SavedValueArrayTag, - LastTag = SavedValueArrayTag - }; - - static const uintptr_t StackTagMask = 7; - - static void staticAsserts() { - JS_STATIC_ASSERT(StackTagMask >= uintptr_t(LastTag)); - JS_STATIC_ASSERT(StackTagMask <= gc::Cell::CellMask); - } - - public: - explicit GCMarker(); - bool init(); - - void setSizeLimit(size_t size) { stack.setSizeLimit(size); } - size_t sizeLimit() const { return stack.sizeLimit; } - - void start(JSRuntime *rt); - void stop(); - void reset(); - - void pushObject(JSObject *obj) { - pushTaggedPtr(ObjectTag, obj); - } - - void pushType(types::TypeObject *type) { - pushTaggedPtr(TypeTag, type); - } - - void pushXML(JSXML *xml) { - pushTaggedPtr(XmlTag, xml); - } - - uint32_t getMarkColor() const { - return color; - } - - /* - * The only valid color transition during a GC is from black to gray. It is - * wrong to switch the mark color from gray to black. The reason is that the - * cycle collector depends on the invariant that there are no black to gray - * edges in the GC heap. This invariant lets the CC not trace through black - * objects. If this invariant is violated, the cycle collector may free - * objects that are still reachable. - */ - void setMarkColorGray() { - JS_ASSERT(isDrained()); - JS_ASSERT(color == gc::BLACK); - color = gc::GRAY; - } - - inline void delayMarkingArena(gc::ArenaHeader *aheader); - void delayMarkingChildren(const void *thing); - void markDelayedChildren(gc::ArenaHeader *aheader); - bool markDelayedChildren(SliceBudget &budget); - bool hasDelayedChildren() const { - return !!unmarkedArenaStackTop; - } - - bool isDrained() { - return isMarkStackEmpty() && !unmarkedArenaStackTop; - } - - bool drainMarkStack(SliceBudget &budget); - - /* - * Gray marking must be done after all black marking is complete. However, - * we do not have write barriers on XPConnect roots. Therefore, XPConnect - * roots must be accumulated in the first slice of incremental GC. We - * accumulate these roots in the GrayRootMarker and then mark them later, - * after black marking is complete. This accumulation can fail, but in that - * case we switch to non-incremental GC. - */ - bool hasBufferedGrayRoots() const; - void startBufferingGrayRoots(); - void endBufferingGrayRoots(); - void markBufferedGrayRoots(); - - static void GrayCallback(JSTracer *trc, void **thing, JSGCTraceKind kind); - - size_t sizeOfExcludingThis(JSMallocSizeOfFun mallocSizeOf) const; - - MarkStack stack; - - private: -#ifdef DEBUG - void checkCompartment(void *p); -#else - void checkCompartment(void *p) {} -#endif - - void pushTaggedPtr(StackTag tag, void *ptr) { - checkCompartment(ptr); - uintptr_t addr = reinterpret_cast(ptr); - JS_ASSERT(!(addr & StackTagMask)); - if (!stack.push(addr | uintptr_t(tag))) - delayMarkingChildren(ptr); - } - - void pushValueArray(JSObject *obj, void *start, void *end) { - checkCompartment(obj); - - if (start == end) - return; - - JS_ASSERT(start <= end); - uintptr_t tagged = reinterpret_cast(obj) | GCMarker::ValueArrayTag; - uintptr_t startAddr = reinterpret_cast(start); - uintptr_t endAddr = reinterpret_cast(end); - - /* - * Push in the reverse order so obj will be on top. If we cannot push - * the array, we trigger delay marking for the whole object. - */ - if (!stack.push(endAddr, startAddr, tagged)) - delayMarkingChildren(obj); - } - - bool isMarkStackEmpty() { - return stack.isEmpty(); - } - - bool restoreValueArray(JSObject *obj, void **vpp, void **endp); - void saveValueRanges(); - inline void processMarkStackTop(SliceBudget &budget); - - void appendGrayRoot(void *thing, JSGCTraceKind kind); - - /* The color is only applied to objects, functions and xml. */ - uint32_t color; - - DebugOnly started; - - /* Pointer to the top of the stack of arenas we are delaying marking on. */ - js::gc::ArenaHeader *unmarkedArenaStackTop; - /* Count of arenas that are currently in the stack. */ - DebugOnly markLaterArenas; - - struct GrayRoot { - void *thing; - JSGCTraceKind kind; -#ifdef DEBUG - JSTraceNamePrinter debugPrinter; - const void *debugPrintArg; - size_t debugPrintIndex; -#endif - - GrayRoot(void *thing, JSGCTraceKind kind) - : thing(thing), kind(kind) {} - }; - - bool grayFailed; - Vector grayRoots; -}; - -void -SetMarkStackLimit(JSRuntime *rt, size_t limit); - -void -MarkStackRangeConservatively(JSTracer *trc, Value *begin, Value *end); - -typedef void (*IterateChunkCallback)(JSRuntime *rt, void *data, gc::Chunk *chunk); -typedef void (*IterateArenaCallback)(JSRuntime *rt, void *data, gc::Arena *arena, - JSGCTraceKind traceKind, size_t thingSize); -typedef void (*IterateCellCallback)(JSRuntime *rt, void *data, void *thing, - JSGCTraceKind traceKind, size_t thingSize); - -/* - * This function calls |compartmentCallback| on every compartment, - * |arenaCallback| on every in-use arena, and |cellCallback| on every in-use - * cell in the GC heap. - */ -extern JS_FRIEND_API(void) -IterateCompartmentsArenasCells(JSRuntime *rt, void *data, - JSIterateCompartmentCallback compartmentCallback, - IterateArenaCallback arenaCallback, - IterateCellCallback cellCallback); - -/* - * Invoke chunkCallback on every in-use chunk. - */ -extern JS_FRIEND_API(void) -IterateChunks(JSRuntime *rt, void *data, IterateChunkCallback chunkCallback); - -/* - * Invoke cellCallback on every in-use object of the specified thing kind for - * the given compartment or for all compartments if it is null. - */ -extern JS_FRIEND_API(void) -IterateCells(JSRuntime *rt, JSCompartment *compartment, gc::AllocKind thingKind, - void *data, IterateCellCallback cellCallback); - -} /* namespace js */ - -extern void -js_FinalizeStringRT(JSRuntime *rt, JSString *str); - -/* - * Macro to test if a traversal is the marking phase of the GC. - */ -#define IS_GC_MARKING_TRACER(trc) \ - ((trc)->callback == NULL || (trc)->callback == GCMarker::GrayCallback) - -namespace js { -namespace gc { - -JSCompartment * -NewCompartment(JSContext *cx, JSPrincipals *principals); - -/* Tries to run a GC no matter what (used for GC zeal). */ -void -RunDebugGC(JSContext *cx); - -void -SetDeterministicGC(JSContext *cx, bool enabled); - -#if defined(JSGC_ROOT_ANALYSIS) && defined(DEBUG) && !defined(JS_THREADSAFE) -/* Overwrites stack references to GC things which have not been rooted. */ -void CheckStackRoots(JSContext *cx); - -inline void MaybeCheckStackRoots(JSContext *cx) { CheckStackRoots(cx); } -#else -inline void MaybeCheckStackRoots(JSContext *cx) {} -#endif - -const int ZealPokeValue = 1; -const int ZealAllocValue = 2; -const int ZealFrameGCValue = 3; -const int ZealVerifierValue = 4; -const int ZealFrameVerifierValue = 5; - -#ifdef JS_GC_ZEAL - -/* Check that write barriers have been used correctly. See jsgc.cpp. */ -void -VerifyBarriers(JSContext *cx); - -void -MaybeVerifyBarriers(JSContext *cx, bool always = false); - -#else - -static inline void -VerifyBarriers(JSContext *cx) -{ -} - -static inline void -MaybeVerifyBarriers(JSContext *cx, bool always = false) -{ -} - -#endif - -} /* namespace gc */ - -static inline JSCompartment * -GetObjectCompartment(JSObject *obj) { return reinterpret_cast(obj)->compartment(); } - -} /* namespace js */ - -#endif /* jsgc_h___ */ diff --git a/js/spidermonkey-win32/include/jshash.h b/js/spidermonkey-win32/include/jshash.h deleted file mode 100644 index acd64af4a9..0000000000 --- a/js/spidermonkey-win32/include/jshash.h +++ /dev/null @@ -1,153 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef jshash_h___ -#define jshash_h___ - -/* - * API to portable hash table code. - */ -#include -#include -#include "jstypes.h" - -JS_BEGIN_EXTERN_C - -typedef uint32_t JSHashNumber; -typedef struct JSHashEntry JSHashEntry; -typedef struct JSHashTable JSHashTable; - -#define JS_HASH_BITS 32 -#define JS_GOLDEN_RATIO 0x9E3779B9U - -typedef JSHashNumber (* JSHashFunction)(const void *key); -typedef int (* JSHashComparator)(const void *v1, const void *v2); -typedef int (* JSHashEnumerator)(JSHashEntry *he, int i, void *arg); - -/* Flag bits in JSHashEnumerator's return value */ -#define HT_ENUMERATE_NEXT 0 /* continue enumerating entries */ -#define HT_ENUMERATE_STOP 1 /* stop enumerating entries */ -#define HT_ENUMERATE_REMOVE 2 /* remove and free the current entry */ - -typedef struct JSHashAllocOps { - void * (*allocTable)(void *pool, size_t size); - void (*freeTable)(void *pool, void *item, size_t size); - JSHashEntry * (*allocEntry)(void *pool, const void *key); - void (*freeEntry)(void *pool, JSHashEntry *he, unsigned flag); -} JSHashAllocOps; - -#define HT_FREE_VALUE 0 /* just free the entry's value */ -#define HT_FREE_ENTRY 1 /* free value and entire entry */ - -struct JSHashEntry { - JSHashEntry *next; /* hash chain linkage */ - JSHashNumber keyHash; /* key hash function result */ - const void *key; /* ptr to opaque key */ - void *value; /* ptr to opaque value */ -}; - -struct JSHashTable { - JSHashEntry **buckets; /* vector of hash buckets */ - uint32_t nentries; /* number of entries in table */ - uint32_t shift; /* multiplicative hash shift */ - JSHashFunction keyHash; /* key hash function */ - JSHashComparator keyCompare; /* key comparison function */ - JSHashComparator valueCompare; /* value comparison function */ - JSHashAllocOps *allocOps; /* allocation operations */ - void *allocPriv; /* allocation private data */ -#ifdef JS_HASHMETER - uint32_t nlookups; /* total number of lookups */ - uint32_t nsteps; /* number of hash chains traversed */ - uint32_t ngrows; /* number of table expansions */ - uint32_t nshrinks; /* number of table contractions */ -#endif -}; - -/* - * Create a new hash table. - * If allocOps is null, use default allocator ops built on top of malloc(). - */ -extern JS_PUBLIC_API(JSHashTable *) -JS_NewHashTable(uint32_t n, JSHashFunction keyHash, - JSHashComparator keyCompare, JSHashComparator valueCompare, - JSHashAllocOps *allocOps, void *allocPriv); - -extern JS_PUBLIC_API(void) -JS_HashTableDestroy(JSHashTable *ht); - -/* Low level access methods */ -extern JS_PUBLIC_API(JSHashEntry **) -JS_HashTableRawLookup(JSHashTable *ht, JSHashNumber keyHash, const void *key); - -#ifdef __cplusplus -extern JS_PUBLIC_API(JSHashEntry *) -JS_HashTableRawAdd(JSHashTable *ht, JSHashEntry **&hep, JSHashNumber keyHash, - const void *key, void *value); -#endif - -extern JS_PUBLIC_API(void) -JS_HashTableRawRemove(JSHashTable *ht, JSHashEntry **hep, JSHashEntry *he); - -/* Higher level access methods */ -extern JS_PUBLIC_API(JSHashEntry *) -JS_HashTableAdd(JSHashTable *ht, const void *key, void *value); - -extern JS_PUBLIC_API(JSBool) -JS_HashTableRemove(JSHashTable *ht, const void *key); - -extern JS_PUBLIC_API(int) -JS_HashTableEnumerateEntries(JSHashTable *ht, JSHashEnumerator f, void *arg); - -extern JS_PUBLIC_API(void *) -JS_HashTableLookup(JSHashTable *ht, const void *key); - -extern JS_PUBLIC_API(int) -JS_HashTableDump(JSHashTable *ht, JSHashEnumerator dump, FILE *fp); - -/* General-purpose C string hash function. */ -extern JS_PUBLIC_API(JSHashNumber) -JS_HashString(const void *key); - -/* Stub function just returns v1 == v2 */ -extern JS_PUBLIC_API(int) -JS_CompareValues(const void *v1, const void *v2); - -JS_END_EXTERN_C - -#endif /* jshash_h___ */ diff --git a/js/spidermonkey-win32/include/jsinttypes.h b/js/spidermonkey-win32/include/jsinttypes.h new file mode 100644 index 0000000000..5f90eaaf7c --- /dev/null +++ b/js/spidermonkey-win32/include/jsinttypes.h @@ -0,0 +1,144 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released + * May 28, 2008. + * + * The Initial Developer of the Original Code is + * Jim Blandy + * Portions created by the Initial Developer are Copyright (C) 2009 + * the Initial Developer. All Rights Reserved. + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef jsinttypes_h___ +#define jsinttypes_h___ + +#include "js-config.h" + +/* + * Types: + * JSInt, JSUint (for = 8, 16, 32, and 64) + * JSIntPtr, JSUIntPtr + * + * JSInt and JSUint are signed and unsigned types known to be + * bits long. Note that neither JSInt8 nor JSUInt8 is necessarily + * equivalent to a plain "char". + * + * JSIntPtr and JSUintPtr are signed and unsigned types capable of + * holding an object pointer. + * + * Use these types in public SpiderMonkey header files, not the + * corresponding types from the C standard header. Windows + * doesn't support , and Microsoft says it has no plans to + * do so in the future; this means that projects that embed + * SpiderMonkey often take matters into their own hands and define the + * standard types themselves. If we define them in our public + * headers, our definitions may conflict with embedders' (see bug + * 479258). The JS* types are in our namespace, and can be used + * without troubling anyone. + * + * Internal SpiderMonkey code wishing to use the type names ISO C + * defines in the standard header can #include + * "jsstdint.h", which provides those types regardless of whether + * itself is available. + */ + +#if defined(JS_HAVE_STDINT_H) || \ + defined(JS_SYS_TYPES_H_DEFINES_EXACT_SIZE_TYPES) + +#if defined(JS_HAVE_STDINT_H) +#include +#else +#include +#endif + +typedef int8_t JSInt8; +typedef int16_t JSInt16; +typedef int32_t JSInt32; +typedef int64_t JSInt64; +typedef intptr_t JSIntPtr; + +typedef uint8_t JSUint8; +typedef uint16_t JSUint16; +typedef uint32_t JSUint32; +typedef uint64_t JSUint64; +typedef uintptr_t JSUintPtr; + +#else + +#if defined(JS_HAVE___INTN) + +typedef __int8 JSInt8; +typedef __int16 JSInt16; +typedef __int32 JSInt32; +typedef __int64 JSInt64; + +typedef unsigned __int8 JSUint8; +typedef unsigned __int16 JSUint16; +typedef unsigned __int32 JSUint32; +typedef unsigned __int64 JSUint64; + +#elif defined(JS_INT8_TYPE) + +typedef signed JS_INT8_TYPE JSInt8; +typedef signed JS_INT16_TYPE JSInt16; +typedef signed JS_INT32_TYPE JSInt32; +typedef signed JS_INT64_TYPE JSInt64; + +typedef unsigned JS_INT8_TYPE JSUint8; +typedef unsigned JS_INT16_TYPE JSUint16; +typedef unsigned JS_INT32_TYPE JSUint32; +typedef unsigned JS_INT64_TYPE JSUint64; + +#else +#error "couldn't find exact-width integer types" +#endif + +/* Microsoft Visual C/C++ defines intptr_t and uintptr_t in . */ +#if defined(JS_STDDEF_H_HAS_INTPTR_T) +#include +typedef intptr_t JSIntPtr; +typedef uintptr_t JSUintPtr; + +/* Windows Mobile defines intptr_t and uintptr_t in . Why not? */ +#elif defined(JS_CRTDEFS_H_HAS_INTPTR_T) +#include +typedef intptr_t JSIntPtr; +typedef uintptr_t JSUintPtr; + +/* Failing that, the configure script will have found something. */ +#elif defined(JS_INTPTR_TYPE) +typedef signed JS_INTPTR_TYPE JSIntPtr; +typedef unsigned JS_INTPTR_TYPE JSUintPtr; + +#else +#error "couldn't find pointer-sized integer types" +#endif + +#endif /* JS_HAVE_STDINT_H */ + +#endif /* jsinttypes_h___ */ diff --git a/js/spidermonkey-win32/include/jslock.h b/js/spidermonkey-win32/include/jslock.h deleted file mode 100644 index adbddd9d2b..0000000000 --- a/js/spidermonkey-win32/include/jslock.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ -#ifndef jslock_h__ -#define jslock_h__ - -#include "jsapi.h" - -#ifdef JS_THREADSAFE - -# include "pratom.h" -# include "prlock.h" -# include "prcvar.h" -# include "prthread.h" -# include "prinit.h" - -# define JS_ATOMIC_INCREMENT(p) PR_ATOMIC_INCREMENT((PRInt32 *)(p)) -# define JS_ATOMIC_DECREMENT(p) PR_ATOMIC_DECREMENT((PRInt32 *)(p)) -# define JS_ATOMIC_ADD(p,v) PR_ATOMIC_ADD((PRInt32 *)(p), (PRInt32)(v)) -# define JS_ATOMIC_SET(p,v) PR_ATOMIC_SET((PRInt32 *)(p), (PRInt32)(v)) - -#else /* JS_THREADSAFE */ - -# define JS_ATOMIC_INCREMENT(p) (++*(p)) -# define JS_ATOMIC_DECREMENT(p) (--*(p)) -# define JS_ATOMIC_ADD(p,v) (*(p) += (v)) -# define JS_ATOMIC_SET(p,v) (*(p) = (v)) - -#endif /* JS_THREADSAFE */ - -namespace js { - -class AutoAtomicIncrement -{ - int32_t *p; - JS_DECL_USE_GUARD_OBJECT_NOTIFIER - - public: - AutoAtomicIncrement(int32_t *p JS_GUARD_OBJECT_NOTIFIER_PARAM) - : p(p) { - JS_GUARD_OBJECT_NOTIFIER_INIT; - JS_ATOMIC_INCREMENT(p); - } - - ~AutoAtomicIncrement() { - JS_ATOMIC_DECREMENT(p); - } -}; - -} /* namespace js */ - -#endif /* jslock_h___ */ diff --git a/js/spidermonkey-win32/include/jslong.h b/js/spidermonkey-win32/include/jslong.h new file mode 100644 index 0000000000..4a1fccc9ea --- /dev/null +++ b/js/spidermonkey-win32/include/jslong.h @@ -0,0 +1,167 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* +** File: jslong.h +** Description: Portable access to 64 bit numerics +** +** Long-long (64-bit signed integer type) support. Some C compilers +** don't support 64 bit integers yet, so we use these macros to +** support both machines that do and don't. +**/ +#ifndef jslong_h___ +#define jslong_h___ + +#include "jstypes.h" + +JS_BEGIN_EXTERN_C + +#define JSLL_INIT(hi, lo) ((((JSInt64)(hi)) << 32) + (JSInt64)(lo)) + +/*********************************************************************** +** MACROS: JSLL_* +** DESCRIPTION: +** The following macros define portable access to the 64 bit +** math facilities. +** +***********************************************************************/ + +/*********************************************************************** +** MACROS: JSLL_ +** +** JSLL_IS_ZERO Test for zero +** JSLL_EQ Test for equality +** JSLL_NE Test for inequality +** JSLL_GE_ZERO Test for zero or positive +** JSLL_CMP Compare two values +***********************************************************************/ +#define JSLL_IS_ZERO(a) ((a) == 0) +#define JSLL_EQ(a, b) ((a) == (b)) +#define JSLL_NE(a, b) ((a) != (b)) +#define JSLL_GE_ZERO(a) ((a) >= 0) +#define JSLL_CMP(a, op, b) ((JSInt64)(a) op (JSInt64)(b)) +#define JSLL_UCMP(a, op, b) ((JSUint64)(a) op (JSUint64)(b)) + +/*********************************************************************** +** MACROS: JSLL_ +** +** JSLL_AND Logical and +** JSLL_OR Logical or +** JSLL_XOR Logical exclusion +** JSLL_OR2 A disgusting deviation +** JSLL_NOT Negation (one's compliment) +***********************************************************************/ +#define JSLL_AND(r, a, b) ((r) = (a) & (b)) +#define JSLL_OR(r, a, b) ((r) = (a) | (b)) +#define JSLL_XOR(r, a, b) ((r) = (a) ^ (b)) +#define JSLL_OR2(r, a) ((r) = (r) | (a)) +#define JSLL_NOT(r, a) ((r) = ~(a)) + +/*********************************************************************** +** MACROS: JSLL_ +** +** JSLL_NEG Negation (two's compliment) +** JSLL_ADD Summation (two's compliment) +** JSLL_SUB Difference (two's compliment) +***********************************************************************/ +#define JSLL_NEG(r, a) ((r) = -(a)) +#define JSLL_ADD(r, a, b) ((r) = (a) + (b)) +#define JSLL_SUB(r, a, b) ((r) = (a) - (b)) + +/*********************************************************************** +** MACROS: JSLL_ +** +** JSLL_MUL Product (two's compliment) +** JSLL_DIV Quotient (two's compliment) +** JSLL_MOD Modulus (two's compliment) +***********************************************************************/ +#define JSLL_MUL(r, a, b) ((r) = (a) * (b)) +#define JSLL_DIV(r, a, b) ((r) = (a) / (b)) +#define JSLL_MOD(r, a, b) ((r) = (a) % (b)) + +/*********************************************************************** +** MACROS: JSLL_ +** +** JSLL_SHL Shift left [0..64] bits +** JSLL_SHR Shift right [0..64] bits with sign extension +** JSLL_USHR Unsigned shift right [0..64] bits +** JSLL_ISHL Signed shift left [0..64] bits +***********************************************************************/ +#define JSLL_SHL(r, a, b) ((r) = (JSInt64)(a) << (b)) +#define JSLL_SHR(r, a, b) ((r) = (JSInt64)(a) >> (b)) +#define JSLL_USHR(r, a, b) ((r) = (JSUint64)(a) >> (b)) +#define JSLL_ISHL(r, a, b) ((r) = (JSInt64)(a) << (b)) + +/*********************************************************************** +** MACROS: JSLL_ +** +** JSLL_L2I Convert to signed 32 bit +** JSLL_L2UI Convert to unsigned 32 bit +** JSLL_L2F Convert to floating point +** JSLL_L2D Convert to floating point +** JSLL_I2L Convert signed to 64 bit +** JSLL_UI2L Convert unsigned to 64 bit +** JSLL_F2L Convert float to 64 bit +** JSLL_D2L Convert float to 64 bit +***********************************************************************/ +#define JSLL_L2I(i, l) ((i) = (JSInt32)(l)) +#define JSLL_L2UI(ui, l) ((ui) = (JSUint32)(l)) +#define JSLL_L2F(f, l) ((f) = (JSFloat64)(l)) +#define JSLL_L2D(d, l) ((d) = (JSFloat64)(l)) + +#define JSLL_I2L(l, i) ((l) = (JSInt64)(i)) +#define JSLL_UI2L(l, ui) ((l) = (JSInt64)(ui)) +#define JSLL_F2L(l, f) ((l) = (JSInt64)(f)) +#define JSLL_D2L(l, d) ((l) = (JSInt64)(d)) + +/*********************************************************************** +** MACROS: JSLL_UDIVMOD +** DESCRIPTION: +** Produce both a quotient and a remainder given an unsigned +** INPUTS: JSUint64 a: The dividend of the operation +** JSUint64 b: The quotient of the operation +** OUTPUTS: JSUint64 *qp: pointer to quotient +** JSUint64 *rp: pointer to remainder +***********************************************************************/ +#define JSLL_UDIVMOD(qp, rp, a, b) \ + (*(qp) = ((JSUint64)(a) / (b)), \ + *(rp) = ((JSUint64)(a) % (b))) + +JS_END_EXTERN_C + +#endif /* jslong_h___ */ diff --git a/js/spidermonkey-win32/include/jsotypes.h b/js/spidermonkey-win32/include/jsotypes.h new file mode 100644 index 0000000000..bfc85ccc23 --- /dev/null +++ b/js/spidermonkey-win32/include/jsotypes.h @@ -0,0 +1,198 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * This section typedefs the old 'native' types to the new PRs. + * These definitions are scheduled to be eliminated at the earliest + * possible time. The NSPR API is implemented and documented using + * the new definitions. + */ + +/* + * Note that we test for PROTYPES_H, not JSOTYPES_H. This is to avoid + * double-definitions of scalar types such as uint32, if NSPR's + * protypes.h is also included. + */ +#ifndef PROTYPES_H +#define PROTYPES_H + +#ifdef XP_BEOS +/* BeOS defines most int types in SupportDefs.h (int8, uint8, int16, + * uint16, int32, uint32, int64, uint64), so in the interest of + * not conflicting with other definitions elsewhere we have to skip the + * #ifdef jungle below, duplicate some definitions, and do our stuff. + */ +#include + +typedef JSUintn uintn; +#ifndef _XP_Core_ +typedef JSIntn intn; +#endif + +#else + +/* SVR4 typedef of uint is commonly found on UNIX machines. */ +#ifdef XP_UNIX +#include +#else +typedef JSUintn uint; +#endif + +typedef JSUintn uintn; +typedef JSUint64 uint64; +typedef JSUint32 uint32; +typedef JSUint16 uint16; +typedef JSUint8 uint8; + +#ifndef _XP_Core_ +typedef JSIntn intn; +#endif + +/* + * On AIX 4.3, sys/inttypes.h (which is included by sys/types.h, a very + * common header file) defines the types int8, int16, int32, and int64. + * So we don't define these four types here to avoid conflicts in case + * the code also includes sys/types.h. + */ +#if defined(AIX) && defined(HAVE_SYS_INTTYPES_H) +#include +#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) +typedef JSInt64 int64; + +/* Explicit signed keyword for bitfield types is required. */ +/* Some compilers may treat them as unsigned without it. */ +typedef signed int int32; +typedef signed short int16; +typedef signed char int8; +#else +typedef JSInt64 int64; + +/* /usr/include/model.h on HP-UX defines int8, int16, and int32 */ +typedef JSInt32 int32; +typedef JSInt16 int16; +typedef JSInt8 int8; +#endif /* AIX && HAVE_SYS_INTTYPES_H */ + +#endif /* XP_BEOS */ + +typedef JSFloat64 float64; + +/* Re: jsbit.h */ +#define TEST_BIT JS_TEST_BIT +#define SET_BIT JS_SET_BIT +#define CLEAR_BIT JS_CLEAR_BIT + +/* Re: prarena.h->plarena.h */ +#define PRArena PLArena +#define PRArenaPool PLArenaPool +#define PRArenaStats PLArenaStats +#define PR_ARENA_ALIGN PL_ARENA_ALIGN +#define PR_INIT_ARENA_POOL PL_INIT_ARENA_POOL +#define PR_ARENA_ALLOCATE PL_ARENA_ALLOCATE +#define PR_ARENA_GROW PL_ARENA_GROW +#define PR_ARENA_MARK PL_ARENA_MARK +#define PR_CLEAR_UNUSED PL_CLEAR_UNUSED +#define PR_CLEAR_ARENA PL_CLEAR_ARENA +#define PR_ARENA_RELEASE PL_ARENA_RELEASE +#define PR_COUNT_ARENA PL_COUNT_ARENA +#define PR_ARENA_DESTROY PL_ARENA_DESTROY +#define PR_InitArenaPool PL_InitArenaPool +#define PR_FreeArenaPool PL_FreeArenaPool +#define PR_FinishArenaPool PL_FinishArenaPool +#define PR_CompactArenaPool PL_CompactArenaPool +#define PR_ArenaFinish PL_ArenaFinish +#define PR_ArenaAllocate PL_ArenaAllocate +#define PR_ArenaGrow PL_ArenaGrow +#define PR_ArenaRelease PL_ArenaRelease +#define PR_ArenaCountAllocation PL_ArenaCountAllocation +#define PR_ArenaCountInplaceGrowth PL_ArenaCountInplaceGrowth +#define PR_ArenaCountGrowth PL_ArenaCountGrowth +#define PR_ArenaCountRelease PL_ArenaCountRelease +#define PR_ArenaCountRetract PL_ArenaCountRetract + +/* Re: prevent.h->plevent.h */ +#define PREvent PLEvent +#define PREventQueue PLEventQueue +#define PR_CreateEventQueue PL_CreateEventQueue +#define PR_DestroyEventQueue PL_DestroyEventQueue +#define PR_GetEventQueueMonitor PL_GetEventQueueMonitor +#define PR_ENTER_EVENT_QUEUE_MONITOR PL_ENTER_EVENT_QUEUE_MONITOR +#define PR_EXIT_EVENT_QUEUE_MONITOR PL_EXIT_EVENT_QUEUE_MONITOR +#define PR_PostEvent PL_PostEvent +#define PR_PostSynchronousEvent PL_PostSynchronousEvent +#define PR_GetEvent PL_GetEvent +#define PR_EventAvailable PL_EventAvailable +#define PREventFunProc PLEventFunProc +#define PR_MapEvents PL_MapEvents +#define PR_RevokeEvents PL_RevokeEvents +#define PR_ProcessPendingEvents PL_ProcessPendingEvents +#define PR_WaitForEvent PL_WaitForEvent +#define PR_EventLoop PL_EventLoop +#define PR_GetEventQueueSelectFD PL_GetEventQueueSelectFD +#define PRHandleEventProc PLHandleEventProc +#define PRDestroyEventProc PLDestroyEventProc +#define PR_InitEvent PL_InitEvent +#define PR_GetEventOwner PL_GetEventOwner +#define PR_HandleEvent PL_HandleEvent +#define PR_DestroyEvent PL_DestroyEvent +#define PR_DequeueEvent PL_DequeueEvent +#define PR_GetMainEventQueue PL_GetMainEventQueue + +/* Re: prhash.h->plhash.h */ +#define PRHashEntry PLHashEntry +#define PRHashTable PLHashTable +#define PRHashNumber PLHashNumber +#define PRHashFunction PLHashFunction +#define PRHashComparator PLHashComparator +#define PRHashEnumerator PLHashEnumerator +#define PRHashAllocOps PLHashAllocOps +#define PR_NewHashTable PL_NewHashTable +#define PR_HashTableDestroy PL_HashTableDestroy +#define PR_HashTableRawLookup PL_HashTableRawLookup +#define PR_HashTableRawAdd PL_HashTableRawAdd +#define PR_HashTableRawRemove PL_HashTableRawRemove +#define PR_HashTableAdd PL_HashTableAdd +#define PR_HashTableRemove PL_HashTableRemove +#define PR_HashTableEnumerateEntries PL_HashTableEnumerateEntries +#define PR_HashTableLookup PL_HashTableLookup +#define PR_HashTableDump PL_HashTableDump +#define PR_HashString PL_HashString +#define PR_CompareStrings PL_CompareStrings +#define PR_CompareValues PL_CompareValues + +#endif /* !defined(PROTYPES_H) */ diff --git a/js/spidermonkey-win32/include/jsperf.h b/js/spidermonkey-win32/include/jsperf.h deleted file mode 100644 index 4321cc7588..0000000000 --- a/js/spidermonkey-win32/include/jsperf.h +++ /dev/null @@ -1,163 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * the Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Zack Weinberg (original author) - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef jsperf_h___ -#define jsperf_h___ - -#include "jsapi.h" - -namespace JS { - -/* - * JS::PerfMeasurement is a generic way to access detailed performance - * measurement APIs provided by your operating system. The details of - * exactly how this works and what can be measured are highly - * system-specific, but this interface is (one hopes) implementable - * on top of all of them. - * - * To use this API, create a PerfMeasurement object, passing its - * constructor a bitmask indicating which events you are interested - * in. Thereafter, Start() zeroes all counters and starts timing; - * Stop() stops timing again; and the counters for the events you - * requested are available as data values after calling Stop(). The - * object may be reused for many measurements. - */ -class JS_FRIEND_API(PerfMeasurement) -{ - protected: - // Implementation-specific data, if any. - void* impl; - - public: - /* - * Events that may be measured. Taken directly from the list of - * "generalized hardware performance event types" in the Linux - * perf_event API, plus some of the "software events". - */ - enum EventMask { - CPU_CYCLES = 0x00000001, - INSTRUCTIONS = 0x00000002, - CACHE_REFERENCES = 0x00000004, - CACHE_MISSES = 0x00000008, - BRANCH_INSTRUCTIONS = 0x00000010, - BRANCH_MISSES = 0x00000020, - BUS_CYCLES = 0x00000040, - PAGE_FAULTS = 0x00000080, - MAJOR_PAGE_FAULTS = 0x00000100, - CONTEXT_SWITCHES = 0x00000200, - CPU_MIGRATIONS = 0x00000400, - - ALL = 0x000007ff, - NUM_MEASURABLE_EVENTS = 11 - }; - - /* - * Bitmask of events that will be measured when this object is - * active (between Start() and Stop()). This may differ from the - * bitmask passed to the constructor if the platform does not - * support measuring all of the requested events. - */ - const EventMask eventsMeasured; - - /* - * Counters for each measurable event. - * Immediately after one of these objects is created, all of the - * counters for enabled events will be zero, and all of the - * counters for disabled events will be uint64_t(-1). - */ - uint64_t cpu_cycles; - uint64_t instructions; - uint64_t cache_references; - uint64_t cache_misses; - uint64_t branch_instructions; - uint64_t branch_misses; - uint64_t bus_cycles; - uint64_t page_faults; - uint64_t major_page_faults; - uint64_t context_switches; - uint64_t cpu_migrations; - - /* - * Prepare to measure the indicated set of events. If not all of - * the requested events can be measured on the current platform, - * then the eventsMeasured bitmask will only include the subset of - * |toMeasure| corresponding to the events that can be measured. - */ - PerfMeasurement(EventMask toMeasure); - - /* Done with this set of measurements, tear down OS-level state. */ - ~PerfMeasurement(); - - /* Start a measurement cycle. */ - void start(); - - /* - * End a measurement cycle, and for each enabled counter, add the - * number of measured events of that type to the appropriate - * visible variable. - */ - void stop(); - - /* Reset all enabled counters to zero. */ - void reset(); - - /* - * True if this platform supports measuring _something_, i.e. it's - * not using the stub implementation. - */ - static bool canMeasureSomething(); -}; - -/* Inject a Javascript wrapper around the above C++ class into the - * Javascript object passed as an argument (this will normally be a - * global object). The JS-visible API is identical to the C++ API. - */ -extern JS_FRIEND_API(JSObject*) - RegisterPerfMeasurement(JSContext *cx, JSObject *global); - -/* - * Given a jsval which contains an instance of the aforementioned - * wrapper class, extract the C++ object. Returns NULL if the - * jsval is not an instance of the wrapper. - */ -extern JS_FRIEND_API(PerfMeasurement*) - ExtractPerfMeasurement(jsval wrapper); - -} // namespace JS - -#endif // jsperf_h___ diff --git a/js/spidermonkey-win32/include/jsprf.h b/js/spidermonkey-win32/include/jsprf.h deleted file mode 100644 index 9efbd64131..0000000000 --- a/js/spidermonkey-win32/include/jsprf.h +++ /dev/null @@ -1,115 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef jsprf_h___ -#define jsprf_h___ - -/* -** API for PR printf like routines. Supports the following formats -** %d - decimal -** %u - unsigned decimal -** %x - unsigned hex -** %X - unsigned uppercase hex -** %o - unsigned octal -** %hd, %hu, %hx, %hX, %ho - 16-bit versions of above -** %ld, %lu, %lx, %lX, %lo - 32-bit versions of above -** %lld, %llu, %llx, %llX, %llo - 64 bit versions of above -** %s - string -** %hs - 16-bit version of above (only available if js_CStringsAreUTF8) -** %c - character -** %hc - 16-bit version of above (only available if js_CStringsAreUTF8) -** %p - pointer (deals with machine dependent pointer size) -** %f - float -** %g - float -*/ -#include "jstypes.h" -#include -#include - -JS_BEGIN_EXTERN_C - -/* -** sprintf into a fixed size buffer. Guarantees that a NUL is at the end -** of the buffer. Returns the length of the written output, NOT including -** the NUL, or (uint32_t)-1 if an error occurs. -*/ -extern JS_PUBLIC_API(uint32_t) JS_snprintf(char *out, uint32_t outlen, const char *fmt, ...); - -/* -** sprintf into a malloc'd buffer. Return a pointer to the malloc'd -** buffer on success, NULL on failure. Call "JS_smprintf_free" to release -** the memory returned. -*/ -extern JS_PUBLIC_API(char*) JS_smprintf(const char *fmt, ...); - -/* -** Free the memory allocated, for the caller, by JS_smprintf -*/ -extern JS_PUBLIC_API(void) JS_smprintf_free(char *mem); - -/* -** "append" sprintf into a malloc'd buffer. "last" is the last value of -** the malloc'd buffer. sprintf will append data to the end of last, -** growing it as necessary using realloc. If last is NULL, JS_sprintf_append -** will allocate the initial string. The return value is the new value of -** last for subsequent calls, or NULL if there is a malloc failure. -*/ -extern JS_PUBLIC_API(char*) JS_sprintf_append(char *last, const char *fmt, ...); - -/* -** sprintf into a function. The function "f" is called with a string to -** place into the output. "arg" is an opaque pointer used by the stuff -** function to hold any state needed to do the storage of the output -** data. The return value is a count of the number of characters fed to -** the stuff function, or (uint32_t)-1 if an error occurs. -*/ -typedef int (*JSStuffFunc)(void *arg, const char *s, uint32_t slen); - -extern JS_PUBLIC_API(uint32_t) JS_sxprintf(JSStuffFunc f, void *arg, const char *fmt, ...); - -/* -** va_list forms of the above. -*/ -extern JS_PUBLIC_API(uint32_t) JS_vsnprintf(char *out, uint32_t outlen, const char *fmt, va_list ap); -extern JS_PUBLIC_API(char*) JS_vsmprintf(const char *fmt, va_list ap); -extern JS_PUBLIC_API(char*) JS_vsprintf_append(char *last, const char *fmt, va_list ap); -extern JS_PUBLIC_API(uint32_t) JS_vsxprintf(JSStuffFunc f, void *arg, const char *fmt, va_list ap); - -JS_END_EXTERN_C - -#endif /* jsprf_h___ */ diff --git a/js/spidermonkey-win32/include/jsproto.tbl b/js/spidermonkey-win32/include/jsproto.tbl index 20dbbd24a7..de7d0273aa 100644 --- a/js/spidermonkey-win32/include/jsproto.tbl +++ b/js/spidermonkey-win32/include/jsproto.tbl @@ -50,14 +50,20 @@ # define XMLFILTER_INIT js_InitNullClass #endif +#if JS_HAS_GENERATORS +# define GENERATOR_INIT js_InitIteratorClasses +#else +# define GENERATOR_INIT js_InitNullClass +#endif + /* * Enumerator codes in the second column must not change -- they are part of * the JS XDR API. Client modules including jsproto.tbl should consider * wrapping the inclusion with JS_BEGIN_EXTERN_C and JS_END_EXTERN_C. */ JS_PROTO(Null, 0, js_InitNullClass) -JS_PROTO(Object, 1, js_InitObjectClass) -JS_PROTO(Function, 2, js_InitFunctionClass) +JS_PROTO(Object, 1, js_InitFunctionAndObjectClasses) +JS_PROTO(Function, 2, js_InitFunctionAndObjectClasses) JS_PROTO(Array, 3, js_InitArrayClass) JS_PROTO(Boolean, 4, js_InitBooleanClass) JS_PROTO(JSON, 5, js_InitJSONClass) @@ -69,32 +75,33 @@ JS_PROTO(RegExp, 10, js_InitRegExpClass) JS_PROTO(XML, 11, XML_INIT) JS_PROTO(Namespace, 12, NAMESPACE_INIT) JS_PROTO(QName, 13, QNAME_INIT) -JS_PROTO(Error, 14, js_InitExceptionClasses) -JS_PROTO(InternalError, 15, js_InitExceptionClasses) -JS_PROTO(EvalError, 16, js_InitExceptionClasses) -JS_PROTO(RangeError, 17, js_InitExceptionClasses) -JS_PROTO(ReferenceError, 18, js_InitExceptionClasses) -JS_PROTO(SyntaxError, 19, js_InitExceptionClasses) -JS_PROTO(TypeError, 20, js_InitExceptionClasses) -JS_PROTO(URIError, 21, js_InitExceptionClasses) -JS_PROTO(Iterator, 22, js_InitIteratorClasses) -JS_PROTO(StopIteration, 23, js_InitIteratorClasses) -JS_PROTO(ArrayBuffer, 24, js_InitTypedArrayClasses) -JS_PROTO(Int8Array, 25, js_InitTypedArrayClasses) -JS_PROTO(Uint8Array, 26, js_InitTypedArrayClasses) -JS_PROTO(Int16Array, 27, js_InitTypedArrayClasses) -JS_PROTO(Uint16Array, 28, js_InitTypedArrayClasses) -JS_PROTO(Int32Array, 29, js_InitTypedArrayClasses) -JS_PROTO(Uint32Array, 30, js_InitTypedArrayClasses) -JS_PROTO(Float32Array, 31, js_InitTypedArrayClasses) -JS_PROTO(Float64Array, 32, js_InitTypedArrayClasses) -JS_PROTO(Uint8ClampedArray, 33, js_InitTypedArrayClasses) -JS_PROTO(Proxy, 34, js_InitProxyClass) -JS_PROTO(AnyName, 35, js_InitNullClass) -JS_PROTO(WeakMap, 36, js_InitWeakMapClass) -JS_PROTO(Map, 37, js_InitMapClass) -JS_PROTO(Set, 38, js_InitSetClass) +JS_PROTO(Reflect, 14, js_InitReflectClass) +JS_PROTO(ASTNode, 15, js_InitReflectClass) +JS_PROTO(Error, 16, js_InitExceptionClasses) +JS_PROTO(InternalError, 17, js_InitExceptionClasses) +JS_PROTO(EvalError, 18, js_InitExceptionClasses) +JS_PROTO(RangeError, 19, js_InitExceptionClasses) +JS_PROTO(ReferenceError, 20, js_InitExceptionClasses) +JS_PROTO(SyntaxError, 21, js_InitExceptionClasses) +JS_PROTO(TypeError, 22, js_InitExceptionClasses) +JS_PROTO(URIError, 23, js_InitExceptionClasses) +JS_PROTO(Generator, 24, GENERATOR_INIT) +JS_PROTO(Iterator, 25, js_InitIteratorClasses) +JS_PROTO(StopIteration, 26, js_InitIteratorClasses) +JS_PROTO(ArrayBuffer, 27, js_InitTypedArrayClasses) +JS_PROTO(Int8Array, 28, js_InitTypedArrayClasses) +JS_PROTO(Uint8Array, 29, js_InitTypedArrayClasses) +JS_PROTO(Int16Array, 30, js_InitTypedArrayClasses) +JS_PROTO(Uint16Array, 31, js_InitTypedArrayClasses) +JS_PROTO(Int32Array, 32, js_InitTypedArrayClasses) +JS_PROTO(Uint32Array, 33, js_InitTypedArrayClasses) +JS_PROTO(Float32Array, 34, js_InitTypedArrayClasses) +JS_PROTO(Float64Array, 35, js_InitTypedArrayClasses) +JS_PROTO(Uint8ClampedArray, 36, js_InitTypedArrayClasses) +JS_PROTO(Proxy, 37, js_InitProxyClass) +JS_PROTO(AnyName, 38, js_InitNullClass) #undef XML_INIT #undef NAMESPACE_INIT #undef QNAME_INIT +#undef GENERATOR_INIT diff --git a/js/spidermonkey-win32/include/jsproxy.h b/js/spidermonkey-win32/include/jsproxy.h deleted file mode 100644 index 8bcbad771a..0000000000 --- a/js/spidermonkey-win32/include/jsproxy.h +++ /dev/null @@ -1,224 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=4 sw=4 et tw=99: - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released - * May 28, 2008. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation - * Portions created by the Initial Developer are Copyright (C) 2009 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Andreas Gal - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef jsproxy_h___ -#define jsproxy_h___ - -#include "jsapi.h" -#include "jsfriendapi.h" - -namespace js { - -/* Base class for all C++ proxy handlers. */ -class JS_FRIEND_API(ProxyHandler) { - void *mFamily; - public: - explicit ProxyHandler(void *family); - virtual ~ProxyHandler(); - - /* ES5 Harmony fundamental proxy traps. */ - virtual bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set, - PropertyDescriptor *desc) = 0; - virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set, - PropertyDescriptor *desc) = 0; - virtual bool defineProperty(JSContext *cx, JSObject *proxy, jsid id, - PropertyDescriptor *desc) = 0; - virtual bool getOwnPropertyNames(JSContext *cx, JSObject *proxy, AutoIdVector &props) = 0; - virtual bool delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp) = 0; - virtual bool enumerate(JSContext *cx, JSObject *proxy, AutoIdVector &props) = 0; - virtual bool fix(JSContext *cx, JSObject *proxy, Value *vp) = 0; - - /* ES5 Harmony derived proxy traps. */ - virtual bool has(JSContext *cx, JSObject *proxy, jsid id, bool *bp); - virtual bool hasOwn(JSContext *cx, JSObject *proxy, jsid id, bool *bp); - virtual bool get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, Value *vp); - virtual bool set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, bool strict, - Value *vp); - virtual bool keys(JSContext *cx, JSObject *proxy, AutoIdVector &props); - virtual bool iterate(JSContext *cx, JSObject *proxy, unsigned flags, Value *vp); - - /* Spidermonkey extensions. */ - virtual bool call(JSContext *cx, JSObject *proxy, unsigned argc, Value *vp); - virtual bool construct(JSContext *cx, JSObject *proxy, unsigned argc, Value *argv, Value *rval); - virtual bool nativeCall(JSContext *cx, JSObject *proxy, Class *clasp, Native native, CallArgs args); - virtual bool hasInstance(JSContext *cx, JSObject *proxy, const Value *vp, bool *bp); - virtual JSType typeOf(JSContext *cx, JSObject *proxy); - virtual bool objectClassIs(JSObject *obj, ESClassValue classValue, JSContext *cx); - virtual JSString *obj_toString(JSContext *cx, JSObject *proxy); - virtual JSString *fun_toString(JSContext *cx, JSObject *proxy, unsigned indent); - virtual bool regexp_toShared(JSContext *cx, JSObject *proxy, RegExpGuard *g); - virtual bool defaultValue(JSContext *cx, JSObject *obj, JSType hint, Value *vp); - virtual bool iteratorNext(JSContext *cx, JSObject *proxy, Value *vp); - virtual void finalize(JSContext *cx, JSObject *proxy); - virtual void trace(JSTracer *trc, JSObject *proxy); - virtual bool getElementIfPresent(JSContext *cx, JSObject *obj, JSObject *receiver, - uint32_t index, Value *vp, bool *present); - - virtual bool isOuterWindow() { - return false; - } - - inline void *family() { - return mFamily; - } -}; - -/* Dispatch point for handlers that executes the appropriate C++ or scripted traps. */ -class Proxy { - public: - /* ES5 Harmony fundamental proxy traps. */ - static bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set, - PropertyDescriptor *desc); - static bool getPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set, Value *vp); - static bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set, - PropertyDescriptor *desc); - static bool getOwnPropertyDescriptor(JSContext *cx, JSObject *proxy, jsid id, bool set, - Value *vp); - static bool defineProperty(JSContext *cx, JSObject *proxy, jsid id, PropertyDescriptor *desc); - static bool defineProperty(JSContext *cx, JSObject *proxy, jsid id, const Value &v); - static bool getOwnPropertyNames(JSContext *cx, JSObject *proxy, AutoIdVector &props); - static bool delete_(JSContext *cx, JSObject *proxy, jsid id, bool *bp); - static bool enumerate(JSContext *cx, JSObject *proxy, AutoIdVector &props); - static bool fix(JSContext *cx, JSObject *proxy, Value *vp); - - /* ES5 Harmony derived proxy traps. */ - static bool has(JSContext *cx, JSObject *proxy, jsid id, bool *bp); - static bool hasOwn(JSContext *cx, JSObject *proxy, jsid id, bool *bp); - static bool get(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, Value *vp); - static bool getElementIfPresent(JSContext *cx, JSObject *proxy, JSObject *receiver, - uint32_t index, Value *vp, bool *present); - static bool set(JSContext *cx, JSObject *proxy, JSObject *receiver, jsid id, bool strict, - Value *vp); - static bool keys(JSContext *cx, JSObject *proxy, AutoIdVector &props); - static bool iterate(JSContext *cx, JSObject *proxy, unsigned flags, Value *vp); - - /* Spidermonkey extensions. */ - static bool call(JSContext *cx, JSObject *proxy, unsigned argc, Value *vp); - static bool construct(JSContext *cx, JSObject *proxy, unsigned argc, Value *argv, Value *rval); - static bool nativeCall(JSContext *cx, JSObject *proxy, Class *clasp, Native native, CallArgs args); - static bool hasInstance(JSContext *cx, JSObject *proxy, const Value *vp, bool *bp); - static JSType typeOf(JSContext *cx, JSObject *proxy); - static bool objectClassIs(JSObject *obj, ESClassValue classValue, JSContext *cx); - static JSString *obj_toString(JSContext *cx, JSObject *proxy); - static JSString *fun_toString(JSContext *cx, JSObject *proxy, unsigned indent); - static bool regexp_toShared(JSContext *cx, JSObject *proxy, RegExpGuard *g); - static bool defaultValue(JSContext *cx, JSObject *obj, JSType hint, Value *vp); - static bool iteratorNext(JSContext *cx, JSObject *proxy, Value *vp); -}; - -inline bool IsObjectProxyClass(const Class *clasp) -{ - return clasp == &js::ObjectProxyClass || clasp == &js::OuterWindowProxyClass; -} - -inline bool IsFunctionProxyClass(const Class *clasp) -{ - return clasp == &js::FunctionProxyClass; -} - -inline bool IsObjectProxy(const JSObject *obj) -{ - return IsObjectProxyClass(GetObjectClass(obj)); -} - -inline bool IsFunctionProxy(const JSObject *obj) -{ - return IsFunctionProxyClass(GetObjectClass(obj)); -} - -inline bool IsProxy(const JSObject *obj) -{ - Class *clasp = GetObjectClass(obj); - return IsObjectProxyClass(clasp) || IsFunctionProxyClass(clasp); -} - -/* Shared between object and function proxies. */ -const uint32_t JSSLOT_PROXY_HANDLER = 0; -const uint32_t JSSLOT_PROXY_PRIVATE = 1; -const uint32_t JSSLOT_PROXY_EXTRA = 2; -/* Function proxies only. */ -const uint32_t JSSLOT_PROXY_CALL = 4; -const uint32_t JSSLOT_PROXY_CONSTRUCT = 5; - -inline ProxyHandler * -GetProxyHandler(const JSObject *obj) -{ - JS_ASSERT(IsProxy(obj)); - return (ProxyHandler *) GetReservedSlot(obj, JSSLOT_PROXY_HANDLER).toPrivate(); -} - -inline const Value & -GetProxyPrivate(const JSObject *obj) -{ - JS_ASSERT(IsProxy(obj)); - return GetReservedSlot(obj, JSSLOT_PROXY_PRIVATE); -} - -inline const Value & -GetProxyExtra(const JSObject *obj, size_t n) -{ - JS_ASSERT(IsProxy(obj)); - return GetReservedSlot(obj, JSSLOT_PROXY_EXTRA + n); -} - -inline void -SetProxyExtra(JSObject *obj, size_t n, const Value &extra) -{ - JS_ASSERT(IsProxy(obj)); - JS_ASSERT(n <= 1); - SetReservedSlot(obj, JSSLOT_PROXY_EXTRA + n, extra); -} - -JS_FRIEND_API(JSObject *) -NewProxyObject(JSContext *cx, ProxyHandler *handler, const Value &priv, - JSObject *proto, JSObject *parent, - JSObject *call = NULL, JSObject *construct = NULL); - -} /* namespace js */ - -JS_BEGIN_EXTERN_C - -extern JS_FRIEND_API(JSObject *) -js_InitProxyClass(JSContext *cx, JSObject *obj); - -JS_END_EXTERN_C - -#endif diff --git a/js/spidermonkey-win32/include/jsprvtd.h b/js/spidermonkey-win32/include/jsprvtd.h deleted file mode 100644 index afa591ee98..0000000000 --- a/js/spidermonkey-win32/include/jsprvtd.h +++ /dev/null @@ -1,493 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef jsprvtd_h___ -#define jsprvtd_h___ -/* - * JS private typename definitions. - * - * This header is included only in other .h files, for convenience and for - * simplicity of type naming. The alternative for structures is to use tags, - * which are named the same as their typedef names (legal in C/C++, and less - * noisy than suffixing the typedef name with "Struct" or "Str"). Instead, - * all .h files that include this file may use the same typedef name, whether - * declaring a pointer to struct type, or defining a member of struct type. - * - * A few fundamental scalar types are defined here too. Neither the scalar - * nor the struct typedefs should change much, therefore the nearly-global - * make dependency induced by this file should not prove painful. - */ - -#include "jsapi.h" -#include "jsutil.h" - -#ifdef __cplusplus -#include "js/HashTable.h" -#include "js/Vector.h" -#endif - -JS_BEGIN_EXTERN_C - -/* - * Convenience constants. - */ -#define JS_BITS_PER_UINT32_LOG2 5 -#define JS_BITS_PER_UINT32 32 - -/* The alignment required of objects stored in GC arenas. */ -static const unsigned JS_GCTHING_ALIGN = 8; -static const unsigned JS_GCTHING_ZEROBITS = 3; - -/* Scalar typedefs. */ -typedef uint8_t jsbytecode; -typedef uint8_t jssrcnote; -typedef uintptr_t jsatomid; - -/* Struct typedefs. */ -typedef struct JSArgumentFormatMap JSArgumentFormatMap; -typedef struct JSGCThing JSGCThing; -typedef struct JSGenerator JSGenerator; -typedef struct JSNativeEnumerator JSNativeEnumerator; -typedef struct JSProperty JSProperty; -typedef struct JSSharpObjectMap JSSharpObjectMap; -typedef struct JSTryNote JSTryNote; - -/* Friend "Advanced API" typedefs. */ -typedef struct JSAtomState JSAtomState; -typedef struct JSCodeSpec JSCodeSpec; -typedef struct JSPrinter JSPrinter; -typedef struct JSStackHeader JSStackHeader; -typedef struct JSSubString JSSubString; -typedef struct JSSpecializedNative JSSpecializedNative; -typedef struct JSXML JSXML; - -/* - * Template declarations. - * - * jsprvtd.h can be included in both C and C++ translation units. For C++, it - * may possibly be wrapped in an extern "C" block which does not agree with - * templates. - */ -#ifdef __cplusplus - -extern "C++" { - -class JSDependentString; -class JSExtensibleString; -class JSExternalString; -class JSLinearString; -class JSFixedString; -class JSStaticAtom; -class JSRope; -class JSAtom; -class JSWrapper; - -namespace js { - -struct ArgumentsData; -struct Class; - -class RegExpGuard; -class RegExpObject; -class RegExpObjectBuilder; -class RegExpShared; -class RegExpStatics; -class MatchPairs; - -namespace detail { class RegExpCode; } - -enum RegExpFlag -{ - IgnoreCaseFlag = 0x01, - GlobalFlag = 0x02, - MultilineFlag = 0x04, - StickyFlag = 0x08, - - NoFlags = 0x00, - AllFlags = 0x0f -}; - -enum RegExpExecType -{ - RegExpExec, - RegExpTest -}; - -class ExecuteArgsGuard; -class InvokeFrameGuard; -class InvokeArgsGuard; -class StringBuffer; - -class FrameRegs; -class StackFrame; -class StackSegment; -class StackSpace; -class ContextStack; -class FrameRegsIter; -class CallReceiver; -class CallArgs; - -struct BytecodeEmitter; -struct Definition; -struct FunctionBox; -struct ObjectBox; -struct ParseNode; -struct Parser; -class TokenStream; -struct Token; -struct TokenPos; -struct TokenPtr; -struct TreeContext; -class UpvarCookie; - -class Proxy; -class ProxyHandler; -class Wrapper; -class CrossCompartmentWrapper; - -class TempAllocPolicy; -class RuntimeAllocPolicy; - -class GlobalObject; - -template -class InlineMap; - -class LifoAlloc; - -class BaseShape; -class UnownedBaseShape; -struct Shape; -struct EmptyShape; -class ShapeKindArray; -class Bindings; - -struct StackBaseShape; -struct StackShape; - -class MultiDeclRange; -class ParseMapPool; -class DefnOrHeader; -typedef InlineMap AtomDefnMap; -typedef InlineMap AtomIndexMap; -typedef InlineMap AtomDOHMap; -typedef Vector UpvarCookies; - -class Breakpoint; -class BreakpointSite; -class Debugger; -class WatchpointMap; - -/* - * Env is the type of what ES5 calls "lexical environments" (runtime - * activations of lexical scopes). This is currently just JSObject, and is - * implemented by Call, Block, With, and DeclEnv objects, among others--but - * environments and objects are really two different concepts. - */ -typedef JSObject Env; - -typedef JSNative Native; -typedef JSPropertyOp PropertyOp; -typedef JSStrictPropertyOp StrictPropertyOp; -typedef JSPropertyDescriptor PropertyDescriptor; - -namespace analyze { - -struct LifetimeVariable; -class LoopAnalysis; -class ScriptAnalysis; -class SlotValue; -class SSAValue; -class SSAUseChain; - -} /* namespace analyze */ - -namespace types { - -class TypeSet; -struct TypeCallsite; -struct TypeObject; -struct TypeCompartment; - -} /* namespace types */ - -enum ThingRootKind -{ - THING_ROOT_OBJECT, - THING_ROOT_SHAPE, - THING_ROOT_BASE_SHAPE, - THING_ROOT_TYPE_OBJECT, - THING_ROOT_STRING, - THING_ROOT_SCRIPT, - THING_ROOT_ID, - THING_ROOT_VALUE, - THING_ROOT_LIMIT -}; - -template class Root; -template class RootedVar; - -template -struct RootMethods { }; - -/* - * Reference to a stack location rooted for GC. See "Moving GC Stack Rooting" - * comment in jscntxt.h. - */ -template -class Handle -{ - public: - /* Copy handles of different types, with implicit coercion. */ - template Handle(Handle handle) { - testAssign(); - ptr = reinterpret_cast(handle.address()); - } - - /* Get a handle from a rooted stack location, with implicit coercion. */ - template inline Handle(const Root &root); - template inline Handle(const RootedVar &root); - - const T *address() { return ptr; } - - operator T () { return value(); } - T operator ->() { return value(); } - - private: - const T *ptr; - T value() { return *ptr; } - - template - void testAssign() { -#ifdef DEBUG - T a = RootMethods::initial(); - S b = RootMethods::initial(); - a = b; - (void)a; -#endif - } -}; - -typedef Handle HandleObject; -typedef Handle HandleFunction; -typedef Handle HandleShape; -typedef Handle HandleBaseShape; -typedef Handle HandleTypeObject; -typedef Handle HandleString; -typedef Handle HandleAtom; -typedef Handle HandleId; -typedef Handle HandleValue; - -} /* namespace js */ - -namespace JSC { - -class ExecutableAllocator; - -} /* namespace JSC */ - -namespace WTF { - -class BumpPointerAllocator; - -} /* namespace WTF */ - -} /* export "C++" */ - -#else - -typedef struct JSAtom JSAtom; - -#endif /* __cplusplus */ - -/* "Friend" types used by jscntxt.h and jsdbgapi.h. */ -typedef enum JSTrapStatus { - JSTRAP_ERROR, - JSTRAP_CONTINUE, - JSTRAP_RETURN, - JSTRAP_THROW, - JSTRAP_LIMIT -} JSTrapStatus; - -typedef JSTrapStatus -(* JSTrapHandler)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval, - jsval closure); - -typedef JSTrapStatus -(* JSInterruptHook)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval, - void *closure); - -typedef JSTrapStatus -(* JSDebuggerHandler)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval, - void *closure); - -typedef JSTrapStatus -(* JSThrowHook)(JSContext *cx, JSScript *script, jsbytecode *pc, jsval *rval, - void *closure); - -typedef JSBool -(* JSWatchPointHandler)(JSContext *cx, JSObject *obj, jsid id, jsval old, - jsval *newp, void *closure); - -/* called just after script creation */ -typedef void -(* JSNewScriptHook)(JSContext *cx, - const char *filename, /* URL of script */ - unsigned lineno, /* first line */ - JSScript *script, - JSFunction *fun, - void *callerdata); - -/* called just before script destruction */ -typedef void -(* JSDestroyScriptHook)(JSContext *cx, - JSScript *script, - void *callerdata); - -typedef void -(* JSSourceHandler)(const char *filename, unsigned lineno, const jschar *str, - size_t length, void **listenerTSData, void *closure); - -/* - * This hook captures high level script execution and function calls (JS or - * native). It is used by JS_SetExecuteHook to hook top level scripts and by - * JS_SetCallHook to hook function calls. It will get called twice per script - * or function call: just before execution begins and just after it finishes. - * In both cases the 'current' frame is that of the executing code. - * - * The 'before' param is JS_TRUE for the hook invocation before the execution - * and JS_FALSE for the invocation after the code has run. - * - * The 'ok' param is significant only on the post execution invocation to - * signify whether or not the code completed 'normally'. - * - * The 'closure' param is as passed to JS_SetExecuteHook or JS_SetCallHook - * for the 'before'invocation, but is whatever value is returned from that - * invocation for the 'after' invocation. Thus, the hook implementor *could* - * allocate a structure in the 'before' invocation and return a pointer to that - * structure. The pointer would then be handed to the hook for the 'after' - * invocation. Alternately, the 'before' could just return the same value as - * in 'closure' to cause the 'after' invocation to be called with the same - * 'closure' value as the 'before'. - * - * Returning NULL in the 'before' hook will cause the 'after' hook *not* to - * be called. - */ -typedef void * -(* JSInterpreterHook)(JSContext *cx, JSStackFrame *fp, JSBool before, - JSBool *ok, void *closure); - -typedef JSBool -(* JSDebugErrorHook)(JSContext *cx, const char *message, JSErrorReport *report, - void *closure); - -typedef struct JSDebugHooks { - JSInterruptHook interruptHook; - void *interruptHookData; - JSNewScriptHook newScriptHook; - void *newScriptHookData; - JSDestroyScriptHook destroyScriptHook; - void *destroyScriptHookData; - JSDebuggerHandler debuggerHandler; - void *debuggerHandlerData; - JSSourceHandler sourceHandler; - void *sourceHandlerData; - JSInterpreterHook executeHook; - void *executeHookData; - JSInterpreterHook callHook; - void *callHookData; - JSThrowHook throwHook; - void *throwHookData; - JSDebugErrorHook debugErrorHook; - void *debugErrorHookData; -} JSDebugHooks; - -/* js::ObjectOps function pointer typedefs. */ - -/* - * Look for id in obj and its prototype chain, returning false on error or - * exception, true on success. On success, return null in *propp if id was - * not found. If id was found, return the first object searching from obj - * along its prototype chain in which id names a direct property in *objp, and - * return a non-null, opaque property pointer in *propp. - * - * If JSLookupPropOp succeeds and returns with *propp non-null, that pointer - * may be passed as the prop parameter to a JSAttributesOp, as a short-cut - * that bypasses id re-lookup. - */ -typedef JSBool -(* JSLookupPropOp)(JSContext *cx, JSObject *obj, jsid id, JSObject **objp, - JSProperty **propp); - -/* - * Get or set attributes of the property obj[id]. Return false on error or - * exception, true with current attributes in *attrsp. - */ -typedef JSBool -(* JSAttributesOp)(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp); - -/* - * A generic type for functions mapping an object to another object, or null - * if an error or exception was thrown on cx. - */ -typedef JSObject * -(* JSObjectOp)(JSContext *cx, JSObject *obj); - -/* - * Hook that creates an iterator object for a given object. Returns the - * iterator object or null if an error or exception was thrown on cx. - */ -typedef JSObject * -(* JSIteratorOp)(JSContext *cx, JSObject *obj, JSBool keysonly); - -/* - * The following determines whether JS_EncodeCharacters and JS_DecodeBytes - * treat char[] as utf-8 or simply as bytes that need to be inflated/deflated. - */ -#ifdef JS_C_STRINGS_ARE_UTF8 -# define js_CStringsAreUTF8 JS_TRUE -#else -extern JSBool js_CStringsAreUTF8; -#endif - -JS_END_EXTERN_C - -#endif /* jsprvtd_h___ */ diff --git a/js/spidermonkey-win32/include/jspubtd.h b/js/spidermonkey-win32/include/jspubtd.h index 0859351f15..a2f64939ec 100644 --- a/js/spidermonkey-win32/include/jspubtd.h +++ b/js/spidermonkey-win32/include/jspubtd.h @@ -39,66 +39,28 @@ #ifndef jspubtd_h___ #define jspubtd_h___ - /* * JS public API typedefs. */ #include "jstypes.h" - -/* - * Allow headers to reference JS::Value without #including the whole jsapi.h. - * Unfortunately, typedefs (hence jsval) cannot be declared. - */ -#ifdef __cplusplus -namespace JS { class Value; } -#endif - -/* - * In release builds, jsid is defined to be an integral type. This - * prevents many bugs from being caught at compile time. E.g.: - * - * jsid id = ... - * if (id == JS_TRUE) // error - * ... - * - * size_t n = id; // error - * - * To catch more errors, jsid is given a struct type in C++ debug builds. - * Struct assignment and (in C++) operator== allow correct code to be mostly - * oblivious to the change. This feature can be explicitly disabled in debug - * builds by defining JS_NO_JSVAL_JSID_STRUCT_TYPES. - */ -#ifdef __cplusplus - -# if defined(DEBUG) && !defined(JS_NO_JSVAL_JSID_STRUCT_TYPES) -# define JS_USE_JSID_STRUCT_TYPES -# endif - -# ifdef JS_USE_JSID_STRUCT_TYPES -struct jsid -{ - size_t asBits; - bool operator==(jsid rhs) const { return asBits == rhs.asBits; } - bool operator!=(jsid rhs) const { return asBits != rhs.asBits; } -}; -# define JSID_BITS(id) (id.asBits) -# else /* defined(JS_USE_JSID_STRUCT_TYPES) */ -typedef ptrdiff_t jsid; -# define JSID_BITS(id) (id) -# endif /* defined(JS_USE_JSID_STRUCT_TYPES) */ -#else /* defined(__cplusplus) */ -typedef ptrdiff_t jsid; -# define JSID_BITS(id) (id) -#endif +#include "jscompat.h" +#include "jsval.h" JS_BEGIN_EXTERN_C +/* Scalar typedefs. */ +typedef JSInt32 jsint; +typedef JSUint32 jsuint; +typedef float64 jsdouble; +typedef JSInt32 jsrefcount; /* PRInt32 if JS_THREADSAFE, see jslock.h */ + #ifdef WIN32 typedef wchar_t jschar; #else -typedef uint16_t jschar; +typedef JSUint16 jschar; #endif + /* * Run-time version enumeration. See jsversion.h for compile-time counterparts * to these values that may be selected by the JS_VERSION macro, and tested by @@ -181,67 +143,476 @@ typedef enum JSIterateOp { JSENUMERATE_DESTROY } JSIterateOp; -/* See JSVAL_TRACE_KIND and JSTraceCallback in jsapi.h. */ -typedef enum { - JSTRACE_OBJECT, - JSTRACE_STRING, - JSTRACE_SCRIPT, - - /* - * Trace kinds internal to the engine. The embedding can only them if it - * implements JSTraceCallback. - */ -#if JS_HAS_XML_SUPPORT - JSTRACE_XML, -#endif - JSTRACE_SHAPE, - JSTRACE_BASE_SHAPE, - JSTRACE_TYPE_OBJECT, - JSTRACE_LAST = JSTRACE_TYPE_OBJECT -} JSGCTraceKind; - /* Struct typedefs. */ -typedef struct JSClass JSClass; -typedef struct JSCompartment JSCompartment; -typedef struct JSConstDoubleSpec JSConstDoubleSpec; -typedef struct JSContext JSContext; -typedef struct JSCrossCompartmentCall JSCrossCompartmentCall; -typedef struct JSErrorReport JSErrorReport; -typedef struct JSExceptionState JSExceptionState; -typedef struct JSFunction JSFunction; -typedef struct JSFunctionSpec JSFunctionSpec; -typedef struct JSIdArray JSIdArray; -typedef struct JSLocaleCallbacks JSLocaleCallbacks; -typedef struct JSObject JSObject; -typedef struct JSObjectMap JSObjectMap; -typedef struct JSPrincipals JSPrincipals; -typedef struct JSPropertyDescriptor JSPropertyDescriptor; -typedef struct JSPropertyName JSPropertyName; -typedef struct JSPropertySpec JSPropertySpec; -typedef struct JSRuntime JSRuntime; -typedef struct JSSecurityCallbacks JSSecurityCallbacks; -typedef struct JSStackFrame JSStackFrame; -typedef struct JSScript JSScript; -typedef struct JSStructuredCloneCallbacks JSStructuredCloneCallbacks; -typedef struct JSStructuredCloneReader JSStructuredCloneReader; -typedef struct JSStructuredCloneWriter JSStructuredCloneWriter; -typedef struct JSTracer JSTracer; -typedef struct JSXDRState JSXDRState; +typedef struct JSClass JSClass; +typedef struct JSConstDoubleSpec JSConstDoubleSpec; +typedef struct JSContext JSContext; +typedef struct JSErrorReport JSErrorReport; +typedef struct JSFunction JSFunction; +typedef struct JSFunctionSpec JSFunctionSpec; +typedef struct JSTracer JSTracer; +typedef struct JSIdArray JSIdArray; +typedef struct JSPropertyDescriptor JSPropertyDescriptor; +typedef struct JSPropertySpec JSPropertySpec; +typedef struct JSObjectMap JSObjectMap; +typedef struct JSRuntime JSRuntime; +typedef struct JSStackFrame JSStackFrame; +typedef struct JSXDRState JSXDRState; +typedef struct JSExceptionState JSExceptionState; +typedef struct JSLocaleCallbacks JSLocaleCallbacks; +typedef struct JSSecurityCallbacks JSSecurityCallbacks; +typedef struct JSONParser JSONParser; +typedef struct JSCompartment JSCompartment; +typedef struct JSCrossCompartmentCall JSCrossCompartmentCall; +typedef struct JSStructuredCloneWriter JSStructuredCloneWriter; +typedef struct JSStructuredCloneReader JSStructuredCloneReader; +typedef struct JSStructuredCloneCallbacks JSStructuredCloneCallbacks; #ifdef __cplusplus -class JSFlatString; -class JSString; -#else -typedef struct JSFlatString JSFlatString; -typedef struct JSString JSString; +typedef class JSWrapper JSWrapper; +typedef class JSCrossCompartmentWrapper JSCrossCompartmentWrapper; #endif -#ifdef JS_THREADSAFE -typedef struct PRCallOnceType JSCallOnceType; +/* JSClass (and js::ObjectOps where appropriate) function pointer typedefs. */ + +/* + * Add, delete, or get a property named by id in obj. Note the jsid id + * type -- id may be a string (Unicode property identifier) or an int (element + * index). The *vp out parameter, on success, is the new property value after + * an add or get. After a successful delete, *vp is JSVAL_FALSE iff + * obj[id] can't be deleted (because it's permanent). + */ +typedef JSBool +(* JSPropertyOp)(JSContext *cx, JSObject *obj, jsid id, jsval *vp); + +/* + * Set a property named by id in obj, treating the assignment as strict + * mode code if strict is true. Note the jsid id type -- id may be a string + * (Unicode property identifier) or an int (element index). The *vp out + * parameter, on success, is the new property value after the + * set. + */ +typedef JSBool +(* JSStrictPropertyOp)(JSContext *cx, JSObject *obj, jsid id, JSBool strict, jsval *vp); + +/* + * This function type is used for callbacks that enumerate the properties of + * a JSObject. The behavior depends on the value of enum_op: + * + * JSENUMERATE_INIT + * A new, opaque iterator state should be allocated and stored in *statep. + * (You can use PRIVATE_TO_JSVAL() to tag the pointer to be stored). + * + * The number of properties that will be enumerated should be returned as + * an integer jsval in *idp, if idp is non-null, and provided the number of + * enumerable properties is known. If idp is non-null and the number of + * enumerable properties can't be computed in advance, *idp should be set + * to JSVAL_ZERO. + * + * JSENUMERATE_INIT_ALL + * Used identically to JSENUMERATE_INIT, but exposes all properties of the + * object regardless of enumerability. + * + * JSENUMERATE_NEXT + * A previously allocated opaque iterator state is passed in via statep. + * Return the next jsid in the iteration using *idp. The opaque iterator + * state pointed at by statep is destroyed and *statep is set to JSVAL_NULL + * if there are no properties left to enumerate. + * + * JSENUMERATE_DESTROY + * Destroy the opaque iterator state previously allocated in *statep by a + * call to this function when enum_op was JSENUMERATE_INIT or + * JSENUMERATE_INIT_ALL. + * + * The return value is used to indicate success, with a value of JS_FALSE + * indicating failure. + */ +typedef JSBool +(* JSNewEnumerateOp)(JSContext *cx, JSObject *obj, JSIterateOp enum_op, + jsval *statep, jsid *idp); + +/* + * The old-style JSClass.enumerate op should define all lazy properties not + * yet reflected in obj. + */ +typedef JSBool +(* JSEnumerateOp)(JSContext *cx, JSObject *obj); + +/* + * Resolve a lazy property named by id in obj by defining it directly in obj. + * Lazy properties are those reflected from some peer native property space + * (e.g., the DOM attributes for a given node reflected as obj) on demand. + * + * JS looks for a property in an object, and if not found, tries to resolve + * the given id. If resolve succeeds, the engine looks again in case resolve + * defined obj[id]. If no such property exists directly in obj, the process + * is repeated with obj's prototype, etc. + * + * NB: JSNewResolveOp provides a cheaper way to resolve lazy properties. + */ +typedef JSBool +(* JSResolveOp)(JSContext *cx, JSObject *obj, jsid id); + +/* + * Like JSResolveOp, but flags provide contextual information as follows: + * + * JSRESOLVE_QUALIFIED a qualified property id: obj.id or obj[id], not id + * JSRESOLVE_ASSIGNING obj[id] is on the left-hand side of an assignment + * JSRESOLVE_DETECTING 'if (o.p)...' or similar detection opcode sequence + * JSRESOLVE_DECLARING var, const, or function prolog declaration opcode + * JSRESOLVE_CLASSNAME class name used when constructing + * + * The *objp out parameter, on success, should be null to indicate that id + * was not resolved; and non-null, referring to obj or one of its prototypes, + * if id was resolved. + * + * This hook instead of JSResolveOp is called via the JSClass.resolve member + * if JSCLASS_NEW_RESOLVE is set in JSClass.flags. + * + * Setting JSCLASS_NEW_RESOLVE and JSCLASS_NEW_RESOLVE_GETS_START further + * extends this hook by passing in the starting object on the prototype chain + * via *objp. Thus a resolve hook implementation may define the property id + * being resolved in the object in which the id was first sought, rather than + * in a prototype object whose class led to the resolve hook being called. + * + * When using JSCLASS_NEW_RESOLVE_GETS_START, the resolve hook must therefore + * null *objp to signify "not resolved". With only JSCLASS_NEW_RESOLVE and no + * JSCLASS_NEW_RESOLVE_GETS_START, the hook can assume *objp is null on entry. + * This is not good practice, but enough existing hook implementations count + * on it that we can't break compatibility by passing the starting object in + * *objp without a new JSClass flag. + */ +typedef JSBool +(* JSNewResolveOp)(JSContext *cx, JSObject *obj, jsid id, uintN flags, + JSObject **objp); + +/* + * Convert obj to the given type, returning true with the resulting value in + * *vp on success, and returning false on error or exception. + */ +typedef JSBool +(* JSConvertOp)(JSContext *cx, JSObject *obj, JSType type, jsval *vp); + +/* + * Delegate typeof to an object so it can cloak a primitive or another object. + */ +typedef JSType +(* JSTypeOfOp)(JSContext *cx, JSObject *obj); + +/* + * Finalize obj, which the garbage collector has determined to be unreachable + * from other live objects or from GC roots. Obviously, finalizers must never + * store a reference to obj. + */ +typedef void +(* JSFinalizeOp)(JSContext *cx, JSObject *obj); + +/* + * Used by JS_AddExternalStringFinalizer and JS_RemoveExternalStringFinalizer + * to extend and reduce the set of string types finalized by the GC. + */ +typedef void +(* JSStringFinalizeOp)(JSContext *cx, JSString *str); + +/* + * JSClass.checkAccess type: check whether obj[id] may be accessed per mode, + * returning false on error/exception, true on success with obj[id]'s last-got + * value in *vp, and its attributes in *attrsp. As for JSPropertyOp above, id + * is either a string or an int jsval. + */ +typedef JSBool +(* JSCheckAccessOp)(JSContext *cx, JSObject *obj, jsid id, JSAccessMode mode, + jsval *vp); + +/* + * Encode or decode an object, given an XDR state record representing external + * data. See jsxdrapi.h. + */ +typedef JSBool +(* JSXDRObjectOp)(JSXDRState *xdr, JSObject **objp); + +/* + * Check whether v is an instance of obj. Return false on error or exception, + * true on success with JS_TRUE in *bp if v is an instance of obj, JS_FALSE in + * *bp otherwise. + */ +typedef JSBool +(* JSHasInstanceOp)(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp); + +/* + * Deprecated function type for JSClass.mark. All new code should define + * JSTraceOp instead to ensure the traversal of traceable things stored in + * the native structures. + */ +typedef uint32 +(* JSMarkOp)(JSContext *cx, JSObject *obj, void *arg); + +/* + * Function type for trace operation of the class called to enumerate all + * traceable things reachable from obj's private data structure. For each such + * thing, a trace implementation must call + * + * JS_CallTracer(trc, thing, kind); + * + * or one of its convenience macros as described in jsapi.h. + * + * JSTraceOp implementation can assume that no other threads mutates object + * state. It must not change state of the object or corresponding native + * structures. The only exception for this rule is the case when the embedding + * needs a tight integration with GC. In that case the embedding can check if + * the traversal is a part of the marking phase through calling + * JS_IsGCMarkingTracer and apply a special code like emptying caches or + * marking its native structures. + * + * To define the tracer for a JSClass, the implementation must add + * JSCLASS_MARK_IS_TRACE to class flags and use JS_CLASS_TRACE(method) + * macro below to convert JSTraceOp to JSMarkOp when initializing or + * assigning JSClass.mark field. + */ +typedef void +(* JSTraceOp)(JSTracer *trc, JSObject *obj); + +#if defined __GNUC__ && __GNUC__ >= 4 && !defined __cplusplus +# define JS_CLASS_TRACE(method) \ + (__builtin_types_compatible_p(JSTraceOp, __typeof(&(method))) \ + ? (JSMarkOp)(method) \ + : js_WrongTypeForClassTracer) + +extern JSMarkOp js_WrongTypeForClassTracer; + #else -typedef JSBool JSCallOnceType; +# define JS_CLASS_TRACE(method) ((JSMarkOp)(method)) #endif -typedef JSBool (*JSInitCallback)(void); + +/* + * Tracer callback, called for each traceable thing directly referenced by a + * particular object or runtime structure. It is the callback responsibility + * to ensure the traversal of the full object graph via calling eventually + * JS_TraceChildren on the passed thing. In this case the callback must be + * prepared to deal with cycles in the traversal graph. + * + * kind argument is one of JSTRACE_OBJECT, JSTRACE_STRING or a tag denoting + * internal implementation-specific traversal kind. In the latter case the only + * operations on thing that the callback can do is to call JS_TraceChildren or + * DEBUG-only JS_PrintTraceThingInfo. + */ +typedef void +(* JSTraceCallback)(JSTracer *trc, void *thing, uint32 kind); + +/* + * DEBUG only callback that JSTraceOp implementation can provide to return + * a string describing the reference traced with JS_CallTracer. + */ +typedef void +(* JSTraceNamePrinter)(JSTracer *trc, char *buf, size_t bufsize); + +typedef JSBool +(* JSEqualityOp)(JSContext *cx, JSObject *obj, const jsval *v, JSBool *bp); + +/* + * Typedef for native functions called by the JS VM. + * + * See jsapi.h, the JS_CALLEE, JS_THIS, etc. macros. + */ + +typedef JSBool +(* JSNative)(JSContext *cx, uintN argc, jsval *vp); + +/* Callbacks and their arguments. */ + +typedef enum JSContextOp { + JSCONTEXT_NEW, + JSCONTEXT_DESTROY +} JSContextOp; + +/* + * The possible values for contextOp when the runtime calls the callback are: + * JSCONTEXT_NEW JS_NewContext successfully created a new JSContext + * instance. The callback can initialize the instance as + * required. If the callback returns false, the instance + * will be destroyed and JS_NewContext returns null. In + * this case the callback is not called again. + * JSCONTEXT_DESTROY One of JS_DestroyContext* methods is called. The + * callback may perform its own cleanup and must always + * return true. + * Any other value For future compatibility the callback must do nothing + * and return true in this case. + */ +typedef JSBool +(* JSContextCallback)(JSContext *cx, uintN contextOp); + +#ifndef JS_THREADSAFE +typedef void +(* JSHeartbeatCallback)(JSRuntime *rt); +#endif + +typedef enum JSGCStatus { + JSGC_BEGIN, + JSGC_END, + JSGC_MARK_END, + JSGC_FINALIZE_END +} JSGCStatus; + +typedef JSBool +(* JSGCCallback)(JSContext *cx, JSGCStatus status); + +/* + * Generic trace operation that calls JS_CallTracer on each traceable thing + * stored in data. + */ +typedef void +(* JSTraceDataOp)(JSTracer *trc, void *data); + +typedef JSBool +(* JSOperationCallback)(JSContext *cx); + +typedef void +(* JSErrorReporter)(JSContext *cx, const char *message, JSErrorReport *report); + +/* + * Possible exception types. These types are part of a JSErrorFormatString + * structure. They define which error to throw in case of a runtime error. + * JSEXN_NONE marks an unthrowable error. + */ +typedef enum JSExnType { + JSEXN_NONE = -1, + JSEXN_ERR, + JSEXN_INTERNALERR, + JSEXN_EVALERR, + JSEXN_RANGEERR, + JSEXN_REFERENCEERR, + JSEXN_SYNTAXERR, + JSEXN_TYPEERR, + JSEXN_URIERR, + JSEXN_LIMIT +} JSExnType; + +typedef struct JSErrorFormatString { + /* The error format string (UTF-8 if js_CStringsAreUTF8). */ + const char *format; + + /* The number of arguments to expand in the formatted error message. */ + uint16 argCount; + + /* One of the JSExnType constants above. */ + int16 exnType; +} JSErrorFormatString; + +typedef const JSErrorFormatString * +(* JSErrorCallback)(void *userRef, const char *locale, + const uintN errorNumber); + +#ifdef va_start +#define JS_ARGUMENT_FORMATTER_DEFINED 1 + +typedef JSBool +(* JSArgumentFormatter)(JSContext *cx, const char *format, JSBool fromJS, + jsval **vpp, va_list *app); +#endif + +typedef JSBool +(* JSLocaleToUpperCase)(JSContext *cx, JSString *src, jsval *rval); + +typedef JSBool +(* JSLocaleToLowerCase)(JSContext *cx, JSString *src, jsval *rval); + +typedef JSBool +(* JSLocaleCompare)(JSContext *cx, JSString *src1, JSString *src2, + jsval *rval); + +typedef JSBool +(* JSLocaleToUnicode)(JSContext *cx, const char *src, jsval *rval); + +/* + * Security protocol types. + */ +typedef struct JSPrincipals JSPrincipals; + +/* + * XDR-encode or -decode a principals instance, based on whether xdr->mode is + * JSXDR_ENCODE, in which case *principalsp should be encoded; or JSXDR_DECODE, + * in which case implementations must return a held (via JSPRINCIPALS_HOLD), + * non-null *principalsp out parameter. Return true on success, false on any + * error, which the implementation must have reported. + */ +typedef JSBool +(* JSPrincipalsTranscoder)(JSXDRState *xdr, JSPrincipals **principalsp); + +/* + * Return a weak reference to the principals associated with obj, possibly via + * the immutable parent chain leading from obj to a top-level container (e.g., + * a window object in the DOM level 0). If there are no principals associated + * with obj, return null. Therefore null does not mean an error was reported; + * in no event should an error be reported or an exception be thrown by this + * callback's implementation. + */ +typedef JSPrincipals * +(* JSObjectPrincipalsFinder)(JSContext *cx, JSObject *obj); + +/* + * Used to check if a CSP instance wants to disable eval() and friends. + * See js_CheckCSPPermitsJSAction() in jsobj. + */ +typedef JSBool +(* JSCSPEvalChecker)(JSContext *cx); + +/* + * Callback used to ask the embedding for the cross compartment wrapper handler + * that implements the desired prolicy for this kind of object in the + * destination compartment. + */ +typedef JSObject * +(* JSWrapObjectCallback)(JSContext *cx, JSObject *obj, JSObject *proto, JSObject *parent, + uintN flags); + +/* + * Callback used by the wrap hook to ask the embedding to prepare an object + * for wrapping in a context. This might include unwrapping other wrappers + * or even finding a more suitable object for the new compartment. + */ +typedef JSObject * +(* JSPreWrapCallback)(JSContext *cx, JSObject *scope, JSObject *obj, uintN flags); + +typedef enum { + JSCOMPARTMENT_NEW, /* XXX Does it make sense to have a NEW? */ + JSCOMPARTMENT_DESTROY +} JSCompartmentOp; + +typedef JSBool +(* JSCompartmentCallback)(JSContext *cx, JSCompartment *compartment, uintN compartmentOp); + +/* + * Read structured data from the reader r. This hook is used to read a value + * previously serialized by a call to the WriteStructuredCloneOp hook. + * + * tag and data are the pair of uint32 values from the header. The callback may + * use the JS_Read* APIs to read any other relevant parts of the object from + * the reader r. closure is any value passed to the JS_ReadStructuredClone + * function. Return the new object on success, NULL on error/exception. + */ +typedef JSObject *(*ReadStructuredCloneOp)(JSContext *cx, JSStructuredCloneReader *r, + uint32 tag, uint32 data, void *closure); + +/* + * Structured data serialization hook. The engine can write primitive values, + * Objects, Arrays, Dates, RegExps, TypedArrays, and ArrayBuffers. Any other + * type of object requires application support. This callback must first use + * the JS_WriteUint32Pair API to write an object header, passing a value + * greater than JS_SCTAG_USER to the tag parameter. Then it can use the + * JS_Write* APIs to write any other relevant parts of the value v to the + * writer w. closure is any value passed to the JS_WriteStructuredCLone function. + * + * Return true on success, false on error/exception. + */ +typedef JSBool (*WriteStructuredCloneOp)(JSContext *cx, JSStructuredCloneWriter *w, + JSObject *obj, void *closure); + +/* + * This is called when JS_WriteStructuredClone finds that the object to be + * written is recursive. To follow HTML5, the application must throw a + * DATA_CLONE_ERR DOMException. errorid is always JS_SCERR_RECURSION. + */ +typedef void (*StructuredCloneErrorOp)(JSContext *cx, uint32 errorid); JS_END_EXTERN_C diff --git a/js/spidermonkey-win32/include/jstypedarray.h b/js/spidermonkey-win32/include/jstypedarray.h deleted file mode 100644 index bfed3c2c73..0000000000 --- a/js/spidermonkey-win32/include/jstypedarray.h +++ /dev/null @@ -1,364 +0,0 @@ -/* -*- Mode: c++; c-basic-offset: 4; tab-width: 40; indent-tabs-mode: nil -*- */ -/* vim: set ts=40 sw=4 et tw=99: */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla WebGL impl - * - * The Initial Developer of the Original Code is - * Mozilla Foundation - * Portions created by the Initial Developer are Copyright (C) 2009 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Vladimir Vukicevic - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef jstypedarray_h -#define jstypedarray_h - -#include "jsapi.h" -#include "jsclass.h" - -#include "gc/Barrier.h" - -typedef struct JSProperty JSProperty; - -namespace js { - -/* - * ArrayBuffer - * - * This class holds the underlying raw buffer that the TypedArray - * subclasses access. It can be created explicitly and passed to a - * TypedArray subclass, or can be created implicitly by constructing a - * TypedArray with a size. - */ -struct JS_FRIEND_API(ArrayBuffer) { - static Class slowClass; - static JSPropertySpec jsprops[]; - static JSFunctionSpec jsfuncs[]; - - static JSBool prop_getByteLength(JSContext *cx, JSObject *obj, jsid id, Value *vp); - - static JSBool fun_slice(JSContext *cx, unsigned argc, Value *vp); - - static JSBool class_constructor(JSContext *cx, unsigned argc, Value *vp); - - static JSObject *create(JSContext *cx, int32_t nbytes, uint8_t *contents = NULL); - - static JSObject *createSlice(JSContext *cx, JSObject *arrayBuffer, - uint32_t begin, uint32_t end); - - ArrayBuffer() - { - } - - ~ArrayBuffer(); - - static void - obj_trace(JSTracer *trc, JSObject *obj); - - static JSBool - obj_lookupGeneric(JSContext *cx, JSObject *obj, jsid id, - JSObject **objp, JSProperty **propp); - static JSBool - obj_lookupProperty(JSContext *cx, JSObject *obj, PropertyName *name, - JSObject **objp, JSProperty **propp); - static JSBool - obj_lookupElement(JSContext *cx, JSObject *obj, uint32_t index, - JSObject **objp, JSProperty **propp); - static JSBool - obj_lookupSpecial(JSContext *cx, JSObject *obj, SpecialId sid, JSObject **objp, - JSProperty **propp); - - static JSBool - obj_defineGeneric(JSContext *cx, JSObject *obj, jsid id, const Value *v, - PropertyOp getter, StrictPropertyOp setter, unsigned attrs); - static JSBool - obj_defineProperty(JSContext *cx, JSObject *obj, PropertyName *name, const Value *v, - PropertyOp getter, StrictPropertyOp setter, unsigned attrs); - static JSBool - obj_defineElement(JSContext *cx, JSObject *obj, uint32_t index, const Value *v, - PropertyOp getter, StrictPropertyOp setter, unsigned attrs); - static JSBool - obj_defineSpecial(JSContext *cx, JSObject *obj, SpecialId sid, const Value *v, - PropertyOp getter, StrictPropertyOp setter, unsigned attrs); - - static JSBool - obj_getGeneric(JSContext *cx, JSObject *obj, JSObject *receiver, jsid id, Value *vp); - - static JSBool - obj_getProperty(JSContext *cx, JSObject *obj, JSObject *receiver, PropertyName *name, - Value *vp); - - static JSBool - obj_getElement(JSContext *cx, JSObject *obj, JSObject *receiver, uint32_t index, Value *vp); - static JSBool - obj_getElementIfPresent(JSContext *cx, JSObject *obj, JSObject *receiver, uint32_t index, - Value *vp, bool *present); - - static JSBool - obj_getSpecial(JSContext *cx, JSObject *obj, JSObject *receiver, SpecialId sid, Value *vp); - - static JSBool - obj_setGeneric(JSContext *cx, JSObject *obj, jsid id, Value *vp, JSBool strict); - static JSBool - obj_setProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *vp, JSBool strict); - static JSBool - obj_setElement(JSContext *cx, JSObject *obj, uint32_t index, Value *vp, JSBool strict); - static JSBool - obj_setSpecial(JSContext *cx, JSObject *obj, SpecialId sid, Value *vp, JSBool strict); - - static JSBool - obj_getGenericAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp); - static JSBool - obj_getPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, unsigned *attrsp); - static JSBool - obj_getElementAttributes(JSContext *cx, JSObject *obj, uint32_t index, unsigned *attrsp); - static JSBool - obj_getSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, unsigned *attrsp); - - static JSBool - obj_setGenericAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp); - static JSBool - obj_setPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, unsigned *attrsp); - static JSBool - obj_setElementAttributes(JSContext *cx, JSObject *obj, uint32_t index, unsigned *attrsp); - static JSBool - obj_setSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, unsigned *attrsp); - - static JSBool - obj_deleteProperty(JSContext *cx, JSObject *obj, PropertyName *name, Value *rval, JSBool strict); - static JSBool - obj_deleteElement(JSContext *cx, JSObject *obj, uint32_t index, Value *rval, JSBool strict); - static JSBool - obj_deleteSpecial(JSContext *cx, JSObject *obj, SpecialId sid, Value *rval, JSBool strict); - - static JSBool - obj_enumerate(JSContext *cx, JSObject *obj, JSIterateOp enum_op, - Value *statep, jsid *idp); - - static JSType - obj_typeOf(JSContext *cx, JSObject *obj); - - static JSObject * - getArrayBuffer(JSObject *obj); -}; - -/* - * TypedArray - * - * The non-templated base class for the specific typed implementations. - * This class holds all the member variables that are used by - * the subclasses. - */ - -struct JS_FRIEND_API(TypedArray) { - enum { - TYPE_INT8 = 0, - TYPE_UINT8, - TYPE_INT16, - TYPE_UINT16, - TYPE_INT32, - TYPE_UINT32, - TYPE_FLOAT32, - TYPE_FLOAT64, - - /* - * Special type that's a uint8, but assignments are clamped to 0 .. 255. - * Treat the raw data type as a uint8. - */ - TYPE_UINT8_CLAMPED, - - TYPE_MAX - }; - - enum { - /* Properties of the typed array stored in reserved slots. */ - FIELD_LENGTH = 0, - FIELD_BYTEOFFSET, - FIELD_BYTELENGTH, - FIELD_TYPE, - FIELD_BUFFER, - FIELD_MAX, - NUM_FIXED_SLOTS = 7 - }; - - // and MUST NOT be used to construct new objects. - static Class fastClasses[TYPE_MAX]; - - // These are the slow/original classes, used - // fo constructing new objects - static Class slowClasses[TYPE_MAX]; - - static JSPropertySpec jsprops[]; - - static JSObject *getTypedArray(JSObject *obj); - - static JSBool prop_getBuffer(JSContext *cx, JSObject *obj, jsid id, Value *vp); - static JSBool prop_getByteOffset(JSContext *cx, JSObject *obj, jsid id, Value *vp); - static JSBool prop_getByteLength(JSContext *cx, JSObject *obj, jsid id, Value *vp); - static JSBool prop_getLength(JSContext *cx, JSObject *obj, jsid id, Value *vp); - - static JSBool obj_lookupGeneric(JSContext *cx, JSObject *obj, jsid id, - JSObject **objp, JSProperty **propp); - static JSBool obj_lookupProperty(JSContext *cx, JSObject *obj, PropertyName *name, - JSObject **objp, JSProperty **propp); - static JSBool obj_lookupElement(JSContext *cx, JSObject *obj, uint32_t index, - JSObject **objp, JSProperty **propp); - static JSBool obj_lookupSpecial(JSContext *cx, JSObject *obj, SpecialId sid, - JSObject **objp, JSProperty **propp); - - static JSBool obj_getGenericAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp); - static JSBool obj_getPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, unsigned *attrsp); - static JSBool obj_getElementAttributes(JSContext *cx, JSObject *obj, uint32_t index, unsigned *attrsp); - static JSBool obj_getSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, unsigned *attrsp); - - static JSBool obj_setGenericAttributes(JSContext *cx, JSObject *obj, jsid id, unsigned *attrsp); - static JSBool obj_setPropertyAttributes(JSContext *cx, JSObject *obj, PropertyName *name, unsigned *attrsp); - static JSBool obj_setElementAttributes(JSContext *cx, JSObject *obj, uint32_t index, unsigned *attrsp); - static JSBool obj_setSpecialAttributes(JSContext *cx, JSObject *obj, SpecialId sid, unsigned *attrsp); - - static uint32_t getLength(JSObject *obj); - static uint32_t getByteOffset(JSObject *obj); - static uint32_t getByteLength(JSObject *obj); - static uint32_t getType(JSObject *obj); - static JSObject * getBuffer(JSObject *obj); - static void * getDataOffset(JSObject *obj); - - public: - static bool - isArrayIndex(JSContext *cx, JSObject *obj, jsid id, uint32_t *ip = NULL); - - static inline uint32_t slotWidth(int atype) { - switch (atype) { - case js::TypedArray::TYPE_INT8: - case js::TypedArray::TYPE_UINT8: - case js::TypedArray::TYPE_UINT8_CLAMPED: - return 1; - case js::TypedArray::TYPE_INT16: - case js::TypedArray::TYPE_UINT16: - return 2; - case js::TypedArray::TYPE_INT32: - case js::TypedArray::TYPE_UINT32: - case js::TypedArray::TYPE_FLOAT32: - return 4; - case js::TypedArray::TYPE_FLOAT64: - return 8; - default: - JS_NOT_REACHED("invalid typed array type"); - return 0; - } - } - - static inline int slotWidth(JSObject *obj) { - return slotWidth(getType(obj)); - } - - static int lengthOffset(); - static int dataOffset(); -}; - -extern bool -IsFastTypedArrayClass(const Class *clasp); - -} // namespace js - -/* Friend API methods */ - -JS_FRIEND_API(JSObject *) -js_InitTypedArrayClasses(JSContext *cx, JSObject *obj); - -JS_FRIEND_API(JSBool) -js_IsTypedArray(JSObject *obj); - -JS_FRIEND_API(JSBool) -js_IsArrayBuffer(JSObject *obj); - -JS_FRIEND_API(JSObject *) -js_CreateArrayBuffer(JSContext *cx, uint32_t nbytes); - -/* - * Create a new typed array of type atype (one of the TypedArray - * enumerant values above), with nelements elements. - */ -JS_FRIEND_API(JSObject *) -js_CreateTypedArray(JSContext *cx, int atype, uint32_t nelements); - -/* - * Create a new typed array of type atype (one of the TypedArray - * enumerant values above), and copy in values from the given JSObject, - * which must either be a typed array or an array-like object. - */ -JS_FRIEND_API(JSObject *) -js_CreateTypedArrayWithArray(JSContext *cx, int atype, JSObject *arrayArg); - -/* - * Create a new typed array of type atype (one of the TypedArray - * enumerant values above), using a given ArrayBuffer for storage. - * The byteoffset and length values are optional; if -1 is passed, an - * offset of 0 and enough elements to use up the remainder of the byte - * array are used as the default values. - */ -JS_FRIEND_API(JSObject *) -js_CreateTypedArrayWithBuffer(JSContext *cx, int atype, JSObject *bufArg, - int byteoffset, int length); - -extern int32_t JS_FASTCALL -js_TypedArray_uint8_clamp_double(const double x); - -JS_FRIEND_API(JSBool) -JS_IsArrayBufferObject(JSObject *obj); - -JS_FRIEND_API(JSObject *) -JS_NewArrayBuffer(JSContext *cx, uint32_t nbytes); - -JS_FRIEND_API(uint32_t) -JS_GetArrayBufferByteLength(JSObject *obj); - -JS_FRIEND_API(uint8_t *) -JS_GetArrayBufferData(JSObject *obj); - -JS_FRIEND_API(uint32_t) -JS_GetTypedArrayLength(JSObject *obj); - -JS_FRIEND_API(uint32_t) -JS_GetTypedArrayByteOffset(JSObject *obj); - -JS_FRIEND_API(uint32_t) -JS_GetTypedArrayByteLength(JSObject *obj); - -JS_FRIEND_API(uint32_t) -JS_GetTypedArrayType(JSObject *obj); - -JS_FRIEND_API(JSObject *) -JS_GetTypedArrayBuffer(JSObject *obj); - -JS_FRIEND_API(void *) -JS_GetTypedArrayData(JSObject *obj); - -#endif /* jstypedarray_h */ diff --git a/js/spidermonkey-win32/include/jstypes.h b/js/spidermonkey-win32/include/jstypes.h index b2886110ca..c2103d80b3 100644 --- a/js/spidermonkey-win32/include/jstypes.h +++ b/js/spidermonkey-win32/include/jstypes.h @@ -54,9 +54,7 @@ #ifndef jstypes_h___ #define jstypes_h___ -#include "mozilla/Attributes.h" -#include "mozilla/Util.h" - +#include #include "js-config.h" /*********************************************************************** @@ -80,11 +78,78 @@ ** ***********************************************************************/ -#define JS_EXTERN_API(type) extern MOZ_EXPORT_API(type) -#define JS_EXPORT_API(type) MOZ_EXPORT_API(type) -#define JS_EXPORT_DATA(type) MOZ_EXPORT_DATA(type) -#define JS_IMPORT_API(type) MOZ_IMPORT_API(type) -#define JS_IMPORT_DATA(type) MOZ_IMPORT_DATA(type) +#define DEFINE_LOCAL_CLASS_OF_STATIC_FUNCTION(Name) class Name + +#if defined(WIN32) || defined(XP_OS2) + +/* These also work for __MWERKS__ */ +# define JS_EXTERN_API(__type) extern __declspec(dllexport) __type +# define JS_EXPORT_API(__type) __declspec(dllexport) __type +# define JS_EXTERN_DATA(__type) extern __declspec(dllexport) __type +# define JS_EXPORT_DATA(__type) __declspec(dllexport) __type + +#elif defined(__SYMBIAN32__) + +# define JS_EXTERN_API(__type) extern EXPORT_C __type +# define JS_EXPORT_API(__type) EXPORT_C __type +# define JS_EXTERN_DATA(__type) extern EXPORT_C __type +# define JS_EXPORT_DATA(__type) EXPORT_C __type + +#else /* Unix */ + +# ifdef HAVE_VISIBILITY_ATTRIBUTE +# define JS_EXTERNAL_VIS __attribute__((visibility ("default"))) +# if defined(__GNUC__) && __GNUC__ <= 4 && __GNUC_MINOR__ < 5 + /* + * GCC wrongly produces a warning when a type with hidden visibility + * (e.g. js::Value) is a member of a local class of a static function. + * This is apparently fixed with GCC 4.5 and above. See: + * + * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=40145. + */ +# undef DEFINE_LOCAL_CLASS_OF_STATIC_FUNCTION +# define DEFINE_LOCAL_CLASS_OF_STATIC_FUNCTION(Name) class __attribute__((visibility ("hidden"))) Name +# endif +# elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) +# define JS_EXTERNAL_VIS __global +# else +# define JS_EXTERNAL_VIS +# endif + +# define JS_EXTERN_API(__type) extern JS_EXTERNAL_VIS __type +# define JS_EXPORT_API(__type) JS_EXTERNAL_VIS __type +# define JS_EXTERN_DATA(__type) extern JS_EXTERNAL_VIS __type +# define JS_EXPORT_DATA(__type) JS_EXTERNAL_VIS __type + +#endif + +#ifdef _WIN32 +# if defined(__MWERKS__) || defined(__GNUC__) +# define JS_IMPORT_API(__x) __x +# else +# define JS_IMPORT_API(__x) __declspec(dllimport) __x +# endif +#elif defined(XP_OS2) +# define JS_IMPORT_API(__x) __declspec(dllimport) __x +#elif defined(__SYMBIAN32__) +# define JS_IMPORT_API(__x) IMPORT_C __x +#else +# define JS_IMPORT_API(__x) JS_EXPORT_API (__x) +#endif + +#if defined(_WIN32) && !defined(__MWERKS__) +# define JS_IMPORT_DATA(__x) __declspec(dllimport) __x +#elif defined(XP_OS2) +# define JS_IMPORT_DATA(__x) __declspec(dllimport) __x +#elif defined(__SYMBIAN32__) +# if defined(__CW32__) +# define JS_IMPORT_DATA(__x) __declspec(dllimport) __x +# else +# define JS_IMPORT_DATA(__x) IMPORT_C __x +# endif +#else +# define JS_IMPORT_DATA(__x) JS_EXPORT_DATA (__x) +#endif /* * The linkage of JS API functions differs depending on whether the file is @@ -93,14 +158,20 @@ * should not. STATIC_JS_API is used to build JS as a static library. */ #if defined(STATIC_JS_API) -# define JS_PUBLIC_API(t) t -# define JS_PUBLIC_DATA(t) t + +# define JS_PUBLIC_API(t) t +# define JS_PUBLIC_DATA(t) t + #elif defined(EXPORT_JS_API) || defined(STATIC_EXPORTABLE_JS_API) -# define JS_PUBLIC_API(t) MOZ_EXPORT_API(t) -# define JS_PUBLIC_DATA(t) MOZ_EXPORT_DATA(t) + +# define JS_PUBLIC_API(t) JS_EXPORT_API(t) +# define JS_PUBLIC_DATA(t) JS_EXPORT_DATA(t) + #else -# define JS_PUBLIC_API(t) MOZ_IMPORT_API(t) -# define JS_PUBLIC_DATA(t) MOZ_IMPORT_DATA(t) + +# define JS_PUBLIC_API(t) JS_IMPORT_API(t) +# define JS_PUBLIC_DATA(t) JS_IMPORT_DATA(t) + #endif #define JS_FRIEND_API(t) JS_PUBLIC_API(t) @@ -117,15 +188,37 @@ #endif #ifndef JS_INLINE -#define JS_INLINE MOZ_INLINE +# if defined __cplusplus +# define JS_INLINE inline +# elif defined _MSC_VER +# define JS_INLINE __inline +# elif defined __GNUC__ +# define JS_INLINE __inline__ +# else +# define JS_INLINE inline +# endif #endif #ifndef JS_ALWAYS_INLINE -#define JS_ALWAYS_INLINE MOZ_ALWAYS_INLINE +# if defined DEBUG +# define JS_ALWAYS_INLINE JS_INLINE +# elif defined _MSC_VER +# define JS_ALWAYS_INLINE __forceinline +# elif defined __GNUC__ +# define JS_ALWAYS_INLINE __attribute__((always_inline)) JS_INLINE +# else +# define JS_ALWAYS_INLINE JS_INLINE +# endif #endif #ifndef JS_NEVER_INLINE -#define JS_NEVER_INLINE MOZ_NEVER_INLINE +# if defined _MSC_VER +# define JS_NEVER_INLINE __declspec(noinline) +# elif defined __GNUC__ +# define JS_NEVER_INLINE __attribute__((noinline)) +# else +# define JS_NEVER_INLINE +# endif #endif #ifndef JS_WARN_UNUSED_RESULT @@ -136,6 +229,25 @@ # endif #endif +#ifdef NS_STATIC_CHECKING +/* + * Attributes for static analysis. Functions declared with JS_REQUIRES_STACK + * always have a valid cx->fp and can access it freely. Other functions can + * access cx->fp only after calling a function that "forces" the stack + * (i.e. lazily instantiates it as needed). + */ +# define JS_REQUIRES_STACK __attribute__((user("JS_REQUIRES_STACK"))) +# define JS_FORCES_STACK __attribute__((user("JS_FORCES_STACK"))) +/* + * Skip the JS_REQUIRES_STACK analysis within functions with this annotation. + */ +# define JS_IGNORE_STACK __attribute__((user("JS_IGNORE_STACK"))) +#else +# define JS_REQUIRES_STACK +# define JS_FORCES_STACK +# define JS_IGNORE_STACK +#endif + /*********************************************************************** ** MACROS: JS_BEGIN_MACRO ** JS_END_MACRO @@ -159,8 +271,17 @@ ** DESCRIPTION: ** Macro shorthands for conditional C++ extern block delimiters. ***********************************************************************/ -#define JS_BEGIN_EXTERN_C MOZ_BEGIN_EXTERN_C -#define JS_END_EXTERN_C MOZ_END_EXTERN_C +#ifdef __cplusplus + +# define JS_BEGIN_EXTERN_C extern "C" { +# define JS_END_EXTERN_C } + +#else + +# define JS_BEGIN_EXTERN_C +# define JS_END_EXTERN_C + +#endif /*********************************************************************** ** MACROS: JS_BIT @@ -168,7 +289,7 @@ ** DESCRIPTION: ** Bit masking macros. XXX n must be <= 31 to be portable ***********************************************************************/ -#define JS_BIT(n) ((uint32_t)1 << (n)) +#define JS_BIT(n) ((JSUint32)1 << (n)) #define JS_BITMASK(n) (JS_BIT(n) - 1) /*********************************************************************** @@ -184,7 +305,14 @@ #define JS_MIN(x,y) ((x)<(y)?(x):(y)) #define JS_MAX(x,y) ((x)>(y)?(x):(y)) -#include "jscpucfg.h" +#ifdef _MSC_VER +# include "jscpucfg.h" /* We can't auto-detect MSVC configuration */ +# if _MSC_VER < 1400 +# define NJ_NO_VARIADIC_MACROS +# endif +#else +# include "jsautocfg.h" /* Use auto-detected configuration */ +#endif /* * Define JS_64BIT iff we are building in an environment with 64-bit @@ -195,21 +323,11 @@ # define JS_64BIT # endif #elif defined(__GNUC__) -/* Additional GCC defines are when running on Solaris, AIX, and HPUX */ -# if defined(__x86_64__) || defined(__sparcv9) || \ - defined(__64BIT__) || defined(__LP64__) +# ifdef __x86_64__ # define JS_64BIT # endif -#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* Sun Studio C/C++ */ -# if defined(__x86_64) || defined(__sparcv9) -# define JS_64BIT -# endif -#elif defined(__xlc__) || defined(__xlC__) /* IBM XL C/C++ */ -# if defined(__64BIT__) -# define JS_64BIT -# endif -#elif defined(__HP_cc) || defined(__HP_aCC) /* HP-UX cc/aCC */ -# if defined(__LP64__) +#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) +# ifdef __x86_64 # define JS_64BIT # endif #else @@ -217,8 +335,53 @@ #endif +#include "jsinttypes.h" + JS_BEGIN_EXTERN_C +/************************************************************************ +** TYPES: JSUintn +** JSIntn +** DESCRIPTION: +** The JSIntn types are most appropriate for automatic variables. They are +** guaranteed to be at least 16 bits, though various architectures may +** define them to be wider (e.g., 32 or even 64 bits). These types are +** never valid for fields of a structure. +************************************************************************/ + +typedef int JSIntn; +typedef unsigned int JSUintn; + +/************************************************************************ +** TYPES: JSFloat64 +** DESCRIPTION: +** NSPR's floating point type is always 64 bits. +************************************************************************/ +typedef double JSFloat64; + +/************************************************************************ +** TYPES: JSSize +** DESCRIPTION: +** A type for representing the size of objects. +************************************************************************/ +typedef size_t JSSize; + +/************************************************************************ +** TYPES: JSPtrDiff +** DESCRIPTION: +** A type for pointer difference. Variables of this type are suitable +** for storing a pointer or pointer sutraction. +************************************************************************/ +typedef ptrdiff_t JSPtrdiff; + +/************************************************************************ +** TYPES: JSUptrdiff +** DESCRIPTION: +** A type for pointer difference. Variables of this type are suitable +** for storing a pointer or pointer sutraction. +************************************************************************/ +typedef JSUintPtr JSUptrdiff; + /************************************************************************ ** TYPES: JSBool ** DESCRIPTION: @@ -227,9 +390,30 @@ JS_BEGIN_EXTERN_C ** 'if (bool)', 'while (!bool)', '(bool) ? x : y' etc., to test booleans ** just as you would C int-valued conditions. ************************************************************************/ -typedef int JSBool; -#define JS_TRUE (int)1 -#define JS_FALSE (int)0 +typedef JSIntn JSBool; +#define JS_TRUE (JSIntn)1 +#define JS_FALSE (JSIntn)0 +/* +** Special: JS_NEITHER is used by the tracer to have tri-state booleans. +** This should not be used in new code. +*/ +#define JS_NEITHER (JSIntn)2 + +/************************************************************************ +** TYPES: JSPackedBool +** DESCRIPTION: +** Use JSPackedBool within structs where bitfields are not desireable +** but minimum and consistent overhead matters. +************************************************************************/ +typedef JSUint8 JSPackedBool; + +/* +** A JSWord is an integer that is the same size as a void* +*/ +typedef JSIntPtr JSWord; +typedef JSUintPtr JSUword; + +#include "jsotypes.h" /*********************************************************************** ** MACROS: JS_LIKELY diff --git a/js/spidermonkey-win32/include/jsutil.h b/js/spidermonkey-win32/include/jsutil.h index c20fbf1433..9da2674704 100644 --- a/js/spidermonkey-win32/include/jsutil.h +++ b/js/spidermonkey-win32/include/jsutil.h @@ -44,154 +44,377 @@ #ifndef jsutil_h___ #define jsutil_h___ -#include "mozilla/Attributes.h" +#include "jstypes.h" +#include +#include -#include "js/Utility.h" +JS_BEGIN_EXTERN_C -/* Forward declarations. */ -struct JSContext; +/* + * JS_Assert is present even in release builds, for the benefit of applications + * that build DEBUG and link against a non-DEBUG SpiderMonkey library. + */ +extern JS_PUBLIC_API(void) +JS_Assert(const char *s, const char *file, JSIntn ln); -static JS_ALWAYS_INLINE void * -js_memcpy(void *dst_, const void *src_, size_t len) -{ - char *dst = (char *) dst_; - const char *src = (const char *) src_; - JS_ASSERT_IF(dst >= src, (size_t) (dst - src) >= len); - JS_ASSERT_IF(src >= dst, (size_t) (src - dst) >= len); +#define JS_CRASH_UNLESS(__cond) \ + JS_BEGIN_MACRO \ + if (!(__cond)) { \ + *(int *)(uintptr_t)0xccadbeef = 0; \ + ((void(*)())0)(); /* More reliable, but doesn't say CCADBEEF */ \ + } \ + JS_END_MACRO - return memcpy(dst, src, len); +#ifdef DEBUG + +#define JS_ASSERT(expr) \ + ((expr) ? (void)0 : JS_Assert(#expr, __FILE__, __LINE__)) + +#define JS_ASSERT_IF(cond, expr) \ + ((!(cond) || (expr)) ? (void)0 : JS_Assert(#expr, __FILE__, __LINE__)) + +#define JS_NOT_REACHED(reason) \ + JS_Assert(reason, __FILE__, __LINE__) + +#define JS_ALWAYS_TRUE(expr) JS_ASSERT(expr) + +#define JS_ALWAYS_FALSE(expr) JS_ASSERT(!(expr)) + +# ifdef JS_THREADSAFE +# define JS_THREADSAFE_ASSERT(expr) JS_ASSERT(expr) +# else +# define JS_THREADSAFE_ASSERT(expr) ((void) 0) +# endif + +#else + +#define JS_ASSERT(expr) ((void) 0) +#define JS_ASSERT_IF(cond,expr) ((void) 0) +#define JS_NOT_REACHED(reason) +#define JS_ALWAYS_TRUE(expr) ((void) (expr)) +#define JS_ALWAYS_FALSE(expr) ((void) (expr)) +#define JS_THREADSAFE_ASSERT(expr) ((void) 0) + +#endif /* defined(DEBUG) */ + +/* + * Compile-time assert. "cond" must be a constant expression. + * The macro can be used only in places where an "extern" declaration is + * allowed. + */ + +#ifdef __SUNPRO_CC +/* + * Sun Studio C++ compiler has a bug + * "sizeof expression not accepted as size of array parameter" + * It happens when js_static_assert() function is declared inside functions. + * The bug number is 6688515. It is not public yet. + * Therefore, for Sun Studio, declare js_static_assert as an array instead. + */ +#define JS_STATIC_ASSERT(cond) extern char js_static_assert[(cond) ? 1 : -1] +#else +#ifdef __COUNTER__ + #define JS_STATIC_ASSERT_GLUE1(x,y) x##y + #define JS_STATIC_ASSERT_GLUE(x,y) JS_STATIC_ASSERT_GLUE1(x,y) + #define JS_STATIC_ASSERT(cond) \ + typedef int JS_STATIC_ASSERT_GLUE(js_static_assert, __COUNTER__)[(cond) ? 1 : -1] +#else + #define JS_STATIC_ASSERT(cond) extern void js_static_assert(int arg[(cond) ? 1 : -1]) +#endif +#endif + +#define JS_STATIC_ASSERT_IF(cond, expr) JS_STATIC_ASSERT(!(cond) || (expr)) + +/* + * Abort the process in a non-graceful manner. This will cause a core file, + * call to the debugger or other moral equivalent as well as causing the + * entire process to stop. + */ +extern JS_PUBLIC_API(void) JS_Abort(void); + +#ifdef DEBUG +# define JS_BASIC_STATS 1 +#endif + +#ifdef DEBUG_brendan +# define JS_SCOPE_DEPTH_METER 1 +#endif + +#ifdef JS_BASIC_STATS + +#include + +typedef struct JSBasicStats { + uint32 num; + uint32 max; + double sum; + double sqsum; + uint32 logscale; /* logarithmic scale: 0 (linear), 2, 10 */ + uint32 hist[11]; +} JSBasicStats; + +#define JS_INIT_STATIC_BASIC_STATS {0,0,0,0,0,{0,0,0,0,0,0,0,0,0,0,0}} +#define JS_BASIC_STATS_INIT(bs) memset((bs), 0, sizeof(JSBasicStats)) + +#define JS_BASIC_STATS_ACCUM(bs,val) \ + JS_BasicStatsAccum(bs, val) + +#define JS_MeanAndStdDevBS(bs,sigma) \ + JS_MeanAndStdDev((bs)->num, (bs)->sum, (bs)->sqsum, sigma) + +extern void +JS_BasicStatsAccum(JSBasicStats *bs, uint32 val); + +extern double +JS_MeanAndStdDev(uint32 num, double sum, double sqsum, double *sigma); + +extern void +JS_DumpBasicStats(JSBasicStats *bs, const char *title, FILE *fp); + +extern void +JS_DumpHistogram(JSBasicStats *bs, FILE *fp); + +#else + +#define JS_BASIC_STATS_ACCUM(bs,val) /* nothing */ + +#endif /* JS_BASIC_STATS */ + + +#if defined(DEBUG_notme) && defined(XP_UNIX) + +typedef struct JSCallsite JSCallsite; + +struct JSCallsite { + uint32 pc; + char *name; + const char *library; + int offset; + JSCallsite *parent; + JSCallsite *siblings; + JSCallsite *kids; + void *handy; +}; + +extern JS_FRIEND_API(JSCallsite *) +JS_Backtrace(int skip); + +extern JS_FRIEND_API(void) +JS_DumpBacktrace(JSCallsite *trace); +#endif + +#if defined JS_USE_CUSTOM_ALLOCATOR + +#include "jscustomallocator.h" + +#else + +static JS_INLINE void* js_malloc(size_t bytes) { + return malloc(bytes); } +static JS_INLINE void* js_calloc(size_t bytes) { + return calloc(bytes, 1); +} + +static JS_INLINE void* js_realloc(void* p, size_t bytes) { + return realloc(p, bytes); +} + +static JS_INLINE void js_free(void* p) { + free(p); +} +#endif/* JS_USE_CUSTOM_ALLOCATOR */ + +JS_END_EXTERN_C + #ifdef __cplusplus + +/* + * Using vanilla new/new[] is unsafe in SpiderMonkey because they throw on + * failure instead of returning NULL, which is what SpiderMonkey expects. + * js_new()/js_array_new() should be used instead, and memory allocated with + * them should be deallocated with js_delete()/js_array_delete(). + * + * If you have a class with a private constructor or destructor, you can + * make js_new/js_delete a friend. This can be fiddly, and the interaction of + * template functions, friend functions and namespaces can overwhelm even + * modern compilers. Manual inlining is probably easier. + * + * (If you're wondering why we can't just use the 'nothrow' variant of + * new/new[], it's because we want to mediate *all* allocations within + * SpiderMonkey, to satisfy any embedders using JS_USE_CUSTOM_ALLOCATOR.) + */ + +#define JS_NEW_BODY(t, parms) \ + void *memory = js_malloc(sizeof(t)); \ + return memory ? new(memory) t parms : NULL; + +template +JS_ALWAYS_INLINE T *js_new() { + JS_NEW_BODY(T, ()) +} + +template +JS_ALWAYS_INLINE T *js_new(const P1 &p1) { + JS_NEW_BODY(T, (p1)) +} + +template +JS_ALWAYS_INLINE T *js_new(const P1 &p1, const P2 &p2) { + JS_NEW_BODY(T, (p1, p2)) +} + +template +JS_ALWAYS_INLINE T *js_new(const P1 &p1, const P2 &p2, const P3 &p3) { + JS_NEW_BODY(T, (p1, p2, p3)) +} + +template +JS_ALWAYS_INLINE T *js_new(const P1 &p1, const P2 &p2, const P3 &p3, const P4 &p4) { + JS_NEW_BODY(T, (p1, p2, p3, p4)) +} + +/* ...add additional js_new()s as necessary... */ + +#undef JS_NEW_BODY + +template +JS_ALWAYS_INLINE void js_delete(T *p) { + if (p) { + p->~T(); + js_free(p); + } +} + +static const int JSMinAlignment = 8; + +template +JS_ALWAYS_INLINE T *js_array_new(size_t n) { + /* The length is stored just before the vector memory. */ + uint64 numBytes64 = uint64(JSMinAlignment) + uint64(sizeof(T)) * uint64(n); + size_t numBytes = size_t(numBytes64); + if (numBytes64 != numBytes) { + JS_ASSERT(0); /* we want to know if this happens in debug builds */ + return NULL; + } + void *memory = js_malloc(numBytes); + if (!memory) + return NULL; + *(size_t *)memory = n; + memory = (void*)(uintptr_t(memory) + JSMinAlignment); + return new(memory) T[n]; +} + +template +JS_ALWAYS_INLINE void js_array_delete(T *p) { + if (p) { + void* p0 = (void *)(uintptr_t(p) - JSMinAlignment); + size_t n = *(size_t *)p0; + for (size_t i = 0; i < n; i++) + (p + i)->~T(); + js_free(p0); + } +} + +/** + * The following classes are designed to cause assertions to detect + * inadvertent use of guard objects as temporaries. In other words, + * when we have a guard object whose only purpose is its constructor and + * destructor (and is never otherwise referenced), the intended use + * might be: + * JSAutoTempValueRooter tvr(cx, 1, &val); + * but is is easy to accidentally write: + * JSAutoTempValueRooter(cx, 1, &val); + * which compiles just fine, but runs the destructor well before the + * intended time. + * + * They work by adding (#ifdef DEBUG) an additional parameter to the + * guard object's constructor, with a default value, so that users of + * the guard object's API do not need to do anything. The default value + * of this parameter is a temporary object. C++ (ISO/IEC 14882:1998), + * section 12.2 [class.temporary], clauses 4 and 5 seem to assume a + * guarantee that temporaries are destroyed in the reverse of their + * construction order, but I actually can't find a statement that that + * is true in the general case (beyond the two specific cases mentioned + * there). However, it seems to be true. + * + * These classes are intended to be used only via the macros immediately + * below them: + * JS_DECL_USE_GUARD_OBJECT_NOTIFIER declares (ifdef DEBUG) a member + * variable, and should be put where a declaration of a private + * member variable would be placed. + * JS_GUARD_OBJECT_NOTIFIER_PARAM should be placed at the end of the + * parameters to each constructor of the guard object; it declares + * (ifdef DEBUG) an additional parameter. + * JS_GUARD_OBJECT_NOTIFIER_INIT is a statement that belongs in each + * constructor. It uses the parameter declared by + * JS_GUARD_OBJECT_NOTIFIER_PARAM. + */ +#ifdef DEBUG +class JSGuardObjectNotifier +{ +private: + bool* mStatementDone; +public: + JSGuardObjectNotifier() : mStatementDone(NULL) {} + + ~JSGuardObjectNotifier() { + *mStatementDone = true; + } + + void setStatementDone(bool *aStatementDone) { + mStatementDone = aStatementDone; + } +}; + +class JSGuardObjectNotificationReceiver +{ +private: + bool mStatementDone; +public: + JSGuardObjectNotificationReceiver() : mStatementDone(false) {} + + ~JSGuardObjectNotificationReceiver() { + /* + * Assert that the guard object was not used as a temporary. + * (Note that this assert might also fire if Init is not called + * because the guard object's implementation is not using the + * above macros correctly.) + */ + JS_ASSERT(mStatementDone); + } + + void Init(const JSGuardObjectNotifier &aNotifier) { + /* + * aNotifier is passed as a const reference so that we can pass a + * temporary, but we really intend it as non-const + */ + const_cast(aNotifier). + setStatementDone(&mStatementDone); + } +}; + +#define JS_DECL_USE_GUARD_OBJECT_NOTIFIER \ + JSGuardObjectNotificationReceiver _mCheckNotUsedAsTemporary; +#define JS_GUARD_OBJECT_NOTIFIER_PARAM \ + , const JSGuardObjectNotifier& _notifier = JSGuardObjectNotifier() +#define JS_GUARD_OBJECT_NOTIFIER_PARAM0 \ + const JSGuardObjectNotifier& _notifier = JSGuardObjectNotifier() +#define JS_GUARD_OBJECT_NOTIFIER_INIT \ + JS_BEGIN_MACRO _mCheckNotUsedAsTemporary.Init(_notifier); JS_END_MACRO + +#else /* defined(DEBUG) */ + +#define JS_DECL_USE_GUARD_OBJECT_NOTIFIER +#define JS_GUARD_OBJECT_NOTIFIER_PARAM +#define JS_GUARD_OBJECT_NOTIFIER_PARAM0 +#define JS_GUARD_OBJECT_NOTIFIER_INIT JS_BEGIN_MACRO JS_END_MACRO + +#endif /* !defined(DEBUG) */ + namespace js { -template -class AlignedPtrAndFlag -{ - uintptr_t bits; - - public: - AlignedPtrAndFlag(T *t, bool flag) { - JS_ASSERT((uintptr_t(t) & 1) == 0); - bits = uintptr_t(t) | uintptr_t(flag); - } - - T *ptr() const { - return (T *)(bits & ~uintptr_t(1)); - } - - bool flag() const { - return (bits & 1) != 0; - } - - void setPtr(T *t) { - JS_ASSERT((uintptr_t(t) & 1) == 0); - bits = uintptr_t(t) | uintptr_t(flag()); - } - - void setFlag() { - bits |= 1; - } - - void unsetFlag() { - bits &= ~uintptr_t(1); - } - - void set(T *t, bool flag) { - JS_ASSERT((uintptr_t(t) & 1) == 0); - bits = uintptr_t(t) | flag; - } -}; - -template -static inline void -Reverse(T *beg, T *end) -{ - while (beg != end) { - if (--end == beg) - return; - T tmp = *beg; - *beg = *end; - *end = tmp; - ++beg; - } -} - -template -static inline T * -Find(T *beg, T *end, const T &v) -{ - for (T *p = beg; p != end; ++p) { - if (*p == v) - return p; - } - return end; -} - -template -static inline typename Container::ElementType * -Find(Container &c, const typename Container::ElementType &v) -{ - return Find(c.begin(), c.end(), v); -} - -template -void -ForEach(InputIterT begin, InputIterT end, CallableT f) -{ - for (; begin != end; ++begin) - f(*begin); -} - -template -static inline T -Min(T t1, T t2) -{ - return t1 < t2 ? t1 : t2; -} - -template -static inline T -Max(T t1, T t2) -{ - return t1 > t2 ? t1 : t2; -} - -/* Allows a const variable to be initialized after its declaration. */ -template -static T& -InitConst(const T &t) -{ - return const_cast(t); -} - -template -JS_ALWAYS_INLINE T & -ImplicitCast(U &u) -{ - T &t = u; - return t; -} - -template -class AutoScopedAssign -{ - private: - JS_DECL_USE_GUARD_OBJECT_NOTIFIER - T *addr; - T old; - - public: - AutoScopedAssign(T *addr, const T &value JS_GUARD_OBJECT_NOTIFIER_PARAM) - : addr(addr), old(*addr) - { - JS_GUARD_OBJECT_NOTIFIER_INIT; - *addr = value; - } - - ~AutoScopedAssign() { *addr = old; } -}; - template JS_ALWAYS_INLINE static void PodZero(T *t) @@ -203,14 +426,7 @@ template JS_ALWAYS_INLINE static void PodZero(T *t, size_t nelem) { - /* - * This function is often called with 'nelem' small; we use an - * inline loop instead of calling 'memset' with a non-constant - * length. The compiler should inline the memset call with constant - * size, though. - */ - for (T *end = t + nelem; t != end; ++t) - memset(t, 0, sizeof(T)); + memset(t, 0, nelem * sizeof(T)); } /* @@ -230,13 +446,6 @@ PodArrayZero(T (&t)[N]) memset(t, 0, N * sizeof(T)); } -template -JS_ALWAYS_INLINE static void -PodAssign(T *dst, const T *src) -{ - js_memcpy((char *) dst, (const char *) src, sizeof(T)); -} - template JS_ALWAYS_INLINE static void PodCopy(T *dst, const T *src, size_t nelem) @@ -246,163 +455,15 @@ PodCopy(T *dst, const T *src, size_t nelem) JS_ASSERT_IF(src >= dst, size_t(src - dst) >= nelem); if (nelem < 128) { - /* - * Avoid using operator= in this loop, as it may have been - * intentionally deleted by the POD type. - */ for (const T *srcend = src + nelem; src != srcend; ++src, ++dst) - PodAssign(dst, src); + *dst = *src; } else { memcpy(dst, src, nelem * sizeof(T)); } } -template -JS_ALWAYS_INLINE static bool -PodEqual(T *one, T *two, size_t len) -{ - if (len < 128) { - T *p1end = one + len; - for (T *p1 = one, *p2 = two; p1 != p1end; ++p1, ++p2) { - if (*p1 != *p2) - return false; - } - return true; - } +} /* namespace js */ - return !memcmp(one, two, len * sizeof(T)); -} - -JS_ALWAYS_INLINE static size_t -UnsignedPtrDiff(const void *bigger, const void *smaller) -{ - return size_t(bigger) - size_t(smaller); -} - -/* - * Ordinarily, a function taking a JSContext* 'cx' parameter reports errors on - * the context. In some cases, functions optionally report and indicate this by - * taking a nullable 'maybecx' parameter. In some cases, though, a function - * always needs a 'cx', but optionally reports. This option is presented by the - * MaybeReportError. - */ -enum MaybeReportError { REPORT_ERROR = true, DONT_REPORT_ERROR = false }; - -} /* namespace js */ -#endif /* __cplusplus */ - -/* - * JS_ROTATE_LEFT32 - * - * There is no rotate operation in the C Language so the construct (a << 4) | - * (a >> 28) is used instead. Most compilers convert this to a rotate - * instruction but some versions of MSVC don't without a little help. To get - * MSVC to generate a rotate instruction, we have to use the _rotl intrinsic - * and use a pragma to make _rotl inline. - * - * MSVC in VS2005 will do an inline rotate instruction on the above construct. - */ -#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64) || \ - defined(_M_X64)) -#include -#pragma intrinsic(_rotl) -#define JS_ROTATE_LEFT32(a, bits) _rotl(a, bits) -#else -#define JS_ROTATE_LEFT32(a, bits) (((a) << (bits)) | ((a) >> (32 - (bits)))) -#endif - -/* Static control-flow checks. */ -#ifdef NS_STATIC_CHECKING -/* Trigger a control flow check to make sure that code flows through label */ -inline __attribute__ ((unused)) void MUST_FLOW_THROUGH(const char *label) {} - -/* Avoid unused goto-label warnings. */ -# define MUST_FLOW_LABEL(label) goto label; label: - -#else -# define MUST_FLOW_THROUGH(label) ((void) 0) -# define MUST_FLOW_LABEL(label) -#endif - -/* Crash diagnostics */ -#ifdef DEBUG -# define JS_CRASH_DIAGNOSTICS 1 -#endif -#ifdef JS_CRASH_DIAGNOSTICS -# define JS_POISON(p, val, size) memset((p), (val), (size)) -# define JS_OPT_ASSERT(expr) \ - ((expr) ? (void)0 : MOZ_Assert(#expr, __FILE__, __LINE__)) -# define JS_OPT_ASSERT_IF(cond, expr) \ - ((!(cond) || (expr)) ? (void)0 : MOZ_Assert(#expr, __FILE__, __LINE__)) -#else -# define JS_POISON(p, val, size) ((void) 0) -# define JS_OPT_ASSERT(expr) ((void) 0) -# define JS_OPT_ASSERT_IF(cond, expr) ((void) 0) -#endif - -/* Basic stats */ -#ifdef DEBUG -# define JS_BASIC_STATS 1 -#endif -#ifdef JS_BASIC_STATS -# include -typedef struct JSBasicStats { - uint32_t num; - uint32_t max; - double sum; - double sqsum; - uint32_t logscale; /* logarithmic scale: 0 (linear), 2, 10 */ - uint32_t hist[11]; -} JSBasicStats; -# define JS_INIT_STATIC_BASIC_STATS {0,0,0,0,0,{0,0,0,0,0,0,0,0,0,0,0}} -# define JS_BASIC_STATS_INIT(bs) memset((bs), 0, sizeof(JSBasicStats)) -# define JS_BASIC_STATS_ACCUM(bs,val) \ - JS_BasicStatsAccum(bs, val) -# define JS_MeanAndStdDevBS(bs,sigma) \ - JS_MeanAndStdDev((bs)->num, (bs)->sum, (bs)->sqsum, sigma) -extern void -JS_BasicStatsAccum(JSBasicStats *bs, uint32_t val); -extern double -JS_MeanAndStdDev(uint32_t num, double sum, double sqsum, double *sigma); -extern void -JS_DumpBasicStats(JSBasicStats *bs, const char *title, FILE *fp); -extern void -JS_DumpHistogram(JSBasicStats *bs, FILE *fp); -#else -# define JS_BASIC_STATS_ACCUM(bs,val) -#endif - -/* A jsbitmap_t is a long integer that can be used for bitmaps. */ -typedef size_t jsbitmap; -#define JS_TEST_BIT(_map,_bit) ((_map)[(_bit)>>JS_BITS_PER_WORD_LOG2] & \ - ((jsbitmap)1<<((_bit)&(JS_BITS_PER_WORD-1)))) -#define JS_SET_BIT(_map,_bit) ((_map)[(_bit)>>JS_BITS_PER_WORD_LOG2] |= \ - ((jsbitmap)1<<((_bit)&(JS_BITS_PER_WORD-1)))) -#define JS_CLEAR_BIT(_map,_bit) ((_map)[(_bit)>>JS_BITS_PER_WORD_LOG2] &= \ - ~((jsbitmap)1<<((_bit)&(JS_BITS_PER_WORD-1)))) - -/* Wrapper for various macros to stop warnings coming from their expansions. */ -#if defined(__clang__) -# define JS_SILENCE_UNUSED_VALUE_IN_EXPR(expr) \ - JS_BEGIN_MACRO \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Wunused-value\"") \ - expr; \ - _Pragma("clang diagnostic pop") \ - JS_END_MACRO -#elif (__GNUC__ >= 5) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) -# define JS_SILENCE_UNUSED_VALUE_IN_EXPR(expr) \ - JS_BEGIN_MACRO \ - _Pragma("GCC diagnostic push") \ - _Pragma("GCC diagnostic ignored \"-Wunused-but-set-variable\"") \ - expr; \ - _Pragma("GCC diagnostic pop") \ - JS_END_MACRO -#else -# define JS_SILENCE_UNUSED_VALUE_IN_EXPR(expr) \ - JS_BEGIN_MACRO \ - expr; \ - JS_END_MACRO -#endif +#endif /* defined(__cplusplus) */ #endif /* jsutil_h___ */ diff --git a/js/spidermonkey-win32/include/jsval.h b/js/spidermonkey-win32/include/jsval.h index 1c07c7f3d2..f6298625c9 100644 --- a/js/spidermonkey-win32/include/jsval.h +++ b/js/spidermonkey-win32/include/jsval.h @@ -40,55 +40,20 @@ #ifndef jsvalimpl_h__ #define jsvalimpl_h__ /* - * Implementation details for js::Value in jsapi.h. + * JS value implementation details for operations on jsval and jsid. + * Embeddings should not rely on any of the definitions in this file. For a + * description of the value representation and the engine-internal C++ value + * interface, js::Value, see jsvalue.h. */ -#include "js/Utility.h" +#include "jsutil.h" JS_BEGIN_EXTERN_C -/******************************************************************************/ - -/* To avoid a circular dependency, pull in the necessary pieces of jsnum.h. */ - -#define JSDOUBLE_SIGNBIT (((uint64_t) 1) << 63) -#define JSDOUBLE_EXPMASK (((uint64_t) 0x7ff) << 52) -#define JSDOUBLE_MANTMASK ((((uint64_t) 1) << 52) - 1) -#define JSDOUBLE_HI32_SIGNBIT 0x80000000 - -static JS_ALWAYS_INLINE JSBool -JSDOUBLE_IS_NEGZERO(double d) -{ - union { - struct { -#if defined(IS_LITTLE_ENDIAN) && !defined(FPU_IS_ARM_FPA) - uint32_t lo, hi; -#else - uint32_t hi, lo; -#endif - } s; - double d; - } x; - if (d != 0) - return JS_FALSE; - x.d = d; - return (x.s.hi & JSDOUBLE_HI32_SIGNBIT) != 0; -} - -static JS_ALWAYS_INLINE JSBool -JSDOUBLE_IS_INT32(double d, int32_t* pi) -{ - if (JSDOUBLE_IS_NEGZERO(d)) - return JS_FALSE; - return d == (*pi = (int32_t)d); -} - -/******************************************************************************/ - /* * Try to get jsvals 64-bit aligned. We could almost assert that all values are * aligned, but MSVC and GCC occasionally break alignment. */ -#if defined(__GNUC__) || defined(__xlc__) || defined(__xlC__) +#ifdef __GNUC__ # define JSVAL_ALIGNMENT __attribute__((aligned (8))) #elif defined(_MSC_VER) /* @@ -98,8 +63,6 @@ JSDOUBLE_IS_INT32(double d, int32_t* pi) # define JSVAL_ALIGNMENT #elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) # define JSVAL_ALIGNMENT -#elif defined(__HP_cc) || defined(__HP_aCC) -# define JSVAL_ALIGNMENT #endif #if JS_BITS_PER_WORD == 64 @@ -111,7 +74,7 @@ JSDOUBLE_IS_INT32(double d, int32_t* pi) * nice symbolic type tags, however we can only do this when we can force the * underlying type of the enum to be the desired size. */ -#if defined(__cplusplus) && !defined(__SUNPRO_CC) && !defined(__xlC__) +#if defined(__cplusplus) && !defined(__SUNPRO_CC) #if defined(_MSC_VER) # define JS_ENUM_HEADER(id, type) enum id : type @@ -126,7 +89,7 @@ JSDOUBLE_IS_INT32(double d, int32_t* pi) #endif /* Remember to propagate changes to the C defines below. */ -JS_ENUM_HEADER(JSValueType, uint8_t) +JS_ENUM_HEADER(JSValueType, uint8) { JSVAL_TYPE_DOUBLE = 0x00, JSVAL_TYPE_INT32 = 0x01, @@ -137,9 +100,15 @@ JS_ENUM_HEADER(JSValueType, uint8_t) JSVAL_TYPE_NULL = 0x06, JSVAL_TYPE_OBJECT = 0x07, - /* These never appear in a jsval; they are only provided as an out-of-band value. */ - JSVAL_TYPE_UNKNOWN = 0x20, - JSVAL_TYPE_MISSING = 0x21 + /* The below types never appear in a jsval; they are only used in tracing. */ + + JSVAL_TYPE_NONFUNOBJ = 0x57, + JSVAL_TYPE_FUNOBJ = 0x67, + + JSVAL_TYPE_STRORNULL = 0x97, + JSVAL_TYPE_OBJORNULL = 0x98, + + JSVAL_TYPE_BOXED = 0x99 } JS_ENUM_FOOTER(JSValueType); JS_STATIC_ASSERT(sizeof(JSValueType) == 1); @@ -147,9 +116,9 @@ JS_STATIC_ASSERT(sizeof(JSValueType) == 1); #if JS_BITS_PER_WORD == 32 /* Remember to propagate changes to the C defines below. */ -JS_ENUM_HEADER(JSValueTag, uint32_t) +JS_ENUM_HEADER(JSValueTag, uint32) { - JSVAL_TAG_CLEAR = 0xFFFFFF80, + JSVAL_TAG_CLEAR = 0xFFFF0000, JSVAL_TAG_INT32 = JSVAL_TAG_CLEAR | JSVAL_TYPE_INT32, JSVAL_TAG_UNDEFINED = JSVAL_TAG_CLEAR | JSVAL_TYPE_UNDEFINED, JSVAL_TAG_STRING = JSVAL_TAG_CLEAR | JSVAL_TYPE_STRING, @@ -164,7 +133,7 @@ JS_STATIC_ASSERT(sizeof(JSValueTag) == 4); #elif JS_BITS_PER_WORD == 64 /* Remember to propagate changes to the C defines below. */ -JS_ENUM_HEADER(JSValueTag, uint32_t) +JS_ENUM_HEADER(JSValueTag, uint32) { JSVAL_TAG_MAX_DOUBLE = 0x1FFF0, JSVAL_TAG_INT32 = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32, @@ -176,70 +145,75 @@ JS_ENUM_HEADER(JSValueTag, uint32_t) JSVAL_TAG_OBJECT = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_OBJECT } JS_ENUM_FOOTER(JSValueTag); -JS_STATIC_ASSERT(sizeof(JSValueTag) == sizeof(uint32_t)); +JS_STATIC_ASSERT(sizeof(JSValueTag) == sizeof(uint32)); -JS_ENUM_HEADER(JSValueShiftedTag, uint64_t) +JS_ENUM_HEADER(JSValueShiftedTag, uint64) { - JSVAL_SHIFTED_TAG_MAX_DOUBLE = ((((uint64_t)JSVAL_TAG_MAX_DOUBLE) << JSVAL_TAG_SHIFT) | 0xFFFFFFFF), - JSVAL_SHIFTED_TAG_INT32 = (((uint64_t)JSVAL_TAG_INT32) << JSVAL_TAG_SHIFT), - JSVAL_SHIFTED_TAG_UNDEFINED = (((uint64_t)JSVAL_TAG_UNDEFINED) << JSVAL_TAG_SHIFT), - JSVAL_SHIFTED_TAG_STRING = (((uint64_t)JSVAL_TAG_STRING) << JSVAL_TAG_SHIFT), - JSVAL_SHIFTED_TAG_BOOLEAN = (((uint64_t)JSVAL_TAG_BOOLEAN) << JSVAL_TAG_SHIFT), - JSVAL_SHIFTED_TAG_MAGIC = (((uint64_t)JSVAL_TAG_MAGIC) << JSVAL_TAG_SHIFT), - JSVAL_SHIFTED_TAG_NULL = (((uint64_t)JSVAL_TAG_NULL) << JSVAL_TAG_SHIFT), - JSVAL_SHIFTED_TAG_OBJECT = (((uint64_t)JSVAL_TAG_OBJECT) << JSVAL_TAG_SHIFT) + JSVAL_SHIFTED_TAG_MAX_DOUBLE = ((((uint64)JSVAL_TAG_MAX_DOUBLE) << JSVAL_TAG_SHIFT) | 0xFFFFFFFF), + JSVAL_SHIFTED_TAG_INT32 = (((uint64)JSVAL_TAG_INT32) << JSVAL_TAG_SHIFT), + JSVAL_SHIFTED_TAG_UNDEFINED = (((uint64)JSVAL_TAG_UNDEFINED) << JSVAL_TAG_SHIFT), + JSVAL_SHIFTED_TAG_STRING = (((uint64)JSVAL_TAG_STRING) << JSVAL_TAG_SHIFT), + JSVAL_SHIFTED_TAG_BOOLEAN = (((uint64)JSVAL_TAG_BOOLEAN) << JSVAL_TAG_SHIFT), + JSVAL_SHIFTED_TAG_MAGIC = (((uint64)JSVAL_TAG_MAGIC) << JSVAL_TAG_SHIFT), + JSVAL_SHIFTED_TAG_NULL = (((uint64)JSVAL_TAG_NULL) << JSVAL_TAG_SHIFT), + JSVAL_SHIFTED_TAG_OBJECT = (((uint64)JSVAL_TAG_OBJECT) << JSVAL_TAG_SHIFT) } JS_ENUM_FOOTER(JSValueShiftedTag); -JS_STATIC_ASSERT(sizeof(JSValueShiftedTag) == sizeof(uint64_t)); +JS_STATIC_ASSERT(sizeof(JSValueShiftedTag) == sizeof(uint64)); #endif #else /* defined(__cplusplus) */ -typedef uint8_t JSValueType; -#define JSVAL_TYPE_DOUBLE ((uint8_t)0x00) -#define JSVAL_TYPE_INT32 ((uint8_t)0x01) -#define JSVAL_TYPE_UNDEFINED ((uint8_t)0x02) -#define JSVAL_TYPE_BOOLEAN ((uint8_t)0x03) -#define JSVAL_TYPE_MAGIC ((uint8_t)0x04) -#define JSVAL_TYPE_STRING ((uint8_t)0x05) -#define JSVAL_TYPE_NULL ((uint8_t)0x06) -#define JSVAL_TYPE_OBJECT ((uint8_t)0x07) -#define JSVAL_TYPE_UNKNOWN ((uint8_t)0x20) +typedef uint8 JSValueType; +#define JSVAL_TYPE_DOUBLE ((uint8)0x00) +#define JSVAL_TYPE_INT32 ((uint8)0x01) +#define JSVAL_TYPE_UNDEFINED ((uint8)0x02) +#define JSVAL_TYPE_BOOLEAN ((uint8)0x03) +#define JSVAL_TYPE_MAGIC ((uint8)0x04) +#define JSVAL_TYPE_STRING ((uint8)0x05) +#define JSVAL_TYPE_NULL ((uint8)0x06) +#define JSVAL_TYPE_OBJECT ((uint8)0x07) +#define JSVAL_TYPE_NONFUNOBJ ((uint8)0x57) +#define JSVAL_TYPE_FUNOBJ ((uint8)0x67) +#define JSVAL_TYPE_STRORNULL ((uint8)0x97) +#define JSVAL_TYPE_OBJORNULL ((uint8)0x98) +#define JSVAL_TYPE_BOXED ((uint8)0x99) +#define JSVAL_TYPE_UNINITIALIZED ((uint8)0xcd) #if JS_BITS_PER_WORD == 32 -typedef uint32_t JSValueTag; -#define JSVAL_TAG_CLEAR ((uint32_t)(0xFFFFFF80)) -#define JSVAL_TAG_INT32 ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_INT32)) -#define JSVAL_TAG_UNDEFINED ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_UNDEFINED)) -#define JSVAL_TAG_STRING ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_STRING)) -#define JSVAL_TAG_BOOLEAN ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_BOOLEAN)) -#define JSVAL_TAG_MAGIC ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_MAGIC)) -#define JSVAL_TAG_NULL ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_NULL)) -#define JSVAL_TAG_OBJECT ((uint32_t)(JSVAL_TAG_CLEAR | JSVAL_TYPE_OBJECT)) +typedef uint32 JSValueTag; +#define JSVAL_TAG_CLEAR ((uint32)(0xFFFF0000)) +#define JSVAL_TAG_INT32 ((uint32)(JSVAL_TAG_CLEAR | JSVAL_TYPE_INT32)) +#define JSVAL_TAG_UNDEFINED ((uint32)(JSVAL_TAG_CLEAR | JSVAL_TYPE_UNDEFINED)) +#define JSVAL_TAG_STRING ((uint32)(JSVAL_TAG_CLEAR | JSVAL_TYPE_STRING)) +#define JSVAL_TAG_BOOLEAN ((uint32)(JSVAL_TAG_CLEAR | JSVAL_TYPE_BOOLEAN)) +#define JSVAL_TAG_MAGIC ((uint32)(JSVAL_TAG_CLEAR | JSVAL_TYPE_MAGIC)) +#define JSVAL_TAG_NULL ((uint32)(JSVAL_TAG_CLEAR | JSVAL_TYPE_NULL)) +#define JSVAL_TAG_OBJECT ((uint32)(JSVAL_TAG_CLEAR | JSVAL_TYPE_OBJECT)) #elif JS_BITS_PER_WORD == 64 -typedef uint32_t JSValueTag; -#define JSVAL_TAG_MAX_DOUBLE ((uint32_t)(0x1FFF0)) -#define JSVAL_TAG_INT32 (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32) -#define JSVAL_TAG_UNDEFINED (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_UNDEFINED) -#define JSVAL_TAG_STRING (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_STRING) -#define JSVAL_TAG_BOOLEAN (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_BOOLEAN) -#define JSVAL_TAG_MAGIC (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_MAGIC) -#define JSVAL_TAG_NULL (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_NULL) -#define JSVAL_TAG_OBJECT (uint32_t)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_OBJECT) +typedef uint32 JSValueTag; +#define JSVAL_TAG_MAX_DOUBLE ((uint32)(0x1FFF0)) +#define JSVAL_TAG_INT32 (uint32)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32) +#define JSVAL_TAG_UNDEFINED (uint32)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_UNDEFINED) +#define JSVAL_TAG_STRING (uint32)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_STRING) +#define JSVAL_TAG_BOOLEAN (uint32)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_BOOLEAN) +#define JSVAL_TAG_MAGIC (uint32)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_MAGIC) +#define JSVAL_TAG_NULL (uint32)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_NULL) +#define JSVAL_TAG_OBJECT (uint32)(JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_OBJECT) -typedef uint64_t JSValueShiftedTag; -#define JSVAL_SHIFTED_TAG_MAX_DOUBLE ((((uint64_t)JSVAL_TAG_MAX_DOUBLE) << JSVAL_TAG_SHIFT) | 0xFFFFFFFF) -#define JSVAL_SHIFTED_TAG_INT32 (((uint64_t)JSVAL_TAG_INT32) << JSVAL_TAG_SHIFT) -#define JSVAL_SHIFTED_TAG_UNDEFINED (((uint64_t)JSVAL_TAG_UNDEFINED) << JSVAL_TAG_SHIFT) -#define JSVAL_SHIFTED_TAG_STRING (((uint64_t)JSVAL_TAG_STRING) << JSVAL_TAG_SHIFT) -#define JSVAL_SHIFTED_TAG_BOOLEAN (((uint64_t)JSVAL_TAG_BOOLEAN) << JSVAL_TAG_SHIFT) -#define JSVAL_SHIFTED_TAG_MAGIC (((uint64_t)JSVAL_TAG_MAGIC) << JSVAL_TAG_SHIFT) -#define JSVAL_SHIFTED_TAG_NULL (((uint64_t)JSVAL_TAG_NULL) << JSVAL_TAG_SHIFT) -#define JSVAL_SHIFTED_TAG_OBJECT (((uint64_t)JSVAL_TAG_OBJECT) << JSVAL_TAG_SHIFT) +typedef uint64 JSValueShiftedTag; +#define JSVAL_SHIFTED_TAG_MAX_DOUBLE ((((uint64)JSVAL_TAG_MAX_DOUBLE) << JSVAL_TAG_SHIFT) | 0xFFFFFFFF) +#define JSVAL_SHIFTED_TAG_INT32 (((uint64)JSVAL_TAG_INT32) << JSVAL_TAG_SHIFT) +#define JSVAL_SHIFTED_TAG_UNDEFINED (((uint64)JSVAL_TAG_UNDEFINED) << JSVAL_TAG_SHIFT) +#define JSVAL_SHIFTED_TAG_STRING (((uint64)JSVAL_TAG_STRING) << JSVAL_TAG_SHIFT) +#define JSVAL_SHIFTED_TAG_BOOLEAN (((uint64)JSVAL_TAG_BOOLEAN) << JSVAL_TAG_SHIFT) +#define JSVAL_SHIFTED_TAG_MAGIC (((uint64)JSVAL_TAG_MAGIC) << JSVAL_TAG_SHIFT) +#define JSVAL_SHIFTED_TAG_NULL (((uint64)JSVAL_TAG_NULL) << JSVAL_TAG_SHIFT) +#define JSVAL_SHIFTED_TAG_OBJECT (((uint64)JSVAL_TAG_OBJECT) << JSVAL_TAG_SHIFT) #endif /* JS_BITS_PER_WORD */ #endif /* defined(__cplusplus) && !defined(__SUNPRO_CC) */ @@ -248,6 +222,8 @@ typedef uint64_t JSValueShiftedTag; #define JSVAL_UPPER_EXCL_TYPE_OF_PRIMITIVE_SET JSVAL_TYPE_OBJECT #define JSVAL_UPPER_INCL_TYPE_OF_NUMBER_SET JSVAL_TYPE_INT32 #define JSVAL_LOWER_INCL_TYPE_OF_PTR_PAYLOAD_SET JSVAL_TYPE_MAGIC +#define JSVAL_UPPER_INCL_TYPE_OF_VALUE_SET JSVAL_TYPE_OBJECT +#define JSVAL_UPPER_INCL_TYPE_OF_BOXABLE_SET JSVAL_TYPE_FUNOBJ #if JS_BITS_PER_WORD == 32 @@ -263,11 +239,12 @@ typedef uint64_t JSValueShiftedTag; #define JSVAL_PAYLOAD_MASK 0x00007FFFFFFFFFFFLL #define JSVAL_TAG_MASK 0xFFFF800000000000LL #define JSVAL_TYPE_TO_TAG(type) ((JSValueTag)(JSVAL_TAG_MAX_DOUBLE | (type))) -#define JSVAL_TYPE_TO_SHIFTED_TAG(type) (((uint64_t)JSVAL_TYPE_TO_TAG(type)) << JSVAL_TAG_SHIFT) +#define JSVAL_TYPE_TO_SHIFTED_TAG(type) (((uint64)JSVAL_TYPE_TO_TAG(type)) << JSVAL_TAG_SHIFT) #define JSVAL_LOWER_INCL_SHIFTED_TAG_OF_OBJ_OR_NULL_SET JSVAL_SHIFTED_TAG_NULL #define JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_PRIMITIVE_SET JSVAL_SHIFTED_TAG_OBJECT #define JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_NUMBER_SET JSVAL_SHIFTED_TAG_UNDEFINED +#define JSVAL_LOWER_INCL_SHIFTED_TAG_OF_PTR_PAYLOAD_SET JSVAL_SHIFTED_TAG_MAGIC #define JSVAL_LOWER_INCL_SHIFTED_TAG_OF_GCTHING_SET JSVAL_SHIFTED_TAG_STRING #endif /* JS_BITS_PER_WORD */ @@ -277,7 +254,7 @@ typedef enum JSWhyMagic JS_ARRAY_HOLE, /* a hole in a dense array */ JS_ARGS_HOLE, /* a hole in the args object's array */ JS_NATIVE_ENUMERATE, /* indicates that a custom enumerate hook forwarded - * to JS_EnumerateState, which really means the object can be + * to js_Enumerate, which really means the object can be * enumerated like a native object. */ JS_NO_ITER_VALUE, /* there is not a pending iterator value */ JS_GENERATOR_CLOSING, /* exception value thrown when closing a generator */ @@ -285,122 +262,114 @@ typedef enum JSWhyMagic JS_THIS_POISON, /* used in debug builds to catch tracing errors */ JS_ARG_POISON, /* used in debug builds to catch tracing errors */ JS_SERIALIZE_NO_NODE, /* an empty subnode in the AST serializer */ - JS_LAZY_ARGUMENTS, /* lazy arguments value on the stack */ - JS_UNASSIGNED_ARGUMENTS, /* the initial value of callobj.arguments */ - JS_IS_CONSTRUCTING, /* magic value passed to natives to indicate construction */ JS_GENERIC_MAGIC /* for local use */ } JSWhyMagic; +typedef struct JSString JSString; +typedef struct JSFlatString JSFlatString; +typedef struct JSObject JSObject; + #if defined(IS_LITTLE_ENDIAN) # if JS_BITS_PER_WORD == 32 typedef union jsval_layout { - uint64_t asBits; + uint64 asBits; struct { union { - int32_t i32; - uint32_t u32; + int32 i32; + uint32 u32; JSBool boo; JSString *str; JSObject *obj; void *ptr; JSWhyMagic why; - size_t word; + jsuword word; } payload; JSValueTag tag; } s; double asDouble; void *asPtr; -} JSVAL_ALIGNMENT jsval_layout; +} jsval_layout; # elif JS_BITS_PER_WORD == 64 typedef union jsval_layout { - uint64_t asBits; + uint64 asBits; #if (!defined(_WIN64) && defined(__cplusplus)) /* MSVC does not pack these correctly :-( */ struct { - uint64_t payload47 : 47; + uint64 payload47 : 47; JSValueTag tag : 17; } debugView; #endif struct { union { - int32_t i32; - uint32_t u32; + int32 i32; + uint32 u32; JSWhyMagic why; + jsuword word; } payload; } s; double asDouble; void *asPtr; - size_t asWord; -} JSVAL_ALIGNMENT jsval_layout; +} jsval_layout; # endif /* JS_BITS_PER_WORD */ #else /* defined(IS_LITTLE_ENDIAN) */ # if JS_BITS_PER_WORD == 32 typedef union jsval_layout { - uint64_t asBits; + uint64 asBits; struct { JSValueTag tag; union { - int32_t i32; - uint32_t u32; + int32 i32; + uint32 u32; JSBool boo; JSString *str; JSObject *obj; void *ptr; JSWhyMagic why; - size_t word; + jsuword word; } payload; } s; double asDouble; void *asPtr; -} JSVAL_ALIGNMENT jsval_layout; +} jsval_layout; # elif JS_BITS_PER_WORD == 64 typedef union jsval_layout { - uint64_t asBits; + uint64 asBits; struct { JSValueTag tag : 17; - uint64_t payload47 : 47; + uint64 payload47 : 47; } debugView; struct { - uint32_t padding; union { - int32_t i32; - uint32_t u32; + int32 i32; + uint32 u32; JSWhyMagic why; } payload; } s; double asDouble; void *asPtr; - size_t asWord; -} JSVAL_ALIGNMENT jsval_layout; +} jsval_layout; # endif /* JS_BITS_PER_WORD */ #endif /* defined(IS_LITTLE_ENDIAN) */ -JS_STATIC_ASSERT(sizeof(jsval_layout) == 8); - #if JS_BITS_PER_WORD == 32 /* * N.B. GCC, in some but not all cases, chooses to emit signed comparison of - * JSValueTag even though its underlying type has been forced to be uint32_t. - * Thus, all comparisons should explicitly cast operands to uint32_t. + * JSValueTag even though its underlying type has been forced to be uint32. + * Thus, all comparisons should explicitly cast operands to uint32. */ -static JS_ALWAYS_INLINE jsval_layout -BUILD_JSVAL(JSValueTag tag, uint32_t payload) -{ - jsval_layout l; - l.asBits = (((uint64_t)(uint32_t)tag) << 32) | payload; - return l; -} +#define BUILD_JSVAL(tag, payload) \ + ((((uint64)(uint32)(tag)) << 32) | (uint32)(payload)) static JS_ALWAYS_INLINE JSBool JSVAL_IS_DOUBLE_IMPL(jsval_layout l) { - return (uint32_t)l.s.tag <= (uint32_t)JSVAL_TAG_CLEAR; + return (uint32)l.s.tag <= (uint32)JSVAL_TAG_CLEAR; } static JS_ALWAYS_INLINE jsval_layout @@ -418,14 +387,14 @@ JSVAL_IS_INT32_IMPL(jsval_layout l) return l.s.tag == JSVAL_TAG_INT32; } -static JS_ALWAYS_INLINE int32_t +static JS_ALWAYS_INLINE int32 JSVAL_TO_INT32_IMPL(jsval_layout l) { return l.s.payload.i32; } static JS_ALWAYS_INLINE jsval_layout -INT32_TO_JSVAL_IMPL(int32_t i) +INT32_TO_JSVAL_IMPL(int32 i) { jsval_layout l; l.s.tag = JSVAL_TAG_INT32; @@ -438,7 +407,7 @@ JSVAL_IS_NUMBER_IMPL(jsval_layout l) { JSValueTag tag = l.s.tag; JS_ASSERT(tag != JSVAL_TAG_CLEAR); - return (uint32_t)tag <= (uint32_t)JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET; + return (uint32)tag <= (uint32)JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET; } static JS_ALWAYS_INLINE JSBool @@ -485,7 +454,6 @@ static JS_ALWAYS_INLINE jsval_layout BOOLEAN_TO_JSVAL_IMPL(JSBool b) { jsval_layout l; - JS_ASSERT(b == JS_TRUE || b == JS_FALSE); l.s.tag = JSVAL_TAG_BOOLEAN; l.s.payload.boo = b; return l; @@ -497,6 +465,13 @@ JSVAL_IS_MAGIC_IMPL(jsval_layout l) return l.s.tag == JSVAL_TAG_MAGIC; } +static JS_ALWAYS_INLINE JSObject * +MAGIC_JSVAL_TO_OBJECT_OR_NULL_IMPL(jsval_layout l) +{ + JS_ASSERT(JSVAL_IS_MAGIC_IMPL(l)); + return l.s.payload.obj; +} + static JS_ALWAYS_INLINE JSBool JSVAL_IS_OBJECT_IMPL(jsval_layout l) { @@ -506,14 +481,14 @@ JSVAL_IS_OBJECT_IMPL(jsval_layout l) static JS_ALWAYS_INLINE JSBool JSVAL_IS_PRIMITIVE_IMPL(jsval_layout l) { - return (uint32_t)l.s.tag < (uint32_t)JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET; + return (uint32)l.s.tag < (uint32)JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET; } static JS_ALWAYS_INLINE JSBool JSVAL_IS_OBJECT_OR_NULL_IMPL(jsval_layout l) { - JS_ASSERT((uint32_t)l.s.tag <= (uint32_t)JSVAL_TAG_OBJECT); - return (uint32_t)l.s.tag >= (uint32_t)JSVAL_LOWER_INCL_TAG_OF_OBJ_OR_NULL_SET; + JS_ASSERT((uint32)l.s.tag <= (uint32)JSVAL_TAG_OBJECT); + return (uint32)l.s.tag >= (uint32)JSVAL_LOWER_INCL_TAG_OF_OBJ_OR_NULL_SET; } static JS_ALWAYS_INLINE JSObject * @@ -542,7 +517,7 @@ static JS_ALWAYS_INLINE jsval_layout PRIVATE_PTR_TO_JSVAL_IMPL(void *ptr) { jsval_layout l; - JS_ASSERT(((uint32_t)ptr & 1) == 0); + JS_ASSERT(((uint32)ptr & 1) == 0); l.s.tag = (JSValueTag)0; l.s.payload.ptr = ptr; JS_ASSERT(JSVAL_IS_DOUBLE_IMPL(l)); @@ -559,7 +534,7 @@ static JS_ALWAYS_INLINE JSBool JSVAL_IS_GCTHING_IMPL(jsval_layout l) { /* gcc sometimes generates signed < without explicit casts. */ - return (uint32_t)l.s.tag >= (uint32_t)JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET; + return (uint32)l.s.tag >= (uint32)JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET; } static JS_ALWAYS_INLINE void * @@ -574,73 +549,16 @@ JSVAL_IS_TRACEABLE_IMPL(jsval_layout l) return l.s.tag == JSVAL_TAG_STRING || l.s.tag == JSVAL_TAG_OBJECT; } -static JS_ALWAYS_INLINE uint32_t +static JS_ALWAYS_INLINE uint32 JSVAL_TRACE_KIND_IMPL(jsval_layout l) { - return (uint32_t)(JSBool)JSVAL_IS_STRING_IMPL(l); -} - -static JS_ALWAYS_INLINE JSBool -JSVAL_IS_SPECIFIC_INT32_IMPL(jsval_layout l, int32_t i32) -{ - return l.s.tag == JSVAL_TAG_INT32 && l.s.payload.i32 == i32; -} - -static JS_ALWAYS_INLINE JSBool -JSVAL_IS_SPECIFIC_BOOLEAN(jsval_layout l, JSBool b) -{ - return (l.s.tag == JSVAL_TAG_BOOLEAN) && (l.s.payload.boo == b); -} - -static JS_ALWAYS_INLINE jsval_layout -MAGIC_TO_JSVAL_IMPL(JSWhyMagic why) -{ - jsval_layout l; - l.s.tag = JSVAL_TAG_MAGIC; - l.s.payload.why = why; - return l; -} - -static JS_ALWAYS_INLINE JSBool -JSVAL_SAME_TYPE_IMPL(jsval_layout lhs, jsval_layout rhs) -{ - JSValueTag ltag = lhs.s.tag, rtag = rhs.s.tag; - return ltag == rtag || (ltag < JSVAL_TAG_CLEAR && rtag < JSVAL_TAG_CLEAR); -} - -static JS_ALWAYS_INLINE jsval_layout -PRIVATE_UINT32_TO_JSVAL_IMPL(uint32_t ui) -{ - jsval_layout l; - l.s.tag = (JSValueTag)0; - l.s.payload.u32 = ui; - JS_ASSERT(JSVAL_IS_DOUBLE_IMPL(l)); - return l; -} - -static JS_ALWAYS_INLINE uint32_t -JSVAL_TO_PRIVATE_UINT32_IMPL(jsval_layout l) -{ - return l.s.payload.u32; -} - -static JS_ALWAYS_INLINE JSValueType -JSVAL_EXTRACT_NON_DOUBLE_TYPE_IMPL(jsval_layout l) -{ - uint32_t type = l.s.tag & 0xF; - JS_ASSERT(type > JSVAL_TYPE_DOUBLE); - return (JSValueType)type; + return (uint32)(JSBool)JSVAL_IS_STRING_IMPL(l); } #elif JS_BITS_PER_WORD == 64 -static JS_ALWAYS_INLINE jsval_layout -BUILD_JSVAL(JSValueTag tag, uint64_t payload) -{ - jsval_layout l; - l.asBits = (((uint64_t)(uint32_t)tag) << JSVAL_TAG_SHIFT) | payload; - return l; -} +#define BUILD_JSVAL(tag, payload) \ + ((((uint64)(uint32)(tag)) << JSVAL_TAG_SHIFT) | (payload)) static JS_ALWAYS_INLINE JSBool JSVAL_IS_DOUBLE_IMPL(jsval_layout l) @@ -660,20 +578,20 @@ DOUBLE_TO_JSVAL_IMPL(double d) static JS_ALWAYS_INLINE JSBool JSVAL_IS_INT32_IMPL(jsval_layout l) { - return (uint32_t)(l.asBits >> JSVAL_TAG_SHIFT) == JSVAL_TAG_INT32; + return (uint32)(l.asBits >> JSVAL_TAG_SHIFT) == JSVAL_TAG_INT32; } -static JS_ALWAYS_INLINE int32_t +static JS_ALWAYS_INLINE int32 JSVAL_TO_INT32_IMPL(jsval_layout l) { - return (int32_t)l.asBits; + return (int32)l.asBits; } static JS_ALWAYS_INLINE jsval_layout -INT32_TO_JSVAL_IMPL(int32_t i32) +INT32_TO_JSVAL_IMPL(int32 i32) { jsval_layout l; - l.asBits = ((uint64_t)(uint32_t)i32) | JSVAL_SHIFTED_TAG_INT32; + l.asBits = ((uint64)(uint32)i32) | JSVAL_SHIFTED_TAG_INT32; return l; } @@ -692,14 +610,14 @@ JSVAL_IS_UNDEFINED_IMPL(jsval_layout l) static JS_ALWAYS_INLINE JSBool JSVAL_IS_STRING_IMPL(jsval_layout l) { - return (uint32_t)(l.asBits >> JSVAL_TAG_SHIFT) == JSVAL_TAG_STRING; + return (uint32)(l.asBits >> JSVAL_TAG_SHIFT) == JSVAL_TAG_STRING; } static JS_ALWAYS_INLINE jsval_layout STRING_TO_JSVAL_IMPL(JSString *str) { jsval_layout l; - uint64_t strBits = (uint64_t)str; + uint64 strBits = (uint64)str; JS_ASSERT(str); JS_ASSERT((strBits >> JSVAL_TAG_SHIFT) == 0); l.asBits = strBits | JSVAL_SHIFTED_TAG_STRING; @@ -715,7 +633,7 @@ JSVAL_TO_STRING_IMPL(jsval_layout l) static JS_ALWAYS_INLINE JSBool JSVAL_IS_BOOLEAN_IMPL(jsval_layout l) { - return (uint32_t)(l.asBits >> JSVAL_TAG_SHIFT) == JSVAL_TAG_BOOLEAN; + return (uint32)(l.asBits >> JSVAL_TAG_SHIFT) == JSVAL_TAG_BOOLEAN; } static JS_ALWAYS_INLINE JSBool @@ -728,8 +646,7 @@ static JS_ALWAYS_INLINE jsval_layout BOOLEAN_TO_JSVAL_IMPL(JSBool b) { jsval_layout l; - JS_ASSERT(b == JS_TRUE || b == JS_FALSE); - l.asBits = ((uint64_t)(uint32_t)b) | JSVAL_SHIFTED_TAG_BOOLEAN; + l.asBits = ((uint64)(uint32)b) | JSVAL_SHIFTED_TAG_BOOLEAN; return l; } @@ -739,6 +656,15 @@ JSVAL_IS_MAGIC_IMPL(jsval_layout l) return (l.asBits >> JSVAL_TAG_SHIFT) == JSVAL_TAG_MAGIC; } +static JS_ALWAYS_INLINE JSObject * +MAGIC_JSVAL_TO_OBJECT_OR_NULL_IMPL(jsval_layout l) +{ + uint64 ptrBits = l.asBits & JSVAL_PAYLOAD_MASK; + JS_ASSERT(JSVAL_IS_MAGIC_IMPL(l)); + JS_ASSERT((ptrBits >> JSVAL_TAG_SHIFT) == 0); + return (JSObject *)ptrBits; +} + static JS_ALWAYS_INLINE JSBool JSVAL_IS_PRIMITIVE_IMPL(jsval_layout l) { @@ -762,7 +688,7 @@ JSVAL_IS_OBJECT_OR_NULL_IMPL(jsval_layout l) static JS_ALWAYS_INLINE JSObject * JSVAL_TO_OBJECT_IMPL(jsval_layout l) { - uint64_t ptrBits = l.asBits & JSVAL_PAYLOAD_MASK; + uint64 ptrBits = l.asBits & JSVAL_PAYLOAD_MASK; JS_ASSERT((ptrBits & 0x7) == 0); return (JSObject *)ptrBits; } @@ -771,7 +697,7 @@ static JS_ALWAYS_INLINE jsval_layout OBJECT_TO_JSVAL_IMPL(JSObject *obj) { jsval_layout l; - uint64_t objBits = (uint64_t)obj; + uint64 objBits = (uint64)obj; JS_ASSERT(obj); JS_ASSERT((objBits >> JSVAL_TAG_SHIFT) == 0); l.asBits = objBits | JSVAL_SHIFTED_TAG_OBJECT; @@ -793,7 +719,7 @@ JSVAL_IS_GCTHING_IMPL(jsval_layout l) static JS_ALWAYS_INLINE void * JSVAL_TO_GCTHING_IMPL(jsval_layout l) { - uint64_t ptrBits = l.asBits & JSVAL_PAYLOAD_MASK; + uint64 ptrBits = l.asBits & JSVAL_PAYLOAD_MASK; JS_ASSERT((ptrBits & 0x7) == 0); return (void *)ptrBits; } @@ -804,17 +730,17 @@ JSVAL_IS_TRACEABLE_IMPL(jsval_layout l) return JSVAL_IS_GCTHING_IMPL(l) && !JSVAL_IS_NULL_IMPL(l); } -static JS_ALWAYS_INLINE uint32_t +static JS_ALWAYS_INLINE uint32 JSVAL_TRACE_KIND_IMPL(jsval_layout l) { - return (uint32_t)(JSBool)!(JSVAL_IS_OBJECT_IMPL(l)); + return (uint32)(JSBool)!(JSVAL_IS_OBJECT_IMPL(l)); } static JS_ALWAYS_INLINE jsval_layout PRIVATE_PTR_TO_JSVAL_IMPL(void *ptr) { jsval_layout l; - uint64_t ptrBits = (uint64_t)ptr; + uint64 ptrBits = (uint64)ptr; JS_ASSERT((ptrBits & 1) == 0); l.asBits = ptrBits >> 1; JS_ASSERT(JSVAL_IS_DOUBLE_IMPL(l)); @@ -828,59 +754,7 @@ JSVAL_TO_PRIVATE_PTR_IMPL(jsval_layout l) return (void *)(l.asBits << 1); } -static JS_ALWAYS_INLINE JSBool -JSVAL_IS_SPECIFIC_INT32_IMPL(jsval_layout l, int32_t i32) -{ - return l.asBits == (((uint64_t)(uint32_t)i32) | JSVAL_SHIFTED_TAG_INT32); -} - -static JS_ALWAYS_INLINE JSBool -JSVAL_IS_SPECIFIC_BOOLEAN(jsval_layout l, JSBool b) -{ - return l.asBits == (((uint64_t)(uint32_t)b) | JSVAL_SHIFTED_TAG_BOOLEAN); -} - -static JS_ALWAYS_INLINE jsval_layout -MAGIC_TO_JSVAL_IMPL(JSWhyMagic why) -{ - jsval_layout l; - l.asBits = ((uint64_t)(uint32_t)why) | JSVAL_SHIFTED_TAG_MAGIC; - return l; -} - -static JS_ALWAYS_INLINE JSBool -JSVAL_SAME_TYPE_IMPL(jsval_layout lhs, jsval_layout rhs) -{ - uint64_t lbits = lhs.asBits, rbits = rhs.asBits; - return (lbits <= JSVAL_SHIFTED_TAG_MAX_DOUBLE && rbits <= JSVAL_SHIFTED_TAG_MAX_DOUBLE) || - (((lbits ^ rbits) & 0xFFFF800000000000LL) == 0); -} - -static JS_ALWAYS_INLINE jsval_layout -PRIVATE_UINT32_TO_JSVAL_IMPL(uint32_t ui) -{ - jsval_layout l; - l.asBits = (uint64_t)ui; - JS_ASSERT(JSVAL_IS_DOUBLE_IMPL(l)); - return l; -} - -static JS_ALWAYS_INLINE uint32_t -JSVAL_TO_PRIVATE_UINT32_IMPL(jsval_layout l) -{ - JS_ASSERT((l.asBits >> 32) == 0); - return (uint32_t)l.asBits; -} - -static JS_ALWAYS_INLINE JSValueType -JSVAL_EXTRACT_NON_DOUBLE_TYPE_IMPL(jsval_layout l) -{ - uint64_t type = (l.asBits >> JSVAL_TAG_SHIFT) & 0xF; - JS_ASSERT(type > JSVAL_TYPE_DOUBLE); - return (JSValueType)type; -} - -#endif /* JS_BITS_PER_WORD */ +#endif static JS_ALWAYS_INLINE double JS_CANONICALIZE_NAN(double d) @@ -893,11 +767,65 @@ JS_CANONICALIZE_NAN(double d) return d; } -JS_END_EXTERN_C - -#ifdef __cplusplus -static jsval_layout JSVAL_TO_IMPL(JS::Value); -static JS::Value IMPL_TO_JSVAL(jsval_layout); +/* See JS_USE_JSVAL_JSID_STRUCT_TYPES comment in jsapi.h. */ +#if defined(DEBUG) && !defined(JS_NO_JSVAL_JSID_STRUCT_TYPES) +# define JS_USE_JSVAL_JSID_STRUCT_TYPES #endif +#ifdef JS_USE_JSVAL_JSID_STRUCT_TYPES + +typedef JSVAL_ALIGNMENT jsval_layout jsval; +typedef struct jsid { size_t asBits; } jsid; + +#if defined(__cplusplus) +extern "C++" +{ + static JS_ALWAYS_INLINE bool + operator==(jsid lhs, jsid rhs) + { + return lhs.asBits == rhs.asBits; + } + + static JS_ALWAYS_INLINE bool + operator!=(jsid lhs, jsid rhs) + { + return lhs.asBits != rhs.asBits; + } + + static JS_ALWAYS_INLINE bool + operator==(jsval lhs, jsval rhs) + { + return lhs.asBits == rhs.asBits; + } + + static JS_ALWAYS_INLINE bool + operator!=(jsval lhs, jsval rhs) + { + return lhs.asBits != rhs.asBits; + } +} +# endif /* defined(__cplusplus) */ + +/* Internal helper macros */ +#define JSVAL_BITS(v) ((v).asBits) +#define JSVAL_FROM_LAYOUT(l) (l) +#define IMPL_TO_JSVAL(v) (v) +#define JSID_BITS(id) ((id).asBits) + +#else /* defined(JS_USE_JSVAL_JSID_STRUCT_TYPES) */ + +/* Use different primitive types so overloading works. */ +typedef JSVAL_ALIGNMENT uint64 jsval; +typedef ptrdiff_t jsid; + +/* Internal helper macros */ +#define JSVAL_BITS(v) (v) +#define JSVAL_FROM_LAYOUT(l) ((l).asBits) +#define IMPL_TO_JSVAL(v) ((v).asBits) +#define JSID_BITS(id) (id) + +#endif /* defined(JS_USE_JSVAL_JSID_STRUCT_TYPES) */ + +JS_END_EXTERN_C + #endif /* jsvalimpl_h__ */ diff --git a/js/spidermonkey-win32/include/jsversion.h b/js/spidermonkey-win32/include/jsversion.h index 332ead2ad9..f72af4981b 100644 --- a/js/spidermonkey-win32/include/jsversion.h +++ b/js/spidermonkey-win32/include/jsversion.h @@ -86,6 +86,7 @@ #define JS_HAS_OBJ_PROTO_PROP 0 /* has o.__proto__ etc. */ #endif #define JS_HAS_OBJ_WATCHPOINT 0 /* has o.watch and o.unwatch */ +#define JS_HAS_SHARP_VARS 0 /* has #n=, #n# for object literals */ #define JS_HAS_XDR 0 /* has XDR API and internal support */ #define JS_HAS_TOSOURCE 0 /* has Object/Array toSource method */ #define JS_HAS_CATCH_GUARD 0 /* has exception handling catch guard */ @@ -95,6 +96,7 @@ #define JS_HAS_FUN_EXPR_STMT 0 /* has function expression statement */ #define JS_HAS_NO_SUCH_METHOD 0 /* has o.__noSuchMethod__ handler */ #define JS_HAS_XML_SUPPORT 0 /* has ECMAScript for XML support */ +#define JS_HAS_ARRAY_EXTRAS 0 /* has indexOf and Lispy extras */ #define JS_HAS_GENERATORS 0 /* has yield in generator function */ #define JS_HAS_BLOCK_SCOPE 0 /* has block scope via let/arraycomp */ #define JS_HAS_DESTRUCTURING 0 /* has [a,b] = ... or {p:a,q:b} = ... */ @@ -111,6 +113,7 @@ #define JS_HAS_PERL_SUBSTR 1 /* has str.substr */ #define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */ #define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */ +#define JS_HAS_SHARP_VARS 1 /* has #n=, #n# for object literals */ #define JS_HAS_XDR 1 /* has XDR API and internal support */ #define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */ #define JS_HAS_CATCH_GUARD 1 /* has exception handling catch guard */ @@ -120,6 +123,7 @@ #define JS_HAS_FUN_EXPR_STMT 1 /* has function expression statement */ #define JS_HAS_NO_SUCH_METHOD 1 /* has o.__noSuchMethod__ handler */ #define JS_HAS_XML_SUPPORT 0 /* has ECMAScript for XML support */ +#define JS_HAS_ARRAY_EXTRAS 0 /* has indexOf and Lispy extras */ #define JS_HAS_GENERATORS 0 /* has yield in generator function */ #define JS_HAS_BLOCK_SCOPE 0 /* has block scope via let/arraycomp */ #define JS_HAS_DESTRUCTURING 0 /* has [a,b] = ... or {p:a,q:b} = ... */ @@ -132,6 +136,7 @@ #define JS_HAS_PERL_SUBSTR 1 /* has str.substr */ #define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */ #define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */ +#define JS_HAS_SHARP_VARS 1 /* has #n=, #n# for object literals */ #define JS_HAS_XDR 1 /* has XDR API and internal support */ #define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */ #define JS_HAS_CATCH_GUARD 1 /* has exception handling catch guard */ @@ -141,6 +146,7 @@ #define JS_HAS_FUN_EXPR_STMT 1 /* has function expression statement */ #define JS_HAS_NO_SUCH_METHOD 1 /* has o.__noSuchMethod__ handler */ #define JS_HAS_XML_SUPPORT 1 /* has ECMAScript for XML support */ +#define JS_HAS_ARRAY_EXTRAS 1 /* has indexOf and Lispy extras */ #define JS_HAS_GENERATORS 0 /* has yield in generator function */ #define JS_HAS_BLOCK_SCOPE 0 /* has block scope via let/arraycomp */ #define JS_HAS_DESTRUCTURING 0 /* has [a,b] = ... or {p:a,q:b} = ... */ @@ -153,6 +159,7 @@ #define JS_HAS_PERL_SUBSTR 1 /* has str.substr */ #define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */ #define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */ +#define JS_HAS_SHARP_VARS 1 /* has #n=, #n# for object literals */ #define JS_HAS_XDR 1 /* has XDR API and internal support */ #define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */ #define JS_HAS_CATCH_GUARD 1 /* has exception handling catch guard */ @@ -162,6 +169,7 @@ #define JS_HAS_FUN_EXPR_STMT 1 /* has function expression statement */ #define JS_HAS_NO_SUCH_METHOD 1 /* has o.__noSuchMethod__ handler */ #define JS_HAS_XML_SUPPORT 1 /* has ECMAScript for XML support */ +#define JS_HAS_ARRAY_EXTRAS 1 /* has indexOf and Lispy extras */ #define JS_HAS_GENERATORS 1 /* has yield in generator function */ #define JS_HAS_BLOCK_SCOPE 1 /* has block scope via let/arraycomp */ #define JS_HAS_DESTRUCTURING 1 /* has [a,b] = ... or {p:a,q:b} = ... */ @@ -174,6 +182,7 @@ #define JS_HAS_PERL_SUBSTR 1 /* has str.substr */ #define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */ #define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */ +#define JS_HAS_SHARP_VARS 1 /* has #n=, #n# for object literals */ #define JS_HAS_XDR 1 /* has XDR API and internal support */ #define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */ #define JS_HAS_CATCH_GUARD 1 /* has exception handling catch guard */ @@ -183,6 +192,7 @@ #define JS_HAS_FUN_EXPR_STMT 1 /* has function expression statement */ #define JS_HAS_NO_SUCH_METHOD 1 /* has o.__noSuchMethod__ handler */ #define JS_HAS_XML_SUPPORT 1 /* has ECMAScript for XML support */ +#define JS_HAS_ARRAY_EXTRAS 1 /* has indexOf and Lispy extras */ #define JS_HAS_GENERATORS 1 /* has yield in generator function */ #define JS_HAS_BLOCK_SCOPE 1 /* has block scope via let/arraycomp */ #define JS_HAS_DESTRUCTURING 2 /* has [a,b] = ... or {p:a,q:b} = ... */ diff --git a/js/spidermonkey-win32/include/jswrapper.h b/js/spidermonkey-win32/include/jswrapper.h deleted file mode 100644 index 8bebe9768b..0000000000 --- a/js/spidermonkey-win32/include/jswrapper.h +++ /dev/null @@ -1,233 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=4 sw=4 et tw=99: - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released - * May 28, 2008. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Andreas Gal - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef jswrapper_h___ -#define jswrapper_h___ - -#include "mozilla/Attributes.h" - -#include "jsapi.h" -#include "jsproxy.h" - -namespace js { - -class DummyFrameGuard; - -/* No-op wrapper handler base class. */ -class JS_FRIEND_API(Wrapper) : public ProxyHandler -{ - unsigned mFlags; - public: - unsigned flags() const { return mFlags; } - - explicit Wrapper(unsigned flags); - - typedef enum { PermitObjectAccess, PermitPropertyAccess, DenyAccess } Permission; - - virtual ~Wrapper(); - - /* ES5 Harmony fundamental wrapper traps. */ - virtual bool getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id, bool set, - PropertyDescriptor *desc) MOZ_OVERRIDE; - virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id, bool set, - PropertyDescriptor *desc) MOZ_OVERRIDE; - virtual bool defineProperty(JSContext *cx, JSObject *wrapper, jsid id, - PropertyDescriptor *desc) MOZ_OVERRIDE; - virtual bool getOwnPropertyNames(JSContext *cx, JSObject *wrapper, AutoIdVector &props) MOZ_OVERRIDE; - virtual bool delete_(JSContext *cx, JSObject *wrapper, jsid id, bool *bp) MOZ_OVERRIDE; - virtual bool enumerate(JSContext *cx, JSObject *wrapper, AutoIdVector &props) MOZ_OVERRIDE; - virtual bool fix(JSContext *cx, JSObject *wrapper, Value *vp) MOZ_OVERRIDE; - - /* ES5 Harmony derived wrapper traps. */ - virtual bool has(JSContext *cx, JSObject *wrapper, jsid id, bool *bp) MOZ_OVERRIDE; - virtual bool hasOwn(JSContext *cx, JSObject *wrapper, jsid id, bool *bp) MOZ_OVERRIDE; - virtual bool get(JSContext *cx, JSObject *wrapper, JSObject *receiver, jsid id, Value *vp) MOZ_OVERRIDE; - virtual bool set(JSContext *cx, JSObject *wrapper, JSObject *receiver, jsid id, bool strict, - Value *vp) MOZ_OVERRIDE; - virtual bool keys(JSContext *cx, JSObject *wrapper, AutoIdVector &props) MOZ_OVERRIDE; - virtual bool iterate(JSContext *cx, JSObject *wrapper, unsigned flags, Value *vp) MOZ_OVERRIDE; - - /* Spidermonkey extensions. */ - virtual bool call(JSContext *cx, JSObject *wrapper, unsigned argc, Value *vp) MOZ_OVERRIDE; - virtual bool construct(JSContext *cx, JSObject *wrapper, unsigned argc, Value *argv, Value *rval) MOZ_OVERRIDE; - virtual bool nativeCall(JSContext *cx, JSObject *wrapper, Class *clasp, Native native, CallArgs args) MOZ_OVERRIDE; - virtual bool hasInstance(JSContext *cx, JSObject *wrapper, const Value *vp, bool *bp) MOZ_OVERRIDE; - virtual JSType typeOf(JSContext *cx, JSObject *proxy) MOZ_OVERRIDE; - virtual bool objectClassIs(JSObject *obj, ESClassValue classValue, JSContext *cx) MOZ_OVERRIDE; - virtual JSString *obj_toString(JSContext *cx, JSObject *wrapper) MOZ_OVERRIDE; - virtual JSString *fun_toString(JSContext *cx, JSObject *wrapper, unsigned indent) MOZ_OVERRIDE; - virtual bool regexp_toShared(JSContext *cx, JSObject *proxy, RegExpGuard *g) MOZ_OVERRIDE; - virtual bool defaultValue(JSContext *cx, JSObject *wrapper, JSType hint, Value *vp) MOZ_OVERRIDE; - virtual bool iteratorNext(JSContext *cx, JSObject *wrapper, Value *vp) MOZ_OVERRIDE; - - virtual void trace(JSTracer *trc, JSObject *wrapper) MOZ_OVERRIDE; - - /* Policy enforcement traps. */ - enum Action { GET, SET, CALL }; - virtual bool enter(JSContext *cx, JSObject *wrapper, jsid id, Action act, bool *bp); - virtual void leave(JSContext *cx, JSObject *wrapper); - - static Wrapper singleton; - - static JSObject *New(JSContext *cx, JSObject *obj, JSObject *proto, JSObject *parent, - Wrapper *handler); - - static JSObject *wrappedObject(const JSObject *wrapper); - static Wrapper *wrapperHandler(const JSObject *wrapper); - - enum { - CROSS_COMPARTMENT = 1 << 0, - LAST_USED_FLAG = CROSS_COMPARTMENT - }; - - static void *getWrapperFamily(); -}; - -/* Base class for all cross compartment wrapper handlers. */ -class JS_FRIEND_API(CrossCompartmentWrapper) : public Wrapper -{ - public: - CrossCompartmentWrapper(unsigned flags); - - virtual ~CrossCompartmentWrapper(); - - /* ES5 Harmony fundamental wrapper traps. */ - virtual bool getPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id, bool set, - PropertyDescriptor *desc) MOZ_OVERRIDE; - virtual bool getOwnPropertyDescriptor(JSContext *cx, JSObject *wrapper, jsid id, bool set, - PropertyDescriptor *desc) MOZ_OVERRIDE; - virtual bool defineProperty(JSContext *cx, JSObject *wrapper, jsid id, - PropertyDescriptor *desc) MOZ_OVERRIDE; - virtual bool getOwnPropertyNames(JSContext *cx, JSObject *wrapper, AutoIdVector &props) MOZ_OVERRIDE; - virtual bool delete_(JSContext *cx, JSObject *wrapper, jsid id, bool *bp) MOZ_OVERRIDE; - virtual bool enumerate(JSContext *cx, JSObject *wrapper, AutoIdVector &props) MOZ_OVERRIDE; - - /* ES5 Harmony derived wrapper traps. */ - virtual bool has(JSContext *cx, JSObject *wrapper, jsid id, bool *bp) MOZ_OVERRIDE; - virtual bool hasOwn(JSContext *cx, JSObject *wrapper, jsid id, bool *bp) MOZ_OVERRIDE; - virtual bool get(JSContext *cx, JSObject *wrapper, JSObject *receiver, jsid id, Value *vp) MOZ_OVERRIDE; - virtual bool set(JSContext *cx, JSObject *wrapper, JSObject *receiver, jsid id, bool strict, - Value *vp) MOZ_OVERRIDE; - virtual bool keys(JSContext *cx, JSObject *wrapper, AutoIdVector &props) MOZ_OVERRIDE; - virtual bool iterate(JSContext *cx, JSObject *wrapper, unsigned flags, Value *vp) MOZ_OVERRIDE; - - /* Spidermonkey extensions. */ - virtual bool call(JSContext *cx, JSObject *wrapper, unsigned argc, Value *vp) MOZ_OVERRIDE; - virtual bool construct(JSContext *cx, JSObject *wrapper, unsigned argc, Value *argv, Value *rval) MOZ_OVERRIDE; - virtual bool nativeCall(JSContext *cx, JSObject *wrapper, Class *clasp, Native native, CallArgs args) MOZ_OVERRIDE; - virtual bool hasInstance(JSContext *cx, JSObject *wrapper, const Value *vp, bool *bp) MOZ_OVERRIDE; - virtual JSString *obj_toString(JSContext *cx, JSObject *wrapper) MOZ_OVERRIDE; - virtual JSString *fun_toString(JSContext *cx, JSObject *wrapper, unsigned indent) MOZ_OVERRIDE; - virtual bool defaultValue(JSContext *cx, JSObject *wrapper, JSType hint, Value *vp) MOZ_OVERRIDE; - virtual bool iteratorNext(JSContext *cx, JSObject *wrapper, Value *vp); - - virtual void trace(JSTracer *trc, JSObject *wrapper) MOZ_OVERRIDE; - - static CrossCompartmentWrapper singleton; -}; - -/* - * Base class for security wrappers. A security wrapper is potentially hiding - * all or part of some wrapped object thus SecurityWrapper defaults to denying - * access to the wrappee. This is the opposite of Wrapper which tries to be - * completely transparent. - * - * NB: Currently, only a few ProxyHandler operations are overridden to deny - * access, relying on derived SecurityWrapper to block access when necessary. - */ -template -class JS_FRIEND_API(SecurityWrapper) : public Base -{ - public: - SecurityWrapper(unsigned flags); - - virtual bool nativeCall(JSContext *cx, JSObject *wrapper, Class *clasp, Native native, CallArgs args) MOZ_OVERRIDE; - virtual bool objectClassIs(JSObject *obj, ESClassValue classValue, JSContext *cx) MOZ_OVERRIDE; - virtual bool regexp_toShared(JSContext *cx, JSObject *proxy, RegExpGuard *g) MOZ_OVERRIDE; -}; - -typedef SecurityWrapper SameCompartmentSecurityWrapper; -typedef SecurityWrapper CrossCompartmentSecurityWrapper; - -/* - * A hacky class that lets a friend force a fake frame. We must already be - * in the compartment of |target| when we enter the forced frame. - */ -class JS_FRIEND_API(ForceFrame) -{ - public: - JSContext * const context; - JSObject * const target; - private: - DummyFrameGuard *frame; - - public: - ForceFrame(JSContext *cx, JSObject *target); - ~ForceFrame(); - bool enter(); -}; - -extern JSObject * -TransparentObjectWrapper(JSContext *cx, JSObject *obj, JSObject *wrappedProto, JSObject *parent, - unsigned flags); - -// Proxy family for wrappers. Public so that IsWrapper() can be fully inlined by -// jsfriendapi users. -extern JS_FRIEND_DATA(int) sWrapperFamily; - -inline bool -IsWrapper(const JSObject *obj) -{ - return IsProxy(obj) && GetProxyHandler(obj)->family() == &sWrapperFamily; -} - -// Given a JSObject, returns that object stripped of wrappers. If -// stopAtOuter is true, then this returns the outer window if it was -// previously wrapped. Otherwise, this returns the first object for -// which JSObject::isWrapper returns false. -JS_FRIEND_API(JSObject *) UnwrapObject(JSObject *obj, bool stopAtOuter = true, - unsigned *flagsp = NULL); - -bool IsCrossCompartmentWrapper(const JSObject *obj); - -} /* namespace js */ - -#endif diff --git a/js/spidermonkey-win32/include/jsxdrapi.h b/js/spidermonkey-win32/include/jsxdrapi.h deleted file mode 100644 index 678d58ecd3..0000000000 --- a/js/spidermonkey-win32/include/jsxdrapi.h +++ /dev/null @@ -1,215 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sw=4 et tw=78: - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -#ifndef jsxdrapi_h___ -#define jsxdrapi_h___ - -/* - * JS external data representation interface API. - * - * The XDR system is comprised of three major parts: - * - * - the state serialization/deserialization APIs, which allow consumers - * of the API to serialize JS runtime state (script bytecodes, atom maps, - * object graphs, etc.) for later restoration. These portions - * are implemented in various appropriate files, such as jsscript.c - * for the script portions and jsobj.c for object state. - * - the callback APIs through which the runtime requests an opaque - * representation of a native object, and through which the runtime - * constructs a live native object from an opaque representation. These - * portions are the responsibility of the native object implementor. - * - utility functions for en/decoding of primitive types, such as - * JSStrings. This portion is implemented in jsxdrapi.c. - * - * Spiritually guided by Sun's XDR, where appropriate. - */ - -#include "jspubtd.h" -#include "jsprvtd.h" - -JS_BEGIN_EXTERN_C - -/* We use little-endian byteorder for all encoded data */ - -#if defined IS_LITTLE_ENDIAN -#define JSXDR_SWAB32(x) x -#define JSXDR_SWAB16(x) x -#elif defined IS_BIG_ENDIAN -#define JSXDR_SWAB32(x) (((uint32_t)(x) >> 24) | \ - (((uint32_t)(x) >> 8) & 0xff00) | \ - (((uint32_t)(x) << 8) & 0xff0000) | \ - ((uint32_t)(x) << 24)) -#define JSXDR_SWAB16(x) (((uint16_t)(x) >> 8) | ((uint16_t)(x) << 8)) -#else -#error "unknown byte order" -#endif - -#define JSXDR_ALIGN 4 - -typedef enum JSXDRMode { - JSXDR_ENCODE, - JSXDR_DECODE -} JSXDRMode; - -typedef enum JSXDRWhence { - JSXDR_SEEK_SET, - JSXDR_SEEK_CUR, - JSXDR_SEEK_END -} JSXDRWhence; - -typedef struct JSXDROps { - JSBool (*get32)(JSXDRState *, uint32_t *); - JSBool (*set32)(JSXDRState *, uint32_t *); - JSBool (*getbytes)(JSXDRState *, char *, uint32_t); - JSBool (*setbytes)(JSXDRState *, char *, uint32_t); - void * (*raw)(JSXDRState *, uint32_t); - JSBool (*seek)(JSXDRState *, int32_t, JSXDRWhence); - uint32_t (*tell)(JSXDRState *); - void (*finalize)(JSXDRState *); -} JSXDROps; - -struct JSXDRState { - JSXDRMode mode; - JSXDROps *ops; - JSContext *cx; - void *userdata; - const char *sharedFilename; - JSPrincipals *principals; - JSPrincipals *originPrincipals; -}; - -extern JS_PUBLIC_API(void) -JS_XDRInitBase(JSXDRState *xdr, JSXDRMode mode, JSContext *cx); - -extern JS_PUBLIC_API(JSXDRState *) -JS_XDRNewMem(JSContext *cx, JSXDRMode mode); - -extern JS_PUBLIC_API(void *) -JS_XDRMemGetData(JSXDRState *xdr, uint32_t *lp); - -extern JS_PUBLIC_API(void) -JS_XDRMemSetData(JSXDRState *xdr, void *data, uint32_t len); - -extern JS_PUBLIC_API(uint32_t) -JS_XDRMemDataLeft(JSXDRState *xdr); - -extern JS_PUBLIC_API(void) -JS_XDRMemResetData(JSXDRState *xdr); - -extern JS_PUBLIC_API(void) -JS_XDRDestroy(JSXDRState *xdr); - -extern JS_PUBLIC_API(JSBool) -JS_XDRUint8(JSXDRState *xdr, uint8_t *b); - -extern JS_PUBLIC_API(JSBool) -JS_XDRUint16(JSXDRState *xdr, uint16_t *s); - -extern JS_PUBLIC_API(JSBool) -JS_XDRUint32(JSXDRState *xdr, uint32_t *lp); - -extern JS_PUBLIC_API(JSBool) -JS_XDRBytes(JSXDRState *xdr, char *bytes, uint32_t len); - -extern JS_PUBLIC_API(JSBool) -JS_XDRCString(JSXDRState *xdr, char **sp); - -extern JS_PUBLIC_API(JSBool) -JS_XDRString(JSXDRState *xdr, JSString **strp); - -extern JS_PUBLIC_API(JSBool) -JS_XDRStringOrNull(JSXDRState *xdr, JSString **strp); - -extern JS_PUBLIC_API(JSBool) -JS_XDRDouble(JSXDRState *xdr, double *dp); - -extern JS_PUBLIC_API(JSBool) -JS_XDRFunctionObject(JSXDRState *xdr, JSObject **objp); - -extern JS_PUBLIC_API(JSBool) -JS_XDRScript(JSXDRState *xdr, JSScript **scriptp); - -/* - * Magic numbers. - */ -#define JSXDR_MAGIC_SCRIPT_1 0xdead0001 -#define JSXDR_MAGIC_SCRIPT_2 0xdead0002 -#define JSXDR_MAGIC_SCRIPT_3 0xdead0003 -#define JSXDR_MAGIC_SCRIPT_4 0xdead0004 -#define JSXDR_MAGIC_SCRIPT_5 0xdead0005 -#define JSXDR_MAGIC_SCRIPT_6 0xdead0006 -#define JSXDR_MAGIC_SCRIPT_7 0xdead0007 -#define JSXDR_MAGIC_SCRIPT_8 0xdead0008 -#define JSXDR_MAGIC_SCRIPT_9 0xdead0009 -#define JSXDR_MAGIC_SCRIPT_10 0xdead000a -#define JSXDR_MAGIC_SCRIPT_11 0xdead000b -#define JSXDR_MAGIC_SCRIPT_12 0xdead000c -#define JSXDR_MAGIC_SCRIPT_CURRENT JSXDR_MAGIC_SCRIPT_12 - -/* - * Bytecode version number. Increment the subtrahend whenever JS bytecode - * changes incompatibly. - * - * This version number is XDR'd near the front of xdr bytecode and - * aborts deserialization if there is a mismatch between the current - * and saved versions. If deserialization fails, the data should be - * invalidated if possible. - */ -#define JSXDR_BYTECODE_VERSION (0xb973c0de - 109) - -JS_END_EXTERN_C - -/* - * Library-private functions. - */ -extern JSBool -js_XDRAtom(JSXDRState *xdr, JSAtom **atomp); - -/* - * Set principals that should be assigned to decoded scripts and functions. - * The principals is not held via JS_HoldPrincipals/JS_DropPrincipals unless - * they are stored in a decoded script. Thus the caller must either ensure - * that principal outlive the XDR instance or are explicitly set to NULL - * before they release by the caller. - */ -extern void -js_XDRSetPrincipals(JSXDRState *xdr, JSPrincipals *principals, JSPrincipals *originPrincipals); - -#endif /* ! jsxdrapi_h___ */ diff --git a/js/spidermonkey-win32/include/mozilla/Assertions.h b/js/spidermonkey-win32/include/mozilla/Assertions.h deleted file mode 100644 index 1b3ba4bfe5..0000000000 --- a/js/spidermonkey-win32/include/mozilla/Assertions.h +++ /dev/null @@ -1,307 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sw=4 et tw=99 ft=cpp: - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Code. - * - * The Initial Developer of the Original Code is - * The Mozilla Foundation - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Jeff Walden - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* Implementations of runtime and static assertion macros for C and C++. */ - -#ifndef mozilla_Assertions_h_ -#define mozilla_Assertions_h_ - -#include "mozilla/Attributes.h" -#include "mozilla/Types.h" - -/* - * MOZ_STATIC_ASSERT may be used to assert a condition *at compile time*. This - * can be useful when you make certain assumptions about what must hold for - * optimal, or even correct, behavior. For example, you might assert that the - * size of a struct is a multiple of the target architecture's word size: - * - * struct S { ... }; - * MOZ_STATIC_ASSERT(sizeof(S) % sizeof(size_t) == 0, - * "S should be a multiple of word size for efficiency"); - * - * This macro can be used in any location where both an extern declaration and a - * typedef could be used. - * - * Be aware of the gcc 4.2 concerns noted further down when writing patches that - * use this macro, particularly if a patch only bounces on OS X. - */ -#ifdef __cplusplus -# if defined(__clang__) -# ifndef __has_extension -# define __has_extension __has_feature /* compatibility, for older versions of clang */ -# endif -# if __has_extension(cxx_static_assert) -# define MOZ_STATIC_ASSERT(cond, reason) static_assert((cond), reason) -# endif -# elif defined(__GNUC__) -# if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L) && \ - (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) -# define MOZ_STATIC_ASSERT(cond, reason) static_assert((cond), reason) -# endif -# elif defined(_MSC_VER) -# if _MSC_VER >= 1600 /* MSVC 10 */ -# define MOZ_STATIC_ASSERT(cond, reason) static_assert((cond), reason) -# endif -# elif defined(__HP_aCC) -# if __HP_aCC >= 62500 && defined(_HP_CXX0x_SOURCE) -# define MOZ_STATIC_ASSERT(cond, reason) static_assert((cond), reason) -# endif -# endif -#endif -#ifndef MOZ_STATIC_ASSERT -# define MOZ_STATIC_ASSERT_GLUE1(x, y) x##y -# define MOZ_STATIC_ASSERT_GLUE(x, y) MOZ_STATIC_ASSERT_GLUE1(x, y) -# if defined(__SUNPRO_CC) - /* - * The Sun Studio C++ compiler is buggy when declaring, inside a function, - * another extern'd function with an array argument whose length contains a - * sizeof, triggering the error message "sizeof expression not accepted as - * size of array parameter". This bug (6688515, not public yet) would hit - * defining moz_static_assert as a function, so we always define an extern - * array for Sun Studio. - * - * We include the line number in the symbol name in a best-effort attempt - * to avoid conflicts (see below). - */ -# define MOZ_STATIC_ASSERT(cond, reason) \ - extern char MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __LINE__)[(cond) ? 1 : -1] -# elif defined(__COUNTER__) - /* - * If there was no preferred alternative, use a compiler-agnostic version. - * - * Note that the non-__COUNTER__ version has a bug in C++: it can't be used - * in both |extern "C"| and normal C++ in the same translation unit. (Alas - * |extern "C"| isn't allowed in a function.) The only affected compiler - * we really care about is gcc 4.2. For that compiler and others like it, - * we include the line number in the function name to do the best we can to - * avoid conflicts. These should be rare: a conflict would require use of - * MOZ_STATIC_ASSERT on the same line in separate files in the same - * translation unit, *and* the uses would have to be in code with - * different linkage, *and* the first observed use must be in C++-linkage - * code. - */ -# define MOZ_STATIC_ASSERT(cond, reason) \ - typedef int MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __COUNTER__)[(cond) ? 1 : -1] -# else -# define MOZ_STATIC_ASSERT(cond, reason) \ - extern void MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __LINE__)(int arg[(cond) ? 1 : -1]) -# endif -#endif - -#define MOZ_STATIC_ASSERT_IF(cond, expr, reason) MOZ_STATIC_ASSERT(!(cond) || (expr), reason) - -#ifdef __cplusplus -extern "C" { -#endif - -extern MFBT_API(void) -MOZ_Crash(void); - -extern MFBT_API(void) -MOZ_Assert(const char* s, const char* file, int ln); - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -/* - * MOZ_ASSERT(expr [, explanation-string]) asserts that |expr| must be truthy in - * debug builds. If it is, execution continues. Otherwise, an error message - * including the expression and the explanation-string (if provided) is printed, - * an attempt is made to invoke any existing debugger, and execution halts. - * MOZ_ASSERT is fatal: no recovery is possible. Do not assert a condition - * which can correctly be falsy. - * - * The optional explanation-string, if provided, must be a string literal - * explaining the assertion. It is intended for use with assertions whose - * correctness or rationale is non-obvious, and for assertions where the "real" - * condition being tested is best described prosaically. Don't provide an - * explanation if it's not actually helpful. - * - * // No explanation needed: pointer arguments often must not be NULL. - * MOZ_ASSERT(arg); - * - * // An explanation can be helpful to explain exactly how we know an - * // assertion is valid. - * MOZ_ASSERT(state == WAITING_FOR_RESPONSE, - * "given that and , we must have..."); - * - * // Or it might disambiguate multiple identical (save for their location) - * // assertions of the same expression. - * MOZ_ASSERT(getSlot(PRIMITIVE_THIS_SLOT).isUndefined(), - * "we already set [[PrimitiveThis]] for this Boolean object"); - * MOZ_ASSERT(getSlot(PRIMITIVE_THIS_SLOT).isUndefined(), - * "we already set [[PrimitiveThis]] for this String object"); - * - * MOZ_ASSERT has no effect in non-debug builds. It is designed to catch bugs - * *only* during debugging, not "in the field". - */ -#ifdef DEBUG - /* First the single-argument form. */ -# define MOZ_ASSERT_HELPER1(expr) \ - ((expr) ? ((void)0) : MOZ_Assert(#expr, __FILE__, __LINE__)) - /* Now the two-argument form. */ -# define MOZ_ASSERT_HELPER2(expr, explain) \ - ((expr) ? ((void)0) : MOZ_Assert(#expr " (" explain ")", __FILE__, __LINE__)) - /* And now, helper macrology up the wazoo. */ - /* - * Count the number of arguments passed to MOZ_ASSERT, very carefully - * tiptoeing around an MSVC bug where it improperly expands __VA_ARGS__ as a - * single token in argument lists. See these URLs for details: - * - * http://connect.microsoft.com/VisualStudio/feedback/details/380090/variadic-macro-replacement - * http://cplusplus.co.il/2010/07/17/variadic-macro-to-count-number-of-arguments/#comment-644 - */ -# define MOZ_COUNT_ASSERT_ARGS_IMPL2(_1, _2, count, ...) \ - count -# define MOZ_COUNT_ASSERT_ARGS_IMPL(args) \ - MOZ_COUNT_ASSERT_ARGS_IMPL2 args -# define MOZ_COUNT_ASSERT_ARGS(...) \ - MOZ_COUNT_ASSERT_ARGS_IMPL((__VA_ARGS__, 2, 1, 0)) - /* Pick the right helper macro to invoke. */ -# define MOZ_ASSERT_CHOOSE_HELPER2(count) MOZ_ASSERT_HELPER##count -# define MOZ_ASSERT_CHOOSE_HELPER1(count) MOZ_ASSERT_CHOOSE_HELPER2(count) -# define MOZ_ASSERT_CHOOSE_HELPER(count) MOZ_ASSERT_CHOOSE_HELPER1(count) - /* The actual macro. */ -# define MOZ_ASSERT_GLUE(x, y) x y -# define MOZ_ASSERT(...) \ - MOZ_ASSERT_GLUE(MOZ_ASSERT_CHOOSE_HELPER(MOZ_COUNT_ASSERT_ARGS(__VA_ARGS__)), \ - (__VA_ARGS__)) -#else -# define MOZ_ASSERT(...) ((void)0) -#endif /* DEBUG */ - -/* - * MOZ_ASSERT_IF(cond1, cond2) is equivalent to MOZ_ASSERT(cond2) if cond1 is - * true. - * - * MOZ_ASSERT_IF(isPrime(num), num == 2 || isOdd(num)); - * - * As with MOZ_ASSERT, MOZ_ASSERT_IF has effect only in debug builds. It is - * designed to catch bugs during debugging, not "in the field". - */ -#ifdef DEBUG -# define MOZ_ASSERT_IF(cond, expr) ((cond) ? MOZ_ASSERT(expr) : ((void)0)) -#else -# define MOZ_ASSERT_IF(cond, expr) ((void)0) -#endif - -/* MOZ_NOT_REACHED_MARKER() expands (in compilers which support it) to an - * expression which states that it is undefined behavior for the compiler to - * reach this point. Most code should probably use the higher level - * MOZ_NOT_REACHED (which expands to this when appropriate). - */ -#if defined(__clang__) -# define MOZ_NOT_REACHED_MARKER() __builtin_unreachable() -#elif defined(__GNUC__) -# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5) -# define MOZ_NOT_REACHED_MARKER() __builtin_unreachable() -# endif -#elif defined(_MSC_VER) -# define MOZ_NOT_REACHED_MARKER() __assume(0) -#endif - -/* - * MOZ_NOT_REACHED(reason) indicates that the given point can't be reached - * during execution: simply reaching that point in execution is a bug. It takes - * as an argument an error message indicating the reason why that point should - * not have been reachable. - * - * // ...in a language parser... - * void handle(BooleanLiteralNode node) - * { - * if (node.isTrue()) - * handleTrueLiteral(); - * else if (node.isFalse()) - * handleFalseLiteral(); - * else - * MOZ_NOT_REACHED("boolean literal that's not true or false?"); - * } - */ -#if defined(MOZ_NOT_REACHED_MARKER) -# if defined(DEBUG) -# define MOZ_NOT_REACHED(reason) do { \ - MOZ_Assert(reason, __FILE__, __LINE__); \ - MOZ_NOT_REACHED_MARKER(); \ - } while (0) -# else -# define MOZ_NOT_REACHED(reason) MOZ_NOT_REACHED_MARKER() -# endif -#else -# if defined(__GNUC__) - /* - * On older versions of gcc we need to call a noreturn function to mark the - * code as unreachable. Since what we want is an unreachable version of - * MOZ_Assert, we use an asm label - * (http://gcc.gnu.org/onlinedocs/gcc-4.6.2/gcc/Asm-Labels.html) to create - * a new declaration to the same symbol. MOZ_ASSERT_NR should only be - * used via this macro, as it is a very specific hack to older versions of - * gcc. - */ -# define MOZ_GETASMPREFIX2(X) #X -# define MOZ_GETASMPREFIX(X) MOZ_GETASMPREFIX2(X) -# define MOZ_ASMPREFIX MOZ_GETASMPREFIX(__USER_LABEL_PREFIX__) - extern MOZ_NORETURN MFBT_API(void) - MOZ_ASSERT_NR(const char* s, const char* file, int ln) \ - asm (MOZ_ASMPREFIX "MOZ_Assert"); - -# define MOZ_NOT_REACHED(reason) MOZ_ASSERT_NR(reason, __FILE__, __LINE__) -# elif defined(DEBUG) -# define MOZ_NOT_REACHED(reason) MOZ_Assert(reason, __FILE__, __LINE__) -# else -# define MOZ_NOT_REACHED(reason) ((void)0) -# endif -#endif - -/* - * MOZ_ALWAYS_TRUE(expr) and MOZ_ALWAYS_FALSE(expr) always evaluate the provided - * expression, in debug builds and in release builds both. Then, in debug - * builds only, the value of the expression is asserted either true or false - * using MOZ_ASSERT. - */ -#ifdef DEBUG -# define MOZ_ALWAYS_TRUE(expr) MOZ_ASSERT((expr)) -# define MOZ_ALWAYS_FALSE(expr) MOZ_ASSERT(!(expr)) -#else -# define MOZ_ALWAYS_TRUE(expr) ((void)(expr)) -# define MOZ_ALWAYS_FALSE(expr) ((void)(expr)) -#endif - -#endif /* mozilla_Assertions_h_ */ diff --git a/js/spidermonkey-win32/include/mozilla/Attributes.h b/js/spidermonkey-win32/include/mozilla/Attributes.h deleted file mode 100644 index 4713b2c3f7..0000000000 --- a/js/spidermonkey-win32/include/mozilla/Attributes.h +++ /dev/null @@ -1,344 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sw=4 et tw=99 ft=cpp: - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Code. - * - * The Initial Developer of the Original Code is - * The Mozilla Foundation - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Jeff Walden (original author) - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* Implementations of various class and method modifier attributes. */ - -#ifndef mozilla_Attributes_h_ -#define mozilla_Attributes_h_ - -/* - * This header does not include any other headers so that it can be included by - * code that is (only currently) mfbt-incompatible. - */ - -/* - * MOZ_INLINE is a macro which expands to tell the compiler that the method - * decorated with it should be inlined. This macro is usable from C and C++ - * code, even though C89 does not support the |inline| keyword. The compiler - * may ignore this directive if it chooses. - */ -#if defined(__cplusplus) -# define MOZ_INLINE inline -#elif defined(_MSC_VER) -# define MOZ_INLINE __inline -#elif defined(__GNUC__) -# define MOZ_INLINE __inline__ -#else -# define MOZ_INLINE inline -#endif - -/* - * MOZ_ALWAYS_INLINE is a macro which expands to tell the compiler that the - * method decorated with it must be inlined, even if the compiler thinks - * otherwise. This is only a (much) stronger version of the MOZ_INLINE hint: - * compilers are not guaranteed to respect it (although they're much more likely - * to do so). - */ -#if defined(DEBUG) -# define MOZ_ALWAYS_INLINE MOZ_INLINE -#elif defined(_MSC_VER) -# define MOZ_ALWAYS_INLINE __forceinline -#elif defined(__GNUC__) -# define MOZ_ALWAYS_INLINE __attribute__((always_inline)) MOZ_INLINE -#else -# define MOZ_ALWAYS_INLINE MOZ_INLINE -#endif - -/* - * g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality - * without warnings (functionality used by the macros below). These modes are - * detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or, more - * standardly, by checking whether __cplusplus has a C++11 or greater value. - * Current versions of g++ do not correctly set __cplusplus, so we check both - * for forward compatibility. - */ -#if defined(__clang__) - /* - * Per Clang documentation, "Note that marketing version numbers should not - * be used to check for language features, as different vendors use different - * numbering schemes. Instead, use the feature checking macros." - */ -# ifndef __has_extension -# define __has_extension __has_feature /* compatibility, for older versions of clang */ -# endif -# if __has_extension(cxx_deleted_functions) -# define MOZ_HAVE_CXX11_DELETE -# endif -# if __has_extension(cxx_override_control) -# define MOZ_HAVE_CXX11_OVERRIDE -# define MOZ_HAVE_CXX11_FINAL final -# endif -# if __has_attribute(noinline) -# define MOZ_HAVE_NEVER_INLINE __attribute__((noinline)) -# endif -# if __has_attribute(noreturn) -# define MOZ_HAVE_NORETURN __attribute__((noreturn)) -# endif -#elif defined(__GNUC__) -# if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L -# if __GNUC__ > 4 -# define MOZ_HAVE_CXX11_DELETE -# define MOZ_HAVE_CXX11_OVERRIDE -# define MOZ_HAVE_CXX11_FINAL final -# elif __GNUC__ == 4 -# if __GNUC_MINOR__ >= 7 -# define MOZ_HAVE_CXX11_OVERRIDE -# define MOZ_HAVE_CXX11_FINAL final -# endif -# if __GNUC_MINOR__ >= 4 -# define MOZ_HAVE_CXX11_DELETE -# endif -# endif -# else - /* __final is a non-C++11 GCC synonym for 'final', per GCC r176655. */ -# if __GNUC__ > 4 -# define MOZ_HAVE_CXX11_FINAL __final -# elif __GNUC__ == 4 -# if __GNUC_MINOR__ >= 7 -# define MOZ_HAVE_CXX11_FINAL __final -# endif -# endif -# endif -# define MOZ_HAVE_NEVER_INLINE __attribute__((noinline)) -# define MOZ_HAVE_NORETURN __attribute__((noreturn)) -#elif defined(_MSC_VER) -# if _MSC_VER >= 1400 -# define MOZ_HAVE_CXX11_OVERRIDE - /* MSVC currently spells "final" as "sealed". */ -# define MOZ_HAVE_CXX11_FINAL sealed -# endif -# define MOZ_HAVE_NEVER_INLINE __declspec(noinline) -# define MOZ_HAVE_NORETURN __declspec(noreturn) -#endif - -/* - * MOZ_NEVER_INLINE is a macro which expands to tell the compiler that the - * method decorated with it must never be inlined, even if the compiler would - * otherwise choose to inline the method. Compilers aren't absolutely - * guaranteed to support this, but most do. - */ -#if defined(MOZ_HAVE_NEVER_INLINE) -# define MOZ_NEVER_INLINE MOZ_HAVE_NEVER_INLINE -#else -# define MOZ_NEVER_INLINE /* no support */ -#endif - -/* - * MOZ_NORETURN, specified at the start of a function declaration, indicates - * that the given function does not return. (The function definition does not - * need to be annotated.) - * - * MOZ_NORETURN void abort(const char* msg); - * - * This modifier permits the compiler to optimize code assuming a call to such a - * function will never return. It also enables the compiler to avoid spurious - * warnings about not initializing variables, or about any other seemingly-dodgy - * operations performed after the function returns. - * - * This modifier does not affect the corresponding function's linking behavior. - */ -#if defined(MOZ_HAVE_NORETURN) -# define MOZ_NORETURN MOZ_HAVE_NORETURN -#else -# define MOZ_NORETURN /* no support */ -#endif - -#ifdef __cplusplus - -/* - * MOZ_DELETE, specified immediately prior to the ';' terminating an undefined- - * method declaration, attempts to delete that method from the corresponding - * class. An attempt to use the method will always produce an error *at compile - * time* (instead of sometimes as late as link time) when this macro can be - * implemented. For example, you can use MOZ_DELETE to produce classes with no - * implicit copy constructor or assignment operator: - * - * struct NonCopyable - * { - * private: - * NonCopyable(const NonCopyable& other) MOZ_DELETE; - * void operator=(const NonCopyable& other) MOZ_DELETE; - * }; - * - * If MOZ_DELETE can't be implemented for the current compiler, use of the - * annotated method will still cause an error, but the error might occur at link - * time in some cases rather than at compile time. - * - * MOZ_DELETE relies on C++11 functionality not universally implemented. As a - * backstop, method declarations using MOZ_DELETE should be private. - */ -#if defined(MOZ_HAVE_CXX11_DELETE) -# define MOZ_DELETE = delete -#else -# define MOZ_DELETE /* no support */ -#endif - -/* - * MOZ_OVERRIDE explicitly indicates that a virtual member function in a class - * overrides a member function of a base class, rather than potentially being a - * new member function. MOZ_OVERRIDE should be placed immediately before the - * ';' terminating the member function's declaration, or before '= 0;' if the - * member function is pure. If the member function is defined in the class - * definition, it should appear before the opening brace of the function body. - * - * class Base - * { - * public: - * virtual void f() = 0; - * }; - * class Derived1 : public Base - * { - * public: - * virtual void f() MOZ_OVERRIDE; - * }; - * class Derived2 : public Base - * { - * public: - * virtual void f() MOZ_OVERRIDE = 0; - * }; - * class Derived3 : public Base - * { - * public: - * virtual void f() MOZ_OVERRIDE { } - * }; - * - * In compilers supporting C++11 override controls, MOZ_OVERRIDE *requires* that - * the function marked with it override a member function of a base class: it - * is a compile error if it does not. Otherwise MOZ_OVERRIDE does not affect - * semantics and merely documents the override relationship to the reader (but - * of course must still be used correctly to not break C++11 compilers). - */ -#if defined(MOZ_HAVE_CXX11_OVERRIDE) -# define MOZ_OVERRIDE override -#else -# define MOZ_OVERRIDE /* no support */ -#endif - -/* - * MOZ_FINAL indicates that some functionality cannot be overridden through - * inheritance. It can be used to annotate either classes/structs or virtual - * member functions. - * - * To annotate a class/struct with MOZ_FINAL, place MOZ_FINAL immediately after - * the name of the class, before the list of classes from which it derives (if - * any) and before its opening brace. MOZ_FINAL must not be used to annotate - * unnamed classes or structs. (With some compilers, and with C++11 proper, the - * underlying expansion is ambiguous with specifying a class name.) - * - * class Base MOZ_FINAL - * { - * public: - * Base(); - * ~Base(); - * virtual void f() { } - * }; - * // This will be an error in some compilers: - * class Derived : public Base - * { - * public: - * ~Derived() { } - * }; - * - * One particularly common reason to specify MOZ_FINAL upon a class is to tell - * the compiler that it's not dangerous for it to have a non-virtual destructor - * yet have one or more virtual functions, silencing the warning it might emit - * in this case. Suppose Base above weren't annotated with MOZ_FINAL. Because - * ~Base() is non-virtual, an attempt to delete a Derived* through a Base* - * wouldn't call ~Derived(), so any cleanup ~Derived() might do wouldn't happen. - * (Formally C++ says behavior is undefined, but compilers will likely just call - * ~Base() and not ~Derived().) Specifying MOZ_FINAL tells the compiler that - * it's safe for the destructor to be non-virtual. - * - * In compilers implementing final controls, it is an error to inherit from a - * class annotated with MOZ_FINAL. In other compilers it serves only as - * documentation. - * - * To annotate a virtual member function with MOZ_FINAL, place MOZ_FINAL - * immediately before the ';' terminating the member function's declaration, or - * before '= 0;' if the member function is pure. If the member function is - * defined in the class definition, it should appear before the opening brace of - * the function body. (This placement is identical to that for MOZ_OVERRIDE. - * If both are used, they should appear in the order 'MOZ_FINAL MOZ_OVERRIDE' - * for consistency.) - * - * class Base - * { - * public: - * virtual void f() MOZ_FINAL; - * }; - * class Derived - * { - * public: - * // This will be an error in some compilers: - * virtual void f(); - * }; - * - * In compilers implementing final controls, it is an error for a derived class - * to override a method annotated with MOZ_FINAL. In other compilers it serves - * only as documentation. - */ -#if defined(MOZ_HAVE_CXX11_FINAL) -# define MOZ_FINAL MOZ_HAVE_CXX11_FINAL -#else -# define MOZ_FINAL /* no support */ -#endif - -/** - * MOZ_WARN_UNUSED_RESULT tells the compiler to emit a warning if a function's - * return value is not used by the caller. - * - * Place this attribute at the very beginning of a function definition. For - * example, write - * - * MOZ_WARN_UNUSED_RESULT int foo(); - * - * or - * - * MOZ_WARN_UNUSED_RESULT int foo() { return 42; } - */ -#if defined(__GNUC__) || defined(__clang__) -# define MOZ_WARN_UNUSED_RESULT __attribute__ ((warn_unused_result)) -#else -# define MOZ_WARN_UNUSED_RESULT -#endif - -#endif /* __cplusplus */ - -#endif /* mozilla_Attributes_h_ */ diff --git a/js/spidermonkey-win32/include/mozilla/BloomFilter.h b/js/spidermonkey-win32/include/mozilla/BloomFilter.h deleted file mode 100644 index 26bc043da9..0000000000 --- a/js/spidermonkey-win32/include/mozilla/BloomFilter.h +++ /dev/null @@ -1,232 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * A counting Bloom filter implementation. This allows consumers to - * do fast probabilistic "is item X in set Y?" testing which will - * never answer "no" when the correct answer is "yes" (but might - * incorrectly answer "yes" when the correct answer is "no"). - */ - -#ifndef mozilla_BloomFilter_h_ -#define mozilla_BloomFilter_h_ - -#include "mozilla/Likely.h" -#include "mozilla/StandardInteger.h" -#include "mozilla/Util.h" - -#include - -namespace mozilla { - -/* - * This class implements a counting Bloom filter as described at - * , with - * 8-bit counters. This allows quick probabilistic answers to the - * question "is object X in set Y?" where the contents of Y might not - * be time-invariant. The probabilistic nature of the test means that - * sometimes the answer will be "yes" when it should be "no". If the - * answer is "no", then X is guaranteed not to be in Y. - * - * The filter is parametrized on KeySize, which is the size of the key - * generated by each of hash functions used by the filter, in bits, - * and the type of object T being added and removed. T must implement - * a |uint32_t hash() const| method which returns a uint32_t hash key - * that will be used to generate the two separate hash functions for - * the Bloom filter. This hash key MUST be well-distributed for good - * results! KeySize is not allowed to be larger than 16. - * - * The filter uses exactly 2**KeySize bytes of memory. From now on we - * will refer to the memory used by the filter as M. - * - * The expected rate of incorrect "yes" answers depends on M and on - * the number N of objects in set Y. As long as N is small compared - * to M, the rate of such answers is expected to be approximately - * 4*(N/M)**2 for this filter. In practice, if Y has a few hundred - * elements then using a KeySize of 12 gives a reasonably low - * incorrect answer rate. A KeySize of 12 has the additional benefit - * of using exactly one page for the filter in typical hardware - * configurations. - */ - -template -class BloomFilter { - /* - * A counting Bloom filter with 8-bit counters. For now we assume - * that having two hash functions is enough, but we may revisit that - * decision later. - * - * The filter uses an array with 2**KeySize entries. - * - * Assuming a well-distributed hash function, a Bloom filter with - * array size M containing N elements and - * using k hash function has expected false positive rate exactly - * - * $ (1 - (1 - 1/M)^{kN})^k $ - * - * because each array slot has a - * - * $ (1 - 1/M)^{kN} $ - * - * chance of being 0, and the expected false positive rate is the - * probability that all of the k hash functions will hit a nonzero - * slot. - * - * For reasonable assumptions (M large, kN large, which should both - * hold if we're worried about false positives) about M and kN this - * becomes approximately - * - * $$ (1 - \exp(-kN/M))^k $$ - * - * For our special case of k == 2, that's $(1 - \exp(-2N/M))^2$, - * or in other words - * - * $$ N/M = -0.5 * \ln(1 - \sqrt(r)) $$ - * - * where r is the false positive rate. This can be used to compute - * the desired KeySize for a given load N and false positive rate r. - * - * If N/M is assumed small, then the false positive rate can - * further be approximated as 4*N^2/M^2. So increasing KeySize by - * 1, which doubles M, reduces the false positive rate by about a - * factor of 4, and a false positive rate of 1% corresponds to - * about M/N == 20. - * - * What this means in practice is that for a few hundred keys using a - * KeySize of 12 gives false positive rates on the order of 0.25-4%. - * - * Similarly, using a KeySize of 10 would lead to a 4% false - * positive rate for N == 100 and to quite bad false positive - * rates for larger N. - */ -public: - BloomFilter() { - MOZ_STATIC_ASSERT(KeySize <= keyShift, "KeySize too big"); - - // Should we have a custom operator new using calloc instead and - // require that we're allocated via the operator? - clear(); - } - - /* - * Clear the filter. This should be done before reusing it, because - * just removing all items doesn't clear counters that hit the upper - * bound. - */ - void clear(); - - /* - * Add an item to the filter. - */ - void add(const T* t); - - /* - * Remove an item from the filter. - */ - void remove(const T* t); - - /* - * Check whether the filter might contain an item. This can - * sometimes return true even if the item is not in the filter, - * but will never return false for items that are actually in the - * filter. - */ - bool mayContain(const T* t) const; - - /* - * Methods for add/remove/contain when we already have a hash computed - */ - void add(uint32_t hash); - void remove(uint32_t hash); - bool mayContain(uint32_t hash) const; - -private: - static const size_t arraySize = (1 << KeySize); - static const uint32_t keyMask = (1 << KeySize) - 1; - static const uint32_t keyShift = 16; - - static uint32_t hash1(uint32_t hash) { return hash & keyMask; } - static uint32_t hash2(uint32_t hash) { return (hash >> keyShift) & keyMask; } - - uint8_t& firstSlot(uint32_t hash) { return counters[hash1(hash)]; } - uint8_t& secondSlot(uint32_t hash) { return counters[hash2(hash)]; } - const uint8_t& firstSlot(uint32_t hash) const { return counters[hash1(hash)]; } - const uint8_t& secondSlot(uint32_t hash) const { return counters[hash2(hash)]; } - - static bool full(const uint8_t& slot) { return slot == UINT8_MAX; } - - uint8_t counters[arraySize]; -}; - -template -inline void -BloomFilter::clear() -{ - memset(counters, 0, arraySize); -} - -template -inline void -BloomFilter::add(uint32_t hash) -{ - uint8_t& slot1 = firstSlot(hash); - if (MOZ_LIKELY(!full(slot1))) - ++slot1; - - uint8_t& slot2 = secondSlot(hash); - if (MOZ_LIKELY(!full(slot2))) - ++slot2; -} - -template -MOZ_ALWAYS_INLINE void -BloomFilter::add(const T* t) -{ - uint32_t hash = t->hash(); - return add(hash); -} - -template -inline void -BloomFilter::remove(uint32_t hash) -{ - // If the slots are full, we don't know whether we bumped them to be - // there when we added or not, so just leave them full. - uint8_t& slot1 = firstSlot(hash); - if (MOZ_LIKELY(!full(slot1))) - --slot1; - - uint8_t& slot2 = secondSlot(hash); - if (MOZ_LIKELY(!full(slot2))) - --slot2; -} - -template -MOZ_ALWAYS_INLINE void -BloomFilter::remove(const T* t) -{ - uint32_t hash = t->hash(); - remove(hash); -} - -template -MOZ_ALWAYS_INLINE bool -BloomFilter::mayContain(uint32_t hash) const -{ - // Check that all the slots for this hash contain something - return firstSlot(hash) && secondSlot(hash); -} - -template -MOZ_ALWAYS_INLINE bool -BloomFilter::mayContain(const T* t) const -{ - uint32_t hash = t->hash(); - return mayContain(hash); -} - -} // namespace mozilla - -#endif /* mozilla_BloomFilter_h_ */ diff --git a/js/spidermonkey-win32/include/mozilla/GuardObjects.h b/js/spidermonkey-win32/include/mozilla/GuardObjects.h deleted file mode 100644 index 68d5eb35d0..0000000000 --- a/js/spidermonkey-win32/include/mozilla/GuardObjects.h +++ /dev/null @@ -1,182 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* vim: set ts=8 sw=4 et tw=99 ft=cpp: */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is mozilla.org code. - * - * The Initial Developer of the Original Code is - * the Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2010 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * L. David Baron , Mozilla Corporation (original author) - * Ms2ger - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* Implementation of macros to ensure correct use of RAII Auto* objects. */ - -#ifndef mozilla_GuardObjects_h -#define mozilla_GuardObjects_h - -#include "mozilla/Assertions.h" -#include "mozilla/Types.h" - -#ifdef __cplusplus - -#ifdef DEBUG - -namespace mozilla { -namespace detail { -/* - * The following classes are designed to cause assertions to detect - * inadvertent use of guard objects as temporaries. In other words, - * when we have a guard object whose only purpose is its constructor and - * destructor (and is never otherwise referenced), the intended use - * might be: - * - * AutoRestore savePainting(mIsPainting); - * - * but is is easy to accidentally write: - * - * AutoRestore(mIsPainting); - * - * which compiles just fine, but runs the destructor well before the - * intended time. - * - * They work by adding (#ifdef DEBUG) an additional parameter to the - * guard object's constructor, with a default value, so that users of - * the guard object's API do not need to do anything. The default value - * of this parameter is a temporary object. C++ (ISO/IEC 14882:1998), - * section 12.2 [class.temporary], clauses 4 and 5 seem to assume a - * guarantee that temporaries are destroyed in the reverse of their - * construction order, but I actually can't find a statement that that - * is true in the general case (beyond the two specific cases mentioned - * there). However, it seems to be true. - * - * These classes are intended to be used only via the macros immediately - * below them: - * - * MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER declares (ifdef DEBUG) a member - * variable, and should be put where a declaration of a private - * member variable would be placed. - * MOZ_GUARD_OBJECT_NOTIFIER_PARAM should be placed at the end of the - * parameters to each constructor of the guard object; it declares - * (ifdef DEBUG) an additional parameter. (But use the *_ONLY_PARAM - * variant for constructors that take no other parameters.) - * MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL should likewise be used in - * the implementation of such constructors when they are not inline. - * MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT should be used in - * the implementation of such constructors to pass the parameter to - * a base class that also uses these macros - * MOZ_GUARD_OBJECT_NOTIFIER_INIT is a statement that belongs in each - * constructor. It uses the parameter declared by - * MOZ_GUARD_OBJECT_NOTIFIER_PARAM. - * - * For more details, and examples of using these macros, see - * https://developer.mozilla.org/en/Using_RAII_classes_in_Mozilla - */ -class MOZ_EXPORT_API(GuardObjectNotifier) -{ - private: - bool* statementDone; - - public: - GuardObjectNotifier() : statementDone(NULL) {} - - ~GuardObjectNotifier() { - *statementDone = true; - } - - void setStatementDone(bool* statementIsDone) { - statementDone = statementIsDone; - } -}; - -class MOZ_EXPORT_API(GuardObjectNotificationReceiver) -{ - private: - bool statementDone; - - public: - GuardObjectNotificationReceiver() : statementDone(false) {} - - ~GuardObjectNotificationReceiver() { - /* - * Assert that the guard object was not used as a temporary. - * (Note that this assert might also fire if init is not called - * because the guard object's implementation is not using the - * above macros correctly.) - */ - MOZ_ASSERT(statementDone); - } - - void init(const GuardObjectNotifier& constNotifier) { - /* - * constNotifier is passed as a const reference so that we can pass a - * temporary, but we really intend it as non-const. - */ - GuardObjectNotifier& notifier = const_cast(constNotifier); - notifier.setStatementDone(&statementDone); - } -}; - -} /* namespace detail */ -} /* namespace mozilla */ - -#endif /* DEBUG */ - -#ifdef DEBUG -# define MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER \ - mozilla::detail::GuardObjectNotificationReceiver _mCheckNotUsedAsTemporary; -# define MOZ_GUARD_OBJECT_NOTIFIER_PARAM \ - , const mozilla::detail::GuardObjectNotifier& _notifier = \ - mozilla::detail::GuardObjectNotifier() -# define MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM \ - const mozilla::detail::GuardObjectNotifier& _notifier = \ - mozilla::detail::GuardObjectNotifier() -# define MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL \ - , const mozilla::detail::GuardObjectNotifier& _notifier -# define MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT \ - , _notifier -# define MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_TO_PARENT \ - _notifier -# define MOZ_GUARD_OBJECT_NOTIFIER_INIT \ - do { _mCheckNotUsedAsTemporary.init(_notifier); } while (0) -#else -# define MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER -# define MOZ_GUARD_OBJECT_NOTIFIER_PARAM -# define MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM -# define MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL -# define MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_TO_PARENT -# define MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT -# define MOZ_GUARD_OBJECT_NOTIFIER_INIT do { } while (0) -#endif - -#endif /* __cplusplus */ - -#endif /* mozilla_GuardObjects_h */ diff --git a/js/spidermonkey-win32/include/mozilla/HashFunctions.h b/js/spidermonkey-win32/include/mozilla/HashFunctions.h deleted file mode 100644 index 9bc088a20b..0000000000 --- a/js/spidermonkey-win32/include/mozilla/HashFunctions.h +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- - * vim: set ts=8 sw=4 et tw=99 ft=cpp: - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Utilities for hashing */ - -#ifndef mozilla_HashFunctions_h_ -#define mozilla_HashFunctions_h_ - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/StandardInteger.h" - -#ifdef __cplusplus -namespace mozilla { - -/** - * The golden ratio as a 32-bit fixed-point value. - */ -static const uint32_t GoldenRatioU32 = 0x9E3779B9U; - -inline uint32_t -RotateLeft32(uint32_t value, uint8_t bits) -{ - MOZ_ASSERT(bits < 32); - return (value << bits) | (value >> (32 - bits)); -} - -/** - * Add the given value(s) to the given hashcode and return the new hashcode. - * - * AddToHash(h, x, y) is equivalent to AddToHash(AddToHash(h, x), y). - */ -MOZ_WARN_UNUSED_RESULT -inline uint32_t -AddToHash(uint32_t hash, uint32_t value) -{ - /* - * This is not a sophisticated hash routine, but it seems to work well for our - * mostly plain-text inputs. Implementation notes follow. - * - * Our use of the golden ratio here is arbitrary; we could pick almost any - * number which: - * - * * is odd (because otherwise, all our hash values will be even) - * - * * has a reasonably-even mix of 1's and 0's (consider the extreme case - * where we multiply by 0x3 or 0xeffffff -- this will not produce good - * mixing across all bits of the hash). - * - * The rotation length of 5 is also arbitrary, although an odd number is again - * preferable so our hash explores the whole universe of possible rotations. - * - * Finally, we multiply by the golden ratio *after* xor'ing, not before. - * Otherwise, if |hash| is 0 (as it often is for the beginning of a message), - * the expression - * - * (GoldenRatioU32 * RotateLeft(hash, 5)) ^ value - * - * evaluates to |value|. - * - * (Number-theoretic aside: Because any odd number |m| is relatively prime to - * our modulus (2^32), the list - * - * [x * m (mod 2^32) for 0 <= x < 2^32] - * - * has no duplicate elements. This means that multiplying by |m| does not - * cause us to skip any possible hash values. - * - * It's also nice if |m| has larger order mod 2^32 -- that is, if the smallest - * k such that m^k == 1 (mod 2^32) is large -- so we can safely multiply our - * hash value by |m| a few times without negating the multiplicative effect. - * Our golden ratio constant has order 2^29, which is more than enough for our - * purposes.) - */ - return GoldenRatioU32 * (RotateLeft32(hash, 5) ^ value); -} - -MOZ_WARN_UNUSED_RESULT -inline uint32_t -AddToHash(uint32_t hash, uint32_t v1, uint32_t v2) -{ - return AddToHash(AddToHash(hash, v1), v2); -} - -MOZ_WARN_UNUSED_RESULT -inline uint32_t -AddToHash(uint32_t hash, uint32_t v1, uint32_t v2, uint32_t v3) -{ - return AddToHash(AddToHash(hash, v1, v2), v3); -} - -MOZ_WARN_UNUSED_RESULT -inline uint32_t -AddToHash(uint32_t hash, uint32_t v1, uint32_t v2, uint32_t v3, uint32_t v4) -{ - return AddToHash(AddToHash(hash, v1, v2, v3), v4); -} - -MOZ_WARN_UNUSED_RESULT -inline uint32_t -AddToHash(uint32_t hash, uint32_t v1, uint32_t v2, uint32_t v3, uint32_t v4, uint32_t v5) -{ - return AddToHash(AddToHash(hash, v1, v2, v3, v4), v5); -} - -} /* namespace mozilla */ -#endif /* __cplusplus */ -#endif /* mozilla_HashFunctions_h_ */ diff --git a/js/spidermonkey-win32/include/mozilla/Likely.h b/js/spidermonkey-win32/include/mozilla/Likely.h deleted file mode 100644 index 6534239b16..0000000000 --- a/js/spidermonkey-win32/include/mozilla/Likely.h +++ /dev/null @@ -1,21 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * MOZ_LIKELY and MOZ_UNLIKELY macros to hint to the compiler how a - * boolean predicate should be branch-predicted. - */ - -#ifndef Likely_h_ -#define Likely_h_ - -#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ > 2)) -# define MOZ_LIKELY(x) (__builtin_expect((x), 1)) -# define MOZ_UNLIKELY(x) (__builtin_expect((x), 0)) -#else -# define MOZ_LIKELY(x) (x) -# define MOZ_UNLIKELY(x) (x) -#endif - -#endif /* Likely_h_ */ diff --git a/js/spidermonkey-win32/include/mozilla/LinkedList.h b/js/spidermonkey-win32/include/mozilla/LinkedList.h deleted file mode 100644 index 70244b8967..0000000000 --- a/js/spidermonkey-win32/include/mozilla/LinkedList.h +++ /dev/null @@ -1,422 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=4 sw=4 tw=80 et cin: - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Code. - * - * The Initial Developer of the Original Code is - * The Mozilla Foundation - * Portions created by the Initial Developer are Copyright (C) 2012 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Justin Lebar - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* A type-safe doubly-linked list class. */ - -/* - * The classes LinkedList and LinkedListElement together form a - * convenient, type-safe doubly-linked list implementation. - * - * The class T which will be inserted into the linked list must inherit from - * LinkedListElement. A given object may be in only one linked list at a - * time. - * - * For example, you might use LinkedList in a simple observer list class as - * follows. - * - * class Observer : public LinkedListElement - * { - * void observe(char* topic) { ... } - * }; - * - * class ObserverContainer - * { - * private: - * LinkedList list; - * - * public: - * - * void addObserver(Observer* observer) - * { - * // Will assert if |observer| is part of another list. - * list.insertBack(observer); - * } - * - * void removeObserver(Observer* observer) - * { - * // Will assert if |observer| is not part of some list. - * observer.remove(); - * } - * - * void notifyObservers(char* topic) - * { - * for (Observer* o = list.getFirst(); - * o != NULL; - * o = o->getNext()) { - * o->Observe(topic); - * } - * } - * }; - * - */ - -#ifndef mozilla_LinkedList_h_ -#define mozilla_LinkedList_h_ - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" - -#ifdef __cplusplus - -namespace mozilla { - -template -class LinkedList; - -template -class LinkedListElement -{ - /* - * It's convenient that we return NULL when getNext() or getPrevious() hits - * the end of the list, but doing so costs an extra word of storage in each - * linked list node (to keep track of whether |this| is the sentinel node) - * and a branch on this value in getNext/getPrevious. - * - * We could get rid of the extra word of storage by shoving the "is - * sentinel" bit into one of the pointers, although this would, of course, - * have performance implications of its own. - * - * But the goal here isn't to win an award for the fastest or slimmest - * linked list; rather, we want a *convenient* linked list. So we won't - * waste time guessing which micro-optimization strategy is best. - * - * - * Speaking of unnecessary work, it's worth addressing here why we wrote - * mozilla::LinkedList in the first place, instead of using stl::list. - * - * The key difference between mozilla::LinkedList and stl::list is that - * mozilla::LinkedList stores the prev/next pointers in the object itself, - * while stl::list stores the prev/next pointers in a list element which - * itself points to the object being stored. - * - * mozilla::LinkedList's approach makes it harder to store an object in more - * than one list. But the upside is that you can call next() / prev() / - * remove() directly on the object. With stl::list, you'd need to store a - * pointer to its iterator in the object in order to accomplish this. Not - * only would this waste space, but you'd have to remember to update that - * pointer every time you added or removed the object from a list. - * - * In-place, constant-time removal is a killer feature of doubly-linked - * lists, and supporting this painlessly was a key design criterion. - */ - -private: - LinkedListElement* next; - LinkedListElement* prev; - const bool isSentinel; - -public: - LinkedListElement() - : next(this) - , prev(this) - , isSentinel(false) - { - } - - /* - * Get the next element in the list, or NULL if this is the last element in - * the list. - */ - T* getNext() - { - return next->asT(); - } - - /* - * Get the previous element in the list, or NULL if this is the first element - * in the list. - */ - T* getPrevious() - { - return prev->asT(); - } - - /* - * Insert elem after this element in the list. |this| must be part of a - * linked list when you call setNext(); otherwise, this method will assert. - */ - void setNext(T* elem) - { - MOZ_ASSERT(isInList()); - setNextUnsafe(elem); - } - - /* - * Insert elem before this element in the list. |this| must be part of a - * linked list when you call setPrevious(); otherwise, this method will - * assert. - */ - void setPrevious(T* elem) - { - MOZ_ASSERT(isInList()); - setPreviousUnsafe(elem); - } - - /* - * Remove this element from the list which contains it. If this element is - * not currently part of a linked list, this method asserts. - */ - void remove() - { - MOZ_ASSERT(isInList()); - - prev->next = next; - next->prev = prev; - next = this; - prev = this; - } - - /* - * Return true if |this| part is of a linked list, and false otherwise. - */ - bool isInList() - { - MOZ_ASSERT((next == this) == (prev == this)); - return next != this; - } - -private: - LinkedListElement& operator=(const LinkedList& other) MOZ_DELETE; - LinkedListElement(const LinkedList& other) MOZ_DELETE; - - friend class LinkedList; - - enum NodeKind { - NODE_KIND_NORMAL, - NODE_KIND_SENTINEL - }; - - LinkedListElement(NodeKind nodeKind) - : next(this) - , prev(this) - , isSentinel(nodeKind == NODE_KIND_SENTINEL) - { - } - - /* - * Return |this| cast to T* if we're a normal node, or return NULL if we're - * a sentinel node. - */ - T* asT() - { - if (isSentinel) - return NULL; - - return static_cast(this); - } - - /* - * Insert elem after this element, but don't check that this element is in - * the list. This is called by LinkedList::insertFront(). - */ - void setNextUnsafe(T* elem) - { - LinkedListElement *listElem = static_cast(elem); - MOZ_ASSERT(!listElem->isInList()); - - listElem->next = this->next; - listElem->prev = this; - this->next->prev = listElem; - this->next = listElem; - } - - /* - * Insert elem before this element, but don't check that this element is in - * the list. This is called by LinkedList::insertBack(). - */ - void setPreviousUnsafe(T* elem) - { - LinkedListElement* listElem = static_cast*>(elem); - MOZ_ASSERT(!listElem->isInList()); - - listElem->next = this; - listElem->prev = this->prev; - this->prev->next = listElem; - this->prev = listElem; - } -}; - -template -class LinkedList -{ -private: - LinkedListElement sentinel; - -public: - LinkedList& operator=(const LinkedList& other) MOZ_DELETE; - LinkedList(const LinkedList& other) MOZ_DELETE; - - LinkedList() - : sentinel(LinkedListElement::NODE_KIND_SENTINEL) - { - } - - /* - * Add elem to the front of the list. - */ - void insertFront(T* elem) - { - /* Bypass setNext()'s this->isInList() assertion. */ - sentinel.setNextUnsafe(elem); - } - - /* - * Add elem to the back of the list. - */ - void insertBack(T* elem) - { - sentinel.setPreviousUnsafe(elem); - } - - /* - * Get the first element of the list, or NULL if the list is empty. - */ - T* getFirst() - { - return sentinel.getNext(); - } - - /* - * Get the last element of the list, or NULL if the list is empty. - */ - T* getLast() - { - return sentinel.getPrevious(); - } - - /* - * Get and remove the first element of the list. If the list is empty, - * return NULL. - */ - T* popFirst() - { - T* ret = sentinel.getNext(); - if (ret) - static_cast*>(ret)->remove(); - - return ret; - } - - /* - * Get and remove the last element of the list. If the list is empty, - * return NULL. - */ - T* popLast() - { - T* ret = sentinel.getPrevious(); - if (ret) - static_cast*>(ret)->remove(); - - return ret; - } - - /* - * Return true if the list is empty, or false otherwise. - */ - bool isEmpty() - { - return !sentinel.isInList(); - } - - /* - * In a debug build, make sure that the list is sane (no cycles, consistent - * next/prev pointers, only one sentinel). Has no effect in release builds. - */ - void debugAssertIsSane() - { -#ifdef DEBUG - /* - * Check for cycles in the forward singly-linked list using the - * tortoise/hare algorithm. - */ - for (LinkedListElement* slow = sentinel.next, - * fast1 = sentinel.next->next, - * fast2 = sentinel.next->next->next; - slow != sentinel && fast1 != sentinel && fast2 != sentinel; - slow = slow->next, - fast1 = fast2->next, - fast2 = fast1->next) { - - MOZ_ASSERT(slow != fast1); - MOZ_ASSERT(slow != fast2); - } - - /* Check for cycles in the backward singly-linked list. */ - for (LinkedListElement* slow = sentinel.prev, - * fast1 = sentinel.prev->prev, - * fast2 = sentinel.prev->prev->prev; - slow != sentinel && fast1 != sentinel && fast2 != sentinel; - slow = slow->prev, - fast1 = fast2->prev, - fast2 = fast1->prev) { - - MOZ_ASSERT(slow != fast1); - MOZ_ASSERT(slow != fast2); - } - - /* - * Check that |sentinel| is the only node in the list with - * isSentinel == true. - */ - for (LinkedListElement* elem = sentinel.next; - elem != sentinel; - elem = elem->next) { - - MOZ_ASSERT(!elem->isSentinel); - } - - /* Check that the next/prev pointers match up. */ - LinkedListElement* prev = sentinel; - LinkedListElement* cur = sentinel.next; - do { - MOZ_ASSERT(cur->prev == prev); - MOZ_ASSERT(prev->next == cur); - - prev = cur; - cur = cur->next; - } while (cur != sentinel); -#endif /* ifdef DEBUG */ - } -}; - -} /* namespace mozilla */ - -#endif /* ifdef __cplusplus */ -#endif /* ifdef mozilla_LinkedList_h_ */ diff --git a/js/spidermonkey-win32/include/mozilla/MSStdInt.h b/js/spidermonkey-win32/include/mozilla/MSStdInt.h deleted file mode 100644 index 0447f2f11b..0000000000 --- a/js/spidermonkey-win32/include/mozilla/MSStdInt.h +++ /dev/null @@ -1,247 +0,0 @@ -// ISO C9x compliant stdint.h for Microsoft Visual Studio -// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 -// -// Copyright (c) 2006-2008 Alexander Chemeris -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. The name of the author may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED -// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -/////////////////////////////////////////////////////////////////////////////// - -#ifndef _MSC_VER // [ -#error "Use this header only with Microsoft Visual C++ compilers!" -#endif // _MSC_VER ] - -#ifndef _MSC_STDINT_H_ // [ -#define _MSC_STDINT_H_ - -#if _MSC_VER > 1000 -#pragma once -#endif - -#include - -// For Visual Studio 6 in C++ mode and for many Visual Studio versions when -// compiling for ARM we should wrap include with 'extern "C++" {}' -// or compiler give many errors like this: -// error C2733: second C linkage of overloaded function 'wmemchr' not allowed -#ifdef __cplusplus -extern "C" { -#endif -# include -#ifdef __cplusplus -} -#endif - -// Define _W64 macros to mark types changing their size, like intptr_t. -#ifndef _W64 -# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 -# define _W64 __w64 -# else -# define _W64 -# endif -#endif - - -// 7.18.1 Integer types - -// 7.18.1.1 Exact-width integer types - -// Visual Studio 6 and Embedded Visual C++ 4 doesn't -// realize that, e.g. char has the same size as __int8 -// so we give up on __intX for them. -#if (_MSC_VER < 1300) - typedef signed char int8_t; - typedef signed short int16_t; - typedef signed int int32_t; - typedef unsigned char uint8_t; - typedef unsigned short uint16_t; - typedef unsigned int uint32_t; -#else - typedef signed __int8 int8_t; - typedef signed __int16 int16_t; - typedef signed __int32 int32_t; - typedef unsigned __int8 uint8_t; - typedef unsigned __int16 uint16_t; - typedef unsigned __int32 uint32_t; -#endif -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; - - -// 7.18.1.2 Minimum-width integer types -typedef int8_t int_least8_t; -typedef int16_t int_least16_t; -typedef int32_t int_least32_t; -typedef int64_t int_least64_t; -typedef uint8_t uint_least8_t; -typedef uint16_t uint_least16_t; -typedef uint32_t uint_least32_t; -typedef uint64_t uint_least64_t; - -// 7.18.1.3 Fastest minimum-width integer types -typedef int8_t int_fast8_t; -typedef int32_t int_fast16_t; -typedef int32_t int_fast32_t; -typedef int64_t int_fast64_t; -typedef uint8_t uint_fast8_t; -typedef uint32_t uint_fast16_t; -typedef uint32_t uint_fast32_t; -typedef uint64_t uint_fast64_t; - -// 7.18.1.4 Integer types capable of holding object pointers -#ifdef _WIN64 // [ - typedef signed __int64 intptr_t; - typedef unsigned __int64 uintptr_t; -#else // _WIN64 ][ - typedef _W64 signed int intptr_t; - typedef _W64 unsigned int uintptr_t; -#endif // _WIN64 ] - -// 7.18.1.5 Greatest-width integer types -typedef int64_t intmax_t; -typedef uint64_t uintmax_t; - - -// 7.18.2 Limits of specified-width integer types - -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 - -// 7.18.2.1 Limits of exact-width integer types -#define INT8_MIN ((int8_t)_I8_MIN) -#define INT8_MAX _I8_MAX -#define INT16_MIN ((int16_t)_I16_MIN) -#define INT16_MAX _I16_MAX -#define INT32_MIN ((int32_t)_I32_MIN) -#define INT32_MAX _I32_MAX -#define INT64_MIN ((int64_t)_I64_MIN) -#define INT64_MAX _I64_MAX -#define UINT8_MAX _UI8_MAX -#define UINT16_MAX _UI16_MAX -#define UINT32_MAX _UI32_MAX -#define UINT64_MAX _UI64_MAX - -// 7.18.2.2 Limits of minimum-width integer types -#define INT_LEAST8_MIN INT8_MIN -#define INT_LEAST8_MAX INT8_MAX -#define INT_LEAST16_MIN INT16_MIN -#define INT_LEAST16_MAX INT16_MAX -#define INT_LEAST32_MIN INT32_MIN -#define INT_LEAST32_MAX INT32_MAX -#define INT_LEAST64_MIN INT64_MIN -#define INT_LEAST64_MAX INT64_MAX -#define UINT_LEAST8_MAX UINT8_MAX -#define UINT_LEAST16_MAX UINT16_MAX -#define UINT_LEAST32_MAX UINT32_MAX -#define UINT_LEAST64_MAX UINT64_MAX - -// 7.18.2.3 Limits of fastest minimum-width integer types -#define INT_FAST8_MIN INT8_MIN -#define INT_FAST8_MAX INT8_MAX -#define INT_FAST16_MIN INT16_MIN -#define INT_FAST16_MAX INT16_MAX -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST32_MAX INT32_MAX -#define INT_FAST64_MIN INT64_MIN -#define INT_FAST64_MAX INT64_MAX -#define UINT_FAST8_MAX UINT8_MAX -#define UINT_FAST16_MAX UINT16_MAX -#define UINT_FAST32_MAX UINT32_MAX -#define UINT_FAST64_MAX UINT64_MAX - -// 7.18.2.4 Limits of integer types capable of holding object pointers -#ifdef _WIN64 // [ -# define INTPTR_MIN INT64_MIN -# define INTPTR_MAX INT64_MAX -# define UINTPTR_MAX UINT64_MAX -#else // _WIN64 ][ -# define INTPTR_MIN INT32_MIN -# define INTPTR_MAX INT32_MAX -# define UINTPTR_MAX UINT32_MAX -#endif // _WIN64 ] - -// 7.18.2.5 Limits of greatest-width integer types -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX - -// 7.18.3 Limits of other integer types - -#ifdef _WIN64 // [ -# define PTRDIFF_MIN _I64_MIN -# define PTRDIFF_MAX _I64_MAX -#else // _WIN64 ][ -# define PTRDIFF_MIN _I32_MIN -# define PTRDIFF_MAX _I32_MAX -#endif // _WIN64 ] - -#define SIG_ATOMIC_MIN INT_MIN -#define SIG_ATOMIC_MAX INT_MAX - -#ifndef SIZE_MAX // [ -# ifdef _WIN64 // [ -# define SIZE_MAX _UI64_MAX -# else // _WIN64 ][ -# define SIZE_MAX _UI32_MAX -# endif // _WIN64 ] -#endif // SIZE_MAX ] - -// WCHAR_MIN and WCHAR_MAX are also defined in -#ifndef WCHAR_MIN // [ -# define WCHAR_MIN 0 -#endif // WCHAR_MIN ] -#ifndef WCHAR_MAX // [ -# define WCHAR_MAX _UI16_MAX -#endif // WCHAR_MAX ] - -#define WINT_MIN 0 -#define WINT_MAX _UI16_MAX - -#endif // __STDC_LIMIT_MACROS ] - - -// 7.18.4 Limits of other integer types - -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 - -// 7.18.4.1 Macros for minimum-width integer constants - -#define INT8_C(val) val##i8 -#define INT16_C(val) val##i16 -#define INT32_C(val) val##i32 -#define INT64_C(val) val##i64 - -#define UINT8_C(val) val##ui8 -#define UINT16_C(val) val##ui16 -#define UINT32_C(val) val##ui32 -#define UINT64_C(val) val##ui64 - -// 7.18.4.2 Macros for greatest-width integer constants -#define INTMAX_C INT64_C -#define UINTMAX_C UINT64_C - -#endif // __STDC_CONSTANT_MACROS ] - - -#endif // _MSC_STDINT_H_ ] diff --git a/js/spidermonkey-win32/include/mozilla/RangedPtr.h b/js/spidermonkey-win32/include/mozilla/RangedPtr.h deleted file mode 100644 index 74ad1c75e4..0000000000 --- a/js/spidermonkey-win32/include/mozilla/RangedPtr.h +++ /dev/null @@ -1,283 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sw=4 et tw=99 ft=cpp: - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Code. - * - * The Initial Developer of the Original Code is - * The Mozilla Foundation - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Jeff Walden (original author) - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Implements a smart pointer asserted to remain within a range specified at - * construction. - */ - -#ifndef mozilla_RangedPtr_h_ -#define mozilla_RangedPtr_h_ - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/Util.h" - -namespace mozilla { - -/* - * RangedPtr is a smart pointer restricted to an address range specified at - * creation. The pointer (and any smart pointers derived from it) must remain - * within the range [start, end] (inclusive of end to facilitate use as - * sentinels). Dereferencing or indexing into the pointer (or pointers derived - * from it) must remain within the range [start, end). All the standard pointer - * operators are defined on it; in debug builds these operations assert that the - * range specified at construction is respected. - * - * In theory passing a smart pointer instance as an argument can be slightly - * slower than passing a T* (due to ABI requirements for passing structs versus - * passing pointers), if the method being called isn't inlined. If you are in - * extremely performance-critical code, you may want to be careful using this - * smart pointer as an argument type. - * - * RangedPtr intentionally does not implicitly convert to T*. Use get() to - * explicitly convert to T*. Keep in mind that the raw pointer of course won't - * implement bounds checking in debug builds. - */ -template -class RangedPtr -{ - T* ptr; - -#ifdef DEBUG - T* const rangeStart; - T* const rangeEnd; -#endif - - void checkSanity() { - MOZ_ASSERT(rangeStart <= ptr); - MOZ_ASSERT(ptr <= rangeEnd); - } - - /* Creates a new pointer for |ptr|, restricted to this pointer's range. */ - RangedPtr create(T *ptr) const { -#ifdef DEBUG - return RangedPtr(ptr, rangeStart, rangeEnd); -#else - return RangedPtr(ptr, NULL, size_t(0)); -#endif - } - - public: - RangedPtr(T* p, T* start, T* end) - : ptr(p) -#ifdef DEBUG - , rangeStart(start), rangeEnd(end) -#endif - { - MOZ_ASSERT(rangeStart <= rangeEnd); - checkSanity(); - } - RangedPtr(T* p, T* start, size_t length) - : ptr(p) -#ifdef DEBUG - , rangeStart(start), rangeEnd(start + length) -#endif - { - MOZ_ASSERT(length <= size_t(-1) / sizeof(T)); - MOZ_ASSERT(uintptr_t(rangeStart) + length * sizeof(T) >= uintptr_t(rangeStart)); - checkSanity(); - } - - /* Equivalent to RangedPtr(p, p, length). */ - RangedPtr(T* p, size_t length) - : ptr(p) -#ifdef DEBUG - , rangeStart(p), rangeEnd(p + length) -#endif - { - MOZ_ASSERT(length <= size_t(-1) / sizeof(T)); - MOZ_ASSERT(uintptr_t(rangeStart) + length * sizeof(T) >= uintptr_t(rangeStart)); - checkSanity(); - } - - /* Equivalent to RangedPtr(arr, arr, N). */ - template - RangedPtr(T arr[N]) - : ptr(arr) -#ifdef DEBUG - , rangeStart(arr), rangeEnd(arr + N) -#endif - { - checkSanity(); - } - - T* get() const { - return ptr; - } - - /* - * You can only assign one RangedPtr into another if the two pointers have - * the same valid range: - * - * char arr1[] = "hi"; - * char arr2[] = "bye"; - * RangedPtr p1(arr1, 2); - * p1 = RangedPtr(arr1 + 1, arr1, arr1 + 2); // works - * p1 = RangedPtr(arr2, 3); // asserts - */ - RangedPtr& operator=(const RangedPtr& other) { - MOZ_ASSERT(rangeStart == other.rangeStart); - MOZ_ASSERT(rangeEnd == other.rangeEnd); - ptr = other.ptr; - checkSanity(); - return *this; - } - - RangedPtr operator+(size_t inc) { - MOZ_ASSERT(inc <= size_t(-1) / sizeof(T)); - MOZ_ASSERT(ptr + inc > ptr); - return create(ptr + inc); - } - - RangedPtr operator-(size_t dec) { - MOZ_ASSERT(dec <= size_t(-1) / sizeof(T)); - MOZ_ASSERT(ptr - dec < ptr); - return create(ptr - dec); - } - - /* - * You can assign a raw pointer into a RangedPtr if the raw pointer is - * within the range specified at creation. - */ - template - RangedPtr& operator=(U* p) { - *this = create(p); - return *this; - } - - template - RangedPtr& operator=(const RangedPtr& p) { - MOZ_ASSERT(rangeStart <= p.ptr); - MOZ_ASSERT(p.ptr <= rangeEnd); - ptr = p.ptr; - checkSanity(); - return *this; - } - - RangedPtr& operator++() { - return (*this += 1); - } - - RangedPtr operator++(int) { - RangedPtr rcp = *this; - ++*this; - return rcp; - } - - RangedPtr& operator--() { - return (*this -= 1); - } - - RangedPtr operator--(int) { - RangedPtr rcp = *this; - --*this; - return rcp; - } - - RangedPtr& operator+=(size_t inc) { - this->operator=(*this + inc); - return *this; - } - - RangedPtr& operator-=(size_t dec) { - this->operator=(*this - dec); - return *this; - } - - T& operator[](int index) const { - MOZ_ASSERT(size_t(index > 0 ? index : -index) <= size_t(-1) / sizeof(T)); - return *create(ptr + index); - } - - T& operator*() const { - return *ptr; - } - - template - bool operator==(const RangedPtr& other) const { - return ptr == other.ptr; - } - template - bool operator!=(const RangedPtr& other) const { - return !(*this == other); - } - - template - bool operator==(const U* u) const { - return ptr == u; - } - template - bool operator!=(const U* u) const { - return !(*this == u); - } - - template - bool operator<(const RangedPtr& other) const { - return ptr < other.ptr; - } - template - bool operator<=(const RangedPtr& other) const { - return ptr <= other.ptr; - } - - template - bool operator>(const RangedPtr& other) const { - return ptr > other.ptr; - } - template - bool operator>=(const RangedPtr& other) const { - return ptr >= other.ptr; - } - - size_t operator-(const RangedPtr& other) const { - MOZ_ASSERT(ptr >= other.ptr); - return PointerRangeSize(other.ptr, ptr); - } - - private: - RangedPtr() MOZ_DELETE; - T* operator&() MOZ_DELETE; - operator T*() const MOZ_DELETE; -}; - -} /* namespace mozilla */ - -#endif /* mozilla_RangedPtr_h_ */ diff --git a/js/spidermonkey-win32/include/mozilla/RefPtr.h b/js/spidermonkey-win32/include/mozilla/RefPtr.h deleted file mode 100644 index 8c3ff94f10..0000000000 --- a/js/spidermonkey-win32/include/mozilla/RefPtr.h +++ /dev/null @@ -1,443 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sw=4 et tw=99 ft=cpp: - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Code. - * - * The Initial Developer of the Original Code is - * The Mozilla Foundation - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Chris Jones - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* Helpers for defining and using refcounted objects. */ - -#ifndef mozilla_RefPtr_h_ -#define mozilla_RefPtr_h_ - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" - -namespace mozilla { - -template class RefCounted; -template class RefPtr; -template class TemporaryRef; -template class OutParamRef; -template OutParamRef byRef(RefPtr&); - -/** - * RefCounted is a sort of a "mixin" for a class T. RefCounted - * manages, well, refcounting for T, and because RefCounted is - * parameterized on T, RefCounted can call T's destructor directly. - * This means T doesn't need to have a virtual dtor and so doesn't - * need a vtable. - * - * RefCounted is created with refcount == 0. Newly-allocated - * RefCounted must immediately be assigned to a RefPtr to make the - * refcount > 0. It's an error to allocate and free a bare - * RefCounted, i.e. outside of the RefPtr machinery. Attempts to - * do so will abort DEBUG builds. - * - * Live RefCounted have refcount > 0. The lifetime (refcounts) of - * live RefCounted are controlled by RefPtr and - * RefPtr. Upon a transition from refcounted==1 - * to 0, the RefCounted "dies" and is destroyed. The "destroyed" - * state is represented in DEBUG builds by refcount==-0xdead. This - * state distinguishes use-before-ref (refcount==0) from - * use-after-destroy (refcount==-0xdead). - */ -template -class RefCounted -{ - friend class RefPtr; - -public: - RefCounted() : refCnt(0) { } - ~RefCounted() { MOZ_ASSERT(refCnt == -0xdead); } - - // Compatibility with nsRefPtr. - void AddRef() { - MOZ_ASSERT(refCnt >= 0); - ++refCnt; - } - - void Release() { - MOZ_ASSERT(refCnt > 0); - if (0 == --refCnt) { -#ifdef DEBUG - refCnt = -0xdead; -#endif - delete static_cast(this); - } - } - - // Compatibility with wtf::RefPtr. - void ref() { AddRef(); } - void deref() { Release(); } - int refCount() const { return refCnt; } - bool hasOneRef() const { - MOZ_ASSERT(refCnt > 0); - return refCnt == 1; - } - -private: - int refCnt; -}; - -/** - * RefPtr points to a refcounted thing that has AddRef and Release - * methods to increase/decrease the refcount, respectively. After a - * RefPtr is assigned a T*, the T* can be used through the RefPtr - * as if it were a T*. - * - * A RefPtr can forget its underlying T*, which results in the T* - * being wrapped in a temporary object until the T* is either - * re-adopted from or released by the temporary. - */ -template -class RefPtr -{ - // To allow them to use unref() - friend class TemporaryRef; - friend class OutParamRef; - - struct dontRef {}; - -public: - RefPtr() : ptr(0) { } - RefPtr(const RefPtr& o) : ptr(ref(o.ptr)) {} - RefPtr(const TemporaryRef& o) : ptr(o.drop()) {} - RefPtr(T* t) : ptr(ref(t)) {} - - template - RefPtr(const RefPtr& o) : ptr(ref(o.get())) {} - - ~RefPtr() { unref(ptr); } - - RefPtr& operator=(const RefPtr& o) { - assign(ref(o.ptr)); - return *this; - } - RefPtr& operator=(const TemporaryRef& o) { - assign(o.drop()); - return *this; - } - RefPtr& operator=(T* t) { - assign(ref(t)); - return *this; - } - - template - RefPtr& operator=(const RefPtr& o) { - assign(ref(o.get())); - return *this; - } - - TemporaryRef forget() { - T* tmp = ptr; - ptr = 0; - return TemporaryRef(tmp, dontRef()); - } - - T* get() const { return ptr; } - operator T*() const { return ptr; } - T* operator->() const { return ptr; } - T& operator*() const { return *ptr; } - template - operator TemporaryRef() { return TemporaryRef(ptr); } - -private: - void assign(T* t) { - unref(ptr); - ptr = t; - } - - T* ptr; - - static MOZ_ALWAYS_INLINE T* ref(T* t) { - if (t) { - t->AddRef(); - } - return t; - } - - static MOZ_ALWAYS_INLINE void unref(T* t) { - if (t) { - t->Release(); - } - } -}; - -/** - * TemporaryRef represents an object that holds a temporary - * reference to a T. TemporaryRef objects can't be manually ref'd or - * unref'd (being temporaries, not lvalues), so can only relinquish - * references to other objects, or unref on destruction. - */ -template -class TemporaryRef -{ - // To allow it to construct TemporaryRef from a bare T* - friend class RefPtr; - - typedef typename RefPtr::dontRef dontRef; - -public: - TemporaryRef(T* t) : ptr(RefPtr::ref(t)) {} - TemporaryRef(const TemporaryRef& o) : ptr(o.drop()) {} - - template - TemporaryRef(const TemporaryRef& o) : ptr(o.drop()) {} - - ~TemporaryRef() { RefPtr::unref(ptr); } - - T* drop() const { - T* tmp = ptr; - ptr = 0; - return tmp; - } - -private: - TemporaryRef(T* t, const dontRef&) : ptr(t) {} - - mutable T* ptr; - - TemporaryRef(); - TemporaryRef& operator=(const TemporaryRef&); -}; - -/** - * OutParamRef is a wrapper that tracks a refcounted pointer passed as - * an outparam argument to a function. OutParamRef implements COM T** - * outparam semantics: this requires the callee to AddRef() the T* - * returned through the T** outparam on behalf of the caller. This - * means the caller (through OutParamRef) must Release() the old - * object contained in the tracked RefPtr. It's OK if the callee - * returns the same T* passed to it through the T** outparam, as long - * as the callee obeys the COM discipline. - * - * Prefer returning TemporaryRef from functions over creating T** - * outparams and passing OutParamRef to T**. Prefer RefPtr* - * outparams over T** outparams. - */ -template -class OutParamRef -{ - friend OutParamRef byRef(RefPtr&); - -public: - ~OutParamRef() { - RefPtr::unref(refPtr.ptr); - refPtr.ptr = tmp; - } - - operator T**() { return &tmp; } - -private: - OutParamRef(RefPtr& p) : refPtr(p), tmp(p.get()) {} - - RefPtr& refPtr; - T* tmp; - - OutParamRef() MOZ_DELETE; - OutParamRef& operator=(const OutParamRef&) MOZ_DELETE; -}; - -/** - * byRef cooperates with OutParamRef to implement COM outparam semantics. - */ -template -OutParamRef -byRef(RefPtr& ptr) -{ - return OutParamRef(ptr); -} - -} // namespace mozilla - -#endif // mozilla_RefPtr_h_ - - -#if 0 - -// Command line that builds these tests -// -// cp RefPtr.h test.cc && g++ -g -Wall -pedantic -DDEBUG -o test test.cc && ./test - -using namespace mozilla; - -struct Foo : public RefCounted -{ - Foo() : dead(false) { } - ~Foo() { - MOZ_ASSERT(!dead); - dead = true; - numDestroyed++; - } - - bool dead; - static int numDestroyed; -}; -int Foo::numDestroyed; - -struct Bar : public Foo { }; - -TemporaryRef -NewFoo() -{ - return RefPtr(new Foo()); -} - -TemporaryRef -NewBar() -{ - return new Bar(); -} - -void -GetNewFoo(Foo** f) -{ - *f = new Bar(); - // Kids, don't try this at home - (*f)->AddRef(); -} - -void -GetPassedFoo(Foo** f) -{ - // Kids, don't try this at home - (*f)->AddRef(); -} - -void -GetNewFoo(RefPtr* f) -{ - *f = new Bar(); -} - -void -GetPassedFoo(RefPtr* f) -{} - -TemporaryRef -GetNullFoo() -{ - return 0; -} - -int -main(int argc, char** argv) -{ - // This should blow up -// Foo* f = new Foo(); delete f; - - MOZ_ASSERT(0 == Foo::numDestroyed); - { - RefPtr f = new Foo(); - MOZ_ASSERT(f->refCount() == 1); - } - MOZ_ASSERT(1 == Foo::numDestroyed); - - { - RefPtr f1 = NewFoo(); - RefPtr f2(NewFoo()); - MOZ_ASSERT(1 == Foo::numDestroyed); - } - MOZ_ASSERT(3 == Foo::numDestroyed); - - { - RefPtr b = NewBar(); - MOZ_ASSERT(3 == Foo::numDestroyed); - } - MOZ_ASSERT(4 == Foo::numDestroyed); - - { - RefPtr f1; - { - f1 = new Foo(); - RefPtr f2(f1); - RefPtr f3 = f2; - MOZ_ASSERT(4 == Foo::numDestroyed); - } - MOZ_ASSERT(4 == Foo::numDestroyed); - } - MOZ_ASSERT(5 == Foo::numDestroyed); - - { - RefPtr f = new Foo(); - f.forget(); - MOZ_ASSERT(6 == Foo::numDestroyed); - } - - { - RefPtr f = new Foo(); - GetNewFoo(byRef(f)); - MOZ_ASSERT(7 == Foo::numDestroyed); - } - MOZ_ASSERT(8 == Foo::numDestroyed); - - { - RefPtr f = new Foo(); - GetPassedFoo(byRef(f)); - MOZ_ASSERT(8 == Foo::numDestroyed); - } - MOZ_ASSERT(9 == Foo::numDestroyed); - - { - RefPtr f = new Foo(); - GetNewFoo(&f); - MOZ_ASSERT(10 == Foo::numDestroyed); - } - MOZ_ASSERT(11 == Foo::numDestroyed); - - { - RefPtr f = new Foo(); - GetPassedFoo(&f); - MOZ_ASSERT(11 == Foo::numDestroyed); - } - MOZ_ASSERT(12 == Foo::numDestroyed); - - { - RefPtr f1 = new Bar(); - } - MOZ_ASSERT(13 == Foo::numDestroyed); - - { - RefPtr f = GetNullFoo(); - MOZ_ASSERT(13 == Foo::numDestroyed); - } - MOZ_ASSERT(13 == Foo::numDestroyed); - - return 0; -} - -#endif diff --git a/js/spidermonkey-win32/include/mozilla/StandardInteger.h b/js/spidermonkey-win32/include/mozilla/StandardInteger.h deleted file mode 100644 index 344750a794..0000000000 --- a/js/spidermonkey-win32/include/mozilla/StandardInteger.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sw=4 et tw=99 ft=cpp: - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Code. - * - * The Initial Developer of the Original Code is - * The Mozilla Foundation - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Jeff Walden (original author) - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* Implements the C99 interface for C and C++ code. */ - -#ifndef mozilla_StandardInteger_h_ -#define mozilla_StandardInteger_h_ - -/* - * The C99 standard header exposes typedefs for common fixed-width - * integer types. It would be feasible to simply #include , but - * MSVC++ versions prior to 2010 don't provide . We could solve this - * by reimplementing for MSVC++ 2008 and earlier. But then we reach - * a second problem: our custom might conflict with a - * defined by an embedder already looking to work around the MSVC++ - * absence. - * - * We address these issues in this manner: - * - * 1. If the preprocessor macro MOZ_CUSTOM_STDINT_H is defined to a path to a - * custom implementation, we will #include it. Embedders using - * a custom must define this macro to an implementation that - * will work with their embedding. - * 2. Otherwise, if we are compiling with a an MSVC++ version without - * , #include our custom reimplementation. - * 3. Otherwise, #include the standard provided by the compiler. - * - * Note that we can't call this file "stdint.h" or something case-insensitively - * equal to "stdint.h" because then MSVC (and other compilers on - * case-insensitive file systems) will include this file, rather than the system - * stdint.h, when we ask for below. - */ -#if defined(MOZ_CUSTOM_STDINT_H) -# include MOZ_CUSTOM_STDINT_H -#elif defined(_MSC_VER) && _MSC_VER < 1600 -# include "mozilla/MSStdInt.h" -#else -# include -#endif - -#endif /* mozilla_StandardInteger_h_ */ diff --git a/js/spidermonkey-win32/include/mozilla/Types.h b/js/spidermonkey-win32/include/mozilla/Types.h deleted file mode 100644 index 6899719463..0000000000 --- a/js/spidermonkey-win32/include/mozilla/Types.h +++ /dev/null @@ -1,170 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sw=4 et tw=99 ft=cpp: - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Code. - * - * The Initial Developer of the Original Code is - * The Mozilla Foundation - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* mfbt foundational types and macros. */ - -#ifndef mozilla_Types_h_ -#define mozilla_Types_h_ - -/* - * This header must be valid C and C++, includable by code embedding either - * SpiderMonkey or Gecko. - */ - -/* - * Expose all the integer types defined in C99's (and the integer - * limit and constant macros, if compiling C code or if compiling C++ code and - * the right __STDC_*_MACRO has been defined for each). These are all usable - * throughout mfbt code, and throughout Mozilla code more generally. - */ -#include "mozilla/StandardInteger.h" - -/* Also expose size_t. */ -#include - -/* Implement compiler and linker macros needed for APIs. */ - -/* - * MOZ_EXPORT_API is used to declare and define a method which is externally - * visible to users of the current library. It encapsulates various decorations - * needed to properly export the method's symbol. MOZ_EXPORT_DATA serves the - * same purpose for data. - * - * api.h: - * extern MOZ_EXPORT_API(int) MeaningOfLife(void); - * extern MOZ_EXPORT_DATA(int) LuggageCombination; - * - * api.c: - * MOZ_EXPORT_API(int) MeaningOfLife(void) { return 42; } - * MOZ_EXPORT_DATA(int) LuggageCombination = 12345; - * - * If you are merely sharing a method across files, just use plain |extern|. - * These macros are designed for use by library interfaces -- not for normal - * methods or data used cross-file. - */ -#if defined(WIN32) || defined(XP_OS2) -# define MOZ_EXPORT_API(type) __declspec(dllexport) type -# define MOZ_EXPORT_DATA(type) __declspec(dllexport) type -#else /* Unix */ -# ifdef HAVE_VISIBILITY_ATTRIBUTE -# define MOZ_EXTERNAL_VIS __attribute__((visibility("default"))) -# elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) -# define MOZ_EXTERNAL_VIS __global -# else -# define MOZ_EXTERNAL_VIS -# endif -# define MOZ_EXPORT_API(type) MOZ_EXTERNAL_VIS type -# define MOZ_EXPORT_DATA(type) MOZ_EXTERNAL_VIS type -#endif - -/* - * Whereas implementers use MOZ_EXPORT_API and MOZ_EXPORT_DATA to declare and - * define library symbols, users use MOZ_IMPORT_API and MOZ_IMPORT_DATA to - * access them. Most often the implementer of the library will expose an API - * macro which expands to either the export or import version of the macro, - * depending upon the compilation mode. - */ -#ifdef _WIN32 -# if defined(__MWERKS__) -# define MOZ_IMPORT_API(x) x -# else -# define MOZ_IMPORT_API(x) __declspec(dllimport) x -# endif -#elif defined(XP_OS2) -# define MOZ_IMPORT_API(x) __declspec(dllimport) x -#else -# define MOZ_IMPORT_API(x) MOZ_EXPORT_API(x) -#endif - -#if defined(_WIN32) && !defined(__MWERKS__) -# define MOZ_IMPORT_DATA(x) __declspec(dllimport) x -#elif defined(XP_OS2) -# define MOZ_IMPORT_DATA(x) __declspec(dllimport) x -#else -# define MOZ_IMPORT_DATA(x) MOZ_EXPORT_DATA(x) -#endif - -/* - * Consistent with the above comment, the MFBT_API and MFBT_DATA macros expose - * export mfbt declarations when building mfbt, and they expose import mfbt - * declarations when using mfbt. - */ -#if defined(IMPL_MFBT) -# define MFBT_API(type) MOZ_EXPORT_API(type) -# define MFBT_DATA(type) MOZ_EXPORT_DATA(type) -#else - /* - * When mozglue is linked in the program, we need the MFBT API symbols - * to be weak. - */ -# if defined(MOZ_GLUE_IN_PROGRAM) -# define MFBT_API(type) __attribute__((weak)) MOZ_IMPORT_API(type) -# define MFBT_DATA(type) __attribute__((weak)) MOZ_IMPORT_DATA(type) -# else -# define MFBT_API(type) MOZ_IMPORT_API(type) -# define MFBT_DATA(type) MOZ_IMPORT_DATA(type) -# endif -#endif - -/* - * C symbols in C++ code must be declared immediately within |extern "C"| - * blocks. However, in C code, they need not be declared specially. This - * difference is abstracted behind the MOZ_BEGIN_EXTERN_C and MOZ_END_EXTERN_C - * macros, so that the user need not know whether he is being used in C or C++ - * code. - * - * MOZ_BEGIN_EXTERN_C - * - * extern MOZ_EXPORT_API(int) MostRandomNumber(void); - * ...other declarations... - * - * MOZ_END_EXTERN_C - * - * This said, it is preferable to just use |extern "C"| in C++ header files for - * its greater clarity. - */ -#ifdef __cplusplus -# define MOZ_BEGIN_EXTERN_C extern "C" { -# define MOZ_END_EXTERN_C } -#else -# define MOZ_BEGIN_EXTERN_C -# define MOZ_END_EXTERN_C -#endif - -#endif /* mozilla_Types_h_ */ diff --git a/js/spidermonkey-win32/include/mozilla/Util.h b/js/spidermonkey-win32/include/mozilla/Util.h deleted file mode 100644 index edbe10d01b..0000000000 --- a/js/spidermonkey-win32/include/mozilla/Util.h +++ /dev/null @@ -1,364 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sw=4 et tw=99 ft=cpp: - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at: - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Code. - * - * The Initial Developer of the Original Code is - * The Mozilla Foundation - * Portions created by the Initial Developer are Copyright (C) 2011 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * Miscellaneous uncategorized functionality. Please add new functionality to - * new headers, or to other appropriate existing headers, not here. - */ - -#ifndef mozilla_Util_h_ -#define mozilla_Util_h_ - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/Types.h" - -#ifdef __cplusplus - -namespace mozilla { - -/** - * DebugOnly contains a value of type T, but only in debug builds. In - * release builds, it does not contain a value. This helper is - * intended to be used along with ASSERT()-style macros, allowing one - * to write - * - * DebugOnly check = Func(); - * ASSERT(check); - * - * more concisely than declaring |check| conditional on #ifdef DEBUG, - * but also without allocating storage space for |check| in release - * builds. - * - * DebugOnly instances can only be coerced to T in debug builds; in - * release builds, they don't have a value so type coercion is not - * well defined. - */ -template -struct DebugOnly -{ -#ifdef DEBUG - T value; - - DebugOnly() {} - DebugOnly(const T& other) : value(other) {} - DebugOnly(const DebugOnly& other) : value(other.value) {} - DebugOnly& operator=(const T& rhs) { - value = rhs; - return *this; - } - void operator++(int) { - value++; - } - void operator--(int) { - value--; - } - - operator T&() { return value; } - operator const T&() const { return value; } - - T& operator->() { return value; } - -#else - DebugOnly() {} - DebugOnly(const T&) {} - DebugOnly(const DebugOnly&) {} - DebugOnly& operator=(const T&) { return *this; } - void operator++(int) {} - void operator--(int) {} -#endif - - /* - * DebugOnly must always have a destructor or else it will - * generate "unused variable" warnings, exactly what it's intended - * to avoid! - */ - ~DebugOnly() {} -}; - -/* - * This class, and the corresponding macro MOZ_ALIGNOF, figure out how many - * bytes of alignment a given type needs. - */ -template -struct AlignmentFinder -{ -private: - struct Aligner - { - char c; - T t; - }; - -public: - static const int alignment = sizeof(Aligner) - sizeof(T); -}; - -#define MOZ_ALIGNOF(T) mozilla::AlignmentFinder::alignment - -/* - * Declare the MOZ_ALIGNED_DECL macro for declaring aligned types. - * - * For instance, - * - * MOZ_ALIGNED_DECL(char arr[2], 8); - * - * will declare a two-character array |arr| aligned to 8 bytes. - */ - -#if defined(__GNUC__) -# define MOZ_ALIGNED_DECL(_type, _align) \ - _type __attribute__((aligned(_align))) -#elif defined(_MSC_VER) -# define MOZ_ALIGNED_DECL(_type, _align) \ - __declspec(align(_align)) _type -#else -# warning "We don't know how to align variables on this compiler." -# define MOZ_ALIGNED_DECL(_type, _align) _type -#endif - -/* - * AlignedElem is a structure whose alignment is guaranteed to be at least N bytes. - * - * We support 1, 2, 4, 8, and 16-bit alignment. - */ -template -struct AlignedElem; - -/* - * We have to specialize this template because GCC doesn't like __attribute__((aligned(foo))) where - * foo is a template parameter. - */ - -template<> -struct AlignedElem<1> -{ - MOZ_ALIGNED_DECL(uint8_t elem, 1); -}; - -template<> -struct AlignedElem<2> -{ - MOZ_ALIGNED_DECL(uint8_t elem, 2); -}; - -template<> -struct AlignedElem<4> -{ - MOZ_ALIGNED_DECL(uint8_t elem, 4); -}; - -template<> -struct AlignedElem<8> -{ - MOZ_ALIGNED_DECL(uint8_t elem, 8); -}; - -template<> -struct AlignedElem<16> -{ - MOZ_ALIGNED_DECL(uint8_t elem, 16); -}; - -/* - * This utility pales in comparison to Boost's aligned_storage. The utility - * simply assumes that uint64_t is enough alignment for anyone. This may need - * to be extended one day... - * - * As an important side effect, pulling the storage into this template is - * enough obfuscation to confuse gcc's strict-aliasing analysis into not giving - * false negatives when we cast from the char buffer to whatever type we've - * constructed using the bytes. - */ -template -struct AlignedStorage -{ - union U { - char bytes[nbytes]; - uint64_t _; - } u; - - const void *addr() const { return u.bytes; } - void *addr() { return u.bytes; } -}; - -template -struct AlignedStorage2 -{ - union U { - char bytes[sizeof(T)]; - uint64_t _; - } u; - - const T *addr() const { return (const T *)u.bytes; } - T *addr() { return (T *)(void *)u.bytes; } -}; - -/* - * Small utility for lazily constructing objects without using dynamic storage. - * When a Maybe is constructed, it is |empty()|, i.e., no value of T has - * been constructed and no T destructor will be called when the Maybe is - * destroyed. Upon calling |construct|, a T object will be constructed with the - * given arguments and that object will be destroyed when the owning Maybe - * is destroyed. - * - * N.B. GCC seems to miss some optimizations with Maybe and may generate extra - * branches/loads/stores. Use with caution on hot paths. - */ -template -class Maybe -{ - AlignedStorage2 storage; - bool constructed; - - T &asT() { return *storage.addr(); } - - explicit Maybe(const Maybe &other); - const Maybe &operator=(const Maybe &other); - - public: - Maybe() { constructed = false; } - ~Maybe() { if (constructed) asT().~T(); } - - bool empty() const { return !constructed; } - - void construct() { - MOZ_ASSERT(!constructed); - new(storage.addr()) T(); - constructed = true; - } - - template - void construct(const T1 &t1) { - MOZ_ASSERT(!constructed); - new(storage.addr()) T(t1); - constructed = true; - } - - template - void construct(const T1 &t1, const T2 &t2) { - MOZ_ASSERT(!constructed); - new(storage.addr()) T(t1, t2); - constructed = true; - } - - template - void construct(const T1 &t1, const T2 &t2, const T3 &t3) { - MOZ_ASSERT(!constructed); - new(storage.addr()) T(t1, t2, t3); - constructed = true; - } - - template - void construct(const T1 &t1, const T2 &t2, const T3 &t3, const T4 &t4) { - MOZ_ASSERT(!constructed); - new(storage.addr()) T(t1, t2, t3, t4); - constructed = true; - } - - T *addr() { - MOZ_ASSERT(constructed); - return &asT(); - } - - T &ref() { - MOZ_ASSERT(constructed); - return asT(); - } - - const T &ref() const { - MOZ_ASSERT(constructed); - return const_cast(this)->asT(); - } - - void destroy() { - ref().~T(); - constructed = false; - } - - void destroyIfConstructed() { - if (!empty()) - destroy(); - } -}; - -/* - * Safely subtract two pointers when it is known that end >= begin. This avoids - * the common compiler bug that if (size_t(end) - size_t(begin)) has the MSB - * set, the unsigned subtraction followed by right shift will produce -1, or - * size_t(-1), instead of the real difference. - */ -template -MOZ_ALWAYS_INLINE size_t -PointerRangeSize(T* begin, T* end) -{ - MOZ_ASSERT(end >= begin); - return (size_t(end) - size_t(begin)) / sizeof(T); -} - -/* - * Compute the length of an array with constant length. (Use of this method - * with a non-array pointer will not compile.) - * - * Beware of the implicit trailing '\0' when using this with string constants. - */ -template -size_t -ArrayLength(T (&arr)[N]) -{ - return N; -} - -/* - * Compute the address one past the last element of a constant-length array. - * - * Beware of the implicit trailing '\0' when using this with string constants. - */ -template -T* -ArrayEnd(T (&arr)[N]) -{ - return arr + ArrayLength(arr); -} - -} /* namespace mozilla */ - -#endif /* __cplusplus */ - -#endif /* mozilla_Util_h_ */ diff --git a/js/spidermonkey-win32/lib/js.dll.REMOVED.git-id b/js/spidermonkey-win32/lib/js.dll.REMOVED.git-id index c50fe370be..b2fd83ab4b 100644 --- a/js/spidermonkey-win32/lib/js.dll.REMOVED.git-id +++ b/js/spidermonkey-win32/lib/js.dll.REMOVED.git-id @@ -1 +1 @@ -c18e2695d8dd3c9f5a1da87fa9602a838e103f22 \ No newline at end of file +23b6d1cc9b79e8890ecdb5843796b10e55db6e8d \ No newline at end of file diff --git a/js/spidermonkey-win32/lib/js.lib.REMOVED.git-id b/js/spidermonkey-win32/lib/js.lib.REMOVED.git-id index 4657f7686a..4058a16215 100644 --- a/js/spidermonkey-win32/lib/js.lib.REMOVED.git-id +++ b/js/spidermonkey-win32/lib/js.lib.REMOVED.git-id @@ -1 +1 @@ -e317a2df3ab37637d29fe07618409961a9798c24 \ No newline at end of file +a407df409ccdefc38d313c212faffd512787940f \ No newline at end of file diff --git a/testjs/proj.win32/testjs.win32.vcproj b/testjs/proj.win32/testjs.win32.vcproj index 3bd1d5c5cc..d21bc35262 100644 --- a/testjs/proj.win32/testjs.win32.vcproj +++ b/testjs/proj.win32/testjs.win32.vcproj @@ -4,6 +4,7 @@ Version="9.00" Name="testjs" ProjectGUID="{D0F06A44-A245-4D13-A498-0120C203B539}" + RootNamespace="testjs" TargetFrameworkVersion="196613" > @@ -49,7 +50,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=".;..\Classes;"..\..\js\spidermonkey-win32\include";..\..\js\JSBindings;..\..\js\BindingsExample;..\..\cocos2dx;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include" - PreprocessorDefinitions="WIN32;_WINDOWS;STRICT;_DEBUG;COCOS2D_DEBUG=1;" + PreprocessorDefinitions="WIN32;_WINDOWS;STRICT;_DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -74,7 +75,7 @@ Date: Wed, 27 Jun 2012 00:10:27 +0800 Subject: [PATCH 249/257] Updated testjs project setting. --- testjs/proj.win32/testjs.win32.vcproj | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/testjs/proj.win32/testjs.win32.vcproj b/testjs/proj.win32/testjs.win32.vcproj index d21bc35262..0dc97321d7 100644 --- a/testjs/proj.win32/testjs.win32.vcproj +++ b/testjs/proj.win32/testjs.win32.vcproj @@ -50,14 +50,14 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories=".;..\Classes;"..\..\js\spidermonkey-win32\include";..\..\js\JSBindings;..\..\js\BindingsExample;..\..\cocos2dx;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include" - PreprocessorDefinitions="WIN32;_WINDOWS;STRICT;_DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1" + PreprocessorDefinitions="WIN32;_WINDOWS;STRICT;_DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" UsePrecompiledHeader="0" WarningLevel="3" DebugInformationFormat="4" - DisableSpecificWarnings="4251;4800;4244;4390;4065;4996" + DisableSpecificWarnings="4267;4251;4244" /> Date: Wed, 27 Jun 2012 14:21:29 +0800 Subject: [PATCH 250/257] fixed #1367: Refactor "createWith***" to "create". --- HelloLua/Resources/hello.lua | 9 +- cocos2dx/CCDrawingPrimitives.cpp | 100 +++++++++--------- cocos2dx/actions/CCActionInterval.cpp | 2 +- cocos2dx/cocoa/CCArray.cpp | 6 +- cocos2dx/cocoa/CCArray.h | 2 +- cocos2dx/cocoa/CCDictionary.cpp | 8 +- cocos2dx/cocoa/CCDictionary.h | 4 +- cocos2dx/cocoa/CCString.cpp | 8 +- cocos2dx/cocoa/CCString.h | 2 +- cocos2dx/extensions/CCBReader/CCBReader.cpp | 2 +- .../CCControlExtension/CCScale9Sprite.cpp | 22 ++-- .../CCTextureWatcher/CCTextureWatcher.cpp | 2 +- cocos2dx/label_nodes/CCLabelAtlas.cpp | 2 +- cocos2dx/label_nodes/CCLabelBMFont.cpp | 2 +- .../CCLayer.cpp | 15 +-- .../layers_scenes_transitions_nodes/CCLayer.h | 1 - cocos2dx/menu_nodes/CCMenu.h | 2 +- cocos2dx/menu_nodes/CCMenuItem.cpp | 6 +- cocos2dx/misc_nodes/CCRenderTexture.cpp | 2 +- .../particle_nodes/CCParticleBatchNode.cpp | 4 +- cocos2dx/particle_nodes/CCParticleBatchNode.h | 2 +- cocos2dx/sprite_nodes/CCAnimation.cpp | 8 +- cocos2dx/sprite_nodes/CCAnimation.h | 4 +- cocos2dx/sprite_nodes/CCAnimationCache.cpp | 4 +- cocos2dx/sprite_nodes/CCSprite.cpp | 14 +-- cocos2dx/sprite_nodes/CCSprite.h | 24 ++--- cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp | 4 +- cocos2dx/sprite_nodes/CCSpriteBatchNode.h | 2 +- cocos2dx/sprite_nodes/CCSpriteFrame.cpp | 8 +- cocos2dx/sprite_nodes/CCSpriteFrame.h | 4 +- cocos2dx/textures/CCTextureAtlas.cpp | 11 +- cocos2dx/textures/CCTextureAtlas.h | 22 +++- .../tileMap_parallax_nodes/CCTMXLayer.cpp | 2 +- .../LuaCocos2d.cpp.REMOVED.git-id | 2 +- .../Templates/1033/Resources/hello.lua | 9 +- .../Resources/hello.lua | 9 +- tests/tests/LabelTest/LabelTest.cpp | 4 +- tests/tests/ParticleTest/ParticleTest.cpp | 8 +- .../PerformanceNodeChildrenTest.cpp | 10 +- .../PerformanceTest/PerformanceSpriteTest.cpp | 6 +- .../RenderTextureTest/RenderTextureTest.cpp | 4 +- tests/tests/ShaderTest/ShaderTest.cpp | 4 +- .../SpriteTest/SpriteTest.cpp.REMOVED.git-id | 2 +- tests/tests/Texture2dTest/Texture2dTest.cpp | 6 +- tests/tests/TileMapTest/TileMapTest.cpp | 2 +- tests/tests/ZwoptexTest/ZwoptexTest.cpp | 4 +- tools/tolua++/CCAnimation.pkg | 6 +- tools/tolua++/CCArray.pkg | 6 +- tools/tolua++/CCDictionary.pkg | 4 +- tools/tolua++/CCLayer.pkg | 2 +- tools/tolua++/CCParticleBatchNode.pkg | 23 ++++ tools/tolua++/CCSprite.pkg | 10 +- tools/tolua++/CCSpriteBatchNode.pkg | 4 +- tools/tolua++/CCSpriteFrame.pkg | 4 +- tools/tolua++/CCString.pkg | 2 +- tools/tolua++/CCTextureAtlas.pkg | 4 +- tools/tolua++/Cocos2d.pkg | 1 + tools/tolua++/basic.lua | 2 +- 58 files changed, 238 insertions(+), 210 deletions(-) create mode 100644 tools/tolua++/CCParticleBatchNode.pkg diff --git a/HelloLua/Resources/hello.lua b/HelloLua/Resources/hello.lua index 0f99068474..33efc36f37 100644 --- a/HelloLua/Resources/hello.lua +++ b/HelloLua/Resources/hello.lua @@ -26,7 +26,7 @@ local function creatDog() rect = CCRectMake(frameWidth, 0, frameWidth, frameHeight) local frame1 = CCSpriteFrame:create(textureDog, rect) - local spriteDog = CCSprite:createWithSpriteFrame(frame0) + local spriteDog = CCSprite:create(frame0) spriteDog.isPaused = false spriteDog:setPosition(0, winSize.height / 4 * 3) @@ -35,7 +35,7 @@ local function creatDog() animFrames:addObject(frame0) animFrames:addObject(frame1) - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.5) + local animation = CCAnimation:create(animFrames, 0.5) local animate = CCAnimate:create(animation); spriteDog:runAction(CCRepeatForever:create(animate)) @@ -76,11 +76,10 @@ local function createLayerFram() end -- add crop - local textureCrop = CCTextureCache:sharedTextureCache():addImage("crop.png") - local frameCrop = CCSpriteFrame:create(textureCrop, CCRectMake(0, 0, 105, 95)) + local frameCrop = CCSpriteFrame:create("crop.png", CCRectMake(0, 0, 105, 95)) for i = 0, 3 do for j = 0, 1 do - local spriteCrop = CCSprite:createWithSpriteFrame(frameCrop); + local spriteCrop = CCSprite:create(frameCrop); spriteCrop:setPosition(10 + 200 + j * 180 - i % 2 * 90, 30 + 10 + i * 95 / 2) layerFarm:addChild(spriteCrop) end diff --git a/cocos2dx/CCDrawingPrimitives.cpp b/cocos2dx/CCDrawingPrimitives.cpp index 8299202943..e2dfd6297e 100644 --- a/cocos2dx/CCDrawingPrimitives.cpp +++ b/cocos2dx/CCDrawingPrimitives.cpp @@ -42,35 +42,35 @@ NS_CC_BEGIN #define M_PI 3.14159265358979323846 #endif -static bool initialized = false; -static CCGLProgram *shader_ = NULL; -static int colorLocation_ = -1; -static ccColor4F color_ = {1,1,1,1}; -static int pointSizeLocation_ = -1; -static GLfloat pointSize_ = 1; +static bool s_bInitialized = false; +static CCGLProgram* s_pShader = NULL; +static int s_nColorLocation = -1; +static ccColor4F s_tColor = {1.0f,1.0f,1.0f,1.0f}; +static int s_nPointSizeLocation = -1; +static GLfloat s_fPointSize = 1.0f; static void lazy_init( void ) { - if( ! initialized ) { + if( ! s_bInitialized ) { // // Position and 1 color passed as a uniform (to similate glColor4ub ) // - shader_ = CCShaderCache::sharedShaderCache()->programForKey(kCCShader_Position_uColor); + s_pShader = CCShaderCache::sharedShaderCache()->programForKey(kCCShader_Position_uColor); - colorLocation_ = glGetUniformLocation( shader_->getProgram(), "u_color"); + s_nColorLocation = glGetUniformLocation( s_pShader->getProgram(), "u_color"); CHECK_GL_ERROR_DEBUG(); - pointSizeLocation_ = glGetUniformLocation( shader_->getProgram(), "u_pointSize"); + s_nPointSizeLocation = glGetUniformLocation( s_pShader->getProgram(), "u_pointSize"); CHECK_GL_ERROR_DEBUG(); - initialized = true; + s_bInitialized = true; } } // When back to foreground on android, we want to it to inilialize again void ccDrawInit() { - initialized = false; + s_bInitialized = false; } void ccDrawPoint( const CCPoint& point ) @@ -82,11 +82,11 @@ void ccDrawPoint( const CCPoint& point ) p.y = point.y; ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); - shader_->use(); - shader_->setUniformForModelViewProjectionMatrix(); + s_pShader->use(); + s_pShader->setUniformForModelViewProjectionMatrix(); - shader_->setUniformLocationWith4fv(colorLocation_, (GLfloat*) &color_.r, 1); - shader_->setUniformLocationWith1f(pointSizeLocation_, pointSize_); + s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1); + s_pShader->setUniformLocationWith1f(s_nPointSizeLocation, s_fPointSize); glVertexAttribPointer(kCCVertexAttrib_Position, 2, GL_FLOAT, GL_FALSE, 0, &p); @@ -100,10 +100,10 @@ void ccDrawPoints( const CCPoint *points, unsigned int numberOfPoints ) lazy_init(); ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); - shader_->use(); - shader_->setUniformForModelViewProjectionMatrix(); - shader_->setUniformLocationWith4fv(colorLocation_, (GLfloat*) &color_.r, 1); - shader_->setUniformLocationWith1f(pointSizeLocation_, pointSize_); + s_pShader->use(); + s_pShader->setUniformForModelViewProjectionMatrix(); + s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1); + s_pShader->setUniformLocationWith1f(s_nPointSizeLocation, s_fPointSize); // XXX: Mac OpenGL error. arrays can't go out of scope before draw is executed ccVertex2F* newPoints = new ccVertex2F[numberOfPoints]; @@ -140,11 +140,11 @@ void ccDrawLine( const CCPoint& origin, const CCPoint& destination ) {destination.x, destination.y} }; - shader_->use(); + s_pShader->use(); CHECK_GL_ERROR_DEBUG(); - shader_->setUniformForModelViewProjectionMatrix(); + s_pShader->setUniformForModelViewProjectionMatrix(); CHECK_GL_ERROR_DEBUG(); - shader_->setUniformLocationWith4fv(colorLocation_, (GLfloat*) &color_.r, 1); + s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1); CHECK_GL_ERROR_DEBUG(); ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); @@ -180,9 +180,9 @@ void ccDrawPoly( const CCPoint *poli, unsigned int numberOfPoints, bool closePol { lazy_init(); - shader_->use(); - shader_->setUniformForModelViewProjectionMatrix(); - shader_->setUniformLocationWith4fv(colorLocation_, (GLfloat*) &color_.r, 1); + s_pShader->use(); + s_pShader->setUniformForModelViewProjectionMatrix(); + s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1); ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); @@ -217,9 +217,9 @@ void ccDrawSolidPoly( const CCPoint *poli, unsigned int numberOfPoints, ccColor4 { lazy_init(); - shader_->use(); - shader_->setUniformForModelViewProjectionMatrix(); - shader_->setUniformLocationWith4fv(colorLocation_, (GLfloat*) &color.r, 1); + s_pShader->use(); + s_pShader->setUniformForModelViewProjectionMatrix(); + s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &color.r, 1); ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); @@ -272,9 +272,9 @@ void ccDrawCircle( const CCPoint& center, float radius, float angle, unsigned in vertices[(segments+1)*2] = center.x; vertices[(segments+1)*2+1] = center.y; - shader_->use(); - shader_->setUniformForModelViewProjectionMatrix(); - shader_->setUniformLocationWith4fv(colorLocation_, (GLfloat*) &color_.r, 1); + s_pShader->use(); + s_pShader->setUniformForModelViewProjectionMatrix(); + s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1); ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); @@ -302,9 +302,9 @@ void ccDrawQuadBezier(const CCPoint& origin, const CCPoint& control, const CCPoi vertices[segments].x = destination.x; vertices[segments].y = destination.y; - shader_->use(); - shader_->setUniformForModelViewProjectionMatrix(); - shader_->setUniformLocationWith4fv(colorLocation_, (GLfloat*) &color_.r, 1); + s_pShader->use(); + s_pShader->setUniformForModelViewProjectionMatrix(); + s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1); ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); @@ -354,9 +354,9 @@ void ccDrawCardinalSpline( CCPointArray *config, CCFloat tension, unsigned int vertices[i].y = newPos.y; } - shader_->use(); - shader_->setUniformForModelViewProjectionMatrix(); - shader_->setUniformLocationWith4fv(colorLocation_, (GLfloat*)&color_.r, 1); + s_pShader->use(); + s_pShader->setUniformForModelViewProjectionMatrix(); + s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*)&s_tColor.r, 1); ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); @@ -383,9 +383,9 @@ void ccDrawCubicBezier(const CCPoint& origin, const CCPoint& control1, const CCP vertices[segments].x = destination.x; vertices[segments].y = destination.y; - shader_->use(); - shader_->setUniformForModelViewProjectionMatrix(); - shader_->setUniformLocationWith4fv(colorLocation_, (GLfloat*) &color_.r, 1); + s_pShader->use(); + s_pShader->setUniformForModelViewProjectionMatrix(); + s_pShader->setUniformLocationWith4fv(s_nColorLocation, (GLfloat*) &s_tColor.r, 1); ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position ); @@ -398,15 +398,15 @@ void ccDrawCubicBezier(const CCPoint& origin, const CCPoint& control1, const CCP void ccDrawColor4F( GLfloat r, GLfloat g, GLfloat b, GLfloat a ) { - color_.r = r; - color_.g = g; - color_.b = b; - color_.a = a; + s_tColor.r = r; + s_tColor.g = g; + s_tColor.b = b; + s_tColor.a = a; } void ccPointSize( GLfloat pointSize ) { - pointSize_ = pointSize * CC_CONTENT_SCALE_FACTOR(); + s_fPointSize = pointSize * CC_CONTENT_SCALE_FACTOR(); //TODO :glPointSize( pointSize ); @@ -414,10 +414,10 @@ void ccPointSize( GLfloat pointSize ) void ccDrawColor4B( GLubyte r, GLubyte g, GLubyte b, GLubyte a ) { - color_.r = r/255.0f; - color_.g = g/255.0f; - color_.b = b/255.0f; - color_.a = a/255.0f; + s_tColor.r = r/255.0f; + s_tColor.g = g/255.0f; + s_tColor.b = b/255.0f; + s_tColor.a = a/255.0f; } NS_CC_END diff --git a/cocos2dx/actions/CCActionInterval.cpp b/cocos2dx/actions/CCActionInterval.cpp index cddd12b8c6..745f914737 100644 --- a/cocos2dx/actions/CCActionInterval.cpp +++ b/cocos2dx/actions/CCActionInterval.cpp @@ -2399,7 +2399,7 @@ CCActionInterval* CCAnimate::reverse(void) } } - CCAnimation *newAnim = CCAnimation::createWithAnimationFrames(pNewArray, m_pAnimation->getDelayPerUnit(), m_pAnimation->getLoops()); + CCAnimation *newAnim = CCAnimation::create(pNewArray, m_pAnimation->getDelayPerUnit(), m_pAnimation->getLoops()); newAnim->setRestoreOriginalFrame(m_pAnimation->getRestoreOriginalFrame()); return create(newAnim); } diff --git a/cocos2dx/cocoa/CCArray.cpp b/cocos2dx/cocoa/CCArray.cpp index 58c50c5465..63c6d8ad8f 100644 --- a/cocos2dx/cocoa/CCArray.cpp +++ b/cocos2dx/cocoa/CCArray.cpp @@ -169,12 +169,12 @@ CCArray* CCArray::create(CCArray* otherArray) CCArray* CCArray::arrayWithContentsOfFile(const char* pFileName) { - return CCArray::createWithContentsOfFile(pFileName); + return CCArray::create(pFileName); } -CCArray* CCArray::createWithContentsOfFile(const char* pFileName) +CCArray* CCArray::create(const char* pFileName) { - CCArray* pRet = createWithContentsOfFileThreadSafe(pFileName); + CCArray* pRet = CCArray::createWithContentsOfFileThreadSafe(pFileName); if (pRet != NULL) { pRet->autorelease(); diff --git a/cocos2dx/cocoa/CCArray.h b/cocos2dx/cocoa/CCArray.h index 1b45372a7a..5f69be05f3 100644 --- a/cocos2dx/cocoa/CCArray.h +++ b/cocos2dx/cocoa/CCArray.h @@ -165,7 +165,7 @@ public: @param pFileName The file name of *.plist file @return The CCArray pointer generated from the file */ - static CCArray* createWithContentsOfFile(const char* pFileName); + static CCArray* create(const char* pFileName); /* @brief The same meaning as arrayWithContentsOfFile(), but it doesn't call autorelease, so the diff --git a/cocos2dx/cocoa/CCDictionary.cpp b/cocos2dx/cocoa/CCDictionary.cpp index a2d67c3aca..a413f539ec 100644 --- a/cocos2dx/cocoa/CCDictionary.cpp +++ b/cocos2dx/cocoa/CCDictionary.cpp @@ -309,10 +309,10 @@ CCDictionary* CCDictionary::create() CCDictionary* CCDictionary::dictionaryWithDictionary(CCDictionary* srcDict) { - return CCDictionary::createWithDictionary(srcDict); + return CCDictionary::create(srcDict); } -CCDictionary* CCDictionary::createWithDictionary(CCDictionary* srcDict) +CCDictionary* CCDictionary::create(CCDictionary* srcDict) { CCDictionary* pNewDict = (CCDictionary*)srcDict->copy(); pNewDict->autorelease(); @@ -333,10 +333,10 @@ CCDictionary* CCDictionary::createWithContentsOfFileThreadSafe(const char *pFile CCDictionary* CCDictionary::dictionaryWithContentsOfFile(const char *pFileName) { - return CCDictionary::createWithContentsOfFile(pFileName); + return CCDictionary::create(pFileName); } -CCDictionary* CCDictionary::createWithContentsOfFile(const char *pFileName) +CCDictionary* CCDictionary::create(const char *pFileName) { CCDictionary* pRet = createWithContentsOfFileThreadSafe(pFileName); pRet->autorelease(); diff --git a/cocos2dx/cocoa/CCDictionary.h b/cocos2dx/cocoa/CCDictionary.h index c6f8e3392f..ec54485d30 100644 --- a/cocos2dx/cocoa/CCDictionary.h +++ b/cocos2dx/cocoa/CCDictionary.h @@ -163,13 +163,13 @@ public: static CCDictionary* create(); - static CCDictionary* createWithDictionary(CCDictionary* srcDict); + static CCDictionary* create(CCDictionary* srcDict); /** @brief Generate a CCDictionary pointer by file @param pFileName The file name of *.plist file @return The CCDictionary pointer generated from the file */ - static CCDictionary* createWithContentsOfFile(const char *pFileName); + static CCDictionary* create(const char *pFileName); /* @brief The same meaning as dictionaryWithContentsOfFile(), but it doesn't call autorelease, so the diff --git a/cocos2dx/cocoa/CCString.cpp b/cocos2dx/cocoa/CCString.cpp index f6ea6d8390..7e7407b692 100644 --- a/cocos2dx/cocoa/CCString.cpp +++ b/cocos2dx/cocoa/CCString.cpp @@ -171,10 +171,10 @@ CCString* CCString::stringWithString(const std::string& pStr) CCString* CCString::stringWithData(const unsigned char* pData, unsigned long nLen) { - return CCString::createWithData(pData, nLen); + return CCString::create(pData, nLen); } -CCString* CCString::createWithData(const unsigned char* pData, unsigned long nLen) +CCString* CCString::create(const unsigned char* pData, unsigned long nLen) { CCString* pRet = NULL; if (pData != NULL) @@ -219,7 +219,7 @@ CCString* CCString::createWithFormat(const char* format, ...) CCString* CCString::stringWithContentsOfFile(const char* pszFileName) { - return CCString::createWithContentsOfFile(pszFileName); + return CCString::create(pszFileName); } CCString* CCString::createWithContentsOfFile(const char* pszFileName) @@ -228,7 +228,7 @@ CCString* CCString::createWithContentsOfFile(const char* pszFileName) unsigned char* pData = 0; CCString* pRet = NULL; pData = CCFileUtils::sharedFileUtils()->getFileData(pszFileName, "rb", &size); - pRet = CCString::createWithData(pData, size); + pRet = CCString::create(pData, size); CC_SAFE_DELETE_ARRAY(pData); return pRet; } diff --git a/cocos2dx/cocoa/CCString.h b/cocos2dx/cocoa/CCString.h index 94912399a0..3084de461c 100644 --- a/cocos2dx/cocoa/CCString.h +++ b/cocos2dx/cocoa/CCString.h @@ -132,7 +132,7 @@ public: * @return A CCString pointer which is an autorelease object pointer, * it means that you needn't do a release operation unless you retain it. */ - static CCString* createWithData(const unsigned char* pData, unsigned long nLen); + static CCString* create(const unsigned char* pData, unsigned long nLen); /** create a string with a file, * @return A CCString pointer which is an autorelease object pointer, diff --git a/cocos2dx/extensions/CCBReader/CCBReader.cpp b/cocos2dx/extensions/CCBReader/CCBReader.cpp index 76548aab89..3688042a12 100644 --- a/cocos2dx/extensions/CCBReader/CCBReader.cpp +++ b/cocos2dx/extensions/CCBReader/CCBReader.cpp @@ -167,7 +167,7 @@ void CCBReader::readStringCacheEntry() { int numBytes = b0 << 8 | b1; const unsigned char * src = (const unsigned char *) (this->mBytes + this->mCurrentByte); - CCString * string = CCString::createWithData(src, (unsigned long)numBytes); + CCString * string = CCString::create(src, (unsigned long)numBytes); string->retain(); this->mCurrentByte += numBytes; diff --git a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp index 9913af1eb5..2cc7a173dd 100644 --- a/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp +++ b/cocos2dx/extensions/CCControlExtension/CCScale9Sprite.cpp @@ -120,25 +120,25 @@ bool CCScale9Sprite::updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect re // // Centre - centre = CCSprite::createWithTexture(scale9Image->getTexture(), m_capInsetsInternal); + centre = CCSprite::create(scale9Image->getTexture(), m_capInsetsInternal); scale9Image->addChild(centre, 0, pCentre); // Top - top = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake(m_capInsetsInternal.origin.x, + top = CCSprite::create(scale9Image->getTexture(), CCRectMake(m_capInsetsInternal.origin.x, t, m_capInsetsInternal.size.width, m_capInsetsInternal.origin.y - t)); scale9Image->addChild(top, 1, pTop); // Bottom - bottom = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake( m_capInsetsInternal.origin.x, + bottom = CCSprite::create(scale9Image->getTexture(), CCRectMake( m_capInsetsInternal.origin.x, m_capInsetsInternal.origin.y + m_capInsetsInternal.size.height, m_capInsetsInternal.size.width, h - (m_capInsetsInternal.origin.y - t + m_capInsetsInternal.size.height) )); scale9Image->addChild(bottom, 1, pBottom); // Left - left = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake( + left = CCSprite::create(scale9Image->getTexture(), CCRectMake( l, m_capInsetsInternal.origin.y, m_capInsetsInternal.origin.x - l, @@ -146,7 +146,7 @@ bool CCScale9Sprite::updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect re scale9Image->addChild(left, 1, pLeft); // Right - right = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake( + right = CCSprite::create(scale9Image->getTexture(), CCRectMake( m_capInsetsInternal.origin.x + m_capInsetsInternal.size.width, m_capInsetsInternal.origin.y, w - (m_capInsetsInternal.origin.x - l + m_capInsetsInternal.size.width), @@ -154,7 +154,7 @@ bool CCScale9Sprite::updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect re scale9Image->addChild(right, 1, pRight); // Top left - topLeft = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake( + topLeft = CCSprite::create(scale9Image->getTexture(), CCRectMake( l, t, m_capInsetsInternal.origin.x - l, @@ -163,7 +163,7 @@ bool CCScale9Sprite::updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect re scale9Image->addChild(topLeft, 2, pTopLeft); // Top right - topRight = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake( + topRight = CCSprite::create(scale9Image->getTexture(), CCRectMake( m_capInsetsInternal.origin.x + m_capInsetsInternal.size.width, t, w - (m_capInsetsInternal.origin.x - l + m_capInsetsInternal.size.width), @@ -172,7 +172,7 @@ bool CCScale9Sprite::updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect re scale9Image->addChild(topRight, 2, pTopRight); // Bottom left - bottomLeft = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake( + bottomLeft = CCSprite::create(scale9Image->getTexture(), CCRectMake( l, m_capInsetsInternal.origin.y + m_capInsetsInternal.size.height, m_capInsetsInternal.origin.x - l, @@ -180,7 +180,7 @@ bool CCScale9Sprite::updateWithBatchNode(CCSpriteBatchNode* batchnode, CCRect re scale9Image->addChild(bottomLeft, 2, pBottomLeft); // Bottom right - bottomRight = CCSprite::createWithTexture(scale9Image->getTexture(), CCRectMake( + bottomRight = CCSprite::create(scale9Image->getTexture(), CCRectMake( m_capInsetsInternal.origin.x + m_capInsetsInternal.size.width, m_capInsetsInternal.origin.y + m_capInsetsInternal.size.height, w - (m_capInsetsInternal.origin.x - l + m_capInsetsInternal.size.width), @@ -347,7 +347,7 @@ bool CCScale9Sprite::initWithSpriteFrame(CCSpriteFrame* spriteFrame, CCRect capI { CCAssert(spriteFrame != NULL, "Sprite frame must be not nil"); - CCSpriteBatchNode *batchnode = CCSpriteBatchNode::createWithTexture(spriteFrame->getTexture(), 9); + CCSpriteBatchNode *batchnode = CCSpriteBatchNode::create(spriteFrame->getTexture(), 9); bool pReturn = this->initWithBatchNode(batchnode, spriteFrame->getRect(), capInsets); return pReturn; } @@ -602,7 +602,7 @@ bool CCScale9Sprite::isOpacityModifyRGB() void CCScale9Sprite::setSpriteFrame(CCSpriteFrame * spriteFrame) { - CCSpriteBatchNode * batchnode = CCSpriteBatchNode::createWithTexture(spriteFrame->getTexture(), 9); + CCSpriteBatchNode * batchnode = CCSpriteBatchNode::create(spriteFrame->getTexture(), 9); this->updateWithBatchNode(batchnode, spriteFrame->getRect(), CCRectZero); // Reset insets diff --git a/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp b/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp index a3630e1176..89f23ebd30 100644 --- a/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp +++ b/cocos2dx/extensions/CCTextureWatcher/CCTextureWatcher.cpp @@ -321,7 +321,7 @@ void CCTextureWatcher::CCListView_cellForRow(CCListView *listView, CCListViewPro labelName->setAnchorPoint(ccp(0.5f, 0)); cell->addChild(labelName); - CCSprite *sprite = CCSprite::createWithTexture(textrue); + CCSprite *sprite = CCSprite::create(textrue); sprite->setAnchorPoint(ccp(0, 0)); CCSize spriteSize = sprite->getContentSize(); diff --git a/cocos2dx/label_nodes/CCLabelAtlas.cpp b/cocos2dx/label_nodes/CCLabelAtlas.cpp index 61b2d03620..a17d652cd0 100644 --- a/cocos2dx/label_nodes/CCLabelAtlas.cpp +++ b/cocos2dx/label_nodes/CCLabelAtlas.cpp @@ -95,7 +95,7 @@ CCLabelAtlas* CCLabelAtlas::create(const char *string, const char *fntFile) bool CCLabelAtlas::initWithString(const char *theString, const char *fntFile) { - CCDictionary *dict = CCDictionary::createWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(fntFile)); + CCDictionary *dict = CCDictionary::create(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(fntFile)); CCAssert(((CCString*)dict->objectForKey("version"))->intValue() == 1, "Unsupported version. Upgrade cocos2d version"); diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index d5401a2e92..47d94d5b34 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -487,7 +487,7 @@ void CCBMFontConfiguration::purgeFontDefDictionary() bool CCBMFontConfiguration::parseConfigFile(const char *controlFile) { std::string fullpath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(controlFile); - CCString *contents = CCString::createWithContentsOfFile(fullpath.c_str()); + CCString *contents = CCString::create(fullpath.c_str()); CCAssert(contents, "CCBMFontConfiguration::parseConfigFile | Open file error."); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp index d189784841..578c49f527 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.cpp @@ -786,10 +786,7 @@ CCLayerMultiplex * CCLayerMultiplex::layerWithLayer(CCLayer* layer) CCLayerMultiplex * CCLayerMultiplex::createWithLayer(CCLayer* layer) { - CCLayerMultiplex * pMultiplexLayer = new CCLayerMultiplex(); - pMultiplexLayer->initWithLayer(layer); - pMultiplexLayer->autorelease(); - return pMultiplexLayer; + return CCLayerMultiplex::create(layer, NULL); } void CCLayerMultiplex::addLayer(CCLayer* layer) @@ -798,16 +795,6 @@ void CCLayerMultiplex::addLayer(CCLayer* layer) m_pLayers->addObject(layer); } -bool CCLayerMultiplex::initWithLayer(CCLayer* layer) -{ - m_pLayers = CCArray::create(); - m_pLayers->retain(); - m_pLayers->addObject(layer); - m_nEnabledLayer = 0; - this->addChild(layer); - return true; -} - bool CCLayerMultiplex::initWithLayers(CCLayer *layer, va_list params) { m_pLayers = CCArray::create(5); diff --git a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h index c888e86076..410346fe99 100644 --- a/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h +++ b/cocos2dx/layers_scenes_transitions_nodes/CCLayer.h @@ -379,7 +379,6 @@ public: static CCLayerMultiplex * createWithLayer(CCLayer* layer); void addLayer(CCLayer* layer); - bool initWithLayer(CCLayer* layer); /** initializes a MultiplexLayer with one or more layers using a variable argument list. */ bool initWithLayers(CCLayer* layer, va_list params); diff --git a/cocos2dx/menu_nodes/CCMenu.h b/cocos2dx/menu_nodes/CCMenu.h index ac81283342..669cf318a1 100644 --- a/cocos2dx/menu_nodes/CCMenu.h +++ b/cocos2dx/menu_nodes/CCMenu.h @@ -97,7 +97,7 @@ public: /** creates a CCMenu with it's items */ static CCMenu* create(CCMenuItem* item, ...); - /** creates a CCMenu with a NSArray of CCMenuItem objects */ + /** creates a CCMenu with a CCArray of CCMenuItem objects */ static CCMenu* create(CCArray* pArrayOfItems); /** creates a CCMenu with it's item, then use addChild() to add diff --git a/cocos2dx/menu_nodes/CCMenuItem.cpp b/cocos2dx/menu_nodes/CCMenuItem.cpp index 1667befd8d..93df0ca76c 100644 --- a/cocos2dx/menu_nodes/CCMenuItem.cpp +++ b/cocos2dx/menu_nodes/CCMenuItem.cpp @@ -796,17 +796,17 @@ bool CCMenuItemImage::initWithNormalImage(const char *normalImage, const char *s // void CCMenuItemImage::setNormalSpriteFrame(CCSpriteFrame * frame) { - setNormalImage(CCSprite::createWithSpriteFrame(frame)); + setNormalImage(CCSprite::create(frame)); } void CCMenuItemImage::setSelectedSpriteFrame(CCSpriteFrame * frame) { - setSelectedImage(CCSprite::createWithSpriteFrame(frame)); + setSelectedImage(CCSprite::create(frame)); } void CCMenuItemImage::setDisabledSpriteFrame(CCSpriteFrame * frame) { - setDisabledImage(CCSprite::createWithSpriteFrame(frame)); + setDisabledImage(CCSprite::create(frame)); } // // MenuItemToggle diff --git a/cocos2dx/misc_nodes/CCRenderTexture.cpp b/cocos2dx/misc_nodes/CCRenderTexture.cpp index 6fbe66efe4..a84d07450d 100644 --- a/cocos2dx/misc_nodes/CCRenderTexture.cpp +++ b/cocos2dx/misc_nodes/CCRenderTexture.cpp @@ -228,7 +228,7 @@ bool CCRenderTexture::initWithWidthAndHeight(int w, int h, CCTexture2DPixelForma m_pTexture->setAliasTexParameters(); - m_pSprite = CCSprite::createWithTexture(m_pTexture); + m_pSprite = CCSprite::create(m_pTexture); m_pTexture->release(); m_pSprite->setScaleY(-1); diff --git a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp index 86da441a9b..94a105840f 100644 --- a/cocos2dx/particle_nodes/CCParticleBatchNode.cpp +++ b/cocos2dx/particle_nodes/CCParticleBatchNode.cpp @@ -60,10 +60,10 @@ CCParticleBatchNode::~CCParticleBatchNode() */ CCParticleBatchNode* CCParticleBatchNode::batchNodeWithTexture(CCTexture2D *tex, unsigned int capacity/* = kCCParticleDefaultCapacity*/) { - return CCParticleBatchNode::createWithTexture(tex, capacity); + return CCParticleBatchNode::create(tex, capacity); } -CCParticleBatchNode* CCParticleBatchNode::createWithTexture(CCTexture2D *tex, unsigned int capacity/* = kCCParticleDefaultCapacity*/) +CCParticleBatchNode* CCParticleBatchNode::create(CCTexture2D *tex, unsigned int capacity/* = kCCParticleDefaultCapacity*/) { CCParticleBatchNode * p = new CCParticleBatchNode(); if( p && p->initWithTexture(tex, capacity)) diff --git a/cocos2dx/particle_nodes/CCParticleBatchNode.h b/cocos2dx/particle_nodes/CCParticleBatchNode.h index b02594273d..59b9c6bbca 100644 --- a/cocos2dx/particle_nodes/CCParticleBatchNode.h +++ b/cocos2dx/particle_nodes/CCParticleBatchNode.h @@ -81,7 +81,7 @@ public: CC_DEPRECATED_ATTRIBUTE static CCParticleBatchNode* batchNodeWithFile(const char* fileImage, unsigned int capacity = kCCParticleDefaultCapacity); /** initializes the particle system with CCTexture2D, a capacity of particles, which particle system to use */ - static CCParticleBatchNode* createWithTexture(CCTexture2D *tex, unsigned int capacity = kCCParticleDefaultCapacity); + static CCParticleBatchNode* create(CCTexture2D *tex, unsigned int capacity = kCCParticleDefaultCapacity); /** initializes the particle system with the name of a file on disk (for a list of supported formats look at the CCTexture2D class), a capacity of particles */ static CCParticleBatchNode* create(const char* fileImage, unsigned int capacity = kCCParticleDefaultCapacity); diff --git a/cocos2dx/sprite_nodes/CCAnimation.cpp b/cocos2dx/sprite_nodes/CCAnimation.cpp index 1d7af65e4c..068bc10e91 100644 --- a/cocos2dx/sprite_nodes/CCAnimation.cpp +++ b/cocos2dx/sprite_nodes/CCAnimation.cpp @@ -97,10 +97,10 @@ CCAnimation* CCAnimation::create(void) CCAnimation* CCAnimation::animationWithSpriteFrames(CCArray *frames, float delay/* = 0.0f*/) { - return CCAnimation::createWithSpriteFrames(frames, delay); + return CCAnimation::create(frames, delay); } -CCAnimation* CCAnimation::createWithSpriteFrames(CCArray *frames, float delay/* = 0.0f*/) +CCAnimation* CCAnimation::create(CCArray *frames, float delay/* = 0.0f*/) { CCAnimation *pAnimation = new CCAnimation(); pAnimation->initWithSpriteFrames(frames, delay); @@ -111,10 +111,10 @@ CCAnimation* CCAnimation::createWithSpriteFrames(CCArray *frames, float delay/* CCAnimation* CCAnimation::animationWithAnimationFrames(CCArray* arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops) { - return CCAnimation::createWithAnimationFrames(arrayOfAnimationFrameNames, delayPerUnit, loops); + return CCAnimation::create(arrayOfAnimationFrameNames, delayPerUnit, loops); } -CCAnimation* CCAnimation::createWithAnimationFrames(CCArray* arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops) +CCAnimation* CCAnimation::create(CCArray* arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops) { CCAnimation *pAnimation = new CCAnimation(); pAnimation->initWithAnimationFrames(arrayOfAnimationFrameNames, delayPerUnit, loops); diff --git a/cocos2dx/sprite_nodes/CCAnimation.h b/cocos2dx/sprite_nodes/CCAnimation.h index 7b419cf7cb..3898fb6dc0 100644 --- a/cocos2dx/sprite_nodes/CCAnimation.h +++ b/cocos2dx/sprite_nodes/CCAnimation.h @@ -116,12 +116,12 @@ public: The frames will be added with one "delay unit". @since v0.99.5 */ - static CCAnimation* createWithSpriteFrames(CCArray* arrayOfSpriteFrameNames, float delay = 0.0f); + static CCAnimation* create(CCArray* arrayOfSpriteFrameNames, float delay = 0.0f); /* Creates an animation with an array of CCAnimationFrame, the delay per units in seconds and and how many times it should be executed. @since v2.0 */ - static CCAnimation* createWithAnimationFrames(CCArray *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops); + static CCAnimation* create(CCArray *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops); /** Adds a CCSpriteFrame to a CCAnimation. The frame will be added with one "delay unit". diff --git a/cocos2dx/sprite_nodes/CCAnimationCache.cpp b/cocos2dx/sprite_nodes/CCAnimationCache.cpp index 328800cd1b..973dc85740 100644 --- a/cocos2dx/sprite_nodes/CCAnimationCache.cpp +++ b/cocos2dx/sprite_nodes/CCAnimationCache.cpp @@ -136,7 +136,7 @@ void CCAnimationCache::parseVersion1(CCDictionary* animations) CCLOG("cocos2d: CCAnimationCache: An animation in your dictionary refers to a frame which is not in the CCSpriteFrameCache. Some or all of the frames for the animation '%s' may be missing.", pElement->getStrKey()); } - animation = CCAnimation::createWithAnimationFrames(frames, delay, 1); + animation = CCAnimation::create(frames, delay, 1); CCAnimationCache::sharedAnimationCache()->addAnimation(animation, pElement->getStrKey()); frames->release(); @@ -245,7 +245,7 @@ void CCAnimationCache::addAnimationsWithFile(const char* plist) CCAssert( plist, "Invalid texture file name"); const char* path = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(plist); - CCDictionary* dict = CCDictionary::createWithContentsOfFile(path); + CCDictionary* dict = CCDictionary::create(path); CCAssert( dict, "CCAnimationCache: File could not be found"); diff --git a/cocos2dx/sprite_nodes/CCSprite.cpp b/cocos2dx/sprite_nodes/CCSprite.cpp index 2aff4cc096..66c104bf19 100644 --- a/cocos2dx/sprite_nodes/CCSprite.cpp +++ b/cocos2dx/sprite_nodes/CCSprite.cpp @@ -60,10 +60,10 @@ NS_CC_BEGIN CCSprite* CCSprite::spriteWithTexture(CCTexture2D *pTexture) { - return CCSprite::createWithTexture(pTexture); + return CCSprite::create(pTexture); } -CCSprite* CCSprite::createWithTexture(CCTexture2D *pTexture) +CCSprite* CCSprite::create(CCTexture2D *pTexture) { CCSprite *pobSprite = new CCSprite(); if (pobSprite && pobSprite->initWithTexture(pTexture)) @@ -77,10 +77,10 @@ CCSprite* CCSprite::createWithTexture(CCTexture2D *pTexture) CCSprite* CCSprite::spriteWithTexture(CCTexture2D *pTexture, const CCRect& rect) { - return CCSprite::createWithTexture(pTexture, rect); + return CCSprite::create(pTexture, rect); } -CCSprite* CCSprite::createWithTexture(CCTexture2D *pTexture, const CCRect& rect) +CCSprite* CCSprite::create(CCTexture2D *pTexture, const CCRect& rect) { CCSprite *pobSprite = new CCSprite(); if (pobSprite && pobSprite->initWithTexture(pTexture, rect)) @@ -128,10 +128,10 @@ CCSprite* CCSprite::create(const char *pszFileName, const CCRect& rect) CCSprite* CCSprite::spriteWithSpriteFrame(CCSpriteFrame *pSpriteFrame) { - return CCSprite::createWithSpriteFrame(pSpriteFrame); + return CCSprite::create(pSpriteFrame); } -CCSprite* CCSprite::createWithSpriteFrame(CCSpriteFrame *pSpriteFrame) +CCSprite* CCSprite::create(CCSpriteFrame *pSpriteFrame) { CCSprite *pobSprite = new CCSprite(); if (pobSprite && pobSprite->initWithSpriteFrame(pSpriteFrame)) @@ -155,7 +155,7 @@ CCSprite* CCSprite::createWithSpriteFrameName(const char *pszSpriteFrameName) char msg[256] = {0}; sprintf(msg, "Invalid spriteFrameName: %s", pszSpriteFrameName); CCAssert(pFrame != NULL, msg); - return createWithSpriteFrame(pFrame); + return create(pFrame); } CCSprite* CCSprite::node() diff --git a/cocos2dx/sprite_nodes/CCSprite.h b/cocos2dx/sprite_nodes/CCSprite.h index 2c4acec767..0c44ca27bd 100644 --- a/cocos2dx/sprite_nodes/CCSprite.h +++ b/cocos2dx/sprite_nodes/CCSprite.h @@ -142,12 +142,12 @@ public: The rect used will be the size of the texture. The offset will be (0,0). */ - static CCSprite* createWithTexture(CCTexture2D *pTexture); + static CCSprite* create(CCTexture2D *pTexture); /** Creates an sprite with a texture and a rect. The offset will be (0,0). */ - static CCSprite* createWithTexture(CCTexture2D *pTexture, const CCRect& rect); + static CCSprite* create(CCTexture2D *pTexture, const CCRect& rect); /** Creates an sprite with an sprite frame. @deprecated: This interface will be deprecated sooner or later. @@ -163,7 +163,7 @@ public: CC_DEPRECATED_ATTRIBUTE static CCSprite* spriteWithSpriteFrameName(const char *pszSpriteFrameName); /** Creates an sprite with an sprite frame. */ - static CCSprite* createWithSpriteFrame(CCSpriteFrame *pSpriteFrame); + static CCSprite* create(CCSpriteFrame *pSpriteFrame); /** Creates an sprite with an sprite frame name. An CCSpriteFrame will be fetched from the CCSpriteFrameCache by name. @@ -347,21 +347,21 @@ protected: // // Data used when the sprite is rendered using a CCSpriteSheet // - CCTextureAtlas *m_pobTextureAtlas; // Sprite Sheet texture atlas (weak reference) - unsigned int m_uAtlasIndex; // Absolute (real) Index on the SpriteSheet - CCSpriteBatchNode *m_pobBatchNode; // Used batch node (weak reference) + CCTextureAtlas* m_pobTextureAtlas; // Sprite Sheet texture atlas (weak reference) + unsigned int m_uAtlasIndex; // Absolute (real) Index on the SpriteSheet + CCSpriteBatchNode* m_pobBatchNode; // Used batch node (weak reference) - bool m_bDirty; // Sprite needs to be updated - bool m_bRecursiveDirty; // Subchildren needs to be updated - bool m_bHasChildren; // optimization to check if it contain children - bool m_bShouldBeHidden; // should not be drawn because one of the ancestors is not visible - CCAffineTransform m_transformToBatch; // + bool m_bDirty; // Sprite needs to be updated + bool m_bRecursiveDirty; // Subchildren needs to be updated + bool m_bHasChildren; // optimization to check if it contain children + bool m_bShouldBeHidden; // should not be drawn because one of the ancestors is not visible + CCAffineTransform m_transformToBatch; // // // Data used when the sprite is self-rendered // ccBlendFunc m_sBlendFunc; // Needed for the texture protocol - CCTexture2D *m_pobTexture;// Texture used to render the sprite + CCTexture2D* m_pobTexture;// Texture used to render the sprite // // Shared data diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp index ac82b54d03..4f31949437 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.cpp @@ -48,10 +48,10 @@ NS_CC_BEGIN CCSpriteBatchNode* CCSpriteBatchNode::batchNodeWithTexture(CCTexture2D* tex, unsigned int capacity/* = kDefaultSpriteBatchCapacity*/) { - return CCSpriteBatchNode::createWithTexture(tex, capacity); + return CCSpriteBatchNode::create(tex, capacity); } -CCSpriteBatchNode* CCSpriteBatchNode::createWithTexture(CCTexture2D* tex, unsigned int capacity/* = kDefaultSpriteBatchCapacity*/) +CCSpriteBatchNode* CCSpriteBatchNode::create(CCTexture2D* tex, unsigned int capacity/* = kDefaultSpriteBatchCapacity*/) { CCSpriteBatchNode *batchNode = new CCSpriteBatchNode(); batchNode->initWithTexture(tex, capacity); diff --git a/cocos2dx/sprite_nodes/CCSpriteBatchNode.h b/cocos2dx/sprite_nodes/CCSpriteBatchNode.h index 2a30f37487..3499a2f336 100644 --- a/cocos2dx/sprite_nodes/CCSpriteBatchNode.h +++ b/cocos2dx/sprite_nodes/CCSpriteBatchNode.h @@ -97,7 +97,7 @@ public: /** creates a CCSpriteBatchNode with a texture2d and capacity of children. The capacity will be increased in 33% in runtime if it run out of space. */ - static CCSpriteBatchNode* createWithTexture(CCTexture2D* tex, unsigned int capacity = kDefaultSpriteBatchCapacity); + static CCSpriteBatchNode* create(CCTexture2D* tex, unsigned int capacity = kDefaultSpriteBatchCapacity); /** creates a CCSpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and capacity of children. The capacity will be increased in 33% in runtime if it run out of space. diff --git a/cocos2dx/sprite_nodes/CCSpriteFrame.cpp b/cocos2dx/sprite_nodes/CCSpriteFrame.cpp index 4a0a8c1fbf..e343530329 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrame.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrame.cpp @@ -47,10 +47,10 @@ CCSpriteFrame* CCSpriteFrame::create(CCTexture2D *pobTexture, const CCRect& rect CCSpriteFrame* CCSpriteFrame::frameWithTextureFilename(const char* filename, const CCRect& rect) { - return createWithTextureFilename(filename, rect); + return CCSpriteFrame::create(filename, rect); } -CCSpriteFrame* CCSpriteFrame::createWithTextureFilename(const char* filename, const CCRect& rect) +CCSpriteFrame* CCSpriteFrame::create(const char* filename, const CCRect& rect) { CCSpriteFrame *pSpriteFrame = new CCSpriteFrame();; pSpriteFrame->initWithTextureFilename(filename, rect); @@ -75,10 +75,10 @@ CCSpriteFrame* CCSpriteFrame::create(CCTexture2D* pobTexture, const CCRect& rect CCSpriteFrame* CCSpriteFrame::frameWithTextureFilename(const char* filename, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize) { - return CCSpriteFrame::createWithTextureFilename(filename, rect, rotated, offset, originalSize); + return CCSpriteFrame::create(filename, rect, rotated, offset, originalSize); } -CCSpriteFrame* CCSpriteFrame::createWithTextureFilename(const char* filename, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize) +CCSpriteFrame* CCSpriteFrame::create(const char* filename, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize) { CCSpriteFrame *pSpriteFrame = new CCSpriteFrame();; pSpriteFrame->initWithTextureFilename(filename, rect, rotated, offset, originalSize); diff --git a/cocos2dx/sprite_nodes/CCSpriteFrame.h b/cocos2dx/sprite_nodes/CCSpriteFrame.h index d41b4bf1c0..23247d3e6c 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrame.h +++ b/cocos2dx/sprite_nodes/CCSpriteFrame.h @@ -127,7 +127,7 @@ public: /** Create a CCSpriteFrame with a texture filename, rect in points. It is assumed that the frame was not trimmed. */ - static CCSpriteFrame* createWithTextureFilename(const char* filename, const CCRect& rect); + static CCSpriteFrame* create(const char* filename, const CCRect& rect); /** Create a CCSpriteFrame with a texture, rect, rotated, offset and originalSize in pixels. The originalSize is the size in points of the frame before being trimmed. @@ -137,7 +137,7 @@ public: /** Create a CCSpriteFrame with a texture filename, rect, rotated, offset and originalSize in pixels. The originalSize is the size in pixels of the frame before being trimmed. */ - static CCSpriteFrame* createWithTextureFilename(const char* filename, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize); + static CCSpriteFrame* create(const char* filename, const CCRect& rect, bool rotated, const CCPoint& offset, const CCSize& originalSize); public: /** Initializes a CCSpriteFrame with a texture, rect in points. diff --git a/cocos2dx/textures/CCTextureAtlas.cpp b/cocos2dx/textures/CCTextureAtlas.cpp index 9c1ca76f65..79060c2237 100644 --- a/cocos2dx/textures/CCTextureAtlas.cpp +++ b/cocos2dx/textures/CCTextureAtlas.cpp @@ -102,8 +102,12 @@ void CCTextureAtlas::setQuads(ccV3F_C4B_T2F_Quad *var) } // TextureAtlas - alloc & init - CCTextureAtlas * CCTextureAtlas::textureAtlasWithFile(const char* file, unsigned int capacity) +{ + return CCTextureAtlas::create(file, capacity); +} + +CCTextureAtlas * CCTextureAtlas::create(const char* file, unsigned int capacity) { CCTextureAtlas * pTextureAtlas = new CCTextureAtlas(); if(pTextureAtlas && pTextureAtlas->initWithFile(file, capacity)) @@ -116,6 +120,11 @@ CCTextureAtlas * CCTextureAtlas::textureAtlasWithFile(const char* file, unsigned } CCTextureAtlas * CCTextureAtlas::textureAtlasWithTexture(CCTexture2D *texture, unsigned int capacity) +{ + return CCTextureAtlas::create(texture, capacity); +} + +CCTextureAtlas * CCTextureAtlas::create(CCTexture2D *texture, unsigned int capacity) { CCTextureAtlas * pTextureAtlas = new CCTextureAtlas(); if (pTextureAtlas && pTextureAtlas->initWithTexture(texture, capacity)) diff --git a/cocos2dx/textures/CCTextureAtlas.h b/cocos2dx/textures/CCTextureAtlas.h index 47686f5bcf..ee9be6e8c9 100644 --- a/cocos2dx/textures/CCTextureAtlas.h +++ b/cocos2dx/textures/CCTextureAtlas.h @@ -58,9 +58,9 @@ class CC_DLL CCTextureAtlas : public CCObject protected: GLushort* m_pIndices; #if CC_TEXTURE_ATLAS_USE_VAO - GLuint m_uVAOname; + GLuint m_uVAOname; #endif - GLuint m_pBuffersVBO[2]; //0: vertex 1: indices + GLuint m_pBuffersVBO[2]; //0: vertex 1: indices bool m_bDirty; //indicates whether or not the array buffer of the VBO needs to be updated @@ -82,8 +82,14 @@ public: /** creates a TextureAtlas with an filename and with an initial capacity for Quads. * The TextureAtlas capacity can be increased in runtime. + @deprecated: This interface will be deprecated sooner or later. */ - static CCTextureAtlas * textureAtlasWithFile(const char* file , unsigned int capacity); + CC_DEPRECATED_ATTRIBUTE static CCTextureAtlas * textureAtlasWithFile(const char* file , unsigned int capacity); + + /** creates a TextureAtlas with an filename and with an initial capacity for Quads. + * The TextureAtlas capacity can be increased in runtime. + */ + static CCTextureAtlas* create(const char* file , unsigned int capacity); /** initializes a TextureAtlas with a filename and with a certain capacity for Quads. * The TextureAtlas capacity can be increased in runtime. @@ -95,8 +101,16 @@ public: /** creates a TextureAtlas with a previously initialized Texture2D object, and * with an initial capacity for n Quads. * The TextureAtlas capacity can be increased in runtime. + @deprecated: This interface will be deprecated sooner or later. */ - static CCTextureAtlas * textureAtlasWithTexture(CCTexture2D *texture, unsigned int capacity); + CC_DEPRECATED_ATTRIBUTE static CCTextureAtlas * textureAtlasWithTexture(CCTexture2D *texture, unsigned int capacity); + + /** creates a TextureAtlas with a previously initialized Texture2D object, and + * with an initial capacity for n Quads. + * The TextureAtlas capacity can be increased in runtime. + */ + static CCTextureAtlas* create(CCTexture2D *texture, unsigned int capacity); + /** initializes a TextureAtlas with a previously initialized Texture2D object, and * with an initial capacity for Quads. diff --git a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp index fc52c93355..ced17788d2 100644 --- a/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp +++ b/cocos2dx/tileMap_parallax_nodes/CCTMXLayer.cpp @@ -75,7 +75,7 @@ bool CCTMXLayer::initWithTilesetInfo(CCTMXTilesetInfo *tilesetInfo, CCTMXLayerIn m_uMinGID = layerInfo->m_uMinGID; m_uMaxGID = layerInfo->m_uMaxGID; m_cOpacity = layerInfo->m_cOpacity; - setProperties(CCDictionary::createWithDictionary(layerInfo->getProperties())); + setProperties(CCDictionary::create(layerInfo->getProperties())); m_fContentScaleFactor = CCDirector::sharedDirector()->getContentScaleFactor(); // tilesetInfo diff --git a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index c6e86f7d02..2751d17e80 100644 --- a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -22628adfacd66254448f16f59cb8bd2af00a92ac \ No newline at end of file +95b4c2c0005c822aadfa31b31b2e92d2d0e21662 \ No newline at end of file diff --git a/template/msvc/CCAppWiz.win32/Templates/1033/Resources/hello.lua b/template/msvc/CCAppWiz.win32/Templates/1033/Resources/hello.lua index 0f99068474..33efc36f37 100644 --- a/template/msvc/CCAppWiz.win32/Templates/1033/Resources/hello.lua +++ b/template/msvc/CCAppWiz.win32/Templates/1033/Resources/hello.lua @@ -26,7 +26,7 @@ local function creatDog() rect = CCRectMake(frameWidth, 0, frameWidth, frameHeight) local frame1 = CCSpriteFrame:create(textureDog, rect) - local spriteDog = CCSprite:createWithSpriteFrame(frame0) + local spriteDog = CCSprite:create(frame0) spriteDog.isPaused = false spriteDog:setPosition(0, winSize.height / 4 * 3) @@ -35,7 +35,7 @@ local function creatDog() animFrames:addObject(frame0) animFrames:addObject(frame1) - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.5) + local animation = CCAnimation:create(animFrames, 0.5) local animate = CCAnimate:create(animation); spriteDog:runAction(CCRepeatForever:create(animate)) @@ -76,11 +76,10 @@ local function createLayerFram() end -- add crop - local textureCrop = CCTextureCache:sharedTextureCache():addImage("crop.png") - local frameCrop = CCSpriteFrame:create(textureCrop, CCRectMake(0, 0, 105, 95)) + local frameCrop = CCSpriteFrame:create("crop.png", CCRectMake(0, 0, 105, 95)) for i = 0, 3 do for j = 0, 1 do - local spriteCrop = CCSprite:createWithSpriteFrame(frameCrop); + local spriteCrop = CCSprite:create(frameCrop); spriteCrop:setPosition(10 + 200 + j * 180 - i % 2 * 90, 30 + 10 + i * 95 / 2) layerFarm:addChild(spriteCrop) end diff --git a/template/xcode4/cocos2dx_lua.xctemplate/Resources/hello.lua b/template/xcode4/cocos2dx_lua.xctemplate/Resources/hello.lua index 0f99068474..33efc36f37 100644 --- a/template/xcode4/cocos2dx_lua.xctemplate/Resources/hello.lua +++ b/template/xcode4/cocos2dx_lua.xctemplate/Resources/hello.lua @@ -26,7 +26,7 @@ local function creatDog() rect = CCRectMake(frameWidth, 0, frameWidth, frameHeight) local frame1 = CCSpriteFrame:create(textureDog, rect) - local spriteDog = CCSprite:createWithSpriteFrame(frame0) + local spriteDog = CCSprite:create(frame0) spriteDog.isPaused = false spriteDog:setPosition(0, winSize.height / 4 * 3) @@ -35,7 +35,7 @@ local function creatDog() animFrames:addObject(frame0) animFrames:addObject(frame1) - local animation = CCAnimation:createWithSpriteFrames(animFrames, 0.5) + local animation = CCAnimation:create(animFrames, 0.5) local animate = CCAnimate:create(animation); spriteDog:runAction(CCRepeatForever:create(animate)) @@ -76,11 +76,10 @@ local function createLayerFram() end -- add crop - local textureCrop = CCTextureCache:sharedTextureCache():addImage("crop.png") - local frameCrop = CCSpriteFrame:create(textureCrop, CCRectMake(0, 0, 105, 95)) + local frameCrop = CCSpriteFrame:create("crop.png", CCRectMake(0, 0, 105, 95)) for i = 0, 3 do for j = 0, 1 do - local spriteCrop = CCSprite:createWithSpriteFrame(frameCrop); + local spriteCrop = CCSprite:create(frameCrop); spriteCrop:setPosition(10 + 200 + j * 180 - i % 2 * 90, 30 + 10 + i * 95 / 2) layerFarm:addChild(spriteCrop) end diff --git a/tests/tests/LabelTest/LabelTest.cpp b/tests/tests/LabelTest/LabelTest.cpp index 8b5c1a3b7b..c5da591143 100644 --- a/tests/tests/LabelTest/LabelTest.cpp +++ b/tests/tests/LabelTest/LabelTest.cpp @@ -195,7 +195,7 @@ void AtlasDemo::backCallback(CCObject* pSender) //------------------------------------------------------------------ Atlas1::Atlas1() { - m_textureAtlas = CCTextureAtlas::textureAtlasWithFile(s_AtlasTest, 3); m_textureAtlas->retain(); + m_textureAtlas = CCTextureAtlas::create(s_AtlasTest, 3); m_textureAtlas->retain(); CCSize s = CCDirector::sharedDirector()->getWinSize(); @@ -1390,7 +1390,7 @@ std::string BMFontOneAtlas::subtitle() /// BMFontUnicode BMFontUnicode::BMFontUnicode() { - CCDictionary *strings = CCDictionary::createWithContentsOfFile("fonts/strings.xml"); + CCDictionary *strings = CCDictionary::create("fonts/strings.xml"); const char *chinese = ((CCString*)strings->objectForKey("chinese1"))->m_sString.c_str(); const char *japanese = ((CCString*)strings->objectForKey("japanese"))->m_sString.c_str(); const char *spanish = ((CCString*)strings->objectForKey("spanish"))->m_sString.c_str(); diff --git a/tests/tests/ParticleTest/ParticleTest.cpp b/tests/tests/ParticleTest/ParticleTest.cpp index 3d8f5f3309..75f434a9f0 100644 --- a/tests/tests/ParticleTest/ParticleTest.cpp +++ b/tests/tests/ParticleTest/ParticleTest.cpp @@ -1239,7 +1239,7 @@ void ParticleBatchHybrid::onEnter() m_emitter = CCParticleSystemQuad::create("Particles/LavaFlow.plist"); m_emitter->retain(); - CCParticleBatchNode *batch = CCParticleBatchNode::createWithTexture(m_emitter->getTexture()); + CCParticleBatchNode *batch = CCParticleBatchNode::create(m_emitter->getTexture()); batch->addChild(m_emitter); @@ -1298,7 +1298,7 @@ void ParticleBatchMultipleEmitters::onEnter() emitter2->setPosition(ccp( s.width/2, s.height/2)); emitter3->setPosition(ccp( s.width/4, s.height/4)); - CCParticleBatchNode *batch = CCParticleBatchNode::createWithTexture(emitter1->getTexture()); + CCParticleBatchNode *batch = CCParticleBatchNode::create(emitter1->getTexture()); batch->addChild(emitter1, 0); batch->addChild(emitter2, 0); @@ -1330,7 +1330,7 @@ void ParticleReorder::onEnter() CCParticleSystem* ignore = CCParticleSystemQuad::create("Particles/SmallSun.plist"); CCNode *parent1 = CCNode::create(); - CCNode *parent2 = CCParticleBatchNode::createWithTexture(ignore->getTexture()); + CCNode *parent2 = CCParticleBatchNode::create(ignore->getTexture()); ignore->unscheduleUpdate(); for( unsigned int i=0; i<2;i++) @@ -1646,7 +1646,7 @@ void AddAndDeleteParticleSystems::onEnter() m_background = NULL; //adds the texture inside the plist to the texture cache - m_pBatchNode = CCParticleBatchNode::createWithTexture(NULL, 16000); + m_pBatchNode = CCParticleBatchNode::create((CCTexture2D*)NULL, 16000); addChild(m_pBatchNode, 1, 2); diff --git a/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp b/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp index 732b60e341..3dfbd8b1f5 100644 --- a/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceNodeChildrenTest.cpp @@ -180,7 +180,7 @@ void IterateSpriteSheet::updateQuantityOfNodes() { for(int i = 0; i < (quantityOfNodes-currentQuantityOfNodes); i++) { - CCSprite *sprite = CCSprite::createWithTexture(batchNode->getTexture(), CCRectMake(0, 0, 32, 32)); + CCSprite *sprite = CCSprite::create(batchNode->getTexture(), CCRectMake(0, 0, 32, 32)); batchNode->addChild(sprite); sprite->setPosition(ccp( CCRANDOM_0_1()*s.width, CCRANDOM_0_1()*s.height)); } @@ -337,7 +337,7 @@ void AddRemoveSpriteSheet::updateQuantityOfNodes() { for (int i=0; i < (quantityOfNodes-currentQuantityOfNodes); i++) { - CCSprite *sprite = CCSprite::createWithTexture(batchNode->getTexture(), CCRectMake(0, 0, 32, 32)); + CCSprite *sprite = CCSprite::create(batchNode->getTexture(), CCRectMake(0, 0, 32, 32)); batchNode->addChild(sprite); sprite->setPosition(ccp( CCRANDOM_0_1()*s.width, CCRANDOM_0_1()*s.height)); sprite->setVisible(false); @@ -382,7 +382,7 @@ void AddSpriteSheet::update(float dt) // Don't include the sprite creation time and random as part of the profiling for(int i=0; igetTexture(), CCRectMake(0,0,32,32)); + CCSprite* pSprite = CCSprite::create(batchNode->getTexture(), CCRectMake(0,0,32,32)); sprites->addObject(pSprite); zs[i] = CCRANDOM_MINUS1_1() * 50; } @@ -445,7 +445,7 @@ void RemoveSpriteSheet::update(float dt) // Don't include the sprite creation time as part of the profiling for(int i=0;igetTexture(), CCRectMake(0,0,32,32)); + CCSprite* pSprite = CCSprite::create(batchNode->getTexture(), CCRectMake(0,0,32,32)); sprites->addObject(pSprite); } @@ -505,7 +505,7 @@ void ReorderSpriteSheet::update(float dt) // Don't include the sprite creation time as part of the profiling for(int i=0;igetTexture(), CCRectMake(0,0,32,32)); + CCSprite* pSprite = CCSprite::create(batchNode->getTexture(), CCRectMake(0,0,32,32)); sprites->addObject(pSprite); } diff --git a/tests/tests/PerformanceTest/PerformanceSpriteTest.cpp b/tests/tests/PerformanceTest/PerformanceSpriteTest.cpp index b174e03007..af15df7b44 100644 --- a/tests/tests/PerformanceTest/PerformanceSpriteTest.cpp +++ b/tests/tests/PerformanceTest/PerformanceSpriteTest.cpp @@ -130,7 +130,7 @@ CCSprite* SubTest::createSpriteWithTag(int tag) case 2: case 3: { - sprite = CCSprite::createWithTexture(batchNode->getTexture(), CCRectMake(0, 0, 52, 139)); + sprite = CCSprite::create(batchNode->getTexture(), CCRectMake(0, 0, 52, 139)); batchNode->addChild(sprite, 0, tag+100); break; } @@ -154,7 +154,7 @@ CCSprite* SubTest::createSpriteWithTag(int tag) x *= 85; y *= 121; - sprite = CCSprite::createWithTexture(batchNode->getTexture(), CCRectMake(x,y,85,121)); + sprite = CCSprite::create(batchNode->getTexture(), CCRectMake(x,y,85,121)); batchNode->addChild(sprite, 0, tag+100); break; } @@ -185,7 +185,7 @@ CCSprite* SubTest::createSpriteWithTag(int tag) x *= 32; y *= 32; - sprite = CCSprite::createWithTexture(batchNode->getTexture(), CCRectMake(x,y,32,32)); + sprite = CCSprite::create(batchNode->getTexture(), CCRectMake(x,y,32,32)); batchNode->addChild(sprite, 0, tag+100); break; } diff --git a/tests/tests/RenderTextureTest/RenderTextureTest.cpp b/tests/tests/RenderTextureTest/RenderTextureTest.cpp index b156546d3f..97d55c4f6e 100644 --- a/tests/tests/RenderTextureTest/RenderTextureTest.cpp +++ b/tests/tests/RenderTextureTest/RenderTextureTest.cpp @@ -188,7 +188,7 @@ void RenderTextureSave::saveImage(cocos2d::CCObject *pSender) CC_SAFE_DELETE(pImage); - CCSprite *sprite = CCSprite::createWithTexture(tex); + CCSprite *sprite = CCSprite::create(tex); sprite->setScale(0.3f); addChild(sprite); @@ -457,7 +457,7 @@ void RenderTextureZbuffer::renderScreenShot() texture->end(); - CCSprite *sprite = CCSprite::createWithTexture(texture->getSprite()->getTexture()); + CCSprite *sprite = CCSprite::create(texture->getSprite()->getTexture()); sprite->setPosition(ccp(256, 256)); sprite->setOpacity(182); diff --git a/tests/tests/ShaderTest/ShaderTest.cpp b/tests/tests/ShaderTest/ShaderTest.cpp index d99c78025e..e9d0d99eeb 100644 --- a/tests/tests/ShaderTest/ShaderTest.cpp +++ b/tests/tests/ShaderTest/ShaderTest.cpp @@ -475,7 +475,7 @@ bool SpriteBlur::initWithTexture(CCTexture2D* texture, const CCRect& rect) blur_ = ccp(1/s.width, 1/s.height); sub_[0] = sub_[1] = sub_[2] = sub_[3] = 0; - GLchar * fragSource = (GLchar*) CCString::createWithContentsOfFile( + GLchar * fragSource = (GLchar*) CCString::create( CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("Shaders/example_Blur.fsh"))->getCString(); CCGLProgram* pProgram = new CCGLProgram(); pProgram->initWithVertexShaderByteArray(ccPositionTextureColor_vert, fragSource); @@ -630,7 +630,7 @@ bool ShaderRetroEffect::init() { if( ShaderTestDemo::init() ) { - GLchar * fragSource = (GLchar*) CCString::createWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("Shaders/example_HorizontalColor.fsh"))->getCString(); + GLchar * fragSource = (GLchar*) CCString::create(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("Shaders/example_HorizontalColor.fsh"))->getCString(); CCGLProgram *p = new CCGLProgram(); p->initWithVertexShaderByteArray(ccPositionTexture_vert, fragSource); diff --git a/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id b/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id index 5f7a8ab926..5404304a26 100644 --- a/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id +++ b/tests/tests/SpriteTest/SpriteTest.cpp.REMOVED.git-id @@ -1 +1 @@ -830b848e5d80adc751de8b576dfeba1423ff77b4 \ No newline at end of file +ce063dda23d6a1bcfed54ba357a7aded426ea89e \ No newline at end of file diff --git a/tests/tests/Texture2dTest/Texture2dTest.cpp b/tests/tests/Texture2dTest/Texture2dTest.cpp index 979536e486..05aabb1b9b 100644 --- a/tests/tests/Texture2dTest/Texture2dTest.cpp +++ b/tests/tests/Texture2dTest/Texture2dTest.cpp @@ -283,12 +283,12 @@ void TextureMipMap::onEnter() CCTexture2D *texture1 = CCTextureCache::sharedTextureCache()->addImage("Images/grossini_dance_atlas_nomipmap.png"); - CCSprite *img0 = CCSprite::createWithTexture(texture0); + CCSprite *img0 = CCSprite::create(texture0); img0->setTextureRect(CCRectMake(85, 121, 85, 121)); img0->setPosition(ccp( s.width/3.0f, s.height/2.0f)); addChild(img0); - CCSprite *img1 = CCSprite::createWithTexture(texture1); + CCSprite *img1 = CCSprite::create(texture1); img1->setTextureRect(CCRectMake(85, 121, 85, 121)); img1->setPosition(ccp( 2*s.width/3.0f, s.height/2.0f)); addChild(img1); @@ -1162,7 +1162,7 @@ void TextureAsync::imageLoaded(CCObject* pObj) // This test just creates a sprite based on the Texture - CCSprite *sprite = CCSprite::createWithTexture(tex); + CCSprite *sprite = CCSprite::create(tex); sprite->setAnchorPoint(ccp(0,0)); addChild(sprite, -1); diff --git a/tests/tests/TileMapTest/TileMapTest.cpp b/tests/tests/TileMapTest/TileMapTest.cpp index 334ccddbc6..17710948bf 100644 --- a/tests/tests/TileMapTest/TileMapTest.cpp +++ b/tests/tests/TileMapTest/TileMapTest.cpp @@ -1254,7 +1254,7 @@ TMXOrthoFromXMLTest::TMXOrthoFromXMLTest() string resources = "TileMaps"; // partial paths are OK as resource paths. string file = resources + "/orthogonal-test1.tmx"; - CCString* str = CCString::createWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(file.c_str())); + CCString* str = CCString::create(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(file.c_str())); CCAssert(str != NULL, "Unable to open file"); CCTMXTiledMap *map = CCTMXTiledMap::create(str->getCString() ,resources.c_str()); diff --git a/tests/tests/ZwoptexTest/ZwoptexTest.cpp b/tests/tests/ZwoptexTest/ZwoptexTest.cpp index bb143af603..375967147c 100644 --- a/tests/tests/ZwoptexTest/ZwoptexTest.cpp +++ b/tests/tests/ZwoptexTest/ZwoptexTest.cpp @@ -136,7 +136,7 @@ void ZwoptexGenericTest::onEnter() layer1->setPosition(ccp(s.width/2-80 - (85.0f * 0.5f), s.height/2 - (121.0f * 0.5f))); addChild(layer1); - sprite1 = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("grossini_dance_01.png")); + sprite1 = CCSprite::create(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("grossini_dance_01.png")); sprite1->setPosition(ccp( s.width/2-80, s.height/2)); addChild(sprite1); @@ -147,7 +147,7 @@ void ZwoptexGenericTest::onEnter() layer2->setPosition(ccp(s.width/2+80 - (85.0f * 0.5f), s.height/2 - (121.0f * 0.5f))); addChild(layer2); - sprite2 = CCSprite::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("grossini_dance_generic_01.png")); + sprite2 = CCSprite::create(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("grossini_dance_generic_01.png")); sprite2->setPosition(ccp( s.width/2 + 80, s.height/2)); addChild(sprite2); diff --git a/tools/tolua++/CCAnimation.pkg b/tools/tolua++/CCAnimation.pkg index 0e528ed731..c7c3f9de9f 100644 --- a/tools/tolua++/CCAnimation.pkg +++ b/tools/tolua++/CCAnimation.pkg @@ -23,9 +23,9 @@ class CCAnimation : public CCObject ~CCAnimation(void); static CCAnimation* create(void); - static CCAnimation* createWithSpriteFrames(CCArray* arrayOfSpriteFrameNames); - static CCAnimation* createWithSpriteFrames(CCArray* arrayOfSpriteFrameNames, float delay); - static CCAnimation* createWithAnimationFrames(CCArray *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops); + static CCAnimation* create(CCArray* arrayOfSpriteFrameNames); + static CCAnimation* create(CCArray* arrayOfSpriteFrameNames, float delay); + static CCAnimation* create(CCArray *arrayOfAnimationFrameNames, float delayPerUnit, unsigned int loops); void addSpriteFrame(CCSpriteFrame *pFrame); void addSpriteFrameWithFileName(const char *pszFileName); diff --git a/tools/tolua++/CCArray.pkg b/tools/tolua++/CCArray.pkg index c075ca8763..7b7a15e9da 100644 --- a/tools/tolua++/CCArray.pkg +++ b/tools/tolua++/CCArray.pkg @@ -1,12 +1,10 @@ class CCArray : public CCObject { -public: - static CCArray* create(); static CCArray* createWithObject(CCObject* pObject); + static CCArray* create(const char* pFileName); static CCArray* create(unsigned int capacity); static CCArray* create(CCArray* otherArray); - static CCArray* createWithContentsOfFile(const char* pFileName); unsigned int count(); @@ -52,4 +50,4 @@ public: void replaceObjectAtIndex(unsigned int uIndex, CCObject* pObject, bool bReleaseObject = true); -}; \ No newline at end of file +}; diff --git a/tools/tolua++/CCDictionary.pkg b/tools/tolua++/CCDictionary.pkg index 3c87553265..218e0f5ca2 100644 --- a/tools/tolua++/CCDictionary.pkg +++ b/tools/tolua++/CCDictionary.pkg @@ -19,8 +19,8 @@ class CCDictionary : public CCObject void removeAllObjects(); static CCDictionary* create(); - static CCDictionary* createWithDictionary(CCDictionary* srcDict); - static CCDictionary* createWithContentsOfFile(const char *pFileName); + static CCDictionary* create(CCDictionary* srcDict); + static CCDictionary* create(const char *pFileName); }; diff --git a/tools/tolua++/CCLayer.pkg b/tools/tolua++/CCLayer.pkg index 6085bd9074..25c47c2a6b 100644 --- a/tools/tolua++/CCLayer.pkg +++ b/tools/tolua++/CCLayer.pkg @@ -62,5 +62,5 @@ class CCLayerMultiplex : public CCLayer void switchTo(unsigned int n); void switchToAndReleaseMe(unsigned int n); - static CCLayerMultiplex * create(CCLayer* layer); + static CCLayerMultiplex * createWithLayer(CCLayer* layer); }; diff --git a/tools/tolua++/CCParticleBatchNode.pkg b/tools/tolua++/CCParticleBatchNode.pkg new file mode 100644 index 0000000000..f30ecec06e --- /dev/null +++ b/tools/tolua++/CCParticleBatchNode.pkg @@ -0,0 +1,23 @@ +class CCParticleBatchNode : public CCNode, public CCTextureProtocol +{ +public: + static CCParticleBatchNode* create(CCTexture2D *tex, unsigned int capacity = kCCParticleDefaultCapacity); + static CCParticleBatchNode* create(const char* fileImage, unsigned int capacity = kCCParticleDefaultCapacity); + + virtual void addChild(CCNode * child); + virtual void addChild(CCNode * child, int zOrder); + virtual void addChild(CCNode * child, int zOrder, int tag); + + void insertChild(CCParticleSystem* pSystem, unsigned int index); + + virtual void removeChild(CCNode* child, bool cleanup); + virtual void reorderChild(CCNode * child, int zOrder); + void removeChildAtIndex(unsigned int index, bool doCleanup); + void removeAllChildrenWithCleanup(bool doCleanup); + void disableParticle(unsigned int particleIndex); + + virtual CCTexture2D* getTexture(void); + virtual void setTexture(CCTexture2D *texture); + virtual void setBlendFunc(ccBlendFunc blendFunc); + virtual ccBlendFunc getBlendFunc(void); +}; diff --git a/tools/tolua++/CCSprite.pkg b/tools/tolua++/CCSprite.pkg index 2bbbe57584..550bc8ecb0 100644 --- a/tools/tolua++/CCSprite.pkg +++ b/tools/tolua++/CCSprite.pkg @@ -62,7 +62,7 @@ class CCSprite : public CCNode void updateTransform(void); //void useSelfRender(void); - void setTextureRect(CCRect rect); + void setTextureRect(CCRect rect); //void setTextureRectInPixels(CCRect rect, bool rotated, CCSize size); //void useBatchNode(CCSpriteBatchNode *batchNode); void setDisplayFrame(CCSpriteFrame *pNewFrame); @@ -70,12 +70,12 @@ class CCSprite : public CCNode //CCSpriteFrame* displayedFrame(void); void setDisplayFrameWithAnimationName(const char *animationName, int frameIndex); - static CCSprite* createWithTexture(CCTexture2D *pTexture); - static CCSprite* createWithTexture(CCTexture2D *pTexture, CCRect rect); + static CCSprite* create(CCTexture2D *pTexture); + static CCSprite* create(CCTexture2D *pTexture, CCRect rect); // static CCSprite* spriteWithTexture(CCTexture2D *pTexture, CCRect rect, CCPoint offset); - static CCSprite* createWithSpriteFrame(CCSpriteFrame *pSpriteFrame); + static CCSprite* create(CCSpriteFrame *pSpriteFrame); static CCSprite* createWithSpriteFrameName(const char *pszSpriteFrameName); - static CCSprite* create(const char *pszFileName); + static CCSprite* create(const char *pszFileName); static CCSprite* create(const char *pszFileName, CCRect rect); //static CCSprite* spriteWithBatchNode(CCSpriteBatchNode *batchNode, CCRect rect); }; diff --git a/tools/tolua++/CCSpriteBatchNode.pkg b/tools/tolua++/CCSpriteBatchNode.pkg index 629266d7cd..d644d65783 100644 --- a/tools/tolua++/CCSpriteBatchNode.pkg +++ b/tools/tolua++/CCSpriteBatchNode.pkg @@ -20,8 +20,8 @@ class CCSpriteBatchNode : public CCNode void setBlendFunc(ccBlendFunc blendFunc); ccBlendFunc getBlendFunc(void); - static CCSpriteBatchNode* createWithTexture(CCTexture2D *tex); - static CCSpriteBatchNode* createWithTexture(CCTexture2D* tex, unsigned int capacity); + static CCSpriteBatchNode* create(CCTexture2D *tex); + static CCSpriteBatchNode* create(CCTexture2D* tex, unsigned int capacity); static CCSpriteBatchNode* create(const char* fileImage); static CCSpriteBatchNode* create(const char* fileImage, unsigned int capacity); }; diff --git a/tools/tolua++/CCSpriteFrame.pkg b/tools/tolua++/CCSpriteFrame.pkg index 7ec0e5578a..10e7047f10 100644 --- a/tools/tolua++/CCSpriteFrame.pkg +++ b/tools/tolua++/CCSpriteFrame.pkg @@ -21,6 +21,6 @@ class CCSpriteFrame : public CCObject static CCSpriteFrame* create(CCTexture2D* pobTexture, CCRect rect); static CCSpriteFrame* create(CCTexture2D* pobTexture, CCRect rect, bool rotated, CCPoint offset, CCSize originalSize); - static CCSpriteFrame* createWithTextureFilename(const char* filename, CCRect rect); - static CCSpriteFrame* createWithTextureFilename(const char* filename, CCRect rect, bool rotated, CCPoint offset, CCSize originalSize); + static CCSpriteFrame* create(const char* filename, CCRect rect); + static CCSpriteFrame* create(const char* filename, CCRect rect, bool rotated, CCPoint offset, CCSize originalSize); }; diff --git a/tools/tolua++/CCString.pkg b/tools/tolua++/CCString.pkg index ea8df4181a..714e34af75 100644 --- a/tools/tolua++/CCString.pkg +++ b/tools/tolua++/CCString.pkg @@ -12,7 +12,7 @@ class CCString : public CCObject bool isEqual(const CCObject* pObject); static CCString* create(const char* pStr); - static CCString* createWithData(unsigned char* pData, unsigned long nLen); + static CCString* create(unsigned char* pData, unsigned long nLen); static CCString* createWithContentsOfFile(const char* pszFileName); }; diff --git a/tools/tolua++/CCTextureAtlas.pkg b/tools/tolua++/CCTextureAtlas.pkg index 78067dd172..680bdd0d84 100644 --- a/tools/tolua++/CCTextureAtlas.pkg +++ b/tools/tolua++/CCTextureAtlas.pkg @@ -21,6 +21,6 @@ class CCTextureAtlas : public CCObject void drawQuads(); - static CCTextureAtlas* textureAtlasWithFile(const char* file , unsigned int capacity); - static CCTextureAtlas* textureAtlasWithTexture(CCTexture2D *texture, unsigned int capacity); + static CCTextureAtlas* create(const char* file , unsigned int capacity); + static CCTextureAtlas* create(CCTexture2D *texture, unsigned int capacity); }; diff --git a/tools/tolua++/Cocos2d.pkg b/tools/tolua++/Cocos2d.pkg index ea5b7b7127..9479c1d8e9 100644 --- a/tools/tolua++/Cocos2d.pkg +++ b/tools/tolua++/Cocos2d.pkg @@ -34,6 +34,7 @@ $pfile "CCNode.pkg" $pfile "CCObject.pkg" $pfile "CCParallaxNode.pkg" $pfile "CCParticleSystem.pkg" +$pfile "CCParticleBatchNode.pkg" $pfile "CCPointExtension.pkg" $pfile "CCProgressTimer.pkg" $pfile "CCRenderTexture.pkg" diff --git a/tools/tolua++/basic.lua b/tools/tolua++/basic.lua index ccc153f707..dcfff784f9 100644 --- a/tools/tolua++/basic.lua +++ b/tools/tolua++/basic.lua @@ -105,7 +105,7 @@ local CCObjectTypes = { "CCMotionStreak", "CCParallaxNode", "CCParticleSystem", - "CCParticleSystemPoint", + "CCParticleBatchNode", "CCParticleSystemQuad", "CCProgressTimer", "CCRenderTexture", From bde351dda7bb41f7efaa2c6529f605fe254f62a7 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 27 Jun 2012 15:04:42 +0800 Subject: [PATCH 251/257] fixed a bug in CCSpriteFrame::getTexture. if( m_strTextureFilename.length() <= 0 ) // logic error, must be > 0 { return CCTextureCache::sharedTextureCache()->addImage(m_strTextureFilename.c_str()); } --- cocos2dx/sprite_nodes/CCSpriteFrame.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/sprite_nodes/CCSpriteFrame.cpp b/cocos2dx/sprite_nodes/CCSpriteFrame.cpp index e343530329..461606b6f2 100644 --- a/cocos2dx/sprite_nodes/CCSpriteFrame.cpp +++ b/cocos2dx/sprite_nodes/CCSpriteFrame.cpp @@ -199,7 +199,7 @@ CCTexture2D* CCSpriteFrame::getTexture(void) return m_pobTexture; } - if( m_strTextureFilename.length() <= 0 ) { + if( m_strTextureFilename.length() > 0 ) { return CCTextureCache::sharedTextureCache()->addImage(m_strTextureFilename.c_str()); } // no texture or texture filename From 88a3428f5ea4b5cc3d92262240bfc820ec5222ca Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 27 Jun 2012 16:37:41 +0800 Subject: [PATCH 252/257] fixed #1366: Updated vs2010 project configuration. --- testjs/proj.win32/testjs.win32.vcxproj | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/testjs/proj.win32/testjs.win32.vcxproj b/testjs/proj.win32/testjs.win32.vcxproj index 868a192d7c..dacb674b23 100644 --- a/testjs/proj.win32/testjs.win32.vcxproj +++ b/testjs/proj.win32/testjs.win32.vcxproj @@ -37,7 +37,7 @@ <_ProjectFileVersion>10.0.40219.1 $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ - true + false $(SolutionDir)$(Configuration).win32\ $(Configuration).win32\ false @@ -64,7 +64,7 @@ Disabled .;..\Classes;..\..\js\spidermonkey-win32\include;..\..\js\JSBindings;..\..\js\BindingsExample;..\..\cocos2dx;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories) - WIN32;_WINDOWS;STRICT;_DEBUG;COCOS2D_DEBUG=1;%(PreprocessorDefinitions) + WIN32;_WINDOWS;STRICT;_DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebugDLL @@ -72,7 +72,7 @@ Level3 EditAndContinue - 4251;4800;4244;4390;4065;4996;%(DisableSpecificWarnings) + 4267;4251;4244 _DEBUG;%(PreprocessorDefinitions) @@ -107,7 +107,7 @@ xcopy /Y /Q "$(SolutionDir)js\spidermonkey-win32\lib\*.*" "$(OutDir)" .;..\Classes;..\..\js\spidermonkey-win32\include;..\..\js\JSBindings;..\..\js\BindingsExample;..\..\cocos2dx;..\..\cocos2dx\include;..\..\cocos2dx\kazmath\include;..\..\cocos2dx\platform\win32;..\..\cocos2dx\platform\third_party\win32;..\..\cocos2dx\platform\third_party\win32\OGLES;..\..\CocosDenshion\Include;%(AdditionalIncludeDirectories) - WIN32;_WINDOWS;STRICT;NDEBUG;%(PreprocessorDefinitions) + WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) MultiThreadedDLL @@ -116,7 +116,7 @@ xcopy /Y /Q "$(SolutionDir)js\spidermonkey-win32\lib\*.*" "$(OutDir)" Level3 - 4251;%(DisableSpecificWarnings) + 4267;4251;4244 NDEBUG;%(PreprocessorDefinitions) From a20a80323b9778609b65c12f9e738ca8e43a9e2f Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 27 Jun 2012 17:04:54 +0800 Subject: [PATCH 253/257] fixed #1367: using CCString::createWithContentOfFile in CCBMFontConfiguration::parseConfigFile. --- cocos2dx/label_nodes/CCLabelBMFont.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/label_nodes/CCLabelBMFont.cpp b/cocos2dx/label_nodes/CCLabelBMFont.cpp index 47d94d5b34..d5401a2e92 100644 --- a/cocos2dx/label_nodes/CCLabelBMFont.cpp +++ b/cocos2dx/label_nodes/CCLabelBMFont.cpp @@ -487,7 +487,7 @@ void CCBMFontConfiguration::purgeFontDefDictionary() bool CCBMFontConfiguration::parseConfigFile(const char *controlFile) { std::string fullpath = CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(controlFile); - CCString *contents = CCString::create(fullpath.c_str()); + CCString *contents = CCString::createWithContentsOfFile(fullpath.c_str()); CCAssert(contents, "CCBMFontConfiguration::parseConfigFile | Open file error."); From 13793a9d757af07ad8b900e3eba77de415387b90 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 27 Jun 2012 17:08:50 +0800 Subject: [PATCH 254/257] fixed #1367: Updated ShaderTest.cpp, TileMapTest.cpp. --- tests/tests/ShaderTest/ShaderTest.cpp | 4 ++-- tests/tests/TileMapTest/TileMapTest.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/tests/ShaderTest/ShaderTest.cpp b/tests/tests/ShaderTest/ShaderTest.cpp index e9d0d99eeb..d99c78025e 100644 --- a/tests/tests/ShaderTest/ShaderTest.cpp +++ b/tests/tests/ShaderTest/ShaderTest.cpp @@ -475,7 +475,7 @@ bool SpriteBlur::initWithTexture(CCTexture2D* texture, const CCRect& rect) blur_ = ccp(1/s.width, 1/s.height); sub_[0] = sub_[1] = sub_[2] = sub_[3] = 0; - GLchar * fragSource = (GLchar*) CCString::create( + GLchar * fragSource = (GLchar*) CCString::createWithContentsOfFile( CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("Shaders/example_Blur.fsh"))->getCString(); CCGLProgram* pProgram = new CCGLProgram(); pProgram->initWithVertexShaderByteArray(ccPositionTextureColor_vert, fragSource); @@ -630,7 +630,7 @@ bool ShaderRetroEffect::init() { if( ShaderTestDemo::init() ) { - GLchar * fragSource = (GLchar*) CCString::create(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("Shaders/example_HorizontalColor.fsh"))->getCString(); + GLchar * fragSource = (GLchar*) CCString::createWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath("Shaders/example_HorizontalColor.fsh"))->getCString(); CCGLProgram *p = new CCGLProgram(); p->initWithVertexShaderByteArray(ccPositionTexture_vert, fragSource); diff --git a/tests/tests/TileMapTest/TileMapTest.cpp b/tests/tests/TileMapTest/TileMapTest.cpp index 17710948bf..334ccddbc6 100644 --- a/tests/tests/TileMapTest/TileMapTest.cpp +++ b/tests/tests/TileMapTest/TileMapTest.cpp @@ -1254,7 +1254,7 @@ TMXOrthoFromXMLTest::TMXOrthoFromXMLTest() string resources = "TileMaps"; // partial paths are OK as resource paths. string file = resources + "/orthogonal-test1.tmx"; - CCString* str = CCString::create(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(file.c_str())); + CCString* str = CCString::createWithContentsOfFile(CCFileUtils::sharedFileUtils()->fullPathFromRelativePath(file.c_str())); CCAssert(str != NULL, "Unable to open file"); CCTMXTiledMap *map = CCTMXTiledMap::create(str->getCString() ,resources.c_str()); From 33e32e987c3c70fe88c7e7d8a50f93ea64aea866 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 27 Jun 2012 18:44:25 +0800 Subject: [PATCH 255/257] Implement EffectsAdvancedTest (Effect4). --- .../EffectsAdvancedTest.cpp | 40 ++++++++++++++----- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp b/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp index b00ab2b3d9..8532c32ed5 100644 --- a/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp +++ b/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp @@ -123,22 +123,40 @@ std::string Effect3::title() // Effect4 // //------------------------------------------------------------------ + +class Lens3DTarget : public CCNode +{ +public: + virtual void setPosition(const CCPoint& var) + { + m_pLens3D->setPosition(var); + } + + static Lens3DTarget* create(CCLens3D* pAction) + { + Lens3DTarget* pRet = new Lens3DTarget(); + pRet->m_pLens3D = pAction; + pRet->autorelease(); + return pRet; + } +private: + CCLens3D* m_pLens3D; +}; + void Effect4::onEnter() { EffectAdvanceTextLayer::onEnter(); - CCActionInterval* lens = CCLens3D::create(ccp(100,180), 150, ccg(32,24), 10); - //id move = [MoveBy::create:5 position:ccp(400,0)]; + CCLens3D* lens = CCLens3D::create(ccp(100,180), 150, ccg(32,24), 10); + CCActionInterval* move = CCJumpBy::create(5, ccp(380,0), 100, 4); + CCActionInterval* move_back = move->reverse(); + CCActionInterval* seq = (CCActionInterval *)(CCSequence::create( move, move_back, NULL)); - /** - @todo we only support CCNode run actions now. - */ -// CCActionInterval* move = CCJumpBy::create(5, ccp(380,0), 100, 4); -// CCActionInterval* move_back = move->reverse(); -// CCActionInterval* seq = (CCActionInterval *)(CCSequence::create( move, move_back, NULL)); -// CCActionManager::sharedManager()->addAction(seq, lens, false); - - runAction( lens ); + CCDirector* director = CCDirector::sharedDirector(); + CCNode* pTarget = Lens3DTarget::create(lens); + director->getActionManager()->addAction(seq, pTarget, false); + addChild(pTarget); + this->runAction( lens ); } std::string Effect4::title() From 86942aedb4b50e0ec8663cec42a5d3c84ebf1889 Mon Sep 17 00:00:00 2001 From: James Chen Date: Wed, 27 Jun 2012 20:50:47 +0800 Subject: [PATCH 256/257] fixed #1368: Implement EffectsAdvancedTest (Effect4). Added some comments. --- .../EffectsAdvancedTest/EffectsAdvancedTest.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp b/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp index 8532c32ed5..77971b6da1 100644 --- a/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp +++ b/tests/tests/EffectsAdvancedTest/EffectsAdvancedTest.cpp @@ -140,6 +140,11 @@ public: return pRet; } private: + + Lens3DTarget() + : m_pLens3D(NULL) + {} + CCLens3D* m_pLens3D; }; @@ -152,10 +157,17 @@ void Effect4::onEnter() CCActionInterval* move_back = move->reverse(); CCActionInterval* seq = (CCActionInterval *)(CCSequence::create( move, move_back, NULL)); + /* In cocos2d-iphone, the type of action's target is 'id', so it supports using the instance of 'CCLens3D' as its target. + While in cocos2d-x, the target of action only supports CCNode or its subclass, + so we make an encapsulation for CCLens3D to achieve that. + */ + CCDirector* director = CCDirector::sharedDirector(); CCNode* pTarget = Lens3DTarget::create(lens); + // Please make sure the target been added to its parent. + this->addChild(pTarget); + director->getActionManager()->addAction(seq, pTarget, false); - addChild(pTarget); this->runAction( lens ); } From edca0871a6475686409fcb2486b5a3680f5ee835 Mon Sep 17 00:00:00 2001 From: James Chen Date: Thu, 28 Jun 2012 00:05:45 +0800 Subject: [PATCH 257/257] fixed #1369: Invoking CCLabelTTF:setPosition(x,y) in lua script causes crash. --- lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id | 2 +- tools/tolua++/CCNode.pkg | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id index 2751d17e80..22569a933f 100644 --- a/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id +++ b/lua/cocos2dx_support/LuaCocos2d.cpp.REMOVED.git-id @@ -1 +1 @@ -95b4c2c0005c822aadfa31b31b2e92d2d0e21662 \ No newline at end of file +045538ed12cb89c21bbddd81ce3dcb49bb1715b2 \ No newline at end of file diff --git a/tools/tolua++/CCNode.pkg b/tools/tolua++/CCNode.pkg index fa41e72604..9fc60990af 100644 --- a/tools/tolua++/CCNode.pkg +++ b/tools/tolua++/CCNode.pkg @@ -21,7 +21,6 @@ class CCNode : public CCObject void getPosition(float* x = 0, float* y = 0); float getPositionX(); float getPositionY(); - void setPosition(CCPoint newPosition); void setPosition(float x, float y); void setPositionX(float x); void setPositionY(float y);