/**
 * 村长镇长信息面板
 */
cc.Class({
    extends: cc.Component,

    properties: {
        title: {
            default: null,
            type: cc.Node,
            serializable: true,
        },
        infoButton: {
            default: null,
            type: cc.Node,
            serializable: true,
        },
        content: {
            default: null,
            type: cc.Label,
            serializable: true,
        },
        callback: {
            default: null,
            visible: false
        },
        confirmLabel: {
            default: null,
            type: cc.Label,
            serializable: true,
        },
        villageInfoTitleText:{
            default: null,
            tip: "村长面板文字图片",
            type: cc.SpriteFrame,
            serializable: true,
        },
        villageInfoButton:{
            default: null,
            tip: "村长按钮图片",
            type: cc.SpriteFrame,
            serializable: true,
        },
      
    },

    /**
     * 设置面板信息
     */
    setVillageAndMayorInfo(context) {
        //let { title, content, confirmText, callback } = context;
        let {content, confirmText, callback ,type} = context;
        this.node.active = true;
        this.callback = callback;
        //this.title.string = title;
        this.content.string = content;
        // this.confirmLabel.string = confirmText;
        // console.log(type);
        if(type == "village"){
            this.title.getComponent(cc.Sprite).spriteFrame = this.villageInfoTitleText;
            this.infoButton.getComponent(cc.Sprite).spriteFrame = this.villageInfoButton;
        }
    },

    onConfirm(e) {
        if (this.callback)
            this.callback(e);
    },

    onCancel(e) {
        this.node.active = false;
    }
});
