From a156962259ff581f43c39adce4e14cf91bd62673 Mon Sep 17 00:00:00 2001 From: True Zhuanjia Date: Fri, 28 Jun 2024 19:32:15 +0800 Subject: [PATCH] current profile UILabel --- .../LayoutOnScreenControlsViewController.h | 1 + .../LayoutOnScreenControlsViewController.m | 24 +++++++++++++------ .../OSCProfilesTableViewController.m | 9 +++++-- Limelight/iPad.storyboard | 12 +++++++++- Limelight/iPhone.storyboard | 9 +++++++ 5 files changed, 45 insertions(+), 10 deletions(-) diff --git a/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.h b/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.h index d8cb4a3b..bc7c451d 100644 --- a/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.h +++ b/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.h @@ -32,6 +32,7 @@ NS_ASSUME_NONNULL_BEGIN @property (weak, nonatomic) IBOutlet UIStackView *toolbarStackView; @property (strong, nonatomic) OSCProfilesTableViewController *oscProfilesTableViewController; @property (nonatomic, assign) NSString *currentProfileName; +@property (strong, nonatomic) IBOutlet UILabel *currentProfileLabel; @end diff --git a/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.m b/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.m index b0d7555e..e0a48d17 100644 --- a/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.m +++ b/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.m @@ -74,6 +74,11 @@ [profilesManager saveProfileWithName:@"Default" andButtonLayers:self.layoutOSC.OSCButtonLayers]; } + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(profileRefresh) + name:@"OscLayoutTableViewCloseNotification" + object:nil]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(OSCLayoutChanged) name:@"OSCLayoutChanged" object:nil]; // used to notifiy this view controller that the user made a change to the OSC layout so that the VC can either fade in or out its 'Undo button' which will signify to the user whether there are any OSC layout changes to undo /* This will animate the toolbar with a subtle up and down motion intended to telegraph to the user that they can hide the toolbar if they wish*/ @@ -273,18 +278,22 @@ storyboard = [UIStoryboard storyboardWithName:@"iPad" bundle:nil]; } - OSCProfilesTableViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"OSCProfilesTableViewController"] ; + // Center the current profile lable horizontally:; + // Calculate the x-position + CGFloat xPosition = (self.view.bounds.size.width - self.currentProfileLabel.frame.size.width) / 2; + // Set the label's frame with the calculated x-position + self.currentProfileLabel.frame = CGRectMake(xPosition, self.currentProfileLabel.frame.origin.y, self.currentProfileLabel.frame.size.width, self.currentProfileLabel.frame.size.height); + self.currentProfileLabel.hidden = NO; // Show Current Profile display + [self.currentProfileLabel setText:[NSString stringWithFormat:@"Current Profile: %@",[profilesManager getSelectedProfile].name]]; // display current profile name when profile is being refreshed. + + _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]; - [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 + _oscProfilesTableViewController.currentOSCButtonLayers = self.layoutOSC.OSCButtonLayers; //pass updated OSCLayout to OSCProfileTableView again }; // [self presentViewController:vc animated:YES completion:nil]; } @@ -312,6 +321,7 @@ [self OSCLayoutChanged]; // fades the 'Undo Button' out }; + self.currentProfileLabel.hidden = YES; // Hide Current Profile display before entering the profile table view _oscProfilesTableViewController.currentOSCButtonLayers = self.layoutOSC.OSCButtonLayers; [self presentViewController:_oscProfilesTableViewController animated:YES completion:nil]; } diff --git a/Limelight/ViewControllers/CustomOSCViewControl/OSCProfilesTableViewController.m b/Limelight/ViewControllers/CustomOSCViewControl/OSCProfilesTableViewController.m index 42a9a79a..dca63e2a 100644 --- a/Limelight/ViewControllers/CustomOSCViewControl/OSCProfilesTableViewController.m +++ b/Limelight/ViewControllers/CustomOSCViewControl/OSCProfilesTableViewController.m @@ -26,6 +26,12 @@ const double NAV_BAR_HEIGHT = 50; @synthesize tableView; +- (void) viewWillDisappear:(BOOL)animated{ + [super viewWillDisappear:animated]; + [[NSNotificationCenter defaultCenter] postNotificationName:@"OscLayoutTableViewCloseNotification" object:self]; // notify other view that oscLayoutManager is closing +} + + - (void) viewDidLoad { [super viewDidLoad]; @@ -101,7 +107,6 @@ const double NAV_BAR_HEIGHT = 50; [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) { @@ -139,7 +144,7 @@ const double NAV_BAR_HEIGHT = 50; } } -- (IBAction) deleteTapped:(id)sender{ +- (IBAction) deleteTapped:(id)sender{// delete can be executed simply by calling this 2 methods. [profilesManager deleteCurrentSelectedProfile]; [self profileViewRefresh]; } diff --git a/Limelight/iPad.storyboard b/Limelight/iPad.storyboard index c02cac41..7876146b 100644 --- a/Limelight/iPad.storyboard +++ b/Limelight/iPad.storyboard @@ -695,6 +695,15 @@ ICAgICAgICAgICAgICA + @@ -706,6 +715,7 @@ ICAgICAgICAgICAgICA + @@ -715,7 +725,7 @@ ICAgICAgICAgICAgICA - + diff --git a/Limelight/iPhone.storyboard b/Limelight/iPhone.storyboard index 26bb6078..ceb93f2f 100644 --- a/Limelight/iPhone.storyboard +++ b/Limelight/iPhone.storyboard @@ -693,6 +693,14 @@ ICAgICAgICAgICAgIA + @@ -706,6 +714,7 @@ ICAgICAgICAgICAgIA +