18 lines
558 B
TypeScript
18 lines
558 B
TypeScript
const unitActionSheetModules = import.meta.glob('../../assets/images/units/unit-*-actions.webp', {
|
|
eager: true,
|
|
import: 'default'
|
|
}) as Record<string, string>;
|
|
|
|
function textureKeyFromPath(path: string) {
|
|
const fileName = path.split('/').pop() ?? path;
|
|
return fileName.replace(/\.(?:png|webp)$/i, '');
|
|
}
|
|
|
|
const unitActionSheetUrls = new Map(
|
|
Object.entries(unitActionSheetModules).map(([path, url]) => [textureKeyFromPath(path), url])
|
|
);
|
|
|
|
export function unitActionSheetUrlForKey(actionKey: string) {
|
|
return unitActionSheetUrls.get(actionKey);
|
|
}
|