import { _decorator, Component, Node, Size } from 'cc';
import { interact_input_data } from '../../../data/data';
import { view_ui_att_item } from './view_ui_att_item';
import { config } from '../../config';
const { ccclass, property } = _decorator;

@ccclass('view_interact_input')
export class view_interact_input extends Component {
    @property(Node) img_number_0:Node = null;
    @property(Node) img_number_1:Node = null;
    @property(Node) img_number_2:Node = null;
    @property(Node) img_number_3:Node = null;
    @property(Node) img_number_4:Node = null;
    @property(Node) img_number_5:Node = null;
    @property(Node) img_number_6:Node = null;
    @property(Node) img_number_7:Node = null;
    @property(Node) img_number_8:Node = null;
    @property(Node) img_number_9:Node = null;
    @property(Node) img_number_xing:Node = null;
    @property(Node) img_number_jing:Node = null;

    @property(Node) att_number_0:Node = null;
    @property(Node) att_number_1:Node = null;
    @property(Node) att_number_2:Node = null;
    @property(Node) att_number_3:Node = null;
    @property(Node) att_number_4:Node = null;
    @property(Node) att_number_5:Node = null;
    @property(Node) att_number_6:Node = null;
    @property(Node) att_number_7:Node = null;
    @property(Node) att_number_8:Node = null;
    @property(Node) att_number_9:Node = null;
    @property(Node) att_number_xing:Node = null;
    @property(Node) att_number_jing:Node = null;

    @property(Node) img_bg:Node = null;
    @property(Node) input_default:Node = null;
    @property(Node) input_fail:Node = null;
    @property(Node) input_right:Node = null;

    @property(Node) font_info:Node = null;

    private m_data:interact_input_data = null;
    public updateView(data:interact_input_data){
        if(data===null){
            data = new interact_input_data;
        }
        this.m_data = data;
        this.img_bg.getComponent(view_ui_att_item).updateAtt(data.bg)
        data.bg = this.img_bg.getComponent(view_ui_att_item).getData()

        this.font_info.getComponent(view_ui_att_item).updateAtt(data.font,config.update_type.update_info)
        data.font = this.font_info.getComponent(view_ui_att_item).getData()
        let font_size = new Size(data.font.width,data.font.height)
        this.img_number_0.getComponent(view_ui_att_item).updateAtt(data.image_0,config.update_type.update_all)
        data.image_0 = this.img_number_0.getComponent(view_ui_att_item).getData(font_size)

        this.img_number_1.getComponent(view_ui_att_item).updateAtt(data.image_1,config.update_type.update_all)
        data.image_1 = this.img_number_1.getComponent(view_ui_att_item).getData(font_size)

        this.img_number_2.getComponent(view_ui_att_item).updateAtt(data.image_2,config.update_type.update_all)
        data.image_2 = this.img_number_2.getComponent(view_ui_att_item).getData(font_size)

        this.img_number_3.getComponent(view_ui_att_item).updateAtt(data.image_3,config.update_type.update_all)
        data.image_3 = this.img_number_3.getComponent(view_ui_att_item).getData(font_size)

        this.img_number_4.getComponent(view_ui_att_item).updateAtt(data.image_4,config.update_type.update_all)
        data.image_4 = this.img_number_4.getComponent(view_ui_att_item).getData(font_size)

        this.img_number_5.getComponent(view_ui_att_item).updateAtt(data.image_5,config.update_type.update_all)
        data.image_5 = this.img_number_5.getComponent(view_ui_att_item).getData(font_size)

        this.img_number_6.getComponent(view_ui_att_item).updateAtt(data.image_6,config.update_type.update_all)
        data.image_6 = this.img_number_6.getComponent(view_ui_att_item).getData(font_size)

        this.img_number_7.getComponent(view_ui_att_item).updateAtt(data.image_7,config.update_type.update_all)
        data.image_7 = this.img_number_7.getComponent(view_ui_att_item).getData(font_size)

        this.img_number_8.getComponent(view_ui_att_item).updateAtt(data.image_8,config.update_type.update_all)
        data.image_8 = this.img_number_8.getComponent(view_ui_att_item).getData(font_size)

        this.img_number_9.getComponent(view_ui_att_item).updateAtt(data.image_9,config.update_type.update_all)
        data.image_9 = this.img_number_8.getComponent(view_ui_att_item).getData(font_size)

        this.img_number_xing.getComponent(view_ui_att_item).updateAtt(data.image_xing,config.update_type.update_all)
        data.image_xing = this.img_number_xing.getComponent(view_ui_att_item).getData()

        this.img_number_jing.getComponent(view_ui_att_item).updateAtt(data.image_jing,config.update_type.update_all)
        data.image_jing = this.img_number_jing.getComponent(view_ui_att_item).getData()


        this.input_default.getComponent(view_ui_att_item).updateAtt(data.input_default)
        data.input_default = this.input_default.getComponent(view_ui_att_item).getData()

        this.input_fail.getComponent(view_ui_att_item).updateAtt(data.input_fail)
        data.input_fail = this.input_fail.getComponent(view_ui_att_item).getData()

        this.input_right.getComponent(view_ui_att_item).updateAtt(data.input_right)
        data.input_right = this.input_right.getComponent(view_ui_att_item).getData()

        //
        this.att_number_0.getComponent(view_ui_att_item).updateAtt(data.att_0,config.update_type.update_info)
        data.att_0 = this.att_number_0.getComponent(view_ui_att_item).getData()

        this.att_number_1.getComponent(view_ui_att_item).updateAtt(data.att_1,config.update_type.update_info)
        data.att_1 = this.att_number_1.getComponent(view_ui_att_item).getData()

        this.att_number_2.getComponent(view_ui_att_item).updateAtt(data.att_2,config.update_type.update_info)
        data.att_2 = this.att_number_2.getComponent(view_ui_att_item).getData()

        this.att_number_3.getComponent(view_ui_att_item).updateAtt(data.att_3,config.update_type.update_info)
        data.att_3 = this.att_number_3.getComponent(view_ui_att_item).getData()

        this.att_number_4.getComponent(view_ui_att_item).updateAtt(data.att_4,config.update_type.update_info)
        data.att_4 = this.att_number_4.getComponent(view_ui_att_item).getData()

        this.att_number_5.getComponent(view_ui_att_item).updateAtt(data.att_5,config.update_type.update_info)
        data.att_5 = this.att_number_5.getComponent(view_ui_att_item).getData()

        this.att_number_6.getComponent(view_ui_att_item).updateAtt(data.att_6,config.update_type.update_info)
        data.att_6 = this.att_number_6.getComponent(view_ui_att_item).getData()

        this.att_number_7.getComponent(view_ui_att_item).updateAtt(data.att_7,config.update_type.update_info)
        data.att_7 = this.att_number_7.getComponent(view_ui_att_item).getData()

        this.att_number_8.getComponent(view_ui_att_item).updateAtt(data.att_8,config.update_type.update_info)
        data.att_8 = this.att_number_8.getComponent(view_ui_att_item).getData()

        this.att_number_9.getComponent(view_ui_att_item).updateAtt(data.att_9,config.update_type.update_info)
        data.att_9 = this.att_number_9.getComponent(view_ui_att_item).getData()

        this.att_number_xing.getComponent(view_ui_att_item).updateAtt(data.att_xing,config.update_type.update_info)
        data.att_xing = this.att_number_xing.getComponent(view_ui_att_item).getData()

        this.att_number_jing.getComponent(view_ui_att_item).updateAtt(data.att_jing,config.update_type.update_info)
        data.att_jing = this.att_number_jing.getComponent(view_ui_att_item).getData()

    }

    public getData(){
        return this.m_data;
    }
}


