Add support for launching the game.
This commit is contained in:
@@ -9,10 +9,13 @@
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
@class ModEntry;
|
||||
@class GameInstall;
|
||||
@interface Controller : NSObject
|
||||
{
|
||||
ModEntry *sidebarItems;
|
||||
GameInstall *game;
|
||||
IBOutlet NSOutlineView *outlineView;
|
||||
}
|
||||
- (ModEntry *)modTree;
|
||||
- (IBAction)launchGame:(id)sender;
|
||||
@end
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
#import "Controller.h"
|
||||
#import "ModEntry.h"
|
||||
#import "GameInstall.h"
|
||||
#import "ImageAndTextCell.h"
|
||||
|
||||
@implementation Controller
|
||||
@@ -24,6 +25,8 @@
|
||||
[outlineView reloadData];
|
||||
[outlineView expandItem:[outlineView itemAtRow:1] expandChildren:YES];
|
||||
[outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:1] byExtendingSelection:NO];
|
||||
|
||||
game = [[GameInstall alloc] initWithPath:@"/Users/paul/src/OpenRA"];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
@@ -110,4 +113,9 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)launchGame:(id)sender
|
||||
{
|
||||
[game launchGame];
|
||||
}
|
||||
@end
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
</object>
|
||||
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<integer value="29"/>
|
||||
<integer value="57"/>
|
||||
<integer value="371"/>
|
||||
</object>
|
||||
<object class="NSArray" key="IBDocument.PluginDependencies">
|
||||
@@ -337,7 +337,7 @@
|
||||
<int key="NSCellFlags">337772096</int>
|
||||
<int key="NSCellFlags2">2048</int>
|
||||
<string key="NSContents">Text Cell</string>
|
||||
<object class="NSFont" key="NSSupport">
|
||||
<object class="NSFont" key="NSSupport" id="868513215">
|
||||
<string key="NSName">LucidaGrande</string>
|
||||
<double key="NSSize">13</double>
|
||||
<int key="NSfFlags">1044</int>
|
||||
@@ -443,6 +443,29 @@
|
||||
<object class="NSCustomView" id="257490795">
|
||||
<reference key="NSNextResponder" ref="991115689"/>
|
||||
<int key="NSvFlags">256</int>
|
||||
<object class="NSMutableArray" key="NSSubviews">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<object class="NSButton" id="430464371">
|
||||
<reference key="NSNextResponder" ref="257490795"/>
|
||||
<int key="NSvFlags">268</int>
|
||||
<string key="NSFrame">{{383, 15}, {111, 27}}</string>
|
||||
<reference key="NSSuperview" ref="257490795"/>
|
||||
<bool key="NSEnabled">YES</bool>
|
||||
<object class="NSButtonCell" key="NSCell" id="492098390">
|
||||
<int key="NSCellFlags">-2080244224</int>
|
||||
<int key="NSCellFlags2">134217728</int>
|
||||
<string key="NSContents">GO!</string>
|
||||
<reference key="NSSupport" ref="868513215"/>
|
||||
<reference key="NSControlView" ref="430464371"/>
|
||||
<int key="NSButtonFlags">-2033434369</int>
|
||||
<int key="NSButtonFlags2">160</int>
|
||||
<string key="NSAlternateContents"/>
|
||||
<string key="NSKeyEquivalent"/>
|
||||
<int key="NSPeriodicDelay">400</int>
|
||||
<int key="NSPeriodicInterval">75</int>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<string key="NSFrame">{{146, 0}, {513, 469}}</string>
|
||||
<reference key="NSSuperview" ref="991115689"/>
|
||||
<int key="NSViewLayerContentsRedrawPolicy">2</int>
|
||||
@@ -585,6 +608,14 @@
|
||||
</object>
|
||||
<int key="connectionID">585</int>
|
||||
</object>
|
||||
<object class="IBConnectionRecord">
|
||||
<object class="IBActionConnection" key="connection">
|
||||
<string key="label">launchGame:</string>
|
||||
<reference key="source" ref="79272443"/>
|
||||
<reference key="destination" ref="430464371"/>
|
||||
</object>
|
||||
<int key="connectionID">588</int>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBMutableOrderedSet" key="objectRecords">
|
||||
<object class="NSArray" key="orderedObjects">
|
||||
@@ -820,6 +851,7 @@
|
||||
<reference key="object" ref="257490795"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="430464371"/>
|
||||
</object>
|
||||
<reference key="parent" ref="991115689"/>
|
||||
</object>
|
||||
@@ -881,6 +913,20 @@
|
||||
<reference key="object" ref="79272443"/>
|
||||
<reference key="parent" ref="0"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">586</int>
|
||||
<reference key="object" ref="430464371"/>
|
||||
<object class="NSMutableArray" key="children">
|
||||
<bool key="EncodedWithXMLCoder">YES</bool>
|
||||
<reference ref="492098390"/>
|
||||
</object>
|
||||
<reference key="parent" ref="257490795"/>
|
||||
</object>
|
||||
<object class="IBObjectRecord">
|
||||
<int key="objectID">587</int>
|
||||
<reference key="object" ref="492098390"/>
|
||||
<reference key="parent" ref="430464371"/>
|
||||
</object>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="flattenedProperties">
|
||||
@@ -959,6 +1005,9 @@
|
||||
<string>579.IBPluginDependency</string>
|
||||
<string>58.IBPluginDependency</string>
|
||||
<string>58.ImportedFromIB2</string>
|
||||
<string>586.IBPluginDependency</string>
|
||||
<string>586.IBViewBoundsToFrameTransform</string>
|
||||
<string>587.IBPluginDependency</string>
|
||||
<string>92.IBPluginDependency</string>
|
||||
<string>92.ImportedFromIB2</string>
|
||||
</object>
|
||||
@@ -1039,6 +1088,11 @@
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<integer value="1"/>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<object class="NSAffineTransform">
|
||||
<bytes key="NSTransformStruct">P4AAAL+AAABDnQAAw6CAAA</bytes>
|
||||
</object>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
|
||||
<integer value="1"/>
|
||||
</object>
|
||||
</object>
|
||||
@@ -1058,7 +1112,7 @@
|
||||
</object>
|
||||
</object>
|
||||
<nil key="sourceID"/>
|
||||
<int key="maxID">585</int>
|
||||
<int key="maxID">588</int>
|
||||
</object>
|
||||
<object class="IBClassDescriber" key="IBDocument.Classes">
|
||||
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
|
||||
@@ -1066,6 +1120,17 @@
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">Controller</string>
|
||||
<string key="superclassName">NSObject</string>
|
||||
<object class="NSMutableDictionary" key="actions">
|
||||
<string key="NS.key.0">launchGame:</string>
|
||||
<string key="NS.object.0">id</string>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="actionInfosByName">
|
||||
<string key="NS.key.0">launchGame:</string>
|
||||
<object class="IBActionInfo" key="NS.object.0">
|
||||
<string key="name">launchGame:</string>
|
||||
<string key="candidateClassName">id</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="NSMutableDictionary" key="outlets">
|
||||
<string key="NS.key.0">outlineView</string>
|
||||
<string key="NS.object.0">NSOutlineView</string>
|
||||
@@ -1155,6 +1220,22 @@
|
||||
<string key="minorKey">AppKit.framework/Headers/NSUserInterfaceItemSearching.h</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">NSButton</string>
|
||||
<string key="superclassName">NSControl</string>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBFrameworkSource</string>
|
||||
<string key="minorKey">AppKit.framework/Headers/NSButton.h</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">NSButtonCell</string>
|
||||
<string key="superclassName">NSActionCell</string>
|
||||
<object class="IBClassDescriptionSource" key="sourceIdentifier">
|
||||
<string key="majorKey">IBFrameworkSource</string>
|
||||
<string key="minorKey">AppKit.framework/Headers/NSButtonCell.h</string>
|
||||
</object>
|
||||
</object>
|
||||
<object class="IBPartialClassDescription">
|
||||
<string key="className">NSCell</string>
|
||||
<string key="superclassName">NSObject</string>
|
||||
|
||||
18
OpenRA.Launcher.Mac/GameInstall.h
Normal file
18
OpenRA.Launcher.Mac/GameInstall.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//
|
||||
// GameInstall.h
|
||||
// OpenRA
|
||||
//
|
||||
// Created by Paul Chote on 15/11/10.
|
||||
// Copyright 2010 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
|
||||
@interface GameInstall : NSObject {
|
||||
NSString *gamePath;
|
||||
}
|
||||
|
||||
-(id)initWithPath:(NSString *)path;
|
||||
-(void)launchGame;
|
||||
@end
|
||||
52
OpenRA.Launcher.Mac/GameInstall.m
Normal file
52
OpenRA.Launcher.Mac/GameInstall.m
Normal file
@@ -0,0 +1,52 @@
|
||||
//
|
||||
// GameInstall.m
|
||||
// OpenRA
|
||||
//
|
||||
// Created by Paul Chote on 15/11/10.
|
||||
// Copyright 2010 __MyCompanyName__. All rights reserved.
|
||||
//
|
||||
|
||||
#import "GameInstall.h"
|
||||
|
||||
|
||||
@implementation GameInstall
|
||||
|
||||
-(id)initWithPath:(NSString *)path
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
NSLog(@"creating game at path %@",path);
|
||||
|
||||
gamePath = path;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
-(void)launchGame
|
||||
{
|
||||
// Use LaunchServices because neither NSTask or NSWorkspace support Info.plist _and_ arguments pre-10.6
|
||||
NSString *path = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"OpenRA.app/Contents/MacOS/OpenRA"];
|
||||
NSArray *args = [NSArray arrayWithObjects:gamePath, @"mono", @"--debug", @"OpenRA.Game.exe", @"Game.Mods=ra",nil];
|
||||
|
||||
FSRef appRef;
|
||||
CFURLGetFSRef((CFURLRef)[NSURL URLWithString:path], &appRef);
|
||||
|
||||
// Set the launch parameters
|
||||
LSApplicationParameters params;
|
||||
params.version = 0;
|
||||
params.flags = kLSLaunchDefaults;
|
||||
params.application = &appRef;
|
||||
params.asyncLaunchRefCon = NULL;
|
||||
params.environment = NULL; // CFDictionaryRef of environment variables; could be useful
|
||||
params.argv = (CFArrayRef)args;
|
||||
params.initialEvent = NULL;
|
||||
|
||||
ProcessSerialNumber psn;
|
||||
OSStatus err = LSOpenApplication(¶ms, &psn);
|
||||
|
||||
// Bring the game window to the front
|
||||
if (err == noErr)
|
||||
SetFrontProcess(&psn);
|
||||
}
|
||||
@end
|
||||
@@ -5,15 +5,17 @@
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<string>OpenRA</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>OpenRA.icns</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>OpenRA Launcher</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>OpenRA Launcher</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.yourcompany.${PRODUCT_NAME:rfc1034identifier}</string>
|
||||
<string>org.open-ra.launcher.mac</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
|
||||
12
OpenRA.Launcher.Mac/OpenRA.app/Contents/Info.plist
Executable file
12
OpenRA.Launcher.Mac/OpenRA.app/Contents/Info.plist
Executable file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>OpenRA</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>OpenRA</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>OpenRA.icns</string>
|
||||
</dict>
|
||||
</plist>
|
||||
10
OpenRA.Launcher.Mac/OpenRA.app/Contents/MacOS/OpenRA
Executable file
10
OpenRA.Launcher.Mac/OpenRA.app/Contents/MacOS/OpenRA
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
# Copyright 2007-2010 The OpenRA Developers (see AUTHORS)
|
||||
# This file is part of OpenRA, which is free software. It is made
|
||||
# available to you under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation. For more information,
|
||||
# see LICENSE.
|
||||
|
||||
echo "Launching OpenRA from $1"
|
||||
cd $1
|
||||
${@:2}
|
||||
1
OpenRA.Launcher.Mac/OpenRA.app/Contents/Resources/OpenRA.icns
Symbolic link
1
OpenRA.Launcher.Mac/OpenRA.app/Contents/Resources/OpenRA.icns
Symbolic link
@@ -0,0 +1 @@
|
||||
../../../OpenRA.icns
|
||||
@@ -16,6 +16,8 @@
|
||||
DA81FAAA1290FA0000C48F2F /* ModEntry.m in Sources */ = {isa = PBXBuildFile; fileRef = DA81FAA91290FA0000C48F2F /* ModEntry.m */; };
|
||||
DA81FB9312910A8B00C48F2F /* ImageAndTextCell.m in Sources */ = {isa = PBXBuildFile; fileRef = DA81FB9212910A8B00C48F2F /* ImageAndTextCell.m */; };
|
||||
DA81FBDC12910E4900C48F2F /* OpenRA.icns in Resources */ = {isa = PBXBuildFile; fileRef = DA81FBDB12910E4900C48F2F /* OpenRA.icns */; };
|
||||
DA81FC3F12911E2B00C48F2F /* GameInstall.m in Sources */ = {isa = PBXBuildFile; fileRef = DA81FC3E12911E2B00C48F2F /* GameInstall.m */; };
|
||||
DA9292C81291DF2D00EDB02E /* OpenRA.app in Resources */ = {isa = PBXBuildFile; fileRef = DA9292C71291DF2D00EDB02E /* OpenRA.app */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
@@ -38,6 +40,9 @@
|
||||
DA81FB9112910A8B00C48F2F /* ImageAndTextCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageAndTextCell.h; sourceTree = "<group>"; };
|
||||
DA81FB9212910A8B00C48F2F /* ImageAndTextCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageAndTextCell.m; sourceTree = "<group>"; };
|
||||
DA81FBDB12910E4900C48F2F /* OpenRA.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = OpenRA.icns; sourceTree = "<group>"; };
|
||||
DA81FC3D12911E2B00C48F2F /* GameInstall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameInstall.h; sourceTree = "<group>"; };
|
||||
DA81FC3E12911E2B00C48F2F /* GameInstall.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameInstall.m; sourceTree = "<group>"; };
|
||||
DA9292C71291DF2D00EDB02E /* OpenRA.app */ = {isa = PBXFileReference; lastKnownFileType = wrapper.application; path = OpenRA.app; sourceTree = "<group>"; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@@ -63,6 +68,8 @@
|
||||
DA81FA811290F5C800C48F2F /* Controller.m */,
|
||||
DA81FAA81290FA0000C48F2F /* ModEntry.h */,
|
||||
DA81FAA91290FA0000C48F2F /* ModEntry.m */,
|
||||
DA81FC3D12911E2B00C48F2F /* GameInstall.h */,
|
||||
DA81FC3E12911E2B00C48F2F /* GameInstall.m */,
|
||||
);
|
||||
name = Classes;
|
||||
sourceTree = "<group>";
|
||||
@@ -117,6 +124,7 @@
|
||||
29B97317FDCFA39411CA2CEA /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
DA9292C71291DF2D00EDB02E /* OpenRA.app */,
|
||||
DA81FBDB12910E4900C48F2F /* OpenRA.icns */,
|
||||
8D1107310486CEB800E47090 /* OpenRA-Info.plist */,
|
||||
089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
|
||||
@@ -187,6 +195,7 @@
|
||||
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */,
|
||||
1DDD58160DA1D0A300B32029 /* MainMenu.xib in Resources */,
|
||||
DA81FBDC12910E4900C48F2F /* OpenRA.icns in Resources */,
|
||||
DA9292C81291DF2D00EDB02E /* OpenRA.app in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@@ -202,6 +211,7 @@
|
||||
DA81FA821290F5C800C48F2F /* Controller.m in Sources */,
|
||||
DA81FAAA1290FA0000C48F2F /* ModEntry.m in Sources */,
|
||||
DA81FB9312910A8B00C48F2F /* ImageAndTextCell.m in Sources */,
|
||||
DA81FC3F12911E2B00C48F2F /* GameInstall.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
||||
@@ -159,7 +159,14 @@
|
||||
isa = PBXProject;
|
||||
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "OpenRA" */;
|
||||
compatibilityVersion = "Xcode 3.1";
|
||||
developmentRegion = English;
|
||||
hasScannedForEncodings = 1;
|
||||
knownRegions = (
|
||||
English,
|
||||
Japanese,
|
||||
French,
|
||||
German,
|
||||
);
|
||||
mainGroup = 29B97314FDCFA39411CA2CEA /* OpenRA */;
|
||||
projectDirPath = "";
|
||||
projectRoot = "";
|
||||
|
||||
Reference in New Issue
Block a user