diff --git a/config/_project_json.yaml b/config/_project_json.yaml index d03233e..77cd934 100644 --- a/config/_project_json.yaml +++ b/config/_project_json.yaml @@ -23,6 +23,8 @@ localization: ui_position_padding_top: Padding Top ui_voice_title:

🔈Voice


ui_voice_lang: Voice Language + ui_voice_idle: Idle Timeout + ui_voice_next: Voice Interval ui_subtitle_title:

📑 Subtitle


ui_subtitle_lang: Subtitle Language ui_voice_actor_title:

🗣️ Voice Actor


@@ -49,6 +51,8 @@ localization: ui_position_padding_top: 上部距离 ui_voice_title:

🔈语音


ui_voice_lang: 语音语言 + ui_voice_idle: 待机间隔 + ui_voice_next: 下一条语音间隔 ui_subtitle_title:

📑 字幕


ui_subtitle_lang: 字幕语言 ui_voice_actor_title:

🗣️ 声优


@@ -128,15 +132,77 @@ properties: text: ui_default_background type: combo value: !match ~{var('assets', "backgrounds")[0]} - fraction: false - max: 100 - min: 0 - options: !match ~{var('assets', "backgroundOptions")} + options: !match ~{var('assets', "backgroundsOptions")} - key: background value: text: ui_custom_background type: file value: "" + - key: voicetitle + value: + text: ui_voice_title + type: bool + value: false + - key: voicelanguage + value: + text: ui_voice_lang + type: combo + condition: voicetitle.value == true + value: !match ~{var('assets', "voiceLangs")[0]} + options: !match ~{var('assets', "voiceLangsOptions")} + - key: voiceidle + value: + text: ui_voice_idle + type: textinput + value: 10 + condition: voicetitle.value == true + fraction: false + min: 0 + - key: voicenext + value: + text: ui_voice_next + type: textinput + value: 3 + condition: voicetitle.value == true + fraction: false + min: 0 + - key: voicesubtitle + value: + text: ui_subtitle_title + condition: voicetitle.value == true + type: bool + value: false + - key: voicesubtitlelanguage + value: + text: ui_subtitle_lang + type: combo + condition: voicesubtitle.value == true + value: !match ~{var('assets', "subtitleLangs")[0]} + options: !match ~{var('assets', "subtitleLangsOptions")} + - key: voicesubtitlex + value: + text: ui_translate_x + type: slider + value: 0 + condition: voicesubtitle.value == true + fraction: false + max: 100 + min: 0 + - key: voicesubtitley + value: + text: ui_translate_y + type: slider + value: 100 + condition: voicesubtitle.value == true + fraction: false + max: 100 + min: 0 + - key: voiceactor + value: + text: ui_voice_actor_title + condition: voicesubtitle.value == true + type: bool + value: false - key: position value: text: ui_position_title diff --git a/libs/project_json.js b/libs/project_json.js index ab60fef..9efeba2 100644 --- a/libs/project_json.js +++ b/libs/project_json.js @@ -23,12 +23,18 @@ export default class ProjectJson { this.#json = JSON.parse(await readFile(this.#getPath())) const matcher = new Matcher('~{', '}', __config.operators[this.#operatorName], { ...this.#assets, - backgroundOptions: this.#assets.backgrounds.map((b) => { - return { - "label": b, - "value": b + ...(() => { + const output = {} + for (const [key, value] of Object.entries(this.#assets)) { + output[`${key}Options`] = value.map((b) => { + return { + "label": b, + "value": b + } + }) } - }) + return output + })() }) const match = { identify: value => value.startsWith('!match'), diff --git a/runner.js b/runner.js index b74fd93..efb3f65 100644 --- a/runner.js +++ b/runner.js @@ -75,8 +75,35 @@ async function main() { rmdir(OPERATOR_RELEASE_FOLDER) + const charwordTableLookup = charwordTable.lookup(OPERATOR_NAME) + const voiceLangs = (() => { + const infoArray = Object.values(charwordTableLookup.operator.info[charwordTableLookup.config.default_region]) + // combine the infoArray + let output = {} + for (const info of infoArray) { + output = { + ...output, + ...info + } + } + return Object.keys(output) + })() + const subtitleLangs = (() => { + const output = [] + for (const [key, value] of Object.entries(charwordTableLookup.operator.info)) { + if (Object.keys(value).length !== 0) { + output.push(key) + } + } + return output + })() + + writeSync(JSON.stringify(charwordTableLookup), path.join(OPERATOR_SOURCE_FOLDER, OPERATOR_NAME, 'charword_table.json')) + const projectJson = new ProjectJson(OPERATOR_NAME, OPERATOR_SHARE_FOLDER, { - backgrounds + backgrounds, + voiceLangs, + subtitleLangs }) projectJson.load().then((content) => { write(JSON.stringify(content, null, 2), path.join(OPERATOR_RELEASE_FOLDER, 'project.json')) @@ -87,8 +114,6 @@ async function main() { write(JSON.stringify(content.assetsJson, null), path.join(OPERATOR_SOURCE_FOLDER, OPERATOR_NAME, `assets.json`)) }) - writeSync(JSON.stringify(charwordTable.lookup(OPERATOR_NAME)), path.join(OPERATOR_SOURCE_FOLDER, OPERATOR_NAME, 'charword_table.json')) - const filesToCopy = [ ...background.getFilesToCopy(SHOWCASE_PUBLIC_ASSSETS_FOLDER), { diff --git a/src/components/voice.js b/src/components/voice.js index e13714c..1d724c9 100644 --- a/src/components/voice.js +++ b/src/components/voice.js @@ -61,6 +61,7 @@ export default class Voice { set useSubtitle(show) { this.#useSubtitle = show this.#el.hidden = !show + window.settings.functionInsights("useSubtitle") } get useSubtitle() { @@ -71,6 +72,7 @@ export default class Voice { * @param {boolean} show */ set useVoice(show) { + window.settings.functionInsights("useVoice") this.#useVoice = show this.#el.hidden = !show this.#playEntryVoice() @@ -89,6 +91,7 @@ export default class Voice { set useVoiceActor(show) { this.#useVoiceActor = show document.getElementById('voice_actor_box').hidden = !show + window.settings.functionInsights("useVoiceActor") } get useVoiceActor() { @@ -104,6 +107,7 @@ export default class Voice { } else { this.#subtitleLang = this.#defaultRegion } + window.settings.functionInsights("subtitleLanguage") } get subtitleLanguage() { @@ -140,6 +144,7 @@ export default class Voice { #updateSubtitlePosition() { window.settings.elementPosition(this.#el, this.#subtitleX, this.#subtitleY) + window.settings.functionInsights("subtitlePosition") } /** @@ -151,6 +156,7 @@ export default class Voice { } else { this.#voiceLang = this.#defaultVoiceLang } + window.settings.functionInsights("language") const availableSubtitleLang = this.#getSubtitleLanguages() if (!availableSubtitleLang.includes(this.#subtitleLang)) { this.#subtitleLang = availableSubtitleLang[0] @@ -174,6 +180,7 @@ export default class Voice { this.#idleDuration = duration * 60 * 1000 this.#initIdleVoiceTimer() } + window.settings.functionInsights("idleDuration") } get idleDuration() { @@ -189,6 +196,7 @@ export default class Voice { this.#nextDuration = duration * 60 * 1000 this.#initNextVoiceTimer() } + window.settings.functionInsights("nextDuration") } get nextDuration() { @@ -227,7 +235,7 @@ export default class Voice { if (id === null) { setTimeout(() => { if (this.#isPlaying) return - this.#el.style.opacity = 1 + this.#el.style.opacity = 0 }, 5 * 1000); return } @@ -246,7 +254,7 @@ export default class Voice { this.#lastVoiceId = this.#currentVoiceId this.#currentVoiceId = id this.#audioEl.src = `./assets/${this.#getVoiceFoler() - }/${id}.wav` + }/${id}.ogg` let startPlayPromise = this.#audioEl.play() if (startPlayPromise !== undefined) { startPlayPromise @@ -365,9 +373,11 @@ export default class Voice {
-