# HG changeset patch # User Nenue # Date 1495275052 14400 # Node ID 0f47780a83c4c5ed51bec1ac5f28968199e05baf # Parent a86b99c84ccc527e5403d20c15c2f404c93c4937 ArtifactPower: - xp bar animations work beyond concordance rank 3 diff -r a86b99c84ccc -r 0f47780a83c4 Modules/ArtifactPower.lua --- a/Modules/ArtifactPower.lua Wed May 17 08:23:57 2017 -0400 +++ b/Modules/ArtifactPower.lua Sat May 20 06:10:52 2017 -0400 @@ -11,6 +11,8 @@ cache = {}, fishingCache = {}, scanQueue = {}, + worldQuestAP = 0, + worldQuestItems = {}, ItemButtons = {}, anchorPoint = 'TOP', anchorPriority = 3, @@ -155,6 +157,7 @@ end end local PENDING_HOOKS = {} +local guid = UnitGUID('player') local function RegisterInventoryFrame(name, listType, args) print('register', name, 'as inventory frame type =', (listType == BAG_FRAMES) and 'bags' or 'bank') @@ -169,7 +172,7 @@ function Module:Setup() print(self:GetName()..':Setup()') - local guid = UnitGUID('player') + guid = UnitGUID('player') VeneerData.ArtifactPower = VeneerData.ArtifactPower or defaultSettings self.db = VeneerData.ArtifactPower self.db[guid] = self.db[guid] or {} @@ -184,7 +187,6 @@ self.db.fishingCache[i] = data end - self.profile = self.db[guid] self.profile.cache = self.profile.cache or {} self.profile.cache.bagItems = self.profile.cache.bagItems or {} @@ -283,13 +285,16 @@ end end + self:UpdateWorldQuestsAP() + self:RegisterEvent('QUEST_LOG_UPDATE') + self.enabled = true - self.enabled = true self:ScanAllBags() self:Reanchor() end function Module:OnHide() print('|cFF88FF00OnHide()|r', debugstack()) + self:UnregisterEvent('QUEST_LOG_UPDATE') self:Reanchor() end function Module:OnEnter() @@ -379,6 +384,8 @@ if #queued_hooks >= 1 then CreateHook() end + elseif event == 'QUEST_LOG_UPDATE' then + self:UpdateWorldQuestsAP() elseif event == 'PLAYER_REGEN_DISABLED' then self:Hide() end @@ -396,9 +403,12 @@ end -function Module:OnMouseDown() +function Module:OnMouseDown(button) self.enabled = nil - self:Hide() + if button == 'RightButton' then + self:Hide() + end + end function Module:Update() @@ -426,40 +436,16 @@ end end - self.worldQuestAP = 0 - if WorldPlan then + if self.worldQuestAP then + bankText = (bankText and (bankText .. '\n') or '') .. '|cFFFFBB00World Quests:|r |cFFFFFFFF' .. ShortNumberString(self.worldQuestAP) .. '' + end - if not self.worldPlanHooked then - WorldPlan:RegisterDataCallback(function() - print('data udpate callback') - self:Update() - end) - self.worldPlanHooked = true - end - - - local showWQ - print('world plan is loaded') - local worldQuests = WorldPlan:GetQuestPins() - for index, pin in ipairs(worldQuests) do - if (pin.rewardType == WORLD_QUEST_REWARD_TYPE_FLAG_ARTIFACT_POWER) and (pin.isActive) and (pin.dataLoaded) then - showWQ = true - print(pin.itemNumber) - self.worldQuestAP = self.worldQuestAP + pin.itemNumber - end - end - - if showWQ then - bankText = (bankText and (bankText .. '\n') or '') .. '|cFFFFBB00World Quests:|r |cFFFFFFFF' .. ShortNumberString(self.worldQuestAP) .. '' - end - - end self.SummaryHeader:SetText(bankText) local numButtons = 0 local contentsHeight = 16 + self.SummaryHeader:GetHeight() - local contentsWidth = self.SummaryHeader:GetWidth() + 16 + local contentsWidth = 400 if self.profile.knowledgeMultiplier then local artifactsWidth = self:UpdateArtifactButtons() @@ -467,7 +453,7 @@ contentsHeight = contentsHeight + 64 end - contentsWidth = max(contentsWidth, artifactsWidth) + contentsWidth = max(contentsWidth, min(artifactsWidth, 400)) local itemsWidth, itemsHeight = self:UpdateItemButtons() contentsHeight = contentsHeight + itemsHeight @@ -485,6 +471,64 @@ self:Reanchor() end +local BROKEN_ISLE_ID = 1007 + +function Module:UpdateWorldQuestsAP() + self.waitingForQuestRewardData = false + self.worldQuestAP = 0 + wipe(self.worldQuestItems) + + for zoneIndex = 1, C_MapCanvas.GetNumZones(BROKEN_ISLE_ID) do + local zoneMapID, zoneName, zoneDepth, left, right, top, bottom = C_MapCanvas.GetZoneInfo(BROKEN_ISLE_ID, zoneIndex); + --print(zoneMapID, zoneName) + if zoneDepth <= 1 then -- Exclude subzones + local taskInfo = C_TaskQuest.GetQuestsForPlayerByMapID(zoneMapID, BROKEN_ISLE_ID); + + if taskInfo then + for i, info in ipairs(taskInfo) do + local questID = info.questId + + local questTitle, factionID, capped = C_TaskQuest.GetQuestInfoByQuestID(questID) + --print(questTitle, HaveQuestRewardData(questID)) + if HaveQuestRewardData(questID) then + + + local numQuestRewards = GetNumQuestLogRewards(questID); + + if numQuestRewards > 0 then + for i = 1, numQuestRewards do + local name, texture, numItems, quality, isUsable, itemID = GetQuestLogRewardInfo(i, questID) + if IsArtifactPowerItem(itemID) then + local _, link = GetItemInfo(itemID) + if link then + local ap = self:GetItemAP(itemID, link) + --print('ap =', ap) + if ap then + self.worldQuestAP = self.worldQuestAP + ap + + end + + self.worldQuestItems[itemID] = (self.worldQuestItems[itemID] or 0) + 1 + end + + --print(self.worldQuestAP) + end + + end + + end + + + else + C_TaskQuest.RequestPreloadRewardData(questID); + self.waitingForQuestRewardData = true + end + end + end + end + end +end + function Module:UpdateArtifactButtons() -- Artifact icons, in no particular order @@ -907,7 +951,7 @@ local actualXP = artifact.currentXP local actualLevel = artifact.level local actualCost = C_ArtifactUI.GetCostForPointAtRank(actualLevel, artifact.tier) - local totalXP = actualXP + unusedXP + local totalXP = actualXP local totalCost = actualCost local totalLevel = actualLevel @@ -924,17 +968,17 @@ if unusedXP > 0 then - local remaining = totalXP + local remaining = totalXP + unusedXP local nextCost = artifact.currentCost totalCost = nextCost while remaining > nextCost do totalLevel = totalLevel + 1 - totalCost = totalCost + nextCost + remaining = remaining - nextCost nextCost = C_ArtifactUI.GetCostForPointAtRank(totalLevel, artifact.tier) - remaining = remaining - nextCost - print('|cFFFFFF00+ ', totalLevel, remaining, '/', nextCost) + print('|cFFFFFF00+ ', totalLevel, remaining, '/', totalCost) end - + totalXP = remaining + totalCost = nextCost end print('total:', totalLevel, totalXP, '/', totalCost) @@ -977,7 +1021,6 @@ -- potential: total of ap on hand print(self.currentXP, self.actualXP, self.potentialXP) if self.actualLevel ~= self.level then - levelText = self.actualLevel r1, g1, b1 = 0, 1, 0 --r2, g2, b2 = 0, 1, 0 @@ -1011,7 +1054,8 @@ end local currentProgress = (self.currentXP < self.currentCost) and (self.currentXP / self.currentCost) or 1 - if self.level <= 53 then + print('|cFFFF4400', currentProgress) + if self.level <= 92 then self.CurrentProgress.animateFrom = self.CurrentProgress:GetHeight() or 1 self.CurrentProgress.animateTo = currentProgress * self:GetHeight() self.CurrentProgress:Show() @@ -1021,8 +1065,9 @@ self.ProgressLine:Hide() end - if self.actualXP ~= self.currentXP then - local projectedProgress = (self.actualXP ~= self.actualCost) and (self.actualXP / self.actualCost) or 1 + if self.totalXP ~= self.currentXP then + local projectedProgress = (self.totalXP / self.totalCost) + print('|cFF00FFFF', projectedProgress) if (projectedProgress > currentProgress) then self.AdjustedProgress:SetPoint('BOTTOM', self.CurrentProgress, 'TOP') projectedProgress = projectedProgress - currentProgress @@ -1037,9 +1082,12 @@ self.AdjustedLine:Show() self.AdjustedProgress:Show() else + self.CurrentProgress:SetPoint('BOTTOM', self, 'BOTTOM') self.AdjustedProgress:Hide() self.AdjustedLine:Hide() end + print(self.CurrentProgress:GetPoint(3)) + print(self.CurrentProgress:GetSize()) if self.actualLevel ~= self.currentLevel then self:SetNormalTexture([[Interface\Buttons\UI-Quickslot-Depress]], 'ADD') @@ -1047,16 +1095,11 @@ self:GetNormalTexture():SetVertexColor(1,1,1) else self:SetNormalTexture(nil, 'ADD') - end - - - - self.Icon:SetTexture(self.texture) end - +local XP_SCALING_DURATION = .5 function Artifact:AnimateProgress(region) local cTime = GetTime() if not region.animateStart then @@ -1064,13 +1107,13 @@ end local progressTo, progressFrom = region.animateTo, region.animateFrom local elapsed = cTime - region.animateStart - if elapsed >= .5 then + if elapsed >= XP_SCALING_DURATION then region:SetHeight(progressTo) region.animateTo = nil region.animateStart = nil region.animateFrom = nil else - local progress = elapsed / .5 + local progress = elapsed / XP_SCALING_DURATION local height = (progressFrom + (progressTo - progressFrom) * progress) --print(self:GetName(), progressTo, progressFrom, (progressTo - progressFrom), ceil(progress*10)/10, ceil(height)) region:SetHeight(height) @@ -1090,9 +1133,9 @@ function Artifact:OnEnter() GameTooltip:SetOwner(self, 'ANCHOR_CURSOR') GameTooltip:SetText(self.name) - GameTooltip:AddLine(ShortNumberString(self.currentXP) .. ' / '..ShortNumberString(self.currentCost), 1, 1, 0) + GameTooltip:AddLine(ShortNumberString(self.currentXP) .. ' / '..ShortNumberString(self.currentCost), 1, 1, 1) if self.actualLevel ~= self.level then - GameTooltip:AddLine(ShortNumberString(self.actualLevel - self.level) .. ' points unlocked', 0, 1, 0) + GameTooltip:AddLine(ShortNumberString(self.actualLevel - self.level) .. ' points unlocked', 1, 1, 0) end if self.currentXP < self.currentCost then GameTooltip:AddLine(ShortNumberString(self.currentCost - self.currentXP) .. ' for level ' .. (self.currentLevel+1), 1, 1, 0) @@ -1122,7 +1165,7 @@ SocketInventoryItem(16) else if IsShiftKeyDown() then - SocketContainerItem(self.containerID, self.slotID) + SocketContainerItem(self.containerID, self.slotID) else end diff -r a86b99c84ccc -r 0f47780a83c4 Modules/ArtifactPower.xml --- a/Modules/ArtifactPower.xml Wed May 17 08:23:57 2017 -0400 +++ b/Modules/ArtifactPower.xml Sat May 20 06:10:52 2017 -0400 @@ -68,8 +68,9 @@ - - + + +