huge bar fix#257
Conversation
remove whitespace
Zidras
left a comment
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
This is wrong indentation. Revert to what it was before, with 1 line break in between functions
| -- 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 |
There was a problem hiding this comment.
This call is inside SetTimer. I don't understand the need for this code nor what it tries to fix
| -- 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) |
There was a problem hiding this comment.
What is this new element you're introducing .elapsed ? I don't see it being used anywhere
|
|
||
| function barPrototype:SetColor(color) | ||
| -- Fix to allow colors not require the table keys | ||
| if color[1] and not color.r then |
| varianceTex:SetWidth(varianceWidth) | ||
| local varianceWidth | ||
| local isEnlarged = self.enlarged and not self.paused | ||
| local barOptions = DBT.Options |
There was a problem hiding this comment.
You cached DBT.Options but only used it once.
| end | ||
|
|
||
| -- change SetPoints based on fillUpBars | ||
| varianceTex:SetWidth(varianceWidth) |
There was a problem hiding this comment.
Removed by accident. Only wanted to remove some comments from myself
| end | ||
| end | ||
| timer:SetText(stringFromTimer(timerCorrectedNegative)) | ||
| if fillUpBars then |
| end | ||
| timer:SetText(stringFromTimer(timerCorrectedNegative)) | ||
| if fillUpBars then | ||
| if currentStyle == "NoAnim" and timerValue <= enlargeTime and not enlargeHack then |
| 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 |
There was a problem hiding this comment.
IIRC, this was intended. The bar starts enlarging at the lowest possible time, not the highest possible.
|
@Ayro97 I've noticed a bug with your implementation, when Fill Up is disabled, where the bar does not enlarge at the defined time. |
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:Updateto 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 thebar:SetValue()calculation from the originaltotaltimeValuetoenlargeTime.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:SetVariancefunction. 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 fromself.totalTimetoenlargeTime.