diff --git a/lib/main.dart b/lib/main.dart index 6f93a65..395ca41 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -8,6 +8,7 @@ import 'package:servermanager/pages/ModManager.dart'; import 'package:servermanager/pages/autorestart.dart'; import 'package:servermanager/pages/credentials_prompt.dart'; import 'package:servermanager/pages/home.dart'; +import 'package:servermanager/pages/snapshots.dart'; import 'package:servermanager/structs/settings.dart'; import 'pages/ServerSettings.dart'; @@ -34,7 +35,8 @@ class MyApp extends StatelessWidget { "/server/ports": (context) => ServerSettingsPage(), "/server/mods": (context) => ModManager(settings: appSettings), "/server/mods/edit": (context) => ModPage(), - "/server/discord": (context) => DiscordConfigPage() + "/server/discord": (context) => DiscordConfigPage(), + "/server/snapshots": (context) => SnapshotsPage() }); } } diff --git a/lib/pages/GameServerPage.dart b/lib/pages/GameServerPage.dart index 5083bd3..e706c00 100644 --- a/lib/pages/GameServerPage.dart +++ b/lib/pages/GameServerPage.dart @@ -45,6 +45,12 @@ class GameServerPageState extends State { Navigator.pushNamed(context, "/server/mods"); }, ), + ListTile( + title: Text("Server Snapshots"), + leading: Icon(Icons.photo), + subtitle: Text("Manage server database snapshots"), + onTap: () {}, + ), ListTile( title: Text("Configure AutoRestart"), leading: Icon(Icons.timer), diff --git a/lib/pages/snapshots.dart b/lib/pages/snapshots.dart new file mode 100644 index 0000000..86589c2 --- /dev/null +++ b/lib/pages/snapshots.dart @@ -0,0 +1,40 @@ +import 'package:flutter/material.dart'; +import 'package:servermanager/pages/Constants.dart'; +import 'package:servermanager/structs/settings.dart'; + +class SnapshotsPage extends StatefulWidget { + SnapshotsPage({super.key}); + + @override + State createState() { + return SnapshotsState(); + } +} + +class SnapshotsState extends State { + SnapshotsState(); + Settings settings = Settings(); + + @override + Widget build(BuildContext context) { + return Scaffold( + appBar: AppBar( + title: Text("Server Snapshots Manager"), + backgroundColor: Constants.TITLEBAR_COLOR, + ), + body: Padding( + padding: EdgeInsets.all(8), + child: SingleChildScrollView( + child: Column( + children: [ + ListTile( + title: Text("Server DB File"), + subtitle: Text(settings.gameServerDBFile), + ), + ], + ), + ), + ), + ); + } +} diff --git a/lib/structs/settings.dart b/lib/structs/settings.dart index e9ab9ab..f77d7f0 100644 --- a/lib/structs/settings.dart +++ b/lib/structs/settings.dart @@ -33,6 +33,7 @@ class Settings { String steamcmd_path = ""; String game_path = ""; String base_path = ""; + String gameServerDBFile = ""; bool FTS = true; Credentials serverLoginCreds = Credentials(username: "admin", password: "changeMe123"); @@ -51,6 +52,7 @@ class Settings { tag.put("steamcmd", StringTag.valueOf(steamcmd_path)); tag.put("game", StringTag.valueOf(game_path)); tag.put("base", StringTag.valueOf(base_path)); + tag.put("dbfile", StringTag.valueOf(getWorldGameDB())); NbtUtils.writeBoolean(tag, "fts", FTS); tag.put("server_creds", serverLoginCreds.save()); @@ -73,6 +75,9 @@ class Settings { steamcmd_path = tag.get("steamcmd")!.asString(); game_path = tag.get("game")!.asString(); base_path = tag.get("base")!.asString(); + if (tag.containsKey("dbfile")) + gameServerDBFile = tag.get("dbfile")!.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 @@ -167,12 +172,13 @@ class Settings { } String getWorldGameDB() { - var path = PathHelper(pth: getServerPath()).resolve("ConanSandbox").resolve("Saved"); + var path = PathHelper(pth: getServerPath()) + .resolve("ConanSandbox") + .resolve("Saved"); var pth2 = path.resolve("game.db"); - if(pth2.exists()) return pth2.build(); + if (pth2.exists()) return pth2.build(); var pth1 = path.resolve("dlc_siptah.db"); - if(pth1.exists()) return pth1.build(); - + if (pth1.exists()) return pth1.build(); return pth2.build(); // Fallback to game.db } @@ -181,7 +187,7 @@ class Settings { Directory dir = Directory(getWorldSnapshotFolder()); var lst = await dir.list().toList(); List backupNames = []; - for(var file in lst) { + for (var file in lst) { backupNames.add(file.path); } @@ -205,9 +211,9 @@ class Settings { } Future createBackupsFolderIfNotExists() async { - if(Directory(getWorldSnapshotFolder()).existsSync()) { + if (Directory(getWorldSnapshotFolder()).existsSync()) { return; - }else { + } else { await Directory(getWorldSnapshotFolder()).create(recursive: true); } } diff --git a/pubspec.yaml b/pubspec.yaml index dbc8498..171f36a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # In Windows, build-name is used as the major, minor, and patch parts # of the product and file versions while build-number is used as the build suffix. -version: 1.1.0+1 +version: 1.1.0+32 environment: sdk: '>=3.1.4 <4.0.0'