Add mono version check
This commit is contained in:
@@ -19,6 +19,9 @@
|
||||
GameInstall *game;
|
||||
NSDictionary *allMods;
|
||||
NSMutableDictionary *downloads;
|
||||
BOOL hasMono;
|
||||
|
||||
IBOutlet NSWindow *window;
|
||||
IBOutlet NSOutlineView *outlineView;
|
||||
IBOutlet WebView *webView;
|
||||
}
|
||||
@@ -32,5 +35,5 @@
|
||||
|
||||
- (BOOL)registerDownload:(NSString *)key withURL:(NSString *)url filePath:(NSString *)path;
|
||||
- (Download *)downloadWithKey:(NSString *)key;
|
||||
|
||||
- (BOOL)hasSupportedMono;
|
||||
@end
|
||||
|
||||
@@ -19,35 +19,92 @@
|
||||
@synthesize webView;
|
||||
|
||||
- (void)awakeFromNib
|
||||
{
|
||||
{
|
||||
game = [[GameInstall alloc] initWithURL:[NSURL URLWithString:@"/Users/paul/src/OpenRA"]];
|
||||
[[JSBridge sharedInstance] setController:self];
|
||||
downloads = [[NSMutableDictionary alloc] init];
|
||||
|
||||
NSTableColumn *col = [outlineView tableColumnWithIdentifier:@"mods"];
|
||||
ImageAndTextCell *imageAndTextCell = [[[ImageAndTextCell alloc] init] autorelease];
|
||||
[col setDataCell:imageAndTextCell];
|
||||
|
||||
sidebarItems = [[SidebarEntry headerWithTitle:@""] retain];
|
||||
[self populateModInfo];
|
||||
id modsRoot = [self sidebarModsTree];
|
||||
[sidebarItems addChild:modsRoot];
|
||||
id otherRoot = [self sidebarOtherTree];
|
||||
[sidebarItems addChild:otherRoot];
|
||||
|
||||
|
||||
[outlineView reloadData];
|
||||
[outlineView expandItem:modsRoot expandChildren:YES];
|
||||
|
||||
if ([[modsRoot children] count] > 0)
|
||||
hasMono = [self hasSupportedMono];
|
||||
if (hasMono)
|
||||
{
|
||||
id firstMod = [[modsRoot children] objectAtIndex:0];
|
||||
int row = [outlineView rowForItem:firstMod];
|
||||
[outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO];
|
||||
[[webView mainFrame] loadRequest:[NSURLRequest requestWithURL: [firstMod url]]];
|
||||
NSTableColumn *col = [outlineView tableColumnWithIdentifier:@"mods"];
|
||||
ImageAndTextCell *imageAndTextCell = [[[ImageAndTextCell alloc] init] autorelease];
|
||||
[col setDataCell:imageAndTextCell];
|
||||
|
||||
sidebarItems = [[SidebarEntry headerWithTitle:@""] retain];
|
||||
[self populateModInfo];
|
||||
id modsRoot = [self sidebarModsTree];
|
||||
[sidebarItems addChild:modsRoot];
|
||||
id otherRoot = [self sidebarOtherTree];
|
||||
[sidebarItems addChild:otherRoot];
|
||||
|
||||
|
||||
[outlineView reloadData];
|
||||
[outlineView expandItem:modsRoot expandChildren:YES];
|
||||
|
||||
if ([[modsRoot children] count] > 0)
|
||||
{
|
||||
id firstMod = [[modsRoot children] objectAtIndex:0];
|
||||
int row = [outlineView rowForItem:firstMod];
|
||||
[outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:row] byExtendingSelection:NO];
|
||||
[[webView mainFrame] loadRequest:[NSURLRequest requestWithURL: [firstMod url]]];
|
||||
}
|
||||
|
||||
[outlineView expandItem:otherRoot expandChildren:YES];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
||||
{
|
||||
if (!hasMono)
|
||||
{
|
||||
NSAlert *alert = [NSAlert alertWithMessageText:@"Mono Framework"
|
||||
defaultButton:@"Download Mono"
|
||||
alternateButton:@"Quit"
|
||||
otherButton:nil
|
||||
informativeTextWithFormat:@"OpenRA requires the Mono Framework version 2.6.7 or later."];
|
||||
|
||||
[alert beginSheetModalForWindow:window modalDelegate:self didEndSelector:@selector(monoAlertEnded:code:context:) contextInfo:NULL];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)monoAlertEnded:(NSAlert *)alert
|
||||
code:(int)button
|
||||
context:(void *)v
|
||||
{
|
||||
if (button == NSAlertDefaultReturn)
|
||||
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"http://www.go-mono.com/mono-downloads/download.html"]];
|
||||
|
||||
[outlineView expandItem:otherRoot expandChildren:YES];
|
||||
[[NSApplication sharedApplication] terminate:self];
|
||||
}
|
||||
|
||||
- (BOOL)hasSupportedMono
|
||||
{
|
||||
if (![[NSFileManager defaultManager] fileExistsAtPath:@"/Library/Frameworks/Mono.framework/Commands/mono"])
|
||||
return NO;
|
||||
|
||||
NSPipe *outPipe = [NSPipe pipe];
|
||||
NSTask *task = [[NSTask alloc] init];
|
||||
[task setLaunchPath:@"/Library/Frameworks/Mono.framework/Commands/mono"];
|
||||
[task setArguments:[NSMutableArray arrayWithObject:@"--version"]];
|
||||
[task setStandardOutput:outPipe];
|
||||
[task setStandardError:[task standardOutput]];
|
||||
[task launch];
|
||||
|
||||
NSData *data = [[outPipe fileHandleForReading] readDataToEndOfFile];
|
||||
[task waitUntilExit];
|
||||
[task release];
|
||||
|
||||
NSString *ret = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
|
||||
|
||||
int major = 0;
|
||||
int minor = 0;
|
||||
int point = 0;
|
||||
sscanf([ret UTF8String], "Mono JIT compiler version %d.%d.%d", &major, &minor, &point);
|
||||
[ret release];
|
||||
|
||||
return (major > 2 ||
|
||||
(major == 2 && minor > 6) ||
|
||||
(major == 2 && minor == 6 && point >= 7));
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
@@ -210,11 +267,11 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
otherButton:nil
|
||||
informativeTextWithFormat:@"%@ in progress and will be cancelled.", format];
|
||||
|
||||
[alert beginSheetModalForWindow:[webView window] modalDelegate:self didEndSelector:@selector(alertEnded:code:context:) contextInfo:NULL];
|
||||
[alert beginSheetModalForWindow:window modalDelegate:self didEndSelector:@selector(quitAlertEnded:code:context:) contextInfo:NULL];
|
||||
return NSTerminateLater;
|
||||
}
|
||||
|
||||
- (void)alertEnded:(NSAlert *)alert
|
||||
- (void)quitAlertEnded:(NSAlert *)alert
|
||||
code:(int)button
|
||||
context:(void *)v
|
||||
{
|
||||
|
||||
@@ -653,6 +653,14 @@
|
||||
</object>
|
||||
<int key="connectionID">592</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBOutletConnection" key="connection">
|
||||
<string key="label">window</string>
|
||||
<reference key="source" ref="79272443"/>
|
||||
<reference key="destination" ref="972006081"/>
|
||||
</object>
|
||||
<int key="connectionID">593</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<object class="NSArray" key="orderedObjects">
|
||||
@@ -1075,9 +1083,9 @@
|
||||
<integer value="1"/>
|
||||
<string>{74, 862}</string>
|
||||
<string>{{6, 978}, {478, 20}}</string>
|
||||
<string>{{611, 537}, {659, 469}}</string>
|
||||
<string>{{378, 537}, {659, 469}}</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>{{611, 537}, {659, 469}}</string>
|
||||
<string>{{378, 537}, {659, 469}}</string>
|
||||
<integer value="1"/>
|
||||
<string>{{33, 99}, {480, 360}}</string>
|
||||
<string>{3.40282e+38, 3.40282e+38}</string>
|
||||
@@ -1131,7 +1139,7 @@
|
||||
</object>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">592</int>
|
||||
<int key="maxID">593</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
@@ -1145,11 +1153,13 @@
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>outlineView</string>
|
||||
<string>webView</string>
|
||||
<string>window</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>NSOutlineView</string>
|
||||
<string>WebView</string>
|
||||
<string>NSWindow</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
|
||||
@@ -1158,6 +1168,7 @@
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<string>outlineView</string>
|
||||
<string>webView</string>
|
||||
<string>window</string>
|
||||
</object>
|
||||
<object class="NSMutableArray" key="dict.values">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
@@ -1169,6 +1180,10 @@
|
||||
<string key="name">webView</string>
|
||||
<string key="candidateClassName">WebView</string>
|
||||
</object>
|
||||
<object class="IBToOneOutletInfo">
|
||||
<string key="name">window</string>
|
||||
<string key="candidateClassName">NSWindow</string>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
|
||||
Reference in New Issue
Block a user