Attributes.ts 26 KB

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