From 259c990c491dfb814f96e75fde667ec717b69e50 Mon Sep 17 00:00:00 2001 From: PatrickSachs Date: Wed, 13 Mar 2019 23:01:34 +0100 Subject: [PATCH 1/3] Show game version in UI --- src/components/App.vue | 4 +++- src/d/json.d.ts | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 src/d/json.d.ts diff --git a/src/components/App.vue b/src/components/App.vue index 742165c..b4b8da8 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. 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; +} From 9cdb905da480e080bce686256728a24f2ec8e602 Mon Sep 17 00:00:00 2001 From: PatrickSachs Date: Thu, 14 Mar 2019 20:54:10 +0100 Subject: [PATCH 2/3] Fixed: Clearing undo/redo when resetting/loading --- src/commands/CommandManager.ts | 8 ++++++++ src/commands/DestroyTreeElementCommand.ts | 2 +- src/components/App.vue | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) 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 b4b8da8..04b379e 100644 --- a/src/components/App.vue +++ b/src/components/App.vue @@ -426,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) { @@ -443,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"); From dd942ea5ae08066077e074bdb31dbc7cae6c3e09 Mon Sep 17 00:00:00 2001 From: PatrickSachs Date: Thu, 14 Mar 2019 20:54:58 +0100 Subject: [PATCH 3/3] 1.0.1 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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": {