-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGeneral.lua
109 lines (101 loc) · 4.1 KB
/
General.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
local LibEvent = LibStub:GetLibrary("LibEvent.7000")
local DEAD = DEAD
local CopyTable = CopyTable
local addon = TinyTooltip
BigTipDB = {}
TinyTooltipCharacterDB = {}
local function ColorStatusBar(self, value)
if (addon.db.general.statusbarColor == "auto") then
local unit = "mouseover"
local focus
if _G["GetMouseFocus"] then
focus = GetMouseFocus()
else
focus = GetMouseFoci()
end
if (focus and focus.unit) then
unit = focus.unit
end
local r, g, b
if (UnitIsPlayer(unit)) then
r, g, b = GetClassColor(select(2,UnitClass(unit)))
else
r, g, b = GameTooltip_UnitColor(unit)
if (g == 0.6) then g = 0.9 end
if (r==1 and g==1 and b==1) then r, g, b = 0, 0.9, 0.1 end
end
self:SetStatusBarColor(r, g, b)
elseif (value and addon.db.general.statusbarColor == "smooth") then
HealthBar_OnValueChanged(self, value, true)
end
end
--LibEvent:attachEvent("VARIABLES_LOADED", function()
LibEvent:attachEvent("PLAYER_ENTERING_WORLD", function()
--CloseButton
if (ItemRefCloseButton and not IsAddOnLoaded("ElvUI")) then
ItemRefCloseButton:SetSize(14, 14)
ItemRefCloseButton:SetPoint("TOPRIGHT", -4, -4)
ItemRefCloseButton:SetNormalTexture("Interface\\Buttons\\UI-StopButton")
ItemRefCloseButton:SetPushedTexture("Interface\\Buttons\\UI-StopButton")
ItemRefCloseButton:GetNormalTexture():SetVertexColor(0.9, 0.6, 0)
end
--StatusBar
local bar = GameTooltipStatusBar
bar.bg = bar:CreateTexture(nil, "BACKGROUND")
bar.bg:SetAllPoints()
bar.bg:SetColorTexture(1, 1, 1)
bar.bg:SetVertexColor(0.2, 0.2, 0.2, 0.8)
bar.TextString = bar:CreateFontString(nil, "OVERLAY")
bar.TextString:SetPoint("CENTER")
bar.TextString:SetFont(NumberFontNormal:GetFont(), 11, "THINOUTLINE")
bar.capNumericDisplay = true
bar.lockShow = 1
bar:HookScript("OnShow", function(self)
ColorStatusBar(self)
end)
bar:HookScript("OnValueChanged", function(self, hp)
if (hp <= 0) then
local min, max = self:GetMinMaxValues()
self.TextString:SetFormattedText("|cff999999%s|r |cffffcc33<%s>|r", AbbreviateLargeNumbers(max), DEAD)
else
TextStatusBar_UpdateTextString(self)
end
ColorStatusBar(self, hp)
end)
bar:HookScript("OnShow", function(self)
if (addon.db.general.statusbarHeight == 0) then
self:Hide()
end
end)
--Variable
addon.db = addon:MergeVariable(addon.db, BigTipDB)
if (addon.db.general.SavedVariablesPerCharacter) then
local db = CopyTable(addon.db)
addon.db = addon:MergeVariable(db, TinyTooltipCharacterDB)
end
LibEvent:trigger("tooltip:variables:loaded")
--Init
LibEvent:trigger("TINYTOOLTIP_GENERAL_INIT")
--ShadowText
GameTooltipHeaderText:SetShadowOffset(1, -1)
GameTooltipHeaderText:SetShadowColor(0, 0, 0, 0.9)
GameTooltipText:SetShadowOffset(1, -1)
GameTooltipText:SetShadowColor(0, 0, 0, 0.9)
Tooltip_Small:SetShadowOffset(1, -1)
Tooltip_Small:SetShadowColor(0, 0, 0, 0.9)
end)
LibEvent:attachTrigger("tooltip:cleared, tooltip:hide", function(self, tip)
LibEvent:trigger("tooltip.style.border.color", tip, unpack(addon.db.general.borderColor))
LibEvent:trigger("tooltip.style.background", tip, unpack(addon.db.general.background))
if (tip.BigFactionIcon) then tip.BigFactionIcon:Hide() end
if (tip.SetBackdrop) then tip:SetBackdrop(nil) end
end)
LibEvent:attachTrigger("tooltip:show", function(self, tip)
if (tip ~= GameTooltip) then return end
LibEvent:trigger("tooltip.statusbar.position", addon.db.general.statusbarPosition, addon.db.general.statusbarOffsetX, addon.db.general.statusbarOffsetY)
local w = GameTooltipStatusBar.TextString:GetWidth() + 10
if (GameTooltipStatusBar:IsShown() and w > tip:GetWidth()) then
tip:SetMinimumWidth(w+2)
tip:Show()
end
end)