diff --git a/commands/packMod.js b/commands/packMod.js index ad6c8777..7b941943 100644 --- a/commands/packMod.js +++ b/commands/packMod.js @@ -24,8 +24,8 @@ const packModCommand = vscode.commands.registerCommand('bg3-mod-helper.packMod', const { rootModPath, modDestPath, lslibPath, autoLaunchOnPack } = getConfig(); const modName = await getModName(); - const modsDirPath = path.normalize(rootModPath + "\\Mods"); - const metaPath = path.normalize(modsDirPath + "\\" + modName + "\\meta.lsx"); + const modsDirPath = path.join(rootModPath, "Mods"); + const metaPath = path.join(modsDirPath, modName, "meta.lsx"); // Check if BG3 is running const isRunning = await isGameRunning(); @@ -50,6 +50,7 @@ const packModCommand = vscode.commands.registerCommand('bg3-mod-helper.packMod', bg3mh_logger.info("Grabbed mod name %s from %s.", modName, rootModPath); + console.log(metaPath); if (!fs.existsSync(metaPath)) { const shouldCreateMeta = await vscode.window.showInformationMessage('meta.lsx not found in ' + metaPath + '. Do you want to create one?', 'Create Meta', 'Close'); if (shouldCreateMeta === 'Create Meta') { diff --git a/extension.js b/extension.js index 2d0d41e1..568b09fe 100644 --- a/extension.js +++ b/extension.js @@ -210,7 +210,9 @@ function aSimpleDataProvider() { } -function deactivate() {} +function deactivate() { + saveConfigFile(); +} module.exports = { diff --git a/support_files/config.js b/support_files/config.js index 605e179a..ee451dfc 100644 --- a/support_files/config.js +++ b/support_files/config.js @@ -17,7 +17,7 @@ function stringify(jsonObj) { return JSON.stringify(jsonObj, null, 4) } - +// this is probably causing issues. gonna need to come up with a better solution. function setConfig(newConfig) { config = newConfig; } @@ -35,6 +35,7 @@ function startUpConfig() { initVariables(); console.log(`root mod path set too: \n${getConfig().rootModPath}`); setModName(mainFolderPath); + console.log(`modName set to ${getModName()}`); // checkConfigFile(); checkModDir(); saveConfigFile(config); @@ -111,7 +112,7 @@ function setModName(rootPath = getConfig().rootModPath) { if (directories.length === 1 && temp_name == "") { console.log(`modName set to ${directories[0]}`) config.update('modName', directories[0], vscode.ConfigurationTarget.Workspace); - console.log(getConfig().modName); + console.log(getModName()); saveConfigFile(); } else { console.log(`modName kept as ${temp_name}`) @@ -119,19 +120,21 @@ function setModName(rootPath = getConfig().rootModPath) { } -function getModName(rootModPath = getConfig().rootModPath) { - // setModName(rootModPath); - return getConfig().modName; +function getModName() { + config = vscode.workspace.getConfiguration('bg3ModHelper'); + return config.get('modName'); } function checkModDir() { const modsDirPath = path.join(getConfig().rootModPath, 'Mods'); + + bg3mh_logger.info(modsDirPath); + console.log(modsDirPath); + try { if (!fs.existsSync(modsDirPath)) { vscode.window.showErrorMessage('Mods directory does not exist.'); - bg3mh_logger.info(modsDirPath); - console.log(modsDirPath); } } catch (error) { raiseError(`Error reading directories in ${modsDirPath}: ${error}`); @@ -160,18 +163,17 @@ function saveConfigFile(settingsToSave = "all" || {}) { } } catch (error) { console.error(error); - setConfig(getConfig()); + // setConfig(getConfig()); } if (settingsToSave === "all") { - setConfig(getConfig()); + // setConfig(getConfig()); } else { - setConfig(settingsToSave); + // setConfig(settingsToSave); } let settingsJson = stringify(config); - console.log(getConfig().modName); fs.writeFileSync(settingsFilePath, settingsJson); } diff --git a/support_files/process_pak.js b/support_files/process_pak.js index ff6d3c6b..48788256 100644 --- a/support_files/process_pak.js +++ b/support_files/process_pak.js @@ -28,8 +28,10 @@ async function lslib_load() { function prepareTempDir(movedPak = false) { let rootModPath; if (isMainThread) { + getConfig = require('./config.js').getConfig(); rootModPath = getConfig.rootModPath; } else { + getConfig = workerData.workerConfig; rootModPath = getConfig.rootModPath; }