From 72a83d48dd36b62918321d93fc8a572fea27863e Mon Sep 17 00:00:00 2001 From: Robert Gravina Date: Wed, 24 Dec 2014 22:57:45 +0900 Subject: [PATCH] Save the state of the path outfit in the State object. Load the state when initialising the path screen. When embarking, make sure to clear the state. On arrival, update the saved state. This enables save/load of the path state in the save game if it occurs before leaving. --- script/path.js | 6 +++++- script/state_manager.js | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/script/path.js b/script/path.js index 25689dc..e1cbb59 100644 --- a/script/path.js +++ b/script/path.js @@ -46,7 +46,7 @@ var Path = { cooldown: World.DEATH_COOLDOWN }).appendTo(this.panel); - Path.outfit = {}; + Path.outfit = $SM.get('outfit'); Engine.updateSlider(); @@ -269,6 +269,7 @@ var Path = { var maxExtraByStore = $SM.get('stores["'+supply+'"]', true) - cur; var maxExtraByBtn = btn.data; Path.outfit[supply] = cur + Math.min(maxExtraByBtn, Math.min(maxExtraByWeight, maxExtraByStore)); + $SM.set('outfit['+supply+']', Path.outfit[supply]) Path.updateOutfitting(); } }, @@ -280,6 +281,7 @@ var Path = { cur = typeof cur == 'number' ? cur : 0; if(cur > 0) { Path.outfit[supply] = Math.max(0, cur - btn.data); + $SM.set('outfit['+supply+']', Path.outfit[supply]) Path.updateOutfitting(); } }, @@ -288,6 +290,7 @@ var Path = { Path.setTitle(); Path.updateOutfitting(); Path.updatePerks(true); + $SM.set('outfit', Path.outfit); Engine.moveStoresView($('#perks'), transition_diff); }, @@ -300,6 +303,7 @@ var Path = { for(var k in Path.outfit) { $SM.add('stores["'+k+'"]', -Path.outfit[k]); } + $SM.remove('outfit'); World.onArrival(); $('#outerSlider').animate({left: '-700px'}, 300); Engine.activeModule = World; diff --git a/script/state_manager.js b/script/state_manager.js index bf2ca8a..7b33dad 100644 --- a/script/state_manager.js +++ b/script/state_manager.js @@ -35,7 +35,8 @@ var StateManager = { 'timers', 'game', //mostly location related: fire temp, workers, population, world map, etc 'playStats', //anything play related: play time, loads, etc - 'previous' // prestige, score, trophies (in future), achievements (again, not yet), etc + 'previous', // prestige, score, trophies (in future), achievements (again, not yet), etc + 'outfit' // used to temporarily store the items to be taken on the path ]; for(var which in cats) {