119881ba-3c1c-48cc-9108-491015644c5e.js 5.54 KB
"use strict";
cc._RF.push(module, '11988G6PBxIzJEISRAVZExe', 'GiftListItemImpl');
// script/game/ui/view/impl/message/GiftListItemImpl.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.GiftListItemImpl = void 0;
const simba_cc_resutils_1 = require("simba-cc-resutils");
const simba_sdk_1 = require("simba-sdk");
const AVG_1 = require("../../../../../avg/AVG");
const CCDummyObjects_1 = require("../../../../../common/CCDummyObjects");
const CCViewBase_1 = require("../../../../../common/classbase/CCViewBase");
const GameTextData_1 = require("../../../../../common/gameplay/gamedata/GameTextData");
const UIManager_1 = require("../../../../../common/gameplay/managers/UIManager");
const GameModelManager_1 = require("../../../../model/GameModelManager");
const AlertDialogViewPresenter_1 = require("../../../presenter/AlertDialogViewPresenter");
const { ccclass, property } = cc._decorator;
let GiftListItemImpl = /** @class */ (() => {
    let GiftListItemImpl = class GiftListItemImpl extends CCViewBase_1.CCPureView {
        constructor() {
            super(...arguments);
            //#region editor bindings
            this.checkNode = CCDummyObjects_1.DummyNode;
            this.bgSprite = CCDummyObjects_1.DummySprite;
            this.iconSprite = CCDummyObjects_1.DummySprite;
            this.likeSprite = CCDummyObjects_1.DummySprite;
            this.numLabel = CCDummyObjects_1.DummyLabel;
            this.likeLabel = CCDummyObjects_1.DummyLabel;
            this.bgSFs = [];
            this.likeSFs = [];
            //#endregion
            this._likeLabelColors = [cc.color(115, 105, 192), cc.color(148, 148, 148)];
        }
        onClick() {
            let storeUnlocked = AVG_1.GameRecord.recordVariables["MallViewPresenter"] === 1;
            if (this._props.count === 0) {
                if (storeUnlocked) {
                    this.showEnterStoreAlert();
                }
                else {
                    UIManager_1.UIManager.showToast(GameModelManager_1.GameModelManager.getLanguageTxt(GameTextData_1.GameTextData.GAME_TEXT_MAIN_FUNCTION_NOT_OPEN));
                }
            }
            else {
                this._props.onClick();
            }
        }
        get checked() { return this.checkNode.active; }
        onLoad() {
            super.onLoad();
            this.bindProp("count", (v) => {
                this.numLabel.string = v.toString();
                let index = v === 0 ? 1 : 0;
                this.bgSprite.spriteFrame = this.bgSFs[index];
                this.likeSprite.spriteFrame = this.likeSFs[index];
                this.likeLabel.node.color = this._likeLabelColors[index];
                this.iconSprite.setMaterial(0, this.iconSprite.getMaterials()[index + 1]);
            });
            this.bindProp("addLike", (v) => this.likeLabel.string = "+" + v);
            this.bindProp("icon", async (v) => {
                if (v) {
                    let sf = await simba_cc_resutils_1.ResUtils.loadRes(v, cc.SpriteFrame, 2);
                    if (cc.isValid(this.iconSprite)) {
                        this.iconSprite.spriteFrame = sf;
                    }
                }
            });
            this.bindProp("select", this.checkNode, "active");
            // this.node.on(cc.Node.EventType.)
        }
        showEnterStoreAlert() {
            let temp = {
                dataptr: {},
                titlecontent: GameModelManager_1.GameModelManager.getLanguageTxt(GameTextData_1.GameTextData.GAME_TEXT_NO_THIS_PROP_TITLE_VALUE),
                content: GameModelManager_1.GameModelManager.getLanguageTxt(GameTextData_1.GameTextData.GAME_TEXT_ENTER_STORE_VALUE),
                ishasad: false,
                istwobtn: true,
                adconfig: "",
                // items: [],
                hasBanner: false,
                callback: (type, ret, param) => {
                    simba_sdk_1.SDK.hideBannerAd();
                }
            };
            UIManager_1.UIManager.pushPresenter(AlertDialogViewPresenter_1.default, temp);
        }
    };
    __decorate([
        property(cc.Node)
    ], GiftListItemImpl.prototype, "checkNode", void 0);
    __decorate([
        property(cc.Sprite)
    ], GiftListItemImpl.prototype, "bgSprite", void 0);
    __decorate([
        property(cc.Sprite)
    ], GiftListItemImpl.prototype, "iconSprite", void 0);
    __decorate([
        property(cc.Sprite)
    ], GiftListItemImpl.prototype, "likeSprite", void 0);
    __decorate([
        property(cc.Label)
    ], GiftListItemImpl.prototype, "numLabel", void 0);
    __decorate([
        property(cc.Label)
    ], GiftListItemImpl.prototype, "likeLabel", void 0);
    __decorate([
        property([cc.SpriteFrame])
    ], GiftListItemImpl.prototype, "bgSFs", void 0);
    __decorate([
        property([cc.SpriteFrame])
    ], GiftListItemImpl.prototype, "likeSFs", void 0);
    GiftListItemImpl = __decorate([
        ccclass
    ], GiftListItemImpl);
    return GiftListItemImpl;
})();
exports.GiftListItemImpl = GiftListItemImpl;

cc._RF.pop();