Skip to content

Commit f993450

Browse files
Merge pull request #582 from OpenWebGAL/dev
4.5.9
2 parents 07c8329 + 848a403 commit f993450

File tree

12 files changed

+88
-42
lines changed

12 files changed

+88
-42
lines changed

packages/webgal/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "webgal",
33
"private": true,
4-
"version": "4.5.8",
4+
"version": "4.5.9",
55
"scripts": {
66
"dev": "vite --host --port 3000",
77
"build": "cross-env NODE_ENV=production tsc && vite build --base=./",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"name":"Default Template",
3-
"webgal-version":"4.5.8"
3+
"webgal-version":"4.5.9"
44
}

packages/webgal/src/Core/Modules/perform/performController.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import cloneDeep from 'lodash/cloneDeep';
55
import { resetStageState, stageActions } from '@/store/stageReducer';
66
import { nextSentence } from '@/Core/controller/gamePlay/nextSentence';
77
import { IRunPerform } from '@/store/stageInterface';
8+
import { WEBGAL_NONE } from '@/Core/constants';
89

910
/**
1011
* 获取随机演出名称
@@ -18,8 +19,23 @@ export class PerformController {
1819
public timeoutList: Array<ReturnType<typeof setTimeout>> = [];
1920

2021
public arrangeNewPerform(perform: IPerform, script: ISentence, syncPerformState = true) {
22+
// 检查演出列表内是否有相同的演出,如果有,一定是出了什么问题
23+
const dupPerformIndex = this.performList.findIndex((p) => p.performName === perform.performName);
24+
if (dupPerformIndex > -1) {
25+
// 结束并删除全部重复演出
26+
for (let i = 0; i < this.performList.length; i++) {
27+
const e = this.performList[i];
28+
if (e.performName === perform.performName) {
29+
e.stopFunction();
30+
clearTimeout(e.stopTimeout as unknown as number);
31+
this.performList.splice(i, 1);
32+
i--;
33+
}
34+
}
35+
}
36+
2137
// 语句不执行演出
22-
if (perform.performName === 'none') {
38+
if (perform.performName === WEBGAL_NONE) {
2339
return;
2440
}
2541
// 同步演出状态
@@ -50,12 +66,19 @@ export class PerformController {
5066
if (!e.isHoldOn && e.performName === name) {
5167
e.stopFunction();
5268
clearTimeout(e.stopTimeout as unknown as number);
69+
/**
70+
* 在演出列表里删除演出对象的操作必须在调用 goNextWhenOver 之前
71+
* 因为 goNextWhenOver 会调用 nextSentence,而 nextSentence 会清除目前未结束的演出
72+
* 那么 nextSentence 函数就会删除这个演出,但是此时,在这个上下文,i 已经被确定了
73+
* 所以 goNextWhenOver 后的代码会多删东西,解决方法就是在调用 goNextWhenOver 前先删掉这个演出对象
74+
* 此问题对所有 goNextWhenOver 属性为真的演出都有影响,但只有 2 个演出有此问题
75+
*/
76+
this.performList.splice(i, 1);
77+
i--;
5378
if (e.goNextWhenOver) {
5479
// nextSentence();
5580
this.goNextWhenOver();
5681
}
57-
this.performList.splice(i, 1);
58-
i--;
5982
}
6083
}
6184
} else {

packages/webgal/src/Core/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ export const STAGE_KEYS = {
44
FIG_L: 'fig-left',
55
FIG_R: 'fig-right',
66
};
7+
8+
export const WEBGAL_NONE = 'none';

packages/webgal/src/Core/controller/gamePlay/nextSentence.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ export const nextSentence = () => {
7070
if (!e.isHoldOn) {
7171
if (e.goNextWhenOver) {
7272
isGoNext = true;
73-
}
73+
} // 先检查是不是要跳过收集
7474
if (!e.skipNextCollect) {
7575
// 由于提前结束使用的不是 unmountPerform 标准 API,所以不会触发两次 nextSentence
7676
e.stopFunction();

packages/webgal/src/Core/controller/stage/pixi/PixiController.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ export default class PixiStage {
842842

843843
const paramY = mapToZeroOne(y);
844844
const target = this.figureObjects.find((e) => e.key === key);
845-
if (target) {
845+
if (target && target.sourceType === 'live2d') {
846846
const container = target.pixiContainer;
847847
const children = container.children;
848848
for (const model of children) {

packages/webgal/src/Core/controller/storage/jumpFromBacklog.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { sceneFetcher } from '../scene/sceneFetcher';
33
import { sceneParser } from '../../parser/sceneParser';
44
import { IStageState } from '@/store/stageInterface';
55
import { webgalStore } from '@/store/store';
6-
import { resetStageState } from '@/store/stageReducer';
6+
import { resetStageState, stageActions } from '@/store/stageReducer';
77
import { setVisibility } from '@/store/GUIReducer';
88
import { runScript } from '@/Core/controller/gamePlay/runScript';
99
import { stopAllPerform } from '@/Core/controller/gamePlay/stopAllPerform';
@@ -18,7 +18,10 @@ import { WebGAL } from '@/Core/WebGAL';
1818
*/
1919
export const restorePerform = () => {
2020
const stageState = webgalStore.getState().stage;
21-
stageState.PerformList.forEach((e) => {
21+
const performToRestore = cloneDeep(stageState.PerformList);
22+
// 清除状态表中演出序列
23+
webgalStore.dispatch(stageActions.removeAllPerform());
24+
performToRestore.forEach((e) => {
2225
runScript(e.script);
2326
});
2427
};

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { getSentenceArgByKey } from '@/Core/util/getSentenceArg';
55
import { IPerform } from '@/Core/Modules/perform/performInterface';
66
import { useSelector } from 'react-redux';
77
import { WebGAL } from '@/Core/WebGAL';
8+
import { WEBGAL_NONE } from '@/Core/constants';
89

910
/**
1011
* 播放一段效果音
@@ -27,6 +28,21 @@ export const playEffect = (sentence: ISentence): IPerform => {
2728
isLoop = true;
2829
}
2930
let isOver = false;
31+
if (!url || url === WEBGAL_NONE) {
32+
return {
33+
performName: WEBGAL_NONE,
34+
duration: 0,
35+
isHoldOn: false,
36+
blockingAuto(): boolean {
37+
return false;
38+
},
39+
blockingNext(): boolean {
40+
return false;
41+
},
42+
stopFunction(): void {},
43+
stopTimeout: undefined,
44+
};
45+
}
3046
return {
3147
performName: 'none',
3248
blockingAuto(): boolean {
@@ -56,14 +72,15 @@ export const playEffect = (sentence: ISentence): IPerform => {
5672
const seVol = mainVol * 0.01 * (userDataState.optionData?.seVolume ?? 100) * 0.01 * volume * 0.01;
5773
seElement.volume = seVol;
5874
seElement.currentTime = 0;
59-
const perform = {
75+
const perform: IPerform = {
6076
performName: performInitName,
6177
duration: 1000 * 60 * 60,
6278
isHoldOn: isLoop,
6379
skipNextCollect: true,
6480
stopFunction: () => {
6581
// 演出已经结束了,所以不用播放效果音了
6682
seElement.pause();
83+
seElement.remove();
6784
},
6885
blockingNext: () => false,
6986
blockingAuto: () => {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ export const say = (sentence: ISentence): IPerform => {
2323
const dispatch = webgalStore.dispatch;
2424
let dialogKey = Math.random().toString(); // 生成一个随机的key
2525
let dialogToShow = sentence.content; // 获取对话内容
26+
if (dialogToShow) {
27+
dialogToShow = String(dialogToShow).replace(/ /g, '\u00a0'); // 替换空格
28+
}
2629
const isConcat = getSentenceArgByKey(sentence, 'concat'); // 是否是继承语句
2730
const isNotend = getSentenceArgByKey(sentence, 'notend') as boolean; // 是否有 notend 参数
2831
const speaker = getSentenceArgByKey(sentence, 'speaker'); // 获取说话者

packages/webgal/src/config/info.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const __INFO = {
2-
version: 'WebGAL 4.5.8',
2+
version: 'WebGAL 4.5.9',
33
contributors: [
44
// 现在改为跳转到 GitHub 了
55
],

0 commit comments

Comments
 (0)