Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 63 additions & 7 deletions Bars/Abstract/Bar.lua
Original file line number Diff line number Diff line change
Expand Up @@ -694,10 +694,17 @@ function BarMixin:ApplyFillDirectionSettings(layoutName, data)
data = data or self:GetData(layoutName)
if not data then return end

if data.fillDirection == "Top to Bottom" or data.fillDirection == "Bottom to Top" then
self.StatusBar:SetOrientation("VERTICAL")
local defaults = self.defaults or {}
local fragmentedResourceLayout = data.fragmentedResourceLayout or defaults.fragmentedResourceLayout

if fragmentedResourceLayout == "Auto" then
if data.fillDirection == "Top to Bottom" or data.fillDirection == "Bottom to Top" then
self.StatusBar:SetOrientation("VERTICAL")
else
self.StatusBar:SetOrientation("HORIZONTAL")
end
else
self.StatusBar:SetOrientation("HORIZONTAL")
self.StatusBar:SetOrientation(string.upper(fragmentedResourceLayout))
end

if data.fillDirection == "Right to Left" or data.fillDirection == "Top to Bottom" then
Expand All @@ -707,6 +714,7 @@ function BarMixin:ApplyFillDirectionSettings(layoutName, data)
end

for _, fragmentedPowerBar in ipairs(self.FragmentedPowerBars) do
-- Fragment orientation is always based on fillDirection (how each fragment fills)
if data.fillDirection == "Top to Bottom" or data.fillDirection == "Bottom to Top" then
fragmentedPowerBar:SetOrientation("VERTICAL")
else
Expand Down Expand Up @@ -1008,7 +1016,8 @@ function BarMixin:CreateFragmentedPowerBars(layoutName, data)
local resource = self:GetResource()
if not resource then return end

local maxPower = resource == "MAELSTROM_WEAPON" and 5 or UnitPowerMax("player", resource) or 0
local maxPower, _ = self:GetResourceValue(resource)
if not maxPower or maxPower <= 0 then return end

for i = 1, maxPower or 0 do
if not self.FragmentedPowerBars[i] then
Expand Down Expand Up @@ -1042,10 +1051,13 @@ function BarMixin:UpdateFragmentedPowerDisplay(layoutName, data, maxPower)

local resource = self:GetResource()
if not resource then return end
-- Use passed maxPower to avoid redundant UnitPowerMax call
maxPower = maxPower or (resource == "MAELSTROM_WEAPON" and 5 or UnitPowerMax("player", resource))
if maxPower <= 0 then return end
-- Use passed maxPower to avoid redundant GetResourceValue call
if not maxPower then
maxPower, _ = self:GetResourceValue(resource)
end
if not maxPower or maxPower <= 0 then return end

local buildVersion = select(4, GetBuildInfo())
local barWidth = self.Frame:GetWidth()
local barHeight = self.Frame:GetHeight()
local fragmentedBarWidth = barWidth / maxPower
Expand Down Expand Up @@ -1365,6 +1377,50 @@ function BarMixin:UpdateFragmentedPowerDisplay(layoutName, data, maxPower)
mwFrame:Show()
end
end
elseif resource == Enum.PowerType.ArcaneCharges or resource == Enum.PowerType.Chi or resource == Enum.PowerType.HolyPower or resource == Enum.PowerType.SoulShards or resource == "TIP_OF_THE_SPEAR" or resource == "SOUL_FRAGMENTS_VENGEANCE" or resource == "WHIRLWIND" then
local _, current = self:GetResourceValue(resource)

local displayOrder = {}
for i = 1, maxPower do
table.insert(displayOrder, i)
end

if data.fillDirection == "Right to Left" or data.fillDirection == "Top to Bottom" then
for i = 1, math.floor(#displayOrder / 2) do
displayOrder[i], displayOrder[#displayOrder - i + 1] = displayOrder[#displayOrder - i + 1], displayOrder[i]
end
end

self.StatusBar:SetAlpha(0)
for pos = 1, #displayOrder do
local idx = displayOrder[pos]
local frame = self.FragmentedPowerBars[idx]
local text = self.FragmentedPowerBarTexts[idx]

if frame then
frame:ClearAllPoints()
if self.StatusBar:GetOrientation() == "VERTICAL" then
frame:SetSize(barWidth, fragmentedBarHeight)
frame:SetPoint("BOTTOM", self.Frame, "BOTTOM", 0, (pos - 1) * fragmentedBarHeight)
else
frame:SetSize(fragmentedBarWidth, barHeight)
frame:SetPoint("LEFT", self.Frame, "LEFT", (pos - 1) * fragmentedBarWidth, 0)
end

frame:SetMinMaxValues(0, 1)

if idx <= current then
frame:SetValue(1, data.smoothProgress and buildVersion >= 120000 and Enum.StatusBarInterpolation.ExponentialEaseOut or nil)
frame:SetStatusBarColor(color.r, color.g, color.b, color.a or 1)
else
frame:SetValue(0, data.smoothProgress and buildVersion >= 120000 and Enum.StatusBarInterpolation.ExponentialEaseOut or nil)
frame:SetStatusBarColor(color.r * 0.5, color.g * 0.5, color.b * 0.5, color.a or 1)
end
text:SetText("")

frame:Show()
end
end
end

self:ApplyFontSettings(layoutName)
Expand Down
14 changes: 14 additions & 0 deletions Constants.lua
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ addonTable.commonDefaults = {
widthMode = "Manual",
height = 15,
fillDirection = "Left to Right",
fragmentedResourceLayout = "Auto",
smoothProgress = true,
fasterUpdates = true,
showText = true,
Expand Down Expand Up @@ -231,6 +232,12 @@ addonTable.availableFillDirections = {
{ text = "Bottom to Top" },
}

addonTable.availableFragmentedResourceLayouts = {
{ text = "Auto"},
{ text = "Vertical"},
{ text = "Horizontal"},
}

addonTable.availableOutlineStyles = {
{ text = "NONE" },
{ text = "OUTLINE" },
Expand Down Expand Up @@ -336,8 +343,15 @@ addonTable.tickedPowerTypes = {

-- Power types that are fragmented (multiple independent segments)
addonTable.fragmentedPowerTypes = {
[Enum.PowerType.ArcaneCharges] = true,
[Enum.PowerType.Chi] = true,
[Enum.PowerType.ComboPoints] = true,
[Enum.PowerType.Essence] = true,
[Enum.PowerType.HolyPower] = true,
[Enum.PowerType.Runes] = true,
[Enum.PowerType.SoulShards] = true,
["MAELSTROM_WEAPON"] = true,
["TIP_OF_THE_SPEAR"] = true,
["SOUL_FRAGMENTS_VENGEANCE"] = true,
["WHIRLWIND"] = true,
}
20 changes: 19 additions & 1 deletion Helpers/LEMSettingsLoader.lua
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,24 @@ local function BuildLemSettings(bar, defaults)
{
parentId = L["CATEGORY_BAR_SETTINGS"],
order = 302,
name = "Fragmented Resource Layout",
kind = LEM.SettingType.Dropdown,
default = defaults.fragmentedResourceLayout,
useOldStyle = true,
values = addonTable.availableFragmentedResourceLayouts,
get = function(layoutName)
return (SenseiClassResourceBarDB[config.dbName][layoutName] and SenseiClassResourceBarDB[config.dbName][layoutName].fragmentedResourceLayout) or defaults.fragmentedResourceLayout
end,
set = function(layoutName, value)
SenseiClassResourceBarDB[config.dbName][layoutName] = SenseiClassResourceBarDB[config.dbName][layoutName] or CopyTable(defaults)
SenseiClassResourceBarDB[config.dbName][layoutName].fragmentedResourceLayout = value
bar:ApplyLayout(layoutName)
end,
tooltip = "Applies to most secondary resources.",
},
{
parentId = L["CATEGORY_BAR_SETTINGS"],
order = 303,
name = L["FASTER_UPDATES"],
kind = LEM.SettingType.Checkbox,
default = defaults.fasterUpdates,
Expand All @@ -359,7 +377,7 @@ local function BuildLemSettings(bar, defaults)
},
{
parentId = L["CATEGORY_BAR_SETTINGS"],
order = 303,
order = 304,
name = L["SMOOTH_PROGRESS"],
kind = LEM.SettingType.Checkbox,
default = defaults.smoothProgress,
Expand Down