fix:小修复道具栏未replaceText的问题,及添加opus与webp支持

This commit is contained in:
ShakeFlower 2025-05-29 10:33:23 +08:00
parent d2925fda45
commit 15c034c62c
4 changed files with 25 additions and 19 deletions

View File

@ -587,12 +587,12 @@ editor_uievent_wrapper = function (editor) {
var disabled = _isTileset && value.indexOf(one) >= 0 ? 'disabled' : '' var disabled = _isTileset && value.indexOf(one) >= 0 ? 'disabled' : ''
html += `<input type="checkbox" key="${one}" class="materialCheckbox" ${checked} ${disabled}/> ${one}`; html += `<input type="checkbox" key="${one}" class="materialCheckbox" ${checked} ${disabled}/> ${one}`;
// 预览图片 // 预览图片
if (one.endsWith('.png') || one.endsWith('.jpg') || one.endsWith('.jpeg') || one.endsWith('.gif')) { if (one.endsWith('.png') || one.endsWith('.jpg') || one.endsWith('.jpeg') || one.endsWith('.gif') || one.endsWith('.webp')) {
html += "<button onclick='editor.uievent._previewMaterialImage(this)' style='margin-left: 10px'>预览</button>"; html += "<button onclick='editor.uievent._previewMaterialImage(this)' style='margin-left: 10px'>预览</button>";
html += '<br style="display:none"/><img key="' + directory + one + '" style="display:none; max-width: 100%"/>'; html += '<br style="display:none"/><img key="' + directory + one + '" style="display:none; max-width: 100%"/>';
} }
// 试听音频 // 试听音频
if (one.endsWith('.mp3') || one.endsWith('.ogg') || one.endsWith('.wav') || one.endsWith('.m4a') || one.endsWith('.flac')) { if (one.endsWith('.mp3') || one.endsWith('.ogg') || one.endsWith('.wav') || one.endsWith('.m4a') || one.endsWith('.flac') || one.endsWith('.opus')) {
html += "<button onclick='editor.uievent._previewMaterialAudio(this)' style='margin-left: 10px'>播放</button>" html += "<button onclick='editor.uievent._previewMaterialAudio(this)' style='margin-left: 10px'>播放</button>"
html += "<small> 音调:<input value='100' style='width:28px' onchange='editor.uievent._previewMaterialAudio_onPitchChange(this)'></small>"; html += "<small> 音调:<input value='100' style='width:28px' onchange='editor.uievent._previewMaterialAudio_onPitchChange(this)'></small>";
html += `<small style='display:none; margin-left: 15px'>0:00 / 0:00</small><br style="display:none"/> html += `<small style='display:none; margin-left: 15px'>0:00 / 0:00</small><br style="display:none"/>
@ -611,7 +611,7 @@ editor_uievent_wrapper = function (editor) {
var disabled = _isTileset && value.indexOf(one) >= 0 ? 'disabled' : ''; var disabled = _isTileset && value.indexOf(one) >= 0 ? 'disabled' : '';
html += `<input type="checkbox" key="${one}" class="materialCheckbox" ${checked} ${disabled}/> ${one}`; html += `<input type="checkbox" key="${one}" class="materialCheckbox" ${checked} ${disabled}/> ${one}`;
// 预览图片 // 预览图片
if (one.endsWith('.png') || one.endsWith('.jpg') || one.endsWith('.jpeg') || one.endsWith('.gif')) { if (one.endsWith('.png') || one.endsWith('.jpg') || one.endsWith('.jpeg') || one.endsWith('.gif') || one.endsWith('.webp')) {
html += "<button onclick='editor.uievent._previewMaterialImage2(this)' style='margin-left: 10px'>预览</button>"; html += "<button onclick='editor.uievent._previewMaterialImage2(this)' style='margin-left: 10px'>预览</button>";
html += '<br style="display:none" key="' + one + '"/><br/>'; html += '<br style="display:none" key="' + one + '"/><br/>';
} }

View File

@ -657,7 +657,7 @@ var comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_type": "material", "_type": "material",
"_directory": "./project/bgms/", "_directory": "./project/bgms/",
"_transform": (function (one) { "_transform": (function (one) {
if (one.endsWith('.mp3') || one.endsWith('.ogg') || one.endsWith('.wav') || one.endsWith('.m4a') || one.endsWith('.flac')) if (one.endsWith('.mp3') || one.endsWith('.ogg') || one.endsWith('.wav') || one.endsWith('.m4a') || one.endsWith('.flac') || one.endsWith('.opus'))
return one; return one;
return null; return null;
}).toString(), }).toString(),

View File

@ -31,7 +31,7 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_range": "editor.mode.checkImages(thiseval, './project/images/')", "_range": "editor.mode.checkImages(thiseval, './project/images/')",
"_directory": "./project/images/", "_directory": "./project/images/",
"_transform": (function (one) { "_transform": (function (one) {
if (one.endsWith('.png') || one.endsWith('.jpg') || one.endsWith('.jpeg') || one.endsWith('.gif')) if (one.endsWith('.png') || one.endsWith('.jpg') || one.endsWith('.jpeg') || one.endsWith('.gif') || one.endsWith('.webp'))
return one; return one;
return null; return null;
}).toString(), }).toString(),
@ -89,7 +89,7 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_range": "editor.mode.checkUnique(thiseval)", "_range": "editor.mode.checkUnique(thiseval)",
"_directory": "./project/bgms/", "_directory": "./project/bgms/",
"_transform": (function (one) { "_transform": (function (one) {
if (one.endsWith('.mp3') || one.endsWith('.ogg') || one.endsWith('.wav') || one.endsWith('.m4a') || one.endsWith('.flac')) if (one.endsWith('.mp3') || one.endsWith('.ogg') || one.endsWith('.wav') || one.endsWith('.m4a') || one.endsWith('.flac') || one.endsWith('.opus'))
return one; return one;
return null; return null;
}).toString(), }).toString(),
@ -102,7 +102,7 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_range": "editor.mode.checkUnique(thiseval)", "_range": "editor.mode.checkUnique(thiseval)",
"_directory": "./project/sounds/", "_directory": "./project/sounds/",
"_transform": (function (one) { "_transform": (function (one) {
if (one.endsWith('.mp3') || one.endsWith('.ogg') || one.endsWith('.wav') || one.endsWith('.m4a') || one.endsWith('.flac')) if (one.endsWith('.mp3') || one.endsWith('.ogg') || one.endsWith('.wav') || one.endsWith('.m4a') || one.endsWith('.flac') || one.endsWith('.opus'))
return one; return one;
return null; return null;
}).toString(), }).toString(),
@ -147,7 +147,7 @@ var data_comment_c456ea59_6018_45ef_8bcc_211a24c627dc = {
"_type": "material", "_type": "material",
"_directory": "./project/bgms/", "_directory": "./project/bgms/",
"_transform": (function (one) { "_transform": (function (one) {
if (one.endsWith('.mp3') || one.endsWith('.ogg') || one.endsWith('.wav') || one.endsWith('.m4a') || one.endsWith('.flac')) if (one.endsWith('.mp3') || one.endsWith('.ogg') || one.endsWith('.wav') || one.endsWith('.m4a') || one.endsWith('.flac') || one.endsWith('.opus'))
return one; return one;
return null; return null;
}).toString(), }).toString(),

View File

@ -2156,7 +2156,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
const loc = `${x},${y}`; const loc = `${x},${y}`;
const hasEvent = has(floor.events[loc]); const hasEvent = has(floor.events[loc]);
if (hasEvent) return; // 如果有事件,直接不清了 if (hasEvent) return; // 如果有事件,直接不清了
const block = core.getBlock(x,y); const block = core.getBlock(x, y);
if (block != null && block.event.cls !== 'items') return; // 角色站的位置为空地和物品以外的图块,不清(例如箭头,可能无法返回) if (block != null && block.event.cls !== 'items') return; // 角色站的位置为空地和物品以外的图块,不清(例如箭头,可能无法返回)
let deep = Infinity; let deep = Infinity;
@ -2760,6 +2760,13 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
return list; return list;
} }
// 复写resize保证屏幕变化时此画布表现正常
const originResize = core.control.resize;
core.control.resize = function () {
originResize.apply(core.control, arguments);
[back, itemBoard, equipBoard, infoBoard].forEach((menu) => { if (menu && menu.onDraw) menu.drawContent(); });
}
// #endregion // #endregion
const { ButtonBase, RoundBtn, IconBtn, ExitBtn, MenuBase } = core.plugin.uiBase; const { ButtonBase, RoundBtn, IconBtn, ExitBtn, MenuBase } = core.plugin.uiBase;
// #region 绘制用到的按钮类 // #region 绘制用到的按钮类
@ -3177,7 +3184,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
core.fillText(ctx, itemsUsedCount[itemId] || 0, 80, 113, 'rgb(47, 49, 54)', '14px Verdana'); core.fillText(ctx, itemsUsedCount[itemId] || 0, 80, 113, 'rgb(47, 49, 54)', '14px Verdana');
} }
const itemText = item.text + ((type === "equips") ? this.getEquipCompareInfo(item) : ""); // 物品描述信息 const itemText = core.replaceText(item.text) + ((type === "equips") ? this.getEquipCompareInfo(item) : ""); // 物品描述信息
core.drawTextContent(ctx, itemText, { core.drawTextContent(ctx, itemText, {
left: 20, top: 125, bold: false, color: "black", left: 20, top: 125, bold: false, color: "black",
align: "left", fontSize: 15, maxWidth: 150 align: "left", fontSize: 15, maxWidth: 150
@ -4822,7 +4829,7 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
core.ui.fillText(ctx, this.setting.getName(), core.ui.fillText(ctx, this.setting.getName(),
this.x, this.y + this.h / 2 + 5, 'white', '16px Verdana'); this.x, this.y + this.h / 2 + 5, 'white', '16px Verdana');
const drawFunc = this.setting.draw; const drawFunc = this.setting.draw;
if (this.status === 'selected'){ if (this.status === 'selected') {
core.drawUIEventSelector(0, "winskin.png", this.x, this.y, this.w, this.h, 137); core.drawUIEventSelector(0, "winskin.png", this.x, this.y, this.w, this.h, 137);
} }
if (drawFunc) drawFunc.apply(this, [ctx]); if (drawFunc) drawFunc.apply(this, [ctx]);
@ -5286,7 +5293,6 @@ var plugins_bb40132b_638b_4a9f_b028_d3fe47acc8d1 =
// 设置初始时选中的按键为第一个按键 // 设置初始时选中的按键为第一个按键
settingMenu.changeBtn(gamePlayBtn); settingMenu.changeBtn(gamePlayBtn);
/** @todo 修复resize时尤其有输入框时自定义画布被破坏的及擦除不正确问题*/
settingMenu.init(); settingMenu.init();
} }
} }