UNPKG

commonui-lib-test

Version:

"#common ui lib test"

138 lines (137 loc) 4.56 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const dialogSystemTips_1 = require("../../../ui/common/dialogSystemTips"); const DialogHandler_1 = require("./DialogHandler"); var EnumSystemTipsType; (function (EnumSystemTipsType) { EnumSystemTipsType[EnumSystemTipsType["None"] = 0] = "None"; EnumSystemTipsType[EnumSystemTipsType["ToLobby"] = 1] = "ToLobby"; EnumSystemTipsType[EnumSystemTipsType["BetFailed"] = 2] = "BetFailed"; })(EnumSystemTipsType || (EnumSystemTipsType = {})); /** * @api {class} SystemTipsHandler * @apiName SystemTipsHandler * @apiGroup SystemTipsHandler * @apiDescription SystemTipsHandler */ class SystemTipsHandler { constructor() { this.initHandler(); } static get Ins() { return SystemTipsHandler._instance = SystemTipsHandler._instance || new SystemTipsHandler(); } /** * @api {function} isInit * @apiName isInit * @apiGroup SystemTipsHandler * @apiDescription isInit */ get isInit() { return this.view && this.view.inContainer; } get currSystemTipsType() { return this.view ? this.view.ctrlTipsType.selectedIndex : 0; } /** * @api {function} initHandler * @apiName initHandler * @apiGroup SystemTipsHandler * @apiDescription initSystemTipsHandler */ initHandler(initCallBack) { if (!this.view) { console.warn("initSystemTipsHandler : init View"); this.createView(); } if (!this.view.inContainer) { console.warn("initSystemTipsHandler : add View"); this.viewUIReady(); } if (initCallBack) initCallBack.run(); this.setViewOrder(); } /** * @api {function} dispose * @apiName dispose * @apiGroup SystemTipsHandler * @apiDescription dispose */ dispose() { if (this.view) { this.view.transZoomin.stop(true); this.view.dispose(); } this.view = null; SystemTipsHandler._instance = null; } /** * @api {function} createView * @apiName createView * @apiGroup SystemTipsHandler * @apiDescription createView */ createView() { this.view = dialogSystemTips_1.default.createInstance(); this.view.name = "SystemTipsHandler"; this.view.setSize(fgui.GRoot.inst.width, this.view.height); this.view.center(true); } /** * @api {function} viewUIReady * @apiName viewUIReady * @apiGroup SystemTipsHandler * @apiDescription viewUIReady */ viewUIReady() { } /** * @api {function} setViewOrder * @apiName setViewOrder * @apiGroup SystemTipsHandler * @apiDescription setViewOrder */ setViewOrder() { fgui.GRoot.inst.addChild(this.view); DialogHandler_1.default.Ins.setDialogOrder(this.view); } /** * @api {function} setSystemTipsOrder * @apiName setSystemTipsOrder * @apiGroup SystemTipsHandler * @apiDescription setSystemTipsOrder */ setSystemTipsOrder(targetView) { let targetViewIndex = fgui.GRoot.inst.getChildIndex(targetView); if (this.isInit) { let selfIndex = fgui.GRoot.inst.getChildIndex(this.view); targetViewIndex = fgui.GRoot.inst.setChildIndexBefore(targetView, selfIndex); } return targetViewIndex; } showSystemTips(systemTipsType = 0, args) { if (this.isInit) { this.setSystemTipsData(systemTipsType, args); } else { this.initHandler(Laya.Handler.create(this, () => this.setSystemTipsData(systemTipsType, args))); } } setSystemTipsData(systemTipsType = 0, args) { const cases = { 2: () => this.onBetFailed(args) }; cases.hasOwnProperty(systemTipsType) && cases[systemTipsType](); this.view.transZoomin.stop(true); this.view.ctrlTipsType.selectedIndex = systemTipsType; this.view.transZoomin.play(Laya.Handler.create(this, this.onTransZoominComplete)); } onTransZoominComplete() { this.view.ctrlTipsType.selectedIndex = EnumSystemTipsType.None; ; } onBetFailed(evt) { let { value } = evt; this.view.comSystemBetFailed.textTitle.setVar("value", value).flushVars(); } } exports.default = SystemTipsHandler;