fix heroIcon & add fold for table gap

This commit is contained in:
tocque 2020-05-15 16:53:24 +08:00
parent 8100bf72b1
commit ec60742c5d
9 changed files with 86 additions and 13 deletions

View File

@ -57,11 +57,21 @@ editor_table_wrapper = function (editor) {
}
editor_table.prototype.gap = function (field) {
return /* html */`<tr><td>----</td><td>----</td><td>${field}</td><td>----</td></tr>\n`
var tokenlist = field.slice(2, -2).split("']['");
var rule = tokenlist.join("-");
tokenlist.pop();
var self = tokenlist.join("-");
var status = tokenPool.check(rule);
return /* html */`<tr data-gap="${rule}" data-field="${self}">
<td>----</td>
<td>----</td>
<td>${field}</td>
<td><button style="background: #FFCCAA" onclick='editor.table.onFoldBtnClick(this)' data-fold="${ status ? "true" : "false" }">${ status ? "展开" : "折叠" }</button></td>
</tr>\n`
}
editor_table.prototype.tr = function (guid, field, shortField, commentHTMLescape, cobjstr, shortComment, tdstr, type) {
return /* html */`<tr id="${guid}">
return /* html */`<tr id="${guid}" data-field="${field.slice(2, -2).split("']['").join("-")}">
<td title="${field}">${shortField}</td>
<td title="${commentHTMLescape}" cobj="${cobjstr}">${shortComment || commentHTMLescape}</td>
<td><div class="etableInputDiv ${type}">${tdstr}</div></td>
@ -349,6 +359,54 @@ editor_table_wrapper = function (editor) {
}
}
tokenPool = new class {
constructor() {
this.pool = new Set();
this.style = document.createElement("style");
document.body.appendChild(this.style);
}
add(token) {
this.pool.add(token);
this.render();
}
remove(token) {
this.pool.delete(token);
this.render();
}
render() {
var content = "";
this.pool.forEach((k) => {
content += /* CSS */`[data-field|=${k}]{ display: none }`;
})
this.style.innerHTML = content;
}
check(token) {
return this.pool.has(token);
}
}
/**
* "折叠"被按下时
*/
editor_table.prototype.onFoldBtnClick = function (button) {
var tr = button.parentNode.parentNode;
if (button.dataset.fold == "true") {
tokenPool.remove(tr.dataset.gap);
button.dataset.fold = "false";
button.innerText = "折叠";
} else {
var style = document.createElement("style");
tokenPool.add(tr.dataset.gap);
button.dataset.fold = "true";
button.innerText = "展开";
}
}
/**
* "显示完整注释"被按下时
*/

View File

@ -134,8 +134,10 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
},
"startBgm": {
"_leaf": true,
"_type": "textarea",
"_string": true,
"_type": "select",
"_select": {
"values": [null].concat(Object.keys(editor.core.material.bgms))
},
"_docs": "标题音乐",
"_data": "在标题界面应该播放的bgm内容"
},
@ -242,6 +244,14 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"hero": {
"_type": "object",
"_data": {
"image": {
"_leaf": true,
"_type": "select",
"_select": {
"values": [null].concat(Object.keys(editor.core.material.images))
},
"_data": "勇士行走图"
},
"name": {
"_leaf": true,
"_type": "textarea",

View File

@ -2851,8 +2851,11 @@ events.prototype._jumpHero_finished = function (animate, ex, ey, callback) {
events.prototype.setHeroIcon = function (name, noDraw) {
name = core.getMappedName(name);
var img = core.material.images.images[name];
if (!img) return;
core.setFlag("heroIcon", name);
if (!img) {
console.error("找不到图片: "+img);
return;
}
core.status.hero.image = name;
core.material.images.hero = img;
core.material.icons.hero.width = img.width / 4;
core.material.icons.hero.height = img.height / 4;

View File

@ -1238,7 +1238,7 @@ maps.prototype._drawThumbnail_realDrawTempCanvas = function (floorId, blocks, op
this.drawEvents(floorId, blocks, tempCanvas);
// 缩略图:勇士
if (options.heroLoc) {
options.heroIcon = options.heroIcon || core.getFlag("heroIcon", "hero.png");
options.heroIcon = options.heroIcon || core.status.hero.image;
options.heroIcon = core.getMappedName(options.heroIcon);
var icon = core.material.icons.hero[options.heroLoc.direction];
var height = core.material.images.images[options.heroIcon].height / 4;

View File

@ -2057,7 +2057,7 @@ ui.prototype.drawCenterFly = function () {
var fillstyle = 'rgba(255,0,0,0.5)';
if (core.canUseItem('centerFly')) fillstyle = 'rgba(0,255,0,0.5)';
var toX = core.bigmap.width - 1 - core.getHeroLoc('x'), toY = core.bigmap.height - 1 - core.getHeroLoc('y');
core.drawThumbnail(null, null, {heroLoc: core.status.hero.loc, heroIcon: core.getFlag('heroIcon', "hero.png")},
core.drawThumbnail(null, null, {heroLoc: core.status.hero.loc, heroIcon: core.status.hero.image},
{ctx: 'ui', centerX: toX, centerY: toY});
var offsetX = core.clamp(toX - core.__HALF_SIZE__, 0, core.bigmap.width - core.__SIZE__),
offsetY = core.clamp(toY - core.__HALF_SIZE__, 0, core.bigmap.height - core.__SIZE__);
@ -2542,7 +2542,7 @@ ui.prototype._drawSLPanel_drawRecord = function(title, data, x, y, size, cho, hi
core.strokeRect('ui', x-size/2, y+15, size, size, cho?strokeColor:'#FFFFFF', cho?6:2);
if (data && data.floorId) {
core.drawThumbnail(data.floorId, core.maps.loadMap(data.maps, data.floorId).blocks, {
heroLoc: data.hero.loc, heroIcon: data.hero.flags.heroIcon, flags: data.hero.flags
heroLoc: data.hero.loc, heroIcon: data.hero.image, flags: data.hero.flags
}, {
ctx: 'ui', x: x-size/2, y: y+15, size: size, centerX: data.hero.loc.x, centerY: data.hero.loc.y
});

View File

@ -85,7 +85,7 @@ function main() {
'data', 'enemys', 'icons', 'maps', 'items', 'functions', 'events', 'plugins'
];
this.materials = [
'animates', 'enemys', 'hero', 'items', 'npcs', 'terrains', 'enemy48', 'npc48'
'animates', 'enemys', 'items', 'npcs', 'terrains', 'enemy48', 'npc48'
];
this.statusBar = {

View File

@ -10,7 +10,8 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
],
"images": [
"bg.jpg",
"winskin.png"
"winskin.png",
"hero.png"
],
"tilesets": [
"magictower.png"
@ -81,6 +82,7 @@ var data_a1e2fb4a_e986_4524_b0da_9b7ba7c0874d =
"version": "Ver 2.6.6",
"floorId": "sample0",
"hero": {
"image": "hero.png",
"name": "阳光",
"lv": 1,
"hpmax": 9999,

View File

@ -16,7 +16,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// 初始化人物,图标,统计信息
core.status.hero = core.clone(hero);
window.flags = core.status.hero.flags;
core.events.setHeroIcon(core.getFlag('heroIcon', 'hero.png'), true);
core.events.setHeroIcon(core.status.hero.image, true);
core.control._initStatistics(core.animateFrame.totalTime);
core.status.hero.statistics.totalTime = core.animateFrame.totalTime =
Math.max(core.status.hero.statistics.totalTime, core.animateFrame.totalTime);
@ -945,7 +945,7 @@ var functions_d6ad677b_427a_4623_b50f_a445a3b0ef8a =
// 重置音量
core.events.setVolume(core.getFlag("__volume__", 1), 0);
// 加载勇士图标
var icon = core.getFlag("heroIcon", "hero.png");
var icon = core.status.hero.image;
icon = core.getMappedName(icon);
if (core.material.images.images[icon]) {
core.material.images.hero = core.material.images.images[icon];

View File

Before

Width:  |  Height:  |  Size: 5.3 KiB

After

Width:  |  Height:  |  Size: 5.3 KiB