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

Fix for issue #224 #366

Open
wants to merge 1 commit 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
1 change: 1 addition & 0 deletions CocosBuilder/ccBuilder/CocosBuilderAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ enum {
- (void) switchToDocument:(CCBDocument*) document;
- (void) closeLastDocument;
- (void) openFile:(NSString*) fileName;
- (void) openImageFile:(NSString*) fileName;
- (void) openJSFile:(NSString*) fileName;
- (void) openJSFile:(NSString*) fileName highlightLine:(int)line;
- (void) resetJSFilesLineHighlight;
Expand Down
43 changes: 41 additions & 2 deletions CocosBuilder/ccBuilder/CocosBuilderAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ - (void) prepareForDocumentSwitch
CocosScene* cs = [CocosScene cocosScene];

if (![self hasOpenedDocument]) return;
currentDocument.docData = [self docDataFromCurrentNodeGraph];
// currentDocument.docData = [self docDataFromCurrentNodeGraph];
currentDocument.stageZoom = [cs stageZoom];
currentDocument.stageScrollOffset = [cs scrollOffset];
}
Expand Down Expand Up @@ -1357,7 +1357,9 @@ - (void) openFile:(NSString*) fileName
CCBDocument* openDoc = [self findDocumentFromFile:fileName];
if (openDoc)
{
[tabView selectTabViewItem:[self tabViewItemFromDoc:openDoc]];
NSTabViewItem* item = [self tabViewItemFromDoc:openDoc];
[self switchToDocument:openDoc forceReload:YES];
[tabView selectTabViewItem:item];
return;
}

Expand Down Expand Up @@ -1554,6 +1556,43 @@ - (void)application:(NSApplication *)sender openFiles:(NSArray *)filenames
}
}

- (void) openImageFile:(NSString*) fileName
{
[[[CCDirector sharedDirector] view] lockOpenGLContext];

[loadedSelectedNodes removeAllObjects];
[[CocosScene cocosScene] setStageSize:CGSizeMake(800, 640) centeredOrigin:YES];

if (![[NSFileManager defaultManager] fileExistsAtPath:fileName])
{
NSRange slash = [fileName rangeOfString:@"/" options:NSBackwardsSearch];

if (slash.location != NSNotFound)
{
fileName = [fileName stringByReplacingCharactersInRange:slash withString: @"/resources-auto/"];
}
}
CCSprite* sp = [CCSprite spriteWithFile:fileName];

[[CocosScene cocosScene] replaceRootNodeWith:sp];

// Setup a default timeline
NSMutableArray* sequences = [NSMutableArray array];

SequencerSequence* seq = [[SequencerSequence alloc] init];
seq.name = @"Default Timeline";
seq.sequenceId = 0;
seq.autoPlay = YES;
[sequences addObject:seq];
[seq release];

currentDocument.sequences = sequences;
sequenceHandler.currentSequence = seq;
[sequenceHandler updateOutlineViewSelection];

[[[CCDirector sharedDirector] view] unlockOpenGLContext];
}

- (void) openJSFile:(NSString*) fileName
{
[self openJSFile:fileName highlightLine:0];
Expand Down
4 changes: 4 additions & 0 deletions CocosBuilder/ccBuilder/ResourceManagerOutlineHandler.m
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,10 @@ - (void) doubleClicked:(id)sender
{
[[CocosBuilderAppDelegate appDelegate] openJSFile:res.filePath];
}
else if (res.type == kCCBResTypeImage)
{
[[CocosBuilderAppDelegate appDelegate] openImageFile:res.filePath];
}
}

}
Expand Down