diff --git a/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx b/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx index 4490a6e5c..58194f5aa 100644 --- a/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx +++ b/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx @@ -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 { @@ -185,7 +187,11 @@ 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 textLineHeight = userDataState.globalGameVar.LineHeight; + const finalTextLineHeight = textLineHeight ? Number(textLineHeight) : lineHeightValue; + const lineHeightCssStr = `line-height: ${finalTextLineHeight}em`; const lhCss = css(lineHeightCssStr); return ( diff --git a/packages/webgal/src/Stage/TextBox/TextBox.tsx b/packages/webgal/src/Stage/TextBox/TextBox.tsx index 1265983e1..dea485b2d 100644 --- a/packages/webgal/src/Stage/TextBox/TextBox.tsx +++ b/packages/webgal/src/Stage/TextBox/TextBox.tsx @@ -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 !== '';