123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755 |
- import { _decorator, Component, Director, director, instantiate, Node, Size, SpriteFrame, Vec2, Vec3 } from 'cc';
- import { ClientEvent } from '../clientEvent';
- import { config } from '../config';
- 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';
- import { attributes_name } from './attributes/attributes_name';
- import { attributes_x_y } from './attributes/attributes_x_y';
- import { attributes_w_h } from './attributes/attributes_w_h';
- import { attributes_res } from './attributes/attributes_res';
- import { main } from '../main';
- import { attributes_origin } from './attributes/attributes_origin';
- import { attributes_delete } from './attributes/attributes_delete';
- import { attributes_drop } from './attributes/attributes_drop';
- import { attributes_slide } from './attributes/attributes_slide';
- import { attributes_click } from './attributes/attributes_click';
- import { attributes_be_active } from './attributes/attributes_be_active';
- import { attributes_animation } from './attributes/attributes_animation';
- import { attributes_active } from './attributes/attributes_active';
- import { tools } from '../tools';
- import { attributes_top } from './attributes/attributes_top';
- import { attributes_text_sound } from './attributes/attributes_text_sound';
- import { attributes_question_select } from './attributes/attributes_question_select';
- import { attributes_count_down } from './attributes/attributes_count_down';
- import { attributes_z_index } from './attributes/attributes_z_index';
- import { attributes_dir } from './attributes/attributes_dir';
- import { attributes_show } from './attributes/attributes_show';
- import { attributes_scene_setting } from './attributes/attributes_scene_setting';
- import { attributes_remark } from './attributes/attributes_remark';
- import { attributes_rotation } from './attributes/attributes_rotation';
- import { attributes_anchor } from './attributes/attributes_anchor';
- import { attributes_container } from './attributes/attributes_container';
- const { ccclass, property } = _decorator;
- @ccclass('Attributes')
- export class Attributes extends Component {
- private attributes_map:Map<string,Node> = new Map
- @property(Node) attributes_name:Node = null;
- @property(Node) attributes_remark:Node = null;
- @property(Node) attributes_x_y:Node = null;
- @property(Node) attributes_w_h:Node = null;
- @property(Node) attributes_anchor:Node = null;
- @property(Node) attributes_rotation:Node = null;
- @property(Node) attributes_res:Node = null;
- @property(Node) attributes_origin:Node = null;
- @property(Node) attributes_be_event:Node = null; //被动事件
- @property(Node) attributes_animation:Node = null; //动画
- @property(Node) attributes_drop:Node = null;
- @property(Node) attributes_click:Node = null;
- @property(Node) attributes_slide:Node = null;
- @property(Node) attributes_delete:Node = null;
- @property(Node) attributes_be_active:Node = null;
- @property(Node) attributes_active:Node = null;
- @property(Node) attributes_top:Node = null;
- @property(Node) attributes_text_sound:Node = null;
- @property(Node) attributes_question_select:Node = null;
- @property(Node) attributes_count_down:Node = null;
- @property(Node) attributes_z_index:Node = null;
- @property(Node) attributes_dir:Node = null;
- @property(Node) attributes_show:Node = null;
- @property(Node) attributes_scene_setting:Node = null;
- @property(Node) attributes_container:Node = null;
- @property(Node) content:Node = null;
- private cur_att_data:attributes_data = null;
- private _main:main = null;
- public static Singleton:Attributes = null;
- public static is_show_more_scene_arrow:boolean = true; //是否显示多场景箭头
- start() {
- Attributes.Singleton = this;
- ClientEvent.on(config.Event.UpdateAttributes,this.UpdateAttributes,this)
- ClientEvent.on(config.Event.ShowWidgetList,this.ShowWidgetList,this)
- this.attributes_map.set("name",this.attributes_name)
- this.attributes_map.set("remark",this.attributes_remark)
- this.attributes_map.set("pos",this.attributes_x_y)
- this.attributes_map.set("size",this.attributes_w_h)
- this.attributes_map.set("anchor",this.attributes_anchor)
- this.attributes_map.set("rotation",this.attributes_rotation)
- this.attributes_map.set("url",this.attributes_res)
- this.attributes_map.set("origin",this.attributes_origin)
- // this.attributes_map.set("be_event",this.attributes_be_event)
- this.attributes_map.set("animation",this.attributes_animation)
- this.attributes_map.set("drop",this.attributes_drop)
- this.attributes_map.set("click",this.attributes_click)
- this.attributes_map.set("slide",this.attributes_slide)
- this.attributes_map.set("delete",this.attributes_delete)
- this.attributes_map.set("be_active",this.attributes_be_active)
- this.attributes_map.set("active",this.attributes_active)
- this.attributes_map.set("top",this.attributes_top)
- this.attributes_map.set("text_sound",this.attributes_text_sound)
- this.attributes_map.set("question_select",this.attributes_question_select)
- this.attributes_map.set("count_down",this.attributes_count_down)
- this.attributes_map.set("z_index",this.attributes_z_index)
- this.attributes_map.set("dir",this.attributes_dir)
- this.attributes_map.set("show",this.attributes_show)
- this.attributes_map.set("scene_set",this.attributes_scene_setting)
- this.attributes_map.set("container",this.attributes_container)
- this.attributes_remark.getComponent(attributes_remark).initView(this.onChangeRemark.bind(this))
- this.attributes_scene_setting.getComponent(attributes_scene_setting).initView(this.onChangSceneTipsRuleStatus.bind(this),this.onChangSceneAttributesStatus.bind(this))
- this.attributes_show.getComponent(attributes_show).initView(this.onChangShowStatus.bind(this))
- this.attributes_dir.getComponent(attributes_dir).initView(this.onChangeDir.bind(this))
- this.attributes_z_index.getComponent(attributes_z_index).initView(this.onChangeZIndex.bind(this))
- this.attributes_count_down.getComponent(attributes_count_down).initView(this.onChangeCountDown.bind(this))
- this.attributes_question_select.getComponent(attributes_question_select).initView(this.onChangeQuestionSelect.bind(this))
- this.attributes_text_sound.getComponent(attributes_text_sound).initView(this.onChangeTextSound.bind(this))
- this.attributes_top.getComponent(attributes_top).initView(this.onChangeTop.bind(this))
- this.attributes_active.getComponent(attributes_active).initView(this.onChangeActive.bind(this))
- this.attributes_animation.getComponent(attributes_animation).initView(this.onChangeAnimation.bind(this))
- this.attributes_be_active.getComponent(attributes_be_active).initView(this.onChangBeActiveStatus.bind(this))
- this.attributes_click.getComponent(attributes_click).initView(this.onChangClick.bind(this))
- this.attributes_slide.getComponent(attributes_slide).initView(this.onChangSlide.bind(this))
- this.attributes_drop.getComponent(attributes_drop).initView(this.onChangDrag.bind(this),this.onChangDragErrBackStatus.bind(this))
- this.attributes_delete.getComponent(attributes_delete).initView(this.onDelete.bind(this))
- this.attributes_w_h.getComponent(attributes_w_h).initView(this.onChangeSize.bind(this))
- this.attributes_x_y.getComponent(attributes_x_y).initView(this.onChangePos.bind(this))
- this.attributes_rotation.getComponent(attributes_rotation).initView(this.onChangeRotation.bind(this))
- this.attributes_anchor.getComponent(attributes_anchor).initView(this.onChangeAnchor.bind(this))
- this.attributes_origin.getComponent(attributes_origin).initView(this.onChangeOrigin.bind(this))
- this.attributes_container.getComponent(attributes_container).initView(this.onContainerAddWidget.bind(this),this)
- this.hideAllAtt()
- }
- public getMain(){
- return this._main
- }
- onContainerAddWidget(){
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.container)
- }
- onChangeRemark(text: string) {
- this.cur_att_data.remark = text
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.remark)
- }
- onChangeAnchor(anchor:Vec2){
- this.cur_att_data.anchor_x = anchor.x
- this.cur_att_data.anchor_y = anchor.y
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.anchor)
- }
- onChangeRotation(rotation: number) {
- this.cur_att_data.rotation = rotation
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.rotation)
- }
- onChangSceneTipsRuleStatus(data:scene_tips_rule_data){
- this.cur_att_data.scene_rule_tips_data = data;
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.scene_rule_tips)
- }
- onChangSceneAttributesStatus(data:attributes_data) {
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.show_more_scene_arrow)
- }
- onChangShowStatus(show:boolean){
- this.cur_att_data.is_show = show;
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.show)
- }
- onChangeDir(dir:number){
- this.cur_att_data.img_dir = dir;
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.dir)
- }
- onChangeZIndex(zIndex:number){
- this.cur_att_data.zIndex = zIndex;
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.zIndex)
- }
- onChangeCountDown(data:att_count_down){
- this.cur_att_data.count_down = data;
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.count_down)
- }
- onChangeQuestionSelect(data:att_question_select){
- this.cur_att_data.question_select = data;
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.question_select)
- }
- onChangeTextSound(data:att_text_sound_data){
- this.cur_att_data.text_sound_data = data;
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.text_sound)
- }
- onChangeTop(data:att_top_data){
- this.cur_att_data.top_data = data;
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.top)
- }
- onChangeActive(active:boolean){
- this.cur_att_data.edit_active = active;
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.active)
- }
- onChangeAnimation(ani_list:att_ani_data[]){
- this.cur_att_data.animation_list = ani_list;
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.animation)
- }
- onChangBeActiveStatus(is_be_active:boolean){
- this.cur_att_data.is_interaction = is_be_active;
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.is_interaction)
- }
- onChangClick(data:att_click_data){
- this.cur_att_data.click_data = data;
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.click)
- }
- onChangSlide(dir:number,num:number,distance:number){
- this.cur_att_data.slide_data.slide_dir = dir;
- this.cur_att_data.slide_data.slide_num = num;
- this.cur_att_data.slide_data.slide_distance = distance;
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.slide)
- }
- onChangDragErrBackStatus(b:boolean){
- this.cur_att_data.drag_data.is_err_drag_back = b;
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.drag_err_back_status)
- }
- onChangDrag(data:att_drag_data){
- this.cur_att_data.drag_data = data;
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.drag)
- }
- onDelete(){
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.delete)
- }
- onChangeOrigin(){
- let call_back = (()=>{
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.origin)
- })
- if(this.cur_att_data.src) {
- tools.loadUrl(this.cur_att_data.src,null,(sf:SpriteFrame)=>{
- // console.log('sf=',sf.originalSize)
- this.cur_att_data.width = sf.originalSize.width
- this.cur_att_data.height = sf.originalSize.height
- call_back()
- })
- } else {
- call_back()
- }
- }
- onChangePos(pos:Vec3){
- this.cur_att_data.x = pos.x;
- this.cur_att_data.y =pos.y;
- this.cur_att_data.z =pos.z;
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.pos)
- }
- onChangeSize(size:Size){
- this.cur_att_data.width = size.width;
- this.cur_att_data.height =size.height;
- ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.size)
- }
- public initView(m:main){
- this._main = m;
- }
- UpdateAttributes(data:attributes_data){
- this.cur_att_data = data;
- if(data!=null){
- this.showAllAtt()
- this.attributes_map.get("scene_set").active = false;
- if(data.type===config.attributes_type.widget){
- this.attributes_map.get("remark").active = true;
- this.attributes_map.get("drop").active = false;
- this.attributes_map.get("click").active = false;
- this.attributes_map.get("slide").active = false;
- this.attributes_map.get("top").active = false;
- this.attributes_map.get("question_select").active = false;
- this.attributes_map.get("text_sound").active = false;
- this.attributes_map.get("count_down").active = false;
- this.attributes_map.get("z_index").active = false;
- this.attributes_map.get("anchor").active = true;
- this.attributes_map.get("rotation").active = true;
- this.attributes_map.get("container").active = false;
- if(data.widget_type===config.Widget_Type_List.DRAG_TYPE){
- this.attributes_map.get("drop").active = true;
- }else if(data.widget_type===config.Widget_Type_List.CLICK_TYPE){
- this.attributes_map.get("click").active = true;
- }else if(data.widget_type===config.Widget_Type_List.IMG_TYPE){
- this.attributes_map.get("animation").active = false;
- }else if(data.widget_type===config.Widget_Type_List.SLIDE_TYPE){
- this.attributes_map.get("slide").active = true;
- }else if(data.widget_type===config.Widget_Type_List.UI_TOP){
- this.attributes_map.get("top").active = true;
- this.attributes_map.get("animation").active = false;
- this.attributes_map.get("origin").active = false;
- this.attributes_map.get("url").active = false;
- this.attributes_map.get("pos").active = false;
- this.attributes_map.get("size").active = false;
- }else if(data.widget_type===config.Widget_Type_List.TEXT_SOUND){
- this.attributes_map.get("animation").active = false;
- this.attributes_map.get("origin").active = false;
- this.attributes_map.get("url").active = false;
- this.attributes_map.get("pos").active = false;
- this.attributes_map.get("size").active = false;
- this.attributes_map.get("text_sound").active = true;
- this.attributes_map.get("anchor").active = false;
- this.attributes_map.get("rotation").active = false;
- }else if(data.widget_type===config.Widget_Type_List.QUESTION_SELECT){
- this.attributes_map.get("animation").active = false;
- this.attributes_map.get("origin").active = false;
- this.attributes_map.get("url").active = false;
- this.attributes_map.get("pos").active = false;
- this.attributes_map.get("size").active = false;
- this.attributes_map.get("pos").active = true;
- this.attributes_map.get("question_select").active = true;
- this.attributes_map.get("anchor").active = false;
- this.attributes_map.get("rotation").active = false;
- }else if(data.widget_type===config.Widget_Type_List.COUNT_DOWN){
- this.attributes_map.get("animation").active = false;
- this.attributes_map.get("origin").active = false;
- this.attributes_map.get("url").active = false;
- this.attributes_map.get("pos").active = true;
- this.attributes_map.get("size").active = false;
- this.attributes_map.get("count_down").active = true;
- this.attributes_map.get("anchor").active = false;
- this.attributes_map.get("rotation").active = false;
- }else if(data.widget_type==config.Widget_Type_List.CONTAINER_LAYER){
- this.attributes_map.get("container").active = true;
- }
- }else if(data.type===config.attributes_type.scene){
- this.hideAllAtt()
- this.attributes_map.get("name").active = true;
- this.attributes_map.get("remark").active = false;
- this.attributes_map.get("size").active = true;
- this.attributes_map.get("url").active = true;
- this.attributes_map.get("animation").active = true;
- this.attributes_map.get("scene_set").active = true;
- this.attributes_map.get("anchor").active = false;
- this.attributes_map.get("rotation").active = false;
- this.attributes_map.get("be_active").active = true;
- }
- // this.scheduleOnce(()=>{ this.updateAttInfo()},0.1)
- this.updateAttInfo()
- }else{
- this.hideAllAtt()
- }
- }
- updateAttInfo(){
- if(this.cur_att_data!=null){
- let name = this.getNameCom()
- name.update_att(`${this.cur_att_data.name}-id:${this.cur_att_data.id}`)
- let remark = this.getRemarkCom()
- remark.update_att(this.cur_att_data.remark)
- let pos = this.getPosCom()
- pos.update_att(this.cur_att_data.x,this.cur_att_data.y,this.cur_att_data.z)
- let size = this.getSizeCom()
- size.update_att(this.cur_att_data.width,this.cur_att_data.height)
- let anchor = this.getAnchorCom()
- anchor.update_att(this.cur_att_data ,this.cur_att_data.anchor_x, this.cur_att_data.anchor_y)
- let rotation = this.getRotationCom()
- rotation.update_att(this.cur_att_data.rotation)
- let url = this.getUrlCom()
- url.update_att(this.cur_att_data.src_name)
- let drag = this.getDragCom()
- if(this.cur_att_data.drag_data!=null){
- drag.update_att(this.cur_att_data.drag_data)
- }
- let slide = this.getSlideCom()
- if(this.cur_att_data.slide_data!=null){
- slide.update_att(this.cur_att_data.slide_data)
- }
- let click = this.getClickCom()
- if(this.cur_att_data.click_data!=null){
- click.update_att(this.cur_att_data.click_data)
- }
- let animation = this.getAnimationCom()
- animation.update_att(this.cur_att_data.animation_list)
- let active = this.getEditActiveCom()
- active.update_att(this.cur_att_data.edit_active)
- let top = this.getTopCom()
- if(this.cur_att_data.top_data!=null){
- top.update_att(this.cur_att_data.top_data)
- }
-
- let text_sound = this.getTextSoundCom()
- if(this.cur_att_data.text_sound_data!=null){
- text_sound.update_att(this.cur_att_data.text_sound_data)
- }
- let _question_select = this.getQuestionCom()
- if(this.cur_att_data.question_select!=null){
- _question_select.update_att(this.cur_att_data.question_select)
- }
- let _count_down = this.getCountDownCom()
- if(this.cur_att_data.count_down!=null){
- _count_down.update_att(this.cur_att_data.count_down)
- }
- this.attributes_be_active.getComponent(attributes_be_active).update_att(this.cur_att_data.is_interaction)
-
- let z_index = this.getZIndexCom()
- z_index.update_att(this.cur_att_data.zIndex)
- let show_com = this.getShowCom()
- show_com.update_att(this.cur_att_data.is_show)
-
- let scene_set = this.getSceneSetingCom()
- if(this.cur_att_data.type===config.attributes_type.scene){
- scene_set.update_att_info(this._main, this.cur_att_data)
- if(this.cur_att_data.scene_rule_tips_data!=null){
- scene_set.update_att(this.cur_att_data.scene_rule_tips_data)
- }else{
- this.cur_att_data.scene_rule_tips_data = new scene_tips_rule_data
- scene_set.update_att(this.cur_att_data.scene_rule_tips_data)
- }
- }
-
- }
- }
- getSceneSetingCom(){
- return this.attributes_map.get("scene_set").getComponent(attributes_scene_setting);
- }
- getShowCom(){
- return this.attributes_map.get("show").getComponent(attributes_show);
- }
- getTopCom(){
- return this.attributes_map.get("top").getComponent(attributes_top);
- }
- getAnimationCom(){
- return this.attributes_map.get("animation").getComponent(attributes_animation);
- }
- getClickCom(){
- return this.attributes_map.get("click").getComponent(attributes_click);
- }
- getSlideCom(){
- return this.attributes_map.get("slide").getComponent(attributes_slide);
- }
- getDragCom(){
- return this.attributes_map.get("drop").getComponent(attributes_drop);
- }
- getNameCom(){
- return this.attributes_map.get("name").getComponent(attributes_name);
- }
- getRemarkCom(){
- return this.attributes_map.get("remark").getComponent(attributes_remark);
- }
- getPosCom(){
- return this.attributes_map.get("pos").getComponent(attributes_x_y);
- }
- getSizeCom(){
- return this.attributes_map.get("size").getComponent(attributes_w_h);
- }
- getAnchorCom() {
- return this.attributes_map.get("anchor").getComponent(attributes_anchor);
- }
- getRotationCom(){
- return this.attributes_map.get("rotation").getComponent(attributes_rotation);
- }
- getEditActiveCom(){
- return this.attributes_map.get("active").getComponent(attributes_active);
- }
- getQuestionCom(){
- return this.attributes_map.get("question_select").getComponent(attributes_question_select);
- }
- getCountDownCom(){
- return this.attributes_map.get("count_down").getComponent(attributes_count_down);
- }
- public getUrlCom(){
- return this.attributes_map.get("url").getComponent(attributes_res);
- }
- public getTextSoundCom(){
- return this.attributes_map.get("text_sound").getComponent(attributes_text_sound);
- }
-
- public getZIndexCom(){
- return this.attributes_map.get("z_index").getComponent(attributes_z_index);
- }
- showAllAtt(){
- this.attributes_map.forEach((v,k)=>{
- v.active = true;
- })
- }
- hideAllAtt(){
- this.attributes_map.forEach((v,k)=>{
- v.active = false;
- })
- }
- public get_cur_att_data(){
- return this.cur_att_data;
- }
- public get_cur_scene_all_widget():widget_item_data[]{ //获取当前所有控件
- let data = this._main.edit_scene_view.getCurSelectScene()
- // console.log('get_cur_scene_all_widget ==',data)
- if(!data){
- return []
- }
- let temp = []
- for (let index = 0; index < data.page_list.length; index++) {
- const element = data.page_list[index];
- for (let i = 0; i < element.page_widget_list.length; i++) {
- const widget = element.page_widget_list[i];
- widget.scene_type = data.type
- widget.scene_page_number = index+1
- temp.push(widget)
- if(widget.type==config.Widget_Type_List.CONTAINER_LAYER){
- for (let j = 0; j < widget.att.container_layer.widget_list.length; j++) {
- const container_widget = widget.att.container_layer.widget_list[j];
- container_widget.scene_type = data.type
- container_widget.scene_page_number = index+1
- container_widget.is_container_layer = true
- temp.push(container_widget)
- }
- }
- }
- }
- return temp;
- }
- public get_cur_scene_widget_by_type(type:number):widget_item_data[]{ //根据类型获取所有的
- let data = this._main.edit_scene_view.getCurSelectScene()
- if(!data){
- return []
- }
- let temp = []
- for (let index = 0; index < data.page_list.length; index++) {
- const element = data.page_list[index];
- for (let i = 0; i < element.page_widget_list.length; i++) {
- const widget = element.page_widget_list[i];
- widget.scene_type = data.type
- widget.scene_page_number = index+1
- if(type===widget.type){
- temp.push(widget)
- }
- if(type==config.Widget_Type_List.CONTAINER_LAYER){
- if(widget.att.container_layer!=null){
- for (let j = 0; j < widget.att.container_layer.widget_list.length; j++) {
- const container_widget = widget.att.container_layer.widget_list[j];
- container_widget.scene_type = data.type
- container_widget.scene_page_number = index+1
- container_widget.is_container_layer = true
- if(type===container_widget.type){
- temp.push(container_widget)
- }
- }
- }
- }
- }
- }
- return temp;
- }
- public get_cur_scene_all_only_widget(){ //获取当前所有控件
- let data = this._main.edit_scene_view.getCurSelectScene()
- if(!data){
- return []
- }
- let temp = []
- for (let index = 0; index < data.page_list.length; index++) {
- const element = data.page_list[index];
- for (let i = 0; i < element.page_widget_list.length; i++) {
- const widget = element.page_widget_list[i];
- widget.scene_type = data.type
- widget.scene_page_number = index+1
- if(widget.type!=config.Widget_Type_List.UI_TOP){
- temp.push(widget)
- }
- if(widget.type==config.Widget_Type_List.CONTAINER_LAYER){
- if(widget.att.container_layer!=null){
- for (let j = 0; j < widget.att.container_layer.widget_list.length; j++) {
- const container_widget = widget.att.container_layer.widget_list[j];
- container_widget.scene_type = data.type
- container_widget.scene_page_number = index+1
- container_widget.is_container_layer = true
- temp.push(container_widget)
- }
- }
- }
- }
- }
- return temp;
- }
- public get_cur_scene_widget_by_id(id:number){ // 根据控件id获取
- let data = this._main.edit_scene_view.getCurSelectScene()
- for (let index = 0; index < data.page_list.length; index++) {
- const element = data.page_list[index];
- for (let i = 0; i < element.page_widget_list.length; i++) {
- const widget = element.page_widget_list[i];
- widget.scene_type = data.type
- widget.scene_page_number = index+1
- if(widget.att.id===id){
- return widget;
- }
- if(widget.type==config.Widget_Type_List.CONTAINER_LAYER){
- if(widget.att.container_layer!=null){
- for (let j = 0; j < widget.att.container_layer.widget_list.length; j++) {
- const container_widget = widget.att.container_layer.widget_list[j];
- container_widget.scene_type = data.type
- container_widget.scene_page_number = index+1
- container_widget.is_container_layer = true
- if(container_widget.att.id===id){
- return container_widget;
- }
- }
- }
- }
- }
- }
- return null;
- }
- public get_widget_at_page_by_widget(select_widget:widget_item_data){ //根据widget 找到所属分页
- let page_index = 0;
- let data = this._main.edit_scene_view.getCurSelectScene()
- for (let index = 0; index < data.page_list.length; index++) {
- const element = data.page_list[index];
- for (let i = 0; i < element.page_widget_list.length; i++) {
- const widget = element.page_widget_list[i];
- widget.scene_type = data.type
- widget.scene_page_number = index+1
- if(widget.att.id===select_widget.att.id){
- page_index = index;
- break;
- }
- if(widget.type==config.Widget_Type_List.CONTAINER_LAYER){
- if(widget.att.container_layer!=null){
- for (let j = 0; j < widget.att.container_layer.widget_list.length; j++) {
- const container_widget = widget.att.container_layer.widget_list[j];
- container_widget.scene_type = data.type
- container_widget.scene_page_number = index+1
- container_widget.is_container_layer = true
- if(container_widget.att.id===select_widget.att.id){
- page_index = index;
- break;
- }
- }
- }
- }
- }
- }
- return page_index;
- }
- public get_scene_list(){
- let scene_list = this._main.control_view.get_bag_data().content;
- let temp = []
- for (let index = 0; index < scene_list.length; index++) {
- const s = scene_list[index];
- if(s.is_child_scene){
- temp.push(s)
- }
- }
- return temp;
- }
- ShowWidgetList(){
- let list = this.get_cur_scene_all_widget()
- if(list.length<=0){
- return tools.showToast("当前场景没有控件!")
- }
- tools.show_widget_list(list)
- }
- ShowALlChildScene(call){
- let list = this.get_scene_list()
- if(list.length<=0){
- return tools.showToast("还没有添加子场景")
- }
- tools.show_select_child_scene(list,call)
- }
- getEventList(){
- let data = this._main.edit_scene_view.getCurSelectScene()
- if(data._task_data == null) {
- return []
- }
- return data._task_data.event_list
- }
- getEventListByType(type:number) {
- let data = this._main.edit_scene_view.getCurSelectScene()
- let temp = []
- for (let index = 0; index < data._task_data.event_list.length; index++) {
- const element = data._task_data.event_list[index];
- if(element.type==type){
- temp.push(element)
- }
- }
- return temp
- }
- getBeActionEventList(){
- let data = this._main.edit_scene_view.getCurSelectScene()
- let temp = []
- for (let index = 0; index < data._task_data.event_list.length; index++) {
- const element = data._task_data.event_list[index];
- if(element.type==config.event_type.be_event){
- temp.push(element)
- }
- }
- return temp
- }
- getEventItemById(event_id:number){
- let list = this.getEventList();
- for (let index = 0; index < list.length; index++) {
- const element = list[index];
- if(event_id===element.event_id){
- return element;
- }
- }
- return null;
- }
- }
|