From 8dabee851d641805c1200d785d01e857d1d2ce0c Mon Sep 17 00:00:00 2001 From: Matt Rasmus Date: Sat, 6 Jul 2013 14:56:27 -0700 Subject: [PATCH 1/3] Stores panel now persists on all non-world/non-space views. --- script/engine.js | 36 +++++++++++++++++++++++++++++++++--- script/outside.js | 9 ++++++++- script/path.js | 8 +++++++- script/room.js | 8 +++++++- script/ship.js | 4 +++- script/world.js | 1 + 6 files changed, 59 insertions(+), 7 deletions(-) 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'); From de2ad910538eab2c31695d933011d4b57665913a Mon Sep 17 00:00:00 2001 From: Matt Rasmus Date: Mon, 8 Jul 2013 13:10:49 -0700 Subject: [PATCH 2/3] Weapons panel hides when not in Room. --- script/engine.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/script/engine.js b/script/engine.js index d00fb62..eae1761 100644 --- a/script/engine.js +++ b/script/engine.js @@ -304,6 +304,15 @@ var Engine = { } module.onArrival(diff); + + if(Engine.activeModule == Room) { + $('div#weapons').animate({opacity: 0}, 300); + } + + if(module == Room) { + $('div#weapons').animate({opacity: 1}, 300); + } + Engine.activeModule = module; Notifications.printQueue(module); From eaf2fcdfbb2e63c21f376015c36ba72c15006671 Mon Sep 17 00:00:00 2001 From: Matt Rasmus Date: Mon, 8 Jul 2013 13:54:50 -0700 Subject: [PATCH 3/3] Keep showing the weapons panel while in the Path screen. --- script/engine.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/script/engine.js b/script/engine.js index eae1761..189454b 100644 --- a/script/engine.js +++ b/script/engine.js @@ -304,12 +304,16 @@ var Engine = { } module.onArrival(diff); - - if(Engine.activeModule == Room) { - $('div#weapons').animate({opacity: 0}, 300); + + if(Engine.activeModule == Room || Engine.activeModule == Path) { + // Don't fade out the weapons if we're switching to a module + // where we're going to keep showing them anyway. + if (module != Room && module != Path) { + $('div#weapons').animate({opacity: 0}, 300); + } } - if(module == Room) { + if(module == Room || module == Path) { $('div#weapons').animate({opacity: 1}, 300); }