Skip to content

Commit

Permalink
see read me (hover show path removed and some otehr stuff idk)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghostboats committed Jul 16, 2024
1 parent da41533 commit 7499f5a
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 20 deletions.
14 changes: 13 additions & 1 deletion commands/folderShortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,16 @@ const openWorkspaceFolderCommand = vscode.commands.registerCommand('bg3-mod-help
}
});

module.exports = { openModsFolderCommand, openGameFolderCommand, openLogsFolderCommand, openWorkspaceFolderCommand };
const openPlayerProfilesFolderCommand = vscode.commands.registerCommand('bg3-mod-helper.openPlayerProfilesFolder', async () => {
const appDataPath = process.env.LOCALAPPDATA;
const playerProfilesPath = path.join(appDataPath, 'Larian Studios', "Baldur's Gate 3", 'PlayerProfiles');

try {
await fs.access(playerProfilesPath);
vscode.env.openExternal(vscode.Uri.file(playerProfilesPath));
} catch (error) {
vscode.window.showInformationMessage('PlayerProfiles folder not found.');
}
});

module.exports = { openModsFolderCommand, openGameFolderCommand, openLogsFolderCommand, openWorkspaceFolderCommand, openPlayerProfilesFolderCommand };
64 changes: 64 additions & 0 deletions commands/indentXmlFiles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
const vscode = require('vscode');
const fs = require('fs');
const path = require('path');
const os = require('os');
const { raiseError, raiseInfo } = require('../support_files/log_utils');
const { getConfig, loadConfigFile, setModName, setConfig } = require('../support_files/config');
const builder = require('xmlbuilder');

async function indentXmlFiles() {
const config = getConfig();
const rootModPath = config.rootModPath;
const indentLevel = await vscode.window.showInputBox({
prompt: 'Enter the number of spaces for indentation',
validateInput: (value) => {
const num = parseInt(value, 10);
return isNaN(num) || num < 0 ? 'Please enter a valid non-negative number' : null;
}
});

if (!indentLevel) {
return; // User cancelled the input box
}

const findFiles = (dir, extensions, fileList = []) => {
fs.readdirSync(dir).forEach(file => {
const filePath = path.join(dir, file);
if (fs.statSync(filePath).isDirectory()) {
// Skip the Localization folder
if (path.basename(filePath).toLowerCase() !== 'localization') {
fileList = findFiles(filePath, extensions, fileList);
}
} else if (extensions.some(ext => filePath.endsWith(ext))) {
fileList.push(filePath);
}
});
return fileList;
};

const files = findFiles(rootModPath, ['.lsx', '.lsj']);

for (const filePath of files) {
let fileContent = fs.readFileSync(filePath, 'utf-8');
// Remove BOM if it exists
if (fileContent.charCodeAt(0) === 0xFEFF) {
fileContent = fileContent.slice(1);
}
try {
const doc = builder.create(fileContent, { headless: true });
const formattedContent = doc.end({ pretty: true, indent: ' '.repeat(parseInt(indentLevel, 10)) });
fs.writeFileSync(filePath, formattedContent, 'utf-8');
raiseInfo(`File ${filePath} has been formatted with an indent level of ${indentLevel} spaces.`);
} catch (error) {
raiseError(`Failed to process file ${filePath}: ${error.message}`);
}
}

raiseInfo('XML files formatting process completed.');
}

const indentXmlFilesCommand = vscode.commands.registerCommand('bg3-mod-helper.indentXmlFilesCommand', async function () {
await indentXmlFiles();
});

module.exports = { indentXmlFilesCommand };
11 changes: 8 additions & 3 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ let packModImport,
openGameFolderCommand,
openLogsFolderCommand,
openWorkspaceFolderCommand,
openPlayerProfilesFolderCommand,
organizeDataFilesCommand,
xmlMergerCommand,
symlinkerCommand,
indentXmlFilesCommand,
debugCommand,
debug2Command,
unpackGameDataCommand,
Expand Down Expand Up @@ -85,6 +87,7 @@ function setCommands() {
openGameFolderCommand = require('./commands/folderShortcuts').openGameFolderCommand;
openLogsFolderCommand = require('./commands/folderShortcuts').openLogsFolderCommand;
openWorkspaceFolderCommand = require('./commands/folderShortcuts').openWorkspaceFolderCommand;
openPlayerProfilesFolderCommand = require('./commands/folderShortcuts').openPlayerProfilesFolderCommand;

// image commands
resizeImageTooltip = require('./commands/resizeImage').resizeImageTooltip;
Expand All @@ -104,6 +107,7 @@ function setCommands() {
xmlMergerCommand = require('./commands/xmlMerger');
organizeDataFilesCommand = require('./commands/organizeDataFiles');
symlinkerCommand = require('./commands/symlinker');
indentXmlFilesCommand = require('./commands/indentXmlFiles');

// debug commands
debugCommand = require('./commands/debug');
Expand Down Expand Up @@ -194,7 +198,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, DDSToPNGCommand, PNGToDDSCommand, resizeTooltipCommand, resizeControllerCommand, resizeHotbarCommand, resizeCustomCommand, createModTemplateCommand, addIconBackgroundCommand, openConverterCommand, versionGeneratorCommand, rotationToolCommand, openModsFolderCommand, openGameFolderCommand, openLogsFolderCommand, openWorkspaceFolderCommand);
context.subscriptions.push(uuidsHandlesHoverProvider, functionsHoverProvider, DDSToPNGCommand, PNGToDDSCommand, resizeTooltipCommand, resizeControllerCommand, resizeHotbarCommand, resizeCustomCommand, createModTemplateCommand, addIconBackgroundCommand, openConverterCommand, versionGeneratorCommand, rotationToolCommand, openModsFolderCommand, openGameFolderCommand, openLogsFolderCommand, openWorkspaceFolderCommand, openPlayerProfilesFolderCommand);
}


Expand Down Expand Up @@ -224,7 +228,6 @@ function aSimpleDataProvider() {
{ label: 'BBCode/Markdown Editor ', command: 'bg3-mod-helper.textEditorTool'},
{ label: 'Version Generator', command: 'bg3-mod-helper.versionGenerator' },
{ label: 'Merge Xmls', command: 'bg3-mod-helper.xmlMerger' },
{ label: 'Add Dependencies to Meta via modsettings.lsx', command: 'bg3-mod-helper.addDependencies'},
{ label: 'Add/Remove Symlink (in development)', command: 'bg3-mod-helper.symlinker' },
{ label: 'Rotation Tool (in development)', command: 'bg3-mod-helper.rotationTool' },
{ label: 'DDS Viewer (in development)', command: 'bg3-mod-helper.DDSViewer' },
Expand All @@ -243,7 +246,8 @@ function aSimpleDataProvider() {
]);
} else if (element.id === 'formatting') {
return Promise.resolve([
{ label: 'Organize Data Files (Alphabetically)', command: 'bg3-mod-helper.organizeDataFilesCommand' }
{ label: 'Organize Data Files (Alphabetically)', command: 'bg3-mod-helper.organizeDataFilesCommand' },
{ label: 'Mass Indent LSX Files', command: 'bg3-mod-helper.indentXmlFilesCommand'}
]);
} else if (element.id === 'config') {
return Promise.resolve([
Expand All @@ -264,6 +268,7 @@ function aSimpleDataProvider() {
{ label: 'Workspace Folder', command: 'bg3-mod-helper.openWorkspaceFolder' },
{ label: 'Extension Logs Folder', command: 'bg3-mod-helper.openLogsFolder' },
{ label: 'Game Data Folder', command: 'bg3-mod-helper.openGameFolder' },
{ label: 'Player Profiles Folder', command: 'bg3-mod-helper.openPlayerProfilesFolder' },
]);
} else {
return Promise.resolve([]);
Expand Down
5 changes: 0 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,6 @@
"default": true,
"description": "Enable or disable hover feature."
},
"bg3ModHelper.hoverShowPath": {
"type": "boolean",
"default": true,
"description": "Toggle file path in hover message (not working in current update)."
},
"bg3ModHelper.rootModPath": {
"type": "string",
"default": "",
Expand Down
1 change: 0 additions & 1 deletion support_files/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ function getConfig() {
return {
hoverMaxFiles: config.get('hoverMaxFiles'),
hoverEnabled: config.get('hoverEnabled'),
hoverShowPath: config.get('hoverShowPath'),
maxCacheSize: config.get('maxCacheSize'),
rootModPath: path.normalize(config.get('rootModPath')),
modDestPath: path.normalize(config.get('modDestPath')),
Expand Down
24 changes: 14 additions & 10 deletions support_files/release_notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,21 @@ function generateReleaseNotes(version) {
{
title: "Mod Setting Changes [IMPORTANT]",
details: [
"Modname changes complete, add details here",
"Configuration Options Data Provider complete, add details here",
"New setting to add files to be excluded when packing (maybe this mixes with stuff below regarding exclude hidden(todo))",
"Modname Setting Added. This value should be autoset on launch as long as you only have one folder in your rootmodpath's Mods folder. If you have multiple it will need to be set!",
"Configuration Options Data Provider complete, see below",
"Conversion exclusion list UI changes to show difference between this and packing exclusion list (todo)",
"Exclude Hidden (not sure if working yet so putting as (todo), need to talk to beans)",
"Auto Launch Game and Zip options removed as settings. This is now handled via the dropdown data provider, the 'Pack and Play' and 'Pack and Zip' options respectivly."
"Exclude Hidden (implemented but requires new lslib which is unreleased atm) setting added, possible remove as setting and make it always check files for .(todo)",
"Auto Launch Game and Zip options removed as settings. This is now handled via the dropdown data provider, the 'Pack and Play' and 'Pack and Zip' options respectivly.",
"Remove hover enabled setting to remvoe dead setting"
]
},
{
title: ".helperignore used [IMPORTANT]",
title: "Configuration Options Data Provider",
details: [
"Similar to other . files like .gitignore or .vscode, you can now use a .helperignore (should be in same dir as rootmodfolder (Public, Localizations, etc)(todo)",
"Will ask if you want one generated for you for the first time on a new release on launch (todo)"
"Contains several quick actions revolving around modSetting which are accessed from the data provider:",
"Reload Window: Will refresh the current vscode window, allowing for new settings to take effect (For example, if you change things like lslib path, you should reload)",
"Extension Setting: Opens the settings page, filtering the bg3 mod helper settings for quick access",
"Update Settings: (todo, overwrites workspace, need to confirm with beans this is the desired effect)"
]
},
{
Expand All @@ -90,7 +92,7 @@ function generateReleaseNotes(version) {
},
{
title: "Symlink Fixes",
details: ["Symlink will no longer create 'random' folders when linking/unlinking (seems to be working, will leave in development tag for now while users test. No errors when personally testing, maybe its a linux only issue?)"]
details: ["Symlink will no longer create 'random' folders when linking/unlinking (seems to be working, will leave in development tag for now while users test. No errors when personally testing, please send paths/screenshots/info/etc if you have any issues)"]
},
{
title: "Zipping Fixes",
Expand All @@ -109,7 +111,9 @@ function generateReleaseNotes(version) {
title: "Minor Changes",
details: [
"Extension confirmed to work on Linux (ty satan!)",
"Check if game is lauched for linus in packing(todo)"
"Check if game is lauched for linus in packing(todo)",
"Shortcut to PlayerProfiles Folder added in folder shortcuts",
"Atlas Fix if .lsx file doenst exist yet (todo)"
]
}
]
Expand Down

0 comments on commit 7499f5a

Please sign in to comment.