From 3899c114afa8dea060451b6569868e1948f44340 Mon Sep 17 00:00:00 2001 From: John C Date: Sun, 3 Jul 2022 13:22:40 -0400 Subject: [PATCH 1/4] Added support for Solar2D exporting Added support for Solar2D (CoronaSDK) exporting with indexing value added. Conditional export coded for trimmed files requiring the extra variables: sourceX sourceY sourceWidth sourceHeight --- dist/web/static/exporters/Solar2D.mst | 48 +++++++++++++++++++ dist/web/static/js/index.js | 24 +++++++++- src/client/exporters/index.js | 14 +++--- src/client/exporters/list.json | 9 ++++ .../resources/static/exporters/Solar2D.mst | 48 +++++++++++++++++++ 5 files changed, 136 insertions(+), 7 deletions(-) create mode 100644 dist/web/static/exporters/Solar2D.mst create mode 100644 src/client/resources/static/exporters/Solar2D.mst diff --git a/dist/web/static/exporters/Solar2D.mst b/dist/web/static/exporters/Solar2D.mst new file mode 100644 index 0000000..645549d --- /dev/null +++ b/dist/web/static/exporters/Solar2D.mst @@ -0,0 +1,48 @@ +local SheetInfo = {} + +SheetInfo.sheet = +{ + frames = { + {{#rects}} + { + -- {{{name}}} + {{#trimmed}} + sourceX = {{spriteSourceSize.x}}, + sourceY = {{spriteSourceSize.y}}, + sourceWidth = {{spriteSourceSize.w}}, + sourceHeight = {{spriteSourceSize.h}}, + {{/trimmed}} + + x = {{frame.x}}, + y = {{frame.y}}, + width = {{frame.w}}, + height = {{frame.h}}, + }, + {{/rects}} + }, + + sheetContentWidth = {{config.imageWidth}}, + sheetContentHeight = {{config.imageHeight}} +} + + +SheetInfo.frameIndex = +{ + {{#rects}} + ["{{name}}"] = {{frame.index}}, + {{/rects}} +} + + +function SheetInfo:getSheet() + return self.sheet; +end + + +function SheetInfo:getFrameIndex(name) + return self.frameIndex[name]; +end + + +return SheetInfo + diff --git a/dist/web/static/js/index.js b/dist/web/static/js/index.js index 6bf4789..c55ac1f 100644 --- a/dist/web/static/js/index.js +++ b/dist/web/static/js/index.js @@ -7518,7 +7518,29 @@ module.exports = { /* 76 */ /***/ (function(module) { -module.exports = JSON.parse("[{\"lang\":\"en\",\"name\":\"english\"},{\"lang\":\"de\",\"name\":\"deutsch\"},{\"lang\":\"es\",\"name\":\"español\"},{\"lang\":\"ru\",\"name\":\"русский\"},{\"lang\":\"zh-cn\",\"name\":\"简体中文\"}]"); +//module.exports = JSON.parse("[{\"lang\":\"en\",\"name\":\"english\"},{\"lang\":\"de\",\"name\":\"deutsch\"},{\"lang\":\"es\",\"name\":\"español\"},{\"lang\":\"ru\",\"name\":\"русский\"},{\"lang\":\"zh-cn\",\"name\":\"简体中文\"}]"); +module.exports = JSON.parse( + "[{\"type\":\"JSON (hash)\",\"description\":\"Json hash\",\"allowTrim\":true,\"allowRotation\":true,\"template\":\"JsonHash.mst\",\"fileExt\":\"json\"},\ + {\"type\":\"JSON (array)\",\"description\":\"Json array\",\"allowTrim\":true,\"allowRotation\":true,\"template\":\"JsonArray.mst\",\"fileExt\":\"json\"},\ + {\"type\":\"XML\",\"description\":\"Plain XML format\",\"allowTrim\":true,\"allowRotation\":true,\"template\":\"XML.mst\",\"fileExt\":\"xml\"},\ + {\"type\":\"css (modern)\",\"description\":\"css format\",\"allowTrim\":true,\"allowRotation\":true,\"template\":\"Css.mst\",\"fileExt\":\"css\"},\ + {\"type\":\"css (old)\",\"description\":\"old css format\",\"allowTrim\":false,\"allowRotation\":false,\"template\":\"OldCss.mst\",\"fileExt\":\"css\"},\ + {\"type\":\"pixi.js\",\"description\":\"pixi.js format\",\"allowTrim\":true,\"allowRotation\":true,\"template\":\"JsonHash.mst\",\"fileExt\":\"json\"},\ + {\"type\":\"Godot (atlas)\",\"description\":\"Godot Atlas format\",\"allowTrim\":true,\"allowRotation\":true,\"template\":\"GodotAtlas.mst\",\"fileExt\":\"tpsheet\"},\ + {\"type\":\"Godot (tileset)\",\"description\":\"Godot Tileset format\",\"allowTrim\":true,\"allowRotation\":true,\"template\":\"GodotTileset.mst\",\"fileExt\":\"tpset\"},\ + {\"type\":\"Phaser (hash)\",\"description\":\"Phaser (json hash)\",\"allowTrim\":true,\"allowRotation\":true,\"template\":\"JsonHash.mst\",\"fileExt\":\"json\"},\ + {\"type\":\"Phaser (array)\",\"description\":\"Phaser (json array)\",\"allowTrim\":true,\"allowRotation\":true,\"template\":\"JsonArray.mst\",\"fileExt\":\"json\"},\ + {\"type\":\"Phaser 3\",\"description\":\"Phaser 3\",\"allowTrim\":true,\"allowRotation\":true,\"template\":\"Phaser3.mst\",\"fileExt\":\"json\"},\ + {\"type\":\"Spine\",\"description\":\"Spine atlas\",\"allowTrim\":true,\"allowRotation\":true,\"template\":\"Spine.mst\",\"fileExt\":\"atlas\"},\ + {\"type\":\"cocos2d\",\"description\":\"cocos2d format\",\"allowTrim\":true,\"allowRotation\":true,\"template\":\"Cocos2d.mst\",\"fileExt\":\"plist\"},\ + {\"type\":\"UnrealEngine\",\"description\":\"UnrealEngine - Paper2d\",\"allowTrim\":true,\"allowRotation\":true,\"template\":\"Unreal.mst\",\"fileExt\":\"paper2dsprites\"},\ + {\"type\":\"Starling\",\"description\":\"Starling format\",\"allowTrim\":true,\"allowRotation\":true,\"template\":\"Starling.mst\",\"fileExt\":\"xml\"},\ + {\"type\":\"UIKit\",\"description\":\"UIKit sprite sheet\",\"allowTrim\":true,\"allowRotation\":false,\"template\":\"UIKit.mst\",\"fileExt\":\"plist\",\"predefined\":true},\ + {\"type\":\"Unity3D\",\"description\":\"Unity3D sprite sheet\",\"allowTrim\":true,\"allowRotation\":false,\"template\":\"Unity3D.mst\",\"fileExt\":\"tpsheet\",\"predefined\":true},\ + {\"type\":\"Solar2D\",\"description\":\"Solar2D (CoronaSDK) sprite sheet\",\"allowTrim\":true,\"allowRotation\":false,\"template\":\"Solar2D.mst\",\"fileExt\":\"lua\",\"predefined\":true},\ + {\"type\":\"Egret2D\",\"description\":\"Egret2D sprite sheet\",\"allowTrim\":false,\"allowRotation\":false,\"template\":\"Egret2D.mst\",\"fileExt\":\"json\",\"predefined\":true},\ + {\"type\":\"custom\",\"description\":\"Custom format\",\"allowTrim\":true,\"allowRotation\":true,\"template\":\"\",\"fileExt\":\"\"}]" + ); /***/ }), /* 77 */ diff --git a/src/client/exporters/index.js b/src/client/exporters/index.js index 199e45c..bcf7960 100644 --- a/src/client/exporters/index.js +++ b/src/client/exporters/index.js @@ -62,6 +62,7 @@ function prepareData(data, options) { opt.base64Prefix = options.textureFormat === "png" ? "data:image/png;base64," : "data:image/jpeg;base64,"; let ret = []; + let frameIndex = 1; for(let item of data) { @@ -80,13 +81,13 @@ function prepareData(data, options) { if(!options.prependFolderName) { name = name.split("/").pop(); } - - let frame = {x: item.frame.x, y: item.frame.y, w: item.frame.w, h: item.frame.h, hw: item.frame.w/2, hh: item.frame.h/2}; + + let frame = { x: item.frame.x, y: item.frame.y, w: item.frame.w, h: item.frame.h, hw: item.frame.w / 2, hh: item.frame.h / 2, index: frameIndex }; let spriteSourceSize = {x: item.spriteSourceSize.x, y: item.spriteSourceSize.y, w: item.spriteSourceSize.w, h: item.spriteSourceSize.h}; let sourceSize = {w: item.sourceSize.w, h: item.sourceSize.h}; - - let trimmed = item.trimmed; - + + let trimmed = item.trimmed; + if(item.trimmed && options.trimMode === 'crop') { trimmed = false; spriteSourceSize.x = 0; @@ -94,7 +95,7 @@ function prepareData(data, options) { sourceSize.w = spriteSourceSize.w; sourceSize.h = spriteSourceSize.h; } - + if(opt.scale !== 1) { frame.x *= opt.scale; frame.y *= opt.scale; @@ -121,6 +122,7 @@ function prepareData(data, options) { trimmed: trimmed }); + frameIndex++; } if(ret.length) { diff --git a/src/client/exporters/list.json b/src/client/exporters/list.json index 6fb28a7..2959e5a 100644 --- a/src/client/exporters/list.json +++ b/src/client/exporters/list.json @@ -146,6 +146,15 @@ "fileExt": "json", "predefined": true }, + { + "type": "Solar2D", + "description": "Solar2D (CoronaSDK) sprite sheet", + "allowTrim": true, + "allowRotation": false, + "template": "Solar2D.mst", + "fileExt": "lua", + "predefined": true + }, { "type": "custom", "description": "Custom format", diff --git a/src/client/resources/static/exporters/Solar2D.mst b/src/client/resources/static/exporters/Solar2D.mst new file mode 100644 index 0000000..645549d --- /dev/null +++ b/src/client/resources/static/exporters/Solar2D.mst @@ -0,0 +1,48 @@ +local SheetInfo = {} + +SheetInfo.sheet = +{ + frames = { + {{#rects}} + { + -- {{{name}}} + {{#trimmed}} + sourceX = {{spriteSourceSize.x}}, + sourceY = {{spriteSourceSize.y}}, + sourceWidth = {{spriteSourceSize.w}}, + sourceHeight = {{spriteSourceSize.h}}, + {{/trimmed}} + + x = {{frame.x}}, + y = {{frame.y}}, + width = {{frame.w}}, + height = {{frame.h}}, + }, + {{/rects}} + }, + + sheetContentWidth = {{config.imageWidth}}, + sheetContentHeight = {{config.imageHeight}} +} + + +SheetInfo.frameIndex = +{ + {{#rects}} + ["{{name}}"] = {{frame.index}}, + {{/rects}} +} + + +function SheetInfo:getSheet() + return self.sheet; +end + + +function SheetInfo:getFrameIndex(name) + return self.frameIndex[name]; +end + + +return SheetInfo + From e8e9692401de3bc205d399d246bcd20054fdacc6 Mon Sep 17 00:00:00 2001 From: John C <75145117+jcbk101@users.noreply.github.com> Date: Tue, 5 Jul 2022 16:49:53 -0400 Subject: [PATCH 2/4] Solar2D support and fixes Fixed "sourceWidth and sourceHeight" values. Added feature to sort by filenames in ascending order. --- dist/web/static/exporters/Solar2D.mst | 48 ++++++++++++++++ dist/web/static/js/index.js | 14 ++++- dist/web/static/localization/de.csv | 2 + dist/web/static/localization/en.csv | 4 +- dist/web/static/localization/es.csv | 4 +- dist/web/static/localization/ru.csv | 4 +- dist/web/static/localization/zh-cn.csv | 4 +- electron/package.json | 14 ++--- package.json | 56 +++++++++---------- src/client/APP.js | 3 +- src/client/exporters/index.js | 34 +++++++++-- src/client/exporters/list.json | 9 +++ .../resources/static/exporters/Solar2D.mst | 48 ++++++++++++++++ .../resources/static/localization/de.csv | 2 + .../resources/static/localization/en.csv | 4 +- .../resources/static/localization/es.csv | 4 +- .../resources/static/localization/ru.csv | 4 +- .../resources/static/localization/zh-cn.csv | 4 +- src/client/ui/PackProperties.jsx | 11 ++++ 19 files changed, 222 insertions(+), 51 deletions(-) create mode 100644 dist/web/static/exporters/Solar2D.mst create mode 100644 src/client/resources/static/exporters/Solar2D.mst diff --git a/dist/web/static/exporters/Solar2D.mst b/dist/web/static/exporters/Solar2D.mst new file mode 100644 index 0000000..645549d --- /dev/null +++ b/dist/web/static/exporters/Solar2D.mst @@ -0,0 +1,48 @@ +local SheetInfo = {} + +SheetInfo.sheet = +{ + frames = { + {{#rects}} + { + -- {{{name}}} + {{#trimmed}} + sourceX = {{spriteSourceSize.x}}, + sourceY = {{spriteSourceSize.y}}, + sourceWidth = {{spriteSourceSize.w}}, + sourceHeight = {{spriteSourceSize.h}}, + {{/trimmed}} + + x = {{frame.x}}, + y = {{frame.y}}, + width = {{frame.w}}, + height = {{frame.h}}, + }, + {{/rects}} + }, + + sheetContentWidth = {{config.imageWidth}}, + sheetContentHeight = {{config.imageHeight}} +} + + +SheetInfo.frameIndex = +{ + {{#rects}} + ["{{name}}"] = {{frame.index}}, + {{/rects}} +} + + +function SheetInfo:getSheet() + return self.sheet; +end + + +function SheetInfo:getFrameIndex(name) + return self.frameIndex[name]; +end + + +return SheetInfo + diff --git a/dist/web/static/js/index.js b/dist/web/static/js/index.js index 6bf4789..6fc33c4 100644 --- a/dist/web/static/js/index.js +++ b/dist/web/static/js/index.js @@ -49913,7 +49913,8 @@ function () { prependFolderName: this.packOptions.prependFolderName, base64Export: this.packOptions.base64Export, scale: this.packOptions.scale, - trimMode: this.packOptions.trimMode + trimMode: this.packOptions.trimMode, + sortByName: this.packOptions.sortByName }; _context.prev = 33; _context.t1 = files; @@ -51499,6 +51500,7 @@ function (_React$Component) { data.alphaThreshold = data.alphaThreshold || 0; data.detectIdentical = data.detectIdentical === undefined ? true : data.detectIdentical; data.packer = getPackerByType(data.packer) ? data.packer : packers[0].type; + data.sortByName = data.sortByName === undefined ? true : data.sortByName; var methodValid = false; var packer = getPackerByType(data.packer); var packerMethods = Object.keys(packer.methods); @@ -51559,6 +51561,7 @@ function (_React$Component) { data.detectIdentical = react_dom_default.a.findDOMNode(this.refs.detectIdentical).checked; data.packer = react_dom_default.a.findDOMNode(this.refs.packer).value; data.packerMethod = react_dom_default.a.findDOMNode(this.refs.packerMethod).value; + data.sortByName = react_dom_default.a.findDOMNode(this.refs.sortByName).checked; this.packOptions = this.applyOptionsDefaults(data); } }, { @@ -51589,6 +51592,7 @@ function (_React$Component) { react_dom_default.a.findDOMNode(this.refs.detectIdentical).checked = this.packOptions.detectIdentical; react_dom_default.a.findDOMNode(this.refs.packer).value = this.packOptions.packer; react_dom_default.a.findDOMNode(this.refs.packerMethod).value = this.packOptions.packerMethod; + react_dom_default.a.findDOMNode(this.refs.sortByName).checked = this.packOptions.sortByName; } }, { key: "getPackOptions", @@ -51935,6 +51939,14 @@ function (_React$Component) { packer: this.state.packer, defaultMethod: this.packOptions.packerMethod, handler: this.onPropChanged + })), react_default.a.createElement("td", null)), react_default.a.createElement("tr", { + title: utils_I18.f("SORT_BY_NAME_TITLE") + }, react_default.a.createElement("td", null, utils_I18.f("SORT_BY_NAME")), react_default.a.createElement("td", null, react_default.a.createElement("input", { + ref: "sortByName", + type: "checkbox", + className: "border-color-gray", + onChange: this.onPropChanged, + defaultChecked: sortByName ? "checked" : "" })), react_default.a.createElement("td", null)))))); } }], [{ diff --git a/dist/web/static/localization/de.csv b/dist/web/static/localization/de.csv index 7b76079..e890462 100644 --- a/dist/web/static/localization/de.csv +++ b/dist/web/static/localization/de.csv @@ -137,3 +137,5 @@ SELECT_DATA_FILE;Daten-Datei SPLITTER;Sprites aus Bild extrahieren SPLITTER_ERROR_NO_FRAMES;Sprites wurden nicht gefunden. Vermutlich ist das Atlas Format falsch. HOLD_TRIM;Trim beibehalten: +SORT_BY_NAME_TITLE;Sort file list by name. +SORT_BY_NAME;Sort files by name: \ No newline at end of file diff --git a/dist/web/static/localization/en.csv b/dist/web/static/localization/en.csv index c485dc0..bed25a5 100644 --- a/dist/web/static/localization/en.csv +++ b/dist/web/static/localization/en.csv @@ -137,4 +137,6 @@ SELECT_TEXTURE;Texture SELECT_DATA_FILE;Data file SPLITTER;Split sheet SPLITTER_ERROR_NO_FRAMES;Sprites not found. Probably, atlas format is incorrect. -HOLD_TRIM;Hold trim: \ No newline at end of file +HOLD_TRIM;Hold trim: +SORT_BY_NAME_TITLE;Sort file list by name. +SORT_BY_NAME;Sort files by name: \ No newline at end of file diff --git a/dist/web/static/localization/es.csv b/dist/web/static/localization/es.csv index c57b446..bbc6e5a 100644 --- a/dist/web/static/localization/es.csv +++ b/dist/web/static/localization/es.csv @@ -137,4 +137,6 @@ SELECT_TEXTURE;Textura SELECT_DATA_FILE;Datos SPLITTER;Desembalaje atlas SPLITTER_ERROR_NO_FRAMES;No se ha encontrado ningún sprite. Quizás el formato del atlas sea incorrecto. -HOLD_TRIM;Mantener corte: \ No newline at end of file +HOLD_TRIM;Mantener corte: +SORT_BY_NAME_TITLE;Sort file list by name. +SORT_BY_NAME;Sort files by name: \ No newline at end of file diff --git a/dist/web/static/localization/ru.csv b/dist/web/static/localization/ru.csv index 0232bba..06803f4 100644 --- a/dist/web/static/localization/ru.csv +++ b/dist/web/static/localization/ru.csv @@ -137,4 +137,6 @@ SELECT_TEXTURE;Текстура SELECT_DATA_FILE;Данные SPLITTER;Распаковка атласа SPLITTER_ERROR_NO_FRAMES;Не найдено ни одного спрайта. Возможно, формат атласа неверен. -HOLD_TRIM;Обрезать: \ No newline at end of file +HOLD_TRIM;Обрезать: +SORT_BY_NAME_TITLE;Sort file list by name. +SORT_BY_NAME;Sort files by name: \ No newline at end of file diff --git a/dist/web/static/localization/zh-cn.csv b/dist/web/static/localization/zh-cn.csv index 07b1d17..62c1932 100644 --- a/dist/web/static/localization/zh-cn.csv +++ b/dist/web/static/localization/zh-cn.csv @@ -137,4 +137,6 @@ SELECT_TEXTURE;纹理图 SELECT_DATA_FILE;数据文件 SPLITTER;分割精灵表 SPLITTER_ERROR_NO_FRAMES;精灵图没有找到,请检查文件格式是否正确。 -HOLD_TRIM;保持整齐(修剪): \ No newline at end of file +HOLD_TRIM;保持整齐(修剪): +SORT_BY_NAME_TITLE;Sort file list by name. +SORT_BY_NAME;Sort files by name: \ No newline at end of file diff --git a/electron/package.json b/electron/package.json index d1d2bdb..c3c1180 100644 --- a/electron/package.json +++ b/electron/package.json @@ -61,14 +61,14 @@ "keywords": [], "license": "ISC", "devDependencies": { - "electron": "^4.0.4", - "electron-builder": "^20.38.5" + "electron": "4.0.4", + "electron-builder": "20.38.5" }, "dependencies": { - "electron-log": "^2.2.17", - "electron-updater": "^4.0.6", - "electron-window-state": "^5.0.3", - "optimist": "^0.6.1", - "tinify": "^1.3.0" + "electron-log": "2.2.17", + "electron-updater": "4.0.6", + "electron-window-state": "5.0.3", + "optimist": "0.6.1", + "tinify": "1.3.0" } } diff --git a/package.json b/package.json index 7df6ad0..956202a 100644 --- a/package.json +++ b/package.json @@ -79,33 +79,33 @@ }, "homepage": "https://github.com/odrick/free-tex-packer", "devDependencies": { - "@babel/core": "^7.6.4", - "@babel/preset-env": "^7.6.3", - "@babel/preset-react": "^7.7.4", - "@jvitela/mustache-wax": "^1.0.1", - "babel-loader": "^8.0.5", - "babel-plugin-transform-runtime": "^6.23.0", - "babel-polyfill": "^6.23.0", - "babel-preset-es2015": "^6.24.0", - "babel-preset-stage-0": "^6.22.0", - "babel-runtime": "^6.23.0", - "chokidar": "^2.0.4", - "copy-webpack-plugin": "^4.6.0", - "electron": "^4.0.4", - "eventemitter3": "^3.0.1", - "file-saver": "^2.0.0", - "glob": "^7.1.1", - "json-loader": "^0.5.4", - "jszip": "^3.1.3", - "maxrects-packer": "^2.7.2", - "mustache": "^3.0.1", - "optimist": "^0.6.1", - "plist": "^3.0.1", - "react": "^16.8.1", - "react-dom": "^16.8.1", - "webpack": "^4.29.3", - "webpack-cli": "^3.2.3", - "webpack-dev-server": "^3.1.14", - "xml2js": "^0.4.19" + "@babel/core": "7.6.4", + "@babel/preset-env": "7.6.3", + "@babel/preset-react": "7.7.4", + "@jvitela/mustache-wax": "1.0.1", + "babel-loader": "8.0.5", + "babel-plugin-transform-runtime": "6.23.0", + "babel-polyfill": "6.23.0", + "babel-preset-es2015": "6.24.0", + "babel-preset-stage-0": "6.22.0", + "babel-runtime": "6.23.0", + "chokidar": "2.0.4", + "copy-webpack-plugin": "4.6.0", + "electron": "4.0.4", + "eventemitter3": "3.0.1", + "file-saver": "2.0.0", + "glob": "7.1.1", + "json-loader": "0.5.4", + "jszip": "3.1.3", + "maxrects-packer": "2.7.2", + "mustache": "3.0.1", + "optimist": "0.6.1", + "plist": "3.0.1", + "react": "16.8.1", + "react-dom": "16.8.1", + "webpack": "4.29.3", + "webpack-cli": "3.2.3", + "webpack-dev-server": "3.1.14", + "xml2js": "0.4.19" } } diff --git a/src/client/APP.js b/src/client/APP.js index 0a6b01b..fee1ae5 100644 --- a/src/client/APP.js +++ b/src/client/APP.js @@ -148,7 +148,8 @@ class APP { prependFolderName: this.packOptions.prependFolderName, base64Export: this.packOptions.base64Export, scale: this.packOptions.scale, - trimMode: this.packOptions.trimMode + trimMode: this.packOptions.trimMode, + sortByName: this.packOptions.sortByName }; try { diff --git a/src/client/exporters/index.js b/src/client/exporters/index.js index 199e45c..f0f23d3 100644 --- a/src/client/exporters/index.js +++ b/src/client/exporters/index.js @@ -51,6 +51,18 @@ function getExporterByType(type) { return null; } +function compare_name( a, b ) +{ + if ( a.name.toLowerCase() < b.name.toLowerCase()){ + return -1; + } + if ( a.name.toLowerCase() > b.name.toLowerCase()){ + return 1; + } + + return 0; +} + function prepareData(data, options) { let opt = Object.assign({}, options); @@ -62,6 +74,15 @@ function prepareData(data, options) { opt.base64Prefix = options.textureFormat === "png" ? "data:image/png;base64," : "data:image/jpeg;base64,"; let ret = []; + let frameIndex = 1; + + // Sort files by name in ascending order + // when requested + if ( options.sortByName) + { + data.sort(compare_name); + } + for(let item of data) { @@ -80,13 +101,13 @@ function prepareData(data, options) { if(!options.prependFolderName) { name = name.split("/").pop(); } - - let frame = {x: item.frame.x, y: item.frame.y, w: item.frame.w, h: item.frame.h, hw: item.frame.w/2, hh: item.frame.h/2}; + + let frame = { x: item.frame.x, y: item.frame.y, w: item.frame.w, h: item.frame.h, hw: item.frame.w / 2, hh: item.frame.h / 2, index: frameIndex }; let spriteSourceSize = {x: item.spriteSourceSize.x, y: item.spriteSourceSize.y, w: item.spriteSourceSize.w, h: item.spriteSourceSize.h}; let sourceSize = {w: item.sourceSize.w, h: item.sourceSize.h}; - - let trimmed = item.trimmed; - + + let trimmed = item.trimmed; + if(item.trimmed && options.trimMode === 'crop') { trimmed = false; spriteSourceSize.x = 0; @@ -94,7 +115,7 @@ function prepareData(data, options) { sourceSize.w = spriteSourceSize.w; sourceSize.h = spriteSourceSize.h; } - + if(opt.scale !== 1) { frame.x *= opt.scale; frame.y *= opt.scale; @@ -121,6 +142,7 @@ function prepareData(data, options) { trimmed: trimmed }); + frameIndex++; } if(ret.length) { diff --git a/src/client/exporters/list.json b/src/client/exporters/list.json index 6fb28a7..2959e5a 100644 --- a/src/client/exporters/list.json +++ b/src/client/exporters/list.json @@ -146,6 +146,15 @@ "fileExt": "json", "predefined": true }, + { + "type": "Solar2D", + "description": "Solar2D (CoronaSDK) sprite sheet", + "allowTrim": true, + "allowRotation": false, + "template": "Solar2D.mst", + "fileExt": "lua", + "predefined": true + }, { "type": "custom", "description": "Custom format", diff --git a/src/client/resources/static/exporters/Solar2D.mst b/src/client/resources/static/exporters/Solar2D.mst new file mode 100644 index 0000000..57e2540 --- /dev/null +++ b/src/client/resources/static/exporters/Solar2D.mst @@ -0,0 +1,48 @@ +local SheetInfo = {} + +SheetInfo.sheet = +{ + frames = { + {{#rects}} + { + -- {{{name}}} + {{#trimmed}} + sourceX = {{spriteSourceSize.x}}, + sourceY = {{spriteSourceSize.y}}, + sourceWidth = {{sourceSize.w}}, + sourceHeight = {{sourceSize.h}}, + {{/trimmed}} + + x = {{frame.x}}, + y = {{frame.y}}, + width = {{frame.w}}, + height = {{frame.h}}, + }, + {{/rects}} + }, + + sheetContentWidth = {{config.imageWidth}}, + sheetContentHeight = {{config.imageHeight}} +} + + +SheetInfo.frameIndex = +{ + {{#rects}} + ["{{name}}"] = {{frame.index}}, + {{/rects}} +} + + +function SheetInfo:getSheet() + return self.sheet; +end + + +function SheetInfo:getFrameIndex(name) + return self.frameIndex[name]; +end + + +return SheetInfo + diff --git a/src/client/resources/static/localization/de.csv b/src/client/resources/static/localization/de.csv index 615f922..43c928d 100644 --- a/src/client/resources/static/localization/de.csv +++ b/src/client/resources/static/localization/de.csv @@ -137,3 +137,5 @@ SELECT_DATA_FILE;Daten-Datei SPLITTER;Sprites aus Bild extrahieren SPLITTER_ERROR_NO_FRAMES;Sprites wurden nicht gefunden. Vermutlich ist das Atlas Format falsch. HOLD_TRIM;Trim beibehalten: +SORT_BY_NAME_TITLE;Sort file list by name. +SORT_BY_NAME;Sort files by name: \ No newline at end of file diff --git a/src/client/resources/static/localization/en.csv b/src/client/resources/static/localization/en.csv index 7ce9472..ec3f563 100644 --- a/src/client/resources/static/localization/en.csv +++ b/src/client/resources/static/localization/en.csv @@ -137,4 +137,6 @@ SELECT_TEXTURE;Texture SELECT_DATA_FILE;Data file SPLITTER;Split sheet SPLITTER_ERROR_NO_FRAMES;Sprites not found. Probably, atlas format is incorrect. -HOLD_TRIM;Hold trim: \ No newline at end of file +HOLD_TRIM;Hold trim: +SORT_BY_NAME_TITLE;Sort file list by name. +SORT_BY_NAME;Sort files by name: \ No newline at end of file diff --git a/src/client/resources/static/localization/es.csv b/src/client/resources/static/localization/es.csv index 68f275e..6c67dfa 100644 --- a/src/client/resources/static/localization/es.csv +++ b/src/client/resources/static/localization/es.csv @@ -137,4 +137,6 @@ SELECT_TEXTURE;Textura SELECT_DATA_FILE;Datos SPLITTER;Desembalaje atlas SPLITTER_ERROR_NO_FRAMES;No se ha encontrado ningún sprite. Quizás el formato del atlas sea incorrecto. -HOLD_TRIM;Mantener corte: \ No newline at end of file +HOLD_TRIM;Mantener corte: +SORT_BY_NAME_TITLE;Sort file list by name. +SORT_BY_NAME;Sort files by name: \ No newline at end of file diff --git a/src/client/resources/static/localization/ru.csv b/src/client/resources/static/localization/ru.csv index 38ca73e..6091301 100644 --- a/src/client/resources/static/localization/ru.csv +++ b/src/client/resources/static/localization/ru.csv @@ -137,4 +137,6 @@ SELECT_TEXTURE;Текстура SELECT_DATA_FILE;Данные SPLITTER;Распаковка атласа SPLITTER_ERROR_NO_FRAMES;Не найдено ни одного спрайта. Возможно, формат атласа неверен. -HOLD_TRIM;Обрезать: \ No newline at end of file +HOLD_TRIM;Обрезать: +SORT_BY_NAME_TITLE;Sort file list by name. +SORT_BY_NAME;Sort files by name: \ No newline at end of file diff --git a/src/client/resources/static/localization/zh-cn.csv b/src/client/resources/static/localization/zh-cn.csv index 07b1d17..62c1932 100644 --- a/src/client/resources/static/localization/zh-cn.csv +++ b/src/client/resources/static/localization/zh-cn.csv @@ -137,4 +137,6 @@ SELECT_TEXTURE;纹理图 SELECT_DATA_FILE;数据文件 SPLITTER;分割精灵表 SPLITTER_ERROR_NO_FRAMES;精灵图没有找到,请检查文件格式是否正确。 -HOLD_TRIM;保持整齐(修剪): \ No newline at end of file +HOLD_TRIM;保持整齐(修剪): +SORT_BY_NAME_TITLE;Sort file list by name. +SORT_BY_NAME;Sort files by name: \ No newline at end of file diff --git a/src/client/ui/PackProperties.jsx b/src/client/ui/PackProperties.jsx index 9c1742a..83b2ad6 100644 --- a/src/client/ui/PackProperties.jsx +++ b/src/client/ui/PackProperties.jsx @@ -93,6 +93,7 @@ class PackProperties extends React.Component { data.alphaThreshold = data.alphaThreshold || 0; data.detectIdentical = data.detectIdentical === undefined ? true : data.detectIdentical; data.packer = getPackerByType(data.packer) ? data.packer : packers[0].type; + data.sortByName = data.sortByName === undefined ? true : data.sortByName; let methodValid = false; let packer = getPackerByType(data.packer); @@ -148,6 +149,7 @@ class PackProperties extends React.Component { data.detectIdentical = ReactDOM.findDOMNode(this.refs.detectIdentical).checked; data.packer = ReactDOM.findDOMNode(this.refs.packer).value; data.packerMethod = ReactDOM.findDOMNode(this.refs.packerMethod).value; + data.sortByName = ReactDOM.findDOMNode(this.refs.sortByName).checked; this.packOptions = this.applyOptionsDefaults(data); } @@ -178,6 +180,8 @@ class PackProperties extends React.Component { ReactDOM.findDOMNode(this.refs.detectIdentical).checked = this.packOptions.detectIdentical; ReactDOM.findDOMNode(this.refs.packer).value = this.packOptions.packer; ReactDOM.findDOMNode(this.refs.packerMethod).value = this.packOptions.packerMethod; + ReactDOM.findDOMNode(this.refs.sortByName).checked = this.packOptions.sortByName; + } getPackOptions() { @@ -431,6 +435,13 @@ class PackProperties extends React.Component { + + + {I18.f("SORT_BY_NAME")} + + + + From a00e09bebe684da1560fd674d73baa0e01e7ee8e Mon Sep 17 00:00:00 2001 From: jcbk101 <75145117+jcbk101@users.noreply.github.com> Date: Tue, 5 Jul 2022 17:35:59 -0400 Subject: [PATCH 3/4] Update Solar2D.mst --- dist/web/static/exporters/Solar2D.mst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/web/static/exporters/Solar2D.mst b/dist/web/static/exporters/Solar2D.mst index 645549d..57e2540 100644 --- a/dist/web/static/exporters/Solar2D.mst +++ b/dist/web/static/exporters/Solar2D.mst @@ -9,8 +9,8 @@ SheetInfo.sheet = {{#trimmed}} sourceX = {{spriteSourceSize.x}}, sourceY = {{spriteSourceSize.y}}, - sourceWidth = {{spriteSourceSize.w}}, - sourceHeight = {{spriteSourceSize.h}}, + sourceWidth = {{sourceSize.w}}, + sourceHeight = {{sourceSize.h}}, {{/trimmed}} x = {{frame.x}}, From 4e3524c660afdbd2a3ffd4ff8cc2114f33f7d243 Mon Sep 17 00:00:00 2001 From: John C <75145117+jcbk101@users.noreply.github.com> Date: Tue, 5 Jul 2022 17:39:24 -0400 Subject: [PATCH 4/4] Update package.json --- package.json | 54 ++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/package.json b/package.json index 956202a..e80dbb5 100644 --- a/package.json +++ b/package.json @@ -79,33 +79,33 @@ }, "homepage": "https://github.com/odrick/free-tex-packer", "devDependencies": { - "@babel/core": "7.6.4", - "@babel/preset-env": "7.6.3", - "@babel/preset-react": "7.7.4", - "@jvitela/mustache-wax": "1.0.1", - "babel-loader": "8.0.5", - "babel-plugin-transform-runtime": "6.23.0", - "babel-polyfill": "6.23.0", - "babel-preset-es2015": "6.24.0", - "babel-preset-stage-0": "6.22.0", - "babel-runtime": "6.23.0", - "chokidar": "2.0.4", - "copy-webpack-plugin": "4.6.0", + "@babel/core": "^7.6.4", + "@babel/preset-env": "^7.6.3", + "@babel/preset-react": "^7.7.4", + "@jvitela/mustache-wax": "^1.0.1", + "babel-loader": "^8.0.5", + "babel-plugin-transform-runtime": "^6.23.0", + "babel-polyfill": "^6.23.0", + "babel-preset-es2015": "^6.24.0", + "babel-preset-stage-0": "^6.22.0", + "babel-runtime": "^6.23.0", + "chokidar": "^2.0.4", + "copy-webpack-plugin": "^4.6.0", "electron": "4.0.4", - "eventemitter3": "3.0.1", - "file-saver": "2.0.0", - "glob": "7.1.1", - "json-loader": "0.5.4", - "jszip": "3.1.3", - "maxrects-packer": "2.7.2", - "mustache": "3.0.1", - "optimist": "0.6.1", - "plist": "3.0.1", - "react": "16.8.1", - "react-dom": "16.8.1", - "webpack": "4.29.3", - "webpack-cli": "3.2.3", - "webpack-dev-server": "3.1.14", - "xml2js": "0.4.19" + "eventemitter3": "^3.0.1", + "file-saver": "^2.0.0", + "glob": "^7.1.1", + "json-loader": "^0.5.4", + "jszip": "^3.1.3", + "maxrects-packer": "^2.7.2", + "mustache": "^3.0.1", + "optimist": "^0.6.1", + "plist": "^3.0.1", + "react": "^16.8.1", + "react-dom": "^16.8.1", + "webpack": "^4.29.3", + "webpack-cli": "^3.2.3", + "webpack-dev-server": "^3.1.14", + "xml2js": "^0.4.19" } }