Merge pull request #2599 from rommapp/disk-spin-animation

Disk spin animation
This commit is contained in:
Georges-Antoine Assi
2025-10-25 19:38:24 -04:00
committed by GitHub
26 changed files with 368 additions and 94 deletions

View File

@@ -84,7 +84,7 @@ async function addToFavorites() {
});
})
.catch((error) => {
console.log(error);
console.error(error);
emitter?.emit("snackbarShow", {
msg: error.response.data.detail,
icon: "mdi-close-circle",
@@ -118,7 +118,7 @@ async function removeFromFavorites() {
collectionsStore.updateCollection(data);
})
.catch((error) => {
console.log(error);
console.error(error);
emitter?.emit("snackbarShow", {
msg: error.response.data.detail,
icon: "mdi-close-circle",

View File

@@ -48,7 +48,7 @@ function run() {
});
})
.catch((error) => {
console.log(error);
console.error(error);
emitter?.emit("snackbarShow", {
msg: error.response.data.detail,
icon: "mdi-close-circle",

View File

@@ -80,7 +80,7 @@ onMounted(() => {
usersStore.set(data);
})
.catch((error) => {
console.log(error);
console.error(error);
});
});
</script>

View File

@@ -50,7 +50,7 @@ async function addRomsToCollection() {
collectionsStore.updateCollection(data);
})
.catch((error) => {
console.log(error);
console.error(error);
emitter?.emit("snackbarShow", {
msg: error.response.data.detail,
icon: "mdi-close-circle",

View File

@@ -93,7 +93,7 @@ async function createCollection() {
router.push({ name: ROUTES.COLLECTION, params: { collection: data.id } });
closeDialog();
} catch (error) {
console.log(error);
console.error(error);
emitter?.emit("snackbarShow", {
msg: "Failed to create collection",
icon: "mdi-close-circle",

View File

@@ -41,7 +41,7 @@ async function deleteCollection() {
}
})
.catch((error) => {
console.log(error);
console.error(error);
emitter?.emit("snackbarShow", {
msg: error.response.data.detail,
icon: "mdi-close-circle",

View File

@@ -39,7 +39,7 @@ async function deleteSmartCollection() {
collectionsStore.removeSmartCollection(smartCollection.value);
})
.catch((error) => {
console.log(error);
console.error(error);
emitter?.emit("snackbarShow", {
msg: error.response.data.detail,
icon: "mdi-close-circle",

View File

@@ -55,7 +55,7 @@ async function removeRomsFromCollection() {
collectionsStore.updateCollection(data);
})
.catch((error) => {
console.log(error);
console.error(error);
emitter?.emit("snackbarShow", {
msg: error.response.data.detail,
icon: "mdi-close-circle",

View File

@@ -45,7 +45,7 @@ async function resetLastPlayed() {
romsStore.removeFromContinuePlaying(props.rom);
})
.catch((error) => {
console.log(error);
console.error(error);
emitter?.emit("snackbarShow", {
msg: error.response.data.detail,
icon: "mdi-close-circle",

View File

@@ -11,21 +11,20 @@ import {
useTemplateRef,
} from "vue";
import { useDisplay } from "vuetify";
import type { SearchRomSchema } from "@/__generated__";
import type { BoxartStyleOption } from "@/components/Settings/UserInterface/Interface.vue";
import ActionBar from "@/components/common/Game/Card/ActionBar.vue";
import Flags from "@/components/common/Game/Card/Flags.vue";
import Skeleton from "@/components/common/Game/Card/Skeleton.vue";
import Sources from "@/components/common/Game/Card/Sources.vue";
import MissingFromFSIcon from "@/components/common/MissingFromFSIcon.vue";
import PlatformIcon from "@/components/common/Platform/PlatformIcon.vue";
import { useGameAnimation } from "@/composables/useGameAnimation";
import { ROUTES } from "@/plugins/router";
import storeCollections from "@/stores/collections";
import storeGalleryView from "@/stores/galleryView";
import storeHeartbeat from "@/stores/heartbeat";
import storePlatforms from "@/stores/platforms";
import storeRoms from "@/stores/roms";
import { type SimpleRom } from "@/stores/roms";
import type { SimpleRom, SearchRom } from "@/stores/roms";
import type { Events } from "@/types/emitter";
import { FRONTEND_RESOURCES_PATH } from "@/utils";
import {
@@ -36,7 +35,7 @@ import {
const props = withDefaults(
defineProps<{
rom: SimpleRom | SearchRomSchema;
rom: SimpleRom | SearchRom;
coverSrc?: string;
aspectRatio?: string | number;
width?: string | number;
@@ -126,10 +125,6 @@ const activeMenu = ref(false);
const showActionBarAlways = useLocalStorage("settings.showActionBar", false);
const showGameTitleAlways = useLocalStorage("settings.showGameTitle", false);
const showSiblings = useLocalStorage("settings.showSiblings", true);
const boxartStyle = useLocalStorage<BoxartStyleOption>(
"settings.boxartStyle",
"cover",
);
const hasNotes = computed(() => {
if (!romsStore.isSimpleRom(props.rom)) return false;
@@ -147,24 +142,28 @@ interface TiltHTMLElement extends HTMLElement {
}
const tiltCardRef = useTemplateRef<TiltHTMLElement>("tilt-card-ref");
const vImgRef = useTemplateRef("game-image-ref");
const gameIsHovering = ref(false);
const {
boxartStyleCover,
animateCD,
animateCartridge,
animateCDSpin,
animateCDLoad,
stopCDAnimation,
animateLoadCart,
} = useGameAnimation({
rom: props.rom,
accelerate: gameIsHovering,
coverSrc: props.coverSrc,
vImgRef: vImgRef,
});
const isWebpEnabled = computed(
() => heartbeatStore.value.TASKS?.ENABLE_SCHEDULED_CONVERT_IMAGES_TO_WEBP,
);
// User selected alternative cover image
const boxartStyleCover = computed(() => {
if (
props.coverSrc ||
!romsStore.isSimpleRom(props.rom) ||
boxartStyle.value === "cover"
)
return null;
const ssMedia = props.rom.ss_metadata?.[boxartStyle.value];
const gamelistMedia = props.rom.gamelist_metadata?.[boxartStyle.value];
return ssMedia || gamelistMedia;
});
const largeCover = computed(() => {
if (props.coverSrc) return props.coverSrc;
if (boxartStyleCover.value)
@@ -202,6 +201,27 @@ const showNoteDialog = (event: MouseEvent | KeyboardEvent) => {
}
};
const onMouseEnter = () => {
gameIsHovering.value = true;
animateCDSpin();
};
const onMouseLeave = () => {
gameIsHovering.value = false;
};
const handlePlayGame = (romId: number) => {
if (romId !== props.rom.id) return;
if (animateCD.value) {
animateCDSpin();
animateCDLoad();
} else if (animateCartridge.value) {
animateLoadCart();
}
};
emitter?.on("playGame", handlePlayGame);
onMounted(() => {
if (tiltCardRef.value && !smAndDown.value && props.enable3DTilt) {
VanillaTilt.init(tiltCardRef.value, {
@@ -218,6 +238,8 @@ onBeforeUnmount(() => {
if (tiltCardRef.value?.vanillaTilt && props.enable3DTilt) {
tiltCardRef.value.vanillaTilt.destroy();
}
emitter?.off("playGame", handlePlayGame);
stopCDAnimation();
});
</script>
@@ -271,6 +293,7 @@ onBeforeUnmount(() => {
<v-card-text class="pa-0">
<v-hover v-slot="{ isHovering, props: imgProps }" open-delay="800">
<v-img
ref="game-image-ref"
v-bind="imgProps"
:key="romsStore.isSimpleRom(rom) ? rom.id : rom.name"
:cover="!boxartStyleCover"
@@ -282,6 +305,8 @@ onBeforeUnmount(() => {
@click="handleClick"
@touchstart="handleTouchStart"
@touchend="handleTouchEnd"
@mouseenter="onMouseEnter"
@mouseleave="onMouseLeave"
>
<template v-if="titleOnHover">
<v-expand-transition>

View File

@@ -1,7 +1,7 @@
<script setup lang="ts">
import type { SearchRomSchema } from "@/__generated__";
import type { SearchRom } from "@/stores/roms";
defineProps<{ rom: SearchRomSchema }>();
defineProps<{ rom: SearchRom }>();
</script>
<template>

View File

@@ -90,7 +90,7 @@ async function deleteRoms() {
}
})
.catch((error) => {
console.log(error);
console.error(error);
emitter?.emit("snackbarShow", {
msg: error.response.data.detail,
icon: "mdi-close-circle",

View File

@@ -109,7 +109,7 @@ async function handleRomUpdate(
}
})
.catch((error) => {
console.log(error);
console.error(error);
emitter?.emit("snackbarShow", {
msg: error.response.data.detail,
icon: "mdi-close-circle",

View File

@@ -4,7 +4,6 @@ import { computed, inject, onBeforeUnmount, ref } from "vue";
import { useI18n } from "vue-i18n";
import { useRoute } from "vue-router";
import { useDisplay } from "vuetify";
import type { SearchRomSchema } from "@/__generated__";
import EmptyManualMatch from "@/components/common/EmptyStates/EmptyManualMatch.vue";
import GameCard from "@/components/common/Game/Card/Base.vue";
import Skeleton from "@/components/common/Game/Card/Skeleton.vue";
@@ -13,7 +12,7 @@ import romApi from "@/services/api/rom";
import storeGalleryView from "@/stores/galleryView";
import storeHeartbeat from "@/stores/heartbeat";
import storePlatforms from "@/stores/platforms";
import storeRoms, { type SimpleRom } from "@/stores/roms";
import storeRoms, { type SimpleRom, type SearchRom } from "@/stores/roms";
import type { Events } from "@/types/emitter";
import { getMissingCoverImage } from "@/utils/covers";
@@ -41,12 +40,12 @@ const route = useRoute();
const searchText = ref("");
const searchBy = ref("Name");
const searched = ref(false);
const matchedRoms = ref<SearchRomSchema[]>([]);
const filteredMatchedRoms = ref<SearchRomSchema[]>();
const matchedRoms = ref<SearchRom[]>([]);
const filteredMatchedRoms = ref<SearchRom[]>();
const emitter = inject<Emitter<Events>>("emitter");
const showSelectSource = ref(false);
const renameFromSource = ref(false);
const selectedMatchRom = ref<SearchRomSchema>();
const selectedMatchRom = ref<SearchRom>();
const selectedCover = ref<MatchedSource>();
const sources = ref<MatchedSource[]>([]);
const heartbeat = storeHeartbeat();
@@ -61,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 || ""),
);
@@ -159,7 +158,7 @@ async function searchRom() {
}
}
function showSources(matchedRom: SearchRomSchema) {
function showSources(matchedRom: SearchRom) {
if (!rom.value) return;
var cardContent = document.getElementById("r-dialog-content");
@@ -238,10 +237,7 @@ function backToMatched() {
renameFromSource.value = false;
}
async function updateRom(
selectedRom: SearchRomSchema,
urlCover: string | undefined,
) {
async function updateRom(selectedRom: SearchRom, urlCover: string | undefined) {
if (!rom.value) return;
show.value = false;
@@ -318,7 +314,7 @@ function closeDialog() {
}
onBeforeUnmount(() => {
emitter?.off("showMatchRomDialog");
emitter?.off("showMatchRomDialog", handleShowMatchRomDialog);
});
</script>

View File

@@ -77,7 +77,7 @@ async function uploadRoms() {
selectedPlatform.value = data;
})
.catch((error) => {
console.log(error);
console.error(error);
emitter?.emit("snackbarShow", {
msg: error.response.data.detail,
icon: "mdi-close-circle",

View File

@@ -1,20 +1,28 @@
<script setup lang="ts">
import type { Emitter } from "mitt";
import { storeToRefs } from "pinia";
import { computed, useAttrs } from "vue";
import { computed, inject, useAttrs, ref } from "vue";
import { useRouter } from "vue-router";
import {
ANIMATION_DELAY,
useGameAnimation,
} from "@/composables/useGameAnimation";
import { ROUTES } from "@/plugins/router";
import storeConfig from "@/stores/config";
import storeHeartbeat from "@/stores/heartbeat";
import { type SimpleRom } from "@/stores/roms";
import storeRoms, { type SimpleRom } from "@/stores/roms";
import type { Events } from "@/types/emitter";
import { isEJSEmulationSupported, isRuffleEmulationSupported } from "@/utils";
const props = defineProps<{ rom: SimpleRom; iconEmbedded?: boolean }>();
const attrs = useAttrs();
const configStore = storeConfig();
const heartbeatStore = storeHeartbeat();
const romsStore = storeRoms();
const router = useRouter();
const { config } = storeToRefs(configStore);
const { value: heartbeat } = storeToRefs(heartbeatStore);
const emitter = inject<Emitter<Events>>("emitter");
const isEmulationSupported = computed(() => {
return (
@@ -31,17 +39,27 @@ const isEmulationSupported = computed(() => {
);
});
const { animateCD, animateCartridge } = useGameAnimation({
rom: props.rom,
});
async function goToPlayer(rom: SimpleRom) {
if (
isEJSEmulationSupported(rom.platform_slug, heartbeat.value, config.value)
) {
await router.push({
name: ROUTES.EMULATORJS,
params: { rom: rom.id },
});
// Force full reload to retrieve COEP/COOP headers from nginx
// Required to enable multi-threading in EmulatorJS.
router.go(0);
emitter?.emit("playGame", rom.id);
setTimeout(
async () => {
await router.push({
name: ROUTES.EMULATORJS,
params: { rom: rom.id },
});
// Force full reload to retrieve COEP/COOP headers from nginx
// Required to enable multi-threading in EmulatorJS
router.go(0);
},
animateCD.value || animateCartridge.value ? ANIMATION_DELAY : 0,
);
} else if (
isRuffleEmulationSupported(rom.platform_slug, heartbeat.value, config.value)
) {

View File

@@ -53,7 +53,7 @@ async function deleteFirmware() {
});
})
.catch((error) => {
console.log(error);
console.error(error);
emitter?.emit("snackbarShow", {
msg: error.response.data.detail,
icon: "mdi-close-circle",

View File

@@ -48,7 +48,7 @@ async function deletePlatform() {
}
})
.catch((error) => {
console.log(error);
console.error(error);
emitter?.emit("snackbarShow", {
msg: error.response.data.detail,
icon: "mdi-close-circle",

View File

@@ -20,13 +20,20 @@ const filteredCovers = ref<SearchCoverSchema[]>();
const panels = ref([0]);
const emitter = inject<Emitter<Events>>("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);
});
</script>

View File

@@ -0,0 +1,185 @@
/**
* This composable is used to animate the game card and play button.
* It will spin CD based games on hover and load cartridge based games on play.
*/
import { useLocalStorage } from "@vueuse/core";
import { computed, ref, type Ref, type ShallowRef } from "vue";
import type { VImg } from "vuetify/lib/components/VImg/VImg.js";
import type { BoxartStyleOption } from "@/components/Settings/UserInterface/Interface.vue";
import storeRoms from "@/stores/roms";
import type { SimpleRom, SearchRom } from "@/stores/roms";
import { isCDBasedSystem } from "@/utils";
export const ANIMATION_DELAY = 500;
export const ANIMATION_CONFIG = {
maxRotationSpeed: 5000, // deg/sec (adjust top speed)
accelerationRate: 2500, // deg/sec^2 (how fast it accelerates)
decelerationRate: -1500, // deg/sec^2 (how fast it decelerates)
transitionCSS: "margin 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55)",
transformCSS: (angle: number) => `rotate(${angle}deg)`,
transformOrigin: (offset: number) => `center calc(50% + ${offset}px)`,
};
function getTranslateY(el: HTMLElement) {
const transform = window.getComputedStyle(el).transform;
if (!transform || transform === "none") return 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;
}
}
export function useGameAnimation({
rom,
coverSrc,
vImgRef,
accelerate = ref(false),
}: {
rom: SimpleRom | SearchRom;
accelerate?: Ref<boolean>;
coverSrc?: string;
vImgRef?: Readonly<ShallowRef<VImg | null>>;
}) {
const romsStore = storeRoms();
const boxartStyle = useLocalStorage<BoxartStyleOption>(
"settings.boxartStyle",
"cover",
);
// User selected alternative cover image
const boxartStyleCover = computed(() => {
if (
coverSrc ||
!romsStore.isSimpleRom(rom) ||
boxartStyle.value === "cover"
)
return null;
const ssMedia = rom.ss_metadata?.[boxartStyle.value];
const gamelistMedia = rom.gamelist_metadata?.[boxartStyle.value];
return ssMedia || gamelistMedia;
});
const animateCD = computed(() => {
return (
boxartStyle.value === "physical_path" &&
Boolean(boxartStyleCover.value) &&
romsStore.isSimpleRom(rom) &&
isCDBasedSystem(rom.platform_slug)
);
});
const animateCartridge = computed(() => {
return (
boxartStyle.value === "physical_path" &&
Boolean(boxartStyleCover.value) &&
romsStore.isSimpleRom(rom) &&
!isCDBasedSystem(rom.platform_slug)
);
});
/* CD animations */
let angle = 0; // current rotation in degrees
let velocity = 0; // degrees / second
let lastTimestamp: number | null = null;
let animationID: number | null = null;
let animateLoad = false;
const spinCD = (timestamp: number) => {
const container = vImgRef?.value?.$el;
const imageElement = vImgRef?.value?.image;
if (!container || !imageElement) return;
if (lastTimestamp === null) lastTimestamp = timestamp;
const deltaTime = (timestamp - lastTimestamp) / 1000; // in seconds
lastTimestamp = timestamp;
const { accelerationRate, decelerationRate, maxRotationSpeed } =
ANIMATION_CONFIG;
// 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;
if (animateLoad) {
// Set the CD spinning at max speed
velocity = ANIMATION_CONFIG.maxRotationSpeed;
// Apply snap-down animation
imageElement.style.marginTop = `${container.offsetHeight}px`;
imageElement.style.transformOrigin = ANIMATION_CONFIG.transformOrigin(
getTranslateY(imageElement),
);
}
// Animate rotation of the CD
imageElement.style.transform = ANIMATION_CONFIG.transformCSS(angle);
if (velocity > 0 || accelerate.value) {
animationID = requestAnimationFrame(spinCD);
} else {
// Stop the animation if the CD is no longer moving
stopCDAnimation();
}
};
const setTransitionCSS = () => {
const imageElement = vImgRef?.value?.image;
if (!imageElement) return;
imageElement.style.transition = ANIMATION_CONFIG.transitionCSS;
};
const animateCDSpin = () => {
if (!animateCD.value) return;
lastTimestamp = null;
setTransitionCSS();
stopCDAnimation();
animationID = requestAnimationFrame(spinCD);
};
const animateCDLoad = () => {
if (!animateCD.value) return;
setTransitionCSS();
animateLoad = true;
};
const stopCDAnimation = () => {
if (animationID !== null) {
cancelAnimationFrame(animationID);
animationID = null;
animateLoad = false;
}
};
/* Cartridge animation */
const animateLoadCart = () => {
if (!animateCartridge.value) return;
const container = vImgRef?.value?.$el;
const imageElement = vImgRef?.value?.image;
if (!container || !imageElement) return;
// Apply snap-down animation
setTransitionCSS();
imageElement.style.transform = ANIMATION_CONFIG.transformCSS(0);
imageElement.style.marginTop = `${container.offsetHeight / 3}px`;
};
return {
boxartStyleCover,
animateCD,
animateCartridge,
animateCDSpin,
animateCDLoad,
stopCDAnimation,
animateLoadCart,
};
}

View File

@@ -1,8 +1,13 @@
<script setup lang="ts">
import { useLocalStorage } from "@vueuse/core";
import { computed, onMounted, useTemplateRef, watch } from "vue";
import type { BoxartStyleOption } from "@/components/Settings/UserInterface/Interface.vue";
import {
computed,
onMounted,
onBeforeUnmount,
useTemplateRef,
watch,
} from "vue";
import Skeleton from "@/components/common/Game/Card/Skeleton.vue";
import { useGameAnimation } from "@/composables/useGameAnimation";
import {
continuePlayingElementRegistry,
gamesListElementRegistry,
@@ -27,22 +32,17 @@ const props = defineProps<{
}>();
const heartbeatStore = storeHeartbeat();
const boxartStyle = useLocalStorage<BoxartStyleOption>(
"settings.boxartStyle",
"cover",
);
const gameCardRef = useTemplateRef<HTMLButtonElement>("game-card-ref");
const vImgRef = useTemplateRef("game-image-ref");
const isWebpEnabled = computed(
() => heartbeatStore.value.TASKS?.ENABLE_SCHEDULED_CONVERT_IMAGES_TO_WEBP,
);
// User selected alternative cover image
const boxartStyleCover = computed(() => {
if (boxartStyle.value === "cover") return null;
const ssMedia = props.rom.ss_metadata?.[boxartStyle.value];
const gamelistMedia = props.rom.gamelist_metadata?.[boxartStyle.value];
return ssMedia || gamelistMedia;
const { boxartStyleCover, animateCDSpin, stopCDAnimation } = useGameAnimation({
rom: props.rom,
accelerate: computed(() => props.selected),
vImgRef: vImgRef,
});
const largeCover = computed(() => {
@@ -77,7 +77,6 @@ const emit = defineEmits([
"select",
"deselect",
]);
const gameCardRef = useTemplateRef<HTMLButtonElement>("game-card-ref");
// Check if this game is in the favorites collection
const collectionsStore = storeCollections();
@@ -91,6 +90,7 @@ watch(
(isSelected) => {
if (isSelected && largeCover.value) {
emit("select", largeCover.value);
animateCDSpin();
} else if (isSelected) {
emit("deselect");
}
@@ -110,6 +110,10 @@ onMounted(() => {
);
}
});
onBeforeUnmount(() => {
stopCDAnimation();
});
</script>
<template>
@@ -128,6 +132,7 @@ onMounted(() => {
>
<div class="w-full h-[350px] relative overflow-hidden rounded">
<v-img
ref="game-image-ref"
class="w-full h-full"
:cover="!boxartStyleCover"
:contain="boxartStyleCover"

View File

@@ -1,14 +1,10 @@
import type { AxiosProgressEvent } from "axios";
import type {
BulkOperationResponse,
SearchRomSchema,
RomUserSchema,
} from "@/__generated__";
import type { BulkOperationResponse, RomUserSchema } from "@/__generated__";
import { type CustomLimitOffsetPage_SimpleRomSchema_ as GetRomsResponse } from "@/__generated__/models/CustomLimitOffsetPage_SimpleRomSchema_";
import api from "@/services/api";
import socket from "@/services/socket";
import storeHeartbeat from "@/stores/heartbeat";
import type { DetailedRom, SimpleRom } from "@/stores/roms";
import type { DetailedRom, SimpleRom, SearchRom } from "@/stores/roms";
import storeUpload from "@/stores/upload";
import { getDownloadPath, getStatusKeyForText } from "@/utils";
@@ -190,7 +186,7 @@ async function searchRom({
romId: number;
searchTerm: string;
searchBy: string;
}): Promise<{ data: SearchRomSchema[] }> {
}): Promise<{ data: SearchRom[] }> {
return api.get("/search/roms", {
params: {
rom_id: romId,

View File

@@ -1,8 +1,11 @@
import { useLocalStorage } from "@vueuse/core";
import { isNull, isUndefined } from "lodash";
import { defineStore } from "pinia";
import type { SearchRomSchema } from "@/__generated__";
import type { DetailedRomSchema, SimpleRomSchema } from "@/__generated__/";
import type {
DetailedRomSchema,
SimpleRomSchema,
SearchRomSchema,
} from "@/__generated__/";
import type { CustomLimitOffsetPage_SimpleRomSchema_ as GetRomsResponse } from "@/__generated__/models/CustomLimitOffsetPage_SimpleRomSchema_";
import cachedApiService from "@/services/cache/api";
import {
@@ -17,6 +20,7 @@ import type { ExtractPiniaStoreType } from "@/types";
type GalleryFilterStore = ExtractPiniaStoreType<typeof storeGalleryFilter>;
export type SimpleRom = SimpleRomSchema;
export type SearchRom = SearchRomSchema;
export type DetailedRom = DetailedRomSchema;
export const MAX_FETCH_LIMIT = 10000;
@@ -270,7 +274,7 @@ export default defineStore("roms", {
setLimit(limit: number) {
this.fetchLimit = limit;
},
isSimpleRom(rom: SimpleRom | SearchRomSchema): rom is SimpleRom {
isSimpleRom(rom: SimpleRom | SearchRom): rom is SimpleRom {
return !isNull(rom.id) && !isUndefined(rom.id);
},
},

View File

@@ -84,4 +84,5 @@ export type Events = {
stateSelected: StateSchema;
showAboutDialog: null;
showNoteDialog: SimpleRom;
playGame: number;
};

View File

@@ -746,3 +746,40 @@ export function platformCategoryToIcon(category: string) {
}
export const FRONTEND_RESOURCES_PATH = "/assets/romm/resources";
export const CD_BASED_SYSTEMS = new Set([
"3do", // 3DO
"amiga-cd32", // Amiga CD32
"atari-jaguar-cd", // Atari Jaguar CD
"philips-cd-i", // Philips CD-i
"commodore-cdtv", // Commodore CDTV
"dc", // Dreamcast
"fm-towns", // FM Towns
"hyperscan", // HyperScan
"laseractive", // LaserActive
"neo-geo-cd", // Neo Geo CD
"ngc", // Nintendo GameCube
"pc-fx", // PC-FX
"psx", // PlayStation
"ps2", // PlayStation 2
"ps3", // PlayStation 3
"ps4", // PlayStation 4
"ps5", // PlayStation 5
"psp", // PlayStation Portable
"segacd", // Sega CD
"series-x-s", // Xbox Series X/S
"saturn", // Sega Saturn
"super-nes-cd-rom-system", // Super NES CD-ROM System
"tandy-vis", // Tandy Video Information System
"tg16", // TurboGrafx-16
"vflash", // V.Flash
"wii", // Wii
"wiiu", // Wii U
"xbox", // Xbox
"xbox360", // Xbox 360
"xboxone", // Xbox One
]);
export function isCDBasedSystem(platformSlug: string): boolean {
return CD_BASED_SYSTEMS.has(platformSlug.toLowerCase());
}

View File

@@ -55,7 +55,7 @@ async function fetchDetails() {
currentRom.value = data;
})
.catch((error) => {
console.log(error);
console.error(error);
noRomError.value = true;
})
.finally(() => {
@@ -117,7 +117,7 @@ watch(
:show-platform-icon="false"
:show-action-bar="false"
/>
<ActionBar class="mt-2" :rom="currentRom" />
<ActionBar :rom="currentRom" />
<RelatedGames v-if="mdAndUp" class="mt-4" :rom="currentRom" />
</v-container>
</v-col>