indexOf 48 -> endsWith 48

This commit is contained in:
ckcz123 2019-04-16 14:00:48 +08:00
parent 2f36a3b0ba
commit 5b239047b5
3 changed files with 8 additions and 8 deletions

View File

@ -448,7 +448,7 @@ editor.prototype.setSelectBoxFromInfo=function(thisevent){
pos.y=thisevent.y;
if(thisevent.x)pos.x+=thisevent.x;
if(thisevent.images=='terrains')pos.y+=2;
ysize = thisevent.images.indexOf('48') === -1 ? 32 : 48;
ysize = thisevent.images.endsWith('48') ? 48 : 32;
}
var dataSelection = document.getElementById('dataSelection');
dataSelection.style.left = pos.x * 32 + 'px';
@ -884,7 +884,7 @@ editor.prototype.listen = function () {
var pos = locToPos(loc);
for (var spriter in editor.widthsX) {
if (pos.x >= editor.widthsX[spriter][1] && pos.x < editor.widthsX[spriter][2]) {
var ysize = spriter.indexOf('48') === -1 ? 32 : 48;
var ysize = spriter.endsWith('48') ? 48 : 32;
loc.ysize = ysize;
pos.images = editor.widthsX[spriter][0];
pos.y = ~~(loc.y / loc.ysize);

View File

@ -269,7 +269,7 @@ editor_file = function (editor, callback) {
}
})
var per_height = image.indexOf('48')>=0?48:32;
var per_height = image.endsWith('48')?48:32;
var idnum=300;
for (var y=0; y<editor.widthsX[image][3]/per_height;y++) {

View File

@ -452,7 +452,7 @@ editor_mode = function (editor) {
return;
}
var ysize = selectAppend.value.indexOf('48') === -1 ? 32 : 48;
var ysize = selectAppend.value.endsWith('48') ? 48 : 32;
editor_mode.appendPic.imageName = value;
var img = core.material.images[value];
editor_mode.appendPic.toImg = img;
@ -529,7 +529,7 @@ editor_mode = function (editor) {
*/
// Step 2: 检测长宽比
var ysize = selectAppend.value.indexOf('48') === -1 ? 32 : 48;
var ysize = selectAppend.value.endsWith('48') ? 48 : 32;
if ((image.width%32!=0 || image.height%ysize!=0) && (image.width<=128 && image.height<=ysize*4)
&& confirm("目标长宽不符合条件,是否自动进行调整?")) {
var ncanvas = document.createElement('canvas').getContext('2d');
@ -592,7 +592,7 @@ editor_mode = function (editor) {
sprite_ctx.drawImage(image, 0, 0);
}
else {
var ysize = selectAppend.value.indexOf('48') === -1 ? 32 : 48;
var ysize = selectAppend.value.endsWith('48') ? 48 : 32;
for (var ii = 0; ii < 3; ii++) {
var newsprite = appendPicCanvas.children[ii];
newsprite.style.width = (newsprite.width = Math.floor(image.width / 32) * 32) / ratio + 'px';
@ -661,7 +661,7 @@ editor_mode = function (editor) {
'x': scrollLeft + e.clientX + appendPicCanvas.scrollLeft - left1.offsetLeft - appendPicCanvas.offsetLeft,
'y': scrollTop + e.clientY + appendPicCanvas.scrollTop - left1.offsetTop - appendPicCanvas.offsetTop,
'size': 32,
'ysize': selectAppend.value.indexOf('48') === -1 ? 32 : 48
'ysize': selectAppend.value.endsWith('48') ? 48 : 32;
};
return loc;
}//返回可用的组件内坐标
@ -740,7 +740,7 @@ editor_mode = function (editor) {
return;
}
var ysize = selectAppend.value.indexOf('48') === -1 ? 32 : 48;
var ysize = selectAppend.value.endsWith('48') ? 48 : 32;
for (var ii = 0, v; v = editor_mode.appendPic.selectPos[ii]; ii++) {
// var imgData = source_ctx.getImageData(v.x * 32, v.y * ysize, 32, ysize);
// sprite_ctx.putImageData(imgData, ii * 32, sprite.height - ysize);