Attributes.ts 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. import { _decorator, Component, Director, director, instantiate, Node, Size, Vec2, Vec3 } from 'cc';
  2. import { ClientEvent } from '../clientEvent';
  3. import { config } from '../config';
  4. import { att_ani_data, att_click_data, att_count_down, att_drag_data, att_question_select, att_text_sound_data, att_top_data, attributes_data, scene_tips_rule_data, widget_item_data } from '../../data/data';
  5. import { attributes_name } from './attributes/attributes_name';
  6. import { attributes_x_y } from './attributes/attributes_x_y';
  7. import { attributes_w_h } from './attributes/attributes_w_h';
  8. import { attributes_res } from './attributes/attributes_res';
  9. import { main } from '../main';
  10. import { attributes_origin } from './attributes/attributes_origin';
  11. import { attributes_delete } from './attributes/attributes_delete';
  12. import { attributes_drop } from './attributes/attributes_drop';
  13. import { attributes_slide } from './attributes/attributes_slide';
  14. import { attributes_click } from './attributes/attributes_click';
  15. import { attributes_be_active } from './attributes/attributes_be_active';
  16. import { attributes_animation } from './attributes/attributes_animation';
  17. import { attributes_active } from './attributes/attributes_active';
  18. import { tools } from '../tools';
  19. import { attributes_top } from './attributes/attributes_top';
  20. import { attributes_text_sound } from './attributes/attributes_text_sound';
  21. import { attributes_question_select } from './attributes/attributes_question_select';
  22. import { attributes_count_down } from './attributes/attributes_count_down';
  23. import { attributes_z_index } from './attributes/attributes_z_index';
  24. import { attributes_dir } from './attributes/attributes_dir';
  25. import { attributes_show } from './attributes/attributes_show';
  26. import { attributes_scene_setting } from './attributes/attributes_scene_setting';
  27. import { attributes_remark } from './attributes/attributes_remark';
  28. import { attributes_rotation } from './attributes/attributes_rotation';
  29. import { attributes_anchor } from './attributes/attributes_anchor';
  30. const { ccclass, property } = _decorator;
  31. @ccclass('Attributes')
  32. export class Attributes extends Component {
  33. private attributes_map:Map<string,Node> = new Map
  34. @property(Node) attributes_name:Node = null;
  35. @property(Node) attributes_remark:Node = null;
  36. @property(Node) attributes_x_y:Node = null;
  37. @property(Node) attributes_w_h:Node = null;
  38. @property(Node) attributes_anchor:Node = null;
  39. @property(Node) attributes_rotation:Node = null;
  40. @property(Node) attributes_res:Node = null;
  41. @property(Node) attributes_origin:Node = null;
  42. @property(Node) attributes_be_event:Node = null; //被动事件
  43. @property(Node) attributes_animation:Node = null; //动画
  44. @property(Node) attributes_drop:Node = null;
  45. @property(Node) attributes_click:Node = null;
  46. @property(Node) attributes_slide:Node = null;
  47. @property(Node) attributes_delete:Node = null;
  48. @property(Node) attributes_be_active:Node = null;
  49. @property(Node) attributes_active:Node = null;
  50. @property(Node) attributes_top:Node = null;
  51. @property(Node) attributes_text_sound:Node = null;
  52. @property(Node) attributes_question_select:Node = null;
  53. @property(Node) attributes_count_down:Node = null;
  54. @property(Node) attributes_z_index:Node = null;
  55. @property(Node) attributes_dir:Node = null;
  56. @property(Node) attributes_show:Node = null;
  57. @property(Node) attributes_scene_setting:Node = null;
  58. @property(Node) content:Node = null;
  59. private cur_att_data:attributes_data = null;
  60. private _main:main = null;
  61. public static Singleton:Attributes = null;
  62. public static is_show_more_scene_arrow:boolean = true; //是否显示多场景箭头
  63. start() {
  64. Attributes.Singleton = this;
  65. ClientEvent.on(config.Event.UpdateAttributes,this.UpdateAttributes,this)
  66. ClientEvent.on(config.Event.ShowWidgetList,this.ShowWidgetList,this)
  67. this.attributes_map.set("name",this.attributes_name)
  68. this.attributes_map.set("remark",this.attributes_remark)
  69. this.attributes_map.set("pos",this.attributes_x_y)
  70. this.attributes_map.set("size",this.attributes_w_h)
  71. this.attributes_map.set("anchor",this.attributes_anchor)
  72. this.attributes_map.set("rotation",this.attributes_rotation)
  73. this.attributes_map.set("url",this.attributes_res)
  74. this.attributes_map.set("origin",this.attributes_origin)
  75. // this.attributes_map.set("be_event",this.attributes_be_event)
  76. this.attributes_map.set("animation",this.attributes_animation)
  77. this.attributes_map.set("drop",this.attributes_drop)
  78. this.attributes_map.set("click",this.attributes_click)
  79. this.attributes_map.set("slide",this.attributes_slide)
  80. this.attributes_map.set("delete",this.attributes_delete)
  81. this.attributes_map.set("be_active",this.attributes_be_active)
  82. this.attributes_map.set("active",this.attributes_active)
  83. this.attributes_map.set("top",this.attributes_top)
  84. this.attributes_map.set("text_sound",this.attributes_text_sound)
  85. this.attributes_map.set("question_select",this.attributes_question_select)
  86. this.attributes_map.set("count_down",this.attributes_count_down)
  87. this.attributes_map.set("z_index",this.attributes_z_index)
  88. this.attributes_map.set("dir",this.attributes_dir)
  89. this.attributes_map.set("show",this.attributes_show)
  90. this.attributes_map.set("scene_set",this.attributes_scene_setting)
  91. this.attributes_remark.getComponent(attributes_remark).initView(this.onChangeRemark.bind(this))
  92. this.attributes_scene_setting.getComponent(attributes_scene_setting).initView(this.onChangSceneTipsRuleStatus.bind(this),this.onChangSceneAttributesStatus.bind(this))
  93. this.attributes_show.getComponent(attributes_show).initView(this.onChangShowStatus.bind(this))
  94. this.attributes_dir.getComponent(attributes_dir).initView(this.onChangeDir.bind(this))
  95. this.attributes_z_index.getComponent(attributes_z_index).initView(this.onChangeZIndex.bind(this))
  96. this.attributes_count_down.getComponent(attributes_count_down).initView(this.onChangeCountDown.bind(this))
  97. this.attributes_question_select.getComponent(attributes_question_select).initView(this.onChangeQuestionSelect.bind(this))
  98. this.attributes_text_sound.getComponent(attributes_text_sound).initView(this.onChangeTextSound.bind(this))
  99. this.attributes_top.getComponent(attributes_top).initView(this.onChangeTop.bind(this))
  100. this.attributes_active.getComponent(attributes_active).initView(this.onChangeActive.bind(this))
  101. this.attributes_animation.getComponent(attributes_animation).initView(this.onChangeAnimation.bind(this))
  102. this.attributes_be_active.getComponent(attributes_be_active).initView(this.onChangBeActiveStatus.bind(this))
  103. this.attributes_click.getComponent(attributes_click).initView(this.onChangClick.bind(this))
  104. this.attributes_slide.getComponent(attributes_slide).initView(this.onChangSlide.bind(this))
  105. this.attributes_drop.getComponent(attributes_drop).initView(this.onChangDrag.bind(this),this.onChangDragErrBackStatus.bind(this))
  106. this.attributes_delete.getComponent(attributes_delete).initView(this.onDelete.bind(this))
  107. this.attributes_w_h.getComponent(attributes_w_h).initView(this.onChangeSize.bind(this))
  108. this.attributes_x_y.getComponent(attributes_x_y).initView(this.onChangePos.bind(this))
  109. this.attributes_rotation.getComponent(attributes_rotation).initView(this.onChangeRotation.bind(this))
  110. this.attributes_anchor.getComponent(attributes_anchor).initView(this.onChangeAnchor.bind(this))
  111. this.attributes_origin.getComponent(attributes_origin).initView(this.onChangeOrigin.bind(this))
  112. this.hideAllAtt()
  113. }
  114. onChangeRemark(text: string) {
  115. this.cur_att_data.remark = text
  116. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.remark)
  117. }
  118. onChangeAnchor(anchor:Vec2){
  119. this.cur_att_data.anchor_x = anchor.x
  120. this.cur_att_data.anchor_y = anchor.y
  121. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.anchor)
  122. }
  123. onChangeRotation(rotation: number) {
  124. this.cur_att_data.rotation = rotation
  125. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.rotation)
  126. }
  127. onChangSceneTipsRuleStatus(data:scene_tips_rule_data){
  128. this.cur_att_data.scene_rule_tips_data = data;
  129. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.scene_rule_tips)
  130. }
  131. onChangSceneAttributesStatus(data:attributes_data) {
  132. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.show_more_scene_arrow)
  133. }
  134. onChangShowStatus(show:boolean){
  135. this.cur_att_data.is_show = show;
  136. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.show)
  137. }
  138. onChangeDir(dir:number){
  139. this.cur_att_data.img_dir = dir;
  140. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.dir)
  141. }
  142. onChangeZIndex(zIndex:number){
  143. this.cur_att_data.zIndex = zIndex;
  144. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.zIndex)
  145. }
  146. onChangeCountDown(data:att_count_down){
  147. this.cur_att_data.count_down = data;
  148. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.count_down)
  149. }
  150. onChangeQuestionSelect(data:att_question_select){
  151. this.cur_att_data.question_select = data;
  152. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.question_select)
  153. }
  154. onChangeTextSound(data:att_text_sound_data){
  155. this.cur_att_data.text_sound_data = data;
  156. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.text_sound)
  157. }
  158. onChangeTop(data:att_top_data){
  159. this.cur_att_data.top_data = data;
  160. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.top)
  161. }
  162. onChangeActive(active:boolean){
  163. this.cur_att_data.edit_active = active;
  164. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.active)
  165. }
  166. onChangeAnimation(ani_list:att_ani_data[]){
  167. this.cur_att_data.animation_list = ani_list;
  168. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.animation)
  169. }
  170. onChangBeActiveStatus(is_be_active:boolean){
  171. this.cur_att_data.is_interaction = is_be_active;
  172. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.is_interaction)
  173. }
  174. onChangClick(data:att_click_data){
  175. this.cur_att_data.click_data = data;
  176. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.click)
  177. }
  178. onChangSlide(dir:number,num:number,distance:number){
  179. this.cur_att_data.slide_data.slide_dir = dir;
  180. this.cur_att_data.slide_data.slide_num = num;
  181. this.cur_att_data.slide_data.slide_distance = distance;
  182. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.slide)
  183. }
  184. onChangDragErrBackStatus(b:boolean){
  185. this.cur_att_data.drag_data.is_err_drag_back = b;
  186. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.drag_err_back_status)
  187. }
  188. onChangDrag(data:att_drag_data){
  189. this.cur_att_data.drag_data = data;
  190. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.drag)
  191. }
  192. onDelete(){
  193. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.delete)
  194. }
  195. onChangeOrigin(){
  196. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.origin)
  197. }
  198. onChangePos(pos:Vec3){
  199. this.cur_att_data.x = pos.x;
  200. this.cur_att_data.y =pos.y;
  201. this.cur_att_data.z =pos.z;
  202. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.pos)
  203. }
  204. onChangeSize(size:Size){
  205. this.cur_att_data.width = size.width;
  206. this.cur_att_data.height =size.height;
  207. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.size)
  208. }
  209. public initView(m:main){
  210. this._main = m;
  211. }
  212. UpdateAttributes(data:attributes_data){
  213. this.cur_att_data = data;
  214. if(data!=null){
  215. this.showAllAtt()
  216. this.attributes_map.get("scene_set").active = false;
  217. if(data.type===config.attributes_type.widget){
  218. this.attributes_map.get("remark").active = true;
  219. this.attributes_map.get("drop").active = false;
  220. this.attributes_map.get("click").active = false;
  221. this.attributes_map.get("slide").active = false;
  222. this.attributes_map.get("top").active = false;
  223. this.attributes_map.get("question_select").active = false;
  224. this.attributes_map.get("text_sound").active = false;
  225. this.attributes_map.get("count_down").active = false;
  226. this.attributes_map.get("z_index").active = false;
  227. this.attributes_map.get("anchor").active = true;
  228. this.attributes_map.get("rotation").active = true;
  229. if(data.widget_type===config.Widget_Type_List.DRAG_TYPE){
  230. this.attributes_map.get("drop").active = true;
  231. }else if(data.widget_type===config.Widget_Type_List.CLICK_TYPE){
  232. this.attributes_map.get("click").active = true;
  233. }else if(data.widget_type===config.Widget_Type_List.IMG_TYPE){
  234. this.attributes_map.get("animation").active = false;
  235. }else if(data.widget_type===config.Widget_Type_List.SLIDE_TYPE){
  236. this.attributes_map.get("slide").active = true;
  237. }else if(data.widget_type===config.Widget_Type_List.UI_TOP){
  238. this.attributes_map.get("top").active = true;
  239. this.attributes_map.get("animation").active = false;
  240. this.attributes_map.get("origin").active = false;
  241. this.attributes_map.get("url").active = false;
  242. this.attributes_map.get("pos").active = false;
  243. this.attributes_map.get("size").active = false;
  244. }else if(data.widget_type===config.Widget_Type_List.TEXT_SOUND){
  245. this.attributes_map.get("animation").active = false;
  246. this.attributes_map.get("origin").active = false;
  247. this.attributes_map.get("url").active = false;
  248. this.attributes_map.get("pos").active = false;
  249. this.attributes_map.get("size").active = false;
  250. this.attributes_map.get("text_sound").active = true;
  251. this.attributes_map.get("anchor").active = false;
  252. this.attributes_map.get("rotation").active = false;
  253. }else if(data.widget_type===config.Widget_Type_List.QUESTION_SELECT){
  254. this.attributes_map.get("animation").active = false;
  255. this.attributes_map.get("origin").active = false;
  256. this.attributes_map.get("url").active = false;
  257. this.attributes_map.get("pos").active = false;
  258. this.attributes_map.get("size").active = false;
  259. this.attributes_map.get("pos").active = true;
  260. this.attributes_map.get("question_select").active = true;
  261. this.attributes_map.get("anchor").active = false;
  262. this.attributes_map.get("rotation").active = false;
  263. }else if(data.widget_type===config.Widget_Type_List.COUNT_DOWN){
  264. this.attributes_map.get("animation").active = false;
  265. this.attributes_map.get("origin").active = false;
  266. this.attributes_map.get("url").active = false;
  267. this.attributes_map.get("pos").active = true;
  268. this.attributes_map.get("size").active = false;
  269. this.attributes_map.get("count_down").active = true;
  270. this.attributes_map.get("anchor").active = false;
  271. this.attributes_map.get("rotation").active = false;
  272. }
  273. }else if(data.type===config.attributes_type.scene){
  274. this.hideAllAtt()
  275. this.attributes_map.get("name").active = true;
  276. this.attributes_map.get("remark").active = false;
  277. this.attributes_map.get("size").active = true;
  278. this.attributes_map.get("url").active = true;
  279. this.attributes_map.get("animation").active = true;
  280. this.attributes_map.get("scene_set").active = true;
  281. this.attributes_map.get("anchor").active = false;
  282. this.attributes_map.get("rotation").active = false;
  283. this.attributes_map.get("be_active").active = true;
  284. }
  285. this.scheduleOnce(()=>{
  286. this.updateAttInfo()
  287. },0.1)
  288. }else{
  289. this.hideAllAtt()
  290. }
  291. }
  292. updateAttInfo(){
  293. if(this.cur_att_data!=null){
  294. let name = this.getNameCom()
  295. name.update_att(`${this.cur_att_data.name}-id:${this.cur_att_data.id}`)
  296. let remark = this.getRemarkCom()
  297. remark.update_att(this.cur_att_data.remark)
  298. let pos = this.getPosCom()
  299. pos.update_att(this.cur_att_data.x,this.cur_att_data.y,this.cur_att_data.z)
  300. let size = this.getSizeCom()
  301. size.update_att(this.cur_att_data.width,this.cur_att_data.height)
  302. let anchor = this.getAnchorCom()
  303. anchor.update_att(this.cur_att_data ,this.cur_att_data.anchor_x, this.cur_att_data.anchor_y)
  304. let rotation = this.getRotationCom()
  305. rotation.update_att(this.cur_att_data.rotation)
  306. let url = this.getUrlCom()
  307. url.update_att(this.cur_att_data.src_name)
  308. let drag = this.getDragCom()
  309. if(this.cur_att_data.drag_data!=null){
  310. drag.update_att(this.cur_att_data.drag_data)
  311. }
  312. let slide = this.getSlideCom()
  313. if(this.cur_att_data.slide_data!=null){
  314. slide.update_att(this.cur_att_data.slide_data)
  315. }
  316. let click = this.getClickCom()
  317. if(this.cur_att_data.click_data!=null){
  318. click.update_att(this.cur_att_data.click_data)
  319. }
  320. let animation = this.getAnimationCom()
  321. animation.update_att(this.cur_att_data.animation_list)
  322. let active = this.getEditActiveCom()
  323. active.update_att(this.cur_att_data.edit_active)
  324. let top = this.getTopCom()
  325. if(this.cur_att_data.top_data!=null){
  326. top.update_att(this.cur_att_data.top_data)
  327. }
  328. let text_sound = this.getTextSoundCom()
  329. if(this.cur_att_data.text_sound_data!=null){
  330. text_sound.update_att(this.cur_att_data.text_sound_data)
  331. }
  332. let _question_select = this.getQuestionCom()
  333. if(this.cur_att_data.question_select!=null){
  334. _question_select.update_att(this.cur_att_data.question_select)
  335. }
  336. let _count_down = this.getCountDownCom()
  337. if(this.cur_att_data.count_down!=null){
  338. _count_down.update_att(this.cur_att_data.count_down)
  339. }
  340. this.attributes_be_active.getComponent(attributes_be_active).update_att(this.cur_att_data.is_interaction)
  341. let z_index = this.getZIndexCom()
  342. z_index.update_att(this.cur_att_data.zIndex)
  343. let show_com = this.getShowCom()
  344. show_com.update_att(this.cur_att_data.is_show)
  345. let scene_set = this.getSceneSetingCom()
  346. if(this.cur_att_data.type===config.attributes_type.scene){
  347. scene_set.update_att_info(this._main, this.cur_att_data)
  348. if(this.cur_att_data.scene_rule_tips_data!=null){
  349. scene_set.update_att(this.cur_att_data.scene_rule_tips_data)
  350. }else{
  351. this.cur_att_data.scene_rule_tips_data = new scene_tips_rule_data
  352. scene_set.update_att(this.cur_att_data.scene_rule_tips_data)
  353. }
  354. }
  355. }
  356. }
  357. getSceneSetingCom(){
  358. return this.attributes_map.get("scene_set").getComponent(attributes_scene_setting);
  359. }
  360. getShowCom(){
  361. return this.attributes_map.get("show").getComponent(attributes_show);
  362. }
  363. getTopCom(){
  364. return this.attributes_map.get("top").getComponent(attributes_top);
  365. }
  366. getAnimationCom(){
  367. return this.attributes_map.get("animation").getComponent(attributes_animation);
  368. }
  369. getClickCom(){
  370. return this.attributes_map.get("click").getComponent(attributes_click);
  371. }
  372. getSlideCom(){
  373. return this.attributes_map.get("slide").getComponent(attributes_slide);
  374. }
  375. getDragCom(){
  376. return this.attributes_map.get("drop").getComponent(attributes_drop);
  377. }
  378. getNameCom(){
  379. return this.attributes_map.get("name").getComponent(attributes_name);
  380. }
  381. getRemarkCom(){
  382. return this.attributes_map.get("remark").getComponent(attributes_remark);
  383. }
  384. getPosCom(){
  385. return this.attributes_map.get("pos").getComponent(attributes_x_y);
  386. }
  387. getSizeCom(){
  388. return this.attributes_map.get("size").getComponent(attributes_w_h);
  389. }
  390. getAnchorCom() {
  391. return this.attributes_map.get("anchor").getComponent(attributes_anchor);
  392. }
  393. getRotationCom(){
  394. return this.attributes_map.get("rotation").getComponent(attributes_rotation);
  395. }
  396. getEditActiveCom(){
  397. return this.attributes_map.get("active").getComponent(attributes_active);
  398. }
  399. getQuestionCom(){
  400. return this.attributes_map.get("question_select").getComponent(attributes_question_select);
  401. }
  402. getCountDownCom(){
  403. return this.attributes_map.get("count_down").getComponent(attributes_count_down);
  404. }
  405. public getUrlCom(){
  406. return this.attributes_map.get("url").getComponent(attributes_res);
  407. }
  408. public getTextSoundCom(){
  409. return this.attributes_map.get("text_sound").getComponent(attributes_text_sound);
  410. }
  411. public getZIndexCom(){
  412. return this.attributes_map.get("z_index").getComponent(attributes_z_index);
  413. }
  414. showAllAtt(){
  415. this.attributes_map.forEach((v,k)=>{
  416. v.active = true;
  417. })
  418. }
  419. hideAllAtt(){
  420. this.attributes_map.forEach((v,k)=>{
  421. v.active = false;
  422. })
  423. }
  424. public get_cur_att_data(){
  425. return this.cur_att_data;
  426. }
  427. public get_cur_scene_all_widget():widget_item_data[]{ //获取当前所有控件
  428. let data = this._main.edit_scene_view.getCurSelectScene()
  429. if(!data){
  430. return []
  431. }
  432. let temp = []
  433. for (let index = 0; index < data.page_list.length; index++) {
  434. const element = data.page_list[index];
  435. for (let i = 0; i < element.page_widget_list.length; i++) {
  436. const widget = element.page_widget_list[i];
  437. temp.push(widget)
  438. }
  439. }
  440. return temp;
  441. }
  442. public get_cur_scene_widget_by_type(type:number):widget_item_data[]{ //根据类型获取所有的
  443. let data = this._main.edit_scene_view.getCurSelectScene()
  444. if(!data){
  445. return []
  446. }
  447. let temp = []
  448. for (let index = 0; index < data.page_list.length; index++) {
  449. const element = data.page_list[index];
  450. for (let i = 0; i < element.page_widget_list.length; i++) {
  451. const widget = element.page_widget_list[i];
  452. if(type===widget.type){
  453. temp.push(widget)
  454. }
  455. }
  456. }
  457. return temp;
  458. }
  459. public get_cur_scene_all_only_widget(){ //获取当前所有控件
  460. let data = this._main.edit_scene_view.getCurSelectScene()
  461. if(!data){
  462. return []
  463. }
  464. let temp = []
  465. for (let index = 0; index < data.page_list.length; index++) {
  466. const element = data.page_list[index];
  467. for (let i = 0; i < element.page_widget_list.length; i++) {
  468. const widget = element.page_widget_list[i];
  469. if(widget.type!=config.Widget_Type_List.UI_TOP){
  470. temp.push(widget)
  471. }
  472. }
  473. }
  474. return temp;
  475. }
  476. public get_cur_scene_widget_by_id(id:number){ // 根据控件id获取
  477. let data = this._main.edit_scene_view.getCurSelectScene()
  478. for (let index = 0; index < data.page_list.length; index++) {
  479. const element = data.page_list[index];
  480. for (let i = 0; i < element.page_widget_list.length; i++) {
  481. const widget = element.page_widget_list[i];
  482. if(widget.att.id===id){
  483. return widget;
  484. }
  485. }
  486. }
  487. return null;
  488. }
  489. public get_widget_at_page_by_widget(select_widget:widget_item_data){ //根据widget 找到所属分页
  490. let page_index = 0;
  491. let data = this._main.edit_scene_view.getCurSelectScene()
  492. for (let index = 0; index < data.page_list.length; index++) {
  493. const element = data.page_list[index];
  494. for (let i = 0; i < element.page_widget_list.length; i++) {
  495. const widget = element.page_widget_list[i];
  496. if(widget.att.id===select_widget.att.id){
  497. page_index = index;
  498. break;
  499. }
  500. }
  501. }
  502. return page_index;
  503. }
  504. public get_scene_list(){
  505. let scene_list = this._main.control_view.get_bag_data().content;
  506. let temp = []
  507. for (let index = 0; index < scene_list.length; index++) {
  508. const s = scene_list[index];
  509. if(s.is_child_scene){
  510. temp.push(s)
  511. }
  512. }
  513. return temp;
  514. }
  515. ShowWidgetList(){
  516. let list = this.get_cur_scene_all_widget()
  517. if(list.length<=0){
  518. return tools.showToast("当前场景没有控件!")
  519. }
  520. tools.show_widget_list(list)
  521. }
  522. ShowALlChildScene(call){
  523. let list = this.get_scene_list()
  524. if(list.length<=0){
  525. return tools.showToast("还没有添加子场景")
  526. }
  527. tools.show_select_child_scene(list,call)
  528. }
  529. getEventList(){
  530. let data = this._main.edit_scene_view.getCurSelectScene()
  531. if(data._task_data == null) {
  532. return []
  533. }
  534. return data._task_data.event_list
  535. }
  536. getEventListByType(type:number) {
  537. let data = this._main.edit_scene_view.getCurSelectScene()
  538. let temp = []
  539. for (let index = 0; index < data._task_data.event_list.length; index++) {
  540. const element = data._task_data.event_list[index];
  541. if(element.type==type){
  542. temp.push(element)
  543. }
  544. }
  545. return temp
  546. }
  547. getBeActionEventList(){
  548. let data = this._main.edit_scene_view.getCurSelectScene()
  549. let temp = []
  550. for (let index = 0; index < data._task_data.event_list.length; index++) {
  551. const element = data._task_data.event_list[index];
  552. if(element.type==config.event_type.be_event){
  553. temp.push(element)
  554. }
  555. }
  556. return temp
  557. }
  558. getEventItemById(event_id:number){
  559. let list = this.getEventList();
  560. for (let index = 0; index < list.length; index++) {
  561. const element = list[index];
  562. if(event_id===element.event_id){
  563. return element;
  564. }
  565. }
  566. return null;
  567. }
  568. }