From a90eca2067824dcdc06128b35cd7bd79698baed2 Mon Sep 17 00:00:00 2001 From: labiker Date: Sat, 23 Sep 2023 09:38:38 +0900 Subject: [PATCH 01/29] Made it possible to use variables for `speaker` in `say` statements. --- .../Core/controller/gamePlay/scriptExecutor.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/webgal/src/Core/controller/gamePlay/scriptExecutor.ts b/packages/webgal/src/Core/controller/gamePlay/scriptExecutor.ts index ea332604a..6a0b68a60 100644 --- a/packages/webgal/src/Core/controller/gamePlay/scriptExecutor.ts +++ b/packages/webgal/src/Core/controller/gamePlay/scriptExecutor.ts @@ -12,6 +12,7 @@ import { ISceneEntry } from '@/Core/Modules/scene'; import { IBacklogItem } from '@/Core/Modules/backlog'; import { SYSTEM_CONFIG } from '@/Core/config/config'; import { WebGAL } from '@/Core/WebGAL'; +import { getSentenceArgByKey } from '@/Core/util/getSentenceArg'; /** * 语句执行器 @@ -59,6 +60,21 @@ export const scriptExecutor = () => { .reduce((pre, curr) => pre + curr, ''); runThis = strIf(valExp); } + + // 如果语句类型为 'say', + // 则检查是否有 'speaker' 参数和对应的变量,如果有,则替换为变量。 + if (currentScript.command === commandType.say) { + const speaker = getSentenceArgByKey(currentScript, 'speaker') as string; + const gameVar = getValueFromState(speaker).toString(); + if (gameVar !== '0') { + currentScript.args.forEach((e) => { + if (e.key === 'speaker') { + e.value = gameVar; + } + }); + } + } + // 执行语句 if (!runThis) { logger.warn('不满足条件,跳过本句!'); From 732a40b8d3135f373db2ed225691706b01827391 Mon Sep 17 00:00:00 2001 From: YujiSakai Date: Thu, 12 Oct 2023 18:45:30 +0900 Subject: [PATCH 02/29] function add --- .../webgal/src/Core/gameScripts/playVideo.tsx | 83 ++++++++++++++++--- 1 file changed, 73 insertions(+), 10 deletions(-) diff --git a/packages/webgal/src/Core/gameScripts/playVideo.tsx b/packages/webgal/src/Core/gameScripts/playVideo.tsx index 402d87790..3f0914f03 100644 --- a/packages/webgal/src/Core/gameScripts/playVideo.tsx +++ b/packages/webgal/src/Core/gameScripts/playVideo.tsx @@ -6,18 +6,59 @@ import styles from '../../Components/Stage/FullScreenPerform/fullScreenPerform.m import { webgalStore } from '@/store/store'; import { nextSentence } from '@/Core/controller/gamePlay/nextSentence'; import { getRandomPerformName, PerformController } from '@/Core/Modules/perform/performController'; - +import { getSentenceArgByKey } from '@/Core/util/getSentenceArg'; import { WebGAL } from '@/Core/WebGAL'; - /** - * 播放一段视频 - * @param sentence + * 播放一段视频 * @param sentence */ export const playVideo = (sentence: ISentence): IPerform => { + const userDataState = webgalStore.getState().userData; + const mainVol = userDataState.optionData.volumeMain; + const vocalVol = mainVol * 0.01 * userDataState.optionData.vocalVolume * 0.01; + const bgmVol = mainVol * 0.01 * userDataState.optionData.bgmVolume * 0.01; + + // 防止左键单击直到视频结束 + const fullScreenClickElement = document.getElementById('FullScreenClick'); + if (fullScreenClickElement) { + fullScreenClickElement.style.pointerEvents = 'none'; + } + const performInitName: string = getRandomPerformName(); + + let blockRightClick = (e: MouseEvent) => { + e.preventDefault(); + e.stopPropagation(); + return false; + } + + function disableRightClick() { + document.addEventListener('contextmenu', blockRightClick, true); + } + + function enableRightClick() { + document.removeEventListener('contextmenu', blockRightClick, true); + } + + function simulateRightClick(element: HTMLElement) { + const mouseEvent = new MouseEvent('contextmenu', { + bubbles: true, + cancelable: true, + view: window, + button: 2, + buttons: 2, + clientX: element.getBoundingClientRect().left, + clientY: element.getBoundingClientRect().top + }); + element.dispatchEvent(mouseEvent); + } + + // 右键单击一次,隐藏菜单,然后禁用右键单击 + simulateRightClick(document.body); + disableRightClick(); + ReactDOM.render(
-
, document.getElementById('videoContainer'), ); @@ -38,6 +79,17 @@ export const playVideo = (sentence: ISentence): IPerform => { let VocalControl: any = document.getElementById('playVideoElement'); if (VocalControl !== null) { VocalControl.currentTime = 0; + VocalControl.volume = bgmVol; + const skipVideo = () => { + if (VocalControl) { + VocalControl.currentTime = VocalControl.duration; + } + }; + // 双击可跳过视频 + const videoElement = document.getElementById('playVideoElement'); + if (videoElement) { + videoElement.addEventListener('dblclick', skipVideo); + } // 播放并作为一个特别演出加入 const perform = { performName: performInitName, @@ -52,10 +104,6 @@ export const playVideo = (sentence: ISentence): IPerform => { /** * 恢复音量 */ - const userDataState = webgalStore.getState().userData; - const mainVol = userDataState.optionData.volumeMain; - const vocalVol = mainVol * 0.01 * userDataState.optionData.vocalVolume * 0.01; - const bgmVol = mainVol * 0.01 * userDataState.optionData.bgmVolume * 0.01; const bgmElement: any = document.getElementById('currentBgm'); if (bgmElement) { bgmElement.volume = bgmVol.toString(); @@ -101,8 +149,23 @@ export const playVideo = (sentence: ISentence): IPerform => { } } }; + + // 防止左键单击直到视频结束 + VocalControl.addEventListener('timeupdate', function() { + if (VocalControl.currentTime >= VocalControl.duration) { + const fullScreenClickElement = document.getElementById('FullScreenClick'); + if (fullScreenClickElement) { + + // 允许右键单击并右键单击一次显示菜单 + enableRightClick(); + simulateRightClick(document.body); + + fullScreenClickElement.style.removeProperty('pointer-events'); + } + } + }); } }, 1); }), }; -}; +}; \ No newline at end of file From 4c26719a92241e80d4abdbd9e19d09a20e511348 Mon Sep 17 00:00:00 2001 From: Mahiru Date: Sat, 21 Oct 2023 13:41:04 +0800 Subject: [PATCH 03/29] fix: l2d --- packages/webgal/index.html | 4 ++-- .../webgal/src/Components/Stage/MainStage/useSetFigure.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/webgal/index.html b/packages/webgal/index.html index cf2a219b6..ffbd40bb9 100644 --- a/packages/webgal/index.html +++ b/packages/webgal/index.html @@ -199,8 +199,8 @@ - - + +