mirror of
https://github.com/zydeco/minivmac4ios.git
synced 2025-02-19 07:31:01 +00:00
add settings UI for choosing emulated machine
This commit is contained in:
parent
a589be4302
commit
75114c37eb
@ -45,6 +45,12 @@
|
||||
283423E01CF9C66D0088B634 /* VIA2EMDV.c in Sources */ = {isa = PBXBuildFile; fileRef = 283423591CF9C0F10088B634 /* VIA2EMDV.c */; };
|
||||
283423E11CF9C66D0088B634 /* VIAEMDEV.c in Sources */ = {isa = PBXBuildFile; fileRef = 2834235B1CF9C0F10088B634 /* VIAEMDEV.c */; };
|
||||
283423E21CF9C66D0088B634 /* VIDEMDEV.c in Sources */ = {isa = PBXBuildFile; fileRef = 2834235D1CF9C0F10088B634 /* VIDEMDEV.c */; };
|
||||
283423E91CFA32870088B634 /* MacPlus.png in Resources */ = {isa = PBXBuildFile; fileRef = 283423E31CFA32800088B634 /* MacPlus.png */; };
|
||||
283423EA1CFA32870088B634 /* MacPlus@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 283423E41CFA32800088B634 /* MacPlus@2x.png */; };
|
||||
283423EB1CFA32870088B634 /* MacPlus@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 283423E51CFA32800088B634 /* MacPlus@3x.png */; };
|
||||
283423EF1CFA329C0088B634 /* MacII.png in Resources */ = {isa = PBXBuildFile; fileRef = 283423EC1CFA329C0088B634 /* MacII.png */; };
|
||||
283423F01CFA329C0088B634 /* MacII@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 283423ED1CFA329C0088B634 /* MacII@2x.png */; };
|
||||
283423F11CFA329C0088B634 /* MacII@3x.png in Resources */ = {isa = PBXBuildFile; fileRef = 283423EE1CFA329C0088B634 /* MacII@3x.png */; };
|
||||
28848B621CDE97D600B86C45 /* InsertDiskViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28848B611CDE97D600B86C45 /* InsertDiskViewController.m */; };
|
||||
28848B651CDE97E900B86C45 /* SettingsViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28848B641CDE97E900B86C45 /* SettingsViewController.m */; };
|
||||
28BA897E1CE7315400A98104 /* KBKey.m in Sources */ = {isa = PBXBuildFile; fileRef = 28BA89751CE7315400A98104 /* KBKey.m */; };
|
||||
@ -219,6 +225,12 @@
|
||||
2834239A1CF9C5380088B634 /* CNFGRAPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CNFGRAPI.h; sourceTree = "<group>"; };
|
||||
2834239B1CF9C5380088B634 /* EMCONFIG.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EMCONFIG.h; sourceTree = "<group>"; };
|
||||
2834239C1CF9C5380088B634 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
283423E31CFA32800088B634 /* MacPlus.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = MacPlus.png; sourceTree = "<group>"; };
|
||||
283423E41CFA32800088B634 /* MacPlus@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "MacPlus@2x.png"; sourceTree = "<group>"; };
|
||||
283423E51CFA32800088B634 /* MacPlus@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "MacPlus@3x.png"; sourceTree = "<group>"; };
|
||||
283423EC1CFA329C0088B634 /* MacII.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = MacII.png; sourceTree = "<group>"; };
|
||||
283423ED1CFA329C0088B634 /* MacII@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "MacII@2x.png"; sourceTree = "<group>"; };
|
||||
283423EE1CFA329C0088B634 /* MacII@3x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "MacII@3x.png"; sourceTree = "<group>"; };
|
||||
28848B601CDE97D600B86C45 /* InsertDiskViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InsertDiskViewController.h; sourceTree = "<group>"; };
|
||||
28848B611CDE97D600B86C45 /* InsertDiskViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InsertDiskViewController.m; sourceTree = "<group>"; };
|
||||
28848B631CDE97E900B86C45 /* SettingsViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SettingsViewController.h; sourceTree = "<group>"; };
|
||||
@ -350,6 +362,9 @@
|
||||
283422E81CF8F1C80088B634 /* CNFGRAPI.h */,
|
||||
283422E91CF8F1C80088B634 /* EMCONFIG.h */,
|
||||
283422CE1CF8EF8C0088B634 /* Info.plist */,
|
||||
283423E31CFA32800088B634 /* MacPlus.png */,
|
||||
283423E41CFA32800088B634 /* MacPlus@2x.png */,
|
||||
283423E51CFA32800088B634 /* MacPlus@3x.png */,
|
||||
);
|
||||
path = MacPlus4M;
|
||||
sourceTree = "<group>";
|
||||
@ -451,6 +466,9 @@
|
||||
2834239A1CF9C5380088B634 /* CNFGRAPI.h */,
|
||||
2834239B1CF9C5380088B634 /* EMCONFIG.h */,
|
||||
2834239C1CF9C5380088B634 /* Info.plist */,
|
||||
283423EC1CFA329C0088B634 /* MacII.png */,
|
||||
283423ED1CFA329C0088B634 /* MacII@2x.png */,
|
||||
283423EE1CFA329C0088B634 /* MacII@3x.png */,
|
||||
);
|
||||
path = MacII;
|
||||
sourceTree = "<group>";
|
||||
@ -791,6 +809,9 @@
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
283423E91CFA32870088B634 /* MacPlus.png in Resources */,
|
||||
283423EA1CFA32870088B634 /* MacPlus@2x.png in Resources */,
|
||||
283423EB1CFA32870088B634 /* MacPlus@3x.png in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -798,6 +819,9 @@
|
||||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
283423EF1CFA329C0088B634 /* MacII.png in Resources */,
|
||||
283423F01CFA329C0088B634 /* MacII@2x.png in Resources */,
|
||||
283423F11CFA329C0088B634 /* MacII@3x.png in Resources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
@ -14,7 +14,7 @@
|
||||
@property (strong, nonatomic) UIWindow *window;
|
||||
@property (nonatomic, readonly) NSString *documentsPath;
|
||||
@property (nonatomic, readonly) NSArray<NSString*> *diskImageExtensions;
|
||||
@property (nonatomic, readonly) NSArray<NSBundle*> *availableEmulators;
|
||||
@property (nonatomic, readonly) NSArray<NSBundle*> *emulatorBundles;
|
||||
@property (readonly, nonatomic, getter = isSandboxed) BOOL sandboxed;
|
||||
|
||||
+ (instancetype)sharedInstance;
|
||||
|
@ -50,7 +50,7 @@ static NSObject<Emulator> *sharedEmulator = nil;
|
||||
NSDictionary *defaultValues = @{@"trackpad": @([UIDevice currentDevice].userInterfaceIdiom != UIUserInterfaceIdiomPad),
|
||||
@"frameskip": @(0),
|
||||
@"keyboardLayout": layoutForLanguage[firstLanguage],
|
||||
@"machine": @"MacII"
|
||||
@"machine": @"MacPlus4M"
|
||||
};
|
||||
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
@ -67,7 +67,7 @@ static NSObject<Emulator> *sharedEmulator = nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSArray<NSBundle*>*)availableEmulators {
|
||||
- (NSArray<NSBundle*>*)emulatorBundles {
|
||||
NSString *pluginsPath = [NSBundle mainBundle].builtInPlugInsPath;
|
||||
NSArray<NSString*> *names = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:pluginsPath error:NULL];
|
||||
NSMutableArray *emulatorBundles = [NSMutableArray arrayWithCapacity:names.count];
|
||||
@ -79,7 +79,6 @@ static NSObject<Emulator> *sharedEmulator = nil;
|
||||
}
|
||||
|
||||
- (BOOL)loadEmulator:(NSString*)name {
|
||||
NSLog(@"Loading %@", name);
|
||||
NSString *emulatorBundleName = [name stringByAppendingPathExtension:@"mnvm"];
|
||||
NSString *emulatorBundlePath = [[NSBundle mainBundle].builtInPlugInsPath stringByAppendingPathComponent:emulatorBundleName];
|
||||
NSBundle *emulatorBundle = [NSBundle bundleWithPath:emulatorBundlePath];
|
||||
|
@ -48,7 +48,7 @@
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="44" sectionHeaderHeight="18" sectionFooterHeight="18" id="9gA-gD-7Wx">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" cocoaTouchSystemColor="groupTableViewBackgroundColor"/>
|
||||
<color key="backgroundColor" red="0.93725490199999995" green="0.93725490199999995" blue="0.95686274510000002" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<prototypes>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="none" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="speed" id="v4I-0T-H8m">
|
||||
<rect key="frame" x="0.0" y="93.5" width="600" height="44"/>
|
||||
@ -115,13 +115,13 @@
|
||||
<rect key="frame" x="15" y="0.0" width="570" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="about" textLabel="znE-ML-UrQ" detailTextLabel="xcq-HY-ZDe" style="IBUITableViewCellStyleValue1" id="MGj-K1-5lZ">
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="machine" textLabel="znE-ML-UrQ" detailTextLabel="xcq-HY-ZDe" style="IBUITableViewCellStyleSubtitle" id="MGj-K1-5lZ">
|
||||
<rect key="frame" x="0.0" y="225.5" width="600" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="MGj-K1-5lZ" id="ueO-zm-JQP">
|
||||
@ -129,17 +129,41 @@
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="znE-ML-UrQ">
|
||||
<rect key="frame" x="15" y="6" width="31.5" height="19.5"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Detail" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="xcq-HY-ZDe">
|
||||
<rect key="frame" x="15" y="25.5" width="30.5" height="13.5"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="11"/>
|
||||
<color key="textColor" red="0.5568627451" green="0.5568627451" blue="0.57647058819999997" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
</tableViewCellContentView>
|
||||
</tableViewCell>
|
||||
<tableViewCell clipsSubviews="YES" contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="about" textLabel="YWX-qF-gPj" detailTextLabel="xr3-v1-hzM" style="IBUITableViewCellStyleValue1" id="Mon-vq-IrO">
|
||||
<rect key="frame" x="0.0" y="269.5" width="600" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Mon-vq-IrO" id="mGZ-Jb-6j4">
|
||||
<rect key="frame" x="0.0" y="0.0" width="600" height="43.5"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="YWX-qF-gPj">
|
||||
<rect key="frame" x="15" y="12" width="31.5" height="19.5"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="xcq-HY-ZDe">
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="xr3-v1-hzM">
|
||||
<rect key="frame" x="543.5" y="12" width="41.5" height="19.5"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" red="0.55686274509803924" green="0.55686274509803924" blue="0.57647058823529407" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<color key="textColor" red="0.5568627451" green="0.5568627451" blue="0.57647058819999997" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
@ -205,7 +229,7 @@
|
||||
<rect key="frame" x="15" y="12" width="31.5" height="19.5"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="16"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Detail" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" adjustsLetterSpacingToFitWidth="YES" id="CbL-Kq-e9s">
|
||||
|
@ -56,6 +56,10 @@ static dispatch_once_t onceToken;
|
||||
return WantInitSpeedValue;
|
||||
}
|
||||
|
||||
- (NSBundle *)bundle {
|
||||
return [NSBundle bundleForClass:self.class];
|
||||
}
|
||||
|
||||
- (NSInteger)speed {
|
||||
return SpeedValue;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
@property (nonatomic, assign) NSInteger speed;
|
||||
@property (nonatomic, weak) CALayer *screenLayer;
|
||||
|
||||
@property (nonatomic, readonly) NSBundle *bundle;
|
||||
@property (nonatomic, readonly) CGSize screenSize;
|
||||
@property (nonatomic, readonly) NSString *insertDiskNotification, *ejectDiskNotification;
|
||||
@property (nonatomic, readonly) NSInteger initialSpeed;
|
||||
|
@ -4,6 +4,8 @@
|
||||
<dict>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>Mac II</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>8M, 1024×768 @ 8-bit, no sound</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
@ -24,5 +26,7 @@
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>Emulator</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>MacII.png</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
BIN
Mini vMac/MacII/MacII.png
Normal file
BIN
Mini vMac/MacII/MacII.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 178 B |
BIN
Mini vMac/MacII/MacII@2x.png
Normal file
BIN
Mini vMac/MacII/MacII@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 204 B |
BIN
Mini vMac/MacII/MacII@3x.png
Normal file
BIN
Mini vMac/MacII/MacII@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 230 B |
@ -3,7 +3,9 @@
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>Mac Plus 4M</string>
|
||||
<string>Mac Plus</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>4M, 512×342</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
@ -24,5 +26,7 @@
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>Emulator</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>MacPlus.png</string>
|
||||
</dict>
|
||||
</plist>
|
||||
|
BIN
Mini vMac/MacPlus4M/MacPlus.png
Normal file
BIN
Mini vMac/MacPlus4M/MacPlus.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 203 B |
BIN
Mini vMac/MacPlus4M/MacPlus@2x.png
Normal file
BIN
Mini vMac/MacPlus4M/MacPlus@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 235 B |
BIN
Mini vMac/MacPlus4M/MacPlus@3x.png
Normal file
BIN
Mini vMac/MacPlus4M/MacPlus@3x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 265 B |
@ -13,9 +13,18 @@
|
||||
|
||||
@end
|
||||
|
||||
typedef enum : NSInteger {
|
||||
SettingsSectionSpeed,
|
||||
SettingsSectionMouse,
|
||||
SettingsSectionKeyboard,
|
||||
SettingsSectionMachine,
|
||||
SettingsSectionAbout
|
||||
} SettingsSection;
|
||||
|
||||
@implementation SettingsViewController
|
||||
{
|
||||
NSArray *keyboardLayouts;
|
||||
NSArray<NSBundle*> *emulatorBundles;
|
||||
NSString *aboutTitle;
|
||||
NSArray<NSDictionary<NSString*,NSString*>*> *aboutItems;
|
||||
UITextView *footerView;
|
||||
@ -24,6 +33,7 @@
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
keyboardLayouts = [[NSBundle mainBundle] pathsForResourcesOfType:@"nfkeyboardlayout" inDirectory:@"Keyboard Layouts"];
|
||||
emulatorBundles = [AppDelegate sharedInstance].emulatorBundles;
|
||||
[self loadCredits];
|
||||
}
|
||||
|
||||
@ -79,42 +89,59 @@
|
||||
#pragma mark - Table view data source
|
||||
|
||||
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
|
||||
return 4;
|
||||
return 5;
|
||||
}
|
||||
|
||||
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
|
||||
if (section == 2) {
|
||||
return keyboardLayouts.count;
|
||||
} else if (section == 3) {
|
||||
return aboutItems.count;
|
||||
} else {
|
||||
return 1;
|
||||
switch (section) {
|
||||
case SettingsSectionKeyboard:
|
||||
return keyboardLayouts.count;
|
||||
case SettingsSectionMachine:
|
||||
return emulatorBundles.count;
|
||||
case SettingsSectionAbout:
|
||||
return aboutItems.count;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
|
||||
switch (section) {
|
||||
case 0: return NSLocalizedString(@"Speed", nil);
|
||||
case 1: return NSLocalizedString(@"Mouse Type", nil);
|
||||
case 2: return NSLocalizedString(@"Keyboard Layout", nil);
|
||||
case 3: return aboutTitle;
|
||||
default: return nil;
|
||||
case SettingsSectionSpeed:
|
||||
return NSLocalizedString(@"Speed", nil);
|
||||
case SettingsSectionMouse:
|
||||
return NSLocalizedString(@"Mouse Type", nil);
|
||||
case SettingsSectionMachine:
|
||||
return NSLocalizedString(@"Emulated Machine", nil);
|
||||
case SettingsSectionKeyboard:
|
||||
return NSLocalizedString(@"Keyboard Layout", nil);
|
||||
case SettingsSectionAbout:
|
||||
return aboutTitle;
|
||||
default:return nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
|
||||
if (section == 3) {
|
||||
if (section == SettingsSectionAbout) {
|
||||
return footerView;
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section {
|
||||
if (section == SettingsSectionMachine) {
|
||||
return NSLocalizedString(@"Changing the emulated machine requires to relaunch Mini vMac", nil);
|
||||
} else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
|
||||
if (section == 3) {
|
||||
if (section == SettingsSectionAbout) {
|
||||
return footerView.bounds.size.height;
|
||||
} else {
|
||||
return 0.0;
|
||||
return UITableViewAutomaticDimension;
|
||||
}
|
||||
}
|
||||
|
||||
@ -122,21 +149,31 @@
|
||||
UITableViewCell *cell = nil;
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
NSInteger section = indexPath.section;
|
||||
if (section == 0) {
|
||||
if (section == SettingsSectionSpeed) {
|
||||
cell = [tableView dequeueReusableCellWithIdentifier:@"speed" forIndexPath:indexPath];
|
||||
UISegmentedControl *speedControl = (UISegmentedControl*)[cell viewWithTag:128];
|
||||
speedControl.selectedSegmentIndex = [defaults integerForKey:@"speedValue"];
|
||||
} else if (section == 1) {
|
||||
} else if (section == SettingsSectionMouse) {
|
||||
cell = [tableView dequeueReusableCellWithIdentifier:@"mouse" forIndexPath:indexPath];
|
||||
UISegmentedControl *mouseControl = (UISegmentedControl*)[cell viewWithTag:128];
|
||||
mouseControl.selectedSegmentIndex = [defaults boolForKey:@"trackpad"] ? 1 : 0;
|
||||
} else if (section == 2) {
|
||||
} else if (section == SettingsSectionKeyboard) {
|
||||
cell = [tableView dequeueReusableCellWithIdentifier:@"keyboard" forIndexPath:indexPath];
|
||||
NSString *layout = keyboardLayouts[indexPath.row];
|
||||
cell.textLabel.text = layout.lastPathComponent.stringByDeletingPathExtension;
|
||||
BOOL selected = [[defaults stringForKey:@"keyboardLayout"] isEqualToString:layout.lastPathComponent];
|
||||
cell.accessoryType = selected ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
|
||||
} else if (section == 3) {
|
||||
} else if (section == SettingsSectionMachine) {
|
||||
NSBundle *bundle = emulatorBundles[indexPath.row];
|
||||
NSString *bundleName = bundle.bundlePath.lastPathComponent.stringByDeletingPathExtension;
|
||||
cell = [tableView dequeueReusableCellWithIdentifier:@"machine" forIndexPath:indexPath];
|
||||
cell.textLabel.text = [bundle objectForInfoDictionaryKey:@"CFBundleDisplayName"];
|
||||
cell.detailTextLabel.text = [bundle objectForInfoDictionaryKey:@"CFBundleGetInfoString"];
|
||||
NSString *iconName = [bundle objectForInfoDictionaryKey:@"CFBundleIconFile"];
|
||||
cell.imageView.image = [UIImage imageNamed:iconName inBundle:bundle compatibleWithTraitCollection:nil];
|
||||
BOOL selected = [[defaults stringForKey:@"machine"] isEqualToString:bundleName];
|
||||
cell.accessoryType = selected ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone;
|
||||
} else if (section == SettingsSectionAbout) {
|
||||
cell = [tableView dequeueReusableCellWithIdentifier:@"about" forIndexPath:indexPath];
|
||||
NSDictionary<NSString*,NSString*> *item = aboutItems[indexPath.row];
|
||||
cell.textLabel.text = item[@"text"];
|
||||
@ -156,12 +193,18 @@
|
||||
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
[tableView deselectRowAtIndexPath:indexPath animated:YES];
|
||||
if (indexPath.section == 2) {
|
||||
if (indexPath.section == SettingsSectionKeyboard) {
|
||||
// selected keyboard layout
|
||||
NSString *layout = keyboardLayouts[indexPath.row];
|
||||
[defaults setValue:layout.lastPathComponent forKey:@"keyboardLayout"];
|
||||
[tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationAutomatic];
|
||||
} if (indexPath.section == 3) {
|
||||
} else if (indexPath.section == SettingsSectionMachine) {
|
||||
// selected emulated machine
|
||||
NSBundle *bundle = emulatorBundles[indexPath.row];
|
||||
NSString *bundleName = bundle.bundlePath.lastPathComponent.stringByDeletingPathExtension;
|
||||
[defaults setValue:bundleName forKey:@"machine"];
|
||||
[tableView reloadSections:[NSIndexSet indexSetWithIndex:indexPath.section] withRowAnimation:UITableViewRowAnimationAutomatic];
|
||||
} else if (indexPath.section == SettingsSectionAbout) {
|
||||
// links in about
|
||||
NSString *linkURL = aboutItems[indexPath.row][@"link"];
|
||||
if (linkURL != nil) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user