Mercurial > wow > worldplan
diff WorldQuests.lua @ 67:96183f981acb
Update for Legion Patch 7.2
- Pins for quests detected from the flight map should properly update as needed.
- Fixed dropdown menu configurations not getting applied.
- Added a toggle button to the world map display that performs the same function as the 'Enable' option in the dropdown menu.
- Rewrote the majority of display update handlers for a significant performance improvements while interacting with the world map.
- AP token info should now reflect artifact knowledge changes.
author | Nenue |
---|---|
date | Sat, 01 Apr 2017 08:17:30 -0400 |
parents | e43e10c5576b |
children | 31de7e9e7849 |
line wrap: on
line diff
--- a/WorldQuests.lua Thu Mar 30 02:32:44 2017 -0400 +++ b/WorldQuests.lua Sat Apr 01 08:17:30 2017 -0400 @@ -18,6 +18,7 @@ local GetQuestLogRewardInfo = GetQuestLogRewardInfo local GetCurrentMapAreaID, GetMapInfo, GetMapNameByID = GetCurrentMapAreaID, GetMapInfo, GetMapNameByID + local print = DEVIAN_WORKSPACE and function(...) _G.print('WorldQuests', ...) end or function() end local rprint = DEVIAN_WORKSPACE and function(...) _G.print('WQRefresh', ...) end or function() end local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end @@ -38,6 +39,7 @@ 0.25, 0.7, 1 } +local ToggleButton = {} local numShown = 0 local numLoaded = 0 local isDataLoaded @@ -56,13 +58,25 @@ end function Module:OnUpdate(sinceLast) - if self.filtersDirty or self.isStale or self.isZoomDirty then + + if self.filtersDirty or self.isStale then self:Refresh() end + if #db.UpdatedPins >= 1 then + print('|cFF00FF88pending updates', #db.UpdatedPins) + self:UpdateQueuedPins() + end + end -local InternalDoRefresh = function (self) - WorldPlanQuests:Refresh() +local currentScale = WorldMapDetailFrame:GetScale() +function Module:RefreshIfChanged() + local scaleCheck = WorldMapDetailFrame:GetScale() + if scaleCheck ~= currentScale then + print('|cFF00FF88scale changed from', currentScale, 'to', scaleCheck) + self:Refresh() + currentScale = scaleCheck + end end function Module:Setup() @@ -73,11 +87,24 @@ end hooksecurefunc("ClickWorldMapActionButton", function () self:OnClickWorldMapActionButton() end) - hooksecurefunc("WorldMapScrollFrame_ReanchorQuestPOIs", InternalDoRefresh) - hooksecurefunc("WorldMap_UpdateQuestBonusObjectives", function () self:OnUpdateQuestBonusObjectives() end) - hooksecurefunc("WorldMapFrame_UpdateMap", InternalDoRefresh) - WorldMapFrame.UIElementsFrame.BountyBoard:SetSelectedBountyChangedCallback(InternalDoRefresh); - WorldMapFrame.UIElementsFrame.ActionButton:SetOnCastChangedCallback(InternalDoRefresh); + hooksecurefunc("WorldMapScrollFrame_ReanchorQuestPOIs", function() + print("WorldMapScrollFrame_ReanchorQuestPOIs") + self:RefreshIfChanged() + end) + hooksecurefunc("WorldMap_UpdateQuestBonusObjectives", function () + self:OnUpdateQuestBonusObjectives() + end) + hooksecurefunc("WorldMapFrame_UpdateMap", function() + print("WorldMapFrame_UpdateMap") + self:RefreshIfChanged() + end) + WorldMapFrame.UIElementsFrame.BountyBoard:SetSelectedBountyChangedCallback(function() + self:OnSelectedBountyChanged() + end); + WorldMapFrame.UIElementsFrame.ActionButton:SetOnCastChangedCallback(function() + print("CastChangedCallback") + self:Refresh(true) + end); self.Status = CreateFrame('Frame', nil, self) self.Status:SetPoint('TOPLEFT', WorldMapPOIFrame, 'TOPLEFT', 0, 0) @@ -103,14 +130,76 @@ end) + + self:SetAllPoints(WorldMapPOIFrame) + for k,v in pairs( ToggleButton) do + self.Toggle:SetScript(k,v) + end + self:Show() +end + +local GetQuestBountyInfoForMapID, GetQuestLogTitle, GetQuestLogIndexByID, IsQuestFlaggedCompleted = GetQuestBountyInfoForMapID, GetQuestLogTitle, GetQuestLogIndexByID, IsQuestFlaggedCompleted +function Module:UpdateBountyInfo() + wipe(db.BountyInfo) + db.selectedBounty = nil + + local selectedBounty = WorldMapFrame.UIElementsFrame.BountyBoard:GetSelectedBountyIndex() + local bounties, numBounties = GetQuestBountyInfoForMapID(db.currentMapID) + + for index, data in ipairs(bounties) do + if data.factionID then + data.title = GetQuestLogTitle(GetQuestLogIndexByID(data.questID)) + data.complete = IsQuestFlaggedCompleted(data.questID) + db.BountyInfo[data.factionID] = data + if index == selectedBounty then + db.selectedBounty = data + end + end + end + + for questID, pin in pairs(db.QuestsByID) do + local doUpdate + if pin.factionID and db.BountyInfo[pin.factionID] then + if not pin.isCriteria then + pin.isCriteria = true + doUpdate = true + end + else + if pin.isCriteria then + doUpdate = true + pin.isCriteria = nil + end + end + if doUpdate then + if pin:IsVisible() then + pin:Refresh() + else + pin.isStale = true + end + end + end + db.BountyUpdate = nil +end + +function Module:OnSelectedBountyChanged() + self:UpdateBountyInfo() end function Module:OnConfigUpdate() + print('|cFFFFFF00OnConfigUpdate()|r') if db.Config.FadeWhileGrouped then db.PinAlpha = 0.15 else db.PinAlpha = 1 end + + if not db.Config.EnablePins then + for _, pin in pairs(db.QuestsByID) do + pin:SetShown(false) + end + end + + ToggleButton.OnShow(self.Toggle) end local InternalHideButton = function(button, index) @@ -140,11 +229,12 @@ end function Module:OnUpdateQuestBonusObjectives() - print('|cFFFF4400WorldMap_UpdateQuestBonusObjectives') + rprint('|cFFFF4400WorldMap_UpdateQuestBonusObjectives') self:UpdateBlizzButtons() end function Module:OnClickWorldMapActionButton() + rprint('|cFFFF4400ClickWorldMapActionButton') self:UpdateBlizzButtons() end @@ -167,21 +257,22 @@ self:RegisterEvent('CURRENT_SPELL_CAST_CHANGED') end -function Module:OnMapInfo(isBrokenIsle, isZoomedOut, mapAreaID) - print('|cFFFFFF00'..self:GetName()..':OnMapInfo()|r visible =', self:IsVisible()) - if self.isZoomedOut ~= isZoomedOut then - self.sizesDirty = true +function Module:OnMapInfo(isBrokenIsle, isZoomedOut, mapAreaID, isNewMap, isMapOpen) + + print('|cFFFFFF00'..self:GetName()..':OnMapInfo()|r, mapAreaID =', mapAreaID,'visible =', isMapOpen, 'changed =', isNewMap) + + if db.BountyUpdate then + self:UpdateBountyInfo() + end + if isNewMap then + print('|cFF00FF88refreshing for changed map') + if isMapOpen then + self:Refresh(true) + else + self.isStale = true + end end - self.isZoomedOut = isZoomedOut - self.isWorldQuestMap = isBrokenIsle - self.currentMapID = mapAreaID - - if self:IsVisible() then - self:Refresh(true) - else - self.isStale = true - end end local superTrackedQuestID function Module:OnEvent (event, ...) @@ -290,6 +381,7 @@ pin.isActive = TQ_IsActive(questID) pin:CheckFilterRules() rprint(pin:GetID(), pin.filtered, pin.used) + pin:SetShown(pin.used) return pin end @@ -417,6 +509,21 @@ end return 128, icon, quantity, name, itemID, quality end + +-- pins are queued by their OnUpdate and are ostensibly already visible, we just need to fix the zoom and anchor +function Module:UpdateQueuedPins() + print('|cFF00FF88UpdateQueuedPins()') + local pin = tremove(db.UpdatedPins) + while pin do + pin:CheckFilterRules() + + local scaleFactor = SCALE_FACTORS[(pin.dataLoaded and not pin.filtered) and scaleConstant or 1] + print(pin.title, pin.dataLoaded and not pin.filtered, scaleFactor) + pin:SetAnchor(nil, pin.x, pin.y, self.hostWidth, self.hostHeight, scaleFactor) + pin = tremove(db.UpdatedPins) + end +end + -- create of update quest pins for a map and its underlying zones function Module:UpdateWorldQuests (mapID) @@ -490,15 +597,20 @@ end end -function Module:Refresh() - self.currentMapID = GetCurrentMapAreaID() - rprint('|cFF00FF88'..self:GetName()..':Refresh()|r') - print('|cFF00FF88'..self:GetName()..':Refresh()|r') +local bountiesInitialized +function Module:Refresh(...) + rprint('|cFF00FF88'..self:GetName()..':Refresh()|r', ...) + print('|cFF00FF88'..self:GetName()..':Refresh()|r', ...) if not self:IsVisible() then print(' not visible, flag for later') self.isStale = true return self:MarkAllPins() end + if not db.Config.EnablePins then + return + end + + wprint(' |cFF00FF88'..self:GetName()..':Refresh()|r') scaleConstant = db.isContinentMap and 2 or 3 @@ -512,8 +624,6 @@ self:UpdateAnchors(nil) end - print('|cFFFFFF00'..self:GetName()..':Cleanup()|r') - rprint('|cFFFFFF00'..self:GetName()..':Cleanup()|r') --local showQuestPOI = db.Config.EnablePins numShown = 0 numLoaded = 0 @@ -522,7 +632,7 @@ if pin.used then pin.throttle = 1 if oV == false then - print('|cFF00FF00cleanup +|r', questID, pin.title) + rprint('|cFF00FF00cleanup +|r', questID, pin.title) end pin:SetShown(true) numShown = numShown + 1 @@ -532,12 +642,13 @@ else if oV == true then - print('|cFFFF4400 -|r', questID, pin.title) + rprint('|cFFFF4400 -|r', questID, pin.title) end pin:HideFrames() end end + print(numShown, 'shown', numLoaded, 'loaded') if numShown > numLoaded then self.Status:Show() end @@ -566,7 +677,7 @@ end - print('~ ', pin.mapID, pin.questID, pin.title) + --print(' |- ', pin.questID, pin.title) rprint('|cFF00FF00update|r', pin.questID, pin.title) if x and y then @@ -603,8 +714,8 @@ self.hostWidth, self.hostHeight = WorldMapPOIFrame:GetSize() self.nudgeThrescholdX = 16/self.hostWidth self.nudgeThrescholdY = 16/self.hostHeight - local print = rprint - print('|cFF00FF00'..self:GetName()..':UpdateAnchors()') + + rprint('|cFF00FF00'..self:GetName()..':UpdateAnchors()') local mapFileName, textureHeight, textureWidth, isMicroDungeon, microDungeonMapName = GetMapInfo() if isMicroDungeon then return @@ -613,15 +724,15 @@ isDataLoaded = true numPins = 0 - local taskInfo = TQ_GetQuestsForPlayerByMapID(self.currentMapID) + local taskInfo = TQ_GetQuestsForPlayerByMapID(db.currentMapID) if taskInfo then - self:UpdateMap(taskInfo, self.currentMapID) + self:UpdateMap(taskInfo, db.currentMapID) end - local numZones = MC_GetNumZones(self.currentMapID) + local numZones = MC_GetNumZones(db.currentMapID) if numZones then for i = 1, numZones do - local mapAreaID = MC_GetZoneInfo(self.currentMapID, i) - local taskInfo = TQ_GetQuestsForPlayerByMapID(mapAreaID, self.currentMapID) + local mapAreaID = MC_GetZoneInfo(db.currentMapID, i) + local taskInfo = TQ_GetQuestsForPlayerByMapID(mapAreaID, db.currentMapID) if taskInfo then self:UpdateMap(taskInfo, mapAreaID) end @@ -629,3 +740,11 @@ end end +function ToggleButton:OnShow() + self:SetChecked(db.Config.EnablePins and true or false) +end +function ToggleButton:OnClick() + print(self:GetChecked()) + db.Config.EnablePins = self:GetChecked() + _G.WorldPlan:OnConfigUpdate() +end \ No newline at end of file