I'm currently looking for ideas on how to split statusbars into segments (graphically only).
My current idea is as follows...
Statusbar before:
Statusbar after:
Code idea for a power bar as an example:
Lua Code:
local function CreateSplit(self,i)
local split = self:CreateTexture()
split:SetTexture(abc)
split:SetSize(6,self:GetHeight())
local layer, sublayer = self:GetStatusBarTexture():GetDrawLayer()
split:SetDrawLayer(layer,sublayer+1)
self.splits[i] = split
return split
end
local function UpdateSplits(self,maxSegments)
if not self.useSplits then return end
if self.maxSegments == maxSegments then return end
self.maxSegments = maxSegments
if maxSegements < 2 then return end
if maxSemgents > 8 then maxSegments = 5 end --anything above 8 will be split into 5 parts of 20%.
if not self.splits then self.splits = {} end
local p = self:GetWidth()/maxSegments
for i=1,7 do
if i>maxSemgents-1 then
if self.splits[i] and self.splits[i]:IsShown() then
self.splits[i]:Hide()
end
else
local split = self.splits[i] or CreateSplit(self,i)
split:SetPoint("CENTER",self,"LEFT",p*i,0)
if not split:IsShown() then split:Show() end
end
end
end
local function UpdatePower(self, event, unit, powerType)
if self.unit ~= unit then return end
local ppmax = UnitPowerMax(unit, powerType)
UpdateSplits(self,ppmax)
...
end
What do you think about that?
Would you do it differently? Why?