From 54038393550d35a2406fd76e140bf5ef04fa881c Mon Sep 17 00:00:00 2001 From: Neko Ayaka Date: Wed, 19 Feb 2025 23:31:09 +0800 Subject: [PATCH] chore(stage-tamagotchi): updated animation config --- .vscode/settings.json | 3 +- packages/stage-tamagotchi/src/main/index.ts | 44 +++++++-------------- 2 files changed, 17 insertions(+), 30 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index 9a293bb7a..60f483623 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,7 +3,8 @@ "i18n-ally.keystyle": "nested", "i18n-ally.localesPaths": [ "packages/stage-web/locales", - "packages/stage-tamagotchi/locales" + "packages/stage-tamagotchi/src/renderer/locales", + "packages/stage-tamagotchi/src/main/locales" ], "i18n-ally.sortKeys": true, diff --git a/packages/stage-tamagotchi/src/main/index.ts b/packages/stage-tamagotchi/src/main/index.ts index 9a50934ba..aa2f4525b 100644 --- a/packages/stage-tamagotchi/src/main/index.ts +++ b/packages/stage-tamagotchi/src/main/index.ts @@ -5,9 +5,6 @@ import { app, BrowserWindow, dialog, ipcMain, Menu, screen, shell } from 'electr import { animate } from 'popmotion' import icon from '../../build/icon.png?asset' -import { createI18n } from './locales' - -const { t, setLocale } = createI18n() let globalMouseTracker: ReturnType | null = null let mainWindow: BrowserWindow @@ -141,39 +138,33 @@ function createSettingsWindow(): void { } } -function buildMenu(): Menu { - return Menu.buildFromTemplate([ +// This method will be called when Electron has finished +// initialization and is ready to create browser windows. +// Some APIs can only be used after this event occurs. +app.whenReady().then(() => { + // Menu + const menu = Menu.buildFromTemplate([ { label: 'airi', role: 'appMenu', submenu: [ { role: 'about', - label: t('menu.about'), }, { role: 'toggleDevTools', - label: t('menu.toggleDevTools'), }, { - label: t('menu.settings'), + label: 'Settings', click: () => createSettingsWindow(), }, { - label: t('menu.quit'), + label: 'Quit', click: () => app.quit(), }, ], }, ]) -} - -// This method will be called when Electron has finished -// initialization and is ready to create browser windows. -// Some APIs can only be used after this event occurs. -app.whenReady().then(() => { - // Menu - const menu = buildMenu() Menu.setApplicationMenu(menu) // Set app user model id for windows @@ -186,19 +177,14 @@ app.whenReady().then(() => { optimizer.watchWindowShortcuts(window) }) - ipcMain.on('locale-changed', (_, locale: string) => { - setLocale(locale) - - Menu.setApplicationMenu(buildMenu()) - }) - + // IPC test + // TODO: i18n ipcMain.on('quit', () => { dialog.showMessageBox({ type: 'info', - title: t('quitDialog.title'), - message: t('quitDialog.message'), - buttons: [t('quitDialog.buttons.0'), t('quitDialog.buttons.1')], - defaultId: 0, + title: 'Quit', + message: 'Are you sure you want to quit?', + buttons: ['Quit', 'Cancel'], }).then((result) => { if (result.response === 0) { app.quit() @@ -249,8 +235,8 @@ function handleWindowMove(cursorX: number, cursorY: number) { // Shared animation config for squishie bounce effect const springConfig = { - stiffness: 300, // Reduced for more elastic feel - damping: 15, // Lower damping for more bounces + stiffness: 2000, // Reduced for more elastic feel + damping: 100, // Lower damping for more bounces mass: 0.5, // Higher mass for more momentum restSpeed: 0.1, // Lower rest speed to allow more bouncing }