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