editor brushMod

editor.brushMod = "line"; // ["line","rectangle"]
This commit is contained in:
YouWei Zhao 2018-07-21 22:18:19 +08:00
parent 1edb335803
commit 5f411c0acc
4 changed files with 34 additions and 3 deletions

View File

@ -1,6 +1,7 @@
function editor() {
this.version = "2.0";
this.material = {};
this.brushMod = "line";//["line","rectangle"]
}
editor.prototype.init = function (callback) {
@ -503,6 +504,20 @@ editor.prototype.listen = function () {
e.stopPropagation();
if (stepPostfix && stepPostfix.length) {
preMapData = JSON.parse(JSON.stringify(editor.map));
if(editor.brushMod==='rectangle'){
var x0=stepPostfix[0].x;
var y0=stepPostfix[0].y;
var x1=stepPostfix[stepPostfix.length-1].x;
var y1=stepPostfix[stepPostfix.length-1].y;
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++){
stepPostfix.push({x:ii,y:jj})
}
}
}
currDrawData.pos = JSON.parse(JSON.stringify(stepPostfix));
currDrawData.info = JSON.parse(JSON.stringify(editor.info));
reDo = null;
@ -839,6 +854,16 @@ editor.prototype.listen = function () {
});
}
var brushMod=document.getElementById('brushMod');
brushMod.onchange=function(){
editor.brushMod=brushMod.value;
}
var brushMod2=document.getElementById('brushMod2');
if(brushMod2)brushMod2.onchange=function(){
editor.brushMod=brushMod2.value;
}
}//绑定事件
/*

View File

@ -24,7 +24,7 @@ document.body.onmousedown = function (e) {
}
});
if (clickpath.indexOf('edit') === -1 && clickpath.indexOf('tip') === -1) {
if (clickpath.indexOf('edit') === -1 && clickpath.indexOf('tip') === -1 && clickpath.indexOf('brushMod') === -1 && clickpath.indexOf('brushMod2') === -1) {
if (clickpath.indexOf('eui') === -1) {
if (selectBox.isSelected) {
editor_mode.onmode('');

View File

@ -264,6 +264,10 @@
<option value="functions">脚本编辑</option>
<option value="appendpic">追加素材</option>
</select>
<select id="brushMod">
<option value="line">画线</option>
<option value="rectangle">画矩形</option>
</select>
<br>
<select id="selectFloor"></select>
<input type="button" value="保存地图" id='saveFloor'/>

View File

@ -236,8 +236,10 @@
<option value="tower">全塔属性</option>
<option value="functions">脚本编辑</option>
<option value="appendpic">追加素材</option>
</select>
<br><br><br><br>
</select><br>
<input type="radio" id="brushMod" name="brushMod" value="line" checked="checked" />画线
<input type="radio" id="brushMod2" name="brushMod" value="rectangle" />画矩形
<br><br><br>
<select id="selectFloor"></select>
<input type="button" value="保存地图" id='saveFloor'/>
<!-- -->