Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.5.9 #582

Merged
merged 7 commits into from
Nov 4, 2024
Merged

4.5.9 #582

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/webgal/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "webgal",
"private": true,
"version": "4.5.8",
"version": "4.5.9",
"scripts": {
"dev": "vite --host --port 3000",
"build": "cross-env NODE_ENV=production tsc && vite build --base=./",
Expand Down
2 changes: 1 addition & 1 deletion packages/webgal/public/game/template/template.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name":"Default Template",
"webgal-version":"4.5.8"
"webgal-version":"4.5.9"
}
29 changes: 26 additions & 3 deletions packages/webgal/src/Core/Modules/perform/performController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import cloneDeep from 'lodash/cloneDeep';
import { resetStageState, stageActions } from '@/store/stageReducer';
import { nextSentence } from '@/Core/controller/gamePlay/nextSentence';
import { IRunPerform } from '@/store/stageInterface';
import { WEBGAL_NONE } from '@/Core/constants';

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

public arrangeNewPerform(perform: IPerform, script: ISentence, syncPerformState = true) {
// 检查演出列表内是否有相同的演出,如果有,一定是出了什么问题
const dupPerformIndex = this.performList.findIndex((p) => p.performName === perform.performName);
if (dupPerformIndex > -1) {
// 结束并删除全部重复演出
for (let i = 0; i < this.performList.length; i++) {
const e = this.performList[i];
if (e.performName === perform.performName) {
e.stopFunction();
clearTimeout(e.stopTimeout as unknown as number);
this.performList.splice(i, 1);
i--;
}
}
}

// 语句不执行演出
if (perform.performName === 'none') {
if (perform.performName === WEBGAL_NONE) {
return;
}
// 同步演出状态
Expand Down Expand Up @@ -50,12 +66,19 @@ export class PerformController {
if (!e.isHoldOn && e.performName === name) {
e.stopFunction();
clearTimeout(e.stopTimeout as unknown as number);
/**
* 在演出列表里删除演出对象的操作必须在调用 goNextWhenOver 之前
* 因为 goNextWhenOver 会调用 nextSentence,而 nextSentence 会清除目前未结束的演出
* 那么 nextSentence 函数就会删除这个演出,但是此时,在这个上下文,i 已经被确定了
* 所以 goNextWhenOver 后的代码会多删东西,解决方法就是在调用 goNextWhenOver 前先删掉这个演出对象
* 此问题对所有 goNextWhenOver 属性为真的演出都有影响,但只有 2 个演出有此问题
*/
this.performList.splice(i, 1);
i--;
if (e.goNextWhenOver) {
// nextSentence();
this.goNextWhenOver();
}
this.performList.splice(i, 1);
i--;
}
}
} else {
Expand Down
2 changes: 2 additions & 0 deletions packages/webgal/src/Core/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ export const STAGE_KEYS = {
FIG_L: 'fig-left',
FIG_R: 'fig-right',
};

export const WEBGAL_NONE = 'none';
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const nextSentence = () => {
if (!e.isHoldOn) {
if (e.goNextWhenOver) {
isGoNext = true;
}
} // 先检查是不是要跳过收集
if (!e.skipNextCollect) {
// 由于提前结束使用的不是 unmountPerform 标准 API,所以不会触发两次 nextSentence
e.stopFunction();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ export default class PixiStage {

const paramY = mapToZeroOne(y);
const target = this.figureObjects.find((e) => e.key === key);
if (target) {
if (target && target.sourceType === 'live2d') {
const container = target.pixiContainer;
const children = container.children;
for (const model of children) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { sceneFetcher } from '../scene/sceneFetcher';
import { sceneParser } from '../../parser/sceneParser';
import { IStageState } from '@/store/stageInterface';
import { webgalStore } from '@/store/store';
import { resetStageState } from '@/store/stageReducer';
import { resetStageState, stageActions } from '@/store/stageReducer';
import { setVisibility } from '@/store/GUIReducer';
import { runScript } from '@/Core/controller/gamePlay/runScript';
import { stopAllPerform } from '@/Core/controller/gamePlay/stopAllPerform';
Expand All @@ -18,7 +18,10 @@ import { WebGAL } from '@/Core/WebGAL';
*/
export const restorePerform = () => {
const stageState = webgalStore.getState().stage;
stageState.PerformList.forEach((e) => {
const performToRestore = cloneDeep(stageState.PerformList);
// 清除状态表中演出序列
webgalStore.dispatch(stageActions.removeAllPerform());
performToRestore.forEach((e) => {
runScript(e.script);
});
};
Expand Down
19 changes: 18 additions & 1 deletion packages/webgal/src/Core/gameScripts/playEffect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { getSentenceArgByKey } from '@/Core/util/getSentenceArg';
import { IPerform } from '@/Core/Modules/perform/performInterface';
import { useSelector } from 'react-redux';
import { WebGAL } from '@/Core/WebGAL';
import { WEBGAL_NONE } from '@/Core/constants';

/**
* 播放一段效果音
Expand All @@ -27,6 +28,21 @@ export const playEffect = (sentence: ISentence): IPerform => {
isLoop = true;
}
let isOver = false;
if (!url || url === WEBGAL_NONE) {
return {
performName: WEBGAL_NONE,
duration: 0,
isHoldOn: false,
blockingAuto(): boolean {
return false;
},
blockingNext(): boolean {
return false;
},
stopFunction(): void {},
stopTimeout: undefined,
};
}
return {
performName: 'none',
blockingAuto(): boolean {
Expand Down Expand Up @@ -56,14 +72,15 @@ export const playEffect = (sentence: ISentence): IPerform => {
const seVol = mainVol * 0.01 * (userDataState.optionData?.seVolume ?? 100) * 0.01 * volume * 0.01;
seElement.volume = seVol;
seElement.currentTime = 0;
const perform = {
const perform: IPerform = {
performName: performInitName,
duration: 1000 * 60 * 60,
isHoldOn: isLoop,
skipNextCollect: true,
stopFunction: () => {
// 演出已经结束了,所以不用播放效果音了
seElement.pause();
seElement.remove();
},
blockingNext: () => false,
blockingAuto: () => {
Expand Down
3 changes: 3 additions & 0 deletions packages/webgal/src/Core/gameScripts/say.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export const say = (sentence: ISentence): IPerform => {
const dispatch = webgalStore.dispatch;
let dialogKey = Math.random().toString(); // 生成一个随机的key
let dialogToShow = sentence.content; // 获取对话内容
if (dialogToShow) {
dialogToShow = String(dialogToShow).replace(/ /g, '\u00a0'); // 替换空格
}
const isConcat = getSentenceArgByKey(sentence, 'concat'); // 是否是继承语句
const isNotend = getSentenceArgByKey(sentence, 'notend') as boolean; // 是否有 notend 参数
const speaker = getSentenceArgByKey(sentence, 'speaker'); // 获取说话者
Expand Down
2 changes: 1 addition & 1 deletion packages/webgal/src/config/info.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const __INFO = {
version: 'WebGAL 4.5.8',
version: 'WebGAL 4.5.9',
contributors: [
// 现在改为跳转到 GitHub 了
],
Expand Down
17 changes: 16 additions & 1 deletion packages/webgal/src/store/stageReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,19 @@ const stageSlice = createSlice({
}
},
addPerform: (state, action: PayloadAction<IRunPerform>) => {
// 先检查是否有重复的,全部干掉
const dupPerformIndex = state.PerformList.findIndex((p) => p.id === action.payload.id);
if (dupPerformIndex > -1) {
const dupId = action.payload.id;
// 删除全部重复演出
for (let i = 0; i < state.PerformList.length; i++) {
const performItem: IRunPerform = state.PerformList[i];
if (performItem.id === dupId) {
state.PerformList.splice(i, 1);
i--;
}
}
}
state.PerformList.push(action.payload);
},
removePerformByName: (state, action: PayloadAction<string>) => {
Expand All @@ -135,6 +148,9 @@ const stageSlice = createSlice({
}
}
},
removeAllPerform: (state) => {
state.PerformList.splice(0, state.PerformList.length);
},
removeAllPixiPerforms: (state, action: PayloadAction<undefined>) => {
for (let i = 0; i < state.PerformList.length; i++) {
const performItem: IRunPerform = state.PerformList[i];
Expand Down Expand Up @@ -205,7 +221,6 @@ const stageSlice = createSlice({
if (action.payload[3]) {
if (state.figureMetaData[action.payload[0]]) delete state.figureMetaData[action.payload[0]];
} else {
console.log('yeah');
// 初始化对象
if (!state.figureMetaData[action.payload[0]]) {
state.figureMetaData[action.payload[0]] = {};
Expand Down
43 changes: 13 additions & 30 deletions releasenote.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,15 @@

#### 新功能

文本拓展语法对角色名称生效

模拟口型同步

允许修改 Live2D 绘制范围

允许设定立绘的 z-index
对话内容支持不间断的连续空格

#### 修复

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

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

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

<!-- English Translation -->
## Release Notes
Expand All @@ -35,21 +29,15 @@

#### New Features

Text extension syntax now affects character names

Simulate lip sync

Allow modification of Live2D drawing range

Allow setting the z-index of the character sprite
Dialogue content now supports continuous spaces.

#### Fixes

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

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

Optimized the performance of character sprite entry and exit effects
Deduplicated performance lists in the state table and performance controller upon insertion.

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

#### 新機能

テキスト拡張文法がキャラクタ名に有効になった

口パク同期

Live2D の描画範囲変更が可能になった

立ち絵の z-index 設定が可能になった
会話内容で連続するスペースが正しく表示されるようになりました。

#### 修正

テキスト拡張文法が先頭行に有効にならない問題を修正
セーブデータ読み込み時に、ステータステーブルに複数の演出記録が重複して保存される問題を修正しました。

IDを持つ効果音が停止した後、演出が完全にクリアされない問題を修正しました。

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

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