pencil pro widget template import changes

This commit is contained in:
True Zhuanjia
2026-02-18 13:01:08 +08:00
parent 38f8c50d7f
commit c7ffd51cec
3 changed files with 21 additions and 0 deletions
@@ -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
OSCProfile *defaultProfileDecoded;
NSMutableArray *targetProfilesDecoded = [self getAllProfiles];
OSCProfile *newPencilProProfile;
bool pencilProProfileExisted = false;
for (NSData *profileEncoded in defaultProfilesEncoded) {
defaultProfileDecoded = [NSKeyedUnarchiver unarchivedObjectOfClasses: classes fromData:profileEncoded error: nil];
OSCProfile *targetProfile = [self findProfileByName:defaultProfileDecoded.name inProfileArray:targetProfilesDecoded];
if([defaultProfileDecoded.name isEqualToString:@"Pencil Pro"]){
newPencilProProfile = [defaultProfileDecoded mutableCopy];
}
if(targetProfile){
if([targetProfile.name isEqualToString:@"Pencil Pro"]){
pencilProProfileExisted = true;
}
uint64_t targetIndex = [targetProfilesDecoded indexOfObject:targetProfile];
targetProfilesDecoded[targetIndex] = defaultProfileDecoded;
}
}
if(newPencilProProfile && !pencilProProfileExisted){
if(newPencilProProfile) [targetProfilesDecoded insertObject:newPencilProProfile atIndex:1];
}
NSMutableArray* targetPofilesEncoded = [self encodedProfilesFromArray:targetProfilesDecoded];
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:targetPofilesEncoded requiringSecureCoding:YES error:nil];
[[NSUserDefaults standardUserDefaults] setObject:data forKey:@"OSCProfiles"];
+1
View File
@@ -251,6 +251,7 @@ import StoreKit
settings?.onscreenControls = 1
dataMan.saveData()
let profileMan = OSCProfilesManager.sharedManager(.zero)
profileMan.updateDefaultTemplates()
let profiles = profileMan.getAllProfiles()
guard profiles.count > 1 else { break }
guard let targetProfile = profiles[1] as? OSCProfile else { break }
@@ -481,6 +481,10 @@ BOOL isCustomResolution(int resolutionSelected) {
selector:@selector(pencilProPurchaseAborted:)
name:@"PencilProPurchaseAbortedNotification"
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(pencilProPurchaseSucceeded:)
name:@"PencilProPurchaseSucceededNotification"
object:nil];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
if(self.mainFrameViewController.settingsExpandedInStreamView){
@@ -3446,6 +3450,10 @@ BOOL isCustomResolution(int resolutionSelected) {
});
}
- (void)pencilProPurchaseSucceeded:(NSNotification *)notification{
self.onScreenWidgetSelector.selectedSegmentIndex = OnScreenControlsLevelCustom;
}
- (void)pencilTickIntervalSliderMoved:(UISlider* )sender{
[self findDynamicLabelFromStack:self.pencilTickIntervalStack].text = [NSString stringWithFormat:@" %d μs ", (uint16_t)sender.value];
}