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

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
.wing/
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");
// Open the DevTools.
win.webContents.openDevTools();
// win.webContents.openDevTools();
// Emitted when the window is 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\resource ..\..\release\avatertools\resource /MIR

View File

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

View File

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

View File

@ -1,5 +1,5 @@
module junyou.game {
/**
*
*/
@ -18,13 +18,13 @@ module junyou.game {
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 } {
if(!parsers) {
function getParsers(t: number): { new(key: string): SplitInfo } {
if (!parsers) {
parsers = {};
parsers[PakSaveType.PAK_BY_ACTION] = ActionSInfo;
parsers[PakSaveType.PAK_ONE_A_D] = OneADSInfo;
@ -32,23 +32,24 @@ module junyou.game {
}
return parsers[t];
}
/**
* pst信息
*
*/ export class PstInfo {
*/
export class PstInfo {
/**
* <br/>
* Key string key <br/>
* Value UnitResource<br/>
*/
protected _resources: { [index: string]: UnitResource } | UnitResource;
/**
* pst的唯一标识
*/
public key: string;
/**
* <br/>
* key {number} <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._resources = {};
// var t = data[0];
@ -75,27 +76,27 @@ module junyou.game {
}
}
/**
*
*/
export class SplitInfo {
/**
*
*/
protected _resDict: { [index: number]: string };
/**
*
*/
protected _subReses: string[];
/**
* key
*/
protected _key: string;
/**
* /<br/>
* key {string} uri<br/>
@ -104,7 +105,7 @@ module junyou.game {
*/
public adDict: { [index: string]: number[] };
/**
*
* @param data
@ -116,21 +117,21 @@ module junyou.game {
constructor(key: string) {
this._key = key;
}
/**
*
* @param data
*/
public parseFrameData(data: any[]): { [index: number]: ActionInfo } {
var frames: { [index: number]: ActionInfo } = {};
for(let a in data) {
frames[a] = ActionInfo.fromData(data[a],a);
for (let a in data) {
frames[a] = ActionInfo.fromData(data[a], a);
}
return frames;
}
/**
*
*/
@ -142,11 +143,11 @@ module junyou.game {
* @param direction
* @param action
*/
public getResource(direction: number,action: number): string {
public getResource(direction: number, action: number): string {
return null;
}
public static getADKey(action: any,direction: number): number {
public static getADKey(action: any, direction: number): number {
return action << 8 | direction;
}
@ -159,23 +160,23 @@ module junyou.game {
}
}
/**
*
*/
export class OneADSInfo extends SplitInfo {
public static _a = function() {
public static _a = function () {
let a = [];
function m(f: number,t: number) {
for(let i = f;i < t;i++) {
function m(f: number, t: number) {
for (let i = f; i < t; i++) {
a.push(String.fromCharCode(i));
}
}
m(97,122);
m(65,90);
m(97, 122);
m(65, 90);
return a;
} ();
}();
protected _n: string;
protected _a: any[];
@ -186,11 +187,11 @@ module junyou.game {
var _adDict: { [index: string]: number[] } = {};
this.adDict = _adDict;
var frames: { [index: number]: ActionInfo } = {};
for(let a in data) {
frames[a] = ActionInfo.fromData(data[a],a);
for(let d = 0;d < 5;d++) {
let res = this.getResource(d,a);
_adDict[res] = [SplitInfo.getADKey(a,d)];
for (let a in data) {
frames[a] = ActionInfo.fromData(data[a], a);
for (let d = 0; d < 5; d++) {
let res = this.getResource(d, a);
_adDict[res] = [SplitInfo.getADKey(a, d)];
}
}
return frames;
@ -202,24 +203,24 @@ module junyou.game {
this._d = infos["d"];
}
getResource(direction: number,action: any): string {
let key = SplitInfo.getADKey(action,direction);
getResource(direction: number, action: any): string {
let key = SplitInfo.getADKey(action, direction);
let res = this._resDict[key];
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));
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));
}
return res;
}
getRep(data: number,repArr: any[]): string {
getRep(data: number, repArr: any[]): string {
var str = data + "";
if(repArr && (data in repArr)) {
if (repArr && (data in repArr)) {
str = repArr[data];
}
return str;
}
}
/**
*
*/
@ -227,7 +228,7 @@ module junyou.game {
parseSplitInfo(infos: any[]) {
var flag = true;
if(infos) {
if (infos) {
this._resDict = {};
this._subReses = [];
var _adDict: { [index: string]: number[] } = {};
@ -235,33 +236,33 @@ module junyou.game {
var _resDict = this._resDict;
var _subReses = this._subReses;
var len = infos.length;
for(let i = 0;i < len;i++) {
for (let i = 0; i < len; i++) {
let pak = infos[i][0];
let acts = pak.a;
if(acts) {
if (acts) {
let dlen = acts.length;
if(dlen) {
if (dlen) {
flag = false;
let res = this.getFileName(pak);
let arr = _adDict[res];
if(!arr) {
if (!arr) {
arr = [];
_adDict[res] = arr;
}
if(res && _subReses.indexOf(res) == -1) {
if (res && _subReses.indexOf(res) == -1) {
_subReses.push(res);
}
for(let j = 0;j < dlen;j++) {
for (let j = 0; j < dlen; j++) {
let a = acts[j];
_resDict[a] = res;
//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");
}
}
@ -272,7 +273,7 @@ module junyou.game {
return PakSaveType.PAK_BY_ACTION + "-" + dirs.join("_");
}
getResource(direction: number,action: number): string {
getResource(direction: number, action: number): string {
return this._resDict[action];
}
}