import UIToastMessage from "../../ui/uiview/common/UIToastMessage"; import { ViewZorder } from "../constant/ViewZOrder"; import UIBase, { UIClass } from "./UIBase"; import UIMng from "./UIMng"; /**确定框界面参数 */ export interface DialogParams { title: string, content: string, certainCb?: Function, cancelCb?: Function } export default class UIHelp { public static SetLabel(node: cc.Node, value: string | number) { if (typeof value === 'number') { value = value.toString(); } else if (value == undefined) { value = ""; } // 文本和富文本只能二选一 if (node.getComponent(cc.RichText)) { let defaultColor = node.color.toHEX('#rrggbb'); node.getComponent(cc.RichText).string = `${value}`; } else { node.getComponent(cc.Label).string = value; } } /**按钮灰化,只有注册click事件,才会真正被禁用 */ public static SetBtnGrayState(node: cc.Node, isGray) { let button = node.getComponent(cc.Button); if (!button) { return; } button.interactable = !isGray; button.enableAutoGrayEffect = isGray; } public static IsBtnGray(node: cc.Node) { let button = node.getComponent(cc.Button); if (!button) { return false; } return !button.interactable; } public static ShowUI(uiClass: UIClass, callback?: Function, ...args: any[]) { UIMng.getInstance().openUI(uiClass, ViewZorder.UI, callback, null, ...args); } public static CloseUI(uiClass: UIClass) { UIMng.getInstance().closeUI(uiClass); } public static IsShowingUI(uiClass: UIClass) { return UIMng.getInstance().isShowing(uiClass); } public static ShowTips(message: string, ...param: any[]) { let tipUI = UIMng.getInstance().getUI(UIToastMessage) as UIToastMessage; if (!tipUI) { UIMng.getInstance().openUI(UIToastMessage, ViewZorder.Tips, (ui) => { (ui as UIToastMessage).pushMessage(message); }); } else { } } // public static ShowDialog(data: DialogParams) { // UIMng.getInstance().openUI(UIConfirmDialog, ViewZorder.Dialog, null, null, data); // } }