load default favorite setting stacks if persisted data is not available

This commit is contained in:
TrueZhuanjia
2025-07-25 11:21:51 +08:00
parent 323613e4db
commit 2b0fb3844b
2 changed files with 39 additions and 3 deletions
@@ -40,7 +40,7 @@
<attribute name="localMousePointerMode" optional="YES" attributeType="Integer 16" defaultValueString="0" usesScalarValueType="NO" syncable="YES"/>
<attribute name="mousePointerVelocityFactor" optional="YES" attributeType="Float" defaultValueString="1" usesScalarValueType="NO" syncable="YES"/>
<attribute name="multiController" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES" syncable="YES"/>
<attribute name="onscreenControls" attributeType="Integer 32" defaultValueString="1" usesScalarValueType="NO" syncable="YES"/>
<attribute name="onscreenControls" attributeType="Integer 32" defaultValueString="0" usesScalarValueType="NO" syncable="YES"/>
<attribute name="optimizeGames" attributeType="Boolean" defaultValueString="YES" usesScalarValueType="YES" syncable="YES"/>
<attribute name="oscLayoutToolFingers" optional="YES" attributeType="Integer 16" defaultValueString="4" usesScalarValueType="NO" syncable="YES"/>
<attribute name="playAudioOnPC" attributeType="Boolean" defaultValueString="NO" usesScalarValueType="YES" syncable="YES"/>
@@ -389,7 +389,7 @@ BOOL isCustomResolution(CGSize res) {
_parentStack.translatesAutoresizingMaskIntoConstraints = NO;
[self.scrollView addSubview:_parentStack];
[NSLayoutConstraint activateConstraints:@[
[_parentStack.topAnchor constraintEqualToAnchor:self.scrollView.contentLayoutGuide.topAnchor constant: currentSettingsMenuMode == AllSettings ? [self getStandardNavBarHeight] : [self getStandardNavBarHeight]+20],
[_parentStack.topAnchor constraintEqualToAnchor:self.scrollView.contentLayoutGuide.topAnchor constant: currentSettingsMenuMode == AllSettings ? [self getStandardNavBarHeight] : [self getStandardNavBarHeight]+10],
[_parentStack.bottomAnchor constraintEqualToAnchor:self.scrollView.contentLayoutGuide.bottomAnchor constant:-20],
[_parentStack.centerXAnchor constraintEqualToAnchor:self.view.centerXAnchor constant: 0], //mark: settingMenuLayout
[_parentStack.widthAnchor constraintEqualToAnchor:self.view.widthAnchor constant:-20] // section width adjusted here //mark: settingMenuLayout
@@ -1166,6 +1166,20 @@ BOOL isCustomResolution(CGSize res) {
}
}
/*
- (BOOL)isFirstLaunch {
NSString *key = @"appHasLaunchedBefore";
BOOL launchedBefore = [[NSUserDefaults standardUserDefaults] boolForKey:key];
if (!launchedBefore) {
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:key];
[[NSUserDefaults standardUserDefaults] synchronize]; // iOS 12+ 可省略
return YES;
}
return NO;
}
*/
- (void)saveFavoriteSettingStackIdentifiers {
if(currentSettingsMenuMode != AllSettings){
@@ -1175,18 +1189,40 @@ BOOL isCustomResolution(CGSize res) {
[_favoriteSettingStackIdentifiers addObject:_parentStack.arrangedSubviews[i].accessibilityIdentifier];
}
}
[[NSUserDefaults standardUserDefaults] setObject:_favoriteSettingStackIdentifiers forKey:@"FavoriteSettingStackIdentifiers"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
- (void)loadFavoriteSettingStackIdentifiers {
NSArray *savedArray = [[NSUserDefaults standardUserDefaults] objectForKey:@"FavoriteSettingStackIdentifiers"];
if ([savedArray isKindOfClass:[NSArray class]]) {
_favoriteSettingStackIdentifiers = [savedArray mutableCopy];
} else {
_favoriteSettingStackIdentifiers = [NSMutableArray array];
[_favoriteSettingStackIdentifiers addObject:@"resolutionStack"];
[_favoriteSettingStackIdentifiers addObject:@"fpsStack"];
[_favoriteSettingStackIdentifiers addObject:@"bitrateStack"];
[_favoriteSettingStackIdentifiers addObject:@"framepacingStack"];
[_favoriteSettingStackIdentifiers addObject:@"codecStack"];
[_favoriteSettingStackIdentifiers addObject:@"hdrStack"];
[_favoriteSettingStackIdentifiers addObject:@"yuv444Stack"];
[_favoriteSettingStackIdentifiers addObject:@"pipStack"];
[_favoriteSettingStackIdentifiers addObject:@"touchModeStack"];
[_favoriteSettingStackIdentifiers addObject:@"pointerVelocityDividerStack"];
[_favoriteSettingStackIdentifiers addObject:@"pointerVelocityFactorStack"];
[_favoriteSettingStackIdentifiers addObject:@"mousePointerVelocityStack"];
[_favoriteSettingStackIdentifiers addObject:@"onScreenWidgetStack"];
[_favoriteSettingStackIdentifiers addObject:@"pipStack"];
[_favoriteSettingStackIdentifiers addObject:@"backgroundSessionTimerStack"];
[_favoriteSettingStackIdentifiers addObject:@"statsOverlayStack"];
[_favoriteSettingStackIdentifiers addObject:@"softKeyboardGestureStack"];
[_favoriteSettingStackIdentifiers addObject:@"slideToSettingsScreenEdgeStack"];
[_favoriteSettingStackIdentifiers addObject:@"slideToToolboxScreenEdgeStack"];
[_favoriteSettingStackIdentifiers addObject:@"slideToSettingsDistanceStack"];
[_favoriteSettingStackIdentifiers addObject:@"unlockDisplayOrientationStack"];
}
/*
for(NSString* str in _favoriteSettingStackIdentifiers){
NSLog(@"favarite setting loaded: %@", str);