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

ソングエディタの編集状態を保存できるようにする #1829

Merged
merged 29 commits into from
Feb 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
3433ee9
add sing schema
y-chan Feb 16, 2024
0d24be4
change project file shape and schema
y-chan Feb 16, 2024
f7abe20
fix missing attribute
y-chan Feb 16, 2024
c4958a0
make all editor states required in project file
y-chan Feb 16, 2024
374354f
remove await and use commit
y-chan Feb 16, 2024
f51a75e
separate phrases map and phrase data map
y-chan Feb 16, 2024
b252f4b
add project load/save buttons to sing editor
y-chan Feb 16, 2024
bdbc6f8
fmt
y-chan Feb 16, 2024
59b9687
add generate singing store initial score func
y-chan Feb 16, 2024
f878e57
initialize song project in create new project
y-chan Feb 16, 2024
98e5cad
rename editor detect variable
y-chan Feb 16, 2024
f904b05
remove phrases
y-chan Feb 16, 2024
006d795
rename sing to song
y-chan Feb 16, 2024
8b51dcc
use dispatch
y-chan Feb 16, 2024
b0e44d5
improve comment
y-chan Feb 16, 2024
4bed10f
add await for set singer and score
y-chan Feb 16, 2024
8176489
improve comment
y-chan Feb 16, 2024
02c4eeb
extract object in migration
y-chan Feb 16, 2024
2e98a87
Revert "separate phrases map and phrase data map"
y-chan Feb 16, 2024
872765a
revert phrase schema
y-chan Feb 16, 2024
718264e
remove last active editor property from project
y-chan Feb 16, 2024
1090591
move talk project validation
y-chan Feb 16, 2024
9de4de1
remove phrases from sing store initial score
y-chan Feb 16, 2024
ba55cc5
add comment of not using generate singing store initial score func
y-chan Feb 16, 2024
b60e0b0
add key shift to song initial object
y-chan Feb 16, 2024
c83b1c7
add set voice key shift to loading project
y-chan Feb 16, 2024
2368523
create apply talk project to store
y-chan Feb 16, 2024
11aa7ca
create apply song project to store func
y-chan Feb 16, 2024
d9f40d4
add missing await
y-chan Feb 16, 2024
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
111 changes: 110 additions & 1 deletion src/components/Menu/MenuBar/BaseMenuBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ import TitleBarButtons from "./TitleBarButtons.vue";
import TitleBarEditorSwitcher from "./TitleBarEditorSwitcher.vue";
import { useStore } from "@/store";
import { base64ImageToUri } from "@/helpers/imageHelper";
import { HotkeyActionType, HotkeyReturnType } from "@/type/preload";
import { setHotkeyFunctions } from "@/store/setting";

const props =
defineProps<{
Expand Down Expand Up @@ -119,6 +121,65 @@ const openHelpDialog = () => {
});
};

const createNewProject = async () => {
if (!uiLocked.value) {
await store.dispatch("CREATE_NEW_PROJECT", {});
}
};

const saveProject = async () => {
if (!uiLocked.value) {
await store.dispatch("SAVE_PROJECT_FILE", { overwrite: true });
}
};

const saveProjectAs = async () => {
if (!uiLocked.value) {
await store.dispatch("SAVE_PROJECT_FILE", {});
}
};

const importProject = () => {
if (!uiLocked.value) {
store.dispatch("LOAD_PROJECT_FILE", {});
}
};

// 「最近使ったプロジェクト」のメニュー
const recentProjectsSubMenuData = ref<MenuItemData[]>([]);
const updateRecentProjects = async () => {
const recentlyUsedProjects = await store.dispatch(
"GET_RECENTLY_USED_PROJECTS"
);
recentProjectsSubMenuData.value =
recentlyUsedProjects.length === 0
? [
{
type: "button",
label: "最近使ったプロジェクトはありません",
onClick: () => {
// 何もしない
},
disabled: true,
disableWhenUiLocked: false,
},
]
: recentlyUsedProjects.map((projectFilePath) => ({
type: "button",
label: projectFilePath,
onClick: () => {
store.dispatch("LOAD_PROJECT_FILE", {
filePath: projectFilePath,
});
},
disableWhenUiLocked: false,
}));
};
const projectFilePath = computed(() => store.state.projectFilePath);
watch(projectFilePath, updateRecentProjects, {
immediate: true,
});

// 「エンジン」メニューのエンジン毎の項目
const engineSubMenuData = computed<MenuItemData[]>(() => {
let subMenu: MenuItemData[] = [];
Expand Down Expand Up @@ -223,7 +284,46 @@ const menudata = computed<MenuItemData[]>(() => [
closeAllDialog();
},
disableWhenUiLocked: false,
subMenu: props.fileSubMenuData,
subMenu: [
...props.fileSubMenuData,
{ type: "separator" },
{
type: "button",
label: "新規プロジェクト",
onClick: createNewProject,
disableWhenUiLocked: true,
},
{
type: "button",
label: "プロジェクトを上書き保存",
onClick: async () => {
await saveProject();
},
disableWhenUiLocked: true,
},
{
type: "button",
label: "プロジェクトを名前を付けて保存",
onClick: async () => {
await saveProjectAs();
},
disableWhenUiLocked: true,
},
{
type: "button",
label: "プロジェクト読み込み",
onClick: () => {
importProject();
},
disableWhenUiLocked: true,
},
{
type: "root",
label: "最近使ったプロジェクト",
disableWhenUiLocked: true,
subMenu: recentProjectsSubMenuData.value,
},
],
},
{
type: "root",
Expand Down Expand Up @@ -338,6 +438,15 @@ watch(uiLocked, () => {
subMenuOpenFlags.value = [...Array(menudata.value.length)].map(() => false);
}
});

const hotkeyMap = new Map<HotkeyActionType, () => HotkeyReturnType>([
["新規プロジェクト", createNewProject],
["プロジェクトを上書き保存", saveProject],
["プロジェクトを名前を付けて保存", saveProjectAs],
["プロジェクト読み込み", importProject],
]);

setHotkeyFunctions(hotkeyMap);
</script>

<style lang="scss">
Expand Down
14 changes: 7 additions & 7 deletions src/components/Sing/MenuBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,26 @@ const exportWaveFile = async () => {
const fileSubMenuData: MenuItemData[] = [
{
type: "button",
label: "MIDI読み込み",
label: "音声を出力",
onClick: () => {
importMidiFile();
exportWaveFile();
},
disableWhenUiLocked: true,
},
{ type: "separator" },
{
type: "button",
label: "MusicXML読み込み",
label: "MIDI読み込み",
onClick: () => {
importMusicXMLFile();
importMidiFile();
},
disableWhenUiLocked: true,
},
{ type: "separator" },
{
type: "button",
label: "音声を出力",
label: "MusicXML読み込み",
onClick: () => {
exportWaveFile();
importMusicXMLFile();
},
disableWhenUiLocked: true,
},
Expand Down
102 changes: 1 addition & 101 deletions src/components/Talk/MenuBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</template>

<script setup lang="ts">
import { computed, ref, watch } from "vue";
import { computed } from "vue";
import { MenuItemData } from "@/components/Menu/type";
import {
generateAndConnectAndSaveAudioWithDialog,
Expand All @@ -20,12 +20,6 @@ import { setHotkeyFunctions } from "@/store/setting";
const store = useStore();
const uiLocked = computed(() => store.getters.UI_LOCKED);

const createNewProject = async () => {
if (!uiLocked.value) {
await store.dispatch("CREATE_NEW_PROJECT", {});
}
};

const generateAndSaveAllAudio = async () => {
if (!uiLocked.value) {
await multiGenerateAndSaveAudioWithDialog({
Expand Down Expand Up @@ -91,59 +85,6 @@ const importTextFile = () => {
}
};

const saveProject = async () => {
if (!uiLocked.value) {
await store.dispatch("SAVE_PROJECT_FILE", { overwrite: true });
}
};

const saveProjectAs = async () => {
if (!uiLocked.value) {
await store.dispatch("SAVE_PROJECT_FILE", {});
}
};

const importProject = () => {
if (!uiLocked.value) {
store.dispatch("LOAD_PROJECT_FILE", {});
}
};

// 「最近使ったプロジェクト」のメニュー
const recentProjectsSubMenuData = ref<MenuItemData[]>([]);
const updateRecentProjects = async () => {
const recentlyUsedProjects = await store.dispatch(
"GET_RECENTLY_USED_PROJECTS"
);
recentProjectsSubMenuData.value =
recentlyUsedProjects.length === 0
? [
{
type: "button",
label: "最近使ったプロジェクトはありません",
onClick: () => {
// 何もしない
},
disabled: true,
disableWhenUiLocked: false,
},
]
: recentlyUsedProjects.map((projectFilePath) => ({
type: "button",
label: projectFilePath,
onClick: () => {
store.dispatch("LOAD_PROJECT_FILE", {
filePath: projectFilePath,
});
},
disableWhenUiLocked: false,
}));
};
const projectFilePath = computed(() => store.state.projectFilePath);
watch(projectFilePath, updateRecentProjects, {
immediate: true,
});

// 「ファイル」メニュー
const fileSubMenuData = computed<MenuItemData[]>(() => [
{
Expand Down Expand Up @@ -187,54 +128,13 @@ const fileSubMenuData = computed<MenuItemData[]>(() => [
},
disableWhenUiLocked: true,
},
{ type: "separator" },
{
type: "button",
label: "新規プロジェクト",
onClick: createNewProject,
disableWhenUiLocked: true,
},
{
type: "button",
label: "プロジェクトを上書き保存",
onClick: async () => {
await saveProject();
},
disableWhenUiLocked: true,
},
{
type: "button",
label: "プロジェクトを名前を付けて保存",
onClick: async () => {
await saveProjectAs();
},
disableWhenUiLocked: true,
},
{
type: "button",
label: "プロジェクト読み込み",
onClick: () => {
importProject();
},
disableWhenUiLocked: true,
},
{
type: "root",
label: "最近使ったプロジェクト",
disableWhenUiLocked: true,
subMenu: recentProjectsSubMenuData.value,
},
]);

const hotkeyMap = new Map<HotkeyActionType, () => HotkeyReturnType>([
["新規プロジェクト", createNewProject],
["音声書き出し", generateAndSaveAllAudio],
["選択音声を書き出し", generateAndSaveSelectedAudio],
["音声を繋げて書き出し", generateAndConnectAndSaveAllAudio],
["テキスト読み込む", importTextFile],
["プロジェクトを上書き保存", saveProject],
["プロジェクトを名前を付けて保存", saveProjectAs],
["プロジェクト読み込み", importProject],
]);

setHotkeyFunctions(hotkeyMap);
Expand Down
Loading
Loading