Compatibility with content mods (#350)
This commit is contained in:
committed by
GitHub
parent
3d965943c0
commit
66ac922ae2
0
Combine.sh
Normal file → Executable file
0
Combine.sh
Normal file → Executable file
@@ -1016,6 +1016,36 @@ CM.Disp.CreateCssArea = function() {
|
|||||||
l("upgrades").style["flex-wrap"] = "wrap";
|
l("upgrades").style["flex-wrap"] = "wrap";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extends the bottom bar (created by CM.Disp.CreateBotBar) with a column for the given building.
|
||||||
|
*
|
||||||
|
* This function is called by CM.Disp.CreateBotBar on initialization of Cookie Monster,
|
||||||
|
* and also in CM.Sim.CopyData if a new building (added by another mod) is discovered.
|
||||||
|
*/
|
||||||
|
CM.Disp.CreateBotBarBuildingColumn = function(buildingName) {
|
||||||
|
if(!CM.Disp.BotBar) {
|
||||||
|
CM.Disp.CreateBotBar();
|
||||||
|
return; // CreateBotBar will call this function again
|
||||||
|
}
|
||||||
|
|
||||||
|
var type = CM.Disp.BotBar.firstChild.firstChild.childNodes[0];
|
||||||
|
var bonus = CM.Disp.BotBar.firstChild.firstChild.childNodes[1];
|
||||||
|
var pp = CM.Disp.BotBar.firstChild.firstChild.childNodes[2];
|
||||||
|
var time = CM.Disp.BotBar.firstChild.firstChild.childNodes[3];
|
||||||
|
|
||||||
|
var i = buildingName;
|
||||||
|
var header = type.appendChild(document.createElement('td'));
|
||||||
|
header.appendChild(document.createTextNode((i.indexOf(' ') != -1 ? i.substring(0, i.indexOf(' ')) : i) + ' ('));
|
||||||
|
|
||||||
|
var span = header.appendChild(document.createElement('span'));
|
||||||
|
span.className = CM.Disp.colorTextPre + CM.Disp.colorBlue;
|
||||||
|
|
||||||
|
header.appendChild(document.createTextNode(')'));
|
||||||
|
bonus.appendChild(document.createElement('td'));
|
||||||
|
pp.appendChild(document.createElement('td'));
|
||||||
|
time.appendChild(document.createElement('td'));
|
||||||
|
}
|
||||||
|
|
||||||
CM.Disp.CreateBotBar = function() {
|
CM.Disp.CreateBotBar = function() {
|
||||||
CM.Disp.BotBar = document.createElement('div');
|
CM.Disp.BotBar = document.createElement('div');
|
||||||
CM.Disp.BotBar.id = 'CMBotBar';
|
CM.Disp.BotBar.id = 'CMBotBar';
|
||||||
@@ -1032,15 +1062,14 @@ CM.Disp.CreateBotBar = function() {
|
|||||||
CM.Disp.BotBar.style.overflow = 'auto';
|
CM.Disp.BotBar.style.overflow = 'auto';
|
||||||
CM.Disp.BotBar.style.textShadow = '-1px 0 black, 0 1px black, 1px 0 black, 0 -1px black';
|
CM.Disp.BotBar.style.textShadow = '-1px 0 black, 0 1px black, 1px 0 black, 0 -1px black';
|
||||||
|
|
||||||
var table = document.createElement('table');
|
var table = CM.Disp.BotBar.appendChild(document.createElement('table'));
|
||||||
table.style.width = '100%';
|
table.style.width = '100%';
|
||||||
table.style.textAlign = 'center';
|
table.style.textAlign = 'center';
|
||||||
table.style.whiteSpace = 'nowrap';
|
table.style.whiteSpace = 'nowrap';
|
||||||
// TODO figure a better way
|
// TODO figure a better way
|
||||||
//table.style.tableLayout = 'fixed';
|
//table.style.tableLayout = 'fixed';
|
||||||
//table.style.overflow = 'hidden';
|
//table.style.overflow = 'hidden';
|
||||||
var tbody = document.createElement('tbody');
|
var tbody = table.appendChild(document.createElement('tbody'));
|
||||||
table.appendChild(tbody);
|
|
||||||
|
|
||||||
var firstCol = function(text, color) {
|
var firstCol = function(text, color) {
|
||||||
var td = document.createElement('td');
|
var td = document.createElement('td');
|
||||||
@@ -1050,36 +1079,20 @@ CM.Disp.CreateBotBar = function() {
|
|||||||
return td;
|
return td;
|
||||||
}
|
}
|
||||||
|
|
||||||
var type = document.createElement('tr');
|
var type = tbody.appendChild(document.createElement('tr'));
|
||||||
type.style.fontWeight = 'bold';
|
type.style.fontWeight = 'bold';
|
||||||
type.appendChild(firstCol(CM.VersionMajor + '.' + CM.VersionMinor, CM.Disp.colorYellow));
|
type.appendChild(firstCol(CM.VersionMajor + '.' + CM.VersionMinor, CM.Disp.colorYellow));
|
||||||
tbody.appendChild(type);
|
var bonus = tbody.appendChild(document.createElement('tr'));
|
||||||
var bonus = document.createElement('tr');
|
|
||||||
bonus.appendChild(firstCol('Bonus Income', CM.Disp.colorBlue));
|
bonus.appendChild(firstCol('Bonus Income', CM.Disp.colorBlue));
|
||||||
tbody.appendChild(bonus);
|
var pp = tbody.appendChild(document.createElement('tr'));
|
||||||
var pp = document.createElement('tr');
|
|
||||||
pp.appendChild(firstCol('Payback Period', CM.Disp.colorBlue));
|
pp.appendChild(firstCol('Payback Period', CM.Disp.colorBlue));
|
||||||
tbody.appendChild(pp);
|
var time = tbody.appendChild(document.createElement('tr'));
|
||||||
var time = document.createElement('tr');
|
|
||||||
time.appendChild(firstCol('Time Left', CM.Disp.colorBlue));
|
time.appendChild(firstCol('Time Left', CM.Disp.colorBlue));
|
||||||
tbody.appendChild(time);
|
|
||||||
|
|
||||||
for (var i in Game.Objects) {
|
for (var i in Game.Objects) {
|
||||||
var header = document.createElement('td');
|
CM.Disp.CreateBotBarBuildingColumn(i);
|
||||||
header.appendChild(document.createTextNode((i.indexOf(' ') != -1 ? i.substring(0, i.indexOf(' ')) : i) + ' ('));
|
|
||||||
var span = document.createElement('span');
|
|
||||||
span.className = CM.Disp.colorTextPre + CM.Disp.colorBlue;
|
|
||||||
header.appendChild(span);
|
|
||||||
header.appendChild(document.createTextNode(')'));
|
|
||||||
type.appendChild(header);
|
|
||||||
bonus.appendChild(document.createElement('td'));
|
|
||||||
pp.appendChild(document.createElement('td'));
|
|
||||||
time.appendChild(document.createElement('td'));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CM.Disp.BotBar.appendChild(table);
|
|
||||||
|
|
||||||
l('wrapper').appendChild(CM.Disp.BotBar);
|
l('wrapper').appendChild(CM.Disp.BotBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3677,6 +3690,8 @@ CM.Sim.CopyData = function() {
|
|||||||
var you = CM.Sim.Objects[i];
|
var you = CM.Sim.Objects[i];
|
||||||
if (you == undefined) {
|
if (you == undefined) {
|
||||||
CM.Sim.InitData();
|
CM.Sim.InitData();
|
||||||
|
you = CM.Sim.Objects[i]; // Not undefined anymore
|
||||||
|
CM.Disp.CreateBotBarBuildingColumn(i); // New building! Add it to the bottom bar
|
||||||
}
|
}
|
||||||
you.amount = me.amount;
|
you.amount = me.amount;
|
||||||
you.level = me.level;
|
you.level = me.level;
|
||||||
@@ -3688,6 +3703,7 @@ CM.Sim.CopyData = function() {
|
|||||||
var you = CM.Sim.Upgrades[i];
|
var you = CM.Sim.Upgrades[i];
|
||||||
if (you == undefined) {
|
if (you == undefined) {
|
||||||
CM.Sim.InitData();
|
CM.Sim.InitData();
|
||||||
|
you = CM.Sim.Upgrades[i];
|
||||||
}
|
}
|
||||||
you.bought = me.bought;
|
you.bought = me.bought;
|
||||||
}
|
}
|
||||||
@@ -3698,6 +3714,7 @@ CM.Sim.CopyData = function() {
|
|||||||
var you = CM.Sim.Achievements[i];
|
var you = CM.Sim.Achievements[i];
|
||||||
if (you == undefined) {
|
if (you == undefined) {
|
||||||
CM.Sim.InitData();
|
CM.Sim.InitData();
|
||||||
|
you = CM.Sim.Achievements[i];
|
||||||
}
|
}
|
||||||
you.won = me.won;
|
you.won = me.won;
|
||||||
}
|
}
|
||||||
|
|||||||
61
src/Disp.js
61
src/Disp.js
@@ -256,6 +256,36 @@ CM.Disp.CreateCssArea = function() {
|
|||||||
l("upgrades").style["flex-wrap"] = "wrap";
|
l("upgrades").style["flex-wrap"] = "wrap";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extends the bottom bar (created by CM.Disp.CreateBotBar) with a column for the given building.
|
||||||
|
*
|
||||||
|
* This function is called by CM.Disp.CreateBotBar on initialization of Cookie Monster,
|
||||||
|
* and also in CM.Sim.CopyData if a new building (added by another mod) is discovered.
|
||||||
|
*/
|
||||||
|
CM.Disp.CreateBotBarBuildingColumn = function(buildingName) {
|
||||||
|
if(!CM.Disp.BotBar) {
|
||||||
|
CM.Disp.CreateBotBar();
|
||||||
|
return; // CreateBotBar will call this function again
|
||||||
|
}
|
||||||
|
|
||||||
|
var type = CM.Disp.BotBar.firstChild.firstChild.childNodes[0];
|
||||||
|
var bonus = CM.Disp.BotBar.firstChild.firstChild.childNodes[1];
|
||||||
|
var pp = CM.Disp.BotBar.firstChild.firstChild.childNodes[2];
|
||||||
|
var time = CM.Disp.BotBar.firstChild.firstChild.childNodes[3];
|
||||||
|
|
||||||
|
var i = buildingName;
|
||||||
|
var header = type.appendChild(document.createElement('td'));
|
||||||
|
header.appendChild(document.createTextNode((i.indexOf(' ') != -1 ? i.substring(0, i.indexOf(' ')) : i) + ' ('));
|
||||||
|
|
||||||
|
var span = header.appendChild(document.createElement('span'));
|
||||||
|
span.className = CM.Disp.colorTextPre + CM.Disp.colorBlue;
|
||||||
|
|
||||||
|
header.appendChild(document.createTextNode(')'));
|
||||||
|
bonus.appendChild(document.createElement('td'));
|
||||||
|
pp.appendChild(document.createElement('td'));
|
||||||
|
time.appendChild(document.createElement('td'));
|
||||||
|
}
|
||||||
|
|
||||||
CM.Disp.CreateBotBar = function() {
|
CM.Disp.CreateBotBar = function() {
|
||||||
CM.Disp.BotBar = document.createElement('div');
|
CM.Disp.BotBar = document.createElement('div');
|
||||||
CM.Disp.BotBar.id = 'CMBotBar';
|
CM.Disp.BotBar.id = 'CMBotBar';
|
||||||
@@ -272,15 +302,14 @@ CM.Disp.CreateBotBar = function() {
|
|||||||
CM.Disp.BotBar.style.overflow = 'auto';
|
CM.Disp.BotBar.style.overflow = 'auto';
|
||||||
CM.Disp.BotBar.style.textShadow = '-1px 0 black, 0 1px black, 1px 0 black, 0 -1px black';
|
CM.Disp.BotBar.style.textShadow = '-1px 0 black, 0 1px black, 1px 0 black, 0 -1px black';
|
||||||
|
|
||||||
var table = document.createElement('table');
|
var table = CM.Disp.BotBar.appendChild(document.createElement('table'));
|
||||||
table.style.width = '100%';
|
table.style.width = '100%';
|
||||||
table.style.textAlign = 'center';
|
table.style.textAlign = 'center';
|
||||||
table.style.whiteSpace = 'nowrap';
|
table.style.whiteSpace = 'nowrap';
|
||||||
// TODO figure a better way
|
// TODO figure a better way
|
||||||
//table.style.tableLayout = 'fixed';
|
//table.style.tableLayout = 'fixed';
|
||||||
//table.style.overflow = 'hidden';
|
//table.style.overflow = 'hidden';
|
||||||
var tbody = document.createElement('tbody');
|
var tbody = table.appendChild(document.createElement('tbody'));
|
||||||
table.appendChild(tbody);
|
|
||||||
|
|
||||||
var firstCol = function(text, color) {
|
var firstCol = function(text, color) {
|
||||||
var td = document.createElement('td');
|
var td = document.createElement('td');
|
||||||
@@ -290,36 +319,20 @@ CM.Disp.CreateBotBar = function() {
|
|||||||
return td;
|
return td;
|
||||||
}
|
}
|
||||||
|
|
||||||
var type = document.createElement('tr');
|
var type = tbody.appendChild(document.createElement('tr'));
|
||||||
type.style.fontWeight = 'bold';
|
type.style.fontWeight = 'bold';
|
||||||
type.appendChild(firstCol(CM.VersionMajor + '.' + CM.VersionMinor, CM.Disp.colorYellow));
|
type.appendChild(firstCol(CM.VersionMajor + '.' + CM.VersionMinor, CM.Disp.colorYellow));
|
||||||
tbody.appendChild(type);
|
var bonus = tbody.appendChild(document.createElement('tr'));
|
||||||
var bonus = document.createElement('tr');
|
|
||||||
bonus.appendChild(firstCol('Bonus Income', CM.Disp.colorBlue));
|
bonus.appendChild(firstCol('Bonus Income', CM.Disp.colorBlue));
|
||||||
tbody.appendChild(bonus);
|
var pp = tbody.appendChild(document.createElement('tr'));
|
||||||
var pp = document.createElement('tr');
|
|
||||||
pp.appendChild(firstCol('Payback Period', CM.Disp.colorBlue));
|
pp.appendChild(firstCol('Payback Period', CM.Disp.colorBlue));
|
||||||
tbody.appendChild(pp);
|
var time = tbody.appendChild(document.createElement('tr'));
|
||||||
var time = document.createElement('tr');
|
|
||||||
time.appendChild(firstCol('Time Left', CM.Disp.colorBlue));
|
time.appendChild(firstCol('Time Left', CM.Disp.colorBlue));
|
||||||
tbody.appendChild(time);
|
|
||||||
|
|
||||||
for (var i in Game.Objects) {
|
for (var i in Game.Objects) {
|
||||||
var header = document.createElement('td');
|
CM.Disp.CreateBotBarBuildingColumn(i);
|
||||||
header.appendChild(document.createTextNode((i.indexOf(' ') != -1 ? i.substring(0, i.indexOf(' ')) : i) + ' ('));
|
|
||||||
var span = document.createElement('span');
|
|
||||||
span.className = CM.Disp.colorTextPre + CM.Disp.colorBlue;
|
|
||||||
header.appendChild(span);
|
|
||||||
header.appendChild(document.createTextNode(')'));
|
|
||||||
type.appendChild(header);
|
|
||||||
bonus.appendChild(document.createElement('td'));
|
|
||||||
pp.appendChild(document.createElement('td'));
|
|
||||||
time.appendChild(document.createElement('td'));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CM.Disp.BotBar.appendChild(table);
|
|
||||||
|
|
||||||
l('wrapper').appendChild(CM.Disp.BotBar);
|
l('wrapper').appendChild(CM.Disp.BotBar);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -168,6 +168,8 @@ CM.Sim.CopyData = function() {
|
|||||||
var you = CM.Sim.Objects[i];
|
var you = CM.Sim.Objects[i];
|
||||||
if (you == undefined) {
|
if (you == undefined) {
|
||||||
CM.Sim.InitData();
|
CM.Sim.InitData();
|
||||||
|
you = CM.Sim.Objects[i]; // Not undefined anymore
|
||||||
|
CM.Disp.CreateBotBarBuildingColumn(i); // New building! Add it to the bottom bar
|
||||||
}
|
}
|
||||||
you.amount = me.amount;
|
you.amount = me.amount;
|
||||||
you.level = me.level;
|
you.level = me.level;
|
||||||
@@ -179,6 +181,7 @@ CM.Sim.CopyData = function() {
|
|||||||
var you = CM.Sim.Upgrades[i];
|
var you = CM.Sim.Upgrades[i];
|
||||||
if (you == undefined) {
|
if (you == undefined) {
|
||||||
CM.Sim.InitData();
|
CM.Sim.InitData();
|
||||||
|
you = CM.Sim.Upgrades[i];
|
||||||
}
|
}
|
||||||
you.bought = me.bought;
|
you.bought = me.bought;
|
||||||
}
|
}
|
||||||
@@ -189,6 +192,7 @@ CM.Sim.CopyData = function() {
|
|||||||
var you = CM.Sim.Achievements[i];
|
var you = CM.Sim.Achievements[i];
|
||||||
if (you == undefined) {
|
if (you == undefined) {
|
||||||
CM.Sim.InitData();
|
CM.Sim.InitData();
|
||||||
|
you = CM.Sim.Achievements[i];
|
||||||
}
|
}
|
||||||
you.won = me.won;
|
you.won = me.won;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user