Skip to content

Conversation

Ayro97
Copy link

@Ayro97 Ayro97 commented Jun 9, 2025

fix for #252

3 key changes:

1. Correcting When the Bar Becomes Huge
The Problem: Bars with variance were becoming huge too early. The code was checking the displayed text (time until variance starts) against the enlargeTime, not the bar's actual timer.
The Solution: Change the enlargement condition in barPrototype:Update to always use the bar's actual timer (timerValue).

2. Correcting the Huge Bar's Fill Level
The Problem: The huge bar's visual fullness was still a percentage of its original total duration, making it look half-empty when it should have been starting a new countdown.
The Solution: In barPrototype:Update, for huge "NoAnim" bars, changed the denominator in the bar:SetValue() calculation from the original totaltimeValue to enlargeTime.

3. Correcting the Huge Bar's Variance Overlay
The Problem: The shaded variance overlay was too small on huge bars because its width was also being calculated as a percentage of the original, longer duration.
The Solution: Modified the barPrototype:SetVariance function. Added a check to see if the bar was huge and using the "NoAnim" style. If so, change the denominator for the overlay's width calculation from self.totalTime to enlargeTime.

Copy link
Owner

@Zidras Zidras left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reviewed the PR purely on submitted code, I haven't tested anything, so I might not be grasping your intentions.
In any case, it seems there are extra code unrelated to the initial bug report. Not only that, some even seem wrong.

timer = varianceMinTimer or varianceMaxTimer -- varianceMaxTimer here could be just normal number timer, so check for varianceMinTimer, which only exists if it's a variant timer
end
if not timer or (self.numBars >= 15 and not isDummy) then
function DBT:CreateBar(timer, id, icon, huge, small, color, isDummy, colorType, inlineIcon, keep, fade, countdown, countdownMax)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong indentation. Revert to what it was before, with 1 line break in between functions

Comment on lines 360 to 362
-- FIX: Reset totalTime BEFORE SetTimer to ensure proper variance handling
newBar.totalTime = timer
newBar:SetTimer(timer) -- This can kill the timer and the timer methods don't like dead timers
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This call is inside SetTimer. I don't understand the need for this code nor what it tries to fix

Comment on lines 367 to 370
-- FIX: Ensure elapsed time is properly reset for variance timers
-- Reset elapsed before setting it to 0 to prevent percentage calculation issues
newBar.elapsed = 0
newBar:SetElapsed(0)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this new element you're introducing .elapsed ? I don't see it being used anywhere

@@ -829,7 +833,6 @@ function barPrototype:SetIcon(icon)
end

function barPrototype:SetColor(color)
-- Fix to allow colors not require the table keys
if color[1] and not color.r then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this comment?

varianceTex:SetWidth(varianceWidth)
local varianceWidth
local isEnlarged = self.enlarged and not self.paused
local barOptions = DBT.Options
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You cached DBT.Options but only used it once.


-- change SetPoints based on fillUpBars
varianceTex:SetWidth(varianceWidth)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove the comment?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed by accident. Only wanted to remove some comments from myself

end
end
timer:SetText(stringFromTimer(timerCorrectedNegative))
if fillUpBars then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong indentation

end
timer:SetText(stringFromTimer(timerCorrectedNegative))
if fillUpBars then
if currentStyle == "NoAnim" and timerValue <= enlargeTime and not enlargeHack then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove comments?

@@ -1073,7 +1085,7 @@ function barPrototype:Update(elapsed)
self:ApplyStyle()
DBT:UpdateBars(true)
end
if not paused and ((barOptions.VarianceEnabled and timerLowestValueFromVariance or timerValue) <= enlargeTime) and not self.small and not isEnlarged and isMoving ~= "enlarge" and enlargeEnabled then
if not paused and timerValue <= enlargeTime and not self.small and not isEnlarged and isMoving ~= "enlarge" and enlargeEnabled then
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC, this was intended. The bar starts enlarging at the lowest possible time, not the highest possible.

@Zidras
Copy link
Owner

Zidras commented Aug 18, 2025

@Ayro97 I've noticed a bug with your implementation, when Fill Up is disabled, where the bar does not enlarge at the defined time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants