diff --git a/_server/editor.js b/_server/editor.js index 8704fea1..6f282c4c 100644 --- a/_server/editor.js +++ b/_server/editor.js @@ -423,6 +423,7 @@ editor.prototype.setLastUsedType = function (type) { editor.prototype.updateLastUsedMap = function () { var lastUsed = editor.uivalues.lastUsed.sort(function (a, b) { + if ((a.istop || 0) != (b.istop || 0)) return (b.istop || 0) - (a.istop || 0); return (b[editor.uivalues.lastUsedType] || 0) - (a[editor.uivalues.lastUsedType] || 0); }); @@ -430,6 +431,7 @@ editor.prototype.updateLastUsedMap = function () { var ctx = editor.dom.lastUsedCtx; ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height); ctx.strokeStyle = 'rgba(255,128,0,0.85)'; + ctx.fillStyle = 'rgba(255,0,0,0.85)'; ctx.lineWidth = 4; for (var i = 0; i < lastUsed.length; ++i) { try { @@ -444,6 +446,9 @@ editor.prototype.updateLastUsedMap = function () { var per_height = info.images.endsWith('48') ? 48 : 32; ctx.drawImage(core.material.images[info.images], 0, info.y * per_height, 32, per_height, x * 32, y * 32, 32, 32); } + if (info.istop) { + ctx.fillRect(32 * x, 32 * y + 24, 8, 8); + } if (selectBox.isSelected() && editor.info.id == info.id) { ctx.strokeRect(32 * x + 2, 32 * y + 2, 28, 28); } diff --git a/_server/editor_listen.js b/_server/editor_listen.js index 7fff8ff5..f5994f4e 100644 --- a/_server/editor_listen.js +++ b/_server/editor_listen.js @@ -35,6 +35,7 @@ editor_listen_wrapper = function (editor) { editor.dom.clearLoc.onmousedown = editor.uifunctions.clearLoc_click editor.dom.lastUsed.onmousedown = editor.uifunctions.lastUsed_click; + editor.dom.lastUsed.oncontextmenu = function (e) { e.preventDefault(); } editor.dom.clearLastUsedBtn.onclick = editor.uifunctions.clearLastUsedBtn_click; editor.dom.lockMode.onchange = editor.uifunctions.lockMode_onchange; diff --git a/_server/editor_mappanel.js b/_server/editor_mappanel.js index e84a600d..f6c7687c 100644 --- a/_server/editor_mappanel.js +++ b/_server/editor_mappanel.js @@ -792,21 +792,33 @@ editor_mappanel_wrapper = function (editor) { var index = x + core.__SIZE__ * y; if (index >= editor.uivalues.lastUsed.length) return; var lastUsed = editor.uivalues.lastUsed.sort(function (a, b) { + if ((a.istop || 0) != (b.istop || 0)) return (b.istop || 0) - (a.istop || 0); return (b[editor.uivalues.lastUsedType] || 0) - (a[editor.uivalues.lastUsedType] || 0); }); + + if (e.button == 2) { + lastUsed[index].istop = lastUsed[index].istop ? 0 : 1; + printf("已"+(lastUsed[index].istop ? '置顶' : '取消置顶')+"该图块"); + editor.config.set('lastUsed', editor.uivalues.lastUsed); + editor.updateLastUsedMap(); + return false; + } var one = Object.assign({}, lastUsed[index]); delete one['recent']; delete one['frequent']; + delete one['istop']; editor.setSelectBoxFromInfo(one); - return; + return false; } editor.uifunctions.clearLastUsedBtn_click = function () { if (editor.isMobile) return; - - editor.uivalues.lastUsed = []; - editor.config.set('lastUsed', []); - editor.updateLastUsedMap(); + + if (confirm("你确定要清理全部最近使用图块么?\n所有最近使用和最常使用图块(含置顶图块)都将被清除;此过程不可逆!")) { + editor.uivalues.lastUsed = []; + editor.config.set('lastUsed', []); + editor.updateLastUsedMap(); + } } ///////////////////////////////////////////////////////////////////////////// diff --git a/editor.html b/editor.html index fda967c7..c5dcf5b9 100644 --- a/editor.html +++ b/editor.html @@ -366,7 +366,7 @@
-

(Ctrl+滚轮放缩)

+

(Ctrl+滚轮放缩,右键置顶)