diff options
| author | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-07-03 06:57:46 +0000 |
|---|---|---|
| committer | SND\MaddTheSane_cp <SND\MaddTheSane_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-07-03 06:57:46 +0000 |
| commit | f557fb4d2b84e5948f54a5fbb0a645a5f97b83dd (patch) | |
| tree | 79d17d1962e4c0927dfafedb65107f473952d33c /macosx/plugins/DFSound/macsrc | |
| parent | 3b35614dd7a9cd014993931f3576e22b91e8820e (diff) | |
| download | pcsxr-f557fb4d2b84e5948f54a5fbb0a645a5f97b83dd.tar.gz | |
Get rid of the messy preprocessor hack for named sliders on the audio plug-ins for OS X:
Consolidate files that are the same.
Whatever class loads a nib, will be that owner, no matter what the nib says.
Have shared code be in a dylib that loads, so there isn't warnings about conflicting classes.
Other changes
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@85757 e17a0e51-4ae3-4d35-97c3-1a29b211df97
Diffstat (limited to 'macosx/plugins/DFSound/macsrc')
| -rwxr-xr-x | macosx/plugins/DFSound/macsrc/NamedSlider.h | 11 | ||||
| -rwxr-xr-x | macosx/plugins/DFSound/macsrc/NamedSlider.m | 17 | ||||
| -rwxr-xr-x | macosx/plugins/DFSound/macsrc/PluginController.h | 21 | ||||
| -rwxr-xr-x | macosx/plugins/DFSound/macsrc/PluginController.m | 89 | ||||
| -rw-r--r-- | macosx/plugins/DFSound/macsrc/SPUPluginController.h | 30 | ||||
| -rw-r--r-- | macosx/plugins/DFSound/macsrc/SPUPluginController.m | 57 |
6 files changed, 145 insertions, 80 deletions
diff --git a/macosx/plugins/DFSound/macsrc/NamedSlider.h b/macosx/plugins/DFSound/macsrc/NamedSlider.h index 38c38f9e..790db09a 100755 --- a/macosx/plugins/DFSound/macsrc/NamedSlider.h +++ b/macosx/plugins/DFSound/macsrc/NamedSlider.h @@ -2,16 +2,11 @@ #import <Cocoa/Cocoa.h> -#ifdef USEOPENAL -#define NamedSlider NetSfPeopsSPUALPluginNamedSlider -#else -#define NamedSlider NetSfPeopsSPUSDLPluginNamedSlider -#endif - @interface NamedSlider : NSSlider { NSArray *strings; + Class pluginClass; } - -- (void)setStrings:(NSArray *)theStrings; +@property (retain) NSArray *strings; +@property Class pluginClass; @end diff --git a/macosx/plugins/DFSound/macsrc/NamedSlider.m b/macosx/plugins/DFSound/macsrc/NamedSlider.m index 2db2f25e..750d0376 100755 --- a/macosx/plugins/DFSound/macsrc/NamedSlider.m +++ b/macosx/plugins/DFSound/macsrc/NamedSlider.m @@ -1,19 +1,16 @@ #import "NamedSlider.h" @implementation NamedSlider +@synthesize pluginClass; - (void)dealloc { - [strings release]; + self.strings = nil; + [super dealloc]; } -- (void)setStrings:(NSArray *)theStrings -{ - [theStrings retain]; - [strings release]; - strings = theStrings; -} +@synthesize strings; - (NSString *)stringValue { @@ -22,7 +19,11 @@ if (index >= 0 && index < [strings count]) return [strings objectAtIndex:index]; - return @"(Unknown)"; + if (!pluginClass) { + return @"(Unknown)"; + } else { + return [[NSBundle bundleForClass:pluginClass] localizedStringForKey:@"(Unknown)" value:@"" table:nil]; + } } - (void)setIntValue:(int)value diff --git a/macosx/plugins/DFSound/macsrc/PluginController.h b/macosx/plugins/DFSound/macsrc/PluginController.h index 10f2752c..38331f74 100755 --- a/macosx/plugins/DFSound/macsrc/PluginController.h +++ b/macosx/plugins/DFSound/macsrc/PluginController.h @@ -1,7 +1,7 @@ /* NetSfPeopsSPUPluginController */ #import <Cocoa/Cocoa.h> -#import "NamedSlider.h" +#import "SPUPluginController.h" #ifdef USEOPENAL #define PluginController NetSfPeopsSPUALPluginController @@ -9,22 +9,5 @@ #define PluginController NetSfPeopsSPUSDLPluginController #endif -@interface PluginController : NSWindowController -{ - IBOutlet NSControl *hiCompBox; - IBOutlet NamedSlider *interpolValue; - IBOutlet NSControl *irqWaitBox; - IBOutlet NSControl *monoSoundBox; - IBOutlet NamedSlider *reverbValue; - IBOutlet NSControl *xaEnableBox; - IBOutlet NSControl *xaSpeedBox; - IBOutlet NamedSlider *volumeValue; - - NSMutableDictionary *keyValues; -} -- (IBAction)cancel:(id)sender; -- (IBAction)ok:(id)sender; -- (IBAction)reset:(id)sender; - -- (void)loadValues; +@interface PluginController : SPUPluginController @end diff --git a/macosx/plugins/DFSound/macsrc/PluginController.m b/macosx/plugins/DFSound/macsrc/PluginController.m index c074ce72..655f479e 100755 --- a/macosx/plugins/DFSound/macsrc/PluginController.m +++ b/macosx/plugins/DFSound/macsrc/PluginController.m @@ -41,7 +41,7 @@ extern char* PLUGLOC(char* toloc); #endif #define PrefsKey APP_ID @" Settings" -static PluginController *pluginController = nil; +static SPUPluginController *pluginController = nil; char * pConfigFile=NULL; void DoAbout() @@ -80,11 +80,7 @@ long DoConfiguration() NSWindow *window; if (pluginController == nil) { -#ifdef USEOPENAL - pluginController = [[PluginController alloc] initWithWindowNibName:@"NetSfPeopsSpuALPluginMain"]; -#else - pluginController = [[PluginController alloc] initWithWindowNibName:@"NetSfPeopsSpuSDLPluginMain"]; -#endif + pluginController = [[PluginController alloc] initWithWindowNibName:@"NetSfPeopsSpuPluginMain"]; } window = [pluginController window]; @@ -103,13 +99,13 @@ void ReadConfig(void) NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys: [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithBool:YES], @"High Compatibility Mode", - [NSNumber numberWithBool:YES], @"SPU IRQ Wait", - [NSNumber numberWithBool:NO], @"XA Pitch", - [NSNumber numberWithBool:NO], @"Mono Sound Output", - [NSNumber numberWithInt:0], @"Interpolation Quality", - [NSNumber numberWithInt:1], @"Reverb Quality", - [NSNumber numberWithInt:3], @"Volume", + @YES, @"High Compatibility Mode", + @YES, @"SPU IRQ Wait", + @NO, @"XA Pitch", + @NO, @"Mono Sound Output", + @0, @"Interpolation Quality", + @1, @"Reverb Quality", + @3, @"Volume", nil], PrefsKey, nil]]; @@ -138,15 +134,15 @@ void ReadConfig(void) NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; NSMutableDictionary *writeDic = [NSMutableDictionary dictionaryWithDictionary:keyValues]; - [writeDic setObject:[NSNumber numberWithBool:[hiCompBox intValue]] forKey:@"High Compatibility Mode"]; - [writeDic setObject:[NSNumber numberWithBool:[irqWaitBox intValue]] forKey:@"SPU IRQ Wait"]; - [writeDic setObject:[NSNumber numberWithBool:[monoSoundBox intValue]] forKey:@"Mono Sound Output"]; - [writeDic setObject:[NSNumber numberWithBool:[xaSpeedBox intValue]] forKey:@"XA Pitch"]; + [writeDic setObject:@((BOOL)[hiCompBox intValue]) forKey:@"High Compatibility Mode"]; + [writeDic setObject:@((BOOL)[irqWaitBox intValue]) forKey:@"SPU IRQ Wait"]; + [writeDic setObject:@((BOOL)[monoSoundBox intValue]) forKey:@"Mono Sound Output"]; + [writeDic setObject:@((BOOL)[xaSpeedBox intValue]) forKey:@"XA Pitch"]; - [writeDic setObject:[NSNumber numberWithInt:[interpolValue intValue]] forKey:@"Interpolation Quality"]; - [writeDic setObject:[NSNumber numberWithInt:[reverbValue intValue]] forKey:@"Reverb Quality"]; + [writeDic setObject:@([interpolValue intValue]) forKey:@"Interpolation Quality"]; + [writeDic setObject:@([reverbValue intValue]) forKey:@"Reverb Quality"]; - [writeDic setObject:[NSNumber numberWithInt:[volumeValue intValue]] forKey:@"Volume"]; + [writeDic setObject:@([volumeValue intValue]) forKey:@"Volume"]; // write to defaults [defaults setObject:writeDic forKey:PrefsKey]; @@ -187,37 +183,40 @@ void ReadConfig(void) - (void)awakeFromNib { - NSBundle *mainBundle = [NSBundle bundleForClass:[self class]]; - - [interpolValue setStrings:[NSArray arrayWithObjects: - [mainBundle localizedStringForKey:@"(No Interpolation)" value:nil table:nil], - [mainBundle localizedStringForKey:@"(Simple Interpolation)" value:nil table:nil], - [mainBundle localizedStringForKey:@"(Gaussian Interpolation)" value:nil table:nil], - [mainBundle localizedStringForKey:@"(Cubic Interpolation)" value:nil table:nil], - nil]]; - - [reverbValue setStrings:[NSArray arrayWithObjects: - [mainBundle localizedStringForKey:@"(No Reverb)" value:nil table:nil], - [mainBundle localizedStringForKey:@"(Simple Reverb)" value:nil table:nil], - [mainBundle localizedStringForKey:@"(PSX Reverb)" value:nil table:nil], - nil]]; - - [volumeValue setStrings:[NSArray arrayWithObjects: - [mainBundle localizedStringForKey:@"(Muted)" value:nil table:nil], - [mainBundle localizedStringForKey:@"(Low)" value:nil table:nil], - [mainBundle localizedStringForKey:@"(Medium)" value:nil table:nil], - [mainBundle localizedStringForKey:@"(Loud)" value:nil table:nil], - [mainBundle localizedStringForKey:@"(Loudest)" value:nil table:nil], - nil]]; + Class thisClass = [self class]; + + NSBundle *mainBundle = [NSBundle bundleForClass:thisClass]; + + [interpolValue setStrings:@[ + [mainBundle localizedStringForKey:@"(No Interpolation)" value:@"" table:nil], + [mainBundle localizedStringForKey:@"(Simple Interpolation)" value:@"" table:nil], + [mainBundle localizedStringForKey:@"(Gaussian Interpolation)" value:@"" table:nil], + [mainBundle localizedStringForKey:@"(Cubic Interpolation)" value:@"" table:nil]]]; + interpolValue.pluginClass = thisClass; + + [reverbValue setStrings:@[ + [mainBundle localizedStringForKey:@"(No Reverb)" value:@"" table:nil], + [mainBundle localizedStringForKey:@"(Simple Reverb)" value:@"" table:nil], + [mainBundle localizedStringForKey:@"(PSX Reverb)" value:@"" table:nil]]]; + reverbValue.pluginClass = thisClass; + + [volumeValue setStrings:@[ + [mainBundle localizedStringForKey:@"(Muted)" value:@"" table:nil], + [mainBundle localizedStringForKey:@"(Low)" value:@"" table:nil], + [mainBundle localizedStringForKey:@"(Medium)" value:@"" table:nil], + [mainBundle localizedStringForKey:@"(Loud)" value:@"" table:nil], + [mainBundle localizedStringForKey:@"(Loudest)" value:@"" table:nil]]]; + volumeValue.pluginClass = thisClass; } @end + char* PLUGLOC(char *toloc) { NSBundle *mainBundle = [NSBundle bundleForClass:[PluginController class]]; NSString *origString = nil, *transString = nil; - origString = [NSString stringWithCString:toloc encoding:NSUTF8StringEncoding]; - transString = [mainBundle localizedStringForKey:origString value:nil table:nil]; - return (char*)[transString cStringUsingEncoding:NSUTF8StringEncoding]; + origString = @(toloc); + transString = [mainBundle localizedStringForKey:origString value:@"" table:nil]; + return (char*)[transString UTF8String]; } diff --git a/macosx/plugins/DFSound/macsrc/SPUPluginController.h b/macosx/plugins/DFSound/macsrc/SPUPluginController.h new file mode 100644 index 00000000..e6a61308 --- /dev/null +++ b/macosx/plugins/DFSound/macsrc/SPUPluginController.h @@ -0,0 +1,30 @@ +// +// SPUPluginController.h +// PeopsSPU +// +// Created by C.W. Betts on 7/2/13. +// +// + +#import <Cocoa/Cocoa.h> +#import "NamedSlider.h" + +@interface SPUPluginController : NSWindowController +{ + IBOutlet NSControl *hiCompBox; + IBOutlet NamedSlider *interpolValue; + IBOutlet NSControl *irqWaitBox; + IBOutlet NSControl *monoSoundBox; + IBOutlet NamedSlider *reverbValue; + IBOutlet NSControl *xaEnableBox; + IBOutlet NSControl *xaSpeedBox; + IBOutlet NamedSlider *volumeValue; + + NSMutableDictionary *keyValues; +} +- (IBAction)cancel:(id)sender; +- (IBAction)ok:(id)sender; +- (IBAction)reset:(id)sender; + +- (void)loadValues; +@end diff --git a/macosx/plugins/DFSound/macsrc/SPUPluginController.m b/macosx/plugins/DFSound/macsrc/SPUPluginController.m new file mode 100644 index 00000000..bfc11f01 --- /dev/null +++ b/macosx/plugins/DFSound/macsrc/SPUPluginController.m @@ -0,0 +1,57 @@ +// +// SPUPluginController.m +// PeopsSPU +// +// Created by C.W. Betts on 7/2/13. +// +// + +#import "SPUPluginController.h" + +@implementation SPUPluginController + +static inline void FuncNotAvailable(id sel, id sender, SEL theCmd) +{ +#ifdef DEBUG + NSLog(@"Class %@ does not implement %@, and was sent a(n) %@ with the description %@", [sel class], NSStringFromSelector(theCmd), [sender class], [sender description]); + if ([sel isMemberOfClass:[SPUPluginController class]]) { + NSLog(@"For one thing, the class %@ isn't supposed to be accessed directly, just subclassed!", [SPUPluginController class]); \ + } else { + NSLog(@"You should implement %@ for your class %@. As it is, you are calling %@ from the superclass %@.", NSStringFromSelector(theCmd), [sel class], NSStringFromSelector(theCmd), [SPUPluginController class]); + } +#endif + [sel doesNotRecognizeSelector:theCmd]; +} + +#define NotAvailableWarn() FuncNotAvailable(self, sender, _cmd) + +- (IBAction)cancel:(id)sender +{ + NotAvailableWarn(); + +} + +- (IBAction)ok:(id)sender +{ + NotAvailableWarn(); +} + +- (IBAction)reset:(id)sender +{ + NotAvailableWarn(); +} + +- (void)loadValues +{ +#ifdef DEBUG + NSLog(@"Class %@ does not implement %@", [self class], NSStringFromSelector(_cmd)); + if ([self isMemberOfClass:[SPUPluginController class]]) { + NSLog(@"For one thing, the class %@ isn't supposed to be accessed directly, just subclassed!", [SPUPluginController class]); + } else { + NSLog(@"You should implement %@ for your class %@. As it is, you are calling %@ from the superclass %@.", NSStringFromSelector(_cmd), [self class], NSStringFromSelector(_cmd), [SPUPluginController class]); + } +#endif + [self doesNotRecognizeSelector:_cmd]; +} + +@end |
