Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solar2D support, Sort by filenames supported #75

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions dist/web/static/exporters/Solar2D.mst
Original file line number Diff line number Diff line change
@@ -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

38 changes: 36 additions & 2 deletions dist/web/static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -49913,7 +49935,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;
Expand Down Expand Up @@ -51499,6 +51522,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);
Expand Down Expand Up @@ -51559,6 +51583,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);
}
}, {
Expand Down Expand Up @@ -51589,6 +51614,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",
Expand Down Expand Up @@ -51935,6 +51961,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))))));
}
}], [{
Expand Down
2 changes: 2 additions & 0 deletions dist/web/static/localization/de.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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:
4 changes: 3 additions & 1 deletion dist/web/static/localization/en.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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:
HOLD_TRIM;Hold trim:
SORT_BY_NAME_TITLE;Sort file list by name.
SORT_BY_NAME;Sort files by name:
4 changes: 3 additions & 1 deletion dist/web/static/localization/es.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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:
HOLD_TRIM;Mantener corte:
SORT_BY_NAME_TITLE;Sort file list by name.
SORT_BY_NAME;Sort files by name:
4 changes: 3 additions & 1 deletion dist/web/static/localization/ru.csv
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,6 @@ SELECT_TEXTURE;Текстура
SELECT_DATA_FILE;Данные
SPLITTER;Распаковка атласа
SPLITTER_ERROR_NO_FRAMES;Не найдено ни одного спрайта. Возможно, формат атласа неверен.
HOLD_TRIM;Обрезать:
HOLD_TRIM;Обрезать:
SORT_BY_NAME_TITLE;Sort file list by name.
SORT_BY_NAME;Sort files by name:
4 changes: 3 additions & 1 deletion dist/web/static/localization/zh-cn.csv
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,6 @@ SELECT_TEXTURE;纹理图
SELECT_DATA_FILE;数据文件
SPLITTER;分割精灵表
SPLITTER_ERROR_NO_FRAMES;精灵图没有找到,请检查文件格式是否正确。
HOLD_TRIM;保持整齐(修剪):
HOLD_TRIM;保持整齐(修剪):
SORT_BY_NAME_TITLE;Sort file list by name.
SORT_BY_NAME;Sort files by name:
14 changes: 7 additions & 7 deletions electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"babel-runtime": "^6.23.0",
"chokidar": "^2.0.4",
"copy-webpack-plugin": "^4.6.0",
"electron": "^4.0.4",
"electron": "4.0.4",
"eventemitter3": "^3.0.1",
"file-saver": "^2.0.0",
"glob": "^7.1.1",
Expand Down
3 changes: 2 additions & 1 deletion src/client/APP.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
34 changes: 28 additions & 6 deletions src/client/exporters/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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) {

Expand All @@ -80,21 +101,21 @@ 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;
spriteSourceSize.y = 0;
sourceSize.w = spriteSourceSize.w;
sourceSize.h = spriteSourceSize.h;
}

if(opt.scale !== 1) {
frame.x *= opt.scale;
frame.y *= opt.scale;
Expand All @@ -121,6 +142,7 @@ function prepareData(data, options) {
trimmed: trimmed
});

frameIndex++;
}

if(ret.length) {
Expand Down
9 changes: 9 additions & 0 deletions src/client/exporters/list.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
48 changes: 48 additions & 0 deletions src/client/resources/static/exporters/Solar2D.mst
Original file line number Diff line number Diff line change
@@ -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

2 changes: 2 additions & 0 deletions src/client/resources/static/localization/de.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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:
4 changes: 3 additions & 1 deletion src/client/resources/static/localization/en.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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:
HOLD_TRIM;Hold trim:
SORT_BY_NAME_TITLE;Sort file list by name.
SORT_BY_NAME;Sort files by name:
4 changes: 3 additions & 1 deletion src/client/resources/static/localization/es.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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:
HOLD_TRIM;Mantener corte:
SORT_BY_NAME_TITLE;Sort file list by name.
SORT_BY_NAME;Sort files by name:
4 changes: 3 additions & 1 deletion src/client/resources/static/localization/ru.csv
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,6 @@ SELECT_TEXTURE;Текстура
SELECT_DATA_FILE;Данные
SPLITTER;Распаковка атласа
SPLITTER_ERROR_NO_FRAMES;Не найдено ни одного спрайта. Возможно, формат атласа неверен.
HOLD_TRIM;Обрезать:
HOLD_TRIM;Обрезать:
SORT_BY_NAME_TITLE;Sort file list by name.
SORT_BY_NAME;Sort files by name:
4 changes: 3 additions & 1 deletion src/client/resources/static/localization/zh-cn.csv
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,6 @@ SELECT_TEXTURE;纹理图
SELECT_DATA_FILE;数据文件
SPLITTER;分割精灵表
SPLITTER_ERROR_NO_FRAMES;精灵图没有找到,请检查文件格式是否正确。
HOLD_TRIM;保持整齐(修剪):
HOLD_TRIM;保持整齐(修剪):
SORT_BY_NAME_TITLE;Sort file list by name.
SORT_BY_NAME;Sort files by name:
Loading