Rename game to edition in the UI

Much clearer to say Classic vs Special Edition instead of "skyrim" vs "skyrimspecialedition".
This commit is contained in:
Tyler Hallada 2022-09-06 15:15:27 -04:00
parent 941eb7b08f
commit eebc43fbee
4 changed files with 29 additions and 5 deletions

View File

@ -2,15 +2,13 @@ import React, { createContext, useCallback } from "react";
import useSWRImmutable from "swr/immutable";
import { jsonFetcher } from "../lib/api";
import type { GameName } from "../lib/games";
interface Game {
id: number;
name: GameName;
nexus_game_id: number;
}
export type GameName = "skyrim" | "skyrimspecialedition";
interface GamesContext {
games?: Game[] | null;
getGameNameById: (id: number) => GameName | undefined;

View File

@ -7,6 +7,7 @@ import { useAppDispatch, useAppSelector } from "../lib/hooks";
import CellList from "./CellList";
import styles from "../styles/ModData.module.css";
import { jsonFetcher } from "../lib/api";
import { editionNames } from "../lib/games";
import {
PluginsByHashWithMods,
removeFetchedPlugin,
@ -239,6 +240,14 @@ const ModData: React.FC<Props> = ({
{modData.name}
</a>
</h1>
<div>
<strong>Edition:&nbsp;</strong>
{
editionNames[
getGameNameById(modData.game_id) ?? "skyrimspecialedition"
]
}
</div>
<div>
<strong>Category:&nbsp;</strong>
<a

View File

@ -20,6 +20,7 @@ import {
setCategory,
setIncludeTranslations,
} from "../slices/modListFilters";
import { editionNames } from "../lib/games";
import { useAppDispatch, useAppSelector } from "../lib/hooks";
import { DownloadCountsContext } from "./DownloadCountsProvider";
import { GamesContext } from "./GamesProvider";
@ -229,7 +230,7 @@ const ModList: React.FC<Props> = ({ mods, files }) => {
/>
</div>
<div className={styles["filter-row"]}>
<label htmlFor="game">Game:</label>
<label htmlFor="game">Edition:</label>
<select
name="game"
id="game"
@ -243,7 +244,7 @@ const ModList: React.FC<Props> = ({ mods, files }) => {
.sort()
.map((game) => (
<option key={game} value={game}>
{game}
{editionNames[game]}
</option>
))}
</select>
@ -325,6 +326,14 @@ const ModList: React.FC<Props> = ({ mods, files }) => {
View on Nexus Mods
</a>
</div>
<div>
<strong>Edition:&nbsp;</strong>
{
editionNames[
getGameNameById(mod.game_id) ?? "skyrimspecialedition"
]
}
</div>
<div>
<strong>Category:&nbsp;</strong>
<a

8
lib/games.ts Normal file
View File

@ -0,0 +1,8 @@
export type GameName = "skyrim" | "skyrimspecialedition";
// Translates gameName (e.g. "skyrim" or "skyrimspecialedition") to edition name which is displayed in the
// UI ("Classic" or "Special Edition").
export const editionNames: Record<GameName, string> = {
skyrim: 'Classic',
skyrimspecialedition: 'Special Edition',
};