1 #import "PluginController.h"
3 #import "PcsxController.h"
5 @implementation PluginController
7 - (IBAction)doAbout:(id)sender
9 PcsxPlugin *plugin = [plugins objectAtIndex:[pluginMenu indexOfSelectedItem]];
10 [plugin aboutAs:pluginType];
13 - (IBAction)doConfigure:(id)sender
15 PcsxPlugin *plugin = [plugins objectAtIndex:[pluginMenu indexOfSelectedItem]];
17 [plugin configureAs:pluginType];
20 - (IBAction)selectPlugin:(id)sender
22 if (sender==pluginMenu) {
23 int index = [pluginMenu indexOfSelectedItem];
25 PcsxPlugin *plugin = [plugins objectAtIndex:index];
27 if (![[PluginList list] setActivePlugin:plugin forType:pluginType]) {
28 /* plugin won't initialize */
31 // write selection to defaults
32 [[NSUserDefaults standardUserDefaults] setObject:[plugin path] forKey:defaultKey];
35 [aboutButton setEnabled:[plugin hasAboutAs:pluginType]];
36 [configureButton setEnabled:[plugin hasConfigureAs:pluginType]];
39 [aboutButton setEnabled:NO];
40 [configureButton setEnabled:NO];
45 // must be called before anything else
46 - (void)setPluginsTo:(NSArray *)list withType:(int)type
53 plugins = [list retain];
54 defaultKey = [[PcsxPlugin getDefaultKeyForType:pluginType] retain];
56 // clear the previous menu items
57 [pluginMenu removeAllItems];
59 // load the currently selected plugin
60 sel = [[NSUserDefaults standardUserDefaults] stringForKey:defaultKey];
62 // add the menu entries
63 for (i = 0; i < [plugins count]; i++) {
64 [pluginMenu addItemWithTitle:[[plugins objectAtIndex:i] description]];
66 // make sure the currently selected is set as such
67 if ([sel isEqualToString:[[plugins objectAtIndex:i] path]]) {
68 [pluginMenu selectItemAtIndex:i];
72 [self selectPlugin:pluginMenu];
77 if (plugins) [plugins release];
78 if (defaultKey) [defaultKey release];