blob: 27ff6f0160e896cfa88108f6b34e57583ed40f65 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#import "PluginController.h"
#import "PcsxrPlugin.h"
#import "PcsxrController.h"
#import "ARCBridge.h"
@interface PluginController ()
@property (arcstrong) NSArray *plugins;
@property (arcstrong) NSString *defaultKey;
@end
@implementation PluginController
@synthesize defaultKey;
@synthesize plugins;
- (IBAction)doAbout:(id)sender
{
PcsxrPlugin *plugin = [plugins objectAtIndex:[pluginMenu indexOfSelectedItem]];
[plugin aboutAs:pluginType];
}
- (IBAction)doConfigure:(id)sender
{
PcsxrPlugin *plugin = [plugins objectAtIndex:[pluginMenu indexOfSelectedItem]];
[plugin configureAs:pluginType];
}
- (IBAction)selectPlugin:(id)sender
{
if (sender == pluginMenu) {
NSInteger index = [pluginMenu indexOfSelectedItem];
if (index != -1) {
PcsxrPlugin *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;
// remember the list
pluginType = type;
self.plugins = list;
self.defaultKey = [PcsxrPlugin defaultKeyForType:pluginType];
// clear the previous menu items
[pluginMenu removeAllItems];
// load the currently selected plugin
sel = [[NSUserDefaults standardUserDefaults] stringForKey:defaultKey];
// add the menu entries
for (PcsxrPlugin *plug in plugins) {
NSString *description = [plug description];
[pluginMenu addItemWithTitle:description];
// make sure the currently selected is set as such
if ([sel isEqualToString:[plug path]]) {
[pluginMenu selectItemWithTitle:description];
}
}
[self selectPlugin:pluginMenu];
}
#if !__has_feature(objc_arc)
- (void)dealloc
{
self.plugins = nil;
self.defaultKey = nil;
[super dealloc];
}
#endif
@end
|