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

@ccclass('sceme_type_select_item')
export class sceme_type_select_item extends Component {
    @property(Node) lab_name:Node = null;
    @property(Node) check_mask:Node = null;
    @property(Node) check:Node = null;
    @property(Node) scenes_node:Node = null;
    @property(Node) check_full:Node = null;

    @property(Node) btn_add:Node = null;
    @property(Node) btn_cancel:Node = null;
    private m_data:scene_item_data = new scene_item_data("",0);
    private m_call_back = null;
    public initView(call_back){
        this.m_call_back = call_back;
        this.btn_add.on(Node.EventType.TOUCH_END,()=>{
            if(this.m_call_back!=null){
                this.m_call_back(this.getData())
            }
            this.close()
        })
        this.btn_cancel.on(Node.EventType.TOUCH_END,()=>{
            this.close()
        })
        this.check_full.on(Node.EventType.TOUCH_END,()=>{
            this.updateStatus()
        })
        this.updateStatus()
    }

    updateStatus(){
        if(!this.check_full.getComponent(Toggle).isChecked){
            this.check_mask.active = true;
        }else{
            this.check_mask.active = false;
            this.check.getComponent(Toggle).isChecked = false;
        }
    }

    public getData(){
        this.m_data.is_full_screen = this.check_full.getComponent(Toggle).isChecked;
        this.m_data.is_check_mask = this.check.getComponent(Toggle).isChecked;
        return this.m_data;
    }

    close(){
        this.node.removeFromParent()
    }
}


