Add option for autosave timer bar #799

This commit is contained in:
Daniël van Noord
2021-05-30 16:37:26 +02:00
parent 9ba81afae1
commit ff31c45a4a
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', 'Overlay on timers displaying seconds and/or percentage left',
true, 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( UpBarColour: new SettingStandard(
'bool', 'bool',
'BarsDisplay', 'BarsDisplay',
@@ -339,7 +346,7 @@ const Config = {
'bool', 'bool',
'BarsDisplay', 'BarsDisplay',
['Grimoire magic meter timer OFF', 'Grimoire magic meter timer ON'], ['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, true,
), ),
GCTimer: new SettingStandard( GCTimer: new SettingStandard(

View File

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

View File

@@ -25,6 +25,12 @@ export function CreateTimerBar() {
TimerBar.style.fontWeight = 'bold'; TimerBar.style.fontWeight = 'bold';
TimerBar.style.backgroundColor = 'black'; 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 // Create standard Golden Cookie bar
const CMTimerBarGC = CreateTimer('CMTimerBarGC', 'Next Cookie', [ const CMTimerBarGC = CreateTimer('CMTimerBarGC', 'Next Cookie', [
{ id: 'CMTimerBarGCMinBar', color: ColourGray }, { id: 'CMTimerBarGCMinBar', color: ColourGray },
@@ -56,6 +62,22 @@ export function UpdateTimerBar() {
const maxWidthOneBar = l('CMTimerBar').offsetWidth - 133; const maxWidthOneBar = l('CMTimerBar').offsetWidth - 133;
let numberOfTimers = 0; 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 // Regulates visibility of Golden Cookie timer
if (Game.shimmerTypes.golden.spawned === 0 && !Game.Has('Golden switch [off]')) { if (Game.shimmerTypes.golden.spawned === 0 && !Game.Has('Golden switch [off]')) {
l('CMTimerBarGC').style.display = ''; l('CMTimerBarGC').style.display = '';