import { _decorator, Component, EditBox, Label, Node, Toggle } from 'cc'; import { att_count_down, event_item } from '../../../data/data'; import { tools } from '../../tools'; import { question_btn_info } from './question_btn_info'; import { config } from '../../config'; import { Attributes } from '../Attributes'; const { ccclass, property } = _decorator; @ccclass('attributes_count_down') export class attributes_count_down extends Component { @property(Node) ProgressBar_Bg:Node = null; @property(Node) ProgressBar_Bar:Node = null; @property(Node) img_text:Node = null; @property(Node) toggle_enbale_time:Node = null; @property(Node) edit_down_count_time:Node = null; //event @property(Node) btn_finish_event:Node = null; @property(Node) btn_fail_event:Node = null; @property(Node) btn_start_event:Node = null; @property(Node) lab_finish_event:Node = null; @property(Node) lab_fail_event:Node = null; @property(Node) lab_start_event:Node = null; @property(Node) clear_finish_event:Node = null; @property(Node) clear_fail_event:Node = null; @property(Node) clear_start_event:Node = null; private call_back = null; private m_data:att_count_down = null; public initView(call){ this.call_back = call; this.edit_down_count_time.on('editing-did-ended',()=>{ this.change() this.update_att(this.m_data) }) this.toggle_enbale_time.on('toggle',()=>{ this.change() this.update_att(this.m_data) }) this.btn_finish_event.on(Node.EventType.TOUCH_END,()=>{ let list = Attributes.Singleton.getEventList() tools.show_select_evele_list(list,(data:event_item)=>{ this.m_data.finish_event_id = data.event_id; this.change() this.update_att(this.m_data) }) }) this.btn_fail_event.on(Node.EventType.TOUCH_END,()=>{ let list = Attributes.Singleton.getEventList() tools.show_select_evele_list(list,(data:event_item)=>{ this.m_data.fail_event_id = data.event_id; this.change() this.update_att(this.m_data) }) }) this.btn_start_event.on(Node.EventType.TOUCH_END,()=>{ let list = Attributes.Singleton.getEventList() tools.show_select_evele_list(list,(data:event_item)=>{ if(data.type!=config.event_type.collect_event){ return tools.showToast("必须设置收集事件") } this.m_data.start_event_id = data.event_id; this.change() this.update_att(this.m_data) }) }) this.clear_finish_event.on(Node.EventType.TOUCH_END,()=>{ this.m_data.finish_event_id = -1; this.change() this.update_att(this.m_data) }) this.clear_fail_event.on(Node.EventType.TOUCH_END,()=>{ this.m_data.fail_event_id = -1; this.change() this.update_att(this.m_data) }) this.clear_start_event.on(Node.EventType.TOUCH_END,()=>{ this.m_data.start_event_id = -1; this.change() this.update_att(this.m_data) }) } public update_att(data:att_count_down){ this.m_data = data; this.ProgressBar_Bg.getComponent(question_btn_info).initView(this.m_data.ProgressBar_Bg,1,null,config.attributes_list_type.count_down) this.ProgressBar_Bar.getComponent(question_btn_info).initView(this.m_data.ProgressBar_Bar,2,null,config.attributes_list_type.count_down) this.img_text.getComponent(question_btn_info).initView(this.m_data.img_text,3,null,config.attributes_list_type.count_down) this.toggle_enbale_time.getComponent(Toggle).isChecked = this.m_data.is_show_time; this.edit_down_count_time.getComponent(EditBox).string = this.m_data.time_count.toString() this.lab_finish_event.getComponent(Label).string = this.m_data.finish_event_id!=-1?`绑定的id${this.m_data.finish_event_id}`:"无" this.lab_fail_event.getComponent(Label).string = this.m_data.fail_event_id!=-1?`绑定的id${this.m_data.fail_event_id}`:"无" this.lab_start_event.getComponent(Label).string = this.m_data.start_event_id!=-1?`绑定的id${this.m_data.start_event_id}`:"无" } change(){ this.m_data.is_show_time = this.toggle_enbale_time.getComponent(Toggle).isChecked ; this.m_data.time_count = parseInt(this.edit_down_count_time.getComponent(EditBox).string); if(this.call_back!=null){ this.call_back(this.m_data) } } }