758ea163-b8a6-4522-bb52-9d8a2427134e.js 7.73 KB
"use strict";
cc._RF.push(module, '758eaFjuKZFIrtSnYokJxNO', 'MainViewImpl');
// script/game/ui/view/impl/MainViewImpl.ts

"use strict";
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.MainViewImpl = void 0;
const CCDummyObjects_1 = require("../../../../common/CCDummyObjects");
const CCViewBase_1 = require("../../../../common/classbase/CCViewBase");
const GameConfig_1 = require("../../../../GameConfig");
const Enums_1 = require("../../../Enums");
const PresenterCCViewFactory_1 = require("../../PresenterCCViewFactory");
const MainView_1 = require("../type/MainView");
const { ccclass, property } = cc._decorator;
let MainViewImpl = /** @class */ (() => {
    let MainViewImpl = class MainViewImpl extends CCViewBase_1.CCPureView {
        constructor() {
            super(...arguments);
            this.contentParent = CCDummyObjects_1.DummyNode;
            this.titleSprite = CCDummyObjects_1.DummySprite;
            this.tabbarButtons = [];
            this.tabbarSpriteFrames = [];
            this.titleSpriteFrames = [];
            this.clickAniArr = [];
            this.debugbtn = CCDummyObjects_1.DummyNode;
            this.waitNode = CCDummyObjects_1.DummyNode;
            this.loadingLabel = CCDummyObjects_1.DummyLabel;
            this._dotNumber = 1;
            this.hideClickAniByIndex = (index) => {
                if (index < 0 || index > this.clickAniArr.length) {
                    return;
                }
                let limitArr = [Enums_1.MainTabs.messageTab, Enums_1.MainTabs.datingEventTab];
                let contrlArr = [this._props.messageRedDot, this._props.datingEventRedDot];
                let exist = limitArr.findIndex((v) => v === index) !== (-1);
                if (exist) {
                    for (let i = 0; i < limitArr.length; i++) {
                        this.clickAniArr[limitArr[i]].node.active = (limitArr[i] !== index) && contrlArr[i];
                    }
                }
                else {
                    for (let i = 0; i < limitArr.length; i++) {
                        this.clickAniArr[limitArr[i]].node.active = contrlArr[i];
                    }
                }
            };
        }
        onTabButtonClick(event, index) {
            this._props.onTabClick(parseInt(index), () => { });
            this.hideClickAniByIndex(parseInt(index));
        }
        onLoad() {
            this.changeLoadingLabel();
            this._tabContentContainer = this.contentParent.addComponent(CCViewBase_1.CCView);
            this.bindProp("messageRedDot", (value) => {
                this.tabbarButtons[Enums_1.MainTabs.messageTab].node.getChildByName("RedDot").active = value;
                if (this._props.selectedTab !== 0 && value) {
                    this.clickAniArr[Enums_1.MainTabs.messageTab].node.active = true;
                }
                else {
                    this.clickAniArr[Enums_1.MainTabs.messageTab].node.active = false;
                }
            });
            this.bindProp("datingEventRedDot", (value) => {
                this.tabbarButtons[Enums_1.MainTabs.datingEventTab].node.getChildByName("RedDot").active = value;
                if (this._props.selectedTab !== Enums_1.MainTabs.datingEventTab && value) {
                    this.clickAniArr[Enums_1.MainTabs.datingEventTab].node.active = true;
                }
                else {
                    this.clickAniArr[Enums_1.MainTabs.datingEventTab].node.active = false;
                }
            });
            //修改主界面发现按钮为永久显示红点
            this.bindProp("discoverRedDot", (value) => {
                this.tabbarButtons[Enums_1.MainTabs.discoverTab].node.getChildByName("RedDot").active = true;
            });
            this.debugbtn.active = GameConfig_1.GameConfig.debug;
        }
        getTabContentContainer() {
            return this._tabContentContainer;
        }
        onPropsLoad(props) {
            super.onPropsLoad(props);
            let currTab = this._props.selectedTab;
            this.tabbarButtons[currTab].normalSprite = this.tabbarSpriteFrames[currTab * 2 + 1];
            this.titleSprite.spriteFrame = this.titleSpriteFrames[currTab];
        }
        onPropChange(key) {
            super.onPropChange(key);
            if (key === "selectedTab") {
                let prevTab = this._prevProps.selectedTab;
                this.tabbarButtons[prevTab].normalSprite = this.tabbarSpriteFrames[prevTab * 2];
                let currTab = this._props.selectedTab;
                this.tabbarButtons[currTab].normalSprite = this.tabbarSpriteFrames[currTab * 2 + 1];
                this.titleSprite.spriteFrame = this.titleSpriteFrames[currTab];
            }
        }
        onDebugClickCallback(event) {
            this._props.onDebugClick();
        }
        getGuideTabParam(index) {
            if (index < 0 || this._props.selectedTab === index) {
                return undefined;
            }
            let node = this.tabbarButtons[index].node;
            let wp = node.convertToWorldSpaceAR(cc.v2(0, 0));
            let m = {
                x: wp.x,
                y: wp.y,
                w: node.width,
                h: node.height,
                d: Enums_1.DirectionType.DOWM,
            };
            return m;
        }
        showWaitingView(isShow) {
            this.waitNode.active = isShow;
        }
        changeLoadingLabel() {
            this.loadingLabel.schedule(() => {
                if (this._dotNumber >= 3) {
                    this._dotNumber = 1;
                }
                else {
                    this._dotNumber++;
                }
                let dot = "";
                for (let i = 0; i < this._dotNumber; i++) {
                    dot += ".";
                }
                this.loadingLabel.string = "正在努力加载(ง ˙o˙)ว!请耐心等待" + dot;
            }, 0.5);
        }
    };
    __decorate([
        property({ type: cc.Node })
    ], MainViewImpl.prototype, "contentParent", void 0);
    __decorate([
        property({ type: cc.Sprite })
    ], MainViewImpl.prototype, "titleSprite", void 0);
    __decorate([
        property({ type: [cc.Button], displayName: "Tabbar Buttons" })
    ], MainViewImpl.prototype, "tabbarButtons", void 0);
    __decorate([
        property({ type: [cc.SpriteFrame], displayName: "Tabbar Spriteframes" })
    ], MainViewImpl.prototype, "tabbarSpriteFrames", void 0);
    __decorate([
        property({ type: [cc.SpriteFrame], displayName: "Title Spriteframes" })
    ], MainViewImpl.prototype, "titleSpriteFrames", void 0);
    __decorate([
        property({ type: [sp.Skeleton], displayName: "Click skeleton ani array" })
    ], MainViewImpl.prototype, "clickAniArr", void 0);
    __decorate([
        property(cc.Node)
    ], MainViewImpl.prototype, "debugbtn", void 0);
    __decorate([
        property(cc.Node)
    ], MainViewImpl.prototype, "waitNode", void 0);
    __decorate([
        property(cc.Label)
    ], MainViewImpl.prototype, "loadingLabel", void 0);
    MainViewImpl = __decorate([
        ccclass,
        PresenterCCViewFactory_1.RegView(MainView_1.MainViewType, "prefab/ui/MainView")
    ], MainViewImpl);
    return MainViewImpl;
})();
exports.MainViewImpl = MainViewImpl;

cc._RF.pop();