View Single Post
07-31-18, 09:19 PM   #7
kurapica.igas
A Chromatic Dragonspawn
Join Date: Aug 2011
Posts: 152
Originally Posted by p3lim View Post
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:
  1. local viewRect  = CreateRectangle(0, 0, 0, 0)
  2.  
  3. BattlefieldMapFrame.ScrollContainer.CalculateViewRect =  function (self, scale)
  4.     local childWidth, childHeight = self.Child:GetSize()
  5.     local left = self:GetHorizontalScroll() / childWidth
  6.     local right = left + (self:GetWidth() / scale) / childWidth
  7.     local top = self:GetVerticalScroll() / childHeight
  8.     local bottom = top + (self:GetHeight() / scale) / childHeight
  9.  
  10.     viewRect:SetSides(left, right, top, bottom)
  11.  
  12.     return viewRect  -- the origin: CreateRectangle(left, right, top, bottom)
  13. 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:
  1. local areaLabelDataProvider = CreateFromMixins(AreaLabelDataProviderMixin)
  2. BattlefieldMapFrame:AddDataProvider(areaLabelDataProvider)
  3. hooksecurefunc(areaLabelDataProvider.Label, "SetLabel", print)
  Reply With Quote