Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename CCBReader to CCSBReader #1309

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cocos2d-ui/CCBReader/CCAnimationManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#import "CCBKeyframe.h"
#import "CCBSequence.h"
#import "CCBSequenceProperty.h"
#import "CCBReader.h"
#import "CCSBReader.h"
#import "CCBKeyframe.h"
#import "OALSimpleAudio.h"
#import "CCActionInterval.h"
Expand Down Expand Up @@ -261,7 +261,7 @@ - (CCAction*)actionFromKeyframe0:(CCBKeyframe*)kf0 andKeyframe1:(CCBKeyframe*)kf
return [CCBActionTweenColor actionWithDuration:duration key:name from:kf0.value to:kf1.value];
}
} else {
CCLOG(@"CCBReader: Failed to create animation for property: %@", name);
CCLOG(@"CCSBReader: Failed to create animation for property: %@", name);
}

return NULL;
Expand Down Expand Up @@ -333,7 +333,7 @@ - (CCAction*)easeAction:(CCAction*) action easingType:(int)easingType easingOpt:
CCActionInterval*intervalAction = (CCActionInterval*)action;
if(!intervalAction)
{
NSLog(@"CCBReader: Incorrect action type %@ for easing - must be a CCActionInterval subclass", action);
NSLog(@"CCSBReader: Incorrect action type %@ for easing - must be a CCActionInterval subclass", action);
return nil;
}

Expand Down Expand Up @@ -395,7 +395,7 @@ - (CCAction*)easeAction:(CCAction*) action easingType:(int)easingType easingOpt:
}
else
{
NSLog(@"CCBReader: Unkown easing type %d", easingType);
NSLog(@"CCSBReader: Unkown easing type %d", easingType);
return action;
}
}
Expand Down
2 changes: 1 addition & 1 deletion cocos2d-ui/CCBReader/CCBLocalizationManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
*/

#import "CCBLocalizationManager.h"
#import "CCBReader.h"
#import "CCSBReader.h"
#import "CCFileLocator.h"
#import "CCFile.h"

Expand Down
2 changes: 1 addition & 1 deletion cocos2d-ui/CCBReader/CCBReader_Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//

#import "CCBReader.h"
#import "CCSBReader.h"

#define kCCBVersion 11

Expand Down
2 changes: 1 addition & 1 deletion cocos2d-ui/CCBReader/CCBuilderReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* THE SOFTWARE.
*/

#import "CCBReader.h"
#import "CCSBReader.h"
#import "CCBAnimationManager.h"
#import "CCAnimationManager.h"
#import "CCBLocalizationManager.h"
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@
#import "CCAnimationManager.h"

/**
The CCBReader loads SpriteBuilder (CCB) documents.
The CCSBReader loads SpriteBuilder (CCB) documents.

For the most part you'll just use one of these two methods:

// load a CCB document as a CCNode instance
CCNode* myNode = [CCBReader load:@"MyNode"];
CCNode* myNode = [CCSBReader load:@"MyNode"];

// load a CCB document of type "Sprite" as a CCSprite instance
CCSprite* mySprite = (CCSprite*)[CCBReader load:@"MySprite"];
CCSprite* mySprite = (CCSprite*)[CCSBReader load:@"MySprite"];

// load a CCB document wrapped in a CCScene instance
CCScene* scene = [CCBReader loadAsScene:@"MyNode"];
CCScene* scene = [CCSBReader loadAsScene:@"MyNode"];

You can optionally pass an owner object to the CCBReader load methods. This owner object then gets assigned all of the SpriteBuilder document's member variables that are marked to be set to the "Owner".
You can optionally pass an owner object to the CCSBReader load methods. This owner object then gets assigned all of the SpriteBuilder document's member variables that are marked to be set to the "Owner".
In all other cases owner is nil and assigning variables to Owner discards their assignment.

When a SpriteBuilder document was loaded, all nodes created from the document will receive the didLoadFromCCB message, if implemented as follows:
Expand All @@ -62,7 +62,7 @@

Nodes created from a SpriteBuilder document will also have a valid CCAnimationManager instance assigned to their [CCNode animationManager] property.
*/
@interface CCBReader : NSObject
@interface CCSBReader : NSObject
{
NSData* data;
unsigned char* bytes;
Expand Down Expand Up @@ -95,11 +95,11 @@
/// -----------------------------------------------------------------------

/**
* Creates a new CCBReader. You don't normally need to do this because you can directly use most methods, ie `[CCBReader load:@"MyNode"];`.
* Creates a new CCSBReader. You don't normally need to do this because you can directly use most methods, ie `[CCSBReader load:@"MyNode"];`.
*
* @return A new CCBReader.
* @return A new CCSBReader.
*/
+ (CCBReader*) reader;
+ (CCSBReader *) reader;

/// -----------------------------------------------------------------------
/// @name Loading SpriteBuilder documents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
#define DEBUG_READER_PROPERTIES 0
#endif

static const NSString * const CCBI_PREFIX = @".ccbi";
static const NSString * const SBI_PREFIX = @".sbi";
static NSString * const CCBI_PREFIX = @".ccbi";
static NSString * const SBI_PREFIX = @".sbi";

@interface CCBFile : CCNode
{
Expand All @@ -67,7 +67,7 @@ @interface CCBFile : CCNode
@end


@interface CCBReader()
@interface CCSBReader ()
{

}
Expand All @@ -78,7 +78,7 @@ @interface CCBReader()
@end


@implementation CCBReader
@implementation CCSBReader

@synthesize animationManager;

Expand Down Expand Up @@ -111,19 +111,19 @@ - (void) dealloc
bytes = NULL;
}

static inline unsigned char readByte(CCBReader *self)
static inline unsigned char readByte(CCSBReader *self)
{
unsigned char byte = self->bytes[self->currentByte];
self->currentByte++;
return byte;
}

static inline BOOL readBool(CCBReader *self)
static inline BOOL readBool(CCSBReader *self)
{
return (BOOL)readByte(self);
}

static inline NSString *readUTF8(CCBReader *self)
static inline NSString *readUTF8(CCSBReader *self)
{
int b0 = readByte(self);
int b1 = readByte(self);
Expand All @@ -137,7 +137,7 @@ static inline BOOL readBool(CCBReader *self)
return str;
}

static inline void alignBits(CCBReader *self)
static inline void alignBits(CCSBReader *self)
{
if (self->currentBit)
{
Expand All @@ -164,7 +164,7 @@ static inline ptrdiff_t readVariableLengthIntFromArray(const uint8_t* buffer, ui
}


static inline int readIntWithSign(CCBReader *self, BOOL pSigned)
static inline int readIntWithSign(CCSBReader *self, BOOL pSigned)
{
unsigned int value = 0;
self->currentByte += readVariableLengthIntFromArray(self->bytes + self->currentByte, &value);
Expand Down Expand Up @@ -192,7 +192,7 @@ static inline int readIntWithSign(CCBReader *self, BOOL pSigned)
//DEPRICATED
//DEPRICATED
//DEPRICATED
static inline int readIntWithSignOLD(CCBReader *self, BOOL sign)
static inline int readIntWithSignOLD(CCSBReader *self, BOOL sign)
{
// Good luck groking this!
// The basic idea is to do as little bit reading as possible and use everything in a byte contexts and avoid loops; espc ones that iterate 8 * bytes-read
Expand Down Expand Up @@ -298,7 +298,7 @@ static inline int readIntWithSignOLD(CCBReader *self, BOOL sign)



static inline float readFloat(CCBReader *self)
static inline float readFloat(CCSBReader *self)
{
unsigned char type = readByte(self);

Expand Down Expand Up @@ -815,7 +815,7 @@ - (void) readPropertyForNode:(CCNode*) node parent:(CCNode*)parent isExtraProp:(
}
else
{
NSLog(@"CCBReader: Failed to set selector/target block for \"%@\" for target %@",selectorName,target);
NSLog(@"CCSBReader: Failed to set selector/target block for \"%@\" for target %@",selectorName,target);
}

#if DEBUG_READER_PROPERTIES
Expand All @@ -824,7 +824,7 @@ - (void) readPropertyForNode:(CCNode*) node parent:(CCNode*)parent isExtraProp:(
}
else
{
NSLog(@"CCBReader: Failed to find target for block");
NSLog(@"CCSBReader: Failed to find target for block");
}
}
}
Expand Down Expand Up @@ -863,7 +863,7 @@ - (void) readPropertyForNode:(CCNode*) node parent:(CCNode*)parent isExtraProp:(
NSAssert(d,@"[PROPERTY] %@ - kCCBPropTypeCCBFile - Failed to find ccb file: \"%@\", node class name: \"%@\", name: \"%@\", in ccb file: \"%@\"",
name, ccbFileName, [node class], [node name], _currentCCBFile);

CCBReader* reader = [[CCBReader alloc] init];
CCSBReader * reader = [[CCSBReader alloc] init];
reader.animationManager.rootContainerSize = parent.contentSize;

// Setup byte array & owner
Expand Down Expand Up @@ -956,7 +956,7 @@ -(CCEffect*)readEffects
Class nodeClass = NSClassFromString(className);
if (nodeClass == nil)
{
NSAssert(nil, @"CCBReader: Could not create class named: %@", className);
NSAssert(nil, @"CCSBReader: Could not create class named: %@", className);
return nil;
}

Expand Down Expand Up @@ -1133,7 +1133,7 @@ -(void)postDeserialization
return;

CCNode * mappedNode = nodeMapping[@(uuid)];
NSAssert(mappedNode != nil, @"CCBReader: Failed to find node UUID:%i", uuid);
NSAssert(mappedNode != nil, @"CCSBReader: Failed to find node UUID:%i", uuid);
[node setValue:mappedNode forKey:name];

}
Expand Down Expand Up @@ -1300,7 +1300,7 @@ -(CCNode*) nodeFromClassName:(NSString*)nodeClassName
Class nodeClass = NSClassFromString(nodeClassName);
if (nodeClass == nil)
{
NSAssert(nil, @"CCBReader: Could not create class named: %@", nodeClassName);
NSAssert(nil, @"CCSBReader: Could not create class named: %@", nodeClassName);
return nil;
}

Expand Down Expand Up @@ -1488,7 +1488,7 @@ - (CCNode*) readNodeGraphParent:(CCNode*)parent
}
else
{
NSLog(@"CCBReader: Couldn't find member variable: %@", memberVarAssignmentName);
NSLog(@"CCSBReader: Couldn't find member variable: %@", memberVarAssignmentName);
}
}
}
Expand Down Expand Up @@ -1758,7 +1758,7 @@ - (BOOL) readHeader
int version = readIntWithSignOLD(self, NO);
if (version != kCCBVersion)
{
[NSException raise:NSInternalInconsistencyException format:@"CCBReader: Incompatible ccbi file version (file: %d reader: %d)",version,kCCBVersion];
[NSException raise:NSInternalInconsistencyException format:@"CCSBReader: Incompatible ccbi file version (file: %d reader: %d)",version,kCCBVersion];
return NO;
}

Expand Down Expand Up @@ -1801,7 +1801,7 @@ + (void) callDidLoadFromCCBForNodeGraph:(CCNode*)nodeGraph
{
for (CCNode* child in nodeGraph.children)
{
[CCBReader callDidLoadFromCCBForNodeGraph:child];
[CCSBReader callDidLoadFromCCBForNodeGraph:child];
}

if ([nodeGraph respondsToSelector:@selector(didLoadFromCCB)])
Expand Down Expand Up @@ -1842,7 +1842,7 @@ - (CCNode*) loadWithData:(NSData*)d owner:(id)o
}

// Call didLoadFromCCB
[CCBReader callDidLoadFromCCBForNodeGraph:nodeGraph];
[CCSBReader callDidLoadFromCCBForNodeGraph:nodeGraph];

return nodeGraph;
}
Expand Down Expand Up @@ -1883,34 +1883,34 @@ +(void) setResourcePath:(NSString *)searchPath
[CCFileLocator sharedFileLocator].searchPaths = array;
}

+ (CCBReader*) reader
+ (CCSBReader *) reader
{
return [[CCBReader alloc] init];
return [[CCSBReader alloc] init];
}

+ (CCNode*) load:(NSString*) file owner:(id)owner
{
return [CCBReader load:file owner:owner parentSize:[CCDirector currentDirector].designSize];
return [CCSBReader load:file owner:owner parentSize:[CCDirector currentDirector].designSize];
}

+ (CCNode*) nodeGraphFromData:(NSData*) data owner:(id)owner parentSize:(CGSize)parentSize
{
return [[CCBReader reader] loadWithData:data owner:owner];
return [[CCSBReader reader] loadWithData:data owner:owner];
}

+ (CCNode*) load:(NSString*) file owner:(id)owner parentSize:(CGSize)parentSize
{
return [[CCBReader reader] nodeGraphFromFile:file owner:owner parentSize:parentSize];
return [[CCSBReader reader] nodeGraphFromFile:file owner:owner parentSize:parentSize];
}

+ (CCNode*) load:(NSString*) file
{
return [CCBReader load:file owner:NULL];
return [CCSBReader load:file owner:NULL];
}

+ (CCScene*) loadAsScene:(NSString *)file owner:(id)owner
{
return [CCBReader sceneWithNodeGraphFromFile:file owner:owner parentSize:[CCDirector currentDirector].designSize];
return [CCSBReader sceneWithNodeGraphFromFile:file owner:owner parentSize:[CCDirector currentDirector].designSize];
}

-(CCScene*) createScene
Expand All @@ -1920,15 +1920,15 @@ -(CCScene*) createScene

+ (CCScene*) sceneWithNodeGraphFromFile:(NSString *)file owner:(id)owner parentSize:(CGSize)parentSize
{
CCNode* node = [CCBReader load:file owner:owner parentSize:parentSize];
CCNode* node = [CCSBReader load:file owner:owner parentSize:parentSize];
CCScene* scene = [CCScene node];
[scene addChild:node];
return scene;
}

+ (CCScene*) loadAsScene:(NSString*) file
{
return [CCBReader loadAsScene:file owner:NULL];
return [CCSBReader loadAsScene:file owner:NULL];
}

+ (NSString*) ccbDirectoryPath
Expand Down
2 changes: 1 addition & 1 deletion cocos2d-ui/cocos2d-ui.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@
#import "CCTextField.h"
#import "CCSlider.h"

// CCBReader
// CCSBReader
#import "CCBuilderReader.h"
Loading