pencil pro widget template import changes
This commit is contained in:
1 parent
38f8c50d7f
commit
c7ffd51cec
3 files changed
+21
No files matched your search
@@ -222,14 +222,26 @@ static CGRect layoutViewBounds;
|
|||||||
NSMutableArray *defaultProfilesEncoded = [NSKeyedUnarchiver unarchivedObjectOfClasses:classes fromData:fileData error:nil]; // Decode the encoded array itself, NOT the objects contained in the array
|
NSMutableArray *defaultProfilesEncoded = [NSKeyedUnarchiver unarchivedObjectOfClasses:classes fromData:fileData error:nil]; // Decode the encoded array itself, NOT the objects contained in the array
|
||||||
OSCProfile *defaultProfileDecoded;
|
OSCProfile *defaultProfileDecoded;
|
||||||
NSMutableArray *targetProfilesDecoded = [self getAllProfiles];
|
NSMutableArray *targetProfilesDecoded = [self getAllProfiles];
|
||||||
|
OSCProfile *newPencilProProfile;
|
||||||
|
bool pencilProProfileExisted = false;
|
||||||
for (NSData *profileEncoded in defaultProfilesEncoded) {
|
for (NSData *profileEncoded in defaultProfilesEncoded) {
|
||||||
defaultProfileDecoded = [NSKeyedUnarchiver unarchivedObjectOfClasses: classes fromData:profileEncoded error: nil];
|
defaultProfileDecoded = [NSKeyedUnarchiver unarchivedObjectOfClasses: classes fromData:profileEncoded error: nil];
|
||||||
OSCProfile *targetProfile = [self findProfileByName:defaultProfileDecoded.name inProfileArray:targetProfilesDecoded];
|
OSCProfile *targetProfile = [self findProfileByName:defaultProfileDecoded.name inProfileArray:targetProfilesDecoded];
|
||||||
|
if([defaultProfileDecoded.name isEqualToString:@"Pencil Pro"]){
|
||||||
|
newPencilProProfile = [defaultProfileDecoded mutableCopy];
|
||||||
|
}
|
||||||
if(targetProfile){
|
if(targetProfile){
|
||||||
|
if([targetProfile.name isEqualToString:@"Pencil Pro"]){
|
||||||
|
pencilProProfileExisted = true;
|
||||||
|
}
|
||||||
uint64_t targetIndex = [targetProfilesDecoded indexOfObject:targetProfile];
|
uint64_t targetIndex = [targetProfilesDecoded indexOfObject:targetProfile];
|
||||||
targetProfilesDecoded[targetIndex] = defaultProfileDecoded;
|
targetProfilesDecoded[targetIndex] = defaultProfileDecoded;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(newPencilProProfile && !pencilProProfileExisted){
|
||||||
|
if(newPencilProProfile) [targetProfilesDecoded insertObject:newPencilProProfile atIndex:1];
|
||||||
|
}
|
||||||
|
|
||||||
NSMutableArray* targetPofilesEncoded = [self encodedProfilesFromArray:targetProfilesDecoded];
|
NSMutableArray* targetPofilesEncoded = [self encodedProfilesFromArray:targetProfilesDecoded];
|
||||||
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:targetPofilesEncoded requiringSecureCoding:YES error:nil];
|
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:targetPofilesEncoded requiringSecureCoding:YES error:nil];
|
||||||
[[NSUserDefaults standardUserDefaults] setObject:data forKey:@"OSCProfiles"];
|
[[NSUserDefaults standardUserDefaults] setObject:data forKey:@"OSCProfiles"];
|
||||||
|
|||||||
@@ -251,6 +251,7 @@ import StoreKit
|
|||||||
settings?.onscreenControls = 1
|
settings?.onscreenControls = 1
|
||||||
dataMan.saveData()
|
dataMan.saveData()
|
||||||
let profileMan = OSCProfilesManager.sharedManager(.zero)
|
let profileMan = OSCProfilesManager.sharedManager(.zero)
|
||||||
|
profileMan.updateDefaultTemplates()
|
||||||
let profiles = profileMan.getAllProfiles()
|
let profiles = profileMan.getAllProfiles()
|
||||||
guard profiles.count > 1 else { break }
|
guard profiles.count > 1 else { break }
|
||||||
guard let targetProfile = profiles[1] as? OSCProfile else { break }
|
guard let targetProfile = profiles[1] as? OSCProfile else { break }
|
||||||
|
|||||||
@@ -481,6 +481,10 @@ BOOL isCustomResolution(int resolutionSelected) {
|
|||||||
selector:@selector(pencilProPurchaseAborted:)
|
selector:@selector(pencilProPurchaseAborted:)
|
||||||
name:@"PencilProPurchaseAbortedNotification"
|
name:@"PencilProPurchaseAbortedNotification"
|
||||||
object:nil];
|
object:nil];
|
||||||
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
|
selector:@selector(pencilProPurchaseSucceeded:)
|
||||||
|
name:@"PencilProPurchaseSucceededNotification"
|
||||||
|
object:nil];
|
||||||
|
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
|
||||||
if(self.mainFrameViewController.settingsExpandedInStreamView){
|
if(self.mainFrameViewController.settingsExpandedInStreamView){
|
||||||
@@ -3446,6 +3450,10 @@ BOOL isCustomResolution(int resolutionSelected) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)pencilProPurchaseSucceeded:(NSNotification *)notification{
|
||||||
|
self.onScreenWidgetSelector.selectedSegmentIndex = OnScreenControlsLevelCustom;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)pencilTickIntervalSliderMoved:(UISlider* )sender{
|
- (void)pencilTickIntervalSliderMoved:(UISlider* )sender{
|
||||||
[self findDynamicLabelFromStack:self.pencilTickIntervalStack].text = [NSString stringWithFormat:@" %d μs ", (uint16_t)sender.value];
|
[self findDynamicLabelFromStack:self.pencilTickIntervalStack].text = [NSString stringWithFormat:@" %d μs ", (uint16_t)sender.value];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user