2022-03-09 06:35:20 +00:00
|
|
|
import { WorkerPool } from "./WorkerPool";
|
|
|
|
import store from "./store";
|
|
|
|
import { clearPlugins, setPending } from "../slices/plugins";
|
|
|
|
|
|
|
|
export const excludedPlugins = [
|
|
|
|
"Skyrim.esm",
|
|
|
|
"Update.esm",
|
|
|
|
"Dawnguard.esm",
|
|
|
|
"HearthFires.esm",
|
|
|
|
"Dragonborn.esm",
|
|
|
|
];
|
|
|
|
|
|
|
|
export const isPluginPath = (path: string) => {
|
|
|
|
if (
|
|
|
|
path.endsWith(".esp") ||
|
|
|
|
path.endsWith(".esm") ||
|
|
|
|
path.endsWith(".esl")
|
|
|
|
) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
export const isPlugin = (file: File) => {
|
|
|
|
return isPluginPath(file.name);
|
|
|
|
}
|
|
|
|
|
|
|
|
export const parsePluginFiles = (pluginFiles: File[], workerPool: WorkerPool) => {
|
2022-03-10 05:40:34 +00:00
|
|
|
if (pluginFiles.length === 0) {
|
|
|
|
alert("Found no plugins in the folder. Please select the Data folder underneath the Skyrim installation folder.");
|
|
|
|
return;
|
|
|
|
}
|
2022-03-09 06:35:20 +00:00
|
|
|
store.dispatch(clearPlugins());
|
|
|
|
store.dispatch(setPending(pluginFiles.length));
|
|
|
|
|
|
|
|
pluginFiles.forEach(async (plugin) => {
|
|
|
|
const contents = new Uint8Array(await plugin.arrayBuffer());
|
|
|
|
workerPool.pushTask({
|
|
|
|
skipParsing: excludedPlugins.includes(plugin.name),
|
|
|
|
filename: plugin.name,
|
|
|
|
lastModified: plugin.lastModified,
|
|
|
|
contents,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|