@minecraft/creator-tools
Version:
Minecraft Creator Tools command line and libraries.
81 lines (79 loc) • 4.43 kB
JavaScript
;
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
Object.defineProperty(exports, "__esModule", { value: true });
exports.TextureReferenceInfoGeneratorTest = void 0;
const ProjectInfoItem_1 = require("./ProjectInfoItem");
const IProjectItemData_1 = require("../app/IProjectItemData");
const IInfoItemData_1 = require("./IInfoItemData");
const BlocksCatalogDefinition_1 = require("../minecraft/BlocksCatalogDefinition");
const TerrainTextureCatalogDefinition_1 = require("../minecraft/TerrainTextureCatalogDefinition");
const ItemTextureCatalogDefinition_1 = require("../minecraft/ItemTextureCatalogDefinition");
const ContentIndex_1 = require("../core/ContentIndex");
const ProjectInfoUtilities_1 = require("./ProjectInfoUtilities");
var TextureReferenceInfoGeneratorTest;
(function (TextureReferenceInfoGeneratorTest) {
TextureReferenceInfoGeneratorTest[TextureReferenceInfoGeneratorTest["textureReferences"] = 1] = "textureReferences";
})(TextureReferenceInfoGeneratorTest = exports.TextureReferenceInfoGeneratorTest || (exports.TextureReferenceInfoGeneratorTest = {}));
class TextureReferenceInfoGenerator {
constructor() {
this.id = "TEXTUREREF";
this.title = "Texture Reference Info Aggregation";
this.performAddOnValidations = false;
}
getTopicData(topicId) {
return {
title: ProjectInfoUtilities_1.default.getTitleFromEnum(TextureReferenceInfoGeneratorTest, topicId),
};
}
summarize(info, infoSet) {
info.textureCount = infoSet.getSummedNumberValue(this.id, TextureReferenceInfoGeneratorTest.textureReferences);
}
async generate(project, contentIndex) {
const items = [];
const textureRefCountPi = new ProjectInfoItem_1.default(IInfoItemData_1.InfoItemType.featureAggregate, this.id, 1, "Texture Refrences");
items.push(textureRefCountPi);
const itemsCopy = project.getItemsCopy();
for (const projectItem of itemsCopy) {
if (projectItem.itemType === IProjectItemData_1.ProjectItemType.blocksCatalogResourceJson) {
await projectItem.ensureFileStorage();
if (projectItem.file) {
const blockCat = await BlocksCatalogDefinition_1.default.ensureOnFile(projectItem.file);
if (blockCat && blockCat.blocksCatalog && projectItem.projectPath) {
const textureRefs = blockCat.getTextureReferences();
for (const textureRef of textureRefs) {
contentIndex.insert(textureRef, projectItem.projectPath, ContentIndex_1.AnnotationCategory.blockTextureReferenceDependent);
}
}
}
}
else if (projectItem.itemType === IProjectItemData_1.ProjectItemType.terrainTextureCatalogResourceJson) {
await projectItem.ensureFileStorage();
if (projectItem.file) {
const blockCat = await TerrainTextureCatalogDefinition_1.default.ensureOnFile(projectItem.file);
if (blockCat && projectItem.projectPath) {
const textureRefs = blockCat.getTextureReferences();
for (const textureRef of textureRefs) {
contentIndex.insert(textureRef, projectItem.projectPath, ContentIndex_1.AnnotationCategory.blockTextureReferenceSource);
}
}
}
}
else if (projectItem.itemType === IProjectItemData_1.ProjectItemType.itemTextureJson) {
await projectItem.ensureFileStorage();
if (projectItem.file) {
const itemCat = await ItemTextureCatalogDefinition_1.default.ensureOnFile(projectItem.file);
if (itemCat && projectItem.projectPath) {
const textureRefs = itemCat.getTextureReferences();
for (const textureRef of textureRefs) {
contentIndex.insert(textureRef, projectItem.projectPath, ContentIndex_1.AnnotationCategory.itemTextureReferenceSource);
}
}
}
}
}
return items;
}
}
exports.default = TextureReferenceInfoGenerator;
//# sourceMappingURL=../maps/info/TextureReferenceInfoGenerator.js.map