58 lines
1.7 KiB
Dart
58 lines
1.7 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);
|
|
}
|
|
|
|
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: () async {
|
|
Directory dir = Directory(
|
|
settings.game_path + Platform.pathSeparator + "pfx");
|
|
// Invoke Proton and reset the prefix.
|
|
if (dir.existsSync()) {
|
|
await dir.delete(recursive: true);
|
|
|
|
await dir.create(recursive: true);
|
|
} else {
|
|
await dir.create(recursive: true);
|
|
}
|
|
|
|
Map<String, String> env = Map();
|
|
env.putIfAbsent(
|
|
"STEAM_COMPAT_CLIENT_INSTALL_PATH", () => "~/.steam");
|
|
env.putIfAbsent("STEAM_COMPAT_DATA_PATH", () => dir.path);
|
|
var res = await Process.run("proton", ["run", "exit"],
|
|
environment: env);
|
|
},
|
|
)
|
|
]),
|
|
)),
|
|
);
|
|
}
|
|
}
|