Mercurial > wow > worldplan
comparison WorldQuests.lua @ 73:25f7dbc20a72
fix WorldMapTooltip getting stranded when flightmap is closed
- quests that are not valid spell targets will have their icon go red
- auto-complete scrolls will no longer hide pin frames; instead they become click through and blizzard POIs are activated beneath for taint-free interaction
| author | Nenue |
|---|---|
| date | Fri, 07 Apr 2017 07:20:28 -0400 |
| parents | 6db0b9696936 |
| children | 2ba11b25aa7f |
comparison
equal
deleted
inserted
replaced
| 72:6db0b9696936 | 73:25f7dbc20a72 |
|---|---|
| 130 self:UpdateBounties('SETUP') | 130 self:UpdateBounties('SETUP') |
| 131 | 131 |
| 132 self:Show() | 132 self:Show() |
| 133 end | 133 end |
| 134 callbacks.ClickWorldMapActionButton = function(WorldQuests) | 134 callbacks.ClickWorldMapActionButton = function(WorldQuests) |
| 135 WorldQuests:GetUsedPOIs() | 135 WorldQuests:Refresh('CLICK_MAP_ACTION_BUTTON') |
| 136 end | 136 end |
| 137 callbacks.WorldMap_UpdateQuestBonusObjectives = function(WorldQuests) | 137 callbacks.WorldMap_UpdateQuestBonusObjectives = function(WorldQuests) |
| 138 WorldQuests:GetUsedPOIs() | 138 WorldQuests:UpdateTaskPOIs() |
| 139 end | 139 end |
| 140 callbacks.WorldMapFrame_UpdateMap = function(WorldQuests) | 140 callbacks.WorldMapFrame_UpdateMap = function(WorldQuests) |
| 141 WorldQuests:RefreshIfChanged() | 141 WorldQuests:RefreshIfChanged() |
| 142 end | 142 end |
| 143 callbacks.WorldMapScrollFrame_ReanchorQuestPOIs = function (WorldQuests) | 143 callbacks.WorldMapScrollFrame_ReanchorQuestPOIs = function (WorldQuests) |
| 145 end | 145 end |
| 146 | 146 |
| 147 callbacks[BountyBoard] = {} | 147 callbacks[BountyBoard] = {} |
| 148 callbacks[BountyBoard].SetSelectedBountyIndex = function(WorldQuests) | 148 callbacks[BountyBoard].SetSelectedBountyIndex = function(WorldQuests) |
| 149 WorldQuests:UpdateBounties('BOUNTY_SELECTED') | 149 WorldQuests:UpdateBounties('BOUNTY_SELECTED') |
| 150 WorldQuests:RefreshIfChanged() | 150 WorldQuests:Refresh('BOUNTY_SELECTED') |
| 151 end | 151 end |
| 152 | 152 |
| 153 callbacks[ActionButton] = {} | 153 callbacks[ActionButton] = {} |
| 154 callbacks[ActionButton].UpdateCastingState = function(WorldQuests) | 154 callbacks[ActionButton].UpdateCastingState = function(WorldQuests) |
| 155 WorldQuests:Refresh(true) | 155 WorldQuests:Refresh('CASTING_STATE_CHANGED') |
| 156 end | 156 end |
| 157 | 157 |
| 158 function Module:OnConfigUpdate() | 158 function Module:OnConfigUpdate() |
| 159 print('|cFFFFFF00OnConfigUpdate()|r') | 159 print('|cFFFFFF00OnConfigUpdate()|r') |
| 160 if db.Config.FadeWhileGrouped then | 160 if db.Config.FadeWhileGrouped then |
| 172 ToggleButton.OnShow(self.Toggle) | 172 ToggleButton.OnShow(self.Toggle) |
| 173 end | 173 end |
| 174 | 174 |
| 175 local InternalHideButton = function(button, index) | 175 local InternalHideButton = function(button, index) |
| 176 button:Hide() | 176 button:Hide() |
| 177 if button.questID and db.QuestsByID[button.questID] then | |
| 178 if db.QuestsByID[button.questID].used and not db.QuestsByID[button.questID].filtered then | |
| 179 db.QuestsByID[button.questID]:SetShown(true) | |
| 180 end | |
| 181 end | |
| 182 end | 177 end |
| 183 local InternalShowButton = function(button, index) | 178 local InternalShowButton = function(button, index) |
| 184 button:Show() | 179 button:Show() |
| 185 if button.questID and db.QuestsByID[button.questID] then | |
| 186 db.QuestsByID[button.questID]:SetShown(false) | |
| 187 end | |
| 188 end | 180 end |
| 189 | 181 |
| 190 db.UsedPOIs = {} | 182 db.UsedPOIs = {} |
| 191 function Module:GetUsedPOIs() | 183 function Module:UpdateTaskPOIs() |
| 192 db.canTargetQuests = SpellCanTargetQuest() | 184 canTargetQuests = SpellCanTargetQuest() |
| 193 local func = db.canTargetQuests and InternalShowButton or InternalHideButton | 185 local func = canTargetQuests and 'Show' or 'Hide' |
| 194 wipe(db.UsedPOIs) | |
| 195 for i = 1, NUM_WORLDMAP_TASK_POIS do | 186 for i = 1, NUM_WORLDMAP_TASK_POIS do |
| 196 local button = _G['WorldMapFrameTaskPOI'..i] | 187 local button = _G['WorldMapFrameTaskPOI'..i] |
| 197 if button and button.worldQuest then | 188 if button and button.worldQuest then |
| 198 func(button, i) | 189 button[func](button) |
| 199 db.UsedPOIs[button.questID] = button | |
| 200 end | 190 end |
| 201 end | 191 end |
| 202 end | 192 end |
| 203 | 193 |
| 204 function Module:OnSecureHook(callbackName, func, ...) | 194 function Module:OnSecureHook(callbackName, func, ...) |
| 222 self:RegisterEvent('WORLD_QUEST_COMPLETED_BY_SPELL') | 212 self:RegisterEvent('WORLD_QUEST_COMPLETED_BY_SPELL') |
| 223 self:RegisterEvent('SUPER_TRACKED_QUEST_CHANGED') | 213 self:RegisterEvent('SUPER_TRACKED_QUEST_CHANGED') |
| 224 self:RegisterEvent('SKILL_LINES_CHANGED') | 214 self:RegisterEvent('SKILL_LINES_CHANGED') |
| 225 self:RegisterEvent('CURRENT_SPELL_CAST_CHANGED') | 215 self:RegisterEvent('CURRENT_SPELL_CAST_CHANGED') |
| 226 self:RegisterEvent('ARTIFACT_UPDATE') | 216 self:RegisterEvent('ARTIFACT_UPDATE') |
| 217 self:RegisterEvent('QUEST_LOG_UPDATE') | |
| 227 end | 218 end |
| 228 | 219 |
| 229 local artifactKnowledgeMultiplier | 220 local artifactKnowledgeMultiplier |
| 230 local superTrackedQuestID | 221 local superTrackedQuestID |
| 231 function Module:OnEvent (event, ...) | 222 function Module:OnEvent (event, ...) |
| 232 | 223 |
| 233 print('|cFFFFFF00'..self:GetName()..':OnEvent() '..event..'|r', GetTime(), ...) | 224 print('|cFFFFFF00'..self:GetName()..':OnEvent() '..event..'|r', GetTime(), ...) |
| 234 if (event == 'QUEST_LOG_UPDATE') then | 225 if (event == 'QUEST_LOG_UPDATE') then |
| 235 if self:IsVisible() then | 226 self:UpdateBounties(event) |
| 236 self:Refresh() | 227 self:RefreshIfChanged(event) |
| 237 else | |
| 238 self.isStale = true | |
| 239 end | |
| 240 | |
| 241 print('WorldMapFrame', WorldMapFrame:IsVisible(), 'hasUpdates:', self.isStale) | |
| 242 elseif event == 'WORLD_QUEST_COMPLETED_BY_SPELL' then | 228 elseif event == 'WORLD_QUEST_COMPLETED_BY_SPELL' then |
| 243 local questID = ... | 229 local questID = ... |
| 230 self:UpdateBounties(event) | |
| 244 if questID and db.QuestsByID[questID] then | 231 if questID and db.QuestsByID[questID] then |
| 245 self:ReleasePin(db.QuestsByID[questID]) | 232 self:ReleasePin(db.QuestsByID[questID]) |
| 246 rprint('|cFFFF4400release|r', questID) | 233 rprint('|cFFFF4400release|r', questID) |
| 247 end | 234 end |
| 235 self:Refresh(event) | |
| 248 elseif event == 'SKILL_LINES_CHANGED' or event == 'CURRENT_SPELL_CAST_CHANGED' then | 236 elseif event == 'SKILL_LINES_CHANGED' or event == 'CURRENT_SPELL_CAST_CHANGED' then |
| 249 self:Refresh(event) | 237 self:Refresh(event) |
| 250 elseif event == 'ARTIFACT_UPDATE' then | 238 elseif event == 'ARTIFACT_UPDATE' then |
| 251 local akCheck = C_ArtifactUI.GetArtifactKnowledgeMultiplier() | 239 local akCheck = C_ArtifactUI.GetArtifactKnowledgeMultiplier() |
| 252 if akCheck and (akCheck ~= artifactKnowledgeMultiplier) then | 240 if akCheck and (akCheck ~= artifactKnowledgeMultiplier) then |
| 276 end | 264 end |
| 277 end | 265 end |
| 278 | 266 |
| 279 | 267 |
| 280 | 268 |
| 281 | 269 local bountyQuests = {} |
| 282 local bountyInfo = {} | 270 local bountyInfo = {} |
| 283 local bountyDisplayLocation, bountyLockedQuestID, selectedBountyIndex, selectedBountyQuestID | 271 local bountyDisplayLocation, bountyLockedQuestID, selectedBountyIndex, selectedBountyQuestID |
| 284 function Module:UpdateBounties(...) | 272 function Module:UpdateBounties(...) |
| 285 print('|cFF00FF88BountyInfo()|r', ...) | 273 print('|cFF00FF88BountyInfo()|r', ...) |
| 286 wipe(db.BountiesByFactionID) | 274 wipe(db.BountiesByFactionID) |
| 287 | 275 wipe(bountyQuests) |
| 288 bountiesDirty = nil | 276 |
| 289 db.selectedBounty = nil | 277 db.selectedBounty = nil |
| 290 selectedBountyIndex = BountyBoard:GetSelectedBountyIndex() | 278 selectedBountyIndex = BountyBoard:GetSelectedBountyIndex() |
| 291 bountyInfo, bountyDisplayLocation, bountyLockedQuestID = GetQuestBountyInfoForMapID(db.currentMapID, bountyInfo) | 279 bountyInfo, bountyDisplayLocation, bountyLockedQuestID = GetQuestBountyInfoForMapID(db.currentMapID, bountyInfo) |
| 292 local numBounties = 0 | 280 local numBounties = 0 |
| 293 for index, data in ipairs(bountyInfo) do | 281 for index, info in ipairs(bountyInfo) do |
| 294 if data.factionID then | 282 if info.factionID then |
| 295 numBounties = numBounties + 1 | 283 numBounties = numBounties + 1 |
| 296 data.index = index | 284 info.index = index |
| 297 data.complete = IsQuestComplete(data.questID) | 285 info.complete = IsQuestComplete(info.questID) |
| 298 if not data.complete then | 286 if not info.complete then |
| 299 db.BountiesByFactionID[data.factionID] = data | 287 db.BountiesByFactionID[info.factionID] = info |
| 300 if index == selectedBountyIndex then | 288 if index == selectedBountyIndex then |
| 301 db.selectedBounty = data | 289 db.selectedBounty = info |
| 302 selectedBountyQuestID = data.questID | 290 selectedBountyQuestID = info.questID |
| 303 end | 291 end |
| 304 print(' ', index, data.factionID, GetQuestLogTitle(GetQuestLogIndexByID(data.questID)), data.complete, (index == selectedBountyIndex) and 'SELECTED' or '') | 292 print(' ', index, info.factionID, GetQuestLogTitle(GetQuestLogIndexByID(info.questID)), info.complete, (index == selectedBountyIndex) and 'SELECTED' or '') |
| 305 end | 293 bountyQuests[info.questID] = info |
| 306 end | 294 end |
| 307 end | 295 end |
| 308 | 296 end |
| 309 local numUpdated = 0 | 297 bountiesDirty = nil |
| 310 local numHidden = 0 | |
| 311 for questID, pin in pairs(db.QuestsByID) do | |
| 312 end | |
| 313 --print(numUpdated, 'changes from Bounty Board ('..tostring(numHidden)..' hidden)') | |
| 314 end | 298 end |
| 315 | 299 |
| 316 function Module:OnMapInfo(isBrokenIsle, isZoomedOut, mapAreaID, isNewMap, isMapOpen) | 300 function Module:OnMapInfo(isBrokenIsle, isZoomedOut, mapAreaID, isNewMap, isMapOpen) |
| 317 if isNewMap then | 301 if isNewMap then |
| 318 print('|cFF00FF88'..self:GetName()..':OnMapInfo()|r, mapAreaID =', mapAreaID,'visible =', isMapOpen, 'changed =', isNewMap) | 302 print('|cFF00FF88OnMapInfo()|r, mapAreaID =', mapAreaID,'visible =', isMapOpen, 'changed =', isNewMap) |
| 319 if isMapOpen then | 303 if isMapOpen then |
| 320 self:Refresh(true) | 304 self:Refresh(true) |
| 321 else | 305 else |
| 322 self.isStale = true | 306 self.isStale = true |
| 323 end | 307 end |
| 441 | 425 |
| 442 local msg = '|cFF00FF88WorldQuests:Refresh()|r|cFF00FFFF' | 426 local msg = '|cFF00FF88WorldQuests:Refresh()|r|cFF00FFFF' |
| 443 function Module:Refresh(...) | 427 function Module:Refresh(...) |
| 444 | 428 |
| 445 rprint(msg, ...) | 429 rprint(msg, ...) |
| 446 print('|cFF00FF88WorldQuests:Refresh()|r', ...) | |
| 447 if not self:IsVisible() then | 430 if not self:IsVisible() then |
| 448 print(' not visible, flag for later') | 431 rprint('|cFF00FF88WorldQuests:Refresh()|r', ...) |
| 449 self.isStale = true | 432 self.isStale = true |
| 450 return self:MarkAllPins() | 433 return self:MarkAllPins() |
| 451 end | 434 else |
| 435 rprint('|cFF00FF88WorldQuests:Refresh()|r', ...) | |
| 436 print('|cFF00FF88WorldQuests:Refresh()|r', ...) | |
| 437 end | |
| 438 | |
| 452 if not db.Config.EnablePins then | 439 if not db.Config.EnablePins then |
| 453 numShown = 0 | 440 numShown = 0 |
| 454 return | 441 return |
| 455 end | 442 end |
| 456 wprint(' '..msg) | 443 wprint(' '..msg) |
| 457 | 444 |
| 458 layoutDirty = nil | |
| 459 scaleConstant = db.isContinentMap and 2 or 3 | 445 scaleConstant = db.isContinentMap and 2 or 3 |
| 460 canTargetQuests = SpellCanTargetQuest() | 446 canTargetQuests = SpellCanTargetQuest() |
| 461 | 447 |
| 462 for index, pin in pairs(db.QuestsByID) do | 448 for index, pin in pairs(db.QuestsByID) do |
| 463 pin.used = nil | 449 pin.used = nil |
| 465 | 451 |
| 466 self:UpdateAnchors() | 452 self:UpdateAnchors() |
| 467 if bountiesDirty then | 453 if bountiesDirty then |
| 468 print(' bounties dirty, pushing that') | 454 print(' bounties dirty, pushing that') |
| 469 self:UpdateBounties() | 455 self:UpdateBounties() |
| 470 bountiesDirty = nil | |
| 471 end | 456 end |
| 472 | 457 |
| 473 | 458 |
| 474 -- calculate quests shown | 459 -- calculate quests shown |
| 475 numShown = 0 | 460 numShown = 0 |
| 496 end | 481 end |
| 497 end | 482 end |
| 498 | 483 |
| 499 | 484 |
| 500 | 485 |
| 501 print(numShown, 'shown,', numLoaded, 'with data') | 486 print(' ', numShown, 'shown,', numLoaded, 'with data') |
| 502 if numShown > numLoaded then | 487 if numShown > numLoaded then |
| 503 self.Status:Show() | 488 self.Status:Show() |
| 504 end | 489 end |
| 505 | 490 |
| 506 | 491 |
| 492 layoutDirty = nil | |
| 507 self.isStale = nil | 493 self.isStale = nil |
| 508 self.sizesDirty = nil | 494 self.sizesDirty = nil |
| 509 self.isZoomDirty = nil | 495 self.isZoomDirty = nil |
| 510 end | 496 end |
| 511 | 497 |
| 498 local refreshReason | |
| 512 function Module:RefreshIfChanged() | 499 function Module:RefreshIfChanged() |
| 513 local scaleCheck = WorldMapDetailFrame:GetScale() | 500 local scaleCheck = WorldMapDetailFrame:GetScale() |
| 501 refreshReason = nil | |
| 514 if scaleCheck ~= currentScale then | 502 if scaleCheck ~= currentScale then |
| 515 print('|cFF00FF88RefreshIfChanged()|r map scale updated') | 503 refreshReason = 'map scale updated' |
| 516 self:Refresh('WORLD_MAP_SCALE_CHANGED') | 504 self:Refresh('WORLD_MAP_SCALE_CHANGED') |
| 517 currentScale = scaleCheck | 505 currentScale = scaleCheck |
| 518 elseif self.isStale or layoutDirty then | 506 elseif self.isStale or layoutDirty then |
| 519 print('|cFF00FF88RefreshIfChanged()|r layout is dirty') | 507 refreshReason = 'layout is marked dirty' |
| 508 end | |
| 509 if not refreshReason then | |
| 510 return | |
| 511 end | |
| 512 | |
| 513 | |
| 514 if self:IsVisible() then | |
| 515 print('|cFF00FFFFRefreshIfChanged()|r', refreshReason) | |
| 520 self:Refresh() | 516 self:Refresh() |
| 517 else | |
| 518 rprint('|cFF00FFFFRefreshIfChanged()|r flagging for later refresh', refreshReason) | |
| 519 self.isStale = true | |
| 521 end | 520 end |
| 522 end | 521 end |
| 523 | 522 |
| 524 -- update visibility states of all pins | 523 -- update visibility states of all pins |
| 525 function Module:MarkAllPins(pins) | 524 function Module:MarkAllPins(pins) |
| 546 pin.owningFrame = WorldMapFrame | 545 pin.owningFrame = WorldMapFrame |
| 547 pin:SetAnchor(WorldMapPOIFrame, x, y, self.hostWidth, self.hostHeight, scaleFactor) | 546 pin:SetAnchor(WorldMapPOIFrame, x, y, self.hostWidth, self.hostHeight, scaleFactor) |
| 548 --tinsert(self.UsedPositions, pin) | 547 --tinsert(self.UsedPositions, pin) |
| 549 end | 548 end |
| 550 | 549 |
| 551 | |
| 552 local isCriteria, isBounty | 550 local isCriteria, isBounty |
| 553 if pin.factionID then | 551 if pin.factionID then |
| 554 if db.BountiesByFactionID[pin.factionID] then | 552 if db.BountiesByFactionID[pin.factionID] then |
| 555 isCriteria = true | 553 isCriteria = true |
| 556 end | 554 end |
| 557 if selectedBountyQuestID then | 555 if selectedBountyQuestID then |
| 558 isBounty = IsQuestCriteriaForBounty(pin.questID, selectedBountyQuestID) and true or nil | 556 isBounty = IsQuestCriteriaForBounty(pin.questID, selectedBountyQuestID) and true or nil |
| 559 end | 557 end |
| 560 end | 558 end |
| 561 | 559 |
| 562 if (pin.isBounty ~= isBounty) or (pin.isCriteria ~= isCriteria) then | 560 local isSpellTarget |
| 563 print(pin.isBounty, '~=', isBounty) | 561 if canTargetQuests then |
| 564 print(pin.isCriteria, '~=', isCriteria) | 562 isSpellTarget = IsQuestIDValidSpellTarget(pin.questID) |
| 563 end | |
| 564 | |
| 565 if (pin.isBounty ~= isBounty) or (pin.isCriteria ~= isCriteria) or (pin.isSpellTarget ~= isSpellTarget) then | |
| 566 pin.isSpellTarget = isSpellTarget | |
| 565 pin.isBounty = isBounty | 567 pin.isBounty = isBounty |
| 566 pin.isCriteria = isCriteria | 568 pin.isCriteria = isCriteria |
| 567 if pin:IsVisible() then | 569 if pin:IsVisible() then |
| 568 --print(' changed', pin.title) | 570 --print(' changed', pin.title) |
| 569 --numUpdated = numUpdated + 1 | 571 --numUpdated = numUpdated + 1 |
| 570 pin:Refresh('BOUNTY_UPDATE') | 572 pin:Refresh('BOUNTY_UPDATE') |
| 571 else | 573 else |
| 572 --numHidden = numHidden + 1 | 574 --numHidden = numHidden + 1 |
| 573 pin.isStale = true | 575 pin.isStale = true |
| 574 end | 576 end |
| 575 layoutDirty = true | |
| 576 end | 577 end |
| 577 | 578 |
| 578 if self:IsVisible() and (pin.isStale) then | 579 if self:IsVisible() and (pin.isStale) then |
| 579 pin:Refresh() | 580 pin:Refresh() |
| 580 end | 581 end |
