Fix some null check errors
This commit is contained in:
parent
d03613b0c7
commit
fc9dc6f4d3
5 changed files with 26 additions and 32 deletions
|
@ -61,18 +61,18 @@ class HomePageState extends State<HomePage> {
|
||||||
leading: Icon(CupertinoIcons.gear),
|
leading: Icon(CupertinoIcons.gear),
|
||||||
subtitle: Text("Linux Proton"),
|
subtitle: Text("Linux Proton"),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (settings.inst!.steamcmd_path.isNotEmpty)
|
if (settings.steamcmd_path.isNotEmpty)
|
||||||
Navigator.pushNamed(context, "/proton");
|
Navigator.pushNamed(context, "/proton");
|
||||||
},
|
},
|
||||||
), // Not yet implemented
|
), // Not yet implemented
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text("SteamCMD"),
|
title: Text("SteamCMD"),
|
||||||
leading: Icon(Icons.comment_rounded),
|
leading: Icon(Icons.comment_rounded),
|
||||||
subtitle: settings.inst!.steamcmd_path.isEmpty
|
subtitle: settings.steamcmd_path.isEmpty
|
||||||
? Text("Path Not Set")
|
? Text("Path Not Set")
|
||||||
: Text(settings.inst!.steamcmd_path),
|
: Text(settings.steamcmd_path),
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (settings.inst!.steamcmd_path.isNotEmpty) {
|
if (settings.steamcmd_path.isNotEmpty) {
|
||||||
Navigator.pushNamed(context, "/steamcmd");
|
Navigator.pushNamed(context, "/steamcmd");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -80,18 +80,18 @@ class HomePageState extends State<HomePage> {
|
||||||
ListTile(
|
ListTile(
|
||||||
title: Text("Server Path"),
|
title: Text("Server Path"),
|
||||||
leading: Icon(CupertinoIcons.folder),
|
leading: Icon(CupertinoIcons.folder),
|
||||||
subtitle: settings.inst!.game_path.isEmpty
|
subtitle: settings.game_path.isEmpty
|
||||||
? Text("Not Set")
|
? Text("Not Set")
|
||||||
: Text(settings.inst!.game_path),
|
: Text(settings.game_path),
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
var path = await getDirectoryPath();
|
var path = await getDirectoryPath();
|
||||||
setState(() {
|
setState(() {
|
||||||
if (path != null && path.isNotEmpty) {
|
if (path != null && path.isNotEmpty) {
|
||||||
settings.inst!.game_path = path;
|
settings.game_path = path;
|
||||||
settings.inst!.steamcmd_path =
|
settings.steamcmd_path =
|
||||||
path + Platform.pathSeparator + "scmd";
|
path + Platform.pathSeparator + "scmd";
|
||||||
|
|
||||||
Directory.current = Directory(settings.inst!.game_path);
|
Directory.current = Directory(settings.game_path);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ class Proton extends StatefulWidget {
|
||||||
Future<void> runProton(String command, List<String> argx) async {
|
Future<void> runProton(String command, List<String> argx) async {
|
||||||
Settings settings = Settings();
|
Settings settings = Settings();
|
||||||
Directory dir =
|
Directory dir =
|
||||||
Directory(settings.inst!.game_path + Platform.pathSeparator + "pfx");
|
Directory(settings.game_path + Platform.pathSeparator + "pfx");
|
||||||
|
|
||||||
if (dir.existsSync()) {
|
if (dir.existsSync()) {
|
||||||
await dir.delete(recursive: true);
|
await dir.delete(recursive: true);
|
||||||
|
|
|
@ -10,6 +10,9 @@ class Settings {
|
||||||
Settings._();
|
Settings._();
|
||||||
static final Settings Instance = Settings._();
|
static final Settings Instance = Settings._();
|
||||||
|
|
||||||
|
String steamcmd_path = "";
|
||||||
|
String game_path = "";
|
||||||
|
|
||||||
factory Settings() {
|
factory Settings() {
|
||||||
return Instance;
|
return Instance;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +41,7 @@ class Settings {
|
||||||
|
|
||||||
Future<Box<E>> Open<E>() {
|
Future<Box<E>> Open<E>() {
|
||||||
Close();
|
Close();
|
||||||
return Hive.openBox("settings", path: inst!.game_path);
|
return Hive.openBox("settings", path: game_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Close() {
|
static void Close() {
|
||||||
|
@ -48,33 +51,32 @@ class Settings {
|
||||||
}
|
}
|
||||||
|
|
||||||
String getServerPath() {
|
String getServerPath() {
|
||||||
return inst!.game_path + Platform.pathSeparator + "server";
|
return game_path + Platform.pathSeparator + "server";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkInitDone() {
|
bool checkInitDone() {
|
||||||
if (File(inst!.steamcmd_path + Platform.pathSeparator + "cxinit")
|
if (File(steamcmd_path + Platform.pathSeparator + "cxinit").existsSync()) {
|
||||||
.existsSync()) {
|
|
||||||
return true;
|
return true;
|
||||||
} else
|
} else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String getSteamCmd() {
|
String getSteamCmd() {
|
||||||
return inst!.steamcmd_path +
|
return steamcmd_path +
|
||||||
Platform.pathSeparator +
|
Platform.pathSeparator +
|
||||||
"steamcmd" +
|
"steamcmd" +
|
||||||
(Platform.isWindows ? ".exe" : ".sh");
|
(Platform.isWindows ? ".exe" : ".sh");
|
||||||
}
|
}
|
||||||
|
|
||||||
String getSteamCmd2FA() {
|
String getSteamCmd2FA() {
|
||||||
return inst!.steamcmd_path +
|
return steamcmd_path +
|
||||||
Platform.pathSeparator +
|
Platform.pathSeparator +
|
||||||
"steamcmd-2fa" +
|
"steamcmd-2fa" +
|
||||||
(Platform.isWindows ? ".exe" : "");
|
(Platform.isWindows ? ".exe" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
String getModPath() {
|
String getModPath() {
|
||||||
return inst!.game_path + Platform.pathSeparator + "mods";
|
return game_path + Platform.pathSeparator + "mods";
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> createModFolderIfNotExists() async {
|
Future<void> createModFolderIfNotExists() async {
|
||||||
|
|
|
@ -9,12 +9,6 @@ class SettingsEntry {
|
||||||
@HiveField(0)
|
@HiveField(0)
|
||||||
List<Mod> mods = [];
|
List<Mod> mods = [];
|
||||||
|
|
||||||
@HiveField(1)
|
|
||||||
String steamcmd_path = "";
|
|
||||||
|
|
||||||
@HiveField(2)
|
|
||||||
String game_path = "";
|
|
||||||
|
|
||||||
@HiveField(3)
|
@HiveField(3)
|
||||||
Credentials? steam_creds;
|
Credentials? steam_creds;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,22 +54,21 @@ class SteamCMDState extends State<SteamCMD> {
|
||||||
changed: (X) {},
|
changed: (X) {},
|
||||||
onSubmit: () async {
|
onSubmit: () async {
|
||||||
// Yes, Proceed
|
// Yes, Proceed
|
||||||
var x = Directory(settings.inst!.steamcmd_path);
|
var x = Directory(settings.steamcmd_path);
|
||||||
try {
|
try {
|
||||||
await x.delete(recursive: true);
|
await x.delete(recursive: true);
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
await x.create(recursive: true);
|
await x.create(recursive: true);
|
||||||
|
|
||||||
Directory.current =
|
Directory.current = Directory(settings.steamcmd_path);
|
||||||
Directory(settings.inst!.steamcmd_path);
|
|
||||||
final dio = Dio();
|
final dio = Dio();
|
||||||
|
|
||||||
Process proc;
|
Process proc;
|
||||||
|
|
||||||
if (Platform.isWindows) {
|
if (Platform.isWindows) {
|
||||||
// Download zip file
|
// Download zip file
|
||||||
final path = settings.inst!.steamcmd_path +
|
final path = settings.steamcmd_path +
|
||||||
Platform.pathSeparator +
|
Platform.pathSeparator +
|
||||||
"windows.zip";
|
"windows.zip";
|
||||||
final reply = await dio.download(windows, path);
|
final reply = await dio.download(windows, path);
|
||||||
|
@ -95,7 +94,7 @@ class SteamCMDState extends State<SteamCMD> {
|
||||||
await Process.start("steamcmd.exe", ["+quit"]);
|
await Process.start("steamcmd.exe", ["+quit"]);
|
||||||
} else {
|
} else {
|
||||||
// Download tgz file
|
// Download tgz file
|
||||||
final path = settings.inst!.steamcmd_path +
|
final path = settings.steamcmd_path +
|
||||||
Platform.pathSeparator +
|
Platform.pathSeparator +
|
||||||
"linux.tgz";
|
"linux.tgz";
|
||||||
final reply = await dio.download(linux, path);
|
final reply = await dio.download(linux, path);
|
||||||
|
@ -124,8 +123,7 @@ class SteamCMDState extends State<SteamCMD> {
|
||||||
await Process.start("./steamcmd.sh", ["+quit"]);
|
await Process.start("./steamcmd.sh", ["+quit"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Directory.current =
|
Directory.current = Directory(settings.game_path);
|
||||||
Directory(settings.inst!.game_path);
|
|
||||||
},
|
},
|
||||||
onCancel: () {},
|
onCancel: () {},
|
||||||
isDefault: false,
|
isDefault: false,
|
||||||
|
@ -142,7 +140,7 @@ class SteamCMDState extends State<SteamCMD> {
|
||||||
final dio = Dio();
|
final dio = Dio();
|
||||||
await dio.download(
|
await dio.download(
|
||||||
Base2FAPath + (Platform.isWindows ? ".exe" : ""),
|
Base2FAPath + (Platform.isWindows ? ".exe" : ""),
|
||||||
settings.inst!.steamcmd_path +
|
settings.steamcmd_path +
|
||||||
Platform.pathSeparator +
|
Platform.pathSeparator +
|
||||||
(Platform.isWindows
|
(Platform.isWindows
|
||||||
? "steamcmd-2fa.exe"
|
? "steamcmd-2fa.exe"
|
||||||
|
@ -150,7 +148,7 @@ class SteamCMDState extends State<SteamCMD> {
|
||||||
if (!Platform.isWindows)
|
if (!Platform.isWindows)
|
||||||
var proc = await Process.start("chmod", [
|
var proc = await Process.start("chmod", [
|
||||||
"+x",
|
"+x",
|
||||||
settings.inst!.steamcmd_path +
|
settings.steamcmd_path +
|
||||||
Platform.pathSeparator +
|
Platform.pathSeparator +
|
||||||
"steamcmd-2fa"
|
"steamcmd-2fa"
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue