@@ -267,6 +267,20 @@ function toDownloadName(gameId) {
267267 return `${ normalized || "game" } -skin.json` ;
268268}
269269
270+ function deriveCatalogPathFromGameHref ( gameHref ) {
271+ const href = normalizeText ( gameHref ) . replace ( / \\ / g, "/" ) ;
272+ if ( ! href || ! href . startsWith ( "/games/" ) ) {
273+ return "" ;
274+ }
275+ if ( href . endsWith ( "/index.html" ) ) {
276+ return `${ href . slice ( 0 , - "/index.html" . length ) } /assets/workspace.asset-catalog.json` ;
277+ }
278+ if ( href . endsWith ( "/" ) ) {
279+ return `${ href } assets/workspace.asset-catalog.json` ;
280+ }
281+ return "" ;
282+ }
283+
270284function downloadTextFile ( filename , contents ) {
271285 const blob = new Blob ( [ contents ] , { type : "application/json" } ) ;
272286 const objectUrl = URL . createObjectURL ( blob ) ;
@@ -1440,7 +1454,8 @@ async function loadActiveSkinForSelectedGame() {
14401454 try {
14411455 result = await loadGameSkin ( {
14421456 gameId : game . id ,
1443- fallbackSchema : game . fallbackSchema
1457+ fallbackSchema : game . fallbackSchema ,
1458+ catalogPath : deriveCatalogPathFromGameHref ( game . gameHref )
14441459 } ) ;
14451460 } catch ( error ) {
14461461 setStatus ( `Skin load failed: ${ error instanceof Error ? error . message : "unknown error" } ` ) ;
@@ -1768,10 +1783,11 @@ function extractPresetPayload(rawPreset) {
17681783
17691784async function loadPresetFromQuery ( ) {
17701785 const searchParams = new URLSearchParams ( window . location . search ) ;
1786+ const requestedGameId = normalizeText ( searchParams . get ( "gameId" ) || searchParams . get ( "game" ) ) ;
17711787 const samplePresetPath = normalizeSamplePresetPath ( searchParams . get ( "samplePresetPath" ) ) ;
17721788 if ( ! samplePresetPath ) {
17731789 return {
1774- gameId : normalizeText ( searchParams . get ( "gameId" ) ) ,
1790+ gameId : requestedGameId ,
17751791 presetLoaded : false
17761792 } ;
17771793 }
@@ -1785,15 +1801,15 @@ async function loadPresetFromQuery() {
17851801 const rawPreset = await response . json ( ) ;
17861802 const payload = extractPresetPayload ( rawPreset ) ;
17871803 state . presetSkin = payload . skin && typeof payload . skin === "object" ? payload . skin : null ;
1788- const gameId = normalizeText ( payload . gameId || searchParams . get ( "gameId" ) ) ;
1804+ const gameId = normalizeText ( payload . gameId || requestedGameId ) ;
17891805 return {
17901806 gameId,
17911807 presetLoaded : true
17921808 } ;
17931809 } catch ( error ) {
17941810 setStatus ( `Preset load failed: ${ error instanceof Error ? error . message : "unknown error" } ` ) ;
17951811 return {
1796- gameId : normalizeText ( searchParams . get ( "gameId" ) ) ,
1812+ gameId : requestedGameId ,
17971813 presetLoaded : false
17981814 } ;
17991815 }
0 commit comments