Bind the js bridge properly. Display the selected mod page on load.

This commit is contained in:
Paul Chote
2010-11-17 11:46:37 +13:00
parent 810b73e1f0
commit 40235db52e
2 changed files with 37 additions and 29 deletions

View File

@@ -18,6 +18,8 @@
- (void) awakeFromNib - (void) awakeFromNib
{ {
game = [[GameInstall alloc] initWithURL:[NSURL URLWithString:@"/Users/paul/src/OpenRA"]]; game = [[GameInstall alloc] initWithURL:[NSURL URLWithString:@"/Users/paul/src/OpenRA"]];
jsbridge = [[JSBridge alloc] initWithController:self];
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];
@@ -31,11 +33,22 @@
[outlineView reloadData]; [outlineView reloadData];
[outlineView expandItem:modsRoot expandChildren:YES]; [outlineView expandItem:modsRoot expandChildren:YES];
[outlineView expandItem:otherRoot expandChildren:YES];
[outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:1] byExtendingSelection:NO];
jsbridge = [[JSBridge alloc] initWithController:self]; if ([[modsRoot children] count] > 0)
[[webView windowScriptObject] setValue:jsbridge forKey:@"external"]; {
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) dealloc
{
[sidebarItems release]; sidebarItems = nil;
[super dealloc];
} }
- (SidebarEntry *)sidebarModsTree - (SidebarEntry *)sidebarModsTree
@@ -66,11 +79,9 @@
return rootItem; return rootItem;
} }
- (void)launchGame
- (void) dealloc
{ {
[sidebarItems release]; sidebarItems = nil; [game launchGame];
[super dealloc];
} }
#pragma mark Sidebar Datasource and Delegate #pragma mark Sidebar Datasource and Delegate
@@ -139,8 +150,10 @@ objectValueForTableColumn:(NSTableColumn *)tableColumn
} }
} }
- (void)launchGame #pragma mark WebView delegates
- (void)webView:(WebView *)sender didClearWindowObject:(WebScriptObject *)windowObject forFrame:(WebFrame *)frame
{ {
[game launchGame]; [windowObject setValue:jsbridge forKey:@"external"];
} }
@end @end

View File

@@ -21,8 +21,8 @@
</object> </object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<integer value="557"/>
<integer value="57"/> <integer value="57"/>
<integer value="589"/>
</object> </object>
<object class="NSArray" key="IBDocument.PluginDependencies"> <object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
@@ -656,6 +656,14 @@
</object> </object>
<int key="connectionID">590</int> <int key="connectionID">590</int>
</object> </object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">frameLoadDelegate</string>
<reference key="source" ref="90421773"/>
<reference key="destination" ref="79272443"/>
</object>
<int key="connectionID">591</int>
</object>
</object> </object>
<object class="IBMutableOrderedSet" key="objectRecords"> <object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects"> <object class="NSArray" key="orderedObjects">
@@ -1083,9 +1091,9 @@
<integer value="1"/> <integer value="1"/>
<string>{74, 862}</string> <string>{74, 862}</string>
<string>{{6, 978}, {478, 20}}</string> <string>{{6, 978}, {478, 20}}</string>
<string>{{611, 949}, {659, 469}}</string> <string>{{611, 537}, {659, 469}}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>{{611, 949}, {659, 469}}</string> <string>{{611, 537}, {659, 469}}</string>
<integer value="1"/> <integer value="1"/>
<string>{{33, 99}, {480, 360}}</string> <string>{{33, 99}, {480, 360}}</string>
<string>{3.40282e+38, 3.40282e+38}</string> <string>{3.40282e+38, 3.40282e+38}</string>
@@ -1118,9 +1126,7 @@
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/> <integer value="1"/>
<string>com.apple.WebKitIBPlugin</string> <string>com.apple.WebKitIBPlugin</string>
<object class="NSAffineTransform"> <object class="NSAffineTransform"/>
<bytes key="NSTransformStruct">AcJAAABDFwAAA</bytes>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string> <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<integer value="1"/> <integer value="1"/>
</object> </object>
@@ -1141,7 +1147,7 @@
</object> </object>
</object> </object>
<nil key="sourceID"/> <nil key="sourceID"/>
<int key="maxID">590</int> <int key="maxID">591</int>
</object> </object>
<object class="IBClassDescriber" key="IBDocument.Classes"> <object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions"> <object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -1149,17 +1155,6 @@
<object class="IBPartialClassDescription"> <object class="IBPartialClassDescription">
<string key="className">Controller</string> <string key="className">Controller</string>
<string key="superclassName">NSObject</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"> <object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys"> <object class="NSArray" key="dict.sortedKeys">