Skip to content

Commit

Permalink
Era: castbar add option 'showRank' (#223)
Browse files Browse the repository at this point in the history
* Era: castbar add option 'showRank'
* Update Castbar.lua
  • Loading branch information
Karl-HeinzSchneider authored Aug 16, 2024
1 parent 2072c15 commit e51aa16
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
30 changes: 24 additions & 6 deletions Mixin/Castbar.mixin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ function DragonFlightUICastbarMixin:OnLoad(unit)
self:SetCastTimeTextShown(true)
self.showTradeSkills = true
self.showTicks = false
self.showRank = false
end

function DragonFlightUICastbarMixin:OnShow()
Expand Down Expand Up @@ -53,7 +54,12 @@ function DragonFlightUICastbarMixin:OnEvent(event, ...)
if (arg1 ~= unit) then return; end

if (event == "UNIT_SPELLCAST_START") then
local name, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible = UnitCastingInfo(unit);
local name, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible, spellId =
UnitCastingInfo(unit);
local subText = GetSpellSubtext(spellId)
if not self.showRank then subText = '' end
if subText ~= '' then subText = ' (' .. subText .. ')' end

if (not name or (not self.showTradeSkills and isTradeSkill)) then
-- local desiredShowFalse = false;
-- self:UpdateShownState(desiredShowFalse);
Expand All @@ -73,8 +79,8 @@ function DragonFlightUICastbarMixin:OnEvent(event, ...)
self:SetValue(self.value);
-- self:UpdateCastTimeText();
if (self.Text) then
self.Text:SetText(text);
self.TextCompact:SetText(text)
self.Text:SetText(text .. subText);
self.TextCompact:SetText(text .. subText)
end
if (self.Icon) then
-- @TODO
Expand All @@ -96,8 +102,12 @@ function DragonFlightUICastbarMixin:OnEvent(event, ...)
self:HandleInterruptOrSpellFailed(false, event, ...);
elseif (event == "UNIT_SPELLCAST_DELAYED") then
if (self:IsShown()) then
local name, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible =
local name, text, texture, startTime, endTime, isTradeSkill, castID, notInterruptible, spellId =
UnitCastingInfo(unit);
local subText = GetSpellSubtext(spellId)
if not self.showRank then subText = '' end
if subText ~= '' then subText = ' (' .. subText .. ')' end

if (not name or (not self.showTradeSkills and isTradeSkill)) then
-- if there is no name, there is no bar
local desiredShowFalse = false;
Expand Down Expand Up @@ -125,6 +135,10 @@ function DragonFlightUICastbarMixin:OnEvent(event, ...)
end
elseif event == "UNIT_SPELLCAST_CHANNEL_START" then
local name, text, texture, startTime, endTime, isTradeSkill, notInterruptible, spellID = UnitChannelInfo(unit);
local subText = GetSpellSubtext(spellId)
if not self.showRank then subText = '' end
if subText ~= '' then subText = ' (' .. subText .. ')' end

if (not name or (not self.showTradeSkills and isTradeSkill)) then
-- if there is no name, there is no bar
local desiredShowFalse = false;
Expand All @@ -147,8 +161,8 @@ function DragonFlightUICastbarMixin:OnEvent(event, ...)
self:SetValue(self.value);
self:UpdateCastTimeText();
if (self.Text) then
self.Text:SetText(text);
self.TextCompact:SetText(text)
self.Text:SetText(text .. subText);
self.TextCompact:SetText(text .. subText)
end
if (self.Icon) then self.Icon:SetTexture(texture); end

Expand Down Expand Up @@ -554,3 +568,7 @@ end
function DragonFlightUICastbarMixin:SetShowTicks(showTicks)
self.showTicks = showTicks
end

function DragonFlightUICastbarMixin:SetShowRank(showRank)
self.showRank = showRank
end
11 changes: 9 additions & 2 deletions Modules/Castbar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ local defaults = {
castTimeMaxEnabled = true,
compactLayout = true,
showIcon = false,
showTicks = false
showTicks = false,
showRank = false
}
}
Module:SetDefaults(defaults)
Expand Down Expand Up @@ -120,10 +121,15 @@ local options = {
compactLayout = {type = 'toggle', name = 'Compact Layout', order = 106.1},
showIcon = {type = 'toggle', name = 'Show Icon', order = 106.2},
showTicks = {type = 'toggle', name = 'Show Ticks', order = 107.1}

}
}

if DF.Era then
local moreOptions = {showRank = {type = 'toggle', name = 'Show Rank', order = 108, new = true}}

for k, v in pairs(moreOptions) do options.args[k] = v end
end

function Module:OnInitialize()
DF:Debug(self, 'Module ' .. mName .. ' OnInitialize()')
self.db = DF.db:RegisterNamespace(mName, defaults)
Expand Down Expand Up @@ -180,6 +186,7 @@ function Module:ApplySettings()
Module.Castbar:SetCompactLayout(db.compactLayout)
Module.Castbar:SetShowTicks(db.showTicks)
Module.Castbar:SetIconShown(db.showIcon)
Module.Castbar:SetShowRank(db.showRank)
Module.Castbar.Icon:SetSize(db.sizeY, db.sizeY)
end

Expand Down

0 comments on commit e51aa16

Please sign in to comment.