fix: show correct SCUM catalog item names
This commit is contained in:
@@ -32,6 +32,18 @@ const directNames: Record<string, string> = {
|
||||
Aspirin: "阿司匹林",
|
||||
Animal_Skin: "动物皮",
|
||||
Air_Pump: "打气筒",
|
||||
Bundle_Of_Rags_Dirty: "脏布条捆",
|
||||
Bundle_Of_Safety_Pins: "安全别针捆",
|
||||
Bundle_Of_Stone_Tips: "石箭头捆",
|
||||
Bundle_Rag_Stripes: "布条捆",
|
||||
Bundle_Wooden_Plank: "木板捆",
|
||||
CementBag: "水泥袋",
|
||||
Charcoal: "木炭",
|
||||
Christmas_Tree: "圣诞树",
|
||||
Coal_01: "煤块",
|
||||
Copper_Strip: "铜条",
|
||||
Depleted_Uranium: "贫铀",
|
||||
Donkey_Head: "驴头",
|
||||
Backpack_02_01: "红色背包",
|
||||
"1H_Cleaver": "菜刀",
|
||||
Water_05l: "水",
|
||||
@@ -82,11 +94,6 @@ const phraseNames: Array<readonly [RegExp, string]> = [
|
||||
[/^(.+) Level (\d+)$/i, "$1 $2 级"]
|
||||
];
|
||||
|
||||
const catalogKindNames: Record<string, string> = { item: "物品", vehicle: "载具", animal: "动物", zombie: "丧尸", "armed-npc": "非玩家角色", razor: "其他" };
|
||||
const fallbackNameGroups: Array<readonly [string, string]> = [
|
||||
["/backpacks/", "背包"], ["/head armor/", "头部装备"], ["/weapons/", "武器"], ["/medicals/", "医疗物品"], ["/food/", "食物"], ["/clothes/", "服装"], ["/vehicles/", "载具部件"], ["/fishing/", "钓鱼用品"], ["/farming/", "农业用品"], ["/crafting/", "制作材料"]
|
||||
];
|
||||
|
||||
export function scumCatalogNameZh(entry: ScumCatalogEntry): string {
|
||||
const direct = directNames[entry.code];
|
||||
if (direct) return direct;
|
||||
@@ -105,7 +112,7 @@ export function scumCatalogNameZh(entry: ScumCatalogEntry): string {
|
||||
if (!/[A-Za-z]/.test(translated)) return translated;
|
||||
const translatedCode = compactLabel(translateWords(code));
|
||||
if (!/[A-Za-z]/.test(translatedCode)) return translatedCode;
|
||||
return catalogFallbackName(entry);
|
||||
return compactLabel(source || code);
|
||||
}
|
||||
|
||||
export function scumCatalogDisplayName(entry: ScumCatalogEntry): string { return scumCatalogNameZh(entry); }
|
||||
@@ -131,12 +138,4 @@ function translateWords(value: string): string {
|
||||
return spaced.replace(/[A-Za-z][A-Za-z'-]*/g, (word) => additionalWordNames[word.toLowerCase()] ?? wordNames[word.toLowerCase()] ?? word);
|
||||
}
|
||||
|
||||
function catalogFallbackName(entry: ScumCatalogEntry): string {
|
||||
const icon = entry.icon.toLowerCase();
|
||||
const group = fallbackNameGroups.find(([needle]) => icon.includes(needle));
|
||||
const prefix = group?.[1] ?? catalogKindNames[entry.kind] ?? "物品";
|
||||
const serial = entry.code.match(/\d+/g)?.join("-");
|
||||
return serial ? prefix + " " + serial : prefix + "条目";
|
||||
}
|
||||
|
||||
function compactLabel(value: string): string { return value.replace(/\s+/g, " ").trim(); }
|
||||
|
||||
Reference in New Issue
Block a user