diff --git a/ShadowEditor.Web/src/editor2/menu/AssetsMenu.jsx b/ShadowEditor.Web/src/editor2/menu/AssetsMenu.jsx index cbd28be2..b03af171 100644 --- a/ShadowEditor.Web/src/editor2/menu/AssetsMenu.jsx +++ b/ShadowEditor.Web/src/editor2/menu/AssetsMenu.jsx @@ -39,14 +39,14 @@ class AssetsMenu extends React.Component { var object = editor.selected; if (object === null) { - UI.msg(L_PLEASE_SELECT_OBJECT); + app.toast(L_PLEASE_SELECT_OBJECT); return; } var geometry = object.geometry; if (geometry === undefined) { - UI.msg(L_OBJECT_SELECTED_IS_NOT_GEOMETRY); + app.toast(L_OBJECT_SELECTED_IS_NOT_GEOMETRY); return; } @@ -70,7 +70,7 @@ class AssetsMenu extends React.Component { var object = editor.selected; if (object === null) { - UI.msg(L_PLEASE_SELECT_OBJECT); + app.toast(L_PLEASE_SELECT_OBJECT); return; } diff --git a/ShadowEditor.Web/src/editor2/menu/EditMenu.jsx b/ShadowEditor.Web/src/editor2/menu/EditMenu.jsx index a7b30f0e..cf7b3f05 100644 --- a/ShadowEditor.Web/src/editor2/menu/EditMenu.jsx +++ b/ShadowEditor.Web/src/editor2/menu/EditMenu.jsx @@ -29,14 +29,15 @@ class EditMenu extends React.Component { } componentDidMount() { - // app.on(`historyChanged.${this.id}`, this.onHistoryChanged.bind(this)); - // app.on(`objectSelected.${this.id}`, this.onObjectSelected.bind(this)); + app.on(`historyChanged.${this.id}`, this.onHistoryChanged.bind(this)); + app.on(`objectSelected.${this.id}`, this.onObjectSelected.bind(this)); } // --------------------- 撤销 -------------------------- handleUndo() { var history = app.editor.history; + if (history.undos.length === 0) { return; } @@ -48,6 +49,7 @@ class EditMenu extends React.Component { handleRedo() { var history = app.editor.history; + if (history.redos.length === 0) { return; } @@ -65,10 +67,8 @@ class EditMenu extends React.Component { return; } - UI.confirm(L_CONFIRM, L_HISTORY_WILL_CLEAR, function (event, btn) { - if (btn === 'ok') { - editor.history.clear(); - } + app.confirm(L_CONFIRM, L_HISTORY_WILL_CLEAR, () => { + editor.history.clear(); }); } @@ -96,10 +96,8 @@ class EditMenu extends React.Component { return; } - UI.confirm(L_CONFIRM, L_DELETE + ' ' + object.name + '?', function (event, btn) { - if (btn === 'ok') { - editor.execute(new RemoveObjectCommand(object)); - } + app.confirm(L_CONFIRM, L_DELETE + ' ' + object.name + '?', () => { + editor.execute(new RemoveObjectCommand(object)); }); } @@ -108,42 +106,42 @@ class EditMenu extends React.Component { onHistoryChanged() { var history = app.editor.history; - var undo = UI.get('undo', this.id); - var redo = UI.get('redo', this.id); - var clearHistory = UI.get('clearHistory', this.id); + // var undo = UI.get('undo', this.id); + // var redo = UI.get('redo', this.id); + // var clearHistory = UI.get('clearHistory', this.id); - if (history.undos.length === 0) { - undo.dom.classList.add('inactive'); - } else { - undo.dom.classList.remove('inactive'); - } + // if (history.undos.length === 0) { + // undo.dom.classList.add('inactive'); + // } else { + // undo.dom.classList.remove('inactive'); + // } - if (history.redos.length === 0) { - redo.dom.classList.add('inactive'); - } else { - redo.dom.classList.remove('inactive'); - } + // if (history.redos.length === 0) { + // redo.dom.classList.add('inactive'); + // } else { + // redo.dom.classList.remove('inactive'); + // } - if (history.undos.length === 0 && history.redos.length === 0) { - clearHistory.dom.classList.add('inactive'); - } else { - clearHistory.dom.classList.remove('inactive'); - } + // if (history.undos.length === 0 && history.redos.length === 0) { + // clearHistory.dom.classList.add('inactive'); + // } else { + // clearHistory.dom.classList.remove('inactive'); + // } } onObjectSelected() { var editor = app.editor; - var clone = UI.get('clone', this.id); - var deleteBtn = UI.get('delete', this.id); + // var clone = UI.get('clone', this.id); + // var deleteBtn = UI.get('delete', this.id); - if (editor.selected && editor.selected.parent != null) { - clone.dom.classList.remove('inactive'); - deleteBtn.dom.classList.remove('inactive'); - } else { - clone.dom.classList.add('inactive'); - deleteBtn.dom.classList.add('inactive'); - } + // if (editor.selected && editor.selected.parent != null) { + // clone.dom.classList.remove('inactive'); + // deleteBtn.dom.classList.remove('inactive'); + // } else { + // clone.dom.classList.add('inactive'); + // deleteBtn.dom.classList.add('inactive'); + // } } } diff --git a/ShadowEditor.Web/src/editor2/menu/GeometryMenu.jsx b/ShadowEditor.Web/src/editor2/menu/GeometryMenu.jsx index 3ed8fc3d..f9cf5bb3 100644 --- a/ShadowEditor.Web/src/editor2/menu/GeometryMenu.jsx +++ b/ShadowEditor.Web/src/editor2/menu/GeometryMenu.jsx @@ -151,7 +151,7 @@ class GeometryMenu extends React.Component { // ---------------------- 文本 ---------------------------------- handleAddText() { - UI.prompt(L_PLEASE_INPUT, null, L_SOME_WORDS, (event, value) => { + app.prompt(L_PLEASE_INPUT, null, L_SOME_WORDS, () => { app.editor.execute(new AddObjectCommand(new Text(value))); }); } diff --git a/ShadowEditor.Web/src/editor2/menu/HelpMenu.jsx b/ShadowEditor.Web/src/editor2/menu/HelpMenu.jsx index 21b0e536..96cdae10 100644 --- a/ShadowEditor.Web/src/editor2/menu/HelpMenu.jsx +++ b/ShadowEditor.Web/src/editor2/menu/HelpMenu.jsx @@ -1,4 +1,4 @@ -import { classNames, PropTypes, MenuBar, MenuItem, MenuItemSeparator, Alert } from '../../third_party'; +import { classNames, PropTypes, MenuBar, MenuItem, MenuItemSeparator } from '../../third_party'; /** * 帮助菜单 @@ -8,10 +8,6 @@ class HelpMenu extends React.Component { constructor(props) { super(props); - this.state = { - showAbout: false, - }; - this.handleSource = this.handleSource.bind(this); this.handleExamples = this.handleExamples.bind(this); this.handleDocuments = this.handleDocuments.bind(this); @@ -19,21 +15,12 @@ class HelpMenu extends React.Component { } render() { - return <> - - - - - - - {this.state.showAbout && - {L_NAME}: ShadowEditor - {L_AUTHOR}: tengge - {L_LISENSE}: MIT - {L_SOURCE}1: https://github.com/tengge1/ShadowEditor - {L_SOURCE}2: https://gitee.com/tengge1/ShadowEditor - } - ; + return + + + + + ; } handleSource() { @@ -49,9 +36,13 @@ class HelpMenu extends React.Component { } handleAbout() { - this.setState({ - showAbout: true, - }); + app.alert('L_ABOUT', ` + {L_NAME}: ShadowEditor + {L_AUTHOR}: tengge + {L_LISENSE}: MIT + {L_SOURCE}1: https://github.com/tengge1/ShadowEditor + {L_SOURCE}2: https://gitee.com/tengge1/ShadowEditor + `); } } diff --git a/ShadowEditor.Web/src/editor2/menu/PlayMenu.jsx b/ShadowEditor.Web/src/editor2/menu/PlayMenu.jsx index 0d9cf96f..82ee613a 100644 --- a/ShadowEditor.Web/src/editor2/menu/PlayMenu.jsx +++ b/ShadowEditor.Web/src/editor2/menu/PlayMenu.jsx @@ -79,7 +79,7 @@ class PlayMenu extends React.Component { var sceneID = app.editor.sceneID; if (!sceneID) { - UI.msg('请先保存场景!'); + app.toast('请先保存场景!'); return; } diff --git a/ShadowEditor.Web/src/editor2/menu/SceneMenu.jsx b/ShadowEditor.Web/src/editor2/menu/SceneMenu.jsx index e1437ad2..b0bae604 100644 --- a/ShadowEditor.Web/src/editor2/menu/SceneMenu.jsx +++ b/ShadowEditor.Web/src/editor2/menu/SceneMenu.jsx @@ -140,7 +140,7 @@ class SceneMenu extends React.Component { sceneName = L_NEW_SCENE; } - UI.prompt(L_SAVE_SCENE, L_NAME, sceneName, (event, name) => { + app.prompt(L_SAVE_SCENE, L_NAME, sceneName, name => { app.editor.sceneName = name; document.title = name; this.commitSaveAs(name); @@ -184,23 +184,21 @@ class SceneMenu extends React.Component { var sceneID = app.editor.sceneID; if (!sceneID) { - UI.msg('请先打开场景!'); + app.toast('请先打开场景!'); return; } - UI.confirm('询问', '是否导出当前场景?', (event, btn) => { - if (btn === 'ok') { - fetch(`${app.options.server}/api/ExportScene/Run?ID=${sceneID}`, { - method: 'POST' - }).then(response => { - if (response.ok) { - response.json().then(json => { - UI.msg(json.Msg); - window.open(`${app.options.server}${json.Url}`, 'export'); - }); - } - }); - } + app.confirm('询问', '是否导出当前场景?', () => { + fetch(`${app.options.server}/api/ExportScene/Run?ID=${sceneID}`, { + method: 'POST' + }).then(response => { + if (response.ok) { + response.json().then(json => { + app.toast(json.Msg); + window.open(`${app.options.server}${json.Url}`, 'export'); + }); + } + }); }); } } diff --git a/ShadowEditor.Web/src/editor2/menu/ToolMenu.jsx b/ShadowEditor.Web/src/editor2/menu/ToolMenu.jsx index c3fbdcda..d940d67a 100644 --- a/ShadowEditor.Web/src/editor2/menu/ToolMenu.jsx +++ b/ShadowEditor.Web/src/editor2/menu/ToolMenu.jsx @@ -27,67 +27,59 @@ class ToolMenu extends React.Component { } handleArrangeMap() { - UI.confirm('询问', '整理贴图会去除名称后的数字和下划线,重新生成数据表和贴图目录,移除空文件夹和未引用贴图文件,系统会自动备份数据表和贴图目录,是否整理?', (event, btn) => { - if (btn === 'ok') { - fetch(`${app.options.server}/api/ArrangeMap/Run`, { - method: 'POST' - }).then(response => { - if (response.ok) { - response.json().then(json => { - UI.msg(json.Msg); - }); - } - }); - } + app.confirm('询问', '整理贴图会去除名称后的数字和下划线,重新生成数据表和贴图目录,移除空文件夹和未引用贴图文件,系统会自动备份数据表和贴图目录,是否整理?', () => { + fetch(`${app.options.server}/api/ArrangeMap/Run`, { + method: 'POST' + }).then(response => { + if (response.ok) { + response.json().then(json => { + UI.msg(json.Msg); + }); + } + }); }); } handleArrangeMesh() { - UI.confirm('询问', '整理模型会去除名称后的数字和下划线,重新生成数据表、模型目录,移除空文件夹和未引用模型文件,系统会自动备份数据表、模型目录,是否整理?', (event, btn) => { - if (btn === 'ok') { - fetch(`${app.options.server}/api/ArrangeMesh/Run`, { - method: 'POST' - }).then(response => { - if (response.ok) { - response.json().then(json => { - UI.msg(json.Msg); - }); - } - }); - } + app.confirm('询问', '整理模型会去除名称后的数字和下划线,重新生成数据表、模型目录,移除空文件夹和未引用模型文件,系统会自动备份数据表、模型目录,是否整理?', () => { + fetch(`${app.options.server}/api/ArrangeMesh/Run`, { + method: 'POST' + }).then(response => { + if (response.ok) { + response.json().then(json => { + UI.msg(json.Msg); + }); + } + }); }); } handleArrangeThumbnail() { - UI.confirm('询问', '整理缩略图会重新生成缩略图目录,修改场景、模型、贴图、材质、音频、动画、粒子、预设体、人物的缩略图路径,请先手动备份数据库,是否整理?', (event, btn) => { - if (btn === 'ok') { - fetch(`${app.options.server}/api/ArrangeThumbnail/Run`, { - method: 'POST' - }).then(response => { - if (response.ok) { - response.json().then(json => { - UI.msg(json.Msg); - }); - } - }); - } + app.confirm('询问', '整理缩略图会重新生成缩略图目录,修改场景、模型、贴图、材质、音频、动画、粒子、预设体、人物的缩略图路径,请先手动备份数据库,是否整理?', () => { + fetch(`${app.options.server}/api/ArrangeThumbnail/Run`, { + method: 'POST' + }).then(response => { + if (response.ok) { + response.json().then(json => { + UI.msg(json.Msg); + }); + } + }); }); } handleExportEditor() { - UI.confirm('询问', '是否导出编辑器?', (event, btn) => { - if (btn === 'ok') { - fetch(`${app.options.server}/api/ExportEditor/Run`, { - method: 'POST' - }).then(response => { - if (response.ok) { - response.json().then(json => { - UI.msg(json.Msg); - window.open(`${app.options.server}${json.Url}`, 'export'); - }); - } - }); - } + app.confirm('询问', '是否导出编辑器?', () => { + fetch(`${app.options.server}/api/ExportEditor/Run`, { + method: 'POST' + }).then(response => { + if (response.ok) { + response.json().then(json => { + UI.msg(json.Msg); + window.open(`${app.options.server}${json.Url}`, 'export'); + }); + } + }); }); } }