Skip to content
Open
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: 2 additions & 0 deletions packages/webgal/public/game/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ Title_img:WebGAL_New_Enter_Image.webp;
Title_bgm:s_Title.mp3;
Game_Logo:WebGalEnter.webp;
Enable_Appreciation:true;
Max_line:4;
Max_lineHeight:0.25;
1 change: 1 addition & 0 deletions packages/webgal/public/game/scene/demo_max_line_test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
WebGAL:我是第一行文本|我是第二行哈哈|第三行在这里|第四行是这个内容;
2 changes: 1 addition & 1 deletion packages/webgal/public/game/scene/start.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
setVar:heroine=WebGAL;
setVar:egine=WebGAL;
choose:简体中文:demo_zh_cn.txt|日本語:demo_ja.txt|English:demo_en.txt|Test:function_test.txt;
choose:多行测试:demo_max_line_test.txt|简体中文:demo_zh_cn.txt|日本語:demo_ja.txt|English:demo_en.txt|Test:function_test.txt;
14 changes: 12 additions & 2 deletions packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import styles from './textbox.module.scss';
import { ReactNode, useEffect } from 'react';
import { useEffect } from 'react';
import { WebGAL } from '@/Core/WebGAL';
import { ITextboxProps } from './types';
import useApplyStyle from '@/hooks/useApplyStyle';
import { css } from '@emotion/css';
import { textSize } from '@/store/userDataInterface';
import { useSelector } from 'react-redux';
import { RootState } from '@/store/store';

export default function IMSSTextbox(props: ITextboxProps) {
const {
Expand Down Expand Up @@ -185,7 +187,15 @@ export default function IMSSTextbox(props: ITextboxProps) {
);
});

const lineHeightCssStr = `line-height: ${textSizeState === textSize.medium ? '2.2em' : '2em'}`;
const userDataState = useSelector((state: RootState) => state.userData);
const lineHeightValue = textSizeState === textSize.medium ? 2.2 : 2;
const MaxTextLine = Number(userDataState.globalGameVar.Max_line); // config定义字体行数
const MaxTextLineHeight = Number(userDataState.globalGameVar.Max_lineHeight); // config 定义字体行数高度
const finalLineHeight = !Number.isNaN(MaxTextLine)
? (Number.isNaN(MaxTextLineHeight) ? lineHeightValue : MaxTextLineHeight) * MaxTextLine
: lineHeightValue; // Max_LineHeight和Max_Line必定为数字,否则使用默认值

const lineHeightCssStr = `line-height: ${finalLineHeight}em`;
const lhCss = css(lineHeightCssStr);

return (
Expand Down
13 changes: 8 additions & 5 deletions packages/webgal/src/Stage/TextBox/TextBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ export const TextBox = () => {
size = getTextSize(stageState.showTextSize) + '%';
textSizeState = stageState.showTextSize;
}
const lineLimit = match(textSizeState)
.with(textSize.small, () => 3)
.with(textSize.medium, () => 2)
.with(textSize.large, () => 2)
.default(() => 2);
const MaxTextLine = Number(userDataState.globalGameVar.Max_line); // congfig定义字体行数
const lineLimit = Number.isNaN(MaxTextLine)
? match(textSizeState)
.with(textSize.small, () => 3)
.with(textSize.medium, () => 2)
.with(textSize.large, () => 2)
.default(() => 2)
: MaxTextLine;
// 拆字
const textArray = compileSentence(stageState.showText, lineLimit);
const isHasName = stageState.showName !== '';
Expand Down