obble / modui_classic

modui: for wow classic
45 stars 20 forks source link

Request: Simplified health/power numbers #51

Open ollema opened 4 years ago

ollema commented 4 years ago

Hey!

With simplified I mean 80 instead of 80/100 energy for example, or 1325 instead of 1325/2308 health. See screenshot:

WoWScrnShot_090319_231922

I've got this working for myself, but it's spewing out errors and I had to make modifications to mod UI. It would be nice if this was not needed, or even better if this was added as an option!

To get this to work I wrote this little addon (with support for Real Mob health):

local UnitHealth = UnitHealth
local realUnitHealth = UnitHealth
local UnitHealthMax = UnitHealthMax
local realUnitHealthMax = UnitHealthMax

if RealMobHealth and RealMobHealth.GetUnitHealth then
    UnitHealth = function(unit)
        local hp = RealMobHealth.GetUnitHealth(unit, true)
        return hp or realUnitHealth(unit)
    end
    UnitHealthMax = function(unit)
        local _,maxhp = RealMobHealth.GetUnitHealth(unit, true)
        return maxhp or realUnitHealthMax(unit)
    end
elseif RealMobHealth then -- maintain compatibility for now
    UnitHealth = function(unit)
        local hp = RealMobHealth.GetHealth(unit, true)
        return hp or realUnitHealth(unit)
    end
    UnitHealthMax = function(unit)
        local _,maxhp = RealMobHealth.GetHealth(unit, true)
        return maxhp or realUnitHealthMax(unit)
    end
end

hooksecurefunc("TextStatusBar_UpdateTextStringWithValues", function()
    PlayerFrameHealthBar.TextString:SetText(AbbreviateLargeNumbers(UnitHealth("player")))
    PlayerFrameManaBar.TextString:SetText(AbbreviateLargeNumbers(UnitPower("player")))

    TargetFrameHealthBar.TextString:SetText(AbbreviateLargeNumbers(UnitHealth("target")))
    TargetFrameManaBar.TextString:SetText(AbbreviateLargeNumbers(UnitPower("target")))
end) 

but you should probably not use this because it generates a lot of Lua errors (still working good though).

It works fine, but the font on the target's powerbar is wrong. I fixed that using this change: https://github.com/ollema/modui_classic/commit/e616f5fcf9f8913ef78e616139ad941e1dff2bb8

Not 100% sure on the coordinates in the y-axis.


Again, this would be really nice to have, and it's probably much easier for you (I have never written a line of lua before today!) than it is for me!

Let me know if I can provide any more details

obble commented 4 years ago

I'll look at adding this soon, id probably prefer this kind of formatting too personally.

ollema commented 4 years ago

awesome!