File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed
src/Core/gameScripts/getUserInput Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ WebGAL:新版本添加了特性:获取用户输入,你要尝试一下吗?
3030choose:尝试一下:userInput|算了吧:toNextPart;
3131
3232label:userInput;
33- getUserInput:name -title=如何称呼你 -buttonText=确认;
33+ getUserInput:name -title=如何称呼你 -buttonText=确认 -defaultValue=WebGALPlayer ;
3434WebGAL:很高兴遇见你,{name}!
3535jumpLabel:toNextPart;
3636
Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ export const getUserInput = (sentence: ISentence): IPerform => {
2424 const title = ( titleFromArgs === 0 ? 'Please Input' : titleFromArgs ) ?? 'Please Input' ;
2525 const buttonTextFromArgs = getSentenceArgByKey ( sentence , 'buttonText' ) ;
2626 const buttonText = ( buttonTextFromArgs === 0 ? 'OK' : buttonTextFromArgs ) ?? 'OK' ;
27+ const defaultValueFromArgs = getSentenceArgByKey ( sentence , 'defaultValue' ) ;
2728 const fontFamily = webgalStore . getState ( ) . userData . optionData . textboxFont ;
2829 const font = fontFamily === textFont . song ? '"思源宋体", serif' : '"WebgalUI", serif' ;
2930 const { playSeEnter, playSeClick } = useSEByWebgalStore ( ) ;
@@ -38,7 +39,10 @@ export const getUserInput = (sentence: ISentence): IPerform => {
3839 const userInput : HTMLInputElement = document . getElementById ( 'user-input' ) as HTMLInputElement ;
3940 if ( userInput ) {
4041 webgalStore . dispatch (
41- setStageVar ( { key : varKey , value : ( userInput ?. value ?? '' ) === '' ? ' ' : userInput ?. value ?? '' } ) ,
42+ setStageVar ( {
43+ key : varKey ,
44+ value : userInput ?. value || defaultValueFromArgs || ' ' ,
45+ } ) ,
4246 ) ;
4347 }
4448 playSeClick ( ) ;
You can’t perform that action at this time.
0 commit comments