tileset bind width&height
This commit is contained in:
parent
eb8abae982
commit
97ba00cb33
@ -85,8 +85,10 @@ function editor() {
|
||||
copyEnemyItem : {
|
||||
type: null,
|
||||
data: {}
|
||||
}
|
||||
},
|
||||
|
||||
// tile
|
||||
tileSize: [1,1],
|
||||
};
|
||||
|
||||
window.onerror = function (msg, url, lineNo, columnNo, error) {
|
||||
|
||||
@ -636,6 +636,8 @@ editor_datapanel_wrapper = function (editor) {
|
||||
|
||||
editor.uifunctions.appendConfirm_func = function () {
|
||||
|
||||
var appendRegister = document.getElementById('appendRegister');
|
||||
|
||||
var appendConfirm = document.getElementById('appendConfirm');
|
||||
appendConfirm.onclick = function () {
|
||||
|
||||
@ -699,15 +701,28 @@ editor_datapanel_wrapper = function (editor) {
|
||||
}
|
||||
var dt = editor.dom.spriteCtx.getImageData(0, 0, editor.dom.sprite.width, editor.dom.sprite.height);
|
||||
var imgbase64 = editor.dom.sprite.toDataURL('image/png');
|
||||
fs.writeFile('./project/images/' + editor_mode.appendPic.imageName + '.png', imgbase64.split(',')[1], 'base64', function (err, data) {
|
||||
var imgName = editor_mode.appendPic.imageName;
|
||||
fs.writeFile('./project/images/' + imgName + '.png', imgbase64.split(',')[1], 'base64', function (err, data) {
|
||||
if (err) {
|
||||
printe(err);
|
||||
throw (err)
|
||||
}
|
||||
printf('追加素材成功,你可以继续追加其他素材,最后再刷新以显示在素材区');
|
||||
editor.dom.sprite.style.height = (editor.dom.sprite.height = (editor.dom.sprite.height + ysize)) + "px";
|
||||
var currHeight = editor.dom.sprite.height;
|
||||
editor.dom.sprite.style.height = (editor.dom.sprite.height = (currHeight + ysize)) + "px";
|
||||
editor.dom.spriteCtx.putImageData(dt, 0, 0);
|
||||
core.material.images[editor.dom.selectAppend.value].src = imgbase64;
|
||||
core.material.images[imgName].src = imgbase64;
|
||||
editor.widthsX[imgName][3] = currHeight;
|
||||
if (appendRegister && appendRegister.checked) {
|
||||
editor.file.autoRegister({images: imgName}, function (e) {
|
||||
if (e) {
|
||||
printe(e);
|
||||
throw e;
|
||||
}
|
||||
printf('追加素材并自动注册成功!你可以继续追加其他素材,最后再刷新以使用。');
|
||||
});
|
||||
} else {
|
||||
printf('追加素材成功!你可以继续追加其他素材,最后再刷新以使用。');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@ -731,15 +746,28 @@ editor_datapanel_wrapper = function (editor) {
|
||||
|
||||
dt = editor.dom.spriteCtx.getImageData(0, 0, editor.dom.sprite.width, editor.dom.sprite.height);
|
||||
var imgbase64 = editor.dom.sprite.toDataURL('image/png');
|
||||
fs.writeFile('./project/images/' + editor_mode.appendPic.imageName + '.png', imgbase64.split(',')[1], 'base64', function (err, data) {
|
||||
var imgName = editor_mode.appendPic.imageName;
|
||||
fs.writeFile('./project/images/' + imgName + '.png', imgbase64.split(',')[1], 'base64', function (err, data) {
|
||||
if (err) {
|
||||
printe(err);
|
||||
throw (err)
|
||||
}
|
||||
printf('快速追加素材成功,你可以继续追加其他素材,最后再刷新以显示在素材区');
|
||||
editor.dom.sprite.style.height = (editor.dom.sprite.height = (editor.dom.sprite.height + ysize)) + "px";
|
||||
var currHeight = editor.dom.sprite.height;
|
||||
editor.dom.sprite.style.height = (editor.dom.sprite.height = (currHeight + ysize)) + "px";
|
||||
editor.dom.spriteCtx.putImageData(dt, 0, 0);
|
||||
core.material.images[editor.dom.selectAppend.value].src = imgbase64;
|
||||
core.material.images[imgName].src = imgbase64;
|
||||
editor.widthsX[imgName][3] = currHeight;
|
||||
if (appendRegister && appendRegister.checked) {
|
||||
editor.file.autoRegister({images: imgName}, function (e) {
|
||||
if (e) {
|
||||
printe(e);
|
||||
throw e;
|
||||
}
|
||||
printf('快速追加素材并自动注册成功!你可以继续追加其他素材,最后再刷新以使用。');
|
||||
})
|
||||
} else {
|
||||
printf('快速追加素材成功!你可以继续追加其他素材,最后再刷新以使用。');
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@ -216,7 +216,7 @@ tip.showHelp = function(value) {
|
||||
'双击事件编辑器的图块可以进行长文本编辑/脚本编辑/地图选点/UI绘制预览等操作',
|
||||
'ESC或点击空白处可以自动保存当前修改',
|
||||
'H键可以打开操作帮助哦',
|
||||
'tileset贴图模式下可以按选中tileset素材,并在地图上拖动来一次绘制一个区域',
|
||||
'tileset贴图模式可以在地图上拖动来一次绘制一个区域;右键额外素材也可以绑定宽高',
|
||||
'可以拖动地图上的图块和事件,或按Ctrl+C, Ctrl+X和Ctrl+V进行复制,剪切和粘贴,Delete删除',
|
||||
'Alt+数字键保存图块,数字键读取保存的图块',
|
||||
];
|
||||
|
||||
@ -24,6 +24,7 @@ editor_listen_wrapper = function (editor) {
|
||||
editor.dom.iconExpandBtn.onclick = editor.uifunctions.fold_material_click
|
||||
|
||||
editor.dom.iconLib.onmousedown = editor.uifunctions.material_ondown
|
||||
editor.dom.iconLib.oncontextmenu = function (e) { e.preventDefault() }
|
||||
|
||||
editor.dom.extraEvent.onmousedown = editor.uifunctions.extraEvent_click
|
||||
editor.dom.chooseThis.onmousedown = editor.uifunctions.chooseThis_click
|
||||
|
||||
@ -221,8 +221,19 @@ editor_mappanel_wrapper = function (editor) {
|
||||
}
|
||||
}
|
||||
}
|
||||
// console.log(editor.uivalues.stepPostfix);
|
||||
if (editor.brushMod === 'tileset' && core.tilesets.indexOf(editor.info.images) !== -1) {
|
||||
var useBrushMode = editor.brushMod == 'tileset';
|
||||
if (editor.uivalues.stepPostfix.length == 1 && (editor.uivalues.tileSize[0] > 1 || editor.uivalues.tileSize[1] > 1)) {
|
||||
useBrushMode = true;
|
||||
var x0 = editor.uivalues.stepPostfix[0].x;
|
||||
var y0 = editor.uivalues.stepPostfix[0].y;
|
||||
editor.uivalues.stepPostfix = [];
|
||||
for (var jj = y0; jj < y0 + editor.uivalues.tileSize[1]; ++jj) {
|
||||
for (var ii = x0; ii < x0 + editor.uivalues.tileSize[0]; ++ii) {
|
||||
editor.uivalues.stepPostfix.push({ x: ii, y: jj });
|
||||
}
|
||||
}
|
||||
}
|
||||
if (useBrushMode && core.tilesets.indexOf(editor.info.images) !== -1) {
|
||||
var imgWidth = ~~(core.material.images.tilesets[editor.info.images].width / 32);
|
||||
var x0 = editor.uivalues.stepPostfix[0].x;
|
||||
var y0 = editor.uivalues.stepPostfix[0].y;
|
||||
|
||||
@ -50,6 +50,7 @@ editor_materialpanel_wrapper = function (editor) {
|
||||
*/
|
||||
editor.uifunctions.material_ondown = function (e) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
if (!editor.isMobile && e.clientY >= editor.dom.iconLib.offsetHeight - editor.uivalues.scrollBarHeight) return;
|
||||
var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft;
|
||||
var scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
|
||||
@ -59,6 +60,7 @@ editor_materialpanel_wrapper = function (editor) {
|
||||
'size': 32
|
||||
};
|
||||
editor.loc = loc;
|
||||
editor.uivalues.tileSize = [1,1];
|
||||
var pos = editor.uifunctions.locToPos(loc);
|
||||
for (var spriter in editor.widthsX) {
|
||||
if (pos.x >= editor.widthsX[spriter][1] && pos.x < editor.widthsX[spriter][2]) {
|
||||
@ -126,6 +128,21 @@ editor_materialpanel_wrapper = function (editor) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (editor.info.isTile && e.button == 2) {
|
||||
var v = prompt("请输入该额外素材区域绑定宽高,以逗号分隔", "1,1");
|
||||
if (v != null && /^\d+,\d+$/.test(v)) {
|
||||
v = v.split(",");
|
||||
var x = parseInt(v[0]), y = parseInt(v[1]);
|
||||
var widthX = editor.widthsX[editor.info.images];
|
||||
if (x <= 0 || y <= 0 || editor.info.x + x > widthX[2] - widthX[1] || 32*(editor.info.y + y) > widthX[3]) {
|
||||
alert("不合法的输入范围,已经越界");
|
||||
} else {
|
||||
editor.uivalues.tileSize = [x, y];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
tip.infos(JSON.parse(JSON.stringify(editor.info)));
|
||||
editor_mode.onmode('nextChange');
|
||||
|
||||
@ -73,6 +73,7 @@
|
||||
<!-- ["terrains", "animates", "enemys", "enemy48", "items", "npcs", "npc48"] -->
|
||||
<input id="appendConfirm" type="button" value="追加"/>
|
||||
<input id="quickAppendConfirm" type="button" value="快速追加"/>
|
||||
<span style="font-size: 13px"> 自动注册</span><input id="appendRegister" type="checkbox" checked/>
|
||||
</p>
|
||||
<p>
|
||||
色相:<input id='changeColorInput' type="range" min="0" max="12" step="1" value="0" list="huelists" style="width: 60%;margin-left: 3%;vertical-align: middle">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user