diff --git a/OpenRA.Launcher.Mac/Controller.h b/OpenRA.Launcher.Mac/Controller.h index f3ac59463c..fea1a83370 100644 --- a/OpenRA.Launcher.Mac/Controller.h +++ b/OpenRA.Launcher.Mac/Controller.h @@ -7,14 +7,17 @@ */ #import - -@class ModEntry; +#import +@class Mod; +@class SidebarEntry; @class GameInstall; @interface Controller : NSObject { - ModEntry *sidebarItems; + SidebarEntry *sidebarItems; GameInstall *game; IBOutlet NSOutlineView *outlineView; + IBOutlet WebView *webView; } - (IBAction)launchGame:(id)sender; +- (SidebarEntry *)sidebarModsTree; @end diff --git a/OpenRA.Launcher.Mac/Controller.m b/OpenRA.Launcher.Mac/Controller.m index 9ae22ee67f..a2e2e28594 100644 --- a/OpenRA.Launcher.Mac/Controller.m +++ b/OpenRA.Launcher.Mac/Controller.m @@ -7,7 +7,8 @@ */ #import "Controller.h" -#import "ModEntry.h" +#import "Mod.h" +#import "SidebarEntry.h" #import "GameInstall.h" #import "ImageAndTextCell.h" @@ -16,9 +17,9 @@ - (void) awakeFromNib { game = [[GameInstall alloc] initWithPath:@"/Users/paul/src/OpenRA"]; - sidebarItems = [[ModEntry headerWithTitle:@""] retain]; - [sidebarItems addChild:[game modTree]]; - + sidebarItems = [[SidebarEntry headerWithTitle:@""] retain]; + [sidebarItems addChild:[self sidebarModsTree]]; + [sidebarItems addChild:[self sidebarOtherTree]]; NSTableColumn *col = [outlineView tableColumnWithIdentifier:@"mods"]; ImageAndTextCell *imageAndTextCell = [[[ImageAndTextCell alloc] init] autorelease]; [col setDataCell:imageAndTextCell]; @@ -28,6 +29,35 @@ [outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:1] byExtendingSelection:NO]; } +- (SidebarEntry *)sidebarModsTree +{ + // Get info for all installed mods + id modnames = [game installedMods]; + NSArray *allMods = [game infoForMods:modnames]; + + SidebarEntry *rootItem = [SidebarEntry headerWithTitle:@"MODS"]; + for (id aMod in allMods) + { + if ([aMod standalone]) + { + id child = [SidebarEntry entryWithMod:aMod allMods:allMods]; + [rootItem addChild:child]; + } + } + + return rootItem; +} + +- (SidebarEntry *)sidebarOtherTree +{ + SidebarEntry *rootItem = [SidebarEntry headerWithTitle:@"OTHER"]; + [rootItem addChild:[SidebarEntry entryWithTitle:@"Support" object:nil icon:nil]]; + [rootItem addChild:[SidebarEntry entryWithTitle:@"Credits" object:nil icon:nil]]; + + return rootItem; +} + + - (void) dealloc { [sidebarItems release]; sidebarItems = nil; diff --git a/OpenRA.Launcher.Mac/English.lproj/MainMenu.xib b/OpenRA.Launcher.Mac/English.lproj/MainMenu.xib index 89a3fbc3e5..40355c080b 100644 --- a/OpenRA.Launcher.Mac/English.lproj/MainMenu.xib +++ b/OpenRA.Launcher.Mac/English.lproj/MainMenu.xib @@ -7,8 +7,17 @@ 1038.35 461.00 - com.apple.InterfaceBuilder.CocoaPlugin - 804 + YES + + YES + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.WebKitIBPlugin + + + YES + 804 + 804 + YES @@ -17,6 +26,7 @@ YES + com.apple.WebKitIBPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -448,7 +458,7 @@ 289 - {{339, 19}, {111, 27}} + {{270, 53}, {111, 27}} YES @@ -465,6 +475,56 @@ 75 + + + 274 + + YES + + YES + Apple HTML pasteboard type + Apple PDF pasteboard type + Apple PICT pasteboard type + Apple URL pasteboard type + Apple Web Archive pasteboard type + NSColor pasteboard type + NSFilenamesPboardType + NSStringPboardType + NeXT RTFD pasteboard type + NeXT Rich Text Format v1.0 pasteboard type + NeXT TIFF v4.0 pasteboard type + WebURLsWithTitlesPboardType + public.png + public.url + public.url-name + + + {469, 469} + + + + + + + + YES + + YES + WebKitDefaultFixedFontSize + WebKitDefaultFontSize + WebKitMinimumFontSize + + + YES + + + + + + + YES + YES + {{190, 0}, {469, 469}} @@ -852,6 +912,7 @@ YES + @@ -927,6 +988,11 @@ + + 589 + + + @@ -1008,6 +1074,8 @@ 586.IBPluginDependency 586.IBViewBoundsToFrameTransform 587.IBPluginDependency + 589.IBPluginDependency + 589.IBViewBoundsToFrameTransform 92.IBPluginDependency 92.ImportedFromIB2 @@ -1053,9 +1121,9 @@ {74, 862} {{6, 978}, {478, 20}} - {{174, 257}, {659, 469}} + {{611, 949}, {659, 469}} com.apple.InterfaceBuilder.CocoaPlugin - {{174, 257}, {659, 469}} + {{611, 949}, {659, 469}} {{33, 99}, {480, 360}} {3.40282e+38, 3.40282e+38} @@ -1089,9 +1157,13 @@ com.apple.InterfaceBuilder.CocoaPlugin - P4AAAL+AAABDv4AAwiAAAA + P4AAAL+AAABDegAAwvoAAA com.apple.InterfaceBuilder.CocoaPlugin + com.apple.WebKitIBPlugin + + AcJAAABDFwAAA + com.apple.InterfaceBuilder.CocoaPlugin @@ -1112,7 +1184,7 @@ - 588 + 589 @@ -1132,14 +1204,35 @@ - outlineView - NSOutlineView + YES + + YES + outlineView + webView + + + YES + NSOutlineView + WebView + - outlineView - - outlineView - NSOutlineView + YES + + YES + outlineView + webView + + + YES + + outlineView + NSOutlineView + + + webView + WebView + diff --git a/OpenRA.Launcher.Mac/GameInstall.h b/OpenRA.Launcher.Mac/GameInstall.h index efc22a5558..50bcd033f1 100644 --- a/OpenRA.Launcher.Mac/GameInstall.h +++ b/OpenRA.Launcher.Mac/GameInstall.h @@ -8,14 +8,15 @@ #import -@class ModEntry; +@class Mod; @interface GameInstall : NSObject { NSString *gamePath; NSMutableString *utilityBuffer; } -(id)initWithPath:(NSString *)path; -- (ModEntry *)modTree; -(void)launchGame; - (void)runUtilityApp:(NSString *)arg handleOutput:(id)obj withMethod:(SEL)sel; +- (NSArray *)installedMods; +- (NSArray *)infoForMods:(NSArray *)mods; @end diff --git a/OpenRA.Launcher.Mac/GameInstall.m b/OpenRA.Launcher.Mac/GameInstall.m index a3ee9e5401..9006a0cff4 100644 --- a/OpenRA.Launcher.Mac/GameInstall.m +++ b/OpenRA.Launcher.Mac/GameInstall.m @@ -7,7 +7,7 @@ */ #import "GameInstall.h" -#import "ModEntry.h" +#import "Mod.h" @implementation GameInstall @@ -76,7 +76,7 @@ { // Commit prev mod if (current != nil) - [ret addObject:[ModEntry modWithId:current fields:fields]]; + [ret addObject:[Mod modWithId:current fields:fields]]; NSLog(@"Parsing mod %@",value); current = value; fields = [NSMutableDictionary dictionary]; @@ -89,25 +89,6 @@ return ret; } -- (ModEntry *)modTree -{ - // Get info for all installed mods - id modnames = [self installedMods]; - NSArray *allMods = [self infoForMods:modnames]; - - ModEntry *rootItem = [ModEntry headerWithTitle:@"MODS"]; - for (id aMod in allMods) - { - if ([aMod standalone]) - { - [rootItem addChild:aMod]; - [aMod buildChildTree:allMods]; - } - } - - return rootItem; -} - -(void)launchGame { // Use LaunchServices because neither NSTask or NSWorkspace support Info.plist _and_ arguments pre-10.6 diff --git a/OpenRA.Launcher.Mac/ModEntry.h b/OpenRA.Launcher.Mac/Mod.h similarity index 62% rename from OpenRA.Launcher.Mac/ModEntry.h rename to OpenRA.Launcher.Mac/Mod.h index e78d35dc1f..a1add343ac 100644 --- a/OpenRA.Launcher.Mac/ModEntry.h +++ b/OpenRA.Launcher.Mac/Mod.h @@ -8,19 +8,15 @@ #import -@interface ModEntry : NSObject { - BOOL isHeader; +@interface Mod : NSObject { NSString *mod; NSString *title; NSString *version; NSString *author; NSString *requires; BOOL standalone; - NSMutableArray *children; - NSImage *icon; } -@property (readonly) BOOL isHeader; @property (readonly) NSString *mod; @property (readonly) NSString *title; @property (readonly) NSString *version; @@ -28,14 +24,7 @@ @property (readonly) NSString *description; @property (readonly) NSString *requires; @property (readonly) BOOL standalone; -@property (readonly) NSMutableArray* children; -@property (readonly) NSImage* icon; -+ (id)headerWithTitle:(NSString *)aTitle; -+ (id)errorWithTitle:(NSString *)aTitle; + (id)modWithId:(NSString *)mid fields:(id)fields; -- (id)initWithId:(NSString *)mod fields:(NSDictionary *)fields isHeader:(BOOL)header; -- (void)addChild:(id)child; -- (void)buildChildTree:(NSArray *)allMods; -- (id)icon; +- (id)initWithId:(NSString *)mod fields:(NSDictionary *)fields; @end diff --git a/OpenRA.Launcher.Mac/Mod.m b/OpenRA.Launcher.Mac/Mod.m new file mode 100644 index 0000000000..2536f34381 --- /dev/null +++ b/OpenRA.Launcher.Mac/Mod.m @@ -0,0 +1,55 @@ +/* + * 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. + */ + +#import "Mod.h" + + +@implementation Mod +@synthesize mod; +@synthesize title; +@synthesize version; +@synthesize author; +@synthesize description; +@synthesize requires; +@synthesize standalone; + ++ (id)modWithId:(NSString *)mod fields:(id)fields +{ + id newObject = [[self alloc] initWithId:mod fields:fields]; + [newObject autorelease]; + return newObject; +} + +- (id)initWithId:(NSString *)anId fields:(NSDictionary *)fields +{ + self = [super init]; + if (self) + { + mod = anId; + title = [[fields objectForKey:@"Title"] retain]; + version = [[fields objectForKey:@"Version"] retain]; + author = [[fields objectForKey:@"Author"] retain]; + description = [[fields objectForKey:@"Description"] retain]; + requires = [[fields objectForKey:@"Requires"] retain]; + standalone = ([[fields objectForKey:@"Standalone"] isEqualToString:@"True"]); + } + return self; +} + + +- (void) dealloc +{ + [title release]; title = nil; + [version release]; version = nil; + [author release]; author = nil; + [description release]; description = nil; + [requires release]; requires = nil; + [super dealloc]; +} + +@end diff --git a/OpenRA.Launcher.Mac/ModEntry.m b/OpenRA.Launcher.Mac/ModEntry.m deleted file mode 100644 index 57e30e040c..0000000000 --- a/OpenRA.Launcher.Mac/ModEntry.m +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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. - */ - -#import "ModEntry.h" - - -@implementation ModEntry -@synthesize mod; -@synthesize isHeader; -@synthesize title; -@synthesize version; -@synthesize author; -@synthesize description; -@synthesize requires; -@synthesize standalone; -@synthesize children; -@synthesize icon; - -+ (id)headerWithTitle:(NSString *)aTitle -{ - id newObject = [[self alloc] initWithId:@"title" fields:[NSDictionary dictionaryWithObject:aTitle forKey:@"Title"] isHeader:YES]; - [newObject autorelease]; - return newObject; -} - -+ (id)errorWithTitle:(NSString *)aTitle -{ - id newObject = [[self alloc] initWithId:@"error" fields:[NSDictionary dictionaryWithObject:aTitle forKey:@"Title"] isHeader:NO]; - [newObject autorelease]; - return newObject; -} - -+ (id)modWithId:(NSString *)mod fields:(id)fields -{ - id newObject = [[self alloc] initWithId:mod fields:fields isHeader:NO]; - [newObject autorelease]; - return newObject; -} - -- (id)initWithId:(NSString *)anId fields:(NSDictionary *)fields isHeader:(BOOL)header -{ - self = [super init]; - if (self) - { - mod = anId; - isHeader = header; - title = [[fields objectForKey:@"Title"] retain]; - version = [[fields objectForKey:@"Version"] retain]; - author = [[fields objectForKey:@"Author"] retain]; - description = [[fields objectForKey:@"Description"] retain]; - requires = [[fields objectForKey:@"Requires"] retain]; - standalone = ([[fields objectForKey:@"Standalone"] isEqualToString:@"True"]); - - if (!isHeader) - { - NSString* imageName = [[NSBundle mainBundle] pathForResource:@"OpenRA" ofType:@"icns"]; - icon = [[NSImage alloc] initWithContentsOfFile:imageName]; - } - children = [[NSMutableArray alloc] init]; - } - return self; -} - -- (void)addChild:(ModEntry *)child -{ - NSLog(@"Adding child %@ to %@",[child mod], mod); - [children addObject:child]; -} - -- (void)buildChildTree:(NSArray *)allMods -{ - for (id aMod in allMods) - { - if (![[aMod requires] isEqualToString:mod]) - continue; - - [self addChild:aMod]; - [aMod buildChildTree:allMods]; - } -} - -- (void) dealloc -{ - [title release]; title = nil; - [version release]; version = nil; - [author release]; author = nil; - [description release]; description = nil; - [requires release]; requires = nil; - [icon release]; icon = nil; - [super dealloc]; -} - -@end diff --git a/OpenRA.Launcher.Mac/OpenRA.xcodeproj/project.pbxproj b/OpenRA.Launcher.Mac/OpenRA.xcodeproj/project.pbxproj index b84f0cecd1..00fb047628 100644 --- a/OpenRA.Launcher.Mac/OpenRA.xcodeproj/project.pbxproj +++ b/OpenRA.Launcher.Mac/OpenRA.xcodeproj/project.pbxproj @@ -13,17 +13,18 @@ 8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; }; 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; }; DA81FA821290F5C800C48F2F /* Controller.m in Sources */ = {isa = PBXBuildFile; fileRef = DA81FA811290F5C800C48F2F /* Controller.m */; }; - DA81FAAA1290FA0000C48F2F /* ModEntry.m in Sources */ = {isa = PBXBuildFile; fileRef = DA81FAA91290FA0000C48F2F /* ModEntry.m */; }; + DA81FAAA1290FA0000C48F2F /* Mod.m in Sources */ = {isa = PBXBuildFile; fileRef = DA81FAA91290FA0000C48F2F /* Mod.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 */; }; + DA9295A712921DF900EDB02E /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DA9295A612921DF900EDB02E /* WebKit.framework */; }; + DA9296901292328200EDB02E /* SidebarEntry.m in Sources */ = {isa = PBXBuildFile; fileRef = DA92968F1292328200EDB02E /* SidebarEntry.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ 089C165DFE840E0CC02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = ""; }; 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = /System/Library/Frameworks/Cocoa.framework; sourceTree = ""; }; - 13E42FB307B3F0F600E4EEF1 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = ""; }; 1DDD58150DA1D0A300B32029 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = English.lproj/MainMenu.xib; sourceTree = ""; }; 256AC3D80F4B6AC300CF3369 /* OpenRAAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OpenRAAppDelegate.h; sourceTree = ""; }; 256AC3D90F4B6AC300CF3369 /* OpenRAAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = OpenRAAppDelegate.m; sourceTree = ""; }; @@ -35,14 +36,17 @@ 8D1107320486CEB800E47090 /* OpenRA.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = OpenRA.app; sourceTree = BUILT_PRODUCTS_DIR; }; DA81FA801290F5C800C48F2F /* Controller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Controller.h; sourceTree = ""; }; DA81FA811290F5C800C48F2F /* Controller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Controller.m; sourceTree = ""; }; - DA81FAA81290FA0000C48F2F /* ModEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModEntry.h; sourceTree = ""; }; - DA81FAA91290FA0000C48F2F /* ModEntry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ModEntry.m; sourceTree = ""; }; + DA81FAA81290FA0000C48F2F /* Mod.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Mod.h; sourceTree = ""; }; + DA81FAA91290FA0000C48F2F /* Mod.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Mod.m; sourceTree = ""; }; DA81FB9112910A8B00C48F2F /* ImageAndTextCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageAndTextCell.h; sourceTree = ""; }; DA81FB9212910A8B00C48F2F /* ImageAndTextCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageAndTextCell.m; sourceTree = ""; }; DA81FBDB12910E4900C48F2F /* OpenRA.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = OpenRA.icns; sourceTree = ""; }; DA81FC3D12911E2B00C48F2F /* GameInstall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GameInstall.h; sourceTree = ""; }; DA81FC3E12911E2B00C48F2F /* GameInstall.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GameInstall.m; sourceTree = ""; }; DA9292C71291DF2D00EDB02E /* OpenRA.app */ = {isa = PBXFileReference; lastKnownFileType = wrapper.application; path = OpenRA.app; sourceTree = ""; }; + DA9295A612921DF900EDB02E /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; }; + DA92968E1292328200EDB02E /* SidebarEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SidebarEntry.h; sourceTree = ""; }; + DA92968F1292328200EDB02E /* SidebarEntry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SidebarEntry.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -51,6 +55,7 @@ buildActionMask = 2147483647; files = ( 8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */, + DA9295A712921DF900EDB02E /* WebKit.framework in Frameworks */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -66,10 +71,12 @@ 256AC3D90F4B6AC300CF3369 /* OpenRAAppDelegate.m */, DA81FA801290F5C800C48F2F /* Controller.h */, DA81FA811290F5C800C48F2F /* Controller.m */, - DA81FAA81290FA0000C48F2F /* ModEntry.h */, - DA81FAA91290FA0000C48F2F /* ModEntry.m */, + DA81FAA81290FA0000C48F2F /* Mod.h */, + DA81FAA91290FA0000C48F2F /* Mod.m */, DA81FC3D12911E2B00C48F2F /* GameInstall.h */, DA81FC3E12911E2B00C48F2F /* GameInstall.m */, + DA92968E1292328200EDB02E /* SidebarEntry.h */, + DA92968F1292328200EDB02E /* SidebarEntry.m */, ); name = Classes; sourceTree = ""; @@ -86,8 +93,8 @@ isa = PBXGroup; children = ( 29B97324FDCFA39411CA2CEA /* AppKit.framework */, - 13E42FB307B3F0F600E4EEF1 /* CoreData.framework */, 29B97325FDCFA39411CA2CEA /* Foundation.framework */, + DA9295A612921DF900EDB02E /* WebKit.framework */, ); name = "Other Frameworks"; sourceTree = ""; @@ -209,9 +216,10 @@ 8D11072D0486CEB800E47090 /* main.m in Sources */, 256AC3DA0F4B6AC300CF3369 /* OpenRAAppDelegate.m in Sources */, DA81FA821290F5C800C48F2F /* Controller.m in Sources */, - DA81FAAA1290FA0000C48F2F /* ModEntry.m in Sources */, + DA81FAAA1290FA0000C48F2F /* Mod.m in Sources */, DA81FB9312910A8B00C48F2F /* ImageAndTextCell.m in Sources */, DA81FC3F12911E2B00C48F2F /* GameInstall.m in Sources */, + DA9296901292328200EDB02E /* SidebarEntry.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/OpenRA.Launcher.Mac/SidebarEntry.h b/OpenRA.Launcher.Mac/SidebarEntry.h new file mode 100644 index 0000000000..d4c08a7016 --- /dev/null +++ b/OpenRA.Launcher.Mac/SidebarEntry.h @@ -0,0 +1,32 @@ +/* + * 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. + */ + +#import + +@class Mod; +@interface SidebarEntry : NSObject +{ + BOOL isHeader; + NSString *title; + NSImage *icon; + id object; + NSMutableArray *children; +} + +@property (readonly) BOOL isHeader; +@property (readonly) NSString *title; +@property (readonly) NSMutableArray* children; +@property (readonly) NSImage* icon; + ++ (id)headerWithTitle:(NSString *)aTitle; ++ (id)entryWithTitle:(NSString *)aTitle object:(id)anObject icon:(id)anIcon; ++ (id)entryWithMod:(Mod *)baseMod allMods:(NSArray *)allMods; +- (id)initWithTitle:(NSString *)aTitle object:(id)anObject icon:(id)anIcon isHeader:(BOOL)aHeader; +- (void)addChild:(id)child; + +@end diff --git a/OpenRA.Launcher.Mac/SidebarEntry.m b/OpenRA.Launcher.Mac/SidebarEntry.m new file mode 100644 index 0000000000..b1324a984d --- /dev/null +++ b/OpenRA.Launcher.Mac/SidebarEntry.m @@ -0,0 +1,78 @@ +/* + * 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. + */ + +#import "SidebarEntry.h" +#import "Mod.h" + +@implementation SidebarEntry +@synthesize isHeader; +@synthesize title; +@synthesize children; +@synthesize icon; + ++ (id)headerWithTitle:(NSString *)aTitle; +{ + id newObject = [[self alloc] initWithTitle:aTitle object:nil icon:nil isHeader:YES]; + [newObject autorelease]; + return newObject; +} + ++ (id)entryWithTitle:(NSString *)aTitle object:(id)anObject icon:(id)anIcon +{ + id newObject = [[self alloc] initWithTitle:aTitle object:anObject icon:anIcon isHeader:NO]; + [newObject autorelease]; + return newObject; +} + ++ (id)entryWithMod:(Mod *)baseMod allMods:(NSArray *)allMods +{ + // TODO: Get the mod icon from the Mod + // Temporary hack until mods define an icon + NSString* imageName = [[NSBundle mainBundle] pathForResource:@"OpenRA" ofType:@"icns"]; + id icon = [[[NSImage alloc] initWithContentsOfFile:imageName] autorelease]; + id ret = [SidebarEntry entryWithTitle:[baseMod title] object:baseMod icon:icon]; + + for (id aMod in allMods) + { + if (![[aMod requires] isEqualToString:[baseMod mod]]) + continue; + + id child = [SidebarEntry entryWithMod:aMod allMods:allMods]; + [ret addChild:child]; + } + return ret; +} + +- (id)initWithTitle:(NSString *)aTitle object:(id)anObject icon:(id)anIcon isHeader:(BOOL)isaHeader +{ + self = [super init]; + if (self) + { + isHeader = isaHeader; + title = [aTitle retain]; + object = [anObject retain]; + icon = [anIcon retain]; + children = [[NSMutableArray alloc] init]; + } + return self; +} + +- (void)addChild:(Mod *)child +{ + NSLog(@"Adding sidebar child %@ to %@",[child title], title); + [children addObject:child]; +} + +- (void) dealloc +{ + [title release]; title = nil; + [object release]; object = nil; + [icon release]; icon = nil; + [super dealloc]; +} +@end