Quantcast
Need help with WorldMapDataProvider - WoWInterface
Thread Tools Display Modes
06-13-20, 01:47 AM   #1
oldZifnab
A Defias Bandit
Join Date: Jun 2020
Posts: 3
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:

WorldmapSample.xml:
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/">
	<Script file="WorldmapSample.lua"/>

	<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>
	</Frame>
</Ui>
WorldmapSample.lua:
Code:
local Me=CreateFrame("Frame","WorldmapSampleFrame")
local pins={}
Me.WorldMapDataProvider = CreateFromMixins(MapCanvasDataProviderMixin)
WorldmapSamplePinMixin = CreateFromMixins(MapCanvasPinMixin)
WorldMapFrame:AddDataProvider(Me.WorldMapDataProvider)
print("WorldmapSample loaded")

-- WORLDMAP REMOVE DATA
function Me.WorldMapDataProvider:RemoveAllData()
	self:GetMap():RemoveAllPinsByTemplate("WorldmapSamplePinTemplate")
	wipe(pins)
	print("wiped pins")
end

-- WORLDMAP REFRESH DATA
function Me.WorldMapDataProvider:RefreshAllData()
	self:RemoveAllData()
	local mapid = self:GetMap():GetMapID()
	if mapid then 
		local pin=self:GetMap():AcquirePin("WorldmapSamplePinTemplate", mapid, 50,50)
		table.insert(pins, pin) 		
	end
end

-- WORLDMAP PIN MIXIN : ON LOAD
function WorldmapSamplePinMixin:OnLoad()
	self:UseFrameLevelType("PIN_FRAME_LEVEL_AREA_POI")
	self:SetScalingLimits(1, 1.0, 1.2)
end

-- WORLDMAP PIN MIXIN : ON ACQUIRED
function WorldmapSamplePinMixin:OnAcquired(mapid, x,y)
	self:SetPosition(x, y)
	self:SetBackdrop(nil)
	self.texture:SetTexture("Interface/AddOns/WorldmapSample/unknown.tga")
	self:SetSize(12,12)
	self.texture:SetTexCoord(0, 1, 0, 1)
	self.texture:SetVertexColor(1, 1, 1, 1)	
	self:EnableMouse(true)
	self:Show()
	print("added pin at "..x.."/"..y.." to map "..mapid)
end

-- 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?
Attached Files
File Type: lua WorldmapSample.lua (1.6 KB, 31 views)
File Type: xml WorldmapSample.xml (361 Bytes, 31 views)
File Type: tga unknown.tga (1.0 KB, 32 views)

Last edited by oldZifnab : 06-13-20 at 04:51 AM.
  Reply With Quote
06-13-20, 10:46 AM   #2
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,124
Either straight up use HereBeDragons or check out its code to see how it is done: https://www.wowace.com/projects/herebedragons
  Reply With Quote
06-14-20, 03:38 AM   #3
oldZifnab
A Defias Bandit
Join Date: Jun 2020
Posts: 3
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...
  Reply With Quote
06-14-20, 05:39 AM   #4
oldZifnab
A Defias Bandit
Join Date: Jun 2020
Posts: 3
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.
  Reply With Quote
06-14-20, 08:59 AM   #5
DahkCeles
An Aku'mai Servant
 
DahkCeles's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2020
Posts: 32
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
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Need help with WorldMapDataProvider

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off