diff --git a/src/components/Dialog/CharacterOrderDialog.vue b/src/components/Dialog/CharacterOrderDialog.vue index d190328212..b9f6e27f17 100644 --- a/src/components/Dialog/CharacterOrderDialog.vue +++ b/src/components/Dialog/CharacterOrderDialog.vue @@ -50,7 +50,7 @@ サンプルボイス一覧
; }>(); const emit = @@ -129,12 +129,8 @@ const modelValueComputed = computed({ set: (val) => emit("update:modelValue", val), }); -const characterInfosMap = computed(() => { - const map: { [key: SpeakerId]: CharacterInfo } = {}; - props.characterInfos.forEach((characterInfo) => { - map[characterInfo.metas.speakerUuid] = characterInfo; - }); - return map; +const characterInfosArray = computed(() => { + return [...props.characterInfos.values()]; }); // 新しいキャラクター @@ -145,13 +141,15 @@ const hasNewCharacter = computed(() => newCharacters.value.length > 0); const sampleCharacterOrder = ref([]); // 選択中のキャラクター -const selectedCharacter = ref(props.characterInfos[0].metas.speakerUuid); +const selectedCharacter = ref(characterInfosArray.value[0].metas.speakerUuid); const selectCharacter = (speakerUuid: SpeakerId) => { selectedCharacter.value = speakerUuid; }; const selectCharacterWithChangePortrait = (speakerUuid: SpeakerId) => { selectCharacter(speakerUuid); - portrait.value = characterInfosMap.value[speakerUuid].portraitPath; + const characterInfo = props.characterInfos.get(speakerUuid); + if (characterInfo == undefined) throw new Error("characterInfo is undefined"); + portrait.value = characterInfo.portraitPath; }; // キャラクター表示順序 @@ -168,7 +166,7 @@ watch( // サンプルの順番、新しいキャラクターは上に sampleCharacterOrder.value = [ ...newCharacters.value, - ...props.characterInfos + ...characterInfosArray.value .filter( (info) => !newCharacters.value.includes(info.metas.speakerUuid) ) @@ -180,11 +178,11 @@ watch( // 保存済みのキャラクターリストを取得 // FIXME: 不明なキャラを無視しているので、不明キャラの順番が保存時にリセットされてしまう characterOrder.value = store.state.userCharacterOrder - .map((speakerUuid) => characterInfosMap.value[speakerUuid]) + .map((speakerUuid) => props.characterInfos.get(speakerUuid)) .filter((info) => info != undefined) as CharacterInfo[]; // 含まれていないキャラクターを足す - const notIncludesCharacterInfos = props.characterInfos.filter( + const notIncludesCharacterInfos = characterInfosArray.value.filter( (characterInfo) => !characterOrder.value.find( (characterInfoInList) => @@ -261,7 +259,7 @@ const closeDialog = () => { }; const portrait = ref( - characterInfosMap.value[selectedCharacter.value].portraitPath + props.characterInfos.get(selectedCharacter.value)?.portraitPath ); const updatePortrait = (portraitPath: string) => { portrait.value = portraitPath; diff --git a/src/components/Talk/EditorHome.vue b/src/components/Talk/EditorHome.vue index 54e996276d..d5b964c6f9 100644 --- a/src/components/Talk/EditorHome.vue +++ b/src/components/Talk/EditorHome.vue @@ -162,14 +162,14 @@ @@ -711,9 +711,7 @@ const isAcceptTermsDialogOpenComputed = computed({ }); // キャラクター並び替え -const orderedAllCharacterInfos = computed( - () => store.getters.GET_ORDERED_ALL_CHARACTER_INFOS -); +const allCharacterInfos = computed(() => store.getters.GET_ALL_CHARACTER_INFOS); const isCharacterOrderDialogOpenComputed = computed({ get: () => !store.state.isAcceptTermsDialogOpen && @@ -726,9 +724,9 @@ const isCharacterOrderDialogOpenComputed = computed({ // TODO: デフォルトスタイル選択(ソング)の実装 // デフォルトスタイル選択(トーク) -const orderedTalkCharacterInfos = computed(() => { +const allTalkCharacterInfos = computed(() => { return filterCharacterInfosByStyleType( - store.getters.GET_ORDERED_ALL_CHARACTER_INFOS, + [...store.getters.GET_ALL_CHARACTER_INFOS.values()], "talk" ); }); diff --git a/src/store/index.ts b/src/store/index.ts index 51072e8333..ae59077686 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -52,49 +52,12 @@ export const indexStore = createPartialStore({ * 同じspeakerUuidのキャラクター情報は、登録順が早いエンジンの情報を元に統合される。 * キャラクター情報が読み出されていないときは、空リストを返す。 */ - getter(state) { - const speakerUuids = [ - ...new Set( - state.engineIds.flatMap((engineId) => - (state.characterInfos[engineId] ?? []).map( - (c) => c.metas.speakerUuid - ) - ) - ), - ]; - const flattenCharacterInfos = speakerUuids.map((speakerUuid) => { - const characterInfos = state.engineIds.flatMap( - (engineId) => - state.characterInfos[engineId]?.find( - (c) => c.metas.speakerUuid === speakerUuid - ) ?? [] - ); - - // エンジンの登録順が早い方が優先される。 - return { - ...characterInfos[0], - metas: { - ...characterInfos[0].metas, - styles: characterInfos.flatMap((c) => c.metas.styles), - }, - }; - }); - return new Map( - flattenCharacterInfos.map((c) => [c.metas.speakerUuid, c]) - ); - }, - }, - /** - * すべてのエンジンのキャラクター情報のリスト。 - * GET_ALL_CHARACTER_INFOSとは違い、話者の順番が保持される。 - */ - GET_ORDERED_ALL_CHARACTER_INFOS: { getter(state) { const speakerUuids = state.engineIds .flatMap((engineId) => (state.characterInfos[engineId] ?? []).map((c) => c.metas.speakerUuid) ) - .filter((uuid, index, uuids) => uuids.indexOf(uuid) === index); // Setを使うと順番が保証されないのでindexOfで重複削除をする。 + .filter((uuid, index, uuids) => uuids.indexOf(uuid) === index); const flattenCharacterInfos = speakerUuids.map((speakerUuid) => { const characterInfos = state.engineIds.flatMap( (engineId) => @@ -112,7 +75,9 @@ export const indexStore = createPartialStore({ }, }; }); - return flattenCharacterInfos; + return new Map( + flattenCharacterInfos.map((c) => [c.metas.speakerUuid, c]) + ); }, }, diff --git a/src/store/type.ts b/src/store/type.ts index 6303454208..985b646b17 100644 --- a/src/store/type.ts +++ b/src/store/type.ts @@ -1190,10 +1190,6 @@ export type IndexStoreTypes = { getter: Map; }; - GET_ORDERED_ALL_CHARACTER_INFOS: { - getter: CharacterInfo[]; - }; - GET_ALL_VOICES: { getter: Voice[]; };