-
Notifications
You must be signed in to change notification settings - Fork 1
/
MinecraftInTheCloudAppDelegate.m
132 lines (105 loc) · 2.26 KB
/
MinecraftInTheCloudAppDelegate.m
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
//
// MinecraftInTheCloudAppDelegate.m
// MinecraftInTheCloud
//
// Created by Rishi Shah on 2/4/11.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "MinecraftInTheCloudAppDelegate.h"
#import "MCCloud.h"
@implementation MinecraftInTheCloudAppDelegate
@synthesize window;
@synthesize checkBox;
@synthesize world;
@synthesize cl;
- (id) init {
if (self = [super init]) {
self.world = 1;
self.cl = [[[MCCloud alloc] init] autorelease];
}
return self;
}
- (void) dealloc {
self.cl = nil;
[super dealloc];
}
- (IBAction) worldChanged: (id)sender {
if ([sender indexOfSelectedItem] > 4) {
self.world = 1;
return;
}
switch ([sender indexOfSelectedItem]) {
case 0:
self.world = 1;
break;
case 1:
self.world = 2;
break;
case 2:
self.world = 3;
break;
case 3:
self.world = 4;
break;
case 4:
self.world = 5;
break;
default:
self.world = 1;
break;
}
}
- (IBAction) cloudChanged: (id)sender {
NSOpenPanel* openPanel = [NSOpenPanel openPanel];
[openPanel setAllowsMultipleSelection:NO];
[openPanel setCanChooseFiles:NO];
[openPanel setCanChooseDirectories:YES];
int result = [openPanel runModalForDirectory:NSHomeDirectory() file:nil];
if (result == NSOKButton) {
self.cl.DROPBOX = [openPanel filename];
[sender setTitle:self.cl.DROPBOX];
}
}
- (IBAction) mineClicked: (id)sender {
NSString* currentWorld;
switch (self.world) {
case 1:
currentWorld = self.cl.WORLD1;
break;
case 2:
currentWorld = self.cl.WORLD2;
break;
case 3:
currentWorld = self.cl.WORLD3;
break;
case 4:
currentWorld = self.cl.WORLD4;
break;
case 5:
currentWorld = self.cl.WORLD5;
break;
default:
currentWorld = self.cl.WORLD1;
break;
}
NSError* error = nil;
if ([checkBox state])
error = [cl initializeCloudWithoutCopying:self.cl.DROPBOX worlds:currentWorld];
else
error = [cl initializeCloud:self.cl.DROPBOX worlds:currentWorld];
if (error != nil) {
[NSApp presentError:error];
}
else {
[sender setTitle:@"Done!"];
}
}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
}
- (void)awakeFromNib {
[window setDelegate:self];
}
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender {
return YES;
}
@end