-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathSimpleSettingsViewController.mm
113 lines (86 loc) · 2.89 KB
/
SimpleSettingsViewController.mm
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/*
Frodo, Commodore 64 emulator for the iPhone
Copyright (C)
See gpl.txt for license information.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import "SimpleSettingsViewController.h"
#import "Prefs.h"
#import "Frodo.h"
#import "C64.h"
#import "C64Defaults.h"
#import "MMStoreManager.h"
typedef struct tagPrefs {
Prefs *prefs;
};
@interface SimpleSettingsViewController()
- (void)updateControls;
@end
@implementation SimpleSettingsViewController
@synthesize showFullKeyboard, fixedJoystick, joystickOnRight, version;
- (void)viewDidLoad {
[super viewDidLoad];
changed = NO;
opaque_prefs = new tagPrefs();
opaque_prefs->prefs = new Prefs();
self.version.text = [NSString stringWithFormat:@"v%@", [[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]];
#if defined(_ARM_ARCH_7)
UILabel* speedLabel = (UILabel*)[self.view viewWithTag:1000];
speedLabel.hidden = false;
speedLabel.text = @"ARMv7 Optimized";
#endif
[self updateControls];
}
- (IBAction)downloadAllPurchases:(id)sender {
[[MMStoreManager defaultStore] downloadAllPurchases];
}
- (IBAction)toggleShowFullKeyboard:(UIButton*)sender {
changed = YES;
sender.selected = !sender.selected;
opaque_prefs->prefs->UseCommodoreKeyboard = (bool)sender.selected;
}
- (IBAction)toggleJoystickOnRight:(UIButton*)sender {
sender.selected = !sender.selected;
[C64Defaults shared].joystickOnRight = sender.selected;
}
- (IBAction)toggleFixedJoystick:(UIButton*)sender {
BOOL fixedOn = (sender.selected = !sender.selected);
[C64Defaults shared].controlsMode = fixedOn ? 1 : 0;
}
- (void)updateControls {
Prefs *prefs = opaque_prefs->prefs;
prefs->Load(Frodo::prefs_path());
showFullKeyboard.selected = prefs->UseCommodoreKeyboard;
joystickOnRight.selected = [C64Defaults shared].joystickOnRight;
fixedJoystick.selected = [C64Defaults shared].controlsMode == 1;
}
- (void)viewWillDisappear:(BOOL)animated {
if (!changed)
return;
Prefs *prefs = opaque_prefs->prefs;
prefs->Save(Frodo::prefs_path());
if (Frodo::Instance && Frodo::Instance->TheC64) {
Prefs *newPrefs = Frodo::reload_prefs();
Frodo::Instance->TheC64->NewPrefs(newPrefs);
ThePrefs = *newPrefs;
}
}
- (void)dealloc {
if (opaque_prefs) {
delete opaque_prefs->prefs;
delete opaque_prefs;
}
self.showFullKeyboard = nil;
self.fixedJoystick = nil;
[super dealloc];
}
@end