Mugen87 8 tahun lalu
induk
melakukan
f301aa0ffb
3 mengubah file dengan 3 tambahan dan 36 penghapusan
  1. 1 2
      editor/js/Editor.js
  2. 1 21
      editor/js/Script.js
  3. 1 13
      editor/js/commands/SetScriptValueCommand.js

+ 1 - 2
editor/js/Editor.js

@@ -75,8 +75,7 @@ var Editor = function () {
 
 		showGridChanged: new Signal(),
 		refreshSidebarObject3D: new Signal(),
-		historyChanged: new Signal(),
-		refreshScriptEditor: new Signal()
+		historyChanged: new Signal()
 
 	};
 

+ 1 - 21
editor/js/Script.js

@@ -84,7 +84,7 @@ var Script = function ( editor ) {
 
 				if ( value !== currentScript.source ) {
 
-					editor.execute( new SetScriptValueCommand( currentObject, currentScript, 'source', value, codemirror.getCursor(), codemirror.getScrollInfo() ) );
+					editor.execute( new SetScriptValueCommand( currentObject, currentScript, 'source', value ) );
 
 				}
 				return;
@@ -422,26 +422,6 @@ var Script = function ( editor ) {
 
 	} );
 
-	signals.refreshScriptEditor.add( function ( object, script, cursorPosition, scrollInfo ) {
-
-		if ( currentScript !== script ) return;
-
-		// copying the codemirror history because "codemirror.setValue(...)" alters its history
-
-		var history = codemirror.getHistory();
-		title.setValue( object.name + ' / ' + script.name );
-		codemirror.setValue( script.source );
-
-		if ( cursorPosition !== undefined ) {
-
-			codemirror.setCursor( cursorPosition );
-			codemirror.scrollTo( scrollInfo.left, scrollInfo.top );
-
-		}
-		codemirror.setHistory( history ); // setting the history to previous state
-
-	} );
-
 	return container;
 
 };

+ 1 - 13
editor/js/commands/SetScriptValueCommand.js

@@ -8,12 +8,10 @@
  * @param script javascript object
  * @param attributeName string
  * @param newValue string, object
- * @param cursorPosition javascript object with format {line: 2, ch: 3}
- * @param scrollInfo javascript object with values {left, top, width, height, clientWidth, clientHeight}
  * @constructor
  */
 
-var SetScriptValueCommand = function ( object, script, attributeName, newValue, cursorPosition, scrollInfo ) {
+var SetScriptValueCommand = function ( object, script, attributeName, newValue ) {
 
 	Command.call( this );
 
@@ -27,8 +25,6 @@ var SetScriptValueCommand = function ( object, script, attributeName, newValue,
 	this.attributeName = attributeName;
 	this.oldValue = ( script !== undefined ) ? script[ this.attributeName ] : undefined;
 	this.newValue = newValue;
-	this.cursorPosition = cursorPosition;
-	this.scrollInfo = scrollInfo;
 
 };
 
@@ -39,7 +35,6 @@ SetScriptValueCommand.prototype = {
 		this.script[ this.attributeName ] = this.newValue;
 
 		this.editor.signals.scriptChanged.dispatch();
-		this.editor.signals.refreshScriptEditor.dispatch( this.object, this.script, this.cursorPosition, this.scrollInfo );
 
 	},
 
@@ -48,14 +43,11 @@ SetScriptValueCommand.prototype = {
 		this.script[ this.attributeName ] = this.oldValue;
 
 		this.editor.signals.scriptChanged.dispatch();
-		this.editor.signals.refreshScriptEditor.dispatch( this.object, this.script, this.cursorPosition, this.scrollInfo );
 
 	},
 
 	update: function ( cmd ) {
 
-		this.cursorPosition = cmd.cursorPosition;
-		this.scrollInfo = cmd.scrollInfo;
 		this.newValue = cmd.newValue;
 
 	},
@@ -69,8 +61,6 @@ SetScriptValueCommand.prototype = {
 		output.attributeName = this.attributeName;
 		output.oldValue = this.oldValue;
 		output.newValue = this.newValue;
-		output.cursorPosition = this.cursorPosition;
-		output.scrollInfo = this.scrollInfo;
 
 		return output;
 
@@ -85,8 +75,6 @@ SetScriptValueCommand.prototype = {
 		this.attributeName = json.attributeName;
 		this.object = this.editor.objectByUuid( json.objectUuid );
 		this.script = this.editor.scripts[ json.objectUuid ][ json.index ];
-		this.cursorPosition = json.cursorPosition;
-		this.scrollInfo = json.scrollInfo;
 
 	}