diff --git a/frontend/src/components/common/Game/Card/Base.vue b/frontend/src/components/common/Game/Card/Base.vue index a18353a8d..d8728a68b 100644 --- a/frontend/src/components/common/Game/Card/Base.vue +++ b/frontend/src/components/common/Game/Card/Base.vue @@ -210,17 +210,17 @@ const onMouseLeave = () => { gameIsHovering.value = false; }; -emitter?.on("playGame", (romId: number) => { +const handlePlayGame = (romId: number) => { if (romId !== props.rom.id) return; - - // Trigger animation based on game type if (animateCD.value) { animateCDSpin(); animateCDLoad(); } else if (animateCartridge.value) { animateLoadCart(); } -}); +}; + +emitter?.on("playGame", handlePlayGame); onMounted(() => { if (tiltCardRef.value && !smAndDown.value && props.enable3DTilt) { @@ -238,7 +238,7 @@ onBeforeUnmount(() => { if (tiltCardRef.value?.vanillaTilt && props.enable3DTilt) { tiltCardRef.value.vanillaTilt.destroy(); } - emitter?.off("playGame"); + emitter?.off("playGame", handlePlayGame); stopCDAnimation(); }); diff --git a/frontend/src/components/common/Game/Dialog/MatchRom.vue b/frontend/src/components/common/Game/Dialog/MatchRom.vue index 987d68b9b..b4bafaf6b 100644 --- a/frontend/src/components/common/Game/Dialog/MatchRom.vue +++ b/frontend/src/components/common/Game/Dialog/MatchRom.vue @@ -60,17 +60,17 @@ const computedAspectRatio = computed(() => { galleryViewStore.defaultAspectRatioCover; return parseFloat(ratio.toString()); }); -emitter?.on("showMatchRomDialog", (romToSearch) => { + +const handleShowMatchRomDialog = (romToSearch: SimpleRom) => { rom.value = romToSearch; show.value = true; matchedRoms.value = []; - - // Use name as search term, only when it's matched - // Otherwise use the filename without tags and extensions searchText.value = romToSearch.is_identified ? (romToSearch.name ?? "") : romToSearch.fs_name_no_tags; -}); +}; +emitter?.on("showMatchRomDialog", handleShowMatchRomDialog); + const missingCoverImage = computed(() => getMissingCoverImage(rom.value?.name || rom.value?.fs_name || ""), ); @@ -314,7 +314,7 @@ function closeDialog() { } onBeforeUnmount(() => { - emitter?.off("showMatchRomDialog"); + emitter?.off("showMatchRomDialog", handleShowMatchRomDialog); }); diff --git a/frontend/src/components/common/SearchCover.vue b/frontend/src/components/common/SearchCover.vue index 1e0979526..fadbaddb7 100644 --- a/frontend/src/components/common/SearchCover.vue +++ b/frontend/src/components/common/SearchCover.vue @@ -20,13 +20,20 @@ const filteredCovers = ref(); const panels = ref([0]); const emitter = inject>("emitter"); -emitter?.on("showSearchCoverDialog", ({ term, aspectRatio = null }) => { + +const handleShowSearchCoverDialog = ({ + term, + aspectRatio = null, +}: { + term: string; + aspectRatio: number | null; +}) => { searchText.value = term; show.value = true; - // TODO: set default aspect ratio to 2/3 if (aspectRatio) coverAspectRatio.value = aspectRatio; if (searchText.value) searchCovers(); -}); +}; +emitter?.on("showSearchCoverDialog", handleShowSearchCoverDialog); const coverAspectRatio = ref( parseFloat(galleryViewStore.defaultAspectRatioCover.toString()), @@ -105,7 +112,7 @@ function closeDialog() { } onBeforeUnmount(() => { - emitter?.off("showSearchCoverDialog"); + emitter?.off("showSearchCoverDialog", handleShowSearchCoverDialog); }); diff --git a/frontend/src/composables/useGameAnimation.ts b/frontend/src/composables/useGameAnimation.ts index 8d69b4d6d..d5b70aa23 100644 --- a/frontend/src/composables/useGameAnimation.ts +++ b/frontend/src/composables/useGameAnimation.ts @@ -22,20 +22,15 @@ export const ANIMATION_CONFIG = { }; function getTranslateY(el: HTMLElement) { - const st = window.getComputedStyle(el); - const tr = st.transform; - if (!tr || tr === "none") return 0; + const transform = window.getComputedStyle(el).transform; + if (!transform || transform === "none") return 0; - const m = tr.match(/\(([^)]+)\)/); - if (!m) return 0; - - const values = m[1].split(",").map((v) => parseFloat(v.trim())); - if (tr.startsWith("matrix3d")) { - // matrix3d(...) has 16 values, translation is at indexes 12,13,14 (tx, ty, tz) - return values[13] || 0; // ty - } else { - // matrix(a, b, c, d, tx, ty) -> ty is index 5 - return values[5] || 0; + try { + const matrix = new DOMMatrix(transform); + return matrix.m42; // m42 is the ty value (vertical translation) + } catch (e) { + console.error("Failed to parse transform matrix:", e); + return 0; } } @@ -109,6 +104,7 @@ export function useGameAnimation({ // Update velocity and angle with acceleration velocity += (accelerate.value ? accelerationRate : decelerationRate) * deltaTime; + // Clamp the velocity velocity = Math.min(maxRotationSpeed, Math.max(0, velocity)); angle = (angle + velocity * deltaTime) % 360; diff --git a/frontend/src/utils/index.ts b/frontend/src/utils/index.ts index 4d1d8df4c..d616a65ea 100644 --- a/frontend/src/utils/index.ts +++ b/frontend/src/utils/index.ts @@ -747,7 +747,7 @@ export function platformCategoryToIcon(category: string) { export const FRONTEND_RESOURCES_PATH = "/assets/romm/resources"; -export const CD_BASED_SYSTEMS = [ +export const CD_BASED_SYSTEMS = new Set([ "3do", // 3DO "amiga-cd32", // Amiga CD32 "atari-jaguar-cd", // Atari Jaguar CD @@ -778,8 +778,8 @@ export const CD_BASED_SYSTEMS = [ "xbox", // Xbox "xbox360", // Xbox 360 "xboxone", // Xbox One -]; +]); export function isCDBasedSystem(platformSlug: string): boolean { - return CD_BASED_SYSTEMS.includes(platformSlug); + return CD_BASED_SYSTEMS.has(platformSlug.toLowerCase()); }