diff --git a/Limelight/Images.xcassets/SquareAndArrowDown.imageset/square_and_arrow_down-120x120@3x.png b/Limelight/Images.xcassets/SquareAndArrowDown.imageset/square_and_arrow_down-120x120@3x.png old mode 100644 new mode 100755 index 75f85523..b39ab97d Binary files a/Limelight/Images.xcassets/SquareAndArrowDown.imageset/square_and_arrow_down-120x120@3x.png and b/Limelight/Images.xcassets/SquareAndArrowDown.imageset/square_and_arrow_down-120x120@3x.png differ diff --git a/Limelight/Images.xcassets/SquareAndArrowDown.imageset/square_and_arrow_down-80x80@2x.png b/Limelight/Images.xcassets/SquareAndArrowDown.imageset/square_and_arrow_down-80x80@2x.png old mode 100644 new mode 100755 index aa21d1b8..33c7a0da Binary files a/Limelight/Images.xcassets/SquareAndArrowDown.imageset/square_and_arrow_down-80x80@2x.png and b/Limelight/Images.xcassets/SquareAndArrowDown.imageset/square_and_arrow_down-80x80@2x.png differ diff --git a/Limelight/Images.xcassets/SquaresArrowUp.imageset/square_and_arrow_up_on_square-120x120@3x.png b/Limelight/Images.xcassets/SquaresArrowUp.imageset/square_and_arrow_up_on_square-120x120@3x.png old mode 100644 new mode 100755 index de7aa00c..e4ff09a7 Binary files a/Limelight/Images.xcassets/SquaresArrowUp.imageset/square_and_arrow_up_on_square-120x120@3x.png and b/Limelight/Images.xcassets/SquaresArrowUp.imageset/square_and_arrow_up_on_square-120x120@3x.png differ diff --git a/Limelight/Images.xcassets/SquaresArrowUp.imageset/square_and_arrow_up_on_square-80x80@2x.png b/Limelight/Images.xcassets/SquaresArrowUp.imageset/square_and_arrow_up_on_square-80x80@2x.png old mode 100644 new mode 100755 index 85e092db..c3269596 Binary files a/Limelight/Images.xcassets/SquaresArrowUp.imageset/square_and_arrow_up_on_square-80x80@2x.png and b/Limelight/Images.xcassets/SquaresArrowUp.imageset/square_and_arrow_up_on_square-80x80@2x.png differ diff --git a/Limelight/Input/CustomOSC/OSCProfilesManager.h b/Limelight/Input/CustomOSC/OSCProfilesManager.h index 6a2c83bd..0892c866 100644 --- a/Limelight/Input/CustomOSC/OSCProfilesManager.h +++ b/Limelight/Input/CustomOSC/OSCProfilesManager.h @@ -50,6 +50,11 @@ NS_ASSUME_NONNULL_BEGIN */ - (void) saveProfileWithName:(NSString*)name andButtonLayers:(NSMutableArray *)buttonLayers; +- (bool) updateSelectedProfileSucceedWithButtonLayers:(NSMutableArray *)buttonLayers; +/** + * Delete current selected profile. + */ +- (void) deleteCurrentSelectedProfile; #pragma mark - Queries /** diff --git a/Limelight/Input/CustomOSC/OSCProfilesManager.m b/Limelight/Input/CustomOSC/OSCProfilesManager.m index f24f619d..b30f8971 100644 --- a/Limelight/Input/CustomOSC/OSCProfilesManager.m +++ b/Limelight/Input/CustomOSC/OSCProfilesManager.m @@ -56,6 +56,35 @@ return profilesEncoded; } + +/** + * Delete an 'OSCProfile' object of specific index for another in the 'OSCProfile' objects array stored in persistent storage + */ +-(void)deleteCurrentSelectedProfile{ + NSMutableArray *profiles = [self getAllProfiles]; + NSInteger selectedIndex = [self getIndexOfSelectedProfile]; + + /* Remove the selected profile */ + if(selectedIndex != 0) [profiles removeObjectAtIndex:selectedIndex]; //deleting default profile (index 0) is not allowed + else { + NSLog(@"Default profile!"); // to be updated here. + } + + selectedIndex--; + if(selectedIndex < 0) selectedIndex = 0; + OSCProfile *newSelectedProfile = [profiles objectAtIndex:selectedIndex]; + newSelectedProfile.isSelected = YES; + + NSMutableArray *profilesEncoded = [self encodedProfilesFromArray:profiles]; // encode each 'profile' object in the array and add them to a new array + + /* Encode the array itself, NOT the objects in the array, which are already encoded. Save array to persistent storage */ + NSData *data = [NSKeyedArchiver archivedDataWithRootObject:profilesEncoded requiringSecureCoding:YES error:nil]; + [[NSUserDefaults standardUserDefaults] setObject:data forKey:@"OSCProfiles"]; + [[NSUserDefaults standardUserDefaults] synchronize]; + +} + + /** * Replaces one 'OSCProfile' object for another in the 'OSCProfile' objects array stored in persistent storage */ @@ -160,6 +189,32 @@ [[NSUserDefaults standardUserDefaults] synchronize]; } + +- (bool) updateSelectedProfileSucceedWithButtonLayers:(NSMutableArray *)buttonLayers { + /* iterate through each OSC button the user sees on screen, create an 'OnScreenButtonState' object from each button, encode each object, and then add each object to an array */ + NSMutableArray *buttonStatesEncoded = [[NSMutableArray alloc] init]; + for (CALayer *buttonLayer in buttonLayers) { + + OnScreenButtonState *buttonState = [[OnScreenButtonState alloc] initWithButtonName:buttonLayer.name isHidden:buttonLayer.isHidden andPosition:buttonLayer.position]; + NSData *buttonStateEncoded = [NSKeyedArchiver archivedDataWithRootObject:buttonState requiringSecureCoding:YES error:nil]; + [buttonStatesEncoded addObject: buttonStateEncoded]; + } + if([self getIndexOfSelectedProfile]==0) return false; + OSCProfile *newProfile = [[OSCProfile alloc] initWithName:[self getSelectedProfile].name + buttonStates:buttonStatesEncoded isSelected:YES]; // create a new 'OSCProfile'. Set the array of encoded button states created above to the 'buttonStates' property of the new profile, along with a 'name'. Set 'isSelected' argument to YES which will set this saved profile as the one that will show up in the game stream view + + + /* set all saved OSCProfiles 'isSelected' property to NO since the new profile you're adding will be set as the selected profile */ + NSMutableArray *profiles = [self getAllProfiles]; + for (OSCProfile *profile in profiles) { + profile.isSelected = NO; + } + [self replaceProfile:[self getSelectedProfile] withProfile:newProfile]; + return true; +} + + + - (void) saveProfileWithName:(NSString*)name andButtonLayers:(NSMutableArray *)buttonLayers { /* iterate through each OSC button the user sees on screen, create an 'OnScreenButtonState' object from each button, encode each object, and then add each object to an array */ NSMutableArray *buttonStatesEncoded = [[NSMutableArray alloc] init]; @@ -212,4 +267,8 @@ return NO; } + + + + @end diff --git a/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.h b/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.h index 63d0e402..d8cb4a3b 100644 --- a/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.h +++ b/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.h @@ -9,6 +9,8 @@ #import #import "LayoutOnScreenControls.h" #import "ToolBarContainerView.h" +#import "OSCProfilesManager.h" +#import "OSCProfilesTableViewController.h" NS_ASSUME_NONNULL_BEGIN @@ -16,7 +18,7 @@ NS_ASSUME_NONNULL_BEGIN This view controller provides the user interface which allows the user to position on screen controller buttons anywhere they'd like on the screen. It also provides the user with the abilities to undo a change, save the on screen controller layout for later retrieval, and load previously saved controller layouts */ @interface LayoutOnScreenControlsViewController : UIViewController - +- (void)profileRefresh; @property LayoutOnScreenControls *layoutOSC; // object that contains a view which contains the on screen controller buttons that allows the user to drag and positions each button on the screen using touch @property int OSCSegmentSelected; @@ -28,6 +30,8 @@ NS_ASSUME_NONNULL_BEGIN @property (weak, nonatomic) IBOutlet UIView *chevronView; @property (weak, nonatomic) IBOutlet UIImageView *chevronImageView; @property (weak, nonatomic) IBOutlet UIStackView *toolbarStackView; +@property (strong, nonatomic) OSCProfilesTableViewController *oscProfilesTableViewController; +@property (nonatomic, assign) NSString *currentProfileName; @end diff --git a/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.m b/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.m index f73003ab..b0d7555e 100644 --- a/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.m +++ b/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.m @@ -215,40 +215,22 @@ /* show pop up notification that lets users choose to save the current OSC layout configuration as a profile they can load when they want. User can also choose to cancel out of this pop up */ - (IBAction) saveTapped:(id)sender { - UIAlertController * inputNameAlertController = [UIAlertController alertControllerWithTitle: @"Enter the name you want to save this controller profile as" message: @"" preferredStyle:UIAlertControllerStyleAlert]; - [inputNameAlertController addTextFieldWithConfigurationHandler:^(UITextField *textField) { // pop up notification with text field where user can enter the text they wish to name their OSC layout profile - textField.placeholder = @"name"; - textField.textColor = [UIColor lightGrayColor]; - textField.clearButtonMode = UITextFieldViewModeWhileEditing; - textField.borderStyle = UITextBorderStyleNone; - }]; - [inputNameAlertController addAction:[UIAlertAction actionWithTitle:@"Save" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { // add save button to allow user to save the on screen controller configuration - NSArray *textFields = inputNameAlertController.textFields; - UITextField *nameField = textFields[0]; - NSString *enteredProfileName = nameField.text; - - if ([enteredProfileName isEqualToString:@"Default"]) { // don't let user user overwrite the 'Default' profile - UIAlertController *alertController = [UIAlertController alertControllerWithTitle: [NSString stringWithFormat:@""] message: [NSString stringWithFormat:@"Saving over the 'Default' profile is not allowed"] preferredStyle:UIAlertControllerStyleAlert]; - - [alertController addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { - [alertController dismissViewControllerAnimated:NO completion:^{ - [self presentViewController:inputNameAlertController animated:YES completion:nil]; - }]; - }]]; - [self presentViewController:alertController animated:YES completion:nil]; - } - else if ([enteredProfileName length] == 0) { // if user entered no text and taps the 'Save' button let them know they can't do that - UIAlertController * savedAlertController = [UIAlertController alertControllerWithTitle: [NSString stringWithFormat:@""] message: [NSString stringWithFormat:@"Profile name cannot be blank!"] preferredStyle:UIAlertControllerStyleAlert]; - - [savedAlertController addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { // show pop up notification letting user know they must enter a name in the text field if they wish to save the controller profile - - [savedAlertController dismissViewControllerAnimated:NO completion:^{ - [self presentViewController:inputNameAlertController animated:YES completion:nil]; - }]; - }]]; - [self presentViewController:savedAlertController animated:YES completion:nil]; - } - else if ([self->profilesManager profileNameAlreadyExist:enteredProfileName] == YES) { // if the entered profile name already exists then let the user know. Offer to allow them to overwrite the existing profile + + if([self->profilesManager updateSelectedProfileSucceedWithButtonLayers:self.layoutOSC.OSCButtonLayers]){ + UIAlertController * savedAlertController = [UIAlertController alertControllerWithTitle: [NSString stringWithFormat:@""] message: [NSString stringWithFormat:@"Current profile updated successfully"] preferredStyle:UIAlertControllerStyleAlert]; + [savedAlertController addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + }]]; + [self presentViewController:savedAlertController animated:YES completion:nil]; + } + else{ + UIAlertController * savedAlertController = [UIAlertController alertControllerWithTitle: [NSString stringWithFormat:@""] message: [NSString stringWithFormat:@"Profile Default can not be overwritten"] preferredStyle:UIAlertControllerStyleAlert]; + [savedAlertController addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + }]]; + [self presentViewController:savedAlertController animated:YES completion:nil]; + } + + /* + if ([self->profilesManager profileNameAlreadyExist:enteredProfileName] == YES) { // if the entered profile name already exists then let the user know. Offer to allow them to overwrite the existing profile UIAlertController * savedAlertController = [UIAlertController alertControllerWithTitle: [NSString stringWithFormat:@""] message: [NSString stringWithFormat:@"Another profile with the name '%@' already exists! Do you want to overwrite it?", enteredProfileName] preferredStyle:UIAlertControllerStyleAlert]; [savedAlertController addAction:[UIAlertAction actionWithTitle:@"Yes" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { // overwrite existing profile @@ -275,11 +257,12 @@ [inputNameAlertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { // adds a button that allows user to decline the option to save the controller layout they currently see on screen [inputNameAlertController dismissViewControllerAnimated:NO completion:nil]; }]]; - [self presentViewController:inputNameAlertController animated:YES completion:nil]; + [self presentViewController:inputNameAlertController animated:YES completion:nil]; */ } -/* Presents the view controller that lists all OSC profiles the user can choose from */ + +/* Basically the same method as loadTapped, without parameter*/ - (void)profileRefresh{ UIStoryboard *storyboard; BOOL isIPhone = ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone); @@ -300,8 +283,10 @@ [self.layoutOSC.layoutChanges removeAllObjects]; // since a new OSC profile is being loaded, this will remove all previous layout changes made from the array [self OSCLayoutChanged]; // fades the 'Undo Button' out + + _oscProfilesTableViewController.currentOSCButtonLayers = self.layoutOSC.OSCButtonLayers; //pass updated OSCLayout to OSCProfView again }; - [self presentViewController:vc animated:YES completion:nil]; + // [self presentViewController:vc animated:YES completion:nil]; } @@ -316,9 +301,9 @@ storyboard = [UIStoryboard storyboardWithName:@"iPad" bundle:nil]; } - OSCProfilesTableViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"OSCProfilesTableViewController"] ; + _oscProfilesTableViewController = [storyboard instantiateViewControllerWithIdentifier:@"OSCProfilesTableViewController"] ; - vc.didDismissOSCProfilesTVC = ^() { // a block that will be called when the modally presented 'OSCProfilesTableViewController' VC is dismissed. By the time the 'OSCProfilesTableViewController' VC is dismissed the user would have potentially selected a different OSC profile with a different layout and they want to see this layout on this 'LayoutOnScreenControlsViewController.' This block of code will load the profile and then hide/show and move each OSC button to their appropriate position + _oscProfilesTableViewController.didDismissOSCProfilesTVC = ^() { // a block that will be called when the modally presented 'OSCProfilesTableViewController' VC is dismissed. By the time the 'OSCProfilesTableViewController' VC is dismissed the user would have potentially selected a different OSC profile with a different layout and they want to see this layout on this 'LayoutOnScreenControlsViewController.' This block of code will load the profile and then hide/show and move each OSC button to their appropriate position [self.layoutOSC updateControls]; // creates and saves a 'Default' OSC profile or loads the one the user selected on the previous screen [self addInnerAnalogSticksToOuterAnalogLayers]; @@ -327,7 +312,8 @@ [self OSCLayoutChanged]; // fades the 'Undo Button' out }; - [self presentViewController:vc animated:YES completion:nil]; + _oscProfilesTableViewController.currentOSCButtonLayers = self.layoutOSC.OSCButtonLayers; + [self presentViewController:_oscProfilesTableViewController animated:YES completion:nil]; } diff --git a/Limelight/ViewControllers/CustomOSCViewControl/OSCProfilesTableViewController.h b/Limelight/ViewControllers/CustomOSCViewControl/OSCProfilesTableViewController.h index 448d0f87..f45ac68f 100644 --- a/Limelight/ViewControllers/CustomOSCViewControl/OSCProfilesTableViewController.h +++ b/Limelight/ViewControllers/CustomOSCViewControl/OSCProfilesTableViewController.h @@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN @property (weak, nonatomic) IBOutlet UITableView *tableView; @property (nonatomic, copy) void (^didDismissOSCProfilesTVC)(void); - +@property (nonatomic, assign) NSMutableArray *currentOSCButtonLayers; @end diff --git a/Limelight/ViewControllers/CustomOSCViewControl/OSCProfilesTableViewController.m b/Limelight/ViewControllers/CustomOSCViewControl/OSCProfilesTableViewController.m index 6d1c09a8..42a9a79a 100644 --- a/Limelight/ViewControllers/CustomOSCViewControl/OSCProfilesTableViewController.m +++ b/Limelight/ViewControllers/CustomOSCViewControl/OSCProfilesTableViewController.m @@ -21,15 +21,32 @@ const double NAV_BAR_HEIGHT = 50; @implementation OSCProfilesTableViewController { OSCProfilesManager *profilesManager; + LayoutOnScreenControlsViewController *parentLayoutOSCViewController; } @synthesize tableView; - (void) viewDidLoad { [super viewDidLoad]; - + + profilesManager = [OSCProfilesManager sharedManager]; + + self.tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, NAV_BAR_HEIGHT)]; + + self.tableView.delegate = self; + self.tableView.dataSource = self; + + [self.tableView registerNib:[UINib nibWithNibName:@"ProfileTableViewCell" bundle:nil] + forCellReuseIdentifier:@"Cell"]; // Register the custom cell nib file with the table view + self.tableView.alpha = 0.5; + + self.tableView.backgroundColor = [[UIColor colorWithRed:0.5 green:0.7 blue:1.0 alpha:1.0] colorWithAlphaComponent:0.5]; // set background color & transparency +} +- (void) viewDidAppear:(BOOL)animated { + [super viewDidAppear: animated]; + self.tableView.tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, NAV_BAR_HEIGHT)]; self.tableView.delegate = self; @@ -38,29 +55,96 @@ const double NAV_BAR_HEIGHT = 50; [self.tableView registerNib:[UINib nibWithNibName:@"ProfileTableViewCell" bundle:nil] forCellReuseIdentifier:@"Cell"]; // Register the custom cell nib file with the table view -} - -- (void) viewDidAppear:(BOOL)animated { - [super viewDidAppear: animated]; - if ([[profilesManager getAllProfiles] count] > 0) { // scroll to selected profile if user has any saved profiles NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[profilesManager getIndexOfSelectedProfile] inSection:0]; [self.tableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionMiddle animated:YES]; - } + } } #pragma mark - UIButton Actions /* Loads the OSC profile that user selected, dismisses this VC, then tells the presenting view controller to lay out the on screen buttons according to the selected profile's instructions */ -- (IBAction) loadTapped:(id)sender { - [self dismissViewControllerAnimated:YES completion:nil]; +- (IBAction) duplicateTapped:(id)sender { + UIAlertController * inputNameAlertController = [UIAlertController alertControllerWithTitle: @"Enter the name you want to save this controller profile as" message: @"" preferredStyle:UIAlertControllerStyleAlert]; + [inputNameAlertController addTextFieldWithConfigurationHandler:^(UITextField *textField) { // pop up notification with text field where user can enter the text they wish to name their OSC layout profile + textField.placeholder = @"name"; + textField.textColor = [UIColor lightGrayColor]; + textField.clearButtonMode = UITextFieldViewModeWhileEditing; + textField.borderStyle = UITextBorderStyleNone; + }]; + [inputNameAlertController addAction:[UIAlertAction actionWithTitle:@"Save" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { // add save button to allow user to save the on screen controller configuration + NSArray *textFields = inputNameAlertController.textFields; + UITextField *nameField = textFields[0]; + NSString *enteredProfileName = nameField.text; + + if ([enteredProfileName isEqualToString:@"Default"]) { // don't let user user overwrite the 'Default' profile + UIAlertController *alertController = [UIAlertController alertControllerWithTitle: [NSString stringWithFormat:@""] message: [NSString stringWithFormat:@"Saving over the 'Default' profile is not allowed"] preferredStyle:UIAlertControllerStyleAlert]; + + [alertController addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + [alertController dismissViewControllerAnimated:NO completion:^{ + [self presentViewController:inputNameAlertController animated:YES completion:nil]; + }]; + }]]; + [self presentViewController:alertController animated:YES completion:nil]; + } + else if ([enteredProfileName length] == 0) { // if user entered no text and taps the 'Save' button let them know they can't do that + UIAlertController * savedAlertController = [UIAlertController alertControllerWithTitle: [NSString stringWithFormat:@""] message: [NSString stringWithFormat:@"Profile name cannot be blank!"] preferredStyle:UIAlertControllerStyleAlert]; + + [savedAlertController addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { // show pop up notification letting user know they must enter a name in the text field if they wish to save the controller profile + + [savedAlertController dismissViewControllerAnimated:NO completion:^{ + [self presentViewController:inputNameAlertController animated:YES completion:nil]; + }]; + }]]; + [self presentViewController:savedAlertController animated:YES completion:nil]; + } + else if ([self->profilesManager profileNameAlreadyExist:enteredProfileName] == YES) { // if the entered profile name already + NSLog(@"tttttttttt"); + UIAlertController * savedAlertController = [UIAlertController alertControllerWithTitle: [NSString stringWithFormat:@""] message: [NSString stringWithFormat:@"Profile name already exists"] preferredStyle:UIAlertControllerStyleAlert]; + + [savedAlertController addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + //[savedAlertController dismissViewControllerAnimated:NO completion:nil]; + //[self profileViewRefresh]; //refresh profile view after saving new profile; + }]]; + [self presentViewController:savedAlertController animated:YES completion:nil]; + } + else { // if user entered a valid name that doesn't already exist then save the profile to persistent storage + [self->profilesManager saveProfileWithName: enteredProfileName andButtonLayers:self.currentOSCButtonLayers]; // the OSC layout here is passed from parent LayoutOSCViewController; + [self->profilesManager setProfileToSelected: enteredProfileName]; + + UIAlertController * savedAlertController = [UIAlertController alertControllerWithTitle: [NSString stringWithFormat:@""] message: [NSString stringWithFormat:@"Profile %@ duplicated from current layout", enteredProfileName] preferredStyle:UIAlertControllerStyleAlert]; // Let user know this profile has been duplicated & saved + + [savedAlertController addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { + [savedAlertController dismissViewControllerAnimated:NO completion:nil]; + [self profileViewRefresh]; //refresh profile view after saving new profile; + }]]; + [self presentViewController:savedAlertController animated:YES completion:nil]; + } + }]]; + [inputNameAlertController addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { // adds a button that allows user to decline the option to save the controller layout they currently see on screen + [inputNameAlertController dismissViewControllerAnimated:NO completion:nil]; + }]]; + [self presentViewController:inputNameAlertController animated:YES completion:nil]; +} + +/* basically the same with loadTapped */ +- (void) profileViewRefresh{ + //[self dismissViewControllerAnimated:YES completion:nil]; + //[selfparentLayoutOSCViewController] + [self.tableView reloadData]; // table view will be refreshed by calling reloadData if (self.didDismissOSCProfilesTVC) { // tells the presenting view controller to lay out the on screen buttons according to the selected profile's instructions self.didDismissOSCProfilesTVC(); } } +- (IBAction) deleteTapped:(id)sender{ + [profilesManager deleteCurrentSelectedProfile]; + [self profileViewRefresh]; +} + + - (IBAction) cancelTapped:(id)sender { [self dismissViewControllerAnimated:YES completion:nil]; } @@ -76,6 +160,7 @@ const double NAV_BAR_HEIGHT = 50; ProfileTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath]; OSCProfile *profile = [[profilesManager getAllProfiles] objectAtIndex: indexPath.row]; cell.name.text = profile.name; + cell.backgroundColor = [[UIColor clearColor] colorWithAlphaComponent:0.99]; if ([profile.name isEqualToString: [profilesManager getSelectedProfile].name]) { // if this cell contains the name of the currently selected OSC profile then add a checkmark to the right side of the cell cell.accessoryType = UITableViewCellAccessoryCheckmark; @@ -152,6 +237,7 @@ const double NAV_BAR_HEIGHT = 50; lastSelectedCell.accessoryType = UITableViewCellAccessoryNone; [tableView deselectRowAtIndexPath:lastSelectedIndexPath animated:YES]; } + [self profileViewRefresh]; // update OSC layout when table view option is changed } diff --git a/Limelight/ViewControllers/SettingsViewController.m b/Limelight/ViewControllers/SettingsViewController.m index 8fd2ad6c..82492c63 100644 --- a/Limelight/ViewControllers/SettingsViewController.m +++ b/Limelight/ViewControllers/SettingsViewController.m @@ -288,10 +288,10 @@ BOOL isCustomResolution(CGSize res) { [self updateBitrateText]; [self updateResolutionDisplayViewText]; - + //init keyboardToggle settings if(currentSettings.touchMode.intValue == RELATIVE_TOUCH_MODE){ [self.keyboardToggleFingerNumSlider setEnabled:[self.touchModeSelector selectedSegmentIndex] != RELATIVE_TOUCH_MODE]; - [self.keyboardToggleFingerNumSlider setValue:3.0]; + [self.keyboardToggleFingerNumSlider setValue:3.0]; //force 3 finger tap to toggle keyboard in relative touch mode. This is for the 4 finger OSC layout tool gesture. [self.keyboardToggleFingerNumLabel setText:[NSString stringWithFormat:@"To Toggle Local Keyboard: Tap %d Fingers", (uint16_t)self.keyboardToggleFingerNumSlider.value]]; } else{ @@ -301,34 +301,38 @@ BOOL isCustomResolution(CGSize res) { } [self.keyboardToggleFingerNumSlider addTarget:self action:@selector(keyboardToggleFingerNumSliderMoved) forControlEvents:(UIControlEventValueChanged)]; // Update label display when slider is being moved. - + // lift streamview setting [self.liftStreamViewForKeyboardSelector setSelectedSegmentIndex:currentSettings.liftStreamViewForKeyboard ? 1 : 0];// Load old setting + + // showkeyboard toolbar setting [self.showKeyboardToolbarSelector setSelectedSegmentIndex:currentSettings.showKeyboardToolbar ? 1 : 0];// Load old setting + + // swipe & exit setting [self.swipeExitScreenEdgeSelector setSelectedSegmentIndex:[self getSelectorIndexFromScreenEdge:(uint32_t)currentSettings.swipeExitScreenEdge.integerValue]]; // Load old setting [self.swipeToExitDistanceSlider setValue:(CGFloat)currentSettings.swipeToExitDistance.floatValue animated:YES]; // Load old setting. [self.swipeToExitDistanceUILabel setText:[NSString stringWithFormat:@"Swipe & Exit Distance: %.2f * screen-width", self.swipeToExitDistanceSlider.value]]; // Initiate label display [self.swipeToExitDistanceSlider addTarget:self action:@selector(swipeToExitDistanceSliderMoved) forControlEvents:(UIControlEventValueChanged)]; // Update label display when slider is being moved. - + // pointer veloc setting [self.pointerVelocityModeDividerSlider setValue:currentSettings.pointerVelocityModeDivider.floatValue * 100 animated:YES]; // Load old setting. [self.pointerVelocityModeDividerUILabel setText:[NSString stringWithFormat:@"Touch Pointer Velocity: Scaled on %d%% of Right Screen", 100 - (uint8_t)self.pointerVelocityModeDividerSlider.value]]; // Initiate label display [self.pointerVelocityModeDividerSlider addTarget:self action:@selector(pointerVelocityModeDividerSliderMoved) forControlEvents:(UIControlEventValueChanged)]; // Update label display when slider is being moved. [self.pointerVelocityModeDividerSlider setEnabled: currentSettings.touchMode.intValue == NATIVE_TOUCH_MODE]; // pointer velocity scaling works only in native touch mode. - + // init pointer veloc setting [self.touchPointerVelocityFactorSlider setValue:currentSettings.touchPointerVelocityFactor.floatValue * 100 animated:YES]; // Load old setting. [self.touchPointerVelocityFactorUILabel setText:[NSString stringWithFormat:@"Touch Pointer Velocity: %d%%", (uint16_t)self.touchPointerVelocityFactorSlider.value]]; // Initiate label display [self.touchPointerVelocityFactorSlider addTarget:self action:@selector(touchPointerVelocityFactorSliderMoved) forControlEvents:(UIControlEventValueChanged)]; // Update label display when slider is being moved. [self.touchPointerVelocityFactorSlider setEnabled: currentSettings.touchMode.intValue == NATIVE_TOUCH_MODE]; // pointer velocity scaling works only in native touch mode. - + // init relative touch mouse pointer veloc setting [self.mousePointerVelocityFactorSlider setValue:currentSettings.mousePointerVelocityFactor.floatValue * 100 animated:YES]; // Load old setting. [self.mousePointerVelocityFactorUILabel setText:[NSString stringWithFormat:@"Mouse Pointer Velocity: %d%%", (uint16_t)self.mousePointerVelocityFactorSlider.value]]; // Initiate label display [self.mousePointerVelocityFactorSlider addTarget:self action:@selector(mousePointerVelocityFactorSliderMoved) forControlEvents:(UIControlEventValueChanged)]; // Update label display when slider is being moved. [self.mousePointerVelocityFactorSlider setEnabled: currentSettings.touchMode.intValue == RELATIVE_TOUCH_MODE]; // mouse velocity scaling works only in relative touch mode. - //CustomOSC stuff + // init CustomOSC stuff [self.onscreenControlSelector addTarget:self action:@selector(onscreenControlChanged) forControlEvents:UIControlEventValueChanged]; /* sets a reference to the correct 'LayoutOnScreenControlsViewController' depending on whether the user is on an iPhone or iPad */ self.layoutOnScreenControlsVC = [[LayoutOnScreenControlsViewController alloc] init]; @@ -342,8 +346,8 @@ BOOL isCustomResolution(CGSize res) { self.layoutOnScreenControlsVC = [storyboard instantiateViewControllerWithIdentifier:@"LayoutOnScreenControlsViewController"]; self.layoutOnScreenControlsVC.modalPresentationStyle = UIModalPresentationFullScreen; } - if(currentSettings.onscreenControls.intValue == OnScreenControlsCustom && currentSettings.touchMode.intValue == RELATIVE_TOUCH_MODE) { - [self.onscreenControllerLabel setText:@"Tap 4 Fingers to Change OSC Layout in Stream View"]; + if(currentSettings.onscreenControls.intValue == OnScreenControlsCustom && currentSettings.touchMode.intValue == RELATIVE_TOUCH_MODE) { //load OSC slider UI Lable to remind user: + [self.onscreenControllerLabel setText:@"Tap 4 Fingers to Change OSC Layout in Stream View"]; //keyboard is force set to 3 finger to make this working. //if (self.layoutOnScreenControlsVC.isBeingPresented == NO) } else{ diff --git a/Limelight/iPad.storyboard b/Limelight/iPad.storyboard index 5de6a4a8..df26fe4d 100644 --- a/Limelight/iPad.storyboard +++ b/Limelight/iPad.storyboard @@ -682,10 +682,10 @@ ICAgICAgICAgICAgICA - + @@ -732,7 +732,7 @@ ICAgICAgICAgICAgIA - + @@ -741,17 +741,24 @@ ICAgICAgICAgICAgIA - + - - - - - + + + + + + + + + + + + @@ -786,10 +793,7 @@ ICAgICAgICAgICAgIA - - - - +