File tree Expand file tree Collapse file tree 5 files changed +24
-8
lines changed
Expand file tree Collapse file tree 5 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -4,3 +4,5 @@ Title_img:WebGAL_New_Enter_Image.webp;
44Title_bgm:s_Title.mp3;
55Game_Logo:WebGalEnter.webp;
66Enable_Appreciation:true;
7+ Max_line:4;
8+ Max_lineHeight:0.25;
Original file line number Diff line number Diff line change 1+ WebGAL:我是第一行文本|我是第二行哈哈|第三行在这里|第四行是这个内容;
Original file line number Diff line number Diff line change 11setVar:heroine=WebGAL;
22setVar:egine=WebGAL;
3- choose:简体中文:demo_zh_cn.txt|日本語:demo_ja.txt|English:demo_en.txt|Test:function_test.txt;
3+ choose:多行测试:demo_max_line_test.txt| 简体中文:demo_zh_cn.txt|日本語:demo_ja.txt|English:demo_en.txt|Test:function_test.txt;
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,15 @@ 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 MaxTextLine = userDataState . globalGameVar . Max_line as number ; // config定义字体行数
193+ const MaxTextLineHeight = userDataState . globalGameVar . Max_lineHeight as number ; // config 定义字体行数高度
194+ const totalHeight = ! Number . isNaN ( Number ( MaxTextLine ) )
195+ ? ( Number . isNaN ( Number ( MaxTextLineHeight ) ) ? lineHeightValue : MaxTextLineHeight ) * MaxTextLine
196+ : lineHeightValue ; // Max_LineHeight和Max_Line必定为数字,否则使用默认值
197+
198+ const lineHeightCssStr = `line-height: ${ totalHeight } em` ;
189199 const lhCss = css ( lineHeightCssStr ) ;
190200
191201 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 = userDataState . globalGameVar . Max_line as number ; // congfig定义字体行数
37+ const lineLimit = Number . isNaN ( Number ( 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