diff --git a/lib/home.dart b/lib/home.dart index ccdbcd1..1ebb55f 100644 --- a/lib/home.dart +++ b/lib/home.dart @@ -61,18 +61,18 @@ class HomePageState extends State { leading: Icon(CupertinoIcons.gear), subtitle: Text("Linux Proton"), onTap: () { - if (settings.inst!.steamcmd_path.isNotEmpty) + if (settings.steamcmd_path.isNotEmpty) Navigator.pushNamed(context, "/proton"); }, ), // Not yet implemented ListTile( title: Text("SteamCMD"), leading: Icon(Icons.comment_rounded), - subtitle: settings.inst!.steamcmd_path.isEmpty + subtitle: settings.steamcmd_path.isEmpty ? Text("Path Not Set") - : Text(settings.inst!.steamcmd_path), + : Text(settings.steamcmd_path), onTap: () { - if (settings.inst!.steamcmd_path.isNotEmpty) { + if (settings.steamcmd_path.isNotEmpty) { Navigator.pushNamed(context, "/steamcmd"); } }, @@ -80,18 +80,18 @@ class HomePageState extends State { ListTile( title: Text("Server Path"), leading: Icon(CupertinoIcons.folder), - subtitle: settings.inst!.game_path.isEmpty + subtitle: settings.game_path.isEmpty ? Text("Not Set") - : Text(settings.inst!.game_path), + : Text(settings.game_path), onTap: () async { var path = await getDirectoryPath(); setState(() { if (path != null && path.isNotEmpty) { - settings.inst!.game_path = path; - settings.inst!.steamcmd_path = + settings.game_path = path; + settings.steamcmd_path = path + Platform.pathSeparator + "scmd"; - Directory.current = Directory(settings.inst!.game_path); + Directory.current = Directory(settings.game_path); } }); diff --git a/lib/proton.dart b/lib/proton.dart index 3cf0c6d..0a7c1ec 100644 --- a/lib/proton.dart +++ b/lib/proton.dart @@ -14,7 +14,7 @@ class Proton extends StatefulWidget { Future runProton(String command, List argx) async { Settings settings = Settings(); Directory dir = - Directory(settings.inst!.game_path + Platform.pathSeparator + "pfx"); + Directory(settings.game_path + Platform.pathSeparator + "pfx"); if (dir.existsSync()) { await dir.delete(recursive: true); diff --git a/lib/settings.dart b/lib/settings.dart index f912553..ebd0b33 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -10,6 +10,9 @@ class Settings { Settings._(); static final Settings Instance = Settings._(); + String steamcmd_path = ""; + String game_path = ""; + factory Settings() { return Instance; } @@ -38,7 +41,7 @@ class Settings { Future> Open() { Close(); - return Hive.openBox("settings", path: inst!.game_path); + return Hive.openBox("settings", path: game_path); } static void Close() { @@ -48,33 +51,32 @@ class Settings { } String getServerPath() { - return inst!.game_path + Platform.pathSeparator + "server"; + return game_path + Platform.pathSeparator + "server"; } bool checkInitDone() { - if (File(inst!.steamcmd_path + Platform.pathSeparator + "cxinit") - .existsSync()) { + if (File(steamcmd_path + Platform.pathSeparator + "cxinit").existsSync()) { return true; } else return false; } String getSteamCmd() { - return inst!.steamcmd_path + + return steamcmd_path + Platform.pathSeparator + "steamcmd" + (Platform.isWindows ? ".exe" : ".sh"); } String getSteamCmd2FA() { - return inst!.steamcmd_path + + return steamcmd_path + Platform.pathSeparator + "steamcmd-2fa" + (Platform.isWindows ? ".exe" : ""); } String getModPath() { - return inst!.game_path + Platform.pathSeparator + "mods"; + return game_path + Platform.pathSeparator + "mods"; } Future createModFolderIfNotExists() async { diff --git a/lib/settingsEntry.dart b/lib/settingsEntry.dart index 9e23d3e..26780e1 100644 --- a/lib/settingsEntry.dart +++ b/lib/settingsEntry.dart @@ -9,12 +9,6 @@ class SettingsEntry { @HiveField(0) List mods = []; - @HiveField(1) - String steamcmd_path = ""; - - @HiveField(2) - String game_path = ""; - @HiveField(3) Credentials? steam_creds; } diff --git a/lib/steamcmd.dart b/lib/steamcmd.dart index b2e912e..56708e2 100644 --- a/lib/steamcmd.dart +++ b/lib/steamcmd.dart @@ -54,22 +54,21 @@ class SteamCMDState extends State { changed: (X) {}, onSubmit: () async { // Yes, Proceed - var x = Directory(settings.inst!.steamcmd_path); + var x = Directory(settings.steamcmd_path); try { await x.delete(recursive: true); } catch (e) {} await x.create(recursive: true); - Directory.current = - Directory(settings.inst!.steamcmd_path); + Directory.current = Directory(settings.steamcmd_path); final dio = Dio(); Process proc; if (Platform.isWindows) { // Download zip file - final path = settings.inst!.steamcmd_path + + final path = settings.steamcmd_path + Platform.pathSeparator + "windows.zip"; final reply = await dio.download(windows, path); @@ -95,7 +94,7 @@ class SteamCMDState extends State { await Process.start("steamcmd.exe", ["+quit"]); } else { // Download tgz file - final path = settings.inst!.steamcmd_path + + final path = settings.steamcmd_path + Platform.pathSeparator + "linux.tgz"; final reply = await dio.download(linux, path); @@ -124,8 +123,7 @@ class SteamCMDState extends State { await Process.start("./steamcmd.sh", ["+quit"]); } - Directory.current = - Directory(settings.inst!.game_path); + Directory.current = Directory(settings.game_path); }, onCancel: () {}, isDefault: false, @@ -142,7 +140,7 @@ class SteamCMDState extends State { final dio = Dio(); await dio.download( Base2FAPath + (Platform.isWindows ? ".exe" : ""), - settings.inst!.steamcmd_path + + settings.steamcmd_path + Platform.pathSeparator + (Platform.isWindows ? "steamcmd-2fa.exe" @@ -150,7 +148,7 @@ class SteamCMDState extends State { if (!Platform.isWindows) var proc = await Process.start("chmod", [ "+x", - settings.inst!.steamcmd_path + + settings.steamcmd_path + Platform.pathSeparator + "steamcmd-2fa" ]);