Originally Posted by p3lim
Almost, you'll want to make sure that the Label is indeed the AreaLabel one, as more providers have a .Label member.
|
For now, there is only one data provider with Label field. Never mind, Theroxis is talking about my addon EnhanceBattlefieldMinimap, the area label is created in it, so in the newest version, a setting is already given for the labels.
Back to the hooking data provider, since there is no action button on the world map, it's safe to just replaced them with our own codes, I replaced some of them to reduce the memory increment, like :
Lua Code:
local viewRect = CreateRectangle(0, 0, 0, 0)
BattlefieldMapFrame.ScrollContainer.CalculateViewRect = function (self, scale)
local childWidth, childHeight = self.Child:GetSize()
local left = self:GetHorizontalScroll() / childWidth
local right = left + (self:GetWidth() / scale) / childWidth
local top = self:GetVerticalScroll() / childHeight
local bottom = top + (self:GetHeight() / scale) / childHeight
viewRect:SetSides(left, right, top, bottom)
return viewRect -- the origin: CreateRectangle(left, right, top, bottom)
end
Unfortunately, waste comes from the APIS can't be done.
If we need use the hooksecurefunc, the target should be the object created from the CreateFromMinxin, like(The Label has a Mixin named AreaLabelFrameMixin) :
Lua Code:
local areaLabelDataProvider = CreateFromMixins(AreaLabelDataProviderMixin)
BattlefieldMapFrame:AddDataProvider(areaLabelDataProvider)
hooksecurefunc(areaLabelDataProvider.Label, "SetLabel", print)