From ac4463d633b4c1d7e36fb1d3813b51ed3a73c5c5 Mon Sep 17 00:00:00 2001 From: Nate Weaver Date: Sat, 7 Jul 2012 20:58:01 -0500 Subject: [PATCH] =?UTF-8?q?Comment=20out=20unused=20var;=20modify=20the=20?= =?UTF-8?q?-openResourceIn=E2=80=A6=20methods=20to=20return=20the=20used?= =?UTF-8?q?=20plug=20so=20we=20can=20add=20them=20to=20our=20window=20cont?= =?UTF-8?q?roller=20list=20in=20one=20place.=20Also=20add=20them=20to=20th?= =?UTF-8?q?e=20window=20controller=20list.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cocoa/Classes/Resource.m | 20 ++++--------- Cocoa/Classes/ResourceDocument.h | 6 ++-- Cocoa/Classes/ResourceDocument.m | 26 +++++++++------- Cocoa/Info.plist | 8 ++--- .../Hex Editor/English.lproj/HexWindow.xib | 30 +++++++++++++++---- .../TemplateWindowController.m | 2 +- ResKnife.xcodeproj/project.pbxproj | 20 ++++++------- 7 files changed, 63 insertions(+), 49 deletions(-) diff --git a/Cocoa/Classes/Resource.m b/Cocoa/Classes/Resource.m index 02b34f1..c3ed8e2 100644 --- a/Cocoa/Classes/Resource.m +++ b/Cocoa/Classes/Resource.m @@ -60,9 +60,7 @@ NSString *RKResourcePboardType = @"RKResourcePboardType"; + (Resource *)getResourceOfType:(NSString *)typeValue andID:(NSNumber *)resIDValue inDocument:(NSDocument *)searchDoc { - NSDocument *doc; - NSEnumerator *enumerator = [[[NSDocumentController sharedDocumentController] documents] objectEnumerator]; - while(doc = [enumerator nextObject]) + for (NSDocument *doc in [[NSDocumentController sharedDocumentController] documents]) { if(searchDoc == nil || searchDoc == doc) { @@ -79,9 +77,7 @@ NSString *RKResourcePboardType = @"RKResourcePboardType"; + (NSArray *)allResourcesOfType:(NSString *)typeValue inDocument:(NSDocument *)searchDoc { NSMutableArray *array = [NSMutableArray array]; - NSDocument *doc; - NSEnumerator *enumerator = [[[NSDocumentController sharedDocumentController] documents] objectEnumerator]; - while(doc = [enumerator nextObject]) + for (NSDocument *doc in [[NSDocumentController sharedDocumentController] documents]) { // parse document for resources if(searchDoc == nil || searchDoc == doc) @@ -92,9 +88,7 @@ NSString *RKResourcePboardType = @"RKResourcePboardType"; + (Resource *)resourceOfType:(NSString *)typeValue withName:(NSString *)nameValue inDocument:(NSDocument *)searchDoc { - NSDocument *doc; - NSEnumerator *enumerator = [[[NSDocumentController sharedDocumentController] documents] objectEnumerator]; - while(doc = [enumerator nextObject]) + for (NSDocument *doc in [[NSDocumentController sharedDocumentController] documents]) { if(searchDoc == nil || searchDoc == doc) { @@ -108,9 +102,7 @@ NSString *RKResourcePboardType = @"RKResourcePboardType"; + (Resource *)resourceOfType:(NSString *)typeValue andID:(NSNumber *)resIDValue inDocument:(NSDocument *)searchDoc { - NSDocument *doc; - NSEnumerator *enumerator = [[[NSDocumentController sharedDocumentController] documents] objectEnumerator]; - while(doc = [enumerator nextObject]) + for (NSDocument *doc in [[NSDocumentController sharedDocumentController] documents]) { if(searchDoc == nil || searchDoc == doc) { @@ -125,9 +117,7 @@ NSString *RKResourcePboardType = @"RKResourcePboardType"; // should probably be in resource document, not resource, but it fits in with the above methods quite well + (NSDocument *)documentForResource:(Resource *)resource { - NSDocument *doc; - NSEnumerator *enumerator = [[[NSDocumentController sharedDocumentController] documents] objectEnumerator]; - while(doc = [enumerator nextObject]) + for (NSDocument *doc in [[NSDocumentController sharedDocumentController] documents]) { Resource *res; NSEnumerator *enumerator2 = [[(ResourceDocument *)doc resources] objectEnumerator]; diff --git a/Cocoa/Classes/ResourceDocument.h b/Cocoa/Classes/ResourceDocument.h index 269b3d0..bb4a569 100644 --- a/Cocoa/Classes/ResourceDocument.h +++ b/Cocoa/Classes/ResourceDocument.h @@ -34,9 +34,9 @@ - (IBAction)openResources:(id)sender; - (IBAction)openResourcesInTemplate:(id)sender; - (IBAction)openResourcesAsHex:(id)sender; -- (void)openResourceUsingEditor:(Resource *)resource; -- (void)openResource:(Resource *)resource usingTemplate:(NSString *)templateName; -- (void)openResourceAsHex:(Resource *)resource; +- (id )openResourceUsingEditor:(Resource *)resource; +- (id )openResource:(Resource *)resource usingTemplate:(NSString *)templateName; +- (id )openResourceAsHex:(Resource *)resource; - (IBAction)playSound:(id)sender; - (void)sound:(NSSound *)sound didFinishPlaying:(BOOL)finished; diff --git a/Cocoa/Classes/ResourceDocument.m b/Cocoa/Classes/ResourceDocument.m index 6f0ba25..d941b73 100644 --- a/Cocoa/Classes/ResourceDocument.m +++ b/Cocoa/Classes/ResourceDocument.m @@ -900,8 +900,11 @@ static NSString *RKExportItemIdentifier = @"com.nickshanks.resknife.toolbar.exp Resource *resource; NSArray *selected = [outlineView selectedItems]; NSEnumerator *enumerator = [selected objectEnumerator]; - while(resource = [enumerator nextObject]) - [self openResourceUsingEditor:resource]; + while(resource = [enumerator nextObject]) { + id usedPlug = [self openResourceUsingEditor:resource]; + if ([usedPlug isKindOfClass:[NSWindowController class]]) + [self addWindowController:usedPlug]; + } } - (IBAction)openResourcesInTemplate:(id)sender @@ -934,11 +937,12 @@ static NSString *RKExportItemIdentifier = @"com.nickshanks.resknife.toolbar.exp REVISIONS: 2003-07-31 UK Changed to use plugin registry instead of file name. + 2012-07-07 NW Changed to return the used plugin. -------------------------------------------------------------------------- */ /* Method name should be changed to: -(void)openResource:(Resource *)resource usingEditor:(Class)overrideEditor */ -- (void)openResourceUsingEditor:(Resource *)resource +- (id )openResourceUsingEditor:(Resource *)resource { Class editorClass = [[RKEditorRegistry defaultRegistry] editorForType:[resource type]]; @@ -949,11 +953,11 @@ static NSString *RKExportItemIdentifier = @"com.nickshanks.resknife.toolbar.exp // update: doug says window controllers automatically release themselves when their window is closed. All default plugs have a window controller as their principal class, but 3rd party ones might not [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resourceDataDidChange:) name:ResourceDataDidChangeNotification object:resource]; id plug = [(id )[editorClass alloc] initWithResource:resource]; - if(plug) return; + if(plug) return plug; } // if no editor exists, or the editor is broken, open using template - [self openResource:resource usingTemplate:[resource type]]; + return [self openResource:resource usingTemplate:[resource type]]; } @@ -967,9 +971,10 @@ static NSString *RKExportItemIdentifier = @"com.nickshanks.resknife.toolbar.exp REVISIONS: 2003-07-31 UK Changed to use plugin registry instead of file name. + 2012-07-07 NW Changed to return the used plugin. -------------------------------------------------------------------------- */ -- (void)openResource:(Resource *)resource usingTemplate:(NSString *)templateName +- (id )openResource:(Resource *)resource usingTemplate:(NSString *)templateName { // opens resource in template using TMPL resource with name templateName Class editorClass = [[RKEditorRegistry defaultRegistry] editorForType:@"Template Editor"]; @@ -983,11 +988,11 @@ static NSString *RKExportItemIdentifier = @"com.nickshanks.resknife.toolbar.exp { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resourceDataDidChange:) name:ResourceDataDidChangeNotification object:resource]; id plug = [(id )[editorClass alloc] initWithResources:resource, tmpl, nil]; - if(plug) return; + if(plug) return plug; } // if no template exists, or template editor is broken, open as hex - [self openResourceAsHex:resource]; + return [self openResourceAsHex:resource]; } /*! @@ -995,18 +1000,19 @@ static NSString *RKExportItemIdentifier = @"com.nickshanks.resknife.toolbar.exp @author Nicholas Shanks @created 2001 @updated 2003-07-31 UK: Changed to use plugin registry instead of file name. + 2012-07-07 NW: Changed to return the used plugin. @description Open a hex editor for the specified Resource instance. This looks up the hexadecimal editor in the plugin registry and then instantiates an editor object, handing it the resource. @param resource Resource to edit */ -- (void)openResourceAsHex:(Resource *)resource +- (id )openResourceAsHex:(Resource *)resource { Class editorClass = [[RKEditorRegistry defaultRegistry] editorForType: @"Hexadecimal Editor"]; // bug: I alloc a plug instance here, but have no idea where I should dealloc it, perhaps the plug ought to call [self autorelease] when it's last window is closed? // update: doug says window controllers automatically release themselves when their window is closed. [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(resourceDataDidChange:) name:ResourceDataDidChangeNotification object:resource]; id plugController = [(id )[editorClass alloc] initWithResource:resource]; -#pragma unused(plugController) + return plugController; } /*! diff --git a/Cocoa/Info.plist b/Cocoa/Info.plist index a6d4c43..b5983aa 100644 --- a/Cocoa/Info.plist +++ b/Cocoa/Info.plist @@ -12,7 +12,7 @@ rsrc CFBundleTypeIconFile - Resource file.icns + Resource file CFBundleTypeName ResourceMap CFBundleTypeOSTypes @@ -53,11 +53,11 @@ CFBundleExecutable - ResKnife Cocoa + ResKnife CFBundleGetInfoString A resource editor for Mac OS X. CFBundleIconFile - ResKnife.icns + ResKnife CFBundleIdentifier com.nickshanks.resknife CFBundleInfoDictionaryVersion @@ -71,7 +71,7 @@ CFBundleSignature ResK CFBundleVersion - 19 + 20 NSAppleScriptEnabled NSMainNibFile diff --git a/Cocoa/Plug-Ins/Hex Editor/English.lproj/HexWindow.xib b/Cocoa/Plug-Ins/Hex Editor/English.lproj/HexWindow.xib index 09cb94d..40b69fd 100644 --- a/Cocoa/Plug-Ins/Hex Editor/English.lproj/HexWindow.xib +++ b/Cocoa/Plug-Ins/Hex Editor/English.lproj/HexWindow.xib @@ -164,7 +164,7 @@ {226, 140} - + 256 @@ -193,6 +193,7 @@ {74, 300} + @@ -232,7 +233,7 @@ 1 - 33557344 + 2912 0 @@ -279,11 +280,12 @@ {74, 300} + - {1, -1} + {5, 5} 0 4 @@ -293,6 +295,7 @@ -2147483392 {{-100, -100}, {15, 298}} + _doScroller: @@ -303,6 +306,7 @@ -2147483392 {{-100, -100}, {87, 18}} + 1 @@ -313,6 +317,7 @@ {{0, 20}, {74, 300}} + 133120 @@ -351,6 +356,7 @@ {339, 298} + @@ -372,7 +378,7 @@ 1 - 33566563 + 12131 0 @@ -397,6 +403,7 @@ {{1, 1}, {339, 298}} + @@ -429,8 +436,9 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA -2147483392 - {{-100, -100}, {15, 68}} + {{-100, -100}, {15, 298}} + _doScroller: @@ -441,6 +449,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA -2147483392 {{-100, -100}, {87, 18}} + 1 @@ -451,6 +460,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA {{82, 20}, {341, 300}} + 133122 @@ -489,6 +499,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA {138, 298} + @@ -510,7 +521,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA 1 - 33566563 + 12131 0 @@ -536,6 +547,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA {{1, 1}, {138, 298}} + @@ -547,6 +559,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA 256 {{124, 1}, {15, 298}} + _doScroller: @@ -557,6 +570,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA -2147483392 {{-100, -100}, {87, 18}} + 1 @@ -567,6 +581,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA {{431, 20}, {140, 300}} + 133138 @@ -578,6 +593,7 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA 290 {{4, 2}, {546, 17}} + YES 67239424 @@ -605,6 +621,8 @@ AAEAAQAAAT0AAwAAAAEAAgAAAVIAAwAAAAEAAQAAAVMAAwAAAAIAAQABAAAAAA {570, 319} + + {{0, 0}, {1920, 1178}} diff --git a/Cocoa/Plug-Ins/Template Editor/TemplateWindowController.m b/Cocoa/Plug-Ins/Template Editor/TemplateWindowController.m index 64632e1..712f1b6 100644 --- a/Cocoa/Plug-Ins/Template Editor/TemplateWindowController.m +++ b/Cocoa/Plug-Ins/Template Editor/TemplateWindowController.m @@ -124,7 +124,7 @@ Class cc = [clone class]; BOOL pushedCounter = NO; - BOOL pushedKey = NO; + //BOOL pushedKey = NO; if(cc == [ElementOCNT class]) { [stream pushCounter:(ElementOCNT *)clone]; pushedCounter = YES; } if(cc == [ElementKBYT class] || diff --git a/ResKnife.xcodeproj/project.pbxproj b/ResKnife.xcodeproj/project.pbxproj index 6a78c85..55ad3e5 100644 --- a/ResKnife.xcodeproj/project.pbxproj +++ b/ResKnife.xcodeproj/project.pbxproj @@ -445,7 +445,7 @@ E15CFF80099BECAE004929B6 /* ElementDATE.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ElementDATE.h; sourceTree = ""; }; E15CFF81099BECAF004929B6 /* ElementDATE.m */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.objc; path = ElementDATE.m; sourceTree = ""; }; E17ADBC006A2132800842474 /* NovaTools.plugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = NovaTools.plugin; sourceTree = BUILT_PRODUCTS_DIR; }; - E18BF58C069FEA1400F076B8 /* ResKnife Cocoa.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "ResKnife Cocoa.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + E18BF58C069FEA1400F076B8 /* ResKnife.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ResKnife.app; sourceTree = BUILT_PRODUCTS_DIR; }; E18BF5A6069FEA1400F076B8 /* Hexadecimal Editor.plugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Hexadecimal Editor.plugin"; sourceTree = BUILT_PRODUCTS_DIR; }; E18BF5B6069FEA1400F076B8 /* Nicks Template Editor.plugin */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Nicks Template Editor.plugin"; sourceTree = BUILT_PRODUCTS_DIR; }; E18BF68D069FEA1800F076B8 /* Ulis Template Editor.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Ulis Template Editor.bundle"; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -946,7 +946,7 @@ F5B588110156D30301000001 /* Products */ = { isa = PBXGroup; children = ( - E18BF58C069FEA1400F076B8 /* ResKnife Cocoa.app */, + E18BF58C069FEA1400F076B8 /* ResKnife.app */, E18BF5A6069FEA1400F076B8 /* Hexadecimal Editor.plugin */, E18BF5B6069FEA1400F076B8 /* Nicks Template Editor.plugin */, E18BF6C8069FEA1900F076B8 /* Template Editor.plugin */, @@ -1308,9 +1308,9 @@ productReference = B2FCA78A15A66ACE00696598 /* PICT Editor.plugin */; productType = "com.apple.product-type.bundle"; }; - E18BF537069FEA1300F076B8 /* ResKnife Cocoa */ = { + E18BF537069FEA1300F076B8 /* ResKnife */ = { isa = PBXNativeTarget; - buildConfigurationList = E13F7ED908F0411100E2A5CB /* Build configuration list for PBXNativeTarget "ResKnife Cocoa" */; + buildConfigurationList = E13F7ED908F0411100E2A5CB /* Build configuration list for PBXNativeTarget "ResKnife" */; buildPhases = ( E18BF53C069FEA1300F076B8 /* Headers */, E18BF553069FEA1300F076B8 /* Resources */, @@ -1330,10 +1330,10 @@ E13F836508F139E900E2A5CB /* PBXTargetDependency */, B229EEE315A4BB720032C12C /* PBXTargetDependency */, ); - name = "ResKnife Cocoa"; + name = ResKnife; productInstallPath = "$(USER_APPS_DIR)"; productName = "ResKnife Cocoa"; - productReference = E18BF58C069FEA1400F076B8 /* ResKnife Cocoa.app */; + productReference = E18BF58C069FEA1400F076B8 /* ResKnife.app */; productType = "com.apple.product-type.application"; }; E18BF58E069FEA1400F076B8 /* Hex Editor Cocoa */ = { @@ -1501,7 +1501,7 @@ projectDirPath = ""; projectRoot = ""; targets = ( - E18BF537069FEA1300F076B8 /* ResKnife Cocoa */, + E18BF537069FEA1300F076B8 /* ResKnife */, E18BF58E069FEA1400F076B8 /* Hex Editor Cocoa */, E18BF69E069FEA1800F076B8 /* Template Editor Cocoa */, E18BF5A7069FEA1400F076B8 /* Nick's Template Editor Cocoa */, @@ -2353,7 +2353,7 @@ GCC_VERSION = com.apple.compilers.llvm.clang.1_0; INFOPLIST_FILE = Cocoa/Info.plist; MACOSX_DEPLOYMENT_TARGET = 10.6; - PRODUCT_NAME = "ResKnife Cocoa"; + PRODUCT_NAME = ResKnife; WARNING_CFLAGS = ( "-Wmost", "-Wno-four-char-constants", @@ -2372,7 +2372,7 @@ GCC_VERSION = com.apple.compilers.llvm.clang.1_0; INFOPLIST_FILE = Cocoa/Info.plist; MACOSX_DEPLOYMENT_TARGET = 10.6; - PRODUCT_NAME = "ResKnife Cocoa"; + PRODUCT_NAME = ResKnife; WARNING_CFLAGS = ( "-Wmost", "-Wno-four-char-constants", @@ -2693,7 +2693,7 @@ defaultConfigurationIsVisible = 0; defaultConfigurationName = Debug; }; - E13F7ED908F0411100E2A5CB /* Build configuration list for PBXNativeTarget "ResKnife Cocoa" */ = { + E13F7ED908F0411100E2A5CB /* Build configuration list for PBXNativeTarget "ResKnife" */ = { isa = XCConfigurationList; buildConfigurations = ( E13F7EDA08F0411100E2A5CB /* Debug */,