From b2c2f0837a2a71e65a2ccdfbb7421f6f9b0a491b Mon Sep 17 00:00:00 2001 From: Andrew Scagnelli Date: Thu, 14 Feb 2019 00:03:09 -0500 Subject: [PATCH] more appletv tweaks (#351) * redo now playing indicator - instead of drawing an arrow overlay, add an offset green shadow * do not show "Connection Terminated" on code 0 if an application quits successfully because it was asked to do so by the user (errorCode = 0), then do not display an alert -- just go back to the prior view. * fix: add missing toggle for mutli-controller support --- Limelight/Database/TemporarySettings.m | 7 +++++-- Limelight/UIAppView.m | 16 ++++++++++++---- .../ViewControllers/StreamFrameViewController.m | 13 ++++++++----- Moonlight TV/Settings.bundle/Root.plist | 10 ++++++++++ 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/Limelight/Database/TemporarySettings.m b/Limelight/Database/TemporarySettings.m index 4ed3f92..d1c35f6 100644 --- a/Limelight/Database/TemporarySettings.m +++ b/Limelight/Database/TemporarySettings.m @@ -7,6 +7,7 @@ // #import "TemporarySettings.h" +#import "OnScreenControls.h" @implementation TemporarySettings @@ -35,7 +36,8 @@ self.playAudioOnPC = [[NSUserDefaults standardUserDefaults] boolForKey:@"audioOnPC"] || NO; self.enableHdr = [[NSUserDefaults standardUserDefaults] boolForKey:@"enableHdr"] || NO; self.optimizeGames = [[NSUserDefaults standardUserDefaults] boolForKey:@"optimizeGames"] || YES; - self.multiController = YES; + self.multiController = [[NSUserDefaults standardUserDefaults] boolForKey:@"multipleControllers"] || YES; + NSInteger _screenSize = [[NSUserDefaults standardUserDefaults] integerForKey:@"streamResolution"]; switch (_screenSize) { case 0: @@ -52,6 +54,7 @@ self.width = [NSNumber numberWithInteger:1920]; break; } + self.onscreenControls = (NSInteger)OnScreenControlsLevelOff; #else self.bitrate = settings.bitrate; self.framerate = settings.framerate; @@ -62,8 +65,8 @@ self.enableHdr = settings.enableHdr; self.optimizeGames = settings.optimizeGames; self.multiController = settings.multiController; -#endif self.onscreenControls = settings.onscreenControls; +#endif self.uniqueId = settings.uniqueId; self.streamingRemotely = settings.streamingRemotely; diff --git a/Limelight/UIAppView.m b/Limelight/UIAppView.m index f08af8e..5bcb3eb 100644 --- a/Limelight/UIAppView.m +++ b/Limelight/UIAppView.m @@ -76,19 +76,24 @@ static UIImage* noImage; self.frame = CGRectMake(0, 0, noImage.size.width, noImage.size.height); if ([_app.id isEqualToString:_app.host.currentGame]) { +#if TARGET_OS_TV + _appButton.layer.masksToBounds = NO; + + _appButton.layer.shadowColor = [UIColor greenColor].CGColor; + _appButton.layer.shadowOffset = CGSizeMake(5,8); + _appButton.layer.shadowOpacity = 0.7; +#else // Only create the app overlay if needed _appOverlay = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Play"]]; -#if !TARGET_OS_TV _appOverlay.layer.shadowColor = [UIColor blackColor].CGColor; _appOverlay.layer.shadowOffset = CGSizeMake(0, 0); _appOverlay.layer.shadowOpacity = 1; _appOverlay.layer.shadowRadius = 2.0; -#endif - [self addSubview:_appOverlay]; _appOverlay.frame = CGRectMake(0, 0, noImage.size.width / 2.f, noImage.size.height / 4.f); [_appOverlay setCenter:CGPointMake(self.frame.size.width/2, self.frame.size.height/6)]; +#endif } BOOL noAppImage = false; @@ -120,10 +125,11 @@ static UIImage* noImage; #else _appButton.frame = CGRectMake(0, 0, appImage.size.width / 2, appImage.size.height / 2); self.frame = CGRectMake(0, 0, appImage.size.width / 2, appImage.size.height / 2); -#endif + _appOverlay.frame = CGRectMake(0, 0, self.frame.size.width / 2.f, self.frame.size.height / 4.f); _appOverlay.layer.shadowRadius = 4.0; [_appOverlay setCenter:CGPointMake(self.frame.size.width/2, self.frame.size.height/6)]; +#endif [_appButton setBackgroundImage:appImage forState:UIControlStateNormal]; [self setNeedsDisplay]; } else { @@ -176,7 +182,9 @@ static UIImage* noImage; // Update the app image if neccessary if ((_appOverlay != nil && ![_app.id isEqualToString:_app.host.currentGame]) || (_appOverlay == nil && [_app.id isEqualToString:_app.host.currentGame])) { +#if !TARGET_OS_TV [self updateAppImage]; +#endif } // Stop updating when we detach from our parent view diff --git a/Limelight/ViewControllers/StreamFrameViewController.m b/Limelight/ViewControllers/StreamFrameViewController.m index 24ee97f..8f03929 100644 --- a/Limelight/ViewControllers/StreamFrameViewController.m +++ b/Limelight/ViewControllers/StreamFrameViewController.m @@ -191,12 +191,15 @@ dispatch_async(dispatch_get_main_queue(), ^{ // Allow the display to go to sleep now [UIApplication sharedApplication].idleTimerDisabled = NO; - - UIAlertController* conTermAlert = [UIAlertController alertControllerWithTitle:@"Connection Terminated" message:@"The connection was terminated" preferredStyle:UIAlertControllerStyleAlert]; - [conTermAlert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){ + if (errorCode == 0) { [self returnToMainFrame]; - }]]; - [self presentViewController:conTermAlert animated:YES completion:nil]; + } else { + UIAlertController* conTermAlert = [UIAlertController alertControllerWithTitle:@"Connection Terminated" message:@"The connection was terminated" preferredStyle:UIAlertControllerStyleAlert]; + [conTermAlert addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction* action){ + [self returnToMainFrame]; + }]]; + [self presentViewController:conTermAlert animated:YES completion:nil]; + } }); [_streamMan stopStream]; diff --git a/Moonlight TV/Settings.bundle/Root.plist b/Moonlight TV/Settings.bundle/Root.plist index 1ca6b0d..5a32012 100644 --- a/Moonlight TV/Settings.bundle/Root.plist +++ b/Moonlight TV/Settings.bundle/Root.plist @@ -56,6 +56,16 @@ DefaultValue + + Type + PSToggleSwitchSpecifier + Title + Enable multi-controller support + Key + multipleControllers + DefaultValue + + Type PSGroupSpecifier