Skip to content

Commit

Permalink
Add try-catch
Browse files Browse the repository at this point in the history
  • Loading branch information
TaYaKi71751 committed Oct 29, 2024
1 parent fdf01c3 commit 827fa2f
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 77 deletions.
71 changes: 35 additions & 36 deletions lib/boot_launcher_flow.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import 'dart:io';

class BootLauncherFlow {
static List<int> getBytes(String unique_session_code) {
List<int> result = [];
List<String> prefix = """<?xml version="1.0" encoding="UTF-8"?>
List<int> result = [];
List<String> prefix = """<?xml version="1.0" encoding="UTF-8"?>
<rage__fwuiFlowBlock>
<ID>boot_flow</ID>
<EntryPoints>
Expand Down Expand Up @@ -323,40 +323,39 @@ class BootLauncherFlow {
</Children>
</FlowRoot>
</rage__fwuiFlowBlock>"""
.split('\n');
for (String line in prefix) {
result.addAll(utf8.encode(line));
result.add(0x0d);
}
return result;
}
.split('\n');
for (String line in prefix) {
result.addAll(utf8.encode(line));
result.add(0x0d);
}
return result;
}

static Future<void> apply(
List<Directory> game_directories, String unique_session_code) async {
for (Directory game_directory in game_directories) {
File file;
if (Platform.isWindows) {
file = File(game_directory.path + '\\x64\\boot_launcher_flow.ymt');
} else if (Platform.isLinux || Platform.isMacOS) {
file = File(game_directory.path + '/x64/boot_launcher_flow.ymt');
} else {
throw Error();
}
await file.writeAsBytes(getBytes(unique_session_code));
}
}
static Future<void> apply(List<Directory> game_directories, String unique_session_code) async {
for (Directory game_directory in game_directories) {
File file;
if (Platform.isWindows) {
file = File(game_directory.path + '\\x64\\boot_launcher_flow.ymt');
} else if (Platform.isLinux || Platform.isMacOS) {
file = File(game_directory.path + '/x64/boot_launcher_flow.ymt');
} else {
throw Error();
}
await file.delete();
}
}

static Future<void> delete(List<Directory> game_directories) async {
for (Directory game_directory in game_directories) {
File file;
if (Platform.isWindows) {
file = File(game_directory.path + '\\x64\\boot_launcher_flow.ymt');
} else if (Platform.isLinux || Platform.isMacOS) {
file = File(game_directory.path + '/x64/boot_launcher_flow.ymt');
} else {
throw Error();
}
await file.delete();
}
}
static Future<void> delete(List<Directory> game_directories) async {
for (Directory game_directory in game_directories) {
File file;
if (Platform.isWindows) {
file = File(game_directory.path + '\\x64\\boot_launcher_flow.ymt');
} else if (Platform.isLinux || Platform.isMacOS) {
file = File(game_directory.path + '/x64/boot_launcher_flow.ymt');
} else {
throw Error();
}
await file.delete();
}
}
}
19 changes: 18 additions & 1 deletion lib/main.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import 'dart:async';
import 'dart:io';
import 'dart:math';

import 'package:flutter/material.dart';
import 'package:rdr2_session/boot_launcher_flow.dart';
Expand Down Expand Up @@ -42,6 +41,12 @@ class MyHomePage extends StatefulWidget {
class _MyHomePageState extends State<MyHomePage> {
final passcode = TextEditingController();
String _status = '';

Future<void> _catch(dynamic e) async {
setState(() {
_status = e.toString();
});
}

Future<void> _random() async {
var helper = RsaKeyHelper();
Expand All @@ -53,6 +58,7 @@ class _MyHomePageState extends State<MyHomePage> {
}

Future<void> _kill() async {
try {
List<String> processList = 'PlayRDR2.exe,RDR2.exe'.split(',');
for (String process in processList) {
setState(() {
Expand All @@ -63,9 +69,13 @@ class _MyHomePageState extends State<MyHomePage> {
_status = 'Killed $process';
});
}
} catch(e) {
_status = e.toString();
}
}

Future<void> _apply() async {
try {
setState(() {
_status = 'Finding Game Paths';
});
Expand All @@ -84,9 +94,13 @@ class _MyHomePageState extends State<MyHomePage> {
setState(() {
_status = 'Applied';
});
} catch(e) {
_status = e.toString();
}
}

Future<void> _delete() async {
try {
setState(() {
_status = 'Finding Game Paths';
});
Expand All @@ -105,6 +119,9 @@ class _MyHomePageState extends State<MyHomePage> {
setState(() {
_status = 'Deleted';
});
} catch(e) {
_status = e.toString();
}
}

@override
Expand Down
79 changes: 39 additions & 40 deletions lib/startup_meta.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import 'dart:convert';
import 'dart:io';

class StartupMeta {
static List<int> getBytes(String unique_session_code) {
List<int> result = [];
List<String> prefix = """<?xml version="1.0" encoding="UTF-8"?>
static List<int> getBytes(String unique_session_code) {
List<int> result = [];
List<String> prefix = """<?xml version="1.0" encoding="UTF-8"?>
<CDataFileMgr__ContentsOfDataFileXml>
<disabledFiles />
<includedXmlFiles itemType="CDataFileMgr__DataFileArray" />
Expand Down Expand Up @@ -57,43 +57,42 @@ class StartupMeta {
<contentChangeSets itemType="CDataFileMgr__ContentChangeSet" />
<patchFiles />
</CDataFileMgr__ContentsOfDataFileXml>"""
.split('\n');
for (String line in prefix) {
result.addAll(utf8.encode(line));
result.add(0x0d);
}
result.addAll(utf8.encode('<!-- $unique_session_code -->'));
result.add(0x0d);
result.add(0x0a);
return result;
}
.split('\n');
for (String line in prefix) {
result.addAll(utf8.encode(line));
result.add(0x0d);
}
result.addAll(utf8.encode('<!-- $unique_session_code -->'));
result.add(0x0d);
result.add(0x0a);
return result;
}

static Future<void> apply(
List<Directory> game_directories, String unique_session_code) async {
for (Directory game_directory in game_directories) {
File file;
if (Platform.isWindows) {
file = File(game_directory.path + '\\x64\\data\\startup.meta');
} else if (Platform.isLinux || Platform.isMacOS) {
file = File(game_directory.path + '/x64/data/startup.meta');
} else {
throw Error();
}
await file.writeAsBytes(getBytes(unique_session_code));
}
}
static Future<void> apply(List<Directory> game_directories, String unique_session_code) async {
for (Directory game_directory in game_directories) {
File file;
if (Platform.isWindows) {
file = File(game_directory.path + '\\x64\\data\\startup.meta');
} else if (Platform.isLinux || Platform.isMacOS) {
file = File(game_directory.path + '/x64/data/startup.meta');
} else {
throw Error();
}
await file.writeAsBytes(getBytes(unique_session_code));
}
}

static Future<void> delete(List<Directory> game_directories) async {
for (Directory game_directory in game_directories) {
File file;
if (Platform.isWindows) {
file = File(game_directory.path + '\\x64\\data\\startup.meta');
} else if (Platform.isLinux || Platform.isMacOS) {
file = File(game_directory.path + '/x64/data/startup.meta');
} else {
throw Error();
}
await file.delete();
}
}
static Future<void> delete(List<Directory> game_directories) async {
for (Directory game_directory in game_directories) {
File file;
if (Platform.isWindows) {
file = File(game_directory.path + '\\x64\\data\\startup.meta');
} else if (Platform.isLinux || Platform.isMacOS) {
file = File(game_directory.path + '/x64/data/startup.meta');
} else {
throw Error();
}
await file.delete();
}
}
}

0 comments on commit 827fa2f

Please sign in to comment.