Skip to content

Commit

Permalink
chore: spine请求重定向到4.2版本
Browse files Browse the repository at this point in the history
  • Loading branch information
mark9804 committed Dec 27, 2024
1 parent 5d1f27b commit fdcb639
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions lib/ba-story-player/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@ export function getOtherSoundUrls(): string[] {
return Object.values(otherSoundMap);
}

/**
* 获取 spine v4.2 资源地址
* @param url
* @returns
*/
function getSpine42Url(url: string) {
return rewritePath(url.replaceAll("ba-all-data", "ba-all-data-spine42"));
}

/**
* 重写路径,把所有大写转小写
* @param path
* @returns
*/
function rewritePath(path: string) {
return path.toLowerCase();
}

/**
* 根据资源类型和参数获取资源地址, 可根据服务器实际情况修改
* @param type
Expand All @@ -52,9 +70,9 @@ export function getResourcesUrl(type: ResourcesTypes, arg: string): string {
const voiceFilename = arg.split("/").pop();
return `${dataUrl}/Audio/VoiceJp/Character_voice/${voiceDirectory}/${voiceFilename}.${oggAudioType}`;
case "l2dSpine":
return `${dataUrl}/spine/${arg}/${arg}.skel`;
return getSpine42Url(`${dataUrl}/spine/${arg}/${arg}.skel`);
case "otherL2dSpine":
return `${dataUrl}/spine/${arg}.skel`;
return getSpine42Url(`${dataUrl}/spine42/${arg}.skel`);
case "excel":
// return `${dataUrl}/data/${arg}`; // FIXME: 临时禁用缓存
return `${dataUrl}/data/${arg}?t=${Math.floor(Date.now() / 3600000)}`;
Expand All @@ -77,9 +95,9 @@ export function getResourcesUrl(type: ResourcesTypes, arg: string): string {
// eslint-disable-next-line no-case-declarations
const filename = `${id}_spr`; //hasumi_spr
if (superSampling) {
return `${dataUrl}/spine/${filename}/${filename}${superSampling}/${filename}.skel`;
return getSpine42Url(`${dataUrl}/spine/${filename}/${filename}${superSampling}/${filename}.skel`);
}
return `${dataUrl}/spine/${filename}/${filename}.skel`;
return getSpine42Url(`${dataUrl}/spine/${filename}/${filename}.skel`);
case "bg":
// UIs/03_Scenario/01_Background/BG_WinterRoad.jpg
if (superSampling && /01_Background/.test(arg)) {
Expand Down

0 comments on commit fdcb639

Please sign in to comment.