Skip to content

Commit

Permalink
maybe maybe maybe
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostboats committed Sep 4, 2024
1 parent 1ca192f commit 571295f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
14 changes: 9 additions & 5 deletions commands/packMod.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ const { convert } = require('../support_files/conversion_junction.js');
const { getFormats } = require('../support_files/lslib_utils.js');
const { pak } = getFormats();

let hasPromptedForModDestPath = false;

const packModCommand = vscode.commands.registerCommand('bg3-mod-helper.packMod', async function (action) {
bg3mh_logger.info("pack button clicked", false);
const { rootModPath, modDestPath, lslibPath } = getConfig();
Expand All @@ -33,18 +35,20 @@ const packModCommand = vscode.commands.registerCommand('bg3-mod-helper.packMod',
const workspaceState = vscode.workspace.getConfiguration('bg3ModHelper');
const promptedForModDestPath = workspaceState.get('promptedForModDestPath', false);

if (!promptedForModDestPath) {
// Only show the prompt the first time
if (!hasPromptedForModDestPath) {
if (!modDestPath.includes(path.join("Larian Studios", "Baldur's Gate 3", "Mods"))) {
const useStandardPath = await vscode.window.showInformationMessage(
'The Mods destination path does not seem to be the standard Baldur\'s Gate 3 Mods folder. Do you want to change it?',
'Change to Standard', 'Keep Current'
'Change to Standard (REQUIRES RELOAD OF VSCODE)', 'Keep Current'
);
if (useStandardPath === 'Change to Standard') {
if (useStandardPath === 'Change to Standard (REQUIRES RELOAD OF VSCODE)') {
const standardPath = path.join(process.env.LOCALAPPDATA, "Larian Studios", "Baldur's Gate 3", "Mods");
await vscode.workspace.getConfiguration('bg3ModHelper').update('modDestPath', standardPath, vscode.ConfigurationTarget.Global);
} else {
await workspaceState.update('promptedForModDestPath', true);
}

// Set the flag to true to prevent the prompt from appearing again
hasPromptedForModDestPath = true;
}
}

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion support_files/release_notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@ function generateReleaseNotes(version) {
details: [
"Will now correctly zip .pak in a .zip folder (which Nexus accepts) instead of a .gz folder (which Nexus does not accept)",
"Zipping files is now done thru the data provider menu, expand the dropdown for packing and select Pack and Zip",
"Zipped files appear in correct location now"
"Zipped files appear in correct location now",
"Pak file is deleted now if zip is made"
]
},
{
Expand Down
6 changes: 5 additions & 1 deletion support_files/zip_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ let zip = new JSZip();

async function zipUpPak(zipPak) {
let rootModPath = getConfig.rootModPath;
let modDestPath = getConfig.modDestPath;
let lastFolderName = path.basename(rootModPath);
let zipPath = path.join(rootModPath, `${lastFolderName}.zip`);
let zipPath = path.join(modDestPath, `${lastFolderName}.zip`);

let temp_folder = path.join(path.sep, "temp_folder");
let pakFilePath = path.join(path.join(path.dirname(rootModPath), temp_folder), lastFolderName + pak);
Expand All @@ -37,6 +38,9 @@ async function zipUpPak(zipPak) {

bg3mh_logger.info(`Zip file has been created at ${zipPath}`, false);

await promisify(fs.unlink)(pakFilePath);
bg3mh_logger.info(`Original .pak file has been deleted at ${pakFilePath}`, false);

if (isMainThread) {
vscode.window.showInformationMessage(`${lastFolderName}.zip created`);
}
Expand Down

0 comments on commit 571295f

Please sign in to comment.