UNPKG

commonui-lib-test

Version:

"#common ui lib test"

55 lines (54 loc) 2.22 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const lodash_es_1 = require("lodash-es"); const Dialog_Basic_1 = require("./Dialog_Basic"); const dialogMatchAni_1 = require("../../ui/common/dialogMatchAni"); const dayjs = require("dayjs"); class Dialog_Match extends Dialog_Basic_1.default { constructor() { super(); this.view = dialogMatchAni_1.default.createInstance(); } onInit() { this.closeButton = this.view.comDialogMatch.btnCancel; this.view.comDialogMatch.btnComfirm.onClick(this, this.onRightBtn); this.view.comDialogMatch.btnCancel.onClick(this, this.onLeftBtn); super.onInit(); } hide() { fgui.GTween.kill(this.view.comDialogMatch.textTime); super.hide(); } setBtnEvent(btnConfirm, btnCancel, target) { this.isRightBtnAutoHide = false; super.setBtnEvent(null, btnConfirm, btnCancel, target); } setMatchType(type, millisecondLeft) { fgui.GTween.kill(this.view.comDialogMatch.textTime); this.view.comDialogMatch.ctrlPingtimes.selectedIndex = type; if (type === 1) this.startRematchTimer(millisecondLeft); } startRematchTimer(millisecondLeft) { fgui.GTween .to(millisecondLeft, 0, lodash_es_1.divide(millisecondLeft, 1000)) .setEase(fgui.EaseType.Linear) .setTarget(this.view.comDialogMatch.textTime) .onStart(this.onStartRematchTimer, this) .onUpdate(this.onUupdateRematchTimer, this) .onComplete(this.hide, this); } onStartRematchTimer(evt) { let millisecondLeft = evt.value.x; let currTimeLeft = dayjs(millisecondLeft).format("s"); this.view.comDialogMatch.textTime.textTime.text = currTimeLeft; } onUupdateRematchTimer(evt) { let millisecondLeft = evt.value.x; let currTimeLeft = dayjs(millisecondLeft).format("s"); if (currTimeLeft >= this.view.comDialogMatch.textTime.textTime.text) return; this.view.comDialogMatch.textTime.textTime.text = currTimeLeft; } } exports.default = Dialog_Match;