Compare commits

..

No commits in common. "8345b541d4f2597ed0418bd55f5a4a401a6ff4c5" and "2e29d4cde740d68cb4cfff9d69151fec47ed64d9" have entirely different histories.

View File

@ -1,43 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ItemLoader = void 0;
const StoreComponent_1 = require("../StoreComponent");
const FileUtils_1 = require("../FileUtils");
const fs = require("node:fs");
const path = require("node:path");
const ModelComponentType_1 = require("../../../src/app/project/game-model/ModelComponentType");
class ItemLoader {
constructor(itemDir) {
this.itemDir = itemDir;
}
loadItemgroups() {
return this.loadItemgroupsRecursively(this.itemDir);
}
loadItemgroupsRecursively(currentDir) {
let loadedItemgroups = [];
const itemgroupFiles = FileUtils_1.FileUtils.listFilesInDirectory(currentDir);
itemgroupFiles.forEach(itemgroupFile => {
if (fs.lstatSync(itemgroupFile).isDirectory()) {
const childgroup = this.loadItemgroupsRecursively(itemgroupFile);
loadedItemgroups = loadedItemgroups.concat(childgroup);
}
else if (path.basename(itemgroupFile).endsWith(".json") && this.fileRepresentsItemgroup(itemgroupFile)) {
const loadedItemgroup = this.loadSingleItemgroup(itemgroupFile);
loadedItemgroups.push(loadedItemgroup);
}
});
return loadedItemgroups;
}
loadSingleItemgroup(itemgroupFile) {
if (itemgroupFile.endsWith(".json")) {
const data = fs.readFileSync(itemgroupFile, "utf-8");
return new StoreComponent_1.StoreComponent(data, itemgroupFile, ModelComponentType_1.ModelComponentType.ITEMGROUP);
}
return undefined;
}
fileRepresentsItemgroup(file) {
return path.basename(path.dirname(file)) === path.parse(path.basename(file)).name;
}
}
exports.ItemLoader = ItemLoader;
//# sourceMappingURL=ItemLoader.js.map