autoEvent

This commit is contained in:
YouWei Zhao 2019-10-19 18:43:17 +08:00
parent 5305533da9
commit 1fd3bf657d
6 changed files with 45 additions and 7 deletions

View File

@ -452,7 +452,8 @@ editor_file = function (editor, callback) {
checkCallback(callback);
if (isset(actionList) && actionList.length > 0) {
actionList.forEach(function (value) {
value[1] = value[1] + "['" + x + "," + y + "']";
if(/\['autoEvent'\]\['\d+'\]$/.test(value[1]))value[1]=value[1].replace(/\['\d+'\]$/,function(v){return "['" + x + "," + y + "']"+v})
else value[1] = value[1] + "['" + x + "," + y + "']";
});
saveSetting('floorloc', actionList, function (err) {
callback([err]);
@ -821,7 +822,13 @@ editor_file = function (editor, callback) {
if (file == 'floorloc') {
actionList.forEach(function (value) {
// 检测null/undefined
if (value[2]==null)
if(/\['autoEvent'\]\['\d+,\d+'\]\['\d+'\]$/.test(value[1])){
var tempvalue=value[1].replace(/\['\d+'\]$/,'')
tempvalue="editor.currentFloorData" +tempvalue
tempvalue=tempvalue+'='+tempvalue+'||{}'
eval(tempvalue)
}
if (value[2]==null && value[0]!=='add')
eval("delete editor.currentFloorData" + value[1]);
else
eval("editor.currentFloorData" + value[1] + '=' + JSON.stringify(value[2]));

View File

@ -146,6 +146,9 @@ editor_game_wrapper = function (editor, main, core) {
});
editor.currentFloorId = core.status.floorId;
editor.currentFloorData = core.floors[core.status.floorId];
// 补出缺省的数据
editor.currentFloorData.autoEvent = editor.currentFloorData.autoEvent || {};
//
for (var ii = 0, name; name = ['bgmap', 'fgmap'][ii]; ii++) {
var mapArray = editor.currentFloorData[name];
if (!mapArray || JSON.stringify(mapArray) == JSON.stringify([])) {//未设置或空数组

View File

@ -145,6 +145,7 @@ editor_table_wrapper = function (editor) {
if (key === '_data') continue;
if (cobj[key] instanceof Function) cobj[key] = cobj[key](args);
}
vobj = args.vobj;
// 标记为_hide的属性不展示
if (cobj._hide) continue;
if (!cobj._leaf) {
@ -340,9 +341,19 @@ editor_table_wrapper = function (editor) {
var mode = editor.dom.editModeSelect.value;
// 1.输入id
var newid = prompt('请输入新项的ID仅公共事件支持中文ID');
if (newid == null || newid.length == 0) {
return;
var newid = '3';
if (mode == 'loc') {
var ae = editor.currentFloorData.autoEvent[editor_mode.pos.x + ',' + editor_mode.pos.x];
if (ae != null) {
var testid;
for (testid = 3; Object.hasOwnProperty.call(ae, testid); testid++); // 从3开始是因为comment中设置了始终显示012
newid = testid + '';
}
} else {
newid = prompt('请输入新项的ID仅公共事件支持中文ID');
if (newid == null || newid.length == 0) {
return;
}
}
// 检查commentEvents

View File

@ -464,6 +464,23 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_type": "textarea",
"_range": "thiseval==null||(thiseval instanceof Array)",
"_data": "该点不可通行的方向 \n 可以在这里定义该点不能前往哪个方向,可以达到悬崖之类的效果\n例如 [\"up\", \"left\"] 代表该点不能往上和左走"
},
"autoEvent": {
"_type": "object",
"_leaf": false,
"_action": function (args) {
args.vobj=args.vobj||{};
for(var ii=0;ii<3;ii++){
args.vobj[ii]=null;
}
},
"_data": function (key) {
return {
"_leaf": true,
"_type": "textarea",
"_data": "自动事件"
}
}
}
}
}

View File

@ -101,7 +101,7 @@
</div>
</div>
<div id="left2" class='leftTab' style="z-index:-1;opacity: 0;"><!-- loc -->
<h3 class="leftTabHeader">地图选点&nbsp;&nbsp;<button onclick="editor.mode.onmode('save')">保存</button>&nbsp;&nbsp;<button onclick="editor_multi.editCommentJs('loc')">配置表格</button>
<h3 class="leftTabHeader">地图选点&nbsp;&nbsp;<button onclick="editor.mode.onmode('save')">保存</button>&nbsp;&nbsp;<button onclick="editor.mode.changeDoubleClickModeByButton('add')">添加</button>&nbsp;&nbsp;<button onclick="editor.mode.changeDoubleClickModeByButton('delete')">删除</button>&nbsp;&nbsp;<button onclick="editor_multi.editCommentJs('loc')">配置表格</button>
</h3>
<div class="leftTabContent">
<p id='pos_a6771a78_a099_417c_828f_0a24851ebfce' style="margin-left: 15px">0,0</p>

View File

@ -97,7 +97,7 @@
</div>
</div>
<div id="left2" class='leftTab' style="z-index:-1;opacity: 0;"><!-- loc -->
<h3 class="leftTabHeader">地图选点&nbsp;&nbsp;<button onclick="editor.mode.onmode('save')">保存</button>&nbsp;&nbsp;<button onclick="editor_multi.editCommentJs('loc')">配置表格</button>
<h3 class="leftTabHeader">地图选点&nbsp;&nbsp;<button onclick="editor.mode.onmode('save')">保存</button>&nbsp;&nbsp;<button onclick="editor.mode.changeDoubleClickModeByButton('add')">添加</button>&nbsp;&nbsp;<button onclick="editor.mode.changeDoubleClickModeByButton('delete')">删除</button>&nbsp;&nbsp;<button onclick="editor_multi.editCommentJs('loc')">配置表格</button>
</h3>
<div class="leftTabContent">
<p id='pos_a6771a78_a099_417c_828f_0a24851ebfce' style="margin-left: 15px">0,0</p>