aboutsummaryrefslogtreecommitdiff
path: root/macosx/ConfigurationController.m
diff options
context:
space:
mode:
authorPCSX* teams2010-11-16 14:15:22 +0200
committerGrazvydas Ignotas2010-11-16 14:15:22 +0200
commitef79bbde537d6b9c745a7d86cb9df1d04c35590d (patch)
treeef8d2520dbb9e1e345b41b12c9959f300ca8fd10 /macosx/ConfigurationController.m
downloadpcsx_rearmed-ef79bbde537d6b9c745a7d86cb9df1d04c35590d.tar.gz
pcsx_rearmed-ef79bbde537d6b9c745a7d86cb9df1d04c35590d.tar.bz2
pcsx_rearmed-ef79bbde537d6b9c745a7d86cb9df1d04c35590d.zip
pcsxr-1.9.92
Diffstat (limited to 'macosx/ConfigurationController.m')
-rw-r--r--macosx/ConfigurationController.m203
1 files changed, 203 insertions, 0 deletions
diff --git a/macosx/ConfigurationController.m b/macosx/ConfigurationController.m
new file mode 100644
index 0000000..9f692ca
--- /dev/null
+++ b/macosx/ConfigurationController.m
@@ -0,0 +1,203 @@
+#import "ConfigurationController.h"
+#import "PcsxController.h"
+#import "PluginList.h"
+#import "PcsxPlugin.h"
+#include "psxcommon.h"
+#include "plugins.h"
+
+@implementation ConfigurationController
+
+- (IBAction)setCheckbox:(id)sender
+{
+ if ([sender isKindOfClass:[NSMatrix class]]) {
+ sender = [sender selectedCell];
+ }
+
+ NSString *key = [self keyForSender:sender];
+ if (key) {
+ [[NSUserDefaults standardUserDefaults] setInteger:[sender intValue] forKey:key];
+ [PcsxController setConfigFromDefaults];
+ }
+}
+
+- (IBAction)setCheckboxInverse:(id)sender
+{
+ if ([sender isKindOfClass:[NSMatrix class]]) {
+ sender = [sender selectedCell];
+ }
+
+ NSString *key = [self keyForSender:sender];
+ if (key) {
+ [[NSUserDefaults standardUserDefaults] setInteger:![sender intValue] forKey:key];
+ [PcsxController setConfigFromDefaults];
+ }
+}
+
+- (IBAction)mcdChangeClicked:(id)sender
+{
+ int tag = [sender tag];
+ char *mcd;
+ NSTextField *label;
+ NSOpenPanel *openDlg = [NSOpenPanel openPanel];
+ NSString *path;
+
+ if (tag == 1) { mcd = Config.Mcd1; label = mcd1Label; }
+ else { mcd = Config.Mcd2; label = mcd2Label; }
+
+ [openDlg setCanChooseFiles:YES];
+ [openDlg setCanChooseDirectories:NO];
+
+ path = [NSString stringWithCString:mcd];
+
+ if ([openDlg runModalForDirectory:[path stringByDeletingLastPathComponent] file:[path lastPathComponent]] == NSOKButton) {
+ NSArray* files = [openDlg filenames];
+ strcpy(mcd, (const char *)[[files objectAtIndex:0] fileSystemRepresentation]);
+
+ [label setTitleWithMnemonic:[NSString stringWithCString:mcd]];
+
+ if (tag == 1)
+ [[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithCString:mcd] forKey:@"Mcd1"];
+ else
+ [[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithCString:mcd] forKey:@"Mcd2"];
+ }
+}
+
+- (IBAction)mcdNewClicked:(id)sender
+{
+ int tag = [sender tag];
+ char *mcd;
+ NSTextField *label;
+ NSSavePanel *openDlg = [NSSavePanel savePanel];
+ NSString *path;
+
+ if (tag == 1) { mcd = Config.Mcd1; label = mcd1Label; }
+ else { mcd = Config.Mcd2; label = mcd2Label; }
+
+ path = [NSString stringWithCString:mcd];
+
+ if ([openDlg runModalForDirectory:[path stringByDeletingLastPathComponent] file:@"New Memory Card File.mcr"] == NSOKButton) {
+ strcpy(mcd, (const char *)[[openDlg filename] fileSystemRepresentation]);
+
+ [label setTitleWithMnemonic:[NSString stringWithCString:mcd]];
+
+ if (tag == 1)
+ [[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithCString:mcd] forKey:@"Mcd1"];
+ else
+ [[NSUserDefaults standardUserDefaults] setObject:[NSString stringWithCString:mcd] forKey:@"Mcd2"];
+
+ CreateMcd(mcd);
+ }
+}
+
+- (IBAction)setVideoType:(id)sender
+{
+ int tag = [[sender selectedItem] tag];
+
+ if (3 == tag) {
+ [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"AutoDetectVideoType"];
+ } else if (1 == tag || 2 == tag) {
+ [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"AutoDetectVideoType"];
+ [[NSUserDefaults standardUserDefaults] setBool:tag==2 forKey:@"VideoTypePAL"];
+ } else {
+ return;
+ }
+ [PcsxController setConfigFromDefaults];
+
+ if ([sender pullsDown]) {
+ NSArray *items = [sender itemArray];
+ int i;
+
+ for (i=0; i<[items count]; i++)
+ [[items objectAtIndex:i] setState:NSOffState];
+
+ [[sender selectedItem] setState:NSOnState];
+ }
+}
+
+- (void)awakeFromNib
+{
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+
+ [[self window] center];
+
+ // setup checkboxes
+ checkBoxDefaults = [[NSMutableDictionary alloc] init];
+
+ // check that the outlets are active before adding them
+ if (noXaAudioCell) [checkBoxDefaults setObject:noXaAudioCell forKey:@"NoXaAudio"];
+ if (sioIrqAlwaysCell) [checkBoxDefaults setObject:sioIrqAlwaysCell forKey:@"SioIrqAlways"];
+ if (bwMdecCell) [checkBoxDefaults setObject:bwMdecCell forKey:@"BlackAndWhiteMDECVideo"];
+ if (autoVTypeCell) [checkBoxDefaults setObject:autoVTypeCell forKey:@"AutoDetectVideoType"];
+ if (vTypePALCell) [checkBoxDefaults setObject:vTypePALCell forKey:@"VideoTypePAL"];
+ if (noCDAudioCell) [checkBoxDefaults setObject:noCDAudioCell forKey:@"NoCDAudio"];
+ if (usesHleCell) [checkBoxDefaults setObject:usesHleCell forKey:@"UseHLE"];
+ if (usesDynarecCell) [checkBoxDefaults setObject:usesDynarecCell forKey:@"NoDynarec"];
+ if (consoleOutputCell) [checkBoxDefaults setObject:consoleOutputCell forKey:@"ConsoleOutput"];
+ if (spuIrqAlwaysCell) [checkBoxDefaults setObject:spuIrqAlwaysCell forKey:@"SpuIrqAlways"];
+ if (rCountFixCell) [checkBoxDefaults setObject:rCountFixCell forKey:@"RootCounterFix"];
+ if (vSyncWAFixCell) [checkBoxDefaults setObject:vSyncWAFixCell forKey:@"VideoSyncWAFix"];
+ if (noFastBootCell) [checkBoxDefaults setObject:noFastBootCell forKey:@"NoFastBoot"];
+
+ // make the visuals match the defaults
+ NSEnumerator *enumerator= [checkBoxDefaults keyEnumerator];
+ id key;
+ while ((key = [enumerator nextObject])) {
+ if ([defaults integerForKey:key]) {
+ [[checkBoxDefaults objectForKey:key] setNextState];
+ }
+ }
+
+ // special cases
+ if (![PcsxController biosAvailable]) {
+ // no bios means always use HLE
+ [usesHleCell setState:NSOnState];
+ [usesHleCell setEnabled:NO];
+ }
+
+ // setup labels
+ [mcd1Label setTitleWithMnemonic:[NSString stringWithCString:Config.Mcd1]];
+ [mcd2Label setTitleWithMnemonic:[NSString stringWithCString:Config.Mcd2]];
+
+ int tag = [defaults integerForKey:@"AutoDetectVideoType"];
+ if (tag)
+ tag = 3;
+ else {
+ tag = [defaults integerForKey:@"VideoTypePAL"]+1;
+ }
+ [vTypePALCell setAutoenablesItems:NO];
+ if ([vTypePALCell pullsDown]) {
+ [[vTypePALCell itemAtIndex:[vTypePALCell indexOfItemWithTag:tag]] setState:NSOnState];
+ } else {
+ [vTypePALCell selectItemAtIndex:[vTypePALCell indexOfItemWithTag:tag]];
+ }
+
+ // setup plugin lists
+ PluginList *list = [PluginList list];
+
+ [list refreshPlugins];
+ [graphicsPlugin setPluginsTo:[list pluginsForType:PSE_LT_GPU] withType: PSE_LT_GPU];
+ [soundPlugin setPluginsTo:[list pluginsForType:PSE_LT_SPU] withType: PSE_LT_SPU];
+ [padPlugin setPluginsTo:[list pluginsForType:PSE_LT_PAD] withType: PSE_LT_PAD];
+ [cdromPlugin setPluginsTo:[list pluginsForType:PSE_LT_CDR] withType: PSE_LT_CDR];
+}
+
+- (void)dealloc
+{
+ [checkBoxDefaults release];
+ [super dealloc];
+}
+
+- (NSString *)keyForSender:(id)sender
+{
+ NSEnumerator *enumerator= [checkBoxDefaults keyEnumerator];
+ id key;
+ while ((key = [enumerator nextObject])) {
+ id object = [checkBoxDefaults objectForKey:key];
+ if ([object isEqual:sender])
+ return key;
+ }
+
+ return nil;
+}
+
+@end