Attributes.ts 29 KB

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