commit:5c8fe730e106cdf6ebf166efac9b6592dad73db3
author:Chip Black
committer:Chip Black
date:Sat Oct 27 21:17:30 2018 -0500
parents:38fed509930b839d2cd63c7d64a958ba4a07c13f
Fix cell properties and reinstate save/load functionality
diff --git a/src/cell.ts b/src/cell.ts
line changes: +1/-1
index ec906ab..ae8dcfb
--- a/src/cell.ts
+++ b/src/cell.ts
@@ -40,7 +40,7 @@ export class Cell extends Storable {
     objects: Map<ID, GameObject>
     agents: Map<ID, GameAgent>
     navigable: boolean
-    saveProperties = ['x', 'y', 'id', 'description']
+    saveProperties = ['x', 'y', 'id', 'title', 'description']
 
     constructor(x: number, y: number) {
         super();

diff --git a/src/gamestate.ts b/src/gamestate.ts
line changes: +4/-3
index 089ab35..f890fad
--- a/src/gamestate.ts
+++ b/src/gamestate.ts
@@ -42,15 +42,16 @@ class GameState {
 
         document.body.classList.toggle('edit-mode', this.editMode);
 
-        if (localStorage['map']) {
-            this.map.load(JSON.parse(localStorage.map));
-        }
         this.textView = new TextView();
         this.editor = new Editor();
         this.mapView = new MapView();
         this.mapView.updateAll();
         this.actions = new Actions();
 
+        if (localStorage['map']) {
+            this.map.load(JSON.parse(localStorage.map));
+        }
+
         this.enterCell();
     }
 

diff --git a/src/main.ts b/src/main.ts
line changes: +7/-2
index 1d64efe..bbbe81a
--- a/src/main.ts
+++ b/src/main.ts
@@ -24,8 +24,13 @@ function keydown(e: KeyboardEvent) {
             gs.map.editDescription();
             break;
         case 'KeyS':
-            //localStorage['map'] = JSON.stringify(gs.map.store());
-            console.log(JSON.stringify(gs.map.store()));
+            localStorage['map'] = JSON.stringify(gs.map.store());
+            console.log(localStorage['map']);
+            break;
+        case 'KeyL':
+            gs.map.load(JSON.parse(localStorage['map']));
+            gs.enterCell();
+            console.log('Map reloaded');
             break;
         default:
             console.log('code:', e.code);