-
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.
- Loading branch information
1 parent
5fad752
commit 967a4e3
Showing
10 changed files
with
100 additions
and
23 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,22 +1,58 @@ | ||
const vscode = require('vscode'); | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const { getConfig } = require('../support_files/config'); | ||
|
||
const { FILTER_PATHS, FIND_FILES, getFormats } = require('../support_files/lslib_utils'); | ||
const { xml, lsx } = getFormats(); | ||
const debugCommand = vscode.commands.registerCommand('bg3-mod-helper.debugCommand', async function () { | ||
const config = getConfig(); | ||
const localizationPath = path.join(config.rootModPath, 'Localization'); | ||
|
||
const { rootModPath } = require('../support_files/config.js').getConfig(); | ||
try { | ||
// Step 1: List subdirectories | ||
const directories = fs.readdirSync(localizationPath, { withFileTypes: true }) | ||
.filter(dirent => dirent.isDirectory()) | ||
.map(dirent => dirent.name); | ||
|
||
const { CREATE_LOGGER, raiseInfo } = require('../support_files/log_utils'); | ||
var bg3mh_logger = CREATE_LOGGER(); | ||
// Step 2: Show QuickPick for subdirectories | ||
const selectedDirectory = await vscode.window.showQuickPick(directories, { | ||
placeHolder: 'Select a Localization folder to merge' | ||
}); | ||
|
||
var test_paths; | ||
if (!selectedDirectory) return; | ||
|
||
let debugCommand = vscode.commands.registerCommand('bg3-mod-helper.debugCommand', async function () { // Made the function async | ||
console.log('‾‾debugCommand‾‾'); | ||
vscode.window.showWarningMessage( | ||
'cmon dude i said no :(' | ||
) | ||
// Step 3: List XML files in the selected subdirectory | ||
const selectedDirPath = path.join(localizationPath, selectedDirectory); | ||
const xmlFiles = fs.readdirSync(selectedDirPath, { withFileTypes: true }) | ||
.filter(dirent => dirent.isFile() && dirent.name.endsWith('.xml')) | ||
.map(dirent => dirent.name); | ||
|
||
console.log('__debugCommand__'); | ||
// Step 4: Use QuickPick to select XML files | ||
const selectedFiles = await vscode.window.showQuickPick(xmlFiles, { | ||
canPickMany: true, | ||
placeHolder: 'Select XML files to merge' | ||
}); | ||
|
||
if (!selectedFiles || selectedFiles.length === 0) return; | ||
|
||
// Step 5: Ask for save location | ||
const uri = await vscode.window.showSaveDialog({ | ||
defaultUri: vscode.Uri.file(path.join(selectedDirPath, 'xml_merged.xml')), | ||
filters: { 'XML files': ['xml'] } | ||
}); | ||
|
||
if (!uri) return; | ||
|
||
// Step 6: Read and merge selected XML files | ||
const mergedContent = selectedFiles | ||
.map(file => fs.readFileSync(path.join(selectedDirPath, file), 'utf8')) | ||
.join('\n'); | ||
|
||
// Step 7: Save the merged file | ||
fs.writeFileSync(uri.fsPath, mergedContent, 'utf8'); | ||
vscode.window.showInformationMessage('XML files merged and saved successfully!'); | ||
} catch (error) { | ||
vscode.window.showErrorMessage('Error merging XML files: ' + error.message); | ||
} | ||
}); | ||
|
||
module.exports = debugCommand; |
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
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
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