diff options
| author | SND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2009-06-09 11:34:52 +0000 |
|---|---|---|
| committer | SND\weimingzhi_cp <SND\weimingzhi_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2009-06-09 11:34:52 +0000 |
| commit | 10eac4b4928e7dd9f79de454641889f2a0b77250 (patch) | |
| tree | 0f9c98f659552ed2406a6159bc123889ca46b919 /macosx/PluginController.m | |
| parent | 568526e291e9743751d8632327b94e01e7181efc (diff) | |
| download | pcsxr-10eac4b4928e7dd9f79de454641889f2a0b77250.tar.gz | |
added prelimiary Mac OS X port (still not working)
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@23667 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'macosx/PluginController.m')
| -rw-r--r-- | macosx/PluginController.m | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/macosx/PluginController.m b/macosx/PluginController.m new file mode 100644 index 00000000..958cad3a --- /dev/null +++ b/macosx/PluginController.m @@ -0,0 +1,80 @@ +#import "PluginController.h" +#import "PcsxPlugin.h" + +@implementation PluginController + +- (IBAction)doAbout:(id)sender +{ + PcsxPlugin *plugin = [plugins objectAtIndex:[pluginMenu indexOfSelectedItem]]; + [plugin aboutAs:pluginType]; +} + +- (IBAction)doConfigure:(id)sender +{ + PcsxPlugin *plugin = [plugins objectAtIndex:[pluginMenu indexOfSelectedItem]]; + + [plugin configureAs:pluginType]; +} + +- (IBAction)selectPlugin:(id)sender +{ + if (sender==pluginMenu) { + int index = [pluginMenu indexOfSelectedItem]; + if (index != -1) { + PcsxPlugin *plugin = [plugins objectAtIndex:index]; + + if (![[PluginList list] setActivePlugin:plugin forType:pluginType]) { + /* plugin won't initialize */ + } + + // write selection to defaults + [[NSUserDefaults standardUserDefaults] setObject:[plugin path] forKey:defaultKey]; + + // set button states + [aboutButton setEnabled:[plugin hasAboutAs:pluginType]]; + [configureButton setEnabled:[plugin hasConfigureAs:pluginType]]; + } else { + // set button states + [aboutButton setEnabled:NO]; + [configureButton setEnabled:NO]; + } + } +} + +// must be called before anything else +- (void)setPluginsTo:(NSArray *)list withType:(int)type +{ + NSString *sel; + int i; + + // remember the list + pluginType = type; + plugins = [list retain]; + defaultKey = [[PcsxPlugin getDefaultKeyForType:pluginType] retain]; + + // clear the previous menu items + [pluginMenu removeAllItems]; + + // load the currently selected plugin + sel = [[NSUserDefaults standardUserDefaults] stringForKey:defaultKey]; + + // add the menu entries + for (i=0; i<[plugins count]; i++) { + [pluginMenu addItemWithTitle:[[plugins objectAtIndex:i] description]]; + + // make sure the currently selected is set as such + if ([sel isEqualToString:[[plugins objectAtIndex:i] path]]) { + [pluginMenu selectItemAtIndex:i]; + } + } + + [self selectPlugin:pluginMenu]; +} + +- (void)dealloc +{ + if (plugins) [plugins release]; + if (defaultKey) [defaultKey release]; +} + +@end |
