pref: parse ext path.

This commit is contained in:
Rintim 2024-05-13 00:40:21 +08:00
parent 37c21700a3
commit 4cf40dbe6c
No known key found for this signature in database
GPG Key ID: BE9E1EA615BACFCF
1 changed files with 16 additions and 3 deletions

View File

@ -1599,8 +1599,21 @@ export class Game {
} }
if (dieAudios && dieAudios.length > 0) { if (dieAudios && dieAudios.length > 0) {
dieAudios.forEach(item => { dieAudios.forEach(item => {
let file = lib.init.parseResourceAddress(item, path => (lib.path.extname(path) ? `audio/die/${path}.mp3` : `audio/die/${path}`)).href; let file = lib.init.parseResourceAddress(item, path => (lib.path.extname(path) ? `audio/die/${path}.mp3` : `audio/die/${path}`));
let key = file.startsWith("db:") ? file.slice(3) : file.startsWith("data:") ? file : lib.path.basename(file); //let key = file.startsWith("db:") ? file.slice(3) : file.startsWith("data:") ? file : lib.path.basename(file);
/**
* @type {string}
*/
let key;
if (item.startsWith("ext:")) {
let relativePath = get.relativePath(file);
let keyPath = relativePath.split("/").slice(2).join("/");
if (lib.path.extname(keyPath)) keyPath = keyPath.replace(lib.path.extname(keyPath), "");
key = keyPath;
} else {
key = file.href;
}
// if (item.startsWith("ext:")) { // if (item.startsWith("ext:")) {
// key = item.slice(4).split("/")[1]; // key = item.slice(4).split("/")[1];
@ -1609,7 +1622,7 @@ export class Game {
// key = item; // key = item;
// file = `die/${item}.mp3`; // file = `die/${item}.mp3`;
// } // }
const data = { key, file }; const data = { key, file: file.href };
if (lib.translate[`#${key}:die`]) data.text = lib.translate[`#${key}:die`]; if (lib.translate[`#${key}:die`]) data.text = lib.translate[`#${key}:die`];
datas.push(data); datas.push(data);
}); });