feat: add customizations page
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
export type CustomizationItem = {
|
||||
id: string;
|
||||
name: string;
|
||||
iconFilePath: string;
|
||||
category: number;
|
||||
associatedCharacter: number;
|
||||
};
|
||||
|
||||
export type Character = {
|
||||
idx: number;
|
||||
name: string;
|
||||
iconFilePath: string;
|
||||
};
|
||||
|
||||
export type Tab = 'cosmetics' | 'charms' | 'badges' | 'banners' | 'portraits';
|
||||
export type RoleFilter = 'all' | 'survivors' | 'killers';
|
||||
|
||||
export const CATEGORY_LABELS: Record<number, string> = {
|
||||
1: 'Heads', 2: 'Torsos', 3: 'Legs',
|
||||
4: 'Heads', 5: 'Bodies', 6: 'Weapons', 7: 'Outfits',
|
||||
};
|
||||
|
||||
export const CATEGORY_ORDER = [7, 1, 4, 2, 3, 5, 6];
|
||||
|
||||
export const TAB_CATEGORIES: Partial<Record<Tab, number>> = {
|
||||
charms: 8, badges: 9, banners: 10, portraits: 11,
|
||||
};
|
||||
|
||||
export const getCosmeticIconUrl = (
|
||||
item: CustomizationItem,
|
||||
characterMap: Map<number, string>
|
||||
): string => {
|
||||
const file = (item.iconFilePath.split('/').pop() ?? '').split('.')[0];
|
||||
|
||||
switch (item.category) {
|
||||
case 8: return `/icons/customization/charms/${file}.png`;
|
||||
case 9: return `/icons/customization/badges/${file}.png`;
|
||||
case 10: return `/icons/customization/banners/${file}.png`;
|
||||
case 11: return `/icons/customization/portrait-backgrounds/${file}.png`;
|
||||
}
|
||||
|
||||
const subfolder =
|
||||
item.category === 1 || item.category === 4 ? 'heads' :
|
||||
item.category === 2 ? 'torsos' :
|
||||
item.category === 3 ? 'legs' :
|
||||
item.category === 5 ? 'bodys' :
|
||||
item.category === 6 ? 'weapons' : 'outfits';
|
||||
|
||||
const charName = characterMap.get(item.associatedCharacter);
|
||||
const charFolder = (charName ?? item.associatedCharacter.toString())
|
||||
.replace(/[\\/:*?"<>|]/g, '_');
|
||||
|
||||
return `/icons/customization/characters/${charFolder}/${subfolder}/${file}.png`;
|
||||
};
|
||||
Reference in New Issue
Block a user