editor: tileset draw-mod
This commit is contained in:
parent
5ad2835914
commit
be3925cae6
@ -1,6 +1,6 @@
|
||||
function editor() {
|
||||
this.version = "2.0";
|
||||
this.brushMod = "line";//["line","rectangle"]
|
||||
this.brushMod = "line";//["line","rectangle","tileset"]
|
||||
this.layerMod = "map";//["fgmap","map","bgmap"]
|
||||
this.isMobile = false;
|
||||
}
|
||||
@ -468,7 +468,7 @@ editor.prototype.listen = function () {
|
||||
});
|
||||
|
||||
var unselect=true;
|
||||
for(var ii=0,thisId;thisId=['edit','tip','brushMod','brushMod2','layerMod','layerMod2','layerMod3','viewportButtons'][ii];ii++){
|
||||
for(var ii=0,thisId;thisId=['edit','tip','brushMod','brushMod2','brushMod3','layerMod','layerMod2','layerMod3','viewportButtons'][ii];ii++){
|
||||
if (clickpath.indexOf(thisId) !== -1){
|
||||
unselect=false;
|
||||
break;
|
||||
@ -625,7 +625,7 @@ editor.prototype.listen = function () {
|
||||
e.stopPropagation();
|
||||
if (stepPostfix && stepPostfix.length) {
|
||||
preMapData = JSON.parse(JSON.stringify({map:editor.map,fgmap:editor.fgmap,bgmap:editor.bgmap}));
|
||||
if(editor.brushMod==='rectangle'){
|
||||
if(editor.brushMod!=='line'){
|
||||
var x0=stepPostfix[0].x;
|
||||
var y0=stepPostfix[0].y;
|
||||
var x1=stepPostfix[stepPostfix.length-1].x;
|
||||
@ -633,8 +633,8 @@ editor.prototype.listen = function () {
|
||||
if(x0>x1){x0^=x1;x1^=x0;x0^=x1;}//swap
|
||||
if(y0>y1){y0^=y1;y1^=y0;y0^=y1;}//swap
|
||||
stepPostfix=[];
|
||||
for(var ii=x0;ii<=x1;ii++){
|
||||
for(var jj=y0;jj<=y1;jj++){
|
||||
for(var jj=y0;jj<=y1;jj++){
|
||||
for(var ii=x0;ii<=x1;ii++){
|
||||
stepPostfix.push({x:ii,y:jj})
|
||||
}
|
||||
}
|
||||
@ -646,8 +646,22 @@ editor.prototype.listen = function () {
|
||||
if (editor.layerMod!='map' && editor.info.images && editor.info.images.indexOf('48')!==-1){
|
||||
printe('前景/背景不支持48的图块');
|
||||
} else {
|
||||
for (var ii = 0; ii < stepPostfix.length; ii++)
|
||||
if(editor.brushMod==='tileset' && core.tilesets.indexOf(editor.info.images)!==-1){
|
||||
var imgWidth=~~(core.material.images.tilesets[editor.info.images].width/32);
|
||||
var x0=stepPostfix[0].x;
|
||||
var y0=stepPostfix[0].y;
|
||||
var idnum=editor.info.idnum;
|
||||
for (var ii = 0; ii < stepPostfix.length; ii++){
|
||||
if(stepPostfix[ii].y!=y0){
|
||||
y0++;
|
||||
idnum+=imgWidth;
|
||||
}
|
||||
editor[editor.layerMod][stepPostfix[ii].y][stepPostfix[ii].x] = editor.ids[editor.indexs[idnum+stepPostfix[ii].x-x0]];
|
||||
}
|
||||
} else {
|
||||
for (var ii = 0; ii < stepPostfix.length; ii++)
|
||||
editor[editor.layerMod][stepPostfix[ii].y][stepPostfix[ii].x] = editor.info;
|
||||
}
|
||||
}
|
||||
// console.log(editor.map);
|
||||
editor.updateMap();
|
||||
@ -1013,6 +1027,11 @@ editor.prototype.listen = function () {
|
||||
editor.brushMod=brushMod2.value;
|
||||
}
|
||||
|
||||
var brushMod3=document.getElementById('brushMod3');
|
||||
if(brushMod3)brushMod3.onchange=function(){
|
||||
editor.brushMod=brushMod3.value;
|
||||
}
|
||||
|
||||
var layerMod=document.getElementById('layerMod');
|
||||
layerMod.onchange=function(){
|
||||
editor.layerMod=layerMod.value;
|
||||
|
||||
@ -276,6 +276,7 @@
|
||||
<select id="brushMod" style="clear:right">
|
||||
<option value="line">画线</option>
|
||||
<option value="rectangle">画矩形</option>
|
||||
<option value="tileset">tileset贴图</option>
|
||||
</select>
|
||||
<select id="layerMod" style="float:left;margin-right:3px">
|
||||
<option value="bgmap">背景层</option>
|
||||
|
||||
@ -245,9 +245,11 @@
|
||||
<option value="functions">脚本编辑</option>
|
||||
<option value="appendpic">追加素材</option>
|
||||
</select>
|
||||
<span style="font-size: 12px; margin-left: 5px">
|
||||
<br/>
|
||||
<span style="font-size: 12px;">
|
||||
<input type="radio" id="brushMod" name="brushMod" value="line" checked="checked" />画线
|
||||
<input type="radio" id="brushMod2" name="brushMod" value="rectangle" />画矩形
|
||||
<input type="radio" id="brushMod3" name="brushMod" value="tileset" />tileset贴图
|
||||
</span>
|
||||
<br/>
|
||||
<span style="font-size: 12px">
|
||||
|
||||
Loading…
Reference in New Issue
Block a user