From d83813057f4462829ff2d29ce5d1cc70331da4cb Mon Sep 17 00:00:00 2001 From: MilleXIV Date: Thu, 1 Sep 2016 19:37:06 -0400 Subject: [PATCH] Artifact Bar and Tooltips --- locales/enUS.lua | 4 ++++ modules/talent.lua | 51 ++++++++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/locales/enUS.lua b/locales/enUS.lua index 791b2d8..687ef00 100644 --- a/locales/enUS.lua +++ b/locales/enUS.lua @@ -116,3 +116,7 @@ L['Set Specialization'] = true; L['Set Loot Specialization'] = true; L['Current Specialization'] = true; L['Current Loot Specialization'] = true; +L['Talent Minimum Width'] = true; +L['Remaining'] = true; +L['Available Ranks'] = true; +L['Artifact Knowledge'] = true; diff --git a/modules/talent.lua b/modules/talent.lua index f4c840d..420fe6f 100644 --- a/modules/talent.lua +++ b/modules/talent.lua @@ -24,6 +24,7 @@ function TalentModule:OnInitialize() self.lootSpecButtons = {} self.classIcon = xb.constants.mediaPath..'spec\\'..xb.constants.playerClass self.LAD = LibStub('LibArtifactData-1.0') + self.curArtifactId = 0 end function TalentModule:OnEnable() @@ -38,6 +39,7 @@ function TalentModule:OnEnable() self:CreateFrames() self:RegisterFrameEvents() + self.LAD:ForceUpdate() self:Refresh() end @@ -55,8 +57,8 @@ function TalentModule:Refresh() if self.talentFrame == nil then return; end if not db.modules.talent.enabled then return; end - local artifactId = 0 - --local artifactId = self.LAD:GetActiveArtifactID() or 0 + --local artifactId = 0 + local artifactId = self.LAD:GetActiveArtifactID() or 0 self.currentSpecID = GetSpecialization() self.currentLootSpecID = GetLootSpecialization() @@ -67,6 +69,7 @@ function TalentModule:Refresh() local textHeight = db.text.fontSize if artifactId > 0 then textHeight = floor((xb:GetHeight() - 4) / 2) + self.curArtifactId = artifactId end self.specIcon:SetTexture(self.classIcon) self.specIcon:SetTexCoord(unpack(self.specCoords[self.currentSpecID])) @@ -105,6 +108,14 @@ function TalentModule:Refresh() self.specFrame:SetSize(iconSize + self.specText:GetStringWidth() + 5, xb:GetHeight()) self.specFrame:SetPoint('LEFT') + if self.specFrame:GetWidth() < db.modules.talent.minWidth then + self.specFrame:SetWidth(db.modules.talent.minWidth) + end + + if self.specBar:GetWidth() < db.modules.talent.minWidth then + self.specBar:SetWidth(db.modules.talent.minWidth) + end + self.talentFrame:SetSize(self.specFrame:GetWidth(), xb:GetHeight()) local popupPadding = xb.constants.popupPadding @@ -165,7 +176,11 @@ function TalentModule:RegisterFrameEvents() self:RegisterEvent('ACTIVE_TALENT_GROUP_CHANGED', 'Refresh') self:RegisterEvent('PLAYER_LOOT_SPEC_UPDATED', 'Refresh') - -- ARTIFACT_ACTIVE_CHANGED + self:RegisterEvent('ARTIFACT_XP_UPDATE', function() + UpdateArtifactBar(self.curArtifactId) + end) + + self:RegisterEvent('UNIT_INVENTORY_CHANGED', 'Refresh') self.specFrame:EnableMouse(true) self.specFrame:RegisterForClicks('AnyUp') @@ -434,7 +449,22 @@ function TalentModule:ShowTooltip() else _, name, _ = GetSpecializationInfoByID(self.currentLootSpecID) end - GameTooltip:AddLine("|cffffffff"..L['Current Loot Specialization']..": |cffffff00"..name.."|r") + GameTooltip:AddDoubleLine(L['Current Loot Specialization'], name, 1, 1, 0, 1, 1, 1) + + if self.curArtifactId > 0 then + GameTooltip:AddLine(" ") + local _, artifactData = self.LAD:GetArtifactInfo(self.curArtifactId) + local knowLevel, knowMult = self.LAD:GetArtifactKnowledge() + if knowLevel > 0 then + GameTooltip:AddDoubleLine(L['Artifact Knowledge']..':', string.format('%d (x%d)', knowLevel, ((knowMult) - 1 * 100)), 1, 1, 0, 1, 1, 1) + GameTooltip:AddLine(" ") + end + GameTooltip:AddDoubleLine(ARTIFACT_POWER..':', string.format('%d / %d (%d%%)', artifactData.power, artifactData.maxPower, floor((artifactData.power / artifactData.maxPower) * 100)), 1, 1, 0, 1, 1, 1) + GameTooltip:AddDoubleLine(L['Remaining']..':', string.format('%d (%d%%)', artifactData.powerForNextRank, floor((artifactData.powerForNextRank / artifactData.maxPower) * 100)), 1, 1, 0, 1, 1, 1) + if artifactData.numRanksPurchasable > 0 then + GameTooltip:AddDoubleLine(L['Available Ranks']..':', string.format('%d', artifactData.numRanksPurchasable), 1, 1, 0, 1, 1, 1) + end + end GameTooltip:AddLine(" ") GameTooltip:AddDoubleLine('<'..L['Left-Click']..'>', L['Set Specialization'], 1, 1, 0, 1, 1, 1) @@ -446,7 +476,8 @@ function TalentModule:GetDefaultOptions() return 'talent', { enabled = true, barCC = false, - showTooltip = true + showTooltip = true, + minWidth = 50 } end @@ -483,6 +514,16 @@ function TalentModule:GetConfig() type = "toggle", get = function() return xb.db.profile.modules.talent.showTooltip; end, set = function(_, val) xb.db.profile.modules.talent.showTooltip = val; self:Refresh(); end + }, + minWidth = { + name = L['Talent Minimum Width'], + type = 'range', + order = 4, + min = 10, + max = 200, + step = 10, + get = function() return xb.db.profile.modules.talent.minWidth; end, + set = function(info, val) xb.db.profile.modules.talent.minWidth = val; self:Refresh(); end } } } -- 1.7.9.5