forked from sshivaji/stockfish-mac-gui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPreferencesController.m
86 lines (70 loc) · 2.66 KB
/
PreferencesController.m
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
#import "PreferencesController.h"
@implementation PreferencesController
-(id)init {
self = [super initWithWindowNibName: @"Preferences"];
return self;
}
-(void)windowDidLoad {
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[analysisInMoveListSwitch
setState: [defaults boolForKey: @"Include Engine Analysis in Move List"]];
[whiteScoreSwitch
setState: [defaults boolForKey:
@"Display all Scores from White's Point of View"]];
[resignSwitch
setState: [defaults boolForKey: @"Resign in Hopeless Positions"]];
[hashSizeTextField
setIntValue: [defaults integerForKey: @"Default Hash Table Size"]];
[darkColorWell
setColor: [NSUnarchiver unarchiveObjectWithData:
[defaults objectForKey: @"Dark Square Color"]]];
[lightColorWell
setColor: [NSUnarchiver unarchiveObjectWithData:
[defaults objectForKey: @"Light Square Color"]]];
[beepWhenMoveSwitch
setState: [defaults boolForKey: @"Beep when Making Moves"]];
}
-(IBAction)changeDarkSquareColor:(id)sender {
[[NSUserDefaults standardUserDefaults]
setObject: [NSArchiver archivedDataWithRootObject: [sender color]]
forKey: @"Dark Square Color"];
// Notify about color change:
[[NSNotificationCenter defaultCenter]
postNotificationName: @"BoardColorsChanged" object: nil];
}
-(IBAction)changeLightSquareColor:(id)sender {
[[NSUserDefaults standardUserDefaults]
setObject: [NSArchiver archivedDataWithRootObject: [sender color]]
forKey: @"Light Square Color"];
// Notify about color change:
[[NSNotificationCenter defaultCenter]
postNotificationName: @"BoardColorsChanged" object: nil];
}
-(IBAction)analysisInMoveListSwitched:(id)sender {
[[NSUserDefaults standardUserDefaults]
setBool: [sender state] forKey: @"Include Engine Analysis in Move List"];
}
-(IBAction)hashTextFieldChanged:(id)sender {
}
-(IBAction)resignSwitched:(id)sender {
[[NSUserDefaults standardUserDefaults]
setBool: [sender state] forKey: @"Resign in Hopeless Positions"];
}
-(IBAction)whiteScoreSwitched:(id)sender {
[[NSUserDefaults standardUserDefaults]
setBool: [sender state]
forKey: @"Display all Scores from White's Point of View"];
}
-(IBAction)beepWhenMoveSwitched:(id)sender {
[[NSUserDefaults standardUserDefaults]
setBool: [sender state] forKey: @"Beep when Making Moves"];
[[NSNotificationCenter defaultCenter]
postNotificationName: @"BeepWhenMakingMovesChanged" object: nil];
}
-(void)controlTextDidChange:(NSNotification *)aNotification {
int newSize = [hashSizeTextField intValue];
if(newSize > 0)
[[NSUserDefaults standardUserDefaults]
setInteger: newSize forKey: @"Default Hash Table Size"];
}
@end