Remove icon preloading from the systems in favour of the async web component
This commit is contained in:
parent
6b80f3530d
commit
8aff8b0fda
4 changed files with 2 additions and 59 deletions
|
|
@ -43,25 +43,6 @@ export const preAliasedPartials = {
|
|||
"dotdungeon.pc.v2.foil": "actors/char-sheet/v2/partials/inventory/items/untyped.v2.pc.hbs",
|
||||
};
|
||||
|
||||
export const icons = [
|
||||
`caret-right.svg`,
|
||||
`caret-down.svg`,
|
||||
`garbage-bin.svg`,
|
||||
`chat-bubble.svg`,
|
||||
`dice/d4.svg`,
|
||||
`dice/d6.svg`,
|
||||
`dice/d8.svg`,
|
||||
`dice/d10.svg`,
|
||||
`dice/d12.svg`,
|
||||
`dice/d20.svg`,
|
||||
`create.svg`,
|
||||
`close.svg`,
|
||||
`edit.svg`,
|
||||
`sheet.svg`,
|
||||
`minus.svg`,
|
||||
];
|
||||
|
||||
|
||||
export async function registerHandlebarsHelpers() {
|
||||
Handlebars.registerHelper(helpers);
|
||||
};
|
||||
|
|
@ -97,38 +78,3 @@ export async function preloadHandlebarsTemplates() {
|
|||
console.groupEnd();
|
||||
return loadTemplates(paths);
|
||||
};
|
||||
|
||||
/**
|
||||
* Loads all of the icons that are needed in the handlebars templating to make
|
||||
* the sheet look nicer.
|
||||
*
|
||||
* @returns An object containing icon names to the corresponding HTML data for
|
||||
* displaying the icon
|
||||
*/
|
||||
export async function preloadIcons() {
|
||||
const pathPrefix = `systems/dotdungeon/assets/`
|
||||
const parsedIcons = {};
|
||||
|
||||
for (const icon of icons) {
|
||||
const iconName = icon.split(`/`).slice(-1)[0].slice(0, -4);
|
||||
if (icon.endsWith(`.svg`)) {
|
||||
try {
|
||||
const response = await fetchWithTimeout(`${pathPrefix}${icon}`);
|
||||
if (response.status !== 200) { continue };
|
||||
const svgData = await response.text();
|
||||
parsedIcons[iconName] = svgData;
|
||||
} catch {
|
||||
console.error(`.dungeon | Failed to fetch/parse icon: ${icon}`);
|
||||
continue;
|
||||
};
|
||||
}
|
||||
else if (icon.endsWith(`.png`)) {
|
||||
parsedIcons[iconName] = `<img alt="" src="${pathPrefix}${icon}">`;
|
||||
}
|
||||
else {
|
||||
console.warn(`.dungeon | Icon "${icon}" failed to be handled by a loader`)
|
||||
};
|
||||
};
|
||||
|
||||
return parsedIcons;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue