Add some basic initial functionality to download mods
This commit is contained in:
parent
64f5e3c267
commit
906191e4d5
3 changed files with 73 additions and 1 deletions
|
@ -92,6 +92,46 @@ class GameServerPageState extends State<GameServerPage> {
|
|||
Navigator.pushNamed(context, "/server/mods");
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text("Download Mods"),
|
||||
subtitle: Text("Downloads the mods"),
|
||||
leading: Icon(Icons.download_sharp),
|
||||
onTap: () async {
|
||||
// Triggers the download status
|
||||
setState(() {
|
||||
downloading = true;
|
||||
});
|
||||
|
||||
// Now, invoke SteamCmd to download the workshop mods. This is an authenticated action, and does require Scmd2fa
|
||||
var result = await Process.run(settings.getSteamCmd2FA(),
|
||||
["--raw", "--secret", settings.steam_creds!.secret]);
|
||||
var code = result.stdout;
|
||||
// Build download command
|
||||
|
||||
List<String> manifest = [
|
||||
"+@sSteamCmdForcePlatformType",
|
||||
"windows",
|
||||
"+force_install_dir",
|
||||
settings.getModPath(),
|
||||
"+login",
|
||||
settings.steam_creds!.username,
|
||||
settings.steam_creds!.password,
|
||||
code
|
||||
];
|
||||
for (Mod M in settings.mods) {
|
||||
manifest.add("+workshop_download_item");
|
||||
manifest.add("${M.mod_id}");
|
||||
}
|
||||
|
||||
result =
|
||||
await Process.run(settings.getSteamCmd(), manifest);
|
||||
|
||||
// Unset downloading
|
||||
setState(() {
|
||||
downloading = false;
|
||||
});
|
||||
},
|
||||
),
|
||||
ListTile(
|
||||
title: Text("Status:"),
|
||||
subtitle: Text("Not Running"),
|
||||
|
@ -211,6 +251,7 @@ class ModPage extends StatelessWidget {
|
|||
String instance = "";
|
||||
bool isNewMod = false;
|
||||
bool willDelete = false;
|
||||
String pak = "Not initialized";
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
@ -223,6 +264,7 @@ class ModPage extends StatelessWidget {
|
|||
name.text = args.mod_name;
|
||||
isNewMod = args.newMod;
|
||||
instance = args.mod_instance_id();
|
||||
pak = args.mod_pak;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -280,6 +322,11 @@ class ModPage extends StatelessWidget {
|
|||
title: Text("Mod Instance ID"),
|
||||
subtitle: Text(instance),
|
||||
),
|
||||
ListTile(
|
||||
title: Text("Mod Pak File: $pak"),
|
||||
subtitle:
|
||||
Text("Mod pak file name as detected during downloading"),
|
||||
),
|
||||
if (!isNewMod)
|
||||
ElevatedButton(
|
||||
onPressed: () {
|
||||
|
|
|
@ -11,6 +11,9 @@ class Mod {
|
|||
@HiveField(1)
|
||||
int mod_id;
|
||||
|
||||
@HiveField(2)
|
||||
String mod_pak;
|
||||
|
||||
bool newMod = false;
|
||||
String _id = "";
|
||||
String mod_instance_id() {
|
||||
|
@ -21,5 +24,9 @@ class Mod {
|
|||
return _id;
|
||||
}
|
||||
|
||||
Mod({this.mod_name = "undef", this.mod_id = 0, this.newMod = false});
|
||||
Mod(
|
||||
{this.mod_name = "undef",
|
||||
this.mod_id = 0,
|
||||
this.newMod = false,
|
||||
this.mod_pak = "Not Initialized"});
|
||||
}
|
||||
|
|
|
@ -77,6 +77,24 @@ class Settings {
|
|||
(Platform.isWindows ? ".exe" : ".sh");
|
||||
}
|
||||
|
||||
String getSteamCmd2FA() {
|
||||
return steamcmd_path +
|
||||
Platform.pathSeparator +
|
||||
"steamcmd-2fa" +
|
||||
(Platform.isWindows ? ".exe" : "");
|
||||
}
|
||||
|
||||
String getModPath() {
|
||||
return game_path + Platform.pathSeparator + "mods";
|
||||
}
|
||||
|
||||
void assertModsFolderExists() {
|
||||
if (Directory(getModPath()).existsSync())
|
||||
return;
|
||||
else
|
||||
Directory(getModPath()).createSync(recursive: true);
|
||||
}
|
||||
|
||||
bool serverInstalled() {
|
||||
return File(
|
||||
getServerPath() + Platform.pathSeparator + "ConanSandboxServer.exe")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue