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

+1-1
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=./",
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

+26-3
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

+2
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

+1-1
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

+1-1
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

+5-2
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

+18-1
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

+3
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

+1-1
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
],

packages/webgal/src/store/stageReducer.ts

+16-1
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,19 @@ const stageSlice = createSlice({
124124
}
125125
},
126126
addPerform: (state, action: PayloadAction<IRunPerform>) => {
127+
// 先检查是否有重复的,全部干掉
128+
const dupPerformIndex = state.PerformList.findIndex((p) => p.id === action.payload.id);
129+
if (dupPerformIndex > -1) {
130+
const dupId = action.payload.id;
131+
// 删除全部重复演出
132+
for (let i = 0; i < state.PerformList.length; i++) {
133+
const performItem: IRunPerform = state.PerformList[i];
134+
if (performItem.id === dupId) {
135+
state.PerformList.splice(i, 1);
136+
i--;
137+
}
138+
}
139+
}
127140
state.PerformList.push(action.payload);
128141
},
129142
removePerformByName: (state, action: PayloadAction<string>) => {
@@ -135,6 +148,9 @@ const stageSlice = createSlice({
135148
}
136149
}
137150
},
151+
removeAllPerform: (state) => {
152+
state.PerformList.splice(0, state.PerformList.length);
153+
},
138154
removeAllPixiPerforms: (state, action: PayloadAction<undefined>) => {
139155
for (let i = 0; i < state.PerformList.length; i++) {
140156
const performItem: IRunPerform = state.PerformList[i];
@@ -205,7 +221,6 @@ const stageSlice = createSlice({
205221
if (action.payload[3]) {
206222
if (state.figureMetaData[action.payload[0]]) delete state.figureMetaData[action.payload[0]];
207223
} else {
208-
console.log('yeah');
209224
// 初始化对象
210225
if (!state.figureMetaData[action.payload[0]]) {
211226
state.figureMetaData[action.payload[0]] = {};

releasenote.md

+13-30
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,15 @@
88

99
#### 新功能
1010

11-
文本拓展语法对角色名称生效
12-
13-
模拟口型同步
14-
15-
允许修改 Live2D 绘制范围
16-
17-
允许设定立绘的 z-index
11+
对话内容支持不间断的连续空格
1812

1913
#### 修复
2014

21-
修复了文本增强语法在首行不生效的问题
15+
读取存档时意外在状态表中存储了多份演出记录的问题
2216

23-
优化为立绘应用效果的性能
17+
带有 id 的效果音播放在停止后演出未完全清除的问题
2418

25-
优化立绘进出场效果的性能
19+
对状态表和演出控制器中的演出列表在插入时去重
2620

2721
<!-- English Translation -->
2822
## Release Notes
@@ -35,21 +29,15 @@
3529

3630
#### New Features
3731

38-
Text extension syntax now affects character names
39-
40-
Simulate lip sync
41-
42-
Allow modification of Live2D drawing range
43-
44-
Allow setting the z-index of the character sprite
32+
Dialogue content now supports continuous spaces.
4533

4634
#### Fixes
4735

48-
Fixed the issue where text enhancement syntax did not take effect on the first line
36+
Fixed an issue where multiple performance records were unexpectedly stored in the state table when loading a save.
4937

50-
Optimized the performance of applying effects to character sprites
38+
Fixed an issue where performances with IDs were not completely cleared after stopping sound effects playback.
5139

52-
Optimized the performance of character sprite entry and exit effects
40+
Deduplicated performance lists in the state table and performance controller upon insertion.
5341

5442
<!-- Japanese Translation -->
5543
## リリースノート
@@ -62,18 +50,13 @@ Optimized the performance of character sprite entry and exit effects
6250

6351
#### 新機能
6452

65-
テキスト拡張文法がキャラクタ名に有効になった
66-
67-
口パク同期
68-
69-
Live2D の描画範囲変更が可能になった
70-
71-
立ち絵の z-index 設定が可能になった
53+
会話内容で連続するスペースが正しく表示されるようになりました。
7254

7355
#### 修正
7456

75-
テキスト拡張文法が先頭行に有効にならない問題を修正
57+
セーブデータ読み込み時に、ステータステーブルに複数の演出記録が重複して保存される問題を修正しました。
58+
59+
IDを持つ効果音が停止した後、演出が完全にクリアされない問題を修正しました。
7660

77-
立ち絵にエフェクトを適用する時のパフォーマンスを最適化
61+
ステータステーブルと演出コントローラーの演出リストにおいて、重複した項目が挿入されるのを防ぐように修正しました。
7862

79-
立ち絵の登場・退場エフェクトのパフォーマンスを最適化

0 commit comments

Comments
 (0)