future il y a 11 mois
Parent
commit
8d769c004d

+ 220 - 5
assets/resources/prefab/widget_item.prefab

@@ -41,19 +41,22 @@
       },
       {
         "__id__": 118
+      },
+      {
+        "__id__": 132
       }
     ],
     "_active": true,
     "_components": [
       {
-        "__id__": 132
+        "__id__": 140
       },
       {
-        "__id__": 134
+        "__id__": 142
       }
     ],
     "_prefab": {
-      "__id__": 136
+      "__id__": 144
     },
     "_lpos": {
       "__type__": "cc.Vec3",
@@ -3095,6 +3098,215 @@
     "targetOverrides": null,
     "nestedPrefabInstanceRoots": null
   },
+  {
+    "__type__": "cc.Node",
+    "_name": "btn_delete",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": {
+      "__id__": 1
+    },
+    "_children": [],
+    "_active": false,
+    "_components": [
+      {
+        "__id__": 133
+      },
+      {
+        "__id__": 135
+      },
+      {
+        "__id__": 137
+      }
+    ],
+    "_prefab": {
+      "__id__": 139
+    },
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": 90.313,
+      "y": 90,
+      "z": 0
+    },
+    "_lrot": {
+      "__type__": "cc.Quat",
+      "x": 0,
+      "y": 0,
+      "z": 0,
+      "w": 1
+    },
+    "_lscale": {
+      "__type__": "cc.Vec3",
+      "x": 1,
+      "y": 1,
+      "z": 1
+    },
+    "_mobility": 0,
+    "_layer": 33554432,
+    "_euler": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 132
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 134
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 20,
+      "height": 20
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "d6qM05tm1N+b/6tDSvO3T0"
+  },
+  {
+    "__type__": "cc.Sprite",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 132
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 136
+    },
+    "_customMaterial": null,
+    "_srcBlendFactor": 2,
+    "_dstBlendFactor": 4,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_spriteFrame": {
+      "__uuid__": "64c1f2bf-dc82-4530-bd30-7879d5a3e03e@f9941",
+      "__expectedType__": "cc.SpriteFrame"
+    },
+    "_type": 1,
+    "_fillType": 0,
+    "_sizeMode": 0,
+    "_fillCenter": {
+      "__type__": "cc.Vec2",
+      "x": 0,
+      "y": 0
+    },
+    "_fillStart": 0,
+    "_fillRange": 0,
+    "_isTrimmedMode": true,
+    "_useGrayscale": false,
+    "_atlas": null,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "15AABJg25JAKJv0MooeWFG"
+  },
+  {
+    "__type__": "cc.Button",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 132
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 138
+    },
+    "clickEvents": [],
+    "_interactable": true,
+    "_transition": 3,
+    "_normalColor": {
+      "__type__": "cc.Color",
+      "r": 214,
+      "g": 214,
+      "b": 214,
+      "a": 255
+    },
+    "_hoverColor": {
+      "__type__": "cc.Color",
+      "r": 211,
+      "g": 211,
+      "b": 211,
+      "a": 255
+    },
+    "_pressedColor": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_disabledColor": {
+      "__type__": "cc.Color",
+      "r": 124,
+      "g": 124,
+      "b": 124,
+      "a": 255
+    },
+    "_normalSprite": {
+      "__uuid__": "64c1f2bf-dc82-4530-bd30-7879d5a3e03e@f9941",
+      "__expectedType__": "cc.SpriteFrame"
+    },
+    "_hoverSprite": {
+      "__uuid__": "20835ba4-6145-4fbc-a58a-051ce700aa3e@f9941",
+      "__expectedType__": "cc.SpriteFrame"
+    },
+    "_pressedSprite": {
+      "__uuid__": "544e49d6-3f05-4fa8-9a9e-091f98fc2ce8@f9941",
+      "__expectedType__": "cc.SpriteFrame"
+    },
+    "_disabledSprite": {
+      "__uuid__": "951249e0-9f16-456d-8b85-a6ca954da16b@f9941",
+      "__expectedType__": "cc.SpriteFrame"
+    },
+    "_duration": 0.1,
+    "_zoomScale": 1.2,
+    "_target": {
+      "__id__": 132
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "dbCLsw5xFLZajhxnED0YAF"
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "d4SMJxOgNAu4YoGwSiaYhm",
+    "instance": null,
+    "targetOverrides": null,
+    "nestedPrefabInstanceRoots": null
+  },
   {
     "__type__": "cc.UITransform",
     "_name": "",
@@ -3105,7 +3317,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 133
+      "__id__": 141
     },
     "_contentSize": {
       "__type__": "cc.Size",
@@ -3133,7 +3345,7 @@
     },
     "_enabled": true,
     "__prefab": {
-      "__id__": 135
+      "__id__": 143
     },
     "lab_name": {
       "__id__": 17
@@ -3184,6 +3396,9 @@
     "btn_look_voice_text": {
       "__id__": 118
     },
+    "btn_delete": {
+      "__id__": 132
+    },
     "_id": ""
   },
   {

+ 14 - 2
assets/script/edit/show_widget_list.ts

@@ -4,6 +4,7 @@ import { widget_item } from './widget_item';
 import { widget_item_data } from '../../data/data';
 import { ClientEvent } from '../clientEvent';
 import { config } from '../config';
+import { tools } from '../tools';
 const { ccclass, property } = _decorator;
 
 @ccclass('show_widget_list')
@@ -19,8 +20,11 @@ export class show_widget_list extends Component {
             const element = list[index];
             let item = instantiate(this.item_prefab)
             item.parent = this.content;
-            item.getComponent(widget_item).initHideDragOtherList()
-            item.getComponent(widget_item).initView(element,this.onItemClick.bind(this),null)
+            let item_component = item.getComponent(widget_item)
+            item_component.initHideDragOtherList()
+            item_component.initView(element,this.onItemClick.bind(this),null)
+            item_component.showButtonDelete(true,this.onItemDeleteClick.bind(this))
+
         }
         this.btn_close.on(Node.EventType.TOUCH_END,()=>{
             this.close()
@@ -61,6 +65,14 @@ export class show_widget_list extends Component {
         ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,data.att,config.attributes_list_type.active)
     }
 
+    onItemDeleteClick(item:widget_item) {
+        let data = item.getData()
+        tools.show_dialog('是否删除当前控件',()=>{
+            item.node.removeFromParent()
+            ClientEvent.dispatchEvent(config.Event.UpdateAttributesToView,data.att,config.attributes_list_type.delete)
+        })
+    }
+
     close(){
         this.node.destroy()
     }

+ 14 - 0
assets/script/edit/widget_item.ts

@@ -28,6 +28,7 @@ export class widget_item extends Component {
     @property(Node) other_drag_content:Node = null;
     @property(Node) lab_remark:Node = null;
     @property(Node) btn_look_voice_text:Node = null;
+    @property(Node) btn_delete:Node = null;
     private m_data:widget_item_data = null;
     private m_att:attributes_data = null;
     private isMove:boolean = false;
@@ -39,6 +40,12 @@ export class widget_item extends Component {
     private x_len:number = 0;
     private y_len:number = 0;
     private m_isShowDragOtherList:boolean = false;
+    private m_delete_cb = null;
+    protected start(): void {
+        this.btn_delete.on(Node.EventType.TOUCH_END, ()=>{
+            this.m_delete_cb && this.m_delete_cb(this)
+        })
+    }
     public initHideDragOtherList() {
         // 点击->控件列表,不显示拖拽其他按钮
         this.m_isShowDragOtherList = true
@@ -88,6 +95,13 @@ export class widget_item extends Component {
         }
     }
 
+    public showButtonDelete(is_show:boolean, delete_cb:Function) {
+        this.btn_delete.active = is_show
+        if(is_show) {
+            this.m_delete_cb = delete_cb
+        }
+    }
+
     public getShowWidgetData(){
         return this.m_data;
     }