Property for tab navigation

Added Engine.tabNavigation property. When true, it enables keyboard navigation to/from tabs. It is disabled on world and enabled some milliseconds after Path.onArrival(), so that when player returns s/he finds him/herself on Path tab instead of navigating.
This commit is contained in:
Andrea Rendine
2015-05-12 00:34:51 +02:00
committed by Blake Grotewold
parent 64a02c162c
commit daf5de3973
2 changed files with 30 additions and 16 deletions
+28 -16
View File
@@ -593,6 +593,14 @@
//return (num > 0 ? "+" : "") + num + " per " + delay + "s"; //return (num > 0 ? "+" : "") + num + " per " + delay + "s";
}, },
tabNavigation: true,
restoreNavigation: function(){
setTimeout(function(){
Engine.tabNavigation = true;
},100);
},
keyDown: function(e) { keyDown: function(e) {
e = e || window.event; e = e || window.event;
if(!Engine.keyPressed && !Engine.keyLock) { if(!Engine.keyPressed && !Engine.keyLock) {
@@ -628,27 +636,31 @@
break; break;
case 37: // Left case 37: // Left
case 65: case 65:
if(Engine.activeModule == Ship && Path.tab) if(Engine.tabNavigation){
Engine.travelTo(Path); if(Engine.activeModule == Ship && Path.tab)
else if(Engine.activeModule == Path && Outside.tab){ Engine.travelTo(Path);
Engine.activeModule.scrollSidebar('left', true); else if(Engine.activeModule == Path && Outside.tab){
Engine.travelTo(Outside); Engine.activeModule.scrollSidebar('left', true);
}else if(Engine.activeModule == Outside && Room.tab){ Engine.travelTo(Outside);
Engine.activeModule.scrollSidebar('left', true); }else if(Engine.activeModule == Outside && Room.tab){
Engine.travelTo(Room); Engine.activeModule.scrollSidebar('left', true);
Engine.travelTo(Room);
}
} }
Engine.log('left'); Engine.log('left');
break; break;
case 39: // Right case 39: // Right
case 68: case 68:
if(Engine.activeModule == Room && Outside.tab) if(Engine.tabNavigation){
Engine.travelTo(Outside); if(Engine.activeModule == Room && Outside.tab)
else if(Engine.activeModule == Outside && Path.tab){ Engine.travelTo(Outside);
Engine.activeModule.scrollSidebar('right', true); else if(Engine.activeModule == Outside && Path.tab){
Engine.travelTo(Path); Engine.activeModule.scrollSidebar('right', true);
}else if(Engine.activeModule == Path && Ship.tab){ Engine.travelTo(Path);
Engine.activeModule.scrollSidebar('right', true); }else if(Engine.activeModule == Path && Ship.tab){
Engine.travelTo(Ship); Engine.activeModule.scrollSidebar('right', true);
Engine.travelTo(Ship);
}
} }
Engine.log('right'); Engine.log('right');
break; break;
+2
View File
@@ -823,6 +823,7 @@ var World = {
$('#outerSlider').animate({opacity:'1'}, 600, 'linear'); $('#outerSlider').animate({opacity:'1'}, 600, 'linear');
Button.cooldown($('#embarkButton')); Button.cooldown($('#embarkButton'));
Engine.keyLock = false; Engine.keyLock = false;
Engine.restoreNavigation();
}, 2000, true); }, 2000, true);
}); });
} }
@@ -865,6 +866,7 @@ var World = {
$('#outerSlider').animate({left: '0px'}, 300); $('#outerSlider').animate({left: '0px'}, 300);
Engine.activeModule = Path; Engine.activeModule = Path;
Path.onArrival(); Path.onArrival();
Engine.restoreNavigation();
}, },
leaveItAtHome: function(thing) { leaveItAtHome: function(thing) {