Mercurial > wow > worldplan
diff QuestPOI.lua @ 95:b29b35cb8539
- 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
- ClassOrderPlan can be closed with the game menu button
author | Nenue |
---|---|
date | Mon, 08 May 2017 22:38:52 -0400 |
parents | 98b5e08b75ed |
children | 8591401ec278 |
line wrap: on
line diff
--- a/QuestPOI.lua Sat Apr 15 11:05:32 2017 -0400 +++ b/QuestPOI.lua Mon May 08 22:38:52 2017 -0400 @@ -44,6 +44,7 @@ local overlayBaseIndex = 1380 local previousHighlight +local FADE_TIMING_MULTIPLIER = 3 local DATA_DEBUG = false local PIN_REFRESH_DELAY = 1 local PIN_REQUEST_DELAY = .2 @@ -93,7 +94,7 @@ borderWidth = 2, highlightWidth = 2, TagSize = 8, - maxAlertLevel = 0, + maxAlertLevel = 3, numberFontObject = 'WorldPlanFont' } local MINIMIZED_STYLE = { @@ -170,6 +171,39 @@ }} end + +do + local timeStates = { + {maxSeconds = 60, + r=1, g=0.25, b =0, format = function (minutes) return '|cFFFF4400'.. minutes .. 'm' end, + }, + {maxSeconds = 240, + r=1, g=.5, b=0, format = function(minutes) return '|cFFFF4400'.. floor(minutes/60) .. 'h' end, + }, + {maxSeconds = 1440, + r=1, g=1, b=0, format = function(minutes) return '|cFFFFFF00'.. floor(minutes/60) .. 'h' end, + }, + {maxSeconds = 10081, + r=0, g=1, b=0, + }, -- 7 days + 1 minute + } + -- Generates a timeleft string + function QuestPOI:GetTimeInfo(timeLeft, limit) + for index = 1, limit do + local state = timeStates[index] + if timeLeft <= state.maxSeconds then + local text + if state.format then + text = state.format(timeLeft) + end + return text, index, state + end + end + return + end +end + + local GetAchievementTooltipExtras = function(info) local hasInfo @@ -273,6 +307,12 @@ --print('|cFF00FF00refresh on show') self:Refresh('POI_ONSHOW_STALE') end + + if self.questID and IsQuestComplete(self.questID) then + self:Release() + return + end + self:RegisterEvent('QUEST_TURNED_IN') self:RegisterEvent('QUEST_LOG_UPDATE') self:HideOrShowFrames(true) @@ -393,16 +433,46 @@ function QuestPOI:OnUpdate (sinceLast) -- control update check intervals - if self.animating then - local alpha = self.icon:GetAlpha() + sinceLast*3 + if self.toAlpha then + if not self.alphaStart then + self.alphaStart = GetTime() + end - self.animateTime = (self.animateTime or 0) + sinceLast - if alpha >= 1 then - alpha = 1 - print('fade over', self.animateTime) - self.animating = nil - self.animateTime = nil + local alpha = self.icon:GetAlpha() + local alphaMod = ((GetTime()-self.alphaStart) *FADE_TIMING_MULTIPLIER) + if self:GetID() == 1 then + print(alpha, self.toAlpha, sinceLast, alphaMod) + end + if alpha > self.toAlpha then + alpha = alpha - (sinceLast*FADE_TIMING_MULTIPLIER) + + if (alpha <= self.toAlpha) then + alpha = self.toAlpha + self.toAlpha = nil + elseif (alpha <= 0) then + alpha = 0 + self.toAlpha = nil + end + elseif alpha < self.toAlpha then + alpha = alpha + alphaMod + + if (alpha >= self.toAlpha) then + alpha = self.toAlpha + self.toAlpha = nil + elseif (alpha >= 1) then + alpha = 1 + self.toAlpha = nil + end + + else + self.toAlpha = nil + end + + if not self.toAlpha then + self.alphaStart = nil + else + self.alphaStart = GetTime() end self.icon:SetAlpha(alpha) @@ -450,8 +520,9 @@ function QuestPOI:StartFading() - if not self.animating then - self.animating = true + if not self.toAlpha then + print('setting toAlpha') + self.toAlpha = 1 self.icon:SetAlpha(0) self.RewardBorder:SetAlpha(0) end @@ -507,7 +578,7 @@ self.dataLoaded = true self.isStale = true self.xpType, self.xpName, self.xpIcon, self.xpCount = xpType, xpName, xpIcon, xpCount - + WorldPlan.dataFlush = true end end @@ -683,9 +754,19 @@ 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) + local multiplier = (text:match('million') and 1000000) or 1 + if text then + text = text:gsub(',', '') + local ap = text:match('([%d]+) '..ARTIFACT_POWER) + if not ap then + ap = text:match('([%d%.]+) million '..ARTIFACT_POWER) + if ap then + ap = tonumber(ap) * 1000000 + end + end + if ap then + rewardCount = tonumber(ap) + end end end return rewardCount @@ -857,16 +938,15 @@ self.maxAlertLevel = style.maxAlertLevel or DEFAULT_STYLE.maxAlertLevel if self.dataLoaded then - print('new pin, has data, cue fade') if self.isNew then + print('new pin, has data, cue fade') 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) + if not self.toAlpha then + icon:SetAlpha(0) + iconBorder:SetAlpha(0) end end @@ -987,26 +1067,24 @@ function QuestPOI:UpdateStatus() -- update time elements self.isActive = TQ_IsActive(self.questID) + --print(self.maxAlertLevel) + local border = (self.isBounty or self.isCriteria) and self.RewardBorder or self.HighlightBorder 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) + local text, timeState, style = self:GetTimeInfo(timeLeft, self.maxAlertLevel) if tl ~= timeState then tl = timeState self.timeLabel:SetText(text) end + if style then + self.RewardBorder:SetVertexColor(style.r, style.g, style.b, style.a) + 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 @@ -1022,7 +1100,7 @@ -- print('|cFFFFFF00' ..self:GetName()..':HideOrShowFrames()') -- do not SetShown() here if not self.hideReason then - self.hideReason = "HideOrShowFrames() called" + self.hideReason = "HideOrShowFrames() called without a reason." end end self.Overlay:SetShown(isShown) @@ -1031,9 +1109,9 @@ end function QuestPOI:Release() - + print('|cFFFF4400'..self:GetID()..':Release()', self.hideReason) self.hideReason = 'Released by script.' - self:SetShown(false) + self:HideOrShowFrames(false) if self.questID then db.QuestsByID[self.questID] = nil for _, map in pairs(db.QuestsByZone) do @@ -1058,12 +1136,15 @@ for i, pin in ipairs(db.UsedPins) do if pin == self then + print('|cFFFF4400cleared from UsedPins|r') tremove(db.UsedPins, i) break end - end tinsert(db.FreePins, self) WorldPlan.dataFlush = true + WorldPlanSummary.isStale = true + + return true end \ No newline at end of file