diff --git a/IJInventoryItem.m b/IJInventoryItem.m index bf51639..c04f046 100644 --- a/IJInventoryItem.m +++ b/IJInventoryItem.m @@ -63,7 +63,7 @@ NSUInteger pixelsPerColumn = 36; NSUInteger pixelsPerRow = 56; - int index; + int index = 0; if (itemId <= 85) { @@ -115,7 +115,7 @@ [NSGraphicsContext restoreGraphicsState]; - return output; + return [output autorelease]; } - (NSImage *)image diff --git a/IJInventoryView.m b/IJInventoryView.m index 17e0b59..66348e4 100644 --- a/IJInventoryView.m +++ b/IJInventoryView.m @@ -206,7 +206,6 @@ const static CGFloat cellOffset = 40; - (void)mouseUp:(NSEvent *)theEvent { - NSLog(@"%s", __PRETTY_FUNCTION__); if (!dragging) { NSPoint mouseDownPoint = [mouseDownEvent locationInWindow]; diff --git a/IJInventoryWindowController.m b/IJInventoryWindowController.m index 4118399..14e934d 100644 --- a/IJInventoryWindowController.m +++ b/IJInventoryWindowController.m @@ -292,6 +292,7 @@ - (void)inventoryView:(IJInventoryView *)theInventoryView selectedItemAtIndex:(int)itemIndex { + NSLog(@"%s index=%d", _cmd, itemIndex); // Show the properties window for this item. IJInventoryItem *lastItem = propertiesViewController.item; @@ -305,31 +306,39 @@ NSArray *items = [self itemArrayForInventoryView:theInventoryView slotOffset:nil]; IJInventoryItem *item = [items objectAtIndex:itemIndex]; if (item.itemId == 0 || lastItem == item) + { + propertiesViewController.item = nil; return; // can't show info on nothing + } if (!propertiesViewController) { propertiesViewController = [[IJItemPropertiesViewController alloc] initWithNibName:@"ItemPropertiesView" bundle:nil]; + + propertiesWindow = [[MAAttachedWindow alloc] initWithView:propertiesViewController.view + attachedToPoint:point + inWindow:self.window + onSide:MAPositionRight + atDistance:0]; + [propertiesWindow setBackgroundColor:[NSColor controlBackgroundColor]]; + [propertiesWindow setViewMargin:10.0]; + [propertiesWindow setAlphaValue:1.0]; + [[self window] addChildWindow:propertiesWindow ordered:NSWindowAbove]; } - propertiesViewController.item = item; - propertiesWindow = [[MAAttachedWindow alloc] initWithView:propertiesViewController.view - attachedToPoint:point - inWindow:self.window - onSide:MAPositionRight - atDistance:0]; - [propertiesWindow setDelegate:propertiesViewController]; // Be the delegate so it can be part of the responder chain (to get cancelOperation:). - [propertiesWindow setBackgroundColor:[NSColor controlBackgroundColor]]; - [propertiesWindow setViewMargin:10.0]; - [propertiesWindow setAlphaValue:1.0]; - [[self window] addChildWindow:propertiesWindow ordered:NSWindowAbove]; - [propertiesWindow makeKeyAndOrderFront:nil]; - + if (observerObject) + [[NSNotificationCenter defaultCenter] removeObserver:observerObject]; observerObject = [[NSNotificationCenter defaultCenter] addObserverForName:NSWindowDidResignKeyNotification object:propertiesWindow queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification *notification) { - [self removePropertiesWindow]; + [propertiesViewController commitEditing]; + [theInventoryView reloadItemAtIndex:itemIndex]; + [propertiesWindow setAlphaValue:0.0]; }]; + propertiesViewController.item = item; + [propertiesWindow setPoint:point side:MAPositionRight]; + [propertiesWindow makeKeyAndOrderFront:nil]; + [propertiesWindow setAlphaValue:1.0]; } #pragma mark - diff --git a/IJItemPropertiesViewController.m b/IJItemPropertiesViewController.m index 3fe79e3..86a3136 100644 --- a/IJItemPropertiesViewController.m +++ b/IJItemPropertiesViewController.m @@ -13,10 +13,4 @@ @synthesize item; -- (void)cancelOperation:(id)sender -{ - // Somewhat hacky method of closing the window on Esc. Depends on us being the window's delegate. - [self.view.window orderOut:nil]; -} - @end diff --git a/ItemPropertiesView.xib b/ItemPropertiesView.xib index a119e70..3f88ed0 100644 --- a/ItemPropertiesView.xib +++ b/ItemPropertiesView.xib @@ -43,21 +43,21 @@ 268 YES - + 268 {{74, 11}, {51, 22}} YES - + -1804468671 - 272630784 - + 272630848 + LucidaGrande 13 1044 - + YES @@ -74,7 +74,7 @@ YES - + -∞ @@ -93,7 +93,7 @@ NaN - + YES @@ -101,7 +101,7 @@ - + 0 0 YES @@ -109,7 +109,7 @@ 1 AAAAAAAAAAAAAAAAAAAAAA - + 3 YES @@ -122,9 +122,9 @@ NO YES - + YES - + 6 System textBackgroundColor @@ -133,28 +133,28 @@ MQA - + 6 System textColor - + 3 MAA - + 268 {{74, 38}, {51, 22}} YES - + -1804468671 - 272630784 - - + 272630848 + + YES @@ -171,7 +171,7 @@ YES - + -∞ @@ -188,10 +188,10 @@ NaN - + - - + + 3 YES @@ -204,25 +204,25 @@ NO YES - + YES - - + + - + 268 {{3, 13}, {66, 17}} YES - + 68288064 71304192 Damage: - - - + + + 6 System controlColor @@ -231,28 +231,28 @@ MC42NjY2NjY2NjY3AA - + 6 System controlTextColor - + - + 268 {{3, 40}, {66, 17}} YES - + 68288064 71304192 Count: - - - - + + + + @@ -275,10 +275,10 @@ value: item.count - + - + value: item.count value @@ -291,10 +291,10 @@ value: item.damage - + - + value: item.damage value @@ -337,86 +337,86 @@ YES - - - - + + + + 3 - + YES - + 4 - - + + 5 - + YES - + 6 - - + + 7 - + YES - + 8 - + YES - + - + 9 - - + + 10 - + YES - + 11 - + YES - + - + 12 - - + + @@ -524,21 +524,21 @@ NSApplication NSResponder - + IBFrameworkSource AppKit.framework/Headers/NSApplication.h NSApplication - + IBFrameworkSource AppKit.framework/Headers/NSApplicationScripting.h NSApplication - + IBFrameworkSource AppKit.framework/Headers/NSColorPanel.h @@ -575,7 +575,7 @@ NSControl NSView - + IBFrameworkSource AppKit.framework/Headers/NSControl.h @@ -591,7 +591,7 @@ NSMenu NSObject - + IBFrameworkSource AppKit.framework/Headers/NSMenu.h @@ -613,19 +613,19 @@ NSObject - + NSObject - + NSObject - + NSObject - + NSObject @@ -664,7 +664,7 @@ NSObject - + NSObject @@ -710,7 +710,7 @@ NSObject - + IBFrameworkSource AppKit.framework/Headers/NSView.h @@ -924,7 +924,7 @@ NSView NSResponder - + NSViewController diff --git a/NBTContainer.m b/NBTContainer.m index 64b0a0b..10c9983 100644 --- a/NBTContainer.m +++ b/NBTContainer.m @@ -76,7 +76,7 @@ { id obj = [[[self class] alloc] init]; [obj readFromData:data]; - return obj; + return [obj autorelease]; } - (void)readFromData:(NSData *)data