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

View File

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