diff --git a/commands/insertHandleUUID.js b/commands/insertHandleUUID.js index 0fdc6571..bcc72803 100644 --- a/commands/insertHandleUUID.js +++ b/commands/insertHandleUUID.js @@ -142,7 +142,7 @@ let handleReplaceDisposable = vscode.commands.registerCommand('bg3-mod-helper.ge let documentsToSave = new Set(); // Search across all text files in the workspace - const files = await vscode.workspace.findFiles('**/*.{txt,lsx,lsj,xml}'); + const files = await vscode.workspace.findFiles('**/*.{txt,lsx,lsj,xml,json}'); for (const file of files) { const textDoc = await vscode.workspace.openTextDocument(file); const text = textDoc.getText(); diff --git a/extension.js b/extension.js index be29ea3c..3743d679 100644 --- a/extension.js +++ b/extension.js @@ -53,7 +53,7 @@ const AutoCompleteProvider = require('./autocomplete/autoCompleteProvider'); const setupFunctionDescriptionHoverProvider = require('./hovers/functionDescriptions'); const { setupUuidsHandlesHoverProvider, registerTextEditCommand }= require('./hovers/uuidsHandlesCollector'); -const { getFullPath } = require('./support_files/helper_functions'); +const { getFullPath, getVersionNumber } = require('./support_files/helper_functions'); function setCommands() { @@ -218,7 +218,8 @@ function aSimpleDataProvider() { }, getChildren: (element) => { if (!element) { - return Promise.resolve([ + const version = getVersionNumber() + return getVersionNumber().then(version => [ // ideas for more dropdown menus: image utilities, generators, debug { label: 'Pack/Unpacking Tool (Click arrow for quick actions, or text to open the tool[tool is in development])', id: 'packer' }, { label: 'Conversion Tool (Click arrow for quick actions, or text to open the tool)', command: 'bg3-mod-helper.openConverter', id: 'conversion' }, @@ -229,7 +230,7 @@ function aSimpleDataProvider() { { label: 'Atlas Generator (Supply a folder of icons to make an atlas and its corresponding .dds with those icons, as well as its merged.lsx)', command: 'bg3-mod-helper.createAtlas' }, { label: 'BBCode/Markdown Editor ', command: 'bg3-mod-helper.textEditorTool'}, { label: 'Convert Video to GIF', command: 'bg3-mod-helper.convertVideoToGif' }, - { label: 'Version Generator', command: 'bg3-mod-helper.versionGenerator' }, + { label: `Ver. Generator (${version})`, command: 'bg3-mod-helper.versionGenerator' }, { label: 'Merge Xmls', command: 'bg3-mod-helper.xmlMerger' }, { label: 'Add/Remove Symlink (in development)', command: 'bg3-mod-helper.symlinker' }, { label: 'Rotation Tool (in development)', command: 'bg3-mod-helper.rotationTool' }, diff --git a/hovers/uuidsHandlesCollector.js b/hovers/uuidsHandlesCollector.js index 9b8a6bd0..7c7f3d53 100644 --- a/hovers/uuidsHandlesCollector.js +++ b/hovers/uuidsHandlesCollector.js @@ -10,7 +10,7 @@ function escapeHtml(str) { } function setupUuidsHandlesHoverProvider() { - return vscode.languages.registerHoverProvider({ scheme: 'file' }, { + return vscode.languages.registerHoverProvider('*', { provideHover(document, position, token) { const { hoverEnabled, maxFilesToShow, maxCacheSize } = getConfig(); if (!hoverEnabled) return; @@ -49,6 +49,7 @@ function setupUuidsHandlesHoverProvider() { const normalizedPath = relativePath.replace(/\\/g, '/').toLowerCase(); console.log(relativePath) console.log(normalizedPath) + const extension = path.extname(relativePath).toLowerCase(); // Check if the file is within the Localization folder if (normalizedPath.includes('localization/')) { // Process as a localization-related file @@ -56,6 +57,10 @@ function setupUuidsHandlesHoverProvider() { let highlightedLineContent = contentMatch ? escapeHtml(contentMatch[1]) : ''; const commandUri = `command:extension.editText?${encodeURIComponent(JSON.stringify({ word: highlightedLineContent, range: { lineNum, path: relativePath } }))}`; currentLine = `Loca Content: ***[${highlightedLineContent}](${commandUri})***\nFile: [${relativePath}](command:extension.openFileAtLine?${encodeURIComponent(JSON.stringify({ relativePath, lineNum }))})\n---\n`; + } else if (extension === '.json') { + // Process as a JSON file + let highlightedLineContent = escapeHtml(lineContent.trim()); + currentLine = `JSON Line: ${highlightedLineContent} \nFile: [**${relativePath}**](${openFileCommandUri}) \n--- \n`; } else { let modifiedLineContent = lineContent.replace(/^<\/?|\/?>$/g, ''); let highlightedLineContent = modifiedLineContent.replace(/(id="[^"]*")/g, '**$1**'); diff --git a/package-lock.json b/package-lock.json index 7ac82e18..5836bccb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bg3-mod-helper", - "version": "2.2.57", + "version": "2.2.59", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "bg3-mod-helper", - "version": "2.2.57", + "version": "2.2.59", "license": "LGPL-3.0-or-later", "dependencies": { "ffmpeg-static": "^5.2.0", diff --git a/package.json b/package.json index 2e191857..2eed7027 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "displayName": "bg3_mod_helper", "publisher": "ghostboats", "description": "This extension is designed to help you make mods in Baldur's Gate 3 by creating UUIDs and handles for you, as well as updating your .loca.xml files as well should they exist. And more to come in the future.", - "version": "2.2.58", + "version": "2.2.59", "icon": "media/marketplace_icon.png", "engines": { "vscode": "^1.86.0" diff --git a/support_files/helper_functions.js b/support_files/helper_functions.js index 807b737b..312ef3c0 100644 --- a/support_files/helper_functions.js +++ b/support_files/helper_functions.js @@ -1,6 +1,7 @@ const vscode = require('vscode'); const path = require('path'); const fs = require('fs'); +const { getConfig, getModName } = require('../support_files/config'); const { CREATE_LOGGER, raiseInfo } = require('./log_utils'); var bg3mh_logger = CREATE_LOGGER(); @@ -16,7 +17,6 @@ function insertText(text) { } } - function getFullPath(relativePath) { if (vscode.workspace.workspaceFolders && vscode.workspace.workspaceFolders.length > 0) { // Get the path of the first workspace folder @@ -35,18 +35,18 @@ function getFullPath(relativePath) { // Function to find instances in workspace async function findInstancesInWorkspace(word, currentFilePath, maxFilesToShow) { bg3mh_logger.debug('‾‾findInstanceInWorkspace‾‾'); - bg3mh_logger.debug('word: ',word,'\ncurrentFilePath: ',currentFilePath,'\nmaxFilesToShow: ',maxFilesToShow); + bg3mh_logger.debug('word: ', word, '\ncurrentFilePath: ', currentFilePath, '\nmaxFilesToShow: ', maxFilesToShow); let instances = []; const workspaceFolder = vscode.workspace.workspaceFolders[0]; const workspacePath = workspaceFolder.uri.fsPath; - let searchPath = new vscode.RelativePattern(workspacePath, '{**/*.lsx,**/*.lsj,**/*.xml,**/*.txt}'); + let searchPath = new vscode.RelativePattern(workspacePath, '{**/*.lsx,**/*.lsj,**/*.xml,**/*.txt,**/*.txt}'); const excludePattern = '**/*.lsf,**/node_modules/**,**/*.loca'; const files = await vscode.workspace.findFiles(searchPath, excludePattern); for (const file of files) { if (file.fsPath === currentFilePath) continue; - + const relativePath = vscode.workspace.asRelativePath(file.fsPath); const document = await vscode.workspace.openTextDocument(file); @@ -60,14 +60,42 @@ async function findInstancesInWorkspace(word, currentFilePath, maxFilesToShow) { } if (instances.length >= maxFilesToShow) break; } - bg3mh_logger.debug('Found Instances:\n',instances) - bg3mh_logger.debug('__findInstanceInWorkspace__') + bg3mh_logger.debug('Found Instances:\n', instances); + bg3mh_logger.debug('__findInstanceInWorkspace__'); return instances; } +async function getVersionNumber() { + const { rootModPath } = getConfig(); + const modName = await getModName(); + const modsDirPath = path.normalize(rootModPath + "\\Mods"); + const metaPath = path.normalize(modsDirPath + "\\" + modName + "\\meta.lsx"); + + if (!fs.existsSync(metaPath)) { + vscode.window.showErrorMessage('Version unable to be displayed in data provider, could not find meta.lsx.'); + return 'N/A'; + } + + try { + let content = fs.readFileSync(metaPath, 'utf8'); + + const regex = //; + const match = content.match(regex); + const version = BigInt(match[1]); + const major = Number((version >> BigInt(55)) & BigInt(0xFF)); + const minor = Number((version >> BigInt(47)) & BigInt(0xFF)); + const revision = Number((version >> BigInt(31)) & BigInt(0xFFFF)); + const build = Number(version & BigInt(0x7FFFFFFF)); + return `${major}.${minor}.${revision}.${build}`; + } catch (error) { + vscode.window.showErrorMessage("Error reading meta.lsx: " + error.message); + return 'N/A'; + } +} -module.exports = { - insertText, - findInstancesInWorkspace, - getFullPath -}; \ No newline at end of file +module.exports = { + insertText, + findInstancesInWorkspace, + getFullPath, + getVersionNumber +}; diff --git a/support_files/release_notes.js b/support_files/release_notes.js index 73c7c971..1c02c8fd 100644 --- a/support_files/release_notes.js +++ b/support_files/release_notes.js @@ -57,32 +57,15 @@ function generateReleaseNotes(version) { version: version, features: [ { - title: "Release Page Created", + title: "Changes", details: [ - "On launch of newly downloaded version of extension, launch release notes page showing newest updates, like this one :)" - ] - }, - { - title: "Mod Setting Changes [IMPORTANT]", - details: [ - "Choose to launch via directx or vulkan in the settings", - "Setting added to close the existing bg3 instance when you pack and play for quicker launch if you forgot to close. By default it is off.", - "If you have a unique mod destination path, the prompt will now only appear one time per session to avoid having to confirm each time on pack" - ] - }, - { - title: "Zipping Fixes", - details: [ - "Zipped files appear in correct location now (your set mod destination)", - "Pak file is deleted now if zip is made" + "I DONT REMEMBER, SORRY I DIDNT HAVE MY COMPUTER FOR OVER A MONTH AND FORGOT WHAT I DID" ] }, { title: "Minor Changes", details: [ - "Atlas Fix if .lsx file doenst exist yet", - "Generate and Replace Handle option added when highlighting a handle and rightclicking", - "Generate Handle will now correctly save the xml files it adds it to", + "Json files will now be recognized for handle hovers (MCM stuff)" ] }, {