mirror of
https://github.com/zydeco/minivmac4ios.git
synced 2024-09-27 12:59:00 +00:00
only reset speed when saved speed is faster than default
this saves the preferences, but still prevents accidentally locking up the app by setting a fast speed on a low end device
This commit is contained in:
parent
fd665a1761
commit
dead799d16
@ -25,7 +25,7 @@ extern NSString *DocumentsChangedNotification;
|
||||
|
||||
+ (instancetype)sharedInstance;
|
||||
+ (id<Emulator>)sharedEmulator;
|
||||
- (void)reloadEmulator;
|
||||
- (void)loadAndStartEmulator;
|
||||
|
||||
- (void)showAlertWithTitle:(NSString *)title message:(NSString *)message;
|
||||
- (IBAction)showInsertDisk:(id)sender;
|
||||
|
@ -33,12 +33,9 @@ NSString *DocumentsChangedNotification = @"documentsChanged";
|
||||
|
||||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
|
||||
sharedAppDelegate = self;
|
||||
if (![self loadEmulator:[[NSUserDefaults standardUserDefaults] stringForKey:@"machine"]]) {
|
||||
[self loadEmulator:@"MacPlus4M"];
|
||||
}
|
||||
[self initDefaults];
|
||||
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryAmbient error:NULL];
|
||||
[sharedEmulator performSelector:@selector(run) withObject:nil afterDelay:0.1];
|
||||
[self loadAndStartEmulator];
|
||||
|
||||
if ([application respondsToSelector:@selector(btcMouseSetRawMode:)]) {
|
||||
[application btcMouseSetRawMode:YES];
|
||||
@ -69,7 +66,6 @@ NSString *DocumentsChangedNotification = @"documentsChanged";
|
||||
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
[defaults registerDefaults:defaultValues];
|
||||
[defaults setValue:@(sharedEmulator.initialSpeed) forKey:@"speedValue"];
|
||||
[defaults addObserver:self forKeyPath:@"speedValue" options:0 context:NULL];
|
||||
}
|
||||
|
||||
@ -108,17 +104,26 @@ NSString *DocumentsChangedNotification = @"documentsChanged";
|
||||
return sharedEmulator != nil;
|
||||
}
|
||||
|
||||
- (void)reloadEmulator {
|
||||
NSBundle *bundle = sharedEmulator.bundle;
|
||||
- (void)loadAndStartEmulator {
|
||||
[self willChangeValueForKey:@"sharedEmulator"];
|
||||
if (sharedEmulator) {
|
||||
NSBundle *bundle = sharedEmulator.bundle;
|
||||
id<Emulator> oldEmulator = sharedEmulator;
|
||||
sharedEmulator = nil;
|
||||
[oldEmulator shutdown];
|
||||
[bundle unload];
|
||||
}
|
||||
if (![self loadEmulator:[[NSUserDefaults standardUserDefaults] stringForKey:@"machine"]]) {
|
||||
[self loadEmulator:@"MacPlus4M"];
|
||||
}
|
||||
[self didChangeValueForKey:@"sharedEmulator"];
|
||||
|
||||
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
|
||||
if ([defaults integerForKey:@"speedValue"] > sharedEmulator.initialSpeed) {
|
||||
[defaults setValue:@(sharedEmulator.initialSpeed) forKey:@"speedValue"];
|
||||
} else {
|
||||
sharedEmulator.speed = [defaults integerForKey:@"speedValue"];
|
||||
}
|
||||
[sharedEmulator performSelector:@selector(run) withObject:nil afterDelay:0.1];
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ typedef enum : NSInteger {
|
||||
[super viewWillDisappear:animated];
|
||||
[AppDelegate sharedEmulator].running = YES;
|
||||
if (![selectedEmulatorBundle isEqual:[AppDelegate sharedEmulator].bundle] && ![AppDelegate sharedEmulator].anyDiskInserted) {
|
||||
[[AppDelegate sharedInstance] reloadEmulator];
|
||||
[[AppDelegate sharedInstance] loadAndStartEmulator];
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user