Merge branch 'master' into dev

Conflicts:
	CookieMonster.js
	src/Disp.js
	src/Main.js
This commit is contained in:
Aktanusa
2014-08-30 01:31:40 -04:00
9 changed files with 1217 additions and 104 deletions

View File

@@ -96,6 +96,19 @@ CM.Disp.GetConfigDisplay = function(config) {
return CM.ConfigData[config].label[CM.Config[config]];
}
CM.Disp.AddJscolor = function() {
CM.Disp.Jscolor = document.createElement('script');
CM.Disp.Jscolor.type = 'text/javascript';
CM.Disp.Jscolor.setAttribute('src', 'http://aktanusa.github.io/CookieMonster/jscolor/jscolor.js');
}
CM.Disp.CreateCssArea = function() {
CM.Disp.Css = document.createElement('style');
CM.Disp.Css.type = 'text/css';
document.head.appendChild(CM.Disp.Css);
}
CM.Disp.CreateBotBar = function() {
CM.Disp.BotBar = document.createElement('div');
CM.Disp.BotBar.id = 'CMBotBar';
@@ -122,7 +135,7 @@ CM.Disp.CreateBotBar = function() {
var firstCol = function(text, color) {
var td = document.createElement('td');
td.style.textAlign = 'right';
td.style.color = color;
td.className = CM.Disp.colorTextPre + color;
td.textContent = text;
return td;
}
@@ -145,7 +158,7 @@ CM.Disp.CreateBotBar = function() {
var header = document.createElement('td');
header.appendChild(document.createTextNode((i.indexOf(' ') != -1 ? i.substring(0, i.indexOf(' ')) : i) + ' ('));
var span = document.createElement('span');
span.style.color = CM.Disp.colorBlue;
span.className = CM.Disp.colorTextPre + CM.Disp.colorBlue;
header.appendChild(span);
header.appendChild(document.createTextNode(')'));
type.appendChild(header);
@@ -179,7 +192,7 @@ CM.Disp.UpdateBotBarOther = function() {
count++;
CM.Disp.BotBar.firstChild.firstChild.childNodes[0].childNodes[count].childNodes[1].textContent = Game.Objects[i].amount;
CM.Disp.BotBar.firstChild.firstChild.childNodes[1].childNodes[count].textContent = Beautify(CM.Cache.Objects[i].bonus, 2);
CM.Disp.BotBar.firstChild.firstChild.childNodes[2].childNodes[count].style.color = CM.Cache.Objects[i].color;
CM.Disp.BotBar.firstChild.firstChild.childNodes[2].childNodes[count].className = CM.Disp.colorTextPre + CM.Cache.Objects[i].color;
CM.Disp.BotBar.firstChild.firstChild.childNodes[2].childNodes[count].textContent = Beautify(CM.Cache.Objects[i].bci, 2);
}
}
@@ -192,7 +205,7 @@ CM.Disp.UpdateBotBarTime = function() {
for (var i in CM.Cache.Objects) {
count++;
var timeColor = CM.Disp.GetTimeColor(Game.Objects[i].getPrice());
CM.Disp.BotBar.firstChild.firstChild.childNodes[3].childNodes[count].style.color = timeColor.color;
CM.Disp.BotBar.firstChild.firstChild.childNodes[3].childNodes[count].className = CM.Disp.colorTextPre + timeColor.color;
CM.Disp.BotBar.firstChild.firstChild.childNodes[3].childNodes[count].textContent = timeColor.text;
}
}
@@ -238,7 +251,7 @@ CM.Disp.CreateTimerBar = function() {
colorBar.style.borderBottomRightRadius = '10px';
}
if (bars[i].color != undefined) {
colorBar.style.backgroundColor = bars[i].color;
colorBar.className = CM.Disp.colorBackPre + bars[i].color;
}
div.appendChild(colorBar);
}
@@ -351,15 +364,15 @@ CM.Disp.UpdateTimerBar = function() {
CM.Disp.TimerBarFren.style.display = '';
if (Game.frenzyPower == 7) {
l('CMTimerBarFrenType').textContent = 'Frenzy';
l('CMTimerBarFrenBar').style.backgroundColor = CM.Disp.colorYellow;
l('CMTimerBarFrenBar').className = CM.Disp.colorBackPre + CM.Disp.colorYellow;
}
else if (Game.frenzyPower == 0.5) {
l('CMTimerBarFrenType').textContent = 'Clot';
l('CMTimerBarFrenBar').style.backgroundColor = CM.Disp.colorRed;
l('CMTimerBarFrenBar').className = CM.Disp.colorBackPre + CM.Disp.colorRed;
}
else {
l('CMTimerBarFrenType').textContent = 'Blood Frenzy';
l('CMTimerBarFrenBar').style.backgroundColor = CM.Disp.colorGreen;
l('CMTimerBarFrenBar').className = CM.Disp.colorBackPre + CM.Disp.colorGreen;
}
l('CMTimerBarFrenBar').style.width = Math.round(Game.frenzy * maxWidth / Game.frenzyMax) + 'px';
l('CMTimerBarFrenTime').textContent = Math.ceil(Game.frenzy / Game.fps);
@@ -423,7 +436,7 @@ CM.Disp.UpdateBotTimerBarDisplay = function() {
CM.Disp.UpdateBuildings = function() {
if (CM.Config.BuildColor == 1) {
for (var i in CM.Cache.Objects) {
l('productPrice' + Game.Objects[i].id).style.color = CM.Cache.Objects[i].color;
l('productPrice' + Game.Objects[i].id).style.color = CM.Config.Colors[CM.Cache.Objects[i].color];
}
}
else {
@@ -457,7 +470,7 @@ CM.Disp.CreateUpgradeBar = function() {
var div = document.createElement('div');
div.style.verticalAlign = 'middle';
var span = document.createElement('span');
span.style.backgroundColor = color;
span.className = CM.Disp.colorBackPre + color;
span.style.display = 'inline-block';
span.style.height = '10px';
span.style.width = '10px';
@@ -481,7 +494,7 @@ CM.Disp.CreateUpgradeBar = function() {
var upgradeNumber = function(id, color) {
var span = document.createElement('span');
span.id = id;
span.style.color = color;
span.className = CM.Disp.colorTextPre + color;
span.style.width = '14.28571428571429%';
span.style.display = 'inline-block';
span.textContent = '0';
@@ -522,13 +535,13 @@ CM.Disp.UpdateUpgrades = function() {
for (var i in Game.UpgradesInStore) {
var me = Game.UpgradesInStore[i];
if (l('upgrade' + i).childNodes.length > 0) {
l('upgrade' + i).childNodes[0].style.backgroundColor = CM.Cache.Upgrades[me.name].color;
l('upgrade' + i).childNodes[0].className = CM.Disp.colorBackPre + CM.Cache.Upgrades[me.name].color;
}
else {
var div = document.createElement('div');
div.style.width = '10px';
div.style.height = '10px';
div.style.backgroundColor = CM.Cache.Upgrades[me.name].color;
div.className = CM.Disp.colorBackPre + CM.Cache.Upgrades[me.name].color;
l('upgrade' + i).appendChild(div);
}
if (CM.Cache.Upgrades[me.name].color == CM.Disp.colorBlue) blue++;
@@ -551,6 +564,21 @@ CM.Disp.UpdateUpgrades = function() {
}
}
CM.Disp.UpdateColors = function() {
var str = '';
for (var i = 0; i < CM.Disp.colors.length; i++) {
str += '.' + CM.Disp.colorTextPre + CM.Disp.colors[i] + ' { color: ' + CM.Config.Colors[CM.Disp.colors[i]] + '; }';
}
for (var i = 0; i < CM.Disp.colors.length; i++) {
str += '.' + CM.Disp.colorBackPre + CM.Disp.colors[i] + ' { background-color: ' + CM.Config.Colors[CM.Disp.colors[i]] + '; }';
}
for (var i = 0; i < CM.Disp.colors.length; i++) {
str += '.' + CM.Disp.colorBorderPre + CM.Disp.colors[i] + ' { border: 1px solid ' + CM.Config.Colors[CM.Disp.colors[i]] + '; }';
}
CM.Disp.Css.textContent = str;
CM.Disp.UpdateBuildings(); // Class has been already set
}
CM.Disp.CreateWhiteScreen = function() {
CM.Disp.WhiteScreen = document.createElement('div');
CM.Disp.WhiteScreen.id = 'CMWhiteScreen';
@@ -758,6 +786,22 @@ CM.Disp.AddMenuPref = function(title) {
frag.appendChild(listing('TimerBarPos'));
frag.appendChild(listing('BuildColor'));
frag.appendChild(listing('UpBarColor'));
for (var i = 0; i < CM.Disp.colors.length; i++) {
var div = document.createElement('div');
div.className = 'listing';
var input = document.createElement('input');
input.id = CM.ConfigPrefix + 'Color' + CM.Disp.colors[i];
input.className = 'option';
input.style.width = '65px';
input.value = CM.Config.Colors[CM.Disp.colors[i]];
div.appendChild(input);
eval('var change = function() {CM.Config.Colors[\'' + CM.Disp.colors[i] + '\'] = l(CM.ConfigPrefix + \'Color\' + \'' + CM.Disp.colors[i] + '\').value; CM.Disp.UpdateColors(); CM.SaveConfig(CM.Config);}');
var jscolorpicker = new jscolor.color(input, {hash: true, caps: false, pickerZIndex: 1000000, pickerPosition: 'right', onImmediateChange: change});
var label = document.createElement('label');
label.textContent = CM.ConfigData.Colors.desc[CM.Disp.colors[i]];
div.appendChild(label);
frag.appendChild(div);
}
frag.appendChild(header('Golden Cookie/Season Popup Emphasis'));
frag.appendChild(listing('Flash'));
@@ -870,7 +914,7 @@ CM.Disp.AddMenuStats = function(title) {
var luckyReqFrag = document.createDocumentFragment();
var luckyReqSpan = document.createElement('span');
luckyReqSpan.style.fontWeight = 'bold';
luckyReqSpan.style.color = luckyColor;
luckyReqSpan.className = CM.Disp.colorTextPre + luckyColor;
luckyReqSpan.textContent = Beautify(CM.Cache.Lucky);
luckyReqFrag.appendChild(luckyReqSpan);
if (luckyTime != '') {
@@ -882,7 +926,7 @@ CM.Disp.AddMenuStats = function(title) {
var luckyReqFrenFrag = document.createDocumentFragment();
var luckyReqFrenSpan = document.createElement('span');
luckyReqFrenSpan.style.fontWeight = 'bold';
luckyReqFrenSpan.style.color = luckyColorFrenzy;
luckyReqFrenSpan.className = CM.Disp.colorTextPre + luckyColorFrenzy;
luckyReqFrenSpan.textContent = Beautify(CM.Cache.LuckyFrenzy);
luckyReqFrenFrag.appendChild(luckyReqFrenSpan);
if (luckyTimeFrenzy != '') {
@@ -909,7 +953,7 @@ CM.Disp.AddMenuStats = function(title) {
var chainReqFrag = document.createDocumentFragment();
var chainReqSpan = document.createElement('span');
chainReqSpan.style.fontWeight = 'bold';
chainReqSpan.style.color = chainColor;
chainReqSpan.className = CM.Disp.colorTextPre + chainColor;
chainReqSpan.textContent = Beautify(CM.Cache.Chain);
chainReqFrag.appendChild(chainReqSpan);
if (chainTime != '') {
@@ -921,7 +965,7 @@ CM.Disp.AddMenuStats = function(title) {
var chainReqFrenFrag = document.createDocumentFragment();
var chainReqFrenSpan = document.createElement('span');
chainReqFrenSpan.style.fontWeight = 'bold';
chainReqFrenSpan.style.color = chainColorFrenzy;
chainReqFrenSpan.className = CM.Disp.colorTextPre + chainColorFrenzy;
chainReqFrenSpan.textContent = Beautify(CM.Cache.ChainFrenzy);
chainReqFrenFrag.appendChild(chainReqFrenSpan);
if (chainTimeFrenzy != '') {
@@ -1090,8 +1134,7 @@ CM.Disp.AddMenuStats = function(title) {
CM.Disp.AddMenu = function() {
var title = function() {
var div = document.createElement('div');
div.className = 'title';
div.style.color = CM.Disp.colorBlue;
div.className = 'title ' + CM.Disp.colorTextPre + CM.Disp.colorBlue;
div.textContent = 'Cookie Monster Goodies';
return div;
}
@@ -1132,13 +1175,13 @@ CM.Disp.CreateTooltipWarnCaut = function() {
box.style.MsTransition = 'opacity 0.1s ease-out';
box.style.OTransition = 'opacity 0.1s ease-out';
box.style.transition = 'opacity 0.1s ease-out';
box.style.border = '1px solid ' + color;
box.className = CM.Disp.colorBorderPre + color;
box.style.padding = '2px';
box.style.background = '#000 url(img/darkNoise.png)';
var labelDiv = document.createElement('div');
box.appendChild(labelDiv);
var labelSpan = document.createElement('span');
labelSpan.style.color = color;
labelSpan.className = CM.Disp.colorTextPre + color;
labelSpan.style.fontWeight = 'bold';
labelSpan.textContent = labelTextFront;
labelDiv.appendChild(labelSpan);
@@ -1234,7 +1277,7 @@ CM.Disp.Tooltip = function(type, name) {
var header = function(text) {
var div = document.createElement('div');
div.style.fontWeight = 'bold';
div.style.color = CM.Disp.colorBlue;
div.className = CM.Disp.colorTextPre + CM.Disp.colorBlue;
div.textContent = text;
return div;
}
@@ -1276,18 +1319,18 @@ CM.Disp.UpdateTooltip = function() {
bonus = CM.Cache.Objects[CM.Disp.tooltipName].bonus;
price = Game.Objects[CM.Disp.tooltipName].getPrice();
if (CM.Config.Tooltip == 1) {
l('CMTooltipBorder').style.color = CM.Cache.Objects[CM.Disp.tooltipName].color;
l('CMTooltipBorder').className = CM.Disp.colorTextPre + CM.Cache.Objects[CM.Disp.tooltipName].color;
l('CMTooltipBCI').textContent = Beautify(CM.Cache.Objects[CM.Disp.tooltipName].bci, 2);
l('CMTooltipBCI').style.color = CM.Cache.Objects[CM.Disp.tooltipName].color;
l('CMTooltipBCI').className = CM.Disp.colorTextPre + CM.Cache.Objects[CM.Disp.tooltipName].color;
}
}
else {
bonus = CM.Cache.Objects10[CM.Disp.tooltipName].bonus;
price = CM.Cache.Objects10[CM.Disp.tooltipName].price;
if (CM.Config.Tooltip == 1) {
l('CMTooltipBorder').style.color = CM.Cache.Objects10[CM.Disp.tooltipName].color;
l('CMTooltipBorder').className = CM.Disp.colorTextPre + CM.Cache.Objects10[CM.Disp.tooltipName].color;
l('CMTooltipBCI').textContent = Beautify(CM.Cache.Objects10[CM.Disp.tooltipName].bci, 2);
l('CMTooltipBCI').style.color = CM.Cache.Objects10[CM.Disp.tooltipName].color;
l('CMTooltipBCI').className = CM.Disp.colorTextPre + CM.Cache.Objects10[CM.Disp.tooltipName].color;
}
}
}
@@ -1295,9 +1338,9 @@ CM.Disp.UpdateTooltip = function() {
bonus = CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].bonus;
price = Game.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].getPrice();
if (CM.Config.Tooltip == 1) {
l('CMTooltipBorder').style.color = CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].color;
l('CMTooltipBorder').className = CM.Disp.colorTextPre + CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].color;
l('CMTooltipBCI').textContent = Beautify(CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].bci, 2);
l('CMTooltipBCI').style.color = CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].color;
l('CMTooltipBCI').className = CM.Disp.colorTextPre + CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].color;
}
}
if (CM.Config.Tooltip == 1) {
@@ -1310,7 +1353,7 @@ CM.Disp.UpdateTooltip = function() {
var timeColor = CM.Disp.GetTimeColor(price);
l('CMTooltipTime').textContent = timeColor.text;
l('CMTooltipTime').style.color = timeColor.color;
l('CMTooltipTime').className = CM.Disp.colorTextPre + timeColor.color;
}
if (CM.Config.ToolWarnCaut == 1) {
@@ -1456,13 +1499,17 @@ CM.Disp.RefreshScale = function() {
CM.Disp.min = -1;
CM.Disp.max = -1;
CM.Disp.mid = -1;
CM.Disp.colorBlue = '#4bb8f0';
CM.Disp.colorGreen = 'lime';
CM.Disp.colorYellow = 'yellow';
CM.Disp.colorOrange = '#ff7f00';
CM.Disp.colorRed = 'red';
CM.Disp.colorPurple = 'magenta';
CM.Disp.colorGray = '#b3b3b3';
CM.Disp.colorTextPre = 'CMText';
CM.Disp.colorBackPre = 'CMBack';
CM.Disp.colorBorderPre = 'CMBorder';
CM.Disp.colorBlue = 'Blue';
CM.Disp.colorGreen = 'Green';
CM.Disp.colorYellow = 'Yellow';
CM.Disp.colorOrange = 'Orange';
CM.Disp.colorRed = 'Red';
CM.Disp.colorPurple = 'Purple';
CM.Disp.colorGray = 'Gray';
CM.Disp.colors = [ CM.Disp.colorBlue, CM.Disp.colorGreen, CM.Disp.colorYellow, CM.Disp.colorOrange, CM.Disp.colorRed, CM.Disp.colorPurple, CM.Disp.colorGray];
CM.Disp.lastGoldenCookieState = 'none';
CM.Disp.lastAscendState = -1;