12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- import { _decorator, Component, EditBox, instantiate, Node, Prefab } from 'cc';
- import { scene_tips_rule_data, ui_att_item } from '../../../data/data';
- import { scene_tips_rule_item } from './scene_tips_rule_item';
- import { config } from '../../config';
- const { ccclass, property } = _decorator;
- @ccclass('attributes_scene_setting')
- export class attributes_scene_setting extends Component {
- @property(Prefab) itemPb:Prefab = null;
- @property(Node) rule_content:Node = null;
- @property(Node) btn_add_rule:Node = null;
- @property(Node) rule_find_tips:Node = null;
- @property(Node) tips:Node = null;
- @property(Node) answer:Node = null;
- @property(EditBox) edit_des:EditBox = null;
- private call_back = null;
- private m_data:scene_tips_rule_data = null;
- public initView(call){
- this.call_back = call;
- this.btn_add_rule.on(Node.EventType.TOUCH_END,()=>{
- this.addRule()
- })
-
- this.edit_des.node.on(EditBox.EventType.EDITING_DID_ENDED,()=>{
- this.m_data.scene_des = this.edit_des.string;
- this.update_att(this.m_data)
- })
- }
- public update_att(data:scene_tips_rule_data){
- this.m_data = data;
- this.rule_content.removeAllChildren()
- this.rule_content.destroyAllChildren()
- // if(this.rule_content.children.length===this.m_data.rule_list.length){
- // for (let index = 0; index < this.rule_content.children.length; index++) {
- // const element = this.rule_content.children[index];
- // element.getComponent(scene_tips_rule_item).initView(this.m_data.rule_list[index],this.m_data.rule_list.length,this.onTipsDelete.bind(this),config.attributes_list_type.scene_rule_tips)
- // }
- // }else{
- for (let index = 0; index < this.m_data.rule_list.length; index++) {
- let item = instantiate(this.itemPb)
- item.parent = this.rule_content
- item.getComponent(scene_tips_rule_item).initView(this.m_data.rule_list[index],this.m_data.rule_list.length,this.onTipsDelete.bind(this),config.attributes_list_type.scene_rule_tips)
- }
- // }
- this.edit_des.string = this.m_data.scene_des==undefined?"":this.m_data.scene_des;
- this.rule_find_tips.getComponent(scene_tips_rule_item).initView(this.m_data.rule_find_tips,-1,null,config.attributes_list_type.scene_rule_tips)
- this.tips.getComponent(scene_tips_rule_item).initView(this.m_data.tips_data.tips_tips,-1,null,config.attributes_list_type.scene_rule_tips)
- this.answer.getComponent(scene_tips_rule_item).initView(this.m_data.tips_data.tips_answer,-1,null,config.attributes_list_type.scene_rule_tips)
- }
- onTipsDelete(index:number){
- this.m_data.rule_list.splice(index,1)
- }
- addRule(){
- let item = instantiate(this.itemPb)
- item.parent = this.rule_content;
- let data = new ui_att_item
- item.getComponent(scene_tips_rule_item).initView(data,this.m_data.rule_list.length,this.onTipsDelete.bind(this),config.attributes_list_type.scene_rule_tips)
- this.m_data.rule_list.push(data)
- }
- }
|