diff --git a/sdvx@asphyxia/handlers/profiles.ts b/sdvx@asphyxia/handlers/profiles.ts index eb691ba..c6bbb5c 100644 --- a/sdvx@asphyxia/handlers/profiles.ts +++ b/sdvx@asphyxia/handlers/profiles.ts @@ -115,8 +115,17 @@ export const saveScore: EPR = async (info, data, send) => { longRate: 0, volRate: 0, volforce: 0, + judge: [], }; + if (record.judge.length == 0) { + console.log("No judge data found, save them for the first time so use current data as baseline."); + record.judge = i.numbers('judge', []); + if (record.judge.length == 7) { + console.log("Judge data length is valid with s-crit."); + } + } + const score = i.number('score', 0); const exscore = i.number('exscore', 0); if (score > record.score) { @@ -125,10 +134,23 @@ export const saveScore: EPR = async (info, data, send) => { record.longRate = i.number('long_rate', 0); record.volRate = i.number('vol_rate', 0); } + if (exscore > record.exscore) { record.exscore = exscore; } + if (score >= record.score || exscore >= record.exscore) { + const newJudge = i.numbers('judge', []); + if (newJudge.length == record.judge.length) { + for (let j = 0; j < record.judge.length; j++) { + if (newJudge[j] > record.judge[j]) { + record.judge[j] = newJudge[j]; + } + } + } + } + + const volforce = i.number('volforce', 0); if (isNaN(record.volforce) || record.volforce === null) { @@ -140,6 +162,8 @@ export const saveScore: EPR = async (info, data, send) => { record.volforce = volforce; } + + if(i.number('clear_type', 0) == 6 && record.clear >= 4){ console.log("Detected Maxxive Clear, but originally UC or PUC, no override.") }else{ diff --git a/sdvx@asphyxia/models/music_record.ts b/sdvx@asphyxia/models/music_record.ts index 546f7a8..f49dead 100644 --- a/sdvx@asphyxia/models/music_record.ts +++ b/sdvx@asphyxia/models/music_record.ts @@ -11,4 +11,6 @@ export interface MusicRecord { longRate: number; volRate: number; volforce: number; + + judge: number[]; } diff --git a/sdvx@asphyxia/webui/asset/js/detail.js b/sdvx@asphyxia/webui/asset/js/detail.js index 318e194..7f31500 100644 --- a/sdvx@asphyxia/webui/asset/js/detail.js +++ b/sdvx@asphyxia/webui/asset/js/detail.js @@ -22,6 +22,61 @@ function zeroPad(num, places) { return Array(+(zero > 0 && zero)).join("0") + num; } +function arraybuffer_emit(event, data) { + return axios.post(`/emit/${event}`, data ?? {},{responseType: 'arraybuffer', timeout: 3000000}); +} + +const GRAPHICS_BASE_PATH = 'data/graphics'; + +function toGraphicsPath(urlOrPath) { + if (!urlOrPath) return urlOrPath; + if (urlOrPath.startsWith('static/asset/')) { + return `${GRAPHICS_BASE_PATH}/${urlOrPath.substring('static/asset/'.length)}`; + } + if (urlOrPath.startsWith('data/graphics/')) { + return `${GRAPHICS_BASE_PATH}/${urlOrPath.substring('data/graphics/'.length)}`; + } + return urlOrPath; +} + +// Cache blob URLs so repeated re-renders don't refetch the same asset. +const assetBlobUrlCache = new Map(); + +async function getOrCreateAssetBlobUrl(urlOrPath) { + const path = toGraphicsPath(urlOrPath); + if (!path) return null; + + const cached = assetBlobUrlCache.get(path); + if (cached) return cached; + + try { + const res = await arraybuffer_emit('getAssetData', { path }); + const data = res?.data; + if (!data) return null; + + const blobUrl = URL.createObjectURL(new Blob([data], { type: 'image/png' })); + assetBlobUrlCache.set(path, blobUrl); + return blobUrl; + } catch (_) { + return null; + } +} + +window.addEventListener('beforeunload', () => { + for (const blobUrl of assetBlobUrlCache.values()) { + try { + URL.revokeObjectURL(blobUrl); + } catch (_) {} + } + assetBlobUrlCache.clear(); +}); + +async function setImgSrcFromAsset(imgEl, urlOrPath) { + if (!imgEl) return; + const blobUrl = await getOrCreateAssetBlobUrl(urlOrPath); + imgEl.setAttribute('src', blobUrl ?? urlOrPath); +} + function isEmptyJson(value) { if (value === null || value === undefined) return true; if (Array.isArray(value)) return value.length === 0; @@ -157,7 +212,7 @@ function getMedal(clear) { function getAppealCard(appeal) { let result = appeal_db["appeal_card_data"]["card"].filter(object => object["@id"] == appeal); - return "static/asset/ap_card/" + result[0]["info"]["texture"] + ".png" + return "data/graphics/ap_card/" + result[0]["info"]["texture"] + ".png" } function getSongLevel(musicid, type) { @@ -839,7 +894,11 @@ $(function() { $('
').append( $('
').append( $('
').append( - $('').attr('src', getAppealCard(profile_data.appeal)) + (() => { + const img = $(''); + setImgSrcFromAsset(img[0], getAppealCard(profile_data.appeal)); + return img; + })() .css('width', '150px') ).css('vertical-align', 'middle') )