File tree Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Expand file tree Collapse file tree 3 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,14 @@ export default class CommandManager {
3535 }
3636 }
3737
38+ /**
39+ * Clears the undo/redo stacks.
40+ */
41+ public clear ( ) {
42+ this . _undo = [ ] ;
43+ this . _redo = [ ] ;
44+ }
45+
3846 /**
3947 * Redoes the last undone command and removes it from the redo stack. If no command has
4048 * been undone before no action is performed.
Original file line number Diff line number Diff line change @@ -40,7 +40,7 @@ export default class DestroyTreeElementCommand implements ICommand {
4040 if ( ! owner ) {
4141 throw new SlowTreeError ( "Could not un-delete tree element with owner " + this . owner ) ;
4242 }
43- // A kinda hacky workaround leveraging the fact that the save data strcuture is the
43+ // A kinda hacky workaround leveraging the fact that the save data structure is the
4444 // same as the one used in game.
4545 // For a larger project a better solution might be warraned, but in this case it does
4646 // the job just fine.
Original file line number Diff line number Diff line change @@ -426,6 +426,7 @@ export default class STApp extends Vue {
426426 const json = JSON .parse (reader .result as string );
427427 console .log (" Uploaded file ..." , json );
428428 try {
429+ this .game ! .cmd .clear ();
429430 scene .loadGame (json );
430431 this .cache ();
431432 } catch (error ) {
@@ -443,8 +444,9 @@ export default class STApp extends Vue {
443444 * Called when the user clicks on the delete button.
444445 */
445446 onClickDelete() {
446- if (this .scene ) {
447+ if (this .game && this . scene ) {
447448 this .scene .clear ();
449+ this .game .cmd .clear ();
448450 this .tree = this .scene .tree .treeType .id ;
449451 }
450452 localStorage .removeItem (" cache" );
You can’t perform that action at this time.
0 commit comments