attributes_top.ts 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. import { _decorator, Component, Label, Node, Toggle } from 'cc';
  2. import { att_top_data, event_item, scene_item_data } from '../../../data/data';
  3. import { tools } from '../../tools';
  4. import { config } from '../../config';
  5. import { att_widget_set_view } from '../uiWidget/att_widget_set_view';
  6. import { att_res_set_view } from '../uiWidget/att_res_set_view';
  7. import { single_ui_widget_info } from '../uiWidget/single_ui_widget_info';
  8. import { Attributes } from '../Attributes';
  9. const { ccclass, property } = _decorator;
  10. @ccclass('attributes_top')
  11. export class attributes_top extends Component {
  12. @property(Node) check_select_open_jump:Node = null;
  13. @property(Node) check_select_open_close:Node = null;
  14. @property(Node) btn_select_type:Node = null;
  15. @property(Node) lab_select_type:Node = null;
  16. @property(Node) btn_set_res:Node = null;
  17. @property(Node) btn_set_att:Node = null;
  18. @property(Node) set_att_view:Node = null;
  19. @property(Node) set_res_view:Node = null;
  20. @property(Node) btn_set_res_close:Node = null;
  21. @property(Node) btn_set_att_close:Node = null;
  22. @property(Node) close_att_node:Node = null;
  23. @property(Node) jump_att_node:Node = null;
  24. @property(Node) btn_add_child_scene:Node = null;
  25. @property(Node) lab_scene:Node = null;
  26. //event
  27. @property(Node) btn_close_event:Node = null;
  28. @property(Node) btn_finish_event:Node = null;
  29. @property(Node) btn_fail_event:Node = null;
  30. @property(Node) lab_close_event:Node = null;
  31. @property(Node) lab_finish_event:Node = null;
  32. @property(Node) lab_fail_event:Node = null;
  33. @property(Node) clear_close_event:Node = null;
  34. @property(Node) clear_finish_event:Node = null;
  35. @property(Node) clear_fail_event:Node = null;
  36. private call_back = null;
  37. private m_data:att_top_data = null;
  38. public initView(call){
  39. this.call_back = call;
  40. this.check_select_open_jump.on(Node.EventType.TOUCH_END,()=>{
  41. this.m_data.is_open_jump =!this.m_data.is_open_jump;
  42. this.change()
  43. })
  44. this.check_select_open_close.on(Node.EventType.TOUCH_END,()=>{
  45. this.m_data.is_open_close =!this.m_data.is_open_close;
  46. this.change()
  47. })
  48. this.close_att_node.getComponent(single_ui_widget_info).initView((data)=>{
  49. this.m_data.close_info = data;
  50. this.change()
  51. })
  52. this.jump_att_node.getComponent(single_ui_widget_info).initView((data)=>{
  53. this.m_data.jump_info = data;
  54. this.change()
  55. })
  56. this.btn_close_event.on(Node.EventType.TOUCH_END,()=>{
  57. let list = Attributes.Singleton.getEventList()
  58. tools.show_select_evele_list(list,(data:event_item)=>{
  59. this.m_data.close_event_id = data.event_id;
  60. this.change()
  61. this.update_att(this.m_data)
  62. })
  63. })
  64. this.btn_finish_event.on(Node.EventType.TOUCH_END,()=>{
  65. let list = Attributes.Singleton.getEventList()
  66. tools.show_select_evele_list(list,(data:event_item)=>{
  67. this.m_data.finish_event_id = data.event_id;
  68. this.change()
  69. this.update_att(this.m_data)
  70. })
  71. })
  72. this.btn_fail_event.on(Node.EventType.TOUCH_END,()=>{
  73. let list = Attributes.Singleton.getEventList()
  74. tools.show_select_evele_list(list,(data:event_item)=>{
  75. this.m_data.fail_event_id = data.event_id;
  76. this.change()
  77. this.update_att(this.m_data)
  78. })
  79. })
  80. this.clear_close_event.on(Node.EventType.TOUCH_END,()=>{
  81. this.m_data.close_event_id = -1;
  82. this.change()
  83. this.update_att(this.m_data)
  84. })
  85. this.clear_finish_event.on(Node.EventType.TOUCH_END,()=>{
  86. this.m_data.finish_event_id = -1;
  87. this.change()
  88. this.update_att(this.m_data)
  89. })
  90. this.clear_fail_event.on(Node.EventType.TOUCH_END,()=>{
  91. this.m_data.fail_event_id = -1;
  92. this.change()
  93. this.update_att(this.m_data)
  94. })
  95. this.btn_select_type.on(Node.EventType.TOUCH_END,()=>{
  96. if(this.m_data.top_ui_type===config.top_view_type.__null){
  97. tools.show_select_ui_top_type((type)=>{
  98. if( this.m_data.top_ui_type != type){
  99. // this.m_data.clearAll()
  100. }
  101. this.m_data.top_ui_type = type;
  102. this.change()
  103. this.update_att(this.m_data)
  104. })
  105. }
  106. })
  107. this.btn_set_res.on(Node.EventType.TOUCH_END,()=>{
  108. this.set_att_view.active = false;
  109. this.set_res_view.active = true;
  110. })
  111. this.btn_set_att.on(Node.EventType.TOUCH_END,()=>{
  112. this.set_att_view.active = true;
  113. this.set_res_view.active = false;
  114. })
  115. this.btn_set_res_close.on(Node.EventType.TOUCH_END,()=>{
  116. this.set_res_view.active = false;
  117. })
  118. this.btn_set_att_close.on(Node.EventType.TOUCH_END,()=>{
  119. this.set_att_view.active = false;
  120. })
  121. this.btn_add_child_scene.on(Node.EventType.TOUCH_END,()=>{
  122. Attributes.Singleton.ShowALlChildScene((scene:scene_item_data)=>{
  123. this.m_data._interact_scene_data.scene = scene;
  124. this.change()
  125. this.update_att(this.m_data)
  126. })
  127. })
  128. }
  129. change(){
  130. if(this.call_back!=null){
  131. this.call_back(this.m_data)
  132. }
  133. }
  134. public update_att(data:att_top_data){
  135. this.m_data = data;
  136. this.close_att_node.getComponent(single_ui_widget_info).updateInfo(data.close_info)
  137. this.jump_att_node.getComponent(single_ui_widget_info).updateInfo(data.jump_info)
  138. this.lab_select_type.getComponent(Label).string = config.top_view_type_map.get(this.m_data.top_ui_type)
  139. this.check_select_open_jump.getComponent(Toggle).isChecked = this.m_data.is_open_jump;
  140. this.check_select_open_close.getComponent(Toggle).isChecked = this.m_data.is_open_close;
  141. if(this.m_data.top_ui_type===config.top_view_type.__null){
  142. this.btn_set_res.active = false;
  143. this.btn_set_att.active = false;
  144. this.btn_select_type.active = true;
  145. }else{
  146. this.btn_set_res.active = true;
  147. this.btn_set_att.active = true;
  148. this.btn_select_type.active = false;
  149. this.set_att_view.getComponent(att_widget_set_view).updateStatus(this.m_data)
  150. this.set_res_view.getComponent(att_res_set_view).updateStatus(this.m_data)
  151. }
  152. if(this.m_data.top_ui_type==config.top_view_type.interact_scene){
  153. this.btn_add_child_scene.active = true
  154. this.btn_set_res.active = false;
  155. this.btn_set_att.active = false;
  156. this.lab_scene.getComponent(Label).string = this.m_data._interact_scene_data.scene ?`当前的子场景名字:${this.m_data._interact_scene_data.scene.scene_diy_name}`:"添加子场景"
  157. }else{
  158. this.btn_add_child_scene.active = false
  159. }
  160. this.lab_close_event.getComponent(Label).string = this.m_data.close_event_id!=-1?`绑定的id${this.m_data.close_event_id}`:"无"
  161. this.lab_finish_event.getComponent(Label).string = this.m_data.finish_event_id!=-1?`绑定的id${this.m_data.finish_event_id}`:"无"
  162. this.lab_fail_event.getComponent(Label).string = this.m_data.fail_event_id!=-1?`绑定的id${this.m_data.fail_event_id}`:"无"
  163. }
  164. }