diff --git a/frontend/src/components/buttons/index.ts b/frontend/src/components/buttons/index.ts index e3df513..f8d789c 100644 --- a/frontend/src/components/buttons/index.ts +++ b/frontend/src/components/buttons/index.ts @@ -1,6 +1,7 @@ // @index('./*', f => `export * from '${f.path}'`) export * from './convert_btn'; export * from './log_file_btn'; +export * from './log_dir_btn'; export * from './path_selector'; export * from './remove_oar_btn'; export * from './unhide_dar_btn'; diff --git a/frontend/src/components/buttons/log_dir_btn.tsx b/frontend/src/components/buttons/log_dir_btn.tsx new file mode 100644 index 0000000..5a52835 --- /dev/null +++ b/frontend/src/components/buttons/log_dir_btn.tsx @@ -0,0 +1,28 @@ +import FolderOpenIcon from '@mui/icons-material/FolderOpen'; +import { Button, Tooltip } from '@mui/material'; +import { toast } from 'react-hot-toast'; + +import { useTranslation } from '@/hooks'; +import { openLogDir } from '@/tauri_cmd'; + +export const LogDirButton = () => { + const { t } = useTranslation(); + + return ( + + + + ); +}; diff --git a/frontend/src/components/buttons/log_file_btn.tsx b/frontend/src/components/buttons/log_file_btn.tsx index 145c5a7..8315961 100644 --- a/frontend/src/components/buttons/log_file_btn.tsx +++ b/frontend/src/components/buttons/log_file_btn.tsx @@ -1,5 +1,5 @@ import { FileOpen } from '@mui/icons-material'; -import { Button } from '@mui/material'; +import { Button, Tooltip } from '@mui/material'; import { toast } from 'react-hot-toast'; import { useTranslation } from '@/hooks'; @@ -9,18 +9,20 @@ export const LogFileButton = () => { const { t } = useTranslation(); return ( - + + + ); }; diff --git a/frontend/src/components/form.tsx b/frontend/src/components/form.tsx index 61a94bc..fb4601d 100644 --- a/frontend/src/components/form.tsx +++ b/frontend/src/components/form.tsx @@ -8,7 +8,14 @@ import { listen } from '@tauri-apps/api/event'; import { Controller, useForm, type SubmitHandler } from 'react-hook-form'; import { toast } from 'react-hot-toast'; -import { ConvertButton, UnhideDarBtn, SelectPathButton, RemoveOarBtn, LogFileButton } from '@/components/buttons'; +import { + ConvertButton, + UnhideDarBtn, + SelectPathButton, + RemoveOarBtn, + LogFileButton, + LogDirButton, +} from '@/components/buttons'; import { SelectLogLevel } from '@/components/lists'; import { LinearWithValueLabel } from '@/components/notifications'; import { useTranslation } from '@/hooks'; @@ -310,16 +317,22 @@ export function ConvertForm() { )} /> - + + } /> - + + + + + + diff --git a/frontend/src/tauri_cmd/index.ts b/frontend/src/tauri_cmd/index.ts index bb9fc1d..17e7f6b 100644 --- a/frontend/src/tauri_cmd/index.ts +++ b/frontend/src/tauri_cmd/index.ts @@ -7,7 +7,7 @@ import { selectLogLevel } from '@/utils/selector'; export { open as openShell } from '@tauri-apps/api/shell'; -type ConverterArgs = { +type ConverterOptions = { src: string; dist?: string; modName?: string; @@ -20,10 +20,16 @@ type ConverterArgs = { }; /** - * Convert DAR to OAR - * # Throw Error + * Converts DAR to OAR. + * + * This function converts a DAR (DynamicAnimationReplacer) to an OAR (OpenAnimationReplacer). + * It takes the specified properties as arguments and invokes the appropriate conversion command. + * + * @param {ConverterOptions} props - Converter Options. + * @returns {Promise} A promise that resolves when converted. + * @throws */ -export async function convertDar2oar(props: ConverterArgs): Promise { +export async function convertDar2oar(props: ConverterOptions): Promise { const args = { options: { darDir: props.src === '' ? undefined : props.src, @@ -42,13 +48,22 @@ export async function convertDar2oar(props: ConverterArgs): Promise { const showProgress = props.showProgress ?? false; if (showProgress) { - return invoke('convert_dar2oar_with_progress', args); + return invoke('convert_dar2oar_with_progress', args); } else { - return invoke('convert_dar2oar', args); + return invoke('convert_dar2oar', args); } } export type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error'; + +/** + * Changes the log level. + * + * This function invokes the 'change_log_level' command with the specified log level. + * + * @param {LogLevel} [logLevel] - The log level to set. If not provided, the default log level will be used. + * @returns {Promise} A promise that resolves when the log level is changed. + */ export async function changeLogLevel(logLevel?: LogLevel): Promise { return invoke('change_log_level', { logLevel }); } @@ -58,21 +73,30 @@ export async function changeLogLevel(logLevel?: LogLevel): Promise { * * # Throw Error */ -export async function unhideDarDir(darDir: string, errMsg = 'DAR dir must be specified.') { +/** + * Add '.mohidden' to DAR's files. + * @param {string} darDir - A string representing the directory path of the DAR directory that needs to be + * unhidden. + * + * @throws + */ +export async function unhideDarDir(darDir: string) { if (darDir === '') { - throw new Error(errMsg); + throw new Error('darDir is empty string.'); } await invoke('unhide_dar_dir', { darDir }); } /** - * @param darPath - * - * # Throw Error + * The function `removeOarDir` is an asynchronous function that removes a specified directory and throws an error if the + * path is empty. + * @param {string} path - The `path` parameter is a string that specifies the directory path of the DAR or OAR directory + * that needs to be removed. + * @throws */ -export async function removeOarDir(path: string, errMsg = 'DAR or OAR dir must be specified.') { +export async function removeOarDir(path: string) { if (path === '') { - throw new Error(errMsg); + throw new Error('Specified path is empty string.'); } await invoke('remove_oar_dir', { path }); } @@ -80,7 +104,7 @@ export async function removeOarDir(path: string, errMsg = 'DAR or OAR dir must b /** * Open a file or Dir * - * # Throw Error + * @throws */ export async function openPath(path: string, setPath: (path: string) => void, isDir: boolean) { const res = await open({ @@ -96,8 +120,27 @@ export async function openPath(path: string, setPath: (path: string) => void, is } } +/** + * Opens the log file. + * + * This function retrieves the log directory using the appLogDir function, + * constructs the path to the log file, and opens the shell with the log file path. + * + * @throws - if not found path + */ export async function openLogFile() { const logDir = await appLogDir(); const logFile = `${logDir}g_dar2oar.log`; await openShell(logFile); } + +/** + * Opens the log directory. + * + * This function opens the shell and awaits the result of the appLogDir function. + * + * @throws - if not found path + */ +export async function openLogDir() { + await openShell(await appLogDir()); +} diff --git a/locales/en-US.json b/locales/en-US.json index d598787..9344c4a 100644 --- a/locales/en-US.json +++ b/locales/en-US.json @@ -40,6 +40,9 @@ "log-level-list-tooltip4": "Error: Logs nothing but errors.", "mapping-wiki-url-leaf": "wiki#what-is-the-mapping-file", "open-log-btn": "Open log", + "open-log-dir-btn": "Log(dir)", + "open-log-tooltip": "Open current log file.(Rotate to a new log file each time the application is launched.)", + "open-log-dir-tooltip": "Open the log storage location.", "progress-btn": "ProgressBar", "progress-btn-tooltip": "Display detail progress", "progress-btn-tooltip2": "", @@ -49,7 +52,7 @@ "remove-oar-success": "Removed OAR directory.", "remove-oar-tooltip": "Find and delete OAR dir from \"DAR(src) Directory*\" or \"OAR(dist) Directory\".", "run-parallel-btn-tooltip": "Use multi-threading.", - "run-parallel-btn-tooltip2": "NOTE: More than twice the processing speed can be expected, but the logs are difficult to read.", + "run-parallel-btn-tooltip2": "Note: More than twice the processing speed can be expected, but the concurrent processing results in thread termination timings being out of order, so log writes will be out of order as well, greatly reducing readability of the logs.", "run-parallel-label": "Run Parallel", "select-btn": "Select", "unhide-dar-btn": "Unhide DAR", diff --git a/locales/ja-JP.json b/locales/ja-JP.json index 1236740..f9c5306 100644 --- a/locales/ja-JP.json +++ b/locales/ja-JP.json @@ -39,7 +39,10 @@ "log-level-list-tooltip3": " Info: 変換時間を記録します", "log-level-list-tooltip4": "Error: 重大なエラー以外記録しません", "mapping-wiki-url-leaf": "wiki#what-is-the-mapping-file", - "open-log-btn": "ログを開く", + "open-log-btn": "ログを閲覧", + "open-log-dir-btn": "ログ(dir)", + "open-log-tooltip": "現在のログファイルを開きます。(アプリを起動するたびに新しいログファイルにローテーションします)", + "open-log-dir-tooltip": "ログの格納場所を開きます。", "progress-btn": "進捗バー", "progress-btn-tooltip": "詳細な進捗状況を表示します", "progress-btn-tooltip2": "", @@ -49,7 +52,7 @@ "remove-oar-success": "OARディレクトリを削除しました", "remove-oar-tooltip": "OAR(dist)(なければDAR(src))からOARディレクトリを捜索して削除します", "run-parallel-btn-tooltip": "マルチスレッドを使用します", - "run-parallel-btn-tooltip2": "注意: 2倍以上の処理速度が期待できますが、ログが読みづらいです", + "run-parallel-btn-tooltip2": "注意: 2倍以上の処理速度が期待できますが、平行処理によりスレッドの終了タイミングが順不同になるため、ログの書き込みも同様に順不同になりログの可読性が大幅に低下します。", "run-parallel-label": "並列実行", "select-btn": "選択", "unhide-dar-btn": "DAR再表示",