Mercurial > wow > worldplan
diff QuestPOI.lua @ 93:98b5e08b75ed v1.4.9
- Fixed quest completion checking and handling
- Changed animation method to hopefully stop weird flickering.
- Pins are now visible before full reward data is loaded
- Filter bar redesigned:
- aligned horizontally along the top of the map display
- filter buttons display a '+' when there are matches in both current and other zones, and '*' when there only matches in other zones
- button tooltips separate local and global quests
- button categories are highlighted and labeled when the cursor is over them
- Fixed invalid POI targets appearing when the spell targeting cursor is active
author | Nenue |
---|---|
date | Sat, 15 Apr 2017 11:04:54 -0400 |
parents | 77013bd72adb |
children | b29b35cb8539 |
line wrap: on
line diff
--- a/QuestPOI.lua Tue Apr 11 00:44:22 2017 -0400 +++ b/QuestPOI.lua Sat Apr 15 11:04:54 2017 -0400 @@ -26,7 +26,7 @@ local HaveQuestRewardData = HaveQuestRewardData -local pairs, ipairs, tinsert, unpack, select = pairs, ipairs, tinsert, unpack, select +local pairs, ipairs, tinsert, tremove, unpack, select = pairs, ipairs, tinsert, tremove, unpack, select local floor, mod, tostring, tonumber, GetSuperTrackedQuestID = floor, mod, tostring, tonumber, GetSuperTrackedQuestID local GameTooltip = GameTooltip local GetItemIcon = GetItemIcon @@ -40,8 +40,8 @@ local dprint = DEVIAN_WORKSPACE and function(...) _G.print('WQData', ...) end or nop local QuestPOI = WorldPlanPOIMixin -local pinBaseIndex = 1500 -local overlayBaseIndex = 1580 +local pinBaseIndex = 1320 +local overlayBaseIndex = 1380 local previousHighlight local DATA_DEBUG = false @@ -252,6 +252,50 @@ end +function QuestPOI:OnLoad() + --qprint('|cFF00FF88'..self:GetName()..':OnLoad()|r',db.Config) + self.debugTimer = 4 + self.title = '|cFF0088FF' .. RETRIEVING_DATA..'|r' + self.count = self.Overlay.count + self.timeLabel = self.Overlay.timeLabel + self.Description = self.Overlay.Description + self.updateRate = PIN_REQUEST_DELAY + self.itemName = '|cFF0088FF' .. RETRIEVING_DATA..'|r' + + + self.IconBackdrop:SetVertexColor(0,0,0,1) + self.Overlay:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 4) + self.Overlay:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', 0, -4) +end + +function QuestPOI:OnShow () + if self.isStale then + --print('|cFF00FF00refresh on show') + self:Refresh('POI_ONSHOW_STALE') + end + self:RegisterEvent('QUEST_TURNED_IN') + self:RegisterEvent('QUEST_LOG_UPDATE') + self:HideOrShowFrames(true) +end + +function QuestPOI:OnEvent(event, questID) + if (self.questID == questID) and IsQuestComplete(self.questID) then + db.log(self.questID .. " Marked completed.") + self:Release() + end +end + +function QuestPOI:OnHide() + --DEFAULT_CHAT_FRAME:AddMessage('|cFFFFFF00'..self:GetName()..'|r:OnHide()') + self:HideOrShowFrames(false) + -- reset flags + self:SetAlpha(db.PinAlpha) + self.isAnimating = nil + if db.Config.DebugEnabled then + db.log(tostring(self.questID) .. ' ' .. tostring(self.title) .. "\n" .. tostring(REWARD_TYPE_NAMES[self.rewardType]) .. ' ' .. tostring(self.itemName) .. ' ' .. tostring(self.itemNumber) .. "\n|cFFFF4400" .. (self.hideReason or 'NO_MESSAGE') .. "|r\n|cFF00FFFF" .. debugstack(2,3,0) .. '|r') + end + self.hideReason = nil +end function QuestPOI:OnEnter() if self.filtered and (self.questID ~= GetSuperTrackedQuestID()) then @@ -328,6 +372,15 @@ --print(WorldMapTooltip:GetParent()) --print(WorldMapTooltip:IsVisible()) end + +function QuestPOI:OnMouseDown(button) + if button == 'RightButton' then + SetSuperTrackedQuestID(nil) + else + TaskPOI_OnClick(self, button) + end +end + function QuestPOI:OnLeave() if self.filtered and (self.questID ~= GetSuperTrackedQuestID()) then return @@ -336,6 +389,74 @@ WorldMapTooltip:Hide(); end +local updateTime, markTime +function QuestPOI:OnUpdate (sinceLast) + -- control update check intervals + + if self.animating then + local alpha = self.icon:GetAlpha() + sinceLast*3 + + self.animateTime = (self.animateTime or 0) + sinceLast + if alpha >= 1 then + alpha = 1 + print('fade over', self.animateTime) + self.animating = nil + self.animateTime = nil + + end + + self.icon:SetAlpha(alpha) + self.RewardBorder:SetAlpha(alpha) + end + + self.throttle = (self.throttle or self.updateRate) + sinceLast + if self.throttle >= self.updateRate then + -- factor overtime into the throttle timer + self.throttle = self.throttle - self.updateRate + else + return + end + --@debug@ + if DATA_DEBUG then + self.debugTimer = self.debugTimer - sinceLast + if self.debugTimer >= 0 then + print(self.debugTimer) + return + end + end + --@end-debug@ + + -- query for reward data if it wasn't found in the original scan + + if not self.dataLoaded then + local dataLoaded = self:GetData() + if dataLoaded and not tContains(db.UpdatedPins, self) then + -- self.PendingFade:Stop() + -- scale info from the parent module is needed, so deal with it there + print('|cFF00FF88 queueing for update') + self.isNew = true + tinsert(db.UpdatedPins, self) + else + + --print('|cFFFF4400OnUpdate(|r'..self:GetID()..'|cFFFF4400)|r poll failed') + end + return + end + + if self.maxAlertLevel then + self:UpdateStatus() + end +end + + +function QuestPOI:StartFading() + if not self.animating then + self.animating = true + self.icon:SetAlpha(0) + self.RewardBorder:SetAlpha(0) + end +end + -- attempt to pull pin data function QuestPOI:GetData () --dprint('|cFF00FF88'..self:GetID()..':GetData()|r') @@ -352,7 +473,7 @@ return false else self.title, self.factionID, self.capped = questTitle, factionID, capped - print(questTitle, factionID, capped) + --print(questTitle, factionID, capped) -- set tag details local worldQuestType self.tagID, self.tagName, worldQuestType, self.rarity, self.isElite, self.tradeskillLineIndex = GetQuestTagInfo(questID); @@ -397,18 +518,6 @@ local ID_RESOURCES = 1220 local ID_LEGIONFALL = 1342 -function QuestPOI:Reset() - self.isActive = nil - self.complete = nil - self.used = nil - self.dataLoaded = nil - self.rewardType = nil - self.itemTexture = nil - self.itemName = nil - self.itemNumber = nil - self:SetShown(false) -end - --- Returns true if data has changed (either from loading in or qualifications changed) function QuestPOI:UpdateRewards() local questID = self.questID @@ -484,8 +593,6 @@ if itemID then local itemName, itemLink, itemRarity, itemLevel, itemMinLevel, itemType, itemSubType, itemStackCount, itemEquipLoc, itemTexture, sellPrice, classID, subclassID = GetItemInfo(itemID); - - if ( classID == LE_ITEM_CLASS_WEAPON or classID == LE_ITEM_CLASS_ARMOR or (classID == LE_ITEM_CLASS_GEM and subclassID == LE_ITEM_GEM_ARTIFACTRELIC) ) then rewardType = REWARD_GEAR rewardIcon = texture @@ -496,26 +603,8 @@ rewardType = REWARD_ARTIFACT_POWER rewardIcon = texture rewardName = name - rewardCount = 1 + rewardCount = self:UpdateArtifactPower(itemLink) foundPrimary = true - - WorldPlanTooltip:SetOwner(self, 'ANCHOR_NONE') - WorldPlanTooltip:SetHyperlink(itemLink) - for i = 1, WorldPlanTooltip:NumLines() do - local line = _G['WorldPlanTooltipTextLeft' .. i] - local text = line and line:GetText() - local ap = text and text:gsub(',', ''):gsub(' million', '000000'):match('(%d+) '..ARTIFACT_POWER) - if ap then - rewardCount = tonumber(ap) - --dprint(ap) - end - - end - - if WorldPlanTooltipTextLeft2 then - local text = WorldPlanTooltipTextLeft2:GetText() - end - --dprint('is an AP token') elseif classID == LE_ITEM_CLASS_TRADEGOODS then rewardType = REWARD_REAGENT @@ -524,8 +613,6 @@ rewardCount = numItems foundPrimary = true end - - --dprint(' reward', i, name, " |T"..tostring(texture)..":12:12|t", quality, isUsable, itemID) tinsert(rewardItems, { name = name, @@ -582,70 +669,26 @@ end end --- run from OnShow if .isNew is set -function QuestPOI:OnAnimStart() - --qprint('|cFFFFFF00OnAnimStart(|r'..self:GetID()..'|cFFFFFF00)|r', self.fadeEvent) - self:Refresh('FADE_IN_START') - self.isNew = nil -end - -function QuestPOI:TryToFade(event) - if self.FadeIn:IsPlaying() then - --qprint('|cFFFF4400TryToFade('..self:GetID()..'|cFFFF4400)|r stopping because already in progress') +function QuestPOI:UpdateArtifactPower(rewardLink) + if not (rewardLink or self.rewardLink) then return end - self.fadeEvent = event - if self.dataLoaded then - --qprint('|cFFFFFF00TryToFade('..self:GetID()..'|cFFFFFF00)|r', event) - self:SetAlpha(0) - self.FadeIn.FadeIn:SetToAlpha(db.PinAlpha) - self.FadeIn:Play() - else + self.rewardLink = rewardLink or self.rewardLink - --qprint('|cFFFF4400TryToFade('..self:GetID()..'|cFFFF4400)|r stopping because not loaded') - end -end - -function QuestPOI:OnAnimStop() - self:SetAlpha(db.PinAlpha) -end - -function QuestPOI:OnShow () - - if self.isNew then - self:TryToFade('POI_ONSHOW_NEW') - elseif not self.FadeIn:IsPlaying() then - print('|cFF00FF00Alpha correction') - self:SetAlpha(db.PinAlpha) -- fix stuck alpha - if self.isStale then - --print('|cFF00FF00refresh on show') - self:Refresh('POI_ONSHOW_STALE') + local rewardCount + WorldPlanTooltip:SetOwner(self, 'ANCHOR_NONE') + WorldPlanTooltip:SetHyperlink(rewardLink or self.rewardLink) + for i = 1, WorldPlanTooltip:NumLines() do + local line = _G['WorldPlanTooltipTextLeft' .. i] + local text = line and line:GetText() + local ap = text and text:gsub(',', ''):gsub(' million', '000000'):match('([%d%.]+) '..ARTIFACT_POWER) + if ap then + rewardCount = tonumber(ap) end end - self:RegisterEvent('QUEST_LOG_UPDATE') - self:ShowFrames() -end - -function QuestPOI:OnEvent(event) - if not TQ_IsActive(self.questID) then - self:UnregisterEvent('QUEST_LOG_UPDATE') - self.hideReason = 'Hiding self because quest is inactive.' - self:SetShown(false) - end -end - -function QuestPOI:OnHide() - --DEFAULT_CHAT_FRAME:AddMessage('|cFFFFFF00'..self:GetName()..'|r:OnHide()') - self:HideFrames() - -- reset flags - self:SetAlpha(db.PinAlpha) - self.isAnimating = nil - if db.Config.DebugEnabled then - db.log(tostring(self.questID) .. ' ' .. tostring(self.title) .. "\n" .. tostring(REWARD_TYPE_NAMES[self.rewardType]) .. ' ' .. tostring(self.itemName) .. ' ' .. tostring(self.itemNumber) .. "\n|cFFFF4400" .. (self.hideReason or 'NO_MESSAGE') .. "|r\n|cFF00FFFF" .. debugstack(2,3,0) .. '|r') - end - self.hideReason = nil + return rewardCount end -- Applies position and sizing parameters to the pin data @@ -653,7 +696,7 @@ --dprint(self:GetName()..':SetAnchor()', owner, dX, dY, scaleFactor, self.filtered, self.used) if not self.used then self.hideReason = 'SetAnchor() on an unused frame.' - self:HideFrames() + self:HideOrShowFrames(false) return end @@ -696,108 +739,19 @@ end --- Show/Hide the text overlays associated with the quest pin; they aren't hierarchically linked -function QuestPOI:ShowFrames() - if not self:IsShown() then - -- print('|cFFFFFF00' ..self:GetName()..':ShowFrames()') - -- do not SetShown() here - end - self.Overlay:SetShown(true) - self.count:SetShown(true) - self.timeLabel:SetShown(true) -end - -function QuestPOI:HideFrames() - if self:IsShown() then - if not self.hideReason then - self.hideReason = "HideFrames() called" - end - end - self.Overlay:SetShown(false) - self.count:SetShown(false) - self.timeLabel:SetShown(false) -end - -function QuestPOI:OnLoad() - --qprint('|cFF00FF88'..self:GetName()..':OnLoad()|r',db.Config) - self.debugTimer = 4 - self.title = '|cFF0088FF' .. RETRIEVING_DATA..'|r' - self.isPending = true - self.count = self.Overlay.count - self.timeLabel = self.Overlay.timeLabel - self.Description = self.Overlay.Description - self.updateRate = PIN_REQUEST_DELAY - self.itemName = '|cFF0088FF' .. RETRIEVING_DATA..'|r' - - self.Overlay:SetPoint('TOPLEFT', self, 'TOPLEFT', 0, 4) - self.Overlay:SetPoint('BOTTOMRIGHT', self, 'BOTTOMRIGHT', 0, -4) -end - -function QuestPOI:OnMouseDown(button) - if button == 'RightButton' then - SetSuperTrackedQuestID(nil) - else - TaskPOI_OnClick(self, button) - end -end - -local updateTime, markTime -function QuestPOI:OnUpdate (sinceLast) - -- control update check intervals - - - self.throttle = (self.throttle or self.updateRate) + sinceLast - if self.throttle >= self.updateRate then - -- factor overtime into the throttle timer - self.throttle = self.throttle - self.updateRate - else - return - end - --@debug@ - if DATA_DEBUG then - self.debugTimer = self.debugTimer - sinceLast - if self.debugTimer >= 0 then - print(self.debugTimer) - return - end - end - --@end-debug@ - - -- query for reward data if it wasn't found in the original scan - - if not self.dataLoaded then - - local dataLoaded = self:GetData() - if dataLoaded and not tContains(db.UpdatedPins, self) then - -- self.PendingFade:Stop() - -- scale info from the parent module is needed, so deal with it there - --print('|cFF00FF88 queueing for update') - tinsert(db.UpdatedPins, self) - else - - --print('|cFFFF4400OnUpdate(|r'..self:GetID()..'|cFFFF4400)|r poll failed') - end - return - end - - if self.maxAlertLevel then - self:UpdateStatus() - end - -end - -- Non-hieriarchical display states, checked separately from used/filtered states function QuestPOI:GetCriteriaState() local isCriteria, isBounty, isSpellTarget - if self.factionID then - for index, bounty in pairs(db.Bounties) do - if IsQuestCriteriaForBounty(self.questID, bounty.questID) then - isCriteria = true - if db.selectedBounty == bounty then - isBounty = true - end - --dprint('|cFF00FF88Criteria:|r', self.questID, bounty.questID, isCriteria, isBounty) + + + + for index, bounty in pairs(db.Bounties) do + if (not IsQuestComplete(bounty.questID)) and IsQuestCriteriaForBounty(self.questID, bounty.questID) then + isCriteria = true + if db.selectedBounty == bounty then + isBounty = true end + --dprint('|cFF00FF88Criteria:|r', self.questID, bounty.questID, isCriteria, isBounty) end end isSpellTarget = IsQuestIDValidSpellTarget(self.questID) @@ -812,184 +766,6 @@ end end --- Called at static intervals and with Refresh -function QuestPOI:UpdateStatus() - -- update time elements - self.isActive = TQ_IsActive(self.questID) - - if self.isActive then - local tl = self.alertLevel - local timeLeft = TQ_GetQuestTimeLeftMinutes(self.questID) - if timeLeft > 0 then - - local text, timeState = WorldPlan:GetTimeInfo(timeLeft, self.maxAlertLevel) - if tl ~= timeState then - tl = timeState - self.timeLabel:SetText(text) - end - end - - local border = (self.isBounty or self.isCriteria) and self.RewardBorder or self.HighlightBorder - - if tl and (timeLeft < 120) then - border:SetVertexColor(1,0,0,0.7) - else - border:SetVertexColor(0,0,0,0.7) - end - self.alertLevel = tl - self.timeLabel:SetShown(self.worldQuest and (self.maxAlertLevel >= 1)) - else - self.hideReason = "No longer active." - self:HideFrames() - - end -end - - -function QuestPOI:Refresh (event) - - print('|cFF00FF88Refresh(|r'..self:GetID()..'|cFF00FF88)|r', event, self.title) - - local style = DEFAULT_STYLE - if self.dataLoaded and not self.filtered then - style = REWARD_TYPE_STYLES[self.rewardType] - else - style = MINIMIZED_STYLE - end - - local currentWidth = style.iconWidth or DEFAULT_STYLE.iconWidth - - - - local borderWidth = style.borderWidth or DEFAULT_STYLE.borderWidth - local highlightWidth = style.highlightWidth or DEFAULT_STYLE.highlightWidth - local tagSize = style.TagSize or DEFAULT_STYLE.TagSize - local hideIcon = style.hideIcon or DEFAULT_STYLE.hideIcon - local borderColor = style.border or DEFAULT_STYLE.border - local textColor = style.textColor or DEFAULT_STYLE.textColor - local questID = self.questID - local iconBorder = self.RewardBorder - local trackingBorder = self.HighlightBorder - local icon = self.icon - local count = self.count - local hideNumbers = style.hideNumber or DEFAULT_STYLE.hideNumber - - local tagIcon = self.tagIcon - self.maxAlertLevel = style.maxAlertLevel or DEFAULT_STYLE.maxAlertLevel - - - if self.itemName then - if self.itemNumber and (self.itemNumber > 1) and (not hideNumbers) then - local numberString = self.itemNumber - if self.itemNumber >= 1000000 then - numberString = (floor(self.itemNumber/100000)/10) .. 'M' - elseif self.itemNumber >= 10000 then - numberString = floor(self.itemNumber/1000) .. 'k' - elseif self.itemNumber >= 1000 then - local numeral = floor(self.itemNumber/1000) - local decimal = mod(self.itemNumber, 1000) - numberString = numeral - if decimal > 100 then - numberString = numberString .. '.' .. tostring(floor(decimal/100)) - end - numberString = numberString .. 'k' - end - - self.count:SetText(numberString) - self.count:SetTextColor(unpack(textColor)) - self.count:Show() - else - self.count:SetText(nil) - self.count:Hide() - end - else - self.count:Hide() - end - - if db.Config.ShowVerboseInfo then - self.Description:SetText(self.title .. "\n" .. floor(self.x*100+.5) .. "," .. floor(self.y*100+.5)) - end - - - icon:SetSize(currentWidth, currentWidth) - icon:SetMask(style.iconMask or DEFAULT_STYLE.iconMask) - if self.itemTexture then - --iconBorder:SetTexture(WORLD_QUEST_BORDER) - - if hideIcon then - icon:SetTexture(PENDING_ICON) - icon:SetDesaturated(true) - icon:SetVertexColor(unpack(borderColor)) - else - icon:SetTexture(self.itemTexture) - icon:SetDesaturated(false) - icon:SetVertexColor(1, 1, 1) - end - else - -- - icon:SetTexture(PENDING_ICON) - icon:SetDesaturated(true) - icon:SetVertexColor(unpack(borderColor)) - end - local borderMask = style.borderMask or DEFAULT_STYLE.borderMask - local borderSize = currentWidth + (borderWidth * 2) + (self.isCriteria and 2 or 0) - - - iconBorder:SetSize(borderSize, borderSize) - iconBorder:SetMask(borderMask) - iconBorder:SetTexture(PENDING_BORDER) - - iconBorder:SetDesaturated(true) - - local highlightSize = borderSize + (highlightWidth * 2) - trackingBorder:SetSize(highlightSize, highlightSize) - trackingBorder:SetMask(borderMask) - trackingBorder:SetTexture(PENDING_BORDER) - - self:SetSize(borderSize, borderSize) - - - - iconBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0)) - trackingBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0)) - - self.tagIcon:SetShown((not self.filtered) and true or false) - self.tagIcon:SetAtlas(self.tagAtlas) - self.EliteBorder:SetShown(self.isElite and not self.filtered) - - self:UpdateSize() - self:UpdateStatus() - self.isStale = nil - - if self.isBounty then - --print('is bounty') - iconBorder:SetVertexColor(trackingBorder:GetVertexColor()) - trackingBorder:SetVertexColor(unpack(BORDER_SELECTED_BOUNTY)) - elseif self.isCriteria then - --print('is criteria of a bounty') - iconBorder:SetVertexColor(trackingBorder:GetVertexColor()) - trackingBorder:SetVertexColor(unpack(BORDER_CRITERIA)) - else - - iconBorder:SetVertexColor(unpack(borderColor)) - trackingBorder:SetVertexColor(1,1,1,1) - end - - if SpellCanTargetQuest() then - if IsQuestIDValidSpellTarget(self.questID) then - icon:SetVertexColor(1,1,1) - else - icon:SetVertexColor(1,0,0,1) - end - self:EnableMouse(false) - else - self:EnableMouse(true) - end - - -- signal filter info update - WorldPlanSummary.isStale = true -end - local cvar_check = { [REWARD_CASH] = 'worldQuestFilterGold', [REWARD_ARTIFACT_POWER] = 'worldQuestFilterArtifactPower', @@ -1044,57 +820,250 @@ self:SetShown(true) end ---- Fixes icons upon size update -function QuestPOI:UpdateSize () +function QuestPOI:Refresh (event) + print('|cFF00FF88Refresh(|r'..self:GetID()..'|cFF00FF88)|r', event, self.title) - --qprint('|cFF00BB88'..self:GetID()..'|r:UpdateSize()', self.style, self.subStyle) - return - --[[ - local style = self.style - local subStyle = self.subStyle - local icon = self.icon + + local style = DEFAULT_STYLE + if self.filtered then + print('choose minimized') + style = MINIMIZED_STYLE + elseif self.dataLoaded then + print('choose reward type') + style = REWARD_TYPE_STYLES[self.rewardType] + else + print('choose default') + end + + local currentWidth = style.iconWidth or DEFAULT_STYLE.iconWidth + + + + local borderWidth = style.borderWidth or DEFAULT_STYLE.borderWidth + local highlightWidth = style.highlightWidth or DEFAULT_STYLE.highlightWidth + local tagSize = style.TagSize or DEFAULT_STYLE.TagSize + local hideIcon = style.hideIcon or DEFAULT_STYLE.hideIcon + local borderColor = style.border or DEFAULT_STYLE.border + local textColor = style.textColor or DEFAULT_STYLE.textColor + local questID = self.questID local iconBorder = self.RewardBorder local trackingBorder = self.HighlightBorder - local tag = self.tagIcon + local icon = self.icon + local count = self.count + local hideNumbers = style.hideNumber or DEFAULT_STYLE.hideNumber - local iconWidth = subStyle.iconWidth - local borderWidth = iconWidth + (subStyle.borderWidth * 2) - local highlightWidth = borderWidth + (subStyle.highlightWidth * 2) - local iconTexture = self.itemTexture + local tagIcon = self.tagIcon + self.maxAlertLevel = style.maxAlertLevel or DEFAULT_STYLE.maxAlertLevel - self:SetSize(highlightWidth, highlightWidth) - if self.questID == GetSuperTrackedQuestID() then - highlightWidth = highlightWidth + 2 - if self.filtered then - self:SetAlpha(db.PinAlpha * 0.5) + if self.dataLoaded then + print('new pin, has data, cue fade') + if self.isNew then + self:StartFading() + self.isNew = nil + end + else + if not self.animating then + print('new pin, but no data, hide icon') + self.icon:SetAlpha(0) + self.RewardBorder:SetAlpha(0) + end + end + + if self.itemName then + if self.itemNumber and (self.itemNumber > 1) and (not hideNumbers) then + local numberString = self.itemNumber + if self.itemNumber >= 1000000 then + numberString = (floor(self.itemNumber/100000)/10) .. 'M' + elseif self.itemNumber >= 10000 then + numberString = floor(self.itemNumber/1000) .. 'k' + elseif self.itemNumber >= 1000 then + local numeral = floor(self.itemNumber/1000) + local decimal = mod(self.itemNumber, 1000) + numberString = numeral + if decimal > 100 then + numberString = numberString .. '.' .. tostring(floor(decimal/100)) + end + numberString = numberString .. 'k' + end + + self.count:SetText(numberString) + self.count:SetTextColor(unpack(textColor)) + self.count:Show() else - self:SetAlpha(db.PinAlpha) + self.count:SetText(nil) + self.count:Hide() + end + else + self.count:Hide() + end + + if db.Config.ShowVerboseInfo then + self.Description:SetText(self.title .. "\n" .. floor(self.x*100+.5) .. "," .. floor(self.y*100+.5)) + end + + + icon:SetSize(currentWidth, currentWidth) + icon:SetMask(style.iconMask or DEFAULT_STYLE.iconMask) + if self.itemTexture then + --iconBorder:SetTexture(WORLD_QUEST_BORDER) + + if hideIcon then + icon:SetTexture(PENDING_ICON) + icon:SetDesaturated(true) + icon:SetVertexColor(unpack(borderColor)) + else + icon:SetTexture(self.itemTexture) + icon:SetDesaturated(false) + icon:SetVertexColor(1, 1, 1) + end + else + -- + --icon:SetTexture(PENDING_ICON) + --icon:SetDesaturated(true) + --icon:SetVertexColor(unpack(borderColor)) + end + local borderMask = style.borderMask or DEFAULT_STYLE.borderMask + local borderSize = currentWidth + (borderWidth * 2) + (self.isCriteria and 2 or 0) + + + iconBorder:SetSize(borderSize, borderSize) + + iconBorder:SetMask(borderMask) + iconBorder:SetTexture(PENDING_BORDER) + + iconBorder:SetDesaturated(true) + + local highlightSize = borderSize + (highlightWidth * 2) + trackingBorder:SetSize(highlightSize, highlightSize) + trackingBorder:SetMask(borderMask) + trackingBorder:SetTexture(PENDING_BORDER) + + self:SetSize(borderSize, borderSize) + self.IconBackdrop:SetSize(currentWidth, currentWidth) + + + + iconBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0)) + trackingBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0)) + + self.tagIcon:SetShown((not self.filtered) and true or false) + self.tagIcon:SetAtlas(self.tagAtlas) + self.EliteBorder:SetShown(self.isElite and not self.filtered) + + self:UpdateStatus() + + if self.isBounty then + --print('is bounty') + iconBorder:SetVertexColor(trackingBorder:GetVertexColor()) + trackingBorder:SetVertexColor(unpack(BORDER_SELECTED_BOUNTY)) + elseif self.isCriteria then + --print('is criteria of a bounty') + iconBorder:SetVertexColor(trackingBorder:GetVertexColor()) + trackingBorder:SetVertexColor(unpack(BORDER_CRITERIA)) + else + + iconBorder:SetVertexColor(unpack(borderColor)) + trackingBorder:SetVertexColor(0,0,0,.5) + end + + if SpellCanTargetQuest() then + if IsQuestIDValidSpellTarget(self.questID) then + icon:SetVertexColor(1,1,1) + else + icon:SetVertexColor(1,0,0,1) + end + self:EnableMouse(false) + else + self:EnableMouse(true) + end + self.isStale = nil + + -- signal filter info update + WorldPlanSummary.isStale = true +end + +-- Called at static intervals and with Refresh +function QuestPOI:UpdateStatus() + -- update time elements + self.isActive = TQ_IsActive(self.questID) + + if self.isActive then + local tl = self.alertLevel + local timeLeft = TQ_GetQuestTimeLeftMinutes(self.questID) + if timeLeft > 0 then + + local text, timeState = WorldPlan:GetTimeInfo(timeLeft, self.maxAlertLevel) + if tl ~= timeState then + tl = timeState + self.timeLabel:SetText(text) + end + end + + local border = (self.isBounty or self.isCriteria) and self.RewardBorder or self.HighlightBorder + + if tl and (timeLeft < 120) then + border:SetVertexColor(1,0,0,0.7) + else + border:SetVertexColor(0,0,0,0.7) + end + self.alertLevel = tl + self.timeLabel:SetShown(self.worldQuest and (self.maxAlertLevel >= 1)) + else + self.hideReason = "No longer active." + self:HideOrShowFrames(false) + + end +end + +-- Show/Hide the text overlays associated with the quest pin; they aren't hierarchically linked +function QuestPOI:HideOrShowFrames(isShown) + if not isShown then + -- print('|cFFFFFF00' ..self:GetName()..':HideOrShowFrames()') + -- do not SetShown() here + if not self.hideReason then + self.hideReason = "HideOrShowFrames() called" + end + end + self.Overlay:SetShown(isShown) + self.count:SetShown(isShown) + self.timeLabel:SetShown(isShown) +end + +function QuestPOI:Release() + + self.hideReason = 'Released by script.' + self:SetShown(false) + if self.questID then + db.QuestsByID[self.questID] = nil + for _, map in pairs(db.QuestsByZone) do + map[self.questID] = nil + end + self.questID = nil + end + self.isActive = nil + self.complete = nil + self.used = nil + self.dataLoaded = nil + self.rewardType = nil + self.itemTexture = nil + self.itemName = nil + self.itemNumber = nil + self:SetShown(false) + self.animating = nil + self.icon:SetAlpha(0) + self.RewardBorder:SetAlpha(0) + self:UnregisterEvent('QUEST_TURNED_IN') + self:UnregisterEvent('QUEST_LOG_UPDATE') + + for i, pin in ipairs(db.UsedPins) do + if pin == self then + tremove(db.UsedPins, i) + break end end - if self.rarity and WORLD_QUEST_QUALITY_COLORS[self.rarity] then - highlightWidth = highlightWidth + self.rarity - end - self.tagIcon:SetSize(self.tagSize, self.tagSize) - icon:SetSize(iconWidth, iconWidth) - iconBorder:SetSize(borderWidth, borderWidth) - trackingBorder:SetSize(highlightWidth, highlightWidth) - - - iconBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0)) - trackingBorder:SetPoint('CENTER', (style.x or 0), (style.y or 0)) - - - if (subStyle.showNumber and self.itemNumber) and style.hasNumeric then - self.count:SetTextColor(unpack(style.numberRGB)) - if subStyle.numberFontObject then - --wqprint('change font', _G[subStyle.numberFontObject]:GetName()) - self.count:SetFontObject(_G[subStyle.numberFontObject]) - end - else - self.count:SetText(nil) - end - --]] + tinsert(db.FreePins, self) + WorldPlan.dataFlush = true end \ No newline at end of file