Skip to content
Merged
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
10 changes: 8 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,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 (
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