Thread Tools Display Modes
10-28-20, 05:37 PM   #1
ApocalypseToast
A Murloc Raider
Join Date: Jul 2020
Posts: 7
Scaling C_TaxiMap Node to Fit Flight Path Map

Hey everyone. Pretty new to making addons and I hit a bump with one project of mine.

I want to get all taxi node info and then put some pins on flight path map where the player doesn't have the flight path yet.

I got all the nodes with C_TaxiMap. The data comes with a Vector2D object https://wow.gamepedia.com/Vector2DMixin

I use GetXY() to get the X and Y, but when I then try and put them on the map, I can tell I have the correct shape as seen here:

(For testing, I used the nodes that are Reachable==1 (known) for now).


Top top exclamation is the Argent Tournament, the one off to the left is Warsong Hold, etc.

But the scale is off, and I'm not sure how to expand it properly. I found this code to put a exclamation on the map just to test for now

https://www.wowinterface.com/forums/...93&postcount=4
Code:
local frameT = FlightMapFrame
local pin = CreateFrame("Frame", "MYPIN", frameT)
pin:SetWidth(16)
pin:SetHeight(16)
pin:EnableMouse(true)
	
pin:SetScript("OnEnter", function(pin)
	print("x: " .. x .. "     y: " .. y)
end) -- this routine you need to write
	
pin:SetScript("OnLeave", function()

end) -- this routine you need to write
	
pin.texture = pin:CreateTexture()
-- You need to set the texture of the pin you want to display.  Here is an example
pin.texture:SetTexture("Interface\\MINIMAP\\ObjectIcons.blp")
pin.texture:SetTexCoord(0.125, 0.250, 0.125, 0.250)
pin.texture:SetAllPoints()
-- Make it appear at different levels in the map as desired (other icons can cover it based on what you choose)
pin:SetFrameStrata("TOOLTIP")
pin:SetFrameLevel(frameT:GetFrameLevel() + 1)
pin:SetPoint("CENTER", frameT, "CENTER", x*10, -y*10)
pin:Show()
When I set point on the second-to-last line, is there a formula that correcly scales it up, or is there a better way of doing this altogether? I looked into HereBeDragons but I continued on this way since I think I'm pretty close.

Thanks!
Attached Thumbnails
Click image for larger version

Name:	chat.PNG
Views:	625
Size:	67.5 KB
ID:	9510  Click image for larger version

Name:	flightpath.PNG
Views:	726
Size:	822.9 KB
ID:	9511  
  Reply With Quote
10-29-20, 09:10 AM   #2
DahkCeles
A Cliff Giant
 
DahkCeles's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2020
Posts: 73
https://www.townlong-yak.com/framexm...taProvider.lua

This is how FlightMapFrame populates presently. Line 138 is important: pin:SetPosition()

I wonder what would happen if you just did this for fun:

Lua Code:
  1. -- code removed, replaced in a subsequent comment

Last edited by DahkCeles : 10-29-20 at 03:58 PM. Reason: Replacing a code block later on below
  Reply With Quote
10-29-20, 01:20 PM   #3
ApocalypseToast
A Murloc Raider
Join Date: Jul 2020
Posts: 7
Could you explain where to put those? I'm afraid I don't really understand them all that well.
  Reply With Quote
10-29-20, 04:07 PM   #4
DahkCeles
A Cliff Giant
 
DahkCeles's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2020
Posts: 73
I had more time to do some toying around, and here's a simple solution. I believe the flight paths are already marked, just invisible and changed to a different icon. They appear briefly when you mouse over other paths, if it requires going past a location you haven't discovered.

So the solution is just to make them appear, and stop the game from re-hiding them.

Lua Code:
  1. -- Step 1: Wait for the flight map to be created
  2. -- Step 2: Any time the flight map appears, enumerate through every flight path pin
  3. -- Step 3: Make each pin shown, and prevent the the OnMouseEnter/OnMouseLeave events from overriding this
  4.  
  5.  
  6. -- STEP 1:
  7. local alreadyHooked
  8. hooksecurefunc("FlightMap_LoadUI", function()
  9.     if (alreadyHooked) then
  10.         return
  11.     else
  12.         alreadyHooked = true
  13.        
  14.         -- STEP 2:
  15.         FlightMapFrame:HookScript("OnShow", function()
  16.             for pin in FlightMapFrame:EnumeratePinsByTemplate("FlightMap_FlightPointPinTemplate") do
  17.                 -- STEP 3:
  18.                 pin:Show()
  19.                 pin.SetShown = pin.Show
  20.             end
  21.         end)
  22.     end
  23. end)


PS. This is the complete addon, minus the TOC file of course. I tested briefly with an alt who had a couple unknown flight paths and it seemed to work.
  Reply With Quote
10-29-20, 04:48 PM   #5
ApocalypseToast
A Murloc Raider
Join Date: Jul 2020
Posts: 7
Wow, yeah that totally works and even less lines than mine. I was going to put the completed addon on Curse but it isn't right for me to do by just copying what you have so I will look into seeing how I can overwrite the textures with something else first. I'd credit you in the description for helping too.

Edit: It doesn't work with Draenor I don't think. /fstack shows the frame is named something else, it also looks and appears differently than the rest of the game. I'll fix it to work with that as well.

Last edited by ApocalypseToast : 10-29-20 at 05:29 PM.
  Reply With Quote
10-29-20, 05:00 PM   #6
DahkCeles
A Cliff Giant
 
DahkCeles's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2020
Posts: 73
Further testing: underwater nodes in Vashj'ir do not play nice with above-water nodes in the Eastern Kingdoms. A few extra lines of code can solve that problem...


Lua Code:
  1. -- Step 1: Wait for the flight map to be created
  2. -- Step 2: Any time the flight map appears, enumerate through every flight path pin and do steps 3 and 4 at least once
  3. -- Step 3: Make each pin shown, and prevent the the OnMouseEnter/OnMouseLeave events from overriding this
  4. -- Step 4: Undersea nodes in Vashj'ir will not play nice, so override the click handler
  5. -- Step 5: Also because of Vashj'ir, change the tooltip text just a little
  6.  
  7.  
  8. -- STEP 1:
  9. local alreadyHooked
  10. hooksecurefunc("FlightMap_LoadUI", function()
  11.     if (alreadyHooked) then
  12.         return
  13.     else
  14.         alreadyHooked = true
  15.        
  16.         -- STEP 2:
  17.         FlightMapFrame:HookScript("OnShow", function()
  18.             for pin in FlightMapFrame:EnumeratePinsByTemplate("FlightMap_FlightPointPinTemplate") do
  19.                 if (pin.alreadyHooked == nil) then
  20.                     pin.alreadyHooked = true
  21.                     -- STEP 3:
  22.                     pin:Show()
  23.                     pin.SetShown = pin.Show
  24.                     -- STEP 4:
  25.                     function pin:OnClick(button)
  26.                         if button == "LeftButton" and self.taxiNodeData.state == Enum.FlightPathState.Reachable then
  27.                             TakeTaxiNode(self.taxiNodeData.slotIndex);
  28.                         end
  29.                     end
  30.                 end
  31.             end
  32.         end)
  33.     end
  34. end)
  35.  
  36.  
  37. -- Instead of saying 'not discovered' it will say 'not available'
  38. TAXI_PATH_UNREACHABLE = ADDON_NOT_AVAILABLE


You are correct about Draenor. Here's the source code for that one:
https://www.townlong-yak.com/framexm...xiFrame.lua#32

Last edited by DahkCeles : 10-29-20 at 05:02 PM.
  Reply With Quote
10-29-20, 05:28 PM   #7
DahkCeles
A Cliff Giant
 
DahkCeles's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2020
Posts: 73
And I got the WoD map working too. The nodes start at "TaxiButton1" and keep increasing from there.

If you don't mind, I might include this in my own addon as well. It seems like a handy feature to keep refining.


Lua Code:
  1. -------------------
  2. -- TaxiFrame in WoD
  3.  
  4. local hooked = 0
  5. TaxiFrame:HookScript("OnShow", function()
  6.     local i = 1
  7.     local button = _G["TaxiButton"..i]
  8.     while (button) do
  9.         button:SetShown(true)
  10.         if (i > hooked) then
  11.             hooked = hooked + 1
  12.             button.Hide = button.Show
  13.         end
  14.         i = i + 1
  15.         button = _G["TaxiButton"..i]
  16.     end
  17. end)
  18.  
  19.  
  20. TaxiFrame:HookScript("OnHide", function()
  21.     local i = 1
  22.     local button = _G["TaxiButton"..i]
  23.     while (button) do
  24.         button:SetShown(false)
  25.         i = i + 1
  26.         button = _G["TaxiButton"..i]
  27.     end
  28. end)
  Reply With Quote
10-29-20, 05:40 PM   #8
ApocalypseToast
A Murloc Raider
Join Date: Jul 2020
Posts: 7
You've done all of it so you don't have to ask.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Scaling C_TaxiMap Node to Fit Flight Path Map

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