feat: update pack handling and character image paths; implement installed packs revision tracking

This commit is contained in:
2026-05-21 23:59:22 +02:00
parent 0bc6f60b2c
commit 618d18d8fb
6 changed files with 110 additions and 11 deletions
+11 -2
View File
@@ -8,7 +8,7 @@
// /assets/<bundleName>/packs/<packId>/characters/<slug>.<ext>
// ─────────────────────────────────────────────────────────────────────────────
import { BUNDLE_NAME } from './pack-config';
import { ref } from 'vue';
import type { PackManifest } from './pack-types';
export interface FightingCharacterOption {
@@ -243,6 +243,13 @@ export const BUNDLED_GAME_NAMES = new Set(Object.keys(characterNamesByGame));
const installedPackCharacters: Record<string, FightingCharacterOption[]> = {};
const installedPackDefaults: Record<string, { leftCharacter: string; rightCharacter: string }> = {};
/**
* Incremented every time a pack is registered or unregistered.
* Composables subscribe to this ref so Vue re-evaluates computed values
* that depend on installedPackCharacters (which is a plain object, not reactive).
*/
export const installedPacksRevision = ref(0);
/**
* Registers an installed (downloaded) pack so that getCharactersByGame() and
* getDefaultCharactersByGame() return its data.
@@ -263,7 +270,7 @@ export const registerInstalledPack = (manifest: PackManifest): void => {
label: char.name,
value: char.slug,
// Images are served at runtime by NodeCG's static asset handler
image: `/assets/${BUNDLE_NAME}/packs/${id}/characters/${char.slug}.png`,
image: `/packs/${id}/characters/${char.slug}.png`,
dlc: char.dlc ?? false,
// Fallback placeholder uses the same palette as the manifest
_placeholder: buildInstalledPlaceholder(name, char.name, startColor, endColor),
@@ -275,6 +282,7 @@ export const registerInstalledPack = (manifest: PackManifest): void => {
rightCharacter: defaultPair.right,
};
}
installedPacksRevision.value++;
};
/**
@@ -284,6 +292,7 @@ export const registerInstalledPack = (manifest: PackManifest): void => {
export const unregisterInstalledPack = (gameName: string): void => {
delete installedPackCharacters[gameName];
delete installedPackDefaults[gameName];
installedPacksRevision.value++;
};
const buildInstalledPlaceholder = (
+1 -1
View File
@@ -51,4 +51,4 @@ export const getCharacterImageRepoUrl = (packId: string, slug: string, ext: stri
* NodeCG serves everything under assets/ at /assets/<bundleName>/.
*/
export const getInstalledCharacterImageUrl = (packId: string, slug: string, ext = 'png'): string =>
`/assets/${BUNDLE_NAME}/packs/${packId}/characters/${slug}.${ext}`;
`/packs/${packId}/characters/${slug}.${ext}`;