123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- import { gameMethod } from "../../../common/gameMethod";
- import auto_dialogView from "../../../data/autoui/dialogView/auto_dialogView";
- import { WindowEvent } from "../../../data/const/EventConst";
- import { ViewZOrder } from "../../../data/const/ViewZOrder";
- import EventMng from "../../../manager/EventMng";
- import AssetMgr from "../../../utils/AssetMgr";
- import { I18n } from "../../../utils/I18nUtil";
- import { uiCommon } from "../../../utils/UICommon";
- import UIBase, { BASE_POP } from "../UIBase";
- import UIHelp, { DialogParams } from "../UIHelp";
- const { ccclass, menu, property } = cc._decorator;
- @ccclass
- @menu("UI/dialogView/UIDialogView")
- export default class UIDialogView extends UIBase {
- ui: auto_dialogView = null;
- dialogParams: DialogParams;// 外部传入的参数
- protected static prefabUrl = "dialogView/dialogView";
- protected static className = "UIDialogView";
- protected static pop = BASE_POP.UI;
- onUILoad() {
- this.ui = this.node.addComponent(auto_dialogView);
- }
- onShow() {
- this.node.zIndex = ViewZOrder.POP_SYSTEM;
- EventMng.on(WindowEvent.SHOW_SYS_DIALOG, this.showDialog, this);
- uiCommon.onRegisterEvent(this.ui.imgMask, this.OnClickMask, this);
- uiCommon.onRegisterEvent(this.ui.btnClose, this.OnClickMask, this);
- uiCommon.onRegisterEvent(this.ui.btnConfirm, this.OnClickConfirmBtn, this);
- uiCommon.onRegisterEvent(this.ui.btnCancel, this.OnClickCancelBtn, this);
- }
- onHide() {
- EventMng.off(WindowEvent.SHOW_SYS_DIALOG, this.showDialog, this);
- uiCommon.unRegisterEvent(this.ui.imgMask);
- uiCommon.unRegisterEvent(this.ui.btnClose);
- uiCommon.unRegisterEvent(this.ui.btnConfirm);
- uiCommon.unRegisterEvent(this.ui.btnCancel);
- }
- onStart() {
- }
- showDialog(data: DialogParams) {
- if (gameMethod.isEmpty(data)) return;
- this.dialogParams = data;
- this.ui.imgMask.active = true;
- uiCommon.setLabel(this.ui.title, this.dialogParams.title || I18n?.getI18nText("common_dialogtitle_1"));
- uiCommon.setLabel(this.ui.DescLabel, this.dialogParams.content || I18n?.getI18nText("common_dialogtitle_1"));
- // 确定、取消
- uiCommon.setLabel(this.ui.txtConfirm, this.dialogParams.txtConfirm || I18n?.getI18nText("common_confirm_11"));
- if (this.dialogParams.onlyConfirm) {
- this.ui.btnCancel.active = false;
- } else {
- this.ui.btnCancel.active = true;
- uiCommon.setLabel(this.ui.txtCancel, this.dialogParams.txtCancel || I18n?.getI18nText("common_cancel_1"));
- }
- }
- // 确定
- OnClickConfirmBtn(): void {
- if (this.dialogParams?.cbConfirm != null) {
- this.dialogParams?.cbConfirm();
- }
- this.closeDialog();
- }
- // 取消
- OnClickCancelBtn(): void {
- if (this.dialogParams?.cbCancel != null) {
- this.dialogParams?.cbCancel();
- }
- this.closeDialog();
- }
- OnClickMask() {
- if (this.dialogParams.onlyConfirm && this.dialogParams?.cbConfirm != null) {
- this.dialogParams?.cbConfirm();
- }
- this.closeDialog();
- }
- closeDialog() {
- this.ui.imgMask.active = false;
- }
- onClose() {
- }
- }
|