import { _decorator, Component, Label, Node } from 'cc';
import { att_ani_data, event_item_scene_ani } from '../../../data/data';
import { control } from '../control';
import { main } from '../../main';
import { tools } from '../../tools';
const { ccclass, property } = _decorator;

@ccclass('event_scene_ani')
export class event_scene_ani extends Component {
    private m_data:event_item_scene_ani = null;
    @property(Node) btn_select_widget:Node = null;
    @property(Node) lab_select_widget:Node = null;
    public initView(data:event_item_scene_ani){
        this.m_data = data;
        this.btn_select_widget.on(Node.EventType.TOUCH_END,()=>{
            let scene_data = main.Singleton.edit_scene_view.getCurSelectScene()

            if(scene_data.page_list[0].att!=null){
                let ani_list = scene_data.page_list[0].att.animation_list;
                if(ani_list.length>0){
                    tools.show_select_animation_list(ani_list,(item:att_ani_data)=>{
                        this.m_data.ani_id = item.ani_id;
                        this.updateStatus()
                    },this.m_data.ani_id)
                }
            }
            
        })
        this.updateStatus()
    
    }

    protected onDestroy(): void {
      
    }
    updateStatus(){
        if(this.m_data.ani_id===-1){
            this.lab_select_widget.getComponent(Label).string = "选择动画"
        }else{
            this.lab_select_widget.getComponent(Label).string = "选择动画id："+this.m_data.ani_id;
        }
    }
}


