Commit db960913 authored by wjf's avatar wjf

l

parent 436e3050
...@@ -444,7 +444,8 @@ export namespace RES { ...@@ -444,7 +444,8 @@ export namespace RES {
//@ts-ignore //@ts-ignore
var data: SkinInt = typeof (skin) == 'string' ? getSkinDataByName(skin) : skin; var data: SkinInt = typeof (skin) == 'string' ? getSkinDataByName(skin) : skin;
if (!data.children || !data.children.length) return; if (!data.children || !data.children.length) return;
for (var i = data.children.length - 1; i >= 0; i--) { // for (var i = data.children.length - 1; i >= 0; i--) {
for (var i = 0; i < data.children.length; i++) {
var child = data.children[i]; var child = data.children[i];
if (child.type == "skin") continue; if (child.type == "skin") continue;
var dis = con.addChild(getDisplayByData(child)); var dis = con.addChild(getDisplayByData(child));
......
var fs = require("fs");
var iconv = require('iconv-lite');
//读取json文件
var data = iconv.decode(fs.readFileSync("./resource/skin.json"), "utf-8");//GBK
//反序列化
data = JSON.parse(data); //eval(data)
reverseChildren(data);
const outJsonData = JSON.stringify(data, "", "\t");
var endPath = './src/';
var endFile = `export const SkinJson = ${outJsonData}`
fs.writeFileSync(endPath + "SkinJson.ts", endFile);
/**
*
* @param {*} arr
*/
function reverseChildren(arr) {
arr.children.reverse();
arr.children.forEach(element => { if (element.children && element.children.length) reverseChildren(element) });
}
\ No newline at end of file
...@@ -3,7 +3,7 @@ var PSD = require('psd'); ...@@ -3,7 +3,7 @@ var PSD = require('psd');
var path = require('path'); var path = require('path');
// const mkdirp = require('mkdirp'); // const mkdirp = require('mkdirp');
//千万别再执行,否则覆盖 //千万别再执行,否则覆盖
// return return
var options = { var options = {
//导出图片的目录,没有就导在psd所在目录 //导出图片的目录,没有就导在psd所在目录
outImgDir: "./resource/", outImgDir: "./resource/",
...@@ -50,6 +50,8 @@ files.forEach(async function (psdFileName) { ...@@ -50,6 +50,8 @@ files.forEach(async function (psdFileName) {
} else { } else {
const groupName = rootNode._children[i].name; const groupName = rootNode._children[i].name;
//颠倒一下
// group111._children.reverse()
queueNodes.push(group111._children); queueNodes.push(group111._children);
queueNodesIndex.push(0); queueNodesIndex.push(0);
queueNodesName.push(undefined); queueNodesName.push(undefined);
...@@ -113,6 +115,8 @@ files.forEach(async function (psdFileName) { ...@@ -113,6 +115,8 @@ files.forEach(async function (psdFileName) {
} }
//单纯的组 //单纯的组
else { else {
//颠倒一下
// node._children.reverse()
queueNodes.push(node._children); queueNodes.push(node._children);
queueNodesIndex[queueIndex] = nodesIndex; queueNodesIndex[queueIndex] = nodesIndex;
queueNodesIndex.push(0); queueNodesIndex.push(0);
...@@ -263,6 +267,8 @@ files.forEach(async function (psdFileName) { ...@@ -263,6 +267,8 @@ files.forEach(async function (psdFileName) {
//导出所有的数据 //导出所有的数据
if (options.outJsonDir) { if (options.outJsonDir) {
//倒转一下所有children的层级
const outJsonData = JSON.stringify(rootStructure/*.group*/, "", "\t"); const outJsonData = JSON.stringify(rootStructure/*.group*/, "", "\t");
const outJsonDirPath = path.resolve(options.outJsonDir); const outJsonDirPath = path.resolve(options.outJsonDir);
const outJsonPath = path.join(outJsonDirPath, 'skin.json'); const outJsonPath = path.join(outJsonDirPath, 'skin.json');
...@@ -300,3 +306,8 @@ function saveAsPng(dirName, name, node, format = "png") { ...@@ -300,3 +306,8 @@ function saveAsPng(dirName, name, node, format = "png") {
} }
function reverseChildren(arr) {
arr.reverse();
if (arr.children) reverseChildren(arr.children)
}
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment