diff --git a/src/components/Talk/AudioCell.vue b/src/components/Talk/AudioCell.vue index a7c1db4626..a69fc56a6e 100644 --- a/src/components/Talk/AudioCell.vue +++ b/src/components/Talk/AudioCell.vue @@ -497,26 +497,26 @@ const removeCell = async () => { // N番目のキャラクターを選ぶ const selectCharacterAt = (index: number) => { - if (userOrderedCharacterInfos.value.length >= index + 1) { - const speakerUuid = - userOrderedCharacterInfos.value[index].metas.speakerUuid; - const style = getDefaultStyle( - speakerUuid, - userOrderedCharacterInfos.value, - store.state.defaultStyleIds, - ); - const voice = { - engineId: style.engineId, - speakerId: speakerUuid, - styleId: style.styleId, - }; - store.dispatch("COMMAND_MULTI_CHANGE_VOICE", { - audioKeys: isMultiSelectEnabled.value - ? store.getters.SELECTED_AUDIO_KEYS - : [props.audioKey], - voice, - }); + if (userOrderedCharacterInfos.value.length < index + 1) { + return; } + const speakerUuid = userOrderedCharacterInfos.value[index].metas.speakerUuid; + const style = getDefaultStyle( + speakerUuid, + userOrderedCharacterInfos.value, + store.state.defaultStyleIds, + ); + const voice = { + engineId: style.engineId, + speakerId: speakerUuid, + styleId: style.styleId, + }; + store.dispatch("COMMAND_MULTI_CHANGE_VOICE", { + audioKeys: isMultiSelectEnabled.value + ? store.getters.SELECTED_AUDIO_KEYS + : [props.audioKey], + voice, + }); }; // 削除ボタンの有効/無効判定 diff --git a/src/components/Talk/TalkEditor.vue b/src/components/Talk/TalkEditor.vue index c414b2dc29..4e95ce09a2 100644 --- a/src/components/Talk/TalkEditor.vue +++ b/src/components/Talk/TalkEditor.vue @@ -143,6 +143,7 @@ import { SplitterPositionType, Voice, HotkeyActionNameType, + actionPostfixSelectNthCharacter, } from "@/type/preload"; import { useHotkeyManager } from "@/plugins/hotkeyPlugin"; import onetimeWatch from "@/helpers/onetimeWatch"; @@ -251,7 +252,7 @@ for (let i = 0; i < 10; i++) { registerHotkeyWithCleanup({ editor: "talk", enableInTextbox: true, - name: `${i + 1}番目のキャラクターを選択` as HotkeyActionNameType, + name: `${i + 1}${actionPostfixSelectNthCharacter}` as HotkeyActionNameType, callback: () => { if (!uiLocked.value) { onCharacterSelectHotkey(i); diff --git a/src/type/preload.ts b/src/type/preload.ts index c30ab10dd5..631c3a92e9 100644 --- a/src/type/preload.ts +++ b/src/type/preload.ts @@ -62,6 +62,9 @@ export type VoiceId = z.infer; export const VoiceId = (voice: Voice): VoiceId => voiceIdSchema.parse(`${voice.engineId}:${voice.speakerId}:${voice.styleId}`); +// 共通のアクション名 +export const actionPostfixSelectNthCharacter = "番目のキャラクターを選択"; + // ホットキーを追加したときは設定のマイグレーションが必要 export const defaultHotkeySettings: HotkeySettingType[] = [ { @@ -175,10 +178,9 @@ export const defaultHotkeySettings: HotkeySettingType[] = [ ...Array.from({ length: 10 }, (_, index) => { const roleKey = index == 9 ? 0 : index + 1; return { - action: `${index + 1}番目のキャラクターを選択` as HotkeyActionNameType, - combination: HotkeyCombination( - !isMac ? "Ctrl " + roleKey : "Meta " + roleKey, - ), + action: + `${index + 1}${actionPostfixSelectNthCharacter}` as HotkeyActionNameType, + combination: HotkeyCombination((!isMac ? "Ctrl " : "Meta ") + roleKey), }; }), ]; @@ -467,16 +469,16 @@ export const hotkeyActionNameSchema = z.enum([ "貼り付け", "すべて選択", "選択解除", - "1番目のキャラクターを選択", - "2番目のキャラクターを選択", - "3番目のキャラクターを選択", - "4番目のキャラクターを選択", - "5番目のキャラクターを選択", - "6番目のキャラクターを選択", - "7番目のキャラクターを選択", - "8番目のキャラクターを選択", - "9番目のキャラクターを選択", - "10番目のキャラクターを選択", + `1${actionPostfixSelectNthCharacter}`, + `2${actionPostfixSelectNthCharacter}`, + `3${actionPostfixSelectNthCharacter}`, + `4${actionPostfixSelectNthCharacter}`, + `5${actionPostfixSelectNthCharacter}`, + `6${actionPostfixSelectNthCharacter}`, + `7${actionPostfixSelectNthCharacter}`, + `8${actionPostfixSelectNthCharacter}`, + `9${actionPostfixSelectNthCharacter}`, + `10${actionPostfixSelectNthCharacter}`, ]); export type HotkeyActionNameType = z.infer;