@minecraft/creator-tools
Version:
Minecraft Creator Tools command line and libraries.
209 lines (206 loc) • 13 kB
JavaScript
"use strict";
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProjectItemTypeGroupIconFiles = exports.ProjectItemTypeIconFiles = exports.ICON_BASE_PATH = void 0;
exports.getIconFilenameForProjectItemType = getIconFilenameForProjectItemType;
exports.getIconPathForProjectItemType = getIconPathForProjectItemType;
exports.getIconPathForProjectItemTypeGroup = getIconPathForProjectItemTypeGroup;
/* ═══════════════════════════════════════════════════════════════════════════
PROJECT ITEM TYPE ICON MAP - SVG File Mappings
Maps ProjectItemType enum values to external SVG icon file paths.
Icons are stored in /public/res/icons/itemtypes/ and loaded dynamically.
Fallback Order:
1. Specific icon for the exact item type
2. Group icon for the item's semantic category
3. Default generic icon
═══════════════════════════════════════════════════════════════════════════ */
const IProjectItemData_1 = require("./IProjectItemData");
const ProjectItemTypeInfo_1 = require("./ProjectItemTypeInfo");
const CreatorToolsHost_1 = __importDefault(require("./CreatorToolsHost"));
/**
* Base path for item type SVG icons (relative to the content web root).
* In VS Code webviews this needs to be resolved against
* `CreatorToolsHost.contentWebRoot` (the `asWebviewUri` of the extension
* root), because absolute paths like "/res/..." resolve to the webview
* sandbox origin and get a 403. In the web build `contentWebRoot` is empty
* and the path stays relative to the page, which is also correct.
*/
exports.ICON_BASE_PATH = "res/icons/itemtypes";
function resolveIconPath(filename) {
const root = CreatorToolsHost_1.default.contentWebRoot || "";
// contentWebRoot, when set, already ends with a slash (via
// StorageUtilities.ensureEndsWithDelimiter in CreatorToolsHost.init).
return `${root}${exports.ICON_BASE_PATH}/${filename}`;
}
/**
* Maps specific ProjectItemType values to their SVG icon filenames.
* If a type is not listed here, it falls back to its group icon.
*/
exports.ProjectItemTypeIconFiles = {
// ═══ Scripts & Logic ═══
[]: "ts.svg",
[]: "js.svg",
[]: "mcfunction.svg",
[]: "test.svg",
[]: "build-process.svg",
[]: "tick.svg",
[]: "animation.svg",
[]: "animation-controller.svg",
// ═══ Entity Types ═══
[]: "entity-type-behavior.svg",
[]: "entity-type-resource.svg",
[]: "spawn-rule.svg",
[]: "dialogue.svg",
[]: "behavior-tree.svg",
// ═══ Item Types ═══
[]: "item-type-behavior.svg",
[]: "item-type-resource.svg",
[]: "attachable.svg",
[]: "loot-table.svg",
[]: "recipe.svg",
[]: "trading.svg",
[]: "item-texture.svg",
// ═══ Block Types ═══
[]: "block-type-behavior.svg",
[]: "block-type-resource.svg",
[]: "blocks-catalog.svg",
[]: "block-culling.svg",
[]: "terrain-texture.svg",
[]: "voxel-shape.svg",
// ═══ World & Worldgen ═══
[]: "world.svg",
[]: "mcworld.svg",
[]: "mctemplate.svg",
[]: "mcproject.svg",
[]: "level-dat.svg",
[]: "level-dat.svg",
[]: "leveldb.svg",
[]: "leveldb.svg",
[]: "leveldb.svg",
[]: "leveldb.svg",
[]: "biome.svg",
[]: "biome.svg",
[]: "feature-rule.svg",
[]: "feature.svg",
[]: "jigsaw.svg",
[]: "jigsaw.svg",
[]: "jigsaw.svg",
[]: "jigsaw.svg",
[]: "dimension.svg",
[]: "volume.svg",
[]: "structure.svg",
[]: "world-template.svg",
// ═══ Models & Animations ═══
[]: "model-geometry.svg",
[]: "animation.svg",
[]: "animation-controller.svg",
[]: "render-controller.svg",
[]: "particle.svg",
// ═══ Textures & Audio ═══
[]: "texture.svg",
[]: "image.svg",
[]: "pack-icon.svg",
[]: "marketing-asset.svg",
[]: "store-asset.svg",
[]: "flipbook-textures.svg",
[]: "audio.svg",
[]: "sound-catalog.svg",
[]: "sound-definition.svg",
[]: "music-definition.svg",
[]: "fog.svg",
[]: "texture-set.svg",
// ═══ Vibrant Visuals ═══
[]: "lighting.svg",
[]: "lighting.svg",
[]: "fog.svg",
[]: "texture-set.svg",
[]: "lighting.svg",
// ═══ UI/UX ═══
[]: "ui.svg",
[]: "language.svg",
[]: "language.svg",
// ═══ Config & Dev ═══
[]: "tsconfig.svg",
[]: "package-json.svg",
[]: "package-json.svg",
[]: "eslint-config.svg",
[]: "env-file.svg",
[]: "manifest.svg",
[]: "manifest.svg",
[]: "behavior-pack.svg",
[]: "resource-pack.svg",
[]: "camera.svg",
[]: "camera.svg",
[]: "material.svg",
[]: "material.svg",
// ═══ Packaging ═══
[]: "mcaddon.svg",
[]: "mcpack.svg",
[]: "zip.svg",
// ═══ Skins & Personas ═══
[]: "skin.svg",
[]: "skin-pack.svg",
[]: "skin-pack.svg",
// ═══ Meta/Documentation ═══
[]: "dataform.svg",
[]: "doc.svg",
[]: "markdown.svg",
[]: "command-set.svg",
// ═══ Design ═══
[]: "action-set.svg",
[]: "design-pack.svg",
// ═══ Unknown/Other ═══
[]: "unknown.svg",
[]: "json.svg",
};
/**
* Maps ProjectItemTypeGroup to their SVG icon filenames.
* Used as fallback when no specific icon exists for an item type.
*/
exports.ProjectItemTypeGroupIconFiles = {
[]: "ts.svg",
[]: "entity-type-behavior.svg",
[]: "item-type-behavior.svg",
[]: "block-type-behavior.svg",
[]: "world.svg",
[]: "model-geometry.svg",
[]: "texture.svg",
[]: "lighting.svg",
[]: "ui.svg",
[]: "properties.svg",
[]: "mcpack.svg",
[]: "skin.svg",
[]: "doc.svg",
[]: "design-pack.svg",
[]: "default.svg",
};
/**
* Gets the SVG icon filename for a specific project item type.
* Falls back to group icon if no specific icon is defined.
*/
function getIconFilenameForProjectItemType(itemType) {
const specificIcon = exports.ProjectItemTypeIconFiles[itemType];
if (specificIcon) {
return specificIcon;
}
const group = (0, ProjectItemTypeInfo_1.getProjectItemTypeGroup)(itemType);
return exports.ProjectItemTypeGroupIconFiles[group] || "default.svg";
}
/**
* Gets the full path to the SVG icon for a project item type.
*/
function getIconPathForProjectItemType(itemType) {
const filename = getIconFilenameForProjectItemType(itemType);
return resolveIconPath(filename);
}
/**
* Gets the full path to the SVG icon for a project item type group.
*/
function getIconPathForProjectItemTypeGroup(group) {
const filename = exports.ProjectItemTypeGroupIconFiles[group] || "default.svg";
return resolveIconPath(filename);
}