From f260d7537261ad114643dc44f65c27d8e89cab18 Mon Sep 17 00:00:00 2001 From: TrueZhuangjia Date: Thu, 3 Apr 2025 00:13:52 +0800 Subject: [PATCH] preset advanced widget template profile --- Limelight/Input/CustomOSC/OSCProfile.h | 1 + .../Input/CustomOSC/OSCProfilesManager.h | 5 +- .../Input/CustomOSC/OSCProfilesManager.m | 45 +++++++++++++++--- Limelight/PresetConfigs/widgetTemplates.bin | Bin 0 -> 71105 bytes .../LayoutOnScreenControlsViewController.m | 11 ++++- Moonlight.xcodeproj/project.pbxproj | 12 +++++ 6 files changed, 64 insertions(+), 10 deletions(-) create mode 100755 Limelight/PresetConfigs/widgetTemplates.bin diff --git a/Limelight/Input/CustomOSC/OSCProfile.h b/Limelight/Input/CustomOSC/OSCProfile.h index 1161b12f..a424a78f 100644 --- a/Limelight/Input/CustomOSC/OSCProfile.h +++ b/Limelight/Input/CustomOSC/OSCProfile.h @@ -10,6 +10,7 @@ #import "OnScreenButtonState.h" NS_ASSUME_NONNULL_BEGIN +#define DEFAULT_TEMPLATE_NAME @"高级控件模板(Advanced widget templates)" /** This object contains information pertaining to any of the user created, custom on screen controller layout configurations, or 'profiles.' The object contains a 'name' property for easy reference, as well as an 'isSelected' property which is used to determine whether this particular custom OSC layout should show on screen during game stream view. Only one 'OSCProfile' is set to 'isSelected' at any given time. The object also contains an array of 'OnScreenButtonStates' which provides information that allows us to move and hide/unhide each of the 19 on screen buttons. Note that the 'buttonStates' property should contain an NSMutableArray of ENCODED 'OnScreenButtonState' objects. This allows us to save the 'OSCProfile' object to NSUserDefaults. diff --git a/Limelight/Input/CustomOSC/OSCProfilesManager.h b/Limelight/Input/CustomOSC/OSCProfilesManager.h index 6448df13..f237ba7c 100644 --- a/Limelight/Input/CustomOSC/OSCProfilesManager.h +++ b/Limelight/Input/CustomOSC/OSCProfilesManager.h @@ -16,6 +16,7 @@ NS_ASSUME_NONNULL_BEGIN Note that the implementation file contains a number of 'Helper' methods. These helper methods are only used in this class's implementation file and help to reduce re-writing large blocks of code that are called multiple times throughout the file */ @interface OSCProfilesManager : NSObject +@property NSMutableArray *currentProfiles; + (OSCProfilesManager *) sharedManager:(CGRect)viewBounds; @@ -40,7 +41,7 @@ NS_ASSUME_NONNULL_BEGIN - (NSMutableArray *) getEncodedProfiles; - (void) importEncodedProfiles:(NSMutableArray* )profilesEncoded; - (OnScreenButtonState *)unarchiveButtonStateEncoded:(NSData *)data; - +- (void) importDefaultTemplates; #pragma mark - Setters /** @@ -64,7 +65,7 @@ NS_ASSUME_NONNULL_BEGIN * Lets the caller of this method know whether a profile with a given name already exists in persistent storage */ - (BOOL) profileNameAlreadyExist:(NSString*)name; - +- (BOOL) profileName:(NSString*) name alreadyExistIn:(NSMutableArray*)profiles; @end diff --git a/Limelight/Input/CustomOSC/OSCProfilesManager.m b/Limelight/Input/CustomOSC/OSCProfilesManager.m index 3c46c12d..d3282b18 100644 --- a/Limelight/Input/CustomOSC/OSCProfilesManager.m +++ b/Limelight/Input/CustomOSC/OSCProfilesManager.m @@ -27,6 +27,7 @@ static CGRect streamViewBounds; dispatch_once(&onceToken, ^{ _sharedManager = [[self alloc] init]; }); + // _sharedManager.currentProfiles = [_sharedManager getAllProfiles]; return _sharedManager; } @@ -137,14 +138,38 @@ static CGRect streamViewBounds; } - (void) importEncodedProfiles:(NSMutableArray* )profilesEncoded { - NSMutableArray* localEncodedPofiles = [self getEncodedProfiles]; - [localEncodedPofiles removeObjectAtIndex:0]; + NSMutableArray* targetProfiles = [_currentProfiles mutableCopy]; //_currentProfiles is availabled as long as getAllProfiles was called before calling this method (_currentProfiles avoids frequent accessing persisted data) + if([self profileName:DEFAULT_TEMPLATE_NAME alreadyExistIn:targetProfiles] && targetProfiles.count > 1) [targetProfiles removeObjectAtIndex:1]; + if(targetProfiles.count > 0) [targetProfiles removeObjectAtIndex:0]; + NSMutableArray* localEncodedPofiles = [self encodedProfilesFromArray:targetProfiles]; [profilesEncoded addObjectsFromArray:localEncodedPofiles]; NSData *data = [NSKeyedArchiver archivedDataWithRootObject:profilesEncoded requiringSecureCoding:YES error:nil]; [[NSUserDefaults standardUserDefaults] setObject:data forKey:@"OSCProfiles"]; [[NSUserDefaults standardUserDefaults] synchronize]; } +- (void) importDefaultTemplates{ + NSString *filePath = [[NSBundle mainBundle] pathForResource:@"widgetTemplates" ofType:@"bin"]; + if (filePath) { + // 2. 读取二进制数据 + NSError *error; + NSData *fileData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingMappedIfSafe error:&error]; + NSMutableArray *profilesEncoded; + if (fileData && !error) { + // 3. 成功读取 + NSSet *classes = [NSSet setWithObjects: [NSMutableData class], [NSMutableArray class], nil]; + if (@available(iOS 13.0, *)) { + // 在 iOS 13 及以上使用 unarchivedObjectOfClasses + profilesEncoded = [NSKeyedUnarchiver unarchivedObjectOfClasses:classes fromData:fileData error:&error]; + } else { + // 在 iOS 12 及以下使用 unarchiveObjectWithData(旧方法) + profilesEncoded = [NSKeyedUnarchiver unarchivedObjectOfClass:[NSMutableArray class] fromData:fileData error:&error]; + } + [self importEncodedProfiles:profilesEncoded]; + } + } +} + #pragma mark - Globally Accessible Methods @@ -165,6 +190,7 @@ static CGRect streamViewBounds; profileDecoded = [NSKeyedUnarchiver unarchivedObjectOfClasses: classes fromData:profileEncoded error: nil]; [profilesDecoded addObject: profileDecoded]; } + _currentProfiles = profilesDecoded; return profilesDecoded; } @@ -352,15 +378,22 @@ static CGRect streamViewBounds; - (BOOL) profileNameAlreadyExist:(NSString*)name { NSMutableArray *profiles = [self getAllProfiles]; - /* Iterate through the decoded profiles and return 'YES' if one of the profiles' 'name' properties equals the 'name' passed into this method */ for (OSCProfile *profile in profiles) { - if ([profile.name isEqualToString:name]) { return YES; } } - + return NO; +} + +- (BOOL) profileName:(NSString*) name alreadyExistIn:(NSMutableArray*)profiles { + /* Iterate through the decoded profiles and return 'YES' if one of the profiles' 'name' properties equals the 'name' passed into this method */ + for (OSCProfile *profile in profiles) { + if ([profile.name isEqualToString:name]) { + return YES; + } + } return NO; } @@ -373,7 +406,7 @@ static CGRect streamViewBounds; error:nil]; } else { // 在 iOS 12 及以下使用 unarchiveObjectWithData(旧方法) - buttonState = [NSKeyedUnarchiver unarchivedObjectOfClass: [OnScreenButtonState class] fromData:data error:nil]; + buttonState = [NSKeyedUnarchiver unarchivedObjectOfClass:[OnScreenButtonState class] fromData:data error:nil]; } return buttonState; } diff --git a/Limelight/PresetConfigs/widgetTemplates.bin b/Limelight/PresetConfigs/widgetTemplates.bin new file mode 100755 index 0000000000000000000000000000000000000000..2dd7e6e13b7b5f70c795518ad3044a65718beb68 GIT binary patch literal 71105 zcmYc)$jK}&F)+Bo$i&RT%ErzWp;DGwRGgWg7pan1l$?=SmRb~|Qj%W~p^~4Jm6}{q zEX2Urwjf@B-!IrZwK6ru5vu4S2WLo8ett;<<1%g@VR3n-P?fyWoSaL%eEdRDe!+TB z-C-)pIf=!^iv$E4m>O6bSTBk2iHe2$1?#0GmL&QMIvUczLF)w+xp_pzOe`Fn-8_B# zgF+*s;}TQSvvLcH%PMQ?n_4@%CqP_#g_n zB(Ws5I3zDIHx=p!jt1rirUr#@m(;Yx(wve@;sO%JNIqRJASEd!Eh8%@ub`-;tfH!> zuA!-=t)r`_Z(wNDz|z3hz}~>oz}djnz}>*pz}vvrz~3OyAlM+(Alx9*Ale|-Al@L+ zAlV?*Al)F-Alo3tJZkD1kl?s4zz+)$Q894|sCQ%=LV zlx0;^W#a|-lM<7&(~I&;^HLmh3NjL-%QI6-GTaiAOY)0A?DW)<;EcqA)QE!o;>?oF z{Jglb)SUd}%#uoonz-D|yx@||tFjI@;1%&T|Mj)5q`n`;H<{L!63*W#h}8V$za4_&fv-5!w|?2%n->C&(OdyiD4eYDu&Gr zhZrt0++ujo@Q0C!k(W`DQGrpF(T35H(T&lA(TmZWF@Q0MF@!OUF@iCHv6pcY<6OpN zjC&aOGhPMxoPmLf5kfQQLun|*c&~x=lBJck4K@$O`UU%zmLw+Sq`D-QBrdkKvqu#P z^9u$^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K8t0$|cs^@85*1W2DPsdlsUnfHE zgx)E=%ZBELmWEEo%Z*nWZ!+UB<1!Pr$h63|D6u+ab;jzdt+uVMt(kp~eV_ew$G48} z9e=p^xdgaGx~+HH=(fvKz*ERm+Pl!Z*t^E}lJ6DYy8*@lrU76UOP!NCFLinP-}L_(99eN$ z30avr`*RNFoXS_oSIXBeY%FXp>?wX!{G|A8nRA(InP0_{ie(k+t68hrs|9M)YBOpJ z>yOu;tiRNx(WKR6+|t?7-7=-^Rok1kubtkVzMWy+Yr5BUZ|@W76YGw03Fz(vIby zmw#RUZ#DmF!PQc0Ti3R)ov?vv1Iq^9O{X`V-E?hh+}4DxncM$t|F?sE*Qs4+c3s_@ zvNvsS{{FA~zaL;YlyfNWQ29~$ql!nhj&D7_{rG`XMyE_p*`8T(X4RR^=Y!6NoR2-9 zbH4a|)A_FRlh4mPzZja=m>@J`1%!r?=hrnbUy_hiRzb^Ai&fR+(1c)_jDdlHgMooT zkb!|gih+Sag@J(qw5|ZOo5h@gfx(l3fx(A?fgzBAfgzZIfgy^4fgyo`fgzQFfuVqb zfuWp%fuV|lfdRCRu#SO&p@D&cp_PGwp_hTd@el)p;}Hf1$CC^Uj#n5M9PctPIKF0J zaD30e;P{t;!HI=|!HJiF!AXdLQRE5(qsTP|Mv>bLj3TcX7)9POFpB(zc#DM*LNlmC KX$ZwA$_fBx5VYt3 literal 0 HcmV?d00001 diff --git a/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.m b/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.m index 875f6506..1b916842 100644 --- a/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.m +++ b/Limelight/ViewControllers/CustomOSCViewControl/LayoutOnScreenControlsViewController.m @@ -162,11 +162,18 @@ [self addInnerAnalogSticksToOuterAnalogLayers]; // allows inner and analog sticks to be dragged together around the screen together as one unit which is the expected behavior self.undoButton.alpha = 0.3; // no changes to undo yet, so fade out the undo button a bit - - if ([[profilesManager getAllProfiles] count] == 0) { // if no saved OSC profiles exist yet then create one called 'Default' and associate it with Moonlight's legacy 'Full' OSC layout that's already been laid out on the screen at this point + + NSMutableArray* allProfiles = [profilesManager getAllProfiles]; + /* + if ([allProfiles count] == 0) { // if no saved OSC profiles exist yet then create one called 'Default' and associate it with Moonlight's legacy 'Full' OSC layout that's already been laid out on the screen at this point [profilesManager saveProfileWithName:@"Default" andButtonLayers:self.layoutOSC.OSCButtonLayers]; + [profilesManager importDefaultTemplates]; + }*/ + if (![profilesManager profileName:DEFAULT_TEMPLATE_NAME alreadyExistIn:allProfiles]){ + [profilesManager importDefaultTemplates]; } + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(setControllerCALayerSliderValues:) name:@"LegacyOscCALayerSelectedNotification" diff --git a/Moonlight.xcodeproj/project.pbxproj b/Moonlight.xcodeproj/project.pbxproj index bb47652a..4c39f080 100644 --- a/Moonlight.xcodeproj/project.pbxproj +++ b/Moonlight.xcodeproj/project.pbxproj @@ -18,6 +18,7 @@ 84351B2D2C29AD6100A77989 /* ToolBarContainerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 84351B292C29AD6000A77989 /* ToolBarContainerView.m */; }; 84351B5C2C29ADBE00A77989 /* ProfileTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 84351B592C29ADBE00A77989 /* ProfileTableViewCell.m */; }; 84351B5D2C29ADBE00A77989 /* ProfileTableViewCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 84351B5B2C29ADBE00A77989 /* ProfileTableViewCell.xib */; }; + 843667F02D9D7173004A7D7F /* widgetTemplates.bin in Resources */ = {isa = PBXBuildFile; fileRef = 843667EF2D9D7173004A7D7F /* widgetTemplates.bin */; }; 843CC7F02C1E757D00BBC475 /* NativeTouchPointer.m in Sources */ = {isa = PBXBuildFile; fileRef = 843CC7EF2C1E757D00BBC475 /* NativeTouchPointer.m */; }; 843CC7F62C1E7A1700BBC475 /* NativeTouchHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 843CC7F52C1E7A1700BBC475 /* NativeTouchHandler.m */; }; 843E93BE2C41528700B1651F /* OrientationHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 843E93BD2C41528700B1651F /* OrientationHelper.swift */; }; @@ -145,6 +146,7 @@ 84351B592C29ADBE00A77989 /* ProfileTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ProfileTableViewCell.m; sourceTree = ""; }; 84351B5A2C29ADBE00A77989 /* ProfileTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ProfileTableViewCell.h; sourceTree = ""; }; 84351B5B2C29ADBE00A77989 /* ProfileTableViewCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ProfileTableViewCell.xib; sourceTree = ""; }; + 843667EF2D9D7173004A7D7F /* widgetTemplates.bin */ = {isa = PBXFileReference; lastKnownFileType = archive.macbinary; name = widgetTemplates.bin; path = Limelight/PresetConfigs/widgetTemplates.bin; sourceTree = SOURCE_ROOT; }; 843CC7EE2C1E757D00BBC475 /* NativeTouchPointer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeTouchPointer.h; sourceTree = ""; }; 843CC7EF2C1E757D00BBC475 /* NativeTouchPointer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NativeTouchPointer.m; sourceTree = ""; }; 843CC7F42C1E778000BBC475 /* NativeTouchHandler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NativeTouchHandler.h; sourceTree = ""; }; @@ -453,6 +455,14 @@ path = Cells; sourceTree = ""; }; + 843667ED2D9D70A3004A7D7F /* PresetConfigs */ = { + isa = PBXGroup; + children = ( + 843667EF2D9D7173004A7D7F /* widgetTemplates.bin */, + ); + name = PresetConfigs; + sourceTree = ""; + }; 84FD0B492C312C0B006B5BE5 /* Localization */ = { isa = PBXGroup; children = ( @@ -578,6 +588,7 @@ FB290CFA19B2C406004C83CF /* Supporting Files */ = { isa = PBXGroup; children = ( + 843667ED2D9D70A3004A7D7F /* PresetConfigs */, FB290CFB19B2C406004C83CF /* Limelight-Info.plist */, FB290CFC19B2C406004C83CF /* InfoPlist.strings */, FB290CFF19B2C406004C83CF /* main.m */, @@ -1000,6 +1011,7 @@ FB89463819F6473800339C8A /* Launch Screen.xib in Resources */, 8454AC662C31907F00F0A302 /* iPad.storyboard in Resources */, 8454AC6A2C319BDA00F0A302 /* iPhone.storyboard in Resources */, + 843667F02D9D7173004A7D7F /* widgetTemplates.bin in Resources */, 84FD0B542C3134A6006B5BE5 /* Localizable.xcstrings in Resources */, 84351B5D2C29ADBE00A77989 /* ProfileTableViewCell.xib in Resources */, );