Toggle to display PP as time period #625

This commit is contained in:
Daniël van Noord
2021-03-17 23:19:34 +01:00
parent 1a0750e8d7
commit 4d716e77e4
9 changed files with 32 additions and 9 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -100,6 +100,13 @@ const Config = {
UpdateBuildings();
},
),
PPDisplayTime: new SettingStandard(
'bool',
'BarsColors',
['PP As Value (Standard)', 'PP As Time Unit'],
'Display PP as calculated value or as approximate time unit. Note that PP does not translate directly into a time unit and this is therefore only an approximation.',
false,
),
UpBarColor: new SettingStandard(
'bool',
'BarsColors',

View File

@@ -5,6 +5,7 @@ const ConfigDefault = {
TimerBarPos: 0,
TimerBarOverlay: 2,
BuildColor: 1,
PPDisplayTime: 0,
UpBarColor: 1,
UpgradeBarFixedPos: 1,
CalcWrink: 0,

View File

@@ -96,6 +96,7 @@ export function Beautify(num, floats, forced) {
export function FormatTime(time, longFormat) {
let formattedTime = time;
if (time === Infinity) return time;
if (time < 0) return 'Negative time period';
formattedTime = Math.ceil(time);
const y = Math.floor(formattedTime / 31557600);
const d = Math.floor((formattedTime % 31557600) / 86400);

View File

@@ -9,6 +9,7 @@ import { CMOptions } from '../../Config/VariablesAndData';
import { VersionMajor, VersionMinor } from '../../Data/Moddata';
import {
Beautify,
FormatTime,
GetTimeColor,
} from '../BeautifyAndFormatting/BeautifyFormatting';
import GetCPS from '../HelperFunctions/GetCPS';
@@ -94,9 +95,13 @@ export function UpdateBotBar() {
l('CMBotBar').firstChild.firstChild.childNodes[2].childNodes[
count
].className = ColorTextPre + target[i].color;
let PPString;
if (CMOptions.PPDisplayTime)
PPString = FormatTime(Math.round(target[i].pp));
else PPString = Beautify(Math.round(target[i].pp), 2);
l('CMBotBar').firstChild.firstChild.childNodes[2].childNodes[
count
].textContent = Beautify(Math.round(target[i].pp), 2);
].textContent = PPString;
const timeColor = GetTimeColor(
(Game.Objects[i].bulkPrice - (Game.cookies + GetWrinkConfigBank())) /
GetCPS(),

View File

@@ -8,6 +8,7 @@ import { CMOptions } from '../../../Config/VariablesAndData';
import { SimObjects } from '../../../Sim/VariablesAndData';
import {
Beautify,
FormatTime,
GetTimeColor,
} from '../../BeautifyAndFormatting/BeautifyFormatting';
import GetCPS from '../../HelperFunctions/GetCPS';
@@ -55,7 +56,9 @@ export default function Building() {
}01% of income)`;
}
l('CMTooltipBorder').className = ColorTextPre + target[TooltipName].color;
l('CMTooltipPP').textContent = Beautify(target[TooltipName].pp, 2);
if (CMOptions.PPDisplayTime)
l('CMTooltipPP').textContent = FormatTime(target[TooltipName].pp);
else l('CMTooltipPP').textContent = Beautify(target[TooltipName].pp, 2);
l('CMTooltipPP').className = ColorTextPre + target[TooltipName].color;
const timeColor = GetTimeColor(
(TooltipPrice - (Game.cookies + GetWrinkConfigBank())) / GetCPS(),

View File

@@ -5,6 +5,7 @@ import {
import { CMOptions } from '../../../Config/VariablesAndData';
import {
Beautify,
FormatTime,
GetTimeColor,
} from '../../BeautifyAndFormatting/BeautifyFormatting';
import GetCPS from '../../HelperFunctions/GetCPS';
@@ -70,6 +71,11 @@ export default function Upgrade() {
)} Clicks`;
l('CMTooltipPP').style.color = 'white';
} else {
if (CMOptions.PPDisplayTime)
l('CMTooltipPP').textContent = FormatTime(
CacheUpgrades[Game.UpgradesInStore[TooltipName].name].pp,
);
else
l('CMTooltipPP').textContent = Beautify(
CacheUpgrades[Game.UpgradesInStore[TooltipName].name].pp,
2,