填充模式

This commit is contained in:
ckcz123 2020-05-15 19:51:27 +08:00
parent efbf3ae3a6
commit 32cadcc280
10 changed files with 61 additions and 9 deletions

View File

@ -170,7 +170,7 @@ body {
#tip {
float: right;
width: 50%;
width: 48%;
height: 95%;
padding: 5px 10px 10px 10px;
margin-right: 0;

View File

@ -26,6 +26,7 @@ function editor() {
brushMod:document.getElementById('brushMod'),
brushMod2:document.getElementById('brushMod2'),
brushMod3:document.getElementById('brushMod3'),
brushMod4:document.getElementById('brushMod4'),
bgc : document.getElementById('bg'),
bgCtx : document.getElementById('bg').getContext('2d'),
fgc : document.getElementById('fg'),

View File

@ -544,7 +544,7 @@ editor_datapanel_wrapper = function (editor) {
});
// Step 3:更新所有坐标
["afterBattle", "afterGetItem", "afterOpenDoor", "changeFloor", "autoEvent", "cannotMove"].forEach(function (name) {
["events", "afterBattle", "afterGetItem", "afterOpenDoor", "changeFloor", "autoEvent", "cannotMove"].forEach(function (name) {
newFloorData[name] = {};
if (!currentFloorData[name]) return;
for (var loc in currentFloorData[name]) {
@ -564,8 +564,14 @@ editor_datapanel_wrapper = function (editor) {
}
});
console.log(currentFloorData);
console.log(newFloorData);
editor.file.saveFloor(newFloorData, function (err) {
if (err) {
printe(err);
throw(err)
}
;alert('地图更改大小成功,即将刷新地图...\n请检查所有点的事件是否存在问题。');
window.location.reload();
});
}
}

View File

@ -41,6 +41,7 @@ editor_listen_wrapper = function (editor) {
editor.dom.brushMod.onchange = editor.uifunctions.brushMod_onchange
if (editor.dom.brushMod2) editor.dom.brushMod2.onchange = editor.uifunctions.brushMod2_onchange;
if (editor.dom.brushMod3) editor.dom.brushMod3.onchange = editor.uifunctions.brushMod3_onchange;
if (editor.dom.brushMod4) editor.dom.brushMod4.onchange = editor.uifunctions.brushMod4_onchange;
editor.dom.layerMod.onchange = editor.uifunctions.layerMod_onchange
if (editor.dom.layerMod2) editor.dom.layerMod2.onchange = editor.uifunctions.layerMod2_onchange;

View File

@ -247,6 +247,11 @@ editor_mappanel_wrapper = function (editor) {
editor[editor.layerMod][editor.uivalues.stepPostfix[ii].y][editor.uivalues.stepPostfix[ii].x] = editor.ids[editor.indexs[idnum + editor.uivalues.stepPostfix[ii].x - x0]];
}
} else {
// 检测是否是填充模式
if (editor.uivalues.stepPostfix.length == 1 && editor.brushMod == 'fill') {
editor.uivalues.stepPostfix = editor.uifunctions._fillMode_bfs(editor[editor.layerMod], editor.uivalues.stepPostfix[0].x, editor.uivalues.stepPostfix[0].y,
editor[editor.layerMod][0].length, editor[editor.layerMod].length);
}
for (var ii = 0; ii < editor.uivalues.stepPostfix.length; ii++)
editor[editor.layerMod][editor.uivalues.stepPostfix[ii].y][editor.uivalues.stepPostfix[ii].x] = editor.info;
}
@ -263,6 +268,32 @@ editor_mappanel_wrapper = function (editor) {
return false;
}
/**
* bfs找寻和某点相连的全部相同图块坐标
*/
editor.uifunctions._fillMode_bfs = function (array, x, y, maxWidth, maxHeight) {
var _getNumber = function (x, y) {
if (x<0 || y<0 || x>=maxWidth || y>=maxHeight) return null;
return array[y][x].idnum || array[y][x] || 0;
}
var number = _getNumber(x, y) || 0;
var visited = {}, result = [];
var list = [{x:x, y:y}];
while (list.length != 0) {
var next = list.shift(), key = next.x+","+next.y;
if (visited[key]) continue;
visited[key] = true;
result.push(next);
[[-1,0],[1,0],[0,-1],[0,1]].forEach(function (dir) {
var nx = next.x + dir[0], ny = next.y + dir[1];
if (_getNumber(nx, ny) == number) {
list.push({x: nx, y: ny});
}
});
}
return result;
}
/**
* editor.dom.mid.onmousewheel
* 在地图编辑区域滚轮切换楼层
@ -586,6 +617,11 @@ editor_mappanel_wrapper = function (editor) {
*/
editor.uifunctions.brushMod_onchange = function () {
editor.brushMod = editor.dom.brushMod.value;
if (editor.brushMod == 'fill') {
tip.isSelectedBlock(false);
tip.msgs[11] = String('填充模式下,将会用选中的素材替换所有和目标点联通的相同素材');
tip.whichShow(12);
}
}
/**
@ -612,6 +648,13 @@ editor_mappanel_wrapper = function (editor) {
editor.brushMod = editor.dom.brushMod3.value;
}
editor.uifunctions.brushMod4_onchange = function () {
tip.isSelectedBlock(false);
tip.msgs[11] = String('填充模式下,将会用选中的素材替换所有和目标点联通的相同素材');
tip.whichShow(12);
editor.brushMod = editor.dom.brushMod4.value;
}
/**
* editor.dom.layerMod.onchange
* 切换编辑的层

View File

@ -220,7 +220,7 @@ editor_ui_wrapper = function (editor) {
var clickpath = editor.uifunctions.getClickpath(e);
var unselect = true;
for (var ii = 0, thisId; thisId = ['edit', 'tip', 'brushMod', 'brushMod2', 'brushMod3', 'layerMod', 'layerMod2', 'layerMod3', 'viewportButtons'][ii]; ii++) {
for (var ii = 0, thisId; thisId = ['edit', 'tip', 'brushMod', 'brushMod2', 'brushMod3', 'brushMode4', 'layerMod', 'layerMod2', 'layerMod3', 'viewportButtons'][ii]; ii++) {
if (clickpath.indexOf(thisId) !== -1) {
unselect = false;
break;

View File

@ -101,4 +101,3 @@
background: hsl(86, 100%, 21%);
color: inherit;
}
/*# sourceMappingURL=awesomplete.css.map */

File diff suppressed because one or more lines are too long

View File

@ -384,6 +384,7 @@
<option value="line">画线</option>
<option value="rectangle">画矩形</option>
<option value="tileset">tileset贴图</option>
<option value="fill">填充模式</option>
</select>
<select id="layerMod" style="float:left;margin-right:3px">
<option value="bgmap">背景层</option>

View File

@ -341,9 +341,11 @@
<span style="font-size: 12px"><input type="checkbox" id="lockMode"/>锁定模式</span>
<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="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贴图
<input type="radio" id="brushMod4" name="brushMod" value="fill" />填充
</span>
<br/>
<span style="font-size: 12px">