Removed CCBReader to avoid conflicts.

This commit is contained in:
Nicolas Gramlich 2012-05-30 11:30:53 -07:00
parent 56ea340314
commit a7d4fa619d
2 changed files with 0 additions and 208 deletions

View File

@ -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;
}

View File

@ -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<std::string> * 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__