xx 11 luni în urmă
părinte
comite
32891cf79b

+ 19 - 0
assets/edit_game.scene

@@ -184569,6 +184569,25 @@
     },
     "_enabled": true,
     "__prefab": null,
+    "btn_add_image": {
+      "__id__": 4972
+    },
+    "btn_add_animation": {
+      "__id__": 4982
+    },
+    "btn_add_drop": {
+      "__id__": 4992
+    },
+    "btn_add_click": {
+      "__id__": 5002
+    },
+    "btn_add_slide": {
+      "__id__": 5012
+    },
+    "item_prefab": {
+      "__uuid__": "26a4ee93-2eda-4748-8fe4-558a29b656a3",
+      "__expectedType__": "cc.Prefab"
+    },
     "_id": "73+R8Z5LVAGa2gA4pA2hNk"
   },
   {

+ 22 - 1
assets/resources/prefab/widget_item.prefab

@@ -53,10 +53,13 @@
       },
       {
         "__id__": 142
+      },
+      {
+        "__id__": 144
       }
     ],
     "_prefab": {
-      "__id__": 144
+      "__id__": 146
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -3405,6 +3408,24 @@
     "__type__": "cc.CompPrefabInfo",
     "fileId": "f6ikh2CUNNY4BucifygRBg"
   },
+  {
+    "__type__": "cc.BlockInputEvents",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 1
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 145
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "422cSG4iVOMo4JsUw8iWJi"
+  },
   {
     "__type__": "cc.PrefabInfo",
     "root": {

+ 11 - 1
assets/script/edit/Attributes.ts

@@ -27,6 +27,7 @@ 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')
@@ -112,9 +113,17 @@ export class Attributes extends Component {
         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(){
+
+    }
+
     onChangeRemark(text: string) {
         this.cur_att_data.remark = text
         ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,this.cur_att_data,config.attributes_list_type.remark)
@@ -265,6 +274,7 @@ export class Attributes extends Component {
                 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){
@@ -309,7 +319,7 @@ export class Attributes extends Component {
                     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("rotation").active = true;
+                    this.attributes_map.get("container").active = true;
                 }
             }else if(data.type===config.attributes_type.scene){
                 this.hideAllAtt()

+ 58 - 14
assets/script/edit/attributes/attributes_container.ts

@@ -1,14 +1,58 @@
-import { _decorator, Component, Node } from 'cc';
-const { ccclass, property } = _decorator;
-
-@ccclass('attributes_container')
-export class attributes_container extends Component {
-    start() {
-
-    }
-
-    update(deltaTime: number) {
-        
-    }
-}
-

+import { _decorator, Component, instantiate, Node, Prefab } from 'cc';
+import { Attributes } from '../Attributes';
+import { config } from '../../config';
+import { widget_item } from '../widget_item';
+import { att_click_data, att_container } from '../../../data/data';
+const { ccclass, property } = _decorator;
+
+@ccclass('attributes_container')
+export class attributes_container extends Component {
+    @property(Node) btn_add_image:Node = null;
+    @property(Node) btn_add_animation:Node = null;
+    @property(Node) btn_add_drop:Node = null;
+    @property(Node) btn_add_click:Node = null;
+    @property(Node) btn_add_slide:Node = null;
+    @property(Prefab) item_prefab:Prefab = null;
+    private cur_att_manager:Attributes = null
+    private call_back = null;
+    public initView(call,att_manager:Attributes){
+        this.cur_att_manager = att_manager
+        this.call_back = call;
+       
+    }
+
+    addWidgetByType(type:number){
+        // let node = instantiate(this.item_prefab)
+        let node =  this.cur_att_manager.getMain().control_view.getWidgetByType(type)
+        // node.getComponent(widget_item).initWidgetByScene(data)
+        this.cur_att_manager.getMain().onPushEndWidget(node,Attributes.Singleton.get_cur_att_data().id)  
+    }
+    start() {
+        this.btn_add_animation.on(Node.EventType.TOUCH_END,()=>{
+            this.addWidgetByType(config.Widget_Type_List.ACTION_TYPE)
+        })
+
+        this.btn_add_image.on(Node.EventType.TOUCH_END,()=>{
+            this.addWidgetByType(config.Widget_Type_List.IMG_TYPE)
+        })
+
+        this.btn_add_drop.on(Node.EventType.TOUCH_END,()=>{
+            this.addWidgetByType(config.Widget_Type_List.DRAG_TYPE)
+        })
+
+        this.btn_add_click.on(Node.EventType.TOUCH_END,()=>{
+            this.addWidgetByType(config.Widget_Type_List.CLICK_TYPE)
+        })
+
+        this.btn_add_slide.on(Node.EventType.TOUCH_END,()=>{
+            this.addWidgetByType(config.Widget_Type_List.SLIDE_TYPE)
+        })
+    }
+
+  
+    update(deltaTime: number) {
+        
+    }
+}
+
+

+ 10 - 0
assets/script/edit/control.ts

@@ -5,6 +5,7 @@ import { res_list } from './res_list';
 import { edit_scene } from './edit_scene';
 import { main } from '../main';
 import { gameManager } from '../run/gameManager';
+import { widget_list } from './widget_list';
 const { ccclass, property } = _decorator;
 
 @ccclass('control')
@@ -143,6 +144,15 @@ export class control extends Component {
         return null;
     }
 
+    public getWidgetData(type:number){
+       return  this.widget_list.getComponent(widget_list).getWidgetDataByType(type)
+    }
+
+    public getWidgetByType(type:number){
+        return  this.widget_list.getComponent(widget_list).getWidgetByType(type)
+     }
+ 
+
     update_res_select_views(){
         for (let index = 0; index < this.res_view_list.length; index++) {
             const element = this.res_view_list[index];

+ 8 - 3
assets/script/edit/cur_edit_scene.ts

@@ -23,7 +23,7 @@ export class cur_edit_scene extends Component {
         this.node.removeAllChildren()
         this.m_edit_scene = _edit_scene;
     }
-    DragWidgetEnd(){
+    DragWidgetEnd(container_id:number=-1){
         if(this.m_edit_scene.getMain().action_node.children.length>0){
             let base_v = this.getCurEditBaseView()
             if(base_v===null){
@@ -44,8 +44,13 @@ export class cur_edit_scene extends Component {
                 }else{
                     node.position = pos;
                 }
-             
-                page.getComponent(scroll_scene).addWidget(node)
+                if(container_id==-1){
+                    page.getComponent(scroll_scene).addWidget(node)
+                }else{
+                    node.position = new Vec3(0,0);
+                    page.getComponent(scroll_scene).addContainer(container_id,node)
+                }
+                
                 //添加数据
                 // let scene_data = this.getCurEditSceneData()
                 // let cur_page_num = this.getCurEditBaseView().cur_page();

+ 18 - 0
assets/script/edit/scroll_scene.ts

@@ -3,6 +3,7 @@ import { attributes_data, scene_item_data } from '../../data/data';
 import { config } from '../config';
 import { ClientEvent } from '../clientEvent';
 import { tools } from '../tools';
+import { widget_item } from './widget_item';
 const { ccclass, property } = _decorator;
 
 @ccclass('scroll_scene')
@@ -93,6 +94,23 @@ export class scroll_scene extends Component {
         node.parent = this.getBg()
     }
 
+    public addContainer(container_id:number,node:Node){
+        let container = this.getWidget(container_id)
+        if(container!=null){
+            node.parent = container
+        }
+    }
+
+    public getWidget(widget_id:number){
+        let list = this.getBg().children
+        for (let index = 0; index < list.length; index++) {
+            const element = list[index];
+            if(element.getComponent(widget_item).getData().att.id==widget_id){
+                return element
+            }
+        }
+    }
+
     public initView(is_mask:boolean,att_data:attributes_data=null){
         if(att_data!=null){
             this.m_att =att_data;

+ 7 - 1
assets/script/edit/widget_item.ts

@@ -296,7 +296,13 @@ export class widget_item extends Component {
             this.node.on(Node.EventType.MOUSE_DOWN,(et:EventTouch)=>{
                 ClientEvent.dispatchEvent(config.Event.UpdateAttributes,this.getWidgetAtt())
             })
-        }else{
+        }
+        else if(this.m_data.type==config.Widget_Type_List.CONTAINER_LAYER){
+            this.node.on(Node.EventType.MOUSE_DOWN,(et:EventTouch)=>{
+                ClientEvent.dispatchEvent(config.Event.UpdateAttributes,this.getWidgetAtt())
+            })
+        }
+        else{
             this.node.on(Node.EventType.TOUCH_MOVE,(et:EventTouch)=>{
                 if(this.isMove){
                     let p = new Vec3(et.getUILocation().x,et.getUILocation().y)

+ 20 - 0
assets/script/edit/widget_list.ts

@@ -18,6 +18,26 @@ export class widget_list extends Component {
             item.getComponent(widget_item).initView(v)
         })
     }
+
+    public getWidgetDataByType(type:number){
+        let content = this.node.getComponent(ScrollView).content
+        for (let index = 0; index < content.children.length; index++) {
+            const element = content.children[index];
+            if(element.getComponent(widget_item).getData().type==type){
+                return element.getComponent(widget_item).getData()
+            }
+        }
+    }
+
+    public getWidgetByType(type:number){
+        let content = this.node.getComponent(ScrollView).content
+        for (let index = 0; index < content.children.length; index++) {
+            const element = content.children[index];
+            if(element.getComponent(widget_item).getData().type==type){
+                return element
+            }
+        }
+    }
 }
 
 

+ 7 - 0
assets/script/main.ts

@@ -206,6 +206,13 @@ export class main extends Component {
     IsHaveDragActionRes(){
         return this.res_action_node.children.length>0
     }
+
+    public onPushEndWidget(node:Node,container_id:number){
+        this.onDragWidget(node)
+        ClientEvent.dispatchEvent(config.Event.DragWidgetEnd,container_id)
+        this.action_node.removeAllChildren()
+        this.action_node.active = false;
+    }
 }