Progress snapshot: got NSMatrixes displaying icons.

This commit is contained in:
preble 2010-10-08 22:57:59 -04:00
parent 145f3013db
commit f26f928c80
6 changed files with 235 additions and 15 deletions

View File

@ -12,8 +12,8 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="372"/>
<integer value="29"/>
<integer value="372"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -492,7 +492,7 @@
<object class="NSWindowTemplate" id="972006081">
<int key="NSWindowStyleMask">15</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{431, 306}, {551, 419}}</string>
<string key="NSWindowRect">{{431, 188}, {551, 537}}</string>
<int key="NSWTFlags">1954021376</int>
<string key="NSWindowTitle">Inside Job</string>
<string key="NSWindowClass">NSWindow</string>
@ -516,7 +516,7 @@
<object class="NSOutlineView" id="69625062">
<reference key="NSNextResponder" ref="626284851"/>
<int key="NSvFlags">4352</int>
<string key="NSFrameSize">{551, 328}</string>
<string key="NSFrameSize">{551, 160}</string>
<reference key="NSSuperview" ref="626284851"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTableHeaderView" key="NSHeaderView" id="563285969">
@ -893,7 +893,7 @@
<int key="NSTableViewDraggingDestinationStyle">0</int>
</object>
</object>
<string key="NSFrame">{{1, 17}, {551, 328}}</string>
<string key="NSFrame">{{1, 17}, {551, 160}}</string>
<reference key="NSSuperview" ref="489307225"/>
<reference key="NSNextKeyView" ref="69625062"/>
<reference key="NSDocView" ref="69625062"/>
@ -935,7 +935,7 @@
</object>
<reference ref="763389417"/>
</object>
<string key="NSFrame">{{-1, -1}, {553, 346}}</string>
<string key="NSFrame">{{-1, -1}, {553, 178}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSNextKeyView" ref="626284851"/>
<int key="NSsFlags">562</int>
@ -949,7 +949,7 @@
<object class="NSTextField" id="574149520">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">266</int>
<string key="NSFrame">{{211, 392}, {332, 14}}</string>
<string key="NSFrame">{{211, 510}, {332, 14}}</string>
<reference key="NSSuperview" ref="439893737"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="828498206">
@ -970,7 +970,7 @@
<object class="NSTextField" id="395301483">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{53, 353}, {85, 19}}</string>
<string key="NSFrame">{{53, 471}, {85, 19}}</string>
<reference key="NSSuperview" ref="439893737"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="52955396">
@ -1046,7 +1046,7 @@
<object class="NSTextField" id="924742053">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{8, 355}, {40, 14}}</string>
<string key="NSFrame">{{8, 473}, {40, 14}}</string>
<reference key="NSSuperview" ref="439893737"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="421186712">
@ -1061,8 +1061,8 @@
</object>
<object class="NSBox" id="263108995">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">12</int>
<string key="NSFrame">{{0, 378}, {551, 5}}</string>
<int key="NSvFlags">10</int>
<string key="NSFrame">{{0, 496}, {551, 5}}</string>
<reference key="NSSuperview" ref="439893737"/>
<string key="NSOffsets">{0, 0}</string>
<object class="NSTextFieldCell" key="NSTitleCell">
@ -1084,7 +1084,7 @@
<object class="NSSegmentedControl" id="626341130">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{11, 387}, {195, 25}}</string>
<string key="NSFrame">{{11, 505}, {195, 25}}</string>
<reference key="NSSuperview" ref="439893737"/>
<bool key="NSEnabled">YES</bool>
<object class="NSSegmentedCell" key="NSCell" id="587756353">
@ -1128,8 +1128,29 @@
<int key="NSSegmentStyle">2</int>
</object>
</object>
<object class="NSCustomView" id="427079584">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">278</int>
<string key="NSFrame">{{77, 295}, {432, 144}}</string>
<reference key="NSSuperview" ref="439893737"/>
<string key="NSClassName">NSView</string>
</object>
<object class="NSCustomView" id="637735386">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">278</int>
<string key="NSFrame">{{77, 239}, {432, 48}}</string>
<reference key="NSSuperview" ref="439893737"/>
<string key="NSClassName">NSView</string>
</object>
<object class="NSCustomView" id="649603357">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">278</int>
<string key="NSFrame">{{11, 247}, {48, 192}}</string>
<reference key="NSSuperview" ref="439893737"/>
<string key="NSClassName">NSView</string>
</object>
</object>
<string key="NSFrameSize">{551, 419}</string>
<string key="NSFrameSize">{551, 537}</string>
<reference key="NSSuperview"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
@ -1444,6 +1465,30 @@
</object>
<int key="connectionID">607</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">inventoryMatrixContainer</string>
<reference key="source" ref="760161335"/>
<reference key="destination" ref="427079584"/>
</object>
<int key="connectionID">614</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">quickMatrixContainer</string>
<reference key="source" ref="760161335"/>
<reference key="destination" ref="637735386"/>
</object>
<int key="connectionID">616</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">armorMatrixContainer</string>
<reference key="source" ref="760161335"/>
<reference key="destination" ref="649603357"/>
</object>
<int key="connectionID">618</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@ -1816,6 +1861,9 @@
<reference ref="395301483"/>
<reference ref="574149520"/>
<reference ref="626341130"/>
<reference ref="427079584"/>
<reference ref="649603357"/>
<reference ref="637735386"/>
</object>
<reference key="parent" ref="972006081"/>
</object>
@ -2064,6 +2112,24 @@
<reference key="object" ref="587756353"/>
<reference key="parent" ref="626341130"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">612</int>
<reference key="object" ref="427079584"/>
<reference key="parent" ref="439893737"/>
<string key="objectName">Matrix Placeholder</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">615</int>
<reference key="object" ref="637735386"/>
<reference key="parent" ref="439893737"/>
<string key="objectName">Matrix Placeholder</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">617</int>
<reference key="object" ref="649603357"/>
<reference key="parent" ref="439893737"/>
<string key="objectName">Matrix Placeholder</string>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
@ -2208,6 +2274,12 @@
<string>600.IBViewBoundsToFrameTransform</string>
<string>601.IBPluginDependency</string>
<string>601.IBSegmentedControlInspectorSelectedSegmentMetadataKey</string>
<string>612.IBPluginDependency</string>
<string>612.IBViewBoundsToFrameTransform</string>
<string>615.IBPluginDependency</string>
<string>615.IBViewBoundsToFrameTransform</string>
<string>617.IBPluginDependency</string>
<string>617.IBViewBoundsToFrameTransform</string>
<string>74.IBPluginDependency</string>
<string>74.ImportedFromIB2</string>
<string>75.IBPluginDependency</string>
@ -2307,9 +2379,9 @@
<string>{{475, 832}, {234, 43}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{191, 193}, {551, 419}}</string>
<string>{{105, 24}, {551, 537}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{191, 193}, {551, 419}}</string>
<string>{{105, 24}, {551, 537}}</string>
<integer value="1"/>
<string>{{33, 99}, {480, 360}}</string>
<string>{3.40282e+38, 3.40282e+38}</string>
@ -2381,6 +2453,18 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="0"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform">
<bytes key="NSTransformStruct">AUGgAABDcAAAA</bytes>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform">
<bytes key="NSTransformStruct">AUKaAABDcAAAA</bytes>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSAffineTransform">
<bytes key="NSTransformStruct">AUGgAABDcAAAA</bytes>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/>
@ -2414,7 +2498,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">607</int>
<int key="maxID">618</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@ -2437,13 +2521,19 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>armorMatrixContainer</string>
<string>inventoryMatrixContainer</string>
<string>outlineView</string>
<string>quickMatrixContainer</string>
<string>statusTextField</string>
<string>worldSelectionControl</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSView</string>
<string>NSView</string>
<string>NSOutlineView</string>
<string>NSView</string>
<string>NSTextField</string>
<string>NSSegmentedControl</string>
</object>
@ -2452,16 +2542,31 @@
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>armorMatrixContainer</string>
<string>inventoryMatrixContainer</string>
<string>outlineView</string>
<string>quickMatrixContainer</string>
<string>statusTextField</string>
<string>worldSelectionControl</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBToOneOutletInfo">
<string key="name">armorMatrixContainer</string>
<string key="candidateClassName">NSView</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">inventoryMatrixContainer</string>
<string key="candidateClassName">NSView</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">outlineView</string>
<string key="candidateClassName">NSOutlineView</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">quickMatrixContainer</string>
<string key="candidateClassName">NSView</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">statusTextField</string>
<string key="candidateClassName">NSTextField</string>

View File

@ -8,6 +8,7 @@
#import <Cocoa/Cocoa.h>
@class IJItemMatrix;
@class IJMinecraftLevel;
@interface IJInventoryWindowController : NSWindowController {
@ -18,6 +19,15 @@
NSSegmentedControl *worldSelectionControl;
NSTextField *statusTextField;
NSView *inventoryMatrixContainer;
IJItemMatrix *inventoryMatrix;
NSView *quickMatrixContainer;
IJItemMatrix *quickMatrix;
NSView *armorMatrixContainer;
IJItemMatrix *armorMatrix;
NSArray *rootItems;
NSMutableArray *armorItem;
NSMutableArray *quickItem;
@ -30,6 +40,9 @@
@property (nonatomic, assign) IBOutlet NSOutlineView *outlineView;
@property (nonatomic, assign) IBOutlet NSSegmentedControl *worldSelectionControl;
@property (nonatomic, assign) IBOutlet NSTextField *statusTextField;
@property (nonatomic, assign) IBOutlet NSView *inventoryMatrixContainer;
@property (nonatomic, assign) IBOutlet NSView *quickMatrixContainer;
@property (nonatomic, assign) IBOutlet NSView *armorMatrixContainer;
@property (nonatomic, retain) NSNumber *worldTime;

View File

@ -9,6 +9,7 @@
#import "IJInventoryWindowController.h"
#import "IJMinecraftLevel.h"
#import "IJInventoryItem.h"
#import "IJItemMatrix.h"
#import "IJItemPickerWindowController.h"
@implementation IJInventoryWindowController
@ -16,6 +17,8 @@
@synthesize outlineView;
@synthesize worldSelectionControl;
@synthesize statusTextField;
@synthesize inventoryMatrixContainer, quickMatrixContainer, armorMatrixContainer;
- (void)awakeFromNib
{
@ -24,6 +27,15 @@
inventoryItem = [NSMutableArray array];
rootItems = [[NSArray alloc] initWithObjects:armorItem, quickItem, inventoryItem, nil];
statusTextField.stringValue = @"";
inventoryMatrix = [IJItemMatrix itemMatrixWithFrame:inventoryMatrixContainer.bounds rows:3 columns:9];
[inventoryMatrixContainer addSubview:inventoryMatrix];
quickMatrix = [IJItemMatrix itemMatrixWithFrame:quickMatrixContainer.bounds rows:1 columns:9];
[quickMatrixContainer addSubview:quickMatrix];
armorMatrix = [IJItemMatrix itemMatrixWithFrame:armorMatrixContainer.bounds rows:4 columns:1];
[armorMatrixContainer addSubview:armorMatrix];
}
- (void)dealloc
{
@ -120,6 +132,25 @@
[outlineView reloadData];
[outlineView expandItem:nil expandChildren:YES];
for (IJInventoryItem *item in inventoryItem)
{
int slot = item.slot - IJInventorySlotNormalFirst;
NSImageCell *cell = [inventoryMatrix cellAtRow:slot/9 column:slot%9];
cell.image = item.image;
}
for (IJInventoryItem *item in quickItem)
{
int slot = item.slot - IJInventorySlotQuickFirst;
NSImageCell *cell = [quickMatrix cellAtRow:0 column:slot];
cell.image = item.image;
}
for (IJInventoryItem *item in armorItem)
{
int slot = item.slot - IJInventorySlotArmorFirst;
NSImageCell *cell = [armorMatrix cellAtRow:3-slot column:0];
cell.image = item.image;
}
dirty = NO;
statusTextField.stringValue = @"";
}

18
IJItemMatrix.h Normal file
View File

@ -0,0 +1,18 @@
//
// IJItemMatrix.h
// InsideJob
//
// Created by Adam Preble on 10/8/10.
// Copyright 2010 Adam Preble. All rights reserved.
//
#import <Cocoa/Cocoa.h>
@interface IJItemMatrix : NSMatrix {
}
+ (id)itemMatrixWithFrame:(NSRect)frame rows:(int)rows columns:(int)cols;
@end

47
IJItemMatrix.m Normal file
View File

@ -0,0 +1,47 @@
//
// IJItemMatrix.m
// InsideJob
//
// Created by Adam Preble on 10/8/10.
// Copyright 2010 Adam Preble. All rights reserved.
//
#import "IJItemMatrix.h"
@implementation IJItemMatrix
+ (id)itemMatrixWithFrame:(NSRect)frame rows:(int)rows columns:(int)cols
{
NSMatrix *matrix = nil; // output
NSImageCell *imageCellPrototype = [[[NSImageCell alloc] init] autorelease];
[imageCellPrototype setImageFrameStyle:NSImageFrameGrayBezel];
matrix = [[[self class] alloc] initWithFrame:frame
mode:NSHighlightModeMatrix
prototype:imageCellPrototype
numberOfRows:rows
numberOfColumns:cols];
[matrix setCellSize:NSMakeSize(32+16, 32+16)];
[matrix setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
[matrix setDrawsBackground:NO];
[matrix setDrawsCellBackground:NO];
[matrix setIntercellSpacing:NSMakeSize(0, 0)];
return [matrix autorelease];
}
- (id)initWithCoder:(NSCoder *)aDecoder
{
if (self = [super initWithCoder:aDecoder])
{
// Initialization code here.
}
return self;
}
- (void)dealloc
{
[super dealloc];
}
@end

View File

@ -21,6 +21,7 @@
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 */; };
66BCFEE812600847005A23F4 /* IJItemMatrix.m in Sources */ = {isa = PBXBuildFile; fileRef = 66BCFEE712600847005A23F4 /* IJItemMatrix.m */; };
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
@ -55,6 +56,8 @@
66BCFC2A125E9A51005A23F4 /* Credits.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = Credits.rtf; sourceTree = "<group>"; };
66BCFC35125EA53E005A23F4 /* InsideJob.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = InsideJob.icns; sourceTree = "<group>"; };
66BCFE61125FCEC6005A23F4 /* DataValuesV110Transparent.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = DataValuesV110Transparent.png; sourceTree = "<group>"; };
66BCFEE612600847005A23F4 /* IJItemMatrix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IJItemMatrix.h; sourceTree = "<group>"; };
66BCFEE712600847005A23F4 /* IJItemMatrix.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = IJItemMatrix.m; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* InsideJob-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "InsideJob-Info.plist"; sourceTree = "<group>"; };
8D1107320486CEB800E47090 /* Inside Job.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Inside Job.app"; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
@ -185,6 +188,8 @@
668B27F1125D963F0060BF71 /* IJInventoryWindowController.m */,
668B2977125E5DD40060BF71 /* IJItemPickerWindowController.h */,
668B2978125E5DD40060BF71 /* IJItemPickerWindowController.m */,
66BCFEE612600847005A23F4 /* IJItemMatrix.h */,
66BCFEE712600847005A23F4 /* IJItemMatrix.m */,
);
name = Interface;
sourceTree = "<group>";
@ -267,6 +272,7 @@
668B27B2125D8F8E0060BF71 /* IJInventoryItem.m in Sources */,
668B27F2125D963F0060BF71 /* IJInventoryWindowController.m in Sources */,
668B2979125E5DD40060BF71 /* IJItemPickerWindowController.m in Sources */,
66BCFEE812600847005A23F4 /* IJItemMatrix.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};