Changed order and reformatted settings #721

This commit is contained in:
Daniël van Noord
2021-03-23 09:35:48 +01:00
parent f7c4e23eb3
commit 02d49dca2e
29 changed files with 855 additions and 853 deletions

View File

@@ -7,7 +7,7 @@ import {
import { CMOptions } from '../../Config/VariablesAndData';
import BuildingSell from '../../Sim/SimulationEvents/SellBuilding';
import { Beautify } from '../BeautifyAndFormatting/BeautifyFormatting';
import { Colors, LastTargetBuildings } from '../VariablesAndData';
import { Colours, LastTargetBuildings } from '../VariablesAndData';
/**
* Section: Functions related to right column of the screen (buildings/upgrades)
@@ -15,8 +15,8 @@ import { Colors, LastTargetBuildings } from '../VariablesAndData';
/**
* This function adjusts some things in the column of buildings.
* It colours them, helps display the correct sell-price and shuffles the order when CM.Options.SortBuildings is set
* The function is called by CM.Disp.Draw(), CM.Disp.UpdateColors() & CM.Disp.RefreshScale()
* And by changes in CM.Options.BuildColor, CM.Options.SortBuild & CM.Data.Config.BulkBuildColor
* The function is called by CM.Disp.Draw(), CM.Disp.UpdateColours() & CM.Disp.RefreshScale()
* And by changes in CM.Options.BuildColour, CM.Options.SortBuild & CM.Data.Config.BulkBuildColour
*/
export default function UpdateBuildings() {
let target = Game.buyBulk;
@@ -30,10 +30,10 @@ export default function UpdateBuildings() {
else if (target === 100) target = CacheObjects100;
if (Game.buyMode === 1) {
if (CMOptions.BuildColor === 1) {
if (CMOptions.BuildColour === 1) {
Object.keys(target).forEach((i) => {
l(`productPrice${Game.Objects[i].id}`).style.color =
CMOptions.Colors[target[i].color];
CMOptions.Colours[target[i].color];
});
} else {
Object.keys(Game.Objects).forEach((i) => {
@@ -72,9 +72,9 @@ export default function UpdateBuildings() {
});
arr.sort(function (a, b) {
return Colors.indexOf(a.color) > Colors.indexOf(b.color)
return Colours.indexOf(a.color) > Colours.indexOf(b.color)
? 1
: Colors.indexOf(a.color) < Colors.indexOf(b.color)
: Colours.indexOf(a.color) < Colours.indexOf(b.color)
? -1
: a.pp < b.pp
? -1
@@ -89,9 +89,9 @@ export default function UpdateBuildings() {
});
arr.sort(function (a, b) {
return Colors.indexOf(a.color) > Colors.indexOf(b.color)
return Colours.indexOf(a.color) > Colours.indexOf(b.color)
? 1
: Colors.indexOf(a.color) < Colors.indexOf(b.color)
: Colours.indexOf(a.color) < Colours.indexOf(b.color)
? -1
: a.pp < b.pp
? -1

View File

@@ -1,13 +1,13 @@
import {
ColorBackPre,
ColorBlue,
ColorGray,
ColorGreen,
ColorOrange,
ColorPurple,
ColorRed,
ColorTextPre,
ColorYellow,
ColourBackPre,
ColourBlue,
ColourGray,
ColourGreen,
ColourOrange,
ColourPurple,
ColourRed,
ColourTextPre,
ColourYellow,
} from '../VariablesAndData';
/**
@@ -28,7 +28,7 @@ function CreateUpgradeBarLegend() {
const div = document.createElement('div');
div.style.verticalAlign = 'middle';
const span = document.createElement('span');
span.className = ColorBackPre + color;
span.className = ColourBackPre + color;
span.style.display = 'inline-block';
span.style.height = '10px';
span.style.width = '10px';
@@ -39,24 +39,24 @@ function CreateUpgradeBarLegend() {
};
legend.appendChild(
legendLine(ColorBlue, 'Better than the best PP of a building option'),
legendLine(ColourBlue, 'Better than the best PP of a building option'),
);
legend.appendChild(
legendLine(ColorGreen, 'Same as the best PP building option'),
legendLine(ColourGreen, 'Same as the best PP building option'),
);
legend.appendChild(
legendLine(ColorYellow, 'Within the top 10 of PP for buildings'),
legendLine(ColourYellow, 'Within the top 10 of PP for buildings'),
);
legend.appendChild(
legendLine(ColorOrange, 'Within the top 20 of PP for buildings'),
legendLine(ColourOrange, 'Within the top 20 of PP for buildings'),
);
legend.appendChild(
legendLine(ColorRed, 'Within the top 30 of PP for buildings'),
legendLine(ColourRed, 'Within the top 30 of PP for buildings'),
);
legend.appendChild(
legendLine(ColorPurple, 'Outside of the top 30 of PP for buildings'),
legendLine(ColourPurple, 'Outside of the top 30 of PP for buildings'),
);
legend.appendChild(legendLine(ColorGray, 'Negative or infinity PP'));
legend.appendChild(legendLine(ColourGray, 'Negative or infinity PP'));
return legend;
}
@@ -67,7 +67,7 @@ export default function CreateUpgradeBar() {
const UpgradeBar = document.createElement('div');
UpgradeBar.id = 'CMUpgradeBar';
UpgradeBar.style.width = '100%';
UpgradeBar.style.backgroundColor = 'black';
UpgradeBar.style.backgroundColour = 'black';
UpgradeBar.style.textAlign = 'center';
UpgradeBar.style.fontWeight = 'bold';
UpgradeBar.style.display = 'none';
@@ -85,19 +85,19 @@ export default function CreateUpgradeBar() {
const upgradeNumber = function (id, color) {
const span = document.createElement('span');
span.id = id;
span.className = ColorTextPre + color;
span.className = ColourTextPre + color;
span.style.width = '14.28571428571429%';
span.style.display = 'inline-block';
span.textContent = '0';
return span;
};
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarBlue', ColorBlue));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarGreen', ColorGreen));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarYellow', ColorYellow));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarOrange', ColorOrange));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarRed', ColorRed));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarPurple', ColorPurple));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarGray', ColorGray));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarBlue', ColourBlue));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarGreen', ColourGreen));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarYellow', ColourYellow));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarOrange', ColourOrange));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarRed', ColourRed));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarPurple', ColourPurple));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarGray', ColourGray));
l('upgrades').parentNode.insertBefore(
UpgradeBar,

View File

@@ -2,26 +2,26 @@
import { CacheUpgrades } from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData';
import {
ColorBackPre,
ColorBlue,
ColorGray,
ColorGreen,
ColorOrange,
ColorPurple,
ColorRed,
Colors,
ColorYellow,
ColourBackPre,
ColourBlue,
ColourGray,
ColourGreen,
ColourOrange,
ColourPurple,
ColourRed,
Colours,
ColourYellow,
} from '../VariablesAndData';
/**
* This function adjusts some things in the upgrades section
* It colours them and shuffles the order when CM.Options.SortBuildings is set
* The function is called by CM.Disp.Draw(), CM.Disp.ToggleUpgradeBarAndColor & CM.Disp.RefreshScale()
* The function is called by CM.Disp.Draw(), CM.Disp.ToggleUpgradeBarAndColour & CM.Disp.RefreshScale()
* And by changes in CM.Options.SortUpgrades
*/
export default function UpdateUpgrades() {
// This counts the amount of upgrades for each pp group and updates the Upgrade Bar
if (CMOptions.UpBarColor > 0) {
if (CMOptions.UpBarColour > 0) {
let blue = 0;
let green = 0;
let yellow = 0;
@@ -32,31 +32,31 @@ export default function UpdateUpgrades() {
Object.keys(Game.UpgradesInStore).forEach((i) => {
const me = Game.UpgradesInStore[i];
let addedColor = false;
let addedColour = false;
for (let j = 0; j < l(`upgrade${i}`).childNodes.length; j += 1) {
if (
l(`upgrade${i}`).childNodes[j].className.indexOf(ColorBackPre) !== -1
l(`upgrade${i}`).childNodes[j].className.indexOf(ColourBackPre) !== -1
) {
l(`upgrade${i}`).childNodes[j].className =
ColorBackPre + CacheUpgrades[me.name].color;
addedColor = true;
ColourBackPre + CacheUpgrades[me.name].color;
addedColour = true;
break;
}
}
if (!addedColor) {
if (!addedColour) {
const div = document.createElement('div');
div.style.width = '10px';
div.style.height = '10px';
div.className = ColorBackPre + CacheUpgrades[me.name].color;
div.className = ColourBackPre + CacheUpgrades[me.name].color;
l(`upgrade${i}`).appendChild(div);
}
if (CacheUpgrades[me.name].color === ColorBlue) blue += 1;
else if (CacheUpgrades[me.name].color === ColorGreen) green += 1;
else if (CacheUpgrades[me.name].color === ColorYellow) yellow += 1;
else if (CacheUpgrades[me.name].color === ColorOrange) orange += 1;
else if (CacheUpgrades[me.name].color === ColorRed) red += 1;
else if (CacheUpgrades[me.name].color === ColorPurple) purple += 1;
else if (CacheUpgrades[me.name].color === ColorGray) gray += 1;
if (CacheUpgrades[me.name].color === ColourBlue) blue += 1;
else if (CacheUpgrades[me.name].color === ColourGreen) green += 1;
else if (CacheUpgrades[me.name].color === ColourYellow) yellow += 1;
else if (CacheUpgrades[me.name].color === ColourOrange) orange += 1;
else if (CacheUpgrades[me.name].color === ColourRed) red += 1;
else if (CacheUpgrades[me.name].color === ColourPurple) purple += 1;
else if (CacheUpgrades[me.name].color === ColourGray) gray += 1;
});
l('CMUpgradeBarBlue').textContent = blue;
@@ -81,9 +81,9 @@ export default function UpdateUpgrades() {
if (CMOptions.SortUpgrades) {
arr.sort(function (a, b) {
return Colors.indexOf(a.color) > Colors.indexOf(b.color)
return Colours.indexOf(a.color) > Colours.indexOf(b.color)
? 1
: Colors.indexOf(a.color) < Colors.indexOf(b.color)
: Colours.indexOf(a.color) < Colours.indexOf(b.color)
? -1
: a.pp < b.pp
? -1