diff --git a/main.c b/main.c index 6e92879..4b55628 100644 --- a/main.c +++ b/main.c @@ -1784,28 +1784,34 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) { "var gd=res[0],id=res[1];" "if(!gl)return;" "var imgs=id&&id.images?id.images:[];" - /* if SM games API works and has data, show it; otherwise fall back to images */ + /* title_id from mount_point: /mnt/shadowmnt/PPSA20515_name_hash -> PPSA20515 */ + "function smTid(img){" + "var mp=(img.mount_point||'').split('/').pop();" + "var t=mp.split('_')[0];" + "return(t.length===9&&/^[A-Za-z]{4}\\d{5}$/.test(t))?t:'';" + "}" "if(gd&&!gd.error&&!gd.status&&gd.games&&gd.games.length){" "_gpR=0;renderGamesList(gl,gd.games);" "}else if(imgs.length){" - /* SM games DB empty: build game cards directly from the images list */ "var h='';" "imgs.forEach(function(img){" - "var parts=(img.path||'').split('/');" - "var fn=parts.pop()||img.path;" + "var tid=smTid(img);" + "var fn=(img.path||'').split('/').pop();" + "var sz=img.size?(img.size>1073741824?(img.size/1073741824).toFixed(2)+' GB':(img.size/1048576).toFixed(0)+' MB'):'?';" "var mn=img.mounted" "?'● aktiv'" ":'○ inaktiv';" - "var ba=img.mounted" - "?(img.title_id?'':'')" + "var ba=tid?(img.mounted" + "?''" + ":'')" ":'';" - "var tid=img.title_id||'';" "h+='
';" - "h+=(tid?'':\"\");" + "h+='';" "h+='
';" "h+='
'+fn+'
';" - "h+=(tid?'
'+tid+'
':'');" - "h+='
'+img.path+'
';" + "h+='
'+tid+' — '+sz+'
';" "h+='
';" "h+='
'+mn+ba+'
';" "});gl.innerHTML=h;" @@ -1830,9 +1836,11 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) { "var ext=fn.indexOf('.')>-1?fn.split('.').pop().toUpperCase():'';" "var sz=img.size?(img.size>1073741824?(img.size/1073741824).toFixed(2)+' GB':(img.size/1048576).toFixed(0)+' MB'):'?';" "var st=img.mounted?'● aktiv':'○';" - "var itid=img.title_id||'';" + "var itid=smTid(img);" "var ipath=img.path||'';" "var iba=img.mounted" + "?(itid?'':'●')" + ":(itid?'':'');" "?(itid?'':'● aktiv')" ":'';" "ih+='';" @@ -2957,8 +2965,6 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) { "/mnt/ext0/homebrew/%s/sce_sys/icon0.png", "/mnt/usb0/%s/sce_sys/icon0.png", "/mnt/usb1/%s/sce_sys/icon0.png", - "/mnt/usb2/%s/sce_sys/icon0.png", - "/mnt/usb3/%s/sce_sys/icon0.png", "/system_data/priv/appmeta/%s/icon0.png", NULL }; @@ -2967,6 +2973,20 @@ static void fn(struct mg_connection *c, int ev, void *ev_data) { snprintf(src,sizeof(src),icon_tpl[i],tid); sf=fopen(src,"rb"); } + /* scan /mnt/shadowmnt/ for {titleId}_* (SM's actual mount location) */ + if(!sf){ + DIR *sd=opendir("/mnt/shadowmnt"); + if(sd){ + struct dirent *de; size_t tlen=strlen(tid); + while(!sf&&(de=readdir(sd))!=NULL){ + if(strncmp(de->d_name,tid,tlen)==0&&de->d_name[tlen]=='_'){ + snprintf(src,sizeof(src),"/mnt/shadowmnt/%s/sce_sys/icon0.png",de->d_name); + sf=fopen(src,"rb"); + } + } + closedir(sd); + } + } if(sf){ /* read source icon */ fseek(sf,0,SEEK_END); long isz=ftell(sf); fseek(sf,0,SEEK_SET);