Start to implement snapshotting

This commit is contained in:
zontreck 2024-07-01 23:43:48 -07:00
parent a2737c82f9
commit e53fc977bc
5 changed files with 63 additions and 9 deletions

View file

@ -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()
});
}
}

View file

@ -45,6 +45,12 @@ class GameServerPageState extends State<GameServerPage> {
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),

40
lib/pages/snapshots.dart Normal file
View file

@ -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<StatefulWidget> createState() {
return SnapshotsState();
}
}
class SnapshotsState extends State<SnapshotsPage> {
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),
),
],
),
),
),
);
}
}

View file

@ -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,13 +172,14 @@ 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();
var pth1 = path.resolve("dlc_siptah.db");
if (pth1.exists()) return pth1.build();
return pth2.build(); // Fallback to game.db
}

View file

@ -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'