Skip to content

Commit

Permalink
hmmm
Browse files Browse the repository at this point in the history
  • Loading branch information
khbsd committed Jun 1, 2024
1 parent 1694bb2 commit 20b4a2f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
5 changes: 3 additions & 2 deletions commands/packMod.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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') {
Expand Down
4 changes: 3 additions & 1 deletion extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ function aSimpleDataProvider() {
}


function deactivate() {}
function deactivate() {
saveConfigFile();
}


module.exports = {
Expand Down
24 changes: 13 additions & 11 deletions support_files/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down Expand Up @@ -111,27 +112,29 @@ 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}`)
}
}


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}`);
Expand Down Expand Up @@ -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);
}

Expand Down
2 changes: 2 additions & 0 deletions support_files/process_pak.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 20b4a2f

Please sign in to comment.