diff --git a/Libs/LibArtifactData-1.0/.docmeta b/Libs/LibArtifactData-1.0/.docmeta new file mode 100644 index 0000000..8b21e72 --- /dev/null +++ b/Libs/LibArtifactData-1.0/.docmeta @@ -0,0 +1,4 @@ +- + type: markdown + input-file: README.md + output-page: Main diff --git a/Libs/LibArtifactData-1.0/.pkgmeta b/Libs/LibArtifactData-1.0/.pkgmeta new file mode 100644 index 0000000..2ad3071 --- /dev/null +++ b/Libs/LibArtifactData-1.0/.pkgmeta @@ -0,0 +1,11 @@ +package-as: LibArtifactData-1.0 + +externals: + LibStub: + url: svn://svn.wowace.com/wow/libstub/mainline/trunk + tag: latest + CallbackHandler-1.0: + url: svn://svn.wowace.com/wow/callbackhandler/mainline/trunk/CallbackHandler-1.0 + tag: latest + +enable-nolib-creation: no diff --git a/Libs/LibArtifactData-1.0/LibArtifactData-1.0.lua b/Libs/LibArtifactData-1.0/LibArtifactData-1.0.lua new file mode 100644 index 0000000..97621d5 --- /dev/null +++ b/Libs/LibArtifactData-1.0/LibArtifactData-1.0.lua @@ -0,0 +1,497 @@ +local MAJOR, MINOR = "LibArtifactData-1.0", 5 + +assert(_G.LibStub, MAJOR .. " requires LibStub") +local lib = _G.LibStub:NewLibrary(MAJOR, MINOR) +if not lib then return end + +lib.callbacks = lib.callbacks or _G.LibStub("CallbackHandler-1.0"):New(lib) + +local Debug = function() end +if _G.AdiDebug then + Debug = _G.AdiDebug:Embed({}, MAJOR) +end + +-- local store +local artifacts = {} +local equippedID, viewedID, activeID +artifacts.knowledgeLevel = 0 +artifacts.knowledgeMultiplier = 1 + +-- constants +local _G = _G +local BACKPACK_CONTAINER = _G.BACKPACK_CONTAINER +local BANK_CONTAINER = _G.BANK_CONTAINER +local INVSLOT_MAINHAND = _G.INVSLOT_MAINHAND +local LE_ITEM_CLASS_WEAPON = _G.LE_ITEM_CLASS_WEAPON +local LE_ITEM_QUALITY_ARTIFACT = _G.LE_ITEM_QUALITY_ARTIFACT +local NUM_BAG_SLOTS = _G.NUM_BAG_SLOTS +local NUM_BANKBAGSLOTS = _G.NUM_BANKBAGSLOTS + +-- blizzard api +local aUI = _G.C_ArtifactUI +local Clear = aUI.Clear +local GetArtifactInfo = aUI.GetArtifactInfo +local GetArtifactKnowledgeLevel = aUI.GetArtifactKnowledgeLevel +local GetArtifactKnowledgeMultiplier = aUI.GetArtifactKnowledgeMultiplier +local GetContainerItemInfo = _G.GetContainerItemInfo +local GetContainerNumSlots = _G.GetContainerNumSlots +local GetCostForPointAtRank = aUI.GetCostForPointAtRank +local GetCurrencyInfo = _G.GetCurrencyInfo +local GetEquippedArtifactInfo = aUI.GetEquippedArtifactInfo +local GetInventoryItemEquippedUnusable = _G.GetInventoryItemEquippedUnusable +local GetItemInfo = _G.GetItemInfo +local GetNumObtainedArtifacts = aUI.GetNumObtainedArtifacts +local GetNumPurchasableTraits = _G.MainMenuBar_GetNumArtifactTraitsPurchasableFromXP +local GetNumRelicSlots = aUI.GetNumRelicSlots +local GetPowerInfo = aUI.GetPowerInfo +local GetPowers = aUI.GetPowers +local GetRelicInfo = aUI.GetRelicInfo +local GetRelicSlotType = aUI.GetRelicSlotType +local GetSpellInfo = _G.GetSpellInfo +local HasArtifactEquipped = _G.HasArtifactEquipped +local IsAtForge = aUI.IsAtForge +local IsViewedArtifactEquipped = aUI.IsViewedArtifactEquipped +local SocketContainerItem = _G.SocketContainerItem +local SocketInventoryItem = _G.SocketInventoryItem + +-- lua api +local select = _G.select +local strmatch = _G.string.match +local tonumber = _G.tonumber + +local private = {} -- private space for the event handlers + +lib.frame = lib.frame or _G.CreateFrame("Frame") +local frame = lib.frame +frame:UnregisterAllEvents() -- deactivate old versions +frame:SetScript("OnEvent", function(_, event, ...) private[event](event, ...) end) +frame:RegisterEvent("PLAYER_ENTERING_WORLD") +frame:RegisterEvent("ARTIFACT_CLOSE") +frame:RegisterEvent("ARTIFACT_XP_UPDATE") +frame:RegisterUnitEvent("PLAYER_SPECIALIZATION_CHANGED", "player") + +local function CopyTable(tbl) + if not tbl then return {} end + local copy = {}; + for k, v in pairs(tbl) do + if ( type(v) == "table" ) then + copy[k] = CopyTable(v); + else + copy[k] = v; + end + end + return copy; +end + +local function PrepareForScan() + frame:UnregisterEvent("ARTIFACT_UPDATE") + local ArtifactFrame = _G.ArtifactFrame + + if not ArtifactFrame or not ArtifactFrame:IsShown() then + _G.UIParent:UnregisterEvent("ARTIFACT_UPDATE") + if ArtifactFrame then + ArtifactFrame:UnregisterEvent("ARTIFACT_UPDATE") + end + end +end + +local function RestoreStateAfterScan() + frame:RegisterEvent("ARTIFACT_UPDATE") + local ArtifactFrame = _G.ArtifactFrame + + if not ArtifactFrame or not ArtifactFrame:IsShown() then + Clear() + if ArtifactFrame then + ArtifactFrame:RegisterEvent("ARTIFACT_UPDATE") + end + _G.UIParent:RegisterEvent("ARTIFACT_UPDATE") + end +end + +local function InformEquippedArtifactChanged(artifactID) + if artifactID ~= equippedID then + Debug("ARTIFACT_EQUIPPED_CHANGED", artifactID, equippedID) + lib.callbacks:Fire("ARTIFACT_EQUIPPED_CHANGED", artifactID, equippedID) + equippedID = artifactID + end +end + +local function InformActiveArtifactChanged(artifactID) + local oldActiveID = activeID + if artifactID and not GetInventoryItemEquippedUnusable("player", INVSLOT_MAINHAND) then + activeID = artifactID + else + activeID = nil + end + if oldActiveID ~= activeID then + Debug("ARTIFACT_ACTIVE_CHANGED", activeID, oldActiveID) + lib.callbacks:Fire("ARTIFACT_ACTIVE_CHANGED", activeID, oldActiveID) + end +end + +local function InformTraitsChanged(artifactID) + Debug("ARTIFACT_TRAITS_CHANGED", artifactID, artifacts[artifactID].traits) + lib.callbacks:Fire("ARTIFACT_TRAITS_CHANGED", artifactID, CopyTable(artifacts[artifactID].traits)) +end + +local function StoreArtifact(artifactID, name, icon, unspentPower, numRanksPurchased, numRanksPurchasable, power, maxPower, traits, relics) + if not artifacts[artifactID] then + artifacts[artifactID] = { + name = name, + icon = icon, + unspentPower = unspentPower, + numRanksPurchased = numRanksPurchased, + numRanksPurchasable = numRanksPurchasable, + power = power, + maxPower = maxPower, + powerForNextRank = maxPower - power, + traits = traits, + relics = relics, + } + Debug("ARTIFACT_ADDED", artifactID, name) + lib.callbacks:Fire("ARTIFACT_ADDED", artifactID) + else + local current = artifacts[artifactID] + current.unspentPower = unspentPower + current.numRanksPurchased = numRanksPurchased -- numRanksPurchased does not include bonus traits from relics + current.numRanksPurchasable = numRanksPurchasable + current.power = power + current.maxPower = maxPower + current.powerForNextRank = maxPower - power + current.traits = traits + current.relics = relics + end +end + +local function ScanTraits(artifactID) + local traits = {} + local powers = GetPowers() + + for i = 1, #powers do + local traitID = powers[i] + local spellID, _, currentRank, maxRank, bonusRanks, _, _, _, isStart, isGold, isFinal = GetPowerInfo(traitID) + if currentRank > 0 then + local name, _, icon = GetSpellInfo(spellID) + traits[#traits + 1] = { + traitID = traitID, + spellID = spellID, + name = name, + icon = icon, + currentRank = currentRank, + maxRank = maxRank, + bonusRanks = bonusRanks, + isGold = isGold, + isStart = isStart, + isFinal = isFinal, + } + end + end + + if artifactID then + artifacts[artifactID].traits = traits + end + + return traits +end + +local function ScanRelics(artifactID) + local relics = {} + for i = 1, GetNumRelicSlots() do + local slotType = GetRelicSlotType(i) + local lockedReason, name, icon, link = GetRelicInfo(i) + local isLocked = lockedReason and true or false + local itemID + if name then + itemID = strmatch(link, "item:(%d+):") + end + + relics[i] = { type = slotType, isLocked = isLocked, name = name, icon = icon, itemID = itemID, link = link } + end + + if artifactID then + artifacts[artifactID].relics = relics + end + + return relics +end + +local function GetArtifactKnowledge() + local lvl = GetArtifactKnowledgeLevel() + local mult = GetArtifactKnowledgeMultiplier() + if artifacts.knowledgeMultiplier ~= mult or artifacts.knowledgeLevel ~= lvl then + artifacts.knowledgeLevel = lvl + artifacts.knowledgeMultiplier = mult + Debug("ARTIFACT_KNOWLEDGE_CHANGED", lvl, mult) + lib.callbacks:Fire("ARTIFACT_KNOWLEDGE_CHANGED", lvl, mult) + end +end + +local function GetViewedArtifactData() + GetArtifactKnowledge() + local itemID, _, name, icon, unspentPower, numRanksPurchased = GetArtifactInfo() -- TODO: appearance stuff needed? altItemID ? + viewedID = itemID + Debug("GetViewedArtifactData", name, itemID) + local numRanksPurchasable, power, maxPower = GetNumPurchasableTraits(numRanksPurchased, unspentPower) + local traits = ScanTraits() + local relics = ScanRelics() + StoreArtifact(itemID, name, icon, unspentPower, numRanksPurchased, numRanksPurchasable, power, maxPower, traits, relics) + + if IsViewedArtifactEquipped() then + InformEquippedArtifactChanged(itemID) + InformActiveArtifactChanged(itemID) + end +end + +local function ScanContainer(container, numObtained) + for slot = 1, GetContainerNumSlots(container) do + local _, _, _, quality, _, _, _, _, _, itemID = GetContainerItemInfo(container, slot) + if quality == LE_ITEM_QUALITY_ARTIFACT then + local classID = select(12, GetItemInfo(itemID)) + if classID == LE_ITEM_CLASS_WEAPON then + Debug("ARTIFACT_FOUND", "in", container, slot) + SocketContainerItem(container, slot) + GetViewedArtifactData() + Clear() + numObtained = numObtained - 1 + if numObtained <= 0 then break end + end + end + end + + return numObtained +end + +local function IterateContainers(from, to, numObtained) + for container = from, to do + numObtained = ScanContainer(container, numObtained) + if numObtained <= 0 then break end + end + + return numObtained +end + +local function ScanBank(numObtained) + PrepareForScan() + numObtained = ScanContainer(BANK_CONTAINER, numObtained) + if numObtained > 0 then + IterateContainers(NUM_BAG_SLOTS + 1, NUM_BAG_SLOTS + NUM_BANKBAGSLOTS, numObtained) + end + RestoreStateAfterScan() +end + +local function InitializeScan(event) + if _G.ArtifactFrame and _G.ArtifactFrame:IsShown() then + Debug("InitializeScan", "aborted because ArtifactFrame is open.") + return + end + + local numObtained = GetNumObtainedArtifacts() -- not available at cold login + Debug("InitializeScan", event, "numObtained", numObtained) + + if numObtained > 0 then + PrepareForScan() + if HasArtifactEquipped() then -- scan equipped + SocketInventoryItem(INVSLOT_MAINHAND) + GetViewedArtifactData() + Clear() + numObtained = numObtained - 1 + end + if numObtained > 0 then -- scan bags + numObtained = IterateContainers(BACKPACK_CONTAINER, NUM_BAG_SLOTS, numObtained) + end + if numObtained > 0 then -- scan bank + frame:RegisterEvent("BANKFRAME_OPENED") + Debug("ARTIFACT_DATA_MISSING", "artifact", numObtained) + lib.callbacks:Fire("ARTIFACT_DATA_MISSING", numObtained) + end + RestoreStateAfterScan() + end +end + +function private.PLAYER_ENTERING_WORLD(event) + _G.C_Timer.After(5, function() + InitializeScan(event) + frame:RegisterEvent("PLAYER_EQUIPMENT_CHANGED") + frame:RegisterEvent("CURRENCY_DISPLAY_UPDATE") + end) +end + +function private.ARTIFACT_CLOSE() + viewedID = nil +end + +function private.ARTIFACT_UPDATE(event, newItem) + Debug(event, newItem) + if newItem then + GetViewedArtifactData() + else + local newRelics = ScanRelics() + local oldRelics = artifacts[viewedID].relics + + for i = 1, #newRelics do + local newRelic = newRelics[i] + -- TODO: test third slot unlock + if newRelic.isLocked ~= oldRelics[i].isLocked or newRelic.itemID ~= oldRelics[i].itemID then + oldRelics[i] = newRelic + Debug("ARTIFACT_RELIC_CHANGED", viewedID, i, newRelic) + lib.callbacks:Fire("ARTIFACT_RELIC_CHANGED", viewedID, i, CopyTable(newRelic)) + -- if a relic changed, so did the traits + ScanTraits(viewedID) + InformTraitsChanged(viewedID) + break + end + end + end +end + +function private.ARTIFACT_XP_UPDATE(event) + -- at the forge the player can purchase traits even for unequipped artifacts + local GetInfo = IsAtForge() and GetArtifactInfo or GetEquippedArtifactInfo + local itemID, _, _, _, unspentPower, numRanksPurchased = GetInfo() + local numRanksPurchasable, power, maxPower = GetNumPurchasableTraits(numRanksPurchased, unspentPower) + + local artifact = artifacts[itemID] + local diff = unspentPower - artifact.unspentPower + + if numRanksPurchased ~= artifact.numRanksPurchased then + -- both learning traits and artifact respec trigger ARTIFACT_XP_UPDATE + -- however respec has a positive diff and learning traits has a negative one + ScanTraits(itemID) + InformTraitsChanged(itemID) + end + + if diff ~= 0 then + artifact.unspentPower = unspentPower + artifact.power = power + artifact.maxPower = maxPower + artifact.numRanksPurchased = numRanksPurchased + artifact.numRanksPurchasable = numRanksPurchasable + artifact.powerForNextRank = maxPower - power + Debug(event, itemID, diff, unspentPower, power, maxPower, maxPower - power, numRanksPurchasable) + lib.callbacks:Fire("ARTIFACT_POWER_CHANGED", itemID, diff, unspentPower, power, maxPower, maxPower - power, numRanksPurchasable) + end +end + +function private.BANKFRAME_OPENED() + local numObtained = lib:GetNumObtainedArtifacts() + if numObtained ~= GetNumObtainedArtifacts() then + ScanBank(numObtained) + end +end + +function private.CURRENCY_DISPLAY_UPDATE(event) + local _, lvl = GetCurrencyInfo(1171) + if lvl ~= artifacts.knowledgeLevel then + artifacts.knowledgeLevel = lvl + Debug("ARTIFACT_DATA_MISSING", event, lvl) + lib.callbacks:Fire("ARTIFACT_DATA_MISSING", "knowledge", lvl) + end +end + +function private.PLAYER_EQUIPMENT_CHANGED(event, slot) + if slot == INVSLOT_MAINHAND then + local itemID = GetEquippedArtifactInfo() + + if itemID and not artifacts[itemID] then + InitializeScan(event) + end + + InformEquippedArtifactChanged(itemID) + InformActiveArtifactChanged(itemID) + end +end + +-- needed in case the game fails to switch artifacts +function private.PLAYER_SPECIALIZATION_CHANGED(event) + local itemID = GetEquippedArtifactInfo() + Debug(event, itemID) + InformActiveArtifactChanged(itemID) +end + +function lib.GetActiveArtifactID() + return activeID +end + +function lib.GetArtifactInfo(_, artifactID) + artifactID = artifactID or equippedID + return artifactID, CopyTable(artifacts[artifactID]) +end + +function lib.GetAllArtifactsInfo() + return CopyTable(artifacts) +end + +function lib.GetNumObtainedArtifacts() + local numArtifacts = 0 + for artifact in pairs(artifacts) do + if tonumber(artifact) then + numArtifacts = numArtifacts + 1 + end + end + + return numArtifacts +end + +function lib.GetArtifactTraits(_, artifactID) + artifactID = artifactID or equippedID + for itemID, data in pairs(artifacts) do + if itemID == artifactID then + return artifactID, CopyTable(data.traits) + end + end +end + +function lib.GetArtifactRelics(_, artifactID) + artifactID = artifactID or equippedID + for itemID, data in pairs(artifacts) do + if itemID == artifactID then + return artifactID, CopyTable(data.relics) + end + end +end + +function lib.GetArtifactPower(_, artifactID) + artifactID = artifactID or equippedID + for itemID, data in pairs(artifacts) do + if itemID == artifactID then + return artifactID, data.unspentPower, data.power, data.maxPower, data.powerForNextRank, data.numRanksPurchased, data.numRanksPurchasable + end + end +end + +function lib.GetArtifactKnowledge() + return artifacts.knowledgeLevel, artifacts.knowledgeMultiplier +end + +function lib.GetAcquiredArtifactPower(_, artifactID) + local total = 0 + + if artifactID then + local data = artifacts[artifactID] + total = total + data.unspentPower + local rank = 1 + while rank <= data.numRanksPurchased do + total = total + GetCostForPointAtRank(rank) + rank = rank + 1 + end + + return total + end + + for itemID, data in pairs(artifacts) do + if tonumber(itemID) then + total = total + data.unspentPower + local rank = 1 + while rank <= data.numRanksPurchased do + total = total + GetCostForPointAtRank(rank) + rank = rank + 1 + end + end + end + + return total +end + +function lib.ForceUpdate() + InitializeScan("FORCE_UPDATE") +end diff --git a/Libs/LibArtifactData-1.0/LibArtifactData-1.0.toc b/Libs/LibArtifactData-1.0/LibArtifactData-1.0.toc new file mode 100644 index 0000000..57abd20 --- /dev/null +++ b/Libs/LibArtifactData-1.0/LibArtifactData-1.0.toc @@ -0,0 +1,13 @@ +## Interface: 70000 +## Title: Lib: ArtifactData-1.0 +## Notes: Provides data about all artifacts in the player's possession. +## Author: Rainrider +## X-Category: Library +## Version: @project-version@ +## LoadOnDemand: 1 +## OptionalDeps: AdiDebug + +LibStub\LibStub.lua +CallbackHandler-1.0\CallbackHandler-1.0.lua + +LibArtifactData-1.0.lua diff --git a/Libs/LibArtifactData-1.0/README.md b/Libs/LibArtifactData-1.0/README.md new file mode 100644 index 0000000..2eaf1d3 --- /dev/null +++ b/Libs/LibArtifactData-1.0/README.md @@ -0,0 +1,25 @@ +## Description + +LibArtifactData-1.0 is a data store for addons that need the player's artifacts data. It has a simple API for data access and uses CallbackHandler-1.0 to propagate data changes. + +## Why to use + +The stock UI provides much of the artifact data only when an artifact is viewed and only for that one artifact. If an addon requires that data prior to the player opening the Artifact UI, or for all artifacts at once, it has to unregister the events the UI uses (so that it doesn't tamper with other UI elements), simulate a shift-right click on the artifact, collect the data and then restore the default state. However this would make the ARTIFACT_UPDATE event fire, upon which all addons listening to it will scan for data anew. This leads to duplicated efforts and possibly some pointless scans, since ARTIFACT_UPDATE does not automatically mean that the data actually changed. + +LibArtifactData-1.0 tries to leverage this behavior by keeping the data for all artifacts accessible all the time and informs interested addons about changes when they actually occur. + +## Limitations + +Data about artifacts placed in the bank is not available until the player opens the bank. LibArtifactData-1.0 can detect such a case and inform addons that some of the data is missing. + +Currently LibArtifactData-1.0 does not collect appearance data. + +## Feedback + +If you have problems using the library, run into any issues or have a feature request, please use the [issue tracker](https://github.com/Rainrider/LibArtifactData-1.0/issues). + +## Further reading + 1. [How to use](https://github.com/Rainrider/LibArtifactData-1.0/wiki/How-to-use) + 2. [API](https://github.com/Rainrider/LibArtifactData-1.0/wiki/API) + 3. [Events](https://github.com/Rainrider/LibArtifactData-1.0/wiki/Events) + 4. [Data structure](https://github.com/Rainrider/LibArtifactData-1.0/wiki/Data-structure) diff --git a/embeds.xml b/embeds.xml index 14c0d68..be42132 100644 --- a/embeds.xml +++ b/embeds.xml @@ -10,6 +10,7 @@ <Include file="Libs\AceConsole-3.0\AceConsole-3.0.xml"/> <Include file="Libs\AceConfig-3.0\AceConfig-3.0.xml"/> <Include file="Libs\LibSharedMedia-3.0\lib.xml"/> + <Include file="Libs\LibArtifactData-1.0\LibArtifactData-1.0.lua"/> </Ui> <!-- diff --git a/modules/talent.lua b/modules/talent.lua index 91cefdb..959b610 100644 --- a/modules/talent.lua +++ b/modules/talent.lua @@ -23,6 +23,7 @@ function TalentModule:OnInitialize() self.specButtons = {} self.lootSpecButtons = {} self.classIcon = xb.constants.mediaPath..'spec\\'..xb.constants.playerClass + self.LAD = LibStub('LibArtifactData-1.0') end function TalentModule:OnEnable() @@ -54,15 +55,18 @@ function TalentModule:Refresh() if self.talentFrame == nil then return; end if not db.modules.talent.enabled then return; end + local artifactId = self.LAD:GetActiveArtifactID() or 0 + self.currentSpecID = GetSpecialization() self.currentLootSpecID = GetLootSpecialization() local iconSize = db.text.fontSize + db.general.barPadding local _, name, _ = GetSpecializationInfo(self.currentSpecID) - - --local textHeight = floor((xb:GetHeight() - 4) / 2) -- This will be useful once we add artifact info local textHeight = db.text.fontSize + if artifactId > 0 then + textHeight = floor((xb:GetHeight() - 4) / 2) + end self.specIcon:SetTexture(self.classIcon) self.specIcon:SetTexCoord(unpack(self.specCoords[self.currentSpecID])) @@ -74,15 +78,16 @@ function TalentModule:Refresh() self.specText:SetTextColor(db.color.inactive.r, db.color.inactive.g, db.color.inactive.b, db.color.inactive.a) self.specText:SetText(string.upper(name)) - self.specText:SetPoint('LEFT', self.specIcon, 'RIGHT', 5, 0) + if artifactId > 0 then + self.specText:SetPoint('TOPLEFT', self.specIcon, 'TOPRIGHT', 5, 0) + else + self.specText:SetPoint('LEFT', self.specIcon, 'RIGHT', 5, 0) + end self.lootSpecButtons[0].icon:SetTexture(self.classIcon) self.lootSpecButtons[0].icon:SetTexCoord(unpack(self.specCoords[self.currentSpecID])) - --[[ - if skill == cap then - self.specText:SetPoint('LEFT', self.specIcon, 'RIGHT', 5, 0) - else - self.specText:SetPoint('TOPLEFT', self.specIcon, 'TOPRIGHT', 5, 0) + + if artifactId > 0 then self.specBar:SetStatusBarTexture(1, 1, 1) if db.modules.tradeskill.barCC then self.specBar:SetStatusBarColor(xb:GetClassColors()) @@ -94,7 +99,8 @@ function TalentModule:Refresh() self.specBarBg:SetAllPoints() self.specBarBg:SetColorTexture(db.color.inactive.r, db.color.inactive.g, db.color.inactive.b, db.color.inactive.a) - end]]-- + self:UpdateArtifactBar(artifactId) + end self.specFrame:SetSize(iconSize + self.specText:GetStringWidth() + 5, xb:GetHeight()) self.specFrame:SetPoint('LEFT') @@ -126,6 +132,12 @@ function TalentModule:Refresh() self.talentFrame:SetPoint('RIGHT', anchorFrame, relativeAnchorPoint, -(xOffset), 0) end +function TalentModule:UpdateArtifactBar(artifactId) + local _, artifactData = self.LAD:GetArtifactInfo(artifactId) + self.specBar:SetMinMaxValues(0, artifactData.maxPower) + self.specBar:SetValue(artifactData.power) +end + function TalentModule:CreateFrames() self.specFrame = self.specFrame or CreateFrame("BUTTON", nil, self.talentFrame, 'SecureActionButtonTemplate') self.specIcon = self.specIcon or self.specFrame:CreateTexture(nil, 'OVERLAY') @@ -147,6 +159,8 @@ function TalentModule:RegisterFrameEvents() self:RegisterEvent('ACTIVE_TALENT_GROUP_CHANGED', 'Refresh') self:RegisterEvent('PLAYER_LOOT_SPEC_UPDATED', 'Refresh') + -- ARTIFACT_ACTIVE_CHANGED + self.specFrame:EnableMouse(true) self.specFrame:RegisterForClicks('AnyUp')