123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 |
- "use strict";
- cc._RF.push(module, '38743aZ7sZAvprwXHSmahja', 'BaseView');
- // lightMVC/core/base/BaseView.ts
- "use strict";
- var __extends = (this && this.__extends) || (function () {
- var extendStatics = function (d, b) {
- extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
- return extendStatics(d, b);
- };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
- return c > 3 && r && Object.defineProperty(target, key, r), r;
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- exports.BaseView = void 0;
- /**
- * 视图基类
- */
- var ViewEvent_1 = require("./ViewEvent");
- var ViewManager_1 = require("../manager/ViewManager");
- var UIUtils_1 = require("../../util/UIUtils");
- var _a = cc._decorator, ccclass = _a.ccclass, property = _a.property;
- var BaseView = /** @class */ (function (_super) {
- __extends(BaseView, _super);
- function BaseView() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- BaseView.prototype.__init__ = function () {
- this.__event__ = new ViewEvent_1.default();
- this.ui = UIUtils_1.default.seekAllSubView(this.node);
- this.init();
- };
- /**
- * view 创建时会被调用,子类可以重写.
- */
- BaseView.prototype.init = function () {
- };
- /**
- * 发送UI事件
- * @param {string} event 事件名称
- * @param {Object} body 事件参数
- */
- BaseView.prototype.sendEvent = function (event, body) {
- this.__event__.emit(event, body);
- };
- /**
- * 绑定UI事件
- * @param {string} name 事件名称
- * @param {(body: any)=>void} cb 事件回调
- * @param {BaseMediator} target 事件回调绑定对象
- * @private 私有函数,不得调用。
- */
- BaseView.prototype.__bindEvent__ = function (name, cb, target) {
- this.__event__.on(name, cb, target);
- };
- /**
- * 关闭当前的界面
- */
- BaseView.prototype.closeView = function () {
- var bgname = "blackBg" + this.node.name;
- if (this.node.parent && this.node.parent.getChildByName(bgname))
- this.node.parent.getChildByName(bgname).destroy();
- ViewManager_1.ViewManager.getInstance().__closeView__(this);
- this.__onClose__();
- };
- /**
- * 关闭所有弹出的界面
- */
- BaseView.prototype.closeAllPopView = function () {
- ViewManager_1.ViewManager.getInstance().__closeAllPopView__();
- };
- BaseView.prototype.__onClose__ = function () {
- this.__event__.destroy();
- this.onClose();
- this.node.destroy();
- };
- /**
- * 当界面被关闭时会被调用,子类可以重写该方法。
- * @override
- */
- BaseView.prototype.onClose = function () {
- };
- /**
- * 子类覆盖,返回UI的prefab路径
- * 路径第一个目录为子包名称如:aa/bb/ccc;aa为子包名 bb/ccc为子包内的prefab路径;
- * 如果放在resources的prefab;则路径去掉子包名/bb/ccc
- * @return {string}
- */
- BaseView.path = function () {
- return "";
- };
- /**
- * 注册mediator
- */
- BaseView.prototype.registerMediator = function (mediator, view, data) {
- var viewMediator = new mediator();
- viewMediator["__init__"]();
- viewMediator.view = view;
- viewMediator.view.__init__();
- viewMediator.init(data);
- };
- BaseView = __decorate([
- ccclass
- ], BaseView);
- return BaseView;
- }(cc.Component));
- exports.BaseView = BaseView;
- cc._RF.pop();
|