-
Notifications
You must be signed in to change notification settings - Fork 6
/
BlockFinderPanelController.mm
92 lines (77 loc) · 2.39 KB
/
BlockFinderPanelController.mm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//
// BlockFinderPanelController.m
// MCMap Live
//
// Created by DK on 10/23/10.
//
#import "BlockFinderPanelController.h"
NSDictionary* minecraft_blocks;
BOOL color_stored = NO;
@implementation BlockFinderPanelController
- (IBAction)selectBlock:(id)sender
{
if(sender == selectNoneMenuItem)
{
NSArray* menuitems = [blockFinderMenu itemArray];
for (NSMenuItem* item in menuitems)
[item setState:NSOffState];
}
else
{
//NSLog(@"Got event to change state of %@",[sender title]);
if ([sender state]==NSOnState)
[sender setState: NSOffState];
else
[sender setState: NSOnState];
}
//[blockFinderMenu update];
}
- (IBAction)startBlockFinder:(id)sender
{
NSArray* menuitems = [blockFinderMenu itemArray];
NSMutableArray* blocks = [[NSMutableArray alloc] init];
for (NSMenuItem* item in menuitems)
{
if ([item state]== NSOnState)
{
NSNumber* blockid = [minecraft_blocks objectForKey:[item title]];
if (blockid != Nil)
{
[blocks addObject: [blockid copy]];
//NSLog(@"Block %@ added to blocks",[item title]);
}
}
}
double xray = [xraySlider doubleValue];
//NSLog(@"Ready to fire setup message.");
[mapview startBlockFinder:blocks inColor:[finderColor color] xray:xray];
//NSLog(@"Set up Block Finder color set.");
[blocks release];
}
- (void)awakeFromNib
{
// Load up the dictionary of minecraft block names and IDs
minecraft_blocks = [[NSDictionary dictionaryWithContentsOfFile:[ NSString stringWithFormat:@"%@/tiles.plist",[ [ NSBundle mainBundle ] resourcePath ]]] retain] ;
// Populate the Blockfinder Menu
[blockSelector setAutoenablesItems:NO];
for (NSString* tilename in [[minecraft_blocks allKeys] sortedArrayUsingSelector:@selector(compare:)])
{
NSMenuItem* tileitem = [[NSMenuItem alloc] initWithTitle:tilename action:@selector(selectBlock:) keyEquivalent:@""];
[blockFinderMenu addItem:tileitem];
}
[blockSelector setMenu:blockFinderMenu];
}
- (void)windowWillClose:(NSNotification *)notification
{
[mapview restoreColor];
color_stored = NO;
}
- (void)windowDidBecomeKey:(NSNotification *)notification
{
if (!color_stored)
{
[mapview storeColor];
color_stored = YES;
}
}
@end