Switch to wine, add winetricks

This commit is contained in:
zontreck 2024-06-03 18:33:13 -07:00
parent 0c30b3f820
commit 0ae098318a
10 changed files with 104 additions and 79 deletions

View file

@ -15,8 +15,7 @@ import 'package:servermanager/statemachine.dart';
import 'package:servermanager/structs/credentials.dart';
import 'package:servermanager/structs/mod.dart';
import 'package:servermanager/structs/settingsEntry.dart';
import '../proton.dart';
import 'package:servermanager/wine.dart';
class Settings {
final String windows =
@ -27,9 +26,6 @@ class Settings {
final String Base2FAPath =
"https://github.com/zontreck/steamcmd-2fa/releases/download/0.2.0/steamcmd-2fa";
final String PROTON_URL =
"https://github.com/GloriousEggroll/proton-ge-custom/releases/download/GE-Proton9-5/GE-Proton9-5.tar.gz";
Settings._();
static final Settings Instance = Settings._();
@ -37,7 +33,6 @@ class Settings {
String steamcmd_path = "";
String game_path = "";
String proton_path = "";
String base_path = "";
bool FTS = true;
Credentials serverLoginCreds =
@ -56,7 +51,6 @@ class Settings {
CompoundTag tag = CompoundTag();
tag.put("steamcmd", StringTag.valueOf(steamcmd_path));
tag.put("game", StringTag.valueOf(game_path));
tag.put("proton", StringTag.valueOf(proton_path));
tag.put("base", StringTag.valueOf(base_path));
NbtUtils.writeBoolean(tag, "fts", FTS);
@ -79,7 +73,6 @@ class Settings {
steamcmd_path = tag.get("steamcmd")!.asString();
game_path = tag.get("game")!.asString();
proton_path = tag.get("proton")!.asString();
base_path = tag.get("proton")!.asString();
FTS = NbtUtils.readBoolean(tag, "fts"); // First Time Setup.
// FTS should be disabled by the client when sending it back to the server in a C2SApplySettingsPacket
@ -170,18 +163,6 @@ class Settings {
return PathHelper(pth: base_path).resolve("mods.jail").build();
}
String getProtonPath() {
return PathHelper(pth: base_path).resolve("proton").build();
}
String getProtonExecutablePath() {
return PathHelper(pth: base_path)
.resolve("proton")
.resolve("GE-Proton9-5")
.resolve("proton")
.build();
}
Future<void> createModFolderIfNotExists() async {
if (Directory(getModPath()).existsSync()) {
return;
@ -269,10 +250,6 @@ class Settings {
flush: true, mode: FileMode.writeOnly);
}
Future<void> initializeProtonPrefix() async {
runProton("echo", ["hello"]);
}
Future<bool> sendRconCommand(String command) async {
try {
createSocket("127.0.0.1", port: inst!.serverSettings.RconPort);
@ -289,19 +266,13 @@ class Settings {
}
}
Future<void> initializeProton() async {
Dio dio = Dio();
print("Downloading proton...");
final path = PathHelper(pth: getProtonPath()).resolve("proton.tar.gz");
await dio.download(PROTON_URL, path.build());
String oldWD = Directory.current.path;
Directory.current = getProtonPath();
Process.runSync("tar", ["-xvf", "proton.tar.gz"]);
Process.runSync("rm", ["-f", "proton.tar.gz"]);
Directory.current = oldWD; // Restore the old working directory
print("Finished!");
Future<void> initializeWine() async {
await runWinetrick("win10");
await runWinetrick("vcrun2015");
await runWinetrick("vcrun2017");
await runWinetrick("vcrun2019");
await runWinetrick("vcrun2022");
await runWinetrick("corefonts");
}
Future<void> initializeSteamCmd() async {
@ -377,9 +348,6 @@ class Settings {
Process.runSync("touch", ["cxinit"]);
Process.runSync("./steamcmd.sh", ["+quit"]);
print("Completed. Initializing Proton");
await initializeProton();
}
Directory.current = Directory(game_path);