searchUsedFlags

This commit is contained in:
ckcz123 2019-10-26 11:00:58 +08:00
parent 9115ab2b7c
commit 6b7300325d
5 changed files with 64 additions and 10 deletions

View File

@ -188,6 +188,11 @@ editor.prototype.init = function (callback) {
for (var floorId in editor.main.floors) {
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 (Boolean(callback)) callback();

View File

@ -484,7 +484,7 @@ editor_ui_wrapper = function (editor) {
uievent.mode = 'searchUsedFlags';
uievent.elements.selectPoint.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.selectFloor.style.display = 'none';
uievent.elements.selectPointBox.style.display = 'none';
@ -495,7 +495,7 @@ editor_ui_wrapper = function (editor) {
// build flags
var html = "";
Object.keys(editor.used_flags).forEach(function (v) {
Object.keys(editor.used_flags).sort().forEach(function (v) {
v = "flag:" + v;
html += "<option value='" + v + "'>" + v + "</option>";
});
@ -508,13 +508,59 @@ editor_ui_wrapper = function (editor) {
var flag = uievent.elements.usedFlags.value;
var html = "<p style='margin-left: 10px'>该变量出现的所有位置如下:</p><ul>";
for (var i = 0; i <= 100; ++i) {
html += "<li>MT1层(0,0)的events</li>";
}
var list = uievent._searchUsedFlags(flag);
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>";
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;
}

View File

@ -218,7 +218,8 @@
<input class="color" id="colorPicker" value="255,215,0,1"/>
<button onclick="confirmColor()">确定</button>
</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>
</h3>
@ -538,6 +539,7 @@
<option value="#000000">黑色</option>
<option value="#FFFFFF">白色</option>
</select>
<select id="uieventUsedFlags" style="margin-left: 10px; display: none" onchange="editor.uievent.doSearchUsedFlags()"></select>
<button id="uieventNo">关闭</button>
<button id="uieventYes">确定</button>
</div>
@ -545,6 +547,7 @@
<div id='uieventBody'>
<canvas class='gameCanvas' id='uievent' width='416' height='416'></canvas>
<div id="selectPointBox"></div>
<div id="uieventUsedFlagList" style="display: none"></div>
</div>
<div id="selectPoint">
<select id="selectPointFloor"></select>

View File

@ -521,7 +521,7 @@
<option value="#000000">黑色</option>
<option value="#FFFFFF">白色</option>
</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="uieventYes">确定</button>
</div>
@ -529,7 +529,7 @@
<div id='uieventBody'>
<canvas class='gameCanvas' id='uievent' width='416' height='416'></canvas>
<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 id="selectPoint">
<select id="selectPointFloor"></select>

View File

@ -4,7 +4,7 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 =
"加点事件": [
{
"type": "comment",
"text": "通过传参flag:arg1表示当前应该的加点数值"
"text": "通过传参flag:arg1 表示当前应该的加点数值"
},
{
"type": "choices",
@ -45,7 +45,7 @@ var events_c12a15a8_c380_4b28_8144_256cba95f760 =
"毒衰咒处理": [
{
"type": "comment",
"text": "获得毒衰咒效果flag:arg1为要获得的类型"
"text": "获得毒衰咒效果flag:arg1 为要获得的类型"
},
{
"type": "switch",