mirror of
https://github.com/rommapp/romm.git
synced 2026-02-18 23:42:07 +01:00
[ROMM-2519] Add QR code for all ds platform
This commit is contained in:
@@ -10,7 +10,7 @@ import storeAuth from "@/stores/auth";
|
||||
import storeDownload from "@/stores/download";
|
||||
import type { DetailedRom } from "@/stores/roms";
|
||||
import type { Events } from "@/types/emitter";
|
||||
import { getDownloadLink, is3DSCIARom } from "@/utils";
|
||||
import { getDownloadLink, isNintendoDSRom } from "@/utils";
|
||||
|
||||
const props = defineProps<{ rom: DetailedRom }>();
|
||||
const downloadStore = storeDownload();
|
||||
@@ -19,8 +19,8 @@ const qrCodeIcon = ref("mdi-qrcode");
|
||||
const auth = storeAuth();
|
||||
const { t } = useI18n();
|
||||
|
||||
const is3DSRom = computed(() => {
|
||||
return is3DSCIARom(props.rom);
|
||||
const isNDSRom = computed(() => {
|
||||
return isNintendoDSRom(props.rom);
|
||||
});
|
||||
|
||||
async function copyDownloadLink(rom: DetailedRom) {
|
||||
@@ -84,7 +84,7 @@ async function copyDownloadLink(rom: DetailedRom) {
|
||||
</v-btn>
|
||||
<PlayBtn :rom="rom" class="flex-grow-1" />
|
||||
<v-btn
|
||||
v-if="is3DSRom"
|
||||
v-if="isNDSRom"
|
||||
:disabled="rom.missing_from_fs"
|
||||
class="flex-grow-1"
|
||||
:aria-label="`Show ${rom.name} QR code`"
|
||||
|
||||
@@ -12,7 +12,7 @@ import storeHeartbeat from "@/stores/heartbeat";
|
||||
import type { SimpleRom } from "@/stores/roms";
|
||||
import type { Events } from "@/types/emitter";
|
||||
import {
|
||||
is3DSCIARom,
|
||||
isNintendoDSRom,
|
||||
isEJSEmulationSupported,
|
||||
isRuffleEmulationSupported,
|
||||
} from "@/utils";
|
||||
@@ -30,8 +30,8 @@ const computedSize = computed(() => {
|
||||
return props.sizeActionBar === 1 ? "small" : "x-small";
|
||||
});
|
||||
|
||||
const is3DSRom = computed(() => {
|
||||
return is3DSCIARom(props.rom);
|
||||
const isNDSRom = computed(() => {
|
||||
return isNintendoDSRom(props.rom);
|
||||
});
|
||||
|
||||
const isEmulationSupported = computed(() => {
|
||||
@@ -81,7 +81,7 @@ watch(menuOpen, (val) => {
|
||||
@click.prevent
|
||||
/>
|
||||
</v-col>
|
||||
<v-col v-if="is3DSRom" class="d-flex">
|
||||
<v-col v-if="isNDSRom" class="d-flex">
|
||||
<v-btn
|
||||
:disabled="rom.missing_from_fs"
|
||||
class="action-bar-btn-small flex-grow-1"
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useDisplay } from "vuetify";
|
||||
import RDialog from "@/components/common/RDialog.vue";
|
||||
import type { SimpleRom } from "@/stores/roms";
|
||||
import type { Events } from "@/types/emitter";
|
||||
import { get3DSCIAFiles, getDownloadLink, is3DSCIAFile } from "@/utils";
|
||||
import { getNintendoDSFiles, getDownloadLink, isNintendoDSFile } from "@/utils";
|
||||
|
||||
const { lgAndUp } = useDisplay();
|
||||
const show = ref(false);
|
||||
@@ -19,12 +19,12 @@ emitter?.on("showQRCodeDialog", async (romToView: SimpleRom) => {
|
||||
|
||||
await nextTick();
|
||||
|
||||
const is3DSFile = is3DSCIAFile(romToView);
|
||||
const matchingFiles = get3DSCIAFiles(romToView);
|
||||
const isNDSFile = isNintendoDSFile(romToView);
|
||||
const matchingFiles = getNintendoDSFiles(romToView);
|
||||
|
||||
const downloadLink = getDownloadLink({
|
||||
rom: romToView,
|
||||
fileIDs: is3DSFile ? [] : [matchingFiles[0].id],
|
||||
fileIDs: isNDSFile ? [] : [matchingFiles[0].id],
|
||||
});
|
||||
|
||||
const qrCode = document.getElementById("qr-code");
|
||||
|
||||
@@ -668,26 +668,37 @@ export function getStatusKeyForText(text: string | null) {
|
||||
return inverseRomStatusMap[text];
|
||||
}
|
||||
|
||||
export function is3DSCIAFile(rom: SimpleRom): boolean {
|
||||
return rom.fs_extension.toLowerCase() == "cia";
|
||||
export function isNintendoDSFile(rom: SimpleRom): boolean {
|
||||
return ["cia", "nds", "3ds", "dsi"].includes(rom.fs_extension.toLowerCase());
|
||||
}
|
||||
|
||||
export function get3DSCIAFiles(rom: SimpleRom): RomFileSchema[] {
|
||||
return rom.files.filter((file) =>
|
||||
file.file_name.toLowerCase().endsWith(".cia"),
|
||||
);
|
||||
export function getNintendoDSFiles(rom: SimpleRom): RomFileSchema[] {
|
||||
return rom.files.filter((file) => {
|
||||
const fileName = file.file_name.toLowerCase();
|
||||
return (
|
||||
fileName.endsWith(".cia") ||
|
||||
fileName.endsWith(".nds") ||
|
||||
fileName.endsWith(".3ds") ||
|
||||
fileName.endsWith(".dsi")
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a ROM is a valid 3DS game
|
||||
* Check if a ROM is a valid NDS/3DS/DSi game
|
||||
* @param rom The ROM object.
|
||||
* @returns True if the ROM is a valid 3DS game, false otherwise.
|
||||
* @returns {boolean} True if the ROM is a valid game, otherwise false.
|
||||
*/
|
||||
export function is3DSCIARom(rom: SimpleRom): boolean {
|
||||
if (rom.platform_slug !== "3ds") return false;
|
||||
export function isNintendoDSRom(rom: SimpleRom): boolean {
|
||||
if (
|
||||
!["3ds", "nds", "new-nintendo-3ds", "nintendo-dsi"].includes(
|
||||
rom.platform_slug,
|
||||
)
|
||||
)
|
||||
return false;
|
||||
|
||||
const hasValidExtension = is3DSCIAFile(rom);
|
||||
const hasValidFile = get3DSCIAFiles(rom).length > 0;
|
||||
const hasValidExtension = isNintendoDSFile(rom);
|
||||
const hasValidFile = getNintendoDSFiles(rom).length > 0;
|
||||
|
||||
return hasValidExtension || hasValidFile;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user