From 821d298586c4bea9d18d691124d6d10614180346 Mon Sep 17 00:00:00 2001 From: Yuto Ashida Date: Sun, 18 Feb 2024 02:43:46 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=BD=E3=83=B3=E3=82=B0=E3=82=A8=E3=83=87?= =?UTF-8?q?=E3=82=A3=E3=82=BF=E3=81=AE=E7=B7=A8=E9=9B=86=E7=8A=B6=E6=85=8B?= =?UTF-8?q?=E3=82=92=E4=BF=9D=E5=AD=98=E3=81=A7=E3=81=8D=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB=E3=81=99=E3=82=8B=20(#1829)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add sing schema * change project file shape and schema * fix missing attribute * make all editor states required in project file * remove await and use commit * separate phrases map and phrase data map * add project load/save buttons to sing editor * fmt * add generate singing store initial score func * initialize song project in create new project * rename editor detect variable * remove phrases * rename sing to song * use dispatch * improve comment Co-authored-by: Hiroshiba * add await for set singer and score Co-authored-by: Hiroshiba * improve comment Co-authored-by: Hiroshiba * extract object in migration * Revert "separate phrases map and phrase data map" This reverts commit 97d68a8f3556c238f0022dd215cdadeb1fd8d5b6. * revert phrase schema * remove last active editor property from project * move talk project validation * remove phrases from sing store initial score Co-authored-by: Sig * add comment of not using generate singing store initial score func * add key shift to song initial object * add set voice key shift to loading project * create apply talk project to store * create apply song project to store func * add missing await --------- Co-authored-by: Hiroshiba Co-authored-by: Sig --- src/components/Menu/MenuBar/BaseMenuBar.vue | 111 +++++++- src/components/Sing/MenuBar.vue | 14 +- src/components/Talk/MenuBar.vue | 102 +------ src/store/project.ts | 279 +++++++++++++++----- src/store/singing.ts | 50 ++-- src/store/type.ts | 67 +++-- 6 files changed, 392 insertions(+), 231 deletions(-) diff --git a/src/components/Menu/MenuBar/BaseMenuBar.vue b/src/components/Menu/MenuBar/BaseMenuBar.vue index 8ab5188d7a..fd28e23fa2 100644 --- a/src/components/Menu/MenuBar/BaseMenuBar.vue +++ b/src/components/Menu/MenuBar/BaseMenuBar.vue @@ -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<{ @@ -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([]); +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(() => { let subMenu: MenuItemData[] = []; @@ -223,7 +284,46 @@ const menudata = computed(() => [ 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", @@ -338,6 +438,15 @@ watch(uiLocked, () => { subMenuOpenFlags.value = [...Array(menudata.value.length)].map(() => false); } }); + +const hotkeyMap = new Map HotkeyReturnType>([ + ["新規プロジェクト", createNewProject], + ["プロジェクトを上書き保存", saveProject], + ["プロジェクトを名前を付けて保存", saveProjectAs], + ["プロジェクト読み込み", importProject], +]); + +setHotkeyFunctions(hotkeyMap);