annotate QuestPOI.lua @ 12:3396a1171081

Added tag v1.0-rc2 for changeset a42820c45da9
author Nenue
date Sun, 23 Oct 2016 17:22:21 -0400
parents a2b623043970
children 4a7e89bffbcb
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@7 73 function QuestPOI: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@7 101 function QuestPOI:OnLeave()
Nenue@7 102 TaskPOI_OnLeave(self)
Nenue@7 103 end
Nenue@7 104 function QuestPOI: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@7 115
Nenue@7 116 function QuestPOI:OnShow ()
Nenue@7 117 qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnShow()')
Nenue@7 118 -- pop this on principle
Nenue@7 119 self:Refresh()
Nenue@7 120 end
Nenue@7 121 function QuestPOI:OnHide()
Nenue@7 122 --qprint('|cFFFFFF00["'..tostring(self.title)..'"]|r:OnHide()')
Nenue@7 123 end
Nenue@7 124
Nenue@7 125 function QuestPOI:SetAnchor(frame, mapID, mapWidth, mapHeight)
Nenue@7 126 self:ClearAllPoints()
Nenue@7 127 local dX, dY = TQ_GetQuestLocation(self.questID, mapID)
Nenue@7 128 if not dX or dX == 0 then
Nenue@7 129 local _, x, y = QuestPOIGetIconInfo(self.questID)
Nenue@7 130 if x and floor(x) ~= 0 then
Nenue@7 131 dX, dY = x, y
Nenue@7 132 else
Nenue@7 133 dX, dY = self.x, self.y
Nenue@7 134 end
Nenue@7 135 end
Nenue@7 136 self.x = dX
Nenue@7 137 self.y = dY
Nenue@7 138
Nenue@9 139 qprint(' |cFF00FF00'..self.questID..':|r', format("%0.2f %0.2f", dX, dY))
Nenue@7 140
Nenue@7 141 local pX = (dX * mapWidth)
Nenue@7 142 local pY = (-dY * mapHeight)
Nenue@7 143
Nenue@7 144 self:SetParent(WorldMapPOIFrame)
Nenue@7 145 self:SetPoint('CENTER', frame, 'TOPLEFT', pX, pY)
Nenue@7 146 end
Nenue@7 147
Nenue@7 148
Nenue@7 149 function QuestPOI:OnLoad()
Nenue@7 150 self:RegisterEvent('SUPER_TRACKED_QUEST_CHANGED')
Nenue@7 151 end
Nenue@7 152
Nenue@7 153 function QuestPOI:OnEvent(event, ...)
Nenue@7 154 if event == 'SUPER_TRACKED_QUEST_CHANGED' then
Nenue@7 155 if self:IsVisible() then
Nenue@7 156 self:Refresh()
Nenue@7 157 end
Nenue@7 158 end
Nenue@7 159 end
Nenue@7 160
Nenue@7 161
Nenue@7 162 local PIN_UPDATE_DELAY = .016
Nenue@7 163 local TOP_PIN_ID
Nenue@7 164 function QuestPOI:OnUpdate (sinceLast)
Nenue@7 165 -- control update check intervals
Nenue@7 166 self.throttle = (self.throttle or PIN_UPDATE_DELAY) - sinceLast
Nenue@7 167 if self.throttle <= 0 then
Nenue@7 168 -- factor overtime into the throttle timer
Nenue@7 169 self.throttle = PIN_UPDATE_DELAY - self.throttle
Nenue@7 170 else
Nenue@7 171 return
Nenue@7 172 end
Nenue@7 173
Nenue@7 174 -- query for reward data if it wasn't found in the original scan
Nenue@7 175 local questID = self.questID
Nenue@7 176 if self.isPending then
Nenue@7 177 self:Reset()
Nenue@7 178 if not (self.PendingFade:IsPlaying() or self.isAnimating) then
Nenue@7 179 self.PendingFade:Play()
Nenue@7 180 end
Nenue@7 181 return
Nenue@7 182 else
Nenue@7 183 if self.PendingFade:IsPlaying() then
Nenue@7 184 self.PendingFade:Stop()
Nenue@7 185 end
Nenue@7 186 end
Nenue@7 187
Nenue@7 188 if self.hasUpdate then
Nenue@7 189 self:Refresh()
Nenue@7 190 self.hasUpdate = nil
Nenue@7 191 end
Nenue@7 192
Nenue@7 193 -- update time elements
Nenue@7 194 local tl = self.timeThreschold
Nenue@7 195 local timeLeft = TQ_GetQuestTimeLeftMinutes(questID)
Nenue@7 196 if timeLeft > 0 then
Nenue@7 197 for i, context in ipairs(PIN_TIME_CONTEXT) do
Nenue@7 198 if i > self.TimeleftStage then
Nenue@7 199 self.timeLabel:SetText(nil)
Nenue@7 200 break
Nenue@7 201 end
Nenue@7 202
Nenue@7 203
Nenue@7 204 if timeLeft <= context.max then
Nenue@7 205 if tl ~= i then
Nenue@7 206 tl = i
Nenue@7 207 end
Nenue@7 208
Nenue@7 209 if context.format then
Nenue@7 210 self.timeLabel:SetText(context.format(timeLeft))
Nenue@7 211 else
Nenue@7 212 self.timeLabel:SetText(nil)
Nenue@7 213 end
Nenue@7 214 break
Nenue@7 215 end
Nenue@7 216 end
Nenue@7 217 else
Nenue@7 218 -- remove self in a timely manner
Nenue@9 219 if not TQ_IsActive(self.questID) then
Nenue@9 220 print('|cFFFF4400'..self:GetName()..' pin hard timeout')
Nenue@9 221 if self.worldQuestType ~= LE_QUEST_TAG_TYPE_PROFESSION then
Nenue@9 222 self:Hide()
Nenue@9 223 end
Nenue@7 224 end
Nenue@7 225 end
Nenue@7 226 self.timeThreschold = tl
Nenue@7 227
Nenue@7 228 if self:IsMouseOver() then
Nenue@7 229 self.MouseGlow:Show()
Nenue@7 230 else
Nenue@7 231 self.MouseGlow:Hide()
Nenue@7 232 end
Nenue@8 233 end
Nenue@8 234
Nenue@8 235
Nenue@9 236
Nenue@9 237 function QuestPOI:Refresh ()
Nenue@9 238 local db = WorldPlan.db
Nenue@9 239 local print = qprint
Nenue@9 240 print('|cFF00FF88["'..tostring(self.title)..'"]|r:Refresh()', tostring(self.title), "|T"..tostring(self.itemTexture)..":12:12|t", tostring(self.itemName))
Nenue@9 241 print(self.style)
Nenue@9 242
Nenue@9 243
Nenue@9 244
Nenue@9 245 local questID = self.questId
Nenue@9 246 local style = self.style
Nenue@9 247 local borderMask = style.mask
Nenue@9 248 local borderFill = style.texture
Nenue@9 249 local iconBorder = self.iconBorder
Nenue@9 250 local icon = self.icon
Nenue@9 251 local count = self.count
Nenue@9 252
Nenue@9 253
Nenue@9 254 local subStyle = self.filtered and 'minimized' or 'continent'
Nenue@9 255 if subStyle ~= self.subStyle then
Nenue@9 256 print( ' - changed subStyle, need to redo masks')
Nenue@9 257 end
Nenue@9 258 self.subStyle = subStyle
Nenue@9 259 print(' - subStyle:', (self.filtered == true), self.subStyle)
Nenue@9 260
Nenue@9 261 --WorldPlan:print(tostring(self.title), "|T"..tostring(self.itemTexture)..":16:16|t", tostring(self.itemName))
Nenue@9 262 SetMaskedTexture(icon, self.itemTexture or ICON_UNKNOWN, borderMask)
Nenue@9 263 icon:SetAllPoints(self)
Nenue@9 264
Nenue@9 265 if self.itemName then
Nenue@9 266 local color = self.rewardColor or COMMON_COLOR
Nenue@9 267 if self.itemNumber and self.target then
Nenue@9 268 self.count:SetText(color.hex .. tostring(self.itemNumber))
Nenue@9 269 else
Nenue@9 270 self.count:SetText(nil)
Nenue@9 271 end
Nenue@9 272 end
Nenue@9 273
Nenue@9 274 SetMaskedTexture(iconBorder, borderFill, borderMask)
Nenue@9 275 local border = (self.rewardType and db.rewardStyle[self.rewardType]) or (WORLD_QUEST_QUALITY_COLORS[self.rarity] or db.defaultStyle)
Nenue@9 276 iconBorder:SetVertexColor(border.r, border.g, border.b, border.a)
Nenue@9 277 iconBorder:SetDesaturated(true)
Nenue@9 278
Nenue@9 279 local trackingBorder = self.supertrackBorder
Nenue@9 280
Nenue@9 281 self.highlight:SetMask(nil)
Nenue@9 282 if questID == GetSuperTrackedQuestID() then
Nenue@9 283 trackingBorder:SetVertexColor(0,0,0,1)
Nenue@9 284 else
Nenue@9 285 trackingBorder:SetVertexColor(0,0,0,0.5)
Nenue@9 286 end
Nenue@9 287 self.highlight:SetAllPoints(trackingBorder)
Nenue@9 288
Nenue@9 289 SetMaskedTexture(trackingBorder, borderFill, borderMask)
Nenue@9 290 self.highlight:SetMask(borderMask)
Nenue@9 291
Nenue@9 292 local qType = self.worldQuestType
Nenue@9 293 self.tagIcon:SetAtlas(self.tagAtlas)
Nenue@9 294 self.tagIcon:SetTexCoord(0,1,0,1)
Nenue@9 295
Nenue@9 296
Nenue@9 297 if self.isElite then
Nenue@9 298 self.EliteDecal:Show()
Nenue@9 299 else
Nenue@9 300 self.EliteDecal:Hide()
Nenue@9 301 end
Nenue@9 302
Nenue@9 303 if style.showNumber then
Nenue@9 304 self.label:SetText(self.itemNumber)
Nenue@9 305 else
Nenue@9 306 self.label:SetText(nil)
Nenue@9 307 end
Nenue@9 308 qprint('|cFF88FF00updated', questID, self.title, self.rewardType, (style.showNumber and self.itemNumber) or '')
Nenue@9 309
Nenue@9 310
Nenue@9 311 self:UpdateSize()
Nenue@9 312 end
Nenue@9 313
Nenue@8 314 function WorldPlanFilterPinMixin:OnEnter ()
Nenue@8 315 local filter = WorldPlan.FilterOptions[self:GetID()]
Nenue@8 316 local mapID = GetCurrentMapAreaID()
Nenue@8 317 local quests = (mapID == WorldPlan.BrokenIsleID) and WorldPlan.QuestsByID or WorldPlan.QuestsByZone[mapID]
Nenue@8 318 if quests then
Nenue@8 319 GameTooltip:SetOwner(self, 'ANCHOR_RIGHT')
Nenue@8 320 GameTooltip:AddLine(filter.label)
Nenue@8 321 local filterKey = self.filterKey
Nenue@8 322 local filterValue = self.filterValue
Nenue@8 323 if filterKey then
Nenue@8 324 for questID, pin in pairs(quests) do
Nenue@8 325 if pin.used and not pin.filtered then
Nenue@8 326 if pin[filterKey] == filterValue then
Nenue@8 327 local style = pin.style or WorldPlan.FilterStyle
Nenue@8 328
Nenue@8 329 if familiars[questID] then
Nenue@8 330 GameTooltip:AddLine(pin.title,0,1,0)
Nenue@8 331 else
Nenue@8 332 GameTooltip:AddLine(pin.title,1,1,1)
Nenue@8 333 end
Nenue@8 334
Nenue@8 335 end
Nenue@8 336 end
Nenue@8 337 end
Nenue@8 338 else
Nenue@8 339 GameTooltip:AddLine('Reset all filters')
Nenue@8 340 end
Nenue@8 341 GameTooltip:Show()
Nenue@8 342 end
Nenue@7 343 end