Fix encoding issue with OpenRA.Utility. Refactor SidebarEntry. Add launcher pages to all mods.
This commit is contained in:
@@ -18,15 +18,20 @@
|
|||||||
- (void) awakeFromNib
|
- (void) awakeFromNib
|
||||||
{
|
{
|
||||||
game = [[GameInstall alloc] initWithURL:[NSURL URLWithString:@"/Users/paul/src/OpenRA"]];
|
game = [[GameInstall alloc] initWithURL:[NSURL URLWithString:@"/Users/paul/src/OpenRA"]];
|
||||||
sidebarItems = [[SidebarEntry headerWithTitle:@""] retain];
|
|
||||||
[sidebarItems addChild:[self sidebarModsTree]];
|
|
||||||
[sidebarItems addChild:[self sidebarOtherTree]];
|
|
||||||
NSTableColumn *col = [outlineView tableColumnWithIdentifier:@"mods"];
|
NSTableColumn *col = [outlineView tableColumnWithIdentifier:@"mods"];
|
||||||
ImageAndTextCell *imageAndTextCell = [[[ImageAndTextCell alloc] init] autorelease];
|
ImageAndTextCell *imageAndTextCell = [[[ImageAndTextCell alloc] init] autorelease];
|
||||||
[col setDataCell:imageAndTextCell];
|
[col setDataCell:imageAndTextCell];
|
||||||
|
|
||||||
|
sidebarItems = [[SidebarEntry headerWithTitle:@""] retain];
|
||||||
|
id modsRoot = [self sidebarModsTree];
|
||||||
|
[sidebarItems addChild:modsRoot];
|
||||||
|
id otherRoot = [self sidebarOtherTree];
|
||||||
|
[sidebarItems addChild:otherRoot];
|
||||||
|
|
||||||
|
|
||||||
[outlineView reloadData];
|
[outlineView reloadData];
|
||||||
[outlineView expandItem:[outlineView itemAtRow:0] expandChildren:YES];
|
[outlineView expandItem:modsRoot expandChildren:YES];
|
||||||
|
[outlineView expandItem:otherRoot expandChildren:YES];
|
||||||
[outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:1] byExtendingSelection:NO];
|
[outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:1] byExtendingSelection:NO];
|
||||||
|
|
||||||
jsbridge = [[JSBridge alloc] initWithController:self];
|
jsbridge = [[JSBridge alloc] initWithController:self];
|
||||||
@@ -44,7 +49,7 @@
|
|||||||
{
|
{
|
||||||
if ([aMod standalone])
|
if ([aMod standalone])
|
||||||
{
|
{
|
||||||
id child = [SidebarEntry entryWithMod:aMod allMods:allMods];
|
id child = [SidebarEntry entryWithMod:aMod allMods:allMods baseURL:[[game gameURL] URLByAppendingPathComponent:@"mods"]];
|
||||||
[rootItem addChild:child];
|
[rootItem addChild:child];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,8 +60,8 @@
|
|||||||
- (SidebarEntry *)sidebarOtherTree
|
- (SidebarEntry *)sidebarOtherTree
|
||||||
{
|
{
|
||||||
SidebarEntry *rootItem = [SidebarEntry headerWithTitle:@"OTHER"];
|
SidebarEntry *rootItem = [SidebarEntry headerWithTitle:@"OTHER"];
|
||||||
[rootItem addChild:[SidebarEntry entryWithTitle:@"Support" object:nil icon:nil]];
|
[rootItem addChild:[SidebarEntry entryWithTitle:@"Support" url:nil icon:nil]];
|
||||||
[rootItem addChild:[SidebarEntry entryWithTitle:@"Credits" object:nil icon:nil]];
|
[rootItem addChild:[SidebarEntry entryWithTitle:@"Credits" url:nil icon:nil]];
|
||||||
|
|
||||||
return rootItem;
|
return rootItem;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
@interface GameInstall : NSObject {
|
@interface GameInstall : NSObject {
|
||||||
NSURL *gameURL;
|
NSURL *gameURL;
|
||||||
}
|
}
|
||||||
|
@property(readonly) NSURL *gameURL;
|
||||||
|
|
||||||
-(id)initWithURL:(NSURL *)path;
|
-(id)initWithURL:(NSURL *)path;
|
||||||
-(void)launchGame;
|
-(void)launchGame;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#import "Mod.h"
|
#import "Mod.h"
|
||||||
|
|
||||||
@implementation GameInstall
|
@implementation GameInstall
|
||||||
|
@synthesize gameURL;
|
||||||
|
|
||||||
-(id)initWithURL:(NSURL *)url
|
-(id)initWithURL:(NSURL *)url
|
||||||
{
|
{
|
||||||
@@ -78,6 +79,12 @@
|
|||||||
[fields setObject:[value stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]
|
[fields setObject:[value stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]
|
||||||
forKey:key];
|
forKey:key];
|
||||||
}
|
}
|
||||||
|
if (current != nil)
|
||||||
|
{
|
||||||
|
id url = [gameURL URLByAppendingPathComponent:[NSString stringWithFormat:@"mods/%@",current]];
|
||||||
|
[ret addObject:[Mod modWithId:current fields:fields baseURL:url]];
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,11 +117,11 @@
|
|||||||
|
|
||||||
- (NSString *)runUtilityQuery:(NSString *)arg
|
- (NSString *)runUtilityQuery:(NSString *)arg
|
||||||
{
|
{
|
||||||
NSTask *task = [[NSTask alloc] init];
|
|
||||||
NSPipe *outPipe = [NSPipe pipe];
|
NSPipe *outPipe = [NSPipe pipe];
|
||||||
NSMutableArray *taskArgs = [NSMutableArray arrayWithObject:@"OpenRA.Utility.exe"];
|
NSMutableArray *taskArgs = [NSMutableArray arrayWithObject:@"OpenRA.Utility.exe"];
|
||||||
[taskArgs addObject:arg];
|
[taskArgs addObject:arg];
|
||||||
|
|
||||||
|
NSTask *task = [[NSTask alloc] init];
|
||||||
[task setCurrentDirectoryPath:[gameURL absoluteString]];
|
[task setCurrentDirectoryPath:[gameURL absoluteString]];
|
||||||
[task setLaunchPath:@"/Library/Frameworks/Mono.framework/Commands/mono"];
|
[task setLaunchPath:@"/Library/Frameworks/Mono.framework/Commands/mono"];
|
||||||
[task setArguments:taskArgs];
|
[task setArguments:taskArgs];
|
||||||
@@ -124,7 +131,8 @@
|
|||||||
NSData *data = [[outPipe fileHandleForReading] readDataToEndOfFile];
|
NSData *data = [[outPipe fileHandleForReading] readDataToEndOfFile];
|
||||||
[task waitUntilExit];
|
[task waitUntilExit];
|
||||||
[task release];
|
[task release];
|
||||||
return [NSString stringWithUTF8String:[data bytes]];
|
|
||||||
|
return [[[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding] autorelease];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,13 +20,13 @@
|
|||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
[controller release]; controller = nil;
|
[controller release]; controller = nil;
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
- (void)launchCurrentMod
|
- (void)launchCurrentMod
|
||||||
{
|
{
|
||||||
NSLog(@"launchcurrent");
|
NSLog(@"launchcurrent");
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
BOOL isHeader;
|
BOOL isHeader;
|
||||||
NSString *title;
|
NSString *title;
|
||||||
NSImage *icon;
|
NSImage *icon;
|
||||||
id object;
|
NSURL *url;
|
||||||
NSMutableArray *children;
|
NSMutableArray *children;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,9 +24,9 @@
|
|||||||
@property (readonly) NSImage* icon;
|
@property (readonly) NSImage* icon;
|
||||||
|
|
||||||
+ (id)headerWithTitle:(NSString *)aTitle;
|
+ (id)headerWithTitle:(NSString *)aTitle;
|
||||||
+ (id)entryWithTitle:(NSString *)aTitle object:(id)anObject icon:(id)anIcon;
|
+ (id)entryWithTitle:(NSString *)aTitle url:(NSURL *)aURL icon:(id)anIcon;
|
||||||
+ (id)entryWithMod:(Mod *)baseMod allMods:(NSArray *)allMods;
|
+ (id)entryWithMod:(Mod *)baseMod allMods:(NSArray *)allMods baseURL:(NSURL *)aURL;
|
||||||
- (id)initWithTitle:(NSString *)aTitle object:(id)anObject icon:(id)anIcon isHeader:(BOOL)aHeader;
|
- (id)initWithTitle:(NSString *)aTitle url:(NSURL *)aURL icon:(id)anIcon isHeader:(BOOL)aHeader;
|
||||||
- (void)addChild:(id)child;
|
- (void)addChild:(id)child;
|
||||||
- (NSURL *)url;
|
- (NSURL *)url;
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -17,45 +17,48 @@
|
|||||||
|
|
||||||
+ (id)headerWithTitle:(NSString *)aTitle;
|
+ (id)headerWithTitle:(NSString *)aTitle;
|
||||||
{
|
{
|
||||||
id newObject = [[self alloc] initWithTitle:aTitle object:nil icon:nil isHeader:YES];
|
id newObject = [[self alloc] initWithTitle:aTitle url:nil icon:nil isHeader:YES];
|
||||||
[newObject autorelease];
|
[newObject autorelease];
|
||||||
return newObject;
|
return newObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (id)entryWithTitle:(NSString *)aTitle object:(id)anObject icon:(id)anIcon
|
+ (id)entryWithTitle:(NSString *)aTitle url:(NSURL *)aURL icon:(id)anIcon
|
||||||
{
|
{
|
||||||
id newObject = [[self alloc] initWithTitle:aTitle object:anObject icon:anIcon isHeader:NO];
|
id newObject = [[self alloc] initWithTitle:aTitle url:aURL icon:anIcon isHeader:NO];
|
||||||
[newObject autorelease];
|
[newObject autorelease];
|
||||||
return newObject;
|
return newObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (id)entryWithMod:(Mod *)baseMod allMods:(NSArray *)allMods
|
+ (id)entryWithMod:(Mod *)baseMod allMods:(NSArray *)allMods baseURL:(NSURL *)baseURL
|
||||||
{
|
{
|
||||||
// TODO: Get the mod icon from the Mod
|
// TODO: Get the mod icon from the Mod
|
||||||
// Temporary hack until mods define an icon
|
// Temporary hack until mods define an icon
|
||||||
NSString* imageName = [[NSBundle mainBundle] pathForResource:@"OpenRA" ofType:@"icns"];
|
NSString* imageName = [[NSBundle mainBundle] pathForResource:@"OpenRA" ofType:@"icns"];
|
||||||
id icon = [[[NSImage alloc] initWithContentsOfFile:imageName] autorelease];
|
id icon = [[[NSImage alloc] initWithContentsOfFile:imageName] autorelease];
|
||||||
id ret = [SidebarEntry entryWithTitle:[baseMod title] object:baseMod icon:icon];
|
id url = [[baseURL URLByAppendingPathComponent:[baseMod mod]]
|
||||||
|
URLByAppendingPathComponent:@"mod.html"];
|
||||||
|
|
||||||
|
id ret = [SidebarEntry entryWithTitle:[baseMod title] url:url icon:icon];
|
||||||
|
|
||||||
for (id aMod in allMods)
|
for (id aMod in allMods)
|
||||||
{
|
{
|
||||||
if (![[aMod requires] isEqualToString:[baseMod mod]])
|
if (![[aMod requires] isEqualToString:[baseMod mod]])
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
id child = [SidebarEntry entryWithMod:aMod allMods:allMods];
|
id child = [SidebarEntry entryWithMod:aMod allMods:allMods baseURL:baseURL];
|
||||||
[ret addChild:child];
|
[ret addChild:child];
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)initWithTitle:(NSString *)aTitle object:(id)anObject icon:(id)anIcon isHeader:(BOOL)isaHeader
|
- (id)initWithTitle:(NSString *)aTitle url:(NSURL *)aURL icon:(id)anIcon isHeader:(BOOL)isaHeader
|
||||||
{
|
{
|
||||||
self = [super init];
|
self = [super init];
|
||||||
if (self)
|
if (self)
|
||||||
{
|
{
|
||||||
isHeader = isaHeader;
|
isHeader = isaHeader;
|
||||||
title = [aTitle retain];
|
title = [aTitle retain];
|
||||||
object = [anObject retain];
|
url = [aURL retain];
|
||||||
icon = [anIcon retain];
|
icon = [anIcon retain];
|
||||||
children = [[NSMutableArray alloc] init];
|
children = [[NSMutableArray alloc] init];
|
||||||
}
|
}
|
||||||
@@ -64,30 +67,18 @@
|
|||||||
|
|
||||||
- (void)addChild:(Mod *)child
|
- (void)addChild:(Mod *)child
|
||||||
{
|
{
|
||||||
NSLog(@"Adding sidebar child %@ to %@",[child title], title);
|
|
||||||
[children addObject:child];
|
[children addObject:child];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL)shouldSelect
|
|
||||||
{
|
|
||||||
return [object shouldSelect];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSURL *)url
|
- (NSURL *)url
|
||||||
{
|
{
|
||||||
if (object == nil)
|
return url;
|
||||||
{
|
|
||||||
NSLog(@"object is nil");
|
|
||||||
return nil;
|
|
||||||
}
|
|
||||||
|
|
||||||
return [object pageURL];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) dealloc
|
- (void) dealloc
|
||||||
{
|
{
|
||||||
[title release]; title = nil;
|
[title release]; title = nil;
|
||||||
[object release]; object = nil;
|
[url release]; url = nil;
|
||||||
[icon release]; icon = nil;
|
[icon release]; icon = nil;
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,6 +64,16 @@
|
|||||||
background-color: #272d2c;
|
background-color: #272d2c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.button:active
|
||||||
|
{
|
||||||
|
background-color:#fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.button:hover
|
||||||
|
{
|
||||||
|
background-color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
|||||||
6
mods/d2k/mod.html
Normal file
6
mods/d2k/mod.html
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<h1>Dune 2000</h1>
|
||||||
|
<input type="button" class="button" onclick="window.external.launchCurrentMod();" value="Play" />
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
6
mods/default/mod.html
Normal file
6
mods/default/mod.html
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<h1>Default Mod</h1>
|
||||||
|
<input type="button" class="button" onclick="window.external.launchCurrentMod();" value="Play" />
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
7
mods/example/mod.html
Normal file
7
mods/example/mod.html
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<h1>Example Mod</h1>
|
||||||
|
<h2>Demonstrates how to add a new unit by adding a soviet supply truck.</h2>
|
||||||
|
<input type="button" class="button" onclick="window.external.launchCurrentMod();" value="Play" />
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
6
mods/ra/mod.html
Normal file
6
mods/ra/mod.html
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<h1>Red Alert</h1>
|
||||||
|
<input type="button" class="button" onclick="window.external.launchCurrentMod();" value="Play" />
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
7
mods/ra_perf/mod.html
Normal file
7
mods/ra_perf/mod.html
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<h1>RA Performance Tests</h1>
|
||||||
|
<h2>Adds special performance test maps to ra.</h2>
|
||||||
|
<input type="button" class="button" onclick="window.external.launchCurrentMod();" value="Play" />
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user