-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
unpacking file selection and dropoff location added as well as packag…
…e.json version and lock
- Loading branch information
1 parent
dbaf936
commit 00437de
Showing
6 changed files
with
51 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,48 @@ | ||
const vscode = require('vscode'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const util = require('util'); | ||
|
||
const { exec } = require('child_process') | ||
const execAsync = util.promisify(require('child_process').exec); | ||
|
||
const { convert } = require('../support_files/conversion_junction.js'); | ||
|
||
const { getFormats } = require('../support_files/lslib_utils.js'); | ||
const { pak } = getFormats(); | ||
const { getConfig } = require('../support_files/config'); | ||
const { rootModPath } = getConfig(); | ||
|
||
const { convert } = require('../support_files/conversion_junction.js'); | ||
const { processPak } = require('../support_files/process_pak.js') | ||
|
||
const unpackModCommand = vscode.commands.registerCommand('bg3-mod-helper.unpackMod', async function () { | ||
const { getModName } = require('../support_files/helper_functions'); | ||
let modName = await getModName(); | ||
|
||
console.log(`Unpacking mod ${modName}.`) | ||
|
||
convert(path.join(rootModPath, modName + pak)); | ||
|
||
}); | ||
const pakFileUri = await vscode.window.showOpenDialog({ | ||
canSelectFiles: true, | ||
canSelectFolders: false, | ||
canSelectMany: false, | ||
filters: { 'PAK Files': ['pak'] }, | ||
title: 'Select a .pak file to unpack' | ||
}); | ||
|
||
if (!pakFileUri) { | ||
vscode.window.showInformationMessage('No file selected.'); | ||
return; | ||
} | ||
|
||
const outputFolderUri = await vscode.window.showOpenDialog({ | ||
canSelectFiles: false, | ||
canSelectFolders: true, | ||
canSelectMany: false, | ||
title: 'Select a folder to unpack the .pak file into' | ||
}); | ||
|
||
if (!outputFolderUri) { | ||
vscode.window.showInformationMessage('No folder selected.'); | ||
return; | ||
} | ||
|
||
const pakFilePath = pakFileUri[0].fsPath; | ||
const baseOutputFolderPath = outputFolderUri[0].fsPath; | ||
const pakFileName = path.basename(pakFilePath, path.extname(pakFilePath)); | ||
|
||
// Create a unique folder for the unpacked contents | ||
const outputFolderPath = path.join(baseOutputFolderPath, `${pakFileName}_unpacked`); | ||
|
||
try { | ||
await fs.promises.mkdir(outputFolderPath, { recursive: true }); | ||
await processPak(pakFilePath, 'n/a', outputFolderPath); | ||
vscode.window.showInformationMessage(`Successfully unpacked ${path.basename(pakFilePath)} to ${outputFolderPath}`); | ||
} catch (error) { | ||
vscode.window.showErrorMessage(`Failed to unpack .pak file: ${error.message}`); | ||
} | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters