76 lines
2 KiB
Dart
76 lines
2 KiB
Dart
import 'dart:io';
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:servermanager/settings.dart';
|
|
|
|
class Proton extends StatefulWidget {
|
|
Settings settings;
|
|
Proton({super.key, required this.settings});
|
|
|
|
@override
|
|
ProtonState createState() => ProtonState(settings: settings);
|
|
}
|
|
|
|
Future<void> runProton(String command, List<String> argx) async {
|
|
Settings settings = Settings();
|
|
Directory dir =
|
|
Directory("${settings.game_path}${Platform.pathSeparator}pfx");
|
|
|
|
if (dir.existsSync()) {
|
|
await dir.delete(recursive: true);
|
|
}
|
|
await dir.create(recursive: true);
|
|
|
|
Map<String, String> env = Map.from(Platform.environment);
|
|
env["STEAM_COMPAT_CLIENT_INSTALL_PATH"] = "~/.steam";
|
|
env["STEAM_COMPAT_DATA_PATH"] = dir.path;
|
|
|
|
try {
|
|
List<String> args = ["run", command];
|
|
args.addAll(argx);
|
|
|
|
ProcessResult res = await Process.run(
|
|
"proton", args, // Run arbitrary command with arguments
|
|
environment: env,
|
|
);
|
|
|
|
print('Exit code: ${res.exitCode}');
|
|
print('stdout: ${res.stdout}');
|
|
print('stderr: ${res.stderr}');
|
|
} catch (e) {
|
|
print('Error executing command: $e');
|
|
}
|
|
}
|
|
|
|
class ProtonState extends State<Proton> {
|
|
Settings settings;
|
|
ProtonState({required this.settings});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text("Proton Manager"),
|
|
backgroundColor: Color.fromARGB(255, 100, 0, 0),
|
|
),
|
|
body: SingleChildScrollView(
|
|
child: Padding(
|
|
padding: const EdgeInsets.all(16),
|
|
child: Column(
|
|
children: [
|
|
ListTile(
|
|
title: Text("Init Prefix"),
|
|
subtitle: Text("Resets proton prefix"),
|
|
leading: Icon(CupertinoIcons.folder_fill),
|
|
onTap: () {
|
|
runProton(
|
|
"echo", ["hello"]); // Change to "cmd" to execute 'cmd'
|
|
},
|
|
)
|
|
],
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|