Commit d2b53489 authored by Merathilis's avatar Merathilis

Updated Azerite Armor Tooltip.

Added option to only show icons. Disabled by default.
parent 24e180fd
......@@ -167,6 +167,7 @@ L["BattleOfDazaralor"] = "Schlacht um Dazar'alor"
L["CrucibleOfStorms"] = "Tiegel der Stürme"
L["FACTION"] = "Fraktion"
L["HEART_OF_AZEROTH_MISSING_ACTIVE_POWERS"] = "Aktive Azeritboni"
L["Only Icons"] = "Nur Symbole"
-- MailInputBox
L["Mail Inputbox Resize"] = "Post Eingabefeld"
......
......@@ -170,6 +170,7 @@ L["BattleOfDazaralor"] = "Battle Of Dazaralor"
L["CrucibleOfStorms"] = "Crucible Of Storms"
L["FACTION"] = "Faction"
L["HEART_OF_AZEROTH_MISSING_ACTIVE_POWERS"] = "Active Azerite Powers"
L["Only Icons"] = true
-- MailInputBox
L["Mail Inputbox Resize"] = true
......
......@@ -169,6 +169,7 @@ L["BattleOfDazaralor"] = "Battle Of Dazaralor"
L["CrucibleOfStorms"] = "Crucible Of Storms"
L["FACTION"] = "Faction"
L["HEART_OF_AZEROTH_MISSING_ACTIVE_POWERS"] = "Traits azéritiques actifs"
L["Only Icons"] = true
-- MailInputBox
L["Mail Inputbox Resize"] = true
......
......@@ -169,6 +169,7 @@ L["BattleOfDazaralor"] = "Battle Of Dazaralor"
L["CrucibleOfStorms"] = "Crucible Of Storms"
L["FACTION"] = "Fazione"
L["HEART_OF_AZEROTH_MISSING_ACTIVE_POWERS"] = "Abilità d'Azerite attive"
L["Only Icons"] = true
-- MailInputBox
L["Mail Inputbox Resize"] = true
......
......@@ -165,6 +165,7 @@ L["BattleOfDazaralor"] = "Battle Of Dazaralor"
L["CrucibleOfStorms"] = "Crucible Of Storms"
L["FACTION"] = "진영"
L["HEART_OF_AZEROTH_MISSING_ACTIVE_POWERS"] = "활성화된 아제라이트 능력"
L["Only Icons"] = true
-- MailInputBox
L["Mail Inputbox Resize"] = true
......
......@@ -167,6 +167,7 @@ L["BattleOfDazaralor"] = "Battle Of Dazaralor"
L["CrucibleOfStorms"] = "Crucible Of Storms"
L["FACTION"] = "Фракция"
L["HEART_OF_AZEROTH_MISSING_ACTIVE_POWERS"] = "Активные азеритовые таланты"
L["Only Icons"] = true
-- MailInputBox
L["Mail Inputbox Resize"] = true
......
......@@ -167,6 +167,7 @@ L["BattleOfDazaralor"] = "达萨罗之战"
L["CrucibleOfStorms"] = "风暴熔炉"
L["FACTION"] = "阵营"
L["HEART_OF_AZEROTH_MISSING_ACTIVE_POWERS"] = "已激活的艾泽里特之力"
L["Only Icons"] = true
-- MailInputBox
L["Mail Inputbox Resize"] = "收件箱大小调整"
......
......@@ -167,6 +167,7 @@ L["BattleOfDazaralor"] = "Battle Of Dazaralor"
L["CrucibleOfStorms"] = "Crucible Of Storms"
L["FACTION"] = "陣營"
L["HEART_OF_AZEROTH_MISSING_ACTIVE_POWERS"] = "啟動艾澤萊晶岩之力"
L["Only Icons"] = true
-- MailInputBox
L["Mail Inputbox Resize"] = true
......
......@@ -5,7 +5,7 @@ local MERTT = MER:GetModule("mUITooltip")
-- Lua functions
local _G = _G
local ipairs, select = ipairs, select
local strfind, format = string.find, string.format
local strmatch, format = strmatch, string.format
local tinsert, twipe = table.insert, table.wipe
-- WoW API / Variables
......@@ -13,103 +13,105 @@ local GetSpellInfo = GetSpellInfo
local C_AzeriteEmpoweredItem_GetPowerInfo = C_AzeriteEmpoweredItem.GetPowerInfo
local C_AzeriteEmpoweredItem_IsAzeriteEmpoweredItemByID = C_AzeriteEmpoweredItem.IsAzeriteEmpoweredItemByID
local C_AzeriteEmpoweredItem_GetAllTierInfoByItemID = C_AzeriteEmpoweredItem.GetAllTierInfoByItemID
local IsAddOnLoaded = IsAddOnLoaded
-- GLOBALS:
-- Credit: AzeriteTooltip, by jokair9
function MERTT:AzeriteArmor()
if not E.db.mui.tooltip.azerite then return end
local tipList = {}
local function scanTooltip(tooltip)
for i = 9, tooltip:NumLines() do
local line = _G[tooltip:GetName().."TextLeft"..i]
local text = line:GetText()
if text and strfind(text, "%- ") then
tinsert(tipList, i)
end
end
return #tipList
-- Credit: AzeriteTooltip, by jokair9. Ported from NDui by siweia
local tipList, powerList, powerCache, tierCache = {}, {}, {}, {}
local iconString = "|T%s:18:22:0:0:64:64:5:59:5:59"
local function getIconString(icon, known)
if known then
return format(iconString..":255:255:255|t", icon)
else
return format(iconString..":120:120:120|t", icon)
end
end
function MERTT:Azerite_ScanTooltip()
twipe(tipList)
twipe(powerList)
local iconString = "|T%s:18:22:0:0:64:64:5:59:5:59"
local function getIconString(icon, known)
if known then
return format(iconString..":255:255:255|t", icon)
else
return format(iconString..":130:130:130|t", icon)
for i = 9, self:NumLines() do
local line = _G[self:GetName().."TextLeft"..i]
local text = line:GetText()
local powerName = text and strmatch(text, "%- (.+)")
if powerName then
tinsert(tipList, i)
powerList[i] = powerName
end
end
end
local powerData = {}
local function convertPowerID(id)
local spellID = powerData[id]
if not spellID then
local powerInfo = C_AzeriteEmpoweredItem_GetPowerInfo(id)
if powerInfo and powerInfo.spellID then
spellID = powerInfo.spellID
powerData[id] = spellID
end
function MERTT:Azerite_PowerToSpell(id)
local spellID = powerCache[id]
if not spellID then
local powerInfo = C_AzeriteEmpoweredItem_GetPowerInfo(id)
if powerInfo and powerInfo.spellID then
spellID = powerInfo.spellID
powerCache[id] = spellID
end
return spellID
end
return spellID
end
local function lookingForAzerite(tooltip, powerName)
for i = 8, tooltip:NumLines() do
local line = _G[tooltip:GetName().."TextLeft"..i]
local text = line:GetText()
if text and strfind(text, "%- "..powerName) then
return true
end
end
function MERTT:Azerite_UpdateItem()
local link = select(2, self:GetItem())
if not link then return end
if not C_AzeriteEmpoweredItem_IsAzeriteEmpoweredItemByID(link) then return end
local allTierInfo = tierCache[link]
if not allTierInfo then
allTierInfo = C_AzeriteEmpoweredItem_GetAllTierInfoByItemID(link)
tierCache[link] = allTierInfo
end
if not allTierInfo then return end
local cache = {}
local function updateAzeriteArmor(self)
local link = select(2, self:GetItem())
if not link then return end
if not C_AzeriteEmpoweredItem_IsAzeriteEmpoweredItemByID(link) then return end
local allTierInfo = cache[link]
if not allTierInfo then
allTierInfo = C_AzeriteEmpoweredItem_GetAllTierInfoByItemID(link)
cache[link] = allTierInfo
end
if not allTierInfo then return end
local count = scanTooltip(self)
local index = 1
for i = 1, #allTierInfo do
local powerIDs = allTierInfo[i].azeritePowerIDs
if powerIDs[1] == 13 then break end
local tooltipText = ""
for _, id in ipairs(powerIDs) do
local spellID = convertPowerID(id)
if not spellID then break end
local name, _, icon = GetSpellInfo(spellID)
local found = lookingForAzerite(self, name)
if found then
tooltipText = tooltipText.." "..getIconString(icon, true)
else
tooltipText = tooltipText.." "..getIconString(icon)
end
end
MERTT.Azerite_ScanTooltip(self)
if #tipList == 0 then return end
if tooltipText ~= "" and count > 0 then
local lineIndex = tipList[index]
local line = _G[self:GetName()..'TextLeft'..lineIndex]
local index = 1
for i = 1, #allTierInfo do
local powerIDs = allTierInfo[i].azeritePowerIDs
if powerIDs[1] == 13 then break end
line:SetText(tooltipText)
_G[self:GetName()..'TextLeft'..lineIndex+1]:SetText('')
local lineIndex = tipList[index]
if not lineIndex then break end
count = count - 1
index = index + 1
local tooltipText = ""
for _, id in ipairs(powerIDs) do
local spellID = MERTT:Azerite_PowerToSpell(id)
if not spellID then break end
local name, _, icon = GetSpellInfo(spellID)
local found = name == powerList[lineIndex]
if found then
tooltipText = tooltipText.." "..getIconString(icon, true)
else
tooltipText = tooltipText.." "..getIconString(icon)
end
end
twipe(tipList)
if tooltipText ~= "" then
local line = _G[self:GetName().."TextLeft"..lineIndex]
if E.db.mui.tooltip.azerite.onlyIcons then
line:SetText(tooltipText)
_G[self:GetName().."TextLeft"..lineIndex+1]:SetText("")
else
line:SetText(line:GetText().."\n "..tooltipText)
end
end
index = index + 1
end
end
function MERTT:AzeriteArmor()
if not E.db.mui.tooltip.azerite.enable or IsAddOnLoaded("AzeriteTooltip") then return end
_G.GameTooltip:HookScript("OnTooltipSetItem", updateAzeriteArmor)
_G.ItemRefTooltip:HookScript("OnTooltipSetItem", updateAzeriteArmor)
_G.ShoppingTooltip1:HookScript("OnTooltipSetItem", updateAzeriteArmor)
_G.GameTooltip:HookScript("OnTooltipSetItem", MERTT.Azerite_UpdateItem)
_G.ItemRefTooltip:HookScript("OnTooltipSetItem", MERTT.Azerite_UpdateItem)
_G.ShoppingTooltip1:HookScript("OnTooltipSetItem", MERTT.Azerite_UpdateItem)
_G.EmbeddedItemTooltip:HookScript("OnTooltipSetItem", MERTT.Azerite_UpdateItem)
_G.GameTooltipTooltip:HookScript("OnTooltipSetItem", MERTT.Azerite_UpdateItem)
end
......@@ -52,20 +52,37 @@ local function Tooltip()
name = L["Keystone"],
desc = L["Adds descriptions for mythic keystone properties to their tooltips."],
},
azerite = {
order = 7,
type = "toggle",
name = L.HEART_OF_AZEROTH_MISSING_ACTIVE_POWERS,
},
titleColor = {
order = 8,
type = "toggle",
name = L["Title Color"],
desc = L["Change the color of the title in the Tooltip."],
},
nameHover = {
azerite = {
order = 10,
type = "group",
name = E.NewSign..L.HEART_OF_AZEROTH_MISSING_ACTIVE_POWERS,
guiInline = true,
hidden = function() return IsAddOnLoaded("AzeriteTooltip") end,
get = function(info) return E.db.mui.tooltip.azerite[info[#info]] end,
set = function(info, value) E.db.mui.tooltip.azerite[info[#info]] = value; end,
args = {
enable = {
order = 1,
type = "toggle",
name = L["Enable"],
set = function(info, value) E.db.mui.tooltip.azerite.enable = value; E:StaticPopup_Show("PRIVATE_RL"); end,
},
onlyIcons = {
order = 2,
type = "toggle",
name = L["Only Icons"],
},
},
},
nameHover = {
order = 11,
type = "group",
guiInline = true,
name = L["Name Hover"],
desc = L["Shows the Unit Name on the mouse."],
......@@ -102,9 +119,9 @@ local function Tooltip()
},
},
progressInfo = {
order = 12,
type = "group",
name = L["Progress Info"],
order = 11,
guiInline = true,
disabled = function() return not E.private.tooltip.enable end,
hidden = function() return IsAddOnLoaded("RaiderIO") end,
......
......@@ -426,7 +426,10 @@ MP.tooltip = {
petIcon = true,
factionIcon = true,
keystone = true,
azerite = true,
azerite = {
enable = true,
onlyIcons = false,
},
titleColor = true,
progressInfo = {
enable = true,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment