123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160 |
- import { _decorator, Color, Component, EditBox, Label, Node, Sprite, Toggle } from 'cc';
- import { att_count_down, event_item, font_color_info, font_info } 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;
- @property(Node) font_size:Node = null;
- @property(Node) font_color: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)
- })
- this.font_color.on(Node.EventType.TOUCH_END,()=>{
- tools.show_set_color(this.font_color.getComponent(Sprite).color,(color:Color)=>{
- this.m_data.font_info.font_color = new font_color_info().infoColor(color) ;
- this.update_att(this.m_data)
- this.change()
- })
- })
- this.font_size.on('editing-did-ended',()=>{
- this.change()
- this.update_att(this.m_data)
- })
- }
- public update_att(data:att_count_down){
- this.m_data = data;
- console.log(' this.m_data.time_count=', this.m_data.time_count)
- console.log(' this.m_data.font_info.font_size=', this.m_data.font_info.font_size)
- 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}`:"无"
- if(this.m_data.font_info!=undefined&&this.m_data.font_info!=null){
- if(this.m_data.font_info.font_size==undefined||
- this.m_data.font_info.font_size==null||
- isNaN(this.m_data.font_info.font_size)) {
- this.m_data.font_info.font_size = 20
- } else {
- this.m_data.font_info.font_size = parseInt(this.font_size.getComponent(EditBox).string)
- }
- let color = this.m_data.font_info.font_color;
- this.font_color.getComponent(Sprite).color = new Color(color.r,color.g,color.b);
- this.font_size.getComponent(EditBox).string = this.m_data.font_info.font_size.toString()
- }else{
- this.m_data.font_info = new font_info;
- }
- }
- change(){
- this.m_data.is_show_time = this.toggle_enbale_time.getComponent(Toggle).isChecked ;
- let down_count_time = this.edit_down_count_time.getComponent(EditBox).string
- if(this.m_data.font_info!=undefined&&this.m_data.font_info!=null){
- if(this.m_data.font_info.font_size==undefined||
- this.m_data.font_info.font_size==null||
- isNaN(this.m_data.font_info.font_size)) {
- this.m_data.font_info.font_size = 20
- } else {
- this.m_data.font_info.font_size = parseInt(this.font_size.getComponent(EditBox).string)
- }
- }
- if(down_count_time.length>0) {
- this.m_data.time_count = parseInt(down_count_time);
- }
- if(this.call_back!=null){
- this.call_back(this.m_data)
- }
- }
- }
|