searchUsedFlags
This commit is contained in:
parent
9115ab2b7c
commit
6b7300325d
@ -188,6 +188,11 @@ editor.prototype.init = function (callback) {
|
|||||||
for (var floorId in editor.main.floors) {
|
for (var floorId in editor.main.floors) {
|
||||||
editor.addUsedFlags(JSON.stringify(editor.main.floors[floorId]));
|
editor.addUsedFlags(JSON.stringify(editor.main.floors[floorId]));
|
||||||
}
|
}
|
||||||
|
if (events_c12a15a8_c380_4b28_8144_256cba95f760.commonEvent) {
|
||||||
|
for (var name in events_c12a15a8_c380_4b28_8144_256cba95f760.commonEvent) {
|
||||||
|
editor.addUsedFlags(JSON.stringify(events_c12a15a8_c380_4b28_8144_256cba95f760.commonEvent[name]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (editor.useCompress == null) editor.useCompress = useCompress;
|
if (editor.useCompress == null) editor.useCompress = useCompress;
|
||||||
if (Boolean(callback)) callback();
|
if (Boolean(callback)) callback();
|
||||||
|
|||||||
@ -484,7 +484,7 @@ editor_ui_wrapper = function (editor) {
|
|||||||
uievent.mode = 'searchUsedFlags';
|
uievent.mode = 'searchUsedFlags';
|
||||||
uievent.elements.selectPoint.style.display = 'none';
|
uievent.elements.selectPoint.style.display = 'none';
|
||||||
uievent.elements.yes.style.display = 'none';
|
uievent.elements.yes.style.display = 'none';
|
||||||
uievent.elements.title.innerText = '搜索变量出现的位置';
|
uievent.elements.title.innerText = '搜索变量';
|
||||||
uievent.elements.selectBackground.style.display = 'none';
|
uievent.elements.selectBackground.style.display = 'none';
|
||||||
uievent.elements.selectFloor.style.display = 'none';
|
uievent.elements.selectFloor.style.display = 'none';
|
||||||
uievent.elements.selectPointBox.style.display = 'none';
|
uievent.elements.selectPointBox.style.display = 'none';
|
||||||
@ -495,7 +495,7 @@ editor_ui_wrapper = function (editor) {
|
|||||||
|
|
||||||
// build flags
|
// build flags
|
||||||
var html = "";
|
var html = "";
|
||||||
Object.keys(editor.used_flags).forEach(function (v) {
|
Object.keys(editor.used_flags).sort().forEach(function (v) {
|
||||||
v = "flag:" + v;
|
v = "flag:" + v;
|
||||||
html += "<option value='" + v + "'>" + v + "</option>";
|
html += "<option value='" + v + "'>" + v + "</option>";
|
||||||
});
|
});
|
||||||
@ -508,13 +508,59 @@ editor_ui_wrapper = function (editor) {
|
|||||||
var flag = uievent.elements.usedFlags.value;
|
var flag = uievent.elements.usedFlags.value;
|
||||||
|
|
||||||
var html = "<p style='margin-left: 10px'>该变量出现的所有位置如下:</p><ul>";
|
var html = "<p style='margin-left: 10px'>该变量出现的所有位置如下:</p><ul>";
|
||||||
for (var i = 0; i <= 100; ++i) {
|
var list = uievent._searchUsedFlags(flag);
|
||||||
html += "<li>MT1层(0,0)的events</li>";
|
list.forEach(function (v) {
|
||||||
}
|
var x = "<li>";
|
||||||
|
if (v[0] != null) x += v[0] + "层 ";
|
||||||
|
else x += "公共事件 ";
|
||||||
|
x += v[1];
|
||||||
|
if (v[2] != null) x += " 的 (" + v[2] + ") 点";
|
||||||
|
x += "</li>";
|
||||||
|
html += x;
|
||||||
|
});
|
||||||
html += "</ul>";
|
html += "</ul>";
|
||||||
uievent.elements.usedFlagList.innerHTML = html;
|
uievent.elements.usedFlagList.innerHTML = html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hasUsedFlags = function (obj, flag) {
|
||||||
|
if (obj == null) return false;
|
||||||
|
if (typeof obj != 'string') return hasUsedFlags(JSON.stringify(obj), flag);
|
||||||
|
|
||||||
|
var index = -1, length = flag.length;
|
||||||
|
while (true) {
|
||||||
|
index = obj.indexOf(flag, index + 1);
|
||||||
|
if (index < 0) return false;
|
||||||
|
if (!/^[a-zA-Z0-9_\u4E00-\u9FCC]$/.test(obj.charAt(index + length))) return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uievent._searchUsedFlags = function (flag) {
|
||||||
|
var list = [];
|
||||||
|
var events = ["events", "autoEvent", "changeFloor", "afterBattle", "afterGetItem", "afterOpenDoor"]
|
||||||
|
for (var floorId in core.floors) {
|
||||||
|
var floor = core.floors[floorId];
|
||||||
|
if (hasUsedFlags(floor.firstArrive, flag)) list.push([floorId, "firstArrive"]);
|
||||||
|
if (hasUsedFlags(floor.eachArrive, flag)) list.push([floorId, "eachArrive"]);
|
||||||
|
events.forEach(function (e) {
|
||||||
|
if (floor[e]) {
|
||||||
|
for (var loc in floor[e]) {
|
||||||
|
if (hasUsedFlags(floor[e][loc], flag)) {
|
||||||
|
list.push([floorId, e, loc]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
// 公共事件
|
||||||
|
if (core.events.commonEvent) {
|
||||||
|
for (var name in core.events.commonEvent) {
|
||||||
|
if (hasUsedFlags(core.events.commonEvent[name], flag))
|
||||||
|
list.push([null, name]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
editor.constructor.prototype.uievent=uievent;
|
editor.constructor.prototype.uievent=uievent;
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -218,7 +218,8 @@
|
|||||||
<input class="color" id="colorPicker" value="255,215,0,1"/>
|
<input class="color" id="colorPicker" value="255,215,0,1"/>
|
||||||
<button onclick="confirmColor()">确定</button>
|
<button onclick="confirmColor()">确定</button>
|
||||||
</div>
|
</div>
|
||||||
<button class="cpPanel" onclick="editor_blockly.selectPoint()">选点</button>
|
<button class="cpPanel" onclick="editor_blockly.selectPoint()">地图选点</button>
|
||||||
|
<button class="cpPanel" onclick="editor.uievent.searchUsedFlags()" style="margin-left:5px">变量搜索</button>
|
||||||
<xml id="toolbox" style="display:none">
|
<xml id="toolbox" style="display:none">
|
||||||
</xml>
|
</xml>
|
||||||
</h3>
|
</h3>
|
||||||
@ -538,6 +539,7 @@
|
|||||||
<option value="#000000">黑色</option>
|
<option value="#000000">黑色</option>
|
||||||
<option value="#FFFFFF">白色</option>
|
<option value="#FFFFFF">白色</option>
|
||||||
</select>
|
</select>
|
||||||
|
<select id="uieventUsedFlags" style="margin-left: 10px; display: none" onchange="editor.uievent.doSearchUsedFlags()"></select>
|
||||||
<button id="uieventNo">关闭</button>
|
<button id="uieventNo">关闭</button>
|
||||||
<button id="uieventYes">确定</button>
|
<button id="uieventYes">确定</button>
|
||||||
</div>
|
</div>
|
||||||
@ -545,6 +547,7 @@
|
|||||||
<div id='uieventBody'>
|
<div id='uieventBody'>
|
||||||
<canvas class='gameCanvas' id='uievent' width='416' height='416'></canvas>
|
<canvas class='gameCanvas' id='uievent' width='416' height='416'></canvas>
|
||||||
<div id="selectPointBox"></div>
|
<div id="selectPointBox"></div>
|
||||||
|
<div id="uieventUsedFlagList" style="display: none"></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="selectPoint">
|
<div id="selectPoint">
|
||||||
<select id="selectPointFloor"></select>
|
<select id="selectPointFloor"></select>
|
||||||
|
|||||||
@ -521,7 +521,7 @@
|
|||||||
<option value="#000000">黑色</option>
|
<option value="#000000">黑色</option>
|
||||||
<option value="#FFFFFF">白色</option>
|
<option value="#FFFFFF">白色</option>
|
||||||
</select>
|
</select>
|
||||||
<select id="uieventUsedFlags" style="margin-left: 20px; display: none"></select>
|
<select id="uieventUsedFlags" style="margin-left: 10px; display: none" onchange="editor.uievent.doSearchUsedFlags()"></select>
|
||||||
<button id="uieventNo">关闭</button>
|
<button id="uieventNo">关闭</button>
|
||||||
<button id="uieventYes">确定</button>
|
<button id="uieventYes">确定</button>
|
||||||
</div>
|
</div>
|
||||||
@ -529,7 +529,7 @@
|
|||||||
<div id='uieventBody'>
|
<div id='uieventBody'>
|
||||||
<canvas class='gameCanvas' id='uievent' width='416' height='416'></canvas>
|
<canvas class='gameCanvas' id='uievent' width='416' height='416'></canvas>
|
||||||
<div id="selectPointBox"></div>
|
<div id="selectPointBox"></div>
|
||||||
<div id="uieventUsedFlagList" style="display: none; overflow: auto" onchange="editor.uievent.doSearchUsedFlags()"></div>
|
<div id="uieventUsedFlagList" style="display: none"></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="selectPoint">
|
<div id="selectPoint">
|
||||||
<select id="selectPointFloor"></select>
|
<select id="selectPointFloor"></select>
|
||||||
|
|||||||
@ -4,7 +4,7 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 =
|
|||||||
"加点事件": [
|
"加点事件": [
|
||||||
{
|
{
|
||||||
"type": "comment",
|
"type": "comment",
|
||||||
"text": "通过传参,flag:arg1表示当前应该的加点数值"
|
"text": "通过传参,flag:arg1 表示当前应该的加点数值"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "choices",
|
"type": "choices",
|
||||||
@ -45,7 +45,7 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 =
|
|||||||
"毒衰咒处理": [
|
"毒衰咒处理": [
|
||||||
{
|
{
|
||||||
"type": "comment",
|
"type": "comment",
|
||||||
"text": "获得毒衰咒效果,flag:arg1为要获得的类型"
|
"text": "获得毒衰咒效果,flag:arg1 为要获得的类型"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "switch",
|
"type": "switch",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user