tweak storyboard
This commit is contained in:
1 parent
cc285d5488
commit
27bb8fd737
13 files changed
+194
-33
No files matched your search
@@ -37,7 +37,9 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
- (NSInteger) getIndexOfSelectedProfile;
|
||||
|
||||
|
||||
- (NSMutableArray *) getEncodedProfiles;
|
||||
- (void) importEncodedProfiles:(NSMutableArray* )profilesEncoded;
|
||||
- (OnScreenButtonState *)unarchiveButtonStateEncoded:(NSData *)data;
|
||||
|
||||
|
||||
#pragma mark - Setters
|
||||
|
||||
@@ -130,6 +130,21 @@ static CGRect streamViewBounds;
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
}
|
||||
|
||||
- (NSMutableArray *) getEncodedProfiles {
|
||||
NSMutableArray *profiles = [self getAllProfiles];
|
||||
NSMutableArray *profilesEncoded = [self encodedProfilesFromArray:profiles]; // encode each 'profile' object in the array and add them to a new array
|
||||
return profilesEncoded;
|
||||
}
|
||||
|
||||
- (void) importEncodedProfiles:(NSMutableArray* )profilesEncoded {
|
||||
NSMutableArray* localEncodedPofiles = [self getEncodedProfiles];
|
||||
[localEncodedPofiles removeObjectAtIndex:0];
|
||||
[profilesEncoded addObjectsFromArray:localEncodedPofiles];
|
||||
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:profilesEncoded requiringSecureCoding:YES error:nil];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:data forKey:@"OSCProfiles"];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark - Globally Accessible Methods
|
||||
|
||||
@@ -349,8 +364,18 @@ static CGRect streamViewBounds;
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
- (OnScreenButtonState *)unarchiveButtonStateEncoded:(NSData *)data {
|
||||
OnScreenButtonState* buttonState;
|
||||
if (@available(iOS 13.0, *)) {
|
||||
// 在 iOS 13 及以上使用 unarchivedObjectOfClasses
|
||||
buttonState = [NSKeyedUnarchiver unarchivedObjectOfClasses:[NSSet setWithObjects:[NSString class], [OnScreenButtonState class], nil]
|
||||
fromData:data
|
||||
error:nil];
|
||||
} else {
|
||||
// 在 iOS 12 及以下使用 unarchiveObjectWithData(旧方法)
|
||||
buttonState = [NSKeyedUnarchiver unarchivedObjectOfClass: [OnScreenButtonState class] fromData:data error:nil];
|
||||
}
|
||||
return buttonState;
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -369,7 +369,7 @@ static float L3_Y;
|
||||
[_activeCustomOscButtonPositionDict removeAllObjects]; //reset the Dict.
|
||||
NSLog(@"_activeCustomOscButtonPositionDict update: STARTOVER");
|
||||
for (NSData *buttonStateEncoded in oscProfile.buttonStates) {
|
||||
OnScreenButtonState *buttonState = [NSKeyedUnarchiver unarchivedObjectOfClass:[OnScreenButtonState class] fromData:buttonStateEncoded error:nil];
|
||||
OnScreenButtonState* buttonState = [profilesManager unarchiveButtonStateEncoded:buttonStateEncoded];
|
||||
buttonState.position = [self denormalizeWidgetPosition:buttonState.position];
|
||||
if(!buttonState.isHidden && [validPositionButtonNames containsObject:buttonState.name] && (buttonState.buttonType == LegacyOscButton || [profilesManager getIndexOfSelectedProfile] == 0 ) ){
|
||||
[_activeCustomOscButtonPositionDict setObject:[NSValue valueWithCGPoint:buttonState.position] forKey:buttonState.name]; // we got a buttonname -> position dict here
|
||||
@@ -725,8 +725,7 @@ static float L3_Y;
|
||||
OSCProfile *oscProfile = [profilesManager getSelectedProfile]; //returns the currently selected OSCProfile
|
||||
|
||||
for (NSData *buttonStateEncoded in oscProfile.buttonStates) {
|
||||
OnScreenButtonState *buttonState = [NSKeyedUnarchiver unarchivedObjectOfClass:[OnScreenButtonState class] fromData:buttonStateEncoded error:nil];
|
||||
|
||||
OnScreenButtonState* buttonState = [profilesManager unarchiveButtonStateEncoded:buttonStateEncoded];
|
||||
if ([buttonState.name isEqualToString:@"dPad"]) {
|
||||
buttonState.position = [self denormalizeWidgetPosition:buttonState.position];
|
||||
D_PAD_CENTER_X = buttonState.position.x;
|
||||
@@ -742,7 +741,7 @@ static float L3_Y;
|
||||
OSCProfile *oscProfile = [profilesManager getSelectedProfile]; // returns the currently selected OSCProfile
|
||||
|
||||
for (NSData *buttonStateEncoded in oscProfile.buttonStates) {
|
||||
OnScreenButtonState *buttonState = [NSKeyedUnarchiver unarchivedObjectOfClass:[OnScreenButtonState class] fromData:buttonStateEncoded error:nil];
|
||||
OnScreenButtonState* buttonState = [profilesManager unarchiveButtonStateEncoded:buttonStateEncoded];
|
||||
buttonState.position = [self denormalizeWidgetPosition:buttonState.position];
|
||||
if ([buttonState.name isEqualToString:@"leftStickBackground"]) {
|
||||
LS_CENTER_X = buttonState.position.x;
|
||||
@@ -767,8 +766,9 @@ static float L3_Y;
|
||||
|
||||
for (NSData *buttonStateEncoded in oscProfile.buttonStates) {
|
||||
|
||||
OnScreenButtonState *buttonStateDecoded = [NSKeyedUnarchiver unarchivedObjectOfClass:[OnScreenButtonState class] fromData:buttonStateEncoded error:nil];
|
||||
|
||||
OnScreenButtonState *buttonStateDecoded = [profilesManager unarchiveButtonStateEncoded:buttonStateEncoded];
|
||||
|
||||
|
||||
for (CALayer *buttonLayer in self.OSCButtonLayers) { // iterate through each button layer on screen and position and hide/unhide each according to the instructions of its associated 'buttonState'
|
||||
if ([buttonLayer.name isEqualToString:buttonStateDecoded.name]) {
|
||||
if ([buttonLayer.name isEqualToString:@"upButton"] == NO &&
|
||||
@@ -827,7 +827,8 @@ static float L3_Y;
|
||||
bool defaultProfileSelected = [profilesManager getIndexOfSelectedProfile] == 0;
|
||||
|
||||
for (NSData *buttonStateEncoded in oscProfile.buttonStates) {
|
||||
OnScreenButtonState *buttonStateDecoded = [NSKeyedUnarchiver unarchivedObjectOfClass:[OnScreenButtonState class] fromData:buttonStateEncoded error:nil];
|
||||
OnScreenButtonState* buttonStateDecoded = [profilesManager unarchiveButtonStateEncoded:buttonStateEncoded];
|
||||
|
||||
for (CALayer *buttonLayer in self.OSCButtonLayers) { // iterate through each button layer on screen
|
||||
// Here we deal with resizing single layer controllers only
|
||||
if ([buttonLayer.name isEqualToString:buttonStateDecoded.name]) {
|
||||
|
||||
@@ -400,7 +400,7 @@ static const double X1_MOUSE_SPEED_DIVISOR = 2.5;
|
||||
|
||||
if(!OnScreenWidgetView.editMode){ // in edit mode, keyboard widget view will be updated within layoutool view controller.
|
||||
for (NSData *buttonStateEncoded in oscProfile.buttonStates) {
|
||||
OnScreenButtonState* buttonState = [NSKeyedUnarchiver unarchivedObjectOfClass:[OnScreenButtonState class] fromData:buttonStateEncoded error:nil];
|
||||
OnScreenButtonState* buttonState = [profilesManager unarchiveButtonStateEncoded:buttonStateEncoded];
|
||||
if(buttonState.buttonType == CustomOnScreenWidget){
|
||||
OnScreenWidgetView* widgetView = [[OnScreenWidgetView alloc] initWithCmdString:buttonState.name buttonLabel:buttonState.alias shape:buttonState.widgetShape]; //reconstruct widgetView
|
||||
//--------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user