Browse Source

disabled undo/redo while scene is playing

issue #34

Note: Executing new commands is still possible.
Daniel 9 years ago
parent
commit
36d140d12e
1 changed files with 39 additions and 0 deletions
  1. 39 0
      editor/js/History.js

+ 39 - 0
editor/js/History.js

@@ -11,6 +11,24 @@ History = function ( editor ) {
 	this.lastCmdTime = new Date();
 	this.idCounter = 0;
 
+	this.historyDisabled = false;
+
+	// signals
+
+	var scope = this;
+
+	this.editor.signals.startPlayer.add( function () {
+
+		scope.historyDisabled = true;
+
+	} );
+
+	this.editor.signals.stopPlayer.add( function () {
+
+		scope.historyDisabled = false;
+
+	} );
+
 };
 
 History.prototype = {
@@ -61,6 +79,13 @@ History.prototype = {
 
 	undo: function () {
 
+		if ( this.historyDisabled ) {
+
+			alert("Undo/Redo disabled while scene is playing.");
+			return;
+
+		}
+
 		var cmd = undefined;
 
 		if ( this.undos.length > 0 ) {
@@ -93,6 +118,13 @@ History.prototype = {
 
 	redo: function () {
 
+		if ( this.historyDisabled ) {
+
+			alert("Undo/Redo disabled while scene is playing.");
+			return;
+
+		}
+
 		var cmd = undefined;
 
 		if ( this.redos.length > 0 ) {
@@ -214,6 +246,13 @@ History.prototype = {
 
 	goToState: function ( id ) {
 
+		if ( this.historyDisabled ) {
+
+			alert("Undo/Redo disabled while scene is playing.");
+			return;
+
+		}
+
 		this.editor.signals.sceneGraphChanged.active = false;
 		this.editor.signals.historyChanged.active = false;