show "tap to restart" when emulated machine shuts down

This commit is contained in:
Jesús A. Álvarez 2016-07-02 15:18:26 +02:00
parent 8ad866b0dc
commit be06c815f4
4 changed files with 37 additions and 3 deletions

View File

@ -23,7 +23,7 @@
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
</view>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstItem="70W-4V-tYr" firstAttribute="bottom" secondItem="wfy-db-euE" secondAttribute="top" id="Xn1-gS-YTJ"/>
<constraint firstItem="70W-4V-tYr" firstAttribute="leading" secondItem="8bC-Xf-vdC" secondAttribute="leading" id="ddo-cc-64n"/>

View File

@ -32,7 +32,7 @@ typedef enum : NSInteger {
@property (nonatomic, readonly) NSBundle *bundle;
@property (nonatomic, readonly) CGSize screenSize;
@property (nonatomic, readonly) NSString *insertDiskNotification, *ejectDiskNotification;
@property (nonatomic, readonly) NSString *insertDiskNotification, *ejectDiskNotification, *shutdownNotification;
@property (nonatomic, readonly) NSInteger initialSpeed;
@property (nonatomic, readonly) BOOL anyDiskInserted;

View File

@ -705,6 +705,7 @@ LOCALFUNC blnr LoadMacRom(void) {
}
SpeedStopped = trueblnr;
return falseblnr;
}
return trueblnr; /* keep launching Mini vMac, regardless */
@ -1750,7 +1751,7 @@ static dispatch_once_t onceToken;
UnInitOSGLU();
if (ForceMacOff) {
ForceMacOff = falseblnr;
[self performSelector:_cmd withObject:nil afterDelay:0.5];
[[NSNotificationCenter defaultCenter] postNotificationName:self.shutdownNotification object:self];
}
}
@ -1825,6 +1826,10 @@ static dispatch_once_t onceToken;
}
}
- (NSString *)shutdownNotification {
return @"didShutDown";
}
#pragma mark - Screen
@synthesize screenLayer;

View File

@ -36,6 +36,8 @@
showSettingsGesture.direction = UISwipeGestureRecognizerDirectionRight;
showSettingsGesture.numberOfTouchesRequired = 2;
[self.view addGestureRecognizer:showSettingsGesture];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(emulatorDidShutDown:) name:[AppDelegate sharedEmulator].shutdownNotification object:nil];
}
- (BOOL)prefersStatusBarHidden {
@ -96,6 +98,33 @@
}
}
- (void)emulatorDidShutDown:(NSNotification*)notification {
UILabel *shutdownLabel = [[UILabel alloc] initWithFrame:self.view.bounds];
shutdownLabel.text = NSLocalizedString(@"the emulated Mac has shut down\ntap to restart", nil);
shutdownLabel.textColor = [UIColor whiteColor];
[self.view addSubview:shutdownLabel];
shutdownLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[shutdownLabel addGestureRecognizer:[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(restartEmulator:)]];
shutdownLabel.numberOfLines = -1;
shutdownLabel.textAlignment = NSTextAlignmentCenter;
shutdownLabel.userInteractionEnabled = YES;
[UIView animateWithDuration:0.5 animations:^{
self.screenView.alpha = 0.5;
}];
[self hideKeyboard:notification];
}
- (void)restartEmulator:(UITapGestureRecognizer*)gestureRecognizer {
if (gestureRecognizer.state == UIGestureRecognizerStateRecognized) {
[UIView animateWithDuration:0.5 animations:^{
self.screenView.alpha = 1.0;
}];
[gestureRecognizer.view removeFromSuperview];
id emulator = [AppDelegate sharedEmulator];
[emulator performSelector:@selector(run) withObject:nil afterDelay:0.1];
}
}
#pragma mark - Keyboard
- (void)installKeyboardGestures {