Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[project-s] キャラクターメニューの調整 #1764

Merged
merged 2 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 34 additions & 19 deletions src/components/Sing/CharacterMenuButton.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<q-btn flat class="q-pa-none">
<slot />
<slot></slot>
<q-menu
class="character-menu"
transition-show="none"
Expand Down Expand Up @@ -86,7 +86,9 @@
>
<q-list>
<q-item
v-for="(style, styleIndex) in characterInfo.metas.styles"
v-for="(style, styleIndex) in getSingingStyles(
characterInfo
)"
:key="styleIndex"
v-close-popup
clickable
Expand All @@ -104,27 +106,21 @@
no-spinner
no-transition
:ratio="1"
:src="characterInfo.metas.styles[styleIndex].iconPath"
:src="style.iconPath"
/>
<q-avatar
v-if="isMultipleEngine"
rounded
class="engine-icon"
>
<img
:src="
engineIcons[
characterInfo.metas.styles[styleIndex].engineId
]
"
/>
<img :src="engineIcons[style.engineId]" />
</q-avatar>
</q-avatar>
<q-item-section v-if="style.styleName"
>{{ characterInfo.metas.speakerName }} ({{
style.styleName
}})</q-item-section
>
<q-item-section v-if="style.styleName">
{{ characterInfo.metas.speakerName }} ({{
getStyleDescription(style)
}})
</q-item-section>
<q-item-section v-else>{{
characterInfo.metas.speakerName
}}</q-item-section>
Expand All @@ -145,17 +141,28 @@ import { defineComponent, computed, ref } from "vue";
import { debounce } from "quasar";
import { useStore } from "@/store";
import { base64ImageToUri } from "@/helpers/imageHelper";
import { SpeakerId, StyleId } from "@/type/preload";
import { CharacterInfo, SpeakerId, StyleId, StyleInfo } from "@/type/preload";
import { getStyleDescription } from "@/sing/viewHelper";

export default defineComponent({
name: "CharacterMenuButton",

setup() {
const store = useStore();

const userOrderedCharacterInfos = computed(
() => store.getters.USER_ORDERED_CHARACTER_INFOS
);
const isSingingStyle = (styleInfo: StyleInfo) => {
return (
styleInfo.styleType === "humming" ||
styleInfo.styleType === "sing_teacher"
);
};

const userOrderedCharacterInfos = computed(() => {
return store.getters.USER_ORDERED_CHARACTER_INFOS?.filter(
(characterInfo) =>
characterInfo.metas.styles.some((value) => isSingingStyle(value))
);
});

const subMenuOpenFlags = ref(
[...Array(userOrderedCharacterInfos.value?.length)].map(() => false)
Expand Down Expand Up @@ -207,6 +214,12 @@ export default defineComponent({
return defaultStyle;
};

const getSingingStyles = (characterInfo: CharacterInfo) => {
return characterInfo.metas.styles.filter((value) =>
isSingingStyle(value)
);
};

const selectedCharacterInfo = computed(() => {
if (
userOrderedCharacterInfos.value == undefined ||
Expand Down Expand Up @@ -250,6 +263,8 @@ export default defineComponent({
reassignSubMenuOpen,
changeStyleId,
getDefaultStyle,
getSingingStyles,
getStyleDescription,
selectedCharacterInfo,
selectedSpeakerUuid,
selectedStyleId,
Expand Down
12 changes: 7 additions & 5 deletions src/components/Sing/ToolBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
{{ selectedCharacterName }}
</div>
<div class="character-style">
{{ selectedCharacterStyle }}
{{ selectedCharacterStyleDescription }}
</div>
</div>
<q-icon
Expand Down Expand Up @@ -124,6 +124,7 @@ import {
isValidBpm,
} from "@/sing/domain";
import CharacterMenuButton from "@/components/Sing/CharacterMenuButton.vue";
import { getStyleDescription } from "@/sing/viewHelper";

export default defineComponent({
name: "SingToolBar",
Expand All @@ -150,13 +151,14 @@ export default defineComponent({
const selectedCharacterName = computed(() => {
return selectedCharacterInfo.value?.metas.speakerName;
});
const selectedCharacterStyle = computed(() => {
return selectedCharacterInfo.value?.metas.styles.find((style) => {
const selectedCharacterStyleDescription = computed(() => {
const style = selectedCharacterInfo.value?.metas.styles.find((style) => {
return (
style.styleId === store.state.singer?.styleId &&
style.engineId === store.state.singer?.engineId
);
})?.styleName;
});
return style != undefined ? getStyleDescription(style) : "";
Copy link
Member

@Hiroshiba Hiroshiba Jan 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これもエラーの握り潰しになっちゃってる雰囲気があるんですが、エンジンが準備できてないときは必ずundefinedになるので、結構どうしようもないんですよね・・・。

これは結局、このviewが本来準備できていないはずの状態でインスタンス化しようとさせられるのが課題だろうな~と思っています。
(ボイボエディタ全体的に、Vueの起動シーケンスの整理が追いついてない)

});
const selectedStyleIconPath = computed(() => {
const styles = selectedCharacterInfo.value?.metas.styles;
Expand Down Expand Up @@ -328,7 +330,7 @@ export default defineComponent({
return {
uiLocked,
selectedCharacterName,
selectedCharacterStyle,
selectedCharacterStyleDescription,
selectedStyleIconPath,
bpmInputBuffer,
beatsInputBuffer,
Expand Down
19 changes: 19 additions & 0 deletions src/sing/viewHelper.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { StyleInfo } from "@/type/preload";

const BASE_X_PER_QUARTER_NOTE = 120;
const BASE_Y_PER_SEMITONE = 30;

Expand Down Expand Up @@ -97,3 +99,20 @@ export const keyInfos = [...Array(128)]
};
})
.reverse();

export const getStyleDescription = (style: StyleInfo) => {
const description: string[] = [];
if (style.styleType === "talk") {
description.push("トーク");
} else if (style.styleType === "humming") {
description.push("ハミング");
} else if (style.styleType === "sing_teacher") {
description.push("歌");
} else {
throw new Error("Unknown style type.");
}
if (style.styleName != undefined) {
description.push(style.styleName);
}
return description.join("・");
Comment on lines +104 to +117
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ひとまずhummingは「ハミング」、sing_teacherは「歌」と表示するようにしています。
また、styleTypestyleNameは「・」で区切っています。

};
1 change: 1 addition & 0 deletions src/store/audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ export const audioStore = createPartialStore<AudioStoreTypes>({
styles[i] = {
styleName: style.name,
styleId: StyleId(style.id),
styleType: style.type,
engineId,
iconPath: base64ImageToUri(styleInfo.icon),
portraitPath:
Expand Down
3 changes: 3 additions & 0 deletions src/type/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,12 @@ export type AppInfos = {
version: string;
};

export type StyleType = "talk" | "humming" | "sing_teacher";

export type StyleInfo = {
styleName?: string;
styleId: StyleId;
styleType?: StyleType;
iconPath: string;
portraitPath: string | undefined;
engineId: EngineId;
Expand Down
Loading