Merge branch 'PR-Branch' of https://github.com/libccy/noname into PR-Branch
This commit is contained in:
commit
ee08aaa3ab
|
@ -1364,19 +1364,21 @@ export class Game extends Uninstantable {
|
||||||
else if (!path.startsWith('db:')) path = `audio/${path}`;
|
else if (!path.startsWith('db:')) path = `audio/${path}`;
|
||||||
if (!lib.config.repeat_audio && _status.skillaudio.includes(path)) return;
|
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');
|
const audio = document.createElement('audio');
|
||||||
audio.autoplay = true;
|
audio.autoplay = true;
|
||||||
audio.volume = lib.config.volumn_audio / 8;
|
audio.volume = lib.config.volumn_audio / 8;
|
||||||
audio.addEventListener('ended', () => audio.remove());
|
//Some browsers do not support "autoplay", so "oncanplay" listening has been added
|
||||||
audio.onerror = event => {
|
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();
|
audio.remove();
|
||||||
if (onError) onError(event);
|
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) => {
|
new Promise((resolve, reject) => {
|
||||||
if (path.startsWith('db:')) game.getDB('image', path.slice(3)).then(octetStream => resolve(get.objectURL(octetStream)), 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}`);
|
else if (lib.path.extname(path)) resolve(`${lib.assetURL}${path}`);
|
||||||
|
|
|
@ -1367,10 +1367,12 @@ export class Get extends Uninstantable {
|
||||||
}
|
}
|
||||||
static infoFuncOL(info) {
|
static infoFuncOL(info) {
|
||||||
var func;
|
var func;
|
||||||
|
const str = info.slice(13).trim();
|
||||||
try {
|
try {
|
||||||
eval('func=(' + info.slice(13) + ');');
|
if (str.startsWith("function") || str.startsWith("(")) eval(`func=(${str});`);
|
||||||
}
|
else eval(`func=(function ${str});`);
|
||||||
catch (e) {
|
} catch (e) {
|
||||||
|
console.error(`${e} in \n${str}`);
|
||||||
return function () {};
|
return function () {};
|
||||||
}
|
}
|
||||||
if (Array.isArray(func)) {
|
if (Array.isArray(func)) {
|
||||||
|
|
|
@ -17,7 +17,7 @@ export async function cordovaReady() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
document.addEventListener("resume", () => {
|
document.addEventListener("resume", () => {
|
||||||
if (ui.backgroundMusic) ui.backgroundMusic.play();
|
if (ui.backgroundMusic && !isNaN(ui.backgroundMusic.duration)) ui.backgroundMusic.play();
|
||||||
});
|
});
|
||||||
document.addEventListener("backbutton", function () {
|
document.addEventListener("backbutton", function () {
|
||||||
if (ui.arena && ui.arena.classList.contains('menupaused')) {
|
if (ui.arena && ui.arena.classList.contains('menupaused')) {
|
||||||
|
|
|
@ -9050,10 +9050,9 @@ class Create extends Uninstantable {
|
||||||
ui.backgroundMusic.autoplay = true;
|
ui.backgroundMusic.autoplay = true;
|
||||||
ui.backgroundMusic.addEventListener('ended', game.playBackgroundMusic);
|
ui.backgroundMusic.addEventListener('ended', game.playBackgroundMusic);
|
||||||
ui.window.appendChild(ui.backgroundMusic);
|
ui.window.appendChild(ui.backgroundMusic);
|
||||||
ui.window.addEventListener(lib.config.touchscreen ? 'touchend' : 'click', function playMusic() {
|
ui.window.addEventListener(lib.config.touchscreen ? 'touchend' : 'click', () => {
|
||||||
ui.window.removeEventListener(lib.config.touchscreen ? 'touchend' : 'click', playMusic, false);
|
if (!ui.backgroundMusic.played.length && lib.config.background_music != 'music_off' && !isNaN(ui.backgroundMusic.duration)) ui.backgroundMusic.play();
|
||||||
if (!ui.backgroundMusic.played.length && lib.config.background_music != 'music_off') ui.backgroundMusic.play();
|
}, {once:true});
|
||||||
}, false);
|
|
||||||
if (lib.config.cursor_style == 'pointer') {
|
if (lib.config.cursor_style == 'pointer') {
|
||||||
ui.window.classList.add('nopointer');
|
ui.window.classList.add('nopointer');
|
||||||
}
|
}
|
||||||
|
@ -14142,6 +14141,10 @@ export class UI extends Uninstantable {
|
||||||
* @type { HTMLDivElement }
|
* @type { HTMLDivElement }
|
||||||
*/
|
*/
|
||||||
static pause;
|
static pause;
|
||||||
|
/**
|
||||||
|
* @type { HTMLAudioElement }
|
||||||
|
*/
|
||||||
|
static backgroundMusic;
|
||||||
static refresh(node) {
|
static refresh(node) {
|
||||||
void window.getComputedStyle(node, null).getPropertyValue("opacity");
|
void window.getComputedStyle(node, null).getPropertyValue("opacity");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue