Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#889 Support new RMG format with localisedName field #890

Merged
merged 1 commit into from
Nov 30, 2024
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
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"@railmapgen/rmg-components": "^10.1.0",
"@railmapgen/rmg-palette-resources": "^2.2.4",
"@railmapgen/rmg-runtime": "^10.2.0",
"@railmapgen/rmg-translate": "^3.2.1",
"@railmapgen/rmg-translate": "^3.2.3",
"@railmapgen/svg-assets": "^4.0.3",
"@reduxjs/toolkit": "^2.2.5",
"bezier-js": "^6.1.4",
Expand Down
5 changes: 3 additions & 2 deletions src/constants/rmg.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Theme } from './constants';
import { Translation } from '@railmapgen/rmg-translate';

/**
* @property {string} 0 - Chinese characters
Expand Down Expand Up @@ -71,8 +72,8 @@ export interface StationInfo {
/**
* Station name in two languages.
*/
name: Name;
secondaryName?: Name;
localisedName: Translation;
localisedSecondaryName?: Translation;
/**
* Station number. (GZMTR specific)
*/
Expand Down
6 changes: 3 additions & 3 deletions src/util/rmg-param-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const parseRmgParam = (
const nodes = graph.filterNodes(
(node, attr) =>
Object.values(StationType).includes(attr.type as StationType) &&
(attr[attr.type] as StationAttributes).names[0] === stnInfo.name[0]
(attr[attr.type] as StationAttributes).names[0] === stnInfo.localisedName.zh
);
if (nodes.length !== 0) stnIdMap[id] = nodes[0] as StnId;
});
Expand All @@ -44,7 +44,7 @@ export const parseRmgParam = (
graph.filterNodes(
(node, attr) =>
Object.values(StationType).includes(attr.type as StationType) &&
(attr[attr.type] as StationAttributes).names[0] === stnInfo.name[0]
(attr[attr.type] as StationAttributes).names[0] === stnInfo.localisedName.zh
).length === 0
)
.forEach(([id, stnInfo], i) => {
Expand All @@ -67,7 +67,7 @@ export const parseRmgParam = (
const attr = {
// deep copy to prevent mutual reference
...structuredClone(stations[type].defaultAttrs),
names: stnInfo.name,
names: [stnInfo.localisedName.zh ?? '', stnInfo.localisedName.en ?? ''],
};

// add style specific attrs from RMG save
Expand Down
Loading