while I assume it's fully functional I would probably have gone with less if statements.
UpdateText:
local HColor = ShowingHelm() and COLOR_HEX_GREEN or COLOR_HEX_RED
local cColor = ShowingVest() and COLOR_HEX_GREEN or COLOR_HEX_RED
self:SetText(FuBarUtils.Colorize(HColor, self.textCloak)..FuBarUtils.Colorize(CColor, self.textHelm))
UpdateTooltip
local IsCloak,IsHelm = ShowingCloak(),ShowingHelm()
FuBarTooltip:AddDoubleLine(nil, "Cloak", IsCloak and "On" or "Off", 1, 1, 0, IsCloak and 0 or 1, IsCloak and 1 or 0, 0)
FuBarTooltip:AddDoubleLine(nil, "Helm", IsHelm and "On" or "Off", 1, 1, 0, IsHelmk and 0 or 1, IsHelm and 1 or 0, 0)
FuBarTooltip:SetHint("Click to toggle.")
OnClick:
local i = (2*(ShowingCloak() or 0) + ShowingHelm() or 0 + 1)
if i>3 then i = i-4 end
if i>=2 then ShowCloak(1); i = i-2; else ShowCloak(0); end
ShowCloak(i)
My smart Idea of using modulus became less smart when I realized lua don't have modulus. I'm not sure I recommend this exact coding but it can clearly be done more consice than currently.
|