1 #import "PluginConfigController.h"
7 #define APP_ID @"net.sf.peops.SoftGpuGLPlugin"
8 #define PrefsKey APP_ID @" Settings"
10 static PluginConfigController *windowController;
11 char * pConfigFile=NULL;
15 // Get parent application instance
16 NSApplication *app = [NSApplication sharedApplication];
17 NSBundle *bundle = [NSBundle bundleWithIdentifier:APP_ID];
20 NSString *path = [bundle pathForResource:@"Credits" ofType:@"rtf"];
21 NSAttributedString *credits;
23 credits = [[[NSAttributedString alloc] initWithPath: path
24 documentAttributes:NULL] autorelease];
26 credits = [[[NSAttributedString alloc] initWithString:@""] autorelease];
29 // Get Application Icon
30 NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:[bundle bundlePath]];
31 NSSize size = NSMakeSize(64, 64);
34 [app orderFrontStandardAboutPanelWithOptions:[NSDictionary dictionaryWithObjectsAndKeys:
35 [bundle objectForInfoDictionaryKey:@"CFBundleName"], @"ApplicationName",
36 icon, @"ApplicationIcon",
37 [bundle objectForInfoDictionaryKey:@"CFBundleShortVersionString"], @"ApplicationVersion",
38 [bundle objectForInfoDictionaryKey:@"CFBundleVersion"], @"Version",
39 [bundle objectForInfoDictionaryKey:@"NSHumanReadableCopyright"], @"Copyright",
49 if (windowController == nil) {
50 windowController = [[PluginConfigController alloc] initWithWindowNibName:@"NetSfPeopsSoftGPUConfig"];
52 window = [windowController window];
55 [windowController loadValues];
58 [window makeKeyAndOrderFront:nil];
63 NSDictionary *keyValues;
64 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
65 [defaults registerDefaults:[NSDictionary dictionaryWithObjectsAndKeys:
66 [[NSMutableDictionary alloc] initWithObjectsAndKeys:
67 [NSNumber numberWithBool:NO], @"FPS Counter",
68 [NSNumber numberWithBool:NO], @"Auto Full Screen",
69 [NSNumber numberWithBool:NO], @"Frame Skipping",
70 [NSNumber numberWithBool:YES], @"Frame Limit",
71 [NSNumber numberWithBool:NO], @"VSync",
72 [NSNumber numberWithBool:NO], @"Enable Hacks",
73 [NSNumber numberWithInt:1], @"Dither Mode",
74 [NSNumber numberWithLong:0], @"Hacks",
78 keyValues = [defaults dictionaryForKey:PrefsKey];
80 iShowFPS = [[keyValues objectForKey:@"FPS Counter"] boolValue];
81 iWindowMode = [[keyValues objectForKey:@"Auto Full Screen"] boolValue] ? 0 : 1;
82 UseFrameSkip = [[keyValues objectForKey:@"Frame Skipping"] boolValue];
83 UseFrameLimit = [[keyValues objectForKey:@"Frame Limit"] boolValue];
84 //??? = [[keyValues objectForKey:@"VSync"] boolValue];
85 iUseFixes = [[keyValues objectForKey:@"Enable Hacks"] boolValue];
87 iUseDither = [[keyValues objectForKey:@"Dither Mode"] intValue];
88 dwCfgFixes = [[keyValues objectForKey:@"Hacks"] longValue];
98 ulKeybits|=KEY_SHOWFPS;
100 ulKeybits&=~KEY_SHOWFPS;
103 if(!iColDepth) iColDepth=32;
104 if(iUseFixes) dwActFixes=dwCfgFixes;
108 if(iFrameLimit==2) SetAutoFrameCap();
109 bSkipNextFrame = FALSE;
115 @implementation PluginConfigController
117 - (IBAction)cancel:(id)sender
122 - (IBAction)ok:(id)sender
124 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
126 NSMutableDictionary *writeDic = [NSMutableDictionary dictionaryWithDictionary:keyValues];
127 [writeDic setObject:[NSNumber numberWithInt:[fpsCounter intValue]] forKey:@"FPS Counter"];
128 [writeDic setObject:[NSNumber numberWithInt:[autoFullScreen intValue]] forKey:@"Auto Full Screen"];
129 [writeDic setObject:[NSNumber numberWithInt:[frameSkipping intValue]] forKey:@"Frame Skipping"];
130 //[writeDic setObject:[NSNumber numberWithInt:[frameLimit intValue]] forKey:@"Frame Limit"];
131 [writeDic setObject:[NSNumber numberWithInt:[vSync intValue]] forKey:@"VSync"];
132 [writeDic setObject:[NSNumber numberWithInt:[hackEnable intValue]] forKey:@"Enable Hacks"];
134 [writeDic setObject:[NSNumber numberWithInt:[ditherMode indexOfSelectedItem]] forKey:@"Dither Mode"];
136 unsigned long hackValues = 0;
138 NSArray *views = [hacksView subviews];
139 for (i=0; i<[views count]; i++) {
140 NSView *control = [views objectAtIndex:i];
141 if ([control isKindOfClass:[NSButton class]]) {
142 hackValues |= [(NSControl *)control intValue] << ([control tag] - 1);
146 [writeDic setObject:[NSNumber numberWithLong:hackValues] forKey:@"Hacks"];
149 [defaults setObject:writeDic forKey:PrefsKey];
150 [defaults synchronize];
152 // and set global values accordingly
158 - (IBAction)reset:(id)sender
160 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
161 [defaults removeObjectForKey:PrefsKey];
165 - (IBAction)hackToggle:(id)sender
167 BOOL enable = [sender intValue] ? YES : NO;
169 NSArray *views = [hacksView subviews];
171 for (i=0; i<[views count]; i++) {
172 NSView *control = [views objectAtIndex:i];
173 if ([control isKindOfClass:[NSButton class]]) {
174 [(NSControl *)control setEnabled:enable];
181 NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
185 /* load from preferences */
187 keyValues = [[defaults dictionaryForKey:PrefsKey] retain];
189 [fpsCounter setIntValue:[[keyValues objectForKey:@"FPS Counter"] intValue]];
190 [autoFullScreen setIntValue:[[keyValues objectForKey:@"Auto Full Screen"] intValue]];
191 [frameSkipping setIntValue:[[keyValues objectForKey:@"Frame Skipping"] intValue]];
192 [vSync setIntValue:[[keyValues objectForKey:@"VSync"] intValue]];
193 [hackEnable setIntValue:[[keyValues objectForKey:@"Enable Hacks"] intValue]];
195 [ditherMode selectItemAtIndex:[[keyValues objectForKey:@"Dither Mode"] intValue]];
197 unsigned long hackValues = [[keyValues objectForKey:@"Hacks"] longValue];
200 NSArray *views = [hacksView subviews];
201 for (i=0; i<[views count]; i++) {
202 NSView *control = [views objectAtIndex:i];
203 if ([control isKindOfClass:[NSButton class]]) {
204 [(NSControl *)control setIntValue:(hackValues >> ([control tag] - 1)) & 1];
208 [self hackToggle:hackEnable];
213 hacksView = [[hacksView subviews] objectAtIndex:0];