From 8f2dd75a4dcec61a17cc7b53b2340891ed7a25b9 Mon Sep 17 00:00:00 2001 From: preble Date: Sun, 10 Oct 2010 02:34:59 -0400 Subject: [PATCH] More work on slot properties. Moved properties window popup back to IJInventoryWindowController. --- English.lproj/MainMenu.xib | 253 +++--- IJInventoryView.h | 9 +- IJInventoryView.m | 92 +-- IJInventoryWindowController.h | 7 + IJInventoryWindowController.m | 86 +- IJItemPickerWindowController.h | 29 - IJItemPickerWindowController.m | 115 --- IJItemPropertiesViewController.m | 27 +- InsideJob.xcodeproj/project.pbxproj | 16 +- ItemPicker.xib | 1136 --------------------------- ItemPropertiesView.xib | 174 ++-- NSColor+Additions.h | 16 + NSColor+Additions.m | 27 + 13 files changed, 396 insertions(+), 1591 deletions(-) delete mode 100644 IJItemPickerWindowController.h delete mode 100644 IJItemPickerWindowController.m delete mode 100644 ItemPicker.xib create mode 100644 NSColor+Additions.h create mode 100644 NSColor+Additions.m diff --git a/English.lproj/MainMenu.xib b/English.lproj/MainMenu.xib index 01b9f8a..eab4a9f 100644 --- a/English.lproj/MainMenu.xib +++ b/English.lproj/MainMenu.xib @@ -12,7 +12,7 @@ YES - + @@ -492,7 +492,7 @@ 7 2 - {{431, 251}, {744, 474}} + {{347, 255}, {670, 481}} 1954021376 Inside Job NSWindow @@ -506,7 +506,7 @@ 266 - {{211, 447}, {525, 14}} + {{211, 454}, {451, 14}} YES @@ -542,7 +542,7 @@ 268 - {{53, 408}, {85, 19}} + {{53, 415}, {85, 19}} YES @@ -585,7 +585,7 @@ NaN - + YES YES @@ -595,7 +595,7 @@ - + 0 0 YES @@ -603,7 +603,7 @@ 1 AAAAAAAAAAAAAAAAAAAAAA - + 3 YES @@ -638,7 +638,7 @@ 268 - {{8, 410}, {40, 14}} + {{8, 417}, {40, 14}} YES @@ -654,7 +654,7 @@ 10 - {{0, 433}, {744, 5}} + {{0, 440}, {670, 5}} {0, 0} @@ -680,7 +680,7 @@ 268 - {{11, 442}, {195, 25}} + {{11, 449}, {195, 25}} YES @@ -724,39 +724,39 @@ 2 - + 268 - {{78, 246}, {432, 144}} + {{78, 277}, {360, 120}} IJInventoryView - + 268 - {{78, 179}, {432, 48}} + {{78, 217}, {360, 40}} IJInventoryView - + 268 - {{11, 198}, {48, 192}} + {{20, 237}, {40, 160}} IJInventoryView - + 265 - {{556, 405}, {177, 22}} + {{482, 412}, {177, 22}} YES - + 343014976 268436544 - + YES 1 @@ -765,9 +765,9 @@ 130560 0 search - + _searchFieldSearch: - + 138690815 0 @@ -794,9 +794,9 @@ - + _searchFieldCancel: - + 138690815 0 @@ -807,21 +807,21 @@ CAAAAA - + 4369 YES - - + + 2304 YES - - + + 4352 - {205, 396} - + {205, 403} + YES @@ -830,7 +830,7 @@ YES - + itemId 40 40 @@ -840,7 +840,7 @@ 2048 - + 3 MC4zMzMzMzI5ODU2AA @@ -851,12 +851,12 @@ - + 337772096 -2080372736 Text Cell - + YES @@ -888,10 +888,10 @@ NaN - + - - + + 3 YES @@ -904,7 +904,7 @@ NO YES - + 6 System @@ -916,9 +916,9 @@ 3 YES YES - + - + image 32 10 @@ -936,7 +936,7 @@ - + 67239424 33554432 @@ -948,9 +948,9 @@ 3 YES YES - + - + name 124 40 @@ -960,22 +960,22 @@ 2048 - + - + 337772096 2048 Text Cell - + 3 YES YES - + 3 @@ -1001,44 +1001,44 @@ 0 - {{1, 1}, {205, 396}} - - - + {{1, 1}, {205, 403}} + + + 4 - - + + -2147483392 {{191, 17}, {15, 365}} - - + + _doScroller: 0.9974811083123426 - - + + -2147483392 {{1, 382}, {190, 15}} - + 1 - + _doScroller: 0.99514563106796117 - {{538, -1}, {207, 398}} + {{464, -1}, {207, 405}} - + 562 - - - + + + QSAAAEEgAABBmAAAQZgAAA - {744, 474} + {670, 481} {{0, 0}, {1440, 878}} @@ -1326,7 +1326,7 @@ inventoryView - + 642 @@ -1334,7 +1334,7 @@ armorView - + 645 @@ -1342,7 +1342,7 @@ quickView - + 646 @@ -1350,7 +1350,7 @@ itemSearchField - + 659 @@ -1358,14 +1358,14 @@ itemTableView - + 660 dataSource - + 661 @@ -1373,7 +1373,7 @@ delegate - + 662 @@ -1382,7 +1382,7 @@ updateItemSearchFilter: - + 663 @@ -1390,7 +1390,7 @@ initialFirstResponder - + 668 @@ -1765,11 +1765,11 @@ - - - - - + + + + + @@ -1883,7 +1883,7 @@ 641 - + YES @@ -1891,110 +1891,110 @@ 643 - + 644 - + 647 - + YES - + 648 - - + + 649 - + YES - - - + + + 650 - - + + 651 - - + + 652 - + YES - - - + + + - + 654 - + YES - + - + 655 - + YES - + - + 656 - - + + 657 - + YES - + - + 658 - - + + 665 - + YES - + - + 667 - - + + @@ -2242,9 +2242,9 @@ {{475, 832}, {234, 43}} com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{34, 169}, {744, 474}} + {{114, 210}, {670, 481}} com.apple.InterfaceBuilder.CocoaPlugin - {{34, 169}, {744, 474}} + {{114, 210}, {670, 481}} {{33, 99}, {480, 360}} {3.40282e+38, 3.40282e+38} @@ -2299,15 +2299,15 @@ com.apple.InterfaceBuilder.CocoaPlugin - AUJsAABDmoAAA + AUKcAABDdgAAA com.apple.InterfaceBuilder.CocoaPlugin - AUJsAABDcgAAA + AUKcAABDRgAAA com.apple.InterfaceBuilder.CocoaPlugin - AUIQAABDSgAAA + AUEwAABDRgAAA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -2427,6 +2427,7 @@ inventoryView itemSearchField itemTableView + observerObject quickView statusTextField worldSelectionControl @@ -2437,6 +2438,7 @@ IJInventoryView NSSearchField NSTableView + id IJInventoryView NSTextField NSSegmentedControl @@ -2450,6 +2452,7 @@ inventoryView itemSearchField itemTableView + observerObject quickView statusTextField worldSelectionControl @@ -2472,6 +2475,10 @@ itemTableView NSTableView + + observerObject + id + quickView IJInventoryView diff --git a/IJInventoryView.h b/IJInventoryView.h index db3b080..d91dcbf 100644 --- a/IJInventoryView.h +++ b/IJInventoryView.h @@ -12,8 +12,6 @@ extern NSString * const IJPasteboardTypeInventoryItem; @protocol IJInventoryViewDelegate; @class IJInventoryItem; -@class IJItemPropertiesViewController; -@class MAAttachedWindow; @interface IJInventoryView : NSView { int rows; @@ -23,10 +21,6 @@ extern NSString * const IJPasteboardTypeInventoryItem; NSArray *items; - IJItemPropertiesViewController *propertiesViewController; - MAAttachedWindow *propertiesWindow; - id observerObject; - id delegate; BOOL dragging; @@ -35,6 +29,8 @@ extern NSString * const IJPasteboardTypeInventoryItem; - (void)setRows:(int)numberOfRows columns:(int)numberOfColumns; - (void)setItems:(NSArray *)theItems; +- (NSPoint)pointForItemAtIndex:(int)index; +- (void)reloadItemAtIndex:(int)itemIndex; @end @@ -42,4 +38,5 @@ extern NSString * const IJPasteboardTypeInventoryItem; @protocol IJInventoryViewDelegate - (void)inventoryView:(IJInventoryView *)inventoryView removeItemAtIndex:(int)itemIndex; - (void)inventoryView:(IJInventoryView *)inventoryView setItem:(IJInventoryItem *)item atIndex:(int)itemIndex; +- (void)inventoryView:(IJInventoryView *)inventoryView selectedItemAtIndex:(int)itemIndex; @end diff --git a/IJInventoryView.m b/IJInventoryView.m index c5028ac..17e0b59 100644 --- a/IJInventoryView.m +++ b/IJInventoryView.m @@ -8,8 +8,8 @@ #import "IJInventoryView.h" #import "IJInventoryItem.h" -#import "IJItemPropertiesViewController.h" #import "MAAttachedWindow.h" +#import NSString * const IJPasteboardTypeInventoryItem = @"net.adampreble.insidejob.inventoryitem"; @@ -34,7 +34,6 @@ const static CGFloat cellOffset = 40; { [items release]; [mouseDownEvent release]; - [propertiesViewController release]; [super dealloc]; } @@ -46,24 +45,13 @@ const static CGFloat cellOffset = 40; { return YES; } -- (void)removePropertiesWindow + +// For use by external stuff, since it flips the coordinates and our layer uses flipped geometry. +- (NSPoint)pointForItemAtIndex:(int)index { - if (observerObject) - { - [[NSNotificationCenter defaultCenter] removeObserver:observerObject]; - observerObject = nil; - - [self.window removeChildWindow:propertiesWindow]; - [propertiesWindow orderOut:nil]; - //[propertiesWindow release]; - propertiesWindow = nil; - propertiesViewController.item = nil; - } -} -- (BOOL)resignFirstResponder -{ - [self removePropertiesWindow]; - return YES; + int x = index % cols; + int y = index / cols; + return CGPointMake(x * cellOffset, self.bounds.size.height - y * cellOffset); } - (void)setRows:(int)numberOfRows columns:(int)numberOfColumns @@ -99,6 +87,18 @@ const static CGFloat cellOffset = 40; layer.bounds = CGRectMake(0, 0, cellSize, cellSize); layer.borderWidth = 1.0; layer.borderColor = CGColorGetConstantColor(kCGColorBlack); + + CATextLayer *textLayer = [CATextLayer layer]; + textLayer.bounds = CGRectMake(0, 0, cellSize-2, 18); + textLayer.position = CGPointMake(cellSize/2.0, cellSize/2.0 + 18/2 - 1); + textLayer.foregroundColor = CGColorGetConstantColor(kCGColorWhite); + textLayer.fontSize = 18; + textLayer.shadowOpacity = 1.0; + textLayer.shadowRadius = 0.5; + textLayer.shadowOffset = NSMakeSize(0, 1); + textLayer.alignmentMode = @"right"; + [layer addSublayer:textLayer]; + [self.layer addSublayer:layer]; } } @@ -109,6 +109,19 @@ const static CGFloat cellOffset = 40; return [self.layer.sublayers objectAtIndex:row * cols + column]; } +- (void)reloadItemAtIndex:(int)itemIndex +{ + IJInventoryItem *item = [items objectAtIndex:itemIndex]; + CALayer *layer = [self.layer.sublayers objectAtIndex:itemIndex]; + layer.contents = item.image; + + CATextLayer *textLayer = [layer.sublayers objectAtIndex:0]; + if (item.count == 0) + textLayer.string = @""; + else + textLayer.string = [NSString stringWithFormat:@"%d", item.count]; +} + - (void)setItems:(NSArray *)theItems { NSLog(@"%s", __PRETTY_FUNCTION__); @@ -116,12 +129,8 @@ const static CGFloat cellOffset = 40; [theItems retain]; items = theItems; - //NSLog(@"%@ sublayers=%@", [self layer], self.layer.sublayers); - [items enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { - IJInventoryItem *item = obj; - CALayer *layer = [self.layer.sublayers objectAtIndex:idx]; - layer.contents = item.image; - }]; + for (int i = 0; i < items.count; i++) + [self reloadItemAtIndex:i]; } - (int)itemIndexForPoint:(NSPoint)point @@ -200,42 +209,11 @@ const static CGFloat cellOffset = 40; NSLog(@"%s", __PRETTY_FUNCTION__); if (!dragging) { - // Show the properties window for this item. - IJInventoryItem *lastItem = propertiesViewController.item; - - [self removePropertiesWindow]; - NSPoint mouseDownPoint = [mouseDownEvent locationInWindow]; NSPoint pointInView = [self convertPoint:mouseDownPoint fromView:nil]; int itemIndex = [self itemIndexForPoint:pointInView]; - IJInventoryItem *item = [items objectAtIndex:itemIndex]; - if (item.itemId == 0 || lastItem == item) - return; // can't show info on nothing - - if (!propertiesViewController) - { - propertiesViewController = [[IJItemPropertiesViewController alloc] initWithNibName:@"ItemPropertiesView" bundle:nil]; - } - propertiesViewController.item = item; - propertiesWindow = [[MAAttachedWindow alloc] initWithView:propertiesViewController.view - attachedToPoint:mouseDownPoint - inWindow:self.window - onSide:MAPositionRight - atDistance:0]; - [propertiesWindow setBackgroundColor:[NSColor controlBackgroundColor]]; - [propertiesWindow setViewMargin:10.0]; - [propertiesWindow setAlphaValue:1.0]; - //[[propertiesWindow animator] setAlphaValue:1.0]; - [[self window] addChildWindow:propertiesWindow ordered:NSWindowAbove]; - [propertiesWindow makeKeyAndOrderFront:nil]; - - observerObject = [[NSNotificationCenter defaultCenter] addObserverForName:NSWindowDidResignKeyNotification - object:propertiesWindow - queue:[NSOperationQueue mainQueue] - usingBlock:^(NSNotification *notification) { - [self removePropertiesWindow]; - }]; + [delegate inventoryView:self selectedItemAtIndex:itemIndex]; } } diff --git a/IJInventoryWindowController.h b/IJInventoryWindowController.h index 4d32b85..b979b4b 100644 --- a/IJInventoryWindowController.h +++ b/IJInventoryWindowController.h @@ -11,6 +11,8 @@ @class IJInventoryView; @class IJMinecraftLevel; +@class MAAttachedWindow; +@class IJItemPropertiesViewController; @interface IJInventoryWindowController : NSWindowController { IJMinecraftLevel *level; @@ -33,6 +35,11 @@ NSArray *allItemIds; NSArray *filteredItemIds; + // + IJItemPropertiesViewController *propertiesViewController; + MAAttachedWindow *propertiesWindow; + id observerObject; + // Document BOOL dirty; int64_t sessionLockValue; diff --git a/IJInventoryWindowController.m b/IJInventoryWindowController.m index bb06c85..4118399 100644 --- a/IJInventoryWindowController.m +++ b/IJInventoryWindowController.m @@ -9,8 +9,13 @@ #import "IJInventoryWindowController.h" #import "IJMinecraftLevel.h" #import "IJInventoryItem.h" -#import "IJItemPickerWindowController.h" #import "IJInventoryView.h" +#import "IJItemPropertiesViewController.h" +#import "MAAttachedWindow.h" + +@interface IJInventoryWindowController () +- (void)removePropertiesWindow; +@end @implementation IJInventoryWindowController @@ -43,6 +48,7 @@ - (void)dealloc { + [propertiesViewController release]; [armorInventory release]; [quickInventory release]; [normalInventory release]; @@ -240,17 +246,17 @@ { if (theInventoryView == inventoryView) { - *slotOffset = IJInventorySlotNormalFirst; + if (slotOffset) *slotOffset = IJInventorySlotNormalFirst; return normalInventory; } else if (theInventoryView == quickView) { - *slotOffset = IJInventorySlotQuickFirst; + if (slotOffset) *slotOffset = IJInventorySlotQuickFirst; return quickInventory; } else if (theInventoryView == armorView) { - *slotOffset = IJInventorySlotArmorFirst; + if (slotOffset) *slotOffset = IJInventorySlotArmorFirst; return armorInventory; } return nil; @@ -284,6 +290,48 @@ [self markDirty]; } +- (void)inventoryView:(IJInventoryView *)theInventoryView selectedItemAtIndex:(int)itemIndex +{ + // Show the properties window for this item. + IJInventoryItem *lastItem = propertiesViewController.item; + + //[self removePropertiesWindow]; + + NSPoint itemLocationInView = [theInventoryView pointForItemAtIndex:itemIndex]; + NSPoint point = [theInventoryView convertPoint:itemLocationInView toView:nil]; + point.x += 16 + 8; + point.y -= 16; + + NSArray *items = [self itemArrayForInventoryView:theInventoryView slotOffset:nil]; + IJInventoryItem *item = [items objectAtIndex:itemIndex]; + if (item.itemId == 0 || lastItem == item) + return; // can't show info on nothing + + if (!propertiesViewController) + { + propertiesViewController = [[IJItemPropertiesViewController alloc] initWithNibName:@"ItemPropertiesView" bundle:nil]; + } + 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]; + + observerObject = [[NSNotificationCenter defaultCenter] addObserverForName:NSWindowDidResignKeyNotification + object:propertiesWindow + queue:[NSOperationQueue mainQueue] + usingBlock:^(NSNotification *notification) { + [self removePropertiesWindow]; + }]; +} + #pragma mark - #pragma mark Item Picker @@ -359,6 +407,36 @@ } +#pragma mark - +#pragma mark + +- (void)reloadInventoryViewForItem:(IJInventoryItem *)item +{ + if ([normalInventory containsObject:item]) + [inventoryView reloadItemAtIndex:[normalInventory indexOfObject:item]]; + else if ([quickInventory containsObject:item]) + [quickView reloadItemAtIndex:[quickInventory indexOfObject:item]]; + else if ([armorInventory containsObject:item]) + [armorView reloadItemAtIndex:[armorInventory indexOfObject:item]]; +} + +- (void)removePropertiesWindow +{ + if (observerObject) + { + [propertiesViewController commitEditing]; + [[NSNotificationCenter defaultCenter] removeObserver:observerObject]; + observerObject = nil; + + [self reloadInventoryViewForItem:propertiesViewController.item]; + + [self.window removeChildWindow:propertiesWindow]; + [propertiesWindow orderOut:nil]; + //[propertiesWindow release]; + propertiesWindow = nil; + propertiesViewController.item = nil; + } +} @end diff --git a/IJItemPickerWindowController.h b/IJItemPickerWindowController.h deleted file mode 100644 index 5e2a7a8..0000000 --- a/IJItemPickerWindowController.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// IJItemPickerWindowController.h -// InsideJob -// -// Created by Adam Preble on 10/7/10. -// Copyright 2010 Adam Preble. All rights reserved. -// - -#import - - -@interface IJItemPickerWindowController : NSWindowController { - void(^completionBlock)(uint16_t itemId); - NSSearchField *searchField; - NSTableView *tableView; - NSArray *allItemIds; - NSArray *filteredItemIds; -} -@property (nonatomic, assign) IBOutlet NSTableView *tableView; -@property (nonatomic, assign) IBOutlet NSSearchField *searchField; - -+ (IJItemPickerWindowController *)sharedController; - -- (void)showPickerWithInitialItemId:(uint16_t)initialItemId completionBlock:(void(^)(uint16_t itemId))block; - -- (IBAction)itemActivated:(id)sender; -- (IBAction)updateFilter:(id)sender; - -@end diff --git a/IJItemPickerWindowController.m b/IJItemPickerWindowController.m deleted file mode 100644 index cae1c52..0000000 --- a/IJItemPickerWindowController.m +++ /dev/null @@ -1,115 +0,0 @@ -// -// IJItemPickerWindowController.m -// InsideJob -// -// Created by Adam Preble on 10/7/10. -// Copyright 2010 Adam Preble. All rights reserved. -// - -#import "IJItemPickerWindowController.h" -#import "IJInventoryItem.h" - -@implementation IJItemPickerWindowController - -@synthesize tableView, searchField; - -+ (IJItemPickerWindowController *)sharedController -{ - static IJItemPickerWindowController *globalSharedController = nil; - if (!globalSharedController) - { - globalSharedController = [[IJItemPickerWindowController alloc] initWithWindowNibName:@"ItemPicker"]; - } - return globalSharedController; -} - -- (void)awakeFromNib -{ - [tableView setTarget:self]; - [tableView setDoubleAction:@selector(itemActivated:)]; - - NSArray *keys = [[IJInventoryItem itemIdLookup] allKeys]; - keys = [keys sortedArrayUsingSelector:@selector(compare:)]; - allItemIds = [[NSArray alloc] initWithArray:keys]; - filteredItemIds = [allItemIds retain]; -} - -- (void)showPickerWithInitialItemId:(uint16_t)initialItemId completionBlock:(void(^)(uint16_t itemId))theBlock -{ - [self showWindow:nil]; - - [searchField becomeFirstResponder]; - - [completionBlock autorelease]; - completionBlock = [theBlock copy]; - - NSUInteger row = [filteredItemIds indexOfObject:[NSNumber numberWithShort:initialItemId]]; - if (row != NSNotFound) - { - [tableView selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO]; - [tableView scrollRowToVisible:row]; - } -} - -- (IBAction)updateFilter:(id)sender -{ - NSString *filterString = [sender stringValue]; - - if (filterString.length == 0) - { - [filteredItemIds autorelease]; - filteredItemIds = [allItemIds retain]; - [tableView reloadData]; - return; - } - - NSMutableArray *results = [NSMutableArray array]; - - for (NSNumber *itemId in allItemIds) - { - NSString *name = [[IJInventoryItem itemIdLookup] objectForKey:itemId]; - NSRange range = [name rangeOfString:filterString options:NSCaseInsensitiveSearch]; - if (range.location != NSNotFound) - [results addObject:itemId]; - } - - [filteredItemIds autorelease]; - filteredItemIds = [results retain]; - [tableView reloadData]; -} - -- (IBAction)itemActivated:(id)sender -{ - NSUInteger row = [tableView selectedRow]; - uint16_t itemId = [[filteredItemIds objectAtIndex:row] shortValue]; - - [[self window] orderOut:nil]; - - completionBlock(itemId); -} - -#pragma mark - -#pragma mark NSTableViewDataSource - -- (NSInteger)numberOfRowsInTableView:(NSTableView *)theTableView -{ - return filteredItemIds.count; -} -- (id)tableView:(NSTableView *)theTableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row -{ - // TODO: Change this, because the row will not correspond once we support sorting. - NSNumber *itemId = [filteredItemIds objectAtIndex:row]; - - if ([tableColumn.identifier isEqual:@"itemId"]) - return [itemId stringValue]; - - NSString *name = [[IJInventoryItem itemIdLookup] objectForKey:itemId]; - return name; -} - -- (void)windowDidResignKey:(NSNotification *)notification -{ - [[self window] orderOut:nil]; -} - -@end diff --git a/IJItemPropertiesViewController.m b/IJItemPropertiesViewController.m index c45edf9..3fe79e3 100644 --- a/IJItemPropertiesViewController.m +++ b/IJItemPropertiesViewController.m @@ -13,31 +13,10 @@ @synthesize item; -+ (NSSet *)keyPathsForValuesAffectingCountNumber +- (void)cancelOperation:(id)sender { - return [NSSet setWithObject:@"item"]; -} -+ (NSSet *)keyPathsForValuesAffectingDamageNumber -{ - return [NSSet setWithObject:@"item"]; -} - -- (NSNumber *)countNumber -{ - return [NSNumber numberWithShort:item.count]; -} -- (void)setCountNumber:(NSNumber *)number -{ - item.count = [number shortValue]; -} - -- (NSNumber *)damageNumber -{ - return [NSNumber numberWithShort:item.damage]; -} -- (void)setDamageNumber:(NSNumber *)number -{ - item.damage = [number shortValue]; + // 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/InsideJob.xcodeproj/project.pbxproj b/InsideJob.xcodeproj/project.pbxproj index 1028b62..29369a0 100644 --- a/InsideJob.xcodeproj/project.pbxproj +++ b/InsideJob.xcodeproj/project.pbxproj @@ -16,13 +16,12 @@ 668B27B2125D8F8E0060BF71 /* IJInventoryItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 668B27B1125D8F8E0060BF71 /* IJInventoryItem.m */; }; 668B27F2125D963F0060BF71 /* IJInventoryWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 668B27F1125D963F0060BF71 /* IJInventoryWindowController.m */; }; 668B290F125E40560060BF71 /* Items.csv in Resources */ = {isa = PBXBuildFile; fileRef = 668B28D8125E370A0060BF71 /* Items.csv */; }; - 668B2979125E5DD40060BF71 /* IJItemPickerWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 668B2978125E5DD40060BF71 /* IJItemPickerWindowController.m */; }; - 668B297C125E5DF00060BF71 /* ItemPicker.xib in Resources */ = {isa = PBXBuildFile; fileRef = 668B297B125E5DF00060BF71 /* ItemPicker.xib */; }; 66BC00031260215C005A23F4 /* IJInventoryView.m in Sources */ = {isa = PBXBuildFile; fileRef = 66BC00021260215C005A23F4 /* IJInventoryView.m */; }; 66BC000E12602359005A23F4 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 66BC000D12602359005A23F4 /* QuartzCore.framework */; }; 66BC033B1260CC59005A23F4 /* MAAttachedWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 66BC033A1260CC59005A23F4 /* MAAttachedWindow.m */; }; 66BC03621260D095005A23F4 /* IJItemPropertiesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 66BC03611260D095005A23F4 /* IJItemPropertiesViewController.m */; }; 66BC03641260D0B3005A23F4 /* ItemPropertiesView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 66BC03631260D0B3005A23F4 /* ItemPropertiesView.xib */; }; + 66BC04F812619072005A23F4 /* NSColor+Additions.m in Sources */ = {isa = PBXBuildFile; fileRef = 66BC04F712619072005A23F4 /* NSColor+Additions.m */; }; 66BCFC2B125E9A51005A23F4 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 66BCFC2A125E9A51005A23F4 /* Credits.rtf */; }; 66BCFC36125EA53E005A23F4 /* InsideJob.icns in Resources */ = {isa = PBXBuildFile; fileRef = 66BCFC35125EA53E005A23F4 /* InsideJob.icns */; }; 66BCFE62125FCEC6005A23F4 /* DataValuesV110Transparent.png in Resources */ = {isa = PBXBuildFile; fileRef = 66BCFE61125FCEC6005A23F4 /* DataValuesV110Transparent.png */; }; @@ -54,9 +53,6 @@ 668B27F0125D963F0060BF71 /* IJInventoryWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IJInventoryWindowController.h; sourceTree = ""; }; 668B27F1125D963F0060BF71 /* IJInventoryWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IJInventoryWindowController.m; sourceTree = ""; }; 668B28D8125E370A0060BF71 /* Items.csv */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Items.csv; sourceTree = ""; }; - 668B2977125E5DD40060BF71 /* IJItemPickerWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IJItemPickerWindowController.h; sourceTree = ""; }; - 668B2978125E5DD40060BF71 /* IJItemPickerWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IJItemPickerWindowController.m; sourceTree = ""; }; - 668B297B125E5DF00060BF71 /* ItemPicker.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ItemPicker.xib; sourceTree = ""; }; 66BC00011260215C005A23F4 /* IJInventoryView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IJInventoryView.h; sourceTree = ""; }; 66BC00021260215C005A23F4 /* IJInventoryView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IJInventoryView.m; sourceTree = ""; }; 66BC000D12602359005A23F4 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; @@ -65,6 +61,8 @@ 66BC03601260D095005A23F4 /* IJItemPropertiesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IJItemPropertiesViewController.h; sourceTree = ""; }; 66BC03611260D095005A23F4 /* IJItemPropertiesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IJItemPropertiesViewController.m; sourceTree = ""; }; 66BC03631260D0B3005A23F4 /* ItemPropertiesView.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = ItemPropertiesView.xib; sourceTree = ""; }; + 66BC04F612619072005A23F4 /* NSColor+Additions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSColor+Additions.h"; sourceTree = ""; }; + 66BC04F712619072005A23F4 /* NSColor+Additions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSColor+Additions.m"; sourceTree = ""; }; 66BCFC2A125E9A51005A23F4 /* Credits.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = Credits.rtf; sourceTree = ""; }; 66BCFC35125EA53E005A23F4 /* InsideJob.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = InsideJob.icns; sourceTree = ""; }; 66BCFE61125FCEC6005A23F4 /* DataValuesV110Transparent.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = DataValuesV110Transparent.png; sourceTree = ""; }; @@ -156,7 +154,6 @@ 8D1107310486CEB800E47090 /* InsideJob-Info.plist */, 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */, 1DDD58140DA1D0A300B32029 /* MainMenu.xib */, - 668B297B125E5DF00060BF71 /* ItemPicker.xib */, 668B28D8125E370A0060BF71 /* Items.csv */, 66BCFC2A125E9A51005A23F4 /* Credits.rtf */, 66BC03631260D0B3005A23F4 /* ItemPropertiesView.xib */, @@ -191,6 +188,8 @@ children = ( 668B255A125D5BCA0060BF71 /* NSData+CocoaDevAdditions.h */, 668B255B125D5BCA0060BF71 /* NSData+CocoaDevAdditions.m */, + 66BC04F612619072005A23F4 /* NSColor+Additions.h */, + 66BC04F712619072005A23F4 /* NSColor+Additions.m */, ); name = Categories; sourceTree = ""; @@ -200,8 +199,6 @@ children = ( 668B27F0125D963F0060BF71 /* IJInventoryWindowController.h */, 668B27F1125D963F0060BF71 /* IJInventoryWindowController.m */, - 668B2977125E5DD40060BF71 /* IJItemPickerWindowController.h */, - 668B2978125E5DD40060BF71 /* IJItemPickerWindowController.m */, 66BC00011260215C005A23F4 /* IJInventoryView.h */, 66BC00021260215C005A23F4 /* IJInventoryView.m */, 66BC03601260D095005A23F4 /* IJItemPropertiesViewController.h */, @@ -275,7 +272,6 @@ 8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */, 1DDD58160DA1D0A300B32029 /* MainMenu.xib in Resources */, 668B290F125E40560060BF71 /* Items.csv in Resources */, - 668B297C125E5DF00060BF71 /* ItemPicker.xib in Resources */, 66BCFC2B125E9A51005A23F4 /* Credits.rtf in Resources */, 66BCFC36125EA53E005A23F4 /* InsideJob.icns in Resources */, 66BCFE62125FCEC6005A23F4 /* DataValuesV110Transparent.png in Resources */, @@ -297,10 +293,10 @@ 668B27AF125D8EFD0060BF71 /* IJMinecraftLevel.m in Sources */, 668B27B2125D8F8E0060BF71 /* IJInventoryItem.m in Sources */, 668B27F2125D963F0060BF71 /* IJInventoryWindowController.m in Sources */, - 668B2979125E5DD40060BF71 /* IJItemPickerWindowController.m in Sources */, 66BC00031260215C005A23F4 /* IJInventoryView.m in Sources */, 66BC033B1260CC59005A23F4 /* MAAttachedWindow.m in Sources */, 66BC03621260D095005A23F4 /* IJItemPropertiesViewController.m in Sources */, + 66BC04F812619072005A23F4 /* NSColor+Additions.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/ItemPicker.xib b/ItemPicker.xib deleted file mode 100644 index b75cac4..0000000 --- a/ItemPicker.xib +++ /dev/null @@ -1,1136 +0,0 @@ - - - - 1060 - 10F569 - 804 - 1038.29 - 461.00 - - com.apple.InterfaceBuilder.CocoaPlugin - 804 - - - YES - - - - YES - com.apple.InterfaceBuilder.CocoaPlugin - - - YES - - YES - - - YES - - - - YES - - IJItemPickerWindowController - - - FirstResponder - - - NSApplication - - - 283 - 2 - {{577, 347}, {249, 286}} - -1535637504 - Item Picker - NSPanel - - {1.79769e+308, 1.79769e+308} - - - 256 - - YES - - - 266 - {{6, 256}, {237, 22}} - - YES - - 343014976 - 272630848 - - - LucidaGrande - 13 - 1044 - - - YES - 1 - - 6 - System - textBackgroundColor - - 3 - MQA - - - - 6 - System - controlTextColor - - 3 - MAA - - - - 130560 - 0 - search - - _searchFieldSearch: - - 138690815 - 0 - - 400 - 75 - - - 130560 - 0 - clear - - YES - - YES - - YES - AXDescription - NSAccessibilityEncodedAttributesValueType - - - YES - cancel - - - - - - _searchFieldCancel: - - 138690815 - 0 - - 400 - 75 - - 255 - CAAAAA - - - - - 274 - - YES - - - 2304 - - YES - - - 256 - {249, 247} - - YES - - - -2147483392 - {{224, 0}, {16, 17}} - - - YES - - itemId - 50 - 40 - 1000 - - 75628096 - 67110912 - - - LucidaGrande - 11 - 3100 - - - 3 - MC4zMzMzMzI5ODU2AA - - - 6 - System - headerTextColor - - - - - 337772096 - 67110912 - Text Cell - - - - 6 - System - controlBackgroundColor - - 3 - MC42NjY2NjY2NjY3AA - - - - - 3 - YES - - - - name - 191 - 10 - 3.4028234663852886e+38 - - 75628096 - 2048 - - - - 6 - System - headerColor - - - - - - 337772096 - 2048 - Text Cell - - - - - - 3 - YES - - - - 3 - 2 - - - 6 - System - gridColor - - 3 - MC41AA - - - 17 - 1444937728 - - - 0 - 15 - 0 - YES - 0 - - - {{1, 1}, {249, 247}} - - - - - 4 - - - - -2147483392 - {{224, 17}, {15, 102}} - - - _doScroller: - 0.99596774193548387 - - - - -2147483392 - {{-100, -100}, {145, 15}} - - 1 - - _doScroller: - 0.996 - - - {{-1, -1}, {251, 249}} - - - 530 - - - - QSAAAEEgAABBmAAAQZgAAA - - - {249, 286} - - - {{0, 0}, {1440, 878}} - {1.79769e+308, 1.79769e+308} - 27 - - - - - YES - - - window - - - - 5 - - - - delegate - - - - 6 - - - - initialFirstResponder - - - - 9 - - - - tableView - - - - 19 - - - - dataSource - - - - 20 - - - - delegate - - - - 21 - - - - updateFilter: - - - - 22 - - - - nextKeyView - - - - 23 - - - - nextKeyView - - - - 24 - - - - searchField - - - - 28 - - - - - YES - - 0 - - - - - - -2 - - - File's Owner - - - -1 - - - First Responder - - - -3 - - - Application - - - 3 - - - YES - - - - - - 4 - - - YES - - - - - - - 7 - - - YES - - - - - - 8 - - - - - 10 - - - YES - - - - - - - - 11 - - - - - 12 - - - - - 13 - - - YES - - - - - - - 15 - - - YES - - - - - - 18 - - - - - 26 - - - YES - - - - - - 27 - - - - - - - YES - - YES - 10.IBPluginDependency - 11.IBPluginDependency - 12.IBPluginDependency - 13.IBPluginDependency - 15.IBPluginDependency - 18.IBPluginDependency - 3.IBEditorWindowLastContentRect - 3.IBPluginDependency - 3.IBWindowTemplateEditedContentRect - 3.NSWindowTemplate.visibleAtLaunch - 4.IBPluginDependency - 7.IBPluginDependency - 8.IBPluginDependency - - - YES - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - {{538, 134}, {249, 286}} - com.apple.InterfaceBuilder.CocoaPlugin - {{538, 134}, {249, 286}} - - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - - - - YES - - - YES - - - - - YES - - - YES - - - - 28 - - - - YES - - IJItemPickerWindowController - NSWindowController - - YES - - YES - itemActivated: - updateFilter: - - - YES - id - id - - - - YES - - YES - itemActivated: - updateFilter: - - - YES - - itemActivated: - id - - - updateFilter: - id - - - - - YES - - YES - searchField - tableView - - - YES - NSSearchField - NSTableView - - - - YES - - YES - searchField - tableView - - - YES - - searchField - NSSearchField - - - tableView - NSTableView - - - - - IBProjectSource - IJItemPickerWindowController.h - - - - - YES - - NSActionCell - NSCell - - IBFrameworkSource - AppKit.framework/Headers/NSActionCell.h - - - - NSApplication - NSResponder - - IBFrameworkSource - AppKit.framework/Headers/NSApplication.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSApplicationScripting.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSColorPanel.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSHelpManager.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSPageLayout.h - - - - NSApplication - - IBFrameworkSource - AppKit.framework/Headers/NSUserInterfaceItemSearching.h - - - - NSCell - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSCell.h - - - - NSControl - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSControl.h - - - - NSFormatter - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSFormatter.h - - - - NSMenu - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSMenu.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSAccessibility.h - - - - NSObject - - - - NSObject - - - - NSObject - - - - NSObject - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSDictionaryController.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSDragging.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSFontManager.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSFontPanel.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSKeyValueBinding.h - - - - NSObject - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSNibLoading.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSOutlineView.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSPasteboard.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSSavePanel.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSTableView.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSToolbarItem.h - - - - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSView.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSArchiver.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSClassDescription.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSError.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSFileManager.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSKeyValueCoding.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSKeyValueObserving.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSKeyedArchiver.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSObject.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSObjectScripting.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSPortCoder.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSRunLoop.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptClassDescription.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptKeyValueCoding.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptObjectSpecifiers.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSScriptWhoseTests.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSThread.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSURL.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSURLConnection.h - - - - NSObject - - IBFrameworkSource - Foundation.framework/Headers/NSURLDownload.h - - - - NSPanel - NSWindow - - IBFrameworkSource - AppKit.framework/Headers/NSPanel.h - - - - NSResponder - - IBFrameworkSource - AppKit.framework/Headers/NSInterfaceStyle.h - - - - NSResponder - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSResponder.h - - - - NSScrollView - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSScrollView.h - - - - NSScroller - NSControl - - IBFrameworkSource - AppKit.framework/Headers/NSScroller.h - - - - NSSearchField - NSTextField - - IBFrameworkSource - AppKit.framework/Headers/NSSearchField.h - - - - NSSearchFieldCell - NSTextFieldCell - - IBFrameworkSource - AppKit.framework/Headers/NSSearchFieldCell.h - - - - NSTableColumn - NSObject - - IBFrameworkSource - AppKit.framework/Headers/NSTableColumn.h - - - - NSTableView - NSControl - - - - NSTextField - NSControl - - IBFrameworkSource - AppKit.framework/Headers/NSTextField.h - - - - NSTextFieldCell - NSActionCell - - IBFrameworkSource - AppKit.framework/Headers/NSTextFieldCell.h - - - - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSClipView.h - - - - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSMenuItem.h - - - - NSView - - IBFrameworkSource - AppKit.framework/Headers/NSRulerView.h - - - - NSView - NSResponder - - - - NSWindow - - IBFrameworkSource - AppKit.framework/Headers/NSDrawer.h - - - - NSWindow - NSResponder - - IBFrameworkSource - AppKit.framework/Headers/NSWindow.h - - - - NSWindow - - IBFrameworkSource - AppKit.framework/Headers/NSWindowScripting.h - - - - NSWindowController - NSResponder - - showWindow: - id - - - showWindow: - - showWindow: - id - - - - IBFrameworkSource - AppKit.framework/Headers/NSWindowController.h - - - - - 0 - IBCocoaFramework - - com.apple.InterfaceBuilder.CocoaPlugin.macosx - - - - com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3 - - - YES - InsideJob.xcodeproj - 3 - - diff --git a/ItemPropertiesView.xib b/ItemPropertiesView.xib index c372a87..a119e70 100644 --- a/ItemPropertiesView.xib +++ b/ItemPropertiesView.xib @@ -43,21 +43,21 @@ 268 YES - + 268 {{74, 11}, {51, 22}} YES - + -1804468671 272630784 - + 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 - - + + 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: - - - - + + + + @@ -274,35 +274,35 @@ - value: countNumber - + value: item.count + - + - value: countNumber + value: item.count value - countNumber + item.count 2 - 13 + 15 - value: damageNumber - + value: item.damage + - + - value: damageNumber + value: item.damage value - damageNumber + item.damage 2 - 14 + 16 @@ -337,86 +337,86 @@ YES - - - - + + + + 3 - + YES - + 4 - - + + 5 - + YES - + 6 - - + + 7 - + YES - + 8 - + YES - + - + 9 - - + + 10 - + YES - + 11 - + YES - + - + 12 - - + + @@ -497,7 +497,7 @@ - 14 + 16 @@ -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/NSColor+Additions.h b/NSColor+Additions.h new file mode 100644 index 0000000..f3c8641 --- /dev/null +++ b/NSColor+Additions.h @@ -0,0 +1,16 @@ +// +// NSColor+Additions.h +// InsideJob +// +// Created by Adam Preble on 10/10/10. +// Copyright 2010 Adam Preble. All rights reserved. +// + +#import + + +@interface NSColor (Additions) + +- (CGColorRef)CGColor; + +@end diff --git a/NSColor+Additions.m b/NSColor+Additions.m new file mode 100644 index 0000000..b2cc78d --- /dev/null +++ b/NSColor+Additions.m @@ -0,0 +1,27 @@ +// +// NSColor+Additions.m +// InsideJob +// +// Created by Adam Preble on 10/10/10. +// Copyright 2010 Adam Preble. All rights reserved. +// + +#import "NSColor+Additions.h" + + +@implementation NSColor (Additions) + +- (CGColorRef)CGColor +{ + CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); + NSColor *deviceColor = [self colorUsingColorSpaceName:NSDeviceRGBColorSpace]; + + CGFloat components[4]; + [deviceColor getRed: &components[0] green: &components[1] blue:&components[2] alpha: &components[3]]; + + CGColorRef output = CGColorCreate(colorSpace, components); + CGColorSpaceRelease (colorSpace); + return (CGColorRef)[(id)output autorelease]; +} + +@end