Skip to content

Commit

Permalink
Merge pull request #1485 from rommapp/romm-1273
Browse files Browse the repository at this point in the history
[ROMM-1273] Use platform versions to check if game playable
  • Loading branch information
gantoine authored Jan 14, 2025
2 parents 6e3d5d6 + c164a9a commit a2cc8ea
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 12 deletions.
22 changes: 17 additions & 5 deletions frontend/src/components/Details/ActionBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import CopyRomDownloadLinkDialog from "@/components/common/Game/Dialog/CopyDownl
import romApi from "@/services/api/rom";
import storeDownload from "@/stores/download";
import storeHeartbeat from "@/stores/heartbeat";
import storeConfig from "@/stores/config";
import type { DetailedRom } from "@/stores/roms";
import type { Events } from "@/types/emitter";
import {
Expand All @@ -14,6 +15,7 @@ import {
} from "@/utils";
import type { Emitter } from "mitt";
import { computed, inject, ref } from "vue";
import { storeToRefs } from "pinia";
// Props
const props = defineProps<{ rom: DetailedRom }>();
Expand All @@ -22,13 +24,23 @@ const heartbeatStore = storeHeartbeat();
const emitter = inject<Emitter<Events>>("emitter");
const playInfoIcon = ref("mdi-play");
const qrCodeIcon = ref("mdi-qrcode");
const configStore = storeConfig();
const { config } = storeToRefs(configStore);
const ejsEmulationSupported = computed(() =>
isEJSEmulationSupported(props.rom.platform_slug, heartbeatStore.value),
);
const ruffleEmulationSupported = computed(() =>
isRuffleEmulationSupported(props.rom.platform_slug, heartbeatStore.value),
const platformSlug = computed(() =>
props.rom.platform_slug in config.value.PLATFORMS_VERSIONS
? config.value.PLATFORMS_VERSIONS[props.rom.platform_slug]
: props.rom.platform_slug,
);
const ejsEmulationSupported = computed(() => {
return isEJSEmulationSupported(platformSlug.value, heartbeatStore.value);
});
const ruffleEmulationSupported = computed(() => {
return isRuffleEmulationSupported(platformSlug.value, heartbeatStore.value);
});
const is3DSRom = computed(() => {
return is3DSCIARom(props.rom);
});
Expand Down
17 changes: 12 additions & 5 deletions frontend/src/components/common/Game/Card/ActionBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import AdminMenu from "@/components/common/Game/AdminMenu.vue";
import romApi from "@/services/api/rom";
import storeDownload from "@/stores/download";
import storeHeartbeat from "@/stores/heartbeat";
import storeConfig from "@/stores/config";
import type { SimpleRom } from "@/stores/roms";
import type { Events } from "@/types/emitter";
import {
Expand All @@ -12,22 +13,28 @@ import {
} from "@/utils";
import type { Emitter } from "mitt";
import { computed, inject } from "vue";
import { storeToRefs } from "pinia";
// Props
const props = defineProps<{ rom: SimpleRom }>();
const downloadStore = storeDownload();
const heartbeatStore = storeHeartbeat();
const emitter = inject<Emitter<Events>>("emitter");
const configStore = storeConfig();
const { config } = storeToRefs(configStore);
const platformSlug = computed(() => {
return props.rom.platform_slug in config.value.PLATFORMS_VERSIONS
? config.value.PLATFORMS_VERSIONS[props.rom.platform_slug]
: props.rom.platform_slug;
});
const ejsEmulationSupported = computed(() => {
return isEJSEmulationSupported(props.rom.platform_slug, heartbeatStore.value);
return isEJSEmulationSupported(platformSlug.value, heartbeatStore.value);
});
const ruffleEmulationSupported = computed(() => {
return isRuffleEmulationSupported(
props.rom.platform_slug,
heartbeatStore.value,
);
return isRuffleEmulationSupported(platformSlug.value, heartbeatStore.value);
});
const is3DSRom = computed(() => {
Expand Down
15 changes: 13 additions & 2 deletions frontend/src/components/common/Game/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import RAvatarRom from "@/components/common/Game/RAvatar.vue";
import romApi from "@/services/api/rom";
import storeDownload from "@/stores/download";
import storeRoms, { type SimpleRom } from "@/stores/roms";
import storeConfig from "@/stores/config";
import storeHeartbeat from "@/stores/heartbeat";
import type { Events } from "@/types/emitter";
import {
Expand Down Expand Up @@ -34,6 +35,8 @@ const downloadStore = storeDownload();
const romsStore = storeRoms();
const { filteredRoms, selectedRoms } = storeToRefs(romsStore);
const heartbeatStore = storeHeartbeat();
const configStore = storeConfig();
const { config } = storeToRefs(configStore);
const page = ref(parseInt(window.location.hash.slice(1)) || 1);
const storedRomsPerPage = parseInt(localStorage.getItem("romsPerPage") ?? "");
const itemsPerPage = ref(isNaN(storedRomsPerPage) ? 25 : storedRomsPerPage);
Expand Down Expand Up @@ -106,12 +109,20 @@ function updateUrlHash() {
window.location.hash = String(page.value);
}
function getTruePlatformSlug(platformSlug: string) {
return platformSlug in config.value.PLATFORMS_VERSIONS
? config.value.PLATFORMS_VERSIONS[platformSlug]
: platformSlug;
}
function checkIfEJSEmulationSupported(platformSlug: string) {
return isEJSEmulationSupported(platformSlug, heartbeatStore.value);
const slug = getTruePlatformSlug(platformSlug);
return isEJSEmulationSupported(slug, heartbeatStore.value);
}
function checkIfRuffleEmulationSupported(platformSlug: string) {
return isRuffleEmulationSupported(platformSlug, heartbeatStore.value);
const slug = getTruePlatformSlug(platformSlug);
return isRuffleEmulationSupported(slug, heartbeatStore.value);
}
function updateSelectAll() {
Expand Down

0 comments on commit a2cc8ea

Please sign in to comment.