From 155f2b2394e871d5826c904a5256efb546895098 Mon Sep 17 00:00:00 2001 From: preble Date: Thu, 7 Oct 2010 21:16:30 -0400 Subject: [PATCH] Improved startup error handling. --- English.lproj/MainMenu.xib | 62 +++++++++++++++++------------------ IJInventoryWindowController.m | 5 +-- IJMinecraftLevel.m | 6 ++++ InsideJobAppDelegate.h | 6 ++-- InsideJobAppDelegate.m | 14 ++------ 5 files changed, 45 insertions(+), 48 deletions(-) diff --git a/English.lproj/MainMenu.xib b/English.lproj/MainMenu.xib index d94a3c2..8f3656b 100644 --- a/English.lproj/MainMenu.xib +++ b/English.lproj/MainMenu.xib @@ -568,7 +568,7 @@ 3 - + World 4 @@ -580,7 +580,7 @@ 4 - + World 5 @@ -813,7 +813,7 @@ YES - + id 42 10 @@ -826,12 +826,12 @@ - + 337772096 -2147481600 Text Cell - + YES @@ -1261,14 +1261,6 @@ 495 - - - window - - - - 532 - window @@ -1325,6 +1317,14 @@ 584 + + + inventoryWindowController + + + + 590 + @@ -1760,8 +1760,8 @@ - - + + @@ -1811,7 +1811,7 @@ - + @@ -1896,36 +1896,36 @@ 585 - + 586 - + 587 - + YES - + 588 - + YES - + - + 589 - - + + @@ -2248,7 +2248,7 @@ - 589 + 590 @@ -2308,14 +2308,14 @@ InsideJobAppDelegate NSObject - window - NSWindow + inventoryWindowController + IJInventoryWindowController - window + inventoryWindowController - window - NSWindow + inventoryWindowController + IJInventoryWindowController diff --git a/IJInventoryWindowController.m b/IJInventoryWindowController.m index a9b0955..f5d574d 100644 --- a/IJInventoryWindowController.m +++ b/IJInventoryWindowController.m @@ -23,10 +23,6 @@ quickItem = [NSMutableArray array]; inventoryItem = [NSMutableArray array]; rootItems = [[NSArray alloc] initWithObjects:armorItem, quickItem, inventoryItem, nil]; - - [self worldSelectionChanged:nil]; - - [outlineView expandItem:nil expandChildren:YES]; } - (void)dealloc { @@ -100,6 +96,7 @@ } [outlineView reloadData]; + [outlineView expandItem:nil expandChildren:YES]; } - (void)saveToWorldAtIndex:(int)worldIndex diff --git a/IJMinecraftLevel.m b/IJMinecraftLevel.m index 1a0ced1..1ae8cf6 100644 --- a/IJMinecraftLevel.m +++ b/IJMinecraftLevel.m @@ -129,6 +129,12 @@ { NSString *path = [IJMinecraftLevel pathForSessionLockAtIndex:worldIndex]; NSData *data = [NSData dataWithContentsOfFile:path]; + + if (!data) + { + NSLog(@"Failed to read session lock at %@", path); + return; + } int64_t milliseconds = [IJMinecraftLevel int64FromData:data]; return checkValue == milliseconds; diff --git a/InsideJobAppDelegate.h b/InsideJobAppDelegate.h index c7c3e77..e5363f1 100644 --- a/InsideJobAppDelegate.h +++ b/InsideJobAppDelegate.h @@ -8,10 +8,12 @@ #import +@class IJInventoryWindowController; + @interface InsideJobAppDelegate : NSObject { - NSWindow *window; + IJInventoryWindowController *inventoryWindowController; } -@property (assign) IBOutlet NSWindow *window; +@property (assign) IBOutlet IJInventoryWindowController *inventoryWindowController; @end diff --git a/InsideJobAppDelegate.m b/InsideJobAppDelegate.m index 04936d4..481f44e 100644 --- a/InsideJobAppDelegate.m +++ b/InsideJobAppDelegate.m @@ -7,22 +7,14 @@ // #import "InsideJobAppDelegate.h" -#import "NBTContainer.h" -#import "IJMinecraftLevel.h" +#import "IJInventoryWindowController.h" @implementation InsideJobAppDelegate -@synthesize window; +@synthesize inventoryWindowController; - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - // Insert code here to initialize your application - -// NSData *fileData = [NSData dataWithContentsOfURL:[NSURL fileURLWithPath:@"../../world5-level.dat"]]; -// IJMinecraftLevel *level = [IJMinecraftLevel nbtContainerWithData:fileData]; -// [level inventory]; - -// NSData *newData = [level writeData]; -// [newData writeToURL:[NSURL fileURLWithPath:@"../../output.nbt"] atomically:NO]; + [inventoryWindowController worldSelectionChanged:nil]; } @end