before todays patch the follow script would just show the current HP 845k for exp and not the total / current
broke after the patch today. any one have a fix?
hooksecurefunc("TextStatusBar_UpdateTextStringWithValues",function(statusFrame, textString, value, valueMin, valueMax)
if valueMax > 0 then
textString:SetText(tostring(AbbreviateLargeNumbers(value)).."");
else
textString:SetText("0");
end
if(statusFrame.LeftText and statusFrame.RightText) then
statusFrame.LeftText:Hide();
statusFrame.RightText:Hide();
textString:Show();
end
end)
It looks like they’ve gotten rid of using global functions for most statusbars and are using a Mixin for each one instead which means you would have to hook the individual function for each bar you want to effect (the new unit frame structures also make it pretty ugly and given they are not identical makes it even uglier).
Eg. for the PlayerFrame and TargetFrame health and mana bars you could use:
local function UpdateBarText(self, textString, value, valueMin, valueMax)
if valueMax > 0 then
textString:SetText(tostring(AbbreviateLargeNumbers(value)).."");
else
textString:SetText("0");
end
if(self.LeftText and self.RightText) then
self.LeftText:Hide();
self.RightText:Hide();
textString:Show();
end
end
hooksecurefunc(PlayerFrame.PlayerFrameContent.PlayerFrameContentMain.HealthBarArea.HealthBar, "UpdateTextStringWithValues", UpdateBarText)
hooksecurefunc(TargetFrame.TargetFrameContent.TargetFrameContentMain.HealthBar, "UpdateTextStringWithValues", UpdateBarText)
hooksecurefunc(PlayerFrame.PlayerFrameContent.PlayerFrameContentMain.ManaBarArea.ManaBar, "UpdateTextStringWithValues", UpdateBarText)
hooksecurefunc(TargetFrame.TargetFrameContent.TargetFrameContentMain.ManaBar, "UpdateTextStringWithValues", UpdateBarText)
I have’t dug into the makeup of the text status bar to see if that has changed.
You just need to format the values the way you want for each unit eg.
local function AsPercent(value, valueMin, valueMax)
return format("%.0f%%", value/valueMax * 100)
end
local function PercentOnly(self, textString, value, valueMin, valueMax)
if value > 0 then
textString:SetText(AsPercent(value, valueMin, valueMax))
else
textString:SetText(0)
end
textString:Show()
end
local function ValAndPercent(self, textString, value, valueMin, valueMax)
if value > 0 then
textString:SetText(format("%s (%s)", AbbreviateLargeNumbers(value), AsPercent(value, valueMin, valueMax)))
else
textString:SetText(0)
end
textString:Show()
end
hooksecurefunc(PlayerFrame.PlayerFrameContent.PlayerFrameContentMain.HealthBarArea.HealthBar, "UpdateTextStringWithValues", PercentOnly)
hooksecurefunc(TargetFrame.TargetFrameContent.TargetFrameContentMain.HealthBar, "UpdateTextStringWithValues", ValAndPercent)