Skip to content

Commit

Permalink
Merge pull request #21 from PatrickSachs/develop
Browse files Browse the repository at this point in the history
1.0.1
  • Loading branch information
Patrick Sachs authored Mar 14, 2019
2 parents f94e736 + dd942ea commit 18df068
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "slow-tree",
"version": "1.0.0",
"version": "1.0.1",
"description": "",
"main": "index.js",
"scripts": {
Expand Down
8 changes: 8 additions & 0 deletions src/commands/CommandManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/DestroyTreeElementCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
8 changes: 6 additions & 2 deletions src/components/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
</v-content>
<v-footer app height="auto">
<v-flex text-xs-center xs12>
slow-tree &copy;2019 —
slow-tree {{pkg.version}} &copy;2019 —
<strong>sahnee.de</strong>
</v-flex>
</v-footer>
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand All @@ -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");
Expand Down
5 changes: 5 additions & 0 deletions src/d/json.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module '*.json' {
type JSON = { [key: string]: JSON | string | number | boolean | null | undefined };
const JSONObject: JSON;
export default JSONObject;
}

0 comments on commit 18df068

Please sign in to comment.