Make skip counting file size for existing mods
This commit is contained in:
@@ -394,9 +394,19 @@ class _ModManagerPageState extends State<ModManagerPage> {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 24),
|
||||
ElevatedButton(
|
||||
onPressed: _startLoadingMods,
|
||||
child: const Text('Scan for Mods'),
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
ElevatedButton(
|
||||
onPressed: _startLoadingMods,
|
||||
child: const Text('Full Scan'),
|
||||
),
|
||||
const SizedBox(width: 16),
|
||||
ElevatedButton(
|
||||
onPressed: _startQuickScan,
|
||||
child: const Text('Quick Scan'),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -526,8 +536,23 @@ class _ModManagerPageState extends State<ModManagerPage> {
|
||||
// Reload button
|
||||
IconButton(
|
||||
icon: const Icon(Icons.refresh),
|
||||
tooltip: 'Reload mods',
|
||||
tooltip: 'Reload all mods (full scan)',
|
||||
onPressed: _startLoadingMods,
|
||||
style: IconButton.styleFrom(
|
||||
backgroundColor: Colors.blueGrey.shade800,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
// Scan New button
|
||||
IconButton(
|
||||
icon: const Icon(Icons.update),
|
||||
tooltip: 'Quick scan (skip existing mods)',
|
||||
onPressed: _startQuickScan,
|
||||
style: IconButton.styleFrom(
|
||||
backgroundColor: Colors.green.shade800,
|
||||
foregroundColor: Colors.white,
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
// Load Dependencies button
|
||||
@@ -1270,6 +1295,59 @@ class _ModManagerPageState extends State<ModManagerPage> {
|
||||
loadMods();
|
||||
}
|
||||
|
||||
void _startQuickScan() {
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
_statusMessage = 'Quick scanning for mods...';
|
||||
_hasCycles = false;
|
||||
_cycleInfo = null;
|
||||
_incompatibleMods = [];
|
||||
});
|
||||
|
||||
// Create an async function to load mods
|
||||
Future<void> loadMods() async {
|
||||
try {
|
||||
// First load available mods with the quick option
|
||||
await for (final mod in modManager.loadAvailable(skipExistingSizes: true)) {
|
||||
// Update UI for each mod loaded
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_statusMessage = 'Loaded mod: ${mod.name}';
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Then load active mods from config
|
||||
await for (final mod in modManager.loadActive()) {
|
||||
// Update UI as active mods are loaded
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_statusMessage = 'Loading active mod: ${mod.name}';
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Update the UI with all loaded mods
|
||||
if (mounted) {
|
||||
_loadModsFromGlobalState();
|
||||
setState(() {
|
||||
_statusMessage = 'Quick scan complete: ${_availableMods.length} mods, ${_activeMods.length} active';
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_isLoading = false;
|
||||
_statusMessage = 'Error during quick scan: $error';
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Start the loading process
|
||||
loadMods();
|
||||
}
|
||||
|
||||
void _toggleModActive(Mod mod) {
|
||||
// Cannot deactivate base game or expansions
|
||||
if ((mod.isBaseGame || mod.isExpansion) && mod.enabled) {
|
||||
|
@@ -130,7 +130,7 @@ class ModList {
|
||||
return newModlist;
|
||||
}
|
||||
|
||||
Stream<Mod> loadAvailable() async* {
|
||||
Stream<Mod> loadAvailable({bool skipExistingSizes = false}) async* {
|
||||
final logger = Logger.instance;
|
||||
final stopwatch = Stopwatch()..start();
|
||||
|
||||
@@ -160,12 +160,12 @@ class ModList {
|
||||
continue;
|
||||
}
|
||||
|
||||
final mod = Mod.fromDirectory(modDir);
|
||||
final mod = Mod.fromDirectory(modDir, skipFileCount: skipExistingSizes);
|
||||
logger.info('Loaded mod from directory: ${mod.name} (ID: ${mod.id})');
|
||||
|
||||
if (mods.containsKey(mod.id)) {
|
||||
logger.warning(
|
||||
'Mod $mod.id already exists in mods list, overwriting',
|
||||
'Mod ${mod.id} already exists in mods list, overwriting',
|
||||
);
|
||||
final existingMod = mods[mod.id]!;
|
||||
mods[mod.id] = Mod(
|
||||
|
Reference in New Issue
Block a user