Skip to content

Commit

Permalink
Added Open World auto-populated menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
preble committed Mar 27, 2011
1 parent 86dde71 commit 5efda97
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Classes/InsideJobAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

#import <Cocoa/Cocoa.h>

@interface InsideJobAppDelegate : NSObject <NSApplicationDelegate> {

@interface InsideJobAppDelegate : NSObject <NSApplicationDelegate, NSMenuDelegate> {
NSArray *menuWorldURLs;
}

@end
32 changes: 32 additions & 0 deletions Classes/InsideJobAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#import "InsideJobAppDelegate.h"
#import "IJMinecraftLevel.h"

@implementation InsideJobAppDelegate

Expand All @@ -19,4 +20,35 @@ - (BOOL)applicationShouldOpenUntitledFile:(NSApplication *)sender
return NO;
}

#pragma mark -
#pragma mark Menu Delegate

//- (void)menuNeedsUpdate:(NSMenu*)menu
//{
//}

- (NSInteger)numberOfItemsInMenu:(NSMenu*)menu
{
[menuWorldURLs release];
menuWorldURLs = [[IJMinecraftLevel minecraftLevelURLs] retain];
return [menuWorldURLs count];
}

- (BOOL)menu:(NSMenu*)menu updateItem:(NSMenuItem*)item atIndex:(NSInteger)index shouldCancel:(BOOL)shouldCancel
{
NSURL *url = [menuWorldURLs objectAtIndex:index];
[item setTitle:[NSString stringWithFormat:@"%@", [[url URLByDeletingLastPathComponent] lastPathComponent]]];
[item setTag:index];
[item setTarget:self];
[item setAction:@selector(openMenuWorld:)];
return YES;
}

- (void)openMenuWorld:(id)sender
{
NSUInteger index = [sender tag];
NSURL *url = [menuWorldURLs objectAtIndex:index];
[[NSDocumentController sharedDocumentController] openDocumentWithContentsOfURL:url display:YES error:nil];
}

@end
75 changes: 60 additions & 15 deletions English.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,21 @@
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="167370130">
<reference key="NSMenu" ref="720053764"/>
<string key="NSTitle">Open World</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
<string key="NSAction">submenuAction:</string>
<object class="NSMenu" key="NSSubmenu" id="376776033">
<string key="NSTitle">Open World</string>
<object class="NSMutableArray" key="NSMenuItems">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
</object>
</object>
<object class="NSMenuItem" id="642641384">
<reference key="NSMenu" ref="720053764"/>
<string key="NSTitle">Open Recent</string>
Expand Down Expand Up @@ -697,6 +712,14 @@
</object>
<int key="connectionID">710</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="376776033"/>
<reference key="destination" ref="976324537"/>
</object>
<int key="connectionID">717</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
Expand Down Expand Up @@ -788,6 +811,7 @@
<reference ref="234194208"/>
<reference ref="642641384"/>
<reference ref="1013332452"/>
<reference ref="167370130"/>
</object>
<reference key="parent" ref="379814623"/>
</object>
Expand Down Expand Up @@ -1050,20 +1074,6 @@
</object>
<reference key="parent" ref="720053764"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">699</int>
<reference key="object" ref="285001729"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="630677140"/>
</object>
<reference key="parent" ref="642641384"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">700</int>
<reference key="object" ref="630677140"/>
<reference key="parent" ref="285001729"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">691</int>
<reference key="object" ref="234194208"/>
Expand All @@ -1084,6 +1094,37 @@
<reference key="object" ref="579971712"/>
<reference key="parent" ref="720053764"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">699</int>
<reference key="object" ref="285001729"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="630677140"/>
</object>
<reference key="parent" ref="642641384"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">700</int>
<reference key="object" ref="630677140"/>
<reference key="parent" ref="285001729"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">714</int>
<reference key="object" ref="167370130"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="376776033"/>
</object>
<reference key="parent" ref="720053764"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">715</int>
<reference key="object" ref="376776033"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<reference key="parent" ref="167370130"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
Expand Down Expand Up @@ -1173,6 +1214,8 @@
<string>58.ImportedFromIB2</string>
<string>669.IBPluginDependency</string>
<string>671.IBPluginDependency</string>
<string>714.IBPluginDependency</string>
<string>715.IBPluginDependency</string>
<string>81.IBEditorWindowLastContentRect</string>
<string>81.IBPluginDependency</string>
<string>81.ImportedFromIB2</string>
Expand Down Expand Up @@ -1267,6 +1310,8 @@
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{483, 773}, {178, 63}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
Expand All @@ -1289,7 +1334,7 @@
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">710</int>
<int key="maxID">717</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand Down

0 comments on commit 5efda97

Please sign in to comment.