diff --git a/Interface/AddOns/SVUI/packages/stats/SVStats.lua b/Interface/AddOns/SVUI/packages/stats/SVStats.lua index 0113400..d807661 100644 --- a/Interface/AddOns/SVUI/packages/stats/SVStats.lua +++ b/Interface/AddOns/SVUI/packages/stats/SVStats.lua @@ -83,6 +83,7 @@ local classColor = RAID_CLASS_COLORS[myClass]; local StatMenuFrame = CreateFrame("Frame", "SVUI_StatMenu", UIParent); local ListNeedsUpdate = true local SCORE_CACHE = {}; +local hexHighlight = "FFFFFF"; -- When its vertical then "left" = "top" and "right" = "bottom". Yes I know thats ghetto, bite me! local positionIndex = {{"middle", "left", "right"}, {"middle", "top", "bottom"}}; @@ -623,50 +624,55 @@ do end local function LoadStatBroker() - local OnEnter, OnLeave, lastObj; - for dataName, dataObj in LDB:DataObjectIterator()do - OnEnter = nil; - OnLeave = nil; - lastObj = nil; - if dataObj.OnEnter then - OnEnter = function(self) + for dataName, dataObj in LDB:DataObjectIterator() do + + local OnEnter, OnLeave, OnClick, lastObj; + + if dataObj.OnTooltipShow then + function OnEnter(self) MOD:Tip(self) - dataObj.OnEnter(MOD.tooltip) + dataObj.OnTooltipShow(MOD.tooltip) MOD:ShowTip() end - elseif dataObj.OnTooltipShow then - OnEnter = function(self) + end + + if dataObj.OnEnter then + function OnEnter(self) MOD:Tip(self) - dataObj.OnTooltipShow(MOD.tooltip) + dataObj.OnEnter(MOD.tooltip) MOD:ShowTip() end - end; + end + if dataObj.OnLeave then - OnLeave = function(self) + function OnLeave(self) dataObj.OnLeave(self) MOD.tooltip:Hide() end - end; - local OnClick = function(self, e) - dataObj.OnClick(self, e) - end; - local CallBack = function(_, name, _, value, _) - local newText; - if(value == nil or string.len(value) > 5 or value == "n / a" or name == value) then - newText = value ~= "n / a" and value or name - lastObj.text:SetText(newText) + end + + if dataObj.OnClick then + function OnClick(self, button) + dataObj.OnClick(self, button) + end + end + + local function textUpdate(event, name, key, value, dataobj) + if value == nil or (len(value) > 5) or value == 'n/a' or name == value then + lastObj.text:SetText(value ~= 'n/a' and value or name) else - newText = ("%s: %s%s|r"):format(name, hexString, value) - lastObj.text:SetText(newText) - end - end; - local OnEvent = function(self) + lastObj.text:SetText(name..': '.. '|cff' .. hexHighlight ..value..'|r') + end + end + + local function OnEvent(self) lastObj = self; - LDB:RegisterCallback("LibDataBroker_AttributeChanged_"..dataName.."_text", CallBack) - LDB:RegisterCallback("LibDataBroker_AttributeChanged_"..dataName.."_value", CallBack) + LDB:RegisterCallback("LibDataBroker_AttributeChanged_"..dataName.."_text", textUpdate) + LDB:RegisterCallback("LibDataBroker_AttributeChanged_"..dataName.."_value", textUpdate) LDB.callbacks:Fire("LibDataBroker_AttributeChanged_"..dataName.."_text", dataName, nil, dataObj.text, dataObj) - end; - MOD:Extend(dataName, {"PLAYER_ENTER_WORLD"}, OnEvent, nil, OnClick, OnEnter, OnLeave) + end + + MOD:Extend(dataName, {"PLAYER_ENTERING_WORLD"}, OnEvent, nil, OnClick, OnEnter, OnLeave) end end --[[ @@ -679,7 +685,7 @@ function MOD:ReLoad() end function MOD:Load() - local hexHighlight = SV:HexColor("highlight") or "FFFFFF" + hexHighlight = SV:HexColor("highlight") or "FFFFFF" local hexClass = classColor.colorStr BGStatString = "|cff" .. hexHighlight .. "%s: |c" .. hexClass .. "%s|r";