From f1474807547f0ae5a09501e9c00ab77c6d33f5ae Mon Sep 17 00:00:00 2001 From: ChangeSuger Date: Sun, 11 Jan 2026 22:24:14 +0800 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20changeBg=20?= =?UTF-8?q?=E4=B8=8E=20changeFigure=20=E7=9A=84=20exit=20=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E4=B8=8D=E8=83=BD=E6=AD=A3=E5=B8=B8=E7=94=9F=E6=95=88?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../webgal/src/Core/Modules/animationFunctions.ts | 6 +++--- packages/webgal/src/store/stageReducer.ts | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/packages/webgal/src/Core/Modules/animationFunctions.ts b/packages/webgal/src/Core/Modules/animationFunctions.ts index 1c5fa4471..249267421 100644 --- a/packages/webgal/src/Core/Modules/animationFunctions.ts +++ b/packages/webgal/src/Core/Modules/animationFunctions.ts @@ -91,13 +91,13 @@ export function getEnterExitAnimation( duration = DEFAULT_BG_OUT_DURATION; } duration = - webgalStore.getState().stage.animationSettings.find((setting) => setting.target + '-off' === target) - ?.exitDuration ?? duration; + webgalStore.getState().stage.animationSettings.find((setting) => setting.target === target)?.exitDuration ?? + duration; // 走默认动画 let animation: IAnimationObject | null = generateUniversalSoftOffAnimationObj(realTarget ?? target, duration); const animationName = webgalStore .getState() - .stage.animationSettings.find((setting) => setting.target + '-off' === target)?.exitAnimationName; + .stage.animationSettings.find((setting) => setting.target === target)?.exitAnimationName; if (animationName) { logger.debug('取代默认退出动画', target); animation = getAnimationObject(animationName, realTarget ?? target, getAnimateDuration(animationName), false); diff --git a/packages/webgal/src/store/stageReducer.ts b/packages/webgal/src/store/stageReducer.ts index 450efbe38..0ebc48f2e 100644 --- a/packages/webgal/src/store/stageReducer.ts +++ b/packages/webgal/src/store/stageReducer.ts @@ -156,7 +156,22 @@ const stageSlice = createSlice({ removeAnimationSettingsByTarget: (state, action: PayloadAction) => { const index = state.animationSettings.findIndex((a) => a.target === action.payload); if (index >= 0) { + const prev = state.animationSettings[index]; state.animationSettings.splice(index, 1); + + const prevTarget = `${action.payload}-off`; + const prevSetting = { + ...prev, + target: prevTarget, + }; + + const prevIndex = state.animationSettings.findIndex((a) => a.target === prevTarget); + + if (prevIndex >= 0) { + state.animationSettings.splice(prevIndex, 1, prevSetting); + } else { + state.animationSettings.push(prevSetting); + } } }, addPerform: (state, action: PayloadAction) => { From 3f1611b22a69eabc50ff621402e0f0f27e019f60 Mon Sep 17 00:00:00 2001 From: Mahiru Date: Wed, 14 Jan 2026 22:15:57 +0800 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=E5=BA=94=E7=94=A8=E9=80=80?= =?UTF-8?q?=E5=87=BA=E5=8A=A8=E7=94=BB=E5=90=8E=E5=88=A0=E9=99=A4=E9=80=80?= =?UTF-8?q?=E5=87=BA=E5=8A=A8=E7=94=BB=E8=AE=BE=E5=AE=9A=EF=BC=9B=E7=AB=8B?= =?UTF-8?q?=E7=BB=98=E5=85=B3=E9=97=AD=E6=97=B6=E4=B8=8D=E8=AE=BE=E5=AE=9A?= =?UTF-8?q?=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/Core/Modules/animationFunctions.ts | 4 +++ .../src/Core/gameScripts/changeFigure.ts | 4 +++ packages/webgal/src/store/stageReducer.ts | 30 ++++++++++++------- 3 files changed, 28 insertions(+), 10 deletions(-) diff --git a/packages/webgal/src/Core/Modules/animationFunctions.ts b/packages/webgal/src/Core/Modules/animationFunctions.ts index 249267421..a399013fc 100644 --- a/packages/webgal/src/Core/Modules/animationFunctions.ts +++ b/packages/webgal/src/Core/Modules/animationFunctions.ts @@ -13,6 +13,7 @@ import { DEFAULT_FIG_IN_DURATION, DEFAULT_FIG_OUT_DURATION, } from '../constants'; +import { stageActions } from '@/store/stageReducer'; // eslint-disable-next-line max-params export function getAnimationObject(animationName: string, target: string, duration: number, writeDefault: boolean) { @@ -102,6 +103,9 @@ export function getEnterExitAnimation( logger.debug('取代默认退出动画', target); animation = getAnimationObject(animationName, realTarget ?? target, getAnimateDuration(animationName), false); duration = getAnimateDuration(animationName); + // 退出动画拿完后,删了这个设定 + webgalStore.dispatch(stageActions.removeAnimationSettingsByTargetOff(target)); + logger.debug('删除退出动画设定', target); } return { duration, animation }; } diff --git a/packages/webgal/src/Core/gameScripts/changeFigure.ts b/packages/webgal/src/Core/gameScripts/changeFigure.ts index 907d5ad99..10a8c8891 100644 --- a/packages/webgal/src/Core/gameScripts/changeFigure.ts +++ b/packages/webgal/src/Core/gameScripts/changeFigure.ts @@ -155,6 +155,10 @@ export function changeFigure(sentence: ISentence): IPerform { } } const setAnimationNames = (key: string, sentence: ISentence) => { + // 如果立绘被关闭了,那么就不用设置了 + if (content === '') { + return; + } // 处理 transform 和 默认 transform let animationObj: AnimationFrame[]; if (transformString) { diff --git a/packages/webgal/src/store/stageReducer.ts b/packages/webgal/src/store/stageReducer.ts index 0ebc48f2e..894aad736 100644 --- a/packages/webgal/src/store/stageReducer.ts +++ b/packages/webgal/src/store/stageReducer.ts @@ -159,21 +159,31 @@ const stageSlice = createSlice({ const prev = state.animationSettings[index]; state.animationSettings.splice(index, 1); - const prevTarget = `${action.payload}-off`; - const prevSetting = { - ...prev, - target: prevTarget, - }; + if (prev.exitAnimationName) { + // 如果有退出动画设定,保留一个 -off 的设定 + const prevTarget = `${action.payload}-off`; + const prevSetting = { + ...prev, + target: prevTarget, + }; - const prevIndex = state.animationSettings.findIndex((a) => a.target === prevTarget); + const prevIndex = state.animationSettings.findIndex((a) => a.target === prevTarget); - if (prevIndex >= 0) { - state.animationSettings.splice(prevIndex, 1, prevSetting); - } else { - state.animationSettings.push(prevSetting); + if (prevIndex >= 0) { + state.animationSettings.splice(prevIndex, 1, prevSetting); + } else { + state.animationSettings.push(prevSetting); + } } } }, + removeAnimationSettingsByTargetOff: (state, action: PayloadAction) => { + // 这里不加 -off 因为传入的就是带 -off 的 + const index = state.animationSettings.findIndex((a) => a.target === `${action.payload}`); + if (index >= 0) { + state.animationSettings.splice(index, 1); + } + }, addPerform: (state, action: PayloadAction) => { // 先检查是否有重复的,全部干掉 const dupPerformIndex = state.PerformList.findIndex((p) => p.id === action.payload.id);