Skip to content

Commit

Permalink
[Feature] Implement "Remaining & Max" timer format for Cast Bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Krealle committed Nov 8, 2024
1 parent 05d3f2b commit b05964e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 4 deletions.
1 change: 1 addition & 0 deletions Data/Constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ const.COLORS = {
const.CastBarTimerFormat = {
NORMAL = "normal",
REMAINING = "remaining",
REMAINING_AND_MAX = "remaining-and-max",
DURATION = "duration",
DURATION_AND_MAX = "duration-and-max",
HIDDEN = "hidden",
Expand Down
1 change: 1 addition & 0 deletions Locales/enUS.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ L["normal"] = "Normal"
L["remaining"] = "Remaining"
L["duration"] = "Duration"
L["duration-and-max"] = "Duration & Max"
L["remaining-and-max"] = "Remaining & Max"
L.hidden = "Hidden"
L.ShowSpell = "Show Spell"
L.Empower = "Empower"
Expand Down
3 changes: 2 additions & 1 deletion Menu/Builder.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1424,10 +1424,11 @@ function Builder:CreateCastBarTimerFontOptions(parent, widgetName)
const.CastBarTimerFormat.HIDDEN,
const.CastBarTimerFormat.NORMAL,
const.CastBarTimerFormat.REMAINING,
const.CastBarTimerFormat.REMAINING_AND_MAX,
const.CastBarTimerFormat.DURATION,
const.CastBarTimerFormat.DURATION_AND_MAX,
}
f.timerFormat = self:CreateDropdown(f, widgetName, L.TimerFormat, nil,
f.timerFormat = self:CreateDropdown(f, widgetName, L.TimerFormat, 140,
items, const.OPTION_KIND.TIMER_FORMAT)
self:AnchorBelow(f.timerFormat, f.fontOptions.styleDropdown)

Expand Down
20 changes: 17 additions & 3 deletions Widgets/Bars/CastBar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -401,15 +401,29 @@ local function onUpdate(self, elapsed)
if self.empowering then
self.timerText:SetFormattedText("%d", self.CurStage)
elseif timerFormat == const.CastBarTimerFormat.DURATION then
self.timerText:SetFormattedText("%.1f", self.duration)
elseif timerFormat == const.CastBarTimerFormat.REMAINING then
self.timerText:SetFormattedText("%.1f", (self.max - self.duration))
local dur = self.duration
if self.channeling then
dur = (self.max - self.duration)
end
self.timerText:SetFormattedText("%.1f", dur)
elseif timerFormat == const.CastBarTimerFormat.DURATION_AND_MAX then
local dur = self.duration
if self.channeling then
dur = (self.max - self.duration)
end
self.timerText:SetFormattedText("%.1f / %.1f", dur, self.max)
elseif timerFormat == const.CastBarTimerFormat.REMAINING then
local dur = self.duration
if not self.channeling then
dur = (self.max - self.duration)
end
self.timerText:SetFormattedText("%.1f", dur)
elseif timerFormat == const.CastBarTimerFormat.REMAINING_AND_MAX then
local dur = self.duration
if not self.channeling then
dur = (self.max - self.duration)
end
self.timerText:SetFormattedText("%.1f / %.1f", dur, self.max)
elseif self.channeling then
self.timerText:SetFormattedText("%.1f", self.duration)
else
Expand Down

0 comments on commit b05964e

Please sign in to comment.