Init
This commit is contained in:
28
Modules/HealthValue.lua
Normal file
28
Modules/HealthValue.lua
Normal file
@ -0,0 +1,28 @@
|
||||
local addon, ns = ...
|
||||
local T = ns.T
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- # MODULES > HEALTH VALUE
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
GameTooltipStatusBar:SetScript('OnValueChanged', function(self, value)
|
||||
if not value then return end
|
||||
local min, max = self:GetMinMaxValues()
|
||||
if (value < min) or (value > max) then return end
|
||||
|
||||
local _, unit = GameTooltip:GetUnit()
|
||||
if unit then
|
||||
min, max = UnitHealth(unit), UnitHealthMax(unit)
|
||||
if not self.text then
|
||||
self.text = self:CreateFontString(nil, 'OVERLAY')
|
||||
self.text:SetPoint('CENTER', GameTooltipStatusBar, 0, 1)
|
||||
self.text:SetFont(STANDARD_TEXT_FONT, 11, 'OUTLINE')
|
||||
self.text:SetShadowOffset(1,-1)
|
||||
end
|
||||
|
||||
self.text:Show()
|
||||
|
||||
local hp = T.ShortValue(min)..' / '..T.ShortValue(max)
|
||||
self.text:SetText(hp)
|
||||
end
|
||||
end)
|
57
Modules/SpellID.lua
Normal file
57
Modules/SpellID.lua
Normal file
@ -0,0 +1,57 @@
|
||||
local addon, ns = ...
|
||||
local L = ns.L
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- # MODULES > SPELLID
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
local function AddIDLine(self, id, isItem)
|
||||
for i = 1, self:NumLines() do
|
||||
local line = _G[self:GetName()..'TextLeft'..i]
|
||||
if not line then break end
|
||||
local text = line:GetText()
|
||||
if text and strfind(text, id) then return end
|
||||
end
|
||||
if isItem then
|
||||
self:AddLine('|cff1994ff'..L.ITEM_ID..' |cnWHITE_FONT_COLOR:'..id..'|r')
|
||||
else
|
||||
self:AddLine('|cff1994ff'..L.SPELL_ID..' |cnWHITE_FONT_COLOR:'..id..'|r')
|
||||
end
|
||||
self:Show()
|
||||
end
|
||||
|
||||
local function OnTooltipSetSpell(self)
|
||||
local _, id = self:GetSpell()
|
||||
if id then AddIDLine(self, id) end
|
||||
end
|
||||
|
||||
hooksecurefunc(GameTooltip, 'SetUnitAura', function(self, ...)
|
||||
local id = select(10, UnitAura(...))
|
||||
if id then AddIDLine(self, id) end
|
||||
if debuginfo == true and id and IsModifierKeyDown() then print(UnitAura(...)..': '..id) end
|
||||
end)
|
||||
|
||||
local function attachByAuraInstanceID(self, ...)
|
||||
local aura = C_UnitAuras.GetAuraDataByAuraInstanceID(...)
|
||||
local id = aura and aura.spellId
|
||||
if id then AddIDLine(self, id) end
|
||||
if debuginfo == true and id and IsModifierKeyDown() then print(UnitAura(...)..': '..id) end
|
||||
end
|
||||
|
||||
hooksecurefunc(GameTooltip, 'SetUnitBuffByAuraInstanceID', attachByAuraInstanceID)
|
||||
hooksecurefunc(GameTooltip, 'SetUnitDebuffByAuraInstanceID', attachByAuraInstanceID)
|
||||
|
||||
hooksecurefunc('SetItemRef', function(link)
|
||||
local id = tonumber(link:match('spell:(%d+)'))
|
||||
if id then AddIDLine(ItemRefTooltip, id) end
|
||||
end)
|
||||
|
||||
local function attachItemTooltip(self)
|
||||
local _, link = TooltipUtil.GetDisplayedItem(self)
|
||||
if not link then return end
|
||||
local id = link:match('item:(%d+):')
|
||||
if id then AddIDLine(self, id, true) end
|
||||
end
|
||||
|
||||
TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Spell, OnTooltipSetSpell)
|
||||
TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Item, attachItemTooltip)
|
100
Modules/Style.lua
Normal file
100
Modules/Style.lua
Normal file
@ -0,0 +1,100 @@
|
||||
local addon, ns = ...
|
||||
local L = ns.L
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
-- # MODULES > STYLE
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
-- hide
|
||||
ITEM_CREATED_BY = ''
|
||||
|
||||
-- unit colours
|
||||
local function GetColor(unit)
|
||||
if not unit then return end
|
||||
local r, g, b
|
||||
|
||||
if UnitIsPlayer(unit) then
|
||||
local _, class = UnitClass(unit)
|
||||
local color = (CUSTOM_CLASS_COLORS or RAID_CLASS_COLORS)[class]
|
||||
if color then
|
||||
r, g, b = color.r, color.g, color.b
|
||||
else
|
||||
r, g, b = 1, 1, 1
|
||||
end
|
||||
elseif UnitIsTapDenied(unit) or UnitIsDead(unit) then
|
||||
r, g, b = 0.6, 0.6, 0.6
|
||||
else
|
||||
local reaction = UnitReaction(unit, 'player')
|
||||
if reaction then
|
||||
r, g, b = FACTION_BAR_COLORS[reaction].r, FACTION_BAR_COLORS[reaction].g, FACTION_BAR_COLORS[reaction].b
|
||||
else
|
||||
r, g, b = 1, 1, 1
|
||||
end
|
||||
end
|
||||
|
||||
return r, g, b
|
||||
end
|
||||
|
||||
-- style
|
||||
local function UpdateTooltip(self)
|
||||
if self ~= GameTooltip or self:IsForbidden() then return end
|
||||
local lines = self:NumLines()
|
||||
local unit = (select(2, self:GetUnit())) or (GetMouseFocus() and GetMouseFocus().GetAttribute and GetMouseFocus():GetAttribute("unit")) or (UnitExists("mouseover") and "mouseover") or nil
|
||||
|
||||
if not unit then return end
|
||||
|
||||
local r, g, b = GetColor(unit)
|
||||
GameTooltipTextLeft1:SetTextColor(r, g, b)
|
||||
|
||||
-- status indicator
|
||||
if UnitIsAFK(unit) then
|
||||
self:AppendText((' %s'):format('|cffe7e716'..L.STATUS_AFK..'|r'))
|
||||
elseif UnitIsDND(unit) then
|
||||
self:AppendText((' %s'):format('|cffdd0000'..L.STATUS_DND..'|r'))
|
||||
end
|
||||
|
||||
-- guild name
|
||||
if GetGuildInfo(unit) then
|
||||
local guildName, guildRankName, _, _ = GetGuildInfo(unit)
|
||||
GameTooltipTextLeft2:SetFormattedText('|cff3Ce13f%s|r |cff1994ff[%s]|r', guildName, guildRankName)
|
||||
end
|
||||
|
||||
-- target
|
||||
if UnitExists(unit..'target') then
|
||||
|
||||
local rTarget, gTarget, bTarget
|
||||
if UnitIsPlayer(unit..'target') then
|
||||
local _, englishClass = UnitClass(unit..'target')
|
||||
rTarget, gTarget, bTarget = GetClassColor(englishClass)
|
||||
else
|
||||
local reaction = UnitReaction(unit, 'player')
|
||||
if reaction then
|
||||
rTarget, gTarget, bTarget= FACTION_BAR_COLORS[reaction].r, FACTION_BAR_COLORS[reaction].g, FACTION_BAR_COLORS[reaction].b
|
||||
end
|
||||
end
|
||||
|
||||
local text = ''
|
||||
|
||||
if UnitName(unit..'target') == UnitName('player') then
|
||||
text = '|cffee7d01'..TARGET..':|r '..'|cffff0000> '..UNIT_YOU..' <|r'
|
||||
else
|
||||
text = '|cffee7d01'..TARGET..':|r '..UnitName(unit..'target')
|
||||
end
|
||||
|
||||
self:AddLine(text, rTarget, gTarget, bTarget)
|
||||
end
|
||||
|
||||
-- statusbar
|
||||
GameTooltip:AddLine(' ') -- add empty line to make room for status bar
|
||||
GameTooltipStatusBar:ClearAllPoints()
|
||||
GameTooltipStatusBar:SetPoint('LEFT', 8, 0)
|
||||
GameTooltipStatusBar:SetPoint('RIGHT', -8, 0)
|
||||
GameTooltipStatusBar:SetPoint('BOTTOM', 0, 10)
|
||||
GameTooltipStatusBar:SetHeight(8)
|
||||
GameTooltipStatusBar:SetStatusBarTexture('Interface\\ChatFrame\\ChatFrameBackground')
|
||||
GameTooltipStatusBarTexture:SetVertexColor(r, g, b)
|
||||
|
||||
self:Show()
|
||||
end
|
||||
|
||||
TooltipDataProcessor.AddTooltipPostCall(Enum.TooltipDataType.Unit, UpdateTooltip)
|
Reference in New Issue
Block a user