import MsgAlert from "../game/msg/MsgAlert"; import FGUtil from "../gear_2.3.4/fgui/FGUtil"; import GameModel from "./GameModel"; export default class SafeCheckAlert { private static shared = new SafeCheckAlert(); main: fgui.GComponent; constructor() { } static show(cancelBlock: () => void, sureBlock: () => void) { this.shared.show(cancelBlock, sureBlock); } static hide() { this.shared.hide(); } private show(cancelBlock: () => void, sureBlock: () => void) { if (this.main != null) { this.main.dispose(); } this.main = fgui.UIPackage.createObject("main_ui", "safe_check_main").asCom; FGUtil.root().addChild(this.main); this.main.makeFullScreen(); let cancelBtn = FGUtil.getButton(this.main, "alert/cancel_btn"); let sureBtn = FGUtil.getButton(this.main, "alert/sure_btn") cancelBtn.onClick(() => { cancelBlock(); }); sureBtn.onClick(() => { let player=GameModel.player; if(player==null){ return; } let myCode = player.safe_password; let code = FGUtil.getTextInput(this.main, "alert/input").text; if (code != myCode) { MsgAlert.addMsg(`密碼錯誤,請重新輸入!`); return; } sureBlock(); }) } hide() { FGUtil.dispose(this.main); this.main = null; } }