- Lua/XML Help
||06-13-20 01:47 AM
Need help with WorldMapDataProvider
Hi, I am trying to extend my AddOn with Icons on the Zone Maps, but... when I last did this Kind of stuff (around BC times), the WorldMap was a simple Frame like any other and Nothing with data Providers and all this.
So I tried to figure it out but it doesn't Show me any Icon.
Can anyone push me the Right way?
Here is the sample code I wrote to understand how all this works:
<Frame name="WorldmapSamplePinTemplate" hidden="false" enableMouse="true" mixin="WorldmapSamplePinMixin" virtual="true">
<Size x="12" y="12"/>
<Layers><Layer level="OVERLAY"><Texture parentKey="texture" setAllPoints="true"></Texture></Layer></Layers>
Me.WorldMapDataProvider = CreateFromMixins(MapCanvasDataProviderMixin)
WorldmapSamplePinMixin = CreateFromMixins(MapCanvasPinMixin)
-- WORLDMAP REMOVE DATA
-- WORLDMAP REFRESH DATA
local mapid = self:GetMap():GetMapID()
if mapid then
local pin=self:GetMap():AcquirePin("WorldmapSamplePinTemplate", mapid, 50,50)
-- WORLDMAP PIN MIXIN : ON LOAD
self:SetScalingLimits(1, 1.0, 1.2)
-- WORLDMAP PIN MIXIN : ON ACQUIRED
function WorldmapSamplePinMixin:OnAcquired(mapid, x,y)
self.texture:SetTexCoord(0, 1, 0, 1)
self.texture:SetVertexColor(1, 1, 1, 1)
print("added pin at "..x.."/"..y.." to map "..mapid)
-- WORLDMAP PIN MIXIN : ON MOUSE EVENTS
function WorldmapSamplePinMixin:OnMouseEnter() print("Mouse Enter") end
function WorldmapSamplePinMixin:OnMouseLeave() print("Mouse Leave") end
function WorldmapSamplePinMixin:OnClick(button) print("Mouse Click") end
In Addition there is of Course a file "unknown.tga" in the WordmapSample Directory.
What happens is: I see the debug message telling me "added pin at 50/50 to map <id>"
So the OnAcquired function gets called. But I don't see the Icon on the Zone map.
Can anyone tell me what I'm doing wrong?
||06-14-20 03:38 AM
Thanks for this hint, I checked HBD but... it has its own Management of minimap and worldmap Pins that would collide with my own management. My minimap Management is already working and deeply integrated in all my other Code. Wouldn't like to throw that all away.
I also tried to get through the HBD Code and understand how it is working… but down to the essentials (which is: just put one pin to the current map), I only found one difference and inserted this (I tried to display the Icon directly using the pin instead of adding a Frame to the pin). but it still doesn't show up on the map.
I must misunderstand something, but I don't get it...
||06-14-20 05:39 AM
Hi, got it now… the only error on my Code was to use x/y coordinates from 0 to 100 instead of 0 to 1.
So, where I placed at 50/50, I should have placed at 0.5/0.5.
||06-14-20 08:59 AM
I studied your code for a solid 15 minutes, comparing it to mine to spot the difference. I never thought to check the x/y coord. lol
|All times are GMT -6. The time now is 12:44 AM.
vBulletin © 2020, Jelsoft Enterprises Ltd
© 2004 - 2020 MMOUI