最近使用/最常使用图块
This commit is contained in:
parent
a62e0119fd
commit
b2de5a8a62
@ -55,6 +55,7 @@ function editor() {
|
|||||||
editModeSelect :document.getElementById('editModeSelect'),
|
editModeSelect :document.getElementById('editModeSelect'),
|
||||||
mid2 : document.getElementById('mid2'),
|
mid2 : document.getElementById('mid2'),
|
||||||
clearLastUsedBtn: document.getElementById('clearLastUsedBtn'),
|
clearLastUsedBtn: document.getElementById('clearLastUsedBtn'),
|
||||||
|
lastUsedTitle: document.getElementById('lastUsedTitle'),
|
||||||
lastUsedDiv: document.getElementById('lastUsedDiv'),
|
lastUsedDiv: document.getElementById('lastUsedDiv'),
|
||||||
lastUsed: document.getElementById('lastUsed'),
|
lastUsed: document.getElementById('lastUsed'),
|
||||||
lastUsedCtx: document.getElementById('lastUsed').getContext('2d'),
|
lastUsedCtx: document.getElementById('lastUsed').getContext('2d'),
|
||||||
@ -105,6 +106,7 @@ function editor() {
|
|||||||
lockMode: false,
|
lockMode: false,
|
||||||
|
|
||||||
// 最近使用的图块
|
// 最近使用的图块
|
||||||
|
lastUsedType: null,
|
||||||
lastUsed: [],
|
lastUsed: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -406,16 +408,33 @@ editor.prototype.updateMap = function () {
|
|||||||
this.updateLastUsedMap();
|
this.updateLastUsedMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
editor.prototype.setLastUsedType = function (type) {
|
||||||
|
if (type == editor.uivalues.lastUsedType) return;
|
||||||
|
editor.uivalues.lastUsedType = type;
|
||||||
|
var _buildHtml = function (type, text) {
|
||||||
|
if (type == null) return "<b>" + text + "</b>";
|
||||||
|
else return `<a href="javascript:editor.setLastUsedType('${type}')">${text}</a>`;
|
||||||
|
}
|
||||||
|
editor.dom.lastUsedTitle.innerHTML
|
||||||
|
= type == 'frequent' ? (_buildHtml('recent', '最近使用') + " | " + _buildHtml(null, '最常使用'))
|
||||||
|
: (_buildHtml(null, '最近使用') + " | " + _buildHtml('frequent', '最常使用'));
|
||||||
|
this.updateLastUsedMap();
|
||||||
|
}
|
||||||
|
|
||||||
editor.prototype.updateLastUsedMap = function () {
|
editor.prototype.updateLastUsedMap = function () {
|
||||||
|
var lastUsed = editor.uivalues.lastUsed.sort(function (a, b) {
|
||||||
|
return (b[editor.uivalues.lastUsedType] || 0) - (a[editor.uivalues.lastUsedType] || 0);
|
||||||
|
});
|
||||||
|
|
||||||
// 绘制最近使用事件
|
// 绘制最近使用事件
|
||||||
var ctx = editor.dom.lastUsedCtx;
|
var ctx = editor.dom.lastUsedCtx;
|
||||||
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
|
||||||
ctx.strokeStyle = 'rgba(255,128,0,0.85)';
|
ctx.strokeStyle = 'rgba(255,128,0,0.85)';
|
||||||
ctx.lineWidth = 4;
|
ctx.lineWidth = 4;
|
||||||
for (var i = 0; i < editor.uivalues.lastUsed.length; ++i) {
|
for (var i = 0; i < lastUsed.length; ++i) {
|
||||||
try {
|
try {
|
||||||
var x = i % core.__SIZE__, y = parseInt(i / core.__SIZE__);
|
var x = i % core.__SIZE__, y = parseInt(i / core.__SIZE__);
|
||||||
var info = editor.uivalues.lastUsed[i];
|
var info = lastUsed[i];
|
||||||
if (!info || !info.images) continue;
|
if (!info || !info.images) continue;
|
||||||
if (info.isTile && core.material.images.tilesets[info.images]) {
|
if (info.isTile && core.material.images.tilesets[info.images]) {
|
||||||
ctx.drawImage(core.material.images.tilesets[info.images], 32 * info.x, 32 * info.y, 32, 32, x*32, y*32, 32, 32);
|
ctx.drawImage(core.material.images.tilesets[info.images], 32 * info.x, 32 * info.y, 32, 32, x*32, y*32, 32, 32);
|
||||||
@ -458,6 +477,7 @@ editor.prototype.drawInitData = function (icons) {
|
|||||||
// editor.uivalues.folded = true;
|
// editor.uivalues.folded = true;
|
||||||
editor.uivalues.foldPerCol = editor.config.get('foldPerCol', 50);
|
editor.uivalues.foldPerCol = editor.config.get('foldPerCol', 50);
|
||||||
// var imgNames = Object.keys(images); //还是固定顺序吧;
|
// var imgNames = Object.keys(images); //还是固定顺序吧;
|
||||||
|
editor.setLastUsedType(editor.config.get('lastUsedType', 'recent'));
|
||||||
editor.uivalues.lastUsed = editor.config.get("lastUsed", []);
|
editor.uivalues.lastUsed = editor.config.get("lastUsed", []);
|
||||||
var imgNames = ["terrains", "animates", "enemys", "enemy48", "items", "npcs", "npc48", "autotile"];
|
var imgNames = ["terrains", "animates", "enemys", "enemy48", "items", "npcs", "npc48", "autotile"];
|
||||||
|
|
||||||
|
|||||||
@ -257,7 +257,17 @@ editor_mappanel_wrapper = function (editor) {
|
|||||||
}
|
}
|
||||||
// console.log(editor.map);
|
// console.log(editor.map);
|
||||||
if (editor.info.y != null) {
|
if (editor.info.y != null) {
|
||||||
editor.uivalues.lastUsed = [editor.info].concat(editor.uivalues.lastUsed.filter(function (e) { return e.id != editor.info.id}));
|
var found = false;
|
||||||
|
editor.uivalues.lastUsed.forEach(function (one) {
|
||||||
|
if (one.id == editor.info.id) {
|
||||||
|
found = true;
|
||||||
|
one.recent = new Date().getTime();
|
||||||
|
one.frequent = (one.frequent || 0) + 1;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
if (!found) {
|
||||||
|
editor.uivalues.lastUsed.push(Object.assign({}, editor.info, {recent: new Date().getTime(), frequent: 1}));
|
||||||
|
}
|
||||||
editor.config.set("lastUsed", editor.uivalues.lastUsed);
|
editor.config.set("lastUsed", editor.uivalues.lastUsed);
|
||||||
}
|
}
|
||||||
editor.updateMap();
|
editor.updateMap();
|
||||||
@ -781,7 +791,13 @@ editor_mappanel_wrapper = function (editor) {
|
|||||||
var x = parseInt(px / 32), y = parseInt(py / 32);
|
var x = parseInt(px / 32), y = parseInt(py / 32);
|
||||||
var index = x + core.__SIZE__ * y;
|
var index = x + core.__SIZE__ * y;
|
||||||
if (index >= editor.uivalues.lastUsed.length) return;
|
if (index >= editor.uivalues.lastUsed.length) return;
|
||||||
editor.setSelectBoxFromInfo(editor.uivalues.lastUsed[index]);
|
var lastUsed = editor.uivalues.lastUsed.sort(function (a, b) {
|
||||||
|
return (b[editor.uivalues.lastUsedType] || 0) - (a[editor.uivalues.lastUsedType] || 0);
|
||||||
|
});
|
||||||
|
var one = Object.assign({}, lastUsed[index]);
|
||||||
|
delete one['recent'];
|
||||||
|
delete one['frequent'];
|
||||||
|
editor.setSelectBoxFromInfo(one);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -320,7 +320,7 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div id="mid2" style="display: none">
|
<div id="mid2" style="display: none">
|
||||||
<p style="margin: 10px">最近使用的图块列表: <button id='clearLastUsedBtn'>清除</button></p>
|
<p style="margin: 10px"><span id='lastUsedTitle'></span> <button id='clearLastUsedBtn'>清除</button></p>
|
||||||
<div class="map" style="height: 160px; margin-top: 25px" id="lastUsedDiv">
|
<div class="map" style="height: 160px; margin-top: 25px" id="lastUsedDiv">
|
||||||
<canvas class='gameCanvas' id='lastUsed' width='416' height='160'></canvas>
|
<canvas class='gameCanvas' id='lastUsed' width='416' height='160'></canvas>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -366,7 +366,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="mid2">
|
<div id="mid2">
|
||||||
<p style="margin: 10px">最近使用的图块列表(Ctrl+滚轮放缩) <button id='clearLastUsedBtn'>清除</button></p>
|
<p style="margin: 10px"><span id='lastUsedTitle'></span>(Ctrl+滚轮放缩) <button id='clearLastUsedBtn'>清除</button></p>
|
||||||
<div class="map" id="lastUsedDiv">
|
<div class="map" id="lastUsedDiv">
|
||||||
<canvas id='lastUsed' width='416' height='416' style="overflow: hidden"></canvas>
|
<canvas id='lastUsed' width='416' height='416' style="overflow: hidden"></canvas>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -51,11 +51,12 @@
|
|||||||
地图拉框选择复制剪切删除
|
地图拉框选择复制剪切删除
|
||||||
(已完成!) 素材替换
|
(已完成!) 素材替换
|
||||||
大屏幕下放大游戏界面
|
大屏幕下放大游戏界面
|
||||||
最近使用/最常使用的图块
|
(已完成!) 最近使用/最常使用的图块
|
||||||
(已完成!) loader并行加载
|
(已完成!) loader并行加载
|
||||||
合并items.js
|
合并items.js
|
||||||
(已完成!) 增加fonts目录,全塔属性增加fonts引用
|
(已完成!) 增加fonts目录,全塔属性增加fonts引用
|
||||||
(已完成!) 右边框输入完后解析按钮高亮
|
(已完成!) 右边框输入完后解析按钮高亮
|
||||||
|
32x48的门
|
||||||
|
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user