Skip to content
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
14 changes: 14 additions & 0 deletions CocosBuilder/CCNode/CCBPProperties.plist
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,20 @@
<key>displayName</key>
<string>Tag</string>
</dict>
<dict>
<key>affectsProperties</key>
<array>
<string>userStringData</string>
</array>
<key>default</key>
<string></string>
<key>type</key>
<string>UserStringData</string>
<key>name</key>
<string>userStringData</string>
<key>displayName</key>
<string>User Data</string>
</dict>
<dict>
<key>type</key>
<string>Check</string>
Expand Down
9 changes: 9 additions & 0 deletions CocosBuilder/Cocos2D iPhone/CCBXCocos2diPhoneWriter.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ - (void) setupPropTypes
[propTypes addObject:@"BlockCCControl"];
[propTypes addObject:@"FloatScale"];
[propTypes addObject:@"FloatXY"];
[propTypes addObject:@"UserStringData"];
}

- (id) init
Expand Down Expand Up @@ -446,6 +447,10 @@ - (void) writeProperty:(id) prop type:(NSString*)type name:(NSString*)name platf
[self writeInt:a withSign:NO];
[self writeInt:b withSign:NO];
}
else if ([type isEqualToString:@"UserStringData"])
{
[self writeCachedString:prop isPath: NO];
}
}

- (void) cacheStringsForNode:(NSDictionary*) node
Expand Down Expand Up @@ -588,6 +593,10 @@ - (void) cacheStringsForNode:(NSDictionary*) node
{
[self addToStringCache:value isPath:NO];
}
else if ([type isEqualToString:@"UserStringData"])
{
[self addToStringCache:value isPath:NO];
}
}

// Custom properties
Expand Down
278 changes: 150 additions & 128 deletions CocosBuilder/CocosBuilder.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

File renamed without changes.
19 changes: 16 additions & 3 deletions CocosBuilder/ccBuilder/CCBPublisher.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ - (id) initWithProjectSettings:(ProjectSettings*)settings warnings:(CCBWarnings*
warnings = [w retain];

// Setup extensions to copy
copyExtensions = [[NSArray alloc] initWithObjects:@"jpg",@"png", @"pvr", @"ccz", @"plist", @"fnt", @"ttf",@"js", @"json", @"wav",@"mp3",@"m4a",@"caf", nil];
copyExtensions = [[NSArray alloc] initWithObjects:@"jpg",@"png", @"pvr", @"ccz", @"plist", @"fnt", @"ttf",@"js", @"json", @"wav",@"mp3",@"m4a",@"caf",@"atlas", nil];

// Set format to use for exports
self.publishFormat = projectSettings.exporter;
Expand Down Expand Up @@ -324,6 +324,19 @@ - (BOOL) copyFileIfChanged:(NSString*)srcFile to:(NSString*)dstFile forResolutio
return YES;
}

- (BOOL)shouldPublishDir:(NSString *)dir
{
for (NSDictionary *dictionary in projectSettings.additionalPublishPaths) {
NSString *dirName = [dictionary objectForKey:@"path"];
NSString *additionalPublishPath = [NSString stringWithFormat:@"%@/%@",[projectSettings.projectPath stringByDeletingLastPathComponent],dirName];

if ([additionalPublishPath isEqualToString:dir])
return YES;
}

return NO;
}

- (BOOL) publishDirectory:(NSString*) dir subPath:(NSString*) subPath
{
CocosBuilderAppDelegate* ad = [CocosBuilderAppDelegate appDelegate];
Expand Down Expand Up @@ -405,7 +418,7 @@ - (BOOL) publishDirectory:(NSString*) dir subPath:(NSString*) subPath
else childPath = fileName;

// Skip resource independent directories
if ([resIndependentDirs containsObject:fileName]) continue;
if ([resIndependentDirs containsObject:fileName] && ![self shouldPublishDir:dir]) continue;

// Skip generated sprite sheets
if (isGeneratedSpriteSheet) continue;
Expand Down Expand Up @@ -482,7 +495,7 @@ - (BOOL) publishDirectory:(NSString*) dir subPath:(NSString*) subPath
// Copy file (and possibly convert)
if (![self copyFileIfChanged:filePath to:dstFile forResolution:NULL isSpriteSheet:isGeneratedSpriteSheet outDir:outDir srcDate: srcSpriteSheetDate]) return NO;

if (publishForResolutions)
if (publishForResolutions && [filePath rangeOfString:@"resources-"].location == NSNotFound)
{
for (NSString* res in publishForResolutions)
{
Expand Down
6 changes: 6 additions & 0 deletions CocosBuilder/ccBuilder/CCBReaderInternal.m
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ + (void) setProp:(NSString*)name ofType:(NSString*)type toValue:(id)serializedVa
[NodeGraphPropertySetter setNodeGraphForNode:node andProperty:name withFile:ccbFile parentSize:parentSize];
[extraProps setObject:ccbFile forKey:name];
}
else if ([type isEqualToString:@"UserStringData"])
{
NSString *userStringData = serializedValue;
if (!userStringData || ![userStringData isKindOfClass:[NSString class]]) userStringData = @"";
[extraProps setObject:userStringData forKey:name];
}
else
{
NSLog(@"WARNING Unrecognized property type: %@", type);
Expand Down
6 changes: 6 additions & 0 deletions CocosBuilder/ccBuilder/CCBWriterInternal.m
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,12 @@ + (NSMutableDictionary*) dictionaryFromCCObject:(CCNode *)node
if (!spriteFile) spriteFile = @"";
serializedValue = spriteFile;
}
else if ([type isEqualToString:@"UserStringData"])
{
NSString *userStringData = [extraProps objectForKey:name];
if (!userStringData) userStringData = @"";
serializedValue = userStringData;
}
else
{
NSLog(@"WARNING Unrecognized property type: %@", type);
Expand Down
6 changes: 4 additions & 2 deletions CocosBuilder/ccBuilder/CocosBuilder-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}-Ovenbits</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
Expand Down Expand Up @@ -44,13 +46,13 @@
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string>Icon.icns</string>
<string>CocosBuilderIcon.icns</string>
<key>CFBundleIdentifier</key>
<string>com.cocosbuilder.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<string>${PRODUCT_NAME}-Ovenbits</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
Expand Down
31 changes: 31 additions & 0 deletions CocosBuilder/ccBuilder/InspectorUserStringData.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* CocosBuilder: http://www.cocosbuilder.com
*
* Copyright (c) 2012 Zynga Inc.
*
* 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.
*/

#import "InspectorValue.h"

@interface InspectorUserStringData : InspectorValue<NSTextFieldDelegate>

@property (nonatomic,assign) NSString* text;

@end
53 changes: 53 additions & 0 deletions CocosBuilder/ccBuilder/InspectorUserStringData.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* CocosBuilder: http://www.cocosbuilder.com
*
* Copyright (c) 2012 Zynga Inc.
*
* 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.
*/

#import "InspectorUserStringData.h"
#import "CCNode+NodeInfo.h"

@implementation InspectorUserStringData

- (void) setText:(NSAttributedString *)text
{
NSString* str = [text string];
if (!str) str = @"";

[selection setExtraProp:str forKey:@"userStringData"];
}

- (NSAttributedString*) text
{
NSAttributedString* text = [[[NSAttributedString alloc] initWithString:[selection extraPropForKey:@"userStringData"]] autorelease];
return text;
}

- (void)controlTextDidChange:(NSNotification *)note
{
NSTextField * changedField = [note object];
NSString* text = [changedField stringValue];
if (!text) text = @"";

[selection setExtraProp:text forKey:@"userStringData"];
}

@end
Loading