Init
This commit is contained in:
		
							
								
								
									
										29
									
								
								Core/Functions.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										29
									
								
								Core/Functions.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,29 @@
 | 
			
		||||
local addon, ns = ...
 | 
			
		||||
local T = {}
 | 
			
		||||
ns.T = T
 | 
			
		||||
 | 
			
		||||
--------------------------------------------------------------------------------
 | 
			
		||||
-- # CORE > FUNCTIONS
 | 
			
		||||
--------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
T.ShortValue = function(value)
 | 
			
		||||
  if value >= 1e11 then
 | 
			
		||||
    return ('%.0fb'):format(value / 1e9)
 | 
			
		||||
  elseif value >= 1e10 then
 | 
			
		||||
    return ('%.1fb'):format(value / 1e9):gsub('%.?0+([km])$', '%1')
 | 
			
		||||
  elseif value >= 1e9 then
 | 
			
		||||
    return ('%.2fb'):format(value / 1e9):gsub('%.?0+([km])$', '%1')
 | 
			
		||||
  elseif value >= 1e8 then
 | 
			
		||||
    return ('%.0fm'):format(value / 1e6)
 | 
			
		||||
  elseif value >= 1e7 then
 | 
			
		||||
    return ('%.1fm'):format(value / 1e6):gsub('%.?0+([km])$', '%1')
 | 
			
		||||
  elseif value >= 1e6 then
 | 
			
		||||
    return ('%.2fm'):format(value / 1e6):gsub('%.?0+([km])$', '%1')
 | 
			
		||||
  elseif value >= 1e5 then
 | 
			
		||||
    return ('%.0fk'):format(value / 1e3)
 | 
			
		||||
  elseif value >= 1e3 then
 | 
			
		||||
    return ('%.1fk'):format(value / 1e3):gsub('%.?0+([km])$', '%1')
 | 
			
		||||
  else
 | 
			
		||||
    return value
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
							
								
								
									
										32
									
								
								Core/Localization.lua
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								Core/Localization.lua
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,32 @@
 | 
			
		||||
local addon, ns = ...
 | 
			
		||||
local L = {}
 | 
			
		||||
ns.L = L
 | 
			
		||||
 | 
			
		||||
--------------------------------------------------------------------------------
 | 
			
		||||
-- # CORE > LOCALIZATION
 | 
			
		||||
--------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
-- ## ENGLISH
 | 
			
		||||
--------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
L['STATUS_AFK'] = 'AFK'
 | 
			
		||||
L['STATUS_DND'] = 'DND'
 | 
			
		||||
L['SPELL_ID'] = 'Spell ID:'
 | 
			
		||||
L['ITEM_ID'] = 'Item ID:'
 | 
			
		||||
 | 
			
		||||
local locale = GetLocale()
 | 
			
		||||
if locale == 'en_GB' or locale == 'en_US' then return end -- ENGLISH
 | 
			
		||||
 | 
			
		||||
-- ## OTHER
 | 
			
		||||
--------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
-- if locale == 'esMX' then return end  -- SPANISH (MEXICO)
 | 
			
		||||
-- if locale == 'pt_BR' then return end -- PORTUGEUSE
 | 
			
		||||
-- if locale == 'de_DE' then return end  -- GERMAN
 | 
			
		||||
-- if locale == 'es_ES' then return end  -- SPANISH (SPAIN)
 | 
			
		||||
-- if locale == 'fr_FR' then return end  -- FRENCH
 | 
			
		||||
-- if locale == 'it_IT' then return end -- ITALIAN
 | 
			
		||||
-- if locale == 'ru_RU' then return end  -- RUSSIAN
 | 
			
		||||
-- if locale == 'ko_KR' then return end -- KOREAN
 | 
			
		||||
-- if locale == 'zh_TW' then return end  -- CHINESE (TRADITIONAL)
 | 
			
		||||
-- if locale == 'zh_CN' then return end  -- CHINESE (SIMPLIFIED)
 | 
			
		||||
							
								
								
									
										12
									
								
								KlazTooltip.toc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										12
									
								
								KlazTooltip.toc
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,12 @@
 | 
			
		||||
## Interface: 100205
 | 
			
		||||
## Title: Klaz|cff1994ffTooltip|r
 | 
			
		||||
## Author: Klaz
 | 
			
		||||
## Notes: Styles default tooltips.
 | 
			
		||||
## IconTexture: Interface\AddOns\KlazTooltip\Media\KlazAddOnIcon.blp
 | 
			
		||||
 | 
			
		||||
Core\Localization.lua
 | 
			
		||||
Core\Functions.lua
 | 
			
		||||
 | 
			
		||||
Modules\HealthValue.lua
 | 
			
		||||
Modules\SpellID.lua
 | 
			
		||||
Modules\Style.lua
 | 
			
		||||
							
								
								
									
										
											BIN
										
									
								
								Media/KlazAddOnIcon.blp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Media/KlazAddOnIcon.blp
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								Media/Screenshot_ItemID.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Media/Screenshot_ItemID.jpg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 59 KiB  | 
							
								
								
									
										
											BIN
										
									
								
								Media/Screenshot_SpellID.jpg
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								Media/Screenshot_SpellID.jpg
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 61 KiB  | 
							
								
								
									
										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