fold autotile

This commit is contained in:
ckcz123 2021-07-21 19:21:32 +08:00
parent 7666fc3f5b
commit 30f48b0b68
2 changed files with 16 additions and 10 deletions

View File

@ -638,7 +638,7 @@ editor.prototype.drawInitData = function (icons) {
if (img == 'autotile') {
var autotiles = images[img];
for (var im in autotiles) {
tempy += autotiles[im].height;
tempy += editor.uivalues.folded ? 32 : autotiles[im].height;
}
var tempx = editor.uivalues.folded ? 32 : 3 * 32;
editor.widthsX[img] = [img, sumWidth / 32, (sumWidth + tempx) / 32, tempy];
@ -748,9 +748,10 @@ editor.prototype.drawInitData = function (icons) {
var autotiles = images[img];
var tempx = editor.uivalues.folded ? 32 : 96;
for (var im in autotiles) {
var subimgs = core.splitImage(autotiles[im], tempx, autotiles[im].height);
var tempy = editor.uivalues.folded ? 32 : autotiles[im].height;
var subimgs = core.splitImage(autotiles[im], tempx, tempy);
drawImage(subimgs[0], nowx, nowy, img);
nowy += autotiles[im].height;
nowy += tempy;
}
nowx += tempx;
continue;

View File

@ -132,13 +132,18 @@ editor_materialpanel_wrapper = function (editor) {
var autotiles = core.material.images['autotile'];
if (pos.images == 'autotile') {
var imNames = Object.keys(autotiles);
if ((pos.y + 1) * ysize > editor.widthsX[spriter][3])
pos.y = ~~(editor.widthsX[spriter][3] / ysize) - 4;
else {
for (var i = 0; i < imNames.length; i++) {
if (pos.y >= 4 * i && pos.y < 4 * (i + 1)) {
pos.images = imNames[i];
pos.y = 4 * i;
if (editor.uivalues.folded) {
pos.y = Math.min(pos.y, imNames.length - 1);
pos.images = imNames[pos.y];
} else {
if ((pos.y + 1) * ysize > editor.widthsX[spriter][3])
pos.y = ~~(editor.widthsX[spriter][3] / ysize) - 4;
else {
for (var i = 0; i < imNames.length; i++) {
if (pos.y >= 4 * i && pos.y < 4 * (i + 1)) {
pos.images = imNames[i];
pos.y = 4 * i;
}
}
}
}