mirror of
https://gitee.com/onvia/ccc-tnt-psd2ui
synced 2025-04-11 09:41:05 +00:00
增加中文转拼音
This commit is contained in:
parent
c8132b5bfd
commit
dd0373c362
@ -1,10 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.EditorVersion = void 0;
|
||||
var EditorVersion;
|
||||
(function (EditorVersion) {
|
||||
EditorVersion[EditorVersion["all"] = 0] = "all";
|
||||
EditorVersion[EditorVersion["v249"] = 1] = "v249";
|
||||
EditorVersion[EditorVersion["v342"] = 2] = "v342";
|
||||
EditorVersion[EditorVersion["v362"] = 3] = "v362";
|
||||
})(EditorVersion = exports.EditorVersion || (exports.EditorVersion = {}));
|
@ -1,180 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.exportImageMgr = void 0;
|
||||
require("ag-psd/initialize-canvas"); // only needed for reading image data and thumbnails
|
||||
const psd = __importStar(require("ag-psd"));
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const ImageMgr_1 = require("./assets-manager/ImageMgr");
|
||||
const FileUtils_1 = require("./utils/FileUtils");
|
||||
const Parser_1 = require("./Parser");
|
||||
const PsdGroup_1 = require("./psd/PsdGroup");
|
||||
const PsdText_1 = require("./psd/PsdText");
|
||||
class ExportImageMgr {
|
||||
constructor() {
|
||||
this.textObjects = [];
|
||||
}
|
||||
test() {
|
||||
const outDir = path_1.default.join(__dirname, "..", "out");
|
||||
let psdPath = "./test-img-only/境界奖励-优化.psd";
|
||||
this.parsePsd(psdPath, outDir);
|
||||
}
|
||||
exec(args) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// 检查参数
|
||||
if (!this.checkArgs(args)) {
|
||||
return;
|
||||
}
|
||||
// 判断输入是文件夹还是文件
|
||||
let stat = fs_extra_1.default.lstatSync(args.input);
|
||||
let isDirectory = stat.isDirectory();
|
||||
if (isDirectory) {
|
||||
if (!args.output) {
|
||||
args.output = path_1.default.join(args.input, "psd2ui");
|
||||
}
|
||||
this.parsePsdDir(args.input, args.output);
|
||||
}
|
||||
else {
|
||||
if (!args.output) {
|
||||
let input_dir = path_1.default.dirname(args.input);
|
||||
args.output = path_1.default.join(input_dir, "psd2ui");
|
||||
}
|
||||
this.parsePsd(args.input, args.output);
|
||||
}
|
||||
});
|
||||
}
|
||||
// 检查参数
|
||||
checkArgs(args) {
|
||||
if (!args.input) {
|
||||
console.error(`请设置 --input`);
|
||||
return false;
|
||||
}
|
||||
if (!fs_extra_1.default.existsSync(args.input)) {
|
||||
console.error(`输入路径不存在: ${args.input}`);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
parsePsdDir(dir, outDir) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// 清空目录
|
||||
fs_extra_1.default.emptyDirSync(outDir);
|
||||
let psds = FileUtils_1.fileUtils.filterFile(dir, (fileName) => {
|
||||
let extname = path_1.default.extname(fileName);
|
||||
if (extname == ".psd") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
for (let i = 0; i < psds.length; i++) {
|
||||
const element = psds[i];
|
||||
yield this.parsePsd(element, outDir);
|
||||
}
|
||||
});
|
||||
}
|
||||
parsePsd(psdPath, outDir) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// 每开始一个新的 psd 清理掉上一个 psd 的图
|
||||
ImageMgr_1.imageMgr.clear();
|
||||
this.textObjects.length = 0;
|
||||
console.log(`=========================================`);
|
||||
console.log(`处理 ${psdPath} 文件`);
|
||||
let psdName = path_1.default.basename(psdPath, ".psd");
|
||||
let buffer = fs_extra_1.default.readFileSync(psdPath);
|
||||
const psdFile = psd.readPsd(buffer);
|
||||
let psdRoot = Parser_1.parser.parseLayer(psdFile);
|
||||
psdRoot.name = psdName;
|
||||
let prefabDir = path_1.default.join(outDir, psdName);
|
||||
let textureDir = path_1.default.join(prefabDir, "textures");
|
||||
fs_extra_1.default.mkdirsSync(prefabDir); // 创建预制体根目录
|
||||
fs_extra_1.default.emptyDirSync(prefabDir);
|
||||
fs_extra_1.default.mkdirsSync(textureDir); //创建 图片目录
|
||||
yield this.saveImage(textureDir);
|
||||
yield this.saveTextFile(psdRoot, prefabDir);
|
||||
console.log(`psd2ui ${psdPath} 处理完成`);
|
||||
});
|
||||
}
|
||||
saveImage(out) {
|
||||
let images = ImageMgr_1.imageMgr.getAllImage();
|
||||
let idx = 0;
|
||||
images.forEach((psdImage, k) => {
|
||||
// 查找镜像
|
||||
let _layer = ImageMgr_1.imageMgr.getSerialNumberImage(psdImage);
|
||||
let name = `${_layer.imgName}_${idx}`;
|
||||
console.log(`保存图片 [${_layer.imgName}] 重命名为 [${name}] md5: ${_layer.md5}`);
|
||||
let fullpath = path_1.default.join(out, `${name}.png`);
|
||||
fs_extra_1.default.writeFileSync(fullpath, _layer.imgBuffer);
|
||||
idx++;
|
||||
});
|
||||
}
|
||||
saveTextFile(psdRoot, out) {
|
||||
this.scanText(psdRoot, psdRoot);
|
||||
let textContent = JSON.stringify(this.textObjects, null, 2);
|
||||
let fullpath = path_1.default.join(out, `text.txt`);
|
||||
fs_extra_1.default.writeFileSync(fullpath, textContent, { encoding: "utf-8" });
|
||||
}
|
||||
scanText(layer, psdRoot) {
|
||||
if (layer instanceof PsdGroup_1.PsdGroup) {
|
||||
for (let i = 0; i < layer.children.length; i++) {
|
||||
const childLayer = layer.children[i];
|
||||
this.scanText(childLayer, psdRoot);
|
||||
}
|
||||
}
|
||||
else if (layer instanceof PsdText_1.PsdText) {
|
||||
let textObj = {
|
||||
text: layer.text,
|
||||
fontSize: layer.fontSize,
|
||||
color: `#${layer.color.toHEX()}`
|
||||
};
|
||||
// 有描边
|
||||
if (layer.outline) {
|
||||
textObj.outlineWidth = layer.outline.width;
|
||||
textObj.outlineColor = `#${layer.outline.color.toHEX()}`;
|
||||
}
|
||||
this.textObjects.push(textObj);
|
||||
}
|
||||
}
|
||||
static getInstance() {
|
||||
if (!this._instance) {
|
||||
this._instance = new ExportImageMgr();
|
||||
}
|
||||
return this._instance;
|
||||
}
|
||||
}
|
||||
ExportImageMgr._instance = null;
|
||||
exports.exportImageMgr = ExportImageMgr.getInstance();
|
@ -1,507 +0,0 @@
|
||||
"use strict";
|
||||
//ag-psd 使用 参考 https://github.com/Agamnentzar/ag-psd/blob/HEAD/README_PSD.md
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Main = void 0;
|
||||
require("ag-psd/initialize-canvas"); // only needed for reading image data and thumbnails
|
||||
const psd = __importStar(require("ag-psd"));
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const Parser_1 = require("./Parser");
|
||||
const PsdGroup_1 = require("./psd/PsdGroup");
|
||||
const CCNode_1 = require("./engine/cc/CCNode");
|
||||
const PsdImage_1 = require("./psd/PsdImage");
|
||||
const PsdText_1 = require("./psd/PsdText");
|
||||
const CCSprite_1 = require("./engine/cc/CCSprite");
|
||||
const CCPrefabInfo_1 = require("./engine/cc/CCPrefabInfo");
|
||||
const CCPrefab_1 = require("./engine/cc/CCPrefab");
|
||||
const CCSize_1 = require("./engine/cc/values/CCSize");
|
||||
const CCVec2_1 = require("./engine/cc/values/CCVec2");
|
||||
const CCLabel_1 = require("./engine/cc/CCLabel");
|
||||
const CCLabelOutline_1 = require("./engine/cc/CCLabelOutline");
|
||||
const ImageCacheMgr_1 = require("./assets-manager/ImageCacheMgr");
|
||||
const EditorVersion_1 = require("./EditorVersion");
|
||||
const config_1 = require("./config");
|
||||
const FileUtils_1 = require("./utils/FileUtils");
|
||||
const ImageMgr_1 = require("./assets-manager/ImageMgr");
|
||||
const ExportImageMgr_1 = require("./ExportImageMgr");
|
||||
const CCUIOpacity_1 = require("./engine/cc/CCUIOpacity");
|
||||
const CCUITransform_1 = require("./engine/cc/CCUITransform");
|
||||
const CCVec3_1 = require("./engine/cc/values/CCVec3");
|
||||
/***
|
||||
* 执行流程
|
||||
* - 首次运行,先读取项目文件夹下所有图片资源,进行 md5 缓存
|
||||
*
|
||||
* - 加载缓存文件
|
||||
* - 处理 psd
|
||||
* - 通过 md5 判断是否已经存在资源,如果存在, 则不再导出,预制体中使用已存在的资源的 uuid
|
||||
*
|
||||
*/
|
||||
console.log(`当前目录: `, __dirname);
|
||||
class Main {
|
||||
constructor() {
|
||||
this.spriteFrameMetaContent = "";
|
||||
this.prefabMetaContent = "";
|
||||
this.psdConfig = null;
|
||||
// 强制导出图片
|
||||
this.isForceImg = false;
|
||||
}
|
||||
test() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// config.editorVersion = EditorVersion.v342;
|
||||
// // 首次运行需要读取所有图片
|
||||
// await imageCacheMgr.loadImages("E:\\Demo\\CC249JSTest\\assets");
|
||||
// // await imageCacheMgr.loadImages("E:\\YQ\\Code\\trunk\\assets");
|
||||
// await imageCacheMgr.saveImageMap("E:\\Git\\ccc-framework-3d\\tools\\psd2ui\\cache\\cache.json");
|
||||
const outDir = path_1.default.join(__dirname, "..", "out");
|
||||
// // 加载测试配置
|
||||
this.loadPsdConfig(path_1.default.join(__dirname, "../test/test.config.json"));
|
||||
// // 首先加载缓存文件
|
||||
yield ImageCacheMgr_1.imageCacheMgr.initWithPath("E:\\Git\\ccc-framework-3d\\tools\\psd2ui\\cache\\cache.json");
|
||||
yield this.loadMetaTemplete();
|
||||
let psdPath = "./test/demo.psd";
|
||||
// // let psdPath = "E:\\YQ\\Meishu\\D_巅峰对决\\竞猜\\guild_PeakBetMainWindow.psd"
|
||||
// psdPath = "./test/对战动画-切.psd";
|
||||
psdPath = "./test/活动icon.psd";
|
||||
this.parsePsd(psdPath, outDir);
|
||||
// let psdPath = "./test";
|
||||
// let psdPath = "E:\\YQ\\Meishu\\D_巅峰对决\\竞猜\\guild_PeakBetMainWindow.psd"
|
||||
// psdPath = "./test/test.psd";
|
||||
// this.parsePsdDir(psdPath, outDir);
|
||||
yield ImageCacheMgr_1.imageCacheMgr.saveImageMap();
|
||||
console.log(`psd2ui 导出完成`);
|
||||
});
|
||||
}
|
||||
// 首先加载 meta 模板
|
||||
loadMetaTemplete() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
this.spriteFrameMetaContent = fs_extra_1.default.readFileSync(path_1.default.join(__dirname, `../assets/cc/meta/CCSpriteFrame.meta.${EditorVersion_1.EditorVersion[config_1.config.editorVersion]}`), "utf-8");
|
||||
this.prefabMetaContent = fs_extra_1.default.readFileSync(path_1.default.join(__dirname, `../assets/cc/meta/CCPrefab.meta.${EditorVersion_1.EditorVersion[config_1.config.editorVersion]}`), "utf-8");
|
||||
});
|
||||
}
|
||||
// 加载配置
|
||||
loadPsdConfig(filepath) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!fs_extra_1.default.existsSync(filepath)) {
|
||||
console.log(`Main-> 配置 ${filepath} 不存在`);
|
||||
return;
|
||||
}
|
||||
// console.log(`Main-> 读取配置 ${filepath}`);
|
||||
let psdConfig = fs_extra_1.default.readFileSync(filepath, "utf-8");
|
||||
this.psdConfig = JSON.parse(psdConfig);
|
||||
// // 合并 文本偏移配置
|
||||
// if (this.psdConfig.textOffsetY) {
|
||||
// config.textOffsetY = Object.assign({}, config.textOffsetY, this.psdConfig.textOffsetY);
|
||||
// }
|
||||
// // 合并 行高配置
|
||||
// if (this.psdConfig.textLineHeightOffset) {
|
||||
// config.textLineHeightOffset = Object.assign({}, config.textLineHeightOffset, this.psdConfig.textLineHeightOffset);
|
||||
// }
|
||||
// 合并配置
|
||||
for (const key in this.psdConfig) {
|
||||
if (key in config_1.config) {
|
||||
if (typeof this.psdConfig[key] === 'object') {
|
||||
config_1.config[key] = Object.assign({}, config_1.config[key], this.psdConfig[key]);
|
||||
}
|
||||
else {
|
||||
config_1.config[key] = this.psdConfig[key] || config_1.config[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
// console.log(`Main-> `,JSON.stringify(config,null,2));
|
||||
});
|
||||
}
|
||||
exec(args) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
args = mergeAlias(args);
|
||||
if (args.help) {
|
||||
console.log(`help:\n`, config_1.config.help);
|
||||
return false;
|
||||
}
|
||||
// 只导出图片
|
||||
if (args["img-only"]) {
|
||||
ExportImageMgr_1.exportImageMgr.exec(args);
|
||||
return true;
|
||||
}
|
||||
let writeCache = () => __awaiter(this, void 0, void 0, function* () {
|
||||
// 写入缓存
|
||||
if (args.cache) {
|
||||
fs_extra_1.default.mkdirsSync(path_1.default.dirname(args.cache));
|
||||
yield ImageCacheMgr_1.imageCacheMgr.saveImageMap(args.cache);
|
||||
}
|
||||
});
|
||||
// 设置引擎版本
|
||||
if (args["engine-version"]) {
|
||||
config_1.config.editorVersion = EditorVersion_1.EditorVersion[args["engine-version"]];
|
||||
}
|
||||
if (args.init && (!args["project-assets"] || !args.cache)) {
|
||||
console.log(`psd2ui --init 无法处理,请设置 --project-assets`);
|
||||
return;
|
||||
}
|
||||
// 在没有缓存文件或者 指定重新缓存的时候,读取项目资源
|
||||
if (args["project-assets"] && (!fs_extra_1.default.existsSync(args.cache) || args["cache-remake"] || args.init)) {
|
||||
yield ImageCacheMgr_1.imageCacheMgr.loadImages(args["project-assets"]);
|
||||
// 先写入一次
|
||||
writeCache();
|
||||
if (args.init) {
|
||||
console.log(`psd2ui 缓存完成`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 检查参数
|
||||
if (!this.checkArgs(args)) {
|
||||
return;
|
||||
}
|
||||
if (args.cache) {
|
||||
yield ImageCacheMgr_1.imageCacheMgr.initWithPath(args.cache);
|
||||
}
|
||||
// 加载 meta 文件模板
|
||||
yield this.loadMetaTemplete();
|
||||
if (args.config) {
|
||||
yield this.loadPsdConfig(args.config);
|
||||
}
|
||||
this.isForceImg = !!args["force-img"];
|
||||
// 判断输入是文件夹还是文件
|
||||
let stat = fs_extra_1.default.lstatSync(args.input);
|
||||
let isDirectory = stat.isDirectory();
|
||||
if (isDirectory) {
|
||||
if (!args.output) {
|
||||
args.output = path_1.default.join(args.input, "psd2ui");
|
||||
}
|
||||
this.parsePsdDir(args.input, args.output);
|
||||
}
|
||||
else {
|
||||
if (!args.output) {
|
||||
let input_dir = path_1.default.dirname(args.input);
|
||||
args.output = path_1.default.join(input_dir, "psd2ui");
|
||||
}
|
||||
this.parsePsd(args.input, args.output);
|
||||
}
|
||||
// 写入缓存
|
||||
yield writeCache();
|
||||
console.log(`psd2ui 导出完成`);
|
||||
});
|
||||
}
|
||||
// 检查参数
|
||||
checkArgs(args) {
|
||||
if (!args.input) {
|
||||
console.error(`请设置 --input`);
|
||||
return false;
|
||||
}
|
||||
// 没有输出目录的时候用 输入目录
|
||||
// if (!args.output) {
|
||||
// console.error(`请设置 --output`);
|
||||
// return false;
|
||||
// }
|
||||
if (!fs_extra_1.default.existsSync(args.input)) {
|
||||
console.error(`输入路径不存在: ${args.input}`);
|
||||
return false;
|
||||
}
|
||||
if (args["engine-version"]) {
|
||||
let editorVersion = EditorVersion_1.EditorVersion[args["engine-version"]];
|
||||
switch (editorVersion) {
|
||||
case EditorVersion_1.EditorVersion.v249:
|
||||
case EditorVersion_1.EditorVersion.v342:
|
||||
break;
|
||||
default:
|
||||
console.log(`暂未实现该引擎版本 ${args["engine-version"]}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
parsePsdDir(dir, outDir) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// 清空目录
|
||||
// fs.emptyDirSync(outDir);
|
||||
let psds = FileUtils_1.fileUtils.filterFile(dir, (fileName) => {
|
||||
let extname = path_1.default.extname(fileName);
|
||||
if (extname == ".psd") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
for (let i = 0; i < psds.length; i++) {
|
||||
const element = psds[i];
|
||||
yield this.parsePsd(element, outDir);
|
||||
}
|
||||
});
|
||||
}
|
||||
parsePsd(psdPath, outDir) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// 每开始一个新的 psd 清理掉上一个 psd 的图
|
||||
ImageMgr_1.imageMgr.clear();
|
||||
console.log(`=========================================`);
|
||||
console.log(`处理 ${psdPath} 文件`);
|
||||
let psdName = path_1.default.basename(psdPath, ".psd");
|
||||
let buffer = fs_extra_1.default.readFileSync(psdPath);
|
||||
const psdFile = psd.readPsd(buffer);
|
||||
let psdRoot = Parser_1.parser.parseLayer(psdFile);
|
||||
psdRoot.name = psdName;
|
||||
let prefabDir = path_1.default.join(outDir, psdName);
|
||||
let textureDir = path_1.default.join(prefabDir, "textures");
|
||||
fs_extra_1.default.mkdirsSync(prefabDir); // 创建预制体根目录
|
||||
// fs.emptyDirSync(prefabDir);
|
||||
fs_extra_1.default.mkdirsSync(textureDir); //创建 图片目录
|
||||
yield this.saveImage(textureDir);
|
||||
yield this.buildPrefab(psdRoot);
|
||||
yield this.savePrefab(psdRoot, prefabDir);
|
||||
console.log(`psd2ui ${psdPath} 处理完成`);
|
||||
});
|
||||
}
|
||||
buildPrefab(psdRoot) {
|
||||
let prefab = new CCPrefab_1.CCPrefab();
|
||||
psdRoot.pushObject(prefab);
|
||||
let data = this.createCCNode(psdRoot, psdRoot);
|
||||
prefab.data = { __id__: data.idx };
|
||||
// 后期处理
|
||||
this.postUIObject(psdRoot, psdRoot);
|
||||
}
|
||||
createCCNode(layer, psdRoot) {
|
||||
var _a, _b, _c, _d;
|
||||
let node = new CCNode_1.CCNode(psdRoot);
|
||||
layer.uiObject = node;
|
||||
node._name = ((_a = layer.attr) === null || _a === void 0 ? void 0 : _a.name) || layer.name;
|
||||
node._active = !layer.hidden;
|
||||
node._opacity = layer.opacity;
|
||||
if (config_1.config.editorVersion >= EditorVersion_1.EditorVersion.v342) {
|
||||
// 3.4.x
|
||||
if (layer.opacity !== 255) {
|
||||
let uiOpacity = new CCUIOpacity_1.CCUIOpacity();
|
||||
uiOpacity._opacity = layer.opacity;
|
||||
uiOpacity.updateWithLayer(layer);
|
||||
node.addComponent(uiOpacity);
|
||||
}
|
||||
}
|
||||
// 劫持尺寸设置,使用 psd 中配置的尺寸,这里不对原数据进行修改
|
||||
let size = new CCSize_1.CCSize(layer.size.width, layer.size.height);
|
||||
if ((_b = layer.attr) === null || _b === void 0 ? void 0 : _b.comps.size) {
|
||||
let _attrSize = layer.attr.comps.size;
|
||||
size.width = (_c = _attrSize.w) !== null && _c !== void 0 ? _c : size.width;
|
||||
size.height = (_d = _attrSize.h) !== null && _d !== void 0 ? _d : size.height;
|
||||
}
|
||||
// 对缩放进行处理
|
||||
size.width = Math.round(Math.abs(size.width / layer.scale.x));
|
||||
size.height = Math.round(Math.abs(size.height / layer.scale.y));
|
||||
// 配置的位置 Y 偏移
|
||||
let offsetY = 0;
|
||||
if (layer instanceof PsdText_1.PsdText) {
|
||||
offsetY = layer.offsetY;
|
||||
}
|
||||
node._contentSize = size;
|
||||
// 更新一下位置 // 根据图层名字设置 锚点,位置, 因为没有对原始数据进行修改,所以这里不考虑 缩放
|
||||
layer.updatePositionWithAR();
|
||||
// 2.4.9
|
||||
node._trs.setPosition(layer.position.x, layer.position.y + offsetY, 0);
|
||||
node._trs.setRotation(0, 0, 0, 1);
|
||||
node._trs.setScale(layer.scale.x, layer.scale.y, layer.scale.z);
|
||||
node._anchorPoint = new CCVec2_1.CCVec2(layer.anchorPoint.x, layer.anchorPoint.y);
|
||||
if (config_1.config.editorVersion >= EditorVersion_1.EditorVersion.v342) {
|
||||
// 3.4.x
|
||||
node._lpos = new CCVec3_1.CCVec3(layer.position.x, layer.position.y + offsetY, 0);
|
||||
node._lrot = new CCVec3_1.CCVec3(0, 0, 0);
|
||||
node._lscale = new CCVec3_1.CCVec3(layer.scale.x, layer.scale.y, layer.scale.z);
|
||||
node._euler = new CCVec3_1.CCVec3();
|
||||
// 3.4.x
|
||||
let uiTransform = new CCUITransform_1.CCUITransform();
|
||||
uiTransform._contentSize = size;
|
||||
uiTransform._anchorPoint = node._anchorPoint;
|
||||
uiTransform.updateWithLayer(layer);
|
||||
node.addComponent(uiTransform);
|
||||
}
|
||||
//
|
||||
if (layer instanceof PsdGroup_1.PsdGroup) {
|
||||
for (let i = 0; i < layer.children.length; i++) {
|
||||
const childLayer = layer.children[i];
|
||||
let childNode = this.createCCNode(childLayer, psdRoot);
|
||||
childNode && node.addChild(childNode);
|
||||
}
|
||||
}
|
||||
else if (layer instanceof PsdImage_1.PsdImage) {
|
||||
let sprite = new CCSprite_1.CCSprite();
|
||||
node.addComponent(sprite);
|
||||
sprite._materials.push({
|
||||
__uuid__: config_1.config.SpriteFrame_Material
|
||||
});
|
||||
sprite.updateWithLayer(layer);
|
||||
if (layer.isIgnore()) {
|
||||
// 忽略图像
|
||||
}
|
||||
else {
|
||||
// 查找绑定的图像
|
||||
let _layer = ImageMgr_1.imageMgr.getSerialNumberImage(layer);
|
||||
// 使用已缓存的 图片 的 uuid
|
||||
let imageWarp = ImageCacheMgr_1.imageCacheMgr.get(_layer.md5);
|
||||
sprite.setSpriteFrame(imageWarp ? imageWarp.textureUuid : _layer.textureUuid);
|
||||
}
|
||||
this.applyConfig(sprite);
|
||||
}
|
||||
else if (layer instanceof PsdText_1.PsdText) {
|
||||
let label = new CCLabel_1.CCLabel();
|
||||
node.addComponent(label);
|
||||
node._color.set(layer.color);
|
||||
label._color.set(layer.color);
|
||||
label._materials.push({
|
||||
__uuid__: config_1.config.Label_Material
|
||||
});
|
||||
label.updateWithLayer(layer);
|
||||
this.applyConfig(label);
|
||||
// 有描边
|
||||
if (layer.outline) {
|
||||
let labelOutline = new CCLabelOutline_1.CCLabelOutline();
|
||||
node.addComponent(labelOutline);
|
||||
labelOutline.updateWithLayer(layer);
|
||||
this.applyConfig(labelOutline);
|
||||
}
|
||||
}
|
||||
// Button / Toggle / ProgressBar
|
||||
if (layer.attr) {
|
||||
for (const key in layer.attr.comps) {
|
||||
if (Object.prototype.hasOwnProperty.call(layer.attr.comps, key) && layer.attr.comps[key]) {
|
||||
let ctor = config_1.config.CompMippings[key];
|
||||
if (ctor) {
|
||||
let comp = new ctor();
|
||||
node.addComponent(comp);
|
||||
comp.updateWithLayer(layer);
|
||||
this.applyConfig(comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.createPrefabInfo(layer, psdRoot);
|
||||
return node;
|
||||
}
|
||||
createPrefabInfo(layer, psdRoot) {
|
||||
let node = layer.uiObject;
|
||||
let prefabInfo = new CCPrefabInfo_1.CCPrefabInfo();
|
||||
let idx = psdRoot.pushObject(prefabInfo);
|
||||
node._prefab = { __id__: idx };
|
||||
}
|
||||
// 后处理
|
||||
postUIObject(layer, psdRoot) {
|
||||
}
|
||||
saveImage(out) {
|
||||
let images = ImageMgr_1.imageMgr.getAllImage();
|
||||
images.forEach((psdImage, k) => {
|
||||
// 查找镜像
|
||||
let _layer = ImageMgr_1.imageMgr.getSerialNumberImage(psdImage);
|
||||
// 查找已缓存的相同图像
|
||||
let imageWarp = ImageCacheMgr_1.imageCacheMgr.get(_layer.md5);
|
||||
// 不是强制导出的话,判断是否已经导出过
|
||||
if (!this.isForceImg) {
|
||||
// 判断是否已经导出过相同 md5 的资源,不再重复导出
|
||||
if (imageWarp === null || imageWarp === void 0 ? void 0 : imageWarp.isOutput) {
|
||||
console.log(`已有相同资源,不再导出 [${psdImage.imgName}] md5: ${psdImage.md5}`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
console.log(`保存图片 [${_layer.imgName}] md5: ${_layer.md5}`);
|
||||
imageWarp && (imageWarp.isOutput = true);
|
||||
let fullpath = path_1.default.join(out, `${_layer.imgName}.png`);
|
||||
fs_extra_1.default.writeFileSync(fullpath, _layer.imgBuffer);
|
||||
this.saveImageMeta(_layer, fullpath);
|
||||
});
|
||||
}
|
||||
saveImageMeta(layer, fullpath) {
|
||||
let _layer = ImageMgr_1.imageMgr.getSerialNumberImage(layer);
|
||||
let imageWarp = ImageCacheMgr_1.imageCacheMgr.get(_layer.md5);
|
||||
if (!imageWarp) {
|
||||
imageWarp = _layer;
|
||||
}
|
||||
// 2.4.9 =-> SPRITE_FRAME_UUID
|
||||
let meta = this.spriteFrameMetaContent.replace(/\$SPRITE_FRAME_UUID/g, imageWarp.uuid);
|
||||
meta = meta.replace(/\$TEXTURE_UUID/g, imageWarp.textureUuid);
|
||||
meta = meta.replace(/\$FILE_NAME/g, _layer.imgName);
|
||||
meta = meta.replace(/\$WIDTH/g, _layer.textureSize.width);
|
||||
meta = meta.replace(/\$HEIGHT/g, _layer.textureSize.height);
|
||||
let s9 = _layer.s9 || {
|
||||
b: 0, t: 0, l: 0, r: 0,
|
||||
};
|
||||
meta = meta.replace(/\$BORDER_TOP/g, s9.t);
|
||||
meta = meta.replace(/\$BORDER_BOTTOM/g, s9.b);
|
||||
meta = meta.replace(/\$BORDER_LEFT/g, s9.l);
|
||||
meta = meta.replace(/\$BORDER_RIGHT/g, s9.r);
|
||||
fs_extra_1.default.writeFileSync(fullpath + `.meta`, meta);
|
||||
}
|
||||
savePrefab(psdDoc, out) {
|
||||
let fullpath = path_1.default.join(out, `${psdDoc.name}.prefab`);
|
||||
fs_extra_1.default.writeFileSync(fullpath, JSON.stringify(psdDoc.objectArray, null, 2));
|
||||
this.savePrefabMeta(psdDoc, fullpath);
|
||||
}
|
||||
savePrefabMeta(psdDoc, fullpath) {
|
||||
let meta = this.prefabMetaContent.replace(/\$PREFB_UUID/g, psdDoc.uuid);
|
||||
fs_extra_1.default.writeFileSync(fullpath + `.meta`, meta);
|
||||
}
|
||||
applyConfig(comp) {
|
||||
if (!this.psdConfig) {
|
||||
return;
|
||||
}
|
||||
if (comp.__type__ in this.psdConfig) {
|
||||
let compConfig = this.psdConfig[comp.__type__];
|
||||
for (const key in compConfig) {
|
||||
if (Object.prototype.hasOwnProperty.call(compConfig, key)) {
|
||||
const element = compConfig[key];
|
||||
comp[key] = element;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.Main = Main;
|
||||
/** 合并别名 */
|
||||
function mergeAlias(args) {
|
||||
// 如果是 json 对象参数
|
||||
if (args.json) {
|
||||
let base64 = args.json;
|
||||
// 解码 json
|
||||
args = JSON.parse(Buffer.from(base64, "base64").toString());
|
||||
// // 编码
|
||||
// let jsonContent = JSON.stringify(args);
|
||||
// let base64 = Buffer.from(jsonContent).toString("base64");
|
||||
}
|
||||
args.help = args.help || args.h;
|
||||
args.input = args.input || args.in;
|
||||
args.output = args.output || args.out;
|
||||
args["engine-version"] = args["engine-version"] || args.ev;
|
||||
args["project-assets"] = args["project-assets"] || args.p;
|
||||
args["cache-remake"] = args["cache-remake"] || args.crm;
|
||||
args["force-img"] = args["force-img"] || args.fimg;
|
||||
args.cache = args.cache || args.c;
|
||||
args.init = args.init || args.i;
|
||||
args.config = args.config;
|
||||
return args;
|
||||
}
|
@ -1,105 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parser = exports.Parser = void 0;
|
||||
const ImageCacheMgr_1 = require("./assets-manager/ImageCacheMgr");
|
||||
const ImageMgr_1 = require("./assets-manager/ImageMgr");
|
||||
const LayerType_1 = require("./psd/LayerType");
|
||||
const PsdDocument_1 = require("./psd/PsdDocument");
|
||||
const PsdGroup_1 = require("./psd/PsdGroup");
|
||||
const PsdImage_1 = require("./psd/PsdImage");
|
||||
const PsdText_1 = require("./psd/PsdText");
|
||||
class Parser {
|
||||
/** 解析图层类型 */
|
||||
parseLayerType(source) {
|
||||
if ("children" in source) {
|
||||
if ("width" in source && "height" in source) {
|
||||
// Document
|
||||
return LayerType_1.LayerType.Doc;
|
||||
}
|
||||
else {
|
||||
// Group
|
||||
return LayerType_1.LayerType.Group;
|
||||
}
|
||||
}
|
||||
else if ("text" in source) {
|
||||
// Text
|
||||
return LayerType_1.LayerType.Text;
|
||||
}
|
||||
// else if ('placedLayer' in layer) {
|
||||
// // 智能对象
|
||||
// }
|
||||
return LayerType_1.LayerType.Image;
|
||||
}
|
||||
parseLayer(source, parent, rootDoc) {
|
||||
let layer = null;
|
||||
let layerType = this.parseLayerType(source);
|
||||
switch (layerType) {
|
||||
case LayerType_1.LayerType.Doc:
|
||||
case LayerType_1.LayerType.Group:
|
||||
{
|
||||
let group = null;
|
||||
// Group
|
||||
if (layerType == LayerType_1.LayerType.Group) {
|
||||
group = new PsdGroup_1.PsdGroup(source, parent, rootDoc);
|
||||
if (group.attr.comps.ignorenode || group.attr.comps.ignore) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Document
|
||||
group = new PsdDocument_1.PsdDocument(source);
|
||||
}
|
||||
for (let i = 0; i < source.children.length; i++) {
|
||||
const childSource = source.children[i];
|
||||
let child = this.parseLayer(childSource, group, rootDoc || group);
|
||||
if (child) {
|
||||
if (!child.attr.comps.ignorenode && !child.attr.comps.ignore) {
|
||||
// 没有进行忽略节点的时候才放入列表
|
||||
group.children.push(child);
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.error(`图层解析错误`);
|
||||
}
|
||||
}
|
||||
layer = group;
|
||||
}
|
||||
break;
|
||||
case LayerType_1.LayerType.Image:
|
||||
{
|
||||
//
|
||||
if (!source.canvas) {
|
||||
console.error(`Parser-> 空图层 ${source === null || source === void 0 ? void 0 : source.name}`);
|
||||
return null;
|
||||
}
|
||||
// Image
|
||||
let image = layer = new PsdImage_1.PsdImage(source, parent, rootDoc);
|
||||
ImageMgr_1.imageMgr.add(image);
|
||||
// 没有设置忽略且不说镜像的情况下才进行缓存
|
||||
if (!image.isIgnore() && !image.isBind()) {
|
||||
if (!ImageCacheMgr_1.imageCacheMgr.has(image.md5)) {
|
||||
ImageCacheMgr_1.imageCacheMgr.set(image.md5, {
|
||||
uuid: image.uuid,
|
||||
textureUuid: image.textureUuid,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case LayerType_1.LayerType.Text:
|
||||
{
|
||||
// Text
|
||||
layer = new PsdText_1.PsdText(source, parent, rootDoc);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
layer.layerType = layerType;
|
||||
layer.parseSource();
|
||||
layer.onCtor();
|
||||
return layer;
|
||||
}
|
||||
}
|
||||
exports.Parser = Parser;
|
||||
exports.parser = new Parser();
|
@ -1,2 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
@ -1,123 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ccversion = exports.cctype = exports.nonserialization = void 0;
|
||||
const EditorVersion_1 = require("./EditorVersion");
|
||||
/** 禁止序列化 */
|
||||
let nonserialization = (target, propertyKey) => {
|
||||
if (!target.__unserialization) {
|
||||
target.__unserialization = [];
|
||||
}
|
||||
target.__unserialization.push(propertyKey);
|
||||
// if(!target.toJSON){
|
||||
// // JSON.stringify 自动调用
|
||||
// target.toJSON = function(){
|
||||
// let data:Record<any,any> = {};
|
||||
// for (const key in this) {
|
||||
// if (Object.prototype.hasOwnProperty.call(this, key)) {
|
||||
// // @ts-ignore
|
||||
// if(this.__unserialization.indexOf(key) !== -1){
|
||||
// continue;
|
||||
// }
|
||||
// // 判断编辑器版本
|
||||
// if(this._version && !this._version[key][EditorVersion[config.editorVersion]]){
|
||||
// continue;
|
||||
// }
|
||||
// const value = this[key];
|
||||
// data[key] = value;
|
||||
// }
|
||||
// }
|
||||
// return data;
|
||||
// }
|
||||
// }
|
||||
};
|
||||
exports.nonserialization = nonserialization;
|
||||
function cctype(type) {
|
||||
return (target) => {
|
||||
Object.defineProperty(target.prototype, "$__type__", {
|
||||
value: type,
|
||||
enumerable: true,
|
||||
});
|
||||
};
|
||||
}
|
||||
exports.cctype = cctype;
|
||||
let _extends = {};
|
||||
let _class_attrs = {};
|
||||
let _target_map_ = {};
|
||||
let __verIdx = 0;
|
||||
let _printID = -1;
|
||||
function checkTag(target) {
|
||||
if (target.constructor.__ver_tag_id__ === undefined || _target_map_[target.constructor.__ver_tag_id__] != target) {
|
||||
target.constructor.__ver_tag_id__ = `${__verIdx}`;
|
||||
_target_map_[target.constructor.__ver_tag_id__] = target;
|
||||
__verIdx++;
|
||||
}
|
||||
return target.constructor.__ver_tag_id__;
|
||||
}
|
||||
function _assign(target, source) {
|
||||
for (const key in source) {
|
||||
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
||||
if (key in target) {
|
||||
continue;
|
||||
}
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
function assign(target, ...sources) {
|
||||
for (let i = 0; i < sources.length; i++) {
|
||||
_assign(target, sources[i]);
|
||||
}
|
||||
}
|
||||
function ccversion(version) {
|
||||
return (target, propertyKey) => {
|
||||
let _class_name_ = target.constructor.name;
|
||||
_class_name_ = checkTag(target);
|
||||
!_class_attrs[_class_name_] && (_class_attrs[_class_name_] = {});
|
||||
let _class_obj = _class_attrs[_class_name_];
|
||||
if (!_class_obj[propertyKey]) {
|
||||
_class_obj[propertyKey] = {};
|
||||
}
|
||||
if (EditorVersion_1.EditorVersion.all === version) {
|
||||
for (const key in EditorVersion_1.EditorVersion) {
|
||||
_class_obj[propertyKey][EditorVersion_1.EditorVersion[key]] = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_class_obj[propertyKey][EditorVersion_1.EditorVersion[version]] = true;
|
||||
}
|
||||
var base = getSuper(target.constructor);
|
||||
// (base === Object || base === UIObject) && (base = null);
|
||||
if (base) {
|
||||
let parent = checkTag(base.prototype);
|
||||
!_extends[_class_name_] && (_extends[_class_name_] = parent);
|
||||
var _super = getSuper(base);
|
||||
let superIdx = 1;
|
||||
while (_super) {
|
||||
// if(_super === Object || _super === UIObject) {
|
||||
// // _super = null;
|
||||
// break;
|
||||
// }
|
||||
let super_tag = checkTag(_super.prototype);
|
||||
!_extends[parent] && (_extends[parent] = super_tag);
|
||||
_super = getSuper(_super);
|
||||
superIdx++;
|
||||
}
|
||||
while (parent) {
|
||||
if (parent in _class_attrs) {
|
||||
assign(_class_obj, _class_attrs[parent]);
|
||||
}
|
||||
parent = _extends[parent];
|
||||
}
|
||||
}
|
||||
if (!target._version) {
|
||||
target._version = {};
|
||||
}
|
||||
target._version[_class_name_] = _class_attrs[_class_name_] = _class_obj;
|
||||
};
|
||||
}
|
||||
exports.ccversion = ccversion;
|
||||
function getSuper(ctor) {
|
||||
var proto = ctor.prototype; // binded function do not have prototype
|
||||
var dunderProto = proto && Object.getPrototypeOf(proto);
|
||||
return dunderProto && dunderProto.constructor;
|
||||
}
|
@ -1,153 +0,0 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.imageCacheMgr = exports.ImageCacheMgr = void 0;
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const config_1 = require("../config");
|
||||
const EditorVersion_1 = require("../EditorVersion");
|
||||
const FileUtils_1 = require("../utils/FileUtils");
|
||||
class ImageCacheMgr {
|
||||
constructor() {
|
||||
this._imageMap = new Map();
|
||||
this._cachePath = null;
|
||||
}
|
||||
initWithPath(_path) {
|
||||
if (!fs_extra_1.default.existsSync(_path)) {
|
||||
console.log(`ImageCacheMgr-> 文件不存在: ${_path}`);
|
||||
return;
|
||||
}
|
||||
this._cachePath = _path;
|
||||
let content = fs_extra_1.default.readFileSync(_path, "utf-8");
|
||||
this.initWithFile(content);
|
||||
}
|
||||
initWithFile(file) {
|
||||
let json = JSON.parse(file);
|
||||
this.initWithJson(json);
|
||||
}
|
||||
initWithJson(json) {
|
||||
for (const key in json) {
|
||||
if (Object.prototype.hasOwnProperty.call(json, key)) {
|
||||
this._imageMap.set(key, json[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
set(md5, warp) {
|
||||
this._imageMap.set(md5, warp);
|
||||
}
|
||||
has(md5) {
|
||||
return this._imageMap.has(md5);
|
||||
}
|
||||
get(md5) {
|
||||
return this._imageMap.get(md5);
|
||||
}
|
||||
saveImageMap(_path) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!_path) {
|
||||
_path = this._cachePath;
|
||||
}
|
||||
if (!_path) {
|
||||
console.log(`ImageCacheMgr-> 缓存路径 [${_path}] 不存在,无法保存 `);
|
||||
return;
|
||||
}
|
||||
let obj = Object.create(null);
|
||||
this._imageMap.forEach((v, k) => {
|
||||
obj[k] = v;
|
||||
});
|
||||
let content = JSON.stringify(obj, null, 2);
|
||||
yield FileUtils_1.fileUtils.writeFile(_path, content);
|
||||
});
|
||||
}
|
||||
// 获取已存在的图片,生成 md5: uuid 映射,
|
||||
loadImages(dir) {
|
||||
if (this._imageMap.size > 0) {
|
||||
console.error(`ImageCacheMgr-> 暂时只能在 启动时加载`);
|
||||
return;
|
||||
}
|
||||
let pngs = FileUtils_1.fileUtils.filterFile(dir, (fileName) => {
|
||||
let extname = path_1.default.extname(fileName);
|
||||
if (extname == ".png") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
for (let i = 0; i < pngs.length; i++) {
|
||||
const png = pngs[i];
|
||||
let md5 = FileUtils_1.fileUtils.getMD5(png);
|
||||
console.log(`ImageCacheMgr->缓存 `, png);
|
||||
let imageWarp = this._loadImageMetaWarp(`${png}.meta`);
|
||||
if (imageWarp) {
|
||||
this.set(md5, imageWarp);
|
||||
}
|
||||
}
|
||||
}
|
||||
_loadImageMetaWarp(_path) {
|
||||
let content = fs_extra_1.default.readFileSync(_path, { encoding: "utf-8" });
|
||||
let imageWarp = null;
|
||||
switch (config_1.config.editorVersion) {
|
||||
case EditorVersion_1.EditorVersion.v249:
|
||||
imageWarp = this._loadImageMeta249(content, _path);
|
||||
break;
|
||||
case EditorVersion_1.EditorVersion.v342:
|
||||
imageWarp = this._loadImageMeta34x(content, _path);
|
||||
break;
|
||||
default:
|
||||
console.log(`ImageCacheMgr-> 暂未实现 ${EditorVersion_1.EditorVersion[config_1.config.editorVersion]} 版本`);
|
||||
break;
|
||||
}
|
||||
return imageWarp;
|
||||
}
|
||||
_loadImageMeta249(metaContent, _path) {
|
||||
var _a;
|
||||
let filename = path_1.default.basename(_path, ".png.meta");
|
||||
let fullpath = path_1.default.join(path_1.default.dirname(_path), `${filename}.png`);
|
||||
let metaJson = JSON.parse(metaContent);
|
||||
if (!((_a = metaJson === null || metaJson === void 0 ? void 0 : metaJson.subMetas) === null || _a === void 0 ? void 0 : _a[filename])) {
|
||||
return null;
|
||||
}
|
||||
let imageWarp = {
|
||||
path: fullpath,
|
||||
textureUuid: metaJson.subMetas[filename].uuid,
|
||||
uuid: metaJson.uuid,
|
||||
isOutput: true,
|
||||
};
|
||||
return imageWarp;
|
||||
}
|
||||
_loadImageMeta34x(metaContent, _path) {
|
||||
var _a;
|
||||
let filename = path_1.default.basename(_path, ".png.meta");
|
||||
let fullpath = path_1.default.join(path_1.default.dirname(_path), `${filename}.png`);
|
||||
let metaJson = JSON.parse(metaContent);
|
||||
if (!((_a = metaJson === null || metaJson === void 0 ? void 0 : metaJson.subMetas) === null || _a === void 0 ? void 0 : _a["6c48a"])) {
|
||||
return null;
|
||||
}
|
||||
let uuid = metaJson.subMetas["6c48a"].uuid.replace("@6c48a", "");
|
||||
let imageWarp = {
|
||||
path: fullpath,
|
||||
textureUuid: uuid,
|
||||
uuid: uuid,
|
||||
isOutput: true,
|
||||
};
|
||||
return imageWarp;
|
||||
}
|
||||
static getInstance() {
|
||||
if (!this._instance) {
|
||||
this._instance = new ImageCacheMgr();
|
||||
}
|
||||
return this._instance;
|
||||
}
|
||||
}
|
||||
exports.ImageCacheMgr = ImageCacheMgr;
|
||||
ImageCacheMgr._instance = null;
|
||||
exports.imageCacheMgr = ImageCacheMgr.getInstance();
|
@ -1,56 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.imageMgr = void 0;
|
||||
class ImageMgr {
|
||||
constructor() {
|
||||
// 镜像图像管理
|
||||
this._imageIdKeyMap = new Map();
|
||||
// 当前 psd 所有的图片
|
||||
this._imageArray = new Map();
|
||||
}
|
||||
add(psdImage) {
|
||||
var _a;
|
||||
// 不忽略导出图片
|
||||
if (!psdImage.isIgnore() && !psdImage.isBind()) {
|
||||
if (!this._imageArray.has(psdImage.md5)) {
|
||||
this._imageArray.set(psdImage.md5, psdImage);
|
||||
}
|
||||
}
|
||||
if (typeof ((_a = psdImage.attr.comps.img) === null || _a === void 0 ? void 0 : _a.id) != "undefined") {
|
||||
let id = psdImage.attr.comps.img.id;
|
||||
if (this._imageIdKeyMap.has(id)) {
|
||||
console.warn(`ImageMgr-> ${psdImage.source.name} 已有相同 @img{id:${id}},请检查 psd 图层`);
|
||||
}
|
||||
this._imageIdKeyMap.set(id, psdImage);
|
||||
}
|
||||
}
|
||||
getAllImage() {
|
||||
return this._imageArray;
|
||||
}
|
||||
/** 尝试获取有编号的图像图层 */
|
||||
getSerialNumberImage(psdImage) {
|
||||
var _a, _b, _c;
|
||||
let bind = (_b = (_a = psdImage.attr.comps.flip) === null || _a === void 0 ? void 0 : _a.bind) !== null && _b !== void 0 ? _b : (_c = psdImage.attr.comps.img) === null || _c === void 0 ? void 0 : _c.bind;
|
||||
if (typeof bind != 'undefined') {
|
||||
if (this._imageIdKeyMap.has(bind)) {
|
||||
return this._imageIdKeyMap.get(bind);
|
||||
}
|
||||
else {
|
||||
console.warn(`ImageMgr-> ${psdImage.source.name} 未找到绑定的图像 {${bind}},请检查 psd 图层`);
|
||||
}
|
||||
}
|
||||
return psdImage;
|
||||
}
|
||||
clear() {
|
||||
this._imageIdKeyMap.clear();
|
||||
this._imageArray.clear();
|
||||
}
|
||||
static getInstance() {
|
||||
if (!this._instance) {
|
||||
this._instance = new ImageMgr();
|
||||
}
|
||||
return this._instance;
|
||||
}
|
||||
}
|
||||
ImageMgr._instance = null;
|
||||
exports.imageMgr = ImageMgr.getInstance();
|
@ -1,56 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.config = exports.Config = void 0;
|
||||
const EditorVersion_1 = require("./EditorVersion");
|
||||
const CCButton_1 = require("./engine/cc/CCButton");
|
||||
const CCProgressBar_1 = require("./engine/cc/CCProgressBar");
|
||||
const CCToggle_1 = require("./engine/cc/CCToggle");
|
||||
class Config {
|
||||
constructor() {
|
||||
this.help = `
|
||||
--help | --h 帮助信息
|
||||
--init | --i 初始化缓存文件 必须设置 --project-assets --cache 两项
|
||||
--force-img | --fimg 强制导出图片 即使在有缓存的情况下也要导出
|
||||
--input | --in 输入目录或者 psd 文件 非 init 时 必选 [dir or psd]
|
||||
--output | --out 输出目录 可选 缺省时为 --input [dir]
|
||||
--engine-version | --ev 引擎版本 可选 [v249 | v342 | v362]
|
||||
--project-assets | --p 指定项目文件夹 可选 [dir]
|
||||
--cache-remake | --crm 重新创建缓存文件 可选
|
||||
--cache | --c 缓存文件全路径 可选 [file-full-path]
|
||||
--config | 预制体配置 可选 [file-full-path]
|
||||
--img-only | 只导出图片 可选
|
||||
--json | json 对象参数 插件工具使用 将所有参数用对象的形式编码成 base64 字符串
|
||||
`;
|
||||
this.editorVersion = EditorVersion_1.EditorVersion.v249;
|
||||
this.DEFAULT_SPRITEFRAME_MATERIAL = {
|
||||
[EditorVersion_1.EditorVersion.v249]: "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432",
|
||||
[EditorVersion_1.EditorVersion.v342]: "",
|
||||
[EditorVersion_1.EditorVersion.v362]: "",
|
||||
};
|
||||
this.DEFAULT_LABEL_MATERIAL = {
|
||||
[EditorVersion_1.EditorVersion.v249]: "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432",
|
||||
[EditorVersion_1.EditorVersion.v342]: "",
|
||||
[EditorVersion_1.EditorVersion.v362]: "",
|
||||
};
|
||||
this.CompMippings = {
|
||||
"Btn": CCButton_1.CCButton,
|
||||
"ProgressBar": CCProgressBar_1.CCProgressBar,
|
||||
"Toggle": CCToggle_1.CCToggle,
|
||||
};
|
||||
// text 文本 Y 偏移
|
||||
this.textOffsetY = {
|
||||
default: 0,
|
||||
"36": 0,
|
||||
};
|
||||
// text 文本 行高偏移,默认为 0 ,行高默认为 字体大小
|
||||
this.textLineHeightOffset = 0;
|
||||
}
|
||||
get SpriteFrame_Material() {
|
||||
return this.DEFAULT_SPRITEFRAME_MATERIAL[exports.config.editorVersion];
|
||||
}
|
||||
get Label_Material() {
|
||||
return this.DEFAULT_LABEL_MATERIAL[exports.config.editorVersion];
|
||||
}
|
||||
}
|
||||
exports.Config = Config;
|
||||
exports.config = new Config();
|
@ -1,52 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UIObject = void 0;
|
||||
const config_1 = require("../config");
|
||||
const EditorVersion_1 = require("../EditorVersion");
|
||||
const Utils_1 = require("../utils/Utils");
|
||||
const _decorator_1 = require("../_decorator");
|
||||
class UIObject {
|
||||
constructor() {
|
||||
this.uuid = "";
|
||||
this.idx = 0;
|
||||
this.uuid = Utils_1.utils.uuid();
|
||||
}
|
||||
toJSON() {
|
||||
var _a;
|
||||
let data = {};
|
||||
for (const key in this) {
|
||||
if (Object.prototype.hasOwnProperty.call(this, key)) {
|
||||
// @ts-ignore
|
||||
if (this.__unserialization && this.__unserialization.indexOf(key) !== -1) {
|
||||
continue;
|
||||
}
|
||||
// @ts-ignore
|
||||
let ver_tag = this.constructor.__ver_tag_id__;
|
||||
// 判断编辑器版本
|
||||
// @ts-ignore
|
||||
if (this._version && ((_a = this._version[ver_tag]) === null || _a === void 0 ? void 0 : _a[key])) {
|
||||
// @ts-ignore
|
||||
if (!this._version[ver_tag][key][EditorVersion_1.EditorVersion[config_1.config.editorVersion]]) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
const value = this[key];
|
||||
data[key] = value;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
__decorate([
|
||||
_decorator_1.nonserialization
|
||||
], UIObject.prototype, "uuid", void 0);
|
||||
__decorate([
|
||||
_decorator_1.nonserialization
|
||||
], UIObject.prototype, "idx", void 0);
|
||||
exports.UIObject = UIObject;
|
@ -1,87 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCButton = void 0;
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const CCComponent_1 = require("./CCComponent");
|
||||
let CCButton = class CCButton extends CCComponent_1.CCComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
// 2.4.x
|
||||
this.duration = 0.1;
|
||||
// 2.4.x
|
||||
this.zoomScale = 1.2;
|
||||
this.clickEvents = [];
|
||||
// 2.4.x
|
||||
this._N$interactable = true;
|
||||
// 2.4.x
|
||||
this._N$enableAutoGrayEffect = false;
|
||||
// 2.4.x
|
||||
this._N$transition = 3;
|
||||
// 2.4.x
|
||||
this.transition = 3;
|
||||
// 2.4.x
|
||||
this._N$target = null;
|
||||
// 3.4.x
|
||||
this._interactable = true;
|
||||
// 3.4.x
|
||||
this._transition = 3;
|
||||
// 3.4.x
|
||||
this._duration = 0.1;
|
||||
// 3.4.x
|
||||
this._zoomScale = 1.2;
|
||||
// 3.4.x
|
||||
this._target = null;
|
||||
}
|
||||
updateWithLayer(psdLayer) {
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCButton.prototype, "duration", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCButton.prototype, "zoomScale", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCButton.prototype, "clickEvents", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCButton.prototype, "_N$interactable", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCButton.prototype, "_N$enableAutoGrayEffect", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCButton.prototype, "_N$transition", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCButton.prototype, "transition", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCButton.prototype, "_N$target", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCButton.prototype, "_interactable", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCButton.prototype, "_transition", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCButton.prototype, "_duration", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCButton.prototype, "_zoomScale", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCButton.prototype, "_target", void 0);
|
||||
CCButton = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.Button")
|
||||
], CCButton);
|
||||
exports.CCButton = CCButton;
|
@ -1,15 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCCompPrefabInfo = void 0;
|
||||
const Utils_1 = require("../../utils/Utils");
|
||||
const UIObject_1 = require("../UIObject");
|
||||
// @cctype("cc.CompPrefabInfo")
|
||||
class CCCompPrefabInfo extends UIObject_1.UIObject {
|
||||
constructor() {
|
||||
super();
|
||||
this.__type__ = "cc.CompPrefabInfo";
|
||||
this.fileId = "";
|
||||
this.fileId = Utils_1.utils.compressUuid(this.uuid);
|
||||
}
|
||||
}
|
||||
exports.CCCompPrefabInfo = CCCompPrefabInfo;
|
@ -1,35 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCComponent = void 0;
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const CCObject_1 = require("./CCObject");
|
||||
class CCComponent extends CCObject_1.CCObject {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this._enabled = true;
|
||||
this.node = null;
|
||||
this._id = "";
|
||||
// 3.4.x
|
||||
this.__prefab = null;
|
||||
}
|
||||
}
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCComponent.prototype, "_enabled", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCComponent.prototype, "node", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCComponent.prototype, "_id", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCComponent.prototype, "__prefab", void 0);
|
||||
exports.CCComponent = CCComponent;
|
@ -1,167 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCLabel = void 0;
|
||||
const config_1 = require("../../config");
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const CCComponent_1 = require("./CCComponent");
|
||||
const CCColor_1 = require("./values/CCColor");
|
||||
let CCLabel = class CCLabel extends CCComponent_1.CCComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this._srcBlendFactor = 770; // 3.4.x = 2
|
||||
this._dstBlendFactor = 771; // 3.4.x = 4
|
||||
this._string = "";
|
||||
this._fontSize = 0;
|
||||
this._lineHeight = 0;
|
||||
this._enableWrapText = true;
|
||||
this._isSystemFontUsed = true;
|
||||
this._spacingX = 0;
|
||||
this._underlineHeight = 0;
|
||||
this._materials = [];
|
||||
// 2.4.x
|
||||
this._N$string = "";
|
||||
// 2.4.x
|
||||
this._N$file = null;
|
||||
// 2.4.x
|
||||
this._batchAsBitmap = false;
|
||||
// 2.4.x
|
||||
this._styleFlags = 0;
|
||||
// 2.4.x
|
||||
this._N$horizontalAlign = 1;
|
||||
// 2.4.x
|
||||
this._N$verticalAlign = 1;
|
||||
// 2.4.x
|
||||
this._N$fontFamily = "Arial";
|
||||
// 2.4.x
|
||||
this._N$overflow = 0;
|
||||
// 2.4.x
|
||||
this._N$cacheMode = 0;
|
||||
// 3.4.x
|
||||
this._visFlags = 0;
|
||||
// 3.4.x
|
||||
this._customMaterial = null;
|
||||
// 3.4.x
|
||||
this._color = new CCColor_1.CCColor(255, 255, 255, 255);
|
||||
// 3.4.x
|
||||
this._overflow = 0;
|
||||
// // 3.4.x
|
||||
this._cacheMode = 0;
|
||||
this._horizontalAlign = 1;
|
||||
this._verticalAlign = 1;
|
||||
this._actualFontSize = 0;
|
||||
this._isItalic = false;
|
||||
this._isBold = false;
|
||||
this._isUnderline = false;
|
||||
}
|
||||
updateWithLayer(psdLayer) {
|
||||
this._fontSize = psdLayer.fontSize;
|
||||
// this._actualFontSize = this._fontSize;
|
||||
this._string = this._N$string = psdLayer.text;
|
||||
this._lineHeight = this._fontSize + config_1.config.textLineHeightOffset;
|
||||
if (config_1.config.editorVersion >= EditorVersion_1.EditorVersion.v342) {
|
||||
this._srcBlendFactor = 2;
|
||||
this._dstBlendFactor = 4;
|
||||
}
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCLabel.prototype, "_srcBlendFactor", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCLabel.prototype, "_dstBlendFactor", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCLabel.prototype, "_string", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCLabel.prototype, "_fontSize", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCLabel.prototype, "_lineHeight", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCLabel.prototype, "_enableWrapText", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCLabel.prototype, "_isSystemFontUsed", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCLabel.prototype, "_spacingX", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCLabel.prototype, "_underlineHeight", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCLabel.prototype, "_materials", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCLabel.prototype, "_N$string", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCLabel.prototype, "_N$file", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCLabel.prototype, "_batchAsBitmap", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCLabel.prototype, "_styleFlags", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCLabel.prototype, "_N$horizontalAlign", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCLabel.prototype, "_N$verticalAlign", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCLabel.prototype, "_N$fontFamily", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCLabel.prototype, "_N$overflow", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCLabel.prototype, "_N$cacheMode", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCLabel.prototype, "_visFlags", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCLabel.prototype, "_customMaterial", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCLabel.prototype, "_color", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCLabel.prototype, "_overflow", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCLabel.prototype, "_cacheMode", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCLabel.prototype, "_horizontalAlign", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCLabel.prototype, "_verticalAlign", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCLabel.prototype, "_actualFontSize", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCLabel.prototype, "_isItalic", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCLabel.prototype, "_isBold", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCLabel.prototype, "_isUnderline", void 0);
|
||||
CCLabel = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.Label")
|
||||
], CCLabel);
|
||||
exports.CCLabel = CCLabel;
|
@ -1,34 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCLabelOutline = void 0;
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const CCComponent_1 = require("./CCComponent");
|
||||
const CCColor_1 = require("./values/CCColor");
|
||||
let CCLabelOutline = class CCLabelOutline extends CCComponent_1.CCComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this._color = new CCColor_1.CCColor(255, 255, 255, 255);
|
||||
this._width = 1;
|
||||
}
|
||||
updateWithLayer(psdLayer) {
|
||||
this._width = psdLayer.outline.width;
|
||||
this._color.set(psdLayer.outline.color);
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCLabelOutline.prototype, "_color", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCLabelOutline.prototype, "_width", void 0);
|
||||
CCLabelOutline = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.LabelOutline")
|
||||
], CCLabelOutline);
|
||||
exports.CCLabelOutline = CCLabelOutline;
|
@ -1,177 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCNode = void 0;
|
||||
const config_1 = require("../../config");
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const CCCompPrefabInfo_1 = require("./CCCompPrefabInfo");
|
||||
const CCObject_1 = require("./CCObject");
|
||||
const CCColor_1 = require("./values/CCColor");
|
||||
const CCSize_1 = require("./values/CCSize");
|
||||
const CCTypedArray_1 = require("./values/CCTypedArray");
|
||||
const CCVec2_1 = require("./values/CCVec2");
|
||||
const CCVec3_1 = require("./values/CCVec3");
|
||||
let CCNode = class CCNode extends CCObject_1.CCObject {
|
||||
constructor(psdDoc) {
|
||||
super();
|
||||
this._parent = null;
|
||||
this._children = [];
|
||||
this._active = true;
|
||||
this._components = [];
|
||||
this._prefab = null;
|
||||
this._id = "";
|
||||
// 2.4.x
|
||||
this._opacity = 255;
|
||||
// 2.4.x
|
||||
this._color = new CCColor_1.CCColor(255, 255, 255, 255);
|
||||
// 2.4.x
|
||||
this._contentSize = new CCSize_1.CCSize();
|
||||
// 2.4.x
|
||||
this._anchorPoint = new CCVec2_1.CCVec2(0, 0);
|
||||
// 2.4.x
|
||||
this._trs = new CCTypedArray_1.CCTypedArray();
|
||||
// 2.4.x
|
||||
this._eulerAngles = new CCVec3_1.CCVec3();
|
||||
// 2.4.x
|
||||
this._skewX = 0;
|
||||
// 2.4.x
|
||||
this._skewY = 0;
|
||||
// 2.4.x
|
||||
this._is3DNode = false;
|
||||
// 2.4.x
|
||||
this._groupIndex = 0;
|
||||
// 2.4.x
|
||||
this.groupIndex = 0;
|
||||
// 2.4.x
|
||||
this._renderEnable = false;
|
||||
// 2.4.x
|
||||
this._bfsRenderFlag = false;
|
||||
// 3.4.x
|
||||
this._lpos = new CCVec3_1.CCVec3();
|
||||
// 3.4.x
|
||||
this._lrot = new CCVec3_1.CCVec3();
|
||||
// 3.4.x
|
||||
this._lscale = new CCVec3_1.CCVec3();
|
||||
// 3.4.x
|
||||
this._euler = new CCVec3_1.CCVec3();
|
||||
// 3.4.x
|
||||
this._layer = 33554432;
|
||||
this.psdDoc = null;
|
||||
this.components = [];
|
||||
this.children = [];
|
||||
if (psdDoc) {
|
||||
this.psdDoc = psdDoc;
|
||||
psdDoc.pushObject(this);
|
||||
}
|
||||
}
|
||||
addComponent(comp) {
|
||||
comp.node = { __id__: this.idx };
|
||||
let compIdx = this.psdDoc.pushObject(comp);
|
||||
this._components.push({ __id__: compIdx });
|
||||
this.components.push(comp);
|
||||
if (config_1.config.editorVersion >= EditorVersion_1.EditorVersion.v342) {
|
||||
this.addCompPrefabInfo(comp);
|
||||
}
|
||||
}
|
||||
addCompPrefabInfo(comp) {
|
||||
let compInfo = new CCCompPrefabInfo_1.CCCompPrefabInfo();
|
||||
let compIdx = this.psdDoc.pushObject(compInfo);
|
||||
comp.__prefab = { __id__: compIdx };
|
||||
}
|
||||
addChild(child) {
|
||||
this._children.push({ __id__: child.idx });
|
||||
child._parent = { __id__: this.idx };
|
||||
this.children.push(child);
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCNode.prototype, "_parent", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCNode.prototype, "_children", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCNode.prototype, "_active", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCNode.prototype, "_components", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCNode.prototype, "_prefab", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCNode.prototype, "_id", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_opacity", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_color", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_contentSize", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_anchorPoint", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_trs", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_eulerAngles", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_skewX", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_skewY", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_is3DNode", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_groupIndex", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "groupIndex", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_renderEnable", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_bfsRenderFlag", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCNode.prototype, "_lpos", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCNode.prototype, "_lrot", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCNode.prototype, "_lscale", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCNode.prototype, "_euler", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCNode.prototype, "_layer", void 0);
|
||||
__decorate([
|
||||
_decorator_1.nonserialization
|
||||
], CCNode.prototype, "psdDoc", void 0);
|
||||
__decorate([
|
||||
_decorator_1.nonserialization
|
||||
], CCNode.prototype, "components", void 0);
|
||||
__decorate([
|
||||
_decorator_1.nonserialization
|
||||
], CCNode.prototype, "children", void 0);
|
||||
CCNode = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.Node")
|
||||
], CCNode);
|
||||
exports.CCNode = CCNode;
|
@ -1,31 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCObject = void 0;
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const UIObject_1 = require("../UIObject");
|
||||
class CCObject extends UIObject_1.UIObject {
|
||||
constructor() {
|
||||
super();
|
||||
this._name = "";
|
||||
this._objFlags = 0;
|
||||
// @ts-ignore
|
||||
this.__type__ = this.$__type__;
|
||||
}
|
||||
}
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCObject.prototype, "__type__", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCObject.prototype, "_name", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCObject.prototype, "_objFlags", void 0);
|
||||
exports.CCObject = CCObject;
|
@ -1,47 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCPrefab = void 0;
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const CCObject_1 = require("./CCObject");
|
||||
let CCPrefab = class CCPrefab extends CCObject_1.CCObject {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this._native = "";
|
||||
this.data = null;
|
||||
this.optimizationPolicy = 0;
|
||||
this.asyncLoadAssets = false;
|
||||
// 2.4.x
|
||||
this.readonly = false;
|
||||
// // 3.4.x
|
||||
this.persistent = false;
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCPrefab.prototype, "_native", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCPrefab.prototype, "data", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCPrefab.prototype, "optimizationPolicy", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCPrefab.prototype, "asyncLoadAssets", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCPrefab.prototype, "readonly", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCPrefab.prototype, "persistent", void 0);
|
||||
CCPrefab = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.Prefab")
|
||||
], CCPrefab);
|
||||
exports.CCPrefab = CCPrefab;
|
@ -1,41 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCPrefabInfo = void 0;
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const Utils_1 = require("../../utils/Utils");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const UIObject_1 = require("../UIObject");
|
||||
// @cctype("cc.PrefabInfo")
|
||||
class CCPrefabInfo extends UIObject_1.UIObject {
|
||||
constructor() {
|
||||
super();
|
||||
this.__type__ = "cc.PrefabInfo";
|
||||
this.root = { __id__: 1 };
|
||||
this.asset = { __id__: 0 };
|
||||
this.fileId = "";
|
||||
this.sync = false;
|
||||
this.fileId = Utils_1.utils.compressUuid(this.uuid);
|
||||
}
|
||||
}
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCPrefabInfo.prototype, "__type__", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCPrefabInfo.prototype, "root", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCPrefabInfo.prototype, "asset", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCPrefabInfo.prototype, "fileId", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCPrefabInfo.prototype, "sync", void 0);
|
||||
exports.CCPrefabInfo = CCPrefabInfo;
|
@ -1,98 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCProgressBar = void 0;
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const CCComponent_1 = require("./CCComponent");
|
||||
const CCSprite_1 = require("./CCSprite");
|
||||
let CCProgressBar = class CCProgressBar extends CCComponent_1.CCComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
// 2.4.x
|
||||
this._N$totalLength = 0;
|
||||
// 2.4.x
|
||||
this._N$barSprite = null;
|
||||
// 2.4.x
|
||||
this._N$mode = 0;
|
||||
// 2.4.x
|
||||
this._N$progress = 1;
|
||||
// 2.4.x
|
||||
this._N$reverse = false;
|
||||
// 3.4.x
|
||||
this._barSprite = null;
|
||||
// 3.4.x
|
||||
this._mode = 0;
|
||||
// 3.4.x
|
||||
this._totalLength = 0;
|
||||
// 3.4.x
|
||||
this._progress = 1;
|
||||
// 3.4.x
|
||||
this._reverse = false;
|
||||
}
|
||||
setBar(sprite) {
|
||||
this._barSprite = this._N$barSprite = {
|
||||
__id__: sprite.idx
|
||||
};
|
||||
}
|
||||
updateWithLayer(psdLayer) {
|
||||
if (!psdLayer.children) {
|
||||
console.error(`CCProgressBar-> 只能作用在 组图层 上`);
|
||||
return;
|
||||
}
|
||||
outer: for (let i = 0; i < psdLayer.children.length; i++) {
|
||||
const child = psdLayer.children[i];
|
||||
if (child.attr.comps.bar) {
|
||||
let node = child.uiObject;
|
||||
// 暂时只有横向进度条
|
||||
this._totalLength = this._N$totalLength = node._contentSize.width;
|
||||
for (let j = 0; j < node.components.length; j++) {
|
||||
const comp = node.components[j];
|
||||
if (comp instanceof CCSprite_1.CCSprite) {
|
||||
this.setBar(comp);
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCProgressBar.prototype, "_N$totalLength", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCProgressBar.prototype, "_N$barSprite", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCProgressBar.prototype, "_N$mode", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCProgressBar.prototype, "_N$progress", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCProgressBar.prototype, "_N$reverse", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCProgressBar.prototype, "_barSprite", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCProgressBar.prototype, "_mode", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCProgressBar.prototype, "_totalLength", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCProgressBar.prototype, "_progress", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCProgressBar.prototype, "_reverse", void 0);
|
||||
CCProgressBar = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.ProgressBar")
|
||||
], CCProgressBar);
|
||||
exports.CCProgressBar = CCProgressBar;
|
@ -1,117 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCSprite = void 0;
|
||||
const config_1 = require("../../config");
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const CCComponent_1 = require("./CCComponent");
|
||||
const CCColor_1 = require("./values/CCColor");
|
||||
const CCVec2_1 = require("./values/CCVec2");
|
||||
let CCSprite = class CCSprite extends CCComponent_1.CCComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
// 2.4.x
|
||||
this._materials = [];
|
||||
this._srcBlendFactor = 770; // 3.4.x = 2
|
||||
this._dstBlendFactor = 771; // 3.4.x = 4
|
||||
this._spriteFrame = null;
|
||||
this._type = 0;
|
||||
this._sizeMode = 1;
|
||||
this._fillType = 0;
|
||||
this._fillCenter = new CCVec2_1.CCVec2();
|
||||
this._fillStart = 0;
|
||||
this._fillRange = 0;
|
||||
this._isTrimmedMode = true;
|
||||
this._atlas = null;
|
||||
// 3.4.x
|
||||
this._visFlags = 0;
|
||||
// 3.4.x
|
||||
this._customMaterial = null;
|
||||
// 3.4.x
|
||||
this._color = new CCColor_1.CCColor(255, 255, 255, 255);
|
||||
// 3.4.x
|
||||
this._useGrayscale = false;
|
||||
}
|
||||
use9() {
|
||||
this._type = 1;
|
||||
this._sizeMode = 0;
|
||||
}
|
||||
updateWithLayer(psdLayer) {
|
||||
if (psdLayer.s9) {
|
||||
this.use9();
|
||||
}
|
||||
if (Math.abs(psdLayer.scale.x) != 1 || Math.abs(psdLayer.scale.y) != 1) {
|
||||
this._sizeMode = 0;
|
||||
}
|
||||
if (config_1.config.editorVersion >= EditorVersion_1.EditorVersion.v342) {
|
||||
this._srcBlendFactor = 2;
|
||||
this._dstBlendFactor = 4;
|
||||
}
|
||||
}
|
||||
setSpriteFrame(uuid) {
|
||||
if (config_1.config.editorVersion >= EditorVersion_1.EditorVersion.v342) {
|
||||
this._spriteFrame = { __uuid__: `${uuid}@f9941`, __expectedType__: "cc.SpriteFrame" };
|
||||
}
|
||||
else {
|
||||
this._spriteFrame = { __uuid__: uuid };
|
||||
}
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCSprite.prototype, "_materials", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCSprite.prototype, "_srcBlendFactor", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCSprite.prototype, "_dstBlendFactor", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCSprite.prototype, "_spriteFrame", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCSprite.prototype, "_type", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCSprite.prototype, "_sizeMode", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCSprite.prototype, "_fillType", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCSprite.prototype, "_fillCenter", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCSprite.prototype, "_fillStart", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCSprite.prototype, "_fillRange", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCSprite.prototype, "_isTrimmedMode", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCSprite.prototype, "_atlas", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCSprite.prototype, "_visFlags", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCSprite.prototype, "_customMaterial", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCSprite.prototype, "_color", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCSprite.prototype, "_useGrayscale", void 0);
|
||||
CCSprite = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.Sprite")
|
||||
], CCSprite);
|
||||
exports.CCSprite = CCSprite;
|
@ -1,75 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCToggle = void 0;
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const CCButton_1 = require("./CCButton");
|
||||
const CCSprite_1 = require("./CCSprite");
|
||||
let CCToggle = class CCToggle extends CCButton_1.CCButton {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
// 2.4.x
|
||||
this._N$isChecked = true;
|
||||
// 2.4.x
|
||||
this.toggleGroup = null;
|
||||
// 2.4.x
|
||||
this.checkMark = null;
|
||||
this.checkEvents = [];
|
||||
// 3.4.x
|
||||
this._isChecked = true;
|
||||
// 3.4.x
|
||||
this._checkMark = null;
|
||||
}
|
||||
setCheckMark(sprite) {
|
||||
this._checkMark = this.checkMark = {
|
||||
__id__: sprite.idx
|
||||
};
|
||||
}
|
||||
updateWithLayer(psdLayer) {
|
||||
if (!psdLayer.children) {
|
||||
console.error(`CCToggle-> 只能作用在 组图层 上`);
|
||||
return;
|
||||
}
|
||||
outer: for (let i = 0; i < psdLayer.children.length; i++) {
|
||||
const child = psdLayer.children[i];
|
||||
if (child.attr.comps.check) {
|
||||
let node = child.uiObject;
|
||||
for (let j = 0; j < node.components.length; j++) {
|
||||
const comp = node.components[j];
|
||||
if (comp instanceof CCSprite_1.CCSprite) {
|
||||
this.setCheckMark(comp);
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCToggle.prototype, "_N$isChecked", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCToggle.prototype, "toggleGroup", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCToggle.prototype, "checkMark", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCToggle.prototype, "checkEvents", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCToggle.prototype, "_isChecked", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCToggle.prototype, "_checkMark", void 0);
|
||||
CCToggle = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.Toggle")
|
||||
], CCToggle);
|
||||
exports.CCToggle = CCToggle;
|
@ -1,28 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCUIOpacity = void 0;
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const CCComponent_1 = require("./CCComponent");
|
||||
// 3.4.x
|
||||
let CCUIOpacity = class CCUIOpacity extends CCComponent_1.CCComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this._opacity = 255;
|
||||
}
|
||||
updateWithLayer(psdLayer) {
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCUIOpacity.prototype, "_opacity", void 0);
|
||||
CCUIOpacity = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.UIOpacity")
|
||||
], CCUIOpacity);
|
||||
exports.CCUIOpacity = CCUIOpacity;
|
@ -1,34 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCUITransform = void 0;
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const CCComponent_1 = require("./CCComponent");
|
||||
const CCSize_1 = require("./values/CCSize");
|
||||
const CCVec2_1 = require("./values/CCVec2");
|
||||
// 3.4.x
|
||||
let CCUITransform = class CCUITransform extends CCComponent_1.CCComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this._contentSize = new CCSize_1.CCSize();
|
||||
this._anchorPoint = new CCVec2_1.CCVec2(0, 0);
|
||||
}
|
||||
updateWithLayer(psdLayer) {
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCUITransform.prototype, "_contentSize", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCUITransform.prototype, "_anchorPoint", void 0);
|
||||
CCUITransform = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.UITransform")
|
||||
], CCUITransform);
|
||||
exports.CCUITransform = CCUITransform;
|
@ -1,11 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCColor = void 0;
|
||||
const Color_1 = require("../../../values/Color");
|
||||
class CCColor extends Color_1.Color {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.__type__ = "cc.Color";
|
||||
}
|
||||
}
|
||||
exports.CCColor = CCColor;
|
@ -1,21 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCSize = void 0;
|
||||
const Size_1 = require("../../../values/Size");
|
||||
const _decorator_1 = require("../../../_decorator");
|
||||
let CCSize = class CCSize extends Size_1.Size {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.__type__ = "cc.Size";
|
||||
}
|
||||
};
|
||||
CCSize = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.Size")
|
||||
], CCSize);
|
||||
exports.CCSize = CCSize;
|
@ -1,37 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCTypedArray = void 0;
|
||||
const _decorator_1 = require("../../../_decorator");
|
||||
let CCTypedArray = class CCTypedArray {
|
||||
constructor() {
|
||||
this.__type__ = "TypedArray";
|
||||
this.ctor = "Float64Array";
|
||||
this.array = [];
|
||||
}
|
||||
setPosition(x, y, z) {
|
||||
this.array[0] = x;
|
||||
this.array[1] = y;
|
||||
this.array[2] = z;
|
||||
}
|
||||
setRotation(x, y, z, w) {
|
||||
this.array[3] = x;
|
||||
this.array[4] = y;
|
||||
this.array[5] = z;
|
||||
this.array[6] = w;
|
||||
}
|
||||
setScale(x, y, z) {
|
||||
this.array[7] = x;
|
||||
this.array[8] = y;
|
||||
this.array[9] = z;
|
||||
}
|
||||
};
|
||||
CCTypedArray = __decorate([
|
||||
(0, _decorator_1.cctype)("TypedArray")
|
||||
], CCTypedArray);
|
||||
exports.CCTypedArray = CCTypedArray;
|
@ -1,21 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCVec2 = void 0;
|
||||
const Vec2_1 = require("../../../values/Vec2");
|
||||
const _decorator_1 = require("../../../_decorator");
|
||||
let CCVec2 = class CCVec2 extends Vec2_1.Vec2 {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.__type__ = "cc.Vec2";
|
||||
}
|
||||
};
|
||||
CCVec2 = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.Vec2")
|
||||
], CCVec2);
|
||||
exports.CCVec2 = CCVec2;
|
@ -1,11 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCVec3 = void 0;
|
||||
const Vec3_1 = require("../../../values/Vec3");
|
||||
class CCVec3 extends Vec3_1.Vec3 {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.__type__ = "cc.Vec3";
|
||||
}
|
||||
}
|
||||
exports.CCVec3 = CCVec3;
|
File diff suppressed because one or more lines are too long
@ -1,10 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.LayerType = void 0;
|
||||
var LayerType;
|
||||
(function (LayerType) {
|
||||
LayerType[LayerType["Doc"] = 0] = "Doc";
|
||||
LayerType[LayerType["Group"] = 1] = "Group";
|
||||
LayerType[LayerType["Text"] = 2] = "Text";
|
||||
LayerType[LayerType["Image"] = 3] = "Image";
|
||||
})(LayerType = exports.LayerType || (exports.LayerType = {}));
|
@ -1,39 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PsdDocument = void 0;
|
||||
const Rect_1 = require("../values/Rect");
|
||||
const Size_1 = require("../values/Size");
|
||||
const PsdGroup_1 = require("./PsdGroup");
|
||||
class PsdDocument extends PsdGroup_1.PsdGroup {
|
||||
constructor(source) {
|
||||
super(source, null, null);
|
||||
/** 当前文档所有的图片 */
|
||||
this.images = new Map();
|
||||
this.objectMap = new Map();
|
||||
this.objectArray = [];
|
||||
this.size = new Size_1.Size(source.width, source.height);
|
||||
this.rect = new Rect_1.Rect(0, this.size.width, 0, this.size.height);
|
||||
}
|
||||
pushObject(uiObject) {
|
||||
let idx = this.objectArray.length;
|
||||
uiObject.idx = idx;
|
||||
this.objectMap.set(uiObject.uuid, idx);
|
||||
this.objectArray.push(uiObject);
|
||||
return idx;
|
||||
}
|
||||
getObjectIdx(uuid) {
|
||||
let idx = this.objectMap.get(uuid);
|
||||
return idx;
|
||||
}
|
||||
getObject(uuid) {
|
||||
let idx = this.objectMap.get(uuid);
|
||||
if (idx < this.objectArray.length) {
|
||||
return this.objectArray[idx];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
onCtor() {
|
||||
super.onCtor();
|
||||
}
|
||||
}
|
||||
exports.PsdDocument = PsdDocument;
|
@ -1,44 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PsdGroup = void 0;
|
||||
const Rect_1 = require("../values/Rect");
|
||||
const PsdLayer_1 = require("./PsdLayer");
|
||||
class PsdGroup extends PsdLayer_1.PsdLayer {
|
||||
constructor(source, parent, rootDoc) {
|
||||
super(source, parent, rootDoc);
|
||||
this.children = [];
|
||||
if (rootDoc) {
|
||||
this.rect = new Rect_1.Rect(0, rootDoc.size.width, 0, rootDoc.size.height);
|
||||
}
|
||||
}
|
||||
parseSource() {
|
||||
var _a;
|
||||
super.parseSource();
|
||||
if (!((_a = this.attr) === null || _a === void 0 ? void 0 : _a.comps.full)) {
|
||||
this.resize();
|
||||
this.computeBasePosition();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
resize() {
|
||||
let left = Number.MAX_SAFE_INTEGER;
|
||||
let right = Number.MIN_SAFE_INTEGER;
|
||||
let top = Number.MAX_SAFE_INTEGER;
|
||||
let bottom = Number.MIN_SAFE_INTEGER;
|
||||
for (let i = 0; i < this.children.length; i++) {
|
||||
const element = this.children[i];
|
||||
let _rect = element.rect;
|
||||
left = Math.min(_rect.left, left);
|
||||
right = Math.max(_rect.right, right);
|
||||
top = Math.min(_rect.top, top);
|
||||
bottom = Math.max(_rect.bottom, bottom);
|
||||
}
|
||||
this.rect.left = left;
|
||||
this.rect.right = right;
|
||||
this.rect.top = top;
|
||||
this.rect.bottom = bottom;
|
||||
}
|
||||
onCtor() {
|
||||
}
|
||||
}
|
||||
exports.PsdGroup = PsdGroup;
|
@ -1,75 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PsdImage = void 0;
|
||||
const PsdLayer_1 = require("./PsdLayer");
|
||||
const Utils_1 = require("../utils/Utils");
|
||||
const Texture9Utils_1 = require("../utils/Texture9Utils");
|
||||
const Size_1 = require("../values/Size");
|
||||
const FileUtils_1 = require("../utils/FileUtils");
|
||||
const Vec3_1 = require("../values/Vec3");
|
||||
class PsdImage extends PsdLayer_1.PsdLayer {
|
||||
constructor(source, parent, rootDoc) {
|
||||
var _a;
|
||||
super(source, parent, rootDoc);
|
||||
this.textureUuid = Utils_1.utils.uuid();
|
||||
// img name
|
||||
this.imgName = ((_a = this.attr.comps.img) === null || _a === void 0 ? void 0 : _a.name) || this.name;
|
||||
// .9
|
||||
if (this.attr.comps['.9']) {
|
||||
let s9 = this.attr.comps['.9'];
|
||||
this.s9 = Texture9Utils_1.Texture9Utils.safeBorder(s9);
|
||||
let newCanvas = Texture9Utils_1.Texture9Utils.split(this.source.canvas, s9);
|
||||
this.source.canvas = newCanvas;
|
||||
}
|
||||
let canvas = this.source.canvas;
|
||||
this.imgBuffer = canvas.toBuffer('image/png');
|
||||
this.md5 = FileUtils_1.fileUtils.getMD5(this.imgBuffer);
|
||||
this.textureSize = new Size_1.Size(canvas.width, canvas.height);
|
||||
this.scale = new Vec3_1.Vec3((this.isFilpX() ? -1 : 1) * this.scale.x, (this.isFilpY() ? -1 : 1) * this.scale.y, 1);
|
||||
}
|
||||
onCtor() {
|
||||
}
|
||||
isIgnore() {
|
||||
//
|
||||
if (this.attr.comps.ignore || this.attr.comps.ignoreimg) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/** 是否是镜像图片 */
|
||||
isBind() {
|
||||
var _a, _b;
|
||||
return typeof ((_a = this.attr.comps.flip) === null || _a === void 0 ? void 0 : _a.bind) !== 'undefined'
|
||||
|| typeof ((_b = this.attr.comps.img) === null || _b === void 0 ? void 0 : _b.bind) !== 'undefined';
|
||||
}
|
||||
/** 是否是 x 方向镜像图片 */
|
||||
isFilpX() {
|
||||
var _a;
|
||||
return typeof ((_a = this.attr.comps.flipX) === null || _a === void 0 ? void 0 : _a.bind) !== 'undefined';
|
||||
}
|
||||
/** 是否是 y 方向镜像图片 */
|
||||
isFilpY() {
|
||||
var _a;
|
||||
return typeof ((_a = this.attr.comps.flipY) === null || _a === void 0 ? void 0 : _a.bind) !== 'undefined';
|
||||
}
|
||||
// 根据锚点计算坐标
|
||||
updatePositionWithAR() {
|
||||
if (!this.parent) {
|
||||
return;
|
||||
}
|
||||
let parent = this.parent;
|
||||
while (parent) {
|
||||
this.position.x -= parent.position.x;
|
||||
this.position.y -= parent.position.y;
|
||||
parent = parent.parent;
|
||||
}
|
||||
// this.position.x = this.position.x - this.parent.size.width * this.parent.anchorPoint.x + this.size.width * this.anchorPoint.x;
|
||||
// this.position.y = this.position.y - this.parent.size.height * this.parent.anchorPoint.y + this.size.height * this.anchorPoint.y;
|
||||
// 如果是镜像图片,则特殊处理
|
||||
let arX = (this.isFilpX() ? (1 - this.anchorPoint.x) : this.anchorPoint.x);
|
||||
let arY = (this.isFilpY() ? (1 - this.anchorPoint.y) : this.anchorPoint.y);
|
||||
this.position.x = this.position.x - this.rootDoc.size.width * this.rootDoc.anchorPoint.x + this.size.width * arX;
|
||||
this.position.y = this.position.y - this.rootDoc.size.height * this.rootDoc.anchorPoint.y + this.size.height * arY;
|
||||
}
|
||||
}
|
||||
exports.PsdImage = PsdImage;
|
@ -1,185 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PsdLayer = void 0;
|
||||
const Size_1 = require("../values/Size");
|
||||
const Vec2_1 = require("../values/Vec2");
|
||||
const Utils_1 = require("../utils/Utils");
|
||||
const Rect_1 = require("../values/Rect");
|
||||
const Color_1 = require("../values/Color");
|
||||
const Vec3_1 = require("../values/Vec3");
|
||||
class PsdLayer {
|
||||
constructor(source, parent, rootDoc) {
|
||||
var _a, _b, _c, _d;
|
||||
this.uuid = Utils_1.utils.uuid();
|
||||
this.source = source;
|
||||
this.parent = parent;
|
||||
this.rootDoc = rootDoc;
|
||||
this.name = source.name;
|
||||
this.position = new Vec2_1.Vec2();
|
||||
this.size = new Size_1.Size();
|
||||
this.rect = new Rect_1.Rect(source);
|
||||
// this.anchorPoint = new Vec2();
|
||||
this.anchorPoint = new Vec2_1.Vec2(0.5, 0.5);
|
||||
this.hidden = false;
|
||||
this.opacity = 255;
|
||||
this.color = new Color_1.Color(255, 255, 255, 255);
|
||||
console.log(`PsdLayer->解析到图层 `, this.name);
|
||||
this.attr = this.parseNameRule(this.name);
|
||||
// // 更新名字
|
||||
this.name = ((_a = this.attr) === null || _a === void 0 ? void 0 : _a.name) || this.name;
|
||||
// 使用配置的缩放系数
|
||||
let _scale = (_b = this.attr) === null || _b === void 0 ? void 0 : _b.comps.scale;
|
||||
this.scale = new Vec3_1.Vec3((_c = _scale === null || _scale === void 0 ? void 0 : _scale.x) !== null && _c !== void 0 ? _c : 1, (_d = _scale === null || _scale === void 0 ? void 0 : _scale.y) !== null && _d !== void 0 ? _d : 1, 1);
|
||||
}
|
||||
parseNameRule(name) {
|
||||
var _a, _b;
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
name = name.trim();
|
||||
let fragments = name.split("@");
|
||||
if (fragments.length === 0) {
|
||||
console.error(`PsdLayer-> 名字解析错误`);
|
||||
return;
|
||||
}
|
||||
let obj = {
|
||||
name: (_b = (_a = fragments[0]) === null || _a === void 0 ? void 0 : _a.replace(/\.|>|\/|\ /g, "_")) !== null && _b !== void 0 ? _b : "unknow",
|
||||
comps: {},
|
||||
};
|
||||
for (let i = 1; i < fragments.length; i++) {
|
||||
const fragment = fragments[i].trim();
|
||||
let attr = {};
|
||||
let startIdx = fragment.indexOf("{");
|
||||
let comp = fragment;
|
||||
if (startIdx != -1) {
|
||||
let endIdx = fragment.indexOf("}");
|
||||
if (endIdx == -1) {
|
||||
console.log(`PsdLayer->${name} 属性 解析错误`);
|
||||
continue;
|
||||
}
|
||||
let attrStr = fragment.substring(startIdx + 1, endIdx);
|
||||
comp = fragment.substr(0, startIdx);
|
||||
attrStr = attrStr.trim();
|
||||
let attrs = attrStr.split(",");
|
||||
attrs.forEach((str) => {
|
||||
str = str.trim();
|
||||
let strs = str.split(":");
|
||||
if (!strs.length) {
|
||||
console.log(`PsdLayer->${name} 属性 解析错误`);
|
||||
return;
|
||||
}
|
||||
strs.map((v) => {
|
||||
return v.trim();
|
||||
});
|
||||
attr[strs[0]] = Utils_1.utils.isNumber(strs[1]) ? parseFloat(strs[1]) : strs[1];
|
||||
});
|
||||
}
|
||||
comp = comp.trim();
|
||||
comp = comp.replace(":", ""); // 防呆,删除 key 中的冒号,
|
||||
obj.comps[comp] = attr;
|
||||
}
|
||||
// 获取别名的值
|
||||
obj.comps.ignore = obj.comps.ignore || obj.comps.ig;
|
||||
obj.comps.ignorenode = obj.comps.ignorenode || obj.comps.ignode;
|
||||
obj.comps.ignoreimg = obj.comps.ignoreimg || obj.comps.igimg;
|
||||
obj.comps.Btn = obj.comps.Btn || obj.comps.btn;
|
||||
obj.comps.ProgressBar = obj.comps.ProgressBar || obj.comps.progressBar;
|
||||
obj.comps.Toggle = obj.comps.Toggle || obj.comps.toggle;
|
||||
// obj.comps.position = obj.comps.position || obj.comps.pos;
|
||||
// 将mirror filpX filpY 进行合并
|
||||
if (obj.comps.flip || obj.comps.flipX || obj.comps.flipY) {
|
||||
obj.comps.flip = Object.assign({}, obj.comps.flip, obj.comps.flipX, obj.comps.flipY);
|
||||
if (obj.comps.flipX) {
|
||||
obj.comps.flip.x = 1;
|
||||
}
|
||||
if (obj.comps.flipY) {
|
||||
obj.comps.flip.y = 1;
|
||||
}
|
||||
// x,y 都缺省时,默认 x 方向镜像
|
||||
if (typeof obj.comps.flip.bind !== 'undefined') {
|
||||
if (!obj.comps.flip.y) {
|
||||
obj.comps.flip.x = 1;
|
||||
}
|
||||
// 只有作为镜像图片使用的时候才反向赋值
|
||||
// 反向赋值,防止使用的时候值错误
|
||||
if (obj.comps.flip.x) {
|
||||
obj.comps.flipX = Object.assign({}, obj.comps.flipX, obj.comps.flip);
|
||||
}
|
||||
if (obj.comps.flip.y) {
|
||||
obj.comps.flipY = Object.assign({}, obj.comps.flipY, obj.comps.flip);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 检查冲突
|
||||
if (obj.comps.full && obj.comps.size) {
|
||||
console.warn(`PsdLayer->${obj.name} 同时存在 @full 和 @size`);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
/** 解析数据 */
|
||||
parseSource() {
|
||||
var _a, _b;
|
||||
let _source = this.source;
|
||||
// psd文档
|
||||
if (!this.parent) {
|
||||
return false;
|
||||
}
|
||||
this.hidden = _source.hidden;
|
||||
this.opacity = Math.round(_source.opacity * 255);
|
||||
// 获取锚点
|
||||
let ar = this.attr.comps.ar;
|
||||
if (ar) {
|
||||
this.anchorPoint.x = (_a = ar.x) !== null && _a !== void 0 ? _a : this.anchorPoint.x;
|
||||
this.anchorPoint.y = (_b = ar.y) !== null && _b !== void 0 ? _b : this.anchorPoint.y;
|
||||
}
|
||||
this.computeBasePosition();
|
||||
return true;
|
||||
}
|
||||
/** 解析 effect */
|
||||
parseEffects() {
|
||||
// 颜色叠加 暂时搞不定
|
||||
// if(this.source.effects?.solidFill){
|
||||
// let solidFills = this.source.effects?.solidFill;
|
||||
// for (let i = 0; i < solidFills.length; i++) {
|
||||
// const solidFill = solidFills[i];
|
||||
// if(solidFill.enabled){
|
||||
// let color = solidFill.color;
|
||||
// this.color = new Color(color.r,color.g,color.b,solidFill.opacity * 255);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
// 计算初始坐标 左下角 0,0 为锚点
|
||||
computeBasePosition() {
|
||||
if (!this.rootDoc) {
|
||||
return;
|
||||
}
|
||||
let _rect = this.rect;
|
||||
let width = (_rect.right - _rect.left);
|
||||
let height = (_rect.bottom - _rect.top);
|
||||
this.size.width = width;
|
||||
this.size.height = height;
|
||||
// 位置 左下角为锚点
|
||||
let x = _rect.left;
|
||||
let y = (this.rootDoc.size.height - _rect.bottom);
|
||||
this.position.x = x;
|
||||
this.position.y = y;
|
||||
}
|
||||
// 根据锚点计算坐标
|
||||
updatePositionWithAR() {
|
||||
if (!this.parent) {
|
||||
return;
|
||||
}
|
||||
let parent = this.parent;
|
||||
while (parent) {
|
||||
this.position.x -= parent.position.x;
|
||||
this.position.y -= parent.position.y;
|
||||
parent = parent.parent;
|
||||
}
|
||||
// this.position.x = this.position.x - this.parent.size.width * this.parent.anchorPoint.x + this.size.width * this.anchorPoint.x;
|
||||
// this.position.y = this.position.y - this.parent.size.height * this.parent.anchorPoint.y + this.size.height * this.anchorPoint.y;
|
||||
this.position.x = this.position.x - this.rootDoc.size.width * this.rootDoc.anchorPoint.x + this.size.width * this.anchorPoint.x;
|
||||
this.position.y = this.position.y - this.rootDoc.size.height * this.rootDoc.anchorPoint.y + this.size.height * this.anchorPoint.y;
|
||||
}
|
||||
}
|
||||
exports.PsdLayer = PsdLayer;
|
@ -1,57 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PsdText = void 0;
|
||||
const config_1 = require("../config");
|
||||
const Color_1 = require("../values/Color");
|
||||
const PsdLayer_1 = require("./PsdLayer");
|
||||
class PsdText extends PsdLayer_1.PsdLayer {
|
||||
parseSource() {
|
||||
super.parseSource();
|
||||
let textSource = this.source.text;
|
||||
let style = textSource.style;
|
||||
if (style) {
|
||||
let fillColor = style.fillColor;
|
||||
if (fillColor) {
|
||||
this.color = new Color_1.Color(fillColor.r, fillColor.g, fillColor.b, fillColor.a * 255);
|
||||
}
|
||||
}
|
||||
this.text = textSource.text;
|
||||
this.fontSize = style.fontSize;
|
||||
this.offsetY = config_1.config.textOffsetY[this.fontSize] || config_1.config.textOffsetY["default"] || 0;
|
||||
this.parseSolidFill();
|
||||
this.parseStroke();
|
||||
return true;
|
||||
}
|
||||
onCtor() {
|
||||
}
|
||||
/** 描边 */
|
||||
parseStroke() {
|
||||
var _a, _b;
|
||||
if ((_a = this.source.effects) === null || _a === void 0 ? void 0 : _a.stroke) {
|
||||
let stroke = (_b = this.source.effects) === null || _b === void 0 ? void 0 : _b.stroke[0];
|
||||
// 外描边
|
||||
if ((stroke === null || stroke === void 0 ? void 0 : stroke.enabled) && (stroke === null || stroke === void 0 ? void 0 : stroke.position) === "outside") {
|
||||
let color = stroke.color;
|
||||
this.outline = {
|
||||
width: stroke.size.value,
|
||||
color: new Color_1.Color(color.r, color.g, color.b, stroke.opacity * 255)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
/** 解析 颜色叠加 */
|
||||
parseSolidFill() {
|
||||
var _a, _b;
|
||||
if ((_a = this.source.effects) === null || _a === void 0 ? void 0 : _a.solidFill) {
|
||||
let solidFills = (_b = this.source.effects) === null || _b === void 0 ? void 0 : _b.solidFill;
|
||||
for (let i = 0; i < solidFills.length; i++) {
|
||||
const solidFill = solidFills[i];
|
||||
if (solidFill.enabled) {
|
||||
let color = solidFill.color;
|
||||
this.color = new Color_1.Color(color.r, color.g, color.b, solidFill.opacity * 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.PsdText = PsdText;
|
@ -1,122 +0,0 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.fileUtils = void 0;
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const crypto_1 = __importDefault(require("crypto"));
|
||||
class FileUtils {
|
||||
// 深度遍历
|
||||
DFS(root, callback, depth = 0) {
|
||||
let exists = fs_extra_1.default.existsSync(root);
|
||||
if (!exists) {
|
||||
console.log(`FileUtils-> ${root} is not exists`);
|
||||
return;
|
||||
}
|
||||
let files = fs_extra_1.default.readdirSync(root);
|
||||
let _cacheDepth = depth;
|
||||
depth++;
|
||||
files.forEach((file) => {
|
||||
let fullPath = path_1.default.join(root, file);
|
||||
let stat = fs_extra_1.default.lstatSync(fullPath);
|
||||
let isDirectory = stat.isDirectory();
|
||||
callback === null || callback === void 0 ? void 0 : callback({ isDirectory, fullPath, fileName: file, depth: _cacheDepth });
|
||||
if (!isDirectory) {
|
||||
}
|
||||
else {
|
||||
this.DFS(fullPath, callback, depth);
|
||||
}
|
||||
});
|
||||
}
|
||||
filterFile(root, filter) {
|
||||
let exists = fs_extra_1.default.existsSync(root);
|
||||
if (!exists) {
|
||||
console.log(`FileUtils-> ${root} is not exists`);
|
||||
return;
|
||||
}
|
||||
var res = [];
|
||||
let files = fs_extra_1.default.readdirSync(root);
|
||||
files.forEach((file) => {
|
||||
let pathName = path_1.default.join(root, file);
|
||||
let stat = fs_extra_1.default.lstatSync(pathName);
|
||||
let isDirectory = stat.isDirectory();
|
||||
// 只对文件进行判断
|
||||
if (!isDirectory) {
|
||||
let isPass = filter(file);
|
||||
if (!isPass) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!isDirectory) {
|
||||
res.push(pathName);
|
||||
}
|
||||
else {
|
||||
res = res.concat(this.filterFile(pathName, filter));
|
||||
}
|
||||
});
|
||||
return res;
|
||||
}
|
||||
getFolderFiles(dir, type) {
|
||||
let exists = fs_extra_1.default.existsSync(dir);
|
||||
if (!exists) {
|
||||
console.log(`FileUtils-> ${dir} is not exists`);
|
||||
return;
|
||||
}
|
||||
let res = [];
|
||||
let files = fs_extra_1.default.readdirSync(dir);
|
||||
files.forEach((file) => {
|
||||
let fullPath = path_1.default.join(dir, file);
|
||||
let stat = fs_extra_1.default.lstatSync(fullPath);
|
||||
let isDirectory = stat.isDirectory();
|
||||
if (isDirectory) {
|
||||
if (type === 'folder') {
|
||||
res.push({ fullPath, basename: file });
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (type === 'file') {
|
||||
res.push({ fullPath, basename: file });
|
||||
}
|
||||
}
|
||||
});
|
||||
return res;
|
||||
}
|
||||
writeFile(fullPath, data) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (typeof data !== 'string') {
|
||||
try {
|
||||
data = JSON.stringify(data, null, 2);
|
||||
}
|
||||
catch (error) {
|
||||
console.log(`FileUtils->writeFile `, error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
console.log(`写入文件 ${fullPath}`);
|
||||
let dir = path_1.default.dirname(fullPath);
|
||||
yield fs_extra_1.default.mkdirp(dir);
|
||||
yield fs_extra_1.default.writeFile(fullPath, data);
|
||||
console.log(`写入完成 ${fullPath} `);
|
||||
});
|
||||
}
|
||||
/** 获取文件的 md5 */
|
||||
getMD5(buffer) {
|
||||
if (typeof buffer === 'string') {
|
||||
buffer = fs_extra_1.default.readFileSync(buffer);
|
||||
}
|
||||
let md5 = crypto_1.default.createHash("md5").update(buffer).digest("hex");
|
||||
return md5;
|
||||
}
|
||||
}
|
||||
exports.fileUtils = new FileUtils();
|
@ -1,37 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Texture9Utils = void 0;
|
||||
const canvas_1 = __importDefault(require("canvas"));
|
||||
class Texture9Utils {
|
||||
static safeBorder(border) {
|
||||
border.l = border.l || border.r || 0;
|
||||
border.r = border.r || border.l || 0;
|
||||
border.t = border.t || border.b || 0;
|
||||
border.b = border.b || border.t || 0;
|
||||
return border;
|
||||
}
|
||||
static split(_canvas, border) {
|
||||
this.safeBorder(border);
|
||||
let cw = _canvas.width;
|
||||
let ch = _canvas.height;
|
||||
let left = border.l || cw;
|
||||
let right = border.r || cw;
|
||||
let top = border.t || ch;
|
||||
let bottom = border.b || ch;
|
||||
let newCanvas = canvas_1.default.createCanvas((border.l + border.r) || cw, (border.b + border.t) || ch);
|
||||
let ctx = newCanvas.getContext("2d");
|
||||
// 左上
|
||||
ctx.drawImage(_canvas, 0, 0, left, top, 0, 0, left, top);
|
||||
// 左下
|
||||
ctx.drawImage(_canvas, 0, ch - top, left, bottom, 0, top, left, bottom);
|
||||
// 右上
|
||||
ctx.drawImage(_canvas, cw - left, 0, right, top, left, 0, right, top);
|
||||
// 右下
|
||||
ctx.drawImage(_canvas, cw - left, ch - top, right, bottom, left, top, right, bottom);
|
||||
return newCanvas;
|
||||
}
|
||||
}
|
||||
exports.Texture9Utils = Texture9Utils;
|
@ -1,80 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.utils = void 0;
|
||||
// ------------decode-uuid
|
||||
const BASE64_KEYS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
||||
const values = new Array(123); // max char code in base64Keys
|
||||
for (let i = 0; i < 123; ++i) {
|
||||
values[i] = 64;
|
||||
} // fill with placeholder('=') index
|
||||
for (let i = 0; i < 64; ++i) {
|
||||
values[BASE64_KEYS.charCodeAt(i)] = i;
|
||||
}
|
||||
// decoded value indexed by base64 char code
|
||||
const BASE64_VALUES = values;
|
||||
const HexChars = '0123456789abcdef'.split('');
|
||||
const _t = ['', '', '', ''];
|
||||
const UuidTemplate = _t.concat(_t, '-', _t, '-', _t, '-', _t, '-', _t, _t, _t);
|
||||
const Indices = UuidTemplate.map((x, i) => x === '-' ? NaN : i).filter(isFinite);
|
||||
let HexMap = {};
|
||||
{
|
||||
for (let i = 0; i < HexChars.length; i++) {
|
||||
let char = HexChars[i];
|
||||
HexMap[char] = i;
|
||||
}
|
||||
}
|
||||
class Utils {
|
||||
uuid() {
|
||||
var d = new Date().getTime();
|
||||
if (globalThis.performance && typeof globalThis.performance.now === "function") {
|
||||
d += performance.now(); //use high-precision timer if available
|
||||
}
|
||||
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||
var r = (d + Math.random() * 16) % 16 | 0;
|
||||
d = Math.floor(d / 16);
|
||||
return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
|
||||
});
|
||||
return uuid;
|
||||
}
|
||||
decodeUuid(base64) {
|
||||
const strs = base64.split('@');
|
||||
const uuid = strs[0];
|
||||
if (uuid.length !== 22) {
|
||||
return base64;
|
||||
}
|
||||
UuidTemplate[0] = base64[0];
|
||||
UuidTemplate[1] = base64[1];
|
||||
for (let i = 2, j = 2; i < 22; i += 2) {
|
||||
const lhs = BASE64_VALUES[base64.charCodeAt(i)];
|
||||
const rhs = BASE64_VALUES[base64.charCodeAt(i + 1)];
|
||||
UuidTemplate[Indices[j++]] = HexChars[lhs >> 2];
|
||||
UuidTemplate[Indices[j++]] = HexChars[((lhs & 3) << 2) | rhs >> 4];
|
||||
UuidTemplate[Indices[j++]] = HexChars[rhs & 0xF];
|
||||
}
|
||||
return base64.replace(uuid, UuidTemplate.join(''));
|
||||
}
|
||||
// 压缩uuid
|
||||
compressUuid(fullUuid) {
|
||||
const strs = fullUuid.split('@');
|
||||
const uuid = strs[0];
|
||||
if (uuid.length !== 36) {
|
||||
return fullUuid;
|
||||
}
|
||||
let zipUuid = [];
|
||||
zipUuid[0] = uuid[0];
|
||||
zipUuid[1] = uuid[1];
|
||||
let cleanUuid = uuid.replace('-', '').replace('-', '').replace('-', '').replace('-', '');
|
||||
for (let i = 2, j = 2; i < 32; i += 3) {
|
||||
const left = HexMap[String.fromCharCode(cleanUuid.charCodeAt(i))];
|
||||
const mid = HexMap[String.fromCharCode(cleanUuid.charCodeAt(i + 1))];
|
||||
const right = HexMap[String.fromCharCode(cleanUuid.charCodeAt(i + 2))];
|
||||
zipUuid[j++] = BASE64_KEYS[(left << 2) + (mid >> 2)];
|
||||
zipUuid[j++] = BASE64_KEYS[((mid & 3) << 4) + right];
|
||||
}
|
||||
return fullUuid.replace(uuid, zipUuid.join(''));
|
||||
}
|
||||
isNumber(val) {
|
||||
return (!isNaN(parseFloat(val)) && isFinite(val));
|
||||
}
|
||||
}
|
||||
exports.utils = new Utils();
|
@ -1,95 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UuidUtils = void 0;
|
||||
var Uuid = require('node-uuid');
|
||||
var Base64KeyChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
var AsciiTo64 = new Array(128);
|
||||
for (var i = 0; i < 128; ++i) {
|
||||
AsciiTo64[i] = 0;
|
||||
}
|
||||
for (i = 0; i < 64; ++i) {
|
||||
AsciiTo64[Base64KeyChars.charCodeAt(i)] = i;
|
||||
}
|
||||
var Reg_Dash = /-/g;
|
||||
var Reg_Uuid = /^[0-9a-fA-F-]{36}$/;
|
||||
var Reg_NormalizedUuid = /^[0-9a-fA-F]{32}$/;
|
||||
var Reg_CompressedUuid = /^[0-9a-zA-Z+/]{22,23}$/;
|
||||
class UuidUtils {
|
||||
// 压缩后的 uuid 可以减小保存时的尺寸,但不能做为文件名(因为无法区分大小写并且包含非法字符)。
|
||||
// 默认将 uuid 的后面 27 位压缩成 18 位,前 5 位保留下来,方便调试。
|
||||
// fc991dd7-0033-4b80-9d41-c8a86a702e59 -> fc9913XADNLgJ1ByKhqcC5Z
|
||||
// 如果启用 min 则将 uuid 的后面 30 位压缩成 20 位,前 2 位保留不变。
|
||||
// fc991dd7-0033-4b80-9d41-c8a86a702e59 -> fcmR3XADNLgJ1ByKhqcC5Z
|
||||
/*
|
||||
* @param {Boolean} [min=false]
|
||||
*/
|
||||
static compressUuid(uuid, min) {
|
||||
if (Reg_Uuid.test(uuid)) {
|
||||
uuid = uuid.replace(Reg_Dash, '');
|
||||
}
|
||||
else if (!Reg_NormalizedUuid.test(uuid)) {
|
||||
return uuid;
|
||||
}
|
||||
var reserved = (min === true) ? 2 : 5;
|
||||
return UuidUtils.compressHex(uuid, reserved);
|
||||
}
|
||||
static compressHex(hexString, reservedHeadLength) {
|
||||
var length = hexString.length;
|
||||
var i;
|
||||
if (typeof reservedHeadLength !== 'undefined') {
|
||||
i = reservedHeadLength;
|
||||
}
|
||||
else {
|
||||
i = length % 3;
|
||||
}
|
||||
var head = hexString.slice(0, i);
|
||||
var base64Chars = [];
|
||||
while (i < length) {
|
||||
var hexVal1 = parseInt(hexString[i], 16);
|
||||
var hexVal2 = parseInt(hexString[i + 1], 16);
|
||||
var hexVal3 = parseInt(hexString[i + 2], 16);
|
||||
base64Chars.push(Base64KeyChars[(hexVal1 << 2) | (hexVal2 >> 2)]);
|
||||
base64Chars.push(Base64KeyChars[((hexVal2 & 3) << 4) | hexVal3]);
|
||||
i += 3;
|
||||
}
|
||||
return head + base64Chars.join('');
|
||||
}
|
||||
static decompressUuid(str) {
|
||||
if (str.length === 23) {
|
||||
// decode base64
|
||||
var hexChars = [];
|
||||
for (var i = 5; i < 23; i += 2) {
|
||||
var lhs = AsciiTo64[str.charCodeAt(i)];
|
||||
var rhs = AsciiTo64[str.charCodeAt(i + 1)];
|
||||
hexChars.push((lhs >> 2).toString(16));
|
||||
hexChars.push((((lhs & 3) << 2) | rhs >> 4).toString(16));
|
||||
hexChars.push((rhs & 0xF).toString(16));
|
||||
}
|
||||
//
|
||||
str = str.slice(0, 5) + hexChars.join('');
|
||||
}
|
||||
else if (str.length === 22) {
|
||||
// decode base64
|
||||
var hexChars = [];
|
||||
for (var i = 2; i < 22; i += 2) {
|
||||
var lhs = AsciiTo64[str.charCodeAt(i)];
|
||||
var rhs = AsciiTo64[str.charCodeAt(i + 1)];
|
||||
hexChars.push((lhs >> 2).toString(16));
|
||||
hexChars.push((((lhs & 3) << 2) | rhs >> 4).toString(16));
|
||||
hexChars.push((rhs & 0xF).toString(16));
|
||||
}
|
||||
//
|
||||
str = str.slice(0, 2) + hexChars.join('');
|
||||
}
|
||||
return [str.slice(0, 8), str.slice(8, 12), str.slice(12, 16), str.slice(16, 20), str.slice(20)].join('-');
|
||||
}
|
||||
static isUuid(str) {
|
||||
return Reg_CompressedUuid.test(str) || Reg_NormalizedUuid.test(str) || Reg_Uuid.test(str);
|
||||
}
|
||||
static uuid() {
|
||||
var uuid = Uuid.v4();
|
||||
return UuidUtils.compressUuid(uuid, true);
|
||||
}
|
||||
}
|
||||
exports.UuidUtils = UuidUtils;
|
||||
;
|
@ -1,37 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Color = void 0;
|
||||
class Color {
|
||||
constructor(r, g, b, a) {
|
||||
this.r = Math.ceil(r || 0);
|
||||
this.g = Math.ceil(g || 0);
|
||||
this.b = Math.ceil(b || 0);
|
||||
this.a = Math.ceil(a || 0);
|
||||
}
|
||||
set(color) {
|
||||
this.r = Math.ceil(color.r || 0);
|
||||
this.g = Math.ceil(color.g || 0);
|
||||
this.b = Math.ceil(color.b || 0);
|
||||
this.a = Math.ceil(color.a || 0);
|
||||
}
|
||||
toHEX(fmt = '#rrggbb') {
|
||||
const prefix = '0';
|
||||
// #rrggbb
|
||||
const hex = [
|
||||
(this.r < 16 ? prefix : '') + (this.r).toString(16),
|
||||
(this.g < 16 ? prefix : '') + (this.g).toString(16),
|
||||
(this.b < 16 ? prefix : '') + (this.b).toString(16),
|
||||
];
|
||||
const i = -1;
|
||||
if (fmt === '#rgb') {
|
||||
hex[0] = hex[0][0];
|
||||
hex[1] = hex[1][0];
|
||||
hex[2] = hex[2][0];
|
||||
}
|
||||
else if (fmt === '#rrggbbaa') {
|
||||
hex.push((this.a < 16 ? prefix : '') + (this.a).toString(16));
|
||||
}
|
||||
return hex.join('');
|
||||
}
|
||||
}
|
||||
exports.Color = Color;
|
@ -1,22 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Rect = void 0;
|
||||
class Rect {
|
||||
constructor(left = 0, right = 0, top = 0, bottom = 0) {
|
||||
if (typeof left == 'object') {
|
||||
this.set(left);
|
||||
return;
|
||||
}
|
||||
this.left = left || 0;
|
||||
this.right = right || 0;
|
||||
this.top = top || 0;
|
||||
this.bottom = bottom || 0;
|
||||
}
|
||||
set(rect) {
|
||||
this.left = rect.left;
|
||||
this.right = rect.right;
|
||||
this.top = rect.top;
|
||||
this.bottom = rect.bottom;
|
||||
}
|
||||
}
|
||||
exports.Rect = Rect;
|
@ -1,10 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Size = void 0;
|
||||
class Size {
|
||||
constructor(width = 0, height = 0) {
|
||||
this.width = width || 0;
|
||||
this.height = height || 0;
|
||||
}
|
||||
}
|
||||
exports.Size = Size;
|
@ -1,10 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Vec2 = void 0;
|
||||
class Vec2 {
|
||||
constructor(x = 0, y = 0) {
|
||||
this.x = x || 0;
|
||||
this.y = y || 0;
|
||||
}
|
||||
}
|
||||
exports.Vec2 = Vec2;
|
@ -1,11 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Vec3 = void 0;
|
||||
class Vec3 {
|
||||
constructor(x = 0, y = 0, z = 0) {
|
||||
this.x = x || 0;
|
||||
this.y = y || 0;
|
||||
this.z = z || 0;
|
||||
}
|
||||
}
|
||||
exports.Vec3 = Vec3;
|
@ -124,12 +124,14 @@ module.exports = {
|
||||
let files = param.files;
|
||||
let isForceImg = param.isForceImg;
|
||||
let isImgOnly = param.isImgOnly;
|
||||
let output = param.output
|
||||
let output = param.output;
|
||||
let isPinyin = param.isPinyin;
|
||||
|
||||
let options = {
|
||||
"project-assets": projectAssets,
|
||||
"cache": cacheFile,
|
||||
"engine-version": ENGINE_VER,
|
||||
"pinyin": isPinyin,
|
||||
}
|
||||
|
||||
let tasks = [];
|
||||
|
2200
ccc-tnt-psd2ui-v2.4.x/package-lock.json
generated
2200
ccc-tnt-psd2ui-v2.4.x/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -1,28 +1,28 @@
|
||||
{
|
||||
"name": "ccc-tnt-psd2ui",
|
||||
"version": "0.0.1",
|
||||
"description": "The package template for getting started.",
|
||||
"author": "Cocos Creator",
|
||||
"main": "main.js",
|
||||
"main-menu": {
|
||||
"i18n:MAIN_MENU.package.title/ccc-tnt-psd2ui/open": {
|
||||
"message": "ccc-tnt-psd2ui:open"
|
||||
}
|
||||
},
|
||||
"panel": {
|
||||
"main": "panel/index.js",
|
||||
"type": "dockable",
|
||||
"title": "ccc-tnt-psd2ui",
|
||||
"width": 480,
|
||||
"height": 360,
|
||||
"min-width": 480,
|
||||
"min-height": 360
|
||||
},
|
||||
|
||||
"dependencies": {
|
||||
"ag-psd": "^15.0.0",
|
||||
"canvas": "^2.10.2",
|
||||
"fs-extra": "^10.1.0",
|
||||
"minimist": "^1.2.7"
|
||||
}
|
||||
}
|
||||
{
|
||||
"name": "ccc-tnt-psd2ui",
|
||||
"version": "0.0.1",
|
||||
"description": "The package template for getting started.",
|
||||
"author": "Cocos Creator",
|
||||
"main": "main.js",
|
||||
"main-menu": {
|
||||
"i18n:MAIN_MENU.package.title/ccc-tnt-psd2ui/open": {
|
||||
"message": "ccc-tnt-psd2ui:open"
|
||||
}
|
||||
},
|
||||
"panel": {
|
||||
"main": "panel/index.js",
|
||||
"type": "dockable",
|
||||
"title": "ccc-tnt-psd2ui",
|
||||
"width": 480,
|
||||
"height": 360,
|
||||
"min-width": 480,
|
||||
"min-height": 360
|
||||
},
|
||||
"dependencies": {
|
||||
"ag-psd": "^15.0.0",
|
||||
"canvas": "^2.10.2",
|
||||
"fs-extra": "^10.1.0",
|
||||
"minimist": "^1.2.7",
|
||||
"pinyin-pro": "^3.16.0"
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
<ui-button id="btn-cache" @click="onClickCache()"> 缓存资源 </ui-button>
|
||||
<ui-checkbox id="is-force-img" style="bottom: 8px;">强制导出图片</ui-checkbox>
|
||||
<ui-checkbox id="is-img-only" style="bottom: 8px;">只导出图片</ui-checkbox>
|
||||
<ui-checkbox id="is-pinyin" style="bottom: 8px;" :value="isPinyin" >中文转拼音</ui-checkbox>
|
||||
|
||||
<hr />
|
||||
<div style="display: flex;">
|
||||
|
@ -25,6 +25,7 @@ Editor.Panel.extend({
|
||||
isImgOnly: false,
|
||||
isForceImg: false,
|
||||
isProcessing: false,
|
||||
isPinyin: true,
|
||||
},
|
||||
|
||||
|
||||
@ -45,6 +46,13 @@ Editor.Panel.extend({
|
||||
this.isImgOnly = !this.isImgOnly;
|
||||
});
|
||||
|
||||
|
||||
let pinyin = root.getElementById("is-pinyin")
|
||||
pinyin.addEventListener('change', () => {
|
||||
this.isPinyin = !this.isPinyin;
|
||||
});
|
||||
|
||||
|
||||
let str = localStorage.getItem(`${Editor.Project.name}_psd2ui_output`);
|
||||
if (str) {
|
||||
let outputInput = root.getElementById("output");
|
||||
@ -90,7 +98,7 @@ Editor.Panel.extend({
|
||||
// Editor.
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
let result = Editor.Dialog.openFile({
|
||||
'multi': true,
|
||||
'type': "file",
|
||||
@ -113,7 +121,7 @@ Editor.Panel.extend({
|
||||
let output = outputInput.value;
|
||||
//
|
||||
this.isProcessing = true;
|
||||
Editor.Ipc.sendToMain('ccc-tnt-psd2ui:on-drop-file', { output, files, isForceImg: this.isForceImg, isImgOnly: this.isImgOnly }, (err) => {
|
||||
Editor.Ipc.sendToMain('ccc-tnt-psd2ui:on-drop-file', { output, files, isForceImg: this.isForceImg, isImgOnly: this.isImgOnly, isPinyin: this.isPinyin }, (err) => {
|
||||
this.isProcessing = false;
|
||||
|
||||
});
|
||||
|
19
ccc-tnt-psd2ui-v3.4.+/dist/main.js
vendored
19
ccc-tnt-psd2ui-v3.4.+/dist/main.js
vendored
@ -49,10 +49,12 @@ exports.methods = {
|
||||
let isForceImg = param.isForceImg;
|
||||
let isImgOnly = param.isImgOnly;
|
||||
let output = param.output;
|
||||
let isPinyin = param.isPinyin;
|
||||
let options = {
|
||||
"project-assets": projectAssets,
|
||||
"cache": cacheFile,
|
||||
"engine-version": ENGINE_VER,
|
||||
"pinyin": isPinyin,
|
||||
};
|
||||
let tasks = [];
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
@ -82,15 +84,19 @@ exports.methods = {
|
||||
}
|
||||
_exec(args, tasks);
|
||||
}
|
||||
await Promise.all(tasks);
|
||||
genUUID2MD5Mapping();
|
||||
console.log("[ccc-tnt-psd2ui] psd 导出完成,输出位置为:", output ? output : "psd 同级目录");
|
||||
Promise.all(tasks).then(() => {
|
||||
genUUID2MD5Mapping();
|
||||
console.log("[ccc-tnt-psd2ui] psd 导出完成,输出位置为:", output ? output : "psd 同级目录");
|
||||
}).catch((reason) => {
|
||||
console.log("[ccc-tnt-psd2ui] 导出失败", reason);
|
||||
}).finally(() => {
|
||||
});
|
||||
},
|
||||
};
|
||||
function _exec(options, tasks) {
|
||||
let jsonContent = JSON.stringify(options);
|
||||
if (!fs_extra_1.default.existsSync(nodejsFile)) {
|
||||
console.log(`main-> 没有批处理文件`, nodejsFile);
|
||||
console.log(`[ccc-tnt-psd2ui] 没有内置 nodejs`, nodejsFile);
|
||||
return tasks;
|
||||
}
|
||||
// 处理权限问题
|
||||
@ -100,10 +106,11 @@ function _exec(options, tasks) {
|
||||
fs_extra_1.default.chmodSync(nodejsFile, 33261);
|
||||
}
|
||||
}
|
||||
console.log("[ccc-tnt-psd2ui] 批处理命令参数:" + jsonContent);
|
||||
console.log("[ccc-tnt-psd2ui] 命令参数:" + jsonContent);
|
||||
console.log("[ccc-tnt-psd2ui] 命令执行中");
|
||||
let base64 = Buffer.from(jsonContent).toString("base64");
|
||||
tasks.push(new Promise((rs) => {
|
||||
// console.log(`main-> `, `${nodejsFile} ${psd}` + ' ' + `--json ${base64}`);
|
||||
// console.log(`[ccc-tnt-psd2ui] `, `${nodejsFile} ${psd}` + ' ' + `--json ${base64}`);
|
||||
exec(`${nodejsFile} ${psd}` + ' ' + `--json ${base64}`, { windowsHide: false }, (err, stdout, stderr) => {
|
||||
console.log("[ccc-tnt-psd2ui]:\n", stdout);
|
||||
if (stderr) {
|
||||
|
@ -32,6 +32,7 @@ module.exports = Editor.Panel.define({
|
||||
isImgOnly: false,
|
||||
isForceImg: false,
|
||||
isProcessing: false,
|
||||
isPinyin: true,
|
||||
outputPath: "",
|
||||
};
|
||||
},
|
||||
@ -58,6 +59,9 @@ module.exports = Editor.Panel.define({
|
||||
onImgOnlyChanged() {
|
||||
this.isImgOnly = !this.isImgOnly;
|
||||
},
|
||||
onPinyinChanged() {
|
||||
this.isPinyin = !this.isPinyin;
|
||||
},
|
||||
async onClickDropArea(event) {
|
||||
if (this.isProcessing) {
|
||||
Editor.Dialog.warn("当前有正在处理的文件,请等待完成。\n如果已完成,请关闭 DOS 窗口。");
|
||||
@ -102,7 +106,7 @@ module.exports = Editor.Panel.define({
|
||||
return;
|
||||
}
|
||||
this.isProcessing = true;
|
||||
await Editor.Message.request("ccc-tnt-psd2ui", "on-drop-file", { output: this.outputPath, files, isForceImg: this.isForceImg, isImgOnly: this.isImgOnly });
|
||||
await Editor.Message.request("ccc-tnt-psd2ui", "on-drop-file", { output: this.outputPath, files, isForceImg: this.isForceImg, isImgOnly: this.isImgOnly, isPinyin: this.isPinyin });
|
||||
this.isProcessing = false;
|
||||
}
|
||||
},
|
||||
|
@ -1,10 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.EditorVersion = void 0;
|
||||
var EditorVersion;
|
||||
(function (EditorVersion) {
|
||||
EditorVersion[EditorVersion["all"] = 0] = "all";
|
||||
EditorVersion[EditorVersion["v249"] = 1] = "v249";
|
||||
EditorVersion[EditorVersion["v342"] = 2] = "v342";
|
||||
EditorVersion[EditorVersion["v362"] = 3] = "v362";
|
||||
})(EditorVersion = exports.EditorVersion || (exports.EditorVersion = {}));
|
@ -1,180 +0,0 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.exportImageMgr = void 0;
|
||||
require("ag-psd/initialize-canvas"); // only needed for reading image data and thumbnails
|
||||
const psd = __importStar(require("ag-psd"));
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const ImageMgr_1 = require("./assets-manager/ImageMgr");
|
||||
const FileUtils_1 = require("./utils/FileUtils");
|
||||
const Parser_1 = require("./Parser");
|
||||
const PsdGroup_1 = require("./psd/PsdGroup");
|
||||
const PsdText_1 = require("./psd/PsdText");
|
||||
class ExportImageMgr {
|
||||
constructor() {
|
||||
this.textObjects = [];
|
||||
}
|
||||
test() {
|
||||
const outDir = path_1.default.join(__dirname, "..", "out");
|
||||
let psdPath = "./test-img-only/境界奖励-优化.psd";
|
||||
this.parsePsd(psdPath, outDir);
|
||||
}
|
||||
exec(args) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// 检查参数
|
||||
if (!this.checkArgs(args)) {
|
||||
return;
|
||||
}
|
||||
// 判断输入是文件夹还是文件
|
||||
let stat = fs_extra_1.default.lstatSync(args.input);
|
||||
let isDirectory = stat.isDirectory();
|
||||
if (isDirectory) {
|
||||
if (!args.output) {
|
||||
args.output = path_1.default.join(args.input, "psd2ui");
|
||||
}
|
||||
this.parsePsdDir(args.input, args.output);
|
||||
}
|
||||
else {
|
||||
if (!args.output) {
|
||||
let input_dir = path_1.default.dirname(args.input);
|
||||
args.output = path_1.default.join(input_dir, "psd2ui");
|
||||
}
|
||||
this.parsePsd(args.input, args.output);
|
||||
}
|
||||
});
|
||||
}
|
||||
// 检查参数
|
||||
checkArgs(args) {
|
||||
if (!args.input) {
|
||||
console.error(`请设置 --input`);
|
||||
return false;
|
||||
}
|
||||
if (!fs_extra_1.default.existsSync(args.input)) {
|
||||
console.error(`输入路径不存在: ${args.input}`);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
parsePsdDir(dir, outDir) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// 清空目录
|
||||
fs_extra_1.default.emptyDirSync(outDir);
|
||||
let psds = FileUtils_1.fileUtils.filterFile(dir, (fileName) => {
|
||||
let extname = path_1.default.extname(fileName);
|
||||
if (extname == ".psd") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
for (let i = 0; i < psds.length; i++) {
|
||||
const element = psds[i];
|
||||
yield this.parsePsd(element, outDir);
|
||||
}
|
||||
});
|
||||
}
|
||||
parsePsd(psdPath, outDir) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// 每开始一个新的 psd 清理掉上一个 psd 的图
|
||||
ImageMgr_1.imageMgr.clear();
|
||||
this.textObjects.length = 0;
|
||||
console.log(`=========================================`);
|
||||
console.log(`处理 ${psdPath} 文件`);
|
||||
let psdName = path_1.default.basename(psdPath, ".psd");
|
||||
let buffer = fs_extra_1.default.readFileSync(psdPath);
|
||||
const psdFile = psd.readPsd(buffer);
|
||||
let psdRoot = Parser_1.parser.parseLayer(psdFile);
|
||||
psdRoot.name = psdName;
|
||||
let prefabDir = path_1.default.join(outDir, psdName);
|
||||
let textureDir = path_1.default.join(prefabDir, "textures");
|
||||
fs_extra_1.default.mkdirsSync(prefabDir); // 创建预制体根目录
|
||||
fs_extra_1.default.emptyDirSync(prefabDir);
|
||||
fs_extra_1.default.mkdirsSync(textureDir); //创建 图片目录
|
||||
yield this.saveImage(textureDir);
|
||||
yield this.saveTextFile(psdRoot, prefabDir);
|
||||
console.log(`psd2ui ${psdPath} 处理完成`);
|
||||
});
|
||||
}
|
||||
saveImage(out) {
|
||||
let images = ImageMgr_1.imageMgr.getAllImage();
|
||||
let idx = 0;
|
||||
images.forEach((psdImage, k) => {
|
||||
// 查找镜像
|
||||
let _layer = ImageMgr_1.imageMgr.getSerialNumberImage(psdImage);
|
||||
let name = `${_layer.imgName}_${idx}`;
|
||||
console.log(`保存图片 [${_layer.imgName}] 重命名为 [${name}] md5: ${_layer.md5}`);
|
||||
let fullpath = path_1.default.join(out, `${name}.png`);
|
||||
fs_extra_1.default.writeFileSync(fullpath, _layer.imgBuffer);
|
||||
idx++;
|
||||
});
|
||||
}
|
||||
saveTextFile(psdRoot, out) {
|
||||
this.scanText(psdRoot, psdRoot);
|
||||
let textContent = JSON.stringify(this.textObjects, null, 2);
|
||||
let fullpath = path_1.default.join(out, `text.txt`);
|
||||
fs_extra_1.default.writeFileSync(fullpath, textContent, { encoding: "utf-8" });
|
||||
}
|
||||
scanText(layer, psdRoot) {
|
||||
if (layer instanceof PsdGroup_1.PsdGroup) {
|
||||
for (let i = 0; i < layer.children.length; i++) {
|
||||
const childLayer = layer.children[i];
|
||||
this.scanText(childLayer, psdRoot);
|
||||
}
|
||||
}
|
||||
else if (layer instanceof PsdText_1.PsdText) {
|
||||
let textObj = {
|
||||
text: layer.text,
|
||||
fontSize: layer.fontSize,
|
||||
color: `#${layer.color.toHEX()}`
|
||||
};
|
||||
// 有描边
|
||||
if (layer.outline) {
|
||||
textObj.outlineWidth = layer.outline.width;
|
||||
textObj.outlineColor = `#${layer.outline.color.toHEX()}`;
|
||||
}
|
||||
this.textObjects.push(textObj);
|
||||
}
|
||||
}
|
||||
static getInstance() {
|
||||
if (!this._instance) {
|
||||
this._instance = new ExportImageMgr();
|
||||
}
|
||||
return this._instance;
|
||||
}
|
||||
}
|
||||
ExportImageMgr._instance = null;
|
||||
exports.exportImageMgr = ExportImageMgr.getInstance();
|
@ -1,507 +0,0 @@
|
||||
"use strict";
|
||||
//ag-psd 使用 参考 https://github.com/Agamnentzar/ag-psd/blob/HEAD/README_PSD.md
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Main = void 0;
|
||||
require("ag-psd/initialize-canvas"); // only needed for reading image data and thumbnails
|
||||
const psd = __importStar(require("ag-psd"));
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const Parser_1 = require("./Parser");
|
||||
const PsdGroup_1 = require("./psd/PsdGroup");
|
||||
const CCNode_1 = require("./engine/cc/CCNode");
|
||||
const PsdImage_1 = require("./psd/PsdImage");
|
||||
const PsdText_1 = require("./psd/PsdText");
|
||||
const CCSprite_1 = require("./engine/cc/CCSprite");
|
||||
const CCPrefabInfo_1 = require("./engine/cc/CCPrefabInfo");
|
||||
const CCPrefab_1 = require("./engine/cc/CCPrefab");
|
||||
const CCSize_1 = require("./engine/cc/values/CCSize");
|
||||
const CCVec2_1 = require("./engine/cc/values/CCVec2");
|
||||
const CCLabel_1 = require("./engine/cc/CCLabel");
|
||||
const CCLabelOutline_1 = require("./engine/cc/CCLabelOutline");
|
||||
const ImageCacheMgr_1 = require("./assets-manager/ImageCacheMgr");
|
||||
const EditorVersion_1 = require("./EditorVersion");
|
||||
const config_1 = require("./config");
|
||||
const FileUtils_1 = require("./utils/FileUtils");
|
||||
const ImageMgr_1 = require("./assets-manager/ImageMgr");
|
||||
const ExportImageMgr_1 = require("./ExportImageMgr");
|
||||
const CCUIOpacity_1 = require("./engine/cc/CCUIOpacity");
|
||||
const CCUITransform_1 = require("./engine/cc/CCUITransform");
|
||||
const CCVec3_1 = require("./engine/cc/values/CCVec3");
|
||||
/***
|
||||
* 执行流程
|
||||
* - 首次运行,先读取项目文件夹下所有图片资源,进行 md5 缓存
|
||||
*
|
||||
* - 加载缓存文件
|
||||
* - 处理 psd
|
||||
* - 通过 md5 判断是否已经存在资源,如果存在, 则不再导出,预制体中使用已存在的资源的 uuid
|
||||
*
|
||||
*/
|
||||
console.log(`当前目录: `, __dirname);
|
||||
class Main {
|
||||
constructor() {
|
||||
this.spriteFrameMetaContent = "";
|
||||
this.prefabMetaContent = "";
|
||||
this.psdConfig = null;
|
||||
// 强制导出图片
|
||||
this.isForceImg = false;
|
||||
}
|
||||
test() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// config.editorVersion = EditorVersion.v342;
|
||||
// // 首次运行需要读取所有图片
|
||||
// await imageCacheMgr.loadImages("E:\\Demo\\CC249JSTest\\assets");
|
||||
// // await imageCacheMgr.loadImages("E:\\YQ\\Code\\trunk\\assets");
|
||||
// await imageCacheMgr.saveImageMap("E:\\Git\\ccc-framework-3d\\tools\\psd2ui\\cache\\cache.json");
|
||||
const outDir = path_1.default.join(__dirname, "..", "out");
|
||||
// // 加载测试配置
|
||||
this.loadPsdConfig(path_1.default.join(__dirname, "../test/test.config.json"));
|
||||
// // 首先加载缓存文件
|
||||
yield ImageCacheMgr_1.imageCacheMgr.initWithPath("E:\\Git\\ccc-framework-3d\\tools\\psd2ui\\cache\\cache.json");
|
||||
yield this.loadMetaTemplete();
|
||||
let psdPath = "./test/demo.psd";
|
||||
// // let psdPath = "E:\\YQ\\Meishu\\D_巅峰对决\\竞猜\\guild_PeakBetMainWindow.psd"
|
||||
// psdPath = "./test/对战动画-切.psd";
|
||||
psdPath = "./test/活动icon.psd";
|
||||
this.parsePsd(psdPath, outDir);
|
||||
// let psdPath = "./test";
|
||||
// let psdPath = "E:\\YQ\\Meishu\\D_巅峰对决\\竞猜\\guild_PeakBetMainWindow.psd"
|
||||
// psdPath = "./test/test.psd";
|
||||
// this.parsePsdDir(psdPath, outDir);
|
||||
yield ImageCacheMgr_1.imageCacheMgr.saveImageMap();
|
||||
console.log(`psd2ui 导出完成`);
|
||||
});
|
||||
}
|
||||
// 首先加载 meta 模板
|
||||
loadMetaTemplete() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
this.spriteFrameMetaContent = fs_extra_1.default.readFileSync(path_1.default.join(__dirname, `../assets/cc/meta/CCSpriteFrame.meta.${EditorVersion_1.EditorVersion[config_1.config.editorVersion]}`), "utf-8");
|
||||
this.prefabMetaContent = fs_extra_1.default.readFileSync(path_1.default.join(__dirname, `../assets/cc/meta/CCPrefab.meta.${EditorVersion_1.EditorVersion[config_1.config.editorVersion]}`), "utf-8");
|
||||
});
|
||||
}
|
||||
// 加载配置
|
||||
loadPsdConfig(filepath) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!fs_extra_1.default.existsSync(filepath)) {
|
||||
console.log(`Main-> 配置 ${filepath} 不存在`);
|
||||
return;
|
||||
}
|
||||
// console.log(`Main-> 读取配置 ${filepath}`);
|
||||
let psdConfig = fs_extra_1.default.readFileSync(filepath, "utf-8");
|
||||
this.psdConfig = JSON.parse(psdConfig);
|
||||
// // 合并 文本偏移配置
|
||||
// if (this.psdConfig.textOffsetY) {
|
||||
// config.textOffsetY = Object.assign({}, config.textOffsetY, this.psdConfig.textOffsetY);
|
||||
// }
|
||||
// // 合并 行高配置
|
||||
// if (this.psdConfig.textLineHeightOffset) {
|
||||
// config.textLineHeightOffset = Object.assign({}, config.textLineHeightOffset, this.psdConfig.textLineHeightOffset);
|
||||
// }
|
||||
// 合并配置
|
||||
for (const key in this.psdConfig) {
|
||||
if (key in config_1.config) {
|
||||
if (typeof this.psdConfig[key] === 'object') {
|
||||
config_1.config[key] = Object.assign({}, config_1.config[key], this.psdConfig[key]);
|
||||
}
|
||||
else {
|
||||
config_1.config[key] = this.psdConfig[key] || config_1.config[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
// console.log(`Main-> `,JSON.stringify(config,null,2));
|
||||
});
|
||||
}
|
||||
exec(args) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
args = mergeAlias(args);
|
||||
if (args.help) {
|
||||
console.log(`help:\n`, config_1.config.help);
|
||||
return false;
|
||||
}
|
||||
// 只导出图片
|
||||
if (args["img-only"]) {
|
||||
ExportImageMgr_1.exportImageMgr.exec(args);
|
||||
return true;
|
||||
}
|
||||
let writeCache = () => __awaiter(this, void 0, void 0, function* () {
|
||||
// 写入缓存
|
||||
if (args.cache) {
|
||||
fs_extra_1.default.mkdirsSync(path_1.default.dirname(args.cache));
|
||||
yield ImageCacheMgr_1.imageCacheMgr.saveImageMap(args.cache);
|
||||
}
|
||||
});
|
||||
// 设置引擎版本
|
||||
if (args["engine-version"]) {
|
||||
config_1.config.editorVersion = EditorVersion_1.EditorVersion[args["engine-version"]];
|
||||
}
|
||||
if (args.init && (!args["project-assets"] || !args.cache)) {
|
||||
console.log(`psd2ui --init 无法处理,请设置 --project-assets`);
|
||||
return;
|
||||
}
|
||||
// 在没有缓存文件或者 指定重新缓存的时候,读取项目资源
|
||||
if (args["project-assets"] && (!fs_extra_1.default.existsSync(args.cache) || args["cache-remake"] || args.init)) {
|
||||
yield ImageCacheMgr_1.imageCacheMgr.loadImages(args["project-assets"]);
|
||||
// 先写入一次
|
||||
writeCache();
|
||||
if (args.init) {
|
||||
console.log(`psd2ui 缓存完成`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// 检查参数
|
||||
if (!this.checkArgs(args)) {
|
||||
return;
|
||||
}
|
||||
if (args.cache) {
|
||||
yield ImageCacheMgr_1.imageCacheMgr.initWithPath(args.cache);
|
||||
}
|
||||
// 加载 meta 文件模板
|
||||
yield this.loadMetaTemplete();
|
||||
if (args.config) {
|
||||
yield this.loadPsdConfig(args.config);
|
||||
}
|
||||
this.isForceImg = !!args["force-img"];
|
||||
// 判断输入是文件夹还是文件
|
||||
let stat = fs_extra_1.default.lstatSync(args.input);
|
||||
let isDirectory = stat.isDirectory();
|
||||
if (isDirectory) {
|
||||
if (!args.output) {
|
||||
args.output = path_1.default.join(args.input, "psd2ui");
|
||||
}
|
||||
this.parsePsdDir(args.input, args.output);
|
||||
}
|
||||
else {
|
||||
if (!args.output) {
|
||||
let input_dir = path_1.default.dirname(args.input);
|
||||
args.output = path_1.default.join(input_dir, "psd2ui");
|
||||
}
|
||||
this.parsePsd(args.input, args.output);
|
||||
}
|
||||
// 写入缓存
|
||||
yield writeCache();
|
||||
console.log(`psd2ui 导出完成`);
|
||||
});
|
||||
}
|
||||
// 检查参数
|
||||
checkArgs(args) {
|
||||
if (!args.input) {
|
||||
console.error(`请设置 --input`);
|
||||
return false;
|
||||
}
|
||||
// 没有输出目录的时候用 输入目录
|
||||
// if (!args.output) {
|
||||
// console.error(`请设置 --output`);
|
||||
// return false;
|
||||
// }
|
||||
if (!fs_extra_1.default.existsSync(args.input)) {
|
||||
console.error(`输入路径不存在: ${args.input}`);
|
||||
return false;
|
||||
}
|
||||
if (args["engine-version"]) {
|
||||
let editorVersion = EditorVersion_1.EditorVersion[args["engine-version"]];
|
||||
switch (editorVersion) {
|
||||
case EditorVersion_1.EditorVersion.v249:
|
||||
case EditorVersion_1.EditorVersion.v342:
|
||||
break;
|
||||
default:
|
||||
console.log(`暂未实现该引擎版本 ${args["engine-version"]}`);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
parsePsdDir(dir, outDir) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// 清空目录
|
||||
// fs.emptyDirSync(outDir);
|
||||
let psds = FileUtils_1.fileUtils.filterFile(dir, (fileName) => {
|
||||
let extname = path_1.default.extname(fileName);
|
||||
if (extname == ".psd") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
for (let i = 0; i < psds.length; i++) {
|
||||
const element = psds[i];
|
||||
yield this.parsePsd(element, outDir);
|
||||
}
|
||||
});
|
||||
}
|
||||
parsePsd(psdPath, outDir) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
// 每开始一个新的 psd 清理掉上一个 psd 的图
|
||||
ImageMgr_1.imageMgr.clear();
|
||||
console.log(`=========================================`);
|
||||
console.log(`处理 ${psdPath} 文件`);
|
||||
let psdName = path_1.default.basename(psdPath, ".psd");
|
||||
let buffer = fs_extra_1.default.readFileSync(psdPath);
|
||||
const psdFile = psd.readPsd(buffer);
|
||||
let psdRoot = Parser_1.parser.parseLayer(psdFile);
|
||||
psdRoot.name = psdName;
|
||||
let prefabDir = path_1.default.join(outDir, psdName);
|
||||
let textureDir = path_1.default.join(prefabDir, "textures");
|
||||
fs_extra_1.default.mkdirsSync(prefabDir); // 创建预制体根目录
|
||||
// fs.emptyDirSync(prefabDir);
|
||||
fs_extra_1.default.mkdirsSync(textureDir); //创建 图片目录
|
||||
yield this.saveImage(textureDir);
|
||||
yield this.buildPrefab(psdRoot);
|
||||
yield this.savePrefab(psdRoot, prefabDir);
|
||||
console.log(`psd2ui ${psdPath} 处理完成`);
|
||||
});
|
||||
}
|
||||
buildPrefab(psdRoot) {
|
||||
let prefab = new CCPrefab_1.CCPrefab();
|
||||
psdRoot.pushObject(prefab);
|
||||
let data = this.createCCNode(psdRoot, psdRoot);
|
||||
prefab.data = { __id__: data.idx };
|
||||
// 后期处理
|
||||
this.postUIObject(psdRoot, psdRoot);
|
||||
}
|
||||
createCCNode(layer, psdRoot) {
|
||||
var _a, _b, _c, _d;
|
||||
let node = new CCNode_1.CCNode(psdRoot);
|
||||
layer.uiObject = node;
|
||||
node._name = ((_a = layer.attr) === null || _a === void 0 ? void 0 : _a.name) || layer.name;
|
||||
node._active = !layer.hidden;
|
||||
node._opacity = layer.opacity;
|
||||
if (config_1.config.editorVersion >= EditorVersion_1.EditorVersion.v342) {
|
||||
// 3.4.x
|
||||
if (layer.opacity !== 255) {
|
||||
let uiOpacity = new CCUIOpacity_1.CCUIOpacity();
|
||||
uiOpacity._opacity = layer.opacity;
|
||||
uiOpacity.updateWithLayer(layer);
|
||||
node.addComponent(uiOpacity);
|
||||
}
|
||||
}
|
||||
// 劫持尺寸设置,使用 psd 中配置的尺寸,这里不对原数据进行修改
|
||||
let size = new CCSize_1.CCSize(layer.size.width, layer.size.height);
|
||||
if ((_b = layer.attr) === null || _b === void 0 ? void 0 : _b.comps.size) {
|
||||
let _attrSize = layer.attr.comps.size;
|
||||
size.width = (_c = _attrSize.w) !== null && _c !== void 0 ? _c : size.width;
|
||||
size.height = (_d = _attrSize.h) !== null && _d !== void 0 ? _d : size.height;
|
||||
}
|
||||
// 对缩放进行处理
|
||||
size.width = Math.round(Math.abs(size.width / layer.scale.x));
|
||||
size.height = Math.round(Math.abs(size.height / layer.scale.y));
|
||||
// 配置的位置 Y 偏移
|
||||
let offsetY = 0;
|
||||
if (layer instanceof PsdText_1.PsdText) {
|
||||
offsetY = layer.offsetY;
|
||||
}
|
||||
node._contentSize = size;
|
||||
// 更新一下位置 // 根据图层名字设置 锚点,位置, 因为没有对原始数据进行修改,所以这里不考虑 缩放
|
||||
layer.updatePositionWithAR();
|
||||
// 2.4.9
|
||||
node._trs.setPosition(layer.position.x, layer.position.y + offsetY, 0);
|
||||
node._trs.setRotation(0, 0, 0, 1);
|
||||
node._trs.setScale(layer.scale.x, layer.scale.y, layer.scale.z);
|
||||
node._anchorPoint = new CCVec2_1.CCVec2(layer.anchorPoint.x, layer.anchorPoint.y);
|
||||
if (config_1.config.editorVersion >= EditorVersion_1.EditorVersion.v342) {
|
||||
// 3.4.x
|
||||
node._lpos = new CCVec3_1.CCVec3(layer.position.x, layer.position.y + offsetY, 0);
|
||||
node._lrot = new CCVec3_1.CCVec3(0, 0, 0);
|
||||
node._lscale = new CCVec3_1.CCVec3(layer.scale.x, layer.scale.y, layer.scale.z);
|
||||
node._euler = new CCVec3_1.CCVec3();
|
||||
// 3.4.x
|
||||
let uiTransform = new CCUITransform_1.CCUITransform();
|
||||
uiTransform._contentSize = size;
|
||||
uiTransform._anchorPoint = node._anchorPoint;
|
||||
uiTransform.updateWithLayer(layer);
|
||||
node.addComponent(uiTransform);
|
||||
}
|
||||
//
|
||||
if (layer instanceof PsdGroup_1.PsdGroup) {
|
||||
for (let i = 0; i < layer.children.length; i++) {
|
||||
const childLayer = layer.children[i];
|
||||
let childNode = this.createCCNode(childLayer, psdRoot);
|
||||
childNode && node.addChild(childNode);
|
||||
}
|
||||
}
|
||||
else if (layer instanceof PsdImage_1.PsdImage) {
|
||||
let sprite = new CCSprite_1.CCSprite();
|
||||
node.addComponent(sprite);
|
||||
sprite._materials.push({
|
||||
__uuid__: config_1.config.SpriteFrame_Material
|
||||
});
|
||||
sprite.updateWithLayer(layer);
|
||||
if (layer.isIgnore()) {
|
||||
// 忽略图像
|
||||
}
|
||||
else {
|
||||
// 查找绑定的图像
|
||||
let _layer = ImageMgr_1.imageMgr.getSerialNumberImage(layer);
|
||||
// 使用已缓存的 图片 的 uuid
|
||||
let imageWarp = ImageCacheMgr_1.imageCacheMgr.get(_layer.md5);
|
||||
sprite.setSpriteFrame(imageWarp ? imageWarp.textureUuid : _layer.textureUuid);
|
||||
}
|
||||
this.applyConfig(sprite);
|
||||
}
|
||||
else if (layer instanceof PsdText_1.PsdText) {
|
||||
let label = new CCLabel_1.CCLabel();
|
||||
node.addComponent(label);
|
||||
node._color.set(layer.color);
|
||||
label._color.set(layer.color);
|
||||
label._materials.push({
|
||||
__uuid__: config_1.config.Label_Material
|
||||
});
|
||||
label.updateWithLayer(layer);
|
||||
this.applyConfig(label);
|
||||
// 有描边
|
||||
if (layer.outline) {
|
||||
let labelOutline = new CCLabelOutline_1.CCLabelOutline();
|
||||
node.addComponent(labelOutline);
|
||||
labelOutline.updateWithLayer(layer);
|
||||
this.applyConfig(labelOutline);
|
||||
}
|
||||
}
|
||||
// Button / Toggle / ProgressBar
|
||||
if (layer.attr) {
|
||||
for (const key in layer.attr.comps) {
|
||||
if (Object.prototype.hasOwnProperty.call(layer.attr.comps, key) && layer.attr.comps[key]) {
|
||||
let ctor = config_1.config.CompMippings[key];
|
||||
if (ctor) {
|
||||
let comp = new ctor();
|
||||
node.addComponent(comp);
|
||||
comp.updateWithLayer(layer);
|
||||
this.applyConfig(comp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
this.createPrefabInfo(layer, psdRoot);
|
||||
return node;
|
||||
}
|
||||
createPrefabInfo(layer, psdRoot) {
|
||||
let node = layer.uiObject;
|
||||
let prefabInfo = new CCPrefabInfo_1.CCPrefabInfo();
|
||||
let idx = psdRoot.pushObject(prefabInfo);
|
||||
node._prefab = { __id__: idx };
|
||||
}
|
||||
// 后处理
|
||||
postUIObject(layer, psdRoot) {
|
||||
}
|
||||
saveImage(out) {
|
||||
let images = ImageMgr_1.imageMgr.getAllImage();
|
||||
images.forEach((psdImage, k) => {
|
||||
// 查找镜像
|
||||
let _layer = ImageMgr_1.imageMgr.getSerialNumberImage(psdImage);
|
||||
// 查找已缓存的相同图像
|
||||
let imageWarp = ImageCacheMgr_1.imageCacheMgr.get(_layer.md5);
|
||||
// 不是强制导出的话,判断是否已经导出过
|
||||
if (!this.isForceImg) {
|
||||
// 判断是否已经导出过相同 md5 的资源,不再重复导出
|
||||
if (imageWarp === null || imageWarp === void 0 ? void 0 : imageWarp.isOutput) {
|
||||
console.log(`已有相同资源,不再导出 [${psdImage.imgName}] md5: ${psdImage.md5}`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
console.log(`保存图片 [${_layer.imgName}] md5: ${_layer.md5}`);
|
||||
imageWarp && (imageWarp.isOutput = true);
|
||||
let fullpath = path_1.default.join(out, `${_layer.imgName}.png`);
|
||||
fs_extra_1.default.writeFileSync(fullpath, _layer.imgBuffer);
|
||||
this.saveImageMeta(_layer, fullpath);
|
||||
});
|
||||
}
|
||||
saveImageMeta(layer, fullpath) {
|
||||
let _layer = ImageMgr_1.imageMgr.getSerialNumberImage(layer);
|
||||
let imageWarp = ImageCacheMgr_1.imageCacheMgr.get(_layer.md5);
|
||||
if (!imageWarp) {
|
||||
imageWarp = _layer;
|
||||
}
|
||||
// 2.4.9 =-> SPRITE_FRAME_UUID
|
||||
let meta = this.spriteFrameMetaContent.replace(/\$SPRITE_FRAME_UUID/g, imageWarp.uuid);
|
||||
meta = meta.replace(/\$TEXTURE_UUID/g, imageWarp.textureUuid);
|
||||
meta = meta.replace(/\$FILE_NAME/g, _layer.imgName);
|
||||
meta = meta.replace(/\$WIDTH/g, _layer.textureSize.width);
|
||||
meta = meta.replace(/\$HEIGHT/g, _layer.textureSize.height);
|
||||
let s9 = _layer.s9 || {
|
||||
b: 0, t: 0, l: 0, r: 0,
|
||||
};
|
||||
meta = meta.replace(/\$BORDER_TOP/g, s9.t);
|
||||
meta = meta.replace(/\$BORDER_BOTTOM/g, s9.b);
|
||||
meta = meta.replace(/\$BORDER_LEFT/g, s9.l);
|
||||
meta = meta.replace(/\$BORDER_RIGHT/g, s9.r);
|
||||
fs_extra_1.default.writeFileSync(fullpath + `.meta`, meta);
|
||||
}
|
||||
savePrefab(psdDoc, out) {
|
||||
let fullpath = path_1.default.join(out, `${psdDoc.name}.prefab`);
|
||||
fs_extra_1.default.writeFileSync(fullpath, JSON.stringify(psdDoc.objectArray, null, 2));
|
||||
this.savePrefabMeta(psdDoc, fullpath);
|
||||
}
|
||||
savePrefabMeta(psdDoc, fullpath) {
|
||||
let meta = this.prefabMetaContent.replace(/\$PREFB_UUID/g, psdDoc.uuid);
|
||||
fs_extra_1.default.writeFileSync(fullpath + `.meta`, meta);
|
||||
}
|
||||
applyConfig(comp) {
|
||||
if (!this.psdConfig) {
|
||||
return;
|
||||
}
|
||||
if (comp.__type__ in this.psdConfig) {
|
||||
let compConfig = this.psdConfig[comp.__type__];
|
||||
for (const key in compConfig) {
|
||||
if (Object.prototype.hasOwnProperty.call(compConfig, key)) {
|
||||
const element = compConfig[key];
|
||||
comp[key] = element;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.Main = Main;
|
||||
/** 合并别名 */
|
||||
function mergeAlias(args) {
|
||||
// 如果是 json 对象参数
|
||||
if (args.json) {
|
||||
let base64 = args.json;
|
||||
// 解码 json
|
||||
args = JSON.parse(Buffer.from(base64, "base64").toString());
|
||||
// // 编码
|
||||
// let jsonContent = JSON.stringify(args);
|
||||
// let base64 = Buffer.from(jsonContent).toString("base64");
|
||||
}
|
||||
args.help = args.help || args.h;
|
||||
args.input = args.input || args.in;
|
||||
args.output = args.output || args.out;
|
||||
args["engine-version"] = args["engine-version"] || args.ev;
|
||||
args["project-assets"] = args["project-assets"] || args.p;
|
||||
args["cache-remake"] = args["cache-remake"] || args.crm;
|
||||
args["force-img"] = args["force-img"] || args.fimg;
|
||||
args.cache = args.cache || args.c;
|
||||
args.init = args.init || args.i;
|
||||
args.config = args.config;
|
||||
return args;
|
||||
}
|
@ -1,105 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parser = exports.Parser = void 0;
|
||||
const ImageCacheMgr_1 = require("./assets-manager/ImageCacheMgr");
|
||||
const ImageMgr_1 = require("./assets-manager/ImageMgr");
|
||||
const LayerType_1 = require("./psd/LayerType");
|
||||
const PsdDocument_1 = require("./psd/PsdDocument");
|
||||
const PsdGroup_1 = require("./psd/PsdGroup");
|
||||
const PsdImage_1 = require("./psd/PsdImage");
|
||||
const PsdText_1 = require("./psd/PsdText");
|
||||
class Parser {
|
||||
/** 解析图层类型 */
|
||||
parseLayerType(source) {
|
||||
if ("children" in source) {
|
||||
if ("width" in source && "height" in source) {
|
||||
// Document
|
||||
return LayerType_1.LayerType.Doc;
|
||||
}
|
||||
else {
|
||||
// Group
|
||||
return LayerType_1.LayerType.Group;
|
||||
}
|
||||
}
|
||||
else if ("text" in source) {
|
||||
// Text
|
||||
return LayerType_1.LayerType.Text;
|
||||
}
|
||||
// else if ('placedLayer' in layer) {
|
||||
// // 智能对象
|
||||
// }
|
||||
return LayerType_1.LayerType.Image;
|
||||
}
|
||||
parseLayer(source, parent, rootDoc) {
|
||||
let layer = null;
|
||||
let layerType = this.parseLayerType(source);
|
||||
switch (layerType) {
|
||||
case LayerType_1.LayerType.Doc:
|
||||
case LayerType_1.LayerType.Group:
|
||||
{
|
||||
let group = null;
|
||||
// Group
|
||||
if (layerType == LayerType_1.LayerType.Group) {
|
||||
group = new PsdGroup_1.PsdGroup(source, parent, rootDoc);
|
||||
if (group.attr.comps.ignorenode || group.attr.comps.ignore) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Document
|
||||
group = new PsdDocument_1.PsdDocument(source);
|
||||
}
|
||||
for (let i = 0; i < source.children.length; i++) {
|
||||
const childSource = source.children[i];
|
||||
let child = this.parseLayer(childSource, group, rootDoc || group);
|
||||
if (child) {
|
||||
if (!child.attr.comps.ignorenode && !child.attr.comps.ignore) {
|
||||
// 没有进行忽略节点的时候才放入列表
|
||||
group.children.push(child);
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.error(`图层解析错误`);
|
||||
}
|
||||
}
|
||||
layer = group;
|
||||
}
|
||||
break;
|
||||
case LayerType_1.LayerType.Image:
|
||||
{
|
||||
//
|
||||
if (!source.canvas) {
|
||||
console.error(`Parser-> 空图层 ${source === null || source === void 0 ? void 0 : source.name}`);
|
||||
return null;
|
||||
}
|
||||
// Image
|
||||
let image = layer = new PsdImage_1.PsdImage(source, parent, rootDoc);
|
||||
ImageMgr_1.imageMgr.add(image);
|
||||
// 没有设置忽略且不说镜像的情况下才进行缓存
|
||||
if (!image.isIgnore() && !image.isBind()) {
|
||||
if (!ImageCacheMgr_1.imageCacheMgr.has(image.md5)) {
|
||||
ImageCacheMgr_1.imageCacheMgr.set(image.md5, {
|
||||
uuid: image.uuid,
|
||||
textureUuid: image.textureUuid,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case LayerType_1.LayerType.Text:
|
||||
{
|
||||
// Text
|
||||
layer = new PsdText_1.PsdText(source, parent, rootDoc);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
layer.layerType = layerType;
|
||||
layer.parseSource();
|
||||
layer.onCtor();
|
||||
return layer;
|
||||
}
|
||||
}
|
||||
exports.Parser = Parser;
|
||||
exports.parser = new Parser();
|
@ -1,2 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
@ -1,123 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ccversion = exports.cctype = exports.nonserialization = void 0;
|
||||
const EditorVersion_1 = require("./EditorVersion");
|
||||
/** 禁止序列化 */
|
||||
let nonserialization = (target, propertyKey) => {
|
||||
if (!target.__unserialization) {
|
||||
target.__unserialization = [];
|
||||
}
|
||||
target.__unserialization.push(propertyKey);
|
||||
// if(!target.toJSON){
|
||||
// // JSON.stringify 自动调用
|
||||
// target.toJSON = function(){
|
||||
// let data:Record<any,any> = {};
|
||||
// for (const key in this) {
|
||||
// if (Object.prototype.hasOwnProperty.call(this, key)) {
|
||||
// // @ts-ignore
|
||||
// if(this.__unserialization.indexOf(key) !== -1){
|
||||
// continue;
|
||||
// }
|
||||
// // 判断编辑器版本
|
||||
// if(this._version && !this._version[key][EditorVersion[config.editorVersion]]){
|
||||
// continue;
|
||||
// }
|
||||
// const value = this[key];
|
||||
// data[key] = value;
|
||||
// }
|
||||
// }
|
||||
// return data;
|
||||
// }
|
||||
// }
|
||||
};
|
||||
exports.nonserialization = nonserialization;
|
||||
function cctype(type) {
|
||||
return (target) => {
|
||||
Object.defineProperty(target.prototype, "$__type__", {
|
||||
value: type,
|
||||
enumerable: true,
|
||||
});
|
||||
};
|
||||
}
|
||||
exports.cctype = cctype;
|
||||
let _extends = {};
|
||||
let _class_attrs = {};
|
||||
let _target_map_ = {};
|
||||
let __verIdx = 0;
|
||||
let _printID = -1;
|
||||
function checkTag(target) {
|
||||
if (target.constructor.__ver_tag_id__ === undefined || _target_map_[target.constructor.__ver_tag_id__] != target) {
|
||||
target.constructor.__ver_tag_id__ = `${__verIdx}`;
|
||||
_target_map_[target.constructor.__ver_tag_id__] = target;
|
||||
__verIdx++;
|
||||
}
|
||||
return target.constructor.__ver_tag_id__;
|
||||
}
|
||||
function _assign(target, source) {
|
||||
for (const key in source) {
|
||||
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
||||
if (key in target) {
|
||||
continue;
|
||||
}
|
||||
target[key] = source[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
function assign(target, ...sources) {
|
||||
for (let i = 0; i < sources.length; i++) {
|
||||
_assign(target, sources[i]);
|
||||
}
|
||||
}
|
||||
function ccversion(version) {
|
||||
return (target, propertyKey) => {
|
||||
let _class_name_ = target.constructor.name;
|
||||
_class_name_ = checkTag(target);
|
||||
!_class_attrs[_class_name_] && (_class_attrs[_class_name_] = {});
|
||||
let _class_obj = _class_attrs[_class_name_];
|
||||
if (!_class_obj[propertyKey]) {
|
||||
_class_obj[propertyKey] = {};
|
||||
}
|
||||
if (EditorVersion_1.EditorVersion.all === version) {
|
||||
for (const key in EditorVersion_1.EditorVersion) {
|
||||
_class_obj[propertyKey][EditorVersion_1.EditorVersion[key]] = true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
_class_obj[propertyKey][EditorVersion_1.EditorVersion[version]] = true;
|
||||
}
|
||||
var base = getSuper(target.constructor);
|
||||
// (base === Object || base === UIObject) && (base = null);
|
||||
if (base) {
|
||||
let parent = checkTag(base.prototype);
|
||||
!_extends[_class_name_] && (_extends[_class_name_] = parent);
|
||||
var _super = getSuper(base);
|
||||
let superIdx = 1;
|
||||
while (_super) {
|
||||
// if(_super === Object || _super === UIObject) {
|
||||
// // _super = null;
|
||||
// break;
|
||||
// }
|
||||
let super_tag = checkTag(_super.prototype);
|
||||
!_extends[parent] && (_extends[parent] = super_tag);
|
||||
_super = getSuper(_super);
|
||||
superIdx++;
|
||||
}
|
||||
while (parent) {
|
||||
if (parent in _class_attrs) {
|
||||
assign(_class_obj, _class_attrs[parent]);
|
||||
}
|
||||
parent = _extends[parent];
|
||||
}
|
||||
}
|
||||
if (!target._version) {
|
||||
target._version = {};
|
||||
}
|
||||
target._version[_class_name_] = _class_attrs[_class_name_] = _class_obj;
|
||||
};
|
||||
}
|
||||
exports.ccversion = ccversion;
|
||||
function getSuper(ctor) {
|
||||
var proto = ctor.prototype; // binded function do not have prototype
|
||||
var dunderProto = proto && Object.getPrototypeOf(proto);
|
||||
return dunderProto && dunderProto.constructor;
|
||||
}
|
@ -1,153 +0,0 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.imageCacheMgr = exports.ImageCacheMgr = void 0;
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const config_1 = require("../config");
|
||||
const EditorVersion_1 = require("../EditorVersion");
|
||||
const FileUtils_1 = require("../utils/FileUtils");
|
||||
class ImageCacheMgr {
|
||||
constructor() {
|
||||
this._imageMap = new Map();
|
||||
this._cachePath = null;
|
||||
}
|
||||
initWithPath(_path) {
|
||||
if (!fs_extra_1.default.existsSync(_path)) {
|
||||
console.log(`ImageCacheMgr-> 文件不存在: ${_path}`);
|
||||
return;
|
||||
}
|
||||
this._cachePath = _path;
|
||||
let content = fs_extra_1.default.readFileSync(_path, "utf-8");
|
||||
this.initWithFile(content);
|
||||
}
|
||||
initWithFile(file) {
|
||||
let json = JSON.parse(file);
|
||||
this.initWithJson(json);
|
||||
}
|
||||
initWithJson(json) {
|
||||
for (const key in json) {
|
||||
if (Object.prototype.hasOwnProperty.call(json, key)) {
|
||||
this._imageMap.set(key, json[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
set(md5, warp) {
|
||||
this._imageMap.set(md5, warp);
|
||||
}
|
||||
has(md5) {
|
||||
return this._imageMap.has(md5);
|
||||
}
|
||||
get(md5) {
|
||||
return this._imageMap.get(md5);
|
||||
}
|
||||
saveImageMap(_path) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (!_path) {
|
||||
_path = this._cachePath;
|
||||
}
|
||||
if (!_path) {
|
||||
console.log(`ImageCacheMgr-> 缓存路径 [${_path}] 不存在,无法保存 `);
|
||||
return;
|
||||
}
|
||||
let obj = Object.create(null);
|
||||
this._imageMap.forEach((v, k) => {
|
||||
obj[k] = v;
|
||||
});
|
||||
let content = JSON.stringify(obj, null, 2);
|
||||
yield FileUtils_1.fileUtils.writeFile(_path, content);
|
||||
});
|
||||
}
|
||||
// 获取已存在的图片,生成 md5: uuid 映射,
|
||||
loadImages(dir) {
|
||||
if (this._imageMap.size > 0) {
|
||||
console.error(`ImageCacheMgr-> 暂时只能在 启动时加载`);
|
||||
return;
|
||||
}
|
||||
let pngs = FileUtils_1.fileUtils.filterFile(dir, (fileName) => {
|
||||
let extname = path_1.default.extname(fileName);
|
||||
if (extname == ".png") {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
for (let i = 0; i < pngs.length; i++) {
|
||||
const png = pngs[i];
|
||||
let md5 = FileUtils_1.fileUtils.getMD5(png);
|
||||
console.log(`ImageCacheMgr->缓存 `, png);
|
||||
let imageWarp = this._loadImageMetaWarp(`${png}.meta`);
|
||||
if (imageWarp) {
|
||||
this.set(md5, imageWarp);
|
||||
}
|
||||
}
|
||||
}
|
||||
_loadImageMetaWarp(_path) {
|
||||
let content = fs_extra_1.default.readFileSync(_path, { encoding: "utf-8" });
|
||||
let imageWarp = null;
|
||||
switch (config_1.config.editorVersion) {
|
||||
case EditorVersion_1.EditorVersion.v249:
|
||||
imageWarp = this._loadImageMeta249(content, _path);
|
||||
break;
|
||||
case EditorVersion_1.EditorVersion.v342:
|
||||
imageWarp = this._loadImageMeta34x(content, _path);
|
||||
break;
|
||||
default:
|
||||
console.log(`ImageCacheMgr-> 暂未实现 ${EditorVersion_1.EditorVersion[config_1.config.editorVersion]} 版本`);
|
||||
break;
|
||||
}
|
||||
return imageWarp;
|
||||
}
|
||||
_loadImageMeta249(metaContent, _path) {
|
||||
var _a;
|
||||
let filename = path_1.default.basename(_path, ".png.meta");
|
||||
let fullpath = path_1.default.join(path_1.default.dirname(_path), `${filename}.png`);
|
||||
let metaJson = JSON.parse(metaContent);
|
||||
if (!((_a = metaJson === null || metaJson === void 0 ? void 0 : metaJson.subMetas) === null || _a === void 0 ? void 0 : _a[filename])) {
|
||||
return null;
|
||||
}
|
||||
let imageWarp = {
|
||||
path: fullpath,
|
||||
textureUuid: metaJson.subMetas[filename].uuid,
|
||||
uuid: metaJson.uuid,
|
||||
isOutput: true,
|
||||
};
|
||||
return imageWarp;
|
||||
}
|
||||
_loadImageMeta34x(metaContent, _path) {
|
||||
var _a;
|
||||
let filename = path_1.default.basename(_path, ".png.meta");
|
||||
let fullpath = path_1.default.join(path_1.default.dirname(_path), `${filename}.png`);
|
||||
let metaJson = JSON.parse(metaContent);
|
||||
if (!((_a = metaJson === null || metaJson === void 0 ? void 0 : metaJson.subMetas) === null || _a === void 0 ? void 0 : _a["6c48a"])) {
|
||||
return null;
|
||||
}
|
||||
let uuid = metaJson.subMetas["6c48a"].uuid.replace("@6c48a", "");
|
||||
let imageWarp = {
|
||||
path: fullpath,
|
||||
textureUuid: uuid,
|
||||
uuid: uuid,
|
||||
isOutput: true,
|
||||
};
|
||||
return imageWarp;
|
||||
}
|
||||
static getInstance() {
|
||||
if (!this._instance) {
|
||||
this._instance = new ImageCacheMgr();
|
||||
}
|
||||
return this._instance;
|
||||
}
|
||||
}
|
||||
exports.ImageCacheMgr = ImageCacheMgr;
|
||||
ImageCacheMgr._instance = null;
|
||||
exports.imageCacheMgr = ImageCacheMgr.getInstance();
|
@ -1,56 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.imageMgr = void 0;
|
||||
class ImageMgr {
|
||||
constructor() {
|
||||
// 镜像图像管理
|
||||
this._imageIdKeyMap = new Map();
|
||||
// 当前 psd 所有的图片
|
||||
this._imageArray = new Map();
|
||||
}
|
||||
add(psdImage) {
|
||||
var _a;
|
||||
// 不忽略导出图片
|
||||
if (!psdImage.isIgnore() && !psdImage.isBind()) {
|
||||
if (!this._imageArray.has(psdImage.md5)) {
|
||||
this._imageArray.set(psdImage.md5, psdImage);
|
||||
}
|
||||
}
|
||||
if (typeof ((_a = psdImage.attr.comps.img) === null || _a === void 0 ? void 0 : _a.id) != "undefined") {
|
||||
let id = psdImage.attr.comps.img.id;
|
||||
if (this._imageIdKeyMap.has(id)) {
|
||||
console.warn(`ImageMgr-> ${psdImage.source.name} 已有相同 @img{id:${id}},请检查 psd 图层`);
|
||||
}
|
||||
this._imageIdKeyMap.set(id, psdImage);
|
||||
}
|
||||
}
|
||||
getAllImage() {
|
||||
return this._imageArray;
|
||||
}
|
||||
/** 尝试获取有编号的图像图层 */
|
||||
getSerialNumberImage(psdImage) {
|
||||
var _a, _b, _c;
|
||||
let bind = (_b = (_a = psdImage.attr.comps.flip) === null || _a === void 0 ? void 0 : _a.bind) !== null && _b !== void 0 ? _b : (_c = psdImage.attr.comps.img) === null || _c === void 0 ? void 0 : _c.bind;
|
||||
if (typeof bind != 'undefined') {
|
||||
if (this._imageIdKeyMap.has(bind)) {
|
||||
return this._imageIdKeyMap.get(bind);
|
||||
}
|
||||
else {
|
||||
console.warn(`ImageMgr-> ${psdImage.source.name} 未找到绑定的图像 {${bind}},请检查 psd 图层`);
|
||||
}
|
||||
}
|
||||
return psdImage;
|
||||
}
|
||||
clear() {
|
||||
this._imageIdKeyMap.clear();
|
||||
this._imageArray.clear();
|
||||
}
|
||||
static getInstance() {
|
||||
if (!this._instance) {
|
||||
this._instance = new ImageMgr();
|
||||
}
|
||||
return this._instance;
|
||||
}
|
||||
}
|
||||
ImageMgr._instance = null;
|
||||
exports.imageMgr = ImageMgr.getInstance();
|
@ -1,56 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.config = exports.Config = void 0;
|
||||
const EditorVersion_1 = require("./EditorVersion");
|
||||
const CCButton_1 = require("./engine/cc/CCButton");
|
||||
const CCProgressBar_1 = require("./engine/cc/CCProgressBar");
|
||||
const CCToggle_1 = require("./engine/cc/CCToggle");
|
||||
class Config {
|
||||
constructor() {
|
||||
this.help = `
|
||||
--help | --h 帮助信息
|
||||
--init | --i 初始化缓存文件 必须设置 --project-assets --cache 两项
|
||||
--force-img | --fimg 强制导出图片 即使在有缓存的情况下也要导出
|
||||
--input | --in 输入目录或者 psd 文件 非 init 时 必选 [dir or psd]
|
||||
--output | --out 输出目录 可选 缺省时为 --input [dir]
|
||||
--engine-version | --ev 引擎版本 可选 [v249 | v342 | v362]
|
||||
--project-assets | --p 指定项目文件夹 可选 [dir]
|
||||
--cache-remake | --crm 重新创建缓存文件 可选
|
||||
--cache | --c 缓存文件全路径 可选 [file-full-path]
|
||||
--config | 预制体配置 可选 [file-full-path]
|
||||
--img-only | 只导出图片 可选
|
||||
--json | json 对象参数 插件工具使用 将所有参数用对象的形式编码成 base64 字符串
|
||||
`;
|
||||
this.editorVersion = EditorVersion_1.EditorVersion.v249;
|
||||
this.DEFAULT_SPRITEFRAME_MATERIAL = {
|
||||
[EditorVersion_1.EditorVersion.v249]: "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432",
|
||||
[EditorVersion_1.EditorVersion.v342]: "",
|
||||
[EditorVersion_1.EditorVersion.v362]: "",
|
||||
};
|
||||
this.DEFAULT_LABEL_MATERIAL = {
|
||||
[EditorVersion_1.EditorVersion.v249]: "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432",
|
||||
[EditorVersion_1.EditorVersion.v342]: "",
|
||||
[EditorVersion_1.EditorVersion.v362]: "",
|
||||
};
|
||||
this.CompMippings = {
|
||||
"Btn": CCButton_1.CCButton,
|
||||
"ProgressBar": CCProgressBar_1.CCProgressBar,
|
||||
"Toggle": CCToggle_1.CCToggle,
|
||||
};
|
||||
// text 文本 Y 偏移
|
||||
this.textOffsetY = {
|
||||
default: 0,
|
||||
"36": 0,
|
||||
};
|
||||
// text 文本 行高偏移,默认为 0 ,行高默认为 字体大小
|
||||
this.textLineHeightOffset = 0;
|
||||
}
|
||||
get SpriteFrame_Material() {
|
||||
return this.DEFAULT_SPRITEFRAME_MATERIAL[exports.config.editorVersion];
|
||||
}
|
||||
get Label_Material() {
|
||||
return this.DEFAULT_LABEL_MATERIAL[exports.config.editorVersion];
|
||||
}
|
||||
}
|
||||
exports.Config = Config;
|
||||
exports.config = new Config();
|
@ -1,52 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UIObject = void 0;
|
||||
const config_1 = require("../config");
|
||||
const EditorVersion_1 = require("../EditorVersion");
|
||||
const Utils_1 = require("../utils/Utils");
|
||||
const _decorator_1 = require("../_decorator");
|
||||
class UIObject {
|
||||
constructor() {
|
||||
this.uuid = "";
|
||||
this.idx = 0;
|
||||
this.uuid = Utils_1.utils.uuid();
|
||||
}
|
||||
toJSON() {
|
||||
var _a;
|
||||
let data = {};
|
||||
for (const key in this) {
|
||||
if (Object.prototype.hasOwnProperty.call(this, key)) {
|
||||
// @ts-ignore
|
||||
if (this.__unserialization && this.__unserialization.indexOf(key) !== -1) {
|
||||
continue;
|
||||
}
|
||||
// @ts-ignore
|
||||
let ver_tag = this.constructor.__ver_tag_id__;
|
||||
// 判断编辑器版本
|
||||
// @ts-ignore
|
||||
if (this._version && ((_a = this._version[ver_tag]) === null || _a === void 0 ? void 0 : _a[key])) {
|
||||
// @ts-ignore
|
||||
if (!this._version[ver_tag][key][EditorVersion_1.EditorVersion[config_1.config.editorVersion]]) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
const value = this[key];
|
||||
data[key] = value;
|
||||
}
|
||||
}
|
||||
return data;
|
||||
}
|
||||
}
|
||||
__decorate([
|
||||
_decorator_1.nonserialization
|
||||
], UIObject.prototype, "uuid", void 0);
|
||||
__decorate([
|
||||
_decorator_1.nonserialization
|
||||
], UIObject.prototype, "idx", void 0);
|
||||
exports.UIObject = UIObject;
|
@ -1,87 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCButton = void 0;
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const CCComponent_1 = require("./CCComponent");
|
||||
let CCButton = class CCButton extends CCComponent_1.CCComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
// 2.4.x
|
||||
this.duration = 0.1;
|
||||
// 2.4.x
|
||||
this.zoomScale = 1.2;
|
||||
this.clickEvents = [];
|
||||
// 2.4.x
|
||||
this._N$interactable = true;
|
||||
// 2.4.x
|
||||
this._N$enableAutoGrayEffect = false;
|
||||
// 2.4.x
|
||||
this._N$transition = 3;
|
||||
// 2.4.x
|
||||
this.transition = 3;
|
||||
// 2.4.x
|
||||
this._N$target = null;
|
||||
// 3.4.x
|
||||
this._interactable = true;
|
||||
// 3.4.x
|
||||
this._transition = 3;
|
||||
// 3.4.x
|
||||
this._duration = 0.1;
|
||||
// 3.4.x
|
||||
this._zoomScale = 1.2;
|
||||
// 3.4.x
|
||||
this._target = null;
|
||||
}
|
||||
updateWithLayer(psdLayer) {
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCButton.prototype, "duration", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCButton.prototype, "zoomScale", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCButton.prototype, "clickEvents", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCButton.prototype, "_N$interactable", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCButton.prototype, "_N$enableAutoGrayEffect", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCButton.prototype, "_N$transition", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCButton.prototype, "transition", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCButton.prototype, "_N$target", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCButton.prototype, "_interactable", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCButton.prototype, "_transition", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCButton.prototype, "_duration", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCButton.prototype, "_zoomScale", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCButton.prototype, "_target", void 0);
|
||||
CCButton = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.Button")
|
||||
], CCButton);
|
||||
exports.CCButton = CCButton;
|
@ -1,15 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCCompPrefabInfo = void 0;
|
||||
const Utils_1 = require("../../utils/Utils");
|
||||
const UIObject_1 = require("../UIObject");
|
||||
// @cctype("cc.CompPrefabInfo")
|
||||
class CCCompPrefabInfo extends UIObject_1.UIObject {
|
||||
constructor() {
|
||||
super();
|
||||
this.__type__ = "cc.CompPrefabInfo";
|
||||
this.fileId = "";
|
||||
this.fileId = Utils_1.utils.compressUuid(this.uuid);
|
||||
}
|
||||
}
|
||||
exports.CCCompPrefabInfo = CCCompPrefabInfo;
|
@ -1,35 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCComponent = void 0;
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const CCObject_1 = require("./CCObject");
|
||||
class CCComponent extends CCObject_1.CCObject {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this._enabled = true;
|
||||
this.node = null;
|
||||
this._id = "";
|
||||
// 3.4.x
|
||||
this.__prefab = null;
|
||||
}
|
||||
}
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCComponent.prototype, "_enabled", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCComponent.prototype, "node", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCComponent.prototype, "_id", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCComponent.prototype, "__prefab", void 0);
|
||||
exports.CCComponent = CCComponent;
|
@ -1,167 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCLabel = void 0;
|
||||
const config_1 = require("../../config");
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const CCComponent_1 = require("./CCComponent");
|
||||
const CCColor_1 = require("./values/CCColor");
|
||||
let CCLabel = class CCLabel extends CCComponent_1.CCComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this._srcBlendFactor = 770; // 3.4.x = 2
|
||||
this._dstBlendFactor = 771; // 3.4.x = 4
|
||||
this._string = "";
|
||||
this._fontSize = 0;
|
||||
this._lineHeight = 0;
|
||||
this._enableWrapText = true;
|
||||
this._isSystemFontUsed = true;
|
||||
this._spacingX = 0;
|
||||
this._underlineHeight = 0;
|
||||
this._materials = [];
|
||||
// 2.4.x
|
||||
this._N$string = "";
|
||||
// 2.4.x
|
||||
this._N$file = null;
|
||||
// 2.4.x
|
||||
this._batchAsBitmap = false;
|
||||
// 2.4.x
|
||||
this._styleFlags = 0;
|
||||
// 2.4.x
|
||||
this._N$horizontalAlign = 1;
|
||||
// 2.4.x
|
||||
this._N$verticalAlign = 1;
|
||||
// 2.4.x
|
||||
this._N$fontFamily = "Arial";
|
||||
// 2.4.x
|
||||
this._N$overflow = 0;
|
||||
// 2.4.x
|
||||
this._N$cacheMode = 0;
|
||||
// 3.4.x
|
||||
this._visFlags = 0;
|
||||
// 3.4.x
|
||||
this._customMaterial = null;
|
||||
// 3.4.x
|
||||
this._color = new CCColor_1.CCColor(255, 255, 255, 255);
|
||||
// 3.4.x
|
||||
this._overflow = 0;
|
||||
// // 3.4.x
|
||||
this._cacheMode = 0;
|
||||
this._horizontalAlign = 1;
|
||||
this._verticalAlign = 1;
|
||||
this._actualFontSize = 0;
|
||||
this._isItalic = false;
|
||||
this._isBold = false;
|
||||
this._isUnderline = false;
|
||||
}
|
||||
updateWithLayer(psdLayer) {
|
||||
this._fontSize = psdLayer.fontSize;
|
||||
// this._actualFontSize = this._fontSize;
|
||||
this._string = this._N$string = psdLayer.text;
|
||||
this._lineHeight = this._fontSize + config_1.config.textLineHeightOffset;
|
||||
if (config_1.config.editorVersion >= EditorVersion_1.EditorVersion.v342) {
|
||||
this._srcBlendFactor = 2;
|
||||
this._dstBlendFactor = 4;
|
||||
}
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCLabel.prototype, "_srcBlendFactor", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCLabel.prototype, "_dstBlendFactor", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCLabel.prototype, "_string", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCLabel.prototype, "_fontSize", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCLabel.prototype, "_lineHeight", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCLabel.prototype, "_enableWrapText", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCLabel.prototype, "_isSystemFontUsed", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCLabel.prototype, "_spacingX", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCLabel.prototype, "_underlineHeight", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCLabel.prototype, "_materials", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCLabel.prototype, "_N$string", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCLabel.prototype, "_N$file", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCLabel.prototype, "_batchAsBitmap", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCLabel.prototype, "_styleFlags", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCLabel.prototype, "_N$horizontalAlign", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCLabel.prototype, "_N$verticalAlign", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCLabel.prototype, "_N$fontFamily", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCLabel.prototype, "_N$overflow", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCLabel.prototype, "_N$cacheMode", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCLabel.prototype, "_visFlags", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCLabel.prototype, "_customMaterial", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCLabel.prototype, "_color", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCLabel.prototype, "_overflow", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCLabel.prototype, "_cacheMode", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCLabel.prototype, "_horizontalAlign", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCLabel.prototype, "_verticalAlign", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCLabel.prototype, "_actualFontSize", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCLabel.prototype, "_isItalic", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCLabel.prototype, "_isBold", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCLabel.prototype, "_isUnderline", void 0);
|
||||
CCLabel = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.Label")
|
||||
], CCLabel);
|
||||
exports.CCLabel = CCLabel;
|
@ -1,34 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCLabelOutline = void 0;
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const CCComponent_1 = require("./CCComponent");
|
||||
const CCColor_1 = require("./values/CCColor");
|
||||
let CCLabelOutline = class CCLabelOutline extends CCComponent_1.CCComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this._color = new CCColor_1.CCColor(255, 255, 255, 255);
|
||||
this._width = 1;
|
||||
}
|
||||
updateWithLayer(psdLayer) {
|
||||
this._width = psdLayer.outline.width;
|
||||
this._color.set(psdLayer.outline.color);
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCLabelOutline.prototype, "_color", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCLabelOutline.prototype, "_width", void 0);
|
||||
CCLabelOutline = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.LabelOutline")
|
||||
], CCLabelOutline);
|
||||
exports.CCLabelOutline = CCLabelOutline;
|
@ -1,177 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCNode = void 0;
|
||||
const config_1 = require("../../config");
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const CCCompPrefabInfo_1 = require("./CCCompPrefabInfo");
|
||||
const CCObject_1 = require("./CCObject");
|
||||
const CCColor_1 = require("./values/CCColor");
|
||||
const CCSize_1 = require("./values/CCSize");
|
||||
const CCTypedArray_1 = require("./values/CCTypedArray");
|
||||
const CCVec2_1 = require("./values/CCVec2");
|
||||
const CCVec3_1 = require("./values/CCVec3");
|
||||
let CCNode = class CCNode extends CCObject_1.CCObject {
|
||||
constructor(psdDoc) {
|
||||
super();
|
||||
this._parent = null;
|
||||
this._children = [];
|
||||
this._active = true;
|
||||
this._components = [];
|
||||
this._prefab = null;
|
||||
this._id = "";
|
||||
// 2.4.x
|
||||
this._opacity = 255;
|
||||
// 2.4.x
|
||||
this._color = new CCColor_1.CCColor(255, 255, 255, 255);
|
||||
// 2.4.x
|
||||
this._contentSize = new CCSize_1.CCSize();
|
||||
// 2.4.x
|
||||
this._anchorPoint = new CCVec2_1.CCVec2(0, 0);
|
||||
// 2.4.x
|
||||
this._trs = new CCTypedArray_1.CCTypedArray();
|
||||
// 2.4.x
|
||||
this._eulerAngles = new CCVec3_1.CCVec3();
|
||||
// 2.4.x
|
||||
this._skewX = 0;
|
||||
// 2.4.x
|
||||
this._skewY = 0;
|
||||
// 2.4.x
|
||||
this._is3DNode = false;
|
||||
// 2.4.x
|
||||
this._groupIndex = 0;
|
||||
// 2.4.x
|
||||
this.groupIndex = 0;
|
||||
// 2.4.x
|
||||
this._renderEnable = false;
|
||||
// 2.4.x
|
||||
this._bfsRenderFlag = false;
|
||||
// 3.4.x
|
||||
this._lpos = new CCVec3_1.CCVec3();
|
||||
// 3.4.x
|
||||
this._lrot = new CCVec3_1.CCVec3();
|
||||
// 3.4.x
|
||||
this._lscale = new CCVec3_1.CCVec3();
|
||||
// 3.4.x
|
||||
this._euler = new CCVec3_1.CCVec3();
|
||||
// 3.4.x
|
||||
this._layer = 33554432;
|
||||
this.psdDoc = null;
|
||||
this.components = [];
|
||||
this.children = [];
|
||||
if (psdDoc) {
|
||||
this.psdDoc = psdDoc;
|
||||
psdDoc.pushObject(this);
|
||||
}
|
||||
}
|
||||
addComponent(comp) {
|
||||
comp.node = { __id__: this.idx };
|
||||
let compIdx = this.psdDoc.pushObject(comp);
|
||||
this._components.push({ __id__: compIdx });
|
||||
this.components.push(comp);
|
||||
if (config_1.config.editorVersion >= EditorVersion_1.EditorVersion.v342) {
|
||||
this.addCompPrefabInfo(comp);
|
||||
}
|
||||
}
|
||||
addCompPrefabInfo(comp) {
|
||||
let compInfo = new CCCompPrefabInfo_1.CCCompPrefabInfo();
|
||||
let compIdx = this.psdDoc.pushObject(compInfo);
|
||||
comp.__prefab = { __id__: compIdx };
|
||||
}
|
||||
addChild(child) {
|
||||
this._children.push({ __id__: child.idx });
|
||||
child._parent = { __id__: this.idx };
|
||||
this.children.push(child);
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCNode.prototype, "_parent", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCNode.prototype, "_children", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCNode.prototype, "_active", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCNode.prototype, "_components", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCNode.prototype, "_prefab", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCNode.prototype, "_id", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_opacity", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_color", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_contentSize", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_anchorPoint", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_trs", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_eulerAngles", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_skewX", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_skewY", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_is3DNode", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_groupIndex", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "groupIndex", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_renderEnable", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCNode.prototype, "_bfsRenderFlag", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCNode.prototype, "_lpos", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCNode.prototype, "_lrot", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCNode.prototype, "_lscale", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCNode.prototype, "_euler", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCNode.prototype, "_layer", void 0);
|
||||
__decorate([
|
||||
_decorator_1.nonserialization
|
||||
], CCNode.prototype, "psdDoc", void 0);
|
||||
__decorate([
|
||||
_decorator_1.nonserialization
|
||||
], CCNode.prototype, "components", void 0);
|
||||
__decorate([
|
||||
_decorator_1.nonserialization
|
||||
], CCNode.prototype, "children", void 0);
|
||||
CCNode = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.Node")
|
||||
], CCNode);
|
||||
exports.CCNode = CCNode;
|
@ -1,31 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCObject = void 0;
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const UIObject_1 = require("../UIObject");
|
||||
class CCObject extends UIObject_1.UIObject {
|
||||
constructor() {
|
||||
super();
|
||||
this._name = "";
|
||||
this._objFlags = 0;
|
||||
// @ts-ignore
|
||||
this.__type__ = this.$__type__;
|
||||
}
|
||||
}
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCObject.prototype, "__type__", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCObject.prototype, "_name", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCObject.prototype, "_objFlags", void 0);
|
||||
exports.CCObject = CCObject;
|
@ -1,47 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCPrefab = void 0;
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const CCObject_1 = require("./CCObject");
|
||||
let CCPrefab = class CCPrefab extends CCObject_1.CCObject {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this._native = "";
|
||||
this.data = null;
|
||||
this.optimizationPolicy = 0;
|
||||
this.asyncLoadAssets = false;
|
||||
// 2.4.x
|
||||
this.readonly = false;
|
||||
// // 3.4.x
|
||||
this.persistent = false;
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCPrefab.prototype, "_native", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCPrefab.prototype, "data", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCPrefab.prototype, "optimizationPolicy", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCPrefab.prototype, "asyncLoadAssets", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCPrefab.prototype, "readonly", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCPrefab.prototype, "persistent", void 0);
|
||||
CCPrefab = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.Prefab")
|
||||
], CCPrefab);
|
||||
exports.CCPrefab = CCPrefab;
|
@ -1,41 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCPrefabInfo = void 0;
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const Utils_1 = require("../../utils/Utils");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const UIObject_1 = require("../UIObject");
|
||||
// @cctype("cc.PrefabInfo")
|
||||
class CCPrefabInfo extends UIObject_1.UIObject {
|
||||
constructor() {
|
||||
super();
|
||||
this.__type__ = "cc.PrefabInfo";
|
||||
this.root = { __id__: 1 };
|
||||
this.asset = { __id__: 0 };
|
||||
this.fileId = "";
|
||||
this.sync = false;
|
||||
this.fileId = Utils_1.utils.compressUuid(this.uuid);
|
||||
}
|
||||
}
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCPrefabInfo.prototype, "__type__", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCPrefabInfo.prototype, "root", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCPrefabInfo.prototype, "asset", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCPrefabInfo.prototype, "fileId", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCPrefabInfo.prototype, "sync", void 0);
|
||||
exports.CCPrefabInfo = CCPrefabInfo;
|
@ -1,98 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCProgressBar = void 0;
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const CCComponent_1 = require("./CCComponent");
|
||||
const CCSprite_1 = require("./CCSprite");
|
||||
let CCProgressBar = class CCProgressBar extends CCComponent_1.CCComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
// 2.4.x
|
||||
this._N$totalLength = 0;
|
||||
// 2.4.x
|
||||
this._N$barSprite = null;
|
||||
// 2.4.x
|
||||
this._N$mode = 0;
|
||||
// 2.4.x
|
||||
this._N$progress = 1;
|
||||
// 2.4.x
|
||||
this._N$reverse = false;
|
||||
// 3.4.x
|
||||
this._barSprite = null;
|
||||
// 3.4.x
|
||||
this._mode = 0;
|
||||
// 3.4.x
|
||||
this._totalLength = 0;
|
||||
// 3.4.x
|
||||
this._progress = 1;
|
||||
// 3.4.x
|
||||
this._reverse = false;
|
||||
}
|
||||
setBar(sprite) {
|
||||
this._barSprite = this._N$barSprite = {
|
||||
__id__: sprite.idx
|
||||
};
|
||||
}
|
||||
updateWithLayer(psdLayer) {
|
||||
if (!psdLayer.children) {
|
||||
console.error(`CCProgressBar-> 只能作用在 组图层 上`);
|
||||
return;
|
||||
}
|
||||
outer: for (let i = 0; i < psdLayer.children.length; i++) {
|
||||
const child = psdLayer.children[i];
|
||||
if (child.attr.comps.bar) {
|
||||
let node = child.uiObject;
|
||||
// 暂时只有横向进度条
|
||||
this._totalLength = this._N$totalLength = node._contentSize.width;
|
||||
for (let j = 0; j < node.components.length; j++) {
|
||||
const comp = node.components[j];
|
||||
if (comp instanceof CCSprite_1.CCSprite) {
|
||||
this.setBar(comp);
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCProgressBar.prototype, "_N$totalLength", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCProgressBar.prototype, "_N$barSprite", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCProgressBar.prototype, "_N$mode", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCProgressBar.prototype, "_N$progress", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCProgressBar.prototype, "_N$reverse", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCProgressBar.prototype, "_barSprite", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCProgressBar.prototype, "_mode", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCProgressBar.prototype, "_totalLength", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCProgressBar.prototype, "_progress", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCProgressBar.prototype, "_reverse", void 0);
|
||||
CCProgressBar = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.ProgressBar")
|
||||
], CCProgressBar);
|
||||
exports.CCProgressBar = CCProgressBar;
|
@ -1,117 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCSprite = void 0;
|
||||
const config_1 = require("../../config");
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const CCComponent_1 = require("./CCComponent");
|
||||
const CCColor_1 = require("./values/CCColor");
|
||||
const CCVec2_1 = require("./values/CCVec2");
|
||||
let CCSprite = class CCSprite extends CCComponent_1.CCComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
// 2.4.x
|
||||
this._materials = [];
|
||||
this._srcBlendFactor = 770; // 3.4.x = 2
|
||||
this._dstBlendFactor = 771; // 3.4.x = 4
|
||||
this._spriteFrame = null;
|
||||
this._type = 0;
|
||||
this._sizeMode = 1;
|
||||
this._fillType = 0;
|
||||
this._fillCenter = new CCVec2_1.CCVec2();
|
||||
this._fillStart = 0;
|
||||
this._fillRange = 0;
|
||||
this._isTrimmedMode = true;
|
||||
this._atlas = null;
|
||||
// 3.4.x
|
||||
this._visFlags = 0;
|
||||
// 3.4.x
|
||||
this._customMaterial = null;
|
||||
// 3.4.x
|
||||
this._color = new CCColor_1.CCColor(255, 255, 255, 255);
|
||||
// 3.4.x
|
||||
this._useGrayscale = false;
|
||||
}
|
||||
use9() {
|
||||
this._type = 1;
|
||||
this._sizeMode = 0;
|
||||
}
|
||||
updateWithLayer(psdLayer) {
|
||||
if (psdLayer.s9) {
|
||||
this.use9();
|
||||
}
|
||||
if (Math.abs(psdLayer.scale.x) != 1 || Math.abs(psdLayer.scale.y) != 1) {
|
||||
this._sizeMode = 0;
|
||||
}
|
||||
if (config_1.config.editorVersion >= EditorVersion_1.EditorVersion.v342) {
|
||||
this._srcBlendFactor = 2;
|
||||
this._dstBlendFactor = 4;
|
||||
}
|
||||
}
|
||||
setSpriteFrame(uuid) {
|
||||
if (config_1.config.editorVersion >= EditorVersion_1.EditorVersion.v342) {
|
||||
this._spriteFrame = { __uuid__: `${uuid}@f9941`, __expectedType__: "cc.SpriteFrame" };
|
||||
}
|
||||
else {
|
||||
this._spriteFrame = { __uuid__: uuid };
|
||||
}
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCSprite.prototype, "_materials", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCSprite.prototype, "_srcBlendFactor", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCSprite.prototype, "_dstBlendFactor", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCSprite.prototype, "_spriteFrame", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCSprite.prototype, "_type", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCSprite.prototype, "_sizeMode", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCSprite.prototype, "_fillType", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCSprite.prototype, "_fillCenter", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCSprite.prototype, "_fillStart", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCSprite.prototype, "_fillRange", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCSprite.prototype, "_isTrimmedMode", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCSprite.prototype, "_atlas", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCSprite.prototype, "_visFlags", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCSprite.prototype, "_customMaterial", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCSprite.prototype, "_color", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCSprite.prototype, "_useGrayscale", void 0);
|
||||
CCSprite = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.Sprite")
|
||||
], CCSprite);
|
||||
exports.CCSprite = CCSprite;
|
@ -1,75 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCToggle = void 0;
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const CCButton_1 = require("./CCButton");
|
||||
const CCSprite_1 = require("./CCSprite");
|
||||
let CCToggle = class CCToggle extends CCButton_1.CCButton {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
// 2.4.x
|
||||
this._N$isChecked = true;
|
||||
// 2.4.x
|
||||
this.toggleGroup = null;
|
||||
// 2.4.x
|
||||
this.checkMark = null;
|
||||
this.checkEvents = [];
|
||||
// 3.4.x
|
||||
this._isChecked = true;
|
||||
// 3.4.x
|
||||
this._checkMark = null;
|
||||
}
|
||||
setCheckMark(sprite) {
|
||||
this._checkMark = this.checkMark = {
|
||||
__id__: sprite.idx
|
||||
};
|
||||
}
|
||||
updateWithLayer(psdLayer) {
|
||||
if (!psdLayer.children) {
|
||||
console.error(`CCToggle-> 只能作用在 组图层 上`);
|
||||
return;
|
||||
}
|
||||
outer: for (let i = 0; i < psdLayer.children.length; i++) {
|
||||
const child = psdLayer.children[i];
|
||||
if (child.attr.comps.check) {
|
||||
let node = child.uiObject;
|
||||
for (let j = 0; j < node.components.length; j++) {
|
||||
const comp = node.components[j];
|
||||
if (comp instanceof CCSprite_1.CCSprite) {
|
||||
this.setCheckMark(comp);
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCToggle.prototype, "_N$isChecked", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCToggle.prototype, "toggleGroup", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v249)
|
||||
], CCToggle.prototype, "checkMark", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.all)
|
||||
], CCToggle.prototype, "checkEvents", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCToggle.prototype, "_isChecked", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCToggle.prototype, "_checkMark", void 0);
|
||||
CCToggle = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.Toggle")
|
||||
], CCToggle);
|
||||
exports.CCToggle = CCToggle;
|
@ -1,28 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCUIOpacity = void 0;
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const CCComponent_1 = require("./CCComponent");
|
||||
// 3.4.x
|
||||
let CCUIOpacity = class CCUIOpacity extends CCComponent_1.CCComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this._opacity = 255;
|
||||
}
|
||||
updateWithLayer(psdLayer) {
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCUIOpacity.prototype, "_opacity", void 0);
|
||||
CCUIOpacity = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.UIOpacity")
|
||||
], CCUIOpacity);
|
||||
exports.CCUIOpacity = CCUIOpacity;
|
@ -1,34 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCUITransform = void 0;
|
||||
const EditorVersion_1 = require("../../EditorVersion");
|
||||
const _decorator_1 = require("../../_decorator");
|
||||
const CCComponent_1 = require("./CCComponent");
|
||||
const CCSize_1 = require("./values/CCSize");
|
||||
const CCVec2_1 = require("./values/CCVec2");
|
||||
// 3.4.x
|
||||
let CCUITransform = class CCUITransform extends CCComponent_1.CCComponent {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this._contentSize = new CCSize_1.CCSize();
|
||||
this._anchorPoint = new CCVec2_1.CCVec2(0, 0);
|
||||
}
|
||||
updateWithLayer(psdLayer) {
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCUITransform.prototype, "_contentSize", void 0);
|
||||
__decorate([
|
||||
(0, _decorator_1.ccversion)(EditorVersion_1.EditorVersion.v342)
|
||||
], CCUITransform.prototype, "_anchorPoint", void 0);
|
||||
CCUITransform = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.UITransform")
|
||||
], CCUITransform);
|
||||
exports.CCUITransform = CCUITransform;
|
@ -1,11 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCColor = void 0;
|
||||
const Color_1 = require("../../../values/Color");
|
||||
class CCColor extends Color_1.Color {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.__type__ = "cc.Color";
|
||||
}
|
||||
}
|
||||
exports.CCColor = CCColor;
|
@ -1,21 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCSize = void 0;
|
||||
const Size_1 = require("../../../values/Size");
|
||||
const _decorator_1 = require("../../../_decorator");
|
||||
let CCSize = class CCSize extends Size_1.Size {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.__type__ = "cc.Size";
|
||||
}
|
||||
};
|
||||
CCSize = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.Size")
|
||||
], CCSize);
|
||||
exports.CCSize = CCSize;
|
@ -1,37 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCTypedArray = void 0;
|
||||
const _decorator_1 = require("../../../_decorator");
|
||||
let CCTypedArray = class CCTypedArray {
|
||||
constructor() {
|
||||
this.__type__ = "TypedArray";
|
||||
this.ctor = "Float64Array";
|
||||
this.array = [];
|
||||
}
|
||||
setPosition(x, y, z) {
|
||||
this.array[0] = x;
|
||||
this.array[1] = y;
|
||||
this.array[2] = z;
|
||||
}
|
||||
setRotation(x, y, z, w) {
|
||||
this.array[3] = x;
|
||||
this.array[4] = y;
|
||||
this.array[5] = z;
|
||||
this.array[6] = w;
|
||||
}
|
||||
setScale(x, y, z) {
|
||||
this.array[7] = x;
|
||||
this.array[8] = y;
|
||||
this.array[9] = z;
|
||||
}
|
||||
};
|
||||
CCTypedArray = __decorate([
|
||||
(0, _decorator_1.cctype)("TypedArray")
|
||||
], CCTypedArray);
|
||||
exports.CCTypedArray = CCTypedArray;
|
@ -1,21 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCVec2 = void 0;
|
||||
const Vec2_1 = require("../../../values/Vec2");
|
||||
const _decorator_1 = require("../../../_decorator");
|
||||
let CCVec2 = class CCVec2 extends Vec2_1.Vec2 {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.__type__ = "cc.Vec2";
|
||||
}
|
||||
};
|
||||
CCVec2 = __decorate([
|
||||
(0, _decorator_1.cctype)("cc.Vec2")
|
||||
], CCVec2);
|
||||
exports.CCVec2 = CCVec2;
|
@ -1,11 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CCVec3 = void 0;
|
||||
const Vec3_1 = require("../../../values/Vec3");
|
||||
class CCVec3 extends Vec3_1.Vec3 {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.__type__ = "cc.Vec3";
|
||||
}
|
||||
}
|
||||
exports.CCVec3 = CCVec3;
|
File diff suppressed because one or more lines are too long
@ -1,10 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.LayerType = void 0;
|
||||
var LayerType;
|
||||
(function (LayerType) {
|
||||
LayerType[LayerType["Doc"] = 0] = "Doc";
|
||||
LayerType[LayerType["Group"] = 1] = "Group";
|
||||
LayerType[LayerType["Text"] = 2] = "Text";
|
||||
LayerType[LayerType["Image"] = 3] = "Image";
|
||||
})(LayerType = exports.LayerType || (exports.LayerType = {}));
|
@ -1,39 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PsdDocument = void 0;
|
||||
const Rect_1 = require("../values/Rect");
|
||||
const Size_1 = require("../values/Size");
|
||||
const PsdGroup_1 = require("./PsdGroup");
|
||||
class PsdDocument extends PsdGroup_1.PsdGroup {
|
||||
constructor(source) {
|
||||
super(source, null, null);
|
||||
/** 当前文档所有的图片 */
|
||||
this.images = new Map();
|
||||
this.objectMap = new Map();
|
||||
this.objectArray = [];
|
||||
this.size = new Size_1.Size(source.width, source.height);
|
||||
this.rect = new Rect_1.Rect(0, this.size.width, 0, this.size.height);
|
||||
}
|
||||
pushObject(uiObject) {
|
||||
let idx = this.objectArray.length;
|
||||
uiObject.idx = idx;
|
||||
this.objectMap.set(uiObject.uuid, idx);
|
||||
this.objectArray.push(uiObject);
|
||||
return idx;
|
||||
}
|
||||
getObjectIdx(uuid) {
|
||||
let idx = this.objectMap.get(uuid);
|
||||
return idx;
|
||||
}
|
||||
getObject(uuid) {
|
||||
let idx = this.objectMap.get(uuid);
|
||||
if (idx < this.objectArray.length) {
|
||||
return this.objectArray[idx];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
onCtor() {
|
||||
super.onCtor();
|
||||
}
|
||||
}
|
||||
exports.PsdDocument = PsdDocument;
|
@ -1,44 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PsdGroup = void 0;
|
||||
const Rect_1 = require("../values/Rect");
|
||||
const PsdLayer_1 = require("./PsdLayer");
|
||||
class PsdGroup extends PsdLayer_1.PsdLayer {
|
||||
constructor(source, parent, rootDoc) {
|
||||
super(source, parent, rootDoc);
|
||||
this.children = [];
|
||||
if (rootDoc) {
|
||||
this.rect = new Rect_1.Rect(0, rootDoc.size.width, 0, rootDoc.size.height);
|
||||
}
|
||||
}
|
||||
parseSource() {
|
||||
var _a;
|
||||
super.parseSource();
|
||||
if (!((_a = this.attr) === null || _a === void 0 ? void 0 : _a.comps.full)) {
|
||||
this.resize();
|
||||
this.computeBasePosition();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
resize() {
|
||||
let left = Number.MAX_SAFE_INTEGER;
|
||||
let right = Number.MIN_SAFE_INTEGER;
|
||||
let top = Number.MAX_SAFE_INTEGER;
|
||||
let bottom = Number.MIN_SAFE_INTEGER;
|
||||
for (let i = 0; i < this.children.length; i++) {
|
||||
const element = this.children[i];
|
||||
let _rect = element.rect;
|
||||
left = Math.min(_rect.left, left);
|
||||
right = Math.max(_rect.right, right);
|
||||
top = Math.min(_rect.top, top);
|
||||
bottom = Math.max(_rect.bottom, bottom);
|
||||
}
|
||||
this.rect.left = left;
|
||||
this.rect.right = right;
|
||||
this.rect.top = top;
|
||||
this.rect.bottom = bottom;
|
||||
}
|
||||
onCtor() {
|
||||
}
|
||||
}
|
||||
exports.PsdGroup = PsdGroup;
|
@ -1,75 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PsdImage = void 0;
|
||||
const PsdLayer_1 = require("./PsdLayer");
|
||||
const Utils_1 = require("../utils/Utils");
|
||||
const Texture9Utils_1 = require("../utils/Texture9Utils");
|
||||
const Size_1 = require("../values/Size");
|
||||
const FileUtils_1 = require("../utils/FileUtils");
|
||||
const Vec3_1 = require("../values/Vec3");
|
||||
class PsdImage extends PsdLayer_1.PsdLayer {
|
||||
constructor(source, parent, rootDoc) {
|
||||
var _a;
|
||||
super(source, parent, rootDoc);
|
||||
this.textureUuid = Utils_1.utils.uuid();
|
||||
// img name
|
||||
this.imgName = ((_a = this.attr.comps.img) === null || _a === void 0 ? void 0 : _a.name) || this.name;
|
||||
// .9
|
||||
if (this.attr.comps['.9']) {
|
||||
let s9 = this.attr.comps['.9'];
|
||||
this.s9 = Texture9Utils_1.Texture9Utils.safeBorder(s9);
|
||||
let newCanvas = Texture9Utils_1.Texture9Utils.split(this.source.canvas, s9);
|
||||
this.source.canvas = newCanvas;
|
||||
}
|
||||
let canvas = this.source.canvas;
|
||||
this.imgBuffer = canvas.toBuffer('image/png');
|
||||
this.md5 = FileUtils_1.fileUtils.getMD5(this.imgBuffer);
|
||||
this.textureSize = new Size_1.Size(canvas.width, canvas.height);
|
||||
this.scale = new Vec3_1.Vec3((this.isFilpX() ? -1 : 1) * this.scale.x, (this.isFilpY() ? -1 : 1) * this.scale.y, 1);
|
||||
}
|
||||
onCtor() {
|
||||
}
|
||||
isIgnore() {
|
||||
//
|
||||
if (this.attr.comps.ignore || this.attr.comps.ignoreimg) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/** 是否是镜像图片 */
|
||||
isBind() {
|
||||
var _a, _b;
|
||||
return typeof ((_a = this.attr.comps.flip) === null || _a === void 0 ? void 0 : _a.bind) !== 'undefined'
|
||||
|| typeof ((_b = this.attr.comps.img) === null || _b === void 0 ? void 0 : _b.bind) !== 'undefined';
|
||||
}
|
||||
/** 是否是 x 方向镜像图片 */
|
||||
isFilpX() {
|
||||
var _a;
|
||||
return typeof ((_a = this.attr.comps.flipX) === null || _a === void 0 ? void 0 : _a.bind) !== 'undefined';
|
||||
}
|
||||
/** 是否是 y 方向镜像图片 */
|
||||
isFilpY() {
|
||||
var _a;
|
||||
return typeof ((_a = this.attr.comps.flipY) === null || _a === void 0 ? void 0 : _a.bind) !== 'undefined';
|
||||
}
|
||||
// 根据锚点计算坐标
|
||||
updatePositionWithAR() {
|
||||
if (!this.parent) {
|
||||
return;
|
||||
}
|
||||
let parent = this.parent;
|
||||
while (parent) {
|
||||
this.position.x -= parent.position.x;
|
||||
this.position.y -= parent.position.y;
|
||||
parent = parent.parent;
|
||||
}
|
||||
// this.position.x = this.position.x - this.parent.size.width * this.parent.anchorPoint.x + this.size.width * this.anchorPoint.x;
|
||||
// this.position.y = this.position.y - this.parent.size.height * this.parent.anchorPoint.y + this.size.height * this.anchorPoint.y;
|
||||
// 如果是镜像图片,则特殊处理
|
||||
let arX = (this.isFilpX() ? (1 - this.anchorPoint.x) : this.anchorPoint.x);
|
||||
let arY = (this.isFilpY() ? (1 - this.anchorPoint.y) : this.anchorPoint.y);
|
||||
this.position.x = this.position.x - this.rootDoc.size.width * this.rootDoc.anchorPoint.x + this.size.width * arX;
|
||||
this.position.y = this.position.y - this.rootDoc.size.height * this.rootDoc.anchorPoint.y + this.size.height * arY;
|
||||
}
|
||||
}
|
||||
exports.PsdImage = PsdImage;
|
@ -1,185 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PsdLayer = void 0;
|
||||
const Size_1 = require("../values/Size");
|
||||
const Vec2_1 = require("../values/Vec2");
|
||||
const Utils_1 = require("../utils/Utils");
|
||||
const Rect_1 = require("../values/Rect");
|
||||
const Color_1 = require("../values/Color");
|
||||
const Vec3_1 = require("../values/Vec3");
|
||||
class PsdLayer {
|
||||
constructor(source, parent, rootDoc) {
|
||||
var _a, _b, _c, _d;
|
||||
this.uuid = Utils_1.utils.uuid();
|
||||
this.source = source;
|
||||
this.parent = parent;
|
||||
this.rootDoc = rootDoc;
|
||||
this.name = source.name;
|
||||
this.position = new Vec2_1.Vec2();
|
||||
this.size = new Size_1.Size();
|
||||
this.rect = new Rect_1.Rect(source);
|
||||
// this.anchorPoint = new Vec2();
|
||||
this.anchorPoint = new Vec2_1.Vec2(0.5, 0.5);
|
||||
this.hidden = false;
|
||||
this.opacity = 255;
|
||||
this.color = new Color_1.Color(255, 255, 255, 255);
|
||||
console.log(`PsdLayer->解析到图层 `, this.name);
|
||||
this.attr = this.parseNameRule(this.name);
|
||||
// // 更新名字
|
||||
this.name = ((_a = this.attr) === null || _a === void 0 ? void 0 : _a.name) || this.name;
|
||||
// 使用配置的缩放系数
|
||||
let _scale = (_b = this.attr) === null || _b === void 0 ? void 0 : _b.comps.scale;
|
||||
this.scale = new Vec3_1.Vec3((_c = _scale === null || _scale === void 0 ? void 0 : _scale.x) !== null && _c !== void 0 ? _c : 1, (_d = _scale === null || _scale === void 0 ? void 0 : _scale.y) !== null && _d !== void 0 ? _d : 1, 1);
|
||||
}
|
||||
parseNameRule(name) {
|
||||
var _a, _b;
|
||||
if (!name) {
|
||||
return;
|
||||
}
|
||||
name = name.trim();
|
||||
let fragments = name.split("@");
|
||||
if (fragments.length === 0) {
|
||||
console.error(`PsdLayer-> 名字解析错误`);
|
||||
return;
|
||||
}
|
||||
let obj = {
|
||||
name: (_b = (_a = fragments[0]) === null || _a === void 0 ? void 0 : _a.replace(/\.|>|\/|\ /g, "_")) !== null && _b !== void 0 ? _b : "unknow",
|
||||
comps: {},
|
||||
};
|
||||
for (let i = 1; i < fragments.length; i++) {
|
||||
const fragment = fragments[i].trim();
|
||||
let attr = {};
|
||||
let startIdx = fragment.indexOf("{");
|
||||
let comp = fragment;
|
||||
if (startIdx != -1) {
|
||||
let endIdx = fragment.indexOf("}");
|
||||
if (endIdx == -1) {
|
||||
console.log(`PsdLayer->${name} 属性 解析错误`);
|
||||
continue;
|
||||
}
|
||||
let attrStr = fragment.substring(startIdx + 1, endIdx);
|
||||
comp = fragment.substr(0, startIdx);
|
||||
attrStr = attrStr.trim();
|
||||
let attrs = attrStr.split(",");
|
||||
attrs.forEach((str) => {
|
||||
str = str.trim();
|
||||
let strs = str.split(":");
|
||||
if (!strs.length) {
|
||||
console.log(`PsdLayer->${name} 属性 解析错误`);
|
||||
return;
|
||||
}
|
||||
strs.map((v) => {
|
||||
return v.trim();
|
||||
});
|
||||
attr[strs[0]] = Utils_1.utils.isNumber(strs[1]) ? parseFloat(strs[1]) : strs[1];
|
||||
});
|
||||
}
|
||||
comp = comp.trim();
|
||||
comp = comp.replace(":", ""); // 防呆,删除 key 中的冒号,
|
||||
obj.comps[comp] = attr;
|
||||
}
|
||||
// 获取别名的值
|
||||
obj.comps.ignore = obj.comps.ignore || obj.comps.ig;
|
||||
obj.comps.ignorenode = obj.comps.ignorenode || obj.comps.ignode;
|
||||
obj.comps.ignoreimg = obj.comps.ignoreimg || obj.comps.igimg;
|
||||
obj.comps.Btn = obj.comps.Btn || obj.comps.btn;
|
||||
obj.comps.ProgressBar = obj.comps.ProgressBar || obj.comps.progressBar;
|
||||
obj.comps.Toggle = obj.comps.Toggle || obj.comps.toggle;
|
||||
// obj.comps.position = obj.comps.position || obj.comps.pos;
|
||||
// 将mirror filpX filpY 进行合并
|
||||
if (obj.comps.flip || obj.comps.flipX || obj.comps.flipY) {
|
||||
obj.comps.flip = Object.assign({}, obj.comps.flip, obj.comps.flipX, obj.comps.flipY);
|
||||
if (obj.comps.flipX) {
|
||||
obj.comps.flip.x = 1;
|
||||
}
|
||||
if (obj.comps.flipY) {
|
||||
obj.comps.flip.y = 1;
|
||||
}
|
||||
// x,y 都缺省时,默认 x 方向镜像
|
||||
if (typeof obj.comps.flip.bind !== 'undefined') {
|
||||
if (!obj.comps.flip.y) {
|
||||
obj.comps.flip.x = 1;
|
||||
}
|
||||
// 只有作为镜像图片使用的时候才反向赋值
|
||||
// 反向赋值,防止使用的时候值错误
|
||||
if (obj.comps.flip.x) {
|
||||
obj.comps.flipX = Object.assign({}, obj.comps.flipX, obj.comps.flip);
|
||||
}
|
||||
if (obj.comps.flip.y) {
|
||||
obj.comps.flipY = Object.assign({}, obj.comps.flipY, obj.comps.flip);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 检查冲突
|
||||
if (obj.comps.full && obj.comps.size) {
|
||||
console.warn(`PsdLayer->${obj.name} 同时存在 @full 和 @size`);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
/** 解析数据 */
|
||||
parseSource() {
|
||||
var _a, _b;
|
||||
let _source = this.source;
|
||||
// psd文档
|
||||
if (!this.parent) {
|
||||
return false;
|
||||
}
|
||||
this.hidden = _source.hidden;
|
||||
this.opacity = Math.round(_source.opacity * 255);
|
||||
// 获取锚点
|
||||
let ar = this.attr.comps.ar;
|
||||
if (ar) {
|
||||
this.anchorPoint.x = (_a = ar.x) !== null && _a !== void 0 ? _a : this.anchorPoint.x;
|
||||
this.anchorPoint.y = (_b = ar.y) !== null && _b !== void 0 ? _b : this.anchorPoint.y;
|
||||
}
|
||||
this.computeBasePosition();
|
||||
return true;
|
||||
}
|
||||
/** 解析 effect */
|
||||
parseEffects() {
|
||||
// 颜色叠加 暂时搞不定
|
||||
// if(this.source.effects?.solidFill){
|
||||
// let solidFills = this.source.effects?.solidFill;
|
||||
// for (let i = 0; i < solidFills.length; i++) {
|
||||
// const solidFill = solidFills[i];
|
||||
// if(solidFill.enabled){
|
||||
// let color = solidFill.color;
|
||||
// this.color = new Color(color.r,color.g,color.b,solidFill.opacity * 255);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
// 计算初始坐标 左下角 0,0 为锚点
|
||||
computeBasePosition() {
|
||||
if (!this.rootDoc) {
|
||||
return;
|
||||
}
|
||||
let _rect = this.rect;
|
||||
let width = (_rect.right - _rect.left);
|
||||
let height = (_rect.bottom - _rect.top);
|
||||
this.size.width = width;
|
||||
this.size.height = height;
|
||||
// 位置 左下角为锚点
|
||||
let x = _rect.left;
|
||||
let y = (this.rootDoc.size.height - _rect.bottom);
|
||||
this.position.x = x;
|
||||
this.position.y = y;
|
||||
}
|
||||
// 根据锚点计算坐标
|
||||
updatePositionWithAR() {
|
||||
if (!this.parent) {
|
||||
return;
|
||||
}
|
||||
let parent = this.parent;
|
||||
while (parent) {
|
||||
this.position.x -= parent.position.x;
|
||||
this.position.y -= parent.position.y;
|
||||
parent = parent.parent;
|
||||
}
|
||||
// this.position.x = this.position.x - this.parent.size.width * this.parent.anchorPoint.x + this.size.width * this.anchorPoint.x;
|
||||
// this.position.y = this.position.y - this.parent.size.height * this.parent.anchorPoint.y + this.size.height * this.anchorPoint.y;
|
||||
this.position.x = this.position.x - this.rootDoc.size.width * this.rootDoc.anchorPoint.x + this.size.width * this.anchorPoint.x;
|
||||
this.position.y = this.position.y - this.rootDoc.size.height * this.rootDoc.anchorPoint.y + this.size.height * this.anchorPoint.y;
|
||||
}
|
||||
}
|
||||
exports.PsdLayer = PsdLayer;
|
@ -1,57 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PsdText = void 0;
|
||||
const config_1 = require("../config");
|
||||
const Color_1 = require("../values/Color");
|
||||
const PsdLayer_1 = require("./PsdLayer");
|
||||
class PsdText extends PsdLayer_1.PsdLayer {
|
||||
parseSource() {
|
||||
super.parseSource();
|
||||
let textSource = this.source.text;
|
||||
let style = textSource.style;
|
||||
if (style) {
|
||||
let fillColor = style.fillColor;
|
||||
if (fillColor) {
|
||||
this.color = new Color_1.Color(fillColor.r, fillColor.g, fillColor.b, fillColor.a * 255);
|
||||
}
|
||||
}
|
||||
this.text = textSource.text;
|
||||
this.fontSize = style.fontSize;
|
||||
this.offsetY = config_1.config.textOffsetY[this.fontSize] || config_1.config.textOffsetY["default"] || 0;
|
||||
this.parseSolidFill();
|
||||
this.parseStroke();
|
||||
return true;
|
||||
}
|
||||
onCtor() {
|
||||
}
|
||||
/** 描边 */
|
||||
parseStroke() {
|
||||
var _a, _b;
|
||||
if ((_a = this.source.effects) === null || _a === void 0 ? void 0 : _a.stroke) {
|
||||
let stroke = (_b = this.source.effects) === null || _b === void 0 ? void 0 : _b.stroke[0];
|
||||
// 外描边
|
||||
if ((stroke === null || stroke === void 0 ? void 0 : stroke.enabled) && (stroke === null || stroke === void 0 ? void 0 : stroke.position) === "outside") {
|
||||
let color = stroke.color;
|
||||
this.outline = {
|
||||
width: stroke.size.value,
|
||||
color: new Color_1.Color(color.r, color.g, color.b, stroke.opacity * 255)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
/** 解析 颜色叠加 */
|
||||
parseSolidFill() {
|
||||
var _a, _b;
|
||||
if ((_a = this.source.effects) === null || _a === void 0 ? void 0 : _a.solidFill) {
|
||||
let solidFills = (_b = this.source.effects) === null || _b === void 0 ? void 0 : _b.solidFill;
|
||||
for (let i = 0; i < solidFills.length; i++) {
|
||||
const solidFill = solidFills[i];
|
||||
if (solidFill.enabled) {
|
||||
let color = solidFill.color;
|
||||
this.color = new Color_1.Color(color.r, color.g, color.b, solidFill.opacity * 255);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.PsdText = PsdText;
|
@ -1,122 +0,0 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.fileUtils = void 0;
|
||||
const fs_extra_1 = __importDefault(require("fs-extra"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const crypto_1 = __importDefault(require("crypto"));
|
||||
class FileUtils {
|
||||
// 深度遍历
|
||||
DFS(root, callback, depth = 0) {
|
||||
let exists = fs_extra_1.default.existsSync(root);
|
||||
if (!exists) {
|
||||
console.log(`FileUtils-> ${root} is not exists`);
|
||||
return;
|
||||
}
|
||||
let files = fs_extra_1.default.readdirSync(root);
|
||||
let _cacheDepth = depth;
|
||||
depth++;
|
||||
files.forEach((file) => {
|
||||
let fullPath = path_1.default.join(root, file);
|
||||
let stat = fs_extra_1.default.lstatSync(fullPath);
|
||||
let isDirectory = stat.isDirectory();
|
||||
callback === null || callback === void 0 ? void 0 : callback({ isDirectory, fullPath, fileName: file, depth: _cacheDepth });
|
||||
if (!isDirectory) {
|
||||
}
|
||||
else {
|
||||
this.DFS(fullPath, callback, depth);
|
||||
}
|
||||
});
|
||||
}
|
||||
filterFile(root, filter) {
|
||||
let exists = fs_extra_1.default.existsSync(root);
|
||||
if (!exists) {
|
||||
console.log(`FileUtils-> ${root} is not exists`);
|
||||
return;
|
||||
}
|
||||
var res = [];
|
||||
let files = fs_extra_1.default.readdirSync(root);
|
||||
files.forEach((file) => {
|
||||
let pathName = path_1.default.join(root, file);
|
||||
let stat = fs_extra_1.default.lstatSync(pathName);
|
||||
let isDirectory = stat.isDirectory();
|
||||
// 只对文件进行判断
|
||||
if (!isDirectory) {
|
||||
let isPass = filter(file);
|
||||
if (!isPass) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!isDirectory) {
|
||||
res.push(pathName);
|
||||
}
|
||||
else {
|
||||
res = res.concat(this.filterFile(pathName, filter));
|
||||
}
|
||||
});
|
||||
return res;
|
||||
}
|
||||
getFolderFiles(dir, type) {
|
||||
let exists = fs_extra_1.default.existsSync(dir);
|
||||
if (!exists) {
|
||||
console.log(`FileUtils-> ${dir} is not exists`);
|
||||
return;
|
||||
}
|
||||
let res = [];
|
||||
let files = fs_extra_1.default.readdirSync(dir);
|
||||
files.forEach((file) => {
|
||||
let fullPath = path_1.default.join(dir, file);
|
||||
let stat = fs_extra_1.default.lstatSync(fullPath);
|
||||
let isDirectory = stat.isDirectory();
|
||||
if (isDirectory) {
|
||||
if (type === 'folder') {
|
||||
res.push({ fullPath, basename: file });
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (type === 'file') {
|
||||
res.push({ fullPath, basename: file });
|
||||
}
|
||||
}
|
||||
});
|
||||
return res;
|
||||
}
|
||||
writeFile(fullPath, data) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (typeof data !== 'string') {
|
||||
try {
|
||||
data = JSON.stringify(data, null, 2);
|
||||
}
|
||||
catch (error) {
|
||||
console.log(`FileUtils->writeFile `, error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
console.log(`写入文件 ${fullPath}`);
|
||||
let dir = path_1.default.dirname(fullPath);
|
||||
yield fs_extra_1.default.mkdirp(dir);
|
||||
yield fs_extra_1.default.writeFile(fullPath, data);
|
||||
console.log(`写入完成 ${fullPath} `);
|
||||
});
|
||||
}
|
||||
/** 获取文件的 md5 */
|
||||
getMD5(buffer) {
|
||||
if (typeof buffer === 'string') {
|
||||
buffer = fs_extra_1.default.readFileSync(buffer);
|
||||
}
|
||||
let md5 = crypto_1.default.createHash("md5").update(buffer).digest("hex");
|
||||
return md5;
|
||||
}
|
||||
}
|
||||
exports.fileUtils = new FileUtils();
|
@ -1,37 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Texture9Utils = void 0;
|
||||
const canvas_1 = __importDefault(require("canvas"));
|
||||
class Texture9Utils {
|
||||
static safeBorder(border) {
|
||||
border.l = border.l || border.r || 0;
|
||||
border.r = border.r || border.l || 0;
|
||||
border.t = border.t || border.b || 0;
|
||||
border.b = border.b || border.t || 0;
|
||||
return border;
|
||||
}
|
||||
static split(_canvas, border) {
|
||||
this.safeBorder(border);
|
||||
let cw = _canvas.width;
|
||||
let ch = _canvas.height;
|
||||
let left = border.l || cw;
|
||||
let right = border.r || cw;
|
||||
let top = border.t || ch;
|
||||
let bottom = border.b || ch;
|
||||
let newCanvas = canvas_1.default.createCanvas((border.l + border.r) || cw, (border.b + border.t) || ch);
|
||||
let ctx = newCanvas.getContext("2d");
|
||||
// 左上
|
||||
ctx.drawImage(_canvas, 0, 0, left, top, 0, 0, left, top);
|
||||
// 左下
|
||||
ctx.drawImage(_canvas, 0, ch - top, left, bottom, 0, top, left, bottom);
|
||||
// 右上
|
||||
ctx.drawImage(_canvas, cw - left, 0, right, top, left, 0, right, top);
|
||||
// 右下
|
||||
ctx.drawImage(_canvas, cw - left, ch - top, right, bottom, left, top, right, bottom);
|
||||
return newCanvas;
|
||||
}
|
||||
}
|
||||
exports.Texture9Utils = Texture9Utils;
|
@ -1,80 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.utils = void 0;
|
||||
// ------------decode-uuid
|
||||
const BASE64_KEYS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
||||
const values = new Array(123); // max char code in base64Keys
|
||||
for (let i = 0; i < 123; ++i) {
|
||||
values[i] = 64;
|
||||
} // fill with placeholder('=') index
|
||||
for (let i = 0; i < 64; ++i) {
|
||||
values[BASE64_KEYS.charCodeAt(i)] = i;
|
||||
}
|
||||
// decoded value indexed by base64 char code
|
||||
const BASE64_VALUES = values;
|
||||
const HexChars = '0123456789abcdef'.split('');
|
||||
const _t = ['', '', '', ''];
|
||||
const UuidTemplate = _t.concat(_t, '-', _t, '-', _t, '-', _t, '-', _t, _t, _t);
|
||||
const Indices = UuidTemplate.map((x, i) => x === '-' ? NaN : i).filter(isFinite);
|
||||
let HexMap = {};
|
||||
{
|
||||
for (let i = 0; i < HexChars.length; i++) {
|
||||
let char = HexChars[i];
|
||||
HexMap[char] = i;
|
||||
}
|
||||
}
|
||||
class Utils {
|
||||
uuid() {
|
||||
var d = new Date().getTime();
|
||||
if (globalThis.performance && typeof globalThis.performance.now === "function") {
|
||||
d += performance.now(); //use high-precision timer if available
|
||||
}
|
||||
var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
||||
var r = (d + Math.random() * 16) % 16 | 0;
|
||||
d = Math.floor(d / 16);
|
||||
return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
|
||||
});
|
||||
return uuid;
|
||||
}
|
||||
decodeUuid(base64) {
|
||||
const strs = base64.split('@');
|
||||
const uuid = strs[0];
|
||||
if (uuid.length !== 22) {
|
||||
return base64;
|
||||
}
|
||||
UuidTemplate[0] = base64[0];
|
||||
UuidTemplate[1] = base64[1];
|
||||
for (let i = 2, j = 2; i < 22; i += 2) {
|
||||
const lhs = BASE64_VALUES[base64.charCodeAt(i)];
|
||||
const rhs = BASE64_VALUES[base64.charCodeAt(i + 1)];
|
||||
UuidTemplate[Indices[j++]] = HexChars[lhs >> 2];
|
||||
UuidTemplate[Indices[j++]] = HexChars[((lhs & 3) << 2) | rhs >> 4];
|
||||
UuidTemplate[Indices[j++]] = HexChars[rhs & 0xF];
|
||||
}
|
||||
return base64.replace(uuid, UuidTemplate.join(''));
|
||||
}
|
||||
// 压缩uuid
|
||||
compressUuid(fullUuid) {
|
||||
const strs = fullUuid.split('@');
|
||||
const uuid = strs[0];
|
||||
if (uuid.length !== 36) {
|
||||
return fullUuid;
|
||||
}
|
||||
let zipUuid = [];
|
||||
zipUuid[0] = uuid[0];
|
||||
zipUuid[1] = uuid[1];
|
||||
let cleanUuid = uuid.replace('-', '').replace('-', '').replace('-', '').replace('-', '');
|
||||
for (let i = 2, j = 2; i < 32; i += 3) {
|
||||
const left = HexMap[String.fromCharCode(cleanUuid.charCodeAt(i))];
|
||||
const mid = HexMap[String.fromCharCode(cleanUuid.charCodeAt(i + 1))];
|
||||
const right = HexMap[String.fromCharCode(cleanUuid.charCodeAt(i + 2))];
|
||||
zipUuid[j++] = BASE64_KEYS[(left << 2) + (mid >> 2)];
|
||||
zipUuid[j++] = BASE64_KEYS[((mid & 3) << 4) + right];
|
||||
}
|
||||
return fullUuid.replace(uuid, zipUuid.join(''));
|
||||
}
|
||||
isNumber(val) {
|
||||
return (!isNaN(parseFloat(val)) && isFinite(val));
|
||||
}
|
||||
}
|
||||
exports.utils = new Utils();
|
@ -1,95 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UuidUtils = void 0;
|
||||
var Uuid = require('node-uuid');
|
||||
var Base64KeyChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
var AsciiTo64 = new Array(128);
|
||||
for (var i = 0; i < 128; ++i) {
|
||||
AsciiTo64[i] = 0;
|
||||
}
|
||||
for (i = 0; i < 64; ++i) {
|
||||
AsciiTo64[Base64KeyChars.charCodeAt(i)] = i;
|
||||
}
|
||||
var Reg_Dash = /-/g;
|
||||
var Reg_Uuid = /^[0-9a-fA-F-]{36}$/;
|
||||
var Reg_NormalizedUuid = /^[0-9a-fA-F]{32}$/;
|
||||
var Reg_CompressedUuid = /^[0-9a-zA-Z+/]{22,23}$/;
|
||||
class UuidUtils {
|
||||
// 压缩后的 uuid 可以减小保存时的尺寸,但不能做为文件名(因为无法区分大小写并且包含非法字符)。
|
||||
// 默认将 uuid 的后面 27 位压缩成 18 位,前 5 位保留下来,方便调试。
|
||||
// fc991dd7-0033-4b80-9d41-c8a86a702e59 -> fc9913XADNLgJ1ByKhqcC5Z
|
||||
// 如果启用 min 则将 uuid 的后面 30 位压缩成 20 位,前 2 位保留不变。
|
||||
// fc991dd7-0033-4b80-9d41-c8a86a702e59 -> fcmR3XADNLgJ1ByKhqcC5Z
|
||||
/*
|
||||
* @param {Boolean} [min=false]
|
||||
*/
|
||||
static compressUuid(uuid, min) {
|
||||
if (Reg_Uuid.test(uuid)) {
|
||||
uuid = uuid.replace(Reg_Dash, '');
|
||||
}
|
||||
else if (!Reg_NormalizedUuid.test(uuid)) {
|
||||
return uuid;
|
||||
}
|
||||
var reserved = (min === true) ? 2 : 5;
|
||||
return UuidUtils.compressHex(uuid, reserved);
|
||||
}
|
||||
static compressHex(hexString, reservedHeadLength) {
|
||||
var length = hexString.length;
|
||||
var i;
|
||||
if (typeof reservedHeadLength !== 'undefined') {
|
||||
i = reservedHeadLength;
|
||||
}
|
||||
else {
|
||||
i = length % 3;
|
||||
}
|
||||
var head = hexString.slice(0, i);
|
||||
var base64Chars = [];
|
||||
while (i < length) {
|
||||
var hexVal1 = parseInt(hexString[i], 16);
|
||||
var hexVal2 = parseInt(hexString[i + 1], 16);
|
||||
var hexVal3 = parseInt(hexString[i + 2], 16);
|
||||
base64Chars.push(Base64KeyChars[(hexVal1 << 2) | (hexVal2 >> 2)]);
|
||||
base64Chars.push(Base64KeyChars[((hexVal2 & 3) << 4) | hexVal3]);
|
||||
i += 3;
|
||||
}
|
||||
return head + base64Chars.join('');
|
||||
}
|
||||
static decompressUuid(str) {
|
||||
if (str.length === 23) {
|
||||
// decode base64
|
||||
var hexChars = [];
|
||||
for (var i = 5; i < 23; i += 2) {
|
||||
var lhs = AsciiTo64[str.charCodeAt(i)];
|
||||
var rhs = AsciiTo64[str.charCodeAt(i + 1)];
|
||||
hexChars.push((lhs >> 2).toString(16));
|
||||
hexChars.push((((lhs & 3) << 2) | rhs >> 4).toString(16));
|
||||
hexChars.push((rhs & 0xF).toString(16));
|
||||
}
|
||||
//
|
||||
str = str.slice(0, 5) + hexChars.join('');
|
||||
}
|
||||
else if (str.length === 22) {
|
||||
// decode base64
|
||||
var hexChars = [];
|
||||
for (var i = 2; i < 22; i += 2) {
|
||||
var lhs = AsciiTo64[str.charCodeAt(i)];
|
||||
var rhs = AsciiTo64[str.charCodeAt(i + 1)];
|
||||
hexChars.push((lhs >> 2).toString(16));
|
||||
hexChars.push((((lhs & 3) << 2) | rhs >> 4).toString(16));
|
||||
hexChars.push((rhs & 0xF).toString(16));
|
||||
}
|
||||
//
|
||||
str = str.slice(0, 2) + hexChars.join('');
|
||||
}
|
||||
return [str.slice(0, 8), str.slice(8, 12), str.slice(12, 16), str.slice(16, 20), str.slice(20)].join('-');
|
||||
}
|
||||
static isUuid(str) {
|
||||
return Reg_CompressedUuid.test(str) || Reg_NormalizedUuid.test(str) || Reg_Uuid.test(str);
|
||||
}
|
||||
static uuid() {
|
||||
var uuid = Uuid.v4();
|
||||
return UuidUtils.compressUuid(uuid, true);
|
||||
}
|
||||
}
|
||||
exports.UuidUtils = UuidUtils;
|
||||
;
|
@ -1,37 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Color = void 0;
|
||||
class Color {
|
||||
constructor(r, g, b, a) {
|
||||
this.r = Math.ceil(r || 0);
|
||||
this.g = Math.ceil(g || 0);
|
||||
this.b = Math.ceil(b || 0);
|
||||
this.a = Math.ceil(a || 0);
|
||||
}
|
||||
set(color) {
|
||||
this.r = Math.ceil(color.r || 0);
|
||||
this.g = Math.ceil(color.g || 0);
|
||||
this.b = Math.ceil(color.b || 0);
|
||||
this.a = Math.ceil(color.a || 0);
|
||||
}
|
||||
toHEX(fmt = '#rrggbb') {
|
||||
const prefix = '0';
|
||||
// #rrggbb
|
||||
const hex = [
|
||||
(this.r < 16 ? prefix : '') + (this.r).toString(16),
|
||||
(this.g < 16 ? prefix : '') + (this.g).toString(16),
|
||||
(this.b < 16 ? prefix : '') + (this.b).toString(16),
|
||||
];
|
||||
const i = -1;
|
||||
if (fmt === '#rgb') {
|
||||
hex[0] = hex[0][0];
|
||||
hex[1] = hex[1][0];
|
||||
hex[2] = hex[2][0];
|
||||
}
|
||||
else if (fmt === '#rrggbbaa') {
|
||||
hex.push((this.a < 16 ? prefix : '') + (this.a).toString(16));
|
||||
}
|
||||
return hex.join('');
|
||||
}
|
||||
}
|
||||
exports.Color = Color;
|
@ -1,22 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Rect = void 0;
|
||||
class Rect {
|
||||
constructor(left = 0, right = 0, top = 0, bottom = 0) {
|
||||
if (typeof left == 'object') {
|
||||
this.set(left);
|
||||
return;
|
||||
}
|
||||
this.left = left || 0;
|
||||
this.right = right || 0;
|
||||
this.top = top || 0;
|
||||
this.bottom = bottom || 0;
|
||||
}
|
||||
set(rect) {
|
||||
this.left = rect.left;
|
||||
this.right = rect.right;
|
||||
this.top = rect.top;
|
||||
this.bottom = rect.bottom;
|
||||
}
|
||||
}
|
||||
exports.Rect = Rect;
|
@ -1,10 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Size = void 0;
|
||||
class Size {
|
||||
constructor(width = 0, height = 0) {
|
||||
this.width = width || 0;
|
||||
this.height = height || 0;
|
||||
}
|
||||
}
|
||||
exports.Size = Size;
|
@ -1,10 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Vec2 = void 0;
|
||||
class Vec2 {
|
||||
constructor(x = 0, y = 0) {
|
||||
this.x = x || 0;
|
||||
this.y = y || 0;
|
||||
}
|
||||
}
|
||||
exports.Vec2 = Vec2;
|
@ -1,11 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Vec3 = void 0;
|
||||
class Vec3 {
|
||||
constructor(x = 0, y = 0, z = 0) {
|
||||
this.x = x || 0;
|
||||
this.y = y || 0;
|
||||
this.z = z || 0;
|
||||
}
|
||||
}
|
||||
exports.Vec3 = Vec3;
|
11
ccc-tnt-psd2ui-v3.4.+/package-lock.json
generated
11
ccc-tnt-psd2ui-v3.4.+/package-lock.json
generated
@ -12,6 +12,7 @@
|
||||
"canvas": "^2.11.0",
|
||||
"fs-extra": "^10.1.0",
|
||||
"minimist": "^1.2.7",
|
||||
"pinyin-pro": "^3.16.0",
|
||||
"vue": "^3.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
@ -679,6 +680,11 @@
|
||||
"resolved": "https://registry.npmmirror.com/picocolors/-/picocolors-1.0.0.tgz",
|
||||
"integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ=="
|
||||
},
|
||||
"node_modules/pinyin-pro": {
|
||||
"version": "3.16.0",
|
||||
"resolved": "https://registry.npmmirror.com/pinyin-pro/-/pinyin-pro-3.16.0.tgz",
|
||||
"integrity": "sha512-U4pMQ/KSMM5JmSb+ZcReCIbgzGl/JaglaHqWjCli0hpA0rDdjRbAO67e6fOa3ZFcJzbqfe6bJkaMMmpiWmkXgQ=="
|
||||
},
|
||||
"node_modules/postcss": {
|
||||
"version": "8.4.20",
|
||||
"resolved": "https://registry.npmmirror.com/postcss/-/postcss-8.4.20.tgz",
|
||||
@ -1445,6 +1451,11 @@
|
||||
"resolved": "https://registry.npmmirror.com/picocolors/-/picocolors-1.0.0.tgz",
|
||||
"integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ=="
|
||||
},
|
||||
"pinyin-pro": {
|
||||
"version": "3.16.0",
|
||||
"resolved": "https://registry.npmmirror.com/pinyin-pro/-/pinyin-pro-3.16.0.tgz",
|
||||
"integrity": "sha512-U4pMQ/KSMM5JmSb+ZcReCIbgzGl/JaglaHqWjCli0hpA0rDdjRbAO67e6fOa3ZFcJzbqfe6bJkaMMmpiWmkXgQ=="
|
||||
},
|
||||
"postcss": {
|
||||
"version": "8.4.20",
|
||||
"resolved": "https://registry.npmmirror.com/postcss/-/postcss-8.4.20.tgz",
|
||||
|
@ -9,6 +9,7 @@
|
||||
"canvas": "^2.11.0",
|
||||
"fs-extra": "^10.1.0",
|
||||
"minimist": "^1.2.7",
|
||||
"pinyin-pro": "^3.16.0",
|
||||
"vue": "^3.1.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
@ -53,12 +53,14 @@ export const methods: { [key: string]: (...any: any) => any } = {
|
||||
let files = param.files;
|
||||
let isForceImg = param.isForceImg;
|
||||
let isImgOnly = param.isImgOnly;
|
||||
let output = param.output
|
||||
let output = param.output;
|
||||
let isPinyin = param.isPinyin;
|
||||
|
||||
let options = {
|
||||
"project-assets": projectAssets,
|
||||
"cache": cacheFile,
|
||||
"engine-version": ENGINE_VER,
|
||||
"pinyin": isPinyin,
|
||||
}
|
||||
|
||||
let tasks: Promise<void>[] = [];
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user