123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- import Config from "../../Config";
- import { KindItem } from "../../common/Xys";
- import GameDataCenter from "../../data/GameDataCenter";
- import { FguiEvent, WindowEvent } from "../../data/const/EventConst";
- import { AudioConst, DayTipsKey, HelpType, InGame } from "../../data/const/TypeConst";
- import EventMng from "../../manager/EventMng";
- import UIBase, { BASE_POP, UIClass } from "./UIBase";
- import { PayProductParam } from "../../data/const/TypeConst";
- import FguiMgr from "../../frameWork/fgui/FguiMgr";
- import IDataModel from "../../data/model/IDataModel";
- import { I18n } from "../../utils/I18nUtil";
- import { uiCommon } from "../../utils/UICommon";
- import { eg } from "../../frameWork/eg";
- import AssetsBundleMgr from "../../utils/AssetsBundleMgr";
- import { ViewZOrder } from "../../data/const/ViewZOrder";
- /**确定框界面参数 */
- export interface DialogParams {
- content: string,// 弹窗文本内容
- title?: string,// 弹窗标题
- cbConfirm?: Function,// 确定按钮的事件
- cbCancel?: Function,// 取消按钮的事件
- txtCancel?: string,// 取消按钮的文本
- txtConfirm?: string,// 确定按钮的文本
- onlyConfirm?: boolean//只有确认键
- costItem?: KindItem//消耗道具
- // needItem?: KindItem//需求道具
- showToggle?: boolean,// 是否显示toggle
- useDlg?: string// 哪个界面调用的弹窗
- dayTipsKey?: DayTipsKey,//今日不再提醒key,不为空则设置
- tipsModel?: IDataModel,//本次登录不再提醒model,不为空则设置
- tipsKey?: string,//本次登录不再提醒key,不为空则设置
- showVideoBtn?: boolean,//显示视频按钮
- videoCb?: Function,//视频按钮回调
- maskCloseOnly?: boolean,//点击遮罩只关闭 不执行cancel
- // videoParam?: {
- // kid: string,
- // sendUrl: string,
- // sendParam: any
- // }
- }
- /**确定框界面参数 */
- export interface DialogJintiaoTipsParams {
- data: PayProductParam,
- needNum: number,
- cbConfirm?: Function,
- cbCancel?: Function,
- }
- /**购买道具弹窗界面参数 */
- export interface BuyItemParams {
- // noAskKey: ShopToolKey
- buyItem: KindItem//需要购买的道具
- costItem: KindItem//消耗道具
- cb: Function//购买回调
- }
- /**通用输入框参数*/
- export interface InputParams {
- content?: string,// 弹窗输入框文本内容
- title?: string,// 弹窗标题
- cbConfirm: Function,// 确定按钮的事件
- txtConfirm?: string,// 确定按钮的文本
- limitLength?: number,// 限制的字符数量
- }
- 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 = `<color=${defaultColor}>${value}</c>`;
- } 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 ShowTips(message: string) {
- // if (FguiMgr.Instance.isShowing(ShowTipsView)) {
- // EventMng.emit(FguiEvent.SHOWTIPS, message)
- // }
- // else {
- // FguiMgr.Instance.openUI(ShowTipsView, ViewZorder.POP_SYSTEM, null, message);
- // }
- }
- public static ShowI18nTips(key: string, ...args) {
- let str = I18n.getI18nText(key, ...args)
- this.ShowTips(str);
- }
- public static ShowHelp(type: HelpType, cb?: Function) {
- // FguiMgr.Instance.openUI(HelpViewView, ViewZorder.HELP, cb, type)
- }
- /**
- * 每日提示整合进dialogview内,如果已经勾选,自动执行cbConfirm
- * dayTipsModel改为dailogModel
- * @param data
- * @returns
- */
- public static ShowDialog(data: DialogParams, zIndex?: number) {
- // if (FguiMgr.Instance.isShowing(DialogViewView)) {
- // return
- // }
- // if (data.dayTipsKey && GameDataCenter.dialog.checkSetToday(data.dayTipsKey) && data.cbConfirm) {
- // data.cbConfirm()
- // return
- // }
- // FguiMgr.Instance.openUI(DialogViewView, zIndex ? zIndex : ViewZorder.DIALOG, null, data);
- }
- // 系统文字弹窗
- public static ShowSystemDialog(data: DialogParams) {
- /*if (FguiMgr.Instance.isShowing(DialogViewView)) {
- return
- }
- FguiMgr.Instance.openUI(DialogViewView, ViewZorder.POP_SYSTEM, null, data);*/
- EventMng.emit(WindowEvent.SHOW_SYS_DIALOG, data);
- }
- public static ShowSideItemTips(item: KindItem) {
- // let cfg = GameDataCenter.item.getItemCfgBase(item);
- // let color = uiCommon.getColorByPz(cfg.pinzhi);
- // UIHelp.ShowSideTips(`[color=${color}]${cfg.name}x${item[2]}[/color]`, item);
- }
- // 信息飘字提示
- public static ShowSideTips(message: string, kindItem?: KindItem) {
- // if (FguiMgr.Instance.isShowing(ShowSideTipsView)) {
- // EventMng.emit(FguiEvent.SHOWSIDETIPS, { msg: message, kindItem: kindItem })
- // }
- // else {
- // FguiMgr.Instance.openUI(ShowSideTipsView, ViewZorder.POP_SYSTEM, null, { msg: message, kindItem: kindItem });
- // }
- }
- public static FlyItemParticle(startPos: cc.Vec3, endPos: cc.Vec3, panel: fairygui.GObject, item: KindItem, index: number, cb: Function = null) {
- // let expEffect = eg.poolManager.GetPool("FlyItemParticle").get();
- // if (expEffect) {
- // // 通过 size 接口判断对象池中是否有空闲的对象
- // expEffect.active = true;
- // panel.node.addChild(expEffect);
- // expEffect.getComponent(FlyItemParticle).ShowItemEffect(startPos, endPos, item, index, cb);
- // } else {
- // // 如果没有空闲对象,也就是对象池中备用对象不够时
- // AssetsBundleMgr.loadBundlePrefab("particle/flyItem", (err, prefab: cc.Prefab) => {
- // if (prefab) {
- // expEffect = cc.instantiate(prefab);
- // expEffect.active = true;
- // expEffect.name = "expEffect";
- // panel.node.addChild(expEffect);
- // expEffect.getComponent(FlyItemParticle).ShowItemEffect(startPos, endPos, item, index, cb);
- // } else {
- // console.log("空的particle/flyItem资源");
- // }
- // });
- // }
- }
- /** 调试弹框用 */
- public static ShowDebugDialog(msg: string) {
- let data: DialogParams = {
- content: msg,
- cbConfirm: () => {
- }
- };
- this.ShowDialog(data);
- }
- }
|