Thread Tools Display Modes
08-12-18, 10:00 AM   #1
Xruptor
A Flamescale Wyrmkin
 
Xruptor's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 133
Error with hiding WorldMapFrame WorldQuests

So I'm trying to write code that will completely eliminate or at least hide the WorldQuests from the World Map. Just the world quests though nothing else. I believe there is a filter way of doing it but I haven't looked much into it.

Code:
hooksecurefunc (WorldMapFrame, "OnMapChanged", function()

	local mapID = WorldMapFrame.mapID

	for dataProvider, state in pairs (WorldMapFrame.dataProviders) do

		if mapID == dataProvider:GetMap():GetMapID() then
			local taskInfo = C_TaskQuest.GetQuestsForPlayerByMapID(mapID)
	
			if (taskInfo and #taskInfo > 0) then

				local questPins = {}
				
				for pin in dataProvider:GetMap():EnumerateAllPins() do
					if pin.questID then
						questPins[pin.questID] = pin
					end
				end
			
				for i, info  in ipairs (taskInfo) do
					local questID = info.questId
					if (HaveQuestData (questID)) then
						local isWorldQuest = QuestUtils_IsQuestWorldQuest (questID)
						if isWorldQuest and questPins[questID] and questPins[questID].worldQuest then
							dataProvider:GetMap():RemovePin(questPins[questID])
						end
					end
				end
				
			end
			
			break
		end
		
	end

end)
The code above is what I'm using but I keep getting an error with it. I've tried several methods but maybe someone here can see something I'm not seeing.

Code:
Date: 2018-08-12 11:57:33
ID: 1
Error occured in: Global
Count: 1
Message: ...ns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua line 244:
   attempt to index a nil value
Debug:
   ...ns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:244: SetPosition()
   ...rd_SharedMapDataProviders\WorldQuestDataProvider.lua:217: RefreshAllData()
   ...dOns\Blizzard_WorldMap\WM_WorldQuestDataProvider.lua:26: RefreshAllData()
   ...ace\AddOns\Blizzard_MapCanvas\Blizzard_MapCanvas.lua:418: RefreshAllDataProviders()
   ...ace\AddOns\Blizzard_MapCanvas\Blizzard_MapCanvas.lua:446: RefreshAll()
   ...ace\AddOns\Blizzard_MapCanvas\Blizzard_MapCanvas.lua:59: OnShow()
   ...rface\AddOns\Blizzard_WorldMap\Blizzard_WorldMap.lua:231:
      ...rface\AddOns\Blizzard_WorldMap\Blizzard_WorldMap.lua:228
   [C]: Show()
   ..\FrameXML\UIParent.lua:2611: SetUIPanel()
   ..\FrameXML\UIParent.lua:2456: ShowUIPanel()
   ..\FrameXML\UIParent.lua:2317:
      ..\FrameXML\UIParent.lua:2313
   [C]: SetAttribute()
   ..\FrameXML\UIParent.lua:3138: ShowUIPanel()
   ..\FrameXML\QuestLogOwnerMixin.lua:103: SetDisplayState()
   ..\FrameXML\QuestLogOwnerMixin.lua:41: HandleUserActionToggleSelf()
   ...rface\AddOns\Blizzard_WorldMap\Blizzard_WorldMap.lua:405: ToggleWorldMap()
   [string "TOGGLEWORLDMAP"]:1:
      [string "TOGGLEWORLDMAP"]:1
Locals:
self = <unnamed> {
 0 = <userdata>
 Highlight = <unnamed> {
 }
 PanTo = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:260
 BountyRing = <unnamed> {
 }
 worldQuest = true
 UseFrameLevelType = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:365
 GetNudgeSourceZoomedInMagnitude = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:175
 SetScaleStyle = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:301
 GetNudgeSourcePinZoomedInNudgeFactor = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:211
 UpdateTooltip = <function> defined @Interface\AddOns\Blizzard_SharedMapDataProviders\WorldQuestDataProvider.lua:400
 GetMap = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:199
 ApplyFrameLevel = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:374
 ApplyCurrentPosition = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:336
 IsIgnoringGlobalPinScale = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:287
 Glow = <unnamed> {
 }
 GetNudgeZoomFactor = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:233
 OnMouseUp = <function> defined @Interface\AddOns\Blizzard_SharedMapDataProviders\WorldQuestDataProvider.lua:436
 OnAcquired = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:110
 PanAndZoomTo = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:265
 SelectedGlow = <unnamed> {
 }
 RefreshVisuals = <function> defined @Interface\AddOns\Blizzard_WorldMap\WM_WorldQuestDataProvider.lua:48
 ApplyCurrentAlpha = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:357
 OnLoad = <function> defined @Interface\AddOns\Blizzard_WorldMap\WM_WorldQuestDataProvider.lua:42
 TrackedCheck = <unnamed> {
 }
 OnReleased = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:114
 OnCanvasPanChanged = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:275
 SetNudgeFactor = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:228
 GetNudgeSourcePinZoomedOutNudgeFactor = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:207
 startScale = 0.425
 OnClick = <function> defined @Interface\AddOns\Blizzard_SharedMapDataProviders\WorldQuestDataProvider.lua:408
 SetNudgeZoomedInFactor = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:179
 GetNudgeSourceRadius = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:162
 normalizedY = 0.72549211978912
 questID = 44744
 scaleFactor = 1
 Underlay = <unnamed> {
 }
 GetFrameLevelType = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:370
 SetAlphaStyle = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:326
 SetScalingLimits = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:291
 worldQuestType = 2
 SetNudgeSourceRadius = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:158
 OnMapInsetMouseLeave = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:146
 GetNudgeTargetFactor = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:154
 numObjectives = 1
 dataProvider = <table> {
 }
 endScale = 0.425
 normalizedX = 0.49518918991089
 SetAlphaLimits = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:316
 SetNudgeSourceMagnitude = <function> defined @Interface\AddOns\Blizzard_MapCanvas\MapCanvas_DataProviderBase.lua:166
 OnCanvasScaleChanged = <function> defined @Interface\AddOns\Blizzard_
__________________
Click HERE for the ultimate idiot test.

if (sizeof(sadness) > sizeof(happiness)) { initDepression(); }
  Reply With Quote
08-12-18, 10:52 AM   #2
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Clicking on the magnifying glass in the top right of the map allows you to remove most, though perhaps not all world quests from the map.
  Reply With Quote
08-12-18, 10:58 AM   #3
Xruptor
A Flamescale Wyrmkin
 
Xruptor's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 133
Originally Posted by semlar View Post
Clicking on the magnifying glass in the top right of the map allows you to remove most, though perhaps not all world quests from the map.
Yep I want to remove them all lol. That's what I'm trying to do. There are a few that don't get filtered out.
__________________
Click HERE for the ultimate idiot test.

if (sizeof(sadness) > sizeof(happiness)) { initDepression(); }
  Reply With Quote
08-13-18, 06:00 AM   #4
Xruptor
A Flamescale Wyrmkin
 
Xruptor's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 133
>.< I guess no one has an idea. It seems to be triggering from the Mixins RefreshAll or RefreshAllData calls. Just can't seem to figure a way not to have it call the SetPosition which triggers the error.
__________________
Click HERE for the ultimate idiot test.

if (sizeof(sadness) > sizeof(happiness)) { initDepression(); }
  Reply With Quote
08-13-18, 07:14 AM   #5
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
This is how I do it:
Lua Code:
  1. local function OrigProviderOnRemoved(self, mapCanvas)
  2.     -- temporary fix to prevent error when removing the original world quest provider, I've notified
  3.     -- Blizzard developers directly about this issue and it should be resolved soon™
  4.     local Map = self:GetMap()
  5.     Map:UnregisterCallback('SetFocusedQuestID', self.setFocusedQuestIDCallback)
  6.     Map:UnregisterCallback('ClearFocusedQuestID', self.clearFocusedQuestIDCallback)
  7.     Map:UnregisterCallback('SetBountyQuestID', self.setBountyQuestIDCallback)
  8.  
  9.     MapCanvasDataProviderMixin.OnRemoved(self, mapCanvas)
  10. end
  11.  
  12. for provider in next, WorldMapFrame.dataProviders do
  13.     if(provider.GetPinTemplate and provider.GetPinTemplate() == 'WorldMap_WorldQuestPinTemplate') then
  14.         -- BUG: the OnRemoved method is broken, so we replace it before we remove the provider
  15.         provider.OnRemoved = OrigProviderOnRemoved
  16.         WorldMapFrame:RemoveDataProvider(provider)
  17.     end
  18. end

The reason I overwrite OnRemoved is because of a bug with the order of execution within it.
Whenever that is fixed, you can just do this:
Lua Code:
  1. for provider in next, WorldMapFrame.dataProviders do
  2.     if(provider.GetPinTemplate and provider.GetPinTemplate() == 'WorldMap_WorldQuestPinTemplate') then
  3.         WorldMapFrame:RemoveDataProvider(provider)
  4.     end
  5. end
  Reply With Quote
08-13-18, 08:19 AM   #6
Xruptor
A Flamescale Wyrmkin
 
Xruptor's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2005
Posts: 133
Originally Posted by p3lim View Post

The reason I overwrite OnRemoved is because of a bug with the order of execution within it.
Whenever that is fixed, you can just do this:
Lua Code:
  1. for provider in next, WorldMapFrame.dataProviders do
  2.     if(provider.GetPinTemplate and provider.GetPinTemplate() == 'WorldMap_WorldQuestPinTemplate') then
  3.         WorldMapFrame:RemoveDataProvider(provider)
  4.     end
  5. end
Thanks for the response p3lim. I've been toying with the DataProviders and have noticed that the order of particular calls are out of whack. One of them being the Refresh one for the pins. I was trying to find a way to get the pins to be removed, but because of the order they where being refreshed and called by SetPoint on the primary Mixin.

It never occured to me to look at removing the DataProvider entirely. I was doing on a pin by pin basis. Thanks for the insight, figured someone would see a different approach then what I was doing.
__________________
Click HERE for the ultimate idiot test.

if (sizeof(sadness) > sizeof(happiness)) { initDepression(); }
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Error with hiding WorldMapFrame WorldQuests

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