annotate QuestPOI.lua @ 27:4a7e89bffbcb r27-beta

- Order Hall resource rewards now show numerals in quest pins. - Fixed an occasional lua error that occurs when opening the quest map for the first time. - Fixed another source of textures losing their masks.
author Nenue
date Thu, 27 Oct 2016 06:18:16 -0400
parents a2b623043970
children c1612c2c1840
rev   line source
Nenue@7 1 -- WorldPlan
Nenue@7 2 -- QuestPOI.lua
Nenue@7 3 -- Created: 10/1/2016 7:21 PM
Nenue@7 4 -- %file-revision%
Nenue@7 5 --
Nenue@7 6 local TQ_GetQuestLocation = C_TaskQuest.GetQuestLocation
Nenue@7 7 local TQ_GetQuestTimeLeftMinutes = C_TaskQuest.GetQuestTimeLeftMinutes
Nenue@9 8 local TQ_IsActive = C_TaskQuest.IsActive
Nenue@7 9 local QuestPOIGetIconInfo, WorldMapPOIFrame = QuestPOIGetIconInfo, WorldMapPOIFrame
Nenue@7 10
Nenue@7 11 local print = DEVIAN_WORKSPACE and function(...) _G.print('WP', ...) end or function() end
Nenue@7 12 local qprint = DEVIAN_WORKSPACE and function(...) _G.print('POI', ...) end or function() end
Nenue@7 13 local iprint = DEVIAN_WORKSPACE and function(...) _G.print('ItemScan', ...) end or function() end
Nenue@7 14 local QuestPOI = WorldPlanPOIMixin
Nenue@7 15
Nenue@9 16 local ICON_UNKNOWN = "Interface\\ICONS\\inv_misc_questionmark"
Nenue@9 17 local ICON_MONEY = "Interface\\Buttons\\UI-GroupLoot-Coin-Up"
Nenue@9 18
Nenue@9 19 local POI_BORDER_MASK = "Interface\\Minimap\\UI-Minimap-Background"
Nenue@9 20 local POI_BORDER_FILL = "Interface\\BUTTONS\\YELLOWORANGE64"
Nenue@9 21 local POI_BORDER_BLUE = "Interface\\BUTTONS\\GRADBLUE"
Nenue@9 22 local POI_BORDER_RED = "Interface\\BUTTONS\\RedGrad64"
Nenue@9 23 local POI_BORDER_YELLOW = "Interface\\BUTTONS\\YELLOWORANGE64"
Nenue@9 24 local POI_BORDER_GREEN = "Interface\\BUTTONS\\GREENGRAD64"
Nenue@9 25
Nenue@7 26 local familiars = {
Nenue@7 27 [42159] = {npc = 106552, name = 'Nightwatcher Merayl'},
Nenue@7 28 [40277] = {npc = 97804, name = 'Tiffany Nelson'},
Nenue@7 29 [40298] = {npc = 99182, name = 'Sir Galveston'},
Nenue@7 30 [40282] = {npc= 99150, name = 'Grixis Tinypop'},
Nenue@7 31 [40278] = {npc = 98270, name = 'Robert Craig'},
Nenue@7 32 [48195] = {npc = 105250, name = 'Aulier'},
Nenue@7 33 [41990] = {npc = 105674, name = 'Varenne'},
Nenue@7 34 [41860] = {npc = 104970, name = 'Xorvasc'},
Nenue@7 35 [40299] = {npc = 99210, name = 'Bodhi Sunwayver'},
Nenue@7 36 [42442] = {npc = 107489, name = 'Amalia'},
Nenue@7 37 [40280] = {npc = 99077, name = 'Bredda Tenderhide'},
Nenue@7 38 [41687] = {npc = 104553, name = 'Odrogg'},
Nenue@7 39 [41944] = {npc = 105455, name = 'Trapper Jarrun'},
Nenue@7 40 [40337] = {npc = 97709, name = 'Master Tamer Flummox'},
Nenue@7 41 [40279] = {npc = 99035, name = 'Durian Strongfruit'}
Nenue@7 42 }
Nenue@7 43 local familiars_id = 9696
Nenue@7 44
Nenue@7 45
Nenue@7 46 local PIN_TIME_CONTEXT = {
Nenue@7 47 {max = 60,
Nenue@7 48 r=1, g=0.25, b =0, format = function (minutes) return '|cFFFF4400'.. minutes .. 'm' end,
Nenue@7 49 continentAlpha = 1, swipeTime = 1440,
Nenue@7 50 },
Nenue@7 51 {max = 240,
Nenue@7 52 r=1, g=.5, b=0, format = function(minutes) return '|cFFFF4400'.. floor(minutes/60) .. 'h' end,
Nenue@7 53 continentAlpha = 1, swipeTime = 1440,
Nenue@7 54 },
Nenue@7 55 {max = 1440,
Nenue@7 56 r=1, g=1, b=0, format = function(minutes) return '|cFFFFFF00'.. floor(minutes/60) .. 'h' end,
Nenue@7 57 continentAlpha = .55, swipeTime = 1440
Nenue@7 58 },
Nenue@7 59 {max = 10081,
Nenue@7 60 r=0, g=1, b=0,
Nenue@7 61 continentAlpha = .3,
Nenue@7 62 }, -- 7 days + 1 minute
Nenue@7 63 }
Nenue@7 64
Nenue@9 65 -- update a masked texture without messing up its blending mask
Nenue@9 66 local SetMaskedTexture = function(region, file, mask)
Nenue@9 67 mask = mask or POI_BORDER_MASK
Nenue@9 68 region:SetMask(nil)
Nenue@9 69 region:SetTexture(file)
Nenue@9 70 region:SetMask(mask)
Nenue@9 71 end
Nenue@7 72
Nenue@27 73 function WorldPlanPOIMixin:OnEnter()
Nenue@7 74 local completed = select(4,GetAchievementInfo(familiars_id))
Nenue@7 75 if not completed then
Nenue@7 76 if self.worldQuestType == LE_QUEST_TAG_TYPE_PET_BATTLE and familiars[self.questID] then
Nenue@7 77 WorldMapTooltip:SetOwner(self, 'ANCHOR_RIGHT')
Nenue@7 78 WorldMapTooltip:AddLine('Family Familiars')
Nenue@7 79 local trainer = familiars[self.questID].name
Nenue@7 80 local numCheevs = GetAchievementNumCriteria(familiars_id)
Nenue@7 81 for index = 1, numCheevs do
Nenue@7 82 local cheevName, cType, cCompleted, quantity, requiredQuantity, charName, flags, cheevID, quantityString, criteriaID = GetAchievementCriteriaInfo(familiars_id, index)
Nenue@7 83 local numTrainers = GetAchievementNumCriteria(cheevID)
Nenue@7 84 for subIndex = 1, numTrainers do
Nenue@7 85 local desc, cType, partCompleted = GetAchievementCriteriaInfo(cheevID, subIndex)
Nenue@7 86 if desc == trainer then
Nenue@7 87 if not partCompleted then
Nenue@7 88 local iconPath = select(10, GetAchievementInfo(cheevID))
Nenue@7 89 WorldMapTooltip:AddLine(cheevName)
Nenue@7 90 WorldMapTooltip:AddTexture(iconPath)
Nenue@7 91 end
Nenue@7 92 end
Nenue@7 93 end
Nenue@7 94 end
Nenue@7 95 WorldMapTooltip:Show()
Nenue@7 96 return
Nenue@7 97 end
Nenue@7 98 end
Nenue@7 99 TaskPOI_OnEnter(self)
Nenue@7 100 end
Nenue@27 101 function WorldPlanPOIMixin:OnLeave()
Nenue@7 102 TaskPOI_OnLeave(self)
Nenue@7 103 end
Nenue@27 104 function WorldPlanPOIMixin:OnMouseDown()
Nenue@7 105 TaskPOI_OnClick(self)
Nenue@7 106 end
Nenue@7 107
Nenue@7 108
Nenue@7 109 function WorldPlanPOIMixin:SetAchievementProgressTooltip()
Nenue@7 110 print('cheevos')
Nenue@7 111
Nenue@7 112
Nenue@7 113 end
Nenue@7 114
Nenue@27 115 function WorldPlanPOIMixin:ShowNew()
Nenue@27 116 self:SetShown(true)
Nenue@27 117 self.isNew = nil
Nenue@27 118 self.FadeIn:Play()
Nenue@7 119 end
Nenue@7 120
Nenue@27 121 function WorldPlanPOIMixin:OnShow ()
Nenue@27 122 qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnShow() update:', self.hasUpdate, 'new:', self.isNew, 'animation:', self.isAnimating)
Nenue@27 123 qprint(debugstack())
Nenue@27 124 -- pop this on principle
Nenue@27 125 if self.hasUpdate then
Nenue@27 126
Nenue@27 127 self:Refresh()
Nenue@27 128 end
Nenue@27 129
Nenue@27 130 end
Nenue@27 131 function WorldPlanPOIMixin:OnHide()
Nenue@27 132 qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnHide()')
Nenue@27 133 end
Nenue@27 134
Nenue@27 135 function WorldPlanPOIMixin:SetAnchor(frame, mapID, mapWidth, mapHeight)
Nenue@7 136 self:ClearAllPoints()
Nenue@7 137 local dX, dY = TQ_GetQuestLocation(self.questID, mapID)
Nenue@7 138 if not dX or dX == 0 then
Nenue@7 139 local _, x, y = QuestPOIGetIconInfo(self.questID)
Nenue@7 140 if x and floor(x) ~= 0 then
Nenue@7 141 dX, dY = x, y
Nenue@7 142 else
Nenue@7 143 dX, dY = self.x, self.y
Nenue@7 144 end
Nenue@7 145 end
Nenue@7 146 self.x = dX
Nenue@7 147 self.y = dY
Nenue@7 148
Nenue@9 149 qprint(' |cFF00FF00'..self.questID..':|r', format("%0.2f %0.2f", dX, dY))
Nenue@7 150
Nenue@7 151 local pX = (dX * mapWidth)
Nenue@7 152 local pY = (-dY * mapHeight)
Nenue@7 153
Nenue@7 154 self:SetParent(WorldMapPOIFrame)
Nenue@7 155 self:SetPoint('CENTER', frame, 'TOPLEFT', pX, pY)
Nenue@7 156 end
Nenue@7 157
Nenue@7 158
Nenue@27 159 function WorldPlanPOIMixin:OnLoad()
Nenue@27 160 qprint('|cFF00FF88'..self:GetName()..':OnLoad()|r',WorldPlan.db)
Nenue@7 161 self:RegisterEvent('SUPER_TRACKED_QUEST_CHANGED')
Nenue@27 162 self.style = WorldPlan.db.defaultPinStyle
Nenue@27 163 self.subStyle = WorldPlan.db.defaultPinStyle.continent
Nenue@7 164 end
Nenue@7 165
Nenue@27 166 function WorldPlanPOIMixin:OnEvent(event, ...)
Nenue@7 167 if event == 'SUPER_TRACKED_QUEST_CHANGED' then
Nenue@7 168 if self:IsVisible() then
Nenue@7 169 self:Refresh()
Nenue@7 170 end
Nenue@7 171 end
Nenue@7 172 end
Nenue@7 173
Nenue@7 174
Nenue@7 175 local PIN_UPDATE_DELAY = .016
Nenue@7 176 local TOP_PIN_ID
Nenue@27 177 function WorldPlanPOIMixin:OnUpdate (sinceLast)
Nenue@7 178 -- control update check intervals
Nenue@7 179 self.throttle = (self.throttle or PIN_UPDATE_DELAY) - sinceLast
Nenue@7 180 if self.throttle <= 0 then
Nenue@7 181 -- factor overtime into the throttle timer
Nenue@7 182 self.throttle = PIN_UPDATE_DELAY - self.throttle
Nenue@7 183 else
Nenue@7 184 return
Nenue@7 185 end
Nenue@7 186
Nenue@7 187 -- query for reward data if it wasn't found in the original scan
Nenue@7 188 local questID = self.questID
Nenue@7 189 if self.isPending then
Nenue@7 190 self:Reset()
Nenue@7 191 if not (self.PendingFade:IsPlaying() or self.isAnimating) then
Nenue@7 192 self.PendingFade:Play()
Nenue@7 193 end
Nenue@7 194 return
Nenue@7 195 else
Nenue@7 196 if self.PendingFade:IsPlaying() then
Nenue@7 197 self.PendingFade:Stop()
Nenue@7 198 end
Nenue@7 199 end
Nenue@7 200
Nenue@7 201 if self.hasUpdate then
Nenue@7 202 self:Refresh()
Nenue@7 203 self.hasUpdate = nil
Nenue@7 204 end
Nenue@7 205
Nenue@7 206 -- update time elements
Nenue@7 207 local tl = self.timeThreschold
Nenue@7 208 local timeLeft = TQ_GetQuestTimeLeftMinutes(questID)
Nenue@7 209 if timeLeft > 0 then
Nenue@7 210 for i, context in ipairs(PIN_TIME_CONTEXT) do
Nenue@7 211 if i > self.TimeleftStage then
Nenue@7 212 self.timeLabel:SetText(nil)
Nenue@7 213 break
Nenue@7 214 end
Nenue@7 215
Nenue@7 216
Nenue@7 217 if timeLeft <= context.max then
Nenue@7 218 if tl ~= i then
Nenue@7 219 tl = i
Nenue@7 220 end
Nenue@7 221
Nenue@7 222 if context.format then
Nenue@7 223 self.timeLabel:SetText(context.format(timeLeft))
Nenue@7 224 else
Nenue@7 225 self.timeLabel:SetText(nil)
Nenue@7 226 end
Nenue@7 227 break
Nenue@7 228 end
Nenue@7 229 end
Nenue@7 230 else
Nenue@7 231 -- remove self in a timely manner
Nenue@9 232 if not TQ_IsActive(self.questID) then
Nenue@9 233 print('|cFFFF4400'..self:GetName()..' pin hard timeout')
Nenue@9 234 if self.worldQuestType ~= LE_QUEST_TAG_TYPE_PROFESSION then
Nenue@9 235 self:Hide()
Nenue@9 236 end
Nenue@7 237 end
Nenue@7 238 end
Nenue@7 239 self.timeThreschold = tl
Nenue@7 240
Nenue@7 241 if self:IsMouseOver() then
Nenue@7 242 self.MouseGlow:Show()
Nenue@7 243 else
Nenue@7 244 self.MouseGlow:Hide()
Nenue@7 245 end
Nenue@8 246 end
Nenue@8 247
Nenue@8 248
Nenue@9 249
Nenue@27 250 function WorldPlanPOIMixin:Refresh ()
Nenue@9 251 local db = WorldPlan.db
Nenue@9 252 local print = qprint
Nenue@9 253 print('|cFF00FF88["'..tostring(self.title)..'"]|r:Refresh()', tostring(self.title), "|T"..tostring(self.itemTexture)..":12:12|t", tostring(self.itemName))
Nenue@9 254 print(self.style)
Nenue@9 255
Nenue@9 256
Nenue@9 257
Nenue@9 258 local questID = self.questId
Nenue@9 259 local style = self.style
Nenue@27 260 local subStyle = style[(self.filtered and 'minimized' or 'continent')]
Nenue@9 261 local borderMask = style.mask
Nenue@9 262 local borderFill = style.texture
Nenue@9 263 local iconBorder = self.iconBorder
Nenue@9 264 local icon = self.icon
Nenue@9 265 local count = self.count
Nenue@9 266
Nenue@27 267 self.subStyle = subStyle
Nenue@27 268 self.hasNumeric = style.hasNumeric
Nenue@27 269 self.numberRGB = style.numberRGB
Nenue@27 270 self.showNumber = subStyle.showNumber
Nenue@9 271
Nenue@27 272
Nenue@9 273 print(' - subStyle:', (self.filtered == true), self.subStyle)
Nenue@9 274
Nenue@9 275 --WorldPlan:print(tostring(self.title), "|T"..tostring(self.itemTexture)..":16:16|t", tostring(self.itemName))
Nenue@9 276 SetMaskedTexture(icon, self.itemTexture or ICON_UNKNOWN, borderMask)
Nenue@9 277 icon:SetAllPoints(self)
Nenue@9 278
Nenue@9 279 if self.itemName then
Nenue@9 280 local color = self.rewardColor or COMMON_COLOR
Nenue@27 281
Nenue@27 282
Nenue@27 283 self.label:SetShown( self.showNumber)
Nenue@27 284 if self.hasNumeric then
Nenue@27 285 self.label:SetText(self.itemNumber)
Nenue@27 286 self.label:SetTextColor(unpack(self.numberRGB))
Nenue@9 287 else
Nenue@27 288 self.label:SetText(nil)
Nenue@9 289 end
Nenue@27 290
Nenue@9 291 end
Nenue@9 292
Nenue@9 293 SetMaskedTexture(iconBorder, borderFill, borderMask)
Nenue@9 294 local border = (self.rewardType and db.rewardStyle[self.rewardType]) or (WORLD_QUEST_QUALITY_COLORS[self.rarity] or db.defaultStyle)
Nenue@9 295 iconBorder:SetVertexColor(border.r, border.g, border.b, border.a)
Nenue@9 296 iconBorder:SetDesaturated(true)
Nenue@9 297
Nenue@9 298 local trackingBorder = self.supertrackBorder
Nenue@9 299
Nenue@9 300 self.highlight:SetMask(nil)
Nenue@9 301 if questID == GetSuperTrackedQuestID() then
Nenue@9 302 trackingBorder:SetVertexColor(0,0,0,1)
Nenue@9 303 else
Nenue@9 304 trackingBorder:SetVertexColor(0,0,0,0.5)
Nenue@9 305 end
Nenue@9 306 self.highlight:SetAllPoints(trackingBorder)
Nenue@9 307
Nenue@9 308 SetMaskedTexture(trackingBorder, borderFill, borderMask)
Nenue@9 309 self.highlight:SetMask(borderMask)
Nenue@9 310
Nenue@9 311 local qType = self.worldQuestType
Nenue@9 312 self.tagIcon:SetAtlas(self.tagAtlas)
Nenue@9 313 self.tagIcon:SetTexCoord(0,1,0,1)
Nenue@9 314
Nenue@9 315
Nenue@9 316 if self.isElite then
Nenue@9 317 self.EliteDecal:Show()
Nenue@9 318 else
Nenue@9 319 self.EliteDecal:Hide()
Nenue@9 320 end
Nenue@9 321 qprint('|cFF88FF00updated', questID, self.title, self.rewardType, (style.showNumber and self.itemNumber) or '')
Nenue@9 322
Nenue@9 323
Nenue@9 324 self:UpdateSize()
Nenue@27 325 self.hasUpdate = nil
Nenue@9 326 end
Nenue@9 327
Nenue@8 328 function WorldPlanFilterPinMixin:OnEnter ()
Nenue@8 329 local filter = WorldPlan.FilterOptions[self:GetID()]
Nenue@8 330 local mapID = GetCurrentMapAreaID()
Nenue@8 331 local quests = (mapID == WorldPlan.BrokenIsleID) and WorldPlan.QuestsByID or WorldPlan.QuestsByZone[mapID]
Nenue@8 332 if quests then
Nenue@8 333 GameTooltip:SetOwner(self, 'ANCHOR_RIGHT')
Nenue@8 334 GameTooltip:AddLine(filter.label)
Nenue@8 335 local filterKey = self.filterKey
Nenue@8 336 local filterValue = self.filterValue
Nenue@8 337 if filterKey then
Nenue@8 338 for questID, pin in pairs(quests) do
Nenue@8 339 if pin.used and not pin.filtered then
Nenue@8 340 if pin[filterKey] == filterValue then
Nenue@8 341 local style = pin.style or WorldPlan.FilterStyle
Nenue@8 342
Nenue@8 343 if familiars[questID] then
Nenue@8 344 GameTooltip:AddLine(pin.title,0,1,0)
Nenue@8 345 else
Nenue@8 346 GameTooltip:AddLine(pin.title,1,1,1)
Nenue@8 347 end
Nenue@8 348
Nenue@8 349 end
Nenue@8 350 end
Nenue@8 351 end
Nenue@8 352 else
Nenue@8 353 GameTooltip:AddLine('Reset all filters')
Nenue@8 354 end
Nenue@8 355 GameTooltip:Show()
Nenue@8 356 end
Nenue@7 357 end