Skip to content

Commit

Permalink
bug: fix backlog record
Browse files Browse the repository at this point in the history
  • Loading branch information
ClodLingxi committed Dec 25, 2024
1 parent 8d88572 commit f3085e6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { ISceneEntry } from '@/Core/Modules/scene';
import { IBacklogItem } from '@/Core/Modules/backlog';
import { SYSTEM_CONFIG } from '@/config';
import { WebGAL } from '@/Core/WebGAL';
import {callBackFunctionOfUpdate, updateFigureFlag, useSetFigure} from "@/Stage/MainStage/useSetFigure";

export const whenChecker = (whenValue: string | undefined): boolean => {
if (whenValue === undefined) {
Expand Down Expand Up @@ -150,7 +151,10 @@ export const scriptExecutor = () => {
// 保存 backlog
if (isSaveBacklog) {
// WebGAL.backlogManager.isSaveBacklogNext = true;
WebGAL.backlogManager.saveCurrentStateToBacklog();
const saveFunction = () => WebGAL.backlogManager.saveCurrentStateToBacklog();
if (updateFigureFlag) {
callBackFunctionOfUpdate.push(saveFunction);
} else saveFunction();
}
}, 0);
WebGAL.sceneManager.sceneData.currentSentenceId++;
Expand Down
25 changes: 20 additions & 5 deletions packages/webgal/src/Stage/MainStage/useSetFigure.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import { generateUniversalSoftOffAnimationObj } from '@/Core/controller/stage/pi
import { getEnterExitAnimation } from '@/Core/Modules/animationFunctions';
import { WebGAL } from '@/Core/WebGAL';

export let updateFigureFlag = false;
export const callBackFunctionOfUpdate: Function[] = [];

export function useSetFigure(stageState: IStageState) {
const { figNameLeft, figName, figNameRight, freeFigure, live2dMotion, live2dExpression } = stageState;

Expand Down Expand Up @@ -49,7 +52,7 @@ export function useSetFigure(stageState: IStageState) {
logger.debug('中立绘已重设');
const { duration, animation } = getEnterExitAnimation(thisFigKey, 'enter');
WebGAL.gameplay.pixiStage!.registerPresetAnimation(animation, softInAniKey, thisFigKey, stageState.effects);
setTimeout(() => WebGAL.gameplay.pixiStage!.removeAnimationWithSetEffects(softInAniKey), duration);
updateFigureToRemoveAnimationWithSetEffects(softInAniKey, duration);
} else {
logger.debug('移除中立绘');
const currentFigCenter = WebGAL.gameplay.pixiStage?.getStageObjByKey(thisFigKey);
Expand All @@ -61,6 +64,18 @@ export function useSetFigure(stageState: IStageState) {
}
}, [figName]);

const updateFigureToRemoveAnimationWithSetEffects = (softInAniKey: string, duration: number) => {
updateFigureFlag = true;
setTimeout(() => {
WebGAL.gameplay.pixiStage!.removeAnimationWithSetEffects(softInAniKey);
while (callBackFunctionOfUpdate.length) {
const fun = callBackFunctionOfUpdate.shift();
fun?.();
}
updateFigureFlag = false;
}, duration);
};

useEffect(() => {
/**
* 特殊处理:左侧立绘
Expand All @@ -78,7 +93,7 @@ export function useSetFigure(stageState: IStageState) {
logger.debug('左立绘已重设');
const { duration, animation } = getEnterExitAnimation(thisFigKey, 'enter');
WebGAL.gameplay.pixiStage!.registerPresetAnimation(animation, softInAniKey, thisFigKey, stageState.effects);
setTimeout(() => WebGAL.gameplay.pixiStage!.removeAnimationWithSetEffects(softInAniKey), duration);
updateFigureToRemoveAnimationWithSetEffects(softInAniKey, duration);
} else {
logger.debug('移除左立绘');
const currentFigLeft = WebGAL.gameplay.pixiStage?.getStageObjByKey(thisFigKey);
Expand Down Expand Up @@ -107,7 +122,7 @@ export function useSetFigure(stageState: IStageState) {
logger.debug('右立绘已重设');
const { duration, animation } = getEnterExitAnimation(thisFigKey, 'enter');
WebGAL.gameplay.pixiStage!.registerPresetAnimation(animation, softInAniKey, thisFigKey, stageState.effects);
setTimeout(() => WebGAL.gameplay.pixiStage!.removeAnimationWithSetEffects(softInAniKey), duration);
updateFigureToRemoveAnimationWithSetEffects(softInAniKey, duration);
} else {
const currentFigRight = WebGAL.gameplay.pixiStage?.getStageObjByKey(thisFigKey);
if (currentFigRight) {
Expand Down Expand Up @@ -138,14 +153,14 @@ export function useSetFigure(stageState: IStageState) {
logger.debug(`${fig.key}立绘已重设`);
const { duration, animation } = getEnterExitAnimation(thisFigKey, 'enter');
WebGAL.gameplay.pixiStage!.registerPresetAnimation(animation, softInAniKey, thisFigKey, stageState.effects);
setTimeout(() => WebGAL.gameplay.pixiStage!.removeAnimationWithSetEffects(softInAniKey), duration);
updateFigureToRemoveAnimationWithSetEffects(softInAniKey, duration);
}
} else {
addFigure(undefined, thisFigKey, fig.name, fig.basePosition);
logger.debug(`${fig.key}立绘已重设`);
const { duration, animation } = getEnterExitAnimation(thisFigKey, 'enter');
WebGAL.gameplay.pixiStage!.registerPresetAnimation(animation, softInAniKey, thisFigKey, stageState.effects);
setTimeout(() => WebGAL.gameplay.pixiStage!.removeAnimationWithSetEffects(softInAniKey), duration);
updateFigureToRemoveAnimationWithSetEffects(softInAniKey, duration);
}
} else {
const currentFigThisKey = WebGAL.gameplay.pixiStage?.getStageObjByKey(thisFigKey);
Expand Down

0 comments on commit f3085e6

Please sign in to comment.