From 97014d273eb61ab688b1138e995ec0a14199e6fd Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sun, 27 Dec 2020 12:39:33 +0100 Subject: [PATCH 1/3] Added timer overlays in TimerBar (#147) --- CookieMonster.js | 12 +++++++++--- src/Disp.js | 12 +++++++++--- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 08fe36e..191ee81 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -1592,7 +1592,7 @@ CM.Disp.CreateTimerBar = function() { */ CM.Disp.TimerBarCreateBar = function(id, name, bars) { timerBar = document.createElement('div'); - timerBar.id = 'CMTimerBarGC'; + timerBar.id = 'CMTimerBar'; timerBar.style.height = '12px'; timerBar.style.margin = '0px 10px'; timerBar.style.position = 'relative'; @@ -1621,6 +1621,8 @@ CM.Disp.TimerBarCreateBar = function(id, name, bars) { colorBar.id = bars[i].id colorBar.style.display = 'inline-block'; colorBar.style.height = '10px'; + colorBar.style.verticalAlign = "text-top"; + colorBar.style.textAlign="center"; if (bars.length - 1 == i) { colorBar.style.borderTopRightRadius = '10px'; colorBar.style.borderBottomRightRadius = '10px'; @@ -1643,7 +1645,7 @@ CM.Disp.TimerBarCreateBar = function(id, name, bars) { } /** - * This function creates an indivudual timer for the timer bar + * This function updates indivudual timers in the timer bar * It is called by CM.Loop() */ CM.Disp.UpdateTimerBar = function() { @@ -1656,6 +1658,7 @@ CM.Disp.UpdateTimerBar = function() { if (Game.shimmerTypes['golden'].spawned == 0 && !Game.Has('Golden switch [off]')) { CM.Disp.TimerBars['CMTimerBarGC'].style.display = ''; l('CMTimerBarGCMinBar').style.width = Math.round(Math.max(0, Game.shimmerTypes['golden'].minTime - Game.shimmerTypes['golden'].time) * maxWidth / Game.shimmerTypes['golden'].maxTime) + 'px'; + l('CMTimerBarGCMinBar').textContent = Math.ceil((Game.shimmerTypes['golden'].minTime - Game.shimmerTypes['golden'].time)/ Game.fps) if (Game.shimmerTypes['golden'].minTime == Game.shimmerTypes['golden'].maxTime) { l('CMTimerBarGCMinBar').style.borderTopRightRadius = '10px'; l('CMTimerBarGCMinBar').style.borderBottomRightRadius = '10px'; @@ -1665,16 +1668,19 @@ CM.Disp.UpdateTimerBar = function() { l('CMTimerBarGCMinBar').style.borderBottomRightRadius = ''; } l('CMTimerBarGCBar').style.width = Math.round(Math.min(Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].minTime, Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) * maxWidth / Game.shimmerTypes['golden'].maxTime) + 'px'; + l('CMTimerBarGCBar').textContent = Math.ceil(Math.min(Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].minTime, Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) / Game.fps); l('CMTimerBarGCTime').textContent = Math.ceil((Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) / Game.fps); numberOfTimers++; } else CM.Disp.TimerBars['CMTimerBarGC'].style.display = 'none'; - // Regulates visibility of Reinder timer + // Regulates visibility of Reindeer timer if (Game.season == 'christmas' && Game.shimmerTypes['reindeer'].spawned == 0) { CM.Disp.TimerBars['CMTimerBarRen'].style.display = ''; l('CMTimerBarRenMinBar').style.width = Math.round(Math.max(0, Game.shimmerTypes['reindeer'].minTime - Game.shimmerTypes['reindeer'].time) * maxWidth / Game.shimmerTypes['reindeer'].maxTime) + 'px'; + l('CMTimerBarRenMinBar').textContent = Math.ceil((Game.shimmerTypes['reindeer'].minTime - Game.shimmerTypes['reindeer'].time)/ Game.fps) l('CMTimerBarRenBar').style.width = Math.round(Math.min(Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].minTime, Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) * maxWidth / Game.shimmerTypes['reindeer'].maxTime) + 'px'; + l('CMTimerBarRenBar').textContent = Math.ceil(Math.min(Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].minTime, Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) / Game.fps); l('CMTimerBarRenTime').textContent = Math.ceil((Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) / Game.fps); numberOfTimers++; } diff --git a/src/Disp.js b/src/Disp.js index f538e7d..02dc403 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -476,7 +476,7 @@ CM.Disp.CreateTimerBar = function() { */ CM.Disp.TimerBarCreateBar = function(id, name, bars) { timerBar = document.createElement('div'); - timerBar.id = 'CMTimerBarGC'; + timerBar.id = 'CMTimerBar'; timerBar.style.height = '12px'; timerBar.style.margin = '0px 10px'; timerBar.style.position = 'relative'; @@ -505,6 +505,8 @@ CM.Disp.TimerBarCreateBar = function(id, name, bars) { colorBar.id = bars[i].id colorBar.style.display = 'inline-block'; colorBar.style.height = '10px'; + colorBar.style.verticalAlign = "text-top"; + colorBar.style.textAlign="center"; if (bars.length - 1 == i) { colorBar.style.borderTopRightRadius = '10px'; colorBar.style.borderBottomRightRadius = '10px'; @@ -527,7 +529,7 @@ CM.Disp.TimerBarCreateBar = function(id, name, bars) { } /** - * This function creates an indivudual timer for the timer bar + * This function updates indivudual timers in the timer bar * It is called by CM.Loop() */ CM.Disp.UpdateTimerBar = function() { @@ -540,6 +542,7 @@ CM.Disp.UpdateTimerBar = function() { if (Game.shimmerTypes['golden'].spawned == 0 && !Game.Has('Golden switch [off]')) { CM.Disp.TimerBars['CMTimerBarGC'].style.display = ''; l('CMTimerBarGCMinBar').style.width = Math.round(Math.max(0, Game.shimmerTypes['golden'].minTime - Game.shimmerTypes['golden'].time) * maxWidth / Game.shimmerTypes['golden'].maxTime) + 'px'; + l('CMTimerBarGCMinBar').textContent = Math.ceil((Game.shimmerTypes['golden'].minTime - Game.shimmerTypes['golden'].time)/ Game.fps) if (Game.shimmerTypes['golden'].minTime == Game.shimmerTypes['golden'].maxTime) { l('CMTimerBarGCMinBar').style.borderTopRightRadius = '10px'; l('CMTimerBarGCMinBar').style.borderBottomRightRadius = '10px'; @@ -549,16 +552,19 @@ CM.Disp.UpdateTimerBar = function() { l('CMTimerBarGCMinBar').style.borderBottomRightRadius = ''; } l('CMTimerBarGCBar').style.width = Math.round(Math.min(Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].minTime, Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) * maxWidth / Game.shimmerTypes['golden'].maxTime) + 'px'; + l('CMTimerBarGCBar').textContent = Math.ceil(Math.min(Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].minTime, Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) / Game.fps); l('CMTimerBarGCTime').textContent = Math.ceil((Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) / Game.fps); numberOfTimers++; } else CM.Disp.TimerBars['CMTimerBarGC'].style.display = 'none'; - // Regulates visibility of Reinder timer + // Regulates visibility of Reindeer timer if (Game.season == 'christmas' && Game.shimmerTypes['reindeer'].spawned == 0) { CM.Disp.TimerBars['CMTimerBarRen'].style.display = ''; l('CMTimerBarRenMinBar').style.width = Math.round(Math.max(0, Game.shimmerTypes['reindeer'].minTime - Game.shimmerTypes['reindeer'].time) * maxWidth / Game.shimmerTypes['reindeer'].maxTime) + 'px'; + l('CMTimerBarRenMinBar').textContent = Math.ceil((Game.shimmerTypes['reindeer'].minTime - Game.shimmerTypes['reindeer'].time)/ Game.fps) l('CMTimerBarRenBar').style.width = Math.round(Math.min(Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].minTime, Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) * maxWidth / Game.shimmerTypes['reindeer'].maxTime) + 'px'; + l('CMTimerBarRenBar').textContent = Math.ceil(Math.min(Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].minTime, Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) / Game.fps); l('CMTimerBarRenTime').textContent = Math.ceil((Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) / Game.fps); numberOfTimers++; } From 6edda5420f7873a12bfc17fbe37b486531aa1022 Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sun, 27 Dec 2020 13:07:07 +0100 Subject: [PATCH 2/3] Fixed Timers for loans (#304) --- CookieMonster.js | 17 ++++++++++------- src/Disp.js | 17 ++++++++++------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index 191ee81..cab285e 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -1610,6 +1610,7 @@ CM.Disp.TimerBarCreateBar = function(id, name, bars) { var type = document.createElement('span'); type.style.display = 'inline-block'; type.style.textAlign = 'right'; + type.style.fontSize = "10px"; type.style.width = '108px'; type.style.marginRight = '5px'; type.style.verticalAlign = 'text-top'; @@ -1650,14 +1651,16 @@ CM.Disp.TimerBarCreateBar = function(id, name, bars) { */ CM.Disp.UpdateTimerBar = function() { if (CM.Options.TimerBar == 1) { - // label width: 113, timer width: 26, div margin: 20 - var maxWidth = CM.Disp.TimerBar.offsetWidth - 159; + // label width: 113, timer width: 30, div margin: 20 + var maxWidthTwoBar = CM.Disp.TimerBar.offsetWidth - 163; + // label width: 113, div margin: 20, calculate timer width at runtime + var maxWidthOneBar = CM.Disp.TimerBar.offsetWidth - 133; var numberOfTimers = 0; // Regulates visibility of Golden Cookie timer if (Game.shimmerTypes['golden'].spawned == 0 && !Game.Has('Golden switch [off]')) { CM.Disp.TimerBars['CMTimerBarGC'].style.display = ''; - l('CMTimerBarGCMinBar').style.width = Math.round(Math.max(0, Game.shimmerTypes['golden'].minTime - Game.shimmerTypes['golden'].time) * maxWidth / Game.shimmerTypes['golden'].maxTime) + 'px'; + l('CMTimerBarGCMinBar').style.width = Math.round(Math.max(0, Game.shimmerTypes['golden'].minTime - Game.shimmerTypes['golden'].time) * maxWidthTwoBar / Game.shimmerTypes['golden'].maxTime) + 'px'; l('CMTimerBarGCMinBar').textContent = Math.ceil((Game.shimmerTypes['golden'].minTime - Game.shimmerTypes['golden'].time)/ Game.fps) if (Game.shimmerTypes['golden'].minTime == Game.shimmerTypes['golden'].maxTime) { l('CMTimerBarGCMinBar').style.borderTopRightRadius = '10px'; @@ -1667,7 +1670,7 @@ CM.Disp.UpdateTimerBar = function() { l('CMTimerBarGCMinBar').style.borderTopRightRadius = ''; l('CMTimerBarGCMinBar').style.borderBottomRightRadius = ''; } - l('CMTimerBarGCBar').style.width = Math.round(Math.min(Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].minTime, Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) * maxWidth / Game.shimmerTypes['golden'].maxTime) + 'px'; + l('CMTimerBarGCBar').style.width = Math.round(Math.min(Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].minTime, Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) * maxWidthTwoBar / Game.shimmerTypes['golden'].maxTime) + 'px'; l('CMTimerBarGCBar').textContent = Math.ceil(Math.min(Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].minTime, Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) / Game.fps); l('CMTimerBarGCTime').textContent = Math.ceil((Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) / Game.fps); numberOfTimers++; @@ -1677,9 +1680,9 @@ CM.Disp.UpdateTimerBar = function() { // Regulates visibility of Reindeer timer if (Game.season == 'christmas' && Game.shimmerTypes['reindeer'].spawned == 0) { CM.Disp.TimerBars['CMTimerBarRen'].style.display = ''; - l('CMTimerBarRenMinBar').style.width = Math.round(Math.max(0, Game.shimmerTypes['reindeer'].minTime - Game.shimmerTypes['reindeer'].time) * maxWidth / Game.shimmerTypes['reindeer'].maxTime) + 'px'; + l('CMTimerBarRenMinBar').style.width = Math.round(Math.max(0, Game.shimmerTypes['reindeer'].minTime - Game.shimmerTypes['reindeer'].time) * maxWidthTwoBar / Game.shimmerTypes['reindeer'].maxTime) + 'px'; l('CMTimerBarRenMinBar').textContent = Math.ceil((Game.shimmerTypes['reindeer'].minTime - Game.shimmerTypes['reindeer'].time)/ Game.fps) - l('CMTimerBarRenBar').style.width = Math.round(Math.min(Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].minTime, Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) * maxWidth / Game.shimmerTypes['reindeer'].maxTime) + 'px'; + l('CMTimerBarRenBar').style.width = Math.round(Math.min(Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].minTime, Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) * maxWidthTwoBar / Game.shimmerTypes['reindeer'].maxTime) + 'px'; l('CMTimerBarRenBar').textContent = Math.ceil(Math.min(Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].minTime, Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) / Game.fps); l('CMTimerBarRenTime').textContent = Math.ceil((Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) / Game.fps); numberOfTimers++; @@ -1704,7 +1707,7 @@ CM.Disp.UpdateTimerBar = function() { } else classColor = CM.Disp.colorPurple; timer.lastChild.children[1].className = CM.Disp.colorBackPre + classColor; - timer.lastChild.children[1].style.width = Math.round(Game.buffs[i].time * maxWidth / Game.buffs[i].maxTime) + 'px'; + timer.lastChild.children[1].style.width = Math.round(Game.buffs[i].time *(maxWidthOneBar - Math.ceil(Game.buffs[i].time / Game.fps).toString().length * 8) / Game.buffs[i].maxTime) + 'px'; timer.lastChild.children[2].textContent = Math.ceil(Game.buffs[i].time / Game.fps); numberOfTimers++; CM.Disp.BuffTimerBars[Game.buffs[i].name] = timer diff --git a/src/Disp.js b/src/Disp.js index 02dc403..045c4a7 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -494,6 +494,7 @@ CM.Disp.TimerBarCreateBar = function(id, name, bars) { var type = document.createElement('span'); type.style.display = 'inline-block'; type.style.textAlign = 'right'; + type.style.fontSize = "10px"; type.style.width = '108px'; type.style.marginRight = '5px'; type.style.verticalAlign = 'text-top'; @@ -534,14 +535,16 @@ CM.Disp.TimerBarCreateBar = function(id, name, bars) { */ CM.Disp.UpdateTimerBar = function() { if (CM.Options.TimerBar == 1) { - // label width: 113, timer width: 26, div margin: 20 - var maxWidth = CM.Disp.TimerBar.offsetWidth - 159; + // label width: 113, timer width: 30, div margin: 20 + var maxWidthTwoBar = CM.Disp.TimerBar.offsetWidth - 163; + // label width: 113, div margin: 20, calculate timer width at runtime + var maxWidthOneBar = CM.Disp.TimerBar.offsetWidth - 133; var numberOfTimers = 0; // Regulates visibility of Golden Cookie timer if (Game.shimmerTypes['golden'].spawned == 0 && !Game.Has('Golden switch [off]')) { CM.Disp.TimerBars['CMTimerBarGC'].style.display = ''; - l('CMTimerBarGCMinBar').style.width = Math.round(Math.max(0, Game.shimmerTypes['golden'].minTime - Game.shimmerTypes['golden'].time) * maxWidth / Game.shimmerTypes['golden'].maxTime) + 'px'; + l('CMTimerBarGCMinBar').style.width = Math.round(Math.max(0, Game.shimmerTypes['golden'].minTime - Game.shimmerTypes['golden'].time) * maxWidthTwoBar / Game.shimmerTypes['golden'].maxTime) + 'px'; l('CMTimerBarGCMinBar').textContent = Math.ceil((Game.shimmerTypes['golden'].minTime - Game.shimmerTypes['golden'].time)/ Game.fps) if (Game.shimmerTypes['golden'].minTime == Game.shimmerTypes['golden'].maxTime) { l('CMTimerBarGCMinBar').style.borderTopRightRadius = '10px'; @@ -551,7 +554,7 @@ CM.Disp.UpdateTimerBar = function() { l('CMTimerBarGCMinBar').style.borderTopRightRadius = ''; l('CMTimerBarGCMinBar').style.borderBottomRightRadius = ''; } - l('CMTimerBarGCBar').style.width = Math.round(Math.min(Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].minTime, Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) * maxWidth / Game.shimmerTypes['golden'].maxTime) + 'px'; + l('CMTimerBarGCBar').style.width = Math.round(Math.min(Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].minTime, Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) * maxWidthTwoBar / Game.shimmerTypes['golden'].maxTime) + 'px'; l('CMTimerBarGCBar').textContent = Math.ceil(Math.min(Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].minTime, Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) / Game.fps); l('CMTimerBarGCTime').textContent = Math.ceil((Game.shimmerTypes['golden'].maxTime - Game.shimmerTypes['golden'].time) / Game.fps); numberOfTimers++; @@ -561,9 +564,9 @@ CM.Disp.UpdateTimerBar = function() { // Regulates visibility of Reindeer timer if (Game.season == 'christmas' && Game.shimmerTypes['reindeer'].spawned == 0) { CM.Disp.TimerBars['CMTimerBarRen'].style.display = ''; - l('CMTimerBarRenMinBar').style.width = Math.round(Math.max(0, Game.shimmerTypes['reindeer'].minTime - Game.shimmerTypes['reindeer'].time) * maxWidth / Game.shimmerTypes['reindeer'].maxTime) + 'px'; + l('CMTimerBarRenMinBar').style.width = Math.round(Math.max(0, Game.shimmerTypes['reindeer'].minTime - Game.shimmerTypes['reindeer'].time) * maxWidthTwoBar / Game.shimmerTypes['reindeer'].maxTime) + 'px'; l('CMTimerBarRenMinBar').textContent = Math.ceil((Game.shimmerTypes['reindeer'].minTime - Game.shimmerTypes['reindeer'].time)/ Game.fps) - l('CMTimerBarRenBar').style.width = Math.round(Math.min(Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].minTime, Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) * maxWidth / Game.shimmerTypes['reindeer'].maxTime) + 'px'; + l('CMTimerBarRenBar').style.width = Math.round(Math.min(Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].minTime, Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) * maxWidthTwoBar / Game.shimmerTypes['reindeer'].maxTime) + 'px'; l('CMTimerBarRenBar').textContent = Math.ceil(Math.min(Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].minTime, Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) / Game.fps); l('CMTimerBarRenTime').textContent = Math.ceil((Game.shimmerTypes['reindeer'].maxTime - Game.shimmerTypes['reindeer'].time) / Game.fps); numberOfTimers++; @@ -588,7 +591,7 @@ CM.Disp.UpdateTimerBar = function() { } else classColor = CM.Disp.colorPurple; timer.lastChild.children[1].className = CM.Disp.colorBackPre + classColor; - timer.lastChild.children[1].style.width = Math.round(Game.buffs[i].time * maxWidth / Game.buffs[i].maxTime) + 'px'; + timer.lastChild.children[1].style.width = Math.round(Game.buffs[i].time *(maxWidthOneBar - Math.ceil(Game.buffs[i].time / Game.fps).toString().length * 8) / Game.buffs[i].maxTime) + 'px'; timer.lastChild.children[2].textContent = Math.ceil(Game.buffs[i].time / Game.fps); numberOfTimers++; CM.Disp.BuffTimerBars[Game.buffs[i].name] = timer From b6cd262ff2674f0e5187c081fc5051f378492d9f Mon Sep 17 00:00:00 2001 From: Daniel van Noord Date: Sun, 27 Dec 2020 13:27:44 +0100 Subject: [PATCH 3/3] Fixed (#388) and add percentage overlay to timers --- CookieMonster.js | 21 ++++++++------------- src/Disp.js | 21 ++++++++------------- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/CookieMonster.js b/CookieMonster.js index cab285e..c8215fd 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -1558,7 +1558,7 @@ CM.Disp.CreateTimerBar = function() { CM.Disp.TimerBar.id = 'CMTimerBar'; CM.Disp.TimerBar.style.position = 'absolute'; CM.Disp.TimerBar.style.display = 'none'; - CM.Disp.TimerBar.style.height = '48px'; + CM.Disp.TimerBar.style.height = '30px'; CM.Disp.TimerBar.style.fontSize = '10px'; CM.Disp.TimerBar.style.fontWeight = 'bold'; CM.Disp.TimerBar.style.backgroundColor = 'black'; @@ -1707,7 +1707,8 @@ CM.Disp.UpdateTimerBar = function() { } else classColor = CM.Disp.colorPurple; timer.lastChild.children[1].className = CM.Disp.colorBackPre + classColor; - timer.lastChild.children[1].style.width = Math.round(Game.buffs[i].time *(maxWidthOneBar - Math.ceil(Game.buffs[i].time / Game.fps).toString().length * 8) / Game.buffs[i].maxTime) + 'px'; + timer.lastChild.children[1].textContent = Math.round(100 * (Game.buffs[i].time / Game.buffs[i].maxTime)) + "%"; + timer.lastChild.children[1].style.width = Math.round(Game.buffs[i].time * (maxWidthOneBar - Math.ceil(Game.buffs[i].time / Game.fps).toString().length * 8) / Game.buffs[i].maxTime) + 'px'; timer.lastChild.children[2].textContent = Math.ceil(Game.buffs[i].time / Game.fps); numberOfTimers++; CM.Disp.BuffTimerBars[Game.buffs[i].name] = timer @@ -1718,13 +1719,7 @@ CM.Disp.UpdateTimerBar = function() { } if (numberOfTimers != 0) { - var height = 48 / numberOfTimers; - for (var i in CM.Disp.TimerBars) { - CM.Disp.TimerBars[i].style.height = height + 'px'; - } - for (var i in CM.Disp.BuffTimerBars) { - CM.Disp.BuffTimerBars[i].style.height = height + 'px'; - } + CM.Disp.TimerBar.style.height = numberOfTimers * 12 + 2 + 'px'; } } } @@ -1766,22 +1761,22 @@ CM.Disp.ToggleTimerBarPos = function() { */ CM.Disp.UpdateBotTimerBarPosition = function() { if (CM.Options.BotBar == 1 && CM.Options.TimerBar == 1 && CM.Options.TimerBarPos == 1) { - CM.Disp.BotBar.style.bottom = '48px'; - l('game').style.bottom = '118px'; + CM.Disp.BotBar.style.bottom = CM.Disp.TimerBar.style.height; + l('game').style.bottom = Number(CM.Disp.TimerBar.style.height.replace("px","")) + 70 + "px"; } else if (CM.Options.BotBar == 1) { CM.Disp.BotBar.style.bottom = '0px'; l('game').style.bottom = '70px'; } else if (CM.Options.TimerBar == 1 && CM.Options.TimerBarPos == 1) { - l('game').style.bottom = '48px'; + l('game').style.bottom = CM.Disp.TimerBar.style.height; } else { // No bars l('game').style.bottom = '0px'; } if (CM.Options.TimerBar == 1 && CM.Options.TimerBarPos == 0) { - l('sectionLeft').style.top = '48px'; + l('sectionLeft').style.top = CM.Disp.TimerBar.style.height; } else { l('sectionLeft').style.top = ''; diff --git a/src/Disp.js b/src/Disp.js index 045c4a7..52f5eeb 100644 --- a/src/Disp.js +++ b/src/Disp.js @@ -442,7 +442,7 @@ CM.Disp.CreateTimerBar = function() { CM.Disp.TimerBar.id = 'CMTimerBar'; CM.Disp.TimerBar.style.position = 'absolute'; CM.Disp.TimerBar.style.display = 'none'; - CM.Disp.TimerBar.style.height = '48px'; + CM.Disp.TimerBar.style.height = '30px'; CM.Disp.TimerBar.style.fontSize = '10px'; CM.Disp.TimerBar.style.fontWeight = 'bold'; CM.Disp.TimerBar.style.backgroundColor = 'black'; @@ -591,7 +591,8 @@ CM.Disp.UpdateTimerBar = function() { } else classColor = CM.Disp.colorPurple; timer.lastChild.children[1].className = CM.Disp.colorBackPre + classColor; - timer.lastChild.children[1].style.width = Math.round(Game.buffs[i].time *(maxWidthOneBar - Math.ceil(Game.buffs[i].time / Game.fps).toString().length * 8) / Game.buffs[i].maxTime) + 'px'; + timer.lastChild.children[1].textContent = Math.round(100 * (Game.buffs[i].time / Game.buffs[i].maxTime)) + "%"; + timer.lastChild.children[1].style.width = Math.round(Game.buffs[i].time * (maxWidthOneBar - Math.ceil(Game.buffs[i].time / Game.fps).toString().length * 8) / Game.buffs[i].maxTime) + 'px'; timer.lastChild.children[2].textContent = Math.ceil(Game.buffs[i].time / Game.fps); numberOfTimers++; CM.Disp.BuffTimerBars[Game.buffs[i].name] = timer @@ -602,13 +603,7 @@ CM.Disp.UpdateTimerBar = function() { } if (numberOfTimers != 0) { - var height = 48 / numberOfTimers; - for (var i in CM.Disp.TimerBars) { - CM.Disp.TimerBars[i].style.height = height + 'px'; - } - for (var i in CM.Disp.BuffTimerBars) { - CM.Disp.BuffTimerBars[i].style.height = height + 'px'; - } + CM.Disp.TimerBar.style.height = numberOfTimers * 12 + 2 + 'px'; } } } @@ -650,22 +645,22 @@ CM.Disp.ToggleTimerBarPos = function() { */ CM.Disp.UpdateBotTimerBarPosition = function() { if (CM.Options.BotBar == 1 && CM.Options.TimerBar == 1 && CM.Options.TimerBarPos == 1) { - CM.Disp.BotBar.style.bottom = '48px'; - l('game').style.bottom = '118px'; + CM.Disp.BotBar.style.bottom = CM.Disp.TimerBar.style.height; + l('game').style.bottom = Number(CM.Disp.TimerBar.style.height.replace("px","")) + 70 + "px"; } else if (CM.Options.BotBar == 1) { CM.Disp.BotBar.style.bottom = '0px'; l('game').style.bottom = '70px'; } else if (CM.Options.TimerBar == 1 && CM.Options.TimerBarPos == 1) { - l('game').style.bottom = '48px'; + l('game').style.bottom = CM.Disp.TimerBar.style.height; } else { // No bars l('game').style.bottom = '0px'; } if (CM.Options.TimerBar == 1 && CM.Options.TimerBarPos == 0) { - l('sectionLeft').style.top = '48px'; + l('sectionLeft').style.top = CM.Disp.TimerBar.style.height; } else { l('sectionLeft').style.top = '';