Rework saving to config
This commit is contained in:
@@ -1325,47 +1325,7 @@ class _ModManagerPageState extends State<ModManagerPage> {
|
||||
'Saving mod load order for ${_activeMods.length} active mods to $configPath',
|
||||
);
|
||||
|
||||
// Save the mod list to the XML config file
|
||||
final file = File(configPath);
|
||||
final buffer = StringBuffer();
|
||||
|
||||
buffer.writeln('<?xml version="1.0" encoding="utf-8"?>');
|
||||
buffer.writeln('<ModsConfigData>');
|
||||
buffer.writeln(' <version>1</version>');
|
||||
|
||||
// Write active mods
|
||||
buffer.writeln(' <activeMods>');
|
||||
for (final mod in _activeMods) {
|
||||
buffer.writeln(' <li>${mod.id}</li>');
|
||||
logger.info(' - Adding mod to config: ${mod.name} (${mod.id})');
|
||||
}
|
||||
buffer.writeln(' </activeMods>');
|
||||
|
||||
// Count expansions
|
||||
final expansions = _availableMods.where((m) => m.isExpansion).toList();
|
||||
logger.info('Found ${expansions.length} expansions to include in config');
|
||||
|
||||
// Add known expansions
|
||||
buffer.writeln(' <knownExpansions>');
|
||||
for (final mod in expansions) {
|
||||
buffer.writeln(' <li>${mod.id}</li>');
|
||||
logger.info(' - Adding expansion to config: ${mod.name} (${mod.id})');
|
||||
}
|
||||
buffer.writeln(' </knownExpansions>');
|
||||
|
||||
buffer.writeln('</ModsConfigData>');
|
||||
|
||||
// Ensure directory exists
|
||||
final directory = Directory(configRoot);
|
||||
if (!directory.existsSync()) {
|
||||
logger.info('Creating config directory: $configRoot');
|
||||
directory.createSync(recursive: true);
|
||||
}
|
||||
|
||||
// Write to file
|
||||
logger.info('Writing config file to $configPath');
|
||||
await file.writeAsString(buffer.toString());
|
||||
logger.info('Successfully saved mod configuration');
|
||||
modManager.saveToConfig(LoadOrder(_activeMods));
|
||||
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
|
Reference in New Issue
Block a user