File tree Expand file tree Collapse file tree
Core/gameScripts/getUserInput Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,6 +15,7 @@ import { setStageVar } from '@/store/stageReducer';
1515import { getCurrentFontFamily } from '@/hooks/useFontFamily' ;
1616import { logger } from '@/Core/util/logger' ;
1717import { tryToRegex } from '@/Core/util/global' ;
18+ import { showGlogalDialog } from '@/UI/GlobalDialog/GlobalDialog' ;
1819
1920/**
2021 * 显示选择枝
@@ -47,7 +48,11 @@ export const getUserInput = (sentence: ISentence): IPerform => {
4748 if ( rule ) {
4849 const reg = tryToRegex ( rule , ruleFlag ) ;
4950 if ( reg && ! reg . test ( userInput . value ) ) {
50- if ( ruleText ) alert ( ruleText . replaceAll ( / \$ 0 / g, userInput . value ) ) ;
51+ if ( ruleText )
52+ showGlogalDialog ( {
53+ title : ruleText . replaceAll ( / \$ 0 / g, userInput . value ) ,
54+ leftText : 'OK' ,
55+ } ) ;
5156 return ;
5257 }
5358 if ( ! reg ) {
Original file line number Diff line number Diff line change @@ -12,23 +12,23 @@ export default function GlobalDialog() {
1212
1313interface IShowGlobalDialogProps {
1414 title : string ;
15- leftText : string ;
16- rightText : string ;
17- leftFunc : Function ;
18- rightFunc : Function ;
15+ leftText ? : string ;
16+ rightText ? : string ;
17+ leftFunc ? : Function ;
18+ rightFunc ? : Function ;
1919}
2020
2121export function showGlogalDialog ( props : IShowGlobalDialogProps ) {
2222 const { playSeClick, playSeEnter } = useSEByWebgalStore ( ) ;
2323 webgalStore . dispatch ( setVisibility ( { component : 'showGlobalDialog' , visibility : true } ) ) ;
2424 const handleLeft = ( ) => {
2525 playSeClick ( ) ;
26- props . leftFunc ( ) ;
26+ props . leftFunc ?. ( ) ;
2727 hideGlobalDialog ( ) ;
2828 } ;
2929 const handleRight = ( ) => {
3030 playSeClick ( ) ;
31- props . rightFunc ( ) ;
31+ props . rightFunc ?. ( ) ;
3232 hideGlobalDialog ( ) ;
3333 } ;
3434 const renderElement = (
@@ -37,12 +37,16 @@ export function showGlogalDialog(props: IShowGlobalDialogProps) {
3737 < div className = { styles . glabalDialog_container_inner } >
3838 < div className = { styles . title } > { props . title } </ div >
3939 < div className = { styles . button_list } >
40- < div className = { styles . button } onClick = { handleLeft } onMouseEnter = { playSeEnter } >
41- { props . leftText }
42- </ div >
43- < div className = { styles . button } onClick = { handleRight } onMouseEnter = { playSeEnter } >
44- { props . rightText }
45- </ div >
40+ { props . leftText && (
41+ < div className = { styles . button } onClick = { handleLeft } onMouseEnter = { playSeEnter } >
42+ { props . leftText }
43+ </ div >
44+ ) }
45+ { props . rightText && (
46+ < div className = { styles . button } onClick = { handleRight } onMouseEnter = { playSeEnter } >
47+ { props . rightText }
48+ </ div >
49+ ) }
4650 </ div >
4751 </ div >
4852 </ div >
You can’t perform that action at this time.
0 commit comments