diff --git a/script/engine.js b/script/engine.js index a94294b..d00fb62 100644 --- a/script/engine.js +++ b/script/engine.js @@ -289,15 +289,22 @@ var Engine = { travelTo: function(module) { if(Engine.activeModule != module) { var currentIndex = Engine.activeModule ? $('.location').index(Engine.activeModule.panel) : 1; - Engine.activeModule = module; $('div.headerButton').removeClass('selected'); module.tab.addClass('selected'); - + var slider = $('#locationSlider'); + var stores = $('#storesContainer'); var panelIndex = $('.location').index(module.panel); var diff = Math.abs(panelIndex - currentIndex); slider.animate({left: -(panelIndex * 700) + 'px'}, 300 * diff); - module.onArrival(); + + if(Engine.storeAvailable('wood')) { + // FIXME Why does this work if there's an animation queue...? + stores.animate({right: -(panelIndex * 700) + 'px'}, 300 * diff); + } + + module.onArrival(diff); + Engine.activeModule = module; Notifications.printQueue(module); } @@ -500,6 +507,29 @@ var Engine = { }); Room.updateIncomeView(); }, + + // Move the stores panel beneath top_container (or to top: 0px if top_container + // either hasn't been filled in or is null) using transition_diff to sync with + // the animation in Engine.travelTo(). + moveStoresView: function(top_container, transition_diff) { + var stores = $('#storesContainer'); + + // If we don't have a storesContainer yet, leave. + if(typeof(stores) === 'undefined') return; + + if(typeof(transition_diff) === 'undefined') transition_diff = 1; + + if(top_container === null) { + stores.animate({top: '0px'}, {queue: false, duration: 300 * transition_diff}); + } + else if(!top_container.length) { + stores.animate({top: '0px'}, {queue: false, duration: 300 * transition_diff}); + } + else { + stores.animate({top: top_container.height() + 26 + 'px'}, + {queue: false, duration: 300 * transition_diff}); + } + }, num: function(name, craftable) { switch(craftable.type) { diff --git a/script/outside.js b/script/outside.js index 79ad486..656daf5 100644 --- a/script/outside.js +++ b/script/outside.js @@ -479,6 +479,10 @@ var Outside = { } this.setTitle(); + + if(Engine.activeModule === Outside && village.children().length > 1) { + $('#storesContainer').css({top: village.height() + 26 + 'px'}); + } }, checkWorker: function(name) { @@ -583,13 +587,16 @@ var Outside = { $('#location_outside').text(title); }, - onArrival: function() { + onArrival: function(transition_diff) { Outside.setTitle(); if(!State.seenForest) { Notifications.notify(Outside, "the sky is grey and the wind blows relentlessly"); State.seenForest = true; } Outside.updateTrapButton(); + Outside.updateVillage(); + + Engine.moveStoresView($('#village'), transition_diff); }, gatherWood: function() { diff --git a/script/path.js b/script/path.js index 41c9369..8ad6215 100644 --- a/script/path.js +++ b/script/path.js @@ -106,6 +106,10 @@ var Path = { perks.appendTo(Path.panel); } } + + if(Engine.activeModule === Path) { + $('#storesContainer').css({top: perks.height() + 26 + 'px'}); + } }, updateOutfitting: function() { @@ -289,10 +293,12 @@ var Path = { } }, - onArrival: function() { + onArrival: function(transition_diff) { Path.setTitle(); Path.updateOutfitting(); Path.updatePerks(); + + Engine.moveStoresView($('#perks'), transition_diff); }, setTitle: function() { diff --git a/script/room.js b/script/room.js index 6b2e27f..f4f4f90 100644 --- a/script/room.js +++ b/script/room.js @@ -502,7 +502,7 @@ var Room = { options: {}, // Nothing for now - onArrival: function() { + onArrival: function(transition_diff) { Room.setTitle(); if(Room.changed) { Notifications.notify(Room, "the fire is " + State.room.fire.text); @@ -518,6 +518,8 @@ var Room = { Room.updateIncomeView(); Notifications.notify(Room, "the stranger is standing by the fire. she says she can help. says she builds things.") } + + Engine.moveStoresView(null, transition_diff); }, TempEnum: { @@ -793,6 +795,10 @@ var Room = { if(newRow) { Room.updateIncomeView(); } + + if($("div#outsidePanel").length) { + Outside.updateVillage(); + } }, updateIncomeView: function() { diff --git a/script/ship.js b/script/ship.js index cff19cf..0fad202 100644 --- a/script/ship.js +++ b/script/ship.js @@ -81,13 +81,15 @@ var Ship = { options: {}, // Nothing for now - onArrival: function() { + onArrival: function(transition_diff) { Ship.setTitle(); if(!State.seenShip) { Notifications.notify(Ship, 'somewhere above the debris cloud, the wanderer fleet hovers. been on this rock too long.'); State.seenShip = true; Engine.saveGame(); } + + Engine.moveStoresView(null, transition_diff); }, setTitle: function() { diff --git a/script/world.js b/script/world.js index 46f1a5b..db9181d 100644 --- a/script/world.js +++ b/script/world.js @@ -757,6 +757,7 @@ var World = { $('#outerSlider').animate({opacity: '0'}, 600, 'linear', function() { $('#outerSlider').css('left', '0px'); $('#locationSlider').css('left', '0px'); + $('#storesContainer').css({'top': '0px', 'right': '0px'}); Engine.activeModule = Room; $('div.headerButton').removeClass('selected'); Room.tab.addClass('selected');