diff --git a/lib/dialogbox.dart b/lib/dialogbox.dart index 71515bc..b7ad5ed 100644 --- a/lib/dialogbox.dart +++ b/lib/dialogbox.dart @@ -28,8 +28,9 @@ class InputBox extends StatelessWidget { this.hasInputField = true}) { if (isDefault) { value.text = ""; - } else + } else { value.text = defaultText; + } } @override @@ -44,22 +45,22 @@ class InputBox extends StatelessWidget { onSubmit(); Navigator.of(context).pop(); }, - child: hasInputField ? Text("Submit") : Text("OK"), style: ButtonStyle( backgroundColor: MaterialStateColor.resolveWith( (states) => const Color.fromARGB(255, 0, 83, 3))), + child: hasInputField ? Text("Submit") : Text("OK"), ), ElevatedButton( onPressed: () { onCancel(); Navigator.of(context).pop(); }, - child: Text("Cancel"), style: ButtonStyle( backgroundColor: MaterialStateColor.resolveWith( - (states) => const Color.fromARGB(255, 109, 7, 0)))) + (states) => const Color.fromARGB(255, 109, 7, 0))), + child: Text("Cancel")) ], - content: Container( + content: SizedBox( height: 128, //decoration: BoxDecoration( //border: Border.all(style: BorderStyle.solid), diff --git a/lib/game.dart b/lib/game.dart index c0ffb03..793149c 100644 --- a/lib/game.dart +++ b/lib/game.dart @@ -1,7 +1,6 @@ import 'dart:io'; import 'package:flutter/material.dart'; -import 'package:hive_flutter/adapters.dart'; import 'package:servermanager/mod.dart'; import 'package:servermanager/settings.dart'; @@ -34,8 +33,9 @@ class GameServerPageState extends State { SnackBar(content: Text("Wait until the download completes"))); return false; - } else + } else { return true; + } }, child: SingleChildScrollView( padding: EdgeInsets.all(16), @@ -199,11 +199,11 @@ class ModManagerState extends State { itemBuilder: (ctx, idx) { Mod mod = settings.inst!.mods[idx]; return Padding( - key: Key("${mod.mod_instance_id()}"), + key: Key(mod.mod_instance_id()), padding: EdgeInsets.all(12), child: ListTile( title: Text(mod.mod_name), - subtitle: Text("ID: " + mod.mod_id.toString()), + subtitle: Text("ID: ${mod.mod_id}"), onTap: () async { final reply = await Navigator.pushNamed( context, "/server/mods/edit", @@ -212,14 +212,15 @@ class ModManagerState extends State { mod_name: mod.mod_name, newMod: false)); - if (reply != null) + if (reply != null) { setState(() { settings.inst!.mods[idx] = reply as Mod; }); - else + } else { setState(() { settings.inst!.mods.removeAt(idx); }); + } }, ), ); @@ -352,16 +353,17 @@ class ModPage extends StatelessWidget { ]), ), onWillPop: () async { - int id_val = 0; + int idVal = 0; try { - id_val = int.parse(id.text); + idVal = int.parse(id.text); } catch (E) {} - if (willDelete) + if (willDelete) { Navigator.pop(context, null); - else + } else { Navigator.pop(context, - Mod(mod_id: id_val, mod_name: name.text, newMod: false)); + Mod(mod_id: idVal, mod_name: name.text, newMod: false)); + } return true; }, ), diff --git a/lib/home.dart b/lib/home.dart index 1ebb55f..fb86676 100644 --- a/lib/home.dart +++ b/lib/home.dart @@ -61,8 +61,9 @@ class HomePageState extends State { leading: Icon(CupertinoIcons.gear), subtitle: Text("Linux Proton"), onTap: () { - if (settings.steamcmd_path.isNotEmpty) + if (settings.steamcmd_path.isNotEmpty) { Navigator.pushNamed(context, "/proton"); + } }, ), // Not yet implemented ListTile( @@ -89,7 +90,7 @@ class HomePageState extends State { if (path != null && path.isNotEmpty) { settings.game_path = path; settings.steamcmd_path = - path + Platform.pathSeparator + "scmd"; + "$path${Platform.pathSeparator}scmd"; Directory.current = Directory(settings.game_path); } diff --git a/lib/proton.dart b/lib/proton.dart index 0a7c1ec..b8a8b86 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.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 ebd0b33..743ae47 100644 --- a/lib/settings.dart +++ b/lib/settings.dart @@ -1,10 +1,7 @@ import 'dart:io'; import 'package:hive/hive.dart'; -import 'package:servermanager/credentials.dart'; -import 'package:servermanager/mod.dart'; import 'package:servermanager/settingsEntry.dart'; -import 'package:servermanager/steamcmd.dart'; class Settings { Settings._(); @@ -35,8 +32,9 @@ class Settings { bool isValid() { if (!Hive.isBoxOpen("settings")) { return false; - } else + } else { return true; + } } Future> Open() { @@ -51,44 +49,40 @@ class Settings { } String getServerPath() { - return game_path + Platform.pathSeparator + "server"; + return "$game_path${Platform.pathSeparator}server"; } bool checkInitDone() { - if (File(steamcmd_path + Platform.pathSeparator + "cxinit").existsSync()) { + if (File("$steamcmd_path${Platform.pathSeparator}cxinit").existsSync()) { return true; - } else + } else { return false; + } } String getSteamCmd() { - return steamcmd_path + - Platform.pathSeparator + - "steamcmd" + - (Platform.isWindows ? ".exe" : ".sh"); + return "$steamcmd_path${Platform.pathSeparator}steamcmd${Platform.isWindows ? ".exe" : ".sh"}"; } String getSteamCmd2FA() { - return steamcmd_path + - Platform.pathSeparator + - "steamcmd-2fa" + - (Platform.isWindows ? ".exe" : ""); + return "$steamcmd_path${Platform.pathSeparator}steamcmd-2fa${Platform.isWindows ? ".exe" : ""}"; } String getModPath() { - return game_path + Platform.pathSeparator + "mods"; + return "$game_path${Platform.pathSeparator}mods"; } Future createModFolderIfNotExists() async { - if (Directory(getModPath()).existsSync()) + if (Directory(getModPath()).existsSync()) { return; - else + } else { await Directory(getModPath()).create(recursive: true); + } } bool serverInstalled() { return File( - getServerPath() + Platform.pathSeparator + "ConanSandboxServer.exe") + "${getServerPath()}${Platform.pathSeparator}ConanSandboxServer.exe") .existsSync(); } diff --git a/lib/steamcmd.dart b/lib/steamcmd.dart index 56708e2..38204c5 100644 --- a/lib/steamcmd.dart +++ b/lib/steamcmd.dart @@ -4,7 +4,6 @@ import 'package:archive/archive_io.dart'; import 'package:dio/dio.dart'; import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; -import 'package:hive_flutter/adapters.dart'; import 'package:servermanager/credentials.dart'; import 'package:servermanager/dialogbox.dart'; import 'package:servermanager/settings.dart'; @@ -68,9 +67,7 @@ class SteamCMDState extends State { if (Platform.isWindows) { // Download zip file - final path = settings.steamcmd_path + - Platform.pathSeparator + - "windows.zip"; + final path = "${settings.steamcmd_path}${Platform.pathSeparator}windows.zip"; final reply = await dio.download(windows, path); final bytes = File(path).readAsBytesSync(); @@ -94,9 +91,7 @@ class SteamCMDState extends State { await Process.start("steamcmd.exe", ["+quit"]); } else { // Download tgz file - final path = settings.steamcmd_path + - Platform.pathSeparator + - "linux.tgz"; + final path = "${settings.steamcmd_path}${Platform.pathSeparator}linux.tgz"; final reply = await dio.download(linux, path); final bytes = File(path).readAsBytesSync(); @@ -145,13 +140,12 @@ class SteamCMDState extends State { (Platform.isWindows ? "steamcmd-2fa.exe" : "steamcmd-2fa")); - if (!Platform.isWindows) + if (!Platform.isWindows) { var proc = await Process.start("chmod", [ "+x", - settings.steamcmd_path + - Platform.pathSeparator + - "steamcmd-2fa" + "${settings.steamcmd_path}${Platform.pathSeparator}steamcmd-2fa" ]); + } }), ListTile( title: Text("Credentials"),