diff --git a/package-lock.json b/package-lock.json index cbe0bd6..1f5552d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "slow-tree", - "version": "1.0.0", + "version": "1.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 9db2e57..e40d8cc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "slow-tree", - "version": "1.0.0", + "version": "1.0.1", "description": "", "main": "index.js", "scripts": { diff --git a/src/commands/CommandManager.ts b/src/commands/CommandManager.ts index 588e37f..0918fea 100644 --- a/src/commands/CommandManager.ts +++ b/src/commands/CommandManager.ts @@ -35,6 +35,14 @@ export default class CommandManager { } } + /** + * Clears the undo/redo stacks. + */ + public clear() { + this._undo = []; + this._redo = []; + } + /** * Redoes the last undone command and removes it from the redo stack. If no command has * been undone before no action is performed. diff --git a/src/commands/DestroyTreeElementCommand.ts b/src/commands/DestroyTreeElementCommand.ts index 146e833..9cee772 100644 --- a/src/commands/DestroyTreeElementCommand.ts +++ b/src/commands/DestroyTreeElementCommand.ts @@ -40,7 +40,7 @@ export default class DestroyTreeElementCommand implements ICommand { if (!owner) { throw new SlowTreeError("Could not un-delete tree element with owner " + this.owner); } - // A kinda hacky workaround leveraging the fact that the save data strcuture is the + // A kinda hacky workaround leveraging the fact that the save data structure is the // same as the one used in game. // For a larger project a better solution might be warraned, but in this case it does // the job just fine. diff --git a/src/components/App.vue b/src/components/App.vue index 742165c..04b379e 100644 --- a/src/components/App.vue +++ b/src/components/App.vue @@ -130,7 +130,7 @@ - slow-tree ©2019 — + slow-tree {{pkg.version}} ©2019 — sahnee.de @@ -204,6 +204,7 @@ import TreeType from "@/TreeType"; import uuid from "@/utils/uuid"; import LeavesGameObject from "@/gameobjects/LeavesGameObject"; import FileSaver from "file-saver"; +import pkg from "../../package.json"; interface IMenuItem { id: string; @@ -241,6 +242,7 @@ export default class STApp extends Vue { private angle: integer = 25; private oldSavegameVersion: boolean = false; private errorMessage: string = ""; + private pkg = pkg; /** * Called when the component is ready to be used, but has no HTMl elements yet. @@ -424,6 +426,7 @@ export default class STApp extends Vue { const json = JSON.parse(reader.result as string); console.log("Uploaded file ...", json); try { + this.game!.cmd.clear(); scene.loadGame(json); this.cache(); } catch (error) { @@ -441,8 +444,9 @@ export default class STApp extends Vue { * Called when the user clicks on the delete button. */ onClickDelete() { - if (this.scene) { + if (this.game && this.scene) { this.scene.clear(); + this.game.cmd.clear(); this.tree = this.scene.tree.treeType.id; } localStorage.removeItem("cache"); diff --git a/src/d/json.d.ts b/src/d/json.d.ts new file mode 100644 index 0000000..218e99c --- /dev/null +++ b/src/d/json.d.ts @@ -0,0 +1,5 @@ +declare module '*.json' { + type JSON = { [key: string]: JSON | string | number | boolean | null | undefined }; + const JSONObject: JSON; + export default JSONObject; +}