1
0
Fork 0

fix(import): align asset types with the Assets enum and honor export mod

This commit is contained in:
Jason Fraley 2026-09-22 21:09:02 -04:00
parent d51c8445bb
commit f4fbcc80fa

View file

@ -59,10 +59,12 @@ function resolveHemtt(explicit?: string): string {
throw new Error("hemtt not found; pass --hemtt <path>"); throw new Error("hemtt not found; pass --hemtt <path>");
} }
// Mirrors the Assets collection's assetType enum (see payload-types.ts).
// The in-game export (ptf_export addon) emits exactly these values.
const KNOWN_ASSET_TYPES = new Set([ const KNOWN_ASSET_TYPES = new Set([
"weapon", "magazine", "ammo", "backpack", "vest", "helmet", "uniform", "weapon", "magazine", "optic", "muzzle", "bipod", "uniform", "vest",
"item", "attachment", "optics", "muzzle", "grip", "rail", "explosive", "backpack", "helmet", "facewear", "nvg", "radio", "medical", "tool",
"grenade", "medical", "tool", "explosive", "skin", "miscellaneous",
]); ]);
function classifyAssetType(clazz: string, type: string): string { function classifyAssetType(clazz: string, type: string): string {
const t = (type || "").toLowerCase(); const t = (type || "").toLowerCase();
@ -116,6 +118,7 @@ interface ImportPlan {
displayName: string; displayName: string;
description: string; description: string;
assetType: string; assetType: string;
mod: string;
pictureRef: string; pictureRef: string;
paaPath: string; paaPath: string;
pngPath: string; pngPath: string;
@ -134,6 +137,7 @@ function planImport(
const displayName = String(rec.displayName ?? rec.name ?? clazz).trim() || clazz; const displayName = String(rec.displayName ?? rec.name ?? clazz).trim() || clazz;
const description = String(rec.description ?? "").trim(); const description = String(rec.description ?? "").trim();
const pictureRef = String(rec.picture ?? "").trim(); const pictureRef = String(rec.picture ?? "").trim();
const mod = String(rec.mod ?? "").trim() || "Arma 3";
const iconRef = lookups.icons ? lookupIcon(lookups.icons, clazz) : ""; const iconRef = lookups.icons ? lookupIcon(lookups.icons, clazz) : "";
const ref = iconRef || pictureRef; const ref = iconRef || pictureRef;
const paaPath = ref ? resolvePaaPath(ref, lookups.paaRoot) : ""; const paaPath = ref ? resolvePaaPath(ref, lookups.paaRoot) : "";
@ -143,7 +147,7 @@ function planImport(
const screenshotPath = lookups.screenshots const screenshotPath = lookups.screenshots
? (["png", "webp", "jpg"].map((e) => join(lookups.screenshots, clazz + "." + e)).find(existsSync) ?? "") ? (["png", "webp", "jpg"].map((e) => join(lookups.screenshots, clazz + "." + e)).find(existsSync) ?? "")
: ""; : "";
return { kind: vehicle ? "vehicle" : "asset", clazz, displayName, description, assetType, pictureRef: ref, paaPath, pngPath, screenshotPath }; return { kind: vehicle ? "vehicle" : "asset", clazz, displayName, description, assetType, mod, pictureRef: ref, paaPath, pngPath, screenshotPath };
} }
async function resolveFuelConfig(payload: { find: (args: any) => Promise<{ docs: any[] }> }): Promise<{ id: number }> { async function resolveFuelConfig(payload: { find: (args: any) => Promise<{ docs: any[] }> }): Promise<{ id: number }> {
@ -182,7 +186,7 @@ async function writeEntry(
data: { data: {
...common, ...common,
assetType: plan.assetType, assetType: plan.assetType,
...(plan.pngPath ? { "Asset Metadata": { mod: "Arma 3", thumbnail: mediaId, gameDescription: plan.description || null } } : {}), ...(plan.pngPath ? { "Asset Metadata": { mod: plan.mod, thumbnail: mediaId, gameDescription: plan.description || null } } : {}),
}, },
}).then((d: any) => `asset:${d.id}`); }).then((d: any) => `asset:${d.id}`);
} }