1 #import "PluginController.h"
5 #define APP_ID @"net.sf.peops.SPUPlugin"
6 #define PrefsKey APP_ID @" Settings"
8 static PluginController *pluginController;
9 char * pConfigFile=NULL;
13 // Get parent application instance
14 NSApplication *app = [NSApplication sharedApplication];
15 NSBundle *bundle = [NSBundle bundleWithIdentifier:APP_ID];
18 NSString *path = [bundle pathForResource:@"Credits" ofType:@"rtf"];
19 NSAttributedString *credits;
21 credits = [[[NSAttributedString alloc] initWithPath: path
22 documentAttributes:NULL] autorelease];
24 credits = [[[NSAttributedString alloc] initWithString:@""] autorelease];
27 // Get Application Icon
28 NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:[bundle bundlePath]];
29 NSSize size = NSMakeSize(64, 64);
32 [app orderFrontStandardAboutPanelWithOptions:[NSDictionary dictionaryWithObjectsAndKeys:
33 [bundle objectForInfoDictionaryKey:@"CFBundleName"], @"ApplicationName",
34 icon, @"ApplicationIcon",
35 [bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"], @"ApplicationVersion",
36 [bundle objectForInfoDictionaryKey:@"CFBundleVersion"], @"Version",
37 [bundle objectForInfoDictionaryKey:@"NSHumanReadableCopyright"], @"Copyright",
43 long DoConfiguration()
47 if (pluginController == nil) {
48 pluginController = [[PluginController alloc] initWithWindowNibName:@"NetSfPeopsSpuPluginMain"];
50 window = [pluginController window];
53 [pluginController loadValues];
56 [window makeKeyAndOrderFront:nil];
63 NSDictionary *keyValues;
64 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
65 [defaults registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
66 [[NSMutableDictionary alloc] initWithObjectsAndKeys:
67 [NSNumber numberWithBool:YES], @"High Compatibility Mode",
68 [NSNumber numberWithBool:YES], @"SPU IRQ Wait",
69 [NSNumber numberWithBool:NO], @"XA Pitch",
70 [NSNumber numberWithInt:0], @"Interpolation Quality",
71 [NSNumber numberWithInt:1], @"Reverb Quality",
75 keyValues = [defaults dictionaryForKey:PrefsKey];
77 iUseTimer = [[keyValues objectForKey:@"High Compatibility Mode"] boolValue] ? 2 : 0;
78 iSPUIRQWait = [[keyValues objectForKey:@"SPU IRQ Wait"] boolValue];
79 iDisStereo = [[keyValues objectForKey:@"Mono Sound Output"] boolValue];
80 iXAPitch = [[keyValues objectForKey:@"XA Pitch"] boolValue];
82 iUseInterpolation = [[keyValues objectForKey:@"Interpolation Quality"] intValue];
83 iUseReverb = [[keyValues objectForKey:@"Reverb Quality"] intValue];
88 @implementation PluginController
90 - (IBAction)cancel:(id)sender
95 - (IBAction)ok:(id)sender
97 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
99 NSMutableDictionary *writeDic = [NSMutableDictionary dictionaryWithDictionary:keyValues];
100 [writeDic setObject:[NSNumber numberWithInt:[hiCompBox intValue]] forKey:@"High Compatibility Mode"];
101 [writeDic setObject:[NSNumber numberWithInt:[irqWaitBox intValue]] forKey:@"SPU IRQ Wait"];
102 [writeDic setObject:[NSNumber numberWithInt:[monoSoundBox intValue]] forKey:@"Mono Sound Output"];
103 [writeDic setObject:[NSNumber numberWithInt:[xaSpeedBox intValue]] forKey:@"XA Pitch"];
105 [writeDic setObject:[NSNumber numberWithInt:[interpolValue intValue]] forKey:@"Interpolation Quality"];
106 [writeDic setObject:[NSNumber numberWithInt:[reverbValue intValue]] forKey:@"Reverb Quality"];
109 [defaults setObject:writeDic forKey:PrefsKey];
110 [defaults synchronize];
112 // and set global values accordingly
118 - (IBAction)reset:(id)sender
120 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
121 [defaults removeObjectForKey:PrefsKey];
127 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
131 /* load from preferences */
133 keyValues = [[defaults dictionaryForKey:PrefsKey] retain];
135 [hiCompBox setIntValue:[[keyValues objectForKey:@"High Compatibility Mode"] intValue]];
136 [irqWaitBox setIntValue:[[keyValues objectForKey:@"SPU IRQ Wait"] intValue]];
137 [monoSoundBox setIntValue:[[keyValues objectForKey:@"Mono Sound Output"] intValue]];
138 [xaSpeedBox setIntValue:[[keyValues objectForKey:@"XA Pitch"] intValue]];
140 [interpolValue setIntValue:[[keyValues objectForKey:@"Interpolation Quality"] intValue]];
141 [reverbValue setIntValue:[[keyValues objectForKey:@"Reverb Quality"] intValue]];
146 [interpolValue setStrings:[NSArray arrayWithObjects:
147 @"(No Interpolation)",
148 @"(Simple Interpolation)",
149 @"(Gaussian Interpolation)",
150 @"(Cubic Interpolation)",
153 [reverbValue setStrings:[NSArray arrayWithObjects: