Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions frontend/src/locales/bg_BG/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
"public-notes": "Публични бележки",
"qr-scan-to-download": "Сканирай, за да свалиш",
"rating": "Оценка",
"ratings-label": "Оценки",
"redownload": "Свали отново",
"redownload-manual": "Re-download scraped manual",
"refresh-complete-desc": "Презапиши метаданните от всички избрани източници",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/cs_CZ/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
"public-notes": "Veřejné poznámky",
"qr-scan-to-download": "Naskenujte pro stažení",
"rating": "Hodnocení",
"ratings-label": "Hodnocení",
"redownload": "Znovu stáhnout",
"redownload-manual": "Re-download scraped manual",
"refresh-complete-desc": "Přepsat metadata ze všech vybraných poskytovatelů",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/de_DE/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
"public-notes": "Öffentliche Notizen",
"qr-scan-to-download": "Scannen zum Herunterladen",
"rating": "Bewertung",
"ratings-label": "Bewertungen",
"redownload": "Erneut herunterladen",
"redownload-manual": "Re-download scraped manual",
"refresh-complete-desc": "Metadaten aller ausgewählten Anbieter überschreiben",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/en_GB/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
"public-notes": "Public notes",
"qr-scan-to-download": "Scan to download",
"rating": "Rating",
"ratings-label": "Ratings",
"redownload": "Re-download",
"redownload-manual": "Re-download scraped manual",
"refresh-complete-desc": "Overwrite metadata from all selected providers",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/en_US/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
"public-notes": "Public notes",
"qr-scan-to-download": "Scan to download",
"rating": "Rating",
"ratings-label": "Ratings",
"redownload": "Re-download",
"redownload-manual": "Re-download scraped manual",
"refresh-complete-desc": "Overwrite metadata from all selected providers",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/es_ES/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
"public-notes": "Notas públicas",
"qr-scan-to-download": "Escanear para descargar",
"rating": "Valoración",
"ratings-label": "Valoraciones",
"redownload": "Volver a descargar",
"redownload-manual": "Re-download scraped manual",
"refresh-complete-desc": "Sobrescribir metadatos de todos los proveedores seleccionados",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/fr_FR/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
"public-notes": "Notes publiques",
"qr-scan-to-download": "Scanner pour télécharger",
"rating": "Note",
"ratings-label": "Notes",
"redownload": "Retélécharger",
"redownload-manual": "Re-download scraped manual",
"refresh-complete-desc": "Écraser les métadonnées de tous les fournisseurs sélectionnés",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/hu_HU/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
"public-notes": "Publikus jegyzetek",
"qr-scan-to-download": "Olvasd be a letöltéshez",
"rating": "Értékelés",
"ratings-label": "Értékelések",
"redownload": "Újraletöltés",
"redownload-manual": "Re-download scraped manual",
"refresh-complete-desc": "Az összes kiválasztott szolgáltató metaadatainak felülírása",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/it_IT/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
"public-notes": "Note pubbliche",
"qr-scan-to-download": "Scansiona per scaricare",
"rating": "Valutazione",
"ratings-label": "Valutazioni",
"redownload": "Riscarica",
"redownload-manual": "Re-download scraped manual",
"refresh-complete-desc": "Sovrascrivi i metadati da tutti i provider selezionati",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/ja_JP/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
"public-notes": "公開メモ",
"qr-scan-to-download": "スキャンしてダウンロード",
"rating": "レーティング",
"ratings-label": "レーティング",
"redownload": "再ダウンロード",
"redownload-manual": "Re-download scraped manual",
"refresh-complete-desc": "選択したすべてのプロバイダからメタデータを上書きします",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/ko_KR/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
"public-notes": "공개 노트",
"qr-scan-to-download": "스캔하여 다운로드",
"rating": "평가",
"ratings-label": "평가",
"redownload": "다시 다운로드",
"redownload-manual": "Re-download scraped manual",
"refresh-complete-desc": "선택한 모든 제공자의 메타데이터로 덮어씁니다",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/pl_PL/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
"public-notes": "Notatki publiczne",
"qr-scan-to-download": "Zeskanuj, aby pobrać",
"rating": "Ocena",
"ratings-label": "Oceny",
"redownload": "Pobierz ponownie",
"redownload-manual": "Re-download scraped manual",
"refresh-complete-desc": "Nadpisz metadane od wszystkich wybranych dostawców",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/pt_BR/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
"public-notes": "Notas públicas",
"qr-scan-to-download": "Escaneie para baixar",
"rating": "Avaliação",
"ratings-label": "Avaliações",
"redownload": "Baixar novamente",
"redownload-manual": "Re-download scraped manual",
"refresh-complete-desc": "Sobrescrever metadados de todos os provedores selecionados",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/ro_RO/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
"public-notes": "Notițe publice",
"qr-scan-to-download": "Scanează pentru a descărca",
"rating": "Evaluare",
"ratings-label": "Evaluări",
"redownload": "Redescarcă",
"redownload-manual": "Re-download scraped manual",
"refresh-complete-desc": "Suprascrie metadatele de la toți furnizorii selectați",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/ru_RU/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
"public-notes": "Публичные заметки",
"qr-scan-to-download": "Отсканируйте для скачивания",
"rating": "Рейтинг",
"ratings-label": "Оценки",
"redownload": "Перезагрузить",
"redownload-manual": "Re-download scraped manual",
"refresh-complete-desc": "Перезаписать метаданные от всех выбранных провайдеров",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/tr_TR/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
"public-notes": "Herkese açık notlar",
"qr-scan-to-download": "İndirmek için tarat",
"rating": "Puan",
"ratings-label": "Puanlar",
"redownload": "Yeniden indir",
"redownload-manual": "Taranmış kılavuzu yeniden indir",
"refresh-complete-desc": "Seçili tüm sağlayıcılardan meta veriyi üzerine yaz",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/zh_CN/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
"public-notes": "公共笔记",
"qr-scan-to-download": "扫码下载",
"rating": "评分",
"ratings-label": "评分",
"redownload": "重新下载",
"redownload-manual": "Re-download scraped manual",
"refresh-complete-desc": "从所有选定来源覆盖元数据",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/locales/zh_TW/rom.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
"public-notes": "公共筆記",
"qr-scan-to-download": "掃描以下載",
"rating": "評分",
"ratings-label": "評分",
"redownload": "重新下載",
"redownload-manual": "Re-download scraped manual",
"refresh-complete-desc": "覆寫所有所選提供商的元數據",
Expand Down
28 changes: 24 additions & 4 deletions frontend/src/v2/components/GameDetails/ProviderCard.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<script setup lang="ts">
// ProviderCard — single metadata-source card. Provider name + logo
// + linked external ID (or "Not linked"). When `url` is non-null and
// the ID is set, the card renders as an `<a target=_blank>`; otherwise
// it's a static div. Brand colour is consumed via the `accent` prop
// (caller passes a CSS color value, typically a token reference).
// + linked external ID (or "Not linked"), plus the provider's rating
// when it publishes one. When `url` is non-null and the ID is set, the
// card renders as an `<a target=_blank>`; otherwise it's a static div.
// Brand colour is consumed via the `accent` prop (caller passes a CSS
// color value, typically a token reference).
import { RIcon } from "@v2/lib";
import { computed } from "vue";
import { useI18n } from "vue-i18n";
Expand All @@ -18,12 +19,14 @@ interface Props {
logo?: string | null;
id?: string | number | null;
href?: string | null;
rating?: string | null;
}

const props = withDefaults(defineProps<Props>(), {
logo: null,
id: null,
href: null,
rating: null,
});

const isLinked = computed(() => props.id !== null && props.id !== undefined);
Expand Down Expand Up @@ -62,6 +65,13 @@ const isClickable = computed(() => isLinked.value && Boolean(props.href));
<span v-else class="provider-card__unlinked">
{{ t("common.not-linked") }}
</span>
<span
v-if="rating"
class="provider-card__rating"
:title="t('rom.ratings-label')"
>
{{ rating }}
</span>
</div>
</component>
</template>
Expand Down Expand Up @@ -114,6 +124,10 @@ const isClickable = computed(() => isLinked.value && Boolean(props.href));
}

.provider-card__id {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 8px;
font-size: 11.5px;
color: var(--r-color-fg-secondary);
font-variant-numeric: tabular-nums;
Expand All @@ -124,4 +138,10 @@ const isClickable = computed(() => isLinked.value && Boolean(props.href));
color: var(--r-color-fg-faint);
font-family: var(--r-font-family-sans);
}
.provider-card__rating {
flex-shrink: 0;
font-family: var(--r-font-family-sans);
font-weight: var(--r-font-weight-semibold);
color: var(--r-color-fg);
}
</style>
9 changes: 8 additions & 1 deletion frontend/src/v2/components/GameDetails/ProviderGrid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
import { computed } from "vue";
import type { DetailedRom } from "@/stores/roms";
import ProviderCard from "@/v2/components/GameDetails/ProviderCard.vue";
import { PROVIDERS, providerId } from "@/v2/components/GameDetails/providers";
import {
PROVIDERS,
providerId,
providerRating,
} from "@/v2/components/GameDetails/providers";

defineOptions({ inheritAttrs: false });

Expand All @@ -17,6 +21,7 @@ type Entry = {
logo: string | null;
id: string | number | null;
href: string | null;
rating: string | null;
};

const entries = computed<Entry[]>(() => {
Expand All @@ -28,6 +33,7 @@ const entries = computed<Entry[]>(() => {
logo: p.logo,
id,
href: id !== null && p.url ? p.url(id, props.rom) : null,
rating: providerRating(props.rom, p),
};
});
// Linked first; the cards know how to dim themselves when unlinked.
Expand All @@ -45,6 +51,7 @@ const entries = computed<Entry[]>(() => {
:logo="e.logo"
:id="e.id"
:href="e.href"
:rating="e.rating"
/>
</div>
</template>
Expand Down
29 changes: 29 additions & 0 deletions frontend/src/v2/components/GameDetails/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,3 +105,32 @@ export function providerId(
if (v === null || v === undefined || v === "" || v === 0) return null;
return v as string | number;
}

// Providers grade on their own scales, so bring each to 0-100 here.
const RATING_SCORES: Partial<
Record<Provider["key"], (rom: DetailedRom) => number>
> = {
igdb_id: (rom) => parseFloat(rom.igdb_metadata?.total_rating ?? ""),
ss_id: (rom) => parseFloat(rom.ss_metadata?.ss_score ?? "") * 10,
moby_id: (rom) => parseFloat(rom.moby_metadata?.moby_score ?? "") * 10,
launchbox_id: (rom) =>
(rom.launchbox_metadata?.community_rating ?? Number.NaN) * 20,
hltb_id: (rom) => rom.hltb_metadata?.review_score ?? Number.NaN,
};

/**
* Formats a provider's score for a ROM as a percentage, or null when the
* provider carries no rating. Scores below 10 keep a decimal to stay
* meaningful; `maximumFractionDigits` never pads a trailing zero.
*/
export function providerRating(
rom: DetailedRom,
provider: Provider,
): string | null {
const score = RATING_SCORES[provider.key]?.(rom) ?? Number.NaN;
if (!Number.isFinite(score)) return null;
return (score / 100).toLocaleString("en-US", {
style: "percent",
maximumFractionDigits: score >= 10 ? 0 : 1,
});
}
Loading