Fix SCUM gift catalog visibility

This commit is contained in:
npc0-hue
2026-09-23 16:12:33 +08:00
parent e8ebf562c7
commit 7e0780ea51
4 changed files with 23 additions and 4 deletions
@@ -40,7 +40,6 @@ const scumMapBaseLayers: ReadonlyArray<readonly [ScumMapLayer, string]> = [["ter
const scumMapVehicleFilters: ReadonlyArray<readonly [MapVehicleFilter, string]> = [["all", "全部载具"], ["land", "陆地载具"], ["water", "水上载具"], ["air", "飞行类载具"], ["other", "其他载具"]];
const scumFlightVehicleKeys = new Set(["kinglet_duster", "kinglet_mariner", "kinglet_scout"]);
const scumGiftCatalogCategories: ReadonlyArray<readonly [string, string]> = [["all", "全部目录"], ["hunting", "狩猎"], ["food", "食物"], ["metabolism", "代谢"], ["medical", "医疗"], ["weapons", "武器"], ["crafting", "制作"], ["gear", "装备"], ["fishing", "钓鱼"], ["building", "建筑"], ["tools", "工具"], ["farming", "农业"], ["misc", "其他"], ["vehicle", "载具"], ["animal", "动物"], ["zombie", "丧尸"], ["armed-npc", "NPC"]];
const scumCatalogPickLimit = 48;
const scumMapSize = 4096;
const scumSurfaceRefreshMs = 15000;
const scumMapZoomMin = 1;
@@ -1430,7 +1429,7 @@ function catalogMatches(query: string, kind: string, target: CatalogPickTarget):
return scumCatalogEntries.filter((entry) => {
const matchesKind = kind === "all" || scumGiftCatalogFilterKey(entry) === kind;
return matchesKind && (!search || scumCatalogSearchText(entry).includes(search));
}).slice(0, scumCatalogPickLimit);
});
}
function appendCatalogItem(items: GiftItemDraft[], code: string): GiftItemDraft[] {
@@ -57,7 +57,7 @@ const wordNames: Record<string, string> = {
};
const additionalWordNames: Record<string, string> = {
activated: "活性炭", alcohol: "酒精", alcoholic: "酒精类", anti: "抗", antibiotic: "抗生素", antimalaria: "抗疟疾", antiparasitic: "抗寄生虫", antipsychotic: "抗精神病", ammunition: "弹药", attachment: "配件", back: "后部", body: "身体", boots: "靴子", box: "盒", bucket: "桶", camp: "营地", charcoal: "木炭", clothes: "服装", component: "组件", crafted: "制作的", crafting: "制作", dirty: "脏污", door: "车门", electrodes: "电极", farming: "农业", feet: "脚部", front: "前部", gear: "装备", gloves: "手套", hiking: "徒步", hood: "引擎盖", inventory: "背包栏", item: "物品", legs: "腿部", light: "轻型", normal: "普通", other: "其他", parts: "零件", rear: "后部", rubber: "橡胶", security: "安全", seat: "座椅", side: "侧面", single: "单发", skin: "皮肤", spare: "备用", standing: "立式", steel: "钢制", tactical: "战术", top: "顶部", trap: "陷阱", underwear: "内衣", weapon: "武器", wheel: "车轮"
activated: "活性炭", alcohol: "酒精", alcoholic: "酒精类", anti: "抗", antibiotic: "抗生素", antimalaria: "抗疟疾", antiparasitic: "抗寄生虫", antipsychotic: "抗精神病", ammunition: "弹药", attachment: "配件", back: "后部", big: "大", body: "身体", boots: "靴子", box: "盒", bucket: "桶", camp: "营地", charcoal: "木炭", clothes: "服装", component: "组件", crafted: "制作的", crafting: "制作", dirty: "脏污", door: "车门", electrodes: "电极", farming: "农业", feet: "脚部", front: "前部", gear: "装备", gloves: "手套", hiking: "徒步", hood: "引擎盖", inventory: "背包栏", item: "物品", legs: "腿部", light: "轻型", military: "军用", normal: "普通", other: "其他", parts: "零件", rear: "后部", rubber: "橡胶", security: "安全", seat: "座椅", side: "侧面", single: "单发", skin: "皮肤", spare: "备用", standing: "立式", steel: "钢制", tactical: "战术", top: "顶部", trap: "陷阱", underwear: "内衣", weapon: "武器", wheel: "车轮"
};
const phraseNames: Array<readonly [RegExp, string]> = [
@@ -94,7 +94,14 @@ export function scumCatalogNameZh(entry: ScumCatalogEntry): string {
export function scumCatalogDisplayName(entry: ScumCatalogEntry): string { return scumCatalogNameZh(entry); }
export function scumCatalogSearchText(entry: ScumCatalogEntry): string {
return [scumCatalogNameZh(entry), entry.name, entry.code, entry.command].join(" ").toLowerCase();
const codeWords = entry.code.replace(/[_-]+/g, " ");
const aliases = [
/(?:big|large).*backpack|backpack.*(?:big|large)/i.test(codeWords) ? "大背包" : "",
/military.*backpack|backpack.*military/i.test(codeWords) ? "军用背包" : "",
/military.*helmet|helmet.*military/i.test(codeWords) ? "军用头盔" : ""
].filter(Boolean);
const source = [scumCatalogNameZh(entry), entry.name, entry.code, codeWords, entry.command, ...aliases].join(" ").toLowerCase();
return source + " " + source.replace(/[\s._-]+/g, "");
}
function usableName(entry: ScumCatalogEntry): string {
+9
View File
@@ -10,6 +10,15 @@ const pluginRoot = resolve(dirname(fileURLToPath(import.meta.url)), "../examples
const catalogSource = readFileSync(join(pluginRoot, "features/scum-catalog.ts"), "utf8");
describe("scum catalog icons", () => {
it("includes the backpack and military helmet entries users expect", () => {
const byCode = new Map(scumCatalogEntries.map((entry) => [entry.code, entry]));
expect(byCode.get("Improvised_Backpack_Big")).toMatchObject({ kind: "item" });
expect(byCode.get("Military_Backpack_01_01")).toMatchObject({ kind: "item" });
expect(byCode.get("Military_Helmet_01_01")).toMatchObject({ kind: "item" });
expect(byCode.get("Improvised_Backpack_Big")?.icon).toContain("backpacks/");
expect(byCode.get("Military_Helmet_01_01")?.icon).toContain("head armor/");
});
it("resolves icons on demand instead of importing each icon as its own module", () => {
expect(catalogSource).not.toContain("import.meta.glob");
expect(scumCatalogIconUrl("npcs/zombie11.webp")).toContain("zombie11.webp");
@@ -346,9 +346,13 @@ describe("SCUM plugin feature module", () => {
it("shows Chinese catalog names and searches through the translated name", () => {
const aloe = scumCatalogEntries.find((item) => item.code === "Aloe_Vera")!;
const vehicle = scumCatalogEntries.find((item) => item.code === "BPC_Laika")!;
const bigBackpack = scumCatalogEntries.find((item) => item.code === "Improvised_Backpack_Big")!;
const militaryHelmet = scumCatalogEntries.find((item) => item.code === "Military_Helmet_01_01")!;
expect(scumCatalogDisplayName(aloe)).toBe("芦荟");
expect(scumCatalogDisplayName(vehicle)).toBe("莱卡");
expect(scumCatalogSearchText(aloe)).toContain("芦荟");
expect(scumCatalogSearchText(bigBackpack)).toContain("大背包");
expect(scumCatalogSearchText(militaryHelmet)).toContain("军用头盔");
});
it("uses catalog spawn commands for mixed gift contents", async () => {