prevent default layout from being changed, fix fake layout change bug
This commit is contained in:
1 parent
a156962259
commit
93f1a2b4fb
3 files changed
+21
-2
No files matched your search
@@ -230,6 +230,7 @@
|
|||||||
else{
|
else{
|
||||||
UIAlertController * savedAlertController = [UIAlertController alertControllerWithTitle: [NSString stringWithFormat:@""] message: [NSString stringWithFormat:@"Profile Default can not be overwritten"] preferredStyle:UIAlertControllerStyleAlert];
|
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) {
|
[savedAlertController addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
||||||
|
[self.oscProfilesTableViewController profileViewRefresh]; // execute this will reset layout in OSC tool!
|
||||||
}]];
|
}]];
|
||||||
[self presentViewController:savedAlertController animated:YES completion:nil];
|
[self presentViewController:savedAlertController animated:YES completion:nil];
|
||||||
}
|
}
|
||||||
@@ -268,6 +269,7 @@
|
|||||||
|
|
||||||
|
|
||||||
/* Basically the same method as loadTapped, without parameter*/
|
/* Basically the same method as loadTapped, without parameter*/
|
||||||
|
// Make sure whenever self view controller load the selected profile and layout its buttons.
|
||||||
- (void)profileRefresh{
|
- (void)profileRefresh{
|
||||||
UIStoryboard *storyboard;
|
UIStoryboard *storyboard;
|
||||||
BOOL isIPhone = ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone);
|
BOOL isIPhone = ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone);
|
||||||
@@ -286,8 +288,10 @@
|
|||||||
self.currentProfileLabel.hidden = NO; // Show Current Profile display
|
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.
|
[self.currentProfileLabel setText:[NSString stringWithFormat:@"Current Profile: %@",[profilesManager getSelectedProfile].name]]; // display current profile name when profile is being refreshed.
|
||||||
|
|
||||||
|
//initialiaze _oscProfilesTableViewController
|
||||||
_oscProfilesTableViewController = [storyboard instantiateViewControllerWithIdentifier:@"OSCProfilesTableViewController"];
|
_oscProfilesTableViewController = [storyboard instantiateViewControllerWithIdentifier:@"OSCProfilesTableViewController"];
|
||||||
|
|
||||||
|
//this part is just for registration, will not be immediately executed.
|
||||||
_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
|
_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.layoutOSC updateControls]; // creates and saves a 'Default' OSC profile or loads the one the user selected on the previous screen
|
||||||
[self addInnerAnalogSticksToOuterAnalogLayers];
|
[self addInnerAnalogSticksToOuterAnalogLayers];
|
||||||
@@ -295,6 +299,9 @@
|
|||||||
[self OSCLayoutChanged]; // fades the 'Undo Button' out
|
[self OSCLayoutChanged]; // fades the 'Undo Button' out
|
||||||
_oscProfilesTableViewController.currentOSCButtonLayers = self.layoutOSC.OSCButtonLayers; //pass updated OSCLayout to OSCProfileTableView again
|
_oscProfilesTableViewController.currentOSCButtonLayers = self.layoutOSC.OSCButtonLayers; //pass updated OSCLayout to OSCProfileTableView again
|
||||||
};
|
};
|
||||||
|
|
||||||
|
[self.oscProfilesTableViewController profileViewRefresh]; // execute this will make sure OSCLayout is updated from persisted profile, not any cache.
|
||||||
|
|
||||||
// [self presentViewController:vc animated:YES completion:nil];
|
// [self presentViewController:vc animated:YES completion:nil];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -383,6 +390,15 @@
|
|||||||
trashCanButton.tintColor = [UIColor colorWithRed:171.0/255.0 green:157.0/255.0 blue:255.0/255.0 alpha:1];
|
trashCanButton.tintColor = [UIColor colorWithRed:171.0/255.0 green:157.0/255.0 blue:255.0/255.0 alpha:1];
|
||||||
}
|
}
|
||||||
[self.layoutOSC touchesEnded:touches withEvent:event];
|
[self.layoutOSC touchesEnded:touches withEvent:event];
|
||||||
|
|
||||||
|
// in case of default profile OSC change, popup msgbox & remind user it's not allowed.
|
||||||
|
if([profilesManager getIndexOfSelectedProfile] == 0 && [self.layoutOSC.layoutChanges count] > 0){
|
||||||
|
UIAlertController * movedAlertController = [UIAlertController alertControllerWithTitle: [NSString stringWithFormat:@""] message: [NSString stringWithFormat:@"Layout of the Default profile can not be changed"] preferredStyle:UIAlertControllerStyleAlert];
|
||||||
|
[movedAlertController addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
|
||||||
|
[self.oscProfilesTableViewController profileViewRefresh];
|
||||||
|
}]];
|
||||||
|
[self presentViewController:movedAlertController animated:YES completion:nil];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
@@ -15,6 +15,9 @@ NS_ASSUME_NONNULL_BEGIN
|
|||||||
*/
|
*/
|
||||||
@interface OSCProfilesTableViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
|
@interface OSCProfilesTableViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
|
||||||
|
|
||||||
|
- (void)profileViewRefresh;
|
||||||
|
|
||||||
|
|
||||||
@property (weak, nonatomic) IBOutlet UITableView *tableView;
|
@property (weak, nonatomic) IBOutlet UITableView *tableView;
|
||||||
@property (nonatomic, copy) void (^didDismissOSCProfilesTVC)(void);
|
@property (nonatomic, copy) void (^didDismissOSCProfilesTVC)(void);
|
||||||
@property (nonatomic, assign) NSMutableArray *currentOSCButtonLayers;
|
@property (nonatomic, assign) NSMutableArray *currentOSCButtonLayers;
|
||||||
|
|||||||
@@ -670,8 +670,8 @@ ICAgICAgICAgICAgICA
|
|||||||
<constraint firstItem="iVZ-Fd-dY7" firstAttribute="top" secondItem="hKp-ds-86I" secondAttribute="top" id="rRw-UW-drh"/>
|
<constraint firstItem="iVZ-Fd-dY7" firstAttribute="top" secondItem="hKp-ds-86I" secondAttribute="top" id="rRw-UW-drh"/>
|
||||||
</constraints>
|
</constraints>
|
||||||
</view>
|
</view>
|
||||||
<button opaque="NO" contentMode="scaleToFill" ambiguous="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="7bp-Wn-j9n" userLabel="Exit">
|
<button opaque="NO" contentMode="scaleToFill" ambiguous="YES" contentHorizontalAlignment="right" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="7bp-Wn-j9n" userLabel="Exit">
|
||||||
<rect key="frame" x="15" y="0.0" width="80" height="50"/>
|
<rect key="frame" x="15" y="0.0" width="100" height="50"/>
|
||||||
<constraints>
|
<constraints>
|
||||||
<constraint firstAttribute="width" constant="50" id="qtH-gP-Fjj"/>
|
<constraint firstAttribute="width" constant="50" id="qtH-gP-Fjj"/>
|
||||||
<constraint firstAttribute="height" constant="50" id="tqU-Lh-NQA"/>
|
<constraint firstAttribute="height" constant="50" id="tqU-Lh-NQA"/>
|
||||||
|
|||||||
Reference in new issue
Block a user