155 lines
5.2 KiB
Dart
155 lines
5.2 KiB
Dart
import 'dart:io';
|
|
|
|
import 'package:flutter/cupertino.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:servermanager/packets/ClientPackets.dart';
|
|
import 'package:servermanager/pages/Constants.dart';
|
|
import 'package:servermanager/structs/credentials.dart';
|
|
import 'package:servermanager/structs/settings.dart';
|
|
|
|
class HomePage extends StatefulWidget {
|
|
Settings settings;
|
|
HomePage({super.key, required this.settings});
|
|
|
|
@override
|
|
HomePageState createState() => HomePageState(settings: settings);
|
|
}
|
|
|
|
class HomePageState extends State<HomePage> {
|
|
Settings settings = Settings();
|
|
bool requireRestart = false;
|
|
|
|
HomePageState({required this.settings});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
appBar: AppBar(
|
|
title: Text("Conan Exiles Server Manager"),
|
|
backgroundColor: Constants.TITLEBAR_COLOR),
|
|
drawer: Drawer(
|
|
child: SingleChildScrollView(
|
|
child: Column(children: [
|
|
DrawerHeader(
|
|
child: Column(
|
|
children: [
|
|
Icon(Icons.computer),
|
|
Text("Conan Exiles Server Manager")
|
|
],
|
|
)),
|
|
Column(
|
|
children: [
|
|
ListTile(
|
|
title: Text("S E R V E R"),
|
|
leading: Icon(Icons.cloud),
|
|
subtitle: Text("The game server!"),
|
|
onTap: () {
|
|
Navigator.pushNamed(context, "/server");
|
|
},
|
|
)
|
|
],
|
|
)
|
|
]),
|
|
)),
|
|
body: SingleChildScrollView(
|
|
padding: EdgeInsets.all(16),
|
|
child: Column(
|
|
children: [
|
|
if (Platform.isLinux)
|
|
SwitchListTile(
|
|
value: true,
|
|
onChanged: (V) {},
|
|
title: Text("Wine"),
|
|
),
|
|
ListTile(
|
|
title: Text("SteamCMD"),
|
|
leading: Icon(Icons.comment_rounded),
|
|
subtitle: settings.steamcmd_path.isEmpty
|
|
? Text("Path Not Set")
|
|
: Text(settings.steamcmd_path),
|
|
onTap: () {
|
|
if (settings.steamcmd_path.isNotEmpty) {
|
|
Navigator.pushNamed(context, "/steamcmd");
|
|
}
|
|
},
|
|
),
|
|
ListTile(
|
|
title: Text("Server Path"),
|
|
leading: Icon(CupertinoIcons.folder),
|
|
subtitle: settings.game_path.isEmpty
|
|
? Text("Not Set")
|
|
: Text(settings.game_path),
|
|
),
|
|
SwitchListTile(
|
|
value: settings.FTS,
|
|
onChanged: (B) {
|
|
setState(() {
|
|
settings.FTS = B;
|
|
});
|
|
},
|
|
title: Text("First Time Setup Mode"),
|
|
subtitle: Text(
|
|
"Enabling this will disable server startup, leaving only the wrapper interface to interact with."),
|
|
),
|
|
ListTile(
|
|
title: Text("Manager Credentials"),
|
|
subtitle:
|
|
Text("Edit ServerManager credentials (SUPER USER ONLY)"),
|
|
leading: Icon(Icons.key),
|
|
onTap: () async {
|
|
if (settings.loggedInUser!.permissions ==
|
|
UserLevel.Super_User) {
|
|
var reply = await Navigator.pushNamed(context, "/acl/edit",
|
|
arguments: settings.superuser);
|
|
if (reply != null) {
|
|
var creds = reply as User;
|
|
settings.superuser = creds;
|
|
}
|
|
}
|
|
},
|
|
),
|
|
ListTile(
|
|
title: Text("Manage Access Control List"),
|
|
subtitle: Text("Non-Super User access manager"),
|
|
leading: Icon(Icons.list),
|
|
onTap: () async {
|
|
Navigator.pushNamed(context, "/acl");
|
|
},
|
|
),
|
|
ListTile(
|
|
title: Text("Save Changes"),
|
|
subtitle: Text(
|
|
"This will upload the settings to the server and trigger a restart"),
|
|
onTap: () async {
|
|
Settings settings = Settings();
|
|
|
|
C2SUploadSettingsPacket upload = C2SUploadSettingsPacket();
|
|
upload.srvSettings = settings.serialize();
|
|
upload.performRestart = requireRestart;
|
|
|
|
await settings.client!.send(upload, !requireRestart);
|
|
Settings.Clear();
|
|
|
|
setState(() {});
|
|
|
|
if (requireRestart) {
|
|
Navigator.pop(context);
|
|
}
|
|
},
|
|
),
|
|
SwitchListTile(
|
|
value: requireRestart,
|
|
onChanged: (V) {
|
|
setState(() {
|
|
requireRestart = V;
|
|
});
|
|
},
|
|
title: Text("Perform Restart"),
|
|
subtitle: Text(
|
|
"Whether a immediate server restart should be performed in combination with this wrapper settings update"),
|
|
)
|
|
],
|
|
)),
|
|
);
|
|
}
|
|
}
|