remove bom

This commit is contained in:
zhl 2020-08-21 11:10:39 +08:00
parent d43212d300
commit b49fb14e91
7 changed files with 124 additions and 122 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
.wing/ .wing/
bin-debug/ bin-debug/
bin-release/ bin-release/
.idea/

View File

@ -23,7 +23,7 @@ function createWindow() {
win.loadURL("http://127.0.0.1:12346/index.html"); win.loadURL("http://127.0.0.1:12346/index.html");
// Open the DevTools. // Open the DevTools.
win.webContents.openDevTools(); // win.webContents.openDevTools();
// Emitted when the window is closed. // Emitted when the window is closed.
win.on('closed', () => { win.on('closed', () => {

View File

@ -1,4 +1,4 @@
echo 开始copy echo 开始copy
robocopy .\bin-release\web\r\js ..\..\release\avatertools\js /MIR robocopy .\bin-release\web\r\js ..\..\release\avatertools\js /MIR
robocopy .\bin-release\web\r\resource ..\..\release\avatertools\resource /MIR robocopy .\bin-release\web\r\resource ..\..\release\avatertools\resource /MIR

View File

@ -1,4 +1,4 @@
/** /**
* jQuery EasyUI 1.4.5 * jQuery EasyUI 1.4.5
* *
* Copyright (c) 2009-2016 www.jeasyui.com. All rights reserved. * Copyright (c) 2009-2016 www.jeasyui.com. All rights reserved.

View File

@ -6,7 +6,7 @@ class Main extends egret.DisplayObjectContainer {
protected dragDele: junyou.tools.DragDele; protected dragDele: junyou.tools.DragDele;
protected grid:grid.GridSprite; protected grid: grid.GridSprite;
private cPst: jgame.AniInfo; private cPst: jgame.AniInfo;
@ -14,10 +14,10 @@ class Main extends egret.DisplayObjectContainer {
public constructor() { public constructor() {
super(); super();
this.addEventListener(egret.Event.ADDED_TO_STAGE,this.onAddToStage,this); this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
window["saveCallback"] = this.saveCallback; window["saveCallback"] = this.saveCallback;
$(document).ready(() => { $(document).ready(() => {
$("#btnSave").on("click",this.saveCallback.bind(this)); $("#btnSave").on("click", this.saveCallback.bind(this));
}); });
} }
@ -25,28 +25,28 @@ class Main extends egret.DisplayObjectContainer {
let pst = this.cPst; let pst = this.cPst;
let frames = pst.frames; let frames = pst.frames;
let obj = {}; let obj = {};
for(let a in frames) { for (let a in frames) {
let aInfo = frames[a]; let aInfo = frames[a];
if(aInfo && aInfo.totalFrame) { if (aInfo && aInfo.totalFrame) {
let m = []; let m = [];
obj[a] = m; obj[a] = m;
let fs = []; let fs = [];
m[0] = fs; m[0] = fs;
if(aInfo.isCircle) { if (aInfo.isCircle) {
m[1] = 1; m[1] = 1;
} }
let aF = aInfo.frames; let aF = aInfo.frames;
let len = aF.length; let len = aF.length;
for(let i = 0;i < len;i++) { for (let i = 0; i < len; i++) {
let frame = aF[i]; let frame = aF[i];
let data: any[] = [+frame.a,+frame.f,+frame.t]; let data: any[] = [+frame.a, +frame.f, +frame.t];
if(frame.e || frame.d != -1) {//一般情况有事件的可能性多余有特定方向的所以先e后d if (frame.e || frame.d != -1) {//一般情况有事件的可能性多余有特定方向的所以先e后d
data.push(frame.e || 0); data.push(frame.e || 0);
if(frame.d != -1) { if (frame.d != -1) {
data.push(+frame.d); data.push(+frame.d);
} }
} }
fs[i]=data; fs[i] = data;
} }
} }
} }
@ -56,7 +56,7 @@ class Main extends egret.DisplayObjectContainer {
let require = window["nodeRequire"]; let require = window["nodeRequire"];
let fs = require("fs"); let fs = require("fs");
fs.writeFileSync(this.dataFile,JSON.stringify(rawData)); fs.writeFileSync(this.dataFile, JSON.stringify(rawData));
} }
private onAddToStage(event: egret.Event) { private onAddToStage(event: egret.Event) {
@ -68,11 +68,11 @@ class Main extends egret.DisplayObjectContainer {
let sh = this.stage.stageHeight; let sh = this.stage.stageHeight;
let hh = sh >> 1; let hh = sh >> 1;
let hw = sw >> 1; let hw = sw >> 1;
g.lineStyle(1,0xff0000); g.lineStyle(1, 0xff0000);
g.moveTo(0,hh); g.moveTo(0, hh);
g.lineTo(sw,hh); g.lineTo(sw, hh);
g.moveTo(hw,0); g.moveTo(hw, 0);
g.lineTo(hw,sh); g.lineTo(hw, sh);
this.grid = new grid.GridSprite(); this.grid = new grid.GridSprite();
this.addChild(this.grid); this.addChild(this.grid);
@ -80,22 +80,22 @@ class Main extends egret.DisplayObjectContainer {
this.dragDele = new junyou.tools.DragDele; this.dragDele = new junyou.tools.DragDele;
this.addChild(this.dragDele); this.addChild(this.dragDele);
this.addChild(sp); this.addChild(sp);
window.addEventListener("dragover",e => { window.addEventListener("dragover", e => {
e.preventDefault(); e.preventDefault();
return false return false
}); });
window.addEventListener("drop",async(e) => { window.addEventListener("drop", async (e) => {
e.preventDefault(); e.preventDefault();
let goted = this.checkFile(e.dataTransfer.files); let goted = this.checkFile(e.dataTransfer.files);
if(goted) { // 一定是 Electron 环境才能取到值 if (goted) { // 一定是 Electron 环境才能取到值
// 加载数据 // 加载数据
let require = window["nodeRequire"]; let require = window["nodeRequire"];
let path = require("path"); let path = require("path");
let fs = require("fs"); let fs = require("fs");
let str = fs.readFileSync(goted.data,"utf8"); let str = fs.readFileSync(goted.data, "utf8");
let data = JSON.parse(str); let data = JSON.parse(str);
let rawData = JSON.parse(str); let rawData = JSON.parse(str);
let aniRender = new jgame.AniRender(); let aniRender = new jgame.AniRender();
@ -108,20 +108,20 @@ class Main extends egret.DisplayObjectContainer {
// let bmd = egret.$toBitmapData(img); // let bmd = egret.$toBitmapData(img);
let bmd = new egret.Bitmap(); let bmd = new egret.Bitmap();
await tools.readImageSync(goted.img, bmd); await tools.readImageSync(goted.img, bmd);
pst.init(goted.key,data,bmd.$bitmapData); pst.init(goted.key, data, bmd.$bitmapData);
pst.rawData = rawData; pst.rawData = rawData;
aniRender._aniInfo = pst; aniRender._aniInfo = pst;
let chkCircle = $("#chkCircle"); let chkCircle = $("#chkCircle");
chkCircle.removeAttr("disabled"); chkCircle.removeAttr("disabled");
pst.actionInfo.isCircle ? chkCircle.attr("checked","checked") : chkCircle.removeAttr("checked"); pst.actionInfo.isCircle ? chkCircle.attr("checked", "checked") : chkCircle.removeAttr("checked");
chkCircle.on("change",(e) => { chkCircle.on("change", (e) => {
pst.actionInfo.isCircle = chkCircle[0]["checked"]; pst.actionInfo.isCircle = chkCircle[0]["checked"];
}); });
let dis = new jgame.ResourceBitmap; let dis = new jgame.ResourceBitmap;
aniRender.display = dis; aniRender.display = dis;
dis.res = pst.getResource(); dis.res = pst.getResource();
aniRender.play(); aniRender.play();
this.dragDele.setStartPoint(hw,hh); this.dragDele.setStartPoint(hw, hh);
this.dragDele.aniInfo = pst; this.dragDele.aniInfo = pst;
this.dataFile = goted.data; this.dataFile = goted.data;
this.dragDele.addChild(dis); this.dragDele.addChild(dis);
@ -137,9 +137,9 @@ class Main extends egret.DisplayObjectContainer {
protected addRender(aniRender: jgame.AniRender) { protected addRender(aniRender: jgame.AniRender) {
let old = this.currentRender; let old = this.currentRender;
if(old) { if (old) {
let dis = old.display; let dis = old.display;
if(dis.parent) { if (dis.parent) {
dis.parent.removeChild(dis); dis.parent.removeChild(dis);
} }
old.onRecycle(); old.onRecycle();
@ -147,7 +147,7 @@ class Main extends egret.DisplayObjectContainer {
this.currentRender = aniRender; this.currentRender = aniRender;
let pst = aniRender._aniInfo; let pst = aniRender._aniInfo;
let dg = $('#dg'); let dg = $('#dg');
dg["datagrid"]('loadData',pst.frames[0].frames); dg["datagrid"]('loadData', pst.frames[0].frames);
} }
@ -155,7 +155,7 @@ class Main extends egret.DisplayObjectContainer {
* *
* @param files * @param files
*/ */
private checkFile(files: FileArray,parent: string = "") { private checkFile(files: FileArray, parent: string = "") {
// 先检查 pdir中的数据 // 先检查 pdir中的数据
// let v; // let v;
// try{ // try{
@ -170,9 +170,9 @@ class Main extends egret.DisplayObjectContainer {
// } // }
// let imgReg = new RegExp(v.image[0]); // let imgReg = new RegExp(v.image[0]);
// let cfgReg = new RegExp(v.config[0]); // let cfgReg = new RegExp(v.config[0]);
let path,fs; let path, fs;
let require = window["nodeRequire"]; let require = window["nodeRequire"];
if(typeof require === "function") { //是Electron环境 if (typeof require === "function") { //是Electron环境
path = require("path"); path = require("path");
fs = require("fs"); fs = require("fs");
} }
@ -181,37 +181,37 @@ class Main extends egret.DisplayObjectContainer {
let img = null; let img = null;
let data = null; let data = null;
// 遍历文件,检查文件是否匹配 // 遍历文件,检查文件是否匹配
for(let i = 0,len = files.length;i < len;i++) { for (let i = 0, len = files.length; i < len; i++) {
let file = files[i]; let file = files[i];
if(path) { // 如果是Electron环境 if (path) { // 如果是Electron环境
let p: string; let p: string;
if(typeof file === "string") { if (typeof file === "string") {
p = path.join(parent,<string>file); p = path.join(parent, <string>file);
} }
else { else {
// 检查路径 // 检查路径
p = file["path"]; p = file["path"];
} }
p = p.replace(/\\/g,"/"); p = p.replace(/\\/g, "/");
let fstats = fs.statSync(p); let fstats = fs.statSync(p);
// 如果是文件夹 // 如果是文件夹
if(fstats.isDirectory()) { if (fstats.isDirectory()) {
goted = this.checkFile.call(this,fs.readdirSync(p),p); goted = this.checkFile.call(this, fs.readdirSync(p), p);
} else if(fstats.isFile()) {// 检查文件 } else if (fstats.isFile()) {// 检查文件
let re = path.parse(p); let re = path.parse(p);
if(re.ext == ".png") { if (re.ext == ".png") {
img = p; img = p;
} else if(re.base == "d.json") { } else if (re.base == "d.json") {
data = p; data = p;
} }
if(img && data) { if (img && data) {
// 得到上级目录 // 得到上级目录
let dirs = re.dir.split(path.sep); let dirs = re.dir.split(path.sep);
let key = dirs[dirs.length - 1]; let key = dirs[dirs.length - 1];
goted = { img: img,data: data,key: key }; goted = { img: img, data: data, key: key };
} }
} }
if(goted) { if (goted) {
return goted; return goted;
} }
} }

View File

@ -5,25 +5,25 @@ module junyou.game {
* *
*/ */
export class AniInfo extends PstInfo { export class AniInfo extends PstInfo {
public rawData:any[]; public rawData: any[];
public constructor() { public constructor() {
super(); super();
} }
public init(key: string,data: any[],bmd:egret.BitmapData) { public init(key: string, data: any[], bmd: egret.BitmapData) {
console.log(data); console.log(data);
super.init(key,data[0],bmd); super.init(key, data[0], bmd);
var res: UnitResource = new UnitResource(key,this.splitInfo,bmd); var res: UnitResource = new UnitResource(key, this.splitInfo, bmd);
res.decodeData(data[1]); res.decodeData(data[1]);
this._resources = res; this._resources = res;
}
getResource(uri:string=null):UnitResource{
return <UnitResource>this._resources;
} }
public get actionInfo(): ActionInfo{ getResource(uri: string = null): UnitResource {
return this.frames[0] return <UnitResource>this._resources;
}
public get actionInfo(): ActionInfo {
return this.frames[0]
} }
} }
} }

View File

@ -18,13 +18,13 @@ module junyou.game {
PAK_ONE_A_D = 4 PAK_ONE_A_D = 4
} }
var parsers: { [index: number]: { new (key: string): SplitInfo } }; var parsers: { [index: number]: { new(key: string): SplitInfo } };
/** /**
* *
*/ */
function getParsers(t: number): { new (key: string): SplitInfo } { function getParsers(t: number): { new(key: string): SplitInfo } {
if(!parsers) { if (!parsers) {
parsers = {}; parsers = {};
parsers[PakSaveType.PAK_BY_ACTION] = ActionSInfo; parsers[PakSaveType.PAK_BY_ACTION] = ActionSInfo;
parsers[PakSaveType.PAK_ONE_A_D] = OneADSInfo; parsers[PakSaveType.PAK_ONE_A_D] = OneADSInfo;
@ -36,7 +36,8 @@ module junyou.game {
/** /**
* pst信息 * pst信息
* *
*/ export class PstInfo { */
export class PstInfo {
/** /**
* <br/> * <br/>
* Key string key <br/> * Key string key <br/>
@ -62,7 +63,7 @@ module junyou.game {
} }
public init(key: string,data: any[],img: egret.BitmapData) { public init(key: string, data: any[], img: egret.BitmapData) {
this.key = key; this.key = key;
this._resources = {}; this._resources = {};
// var t = data[0]; // var t = data[0];
@ -123,8 +124,8 @@ module junyou.game {
*/ */
public parseFrameData(data: any[]): { [index: number]: ActionInfo } { public parseFrameData(data: any[]): { [index: number]: ActionInfo } {
var frames: { [index: number]: ActionInfo } = {}; var frames: { [index: number]: ActionInfo } = {};
for(let a in data) { for (let a in data) {
frames[a] = ActionInfo.fromData(data[a],a); frames[a] = ActionInfo.fromData(data[a], a);
} }
return frames; return frames;
} }
@ -142,11 +143,11 @@ module junyou.game {
* @param direction * @param direction
* @param action * @param action
*/ */
public getResource(direction: number,action: number): string { public getResource(direction: number, action: number): string {
return null; return null;
} }
public static getADKey(action: any,direction: number): number { public static getADKey(action: any, direction: number): number {
return action << 8 | direction; return action << 8 | direction;
} }
@ -165,17 +166,17 @@ module junyou.game {
*/ */
export class OneADSInfo extends SplitInfo { export class OneADSInfo extends SplitInfo {
public static _a = function() { public static _a = function () {
let a = []; let a = [];
function m(f: number,t: number) { function m(f: number, t: number) {
for(let i = f;i < t;i++) { for (let i = f; i < t; i++) {
a.push(String.fromCharCode(i)); a.push(String.fromCharCode(i));
} }
} }
m(97,122); m(97, 122);
m(65,90); m(65, 90);
return a; return a;
} (); }();
protected _n: string; protected _n: string;
protected _a: any[]; protected _a: any[];
@ -186,11 +187,11 @@ module junyou.game {
var _adDict: { [index: string]: number[] } = {}; var _adDict: { [index: string]: number[] } = {};
this.adDict = _adDict; this.adDict = _adDict;
var frames: { [index: number]: ActionInfo } = {}; var frames: { [index: number]: ActionInfo } = {};
for(let a in data) { for (let a in data) {
frames[a] = ActionInfo.fromData(data[a],a); frames[a] = ActionInfo.fromData(data[a], a);
for(let d = 0;d < 5;d++) { for (let d = 0; d < 5; d++) {
let res = this.getResource(d,a); let res = this.getResource(d, a);
_adDict[res] = [SplitInfo.getADKey(a,d)]; _adDict[res] = [SplitInfo.getADKey(a, d)];
} }
} }
return frames; return frames;
@ -202,18 +203,18 @@ module junyou.game {
this._d = infos["d"]; this._d = infos["d"];
} }
getResource(direction: number,action: any): string { getResource(direction: number, action: any): string {
let key = SplitInfo.getADKey(action,direction); let key = SplitInfo.getADKey(action, direction);
let res = this._resDict[key]; let res = this._resDict[key];
if(!res) { if (!res) {
this._resDict[key] = res = this._n.replace(/\{f\}/g,this._key).replace(/\{d\}/g,this.getRep(direction,this._d)).replace(/\{a\}/g,this.getRep(action,this._a)); this._resDict[key] = res = this._n.replace(/\{f\}/g, this._key).replace(/\{d\}/g, this.getRep(direction, this._d)).replace(/\{a\}/g, this.getRep(action, this._a));
} }
return res; return res;
} }
getRep(data: number,repArr: any[]): string { getRep(data: number, repArr: any[]): string {
var str = data + ""; var str = data + "";
if(repArr && (data in repArr)) { if (repArr && (data in repArr)) {
str = repArr[data]; str = repArr[data];
} }
return str; return str;
@ -227,7 +228,7 @@ module junyou.game {
parseSplitInfo(infos: any[]) { parseSplitInfo(infos: any[]) {
var flag = true; var flag = true;
if(infos) { if (infos) {
this._resDict = {}; this._resDict = {};
this._subReses = []; this._subReses = [];
var _adDict: { [index: string]: number[] } = {}; var _adDict: { [index: string]: number[] } = {};
@ -235,33 +236,33 @@ module junyou.game {
var _resDict = this._resDict; var _resDict = this._resDict;
var _subReses = this._subReses; var _subReses = this._subReses;
var len = infos.length; var len = infos.length;
for(let i = 0;i < len;i++) { for (let i = 0; i < len; i++) {
let pak = infos[i][0]; let pak = infos[i][0];
let acts = pak.a; let acts = pak.a;
if(acts) { if (acts) {
let dlen = acts.length; let dlen = acts.length;
if(dlen) { if (dlen) {
flag = false; flag = false;
let res = this.getFileName(pak); let res = this.getFileName(pak);
let arr = _adDict[res]; let arr = _adDict[res];
if(!arr) { if (!arr) {
arr = []; arr = [];
_adDict[res] = arr; _adDict[res] = arr;
} }
if(res && _subReses.indexOf(res) == -1) { if (res && _subReses.indexOf(res) == -1) {
_subReses.push(res); _subReses.push(res);
} }
for(let j = 0;j < dlen;j++) { for (let j = 0; j < dlen; j++) {
let a = acts[j]; let a = acts[j];
_resDict[a] = res; _resDict[a] = res;
//push所有动作的数据 //push所有动作的数据
arr.push(SplitInfo.getADKey(a,0),SplitInfo.getADKey(a,1),SplitInfo.getADKey(a,2),SplitInfo.getADKey(a,3),SplitInfo.getADKey(a,4)); arr.push(SplitInfo.getADKey(a, 0), SplitInfo.getADKey(a, 1), SplitInfo.getADKey(a, 2), SplitInfo.getADKey(a, 3), SplitInfo.getADKey(a, 4));
} }
} }
} }
} }
} }
if(flag) { if (flag) {
throw new Error("no pak split info"); throw new Error("no pak split info");
} }
} }
@ -272,7 +273,7 @@ module junyou.game {
return PakSaveType.PAK_BY_ACTION + "-" + dirs.join("_"); return PakSaveType.PAK_BY_ACTION + "-" + dirs.join("_");
} }
getResource(direction: number,action: number): string { getResource(direction: number, action: number): string {
return this._resDict[action]; return this._resDict[action];
} }
} }