From f76b6d162b98b1eaf886d548ab0acea46e6ec3f4 Mon Sep 17 00:00:00 2001 From: None <134219525+None-44@users.noreply.github.com> Date: Thu, 22 Aug 2024 16:53:18 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=E4=BD=BF=E5=BE=97=E6=96=87=E6=9C=AC?= =?UTF-8?q?=E6=8B=93=E5=B1=95=E8=AF=AD=E6=B3=95=E5=AF=B9=E8=A7=92=E8=89=B2?= =?UTF-8?q?=E5=90=8D=E7=A7=B0=E6=9C=89=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1.修改了showName类型以及相关引用 2.由于脚本中的第一个':'会被认为是角色名称与对话文本的分割,因此在对角色名称使用拓展文本语法时需要将‘:’替换为'~',再由代码对其进行替换 --- .../webgal/src/Stage/TextBox/IMSSTextbox.tsx | 133 +++++++++++------- packages/webgal/src/Stage/TextBox/TextBox.tsx | 6 +- .../legacy-standard/StandardTextbox.tsx | 38 +++-- packages/webgal/src/Stage/TextBox/types.ts | 2 +- packages/webgal/src/UI/Backlog/Backlog.tsx | 22 ++- .../Menu/Options/TextPreview/TextPreview.tsx | 2 +- 6 files changed, 135 insertions(+), 68 deletions(-) diff --git a/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx b/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx index b6179a4a0..9e2cb92ca 100644 --- a/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx +++ b/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx @@ -41,6 +41,78 @@ export default function IMSSTextbox(props: ITextboxProps) { }, []); let allTextIndex = 0; + const nameElementList = showName.map((line, index)=>{ + const textline = line.map((en,index)=>{ + const e = en.reactNode; + let style = ''; + let tips = ''; + let style_alltext = ''; + if (en.enhancedValue) { + const data = en.enhancedValue; + console.log(data); + for (const dataElem of data) { + const { key, value } = dataElem; + switch (key) { + case 'style': + style = value; + break; + case 'tips': + tips = value; + break; + case 'style-alltext': + style_alltext = value; + break; + } + } + } + let prevLength = currentConcatDialogPrev.length; + const styleClassName = ' ' + css(style); + const styleAllText = ' ' + css(style_alltext); + if (index < prevLength) { + return ( + + + {e} + {e} + {isUseStroke && {e}} + + + ); + } + return ( + + + {e} + {e} + {isUseStroke && {e}} + + + ); + + }) + return ( +
+ {textline} +
+ ); + }); const textElementList = textArray.map((line, index) => { const textLine = line.map((en, index) => { const e = en.reactNode; @@ -159,53 +231,20 @@ export default function IMSSTextbox(props: ITextboxProps) { miniAvatar )} - {showName !== '' && ( - <> -
-
- {showName.split('').map((e, i) => { - return ( - - - {e} - {e} - {isUseStroke && {e}} - - - ); - })} -
-
-
- {showName.split('').map((e, i) => { - return ( - - - {e} - {e} - {isUseStroke && {e}} - - - ); - })} -
- + {showName !== null && ( +
+ {nameElementList} +
)}
{ .default(() => 2); // 拆字 const textArray = compileSentence(stageState.showText, lineLimit); - const showName = stageState.showName; + const showName = compileSentence(stageState.showName,lineLimit); const currentConcatDialogPrev = stageState.currentConcatDialogPrev; const currentDialogKey = stageState.currentDialogKey; const miniAvatar = stageState.miniAvatar; @@ -264,9 +264,9 @@ function parseEnhancedString(enhanced: string): KeyValuePair[] { while ((match = regex.exec(enhanced)) !== null) { result.push({ key: match[1], - value: match[2].trim(), + value: match[2].replace(/~/g,':').trim(), }); } return result; -} +} \ No newline at end of file diff --git a/packages/webgal/src/Stage/TextBox/legacy-themes/legacy-standard/StandardTextbox.tsx b/packages/webgal/src/Stage/TextBox/legacy-themes/legacy-standard/StandardTextbox.tsx index 33ca4f88b..adc0219ba 100644 --- a/packages/webgal/src/Stage/TextBox/legacy-themes/legacy-standard/StandardTextbox.tsx +++ b/packages/webgal/src/Stage/TextBox/legacy-themes/legacy-standard/StandardTextbox.tsx @@ -38,7 +38,25 @@ export default function StandardTextbox(props: ITextboxProps) { WebGAL.events.textSettle.off(settleText); }; }, []); - + const nameElementList = showName.map((e,index)=>{ + let prevLength = currentConcatDialogPrev.length; + if (index < prevLength) { + return ( + + {e} + {e} + {isUseStroke && {e}} + + ); + } + return ( + + {e} + {e} + {isUseStroke && {e}} + + ); + }); const textElementList = textArray.map((e, index) => { // if (e === '
') { // return
; @@ -83,7 +101,7 @@ export default function StandardTextbox(props: ITextboxProps) { }); const padding = isHasMiniAvatar ? 500 : undefined; - const isHasName = showName !== ''; + const isHasName = showName !== null; let paddingTop = isHasName ? undefined : 15; if (textSizeState === textSize.small && !isHasName) { paddingTop = 35; @@ -114,19 +132,9 @@ export default function StandardTextbox(props: ITextboxProps) {
{miniAvatar !== '' && miniAvatar}
- {showName !== '' && ( -
- {showName.split('').map((e, i) => { - return ( - - - {e} - {e} - {isUseStroke && {e}} - - - ); - })} + {showName !== null && ( +
+ {nameElementList}
)}
{
); }); + const showNameArray = compileSentence(backlogItem.currentStageState.showName, 3, true); + const showNameArray2 = showNameArray.map((line)=>{ + return line.map((c) => { + return c.reactNode; + }); + }); + const showNameArrayReduced = mergeStringsAndKeepObjects(showNameArray2); + const nameElementList = showNameArrayReduced.map((line,index)=>{ + return ( +
+ {line.map((e, index) => { + if (e === '
') { + return
; + } else { + return e; + } + })} +
+ ); + }); const singleBacklogView = (
{
) : null}
-
{backlogItem.currentStageState.showName}
+
{nameElementList}
{showTextElementList} diff --git a/packages/webgal/src/UI/Menu/Options/TextPreview/TextPreview.tsx b/packages/webgal/src/UI/Menu/Options/TextPreview/TextPreview.tsx index d6d9e0459..a5fdb5f80 100644 --- a/packages/webgal/src/UI/Menu/Options/TextPreview/TextPreview.tsx +++ b/packages/webgal/src/UI/Menu/Options/TextPreview/TextPreview.tsx @@ -30,7 +30,7 @@ export const TextPreview = (props: any) => { textArray: previewTextArray, isText: true, textDelay: textDelay, - showName: t('textPreview.title'), + showName: compileSentence(t('textPreview.title'),3), currentConcatDialogPrev: '', fontSize: size, currentDialogKey: '', From 9b85b7c1825439779984cb1f37a0bb25606e17d0 Mon Sep 17 00:00:00 2001 From: None <134219525+None-44@users.noreply.github.com> Date: Tue, 3 Sep 2024 18:02:36 +0800 Subject: [PATCH 2/3] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E5=A7=93=E5=90=8D?= =?UTF-8?q?=E6=A1=86=E9=94=99=E8=AF=AF=E6=98=BE=E7=A4=BA=E5=B9=B6=E6=94=B9?= =?UTF-8?q?=E6=AD=A3=E8=A7=92=E8=89=B2=E5=90=8D=E7=A7=B0=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1,解决没有角色名称依旧会出现姓名框 2,由于使用角色名称默认样式时改变颜色的拓展文本语法无法生效,因此当使用拓展文本语法时将使用与文本相同的样式 3,目前无法复现角色名称闪烁 --- .../webgal/src/Stage/TextBox/IMSSTextbox.tsx | 56 ++++++++++--------- packages/webgal/src/Stage/TextBox/TextBox.tsx | 2 + .../legacy-standard/StandardTextbox.tsx | 4 +- packages/webgal/src/Stage/TextBox/types.ts | 1 + .../Menu/Options/TextPreview/TextPreview.tsx | 6 +- 5 files changed, 41 insertions(+), 28 deletions(-) diff --git a/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx b/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx index 9e2cb92ca..5507a31b1 100644 --- a/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx +++ b/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx @@ -16,6 +16,7 @@ export default function IMSSTextbox(props: ITextboxProps) { isFirefox: boolean, fontSize, miniAvatar, + isHasName, showName, font, textDuration, @@ -39,7 +40,6 @@ export default function IMSSTextbox(props: ITextboxProps) { WebGAL.events.textSettle.off(settleText); }; }, []); - let allTextIndex = 0; const nameElementList = showName.map((line, index)=>{ const textline = line.map((en,index)=>{ @@ -47,7 +47,9 @@ export default function IMSSTextbox(props: ITextboxProps) { let style = ''; let tips = ''; let style_alltext = ''; + let isEnhanced = false; if (en.enhancedValue) { + isEnhanced = true; const data = en.enhancedValue; console.log(data); for (const dataElem of data) { @@ -65,16 +67,13 @@ export default function IMSSTextbox(props: ITextboxProps) { } } } - let prevLength = currentConcatDialogPrev.length; const styleClassName = ' ' + css(style); const styleAllText = ' ' + css(style_alltext); - if (index < prevLength) { + if(isEnhanced){ return ( {e} @@ -86,19 +85,16 @@ export default function IMSSTextbox(props: ITextboxProps) { } return ( {e} - {e} - {isUseStroke && {e}} + {e} + {isUseStroke && {e}} ); - }) return (
)}
- {showName !== null && ( -
+
+ {nameElementList} +
+
- {nameElementList} -
+ > + {nameElementList} +
+ )}
{ .default(() => 2); // 拆字 const textArray = compileSentence(stageState.showText, lineLimit); + const isHasName = stageState.showName !== ''; const showName = compileSentence(stageState.showName,lineLimit); const currentConcatDialogPrev = stageState.currentConcatDialogPrev; const currentDialogKey = stageState.currentDialogKey; @@ -79,6 +80,7 @@ export const TextBox = () => { isText={isText} textDelay={textDelay} showName={showName} + isHasName={isHasName} currentConcatDialogPrev={currentConcatDialogPrev} fontSize={size} currentDialogKey={currentDialogKey} diff --git a/packages/webgal/src/Stage/TextBox/legacy-themes/legacy-standard/StandardTextbox.tsx b/packages/webgal/src/Stage/TextBox/legacy-themes/legacy-standard/StandardTextbox.tsx index adc0219ba..465b918bb 100644 --- a/packages/webgal/src/Stage/TextBox/legacy-themes/legacy-standard/StandardTextbox.tsx +++ b/packages/webgal/src/Stage/TextBox/legacy-themes/legacy-standard/StandardTextbox.tsx @@ -15,6 +15,7 @@ export default function StandardTextbox(props: ITextboxProps) { isFirefox, fontSize, miniAvatar, + isHasName, showName, font, textDuration, @@ -101,7 +102,6 @@ export default function StandardTextbox(props: ITextboxProps) { }); const padding = isHasMiniAvatar ? 500 : undefined; - const isHasName = showName !== null; let paddingTop = isHasName ? undefined : 15; if (textSizeState === textSize.small && !isHasName) { paddingTop = 35; @@ -132,7 +132,7 @@ export default function StandardTextbox(props: ITextboxProps) {
{miniAvatar !== '' && miniAvatar}
- {showName !== null && ( + {isHasName && (
{nameElementList}
diff --git a/packages/webgal/src/Stage/TextBox/types.ts b/packages/webgal/src/Stage/TextBox/types.ts index fe1e53845..59e41e126 100644 --- a/packages/webgal/src/Stage/TextBox/types.ts +++ b/packages/webgal/src/Stage/TextBox/types.ts @@ -11,6 +11,7 @@ export interface ITextboxProps { fontSize: string; miniAvatar: string; showName: EnhancedNode[][]; + isHasName: boolean; font: string; textDuration: number; textSizeState: number; diff --git a/packages/webgal/src/UI/Menu/Options/TextPreview/TextPreview.tsx b/packages/webgal/src/UI/Menu/Options/TextPreview/TextPreview.tsx index a5fdb5f80..4e8bbc4d3 100644 --- a/packages/webgal/src/UI/Menu/Options/TextPreview/TextPreview.tsx +++ b/packages/webgal/src/UI/Menu/Options/TextPreview/TextPreview.tsx @@ -23,6 +23,9 @@ export const TextPreview = (props: any) => { const isSafari = /^((?!chrome|android).)*safari/i.test(userAgent); const previewText = t('textPreview.text'); const previewTextArray = compileSentence(previewText, 3); + const showNameText = t('textPreview.title'); + const showNameArray = compileSentence(showNameText, 3); + const isHasName = showNameText !== ''; const Textbox = IMSSTextbox; @@ -30,7 +33,8 @@ export const TextPreview = (props: any) => { textArray: previewTextArray, isText: true, textDelay: textDelay, - showName: compileSentence(t('textPreview.title'),3), + isHasName: isHasName, + showName: showNameArray, currentConcatDialogPrev: '', fontSize: size, currentDialogKey: '', From 3fd1b193a61c117bc4f846b6c76065faee46f2ad Mon Sep 17 00:00:00 2001 From: Mahiru Date: Mon, 9 Sep 2024 01:06:12 +0800 Subject: [PATCH 3/3] fix: enhance value do not effect when at first of line --- .../webgal/src/Stage/TextBox/IMSSTextbox.tsx | 38 ++++++++----------- packages/webgal/src/Stage/TextBox/TextBox.tsx | 11 ++++-- 2 files changed, 22 insertions(+), 27 deletions(-) diff --git a/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx b/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx index 5507a31b1..413dcb6e2 100644 --- a/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx +++ b/packages/webgal/src/Stage/TextBox/IMSSTextbox.tsx @@ -41,8 +41,8 @@ export default function IMSSTextbox(props: ITextboxProps) { }; }, []); let allTextIndex = 0; - const nameElementList = showName.map((line, index)=>{ - const textline = line.map((en,index)=>{ + const nameElementList = showName.map((line, index) => { + const textline = line.map((en, index) => { const e = en.reactNode; let style = ''; let tips = ''; @@ -51,7 +51,6 @@ export default function IMSSTextbox(props: ITextboxProps) { if (en.enhancedValue) { isEnhanced = true; const data = en.enhancedValue; - console.log(data); for (const dataElem of data) { const { key, value } = dataElem; switch (key) { @@ -67,27 +66,21 @@ export default function IMSSTextbox(props: ITextboxProps) { } } } - const styleClassName = ' ' + css(style); - const styleAllText = ' ' + css(style_alltext); - if(isEnhanced){ + const styleClassName = ' ' + css(style, { label: 'showname' }); + const styleAllText = ' ' + css(style_alltext, { label: 'showname' }); + if (isEnhanced) { return ( - + {e} - {e} - {isUseStroke && {e}} + {e} + {isUseStroke && {e}} ); } return ( - + {e} {e} @@ -95,7 +88,7 @@ export default function IMSSTextbox(props: ITextboxProps) { ); - }) + }); return (
- {nameElementList} + {nameElementList}
{nameElementList}
diff --git a/packages/webgal/src/Stage/TextBox/TextBox.tsx b/packages/webgal/src/Stage/TextBox/TextBox.tsx index 216ad0b14..7e6edcb88 100644 --- a/packages/webgal/src/Stage/TextBox/TextBox.tsx +++ b/packages/webgal/src/Stage/TextBox/TextBox.tsx @@ -68,7 +68,7 @@ export const TextBox = () => { // 拆字 const textArray = compileSentence(stageState.showText, lineLimit); const isHasName = stageState.showName !== ''; - const showName = compileSentence(stageState.showName,lineLimit); + const showName = compileSentence(stageState.showName, lineLimit); const currentConcatDialogPrev = stageState.currentConcatDialogPrev; const currentDialogKey = stageState.currentDialogKey; const miniAvatar = stageState.miniAvatar; @@ -137,7 +137,7 @@ export function compileSentence(sentence: string, lineLimit: number, ignoreLineL * @param sentence */ export function splitChars(sentence: string) { - if (!sentence) return []; + if (!sentence) return ['']; const words: string[] = []; let word = ''; let cjkFlag = isCJK(sentence[0]); @@ -250,6 +250,9 @@ function parseString(input: string): Segment[] { } } + // 我也不知道为什么,不加这个就会导致在 Enhanced Value 处于行首时故障 + // 你可以认为这个代码不明所以,但是不要删除 + result.unshift({ type: SegmentType.String, value: '' }); return result; } @@ -266,9 +269,9 @@ function parseEnhancedString(enhanced: string): KeyValuePair[] { while ((match = regex.exec(enhanced)) !== null) { result.push({ key: match[1], - value: match[2].replace(/~/g,':').trim(), + value: match[2].replace(/~/g, ':').trim(), }); } return result; -} \ No newline at end of file +}