mirror of
https://github.com/tengge1/ShadowEditor.git
synced 2026-01-25 15:08:11 +00:00
删除模型窗口。
This commit is contained in:
parent
babb651ceb
commit
c2e2ef80d3
@ -1,5 +1,4 @@
|
||||
import UI from '../../ui/UI';
|
||||
import ModelWindow from '../window/ModelWindow';
|
||||
import TextureWindow from '../window/TextureWindow';
|
||||
import AudioWindow from '../window/AudioWindow';
|
||||
import MMDWindow from '../window/MMDWindow';
|
||||
@ -31,11 +30,6 @@ AssetMenu.prototype.render = function () {
|
||||
xtype: 'div',
|
||||
cls: 'options',
|
||||
children: [{
|
||||
xtype: 'div',
|
||||
html: '模型管理',
|
||||
cls: 'option',
|
||||
onClick: this.onManageModel.bind(this)
|
||||
}, {
|
||||
xtype: 'div',
|
||||
html: '纹理管理',
|
||||
cls: 'option',
|
||||
@ -108,16 +102,6 @@ AssetMenu.prototype.render = function () {
|
||||
container.render();
|
||||
}
|
||||
|
||||
// --------------------------------- 模型管理 --------------------------------------
|
||||
|
||||
AssetMenu.prototype.onManageModel = function () {
|
||||
if (this.modelWindow == null) {
|
||||
this.modelWindow = new ModelWindow({ parent: this.app.container, app: this.app });
|
||||
this.modelWindow.render();
|
||||
}
|
||||
this.modelWindow.show();
|
||||
};
|
||||
|
||||
// --------------------------------- 纹理管理 --------------------------------------
|
||||
|
||||
AssetMenu.prototype.onManageTexture = function () {
|
||||
|
||||
@ -1,125 +0,0 @@
|
||||
import UI from '../../ui/UI';
|
||||
import Ajax from '../../utils/Ajax';
|
||||
|
||||
/**
|
||||
* 模型编辑窗口
|
||||
* @author tengge / https://github.com/tengge1
|
||||
* @param {*} options
|
||||
*/
|
||||
function ModelEditWindow(options) {
|
||||
UI.Control.call(this, options);
|
||||
this.app = options.app;
|
||||
this.callback = options.callback || null;
|
||||
}
|
||||
|
||||
ModelEditWindow.prototype = Object.create(UI.Control.prototype);
|
||||
ModelEditWindow.prototype.constructor = ModelEditWindow;
|
||||
|
||||
ModelEditWindow.prototype.render = function () {
|
||||
var container = UI.create({
|
||||
xtype: 'window',
|
||||
id: 'window',
|
||||
scope: this.id,
|
||||
parent: this.parent,
|
||||
title: '编辑模型',
|
||||
width: '320px',
|
||||
height: '280px',
|
||||
shade: true,
|
||||
children: [{
|
||||
xtype: 'row',
|
||||
children: [{
|
||||
xtype: 'label',
|
||||
text: '名称'
|
||||
}, {
|
||||
xtype: 'input',
|
||||
id: 'name',
|
||||
scope: this.id
|
||||
}]
|
||||
}, {
|
||||
xtype: 'row',
|
||||
children: [{
|
||||
xtype: 'label',
|
||||
text: '缩略图'
|
||||
}, {
|
||||
xtype: 'imageuploader',
|
||||
id: 'image',
|
||||
scope: this.id,
|
||||
server: this.app.options.server
|
||||
}]
|
||||
}, {
|
||||
xtype: 'row',
|
||||
style: {
|
||||
justifyContent: 'center',
|
||||
marginTop: '8px'
|
||||
},
|
||||
children: [{
|
||||
xtype: 'button',
|
||||
text: '确定',
|
||||
style: {
|
||||
margin: '0 8px'
|
||||
},
|
||||
onClick: this.save.bind(this)
|
||||
}, {
|
||||
xtype: 'button',
|
||||
text: '取消',
|
||||
style: {
|
||||
margin: '0 8px'
|
||||
},
|
||||
onClick: this.hide.bind(this)
|
||||
}]
|
||||
}]
|
||||
});
|
||||
container.render();
|
||||
};
|
||||
|
||||
ModelEditWindow.prototype.show = function () {
|
||||
UI.get('window', this.id).show();
|
||||
};
|
||||
|
||||
ModelEditWindow.prototype.hide = function () {
|
||||
UI.get('window', this.id).hide();
|
||||
};
|
||||
|
||||
ModelEditWindow.prototype.setData = function (data) {
|
||||
this.data = data;
|
||||
this.updateUI();
|
||||
};
|
||||
|
||||
ModelEditWindow.prototype.updateUI = function () {
|
||||
if (this.data === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
var name = UI.get('name', this.id);
|
||||
var image = UI.get('image', this.id);
|
||||
name.setValue(this.data.Name);
|
||||
image.setValue(this.data.Thumbnail);
|
||||
};
|
||||
|
||||
ModelEditWindow.prototype.save = function () {
|
||||
var server = this.app.options.server;
|
||||
|
||||
if (this.data === undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
var name = UI.get('name', this.id);
|
||||
var image = UI.get('image', this.id);
|
||||
|
||||
Ajax.post(`${server}/api/Mesh/Edit`, {
|
||||
ID: this.data.ID,
|
||||
Name: name.getValue(),
|
||||
Image: image.getValue()
|
||||
}, json => {
|
||||
var obj = JSON.parse(json);
|
||||
UI.msg(obj.Msg);
|
||||
if (obj.Code === 200) {
|
||||
this.hide();
|
||||
if (typeof (this.callback) === 'function') {
|
||||
this.callback(obj);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export default ModelEditWindow;
|
||||
@ -1,104 +0,0 @@
|
||||
import UI from '../../ui/UI';
|
||||
import Ajax from '../../utils/Ajax';
|
||||
import ModelLoader from '../../loader/ModelLoader';
|
||||
import AddObjectCommand from '../../command/AddObjectCommand';
|
||||
import ModelEditWindow from './ModelEditWindow';
|
||||
|
||||
/**
|
||||
* 模型窗口
|
||||
* @author tengge / https://github.com/tengge1
|
||||
* @param {*} options
|
||||
*/
|
||||
function ModelWindow(options) {
|
||||
UI.ImageListWindow.call(this, options);
|
||||
this.app = options.app;
|
||||
|
||||
this.title = '模型列表';
|
||||
this.imageIcon = 'icon-model';
|
||||
this.cornerTextField = 'Type';
|
||||
this.uploadUrl = `${this.app.options.server}/api/Mesh/Add`;
|
||||
this.preImageUrl = this.app.options.server;
|
||||
this.showUploadButton = true;
|
||||
}
|
||||
|
||||
ModelWindow.prototype = Object.create(UI.ImageListWindow.prototype);
|
||||
ModelWindow.prototype.constructor = ModelWindow;
|
||||
|
||||
ModelWindow.prototype.beforeUpdateList = function () {
|
||||
var server = this.app.options.server;
|
||||
|
||||
return new Promise(resolve => {
|
||||
Ajax.getJson(`${server}/api/Mesh/List`, obj => {
|
||||
resolve(obj.Data);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
ModelWindow.prototype.onUpload = function (obj) {
|
||||
this.update();
|
||||
UI.msg(obj.Msg);
|
||||
};
|
||||
|
||||
ModelWindow.prototype.onClick = function (model) {
|
||||
var loader = new ModelLoader(this.app);
|
||||
|
||||
var url = model.Url;
|
||||
|
||||
if (model.Url.indexOf(';') > -1) { // 包含多个入口文件
|
||||
url = url.split(';').map(n => this.app.options.server + n);
|
||||
} else {
|
||||
url = this.app.options.server + model.Url;
|
||||
}
|
||||
|
||||
loader.load(url, model).then(obj => {
|
||||
if (!obj) {
|
||||
return;
|
||||
}
|
||||
obj.name = model.Name;
|
||||
|
||||
Object.assign(obj.userData, model, {
|
||||
Server: true
|
||||
});
|
||||
|
||||
var cmd = new AddObjectCommand(obj);
|
||||
cmd.execute();
|
||||
|
||||
if (obj.userData.scripts) {
|
||||
obj.userData.scripts.forEach(n => {
|
||||
this.app.editor.scripts[n.uuid] = n;
|
||||
});
|
||||
this.app.call('scriptChanged', this);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
ModelWindow.prototype.onEdit = function (data) {
|
||||
if (this.editWindow === undefined) {
|
||||
this.editWindow = new ModelEditWindow({
|
||||
app: this.app,
|
||||
parent: this.parent,
|
||||
callback: this.update.bind(this)
|
||||
});
|
||||
this.editWindow.render();
|
||||
}
|
||||
this.editWindow.setData(data);
|
||||
this.editWindow.show();
|
||||
};
|
||||
|
||||
ModelWindow.prototype.onDelete = function (data) {
|
||||
var server = this.app.options.server;
|
||||
|
||||
UI.confirm('询问', `是否删除模型${data.Name}?`, (event, btn) => {
|
||||
if (btn === 'ok') {
|
||||
Ajax.post(`${server}/api/Mesh/Delete?ID=${data.ID}`, json => {
|
||||
var obj = JSON.parse(json);
|
||||
if (obj.Code === 200) {
|
||||
this.update();
|
||||
}
|
||||
UI.msg(obj.Msg);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
export default ModelWindow;
|
||||
Loading…
x
Reference in New Issue
Block a user