derive per platform aspect ratios

This commit is contained in:
Georges-Antoine Assi
2026-03-08 11:18:34 -04:00
parent 88495750e8
commit 0422f24f7f
2 changed files with 77 additions and 59 deletions

View File

@@ -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: {

View File

@@ -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;