diff --git a/_server/CodeMirror/defs.js b/_server/CodeMirror/defs.js index b1e7e7bc..38f330da 100644 --- a/_server/CodeMirror/defs.js +++ b/_server/CodeMirror/defs.js @@ -1748,6 +1748,17 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [ "!type": "number", "!doc": "窗口宽度的一半,为6或7" }, + "floorIds": { + "!type": "[string]", + "!doc": "全部楼层ID列表" + }, + "floors": { + "!doc": "全部楼层信息" + }, + "floorPartitions": { + "!type": "[[string]]", + "!doc": "楼层分区信息" + }, "material": { "!doc": "游戏所用到的资源", "animates": { @@ -3990,6 +4001,10 @@ var terndefs_f6783a0a_522d_417e_8407_94c67b692e50 = [ "!doc": "恢复某一些被删除楼层。
fromId: 开始恢复的楼层ID
toId: 恢复到的楼层编号;可选,不填则视为fromId
例如:core.resumeMaps(\"MT1\", \"MT300\") 恢复MT1~MT300之间的全部层
core.resumeMaps(\"MT10\") 只删恢复MT10层", "!type": "fn(fromId: string, toId?: string)" }, + "autoRemoveMaps": { + "!doc": "根据楼层分区信息自动砍层与恢复", + "!type": "fn(floorId: string)" + }, "openItemShop": { "!doc": "打开一个道具商店", "!type": "fn(itemShopId: string)" diff --git a/_server/MotaAction.g4 b/_server/MotaAction.g4 index bddd4771..9a5f35ac 100644 --- a/_server/MotaAction.g4 +++ b/_server/MotaAction.g4 @@ -387,6 +387,42 @@ var code = '{"title": "'+EvalString_0+'", "name": "'+EvalString_1+'", "hard": '+ return code; */; +floorPartition_m + : '高层塔分区管理' BGNL? floorPartitionList+ BEND + + +/* floorPartition_m +tooltip : 高层塔分区管理 +helpUrl : /_docs/#/instruction +var code = '[\n'+floorPartitionList_0+']\n'; +return code; +*/; + +floorPartitionList + : floorPartitionItem + | floorPartitionEmpty; + +floorPartitionEmpty + : Newline + +/* floorPartitionEmpty +var code = ' \n'; +return code; +*/; + +floorPartitionItem + : '分区项' '起始楼层ID' IdString '终止楼层ID(不填代表到最后一层)' IdString? BEND + +/* floorPartitionItem +tooltip : 难度分歧项 +helpUrl : /_docs/#/instruction +default : ['MTx',''] +IdString_1 = IdString_1 ? (', "'+IdString_1+'"') : ''; +var code = '["'+IdString_0+'"'+IdString_1+'],\n'; +return code; +*/; + + // equip 事件编辑器入口之一 equip_m : '装备' '类型' EvalString '装备动画(第一个装备格有效)' IdString? BGNL? '数值提升项' equipList+ '百分比提升项' equipList+ BEND diff --git a/_server/MotaActionParser.js b/_server/MotaActionParser.js index 7e72a2a8..354ce6bd 100644 --- a/_server/MotaActionParser.js +++ b/_server/MotaActionParser.js @@ -58,6 +58,14 @@ ActionParser.prototype.parse = function (obj,type) { } return MotaActionBlocks['levelChoose_m'].xmlText([text_choices]); + case 'floorPartition': + if(!obj) obj=[]; + var text_choices = null; + for(var ii=obj.length-1,choice;choice=obj[ii];ii--) { + text_choices=MotaActionBlocks['floorPartitionItem'].xmlText([obj[0], obj[1]||"", text_choices]); + } + return MotaActionBlocks['floorPartition_m'].xmlText([text_choices]); + case 'equip': if(!obj) obj={}; var buildEquip = function (obj) { diff --git a/_server/editor_blocklyconfig.js b/_server/editor_blocklyconfig.js index fa525b62..36452a2c 100644 --- a/_server/editor_blocklyconfig.js +++ b/_server/editor_blocklyconfig.js @@ -65,6 +65,9 @@ editor_blocklyconfig=(function(){ MotaActionBlocks['firstArrive_m'].xmlText(), MotaActionBlocks['eachArrive_m'].xmlText(), MotaActionBlocks['level_m'].xmlText(), + MotaActionFunctions.actionParser.parse([ + ['MTx', ''] + ], 'floorPartition'), MotaActionBlocks['commonEvent_m'].xmlText(), MotaActionBlocks['item_m'].xmlText(), MotaActionFunctions.actionParser.parse([ diff --git a/_server/table/data.comment.js b/_server/table/data.comment.js index 80e51f03..33a5e8fd 100644 --- a/_server/table/data.comment.js +++ b/_server/table/data.comment.js @@ -18,6 +18,13 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_docs": "楼层列表", "_data": "在这里按顺序放所有的楼层;其顺序直接影响到楼层传送器、浏览地图和上/下楼器的顺序" }, + "floorPartitions": { + "_leaf": true, + "_type": "event", + "_event": "floorPartition", + "_docs": "分区指定", + "_data": "可以在这里指定楼层分区;主要适用于不可返回的高层塔;进入新分区后将自动调用砍层插件以减少空间消耗;未在任何分区的楼层将被视为公共区域" + }, "images": { "_leaf": true, "_type": "material", diff --git a/main.js b/main.js index dff0a79f..70affa7a 100644 --- a/main.js +++ b/main.js @@ -236,7 +236,7 @@ main.prototype.init = function (mode, callback) { main.loadFloors(function() { var coreData = {}; ["dom", "statusBar", "canvas", "images", "tilesets", "materials", - "animates", "bgms", "sounds", "floorIds", "floors"].forEach(function (t) { + "animates", "bgms", "sounds", "floorIds", "floors", "floorPartitions"].forEach(function (t) { coreData[t] = main[t]; }) main.core.init(coreData, callback); diff --git a/project/data.js b/project/data.js index 78647a8c..78ebc976 100644 --- a/project/data.js +++ b/project/data.js @@ -8,6 +8,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "sample3", "MT0" ], + "floorPartitions": [], "images": [ "bg.jpg", "winskin.png", @@ -79,8 +80,18 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d = "statusLeftBackground": "url(project/materials/ground.png) repeat", "statusTopBackground": "url(project/materials/ground.png) repeat", "toolsBackground": "url(project/materials/ground.png) repeat", - "borderColor": [204,204,204,1], - "statusBarColor": [255,255,255,1], + "borderColor": [ + 204, + 204, + 204, + 1 + ], + "statusBarColor": [ + 255, + 255, + 255, + 1 + ], "floorChangingStyle": "background-color: black; color: white", "font": "Verdana" } diff --git a/project/functions.js b/project/functions.js index 759eb1d5..a4e655a3 100644 --- a/project/functions.js +++ b/project/functions.js @@ -110,6 +110,9 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a = // core.deleteAllCanvas(); // } + // 根据分区信息自动砍层与恢复 + if (core.autoRemoveMaps) core.autoRemoveMaps(floorId); + // 重置画布尺寸 core.maps.resizeMap(floorId); // 设置勇士的位置 diff --git a/project/plugins.js b/project/plugins.js index 03f95f04..8db2f343 100644 --- a/project/plugins.js +++ b/project/plugins.js @@ -252,10 +252,12 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = var fromIndex = core.floorIds.indexOf(fromId), toIndex = core.floorIds.indexOf(toId); if (toIndex < 0) toIndex = core.floorIds.length - 1; + flags.__visited__ = flags.__visited__ || {}; flags.__removed__ = flags.__removed__ || []; - flags.__disabled__ = flags.__disabled__ || []; + flags.__disabled__ = flags.__disabled__ || {}; for (var i = fromIndex; i <= toIndex; ++i) { var floorId = core.floorIds[i]; + if (core.status.maps[floorId].deleted) continue; delete flags.__visited__[floorId]; flags.__removed__.push(floorId); delete flags.__disabled__[floorId]; @@ -276,12 +278,43 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 = flags.__removed__ = flags.__removed__ || []; for (var i = fromIndex; i <= toIndex; ++i) { var floorId = core.floorIds[i]; + if (!core.status.maps[floorId].deleted) continue; flags.__removed__ = flags.__removed__.filter(function (f) { return f != floorId; }); - if (core.status.maps[floorId].deleted) { - core.status.maps[floorId] = core.loadFloor(floorId); - } + core.status.maps[floorId] = core.loadFloor(floorId); } } + + // 分区砍层相关 + var inAnyPartition = function (floorId) { + var inPartition = false; + (core.floorPartitions || []).forEach(function (floor) { + var fromIndex = core.floorIds.indexOf(floor[0]); + var toIndex = core.floorIds.indexOf(floor[1]); + var index = core.floorIds.indexOf(floorId); + if (fromIndex < 0 || index < 0) return; + if (toIndex < 0) toIndex = core.floorIds.length - 1; + if (index >= fromIndex && index <= toIndex) inPartition = true; + }); + return inPartition; + } + + // 分区砍层 + this.autoRemoveMaps = function (floorId) { + if (main.mode != 'play' || !inAnyPartition(floorId)) return; + // 根据分区信息自动砍层与恢复 + (core.floorPartitions || []).forEach(function (floor) { + var fromIndex = core.floorIds.indexOf(floor[0]); + var toIndex = core.floorIds.indexOf(floor[1]); + var index = core.floorIds.indexOf(floorId); + if (fromIndex < 0 || index < 0) return; + if (toIndex < 0) toIndex = core.floorIds.length - 1; + if (index >= fromIndex && index <= toIndex) { + core.resumeMaps(core.floorIds[fromIndex], core.floorIds[toIndex]); + } else { + core.removeMaps(core.floorIds[fromIndex], core.floorIds[toIndex]); + } + }); + } }, "fiveLayers": function () { // 是否启用五图层(增加背景2层和前景2层) 将__enableFiveLayers置为true即会启用;启用后请保存后刷新编辑器