Stores panel now persists on all non-world/non-space views.

This commit is contained in:
Matt Rasmus
2013-07-06 14:56:27 -07:00
parent 12258689e8
commit 8dabee851d
6 changed files with 59 additions and 7 deletions
+32 -2
View File
@@ -289,15 +289,22 @@ var Engine = {
travelTo: function(module) { travelTo: function(module) {
if(Engine.activeModule != module) { if(Engine.activeModule != module) {
var currentIndex = Engine.activeModule ? $('.location').index(Engine.activeModule.panel) : 1; var currentIndex = Engine.activeModule ? $('.location').index(Engine.activeModule.panel) : 1;
Engine.activeModule = module;
$('div.headerButton').removeClass('selected'); $('div.headerButton').removeClass('selected');
module.tab.addClass('selected'); module.tab.addClass('selected');
var slider = $('#locationSlider'); var slider = $('#locationSlider');
var stores = $('#storesContainer');
var panelIndex = $('.location').index(module.panel); var panelIndex = $('.location').index(module.panel);
var diff = Math.abs(panelIndex - currentIndex); var diff = Math.abs(panelIndex - currentIndex);
slider.animate({left: -(panelIndex * 700) + 'px'}, 300 * diff); 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); Notifications.printQueue(module);
} }
@@ -501,6 +508,29 @@ var Engine = {
Room.updateIncomeView(); 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) { num: function(name, craftable) {
switch(craftable.type) { switch(craftable.type) {
case 'good': case 'good':
+8 -1
View File
@@ -479,6 +479,10 @@ var Outside = {
} }
this.setTitle(); this.setTitle();
if(Engine.activeModule === Outside && village.children().length > 1) {
$('#storesContainer').css({top: village.height() + 26 + 'px'});
}
}, },
checkWorker: function(name) { checkWorker: function(name) {
@@ -583,13 +587,16 @@ var Outside = {
$('#location_outside').text(title); $('#location_outside').text(title);
}, },
onArrival: function() { onArrival: function(transition_diff) {
Outside.setTitle(); Outside.setTitle();
if(!State.seenForest) { if(!State.seenForest) {
Notifications.notify(Outside, "the sky is grey and the wind blows relentlessly"); Notifications.notify(Outside, "the sky is grey and the wind blows relentlessly");
State.seenForest = true; State.seenForest = true;
} }
Outside.updateTrapButton(); Outside.updateTrapButton();
Outside.updateVillage();
Engine.moveStoresView($('#village'), transition_diff);
}, },
gatherWood: function() { gatherWood: function() {
+7 -1
View File
@@ -106,6 +106,10 @@ var Path = {
perks.appendTo(Path.panel); perks.appendTo(Path.panel);
} }
} }
if(Engine.activeModule === Path) {
$('#storesContainer').css({top: perks.height() + 26 + 'px'});
}
}, },
updateOutfitting: function() { updateOutfitting: function() {
@@ -289,10 +293,12 @@ var Path = {
} }
}, },
onArrival: function() { onArrival: function(transition_diff) {
Path.setTitle(); Path.setTitle();
Path.updateOutfitting(); Path.updateOutfitting();
Path.updatePerks(); Path.updatePerks();
Engine.moveStoresView($('#perks'), transition_diff);
}, },
setTitle: function() { setTitle: function() {
+7 -1
View File
@@ -502,7 +502,7 @@ var Room = {
options: {}, // Nothing for now options: {}, // Nothing for now
onArrival: function() { onArrival: function(transition_diff) {
Room.setTitle(); Room.setTitle();
if(Room.changed) { if(Room.changed) {
Notifications.notify(Room, "the fire is " + State.room.fire.text); Notifications.notify(Room, "the fire is " + State.room.fire.text);
@@ -518,6 +518,8 @@ var Room = {
Room.updateIncomeView(); Room.updateIncomeView();
Notifications.notify(Room, "the stranger is standing by the fire. she says she can help. says she builds things.") 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: { TempEnum: {
@@ -793,6 +795,10 @@ var Room = {
if(newRow) { if(newRow) {
Room.updateIncomeView(); Room.updateIncomeView();
} }
if($("div#outsidePanel").length) {
Outside.updateVillage();
}
}, },
updateIncomeView: function() { updateIncomeView: function() {
+3 -1
View File
@@ -81,13 +81,15 @@ var Ship = {
options: {}, // Nothing for now options: {}, // Nothing for now
onArrival: function() { onArrival: function(transition_diff) {
Ship.setTitle(); Ship.setTitle();
if(!State.seenShip) { if(!State.seenShip) {
Notifications.notify(Ship, 'somewhere above the debris cloud, the wanderer fleet hovers. been on this rock too long.'); Notifications.notify(Ship, 'somewhere above the debris cloud, the wanderer fleet hovers. been on this rock too long.');
State.seenShip = true; State.seenShip = true;
Engine.saveGame(); Engine.saveGame();
} }
Engine.moveStoresView(null, transition_diff);
}, },
setTitle: function() { setTitle: function() {
+1
View File
@@ -757,6 +757,7 @@ var World = {
$('#outerSlider').animate({opacity: '0'}, 600, 'linear', function() { $('#outerSlider').animate({opacity: '0'}, 600, 'linear', function() {
$('#outerSlider').css('left', '0px'); $('#outerSlider').css('left', '0px');
$('#locationSlider').css('left', '0px'); $('#locationSlider').css('left', '0px');
$('#storesContainer').css({'top': '0px', 'right': '0px'});
Engine.activeModule = Room; Engine.activeModule = Room;
$('div.headerButton').removeClass('selected'); $('div.headerButton').removeClass('selected');
Room.tab.addClass('selected'); Room.tab.addClass('selected');