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
{
game = [[GameInstall alloc] initWithURL:[NSURL URLWithString:@"/Users/paul/src/OpenRA"]];
jsbridge = [[JSBridge alloc] initWithController:self];
NSTableColumn *col = [outlineView tableColumnWithIdentifier:@"mods"];
ImageAndTextCell *imageAndTextCell = [[[ImageAndTextCell alloc] init] autorelease];
[col setDataCell:imageAndTextCell];
@@ -31,11 +33,22 @@
[outlineView reloadData];
[outlineView expandItem:modsRoot expandChildren:YES];
[outlineView expandItem:otherRoot expandChildren:YES];
[outlineView selectRowIndexes:[NSIndexSet indexSetWithIndex:1] byExtendingSelection:NO];
jsbridge = [[JSBridge alloc] initWithController:self];
[[webView windowScriptObject] setValue:jsbridge forKey:@"external"];
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) dealloc
{
[sidebarItems release]; sidebarItems = nil;
[super dealloc];
}
- (SidebarEntry *)sidebarModsTree
@@ -66,11 +79,9 @@
return rootItem;
}
- (void) dealloc
- (void)launchGame
{
[sidebarItems release]; sidebarItems = nil;
[super dealloc];
[game launchGame];
}
#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

View File

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