Merge pull request #837 from DanielNoord/autosavetimer

Add option for autosave timer bar #799
This commit is contained in:
Daniël van Noord
2021-05-30 16:38:46 +02:00
committed by GitHub
5 changed files with 33 additions and 3 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -274,6 +274,13 @@ const Config = {
'Overlay on timers displaying seconds and/or percentage left',
true,
),
AutosaveTimerBar: new SettingStandard(
'bool',
'BarsDisplay',
['Autosave timer bar OFF', 'Autosave timer bar ON'],
'Show a timer counting down till next autosave in the timer bar',
true,
),
UpBarColour: new SettingStandard(
'bool',
'BarsDisplay',
@@ -339,7 +346,7 @@ const Config = {
'bool',
'BarsDisplay',
['Grimoire magic meter timer OFF', 'Grimoire magic meter timer ON'],
'A timer on how long before the Grimoire magic meter is full',
'A timer overlay showing how long till the Grimoire magic meter is full',
true,
),
GCTimer: new SettingStandard(

View File

@@ -31,6 +31,7 @@ const ConfigDefault: {
TimerBar: 1,
TimerBarPos: 0,
TimerBarOverlay: 2,
AutosaveTimerBar: 0,
UpBarColour: 1,
UpgradeBarFixedPos: 1,
SortBuildings: 0,

View File

@@ -25,6 +25,12 @@ export function CreateTimerBar() {
TimerBar.style.fontWeight = 'bold';
TimerBar.style.backgroundColor = 'black';
// Create standard Autosave bar
const CMTimerBarAutosave = CreateTimer('CMTimerBarAutosave', 'Autosave', [
{ id: 'CMTimerBarAutosaveBar', color: ColourPurple },
]);
TimerBar.appendChild(CMTimerBarAutosave);
// Create standard Golden Cookie bar
const CMTimerBarGC = CreateTimer('CMTimerBarGC', 'Next Cookie', [
{ id: 'CMTimerBarGCMinBar', color: ColourGray },
@@ -56,6 +62,22 @@ export function UpdateTimerBar() {
const maxWidthOneBar = l('CMTimerBar').offsetWidth - 133;
let numberOfTimers = 0;
if (CMOptions.AutosaveTimerBar && Game.prefs.autosave) {
const timeTillNextAutosave =
(Game.fps * 60 - (Game.OnAscend ? 0 : Game.T % (Game.fps * 60))) / Game.fps;
l('CMTimerBarAutosave').style.display = '';
l('CMTimerBarAutosaveBar').style.width = `${Math.round(
(timeTillNextAutosave *
(maxWidthOneBar - Math.ceil(timeTillNextAutosave).toString().length * 8)) /
60,
)}px`;
if (CMOptions.TimerBarOverlay >= 1) {
l('CMTimerBarAutosaveBar').textContent = Math.ceil(timeTillNextAutosave);
} else l('CMTimerBarAutosaveBar').textContent = '';
l('CMTimerBarAutosaveTime').textContent = Math.ceil(timeTillNextAutosave);
numberOfTimers += 1;
} else l('CMTimerBarAutosave').style.display = 'none';
// Regulates visibility of Golden Cookie timer
if (Game.shimmerTypes.golden.spawned === 0 && !Game.Has('Golden switch [off]')) {
l('CMTimerBarGC').style.display = '';