Hyper mode and LightsOff is now stored in the State

This commit is contained in:
nicholas_pellizer
2015-04-23 11:33:44 +02:00
committed by Blake Grotewold
parent f85b8fdf7e
commit 8320156f42
2 changed files with 151 additions and 135 deletions
+37 -22
View File
@@ -140,15 +140,9 @@
.appendTo(menu);
$('<span>')
.addClass('menuBtn')
.addClass('hyper menuBtn')
.text(_('hyper.'))
.click(function(){
Engine.options.doubleTime = !Engine.options.doubleTime;
if(Engine.options.doubleTime)
$(this).text(_('classic.'));
else
$(this).text(_('hyper.'));
})
.click(Engine.triggerHyperMode)
.appendTo(menu);
$('<span>')
@@ -220,6 +214,14 @@
Ship.init();
}
if($SM.get('config.lightsOff', true)){
Engine.turnLightsOff();
}
if($SM.get('config.hyperMode', true)){
Engine.triggerHyperMode();
}
Engine.saveLanguage();
Engine.travelTo(Room);
@@ -476,16 +478,29 @@
if (darkCss == null) {
$('head').append('<link rel="stylesheet" href="css/dark.css" type="text/css" title="darkenLights" />');
$('.lightsOff').text(_('lights on.'));
$SM.set('config.lightsOff', true, true);
} else if (darkCss.disabled) {
darkCss.disabled = false;
$('.lightsOff').text(_('lights on.'));
$SM.set('config.lightsOff', true,true);
} else {
$("#darkenLights").attr("disabled", "disabled");
darkCss.disabled = true;
$('.lightsOff').text(_('lights off.'));
$SM.set('config.lightsOff', false, true);
}
},
triggerHyperMode: function(){
Engine.options.doubleTime = !Engine.options.doubleTime;
if(Engine.options.doubleTime)
$('.hyper').text(_('classic.'));
else
$('.hyper').text(_('hyper.'));
$SM.set('config.hyperMode', Engine.options.doubleTime, false);
},
// Gets a guid
getGuid: function() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
@@ -732,27 +747,27 @@
function inView(dir, elem){
var scTop = $('#main').offset().top;
var scBot = scTop + $('#main').height();
var scTop = $('#main').offset().top;
var scBot = scTop + $('#main').height();
var elTop = elem.offset().top;
var elBot = elTop + elem.height();
var elTop = elem.offset().top;
var elBot = elTop + elem.height();
if( dir == 'up' ){
// STOP MOVING IF BOTTOM OF ELEMENT IS VISIBLE IN SCREEN
return ( elBot < scBot );
}else if( dir == 'down' ){
return ( elTop > scTop );
}else{
return ( ( elBot <= scBot ) && ( elTop >= scTop ) );
}
if( dir == 'up' ){
// STOP MOVING IF BOTTOM OF ELEMENT IS VISIBLE IN SCREEN
return ( elBot < scBot );
}else if( dir == 'down' ){
return ( elTop > scTop );
}else{
return ( ( elBot <= scBot ) && ( elTop >= scTop ) );
}
}
function scrollByX(elem, x){
var elTop = parseInt( elem.css('top'), 10 );
elem.css( 'top', ( elTop + x ) + "px" );
var elTop = parseInt( elem.css('top'), 10 );
elem.css( 'top', ( elTop + x ) + "px" );
}
+16 -15
View File
@@ -28,15 +28,16 @@ var StateManager = {
//create categories
var cats = [
'features', //big features like buildings, location availability, unlocks, etc
'stores', //little stuff, items, weapons, etc
'character', //this is for player's character stats such as perks
'features', //big features like buildings, location availability, unlocks, etc
'stores', //little stuff, items, weapons, etc
'character', //this is for player's character stats such as perks
'income',
'timers',
'game', //mostly location related: fire temp, workers, population, world map, etc
'playStats', //anything play related: play time, loads, etc
'previous', // prestige, score, trophies (in future), achievements (again, not yet), etc
'outfit' // used to temporarily store the items to be taken on the path
'game', //mostly location related: fire temp, workers, population, world map, etc
'playStats', //anything play related: play time, loads, etc
'previous', // prestige, score, trophies (in future), achievements (again, not yet), etc
'outfit', // used to temporarily store the items to be taken on the path
'config'
];
for(var which in cats) {
@@ -343,18 +344,18 @@ var StateManager = {
if(income.timeLeft <= 0) {
Engine.log('collection income from ' + source);
if(source == 'thieves') $SM.addStolen(income.stores);
if(source == 'thieves') $SM.addStolen(income.stores);
var cost = income.stores;
var ok = true;
if (source != 'thieves') {
for (var k in cost) {
var have = $SM.get('stores["' + k + '"]', true);
if (have + cost[k] < 0) {
ok = false;
break;
}
}
for (var k in cost) {
var have = $SM.get('stores["' + k + '"]', true);
if (have + cost[k] < 0) {
ok = false;
break;
}
}
}
if(ok){