Update download mods function with more feedback

This commit is contained in:
zontreck 2023-11-04 14:16:53 -07:00
parent d8345d08fa
commit 239eac82b2
2 changed files with 19 additions and 9 deletions

View file

@ -149,7 +149,8 @@ class GameServerPageState extends State<GameServerPage> {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text("Scanning mods...")));
for (Mod M in settings.inst!.mods) {
for (Mod M in settings.inst!.mods.toList()) {
var index = settings.inst!.mods.indexOf(M);
// Assemble final path.
String modsPath = PathHelper.builder(settings.game_path)
.resolve("mods")
@ -172,6 +173,12 @@ class GameServerPageState extends State<GameServerPage> {
M.mod_pak = name;
M.mod_hash = hash;
print("Discovered mod file: ${name}");
print("Hash: ${hash}");
// Update the mod instance
settings.inst!.mods[index] = M;
}
}
}
@ -179,6 +186,9 @@ class GameServerPageState extends State<GameServerPage> {
setState(() {
settings.Write();
});
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text("Mods have been scanned")));
},
),
ListTile(

View file

@ -5,17 +5,17 @@ part 'mod.g.dart';
@HiveType(typeId: 2)
class Mod {
@HiveField(0)
String mod_name;
@HiveField(0, defaultValue: "")
String mod_name = "";
@HiveField(1)
int mod_id;
@HiveField(1, defaultValue: 0)
int mod_id = 0;
@HiveField(2)
String mod_pak;
@HiveField(2, defaultValue: "")
String mod_pak = "";
@HiveField(3)
String mod_hash;
@HiveField(3, defaultValue: "")
String mod_hash = "";
bool newMod = false;
String _id = "";