From d17f03ddbf94dc5ea45678dc3b692b2cb77247a4 Mon Sep 17 00:00:00 2001 From: preble Date: Thu, 7 Oct 2010 21:29:41 -0400 Subject: [PATCH] Added status field and some dirty handling. Added "delete" to clear out a slot. --- English.lproj/MainMenu.xib | 110 ++++++++++++++++++++++++++-------- IJInventoryWindowController.h | 2 + IJInventoryWindowController.m | 37 +++++++++++- ItemPicker.xib | 21 ++++--- 4 files changed, 134 insertions(+), 36 deletions(-) diff --git a/English.lproj/MainMenu.xib b/English.lproj/MainMenu.xib index 8f3656b..263a136 100644 --- a/English.lproj/MainMenu.xib +++ b/English.lproj/MainMenu.xib @@ -12,8 +12,8 @@ YES - - + + YES @@ -310,8 +310,7 @@ Delete - - 1048576 + CA 2147483647 @@ -568,7 +567,7 @@ 3 - + World 4 @@ -580,7 +579,7 @@ 4 - + World 5 @@ -670,7 +669,7 @@ 6 System controlBackgroundColor - + 3 MC42NjY2NjY2NjY3AA @@ -813,7 +812,7 @@ YES - + id 42 10 @@ -826,12 +825,12 @@ - + 337772096 -2147481600 Text Cell - + YES @@ -1041,6 +1040,27 @@ QSAAAEEgAABBmAAAQZgAAA + + + 266 + {{186, 381}, {348, 14}} + + YES + + 68288064 + 71435264 + Status + + + + 6 + System + controlColor + + + + + {551, 419} @@ -1325,6 +1345,14 @@ 590 + + + statusTextField + + + + 593 + @@ -1693,6 +1721,7 @@ YES + @@ -1760,8 +1789,8 @@ - - + + @@ -1811,7 +1840,7 @@ - + @@ -1896,36 +1925,50 @@ 585 - + 586 - + 587 - + YES - + 588 - + YES - + - + 589 - - + + + + + 591 + + + YES + + + + + + 592 + + @@ -2063,6 +2106,8 @@ 589.IBNumberFormatterBehaviorMetadataKey 589.IBNumberFormatterLocalizesFormatMetadataKey 589.IBPluginDependency + 591.IBPluginDependency + 592.IBPluginDependency 74.IBPluginDependency 74.ImportedFromIB2 75.IBPluginDependency @@ -2122,7 +2167,7 @@ com.apple.InterfaceBuilder.CocoaPlugin - {{525, 653}, {151, 183}} + {{525, 653}, {158, 183}} com.apple.InterfaceBuilder.CocoaPlugin {{187, 434}, {243, 243}} @@ -2215,6 +2260,8 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -2248,7 +2295,7 @@ - 590 + 593 @@ -2272,11 +2319,13 @@ YES outlineView + statusTextField worldPopup YES NSOutlineView + NSTextField NSPopUpButton @@ -2285,6 +2334,7 @@ YES outlineView + statusTextField worldPopup @@ -2293,6 +2343,10 @@ outlineView NSOutlineView + + statusTextField + NSTextField + worldPopup NSPopUpButton @@ -2878,6 +2932,14 @@ AppKit.framework/Headers/NSText.h + + NSTextField + NSControl + + IBFrameworkSource + AppKit.framework/Headers/NSTextField.h + + NSTextFieldCell NSActionCell diff --git a/IJInventoryWindowController.h b/IJInventoryWindowController.h index 5e401de..7c169fc 100644 --- a/IJInventoryWindowController.h +++ b/IJInventoryWindowController.h @@ -16,6 +16,7 @@ NSOutlineView *outlineView; NSPopUpButton *worldPopup; + NSTextField *statusTextField; NSArray *rootItems; NSMutableArray *armorItem; @@ -28,6 +29,7 @@ @property (nonatomic, assign) IBOutlet NSOutlineView *outlineView; @property (nonatomic, assign) IBOutlet NSPopUpButton *worldPopup; +@property (nonatomic, assign) IBOutlet NSTextField *statusTextField; - (IBAction)worldSelectionChanged:(id)sender; diff --git a/IJInventoryWindowController.m b/IJInventoryWindowController.m index f5d574d..7bd3eda 100644 --- a/IJInventoryWindowController.m +++ b/IJInventoryWindowController.m @@ -15,7 +15,7 @@ @synthesize outlineView; @synthesize worldPopup; - +@synthesize statusTextField; - (void)awakeFromNib { @@ -23,6 +23,7 @@ quickItem = [NSMutableArray array]; inventoryItem = [NSMutableArray array]; rootItems = [[NSArray alloc] initWithObjects:armorItem, quickItem, inventoryItem, nil]; + statusTextField.stringValue = @""; } - (void)dealloc { @@ -97,6 +98,9 @@ [outlineView reloadData]; [outlineView expandItem:nil expandChildren:YES]; + + dirty = NO; + statusTextField.stringValue = @""; } - (void)saveToWorldAtIndex:(int)worldIndex @@ -137,6 +141,15 @@ } [[level writeData] writeToURL:[NSURL fileURLWithPath:levelPath] atomically:NO]; + + dirty = NO; + statusTextField.stringValue = @"Saved."; +} + +- (void)markDirty +{ + dirty = YES; + statusTextField.stringValue = @"World has unsaved changes."; } #pragma mark - @@ -154,6 +167,24 @@ [self saveToWorldAtIndex:worldIndex]; } +- (void)delete:(id)sender +{ + IJInventoryItem *item = [outlineView itemAtRow:[outlineView selectedRow]]; + item.count = 0; + item.itemId = 0; + item.damage = 0; + [self markDirty]; + [outlineView reloadItem:item]; +} + +- (BOOL)validateUserInterfaceItem:(id )anItem +{ + if (anItem.action == @selector(delete:)) + { + return [outlineView selectedRow] != -1 && ![rootItems containsObject:[outlineView itemAtRow:[outlineView selectedRow]]]; + } + return YES; +} #pragma mark - #pragma mark Inventory Outline View @@ -256,16 +287,19 @@ if ([tableColumn.identifier isEqual:@"id"]) { invItem.itemId = [object shortValue]; + [self markDirty]; } else if ([tableColumn.identifier isEqual:@"count"]) { invItem.count = [object unsignedCharValue]; if (invItem.count > 64) invItem.count = 64; + [self markDirty]; } else if ([tableColumn.identifier isEqual:@"damage"]) { invItem.damage = [object shortValue]; + [self markDirty]; } } @@ -279,6 +313,7 @@ [[IJItemPickerWindowController sharedController] showPickerWithInitialItemId:invItem.itemId completionBlock:^(uint16_t itemId) { invItem.itemId = itemId; [outlineView reloadItem:item]; + [self markDirty]; }]; return NO; } diff --git a/ItemPicker.xib b/ItemPicker.xib index ee504dc..da878cb 100644 --- a/ItemPicker.xib +++ b/ItemPicker.xib @@ -12,7 +12,7 @@ YES - + YES @@ -175,7 +175,7 @@ 3 MC4zMzMzMzI5ODU2AA - + 6 System headerTextColor @@ -203,7 +203,7 @@ YES - + name 191 10 @@ -219,9 +219,9 @@ headerColor - + - + 337772096 2048 Text Cell @@ -232,7 +232,6 @@ 3 YES - YES @@ -467,7 +466,7 @@ YES - + @@ -487,17 +486,17 @@ 26 - + YES - + 27 - - + +