填充模式
This commit is contained in:
1 parent
efbf3ae3a6
commit
32cadcc280
10 files changed
+61
-9
No files matched your search
@@ -170,7 +170,7 @@ body {
|
||||
|
||||
#tip {
|
||||
float: right;
|
||||
width: 50%;
|
||||
width: 48%;
|
||||
height: 95%;
|
||||
padding: 5px 10px 10px 10px;
|
||||
margin-right: 0;
|
||||
|
||||
@@ -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'),
|
||||
|
||||
@@ -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();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
* 切换编辑的层
|
||||
|
||||
@@ -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;
|
||||
|
||||
Vendored
-1
@@ -101,4 +101,3 @@
|
||||
background: hsl(86, 100%, 21%);
|
||||
color: inherit;
|
||||
}
|
||||
/*# sourceMappingURL=awesomplete.css.map */
|
||||
-1
@@ -1,3 +1,2 @@
|
||||
// Awesomplete - Lea Verou - MIT license
|
||||
!function(){function t(t){var e=Array.isArray(t)?{label:t[0],value:t[1]}:"object"==typeof t&&"label"in t&&"value"in t?t:{label:t,value:t};this.label=e.label||e.value,this.value=e.value}function e(t,e,i){for(var n in e){var s=e[n],r=t.input.getAttribute("data-"+n.toLowerCase());"number"==typeof s?t[n]=parseInt(r):!1===s?t[n]=null!==r:s instanceof Function?t[n]=null:t[n]=r,t[n]||0===t[n]||(t[n]=n in i?i[n]:s)}}function i(t,e){return"string"==typeof t?(e||document).querySelector(t):t||null}function n(t,e){return o.call((e||document).querySelectorAll(t))}function s(){n("input.awesomplete").forEach(function(t){new r(t)})}var r=function(t,n){var s=this;r.count=(r.count||0)+1,this.count=r.count,this.isOpened=!1,this.input=i(t),this.input.setAttribute("autocomplete","off"),this.input.setAttribute("aria-expanded","false"),this.input.setAttribute("aria-owns","awesomplete_list_"+this.count),this.input.setAttribute("role","combobox"),this.options=n=n||{},e(this,{minChars:2,maxItems:10,autoFirst:!1,data:r.DATA,filter:r.FILTER_CONTAINS,sort:!1!==n.sort&&r.SORT_BYLENGTH,container:r.CONTAINER,item:r.ITEM,replace:r.REPLACE,tabSelect:!1},n),this.index=-1,this.container=this.container(t),this.ul=i.create("ul",{hidden:"hidden",role:"listbox",id:"awesomplete_list_"+this.count,inside:this.container}),this.status=i.create("span",{className:"visually-hidden",role:"status","aria-live":"assertive","aria-atomic":!0,inside:this.container,textContent:0!=this.minChars?"Type "+this.minChars+" or more characters for results.":"Begin typing for results."}),this._events={input:{input:this.evaluate.bind(this),blur:this.close.bind(this,{reason:"blur"}),keydown:function(t){var e=t.keyCode;s.opened&&(13===e&&s.selected?(t.preventDefault(),s.select()):9===e&&s.selected&&s.tabSelect?s.select():27===e?s.close({reason:"esc"}):38!==e&&40!==e||(t.preventDefault(),s[38===e?"previous":"next"]()))}},form:{submit:this.close.bind(this,{reason:"submit"})},ul:{mousedown:function(t){t.preventDefault()},click:function(t){var e=t.target;if(e!==this){for(;e&&!/li/i.test(e.nodeName);)e=e.parentNode;e&&0===t.button&&(t.preventDefault(),s.select(e,t.target))}}}},i.bind(this.input,this._events.input),i.bind(this.input.form,this._events.form),i.bind(this.ul,this._events.ul),this.input.hasAttribute("list")?(this.list="#"+this.input.getAttribute("list"),this.input.removeAttribute("list")):this.list=this.input.getAttribute("data-list")||n.list||[],r.all.push(this)};r.prototype={set list(t){if(Array.isArray(t))this._list=t;else if("string"==typeof t&&t.indexOf(",")>-1)this._list=t.split(/\s*,\s*/);else if((t=i(t))&&t.children){var e=[];o.apply(t.children).forEach(function(t){if(!t.disabled){var i=t.textContent.trim(),n=t.value||i,s=t.label||i;""!==n&&e.push({label:s,value:n})}}),this._list=e}document.activeElement===this.input&&this.evaluate()},get selected(){return this.index>-1},get opened(){return this.isOpened},close:function(t){this.opened&&(this.input.setAttribute("aria-expanded","false"),this.ul.setAttribute("hidden",""),this.isOpened=!1,this.index=-1,this.status.setAttribute("hidden",""),i.fire(this.input,"awesomplete-close",t||{}))},open:function(){this.input.setAttribute("aria-expanded","true"),this.ul.removeAttribute("hidden"),this.isOpened=!0,this.status.removeAttribute("hidden"),this.autoFirst&&-1===this.index&&this.goto(0),i.fire(this.input,"awesomplete-open")},destroy:function(){if(i.unbind(this.input,this._events.input),i.unbind(this.input.form,this._events.form),!this.options.container){var t=this.container.parentNode;t.insertBefore(this.input,this.container),t.removeChild(this.container)}this.input.removeAttribute("autocomplete"),this.input.removeAttribute("aria-autocomplete");var e=r.all.indexOf(this);-1!==e&&r.all.splice(e,1)},next:function(){var t=this.ul.children.length;this.goto(this.index<t-1?this.index+1:t?0:-1)},previous:function(){var t=this.ul.children.length,e=this.index-1;this.goto(this.selected&&-1!==e?e:t-1)},goto:function(t){var e=this.ul.children;this.selected&&e[this.index].setAttribute("aria-selected","false"),this.index=t,t>-1&&e.length>0&&(e[t].setAttribute("aria-selected","true"),this.status.textContent=e[t].textContent+", list item "+(t+1)+" of "+e.length,this.input.setAttribute("aria-activedescendant",this.ul.id+"_item_"+this.index),this.ul.scrollTop=e[t].offsetTop-this.ul.clientHeight+e[t].clientHeight,i.fire(this.input,"awesomplete-highlight",{text:this.suggestions[this.index]}))},select:function(t,e){if(t?this.index=i.siblingIndex(t):t=this.ul.children[this.index],t){var n=this.suggestions[this.index];i.fire(this.input,"awesomplete-select",{text:n,origin:e||t})&&(this.replace(n),this.close({reason:"select"}),i.fire(this.input,"awesomplete-selectcomplete",{text:n}))}},evaluate:function(){var e=this,i=this.input.value;i.length>=this.minChars&&this._list&&this._list.length>0?(this.index=-1,this.ul.innerHTML="",this.suggestions=this._list.map(function(n){return new t(e.data(n,i))}).filter(function(t){return e.filter(t,i)}),!1!==tLine truncated
|
||||
//# sourceMappingURL=awesomplete.min.js.map
|
||||
@@ -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>
|
||||
|
||||
+4
-2
@@ -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">
|
||||
|
||||
Reference in new issue
Block a user