浏览代码

Added command property 'name'

- allows us to give every command a unique description
- especially useful for CmdMultiCmds
Daniel 9 年之前
父节点
当前提交
476cc0509e

+ 3 - 0
editor/js/Cmd.js

@@ -8,6 +8,7 @@ Cmd = function () {
 	this.serialized = false;
 	this.serialized = false;
 	this.updatable = false;
 	this.updatable = false;
 	this.type = '';
 	this.type = '';
+	this.name = '';
 
 
 };
 };
 
 
@@ -16,6 +17,7 @@ Cmd.prototype.toJSON = function () {
 	var output = {};
 	var output = {};
 	output.type = this.type;
 	output.type = this.type;
 	output.id = this.id;
 	output.id = this.id;
+	output.name = this.name;
 	return output;
 	return output;
 
 
 };
 };
@@ -24,5 +26,6 @@ Cmd.prototype.fromJSON = function ( json ) {
 
 
 	this.type = json.type;
 	this.type = json.type;
 	this.id = json.id;
 	this.id = json.id;
+	this.name = json.name;
 
 
 };
 };

+ 1 - 0
editor/js/CmdAddObject.js

@@ -7,6 +7,7 @@ CmdAddObject = function ( object ) {
 	Cmd.call( this );
 	Cmd.call( this );
 
 
 	this.type = 'CmdAddObject';
 	this.type = 'CmdAddObject';
+	this.name = 'Add object';
 
 
 	this.object = object;
 	this.object = object;
 	if ( object !== undefined ) {
 	if ( object !== undefined ) {

+ 1 - 0
editor/js/CmdAddScript.js

@@ -7,6 +7,7 @@ CmdAddScript = function ( object, script ) {
 	Cmd.call( this );
 	Cmd.call( this );
 
 
 	this.type = 'CmdAddScript';
 	this.type = 'CmdAddScript';
+	this.name = 'Add script';
 
 
 	this.object = object;
 	this.object = object;
 	this.objectUuid = object !== undefined ? object.uuid : undefined;
 	this.objectUuid = object !== undefined ? object.uuid : undefined;

+ 1 - 0
editor/js/CmdMoveObject.js

@@ -7,6 +7,7 @@ CmdMoveObject = function ( object, newParent, newBefore ) {
 	Cmd.call( this );
 	Cmd.call( this );
 
 
 	this.type = 'CmdMoveObject';
 	this.type = 'CmdMoveObject';
+	this.name = 'Move object';
 
 
 	this.object = object;
 	this.object = object;
 	this.objectUuid = object !== undefined ? object.uuid : undefined;
 	this.objectUuid = object !== undefined ? object.uuid : undefined;

+ 1 - 0
editor/js/CmdMultiCmds.js

@@ -7,6 +7,7 @@ CmdMultiCmds = function ( cmdArray ) {
 	Cmd.call( this );
 	Cmd.call( this );
 
 
 	this.type = 'CmdMultiCmds';
 	this.type = 'CmdMultiCmds';
+	this.name = 'Multiple Changes';
 
 
 	this.cmdArray = cmdArray !== undefined ? cmdArray : [];
 	this.cmdArray = cmdArray !== undefined ? cmdArray : [];
 
 

+ 1 - 0
editor/js/CmdRemoveObject.js

@@ -7,6 +7,7 @@ CmdRemoveObject = function ( object ) {
 	Cmd.call( this );
 	Cmd.call( this );
 
 
 	this.type = 'CmdRemoveObject';
 	this.type = 'CmdRemoveObject';
+	this.name = 'Remove object';
 
 
 	this.object = object;
 	this.object = object;
 	this.parent = object !== undefined ? object.parent : undefined;
 	this.parent = object !== undefined ? object.parent : undefined;

+ 1 - 0
editor/js/CmdRemoveScript.js

@@ -7,6 +7,7 @@ CmdRemoveScript = function ( object, script ) {
 	Cmd.call( this );
 	Cmd.call( this );
 
 
 	this.type = 'CmdRemoveScript';
 	this.type = 'CmdRemoveScript';
+	this.name = 'Remove script';
 
 
 	this.object = object;
 	this.object = object;
 	this.objectUuid = object !== undefined ? object.uuid : undefined;
 	this.objectUuid = object !== undefined ? object.uuid : undefined;

+ 1 - 0
editor/js/CmdSetColor.js

@@ -7,6 +7,7 @@ CmdSetColor = function ( object, attributeName, newValue ) {
 	Cmd.call( this );
 	Cmd.call( this );
 
 
 	this.type = 'CmdSetColor';
 	this.type = 'CmdSetColor';
+	this.name = 'Set ' + attributeName;
 	this.updatable = true;
 	this.updatable = true;
 
 
 	this.object = object;
 	this.object = object;

+ 1 - 0
editor/js/CmdSetGeometry.js

@@ -7,6 +7,7 @@ CmdSetGeometry = function ( object, newGeometry ) {
 	Cmd.call( this );
 	Cmd.call( this );
 
 
 	this.type = 'CmdSetGeometry';
 	this.type = 'CmdSetGeometry';
+	this.name = 'Set geometry';
 	this.updatable = true;
 	this.updatable = true;
 
 
 	this.object = object;
 	this.object = object;

+ 1 - 0
editor/js/CmdSetGeometryValue.js

@@ -7,6 +7,7 @@ CmdSetGeometryValue = function ( object, attributeName, newValue ) {
 	Cmd.call( this );
 	Cmd.call( this );
 
 
 	this.type = 'CmdSetGeometryValue';
 	this.type = 'CmdSetGeometryValue';
+	this.name = 'Set geometry.' + attributeName;
 
 
 	this.object = object;
 	this.object = object;
 	this.attributeName = attributeName;
 	this.attributeName = attributeName;

+ 1 - 0
editor/js/CmdSetMaterial.js

@@ -7,6 +7,7 @@ CmdSetMaterial = function ( object, newMaterial ) {
 	Cmd.call( this );
 	Cmd.call( this );
 
 
 	this.type = 'CmdSetMaterial';
 	this.type = 'CmdSetMaterial';
+	this.name = 'Set material';
 
 
 	this.object = object;
 	this.object = object;
 	this.objectUuid = object !== undefined ? object.uuid : undefined;
 	this.objectUuid = object !== undefined ? object.uuid : undefined;

+ 1 - 0
editor/js/CmdSetMaterialColor.js

@@ -7,6 +7,7 @@ CmdSetMaterialColor = function ( object, attributeName, newValue ) {
 	Cmd.call( this );
 	Cmd.call( this );
 
 
 	this.type = 'CmdSetMaterialColor';
 	this.type = 'CmdSetMaterialColor';
+	this.name = 'Set material.' + attributeName;
 	this.updatable = true;
 	this.updatable = true;
 
 
 	this.object = object;
 	this.object = object;

+ 1 - 0
editor/js/CmdSetMaterialMap.js

@@ -7,6 +7,7 @@ CmdSetMaterialMap = function ( object, mapName, newMap ) {
 	Cmd.call( this );
 	Cmd.call( this );
 
 
 	this.type = 'CmdSetMaterialMap';
 	this.type = 'CmdSetMaterialMap';
+	this.name = 'Set material.' + mapName;
 
 
 	this.object = object;
 	this.object = object;
 	this.mapName = mapName;
 	this.mapName = mapName;

+ 1 - 0
editor/js/CmdSetMaterialValue.js

@@ -7,6 +7,7 @@ CmdSetMaterialValue = function ( object, attributeName, newValue ) {
 	Cmd.call( this );
 	Cmd.call( this );
 
 
 	this.type = 'CmdSetMaterialValue';
 	this.type = 'CmdSetMaterialValue';
+	this.name = 'Set material.' + attributeName;
 	this.updatable = true;
 	this.updatable = true;
 
 
 	this.object = object;
 	this.object = object;

+ 1 - 0
editor/js/CmdSetPosition.js

@@ -7,6 +7,7 @@ CmdSetPosition = function ( object, newPositionVector, oldPositionVector ) {
 	Cmd.call( this );
 	Cmd.call( this );
 
 
 	this.type = 'CmdSetPosition';
 	this.type = 'CmdSetPosition';
+	this.name = 'Set position';
 	this.updatable = true;
 	this.updatable = true;
 
 
 	this.object = object;
 	this.object = object;

+ 1 - 0
editor/js/CmdSetRotation.js

@@ -7,6 +7,7 @@ CmdSetRotation = function ( object, newRotationEuler, oldRotationEuler ) {
 	Cmd.call( this );
 	Cmd.call( this );
 
 
 	this.type = 'CmdSetRotation';
 	this.type = 'CmdSetRotation';
+	this.name = 'Set rotation';
 	this.updatable = true;
 	this.updatable = true;
 
 
 	this.object = object;
 	this.object = object;

+ 1 - 0
editor/js/CmdSetScale.js

@@ -7,6 +7,7 @@ CmdSetScale = function ( object, newScaleVector, oldScaleVector ) {
 	Cmd.call( this );
 	Cmd.call( this );
 
 
 	this.type = 'CmdSetScale';
 	this.type = 'CmdSetScale';
+	this.name = 'Set scale';
 	this.updatable = true;
 	this.updatable = true;
 
 
 	this.object = object;
 	this.object = object;

+ 1 - 0
editor/js/CmdSetScene.js

@@ -7,6 +7,7 @@ CmdSetScene = function ( oldScene, newScene ) {
 	Cmd.call( this );
 	Cmd.call( this );
 
 
 	this.type = 'CmdSetScene';
 	this.type = 'CmdSetScene';
+	this.name = 'Set scene';
 
 
 	this.cmdArray = [];
 	this.cmdArray = [];
 
 

+ 1 - 0
editor/js/CmdSetScriptValue.js

@@ -7,6 +7,7 @@ CmdSetScriptValue = function ( object, script, attributeName, newValue, cursorPo
 	Cmd.call( this );
 	Cmd.call( this );
 
 
 	this.type = 'CmdSetScriptValue';
 	this.type = 'CmdSetScriptValue';
+	this.name = 'Set script.' + attributeName;
 	this.updatable = true;
 	this.updatable = true;
 
 
 	this.object = object;
 	this.object = object;

+ 2 - 0
editor/js/CmdSetUuid.js

@@ -7,6 +7,8 @@ CmdSetUuid = function ( object, newUuid ) {
 	Cmd.call( this );
 	Cmd.call( this );
 
 
 	this.type = 'CmdSetUuid';
 	this.type = 'CmdSetUuid';
+	this.name = 'Update uuid';
+
 	this.object = object;
 	this.object = object;
 
 
 	this.oldUuid = object !== undefined ? object.uuid : undefined;
 	this.oldUuid = object !== undefined ? object.uuid : undefined;

+ 1 - 0
editor/js/CmdSetValue.js

@@ -7,6 +7,7 @@ CmdSetValue = function ( object, attributeName, newValue ) {
 	Cmd.call( this );
 	Cmd.call( this );
 
 
 	this.type = 'CmdSetValue';
 	this.type = 'CmdSetValue';
+	this.name = 'Set ' + attributeName;
 	this.updatable = true;
 	this.updatable = true;
 
 
 	this.object = object;
 	this.object = object;

+ 3 - 1
editor/js/Menubar.Edit.js

@@ -188,7 +188,9 @@ Menubar.Edit = function ( editor ) {
 			}
 			}
 
 
 		} );
 		} );
-		editor.execute( new CmdMultiCmds( cmds ) );
+		var minifyCmd = new CmdMultiCmds( cmds );
+		minifyCmd.name = 'Minify Shaders';
+		editor.execute( minifyCmd );
 
 
 
 
 		window.alert( nMaterialsChanged +
 		window.alert( nMaterialsChanged +

+ 3 - 1
editor/js/Sidebar.Geometry.js

@@ -79,7 +79,9 @@ Sidebar.Geometry = function ( editor ) {
 					new CmdSetRotation( object, new THREE.Euler( 0, 0, 0 ) ),
 					new CmdSetRotation( object, new THREE.Euler( 0, 0, 0 ) ),
 					new CmdSetScale( object, new THREE.Vector3( 1, 1, 1 ) ) ];
 					new CmdSetScale( object, new THREE.Vector3( 1, 1, 1 ) ) ];
 
 
-				editor.execute( new CmdMultiCmds( cmds ) );
+				var flattenCmd = new CmdMultiCmds( cmds );
+				flattenCmd.name = 'Flatten Geometry';
+				editor.execute( flattenCmd );
 
 
 				editor.signals.geometryChanged.dispatch( object );
 				editor.signals.geometryChanged.dispatch( object );
 				editor.signals.objectChanged.dispatch( object );
 				editor.signals.objectChanged.dispatch( object );

+ 2 - 2
editor/js/Sidebar.History.js

@@ -51,7 +51,7 @@ Sidebar.History = function ( editor ) {
 
 
 				var object = objects[ i ];
 				var object = objects[ i ];
 
 
-				var html = pad + "<span style='color: #0000cc '>" + enumerator++ + ". Undo: " + object.type.substring( 3, object.type.length ).replace(/([a-z])([A-Z])/g, '$1 $2') + "</span>";
+				var html = pad + "<span style='color: #0000cc '>" + enumerator++ + ". Undo: " + object.name + "</span>";
 
 
 				options.push( { value: object.id, html: html } );
 				options.push( { value: object.id, html: html } );
 
 
@@ -66,7 +66,7 @@ Sidebar.History = function ( editor ) {
 
 
 				var object = objects[ i ];
 				var object = objects[ i ];
 
 
-				var html = pad + "<span style='color: #71544e'>" + enumerator++ + ". Redo: " +  object.type.substring( 3, object.type.length ).replace(/([a-z])([A-Z])/g, '$1 $2') + "</span>";
+				var html = pad + "<span style='color: #71544e'>" + enumerator++ + ". Redo: " +  object.name + "</span>";
 
 
 				options.push( { value: object.id, html: html } );
 				options.push( { value: object.id, html: html } );