Skip to content

Commit

Permalink
chore(stage-tamagotchi): updated animation config
Browse files Browse the repository at this point in the history
  • Loading branch information
nekomeowww committed Feb 19, 2025
1 parent 2854483 commit 5403839
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 30 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,

Expand Down
44 changes: 15 additions & 29 deletions packages/stage-tamagotchi/src/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<typeof setInterval> | null = null
let mainWindow: BrowserWindow
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 5403839

Please sign in to comment.