7cbed840-23cb-4f8c-9a98-d6a4d554ee6e.js 3.94 KB
"use strict";
cc._RF.push(module, '7cbedhAI8tPjJqY1qTVVO5u', 'MainInfoSubviewImpl');
// script/game/ui/view/impl/MainInfoSubviewImpl.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.MainInfoViewImpl = void 0;
const CCDummyObjects_1 = require("../../../../common/CCDummyObjects");
const CCViewBase_1 = require("../../../../common/classbase/CCViewBase");
const PresenterCCViewFactory_1 = require("../../PresenterCCViewFactory");
const MainInfoSubviewiew_1 = require("../type/MainInfoSubviewiew");
const { ccclass, property } = cc._decorator;
let MainInfoViewImpl = /** @class */ (() => {
    let MainInfoViewImpl = class MainInfoViewImpl extends CCViewBase_1.CCPureSubview {
        constructor() {
            super(...arguments);
            //#region  editor bindings
            this.timeLabel = CCDummyObjects_1.DummyLabel;
            this.energySprite = CCDummyObjects_1.DummySprite;
            this.energyLabel = CCDummyObjects_1.DummyLabel;
            this.energySprites = [];
            this.coolddown = CCDummyObjects_1.DummyLabel;
            this.onEnergyClickCallback = () => {
                this._props.onClick();
            };
            this.updateTime = () => {
                let now = new Date;
                this.timeLabel.string = `${now.getHours()}:${(now.getMinutes() < 10 ? '0' : '') + now.getMinutes()}`;
                this.scheduleOnce(() => {
                    this.scheduleOnce(this.updateTime, 60 - now.getSeconds());
                });
            };
        }
        //#endregion
        onLoad() {
            this.updateTime();
            this.energySprite.type = cc.Sprite.Type.FILLED;
            this.energySprite.fillType = cc.Sprite.FillType.VERTICAL;
            this.bindProp("energycontent", (value) => {
                this.energyLabel.string = value;
            });
            this.bindProp("timecontent", (value) => {
                if (value === "") {
                    this.coolddown.node.active = false;
                }
                else {
                    this.coolddown.node.active = true;
                    this.coolddown.string = value;
                }
            });
            this.bindProp("energybackindex", (value) => {
                this.energySprite.spriteFrame = this.energySprites[value];
            });
            this.bindProp("energy", (value) => {
                this.energySprite.fillRange = value;
            });
            this.energySprite.node.on(cc.Node.EventType.TOUCH_END, this.onEnergyClickCallback, this);
            this.energyLabel.node.on(cc.Node.EventType.TOUCH_END, this.onEnergyClickCallback, this);
        }
    };
    __decorate([
        property(cc.Label)
    ], MainInfoViewImpl.prototype, "timeLabel", void 0);
    __decorate([
        property(cc.Sprite)
    ], MainInfoViewImpl.prototype, "energySprite", void 0);
    __decorate([
        property(cc.Label)
    ], MainInfoViewImpl.prototype, "energyLabel", void 0);
    __decorate([
        property(cc.SpriteFrame)
    ], MainInfoViewImpl.prototype, "energySprites", void 0);
    __decorate([
        property(cc.Label)
    ], MainInfoViewImpl.prototype, "coolddown", void 0);
    MainInfoViewImpl = __decorate([
        ccclass,
        PresenterCCViewFactory_1.RegSubview(MainInfoSubviewiew_1.MainInfoSubviewType)
    ], MainInfoViewImpl);
    return MainInfoViewImpl;
})();
exports.MainInfoViewImpl = MainInfoViewImpl;

cc._RF.pop();