import { _decorator, Component, Label, Node } from 'cc';
import { config } from '../../config';
import { tools } from '../../tools';
const { ccclass, property } = _decorator;

@ccclass('attributes_z_index')
export class attributes_z_index extends Component {
    @property(Node) check_select:Node = null;
    @property(Node) lab_select_zIndex:Node = null;
    private call_back = null;
    private zIndex = config.Zindex_type.Zindex_scene;
    public initView(call){
        this.call_back = call;
        this.check_select.on(Node.EventType.TOUCH_END,()=>{
            tools.show_select_z_index((z:number)=>{
                this.zIndex = z;
                this.update_att(this.zIndex)
                this.change()
            })
        })
    }
    
    change(){
        if(this.call_back!=null){
            this.call_back(this.zIndex)
        }
    }

    public update_att(zIndex:number){
        this.zIndex = zIndex;
        this.lab_select_zIndex.getComponent(Label).string = config.Zindex_type_map.get(this.zIndex)
    }
}


