Skip to content

Commit 007785d

Browse files
author
Hardy--Lee
committed
fix: merge conflict
1 parent b46e61e commit 007785d

File tree

3 files changed

+34
-69
lines changed

3 files changed

+34
-69
lines changed

packages/webgal/src/Core/Modules/animationFunctions.ts

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { WebGAL } from '@/Core/WebGAL';
99
import PixiStage, { IAnimationObject, IStageObject } from '@/Core/controller/stage/pixi/PixiController';
1010
import { AnimationFrame, IUserAnimation } from './animations';
1111
import { generateTransformAnimationObj } from '../controller/stage/pixi/animations/generateTransformAnimationObj';
12-
import { getSentenceArgByKey } from '../util/getSentenceArg';
12+
import { getNumberArgByKey, getStringArgByKey } from '../util/getSentenceArg';
1313
import { ISentence } from '../controller/scene/sceneInterface';
1414

1515
// eslint-disable-next-line max-params
@@ -128,13 +128,9 @@ export function createEnterExitAnimation(
128128
currentTransform: ITransform,
129129
): number {
130130
// 处理 transform 和 默认 transform
131-
const transformString = getSentenceArgByKey(sentence, 'transform');
132-
const durationFromArg = getSentenceArgByKey(sentence, 'duration');
133-
const ease = getSentenceArgByKey(sentence, 'ease')?.toString() ?? '';
134-
let duration = defaultDuration;
135-
if (typeof durationFromArg === 'number') {
136-
duration = durationFromArg;
137-
}
131+
const transformString = getStringArgByKey(sentence, 'transform');
132+
const ease = getStringArgByKey(sentence, 'ease') ?? '';
133+
let duration = getNumberArgByKey(sentence, 'duration') ?? defaultDuration;
138134

139135
if (transformString) {
140136
console.log(transformString);
@@ -159,15 +155,15 @@ export function createEnterExitAnimation(
159155
createDefaultEnterExitAnimation('exit', targetKey, exitFrame, duration, ease);
160156
}
161157

162-
const enterAnim = getSentenceArgByKey(sentence, 'enter');
163-
const exitAnim = getSentenceArgByKey(sentence, 'exit');
164-
if (enterAnim) {
165-
WebGAL.animationManager.nextEnterAnimationName.set(targetKey, enterAnim.toString());
166-
duration = getAnimateDuration(enterAnim.toString());
158+
const enterAnimation = getStringArgByKey(sentence, 'enter');
159+
const exitAnimation = getStringArgByKey(sentence, 'exit');
160+
if (enterAnimation) {
161+
WebGAL.animationManager.nextEnterAnimationName.set(targetKey, enterAnimation);
162+
duration = getAnimateDuration(enterAnimation);
167163
}
168-
if (exitAnim) {
169-
WebGAL.animationManager.nextExitAnimationName.set(targetKey, exitAnim.toString());
170-
duration = getAnimateDuration(exitAnim.toString());
164+
if (exitAnimation) {
165+
WebGAL.animationManager.nextExitAnimationName.set(targetKey, exitAnimation);
166+
duration = getAnimateDuration(exitAnimation);
171167
}
172168

173169
return duration;

packages/webgal/src/Core/gameScripts/changeBg/index.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,9 @@ import { webgalStore } from '@/store/store';
66
import { setStage, stageActions } from '@/store/stageReducer';
77
import { getNumberArgByKey, getStringArgByKey } from '@/Core/util/getSentenceArg';
88
import { unlockCgInUserData } from '@/store/userDataReducer';
9-
import { logger } from '@/Core/util/logger';
10-
import { baseTransform, ITransform } from '@/store/stageInterface';
11-
import { generateTransformAnimationObj } from '@/Core/controller/stage/pixi/animations/generateTransformAnimationObj';
12-
import { AnimationFrame, IUserAnimation } from '@/Core/Modules/animations';
9+
import { baseTransform } from '@/store/stageInterface';
1310
import cloneDeep from 'lodash/cloneDeep';
14-
import {
15-
createDefaultEnterExitAnimation,
16-
createEnterExitAnimation,
17-
getAnimateDuration,
18-
getEnterAnimationKey,
19-
getOldTargetKey,
20-
} from '@/Core/Modules/animationFunctions';
11+
import { createEnterExitAnimation, getEnterAnimationKey, getOldTargetKey } from '@/Core/Modules/animationFunctions';
2112
import { WebGAL } from '@/Core/WebGAL';
2213
import { STAGE_KEYS } from '@/Core/constants';
2314

@@ -29,30 +20,27 @@ import { STAGE_KEYS } from '@/Core/constants';
2920
export const changeBg = (sentence: ISentence): IPerform => {
3021
const url = sentence.content;
3122
const key = STAGE_KEYS.BG_MAIN;
32-
let duration = 1000;
3323
const unlockName = getStringArgByKey(sentence, 'unlockname') ?? '';
3424
const series = getStringArgByKey(sentence, 'series') ?? 'default';
35-
const transformString = getStringArgByKey(sentence, 'transform');
3625
let duration = getNumberArgByKey(sentence, 'duration') ?? 1000;
37-
const ease = getStringArgByKey(sentence, 'ease') ?? '';
3826

3927
const dispatch = webgalStore.dispatch;
4028
if (unlockName !== '') {
4129
dispatch(unlockCgInUserData({ name: unlockName, url, series }));
30+
}
4231

4332
// 储存一下现有的 transform 给退场动画当起始帧用, 因为马上就要清除了
4433
const currentEffect = webgalStore.getState().stage.effects.find((e) => e.target === key);
4534
let currentTransform = baseTransform;
4635
if (currentEffect?.transform) {
4736
currentTransform = cloneDeep(currentEffect.transform);
4837
}
49-
}
5038

5139
/**
5240
* 删掉相关 Effects,因为已经移除了
5341
*/
5442
if (webgalStore.getState().stage.bgName !== sentence.content) {
55-
dispatch(stageActions.removeEffectByTargetId(`bg-main`));
43+
dispatch(stageActions.removeEffectByTargetId(key));
5644
}
5745

5846
duration = createEnterExitAnimation(sentence, key, duration, currentTransform);

packages/webgal/src/Core/gameScripts/changeFigure.ts

Lines changed: 18 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,9 @@ import { webgalStore } from '@/store/store';
44
import { setStage, stageActions } from '@/store/stageReducer';
55
import cloneDeep from 'lodash/cloneDeep';
66
import { getBooleanArgByKey, getNumberArgByKey, getStringArgByKey } from '@/Core/util/getSentenceArg';
7-
import { baseTransform, IFreeFigure, IStageState, ITransform } from '@/store/stageInterface';
8-
import { AnimationFrame, IUserAnimation } from '@/Core/Modules/animations';
9-
import { generateTransformAnimationObj } from '@/Core/controller/stage/pixi/animations/generateTransformAnimationObj';
7+
import { baseTransform, IFreeFigure, IStageState } from '@/store/stageInterface';
108
import { assetSetter, fileType } from '@/Core/util/gameAssetsAccess/assetSetter';
11-
import { logger } from '@/Core/util/logger';
12-
import {
13-
createDefaultEnterExitAnimation,
14-
createEnterExitAnimation,
15-
getAnimateDuration,
16-
getEnterAnimationKey,
17-
getOldTargetKey,
18-
} from '@/Core/Modules/animationFunctions';
9+
import { createEnterExitAnimation, getEnterAnimationKey, getOldTargetKey } from '@/Core/Modules/animationFunctions';
1910
import { WebGAL } from '@/Core/WebGAL';
2011
import { STAGE_KEYS } from '../constants';
2112
/**
@@ -48,9 +39,17 @@ export function changeFigure(sentence: ISentence): IPerform {
4839
}
4940

5041
// id 与 自由立绘
51-
let key = getStringArgByKey(sentence, 'id') ?? '';
52-
const isFreeFigure = key ? true : false;
53-
const id = key ? key : `fig-${pos}`;
42+
const idFromArgs = getStringArgByKey(sentence, 'id') ?? '';
43+
const isFreeFigure = idFromArgs ? true : false;
44+
let key = idFromArgs;
45+
if (!isFreeFigure) {
46+
const positionMap = {
47+
center: STAGE_KEYS.FIG_CENTER,
48+
left: STAGE_KEYS.FIG_LEFT,
49+
right: STAGE_KEYS.FIG_RIGHT,
50+
};
51+
key = positionMap[pos];
52+
}
5453

5554
// live2d 或 spine 相关
5655
let motion = getStringArgByKey(sentence, 'motion') ?? '';
@@ -66,19 +65,15 @@ export function changeFigure(sentence: ISentence): IPerform {
6665
const animationFlag = getStringArgByKey(sentence, 'animationFlag') ?? '';
6766

6867
// 其他参数
69-
const transformString = getStringArgByKey(sentence, 'transform');
70-
const ease = getStringArgByKey(sentence, 'ease') ?? '';
7168
let duration = getNumberArgByKey(sentence, 'duration') ?? 500;
72-
const enterAnimation = getStringArgByKey(sentence, 'enter');
73-
const exitAnimation = getStringArgByKey(sentence, 'exit');
7469
const zIndex = getNumberArgByKey(sentence, 'zIndex') ?? -1;
7570

7671
const dispatch = webgalStore.dispatch;
7772

7873
const currentFigureAssociatedAnimation = webgalStore.getState().stage.figureAssociatedAnimation;
79-
const filteredFigureAssociatedAnimation = currentFigureAssociatedAnimation.filter((item) => item.targetId !== id);
74+
const filteredFigureAssociatedAnimation = currentFigureAssociatedAnimation.filter((item) => item.targetId !== key);
8075
const newFigureAssociatedAnimationItem = {
81-
targetId: id,
76+
targetId: key,
8277
animationFlag: animationFlag,
8378
mouthAnimation: {
8479
open: mouthOpen,
@@ -97,7 +92,7 @@ export function changeFigure(sentence: ISentence): IPerform {
9792
* 如果 url 没变,不移除
9893
*/
9994
let isRemoveEffects = true;
100-
if (key !== '') {
95+
if (isFreeFigure) {
10196
const figWithKey = webgalStore.getState().stage.freeFigure.find((e) => e.key === key);
10297
if (figWithKey) {
10398
if (figWithKey.name === sentence.content) {
@@ -122,16 +117,6 @@ export function changeFigure(sentence: ISentence): IPerform {
122117
}
123118
}
124119

125-
// 确定 key
126-
if (!isFreeFigure) {
127-
const positionMap = {
128-
center: STAGE_KEYS.FIG_CENTER,
129-
left: STAGE_KEYS.FIG_LEFT,
130-
right: STAGE_KEYS.FIG_RIGHT,
131-
};
132-
key = positionMap[pos];
133-
}
134-
135120
// 储存一下现有的 transform 给退场动画当起始帧用, 因为马上就要清除了
136121
const currentEffect = webgalStore.getState().stage.effects.find((e) => e.target === key);
137122
let currentTransform = baseTransform;
@@ -143,13 +128,9 @@ export function changeFigure(sentence: ISentence): IPerform {
143128
* 处理 Effects
144129
*/
145130
if (isRemoveEffects) {
146-
const deleteKey = `fig-${pos}`;
147-
const deleteKey2 = `${key}`;
148-
webgalStore.dispatch(stageActions.removeEffectByTargetId(deleteKey));
149-
webgalStore.dispatch(stageActions.removeEffectByTargetId(deleteKey2));
131+
webgalStore.dispatch(stageActions.removeEffectByTargetId(key));
150132
// 重设 figureMetaData,这里是 zIndex,实际上任何键都可以,因为整体是移除那条记录
151-
dispatch(stageActions.setFigureMetaData([deleteKey, 'zIndex', 0, true]));
152-
dispatch(stageActions.setFigureMetaData([deleteKey2, 'zIndex', 0, true]));
133+
dispatch(stageActions.setFigureMetaData([key, 'zIndex', 0, true]));
153134
}
154135

155136
duration = createEnterExitAnimation(sentence, key, duration, currentTransform);

0 commit comments

Comments
 (0)