feat: Allow users to select custom SVG files for fear icons.

This commit is contained in:
CPTN Cosmo 2025-12-19 01:15:40 +01:00
parent 12e65a65af
commit bd82f9b1d8

View file

@ -16,7 +16,8 @@ Hooks.once('init', () => {
type: String, type: String,
choices: { choices: {
'preset': 'Preset List', 'preset': 'Preset List',
'custom': 'Custom FontAwesome Class' 'custom': 'Custom FontAwesome Class',
'custom-svg': 'Custom SVG File'
}, },
default: 'preset', default: 'preset',
onChange: refreshFearTracker onChange: refreshFearTracker
@ -55,6 +56,17 @@ Hooks.once('init', () => {
onChange: refreshFearTracker onChange: refreshFearTracker
}); });
game.settings.register(MODULE_ID, 'customSvgPath', {
name: 'Custom SVG File',
hint: 'Select a custom SVG file for the fear icon.',
scope: 'client',
config: true,
type: String,
default: '',
filePicker: 'image',
onChange: refreshFearTracker
});
game.settings.register(MODULE_ID, 'colorTheme', { game.settings.register(MODULE_ID, 'colorTheme', {
name: 'Color Theme', name: 'Color Theme',
hint: 'Choose a color preset or Custom to set your own colors below.', hint: 'Choose a color preset or Custom to set your own colors below.',
@ -108,13 +120,19 @@ Hooks.on('renderSettingsConfig', (app, html, data) => {
// Icon Inputs // Icon Inputs
const presetGroup = $html.find(`select[name="${MODULE_ID}.presetIcon"]`).closest('.form-group'); const presetGroup = $html.find(`select[name="${MODULE_ID}.presetIcon"]`).closest('.form-group');
const customIconGroup = $html.find(`input[name="${MODULE_ID}.customIcon"]`).closest('.form-group'); const customIconGroup = $html.find(`input[name="${MODULE_ID}.customIcon"]`).closest('.form-group');
const customSvgGroup = $html.find(`input[name="${MODULE_ID}.customSvgPath"]`).closest('.form-group');
// Reset
presetGroup.hide();
customIconGroup.hide();
customSvgGroup.hide();
if (iconType === 'preset') { if (iconType === 'preset') {
presetGroup.show(); presetGroup.show();
customIconGroup.hide(); } else if (iconType === 'custom') {
} else {
presetGroup.hide();
customIconGroup.show(); customIconGroup.show();
} else if (iconType === 'custom-svg') {
customSvgGroup.show();
} }
// Color Inputs // Color Inputs
@ -213,11 +231,14 @@ function injectFearCustomization(html) {
let iconClass = 'fa-skull'; let iconClass = 'fa-skull';
if (iconType === 'preset') { if (iconType === 'preset') {
iconClass = presetIcon; iconClass = presetIcon;
} else { } else if (iconType === 'custom') {
iconClass = customIcon; iconClass = customIcon;
} else if (iconType === 'custom-svg') {
const svgPath = game.settings.get(MODULE_ID, 'customSvgPath');
iconClass = svgPath || 'icons/svg/mystery-man.svg'; // Fallback
} }
const isSVG = iconClass.includes('.svg'); const isSVG = iconClass.includes('.svg') || iconType === 'custom-svg';
const icons = fearContainer.querySelectorAll('i'); const icons = fearContainer.querySelectorAll('i');
const totalIcons = icons.length; const totalIcons = icons.length;