From 4e39d93cd2ae98c8e84bc18fe01cba192dd6f0ef Mon Sep 17 00:00:00 2001 From: ghostboats <106226990+ghostboats@users.noreply.github.com> Date: Tue, 14 May 2024 14:27:30 -0500 Subject: [PATCH] add remove from exlclusion list and conversion tweaks --- extension.js | 19 +++++++++++++++---- package.json | 12 +++++++++++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/extension.js b/extension.js index de52971f..fc861e37 100644 --- a/extension.js +++ b/extension.js @@ -35,10 +35,7 @@ const { resizeImageTooltip, resizeImageController, resizeImageHotbar, resizeImag const { getFullPath } = require('./support_files/helper_functions'); -/** - * Adds a file to the exclusion list. - * @param {vscode.Uri} fileUri - The URI of the file to be excluded. - */ + async function addToExcludeList(fileUri) { const config = vscode.workspace.getConfiguration('bg3ModHelper'); let excludedFiles = config.get('excludedFiles') || []; @@ -54,6 +51,19 @@ async function addToExcludeList(fileUri) { } } +async function removeFromExcludeList(fileUri) { + const config = vscode.workspace.getConfiguration('bg3ModHelper'); + let excludedFiles = config.get('excludedFiles') || []; + const filePath = fileUri.fsPath.replace(/\\/g, '/'); + + if (excludedFiles.includes(filePath)) { + excludedFiles = excludedFiles.filter(p => p !== filePath); // Remove the file from the list + await config.update('excludedFiles', excludedFiles, vscode.ConfigurationTarget.Global); + vscode.window.showInformationMessage(`${filePath} removed from conversion exclusion list.`); + } else { + vscode.window.showWarningMessage(`${filePath} not in the exclusion list.`); + } +} /** * @param {vscode.ExtensionContext} context @@ -146,6 +156,7 @@ function activate(context) { let createModTemplateCommand = vscode.commands.registerCommand('bg3-mod-helper.createModTemplate', createModTemplateImport); context.subscriptions.push(vscode.commands.registerCommand('bg3-mod-helper.addToExcludeList', addToExcludeList)); + context.subscriptions.push(vscode.commands.registerCommand('bg3-mod-helper.removeFromExcludeList', removeFromExcludeList)); context.subscriptions.push(uuidsHandlesHoverProvider, functionsHoverProvider, DDSToPNG, PNGToDDS, resizeTooltipCommand, resizeControllerCommand, resizeHotbarCommand, resizeCustomCommand, createModTemplateCommand, addIconBackgroundCommand, openConverterCommand, versionGeneratorCommand, rotationToolCommand); } diff --git a/package.json b/package.json index 4a28e348..484a4b63 100644 --- a/package.json +++ b/package.json @@ -151,6 +151,11 @@ "title": "Add to Conversion Exclusion List", "category": "BG3 Mod Helper" }, + { + "command": "bg3-mod-helper.removeFromExcludeList", + "title": "Remove from Conversion Exclusion List", + "category": "BG3 Mod Helper" + }, { "command": "bg3-mod-helper.debugCommand", "title": "For dev use, dont press the button" @@ -285,9 +290,14 @@ "group": "navigation" }, { - "when": "resourceExtname == .lsx || resourceExtname == .loca || resourceExtname == .xml || resourceExtname == .lsf", + "when": "resourceExtname == .lsx || resourceExtname == .loca || resourceExtname == .xml || resourceExtname == .lsf && !isExcluded", "command": "bg3-mod-helper.addToExcludeList", "group": "navigation" + }, + { + "when": "resourceExtname == .lsx || resourceExtname == .loca || resourceExtname == .xml || resourceExtname == .lsf && isExcluded", + "command": "bg3-mod-helper.removeFromExcludeList", + "group": "navigation" } ], "editor/context": [