export profile Data

This commit is contained in:
TrueZhuangjia
2025-03-29 21:44:06 +08:00
committed by TrueZhuanjia
parent c8522de476
commit cc285d5488
6 changed files with 44 additions and 16 deletions
+2 -2
View File
@@ -985,9 +985,9 @@ ICAgICAgICAgICAgICA
</constraints>
<items>
<navigationItem title="Controller &amp; Widget Profiles" id="Q2V-XF-4jq">
<barButtonItem key="leftBarButtonItem" title="Exit" width="90" style="plain" id="Bhn-IO-Wlt" userLabel="Delete">
<barButtonItem key="leftBarButtonItem" title="Export All Pofiles" width="90" style="plain" id="Bhn-IO-Wlt" userLabel="Export Data">
<connections>
<action selector="exitTapped:" destination="Atv-Nj-0qv" id="pwG-sO-9he"/>
<action selector="exportDataTapped:" destination="Atv-Nj-0qv" id="pwG-sO-9he"/>
</connections>
</barButtonItem>
<rightBarButtonItems>
+4 -5
View File
@@ -13,7 +13,7 @@
<objects>
<viewController id="dgh-JZ-Q7z" customClass="MainFrameViewController" sceneMemberID="viewController">
<collectionView key="view" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" dataMode="prototypes" id="Rtu-AT-Alw" customClass="AppCollectionView">
<rect key="frame" x="0.0" y="0.0" width="414" height="804"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" red="0.3333333432674408" green="0.3333333432674408" blue="0.3333333432674408" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<collectionViewFlowLayout key="collectionViewLayout" minimumLineSpacing="15" minimumInteritemSpacing="15" id="YcZ-cR-3tK">
@@ -83,7 +83,7 @@
<viewControllerLayoutGuide type="bottom" id="HaZ-6S-ZpN"/>
</layoutGuides>
<view key="view" contentMode="scaleToFill" id="iNk-qF-gIr" customClass="UIScrollView">
<rect key="frame" x="0.0" y="0.0" width="499" height="3500"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="Resolution " lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="8zy-ri-Dqc">
@@ -676,7 +676,6 @@ ICAgICAgICAgICAgIA
<objects>
<navigationController id="ftZ-kC-fxI" sceneMemberID="viewController">
<navigationBar key="navigationBar" contentMode="scaleToFill" barStyle="black" translucent="NO" id="0ZA-Ec-QgD">
<rect key="frame" x="0.0" y="48" width="414" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<color key="backgroundColor" red="0.66666668653488159" green="0.66666668653488159" blue="0.66666668653488159" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color key="barTintColor" red="0.66666668653488159" green="0.66666668653488159" blue="0.66666668653488159" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
@@ -750,7 +749,7 @@ ICAgICAgICAgICAgIA
<viewControllerLayoutGuide type="bottom" id="TWA-bF-hnk"/>
</layoutGuides>
<view key="view" opaque="NO" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="Mwx-9q-yJJ">
<rect key="frame" x="0.0" y="0.0" width="650" height="896"/>
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="Jnu-63-bcf" customClass="ToolBarContainerView">
@@ -991,7 +990,7 @@ ICAgICAgICAgICAgIA
<navigationItem title="Controller &amp; Widget Profiles" id="5pN-Sn-SCN">
<barButtonItem key="leftBarButtonItem" title="Exit" id="D9X-7p-9oc">
<connections>
<action selector="exitTapped:" destination="0K8-kQ-xlN" id="Sam-Ct-kqC"/>
<action selector="exportDataTapped:" destination="0K8-kQ-xlN" id="Sam-Ct-kqC"/>
</connections>
</barButtonItem>
<rightBarButtonItems>
@@ -247,7 +247,8 @@ static CGRect streamViewBounds;
/*
NSString *documentsPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES).firstObject;
NSString *path = [documentsPath stringByAppendingPathComponent:@"newDefault.bin"];
[newProfileEncoded writeToFile:path atomically:YES];
[profiles writeToFile:path atomically:YES];
NSLog(@"默认 Profile 数据已保存到: %@", path);
*/
}
@@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
This view displays a list of on screen controller profiles and gives the user the ability to select any of the profiles to be the 'Selected' profile whose on screen controller layout configuration will be shown on the game stream view, or in the on screen controller layout view. This view also allows the user to swipe and delete any of the listed profiles.
*/
@interface OSCProfilesTableViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
@interface OSCProfilesTableViewController : UIViewController <UITableViewDelegate, UITableViewDataSource, UIDocumentPickerDelegate>
- (void)profileViewRefresh;
@@ -166,9 +166,37 @@ const double NAV_BAR_HEIGHT = 50;
[self profileViewRefresh];
}
- (IBAction) exportDataTapped:(id)sender {
// 创建临时占位文件(仅用于提供文件名)
NSString *tempPath = [NSTemporaryDirectory() stringByAppendingPathComponent:@"profiles.bin"];
[[NSData new] writeToFile:tempPath atomically:YES]; // 空文件
// 初始化选择器
UIDocumentPickerViewController *picker = [[UIDocumentPickerViewController alloc] initWithURL:[NSURL fileURLWithPath:tempPath] inMode:UIDocumentPickerModeExportToService];
picker.delegate = self;
[self presentViewController:picker animated:YES completion:nil];
}
- (IBAction) exitTapped:(id)sender {
[self dismissViewControllerAnimated:YES completion:nil];
#pragma mark - UIDocumentPickerDelegate
- (void)documentPicker:(UIDocumentPickerViewController *)controller
didPickDocumentsAtURLs:(NSArray<NSURL *> *)urls {
if (urls.count == 0) return;
NSURL *destinationURL = urls.firstObject;
NSArray *profiles = [profilesManager getAllProfiles];
// 1. 序列化数据
NSError *error;
NSData *data = [NSKeyedArchiver archivedDataWithRootObject:profiles requiringSecureCoding:YES error:&error];
if (!data) {
NSLog(@"序列化失败: %@", error);
return;
}
// 2. 安全写入
[destinationURL startAccessingSecurityScopedResource];
BOOL success = [data writeToURL:destinationURL options:NSDataWritingAtomic error:&error];
[destinationURL stopAccessingSecurityScopedResource];
if (!success) {
NSLog(@"写入失败: %@", error);
}
}
+5 -5
View File
@@ -536,31 +536,31 @@
}
},
"Bhn-IO-Wlt.title" : {
"comment" : "Class = \"UIBarButtonItem\"; title = \"Exit\"; ObjectID = \"Bhn-IO-Wlt\";",
"comment" : "Class = \"UIBarButtonItem\"; title = \"Export All Pofiles\"; ObjectID = \"Bhn-IO-Wlt\";",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Exit"
"value" : "Export All Pofiles"
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "退出"
"value" : "导出所有"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "退出"
"value" : "导出所有"
}
},
"zh-HK" : {
"stringUnit" : {
"state" : "needs_review",
"value" : "退出"
"value" : "导出所有"
}
}
}