Attributes.ts 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755
  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. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.container)
  123. }
  124. onChangeRemark(text: string) {
  125. this.cur_att_data.remark = text
  126. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.remark)
  127. }
  128. onChangeAnchor(anchor:Vec2){
  129. this.cur_att_data.anchor_x = anchor.x
  130. this.cur_att_data.anchor_y = anchor.y
  131. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.anchor)
  132. }
  133. onChangeRotation(rotation: number) {
  134. this.cur_att_data.rotation = rotation
  135. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.rotation)
  136. }
  137. onChangSceneTipsRuleStatus(data:scene_tips_rule_data){
  138. this.cur_att_data.scene_rule_tips_data = data;
  139. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.scene_rule_tips)
  140. }
  141. onChangSceneAttributesStatus(data:attributes_data) {
  142. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.show_more_scene_arrow)
  143. }
  144. onChangShowStatus(show:boolean){
  145. this.cur_att_data.is_show = show;
  146. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.show)
  147. }
  148. onChangeDir(dir:number){
  149. this.cur_att_data.img_dir = dir;
  150. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.dir)
  151. }
  152. onChangeZIndex(zIndex:number){
  153. this.cur_att_data.zIndex = zIndex;
  154. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.zIndex)
  155. }
  156. onChangeCountDown(data:att_count_down){
  157. this.cur_att_data.count_down = data;
  158. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.count_down)
  159. }
  160. onChangeQuestionSelect(data:att_question_select){
  161. this.cur_att_data.question_select = data;
  162. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.question_select)
  163. }
  164. onChangeTextSound(data:att_text_sound_data){
  165. this.cur_att_data.text_sound_data = data;
  166. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.text_sound)
  167. }
  168. onChangeTop(data:att_top_data){
  169. this.cur_att_data.top_data = data;
  170. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.top)
  171. }
  172. onChangeActive(active:boolean){
  173. this.cur_att_data.edit_active = active;
  174. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.active)
  175. }
  176. onChangeAnimation(ani_list:att_ani_data[]){
  177. this.cur_att_data.animation_list = ani_list;
  178. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.animation)
  179. }
  180. onChangBeActiveStatus(is_be_active:boolean){
  181. this.cur_att_data.is_interaction = is_be_active;
  182. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.is_interaction)
  183. }
  184. onChangClick(data:att_click_data){
  185. this.cur_att_data.click_data = data;
  186. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.click)
  187. }
  188. onChangSlide(dir:number,num:number,distance:number){
  189. this.cur_att_data.slide_data.slide_dir = dir;
  190. this.cur_att_data.slide_data.slide_num = num;
  191. this.cur_att_data.slide_data.slide_distance = distance;
  192. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.slide)
  193. }
  194. onChangDragErrBackStatus(b:boolean){
  195. this.cur_att_data.drag_data.is_err_drag_back = b;
  196. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.drag_err_back_status)
  197. }
  198. onChangDrag(data:att_drag_data){
  199. this.cur_att_data.drag_data = data;
  200. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.drag)
  201. }
  202. onDelete(){
  203. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.delete)
  204. }
  205. onChangeOrigin(){
  206. let call_back = (()=>{
  207. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.origin)
  208. })
  209. if(this.cur_att_data.src) {
  210. tools.loadUrl(this.cur_att_data.src,null,(sf:SpriteFrame)=>{
  211. // console.log('sf=',sf.originalSize)
  212. this.cur_att_data.width = sf.originalSize.width
  213. this.cur_att_data.height = sf.originalSize.height
  214. call_back()
  215. })
  216. } else {
  217. call_back()
  218. }
  219. }
  220. onChangePos(pos:Vec3){
  221. this.cur_att_data.x = pos.x;
  222. this.cur_att_data.y =pos.y;
  223. this.cur_att_data.z =pos.z;
  224. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.pos)
  225. }
  226. onChangeSize(size:Size){
  227. this.cur_att_data.width = size.width;
  228. this.cur_att_data.height =size.height;
  229. ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.size)
  230. }
  231. public initView(m:main){
  232. this._main = m;
  233. }
  234. UpdateAttributes(data:attributes_data){
  235. this.cur_att_data = data;
  236. if(data!=null){
  237. this.showAllAtt()
  238. this.attributes_map.get("scene_set").active = false;
  239. if(data.type===config.attributes_type.widget){
  240. this.attributes_map.get("remark").active = true;
  241. this.attributes_map.get("drop").active = false;
  242. this.attributes_map.get("click").active = false;
  243. this.attributes_map.get("slide").active = false;
  244. this.attributes_map.get("top").active = false;
  245. this.attributes_map.get("question_select").active = false;
  246. this.attributes_map.get("text_sound").active = false;
  247. this.attributes_map.get("count_down").active = false;
  248. this.attributes_map.get("z_index").active = false;
  249. this.attributes_map.get("anchor").active = true;
  250. this.attributes_map.get("rotation").active = true;
  251. this.attributes_map.get("container").active = false;
  252. if(data.widget_type===config.Widget_Type_List.DRAG_TYPE){
  253. this.attributes_map.get("drop").active = true;
  254. }else if(data.widget_type===config.Widget_Type_List.CLICK_TYPE){
  255. this.attributes_map.get("click").active = true;
  256. }else if(data.widget_type===config.Widget_Type_List.IMG_TYPE){
  257. this.attributes_map.get("animation").active = false;
  258. }else if(data.widget_type===config.Widget_Type_List.SLIDE_TYPE){
  259. this.attributes_map.get("slide").active = true;
  260. }else if(data.widget_type===config.Widget_Type_List.UI_TOP){
  261. this.attributes_map.get("top").active = true;
  262. this.attributes_map.get("animation").active = false;
  263. this.attributes_map.get("origin").active = false;
  264. this.attributes_map.get("url").active = false;
  265. this.attributes_map.get("pos").active = false;
  266. this.attributes_map.get("size").active = false;
  267. }else if(data.widget_type===config.Widget_Type_List.TEXT_SOUND){
  268. this.attributes_map.get("animation").active = false;
  269. this.attributes_map.get("origin").active = false;
  270. this.attributes_map.get("url").active = false;
  271. this.attributes_map.get("pos").active = false;
  272. this.attributes_map.get("size").active = false;
  273. this.attributes_map.get("text_sound").active = true;
  274. this.attributes_map.get("anchor").active = false;
  275. this.attributes_map.get("rotation").active = false;
  276. }else if(data.widget_type===config.Widget_Type_List.QUESTION_SELECT){
  277. this.attributes_map.get("animation").active = false;
  278. this.attributes_map.get("origin").active = false;
  279. this.attributes_map.get("url").active = false;
  280. this.attributes_map.get("pos").active = false;
  281. this.attributes_map.get("size").active = false;
  282. this.attributes_map.get("pos").active = true;
  283. this.attributes_map.get("question_select").active = true;
  284. this.attributes_map.get("anchor").active = false;
  285. this.attributes_map.get("rotation").active = false;
  286. }else if(data.widget_type===config.Widget_Type_List.COUNT_DOWN){
  287. this.attributes_map.get("animation").active = false;
  288. this.attributes_map.get("origin").active = false;
  289. this.attributes_map.get("url").active = false;
  290. this.attributes_map.get("pos").active = true;
  291. this.attributes_map.get("size").active = false;
  292. this.attributes_map.get("count_down").active = true;
  293. this.attributes_map.get("anchor").active = false;
  294. this.attributes_map.get("rotation").active = false;
  295. }else if(data.widget_type==config.Widget_Type_List.CONTAINER_LAYER){
  296. this.attributes_map.get("container").active = true;
  297. }
  298. }else if(data.type===config.attributes_type.scene){
  299. this.hideAllAtt()
  300. this.attributes_map.get("name").active = true;
  301. this.attributes_map.get("remark").active = false;
  302. this.attributes_map.get("size").active = true;
  303. this.attributes_map.get("url").active = true;
  304. this.attributes_map.get("animation").active = true;
  305. this.attributes_map.get("scene_set").active = true;
  306. this.attributes_map.get("anchor").active = false;
  307. this.attributes_map.get("rotation").active = false;
  308. this.attributes_map.get("be_active").active = true;
  309. }
  310. // this.scheduleOnce(()=>{ this.updateAttInfo()},0.1)
  311. this.updateAttInfo()
  312. }else{
  313. this.hideAllAtt()
  314. }
  315. }
  316. updateAttInfo(){
  317. if(this.cur_att_data!=null){
  318. let name = this.getNameCom()
  319. name.update_att(`${this.cur_att_data.name}-id:${this.cur_att_data.id}`)
  320. let remark = this.getRemarkCom()
  321. remark.update_att(this.cur_att_data.remark)
  322. let pos = this.getPosCom()
  323. pos.update_att(this.cur_att_data.x,this.cur_att_data.y,this.cur_att_data.z)
  324. let size = this.getSizeCom()
  325. size.update_att(this.cur_att_data.width,this.cur_att_data.height)
  326. let anchor = this.getAnchorCom()
  327. anchor.update_att(this.cur_att_data ,this.cur_att_data.anchor_x, this.cur_att_data.anchor_y)
  328. let rotation = this.getRotationCom()
  329. rotation.update_att(this.cur_att_data.rotation)
  330. let url = this.getUrlCom()
  331. url.update_att(this.cur_att_data.src_name)
  332. let drag = this.getDragCom()
  333. if(this.cur_att_data.drag_data!=null){
  334. drag.update_att(this.cur_att_data.drag_data)
  335. }
  336. let slide = this.getSlideCom()
  337. if(this.cur_att_data.slide_data!=null){
  338. slide.update_att(this.cur_att_data.slide_data)
  339. }
  340. let click = this.getClickCom()
  341. if(this.cur_att_data.click_data!=null){
  342. click.update_att(this.cur_att_data.click_data)
  343. }
  344. let animation = this.getAnimationCom()
  345. animation.update_att(this.cur_att_data.animation_list)
  346. let active = this.getEditActiveCom()
  347. active.update_att(this.cur_att_data.edit_active)
  348. let top = this.getTopCom()
  349. if(this.cur_att_data.top_data!=null){
  350. top.update_att(this.cur_att_data.top_data)
  351. }
  352. let text_sound = this.getTextSoundCom()
  353. if(this.cur_att_data.text_sound_data!=null){
  354. text_sound.update_att(this.cur_att_data.text_sound_data)
  355. }
  356. let _question_select = this.getQuestionCom()
  357. if(this.cur_att_data.question_select!=null){
  358. _question_select.update_att(this.cur_att_data.question_select)
  359. }
  360. let _count_down = this.getCountDownCom()
  361. if(this.cur_att_data.count_down!=null){
  362. _count_down.update_att(this.cur_att_data.count_down)
  363. }
  364. this.attributes_be_active.getComponent(attributes_be_active).update_att(this.cur_att_data.is_interaction)
  365. let z_index = this.getZIndexCom()
  366. z_index.update_att(this.cur_att_data.zIndex)
  367. let show_com = this.getShowCom()
  368. show_com.update_att(this.cur_att_data.is_show)
  369. let scene_set = this.getSceneSetingCom()
  370. if(this.cur_att_data.type===config.attributes_type.scene){
  371. scene_set.update_att_info(this._main, this.cur_att_data)
  372. if(this.cur_att_data.scene_rule_tips_data!=null){
  373. scene_set.update_att(this.cur_att_data.scene_rule_tips_data)
  374. }else{
  375. this.cur_att_data.scene_rule_tips_data = new scene_tips_rule_data
  376. scene_set.update_att(this.cur_att_data.scene_rule_tips_data)
  377. }
  378. }
  379. }
  380. }
  381. getSceneSetingCom(){
  382. return this.attributes_map.get("scene_set").getComponent(attributes_scene_setting);
  383. }
  384. getShowCom(){
  385. return this.attributes_map.get("show").getComponent(attributes_show);
  386. }
  387. getTopCom(){
  388. return this.attributes_map.get("top").getComponent(attributes_top);
  389. }
  390. getAnimationCom(){
  391. return this.attributes_map.get("animation").getComponent(attributes_animation);
  392. }
  393. getClickCom(){
  394. return this.attributes_map.get("click").getComponent(attributes_click);
  395. }
  396. getSlideCom(){
  397. return this.attributes_map.get("slide").getComponent(attributes_slide);
  398. }
  399. getDragCom(){
  400. return this.attributes_map.get("drop").getComponent(attributes_drop);
  401. }
  402. getNameCom(){
  403. return this.attributes_map.get("name").getComponent(attributes_name);
  404. }
  405. getRemarkCom(){
  406. return this.attributes_map.get("remark").getComponent(attributes_remark);
  407. }
  408. getPosCom(){
  409. return this.attributes_map.get("pos").getComponent(attributes_x_y);
  410. }
  411. getSizeCom(){
  412. return this.attributes_map.get("size").getComponent(attributes_w_h);
  413. }
  414. getAnchorCom() {
  415. return this.attributes_map.get("anchor").getComponent(attributes_anchor);
  416. }
  417. getRotationCom(){
  418. return this.attributes_map.get("rotation").getComponent(attributes_rotation);
  419. }
  420. getEditActiveCom(){
  421. return this.attributes_map.get("active").getComponent(attributes_active);
  422. }
  423. getQuestionCom(){
  424. return this.attributes_map.get("question_select").getComponent(attributes_question_select);
  425. }
  426. getCountDownCom(){
  427. return this.attributes_map.get("count_down").getComponent(attributes_count_down);
  428. }
  429. public getUrlCom(){
  430. return this.attributes_map.get("url").getComponent(attributes_res);
  431. }
  432. public getTextSoundCom(){
  433. return this.attributes_map.get("text_sound").getComponent(attributes_text_sound);
  434. }
  435. public getZIndexCom(){
  436. return this.attributes_map.get("z_index").getComponent(attributes_z_index);
  437. }
  438. showAllAtt(){
  439. this.attributes_map.forEach((v,k)=>{
  440. v.active = true;
  441. })
  442. }
  443. hideAllAtt(){
  444. this.attributes_map.forEach((v,k)=>{
  445. v.active = false;
  446. })
  447. }
  448. public get_cur_att_data(){
  449. return this.cur_att_data;
  450. }
  451. public get_cur_scene_all_widget():widget_item_data[]{ //获取当前所有控件
  452. let data = this._main.edit_scene_view.getCurSelectScene()
  453. // console.log('get_cur_scene_all_widget ==',data)
  454. if(!data){
  455. return []
  456. }
  457. let temp = []
  458. for (let index = 0; index < data.page_list.length; index++) {
  459. const element = data.page_list[index];
  460. for (let i = 0; i < element.page_widget_list.length; i++) {
  461. const widget = element.page_widget_list[i];
  462. widget.scene_type = data.type
  463. widget.scene_page_number = index+1
  464. temp.push(widget)
  465. if(widget.type==config.Widget_Type_List.CONTAINER_LAYER){
  466. for (let j = 0; j < widget.att.container_layer.widget_list.length; j++) {
  467. const container_widget = widget.att.container_layer.widget_list[j];
  468. container_widget.scene_type = data.type
  469. container_widget.scene_page_number = index+1
  470. container_widget.is_container_layer = true
  471. temp.push(container_widget)
  472. }
  473. }
  474. }
  475. }
  476. return temp;
  477. }
  478. public get_cur_scene_widget_by_type(type:number):widget_item_data[]{ //根据类型获取所有的
  479. let data = this._main.edit_scene_view.getCurSelectScene()
  480. if(!data){
  481. return []
  482. }
  483. let temp = []
  484. for (let index = 0; index < data.page_list.length; index++) {
  485. const element = data.page_list[index];
  486. for (let i = 0; i < element.page_widget_list.length; i++) {
  487. const widget = element.page_widget_list[i];
  488. widget.scene_type = data.type
  489. widget.scene_page_number = index+1
  490. if(type===widget.type){
  491. temp.push(widget)
  492. }
  493. if(type==config.Widget_Type_List.CONTAINER_LAYER){
  494. if(widget.att.container_layer!=null){
  495. for (let j = 0; j < widget.att.container_layer.widget_list.length; j++) {
  496. const container_widget = widget.att.container_layer.widget_list[j];
  497. container_widget.scene_type = data.type
  498. container_widget.scene_page_number = index+1
  499. container_widget.is_container_layer = true
  500. if(type===container_widget.type){
  501. temp.push(container_widget)
  502. }
  503. }
  504. }
  505. }
  506. }
  507. }
  508. return temp;
  509. }
  510. public get_cur_scene_all_only_widget(){ //获取当前所有控件
  511. let data = this._main.edit_scene_view.getCurSelectScene()
  512. if(!data){
  513. return []
  514. }
  515. let temp = []
  516. for (let index = 0; index < data.page_list.length; index++) {
  517. const element = data.page_list[index];
  518. for (let i = 0; i < element.page_widget_list.length; i++) {
  519. const widget = element.page_widget_list[i];
  520. widget.scene_type = data.type
  521. widget.scene_page_number = index+1
  522. if(widget.type!=config.Widget_Type_List.UI_TOP){
  523. temp.push(widget)
  524. }
  525. if(widget.type==config.Widget_Type_List.CONTAINER_LAYER){
  526. if(widget.att.container_layer!=null){
  527. for (let j = 0; j < widget.att.container_layer.widget_list.length; j++) {
  528. const container_widget = widget.att.container_layer.widget_list[j];
  529. container_widget.scene_type = data.type
  530. container_widget.scene_page_number = index+1
  531. container_widget.is_container_layer = true
  532. temp.push(container_widget)
  533. }
  534. }
  535. }
  536. }
  537. }
  538. return temp;
  539. }
  540. public get_cur_scene_widget_by_id(id:number){ // 根据控件id获取
  541. let data = this._main.edit_scene_view.getCurSelectScene()
  542. for (let index = 0; index < data.page_list.length; index++) {
  543. const element = data.page_list[index];
  544. for (let i = 0; i < element.page_widget_list.length; i++) {
  545. const widget = element.page_widget_list[i];
  546. widget.scene_type = data.type
  547. widget.scene_page_number = index+1
  548. if(widget.att.id===id){
  549. return widget;
  550. }
  551. if(widget.type==config.Widget_Type_List.CONTAINER_LAYER){
  552. if(widget.att.container_layer!=null){
  553. for (let j = 0; j < widget.att.container_layer.widget_list.length; j++) {
  554. const container_widget = widget.att.container_layer.widget_list[j];
  555. container_widget.scene_type = data.type
  556. container_widget.scene_page_number = index+1
  557. container_widget.is_container_layer = true
  558. if(container_widget.att.id===id){
  559. return container_widget;
  560. }
  561. }
  562. }
  563. }
  564. }
  565. }
  566. return null;
  567. }
  568. public get_widget_at_page_by_widget(select_widget:widget_item_data){ //根据widget 找到所属分页
  569. let page_index = 0;
  570. let data = this._main.edit_scene_view.getCurSelectScene()
  571. for (let index = 0; index < data.page_list.length; index++) {
  572. const element = data.page_list[index];
  573. for (let i = 0; i < element.page_widget_list.length; i++) {
  574. const widget = element.page_widget_list[i];
  575. widget.scene_type = data.type
  576. widget.scene_page_number = index+1
  577. if(widget.att.id===select_widget.att.id){
  578. page_index = index;
  579. break;
  580. }
  581. if(widget.type==config.Widget_Type_List.CONTAINER_LAYER){
  582. if(widget.att.container_layer!=null){
  583. for (let j = 0; j < widget.att.container_layer.widget_list.length; j++) {
  584. const container_widget = widget.att.container_layer.widget_list[j];
  585. container_widget.scene_type = data.type
  586. container_widget.scene_page_number = index+1
  587. container_widget.is_container_layer = true
  588. if(container_widget.att.id===select_widget.att.id){
  589. page_index = index;
  590. break;
  591. }
  592. }
  593. }
  594. }
  595. }
  596. }
  597. return page_index;
  598. }
  599. public get_scene_list(){
  600. let scene_list = this._main.control_view.get_bag_data().content;
  601. let temp = []
  602. for (let index = 0; index < scene_list.length; index++) {
  603. const s = scene_list[index];
  604. if(s.is_child_scene){
  605. temp.push(s)
  606. }
  607. }
  608. return temp;
  609. }
  610. ShowWidgetList(){
  611. let list = this.get_cur_scene_all_widget()
  612. if(list.length<=0){
  613. return tools.showToast("当前场景没有控件!")
  614. }
  615. tools.show_widget_list(list)
  616. }
  617. ShowALlChildScene(call){
  618. let list = this.get_scene_list()
  619. if(list.length<=0){
  620. return tools.showToast("还没有添加子场景")
  621. }
  622. tools.show_select_child_scene(list,call)
  623. }
  624. getEventList(){
  625. let data = this._main.edit_scene_view.getCurSelectScene()
  626. if(data._task_data == null) {
  627. return []
  628. }
  629. return data._task_data.event_list
  630. }
  631. getEventListByType(type:number) {
  632. let data = this._main.edit_scene_view.getCurSelectScene()
  633. let temp = []
  634. for (let index = 0; index < data._task_data.event_list.length; index++) {
  635. const element = data._task_data.event_list[index];
  636. if(element.type==type){
  637. temp.push(element)
  638. }
  639. }
  640. return temp
  641. }
  642. getBeActionEventList(){
  643. let data = this._main.edit_scene_view.getCurSelectScene()
  644. let temp = []
  645. for (let index = 0; index < data._task_data.event_list.length; index++) {
  646. const element = data._task_data.event_list[index];
  647. if(element.type==config.event_type.be_event){
  648. temp.push(element)
  649. }
  650. }
  651. return temp
  652. }
  653. getEventItemById(event_id:number){
  654. let list = this.getEventList();
  655. for (let index = 0; index < list.length; index++) {
  656. const element = list[index];
  657. if(event_id===element.event_id){
  658. return element;
  659. }
  660. }
  661. return null;
  662. }
  663. }