From a428c0330d87a9e57f6d6e069035daa2c6db0315 Mon Sep 17 00:00:00 2001 From: Mahiru Date: Sun, 21 Jan 2024 23:12:37 +0800 Subject: [PATCH 1/5] add command receive from terre --- .../webgal/src/Core/util/syncWithEditor/webSocketFunc.ts | 9 +++++++++ packages/webgal/src/types/debugProtocol.ts | 3 +++ 2 files changed, 12 insertions(+) diff --git a/packages/webgal/src/Core/util/syncWithEditor/webSocketFunc.ts b/packages/webgal/src/Core/util/syncWithEditor/webSocketFunc.ts index c9c7a590..25b54a12 100644 --- a/packages/webgal/src/Core/util/syncWithEditor/webSocketFunc.ts +++ b/packages/webgal/src/Core/util/syncWithEditor/webSocketFunc.ts @@ -3,6 +3,8 @@ import { syncWithOrigine } from '@/Core/util/syncWithEditor/syncWithOrigine'; import { DebugCommand, IDebugMessage } from '@/types/debugProtocol'; import { WebGAL } from '@/Core/WebGAL'; import { webgalStore } from '@/store/store'; +import { WebgalParser } from '@/Core/parser/sceneParser'; +import { runScript } from '@/Core/controller/gamePlay/runScript'; export const webSocketFunc = () => { const loc: string = window.location.hostname; @@ -26,6 +28,7 @@ export const webSocketFunc = () => { sentence: WebGAL.sceneManager.sceneData.currentSentenceId, }, stageSyncMsg: webgalStore.getState().stage, + message: 'sync', }; socket.send(JSON.stringify(message)); // logger.debug('传送信息', message); @@ -40,6 +43,12 @@ export const webSocketFunc = () => { if (message.command === DebugCommand.JUMP) { syncWithOrigine(message.sceneMsg.scene, message.sceneMsg.sentence); } + if (message.command === DebugCommand.EXE_COMMAND) { + const command = message.message; + const scene = WebgalParser.parse(command, 'temp.txt', 'temp.txt'); + const sentence = scene.sentenceList[0]; + runScript(sentence); + } }; socket.onerror = (e) => { logger.info('当前没有连接到 Terre 编辑器'); diff --git a/packages/webgal/src/types/debugProtocol.ts b/packages/webgal/src/types/debugProtocol.ts index 50b66de8..1e8a69ac 100644 --- a/packages/webgal/src/types/debugProtocol.ts +++ b/packages/webgal/src/types/debugProtocol.ts @@ -7,6 +7,8 @@ export enum DebugCommand { SYNCFC, // 同步自编辑器 SYNCFE, + // 执行指令 + EXE_COMMAND, } export interface IDebugMessage { @@ -15,5 +17,6 @@ export interface IDebugMessage { sentence: number; scene: string; }; + message: string; stageSyncMsg: IStageState; } From af6c819d5f58289a94a1240384ce8885b6ac45d5 Mon Sep 17 00:00:00 2001 From: Mahiru Date: Wed, 24 Jan 2024 21:45:30 +0800 Subject: [PATCH 2/5] feat: enhance performance of backlog --- packages/webgal/src/UI/Backlog/Backlog.tsx | 32 ++++++++++++++++++++-- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/packages/webgal/src/UI/Backlog/Backlog.tsx b/packages/webgal/src/UI/Backlog/Backlog.tsx index f7436e29..48fd89d6 100644 --- a/packages/webgal/src/UI/Backlog/Backlog.tsx +++ b/packages/webgal/src/UI/Backlog/Backlog.tsx @@ -5,7 +5,7 @@ import { useDispatch, useSelector } from 'react-redux'; import { RootState, webgalStore } from '@/store/store'; import { setVisibility } from '@/store/GUIReducer'; import { logger } from '@/Core/util/logger'; -import { useEffect, useMemo, useRef, useState } from 'react'; +import { ReactNode, useEffect, useMemo, useRef, useState } from 'react'; import useTrans from '@/hooks/useTrans'; import { compileSentence, splitChars } from '@/Stage/TextBox/TextBox'; import useSoundEffect from '@/hooks/useSoundEffect'; @@ -27,9 +27,9 @@ export const Backlog = () => { // logger.info('backlogList render'); for (let i = 0; i < WebGAL.backlogManager.getBacklog().length; i++) { const backlogItem = WebGAL.backlogManager.getBacklog()[i]; - // const showTextArray = splitChars(backlogItem.currentStageState.showText.replaceAll(/[\[\]]/g, '')); const showTextArray = compileSentence(backlogItem.currentStageState.showText, 3, true); - const showTextElementList = showTextArray.map((e, index) => { + const showTextArrayReduced = mergeStringsAndKeepObjects(showTextArray); + const showTextElementList = showTextArrayReduced.map((e, index) => { if (e === '
') { return
; } else { @@ -165,3 +165,29 @@ export const Backlog = () => { ); }; + +function mergeStringsAndKeepObjects(arr: ReactNode[]) { + let result = []; + let currentString = ''; + + // eslint-disable-next-line @typescript-eslint/prefer-for-of + for (let i = 0; i < arr.length; i++) { + const currentItem = arr[i]; + + if (typeof currentItem === 'string') { + currentString += currentItem; + } else { + if (currentString !== '') { + result.push(currentString); + currentString = ''; + } + result.push(currentItem); + } + } + + if (currentString !== '') { + result.push(currentString); + } + + return result; +} From dd8c8f585d1cf434ebe76a76f08c2af6e4f87b33 Mon Sep 17 00:00:00 2001 From: Mahiru Date: Sat, 27 Jan 2024 15:58:34 +0800 Subject: [PATCH 3/5] fix: iOS resize problem --- packages/webgal/index.html | 391 +++++++++++++++++++------------------ 1 file changed, 203 insertions(+), 188 deletions(-) diff --git a/packages/webgal/index.html b/packages/webgal/index.html index ffbd40bb..85232d95 100644 --- a/packages/webgal/index.html +++ b/packages/webgal/index.html @@ -7,13 +7,12 @@ WebGAL - + - -
-
+
- -
- -
- -
-
-
- PRESS THE SCREEN TO START + PRESS THE SCREEN TO START +
-
-
-
- Powered by WebGAL Framework -
-
- Made with ❤ by Mahiru +
+ Powered by WebGAL Framework +
+
+ Made with ❤ by Mahiru +
- -
-
- - - - - - - + + + + + + + setTimeout(() => { + if (title) { + title.style.display = "none"; + } + }, 2000); // 将落地页设置为不显示 + window.enterPromise(); + delete window.enterPromise; + } + - + + \ No newline at end of file From 4b85267b039b22eafb5e9808012ebaa907b406ca Mon Sep 17 00:00:00 2001 From: Mahiru Date: Sat, 27 Jan 2024 23:08:00 +0800 Subject: [PATCH 4/5] fix: timeline func problem of scale and transform --- .../stage/pixi/animations/timeline.ts | 35 +++++++++++++++---- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/packages/webgal/src/Core/controller/stage/pixi/animations/timeline.ts b/packages/webgal/src/Core/controller/stage/pixi/animations/timeline.ts index 21741707..377db8ef 100644 --- a/packages/webgal/src/Core/controller/stage/pixi/animations/timeline.ts +++ b/packages/webgal/src/Core/controller/stage/pixi/animations/timeline.ts @@ -3,6 +3,8 @@ import { animate } from 'popmotion'; import { WebGAL } from '@/Core/WebGAL'; import { webgalStore } from '@/store/store'; import { stageActions } from '@/store/stageReducer'; +import omitBy from 'lodash/omitBy'; +import isUndefined from 'lodash/isUndefined'; /** * 动画创建模板 @@ -40,10 +42,10 @@ export function generateTimelineObj( onUpdate: (updateValue) => { if (container) { const { scaleX, scaleY, ...val } = updateValue; - Object.assign(container, val); + Object.assign(container, omitBy(val, isUndefined)); // 因为 popmotion 不能用嵌套,scale 要手动设置 - container.scale.x = scaleX; - container.scale.y = scaleY; + if (!isUndefined(scaleX)) container.scale.x = scaleX; + if (!isUndefined(scaleY)) container.scale.y = scaleY; } }, }); @@ -58,8 +60,17 @@ export function generateTimelineObj( function setStartState() { if (target?.pixiContainer) { // 不能赋值到 position,因为 x 和 y 被 WebGALPixiContainer 代理,而 position 属性没有代理 - const { position, ...state } = getStartStateEffect(); - Object.assign(target?.pixiContainer, { x: position.x, y: position.y, ...state }); + const { position, scale, ...state } = getStartStateEffect(); + const assignValue = omitBy({ x: position.x, y: position.y, ...state }, isUndefined); + Object.assign(target?.pixiContainer, assignValue); + if (target?.pixiContainer) { + if (!isUndefined(scale.x)) { + target.pixiContainer.scale.x = scale.x; + } + if (!isUndefined(scale?.y)) { + target.pixiContainer.scale.y = scale.y; + } + } } } @@ -71,8 +82,18 @@ export function generateTimelineObj( animateInstance = null; if (target?.pixiContainer) { // 不能赋值到 position,因为 x 和 y 被 WebGALPixiContainer 代理,而 position 属性没有代理 - const { position, ...state } = getEndStateEffect(); - Object.assign(target?.pixiContainer, { x: position.x, y: position.y, ...state }); + // 不能赋值到 position,因为 x 和 y 被 WebGALPixiContainer 代理,而 position 属性没有代理 + const { position, scale, ...state } = getEndStateEffect(); + const assignValue = omitBy({ x: position.x, y: position.y, ...state }, isUndefined); + Object.assign(target?.pixiContainer, assignValue); + if (target?.pixiContainer) { + if (!isUndefined(scale.x)) { + target.pixiContainer.scale.x = scale.x; + } + if (!isUndefined(scale?.y)) { + target.pixiContainer.scale.y = scale.y; + } + } } } From 6136809f90f08009712eedfe5fa0d545c5c36481 Mon Sep 17 00:00:00 2001 From: Mahiru Date: Sat, 27 Jan 2024 23:12:18 +0800 Subject: [PATCH 5/5] update version --- packages/webgal/package.json | 2 +- packages/webgal/src/config/info.ts | 2 +- releasenote.md | 56 +++++++++--------------------- 3 files changed, 18 insertions(+), 42 deletions(-) diff --git a/packages/webgal/package.json b/packages/webgal/package.json index e7115d37..4edd6214 100644 --- a/packages/webgal/package.json +++ b/packages/webgal/package.json @@ -1,7 +1,7 @@ { "name": "webgal", "private": true, - "version": "4.4.10", + "version": "4.4.11", "scripts": { "dev": "vite --host --port 3000", "build": "cross-env NODE_ENV=production tsc && vite build --base=./", diff --git a/packages/webgal/src/config/info.ts b/packages/webgal/src/config/info.ts index ce5588b2..6ea1c90c 100644 --- a/packages/webgal/src/config/info.ts +++ b/packages/webgal/src/config/info.ts @@ -1,5 +1,5 @@ export const __INFO = { - version: 'WebGAL 4.4.10', + version: 'WebGAL 4.4.11', contributors: [ { username: 'Mahiru', link: 'https://github.com/MakinoharaShoko' }, { username: 'Hoshinokinya', link: 'https://github.com/hshqwq' }, diff --git a/releasenote.md b/releasenote.md index dc168eb8..73a34777 100644 --- a/releasenote.md +++ b/releasenote.md @@ -8,21 +8,15 @@ #### 新功能 -可以根据变量来控制选择肢显隐和是否可以点击 - -添加水波纹滤镜 - -`intro` 可以设置是否在结束时关闭 - -更换系统音效,使其更加通用 +从编辑器接受指令 #### 修复 -优化控制按钮自动消失的逻辑 +小幅改善 iOS 设备的崩溃状况 -修复相同文件名图像同时加载时冲突的异常 +优化 Backlog 性能 -更换动画库 +修复动画模块异常 ## Release Notes @@ -35,21 +29,15 @@ #### New Features -Choices can be shown/hidden and clickable based on variables - -Added ripple filter - -`intro` can be set to not close after it finishes - -Replaced system sound effects to be more versatile +Accept commands from editor #### Fixes -Optimized the logic for auto-hiding control buttons +Slightly improve crash situation on iOS devices -Fixed an exception when images with the same file name are loaded at the same time +Optimize Backlog performance -Changed the animation library +Fix abnormal animation module @@ -63,21 +51,15 @@ Changed the animation library #### 新機能 -変数によって選択肢の表示・非表示やクリック可能かどうかを制御可能に - -水波紋フィルターを追加 - -introは終了時に閉じるかどうかを設定可能に - -システム効果音を変更し、より汎用的に +エディタからの指示を受け付ける #### 修正 -コントロールボタンの自動消去のロジックを最適化 +iOS デバイスでのクラッシュを若干改善 -同じファイル名の画像が同時にロードされたときの競合の異常を修正 +Backlog のパフォーマンスを最適化 -アニメーションライブラリを変更 +アニメーションモジュールの異常を修正 @@ -91,19 +73,13 @@ introは終了時に閉じるかどうかを設定可能に #### Nouvelles fonctionnalités -Possibilité de contrôler l'affichage et la sélection des choix en fonction des variables - -Ajout d'un filtre d'ondulation - -`intro` peut être configuré pour se fermer ou non à la fin - -Remplacement des sons système pour les rendre plus universels +Recevoir des instructions de l'éditeur #### Corrections -Optimisation de la logique de disparition automatique des boutons de contrôle +Amélioration mineure des plantages sur les appareils iOS -Correction de l'exception de conflit lors du chargement simultané d'images portant le même nom +Optimisation des performances de Backlog -Remplacement de la bibliothèque d'animations +Correction d'un bug dans le module d'animation