Skip to content

Commit

Permalink
Merge pull request #294 from MakinoharaShoko/dev
Browse files Browse the repository at this point in the history
4.4.0
  • Loading branch information
MakinoharaShoko authored Jul 3, 2023
2 parents 213daf8 + b90c130 commit 0f6ecdc
Show file tree
Hide file tree
Showing 129 changed files with 5,623 additions and 1,075 deletions.
27 changes: 27 additions & 0 deletions packages/parser/test/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,30 @@ test("choose", async () => {
};
expect(result.sentenceList).toContainEqual(expectSentenceItem);
});

test("long-script", async () => {

const sceneRaw = await fsp.readFile('test/test-resources/long-script.txt');
const sceneText = sceneRaw.toString();

const parser = new SceneParser((assetList) => {
}, (fileName, assetType) => {
return fileName;
}, ADD_NEXT_ARG_LIST, SCRIPT_CONFIG);

console.log('line count:',sceneText.split('\n').length)
console.time('parse-time-consumed')
const result = parser.parse(sceneText, "start", "/start.txt");
console.timeEnd('parse-time-consumed')
const expectSentenceItem: ISentence = {
command: commandType.label,
commandRaw: "label",
content: "end",
args: [
{ key: "next", value: true }
],
sentenceAssets: [],
subScene: []
};
expect(result.sentenceList).toContainEqual(expectSentenceItem);
});
3,672 changes: 3,672 additions & 0 deletions packages/parser/test/test-resources/long-script.txt

Large diffs are not rendered by default.

3 changes: 2 additions & 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.3.20",
"version": "4.4.0",
"scripts": {
"dev": "vite --host --port 3000",
"build": "cross-env NODE_ENV=production tsc && vite build --base=./",
Expand All @@ -20,6 +20,7 @@
"lodash": "^4.17.21",
"mitt": "^3.0.0",
"modern-css-reset": "^1.4.0",
"pixi-filters": "^4.2.0",
"pixi.js": "^6.3.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
Expand Down
2 changes: 1 addition & 1 deletion packages/webgal/public/game/animation/animationTable.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
["enter-from-left","enter-from-bottom","enter-from-right","shake","move-front-and-back","enter","exit","l2c","shake2"]
["enter-from-left","enter-from-bottom","enter-from-right","shake","move-front-and-back","enter","exit","l2c","shake2","blur","oldFilm","dotFilm","reflectionFilm","glitchFilm","rgbFilm","godrayFilm","removeFilm"]
10 changes: 10 additions & 0 deletions packages/webgal/public/game/animation/blur.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
{
"blur": 0,
"duration": 0
},
{
"blur": 5,
"duration": 300
}
]
6 changes: 6 additions & 0 deletions packages/webgal/public/game/animation/dotFilm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"dotFilm": 1,
"duration": 0
}
]
8 changes: 0 additions & 8 deletions packages/webgal/public/game/animation/enter-from-left.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
"x": 1,
"y": 1
},
"pivot": {
"x": 0.5,
"y": 0.5
},
"position": {
"x": -50,
"y": 0
Expand All @@ -23,10 +19,6 @@
"x": 1,
"y": 1
},
"pivot": {
"x": 0.5,
"y": 0.5
},
"position": {
"x": 0,
"y": 0
Expand Down
6 changes: 6 additions & 0 deletions packages/webgal/public/game/animation/glitchFilm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"glitchFilm": 1,
"duration": 0
}
]
6 changes: 6 additions & 0 deletions packages/webgal/public/game/animation/godrayFilm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"godrayFilm": 1,
"duration": 0
}
]
8 changes: 0 additions & 8 deletions packages/webgal/public/game/animation/l2c.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
"x": 1,
"y": 1
},
"pivot": {
"x": 0.5,
"y": 0.5
},
"position": {
"x": 0,
"y": 0
Expand All @@ -23,10 +19,6 @@
"x": 1,
"y": 1
},
"pivot": {
"x": 0.5,
"y": 0.5
},
"position": {
"x": 500,
"y": 0
Expand Down
6 changes: 6 additions & 0 deletions packages/webgal/public/game/animation/oldFilm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"oldFilm": 1,
"duration": 0
}
]
6 changes: 6 additions & 0 deletions packages/webgal/public/game/animation/reflectionFilm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"reflectionFilm": 1,
"duration": 0
}
]
11 changes: 11 additions & 0 deletions packages/webgal/public/game/animation/removeFilm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[
{
"oldFilm": 0,
"dotFilm": 0,
"reflectionFilm": 0,
"glitchFilm": 0,
"rgbFilm": 0,
"godrayFilm": 0,
"duration": 0
}
]
6 changes: 6 additions & 0 deletions packages/webgal/public/game/animation/rgbFilm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"rgbFilm": 1,
"duration": 0
}
]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/webgal/public/game/background/bg1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified packages/webgal/public/game/figure/stand.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions packages/webgal/public/game/scene/start.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
; 初始场景,以及特效演示
; WebGAL 引擎会默认读取 start.txt 作为初始场景,因此请不要删除,并在初始场景内跳转到其他场景
bgm:s_Title.mp3;
unlockBgm:s_Title.mp3 -name=雲を追いかけて;
intro:你好|欢迎来到 WebGAL 的世界;
changeBg:bg.png -next;
unlockCg:bg.png -name=良夜; // 解锁CG并赋予名称
changeFigure:stand.png -left -next;
setAnimation:enter-from-left -target=fig-left -next;
changeFigure:stand.png -left -enter=enter-from-left -next;
WebGAL:欢迎使用 WebGAL!这是一款全新的网页端视觉小说引擎。 -v1.wav;
changeFigure:stand2.png -right -next;
WebGAL 是使用 Web 技术开发的引擎,因此在网页端有良好的表现。 -v2.wav;
由于这个特性,如果你将 WebGAL 部署到服务器或网页托管平台上,玩家只需要一串链接就可以开始游玩! -v3.wav;
setAnimation:move-front-and-back -target=fig-left -next;
听起来是不是非常吸引人? -v4.wav;
changeFigure:none -right -next;
setAnimation:l2c -target=fig-left -next;
Expand Down
39 changes: 15 additions & 24 deletions packages/webgal/src/Components/Stage/MainStage/useSetBg.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import { IStageState } from '@/store/stageInterface';
import { useEffect } from 'react';
import { RUNTIME_GAMEPLAY } from '@/Core/runtime/gamePlay';
import { logger } from '@/Core/util/etc/logger';
import { IStageObject } from '@/Core/controller/stage/pixi/PixiController';
import { generateUniversalSoftOffAnimationObj } from '@/Core/controller/stage/pixi/animations/universalSoftOff';
import { generateUniversalSoftInAnimationObj } from '@/Core/controller/stage/pixi/animations/universalSoftIn';
import { setEbg } from '@/Core/util/setEbg';
import { WebGAL } from '@/main';
import { getEnterExitAnimation } from '@/Core/Modules/animations';

export function useSetBg(stageState: IStageState) {
const bgName = stageState.bgName;
Expand All @@ -16,25 +15,20 @@ export function useSetBg(stageState: IStageState) {
useEffect(() => {
const thisBgKey = 'bg-main';
if (bgName !== '') {
const currentBg = RUNTIME_GAMEPLAY.pixiStage?.getStageObjByKey(thisBgKey);
const currentBg = WebGAL.gameplay.pixiStage?.getStageObjByKey(thisBgKey);
if (currentBg) {
if (currentBg.sourceUrl !== bgName) {
removeBg(currentBg);
}
}
RUNTIME_GAMEPLAY.pixiStage?.addBg(thisBgKey, bgName);
WebGAL.gameplay.pixiStage?.addBg(thisBgKey, bgName);
setEbg(bgName);
logger.debug('重设背景');
// 走默认动画
RUNTIME_GAMEPLAY.pixiStage!.registerPresetAnimation(
generateUniversalSoftInAnimationObj(thisBgKey, 1000),
'bg-main-softin',
thisBgKey,
stageState.effects,
);
setTimeout(() => RUNTIME_GAMEPLAY.pixiStage!.removeAnimation('bg-main-softin'), 1000);
const { duration, animation } = getEnterExitAnimation('bg-main-off', 'enter');
WebGAL.gameplay.pixiStage!.registerPresetAnimation(animation, 'bg-main-softin', thisBgKey, stageState.effects);
setTimeout(() => WebGAL.gameplay.pixiStage!.removeAnimationWithSetEffects('bg-main-softin'), duration);
} else {
const currentBg = RUNTIME_GAMEPLAY.pixiStage?.getStageObjByKey(thisBgKey);
const currentBg = WebGAL.gameplay.pixiStage?.getStageObjByKey(thisBgKey);
if (currentBg) {
removeBg(currentBg);
}
Expand All @@ -43,17 +37,14 @@ export function useSetBg(stageState: IStageState) {
}

function removeBg(bgObject: IStageObject) {
RUNTIME_GAMEPLAY.pixiStage?.removeAnimationWithSetEffects('bg-main-softin');
WebGAL.gameplay.pixiStage?.removeAnimationWithSetEffects('bg-main-softin');
const oldBgKey = bgObject.key;
bgObject.key = 'bg-main-off';
RUNTIME_GAMEPLAY.pixiStage?.removeStageObjectByKey(oldBgKey);
RUNTIME_GAMEPLAY.pixiStage!.registerAnimation(
generateUniversalSoftOffAnimationObj('bg-main-off', 1000),
'bg-main-softoff',
'bg-main-off',
);
WebGAL.gameplay.pixiStage?.removeStageObjectByKey(oldBgKey);
const { duration, animation } = getEnterExitAnimation('bg-main-off', 'exit');
WebGAL.gameplay.pixiStage!.registerAnimation(animation, 'bg-main-softoff', 'bg-main-off');
setTimeout(() => {
RUNTIME_GAMEPLAY.pixiStage?.removeAnimation('bg-main-softoff');
RUNTIME_GAMEPLAY.pixiStage?.removeStageObjectByKey('bg-main-off');
}, 1000);
WebGAL.gameplay.pixiStage?.removeAnimation('bg-main-softoff');
WebGAL.gameplay.pixiStage?.removeStageObjectByKey('bg-main-off');
}, duration);
}
28 changes: 16 additions & 12 deletions packages/webgal/src/Components/Stage/MainStage/useSetEffects.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { RUNTIME_GAMEPLAY } from '@/Core/runtime/gamePlay';
import { baseTransform, IEffect, IStageState } from '@/store/stageInterface';
// import { logger } from '@/Core/util/etc/logger';
import { setBlurFilter } from '@/Core/util/etc/setBlurFilter';
import { baseTransform, IEffect, IStageState, ITransform } from '@/store/stageInterface';
import { WebGAL } from '@/main';

export function setStageObjectEffects(stageState: IStageState) {
const effects = stageState.effects;
Expand All @@ -11,28 +9,34 @@ export function setStageObjectEffects(stageState: IStageState) {
}

export function setStageEffects(effects: IEffect[]) {
const stageObjects = RUNTIME_GAMEPLAY.pixiStage?.getAllStageObj() ?? [];
const stageObjects = WebGAL.gameplay.pixiStage?.getAllStageObj() ?? [];
for (const stageObj of stageObjects) {
const key = stageObj.key;
const effect = effects.find((effect) => effect.target === key);
const lockedStageTargets = RUNTIME_GAMEPLAY.pixiStage?.getAllLockedObject() ?? [];
const lockedStageTargets = WebGAL.gameplay.pixiStage?.getAllLockedObject() ?? [];
if (!lockedStageTargets.includes(key)) {
if (effect) {
// logger.debug('应用effects', key);
const targetPixiContainer = RUNTIME_GAMEPLAY.pixiStage?.getStageObjByKey(key);
const targetPixiContainer = WebGAL.gameplay.pixiStage?.getStageObjByKey(key);
if (targetPixiContainer) {
const container = targetPixiContainer.pixiContainer;
setBlurFilter(container);
Object.assign(container, effect.transform);
Object.assign(container, convertTransform(effect.transform));
}
} else {
const targetPixiContainer = RUNTIME_GAMEPLAY.pixiStage?.getStageObjByKey(key);
const targetPixiContainer = WebGAL.gameplay.pixiStage?.getStageObjByKey(key);
if (targetPixiContainer) {
const container = targetPixiContainer.pixiContainer;
setBlurFilter(container);
Object.assign(container, baseTransform);
Object.assign(container, convertTransform(baseTransform));
}
}
}
}
}

function convertTransform(transform: ITransform | undefined) {
if (!transform) {
return {};
}
const { position, pivot, ...rest } = transform;
return { ...rest, x: position.x, y: position.y };
}
Loading

0 comments on commit 0f6ecdc

Please sign in to comment.