Skip to content

Commit

Permalink
feat(infobar): add tier charges into currency block
Browse files Browse the repository at this point in the history
  • Loading branch information
ffainy committed Mar 13, 2023
1 parent a11e9af commit f6263b5
Showing 1 changed file with 31 additions and 16 deletions.
47 changes: 31 additions & 16 deletions src/modules/infobar/currency.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,60 +6,72 @@ local currPvE = {
['Elemental Overflow'] = 2118, -- 元素涌流
['Storm Sigil'] = 2122, -- 风暴徽记
['Valor'] = 1191, -- 勇气点数
['Timewarped Badge'] = 1166 -- 时空扭曲徽章
['Timewarped Badge'] = 1166, -- 时空扭曲徽章
}
local currPvP = {
['Honor'] = 1792,
['Conquest'] = 1602,
}

local function AddIcon(texture)
local function addIcon(texture)
texture = texture and '|T' .. texture .. ':12:16:0:0:50:50:4:46:4:46|t ' or ''
return texture
end

local title
local function AddTitle(text)
local function addTitle(text)
if not title then
_G.GameTooltip:AddLine(' ')
_G.GameTooltip:AddLine(text, 0.6, 0.8, 1)

title = true
end
end

local function Block_OnEvent(self)
local function onEvent(self)
local info = C_CurrencyInfo.GetCurrencyInfo(currShow)
self.text:SetText(format('%s: |cffdf5ed9%s|r', info.name, BreakUpLargeNumbers(info.quantity)))
end

local function Block_OnMouseUp(self, btn)
local function onMouseUp(self, btn)
if btn == 'LeftButton' then
securecall(_G.ToggleCharacter, 'TokenFrame')
end
end

local function Block_OnEnter(self)
local function onEnter(self)
local anchorTop = C.DB.Infobar.AnchorTop
_G.GameTooltip:SetOwner(self, (anchorTop and 'ANCHOR_BOTTOM') or 'ANCHOR_TOP', 0, (anchorTop and -6) or 6)
_G.GameTooltip:ClearLines()
_G.GameTooltip:AddLine(_G.CURRENCY, 0.9, 0.8, 0.6)

title = false
local chargeInfo = C_CurrencyInfo.GetCurrencyInfo(2167) -- Tier charges
if chargeInfo then
addTitle('Tier Charges')

local iconTexture = ' |T' .. chargeInfo.iconFileID .. ':13:15:0:0:50:50:4:46:4:46|t'
_G.GameTooltip:AddDoubleLine(chargeInfo.name, chargeInfo.quantity .. '/' .. chargeInfo.maxQuantity .. iconTexture, 1, 1, 1, 1, 1, 1)
end

title = false
for _, id in pairs(currPvE) do
AddTitle('PvE')
addTitle('PvE')

local info = C_CurrencyInfo.GetCurrencyInfo(id)
local amount = format('|cff20ff20%s|r', BreakUpLargeNumbers(info.quantity))

_G.GameTooltip:AddDoubleLine(AddIcon(info.iconFileID) .. info.name, amount, 1, 1, 1)
_G.GameTooltip:AddDoubleLine(addIcon(info.iconFileID) .. info.name, amount, 1, 1, 1)
end

title = false
for _, id in pairs(currPvP) do
AddTitle('PvP')
addTitle('PvP')

local info = C_CurrencyInfo.GetCurrencyInfo(id)
local amount = format('|cff20ff20%s|r', BreakUpLargeNumbers(info.quantity))

_G.GameTooltip:AddDoubleLine(AddIcon(info.iconFileID) .. info.name, amount, 1, 1, 1)
_G.GameTooltip:AddDoubleLine(addIcon(info.iconFileID) .. info.name, amount, 1, 1, 1)
end

_G.GameTooltip:AddLine(' ')
Expand All @@ -68,7 +80,7 @@ local function Block_OnEnter(self)
_G.GameTooltip:Show()
end

local function Block_OnLeave(self)
local function onLeave(self)
F:HideTooltip()
end

Expand All @@ -79,10 +91,13 @@ function INFOBAR:CreateCurrencyBlock()

local cur = INFOBAR:RegisterNewBlock('currency', 'LEFT', 150)

cur.onEvent = Block_OnEvent
cur.onEnter = Block_OnEnter
cur.onLeave = Block_OnLeave
cur.onMouseUp = Block_OnMouseUp
cur.onEvent = onEvent
cur.onEnter = onEnter
cur.onLeave = onLeave
cur.onMouseUp = onMouseUp

cur.eventList = { 'PLAYER_ENTERING_WORLD', 'CURRENCY_DISPLAY_UPDATE' }
cur.eventList = {
'PLAYER_ENTERING_WORLD',
'CURRENCY_DISPLAY_UPDATE',
}
end

0 comments on commit f6263b5

Please sign in to comment.