From cc80dd450d3ac31403ce8427cf60005b7191f8ed Mon Sep 17 00:00:00 2001 From: ckcz123 Date: Thu, 26 Dec 2019 15:02:10 +0800 Subject: [PATCH] copy enemyitem & foldColNum & fix bug --- _server/editor.js | 8 +++++- _server/editor_datapanel.js | 50 +++++++++++++++++++++++++++++++++ _server/editor_file_unsorted.js | 2 ++ _server/editor_listen.js | 1 + _server/editor_materialpanel.js | 16 ++++++++--- _server/table/comment.js | 2 +- editor.html | 4 +++ libs/events.js | 14 ++++++--- libs/maps.js | 2 +- project/items.js | 8 +++--- 10 files changed, 92 insertions(+), 15 deletions(-) diff --git a/_server/editor.js b/_server/editor.js index 252b8e4b..a56e63a8 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -82,6 +82,12 @@ function editor() { loc: null, n: -1, enemys: [] + }, + + // 复制怪物或道具属性 + copyEnemyItem : { + type: null, + data: {} } }; @@ -402,7 +408,7 @@ editor.prototype.drawInitData = function (icons) { editor.widthsX = {}; editor.uivalues.folded = core.getLocalStorage('folded', false); // editor.uivalues.folded = true; - editor.uivalues.foldPerCol = 50; + editor.uivalues.foldPerCol = core.getLocalStorage('foldPerCol', 50); // var imgNames = Object.keys(images); //还是固定顺序吧; var imgNames = ["terrains", "animates", "enemys", "enemy48", "items", "npcs", "npc48", "autotile"]; diff --git a/_server/editor_datapanel.js b/_server/editor_datapanel.js index 08678104..7019b2e3 100644 --- a/_server/editor_datapanel.js +++ b/_server/editor_datapanel.js @@ -210,7 +210,57 @@ editor_datapanel_wrapper = function (editor) { } } + editor.uifunctions.copyPasteEnemyItem_func = function () { + var copyEnemyItem = document.getElementById('copyEnemyItem'); + var pasteEnemyItem = document.getElementById('pasteEnemyItem'); + copyEnemyItem.onclick = function () { + var cls = (editor_mode.info || {}).images; + if (editor_mode.mode != 'enemyitem' || (cls != 'enemys' && cls != 'enemy48' && cls != 'items')) return; + editor.uivalues.copyEnemyItem.type = cls; + var id = editor_mode.info.id; + if (cls == 'enemys' || cls == 'enemy48') { + editor.uivalues.copyEnemyItem.data = core.clone(enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80[id]); + printf("怪物属性复制成功"); + } else { + editor.uivalues.copyEnemyItem.data = {}; + for (var x in items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a) { + if (items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a[x][id] != null) { + editor.uivalues.copyEnemyItem.data[x] = core.clone(items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a[x][id]); + } + } + printf("道具属性复制成功"); + } + } + + pasteEnemyItem.onclick = function () { + var cls = (editor_mode.info || {}).images; + if (editor_mode.mode != 'enemyitem' || !cls || cls != editor.uivalues.copyEnemyItem.type) return; + var id = editor_mode.info.id; + if (cls == 'enemys' || cls == 'enemy48') { + if (confirm("你确定要覆盖此怪物的全部属性么?这是个不可逆操作!")) { + enemys_fcae963b_31c9_42b4_b48c_bb48d09f3f80[id] = core.clone(editor.uivalues.copyEnemyItem.data); + editor.file.saveSetting('enemys', [], function (err) { + if (err) printe(err); + else printf("怪物属性粘贴成功\n请再重新选中该怪物方可查看更新后的表格。"); + }) + } + } else { + if (confirm("你确定要覆盖此道具的全部属性么?这是个不可逆操作!")) { + for (var x in editor.uivalues.copyEnemyItem.data) { + items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a[x][id] = core.clone(editor.uivalues.copyEnemyItem.data[x]); + } + editor.file.saveSetting('items', [], function (err) { + if (err) printe(err); + else printf("道具属性粘贴成功\n请再重新选中该道具方可查看更新后的表格。"); + }) + } + } + + } + + + } diff --git a/_server/editor_file_unsorted.js b/_server/editor_file_unsorted.js index c11bd4d8..7ee709c8 100644 --- a/_server/editor_file_unsorted.js +++ b/_server/editor_file_unsorted.js @@ -897,6 +897,8 @@ editor_file = function (editor, callback) { callback('出错了,要设置的文件名不识别'); } + editor.file.saveSetting = saveSetting; + return editor_file; } //editor_file = editor_file(editor); \ No newline at end of file diff --git a/_server/editor_listen.js b/_server/editor_listen.js index dec2bc2f..1e50f6af 100644 --- a/_server/editor_listen.js +++ b/_server/editor_listen.js @@ -133,6 +133,7 @@ editor_listen_wrapper = function (editor) { editor.uifunctions.newIdIdnum_func() editor.uifunctions.changeId_func() + editor.uifunctions.copyPasteEnemyItem_func(); editor.uifunctions.selectFloor_func() editor.uifunctions.saveFloor_func() diff --git a/_server/editor_materialpanel.js b/_server/editor_materialpanel.js index 2ba50d82..2c0daabe 100644 --- a/_server/editor_materialpanel.js +++ b/_server/editor_materialpanel.js @@ -29,10 +29,18 @@ editor_materialpanel_wrapper = function (editor) { * editor.dom.iconExpandBtn.onclick */ editor.uifunctions.fold_material_click = function () { - if (confirm(editor.uivalues.folded ? "你想要展开素材吗?\n展开模式下将显示全素材内容。" - : ("你想要折叠素材吗?\n折叠模式下每个素材将仅显示单列,并且每" + editor.uivalues.foldPerCol + "个自动换列。"))) { - core.setLocalStorage('folded', !editor.uivalues.folded); - window.location.reload(); + if (editor.uivalues.folded) { + if (confirm("你想要展开素材吗?\n展开模式下将显示全素材内容。")) { + core.setLocalStorage('folded', false); + window.location.reload(); + } + } else { + var perCol = parseInt(prompt("请输入折叠素材模式下每列的个数:", "50")) || 0; + if (perCol > 0) { + core.setLocalStorage('foldPerCol', perCol); + core.setLocalStorage('folded', true); + window.location.reload(); + } } } diff --git a/_server/table/comment.js b/_server/table/comment.js index 6e549b88..20783952 100644 --- a/_server/table/comment.js +++ b/_server/table/comment.js @@ -143,7 +143,7 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = { "_leaf": true, "_type": "textarea", "_range": "thiseval==null || thiseval instanceof Array || (thiseval==~~thiseval && thiseval>=0)", - "_data": "特殊属性\n\n0:无,1:先攻,2:魔攻,3:坚固,4:2连击,\n5:3连击,6:n连击,7:破甲,8:反击,9:净化,\n10:模仿,11:吸血,12:中毒,13:衰弱,14:诅咒,\n15:领域,16:夹击,17:仇恨,18:阻击,19:自爆,\n20:无敌,21:退化,22:固伤,23:重生,24:激光,25:光环\n\n多个属性例如用[1,4,11]表示先攻2连击吸血" + "_data": "特殊属性\n\n0:无,1:先攻,2:魔攻,3:坚固,4:2连击,\n5:3连击,6:n连击,7:破甲,8:反击,9:净化,\n10:模仿,11:吸血,12:中毒,13:衰弱,14:诅咒,\n15:领域,16:夹击,17:仇恨,18:阻击,19:自爆,\n20:无敌,21:退化,22:固伤,23:重生,24:激光,25:光环\n26:支援,27:捕捉\n多个属性例如用[1,4,11]表示先攻2连击吸血" }, "value": { "_leaf": true, diff --git a/editor.html b/editor.html index 6fb22aec..b1a645f7 100644 --- a/editor.html +++ b/editor.html @@ -131,6 +131,10 @@ +
+ + +
diff --git a/libs/events.js b/libs/events.js index 1dcc3ce0..a52fce8d 100644 --- a/libs/events.js +++ b/libs/events.js @@ -976,13 +976,13 @@ events.prototype.recoverEvents = function (data) { ////// 检测自动事件 ////// events.prototype.checkAutoEvents = function () { // 只有在无操作或事件流中才能执行自动事件! - if (!core.isPlaying() || core.status.lockControl && core.status.event.id != 'action') return; + if (!core.isPlaying() || (core.status.lockControl && core.status.event.id != 'action')) return; var todo = [], delay = []; core.status.autoEvents.forEach(function (autoEvent) { var symbol = autoEvent.symbol, x = autoEvent.x, y = autoEvent.y, floorId = autoEvent.floorId; // 不在当前楼层 or 已经执行过 or 正在执行中 if (autoEvent.currentFloor && floorId != core.status.floorId) return; - if (!autoEvent.multiExecute && autoEvent.executed) return; + if (!autoEvent.multiExecute && core.autoEventExecuted(symbol)) return; if (core.autoEventExecuting(symbol)) return; var prefix = floorId + "@" + x + "@" + y; try { @@ -992,7 +992,7 @@ events.prototype.checkAutoEvents = function () { } core.autoEventExecuting(symbol, true); - autoEvent.executed = true; + core.autoEventExecuted(symbol, true); var event = [ {"type": "function", "function": @@ -1022,7 +1022,13 @@ events.prototype.checkAutoEvents = function () { events.prototype.autoEventExecuting = function (symbol, value) { var name = '_executing_autoEvent_' + symbol; - if (value == null) return core.getFlag(name, false); + if (value == null) return core.hasFlag(name); + else core.setFlag(name, value || null); +} + +events.prototype.autoEventExecuted = function (symbol, value) { + var name = '_executed_autoEvent_' + symbol; + if (value == null) return core.hasFlag(name); else core.setFlag(name, value || null); } diff --git a/libs/maps.js b/libs/maps.js index a0bdeae3..b65cd2f5 100644 --- a/libs/maps.js +++ b/libs/maps.js @@ -369,7 +369,7 @@ maps.prototype._getBgFgMapArray = function (name, floorId, noCache) { return core.status[name + "maps"][floorId]; var arr = core.clone(core.floors[floorId][name + "map"] || []); - if (main.mode == 'editor' && !(uievent && uievent.isOpen)) + if (main.mode == 'editor' && !(window.editor && editor.uievent && editor.uievent.isOpen)) arr = core.clone(editor[name + "map"]) || arr; for (var x = 0; x < width; x++) { for (var y = 0; y < height; y++) { diff --git a/project/items.js b/project/items.js index e800d30d..598488b7 100644 --- a/project/items.js +++ b/project/items.js @@ -39,22 +39,22 @@ var items_296f5d02_12fd_4166_a7c1_b5e830c9ee3a = "redPotion": { "cls": "items", "name": "红血瓶", - "text": "',生命+'+core.values.redPotion" + "text": "',生命+${core.values.redPotion}'" }, "bluePotion": { "cls": "items", "name": "蓝血瓶", - "text": "',生命+'+core.values.bluePotion" + "text": "',生命+${core.values.bluePotion}'" }, "yellowPotion": { "cls": "items", "name": "黄血瓶", - "text": "'生命+'+core.values.yellowPotion" + "text": "',生命+${core.values.yellowPotion'}" }, "greenPotion": { "cls": "items", "name": "绿血瓶", - "text": "',生命+'+core.values.greenPotion" + "text": "',生命+${core.values.greenPotion}'" }, "sword0": { "cls": "items",