From 0422f24f7fcd6290de8ccf526c8b092b3d445841 Mon Sep 17 00:00:00 2001 From: Georges-Antoine Assi Date: Sun, 8 Mar 2026 11:18:34 -0400 Subject: [PATCH] derive per platform aspect ratios --- .../AppBar/Platform/PlatformInfoDrawer.vue | 120 +++++++++++------- frontend/src/stores/galleryView.ts | 16 +-- 2 files changed, 77 insertions(+), 59 deletions(-) diff --git a/frontend/src/components/Gallery/AppBar/Platform/PlatformInfoDrawer.vue b/frontend/src/components/Gallery/AppBar/Platform/PlatformInfoDrawer.vue index 31667d12c..da636053e 100644 --- a/frontend/src/components/Gallery/AppBar/Platform/PlatformInfoDrawer.vue +++ b/frontend/src/components/Gallery/AppBar/Platform/PlatformInfoDrawer.vue @@ -33,53 +33,79 @@ const auth = storeAuth(); const navigationStore = storeNavigation(); const { activePlatformInfoDrawer } = storeToRefs(navigationStore); const selectedAspectRatio = ref(0); -const aspectRatioOptions = computed(() => [ - { - name: "2 / 3", - size: 2 / 3, - source: "SteamGridDB", - }, - { - name: "3 / 4", - size: 3 / 4, - source: "IGDB / MobyGames", - }, - { - name: "0.71 / 1", - size: 0.71 / 1, - source: "DVD", - }, - { - name: "0.79 / 1", - size: 0.79 / 1, - source: "Blu-ray (Full artwork)", - }, - { - name: "0.87 / 1", - size: 0.87 / 1, - source: "Blu-ray (Plastic header)", - }, - { - name: "1.08 / 1", - size: 1.08 / 1, - source: "Nintendo DS / 3DS", - }, - { - name: "0.58 / 1", - size: 0.58 / 1, - source: "PSP", - }, - { - name: "1 / 1", - size: 1 / 1, - source: t("platform.old-squared-cases"), - }, - { - name: "16 / 11", - size: 16 / 11, - source: t("platform.old-horizontal-cases"), - }, -]); + +// Some platform boxes have specific aspect ratios +const DVD_PLATFORMS = new Set(["dvd-player"]); +const BLU_RAY_PLATFORMS = new Set(["blu-ray-player"]); +const DS_3DS_PLATFORMS = new Set(["3ds", "nds", "new-nintendo-3ds"]); +const PSP_PLATFORMS = new Set(["psp", "psp-minis"]); + +const aspectRatioOptions = computed(() => { + const slug = currentPlatform.value?.slug?.toLowerCase() ?? ""; + return [ + { + name: "2 / 3", + size: 2 / 3, + source: "SteamGridDB", + }, + { + name: "3 / 4", + size: 3 / 4, + source: "IGDB / MobyGames", + }, + ...(DVD_PLATFORMS.has(slug) + ? [ + { + name: "0.71 / 1", + size: 0.71 / 1, + source: "DVD", + }, + ] + : []), + ...(BLU_RAY_PLATFORMS.has(slug) + ? [ + { + name: "0.79 / 1", + size: 0.79 / 1, + source: "Blu-ray (Full artwork)", + }, + { + name: "0.87 / 1", + size: 0.87 / 1, + source: "Blu-ray (Plastic header)", + }, + ] + : []), + ...(DS_3DS_PLATFORMS.has(slug) + ? [ + { + name: "1.08 / 1", + size: 1.08 / 1, + source: "Nintendo DS / 3DS", + }, + ] + : []), + ...(PSP_PLATFORMS.has(slug) + ? [ + { + name: "0.58 / 1", + size: 0.58 / 1, + source: "PSP", + }, + ] + : []), + { + name: "1 / 1", + size: 1 / 1, + source: t("platform.old-squared-cases"), + }, + { + name: "16 / 11", + size: 16 / 11, + source: t("platform.old-horizontal-cases"), + }, + ]; +}); const tabIndex = computed(() => (activePlatformInfoDrawer.value ? 0 : -1)); const PLATFORM_INFO_FIELDS: { diff --git a/frontend/src/stores/galleryView.ts b/frontend/src/stores/galleryView.ts index d05da12b9..f93b9fb56 100644 --- a/frontend/src/stores/galleryView.ts +++ b/frontend/src/stores/galleryView.ts @@ -46,18 +46,10 @@ export default defineStore("galleryView", { const platformsStore = storePlatforms(); const platform = platformId ? platformsStore.get(platformId) : null; if (platform?.aspect_ratio) { - const ratioParts = platform.aspect_ratio.match(/\d+(?:\.\d+)?/g); - if (ratioParts && ratioParts.length >= 2) { - const width = Number(ratioParts[0]); - const height = Number(ratioParts[1]); - if ( - Number.isFinite(width) && - Number.isFinite(height) && - height !== 0 - ) { - return width / height; - } - } + return ( + parseFloat(platform.aspect_ratio.split("/")[0]) / + parseFloat(platform.aspect_ratio.split("/")[1]) + ); } return this.defaultAspectRatio;