Skip to content

Commit

Permalink
Merge pull request #454 from OpenWebGAL/dev
Browse files Browse the repository at this point in the history
4.4.11
  • Loading branch information
MakinoharaShoko committed Jan 27, 2024
2 parents fb2cef0 + 6136809 commit 322df19
Show file tree
Hide file tree
Showing 8 changed files with 290 additions and 240 deletions.
391 changes: 203 additions & 188 deletions packages/webgal/index.html

Large diffs are not rendered by default.

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.4.10",
"version": "4.4.11",
"scripts": {
"dev": "vite --host --port 3000",
"build": "cross-env NODE_ENV=production tsc && vite build --base=./",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

/**
* 动画创建模板
Expand Down Expand Up @@ -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;
}
},
});
Expand All @@ -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;
}
}
}
}

Expand All @@ -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;
}
}
}
}

Expand Down
9 changes: 9 additions & 0 deletions packages/webgal/src/Core/util/syncWithEditor/webSocketFunc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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 编辑器');
Expand Down
32 changes: 29 additions & 3 deletions packages/webgal/src/UI/Backlog/Backlog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 === '<br />') {
return <br key={`br${index}`} />;
} else {
Expand Down Expand Up @@ -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;
}
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.4.10',
version: 'WebGAL 4.4.11',
contributors: [
{ username: 'Mahiru', link: 'https://github.com/MakinoharaShoko' },
{ username: 'Hoshinokinya', link: 'https://github.com/hshqwq' },
Expand Down
3 changes: 3 additions & 0 deletions packages/webgal/src/types/debugProtocol.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export enum DebugCommand {
SYNCFC,
// 同步自编辑器
SYNCFE,
// 执行指令
EXE_COMMAND,
}

export interface IDebugMessage {
Expand All @@ -15,5 +17,6 @@ export interface IDebugMessage {
sentence: number;
scene: string;
};
message: string;
stageSyncMsg: IStageState;
}
56 changes: 16 additions & 40 deletions releasenote.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,15 @@

#### 新功能

可以根据变量来控制选择肢显隐和是否可以点击

添加水波纹滤镜

`intro` 可以设置是否在结束时关闭

更换系统音效,使其更加通用
从编辑器接受指令

#### 修复

优化控制按钮自动消失的逻辑
小幅改善 iOS 设备的崩溃状况

修复相同文件名图像同时加载时冲突的异常
优化 Backlog 性能

更换动画库
修复动画模块异常

<!-- English Translation -->
## Release Notes
Expand All @@ -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


<!-- Japanese Translation -->
Expand All @@ -63,21 +51,15 @@ Changed the animation library

#### 新機能

変数によって選択肢の表示・非表示やクリック可能かどうかを制御可能に

水波紋フィルターを追加

introは終了時に閉じるかどうかを設定可能に

システム効果音を変更し、より汎用的に
エディタからの指示を受け付ける

#### 修正

コントロールボタンの自動消去のロジックを最適化
iOS デバイスでのクラッシュを若干改善

同じファイル名の画像が同時にロードされたときの競合の異常を修正
Backlog のパフォーマンスを最適化

アニメーションライブラリを変更
アニメーションモジュールの異常を修正


<!-- French Translation -->
Expand All @@ -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

0 comments on commit 322df19

Please sign in to comment.