File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed
packages/webgal/src/Stage/TextBox Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change 11import styles from './textbox.module.scss' ;
2- import { ReactNode , useEffect } from 'react' ;
2+ import { useEffect } from 'react' ;
33import { WebGAL } from '@/Core/WebGAL' ;
44import { ITextboxProps } from './types' ;
55import useApplyStyle from '@/hooks/useApplyStyle' ;
66import { css } from '@emotion/css' ;
77import { textSize } from '@/store/userDataInterface' ;
8+ import { useSelector } from 'react-redux' ;
9+ import { RootState } from '@/store/store' ;
810
911export default function IMSSTextbox ( props : ITextboxProps ) {
1012 const {
@@ -185,7 +187,11 @@ export default function IMSSTextbox(props: ITextboxProps) {
185187 ) ;
186188 } ) ;
187189
188- const lineHeightCssStr = `line-height: ${ textSizeState === textSize . medium ? '2.2em' : '2em' } ` ;
190+ const userDataState = useSelector ( ( state : RootState ) => state . userData ) ;
191+ const lineHeightValue = textSizeState === textSize . medium ? 2.2 : 2 ;
192+ const textLineHeight = userDataState . globalGameVar . LineHeight ;
193+ const finalTextLineHeight = textLineHeight ? Number ( textLineHeight ) : lineHeightValue ;
194+ const lineHeightCssStr = `line-height: ${ finalTextLineHeight } em` ;
189195 const lhCss = css ( lineHeightCssStr ) ;
190196
191197 return (
Original file line number Diff line number Diff line change @@ -33,11 +33,14 @@ export const TextBox = () => {
3333 size = getTextSize ( stageState . showTextSize ) + '%' ;
3434 textSizeState = stageState . showTextSize ;
3535 }
36- const lineLimit = match ( textSizeState )
37- . with ( textSize . small , ( ) => 3 )
38- . with ( textSize . medium , ( ) => 2 )
39- . with ( textSize . large , ( ) => 2 )
40- . default ( ( ) => 2 ) ;
36+ const MaxTextLine = Number ( userDataState . globalGameVar . Max_line ) ; // congfig定义字体行数
37+ const lineLimit = Number . isNaN ( MaxTextLine )
38+ ? match ( textSizeState )
39+ . with ( textSize . small , ( ) => 3 )
40+ . with ( textSize . medium , ( ) => 2 )
41+ . with ( textSize . large , ( ) => 2 )
42+ . default ( ( ) => 2 )
43+ : MaxTextLine ;
4144 // 拆字
4245 const textArray = compileSentence ( stageState . showText , lineLimit ) ;
4346 const isHasName = stageState . showName !== '' ;
You can’t perform that action at this time.
0 commit comments