From e05e689556fb3e12e107ffb642ab9247c5fbaad9 Mon Sep 17 00:00:00 2001 From: kuangshen04 <2832899707@qq.com> Date: Thu, 18 Jan 2024 23:00:21 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E4=BF=AE=E5=A4=8DinfoFuncOL=E8=BD=AC?= =?UTF-8?q?=E8=AF=91func=E8=AF=AD=E6=B3=95=E9=94=99=E8=AF=AF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/get/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/noname/get/index.js b/noname/get/index.js index 2e787929d..cf0c34341 100644 --- a/noname/get/index.js +++ b/noname/get/index.js @@ -1367,11 +1367,13 @@ export class Get extends Uninstantable { } static infoFuncOL(info) { var func; + const str = info.slice(13).trim(); try { - eval('func=(' + info.slice(13) + ');'); - } - catch (e) { - return function () { }; + if (str.startsWith("function") || str.startsWith("(")) eval(`func=(${str});`); + else eval(`func=(function ${str});`); + } catch (e) { + console.error(`${e} in \n${str}`); + return function () {}; } if (Array.isArray(func)) { func = get.filter.apply(this, get.parsedResult(func)); From 6f2d0e7838d08c9938966387287960ee1bfb1633 Mon Sep 17 00:00:00 2001 From: kuangshen04 <2832899707@qq.com> Date: Thu, 18 Jan 2024 23:05:40 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BC=98=E5=8C=96playAudio=EF=BC=8C?= =?UTF-8?q?=E4=B9=8B=E5=90=8Eonerror=E4=B8=8D=E4=BC=9AaddVideo=EF=BC=8C?= =?UTF-8?q?=E4=BB=A5=E9=98=B2=E6=AD=A2=E5=8F=AF=E8=83=BD=E7=9A=84=E5=86=85?= =?UTF-8?q?=E5=AD=98=E6=B3=84=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/game/index.js | 16 +++++++++------- noname/library/element/content.js | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/noname/game/index.js b/noname/game/index.js index ad55dc55f..9b2379276 100644 --- a/noname/game/index.js +++ b/noname/game/index.js @@ -1364,19 +1364,21 @@ export class Game extends Uninstantable { else if (!path.startsWith('db:')) path = `audio/${path}`; if (!lib.config.repeat_audio && _status.skillaudio.includes(path)) return; } - _status.skillaudio.add(path); - game.addVideo('playAudio', null, path); - setTimeout(() => _status.skillaudio.remove(path), 1000); const audio = document.createElement('audio'); audio.autoplay = true; audio.volume = lib.config.volumn_audio / 8; - audio.addEventListener('ended', () => audio.remove()); - audio.onerror = event => { + //Some browsers do not support "autoplay", so "oncanplay" listening has been added + audio.oncanplay = () => Promise.resolve(audio.play()).catch(() => void 0); + audio.onplay = () => { + _status.skillaudio.add(path); + setTimeout(() => _status.skillaudio.remove(path), 1000); + game.addVideo("playAudio", null, path); + }; + audio.onended = (event) => audio.remove(); + audio.onerror = (event) => { audio.remove(); if (onError) onError(event); }; - //Some browsers do not support "autoplay", so "oncanplay" listening has been added - audio.oncanplay = () => Promise.resolve(audio.play()).catch(() => void 0); new Promise((resolve, reject) => { if (path.startsWith('db:')) game.getDB('image', path.slice(3)).then(octetStream => resolve(get.objectURL(octetStream)), reject); else if (lib.path.extname(path)) resolve(`${lib.assetURL}${path}`); diff --git a/noname/library/element/content.js b/noname/library/element/content.js index 62ccb6803..f0caf0960 100644 --- a/noname/library/element/content.js +++ b/noname/library/element/content.js @@ -2025,10 +2025,10 @@ export const Content = { event.choice = event.doing.todoList.filter(info => { if (!lib.filter.filterTrigger(trigger, info.player, event.triggername, info.skill)) return false; if (directUse(info)) return false; + if (event.current.priority !== info.priority) return false; if (event.current.player !== info.player) return false; return lib.skill.global.includes(info.skill) || event.current.player.hasSkill(info.skill, true); }); - event.choice = event.choice.filter(n=>n.priority == event.choice[0].priority); if (event.choice.length < 2) return event.goto(4); 'step 2'; const next = event.choice[0].player.chooseControl(event.choice.map(i => i.skill)); From 8047ca191c6cc74c0755a1a69cc54e458680e25e Mon Sep 17 00:00:00 2001 From: nonameShijian <2954700422@qq.com> Date: Thu, 18 Jan 2024 23:23:57 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E8=83=8C=E6=99=AF=E9=9F=B3=E4=B9=90?= =?UTF-8?q?=E5=9C=A8=E4=B8=8D=E5=8F=AF=E6=92=AD=E6=94=BE=E6=97=B6=E4=B8=8D?= =?UTF-8?q?=E8=B0=83=E7=94=A8play()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/init/cordova.js | 2 +- noname/ui/index.js | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/noname/init/cordova.js b/noname/init/cordova.js index 38a939fa3..b642fad9d 100644 --- a/noname/init/cordova.js +++ b/noname/init/cordova.js @@ -17,7 +17,7 @@ export async function cordovaReady() { } }); document.addEventListener("resume", () => { - if (ui.backgroundMusic) ui.backgroundMusic.play(); + if (ui.backgroundMusic && !isNaN(ui.backgroundMusic.duration)) ui.backgroundMusic.play(); }); document.addEventListener("backbutton", function () { if (ui.arena && ui.arena.classList.contains('menupaused')) { diff --git a/noname/ui/index.js b/noname/ui/index.js index 9a63d9894..f38e155ca 100644 --- a/noname/ui/index.js +++ b/noname/ui/index.js @@ -9050,10 +9050,9 @@ class Create extends Uninstantable { ui.backgroundMusic.autoplay = true; ui.backgroundMusic.addEventListener('ended', game.playBackgroundMusic); ui.window.appendChild(ui.backgroundMusic); - ui.window.addEventListener(lib.config.touchscreen ? 'touchend' : 'click', function playMusic() { - ui.window.removeEventListener(lib.config.touchscreen ? 'touchend' : 'click', playMusic, false); - if (!ui.backgroundMusic.played.length && lib.config.background_music != 'music_off') ui.backgroundMusic.play(); - }, false); + ui.window.addEventListener(lib.config.touchscreen ? 'touchend' : 'click', () => { + if (!ui.backgroundMusic.played.length && lib.config.background_music != 'music_off' && !isNaN(ui.backgroundMusic.duration)) ui.backgroundMusic.play(); + }, {once:true}); if (lib.config.cursor_style == 'pointer') { ui.window.classList.add('nopointer'); } @@ -14142,6 +14141,10 @@ export class UI extends Uninstantable { * @type { HTMLDivElement } */ static pause; + /** + * @type { HTMLAudioElement } + */ + static backgroundMusic; static refresh(node) { void window.getComputedStyle(node, null).getPropertyValue("opacity"); }