# HG changeset patch # User Nenue # Date 1478238039 14400 # Node ID 21bcff08b0f4b55a8326ef9316a0346b33792e75 # Parent 26dfa661daa7a63f9d10f092c7e97d2cd9c92750 WorldPlan: - Quest pins are now placed on the flight map. Their visibility rules will mirror the filter options from the world map. - Filter controls polish: - First click negates other reward type filters. Subsequent clicks will then toggle individual reward types until the filters are reset via Right-click. - Adheres to the Blizzard CVars added in patch 7.1 - Numerous optimizations to how data and visual updates are handled; should see an even better load time, and snappier world map interaction. ClassPlan: - The 'Available Missions' list is now recorded. It can be reviewed by clicking on the mission list heading. - Information filtering by character and realm. diff -r 26dfa661daa7 -r 21bcff08b0f4 FilterBar.lua --- a/FilterBar.lua Thu Nov 03 17:29:15 2016 -0400 +++ b/FilterBar.lua Fri Nov 04 01:40:39 2016 -0400 @@ -40,9 +40,9 @@ local familiars_id = 9696 local DEFAULT_FILTER_LAYOUT = { - PinSize = 22, - Border = 3, - TrackingBorder = 2, + iconWidth = 24, + borderWidth = 3, + highlightWidth = 2, TagSize = 12, TimeleftStage = 3, showNumber = true, @@ -161,7 +161,9 @@ local numHeaders = 0 print('|cFF00FF88'..self:GetName()..':Update()|r', 'currentMap=',WorldPlan.currentMapID) - + local layout = DEFAULT_FILTER_LAYOUT + local borderWidth = layout.iconWidth + (layout.borderWidth * 2) + local highlightWidth = borderWidth + (layout.highlightWidth * 2) local quests = WorldPlanQuests.QuestsByZone[WorldPlan.currentMapID] or WorldPlanQuests.QuestsByID local foundQuests = questResults[1] for index, info in ipairs(self.filterList) do @@ -186,25 +188,22 @@ local button = blocks[numHeaders] if not blocks[numHeaders] then button = CreateFrame('Button', 'WorldPlanFilterButton'..numHeaders, WorldMapScrollFrame, 'WorldPlanFilterPin') + button:SetSize(borderWidth, borderWidth) - button:SetSize(24,24) - button.icon:ClearAllPoints() - button.icon:SetAllPoints(button) + button.icon:SetSize(layout.iconWidth, layout.iconWidth) + button.RewardBorder:SetSize(borderWidth, borderWidth) + button.HighlightBorder:SetSize(highlightWidth, highlightWidth) + button.RewardBorder:SetMask(filterMask) + button.RewardBorder:SetDesaturated(true) - button.iconBorder:SetPoint('TOPLEFT', button, 'TOPLEFT', -2, 2) - button.iconBorder:SetPoint('BOTTOMRIGHT', button, 'BOTTOMRIGHT', 2, -2) - button.iconBorder:SetMask(filterMask) - button.iconBorder:SetTexture(filterFill) - button.iconBorder:SetDesaturated(true) - - button.supertrackBorder:Hide() + button.HighlightBorder:Hide() blocks[numHeaders] = button end button.info = info button.questList = questResults[resultIndex] button:SetID(index) - button.spacing = ((info.filterKey ~= relativeFrame.filterKey) and 10) or 0 + button.spacing = ((relativeFrame.cVar and (not info.cVar)) or (relativeFrame.filterKey ~= info.filterKey)) and 5 or 0 button.relativeFrame = relativeFrame button:Refresh((numHeaders == 1), numQuests) button:Show() @@ -233,21 +232,12 @@ function WorldPlanFilterPinMixin:OnEnter() if self.questList and #self.questList >= 1 then GameTooltip:SetOwner(self, 'ANCHOR_LEFT') - GameTooltip_ClearInsertedFrames(GameTooltip) GameTooltip:AddLine(self.info.label) for index, pin in ipairs(self.questList) do local colorInfo = (pin.quality and ITEM_QUALITY_COLORS[pin.quality]) or rgbWhite - GameTooltip:AddLine(pin.title ..(pin.cheevos and " |cFFFFFF00!|R" or ''), colorInfo.r, colorInfo.g, colorInfo.b) - GameTooltip:AddTexture(pin.itemTexture) - local cLine = GameTooltip:NumLines() - 1 - --print(cLine, _G['GameTooltipTexture'..cLine]:GetTexture()) - if type(pin.itemTexture) == 'number' then - --- voodoo workaround for IDs getting coerced to string - _G['GameTooltipTexture'..cLine]:Show() - _G['GameTooltipTexture'..cLine]:SetTexture(pin.itemTexture) - end - GameTooltip:Show() + GameTooltip:AddLine('|T'.. tostring(pin.itemTexture)..':16:16|t ' .. pin.title ..(pin.cheevos and " |cFFFFFF00!|R" or ''), colorInfo.r, colorInfo.g, colorInfo.b) end + GameTooltip:Show() end end @@ -279,14 +269,14 @@ if isFirst then self:SetPoint('TOP', self.relativeFrame, 'BOTTOM', 0, -5) else - self:SetPoint('TOPRIGHT', self.relativeFrame, 'BOTTOMRIGHT', 0, -(3 + (self.spacing or 0))) + self:SetPoint('TOPRIGHT', self.relativeFrame, 'BOTTOMRIGHT', 0, -(self.spacing or 0)) end print('anchor to', self.relativeFrame:GetName(), info.mask) local r, g, b, a = 1,1,1,1 local desaturated = false if self.cVar then - self.iconBorder:SetVertexColor(1, 1, 1, 1) + self.RewardBorder:SetVertexColor(1, 1, 1, 1) if GetCVarBool(self.cVar) then self.icon:SetVertexColor(1,1,1,1) self:SetAlpha(1) @@ -298,12 +288,20 @@ self:SetAlpha(1) if WorldPlan.UsedFilters[self.filterKey] then if WorldPlan.UsedFilters[self.filterKey] == self.filterValue then - self.iconBorder:SetVertexColor(0, 1, 0) + self.RewardBorder:SetVertexColor(0, 1, 0) else - self.iconBorder:SetVertexColor(1, 0, 0) + self.RewardBorder:SetVertexColor(1, 0, 0) end else - self.iconBorder:SetVertexColor(1, 1, 1, 1) + if self.filterKey == 'worldQuestType' then + self.RewardBorder:SetVertexColor(0, 1, 1) + elseif self.filterKey == 'factionID' then + self.RewardBorder:SetVertexColor(1, 1, 0) + else + + self.RewardBorder:SetVertexColor(0.5, 0.5, 0.5) + end + end end @@ -315,6 +313,7 @@ self:SetFrameStrata('HIGH') self:SetFrameLevel(151) self:SetScript('OnUpdate', nil) + WorldPlanPOIMixin.OnLoad(self) end function WorldPlanFilterPinMixin:OnUpdate () @@ -329,43 +328,69 @@ -- shift-click: reset filter -- click: rotate through include(1), exclude(-1), ignore(nil) +local filtered_report = {} function WorldPlanFilterPinMixin:OnClick (button) print('|cFF00FF88'..self:GetName()..':OnClick()|r', filterKey, filterValue, operation) local filterKey = self.filterKey local filterValue = self.filterValue + local cVar = self.cVar + local parent = self:GetParent() + local operation = opPrefix + local setDirty = false - - local operation = opPrefix - - - if not filterKey then + local resetMode = (button == 'RightButton') + wipe(filtered_report) + if not (filterKey or cVar) then wipe(WorldPlan.UsedFilters) for i, info in ipairs(DEFAULT_FILTER_LIST) do if info.cVar then + if GetCVar(info.cVar) ~= 1 then + tinsert(filtered_report, '|cFF888888'.. tostring(info.label) ..'|r') + end SetCVar(info.cVar, 1) end end - elseif self.cVar then + elseif cVar then + WorldPlan:print('Toggling cvar filter:', cVar) + if (not parent.isDirty) or resetMode then for i, info in ipairs(DEFAULT_FILTER_LIST) do if info.cVar then - if (info.cVar ~= self.cVar) and (button == 'LeftButton') then - SetCVar(info.cVar, 0) + local value = GetCVar(info.cVar) + if resetMode then + value = 1 + parent.isDirty = nil else - SetCVar(info.cVar, 1) + + if (cVar ~= info.cVar) then + value = 0 + else + value = 1 + end + setDirty = true + end + SetCVar(info.cVar, value) end end + if setDirty then + parent.isDirty = true + end + else + SetCVar(cVar, (GetCVarBool(cVar) and 0) or 1) + end else - local setInclude = (button == 'LeftButton') local flushValue print('') if WorldPlan.UsedFilters[filterKey] == filterValue then WorldPlan.UsedFilters[filterKey] = nil + tinsert(filtered_report, '|cFFFF0000'.. tostring(filterKey) ..'|r') else WorldPlan.UsedFilters[filterKey] = filterValue + tinsert(filtered_report, '|cFF00FF00'.. tostring(filterKey) ..'|r') end end + WorldPlan:print('Changed:', table.concat(filtered_report, ', ')) WorldPlan:Refresh(true) end \ No newline at end of file diff -r 26dfa661daa7 -r 21bcff08b0f4 FlightMap.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FlightMap.lua Fri Nov 04 01:40:39 2016 -0400 @@ -0,0 +1,132 @@ + +local print = DEVIAN_WORKSPACE and function(...) _G.print('Canvas', ...) end or function() end +local wprint = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end +local wipe, pairs, ipairs = wipe, pairs, ipairs +local HaveQuestData, QuestUtils_IsQuestWorldQuest, C_MapCanvas, C_TaskQuest = HaveQuestData, QuestUtils_IsQuestWorldQuest, C_MapCanvas, C_TaskQuest + +WorldPlanFlightMapHandler = { + TaskQueue = {} +} +WorldPlanDataProvider = {} +WorldPlanDataPinMixin = {} + +function WorldPlanFlightMapHandler:OnLoad() + print('MapCanvas Module') + self:RegisterEvent('ADDON_LOADED') +end +function WorldPlanFlightMapHandler:OnEvent(event, arg) + if arg == "Blizzard_FlightMap" then + print('sending data provider') + local dataProvider = Mixin(MapCanvasDataProviderMixin, WorldPlanDataProvider) + WorldPlanDataPinMixin = Mixin(MapCanvasPinMixin, WorldPlanDataPinMixin) + WorldPlanDataPinMixin.OnNext = function(...) self:OnNext(...) end + FlightMapFrame:AddDataProvider(dataProvider) + end +end + +function WorldPlanFlightMapHandler:OnNext(func) + tinsert(self.TaskQueue, func) +end + +function WorldPlanFlightMapHandler:OnUpdate() + if #self.TaskQueue >= 1 then + print('firing scheduled task ('.. tostring(#self.TaskQueue) ..' remaining)') + local func = tremove(self.TaskQueue, 1) + func() + end +end + +function WorldPlanDataProvider:OnShow() + assert(self.ticker == nil); + self.ticker = C_Timer.NewTicker(10, function() self:RefreshAllData() end); +end +function WorldPlanDataProvider:OnHide() + self.ticker:Cancel(); + self.ticker = nil; +end + +function WorldPlanDataProvider:OnAdded(mapCanvas) + self.activePins = {}; + self.owningMap = mapCanvas +end + + +function WorldPlanDataProvider:RefreshAllData() + local print = print + print('|cFFFF0088'..self.owningMap:GetName()..':RefreshAllData()|r') + + + local pinsToRemove = {}; + for questId in pairs(self.activePins) do + pinsToRemove[questId] = true; + end + + + local mapAreaID = self:GetMap():GetMapID(); + for zoneIndex = 1, C_MapCanvas.GetNumZones(mapAreaID) do + local zoneMapID, zoneName, zoneDepth, left, right, top, bottom = C_MapCanvas.GetZoneInfo(mapAreaID, zoneIndex); + print(zoneMapID, zoneName) + if zoneDepth <= 1 then -- Exclude subzones + local taskInfo = C_TaskQuest.GetQuestsForPlayerByMapID(zoneMapID, mapAreaID); + + if taskInfo then + for i, info in ipairs(taskInfo) do + if HaveQuestData(info.questId) then + if QuestUtils_IsQuestWorldQuest(info.questId) then + local pin = WorldPlanQuests:AcquirePin(info.questId, zoneMapID) + pin:RefreshData(info) + pin:IsShowable() + if pin.used then + print(i, pin.x, pin.y, pin.used, pin.isNew, pin.isStale, pin:IsShown(), pin:GetAlpha()) + pinsToRemove[info.questId] = nil; + + local frame = self.activePins[info.questId] + if not frame then + frame = self:GetMap():AcquirePin("WorldPlanFlightPin") + frame:SetAlphaLimits(1, 0.7, 1) + frame:SetScalingLimits(1, 3, 1.5); + frame:SetFrameLevel(1000 + self:GetMap():GetNumActivePinsByTemplate("WorldPlanFlightPin")); + frame:Show() + self.activePins[info.questId] = frame + end + frame:SetPosition(info.x, info.y) + frame.pin = pin + + pin.isStale = true + pin:SetParent(frame) + pin:ClearAllPoints() + pin:SetPoint('CENTER', frame, 'CENTER') + + end + pin:SetShown(pin.used) + end + end + end + end + end + end + + for questId in pairs(pinsToRemove) do + self:GetMap():RemovePin(self.activePins[questId]); + self.activePins[questId] = nil; + end + --self:GetMap():RemoveAllPinsByTemplate("WorldQuestPinTemplate"); + +end + +function WorldPlanDataPinMixin:OnShow() + print('|cFFFFFF00'..tostring(self:GetName())..':OnShow()|r') +end + +function WorldPlanDataPinMixin:OnMouseEnter () + self.pin:OnEnter() +end + +function WorldPlanDataPinMixin:OnMouseLeave () + self.pin:OnLeave() +end + +function WorldPlanDataPinMixin:RemoveAllData() + wipe(self.activePins); + self:GetMap():RemoveAllPinsByTemplate("WorldPlanFlightPin"); +end \ No newline at end of file diff -r 26dfa661daa7 -r 21bcff08b0f4 FlightMap.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/FlightMap.xml Fri Nov 04 01:40:39 2016 -0400 @@ -0,0 +1,18 @@ + +