mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-05-28 00:01:54 +08:00
Stores panel now persists on all non-world/non-space views.
This commit is contained in:
+33
-3
@@ -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) {
|
||||
|
||||
+8
-1
@@ -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() {
|
||||
|
||||
+7
-1
@@ -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() {
|
||||
|
||||
+7
-1
@@ -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() {
|
||||
|
||||
+3
-1
@@ -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() {
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user