More slight refactoring
This commit is contained in:
@@ -57,10 +57,10 @@ class ModList {
|
||||
path: mod.path,
|
||||
versions: mod.versions,
|
||||
description: mod.description,
|
||||
hardDependencies: mod.hardDependencies,
|
||||
dependencies: mod.dependencies,
|
||||
loadAfter: mod.loadAfter,
|
||||
loadBefore: mod.loadBefore,
|
||||
incompatabilities: mod.incompatabilities,
|
||||
incompatibilities: mod.incompatibilities,
|
||||
size: mod.size,
|
||||
enabled: existingMod.enabled,
|
||||
isBaseGame: existingMod.isBaseGame,
|
||||
@@ -147,12 +147,12 @@ class ModList {
|
||||
: isExpansion
|
||||
? "RimWorld expansion"
|
||||
: ""),
|
||||
hardDependencies: existingMod?.hardDependencies ?? [],
|
||||
dependencies: existingMod?.dependencies ?? [],
|
||||
loadAfter:
|
||||
existingMod?.loadAfter ??
|
||||
(isExpansion ? ['ludeon.rimworld'] : []),
|
||||
loadBefore: existingMod?.loadBefore ?? [],
|
||||
incompatabilities: existingMod?.incompatabilities ?? [],
|
||||
incompatibilities: existingMod?.incompatibilities ?? [],
|
||||
enabled: existingMod?.enabled ?? false,
|
||||
size: existingMod?.size ?? 0,
|
||||
isBaseGame: isBaseGame,
|
||||
@@ -162,7 +162,7 @@ class ModList {
|
||||
logger.warning('Mod $modId already exists in mods list, overwriting');
|
||||
}
|
||||
mods[modId] = mod;
|
||||
activeMods[modId] = true;
|
||||
setEnabled(modId, mod.enabled);
|
||||
yield mod;
|
||||
}
|
||||
|
||||
@@ -172,6 +172,28 @@ class ModList {
|
||||
throw Exception('Failed to load config file: $e');
|
||||
}
|
||||
}
|
||||
|
||||
void setEnabled(String modId, bool enabled) {
|
||||
if (mods.containsKey(modId)) {
|
||||
mods[modId]!.enabled = enabled;
|
||||
if (enabled) {
|
||||
activeMods[modId] = true;
|
||||
} else {
|
||||
activeMods.remove(modId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// List of mod ids
|
||||
List<String> sort() {
|
||||
final sortedMods = activeMods.keys.toList();
|
||||
sortedMods.sort((a, b) {
|
||||
final aIndex = mods[a]!.loadBefore.length;
|
||||
final bIndex = mods[b]!.loadBefore.length;
|
||||
return aIndex.compareTo(bIndex);
|
||||
});
|
||||
return sortedMods;
|
||||
}
|
||||
}
|
||||
|
||||
String _expansionNameFromId(String id) {
|
||||
|
Reference in New Issue
Block a user