修复菜单各种bug。

This commit is contained in:
liteng 2019-07-04 07:48:21 +08:00
parent fbf04e1a35
commit cee84e9cfd
7 changed files with 108 additions and 129 deletions

View File

@ -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;
}

View File

@ -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');
// }
}
}

View File

@ -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)));
});
}

View File

@ -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 <>
<MenuItem title={L_HELP}>
<MenuItem title={L_SOURCE} onClick={this.handleSource}></MenuItem>
<MenuItem title={L_EXAMPLES} onClick={this.handleExamples}></MenuItem>
<MenuItem title={L_DOCUMENTS} onClick={this.handleDocuments}></MenuItem>
<MenuItem title={L_ABOUT} onClick={this.handleAbout}></MenuItem>
</MenuItem>
{this.state.showAbout && <Alert title={L_ABOUT} okText={L_OK}>
{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
</Alert>}
</>;
return <MenuItem title={L_HELP}>
<MenuItem title={L_SOURCE} onClick={this.handleSource}></MenuItem>
<MenuItem title={L_EXAMPLES} onClick={this.handleExamples}></MenuItem>
<MenuItem title={L_DOCUMENTS} onClick={this.handleDocuments}></MenuItem>
<MenuItem title={L_ABOUT} onClick={this.handleAbout}></MenuItem>
</MenuItem>;
}
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
`);
}
}

View File

@ -79,7 +79,7 @@ class PlayMenu extends React.Component {
var sceneID = app.editor.sceneID;
if (!sceneID) {
UI.msg('请先保存场景!');
app.toast('请先保存场景!');
return;
}

View File

@ -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');
});
}
});
});
}
}

View File

@ -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');
});
}
});
});
}
}