From 83d2b896f2f3c4009c545b20df7eb6bad3ca20e2 Mon Sep 17 00:00:00 2001 From: liteng <930372551@qq.com> Date: Sun, 29 Jul 2018 13:04:43 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=A8=A1=E5=9E=8B=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/editor/menubar/AssetMenu.js | 10 ++++++++- src/event/EventDispatcher.js | 2 ++ src/event/EventList.js | 1 + src/event/menu/asset/AddAssetEvent.js | 32 +++++++++++++++++++++++++++ src/ui/ImageList.js | 3 +++ 5 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 src/event/menu/asset/AddAssetEvent.js diff --git a/src/editor/menubar/AssetMenu.js b/src/editor/menubar/AssetMenu.js index 992a17f4..8f3dc07f 100644 --- a/src/editor/menubar/AssetMenu.js +++ b/src/editor/menubar/AssetMenu.js @@ -27,9 +27,17 @@ AssetMenu.prototype.render = function () { xtype: 'div', cls: 'options', children: [{ + xtype: 'div', + id: 'mAddAsset', + html: '添加模型', + cls: 'option', + onClick: function () { + _this.app.call('mAddAsset'); + } + }, { xtype: 'div', id: 'mImportAsset', - html: '导入', + html: '导入模型', cls: 'option', onClick: function () { _this.app.call('mImportAsset'); diff --git a/src/event/EventDispatcher.js b/src/event/EventDispatcher.js index b22ea1ed..4f862bfe 100644 --- a/src/event/EventDispatcher.js +++ b/src/event/EventDispatcher.js @@ -78,6 +78,7 @@ import AddHemisphereLightEvent from './menu/add/AddHemisphereLightEvent'; import AddAmbientLightEvent from './menu/add/AddAmbientLightEvent'; import AddPerspectiveCameraEvent from './menu/add/AddPerspectiveCameraEvent'; +import AddAssetEvent from './menu/asset/AddAssetEvent'; import ImportAssetEvent from './menu/asset/ImportAssetEvent'; import ExportGeometryEvent from './menu/asset/ExportGeometryEvent'; import ExportObjectEvent from './menu/asset/ExportObjectEvent'; @@ -222,6 +223,7 @@ function EventDispatcher(app) { new AddAmbientLightEvent(this.app), new AddPerspectiveCameraEvent(this.app), + new AddAssetEvent(this.app), new ImportAssetEvent(this.app), new ExportGeometryEvent(this.app), new ExportObjectEvent(this.app), diff --git a/src/event/EventList.js b/src/event/EventList.js index a138f74f..fe5775b6 100644 --- a/src/event/EventList.js +++ b/src/event/EventList.js @@ -56,6 +56,7 @@ var EventList = [ 'mAddAmbientLight', // 添加环境光 'mAddPerspectiveCamera', // 添加透视相机 + 'mAddAsset', // 添加模型 'mImportAsset', // 导入资源 'mExportGeometry', // 导出几何体 'mExportObject', // 导出物体 diff --git a/src/event/menu/asset/AddAssetEvent.js b/src/event/menu/asset/AddAssetEvent.js new file mode 100644 index 00000000..68c982e1 --- /dev/null +++ b/src/event/menu/asset/AddAssetEvent.js @@ -0,0 +1,32 @@ +import MenuEvent from '../MenuEvent'; + +/** + * 添加资源事件 + * @param {*} app + */ +function AddAssetEvent(app) { + MenuEvent.call(this, app); +} + +AddAssetEvent.prototype = Object.create(MenuEvent.prototype); +AddAssetEvent.prototype.constructor = AddAssetEvent; + +AddAssetEvent.prototype.start = function () { + var _this = this; + this.app.on('mAddAsset.' + this.id, function () { + _this.onAddAsset(); + }); +}; + +AddAssetEvent.prototype.stop = function () { + this.app.on('mAddAsset.' + this.id, null); +}; + +AddAssetEvent.prototype.onAddAsset = function () { + var btn = UI.get('modelBtn'); + if (btn) { + btn.dom.click(); + } +}; + +export default AddAssetEvent; \ No newline at end of file diff --git a/src/ui/ImageList.js b/src/ui/ImageList.js index e413b3f9..9f3c7a0f 100644 --- a/src/ui/ImageList.js +++ b/src/ui/ImageList.js @@ -63,6 +63,9 @@ ImageList.prototype.render = function () { obj.onClick = onClick.bind(this); obj.render(); obj.dom.dataIndex = i; // 序号 + obj.img.dataIndex = i; + obj.editBtn.dom.dataIndex = i; + obj.deleteBtn.dom.dataIndex = i; // 说明 var description = document.createElement('div');