mirror of
https://mirror.ghproxy.com/https://github.com/StarCitizenToolBox/app.git
synced 2024-12-23 05:23:44 +08:00
新增摄影模式工具
This commit is contained in:
parent
cda6240295
commit
41763e0f61
@ -11,6 +11,7 @@ import 'package:starcitizen_doctor/common/helper/log_helper.dart';
|
|||||||
import 'package:starcitizen_doctor/common/helper/system_helper.dart';
|
import 'package:starcitizen_doctor/common/helper/system_helper.dart';
|
||||||
import 'package:starcitizen_doctor/ui/tools/downloader/downloader_dialog_ui_model.dart';
|
import 'package:starcitizen_doctor/ui/tools/downloader/downloader_dialog_ui_model.dart';
|
||||||
import 'package:url_launcher/url_launcher_string.dart';
|
import 'package:url_launcher/url_launcher_string.dart';
|
||||||
|
import 'package:xml/xml.dart';
|
||||||
|
|
||||||
import 'downloader/downloader_dialog_ui.dart';
|
import 'downloader/downloader_dialog_ui.dart';
|
||||||
|
|
||||||
@ -79,7 +80,10 @@ class ToolsUIModel extends BaseUIModel {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
items.addAll(await _addNvmePatchCard());
|
items.addAll(await _addNvmePatchCard());
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
|
items.add(await _addPhotographyCard());
|
||||||
|
notifyListeners();
|
||||||
items.add(await _addShaderCard());
|
items.add(await _addShaderCard());
|
||||||
|
// close loading
|
||||||
isItemLoading = false;
|
isItemLoading = false;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@ -169,6 +173,19 @@ class ToolsUIModel extends BaseUIModel {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<_ToolsItemData> _addPhotographyCard() async {
|
||||||
|
// 获取配置文件状态
|
||||||
|
final isEnable = await _checkPhotographyStatus();
|
||||||
|
|
||||||
|
return _ToolsItemData(
|
||||||
|
"photography_mode",
|
||||||
|
isEnable ? "关闭摄影模式" : "开启摄影模式",
|
||||||
|
"一键修改镜游戏内镜头参数以便于摄影操作。\n\n @拉邦那 Lapernum 提供参数信息。",
|
||||||
|
const Icon(FontAwesomeIcons.camera, size: 28),
|
||||||
|
onTap: () => _onChangePhotographyMode(isEnable),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// ---------------------------- func -------------------------------------------------------
|
/// ---------------------------- func -------------------------------------------------------
|
||||||
/// -----------------------------------------------------------------------------------------
|
/// -----------------------------------------------------------------------------------------
|
||||||
/// -----------------------------------------------------------------------------------------
|
/// -----------------------------------------------------------------------------------------
|
||||||
@ -374,6 +391,60 @@ class ToolsUIModel extends BaseUIModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<bool> _checkPhotographyStatus({bool? setMode}) async {
|
||||||
|
const keys = ["AudioShakeStrength", "CameraSpringMovement", "ShakeScale"];
|
||||||
|
final attributesFile = File(
|
||||||
|
"$scInstalledPath\\USER\\Client\\0\\Profiles\\default\\attributes.xml");
|
||||||
|
if (setMode == null) {
|
||||||
|
bool isEnable = false;
|
||||||
|
if (scInstalledPath.isNotEmpty) {
|
||||||
|
if (await attributesFile.exists()) {
|
||||||
|
final xmlFile =
|
||||||
|
XmlDocument.parse(await attributesFile.readAsString());
|
||||||
|
isEnable = true;
|
||||||
|
for (var k in keys) {
|
||||||
|
if (!isEnable) break;
|
||||||
|
final e = xmlFile.rootElement.children
|
||||||
|
.where((element) => element.getAttribute("name") == k)
|
||||||
|
.firstOrNull;
|
||||||
|
if (e != null && e.getAttribute("value") == "0") {
|
||||||
|
} else {
|
||||||
|
isEnable = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return isEnable;
|
||||||
|
} else {
|
||||||
|
if (!await attributesFile.exists()) {
|
||||||
|
showToast(context!, "配置文件不存在,请尝试运行一次游戏");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final xmlFile = XmlDocument.parse(await attributesFile.readAsString());
|
||||||
|
// clear all
|
||||||
|
xmlFile.rootElement.children.removeWhere(
|
||||||
|
(element) => keys.contains(element.getAttribute("name")));
|
||||||
|
if (setMode) {
|
||||||
|
for (var element in keys) {
|
||||||
|
XmlElement newNode = XmlElement(XmlName('Attr'), [
|
||||||
|
XmlAttribute(XmlName('name'), element),
|
||||||
|
XmlAttribute(XmlName('value'), '0'),
|
||||||
|
]);
|
||||||
|
xmlFile.rootElement.children.add(newNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dPrint(xmlFile);
|
||||||
|
await attributesFile.delete();
|
||||||
|
await attributesFile.writeAsString(xmlFile.toXmlString(pretty: true));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
_onChangePhotographyMode(bool isEnable) async {
|
||||||
|
await handleError(() => _checkPhotographyStatus(setMode: !isEnable));
|
||||||
|
reloadData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _ToolsItemData {
|
class _ToolsItemData {
|
||||||
|
@ -65,6 +65,7 @@ dependencies:
|
|||||||
hexcolor: ^3.0.1
|
hexcolor: ^3.0.1
|
||||||
dart_rss: ^3.0.1
|
dart_rss: ^3.0.1
|
||||||
html: ^0.15.4
|
html: ^0.15.4
|
||||||
|
xml: ^6.5.0
|
||||||
|
|
||||||
dependency_overrides:
|
dependency_overrides:
|
||||||
http: ^1.1.2
|
http: ^1.1.2
|
||||||
|
Loading…
Reference in New Issue
Block a user